summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Höglund <firefly@firefly.nu>2014-07-22 15:00:30 +0200
committerJonas Höglund <firefly@firefly.nu>2014-07-22 15:00:30 +0200
commit5662b94aa2b8a0b1a3c4b40da317215c4b74325f (patch)
treece559d08b60ae716c2b9413003a870a0f5fb5bd3
parente57de4f6adecaa13bf60de6f78b2513cb0fa6ac5 (diff)
Home: do timer counter increment function
-rw-r--r--constants/misc_constants.asm7
-rwxr-xr-xengine/bank3.asm10
-rwxr-xr-xengine/home.asm18
3 files changed, 22 insertions, 13 deletions
diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm
index 45623d0..92313ee 100644
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -13,6 +13,13 @@ CURR_BGP EQU $CABC
CURR_OBP0 EQU $CABD
CURR_OBP1 EQU $CABE
+COUNTER_ENABLE EQU $CAC4
+COUNTER_FIELD0 EQU $CAC5
+COUNTER_FIELD1 EQU $CAC6
+COUNTER_FIELD2 EQU $CAC7
+COUNTER_FIELD3 EQU $CAC8
+COUNTER_FIELD4 EQU $CAC9
+
BUF_PALETTE EQU $CAF0
BUF_SERIAL EQU $CB74
diff --git a/engine/bank3.asm b/engine/bank3.asm
index 6e1c5bf..52113cb 100755
--- a/engine/bank3.asm
+++ b/engine/bank3.asm
@@ -242,11 +242,11 @@ Func_c1b1: ; c1b1 (3:41b1)
farcall Func_1c82e
farcall Func_131b3
xor a
- ld [$cac5], a
- ld [$cac6], a
- ld [$cac7], a
- ld [$cac8], a
- ld [$cac9], a
+ ld [COUNTER_FIELD0], a
+ ld [COUNTER_FIELD1], a
+ ld [COUNTER_FIELD2], a
+ ld [COUNTER_FIELD3], a
+ ld [COUNTER_FIELD4], a
ret
Func_c1ed: ; c1ed (3:41ed)
diff --git a/engine/home.asm b/engine/home.asm
index e7b5253..ff3b2f8 100755
--- a/engine/home.asm
+++ b/engine/home.asm
@@ -122,7 +122,7 @@ TimerHandler: ; 01e6 (0:01e6)
inc [hl]
and $3
jr nz, .asm_217
- call Func_021c
+ call IncrementCounter
ld hl, $caba
bit 1, [hl]
jr nz, .asm_217
@@ -143,26 +143,28 @@ TimerHandler: ; 01e6 (0:01e6)
pop af
reti
-Func_021c: ; 021c (0:021c)
- ld a, [$cac4]
+; increment timer counter by a tick
+; the counter consists of three fields 0..60 and two fields 0..255
+IncrementCounter: ; 021c (0:021c)
+ ld a, [COUNTER_ENABLE]
or a
ret z
- ld hl, $cac5
+ ld hl, COUNTER_FIELD0
inc [hl]
ld a, [hl]
- cp $3c
+ cp 60
ret c
ld [hl], $0
inc hl
inc [hl]
ld a, [hl]
- cp $3c
+ cp 60
ret c
ld [hl], $0
inc hl
inc [hl]
ld a, [hl]
- cp $3c
+ cp 60
ret c
ld [hl], $0
inc hl
@@ -3668,7 +3670,7 @@ Func_380e: ; 380e (0:380e)
Func_383d: ; 383d (0:383d)
ld a, $1
- ld [$cac4], a
+ ld [COUNTER_ENABLE], a
ld a, [CURR_ROM_BANK]
push af
.asm_3845