Sherlock: annotated disassembly

Routines

Prev: C628 Up: Map Next: C74E
C6BE: Check the indirect object against the action record's requirement
As C628, for the indirect object and the low nibble of byte 1 ($A010). C6B8 sets $A021 = 1 (the indirect object is being checked); C654 sets it to 0.
How it works:
1. Take the indirect object's requirement code from the low nibble of byte 1 of the record. Zero means no requirement: pass.
2. Codes 5 and 6 want a number (the parser's number marker is $FE, the value in $A031): code 5 needs bit 7 of the value clear, code 6 needs it set.
3. Codes 1 and 2 want a room whose record has bit 7 of its first byte set; codes 1 and 3 also want the room to be next door to the actor (D471).
4. Codes 7 to 15 are handed to C7A6 along with the object's id, which is also stored at $CB7A so that a refusal can name it.
5. A failure there sets $A021 and refuses.
Input
IY The action record
Output
F NZ if the indirect object is acceptable, Z if refused (the refusal is printed by $DC15)
C6BE LD A,(IY+$01) Read byte +1 of the record at IY into A - The requirement code: the low nibble of the record's byte 1; 0 needs nothing
C6C1 AND $0F Keep only bits 0, 1, 2, 3 of A (mask $0F)
C6C3 JR NZ,$C6CB If any of bits 0, 1, 2, 3 of A was set, skip ahead to C6CB
C6C5 OR $01 Make A non-zero, which clears the zero flag, and hand that back to the caller - Pass: NZ
C6C7 RET Return to the caller
C6C8 JP $DC15 Refuse
C6CB CP $05 Compare A with $05 - Codes 5 and 6: a number
C6CD JR C,$C6F5 If A is below $05, skip ahead to C6F5
C6CF CP $07 Compare A with $07
C6D1 JR NC,$C719 If A is $07 or more, jump on to C719
C6D3 LD A,($A035) Read $A035 in "Game variables" into A - It must be a number ($FE), its value at $A031...
C6D6 CP $FE Compare A with $FE
C6D8 JP NZ,$C654 If A differs from $FE, go back to C654
C6DB LD HL,($A031) Read $A031 in "Game variables" into HL
C6DE LD A,(IY+$01) Read byte +1 of the record at IY into A - ...with bit 7 of its low byte clear for code 5...
C6E1 AND $0F Keep only bits 0, 1, 2, 3 of A (mask $0F)
C6E3 CP $05 Compare A with $05
C6E5 JR NZ,$C6EE If A differs from $05, skip ahead to C6EE
C6E7 BIT 7,L Test bit 7 of L
C6E9 JR Z,$C6C5 If bit 7 of L is clear, go back to C6C5
C6EB JP $C654 Go back to C654
C6EE BIT 7,L Test bit 7 of L - ...and set for code 6
C6F0 JR NZ,$C6C5 If bit 7 of L is set, go back to C6C5
C6F2 JP $C654 Go back to C654
C6F5 CP $03 Compare A with $03 - Codes 1 and 2: a room whose record has bit 7 of byte 0 set
C6F7 JR NC,$C706 If A is $03 or more, skip ahead to C706
C6F9 LD A,($A035) Read $A035 in "Game variables" into A
C6FC CALL $D224 Call the routine "Find a room record" (D224)
C6FF BIT 7,(IX+$00) Test bit 7 of the first byte of the record at IX
C703 JP Z,$C654 If bit 7 of the first byte of the record at IX is clear, go back to C654
C706 BIT 0,(IY+$01) Test bit 0 of byte +1 of the record at IY - Codes 1 and 3: and next door to the actor (D471)
C70A JR Z,$C6C5 If bit 0 of byte +1 of the record at IY is clear, go back to C6C5
C70C LD A,($A035) Read $A035 in "Game variables" into A
C70F CALL $D471 Call D471 (inside "Find the exit from the actor's room through...")
C712 CP $FF Compare A with $FF
C714 JP Z,$C654 If A equals $FF, go back to C654
C717 JR $C6C5 Go back to C6C5
C719 LD A,($A035) Read $A035 in "Game variables" into A - Codes 7-15 (C7A6), with the object noted at $CB7A
C71C LD ($CB7A),A Store A in $CB7A in "The flags CB7B is to name"
C71F LD C,A Copy A into C
C720 LD A,(IY+$01) Read byte +1 of the record at IY into A
C723 CALL $C7A6 Call the routine "Check object C against requirement code A (7-15)" (C7A6)
C726 RET Z If the zero flag is set, return
C727 BIT 4,(IY+$00) Test bit 4 of the first byte of the record at IY - Flags bit 4: then the indirect object's +5 masks from the header (C74E)
C72B JP Z,$C62F If bit 4 of the first byte of the record at IY is clear, go back to C62F
C72E LD A,(IY+$02) Read byte +2 of the record at IY into A
C731 LD L,(IY+$05) Read byte +5 of the record at IY into L
C734 LD H,(IY+$06) Read byte +6 of the record at IY into H
C737 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)
C73B JR Z,$C746 If bit 6 of the first byte of the record at IY is clear, skip ahead to C746
C73D LD A,(IY+$04) Read byte +4 of the record at IY into A
C740 LD L,(IY+$07) Read byte +7 of the record at IY into L
C743 LD H,(IY+$08) Read byte +8 of the record at IY into H
C746 LD B,A Copy A into B
C747 CALL $C74E Call the routine "Test object C's +5 flags against a record's masks" (C74E)
C74A RET NZ If the zero flag is clear, return
C74B JP $C6B8 The flags were wrong: $A021 = 1, and refuse
Prev: C628 Up: Map Next: C74E