Prev: 38359 Up: Map Next: 38427
38362: Update Clock
Used by the routine at UpdateFixedEntities.
Called whenever FRAMES has changed. Once 50 frames have passed, FRAMES is reduced by that, the seconds in ClockSeconds are increased (in BCD), the minutes in ClockMinutes when the seconds reach 96 and the hours in ClockHours when the minutes reach 96 and then the clock is printed on the screen.
ClockTick 38362 LD A,(23672) Fetch FRAMES.
38365 CP 50 Return if fewer than 50 frames have passed.
38367 RET C
38368 SUB 50 Subtract 50 as a second has passed.
38370 LD (23672),A Update FRAMES.
38373 LD HL,24127 Point HL at the clock seconds at ClockSeconds.
38376 LD A,(HL) Fetch the seconds.
38377 INC A Increment the seconds.
38378 DAA Convert it to BCD.
38379 LD (HL),A Write it back.
38380 CP 96 Jump to ClockTick_Print if the seconds have not reached 96.
38382 JR NZ,ClockTick_Print
38384 LD (HL),0 Reset the seconds to 0.
38386 DEC HL Move HL on to the minutes.
38387 LD A,(HL) Fetch the minutes.
38388 INC A Increment the minutes.
38389 DAA Convert it to BCD.
38390 LD (HL),A Write it back.
38391 CP 96 Jump to ClockTick_Print if the minutes have not reached 96.
38393 JR NZ,ClockTick_Print
38395 LD (HL),0 Reset the minutes to 0.
38397 DEC HL Move HL on to the hours.
38398 LD A,(HL) Fetch the hours.
38399 INC A Increment the hours.
38400 DAA Convert it to BCD.
38401 AND %00001111 Keep only bits 0-3.
38403 LD (HL),A Write it back.
Print the clock.
ClockTick_Print 38404 LD HL,16584 HL=16584 (screen buffer location).
This entry point is used by the routine at GameStats.
PrintClock 38407 CALL ScreenAddress Call ScreenAddress to get the screen address.
38410 LD DE,24125 Point DE at the clock hours at ClockHours.
38413 LD B,2 B=2.
38415 CALL PrintScore_LowDigit Call PrintScore_LowDigit to print the last digit of the hours and both digits of the minutes.
38418 LD DE,24127 Point DE at the clock seconds at ClockSeconds.
38421 INC HL Move HL on to the next character position.
38422 LD B,1 B=1.
38424 JP PrintScore_Loop Jump to PrintScore_Loop to print both digits of the seconds.
Prev: 38359 Up: Map Next: 38427