Page 1 of 1
Video in graphic mode
Posted: Wed Oct 18, 2023 10:58 am
by KuzinAlexandr
Hello other forum users. I'm wondering how video memory can be used in graphics mode. In text it is used like this:
Code: Select all
char* videoptr = (char*)0xb8000;
void kmain()
{
videoptr[0] = 'H';
videoptr[1] = 0x07;
}
I heard that the address 0xA0000 is already used for the graphic mode
I would like to receive a code snippet for using the graphical mode.
Re: Video in graphic mode
Posted: Sun Oct 22, 2023 7:47 pm
by Octocontrabass
KuzinAlexandr wrote:I'm wondering how video memory can be used in graphics mode. In text it is used like this:
You can access video memory the same way in graphics mode. The specifics depend on which mode you're using.
KuzinAlexandr wrote:I heard that the address 0xA0000 is already used for the graphic mode
Standard VGA modes 0xD, 0xE, 0xF, 0x10, 0x11, 0x12, and 0x13 use address 0xA0000. Standard VGA modes 0x4, 0x5, and 0x6 use address 0xB8000. Non-standard modes can use other addresses.
Re: Video in graphic mode
Posted: Wed Nov 01, 2023 9:45 pm
by Ultrasick
VGA has configuration registers. You can set the starting address of the framebuffer as you wish (within limits). The starting address can be set independent of whether you are in graphics or text mode.
When you use 16 colors per pixel, then writing a pixel is not so straight forward. You can only access 64 KB of the 256 KB. There is a configuration register where you tell the graphics circuit which of the four 64 KB parts should be accessible.
Those 4 parts (4x 64 KB) of the total memory (256 KB) are called "memory banks". Since you can only access 64 KB at any time you need to do bank switching (changing a value in a VGA configuration register).
A pixel is 4 bits in size (when using 16 colors). But every bit is stored in a different bank. So you store
[*] the bit 2^0 in bank 0
[*] the bit 2^1 in bank 1
[*] the bit 2^2 in bank 2 and
[*] the bit 2^3 in bank 3.
To sum it up and answer you question about a code snippet: You need at least a year of development time to write a proper VGA compatible driver. But I don't think that you can do it within a year.