Prev: 74C8 Up: Map Next: 7500
74D8: Deal with Sam
Called from the main loop at F02B when one of Sam's status flags at 7FFC is set, indicating that he is in the middle of an action. Returns with the zero flag set if Sam has finished the action by the end of the routine.
74D8 LD HL,$E608 Decrement Sam's main action timer in byte 0x08 of his buffer
74DB DEC (HL)
74DC RET NZ Return unless it's time to deal with Sam
74DD LD HL,$74F3 We will continue at 74F3 (below) after calling the routine to handle Sam
74E0 PUSH HL
74E1 LD L,$C6 HL=74C6
74E3 LD A,($7FFC) Pick up Sam's status flags from 7FFC
74E6 INC L Point HL at one of the entries in the table of Sam-handling routine addresses at 74C8
74E7 INC L
74E8 RLCA
74E9 JR NC,$74E6
74EB LD C,(HL) Collect the routine address into BC
74EC INC L
74ED LD B,(HL)
74EE PUSH BC Push it onto the stack, ready for an indirect jump
74EF LD HL,$E600 Point HL at byte 0x00 of Sam's buffer
74F2 RET Make an indirect jump to the Sam-handling routine
We come here after the Sam-handling routine has returned.
74F3 LD HL,$7FFC 7FFC holds Sam's status flags
74F6 LD A,(HL) Pick them up in A
74F7 AND A Has Sam finished the action yet?
74F8 RET Z Return with the zero flag set if so
74F9 LD A,($E608) Collect Sam's main action timer from byte 0x08 of his buffer
74FC AND A Did the Sam-handling routine set the action timer to a non-zero value (meaning that the action is still in progress)?
74FD RET NZ Return with the zero flag reset if so
74FE LD (HL),A Otherwise clear all of Sam's status flags at 7FFC
74FF RET Return with the zero flag set
Prev: 74C8 Up: Map Next: 7500