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.

CHAPTER 13-ADVANCED MOVES 155Lines 120 and 130 test the v<strong>al</strong>ue of PDL(0) and decrement or incrementthe X-coordinate as needed. Line 140 keeps everything within range, andline 150 skips the XDRAW statements if there is no movement of thesquare-this helps to avoid flicker.In line 160, if the old direction (OD) is different from the new direction(ND) then the extra XDRAW is done. (Remember that series of XDRAWstatements above?) Line 170 does the regular XDRAW and s<strong>et</strong>s the oldv<strong>al</strong>ues to the new v<strong>al</strong>ues.With these changes in effect, the rectangle will respond to paddle control.When you add parti<strong>al</strong> modification, pre-shifting, and pre-c<strong>al</strong>culation toyour repertoire, you give the fi n<strong>al</strong> polish to your animation skil ls. That isabout <strong>al</strong>l there is to know about designing and animating figures, and inthe next chapter we address a slightly diffe rent topic: collision d<strong>et</strong>ection.* * * One extra tid-bit for the Apple lie***One annoying source of flicker in animation stems from changing thedata being displayed while it is being scanned. The electron beam in yourmonitor or TV sweeps over the entire screen sixty times every second,much as a searchlight will sweep across the sky. The trick is to change thedisplay data when the beam is not "looking." Over one-quarter of the timein each sweep is spent g<strong>et</strong>ting the beam from the bottom back to the topof the screen so it can begin the next cycle. This is c<strong>al</strong>led Vertic<strong>al</strong> Blanking.Since nothing new can be displayed during this interv<strong>al</strong> (about one-200th of a second), this is the best time to switch the display data. With theApple II + there was no way to tell when the vertic<strong>al</strong> blanking was occurring,but the lie has a speci<strong>al</strong> Vertic<strong>al</strong> Blanking Location (VBL) at 49177($C019) which sign<strong>al</strong>s the vertic<strong>al</strong> blanking interv<strong>al</strong> to anyone who cares tolook. When the vertic<strong>al</strong> blanking interv<strong>al</strong> begins, the v<strong>al</strong>ue in the VBLdrops to less than 128, and this v<strong>al</strong>ue may be read using a PEEK statement.L<strong>et</strong>'s suppose that the routine to animate the figure by changing thedisplayed data begins at line 1000, then line 1000 could read:l(il(il(il IF PEEK ( 49177) > 127 GOTO l(il(il(ill(ill(il Routine to POKE in new v<strong>al</strong>uesLine 1000 will delay the changing of display v<strong>al</strong>ues until the vertic<strong>al</strong> blankingperiod begins, at which time it will drop through to line 1010 andbegin changing.The VBL is still too new to fairly ev<strong>al</strong>uate its usefu lness, but it is g<strong>et</strong>tingmixed reviews from some of the current game programmers. Although it isnice to change the display data during the vertic<strong>al</strong> blanki ng interv<strong>al</strong>, doing

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

Saved successfully!

Ooh no, something went wrong!