Discovering a Text Adventure Game
In this session, we are going to be evaluating code extracted from a text adventure called ‘Old West’. I came across this interesting program after browsing a copy of a book called Compute!’s Commodore Collection Volume One at my local library in the early 80’s. It was bundled with other programs in Chapter 1 titled ‘Games’ on page 15. This program was more than just an average text adventure, since it utilized two dimension arrays to track room movement accessibility, strings that contained the verbs and nouns, DATA statements that created the maps and objects, one dimensional array that displayed the objects that were visible before and after a logical step was completed, and there are variables that are used as flags to show a specific task has been completed. There is much more than this, but that is the gist of the program.
Interacting with the Game
By definition, a text adventure is a role playing adventure that interacts with a user using a two word entry of verb and noun. These were first made popular by a company called Infocom, with an adventure series titled Zork. So in this type of adventure the player utilizes the commands to move around in what is known as a game map, and uses them to take action on objects in range. Many game players learned to create their own map after navigating through a text adventure to learn about all of the opportunities that existed around them. Making a log like this also helped users to uncover clues that could easily be missed if you are walking around a very large map. Simple commands consisted of the word ‘LOOK’ to examine your surroundings, ‘GET OBJECT’ (name inserted with OBJECT) to pick up items in range, ‘INV’ (for inventory) to see what you are holding, and sometimes ‘QUI’ to quit the game. The goal is to discover new commands throughout the game as you communicated with beings, picked up objects, and very often examined things around you.
Analyzing the Text Adventure
When ‘Old West’ starts up on the C64 the screen is cleared, arrays are initialized, data is read into arrays, and soon we see the words ‘I hear a horse’ on the screen. Within a few seconds more words fade into view and we see the words ‘Cloppity’ repeated in succession down the screen. This creates a vision of a horse coming into range, and since we currently live in the age of automobiles, it is no surprise that we have been planted in a western town, hence the name of the program.
Several seconds after the cloppity words are removed from view, we get our first taste of this adventure. Apparently our horse is nearby. The room locations tell us this moment that we are in a Dusty Street. Some adventures don’t explain if you are standing or sitting and leave that up to you to figure it out. However, this one allows you to instantly move around, so it is obvious you are on your feet. The game says you see a poster and your obvious exists are North, South, or East (N, S, E). So to move around you choose a location in the game advances you in that direction. Before exploring a new room you type the words READ POSTER to look at the poster in view. The words Wanted Alive-Black Bart! $1000 reward appear. So the goal of the game has been revealed already.
Warning: Many clues will be given to this game, so you can cease reading if you decide to play the game and want to figure it out for yourself.
Next you decide to walk to the North (choosing N). The previous text is erased and the new room appears. You are still in a Dusty Street. In range you see a horse trough and a bucket. The obvious exists are South, East, or West. Next you type the words GO TROUGH. The words ‘Splash I’m all wet. You found something’ appear. Then the text fades and you now see an object called shiny star in the horse trough. At this point you can pick up the object. So typing the words GET STAR causes the computer to respond with ‘Okay’.
In this adventure only one command is needed. Next you decide to check your inventory. You type the letter ‘I’ and the system soon says ‘I’m carrying shiny star’. When playing a role playing adventure it is often important to check your inventory. Many times you will discover clues with the objects you possess.
Walking to the West seemed ideal to to learn more about your world. So the letter ‘W’ is typed and the Return is pressed (on a typical Commodore 64 or Enter when using the VICE emulator) and your new room is seen. Now you are in a Saloon. You see a room in back, and a bottle of elixir. The only direction you can move in is east. You enter ‘GET ELI’ and are quite surprised when the game responds with ‘I don’t see it here’. At this point, I noticed the game was requiring you to learn a new noun to pick up the elixir. A quick search of Google confirmed that elixir is a sweetened liquid usually containing alcohol. However, the game is actually waiting on the clue words GET WHI (for whisky). Later, I decided to change the string context to accept the letter WHI instead of ELI since it made for an easier playing game.
At this time you have arrived at a hidden location, but it is not known yet. There is a secret room in range, but the interpreter is waiting patiently for you to discover it. There is a room in back’, but you cannot proceed in that direction. The answer is to type the words GO ROOM’ (or GO ROO) to get into the hidden room. Many text adventure led game players down rabbit holes until they could learn how to get out of a dark tunnel, hole, or in this case move to a room that seemed to be mentally barred.
Soon the new room is revealed as Room in Back. Suddenly you see Black Bart standing before you. The game decided not to trap you in this room (as was common with many adventures), but instead still allows you to move East from the direction you came in. If you try to GET BART the game will end since he gets mad and finishes you off. The secret is to GIVE WHI. Then you see the words ‘Black Bart gulps elixir and immediately falls asleep’. Now it is safe to GET BLA (get Black Bart).
To keep this article from getting too long, I will now dig into the code some more so we can learn how it works. You can also watch the YouTube video at the top of this page to hear my verbal explanation. The game map consists in total of 10 rooms (several are hidden). As we delve into the code, you will get a clearer picture of how the game logic works, and hopefully be inspired to write your own text adventure soon.
Examining the C64 Game Map
To make the logic easier to follow I have broken down the context of the program into bullet points below. Otherwise this would involve a lot of explaining line by line. It is easier to lose a reader in this manner, so I shifted gears here.
My goal is to hopefully find a way to allow access to a Basic download through d64 images. However, to my disappointment, I discovered that WordPress does not allow these type of uploads (because of the MCE Editor). It is used to also rip out scripts that pose a threat. So I created the PDFs by copying snapshots from VICE to Word for now. The only disadvantage is that it is unable to copy the special characters, so listings are not completely accurate. For now this will have to do unless I decide to eventually port everything to Github. You can view the PDF listing for Old West on my Basic Old West Files page or click on the image below.
C64 3D Books
Listed below is a PDF for the Old West Basic programming code and the original book. I found this text adventure within the pages of Compute!’s Commodore Collection Volume One. You can view the program and information starting at page 15. These PDFs can be opened like a 3D book. Just click on each individual image to view them.
[3d-flip-book mode=”thumbnail-lightbox” urlparam=”fb3d-page” id=”1859″ title=”false” lightbox=”dark”]
[3d-flip-book mode=”thumbnail-lightbox” urlparam=”fb3d-page” id=”1874″ title=”false” lightbox=”dark”]
Variables Defined
Variable | Description | Program Lines |
---|---|---|
C1,K1,L1,B1,W1,J1,S1 | Flags that control tasks completed | 100,310,430,435,440,450,460,465,490,805,842,845,850,890,995 |
N$(x) | Contain the objects and hidden objects | 500,860,890 |
V1$ | Move directions | 550,780,1110 |
V$ | Game verbs (two letter commands) | 150,160,560 |
N$ | The game’s objects (two letter commands) | 210,220,465,570,730,855,856,1120 |
L(x) | Controls the items you can see (or that are concealed currently) | 135,310,381,382,410,425,435,444,445,460,490,600,610,730,810,842,845,850,856,860,870,880,900,995 |
M(x,y) | Contains the room matrix, which shows the direction you can move in. A zero found here means that movement is blocked. | 135, 310,355,360,620,630,640,642,775,860 |
R$(x) | Current room location | 650,675,700 |
TD | Delay loop – to pause the message ‘I hear a horse’ seen on the screen | 120 |
CY | Loop that changes the ‘cloppity’ colors and repeats the words down the screen | 126 |
N | noun variable that tracks the noun entered. Example: N=13 (line 132) is pointing to ‘BL’ – Black Bart | 132,225,227,310,350,355,360,370,380,385,405,420,425,430,435,440,441,444,460,480,800,805,842,845,900,910,950,980 |
S | Flag that tracks if you can see something on the screen. S=0 will print ‘nothing special’ otherwise | 145,750,760,1080,1140 |
I | Loop that reads through the verb entered (V$). There are 20 verbs. It reads it in two step increments to read each addition verb in the string. Example: V$=”GOTAGEPIOPPUDRMILOGISWFIREUN”. So if you enter GO it reads the first section. Then skip two letters and you will see TA to read TAKE. This reads through based on the verb you typed in | 720 |
L | Current room. This is tracked in line 730 to show the objects displayed in each room. It is matched against the array L(x). The variable is created in line 370 to read the room matrix into it. Example: L=M(L,N-21) | 132,310,355,360,370,380,385,425,430,460,490,730,765,775,845,860,876,950,980,1080 |
A$ | String variable that reads the input for the player (consisting of move directions (N,S,E,W), (I – inventory), (QU – quit), and the verb and nouns entered | 875,1000,1005,1010,1020,1030,1045,1060,1110,1120 |
B$ | String variable that stores the noun entered. Line 1120 reads the noun from the array N$(x). In line 1120 it ends up here if you have type in a move direction (N,S,E,W) and stores it in the variable B$. This ends up storing the two letter movement (SO,EA,WE,LO) there, reading in increments of two letters. Example: B$=MID$(N$,2*I+41,2) | 200,220,1000,1030,1120 |
V | Stores the verb variables. Line 160 reads through each verb. Example: V=(I+1)/2 – to read every second two letter combination in the V$ variable | 160,300 |
C | Variable that keeps a count of how many items you are carrying. Line 400 NN$(x) – This variable changes an object to indicate further tasks have been completed. Example: Line 430 changes the ‘sink’ seen to ‘sink full of water’ when checking your inventory after you type ‘FILL SIN’ (fill sink) |
430,435,445,810,850,860,890,900 |
NN$(x) | This variable changes an object to indicate further tasks have been completed. Example: Line 430 changes the ‘sink’ seen to ‘sink full of water’ when checking your inventory after you type ‘FILL SIN’ (fill sink) | 430,435,445,810,850,860,890,900 |
C$ | This variable is used when you need to complete a second part to a task: Example: Line 845 is used to interact with the window (‘WI’) | 830,840,845,855,990,995 |
[…] Previous Next […]