diff options
Diffstat (limited to 'engine')
36 files changed, 395 insertions, 360 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 1bd48988..6d0f0e5f 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -2170,8 +2170,8 @@ ChangeMonPic: ; 79793 (1e:5793) pop af ld [wBattleMonSpecies2], a .done - ld b, $1 - jp GoPAL_SET + ld b, SET_PAL_BATTLE + jp RunPaletteCommand AnimationHideEnemyMonPic: ; 797d8 (1e:57d8) ; Hides the enemy mon's sprite diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 9dbcf179..0b534dda 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -184,8 +184,8 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) inc a ld [H_AUTOBGTRANSFERENABLED], a call Delay3 - ld b, $1 - call GoPAL_SET + ld b, SET_PAL_BATTLE + call RunPaletteCommand call HideSprites jpab PrintBeginningBattleText @@ -788,7 +788,7 @@ CheckNumAttacksLeft: ; 3c50f (f:450f) HandleEnemyMonFainted: ; 3c525 (f:4525) xor a - ld [wccf0], a + ld [wInHandlePlayerMonFainted], a call FaintEnemyPokemon call AnyPartyAlive ld a, d @@ -888,9 +888,9 @@ FaintEnemyPokemon: ; 0x3c567 ld a, [hli] or [hl] jr nz, .playermonnotfaint - ld a, [wccf0] - and a - jr nz, .playermonnotfaint + ld a, [wInHandlePlayerMonFainted] + and a ; was this called by HandlePlayerMonFainted? + jr nz, .playermonnotfaint ; if so, don't call RemoveFaintedPlayerMon twice call RemoveFaintedPlayerMon .playermonnotfaint call AnyPartyAlive @@ -950,11 +950,13 @@ EnemyMonFaintedText: ; 0x3c63e db "@" EndLowHealthAlarm: ; 3c643 (f:4643) +; This function is called when the player has the won the battle. It turns off +; the low health alarm and prevents it from reactivating until the next battle. xor a - ld [wLowHealthAlarm], a ;disable low health alarm + ld [wLowHealthAlarm], a ; turn off low health alarm ld [wChannelSoundIDs + CH4], a inc a - ld [wccf6], a + ld [wLowHealthAlarmDisabled], a ; prevent it from reactivating ret AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f) @@ -976,7 +978,7 @@ AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f) ; stores whether enemy ran in Z flag ReplaceFaintedEnemyMon: ; 3c664 (f:4664) - ld hl, wcf1e + ld hl, wEnemyHPBarColor ld e, $30 call GetBattleHealthBarColor callab DrawEnemyPokeballs @@ -1053,8 +1055,8 @@ PlayBattleVictoryMusic: ; 3c6ee (f:46ee) jp Delay3 HandlePlayerMonFainted: ; 3c700 (f:4700) - ld a, $1 - ld [wccf0], a + ld a, 1 + ld [wInHandlePlayerMonFainted], a call RemoveFaintedPlayerMon call AnyPartyAlive ; test if any more mons are alive ld a, d @@ -1115,9 +1117,15 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741) call SlideDownFaintedMonPic ld a, $1 ld [wBattleResult], a - ld a, [wccf0] - and a - ret z + +; When the player mon and enemy mon faint at the same time and the fact that the +; enemy mon has fainted is detected first (e.g. when the player mon knocks out +; the enemy mon using a move with recoil and faints due to the recoil), don't +; play the player mon's cry or show the "[player mon] fainted!" message. + ld a, [wInHandlePlayerMonFainted] + and a ; was this called by HandleEnemyMonFainted? + ret z ; if so, return + ld a, [wBattleMonSpecies] call PlayCry ld hl, PlayerMonFaintedText @@ -1199,7 +1207,7 @@ ChooseNextMon: ; 3c7d8 (f:47d8) call GBPalWhiteOut call LoadHudTilePatterns call LoadScreenTilesFromBuffer1 - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call GBPalNormal call SendOutMon ld hl, wEnemyMonHP @@ -1228,8 +1236,8 @@ HandlePlayerBlackOut: ; 3c837 (f:4837) cp OAKS_LAB ret z ; starter battle in oak's lab: don't black out .notSony1Battle - ld b, $0 - call GoPAL_SET + ld b, SET_PAL_BATTLE_BLACK + call RunPaletteCommand ld hl, PlayerBlackedOutText2 ld a, [wLinkState] cp LINK_STATE_BATTLING @@ -1494,8 +1502,8 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) coord hl, 0, 0 lb bc, 4, 11 call ClearScreenArea - ld b,1 - call GoPAL_SET + ld b, SET_PAL_BATTLE + call RunPaletteCommand call GBPalNormal ld hl,TrainerSentOutText call PrintText @@ -1829,8 +1837,8 @@ SendOutMon: ; 3cc91 (f:4c91) ld [W_PLAYERDISABLEDMOVE], a ld [wPlayerDisabledMoveNumber], a ld [wPlayerMonMinimized], a - ld b, $1 - call GoPAL_SET + ld b, SET_PAL_BATTLE + call RunPaletteCommand ld hl, W_ENEMYBATTSTATUS1 res UsingTrappingMove, [hl] ld a, $1 @@ -1926,17 +1934,17 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60) predef DrawHP ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - ld hl, wcf1d + ld hl, wPlayerHPBarColor call GetBattleHealthBarColor ld hl, wBattleMonHP ld a, [hli] or [hl] jr z, .asm_3cdd9 - ld a, [wccf6] - and a - ret nz - ld a, [wcf1d] - cp $2 + ld a, [wLowHealthAlarmDisabled] + and a ; has the alarm been disabled because the player has already won? + ret nz ; if so, return + ld a, [wPlayerHPBarColor] + cp HP_BAR_RED jr z, .asm_3cde6 .asm_3cdd9 ld hl, wLowHealthAlarm @@ -2039,7 +2047,7 @@ DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec) call DrawHPBar ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a - ld hl, wcf1e + ld hl, wEnemyHPBarColor GetBattleHealthBarColor: ; 3ce90 (f:4e90) ld b, [hl] @@ -2047,8 +2055,8 @@ GetBattleHealthBarColor: ; 3ce90 (f:4e90) ld a, [hl] cp b ret z - ld b, $1 - jp GoPAL_SET + ld b, SET_PAL_BATTLE + jp RunPaletteCommand ; center's mon's name on the battle screen ; if the name is 1 or 2 letters long, it is printed 2 spaces more to the right than usual @@ -2397,7 +2405,7 @@ PartyMenuOrRockOrRun: call GBPalWhiteOut call LoadHudTilePatterns call LoadScreenTilesFromBuffer2 - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call GBPalNormal jp DisplayBattleMenu .partyMonDeselected @@ -2486,7 +2494,7 @@ PartyMenuOrRockOrRun: call ClearSprites call LoadHudTilePatterns call LoadScreenTilesFromBuffer1 - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call GBPalNormal ; fall through to SwitchPlayerMon @@ -2634,7 +2642,7 @@ MoveSelectionMenu: ; 3d219 (f:5219) cp LINK_STATE_BATTLING jr z, .matchedkeyspicked ld a, [W_FLAGS_D733] - bit 0, a + bit BIT_TEST_BATTLE, a ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON | SELECT jr z, .matchedkeyspicked ld b, $ff @@ -2662,7 +2670,7 @@ SelectMenuItem: ; 3d2fe (f:52fe) jr .select .battleselect ld a, [W_FLAGS_D733] - bit 0, a + bit BIT_TEST_BATTLE, a jr nz, .select call PrintMenuItem ld a, [wMenuItemToSwap] @@ -6170,8 +6178,8 @@ GetCurrentMove: ; 3eabe (f:6abe) .player ld de, W_PLAYERMOVENUM ld a, [W_FLAGS_D733] - bit 0, a - ld a, [wccd9] + bit BIT_TEST_BATTLE, a + ld a, [wTestBattlePlayerSelectedMove] jr nz, .selected ld a, [wPlayerSelectedMove] .selected @@ -6201,7 +6209,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01) call GetMonHeader ld a, [W_ENEMYBATTSTATUS3] bit Transformed, a ; is enemy mon transformed? - ld hl, wcceb ; copied DVs from when it used Transform + ld hl, wTransformedEnemyMonOriginalDVs ; original DVs before transforming ld a, [hli] ld b, [hl] jr nz, .storeDVs @@ -6879,7 +6887,7 @@ InitBattleCommon: ; 3ef3d (f:6f3d) ld [wEnemyMonPartyPos], a ld a, $2 ld [W_ISINBATTLE], a - jp InitBattle_Common + jp _InitBattleCommon InitWildBattle: ; 3ef8b (f:6f8b) ld a, $1 @@ -6931,9 +6939,9 @@ InitWildBattle: ; 3ef8b (f:6f8b) predef CopyUncompressedPicToTilemap ; common code that executes after init battle code specific to trainer or wild battles -InitBattle_Common: ; 3efeb (f:6feb) - ld b, $0 - call GoPAL_SET +_InitBattleCommon: ; 3efeb (f:6feb) + ld b, SET_PAL_BATTLE_BLACK + call RunPaletteCommand call SlidePlayerAndEnemySilhouettesOnScreen xor a ld [H_AUTOBGTRANSFERENABLED], a diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index 433588e3..ab3e3c19 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -76,11 +76,11 @@ GainExperience: ; 5524f (15:524f) ld b, [hl] ld a, [wPlayerID + 1] cp b - ld a, $0 + ld a, 0 jr z, .next .tradedMon call BoostExp ; traded mon exp boost - ld a, $1 + ld a, 1 .next ld [wGainBoostedExp], a ld a, [W_ISINBATTLE] @@ -92,12 +92,12 @@ GainExperience: ; 5524f (15:524f) ; add the gained exp to the party mon's exp ld b, [hl] ld a, [H_QUOTIENT + 3] - ld [wcf4c], a + ld [wExpAmountGained + 1], a add b ld [hld], a ld b, [hl] ld a, [H_QUOTIENT + 2] - ld [wcf4b], a + ld [wExpAmountGained], a adc b ld [hl], a jr nc, .noCarry diff --git a/engine/battle/init_battle_variables.asm b/engine/battle/init_battle_variables.asm index 3c926858..6a4cd771 100644 --- a/engine/battle/init_battle_variables.asm +++ b/engine/battle/init_battle_variables.asm @@ -16,17 +16,17 @@ InitBattleVariables: ; 525af (14:65af) ld [wPlayerMonNumber], a ld [wEscapedFromBattle], a ld [wMapPalOffset], a - ld hl, wcf1d - ld [hli], a - ld [hl], a + ld hl, wPlayerHPBarColor + ld [hli], a ; wPlayerHPBarColor + ld [hl], a ; wEnemyHPBarColor ld hl, wCanEvolveFlags ld b, $3c .loop ld [hli], a dec b jr nz, .loop - inc a - ld [wccd9], a + inc a ; POUND + ld [wTestBattlePlayerSelectedMove], a ld a, [W_CURMAP] cp SAFARI_ZONE_EAST jr c, .notSafariBattle diff --git a/engine/battle/moveEffects/transform_effect.asm b/engine/battle/moveEffects/transform_effect.asm index 185d47af..6a40eda2 100644 --- a/engine/battle/moveEffects/transform_effect.asm +++ b/engine/battle/moveEffects/transform_effect.asm @@ -67,12 +67,12 @@ TransformEffect_: ; 3bab1 (e:7ab1) ld a, [H_WHOSETURN] and a jr z, .next -; save enemy mon DVs in wcceb/wccec (enemy turn only) +; save enemy mon DVs at wTransformedEnemyMonOriginalDVs ld a, [de] - ld [wcceb], a + ld [wTransformedEnemyMonOriginalDVs], a inc de ld a, [de] - ld [wccec], a + ld [wTransformedEnemyMonOriginalDVs + 1], a dec de .next ; DVs diff --git a/engine/battle/scroll_draw_trainer_pic.asm b/engine/battle/scroll_draw_trainer_pic.asm index b32650e3..5949208c 100644 --- a/engine/battle/scroll_draw_trainer_pic.asm +++ b/engine/battle/scroll_draw_trainer_pic.asm @@ -3,8 +3,8 @@ _ScrollTrainerPicAfterBattle: ; 396d3 (e:56d3) ; the screen from the right. xor a ld [wEnemyMonSpecies2], a - ld b, $1 - call GoPAL_SET + ld b, SET_PAL_BATTLE + call RunPaletteCommand callab _LoadTrainerPic coord hl, 19, 0 ld c, $0 diff --git a/engine/cable_club.asm b/engine/cable_club.asm index 0759bd11..465561ca 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -836,7 +836,7 @@ TradeCenter_Trade: call ClearScreen call LoadHpBarAndStatusTilePatterns xor a - ld [wcc5b], a + ld [wUnusedCC5B], a ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .usingExternalClock diff --git a/engine/clear_save.asm b/engine/clear_save.asm index d4f05071..adbef1a4 100755 --- a/engine/clear_save.asm +++ b/engine/clear_save.asm @@ -1,6 +1,6 @@ DoClearSaveDialogue: ; 1c98a (7:498a) call ClearScreen - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call LoadFontTilePatterns call LoadTextBoxTilePatterns ld hl, ClearSaveDataText diff --git a/engine/evolution.asm b/engine/evolution.asm index 8fbf568a..c65cc293 100755 --- a/engine/evolution.asm +++ b/engine/evolution.asm @@ -21,8 +21,8 @@ EvolveMon: ; 7bde9 (1e:7de9) ld [H_AUTOBGTRANSFERENABLED], a ld [hTilesetType], a ld a, [wEvoOldSpecies] - ld [wcf1d], a - ld c, $0 + ld [wWholeScreenPaletteMonSpecies], a + ld c, 0 call EvolutionSetWholeScreenPalette ld a, [wEvoNewSpecies] ld [wcf91], a @@ -46,7 +46,7 @@ EvolveMon: ; 7bde9 (1e:7de9) call PlayMusic ld c, 80 call DelayFrames - ld c, $1 + ld c, 1 ; set PAL_BLACK instead of mon palette call EvolutionSetWholeScreenPalette lb bc, $1, $10 .animLoop @@ -66,13 +66,13 @@ EvolveMon: ; 7bde9 (1e:7de9) call Evolution_ChangeMonPic ; show the new species pic ld a, [wEvoNewSpecies] .done - ld [wcf1d], a + ld [wWholeScreenPaletteMonSpecies], a ld a, $ff ld [wNewSoundID], a call PlaySound - ld a, [wcf1d] + ld a, [wWholeScreenPaletteMonSpecies] call PlayCry - ld c, $0 + ld c, 0 call EvolutionSetWholeScreenPalette pop af ld [wd0b5], a @@ -94,8 +94,8 @@ EvolveMon: ; 7bde9 (1e:7de9) jr .done EvolutionSetWholeScreenPalette: ; 7beb4 (1e:7eb4) - ld b, $b - jp GoPAL_SET + ld b, SET_PAL_POKEMON_WHOLE_SCREEN + jp RunPaletteCommand Evolution_LoadPic: ; 7beb9 (1e:7eb9) call GetMonHeader diff --git a/engine/game_corner_slots2.asm b/engine/game_corner_slots2.asm index 643536ea..58386ba1 100755 --- a/engine/game_corner_slots2.asm +++ b/engine/game_corner_slots2.asm @@ -3,7 +3,7 @@ AbleToPlaySlotsCheck: ; 2ff09 (b:7f09) and $8 jr z, .done ; not able ld b, COIN_CASE - predef IsItemInBag_ ; IsItemInBag_ + predef GetQuantityOfItemInBag ld a, b and a ld b, (GameCornerCoinCaseText_id - TextPredefs) / 2 + 1 diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index 062950cf..d95c01c5 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -104,7 +104,7 @@ HoFShowMonOrPlayer: ; 70278 (1c:4278) ld [wcf91], a ld [wd0b5], a ld [wBattleMonSpecies2], a - ld [wcf1d], a + ld [wWholeScreenPaletteMonSpecies], a ld a, [wHoFMonOrPlayer] and a jr z, .showMon @@ -117,9 +117,9 @@ HoFShowMonOrPlayer: ; 70278 (1c:4278) call LoadFrontSpriteByMonIndex predef LoadMonBackPic .next1 - ld b, $b - ld c, $0 - call GoPAL_SET + ld b, SET_PAL_POKEMON_WHOLE_SCREEN + ld c, 0 + call RunPaletteCommand ld a, %11100100 ld [rBGP], a ld c, $31 ; back pic @@ -243,7 +243,7 @@ HoFDisplayPlayerStats: ; 70377 (1c:4377) call HoFPrintTextAndDelay ld hl, DexRatingText call HoFPrintTextAndDelay - ld hl, wcc5d + ld hl, wDexRatingText HoFPrintTextAndDelay: ; 703e2 (1c:43e2) call PrintText diff --git a/engine/intro.asm b/engine/intro.asm index 46f0c37a..29aa4ef4 100755 --- a/engine/intro.asm +++ b/engine/intro.asm @@ -1,3 +1,7 @@ +MOVE_GENGAR_RIGHT EQU $00 +MOVE_GENGAR_LEFT EQU $01 +MOVE_NIDORINO_RIGHT EQU $ff + PlayIntro: ; 41682 (10:5682) xor a ld [hJoyHeld], a @@ -14,8 +18,8 @@ PlayIntro: ; 41682 (10:5682) ret PlayIntroScene: ; 4169d (10:569d) - ld b, $7 - call GoPAL_SET + ld b, SET_PAL_NIDORINO_INTRO + call RunPaletteCommand ld a, %11100100 ld [rBGP], a ld [rOBP0], a @@ -30,7 +34,7 @@ PlayIntroScene: ; 4169d (10:569d) ld [W_BASECOORDY], a lb bc, 6, 6 call InitIntroNidorinoOAM - ld de, $28ff ; move Nidorino right by 80 pixels + lb de, 80 / 2, MOVE_NIDORINO_RIGHT call IntroMoveMon ret c @@ -69,7 +73,7 @@ PlayIntroScene: ; 4169d (10:569d) call IntroCopyTiles ld a, SFX_INTRO_RAISE call PlaySound - ld de, $401 ; move Gengar left by 8 pixels + lb de, 8 / 2, MOVE_GENGAR_LEFT call IntroMoveMon ld c, $1e call CheckForUserInterruption @@ -80,7 +84,7 @@ PlayIntroScene: ; 4169d (10:569d) call IntroCopyTiles ld a, SFX_INTRO_CRASH call PlaySound - ld de, $800 ; move Gengar right by 16 pixels + lb de, 16 / 2, MOVE_GENGAR_RIGHT call IntroMoveMon ; hip ld a, SFX_INTRO_HIP @@ -93,7 +97,7 @@ PlayIntroScene: ; 4169d (10:569d) call CheckForUserInterruption ret c - ld de, $401 ; move Gengar left by 8 pixels + lb de, 8 / 2, MOVE_GENGAR_LEFT call IntroMoveMon ld b, $3 call IntroCopyTiles @@ -298,8 +302,8 @@ LoadIntroGraphics: ; 41852 (10:5852) jp FarCopyData2 PlayShootingStar: ; 4188a (10:588a) - ld b, $c - call GoPAL_SET + ld b, SET_PAL_GAME_FREAK_INTRO + call RunPaletteCommand callba LoadCopyrightAndTextBoxTiles ld a, $e4 ld [rBGP], a diff --git a/engine/items/items.asm b/engine/items/items.asm index 4ba3c706..f0666587 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -127,7 +127,7 @@ ItemUseBall: ; d687 (3:5687) ld hl,W_NUMSAFARIBALLS dec [hl] .skipSafariZoneCode - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand ld a,$43 ld [wd11e],a call LoadScreenTilesFromBuffer1 ;restore screenBuffer from Backup @@ -364,7 +364,7 @@ ItemUseBall: ; d687 (3:5687) jr .next16 .next15 set Transformed,[hl] - ld hl,wcceb + ld hl,wTransformedEnemyMonOriginalDVs ld a,[wEnemyMonDVs] ld [hli],a ld a,[wEnemyMonDVs + 1] @@ -1111,7 +1111,7 @@ ItemUseMedicine: ; dabb (3:5abb) and a ; using Softboiled? ret nz ; if so, return call GBPalWhiteOut - call z,GoPAL_SET_CF1C + call z,RunDefaultPaletteCommand ld a,[W_ISINBATTLE] and a ret nz @@ -1324,7 +1324,7 @@ ItemUseRock: ; df67 (3:5f67) BaitRockCommon: ; df7f (3:5f7f) ld [W_ANIMATIONID],a xor a - ld [wcc5b],a + ld [wAnimationType],a ld [H_WHOSETURN],a ld [de],a ; zero escape factor (for bait), zero bait factor (for rock) .randomLoop ; loop until a random number less than 5 is generated @@ -1928,7 +1928,7 @@ ItemUsePPRestore: ; e31e (3:631e) pop af ld [wWhichPokemon],a call GBPalWhiteOut - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand jp RemoveUsedItem .afterRestoringPP ; after using a (Max) Ether/Elixir ld a,[wWhichPokemon] @@ -2032,7 +2032,7 @@ ItemUsePPRestore: ; e31e (3:631e) call ItemUseNoEffect .itemNotUsed call GBPalWhiteOut - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand pop af xor a ld [wActionResultOrTookBattleTurn],a ; item use failed @@ -2105,16 +2105,16 @@ ItemUseTMHM: ; e479 (3:6479) push af .chooseMon ld hl,wcf4b - ld de,wd036 + ld de,wTempMoveNameBuffer ld bc,14 - call CopyData + call CopyData ; save the move name because DisplayPartyMenu will overwrite it ld a,$ff ld [wUpdateSpritesEnabled],a ld a,TMHM_PARTY_MENU ld [wPartyMenuTypeOrMessageID],a call DisplayPartyMenu push af - ld hl,wd036 + ld hl,wTempMoveNameBuffer ld de,wcf4b ld bc,14 call CopyData @@ -2125,7 +2125,7 @@ ItemUseTMHM: ; e479 (3:6479) pop af call GBPalWhiteOutWithDelay3 call ClearSprites - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand jp LoadScreenTilesFromBuffer1 ; restore saved screen .checkIfAbleToLearnMove predef CanLearnTM ; check if the pokemon can learn the move @@ -2201,7 +2201,7 @@ ItemUseNotYoursToUse: ; e586 (3:6586) jr ItemUseFailed ThrowBallAtTrainerMon: ; e58b (3:658b) - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call LoadScreenTilesFromBuffer1 ; restore saved screen call Delay3 ld a,TOSS_ANIM diff --git a/engine/learn_move.asm b/engine/learn_move.asm index 46d30bd9..c0ced4a0 100755 --- a/engine/learn_move.asm +++ b/engine/learn_move.asm @@ -4,7 +4,7 @@ LearnMove: ; 6e43 (1:6e43) ld hl, wPartyMonNicks call GetPartyMonName ld hl, wcd6d - ld de, wd036 + ld de, wLearnMoveMonName ld bc, NAME_LENGTH call CopyData @@ -16,13 +16,13 @@ DontAbandonLearning: ; 6e5b (1:6e5b) ld d, h ld e, l ld b, NUM_MOVES -.asm_6e6b +.findEmptyMoveSlotLoop ld a, [hl] and a - jr z, .asm_6e8b + jr z, .next inc hl dec b - jr nz, .asm_6e6b + jr nz, .findEmptyMoveSlotLoop push de call TryingToLearn pop de @@ -35,7 +35,7 @@ DontAbandonLearning: ; 6e5b (1:6e5b) call PrintText pop de pop hl -.asm_6e8b +.next ld a, [wMoveNum] ld [hl], a ld bc, wPartyMon1PP - wPartyMon1Moves @@ -86,13 +86,13 @@ AbandonLearning: ; 6eda (1:6eda) jp nz, DontAbandonLearning ld hl, DidNotLearnText call PrintText - ld b, $0 + ld b, 0 ret PrintLearnedMove: ; 6efe (1:6efe) ld hl, LearnedMove1Text call PrintText - ld b, $1 + ld b, 1 ret TryingToLearn: ; 6f07 (1:6f07) @@ -108,7 +108,7 @@ TryingToLearn: ; 6f07 (1:6f07) ld a, [wCurrentMenuItem] rra ret c - ld bc, - NUM_MOVES + ld bc, -NUM_MOVES add hl, bc push hl ld de, wMoves @@ -121,8 +121,8 @@ TryingToLearn: ; 6f07 (1:6f07) ld hl, WhichMoveToForgetText call PrintText coord hl, 4, 7 - ld b, $4 - ld c, $e + ld b, 4 + ld c, 14 call TextBoxBorder coord hl, 6, 8 ld de, wMovesString @@ -160,7 +160,7 @@ TryingToLearn: ; 6f07 (1:6f07) push hl ld a, [wCurrentMenuItem] ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] push af diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index 072a19d3..e8e48b79 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -450,7 +450,7 @@ DisplayDepositWithdrawMenu: ; 2174b (8:574b) predef StatusScreen2 call LoadScreenTilesFromBuffer1 call ReloadTilesetTilePatterns - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call LoadGBPal jr .loop diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm index 3e28bc93..630c6c23 100755 --- a/engine/menu/diploma.asm +++ b/engine/menu/diploma.asm @@ -55,8 +55,8 @@ DisplayDiploma: ; 566e2 (15:66e2) call EnableLCD callba LoadTrainerInfoTextBoxTiles - ld b, $8 - call GoPAL_SET + ld b, SET_PAL_GENERIC + call RunPaletteCommand call Delay3 call GBPalNormal ld a, $90 diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm index e2dce785..5b8ae7f0 100755 --- a/engine/menu/league_pc.asm +++ b/engine/menu/league_pc.asm @@ -47,7 +47,7 @@ PKMNLeaguePC: ; 0x7657e res 6, [hl] call GBPalWhiteOutWithDelay3 call ClearScreen - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand jp GBPalNormal LeaguePCShowTeam: ; 765e5 (1d:65e5) @@ -86,15 +86,15 @@ LeaguePCShowMon: ; 76610 (1d:6610) ld [wcf91], a ld [wd0b5], a ld [wBattleMonSpecies2], a - ld [wcf1d], a + ld [wWholeScreenPaletteMonSpecies], a ld a, [hli] ld [wHoFMonLevel], a ld de, wcd6d ld bc, NAME_LENGTH call CopyData - ld b, $0B + ld b, SET_PAL_POKEMON_WHOLE_SCREEN ld c, 0 - call GoPAL_SET + call RunPaletteCommand coord hl, 12, 5 call GetMonHeader call LoadFrontSpriteByMonIndex diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index 24302c46..6c109cec 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -24,7 +24,7 @@ MainMenu: ; 5af2 (1:5af2) ld hl,wd72e res 6,[hl] call ClearScreen - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call LoadTextBoxTilePatterns call LoadFontTilePatterns ld hl,wd730 @@ -150,7 +150,7 @@ LinkMenu: ; 5c0a (1:5c0a) ld de, CableClubOptionsText call PlaceString xor a - ld [wcd37], a + ld [wUnusedCD37], a ld [wd72d], a ld hl, wTopMenuItemY ld a, $7 diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm index 85111cd6..978216c8 100755 --- a/engine/menu/naming_screen.asm +++ b/engine/menu/naming_screen.asm @@ -88,8 +88,8 @@ DisplayNamingScreen: ; 6596 (1:6596) call GBPalWhiteOutWithDelay3 call ClearScreen call UpdateSprites - ld b, $8 - call GoPAL_SET + ld b, SET_PAL_GENERIC + call RunPaletteCommand call LoadHpBarAndStatusTilePatterns call LoadEDTile callba LoadMonPartySpriteGfx @@ -163,7 +163,7 @@ DisplayNamingScreen: ; 6596 (1:6596) call GBPalWhiteOutWithDelay3 call ClearScreen call ClearSprites - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call GBPalNormal xor a ld [W_SUBANIMTRANSFORM], a diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm index d83c4fbe..f3e1a138 100755 --- a/engine/menu/party_menu.asm +++ b/engine/menu/party_menu.asm @@ -29,13 +29,13 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) cp a,SWAP_MONS_PARTY_MENU jp z,.printMessage call ErasePartyMenuCursors - callba SendBlkPacket_PartyMenu + callba InitPartyMenuBlkPacket coord hl, 3, 0 ld de,wPartySpecies xor a ld c,a ld [hPartyMonIndex],a - ld [wcf2d],a + ld [wWhichPartyMenuHPBar],a .loop ld a,[de] cp a,$FF ; reached the terminator? @@ -96,7 +96,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) ld a,[hFlags_0xFFF6] res 0,a ld [hFlags_0xFFF6],a - call SetPartyMenuHealthBarColor ; color the HP bar (on SGB) + call SetPartyMenuHPBarColor ; color the HP bar (on SGB) pop hl jr .printLevel .teachMoveMenu @@ -188,8 +188,8 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) .notAbleToEvolveText db "NOT ABLE@" .afterDrawingMonEntries - ld b,$0A - call GoPAL_SET + ld b, SET_PAL_PARTY_MENU + call RunPaletteCommand .printMessage ld hl,wd730 ld a,[hl] @@ -311,15 +311,15 @@ RareCandyText: ; 12ec0 (4:6ec0) db $06 db "@" -SetPartyMenuHealthBarColor: ; 12ec7 (4:6ec7) - ld hl, wcf1f - ld a, [wcf2d] +SetPartyMenuHPBarColor: ; 12ec7 (4:6ec7) + ld hl, wPartyMenuHPBarColors + ld a, [wWhichPartyMenuHPBar] ld c, a - ld b, $0 + ld b, 0 add hl, bc call GetHealthBarColor - ld b, $fc - call GoPAL_SET - ld hl, wcf2d + ld b, UPDATE_PARTY_MENU_BLK_PACKET + call RunPaletteCommand + ld hl, wWhichPartyMenuHPBar inc [hl] ret diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 8e69329a..a58523e8 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -12,8 +12,8 @@ ShowPokedexMenu: ; 40000 (10:4000) ld [wd11e],a ld [hJoy7],a .setUpGraphics - ld b,$08 - call GoPAL_SET + ld b, SET_PAL_GENERIC + call RunPaletteCommand callab LoadPokedexTilePatterns .doPokemonListMenu ld hl,wTopMenuItemY @@ -41,7 +41,7 @@ ShowPokedexMenu: ; 40000 (10:4000) pop af ld [wListScrollOffset],a call GBPalWhiteOutWithDelay3 - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand jp ReloadMapData .goToSideMenu call HandlePokedexSideMenu @@ -404,8 +404,8 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) ld a,[wd11e] ; pokemon ID ld [wcf91],a push af - ld b,04 - call GoPAL_SET + ld b, SET_PAL_POKEDEX + call RunPaletteCommand pop af ld [wd11e],a ld a,[hTilesetType] @@ -561,7 +561,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) ld [hTilesetType],a call GBPalWhiteOut call ClearScreen - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call LoadTextBoxTilePatterns call GBPalNormal ld hl,wd72c diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index f726f128..ab8c8756 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -297,7 +297,7 @@ ErasePartyMenuCursors: ; 132ed (4:72ed) ItemMenuLoop: ; 132fc (4:72fc) call LoadScreenTilesFromBuffer2DisableBGTransfer ; restore saved screen - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand StartMenu_Item: ; 13302 (4:7302) ld a,[wLinkState] @@ -506,14 +506,14 @@ StartMenu_TrainerInfo: ; 13460 (4:7460) ld [hTilesetType],a call DrawTrainerInfo predef DrawBadges ; draw badges - ld b,$0d - call GoPAL_SET + ld b, SET_PAL_TRAINER_CARD + call RunPaletteCommand call GBPalNormal call WaitForTextScrollButtonPress ; wait for button press call GBPalWhiteOut call LoadFontTilePatterns call LoadScreenTilesFromBuffer2 ; restore saved screen - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call ReloadMapData call LoadGBPal pop af diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm index fb4a0dfc..c91d5eda 100755 --- a/engine/menu/status_screen.asm +++ b/engine/menu/status_screen.asm @@ -121,10 +121,10 @@ StatusScreen: ; 12953 (4:6953) call PlaceString ; "TYPE1/" coord hl, 11, 3 predef DrawHP - ld hl, wcf25 + ld hl, wStatusScreenHPBarColor call GetHealthBarColor - ld b, $3 - call GoPAL_SET ; SGB palette + ld b, SET_PAL_STATUS_SCREEN + call RunPaletteCommand coord hl, 16, 6 ld de, wLoadedMonStatus call PrintStatusCondition diff --git a/engine/mon_party_sprites.asm b/engine/mon_party_sprites.asm index e7f9d2df..185151cb 100755 --- a/engine/mon_party_sprites.asm +++ b/engine/mon_party_sprites.asm @@ -5,15 +5,15 @@ AnimatePartyMon_ForceSpeed1: ; 716f7 (1c:56f7) inc a jr GetAnimationSpeed -; wcf1f contains the party mon's health bar colors +; wPartyMenuHPBarColors contains the party mon's health bar colors ; 0: green ; 1: yellow ; 2: red AnimatePartyMon: ; 716ff (1c:56ff) - ld hl, wcf1f + ld hl, wPartyMenuHPBarColors ld a, [wCurrentMenuItem] ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] @@ -42,7 +42,7 @@ GetAnimationSpeed: ; 7170a (1c:570a) jp DelayFrame .resetSprites push bc - ld hl, wcc5b + ld hl, wMonPartySpritesSavedOAM ld de, wOAMBuffer ld bc, $60 call CopyData @@ -86,7 +86,7 @@ GetAnimationSpeed: ; 7170a (1c:570a) ; that each frame lasts for green HP, yellow HP, and red HP in order. ; On the naming screen, the yellow HP speed is always used. PartyMonSpeeds: ; 71769 (1c:5769) - db $05,$10,$20 + db 5, 16, 32 LoadMonPartySpriteGfx: ; 7176c (1c:576c) ; Load mon party sprite tile patterns into VRAM during V-blank. @@ -372,7 +372,7 @@ UnusedPartyMonSpriteFunction: ; 71890 (1c:5890) WriteMonPartySpriteOAM: ; 718c3 (1c:58c3) ; Write the OAM blocks for the first animation frame into the OAM buffer and -; make a copy at wcc5b. +; make a copy at wMonPartySpritesSavedOAM. push af ld c, $10 ld h, wOAMBuffer / $100 @@ -392,7 +392,7 @@ WriteMonPartySpriteOAM: ; 718c3 (1c:58c3) ; we can flip back to it from the second frame by copying it back. .makeCopy ld hl, wOAMBuffer - ld de, wcc5b + ld de, wMonPartySpritesSavedOAM ld bc, $60 jp CopyData diff --git a/engine/overworld/cinnabar_lab.asm b/engine/overworld/cinnabar_lab.asm index 5337255c..f81324e0 100755 --- a/engine/overworld/cinnabar_lab.asm +++ b/engine/overworld/cinnabar_lab.asm @@ -5,14 +5,14 @@ GiveFossilToCinnabarLab: ; 61006 (18:5006) ld [wCurrentMenuItem], a ld a, A_BUTTON | B_BUTTON ld [wMenuWatchedKeys], a - ld a, [wcd37] + ld a, [wFilteredBagItemsCount] dec a ld [wMaxMenuItem], a ld a, 2 ld [wTopMenuItemY], a ld a, 1 ld [wTopMenuItemX], a - ld a, [wcd37] + ld a, [wFilteredBagItemsCount] dec a ld bc, 2 ld hl, 3 @@ -29,9 +29,9 @@ GiveFossilToCinnabarLab: ; 61006 (18:5006) call HandleMenuInput bit 1, a ; pressed B? jr nz, .cancelledGivingFossil - ld hl, wcc5b + ld hl, wFilteredBagItems ld a, [wCurrentMenuItem] - ld d, $0 + ld d, 0 ld e, a add hl, de ld a, [hl] @@ -90,9 +90,9 @@ LabFossil_610bd: ; 610bd (18:50bd) PrintFossilsInBag: ; 610c2 (18:50c2) ; Prints each fossil in the player's bag on a separate line in the menu. - ld hl, wcc5b + ld hl, wFilteredBagItems xor a - ld [hFossilCounter], a + ld [hItemCounter], a .loop ld a, [hli] cp $ff @@ -101,12 +101,12 @@ PrintFossilsInBag: ; 610c2 (18:50c2) ld [wd11e], a call GetItemName coord hl, 2, 2 - ld a, [hFossilCounter] + ld a, [hItemCounter] ld bc, SCREEN_WIDTH * 2 call AddNTimes ld de, wcd6d call PlaceString - ld hl, hFossilCounter + ld hl, hItemCounter inc [hl] pop hl jr .loop diff --git a/engine/overworld/hidden_items.asm b/engine/overworld/hidden_items.asm index 1203dd2a..28528116 100755 --- a/engine/overworld/hidden_items.asm +++ b/engine/overworld/hidden_items.asm @@ -51,7 +51,7 @@ HiddenItemBagFullText: ; 76794 (1d:6794) HiddenCoins: ; 76799 (1d:6799) ld b, COIN_CASE - predef IsItemInBag_ + predef GetQuantityOfItemInBag ld a, b and a ret z diff --git a/engine/overworld/oaks_aide.asm b/engine/overworld/oaks_aide.asm index 31832315..8ac456d2 100755 --- a/engine/overworld/oaks_aide.asm +++ b/engine/overworld/oaks_aide.asm @@ -18,7 +18,7 @@ OaksAideScript: ; 0x59035 .giveItem ld hl, OaksAideHereYouGoText call PrintText - ld a, [hOaksAideItemReward] + ld a, [hOaksAideRewardItem] ld b, a ld c, 1 call GiveItem diff --git a/engine/palettes.asm b/engine/palettes.asm index a325e0a3..55d488aa 100755 --- a/engine/palettes.asm +++ b/engine/palettes.asm @@ -1,33 +1,33 @@ -Func_71ddf: ; 71ddf (1c:5ddf) +_RunPaletteCommand: ; 71ddf (1c:5ddf) call GetPredefRegisters ld a, b cp $ff - jr nz, .asm_71dea - ld a, [wcf1c] -.asm_71dea - cp $fc - jp z, Func_71fc2 + jr nz, .next + ld a, [wDefaultPaletteCommand] ; use default command if command ID is $ff +.next + cp UPDATE_PARTY_MENU_BLK_PACKET + jp z, UpdatePartyMenuBlkPacket ld l, a - ld h, $0 + ld h, 0 add hl, hl - ld de, PointerTable_71f73 + ld de, SetPalFunctions add hl, de ld a, [hli] ld h, [hl] ld l, a - ld de, Func_72156 + ld de, SendSGBPackets push de jp [hl] -SendPalPacket_Black: ; 71dff (1c:5dff) +SetPal_BattleBlack: ; 71dff (1c:5dff) ld hl, PalPacket_Black ld de, BlkPacket_Battle ret ; uses PalPacket_Empty to build a packet based on mon IDs and health color -BuildBattlePalPacket: ; 71e06 (1c:5e06) +SetPal_Battle: ; 71e06 (1c:5e06) ld hl, PalPacket_Empty - ld de, wcf2d + ld de, wPalPacket ld bc, $10 call CopyData ld a, [W_PLAYERBATTSTATUS3] @@ -38,12 +38,12 @@ BuildBattlePalPacket: ; 71e06 (1c:5e06) ld hl, wEnemyMonSpecies2 call DeterminePaletteID ld c, a - ld hl, wcf2e - ld a, [wcf1d] + ld hl, wPalPacket + 1 + ld a, [wPlayerHPBarColor] add PAL_GREENBAR ld [hli], a inc hl - ld a, [wcf1e] + ld a, [wEnemyHPBarColor] add PAL_GREENBAR ld [hli], a inc hl @@ -52,21 +52,21 @@ BuildBattlePalPacket: ; 71e06 (1c:5e06) inc hl ld a, c ld [hl], a - ld hl, wcf2d + ld hl, wPalPacket ld de, BlkPacket_Battle - ld a, $1 - ld [wcf1c], a + ld a, SET_PAL_BATTLE + ld [wDefaultPaletteCommand], a ret -SendPalPacket_TownMap: ; 71e48 (1c:5e48) +SetPal_TownMap: ; 71e48 (1c:5e48) ld hl, PalPacket_TownMap ld de, BlkPacket_WholeScreen ret ; uses PalPacket_Empty to build a packet based the mon ID -BuildStatusScreenPalPacket: ; 71e4f (1c:5e4f) +SetPal_StatusScreen: ; 71e4f (1c:5e4f) ld hl, PalPacket_Empty - ld de, wcf2d + ld de, wPalPacket ld bc, $10 call CopyData ld a, [wcf91] @@ -76,67 +76,67 @@ BuildStatusScreenPalPacket: ; 71e4f (1c:5e4f) .pokemon call DeterminePaletteIDOutOfBattle push af - ld hl, wcf2e - ld a, [wcf25] + ld hl, wPalPacket + 1 + ld a, [wStatusScreenHPBarColor] add PAL_GREENBAR ld [hli], a inc hl pop af ld [hl], a - ld hl, wcf2d + ld hl, wPalPacket ld de, BlkPacket_StatusScreen ret -SendPalPacket_PartyMenu: ; 71e7b (1c:5e7b) +SetPal_PartyMenu: ; 71e7b (1c:5e7b) ld hl, PalPacket_PartyMenu - ld de, wcf2e + ld de, wPartyMenuBlkPacket ret -SendPalPacket_Pokedex: ; 71e82 (1c:5e82) +SetPal_Pokedex: ; 71e82 (1c:5e82) ld hl, PalPacket_Pokedex - ld de, wcf2d + ld de, wPalPacket ld bc, $10 call CopyData ld a, [wcf91] call DeterminePaletteIDOutOfBattle - ld hl, wcf30 + ld hl, wPalPacket + 3 ld [hl], a - ld hl, wcf2d + ld hl, wPalPacket ld de, BlkPacket_Pokedex ret -SendPalPacket_Slots: ; 71e9f (1c:5e9f) +SetPal_Slots: ; 71e9f (1c:5e9f) ld hl, PalPacket_Slots ld de, BlkPacket_Slots ret -SendPalPacket_Titlescreen: ; 71ea6 (1c:5ea6) +SetPal_TitleScreen: ; 71ea6 (1c:5ea6) ld hl, PalPacket_Titlescreen ld de, BlkPacket_Titlescreen ret ; used mostly for menus and the Oak intro -SendPalPacket_Generic: ; 71ead (1c:5ead) +SetPal_Generic: ; 71ead (1c:5ead) ld hl, PalPacket_Generic ld de, BlkPacket_WholeScreen ret -SendPalPacket_NidorinoIntro: ; 71eb4 (1c:5eb4) +SetPal_NidorinoIntro: ; 71eb4 (1c:5eb4) ld hl, PalPacket_NidorinoIntro ld de, BlkPacket_NidorinoIntro ret -SendPalPacket_GameFreakIntro: ; 71ebb (1c:5ebb) +SetPal_GameFreakIntro: ; 71ebb (1c:5ebb) ld hl, PalPacket_GameFreakIntro ld de, BlkPacket_GameFreakIntro - ld a, $8 - ld [wcf1c], a + ld a, SET_PAL_GENERIC + ld [wDefaultPaletteCommand], a ret ; uses PalPacket_Empty to build a packet based on the current map -BuildOverworldPalPacket: ; 71ec7 (1c:5ec7) +SetPal_Overworld: ; 71ec7 (1c:5ec7) ld hl, PalPacket_Empty - ld de, wcf2d + ld de, wPalPacket ld bc, $10 call CopyData ld a, [W_CURMAPTILESET] @@ -162,12 +162,12 @@ BuildOverworldPalPacket: ; 71ec7 (1c:5ec7) jr c, .town ld a, PAL_ROUTE - 1 .town - inc a ; a town's pallete ID is its map ID + 1 - ld hl, wcf2e + inc a ; a town's palette ID is its map ID + 1 + ld hl, wPalPacket + 1 ld [hld], a ld de, BlkPacket_WholeScreen - ld a, $9 - ld [wcf1c], a + ld a, SET_PAL_OVERWORLD + ld [wDefaultPaletteCommand], a ret .PokemonTowerOrAgatha ld a, PAL_GREYMON - 1 @@ -181,131 +181,143 @@ BuildOverworldPalPacket: ; 71ec7 (1c:5ec7) ; used when a Pokemon is the only thing on the screen ; such as evolution, trading and the Hall of Fame -SendPokemonPalette_WholeScreen: ; 71f17 (1c:5f17) +SetPal_PokemonWholeScreen: ; 71f17 (1c:5f17) push bc ld hl, PalPacket_Empty - ld de, wcf2d + ld de, wPalPacket ld bc, $10 call CopyData pop bc ld a, c and a - ld a, $1e - jr nz, .asm_71f31 - ld a, [wcf1d] + ld a, PAL_BLACK + jr nz, .next + ld a, [wWholeScreenPaletteMonSpecies] call DeterminePaletteIDOutOfBattle -.asm_71f31 - ld [wcf2e], a - ld hl, wcf2d +.next + ld [wPalPacket + 1], a + ld hl, wPalPacket ld de, BlkPacket_WholeScreen ret -BuildTrainerCardPalPacket: ; 71f3b (1c:5f3b) +SetPal_TrainerCard: ; 71f3b (1c:5f3b) ld hl, BlkPacket_TrainerCard - ld de, wcc5b + ld de, wTrainerCardBlkPacket ld bc, $40 call CopyData - ld de, LoopCounts_71f8f - ld hl, wcc5d + ld de, BadgeBlkDataLengths + ld hl, wTrainerCardBlkPacket + 2 ld a, [W_OBTAINEDBADGES] - ld c, $8 -.asm_71f52 + ld c, 8 +.badgeLoop srl a push af - jr c, .asm_71f62 + jr c, .haveBadge +; The player doens't have the badge, so zero the badge's blk data. push bc ld a, [de] ld c, a xor a -.asm_71f5b +.zeroBadgeDataLoop ld [hli], a dec c - jr nz, .asm_71f5b + jr nz, .zeroBadgeDataLoop pop bc - jr .asm_71f67 -.asm_71f62 + jr .nextBadge +.haveBadge +; The player does have the badge, so skip past the badge's blk data. ld a, [de] -.asm_71f63 +.skipBadgeDataLoop inc hl dec a - jr nz, .asm_71f63 -.asm_71f67 + jr nz, .skipBadgeDataLoop +.nextBadge pop af inc de dec c - jr nz, .asm_71f52 + jr nz, .badgeLoop ld hl, PalPacket_TrainerCard - ld de, wcc5b + ld de, wTrainerCardBlkPacket ret -PointerTable_71f73: ; 71f73 (1c:5f73) - dw SendPalPacket_Black - dw BuildBattlePalPacket - dw SendPalPacket_TownMap - dw BuildStatusScreenPalPacket - dw SendPalPacket_Pokedex - dw SendPalPacket_Slots - dw SendPalPacket_Titlescreen - dw SendPalPacket_NidorinoIntro - dw SendPalPacket_Generic - dw BuildOverworldPalPacket - dw SendPalPacket_PartyMenu - dw SendPokemonPalette_WholeScreen - dw SendPalPacket_GameFreakIntro - dw BuildTrainerCardPalPacket - -; each byte is the number of loops to make in .asm_71f5b for each badge -LoopCounts_71f8f: ; 71f8f (1c:5f8f) - db $06,$06,$06,$12,$06,$06,$06,$06 +SetPalFunctions: ; 71f73 (1c:5f73) + dw SetPal_BattleBlack + dw SetPal_Battle + dw SetPal_TownMap + dw SetPal_StatusScreen + dw SetPal_Pokedex + dw SetPal_Slots + dw SetPal_TitleScreen + dw SetPal_NidorinoIntro + dw SetPal_Generic + dw SetPal_Overworld + dw SetPal_PartyMenu + dw SetPal_PokemonWholeScreen + dw SetPal_GameFreakIntro + dw SetPal_TrainerCard + +; The length of the blk data of each badge on the Trainer Card. +; The Rainbow Badge has 3 entries because of its many colors. +BadgeBlkDataLengths: ; 71f8f (1c:5f8f) + db 6 ; Boulder Badge + db 6 ; Cascade Badge + db 6 ; Thunder Badge + db 6 * 3 ; Rainbow Badge + db 6 ; Soul Badge + db 6 ; Marsh Badge + db 6 ; Volcano Badge + db 6 ; Earth Badge DeterminePaletteID: ; 71f97 (1c:5f97) - bit 3, a ; bit 3 of battle status 3, set if current Pokemon is transformed - ld a, PAL_GREYMON ; if yes, use Ditto's palette + bit Transformed, a ; a is battle status 3 + ld a, PAL_GREYMON ; if the mon has used Transform, use Ditto's palette ret nz ld a, [hl] DeterminePaletteIDOutOfBattle: ; 71f9d (1c:5f9d) ld [wd11e], a - and a - jr z, .idZero + and a ; is the mon index 0? + jr z, .skipDexNumConversion push bc - predef IndexToPokedex ; turn Pokemon ID number into Pokedex number + predef IndexToPokedex pop bc ld a, [wd11e] -.idZero +.skipDexNumConversion ld e, a - ld d, $00 - ld hl, MonsterPalettes ; not just for Pokemon, Trainers use it too + ld d, 0 + ld hl, MonsterPalettes ; not just for Pokemon, Trainers use it too add hl, de ld a, [hl] ret -SendBlkPacket_PartyMenu: ; 71fb6 (1c:5fb6) +InitPartyMenuBlkPacket: ; 71fb6 (1c:5fb6) ld hl, BlkPacket_PartyMenu - ld de, wcf2e + ld de, wPartyMenuBlkPacket ld bc, $30 jp CopyData -Func_71fc2: ; 71fc2 (1c:5fc2) - ld hl, wcf1f - ld a, [wcf2d] +UpdatePartyMenuBlkPacket: ; 71fc2 (1c:5fc2) +; Update the blk packet with the palette of the HP bar that is +; specified in [wWhichPartyMenuHPBar]. + ld hl, wPartyMenuHPBarColors + ld a, [wWhichPartyMenuHPBar] ld e, a - ld d, $0 + ld d, 0 add hl, de ld e, l ld d, h ld a, [de] and a - ld e, $5 - jr z, .asm_71fdb + ld e, (1 << 2) | 1 ; green + jr z, .next dec a - ld e, $a - jr z, .asm_71fdb - ld e, $f -.asm_71fdb + ld e, (2 << 2) | 2 ; yellow + jr z, .next + ld e, (3 << 2) | 3 ; red +.next push de - ld hl, wcf37 - ld bc, $6 - ld a, [wcf2d] + ld hl, wPartyMenuBlkPacket + 8 + 1 + ld bc, 6 + ld a, [wWhichPartyMenuHPBar] call AddNTimes pop de ld [hl], e @@ -321,11 +333,9 @@ SendSGBPacket: ; 71feb (1c:5feb) .loop2 ; save B for later use push bc -; load a non-zero value in $fff9 to disable the routine that checks actual -; joypad input (said routine, located at $15f, does nothing if $fff9 is not -; zero) - ld a,$01 - ld [$fff9],a +; disable ReadJoypad to prevent it from interfering with sending the packet + ld a, 1 + ld [hDisableJoypadPolling], a ; send RESET signal (P14=LOW, P15=LOW) xor a ld [rJOYP],a @@ -367,7 +377,7 @@ SendSGBPacket: ; 71feb (1c:5feb) ld a,$30 ld [rJOYP],a xor a - ld [$fff9],a + ld [hDisableJoypadPolling],a ; wait for about 70000 cycles call Wait7000 ; restore (previously pushed) number of packets @@ -383,39 +393,39 @@ LoadSGB: ; 7202b (1c:602b) ld [wOnSGB], a call CheckSGB ret nc - ld a, $1 + ld a, 1 ld [wOnSGB], a ld a, [wGBC] and a - jr z, .asm_7203f + jr z, .notGBC ret -.asm_7203f +.notGBC di - call Func_72075 + call PrepareSuperNintendoVRAMTransfer ei - ld a, $1 - ld [wcf2d], a + ld a, 1 + ld [wCopyingSGBTileData], a ld de, ChrTrnPacket ld hl, SGBBorderGraphics - call Func_7210b + call CopyGfxToSuperNintendoVRAM xor a - ld [wcf2d], a + ld [wCopyingSGBTileData], a ld de, PctTrnPacket ld hl, BorderPalettes - call Func_7210b + call CopyGfxToSuperNintendoVRAM xor a - ld [wcf2d], a + ld [wCopyingSGBTileData], a ld de, PalTrnPacket ld hl, SuperPalettes - call Func_7210b + call CopyGfxToSuperNintendoVRAM call ClearVram ld hl, MaskEnCancelPacket jp SendSGBPacket -Func_72075: ; 72075 (1c:6075) - ld hl, PointerTable_72089 - ld c, $9 -.asm_7207a +PrepareSuperNintendoVRAMTransfer: ; 72075 (1c:6075) + ld hl, .packetPointers + ld c, 9 +.loop push bc ld a, [hli] push hl @@ -426,10 +436,11 @@ Func_72075: ; 72075 (1c:6075) inc hl pop bc dec c - jr nz, .asm_7207a + jr nz, .loop ret -PointerTable_72089: ; 72089 (1c:6089) +.packetPointers +; Only the first packet is needed. dw MaskEnFreezePacket dw DataSnd_72548 dw DataSnd_72558 @@ -441,17 +452,18 @@ PointerTable_72089: ; 72089 (1c:6089) dw DataSnd_725b8 CheckSGB: ; 7209b (1c:609b) +; Returns whether the game is running on an SGB in carry. ld hl, MltReq2Packet di call SendSGBPacket - ld a, $1 - ld [$fff9], a + ld a, 1 + ld [hDisableJoypadPolling], a ei call Wait7000 ld a, [rJOYP] and $3 cp $3 - jr nz, .asm_720fd + jr nz, .isSGB ld a, $20 ld [rJOYP], a ld a, [rJOYP] @@ -482,50 +494,50 @@ CheckSGB: ; 7209b (1c:609b) ld a, [rJOYP] and $3 cp $3 - jr nz, .asm_720fd - call Func_72102 + jr nz, .isSGB + call SendMltReq1Packet and a ret -.asm_720fd - call Func_72102 +.isSGB + call SendMltReq1Packet scf ret -Func_72102: ; 72102 (1c:6102) +SendMltReq1Packet: ; 72102 (1c:6102) ld hl, MltReq1Packet call SendSGBPacket jp Wait7000 -Func_7210b: ; 7210b (1c:610b) +CopyGfxToSuperNintendoVRAM: ; 7210b (1c:610b) di push de call DisableLCD ld a, $e4 ld [rBGP], a ld de, vChars1 - ld a, [wcf2d] + ld a, [wCopyingSGBTileData] and a - jr z, .asm_72122 - call Func_72188 - jr .asm_72128 -.asm_72122 + jr z, .notCopyingTileData + call CopySGBBorderTiles + jr .next +.notCopyingTileData ld bc, $1000 call CopyData -.asm_72128 +.next ld hl, vBGMap0 ld de, $c ld a, $80 ld c, $d -.asm_72132 +.loop ld b, $14 -.asm_72134 +.innerLoop ld [hli], a inc a dec b - jr nz, .asm_72134 + jr nz, .innerLoop add hl, de dec c - jr nz, .asm_72132 + jr nz, .loop ld a, $e3 ld [rLCDC], a pop hl @@ -548,27 +560,27 @@ Wait7000: ; 7214a (1c:614a) jr nz, .loop ret -Func_72156: ; 72156 (1c:6156) +SendSGBPackets: ; 72156 (1c:6156) ld a, [wGBC] and a - jr z, .asm_72165 + jr z, .notGBC push de - call Func_7216d + call InitGBCPalettes pop hl - call Func_72187 + call EmptyFunc5 ret -.asm_72165 +.notGBC push de call SendSGBPacket pop hl jp SendSGBPacket -Func_7216d: ; 7216d (1c:616d) - ld a, $80 - ld [$ff68], a +InitGBCPalettes: ; 7216d (1c:616d) + ld a, $80 ; index 0 with auto-increment + ld [rBGPI], a inc hl ld c, $20 -.asm_72174 +.loop ld a, [hli] inc hl add a @@ -576,37 +588,48 @@ Func_7216d: ; 7216d (1c:616d) add a ld de, SuperPalettes add e - jr nc, .asm_72180 + jr nc, .noCarry inc d -.asm_72180 +.noCarry ld a, [de] - ld [$ff69], a + ld [rBGPD], a dec c - jr nz, .asm_72174 + jr nz, .loop ret -Func_72187: ; 72187 (1c:6187) +EmptyFunc5: ; 72187 (1c:6187) ret -Func_72188: ; 72188 (1c:6188) - ld b, $80 -.asm_7218a - ld c, $10 -.asm_7218c +CopySGBBorderTiles: ; 72188 (1c:6188) +; SGB tile data is stored in a 4BPP planar format. +; Each tile is 32 bytes. The first 16 bytes contain bit planes 1 and 2, while +; the second 16 bytes contain bit planes 3 and 4. +; This function converts 2BPP planar data into this format by mapping +; 2BPP colors 0-3 to 4BPP colors 0-3. 4BPP colors 4-15 are not used. + ld b, 128 + +.tileLoop + +; Copy bit planes 1 and 2 of the tile data. + ld c, 16 +.copyLoop ld a, [hli] ld [de], a inc de dec c - jr nz, .asm_7218c - ld c, $10 + jr nz, .copyLoop + +; Zero bit planes 3 and 4. + ld c, 16 xor a -.asm_72195 +.zeroLoop ld [de], a inc de dec c - jr nz, .asm_72195 + jr nz, .zeroLoop + dec b - jr nz, .asm_7218a + jr nz, .tileLoop ret INCLUDE "data/sgb_packets.asm" diff --git a/engine/pokedex_rating.asm b/engine/pokedex_rating.asm index 265eff40..73025f0a 100755 --- a/engine/pokedex_rating.asm +++ b/engine/pokedex_rating.asm @@ -33,7 +33,7 @@ DisplayDexRating: ; 44169 (11:4169) callba PlayPokedexRatingSfx jp WaitForTextScrollButtonPress .hallOfFame - ld de, wcc5b + ld de, wDexRatingNumMonsSeen ld a, [hDexRatingNumMonsSeen] ld [de], a inc de diff --git a/engine/predefs.asm b/engine/predefs.asm index d8cf030c..16533751 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -80,7 +80,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef LoadTilesetHeader add_predef LearnMoveFromLevelUp add_predef LearnMove - add_predef IsItemInBag_ + add_predef GetQuantityOfItemInBag dbw $03,CheckForHiddenObjectOrBookshelfOrCardKeyDoor ; for these two, the bank number is actually 0 dbw $03,GiveItem add_predef ChangeBGPalColor0_4Frames @@ -121,7 +121,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef SetPartyMonTypes add_predef CanLearnTM add_predef TMToMove - add_predef Func_71ddf + add_predef _RunPaletteCommand add_predef StarterDex ; 46 add_predef _AddPartyMon add_predef UpdateHPBar2 diff --git a/engine/predefs7.asm b/engine/predefs7.asm index bf31772c..a2c08171 100755 --- a/engine/predefs7.asm +++ b/engine/predefs7.asm @@ -21,7 +21,7 @@ DisplayElevatorFloorMenu: ; 1c9c6 (7:49c6) ret c ld hl, wd126 set 7, [hl] - ld hl, wcc5b + ld hl, wElevatorWarpMaps ld a, [wWhichPokemon] add a ld d, 0 diff --git a/engine/save.asm b/engine/save.asm index ae895d96..a7b2a7c0 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -644,7 +644,7 @@ SaveHallOfFameTeams: ; 73b0d (1c:7b0d) call AddNTimes ld e, l ld d, h - ld hl, wcc5b + ld hl, wHallOfFame ld bc, HOF_TEAM jr HallOfFame_Copy @@ -653,7 +653,7 @@ SaveHallOfFameTeams: ; 73b0d (1c:7b0d) ld de, sHallOfFame ld bc, HOF_TEAM * (HOF_TEAM_CAPACITY - 1) call HallOfFame_Copy - ld hl, wcc5b + ld hl, wHallOfFame ld de, sHallOfFame + HOF_TEAM * (HOF_TEAM_CAPACITY - 1) ld bc, HOF_TEAM jr HallOfFame_Copy @@ -663,7 +663,7 @@ LoadHallOfFameTeams: ; 73b3f (1c:7b3f) ld bc, HOF_TEAM ld a, [wHoFTeamIndex] call AddNTimes - ld de, wcc5b + ld de, wHallOfFame ld bc, HOF_TEAM ; fallthrough diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index b68b9294..78ce35a2 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -21,8 +21,8 @@ PromptUserToPlaySlots: ; 3730e (d:730e) call GBPalWhiteOutWithDelay3 call LoadSlotMachineTiles call LoadFontTilePatterns - ld b, $5 - call GoPAL_SET + ld b, SET_PAL_SLOTS + call RunPaletteCommand call GBPalNormal ld a, $e4 ld [rOBP0], a @@ -41,7 +41,7 @@ PromptUserToPlaySlots: ; 3730e (d:730e) call GBPalWhiteOutWithDelay3 ld a, $1 ld [wUpdateSpritesEnabled], a - call GoPAL_SET_CF1C + call RunDefaultPaletteCommand call ReloadMapSpriteTilePatterns call ReloadTilesetTilePatterns .done diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index 0dbe4a4c..b0bf0fb6 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -134,8 +134,8 @@ ENDC call LoadScreenTilesFromBuffer2 ld a, vBGMap0 / $100 call TitleScreenCopyTileMapToVRAM - ld b, $6 - call GoPAL_SET + ld b, SET_PAL_TITLE_SCREEN + call RunPaletteCommand call GBPalNormal ld a, %11100100 ld [rOBP0], a @@ -215,7 +215,7 @@ ENDC ld [wNewSoundID], a call PlaySound xor a - ld [wcc5b], a + ld [wUnusedCC5B], a ; Keep scrolling in new mons indefinitely until the user performs input. .awaitUserInterruptionLoop diff --git a/engine/town_map.asm b/engine/town_map.asm index 414b6509..225de2b8 100755 --- a/engine/town_map.asm +++ b/engine/town_map.asm @@ -314,8 +314,8 @@ LoadTownMap: ; 7109b (1c:509b) jr .nextTile .done call EnableLCD - ld b, $2 - call GoPAL_SET + ld b, SET_PAL_TOWN_MAP + call RunPaletteCommand call Delay3 call GBPalNormal xor a @@ -338,7 +338,7 @@ ExitTownMap: ; 711ab (1c:51ab) call LoadPlayerSpriteGraphics call LoadFontTilePatterns call UpdateSprites - jp GoPAL_SET_CF1C + jp RunDefaultPaletteCommand DrawPlayerOrBirdSprite: ; 711c4 (1c:51c4) ; a = map number diff --git a/engine/trade.asm b/engine/trade.asm index b7c72520..66afa47e 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -268,8 +268,8 @@ Trade_DrawOpenEndOfLinkCable: ; 41298 (10:5298) call Trade_ClearTileMap ld b, vBGMap0 / $100 call CopyScreenTileBufferToVRAM - ld b, $8 - call GoPAL_SET + ld b, SET_PAL_GENERIC + call RunPaletteCommand ; This function call is pointless. It just copies blank tiles to VRAM that was ; already filled with blank tiles. @@ -552,14 +552,14 @@ Trade_CopyCableTilesOffScreen: ; 414ae (10:54ae) ; continues when the screen is scrolled. push hl coord hl, 0, 4 - call CopyToScreenEdgeTiles + call CopyToRedrawRowOrColumnSrcTiles pop hl ld a, h - ld [H_SCREENEDGEREDRAWADDR + 1], a + ld [hRedrawRowOrColumnDest + 1], a ld a, l - ld [H_SCREENEDGEREDRAWADDR], a - ld a, REDRAWROW - ld [H_SCREENEDGEREDRAW], a + ld [hRedrawRowOrColumnDest], a + ld a, REDRAW_ROW + ld [hRedrawRowOrColumnMode], a ld c, 10 jp DelayFrames @@ -727,10 +727,10 @@ Trade_CircleOAM3: ; 4159c (10:559c) Trade_LoadMonSprite: ; 415a4 (10:55a4) ld [wcf91], a ld [wd0b5], a - ld [wcf1d], a - ld b, $b - ld c, $0 - call GoPAL_SET + ld [wWholeScreenPaletteMonSpecies], a + ld b, SET_PAL_POKEMON_WHOLE_SCREEN + ld c, 0 + call RunPaletteCommand ld a, [H_AUTOBGTRANSFERENABLED] xor $1 ld [H_AUTOBGTRANSFERENABLED], a @@ -849,5 +849,5 @@ TradeforText: ; 41671 (10:5671) Trade_ShowAnimation: ; 41676 (10:5676) ld [W_ANIMATIONID], a xor a - ld [wcc5b], a + ld [wAnimationType], a predef_jump MoveAnimation |