Classic Computer Magazine Archive COMPUTE! ISSUE 20 / JANUARY 1982 / PAGE 86

More Apple Hi-Res Shape Writer

Chris Dupuy
Gonzales, LA

Countless hours spent plugging ones and zeros on graph paper are now history, thanks to Mr. Hen-nig's "Hi-Res Shape Writer." [COMPUTE! #14] Shload miseries are not missed and drawing shapes other than right angles are now a breeze.

After creating one star cruiser after another, I was soon struck with the harsh realization that I could not SAVE these cosmic creations on my cassette recorder. Unfortunately for me, I belong to the one percent club of Apple owners who cannot afford the luxuries of a disk drive. Undaunted with the PEEKs and POKEs ahead of me, I proceeded to write a routine that would put all the bytes from the shape table into trusty DATA statements.

The program is intended to be added to the original "Apple Hi-Res Shape Writer" by Doug Hennig. However, the routine used to POKE DATA in DATA statements can be adapted to other programs where the user does not want to be bothered with the rules of STOREing and RECALLing arrays.

Program Operation

REMark statements were omitted from the program in order to save valuable space, since memory size becomes a problem with complex shapes.

5-1084 Sets an array to the bytes POKEd into the shape table in original program.

13900-13906 Searches for the memory locations of the first blank DATA statement and sets Y equal to this.

13910-13970 POKEs Q to first item in DATA statement.

13930 Separates Q into individual digits.

13975 POKEs number of shape tables and reference numbers for shape tables.

14000-14075 POKEs bytes of shape table into the succeeding locations of the DATA statements.

14004 Searches DATA statement for a period (CHR$(46)), in order to find location to insert next value.

14550-14630 Demonstration program to verify information in DATA statements.

14572 Checks DATA statement to verify additional space on current statement. If not, then READ asterisks and jump to next DATA statement.

14700-14710 DELetes main portion of program and leaves demo program with DATA statements to be SAVEd.

15000-15005 DATA statements with 184 periods (quantity is at your discretion), and 4 asterisks.

Variables Used

Q Holds the number of bytes in the shape table.

V() Stores individual bytes of shape table.

Y Keeps track of the DATA statement memory locations.

R Used to check memory locations for a period.

F,FF Holds LENgth of strings and uses that value in FOR-NEXT statements.

T(),L() Arrays that hold the individual digits of bytes from shape table.

E$ User input.

X The location for bytes to be POKEd into shape table.

Y$ Stores the DATA being READ from demo program. String is used to prevent error message when asterisk is READ.

Hints And Changes

Those who have 32K Apples will encounter space problems when trying to run this longer program. DELeting the instructions, REMarks, disks subroutines, and combining statements will help avoid this obstacle.

Once all changes are made to your program, lines 13904 and 13906 may be DELeted. However, the memory location for the first DATA statement must be found. In machine language, the three bytes to look for are: 83 00 2E. The decimal location of 2E should then be set to Y in line 13900. Remember—if this change is done, no other changes can be made in the program (except for DATA statements), without the information being POKEd into the wrong locations. If searching for memory locations is too tedious, then you might want to experiment by raising the value in line 13900. Either one of these changes will save time in program execution.

Providing you have shaved off a good portion of the program, the value in line five may be raised to accomodate more complex shapes.

The major shortcoming in this program is the inability to store more than one shape table at a time. Though a small amount of effort could change this, it would not be feasible if you are running low on memory. I hope this program brought some relief and enjoyment to you cassette owners out there.

5 DIM V(250)
1082 Q = Q + 1
1084 V(Q) = X
13040 TEXT: HOME
13042 VTAB 10: HTAB 5
13045 PRINT "MEMORY LOCATIONS ARE BEING SCANNED"
13900 Y = 3500
13904 IF PEEK(Y) = 131 AND PEEK (Y + 2) = 46 THEN Y = Y + 2 : GOTO 13910
13906 Y = Y + 1 : GOTO 13904
13910 FF = LEN(STR$(Q))
13920 FOR X = 1 TO FF
13930 T(X) = VAL(MID$(STR$(Q), X, 1))
13940 POKE Y, T(X) + 48
13945 Y = Y + 1
13950 NEXT
13970 POKE Y, 44
13975 POKE Y + 1,49: POKE Y + 2,44:POKE Y + 3, 48: POKE Y + 4, 44 :
      POKE Y + 5, 52 : POKE Y + 6, 44 : POKE Y + 7, 48 : POKE Y + 8, 44
13997 TEXT : HOME
13998 VTAB 10: HTAB 2
13999 PRINT "DATA IS NOW BEING POKED INTO MEMORY"
14000 FOR QQ = 1 TO Q
14003 R = PEEK (Y)
14004 IF R <> 46 THEN Y = Y + 1: GOTO 14003
14005 F = LEN(STRS$(V(QQ)))
14010 FOR T = 1 TO F
14019 L(T) = VAL(MID$(STR$(V(QQ)), T, I))
14040 POKE Y, L (T) + 48
14050 Y = Y + 1
14055 NEXT
14060 POKE Y, 44
14070 Y = Y + 1
14075 NEXT
14100 HOME
14500 PRINT "TYPE ‘ESC’ KEY TO DEMONSTRATE PROGRAM"
14510 GET E$ : IF E$ <> CHR$(27) THEN END
14550 POKE 232, 0 : POKE 244, 64
14555 READ Q
14560 FOR X = 16384 TO 16387 + Q
14570 READ Y $
14572 IF Y$ = "*" OR Y$ = "**" OR Y$ = "***" THEN 14570
14575 Y = VAL(Y$)
14580 POKE X, Y
14590 NEXT
14600 POKE 16388 + Q, 0
14610 HGR: SCALE = 1: ROT = 0
14620 HCOLOR = 3
14630 DRAW 1 AT 140, 80
14700 VTAB 22
14702 PRINT "TYPE ‘ESC’ TO FORM NEW PROGRAM"
14704 GET E$: IF E$ <> CHR$(27) THEN END
14705 TEXT: HOME
14706 PRINT "PROGRAM IS NOW READY TO BE SAVED"
14710 DEL 5, 14510
15000 DATA . . . . . . . . . . . . . . . . . . . . . . ****
15001 DATA . . . . . . . . . . . . . . . . . . . . . . ****
15001 DATA . . . . . . . . . . . . . . . . . . . . . . ****
15002 DATA . . . . . . . . . . . . . . . . . . . . . . ****
15003 DATA . . . . . . . . . . . . . . . . . . . . . . ****
15004 DATA . . . . . . . . . . . . . . . . . . . . . . ****
15005 DATA . . . . . . . . . . . . . . . . . . . . . . ****