07.12.2015 Views

Microcomputer Graphics

myers-1982-microcomputer-graphics

myers-1982-microcomputer-graphics

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

240 <strong>Microcomputer</strong> <strong>Graphics</strong><br />

the beginning of the table. Another area that usually is safe lies just<br />

above the second page of high resolution graphics. Program A2.2 stores<br />

a shape table there.<br />

While the location of a shape table in memory is somewhat arbitrary,<br />

the address of the beginning of the table must be made known to<br />

the shape drawing commands. When either DRAW or XDRA Wis used,<br />

the address of the shape table is found in locations 232 (low part of the<br />

address) and 233 (high part of the address). It is the programmer's<br />

responsibility to see that these locations contain the proper addresses.<br />

In general, for a shape table stored at location A, location 232<br />

should contain the value A - 2 5 6 * < INT > , while location 233<br />

should contain I NT • These values may be set when the table is<br />

loaded from disk. Several tables may be used within a program if the<br />

contents of locations 232 and 233 are redefined at appropriate times.<br />

Values of ROT, SCALE, and HCOLOR should be defined before<br />

using either DRAW or XDRA W. (See the Applesoft Basic Programming<br />

Reference Manual for a description of these commands.) You will<br />

find that some distortion occurs when shapes are rotated or scaled.<br />

Also, since most shapes contain vertical line segments, you will find that<br />

colors are not easily used. White is the preferred color for shapes.<br />

The following short program illustrates a use of shape tables to simulate<br />

a radar screen. The shape table is identified in lines 20 and 30. It<br />

consists of two shapes: a single plot-then-move-up vector, and a collection<br />

of vectors that define an airplane. The shapes are illustrated in Fig-<br />

•<br />

•<br />

• • • • • •<br />

(a)<br />

•<br />

•<br />

(b)<br />

Figure A2.2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!