VGA Mode 0x13

Text games are fun, but I'm not looking for this particular game to be text-based. I want to use the VGA hardware in graphics mode, not text mode, for this project. I'll be using a BIOS function to set the VGA adapter into mode number 19, or 0x13. In mode 0x13, video memory consists of 64000 consecutive pixels (320 x 200) starting at 0xa0000. To change to mode 0x13, we will use BIOS interrupt 0x10, and I'll test this by writing a repeating sequence of pixels to the screen:

org 0x7c00
bits 16

  mov ax, 0x0013
  int 0x10

  mov ax, 0xa000
  mov es, ax

  xor di, di
  xor al, al

row_loop:
  mov dl, al
pix_loop:
  mov byte [es:di], al
  inc di
  inc al
  cmp al, dl
  jne pix_loop
  inc al
  add di, 320 - 256
  cmp di, 64000
  jne row_loop

halt:
  hlt
  jmp halt

times 510 - ($ - $$) db 0
dw 0xaa55

Assembling and running this gives us the following screen:

Now we can access video memory as an array of pixels, rather than an array of characters. Here is a tar archive of the files used for this chapter.

Index
Previous
Next