Sherlock: annotated disassembly

Routines

Prev: CB79 Up: Map Next: CBA7
CB7B: Refuse by naming the flag that failed: "THE ... IS <word>"
Takes the lowest bit in CB79 and prints 6817 ('THE <object> IS') followed by that bit's word: from C471 when a needed bit was missing, from C481 (bit 7 of CB79 set) when a forbidden bit was present. The object is $CB7A, saved by C685.
Input
$CB79 The flag bits that failed
$CB7A The object
Output
A message like "THE ... IS <word>" printed
CB7B LD A,($CB79) Read "The flags CB7B is to name" (CB79) into A - CB79 = the missing or forbidden flag bits; bit 7 says which
CB7E BIT 7,A Test bit 7 of A
CB80 LD HL,$C471 Point HL at "Words for a +5 flag that should be set but is not" (C471) - Needed bit missing: table at C471...
CB83 JR Z,$CB88 If bit 7 of A is clear, skip ahead to CB88
CB85 LD HL,$C481 ...forbidden bit present: table at C481
CB88 OR $80 Mark the end of the bits with bit 7
CB8A LD E,(HL) Read the byte HL points at into E - Walk the table: DE = the next word, shifting the flag byte right until the lowest set bit falls out
CB8B INC HL Step HL on to the next byte
CB8C LD D,(HL) Read the byte HL points at into D
CB8D INC HL Step HL on to the next byte
CB8E RRCA Rotate A right one place (bit 0 goes to carry and bit 7)
CB8F JR NC,$CB8A If the carry flag is clear, go back to CB8A
CB91 LD A,D Copy D into A - Word zero: nothing to say (CB58)
CB92 OR E Set in A the bits that are set in E
CB93 JR Z,$CB58 If the result is zero, go back to CB58
CB95 LD A,($CB7A) Read $CB7A in "The flags CB7B is to name" into A - The object saved at $CB7A becomes the direct object
CB98 LD ($A034),A Store A in $A034 in "Game variables"
CB9B LD HL,$6817 Point HL at the message "THE OIL LAMP IS" (6817) - Print 6817 'THE <object> IS' (the word follows)
CB9E CALL $A59F Call the routine "Print the message at HL" (A59F)
CBA1 CALL $A887 Call A887 (inside "Print the dictionary word that HL refers to")
CBA4 JP $A2A2 Go back to the routine "Print a newline (A kept)" (A2A2)
Prev: CB79 Up: Map Next: CBA7