10 PRINT on the Apple II
By Michael Doornbos
- 2 minutes read - 422 wordsThe quest continues: 10PRINT on all the things! This time we’re bringing the classic maze generator to one of the most iconic computers of the 1970s and 80s: the Apple II.
The Apple II
The Apple II, introduced in 1977, was one of the first successful mass-produced microcomputers. Designed primarily by Steve Wozniak, it featured a 6502 processor running at 1 MHz, came with 4KB of RAM (expandable to 48KB), and introduced color graphics to personal computing.
The machine shipped with Applesoft BASIC in ROM (on later models) or Integer BASIC on earlier models. Applesoft BASIC, developed by Microsoft, became the standard BASIC for the platform and is what we’ll use here.
The Apple II’s 40-column text display and unique character set make it an interesting platform for 10PRINT. Unlike the Commodore 64 with its PETSCII graphics characters, the Apple II uses standard ASCII, so we’ll need the same approach we’ve used on other non-Commodore platforms.
Let’s do it
On the Commodore 64, 10PRINT looks like this:
10 PRINT CHR$(205.5+RND(1));:GOTO 10
Characters 205 and 206 are the diagonal line graphics characters in PETSCII. On the Apple II, we need to use ASCII instead. The forward slash / is character 47, and the backslash \ is character 92.
The difference between them is 45 (92 - 47 = 45). We can randomly add either 0 or 45 to 47 to get one character or the other:
10 PRINT CHR$(47 + INT(RND(1) * 2) * 45);: GOTO 10
This works exactly like our implementations on the AIM 65, KIM-1, and other non-Commodore platforms. Type it in, hit RUN, and watch the maze fill your screen.
Not terribly good as many other vintage computers thanks to the generous charachter spacing between the rows, but it works.
A Note on RND
Applesoft BASIC’s RND function has a quirk: RND(1) generates the next number in a pseudo-random sequence, but the sequence is the same every time you power on. If you want a different maze each time, you can seed the generator with a negative number:
5 X = RND(-PEEK(78) - PEEK(79) * 256)
10 PRINT CHR$(47 + INT(RND(1) * 2) * 45);: GOTO 10
Line 5 seeds the random number generator using the system’s internal timer values, giving you a different maze pattern each run.
The Apple II proves once again that 10PRINT transcends platforms. One line of code, smooth scrolling courtesy of the ROM, and that familiar maze pattern filling the screen.
What’s your favorite version? And more importantly: what platform should 10PRINT conquer next?