The Apple II released in June 1977 was one of the first successful mass-produced computers and Apple’s first personal computer aimed squarely at the consumer market. The hardware was designed primarily by Steve Wozniak and the case by Steve Jobs, who we both know as the founders of Apple. In 1977, there were three machines vying for attention and inclusion in our lives: the Apple II, the Commodore PET and the Tandy TRS-80. In the USA, the Apple II was adopted and loved by a generation of coders who took their first steps with this great machine.
Emulating an Apple II
The cost of original Apple II hardware has skyrocketed and so to take our first steps with this great machine, we look to emulation via microm8.
1. Download and install microm8 for your operating system.
2. Open the microm8 executable. On first boot it will need to update, so be patient.
Once it has finished updating, microm8 will restart and present a rather retro 3D menu (see above).
3. Select Applesoft BASIC to open the BASIC interpreter.
BASIC is a general purpose high level language and the original version was designed by John G. Kemeny and Thomas E. Kurtz and was released at Dartmouth College in 1964. In basic terms (no pun intended), BASIC is a human readable language that uses words common in the English language.
BASIC is the Python of the 1970s and 80s. Machines such as the Apple II were designed to boot straight into BASIC and from there we can write code and basic file operations.
Creating a Number Guessing Game
For our BASIC project we shall create a number guessing game. we have ten chances to guess the correct number before the game ends. If we guess too high, the game will tell us so, the same is true if we guess too low.
1. Line 10, create a variable, N and inside the variable store a random integer between 0 and 50.
10 N = INT(50*RND(1))
2. Lines 20 and 30, write two instructions to the player. The first informs them that they have ten attempts to guess the number, and then it asks for their guess.
20 PRINT "YOU HAVE 10 TRIES TO GUESS THE CORRECT NUMBER" 30 PRINT "WHAT IS YOUR GUESS?"
3. Line 40. Create a for loop that will iterate ten times.
40 FOR C = 1 TO 10
4. Line 50. Capture the user's answer into a variable, G.
50 INPUT G
5. Lines 60 to 80. Create three conditional tests. Each test will check the value of the user's answer, G, with the randomly generated answer. If the answer is too high or low then a message is printed to the user. If their guess matches the random value, the code jumps out of the for loop.
60 IF G > N THEN PRINT "TOO HIGH"; 70 IF G < N THEN PRINT "TOO LOW"; 80 IF G = N THEN GOTO 130
6. Line 90, check the value of the variable C, which counts from 1 to 10. If the value of C is not 10, then print “TRY AGAIN” and then for line 100 iterate the for loop by one and the code will loop back to line 50.
90 IF C<>10 THEN PRINT " TRY AGAIN" 100 NEXT C
7. Line 110, create a “bad ending” for the game. If the player doesn’t guess the number then lines 110 and 120 will be our game over screen.
110 PRINT " I'M SORRY YOU FAILED...GAME OVER!" 120 END
8. Lines 130 and 140 are the “good ending” of the game, activated when the player wins the game.
130 PRINT "YOU GUESSED CORRECTLY" 140 END
To run the game, type RUN and try to guess the correct number.
Playing a Game on the Apple II
The Apple II had many great games, some of which were ports from arcades and other consoles while others were made directly for the Apple II. Luckily for us microM8 comes with an extensive catalogue of games builtin.
1. From the microM8 menu screen press B to open the disk catalog.
2. In the Disk catalog look for “appleii” and double left mouse click to open.
3. Click on the “disk images” folder.
4. Click on Games and then select a letter from the list to show games starting with that letter. Select your game and enjoy!
This story originally appeared in an issue of Linux Format Magazine