Author Topic: VESA Bank switching problem  (Read 17526 times)

David

  • Guest
VESA Bank switching problem
« on: February 07, 2010, 10:45:38 PM »
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.
Code: [Select]
;********************************************
;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

Offline Keith Kanios

  • Full Member
  • **
  • Posts: 383
  • Country: us
    • Personal Homepage
Re: VESA Bank switching problem
« Reply #1 on: February 08, 2010, 02:08:19 AM »
shl DX, 4 in switch_bank is erroneous. Unless otherwise noted, VGA/VESA banking works similar to other forms of segmentation, and thus should be selected linearly.

David

  • Guest
Re: VESA Bank switching problem
« Reply #2 on: February 08, 2010, 05:10:21 PM »
Should I delete the line then? Or change it?

David

David

  • Guest
Re: VESA Bank switching problem
« Reply #3 on: February 08, 2010, 05:32:54 PM »
It looks like just deleting it worked (At least on my PC's video card, I'll test it on other cards later).

Well, thanks a lot, Keith Kanios, it works now.

David