I need to print a full sentence on screen with the ah
, 09h technique. I don't now why it doesn't show up on screen.
message db 'game over, to play again press y$'
PROC GAMEOVER
push dx
call cleanscreen
mov dx, offset message
mov ah,9h
int 21h
mov ah,0
int 16h
cmp al, 'y'
jne line
CALL STARTGAME
line:
pop dx
RET
ENDP GAMEOVER
proc cleanscreen ; cleans the screen
push cx
push bx
mov cx,4000d
mov bx,0
clean:
mov [byte ptr es:bx],0
inc bx
loop clean
pop bx
pop cx
ret
endp cleanscreen
CodePudding user response:
Look at the cleanscreen proc:
proc cleanscreen ; cleans the screen push cx push bx mov cx,4000d mov bx,0 clean: mov [byte ptr es:bx],0 inc bx loop clean pop bx pop cx ret endp cleanscreen
The screen is setup for the 80x25 16-color text mode. When you clear the screen storing all zeroes in it, it means that all the character cells get filled with ASCII code 0 (which is a space character) and attribute 00h (which is BlackOnBlack). The important thing here is that the DOS.PrintString function 09h does not care about the attributes already present on the screen, and neither does it output any new color information. Thus the characters of your text get written to screen fine but you don't get to see any of it because of the black foreground color and the black background color.
Write the proc this way:
proc cleanscreen ; cleans the screen
push ax
push cx
push di
mov ax, 0720h ; WhiteOnBlack space character
mov cx, 2000 ; 80*25
xor di, di
rep stosw ; write CX words starting at [es:di]
pop di
pop cx
pop ax
ret
endp cleanscreen