I'm trying to set the VGA(640x480x16) color palette in assembler on DOSBox but specifically colors 6, 8-F don't change. I have tried using interrupts and directly through ports both work for other colors but not for those. I'm using DOSBox 0.74-3 on default config. Here is my code
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
and here is setting the pallet using ports
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
thanks in advance
Your program sets color register 6 to some gray color. What you observe is that in the 16-color video mode 12h, palette register 6 is mapped to color register 20 (14h). So rather change color register 20 (14h). Same applies for the palette registers 8 (08h) to 15 (0Fh).
Here is the connection between the palette register (the color value) and the color register (DAC register which you should change). All numbers in hex:
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
So, for example, in order to update the color in palette register number 0Ah you should make the change in color register number 3Ah.
Also, your setpalete macro does not load the correct RGB registers. This is the correct version:
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