Introduction
The game includes a simple compiled programming language, conceptually similar to
AWK . Each entry includes a number of
patterns or clauses, that if all are true, invokes one or more actions.
The logic for each room is stored in various buffers starting at
E80F (for the Town Square).
These are accessed by the routine at
EABF. The routine starts by checking for patterns,
but switches to checking for actions taken if those patterns are all true with byte F7.
A new pattern is then identified with byte F6. Byte FF signals the end of the logic.
Each room also contains a set of custom code that can be executed on entry. These are
stored in a table at
EEF3. If there is no custom action for the room, the table's
entry is
F2F6, which is a simple RET instruction.
Patterns
A pattern is identified by the byte sequence opcode,[operands]. The number of bytes used as
operands is dependent on the specific opcode.
The routines to handle each pattern is stored in a lookup table at
E7E9.
Value |
Instruction |
Description |
0 |
AT_OBJ(n) |
True if the player is standing next to the 'n'th object in the room. |
1 |
HAS(n) |
True if the player is holding object 'n'. |
2 |
IS_SET(f) |
True if the flag 'f' is set. |
3 |
IS_OBJ(n,i) |
True if the 'n'th object in the room is 'i'. |
4 |
AT(x,y) |
True if the player is standing at co-ordinates x,y. |
5 |
AM(n) |
True if the player is using the character with this ID. |
6 |
NOT_HAS(n) |
True if the player isn't holding object 'n'. |
7 |
NOT_OBJ(n,i) |
True if the 'n'th object in the room isn't 'i'. |
The character IDs used in opcode 5 (AM(n)) are:
Value |
Character |
01 |
Wally |
02 |
Wilma |
04 |
Tom |
08 |
Dick |
10 |
Harry |
Actions
An action is identified by the byte sequence opcode,[operands]. The number of bytes used as
operands is dependent on the specific opcode.
The routines to handle each action is stored in a lookup table at
E7F9.
Value |
Instruction |
Description |
0 |
SWAP |
Swap the least-recently picked up item for the nearest one in the room. |
1 |
SWAPFOR( n ) |
Swap object with ID 'n' that the player holds for the nearest one in the room. Used when a combination of items held or near reacts to produce another one, such as swapping the sand for the cement when holding a full bucket. |
2 |
SET( f ) |
Set flag 'f'. |
3 |
RESET( f ) |
Reset flag 'f'. |
4 |
SET(f, i) |
Set the value 'x' to 'i'. |
5 |
EARN(i) |
Earn the amount of money indexed. |
6 |
WALL |
Build the wall. Only relevant in Wall Street. |
7 |
SPACE |
Enter the asteroids game. Only relevant when standing near a phone booth. |
8 |
SAFE |
Blow the safe, get the money and complete the game! Only used in the bank. |
9 |
CHASE |
Open up the floor and drop the player down to the "chase the shark" room. Most often used when some task needs to be completed at a location, but the player has the wrong character and items. |
A |
OUT |
Enter the "out of town" room. |
Money
The money earned by various tasks is defined in a table at
EC5C.
Each entry in the table contains three bytes:
Byte |
Character |
0 |
Set to 1 if the task earning the money is completed, or 0 if not |
1 |
Money low byte |
2 |
Money high byte |
Money is always given in multiples of £10.
The high byte is the hundreds part of the money. The low byte is the tens part of the money.
In both cases, only the top nybble is used (as a decimal digit can be represented as four bits).
Example : $00, $50, $01 = Entry 1, £150.
The maximum amount of money that can be earned is defined at
ECFC as £4,000.
Morning, lunch and tea breaks and the end of the game are reached when a certain amount
of money has been earned, defined in entries at
ECF6. These are:
Byte |
Character |
£600 |
Morning tea break |
£1,300 |
Lunch time |
£2,100 |
Tea time |
£4,000 |
End of game |
The index of the next index into the buffer is stored in
ECF5.
Computer characters
The computer characters run off a list defined at
AEEA, which contains a target room for
them to move to, where they will swap with the first item in the room. The list is terminated
by FF.
Whenever a computer character has swapped with an item, it picks the next entry off the table
to decide where it's going to move to. As different characters swap at different times,
always taking the next room ID in the table, it looks pseudo-random to the end user.
The table at
AD78 explains how the computer character needs to move between the current
and the target room. Each entry contains a pair of bytes. The routine at
ADBA, called
when a character enters a new room, takes
the cumulative difference between the two pairs of bytes (in the next room and the
target room) and assigns it a "score". It compares it against a running "best score"
(initialised to FF so the first entry will always return a better result), and picks
the room with the lowest score, which moves the character towards the intended room.