Friday, April 19, 2024 | Toby Opferman
 

Mode 13h Tutorial

Toby Opferman
http://www.opferman.net
programming@opferman.net



                        VGA Mode 13h Tutor

   If you have been programming in BGI or something simular
and finally want to learn to program Graphics for real, this
is the Doc file for you.  I assume you know assembly already.

    MOV AX, 13h
    INT 10h

  That is all you need to set the Mode to 320x200x256 Colors.
Function 00h - Set Video Mode
         13h = VGA 320x200x256


A000:0000  Is The Segment:Offset for the video buffer.  Just
write to this portion of memory (64000 Bytes Large (320*200) To
Put something on the screen.  Example:
   MOV DI, X
   MOV AX, Y
   SHL AX, 6
   ADD DI, AX
   SHL AX, 2
   ADD DI, AX
   MOV AL, COLOUR
   STOSB

That will Plot a Pixel.

In C, just make a Far pointer:

 char far *Video = (char far *)0xA0000000;
 Video[X + (Y<<6) + (Y<<8)] = Color;
   Or
 *((char far *)0xA0000000 + X + (Y<<6) + (Y<<8)) = Color;
  That will do it too.

  A Y<<6 + Y<<8  is equal to Y*320


To Switch back to Text Mode just:
   MOV AX, 3
   INT 10h

   Function 00h - Set Video Mode
              3 = 80x25 Text Mode
 
About Toby Opferman

Professional software engineer with over 15 years...

Learn more »
Codeproject Articles

Programming related articles...

Articles »
Resume

Resume »
Contact

Email: codeproject(at)opferman(dot)com