;Copyright 2000 - Mark McDonald All rights reserved
; DECLARE: FUNCTION mkattr(BYVAL integer, BYVAL integer) AS INTEGER
; DESC:    Convert background and foreground colors into a single
;          attribute integer.
; EXAMP:   ColorAttribute = mkattr(ForeGround, Background)

MCODE Segment Byte
        Assume  CS: MCODE

        Public  mkattr

mkattr Proc     Far

ARG     BackGround: WORD, ForeGround: WORD = Retbytes

        push    BP                      ;
        mov     BP,SP                   ;
        push    CX                      ; preserve CX
        push    DX                      ;  and DX

        mov     AX,ForeGround           ; put foreground in AX
        cmp     AX,16                   ; is it less than 16?
        jb      NoBlink                 ; no, get background
        add     AX,112                  ; add 112 to it
NoBlink:
        mov     DX,BackGround           ; put background in DX
        mov     CL,4                    ; multiply * 16 by shifting
        shl     DL,CL                   ;  left 4 times
        add     AL,DL                   ; add foreground color
        xor     AH,AH                   ; clear AH

        pop     DX                      ; preserve DX
        pop     CX                      ;  and CX
        pop     BP                      ;
        retf    Retbytes                ;
mkattr EndP
MCODE EndS
        End