## Simple VGA Graphics on the PC

VGA graphics mode 13H
This is set, as usual, using INT 10H, function 0. This mode has 320 columns, 200 rows, and 256 possible colors at a time (out of a possible 256,000). If you want to use colors other than the default 256, you'll have to use the palette registers, and it's up to you to find out how to do that yourself! Like text mode, what is displayed on the screen is determined by the contents of video memory. Unlike text mode, VGA graphics memory begins at segment A000h. Since each pixel can be one of 256 colors, each pixel is represented by one byte. The pixels are stored in row-major order, like text mode. As a quick example, to change the pixel in row 23, column 117 to color 182, you could do the following (assuming the video mode has already been set):

    MOV AX,0A000h
    MOV ES,AX
    MOV BL,23
    MOV AL,320 ; bytes per row
    MUL BL     ; result in AX
    ADD AX,117 ; offset of pixel at row 23,col 117 is now in AX
    MOV SI,AX
    MOV ES:[SI],182

What color is color number 182? I don't know offhand. You can be sure that colors 0 through 15 correspond to the text mode colors, given in the following table (p.333, ch.16 of text):

The 16 Standard CGA Colors
0=black, 1=blue, 2=green, 3=cyan, 4=red
5=magenta (purple), 6=brown, 7=white, 8=gray
9=light blue, 10=light green, 11=light cyan, 12=light red
13=light magenta, 14=yellow, 15=intense white

Naturally, you should use appropriately defined EQU's and other good programming habits :)

While it is possible to write directly to video buffer, we can also use interrupt 10h for convenience. Thus INT 10h, function 0Ch writes a graphic pixel: see p.335, ch.16. It is a tradeoff between convenience and speed: direct access to video buffer is faster than the use of interrupts. Note that one of the convenience of interrupts is that it takes care of the differences in different modes.

Exercise Write a program that to draw the Union Jack on the screen, against a gray background.