vesa bank switching

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
virusx

vesa bank switching

Post 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.
Slasher

Re:vesa bank switching

Post 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?
Perica
Member
Member
Posts: 454
Joined: Sat Nov 25, 2006 12:50 am

Re:vesa bank switching

Post by Perica »

..
Last edited by Perica on Tue Dec 05, 2006 9:28 pm, edited 1 time in total.
Slasher

Re:vesa bank switching

Post 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?
virusx

Re:vesa bank switching

Post 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
Slasher

Re:vesa bank switching

Post 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.
virusx

Re:vesa bank switching

Post by virusx »

ok,
I got it.

Thanks for all of your support.
ASHLEY4

Re:vesa bank switching

Post 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.
virusx

Re:vesa bank switching

Post 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,
Slasher

Re:vesa bank switching

Post 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)
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:vesa bank switching

Post 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 :)
virusx

Re:vesa bank switching

Post 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.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:vesa bank switching

Post 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".
ASHLEY4

Re:vesa bank switching

Post 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.
Post Reply