12.07.2015 Views

williams-et-al-1983-apple-ii-computer-graphics

williams-et-al-1983-apple-ii-computer-graphics

williams-et-al-1983-apple-ii-computer-graphics

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

150 APPLE II COMPUTER GRAPHICSaround the screen, there are many c<strong>al</strong>culations to be made: the shape's Xand Y-coordinates, perhaps the address corresponding to those coordinates,and if you are animating using byte-move, which of the sevenversions of the shape is to be used at each coordinate.Som<strong>et</strong>imes the figuring can be done "on the fly," such as after the shapeis drawn on the screen and before it is erased to be moved. This increasesthe time the object is on the screen. This increases the ratio of the displaytime to the erase time, which in turn reduces flicker. However, c<strong>al</strong>culating<strong>al</strong>l of this within the animation routine will slow it down becausearithm<strong>et</strong>ic operations tend to gobble up relatively large amounts of processortime-remember, it is usu<strong>al</strong>ly faster to look it up than to figure it out.As an <strong>al</strong>ternative, it is possible to compute the path of an object before itstarts, and store each of the coordinates in a table (BASIC c<strong>al</strong>ls themarrays). It is usu<strong>al</strong>ly faster to look a number up in a table (especi<strong>al</strong>ly whenusing machine code) than it is to compute it on the spot. The gameTHRESHOLD uses tables, byte-move, and pre-c<strong>al</strong>culation in its animation.In Chapter 12 we used byte-move techniq ues to move a line across thescreen. If you still have that program lying around on a disk somewhere,go g<strong>et</strong> it because we are about to mod ify it. The compl<strong>et</strong>e listing is givenbelow, but if you have the old program you can avoid having to type mostof it in again.10 DIM A%(280 ): REM 280 X-COORDINATES20 REM30 REM READ THE VALUES FOR40 REM THE 7 PAIRS OF FRAMES50 REM60 FOR I = 0 TO 670 READ T%(I), H%(I)80 NEXT I90 REM100 REM110 REM120 REM INITIALIZE THE TABLE130 REM OF ADDRESSES140 REM150 J = 0160 FOR I170 A%(J)180 NEXT190 REM14336 TO 14374I:J = J + 1200 REM PRE CALC .205 REM210 DIM Q%(280 ),R% (280 )220 FOR X 1 TO 280230 Q%(X) = x I 7:R%(X) X-Q% ( X ) * 7

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

Saved successfully!

Ooh no, something went wrong!