Go to file
2024-05-27 07:15:18 -04:00
.gitignore Update for publishing 2024-05-27 07:15:18 -04:00
asmvga.asm Update for publishing 2024-05-27 07:15:18 -04:00
bmp.c svga works, optimize vga and clean up code 2024-03-22 17:10:14 -04:00
bmp.h svga works, optimize vga and clean up code 2024-03-22 17:10:14 -04:00
chkn640.bmp svga works, optimize vga and clean up code 2024-03-22 17:10:14 -04:00
dpmi.c svga works, optimize vga and clean up code 2024-03-22 17:10:14 -04:00
dpmi.h svga works, optimize vga and clean up code 2024-03-22 17:10:14 -04:00
main.c Update for publishing 2024-05-27 07:15:18 -04:00
makefile svga works, optimize vga and clean up code 2024-03-22 17:10:14 -04:00
README.md Update for publishing 2024-05-27 07:15:18 -04:00
run initial commit 2024-03-19 08:18:55 -04:00
setup.sh initial commit 2024-03-19 08:18:55 -04:00
simple.c Update for publishing 2024-05-27 07:15:18 -04:00
svga.c svga works, optimize vga and clean up code 2024-03-22 17:10:14 -04:00
vesa.c svga works, optimize vga and clean up code 2024-03-22 17:10:14 -04:00
vesa.h svga works, optimize vga and clean up code 2024-03-22 17:10:14 -04:00
vga.asm svga works, optimize vga and clean up code 2024-03-22 17:10:14 -04:00

VGA and SVGA code examples

Some code to exercise the four logic units of the VGA card in 256 color mode, as well as code that gets SVGA mode working. Most of this is in C, but some of it's in assembler to help me learn assembler better, as well as get comfortable with C/asm interop on x86.

Check out the video I wrote all this code to support: https://makertube.net/w/sQSZJcxh8CRuMZWVh8Q6aF

Read more about my project The Industrious Rabbit at https://theindustriousrabbit.com/

Building

You'll need Open Watcom 2.0. You can use wmake on the makefile to build some of these, and wcl386 -q -bt=dos -l=dos4g <c or asm files> for the others. All of these run in 32-bit protected mode within a DPMI wrapper and in a flat memory space, because I really don't want to deal with segment:offset addressing.

What's here

main.c and vga.asm

C code that exercises a bunch of the VGA registers by transforming a colored cube of all 256 VGA colors in different ways. The display is set to unchained mode. Lots of latch copies and trasnforming data with stuff in the latches. The core of the transformation code is in vga.asm, which is also where the keyboard handler for exiting the program lives.

svga.c, vesa.c, dpmi.c, and bmp.c

Display a bitmap in a 640x480x256 SVGA mode. Trying to find a fully working SVGA, DOS Protected Mode Interface, and VESA example was tough, so hopefully this will help you out if you're trying to do the same thing!

simple.c and asmvga.asm

These both draw a single dot on the screen, but in different ways:

  • simple.c draws the dot directly to VGA memory
  • asmvga.asm allocates a block of RAM, writes the pixel there, then shovels the data from the RAM into the VGA card with rep movsb, which is the procedure a game would use to draw to a non-VGA RAM buffer and then copy when done.