Apple 1 INTEGER BASIC #2

Okay, if the Apple 1 computer does not have screen addressing, how am I doing SPIROGRAPH?

7000 REM SET PIXEL (X, Y) 0-39, 0-47
7010 Z = 1 : Q = V(10*(Y/2)+X/4+1) * 2
7020 FOR S = 1 TO 4 – X MOD 4
7030 Z = Z * 4: Q = Q / 4
7040 NEXT S
7050 Q = Q MOD 4: Z = Z / 4
7060 IF Y MOD 2 = 0 THEN 7080
7070 IF Q MOD 4 = 0 THEN V(10*(Y/2)+X/4+1) = V(10*(Y/2)+X/4+1) + Z: RETURN
7080 IF Q MOD 4 = 0 THEN V(10*(Y/2)+X/4+1) = V(10*(Y/2)+X/4+1) + Z * 2: RETURN

8000 REM PRINT SCREEN 40 * 48; TBTBTBTB
8010 FOR Y = 0 TO 23
8020 FOR X = 0 TO 39
8030 IF Y = 23 AND X = 39 THEN RETURN
8040 Z = V(Y * 10 + X / 4 + 1) * 4
8050 FOR S = 1 TO 4 – X MOD 4
8060 Z = Z / 4
8070 NEXT S
8080 Z = Z MOD 4
8090 IF Z = 3 THEN PRINT “:”;
8100 IF Z = 2 THEN PRINT “‘”;
8110 IF Z = 1 THEN PRINT “,”;
8120 IF Z = 0 THEN PRINT ” “;
8130 NEXT X
8140 NEXT Y

As the screen is 40 x 24 characters, it would be nice to make that 40 x 48 — using ‘ , and : to double vertical resolution.

First I made an array of 240 integers.  It would have been nice to make an array of 40 x 48 integers, but there isn’t enough memory, and two dimensional arrays are not supported.  So I had to fit two vertical dots and 4 horizontal dots into one integer.  Then, using shift-by-divide and the MOD function, I could calculate what I wanted on the screen, and finally print it all out at once.  However, I didn’t print out the last character, as that would have scrolled the screen.

Spirograph is round, so the 48 lines vertically are not needed.  And, this is important, because the program actually loads, but does not run — getting an out-of-memory error.  Deleting some of the many REMarks frees up enough space to run.