Prev: 95D7 Up: Map Next: 961B
95DA: Advance the elapsed-time clock
Used by the routine at FRAME_TICK_NEXT.
The clock counts up rather than down -- Atic Atac's TIME is how long you have been in the castle, not how long is left. Three bytes of BCD at $5E3D, $5E3E and $5E3F hold it, and the panel prints them as one digit, then two, a colon, then two: 000:09.
Its time base is the ROM's own FRAMES counter, which ticks 50 times a second on the interrupt the game leaves enabled. Rather than remember when the last second was, it subtracts 50 from FRAMES whenever there are at least 50 there, so the remainder carries the fraction of a second forward and nothing drifts.
Confirmed against a running game: with the three bytes reading $00 $00 $09 the panel showed TIME 000:09.
TICK_CLOCK 95DA LD A,($5C78) Fewer than fifty frames since the last tick, so there is nothing to do yet.
95DD CP $32
95DF RET C
95E0 SUB $32 Take a whole second out and leave the remainder for next time.
95E2 LD ($5C78),A
95E5 LD HL,$5E3F The seconds, the last of the three bytes.
95E8 LD A,(HL) INC then DAA -- adding 1 in BCD, so the digits stay printable.
95E9 INC A
95EA DAA
95EB LD (HL),A
95EC CP $60 Sixty, in BCD, is $60.
95EE JR NZ,TICK_CLOCK_0
95F0 LD (HL),$00 Round the seconds and carry into the minutes.
95F2 DEC HL
95F3 LD A,(HL)
95F4 INC A
95F5 DAA
95F6 LD (HL),A
95F7 CP $60
95F9 JR NZ,TICK_CLOCK_0
95FB LD (HL),$00
95FD DEC HL And the minutes into the hours.
95FE LD A,(HL)
95FF INC A
9600 DAA
9601 AND $0F Hours are kept to a single digit, which is what makes the display 000:09 rather than 00:00:09.
9603 LD (HL),A
TICK_CLOCK_0 9604 LD HL,$40C8
This entry point is used by the routine at DRAW_SUMMARY.
PRINT_CLOCK 9607 CALL PIXEL_TO_SCREEN
960A LD DE,$5E3D
960D LD B,$02
960F CALL DRAW_LOW_DIGIT
9612 LD DE,$5E3F
9615 INC HL
9616 LD B,$01
9618 JP DRAW_DIGITS
Prev: 95D7 Up: Map Next: 961B