Prev: BFC6 Up: Map Next: C00C
BFD9: Handler: Game Clock
Used by the routine at Game_Initialisation.
Carries out this step while the game is running.
Handle the game ticker.
Handler_GameClock BFD9 LD HL,($9FDD) Increment *CurrentTime_Ticker by one.
BFDC INC HL
BFDD LD ($9FDD),HL
Handle the clock minutes.
BFE0 LD HL,$9FDF Increment *CurrentTime_Minutes by one.
BFE3 INC (HL)
BFE4 LD A,(HL) Return unless the minute count has reached 3C.
BFE5 CP $3C
BFE7 RET NZ
The minutes is at 60, which is invalid - so handle rolling the clock hour digits.
BFE8 LD (HL),$00 Reset the minutes back to 00 at *HL.
Handle the clock hours.
BFEA LD HL,$9FE0 Increment *CurrentTime_Hour by one.
BFED INC (HL)
BFEE LD A,(HL) Jump to Handler_GameClock_AM_PM unless the hour has reached 0D.
BFEF CP $0D
BFF1 JR NZ,Handler_GameClock_AM_PM
The hours is at 13. which is invalid - so handle rolling the clock.
BFF3 LD (HL),$01 Reset the hours back to 01 at *HL.
BFF5 RET Return.
Noon or midnight flips the AM/PM marker.
Handler_GameClock_AM_PM BFF6 CP $0C Return unless the hour is 0C.
BFF8 RET NZ
It's either midday or midnight, so flip between AM and PM.
BFF9 LD A,($9FE2) Read the AM/PM marker.
Smart way of altering the letter from "a" to "p" and back again.
Letter Bits
"a" 01100001
"p" 01110000
BFFC XOR %00010001 Flip bits 0, 4.
BFFE LD ($9FE2),A Write this back to *Messaging_AM_PM.
If the clock went from PM to AM, handle rolling the day of the week.
C001 CP $61 Return unless the AM/PM marker is the letter a.
C003 RET NZ
C004 LD A,($9FE1) Increment *CurrentDayOfWeek by one.
C007 INC A
C008 LD ($9FE1),A
C00B RET Return.
Prev: BFC6 Up: Map Next: C00C