Sherlock: annotated disassembly

Routines

Prev: D102 Up: Map Next: D182
D113: Describe room A in full
The picture, if pictures are on and the room has one (A277); 'YOU ARE IN <thing>' when the actor is inside something (C863); the room's own text or 'YOU ARE ON/IN ... <name>' (D182); the exits (D60B); the things here (D68C); the people here (D4A7); end of line. To the north there is the front door.').
How it works:
1. Draw the room's picture if pictures are on and the room has one (A277).
2. If the actor is inside something (a cab, say), print 'YOU ARE IN' and how it is held (D5D3) and its name (D3D5).
3. Print the room's own description (D182), then list what can be seen.
Input
A A room number
HL The opening message
Output
The room described, with its picture if shown
D113 LD B,A B = the room number
D114 CALL $D224 Room record into IX (D224)
D117 LD A,B Copy B into A - Draw the room's picture if pictures are on (A277)
D118 CALL $A277 Call the routine "Describe a room's picture" (A277)
D11B PUSH IX Save IX on the stack - Save the room record, B and HL
D11D PUSH BC Save BC on the stack
D11E PUSH HL Save HL on the stack
D11F LD A,($A036) Read $A036 in "Game variables" into A - Is the actor inside something (C863)? A' = the container, or $FF
D122 CALL $C863 Call the routine "Is thing number A here? (C86E)" (C863)
D125 EX AF,AF' Swap AF with the shadow copy
D126 CP $FF Compare A with $FF - $FF: not inside anything, skip
D128 JR Z,$D167 If A equals $FF, jump on to D167
D12A PUSH AF Inside something: build 'YOU ARE IN <thing>':
D12B LD HL,($68DE) Read $68DE in "Message: "YOU ARE IN"" into HL - save the word at $68DE...
D12E PUSH HL Save HL on the stack
D12F LD HL,$8000 Point HL at $8000 in "Message: "AS YOU RUN YOUR HANDS OVER THE..." - ...put the word for IN ($8000) into the message (D0D0)...
D132 CALL $D0D0 Call the routine "Put word HL into the 'YOU ARE ...' message" (D0D0)
D135 LD HL,$68DD Point HL at the message "YOU ARE IN" (68DD) - ...and print 68DD
D138 CALL $A59F Call the routine "Print the message at HL" (A59F)
D13B POP HL Restore HL from the stack - Put the old word back
D13C LD ($68DE),HL Store HL in $68DE in "Message: "YOU ARE IN""
D13F POP AF Restore AF from the stack
D140 PUSH AF Save AF on the stack
D141 CALL $D237 Container's record (D237)
D144 CALL $D5D3 Print how it is held (IN, ON, BEHIND...) (D5D3)
D147 CALL $D3D5 Call the routine "Print thing IX's name" (D3D5) - Print its name (D3D5)
D14A POP AF Restore AF from the stack
D14B PUSH AF Save AF on the stack
D14C CALL $D4CC Call the routine "Count the things in place B that should be listed (B)" (D4CC) - Count the other things in the container that should be listed (D4CC)
D14F AND A Test A for zero (this leaves A as it was and clears carry)
D150 JR Z,$D163 If A is zero, skip ahead to D163 - None: just end the sentence (A414)
D152 LD C,A Copy A into C
D153 LD DE,$09BF Load DE with $09BF - Some: print the lead-in $09BF
D156 CALL $A887 Call A887 (inside "Print the dictionary word that HL refers to")
D159 LD A,($A00A) Read the current actor's room (A00A) into A
D15C LD B,A Copy A into B
D15D POP AF Restore AF from the stack
D15E CALL $D51A Call the routine "List the things in a place, with commas and AND" (D51A) - List them with commas and AND (D51A)
D161 JR $D167 Skip ahead to D167
D163 CALL $A414 Call A414 (inside "Print the rest of a narrated command: verb...")
D166 POP AF Restore AF from the stack
D167 POP DE Restore DE from the stack - Back to the room record
D168 POP BC Restore BC from the stack
D169 POP IX Restore IX from the stack
D16B LD L,(IX+$07) Read byte +7 of the record at IX into L - HL = the room's own description word
D16E LD H,(IX+$08) Read byte +8 of the record at IX into H
D171 CALL $D182 Call the routine "Print a room's description" (D182) - Print it, or 'YOU ARE ON/IN ... <name>' if it has none (D182)
D174 LD A,B Copy B into A
D175 CALL $D60B Call the routine "Describe the ways out through things: 'TO THE NORTH..." (D60B) - The exits (D60B)
This entry point is used by the routine at D1B2.
D178 LD A,B Copy B into A
D179 CALL $D68C The things here (D68C)
D17C CALL $D4A7 The people here (D4A7)
D17F JP $A2A2 End the line (A2A2)
Prev: D102 Up: Map Next: D182