Code Links


"This questionnaire is not an official psychological test and is not endorsed by any reputable doctor. Only the doctor that you'll find in Bedlam endorses this crazy test. Although the test is mostly for fun, it does have a purpose. Concealed within the questions and score evaluations are clues which should help you escape Bedlam. You may not recognize the clues in the questionnaire until you try to escape from Bedlam." - From the game manual

Tour Guide

The code is practically a virtual-machine for the game written in adventure-language. The Main Loop decodes the complex user input with nouns, verbs, adjectives, and prepositions.

Have a look at the Adventure Language Processor and all its complex commands.

Have a look at the Phrase List that describes the forms of all known input lines.

The Bedlam game has fewer rooms and more object interactions. Visit all the Room Definitions. Then have a look at the Objects and their scripts.

Have a look at the General Command Script that processes commands not handled by the current room.

Look through the game's list of all known words.


If you seek specific game information, solutions, and online emulators then check out Sean Murphy's wonderful site.
Solutions and info on Pyramid 2000, Raaka-Tu, and Bedlam:

Check out Aaron Wolfe's awesome port of Bedlam to the Android platform. He is working on Raaka-tu next!

The Evolution of the Engine

I will follow Arnstein's adventure language and interpreter as it evolved from Pyramid 2000 to Raaka-Tu and finally to Bedlam. Be sure to visit those pages as well:

A Year Later

A year later the engine in Bedlam is almost identical to that of RaakaTu. The RAM usage is identical between the two. Bedlam adds a needed automatic MORE prompt to the print routine that was in Pyramid but fell out with RaakaTu.

Bedlam adds the ability to give a command to an object. For instance you can tell NAPOLEAN GET KEY. An additional object field, Field "11", contains the handler for "being commanded".

Bedlam adds a SYSTEM object that can be the "object executing the script" instead of the player or another object. Messages generated by the SYSTEM object are always printed to the screen. Messages from other objects are filtered by location.

The adventure language for BEDLAM does not use a few of the commands that RaakaTu does. For instance, there is no score. Rather than repurpose these command numbers the jump tables is filled with pointers to "do nothing" code. This allows the same script compiler to work for BEDLAM and RAAKATU. BEDLAM adds a few commands related to opening and locking objects.

Objects have taken on a "lockable" and "openable" attribute with additional bits in the object data field. Evidently this feature was added halfway through the scripting of Bedlam. There is a common command that prints "WHICH IS CLOSED" presumably used in door descriptions. But the functionality got moved into the engine as a general property of printing object descriptions in a room. If an object is "OPENABLE" then the "WHICH IS CLOSED" is tagged onto the end of the description if it is closed. If the state is open, the description is silent. This is coded in assembly as part of the engine, but the "WHICH IS CLOSED" feature remains as a script-function though it is never called.

Thus open doors are just doors but closed doors are noted. CLOSED is a notable condition for a door. But the refrigerator should be noted if it is open. If you leave the fridge open you should see "WHICH IS OPEN". Instead, the script does not allow you to leave the door open. The fridge automatically snaps shut after you open it.

Proper-name processing is built into the script as a common script-function "AA". Short names for Napoleon and the refrigerator are "NAPOLEON" and "REFRIGERATOR". But a common error message involving both might be "YOU CAN'T ATTACK THE REFRIGERATOR" and "YOU CAN'T ATTACK NAPOLEON". For non-proper names the message needs a "THE" before . Common script-function "AA" prints an object's short name with a leading "THE" if it is NOT a live creature. That assumes that all live creatures in the game have proper names. In the case of "THE DOG", the short description includes "THE" since the description isn't a proper name as function "AA" thinks.

Bedlam uses adjectives to distinguish RED DOOR from GREEN DOOR. If you are in a room with only one door, then "OPEN DOOR" will work fine. If there is more than one door you'll have to "OPEN RED DOOR". The engine will prompt you with a ?WHICH? if it needs it.

Adjective processing was available in the RAAKATU engine, but none of the objects had any adjectives. Field "1" of each object is a list of adjectives attached to the object. The engine processes the adjectives automatically to locate the right 1st and 2nd nouns. Once processed by the engine adjectives can be ignored in the adventure script.

In RAAKATU object Field "3" (long description) was a static string. In BEDLAM it is a script. Most of the time the script just prints a static string. But for "people" objects the script prints a long introduction the first time you meet the person. The script then switches the object for another object that prints a shorter description from then on. Thus the people in the game cleverly remember that they have met you whether you remember them or not.


CommonCommand 94 sets up the game by moving the game objects into position. Many of objects are distributed randomly, and one of three solutions is picks at random. I will call these the BLUE-PILL-EXIT, the NAPOLEON-EXIT, and the PICASSO-EXIT.

Blue Pill Exit

There are two blue-pill objects in the code. If the game picks the BLUE-PILL-EXIT then you get BluePillA. Otherwise you get BluePillB. Both pills can be dissolved in the hamburger meat and fed to the dog. But BluePillA is poison and will kill the dog. The command script for room 93 (THE KENNEL) checks the status of the dog with every command you issue in room 93. If the dog is dead then the guards lock you in the storage shed. There is a green escape door in the shed. That's the BLUE-PILL-EXIT.

Napoleon Exit

The NAPOLEON-EXIT involves a secret door placed randomly (within limits) in the hospital. The door is secret in that it does not show up in normal room descriptions. If you EXAMINE the rooms you will see it. Also XRay Johnson will see it for you. But it is much easier just to EXAMINE as you walk around.

Like the blue pill, there are a couple of versions of the Napoleon object. You get NapoleonB if the game picks the NAPOLEON-EXIT. Otherwise you get NapoleonA. Napoleon is strong and you can tell him to open things. In fact NapoleonB is the only way to open the secret door. NapoleanA will complain about being tired. The trick with the NAPOLEAN-EXIT is to find the secret door and to get Napoleon to it (see people-movement below).

Picasso Exit

The PICASSO-EXIT involves opening a door that Picasso paints on the wall. There are two Picasso objects: PicassoA and PicassoB. Both paint a non-openable door at random, but PicassoB also paints a door in your cell that you can open. You'll get PicassoB if the game picks the PICASSO-EXIT. PicassoB is much more aggressive with the doors. Every time he changes rooms the regular painted door goes with him. PicassoA is much more reserved about painting.

The PICASSO-EXIT involves waiting for Picasso to visit your cell. Then you open the painted door and escape. Note that the TRS80 version of the Picasso logic is a bit different from the CoCo version. The TRS80 version seems to allow Picasso to paint the exit door anywhere while the CoCo version is fixed to your starting cell.

Houdini, Merlin, XRay Johnson, and More

There are several other colorful people you will meet in the game. You'll meet Houdini hanging from the ceiling in a straight jacket. You can let him down and he will struggle with the jacket, but he'll never get out of it. Merlin will just say random things. There is a "real" doctor who has been tied up by a patient you'll meet in disguise. The "real" doctor drops into unconsciousness and out of the game. The "fake" doctor will give you a lobotomy that you'll actually need to get a key from the nurse!

XRay Johnson can see the PICASSO-EXIT even before Picasso gets there to paint it. He can also see the secret door. You can tell Ray which direction to go in and he'll obey (if he can). The other people have a mind of their own.

People Movement

The people objects all use a common movement script: CommonCommand 9C. Most of the time (90%) the people will move in the direction you just moved in no matter where they are. This has the side effect of having them follow you once you bump into them. It also means they will tend to move away from you until they bump into a wall and you find them. The other 10% of the time they try to attempt a random direction getting separated from you if they were following.

Houdini does not move. If any of the people bump into Houdini they will not execute the 90% do-what-you-do case. There is still a 10% chance each turn that they will move at random. This will take them away from Houdini and they will move again. But in general Houdini is a magnet that holds the others captive for a bit.

CommonCommand 9A is used if a command is given to a person when the person is not prepared to handle it. This script prints messages for WHAT, COME, WAIT, and MEET. Despite the messages, the COME and WAIT have no effect on the objects. All other commands get a random "no" that can be quite humorous.

Frontal Lobotomy

The crazy doctor is an interesting touch to the game. The green key is in the electro-shock room with the nurse. The action-script for the nurse gives you an instant shock treatment which returns you to your room ... without the key if you just picked it up.

The crazy doctor gives you a lobotomy which drops object 3A in your pack. The action script for the player object checks to see if 3A is in the pack. If it is then the player is given a random movement command. This is the "wandering" you feel like doing after the lobotomy.

If you manage to get into the electro-shock room with 3A in your pack, and that takes some doing, you can get the key and let the 3A random-movement take you back out of the room (hopefully -- it may take a few tries). Since the player object (13) executes before the nurse object (2D) the random movement will fire before the nurse's script can shock you. You then use the PLUGH command to take 3A out of your pack. The PLUGH command goes all the way back to Colossal Cave Adventure.