DosBox how to fix character attribute?

纵饮孤独 提交于 2019-12-06 09:42:55

In the graphics video modes, the BL parameter for BIOS function 09h only defines the foreground color. It is always applied to a black background.

Below is my implementation of an extension of the functionality of this function. Now BL holds an attribute (foreground color and background color) just like in the text video modes.

only valid in a graphics video mode

; IN (al,bl,cx) OUT ()
EnhancedWriteCharacterWithAttribute:
    pusha
    mov     bh, 0            ;Display page 0
    mov     bp, bx
    push    ax
    shr     bl, 4            ;Get background color (high nibble)
    mov     ax, 09DBh        ;ASCII DBh is full block character
    int     10h              ;BIOS.WriteCharacterAndAttribute
    xor     bx, bp           ;Anticipate upcoming 'xor'
    and     bl, 15           ;Get foreground color (low nibble)
    or      bl, 128          ;Have BIOS 'xor' it
    pop     ax
    int     10h              ;BIOS.WriteCharacterAndAttribute
    popa
    ret

Use it like this:

mov     ax, 0012h ; BIOS.SetVideo 640x480x16
int     10h

mov     al, "1"   ; Character
mov     bl, 1Fh   ; Attribute
mov     cx, 80    ; Repetition count
call    EnhancedWriteCharacterWithAttribute

Take note

In the text video modes providing a large repetition count in CX can write the whole screen at once. This is not possible in the graphics video modes because BIOS will stop at the right edge of the screen.


You might want to read Displaying characters with DOS or BIOS for more on how to achieve your current and future goals.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!