Some VBE documentation or example?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
CPPOS
Posts: 3
Joined: Tue Jun 30, 2015 1:01 pm

Some VBE documentation or example?

Post by CPPOS »

Hi forum. I'm a new member.

I'm developing a Real Mode Simple GUI OS for hobby in C++

In normal VGA i have only 320x200 and 256 color support.

I tried my VBE driver get it to work, but i couldn't.

I need an example for VBE or a better SVGA driver.

Can anyone make and share a very simple OS in C++ only including VBE driver (Setmode, Putpixel, Getpixel, etc...) and an example?

Thanks. I really really need it. Please.

:)
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Some VBE documentation or example?

Post by Brendan »

Hi,
CPPOS wrote:Can anyone make and share a very simple OS in C++ only including VBE driver (Setmode, Putpixel, Getpixel, etc...) and an example?
It's not possible. The calling conventions that the BIOS (and VBE) use are different, so you need to use assembly and therefore it can't be done with C++ only. I'm also not aware of any C++ compiler that's capable of generating code that works in real mode (excluding ancient/obsolete compilers from last century, but even those probably require DOS).

Also note that for higher resolution/SVGA modes you typically want to use a linear frame buffer so you can access all of the pixels without messy and slow bank switching, and this can't be done in real mode (the address of the linear frame buffer is always too high to reach with real mode addressing). For acceptable performance you'd also want a buffer in RAM (which will cost more memory than you can access in real mode for all but saddest video modes). Note: It is possible to switch between (e.g.) real mode and protected mode; where almost all of your code runs in 32-bit protected mode (and you only switch back to real mode to use the BIOS). This solves most of the problems with limited addressing/memory while also making it so you can use modern compilers, but means you're not using real mode.

Finally, "Getpixel" should never be used for anything ever (reading from display memory is very slow), and "Putpixel" should probably also never be used (it's far faster to use higher level primitives like "PutCharacter", "PutLine", "Put Rectangle", etc).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
CPPOS
Posts: 3
Joined: Tue Jun 30, 2015 1:01 pm

Re: Some VBE documentation or example?

Post by CPPOS »

Brendan wrote:Hi,
CPPOS wrote:Can anyone make and share a very simple OS in C++ only including VBE driver (Setmode, Putpixel, Getpixel, etc...) and an example?
It's not possible. The calling conventions that the BIOS (and VBE) use are different, so you need to use assembly and therefore it can't be done with C++ only. I'm also not aware of any C++ compiler that's capable of generating code that works in real mode (excluding ancient/obsolete compilers from last century, but even those probably require DOS).

Also note that for higher resolution/SVGA modes you typically want to use a linear frame buffer so you can access all of the pixels without messy and slow bank switching, and this can't be done in real mode (the address of the linear frame buffer is always too high to reach with real mode addressing). For acceptable performance you'd also want a buffer in RAM (which will cost more memory than you can access in real mode for all but saddest video modes). Note: It is possible to switch between (e.g.) real mode and protected mode; where almost all of your code runs in 32-bit protected mode (and you only switch back to real mode to use the BIOS). This solves most of the problems with limited addressing/memory while also making it so you can use modern compilers, but means you're not using real mode.

Finally, "Getpixel" should never be used for anything ever (reading from display memory is very slow), and "Putpixel" should probably also never be used (it's far faster to use higher level primitives like "PutCharacter", "PutLine", "Put Rectangle", etc).


Cheers,

Brendan
Thanks for your post.

I was using Turbo C++ compiler runs in dos, real mode.
Okay, how to make a Simple SVGA OS in C++ and Assembly?
CPPOS
Posts: 3
Joined: Tue Jun 30, 2015 1:01 pm

Re: Some VBE documentation or example?

Post by CPPOS »

I found a resource: http://www.brokenthorn.com/Resources/OSDevVid2.html
But i couldn't understand it.
It requires some functions not in tutorial.
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: Some VBE documentation or example?

Post by Roman »

CPPOS wrote:I found a resource: http://www.brokenthorn.com/Resources/OSDevVid2.html
But i couldn't understand it.
It requires some functions not in tutorial.
I've looked through that. It tells you to use BIOS interrupts, doesn't it?
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Some VBE documentation or example?

Post by Brendan »

Hi,
CPPOS wrote:I was using Turbo C++ compiler runs in dos, real mode.
Yes - an ancient C++ compiler from 25 years ago that won't even run on modern systems (e.g. with 64-bit Windows) and probably has to be used inside an emulator like DOSbox.
CPPOS wrote:Okay, how to make a Simple SVGA OS in C++ and Assembly?
You probably want to start with reading these pages, in order:
Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
freecrac
Member
Member
Posts: 69
Joined: Thu Sep 20, 2012 5:11 am
Location: germany hamburg

Re: Some VBE documentation or example?

Post by freecrac »

Hello.
Some puplic and costfree documents from vesa.org (need register/login):
vbe3.pdf
EEDIDguideV1.pdf
EEDIDverifGuideRa.pdf

But wihin DOSbox we can only use outdated VBE modenumbers from VBE 1.x, but not the modenumbers of a VBE2 or VBE3 bios from a modern display device, example for to switch into a widescreen resolution of 1920x1200 (16:10 aspect ratio).

In the simplest form for to access the linear framebuffer we can additional use the 16 bit big-realmode.
https://en.wikipedia.org/wiki/Unreal_mode
To put an 80386 or higher microprocessor into unreal mode, a program must first enter protected mode, find or create a flat descriptor in the GDT or LDT, load some of the data segment registers with the respective protected mode "selector", and then switch back to real mode. After returning to real mode, the processor will continue using the cached descriptors as established in protected mode, thus allowing access to 4 GiB of "extended" memory from real mode.
Bresenham line routine for the linear framebuffer with 8 bpp
http://board.flatassembler.net/topic.php?t=16530

Dirk
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: Some VBE documentation or example?

Post by Muazzam »

CPPOS wrote:Hi forum. I'm a new member.
You're welcome.
CPPOS wrote:
[...]
I need an example for VBE or a better SVGA driver.
[...]
Can anyone make and share a very simple OS.
[...]
Thanks. I really really need it. Please.
[...]
Just an advice, please stop saying 'I need it.' Really, we don't care whether you need anything or not. Moreover, it is not a raw beginners' forum. And yes, we don't have time to make you an OS and share it. Learn to learn on your own and search information on the Internet. These are excellent pages: http://wiki.osdev.org/Beginner_Mistakes, http://wiki.osdev.org/Required_Knowledge. (And also http://www.google.com, if you don't know.)
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Some VBE documentation or example?

Post by neon »

I found a resource: http://www.brokenthorn.com/Resources/OSDevVid2.html
But i couldn't understand it.
It requires some functions not in tutorial.
Hello,

With regards to VBE, the only methods that were not described in the tutorial were opted out due to their implementations being specific to the software system. E.g. The software can either drop down to real mode to call the BIOS (in the case of a boot loader) or enter virtual 8086 mode which requires basic multitasking and user mode support. Since you are already running in real mode using a deprecated compiler (however one that can certainly generate code for system software) you should be able to just call the BIOS directly. E.g. implement your own int86 method that calls the BIOS.

With the above in mind, What is it exactly that you are uncertain of? Are you not sure how to call the BIOS? The vbe3.pdf document provided earlier contains all of the information on VBE and was written quite well. Did you already look over it?
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Post Reply