Haven't tested this either. But it should be something along these lines.
Code:
typedef struct
{
char skip[88]; // there are some interesting fields here but
// we skip them for simplicity
unsigned framebuffer_addr_lo; // separated these fields to avoid 64 bit
unsigned framebuffer_addr_hi; // arithmetic (which may need some extra code)
unsigned framebuffer_pitch; // this is basically bytes per line
unsigned framebuffer_width;
unsigned framebuffer_height;
unsigned char framebuffer_bpp;
} multiboot_info_t;
multiboot_info_t *mbinfo;
void vesa_drawpixel(unsigned x, unsigned y, unsigned color)
{ // assuming 32bpp
unsigned *line = (unsigned *)(mbinfo->framebuffer_addr_lo + y * mbinfo->framebuffer_pitch);
line[x] = color;
}
void vesa_clear(unsigned color)
{ // slow but simple
for(unsigned y = 0; y < mbinfo->framebuffer_height; ++y)
{
for(unsigned x = 0; x < mbinfo->framebuffer_width; ++x)
vesa_drawpixel(x, y, color);
}
}
void kmain(multiboot_info_t *mboot_info)
{
mbinfo = mboot_info;
vesa_clear(0x00203040);
vesa_drawpixel(400, 300, 0x00FFFFFF);
}
For different color depths, you have to change data type of line in vesa_drawpixel. For 16 bit it would be unsigned short and unsigned char for 8 bit.
TBH. These are the basics of the basics. If you want to be able to write something more than 'Hello, World!' for your OS, you really need to be fluent in regular programming as well.