How in the world do you set up a GUI??

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.
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: How in the world do you set up a GUI??

Post by zhiayang »

Mano wrote:Well, I was looking for an easy way to change the video mode. On wiki there's a list of possible ways of doing it, and it's in order of dificulty. Because I'm using GRUB, interrupts won't do. So I decided to search how to patch Grub, and I've found a pre-built patched GRUB on this topic.

I downloaded the stage2_eltorito, replaced it, and changed my menu.lst file. All I did was actually to add a line after the kernel command:

Code: Select all

vbeset XXX
Where XXX is the hex value related to the mode you want. To find out which value to put, I just pressed C to enter grub's command line, and typed the command:

Code: Select all

vbeprobe
It worked for me at least. Anyway, I don't think this is really useful. I still think it's better to study and try to code my own vga driver.


Right. So now it says "Blackcomb ... lala" and "0x118: Direct colour, 1024x768x24". So I assume I did everything correctly? But when I get into my OS, it's still the console screen.
User avatar
Mano
Posts: 8
Joined: Mon Jan 09, 2012 4:52 am
Location: Brazil

Re: How in the world do you set up a GUI??

Post by Mano »

requimrar wrote: Right. So now it says "Blackcomb ... lala" and "0x118: Direct colour, 1024x768x24". So I assume I did everything correctly? But when I get into my OS, it's still the console screen.
I believe you replaced the stage2_eltorito, and that's why you're seeing the patched Grub screen. But, did you change your menu.lst file?

Here's how mine is:

Code: Select all

default=0
timeout=30
title MY_SO
foreground bbbbbb
background 000000
kernel /boot/kernel.bin root=/dev/hda2 
vbeset 0x146 #code for video mode obtained with vbeprobe command on GRUB command line.
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: How in the world do you set up a GUI??

Post by zhiayang »

Mano wrote:
requimrar wrote: Right. So now it says "Blackcomb ... lala" and "0x118: Direct colour, 1024x768x24". So I assume I did everything correctly? But when I get into my OS, it's still the console screen.
I believe you replaced the stage2_eltorito, and that's why you're seeing the patched Grub screen. But, did you change your menu.lst file?

Here's how mine is:

Code: Select all

default=0
timeout=30
title MY_SO
foreground bbbbbb
background 000000
kernel /boot/kernel.bin root=/dev/hda2 
vbeset 0x146 #code for video mode obtained with vbeprobe command on GRUB command line.

OHHHH... I just put 118. DERP. thanks.




EDIT: So this means that I need to restart to change graphics mode? Or is it possible to switch back to text mode?
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re: How in the world do you set up a GUI??

Post by bubach »

you should be able to get back to text mode without BIOS use, like:
http://bos.asmhackers.net/docs/vga_with ... _5/vga.php

becasue mode 0x3 is basic VGA and the same on all computers with VGA support. but that's a one time deal. no way to go back and forth between VGA and VESA modes unless using methods previously mentioned.
but it still might come in handy to have a mode switch for panic screens, just like the BSOD. :)
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: How in the world do you set up a GUI??

Post by Owen »

Switching back from a VBE mode to a VGA mode requires using the VBE BIOS (Some GPUs don't require it, but the only reliable method is to go through the BIOS)
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re: How in the world do you set up a GUI??

Post by bubach »

My bad, assumed stuff I shouldn't.
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
User avatar
DavidCooper
Member
Member
Posts: 1150
Joined: Wed Oct 27, 2010 4:53 pm
Location: Scotland

Re: How in the world do you set up a GUI??

Post by DavidCooper »

Owen wrote:Switching back from a VBE mode to a VGA mode requires using the VBE BIOS (Some GPUs don't require it, but the only reliable method is to go through the BIOS)
Could you clarify something about that please - when switching back from a VBE mode to a VGA mode, is there ever a problem with using the older BIOS method of selecting a VGA mode (al=0, ah=mode) as opposed to the VBE method where you make ax = 4f02h? When you refer to the VBE BIOS it sounds as if you may be ruling out the former method, though that's probably accidental as you are obviously focussed on making a point about using the BIOS as opposed to not using the BIOS).
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: How in the world do you set up a GUI??

Post by turdus »

Guys, guys... you are totally wrong.
First of all, there's no way to tell which mode will be set for a given vbe code on different machines (for resolutions introduced after 1994 at least). But you really should know it, because switching to text mode without VBE BIOS (using VGA registers) is only possible for certain modes (see RBIL Table 00080 bit 5, homework: find and read documentation). Owen is almost right, he's way is safer and bulletproof.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: How in the world do you set up a GUI??

Post by Combuster »

Owen wrote:Some GPUs don't require it
Not using the BIOS at all to disable a VBE mode will fail in the vast majority of cases. That is because all cards have separate registers that deal with bitfields beyond the VGA's capability, and none of the ones I have seen have a lucky "VGA compatible bit" within the VGA register file. Worse, some video cards share parts of the register files and in the worst case you can burn out your monitor or overclock your card to hell if you try.
because switching to text mode without VBE BIOS (using VGA registers) is only possible for certain modes
I.e., modes you don't need VBE for and a quality VGA driver can do on its own. Which essentially makes the BIOS a requirement for all realistic uses of VBE. :wink:

The official part is more interesting in that regard: VBE does not define a way to return to a legacy mode as those modes do not need to exist (the card may not be VGA). It does however declare that:
the 8-bit value returned by VGA BIOS Function 0Fh (it is up to the OEM to
define this number), must correctly reinitialize the graphics mode through VGA BIOS Function
00h.
In other words, the Video BIOS must be able to set a video mode with legacy function 0, and besides that, all DOS apps of old use just that function to get back to text mode before exiting. Technically you are still dealing with a VBE BIOS as a whole.
Last edited by Combuster on Wed Feb 01, 2012 2:15 pm, edited 1 time in total.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: How in the world do you set up a GUI??

Post by turdus »

Combuster wrote:Not using the BIOS at all to disable a VBE mode will fail in the vast majority of cases, and that is because all cards have separate registers that deal with bitfields beyond the VGA's capability, and none of the ones I have seen have a lucky "VGA compatible bit" within the VGA register file.
I can confirm that. Never saw any 32 bit lfb bigger than 1024x768 that had the bit set.
Yashas
Member
Member
Posts: 45
Joined: Sun Feb 05, 2012 5:19 am
Location: India
Contact:

Re: How in the world do you set up a GUI??

Post by Yashas »

May i know actually what do u want in GUI.Text,VideoMode,Bitmap or something else.Becaz i had made mine , i can give some bit of my code.
Unkn0wn1
Member
Member
Posts: 37
Joined: Fri Jan 13, 2012 11:18 am

Re: How in the world do you set up a GUI??

Post by Unkn0wn1 »

Preferably not CP'd from somewhere or other.

Seriously, I need a disk image of his OS. Just to laugh when it turns out he's lying...
Not sane
Just remember, FIND Is Not DOS :)
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: How in the world do you set up a GUI??

Post by zhiayang »

Unkn0wn1 wrote:Preferably not CP'd from somewhere or other.

Seriously, I need a disk image of his OS. Just to laugh when it turns out he's lying...
Indeed, indeed. But in that sense some source code would prove to be more useful. Also... I'm not one to discriminate based on someones age (I'm 16 anyway), but that guys only 13, and that's suspicious. I mean, if you have so much driver support, graphics etc, why would you need to copy the barebones keyboard driver?

Either way, back on topic;
so I get grub to switch modes okay,
but using the pixel plotting code from the wiki, I can't get anything on screen. I do remember once where I managed to get 2 random pixels on screen, but I can't reproduce it

What address do I give putpixel for the *screen pointer? The standard 0xB8000 (if I remember correctly), or what?

Also, what do the colours go by, is it the standard 0x00 to 0xFF or something else?


Ps: I don't mean to offend anyone, I'm just more on the cynical side...
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: How in the world do you set up a GUI??

Post by gerryg400 »

requimrar wrote:
Unkn0wn1 wrote:Preferably not CP'd from somewhere or other.

Seriously, I need a disk image of his OS. Just to laugh when it turns out he's lying...
Indeed, indeed. But in that sense some source code would prove to be more useful. Also... I'm not one to discriminate based on someones age (I'm 16 anyway), but that guys only 13, and that's suspicious. I mean, if you have so much driver support, graphics etc, why would you need to copy the barebones keyboard driver?

Either way, back on topic;
so I get grub to switch modes okay,
but using the pixel plotting code from the wiki, I can't get anything on screen. I do remember once where I managed to get 2 random pixels on screen, but I can't reproduce it

What address do I give putpixel for the *screen pointer? The standard 0xB8000 (if I remember correctly), or what?

Also, what do the colours go by, is it the standard 0x00 to 0xFF or something else?


Ps: I don't mean to offend anyone, I'm just more on the cynical side...
You get the frame_buf_ptr from the mode info block for the mode you choose. It's often near the top of the 32bit address space.
If a trainstation is where trains stop, what is a workstation ?
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: How in the world do you set up a GUI??

Post by zhiayang »

gerryg400 wrote:You get the frame_buf_ptr from the mode info block for the mode you choose. It's often near the top of the 32bit address space.
Yes, but that requires I be in real mode (at least according to the wiki); I'm using grub.
Post Reply