summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authordannye <corrnondacqb@yahoo.com>2015-08-10 00:00:12 -0500
committerdannye <corrnondacqb@yahoo.com>2015-08-10 00:00:12 -0500
commit66bc517605860c9f716a176ed467d34097985895 (patch)
tree4c126cbb3bbdb2b0a236375c2140e7a6c25260a6 /engine
parent8a6d46f3d9ba4fb6939eb9ea9949f47aa8608d4a (diff)
parent2b018159997e3b580efd114ff4e3548a0de3cbc5 (diff)
Merge branch 'master' of https://github.com/YamaArashi/pokered
Diffstat (limited to 'engine')
-rwxr-xr-xengine/battle/animations.asm20
-rwxr-xr-xengine/battle/bank_e_misc.asm4
-rw-r--r--engine/battle/common_text.asm4
-rwxr-xr-xengine/battle/core.asm66
-rwxr-xr-xengine/battle/end_of_battle.asm2
-rw-r--r--engine/battle/experience.asm4
-rw-r--r--engine/battle/trainer_ai.asm4
-rwxr-xr-xengine/cable_club.asm20
-rwxr-xr-xengine/evolution.asm6
-rwxr-xr-xengine/evos_moves.asm10
-rwxr-xr-xengine/hall_of_fame.asm8
-rwxr-xr-xengine/hidden_object_functions14.asm2
-rwxr-xr-xengine/hidden_object_functions7.asm10
-rwxr-xr-xengine/intro.asm6
-rwxr-xr-xengine/items/items.asm51
-rwxr-xr-xengine/menu/main_menu.asm4
-rwxr-xr-xengine/menu/pokedex.asm8
-rwxr-xr-xengine/menu/status_screen.asm10
-rwxr-xr-xengine/oak_speech.asm10
-rwxr-xr-xengine/overworld/elevator.asm2
-rwxr-xr-xengine/overworld/healing_machine.asm40
-rwxr-xr-xengine/overworld/npc_movement.asm12
-rwxr-xr-xengine/overworld/oaks_aide.asm34
-rwxr-xr-xengine/overworld/pokecenter.asm12
-rwxr-xr-xengine/pokedex_rating.asm30
-rwxr-xr-xengine/slot_machine.asm4
-rwxr-xr-xengine/titlescreen.asm6
27 files changed, 196 insertions, 193 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm
index 424190d3..1bd48988 100755
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -772,7 +772,7 @@ DoBallTossSpecialEffects: ; 78f3e (1e:4f3e)
dec b
jr nz,.loop
ld a,%00001000
- ld [$ff10],a ; Channel 1 sweep register
+ ld [rNR10],a ; Channel 1 sweep register
ret
.isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame
ld a,[W_SUBANIMCOUNTER]
@@ -2335,19 +2335,19 @@ GetMoveSound: ; 7986f (1e:586f)
call GetCryData
ld b,a
pop hl
- ld a,[wc0f1]
+ ld a,[wFrequencyModifier]
add [hl]
- ld [wc0f1],a
+ ld [wFrequencyModifier],a
inc hl
- ld a,[wc0f2]
+ ld a,[wTempoModifier]
add [hl]
- ld [wc0f2],a
+ ld [wTempoModifier],a
jr .done
.NotCryMove
ld a,[hli]
- ld [wc0f1],a
+ ld [wFrequencyModifier],a
ld a,[hli]
- ld [wc0f2],a
+ ld [wTempoModifier],a
.done
ld a,b
ret
@@ -2956,7 +2956,7 @@ TossBallAnimation: ; 79e16 (1e:5e16)
ld a,[W_ISINBATTLE]
cp a,2
jr z,.BlockBall ; if in trainer battle, play different animation
- ld a,[wd11e]
+ ld a,[wPokeBallAnimData]
ld b,a
; upper nybble: how many animations (from PokeBallAnimations) to play
@@ -3029,8 +3029,8 @@ PlayApplyingAttackSound: ; 79e6a (1e:5e6a)
ld b, $1
ld c, SFX_NOT_VERY_EFFECTIVE
.playSound
- ld [wc0f1], a
+ ld [wFrequencyModifier], a
ld a, b
- ld [wc0f2], a
+ ld [wTempoModifier], a
ld a, c
jp PlaySound
diff --git a/engine/battle/bank_e_misc.asm b/engine/battle/bank_e_misc.asm
index f47087d8..dc766f23 100755
--- a/engine/battle/bank_e_misc.asm
+++ b/engine/battle/bank_e_misc.asm
@@ -92,9 +92,9 @@ InitList: ; 39bd5 (e:5bd5)
ld a, h
ld [wListPointer + 1], a
ld a, e
- ld [wcf8d], a
+ ld [wUnusedCF8D], a
ld a, d
- ld [wcf8e], a
+ ld [wUnusedCF8D + 1], a
ld bc, ItemPrices
ld a, c
ld [wItemPrices], a
diff --git a/engine/battle/common_text.asm b/engine/battle/common_text.asm
index a00e9d59..a1afcb75 100644
--- a/engine/battle/common_text.asm
+++ b/engine/battle/common_text.asm
@@ -61,9 +61,9 @@ PrintBeginningBattleText: ; 58d99 (16:4d99)
.playSFX
xor a
- ld [wc0f1], a
+ ld [wFrequencyModifier], a
ld a, $80
- ld [wc0f2], a
+ ld [wTempoModifier], a
ld a, SFX_SILPH_SCOPE
call PlaySound
jp WaitForSoundToFinish
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index ee93023f..418447ba 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -834,8 +834,17 @@ FaintEnemyPokemon: ; 0x3c567
.wild
ld hl, W_PLAYERBATTSTATUS1
res AttackingMultipleTimes, [hl]
- xor a
- ld [wPlayerNumHits], a
+; Bug. This only zeroes the high byte of the player's accumulated damage,
+; setting the accumulated damage to itself mod 256 instead of 0 as was probably
+; intended. That alone is problematic, but this mistake has another more severe
+; effect. This function's counterpart for when the player mon faints,
+; RemoveFaintedPlayerMon, zeroes both the high byte and the low byte. In a link
+; battle, the other player's Game Boy will call that function in response to
+; the enemy mon (the player mon from the other side's perspective) fainting,
+; and the states of the two Game Boys will go out of sync unless the damage
+; was congruent to 0 modulo 256.
+ xor a
+ ld [wPlayerBideAccumulatedDamage], a
ld hl, wEnemyStatsToDouble ; clear enemy statuses
ld [hli], a
ld [hli], a
@@ -858,12 +867,12 @@ FaintEnemyPokemon: ; 0x3c567
dec a
jr z, .wild_win
xor a
- ld [wc0f1], a
- ld [wc0f2], a
+ ld [wFrequencyModifier], a
+ ld [wTempoModifier], a
ld a, SFX_FAINT_FALL
call PlaySoundWaitForCurrent
.sfxwait
- ld a, [wc02a]
+ ld a, [wChannelSoundIDs + CH4]
cp SFX_FAINT_FALL
jr z, .sfxwait
ld a, SFX_FAINT_THUD
@@ -943,7 +952,7 @@ EnemyMonFaintedText: ; 0x3c63e
EndLowHealthAlarm: ; 3c643 (f:4643)
xor a
ld [wLowHealthAlarm], a ;disable low health alarm
- ld [wc02a], a
+ ld [wChannelSoundIDs + CH4], a
inc a
ld [wccf6], a
ret
@@ -1036,7 +1045,7 @@ TrainerDefeatedText: ; 3c6e9 (f:46e9)
PlayBattleVictoryMusic: ; 3c6ee (f:46ee)
push af
ld a, $ff
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySoundWaitForCurrent
ld c, BANK(Music_DefeatedTrainer)
pop af
@@ -1092,8 +1101,7 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741)
ld [wLowHealthAlarm], a ;disable low health alarm
call WaitForSoundToFinish
.skipWaitForSound
-; bug? if the player mon faints while the enemy mon is using bide,
-; the accumulated damage is overwritten. xxx what values can [wLowHealthAlarm] have here?
+; a is 0, so this zeroes the enemy's accumulated damage.
ld hl, wEnemyBideAccumulatedDamage
ld [hli], a
ld [hl], a
@@ -1936,7 +1944,7 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60)
ld [hl], $0
ret z
xor a
- ld [wc02a], a
+ ld [wChannelSoundIDs + CH4], a
ret
.asm_3cde6
ld hl, wLowHealthAlarm
@@ -2954,7 +2962,7 @@ PrintMenuItem: ; 3d4b6 (f:54b6)
lb bc, 1, 2
call PrintNumber
coord hl, 8, 11
- ld de, wd11e
+ ld de, wMaxPP
lb bc, 1, 2
call PrintNumber
call GetCurrentMove
@@ -5279,7 +5287,7 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
ld d,a ; d = type 1 of defender
ld e,[hl] ; e = type 2 of defender
ld a,[W_PLAYERMOVETYPE]
- ld [wd11e],a
+ ld [wMoveType],a
ld a,[H_WHOSETURN]
and a
jr z,.next
@@ -5293,9 +5301,9 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
ld d,a ; d = type 1 of defender
ld e,[hl] ; e = type 2 of defender
ld a,[W_ENEMYMOVETYPE]
- ld [wd11e],a
+ ld [wMoveType],a
.next
- ld a,[wd11e] ; move type
+ ld a,[wMoveType]
cp b ; does the move type match type 1 of the attacker?
jr z,.sameTypeAttackBonus
cp c ; does the move type match type 2 of the attacker?
@@ -5320,8 +5328,8 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
ld hl,wDamageMultipliers
set 7,[hl]
.skipSameTypeAttackBonus
- ld a,[wd11e]
- ld b,a ; b = move type
+ ld a,[wMoveType]
+ ld b,a
ld hl,TypeEffects
.loop
ld a,[hli] ; a = "attacking type" of the current type pair
@@ -5384,29 +5392,29 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
; function to tell how effective the type of an enemy attack is on the player's current pokemon
; this doesn't take into account the effects that dual types can have
; (e.g. 4x weakness / resistance, weaknesses and resistances canceling)
-; the result is stored in [wd11e]
+; the result is stored in [wTypeEffectiveness]
; ($05 is not very effective, $10 is neutral, $14 is super effective)
; as far is can tell, this is only used once in some AI code to help decide which move to use
AIGetTypeEffectiveness: ; 3e449 (f:6449)
ld a,[W_ENEMYMOVETYPE]
- ld d,a ; d = type of enemy move
+ ld d,a ; d = type of enemy move
ld hl,wBattleMonType
- ld b,[hl] ; b = type 1 of player's pokemon
+ ld b,[hl] ; b = type 1 of player's pokemon
inc hl
- ld c,[hl] ; c = type 2 of player's pokemon
+ ld c,[hl] ; c = type 2 of player's pokemon
ld a,$10
- ld [wd11e],a ; initialize [wd11e] to neutral effectiveness
+ ld [wTypeEffectiveness],a ; initialize to neutral effectiveness
ld hl,TypeEffects
.loop
ld a,[hli]
cp a,$ff
ret z
- cp d ; match the type of the move
+ cp d ; match the type of the move
jr nz,.nextTypePair1
ld a,[hli]
- cp b ; match with type 1 of pokemon
+ cp b ; match with type 1 of pokemon
jr z,.done
- cp c ; or match with type 2 of pokemon
+ cp c ; or match with type 2 of pokemon
jr z,.done
jr .nextTypePair2
.nextTypePair1
@@ -5416,7 +5424,7 @@ AIGetTypeEffectiveness: ; 3e449 (f:6449)
jr .loop
.done
ld a,[hl]
- ld [wd11e],a ; store damage multiplier
+ ld [wTypeEffectiveness],a ; store damage multiplier
ret
INCLUDE "data/type_effects.asm"
@@ -6569,12 +6577,12 @@ CalculateModifiedStats: ; 3ed99 (f:6d99)
CalculateModifiedStat: ; 3eda5 (f:6da5)
push bc
push bc
- ld a, [wd11e]
+ ld a, [wCalculateWhoseStats]
and a
ld a, c
ld hl, wBattleMonAttack
ld de, wPlayerMonUnmodifiedAttack
- ld bc, wPlayerMonAttackMod
+ ld bc, wPlayerMonStatMods
jr z, .next
ld hl, wEnemyMonAttack
ld de, wEnemyMonUnmodifiedAttack
@@ -6985,8 +6993,8 @@ _LoadTrainerPic: ; 3f04b (f:704b)
; unreferenced
ResetCryModifiers: ; 3f069 (f:7069)
xor a
- ld [wc0f1], a
- ld [wc0f2], a
+ ld [wFrequencyModifier], a
+ ld [wTempoModifier], a
jp PlaySound
; animates the mon "growing" out of the pokeball
diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm
index c642d206..f1de313c 100755
--- a/engine/battle/end_of_battle.asm
+++ b/engine/battle/end_of_battle.asm
@@ -46,7 +46,7 @@ EndOfBattle: ; 137aa (4:77aa)
.resetVariables
xor a
ld [wLowHealthAlarm], a ;disable low health alarm
- ld [wc02a], a
+ ld [wChannelSoundIDs + CH4], a
ld [W_ISINBATTLE], a
ld [W_BATTLETYPE], a
ld [W_MOVEMISSED], a
diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm
index edee81b1..433588e3 100644
--- a/engine/battle/experience.asm
+++ b/engine/battle/experience.asm
@@ -231,8 +231,8 @@ GainExperience: ; 5524f (15:524f)
ld bc, 1 + NUM_STATS * 2
call CopyData
.recalcStatChanges
- xor a
- ld [wd11e], a
+ xor a ; battle mon
+ ld [wCalculateWhoseStats], a
callab CalculateModifiedStats
callab ApplyBurnAndParalysisPenaltiesToPlayer
callab ApplyBadgeStatBoosts
diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm
index 08205048..afb04216 100644
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -191,7 +191,7 @@ AIMoveChoiceModification2: ; 397e7 (e:57e7)
AIMoveChoiceModification3: ; 39817 (e:5817)
ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset)
ld de, wEnemyMonMoves ; enemy moves
- ld b, $5
+ ld b, NUM_MOVES + 1
.nextMove
dec b
ret z ; processed all 4 moves
@@ -208,7 +208,7 @@ AIMoveChoiceModification3: ; 39817 (e:5817)
pop de
pop bc
pop hl
- ld a, [wd11e]
+ ld a, [wTypeEffectiveness]
cp $10
jr z, .nextMove
jr c, .notEffectiveMove
diff --git a/engine/cable_club.asm b/engine/cable_club.asm
index 88e85e8b..31eee481 100755
--- a/engine/cable_club.asm
+++ b/engine/cable_club.asm
@@ -256,9 +256,9 @@ CableClub_DoBattleOrTradeAgain: ; 5345
dec c
jr nz, .unpatchEnemyMonsLoop
ld a, wEnemyMonOT % $100
- ld [wcf8d], a
+ ld [wUnusedCF8D], a
ld a, wEnemyMonOT / $100
- ld [wcf8e], a
+ ld [wUnusedCF8D + 1], a
xor a
ld [wTradeCenterPointerTableIndex], a
ld a, $ff
@@ -824,12 +824,12 @@ TradeCenter_Trade:
add hl, bc
ld a, [hl]
ld [wTradedEnemyMonSpecies], a
- ld a, $a
- ld [wMusicHeaderPointer], a
+ ld a, 10
+ ld [wAudioFadeOutControl], a
ld a, $2
- ld [wc0f0], a
+ ld [wAudioSavedROMBank], a
ld a, MUSIC_SAFARI_ZONE
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld c, 100
call DelayFrames
@@ -915,12 +915,12 @@ CableClub_Run: ; 5a5f (1:5a5f)
inc a ; LINK_STATE_IN_CABLE_CLUB
ld [wLinkState], a
ld [$ffb5], a
- ld a, $a
- ld [wMusicHeaderPointer], a
+ ld a, 10
+ ld [wAudioFadeOutControl], a
ld a, BANK(Music_Celadon)
- ld [wc0f0], a
+ ld [wAudioSavedROMBank], a
ld a, MUSIC_CELADON
- ld [wc0ee], a
+ ld [wNewSoundID], a
jp PlaySound
EmptyFunc3: ; 5aaf (1:5aaf)
diff --git a/engine/evolution.asm b/engine/evolution.asm
index 720e77cd..8fbf568a 100755
--- a/engine/evolution.asm
+++ b/engine/evolution.asm
@@ -8,9 +8,9 @@ EvolveMon: ; 7bde9 (1e:7de9)
push af
xor a
ld [wLowHealthAlarm], a
- ld [wc02a], a
+ ld [wChannelSoundIDs + CH4], a
dec a
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
@@ -68,7 +68,7 @@ EvolveMon: ; 7bde9 (1e:7de9)
.done
ld [wcf1d], a
ld a, $ff
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld a, [wcf1d]
call PlayCry
diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm
index 4e55cdea..e2b1172a 100755
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -166,7 +166,7 @@ Evolution_PartyMonLoop: ; loop over party mons
ld de, W_MONHEADER
call CopyData
ld a, [wd0b5]
- ld [W_MONHDEXNUM], a
+ ld [W_MONHINDEX], a
pop af
ld [wd11e], a
ld hl, wLoadedMonHPExp - 1
@@ -257,12 +257,12 @@ Evolution_PartyMonLoop: ; loop over party mons
call nz, PlayDefaultMusic
ret
-; checks if the evolved mon's name is different from the standard name (i.e. it has a nickname)
-; if so, rename it to is evolved form's standard name
RenameEvolvedMon: ; 3aef7 (e:6ef7)
+; Renames the mon to its new, evolved form's standard name unless it had a
+; nickname, in which case the nickname is kept.
ld a, [wd0b5]
push af
- ld a, [W_MONHDEXNUM]
+ ld a, [W_MONHINDEX]
ld [wd0b5], a
call GetName
pop af
@@ -275,7 +275,7 @@ RenameEvolvedMon: ; 3aef7 (e:6ef7)
cp [hl]
inc hl
ret nz
- cp $50
+ cp "@"
jr nz, .compareNamesLoop
ld a, [wWhichPokemon]
ld bc, 11
diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm
index ce1430e3..293c756f 100755
--- a/engine/hall_of_fame.asm
+++ b/engine/hall_of_fame.asm
@@ -280,9 +280,9 @@ HoFRecordMonInfo: ; 70404 (1c:4404)
jp CopyData
HoFFadeOutScreenAndMusic: ; 70423 (1c:4423)
- ld a, $a
- ld [wcfc8], a
- ld [wcfc9], a
+ ld a, 10
+ ld [wAudioFadeOutCounterReloadValue], a
+ ld [wAudioFadeOutCounter], a
ld a, $ff
- ld [wMusicHeaderPointer], a
+ ld [wAudioFadeOutControl], a
jp GBFadeOutToWhite
diff --git a/engine/hidden_object_functions14.asm b/engine/hidden_object_functions14.asm
index e0ed973d..97187638 100755
--- a/engine/hidden_object_functions14.asm
+++ b/engine/hidden_object_functions14.asm
@@ -2,7 +2,7 @@ PrintNotebookText: ; 52996 (14:6996)
call EnableAutoTextBoxDrawing
ld a, $1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
- ld a, [wTrainerSpriteOffset]
+ ld a, [wHiddenObjectFunctionArgument]
jp PrintPredefTextID
TMNotebook: ; 529a4 (14:69a4)
diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm
index e3c296ca..67e75301 100755
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -19,8 +19,8 @@ DisplayOakLabRightPoster: ; 1e965 (7:6965)
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld a, [wd11e]
- cp $2
+ ld a, [wNumSetBits]
+ cp 2
tx_pre_id SaveOptionText
jr c, .ownThreeOrMoreMon
tx_pre_id StrengthsAndWeaknessesText
@@ -63,14 +63,14 @@ SafariZoneGameStillGoing: ; 1e9ab (7:69ab)
SafariZoneGameOver: ; 1e9b0 (7:69b0)
call EnableAutoTextBoxDrawing
xor a
- ld [wMusicHeaderPointer], a
+ ld [wAudioFadeOutControl], a
dec a
call PlaySound
ld c, BANK(SFX_Safari_Zone_PA)
ld a, SFX_SAFARI_ZONE_PA
call PlayMusic
.asm_1e9c2
- ld a, [wc02a]
+ ld a, [wChannelSoundIDs + CH4]
cp $b9
jr nz, .asm_1e9c2
ld a, TEXT_SAFARI_GAME_OVER
@@ -374,7 +374,7 @@ BillsHouseInitiatedText: ; 1ebe2 (7:6be2)
db $06
TX_ASM
ld a, $ff
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld c, 16
call DelayFrames
diff --git a/engine/intro.asm b/engine/intro.asm
index 636b4af5..46f0c37a 100755
--- a/engine/intro.asm
+++ b/engine/intro.asm
@@ -325,10 +325,10 @@ PlayShootingStar: ; 4188a (10:588a)
call DelayFrames
.next
ld a, BANK(Music_IntroBattle)
- ld [wc0ef], a
- ld [wc0f0], a
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
ld a, MUSIC_INTRO_BATTLE
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
call IntroClearMiddleOfScreen
call ClearSprites
diff --git a/engine/items/items.asm b/engine/items/items.asm
index bae86ddb..fe53082b 100755
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -312,7 +312,7 @@ ItemUseBall: ; d687 (3:5687)
ld b,$63
.next12
ld a,b
- ld [wd11e],a
+ ld [wPokeBallAnimData],a
.BallSuccess2
ld c,20
call DelayFrames
@@ -331,7 +331,7 @@ ItemUseBall: ; d687 (3:5687)
ld [wcf91],a
pop af
ld [wWhichPokemon],a
- ld a,[wd11e]
+ ld a,[wPokeBallAnimData]
cp a,$10
ld hl,ItemUseBallText00
jp z,.printText0
@@ -856,7 +856,7 @@ ItemUseMedicine: ; dabb (3:5abb)
.notFullHP ; if the pokemon's current HP doesn't equal its max HP
xor a
ld [wLowHealthAlarm],a ;disable low health alarm
- ld [wc02a],a
+ ld [wChannelSoundIDs + CH4],a
push hl
push de
ld bc,32
@@ -1643,7 +1643,7 @@ ItemUsePokeflute: ; e140 (3:6140)
call WaitForSoundToFinish ; wait for sound to end
callba Music_PokeFluteInBattle ; play in-battle pokeflute music
.musicWaitLoop ; wait for music to finish playing
- ld a,[wc02c]
+ ld a,[wChannelSoundIDs + CH6]
and a ; music off?
jr nz,.musicWaitLoop
.skipMusic
@@ -1716,8 +1716,8 @@ PlayedFluteHadEffectText: ; e215 (3:6215)
ld c, BANK(SFX_Pokeflute)
call PlayMusic
.musicWaitLoop ; wait for music to finish playing
- ld a,[wc028]
- cp a,$b8
+ ld a,[wChannelSoundIDs + CH2]
+ cp a, SFX_POKEFLUE
jr z,.musicWaitLoop
call PlayDefaultMusic ; start playing normal music again
.done
@@ -1895,7 +1895,7 @@ ItemUsePPRestore: ; e31e (3:631e)
ld [wPlayerMoveListIndex],a
jr nz,.chooseMon
ld hl,wPartyMon1Moves
- ld bc,44
+ ld bc, wPartyMon2 - wPartyMon1
call GetSelectedMoveOffset
push hl
ld a,[hl]
@@ -1937,7 +1937,7 @@ ItemUsePPRestore: ; e31e (3:631e)
cp b ; is the pokemon whose PP was restored active in battle?
jr nz,.skipUpdatingInBattleData
ld hl,wPartyMon1PP
- ld bc,wPartyMon2 - wPartyMon1
+ ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
ld de,wBattleMonPP
ld bc,4
@@ -1959,12 +1959,12 @@ ItemUsePPRestore: ; e31e (3:631e)
ld [wMonDataLocation],a
call GetMaxPP
ld hl,wPartyMon1Moves
- ld bc,44
+ ld bc, wPartyMon2 - wPartyMon1
call GetSelectedMoveOffset
- ld bc,21
+ ld bc, wPartyMon1PP - wPartyMon1Moves
add hl,bc ; hl now points to move's PP
- ld a,[wd11e]
- ld b,a ; b = max PP
+ ld a,[wMaxPP]
+ ld b,a
ld a,[wPPRestoreItem]
cp a,MAX_ETHER
jr z,.fullyRestorePP
@@ -2009,7 +2009,7 @@ ItemUsePPRestore: ; e31e (3:631e)
.elixirLoop
push bc
ld hl,wPartyMon1Moves
- ld bc,44
+ ld bc, wPartyMon2 - wPartyMon1
call GetSelectedMoveOffset
ld a,[hl]
and a ; does the current slot have a move?
@@ -2283,20 +2283,17 @@ GotOffBicycleText: ; e5fc (3:65fc)
; also, when a PP Up is used, it increases the current PP by one PP Up bonus
; INPUT:
; [wWhichPokemon] = index of pokemon in party
-; [wd11e] = mode
-; 0: Pokemon Center healing
-; 1: using a PP Up
; [wCurrentMenuItem] = index of move (when using a PP Up)
RestoreBonusPP: ; e606 (3:6606)
ld hl,wPartyMon1Moves
- ld bc,wPartyMon2 - wPartyMon1
+ ld bc, wPartyMon2 - wPartyMon1
ld a,[wWhichPokemon]
call AddNTimes
push hl
ld de,wNormalMaxPPList - 1
predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wNormalMaxPPList
pop hl
- ld c,21
+ ld c, wPartyMon1PP - wPartyMon1Moves
ld b,0
add hl,bc ; hl now points to move 1 PP
ld de,wNormalMaxPPList
@@ -2307,7 +2304,7 @@ RestoreBonusPP: ; e606 (3:6606)
ld a,b
cp a,5 ; reached the end of the pokemon's moves?
ret z ; if so, return
- ld a,[wd11e]
+ ld a,[wUsingPPUp]
dec a ; using a PP Up?
jr nz,.skipMenuItemIDCheck
; if using a PP Up, check if this is the move it's being used on
@@ -2329,8 +2326,6 @@ RestoreBonusPP: ; e606 (3:6606)
; INPUT:
; [de] = normal max PP
; [hl] = move PP
-; [wd11e] = max number of times to add bonus
-; set to 1 when using a PP Up, set to 255 otherwise
AddBonusPP: ; e642 (3:6642)
push bc
ld a,[de] ; normal max PP of move
@@ -2358,9 +2353,9 @@ AddBonusPP: ; e642 (3:6642)
.addAmount
add b
ld b,a
- ld a,[wd11e]
- dec a
- jr z,.done
+ ld a,[wUsingPPUp]
+ dec a ; is the player using a PP Up right now?
+ jr z,.done ; if so, only add the bonus once
dec c
jr nz,.loop
.done
@@ -2379,7 +2374,7 @@ AddBonusPP: ; e642 (3:6642)
; 04: player's in-battle pokemon
; [wCurrentMenuItem] = move index
; OUTPUT:
-; [wd11e] = max PP
+; [wMaxPP] = max PP
GetMaxPP: ; e677 (3:6677)
ld a,[wMonDataLocation]
and a
@@ -2432,12 +2427,12 @@ GetMaxPP: ; e677 (3:6677)
ld l,e
inc hl ; hl = wcd73
ld [hl],a
- xor a
- ld [wd11e],a ; no limit on PP Up amount
+ xor a ; add the bonus for the existing PP Up count
+ ld [wUsingPPUp],a
call AddBonusPP ; add bonus PP from PP Ups
ld a,[hl]
and a,%00111111 ; mask out the PP Up count
- ld [wd11e],a ; store max PP
+ ld [wMaxPP],a ; store max PP
ret
GetSelectedMoveOffset: ; e6e3 (3:66e3)
diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm
index f99e5b80..b8896d79 100755
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -395,7 +395,7 @@ PrintNumBadges: ; 5e2f (1:5e2f)
ld b, $1
call CountSetBits
pop hl
- ld de, wd11e
+ ld de, wNumSetBits
lb bc, 1, 2
jp PrintNumber
@@ -405,7 +405,7 @@ PrintNumOwnedMons: ; 5e42 (1:5e42)
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
pop hl
- ld de, wd11e
+ ld de, wNumSetBits
lb bc, 1, 3
jp PrintNumber
diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm
index ead2c359..fd8a928d 100755
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -169,14 +169,14 @@ HandlePokedexListMenu: ; 40111 (10:4111)
ld hl,wPokedexSeen
ld b,wPokedexSeenEnd - wPokedexSeen
call CountSetBits
- ld de,wd11e
+ ld de, wNumSetBits
coord hl, 16, 3
lb bc, 1, 3
call PrintNumber ; print number of seen pokemon
ld hl,wPokedexOwned
ld b,wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld de,wd11e
+ ld de, wNumSetBits
coord hl, 16, 6
lb bc, 1, 3
call PrintNumber ; print number of owned pokemon
@@ -397,7 +397,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
ld hl,wd72c
set 1,[hl]
ld a,$33 ; 3/7 volume
- ld [$ff24],a
+ ld [rNR50],a
call GBPalWhiteOut ; zero all palettes
call ClearScreen
ld a,[wd11e] ; pokemon ID
@@ -566,7 +566,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
ld hl,wd72c
res 1,[hl]
ld a,$77 ; max volume
- ld [$ff24],a
+ ld [rNR50],a
ret
HeightWeightText: ; 40448 (10:4448)
diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm
index c959400a..fb4a0dfc 100755
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -80,7 +80,7 @@ StatusScreen: ; 12953 (4:6953)
ld hl, wd72c
set 1, [hl]
ld a, $33
- ld [$ff24], a ; Reduce the volume
+ ld [rNR50], a ; Reduce the volume
call GBPalWhiteOutWithDelay3
call ClearScreen
call UpdateSprites
@@ -138,7 +138,7 @@ StatusScreen: ; 12953 (4:6953)
call PlaceString ; "STATUS/"
coord hl, 14, 2
call PrintLevel ; Pokémon level
- ld a, [W_MONHDEXNUM]
+ ld a, [W_MONHINDEX]
ld [wd11e], a
ld [wd0b5], a
predef IndexToPokedex
@@ -372,7 +372,7 @@ StatusScreen2: ; 12b57 (4:6b57)
call PrintNumber
ld a, "/"
ld [hli], a
- ld de, wd11e
+ ld de, wMaxPP
lb bc, 1, 2
call PrintNumber
pop hl
@@ -417,7 +417,7 @@ StatusScreen2: ; 12b57 (4:6b57)
call StatusScreen_ClearName
coord hl, 9, 1
call StatusScreen_ClearName
- ld a, [W_MONHDEXNUM]
+ ld a, [W_MONHINDEX]
ld [wd11e], a
call GetMonName
coord hl, 9, 1
@@ -431,7 +431,7 @@ StatusScreen2: ; 12b57 (4:6b57)
ld hl, wd72c
res 1, [hl]
ld a, $77
- ld [$ff24], a
+ ld [rNR50], a
call GBPalWhiteOut
jp ClearScreen
diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm
index 98499d7f..566bd880 100755
--- a/engine/oak_speech.asm
+++ b/engine/oak_speech.asm
@@ -129,12 +129,12 @@ OakSpeech: ; 6115 (1:6115)
ld a,[H_LOADEDROMBANK]
push af
ld a, BANK(Music_PalletTown)
- ld [wc0ef],a
- ld [wc0f0],a
- ld a,$A
- ld [wMusicHeaderPointer],a
+ ld [wAudioROMBank],a
+ ld [wAudioSavedROMBank],a
+ ld a, 10
+ ld [wAudioFadeOutControl],a
ld a,$FF
- ld [wc0ee],a
+ ld [wNewSoundID],a
call PlaySound ; stop music
pop af
ld [H_LOADEDROMBANK],a
diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm
index eb62fee7..05a9cc4e 100755
--- a/engine/overworld/elevator.asm
+++ b/engine/overworld/elevator.asm
@@ -33,7 +33,7 @@ ShakeElevator: ; 7bf15 (1e:7f15)
ld a, SFX_SAFARI_ZONE_PA
call PlayMusic
.musicLoop
- ld a, [wc02a]
+ ld a, [wChannelSoundIDs + CH4]
cp $b9
jr z, .musicLoop
call UpdateSprites
diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm
index 3ab41d5f..bf7130cb 100755
--- a/engine/overworld/healing_machine.asm
+++ b/engine/overworld/healing_machine.asm
@@ -15,44 +15,44 @@ AnimateHealingMachine: ; 70433 (1c:4433)
ld hl, wOAMBuffer + $84
ld de, PokeCenterOAMData
call CopyHealingMachineOAM
- ld a, $4
- ld [wMusicHeaderPointer], a
+ ld a, 4
+ ld [wAudioFadeOutControl], a
ld a, $ff
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
-.asm_70464
- ld a, [wMusicHeaderPointer]
- and a
- jr nz, .asm_70464
+.waitLoop
+ ld a, [wAudioFadeOutControl]
+ and a ; is fade-out finished?
+ jr nz, .waitLoop ; if not, check again
ld a, [wPartyCount]
ld b, a
-.asm_7046e
+.partyLoop
call CopyHealingMachineOAM
ld a, SFX_HEALING_MACHINE
call PlaySound
ld c, 30
call DelayFrames
dec b
- jr nz, .asm_7046e
- ld a, [wc0ef]
+ jr nz, .partyLoop
+ ld a, [wAudioROMBank]
cp BANK(Audio3_UpdateMusic)
- ld [wc0f0], a
- jr nz, .asm_70495
+ ld [wAudioSavedROMBank], a
+ jr nz, .next
ld a, $ff
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld a, BANK(Music_PkmnHealed)
- ld [wc0ef], a
-.asm_70495
+ ld [wAudioROMBank], a
+.next
ld a, MUSIC_PKMN_HEALED
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld d, $28
call FlashSprite8Times
-.asm_704a2
- ld a, [wc026]
- cp MUSIC_PKMN_HEALED
- jr z, .asm_704a2
+.waitLoop2
+ ld a, [wChannelSoundIDs]
+ cp MUSIC_PKMN_HEALED ; is the healed music still playing?
+ jr z, .waitLoop2 ; if so, check gain
ld c, 32
call DelayFrames
pop af
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index 0c01e38c..fa5ac222 100755
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -163,10 +163,10 @@ PewterMuseumGuyMovementScriptPointerTable: ; 1a510 (6:6510)
PewterMovementScript_WalkToMuseum: ; 1a514 (6:6514)
ld a, BANK(Music_MuseumGuy)
- ld [wc0ef], a
- ld [wc0f0], a
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
ld a, MUSIC_MUSEUM_GUY
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld a, [wSpriteIndex]
swap a
@@ -219,10 +219,10 @@ PewterGymGuyMovementScriptPointerTable: ; 1a57d (6:657d)
PewterMovementScript_WalkToGym: ; 1a581 (6:6581)
ld a, BANK(Music_MuseumGuy)
- ld [wc0ef], a
- ld [wc0f0], a
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
ld a, MUSIC_MUSEUM_GUY
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld a, [wSpriteIndex]
swap a
diff --git a/engine/overworld/oaks_aide.asm b/engine/overworld/oaks_aide.asm
index 00f6ea82..31832315 100755
--- a/engine/overworld/oaks_aide.asm
+++ b/engine/overworld/oaks_aide.asm
@@ -4,45 +4,45 @@ OaksAideScript: ; 0x59035
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
- jr nz, .asm_59086
+ jr nz, .choseNo
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld a, [wd11e]
- ld [$ffdd], a
+ ld a, [wNumSetBits]
+ ld [hOaksAideNumMonsOwned], a
ld b, a
- ld a, [$ffdb]
+ ld a, [hOaksAideRequirement]
cp b
- jr z, .asm_59059
- jr nc, .asm_5907c
-.asm_59059
+ jr z, .giveItem
+ jr nc, .notEnoughOwnedMons
+.giveItem
ld hl, OaksAideHereYouGoText
call PrintText
- ld a, [$ffdc]
+ ld a, [hOaksAideItemReward]
ld b, a
ld c, 1
call GiveItem
- jr nc, .BagFull
+ jr nc, .bagFull
ld hl, OaksAideGotItemText
call PrintText
ld a, $1
- jr .asm_5908e
-.BagFull
+ jr .done
+.bagFull
ld hl, OaksAideNoRoomText
call PrintText
xor a
- jr .asm_5908e
-.asm_5907c
+ jr .done
+.notEnoughOwnedMons
ld hl, OaksAideUhOhText
call PrintText
ld a, $80
- jr .asm_5908e
-.asm_59086
+ jr .done
+.choseNo
ld hl, OaksAideComeBackText
call PrintText
ld a, $ff
-.asm_5908e
- ld [$ffdb], a
+.done
+ ld [hOaksAideResult], a
ret
OaksAideHiText: ; 59091 (16:5091)
diff --git a/engine/overworld/pokecenter.asm b/engine/overworld/pokecenter.asm
index 5b2e4cbb..f302d994 100755
--- a/engine/overworld/pokecenter.asm
+++ b/engine/overworld/pokecenter.asm
@@ -24,12 +24,12 @@ DisplayPokemonCenterDialogue_: ; 6fe6 (1:6fe6)
predef HealParty
callba AnimateHealingMachine ; do the healing machine animation
xor a
- ld [wMusicHeaderPointer], a
- ld a, [wc0f0]
- ld [wc0ef], a
- ld a, [wd35b]
- ld [wcfca], a
- ld [wc0ee], a
+ ld [wAudioFadeOutControl], a
+ ld a, [wAudioSavedROMBank]
+ ld [wAudioROMBank], a
+ ld a, [wMapMusicSoundID]
+ ld [wLastMusicSoundID], a
+ ld [wNewSoundID], a
call PlaySound
ld hl, PokemonFightingFitText
call PrintText
diff --git a/engine/pokedex_rating.asm b/engine/pokedex_rating.asm
index ca88673f..265eff40 100755
--- a/engine/pokedex_rating.asm
+++ b/engine/pokedex_rating.asm
@@ -2,18 +2,18 @@ DisplayDexRating: ; 44169 (11:4169)
ld hl, wPokedexSeen
ld b, wPokedexSeenEnd - wPokedexSeen
call CountSetBits
- ld a, [wd11e] ; result of CountSetBits (seen count)
- ld [$FFDB], a
+ ld a, [wNumSetBits]
+ ld [hDexRatingNumMonsSeen], a
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld a, [wd11e] ; result of CountSetBits (own count)
- ld [$FFDC], a
+ ld a, [wNumSetBits]
+ ld [hDexRatingNumMonsOwned], a
ld hl, DexRatingsTable
.findRating
ld a, [hli]
ld b, a
- ld a, [$FFDC] ; number of pokemon owned
+ ld a, [hDexRatingNumMonsOwned]
cp b
jr c, .foundRating
inc hl
@@ -24,30 +24,30 @@ DisplayDexRating: ; 44169 (11:4169)
ld h, [hl]
ld l, a ; load text pointer into hl
CheckAndResetEventA EVENT_HALL_OF_FAME_DEX_RATING
- jr nz, .label3
+ jr nz, .hallOfFame
push hl
ld hl, PokedexRatingText_441cc
call PrintText
pop hl
call PrintText
callba PlayPokedexRatingSfx
- jp WaitForTextScrollButtonPress ; wait for button press
-.label3
+ jp WaitForTextScrollButtonPress
+.hallOfFame
ld de, wcc5b
- ld a, [$FFDB]
+ ld a, [hDexRatingNumMonsSeen]
ld [de], a
inc de
- ld a, [$FFDC]
+ ld a, [hDexRatingNumMonsOwned]
ld [de], a
inc de
-.label4
+.copyRatingTextLoop
ld a, [hli]
- cp a, $50
- jr z, .label5
+ cp a, "@"
+ jr z, .doneCopying
ld [de], a
inc de
- jr .label4
-.label5
+ jr .copyRatingTextLoop
+.doneCopying
ld [de], a
ret
diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm
index 3b392dde..b68b9294 100755
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -411,7 +411,7 @@ SlotMachine_CheckForMatches: ; 37588 (d:7588)
call PrintText
.done
xor a
- ld [wc002], a
+ ld [wMuteAudioAndPauseMusic], a
ret
.rollWheel3DownByOneSymbol
call SlotMachine_AnimWheel3
@@ -654,7 +654,7 @@ SlotMachine_PrintPayoutCoins: ; 3775f (d:775f)
SlotMachine_PayCoinsToPlayer: ; 3776b (d:776b)
ld a, $1
- ld [wc002], a
+ ld [wMuteAudioAndPauseMusic], a
call WaitForSoundToFinish
; Put 1 in the temp coins variable. This value is added to the player's coins
diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm
index fea179d6..10c3f2a0 100755
--- a/engine/titlescreen.asm
+++ b/engine/titlescreen.asm
@@ -18,8 +18,8 @@ SetDefaultNamesBeforeTitlescreen: ; 42b7 (1:42b7)
ld [hli], a
ld [hl], a
ld a, BANK(Music_TitleScreen)
- ld [wc0ef], a
- ld [wc0f0], a
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
DisplayTitleScreen: ; 42dd (1:42dd)
call GBPalWhiteOut
@@ -212,7 +212,7 @@ ENDC
call Delay3
call WaitForSoundToFinish
ld a, MUSIC_TITLE_SCREEN
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
xor a
ld [wcc5b], a