My Apple IIe: A simple text based arcade game in Applesoft Basic

apple-second-logo-rainbow-bitten

If we type this simple 8 line Applesoft Basic program into my working Apple IIe computer, we will end up with a cool little text based arcade game!  Watch the video below to see the game in action!

This small Applesoft Basic program was published in one of my Beagle Bros Apple Software Catalogs from 1987 (volume 0, number 10).  This little program was credited as being submitted by Beagle Bros customer Tim Boehme, who received a box of Beagle Bros magnetic write protect tabs for his efforts!

Wow!  Write protect tabs!  Amazing!  🙂

Applesoft Basic

Applesoft Basic is the programming language of all the early Apple computers and was provided in ROM (memory) to make it available to the user without the need for a startup disk or the need to load it into memory from a cassette tape.

Applesoft Basic was actually created by Microsoft for Apple.  Hence the name.  It is interpreted and not compiled, so it is not very fast.  And it can throw syntax errors at runtime if it’s unable to interpret a line of code.

One sort of funny feature of Applesoft Basic is that variable names are only significant to 2 letters, although it allows more.  So if you initialize a variable named “KURT” to a value of 10, you can PRINT the variable “KU” and also the variable “KURT” and also the variable “KUPP” and they will all three show a value of 10.  They are all three pointing to the exact same memory location.

applesoft-iia

Code

Here’s the source code:

10 REM "MUNCH THE SNAILS!"
20 TEXT: HOME: H = 20: PRINT CHR$ (21): POKE 35,22
30 K = PEEK (49152): ON K < 128 GOTO 40: H = H + (K = 149) - (K = 136)
40 POKE 49168,0: IF RND (1) * 10 < 1 THEN VTAB 20: HTAB RND (1) * 20 + 10: PRINT "@": GOTO 70
50 VTAB 22: HTAB RND (1) * 39 + 1: PRINT CHR$ (46)
60 IF PEEK (1535 + H) = 192 THEN S = S + 1: VTAB 5: HTAB H: PRINT "#"; CHR$ (7): VTAB 23: PRINT "MUNCHED: ";S: GOTO 80
70 VTAB 5: HTAB H: PRINT "V"
80 T = T + 1: IF S < 10 THEN 30
90 TEXT: VTAB 23: PRINT S;" SNAILS MUNCHED IN ";T;" SNAIL SECONDS.": END

Emulators

If you don’t have a working Apple IIe of your own to try your Applesoft code on, you can first try it in a JavaScript implementation of Applesoft Basic.  There are some things that this emulator cannot do, though.  It’s just not terribly robust.

A very robust option is the standalone Apple II emulator program that you can install onto your Windows computer.  It’s called AppleWin.  Just scroll down to the bottom of the Github page and download the latest release.  It’s in a zip file, so just unzip it and run the executable.

Once it starts, just click on the floppy disk 1 icon and choose the master disk file that comes installed with the emulator.  Then reboot with the Apple button and it will boot to Applesoft Basic.  Or, you can download ROMs for various Apple games and programs from the Internet and boot those instead.  It emulates the speed of the processor, so it’s a very realistic emulation of the Apple IIe.  Including several monitor types to choose from.

Thanks

I hope you found this post informative and/or entertaining!  Thanks for your interest!  And feel free to leave comments or questions below!

Thanks,
Kurt

7 thoughts on “My Apple IIe: A simple text based arcade game in Applesoft Basic”

  1. could you add some color and there is a delay between the button press and the actual movement

  2. For those interested… at 6:35 he mentions that wasn’t sure what the Peek(1535+H) was doing exactly…
    This was looking directly at the video memory – specifically the ROW starting at 1535, with an offset into that row of H (the position of the where the letter ‘V’ should be.)

    0400-07FF Text screen and “screen holes”, which contain system data
    Think of it as a 2×2 matrix
    ROWxCOL
    Here’s the memory address starting values for TEXT mode for the all 24 rows….just need to add for each of the columns. VTAB 5 (row 5) is where the player V is always at, so:
    in the table below ROW 5, COL 1 is at 1536. (or 1535 + COL).

    Which is why the code is looking for 1535 + H. (h is the column where the V is at).
    1.
    1 1024
    2 1152
    3 1280
    4 1408
    5 1536
    6 1664
    7 1792
    8 1920
    9 1064
    10 1192
    11 1320
    12 1448
    13 1576
    14 1704
    15 1832
    16 1960
    17 1104
    18 1232
    19 1360
    20 1488
    21 1616
    22 1744
    23 1872
    24 2000

  3. It says unsupported peek location 1555 in applesoft basic and always gives errors in every other emulator.

  4. It is possible to add some colors if your Apple II has a Chat Mauve card or equivalent that allows the double hi-res.
    Then you can specify the background color and the text color between 16 different colors (that are the same colors available from the GR low graphic mode of the Apple IIe)
    I used this double hi-res mode to add some color to games like Castle Wolfenstein something like 35 years ago: the commends are &GR instead of GR or HGR in my souvenirs

Leave a Reply

Your email address will not be published. Required fields are marked *