Setting the video mode in C Graphics

Setting the video mode in C Graphics


To set the video mode, call interrupt 0x10 (BIOS video functions) with 0 (zero) in the AH register and the desired mode number in the AL register. For mode 0x13, the code (Borland C) would be as follows:

union REGS regs;  regs.h.ah = 0x00;  /* function 00h = mode set */ regs.h.al = 0x13;  /* 256-color */ int86(0x10,&regs,&regs); /* do it! */ 

To return to text mode after the program finishes, simply set the mode number to 3.

union REGS regs;  regs.h.ah = 0x00; regs.h.al = 0x03; /* text mode is mode 3 */ int86(0x10,&regs,&regs); 

Plotting a pixel

An easy way to plot a pixel is by using function 0x0C under BIOS interrupt 0x10. For this function, set CX and DX to the pixel x and y location. The color displayed depends on the value in AL. See Table I for a list of common colors.

union REGS regs;  regs.h.ah = 0x0C;   /* function 0Ch = pixel plot */ regs.h.al = color; regs.x.cx = x;      /* x location, from 0..319  */ regs.x.dx = y;      /* y location, from 0..199  */ int86(0x10,&regs,&regs); 

This pixel-plotting method is easy, but it is also very slow. BIOS will do certain checks to make sure that the input is valid, and then it will test to see if the (x,y) coordinates are within the screen boundaries, and finally it will calculate the offset to video memory. A faster way to plot a pixel is to write directly to video memory.



Related Links :

No comments:

Post a Comment


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!