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.

24 APPLE II COMPUTER GRAPHICSs<strong>et</strong>s the Hi-Res <strong>graphics</strong> mode and clears the screen.6(il 1% = (RND ( l) * 8192) + 8192generates a random location b<strong>et</strong>ween 8192 ($2©©©) and 16383 ($3FFF),inclusive. This area of memory is reserved fo r page 1 of Hi-Res <strong>graphics</strong>.7(il V% = (RND ( l) * 256)generates a v<strong>al</strong>ue b<strong>et</strong>ween © and 255, inclusive.8(il POKE 1%, V%POKEs the v<strong>al</strong>ue into the memory location within screen memory to mak<strong>et</strong>he dots appear.9(il GOTO 5(ilbegins the loop again.C<strong>al</strong>l for HelpThe CALL statement is much like the APPLESOFT GOSUB, except that thesubroutine being CALLed is a machine language routine in memory insteadof a BASIC routine within your program. At the end of the subroutine,the machine code equ iv<strong>al</strong>ent of a RE:fURN statement r<strong>et</strong>urns to theinstruction which fo llowed the CALL in your-program. The use of machinelevel routines is helpful because they <strong>al</strong>low you more control over the<strong>computer</strong>, and are much faster than corresponding BASIC routines.Smooth animation virtu<strong>al</strong>ly requires the extra speed afforded by machinelevel subroutines. On the negative side, the workings of a routine writtenin machine code are usu<strong>al</strong>ly rather obscu re; and further, any errors inusing that routine can lead to any number of unpredictable and bizarreresults.The simplest use of the CALL statement is to CALL one of the routineswithin the Apple operating system. CALL -936 clears the text screen andmoves the cursor to the upper left corner-the same effect as the HOMEstatement. When one uses the HOME command, APPLESOFT essenti<strong>al</strong>lyissues a CALL to that same location. There are many other usable routineslisted in the APPLESOFT manu<strong>al</strong>, see pages 129-1 3©, and the APPLE IIREFERENCE MAN UAL, see pages 61-64.Another way to use CALL is to have your BASIC program POKE a machinelanguage program into memory, then invoke that routine using theCALL statement. Type in the program from Listing 4-3 by way of anexample. You will see the screen will fi ll with the inverse @ character. Thefirst portion of the program POKEs a subroutine into memory using a datatable, and then the subroutine is CALLed. The subroutine itself is of no re<strong>al</strong>v<strong>al</strong>ue because <strong>al</strong>l it does is fill the screen with inverse @ characters, but itdoes demonstrate the use of CALL.

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

Saved successfully!

Ooh no, something went wrong!