Sherlock: annotated disassembly

Routines

Prev: E104 Up: Map Next: E17B
E135: Action record: RUN at $E0A7; RUN at $E0E2; RUN at $E0F4; default for verb 20 (EXAMINE CLOSELY)
Addresses named in the title: E0A7, E0E2, E0F4.
EXAMINE CLOSELY. The body, for the player only (actor 0), prints the description (DF5B) and then looks the thing up in E16B, a table of three-byte entries (thing, message address) ended by $FF: the bed (76), the window (102), the bridge (57), the drawer (62) and the corpse (46) each have a longer text of their own.
EXAMINE CLOSELY BED (room 61) -> 'The bed is unmade and one sheet is crumpled up on top. In one corner of the sheet is a very small tear.'; CORPSE (room 88) -> dried blood on the face and 'dark speckled markings that resemble powder burns' on the right hand; BRIDGE (room 88) -> 'a small chip in the stone work that is evidently quite new.
The table at E16B is data (thing, message pairs) that the disassembler listed as code, which is why the last 12 'instructions' were not executed.
Input
$A034 The direct object
Output
F NZ; its description and any extra text printed
E135 DEFB $78,$50,$2E,$DF,$80,$40,$00,$00 Action record header: flags $78; bit 5: test D078 first; bit 6: pre-check at DF2E; bit 4: five extra bytes; byte 1 $50
E13D DEFB $00
E13E LD A,$01 Load A with $01 - CAAE = 1
E140 LD ($CAAE),A Store A in "Flag: the player's view has changed" (CAAE)
E143 LD A,($A036) Read $A036 in "Game variables" into A - Only the player examines closely: anyone else passes
E146 AND A Clear the carry flag for the caller (A is unchanged)
E147 RET NZ If A is not zero, return
E148 CALL $E151 Print the description and the extra text (E151)
E14B CALL $A2A2 Call the routine "Print a newline (A kept)" (A2A2) - Newline (A2A2)
E14E OR $01 Make A non-zero, which clears the zero flag, and hand that back to the caller
E150 RET Return to the caller
E151 CALL $DF5B The thing's own description (DF5B)...
E154 LD A,($A034) Read $A034 in "Game variables" into A - ...then look for it in the table at E16B (D34E)
E157 LD IX,$E16B Point IX at E16B in "Action record: RUN at E0A7; RUN at E0E2;..."
E15B CALL $D34E Call the routine "Find a 3-byte record by id, in a sentinel-terminated..." (D34E)
E15E CP $FF Compare A with $FF - Not there ($FF): done
E160 RET Z If A equals $FF, return
E161 LD L,(IX+$01) Read byte +1 of the record at IX into L - Found: print its extra text
E164 LD H,(IX+$02) Read byte +2 of the record at IX into H
E167 CALL $A59F Call the routine "Print the message at HL" (A59F)
E16A RET Return to the caller
E16B LD C,H Copy H into C
E16C JP NZ,$667B If the zero flag is clear, go back to $667B
E16F RST $10 Call the ROM routine at $10
E170 LD A,E Copy E into A
E171 ADD HL,SP Add SP to HL
E172 SBC A,(HL) Subtract the byte HL points at and the carry from A
E173 LD A,H Copy H into A
E174 LD A,$E7 Load A with $E7
E176 LD A,H Copy H into A
E177 LD L,$4A Load L with $4A
E179 LD A,H Copy H into A
E17A RST $38 Call the ROM routine at $38
Prev: E104 Up: Map Next: E17B