summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-11-03 19:52:59 -0500
committerRangi <remy.oukaour+rangi42@gmail.com>2020-11-03 19:52:59 -0500
commit5c143ed970c969832953699e80b1fcaab182c5a1 (patch)
treee53bfcffbb48a14a59046c1e32da8b9ba6478bee
parentb56c1b6351f51742903250ee0c4eae9d22e2b6a5 (diff)
Identify more uses of wBuffer1-6
-rw-r--r--engine/battle/ai/move.asm14
-rw-r--r--engine/battle/ai/scoring.asm22
-rw-r--r--engine/battle/core.asm12
-rw-r--r--engine/battle/trainer_huds.asm7
-rw-r--r--engine/events/daycare.asm4
-rw-r--r--engine/events/heal_machine_anim.asm20
-rw-r--r--engine/events/lucky_number.asm4
-rw-r--r--engine/events/pokecenter_pc.asm24
-rw-r--r--engine/events/treemons.asm6
-rw-r--r--engine/items/buy_sell_toss.asm12
-rw-r--r--engine/link/link.asm5
-rw-r--r--engine/menus/menu_2.asm11
-rw-r--r--engine/overworld/decorations.asm55
-rw-r--r--engine/overworld/time.asm10
-rw-r--r--engine/phone/phone.asm6
-rw-r--r--engine/pokemon/evolve.asm2
-rw-r--r--engine/pokemon/learn.asm2
-rw-r--r--engine/pokemon/mail.asm3
-rw-r--r--engine/pokemon/mail_2.asm37
-rw-r--r--engine/pokemon/mon_menu.asm2
-rw-r--r--engine/pokemon/mon_stats.asm21
-rw-r--r--engine/pokemon/mon_submenu.asm26
-rw-r--r--engine/pokemon/move_mon.asm6
-rw-r--r--engine/pokemon/stats_screen.asm14
-rw-r--r--engine/pokemon/switchpartymons.asm28
-rw-r--r--engine/rtc/restart_clock.asm84
-rw-r--r--gfx/mail/mail.pal59
-rw-r--r--wram.asm91
28 files changed, 325 insertions, 262 deletions
diff --git a/engine/battle/ai/move.asm b/engine/battle/ai/move.asm
index cb9289d5..94dbd41c 100644
--- a/engine/battle/ai/move.asm
+++ b/engine/battle/ai/move.asm
@@ -1,5 +1,5 @@
AIChooseMove:
-; Score each move in wEnemyMonMoves starting from wBuffer1. Lower is better.
+; Score each move of wEnemyMonMoves in wEnemyAIMoveScores. Lower is better.
; Pick the move with the lowest score.
; Wildmons attack at random.
@@ -17,7 +17,7 @@ AIChooseMove:
; The default score is 20. Unusable moves are given a score of 80.
ld a, 20
- ld hl, wBuffer1
+ ld hl, wEnemyAIMoveScores
ld [hli], a
ld [hli], a
ld [hli], a
@@ -37,14 +37,14 @@ AIChooseMove:
inc hl
jr .CheckDisabledMove
.ScoreDisabledMove:
- ld hl, wBuffer1
+ ld hl, wEnemyAIMoveScores
ld b, 0
add hl, bc
ld [hl], 80
; Don't pick moves with 0 PP.
.CheckPP:
- ld hl, wBuffer1 - 1
+ ld hl, wEnemyAIMoveScores - 1
ld de, wEnemyMonPP
ld b, 0
.CheckMovePP:
@@ -108,7 +108,7 @@ AIChooseMove:
; Decrement the scores of all moves one by one until one reaches 0.
.DecrementScores:
- ld hl, wBuffer1
+ ld hl, wEnemyAIMoveScores
ld de, wEnemyMonMoves
ld c, NUM_MOVES
@@ -143,7 +143,7 @@ AIChooseMove:
cp NUM_MOVES + 1
jr nz, .move_loop
- ld hl, wBuffer1
+ ld hl, wEnemyAIMoveScores
ld de, wEnemyMonMoves
ld c, NUM_MOVES
@@ -173,7 +173,7 @@ AIChooseMove:
; Randomly choose one of the moves with a score of 1
.ChooseMove:
- ld hl, wBuffer1
+ ld hl, wEnemyAIMoveScores
call Random
maskbits NUM_MOVES
ld c, a
diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm
index e4f35b89..769b8835 100644
--- a/engine/battle/ai/scoring.asm
+++ b/engine/battle/ai/scoring.asm
@@ -6,7 +6,7 @@ AI_Basic:
; -Using status-only moves if the player can't be statused
; -Using moves that fail if they've already been used
- ld hl, wBuffer1 - 1
+ ld hl, wEnemyAIMoveScores - 1
ld de, wEnemyMonMoves
ld b, NUM_MOVES + 1
.checkmove
@@ -73,7 +73,7 @@ AI_Setup:
; 50% chance to greatly encourage stat-down moves during the first turn of player's Pokemon.
; Almost 90% chance to greatly discourage stat-modifying moves otherwise.
- ld hl, wBuffer1 - 1
+ ld hl, wEnemyAIMoveScores - 1
ld de, wEnemyMonMoves
ld b, NUM_MOVES + 1
.checkmove
@@ -147,7 +147,7 @@ AI_Types:
; Discourage not very effective moves unless
; all damaging moves are of the same type.
- ld hl, wBuffer1 - 1
+ ld hl, wEnemyAIMoveScores - 1
ld de, wEnemyMonMoves
ld b, NUM_MOVES + 1
.checkmove
@@ -234,7 +234,7 @@ AI_Types:
AI_Offensive:
; Greatly discourage non-damaging moves.
- ld hl, wBuffer1 - 1
+ ld hl, wEnemyAIMoveScores - 1
ld de, wEnemyMonMoves
ld b, NUM_MOVES + 1
.checkmove
@@ -261,7 +261,7 @@ AI_Offensive:
AI_Smart:
; Context-specific scoring.
- ld hl, wBuffer1
+ ld hl, wEnemyAIMoveScores
ld de, wEnemyMonMoves
ld b, NUM_MOVES + 1
.checkmove
@@ -518,7 +518,7 @@ AI_Smart_LockOn:
.player_locked_on
push hl
- ld hl, wBuffer1 - 1
+ ld hl, wEnemyAIMoveScores - 1
ld de, wEnemyMonMoves
ld c, NUM_MOVES + 1
@@ -2857,7 +2857,7 @@ AI_Opportunist:
ret c
.lowhp
- ld hl, wBuffer1 - 1
+ ld hl, wEnemyAIMoveScores - 1
ld de, wEnemyMonMoves
ld c, NUM_MOVES + 1
.checkmove
@@ -2951,7 +2951,7 @@ AI_Aggressive:
jr z, .done
; Discourage moves that do less damage unless they're reckless too.
- ld hl, wBuffer1 - 1
+ ld hl, wEnemyAIMoveScores - 1
ld de, wEnemyMonMoves
ld b, 0
.checkmove2
@@ -3024,7 +3024,7 @@ AI_Cautious:
and a
ret z
- ld hl, wBuffer1 - 1
+ ld hl, wEnemyAIMoveScores - 1
ld de, wEnemyMonMoves
ld c, NUM_MOVES + 1
.loop
@@ -3062,7 +3062,7 @@ INCLUDE "data/battle/ai/residual_moves.asm"
AI_Status:
; Dismiss status moves that don't affect the player.
- ld hl, wBuffer1 - 1
+ ld hl, wEnemyAIMoveScores - 1
ld de, wEnemyMonMoves
ld b, NUM_MOVES + 1
.checkmove
@@ -3125,7 +3125,7 @@ AI_Risky:
; Use any move that will KO the target.
; Risky moves will often be an exception (see below).
- ld hl, wBuffer1 - 1
+ ld hl, wEnemyAIMoveScores - 1
ld de, wEnemyMonMoves
ld c, NUM_MOVES + 1
.checkmove
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index ca8ac21e..8ec5f469 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -5075,7 +5075,7 @@ MoveSelectionScreen:
hlcoord 6, 17 - NUM_MOVES - 4
.got_start_coord
ld a, SCREEN_WIDTH
- ld [wBuffer1], a
+ ld [wListMovesLineSpacing], a
predef ListMoves
ld b, 5
@@ -6108,8 +6108,7 @@ LoadEnemyMon:
ld [hli], a
ld [hli], a
ld [hl], a
-; Make sure the predef knows this isn't a partymon
- ld [wEvolutionOldSpecies], a
+ ld [wSkipMovesBeforeLevelUp], a
; Fill moves based on level
predef FillMoves
@@ -7335,9 +7334,10 @@ SendOutMonText:
and a
jr z, .not_linked
- ld hl, GoMonText ; If we're in a LinkBattle print just "Go <PlayerMon>"
-
- ld a, [wBattleHasJustStarted] ; unless this (unidentified) variable is set
+; If we're in a LinkBattle print just "Go <PlayerMon>"
+; unless DoBattle already set [wBattleHasJustStarted]
+ ld hl, GoMonText
+ ld a, [wBattleHasJustStarted]
and a
jr nz, .skip_to_textbox
diff --git a/engine/battle/trainer_huds.asm b/engine/battle/trainer_huds.asm
index 7fd57571..a3fa4fdf 100644
--- a/engine/battle/trainer_huds.asm
+++ b/engine/battle/trainer_huds.asm
@@ -47,7 +47,7 @@ ShowOTTrainerMonsRemaining:
StageBallTilesData:
ld a, [de]
push af
- ld de, wBuffer1
+ ld de, wBattleHUDTiles
ld c, PARTY_LENGTH
ld a, $34 ; empty slot
.loop1
@@ -56,7 +56,8 @@ StageBallTilesData:
dec c
jr nz, .loop1
pop af
- ld de, wBuffer1
+
+ ld de, wBattleHUDTiles
.loop2
push af
call .GetHUDTile
@@ -200,7 +201,7 @@ LinkBattle_TrainerHuds:
jp LoadTrainerHudOAM
LoadTrainerHudOAM:
- ld de, wBuffer1
+ ld de, wBattleHUDTiles
ld c, PARTY_LENGTH
.loop
ld a, [wPlaceBallsY]
diff --git a/engine/events/daycare.asm b/engine/events/daycare.asm
index 4648e9d2..20c35572 100644
--- a/engine/events/daycare.asm
+++ b/engine/events/daycare.asm
@@ -610,8 +610,8 @@ DayCare_InitBreeding:
xor a
ld [wEggMonItem], a
ld de, wEggMonMoves
- xor a
- ld [wBuffer1], a
+ xor a ; FALSE
+ ld [wSkipMovesBeforeLevelUp], a
predef FillMoves
farcall InitEggMoves
ld hl, wEggMonID
diff --git a/engine/events/heal_machine_anim.asm b/engine/events/heal_machine_anim.asm
index ae2daa86..d63b678e 100644
--- a/engine/events/heal_machine_anim.asm
+++ b/engine/events/heal_machine_anim.asm
@@ -17,19 +17,19 @@ HealMachineAnim:
; 1: Left (Elm's Lab)
; 2: Up (Hall of Fame)
ld a, [wScriptVar]
- ld [wBuffer1], a
+ ld [wHealMachineAnimType], a
ldh a, [rOBP1]
- ld [wBuffer2], a
+ ld [wHealMachineTempOBP1], a
call .DoJumptableFunctions
- ld a, [wBuffer2]
+ ld a, [wHealMachineTempOBP1]
call DmgToCgbObjPal1
ret
.DoJumptableFunctions:
xor a
- ld [wBuffer3], a
-.jumpable_loop
- ld a, [wBuffer1]
+ ld [wHealMachineAnimState], a
+.jumptable_loop
+ ld a, [wHealMachineAnimType]
ld e, a
ld d, 0
ld hl, .Pointers
@@ -38,17 +38,17 @@ HealMachineAnim:
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [wBuffer3]
+ ld a, [wHealMachineAnimState]
ld e, a
inc a
- ld [wBuffer3], a
+ ld [wHealMachineAnimState], a
add hl, de
ld a, [hl]
cp HEALMACHINESTATE_FINISH
jr z, .finish
ld hl, .Jumptable
rst JumpTable
- jr .jumpable_loop
+ jr .jumptable_loop
.finish
ret
@@ -229,7 +229,7 @@ INCLUDE "gfx/overworld/heal_machine.pal"
.PlaceHealingMachineTile:
push bc
- ld a, [wBuffer1]
+ ld a, [wHealMachineAnimType]
bcpixel 2, 4
cp HEALMACHINE_ELMS_LAB
jr z, .okay
diff --git a/engine/events/lucky_number.asm b/engine/events/lucky_number.asm
index 9e1d9b9b..8f4e7fdc 100644
--- a/engine/events/lucky_number.asm
+++ b/engine/events/lucky_number.asm
@@ -126,7 +126,7 @@ CheckForLuckyNumberWinners:
push hl
ld d, h
ld e, l
- ld hl, wBuffer1
+ ld hl, wMonIDDigitsBuffer
lb bc, PRINTNUM_LEADINGZEROS | 2, 5
call PrintNum
ld hl, wLuckyNumberDigitsBuffer
@@ -136,7 +136,7 @@ CheckForLuckyNumberWinners:
ld b, 5
ld c, 0
ld hl, wLuckyNumberDigitsBuffer + 4
- ld de, wBuffer1 + 4
+ ld de, wMonIDDigitsBuffer + 4
.loop
ld a, [de]
cp [hl]
diff --git a/engine/events/pokecenter_pc.asm b/engine/events/pokecenter_pc.asm
index 0503ee6f..74645a92 100644
--- a/engine/events/pokecenter_pc.asm
+++ b/engine/events/pokecenter_pc.asm
@@ -361,15 +361,15 @@ PlayerWithdrawItemMenu:
.withdraw
ld a, [wItemQuantityChangeBuffer]
- ld [wBuffer1], a ; quantity
+ ld [wPCItemQuantityChangeBuffer], a
ld a, [wCurItemQuantity]
- ld [wBuffer2], a
+ ld [wPCItemQuantity], a
ld hl, wNumItems
call ReceiveItem
jr nc, .PackFull
- ld a, [wBuffer1]
+ ld a, [wPCItemQuantityChangeBuffer]
ld [wItemQuantityChangeBuffer], a
- ld a, [wBuffer2]
+ ld a, [wPCItemQuantity]
ld [wCurItemQuantity], a
ld hl, wNumPCItems
call TossItem
@@ -490,15 +490,15 @@ PlayerDepositItemMenu:
ret
.tossable
- ld a, [wBuffer1]
+ ld a, [wPCItemQuantityChangeBuffer]
push af
- ld a, [wBuffer2]
+ ld a, [wPCItemQuantity]
push af
call .DepositItem
pop af
- ld [wBuffer2], a
+ ld [wPCItemQuantity], a
pop af
- ld [wBuffer1], a
+ ld [wPCItemQuantityChangeBuffer], a
ret
.DepositItem:
@@ -522,15 +522,15 @@ PlayerDepositItemMenu:
.ContinueDeposit:
ld a, [wItemQuantityChangeBuffer]
- ld [wBuffer1], a
+ ld [wPCItemQuantityChangeBuffer], a
ld a, [wCurItemQuantity]
- ld [wBuffer2], a
+ ld [wPCItemQuantity], a
ld hl, wNumPCItems
call ReceiveItem
jr nc, .NoRoomInPC
- ld a, [wBuffer1]
+ ld a, [wPCItemQuantityChangeBuffer]
ld [wItemQuantityChangeBuffer], a
- ld a, [wBuffer2]
+ ld a, [wPCItemQuantity]
ld [wCurItemQuantity], a
ld hl, wNumItems
call TossItem
diff --git a/engine/events/treemons.asm b/engine/events/treemons.asm
index 42d89d1f..f0184816 100644
--- a/engine/events/treemons.asm
+++ b/engine/events/treemons.asm
@@ -195,11 +195,11 @@ NoTreeMon:
GetTreeScore:
call .CoordScore
- ld [wBuffer1], a
+ ld [wTreeMonCoordScore], a
call .OTIDScore
- ld [wBuffer2], a
+ ld [wTreeMonOTIDScore], a
ld c, a
- ld a, [wBuffer1]
+ ld a, [wTreeMonCoordScore]
sub c
jr z, .rare
jr nc, .ok
diff --git a/engine/items/buy_sell_toss.asm b/engine/items/buy_sell_toss.asm
index 7a808f61..07aaaf38 100644
--- a/engine/items/buy_sell_toss.asm
+++ b/engine/items/buy_sell_toss.asm
@@ -7,9 +7,9 @@ SelectQuantityToToss:
SelectQuantityToBuy:
farcall GetItemPrice
ld a, d
- ld [wBuffer1], a
+ ld [wBuySellItemPrice + 0], a
ld a, e
- ld [wBuffer2], a
+ ld [wBuySellItemPrice + 1], a
ld hl, BuyItem_MenuHeader
call LoadMenuHeader
call Toss_Sell_Loop
@@ -18,9 +18,9 @@ SelectQuantityToBuy:
SelectQuantityToSell:
farcall GetItemPrice
ld a, d
- ld [wBuffer1], a
+ ld [wBuySellItemPrice + 0], a
ld a, e
- ld [wBuffer2], a
+ ld [wBuySellItemPrice + 1], a
ld hl, SellItem_MenuHeader
call LoadMenuHeader
call Toss_Sell_Loop
@@ -157,9 +157,9 @@ DisplaySellingPrice:
BuySell_MultiplyPrice:
xor a
ldh [hMultiplicand + 0], a
- ld a, [wBuffer1]
+ ld a, [wBuySellItemPrice + 0]
ldh [hMultiplicand + 1], a
- ld a, [wBuffer2]
+ ld a, [wBuySellItemPrice + 1]
ldh [hMultiplicand + 2], a
ld a, [wItemQuantityChangeBuffer]
ldh [hMultiplier], a
diff --git a/engine/link/link.asm b/engine/link/link.asm
index 2a59e99d..648d7236 100644
--- a/engine/link/link.asm
+++ b/engine/link/link.asm
@@ -419,6 +419,7 @@ Gen2ToGen2LinkComms:
ld [wOtherTrainerClass], a
call ClearTilemap
call WaitBGMap
+
ld hl, wOptions
ld a, [hl]
push af
@@ -430,19 +431,19 @@ Gen2ToGen2LinkComms:
ld bc, NAME_LENGTH
call CopyBytes
call ReturnToMapFromSubmenu
-
- ; LET'S DO THIS
ld a, [wDisableTextAcceleration]
push af
ld a, 1
ld [wDisableTextAcceleration], a
+ ; LET'S DO THIS
predef StartBattle
pop af
ld [wDisableTextAcceleration], a
pop af
ld [wOptions], a
+
farcall LoadPokemonData
jp ExitLinkCommunications
diff --git a/engine/menus/menu_2.asm b/engine/menus/menu_2.asm
index 83040f84..a0af3223 100644
--- a/engine/menus/menu_2.asm
+++ b/engine/menus/menu_2.asm
@@ -232,7 +232,7 @@ Kurt_SelectApricorn:
.MenuData:
db SCROLLINGMENU_ENABLE_SELECT | SCROLLINGMENU_ENABLE_FUNCTION3
- dbw 0, wBuffer1
+ dbw 0, wKurtApricornCount
dw .Name
dw NULL
@@ -251,9 +251,10 @@ Kurt_SelectApricorn:
FindApricornsInBag:
; Checks the bag for Apricorns.
- ld hl, wBuffer1
+ ld hl, wKurtApricornCount
xor a
ld [hli], a
+ assert wKurtApricornCount + 1 == wKurtApricornItems
dec a
ld bc, 10
call ByteFill
@@ -279,15 +280,15 @@ FindApricornsInBag:
.done
xor a
call .addtobuffer
- ld a, [wBuffer1]
+ ld a, [wKurtApricornCount]
cp 1
ret nz
scf
ret
-.addtobuffer
+.addtobuffer:
push hl
- ld hl, wBuffer1
+ ld hl, wKurtApricornCount
inc [hl]
ld e, [hl]
ld d, 0
diff --git a/engine/overworld/decorations.asm b/engine/overworld/decorations.asm
index 059f915a..24cf578a 100644
--- a/engine/overworld/decorations.asm
+++ b/engine/overworld/decorations.asm
@@ -10,17 +10,17 @@ _PlayerDecorationMenu:
push af
ld hl, .MenuHeader
call LoadMenuHeader
- xor a
- ld [wBuffer5], a
- ld a, $1
- ld [wBuffer6], a
+ xor a ; FALSE
+ ld [wChangedDecorations], a
+ ld a, $1 ; bed
+ ld [wCurDecorationCategory], a
.top_loop
- ld a, [wBuffer6]
+ ld a, [wCurDecorationCategory]
ld [wMenuCursorBuffer], a
call .FindCategoriesWithOwnedDecos
call DoNthMenu
ld a, [wMenuCursorY]
- ld [wBuffer6], a
+ ld [wCurDecorationCategory], a
jr c, .exit_menu
ld a, [wMenuSelection]
ld hl, .pointers
@@ -31,7 +31,7 @@ _PlayerDecorationMenu:
call ExitMenu
pop af
ld [wWhichIndexSet], a
- ld a, [wBuffer5]
+ ld a, [wChangedDecorations]
ld c, a
ret
@@ -71,7 +71,7 @@ _PlayerDecorationMenu:
xor a
ld [wWhichIndexSet], a
call .ClearStringBuffer2
- call .FindOwndDecos
+ call .FindOwnedDecos
ld a, 7
call .AppendToStringBuffer2
ld hl, wStringBuffer2
@@ -98,7 +98,7 @@ _PlayerDecorationMenu:
ld [hl], a
ret
-.FindOwndDecos:
+.FindOwnedDecos:
ld hl, .dw
.loop
ld a, [hli]
@@ -635,12 +635,12 @@ DecoAction_putawaybigdoll:
DecoAction_TrySetItUp:
ld a, [hl]
- ld [wBuffer1], a
+ ld [wCurDecoration], a
push hl
call DecoAction_SetItUp
jr c, .failed
- ld a, 1
- ld [wBuffer5], a
+ ld a, TRUE
+ ld [wChangedDecorations], a
pop hl
ld a, [wMenuSelection]
ld [hl], a
@@ -654,7 +654,7 @@ DecoAction_TrySetItUp:
DecoAction_SetItUp:
; See if there's anything of the same type already out
- ld a, [wBuffer1]
+ ld a, [wCurDecoration]
and a
jr z, .nothingthere
; See if that item is already out
@@ -666,7 +666,7 @@ DecoAction_SetItUp:
ld a, [wMenuSelection]
ld hl, wStringBuffer4
call GetDecorationName
- ld a, [wBuffer1]
+ ld a, [wCurDecoration]
ld hl, wStringBuffer3
call GetDecorationName
ld hl, PutAwayAndSetUpText
@@ -692,16 +692,16 @@ DecoAction_SetItUp:
DecoAction_TryPutItAway:
; If there is no item of that type already set, there is nothing to put away.
ld a, [hl]
- ld [wBuffer1], a
+ ld [wCurDecoration], a
xor a
ld [hl], a
- ld a, [wBuffer1]
+ ld a, [wCurDecoration]
and a
jr z, .nothingthere
; Put it away.
- ld a, $1
- ld [wBuffer5], a
- ld a, [wBuffer1]
+ ld a, TRUE
+ ld [wChangedDecorations], a
+ ld a, [wCurDecoration]
ld [wMenuSelection], a
ld hl, wStringBuffer3
call GetDecorationName
@@ -722,8 +722,8 @@ DecoAction_setupornament:
jr c, .cancel
call DecoAction_SetItUp_Ornament
jr c, .cancel
- ld a, $1
- ld [wBuffer5], a
+ ld a, TRUE
+ ld [wChangedDecorations], a
jr DecoAction_FinishUp_Ornament
.cancel
@@ -809,8 +809,8 @@ DecoAction_PutItAway_Ornament:
jr z, .nothingthere
ld hl, wStringBuffer3
call GetDecorationName
- ld a, $1
- ld [wBuffer5], a
+ ld a, TRUE
+ ld [wChangedDecorations], a
xor a
ld [wSelectedDecoration], a
ld hl, PutAwayTheDecoText
@@ -836,9 +836,9 @@ DecoAction_AskWhichSide:
call CopyMenuData
jr c, .nope
ld a, [wMenuCursorY]
- cp 3
+ cp 3 ; cancel
jr z, .nope
- ld [wBuffer2], a
+ ld [wSelectedDecorationSide], a
call QueryWhichSide
ld a, [hl]
ld [wSelectedDecoration], a
@@ -854,9 +854,10 @@ DecoAction_AskWhichSide:
QueryWhichSide:
ld hl, wDecoRightOrnament
ld de, wDecoLeftOrnament
- ld a, [wBuffer2]
- cp 1
+ ld a, [wSelectedDecorationSide]
+ cp 1 ; right side
ret z
+ ; left side, swap hl and de
push hl
ld h, d
ld l, e
diff --git a/engine/overworld/time.asm b/engine/overworld/time.asm
index a109a417..1366815f 100644
--- a/engine/overworld/time.asm
+++ b/engine/overworld/time.asm
@@ -216,15 +216,15 @@ DoMysteryGiftIfDayHasPassed:
call OpenSRAM
ld hl, sMysteryGiftTimer
ld a, [hli]
- ld [wBuffer1], a
+ ld [wTempMysteryGiftTimer], a
ld a, [hl]
- ld [wBuffer2], a
+ ld [wTempMysteryGiftTimer + 1], a
call CloseSRAM
- ld hl, wBuffer1
+ ld hl, wTempMysteryGiftTimer
call CheckDayDependentEventHL
jr nc, .not_timed_out
- ld hl, wBuffer1
+ ld hl, wTempMysteryGiftTimer
call InitOneDayCountdown
call CloseSRAM
farcall ResetDailyMysteryGiftLimitIfUnlocked
@@ -232,7 +232,7 @@ DoMysteryGiftIfDayHasPassed:
.not_timed_out
ld a, BANK(sMysteryGiftTimer)
call OpenSRAM
- ld hl, wBuffer1
+ ld hl, wTempMysteryGiftTimer
ld a, [hli]
ld [sMysteryGiftTimer], a
ld a, [hl]
diff --git a/engine/phone/phone.asm b/engine/phone/phone.asm
index af0c3931..307b4607 100644
--- a/engine/phone/phone.asm
+++ b/engine/phone/phone.asm
@@ -62,7 +62,7 @@ Phone_FindOpenSlot:
GetRemainingSpaceInPhoneList:
xor a
- ld [wBuffer1], a
+ ld [wRegisteredPhoneNumbers], a
ld hl, PermanentNumbers
.loop
ld a, [hli]
@@ -76,7 +76,7 @@ GetRemainingSpaceInPhoneList:
ld c, a
call _CheckCellNum
jr c, .permanent
- ld hl, wBuffer1
+ ld hl, wRegisteredPhoneNumbers
inc [hl]
.permanent
pop hl
@@ -87,7 +87,7 @@ GetRemainingSpaceInPhoneList:
.done
ld a, CONTACT_LIST_SIZE
- ld hl, wBuffer1
+ ld hl, wRegisteredPhoneNumbers
sub [hl]
ret
diff --git a/engine/pokemon/evolve.asm b/engine/pokemon/evolve.asm
index 3619d2da..db95a85b 100644
--- a/engine/pokemon/evolve.asm
+++ b/engine/pokemon/evolve.asm
@@ -509,7 +509,7 @@ FillMoves:
ld a, [wCurPartyLevel]
cp b
jp c, .done
- ld a, [wEvolutionOldSpecies]
+ ld a, [wSkipMovesBeforeLevelUp]
and a
jr z, .CheckMove
ld a, [wPrevPartyLevel]
diff --git a/engine/pokemon/learn.asm b/engine/pokemon/learn.asm
index 2c66dcd5..183551bc 100644
--- a/engine/pokemon/learn.asm
+++ b/engine/pokemon/learn.asm
@@ -142,7 +142,7 @@ ForgetMove:
call Textbox
hlcoord 5 + 2, 2 + 2
ld a, SCREEN_WIDTH * 2
- ld [wBuffer1], a
+ ld [wListMovesLineSpacing], a
predef ListMoves
; w2DMenuData
ld a, $4
diff --git a/engine/pokemon/mail.asm b/engine/pokemon/mail.asm
index 94006146..e3b88146 100644
--- a/engine/pokemon/mail.asm
+++ b/engine/pokemon/mail.asm
@@ -322,7 +322,8 @@ InitMail:
; initialize wMailboxCount from sMailboxCount
ld hl, wMailboxCount
- ld [hli], a ; now hl = wMailboxItems
+ ld [hli], a
+ assert wMailboxCount + 1 == wMailboxItems
and a
jr z, .done ; if no mail, we're done
diff --git a/engine/pokemon/mail_2.asm b/engine/pokemon/mail_2.asm
index b5168580..651a5e59 100644
--- a/engine/pokemon/mail_2.asm
+++ b/engine/pokemon/mail_2.asm
@@ -1,3 +1,17 @@
+; MailGFXPointers indexes
+; LoadMailPalettes.MailPals indexes (see gfx/mail/mail.pal)
+ const_def
+ const FLOWER_MAIL_INDEX ; 0
+ const SURF_MAIL_INDEX ; 1
+ const LITEBLUEMAIL_INDEX ; 2
+ const PORTRAITMAIL_INDEX ; 3
+ const LOVELY_MAIL_INDEX ; 4
+ const EON_MAIL_INDEX ; 5
+ const MORPH_MAIL_INDEX ; 6
+ const BLUESKY_MAIL_INDEX ; 7
+ const MUSIC_MAIL_INDEX ; 8
+ const MIRAGE_MAIL_INDEX ; 9
+
ReadPartyMonMail:
ld a, [wCurPartyMon]
ld hl, sPartyMail
@@ -16,7 +30,7 @@ ReadAnyMail:
call .LoadGFX
call EnableLCD
call WaitBGMap
- ld a, [wBuffer3]
+ ld a, [wCurMailIndex]
ld e, a
farcall LoadMailPalettes
call SetPalettes
@@ -53,13 +67,13 @@ ReadAnyMail:
call OpenSRAM
ld de, sPartyMon1MailAuthorID - sPartyMon1Mail
add hl, de
+ ld a, [hli] ; author id
+ ld [wCurMailAuthorID], a
ld a, [hli]
- ld [wBuffer1], a
- ld a, [hli]
- ld [wBuffer2], a
- ld a, [hli]
+ ld [wCurMailAuthorID + 1], a
+ ld a, [hli] ; species
ld [wCurPartySpecies], a
- ld b, [hl]
+ ld b, [hl] ; type
call CloseSRAM
ld hl, MailGFXPointers
ld c, 0
@@ -80,7 +94,7 @@ ReadAnyMail:
.got_pointer
ld a, c
- ld [wBuffer3], a
+ ld [wCurMailIndex], a
ld a, [hli]
ld h, [hl]
ld l, a
@@ -92,6 +106,7 @@ ReadAnyMail:
ret
MailGFXPointers:
+; entries correspond to *MAIL_INDEX constants
dbw FLOWER_MAIL, LoadFlowerMailGFX
dbw SURF_MAIL, LoadSurfMailGFX
dbw LITEBLUEMAIL, LoadLiteBlueMailGFX
@@ -102,7 +117,7 @@ MailGFXPointers:
dbw BLUESKY_MAIL, LoadBlueSkyMailGFX
dbw MUSIC_MAIL, LoadMusicMailGFX
dbw MIRAGE_MAIL, LoadMirageMailGFX
- db -1
+ db -1 ; end
LoadSurfMailGFX:
push bc
@@ -678,12 +693,12 @@ MailGFX_PlaceMessage:
ld a, [de]
and a
ret z
- ld a, [wBuffer3]
+ ld a, [wCurMailIndex]
hlcoord 8, 14
- cp $3 ; PORTRAITMAIL
+ cp PORTRAITMAIL_INDEX
jr z, .place_author
hlcoord 6, 14
- cp $6 ; MORPH_MAIL
+ cp MORPH_MAIL_INDEX
jr z, .place_author
hlcoord 5, 14
diff --git a/engine/pokemon/mon_menu.asm b/engine/pokemon/mon_menu.asm
index 98ebc18e..9fb292f7 100644
--- a/engine/pokemon/mon_menu.asm
+++ b/engine/pokemon/mon_menu.asm
@@ -1144,7 +1144,7 @@ SetUpMoveList:
ld bc, NUM_MOVES
call CopyBytes
ld a, SCREEN_WIDTH * 2
- ld [wBuffer1], a
+ ld [wListMovesLineSpacing], a
hlcoord 2, 3
predef ListMoves
hlcoord 10, 4
diff --git a/engine/pokemon/mon_stats.asm b/engine/pokemon/mon_stats.asm
index 3ed26a2d..d54f6c07 100644
--- a/engine/pokemon/mon_stats.asm
+++ b/engine/pokemon/mon_stats.asm
@@ -244,9 +244,9 @@ ListMovePP:
sub c
ld b, a
push hl
- ld a, [wBuffer1]
+ ld a, [wListMovesLineSpacing]
ld e, a
- ld d, $0
+ ld d, 0
ld a, $3e ; P
call .load_loop
ld a, b
@@ -301,7 +301,7 @@ ListMovePP:
lb bc, 1, 2
call PrintNum
pop hl
- ld a, [wBuffer1]
+ ld a, [wListMovesLineSpacing]
ld e, a
ld d, 0
add hl, de
@@ -341,7 +341,7 @@ Unused_PlaceEnemyHPLevel:
push hl
ld bc, -12
add hl, bc
- ld b, $0
+ ld b, 0
call DrawEnemyHP
pop hl
ld bc, 5
@@ -354,6 +354,7 @@ Unused_PlaceEnemyHPLevel:
ret
PlaceStatusString:
+; Return nz if the status is not OK
push de
inc de
inc de
@@ -368,7 +369,7 @@ PlaceStatusString:
ld de, FntString
call CopyStatusString
pop de
- ld a, $1
+ ld a, TRUE
and a
ret
@@ -407,7 +408,7 @@ PlaceNonFaintStatus:
.place
call CopyStatusString
- ld a, $1
+ ld a, TRUE
and a
.no_status
@@ -421,9 +422,9 @@ FrzString: db "FRZ@"
ParString: db "PAR@"
ListMoves:
-; List moves at hl, spaced every [wBuffer1] tiles.
+; List moves at hl, spaced every [wListMovesLineSpacing] tiles.
ld de, wListMoves_MoveIndicesBuffer
- ld b, $0
+ ld b, 0
.moves_loop
ld a, [de]
inc de
@@ -446,7 +447,7 @@ ListMoves:
inc b
pop hl
push bc
- ld a, [wBuffer1]
+ ld a, [wListMovesLineSpacing]
ld c, a
ld b, 0
add hl, bc
@@ -462,7 +463,7 @@ ListMoves:
.nonmove_loop
push af
ld [hl], "-"
- ld a, [wBuffer1]
+ ld a, [wListMovesLineSpacing]
ld c, a
ld b, 0
add hl, bc
diff --git a/engine/pokemon/mon_submenu.asm b/engine/pokemon/mon_submenu.asm
index bd20b7c1..9dc59231 100644
--- a/engine/pokemon/mon_submenu.asm
+++ b/engine/pokemon/mon_submenu.asm
@@ -25,8 +25,8 @@ MonSubmenu:
db 1 ; default option
.GetTopCoord:
-; TopCoord = 1 + BottomCoord - 2 * (NumSubmenuItems + 1)
- ld a, [wBuffer1]
+; [wMenuBorderTopCoord] = 1 + [wMenuBorderBottomCoord] - 2 * ([wMonSubmenuCount] + 1)
+ ld a, [wMonSubmenuCount]
inc a
add a
ld b, a
@@ -41,7 +41,7 @@ MonMenuLoop:
.loop
ld a, MENU_UNUSED_3 | MENU_BACKUP_TILES_2 ; flags
ld [wMenuDataFlags], a
- ld a, [wBuffer1] ; items
+ ld a, [wMonSubmenuCount]
ld [wMenuDataItems], a
call InitVerticalMenuCursor
ld hl, w2DMenuFlags1
@@ -65,7 +65,7 @@ MonMenuLoop:
dec a
ld c, a
ld b, 0
- ld hl, wBuffer2
+ ld hl, wMonSubmenuItems
add hl, bc
ld a, [hl]
ret
@@ -74,7 +74,7 @@ PopulateMonMenu:
call MenuBoxCoord2Tile
ld bc, 2 * SCREEN_WIDTH + 2
add hl, bc
- ld de, wBuffer2
+ ld de, wMonSubmenuItems
.loop
ld a, [de]
inc de
@@ -170,7 +170,7 @@ GetMonSubmenuItems:
call AddMonMenuItem
.skip2
- ld a, [wBuffer1]
+ ld a, [wMonSubmenuCount]
cp NUM_MONMENU_ITEMS
jr z, .ok2
ld a, MONMENUITEM_CANCEL
@@ -212,17 +212,17 @@ IsFieldMove:
ResetMonSubmenu:
xor a
- ld [wBuffer1], a
- ld hl, wBuffer2
+ ld [wMonSubmenuCount], a
+ ld hl, wMonSubmenuItems
ld bc, NUM_MONMENU_ITEMS + 1
call ByteFill
ret
TerminateMonSubmenu:
- ld a, [wBuffer1]
+ ld a, [wMonSubmenuCount]
ld e, a
ld d, 0
- ld hl, wBuffer2
+ ld hl, wMonSubmenuItems
add hl, de
ld [hl], -1
ret
@@ -231,12 +231,12 @@ AddMonMenuItem:
push hl
push de
push af
- ld a, [wBuffer1]
+ ld a, [wMonSubmenuCount]
ld e, a
inc a
- ld [wBuffer1], a
+ ld [wMonSubmenuCount], a
ld d, 0
- ld hl, wBuffer2
+ ld hl, wMonSubmenuItems
add hl, de
pop af
ld [hl], a
diff --git a/engine/pokemon/move_mon.asm b/engine/pokemon/move_mon.asm
index fe2a0886..dd4f545d 100644
--- a/engine/pokemon/move_mon.asm
+++ b/engine/pokemon/move_mon.asm
@@ -132,7 +132,7 @@ rept NUM_MOVES - 1
ld [hli], a
endr
ld [hl], a
- ld [wEvolutionOldSpecies], a
+ ld [wSkipMovesBeforeLevelUp], a
predef FillMoves
.next
@@ -876,8 +876,8 @@ RetrieveBreedmon:
call AddNTimes
ld d, h
ld e, l
- ld a, $1
- ld [wBuffer1], a
+ ld a, TRUE
+ ld [wSkipMovesBeforeLevelUp], a
predef FillMoves
ld a, [wPartyCount]
dec a
diff --git a/engine/pokemon/stats_screen.asm b/engine/pokemon/stats_screen.asm
index b53a2622..e7c7329b 100644
--- a/engine/pokemon/stats_screen.asm
+++ b/engine/pokemon/stats_screen.asm
@@ -431,7 +431,7 @@ LoadPinkPage:
call PrintNum
; level-up graphics and strings
call .CalcExpToNextLevel
- ld de, wBuffer1
+ ld de, wExpToNextLevel
hlcoord 13, 13
lb bc, 3, 7
call PrintNum
@@ -475,18 +475,18 @@ LoadPinkPage:
ldh a, [hQuotient + 3]
sub [hl]
dec hl
- ld [wBuffer3], a
+ ld [wExpToNextLevel + 2], a
ldh a, [hQuotient + 2]
sbc [hl]
dec hl
- ld [wBuffer2], a
+ ld [wExpToNextLevel + 1], a
ldh a, [hQuotient + 1]
sbc [hl]
- ld [wBuffer1], a
+ ld [wExpToNextLevel], a
ret
.AlreadyAtMaxLevel:
- ld hl, wBuffer1
+ ld hl, wExpToNextLevel
xor a
ld [hli], a
ld [hli], a
@@ -588,11 +588,11 @@ LoadGreenPage:
call PlaceString
hlcoord 8, 10
ld a, SCREEN_WIDTH * 2
- ld [wBuffer1], a
+ ld [wListMovesLineSpacing], a
call ListMoves
hlcoord 12, 11
ld a, SCREEN_WIDTH * 2
- ld [wBuffer1], a
+ ld [wListMovesLineSpacing], a
call ListMovePP
; Load palettes / place frontpic
diff --git a/engine/pokemon/switchpartymons.asm b/engine/pokemon/switchpartymons.asm
index 2c00b34b..512332fc 100644
--- a/engine/pokemon/switchpartymons.asm
+++ b/engine/pokemon/switchpartymons.asm
@@ -1,17 +1,17 @@
_SwitchPartyMons:
ld a, [wSwitchMon]
dec a
- ld [wBuffer3], a
+ ld [wSwitchMonFrom], a
ld b, a
ld a, [wMenuCursorY]
dec a
- ld [wBuffer2], a
+ ld [wSwitchMonTo], a
cp b
jr z, .skip
call .SwapMonAndMail
- ld a, [wBuffer3]
+ ld a, [wSwitchMonFrom]
call .ClearSprite
- ld a, [wBuffer2]
+ ld a, [wSwitchMonTo]
call .ClearSprite
.skip
ret
@@ -44,13 +44,13 @@ _SwitchPartyMons:
push de
push bc
ld bc, wPartySpecies
- ld a, [wBuffer2]
+ ld a, [wSwitchMonTo]
ld l, a
ld h, $0
add hl, bc
ld d, h
ld e, l
- ld a, [wBuffer3]
+ ld a, [wSwitchMonFrom]
ld l, a
ld h, $0
add hl, bc
@@ -60,7 +60,7 @@ _SwitchPartyMons:
ld [hl], a
pop af
ld [de], a
- ld a, [wBuffer2]
+ ld a, [wSwitchMonTo]
ld hl, wPartyMon1Species
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
@@ -68,7 +68,7 @@ _SwitchPartyMons:
ld de, wSwitchMonBuffer
ld bc, PARTYMON_STRUCT_LENGTH
call CopyBytes
- ld a, [wBuffer3]
+ ld a, [wSwitchMonFrom]
ld hl, wPartyMon1
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
@@ -80,12 +80,12 @@ _SwitchPartyMons:
ld hl, wSwitchMonBuffer
ld bc, PARTYMON_STRUCT_LENGTH
call CopyBytes
- ld a, [wBuffer2]
+ ld a, [wSwitchMonTo]
ld hl, wPartyMonOT
call SkipNames
push hl
call .CopyNameToSwitchMonBuffer
- ld a, [wBuffer3]
+ ld a, [wSwitchMonFrom]
ld hl, wPartyMonOT
call SkipNames
pop de
@@ -95,12 +95,12 @@ _SwitchPartyMons:
ld hl, wSwitchMonBuffer
call .CopyName
ld hl, wPartyMonNicknames
- ld a, [wBuffer2]
+ ld a, [wSwitchMonTo]
call SkipNames
push hl
call .CopyNameToSwitchMonBuffer
ld hl, wPartyMonNicknames
- ld a, [wBuffer3]
+ ld a, [wSwitchMonFrom]
call SkipNames
pop de
push hl
@@ -109,7 +109,7 @@ _SwitchPartyMons:
ld hl, wSwitchMonBuffer
call .CopyName
ld hl, sPartyMail
- ld a, [wBuffer2]
+ ld a, [wSwitchMonTo]
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
push hl
@@ -119,7 +119,7 @@ _SwitchPartyMons:
call OpenSRAM
call CopyBytes
ld hl, sPartyMail
- ld a, [wBuffer3]
+ ld a, [wSwitchMonFrom]
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
pop de
diff --git a/engine/rtc/restart_clock.asm b/engine/rtc/restart_clock.asm
index 15b1fd13..65c4fbdb 100644
--- a/engine/rtc/restart_clock.asm
+++ b/engine/rtc/restart_clock.asm
@@ -1,3 +1,10 @@
+; RestartClock_GetWraparoundTime.WrapAroundTimes indexes
+ const_def 1
+ const RESTART_CLOCK_DAY
+ const RESTART_CLOCK_HOUR
+ const RESTART_CLOCK_MIN
+NUM_RESTART_CLOCK_DIVISIONS EQU const_value - 1
+
RestartClock_GetWraparoundTime:
push hl
dec a
@@ -18,14 +25,15 @@ endr
ret
.WrapAroundTimes:
- dw wBuffer4
- db 7, 4
-
- dw wBuffer5
- db 24, 12
-
- dw wBuffer6
- db 60, 15
+; entries correspond to RESTART_CLOCK_* constants
+wraparound_time: MACRO
+ dw \1 ; value pointer
+ db \2 ; maximum value
+ db \3 ; up/down arrow x coord (pairs with wRestartClockUpArrowYCoord)
+ENDM
+ wraparound_time wRestartClockDay, 7, 4
+ wraparound_time wRestartClockHour, 24, 12
+ wraparound_time wRestartClockMin, 60, 15
RestartClock:
; If we're here, we had an RTC overflow.
@@ -56,18 +64,18 @@ RestartClock:
text_end
.SetClock:
- ld a, 1
- ld [wBuffer1], a ; which digit
- ld [wBuffer2], a
+ ld a, RESTART_CLOCK_DAY
+ ld [wRestartClockCurDivision], a
+ ld [wRestartClockPrevDivision], a
ld a, 8
- ld [wBuffer3], a
+ ld [wRestartClockUpArrowYCoord], a
call UpdateTime
call GetWeekday
- ld [wBuffer4], a
+ ld [wRestartClockDay], a
ldh a, [hHours]
- ld [wBuffer5], a
+ ld [wRestartClockHour], a
ldh a, [hMinutes]
- ld [wBuffer6], a
+ ld [wRestartClockMin], a
.loop
call .joy_loop
@@ -79,11 +87,11 @@ RestartClock:
call PrintText
call YesNoBox
jr c, .cancel
- ld a, [wBuffer4]
+ ld a, [wRestartClockDay]
ld [wStringBuffer2], a
- ld a, [wBuffer5]
+ ld a, [wRestartClockHour]
ld [wStringBuffer2 + 1], a
- ld a, [wBuffer6]
+ ld a, [wRestartClockMin]
ld [wStringBuffer2 + 2], a
xor a
ld [wStringBuffer2 + 3], a
@@ -128,29 +136,29 @@ RestartClock:
jr .joy_loop
.press_A
- ld a, $0
+ ld a, FALSE
scf
ret
.press_B
- ld a, $1
+ ld a, TRUE
scf
ret
.pressed_up
- ld a, [wBuffer1]
+ ld a, [wRestartClockCurDivision]
call RestartClock_GetWraparoundTime
ld a, [de]
inc a
ld [de], a
cp b
jr c, .done_scroll
- ld a, $0
+ ld a, 0
ld [de], a
jr .done_scroll
.pressed_down
- ld a, [wBuffer1]
+ ld a, [wRestartClockCurDivision]
call RestartClock_GetWraparoundTime
ld a, [de]
dec a
@@ -163,22 +171,22 @@ RestartClock:
jr .done_scroll
.pressed_left
- ld hl, wBuffer1
+ ld hl, wRestartClockCurDivision
dec [hl]
jr nz, .done_scroll
- ld [hl], $3
+ ld [hl], RESTART_CLOCK_MIN
jr .done_scroll
.pressed_right
- ld hl, wBuffer1
+ ld hl, wRestartClockCurDivision
inc [hl]
ld a, [hl]
- cp $4
+ cp NUM_RESTART_CLOCK_DIVISIONS + 1
jr c, .done_scroll
- ld [hl], $1
+ ld [hl], RESTART_CLOCK_DAY
.done_scroll
- xor a
+ xor a ; FALSE
ret
.PrintTime:
@@ -187,27 +195,27 @@ RestartClock:
ld c, 18
call Textbox
decoord 1, 8
- ld a, [wBuffer4]
+ ld a, [wRestartClockDay]
ld b, a
farcall PrintDayOfWeek
- ld a, [wBuffer5]
+ ld a, [wRestartClockHour]
ld b, a
- ld a, [wBuffer6]
+ ld a, [wRestartClockMin]
ld c, a
decoord 11, 8
farcall PrintHoursMins
- ld a, [wBuffer2]
+ ld a, [wRestartClockPrevDivision]
lb de, " ", " "
call .PlaceChars
- ld a, [wBuffer1]
+ ld a, [wRestartClockCurDivision]
lb de, "▲", "▼"
call .PlaceChars
- ld a, [wBuffer1]
- ld [wBuffer2], a
+ ld a, [wRestartClockCurDivision]
+ ld [wRestartClockPrevDivision], a
ret
.UnusedPlaceCharsFragment: ; unreferenced
- ld a, [wBuffer3]
+ ld a, [wRestartClockUpArrowYCoord]
ld b, a
call Coord2Tile
ret
@@ -215,7 +223,7 @@ RestartClock:
.PlaceChars:
push de
call RestartClock_GetWraparoundTime
- ld a, [wBuffer3]
+ ld a, [wRestartClockUpArrowYCoord]
dec a
ld b, a
call Coord2Tile
diff --git a/gfx/mail/mail.pal b/gfx/mail/mail.pal
index 4096ffae..7b27c67c 100644
--- a/gfx/mail/mail.pal
+++ b/gfx/mail/mail.pal
@@ -1,49 +1,10 @@
- RGB 20, 31, 11
- RGB 31, 19, 00
- RGB 31, 10, 09
- RGB 00, 00, 00
-
- RGB 15, 20, 31
- RGB 30, 26, 00
- RGB 31, 12, 00
- RGB 00, 00, 00
-
- RGB 24, 17, 31
- RGB 30, 26, 00
- RGB 08, 11, 31
- RGB 00, 00, 00
-
- RGB 31, 25, 17
- RGB 31, 18, 04
- RGB 28, 12, 05
- RGB 00, 00, 00
-
- RGB 19, 26, 31
- RGB 31, 05, 08
- RGB 31, 09, 31
- RGB 00, 00, 00
-
- RGB 31, 19, 28
- RGB 31, 21, 00
- RGB 12, 22, 00
- RGB 00, 00, 00
-
- RGB 19, 17, 23
- RGB 30, 26, 00
- RGB 31, 12, 00
- RGB 00, 00, 00
-
- RGB 07, 26, 31
- RGB 26, 26, 27
- RGB 31, 11, 11
- RGB 00, 00, 00
-
- RGB 21, 31, 21
- RGB 30, 26, 00
- RGB 31, 12, 00
- RGB 00, 00, 00
-
- RGB 07, 26, 31
- RGB 31, 31, 00
- RGB 00, 21, 00
- RGB 00, 00, 00
+ RGB 20,31,11, 31,19,00, 31,10,09, 00,00,00 ; FLOWER_MAIL
+ RGB 15,20,31, 30,26,00, 31,12,00, 00,00,00 ; SURF_MAIL
+ RGB 24,17,31, 30,26,00, 08,11,31, 00,00,00 ; LITEBLUEMAIL
+ RGB 31,25,17, 31,18,04, 28,12,05, 00,00,00 ; PORTRAITMAIL
+ RGB 19,26,31, 31,05,08, 31,09,31, 00,00,00 ; LOVELY_MAIL
+ RGB 31,19,28, 31,21,00, 12,22,00, 00,00,00 ; EON_MAIL
+ RGB 19,17,23, 30,26,00, 31,12,00, 00,00,00 ; MORPH_MAIL
+ RGB 07,26,31, 26,26,27, 31,11,11, 00,00,00 ; BLUESKY_MAIL
+ RGB 21,31,21, 30,26,00, 31,12,00, 00,00,00 ; MUSIC_MAIL
+ RGB 07,26,31, 31,31,00, 00,21,00, 00,00,00 ; MIRAGE_MAIL
diff --git a/wram.asm b/wram.asm
index 1d801b4f..1a2f7ebb 100644
--- a/wram.asm
+++ b/wram.asm
@@ -710,7 +710,7 @@ wBattleAnimTempPalette:: db
ENDU
UNION
- ds $32
+ ds 50
wBattleAnimEnd::
NEXTU
@@ -1897,7 +1897,7 @@ wEvolvableFlags:: flag_array PARTY_LENGTH
wForceEvolution:: db
UNION
-; general-purpose buffers
+; unidentified
wBuffer1:: db
wBuffer2:: db
wBuffer3:: db
@@ -1918,11 +1918,76 @@ wCurHPAnimLowHP:: db
wCurHPAnimHighHP:: db
NEXTU
+; battle AI
+wEnemyAIMoveScores:: ds NUM_MOVES
+
+NEXTU
+; battle HUD
+wBattleHUDTiles:: ds PARTY_LENGTH
+
+NEXTU
; evolution data
wEvolutionOldSpecies:: db
wEvolutionNewSpecies:: db
-wEvolutionPicOffset:: db
-wEvolutionCanceled:: db
+wEvolutionPicOffset:: db
+wEvolutionCanceled:: db
+
+NEXTU
+; experience
+wExpToNextLevel:: ds 3
+
+NEXTU
+; lucky number show
+wMonIDDigitsBuffer:: ds 5
+
+NEXTU
+; mon submenu
+wMonSubmenuCount:: db
+wMonSubmenuItems:: ds NUM_MONMENU_ITEMS + 1
+
+NEXTU
+; heal machine anim
+wHealMachineAnimType:: db
+wHealMachineTempOBP1:: db
+wHealMachineAnimState:: db
+
+NEXTU
+; decorations
+wCurDecoration:: db
+wSelectedDecorationSide:: db
+wSelectedDecoration:: db
+wOtherDecoration:: db
+wChangedDecorations:: db
+wCurDecorationCategory:: db
+
+NEXTU
+; withdraw/deposit items
+wPCItemQuantityChangeBuffer:: db
+wPCItemQuantity:: db
+
+NEXTU
+; mail
+wCurMailAuthorID:: dw
+wCurMailIndex:: db
+
+NEXTU
+; kurt
+wKurtApricornCount:: db
+wKurtApricornItems:: ds 10
+
+NEXTU
+; tree mons
+wTreeMonCoordScore:: db
+wTreeMonOTIDScore:: db
+
+NEXTU
+; restart clock
+wRestartClockCurDivision:: db
+wRestartClockPrevDivision:: db
+wRestartClockUpArrowYCoord:: db
+wRestartClockDay:: db
+wRestartClockHour:: db
+wRestartClockMin:: db
NEXTU
; link
@@ -1931,12 +1996,20 @@ wLinkBattleRNPreamble:: ds SERIAL_RN_PREAMBLE_LENGTH
wLinkBattleRNs:: ds SERIAL_RNS_LENGTH
NEXTU
-; miscellaneous
-wMagikarpLength:: dw
-wSelectedDecoration:: db
-wOtherDecoration:: db
- ds 3
+; miscellaneous bytes
+wSkipMovesBeforeLevelUp::
+wRegisteredPhoneNumbers::
+wListMovesLineSpacing:: db
+wSwitchMonTo:: db
+wSwitchMonFrom:: db
+ ds 4
wCurEnemyItem:: db
+
+NEXTU
+; miscellaneous words
+wBuySellItemPrice::
+wTempMysteryGiftTimer::
+wMagikarpLength:: dw
ENDU
wTempEnemyMonSpecies:: db