NondairyDig
NondairyDig

Reputation: 1

Why background color not changing

clear_screen proc NEAR
    mov ah, 00h ;set config to video mode
    mov al, 13h ;choose video mode
    int 10h ; start config

    mov ah, 0Bh ;set config to background color
    mov bh, 00h ;same
    mov bl, 0Ch ;light red as background color
    int 10h ; start config

    ret
clear_screen ENDP

That's my procedure for clearing the screen for a pong game in assembly and it's not changing the background color to light red. pls help

Upvotes: 0

Views: 308

Answers (2)

3ud4jm0nj4
3ud4jm0nj4

Reputation: 1

the emulator and windows command line prompt do not support background blinking, however to make colors look the same in dos and in full screen mode it is required to turn off the background blinking.

; use this code for compatibility with dos/cmd prompt full screen mode: 
mov     ax, 1003h
mov     bx, 0   ; disable blinking. 
int     10h

Upvotes: 0

Brendan
Brendan

Reputation: 37232

For text mode; the "int 0x10, ah=0x0B, bh=0x00" function only sets the border color (not the background color). For modern computers the contents of the frame buffer fill the screen, so you can't see any border color and it'd look like the function did nothing.

To set the background (while clearing the screen) you have at least 2 choices:

  • use "int 0x10, ah=0x06" to scroll the whole screen up by 25 lines, where bh will contain whatever attribute you want (both foreground and background color).

  • do it yourself without BIOS (it can be done with little more than a rep stosw or rep stosd). This is likely to be faster than using BIOS.

Upvotes: 2

Related Questions