Assembly Language Help (alang.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Colors
◄Map► ◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
;* Colors - Alters screen colors within a specified area by using bit
;* or move operations on display attribute bytes in video memory.
;*
;* Shows: Instructions - not rol ror and xor or
;*
;* Params: Logic - Code number, 0 = NOT 2 = ROR 4 = XOR 6 = MOV
;* 1 = ROL 3 = AND 5 = OR
;* Attr - Attribute mask
;* Row1 - Row at top of window
;* Col1 - Column at left edge of window
;* Row2 - Row at bottom of window
;* Col2 - Column at right edge of window
;*
;* Return: None
Colors PROC USES ds si,
Logic:WORD, Attr:WORD, Row1:WORD, Col1:WORD, Row2:WORD, Col2:WORD
GetVidOffset Row1, Col1 ; Get offset in video segment
inc ax
mov si, ax ; SI = offset for 1st attr byte
mov bx, Row2
sub bx, Row1
inc bx ; BX = number of window rows
mov cx, Col2
sub cx, Col1
inc cx ; CX = number of columns
mov ds, vconfig.sgmnt ; DS = video segment
mov ax, Attr ; AL = mask for and, xor, and or
.REPEAT
push si ; Save ptr to start of line
push cx ; and number of columns
; Disable CGA video prior to memory access to avoid screen snow. (See the
; WinOpen and StrWrite procedures for further discussions on CGA snow.)
.IF vconfig.adapter == CGA ; If CGA adapter:
INVOKE DisableCga ; Yes? Disable video
.ENDIF
cmp Logic, 1 ; Rotate left?
jl c_not ; If less, do NOT
je c_rol ; If equal, do ROL
cmp Logic, 3 ; And?
jl c_ror ; If less, do ROR
je c_and ; If equal, do AND
cmp Logic, 5 ; Or?
jl c_xor ; If less, do XOR
je c_or ; If equal, do OR
c_mov:
mov BYTE PTR [si], al ; MOV attr parameter
add si, 2 ; into attribute byte
loop c_mov
jmp c_done
c_or:
or BYTE PTR [si], al ; OR with attr parameter
add si, 2
loop c_or
jmp c_done
c_xor:
xor BYTE PTR [si], al ; XOR with attr parameter
add si, 2
loop c_xor
jmp c_done
c_and:
and BYTE PTR [si], al ; AND with attr parameter
add si, 2
loop c_and
jmp c_done
c_ror:
ror BYTE PTR [si], 1 ; Rotate right 1 bit
add si, 2
loop c_ror
jmp c_done
c_rol:
rol BYTE PTR [si], 1 ; Rotate left 1 bit
add si, 2
loop c_rol
jmp c_done
c_not:
not BYTE PTR [si] ; Flip bits
add si, 2
loop c_not
c_done:
.IF vconfig.adapter == CGA ; If CGA:
INVOKE EnableCga ; Reenable CGA video
.ENDIF
pop cx ; Recover number of columns
pop si ; Recover offset for start of line
add si, 160 ; Point to start of next line
dec bx ; Decrement row counter
.UNTIL zero? ; Loop while rows remain
ret
Colors ENDP
-♦-