I recently got interested in writing a simple kernel. I did some searching on the internet and came across OSDev Wiki. I set up the basic kernel (and after some frustration, the cross-compiler). Now I wanted to take it a step further: I want to start writing values to individual pixels. The only satisfactory and understandable answer I came across was the one on the Wiki, Drawing in Protected Mode. I want to use the functions provided, but still can't seem to understand what I need to pass as the arguments. Below is the code for the function I am using, I can't understand what I need to pass for the first argument. Is there some memory buffer (similar to the terminal_buffer used for text) I need?
/* only valid for 800x600x32bpp */
static void putpixel(unsigned char* screen, int x,int y, int color) {
unsigned where = x*4 + y*3200;
screen[where] = color & 255; // BLUE
screen[where + 1] = (color >> 8) & 255; // GREEN
screen[where + 2] = (color >> 16) & 255; // RED
}
This is probably a stupid question since I'm very new to OS development.
Thanks in advance,
Javax
BTW: I am doing x86 code. I also saw this question and tried inlining it in C++. This code compiles, but if I call the function, the OS refuses to boot. It only gets to this stage:the stage it boots to before returning to the GRUB menu screen. This may be beside the point, however, if I can find an alternative solution. This is the alternative option:
void setPixel () {
asm ("mov %ah, 0x0C");
asm ("mov %al, 0x13");
asm ("int $0x10");
asm ("mov %ah, 0x0C");
asm ("mov %bh, 0");
asm ("mov %dx, 5");
asm ("mov %cx, 5");
asm ("mov %al, 0x04");
asm ("int $0x10");
}