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

Create successful ePaper yourself

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

CHAPTER 12-BYTE-MOVE SHAPES 139l!ill!il REM CALCULATE Yl!iJ2!il REM COORDINATESlYJJ!il REM1YJ4!il DIM Y%( 192)l!il5!il FOR I = 1 TO 185 STEP 8: READ SA%l!iJ6!il FOR J = !il TO 7:Y%(I + J) = SA% +J * lYJ241YJ7!il NEXT J,I1YJ8!il DATA 8192,8J2YJ, 8448,8576, 87YJ4,88J2,896YJ,9YJ881YJ9!il DATA 82J2,8J6YJ, 8488, 8616 , 8744,8872,9!il!iJYJ, 9128ll!il!il DATA 8272,84YJYJ,8528, 8656,8784, 8912 ,9YJ4YJ,9168lllYJ RETURNListing 12-2.Lines 1 ©©© th rough 111 fl) c<strong>al</strong> cu late the starting addresses for each of the192 screen lines by taking the base address of the box that the line lies inand adding the position address to it. That position address is c<strong>al</strong>culated asa multiple of 1©24. If that <strong>al</strong>gorithm escapes you, try reviewing the portionof Chapter 8 where we t<strong>al</strong>ked about c<strong>al</strong>culating addresses fo r Hi-Res memory.Line 245 is executed after each frame is displayed, and its purpose is toincrement each of the seven Y coordinates so that the prop will be plottedone line lower the next time.Run the mod ified program. You will see the propeller dropping downthe left edge of the screen as it spins. You will <strong>al</strong>so see a trail of garbageleft behind as the shape progresses. Most of each frame is wiped out whenthe next one plots over it, but since we are moving down b<strong>et</strong>ween frames,the top line of each frame remains on the screen to haunt you.When moving a shape using byte-move, it is often neccesary to makespeci<strong>al</strong> provisions for erasing the left-overs.We <strong>al</strong>l know that your first try never runs perfectly anyway, and theproblem is easily remedied by adding:215 POKE Y%(YYJ%) ,YJ244 YYJ% = Y1%Line 244 stores the Y-coordinate for the old top line as Y©%, and line 215POKEs a zero there to erase that byte.G<strong>et</strong>ting It AcrossSo far, you have performed a stationary and a vertic<strong>al</strong> animation using

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

Saved successfully!

Ooh no, something went wrong!