diff options
59 files changed, 360 insertions, 394 deletions
diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index c06e7a65..68090c78 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -121,6 +121,24 @@ BOX_DATA EQU 2 DAYCARE_DATA EQU 3 BATTLE_MON_DATA EQU 4 +; player direction constants + +PLAYER_DIR_BIT_RIGHT EQU 0 +PLAYER_DIR_BIT_LEFT EQU 1 +PLAYER_DIR_BIT_DOWN EQU 2 +PLAYER_DIR_BIT_UP EQU 3 + +PLAYER_DIR_RIGHT EQU (1 << PLAYER_DIR_BIT_RIGHT) +PLAYER_DIR_LEFT EQU (1 << PLAYER_DIR_BIT_LEFT) +PLAYER_DIR_DOWN EQU (1 << PLAYER_DIR_BIT_DOWN) +PLAYER_DIR_UP EQU (1 << PLAYER_DIR_BIT_UP) + +; flag operations + +FLAG_RESET EQU 0 +FLAG_SET EQU 1 +FLAG_TEST EQU 2 + ; serial ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK EQU $01 diff --git a/engine/HoF_room_pc.asm b/engine/HoF_room_pc.asm index 06c926db..5e3ff37b 100755 --- a/engine/HoF_room_pc.asm +++ b/engine/HoF_room_pc.asm @@ -29,7 +29,7 @@ HallOfFamePC: ; 7405c (1d:405c) ld c, 128 call DelayFrames xor a - ld [wNumCreditsMonsDisplayed - 1], a ; not read + ld [wUnusedCD3D], a ; not read ld [wNumCreditsMonsDisplayed], a jp Credits diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 075bc179..a74e0a27 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -187,9 +187,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) ld b, $1 call GoPAL_SET call HideSprites - ld hl, PrintBeginningBattleText - ld b, BANK(PrintBeginningBattleText) - jp Bankswitch + jpab PrintBeginningBattleText ; when a battle is starting, silhouettes of the player's pic and the enemy's pic are slid onto the screen ; the lower of the player's pic (his body) is part of the background, but his head is a sprite @@ -330,7 +328,7 @@ StartBattle: ; 3c11e (f:411e) call SaveScreenTilesToBuffer1 ld a, [wWhichPokemon] ld c, a - ld b, $1 + ld b, FLAG_SET push bc ld hl, wPartyGainExpFlags predef FlagActionPredef @@ -359,9 +357,7 @@ EnemyRan: ; 3c202 (f:4202) call PlaySoundWaitForCurrent xor a ld [H_WHOSETURN], a - ld hl, AnimationSlideEnemyMonOut - ld b, BANK(AnimationSlideEnemyMonOut) - jp Bankswitch + jpab AnimationSlideEnemyMonOut WildRanText: ; 3c229 (f:4229) TX_FAR _WildRanText @@ -938,9 +934,7 @@ FaintEnemyPokemon: ; 0x3c567 jr nz, .gainExpFlagsLoop ld a, b ld [wPartyGainExpFlags], a - ld hl, GainExperience - ld b, BANK(GainExperience) - jp Bankswitch + jpab GainExperience EnemyMonFaintedText: ; 0x3c63e TX_FAR _EnemyMonFaintedText @@ -1087,7 +1081,7 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741) ld a, [wPlayerMonNumber] ld c, a ld hl, wPartyGainExpFlags - ld b, $0 + ld b, FLAG_RESET predef FlagActionPredef ; clear gain exp flag for fainted mon ld hl, W_ENEMYBATTSTATUS1 res 2, [hl] ; reset "attacking multiple times" flag @@ -1187,7 +1181,7 @@ ChooseNextMon: ; 3c7d8 (f:47d8) ld [wPlayerMonNumber], a ld c, a ld hl, wPartyGainExpFlags - ld b, $1 + ld b, FLAG_SET push bc predef FlagActionPredef pop bc @@ -1356,7 +1350,7 @@ EnemySendOut: ; 3c90e (f:490e) ld [hl],a ld a,[wPlayerMonNumber] ld c,a - ld b,1 + ld b,FLAG_SET push bc predef FlagActionPredef ld hl,wPartyFoughtCurrentEnemyFlags @@ -2496,7 +2490,7 @@ SwitchPlayerMon: ; 3d1ba (f:51ba) ld a, [wWhichPokemon] ld [wPlayerMonNumber], a ld c, a - ld b, $1 + ld b, FLAG_SET push bc ld hl, wPartyGainExpFlags predef FlagActionPredef @@ -6302,7 +6296,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01) predef WriteMonMoves ; get moves based on current level .loadMovePPs ld hl, wEnemyMonMoves - ld de, wEnemyMonSpecial + 1 + ld de, wEnemyMonPP - 1 predef LoadMovePPs ld hl, W_MONHBASESTATS ld de, wEnemyMonBaseStats @@ -6332,7 +6326,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01) ld a, [wd11e] dec a ld c, a - ld b, $1 + ld b, FLAG_SET ld hl, wPokedexSeen predef FlagActionPredef ; mark this mon as seen in the pokedex ld hl, wEnemyMonLevel @@ -6462,14 +6456,10 @@ LoadPlayerBackPic: ; 3ec92 (f:6c92) ; does nothing since no stats are ever selected (barring glitches) DoubleOrHalveSelectedStats: ; 3ed02 (f:6d02) callab DoubleSelectedStats - ld hl, HalveSelectedStats - ld b, BANK(HalveSelectedStats) - jp Bankswitch + jpab HalveSelectedStats ScrollTrainerPicAfterBattle: ; 3ed12 (f:6d12) - ld hl, _ScrollTrainerPicAfterBattle - ld b, BANK(_ScrollTrainerPicAfterBattle) - jp Bankswitch + jpab _ScrollTrainerPicAfterBattle ApplyBurnAndParalysisPenaltiesToPlayer: ; 3ed1a (f:6d1a) ld a, $1 @@ -6967,7 +6957,7 @@ InitBattle_Common: ; 3efeb (f:6feb) ld [wLetterPrintingDelayFlags], a pop af ld [wMapPalOffset], a - ld a, [wd0d4] + ld a, [wSavedTilesetType] ld [hTilesetType], a scf ret @@ -7372,9 +7362,7 @@ BadlyPoisonedText: ; 3f2e4 (f:72e4) db "@" DrainHPEffect: ; 3f2e9 (f:72e9) - ld hl, DrainHPEffect_ - ld b, BANK(DrainHPEffect_) - jp Bankswitch + jpab DrainHPEffect_ ExplodeEffect: ; 3f2f1 (f:72f1) ld hl, wBattleMonHP @@ -8209,9 +8197,7 @@ FlinchSideEffect: ; 3f85b (f:785b) ret OneHitKOEffect: ; 3f884 (f:7884) - ld hl, OneHitKOEffect_ - ld b, BANK(OneHitKOEffect_) - jp Bankswitch + jpab OneHitKOEffect_ ChargeEffect: ; 3f88c (f:788c) ld hl, W_PLAYERBATTSTATUS1 @@ -8321,19 +8307,13 @@ TrappingEffect: ; 3f917 (f:7917) ret MistEffect: ; 3f941 (f:7941) - ld hl, MistEffect_ - ld b, BANK(MistEffect_) - jp Bankswitch + jpab MistEffect_ FocusEnergyEffect: ; 3f949 (f:7949) - ld hl, FocusEnergyEffect_ - ld b, BANK(FocusEnergyEffect_) - jp Bankswitch + jpab FocusEnergyEffect_ RecoilEffect: ; 3f951 (f:7951) - ld hl, RecoilEffect_ - ld b, BANK(RecoilEffect_) - jp Bankswitch + jpab RecoilEffect_ ConfusionSideEffect: ; 3f959 (f:7959) call BattleRandom @@ -8387,14 +8367,10 @@ ConfusionEffectFailed: ; 3f9a6 (f:79a6) jp ConditionalPrintButItFailed ParalyzeEffect: ; 3f9b1 (f:79b1) - ld hl, ParalyzeEffect_ - ld b, BANK(ParalyzeEffect_) - jp Bankswitch + jpab ParalyzeEffect_ SubstituteEffect: ; 3f9b9 (f:79b9) - ld hl, SubstituteEffect_ - ld b, BANK(SubstituteEffect_) - jp Bankswitch + jpab SubstituteEffect_ HyperBeamEffect: ; 3f9c1 (f:79c1) ld hl, W_PLAYERBATTSTATUS2 @@ -8505,9 +8481,7 @@ MimicLearnedMoveText: ; 3fa77 (f:7a77) db "@" LeechSeedEffect: ; 3fa7c (f:7a7c) - ld hl, LeechSeedEffect_ - ld b, BANK(LeechSeedEffect_) - jp Bankswitch + jpab LeechSeedEffect_ SplashEffect: ; 3fa84 (f:7a84) call PlayCurrentMoveAnimation @@ -8601,34 +8575,22 @@ MoveWasDisabledText: ; 3fb09 (f:7b09) db "@" PayDayEffect: ; 3fb0e (f:7b0e) - ld hl, PayDayEffect_ - ld b, BANK(PayDayEffect_) - jp Bankswitch + jpab PayDayEffect_ ConversionEffect: ; 3fb16 (f:7b16) - ld hl, ConversionEffect_ - ld b, BANK(ConversionEffect_) - jp Bankswitch + jpab ConversionEffect_ HazeEffect: ; 3fb1e (f:7b1e) - ld hl, HazeEffect_ - ld b, BANK(HazeEffect_) - jp Bankswitch + jpab HazeEffect_ HealEffect: ; 3fb26 (f:7b26) - ld hl, HealEffect_ - ld b, BANK(HealEffect_) - jp Bankswitch + jpab HealEffect_ TransformEffect: ; 3fb2e (f:7b2e) - ld hl, TransformEffect_ - ld b, BANK(TransformEffect_) - jp Bankswitch + jpab TransformEffect_ ReflectLightScreenEffect: ; 3fb36 (f:7b36) - ld hl, ReflectLightScreenEffect_ - ld b, BANK(ReflectLightScreenEffect_) - jp Bankswitch + jpab ReflectLightScreenEffect_ NothingHappenedText: ; 3fb3e (f:7b3e) TX_FAR _NothingHappenedText diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index 6ec8c463..6f479ea3 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -15,7 +15,7 @@ GainExperience: ; 5524f (15:524f) ld hl, wPartyGainExpFlags ld a, [wWhichPokemon] ld c, a - ld b, $2 + ld b, FLAG_TEST predef FlagActionPredef ld a, c and a ; is mon's gain exp flag set? @@ -257,7 +257,7 @@ GainExperience: ; 5524f (15:524f) ld hl, wCanEvolveFlags ld a, [wWhichPokemon] ld c, a - ld b, $1 + ld b, FLAG_SET predef FlagActionPredef pop hl pop af @@ -281,7 +281,7 @@ GainExperience: ; 5524f (15:524f) ld [hl], a ; clear gain exp flags ld a, [wPlayerMonNumber] ld c, a - ld b, $1 + ld b, FLAG_SET push bc predef FlagActionPredef ; set the gain exp flag for the mon that is currently out ld hl, wPartyFoughtCurrentEnemyFlags diff --git a/engine/battle/init_battle_variables.asm b/engine/battle/init_battle_variables.asm index f10e9f5e..3c926858 100644 --- a/engine/battle/init_battle_variables.asm +++ b/engine/battle/init_battle_variables.asm @@ -1,6 +1,6 @@ InitBattleVariables: ; 525af (14:65af) ld a, [hTilesetType] - ld [wd0d4], a + ld [wSavedTilesetType], a xor a ld [wActionResultOrTookBattleTurn], a ld [wBattleResult], a @@ -35,6 +35,4 @@ InitBattleVariables: ; 525af (14:65af) ld a, $2 ; safari battle ld [W_BATTLETYPE], a .notSafariBattle - ld hl, PlayBattleMusic - ld b, BANK(PlayBattleMusic) - jp Bankswitch + jpab PlayBattleMusic diff --git a/engine/battle/moveEffects/focus_energy_effect.asm b/engine/battle/moveEffects/focus_energy_effect.asm index 20a0c07e..b8a783e4 100644 --- a/engine/battle/moveEffects/focus_energy_effect.asm +++ b/engine/battle/moveEffects/focus_energy_effect.asm @@ -14,9 +14,7 @@ FocusEnergyEffect_: ; 27f86 (9:7f86) .alreadyUsing ld c, 50 call DelayFrames - ld hl, PrintButItFailedText_ - ld b, BANK(PrintButItFailedText_) - jp Bankswitch + jpab PrintButItFailedText_ GettingPumpedText: ; 27fb3 (9:7fb3) db $0a diff --git a/engine/battle/moveEffects/mist_effect.asm b/engine/battle/moveEffects/mist_effect.asm index 8394eec1..1f8e40b0 100644 --- a/engine/battle/moveEffects/mist_effect.asm +++ b/engine/battle/moveEffects/mist_effect.asm @@ -12,9 +12,7 @@ MistEffect_: ; 33f2b (c:7f2b) ld hl, ShroudedInMistText jp PrintText .mistAlreadyInUse - ld hl, PrintButItFailedText_ - ld b, BANK(PrintButItFailedText_) - jp Bankswitch + jpab PrintButItFailedText_ ShroudedInMistText: ; 33f52 (c:7f52) TX_FAR _ShroudedInMistText diff --git a/engine/battle/moveEffects/paralyze_effect.asm b/engine/battle/moveEffects/paralyze_effect.asm index b88e6479..658b0c50 100644 --- a/engine/battle/moveEffects/paralyze_effect.asm +++ b/engine/battle/moveEffects/paralyze_effect.asm @@ -36,18 +36,12 @@ ParalyzeEffect_: ; 52601 (14:6601) ld c, 30 call DelayFrames callab PlayCurrentMoveAnimation - ld hl, PrintMayNotAttackText - ld b, BANK(PrintMayNotAttackText) - jp Bankswitch + jpab PrintMayNotAttackText .didntAffect ld c, 50 call DelayFrames - ld hl, PrintDidntAffectText - ld b, BANK(PrintDidntAffectText) - jp Bankswitch + jpab PrintDidntAffectText .doesntAffect ld c, 50 call DelayFrames - ld hl, PrintDoesntAffectText - ld b, BANK(PrintDoesntAffectText) - jp Bankswitch + jpab PrintDoesntAffectText diff --git a/engine/battle/moveEffects/substitute_effect.asm b/engine/battle/moveEffects/substitute_effect.asm index 444c755b..c72fffbe 100644 --- a/engine/battle/moveEffects/substitute_effect.asm +++ b/engine/battle/moveEffects/substitute_effect.asm @@ -55,9 +55,7 @@ SubstituteEffect_: ; 17dad (5:7dad) call Bankswitch ; jump to routine depending on animation setting ld hl, SubstituteText call PrintText - ld hl, DrawHUDsAndHPBars - ld b, BANK(DrawHUDsAndHPBars) - jp Bankswitch + jpab DrawHUDsAndHPBars .alreadyHasSubstitute ld hl, HasSubstituteText jr .printText diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index 3129b560..2c668d63 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -5,7 +5,7 @@ TryEvolvingMon: ; 3ad0e (e:6d0e) ld [hl], a ld a, [wWhichPokemon] ld c, a - ld b, $1 + ld b, FLAG_SET call Evolution_FlagAction ; this is only called after battle @@ -36,7 +36,7 @@ Evolution_PartyMonLoop: ; loop over party mons ld a, [wWhichPokemon] ld c, a ld hl, wCanEvolveFlags - ld b, $2 + ld b, FLAG_TEST call Evolution_FlagAction ld a, c and a ; is the mon's bit set? @@ -217,7 +217,7 @@ Evolution_PartyMonLoop: ; loop over party mons ld a, [wd11e] dec a ld c, a - ld b, $1 + ld b, FLAG_SET ld hl, wPokedexOwned push bc call Evolution_FlagAction diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm index 4b45631d..02e2b743 100755 --- a/engine/give_pokemon.asm +++ b/engine/give_pokemon.asm @@ -60,7 +60,7 @@ SetPokedexOwnedFlag: ; 4fe11 (13:7e11) dec a ld c, a ld hl, wPokedexOwned - ld b, $1 + ld b, FLAG_SET predef FlagActionPredef pop af ld [wd11e], a diff --git a/engine/hidden_object_functions3.asm b/engine/hidden_object_functions3.asm index 8502cea8..80251b94 100755 --- a/engine/hidden_object_functions3.asm +++ b/engine/hidden_object_functions3.asm @@ -34,9 +34,7 @@ PrintBookshelfText: ; fb50 (3:7b50) .noMatch ld a, $ff ld [$ffdb], a - ld b, BANK(PrintCardKeyText) - ld hl, PrintCardKeyText - jp Bankswitch + jpba PrintCardKeyText ; format: db tileset id, bookshelf tile id, text id BookshelfTileIDs: ; fb8b (3:7b8b) diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm index f7deae66..8893e496 100755 --- a/engine/hidden_object_functions7.asm +++ b/engine/hidden_object_functions7.asm @@ -78,7 +78,7 @@ SafariZoneGameOver: ; 1e9b0 (7:69b0) ld [H_DOWNARROWBLINKCNT2], a call DisplayTextID xor a - ld [wd528], a + ld [wPlayerMovingDirection], a ld a, SAFARI_ZONE_ENTRANCE ld [H_DOWNARROWBLINKCNT1], a ld a, $3 @@ -209,7 +209,7 @@ CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92) call PrintText ld a, [$ffe0] ld c, a - ld b, $1 + ld b, FLAG_SET call CinnabarGymQuiz_1ea8a jp CinnabarGymQuiz_1eb0a .asm_1eab8 @@ -222,7 +222,7 @@ CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92) ld a, [$ffdb] add $2 ld c, a - ld b, $2 + ld b, FLAG_TEST ld hl, wd79a predef FlagActionPredef ld a, c @@ -241,7 +241,7 @@ CinnabarGymQuizCorrectText: ; 1eae3 (7:6ae3) ld a, [$ffe0] ld c, a - ld b, $2 + ld b, FLAG_TEST call CinnabarGymQuiz_1ea8a ld a, c and a @@ -278,7 +278,7 @@ CinnabarGymQuiz_1eb0a: ; 1eb0a (7:6b0a) ld a, [$ffdb] ld [$ffe0], a ld c, a - ld b, $2 + ld b, FLAG_TEST call CinnabarGymQuiz_1ea8a ld a, c and a diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm index 6f1167d0..96c37ab0 100755 --- a/engine/in_game_trades.asm +++ b/engine/in_game_trades.asm @@ -38,7 +38,7 @@ DoInGameTradeDialogue: ; 71ad9 (1c:5ad9) ld hl,wCompletedInGameTradeFlags ld a,[wWhichTrade] ld c,a - ld b,$2 + ld b,FLAG_TEST predef FlagActionPredef ld a,c and a @@ -112,7 +112,7 @@ InGameTrade_DoTrade: ; 71c07 (1c:5c07) ld hl,wCompletedInGameTradeFlags ld a,[wWhichTrade] ld c,a - ld b,$1 + ld b,FLAG_SET predef FlagActionPredef ld hl, ConnectCableText call PrintText @@ -159,9 +159,7 @@ InGameTrade_RestoreScreen: ; 71ca2 (1c:5ca2) call LoadGBPal ld c, 10 call DelayFrames - ld b, BANK(LoadWildData) - ld hl, LoadWildData - jp Bankswitch + jpba LoadWildData InGameTrade_PrepareTradeData: ; 71cc1 (1c:5cc1) ld hl, wTradedPlayerMonSpecies diff --git a/engine/items/itemfinder.asm b/engine/items/itemfinder.asm index 51277632..5da72388 100755 --- a/engine/items/itemfinder.asm +++ b/engine/items/itemfinder.asm @@ -10,7 +10,7 @@ HiddenItemNear: ; 7481f (1d:481f) push hl ld hl, wObtainedHiddenItemsFlags ld c, b - ld b, $2 + ld b, FLAG_TEST predef FlagActionPredef ld a, c pop hl diff --git a/engine/items/items.asm b/engine/items/items.asm index 704e6034..f2c41ef6 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -400,15 +400,15 @@ ItemUseBall: ; d687 (3:5687) ld a,[wd11e] dec a ld c,a - ld b,2 - ld hl,wPokedexOwned ;Dex_own_flags (pokemon) + ld b,FLAG_TEST + ld hl,wPokedexOwned predef FlagActionPredef ld a,c push af ld a,[wd11e] dec a ld c,a - ld b,1 + ld b,FLAG_SET predef FlagActionPredef pop af and a @@ -499,9 +499,7 @@ ItemUseTownMap: ; d968 (3:5968) ld a,[W_ISINBATTLE] and a jp nz,ItemUseNotTime - ld b, BANK(DisplayTownMap) - ld hl, DisplayTownMap - jp Bankswitch ; display Town Map + jpba DisplayTownMap ItemUseBicycle: ; d977 (3:5977) ld a,[W_ISINBATTLE] @@ -593,14 +591,14 @@ ItemUseSurfboard: ; d9b4 (3:59b4) jp LoadWalkingPlayerSpriteGraphics ; uses a simulated button press to make the player move forward .makePlayerMoveForward - ld a,[wd52a] ; direction the player is going - bit 3,a + ld a,[wPlayerDirection] ; direction the player is going + bit PLAYER_DIR_BIT_UP,a ld b,D_UP jr nz,.storeSimulatedButtonPress - bit 2,a + bit PLAYER_DIR_BIT_DOWN,a ld b,D_DOWN jr nz,.storeSimulatedButtonPress - bit 1,a + bit PLAYER_DIR_BIT_LEFT,a ld b,D_LEFT jr nz,.storeSimulatedButtonPress ld b,D_RIGHT @@ -806,7 +804,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld a,[wUsedItemOnWhichPokemon] ld c,a ld hl,wPartyFoughtCurrentEnemyFlags - ld b,$02 + ld b,FLAG_TEST predef FlagActionPredef ld a,c and a @@ -814,7 +812,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld a,[wUsedItemOnWhichPokemon] ld c,a ld hl,wPartyGainExpFlags - ld b,$01 + ld b,FLAG_SET predef FlagActionPredef .next pop bc @@ -2552,8 +2550,8 @@ IsKeyItem_: ; e764 (3:6764) dec a ld c,a ld hl,wHPBarMaxHP - ld b,$02 ; test bit - predef FlagActionPredef ; bitfield operation function + ld b,FLAG_TEST + predef FlagActionPredef ld a,c and a ret nz diff --git a/engine/items/tms.asm b/engine/items/tms.asm index 511aab5b..23912b34 100755 --- a/engine/items/tms.asm +++ b/engine/items/tms.asm @@ -17,7 +17,7 @@ CanLearnTM: ; 1373e (4:773e) jr .findTMloop .TMfoundLoop pop hl - ld b, $2 ; read corresponding bit from TM compatibility array + ld b, FLAG_TEST predef_jump FlagActionPredef ; converts TM/HM number in wd11e into move number diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm index 06a7894c..1f5cf8e0 100755 --- a/engine/menu/league_pc.asm +++ b/engine/menu/league_pc.asm @@ -110,9 +110,7 @@ LeaguePCShowMon: ; 76610 (1d:6610) ld de, wHoFTeamNo ld bc, $0103 call PrintNumber - ld b, BANK(HoFDisplayMonInfo) - ld hl, HoFDisplayMonInfo - jp Bankswitch + jpba HoFDisplayMonInfo HallOfFameNoText: ; 76670 (1d:6670) db "HALL OF FAME No @" diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index eeaa4594..3ed2f443 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -107,8 +107,8 @@ MainMenu: ; 5af2 (1:5af2) .pressedA call GBPalWhiteOutWithDelay3 call ClearScreen - ld a,4 - ld [wd52a],a + ld a,PLAYER_DIR_DOWN + ld [wPlayerDirection],a ld c,10 call DelayFrames ld a,[wNumHoFTeams] diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm index 9a608491..6037329e 100755 --- a/engine/menu/naming_screen.asm +++ b/engine/menu/naming_screen.asm @@ -172,9 +172,7 @@ DisplayNamingScreen: ; 6596 (1:6596) ld a, [W_ISINBATTLE] and a jp z, LoadTextBoxTilePatterns - ld hl, LoadHudTilePatterns - ld b, BANK(LoadHudTilePatterns) - jp Bankswitch + jpab LoadHudTilePatterns .namingScreenButtonFunctions dw .dPadReturnPoint diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 4e173bc0..2f22f78e 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -379,7 +379,7 @@ IsPokemonBitSet: ; 402c2 (10:42c2) ld a,[wd11e] dec a ld c,a - ld b,2 + ld b,FLAG_TEST predef FlagActionPredef ld a,c and a diff --git a/engine/menu/prize_menu.asm b/engine/menu/prize_menu.asm index b1b751b9..f2f2a794 100755 --- a/engine/menu/prize_menu.asm +++ b/engine/menu/prize_menu.asm @@ -179,7 +179,7 @@ LoadCoinsToSubtract: ; 528b1 (14:68b1) ld hl,wd141 ; first prize's price add hl,de ; get selected prize's price xor a - ld [hCoins - 1],a + ld [hUnusedCoinsByte],a ld a,[hli] ld [hCoins],a ld a,[hl] diff --git a/engine/overworld/cable_club_npc.asm b/engine/overworld/cable_club_npc.asm index b9e3102a..2a9b19fe 100755 --- a/engine/overworld/cable_club_npc.asm +++ b/engine/overworld/cable_club_npc.asm @@ -111,9 +111,7 @@ Func_72a8: ; 72a8 (1:72a8) xor a ld [hld], a ld [hl], a - ld hl, LinkMenu - ld b, BANK(LinkMenu) - jp Bankswitch + jpab LinkMenu CableClubNPCAreaReservedFor2FriendsLinkedByCableText: ; 72b3 (1:72b3) TX_FAR _CableClubNPCAreaReservedFor2FriendsLinkedByCableText diff --git a/engine/overworld/hidden_items.asm b/engine/overworld/hidden_items.asm index fee5b5bc..fc69afc1 100755 --- a/engine/overworld/hidden_items.asm +++ b/engine/overworld/hidden_items.asm @@ -5,7 +5,7 @@ HiddenItems: ; 76688 (1d:6688) ld hl, wObtainedHiddenItemsFlags ld a, [wHiddenItemOrCoinsIndex] ld c, a - ld b, $2 + ld b, FLAG_TEST predef FlagActionPredef ld a, c and a @@ -31,7 +31,7 @@ FoundHiddenItemText: ; 7675b (1d:675b) ld hl, wObtainedHiddenItemsFlags ld a, [wTrainerScreenX] ld c, a - ld b, $1 + ld b, FLAG_SET predef FlagActionPredef ld a, SFX_GET_ITEM_2 call PlaySoundWaitForCurrent @@ -61,13 +61,13 @@ HiddenCoins: ; 76799 (1d:6799) ld hl, wObtainedHiddenCoinsFlags ld a, [wHiddenItemOrCoinsIndex] ld c, a - ld b, $2 + ld b, FLAG_TEST predef FlagActionPredef ld a, c and a ret nz xor a - ld [hCoins - 1], a + ld [hUnusedCoinsByte], a ld [hCoins], a ld [hCoins + 1], a ld a, [wHiddenObjectFunctionArgument] @@ -102,7 +102,7 @@ HiddenCoins: ; 76799 (1d:6799) ld hl, wObtainedHiddenCoinsFlags ld a, [wTrainerScreenX] ld c, a - ld b, $1 + ld b, FLAG_SET predef FlagActionPredef call EnableAutoTextBoxDrawing ld a, [wPlayerCoins] diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index f618261e..be10fd69 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -25,24 +25,24 @@ UpdatePlayerSprite: ; 4e31 (1:4e31) ld a, [wWalkCounter] and a jr nz, .moving - ld a, [wd528] + ld a, [wPlayerMovingDirection] ; check if down - bit 2, a + bit PLAYER_DIR_BIT_DOWN, a jr z, .checkIfUp xor a ; ld a, SPRITE_FACING_DOWN jr .next .checkIfUp - bit 3, a + bit PLAYER_DIR_BIT_UP, a jr z, .checkIfLeft ld a, SPRITE_FACING_UP jr .next .checkIfLeft - bit 1, a + bit PLAYER_DIR_BIT_LEFT, a jr z, .checkIfRight ld a, SPRITE_FACING_LEFT jr .next .checkIfRight - bit 0, a + bit PLAYER_DIR_BIT_RIGHT, a jr z, .notMoving ld a, SPRITE_FACING_RIGHT jr .next @@ -405,23 +405,23 @@ InitializeSpriteFacingDirection: ; 507f (1:507f) bit 5, a jr nz, notYetMoving res 7, [hl] - ld a, [wd52a] - bit 3, a + ld a, [wPlayerDirection] + bit PLAYER_DIR_BIT_UP, a jr z, .notFacingDown - ld c, $0 ; make sprite face down + ld c, SPRITE_FACING_DOWN jr .facingDirectionDetermined .notFacingDown - bit 2, a + bit PLAYER_DIR_BIT_DOWN, a jr z, .notFacingUp - ld c, $4 ; make sprite face up + ld c, SPRITE_FACING_UP jr .facingDirectionDetermined .notFacingUp - bit 1, a + bit PLAYER_DIR_BIT_LEFT, a jr z, .notFacingRight - ld c, $c ; make sprite face right + ld c, SPRITE_FACING_RIGHT jr .facingDirectionDetermined .notFacingRight - ld c, $8 ; make sprite face left + ld c, SPRITE_FACING_LEFT .facingDirectionDetermined ld a, [H_CURRENTSPRITEOFFSET] add $9 diff --git a/engine/overworld/saffron_guards.asm b/engine/overworld/saffron_guards.asm index 8e584a2d..c0d6a985 100755 --- a/engine/overworld/saffron_guards.asm +++ b/engine/overworld/saffron_guards.asm @@ -10,9 +10,7 @@ RemoveGuardDrink: ; 5a59f (16:659f) call IsItemInBag pop hl jr z, .drinkLoop - ld b, BANK(RemoveItemByID) - ld hl, RemoveItemByID - jp Bankswitch + jpba RemoveItemByID GuardDrinksList: ; 5a5b7 (16:65b7) db FRESH_WATER, SODA_POP, LEMONADE, $00 diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index 729e16bb..84c0cdf7 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -262,9 +262,7 @@ ENDC jp MainMenu .doClearSaveDialogue - ld b, BANK(DoClearSaveDialogue) - ld hl, DoClearSaveDialogue - jp Bankswitch + jpba DoClearSaveDialogue TitleScreenPickNewMon: ; 4496 (1:4496) ld a, vBGMap0 / $100 diff --git a/engine/trade.asm b/engine/trade.asm index 68baaa16..ba8de4ff 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -199,9 +199,7 @@ LoadTradingGFXAndMonNames: ; 411a1 (10:51a1) Trade_LoadMonPartySpriteGfx: ; 4120b (10:520b) ld a, %11010000 ld [rOBP1], a - ld b, BANK(LoadMonPartySpriteGfx) - ld hl, LoadMonPartySpriteGfx - jp Bankswitch + jpba LoadMonPartySpriteGfx Trade_SwapNames: ; 41217 (10:5217) ld hl, wPlayerName @@ -253,9 +253,7 @@ DrawHPBar:: ; 1336 (0:1336) ; wLoadedMon = base address of pokemon data ; W_MONHDEXNUM = base address of base stats LoadMonData:: ; 1372 (0:1372) - ld hl, LoadMonData_ - ld b, BANK(LoadMonData_) - jp Bankswitch + jpab LoadMonData_ OverwritewMoves:: ; 137a (0:137a) @@ -1317,9 +1315,7 @@ CountSetBits:: ; 2b7f (0:2b7f) ; subtracts the amount the player paid from their money ; sets carry flag if there is enough money and unsets carry flag if not SubtractAmountPaidFromMoney:: ; 2b96 (0:2b96) - ld b,BANK(SubtractAmountPaidFromMoney_) - ld hl,SubtractAmountPaidFromMoney_ - jp Bankswitch + jpba SubtractAmountPaidFromMoney_ ; adds the amount the player sold to their money AddAmountSoldToMoney:: ; 2b9e (0:2b9e) @@ -2077,9 +2073,7 @@ ReloadTilesetTilePatterns:: ; 3090 (0:3090) ChooseFlyDestination:: ; 30a9 (0:30a9) ld hl,wd72e res 4,[hl] - ld b, BANK(LoadTownMap_Fly) - ld hl, LoadTownMap_Fly - jp Bankswitch + jpba LoadTownMap_Fly ; causes the text box to close without waiting for a button press after displaying text DisableWaitingAfterTextDisplay:: ; 30b6 (0:30b6) @@ -2097,9 +2091,7 @@ DisableWaitingAfterTextDisplay:: ; 30b6 (0:30b6) ; 01: successful ; 02: not able to be used right now, no extra menu displayed (only certain items use this) UseItem:: ; 30bc (0:30bc) - ld b,BANK(UseItem_) - ld hl,UseItem_ - jp Bankswitch + jpba UseItem_ ; confirms the item toss and then tosses the item ; INPUT: @@ -2201,14 +2193,10 @@ RunNPCMovementScript:: ; 310e (0:310e) dw PewterMuseumGuyMovementScriptPointerTable dw PewterGymGuyMovementScriptPointerTable .playerStepOutFromDoor - ld b, BANK(PlayerStepOutFromDoor) - ld hl, PlayerStepOutFromDoor - jp Bankswitch + jpba PlayerStepOutFromDoor EndNPCMovementScript:: ; 314e (0:314e) - ld b, BANK(_EndNPCMovementScript) - ld hl, _EndNPCMovementScript - jp Bankswitch + jpba _EndNPCMovementScript EmptyFunc2:: ; 3156 (0:3156) ret @@ -2309,7 +2297,7 @@ TalkToTrainer:: ; 31cc (0:31cc) call ReadTrainerHeaderInfo ; read flag's byte ptr ld a, [wTrainerHeaderFlagBit] ld c, a - ld b, $2 + ld b, FLAG_TEST call TrainerFlagAction ; read trainer's flag ld a, c and a @@ -2404,7 +2392,7 @@ EndTrainerBattle:: ; 3275 (0:3275) call ReadTrainerHeaderInfo ld a, [wTrainerHeaderFlagBit] ld c, a - ld b, $1 + ld b, FLAG_SET call TrainerFlagAction ; flag trainer as fought ld a, [W_ENEMYMONORTRAINERCLASS] cp $c8 @@ -2434,9 +2422,7 @@ ResetButtonPressedAndMapScript:: ; 32c1 (0:32c1) ; calls TrainerWalkUpToPlayer TrainerWalkUpToPlayer_Bank0:: ; 32cf (0:32cf) - ld b, BANK(TrainerWalkUpToPlayer) - ld hl, TrainerWalkUpToPlayer - jp Bankswitch + jpba TrainerWalkUpToPlayer ; sets opponent type and mon set/lvl based on the engaging trainer data InitBattleEnemyParameters:: ; 32d7 (0:32d7) @@ -2484,7 +2470,7 @@ CheckForEngagingTrainers:: ; 3306 (0:3306) ret z ld a, $2 call ReadTrainerHeaderInfo ; read trainer flag's byte ptr - ld b, $2 + ld b, FLAG_TEST ld a, [wTrainerHeaderFlagBit] ld c, a call TrainerFlagAction ; read trainer flag @@ -2726,9 +2712,7 @@ IsItemInBag:: ; 3493 (0:3493) DisplayPokedex:: ; 349b (0:349b) ld [wd11e], a - ld b, BANK(_DisplayPokedex) - ld hl, _DisplayPokedex - jp Bankswitch + jpba _DisplayPokedex SetSpriteFacingDirectionAndDelay:: ; 34a6 (0:34a6) call SetSpriteFacingDirection @@ -2937,9 +2921,7 @@ GetTrainerInformation:: ; 3566 (0:3566) ret GetTrainerName:: ; 359e (0:359e) - ld b, BANK(GetTrainerName_) - ld hl, GetTrainerName_ - jp Bankswitch + jpba GetTrainerName_ HasEnoughMoney:: @@ -3604,9 +3586,7 @@ CopyDataUntil:: ; 3913 (0:3913) ; [wRemoveMonFromBox] == 0 specifies the party. ; [wRemoveMonFromBox] != 0 specifies the current box. RemovePokemon:: ; 391f (0:391f) - ld hl, _RemovePokemon - ld b, BANK(_RemovePokemon) - jp Bankswitch + jpab _RemovePokemon AddPartyMon:: ; 3927 (0:3927) push hl @@ -4590,9 +4570,7 @@ GivePokemon:: ld [W_CURENEMYLVL], a xor a ; PLAYER_PARTY_DATA ld [wMonDataLocation], a - ld b, BANK(_GivePokemon) - ld hl, _GivePokemon - jp Bankswitch + jpba _GivePokemon Random:: @@ -4613,9 +4591,7 @@ INCLUDE "home/predef.asm" Func_3ead:: ; 3ead (0:3ead) - ld b, BANK(CinnabarGymQuiz_1eb0a) - ld hl, CinnabarGymQuiz_1eb0a - jp Bankswitch + jpba CinnabarGymQuiz_1eb0a CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: ; 3eb5 (0:3eb5) ld a, [H_LOADEDROMBANK] diff --git a/home/overworld.asm b/home/overworld.asm index 13cce7ee..cc5e9f5e 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -1,9 +1,7 @@ HandleMidJump:: ; Handle the player jumping down ; a ledge in the overworld. - ld b, BANK(_HandleMidJump) - ld hl, _HandleMidJump - jp Bankswitch + jpba _HandleMidJump EnterMap:: ; Load a new map. @@ -136,52 +134,52 @@ OverworldLoopLessDelay:: call UpdateSprites ld a,$01 ld [wcc4b],a - ld a,[wd528] ; the direction that was pressed last time + ld a,[wPlayerMovingDirection] ; the direction that was pressed last time and a jp z,OverworldLoop ; if a direction was pressed last time - ld [wd529],a ; save the last direction + ld [wPlayerLastStopDirection],a ; save the last direction xor a - ld [wd528],a ; zero the direction + ld [wPlayerMovingDirection],a ; zero the direction jp OverworldLoop .checkIfDownButtonIsPressed ld a,[hJoyHeld] ; current joypad state bit 7,a ; down button jr z,.checkIfUpButtonIsPressed - ld a,$01 - ld [wSpriteStateData1 + 3],a - ld a,$04 + ld a,1 + ld [wSpriteStateData1 + 3],a ; delta Y + ld a,PLAYER_DIR_DOWN jr .handleDirectionButtonPress .checkIfUpButtonIsPressed bit 6,a ; up button jr z,.checkIfLeftButtonIsPressed - ld a,$ff - ld [wSpriteStateData1 + 3],a - ld a,$08 + ld a,-1 + ld [wSpriteStateData1 + 3],a ; delta Y + ld a,PLAYER_DIR_UP jr .handleDirectionButtonPress .checkIfLeftButtonIsPressed bit 5,a ; left button jr z,.checkIfRightButtonIsPressed - ld a,$ff - ld [wSpriteStateData1 + 5],a - ld a,$02 + ld a,-1 + ld [wSpriteStateData1 + 5],a ; delta X + ld a,PLAYER_DIR_LEFT jr .handleDirectionButtonPress .checkIfRightButtonIsPressed bit 4,a ; right button jr z,.noDirectionButtonsPressed - ld a,$01 - ld [wSpriteStateData1 + 5],a + ld a,1 ; PLAYER_DIR_RIGHT + ld [wSpriteStateData1 + 5],a ; delta X .handleDirectionButtonPress - ld [wd52a],a ; new direction + ld [wPlayerDirection],a ; new direction ld a,[wd730] bit 7,a ; are we simulating button presses? jr nz,.noDirectionChange ; ignore direction changes if we are ld a,[wcc4b] and a jr z,.noDirectionChange - ld a,[wd52a] ; new direction + ld a,[wPlayerDirection] ; new direction ld b,a - ld a,[wd529] ; old direction + ld a,[wPlayerLastStopDirection] ; old direction cp b jr z,.noDirectionChange ; the code below is strange @@ -189,42 +187,42 @@ OverworldLoopLessDelay:: ; also, it does a seemingly pointless loop afterwards swap a ; put old direction in upper half or b ; put new direction in lower half - cp a,$48 ; change dir from down to up + cp a,(PLAYER_DIR_DOWN << 4) | PLAYER_DIR_UP ; change dir from down to up jr nz,.notDownToUp - ld a,$02 - ld [wd528],a + ld a,PLAYER_DIR_LEFT + ld [wPlayerMovingDirection],a jr .oddLoop .notDownToUp - cp a,$84 ; change dir from up to down + cp a,(PLAYER_DIR_UP << 4) | PLAYER_DIR_DOWN ; change dir from up to down jr nz,.notUpToDown - ld a,$01 - ld [wd528],a + ld a,PLAYER_DIR_RIGHT + ld [wPlayerMovingDirection],a jr .oddLoop .notUpToDown - cp a,$12 ; change dir from right to left + cp a,(PLAYER_DIR_RIGHT << 4) | PLAYER_DIR_LEFT ; change dir from right to left jr nz,.notRightToLeft - ld a,$04 - ld [wd528],a + ld a,PLAYER_DIR_DOWN + ld [wPlayerMovingDirection],a jr .oddLoop .notRightToLeft - cp a,$21 ; change dir from left to right + cp a,(PLAYER_DIR_LEFT << 4) | PLAYER_DIR_RIGHT ; change dir from left to right jr nz,.oddLoop - ld a,$08 - ld [wd528],a + ld a,PLAYER_DIR_UP + ld [wPlayerMovingDirection],a .oddLoop ld hl,wFlags_0xcd60 set 2,[hl] ld hl,wcc4b dec [hl] jr nz,.oddLoop - ld a,[wd52a] - ld [wd528],a + ld a,[wPlayerDirection] + ld [wPlayerMovingDirection],a call NewBattle jp c,.battleOccurred jp OverworldLoop .noDirectionChange - ld a,[wd52a] ; current direction - ld [wd528],a ; save direction + ld a,[wPlayerDirection] ; current direction + ld [wPlayerMovingDirection],a ; save direction call UpdateSprites ld a,[wWalkBikeSurfState] cp a,$02 ; surfing @@ -355,9 +353,7 @@ NewBattle:: ; 0683 (0:0683) ld a,[wd72e] bit 4,a jr nz,.noBattle - ld b, BANK(InitBattle) - ld hl, InitBattle - jp Bankswitch + jpba InitBattle .noBattle and a ret @@ -570,7 +566,7 @@ CheckMapConnections:: ; 07ba (0:07ba) jp .loadNewMap .checkEastMap ld b,a - ld a,[wd525] ; map width + ld a,[wCurrentMapWidth2] ; map width cp b jr nz,.checkNorthMap ld a,[W_MAPCONN4PTR] @@ -632,7 +628,7 @@ CheckMapConnections:: ; 07ba (0:07ba) jp .loadNewMap .checkSouthMap ld b,a - ld a,[wd524] + ld a,[wCurrentMapHeight2] cp b jr nz,.didNotEnterConnectedMap ld a,[W_MAPCONN2PTR] @@ -783,9 +779,7 @@ HandleFlyWarpOrDungeonWarp:: jp SpecialEnterMap LeaveMapAnim:: - ld b, BANK(_LeaveMapAnim) - ld hl, _LeaveMapAnim - jp Bankswitch + jpba _LeaveMapAnim LoadPlayerSpriteGraphics:: ; Load sprite graphics based on whether the player is standing, biking, or surfing. @@ -870,7 +864,7 @@ LoadTilesetTilePatternData:: ; 09e8 (0:09e8) LoadTileBlockMap:: ; 09fc (0:09fc) ; fill C6E8-CBFB with the background tile ld hl,wOverworldMap - ld a,[wd3ad] ; background tile number + ld a,[wMapBackgroundTile] ld d,a ld bc,$0514 .backgroundTileLoop @@ -1063,15 +1057,15 @@ LoadEastWestConnectionsTileMap:: ; 0b02 (0:0b02) IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) xor a ld [hSpriteIndexOrTextID],a - ld a,[wd4b0] ; number of signs in the map + ld a,[wNumSigns] and a jr z,.extendRangeOverCounter ; if there are signs predef GetTileAndCoordsInFrontOfPlayer ; get the coordinates in front of the player in de - ld hl,wd4b1 ; start of sign coordinates - ld a,[wd4b0] ; number of signs in the map + ld hl,wSignCoords + ld a,[wNumSigns] ld b,a - ld c,$00 + ld c,0 .signLoop inc c ld a,[hli] ; sign Y @@ -1087,8 +1081,8 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) ; found sign push hl push bc - ld hl,wd4d1 ; start of sign text ID's - ld b,$00 + ld hl,wSignTextIDs + ld b,0 dec c add hl,bc ld a,[hl] @@ -1103,7 +1097,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) .extendRangeOverCounter predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player in c ld hl,W_TILESETTALKINGOVERTILES ; list of tiles that extend talking range (counter tiles) - ld b,$03 + ld b,3 ld d,$20 ; talking range in pixels (long range) .counterTilesLoop ld a,[hli] @@ -1117,7 +1111,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) IsSpriteInFrontOfPlayer:: ; 0b6b (0:0b6b) ld d,$10 ; talking range in pixels (normal range) IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d) - ld bc,$3c40 ; Y and X position of player sprite + lb bc, $3c, $40 ; Y and X position of player sprite ld a,[wSpriteStateData1 + 9] ; direction the player is facing .checkIfPlayerFacingUp cp SPRITE_FACING_UP @@ -1126,7 +1120,7 @@ IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d) ld a,b sub d ld b,a - ld a,$08 + ld a,PLAYER_DIR_UP jr .doneCheckingDirection .checkIfPlayerFacingDown cp SPRITE_FACING_DOWN @@ -1135,7 +1129,7 @@ IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d) ld a,b add d ld b,a - ld a,$04 + ld a,PLAYER_DIR_DOWN jr .doneCheckingDirection .checkIfPlayerFacingRight cp SPRITE_FACING_RIGHT @@ -1144,16 +1138,16 @@ IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d) ld a,c add d ld c,a - ld a,$01 + ld a,PLAYER_DIR_RIGHT jr .doneCheckingDirection .playerFacingLeft ; facing left ld a,c sub d ld c,a - ld a,$02 + ld a,PLAYER_DIR_LEFT .doneCheckingDirection - ld [wd52a],a + ld [wPlayerDirection],a ld a,[W_NUMSPRITES] ; number of sprites and a ret z @@ -1208,7 +1202,7 @@ CollisionCheckOnLand:: ; 0bd1 (0:0bd1) ld a,[wSimulatedJoypadStatesIndex] and a jr nz,.noCollision ; no collisions when the player's movements are being controlled by the game - ld a,[wd52a] ; the direction that the player is trying to go in + ld a,[wPlayerDirection] ; the direction that the player is trying to go in ld d,a ld a,[wSpriteStateData1 + 12] ; the player sprite's collision data (bit field) (set in the sprite movement code) and d ; check if a sprite is in the direction the player is trying to go @@ -1899,7 +1893,7 @@ CollisionCheckOnWater:: ; 0fb7 (0:0fb7) ld a,[wd730] bit 7,a jp nz,.noCollision ; return and clear carry if button presses are being simulated - ld a,[wd52a] ; the direction that the player is trying to go in + ld a,[wPlayerDirection] ; the direction that the player is trying to go in ld d,a ld a,[wSpriteStateData1 + 12] ; the player sprite's collision data (bit field) (set in the sprite movement code) and d ; check if a sprite is in the direction the player is trying to go @@ -2079,17 +2073,17 @@ LoadMapHeader:: ; 107c (0:107c) call CopyMapConnectionHeader .getObjectDataPointer ld a,[hli] - ld [wd3a9],a + ld [wObjectDataPointerTemp],a ld a,[hli] - ld [wd3aa],a + ld [wObjectDataPointerTemp + 1],a push hl - ld a,[wd3a9] + ld a,[wObjectDataPointerTemp] ld l,a - ld a,[wd3aa] + ld a,[wObjectDataPointerTemp + 1] ld h,a ; hl = base of object data - ld de,wd3ad ; background tile ID + ld de,wMapBackgroundTile ld a,[hli] - ld [de],a ; save background tile ID + ld [de],a .loadWarpData ld a,[hli] ld [wNumberOfWarps],a @@ -2109,16 +2103,16 @@ LoadMapHeader:: ; 107c (0:107c) jr nz,.warpLoop .loadSignData ld a,[hli] ; number of signs - ld [wd4b0],a ; save the number of signs + ld [wNumSigns],a and a ; are there any signs? jr z,.loadSpriteData ; if not, skip this ld c,a - ld de,wd4d1 ; base address of sign text IDs + ld de,wSignTextIDs ld a,d - ld [$ff95],a + ld [hSignCoordPointer],a ld a,e - ld [$ff96],a - ld de,wd4b1 ; base address of sign coordinates + ld [hSignCoordPointer + 1],a + ld de,wSignCoords .signLoop ld a,[hli] ld [de],a @@ -2127,17 +2121,17 @@ LoadMapHeader:: ; 107c (0:107c) ld [de],a inc de push de - ld a,[$ff95] + ld a,[hSignCoordPointer] ld d,a - ld a,[$ff96] + ld a,[hSignCoordPointer + 1] ld e,a ld a,[hli] ld [de],a inc de ld a,d - ld [$ff95],a + ld [hSignCoordPointer],a ld a,e - ld [$ff96],a + ld [hSignCoordPointer + 1],a pop de dec c jr nz,.signLoop @@ -2265,10 +2259,10 @@ LoadMapHeader:: ; 107c (0:107c) pop hl ; restore hl from before going to the warp/sign/sprite data (this value was saved for seemingly no purpose) ld a,[W_CURMAPHEIGHT] ; map height in 4x4 tile blocks add a ; double it - ld [wd524],a ; store map height in 2x2 tile blocks + ld [wCurrentMapHeight2],a ; store map height in 2x2 tile blocks ld a,[W_CURMAPWIDTH] ; map width in 4x4 tile blocks add a ; double it - ld [wd525],a ; map width in 2x2 tile blocks + ld [wCurrentMapWidth2],a ; map width in 2x2 tile blocks ld a,[W_CURMAP] ld c,a ld b,$00 @@ -82,6 +82,9 @@ hTilePlayerStandingOn EQU $FF93 hSpritePriority EQU $FF94 +; 2 bytes +hSignCoordPointer EQU $FF95 + hNPCMovementDirections2Index EQU $FF95 ; CalcPositionOfPlayerRelativeToNPC @@ -137,6 +140,9 @@ hNPCPlayerRelativePosPerspective EQU $FF9B ; 1 = target is to the west hNPCPlayerRelativePosFlags EQU $FF9D +; some code zeroes this for no reason when writing a coin amount +hUnusedCoinsByte EQU $FF9F + hMoney EQU $FF9F ; 3-byte BCD number hCoins EQU $FFA0 ; 2-byte BCD number @@ -53,6 +53,18 @@ callab: MACRO call Bankswitch ENDM +jpba: MACRO + ld b, BANK(\1) + ld hl, \1 + jp Bankswitch + ENDM + +jpab: MACRO + ld hl, \1 + ld b, BANK(\1) + jp Bankswitch + ENDM + bcd2: MACRO dn ((\1) / 1000) % 10, ((\1) / 100) % 10 dn ((\1) / 10) % 10, (\1) % 10 @@ -2038,7 +2038,7 @@ _DisplayPokedex: ; 7c18 (1:7c18) ld a, [wd11e] dec a ld c, a - ld b, $1 + ld b, FLAG_SET ld hl, wPokedexSeen predef FlagActionPredef ld a, $1 @@ -3235,7 +3235,7 @@ MarkTownVisitedAndLoadMissableObjects: ; f113 (3:7113) cp ROUTE_1 jr nc, .notInTown ld c, a - ld b, $1 + ld b, FLAG_SET ld hl, W_TOWNVISITEDFLAG ; mark town as visited (for flying) predef FlagActionPredef .notInTown @@ -3319,7 +3319,7 @@ InitializeMissableObjectsFlags: ; f175 (3:7175) ld hl, W_MISSABLEOBJECTFLAGS ld a, [wd048] ld c, a - ld b, $1 + ld b, FLAG_SET call MissableObjectFlagAction ; set flag iff Item is hidden .asm_f19d ld hl, wd048 @@ -3343,7 +3343,7 @@ IsObjectHidden: ; f1a6 (3:71a6) ld a, [hli] jr nz, .loop ld c, a - ld b, $2 + ld b, FLAG_TEST ld hl, W_MISSABLEOBJECTFLAGS call MissableObjectFlagAction ld a, c @@ -3362,7 +3362,7 @@ ShowObject2: ld hl, W_MISSABLEOBJECTFLAGS ld a, [wcc4d] ld c, a - ld b, $0 + ld b, FLAG_RESET call MissableObjectFlagAction ; reset "removed" flag jp UpdateSprites @@ -3372,7 +3372,7 @@ HideObject: ; f1d7 (3:71d7) ld hl, W_MISSABLEOBJECTFLAGS ld a, [wcc4d] ld c, a - ld b, $1 + ld b, FLAG_SET call MissableObjectFlagAction ; set "removed" flag jp UpdateSprites @@ -3642,7 +3642,7 @@ _AddPartyMon: ; f2e5 (3:72e5) ld a, [wd11e] dec a ld c, a - ld b, $2 + ld b, FLAG_TEST ld hl, wPokedexOwned call FlagAction ld a, c @@ -3650,7 +3650,7 @@ _AddPartyMon: ; f2e5 (3:72e5) ld a, [wd11e] dec a ld c, a - ld b, $1 + ld b, FLAG_SET push bc call FlagAction pop bc @@ -3882,7 +3882,7 @@ _AddEnemyMonToPlayerParty: ; f49d (3:749d) ld a, [wd11e] dec a ld c, a - ld b, $1 + ld b, FLAG_SET ld hl, wPokedexOwned push bc call FlagAction ; add to owned pokemon diff --git a/scripts/celadongamecorner.asm b/scripts/celadongamecorner.asm index 53e55872..c8d07058 100755 --- a/scripts/celadongamecorner.asm +++ b/scripts/celadongamecorner.asm @@ -170,7 +170,7 @@ CeladonGameCornerText2: ; 48ca9 (12:4ca9) ld c, $3 predef SubBCDPredef xor a - ld [hCoins - 1], a + ld [hUnusedCoinsByte], a ld [hCoins], a ld a, $50 ld [hCoins + 1], a @@ -238,7 +238,7 @@ CeladonGameCornerText5: ; 48d4a (12:4d4a) call Has9990Coins jr nc, .asm_48d8e xor a - ld [hCoins - 1], a + ld [hUnusedCoinsByte], a ld [hCoins], a ld a, $10 ld [hCoins + 1], a @@ -320,7 +320,7 @@ CeladonGameCornerText9: ; 48dd9 (12:4dd9) call Has9990Coins jr nc, .asm_48e18 xor a - ld [hCoins - 1], a + ld [hUnusedCoinsByte], a ld [hCoins], a ld a, $20 ld [hCoins + 1], a @@ -373,7 +373,7 @@ CeladonGameCornerText10: ; 48e3b (12:4e3b) call Has9990Coins jr z, .asm_48e7a xor a - ld [hCoins - 1], a + ld [hUnusedCoinsByte], a ld [hCoins], a ld a, $20 ld [hCoins + 1], a diff --git a/scripts/celadonmartelevator.asm b/scripts/celadonmartelevator.asm index a0aa576d..c8ff1a6d 100755 --- a/scripts/celadonmartelevator.asm +++ b/scripts/celadonmartelevator.asm @@ -55,9 +55,7 @@ CeldaonMartElevatorWarpMaps: ; 4864a (12:464a) db $02, CELADON_MART_5 CeladonMartElevatorScript_48654: ; 48654 (12:4654) - ld b, BANK(ShakeElevator) - ld hl, ShakeElevator - jp Bankswitch + jpba ShakeElevator CeladonMartElevatorTextPointers: ; 4865c (12:465c) dw CeladonMartElevatorText1 diff --git a/scripts/celadonmartroof.asm b/scripts/celadonmartroof.asm index b0afbee0..f83e466d 100755 --- a/scripts/celadonmartroof.asm +++ b/scripts/celadonmartroof.asm @@ -135,9 +135,7 @@ CeladonMartRoofScript_4840c: ; 4840c (12:440c) jp PrintText RemoveItemByIDBank12: ; 484e6 (12:44e6) - ld b, BANK(RemoveItemByID) - ld hl, RemoveItemByID - jp Bankswitch + jpba RemoveItemByID CeladonMartRoofText_484ee: ; 484ee (12:44ee) TX_FAR _CeladonMartRoofText_484ee diff --git a/scripts/ceruleancity.asm b/scripts/ceruleancity.asm index 2c7bd449..48480167 100755 --- a/scripts/ceruleancity.asm +++ b/scripts/ceruleancity.asm @@ -44,15 +44,15 @@ CeruleanCityScript0: ; 194c8 (6:54c8) jr nc, .asm_194f7 ld a, [wCoordIndex] cp $1 - ld a, $8 + ld a, PLAYER_DIR_UP ld b, SPRITE_FACING_DOWN jr nz, .asm_194e6 - ld a, $4 + ld a, PLAYER_DIR_DOWN ld b, SPRITE_FACING_UP .asm_194e6 - ld [wd528], a + ld [wPlayerMovingDirection], a ld a, b - ld [wSpriteStateData1 + $29], a + ld [wSpriteStateData1 + 2 * $10 + $9], a call Delay3 ld a, $2 ld [hSpriteIndexOrTextID], a diff --git a/scripts/cinnabargym.asm b/scripts/cinnabargym.asm index 9b308bd3..213568d5 100755 --- a/scripts/cinnabargym.asm +++ b/scripts/cinnabargym.asm @@ -54,14 +54,14 @@ CinnabarGymScript0: ; 757ae (1d:57ae) ld [H_SPRITEINDEX], a cp $4 jr nz, .asm_757c3 - ld a, $4 - ld [wd528], a + ld a, PLAYER_DIR_DOWN + ld [wPlayerMovingDirection], a ld de, MovementData_757d7 jr .asm_757cb .asm_757c3 ld de, MovementData_757da - ld a, $1 - ld [wd528], a + ld a, PLAYER_DIR_RIGHT + ld [wPlayerMovingDirection], a .asm_757cb call MoveSprite ld a, $1 @@ -99,7 +99,7 @@ CinnabarGymScript2: ; 757f6 (1d:57f6) ld a, [wTrainerHeaderFlagBit] ld [$ffdb], a ld c, a - ld b, $2 + ld b, FLAG_TEST ld hl, wd79a call CinnabarGymScript_757f1 ld a, c @@ -113,13 +113,13 @@ CinnabarGymScript2: ; 757f6 (1d:57f6) ld a, [wTrainerHeaderFlagBit] ld [$ffdb], a ld c, a - ld b, $1 + ld b, FLAG_SET ld hl, wd79a call CinnabarGymScript_757f1 ld a, [wTrainerHeaderFlagBit] sub $2 ld c, a - ld b, $1 + ld b, FLAG_SET ld hl, wd79c call CinnabarGymScript_757f1 call Func_3ead diff --git a/scripts/cinnabarisland.asm b/scripts/cinnabarisland.asm index 70ea25a5..92c0fc6b 100755 --- a/scripts/cinnabarisland.asm +++ b/scripts/cinnabarisland.asm @@ -24,8 +24,8 @@ CinnabarIslandScript0: ; 1ca38 (7:4a38) ld a, [W_XCOORD] cp $12 ret nz - ld a, $8 - ld [wd528], a + ld a, PLAYER_DIR_UP + ld [wPlayerMovingDirection], a ld a, $8 ld [hSpriteIndexOrTextID], a call DisplayTextID diff --git a/scripts/fightingdojo.asm b/scripts/fightingdojo.asm index 8a4a0464..c21dde00 100755 --- a/scripts/fightingdojo.asm +++ b/scripts/fightingdojo.asm @@ -42,8 +42,8 @@ FightingDojoScript1: ; 5cd83 (17:4d83) ret nz ld a, $1 ld [wcf0d], a - ld a, $1 - ld [wd528], a + ld a, PLAYER_DIR_RIGHT + ld [wPlayerMovingDirection], a ld a, $1 ld [H_SPRITEINDEX], a ld a, SPRITE_FACING_LEFT @@ -61,8 +61,8 @@ FightingDojoScript3: ; 5cdc6 (17:4dc6) ld a, [wcf0d] and a jr z, .asm_5cde4 - ld a, $1 - ld [wd528], a + ld a, PLAYER_DIR_RIGHT + ld [wPlayerMovingDirection], a ld a, $1 ld [H_SPRITEINDEX], a ld a, SPRITE_FACING_LEFT diff --git a/scripts/gary.asm b/scripts/gary.asm index 476a59b0..d01161da 100755 --- a/scripts/gary.asm +++ b/scripts/gary.asm @@ -139,8 +139,8 @@ GaryScript5: ; 7601a (1d:601a) ld a, [wd730] bit 0, a ret nz - ld a, $2 - ld [wd528], a + ld a, PLAYER_DIR_LEFT + ld [wPlayerMovingDirection], a ld a, $1 ld [H_SPRITEINDEX], a ld a, SPRITE_FACING_LEFT diff --git a/scripts/halloffameroom.asm b/scripts/halloffameroom.asm index 680ebdd9..bc0d19e1 100755 --- a/scripts/halloffameroom.asm +++ b/scripts/halloffameroom.asm @@ -80,19 +80,19 @@ HallofFameRoomScript1: ; 5a52b (16:652b) ld a, [wSimulatedJoypadStatesIndex] and a ret nz - ld a, $1 - ld [wd528], a + ld a, PLAYER_DIR_RIGHT + ld [wPlayerMovingDirection], a ld a, $1 ld [H_SPRITEINDEX], a call SetSpriteMovementBytesToFF - ld a, $8 + ld a, SPRITE_FACING_LEFT ld [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay call Delay3 xor a ld [wJoyIgnore], a - inc a - ld [wd528], a + inc a ; PLAYER_DIR_RIGHT + ld [wPlayerMovingDirection], a ld a, $1 ld [hSpriteIndexOrTextID], a call DisplayTextID diff --git a/scripts/lab4.asm b/scripts/lab4.asm index 6d4bd923..21fee0c6 100755 --- a/scripts/lab4.asm +++ b/scripts/lab4.asm @@ -112,6 +112,4 @@ Lab4Text2: ; 75dda (1d:5dda) jp TextScriptEnd LoadFossilItemAndMonNameBank1D: ; 75de8 (1d:5de8) - ld b, BANK(LoadFossilItemAndMonName) - ld hl, LoadFossilItemAndMonName - jp Bankswitch + jpba LoadFossilItemAndMonName diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index 226c2d2d..ae6da40d 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -178,8 +178,8 @@ OaksLabScript6: ; 1cc36 (7:4c36) ld a, D_UP ld [wSimulatedJoypadStatesEnd], a call StartSimulatingJoypadStates - ld a, $8 - ld [wd528], a + ld a, PLAYER_DIR_UP + ld [wPlayerMovingDirection], a ld a, $7 ld [W_OAKSLABCURSCRIPT], a @@ -354,8 +354,8 @@ OaksLabScript10: ; 1cd6d (7:4d6d) xor a ; SPRITE_FACING_DOWN ld [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay - ld a, $8 - ld [wd528], a + ld a, PLAYER_DIR_UP + ld [wPlayerMovingDirection], a ld c, BANK(Music_MeetRival) ld a, MUSIC_MEET_RIVAL call PlayMusic @@ -414,8 +414,8 @@ OaksLabScript11: ; 1cdb9 (7:4db9) set 7, [hl] xor a ld [wJoyIgnore], a - ld a, $8 - ld [wd528], a + ld a, PLAYER_DIR_UP + ld [wPlayerMovingDirection], a ld a, $c ld [W_OAKSLABCURSCRIPT], a ret @@ -423,8 +423,8 @@ OaksLabScript11: ; 1cdb9 (7:4db9) OaksLabScript12: ; 1ce03 (7:4e03) ld a, $f0 ld [wJoyIgnore], a - ld a, $8 - ld [wd528], a + ld a, PLAYER_DIR_UP + ld [wPlayerMovingDirection], a call UpdateSprites ld a, $1 ld [wSpriteIndex], a diff --git a/scripts/pallettown.asm b/scripts/pallettown.asm index 327a32ff..b463c4d6 100755 --- a/scripts/pallettown.asm +++ b/scripts/pallettown.asm @@ -28,8 +28,8 @@ PalletTownScript0: ; 18e81 (6:4e81) ret nz xor a ld [hJoyHeld],a - ld a,4 - ld [wd528],a + ld a,PLAYER_DIR_DOWN + ld [wPlayerMovingDirection],a ld a,$FF call PlaySound ; stop music ld a, BANK(Music_MeetProfOak) @@ -190,8 +190,8 @@ OakAppearsText: ; 18fb0 (6:4fb0) ld [wEmotionBubbleSpriteIndex],a ; player's sprite ld [wWhichEmotionBubble],a ; EXCLAMATION_BUBBLE predef EmotionBubble - ld a,4 - ld [wd528],a + ld a,PLAYER_DIR_DOWN + ld [wPlayerMovingDirection],a jp TextScriptEnd OakWalksUpText: ; 18fce (6:4fce) diff --git a/scripts/pokemontower2.asm b/scripts/pokemontower2.asm index 8520b10b..6a54d549 100755 --- a/scripts/pokemontower2.asm +++ b/scripts/pokemontower2.asm @@ -33,15 +33,15 @@ PokemonTower2Script0: ; 6050f (18:450f) res 6, [hl] ld a, [wCoordIndex] cp $1 - ld a, $8 + ld a, PLAYER_DIR_UP ld b, SPRITE_FACING_DOWN jr nz, .asm_60544 ld hl, wd764 set 6, [hl] - ld a, $2 + ld a, PLAYER_DIR_LEFT ld b, SPRITE_FACING_RIGHT .asm_60544 - ld [wd528], a + ld [wPlayerMovingDirection], a ld a, $1 ld [H_SPRITEINDEX], a ld a, b diff --git a/scripts/redshouse2f.asm b/scripts/redshouse2f.asm index 8fcdc66e..2335e6d1 100755 --- a/scripts/redshouse2f.asm +++ b/scripts/redshouse2f.asm @@ -11,8 +11,8 @@ RedsHouse2FScriptPointers: ; 5c0bc (17:40bc) RedsHouse2FScript0: ; 5c0c0 (17:40c0) xor a ld [hJoyHeld],a - ld a,8 - ld [wd528],a + ld a,PLAYER_DIR_UP + ld [wPlayerMovingDirection],a ld a,1 ld [W_REDSHOUSE2CURSCRIPT],a ret diff --git a/scripts/route22.asm b/scripts/route22.asm index f125030e..01f8bee8 100755 --- a/scripts/route22.asm +++ b/scripts/route22.asm @@ -67,8 +67,8 @@ Route22Script0: ; 50f00 (14:4f00) ld [hJoyHeld], a ld a, $f0 ld [wJoyIgnore], a - ld a, $2 - ld [wd528], a + ld a, PLAYER_DIR_LEFT + ld [wPlayerMovingDirection], a ld a, [wd7eb] bit 0, a ; is this the rival battle at the beginning of the game? jr nz, .firstRivalBattle @@ -111,8 +111,8 @@ Route22Script1: ; 50f62 (14:4f62) ld a, [wcf0d] cp $1 jr nz, .asm_50f78 - ld a, $4 - ld [wd528], a + ld a, PLAYER_DIR_DOWN + ld [wPlayerMovingDirection], a ld a, SPRITE_FACING_UP jr .asm_50f7a .asm_50f78 @@ -270,13 +270,13 @@ Route22Script4: ; 51087 (14:5087) ld a, [wcf0d] cp $1 jr nz, .asm_510a1 - ld a, $4 - ld [wd528], a + ld a, PLAYER_DIR_DOWN + ld [wPlayerMovingDirection], a ld a, SPRITE_FACING_UP jr .asm_510a8 .asm_510a1 - ld a, $2 - ld [wd528], a + ld a, PLAYER_DIR_LEFT + ld [wPlayerMovingDirection], a ld a, SPRITE_FACING_RIGHT .asm_510a8 ld [hSpriteFacingDirection], a @@ -314,13 +314,13 @@ Route22Script5: ; 510df (14:50df) ld a, [wcf0d] cp $1 jr nz, .asm_510fb - ld a, $4 - ld [wd528], a + ld a, PLAYER_DIR_DOWN + ld [wPlayerMovingDirection], a ld a, SPRITE_FACING_UP jr .asm_51102 .asm_510fb - ld a, $2 - ld [wd528], a + ld a, PLAYER_DIR_LEFT + ld [wPlayerMovingDirection], a ld a, SPRITE_FACING_RIGHT .asm_51102 ld [hSpriteFacingDirection], a diff --git a/scripts/route23.asm b/scripts/route23.asm index a258b88a..cfcf41f5 100755 --- a/scripts/route23.asm +++ b/scripts/route23.asm @@ -52,7 +52,7 @@ Route23Script0: ; 51219 (14:5219) ld [hSpriteIndexOrTextID], a ld a, c ld [wWhichBadge], a - ld b, $2 + ld b, FLAG_TEST ld hl, wd7ed predef FlagActionPredef ld a, c @@ -193,7 +193,7 @@ Route23Script_51346: ; 51346 (14:5346) ld a, [wWhichBadge] inc a ld c, a - ld b, $2 + ld b, FLAG_TEST ld hl, W_OBTAINEDBADGES predef FlagActionPredef ld a, c @@ -210,7 +210,7 @@ Route23Script_51346: ; 51346 (14:5346) call PrintText ld a, [wWhichBadge] ld c, a - ld b, $1 + ld b, FLAG_SET ld hl, wd7ed predef FlagActionPredef ld a, $2 diff --git a/scripts/route5gate.asm b/scripts/route5gate.asm index 1ccf27af..35f3a020 100755 --- a/scripts/route5gate.asm +++ b/scripts/route5gate.asm @@ -22,8 +22,8 @@ Route5GateScript0: ; 1df50 (7:5f50) ld hl, CoordsData_1df8f call ArePlayerCoordsInArray ret nc - ld a, $2 - ld [wd528], a + ld a, PLAYER_DIR_LEFT + ld [wPlayerMovingDirection], a xor a ld [hJoyHeld], a callba RemoveGuardDrink diff --git a/scripts/route6gate.asm b/scripts/route6gate.asm index d1aed2df..a4b6149c 100755 --- a/scripts/route6gate.asm +++ b/scripts/route6gate.asm @@ -16,8 +16,8 @@ Route6GateScript0: ; 1e04e (7:604e) ld hl, CoordsData_1e08c call ArePlayerCoordsInArray ret nc - ld a, $1 - ld [wd528], a + ld a, PLAYER_DIR_RIGHT + ld [wPlayerMovingDirection], a xor a ld [hJoyHeld], a callba RemoveGuardDrink diff --git a/scripts/route7gate.asm b/scripts/route7gate.asm index d73dc566..b55f813c 100755 --- a/scripts/route7gate.asm +++ b/scripts/route7gate.asm @@ -28,8 +28,8 @@ Route7GateScript0: ; 1e128 (7:6128) ld hl, CoordsData_1e167 call ArePlayerCoordsInArray ret nc - ld a, $8 - ld [wd528], a + ld a, PLAYER_DIR_UP + ld [wPlayerMovingDirection], a xor a ld [hJoyHeld], a callba RemoveGuardDrink diff --git a/scripts/route8gate.asm b/scripts/route8gate.asm index 261a7a1e..96bfa875 100755 --- a/scripts/route8gate.asm +++ b/scripts/route8gate.asm @@ -27,8 +27,8 @@ Route8GateScript0: ; 1e1ee (7:61ee) ld hl, CoordsData_1e22c call ArePlayerCoordsInArray ret nc - ld a, $2 - ld [wd528], a + ld a, PLAYER_DIR_LEFT + ld [wPlayerMovingDirection], a xor a ld [hJoyHeld], a callba RemoveGuardDrink diff --git a/scripts/safarizoneentrance.asm b/scripts/safarizoneentrance.asm index 2e5b55f7..ab54dd8a 100755 --- a/scripts/safarizoneentrance.asm +++ b/scripts/safarizoneentrance.asm @@ -72,8 +72,8 @@ SafariZoneEntranceScriptPointers: ; 751d9 (1d:51d9) ret .SafariZoneEntranceScript5 - ld a, $4 - ld [wd528], a + ld a, PLAYER_DIR_DOWN + ld [wPlayerMovingDirection], a ld hl, wd790 bit 6, [hl] res 6, [hl] diff --git a/scripts/silphco11.asm b/scripts/silphco11.asm index b4f94b13..62591476 100755 --- a/scripts/silphco11.asm +++ b/scripts/silphco11.asm @@ -199,7 +199,7 @@ MovementData_62216: ; 62216 (18:6216) db $FF SilphCo11Script_6221a: ; 6221a (18:621a) - ld [wd528], a + ld [wPlayerMovingDirection], a ld a, $3 ld [H_SPRITEINDEX], a ld a, b @@ -213,11 +213,11 @@ SilphCo11Script5: ; 62227 (18:6227) ld a, [wcf0d] cp $1 jr z, .asm_6223c - ld a, $2 + ld a, PLAYER_DIR_LEFT ld b, SPRITE_FACING_RIGHT jr .asm_62240 .asm_6223c - ld a, $8 + ld a, PLAYER_DIR_UP ld b, SPRITE_FACING_DOWN .asm_62240 call SilphCo11Script_6221a @@ -247,11 +247,11 @@ SilphCo11Script3: ; 6226a (18:626a) ld a, [wcf0d] cp $1 jr z, .asm_62284 - ld a, $2 + ld a, PLAYER_DIR_LEFT ld b, SPRITE_FACING_RIGHT jr .asm_62288 .asm_62284 - ld a, $8 + ld a, PLAYER_DIR_UP ld b, SPRITE_FACING_DOWN .asm_62288 call SilphCo11Script_6221a diff --git a/scripts/silphco7.asm b/scripts/silphco7.asm index 5043b947..78d6e0d7 100755 --- a/scripts/silphco7.asm +++ b/scripts/silphco7.asm @@ -127,8 +127,8 @@ SilphCo7Script0: ; 51c23 (14:5c23) ld [hJoyHeld], a ld a, $f0 ld [wJoyIgnore], a - ld a, $4 - ld [wd528], a + ld a, PLAYER_DIR_DOWN + ld [wPlayerMovingDirection], a ld a, $ff ld [wc0ee], a call PlaySound @@ -209,8 +209,8 @@ SilphCo7Script4: ; 51cc8 (14:5cc8) ld [wJoyIgnore], a ld hl, wd82f set 0, [hl] - ld a, $4 - ld [wd528], a + ld a, PLAYER_DIR_DOWN + ld [wPlayerMovingDirection], a ld a, $9 ld [H_SPRITEINDEX], a ld a, SPRITE_FACING_UP diff --git a/scripts/ssanne2.asm b/scripts/ssanne2.asm index d4651a22..bc13d4b6 100755 --- a/scripts/ssanne2.asm +++ b/scripts/ssanne2.asm @@ -74,8 +74,8 @@ SSAnne2Script_61416: ; 61416 (18:5416) ld a, [W_XCOORD] cp $25 jr nz, .asm_61426 - ld a, $2 - ld [wd528], a + ld a, PLAYER_DIR_LEFT + ld [wPlayerMovingDirection], a ld a, SPRITE_FACING_RIGHT jr .asm_61427 .asm_61426 diff --git a/scripts/viridiangym.asm b/scripts/viridiangym.asm index 7a577095..40484d21 100755 --- a/scripts/viridiangym.asm +++ b/scripts/viridiangym.asm @@ -128,9 +128,7 @@ ViridianGymScript4: ; 7496b (1d:496b) ld [W_CURMAPSCRIPT], a ret .asm_74980 - ld b, BANK(LoadSpinnerArrowTiles) - ld hl, LoadSpinnerArrowTiles - jp Bankswitch + jpba LoadSpinnerArrowTiles ViridianGymScript3: ; 74988 (1d:4988) ld a, [W_ISINBATTLE] @@ -733,6 +733,8 @@ wWhichTrade:: ; cd3d ; which entry from TradeMons to select wTrainerSpriteOffset:: ; cd3d + +wUnusedCD3D:: ; cd3d ds 1 wSSAnneSmokeX:: ; cd3e @@ -1699,7 +1701,11 @@ W_MONHLEARNSET:: ; d0cc flag_array 50 + 5 ds 1 -wd0d4:: ds 3 ; temp storage for hTilesetType +wSavedTilesetType:: ; d0d4 +; saved at the start of a battle and then written back at the end of the battle + ds 1 + + ds 2 W_MONHPADDING:: ; d0d7 @@ -2064,9 +2070,14 @@ W_SPRITESETID:: ; d3a8 ; sprite set ID for the current map ds 1 -wd3a9:: ds 1 ; used when getting the object data pointer -wd3aa:: ds 3 ; second part of the pointer -wd3ad:: ds 1 ; used as the beginning value for copying warp data +wObjectDataPointerTemp:: ; d3a9 + ds 2 + + ds 2 + +wMapBackgroundTile:: ; d3ad +; the tile shown outside the boundaries of the map + ds 1 wNumberOfWarps:: ; d3ae ; number of warps in current map @@ -2082,9 +2093,17 @@ wDestinationWarpID:: ; d42f ds 128 -wd4b0:: ds 1 ; number of signs on the map -wd4b1:: ds 32 ; starting address for sign coords -wd4d1:: ds 16 ; starting address for sign text IDs +wNumSigns:: ; d4b0 +; number of signs in the current map (up to 16) + ds 1 + +wSignCoords:: ; d4b1 +; 2 bytes each +; Y, X + ds 32 + +wSignTextIDs:: ; d4d1 + ds 16 W_NUMSPRITES:: ; d4e1 ; number of sprites on the current map @@ -2105,16 +2124,35 @@ W_MAPSPRITEEXTRADATA:: ; d504 ; two bytes per sprite (trainer class/item ID, trainer set ID) ds 32 -wd524:: ds 1 ; map height in 2x2 metatiles, also used with checking connections -wd525:: ds 1 ; map width in 2x2 metatiles, also used with checking connections +wCurrentMapHeight2:: ; d524 +; map height in 2x2 meta-tiles + ds 1 + +wCurrentMapWidth2:: ; d525 +; map width in 2x2 meta-tiles + ds 1 wMapViewVRAMPointer:: ; d526 ; the address of the upper left corner of the visible portion of the BG tile map in VRAM ds 2 -wd528:: ds 1 ; additional storage for directions -wd529:: ds 1 ; same case as above, but used differently -wd52a:: ds 1 ; same case as above +; In the comments for the player direction variables below, "moving" refers to +; both walking and changing facing direction without taking a step. + +wPlayerMovingDirection:: ; d528 +; if the player is moving, the current direction +; if the player is not moving, zero +; map scripts write to this in order to change the player's facing direction + ds 1 + +wPlayerLastStopDirection:: ; d529 +; the direction in which the player was moving before the player last stopped + ds 1 + +wPlayerDirection:: ; d52a +; if the player is moving, the current direction +; if the player is not moving, the last the direction in which the player moved + ds 1 W_TILESETBANK:: ; d52b ds 1 |