Sherlock: annotated disassembly

Routines

Prev: C933 Up: Map Next: C989
C960: Look up a numbered entry in the table at $AA71
Addresses named in the title: AA71.
Given a number in (IX+1), computes AA71 + (that number - 1)*2 and reads a 16-bit value from there - a plain, direct-indexed table lookup, not a search.
Input
IX A record whose +1 is a number
Output
HL The action record at entry (number - 1) of the table at $AA71
C960 LD A,(IX+$01) The number to look up (meaning depends on IX - see prose)
C963 LD E,A Copy A into E
C964 LD D,$00 Load D with $00
C966 LD HL,$AA71 The table's base
C969 DEC DE Step DE back one byte
C96A ADD HL,DE (number-1) * 2, added twice for a word-sized stride
C96B ADD HL,DE Add DE to HL
C96C LD E,(HL) This entry's own table value...
C96D INC HL Step HL on to the next byte
C96E LD D,(HL) ...becomes the result
C96F EX DE,HL Swap DE and HL
C970 JR $C996 Run it
This entry point is used by the routines at C929 and C933.
C972 LD A,($A033) Look the verb up in the default-action table
C975 LD IX,$9F38 Point IX at "Each verb's default action record" (9F38)
C979 CALL $D34E Call the routine "Find a 3-byte record by id, in a sentinel-terminated..." (D34E)
C97C CP $FF No default for this verb?
C97E JP Z,$DC15 Then fail
C981 LD L,(IX+$01) HL = the default action record
C984 LD H,(IX+$02) Read byte +2 of the record at IX into H
C987 JR $C996 Run it
Prev: C933 Up: Map Next: C989