The PDF Version

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:

void StandardVideoMode(int mode)
{asm{mov ax,mode
     int 10h
    } 
}

or if you prefer straight CPP then try

void StandardVideoMode(int mode)
{union REGS regs;
 regs.x.ax=mode;
 int86(0x10,&regs,&regs);
}


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:

void Video::StandardVideoMode(short mode)
{ union REGS regs;
  regs.x.ax=mode;
  if(!ClearMem)
    {regs.x.ax+=128;
    }
  if(mode == 0x13)
   {Screen_Width=320;
    Screen_Height=200;
    Screen_Size=64000;
   }
  if(mode == 3)
   {Screen_Width=80;
    Screen_Height=25;
    Screen_Size=4000;
   }
  int86(0x10,®s,®s);
  CurrentVideoMode=mode;
  Move2Vid = &Video::MoveMemStandard;
  XCenter=Screen_Width >> 1;
  YCetner=Screen_Height >>1;
}


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 NumberDescription
040x25 Text Mode, 16 colors
140x25 Text Mode, 16 colors
280x25 Text Mode, 16 colors
380x25 Text Mode, 16 colors
4320x200 Graphics Mode 4 colors
5320x200 Graphics Mode 4 colors
6640x200 Graphics Mode 2 colors
780x25 Text Mode, Mono
8Undocumented
9Undocumented
10Undocumented
11Undocumented
12Undocumented
13320x200 Graphics Mode, 16 colors
14640x200 Graphics Mode, 16 colors
15640x350 Graphics Mode, Mono
16640x350 Graphics Mode, 16 colors
17640x480 Graphics Mode, 2 colors
18640x480 Graphics Mode, 16 colors
19320x200 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.


If you have any questions, comments, rude remarks please give me some feedback!