Skip to content

Commit

Permalink
Identify wcf91 as wCurPartySpecies, wCurItem, and wCurListMenuItem (#457
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Rangi42 authored Aug 4, 2024
1 parent 6e3ab0a commit 77d0514
Show file tree
Hide file tree
Showing 50 changed files with 181 additions and 177 deletions.
6 changes: 3 additions & 3 deletions engine/battle/animations.asm
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ DoSpecialEffectByAnimationId:
INCLUDE "data/battle_anims/special_effects.asm"

DoBallTossSpecialEffects:
ld a, [wcf91]
ld a, [wCurItem]
cp ULTRA_BALL + 1 ; is it a Master Ball or Ultra Ball?
jr nc, .skipFlashingEffect
.flashingEffect ; do a flashing effect if it's Master Ball or Ultra Ball
Expand Down Expand Up @@ -2031,7 +2031,7 @@ ChangeMonPic:
and a
jr z, .playerTurn
ld a, [wChangeMonPicEnemyTurnSpecies]
ld [wcf91], a
ld [wCurPartySpecies], a
ld [wd0b5], a
xor a
ld [wSpriteFlipped], a
Expand Down Expand Up @@ -2599,7 +2599,7 @@ TossBallAnimation:

ld hl, .PokeBallAnimations
; choose which toss animation to use
ld a, [wcf91]
ld a, [wCurItem]
cp POKE_BALL
ld b, TOSS_ANIM
jr z, .done
Expand Down
2 changes: 1 addition & 1 deletion engine/battle/common_text.asm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PrintBeginningBattleText:
ld b, SILPH_SCOPE
call IsItemInBag
ld a, [wEnemyMonSpecies2]
ld [wcf91], a
ld [wCurPartySpecies], a
cp RESTLESS_SOUL
jr z, .isMarowak
ld a, b
Expand Down
30 changes: 15 additions & 15 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ StartBattle:
ld b, 0
add hl, bc
ld a, [hl] ; species
ld [wcf91], a
ld [wCurPartySpecies], a
ld [wBattleMonSpecies2], a
call LoadScreenTilesFromBuffer1
hlcoord 1, 5
Expand Down Expand Up @@ -1353,7 +1353,7 @@ EnemySendOutFirstMon:
add hl, bc
ld a, [hl]
ld [wEnemyMonSpecies2], a
ld [wcf91], a
ld [wCurPartySpecies], a
call LoadEnemyMonData
ld hl, wEnemyMonHP
ld a, [hli]
Expand Down Expand Up @@ -1420,7 +1420,7 @@ EnemySendOutFirstMon:
ld hl, TrainerSentOutText
call PrintText
ld a, [wEnemyMonSpecies2]
ld [wcf91], a
ld [wCurPartySpecies], a
ld [wd0b5], a
call GetMonHeader
ld de, vFrontPic
Expand Down Expand Up @@ -1759,7 +1759,7 @@ SendOutMon:
call PlayMoveAnimation
hlcoord 4, 11
predef AnimateSendingOutMon
ld a, [wcf91]
ld a, [wCurPartySpecies]
call PlayCry
call PrintEmptyString
jp SaveScreenTilesToBuffer1
Expand Down Expand Up @@ -1841,7 +1841,7 @@ DrawPlayerHUDAndHPBar:
call PrintLevel
.doNotPrintLevel
ld a, [wLoadedMonSpecies]
ld [wcf91], a
ld [wCurPartySpecies], a
hlcoord 10, 9
predef DrawHP
ld a, $1
Expand Down Expand Up @@ -2159,7 +2159,7 @@ DisplayBattleMenu::
jp LoadScreenTilesFromBuffer1 ; restore saved screen and return
.throwSafariBallWasSelected
ld a, SAFARI_BALL
ld [wcf91], a
ld [wCurItem], a
jr UseBagItem

.upperLeftMenuItemWasNotSelected ; a menu item other than the upper left item was selected
Expand All @@ -2184,7 +2184,7 @@ DisplayBattleMenu::

; bait was selected
ld a, SAFARI_BAIT
ld [wcf91], a
ld [wCurItem], a
jr UseBagItem

BagWasSelected:
Expand Down Expand Up @@ -2236,7 +2236,7 @@ DisplayBagMenu:

UseBagItem:
; either use an item from the bag or use a safari zone item
ld a, [wcf91]
ld a, [wCurItem]
ld [wd11e], a
call GetItemName
call CopyToStringBuffer
Expand Down Expand Up @@ -2305,7 +2305,7 @@ PartyMenuOrRockOrRun:
jr nz, .partyMenuWasSelected
; safari battle
ld a, SAFARI_ROCK
ld [wcf91], a
ld [wCurItem], a
jp UseBagItem
.partyMenuWasSelected
call LoadScreenTilesFromBuffer1
Expand Down Expand Up @@ -2379,7 +2379,7 @@ PartyMenuOrRockOrRun:
jr nz, .doEnemyMonAnimation
; enemy mon is not minimised
ld a, [wEnemyMonSpecies]
ld [wcf91], a
ld [wCurPartySpecies], a
ld [wd0b5], a
call GetMonHeader
ld de, vFrontPic
Expand Down Expand Up @@ -6771,7 +6771,7 @@ InitBattle::

InitOpponent:
ld a, [wCurOpponent]
ld [wcf91], a
ld [wCurPartySpecies], a
ld [wEnemyMonSpecies2], a
jr InitBattleCommon

Expand Down Expand Up @@ -6847,14 +6847,14 @@ InitWildBattle:
ld a, "T"
ld [hli], a
ld [hl], "@"
ld a, [wcf91]
ld a, [wCurPartySpecies]
push af
ld a, MON_GHOST
ld [wcf91], a
ld [wCurPartySpecies], a
ld de, vFrontPic
call LoadMonFrontSprite ; load ghost sprite
pop af
ld [wcf91], a
ld [wCurPartySpecies], a
jr .spriteLoaded
.isNoGhost
ld de, vFrontPic
Expand Down Expand Up @@ -7030,7 +7030,7 @@ LoadMonBackPic:
; Assumes the monster's attributes have
; been loaded with GetMonHeader.
ld a, [wBattleMonSpecies2]
ld [wcf91], a
ld [wCurPartySpecies], a
hlcoord 1, 5
ld b, 7
ld c, 8
Expand Down
2 changes: 1 addition & 1 deletion engine/battle/misc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,5 @@ GetMonSpecies:
ld d, 0
add hl, de
ld a, [hl]
ld [wcf91], a
ld [wCurPartySpecies], a
ret
4 changes: 2 additions & 2 deletions engine/battle/read_trainer_party.asm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ReadTrainer:
ld a, [hli]
and a ; have we reached the end of the trainer data?
jr z, .FinishUp
ld [wcf91], a ; write species somewhere (XXX why?)
ld [wCurPartySpecies], a
ld a, ENEMY_PARTY_DATA
ld [wMonDataLocation], a
push hl
Expand All @@ -71,7 +71,7 @@ ReadTrainer:
jr z, .AddLoneMove
ld [wCurEnemyLevel], a
ld a, [hli]
ld [wcf91], a
ld [wCurPartySpecies], a
ld a, ENEMY_PARTY_DATA
ld [wMonDataLocation], a
push hl
Expand Down
2 changes: 1 addition & 1 deletion engine/battle/wild_encounters.asm
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ TryDoWildEncounter:
ld a, [hli]
ld [wCurEnemyLevel], a
ld a, [hl]
ld [wcf91], a
ld [wCurPartySpecies], a
ld [wEnemyMonSpecies2], a
ld a, [wRepelRemainingSteps]
and a
Expand Down
2 changes: 1 addition & 1 deletion engine/debug/debug_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ TestBattle: ; unreferenced except in _DEBUG

; Give the player a level 20 Rhydon.
ld a, RHYDON
ld [wcf91], a
ld [wCurPartySpecies], a
ld a, 20
ld [wCurEnemyLevel], a
xor a
Expand Down
4 changes: 2 additions & 2 deletions engine/debug/debug_party.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SetDebugNewGameParty: ; unreferenced except in _DEBUG
ld a, [de]
cp -1
ret z
ld [wcf91], a
ld [wCurPartySpecies], a
inc de
ld a, [de]
ld [wCurEnemyLevel], a
Expand Down Expand Up @@ -97,7 +97,7 @@ IF DEF(_DEBUG)
ld a, [de]
cp -1
jr z, .items_end
ld [wcf91], a
ld [wCurItem], a
inc de
ld a, [de]
inc de
Expand Down
4 changes: 2 additions & 2 deletions engine/events/give_pokemon.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _GivePokemon::
; add to box
xor a
ld [wEnemyBattleStatus3], a
ld a, [wcf91]
ld a, [wCurPartySpecies]
ld [wEnemyMonSpecies2], a
callfar LoadEnemyMonData
call SetPokedexOwnedFlag
Expand Down Expand Up @@ -52,7 +52,7 @@ _GivePokemon::
ret

SetPokedexOwnedFlag:
ld a, [wcf91]
ld a, [wCurPartySpecies]
push af
ld [wd11e], a
predef IndexToPokedex
Expand Down
7 changes: 3 additions & 4 deletions engine/events/hidden_objects/museum_fossils.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AerodactylFossil:
ld a, FOSSIL_AERODACTYL
ld [wcf91], a
ld [wCurPartySpecies], a
call DisplayMonFrontSpriteInBox
call EnableAutoTextBoxDrawing
tx_pre AerodactylFossilText
Expand All @@ -12,7 +12,7 @@ AerodactylFossilText::

KabutopsFossil:
ld a, FOSSIL_KABUTOPS
ld [wcf91], a
ld [wCurPartySpecies], a
call DisplayMonFrontSpriteInBox
call EnableAutoTextBoxDrawing
tx_pre KabutopsFossilText
Expand All @@ -24,7 +24,6 @@ KabutopsFossilText::

DisplayMonFrontSpriteInBox:
; Displays a pokemon's front sprite in a pop-up window.
; [wcf91] = pokemon internal id number
ld a, 1
ldh [hAutoBGTransferEnabled], a
call Delay3
Expand All @@ -35,7 +34,7 @@ DisplayMonFrontSpriteInBox:
ld [wTextBoxID], a
call DisplayTextBoxID
call UpdateSprites
ld a, [wcf91]
ld a, [wCurPartySpecies]
ld [wd0b5], a
call GetMonHeader
ld de, vChars1 tile $31
Expand Down
2 changes: 1 addition & 1 deletion engine/events/hidden_objects/route_15_binoculars.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Route15GateLeftBinoculars:
call EnableAutoTextBoxDrawing
tx_pre Route15UpstairsBinocularsText
ld a, ARTICUNO
ld [wcf91], a
ld [wCurPartySpecies], a
call PlayCry
jp DisplayMonFrontSpriteInBox

Expand Down
4 changes: 2 additions & 2 deletions engine/events/in_game_trades.asm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ InGameTrade_DoTrade:
jp c, .tradeFailed ; jump if the player didn't select a pokemon
ld a, [wInGameTradeGiveMonSpecies]
ld b, a
ld a, [wcf91]
ld a, [wCurPartySpecies]
cp b
ld a, $2
jr nz, .tradeFailed ; jump if the selected mon's species is not the required one
Expand Down Expand Up @@ -128,7 +128,7 @@ InGameTrade_DoTrade:
pop af
ld [wWhichPokemon], a
ld a, [wInGameTradeReceiveMonSpecies]
ld [wcf91], a
ld [wCurPartySpecies], a
xor a
ld [wMonDataLocation], a ; not used
ld [wRemoveMonFromBox], a
Expand Down
4 changes: 2 additions & 2 deletions engine/events/pokemart.asm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ DisplayPokemartDialogue_::
ld a, [wIsKeyItem]
and a
jr nz, .unsellableItem
ld a, [wcf91]
ld a, [wCurItem]
call IsItemHM
jr c, .unsellableItem
ld a, PRICEDITEMLISTMENU
Expand Down Expand Up @@ -156,7 +156,7 @@ DisplayPokemartDialogue_::
call DisplayChooseQuantityMenu
inc a
jr z, .buyMenuLoop ; if the player closed the choose quantity menu with the B button
ld a, [wcf91] ; item ID
ld a, [wCurItem]
ld [wd11e], a ; store item ID for GetItemName
call GetItemName
call CopyToStringBuffer
Expand Down
4 changes: 2 additions & 2 deletions engine/events/prize_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ HandlePrizeChoice:
jr .subtractCoins
.giveMon
ld a, [wd11e]
ld [wcf91], a
ld [wCurPartySpecies], a
push af
call GetPrizeMonLevel
ld c, a
Expand Down Expand Up @@ -287,7 +287,7 @@ OhFineThenTextPtr:
text_end

GetPrizeMonLevel:
ld a, [wcf91]
ld a, [wCurPartySpecies]
ld b, a
ld hl, PrizeMonLevelDictionary
.loop
Expand Down
4 changes: 2 additions & 2 deletions engine/gfx/mon_icons.asm
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ WriteMonPartySpriteOAMBySpecies:
UnusedPartyMonSpriteFunction:
; This function is unused and doesn't appear to do anything useful. It looks
; like it may have been intended to load the tile patterns and OAM data for
; the mon party sprite associated with the species in [wcf91].
; the mon party sprite associated with the species in [wCurPartySpecies].
; However, its calculations are off and it loads garbage data.
ld a, [wcf91]
ld a, [wCurPartySpecies]
call GetPartyMonSpriteID
push af
ld hl, vSprites tile $00
Expand Down
4 changes: 2 additions & 2 deletions engine/gfx/palettes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ SetPal_StatusScreen:
ld de, wPalPacket
ld bc, $10
call CopyData
ld a, [wcf91]
ld a, [wCurPartySpecies]
cp NUM_POKEMON_INDEXES + 1
jr c, .pokemon
ld a, $1 ; not pokemon
Expand Down Expand Up @@ -97,7 +97,7 @@ SetPal_Pokedex:
ld de, wPalPacket
ld bc, $10
call CopyData
ld a, [wcf91]
ld a, [wCurPartySpecies]
call DeterminePaletteIDOutOfBattle
ld hl, wPalPacket + 3
ld [hl], a
Expand Down
6 changes: 3 additions & 3 deletions engine/items/inventory.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; function to add an item (in varying quantities) to the player's bag or PC box
; INPUT:
; hl = address of inventory (either wNumBagItems or wNumBoxItems)
; [wcf91] = item ID
; [wCurItem] = item ID
; [wItemQuantity] = item quantity
; sets carry flag if successful, unsets carry flag if unsuccessful
AddItemToInventory_::
Expand Down Expand Up @@ -30,7 +30,7 @@ AddItemToInventory_::
.notAtEndOfInventory
ld a, [hli]
ld b, a ; b = ID of current item in table
ld a, [wcf91] ; a = ID of item being added
ld a, [wCurItem] ; a = ID of item being added
cp b ; does the current item in the table match the item being added?
jp z, .increaseItemQuantity ; if so, increase the item's quantity
inc hl
Expand All @@ -50,7 +50,7 @@ AddItemToInventory_::
ld c, a
ld b, 0
add hl, bc ; hl = address to store the item
ld a, [wcf91]
ld a, [wCurItem]
ld [hli], a ; store item ID
ld a, [wItemQuantity]
ld [hli], a ; store item quantity
Expand Down
Loading

0 comments on commit 77d0514

Please sign in to comment.