Hello everyone:
I am a new member here, with a question. The following code snippet doesn't seem to switch banks with the VESA standard. Could someone who know VESA tell me what's wrong with my code? It only draws on the top half the screen. (Because it isn't switching banks.) By the way I am using 640x480x8. That is 0x101 to call in hex.
;********************************************
;set_svga: Sets an SVGA resolution
;AX = Resolution to set.
;********************************************
set_svga:
push AX
push BX
mov BX, AX ;VBE Resolution.
mov AX, 0x4F02 ;Set VBE Mode.
int 0x10 ;Call BIOS interupt 0x10.
pop BX
pop AX
ret
;********************************************
;plot_svga_pixel: Plots an SVGA pixel.
;AX = X Coordinate.
;BX = Y Coordinate.
;CX = Color.
;********************************************
plot_svga_pixel:
push AX
push BX
push SI
mov SI, AX ;Store X coord in SI.
mov AX, BX ;AX = BX (Y coord).
mov BX, 640 ;Store Screen X Resolution in register BX.
mul BX ;Multiply AX (Y coord) by 640 (Screen X) DX = Bank.
add AX, SI ;Add SI (X coord) to AX (Y coord * ScreenX).
jnc .no_carry ;If the add went into a new bank, carry set.
inc DX ;Else bank (DX) = bank (DX) + 1.
.no_carry:
mov SI, AX ;mov ax (offset) to SI
cmp DX, DI ;Compare pixel's bank to the current bank.
jz .same ;If it's the same, don't set the bank.
mov DI, DX ;Else update bank.
call switch_bank
.same:
push DI
mov BX, 0xA000
mov ES, BX ;0xA000 to ES.
mov DI, SI ;Calculated offset to DI.
mov AX, CX
mov [ES:DI], AX ;Draw the pixel.
pop DI
pop SI
pop BX
pop AX
ret
switch_bank:
push AX
push BX
mov AX, 4F05h ;VESA switch bank.
xor BX, BX ;BX should be 0.
mov DX, DI ;DX = bank * 16.
shl DX, 4
int 10h
pop BX
pop AX
ret
Thanks in advance.
David