Sherlock: annotated disassembly

Routines

Prev: 9AF4 Up: Map Next: 9B50
9B25: Price a cab ride from its journey time
IX is the journey's entry in 9B7F. The fare is HL = DE x (minutes / 5, rounded down, + 1). Unless E619 says otherwise for the actor in $A036, it is taken off the money (E39C, SBC HL,DE, E38F); then CFB6, and $A035 from the entry's +3.
Input
IX The journey entry (+2 holds the minutes)
DE The fare for each five minutes
Output
DE The fare
IX Unchanged
9B25 LD A,(IX+$02) Read byte +2 of the record at IX into A - A = the journey's minutes
9B28 PUSH IX Save IX on the stack
9B2A LD HL,$0000 Load HL with $0000 - HL = DE x (minutes / 5 + 1): DE per five minutes, started
9B2D ADD HL,DE Add DE to HL
9B2E SUB $05 Subtract $05 from A
9B30 JR NC,$9B2D If it did not go below zero, go back to 9B2D
9B32 EX DE,HL DE = the fare
9B33 LD A,($A036) Read $A036 in "Game variables" into A - Does the actor ($A036) pay? (E619)
9B36 CALL $E619 Call E619 (inside "Action record: RUN at E08F; RUN at E46B;...")
9B39 JR Z,$9B44 If the zero flag is set, skip ahead to 9B44
9B3B CALL $E39C Call the routine "HL = the money a thing holds (+9/+10)" (E39C) - Take the fare off the actor's money
9B3E AND A Clear the carry flag, so that the subtraction that follows is a plain one (a compare)
9B3F SBC HL,DE Subtract DE from HL (a compare: carry = HL was smaller, zero = equal)
9B41 CALL $E38F Call the routine "Store HL as the money a thing holds (+9/+10)" (E38F)
9B44 CALL $CFB6 Narrate the action (CFB6)
9B47 LD A,(IX+$03) Read byte +3 of the record at IX into A - $A035 = (IX+3), with IX as CFB6 left it
9B4A LD ($A035),A Store A in $A035 in "Game variables"
9B4D POP IX Restore IX from the stack
9B4F RET Return to the caller
Prev: 9AF4 Up: Map Next: 9B50