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.

28 APPLE II COMPUTER GRAPHICS<strong>al</strong>ly prints the v<strong>al</strong>ue r<strong>et</strong>urned by the subroutine. The subroutine in thisexample r<strong>et</strong>urns only garbage.The following <strong>al</strong>terations are those which have been made to Listing4-3:Lines changed: 1 (/), 7(/), 16(/), 17(/), 24(/)Lines added : 65, 134, 136, 172, 174,1 76, 1 78,2(/)5These differences are explained below.65 POKE 1, 76: POKE 11, : POKE 12, 3Line 65 places information into memory which is needed by the USRcommand. When BASIC encounters USR, it automatic<strong>al</strong>ly jumps to location1 (/), and from there to the location of the subroutine which is to beused. The particular v<strong>al</strong>ues POKEd here direct the <strong>computer</strong> to jump tolocation $3 'where lies the subroutine. Location 11 contains the secondbyte of the subroutine's addre\s, in this case $ 'and location 12 containsthe fi rst byte-$3. If the subroutine begins in a different location, say$C25, the v<strong>al</strong>ues 37 ($25 = 2*16 + 5) and 192 ($Cf/) = 12*16 + (/))would be POKEd into locations 11 and 12, respectively.7 FOR L =768 TO 85The loop goes from 768 to 8(/)5 instead of to 8(/)2 because of the three extradata v<strong>al</strong>ues which have been added in line 2(/)5. The effect of those threeextra v<strong>al</strong>ues is to accept the character code which is passed by the USRcommand.134 PRINT "WHAT CHARACTER DO YOUWISH TO PRINT? 11136 GET C$:C = ASC (C$) + 128These lines GET the character that the user wishes to pri nt and convert it toits Apple code v<strong>al</strong>ue.16 PRINT USR ( C)This line passes the selected character code to the subroutine and thenexecutes it. When the subroutine is fi nished, this statement <strong>al</strong>so prints thev<strong>al</strong>ue which is r<strong>et</strong>urned by the subroutine. In this case the v<strong>al</strong>ue printed ismeaningless and it will not be printed if line 16(/) is changed to read 16X =USR(C).17 VTAB (22) : PRINT "ALL DONE"The VTAB has been changed to 22 to <strong>al</strong>low program line 172 to print onscreen line 23, and the GOTO has been removed since the program nolonger ends at this point.172 PRINT "ANOTHER CHARACTER? (Y/N) 11 : GET R$

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

Saved successfully!

Ooh no, something went wrong!