Sherlock: annotated disassembly

Routines

Prev: E654 Up: Map Next: E6BC
E66F: Action record: is the account settled? (RUN at $F309, $F321, $F33E)
Addresses named in the title: F309, F321, F33E.
No body; the pre-check passes when the cabbie has no purse or its balance is exactly zero. The cabbie's script at F2B6 reads the balance of his purse (+9/+10 of the money he holds): negative while a fare is owed, positive when change is due, zero when settled.
The block also holds two routines that merely follow it in memory (E686 and E691): a 50 percent roll used by Watson's after-turn code, and the remark in which Watson asks 'why do you think that ...?' about a statement chosen at random from the list of statements already made.
Output
F NZ if the cabbie has no purse or its balance is zero; otherwise $DC15
E66F DEFB $40,$00,$73,$E6 Action record header: flags $40; bit 6: pre-check at E673; byte 1 $00
E673 LD A,($A036) Pre-check: A = the current actor ($A036)
E676 CALL $E619 Is anything held by that actor (E619)?
E679 JR Z,$E683 None: succeed (E683)
E67B CALL $E39C Otherwise check the result (E39C)
E67E LD A,H Copy H into A - HL non-zero: fail (DC15)
E67F OR L Set in A the bits that are set in L
E680 JP NZ,$DC15 If the result is not zero, go back to the routine "Fail: A = 0, HL = 0, Z set" (DC15)
E683 OR $01 Make A non-zero, which clears the zero flag, and hand that back to the caller - Succeed, NZ
E685 RET Return to the caller
E686 CALL $D29D Call the routine "A random number from 1 to 100" (D29D) - Roll 1-100 (D29D)...
E689 CP $32 Compare A with $32
E68B JP C,$DC15 ...under 50: fail
E68E OR $01 Make A non-zero, which clears the zero flag, and hand that back to the caller - 50 or more: NZ
E690 RET Return to the caller
This entry point is used by the routine at 9D13.
E691 CALL $E686 Watson's after-turn remark about something already said: the 50% roll first
E694 RET Z Failed the roll: nothing to say
E695 CALL $D29D Call the routine "A random number from 1 to 100" (D29D) - Another roll 1-100 into B: how far along the list of remembered statements to go
E698 LD B,A Copy A into B
E699 LD IX,$9FF6 IX = the head of the list at $9FF6
E69D DJNZ $E6A6 Count B down (E6A6 when done)
E69F CALL $A0F7 Call the routine "Move IX to the next node of a list" (A0F7) - Next node (A0F7); at the end of the list start again
E6A2 JR Z,$E699 If the zero flag is set, go back to E699
E6A4 JR $E69D Go back to E69D
E6A6 PUSH IX Save IX on the stack - Is it the head itself (an empty list)?
E6A8 POP HL Restore HL from the stack
E6A9 LD DE,$9FF6 Point DE at $9FF6 in "Game variables"
E6AC AND A Clear the carry flag, so that the subtraction that follows is a plain one (a compare)
E6AD SBC HL,DE Subtract DE from HL (a compare: carry = HL was smaller, zero = equal)
E6AF JR Z,$E6B9 If the two values are equal, skip ahead to E6B9
E6B1 PUSH IX No: print the question about that statement with IX as its subject (6F80)
E6B3 LD HL,$6F80 Point HL at the message "YOU SAY" WHY DO YOU THINK THAT YOU AND YOU?"." (6F80)
E6B6 CALL $A59F Call the routine "Print the message at HL" (A59F)
E6B9 OR $01 Make A non-zero, which clears the zero flag, and hand that back to the caller - Return NZ
E6BB RET Return to the caller
Prev: E654 Up: Map Next: E6BC