When i want to change the color , not all the new values are accepted. This is a sample code to reproduce the problem. The color pointed by the arrow should be white. You can use nasm to assemble the progam. The problem comes with vmware, bochs and real boot. This code is a part of my loader.
Note : i use direct setting of vga register , but when i use INT the problem comes to.
Code: Select all
; ***********************************************************************
; ***********************************************************************
; definition
%define _b byte
%define _w word
%define _d dword
; ***********************
; *************************************************************************
mov ax, cs ;
mov ds, ax ;
mov es, ax ;
mov ax, 0x0000 ;
mov ss, ax
mov sp, 0xFFFF
; VGA mode 640*480 16 colors
mov al, 0x12 ;
mov ah, 00 ;
int 10h
call synch
;******************************
; Palette colors
;mask
mov dx, 3c6h
mov al, 0ffh
out dx, al
; index 0
mov dx, 3c8h
mov al, 00
out dx, al
mov dx, 3c9h
;0
mov al, 00
out dx, al
mov al, 00
out dx, al
mov al, 00
out dx, al
;1
mov al, 35
out dx, al
mov al, 05
out dx, al
mov al, 07
out dx, al
;2
mov al, 21
out dx, al
mov al, 03
out dx, al
mov al, 04
out dx, al
;3
mov al, 37
out dx, al
mov al, 21
out dx, al
mov al, 23
out dx, al
;4
mov al, 01
out dx, al
mov al, 04
out dx, al
mov al, 05
out dx, al
;5
mov al, 63
out dx, al
mov al, 63
out dx, al
mov al, 63
out dx, al
;6
mov al, 63
out dx, al
mov al, 63
out dx, al
mov al, 63
out dx, al
;7
mov al, 00
out dx, al
mov al, 00
out dx, al
mov al, 63
out dx, al
;8
mov al, 63
out dx, al
mov al, 63
out dx, al
mov al, 63
out dx, al
;9
mov al, 63
out dx, al
mov al, 63
out dx, al
mov al, 63
out dx, al
; draw the bar
xor bx, bx
mov cx, 15
mov _b [colindex], 00
draw: inc bx
add _b [colindex], 1
call drawbar
loop draw
; drow arrow
mov cl, 10
mov ax, 308
mov bx, 326
call setpix
inc bx
call setpix
inc bx
call setpix
inc bx
call setpix
inc bx
call setpix
inc bx
call setpix
mov bx, 327
mov ax, 307
call setpix
add ax, 2
call setpix
mov bx, 328
mov ax, 306
call setpix
add ax, 4
call setpix
end:
;
; end of program
xor ah, ah
int 16h ; wait user hit keyboard
mov al, 0x02 ; restore video mode
mov ah, 00 ;
int 10h
mov ax, 4c00h ;end of program
int 21h
; *************************************************************************
; ***********************
; * FONCTIONS *
; *************************************************************************
;*************************************
;* drawBar
;* Dessine 8 de pixel dans la barre
;* de progression
;* BX : position
;* cl : color
;*************************************
drawbar:
pusha
mov ax, 10
mul bx
mov cx, 10
add ax, 241
trace: mov bx, 321
push cx
mov cl, [colindex]
call setpix
inc bx
call setpix
inc bx
call setpix
inc bx
call setpix
inc bx
call setpix
pop cx
inc ax
loop trace
popa
ret
;*************************************
;* synch
;* vertical synch
;*************************************
synch:
pusha
mov dx, 0x03da
S1:
in al, dx
test al, 08
jz S1
S2:
in al, dx
test al, 08
jnz S2
popa
ret
;*************************************
;*************************************
;* setpix
;* ax : x
;* bx : y
;* cl : color
;*************************************
setpix :
pusha
;push ds
;calcul de la position
push cx
push bx
push ax
mov ax, 0A000h
mov es, ax
;xor eax, eax ;
pop ax ;
mov bx, ax
shr ax, 3
and bx, 00000111b
pop cx ;
push ax ;
push bx ;
;pop bx ;
mov ax, 80
mul cx
pop cx ;
pop bx ;
add bx, ax ;
mov ax, 1000000010000000b
shr ax, cl
;mov cl, 01
mov cl, al
mov al, [es:bx] ;
mov dx, 3ceh
mov ax, 0205h
out dx, ax
mov ax, 0003h
out dx, ax
mov ah, cl
;mov ah, 01
mov al, 08
out dx, ax
pop cx
mov [es:bx], cl
;pop ds
popa
ret
;*************************************
; ***********************
; * DATA *
; *************************************************************************
colindex:
db 00