Prev: 6498 Up: Map Next: 64F0
64C7: Handler: Update Time
Used by the routine at HandlerPlayer.
Adds one second to the time taken every 32 frames. The time is held as three BCD bytes from Time_1: hours (a single digit), minutes and seconds.
HandlerTime 64C7 LD A,($5C78) Fetch the frame counter from FRAMES.
64CA CP $32 Return if less than 32 frames (one second) have passed.
64CC RET C
64CD SUB $32 Take 32 frames off the frame counter.
64CF LD ($5C78),A Write the remaining frames back to FRAMES.
Update the time from the smallest unit upwards.
Handles the "seconds".
64D2 LD HL,$5E33 Point HL at the seconds of the time (Time_3).
64D5 LD A,(HL) Grab the seconds.
64D6 INC A Add one second.
64D7 DAA Convert to BCD and write seconds back to Time_3.
64D8 LD (HL),A
64D9 CP $60 Return unless seconds have reached 60.
64DB RET NZ
64DC LD (HL),$00 Reset seconds to 00.
Handles the "minutes".
64DE DEC HL Point HL at the minutes of the time (Time_2).
64DF LD A,(HL) Grab the minutes.
64E0 INC A Add one minute.
64E1 DAA Convert to BCD and write minutes back to Time_2.
64E2 LD (HL),A
64E3 CP $60 Return unless minutes have reached 60.
64E5 RET NZ
64E6 LD (HL),$00 Reset minutes to 00.
Handles the "hours".
64E8 DEC HL Point HL at the hours of the time (Time_1).
64E9 LD A,(HL) Grab the hours.
64EA INC A Add one hour.
64EB DAA Convert to BCD.
64EC AND %00001111 Keep only bits 0-3 (so the hours are a single digit).
64EE LD (HL),A Write hours back to Time_1.
64EF RET Return.
Prev: 6498 Up: Map Next: 64F0