gpt4 book ai didi

assembly - 在MCGA BIOS文本模式下(AL = 03h)为背景提供16种颜色

转载 作者:行者123 更新时间:2023-12-04 17:08:59 25 4
gpt4 key购买 nike

MCGA支持4位色深,即16种颜色。但是,当我尝试打印所有这些颜色时,我只得到其中的前8种,其余8种仅是复制它们,如下图所示。可能是我在这里做错了还是全部是因为DOSBox?

代码(MASM,在DOSBox 0.74下):

TITLE   PROGRAM193
;----------------------------------------------------------
.MODEL SMALL
.STACK 64
.DATA
;----------------------------------------------------------
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX

MOV AX, 0600h ;AH = 06h (scroll up window)
; black (0)
MOV BH, 0Fh ;0 (black) background, F (white) text
MOV CX, 0000h ;upper line, left column
MOV DX, 004Fh ;finishing line, right column
INT 10h

; blue (1)
MOV BH, 1Fh
MOV CX, 0100h
MOV DX, 014Fh
INT 10h

; green (2)
MOV BH, 2Fh
MOV CX, 0200h
MOV DX, 024Fh
INT 10h

; cyan (3)
MOV BH, 3Fh
MOV CX, 0300h
MOV DX, 034Fh
INT 10h

; red (4)
MOV BH, 4Fh
MOV CX, 0400h
MOV DX, 044Fh
INT 10h

; magenta (5)
MOV BH, 5Fh
MOV CX, 0500h
MOV DX, 054Fh
INT 10h

; brown (6)
MOV BH, 6Fh
MOV CX, 0600h
MOV DX, 064Fh
INT 10h

; light gray (7)
MOV BH, 7Fh
MOV CX, 0700h
MOV DX, 074Fh
INT 10h

; -------------------------------
; | The problem starts up here... |
; -------------------------------
; dark gray (8)
MOV BH, 8Fh
MOV CX, 0800h
MOV DX, 084Fh
INT 10h

; light blue (9)
MOV BH, 9Fh
MOV CX, 0900h
MOV DX, 094Fh
INT 10h

; light green (A)
MOV BH, 0AFh
MOV CX, 0A00h
MOV DX, 0A4Fh
INT 10h

; light cyan (B)
MOV BH, 0BFh
MOV CX, 0B00h
MOV DX, 0B4Fh
INT 10h

; light red (C)
MOV BH, 0CFh
MOV CX, 0C00h
MOV DX, 0C4Fh
INT 10h

; light magenta (D)
MOV BH, 0DFh
MOV CX, 0D00h
MOV DX, 0D4Fh
INT 10h

; yellow (E)
MOV BH, 0EFh
MOV CX, 0E00h
MOV DX, 0E4Fh
INT 10h

; white (F)
MOV BH, 0F1h
MOV CX, 0F00h
MOV DX, 0F4Fh
INT 10h

MOV AX, 4C00h
INT 21h
MAIN ENDP
END MAIN

最佳答案

默认情况下,文本有16种颜色,背景只有8种颜色。
有一种方法可以获取所有16种背景颜色,这需要关闭“闪烁属性”。
这是可以做到的:

MAIN    PROC    FAR
MOV AX, @DATA
MOV DS, AX


; turn-off blinking attribute
MOV AX, 1003h
MOV BL, 00
INT 10h


MOV AX, 0600h ;AH = 06h (scroll up window)
; black (0)
MOV BH, 0Fh ;0 (black) background, F (white) text
MOV CX, 0000h ;upper line, left column
MOV DX, 004Fh ;finishing line, right column
INT 10h

; the rest of the magic...
结果如下所示:

关于assembly - 在MCGA BIOS文本模式下(AL = 03h)为背景提供16种颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28790368/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com