diff options
Diffstat (limited to 'engine/pinball_game/timer.asm')
-rwxr-xr-x | engine/pinball_game/timer.asm | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/engine/pinball_game/timer.asm b/engine/pinball_game/timer.asm new file mode 100755 index 0000000..1200877 --- /dev/null +++ b/engine/pinball_game/timer.asm @@ -0,0 +1,58 @@ +StartTimer: ; 0x867d
+; Starts the timer that counts down with the specified starting time when things
+; like CatchEm Mode start.
+; input: b = minutes
+; c = seconds
+ ld a, c
+ ld [wTimerSeconds], a
+ ld a, b
+ ld [wTimerMinutes], a
+ xor a
+ ld [wTimerFrames], a
+ ld [wd57e], a
+ ld [wd57f], a
+ ld a, $1
+ ld [wd57d], a
+ ld a, $1
+ ld [wd580], a
+ callba Func_1404a
+ ret
+
+Func_86a4: ; 0x86a4
+ ld a, [wd57f]
+ and a
+ ret nz
+ ld a, [wTimerFrames]
+ inc a
+ cp $3c
+ jr c, .asm_86b2
+ xor a
+.asm_86b2
+ ld [wTimerFrames], a
+ ret c
+ ld hl, wTimerMinutes
+ ld a, [hld]
+ or [hl]
+ jr nz, .asm_86c3
+ ld a, $1
+ ld [wd57e], a
+ ret
+
+.asm_86c3
+ ld a, [hl]
+ sub $1
+ daa
+ jr nc, .asm_86cb
+ ld a, $59
+.asm_86cb
+ ld [hli], a
+ ld a, [hl]
+ sbc $0
+ daa
+ ld [hl], a
+ ret
+
+Func_86d2: ; 0x86d2
+ xor a
+ ld [wd57d], a
+ ret
|