DosBox如何修复字符属性? [英] DosBox how to fix character attribute?
问题描述
我编写汇编代码只是为了编写一个具有蓝色背景和白色前景的字符.它可以在emu8086的模拟器中使用,但是当我在DosBox上打开它时,它不会显示背景色.
I wrote my assembly code just to write a character with a blue background and white foreground. It works in emu8086's emulator but when I open it on DosBox it does not show the background color.
使用Emu8086:
With Emu8086:
使用DosBox:
With DosBox:
mov ax,0012h
int 10h
mov ah,9
mov al,31h
mov bl,1fh
int 10h
推荐答案
在图形视频模式下,BIOS功能09h的BL
参数仅定义前景色.它始终应用于黑色背景.
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.
下面是我对该功能功能扩展的实现.现在BL
拥有一个属性(前景色和背景色),就像在文本视频模式下一样.
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.
仅在图形视频模式下有效
; 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
像这样使用它:
mov ax, 0012h ; BIOS.SetVideo 640x480x16
int 10h
mov al, "1" ; Character
mov bl, 1Fh ; Attribute
mov cx, 80 ; Repetition count
call EnhancedWriteCharacterWithAttribute
记笔记
在CX
中提供大量重复计数的文本视频模式下,可以一次写入整个屏幕.在图形视频模式下,这是不可能的,因为BIOS将停止在屏幕的右边缘.
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.
您可能想阅读使用DOS或BIOS显示字符以了解更多信息关于如何实现当前和未来目标的信息.
You might want to read Displaying characters with DOS or BIOS for more on how to achieve your current and future goals.
这篇关于DosBox如何修复字符属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!