Sherlock: annotated disassembly

Routines

Prev: B303 Up: Map Next: B32D
B308: Count the candidates for the direct object
Runs the direct-object search to the end (B34F, B4C1), counting in $B170, and puts the search state back as it was. A = the count.
Output
A The number of candidates for the direct object
Search state kept
B308 LD HL,($B17E) Read $B17E in "Parser variables" into HL - Keep the direct object's search position ($B17E) and its number-used flag (B4A2)
B30B PUSH HL Save HL on the stack
B30C LD A,($B4A2) Read "B4C1: $FF until the number in the direct-object..." (B4A2) into A
B30F PUSH AF Save AF on the stack
B310 CALL $B34F Start the search again from the top (B34F)
B313 CALL $B4C1 Call the routine "The next candidate for the direct object ($A034)" (B4C1)
B316 JR Z,$B31E If the zero flag is set, skip ahead to B31E
B318 LD HL,$B170 Point HL at $B170 in "Parser variables" - One more: $B170 counts them
B31B INC (HL) Add one to the byte at $B170 in "Parser variables"
B31C JR $B313 Go back to B313
B31E POP AF Restore AF from the stack - No more: put the position and flag back
B31F LD ($B4A2),A Store A in "B4C1: $FF until the number in the direct-object..." (B4A2)
B322 LD HL,$B170 Point HL at $B170 in "Parser variables"
B325 LD A,(HL) Read the byte at $B170 in "Parser variables" into A - A = how many; $B170 cleared again
B326 LD (HL),$00 Store $00 at the address HL points to
B328 POP HL Restore HL from the stack
B329 LD ($B17E),HL Store HL in $B17E in "Parser variables"
B32C RET Return to the caller
Prev: B303 Up: Map Next: B32D