2014-02-02 01:26:39 +00:00
|
|
|
ResetGameTime:: ; 208a
|
2013-09-03 22:58:16 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wGameTimeCap], a
|
|
|
|
ld [wGameTimeHours], a
|
|
|
|
ld [wGameTimeHours + 1], a
|
|
|
|
ld [wGameTimeMinutes], a
|
|
|
|
ld [wGameTimeSeconds], a
|
|
|
|
ld [wGameTimeFrames], a
|
2013-09-03 22:58:16 +00:00
|
|
|
ret
|
|
|
|
; 209e
|
|
|
|
|
|
|
|
|
2014-02-02 01:26:39 +00:00
|
|
|
GameTimer:: ; 209e
|
2013-09-03 22:58:16 +00:00
|
|
|
|
|
|
|
nop
|
|
|
|
|
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, BANK(wGameTime)
|
2013-09-03 22:58:16 +00:00
|
|
|
ld [rSVBK], a
|
|
|
|
|
|
|
|
call UpdateGameTimer
|
|
|
|
|
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
ret
|
|
|
|
; 20ad
|
|
|
|
|
|
|
|
|
2014-02-02 01:26:39 +00:00
|
|
|
UpdateGameTimer:: ; 20ad
|
2013-09-03 22:58:16 +00:00
|
|
|
; Increment the game timer by one frame.
|
|
|
|
; The game timer is capped at 999:59:59.00.
|
|
|
|
|
|
|
|
|
|
|
|
; Don't update if game logic is paused.
|
2016-05-08 18:11:24 +00:00
|
|
|
ld a, [wGameLogicPaused]
|
2013-09-03 22:58:16 +00:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
; Is the timer paused?
|
2017-12-28 12:15:46 +00:00
|
|
|
ld hl, wGameTimerPause
|
2013-09-03 22:58:16 +00:00
|
|
|
bit 0, [hl]
|
|
|
|
ret z
|
|
|
|
|
|
|
|
; Is the timer already capped?
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wGameTimeCap
|
2013-09-03 22:58:16 +00:00
|
|
|
bit 0, [hl]
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
|
|
|
|
; +1 frame
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wGameTimeFrames
|
2013-09-03 22:58:16 +00:00
|
|
|
ld a, [hl]
|
|
|
|
inc a
|
|
|
|
|
|
|
|
cp 60 ; frames/second
|
|
|
|
jr nc, .second
|
|
|
|
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
.second
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
; +1 second
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wGameTimeSeconds
|
2013-09-03 22:58:16 +00:00
|
|
|
ld a, [hl]
|
|
|
|
inc a
|
|
|
|
|
|
|
|
cp 60 ; seconds/minute
|
|
|
|
jr nc, .minute
|
|
|
|
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
.minute
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
; +1 minute
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wGameTimeMinutes
|
2013-09-03 22:58:16 +00:00
|
|
|
ld a, [hl]
|
|
|
|
inc a
|
|
|
|
|
|
|
|
cp 60 ; minutes/hour
|
|
|
|
jr nc, .hour
|
|
|
|
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
.hour
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
; +1 hour
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wGameTimeHours]
|
2013-09-03 22:58:16 +00:00
|
|
|
ld h, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wGameTimeHours + 1]
|
2013-09-03 22:58:16 +00:00
|
|
|
ld l, a
|
|
|
|
inc hl
|
|
|
|
|
|
|
|
|
|
|
|
; Cap the timer after 1000 hours.
|
|
|
|
ld a, h
|
2017-12-25 18:40:10 +00:00
|
|
|
cp HIGH(1000)
|
2013-09-03 22:58:16 +00:00
|
|
|
jr c, .ok
|
|
|
|
|
|
|
|
ld a, l
|
2017-12-25 18:40:10 +00:00
|
|
|
cp LOW(1000)
|
2013-09-03 22:58:16 +00:00
|
|
|
jr c, .ok
|
|
|
|
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wGameTimeCap
|
2013-09-03 22:58:16 +00:00
|
|
|
set 0, [hl]
|
|
|
|
|
|
|
|
ld a, 59 ; 999:59:59.00
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wGameTimeMinutes], a
|
|
|
|
ld [wGameTimeSeconds], a
|
2013-09-03 22:58:16 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
.ok
|
|
|
|
ld a, h
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wGameTimeHours], a
|
2013-09-03 22:58:16 +00:00
|
|
|
ld a, l
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wGameTimeHours + 1], a
|
2013-09-03 22:58:16 +00:00
|
|
|
ret
|
|
|
|
; 210f
|