summaryrefslogtreecommitdiff
path: root/home
diff options
context:
space:
mode:
Diffstat (limited to 'home')
-rw-r--r--home/game_time.asm36
-rw-r--r--home/item.asm37
-rw-r--r--home/map.asm16
-rw-r--r--home/random.asm63
4 files changed, 53 insertions, 99 deletions
diff --git a/home/game_time.asm b/home/game_time.asm
index bb511e04..01ad750b 100644
--- a/home/game_time.asm
+++ b/home/game_time.asm
@@ -1,11 +1,11 @@
ResetGameTime:: ; 1ee6 (0:1ee6)
xor a
- ld [GameTimeCap], a
- ld [GameTimeHours], a
- ld [GameTimeHours + 1], a
- ld [GameTimeMinutes], a
- ld [GameTimeSeconds], a
- ld [GameTimeFrames], a
+ ld [wGameTimeCap], a
+ ld [wGameTimeHours], a
+ ld [wGameTimeHours + 1], a
+ ld [wGameTimeMinutes], a
+ ld [wGameTimeSeconds], a
+ ld [wGameTimeFrames], a
ret
GameTimer:: ; 1efa (0:1efa)
@@ -14,15 +14,15 @@ GameTimer:: ; 1efa (0:1efa)
and a
ret nz
- ld hl, GameTimerPause
+ ld hl, wGameTimerPause
bit 0, [hl]
ret z
- ld hl, GameTimeCap
+ ld hl, wGameTimeCap
bit 0, [hl]
ret nz
- ld hl, GameTimeFrames
+ ld hl, wGameTimeFrames
ld a, [hl]
inc a
cp 60
@@ -33,7 +33,7 @@ GameTimer:: ; 1efa (0:1efa)
.second
xor a
ld [hl], a
- ld hl, GameTimeSeconds
+ ld hl, wGameTimeSeconds
ld a, [hl]
inc a
cp 60
@@ -44,7 +44,7 @@ GameTimer:: ; 1efa (0:1efa)
.minute
xor a
ld [hl], a
- ld hl, GameTimeMinutes
+ ld hl, wGameTimeMinutes
ld a, [hl]
inc a
cp 60
@@ -55,9 +55,9 @@ GameTimer:: ; 1efa (0:1efa)
.hour
xor a
ld [hl], a
- ld a, [GameTimeHours]
+ ld a, [wGameTimeHours]
ld h, a
- ld a, [GameTimeHours + 1]
+ ld a, [wGameTimeHours + 1]
ld l, a
inc hl
ld a, h
@@ -66,16 +66,16 @@ GameTimer:: ; 1efa (0:1efa)
ld a, l
cp 1000 % $100
jr c, .ok
- ld hl, GameTimeCap
+ ld hl, wGameTimeCap
set 0, [hl]
ld a, 59
- ld [GameTimeMinutes], a
- ld [GameTimeSeconds], a
+ ld [wGameTimeMinutes], a
+ ld [wGameTimeSeconds], a
ret
.ok
ld a, h
- ld [GameTimeHours], a
+ ld [wGameTimeHours], a
ld a, l
- ld [GameTimeHours + 1], a
+ ld [wGameTimeHours + 1], a
ret
diff --git a/home/item.asm b/home/item.asm
index 92d74c35..bee5f678 100644
--- a/home/item.asm
+++ b/home/item.asm
@@ -1,30 +1,26 @@
-DoItemEffect:: ; 2f3f
- callba _DoItemEffect
+DoItemEffect::
+ callba DoItemEffect_
ret
-; 2f46
-CheckTossableItem:: ; 2f46
+CheckTossableItem::
push hl
push de
push bc
- callba _CheckTossableItem
+ callba CheckTossableItem_
pop bc
pop de
pop hl
ret
-; 2f53
-TossItem:: ; 2f53
+TossItem::
push hl
push de
push bc
ld a, [hROMBank]
push af
- ld a, BANK(_TossItem)
+ ld a, BANK(TossItem_)
rst Bankswitch
-
- call _TossItem
-
+ call TossItem_
pop bc
ld a, b
rst Bankswitch
@@ -32,19 +28,16 @@ TossItem:: ; 2f53
pop de
pop hl
ret
-; 2f66
-ReceiveItem:: ; 2f66
+ReceiveItem::
push bc
ld a, [hROMBank]
push af
- ld a, BANK(_ReceiveItem)
+ ld a, BANK(ReceiveItem_)
rst Bankswitch
push hl
push de
-
- call _ReceiveItem
-
+ call ReceiveItem_
pop de
pop hl
pop bc
@@ -52,19 +45,16 @@ ReceiveItem:: ; 2f66
rst Bankswitch
pop bc
ret
-; 2f79
-CheckItem:: ; 2f79
+CheckItem::
push hl
push de
push bc
ld a, [hROMBank]
push af
- ld a, BANK(_CheckItem)
+ ld a, BANK(CheckItem_)
rst Bankswitch
-
- call _CheckItem
-
+ call CheckItem_
pop bc
ld a, b
rst Bankswitch
@@ -72,4 +62,3 @@ CheckItem:: ; 2f79
pop de
pop hl
ret
-; 2f8c
diff --git a/home/map.asm b/home/map.asm
index 5da4d27d..2f4a32e2 100644
--- a/home/map.asm
+++ b/home/map.asm
@@ -1411,7 +1411,7 @@ CheckObjectMask::
.asm_282c
ld e, a
ld d, $0
- ld hl, MapObjectsEnd
+ ld hl, wMapObjectsEnd
add hl, de
ld a, [hl]
.asm_2834
@@ -1431,7 +1431,7 @@ UnmaskObject:: ; 2841 (0:2841)
ld a, [hMapObjectIndexBuffer]
ld e, a
ld d, $0
- ld hl, MapObjectsEnd
+ ld hl, wMapObjectsEnd
add hl, de
ld [hl], $0
ret
@@ -1737,7 +1737,7 @@ SaveScreen_LoadNeighbor::
GetMovementPermissions:: ; 2a05 (0:2a05)
xor a
- ld [TilePermissions], a
+ ld [wTilePermissions], a
call .LeftRight
call .UpDown
ld a, [wPlayerStandingMapX]
@@ -1757,7 +1757,7 @@ GetMovementPermissions:: ; 2a05 (0:2a05)
adc h
ld h, a
ld a, [hl]
- ld hl, TilePermissions
+ ld hl, wTilePermissions
or [hl]
ld [hl], a
ret
@@ -1818,7 +1818,7 @@ GetMovementPermissions:: ; 2a05 (0:2a05)
cp $7
ret nz
.asm_2a90
- ld hl, TilePermissions
+ ld hl, wTilePermissions
set 3, [hl]
ret
@@ -1834,7 +1834,7 @@ GetMovementPermissions:: ; 2a05 (0:2a05)
cp $5
ret nz
.asm_2aaa
- ld hl, TilePermissions
+ ld hl, wTilePermissions
set 3, [hl]
ret
@@ -1850,7 +1850,7 @@ GetMovementPermissions:: ; 2a05 (0:2a05)
cp $7
ret nz
.asm_2ac4
- ld hl, TilePermissions
+ ld hl, wTilePermissions
set 3, [hl]
ret
@@ -1866,7 +1866,7 @@ GetMovementPermissions:: ; 2a05 (0:2a05)
cp $6
ret nz
.asm_2ade
- ld hl, TilePermissions
+ ld hl, wTilePermissions
set 3, [hl]
ret
diff --git a/home/random.asm b/home/random.asm
index ae39f439..f96718b2 100644
--- a/home/random.asm
+++ b/home/random.asm
@@ -1,84 +1,49 @@
-Random:: ; 2f8c
-; A simple hardware-based random number generator (RNG).
-
-; Two random numbers are generated by adding and subtracting
-; the divider to the respective values every time it's called.
-
-; The divider is a register that increments at a rate of 16384Hz.
-; For comparison, the Game Boy operates at a clock speed of 4.2MHz.
-
-; Additionally, an equivalent function is executed in VBlank.
-
-; This leaves a with the value in hRandomSub.
-
+Random:: ; 30a2 (0:30a2)
push bc
-
ld a, [rDIV]
ld b, a
- ld a, [hRandomAdd]
+ ld a, [hRandom]
adc b
- ld [hRandomAdd], a
-
+ ld [hRandom], a
ld a, [rDIV]
ld b, a
ld a, [hRandomSub]
sbc b
ld [hRandomSub], a
-
pop bc
ret
-; 2f9f
-
-BattleRandom:: ; 2f9f
-; _BattleRandom lives in another bank.
-
-; It handles all RNG calls in the battle engine, allowing
-; link battles to remain in sync using a shared PRNG.
+BattleRandom::
ld a, [hROMBank]
push af
- ld a, BANK(_BattleRandom)
+ ld a, BANK(BattleRandom_)
rst Bankswitch
-
- call _BattleRandom
-
- ld [PredefTemp + 1], a
+ call BattleRandom_
+ ld [wPredefHLBuffer + 1], a
pop af
rst Bankswitch
- ld a, [PredefTemp + 1]
+ ld a, [wPredefHLBuffer + 1]
ret
-; 2fb1
-
-
-RandomRange:: ; 2fb1
-; Return a random number between 0 and a (non-inclusive).
+RandomRange::
push bc
ld c, a
-
- ; b = $100 % c
xor a
sub c
-.mod
+.asm_30cb
sub c
- jr nc, .mod
+ jr nc, .asm_30cb
add c
ld b, a
-
- ; Get a random number
- ; from 0 to $ff - b.
push bc
-.loop
+.asm_30d1
call Random
- ld a, [hRandomAdd]
+ ld a, [hRandom]
ld c, a
add b
- jr c, .loop
+ jr c, .asm_30d1
ld a, c
pop bc
-
call SimpleDivide
-
pop bc
ret
-; 2fcb