Video Memory

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
NewOS

Video Memory

Post by NewOS »

Hi, I have couple of question about what we see on the screen. First it is right all we see on the screen is written somewhere on the central memory ? If so, if I write a program to put some data into this part of memory I will make the design looking wierd ? Or if, simply, the kernel won't be let me write in this region of the memory ? But what is the format of this part of memory ? it is only a bitmap of 1024x768(if the user have this resolution of course) and windows simply modify this bitmap stored into this part of memory ?

And how to access to the video card to write something on the screen ? without bios and without high function, like opengl, gdi, directx ? Because the GDI itself have to access to a something to write to the screen. and in protected mode, bios int not availables. does exist a list of port or something ? or if is just simply the driver doing the job ?

thank you :)
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Video Memory

Post by Solar »

Whoa, lots of questions! Unfortunately, it's not really clear what you are referring to.
NewOS wrote: Hi, I have couple of question about what we see on the screen.
Depends on what is running on your machine at the moment you're looking at your screen. A self-written kernel? (Then you should be able to answer the question yourself.) Some hobbyist OS you downloaded (which one)? Linux? Windows?

Right after a system started up, you usually see some 80x25 text display (at least on x86 machines). This could be done by calling BIOS interrupts, or by writing directly to video memory.

But you refer to windows in your posting, so I assume you mean a full graphical interface, like Windows or X Window. And again the answer is a clear "it depends": Of course you can write a bitmap to memory, and have the graphics card display that. (Called "framebuffer".)

But graphics cards usually offer "accelerated" functions, not only for 3D but for 2D operations too. And since graphics cards differ in the ways they implement this, that's where graphic drivers come into play - and since every OS plays the driver game differently (GDI, DirectX, X Window, OpenGL, ...), there's really no way to really answer your questions unless you become a bit more specific. ;-)
Every good solution is obvious once you've found it.
NewOS

Re:Video Memory

Post by NewOS »

Well, I'm talking about windows, its the GDI displaying what we see under windows right ? So how GDI work ? if I write a new kernel how to access to the video card to display all I want on the screen in text mode and high resolution. Because bios int are not available under pmode. And how the gui is working ? how to put a little bmp 8x8 for the mouse cursor and attach it to the mouse moves ? And how to make event like when the user click a specific region on the screen, like clicking X button to close the window ?

And what we see on the screen, is it a 1024x768 bmp somewhere in memory that be refresh every second ? or if what we see it organized another way ?

And if is right what we see on the screen is somewhere in the memory, what is the address ? is it a standard and the same thing on every pc under windows or any OS ?

And how the video card can be access to where the screen is located in central memory ?

Thanks :)
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:Video Memory

Post by Pype.Clicker »

Hmm... considering the amount of worries you have, i suggest you get a good tutorial about 320x200 VGA mode and the VBE documentation. thinks will start being *very* clearer from there.
NewOS wrote: Because bios int are not available under pmode.
You'll need the BIOS to set up the video mode. That's almost impossible to avoid unless you have a product-dedicated driver for each video card. And even if you cannot access BIOS ints in pmode, you can
* set up wished mode while still in real mode
* use VBE3 protected-mode interface to access mode-setup API
* use a V86 monitor to call the BIOS interrupt from your 32 bits kernel.
And what we see on the screen, is it a 1024x768 bmp somewhere in memory that be refresh every second ? or if what we see it organized another way ?
more or less, the video card maps its internal data on some physical memory (usually at the high end of memory) and mode info/mode setup should tell you where exactly it is. The exact structure of that memory area (the VideoRAM) depends on the colour depth. 32K colors modes use two consecutive bytes for each pixel, encoding the color something like '-RRRRRGGGGGBBBBB' while 32 bits (16M colors plus 8 bits for alpha channel which isn't used by the video hardware) has one byte for each colour component.
And how the gui is working ? how to put a little bmp 8x8 for the mouse cursor and attach it to the mouse moves ? And how to make event like when the user click a specific region on the screen, like clicking X button to close the window ?
basically, the GUI receives interrupts from hardware devices such as mouse and keyboards, update it's internal state accordingly and then will lookup complex datastructure to tell which 'widget' is pointed and therefore should receive the 'MOUSE_CLICK' event.

No need to say that you'll have *long* code to write before being able to handle such things ...
And if is right what we see on the screen is somewhere in the memory, what is the address ? is it a standard and the same thing on every pc under windows or any OS ?
Be more specific. If you want to see a jpeg picture or an hex dump of some memory location, things you'll have to do will *not* be the same. Once in gfx mode, all the hardware can do is plotting pixels. If you want characters to display, you need software to define which pixels should be switched on to render a 'A' ...
Post Reply