Sherlock: annotated disassembly

Trains and cabs

Sherlock has two kinds of public transport. Trains run to a timetable whether or not you are there: eight steam trains circle the underground stations and run the Leatherhead line. Hansom cabs are the opposite: they stand off stage until somebody hails one, and they go nowhere unless they are told to. Both are ordinary things that hold other things, so a passenger is simply something inside the vehicle, and when the vehicle moves everything in it moves too.

The short answers

The things and rooms involved

WhatThing or room numbersNotes
Underground trainsthings 36 to 41 (actors 36 to 41)Three run one way round the platform-one stations and three the other way round the platform-two stations.
Leatherhead trainsthings 42 and 43 (actors 42 and 43)Two trains on the same three-hour circuit, half a circuit apart.
Hansom cabs and cabbiescab 30 with cabbie 31; cab 33 with cabbie 34The cabbie is always the next number after his cab (9B50 relies on it). Both cabbies are actors (9860).
Police cabthing 109, room 105 (8B65)Driven by the local police man. It has only three routes (9AA3).
Rooms for a train in motionroom 2 (84F5) for the underground; rooms 3 (84FF) and 4 (8509) for the Leatherhead lineThese are the "between stations" rooms. A passenger's own room number becomes the room the train is in.
Room for a cab in motionroom 1 (84EB)The hansom cab: the cab is put here for the length of the ride, then moved to the destination.
Station roomsAldergate 15 (platforms 16, 17); Kings Cross 19 (platforms 20, 21 underground and 22, 23 Leatherhead); Paddington 25 (26, 27); Victoria 29 (30, 31); Leatherhead 53 (54, 55)A station room has no description of its own; the trains stop only in the platform rooms.

How a timetable is written

Every actor has an eight-byte record in the actor table (9860): its thing number, the position in its plan script (+1/+2), the plan registers, and the minute at which it next acts (+6/+7). Once per turn the main loop (A064) walks the table; an actor whose minute has come runs one step of its script (CC78), and the step's duration decides when it next acts. A train's script is built from two instructions only:

A GOTO ($0E) at the end sends the script back to its start, and a PASS ($0F) is a one-minute pause. Because the waits are the only thing that spends time, adding up the minutes gives the timetable exactly.

The underground: two circuits of 30 minutes

Six trains share two scripts. The first circuit (F21D to F243) calls at the platform-one stations in the order Aldergate, Kings Cross, Paddington, Victoria; the second (F246 to F275) goes the other way round the platform-two stations: Kings Cross, Aldergate, Victoria, Paddington. Each train is a different distance round the same script because its actor-table entry points at a different instruction, so the three trains on a circuit are spread round it: ten minutes apart on the platform-one circuit, and nine, nine and twelve minutes apart on the platform-two circuit.

StepPlatform-one circuit: where the train isMinutesStart of the day
1Aldergate platform one (85AE)3actor 36 starts here
2between stations (room 2, 84F5)3
3Kings Cross platform one (85E8)3
4between stations (room 2, 84F5)1
5waits where it is (in the same room as before)2actor 38 starts here
6Paddington platform one (8642)4
7between stations (room 2, 84F5)4
8waits where it is (in the same room as before)1actor 37 starts here
9Victoria platform one (867C)4
10between stations (room 2, 84F5)5
Whole circuit30
StepPlatform-two circuit: where the train isMinutesStart of the day
1waits where it is (in the same room as before)2actor 39 starts here
2Kings Cross platform two (85F8)3
3between stations (room 2, 84F5)3
4Aldergate platform two (85BE)3
5between stations (room 2, 84F5)1
6waits where it is (in the same room as before)4actor 41 starts here
7Victoria platform two (868C)4
8between stations (room 2, 84F5)1
9waits where it is (in the same room as before)4actor 40 starts here
10Paddington platform two (8652)4
11between stations (room 2, 84F5)1
Whole circuit30

From the start of the game (8:00am) a train reaches each platform-one platform every ten minutes. Each platform-two platform gets three trains in every 30 minutes, nine, nine and twelve minutes apart. A train stays three or four minutes. The first arrivals:

PlatformTrains arrive at
Aldergate platform one (85AE)8:00am, 8:10am, 8:20am, 8:30am, 8:40am, 8:50am ...
Kings Cross platform one (85E8)8:06am, 8:16am, 8:26am, 8:36am, 8:46am, 8:56am ...
Paddington platform one (8642)8:02am, 8:12am, 8:22am, 8:32am, 8:42am, 8:52am ...
Victoria platform one (867C)8:01am, 8:11am, 8:21am, 8:31am, 8:41am, 8:51am ...
Kings Cross platform two (85F8)8:02am, 8:11am, 8:20am, 8:32am, 8:41am, 8:50am ...
Aldergate platform two (85BE)8:08am, 8:17am, 8:26am, 8:38am, 8:47am, 8:56am ...
Victoria platform two (868C)8:04am, 8:16am, 8:25am, 8:34am, 8:46am, 8:55am ...
Paddington platform two (8652)8:04am, 8:13am, 8:25am, 8:34am, 8:43am, 8:55am ...

The ride from one platform to the next is three or five minutes, depending on the stretch (the platform-one train takes 3 from Aldergate to Kings Cross, 3 on to Paddington, 5 on to Victoria and 5 back to Aldergate).

The Leatherhead line: one circuit of three hours

The two Leatherhead trains run the same script (F278 to F2A2) from different starting points. A train stops at Kings Cross platform four, shunts to platform three, then spends 65 minutes on the line in room 3, and does the same at Leatherhead (platforms one and two) before the long run back.

StepWhere the train isMinutesStart of the day
1waits where it is (in the same room as before)60actor 42 starts here
2Kings Cross platform four (8618)10
3between stations (room 4, 8509)5
4Kings Cross platform three (8608)10
5between stations (room 3, 84FF)5
6waits where it is (in the same room as before)60actor 43 starts here
7Leatherhead platform one (87FC)10
8between stations (room 4, 8509)5
9Leatherhead platform two (880C)10
10between stations (room 3, 84FF)5
Whole circuit180

The two trains are half a circuit apart, so a train arrives at each platform every 90 minutes:

PlatformTrains arrive at
Kings Cross platform four (8618)9:00am, 10:30am, 12:00pm, 1:30pm, 3:00pm, 4:30pm, 6:00pm, 7:30pm ...
Kings Cross platform three (8608)9:15am, 10:45am, 12:15pm, 1:45pm, 3:15pm, 4:45pm, 6:15pm, 7:45pm ...
Leatherhead platform one (87FC)9:00am, 10:30am, 12:00pm, 1:30pm, 3:00pm, 4:30pm, 6:00pm, 7:30pm ...
Leatherhead platform two (880C)9:15am, 10:45am, 12:15pm, 1:45pm, 3:15pm, 4:45pm, 6:15pm, 7:45pm ...

The journey from Kings Cross platform three to Leatherhead takes 65 minutes. A passenger who stays on the train is carried on: at the end of a stop the train moves to the other platform of the same station, so riding on from Leatherhead platform one takes you to platform two, five minutes later, by way of the between-stations room 4 (you cannot get out there). This timetable decides the endgame chase. Phipps boards the train that leaves Leatherhead platform two at 4:55pm, and the next one is 90 minutes behind it (E7E7).

How a train moves from station to station

The move is one action record, "put a train in a room" (E4C9, internal verb 140). It does four things:

  1. Takes the room number from the direct object ($A034). If it is room 2, 3 or 4, the train is about to leave a station, so it prints THE TRAIN PULLS OUT OF THE STATION. (7611) and uses the routine that clears the train's revealed bit (+5 bit 7, 9C60). Otherwise it uses the routine that sets it (9C56). A train is therefore visible at a platform and invisible between stations: the visibility test (C821) refuses anything without that bit.
  2. Moves the train, with everything inside it, to the room (DD0E). The move updates the +15 room byte of the train and of each passenger, and the player's own room, so a passenger's room number follows the train: 23, then 4, then 22, then 3 on the first stage of the Leatherhead run.
  3. Clears bit 6 of the new room's record (the "visited" bit), so the room description is shown in full again.
  4. Returns "done"; the script then waits the stated minutes.

Everything a train prints is shown only when the player can see it. Before each actor's turn the engine switches printing off (CC61) and switches it on only if the actor and the player can see each other (C821), so a train pulling out on the other side of London is silent. When a train arrives at your platform the move narration prints A STEAM TRAIN ENTERS.

Getting on and off

CLIMB INTO TRAIN works like getting into any container, and needs the train to be visible, which means it is at your platform. While you are aboard the room description reads "You are in a steam train" plus the platform or, between stations, "riding in a steam train through the picturesque English countryside". GET OUT OF TRAIN is refused between stations (the message is YOU CANNOT GET OUT OF THE STEAM TRAIN.); at a platform it works. Characters who follow you, such as Watson and Lestrade, climb in after you with the "follow" script (E476), and a train that carries Lestrade is described with him in it.

Hansom cabs

Where a cab is, and how it is hailed

At the start of the game both cabs are off stage, in room 0. The HAIL action (E2C7, shared action AA71 entry 11) works only if all of these hold (the pre-check at E298):

The action then puts the cab in your room (DD0E), remembers which cab it is (E2C6), and starts the cabbie on the fare script at F2B6 with you and the cab as its two objects (E2EE).

What the cabbie does

The cabbie is an actor with the script at F2B2. Its first two instructions are a PASS and a GOTO back to itself, so an unhailed cabbie does nothing for ever. HAIL gives him a second entry point to run, with these stages:

  1. Greeting and waiting. He says GOOD MORNING GUV'NOR (6BAC) and starts a countdown of 4 minutes plus a random 0 to 4 (E52F). Each minute he checks whether you are there (F2C2); if you are, he moves on to the next stage. If you are not, he ticks the countdown (E57A), and when it runs out he prints WITH A PRACTISED FLICK OF THE REINS, YOU MOVES ON DOWN THE STREET IN SEARCH OF OTHER FARES. (6BF6) and puts the cab back in room 0 (F376).
  2. Waiting for a destination. While you are there he waits for a "go to" order, re-asking WELL ARE WE GOIN' ANYWHERE GUV'NOR? (6C1B) whenever a countdown (5 plus a random 0 to 3 minutes) runs out, and then starting again from the first stage. An order is SAY TO CABBIE "GO TO ..." or "GO FURIOUSLY TO ...".
  3. The ride. See below.
  4. Payment. When the ride ends the cabbie names the fare (RIGHT GUV'NOR THAT WILL BE 10D., E6BC). If you stay in the cab without paying he repeats it about every six minutes (a countdown of 5 plus a random 0 to 2 minutes), and the cab never drives off with you. If you get out without paying the cabbie, who now appears to be getting quite agitated, says WHAT ABOUT ME MONEY GUV'NOR? (message 6BC7), and if you then walk away he shouts after you (E70E, message 6C54): YOU BLOODY SNOB, WATCH OUT IF WE EVER MEET AGAIN. Then he puts the cab back in room 0 (F376) and goes back to his idle loop. Nothing else follows from not paying: he does not chase you, and nothing in the cabbie's script punishes you further. Once the account is settled, or change is given, the script moves on the same way.

Whether a fare is owed is kept in the cabbie's purse: the ride makes his balance negative by the fare, so "negative" means a fare is owed, "positive" means change is due and zero means settled (E63E, E654, E66F).

The ride

A ride is two shared actions, one for each speed. GO TO (9AF4, shared action 14) and GO FURIOUSLY TO (9AE1, shared action 15) both do the same things:

  1. Check that the cab can get there from where it stands (9B50): look for a journey between the two rooms in the journey table (9B7F, searched either way round by 9C07). If there is none, the cabbie says SORRY GUV'NOR I CANNOT GET THERE FROM 'ERE.
  2. Price the ride (9B25): the fare is the rate times (the journey's minutes divided by 5, rounded down, plus 1). GO TO charges 2d a step and GO FURIOUSLY TO 6d. Baker Street to Parliament Street is 20 minutes, so 2 × 5 = 10d. The fare is taken off the cabbie's purse.
  3. Set the length of the action to the journey's minutes. Going furiously takes two minutes off, so the ride is two minutes quicker but three times dearer.
  4. Put the cab in room 1 (the hansom cab) and make it invisible (9C60), then hand the ride to the vehicle sub-script at F3AD, which, when the minutes have passed, moves the cab and everything in it to the destination (9C41) and makes it visible again.

So a cab ride does not pass through the streets in between: the cab sits in room 1 for the journey time, then appears at the destination.

The journey table

There are ten cab stands, all street rooms, and every pair has an entry: 45 in all (9B7F). Leatherhead and Old Mill Road are not in it. They are reached by train and by the police cab. The minutes for each pair:

Portman StBaker StParliament StSlater StAldergate StKings Cross RdBishops RdBuckingham Palace RdCamden StSidmouth St
Portman St–37201918712613
Baker St3–20252612615249
Parliament St720–181812192415
Slater St202518–32030201725
Aldergate St1926183–132817911
Kings Cross Rd1812122013–1116183
Bishops Rd7619302811–152413
Buckingham Palace Rd1215220171615–1219
Camden St6244179182412–22
Sidmouth St1391525113131922–

Fares at the normal rate are 2d for each full five minutes plus 2d: 3 minutes costs 2d, 6 to 9 minutes 4d, 20 minutes 10d, 30 minutes 14d.

The police cab

The police cab (thing 109, with the room 105 inside) is driven by the local police man and has only three routes (9AA3): Old Mill Road to Main Street, Main Street to Old Mill Road and Main Street to Kings Cross Road. A plain GO TO (9A99) takes 20 minutes longer than GO FURIOUSLY TO (shared action 2): the run out to Old Mill Road takes 114 minutes by plain GO TO and 94 going furiously. It is the only way to Old Mill Road, which is why the endgame needs it.

Do cabs move when they are not hailed?

No. A cab that has not been hailed is off stage in room 0 and cannot be seen or reached. Its cabbie runs the do-nothing loop at F2B2, so no cabbie ever leaves on his own and no cab ever wanders the streets. The same holds after a ride: when the fare has been dealt with the cab goes back to room 0. A cab is only ever in a street because someone hailed it, and that someone can be a character as well as you: Lestrade hails cab 30 at the start of the game (the action is the same HAIL, run by actor 2) and rides it from Parliament Street to Kings Cross Road, arriving at about 8:16am, after which the cab goes back to room 0. Other characters use cabs the same way: Phipps and the Major each run the cab-hailing sub-script in their own plans, and the German agent runs Phipps's flight code, which includes it, and Lestrade's own cab sub-script is at EBA4. Cab 33 stays in room 0 until somebody hails it.

The trains are different in exactly this respect: they never stand idle, and a train you cannot see (between stations, or at a platform in another part of London) is still running its script.