Vesa Graphics Programming

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
User avatar
gzaloprgm
Member
Member
Posts: 141
Joined: Sun Sep 23, 2007 4:53 pm
Location: Buenos Aires, Argentina
Contact:

Vesa Graphics Programming

Post by gzaloprgm »

Hi, I am new in this forum. I am currently making a small OS.

I have already read vesa mode tutorials.

I switch to 800*600*32 Vesa mode in my bootloader, using bios interruptions.

Then I load PMode and A20, and I load my kernel from floppy.

But I don't know how to do bank Switching in PMode, can anyone help me?

Otherwise if I write directly to the memory I can't write in the whole screen.

Please Help me!

Greetings

Gonzalo
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

Make your OS have memory management, task switching, and all of that. Don't even bother with the GUI until the OS can do that, and maybe load a binary file from a floppy.

A GUI is not an OS.
Translation: GUI != OS.

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
OrOS
Member
Member
Posts: 143
Joined: Sat Sep 08, 2007 11:26 pm
Location: Canada

Post by OrOS »

^ points up. My OS is completly built around a GUI, with the command line loading in that. You want to base it off of a gui instead of jumping right into a command shell, go for it. But he's right, you do need many other things for it to be an 'OS.' Don't lose your priorities.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Vesa Graphics Programming

Post by AJ »

gzaloprgm wrote: But I don't know how to do bank Switching in PMode, can anyone help me?
Hello,

I would suggest using a linear frame buffer instead of attempting to write in banks. To do this, set bit 14 of ax when you call function 0x4F02 and use the physical base pointer in the mode structure to determine where to write.

Your alternatives are:

* Use v86 mode for bank switching (slooooow!).
* Use the VBE protected mode interface, which is optional so you need to have some method of bank switching even if the entry point is not implemented in your BIOS.

Cheers,
Adam
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

As AJ as pointed out if you have LFB you should use that, but some cards even new ones, only have bank :x .
So in that case, there is away to change bank from PMode in some cards :shock: .
Now i have not tried it myself, but this code does work with some cards, it will also need moding to suite your OS.

Code: Select all

; bankswitch for S3 cards
; Modifying the set_bank -function is mostly enough
; for different Vesa 1.2 setups.


set_bank:

   cli
   cmp al,[0xfff2]
   je retsb
   mov [0xfff2],al
   push ax
   push dx
   mov ah,al
   mov dx,0x03D4
   mov al,0x39
   out dx,al
   inc dl
   mov al,0xA5
   out dx,al
   dec dl
   mov al,6Ah
   out dx,al
   inc dl
   mov al,ah
   out dx,al
   dec dl
   mov al,0x39
   out dx,al
   inc dl
   mov al,0x5A
   out dx,al
   dec dl
   pop dx
   pop ax
   
 retsb:
   
   ret
   
Also this may help, the site a bit slow though.
http://my.execpc.com/~geezer/os/slfb.asm
User avatar
gzaloprgm
Member
Member
Posts: 141
Joined: Sun Sep 23, 2007 4:53 pm
Location: Buenos Aires, Argentina
Contact:

Post by gzaloprgm »

piranha wrote:Make your OS have memory management, task switching, and all of that. Don't even bother with the GUI until the OS can do that, and maybe load a binary file from a floppy.
Thanks! I know that an OS is much more than a GUI, I just asked for vesa video modes, because I wanna make a Command Line Interface, but in vesa, so I can make high resolution console, use my other fonts, more colors, etcetera. The last thing I'll do is a GUI.

Thanks, I am now writing the switch part.
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

Well i also have a higher resolution console 90x60 to be precise with my own font, yet it is still in text mode and thus fast and very compatible (if your monitor supports it).

and piranha had a valid point. If you write you vesa commandline and font routines chances are you will have to rewrite them as your OS progresses.
Author of COBOS
Avarok
Member
Member
Posts: 102
Joined: Thu Aug 30, 2007 9:09 pm

Post by Avarok »

If I may guys,

He's saying (I think) he wants to switch the video mode while he's still in 16 bit mode. This is very sensible and rarely used. It allows you to avoid vm86 mode altogether.

So, he's trying to switch to a high resolution graphical video mode and then later when he gets around to writing the GUI, he'll actually start putting stuff on it.

As long as you have a means of debugging, kudos on ya m8. : p

I can't answer your question personally though.
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies.
- C. A. R. Hoare
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

This is very sensible and rarely used.
What makes you think it's rarely used? What are all those "Popping into real-mode and back" posts on the forums about then? ;)

Plus, GRUB can do this for you (if you ask it to).
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Avarok wrote:He's saying (I think) he wants to switch the video mode while he's still in 16 bit mode.
gzaloprgm wrote: I switch to 800*600*32 Vesa mode in my bootloader, using bios interruptions.
...

But I don't know how to do bank Switching in PMode, can anyone help me?
I interpret this as we are already in a VESA mode and PMode and now need to do bank switching (gzaloprgm isn't using a lfb).

I switch VESA modes using v86 and there is no reason why that is any less workable than switching while still in real mode (especially if you are using GRUB).

Cheers,
Adam[/quote]
Post Reply