head	1.1;
access;
symbols;
locks
	yap:1.1; strict;
comment	@# @;


1.1
date	97.12.04.16.21.47;	author yap;	state Exp;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@<html>
<body bgcolor=fafafa>

<h2>
Simple VGA Graphics on the PC
</h2>

<b> VGA graphics mode 13H </b>
<br>  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):

<table border=4 bgcolor=fa99fa>
<tr><td>
<pre>
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</pre></td></tr>
</table>

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):

<table border=4 bgcolor=fa99fa>
<caption><b>The 16 Standard CGA Colors</b></caption>
<tr><td> 0=black, 1=blue, 2=green, 3=cyan, 4=red </td></tr>
<tr><td>  5=magenta (purple),
6=brown, 7=white, 8=gray </td></tr>
<tr><td> 9=light blue, 10=light green,
11=light cyan, 12=light red </td></tr>
<tr><td> 13=light magenta, 
14=yellow, 15=intense white </td></tr>
</table>

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

<p>
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. 


<p>
<b>Exercise</b>  Write a program that to draw the Union Jack
on the screen, against a gray background.

<p>
<hr>
<p>
<address>
This has been adapted by Chee from notes by Marsha Berger (1996).
</address>
</body>
</html>
@
