Prev: 96A8 Up: Map Next: 9728
96B3: Let the other characters act, then count the timers down
Used by the routine at OBEY.
Calls CHECK_WON and CHARACTERS_ACT -- has the player won, and every other character's turn -- and then walks TIMERS. A timer whose count is zero is not running. One that is running counts down by one a turn; on reaching zero it runs its routine, and in the turns before that, while the count is no more than its warning span, it runs its warning routine instead.
Only one timer fires in a turn. A second one to reach zero in the same turn is held at a count of 1 and fires in the next, so two events never land on the player at once -- though a held timer with a warning span runs its warning this turn instead, and BARREL_REACHES_LAKE clears TIMER_FIRED as it starts, so it does not use the turn's firing up.
END_OF_TURN 96B3 PUSH HL
96B4 PUSH IX
96B6 PUSH IY
96B8 PUSH BC
96B9 PUSH DE
96BA CALL CHECK_WON Has the player won? Then every other character's turn
96BD CALL CHARACTERS_ACT
96C0 SUB A Nothing has fired yet this turn; printing on
96C1 LD (TIMER_FIRED),A
96C4 INC A
96C5 LD (SUCCEEDED),A
96C8 LD (DOING_IT),A
96CB LD IY,TIMERS IY = the first timer
END_OF_TURN_0 96CF LD A,(IY+$00) $FF ends the table
96D2 CP $FF
96D4 JR Z,END_OF_TURN_3
96D6 LD A,(IY+$01) A count of zero: not running
96D9 CP $00
96DB JR Z,END_OF_TURN_2
96DD DEC A Count down, and go on to the warning test unless it reached zero
96DE LD (IY+$01),A
96E1 CP $00
96E3 JR NZ,END_OF_TURN_1
96E5 LD A,(TIMER_FIRED) Already had one fire this turn? Hold this one at 1 until the next
96E8 CP $01
96EA LD (IY+$01),A
96ED JR Z,END_OF_TURN_1
96EF INC A Count one fired
96F0 LD (TIMER_FIRED),A
96F3 LD L,(IY+$02) Run its routine through RUN_ROUTINE
96F6 LD H,(IY+$03)
96F9 CALL RUN_ROUTINE
96FC JR END_OF_TURN_2
END_OF_TURN_1 96FE LD A,(IY+$04) No warning span: nothing to do
9701 CP $00
9703 JR Z,END_OF_TURN_2
9705 CP (IY+$01) Is the count within the warning span?
9708 JR C,END_OF_TURN_2
970A LD L,(IY+$05) Then run the warning routine
970D LD H,(IY+$06)
9710 CALL RUN_ROUTINE
END_OF_TURN_2 9713 LD DE,$0007 On to the next 7-byte timer
9716 ADD IY,DE
9718 JP END_OF_TURN_0
END_OF_TURN_3 971B LD A,$01 Printing on
971D LD (PRINTING_ON),A
9720 POP DE
9721 POP BC
9722 POP IY
9724 POP IX
9726 POP HL
9727 RET
Prev: 96A8 Up: Map Next: 9728