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.

26 APPLE II COMPUTER GRAPHICS17 VTAB (24) : PRINT "ALL DONE" :GOTO 2t\i't\fter the subroutine is compl<strong>et</strong>e, this line will print an end of job message:ind then jump to the END statement.21 DATA 169,,lj3 ,254,169,7,133,255,16,25522 DATA 162,4,32,88,252, 165,161,145, 25423 DATA 198, 254, 28,252,136,28,247, 22,24,5,198,255,7624 DATA 17,3,96Lines 210-240 constitute the data table of v<strong>al</strong>ues to be placed into memoryto fo rm the subroutine. They are READ by line 80 and POKEd by line 90.Using the technique presented above, any machine language programmay be POKEd into memory, and then executed from BASIC using theCALL statement.USRThe USR statement is similar to the CALL statement, in that it causes theexecution of a machine level routine in memory. Where CALL simplyexecutes the indicated routine, USR <strong>al</strong>lows the BASIC program some controlover the machine level routine by handing up to two bytes of informationto the subroutine before commencing execution. Further, when theroutine is fi nished, it passes a v<strong>al</strong>ue back to the BASIC program.The USR statement must be used within a larger BASIC statement, fo rexample, X = USR(8) or PRINT USR(247). The v<strong>al</strong>ue given within theparentheses is the decim<strong>al</strong> v<strong>al</strong>ue of data passed to the subroutine, andafter the subroutine is executed, USR( ) represents the v<strong>al</strong>ue which is givenback to the BASIC routine. Suppose that the two examples cited above usea subroutine which doubles any v<strong>al</strong>ue it is given. Then the statement X =USR(8) would assign X the v<strong>al</strong>ue 16, and PRINT USR(247) would print 494.Listing 4-4 is an <strong>al</strong>teration of Listing 4-3. Key in Listing 4-4 and run theprogram. You will see the messageWHAT CHARACTER DO YOU WISH TO PRINT?appear on the screen. Press any character key and then the RETURN key.After a short wait, the screen will fill with the character that you havechosen. When the screen has filled, a number is printed in the upper leftcorner of the screen; the "ALL DONE" message is printed near the bottom.Next, the messageANOTHER CHARACTER? (Y/N)will appear, giving you a chance to try another character.

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

Saved successfully!

Ooh no, something went wrong!