调色板不适用于 VGA 中的某些颜色

color palette not working on certain colors in VGA

我正在尝试在 DOSBox 上的汇编器中设置 VGA(640x480x16) 调色板,但特别是颜色 6、8-F 没有改变。我试过使用中断和直接通过端口都适用于其他颜色但不适用于其他颜色。我在默认配置上使用 DOSBox 0.74-3。这是我的代码

    setpalete MACRO index,r,g,b
            mov ax, 1010h
            mov bx, index
            mov ch, r
            mov cl, g
            mov dh, b
            int 10h
    ENDM
    Start:
        mov ax, 0A000h
        mov es, ax

        ;set video mode to 640x480 16 color ah=0 al=12h int 10h
        mov ax, 12h 
        int 10h

        setpalete 06h,030h,030h,030h

        mov dx, 03C4h ;dx = indexregister
        mov ah, 06h ;Color 
        mov al, 02h ;register select - map mask
        out dx, ax ;select the bitplanes.
        mov al, 0FFh
        mov di, 0
        mov cx,38400
        rep stosb

这里是使用端口设置托盘

setpalete MACRO index,r,g,b
    mov dx, 3c8h
    mov al, index
    out dx, al
    mov dx, 3c9h
    mov al, r
    out dx, al ; set R
    mov al, g
    out dx, al ; set G
    mov al, b
    out dx, al ; set B
ENDM

提前致谢

您的程序将 颜色寄存器 6 设置为某种灰色。您观察到的是,在 16 色视频模式 12h 中,调色板寄存器 6 映射到颜色寄存器 20 (14h)。所以宁愿改变颜色寄存器 20 (14h)。同样适用于调色板寄存器 8 (08h) 至 15 (0Fh)。

这里是调色板寄存器(颜色值)和颜色寄存器(你应该改变的DAC寄存器)之间的连接。所有十六进制数字:

0  1  2  3  4  5  6 7  8  9  A  B  C  D  E  F     palette register
0  1  2  3  4  5 14 7 38 39 3A 3B 3C 3D 3E 3F     color register

因此,例如,为了更新编号为 0Ah 的调色板寄存器中的颜色,您应该更改编号为 3Ah 的颜色寄存器。


此外,您的 setpalete 宏没有加载正确的 RGB 寄存器。这是正确的版本:

setpalete MACRO index,r,g,b
        mov bx, index
        mov dh, r
        mov ch, g
        mov cl, b
        mov ax, 1010h  ; BIOS.SetIndividualColorRegister
        int 10h
ENDM