Reputation: 189
This is a basic DOSBox program that when executed will flip the screen from left to right. The program works fine. The only problem I am having is I am supposed to make all non-alphabetic characters be red on white. I don't have any trouble changing the color of non-alphabetic characters but I do not know the combination for binary red on white. I thought it was 11111100b but this makes the color red on grey and the characters blink on and off. Probably something very simple but I can't figure it out. Any suggestions?
MyCode SEGMENT
ASSUME CS:MyCode, DS:MyData
MainProg PROC
MOV AX, MyData
MOV DS, AX
MOV AX, 0B800h
MOV ES, AX
MOV BX, (25 * 160) ;BX contains value that equals row 25, column 0
loop25:
SUB BX, 160 ;Selects next row
CALL flipRow ;Flips that row
CMP BX, 0 ;Have all rows been flipped?
JNE loop25 ;if not, repeat
MOV AH, 4Ch
INT 21h
MainProg ENDP
flipRow PROC ;PROC will flip each rown on verticle axis
MOV DI, BX ;Puts row, column 0 in DI
ADD DI, 158 ;Adds 158 to DI to select right most character
MOV SI, BX ;Puts row, column 0 in SI
loopRow: ;loop until row is finished flipping
MOV AX, ES: [DI] ;AX points to right most character
MOV CX, ES: [SI] ;CX points to left most character
MOV ES: [DI], CX ;Put left most character into right most place
;-------------------------------------------------------------------------
CMP CL, 65
JL thenPart
CMP CL, 91
JL next
CMP CL, 97
JL thenPart ;Is the character Alphebetic? If not, color red on white
CMP CL, 123
JL next
CMP CL, 122
JG next
thenPart:
MOV ES: [DI + 1], BYTE PTR 00FCh
next:
;-------------------------------------------------------------------------
MOV ES: [SI], AX ;Put right most character in left most place
;-------------------------------------------------------------------------
CMP AL, 66
JL then2
CMP AL, 91
JL next2
CMP AL, 97
JL then2 ;Is the character Alphabetic? If not, color red on white
CMP AL, 123
JL next2
CMP AL, 122
JG next2
then2:
MOV ES: [SI + 1], BYTE PTR 01111100b
next2:
;-------------------------------------------------------------------------
DEC DI
DEC DI ;Move in left
INC SI
INC SI ;Move in right
CMP SI, DI ;Is the row completely flipped?
JL loopRow ;If not, repeat
RET
flipRow ENDP
MyCode ENDS
Upvotes: 0
Views: 3122
Reputation: 22457
The CGA/EGA/VGA screen adapter for which this color system was designed, had two distinctive text color modes.
In its default mode, the foreground color has a 'bright' bit -- the 3rd bit, where 2-1-0 are for RGB --, but this same bit in the 'background' part is 'blink'. So effectively you cannot have a 'bright' background.
The default setting can be changed with a low-level VIDEO interrupt:
AX = 1003h (operation code)
BL = 00h (enable bold background)
or BL = 01h (enable blinking)
INT 10h (execute operation)
(Ancient memory jogged ctsy. of http://webpages.charter.net/danrollins/techhelp/0140.HTM.)
Upvotes: 1