Calormen website provides an online Applesoft BASIC emulator, developed in javascript. You can enter or upload your code into the emulator and run it immediately, without having an emulator installed on your PC. You can also find on the website numerous examples of source code in Applesoft BASIC, such as games and graphic demos.
Among these programs, I’ ve found a text adventure game called Tays House Adventure developed by Floyd McWilliams. The aim is to find treasures while avoiding traps in the house of your obviously mad Uncle Tays. Nothing very original, but what caught my attention was the way how the BASIC program was written; all character strings are encrypted, to avoid a hacker/player inspecting the source code to crack the game. For example :
300 DATA "7UVYAO5", "2UQWVJ3", "2GCUV1", "7DLZA3", "9DY5", "5ITBS2", "6T8", "2U3", "2G9", "2Y7", "8C5", "8L8"
305 DATA "2K3", "1JOWFOUPSZ8", "1TDPSF0", "8RCUX6", "3KHOS7"
310 DATA "4XEOI3", "7KYVW9", "6RUUQ9", "3UHDG4", "9NGJVRWN9", "5ZSQTHP0", "9NJC8", "6YVOT4"
So I wrote a program in Python that decrypts all character strings and returns a BASIC program where everything is readable. The aim is to obtain an Applesoft BASIC program with no encrypted data.
Step 1: download the GAME
Go to the emulator page, Select the Text Adventure (Floyd McWilliams)
program. You can download the source code using icon.
I had to correct the program thanks to Visual Studio Code, since Applesoft BASIC extension displayed several errors: invalid variable names and line numbering errors. Here is the program fixed:
Step 2: decryption
You can find hereafter the Python program that go through the previous BASIC program and decrypts all strings. The subroutine located on line 10000 of the BASIC program performs the decryption so it was easy to translate this portion of code into Python code.
Once untared, the Python program is to be used as follows:
./clear_adventure.py tays_house_adventure.bas
The deciphered BASIC listing will be display on standard output, unless you specify the output file with -o
option.
Here is an extract of the output file :
300 DATA "NORTH", "SOUTH", "EAST", "WEST", "UP", "DOWN", "N", "S", "E", "W", "U", "D"
305 DATA "I", "INVENTORY", "SCORE", "JUMP", "HELP"
310 DATA "TAKE", "DROP", "LOOK", "READ", "EXAMINE", "UNLOCK", "EAT", "SPIN"
Step 3: Finalisation
The deciphered BASIC program needs to be tweaked slightly, by removing the decryption from subroutine located from line 10000:
10000 D2$=D$
10070 IF SP THEN PRINT ".";
10099 RETURN
The decrypted and operational Tays house adventure program can be downloaded here :
Step 4: play
Now you can play Tays House Adventure on your Apple II or your favourite emulator.
You can find some ressources about this game here :
- On the Interactive Fiction Database.
- A solution by Jim Gerries
- Even a video about the game on Youtube from Jim Gerries who ported the game to TRS-80 MC10.
- Another place to download the original Applesoft version.