![](/img/trans.png)
[英]INT 10h/ah=13h doesn't print strings when part of second stage bootloader
[英]INT 10h, AH=13h with colored background
我正在嘗試使用int 10h, AH=13h
function 在圖形模式下打印字符串,我得到BL
中的高位和低位對應背景和前景 colors 的值,但我就是做不到讓它工作。
例如,我試圖在白色背景上打印一串黑色文本,所以我寫了mov bl, 11110000b
或0f0h
,但它只將它讀取為0f0h
的前景色,而不是0fh
的背景和0
的前景. 有人知道為什么會這樣嗎?
BIOS.DisplayString function 13h無法顯示黑色以外的背景色。 尤其是在256色視頻模式下,BL中的屬性已經不能同時表示前景色和背景色,因為前景色設置已經占據了整個8位。
我已經編寫了一個程序,可以使用 16 個前景 colors 之一和 16 個背景 colors 之一在 256 色屏幕上顯示 ASCIIZ 字符串。該字符串的長度或它可以包含的內容(鈴,退格,制表符、換行、回車)。
盡管代碼對所有內容都使用 BIOS,但 DOSBox 會瞬間繪制整個屏幕。 如果這仍然不夠快,那么獲取一個指向字體的指針並直接寫入 A000:0000 處的屏幕。 您還必須自己管理 cursor。 我敢肯定它會更快,但我懷疑它是否重要......
ORG 256
mov ax, 0013h ; BIOS.SetVideo 320x200 256-color graphics screen
int 10h
mov si, msg1
mov bl, 0E2h ; GreenOnYellow
call WriteStringWithAttributeMode19
mov si, msg2
mov bl, 0F0h ; BlackOnWhite
call WriteStringWithAttributeMode19
mov ah, 00h ; BIOS.GetKeystroke
int 16h ; -> AX
mov ax, 0003h ; BIOS.SetVideo 80x25 16-color text screen
int 10h
ret
; ---------------------------
msg1: db 'This is a colourful text', 13, 10
db ' written on two lines ', 13, 10, 0
msg2: db '------------------------', 13, 10
db 879 dup 'Q', 0
; ---------------------------
; IN (bl,ds:si) OUT ()
WriteStringWithAttributeMode19:
pusha
mov bh, 0 ; Display page 0
mov bp, bx
jmps .d
.a: cmp al, 9
je .Tab
cmp al, 13
ja .b
mov cx, 1101_1010_0111_1111b
bt cx, ax
jnc .c ; 7,8,10,13 don't need the color
.b: mov bx, bp
mov dl, bl
shr dl, 4 ; Get background color (high nibble)
and bl, 15 ; Get foreground color (low nibble)
xor bl, dl
mov ah, 0Eh
int 10h ; BIOS.Teletype
mov ah, 03h
int 10h ; BIOS.GetCursor -> CX DX
dec dl ; Column is [0,39]
jns :1
mov dl, 39
dec dh
:1: movzx cx, dl ; Column -> X
shl cx, 3
movzx dx, dh ; Row -> Y
shl dx, 3
mov bx, bp
shr bl, 4 ; Get background color (high nibble)
:2: mov ah, 0Dh ; BIOS.ReadPixel
int 10h ; -> AL
xor al, bl
mov ah, 0Ch ; BIOS.WritePixel
int 10h
inc cx ; X++
test cx, 7
jnz :2
sub cx, 8
inc dx ; Y++
test dx, 7
jnz :2
jmp .d
.c: mov ah, 0Eh
int 10h ; BIOS.Teletype
.d: lodsb
test al, al
jnz .a
popa
ret
.Tab: mov cx, 1 ; Start displaying colored space(s)
mov bx, bp
shr bl, 4 ; Get background color
mov ax, 0EDBh ; ASCII DBh is full block character
int 10h ; BIOS.Teletype
mov ah, 03h
int 10h ; BIOS.GetCursor -> CX DX
test dl, 7
jnz .Tab ; Column not yet multiple of 8
jmps .d
; ----------------------------
您可以在WriteStringWithAttributeGVM過程中找到 16 色圖形屏幕的類似代碼,該過程是Displaying characters with DOS or BIOS的一部分。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.