VGA programming lessons

Subject

How do we use the assembly (and pascal) language as well as the VGA direct memory/register access for programming 2D graphs? If you want to know the answer, this is an article for you. Although the standard VGA BIOS contains a lots of different video modes, I am going to use only one VGA mode, the 256 colors, 320 by 200 pixels mode (a.k.a. mode $13). This is small, simple, and really easy to use mode. Our code will be so fast, I promise.

Reason

You'd propably say that this is a little bit outdated. Nowadays nobody uses normal VGA card, not even DOS or Borland Pascal. Programmers use DirectX, and Windows for developing games. Why then this article can be interesting for you? I have no answers, maybe this: "why not?". I do it for fun, so anyone who landed here can have fun. Plus, even if this knowledge is old, still you can learn how to do some 2D graphics programming. For example, if you want to do the same thing in DirectX, all you have to do is just extend the dimensions. Or, if you want to work in a free dos OS for some reason, this will be a good tutorial. (There is no new under the sun.)

What do we need?

In case you like my work, you can donate any amount... up to you :-)

Press the button or use the e-mail found on the main page.

Lessons

The list is not complete and there are missing lessons. I will be working on it.

In these lessons I am going to present and explain the functions and procedures we use. These routines are collected into one pascal unit called gfx256. So when you're reading a lesson, you will see only the functions related to that particular lesson, while the unit contains everything. Therefore you don't have to download the gfx256 for each lesson. Download it only once.

  • Lesson   1 - The stucture of the 320x200x256 VGA mode
  • Lesson   2 - Set VGA videomodes, clear screen
  • Lesson   3 - Draw pixels and horizontal/vertical lines
  • Lesson   4 - Draw a general line
  • Lesson   5 - Draw bars and boxes
  • Lesson   6 - Colors, palette manipulation
  • Lesson   7 - Images
  • Lesson   8 - Writing text
  • Lesson   9 - A virtual character screen
  • Lesson 10 - Useful VGA registers, I/O access, detecting vertical retrace
  • Lesson 11 - Sprites
  • Lesson 12 - Save the screen as bitmap image