Sherlock: annotated disassembly

Routines

Prev: C60D Up: Map Next: C6BE
C628: Check the direct object against the action record's requirement
The low nibble of an action record's byte 0 is a requirement code for the direct object, copied to $A00F by C571; the low nibble of byte 1 is the same for the indirect object (C6BE). Returns Z to refuse (C632 is JP DC15). Codes 7-15 are handed to C7A6.
0: none. 1 and 2: the object must be a room whose record (D224, the room table at 840B) has bit 7 of byte 0 set; 1 also needs D471 to find something. 3: D471 must find something. 4 and 7: anything. 5: a number ($A034 = $FE) with bit 7 of the value clear (WAIT UNTIL); 6: the same with bit 7 set (PAY TO). 8: the object must be here (C821). 9: TAKE - here, in exactly one location (C8A7), not a person (C8BE), small enough for the actor to carry (C8C6), and not held by a person (C8AF). 10: here and held by the actor. 11: here and in more than one location - a door or passage. 12: a person, with no visibility check (FOLLOW). 13-15: here and a person.
TAKE PLAIN DOOR, TAKE WATSON, GO THROUGH PLAIN DOOR and TAKE DISGUISE get 'I SEE NO ... THAT YOU CAN ...'; DROP LAMP when not carried, TALK TO LAMP, GO THROUGH LAMP, FOLLOW LAMP, GIVE LAMP TO WATSON when not carried and a second TAKE LAMP get 'YOU CANNOT ... THE ...'; PAY 5 TO WATSON gets 'DON'T BE SILLY.'
Input
IY The action record
Output
F NZ if the direct object meets the record's requirement; otherwise the command is refused through $DC15
C628 LD A,(IY+$00) Read the first byte of the record at IY into A - The requirement code: the low nibble of the record's byte 0; 0 needs nothing
C62B AND $0F Keep only bits 0, 1, 2, 3 of A (mask $0F)
C62D JR NZ,$C635 If any of bits 0, 1, 2, 3 of A was set, skip ahead to C635
This entry point is used by the routines at C6BE, C74E and C7A6.
C62F OR $01 Make A non-zero, which clears the zero flag, and hand that back to the caller - Pass: NZ
C631 RET Return to the caller
This entry point is used by the routine at C7A6.
C632 JP $DC15 Refuse
C635 CP $05 Compare A with $05 - Codes 5 and 6: a number
C637 JR C,$C660 If A is below $05, jump on to C660
C639 CP $07 Compare A with $07
C63B JR NC,$C682 If A is $07 or more, jump on to C682
C63D LD A,($A034) Read $A034 in "Game variables" into A - It must be a number ($FE), its value at $A02F...
C640 CP $FE Compare A with $FE
C642 JR NZ,$C654 If A differs from $FE, skip ahead to C654
C644 LD HL,($A02F) Read $A02F in "Game variables" into HL
C647 LD A,(IY+$00) Read the first byte of the record at IY into A
C64A AND $0F Keep only bits 0, 1, 2, 3 of A (mask $0F)
C64C CP $05 Compare A with $05 - ...with bit 7 of its low byte clear for code 5 (WAIT UNTIL), set for 6 (money: PAY TO)
C64E JR NZ,$C65A If A differs from $05, skip ahead to C65A
C650 BIT 7,L Test bit 7 of L
C652 JR Z,$C62F If bit 7 of L is clear, go back to C62F
This entry point is used by the routine at C6BE.
C654 XOR A Clear A to zero (and the carry flag) - Refused: $A021 = 0
C655 LD ($A021),A Store A in $A021 in "Game variables"
C658 JR $C632 Go back to C632
C65A BIT 7,L Test bit 7 of L
C65C JR NZ,$C62F If bit 7 of L is set, go back to C62F
C65E JR $C654 Go back to C654
C660 CP $03 Compare A with $03 - Codes 1 and 2: a room whose record has bit 7 of byte 0 set
C662 JR NC,$C670 If A is $03 or more, skip ahead to C670
C664 LD A,($A034) Read $A034 in "Game variables" into A
C667 CALL $D224 Call the routine "Find a room record" (D224)
C66A BIT 7,(IX+$00) Test bit 7 of the first byte of the record at IX
C66E JR Z,$C654 If bit 7 of the first byte of the record at IX is clear, go back to C654
C670 BIT 0,(IY+$00) Test bit 0 of the first byte of the record at IY - Codes 1 and 3: and next door to the actor (D471)
C674 JR Z,$C62F If bit 0 of the first byte of the record at IY is clear, go back to C62F
C676 LD A,($A034) Read $A034 in "Game variables" into A
C679 CALL $D471 Call D471 (inside "Find the exit from the actor's room through...")
C67C CP $FF Compare A with $FF
C67E JR Z,$C654 If A equals $FF, go back to C654
C680 JR $C62F Go back to C62F
C682 LD A,($A034) Read $A034 in "Game variables" into A - Codes 7-15 (C7A6), with the object noted at $CB7A for CB7B
C685 LD ($CB7A),A Store A in $CB7A in "The flags CB7B is to name"
C688 LD C,A Copy A into C
C689 LD A,(IY+$00) Read the first byte of the record at IY into A
C68C CALL $C7A6 Call the routine "Check object C against requirement code A (7-15)" (C7A6)
C68F JR Z,$C654 If the zero flag is set, go back to C654
C691 BIT 4,(IY+$00) Test bit 4 of the first byte of the record at IY - Flags bit 4: then the +5 flag masks from the header (C74E)
C695 JR Z,$C62F If bit 4 of the first byte of the record at IY is clear, go back to C62F
C697 LD A,(IY+$02) Read byte +2 of the record at IY into A
C69A LD L,(IY+$03) Read byte +3 of the record at IY into L
C69D LD H,(IY+$04) Read byte +4 of the record at IY into H
C6A0 BIT 6,(IY+$00) Test bit 6 of the first byte of the record at IY - (two bytes further on when the header also has a pre-check address, bit 6)
C6A4 JR Z,$C6AF If bit 6 of the first byte of the record at IY is clear, skip ahead to C6AF
C6A6 LD A,(IY+$04) Read byte +4 of the record at IY into A
C6A9 LD L,(IY+$05) Read byte +5 of the record at IY into L
C6AC LD H,(IY+$06) Read byte +6 of the record at IY into H
C6AF RRCA Rotate A right one place (bit 0 goes to carry and bit 7)
C6B0 RRCA Rotate A right one place (bit 0 goes to carry and bit 7)
C6B1 RRCA Rotate A right one place (bit 0 goes to carry and bit 7)
C6B2 RRCA Rotate A right one place (bit 0 goes to carry and bit 7)
C6B3 LD B,A Copy A into B
C6B4 CALL $C74E Call the routine "Test object C's +5 flags against a record's masks" (C74E)
C6B7 RET NZ If the zero flag is clear, return
This entry point is used by the routine at C6BE.
C6B8 LD A,$01 Load A with $01 - The flags were wrong: $A021 = 1
C6BA LD ($A021),A Store A in $A021 in "Game variables"
C6BD RET Return to the caller
Prev: C60D Up: Map Next: C6BE