ref: 7f6d0d49b61a77cfba76057d99881634b882486b
parent: 12db77201f7ba50241331c3949241a420f43d660
author: YamaArashi <shadow962@live.com>
date: Fri Jul 24 16:27:59 EDT 2015
more naming variables
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -225,7 +225,7 @@
ld [wPartyFoughtCurrentEnemyFlags], a
ld [wActionResultOrTookBattleTurn], a
inc a
- ld [wd11d], a
+ ld [wFirstMonsNotOutYet], a
ld hl, wEnemyMon1HP
ld bc, wEnemyMon2 - wEnemyMon1 - 1
ld d, $3
@@ -379,7 +379,7 @@
jp z, HandleEnemyMonFainted ; if enemy mon HP is 0, jump
call SaveScreenTilesToBuffer1
xor a
- ld [wd11d], a
+ ld [wFirstMonsNotOutYet], a
ld a, [W_PLAYERBATTSTATUS2]
and (1 << NeedsToRecharge) | (1 << UsingRage) ; check if the player is using Rage or needs to recharge
jr nz, .selectEnemyMove
@@ -1434,7 +1434,7 @@
ld [wLastSwitchInEnemyMonHP + 1],a
ld a,1
ld [wCurrentMenuItem],a
- ld a,[wd11d]
+ ld a,[wFirstMonsNotOutYet]
dec a
jr z,.next4
ld a,[wPartyCount]
@@ -1549,7 +1549,7 @@
ld a, [hli]
or [hl]
ret nz
- ld a, [wd11d]
+ ld a, [wFirstMonsNotOutYet]
and a
jr nz, .done
ld hl, NoWillText
@@ -1647,8 +1647,8 @@
ld hl, NoRunningText
.printCantEscapeOrNoRunningText
call PrintText
- ld a, $1
- ld [wd11f], a
+ ld a, 1
+ ld [wForcePlayerToChooseMon], a
call SaveScreenTilesToBuffer1
and a ; reset carry
ret
@@ -2334,7 +2334,7 @@
res UsingTrappingMove, [hl] ; not using multi-turn move any more
.checkIfMonCaptured
- ld a, [wd11c]
+ ld a, [wCapturedMonSpecies]
and a ; was the enemy mon captured with a ball?
jr nz, .returnAfterCapturingMon
@@ -2354,7 +2354,7 @@
.returnAfterCapturingMon
call GBPalNormal
xor a
- ld [wd11c], a
+ ld [wCapturedMonSpecies], a
ld a, $2
ld [wBattleResult], a
scf ; set carry
@@ -2516,8 +2516,8 @@
ld hl, wBattleMonSpeed
ld de, wEnemyMonSpeed
call TryRunningFromBattle
- ld a, $0
- ld [wd11f], a
+ ld a, 0
+ ld [wForcePlayerToChooseMon], a
ret c
ld a, [wActionResultOrTookBattleTurn]
and a
@@ -3035,18 +3035,18 @@
push hl
call BattleRandom
ld b, $1
- cp $3f ; select move 1 in [0,3e] (63/256 chance)
+ cp $3f ; select move 1, [0,3e] (63/256 chance)
jr c, .moveChosen
inc hl
inc b
- cp $7f ; select move 1 in [3f,7e] (64/256 chance)
+ cp $7f ; select move 2, [3f,7e] (64/256 chance)
jr c, .moveChosen
inc hl
inc b
- cp $be ; select move 1 in [7f,bd] (63/256 chance)
+ cp $be ; select move 3, [7f,bd] (63/256 chance)
jr c, .moveChosen
inc hl
- inc b ; select move 4 in [be,ff] (66/256 chance)
+ inc b ; select move 4, [be,ff] (66/256 chance)
.moveChosen
ld a, b
dec a
--- a/engine/battle/end_of_battle.asm
+++ b/engine/battle/end_of_battle.asm
@@ -51,7 +51,7 @@
ld [W_BATTLETYPE], a
ld [W_MOVEMISSED], a
ld [W_CUROPPONENT], a
- ld [wd11f], a
+ ld [wForcePlayerToChooseMon], a
ld [wNumRunAttempts], a
ld [wEscapedFromBattle], a
ld hl, wPartyAndBillsPCSavedMenuItem
--- a/engine/battle/read_trainer_party.asm
+++ b/engine/battle/read_trainer_party.asm
@@ -154,7 +154,7 @@
ld b,a
.LastLoop
; update wAmountMoneyWon addresses (money to win) based on enemy's level
- ld hl,wd047
+ ld hl,wTrainerBaseMoney + 1
ld c,2 ; wAmountMoneyWon is a 3-byte number
push bc
predef AddBCDPredef
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -2,7 +2,7 @@
; unused slots are filled with 0, all used slots may be chosen with equal probability
AIEnemyTrainerChooseMoves: ; 39719 (e:5719)
ld a, $a
- ld hl, wHPBarMaxHP ; init temporary move selection array. Only the moves with the lowest numbers are chosen in the end
+ ld hl, wBuffer ; init temporary move selection array. Only the moves with the lowest numbers are chosen in the end
ld [hli], a ; move 1
ld [hli], a ; move 2
ld [hli], a ; move 3
@@ -11,7 +11,7 @@
swap a
and $f
jr z, .noMoveDisabled
- ld hl, wHPBarMaxHP
+ ld hl, wBuffer
dec a
ld c, a
ld b, $0
@@ -18,7 +18,7 @@
add hl, bc ; advance pointer to forbidden move
ld [hl], $50 ; forbid (highly discourage) disabled move
.noMoveDisabled
- ld hl, TrainerClassMoveChoiceModifications ; 589B
+ ld hl, TrainerClassMoveChoiceModifications
ld a, [W_TRAINERCLASS]
ld b, a
.loopTrainerClasses
@@ -44,7 +44,7 @@
dec a
add a
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc ; skip to pointer
ld a, [hli] ; read pointer into hl
ld h, [hl]
@@ -53,9 +53,9 @@
push de
jp [hl] ; execute modification function
.loopFindMinimumEntries ; all entries will be decremented sequentially until one of them is zero
- ld hl, wHPBarMaxHP ; temp move selection array
+ ld hl, wBuffer ; temp move selection array
ld de, wEnemyMonMoves ; enemy moves
- ld c, $4
+ ld c, NUM_MOVES
.loopDecrementEntries
ld a, [de]
inc de
@@ -73,11 +73,11 @@
inc [hl]
dec hl
inc a
- cp $5
+ cp NUM_MOVES + 1
jr nz, .loopUndoPartialIteration
- ld hl, wHPBarMaxHP ; temp move selection array
+ ld hl, wBuffer ; temp move selection array
ld de, wEnemyMonMoves ; enemy moves
- ld c, $4
+ ld c, NUM_MOVES
.filterMinimalEntries ; all minimal entries now have value 1. All other slots will be disabled (move set to 0)
ld a, [de]
and a
@@ -97,7 +97,7 @@
inc de
dec c
jr nz, .filterMinimalEntries
- ld hl, wHPBarMaxHP ; use created temporary array as move set
+ ld hl, wBuffer ; use created temporary array as move set
ret
.useOriginalMoveSet
ld hl, wEnemyMonMoves ; use original move set
@@ -694,11 +694,13 @@
ld hl, AIBattleWithdrawText
call PrintText
+ ; This wFirstMonsNotOutYet variable is abused to prevent the player from
+ ; switching in a new mon in response to this switch.
ld a,1
- ld [wd11d],a
+ ld [wFirstMonsNotOutYet],a
callab EnemySendOut
xor a
- ld [wd11d],a
+ ld [wFirstMonsNotOutYet],a
ld a,[wLinkState]
cp LINK_STATE_BATTLING
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -14,7 +14,7 @@
ld a, [hTilesetType]
push af
xor a
- ld [wd121], a
+ ld [wEvolutionOccurred], a
dec a
ld [wWhichPokemon], a
push hl
@@ -91,7 +91,7 @@
ld a, [wLoadedMonLevel]
cp b ; is the mon's level greater than the evolution requirement?
jp c, Evolution_PartyMonLoop ; if so, go the next mon
- jr .asm_3adb6
+ jr .doEvolution
.checkItemEvo
ld a, [hli]
ld b, a ; evolution item
@@ -104,10 +104,10 @@
ld a, [wLoadedMonLevel]
cp b ; is the mon's level greater than the evolution requirement?
jp c, .nextEvoEntry2 ; if so, go the next evolution entry
-.asm_3adb6
+.doEvolution
ld [W_CURENEMYLVL], a
- ld a, $1
- ld [wd121], a
+ ld a, 1
+ ld [wEvolutionOccurred], a
push hl
ld a, [hl]
ld [wEvoNewSpecies], a
@@ -252,7 +252,7 @@
ld a, [W_ISINBATTLE]
and a
ret nz
- ld a, [wd121]
+ ld a, [wEvolutionOccurred]
and a
call nz, PlayDefaultMusic
ret
--- a/engine/hidden_object_functions17.asm
+++ b/engine/hidden_object_functions17.asm
@@ -311,7 +311,7 @@
GymTrashScript: ; 5ddfc (17:5dfc)
call EnableAutoTextBoxDrawing
ld a, [wHiddenObjectFunctionArgument]
- ld [wcd5b], a
+ ld [wGymTrashCanIndex], a
; Don't do the trash can puzzle if it's already been done.
CheckEvent EVENT_2ND_LOCK_OPENED
@@ -320,12 +320,12 @@
tx_pre_jump VermilionGymTrashText
.ok
- bit 1, a
+ CheckEventReuseA EVENT_1ST_LOCK_OPENED
jr nz, .trySecondLock
- ld a, [wd743]
+ ld a, [wFirstLockTrashCanIndex]
ld b, a
- ld a, [wcd5b]
+ ld a, [wGymTrashCanIndex]
cp b
jr z, .openFirstLock
@@ -337,7 +337,7 @@
SetEvent EVENT_1ST_LOCK_OPENED
ld hl, GymTrashCans
- ld a, [wcd5b]
+ ld a, [wGymTrashCanIndex]
; * 5
ld b, a
add a
@@ -364,15 +364,15 @@
add hl, de
ld a, [hl]
and $f
- ld [wd744], a
+ ld [wSecondLockTrashCanIndex], a
tx_pre_id VermilionGymTrashSuccesText1
jr .done
.trySecondLock
- ld a, [wd744]
+ ld a, [wSecondLockTrashCanIndex]
ld b, a
- ld a, [wcd5b]
+ ld a, [wGymTrashCanIndex]
cp b
jr z, .openSecondLock
@@ -381,7 +381,7 @@
call Random
and $e
- ld [wd743], a
+ ld [wFirstLockTrashCanIndex], a
tx_pre_id VermilionGymTrashFailText
jr .done
--- a/engine/hp_bar.asm
+++ b/engine/hp_bar.asm
@@ -205,20 +205,21 @@
push de
ld a, [wHPBarType]
and a
- jr z, .asm_fb2d
+ jr z, .done ; don't print number in enemy HUD
+; convert from little-endian to big-endian for PrintNumber
ld a, [wHPBarOldHP]
- ld [wcef1], a
- ld a, [wHPBarOldHP+1]
- ld [wcef0], a
+ ld [wHPBarTempHP + 1], a
+ ld a, [wHPBarOldHP + 1]
+ ld [wHPBarTempHP], a
push hl
ld a, [hFlags_0xFFF6]
bit 0, a
jr z, .asm_fb15
ld de, $9
- jr .asm_fb18
+ jr .next
.asm_fb15
ld de, $15
-.asm_fb18
+.next
add hl, de
push hl
ld a, $7f
@@ -226,12 +227,12 @@
ld [hli], a
ld [hli], a
pop hl
- ld de, wcef0
+ ld de, wHPBarTempHP
ld bc, $203
call PrintNumber
call DelayFrame
pop hl
-.asm_fb2d
+.done
pop de
pop af
ret
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -118,7 +118,7 @@
.UseBall
;ok, you can use a ball
xor a
- ld [wd11c],a
+ ld [wCapturedMonSpecies],a
ld a,[W_BATTLETYPE]
cp a,2 ;SafariBattle
jr nz,.skipSafariZoneCode
@@ -388,7 +388,7 @@
pop af
ld [hl],a
ld a,[wEnemyMonSpecies] ;enemy
- ld [wd11c],a
+ ld [wCapturedMonSpecies],a
ld [wcf91],a
ld [wd11e],a
ld a,[W_BATTLETYPE]
@@ -645,7 +645,7 @@
call PlaySoundWaitForCurrent
call WaitForSoundToFinish
callab TryEvolvingMon ; try to evolve pokemon
- ld a,[wd121]
+ ld a,[wEvolutionOccurred]
and a
jr z,.noEffect
pop af
@@ -2537,13 +2537,13 @@
; if the item is not an HM or TM
push af
ld hl,KeyItemBitfield
- ld de,wHPBarMaxHP
+ ld de,wBuffer
ld bc,15 ; only 11 bytes are actually used
call CopyData
pop af
dec a
ld c,a
- ld hl,wHPBarMaxHP
+ ld hl,wBuffer
ld b,FLAG_TEST
predef FlagActionPredef
ld a,c
--- a/engine/learn_move.asm
+++ b/engine/learn_move.asm
@@ -46,10 +46,10 @@
ld hl, Moves
ld bc, $6
call AddNTimes
- ld de, wHPBarMaxHP
+ ld de, wBuffer
ld a, BANK(Moves)
call FarCopyData
- ld a, [wHPBarNewHP + 1]
+ ld a, [wBuffer + 5] ; a = move's max PP
pop de
pop hl
ld [hl], a
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -54,7 +54,7 @@
db "@"
DisplayNameRaterScreen: ; 655c (1:655c)
- ld hl, wHPBarMaxHP
+ ld hl, wBuffer
xor a
ld [wUpdateSpritesEnabled], a
ld a, NAME_MON_SCREEN
@@ -72,7 +72,7 @@
call AddNTimes
ld e, l
ld d, h
- ld hl, wHPBarMaxHP
+ ld hl, wBuffer
ld bc, 11
call CopyData
and a
@@ -94,24 +94,24 @@
call LoadEDTile
callba LoadMonPartySpriteGfx
coord hl, 0, 4
- ld b, $9
- ld c, $12
+ ld b, 9
+ ld c, 18
call TextBoxBorder
call PrintNamingText
- ld a, $3
+ ld a, 3
ld [wTopMenuItemY], a
- ld a, $1
+ ld a, 1
ld [wTopMenuItemX], a
ld [wLastMenuItem], a
ld [wCurrentMenuItem], a
ld a, $ff
ld [wMenuWatchedKeys], a
- ld a, $7
+ ld a, 7
ld [wMaxMenuItem], a
ld a, $50
ld [wcf4b], a
xor a
- ld hl, wHPBarMaxHP + 1
+ ld hl, wNamingScreenSubmitName
ld [hli], a
ld [hli], a
ld [wAnimCounter], a
@@ -119,7 +119,7 @@
call PrintAlphabet
call GBPalNormal
.ABStartReturnPoint
- ld a, [wHPBarMaxHP + 1]
+ ld a, [wNamingScreenSubmitName]
and a
jr nz, .submitNickname
call PrintNicknameAndUnderscores
@@ -197,14 +197,14 @@
ld de, .selectReturnPoint
push de
.pressedSelect
- ld a, [wHPBarOldHP]
+ ld a, [wAlphabetCase]
xor $1
- ld [wHPBarOldHP], a
+ ld [wAlphabetCase], a
ret
.pressedStart
- ld a, $1
- ld [wHPBarMaxHP + 1], a
+ ld a, 1
+ ld [wNamingScreenSubmitName], a
ret
.pressedA
@@ -216,7 +216,7 @@
jr z, .pressedStart
.didNotPressED
ld a, [wCurrentMenuItem]
- cp $6 ; case swtich row
+ cp $6 ; case switch row
jr nz, .didNotPressCaseSwtich
ld a, [wTopMenuItemX]
cp $1 ; case switch column
@@ -228,9 +228,9 @@
ld l, a
inc hl
ld a, [hl]
- ld [wHPBarNewHP], a
+ ld [wNamingScreenLetter], a
call CalcStringLength
- ld a, [wHPBarNewHP]
+ ld a, [wNamingScreenLetter]
cp $e5
ld de, Dakutens
jr z, .dakutensAndHandakutens
@@ -240,11 +240,11 @@
ld a, [wNamingScreenType]
cp NAME_MON_SCREEN
jr nc, .checkMonNameLength
- ld a, [wHPBarMaxHP]
+ ld a, [wNamingScreenNameLength]
cp $7 ; max length of player/rival names
jr .checkNameLength
.checkMonNameLength
- ld a, [wHPBarMaxHP]
+ ld a, [wNamingScreenNameLength]
cp $a ; max length of pokemon nicknames
.checkNameLength
jr c, .addLetter
@@ -257,7 +257,7 @@
ret nc
dec hl
.addLetter
- ld a, [wHPBarNewHP]
+ ld a, [wNamingScreenLetter]
ld [hli], a
ld [hl], $50
ld a, SFX_PRESS_AB
@@ -264,7 +264,7 @@
call PlaySound
ret
.pressedB
- ld a, [wHPBarMaxHP]
+ ld a, [wNamingScreenNameLength]
and a
ret z
call CalcStringLength
@@ -335,7 +335,7 @@
PrintAlphabet: ; 676f (1:676f)
xor a
ld [H_AUTOBGTRANSFERENABLED], a
- ld a, [wHPBarOldHP]
+ ld a, [wAlphabetCase]
and a
ld de, LowerCaseAlphabet
jr nz, .lowercase
@@ -371,7 +371,7 @@
PrintNicknameAndUnderscores: ; 680e (1:680e)
call CalcStringLength
ld a, c
- ld [wHPBarMaxHP], a
+ ld [wNamingScreenNameLength], a
coord hl, 10, 2
ld bc, $10a
call ClearScreenArea
@@ -394,7 +394,7 @@
jr nz, .placeUnderscoreLoop
ld a, [wNamingScreenType]
cp NAME_MON_SCREEN
- ld a, [wHPBarMaxHP]
+ ld a, [wNamingScreenNameLength]
jr nc, .pokemon2
cp 7 ; player or rival max name length
jr .playerOrRival2
@@ -433,7 +433,7 @@
ret nc
inc hl
ld a, [hl]
- ld [wHPBarNewHP], a
+ ld [wNamingScreenLetter], a
ret
Dakutens: ; 6885 (1:6885)
--- a/engine/overworld/item.asm
+++ b/engine/overworld/item.asm
@@ -31,7 +31,7 @@
jr nc, .BagFull
ld a, [$ffdb]
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, 1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -149,7 +149,7 @@
and a
ret nz
ld a, $0
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld hl, wd730
res 7, [hl]
--- a/engine/overworld/player_animations.asm
+++ b/engine/overworld/player_animations.asm
@@ -370,10 +370,10 @@
ld b, [hl]
.done
ld a, b
- ld [wcd5b], a
+ ld [wStandingOnWarpPadOrHole], a
ret
-; format: db tileset id, tile id, value to be put in wcd5b
+; format: db tileset id, tile id, value to be put in [wStandingOnWarpPadOrHole]
.warpPadAndHoleData: ; 707a9 (1c:47a9)
db FACILITY, $20, 1 ; warp pad
db FACILITY, $11, 2 ; hole
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -487,24 +487,24 @@
; the X-flip OAM bit to be used so that only 2 rather than 4 tile patterns are
; needed.
xor a
- ld [wcd5c], a
- ld de, $202
+ ld [wSymmetricSpriteOAMAttributes], a
+ lb de, 2, 2
.loop
push de
push bc
.innerLoop
ld a, b
- ld [hli], a
+ ld [hli], a ; Y
ld a, c
- ld [hli], a
+ ld [hli], a ; X
ld a, [wOAMBaseTile]
- ld [hli], a
- ld a, [wcd5c]
- ld [hli], a
- xor $20
- ld [wcd5c], a
+ ld [hli], a ; tile
+ ld a, [wSymmetricSpriteOAMAttributes]
+ ld [hli], a ; attributes
+ xor (1 << OAM_X_FLIP)
+ ld [wSymmetricSpriteOAMAttributes], a
inc d
- ld a, $8
+ ld a, 8
add c
ld c, a
dec e
@@ -516,7 +516,7 @@
inc [hl]
inc [hl]
pop hl
- ld a, $8
+ ld a, 8
add b
ld b, a
dec d
--- a/home.asm
+++ b/home.asm
@@ -394,13 +394,13 @@
; otherwise, it is 0
.storeMaxMenuItemID
ld [hli], a ; max menu item ID
- ld a, [wd11f]
+ ld a, [wForcePlayerToChooseMon]
and a
- ld a, A_BUTTON + B_BUTTON
+ ld a, A_BUTTON | B_BUTTON
jr z, .next
xor a
- ld [wd11f], a
- inc a
+ ld [wForcePlayerToChooseMon], a
+ inc a ; a = A_BUTTON
.next
ld [hli], a ; menu watched keys
pop af
@@ -2403,7 +2403,7 @@
call IsInArray ; search for sprite ID
inc hl
ld a, [hl]
- ld [wcc4d], a ; load corresponding missable object index and remove it
+ ld [wMissableObjectIndex], a ; load corresponding missable object index and remove it
predef HideObject
.skipRemoveSprite
ld hl, wd730
@@ -2905,7 +2905,7 @@
inc de
ld a, [hli]
ld [de], a
- ld de, wd046
+ ld de, wTrainerBaseMoney
ld a, [hli]
ld [de], a
inc de
@@ -3944,7 +3944,7 @@
ret
.keyPressed
xor a
- ld [wcc4b],a
+ ld [wCheckFor180DegreeTurn],a
ld a,[hJoy5]
ld b,a
bit 6,a ; pressed Up key?
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -132,8 +132,8 @@
ld hl,wFlags_0xcd60
res 2,[hl]
call UpdateSprites
- ld a,$01
- ld [wcc4b],a
+ ld a,1
+ ld [wCheckFor180DegreeTurn],a
ld a,[wPlayerMovingDirection] ; the direction that was pressed last time
and a
jp z,OverworldLoop
@@ -174,7 +174,7 @@
ld a,[wd730]
bit 7,a ; are we simulating button presses?
jr nz,.noDirectionChange ; ignore direction changes if we are
- ld a,[wcc4b]
+ ld a,[wCheckFor180DegreeTurn]
and a
jr z,.noDirectionChange
ld a,[wPlayerDirection] ; new direction
@@ -182,9 +182,14 @@
ld a,[wPlayerLastStopDirection] ; old direction
cp b
jr z,.noDirectionChange
-; the code below is strange
-; it computes whether or not the player did a 180 degree turn, but then overwrites the result
-; also, it does a seemingly pointless loop afterwards
+; Check whether the player did a 180-degree turn.
+; It appears that this code was supposed to show the player rotate by having
+; the player's sprite face an intermediate direction before facing the opposite
+; direction (instead of doing an instantaneous about-face), but the intermediate
+; direction is only set for a short period of time. It is unlikely for it to
+; ever be visible because DelayFrame is called at the start of OverworldLoop and
+; normally not enough cycles would be executed between then and the time the
+; direction is set for V-blank to occur while the direction is still set.
swap a ; put old direction in upper half
or b ; put new direction in lower half
cp a,(PLAYER_DIR_DOWN << 4) | PLAYER_DIR_UP ; change dir from down to up
@@ -191,30 +196,30 @@
jr nz,.notDownToUp
ld a,PLAYER_DIR_LEFT
ld [wPlayerMovingDirection],a
- jr .oddLoop
+ jr .holdIntermediateDirectionLoop
.notDownToUp
cp a,(PLAYER_DIR_UP << 4) | PLAYER_DIR_DOWN ; change dir from up to down
jr nz,.notUpToDown
ld a,PLAYER_DIR_RIGHT
ld [wPlayerMovingDirection],a
- jr .oddLoop
+ jr .holdIntermediateDirectionLoop
.notUpToDown
cp a,(PLAYER_DIR_RIGHT << 4) | PLAYER_DIR_LEFT ; change dir from right to left
jr nz,.notRightToLeft
ld a,PLAYER_DIR_DOWN
ld [wPlayerMovingDirection],a
- jr .oddLoop
+ jr .holdIntermediateDirectionLoop
.notRightToLeft
cp a,(PLAYER_DIR_LEFT << 4) | PLAYER_DIR_RIGHT ; change dir from left to right
- jr nz,.oddLoop
+ jr nz,.holdIntermediateDirectionLoop
ld a,PLAYER_DIR_UP
ld [wPlayerMovingDirection],a
-.oddLoop
+.holdIntermediateDirectionLoop
ld hl,wFlags_0xcd60
set 2,[hl]
- ld hl,wcc4b
+ ld hl,wCheckFor180DegreeTurn
dec [hl]
- jr nz,.oddLoop
+ jr nz,.holdIntermediateDirectionLoop
ld a,[wPlayerDirection]
ld [wPlayerMovingDirection],a
call NewBattle
@@ -493,7 +498,7 @@
; if not going back to the previous map
ld [W_CURMAP],a
callba IsPlayerStandingOnWarpPadOrHole
- ld a,[wcd5b]
+ ld a,[wStandingOnWarpPadOrHole]
dec a ; is the player on a warp pad?
jr nz,.notWarpPad
; if the player is on a warp pad
@@ -2007,7 +2012,7 @@
LoadMapHeader:: ; 107c (0:107c)
callba MarkTownVisitedAndLoadMissableObjects
ld a,[W_CURMAPTILESET]
- ld [wd119],a
+ ld [wUnusedD119],a
ld a,[W_CURMAP]
call SwitchToMapRomBank
ld a,[W_CURMAPTILESET]
@@ -2305,7 +2310,7 @@
ld [hSCY],a
ld [hSCX],a
ld [wWalkCounter],a
- ld [wd119],a
+ ld [wUnusedD119],a
ld [wWalkBikeSurfStateCopy],a
ld [W_SPRITESETID],a
call LoadTextBoxTilePatterns
--- a/home/vblank.asm
+++ b/home/vblank.asm
@@ -6,7 +6,7 @@
push hl
ld a, [H_LOADEDROMBANK]
- ld [wd122], a
+ ld [wVBlankSavedROMBank], a
ld a, [hSCX]
ld [rSCX], a
@@ -78,7 +78,7 @@
and a
call z, ReadJoypad
- ld a, [wd122]
+ ld a, [wVBlankSavedROMBank]
ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a
--- a/home/vcopy.asm
+++ b/home/vcopy.asm
@@ -380,21 +380,23 @@
and a
ret z ; no animations if indoors (or if a menu set this to 0)
- ld a, [$ffd8]
+ ld a, [hMovingBGTilesCounter1]
inc a
- ld [$ffd8], a
- cp $14
+ ld [hMovingBGTilesCounter1], a
+ cp 20
ret c
- cp $15
+ cp 21
jr z, .flower
+; water
+
ld hl, vTileset + $14 * $10
ld c, $10
- ld a, [wd085]
+ ld a, [wMovingBGTilesCounter2]
inc a
and 7
- ld [wd085], a
+ ld [wMovingBGTilesCounter2], a
and 4
jr nz, .left
@@ -417,14 +419,14 @@
ret nc
; if in a cave, no flower animations
xor a
- ld [$ffd8], a
+ ld [hMovingBGTilesCounter1], a
ret
.flower
xor a
- ld [$ffd8], a
+ ld [hMovingBGTilesCounter1], a
- ld a, [wd085]
+ ld a, [wMovingBGTilesCounter2]
and 3
cp 2
ld hl, FlowerTile1
--- a/hram.asm
+++ b/hram.asm
@@ -259,6 +259,8 @@
; this is often set to 00 in order to turn off water and flower BG tile animations
hTilesetType EQU $FFD7
+hMovingBGTilesCounter1 EQU $FFD8
+
H_CURRENTSPRITEOFFSET EQU $FFDA ; multiple of $10
hFossilCounter EQU $FFDB
--- a/main.asm
+++ b/main.asm
@@ -1642,39 +1642,39 @@
; The bottom and right edges of the menu may remain after the function returns.
TwoOptionMenu_SaveScreenTiles: ; 763e (1:763e)
- ld de, wHPBarMaxHP
- ld bc, $506
-.asm_7644
+ ld de, wBuffer
+ lb bc, 5, 6
+.loop
ld a, [hli]
ld [de], a
inc de
dec c
- jr nz, .asm_7644
+ jr nz, .loop
push bc
- ld bc, 14
+ ld bc, SCREEN_WIDTH - 6
add hl, bc
pop bc
ld c, $6
dec b
- jr nz, .asm_7644
+ jr nz, .loop
ret
TwoOptionMenu_RestoreScreenTiles: ; 7656 (1:7656)
- ld de, wHPBarMaxHP
- ld bc, $506
-.asm_765c
+ ld de, wBuffer
+ lb bc, 5, 6
+.loop
ld a, [de]
inc de
ld [hli], a
dec c
- jr nz, .asm_765c
+ jr nz, .loop
push bc
- ld bc, $e
+ ld bc, SCREEN_WIDTH - 6
add hl, bc
pop bc
- ld c, $6
+ ld c, 6
dec b
- jr nz, .asm_765c
+ jr nz, .loop
call UpdateSprites
ret
@@ -3167,9 +3167,9 @@
and $3
or $98
ld a, l
- ld [wHPBarMaxHP], a
+ ld [wBuffer], a
ld a, h
- ld [wHPBarMaxHP + 1], a
+ ld [wBuffer + 1], a ; this copy of the address is not used
ld a, 2
ld [$ffbe], a
ld c, 9 ; number of rows of 2x2 tiles (this covers the whole screen)
@@ -3177,25 +3177,25 @@
push bc
push hl
push hl
- ld hl, wTileMap - 2 * 20
- ld de, 20
+ ld hl, wTileMap - 2 * SCREEN_WIDTH
+ ld de, SCREEN_WIDTH
ld a, [$ffbe]
-.asm_ef1a
+.calcWRAMAddrLoop
add hl, de
dec a
- jr nz, .asm_ef1a
+ jr nz, .calcWRAMAddrLoop
call CopyToScreenEdgeTiles
pop hl
ld de, $20
ld a, [$ffbe]
ld c, a
-.asm_ef28
+.calcVRAMAddrLoop
add hl, de
ld a, h
and $3
or $98
dec c
- jr nz, .asm_ef28
+ jr nz, .calcVRAMAddrLoop
ld [H_SCREENEDGEREDRAWADDR + 1], a
ld a, l
ld [H_SCREENEDGEREDRAWADDR], a
@@ -3301,7 +3301,7 @@
call FillMemory ; clear missable objects flags
ld hl, MapHS00
xor a
- ld [wd048], a
+ ld [wMissableObjectCounter], a
.missableObjectsLoop
ld a, [hli]
cp $ff ; end of list
@@ -3310,14 +3310,14 @@
inc hl
ld a, [hl]
cp Hide
- jr nz, .asm_f19d
+ jr nz, .skip
ld hl, W_MISSABLEOBJECTFLAGS
- ld a, [wd048]
+ ld a, [wMissableObjectCounter]
ld c, a
ld b, FLAG_SET
- call MissableObjectFlagAction ; set flag iff Item is hidden
-.asm_f19d
- ld hl, wd048
+ call MissableObjectFlagAction ; set flag if Item is hidden
+.skip
+ ld hl, wMissableObjectCounter
inc [hl]
pop hl
inc hl
@@ -3351,11 +3351,11 @@
ret
; adds missable object (items, leg. pokemon, etc.) to the map
-; [wcc4d]: index of the missable object to be added (global index)
+; [wMissableObjectIndex]: index of the missable object to be added (global index)
ShowObject: ; f1c8 (3:71c8)
ShowObject2:
ld hl, W_MISSABLEOBJECTFLAGS
- ld a, [wcc4d]
+ ld a, [wMissableObjectIndex]
ld c, a
ld b, FLAG_RESET
call MissableObjectFlagAction ; reset "removed" flag
@@ -3362,10 +3362,10 @@
jp UpdateSprites
; removes missable object (items, leg. pokemon, etc.) from the map
-; [wcc4d]: index of the missable object to be removed (global index)
+; [wMissableObjectIndex]: index of the missable object to be removed (global index)
HideObject: ; f1d7 (3:71d7)
ld hl, W_MISSABLEOBJECTFLAGS
- ld a, [wcc4d]
+ ld a, [wMissableObjectIndex]
ld c, a
ld b, FLAG_SET
call MissableObjectFlagAction ; set "removed" flag
--- a/scripts/billshouse.asm
+++ b/scripts/billshouse.asm
@@ -49,7 +49,7 @@
bit 0, a
ret nz
ld a, HS_BILL_POKEMON
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
SetEvent EVENT_BILL_SAID_USE_CELL_SEPARATOR
xor a
@@ -75,7 +75,7 @@
ld [$ffee], a
call SetSpritePosition1
ld a, HS_BILL_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld c, 8
call DelayFrames
@@ -170,10 +170,10 @@
call PrintText
SetEvent EVENT_GOT_SS_TICKET
ld a, HS_CERULEAN_GUARD_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, HS_CERULEAN_GUARD_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
.asm_1e8a9
ld hl, BillsHouseText_1e8cb
--- a/scripts/blueshouse.asm
+++ b/scripts/blueshouse.asm
@@ -40,7 +40,7 @@
call GiveItem
jr nc, .BagFull
ld a,HS_TOWN_MAP
- ld [wcc4d],a
+ ld [wMissableObjectIndex],a
predef HideObject ; hide table map object
ld hl,GotMapText
call PrintText
--- a/scripts/celadongamecorner.asm
+++ b/scripts/celadongamecorner.asm
@@ -107,7 +107,7 @@
xor a
ld [wJoyIgnore], a
ld a, HS_GAME_CORNER_ROCKET
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld hl, wd126
set 5, [hl]
--- a/scripts/celadonmansion5.asm
+++ b/scripts/celadonmansion5.asm
@@ -15,7 +15,7 @@
call GivePokemon
jr nc, .asm_24365
ld a, HS_CELADON_MANSION_5_GIFT
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
.asm_24365
jp TextScriptEnd
--- a/scripts/ceruleancity.asm
+++ b/scripts/ceruleancity.asm
@@ -9,7 +9,7 @@
ld [wJoyIgnore], a
ld [W_CERULEANCITYCURSCRIPT], a
ld a, HS_CERULEAN_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump HideObject
CeruleanCityScriptPointers: ; 1949d (6:549d)
@@ -86,7 +86,7 @@
ld [hl], $19
.asm_19535
ld a, HS_CERULEAN_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld de, CeruleanCityMovement1
ld a, $1
@@ -218,7 +218,7 @@
bit 0, a
ret nz
ld a, HS_CERULEAN_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
xor a
ld [wJoyIgnore], a
--- a/scripts/ceruleancity2.asm
+++ b/scripts/ceruleancity2.asm
@@ -4,13 +4,13 @@
; the screen then fades out, he disappears, and fades back in
call GBFadeOutToBlack
ld a, HS_CERULEAN_GUARD_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, HS_CERULEAN_GUARD_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_CERULEAN_ROCKET
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call GBFadeInFromBlack
ret
--- a/scripts/fightingdojo.asm
+++ b/scripts/fightingdojo.asm
@@ -274,7 +274,7 @@
; once Poké Ball is taken, hide sprite
ld a, HS_FIGHTING_DOJO_GIFT_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
SetEvents EVENT_GOT_HITMONLEE, EVENT_DEFEATED_FIGHTING_DOJO
.done
@@ -310,7 +310,7 @@
; once Poké Ball is taken, hide sprite
ld a, HS_FIGHTING_DOJO_GIFT_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
.done
jp TextScriptEnd
--- a/scripts/gary.asm
+++ b/scripts/gary.asm
@@ -120,7 +120,7 @@
ld [H_SPRITEINDEX], a
call MoveSprite
ld a, HS_CHAMPIONS_ROOM_OAK
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, $5
ld [W_GARYCURSCRIPT], a
@@ -197,7 +197,7 @@
bit 0, a
ret nz
ld a, HS_CHAMPIONS_ROOM_OAK
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, $9
ld [W_GARYCURSCRIPT], a
--- a/scripts/halloffameroom.asm
+++ b/scripts/halloffameroom.asm
@@ -95,7 +95,7 @@
ld a, $ff
ld [wJoyIgnore], a
ld a, HS_UNKNOWN_DUNGEON_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, $2
ld [W_HALLOFFAMEROOMCURSCRIPT], a
--- a/scripts/mtmoon3.asm
+++ b/scripts/mtmoon3.asm
@@ -145,7 +145,7 @@
.asm_49e1d
ld a, HS_MT_MOON_3_FOSSIL_1
.asm_49e1f
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
xor a
ld [wJoyIgnore], a
@@ -276,7 +276,7 @@
jp nc, MtMoon3Script_49f76
call MtMoon3Script_49f69
ld a, HS_MT_MOON_3_FOSSIL_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
SetEvent EVENT_GOT_DOME_FOSSIL
ld a, $4
@@ -304,7 +304,7 @@
jp nc, MtMoon3Script_49f76
call MtMoon3Script_49f69
ld a, HS_MT_MOON_3_FOSSIL_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
SetEvent EVENT_GOT_HELIX_FOSSIL
ld a, $4
--- a/scripts/museum1f.asm
+++ b/scripts/museum1f.asm
@@ -196,7 +196,7 @@
jr nc, .BagFull
SetEvent EVENT_GOT_OLD_AMBER
ld a, HS_OLD_AMBER
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld hl, ReceivedOldAmberText
jr .asm_5c288
--- a/scripts/oakslab.asm
+++ b/scripts/oakslab.asm
@@ -37,7 +37,7 @@
and a
ret nz
ld a, HS_OAKS_LAB_OAK_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld hl, wd72e
res 4, [hl]
@@ -67,10 +67,10 @@
bit 0, a
ret nz
ld a, HS_OAKS_LAB_OAK_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_OAKS_LAB_OAK_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, $3
@@ -315,7 +315,7 @@
.asm_1cd30
ld a, HS_STARTER_BALL_3
.asm_1cd32
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call Delay3
ld a, [wRivalStarterTemp]
@@ -475,7 +475,7 @@
bit 0, a
jr nz, .asm_1ce8c
ld a, HS_OAKS_LAB_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
xor a
ld [wJoyIgnore], a
@@ -519,7 +519,7 @@
call DisplayTextID
call OaksLabScript_1d02b
ld a, HS_OAKS_LAB_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, [wNPCMovementDirections2Index]
ld [wd157], a
@@ -578,10 +578,10 @@
call DisplayTextID
call Delay3
ld a, HS_POKEDEX_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_POKEDEX_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call OaksLabScript_1cefd
ld a, $1a
@@ -599,10 +599,10 @@
SetEvent EVENT_GOT_POKEDEX
SetEvent EVENT_OAK_GOT_PARCEL
ld a, HS_LYING_OLD_MAN
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_OLD_MAN
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, [wd157]
ld b, $0
@@ -630,13 +630,13 @@
ret nz
call PlayDefaultMusic
ld a, HS_OAKS_LAB_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
SetEvent EVENT_1ST_ROUTE22_RIVAL_BATTLE
ResetEventReuseHL EVENT_2ND_ROUTE22_RIVAL_BATTLE
SetEventReuseHL EVENT_ROUTE22_RIVAL_WANTS_BATTLE
ld a, HS_ROUTE_22_RIVAL_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, $5
ld [W_PALLETTOWNCURSCRIPT], a
@@ -914,7 +914,7 @@
.asm_1d1e3
ld a, HS_STARTER_BALL_3
.asm_1d1e5
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, $1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
--- a/scripts/pallettown.asm
+++ b/scripts/pallettown.asm
@@ -51,7 +51,7 @@
ld a,$FF
ld [wJoyIgnore],a
ld a,HS_PALLET_TOWN_OAK
- ld [wcc4d],a
+ ld [wMissableObjectIndex],a
predef ShowObject
; trigger the next script
@@ -136,10 +136,10 @@
jr nz,.next
SetEvent EVENT_DAISY_WALKING
ld a,HS_DAISY_SITTING
- ld [wcc4d],a
+ ld [wMissableObjectIndex],a
predef HideObject
ld a,HS_DAISY_WALKING
- ld [wcc4d],a
+ ld [wMissableObjectIndex],a
predef_jump ShowObject
.next
CheckEvent EVENT_GOT_POKEBALLS_FROM_OAK
--- a/scripts/pewtercity.asm
+++ b/scripts/pewtercity.asm
@@ -88,7 +88,7 @@
bit 0, a
ret nz
ld a, HS_MUSEUM_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, $3
ld [W_PEWTERCITYCURSCRIPT], a
@@ -99,7 +99,7 @@
ld [wSpriteIndex], a
call SetSpritePosition2
ld a, HS_MUSEUM_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
xor a
ld [wJoyIgnore], a
@@ -157,7 +157,7 @@
bit 0, a
ret nz
ld a, HS_GYM_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, $6
ld [W_PEWTERCITYCURSCRIPT], a
@@ -168,7 +168,7 @@
ld [wSpriteIndex], a
call SetSpritePosition2
ld a, HS_GYM_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
xor a
ld [wJoyIgnore], a
--- a/scripts/pewtergym.asm
+++ b/scripts/pewtergym.asm
@@ -66,10 +66,10 @@
set 0, [hl]
ld a, HS_GYM_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_ROUTE_22_RIVAL_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ResetEvents EVENT_1ST_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_BATTLE
--- a/scripts/pokemontower2.asm
+++ b/scripts/pokemontower2.asm
@@ -112,7 +112,7 @@
bit 0, a
ret nz
ld a, HS_POKEMONTOWER_2_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
xor a
ld [wJoyIgnore], a
--- a/scripts/pokemontower7.asm
+++ b/scripts/pokemontower7.asm
@@ -51,7 +51,7 @@
cp b ; search for sprite ID in missing objects list
ld a, [hli]
jr nz, .missableObjectsListLoop
- ld [wcc4d], a ; remove missable object
+ ld [wMissableObjectIndex], a ; remove missable object
predef HideObject
xor a
ld [wJoyIgnore], a
@@ -67,7 +67,7 @@
ld a, $ff
ld [wJoyIgnore], a
ld a, HS_POKEMONTOWER_7_MR_FUJI
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, SPRITE_FACING_UP
ld [wSpriteStateData1 + 9], a
@@ -259,13 +259,13 @@
SetEvent EVENT_RESCUED_MR_FUJI
SetEvent EVENT_RESCUED_MR_FUJI_2
ld a, HS_LAVENDER_HOUSE_1_MR_FUJI
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, HS_SAFFRON_CITY_E
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_SAFFRON_CITY_F
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, $4
ld [W_POKEMONTOWER7CURSCRIPT], a
--- a/scripts/rockethideout4.asm
+++ b/scripts/rockethideout4.asm
@@ -56,10 +56,10 @@
call DisplayTextID
call GBFadeOutToBlack
ld a, HS_ROCKET_HIDEOUT_4_GIOVANNI
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_ROCKET_HIDEOUT_4_ITEM_4
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
call UpdateSprites
call GBFadeInFromBlack
@@ -211,7 +211,7 @@
CheckAndSetEvent EVENT_ROCKET_DROPPED_LIFT_KEY
jr nz, .asm_455e9
ld a, HS_ROCKET_HIDEOUT_4_ITEM_5
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
.asm_455e9
jp TextScriptEnd
--- a/scripts/route12.asm
+++ b/scripts/route12.asm
@@ -34,7 +34,7 @@
ld a, 30
ld [W_CURENEMYLVL], a
ld a, HS_ROUTE_12_SNORLAX
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, $3
ld [W_ROUTE12CURSCRIPT], a
--- a/scripts/route16.asm
+++ b/scripts/route16.asm
@@ -34,7 +34,7 @@
ld a, 30
ld [W_CURENEMYLVL], a
ld a, HS_ROUTE_16_SNORLAX
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call UpdateSprites
ld a, $3
--- a/scripts/route20.asm
+++ b/scripts/route20.asm
@@ -49,11 +49,11 @@
ret
Route20Script_50d0c: ; 50d0c (14:4d0c)
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
Route20Script_50d14: ; 50d14 (14:4d14)
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump HideObject
Route20ScriptPointers: ; 50d1c (14:4d1c)
--- a/scripts/route22.asm
+++ b/scripts/route22.asm
@@ -224,7 +224,7 @@
xor a
ld [wJoyIgnore], a
ld a, HS_ROUTE_22_RIVAL_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call PlayDefaultMusic
ResetEvents EVENT_1ST_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_BATTLE
@@ -369,7 +369,7 @@
xor a
ld [wJoyIgnore], a
ld a, HS_ROUTE_22_RIVAL_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call PlayDefaultMusic
ResetEvents EVENT_2ND_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_BATTLE
--- a/scripts/route23.asm
+++ b/scripts/route23.asm
@@ -13,10 +13,10 @@
ResetEvents EVENT_VICTORY_ROAD_2_BOULDER_ON_SWITCH1, EVENT_VICTORY_ROAD_2_BOULDER_ON_SWITCH2
ResetEvents EVENT_VICTORY_ROAD_3_BOULDER_ON_SWITCH1, EVENT_VICTORY_ROAD_3_BOULDER_ON_SWITCH2
ld a, HS_VICTORY_ROAD_3_BOULDER
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, HS_VICTORY_ROAD_2_BOULDER
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump HideObject
Route23ScriptPointers: ; 51213 (14:5213)
--- a/scripts/route25.asm
+++ b/scripts/route25.asm
@@ -19,7 +19,7 @@
jr nz, .asm_515ff
ResetEventReuseHL EVENT_BILL_SAID_USE_CELL_SEPARATOR
ld a, HS_BILL_POKEMON
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
.asm_515ff
CheckEventAfterBranchReuseHL EVENT_GOT_SS_TICKET, EVENT_MET_BILL_2
@@ -26,13 +26,13 @@
ret z
SetEventReuseHL EVENT_LEFT_BILLS_HOUSE_AFTER_HELPING
ld a, HS_NUGGET_BRIDGE_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_BILL_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_BILL_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
Route25ScriptPointers: ; 51622 (14:5622)
--- a/scripts/seafoamislands1.asm
+++ b/scripts/seafoamislands1.asm
@@ -14,22 +14,22 @@
jr nz, .asm_44819
SetEventReuseHL EVENT_SEAFOAM1_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_1_BOULDER_1
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_2_BOULDER_1
- ld [wd07a], a
+ ld [wObjectToShow], a
jr .asm_44825
.asm_44819
SetEventAfterBranchReuseHL EVENT_SEAFOAM1_BOULDER2_DOWN_HOLE, EVENT_SEAFOAM1_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_1_BOULDER_2
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_2_BOULDER_2
- ld [wd07a], a
+ ld [wObjectToShow], a
.asm_44825
- ld a, [wd079]
- ld [wcc4d], a
+ ld a, [wObjectToHide]
+ ld [wMissableObjectIndex], a
predef HideObject
- ld a, [wd07a]
- ld [wcc4d], a
+ ld a, [wObjectToShow]
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
.asm_4483b
ld a, $9f
--- a/scripts/seafoamislands2.asm
+++ b/scripts/seafoamislands2.asm
@@ -13,22 +13,22 @@
jr nz, .asm_46340
SetEventReuseHL EVENT_SEAFOAM2_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_2_BOULDER_1
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_3_BOULDER_1
- ld [wd07a], a
+ ld [wObjectToShow], a
jr .asm_4634c
.asm_46340
SetEventAfterBranchReuseHL EVENT_SEAFOAM2_BOULDER2_DOWN_HOLE, EVENT_SEAFOAM2_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_2_BOULDER_2
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_3_BOULDER_2
- ld [wd07a], a
+ ld [wObjectToShow], a
.asm_4634c
- ld a, [wd079]
- ld [wcc4d], a
+ ld a, [wObjectToHide]
+ ld [wMissableObjectIndex], a
predef HideObject
- ld a, [wd07a]
- ld [wcc4d], a
+ ld a, [wObjectToShow]
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
.asm_46362
ld a, $a0
--- a/scripts/seafoamislands3.asm
+++ b/scripts/seafoamislands3.asm
@@ -13,22 +13,22 @@
jr nz, .asm_4647c
SetEventReuseHL EVENT_SEAFOAM3_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_3_BOULDER_1
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_3
- ld [wd07a], a
+ ld [wObjectToShow], a
jr .asm_46488
.asm_4647c
SetEventAfterBranchReuseHL EVENT_SEAFOAM3_BOULDER2_DOWN_HOLE, EVENT_SEAFOAM3_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_3_BOULDER_2
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_4
- ld [wd07a], a
+ ld [wObjectToShow], a
.asm_46488
- ld a, [wd079]
- ld [wcc4d], a
+ ld a, [wObjectToHide]
+ ld [wMissableObjectIndex], a
predef HideObject
- ld a, [wd07a]
- ld [wcc4d], a
+ ld a, [wObjectToShow]
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
.asm_4649e
ld a, $a1
--- a/scripts/seafoamislands4.asm
+++ b/scripts/seafoamislands4.asm
@@ -13,22 +13,22 @@
jr nz, .asm_465b8
SetEventReuseHL EVENT_SEAFOAM4_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_1
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_5_BOULDER_1
- ld [wd07a], a
+ ld [wObjectToShow], a
jr .asm_465c4
.asm_465b8
SetEventAfterBranchReuseHL EVENT_SEAFOAM4_BOULDER2_DOWN_HOLE, EVENT_SEAFOAM4_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_2
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_5_BOULDER_2
- ld [wd07a], a
+ ld [wObjectToShow], a
.asm_465c4
- ld a, [wd079]
- ld [wcc4d], a
+ ld a, [wObjectToHide]
+ ld [wMissableObjectIndex], a
predef HideObject
- ld a, [wd07a]
- ld [wcc4d], a
+ ld a, [wObjectToShow]
+ ld [wMissableObjectIndex], a
predef ShowObject
jr .asm_465ed
.asm_465dc
--- a/scripts/silphco1.asm
+++ b/scripts/silphco1.asm
@@ -5,7 +5,7 @@
CheckAndSetEvent EVENT_SILPH_CO_RECEPTIONIST_AT_DESK
ret nz
ld a, HS_SILPH_CO_1F_RECEPTIONIST
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
SilphCo1TextPointers: ; 5d469 (17:5469)
--- a/scripts/silphco11.asm
+++ b/scripts/silphco11.asm
@@ -76,7 +76,7 @@
cp $ff
jr z, .asm_62181
push hl
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
pop hl
jr .asm_62170
@@ -87,7 +87,7 @@
cp $ff
ret z
push hl
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
pop hl
jr .asm_62184
--- a/scripts/silphco7.asm
+++ b/scripts/silphco7.asm
@@ -252,7 +252,7 @@
bit 0, a
ret nz
ld a, HS_SILPH_CO_7F_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call PlayDefaultMusic
xor a
--- a/scripts/ssanne2.asm
+++ b/scripts/ssanne2.asm
@@ -33,7 +33,7 @@
ld a, [wCoordIndex]
ld [$ffdb], a
ld a, HS_SS_ANNE_2_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
call Delay3
ld a, $2
@@ -171,7 +171,7 @@
xor a
ld [wJoyIgnore], a
ld a, HS_SS_ANNE_2_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call PlayDefaultMusic
ld a, $4
--- a/scripts/vermilioncity.asm
+++ b/scripts/vermilioncity.asm
@@ -17,7 +17,7 @@
call Random
ld a, [$ffd4]
and $e
- ld [wd743], a
+ ld [wFirstLockTrashCanIndex], a
ret
VermilionCityScript_197cb: ; 197cb (6:57cb)
--- a/scripts/victoryroad3.asm
+++ b/scripts/victoryroad3.asm
@@ -44,10 +44,10 @@
CheckAndSetEvent EVENT_VICTORY_ROAD_3_BOULDER_ON_SWITCH2
jr nz, .asm_449fe
ld a, HS_VICTORY_ROAD_3_BOULDER
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_VICTORY_ROAD_2_BOULDER
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
.coordsData_449f9: ; 449f9 (11:49f9)
--- a/scripts/viridiangym.asm
+++ b/scripts/viridiangym.asm
@@ -163,7 +163,7 @@
SetEventRange EVENT_BEAT_VIRIDIAN_GYM_TRAINER_0, EVENT_BEAT_VIRIDIAN_GYM_TRAINER_7
ld a, HS_ROUTE_22_RIVAL_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
SetEvents EVENT_2ND_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_BATTLE
jp ViridianGymScript_748d6
@@ -275,7 +275,7 @@
call PrintText
call GBFadeOutToBlack
ld a, HS_VIRIDIAN_GYM_GIOVANNI
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call UpdateSprites
call Delay3
--- a/text/maps/name_rater.asm
+++ b/text/maps/name_rater.asm
@@ -35,7 +35,7 @@
text "OK! This #MON"
line "has been renamed"
cont "@"
- TX_RAM wHPBarMaxHP
+ TX_RAM wBuffer
text "!"
para "That's a better"
--- a/wram.asm
+++ b/wram.asm
@@ -360,9 +360,15 @@
; set to 0 if you can't go past the top or bottom of the menu
ds 1
-wcc4b:: ds 2 ; used as a joypad storage value
-wcc4d:: ds 1 ; used in sprite hiding/showing related operations
+wCheckFor180DegreeTurn:: ; cc4b
+; whether to check for 180-degree turn (0 = don't, 1 = do)
+ ds 1
+ ds 1
+
+wMissableObjectIndex:: ; cc4d
+ ds 1
+
wPredefID:: ; cc4e
ds 1
wPredefRegisters:: ; cc4f
@@ -979,11 +985,19 @@
wTradedEnemyMonOTID:: ; cd59
ds 2
+wStandingOnWarpPadOrHole:: ; cd5b
+; 0 = neither
+; 1 = warp pad
+; 2 = hole
+
wOAMBaseTile:: ; cd5b
-wcd5b:: ds 1 ; used in some sprite stuff, town map and surge gym trash cans
-wcd5c:: ds 1 ; used in town map
+wGymTrashCanIndex:: ; cd5b
+ ds 1
+wSymmetricSpriteOAMAttributes:: ; cd5c
+ ds 1
+
wMonPartySpriteSpecies:: ; cd5d
ds 1
@@ -1049,6 +1063,8 @@
; second buffer for temporarily saving and restoring current screen's tiles (e.g. if menus are drawn on top)
ds 20 * 18
+wNamingScreenNameLength:: ; cee9
+
wEvoOldSpecies:: ; cee9
wBuffer:: ; cee9
@@ -1066,11 +1082,18 @@
wHPBarMaxHP:: ; cee9
ds 1
+wNamingScreenSubmitName:: ; ceea
+; non-zero when the player has chosen to submit the name
+
wChangeMonPicPlayerTurnSpecies:: ; ceea
wEvoNewSpecies:: ; ceea
ds 1
+wAlphabetCase:: ; ceeb
+; 0 = upper case
+; 1 = lower case
+
wEvoMonTileOffset:: ; ceeb
wHPBarOldHP:: ; ceeb
@@ -1079,14 +1102,18 @@
wEvoCancelled:: ; ceec
ds 1
+wNamingScreenLetter:: ; ceed
+
wHPBarNewHP:: ; ceed
ds 2
wHPBarDelta:: ; ceef
ds 1
-wcef0:: ds 1 ; used with HP bar stuff, probably used with wBuffer too.
-wcef1:: ds 12 ; same case as above
+wHPBarTempHP:: ; cef0
+ ds 2
+ ds 11
+
wHPBarHPDifference:: ; cefd
ds 1
ds 7
@@ -1356,10 +1383,17 @@
ds 2
ds 1
wd036:: ds 16 ; used as a temporary buffer to print "XXX learned YYY"
-wd046:: ds 1 ; used with trainer pointer stuff (not exactly sure, but the label is incremented and loaded with a value, so wd047 is accessed)
-wd047:: ds 1 ; used with unloading trainer data?
-wd048:: ds 2 ; used as a pointer for missable object loop
+wTrainerBaseMoney:: ; d046
+; 2-byte BCD number
+; money received after battle = base money × level of highest-level enemy mon
+ ds 2
+
+wMissableObjectCounter:: ; d048
+ ds 1
+
+ ds 1
+
W_TRAINERNAME:: ; d04a
; 13 bytes for the letters of the opposing trainer
; the name is terminated with $50 with possible
@@ -1367,6 +1401,7 @@
ds 13
W_ISINBATTLE:: ; d057
+; lost battle, this is -1
; no battle, this is 0
; wild battle, this is 1
; trainer battle, this is 2
@@ -1513,11 +1548,17 @@
; non-zero when an item or move that allows escape from battle was used
ds 1
-wAmountMoneyWon:: ; wd079 - wd07b
-wd079:: ds 1 ; used as a value to print the money won from a battle, as well as a misc. value in seafoam
-wd07a:: ds 1 ; same case as above
-wd07b:: ds 1 ; used as a buffer to convert the money won from a battle into BCD
+wAmountMoneyWon:: ; d079
+; 3-byte BCD number
+wObjectToHide:: ; d079
+ ds 1
+
+wObjectToShow:: ; d07a
+ ds 1
+
+ ds 1
+
W_ANIMATIONID:: ; d07c
; ID number of the current battle animation
ds 1
@@ -1551,7 +1592,8 @@
; counts how many tiles of the current frame block have been drawn
ds 1
-wd085:: ds 1 ; used with animating water/flowers
+wMovingBGTilesCounter2:: ; d085
+ ds 1
W_SUBANIMFRAMEDELAY:: ; d086
; duration of each frame of the current subanimation in terms of screen refreshes
@@ -1816,7 +1858,8 @@
wMovesString:: ; d0e1
ds 56
-wd119:: ds 1 ; written to from W_CURMAPTILESET but never read
+wUnusedD119:: ; d119
+ ds 1
wWalkBikeSurfStateCopy:: ; d11a
; wWalkBikeSurfState is sometimes copied here, but it doesn't seem to be used for anything
@@ -1826,19 +1869,40 @@
; the type of list for InitList to init
ds 1
-wd11c:: ds 1 ; temp storage value for catching pokemon
-wd11d:: ds 1 ; used with battle switchout and testing if the enemy mon fainted
+wCapturedMonSpecies:: ; d11c
+; 0 if no mon was captured
+ ds 1
+
+wFirstMonsNotOutYet:: ; d11d
+; Non-zero when the first player mon and enemy mon haven't been sent out yet.
+; It prevents the game from asking if the player wants to choose another mon
+; when the enemy sends out their first mon and suppresses the "no will to fight"
+; message when the game searches for the first non-fainted mon in the party,
+; which will be the first mon sent out.
+ ds 1
+
wd11e:: ds 1 ; used as a Pokemon and Item storage value. Also used as an output value for CountSetBits
-wd11f:: ds 1 ; used when running from battle and PartyMenuInit
+wForcePlayerToChooseMon:: ; d11f
+; When this value is non-zero, the player isn't allowed to exit the party menu
+; by pressing B and not choosing a mon.
+ ds 1
+
wNumRunAttempts::
; number of times the player has tried to run from battle
ds 1
-wd121:: ds 1 ; used with evolving pokemon
-wd122:: ds 2 ; saved ROM bank number for vblank
-wIsKeyItem:: ds 1 ; d124
+wEvolutionOccurred:: ; d121
+ ds 1
+wVBlankSavedROMBank:: ; d122
+ ds 1
+
+ ds 1
+
+wIsKeyItem:: ; d124
+ ds 1
+
wTextBoxID:: ; d125
ds 1
@@ -2664,9 +2728,13 @@
ds 2
-wd743:: ds 1 ; used with surge gym trash cans
-wd744:: ds 3 ; also used with surge gym trash cans
+wFirstLockTrashCanIndex:: ; d743
+ ds 1
+wSecondLockTrashCanIndex:: ; d743
+ ds 1
+
+ ds 2
wEventFlags:: ; d747
ds 320