Page 1 of 1

vesa bank switching

Posted: Thu Apr 22, 2004 7:39 pm
by virusx
hi,
Can anybody suggest be the correct way to switch bank.
I tried to use funk 05h real mode.
How to do in protected mode.

Re:vesa bank switching

Posted: Thu Apr 22, 2004 7:57 pm
by Slasher
2 options
1. Switch to real mode and use the Vesa Bios funtion either through Int 10h or direct call ( not too good. but only doing this when the ban changes improves things)
2. Use a V86 task. better than switching to real mode

The best is to use VESA 2.0 and LFB modes.
Does any one have better ideas?

Re:vesa bank switching

Posted: Thu Apr 22, 2004 8:19 pm
by Perica
..

Re:vesa bank switching

Posted: Thu Apr 22, 2004 8:44 pm
by Slasher
Isn't the protected mode bank switching function dependent on VESA 2.0+ support? (correct me if I'm wrong)
Instead of using that why not use the LFB modes?

Re:vesa bank switching

Posted: Thu Apr 22, 2004 9:43 pm
by virusx
Code Slasher wrote: Isn't the protected mode bank switching function dependent on VESA 2.0+ support? (correct me if I'm wrong)
Yes it needs 2.0+ support. Do you have some examples how to use linear frame buffer.

thanks

Re:vesa bank switching

Posted: Thu Apr 22, 2004 9:54 pm
by Slasher
I dont have any code yet, but basically you use the VESA Function that gets VIDEO MODE INFORMATION for the mode you want to use and then in the structure that it generates there is a field that hold the Physical address of the Liner Frame Buffer. It is a 32bit address which you can just write to if you are not using paging or map to a linear address of your choice and use the linear address once paging is on.
Its best to read the VBE3.pdf file for the full details.

Re:vesa bank switching

Posted: Thu Apr 22, 2004 10:48 pm
by virusx
ok,
I got it.

Thanks for all of your support.

Re:vesa bank switching

Posted: Fri Apr 23, 2004 12:08 am
by ASHLEY4
Here is code for vesa bank swiching (real-mode)

Code: Select all

mov ax,4f02h? ;set vesa 1.0 screen mode
mov bx,101h? ;640*480*256
int 10h

mov dx,0xa000
mov ds,dx? ? ? ? ? ? ? ;sets up registers
call window
rain:
xor dx,dx? ? ? ;(pages-1)

mouse:
push dx
call window
xor bx,bx
mov al, 0cch
call dog
pop dx
cmp dx,4
je rain
inc dx
mov ah,01h
int 16h
jz mouse

mov ax,0003h
int 10h

mov ax,4c00h? ? ? ; This is just 
int 21h? ? ? ? ? ? ? ? ; for test ,take it out in your OS

window:
mov ax,4f05h? ? ;vesa 1 window select
mov bx,0
int 10h? ? ? ? ;dx is? the reqired window
xor bx,bx
ret

dog:? ? ? ? ;(4*2^16)+45056 pixels
mov [bx],al
inc bx
cmp bx,$00000
jne dog
ret
I also have code for vesa 2 linear,For seting up 640x480x24bpp,If you need it ?.

ASHLEY4.

Re:vesa bank switching

Posted: Fri Apr 23, 2004 12:22 am
by virusx
Thanks,

but i am confused when to switch bank.
I switch bank after 64k mem in a000 is full. But how to know which bank to switch.
I did it like this.

Code: Select all

             offset = (HRES * y) +  x;
   banksize = (modeinfo.wingranularity) * 1024;
   bankno = offset / banksize;
   offset = offset % banksize;

   set_bank(bankno); /* this does a bank switch to bankno */

   SVGA[offset] = c_color;
But it will be very slow since i have to switch in every pixel plot.
ASHLEY4 wrote:
I also have code for vesa 2 linear,For seting up 640x480x24bpp,If you need it ?.

ASHLEY4.
please,

Re:vesa bank switching

Posted: Fri Apr 23, 2004 12:36 am
by Slasher
No, you dont switch on every pixel
You should store the current bank number (initially it will be zero) in a variable say _bnumber. THen when you calculate the bank number for the pixel you are about to draw compare it to _bnumber. If they are diffent then you switch banks to the new bank number and update _bnumber to the new bank number. if they are the same,just plot the pixel. so if the window gran is 64k you switch only on every 64k pixels (well average is close to that)

Re:vesa bank switching

Posted: Fri Apr 23, 2004 2:39 am
by Pype.Clicker
iirc, VBE2 has a pmode interface for bank switching (which should be a bit better supported than VBE3's full pmode interface :)

Re:vesa bank switching

Posted: Sun Apr 25, 2004 4:26 am
by virusx
hi,
I found some tutor saying.

"Also, note that attempting to use SVGA with real-mode or *16-bit protected-mode code* will be almost impossible as it is so slow due to the 64k segment size limit. Only 32-bit programs should use SVGA."

http://www.sylpher.com/dosuser/dosgames.htm

is it correct.

Re:vesa bank switching

Posted: Sun Apr 25, 2004 2:47 pm
by Pype.Clicker
well, 'realmode' programs will indeed have hard time using 1600x1200x32bpp with a 64KB window ... however, if you have no choice, you have no choice ;)

I would rather say this by "if you fear about performance penalties of window switching, do your stuff in protected/unreal mode".

Re:vesa bank switching

Posted: Sun Apr 25, 2004 5:53 pm
by ASHLEY4
Also if you must use it (Vesa1 banked) :'( , Design your gui to use as many X movements and not as many Y movements.
eg: Take a game, If i shoot across the screen, It's the same speed if it's a bank or linear, But if i shoot up the screen its slower, With banked than linear.
I know this is not always possible, But keep it in mined ;).

ASHLEY4.