Intro
Plotting pixels with the VGA Bios Interrupt (0×10) is very easy. That’s kind of the point of BIOS, but having a set of graphic functions available to us through the BIOS has some fallbacks. BIOS is notoriously SLOW! If you are going to make a graphical pulldowm menu system or create a small program to display a bitmap this method of blitting to the screen is just fine! There are a lot of programs that use BIOS to do their displaying, one example i believe is LOTUS 1-2-3. Any program that demands high speed graphics and split second updates (like 1/30 of a second), i highly recommend learning how to access VRAM directly. Here’s the BIOS function:
The Code
-
void PutPixel(int x,int y,int color,int page)
-
{
-
union REGS regs;
-
regs.h.ah=0x0C;
-
regs.h.al=color;
-
regs.h.bh=page;
-
regs.x.cx=x;
-
regs.x.dx=y;
-
int86(0×10,&regs,&regs);
-
}
Here we are following the BIOS guidelines for calling this function of the video interrupt (0×10). We set our high end of our ax register to 0x0c, and the lower portion to the color we want. We set the high end of the bx register to the visible page we want (usually 0) and then set cx and dx according to the x and y locations. Please note that this direct means of accessing the screen is unsuitable for fast screen updates! If you need to get things done quickly, you MUST find a faster way, and that would be by directly accessing the memory!
Thanks for taking the time to read this little tutorial. I would combine the two plotting pixels tutorials, but I wanted to keep them separate as to not confuse new programmers. Too much to look at can be more harm than good!