Sherlock: annotated disassembly

Routines

Prev: C74E Up: Map Next: C821
C7A6: Check object C against requirement code A (7-15)
The second half of the requirement checks; see C628 for the codes. Each refusal goes to C632, each pass to C62F.
How it works:
1. Mask the code to its low nibble. Codes 7 to 15 split into six groups; each ends by jumping to the pass at C62F or the refusal at C632.
2. Code 7: anything will do. Code 8: the object must be in the actor's room (C821).
3. Code 9 (TAKE): in the room; in exactly one place (C8A7), so doors and the like are out; not a person (C8BE); of a size the actor can carry (C8C6); and not already held by a person (C8AF).
4. Code 10: in the room and held by the actor (D275). Code 11: in the room and in more than one place, which is what a door is. Code 12: a person anywhere. Codes 13 to 15: a person who is in the room.
Input
A The requirement code (7-15)
C The object's id
IY The action record
Output
F NZ if the object passes, Z if it is refused
C7A6 AND $0F Keep only bits 0, 1, 2, 3 of A (mask $0F)
C7A8 CP $07 Compare A with $07 - 7: anything at all
C7AA JP Z,$C62F If A equals $07, go back to C62F
C7AD CP $08 Compare A with $08 - 8: it must be here (C821)
C7AF JR NZ,$C7BB If A differs from $08, skip ahead to C7BB
C7B1 LD A,C Copy C into A
C7B2 CALL $C821 Call the routine "Can the current actor ($A036) see thing A?" (C821)
C7B5 JP Z,$C632 If the zero flag is set, go back to C632
C7B8 JP $C62F Go back to C62F
C7BB CP $09 Compare A with $09 - 9: something to take - here,
C7BD JR NZ,$C7E4 If A differs from $09, skip ahead to C7E4
C7BF LD A,C Copy C into A
C7C0 CALL $C821 Call the routine "Can the current actor ($A036) see thing A?" (C821)
C7C3 JP Z,$C632 If the zero flag is set, go back to C632
C7C6 LD A,C Copy C into A - in only one place (C8A7),
C7C7 CALL $C8A7 Call the routine "How many locations has object A? (Z if exactly one)" (C8A7)
C7CA JP NZ,$C632 If the zero flag is clear, go back to C632
C7CD LD A,C Copy C into A - not a person (C8BE),
C7CE CALL $C8BE Call the routine "Is object A a person? (NZ if so)" (C8BE)
C7D1 JP NZ,$C632 If the zero flag is clear, go back to C632
C7D4 LD B,C Copy C into B - something the actor can carry (C8C6),
C7D5 LD A,($A036) Read $A036 in "Game variables" into A
C7D8 CALL $C8C6 Call the routine "Can the actor carry object A as well as what it holds?" (C8C6)
C7DB JP Z,$C632 If the zero flag is set, go back to C632
C7DE LD A,C Copy C into A - and then whether a person holds it (C8AF, on at C768)
C7DF CALL $C8AF Call the routine "Is object A held, at any depth, by a person?" (C8AF)
C7E2 JR $C768 Go back to C768
C7E4 CP $0A Compare A with $0A - 10: here and carried by the actor (D275)
C7E6 JR NZ,$C7F9 If A differs from $0A, skip ahead to C7F9
C7E8 LD A,C Copy C into A
C7E9 CALL $C821 Call the routine "Can the current actor ($A036) see thing A?" (C821)
C7EC JP Z,$C632 If the zero flag is set, go back to C632
C7EF LD A,C Copy C into A
C7F0 CALL $D275 Call the routine "Is thing A carried by the actor, perhaps inside..." (D275)
C7F3 JP NC,$C632 If the carry flag is clear, go back to C632
C7F6 JP $C62F Go back to C62F
C7F9 CP $0B Compare A with $0B - 11: here and in more than one place (a door, say)
C7FB JR NZ,$C80A If A differs from $0B, skip ahead to C80A
C7FD LD A,C Copy C into A
C7FE CALL $C821 Call the routine "Can the current actor ($A036) see thing A?" (C821)
C801 JP Z,$C632 If the zero flag is set, go back to C632
C804 LD A,C Copy C into A
C805 CALL $C8A7 Call the routine "How many locations has object A? (Z if exactly one)" (C8A7)
C808 JR $C7B5 Go back to C7B5
C80A CP $0C Compare A with $0C - 12: a person, anywhere
C80C JR NZ,$C814 If A differs from $0C, skip ahead to C814
C80E LD A,C Copy C into A
C80F CALL $C8BE Call the routine "Is object A a person? (NZ if so)" (C8BE)
C812 JR $C7B5 Go back to C7B5
C814 LD A,C Copy C into A - 13-15: a person who is here
C815 CALL $C821 Call the routine "Can the current actor ($A036) see thing A?" (C821)
C818 JP Z,$C632 If the zero flag is set, go back to C632
C81B LD A,C Copy C into A
C81C CALL $C8BE Call the routine "Is object A a person? (NZ if so)" (C8BE)
C81F JR $C7B5 Go back to C7B5
Prev: C74E Up: Map Next: C821