Programmer’s Corner

Loading and Saving Graphics Screens on the Apple II Series Part 2

While last months article covered some nifty graphics manipulation techniques, I missed making a few points about some extremely important items which must be made in order to make our program work well.
Every Apple II has some calls built in the rom of the machine which when called, perform tasks which we would normally have to assign basic statements to. A perfect example is the disk access lines of the program.
Lets take the following lines from the program and re-write them using calls. This obviously wont make the program shorter but it does make it clearer and easier to handle within the program.

 35 REM **
40 REM SET DEFAULTS
45 REM **
50 D$=CHR$(13)+CHR$(4)
55 SL=6 : DR=1 : MD=0
 600 REM *
602 REM CATALOG THE CURRENT DISK
604 REM *
610 HOME
615 PRINT D$;”CATALOG , S”;SL;”,D”;DR
620 PRINT
625 PRINT “PRESS ANY KEY TO CONTINUE
630 A$=INKEY$
635 IF MD=1 THEN 302
640 IF MD=2 THEN 502
 700 REM *
702 REM DRIVE AND SLOT SELECTOR
704 REM *
710 HOME
720 PRINT “SLOT OF DISK DRIVE : “;
722 S$=INKEY$
724 S$=”4” THEN 722
726 ST=VAL(S$)
728 IF ST<3 OR ST>7 THEN 722
730 SL=ST
740 PRINT
742 PRINT “SELECT DRIVE (1/2)”
744 DT$=INKEY$
746 DT=VAL(DT$)
748 IF DT<1 OR DT>2 THEN 744
Call-A.P.P.L.E. July 2002 Page 035 of 38
750 DR=DT
760 GOTO 70

While lines 30-55 are ok for the new program, we can change lines 600 through 640 to the following code:

600 REM *
602 REM CATALOG THE CURRENT DISK
604 REM *
610 HOME
615 CALL 42350
620 PRINT
625 PRINT “PRESS ANY KEY TO CONTINUE
630 A$=INKEY$
635 IF MD=1 THEN 302
640 IF MD=2 THEN 502

Notice line 615. This one call did everything automatically by using the defaults for the drive and slot as in memory. The same thing can be done for assignment of the slot and drive as shown below in the following lines 700 through 760.

 700 REM *
702 REM DRIVE AND SLOT SELECTOR
704 REM *
710 HOME
720 PRINT “SLOT OF DISK DRIVE : “;
722 S$=INKEY$
724 S$=”4” THEN 722
726 ST=VAL(S$)
728 IF ST<3 OR ST>7 THEN 722
730 SL=ST
740 PRINT
742 PRINT “SELECT DRIVE (1/2)”
744 DT$=INKEY$
746 DT=VAL(DT$)
748 IF DT<1 OR DT>2 THEN 744
750 DR=DT
755 POKE 43626,SL : POKE 43624,DR
760 GOTO 70

Notice line 755. Both the slot and drive have been poked into memory for usage by the call in line 615. This setting can also be used by other commands.

One other point which we failed to make in last month’s article was about the access of the graphics page. Take a look at the following lines of code:

 360 REM **
370 REM LOAD TO PAGE 1
380 REM **
382 POKE 16304,0
384 POKE 16302,0
386 POKE 16300,0
388 POKE 16297,0
390 PRINT D$;”BLOAD “;NA$;”,A$2000 ,S”;SL;”, D”;DR
400 A$=INKEY$
410 GOTO 70

Lines 382 through 388 contain the pokes which allow the graphics page to be accessed so that you can perform text commands without the screen being re-drawn after each one. This is also true for the lines in 435-447 of the program.

The difference between the two sets of lines is the poke to 16300 for page 1 and 16299 for page 2. By poking 0 into one of the two addresses, you can easily toggle between the two graphics pages.

Some specifics about the pokes used in these lines are shown in the table below:

 POKE          Explanation
 ============= =================
 POKE 16304,0  Enter graphics mode
 POKE 16302,0  Enter full graphics mode
 POKE 16301,0  Set the screen for both text and graphics
 POKE 16300,0  Go to Hi-Res page 1
 POKE 16299,0  Go to Hi-Res page 2
 POKE 16298,0  Set the graphics more to low resolution
 POKE 16297,0  Set the graphics mode to high resolution

Using the combination of these pokes and the other techniques shown, you should be able to adequately control the graphics screens.

A few minor corrections to our program are needed before it will work perfectly but it is well under way. Make a note of how the program is written. Notice the modular style. This is the best style to use as many of your routines will be used over and over during the years and in many programs. The error modules and the drive control modules are particularly useful in this manner.

Next month, we will look at the data file access routines in Applesoft and some sorting routines which will allow you to sort your data lists.

Please follow and like us:

About the Author

Bill Martens

A.P.P.L.E. Chairman of the Board and Club president -- Bill worked for the founder, Val J. Golding and A.P.P.L.E. from 1981 to 1982. In 1999, he began archiving the materials which were distributed and sold by A.P.P.L.E.. That project led to the group that remained of A.P.P.L.E. Bill was involved in the financial industry in Tokyo and has over 20 major office infrastructure projects to his name. In March 2001, he retired to write books and to spend more time pursuing personal interests. As the president of the users group, Bill is in charge of distribution of Call-A.P.P.L.E. magazine as well as the organization of this web site. Bill currently resides in Tokyo, Japan and Shelton, Wa splitting time between the places.