Standard Video Modes

Setting Normal VGA Resolutions

When setting normal (non-VESA) resolutions, we can easily use a BIOS function call. All we have to do is load the appropriate values into the CPU registers and call the video interrupt! It can look something like this:

  1. void StandardVideoMode(int mode)
  2. {
  3.     asm{mov ax,mode
  4.         int 10h
  5.     }
  6. }

or if you prefer straight CPP then try

  1. void StandardVideoMode(int mode)
  2. {
  3.     union REGS regs;
  4.     regs.x.ax=mode;
  5.     int86(0×10,&regs,&regs);
  6. }

Thats all there is too it! I honestly only use this function to switch to text mode (3) or good old 320x200x256 mode (19). Here’s a good way to structure your function:

  1. void Video::StandardVideoMode(short mode)
  2. {
  3.     union REGS regs;
  4.     regs.x.ax=mode;
  5.     if(!ClearMem)
  6.     {
  7.         regs.x.ax+=128;
  8.     }
  9.     if(mode == 0×13)
  10.     {
  11.         Screen_Width=320;
  12.         Screen_Height=200;
  13.         Screen_Size=64000;
  14.     }
  15.     if(mode == 3)
  16.     {
  17.         Screen_Width=80;
  18.         Screen_Height=25;
  19.         Screen_Size=4000;
  20.     }
  21.     
  22.     int86(0×10,&regs,&regs);
  23.     CurrentVideoMode=mode;
  24.     Move2Vid = &Video::MoveMemStandard;
  25.     XCenter=Screen_Width >> 1;
  26.     YCetner=Screen_Height >>1;
  27. }

Here we’ve added a couple of new twists. Firstly this function is contained in my Video class where I have a couple of new variables. We use a new variable called ClearMem that is a flag telling the code wether it is ok to clear the contents of Video RAM. This flag must be set before our function is called. We set several screen variables,Screen_Width, Screen_Height, Screen_Size according to which mode we are setting. I’m only testing my favorite two video modes in the code, but I think you can add the appropriate changes for other modes. CurrentVideoMode is simply a class variable that holds, amazingly, the current video mode. Lastly, notice we set a new variable called Move2Vid. Previously it was a function that moved our offscreen buffer to Video RAM. Now it is a function pointer. MoveMemStandard is the function that will move our video buffer to VRAM. For more explanation on how these work, take a look at the Moving your Offscreen Buffer to Video Ram tutorial! Without further delay, here’s the much anticipated mode listing!

Here’s a video mode listing to put you on your way!

Mode Listing

Mode Number Description
0 40×25 Text Mode, 16 colors
1 40×25 Text Mode, 16 colors
2 80×25 Text Mode, 16 colors
3 80×25 Text Mode, 16 colors
4 320×200 Graphics Mode 4 colors
5 320×200 Graphics Mode 4 colors
6 640×200 Graphics Mode 2 colors
7 80×25 Text Mode, Mono
8 Undocumented
9 Undocumented
10 Undocumented
11 Undocumented
12 Undocumented
13 320×200 Graphics Mode, 16 colors
14 640×200 Graphics Mode, 16 colors
15 640×350 Graphics Mode, Mono
16 640×350 Graphics Mode, 16 colors
17 640×480 Graphics Mode, 2 colors
18 640×480 Graphics Mode, 16 colors
19 320×200 Graphics Mode, 256 colors

If bit 7 of the mode is set when our StandardVideoMode function is called, contents of Video Ram won’t be cleared, otherwise changing video modes will automatically clear the screen.

Some of the modes are duplicated because and EGA/VGA card can’t differ the output of the color signal in Modes 0,1,2,3,4 and 5.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>