summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rwxr-xr-xengine/battle/core.asm2
-rwxr-xr-xengine/hidden_object_functions17.asm19
-rwxr-xr-xengine/hidden_object_functions18.asm2
-rwxr-xr-xengine/hidden_object_functions7.asm32
-rwxr-xr-xengine/items/items.asm18
-rwxr-xr-xengine/menu/main_menu.asm4
-rwxr-xr-xengine/menu/party_menu.asm2
-rwxr-xr-xengine/menu/prize_menu.asm36
-rwxr-xr-xengine/menu/start_sub_menus.asm12
-rwxr-xr-xengine/overworld/npc_movement.asm6
-rwxr-xr-xengine/overworld/pewter_guys.asm18
-rwxr-xr-xengine/overworld/trainers.asm16
12 files changed, 91 insertions, 76 deletions
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index b3d82f8c..77f0c0c6 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -2310,7 +2310,7 @@ UseBagItem:
call GetItemName
call CopyStringToCF4B ; copy name
xor a
- ld [wd152], a
+ ld [wPseudoItemID], a
call UseItem
call LoadHudTilePatterns
call ClearSprites
diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm
index 788dd777..aad8c468 100755
--- a/engine/hidden_object_functions17.asm
+++ b/engine/hidden_object_functions17.asm
@@ -349,12 +349,21 @@ GymTrashScript: ; 5ddfc (17:5dfc)
add hl, de
ld a, [hli]
- ld [$ffdb], a
+; There is a bug in this code. It should calculate a value in the range [0, 3]
+; but if the mask and random number don't have any 1 bits in common, then
+; the result of the AND will be 0. When 1 is subtracted from that, the value
+; will become $ff. This will result in 255 being added to hl, which will cause
+; hl to point to one of the zero bytes that pad the end of the ROM bank.
+; Trash can 0 was intended to be able to have the second lock only when the
+; first lock was in trash can 1 or 3. However, due to this bug, trash can 0 can
+; have the second lock regardless of which trash can had the first lock.
+
+ ld [hGymTrashCanRandNumMask], a
push hl
call Random
swap a
ld b, a
- ld a, [$ffdb]
+ ld a, [hGymTrashCanRandNumMask]
and b
dec a
pop hl
@@ -398,6 +407,12 @@ GymTrashScript: ; 5ddfc (17:5dfc)
jp PrintPredefTextID
GymTrashCans: ; 5de7d (17:5e7d)
+; byte 0: mask for random number
+; bytes 1-4: indices of the trash cans that can have the second lock
+; (but see the comment above explaining a bug regarding this)
+; Note that the mask is simply the number of valid trash can indices that
+; follow. The remaining bytes are filled with 0 to pad the length of each entry
+; to 5 bytes.
db 2, 1, 3, 0, 0 ; 0
db 3, 0, 2, 4, 0 ; 1
db 2, 1, 5, 0, 0 ; 2
diff --git a/engine/hidden_object_functions18.asm b/engine/hidden_object_functions18.asm
index 00744c5d..0a93fd44 100755
--- a/engine/hidden_object_functions18.asm
+++ b/engine/hidden_object_functions18.asm
@@ -19,7 +19,7 @@ GymStatues: ; 62419 (18:6419)
jr .loop
.match
ld b, [hl]
- ld a, [wd72a]
+ ld a, [wBeatGymFlags]
and b
cp b
tx_pre_id GymStatueText2
diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm
index 4e76d996..e3c296ca 100755
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -125,21 +125,21 @@ PrintCinnabarQuiz: ; 1ea17 (7:6a17)
CinnabarGymQuiz: ; 1ea25 (7:6a25)
TX_ASM
xor a
- ld [wda38], a
+ ld [wOpponentAfterWrongAnswer], a
ld a, [wHiddenObjectFunctionArgument]
push af
and $f
- ld [$ffdb], a
+ ld [hGymGateIndex], a
pop af
and $f0
swap a
ld [$ffdc], a
ld hl, CinnabarGymQuizIntroText
call PrintText
- ld a, [$ffdb]
+ ld a, [hGymGateIndex]
dec a
add a
- ld d, $0
+ ld d, 0
ld e, a
ld hl, CinnabarQuizQuestions
add hl, de
@@ -198,10 +198,10 @@ CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92)
ld c, a
ld a, [wCurrentMenuItem]
cp c
- jr nz, .asm_1eab8
+ jr nz, .wrongAnswer
ld hl, wd126
set 5, [hl]
- ld a, [$ffdb]
+ ld a, [hGymGateIndex]
ld [$ffe0], a
ld hl, CinnabarGymQuizCorrectText
call PrintText
@@ -211,14 +211,14 @@ CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92)
ld b, FLAG_SET
call CinnabarGymGateFlagAction
jp UpdateCinnabarGymGateTileBlocks_
-.asm_1eab8
+.wrongAnswer
call WaitForSoundToFinish
ld a, SFX_DENIED
call PlaySound
call WaitForSoundToFinish
ld hl, CinnabarGymQuizIncorrectText
call PrintText
- ld a, [$ffdb]
+ ld a, [hGymGateIndex]
add $2
AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2
ld c, a
@@ -228,9 +228,9 @@ CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92)
ld a, c
and a
ret nz
- ld a, [$ffdb]
+ ld a, [hGymGateIndex]
add $2
- ld [wda38], a
+ ld [wOpponentAfterWrongAnswer], a
ret
CinnabarGymQuizCorrectText: ; 1eae3 (7:6ae3)
@@ -261,9 +261,9 @@ UpdateCinnabarGymGateTileBlocks_: ; 1eb0a (7:6b0a)
; Update the overworld map with open floor blocks or locked gate blocks
; depending on event flags.
ld a, 6
- ld [$ffdb], a
+ ld [hGymGateIndex], a
.loop
- ld a, [$ffdb]
+ ld a, [hGymGateIndex]
dec a
add a
add a
@@ -276,9 +276,9 @@ UpdateCinnabarGymGateTileBlocks_: ; 1eb0a (7:6b0a)
ld c, a
inc hl
ld a, [hl]
- ld [wd12f], a
+ ld [wGymGateTileBlock], a
push bc
- ld a, [$ffdb]
+ ld a, [hGymGateIndex]
ld [$ffe0], a
AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0
ld c, a
@@ -287,7 +287,7 @@ UpdateCinnabarGymGateTileBlocks_: ; 1eb0a (7:6b0a)
ld a, c
and a
jr nz, .unlocked
- ld a, [wd12f]
+ ld a, [wGymGateTileBlock]
jr .next
.unlocked
ld a, $e
@@ -295,7 +295,7 @@ UpdateCinnabarGymGateTileBlocks_: ; 1eb0a (7:6b0a)
pop bc
ld [wNewTileBlockID], a
predef ReplaceTileBlock
- ld hl, $ffdb
+ ld hl, hGymGateIndex
dec [hl]
jr nz, .loop
ret
diff --git a/engine/items/items.asm b/engine/items/items.asm
index 5669f012..7f16691d 100755
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -628,7 +628,7 @@ ItemUseEvoStone: ; da5b (3:5a5b)
ld a,[wWhichPokemon]
push af
ld a,[wcf91]
- ld [wd156],a
+ ld [wEvoStoneItemID],a
push af
ld a,EVO_STONE_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a
@@ -679,7 +679,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [wPartyMenuTypeOrMessageID],a
ld a,$ff
ld [wUpdateSpritesEnabled],a
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
jr z,.notUsingSoftboiled
; if using softboiled
@@ -712,7 +712,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [wcf91],a
pop af
ld [wWhichPokemon],a
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
jr z,.checkItemType
; if using softboiled
@@ -865,7 +865,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [wHPBarMaxHP+1],a
ld a,[hl]
ld [wHPBarMaxHP],a ; max HP stored at wHPBarMaxHP (2 bytes, big-endian)
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
jp z,.notUsingSoftboiled2
; if using softboiled
@@ -1052,7 +1052,7 @@ ItemUseMedicine: ; dabb (3:5abb)
call ItemUseNoEffect
jp .done
.doneHealing
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
jr nz,.skipRemovingItem ; no item to remove if using Softboiled
push hl
@@ -1107,7 +1107,7 @@ ItemUseMedicine: ; dabb (3:5abb)
pop af
pop af
.done
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
ret nz ; if so, return
call GBPalWhiteOut
@@ -1381,7 +1381,7 @@ ItemUseEscapeRope: ; dfaf (3:5faf)
inc a
ld [wEscapedFromBattle],a
ld [wActionResultOrTookBattleTurn],a ; item used
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Dig?
ret nz ; if so, return
call ItemUseReloadOverworldData
@@ -1419,7 +1419,7 @@ ItemUseXAccuracy: ; e013 (3:6013)
; The Card Key is handled in a different way.
ItemUseCardKey: ; e022 (3:6022)
xor a
- ld [wd71f],a
+ ld [wUnusedD71F],a
call GetTileAndCoordsInFrontOfPlayer
ld a,[GetTileAndCoordsInFrontOfPlayer] ; $4586
cp a,$18
@@ -1451,7 +1451,7 @@ ItemUseCardKey: ; e022 (3:6022)
cp e
jr nz,.nextEntry3
ld a,[hl]
- ld [wd71f],a
+ ld [wUnusedD71F],a
jr .done
.nextEntry1
inc hl
diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm
index a46abf2a..994841d3 100755
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -278,7 +278,7 @@ LinkMenu: ; 5c0a (1:5c0a)
ld [wSerialExchangeNybbleSendData], a
inc a ; LINK_STATE_IN_CABLE_CLUB
ld [wLinkState], a
- ld [wcc47], a
+ ld [wEnteringCableClub], a
jr SpecialEnterMap
.choseCancel
xor a
@@ -322,7 +322,7 @@ SpecialEnterMap: ; 5d5f (1:5d5f)
call ResetPlayerSpriteData
ld c, 20
call DelayFrames
- ld a, [wcc47]
+ ld a, [wEnteringCableClub]
and a
ret nz
jp EnterMap
diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm
index 00ae3912..42ab553a 100755
--- a/engine/menu/party_menu.asm
+++ b/engine/menu/party_menu.asm
@@ -167,7 +167,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
dec hl
dec hl
ld b,[hl]
- ld a,[wd156] ; evolution stone item ID
+ ld a,[wEvoStoneItemID] ; the stone the player used
inc hl
inc hl
inc hl
diff --git a/engine/menu/prize_menu.asm b/engine/menu/prize_menu.asm
index f2f2a794..2bf932ba 100755
--- a/engine/menu/prize_menu.asm
+++ b/engine/menu/prize_menu.asm
@@ -65,11 +65,11 @@ GetPrizeMenuId: ; 5278e (14:678e)
; (distinguishing between Pokemon names
; and Items (specifically TMs) names)
ld a,[hSpriteIndexOrTextID]
- sub a,$03 ; prize-texts' id are 3, 4 and 5
- ld [wd12f],a ; prize-texts' id (relative, i.e. 0, 1 or 2)
+ sub a,3 ; prize-texts' id are 3, 4 and 5
+ ld [wWhichPrizeWindow],a ; prize-texts' id (relative, i.e. 0, 1 or 2)
add a
add a
- ld d,$00
+ ld d,0
ld e,a
ld hl,PrizeDifferentMenuPtrs
add hl,de
@@ -84,10 +84,10 @@ GetPrizeMenuId: ; 5278e (14:678e)
ld a,[hli]
ld h,[hl]
ld l,a
- ld de,wd141
- ld bc,$0006
+ ld de,wPrize1Price
+ ld bc,6
call CopyData
- ld a,[wd12f]
+ ld a,[wWhichPrizeWindow]
cp a,$02 ;is TM_menu?
jr nz,.putMonName
ld a,[W_PRIZE1]
@@ -127,7 +127,7 @@ GetPrizeMenuId: ; 5278e (14:678e)
ld de,NoThanksText
call PlaceString
; put prices on the right side of the textbox
- ld de,wd141
+ ld de,wPrize1Price
coord hl, 13, 5
; reg. c:
; [low nybble] number of bytes
@@ -136,11 +136,11 @@ GetPrizeMenuId: ; 5278e (14:678e)
; Function $15CD displays BCD value (same routine
; used by text-command $02)
call PrintBCDNumber
- ld de,wd143
+ ld de,wPrize2Price
coord hl, 13, 7
ld c,(%1 << 7 | 2)
call PrintBCDNumber
- ld de,wd145
+ ld de,wPrize3Price
coord hl, 13, 9
ld c,(1 << 7 | 2)
jp PrintBCDNumber
@@ -172,11 +172,11 @@ PrintPrizePrice: ; 5287a (14:687a)
db " @"
LoadCoinsToSubtract: ; 528b1 (14:68b1)
- ld a,[wd139] ; backup of selected menu_entry
+ ld a,[wWhichPrize]
add a
- ld d,$00
+ ld d,0
ld e,a
- ld hl,wd141 ; first prize's price
+ ld hl,wPrize1Price
add hl,de ; get selected prize's price
xor a
ld [hUnusedCoinsByte],a
@@ -187,15 +187,15 @@ LoadCoinsToSubtract: ; 528b1 (14:68b1)
ret
HandlePrizeChoice: ; 528c6 (14:68c6)
- ld a,[wCurrentMenuItem] ; selected menu_entry
- ld [wd139],a
- ld d,$00
+ ld a,[wCurrentMenuItem]
+ ld [wWhichPrize],a
+ ld d,0
ld e,a
ld hl,W_PRIZE1
add hl,de
ld a,[hl]
ld [wd11e],a
- ld a,[wd12f]
+ ld a,[wWhichPrizeWindow]
cp a,$02 ; is prize a TM?
jr nz,.GetMonName
call GetItemName
@@ -205,14 +205,14 @@ HandlePrizeChoice: ; 528c6 (14:68c6)
.GivePrize
ld hl,SoYouWantPrizeTextPtr
call PrintText
- call YesNoChoice ; yes/no textbox
+ call YesNoChoice
ld a,[wCurrentMenuItem] ; yes/no answer (Y=0, N=1)
and a
jr nz,.PrintOhFineThen
call LoadCoinsToSubtract
call HasEnoughCoins
jr c,.NotEnoughCoins
- ld a,[wd12f]
+ ld a,[wWhichPrizeWindow]
cp a,$02
jr nz,.GiveMon
ld a,[wd11e]
diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm
index 481c0fbe..0895258c 100755
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -167,7 +167,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
jp z,.loop
ld a,SURFBOARD
ld [wcf91],a
- ld [wd152],a
+ ld [wPseudoItemID],a
call UseItem
ld a,[wActionResultOrTookBattleTurn]
and a
@@ -195,7 +195,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
.dig
ld a,ESCAPE_ROPE
ld [wcf91],a
- ld [wd152],a
+ ld [wPseudoItemID],a
call UseItem
ld a,[wActionResultOrTookBattleTurn]
and a
@@ -260,7 +260,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
push af
ld a,POTION
ld [wcf91],a
- ld [wd152],a
+ ld [wPseudoItemID],a
call UseItem
pop af
ld [wPartyAndBillsPCSavedMenuItem],a
@@ -381,8 +381,8 @@ StartMenu_Item: ; 13302 (4:7302)
ld a,[wCurrentMenuItem]
and a
jr nz,.tossItem
-.useItem
- ld [wd152],a
+; use item
+ ld [wPseudoItemID],a ; a must be 0 due to above conditional jump
ld a,[wcf91]
cp a,HM_01
jr nc,.useItem_partyMenu
@@ -399,7 +399,7 @@ StartMenu_Item: ; 13302 (4:7302)
jp ItemMenuLoop
.useItem_closeMenu
xor a
- ld [wd152],a
+ ld [wPseudoItemID],a
call UseItem
ld a,[wActionResultOrTookBattleTurn]
and a
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index c9265f3e..0c01e38c 100755
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -178,7 +178,7 @@ PewterMovementScript_WalkToMuseum: ; 1a514 (6:6514)
dec a
ld [wSimulatedJoypadStatesIndex], a
xor a
- ld [wd12f], a
+ ld [wWhichPewterGuy], a
predef PewterGuys
ld hl, wNPCMovementDirections2
ld de, RLEList_PewterMuseumGuy
@@ -234,8 +234,8 @@ PewterMovementScript_WalkToGym: ; 1a581 (6:6581)
call DecodeRLEList
dec a
ld [wSimulatedJoypadStatesIndex], a
- ld a, $1
- ld [wd12f], a
+ ld a, 1
+ ld [wWhichPewterGuy], a
predef PewterGuys
ld hl, wNPCMovementDirections2
ld de, RLEList_PewterGymGuy
diff --git a/engine/overworld/pewter_guys.asm b/engine/overworld/pewter_guys.asm
index fa0dd4a7..4ac60e00 100755
--- a/engine/overworld/pewter_guys.asm
+++ b/engine/overworld/pewter_guys.asm
@@ -9,7 +9,7 @@ PewterGuys: ; 37ca1 (d:7ca1)
ld d, h
ld e, l
ld hl, PointerTable_37ce6
- ld a, [wd12f]
+ ld a, [wWhichPewterGuy]
add a
ld b, 0
ld c, a
@@ -21,17 +21,17 @@ PewterGuys: ; 37ca1 (d:7ca1)
ld b, a
ld a, [W_XCOORD]
ld c, a
-.asm_37cc7
+.findMatchingCoordsLoop
ld a, [hli]
cp b
- jr nz, .asm_37ce1
+ jr nz, .nextEntry1
ld a, [hli]
cp c
- jr nz, .asm_37ce2
+ jr nz, .nextEntry2
ld a, [hli]
ld h, [hl]
ld l, a
-.asm_37cd2
+.copyMovementDataLoop
ld a, [hli]
cp $ff
ret z
@@ -40,13 +40,13 @@ PewterGuys: ; 37ca1 (d:7ca1)
ld a, [wSimulatedJoypadStatesIndex]
inc a
ld [wSimulatedJoypadStatesIndex], a
- jr .asm_37cd2
-.asm_37ce1
+ jr .copyMovementDataLoop
+.nextEntry1
inc hl
-.asm_37ce2
+.nextEntry2
inc hl
inc hl
- jr .asm_37cc7
+ jr .findMatchingCoordsLoop
PointerTable_37ce6: ; 37ce6 (d:7ce6)
dw PewterMuseumGuyCoords
diff --git a/engine/overworld/trainers.asm b/engine/overworld/trainers.asm
index a983881d..7d2ec0dd 100755
--- a/engine/overworld/trainers.asm
+++ b/engine/overworld/trainers.asm
@@ -24,16 +24,16 @@ _GetSpritePosition2: ; 56819 (15:6819)
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
ld a, [hli] ; c1x4 (screen Y pos)
- ld [wd130], a
+ ld [wSavedSpriteScreenY], a
inc hl
ld a, [hl] ; c1x6 (screen X pos)
- ld [wd131], a
+ ld [wSavedSpriteScreenX], a
ld de, $104 - $6
add hl, de
ld a, [hli] ; c2x4 (map Y pos)
- ld [wd132], a
+ ld [wSavedSpriteMapY], a
ld a, [hl] ; c2x5 (map X pos)
- ld [wd133], a
+ ld [wSavedSpriteMapX], a
ret
_SetSpritePosition1: ; 5683d (15:683d)
@@ -61,16 +61,16 @@ _SetSpritePosition2: ; 5685d (15:685d)
ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
- ld a, [wd130]
+ ld a, [wSavedSpriteScreenY]
ld [hli], a
inc hl
- ld a, [wd131]
+ ld a, [wSavedSpriteScreenX]
ld [hl], a
ld de, $00fe
add hl, de
- ld a, [wd132]
+ ld a, [wSavedSpriteMapY]
ld [hli], a
- ld a, [wd133]
+ ld a, [wSavedSpriteMapX]
ld [hl], a
ret