Page 1 of 1

VESA in Pmode?

Posted: Tue Aug 06, 2002 5:35 am
by Thunder
I've downloaded some Vesa 2.0 tutorials, but these commands works in real mode. >:(
Question, how can I change resolution in pmode (no v86 mode) and put pixel in the screen? ???

Re:VESA in Pmode?

Posted: Tue Aug 06, 2002 9:49 am
by matt
Well, first you have to set the video mode in real mode. (because it uses an iterrupt to set the video mode.)
;mov ax, 0x4F02
mov bx, 0x115
int 10h ;This sets the video mode ;This sets the vid mode
;to 800x600x32bpp

Plotting pixels is almost the same as in 13h EXCEPT the video memory is devided into 64k banks. This is still confusing me and I havn't been able to switch banks yet ;) But to switch banks in Pmode, you have to get a vesa pmode interface (while your in real mode because it uses interrupts). To get your vesa pmode interface and switch banks, try this code:

;IN REAL MODE
vesa_pmode_table dw
mov ax, 4f0ah
mob bl,0
int 10h

xor eax,eax
mov ax, es
shl eax,4
movzx edi,edi
mov eax,edi
mov [vesa_pmode_table],eax

PMODE!!!!!!!!!
mov ax,4f05h
mov bh,0
mov bl,THE_BANK_NUMBER_TO_SWITCHTO
zeroselector dw 0xFFFFF
mov es,[zeroselector] ;pointer to linear 0000000...
mov edx, [vesa_pmode_table]
movxz ecx,word ptr [es:edx]
call edx


to plot a pixel, use this
VIDEOMEMORY[800*y+x-BankNumber*banksize]=color
banksize is around 64kilobyets. Actually, its a bit higher because there are 1024 bytes in a kilobyte, so you will have to figgure out banksize on your own.

I'm not sure if that bank switching code will work though. I kinda had to make some modifications to it for it to compile, but it something crashes when I try it... Good luck figguring it out!

Re:VESA in Pmode?

Posted: Tue Aug 06, 2002 11:43 am
by Peter_Vigren
You can, in newer BIOS's, access a protected mode access point or something like that to use BIOS to set video mode in protected mode... it is descibed in a pdf-file for the VESA-standard... I'm not sure where to locate it though... But I think it must be possible to use the ports somehow... the tricky thing is to understand how and with what data...

Re:VESA in Pmode?

Posted: Tue Aug 06, 2002 1:22 pm
by .bdjames
In the VESA3 doc it says that you should scan the first
64k for the magic string, then copy that 32k block, clear
the vram listed from the block, then run the initialization
code in the block.

This is silly, not to mention the vesa pmode functions
are optional and none of the acceleration functions are
supported.

Not to mention that the vesa3 doc says that some newer
cards are not vga compatible.

I suggest looking into the svgalib for linux.

Re:VESA in Pmode?

Posted: Thu Aug 08, 2002 2:35 am
by klue
And how do you supose THAT works? just asking

Re:VESA in Pmode?

Posted: Thu Aug 08, 2002 3:03 am
by frank
humm....
I was thinking about reenabling int 0x10,
load the vesa mode
(0xA0000 was the videoaddress for vesa....,
now make that a linear adress)
and put the pixel..

Btw is it also possible to get to vesa without that interrupts?

Re:VESA in Pmode?

Posted: Thu Aug 08, 2002 7:06 am
by .bdjames
Well, the svgalib is built off the old vgalib. They just
extend the modes for each chipset. Check it out.

Re:VESA in Pmode?

Posted: Thu Aug 08, 2002 12:15 pm
by matt
frank wrote: humm....
I was thinking about reenabling int 0x10,
load the vesa mode
(0xA0000 was the videoaddress for vesa....,
now make that a linear adress)
and put the pixel..

Btw is it also possible to get to vesa without that interrupts?
Yes, you can but its so damn confusing :p the code I posted above *should* be able to switch banks in pmode, but I couldn't get it to work for my self ;) All the vesa crap is confusing because all the examples are written for programs you run under dos or something, not for making operating systems so it takes a lot of work to figgure out how to port it to your kernel.
I would suggesst you use a linear frame buffer so you don't have to switch banks, and to set the video mode, just jump back into real mode, set the video mode, then jump back to protected mode.