diff --git a/INSTALL.md b/INSTALL.md index 7f1d47879..02851644a 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -418,21 +418,16 @@ If you aren't in the pokeemerald directory already, then **change directory** to ```bash cd pokeemerald ``` -To build **pokeemerald.gba** for the first time and confirm it matches the official ROM image (Note: to speed up builds, see [Parallel builds](#parallel-builds)): +To build **pokeemerald.gba** (Note: to speed up builds, see [Parallel builds](#parallel-builds)): ```bash -make compare +make ``` -If an OK is returned, then the installation went smoothly. +If it has built successfully you will have the output file **pokeemerald.gba** in your project folder.
Note for Windows... > If you switched terminals since the last build (e.g. from msys2 to WSL1), you must run `make clean-tools` once before any subsequent `make` commands.
-To build **pokeemerald.gba** with your changes: -```bash -make -``` - # Building guidance ## Parallel builds @@ -451,6 +446,22 @@ Replace `` with the number that the `nproc` command returned. `nproc` is not available on macOS. The alternative is `sysctl -n hw.ncpu` ([relevant Stack Overflow thread](https://stackoverflow.com/questions/1715580)). +## Compare ROM to the original + +For contributing, or if you'd simply like to verify that your ROM is identical to the original game, run: +```bash +make compare +``` +If it matches, you will see the following at the end of the output: +```bash +pokeemerald.gba: OK +``` +If there are any changes from the original game, you will instead see: +```bash +pokeemerald.gba: FAILED +shasum: WARNING: 1 computed checksum did NOT match +``` + ## devkitARM's C compiler This project supports the `arm-none-eabi-gcc` compiler included with devkitARM. If devkitARM (a.k.a. gba-dev) has already been installed as part of the platform-specific instructions, simply run: diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 850cd163d..dcafffe50 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -14662,7 +14662,7 @@ Move_TAKE_DOWN: setalpha 12, 8 createvisualtask AnimTask_WindUpLunge, 5, ANIM_ATTACKER, -24, 8, 23, 10, 40, 10 delay 35 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 1, RGB_BLACK, 10, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 1, RGB_BLACK, 10, RGB_BLACK, 0 createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 4, -10, 0, ANIM_TARGET, 0 playsewithpan SE_M_MEGA_KICK2, SOUND_PAN_TARGET delay 1 @@ -14682,14 +14682,14 @@ Move_TAKE_DOWN: Move_DOUBLE_EDGE: loadspritegfx ANIM_TAG_IMPACT playsewithpan SE_M_SWIFT, SOUND_PAN_ATTACKER - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 2, 4, 2, RGB_WHITE, 10, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_ATTACKER, 4, 2, RGB_WHITE, 10, RGB_BLACK, 0 waitforvisualfinish delay 10 playsewithpan SE_M_SWAGGER, SOUND_PAN_ATTACKER waitplaysewithpan SE_M_SWAGGER, SOUND_PAN_ATTACKER, 8 createvisualtask AnimTask_TranslateMonEllipticalRespectSide, 2, ANIM_ATTACKER, 18, 6, 2, 4 waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 0, 16, 16, RGB_WHITE + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 0, 16, 16, RGB_WHITE createsprite gSlideMonToOffsetSpriteTemplate, ANIM_ATTACKER, 2, 0, 20, 0, 0, 4 delay 3 waitforvisualfinish @@ -14701,7 +14701,7 @@ Move_DOUBLE_EDGE: createvisualtask AnimTask_RotateMonSpriteToSide, 2, 8, -256, 1, 0 createvisualtask AnimTask_ShakeMonInPlace, 2, ANIM_ATTACKER, 4, 0, 12, 1 createvisualtask AnimTask_ShakeMonInPlace, 2, ANIM_TARGET, 4, 0, 12, 1 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 16, 0, RGB_WHITE + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 16, 0, RGB_WHITE waitforvisualfinish createvisualtask AnimTask_RotateMonSpriteToSide, 2, 8, -256, 0, 1 createvisualtask AnimTask_RotateMonSpriteToSide, 2, 8, -256, 1, 1 @@ -14759,7 +14759,7 @@ Move_FIRE_BLAST: call FireBlastRing call FireBlastRing delay 24 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 3, 0, 8, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 3, 0, 8, RGB_BLACK waitforvisualfinish delay 19 createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 5, 0, 20, 1 @@ -14781,7 +14781,7 @@ Move_FIRE_BLAST: delay 3 call FireBlastCross waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 2, 8, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 2, 8, 0, RGB_BLACK waitforvisualfinish end FireBlastRing: @@ -14859,17 +14859,17 @@ Move_MEGA_PUNCH: loadspritegfx ANIM_TAG_HANDS_AND_FEET monbg ANIM_TARGET delay 2 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 0, 0, 16, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 0, 0, 16, RGB_BLACK setalpha 12, 8 playsewithpan SE_M_MEGA_KICK, SOUND_PAN_TARGET createsprite gMegaPunchKickSpriteTemplate, ANIM_ATTACKER, 3, 0, 0, 0, 50 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 0, 7, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 0, 7, RGB_WHITE delay 50 call SetImpactBackground createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 2, 0, 0, ANIM_TARGET, 0 createvisualtask AnimTask_ShakeMon2, 2, ANIM_TARGET, 4, 0, 22, 1 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 0, 0, RGB_WHITE - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 1, RGB_BLACK, 8, RGB_BLACK, 0 + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 0, 0, RGB_WHITE + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 1, RGB_BLACK, 8, RGB_BLACK, 0 playsewithpan SE_M_VITAL_THROW2, SOUND_PAN_TARGET waitforvisualfinish clearmonbg ANIM_TARGET @@ -14884,18 +14884,18 @@ Move_MEGA_KICK: loadspritegfx ANIM_TAG_HANDS_AND_FEET monbg ANIM_TARGET delay 2 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 0, 0, 16, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 0, 0, 16, RGB_BLACK setalpha 12, 8 playsewithpan SE_M_MEGA_KICK, SOUND_PAN_TARGET createsprite gMegaPunchKickSpriteTemplate, ANIM_ATTACKER, 3, 0, 0, 1, 50 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 0, 7, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 0, 7, RGB_WHITE delay 50 playsewithpan SE_M_MEGA_KICK2, SOUND_PAN_TARGET call SetImpactBackground createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 2, 0, 0, ANIM_TARGET, 0 createvisualtask AnimTask_ShakeMon2, 2, ANIM_TARGET, 4, 0, 22, 1 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 0, 0, RGB_WHITE - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 1, RGB_BLACK, 8, RGB_BLACK, 0 + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 0, 0, RGB_WHITE + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 1, RGB_BLACK, 8, RGB_BLACK, 0 waitforvisualfinish clearmonbg ANIM_TARGET blendoff @@ -14954,21 +14954,21 @@ SonicBoomHit: Move_THUNDER_SHOCK: loadspritegfx ANIM_TAG_SPARK loadspritegfx ANIM_TAG_SPARK_2 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 0, 0, 6, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 0, 0, 6, RGB_BLACK waitforvisualfinish delay 10 createvisualtask AnimTask_ElectricBolt, 5, 0, -44, 0 playsewithpan SE_M_THUNDERBOLT, SOUND_PAN_TARGET delay 9 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 0, 0, 13, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 0, 0, 13, RGB_BLACK waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 0, 13, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 0, 13, 0, RGB_BLACK waitforvisualfinish delay 20 call ElectricityEffect waitforvisualfinish delay 20 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 0, 6, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 0, 6, 0, RGB_BLACK waitforvisualfinish end @@ -14976,7 +14976,7 @@ Move_THUNDERBOLT: loadspritegfx ANIM_TAG_SPARK loadspritegfx ANIM_TAG_SHOCK_3 loadspritegfx ANIM_TAG_SPARK_2 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 0, 0, 6, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 0, 0, 6, RGB_BLACK waitforvisualfinish delay 10 createvisualtask AnimTask_ElectricBolt, 5, 24, -52, 0 @@ -14988,9 +14988,9 @@ Move_THUNDERBOLT: createvisualtask AnimTask_ElectricBolt, 5, 0, -60, 1 playsewithpan SE_M_THUNDERBOLT, SOUND_PAN_TARGET delay 9 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 0, 0, 13, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 0, 0, 13, RGB_BLACK waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 0, 13, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 0, 13, 0, RGB_BLACK waitforvisualfinish delay 20 createsprite gThunderboltOrbSpriteTemplate, ANIM_TARGET, 3, 44, 0, 0, 3 @@ -15004,20 +15004,20 @@ Move_THUNDERBOLT: createsprite gSparkElectricityFlashingSpriteTemplate, ANIM_TARGET, 4, 0, 0, 16, 44, 224, 40, 2, -32765 playsewithpan SE_M_HYPER_BEAM, SOUND_PAN_TARGET delay 0 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 0, 2, 2, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 0, 2, 2, RGB_BLACK delay 6 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 0, 6, 6, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 0, 6, 6, RGB_BLACK delay 6 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 0, 2, 2, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 0, 2, 2, RGB_BLACK delay 6 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 0, 6, 6, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 0, 6, 6, RGB_BLACK waitforvisualfinish delay 20 waitplaysewithpan SE_M_THUNDERBOLT2, SOUND_PAN_TARGET, 19 call ElectricityEffect waitforvisualfinish delay 20 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 0, 6, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 0, 6, 0, RGB_BLACK waitforvisualfinish end @@ -15025,7 +15025,7 @@ Move_THUNDER_WAVE: loadspritegfx ANIM_TAG_SPARK loadspritegfx ANIM_TAG_SPARK_2 loadspritegfx ANIM_TAG_SPARK_H - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 0, 0, 6, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 0, 0, 6, RGB_BLACK waitforvisualfinish delay 10 createvisualtask AnimTask_ElectricBolt, 5, 0, -48, 0 @@ -15038,7 +15038,7 @@ Move_THUNDER_WAVE: delay 4 createsprite gThunderWaveSpriteTemplate, ANIM_TARGET, 2, -16, 16 waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 0, 6, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 0, 6, 0, RGB_BLACK waitforvisualfinish end @@ -15147,10 +15147,10 @@ Move_REVERSAL: loadspritegfx ANIM_TAG_HANDS_AND_FEET loadspritegfx ANIM_TAG_IMPACT playsewithpan SE_M_DETECT, SOUND_PAN_ATTACKER - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 3, RGB_WHITE, 8, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 3, RGB_WHITE, 8, RGB_BLACK, 0 waitforvisualfinish delay 30 - createvisualtask AnimTask_BlendColorCycle, 2, 31, 3, 2, 0, 10, RGB_WHITE + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 2, 0, 10, RGB_WHITE delay 10 playsewithpan SE_M_REVERSAL, SOUND_PAN_ATTACKER createsprite gReversalOrbSpriteTemplate, ANIM_ATTACKER, 2, 26, 0 @@ -15164,7 +15164,7 @@ Move_REVERSAL: createsprite gHorizontalLungeSpriteTemplate, ANIM_ATTACKER, 2, 6, 4 delay 8 playsewithpan SE_M_VITAL_THROW2, SOUND_PAN_TARGET - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 1, RGB_WHITE, 8, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 1, RGB_WHITE, 8, RGB_BLACK, 0 createsprite gFistFootSpriteTemplate, ANIM_TARGET, 4, 0, 0, 10, 1, 0 createsprite gBasicHitSplatSpriteTemplate, ANIM_TARGET, 3, 0, 0, ANIM_TARGET, 1 createvisualtask AnimTask_ShakeTargetBasedOnMovePowerOrDmg, 5, FALSE, 1, 8, 1, 0 @@ -15248,7 +15248,7 @@ Move_PSYCH_UP: delay 4 playsewithpan SE_M_PSYBEAM, SOUND_PAN_ATTACKER createvisualtask AnimTask_ScaleMonAndRestore, 5, -5, -5, 10, ANIM_ATTACKER, 1 - createvisualtask AnimTask_BlendBattleAnimPal, 9, 2, 2, 10, 0, RGB_YELLOW + createvisualtask AnimTask_BlendBattleAnimPal, 9, F_PAL_ATTACKER, 2, 10, 0, RGB_YELLOW delay 30 clearmonbg ANIM_ATK_PARTNER blendoff @@ -15346,18 +15346,18 @@ FuryCutterRight: createsprite gCuttingSliceSpriteTemplate, ANIM_ATTACKER, 2, 40, -32, 1 goto FuryCutterContinue FuryCutterMedium: - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 1, RGB(9, 8, 10), 4, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 1, RGB(9, 8, 10), 4, RGB_BLACK, 0 goto FuryCutterContinue2 FuryCutterStrong: - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 3, RGB(9, 8, 10), 4, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 3, RGB(9, 8, 10), 4, RGB_BLACK, 0 goto FuryCutterContinue2 FuryCutterStrongest: - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 3, RGB(9, 8, 10), 4, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 3, RGB(9, 8, 10), 4, RGB_BLACK, 0 goto FuryCutterContinue2 Move_SELF_DESTRUCT: loadspritegfx ANIM_TAG_EXPLOSION - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 1, 0, 9, RGB_RED + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 1, 0, 9, RGB_RED createvisualtask AnimTask_ShakeMon2, 5, 4, 6, 0, 38, 1 createvisualtask AnimTask_ShakeMon2, 5, 5, 6, 0, 38, 1 createvisualtask AnimTask_ShakeMon2, 5, 6, 6, 0, 38, 1 @@ -15366,7 +15366,7 @@ Move_SELF_DESTRUCT: call SelfDestructExplode call SelfDestructExplode waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 1, 9, 0, RGB_RED + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 1, 9, 0, RGB_RED end SelfDestructExplode: playsewithpan SE_M_SELF_DESTRUCT, SOUND_PAN_ATTACKER @@ -15523,7 +15523,7 @@ RisingWaterHitEffect: Move_EXPLOSION: loadspritegfx ANIM_TAG_EXPLOSION - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 8, 9, RGB(26, 8, 8), 8, RGB_BLACK, 8 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 8, 9, RGB(26, 8, 8), 8, RGB_BLACK, 8 createvisualtask AnimTask_ShakeMon2, 5, 4, 8, 0, 40, 1 createvisualtask AnimTask_ShakeMon2, 5, 5, 8, 0, 40, 1 createvisualtask AnimTask_ShakeMon2, 5, 6, 8, 0, 40, 1 @@ -15532,9 +15532,9 @@ Move_EXPLOSION: call Explosion1 call Explosion1 waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 1, 16, 16, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 1, 16, 16, RGB_WHITE delay 50 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 3, 16, 0, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 3, 16, 0, RGB_WHITE end Explosion1: playsewithpan SE_M_EXPLOSION, SOUND_PAN_ATTACKER @@ -15578,16 +15578,16 @@ Move_PROTECT: Move_DETECT: loadspritegfx ANIM_TAG_SPARKLE_4 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 0, 9, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 0, 9, RGB_BLACK waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 1, 0, 9, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 1, 0, 9, RGB_WHITE delay 18 playsewithpan SE_M_DETECT, SOUND_PAN_ATTACKER createsprite gSpinningSparkleSpriteTemplate, ANIM_ATTACKER, 13, 20, -20 waitforvisualfinish delay 10 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 9, 0, RGB_BLACK - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 2, 9, 0, RGB_WHITE + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 9, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 2, 9, 0, RGB_WHITE waitforvisualfinish end @@ -15609,7 +15609,7 @@ Frustration_Continue: Frustration_Strongest: playsewithpan SE_M_DRAGON_RAGE, SOUND_PAN_ATTACKER createvisualtask AnimTask_ShakeMon2, 5, ANIM_ATTACKER, 1, 0, 15, 1 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 3, 0, 9, 31 + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 3, 0, 9, RGB_RED waitforvisualfinish delay 20 playsewithpan SE_M_SWAGGER2, SOUND_PAN_ATTACKER @@ -15640,12 +15640,12 @@ Frustration_Strongest: createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 3, 18, -18, ANIM_TARGET, 0 playsewithpan SE_M_COMET_PUNCH, SOUND_PAN_TARGET waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 3, 9, 0, 31 + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 3, 9, 0, RGB_RED goto Frustration_Continue Frustration_Strong: playsewithpan SE_M_DRAGON_RAGE, SOUND_PAN_ATTACKER createvisualtask AnimTask_ShakeMon2, 5, ANIM_ATTACKER, 1, 0, 15, 1 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 3, 0, 9, 31 + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 3, 0, 9, RGB_RED waitforvisualfinish delay 20 playsewithpan SE_M_SWAGGER2, SOUND_PAN_ATTACKER @@ -15666,7 +15666,7 @@ Frustration_Strong: createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 3, -12, -6, ANIM_TARGET, 1 createvisualtask AnimTask_ShakeMon2, 5, ANIM_TARGET, 4, 0, 6, 1 waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 3, 9, 0, 31 + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 3, 9, 0, RGB_RED goto Frustration_Continue Frustration_Medium: playsewithpan SE_M_SWAGGER2, SOUND_PAN_ATTACKER @@ -15708,7 +15708,7 @@ Move_SAFEGUARD: createsprite gGuardRingSpriteTemplate, ANIM_ATTACKER, 2 waitforvisualfinish playsewithpan SE_SHINY, SOUND_PAN_ATTACKER - createvisualtask AnimTask_BlendColorCycle, 2, 10, 0, 2, 0, 10, RGB_WHITE + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATK_SIDE, 0, 2, 0, 10, RGB_WHITE waitforvisualfinish clearmonbg ANIM_ATK_PARTNER blendoff @@ -15764,13 +15764,13 @@ Move_GUILLOTINE: playsewithpan SE_M_VICEGRIP, SOUND_PAN_TARGET createsprite gGuillotineSpriteTemplate, ANIM_ATTACKER, 2, 0 createsprite gGuillotineSpriteTemplate, ANIM_ATTACKER, 2, 1 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 0, 16, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 0, 16, RGB_BLACK delay 9 createvisualtask AnimTask_ShakeMon2, 5, ANIM_TARGET, 2, 0, 23, 1 delay 46 createvisualtask AnimTask_ShakeMon2, 5, ANIM_TARGET, 4, 0, 8, 1 createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 3, 0, 0, ANIM_TARGET, 0 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 1, RGB_BLACK, 8, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 1, RGB_BLACK, 8, RGB_BLACK, 0 playsewithpan SE_M_RAZOR_WIND, SOUND_PAN_TARGET waitforvisualfinish clearmonbg ANIM_DEF_PARTNER @@ -15800,7 +15800,7 @@ Move_PAY_DAY: Move_OUTRAGE: loadspritegfx ANIM_TAG_SMALL_EMBER loopsewithpan SE_M_DRAGON_RAGE, SOUND_PAN_ATTACKER, 8, 3 - createvisualtask AnimTask_BlendColorCycle, 2, 7, 2, 5, 3, 8, RGB(14, 13, 0) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_BG | F_PAL_ATTACKER | F_PAL_TARGET, 2, 5, 3, 8, RGB(14, 13, 0) createvisualtask AnimTask_TranslateMonEllipticalRespectSide, 2, ANIM_ATTACKER, 12, 6, 5, 4 delay 0 createsprite gOutrageFlameSpriteTemplate, ANIM_TARGET, 2, 0, 0, 30, 1280, 0, 3 @@ -15846,25 +15846,25 @@ Move_SPARK: loadspritegfx ANIM_TAG_IMPACT loadspritegfx ANIM_TAG_SPARK_2 delay 0 - createvisualtask AnimTask_BlendColorCycle, 2, 3, -31, 1, 5, 5, RGB(31, 31, 22) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_BG | F_PAL_ATTACKER, -31, 1, 5, 5, RGB(31, 31, 22) playsewithpan SE_M_THUNDERBOLT2, SOUND_PAN_ATTACKER createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 32, 24, 190, 12, ANIM_ATTACKER, 1, 0 delay 0 createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 80, 24, 22, 12, ANIM_ATTACKER, 1, 0 createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 156, 24, 121, 13, ANIM_ATTACKER, 1, 1 delay 0 - createvisualtask AnimTask_BlendColorCycle, 2, 3, -31, 1, 0, 0, RGB(31, 31, 22) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_BG | F_PAL_ATTACKER, -31, 1, 0, 0, RGB(31, 31, 22) delay 10 - createvisualtask AnimTask_BlendColorCycle, 2, 3, -31, 1, 5, 5, RGB(31, 31, 22) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_BG | F_PAL_ATTACKER, -31, 1, 5, 5, RGB(31, 31, 22) playsewithpan SE_M_THUNDERBOLT2, SOUND_PAN_ATTACKER createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 100, 24, 60, 10, ANIM_ATTACKER, 1, 0 createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 170, 24, 42, 11, ANIM_ATTACKER, 1, 1 delay 0 createsprite gSparkElectricitySpriteTemplate, ANIM_ATTACKER, 0, 238, 24, 165, 10, ANIM_ATTACKER, 1, 1 delay 0 - createvisualtask AnimTask_BlendColorCycle, 2, 3, -31, 1, 0, 0, RGB(31, 31, 22) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_BG | F_PAL_ATTACKER, -31, 1, 0, 0, RGB(31, 31, 22) delay 20 - createvisualtask AnimTask_BlendColorCycle, 2, 3, -31, 1, 7, 7, RGB(31, 31, 22) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_BG | F_PAL_ATTACKER, -31, 1, 7, 7, RGB(31, 31, 22) playsewithpan SE_M_THUNDERBOLT2, SOUND_PAN_ATTACKER createsprite gSparkElectricityFlashingSpriteTemplate, ANIM_ATTACKER, 4, 0, 0, 32, 12, 0, 20, 0, 0 createsprite gSparkElectricityFlashingSpriteTemplate, ANIM_ATTACKER, 4, 0, 0, 32, 12, 64, 20, 1, 0 @@ -15876,14 +15876,14 @@ Move_SPARK: createsprite gSparkElectricityFlashingSpriteTemplate, ANIM_ATTACKER, 4, 0, 0, 16, 12, 224, 20, 2, 0 delay 4 waitforvisualfinish - createvisualtask AnimTask_BlendColorCycle, 2, 3, -31, 1, 0, 0, RGB(31, 31, 22) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_BG | F_PAL_ATTACKER, -31, 1, 0, 0, RGB(31, 31, 22) createsprite gHorizontalLungeSpriteTemplate, ANIM_ATTACKER, 2, 4, 4 delay 4 playsewithpan SE_M_HYPER_BEAM, SOUND_PAN_TARGET createsprite gBasicHitSplatSpriteTemplate, ANIM_TARGET, 2, 0, 0, ANIM_TARGET, 2 createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 3, 0, 6, 1 waitforvisualfinish - createvisualtask AnimTask_BlendColorCycle, 2, 4, -31, 2, 0, 6, RGB(31, 31, 22) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_TARGET, -31, 2, 0, 6, RGB(31, 31, 22) call ElectricityEffect waitforvisualfinish end @@ -15914,7 +15914,7 @@ Move_ATTRACT: createsprite gRedHeartRisingSpriteTemplate, ANIM_ATTACKER, 40, 112, 256, 90 createsprite gRedHeartRisingSpriteTemplate, ANIM_ATTACKER, 40, 200, 272, 90 delay 75 - createvisualtask AnimTask_BlendColorCycle, 2, 4, 4, 4, 0, 10, RGB(31, 25, 27) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_TARGET, 4, 4, 0, 10, RGB(31, 25, 27) end Move_GROWTH: @@ -15924,7 +15924,7 @@ Move_GROWTH: waitforvisualfinish end GrowthEffect: - createvisualtask AnimTask_BlendColorCycle, 2, 2, 0, 2, 0, 8, RGB_WHITE + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 0, 2, 0, 8, RGB_WHITE playsewithpan SE_M_TAKE_DOWN, SOUND_PAN_ATTACKER createvisualtask AnimTask_ScaleMonAndRestore, 5, -3, -3, 16, ANIM_ATTACKER, 0 return @@ -15984,12 +15984,12 @@ Move_MEAN_LOOK: loadspritegfx ANIM_TAG_EYE monbg ANIM_DEF_PARTNER playsewithpan SE_M_PSYBEAM, SOUND_PAN_ATTACKER - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 16, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 0, 16, RGB_BLACK loopsewithpan SE_M_CONFUSE_RAY, SOUND_PAN_TARGET, 15, 4 waitplaysewithpan SE_M_LEER, SOUND_PAN_TARGET, 85 createsprite gMeanLookEyeSpriteTemplate, ANIM_ATTACKER, 2 delay 120 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 16, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 16, 0, RGB_BLACK delay 30 clearmonbg ANIM_DEF_PARTNER waitforvisualfinish @@ -16129,7 +16129,7 @@ Move_ICY_WIND: loadspritegfx ANIM_TAG_ICE_CRYSTALS loadspritegfx ANIM_TAG_ICE_SPIKES monbg ANIM_DEF_PARTNER - createvisualtask AnimTask_BlendBattleAnimPal, 10, 11, 4, 0, 4, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG | F_PAL_ATK_SIDE, 4, 0, 4, RGB_BLACK fadetobg BG_ICE waitbgfadeout playsewithpan SE_M_ICY_WIND, 0 @@ -16146,7 +16146,7 @@ Move_ICY_WIND: clearmonbg ANIM_DEF_PARTNER restorebg waitbgfadeout - createvisualtask AnimTask_BlendBattleAnimPal, 10, 11, 4, 4, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG | F_PAL_ATK_SIDE, 4, 4, 0, RGB_BLACK waitbgfadein end IcyWindSwirlingSnowballs: @@ -16501,9 +16501,9 @@ Move_EARTHQUAKE: createvisualtask AnimTask_HorizontalShake, 5, MAX_BATTLERS_COUNT, 10, 50 playsewithpan SE_M_EARTHQUAKE, 0 delay 10 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 delay 16 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 end Move_FISSURE: @@ -16514,11 +16514,11 @@ Move_FISSURE: delay 8 call FissureDirtPlumeFar delay 15 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 delay 15 call FissureDirtPlumeClose delay 15 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 delay 15 call FissureDirtPlumeFar delay 50 @@ -16746,7 +16746,7 @@ SkullBashAttack: playsewithpan SE_M_TAKE_DOWN, SOUND_PAN_ATTACKER waitforvisualfinish playse SE_BANG - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 createvisualtask AnimTask_ShakeMonInPlace, 2, ANIM_ATTACKER, 2, 0, 40, 1 createvisualtask AnimTask_ShakeMonInPlace, 2, ANIM_TARGET, 10, 0, 40, 1 createsprite gFlashingHitSplatSpriteTemplate, ANIM_TARGET, 4, 0, 0, ANIM_TARGET, 0 @@ -16792,7 +16792,7 @@ Move_GLARE: createvisualtask AnimTask_GlareEyeDots, 5, 0 playsewithpan SE_M_PSYBEAM2, SOUND_PAN_ATTACKER waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 5, 1, 0, 0, 16, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 5, F_PAL_BG, 0, 0, 16, RGB_BLACK waitforvisualfinish createsprite gEyeSparkleSpriteTemplate, ANIM_ATTACKER, 0, -16, -8 createsprite gEyeSparkleSpriteTemplate, ANIM_ATTACKER, 0, 16, -8 @@ -16801,7 +16801,7 @@ Move_GLARE: delay 2 createvisualtask AnimTask_ShakeTargetInPattern, 3, 20, 1, FALSE waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 5, 1, 0, 16, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 5, F_PAL_BG, 0, 16, 0, RGB_BLACK end Move_BARRAGE: @@ -16826,17 +16826,17 @@ SkyAttackSetUp: jumpretfalse SkyAttackSetUpAgainstOpponent goto SkyAttackSetUpAgainstPartner SkyAttackSetUpAgainstOpponent: - createvisualtask AnimTask_BlendBattleAnimPal, 10, 27, 1, 0, 12, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG | F_PAL_ATK_SIDE | F_PAL_DEF_PARTNER, 1, 0, 12, RGB_BLACK waitforvisualfinish delay 12 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 1, 8, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 1, 8, 0, RGB_BLACK createvisualtask AnimTask_HorizontalShake, 5, ANIM_ATTACKER, 2, 16 loopsewithpan SE_M_STAT_INCREASE, SOUND_PAN_ATTACKER, 4, 8 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 1, 0, 15, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 1, 0, 15, RGB_WHITE delay 20 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 1, 15, 0, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 1, 15, 0, RGB_WHITE waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 25, 1, 8, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG | F_PAL_ATK_PARTNER | F_PAL_DEF_PARTNER, 1, 8, 0, RGB_BLACK waitforvisualfinish clearmonbg ANIM_DEF_PARTNER blendoff @@ -16845,13 +16845,13 @@ SkyAttackSetUpAgainstPartner: createvisualtask AnimTask_BlendBattleAnimPalExclude, 10, ANIM_TARGET, 1, 0, 12, RGB_BLACK waitforvisualfinish delay 12 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 1, 8, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 1, 8, 0, RGB_BLACK createvisualtask AnimTask_HorizontalShake, 5, ANIM_ATTACKER, 2, 16 playsewithpan SE_M_STAT_INCREASE, SOUND_PAN_ATTACKER delay 8 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 1, 0, 15, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 1, 0, 15, RGB_WHITE delay 20 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 1, 15, 0, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 1, 15, 0, RGB_WHITE waitforvisualfinish createvisualtask AnimTask_BlendBattleAnimPalExclude, 10, 4, 1, 8, 0, RGB_BLACK waitforvisualfinish @@ -16863,7 +16863,7 @@ SkyAttackUnleash: loadspritegfx ANIM_TAG_BIRD call SetSkyBg monbg ANIM_ATTACKER - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 0, 0, 16, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 0, 0, 16, RGB_WHITE delay 4 createvisualtask AnimTask_AttackerFadeToInvisible, 5, 0 waitforvisualfinish @@ -16875,7 +16875,7 @@ SkyAttackUnleash: delay 20 createvisualtask AnimTask_AttackerFadeFromInvisible, 5, 1 delay 2 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 0, 15, 0, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 0, 15, 0, RGB_WHITE waitforvisualfinish clearmonbg ANIM_ATTACKER call UnsetSkyBg @@ -16925,7 +16925,7 @@ Move_SUPER_FANG: createsprite gSuperFangSpriteTemplate, ANIM_TARGET, 2 playsewithpan SE_M_BITE, SOUND_PAN_TARGET delay 8 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 1, RGB(31, 2, 2), 14, RGB_WHITE, 14 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 1, RGB(31, 2, 2), 14, RGB_WHITE, 14 createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 0, 7, 12, 1 waitforvisualfinish blendoff @@ -17013,7 +17013,7 @@ Move_SPITE: playsewithpan SE_M_PSYBEAM, SOUND_PAN_ATTACKER waitbgfadein monbg ANIM_DEF_PARTNER - createvisualtask AnimTask_BlendColorCycle, 2, 2, 2, 6, 0, 8, RGB_WHITE + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 2, 6, 0, 8, RGB_WHITE createvisualtask AnimTask_SpiteTargetShadow, 2 loopsewithpan SE_M_PSYBEAM, SOUND_PAN_TARGET, 20, 3 waitforvisualfinish @@ -17106,7 +17106,7 @@ Move_ENDURE: playsewithpan SE_M_DRAGON_RAGE, SOUND_PAN_ATTACKER call EndureEffect delay 8 - createvisualtask AnimTask_BlendColorCycle, 2, 2, 2, 2, 0, 11, RGB_RED + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 2, 2, 0, 11, RGB_RED createvisualtask AnimTask_ShakeMon2, 2, ANIM_ATTACKER, 1, 0, 32, 1 call EndureEffect delay 8 @@ -17240,9 +17240,9 @@ MagnitudeIntense: createvisualtask AnimTask_HorizontalShake, 5, MAX_BATTLERS_COUNT, 0, 50 loopsewithpan SE_M_STRENGTH, SOUND_PAN_TARGET, 8, 10 delay 10 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 delay 16 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 1, RGB_BLACK, 14, RGB_WHITE, 14 goto MagnitudeEnd Move_RAPID_SPIN: @@ -17269,7 +17269,7 @@ Move_MOONLIGHT: loadspritegfx ANIM_TAG_GREEN_SPARKLE loadspritegfx ANIM_TAG_BLUE_STAR setalpha 0, 16 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 16, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 0, 16, RGB_BLACK waitforvisualfinish createsprite gMoonSpriteTemplate, ANIM_ATTACKER, 2, 120, 56 createvisualtask AnimTask_AlphaFadeIn, 3, 0, 16, 16, 0, 1 @@ -17380,12 +17380,12 @@ Move_HEAT_WAVE: Move_HAIL: loadspritegfx ANIM_TAG_HAIL loadspritegfx ANIM_TAG_ICE_CRYSTALS - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 3, 0, 6, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 3, 0, 6, RGB_BLACK waitforvisualfinish createvisualtask AnimTask_Hail, 5 loopsewithpan SE_M_HAIL, 0, 8, 10 waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 3, 6, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 3, 6, 0, RGB_BLACK end Move_TORMENT: @@ -17463,7 +17463,7 @@ Move_CHARGE: loadspritegfx ANIM_TAG_ELECTRICITY monbg ANIM_ATTACKER setalpha 12, 8 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 0, 4, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 0, 4, RGB_BLACK waitforvisualfinish createvisualtask AnimTask_ElectricChargingParticles, 2, ANIM_ATTACKER, 60, 2, 12 playsewithpan SE_M_CHARGE, SOUND_PAN_ATTACKER @@ -17487,7 +17487,7 @@ Move_CHARGE: createsprite gElectricPuffSpriteTemplate, ANIM_ATTACKER, 2, 0, -16, -16 playsewithpan SE_M_THUNDERBOLT2, SOUND_PAN_ATTACKER waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 4, 4, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 4, 4, 0, RGB_BLACK clearmonbg ANIM_ATTACKER blendoff end @@ -17617,13 +17617,13 @@ BrickBreakNormal: playsewithpan SE_M_VITAL_THROW, SOUND_PAN_TARGET delay 20 createvisualtask AnimTask_WindUpLunge, 2, ANIM_ATTACKER, -24, 0, 24, 10, 24, 3 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 0, 6, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 0, 6, RGB_BLACK delay 37 createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 3, 0, 0, ANIM_TARGET, 1 createsprite gFistFootSpriteTemplate, ANIM_ATTACKER, 4, 0, 0, 10, 1, 0 playsewithpan SE_M_VITAL_THROW2, SOUND_PAN_TARGET waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 6, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 6, 0, RGB_BLACK waitforvisualfinish clearmonbg ANIM_TARGET end @@ -17643,7 +17643,7 @@ BrickBreakShatteredWall: playsewithpan SE_M_VITAL_THROW, SOUND_PAN_TARGET delay 20 createvisualtask AnimTask_WindUpLunge, 2, ANIM_ATTACKER, -24, 0, 24, 10, 24, 3 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 0, 6, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 0, 6, RGB_BLACK delay 37 createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 3, 0, 0, ANIM_TARGET, 1 createsprite gFistFootSpriteTemplate, ANIM_ATTACKER, 4, 0, 0, 10, 1, 0 @@ -17655,7 +17655,7 @@ BrickBreakShatteredWall: createsprite gBrickBreakWallShardSpriteTemplate, ANIM_ATTACKER, 2, ANIM_TARGET, 3, 8, 12 playsewithpan SE_M_BRICK_BREAK, SOUND_PAN_TARGET waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 6, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 6, 0, RGB_BLACK waitforvisualfinish clearmonbg ANIM_TARGET end @@ -17694,7 +17694,7 @@ Move_ENDEAVOR: Move_ERUPTION: loadspritegfx ANIM_TAG_WARM_ROCK - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 2, 0, 4, RGB_RED + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 2, 0, 4, RGB_RED waitforvisualfinish createvisualtask AnimTask_EruptionLaunchRocks, 2 waitplaysewithpan SE_M_EXPLOSION, SOUND_PAN_ATTACKER, 60 @@ -17714,7 +17714,7 @@ Move_ERUPTION: createvisualtask AnimTask_HorizontalShake, 5, MAX_BATTLERS_COUNT, 8, 60 loopsewithpan SE_M_ROCK_THROW, SOUND_PAN_TARGET, 16, 12 delay 80 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 40, 31, 4, 4, 0, RGB_RED + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 40, F_PAL_BG | F_PAL_BATTLERS, 4, 4, 0, RGB_RED end Move_SKILL_SWAP: @@ -17769,13 +17769,13 @@ Move_CAMOUFLAGE: monbg ANIM_ATK_PARTNER splitbgprio ANIM_ATTACKER setalpha 16, 0 - createvisualtask AnimTask_SetCamouflageBlend, 5, 2, 3, 0, 14 + createvisualtask AnimTask_SetCamouflageBlend, 5, F_PAL_ATTACKER, 3, 0, 14 delay 16 createvisualtask AnimTask_AttackerFadeToInvisible, 2, 4 playsewithpan SE_M_FAINT_ATTACK, SOUND_PAN_ATTACKER waitforvisualfinish delay 8 - createvisualtask AnimTask_SetCamouflageBlend, 5, 2, 0, 0, 0 + createvisualtask AnimTask_SetCamouflageBlend, 5, F_PAL_ATTACKER, 0, 0, 0 waitforvisualfinish createvisualtask AnimTask_AttackerFadeFromInvisible, 2, 1 waitforvisualfinish @@ -17787,13 +17787,13 @@ Move_TAIL_GLOW: loadspritegfx ANIM_TAG_CIRCLE_OF_LIGHT monbg ANIM_ATTACKER setalpha 12, 8 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 0, 4, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 0, 4, RGB_BLACK waitforvisualfinish createsprite gTailGlowOrbSpriteTemplate, ANIM_ATTACKER, 66, ANIM_ATTACKER delay 18 loopsewithpan SE_M_MORNING_SUN, SOUND_PAN_ATTACKER, 16, 6 waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 4, 4, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 4, 4, 0, RGB_BLACK clearmonbg ANIM_ATTACKER blendoff delay 1 @@ -17851,15 +17851,15 @@ Move_MIST_BALL: waitforvisualfinish playsewithpan SE_M_SAND_ATTACK, SOUND_PAN_TARGET createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 5, 0, 10, 0 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 1, 1, 1, RGB(23, 16, 31), 16, RGB_WHITE, 16 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_BG, 1, 1, RGB(23, 16, 31), 16, RGB_WHITE, 16 delay 0 playsewithpan SE_M_HAZE, 0 createvisualtask AnimTask_LoadMistTiles, 5 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 3, 0, 16, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 3, 0, 16, RGB_WHITE delay 8 createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 4, 0, 70, 0 delay 70 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 16, 0, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 16, 0, RGB_WHITE end Move_FEATHER_DANCE: @@ -18029,7 +18029,7 @@ Move_AROMATHERAPY: loadspritegfx ANIM_TAG_FLOWER loadspritegfx ANIM_TAG_THIN_RING loadspritegfx ANIM_TAG_SPARKLE_2 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 1, 0, 0, 7, RGB(13, 31, 12) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_BG, 0, 0, 7, RGB(13, 31, 12) delay 1 monbg ANIM_ATTACKER delay 1 @@ -18047,7 +18047,7 @@ Move_AROMATHERAPY: waitforvisualfinish clearmonbg ANIM_ATTACKER delay 1 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 1, 0, 7, 0, RGB(13, 31, 12) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_BG, 0, 7, 0, RGB(13, 31, 12) delay 1 playsewithpan SE_M_STAT_INCREASE, SOUND_PAN_ATTACKER createvisualtask AnimTask_StatusClearedEffect, 2, 1 @@ -18058,7 +18058,7 @@ Move_AROMATHERAPY: createsprite gSparklingStarsSpriteTemplate, ANIM_ATTACKER, 16, 12, -5, 0, 0, 32, 60, 1 waitforvisualfinish playsewithpan SE_SHINY, SOUND_PAN_ATTACKER - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 43, 3, 10, 0, RGB(13, 31, 12) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_BG | F_PAL_ATK_SIDE | F_PAL_ANIM_1, 3, 10, 0, RGB(13, 31, 12) createsprite gBlendThinRingExpandingSpriteTemplate, ANIM_ATTACKER, 16, 0, 0, 0, 1 waitforvisualfinish end @@ -18119,13 +18119,13 @@ Move_ODOR_SLEUTH: waitforvisualfinish clearmonbg ANIM_TARGET delay 1 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 1, RGB_WHITEALPHA, 16, RGB_WHITEALPHA, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 1, RGB_WHITEALPHA, 16, RGB_WHITEALPHA, 0 playsewithpan SE_M_LEER, SOUND_PAN_ATTACKER end Move_GRASS_WHISTLE: loadspritegfx ANIM_TAG_MUSIC_NOTES - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 0, 4, RGB(18, 31, 12) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 0, 4, RGB(18, 31, 12) waitforvisualfinish createvisualtask AnimTask_MusicNotesRainbowBlend, 2 waitforvisualfinish @@ -18156,19 +18156,19 @@ Move_GRASS_WHISTLE: delay 4 waitforvisualfinish createvisualtask AnimTask_MusicNotesClearRainbowBlend, 2 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 4, 4, 0, RGB(18, 31, 12) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 4, 4, 0, RGB(18, 31, 12) waitforvisualfinish end Move_TICKLE: loadspritegfx ANIM_TAG_EYE_SPARKLE - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 2, 0, 0, 16, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_ATTACKER, 0, 0, 16, RGB_BLACK waitforvisualfinish createsprite gEyeSparkleSpriteTemplate, ANIM_ATTACKER, 0, -16, -8 createsprite gEyeSparkleSpriteTemplate, ANIM_ATTACKER, 0, 16, -8 playsewithpan SE_M_DETECT, SOUND_PAN_ATTACKER waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 2, 0, 16, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_ATTACKER, 0, 16, 0, RGB_BLACK waitforvisualfinish delay 20 createvisualtask AnimTask_SwayMon, 3, 0, 6, 1280, 3, ANIM_ATTACKER @@ -18247,7 +18247,7 @@ Move_AERIAL_ACE: playsewithpan SE_M_RAZOR_WIND2, SOUND_PAN_ATTACKER delay 5 createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 0, 3, 10, 1 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 1, RGB_BLACK, 10, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 1, RGB_BLACK, 10, RGB_BLACK, 0 playsewithpan SE_M_RAZOR_WIND, SOUND_PAN_TARGET waitforvisualfinish clearmonbg ANIM_TARGET @@ -18257,7 +18257,7 @@ Move_AERIAL_ACE: Move_IRON_DEFENSE: loopsewithpan SE_SHINY, SOUND_PAN_ATTACKER, 28, 2 createvisualtask AnimTask_MetallicShine, 5, 0, 0, 0 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 8, 2, RGB_WHITEALPHA, 14, RGB_WHITEALPHA, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 8, 2, RGB_WHITEALPHA, 14, RGB_WHITEALPHA, 0 waitforvisualfinish end @@ -18310,7 +18310,7 @@ Move_VOLT_TACKLE: loadspritegfx ANIM_TAG_ELECTRICITY monbg ANIM_ATTACKER setalpha 12, 8 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 0, 0, 8, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 0, 0, 8, RGB_BLACK waitforvisualfinish createsprite gVoltTackleOrbSlideSpriteTemplate, ANIM_ATTACKER, 1 playsewithpan SE_M_CHARGE, SOUND_PAN_ATTACKER @@ -18347,7 +18347,7 @@ Move_VOLT_TACKLE: delay 2 createsprite gElectricPuffSpriteTemplate, ANIM_ATTACKER, 2, 0, -16, -16 waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1, 0, 8, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 0, 8, 0, RGB_BLACK waitforvisualfinish end @@ -18443,7 +18443,7 @@ Move_SHOCK_WAVE: loadspritegfx ANIM_TAG_LIGHTNING monbg ANIM_ATTACKER setalpha 12, 8 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 0, 4, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 0, 4, RGB_BLACK waitforvisualfinish createvisualtask AnimTask_ElectricChargingParticles, 2, ANIM_ATTACKER, 20, 0, 2 playsewithpan SE_M_CHARGE, SOUND_PAN_ATTACKER @@ -18457,10 +18457,10 @@ Move_SHOCK_WAVE: playsewithpan SE_M_TRI_ATTACK2, SOUND_PAN_TARGET waitforvisualfinish createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 0, 6, 18, 1 - createvisualtask AnimTask_BlendBattleAnimPal, 5, 1, 3, 16, 0, RGB_WHITE - createvisualtask AnimTask_BlendBattleAnimPal, 5, 4, 0, 16, 16, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 5, F_PAL_BG, 3, 16, 0, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 5, F_PAL_TARGET, 0, 16, 16, RGB_BLACK delay 4 - createvisualtask AnimTask_BlendBattleAnimPal, 5, 4, 0, 0, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 5, F_PAL_TARGET, 0, 0, 0, RGB_BLACK waitforvisualfinish clearmonbg ANIM_ATTACKER blendoff @@ -18525,7 +18525,7 @@ Move_MIND_READER: createsprite gWhiteHaloSpriteTemplate, ANIM_ATTACKER, 5 delay 40 playsewithpan SE_M_LEER, SOUND_PAN_TARGET - createvisualtask AnimTask_BlendColorCycle, 2, 1, 1, 2, 0, 10, RGB_BLACK + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_BG, 1, 2, 0, 10, RGB_BLACK call MindReaderEyeSpikeEffect waitforvisualfinish clearmonbg ANIM_DEF_PARTNER @@ -18561,8 +18561,8 @@ Move_ICE_PUNCH: loadspritegfx ANIM_TAG_ICE_CRYSTALS loadspritegfx ANIM_TAG_IMPACT loadspritegfx ANIM_TAG_HANDS_AND_FEET - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 7, RGB_BLACK - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 0, 9, RGB(12, 26, 31) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 0, 7, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 0, 9, RGB(12, 26, 31) delay 20 playsewithpan SE_M_STRING_SHOT, SOUND_PAN_TARGET createsprite gIceCrystalSpiralInwardSmall, ANIM_ATTACKER, 2, 0 @@ -18584,9 +18584,9 @@ Move_ICE_PUNCH: delay 15 call IceCrystalEffectShort delay 5 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 9, 0, RGB(12, 26, 31) + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 9, 0, RGB(12, 26, 31) waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 0, 7, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 0, 7, 0, RGB_BLACK waitforvisualfinish clearmonbg ANIM_DEF_PARTNER blendoff @@ -18608,7 +18608,7 @@ Move_CONFUSION: call SetPsychicBackground setalpha 8, 8 createvisualtask AnimTask_ShakeMon2, 2, ANIM_ATTACKER, 1, 0, 10, 1 - createvisualtask AnimTask_BlendColorCycle, 2, 2, 0, 2, 0, 8, RGB_WHITE + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 0, 2, 0, 8, RGB_WHITE waitforvisualfinish playsewithpan SE_M_SUPERSONIC, SOUND_PAN_TARGET createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 3, 0, 15, 1 @@ -18625,7 +18625,7 @@ Move_PSYCHIC: call SetPsychicBackground setalpha 8, 8 createvisualtask AnimTask_ShakeMon2, 2, ANIM_ATTACKER, 1, 0, 10, 1 - createvisualtask AnimTask_BlendColorCycle, 2, 2, 0, 2, 0, 8, RGB(31, 23, 0) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 0, 2, 0, 8, RGB(31, 23, 0) waitforvisualfinish loopsewithpan SE_M_SUPERSONIC, SOUND_PAN_TARGET, 10, 3 createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 5, 0, 15, 1 @@ -18650,7 +18650,7 @@ FutureSight: call SetPsychicBackground setalpha 8, 8 playsewithpan SE_M_SUPERSONIC, SOUND_PAN_ATTACKER - createvisualtask AnimTask_BlendColorCycle, 2, 2, 0, 2, 0, 8, RGB_WHITE + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 0, 2, 0, 8, RGB_WHITE createvisualtask AnimTask_ScaleMonAndRestore, 5, -4, -4, 15, ANIM_ATTACKER, 1 waitforvisualfinish clearmonbg ANIM_ATK_PARTNER @@ -18663,7 +18663,7 @@ Move_THUNDER: waitbgfadeout createvisualtask AnimTask_StartSlidingBg, 5, -256, 0, 1, -1 waitbgfadein - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 0, 16, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 0, 16, RGB_BLACK delay 16 createvisualtask AnimTask_InvertScreenColor, 2, 0x1 | 0x2 | 0x4 playsewithpan SE_M_THUNDER_WAVE, SOUND_PAN_TARGET @@ -18707,7 +18707,7 @@ Move_THUNDER: delay 2 createvisualtask AnimTask_InvertScreenColor, 2, 0x1 | 0x2 | 0x4 delay 1 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_TARGET, 2, 1, 2, 16, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_TARGET, 2, F_PAL_BG, 2, 16, 0, RGB_BLACK waitforvisualfinish restorebg waitbgfadeout @@ -18721,7 +18721,7 @@ Move_THUNDER_PUNCH: loadspritegfx ANIM_TAG_LIGHTNING monbg ANIM_TARGET setalpha 12, 8 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 0, 16, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 0, 16, RGB_BLACK waitforvisualfinish playsewithpan SE_M_COMET_PUNCH, SOUND_PAN_TARGET createsprite gFistFootSpriteTemplate, ANIM_TARGET, 4, 0, 0, 8, 1, 0 @@ -18741,7 +18741,7 @@ Move_THUNDER_PUNCH: createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 0, 3, 15, 1 createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 3, 0, 0, ANIM_TARGET, 2 delay 1 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 16, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 16, 0, RGB_BLACK delay 20 waitforvisualfinish clearmonbg ANIM_TARGET @@ -18827,7 +18827,7 @@ Move_DRAGON_BREATH: delay 2 createsprite gDragonBreathFireSpriteTemplate, ANIM_TARGET, 2, 0, 0, 0, 0, 20 delay 2 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 1, 0, 9, RGB_RED + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 1, 0, 9, RGB_RED createsprite gDragonBreathFireSpriteTemplate, ANIM_TARGET, 2, 0, 0, 0, 0, 20 delay 2 createvisualtask AnimTask_ShakeMon2, 2, ANIM_TARGET, 2, 0, 21, 1 @@ -18847,7 +18847,7 @@ Move_DRAGON_BREATH: delay 2 createsprite gDragonBreathFireSpriteTemplate, ANIM_TARGET, 2, 0, 0, 0, 0, 20 waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 1, 9, 0, RGB_RED + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 1, 9, 0, RGB_RED waitforvisualfinish clearmonbg ANIM_DEF_PARTNER end @@ -18927,17 +18927,17 @@ Move_LIGHT_SCREEN: end SpecialScreenSparkle: - createsprite gSpecialScreenSparkleSpriteTemplate, ANIM_ATTACKER, 2, 23, 0, ANIM_ATTACKER, 1 + createsprite gSpecialScreenSparkleSpriteTemplate, ANIM_ATTACKER, 2, 23, 0, ANIM_ATTACKER, TRUE delay 6 - createsprite gSpecialScreenSparkleSpriteTemplate, ANIM_ATTACKER, 2, 31, -8, ANIM_ATTACKER, 1 + createsprite gSpecialScreenSparkleSpriteTemplate, ANIM_ATTACKER, 2, 31, -8, ANIM_ATTACKER, TRUE delay 5 - createsprite gSpecialScreenSparkleSpriteTemplate, ANIM_ATTACKER, 2, 30, 20, ANIM_ATTACKER, 1 + createsprite gSpecialScreenSparkleSpriteTemplate, ANIM_ATTACKER, 2, 30, 20, ANIM_ATTACKER, TRUE delay 7 - createsprite gSpecialScreenSparkleSpriteTemplate, ANIM_ATTACKER, 2, 10, -15, ANIM_ATTACKER, 1 + createsprite gSpecialScreenSparkleSpriteTemplate, ANIM_ATTACKER, 2, 10, -15, ANIM_ATTACKER, TRUE delay 6 - createsprite gSpecialScreenSparkleSpriteTemplate, ANIM_ATTACKER, 2, 20, 10, ANIM_ATTACKER, 1 + createsprite gSpecialScreenSparkleSpriteTemplate, ANIM_ATTACKER, 2, 20, 10, ANIM_ATTACKER, TRUE delay 6 - createsprite gSpecialScreenSparkleSpriteTemplate, ANIM_ATTACKER, 2, 10, 18, ANIM_ATTACKER, 1 + createsprite gSpecialScreenSparkleSpriteTemplate, ANIM_ATTACKER, 2, 10, 18, ANIM_ATTACKER, TRUE return Move_MIRROR_COAT: @@ -18960,11 +18960,11 @@ Move_REFLECT: waitplaysewithpan SE_M_REFLECT, SOUND_PAN_ATTACKER, 15 createsprite gReflectWallSpriteTemplate, ANIM_ATTACKER, 1, 40, 0, ANIM_TAG_BLUE_LIGHT_WALL delay 20 - createsprite gReflectSparkleSpriteTemplate, ANIM_ATTACKER, 2, 30, 0, ANIM_ATTACKER, 1 + createsprite gReflectSparkleSpriteTemplate, ANIM_ATTACKER, 2, 30, 0, ANIM_ATTACKER, TRUE delay 7 - createsprite gReflectSparkleSpriteTemplate, ANIM_ATTACKER, 2, 19, -12, ANIM_ATTACKER, 1 + createsprite gReflectSparkleSpriteTemplate, ANIM_ATTACKER, 2, 19, -12, ANIM_ATTACKER, TRUE delay 7 - createsprite gReflectSparkleSpriteTemplate, ANIM_ATTACKER, 2, 10, 20, ANIM_ATTACKER, 1 + createsprite gReflectSparkleSpriteTemplate, ANIM_ATTACKER, 2, 10, 20, ANIM_ATTACKER, TRUE waitforvisualfinish delay 1 blendoff @@ -19031,7 +19031,7 @@ Move_SMOG: call SmogCloud delay 120 loopsewithpan SE_M_TOXIC, SOUND_PAN_TARGET, 18, 2 - createvisualtask AnimTask_BlendColorCycle, 2, 4, 2, 2, 0, 12, RGB(26, 0, 26) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_TARGET, 2, 2, 0, 12, RGB(26, 0, 26) delay 10 createvisualtask AnimTask_ShakeMon2, 2, ANIM_TARGET, 2, 0, 15, 1 waitforvisualfinish @@ -19165,14 +19165,14 @@ Move_DRAGON_RAGE: Move_RAIN_DANCE: loadspritegfx ANIM_TAG_RAIN_DROPS playsewithpan SE_M_RAIN_DANCE, SOUND_PAN_ATTACKER - createvisualtask AnimTask_BlendBattleAnimPal, 10, 0x781, 2, 0, 4, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG | F_PAL_BATTLERS_2, 2, 0, 4, RGB_BLACK waitforvisualfinish createvisualtask AnimTask_CreateRaindrops, 2, 0, 3, 120 createvisualtask AnimTask_CreateRaindrops, 2, 0, 3, 120 delay 120 delay 30 waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 0x781, 2, 4, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG | F_PAL_BATTLERS_2, 2, 4, 0, RGB_BLACK waitforvisualfinish end @@ -19243,7 +19243,7 @@ Move_ICE_BEAM: splitbgprio ANIM_TARGET setalpha 12, 8 loadspritegfx ANIM_TAG_ICE_CRYSTALS - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 7, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 0, 7, RGB_BLACK waitforvisualfinish createsoundtask SoundTask_LoopSEAdjustPanning, SE_M_BUBBLE_BEAM2, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, 4, 4, 0, 10 createsprite gIceBeamOuterCrystalSpriteTemplate, ANIM_ATTACKER, 2, 20, 12, 0, 12, 20 @@ -19252,7 +19252,7 @@ Move_ICE_BEAM: call IceBeamCreateCrystals call IceBeamCreateCrystals call IceBeamCreateCrystals - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 4, -31, 0, 7, RGB(0, 20, 31) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_TARGET, -31, 0, 7, RGB(0, 20, 31) createvisualtask AnimTask_ShakeMon2, 2, ANIM_TARGET, 2, 0, 25, 1 call IceBeamCreateCrystals call IceBeamCreateCrystals @@ -19268,9 +19268,9 @@ Move_ICE_BEAM: waitforvisualfinish delay 20 call IceCrystalEffectShort - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 4, 5, 7, 0, RGB(0, 20, 31) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_TARGET, 5, 7, 0, RGB(0, 20, 31) waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 0, 7, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 0, 7, 0, RGB_BLACK waitforvisualfinish clearmonbg ANIM_TARGET blendoff @@ -19333,7 +19333,7 @@ SolarBeamEnd: SolarBeamSetUp: monbg ANIM_ATK_PARTNER setalpha 12, 8 - createvisualtask AnimTask_BlendColorCycle, 2, 2, 1, 4, 0, 11, RGB(31, 31, 11) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 1, 4, 0, 11, RGB(31, 31, 11) playsewithpan SE_M_MEGA_KICK, SOUND_PAN_ATTACKER call SolarBeamAbsorbEffect waitforvisualfinish @@ -19378,7 +19378,7 @@ SolarBeamUnleash: delay 4 createsprite gSolarBeamBigOrbSpriteTemplate, ANIM_TARGET, 3, 15, 0, 20, 1 delay 4 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 1, 0, 10, RGB(25, 31, 0) + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 1, 0, 10, RGB(25, 31, 0) createsprite gSolarBeamBigOrbSpriteTemplate, ANIM_TARGET, 3, 15, 0, 20, 2 delay 4 createvisualtask AnimTask_ShakeMon2, 5, ANIM_TARGET, 2, 0, 65, 1 @@ -19393,7 +19393,7 @@ SolarBeamUnleash: call SolarBeamUnleash1 call SolarBeamUnleash1 waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 1, 10, 0, RGB(25, 31, 0) + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 1, 10, 0, RGB(25, 31, 0) call UnsetSolarBeamBg goto SolarBeamEnd SolarBeamUnleash1: @@ -19456,7 +19456,7 @@ BlizzardIceCrystals: Move_POWDER_SNOW: loadspritegfx ANIM_TAG_ICE_CRYSTALS monbg ANIM_DEF_PARTNER - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 1, 0, 3, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 1, 0, 3, RGB_BLACK waitforvisualfinish panse SE_M_GUST, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 call PowderSnowSnowballs @@ -19468,7 +19468,7 @@ Move_POWDER_SNOW: waitforvisualfinish clearmonbg ANIM_DEF_PARTNER delay 20 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 1, 3, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 1, 3, 0, RGB_BLACK end PowderSnowSnowballs: createsprite gPowderSnowSnowballSpriteTemplate, ANIM_ATTACKER, 40, 0, 0, 0, 0, 56, 4, 4, 1 @@ -19549,7 +19549,7 @@ Move_SIGNAL_BEAM: call SignalBeamOrbs call SignalBeamOrbs createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 3, 0, 25, 1 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 4, 8, 5, RGB_RED, 8, RGB(1, 30, 0), 8 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_TARGET, 8, 5, RGB_RED, 8, RGB(1, 30, 0), 8 call SignalBeamOrbs call SignalBeamOrbs call SignalBeamOrbs @@ -19582,7 +19582,7 @@ Move_ABSORB: monbg ANIM_DEF_PARTNER splitbgprio_foes ANIM_TARGET setalpha 12, 8 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 4, RGB(13, 31, 12) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 0, 4, RGB(13, 31, 12) waitforvisualfinish playsewithpan SE_M_ABSORB, SOUND_PAN_TARGET createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 2, 0, 0, ANIM_TARGET, 2 @@ -19595,7 +19595,7 @@ Move_ABSORB: delay 15 call HealingEffect waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 4, 0, RGB(13, 31, 12) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 4, 0, RGB(13, 31, 12) waitforvisualfinish clearmonbg ANIM_DEF_PARTNER blendoff @@ -19635,7 +19635,7 @@ Move_MEGA_DRAIN: monbg ANIM_DEF_PARTNER splitbgprio_foes ANIM_TARGET setalpha 12, 8 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 8, RGB(13, 31, 12) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 0, 8, RGB(13, 31, 12) waitforvisualfinish playsewithpan SE_M_ABSORB, SOUND_PAN_TARGET createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 2, 0, 0, ANIM_TARGET, 1 @@ -19648,7 +19648,7 @@ Move_MEGA_DRAIN: delay 15 call HealingEffect waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 8, 0, RGB(13, 31, 12) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 8, 0, RGB(13, 31, 12) waitforvisualfinish clearmonbg ANIM_DEF_PARTNER blendoff @@ -19696,7 +19696,7 @@ Move_GIGA_DRAIN: monbg ANIM_DEF_PARTNER splitbgprio_foes ANIM_TARGET setalpha 12, 8 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 12, RGB(13, 31, 12) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 0, 12, RGB(13, 31, 12) waitforvisualfinish playsewithpan SE_M_ABSORB, SOUND_PAN_TARGET createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 2, 0, 0, ANIM_TARGET, 0 @@ -19709,7 +19709,7 @@ Move_GIGA_DRAIN: delay 15 call HealingEffect waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 12, 0, RGB(13, 31, 12) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 12, 0, RGB(13, 31, 12) waitforvisualfinish clearmonbg ANIM_DEF_PARTNER blendoff @@ -19775,14 +19775,14 @@ Move_LEECH_LIFE: delay 2 createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 0, 5, 5, 1 waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 7, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 0, 7, RGB_BLACK waitforvisualfinish call AbsorbEffect waitforvisualfinish delay 15 call HealingEffect waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 7, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 7, 0, RGB_BLACK waitforvisualfinish clearmonbg ANIM_DEF_PARTNER blendoff @@ -19790,7 +19790,7 @@ Move_LEECH_LIFE: Move_SYNTHESIS: loadspritegfx ANIM_TAG_SPARKLE_2 - createvisualtask AnimTask_BlendColorCycle, 2, 2, 2, 2, 0, 16, RGB(27, 31, 18) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 2, 2, 0, 16, RGB(27, 31, 18) playsewithpan SE_M_MEGA_KICK, SOUND_PAN_ATTACKER call GrantingStarsEffect waitforvisualfinish @@ -19832,7 +19832,7 @@ Move_SLUDGE: createsprite gSludgeProjectileSpriteTemplate, ANIM_TARGET, 2, 20, 0, 40, 0 waitforvisualfinish createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 3, 0, 5, 1 - createvisualtask AnimTask_BlendColorCycle, 2, 4, 1, 2, 0, 12, RGB(30, 0, 31) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_TARGET, 1, 2, 0, 12, RGB(30, 0, 31) call PoisonBubblesEffect waitforvisualfinish end @@ -19850,7 +19850,7 @@ Move_SLUDGE_BOMB: call SludgeBombProjectile call SludgeBombProjectile createvisualtask AnimTask_ShakeMon2, 5, ANIM_TARGET, 3, 0, 15, 1 - createvisualtask AnimTask_BlendColorCycle, 2, 4, 1, 2, 0, 12, RGB(30, 0, 31) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_TARGET, 1, 2, 0, 12, RGB(30, 0, 31) createsprite gSludgeBombHitParticleSpriteTemplate, ANIM_TARGET, 2, 42, 27, 20 createsprite gSludgeBombHitParticleSpriteTemplate, ANIM_TARGET, 2, -27, 44, 20 createsprite gSludgeBombHitParticleSpriteTemplate, ANIM_TARGET, 2, 39, -28, 20 @@ -19894,7 +19894,7 @@ Move_ACID: delay 15 createvisualtask AnimTask_ShakeMon2, 5, ANIM_TARGET, 2, 0, 10, 1 createvisualtask AnimTask_ShakeMon2, 5, ANIM_DEF_PARTNER, 2, 0, 10, 1 - createvisualtask AnimTask_BlendColorCycle, 2, 20, 2, 2, 0, 12, RGB(30, 0, 31) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_DEF_SIDE, 2, 2, 0, 12, RGB(30, 0, 31) createsprite gAcidPoisonDropletSpriteTemplate, ANIM_TARGET, 2, 0, -22, 0, 15, 55, TRUE playsewithpan SE_M_BUBBLE, SOUND_PAN_TARGET delay 10 @@ -19944,7 +19944,7 @@ Move_BONE_CLUB: delay 12 createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 2, 0, 0, ANIM_TARGET, 1 createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 0, 5, 5, 1 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 7, 5, 1, RGB_BLACK, 10, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_ATTACKER | F_PAL_TARGET, 5, 1, RGB_BLACK, 10, RGB_BLACK, 0 playsewithpan SE_M_VITAL_THROW2, SOUND_PAN_TARGET waitforvisualfinish clearmonbg ANIM_DEF_PARTNER @@ -20008,7 +20008,7 @@ MegahornContinue: createsprite gSlideMonToOffsetSpriteTemplate, ANIM_ATTACKER, 2, 1, -16, 4, 1, 4 waitforvisualfinish createvisualtask AnimTask_ShakeMonInPlace, 2, ANIM_TARGET, -4, 1, 12, 1 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 7, 5, 1, RGB_WHITE, 10, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_ATTACKER | F_PAL_TARGET, 5, 1, RGB_WHITE, 10, RGB_BLACK, 0 delay 10 createsprite gSlideMonToOriginalPosSpriteTemplate, ANIM_ATTACKER, 2, 0, 0, 11 delay 3 @@ -20150,7 +20150,7 @@ Move_CRABHAMMER: createsprite gWaterHitSplatSpriteTemplate, ANIM_ATTACKER, 4, 0, 0, ANIM_TARGET, 0 playsewithpan SE_M_VITAL_THROW2, SOUND_PAN_TARGET delay 1 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 1, RGB(13, 21, 31), 10, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 1, RGB(13, 21, 31), 10, RGB_BLACK, 0 createsprite gSlideMonToOffsetSpriteTemplate, ANIM_ATTACKER, 2, 1, -24, 0, 0, 4 waitforvisualfinish delay 8 @@ -20246,14 +20246,14 @@ Move_WHIRLPOOL: splitbgprio ANIM_TARGET setalpha 12, 8 delay 0 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 4, 2, 0, 7, RGB(0, 13, 23) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_TARGET, 2, 0, 7, RGB(0, 13, 23) playsewithpan SE_M_WHIRLPOOL, SOUND_PAN_TARGET createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 0, 2, 50, 1 call WhirlpoolEffect call WhirlpoolEffect call WhirlpoolEffect delay 12 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 4, 2, 7, 0, RGB(0, 13, 23) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_TARGET, 2, 7, 0, RGB(0, 13, 23) waitforvisualfinish clearmonbg ANIM_DEF_PARTNER end @@ -20353,7 +20353,7 @@ Move_CROSS_CHOP: createsprite gCrossChopHandSpriteTemplate, ANIM_ATTACKER, 2, 0, 0, 1 delay 40 playsewithpan SE_M_RAZOR_WIND, SOUND_PAN_TARGET - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 1, RGB_WHITE, 10, RGB_BLACK, 10 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 1, RGB_WHITE, 10, RGB_BLACK, 10 createsprite gCrossImpactSpriteTemplate, ANIM_ATTACKER, 3, 0, 0, 1, 20 createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 7, 0, 9, 1 waitforvisualfinish @@ -20605,7 +20605,7 @@ Move_SUNNY_DAY: loadspritegfx ANIM_TAG_SUNLIGHT monbg ANIM_ATK_PARTNER setalpha 13, 3 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 0x781, 1, 0, 6, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG | F_PAL_BATTLERS_2, 1, 0, 6, RGB_WHITE waitforvisualfinish panse_adjustnone SE_M_PETAL_DANCE, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +1, 0 call SunnyDayLightRay @@ -20613,7 +20613,7 @@ Move_SUNNY_DAY: call SunnyDayLightRay call SunnyDayLightRay waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 0x781, 1, 6, 0, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG | F_PAL_BATTLERS_2, 1, 6, 0, RGB_WHITE waitforvisualfinish clearmonbg ANIM_ATK_PARTNER blendoff @@ -20813,7 +20813,7 @@ Move_MIST: call MistCloud call MistCloud delay 32 - createvisualtask AnimTask_BlendColorCycle, 2, 10, 8, 2, 0, 14, RGB_WHITE + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATK_SIDE, 8, 2, 0, 14, RGB_WHITE waitforvisualfinish clearmonbg ANIM_ATK_PARTNER blendoff @@ -20829,9 +20829,9 @@ Move_HAZE: playsewithpan SE_M_HAZE, 0 createvisualtask AnimTask_HazeScrollingFog, 5 delay 30 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 0x780, 2, 0, 16, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BATTLERS_2, 2, 0, 16, RGB_BLACK delay 90 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 0x780, 1, 16, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BATTLERS_2, 1, 16, 0, RGB_BLACK end Move_FIRE_PUNCH: @@ -20840,7 +20840,7 @@ Move_FIRE_PUNCH: loadspritegfx ANIM_TAG_IMPACT monbg ANIM_DEF_PARTNER setalpha 12, 8 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 0, 9, RGB_RED + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 0, 9, RGB_RED createsprite gFireSpiralInwardSpriteTemplate, ANIM_TARGET, 1, 0 createsprite gFireSpiralInwardSpriteTemplate, ANIM_TARGET, 1, 64 createsprite gFireSpiralInwardSpriteTemplate, ANIM_TARGET, 1, 128 @@ -20854,7 +20854,7 @@ Move_FIRE_PUNCH: delay 4 playsewithpan SE_M_FLAMETHROWER, SOUND_PAN_TARGET waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 0, 9, 0, RGB_RED + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 0, 9, 0, RGB_RED waitforvisualfinish clearmonbg ANIM_DEF_PARTNER blendoff @@ -20983,7 +20983,7 @@ Move_POISON_GAS: createsprite gPoisonGasCloudSpriteTemplate, ANIM_TARGET, 0, 64, 0, 0, -32, -6, 4192, 1072, 0 delay 40 loopsewithpan SE_M_MIST, SOUND_PAN_TARGET, 28, 6 - createvisualtask AnimTask_BlendColorCycle, 2, 4, 6, 2, 0, 12, RGB(26, 0, 26) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_TARGET, 6, 2, 0, 12, RGB(26, 0, 26) waitforvisualfinish blendoff clearmonbg ANIM_DEF_PARTNER @@ -21017,7 +21017,7 @@ Move_PSYBEAM: call PsybeamRings call PsybeamRings createvisualtask AnimTask_SwayMon, 5, 0, 6, 2048, 4, ANIM_TARGET - createvisualtask AnimTask_BlendColorCycle, 2, 4, 2, 2, 0, 12, RGB(31, 18, 31) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_TARGET, 2, 2, 0, 12, RGB(31, 18, 31) call PsybeamRings call PsybeamRings call PsybeamRings @@ -21042,7 +21042,7 @@ Move_HYPNOSIS: call HypnosisRings call HypnosisRings call HypnosisRings - createvisualtask AnimTask_BlendColorCycle, 2, 4, 2, 2, 0, 12, RGB(31, 18, 31) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_TARGET, 2, 2, 0, 12, RGB(31, 18, 31) waitforvisualfinish delay 1 call UnsetPsychicBg @@ -21062,7 +21062,7 @@ Move_PSYWAVE: createsoundtask SoundTask_LoopSEAdjustPanning, SE_M_TELEPORT, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, 2, 9, 0, 10 call PsywaveRings call PsywaveRings - createvisualtask AnimTask_BlendColorCycle, 2, 4, 1, 4, 0, 12, RGB(31, 18, 31) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_TARGET, 1, 4, 0, 12, RGB(31, 18, 31) call PsywaveRings call PsywaveRings call PsywaveRings @@ -21198,7 +21198,7 @@ Move_NIGHT_SHADE: createvisualtask AnimTask_NightShadeClone, 5, 85 delay 70 createvisualtask AnimTask_ShakeMon2, 2, ANIM_TARGET, 2, 0, 12, 1 - createvisualtask AnimTask_BlendColorCycle, 2, 4, 0, 2, 0, 13, RGB_BLACK + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_TARGET, 0, 2, 0, 13, RGB_BLACK waitforvisualfinish clearmonbg ANIM_ATTACKER delay 1 @@ -21260,7 +21260,7 @@ Move_FOCUS_ENERGY: playsewithpan SE_M_DRAGON_RAGE, SOUND_PAN_ATTACKER call EndureEffect delay 8 - createvisualtask AnimTask_BlendColorCycle, 2, 2, 2, 2, 0, 11, RGB_WHITE + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 2, 2, 0, 11, RGB_WHITE createvisualtask AnimTask_ShakeMon2, 2, ANIM_ATTACKER, 1, 0, 32, 1 call EndureEffect delay 8 @@ -21273,7 +21273,7 @@ Move_BIDE: end BideSetUp: loopsewithpan SE_M_TAKE_DOWN, SOUND_PAN_ATTACKER, 9, 2 - createvisualtask AnimTask_BlendColorCycle, 2, 2, 2, 2, 0, 11, RGB_RED + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 2, 2, 0, 11, RGB_RED createvisualtask AnimTask_ShakeMon2, 2, ANIM_ATTACKER, 1, 0, 32, 1 waitforvisualfinish end @@ -21283,7 +21283,7 @@ BideUnleash: monbg ANIM_DEF_PARTNER setalpha 12, 8 loopsewithpan SE_M_TAKE_DOWN, SOUND_PAN_ATTACKER, 9, 2 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 2, 0, 11, RGB_RED + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 2, 0, 11, RGB_RED createvisualtask AnimTask_ShakeMon2, 2, ANIM_ATTACKER, 1, 0, 32, 1 waitforvisualfinish createsprite gSlideMonToOffsetSpriteTemplate, ANIM_ATTACKER, 2, 0, 24, 0, 0, 4 @@ -21302,7 +21302,7 @@ BideUnleash: delay 5 createsprite gSlideMonToOriginalPosSpriteTemplate, ANIM_ATTACKER, 2, 0, 0, 7 waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 2, 11, 0, RGB_RED + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 2, 11, 0, RGB_RED waitforvisualfinish clearmonbg ANIM_DEF_PARTNER blendoff @@ -21313,7 +21313,7 @@ Move_STRING_SHOT: loadspritegfx ANIM_TAG_WEB_THREAD monbg ANIM_DEF_PARTNER delay 0 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 5, 1, 2, 0, 9, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 5, F_PAL_BG, 2, 0, 9, RGB_BLACK waitforvisualfinish loopsewithpan SE_M_STRING_SHOT, SOUND_PAN_ATTACKER, 9, 6 call StringShotThread @@ -21345,7 +21345,7 @@ Move_STRING_SHOT: clearmonbg ANIM_DEF_PARTNER delay 1 waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 5, 1, 2, 9, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 5, F_PAL_BG, 2, 9, 0, RGB_BLACK end StringShotThread: @@ -21358,7 +21358,7 @@ Move_SPIDER_WEB: loadspritegfx ANIM_TAG_WEB_THREAD monbg ANIM_DEF_PARTNER delay 0 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 5, 1, 2, 0, 9, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 5, F_PAL_BG, 2, 0, 9, RGB_BLACK waitforvisualfinish splitbgprio ANIM_TARGET loopsewithpan SE_M_STRING_SHOT, SOUND_PAN_ATTACKER, 9, 6 @@ -21382,7 +21382,7 @@ Move_SPIDER_WEB: waitforvisualfinish clearmonbg ANIM_DEF_PARTNER delay 1 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 5, 1, 2, 9, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 5, F_PAL_BG, 2, 9, 0, RGB_BLACK end SpiderWebThread: @@ -21450,7 +21450,7 @@ Move_RECOVER: monbg ANIM_ATK_PARTNER setalpha 12, 8 loopsewithpan SE_M_MEGA_KICK, SOUND_PAN_ATTACKER, 13, 3 - createvisualtask AnimTask_BlendColorCycle, 2, 2, 0, 6, 0, 11, RGB(31, 31, 11) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 0, 6, 0, 11, RGB(31, 31, 11) call RecoverAbsorbEffect call RecoverAbsorbEffect call RecoverAbsorbEffect @@ -21492,7 +21492,7 @@ Move_MIMIC: setarg 7, 0xFFFF waitforvisualfinish playsewithpan SE_M_TAKE_DOWN, SOUND_PAN_ATTACKER - createvisualtask AnimTask_BlendColorCycle, 2, 2, 0, 2, 0, 11, RGB_WHITE + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 0, 2, 0, 11, RGB_WHITE waitforvisualfinish clearmonbg_static ANIM_DEF_PARTNER blendoff @@ -21539,7 +21539,7 @@ CurseGhost: createsprite gCurseGhostSpriteTemplate, ANIM_TARGET, 2 createvisualtask AnimTask_ShakeMon2, 2, ANIM_TARGET, 2, 0, 14, 1 waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 16, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 16, 0, RGB_BLACK waitforvisualfinish clearmonbg ANIM_DEF_PARTNER end @@ -21557,7 +21557,7 @@ CurseStats: CurseStats1: playsewithpan SE_M_DRAGON_RAGE, SOUND_PAN_ATTACKER createvisualtask AnimTask_DrawFallingWhiteLinesOnAttacker, 5 - createvisualtask AnimTask_BlendColorCycle, 5, 2, 4, 2, 0, 10, RGB_RED + createvisualtask AnimTask_BlendColorCycle, 5, F_PAL_ATTACKER, 4, 2, 0, 10, RGB_RED return Move_SOFT_BOILED: @@ -21572,7 +21572,7 @@ Move_SOFT_BOILED: delay 120 delay 7 playsewithpan SE_M_HORN_ATTACK, SOUND_PAN_ATTACKER - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 10, 0, RGB(12, 24, 30) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 10, 0, RGB(12, 24, 30) createsprite gThinRingExpandingSpriteTemplate, ANIM_ATTACKER, 3, 31, 16, 0, 1 delay 8 createsprite gThinRingExpandingSpriteTemplate, ANIM_ATTACKER, 3, 31, 16, 0, 1 @@ -21587,7 +21587,7 @@ Move_HEAL_BELL: loadspritegfx ANIM_TAG_BELL loadspritegfx ANIM_TAG_MUSIC_NOTES_2 loadspritegfx ANIM_TAG_THIN_RING - createvisualtask AnimTask_BlendBattleAnimPal, 10, 10, 0, 0, 10, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATK_SIDE, 0, 0, 10, RGB_WHITE waitforvisualfinish createvisualtask AnimTask_LoadMusicNotesPals, 5 createsprite gBellSpriteTemplate, ANIM_ATTACKER, 2, 0, -24, 0, 1 @@ -21625,12 +21625,12 @@ Move_HEAL_BELL: loadspritegfx ANIM_TAG_THIN_RING playsewithpan SE_SHINY, SOUND_PAN_ATTACKER createvisualtask AnimTask_BlendBattleAnimPalExclude, 10, 4, 3, 10, 0, RGB(12, 24, 30) - createvisualtask AnimTask_BlendBattleAnimPal, 10, 10, 3, 10, 0, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATK_SIDE, 3, 10, 0, RGB_WHITE createsprite gBlendThinRingExpandingSpriteTemplate, ANIM_ATTACKER, 16, 0, 0, 0, 1 end HealBellRing: createvisualtask AnimTask_BlendBattleAnimPalExclude, 10, 4, 3, 8, 0, RGB(12, 24, 30) - createvisualtask AnimTask_BlendBattleAnimPal, 10, 10, 3, 2, 10, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATK_SIDE, 3, 2, 10, RGB_WHITE createsprite gThinRingExpandingSpriteTemplate, ANIM_ATTACKER, 40, 0, -24, 0, 1 playsewithpan SE_M_HEAL_BELL, SOUND_PAN_ATTACKER return @@ -21643,12 +21643,12 @@ Move_FAKE_OUT: createvisualtask AnimTask_ShakeMon2, 2, ANIM_TARGET, 4, 0, 5, 1 createvisualtask AnimTask_StretchTargetUp, 3 waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 16, 0, RGB_WHITE + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 16, 0, RGB_WHITE end Move_SCARY_FACE: loadspritegfx ANIM_TAG_EYE_SPARKLE - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 27, 3, 0, 16, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_ATK_SIDE | F_PAL_DEF_PARTNER, 3, 0, 16, RGB_BLACK playsewithpan SE_M_PSYBEAM, SOUND_PAN_ATTACKER waitforvisualfinish delay 10 @@ -21660,7 +21660,7 @@ Move_SCARY_FACE: waitforvisualfinish createvisualtask AnimTask_ShakeTargetInPattern, 3, 20, 1, FALSE playsewithpan SE_M_STRING_SHOT2, SOUND_PAN_TARGET - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 27, 3, 16, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_ATK_SIDE | F_PAL_DEF_PARTNER, 3, 16, 0, RGB_BLACK waitforvisualfinish end @@ -21804,7 +21804,7 @@ PresentHeal: Move_BATON_PASS: loadspritegfx ANIM_TAG_POKEBALL playsewithpan SE_M_BATON_PASS, SOUND_PAN_ATTACKER - createvisualtask AnimTask_BlendColorCycle, 2, 31, 1, 2, 0, 11, RGB(31, 22, 30) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_BG | F_PAL_BATTLERS, 1, 2, 0, 11, RGB(31, 22, 30) createsprite gBatonPassPokeballSpriteTemplate, ANIM_ATTACKER, 2 end @@ -21830,13 +21830,13 @@ Move_PERISH_SONG: delay 20 panse SE_M_PERISH_SONG, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0 delay 80 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 0, 16, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 0, 16, RGB_BLACK createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 4, 0 createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 5, 0 createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 6, 0 createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 7, 0 delay 100 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 16, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 16, 0, RGB_BLACK createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 4, 1 createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 5, 1 createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 6, 1 @@ -21911,7 +21911,7 @@ Move_TRI_ATTACK: delay 20 createsoundtask SoundTask_LoopSEAdjustPanning, SE_M_TRI_ATTACK, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, 5, 6, 0, 7 waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 0, 16, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 0, 16, RGB_BLACK delay 16 loadspritegfx ANIM_TAG_FIRE createsprite gLargeFlameScatterSpriteTemplate, ANIM_TARGET, 2, 0, 0, 30, 30, -1, 0 @@ -21947,7 +21947,7 @@ Move_TRI_ATTACK: waitforvisualfinish loadspritegfx ANIM_TAG_ICE_CRYSTALS call IceCrystalEffectShort - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 16, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 16, 0, RGB_BLACK waitforvisualfinish end @@ -22033,7 +22033,7 @@ Move_TRICK: Move_WISH: loadspritegfx ANIM_TAG_GOLD_STARS loadspritegfx ANIM_TAG_SPARKLE_2 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 0, 10, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 0, 10, RGB_BLACK waitforvisualfinish panse_adjustall SE_M_REFLECT, SOUND_PAN_TARGET, SOUND_PAN_ATTACKER, -3, 0 createsprite gWishStarSpriteTemplate, ANIM_ATTACKER, 40 @@ -22042,19 +22042,19 @@ Move_WISH: loopsewithpan SE_M_HEAL_BELL, SOUND_PAN_ATTACKER, 16, 3 call GrantingStarsEffect waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 10, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 10, 0, RGB_BLACK waitforvisualfinish end Move_STOCKPILE: loadspritegfx ANIM_TAG_GRAY_ORB playsewithpan SE_M_MEGA_KICK, SOUND_PAN_ATTACKER - createvisualtask AnimTask_BlendColorCycle, 2, 2, 8, 1, 0, 12, RGB_WHITE + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 8, 1, 0, 12, RGB_WHITE createvisualtask AnimTask_StockpileDeformMon, 5 call StockpileAbsorb call StockpileAbsorb waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 2, 0, 12, 0, RGB_WHITE + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_ATTACKER, 0, 12, 0, RGB_WHITE end StockpileAbsorb: createsprite gStockpileAbsorptionOrbSpriteTemplate, ANIM_ATTACKER, 2, 55, 55, 13 @@ -22172,7 +22172,7 @@ Move_MORNING_SUN: loadspritegfx ANIM_TAG_BLUE_STAR createvisualtask AnimTask_MorningSunLightBeam, 5 delay 8 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 0x781, 8, 0, 12, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG | F_PAL_BATTLERS_2, 8, 0, 12, RGB_WHITE delay 14 call MorningSunStar call MorningSunStar @@ -22189,7 +22189,7 @@ Move_MORNING_SUN: call MorningSunStar call MorningSunStar call MorningSunStar - createvisualtask AnimTask_BlendBattleAnimPal, 10, 0x781, 3, 12, 0, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG | F_PAL_BATTLERS_2, 3, 12, 0, RGB_WHITE waitforvisualfinish waitsound call HealingEffect @@ -22208,7 +22208,7 @@ Move_SWEET_SCENT: call SweetScentEffect createsprite gSweetScentPetalSpriteTemplate, ANIM_ATTACKER, 2, 55, 0 setpan SOUND_PAN_TARGET - createvisualtask AnimTask_BlendColorCycle, 2, 20, 1, 5, 5, 13, RGB(31, 21, 21) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_DEF_SIDE, 1, 5, 5, 13, RGB(31, 21, 21) call SweetScentEffect waitforvisualfinish end @@ -22239,7 +22239,7 @@ SweetScentEffect: Move_HYPER_BEAM: loadspritegfx ANIM_TAG_ORBS - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 4, 0, 16, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 4, 0, 16, RGB_BLACK waitforvisualfinish delay 10 playsewithpan SE_M_HYPER_BEAM, SOUND_PAN_ATTACKER @@ -22255,7 +22255,7 @@ Move_HYPER_BEAM: call HyperBeamOrbs call HyperBeamOrbs createvisualtask AnimTask_ShakeMon2, 2, ANIM_TARGET, 4, 0, 50, 1 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 0, 11, RGB(25, 25, 25) + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 0, 11, RGB(25, 25, 25) call HyperBeamOrbs call HyperBeamOrbs call HyperBeamOrbs @@ -22277,9 +22277,9 @@ Move_HYPER_BEAM: call HyperBeamOrbs call HyperBeamOrbs call HyperBeamOrbs - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 11, 0, RGB(25, 25, 25) + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 11, 0, RGB(25, 25, 25) waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 4, 16, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 4, 16, 0, RGB_BLACK end HyperBeamOrbs: createsprite gHyperBeamOrbSpriteTemplate, ANIM_TARGET, 2 @@ -22334,17 +22334,17 @@ CreateFlatterConfetti: Move_ROLE_PLAY: monbg ANIM_ATK_PARTNER - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 0, 16, RGB_WHITE - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 0, 10, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 0, 16, RGB_WHITE + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 0, 10, RGB_BLACK waitforvisualfinish playsewithpan SE_M_TRI_ATTACK, SOUND_PAN_ATTACKER waitplaysewithpan SE_M_DETECT, SOUND_PAN_ATTACKER, 30 createvisualtask AnimTask_RolePlaySilhouette, 2 waitforvisualfinish clearmonbg ANIM_ATK_PARTNER - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 16, 0, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 16, 0, RGB_WHITE delay 8 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 2, 10, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 2, 10, 0, RGB_BLACK end Move_REFRESH: @@ -22357,7 +22357,7 @@ Move_REFRESH: call GrantingStarsEffect waitforvisualfinish playsewithpan SE_SHINY, SOUND_PAN_ATTACKER - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 10, 0, RGB(12, 24, 30) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 10, 0, RGB(12, 24, 30) createsprite gThinRingExpandingSpriteTemplate, ANIM_ATTACKER, 3, 0, 0, 0, 0 end @@ -22369,13 +22369,13 @@ Move_BLAZE_KICK: setalpha 12, 8 playsewithpan SE_M_FLAME_WHEEL, SOUND_PAN_TARGET createsprite gSpinningHandOrFootSpriteTemplate, ANIM_TARGET, 3, 0, 0, 1, 30 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 0, 7, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 0, 7, RGB_WHITE delay 30 playsewithpan SE_M_FLAMETHROWER, SOUND_PAN_TARGET createsprite gBasicHitSplatSpriteTemplate, ANIM_TARGET, 2, 0, 0, ANIM_TARGET, 0 createvisualtask AnimTask_ShakeMon2, 2, ANIM_TARGET, 3, 0, 14, 1 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 4, 2, 0, 0, RGB_WHITE - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 1, RGB_BLACK, 8, RGB_BLACK, 0 + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_TARGET, 2, 0, 0, RGB_WHITE + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 1, RGB_BLACK, 8, RGB_BLACK, 0 call FireSpreadEffect waitforvisualfinish clearmonbg ANIM_TARGET @@ -22394,7 +22394,7 @@ Move_HYPER_VOICE: end HyperVoiceEffect: - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 3, 8, 0, RGB_YELLOW + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 3, 8, 0, RGB_YELLOW createvisualtask AnimTask_ScaleMonAndRestore, 5, -5, -5, 5, ANIM_ATTACKER, 0 createsprite gHyperVoiceRingSpriteTemplate, ANIM_ATTACKER, 0, 45, 0, 0, 0, 0, 0, 1 createvisualtask AnimTask_ShakeMon2, 2, ANIM_TARGET, 1, 0, 6, 1 @@ -22405,14 +22405,14 @@ HyperVoiceEffect: Move_SAND_TOMB: loadspritegfx ANIM_TAG_MUD_SAND - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 4, 2, 0, 7, RGB(19, 17, 0) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_TARGET, 2, 0, 7, RGB(19, 17, 0) createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 0, 2, 43, 1 playsewithpan SE_M_SAND_TOMB, SOUND_PAN_TARGET call SandTombSwirlingDirt call SandTombSwirlingDirt call SandTombSwirlingDirt delay 22 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 4, 2, 7, 0, RGB(19, 17, 0) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_TARGET, 2, 7, 0, RGB(19, 17, 0) waitforvisualfinish end @@ -22511,7 +22511,7 @@ Move_DRAGON_CLAW: loadspritegfx ANIM_TAG_SMALL_EMBER loadspritegfx ANIM_TAG_CLAW_SLASH playsewithpan SE_M_SACRED_FIRE2, SOUND_PAN_ATTACKER - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 4, 0, 8, RGB(31, 19, 0) + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 4, 0, 8, RGB(31, 19, 0) createvisualtask AnimTask_ShakeMon, 5, ANIM_ATTACKER, 0, 2, 15, 1 call DragonClawFireSpiral call DragonClawFireSpiral @@ -22548,7 +22548,7 @@ Move_DRAGON_CLAW: createsprite gFireSpinSpriteTemplate, ANIM_ATTACKER, 2, 0, 28, 512, 25, 16, 46, ANIM_ATTACKER delay 2 createsprite gFireSpinSpriteTemplate, ANIM_ATTACKER, 2, 0, 33, 464, 30, 15, -50, ANIM_ATTACKER - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 4, 8, 0, RGB(31, 19, 0) + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 4, 8, 0, RGB(31, 19, 0) waitforvisualfinish end DragonClawFireSpiral: @@ -22631,7 +22631,7 @@ Move_REVENGE: playsewithpan SE_M_TAKE_DOWN, SOUND_PAN_ATTACKER createsprite gRevengeSmallScratchSpriteTemplate, ANIM_ATTACKER, 2, 10, -10 waitforvisualfinish - createvisualtask AnimTask_BlendColorCycle, 2, 2, 0, 4, 2, 8, RGB_RED + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 0, 4, 2, 8, RGB_RED waitforvisualfinish unloadspritegfx ANIM_TAG_PURPLE_SCRATCH loadspritegfx ANIM_TAG_PURPLE_SWIPE @@ -22661,7 +22661,7 @@ Move_POISON_FANG: delay 10 createvisualtask AnimTask_ShakeMon, 3, ANIM_TARGET, 3, 0, 10, 1 waitforvisualfinish - createvisualtask AnimTask_BlendColorCycle, 2, 4, 0, 4, 0, 12, RGB(26, 0, 26) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_TARGET, 0, 4, 0, 12, RGB(26, 0, 26) call PoisonBubblesEffect waitforvisualfinish end @@ -22677,7 +22677,7 @@ Move_FRENZY_PLANT: monbg ANIM_TARGET splitbgprio ANIM_TARGET setalpha 12, 8 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 1, 2, 0, 5, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_BG, 2, 0, 5, RGB_BLACK waitforvisualfinish createsprite gFrenzyPlantRootSpriteTemplate, ANIM_ATTACKER, 2, 10, 8, 2, 0, 0, 100 playsewithpan SE_M_SCRATCH, SOUND_PAN_ATTACKER @@ -22725,7 +22725,7 @@ Move_FRENZY_PLANT: createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 2, 0, 10, ANIM_TARGET, 1 playsewithpan SE_M_DOUBLE_SLAP, SOUND_PAN_TARGET waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 1, 2, 5, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_BG, 2, 5, 0, RGB_BLACK waitforvisualfinish clearmonbg ANIM_TARGET blendoff @@ -22867,7 +22867,7 @@ ReturnStrong: createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 6, 0, 8, 1 goto ReturnContinue ReturnStrongest: - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 0, 0, 6, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 0, 0, 6, RGB_BLACK waitforvisualfinish createsprite gVerticalDipSpriteTemplate, ANIM_ATTACKER, 2, 16, 1, ANIM_ATTACKER createvisualtask SoundTask_PlaySE2WithPanning, 5, SE_M_TAIL_WHIP, SOUND_PAN_ATTACKER @@ -22924,7 +22924,7 @@ ReturnStrongest: createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 2, -5, 3, ANIM_TARGET, 0 createvisualtask SoundTask_PlaySE1WithPanning, 5, SE_M_MEGA_KICK2, SOUND_PAN_TARGET waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 0, 6, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 0, 6, 0, RGB_BLACK goto ReturnContinue ReturnStrongestHit: createsprite gVerticalDipSpriteTemplate, ANIM_ATTACKER, 2, 4, 3, ANIM_ATTACKER @@ -23176,7 +23176,7 @@ Move_OVERHEAT: loadspritegfx ANIM_TAG_IMPACT monbg ANIM_DEF_PARTNER setalpha 12, 18 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 5, RGB(28, 0, 0) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 0, 5, RGB(28, 0, 0) waitforvisualfinish createvisualtask AnimTask_AllocBackupPalBuffer, 5 waitforvisualfinish @@ -23187,7 +23187,7 @@ Move_OVERHEAT: playsewithpan SE_M_DRAGON_RAGE, SOUND_PAN_ATTACKER createvisualtask AnimTask_CopyPalUnfadedToBackup, 5, 1, 0 delay 1 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 2, 1, 0, 13, RGB(28, 0, 0) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_ATTACKER, 1, 0, 13, RGB(28, 0, 0) createvisualtask AnimTask_ShakeMon, 5, ANIM_ATTACKER, 2, 0, 15, 1 waitforvisualfinish playsewithpan SE_M_FLAME_WHEEL2, SOUND_PAN_ATTACKER @@ -23233,12 +23233,12 @@ Move_OVERHEAT: playsewithpan SE_M_FLAMETHROWER, SOUND_PAN_TARGET createvisualtask AnimTask_CopyPalFadedToUnfaded, 5, 1 delay 1 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 2, -1, 0, 13, RGB(18, 18, 18) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_ATTACKER, -1, 0, 13, RGB(18, 18, 18) createvisualtask AnimTask_ShakeMon, 5, ANIM_ATTACKER, 3, 0, 15, 1 waitforvisualfinish createvisualtask AnimTask_CopyPalUnfadedFromBackup, 5, 0, 1 delay 1 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 5, 0, RGB(28, 0, 0) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 5, 0, RGB(28, 0, 0) waitforvisualfinish clearmonbg ANIM_DEF_PARTNER blendoff @@ -23246,7 +23246,7 @@ Move_OVERHEAT: delay 15 createvisualtask AnimTask_CopyPalUnfadedFromBackup, 5, 1, 0 delay 1 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 2, 0, 13, 0, RGB(18, 18, 18) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_ATTACKER, 0, 13, 0, RGB(18, 18, 18) waitforvisualfinish createvisualtask AnimTask_FreeBackupPalBuffer, 5 waitforvisualfinish @@ -23390,7 +23390,7 @@ Move_WATER_PULSE: monbg ANIM_TARGET splitbgprio ANIM_TARGET playsewithpan SE_M_BUBBLE3, SOUND_PAN_ATTACKER - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 0, 0, 7, RGB(0, 25, 28) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 0, 0, 7, RGB(0, 25, 28) delay 10 createsprite gWaterPulseBubbleSpriteTemplate, ANIM_ATTACKER, 66, 100, 100, 8, 1, 20, 40, 0 createsprite gWaterPulseBubbleSpriteTemplate, ANIM_ATTACKER, 66, 20, 100, 16, 2, 10, 35, 1 @@ -23410,7 +23410,7 @@ Move_WATER_PULSE: delay 13 createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 0, 8, 18, 1 waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 7, 0, RGB(0, 25, 28) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 7, 0, RGB(0, 25, 28) waitforvisualfinish clearmonbg ANIM_DEF_PARTNER end @@ -23423,7 +23423,7 @@ Move_PSYCHO_BOOST: createvisualtask AnimTask_FadeScreenToWhite, 5 waitbgfadein delay 6 - createvisualtask AnimTask_BlendColorCycle, 2, 1, 2, 8, 0, 10, RGB_BLACK + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_BG, 2, 8, 0, 10, RGB_BLACK delay 0 splitbgprio ANIM_ATTACKER setalpha 8, 8 @@ -23450,7 +23450,7 @@ Move_KNOCK_OFF: playsewithpan SE_M_VITAL_THROW, SOUND_PAN_TARGET createsprite gKnockOffStrikeSpriteTemplate, ANIM_TARGET, 2, -16, -16 delay 8 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 5, 1, RGB_WHITE, 10, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 5, 1, RGB_WHITE, 10, RGB_BLACK, 0 createsprite gBasicHitSplatSpriteTemplate, ANIM_TARGET, 3, 0, 0, ANIM_TARGET, 2 playsewithpan SE_M_COMET_PUNCH, SOUND_PAN_TARGET createsprite gSlideMonToOffsetSpriteTemplate, ANIM_ATTACKER, 2, 1, -12, 10, 0, 3 @@ -23468,7 +23468,7 @@ Move_DOOM_DESIRE: delay 1 monbg ANIM_ATK_PARTNER createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_TARGET, FALSE - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 4, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 0, 4, RGB_BLACK waitforvisualfinish setalpha 8, 8 playsewithpan SE_M_PSYBEAM, SOUND_PAN_ATTACKER @@ -23476,7 +23476,7 @@ Move_DOOM_DESIRE: waitforvisualfinish delay 20 createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_TARGET, TRUE - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 4, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 4, 0, RGB_BLACK waitforvisualfinish clearmonbg ANIM_ATK_PARTNER blendoff @@ -23761,7 +23761,7 @@ Move_WEATHER_BALL: waitforvisualfinish delay 15 playsewithpan SE_M_DETECT, 0 - createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 31, 5, 1, RGB_WHITE, 10, RGB_BLACK, 0 + createsprite gComplexPaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG | F_PAL_BATTLERS, 5, 1, RGB_WHITE, 10, RGB_BLACK, 0 waitforvisualfinish createvisualtask AnimTask_GetWeather, 2 delay 1 @@ -24144,7 +24144,7 @@ UnsetSolarBeamBg: Status_Poison: loopsewithpan SE_M_TOXIC, SOUND_PAN_TARGET, 13, 6 createvisualtask AnimTask_ShakeMon2, 2, ANIM_ATTACKER, 1, 0, 18, 2 - createvisualtask AnimTask_BlendColorCycle, 2, 2, 2, 2, 0, 12, RGB(30, 0, 31) + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 2, 2, 0, 12, RGB(30, 0, 31) end Status_Confusion: @@ -24249,13 +24249,13 @@ General_StatsChange: General_SubstituteFade: monbg ANIM_ATTACKER createvisualtask AnimTask_SubstituteFadeToInvisible, 5 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 0, 0, 16, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 0, 0, 16, RGB_WHITE waitforvisualfinish delay 1 clearmonbg ANIM_ATTACKER delay 2 blendoff - createvisualtask AnimTask_BlendBattleAnimPal, 10, 2, 0, 0, 0, RGB_WHITE + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_ATTACKER, 0, 0, 0, RGB_WHITE createvisualtask AnimTask_SwapMonSpriteToFromSubstitute, 2, TRUE end @@ -24347,13 +24347,13 @@ Status_Whirlpool: splitbgprio ANIM_TARGET setalpha 12, 8 delay 0 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 4, 2, 0, 7, RGB(0, 13, 23) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_TARGET, 2, 0, 7, RGB(0, 13, 23) playsewithpan SE_M_WHIRLPOOL, SOUND_PAN_TARGET createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 0, 2, 30, 1 call WhirlpoolEffect call WhirlpoolEffect delay 12 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 4, 2, 7, 0, RGB(0, 13, 23) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_TARGET, 2, 7, 0, RGB(0, 13, 23) waitforvisualfinish stopsound clearmonbg ANIM_DEF_PARTNER @@ -24381,13 +24381,13 @@ Status_Snap_Trap: @ placeholder Status_SandTomb: loadspritegfx ANIM_TAG_MUD_SAND - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 4, 2, 0, 7, RGB(19, 17, 0) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_TARGET, 2, 0, 7, RGB(19, 17, 0) createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 0, 2, 30, 1 playsewithpan SE_M_SAND_TOMB, SOUND_PAN_TARGET call SandTombSwirlingDirt call SandTombSwirlingDirt delay 22 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 4, 2, 7, 0, RGB(19, 17, 0) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_TARGET, 2, 7, 0, RGB(19, 17, 0) waitforvisualfinish stopsound end @@ -24425,7 +24425,7 @@ General_HeldItemEffect: call GrantingStarsEffect waitforvisualfinish playsewithpan SE_SHINY, SOUND_PAN_ATTACKER - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 2, 3, 7, 0, RGB(17, 31, 25) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_ATTACKER, 3, 7, 0, RGB(17, 31, 25) createsprite gThinRingExpandingSpriteTemplate, ANIM_ATTACKER, 3, 0, 0, 0, 0 waitforvisualfinish end @@ -24469,11 +24469,11 @@ General_SmokeballEscape: end General_HangedOn: - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 2, 7, 0, 9, RGB_RED + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_ATTACKER, 7, 0, 9, RGB_RED playsewithpan SE_M_DRAGON_RAGE, SOUND_PAN_ATTACKER createvisualtask AnimTask_SlideMonForFocusBand, 5, 30, 128, 0, 1, 2, 0, 1 waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, 2, 4, 9, 0, RGB_RED + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 0, F_PAL_ATTACKER, 4, 9, 0, RGB_RED waitforvisualfinish delay 6 createsprite gSlideMonToOriginalPosSpriteTemplate, ANIM_ATTACKER, 0, 0, 0, 15 @@ -24482,13 +24482,13 @@ General_HangedOn: General_Rain: loadspritegfx ANIM_TAG_RAIN_DROPS playsewithpan SE_M_RAIN_DANCE, SOUND_PAN_ATTACKER - createvisualtask AnimTask_BlendBattleAnimPal, 10, 0x781, 2, 0, 4, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG | F_PAL_BATTLERS_2, 2, 0, 4, RGB_BLACK waitforvisualfinish createvisualtask AnimTask_CreateRaindrops, 2, 0, 3, 60 createvisualtask AnimTask_CreateRaindrops, 2, 0, 3, 60 delay 50 waitforvisualfinish - createvisualtask AnimTask_BlendBattleAnimPal, 10, 0x781, 2, 4, 0, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG | F_PAL_BATTLERS_2, 2, 4, 0, RGB_BLACK waitforvisualfinish end @@ -24572,7 +24572,7 @@ General_FutureSightHit: General_DoomDesireHit: createvisualtask AnimTask_SetAnimTargetToBattlerTarget, 2 loadspritegfx ANIM_TAG_EXPLOSION - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 0, 16, RGB_WHITE + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 0, 16, RGB_WHITE waitforvisualfinish delay 10 createvisualtask AnimTask_DoomDesireLightBeam, 5 @@ -24599,7 +24599,7 @@ General_DoomDesireHit: playsewithpan SE_M_SELF_DESTRUCT, SOUND_PAN_TARGET createsprite gExplosionSpriteTemplate, ANIM_ATTACKER, 3, 16, 16, 1, 1 waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 16, 0, RGB_WHITE + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 16, 0, RGB_WHITE waitforvisualfinish end @@ -24608,7 +24608,7 @@ General_FocusPunchSetUp: playsewithpan SE_M_DRAGON_RAGE, SOUND_PAN_ATTACKER call EndureEffect delay 8 - createvisualtask AnimTask_BlendColorCycle, 2, 2, 2, 2, 0, 11, RGB_RED + createvisualtask AnimTask_BlendColorCycle, 2, F_PAL_ATTACKER, 2, 2, 0, 11, RGB_RED createvisualtask AnimTask_ShakeMon2, 2, ANIM_ATTACKER, 1, 0, 32, 1 call EndureEffect delay 8 @@ -24621,7 +24621,7 @@ General_IngrainHeal: loadspritegfx ANIM_TAG_BLUE_STAR monbg ANIM_DEF_PARTNER setalpha 12, 8 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 4, RGB(13, 31, 12) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 0, 4, RGB(13, 31, 12) waitforvisualfinish delay 3 call AbsorbEffect @@ -24629,7 +24629,7 @@ General_IngrainHeal: delay 15 call HealingEffect waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 4, 0, RGB(13, 31, 12) + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 1, 4, 0, RGB(13, 31, 12) waitforvisualfinish clearmonbg ANIM_DEF_PARTNER blendoff @@ -24637,7 +24637,7 @@ General_IngrainHeal: General_WishHeal: loadspritegfx ANIM_TAG_SPARKLE_2 - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 0, 10, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 0, 10, RGB_BLACK waitforvisualfinish playsewithpan SE_M_MEGA_KICK, SOUND_PAN_ATTACKER call GrantingStarsEffect @@ -24646,7 +24646,7 @@ General_WishHeal: loadspritegfx ANIM_TAG_BLUE_STAR call HealingEffect waitforvisualfinish - createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 10, 0, RGB_BLACK + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 10, 0, RGB_BLACK end General_IllusionOff: diff --git a/data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc b/data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc index 406ab46ae..def903b1d 100644 --- a/data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc +++ b/data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc @@ -5,6 +5,10 @@ .set LOCALID_PLAYER, 13 .set LOCALID_OPPONENT, 15 +.set NO_DRAW, 0 +.set DRAW_TRAINER, 1 +.set DRAW_TUCKER, 2 + BattleFrontier_BattleDomeBattleRoom_MapScripts:: map_script MAP_SCRIPT_ON_TRANSITION, BattleFrontier_BattleDomeBattleRoom_OnTransition map_script MAP_SCRIPT_ON_FRAME_TABLE, BattleFrontier_BattleDomeBattleRoom_OnFrame @@ -12,10 +16,6 @@ BattleFrontier_BattleDomeBattleRoom_MapScripts:: map_script MAP_SCRIPT_ON_RESUME, BattleFrontier_BattleDomeBattleRoom_OnResume .byte 0 - .set NO_DRAW, 0 - .set DRAW_TRAINER, 1 - .set DRAW_TUCKER, 2 - BattleFrontier_BattleDomeBattleRoom_OnTransition: dome_setopponentgfx frontier_get FRONTIER_DATA_BATTLE_NUM diff --git a/data/maps/BattleFrontier_BattlePikeLobby/scripts.inc b/data/maps/BattleFrontier_BattlePikeLobby/scripts.inc index 320e12d99..3e729e212 100644 --- a/data/maps/BattleFrontier_BattlePikeLobby/scripts.inc +++ b/data/maps/BattleFrontier_BattlePikeLobby/scripts.inc @@ -364,7 +364,8 @@ BattleFrontier_BattlePikeLobby_Text_AwardYouTheseBattlePoints2: @ Unused BattleFrontier_BattlePikeLobby_Text_ReachedBattlePointLimit: .string "You appear to have reached the limit\n" - .string "for Battle Points…\pPlease exchange some Battle Points\n" + .string "for Battle Points…\p" + .string "Please exchange some Battle Points\n" .string "for prizes, then return…$" BattleFrontier_BattlePikeLobby_Text_FailedToSaveBeforeQuitting: diff --git a/data/maps/BattleFrontier_Lounge2/scripts.inc b/data/maps/BattleFrontier_Lounge2/scripts.inc index 8efc17293..12eda4a5e 100644 --- a/data/maps/BattleFrontier_Lounge2/scripts.inc +++ b/data/maps/BattleFrontier_Lounge2/scripts.inc @@ -22,18 +22,20 @@ BattleFrontier_Lounge2_EventScript_AlreadyMetManiac:: end BattleFrontier_Lounge2_EventScript_GiveAdvice:: - call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 0, BattleFrontier_Lounge2_EventScript_BufferSingle - call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 1, BattleFrontier_Lounge2_EventScript_BufferDouble - call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 2, BattleFrontier_Lounge2_EventScript_BufferMulti - call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 3, BattleFrontier_Lounge2_EventScript_BufferMultiLink - call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 4, BattleFrontier_Lounge2_EventScript_BufferBattleDome - call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 5, BattleFrontier_Lounge2_EventScript_BufferBattleFactory - call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 6, BattleFrontier_Lounge2_EventScript_BufferBattlePalace - call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 7, BattleFrontier_Lounge2_EventScript_BufferBattleArena - call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 8, BattleFrontier_Lounge2_EventScript_BufferBattlePike - call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 9, BattleFrontier_Lounge2_EventScript_BufferBattlePyramid - call_if_le VAR_FRONTIER_MANIAC_FACILITY, 3, BattleFrontier_Lounge2_EventScript_BattleTowerNews - call_if_ge VAR_FRONTIER_MANIAC_FACILITY, 4, BattleFrontier_Lounge2_EventScript_FacilityNews + call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_TOWER_SINGLES, BattleFrontier_Lounge2_EventScript_BufferSingle + call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_TOWER_DOUBLES, BattleFrontier_Lounge2_EventScript_BufferDouble + call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_TOWER_MULTIS, BattleFrontier_Lounge2_EventScript_BufferMulti + call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_TOWER_LINK, BattleFrontier_Lounge2_EventScript_BufferMultiLink + call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_DOME, BattleFrontier_Lounge2_EventScript_BufferBattleDome + call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_FACTORY, BattleFrontier_Lounge2_EventScript_BufferBattleFactory + call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_PALACE, BattleFrontier_Lounge2_EventScript_BufferBattlePalace + call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_ARENA, BattleFrontier_Lounge2_EventScript_BufferBattleArena + call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_PIKE, BattleFrontier_Lounge2_EventScript_BufferBattlePike + call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_PYRAMID, BattleFrontier_Lounge2_EventScript_BufferBattlePyramid +@ <= FRONTIER_MANIAC_TOWER_LINK is any Battle Tower mode + call_if_le VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_TOWER_LINK, BattleFrontier_Lounge2_EventScript_BattleTowerNews +@ >= FRONTIER_MANIAC_DOME is any facility other than Battle Tower + call_if_ge VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_DOME, BattleFrontier_Lounge2_EventScript_FacilityNews special ShowFrontierManiacMessage waitmessage waitbuttonpress diff --git a/data/scripts/gift_altering_cave.inc b/data/scripts/gift_altering_cave.inc index 65ff87068..0ea69aac0 100644 --- a/data/scripts/gift_altering_cave.inc +++ b/data/scripts/gift_altering_cave.inc @@ -12,7 +12,7 @@ MysteryGiftScript_AlteringCave_: release end -sText_MysteryGiftAlteringCave:: +sText_MysteryGiftAlteringCave: .string "Thank you for using the MYSTERY\n" .string "GIFT System.\p" .string "There appears to be a rumor about\n" diff --git a/data/text/contest_strings.inc b/data/text/contest_strings.inc index e57e76a52..948c19922 100644 --- a/data/text/contest_strings.inc +++ b/data/text/contest_strings.inc @@ -4,145 +4,192 @@ gText_HighlyAppealingMove:: .string "A highly appealing move.$" gText_UserMoreEasilyStartled:: - .string "After this move, the user is\nmore easily startled.$" + .string "After this move, the user is\n" + .string "more easily startled.$" gText_GreatAppealButNoMoreToEnd:: - .string "Makes a great appeal, but\nallows no more to the end.$" + .string "Makes a great appeal, but\n" + .string "allows no more to the end.$" gText_UsedRepeatedlyWithoutBoringJudge:: - .string "Can be repeatedly used\nwithout boring the JUDGE.$" + .string "Can be repeatedly used\n" + .string "without boring the JUDGE.$" gText_AvoidStartledByOthersOnce:: - .string "Can avoid being startled\nby others once.$" + .string "Can avoid being startled\n" + .string "by others once.$" gText_AvoidStartledByOthers:: - .string "Can avoid being startled\nby others.$" + .string "Can avoid being startled\n" + .string "by others.$" gText_AvoidStartledByOthersLittle:: - .string "Can avoid being startled\nby others a little.$" + .string "Can avoid being startled\n" + .string "by others a little.$" gText_UserLessLikelyStartled:: - .string "After this move, the user is\nless likely to be startled.$" + .string "After this move, the user is\n" + .string "less likely to be startled.$" gText_SlightlyStartleFrontMon:: - .string "Slightly startles the\nPOKéMON in front.$" + .string "Slightly startles the\n" + .string "POKéMON in front.$" gText_SlightlyStartleAppealed:: - .string "Slightly startles those\nthat have made appeals.$" + .string "Slightly startles those\n" + .string "that have made appeals.$" gText_StartleAppealedBeforeUser:: - .string "Startles the POKéMON that\nappealed before the user.$" + .string "Startles the POKéMON that\n" + .string "appealed before the user.$" gText_StartleAllAppealed:: - .string "Startles all POKéMON that\nhave done their appeals.$" + .string "Startles all POKéMON that\n" + .string "have done their appeals.$" gText_BadlyStartleFrontMon:: - .string "Badly startles the\nPOKéMON in front.$" + .string "Badly startles the\n" + .string "POKéMON in front.$" gText_BadlyStartleAppealed:: - .string "Badly startles those that\nhave made appeals.$" + .string "Badly startles those that\n" + .string "have made appeals.$" gText_StartleAppealedBeforeUser2:: - .string "Startles the POKéMON that\nappealed before the user.$" + .string "Startles the POKéMON that\n" + .string "appealed before the user.$" gText_StartleAllAppealed2:: - .string "Startles all POKéMON that\nhave done their appeals.$" + .string "Startles all POKéMON that\n" + .string "have done their appeals.$" gText_ShiftJudgesAttentionFromOthers:: - .string "Shifts the JUDGE's\nattention from others.$" + .string "Shifts the JUDGE's\n" + .string "attention from others.$" gText_StartleMonHasJudgesAttention:: - .string "Startles the POKéMON that\nhas the JUDGE's attention.$" + .string "Startles the POKéMON that\n" + .string "has the JUDGE's attention.$" gText_JamOthersMissesTurn:: - .string "Jams the others, and misses\none turn of appeals.$" + .string "Jams the others, and misses\n" + .string "one turn of appeals.$" gText_StartleMonsMadeSameTypeAppeal:: - .string "Startles POKéMON that\nmade a same-type appeal.$" + .string "Startles POKéMON that\n" + .string "made a same-type appeal.$" gText_BadlyStartleCoolAppeals:: - .string "Badly startles POKéMON\nthat made COOL appeals.$" + .string "Badly startles POKéMON\n" + .string "that made COOL appeals.$" gText_BadlyStartleBeautyAppeals:: - .string "Badly startles POKéMON\nthat made BEAUTY appeals.$" + .string "Badly startles POKéMON\n" + .string "that made BEAUTY appeals.$" gText_BadlyStartleCuteAppeals:: - .string "Badly startles POKéMON\nthat made CUTE appeals.$" + .string "Badly startles POKéMON\n" + .string "that made CUTE appeals.$" gText_BadlyStartleSmartAppeals:: - .string "Badly startles POKéMON\nthat made SMART appeals.$" + .string "Badly startles POKéMON\n" + .string "that made SMART appeals.$" gText_BadlyStartleToughAppeals:: - .string "Badly startles POKéMON\nthat made TOUGH appeals.$" + .string "Badly startles POKéMON\n" + .string "that made TOUGH appeals.$" gText_MakeMonAfterUserNervous:: - .string "Makes one POKéMON after\nthe user nervous.$" + .string "Makes one POKéMON after\n" + .string "the user nervous.$" gText_MakeAllMonsAfterUserNervous:: - .string "Makes all POKéMON after\nthe user nervous.$" + .string "Makes all POKéMON after\n" + .string "the user nervous.$" gText_WorsenConditionOfThoseMadeAppeals:: - .string "Worsens the condition of\nthose that made appeals.$" + .string "Worsens the condition of\n" + .string "those that made appeals.$" gText_BadlyStartleMonsGoodCondition:: - .string "Badly startles POKéMON in\ngood condition.$" + .string "Badly startles POKéMON in\n" + .string "good condition.$" gText_AppealGreatIfPerformedFirst:: - .string "The appeal works great if\nperformed first.$" + .string "The appeal works great if\n" + .string "performed first.$" gText_AppealGreatIfPerformedLast:: - .string "The appeal works great if\nperformed last.$" + .string "The appeal works great if\n" + .string "performed last.$" gText_AppealAsGoodAsThoseBeforeIt:: - .string "Makes the appeal as good\nas those before it.$" + .string "Makes the appeal as good\n" + .string "as those before it.$" gText_AppealAsGoodAsOneBeforeIt:: - .string "Makes the appeal as good\nas the one before it.$" + .string "Makes the appeal as good\n" + .string "as the one before it.$" gText_AppealBetterLaterItsPerformed:: - .string "The appeal works better\nthe later it is performed.$" + .string "The appeal works better\n" + .string "the later it is performed.$" gText_AppealVariesDependingOnTiming:: - .string "The appeal's quality varies\ndepending on its timing.$" + .string "The appeal's quality varies\n" + .string "depending on its timing.$" gText_WorksWellIfSameTypeAsBefore:: - .string "Works well if it's the same\ntype as the one before.$" + .string "Works well if it's the same\n" + .string "type as the one before.$" gText_WorksWellIfDifferentTypeAsBefore:: - .string "Works well if different in\ntype than the one before.$" + .string "Works well if different in\n" + .string "type than the one before.$" gText_AffectedByAppealInFront:: - .string "Affected by how well the\nappeal in front goes.$" + .string "Affected by how well the\n" + .string "appeal in front goes.$" gText_UpsConditionHelpsPreventNervousness:: - .string "Ups the user's condition.\nHelps prevent nervousness.$" + .string "Ups the user's condition.\n" + .string "Helps prevent nervousness.$" gText_AppealWorksWellIfConditionGood:: - .string "The appeal works well if the\nuser's condition is good.$" + .string "The appeal works well if the\n" + .string "user's condition is good.$" gText_NextAppealMadeEarlier:: - .string "The next appeal can be\nmade earlier next turn.$" + .string "The next appeal can be\n" + .string "made earlier next turn.$" gText_NextAppealMadeLater:: - .string "The next appeal can be\nmade later next turn.$" + .string "The next appeal can be\n" + .string "made later next turn.$" gText_TurnOrderMoreEasilyScrambled:: - .string "Makes the next turn's order\nmore easily scrambled.$" + .string "Makes the next turn's order\n" + .string "more easily scrambled.$" gText_ScrambleOrderOfNextAppeals:: - .string "Scrambles the order of\nappeals on the next turn.$" + .string "Scrambles the order of\n" + .string "appeals on the next turn.$" gText_AppealExcitesAudienceInAnyContest:: - .string "An appeal that excites the\naudience in any CONTEST.$" + .string "An appeal that excites the\n" + .string "audience in any CONTEST.$" gText_BadlyStartlesMonsGoodAppeals:: - .string "Badly startles all POKéMON\nthat made good appeals.$" + .string "Badly startles all POKéMON\n" + .string "that made good appeals.$" gText_AppealBestMoreCrowdExcited:: - .string "The appeal works best the\nmore the crowd is excited.$" + .string "The appeal works best the\n" + .string "more the crowd is excited.$" gText_TemporarilyStopCrowdExcited:: - .string "Temporarily stops the\ncrowd from growing excited.$" + .string "Temporarily stops the\n" + .string "crowd from growing excited.$" @ Unused move names diff --git a/data/text/pc_transfer.inc b/data/text/pc_transfer.inc index 53a82c8f1..3fa255340 100644 --- a/data/text/pc_transfer.inc +++ b/data/text/pc_transfer.inc @@ -5,7 +5,8 @@ gText_PkmnTransferredSomeonesPC:: .string "BOX “{STR_VAR_1}.”$" gText_PkmnTransferredLanettesPC:: - .string "{STR_VAR_2} was transferred to\nLANETTE'S PC.\p" + .string "{STR_VAR_2} was transferred to\n" + .string "LANETTE'S PC.\p" .string "It was placed in \n" .string "BOX “{STR_VAR_1}.”$" diff --git a/data/text/pokedex_rating.inc b/data/text/pokedex_rating.inc index fcb26bc7d..175aaccc6 100644 --- a/data/text/pokedex_rating.inc +++ b/data/text/pokedex_rating.inc @@ -3,7 +3,7 @@ gBirchDexRatingText_AreYouCurious:: .string "Are you curious about how your\n" .string "POKéDEX is coming along?$" -gBirchDexRatingText_Cancel: +gBirchDexRatingText_Cancel:: .string "Hm? Oh, you haven't caught enough\n" .string "POKéMON to make it worthwhile.$" diff --git a/data/text/surf.inc b/data/text/surf.inc index 453a3d5b1..13854f7aa 100644 --- a/data/text/surf.inc +++ b/data/text/surf.inc @@ -1,5 +1,6 @@ gText_WantToUseSurf:: - .string "The water is dyed a deep blue…\nWould you like to SURF?$" + .string "The water is dyed a deep blue…\n" + .string "Would you like to SURF?$" gText_PlayerUsedSurf:: .string "{STR_VAR_1} used SURF!$" diff --git a/data/text/tv.inc b/data/text/tv.inc index 68b842158..6cfc289d2 100644 --- a/data/text/tv.inc +++ b/data/text/tv.inc @@ -166,7 +166,7 @@ BattleFrontier_BattleTowerLobby_Text_LookingForwardToNextBattle:: .string "I'll be looking forward to your\n" .string "next battle!$" -gTVBravoTrainerBattleTowerText00:: +BravoTrainerBattleTower_Text_Intro:: .string "Yeah!\n" .string "It's BRAVO TRAINER time!\p" .string "Today, we're going to profile {STR_VAR_1},\n" @@ -174,12 +174,12 @@ gTVBravoTrainerBattleTowerText00:: .string "For the challenge, {STR_VAR_1} entered\n" .string "one wicked {STR_VAR_2}.$" -gTVBravoTrainerBattleTowerText01:: +BravoTrainerBattleTower_Text_NewRecord:: .string "The pair set a new record of {STR_VAR_2} wins\n" .string "in a row in {STR_VAR_1} competition!\l" .string "Bravo, TRAINER!$" -gTVBravoTrainerBattleTowerText02:: +BravoTrainerBattleTower_Text_Lost:: .string "The twosome finally succumbed to\n" .string "{STR_VAR_1} in match number {STR_VAR_2}.\l" .string "Nice try, TRAINER!\p" @@ -188,7 +188,7 @@ gTVBravoTrainerBattleTowerText02:: .string "We asked the TRAINER for impressions\n" .string "on the match with {STR_VAR_1}.$" -gTVBravoTrainerBattleTowerText03:: +BravoTrainerBattleTower_Text_Won:: .string "The twosome won it all by defeating\n" .string "{STR_VAR_1}'s {STR_VAR_2} thoroughly.\l" .string "Bravo, TRAINER!\p" @@ -197,7 +197,7 @@ gTVBravoTrainerBattleTowerText03:: .string "We asked the TRAINER for impressions\n" .string "on the moment of glory.$" -gTVBravoTrainerBattleTowerText04:: +BravoTrainerBattleTower_Text_LostFinal:: .string "After a string of wins, the pair finally\n" .string "succumbed to {STR_VAR_1}'s {STR_VAR_2},\l" .string "their final hurdle.\p" @@ -208,7 +208,7 @@ gTVBravoTrainerBattleTowerText04:: .string "We asked the TRAINER for impressions\n" .string "on battling the celebrity pair.$" -gTVBravoTrainerBattleTowerText05:: +BravoTrainerBattleTower_Text_Satisfied:: .string "This is what the TRAINER had to say:\n" .string "“I'm satisfied!”\p" .string "Now isn't that a refreshing reply?\n" @@ -218,7 +218,7 @@ gTVBravoTrainerBattleTowerText05:: .string "I found out exactly how satisfied\n" .string "when I heard the TRAINER say this:$" -gTVBravoTrainerBattleTowerText06:: +BravoTrainerBattleTower_Text_Unsatisfied:: .string "This is what the TRAINER had to say:\n" .string "“I'm not satisfied…”\p" .string "Our TRAINER was obviously a little down\n" @@ -228,22 +228,22 @@ gTVBravoTrainerBattleTowerText06:: .string "Anyway, I found out how dissatisfied\n" .string "our TRAINER was when I heard this:$" -gTVBravoTrainerBattleTowerText07:: +BravoTrainerBattleTower_Text_None1:: .string "None$" -gTVBravoTrainerBattleTowerText08:: +BravoTrainerBattleTower_Text_None2:: .string "None$" -gTVBravoTrainerBattleTowerText09:: +BravoTrainerBattleTower_Text_None3:: .string "None$" -gTVBravoTrainerBattleTowerText10:: +BravoTrainerBattleTower_Text_None4:: .string "None$" -gTVBravoTrainerBattleTowerText11:: +BravoTrainerBattleTower_Text_Response:: .string "“{STR_VAR_1}.”$" -gTVBravoTrainerBattleTowerText12:: +BravoTrainerBattleTower_Text_ResponseSatisfied:: .string "“{STR_VAR_1}.”\n" .string "Now isn't that great?\p" .string "It really expresses {STR_VAR_2}'s joy,\n" @@ -252,7 +252,7 @@ gTVBravoTrainerBattleTowerText12:: .string "end… It really was what you'd call\l" .string "“{STR_VAR_1}”!$" -gTVBravoTrainerBattleTowerText13:: +BravoTrainerBattleTower_Text_ResponseUnsatisfied:: .string "“{STR_VAR_1}.”\n" .string "Now isn't that fitting?\p" .string "That battle with {STR_VAR_3} at the\n" @@ -261,7 +261,7 @@ gTVBravoTrainerBattleTowerText13:: .string "{STR_VAR_2}'s disappointment comes across\n" .string "loud and clear, I'd say!$" -gTVBravoTrainerBattleTowerText14:: +BravoTrainerBattleTower_Text_Outro:: .string "Bravo, {STR_VAR_1}!\n" .string "Bravo, {STR_VAR_2}!\p" .string "I hope we can count on seeing\n" diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md deleted file mode 100644 index ce06c1489..000000000 --- a/docs/bugs_and_glitches.md +++ /dev/null @@ -1,51 +0,0 @@ - -# Bugs and Glitches - -These are known bugs and glitches in the original Pokémon Emerald game: code that clearly does not work as intended, or that only works in limited circumstances but has the possibility to fail or crash. Defining the `BUGFIX` and `UBFIX` preprocessor variables will fix some of these automatically. `UBFIX` will already be defined for MODERN builds. - -Fixes are written in the `diff` format. If you've used Git before, this should look familiar: - -```diff - this is some code --delete red - lines -+add green + lines -``` - -## Contents - -- [Scrolling through items in the bag causes the image to flicker](#scrolling-through-items-in-the-bag-causes-the-image-to-flicker) - - -## Scrolling through items in the bag causes the image to flicker - -**Fix:** Add the following function to [src/item_menu_icons.c](https://github.com/pret/pokeemerald/blob/master/src/item_menu_icons.c): -```diff -+void HideBagItemIconSprite(u8 id) -+{ -+ u8 *spriteId = &gBagMenu->spriteId[10]; -+ if (spriteId[id] != 0xFF) -+ { -+ gSprites[spriteId[id]].invisible = TRUE; -+ } -+} - -``` - -and its corresponding declaration in [include/item_menu_icons.h](https://github.com/pret/pokeemerald/blob/master/include/item_menu_icons.h): - -```diff -+void HideBagItemIconSprite(u8 id); - -``` - -Then edit `BagMenu_MoveCursorCallback` in [src/item_menu.c](https://github.com/pret/pokeemerald/blob/master/src/item_menu.c): - -```diff - ... -{ -- RemoveBagItemIconSprite(1 ^ gBagMenu->itemIconSlot); -+ HideBagItemIconSprite(gBagMenu->itemIconSlot ^ 1); -+ RemoveBagItemIconSprite(gBagMenu->itemIconSlot); - if (itemIndex != LIST_CANCEL) - ... -``` diff --git a/gflib/bg.h b/gflib/bg.h index d8b5a5404..02ff07369 100644 --- a/gflib/bg.h +++ b/gflib/bg.h @@ -76,7 +76,7 @@ s32 ChangeBgY(u8 bg, s32 value, u8 op); s32 ChangeBgY_ScreenOff(u8 bg, s32 value, u8 op); s32 GetBgY(u8 bg); void SetBgAffine(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle); -u8 Unused_AdjustBgMosaic(u8 a1, u8 a2); +u8 Unused_AdjustBgMosaic(u8 val, u8 mode); void SetBgTilemapBuffer(u8 bg, void *tilemap); void UnsetBgTilemapBuffer(u8 bg); void* GetBgTilemapBuffer(u8 bg); diff --git a/gflib/sprite.c b/gflib/sprite.c index f05fe76f2..e5bf89063 100644 --- a/gflib/sprite.c +++ b/gflib/sprite.c @@ -94,7 +94,7 @@ static void ApplyAffineAnimFrame(u8 matrixNum, struct AffineAnimFrameCmd *frameC static u8 IndexOfSpriteTileTag(u16 tag); static void AllocSpriteTileRange(u16 tag, u16 start, u16 count); static void DoLoadSpritePalette(const u16 *src, u16 paletteOffset); -static void UpdateSpriteMatrixAnchorPos(struct Sprite* sprite, s32 a1, s32 a2); +static void UpdateSpriteMatrixAnchorPos(struct Sprite*, s32, s32); typedef void (*AnimFunc)(struct Sprite *); typedef void (*AnimCmdFunc)(struct Sprite *); @@ -632,14 +632,11 @@ void DestroySprite(struct Sprite *sprite) } } -void ResetOamRange(u8 a, u8 b) +void ResetOamRange(u8 start, u8 end) { u8 i; - - for (i = a; i < b; i++) - { + for (i = start; i < end; i++) gMain.oamBuffer[i] = *(struct OamData *)&gDummyOamData; - } } void LoadOam(void) diff --git a/gflib/sprite.h b/gflib/sprite.h index e53737981..f7ef16532 100644 --- a/gflib/sprite.h +++ b/gflib/sprite.h @@ -270,7 +270,7 @@ u8 CreateSpriteAtEnd(const struct SpriteTemplate *template, s16 x, s16 y, u8 sub u8 CreateInvisibleSprite(void (*callback)(struct Sprite *)); u8 CreateSpriteAndAnimate(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); void DestroySprite(struct Sprite *sprite); -void ResetOamRange(u8 a, u8 b); +void ResetOamRange(u8 start, u8 end); void LoadOam(void); void SetOamMatrix(u8 matrixNum, u16 a, u16 b, u16 c, u16 d); void CalcCenterToCornerVec(struct Sprite *sprite, u8 shape, u8 size, u8 affineMode); diff --git a/gflib/text.c b/gflib/text.c index 557c11704..c400c0582 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -326,14 +326,14 @@ void RunTextPrinters(void) { if (sTextPrinters[i].active) { - u16 temp = RenderFont(&sTextPrinters[i]); - switch (temp) + u16 renderCmd = RenderFont(&sTextPrinters[i]); + switch (renderCmd) { case RENDER_PRINT: CopyWindowToVram(sTextPrinters[i].printerTemplate.windowId, COPYWIN_GFX); case RENDER_UPDATE: - if (sTextPrinters[i].callback != 0) - sTextPrinters[i].callback(&sTextPrinters[i].printerTemplate, temp); + if (sTextPrinters[i].callback != NULL) + sTextPrinters[i].callback(&sTextPrinters[i].printerTemplate, renderCmd); break; case RENDER_FINISH: sTextPrinters[i].active = FALSE; diff --git a/graphics/door_anims/abandoned_ship.png b/graphics/door_anims/abandoned_ship.png index e46aca9ba..0030246b4 100644 Binary files a/graphics/door_anims/abandoned_ship.png and b/graphics/door_anims/abandoned_ship.png differ diff --git a/graphics/door_anims/abandoned_ship_room.png b/graphics/door_anims/abandoned_ship_room.png index a5284af7e..006922f5b 100644 Binary files a/graphics/door_anims/abandoned_ship_room.png and b/graphics/door_anims/abandoned_ship_room.png differ diff --git a/graphics/door_anims/battle_arena.png b/graphics/door_anims/battle_arena.png index ef6652815..ad3350a59 100644 Binary files a/graphics/door_anims/battle_arena.png and b/graphics/door_anims/battle_arena.png differ diff --git a/graphics/door_anims/battle_arena_lobby.png b/graphics/door_anims/battle_arena_lobby.png index b9a2134e3..78c344070 100644 Binary files a/graphics/door_anims/battle_arena_lobby.png and b/graphics/door_anims/battle_arena_lobby.png differ diff --git a/graphics/door_anims/battle_dome.png b/graphics/door_anims/battle_dome.png index 729385b3f..4bc9fab94 100644 Binary files a/graphics/door_anims/battle_dome.png and b/graphics/door_anims/battle_dome.png differ diff --git a/graphics/door_anims/battle_dome_corridor.png b/graphics/door_anims/battle_dome_corridor.png index 198ad9acc..78e77869e 100644 Binary files a/graphics/door_anims/battle_dome_corridor.png and b/graphics/door_anims/battle_dome_corridor.png differ diff --git a/graphics/door_anims/battle_dome_lobby.png b/graphics/door_anims/battle_dome_lobby.png index bd4e4e895..631cdecce 100644 Binary files a/graphics/door_anims/battle_dome_lobby.png and b/graphics/door_anims/battle_dome_lobby.png differ diff --git a/graphics/door_anims/battle_factory.png b/graphics/door_anims/battle_factory.png index 7ed6c876b..1d74d8b58 100644 Binary files a/graphics/door_anims/battle_factory.png and b/graphics/door_anims/battle_factory.png differ diff --git a/graphics/door_anims/battle_frontier.png b/graphics/door_anims/battle_frontier.png index bf758c03e..c3dcd4324 100644 Binary files a/graphics/door_anims/battle_frontier.png and b/graphics/door_anims/battle_frontier.png differ diff --git a/graphics/door_anims/battle_frontier_sliding.png b/graphics/door_anims/battle_frontier_sliding.png index a43cf519d..1359f4725 100644 Binary files a/graphics/door_anims/battle_frontier_sliding.png and b/graphics/door_anims/battle_frontier_sliding.png differ diff --git a/graphics/door_anims/battle_palace_lobby.png b/graphics/door_anims/battle_palace_lobby.png index f106ae960..a4aa998d4 100644 Binary files a/graphics/door_anims/battle_palace_lobby.png and b/graphics/door_anims/battle_palace_lobby.png differ diff --git a/graphics/door_anims/battle_tent.png b/graphics/door_anims/battle_tent.png index a0a88e4c5..b278e3310 100644 Binary files a/graphics/door_anims/battle_tent.png and b/graphics/door_anims/battle_tent.png differ diff --git a/graphics/door_anims/battle_tent_interior.png b/graphics/door_anims/battle_tent_interior.png index f8edb5a1a..036ec9d5a 100644 Binary files a/graphics/door_anims/battle_tent_interior.png and b/graphics/door_anims/battle_tent_interior.png differ diff --git a/graphics/door_anims/battle_tower.png b/graphics/door_anims/battle_tower.png index 3b9fe547c..3ec2b59bb 100644 Binary files a/graphics/door_anims/battle_tower.png and b/graphics/door_anims/battle_tower.png differ diff --git a/graphics/door_anims/battle_tower_corridor.png b/graphics/door_anims/battle_tower_corridor.png deleted file mode 100644 index 06ad24c9f..000000000 Binary files a/graphics/door_anims/battle_tower_corridor.png and /dev/null differ diff --git a/graphics/door_anims/battle_tower_elevator.png b/graphics/door_anims/battle_tower_elevator.png index 1d95b5b6a..fed07182e 100644 Binary files a/graphics/door_anims/battle_tower_elevator.png and b/graphics/door_anims/battle_tower_elevator.png differ diff --git a/graphics/door_anims/battle_tower_multi_corridor.png b/graphics/door_anims/battle_tower_multi_corridor.png index 145dea7a5..cb32fbc70 100644 Binary files a/graphics/door_anims/battle_tower_multi_corridor.png and b/graphics/door_anims/battle_tower_multi_corridor.png differ diff --git a/graphics/door_anims/battle_tower_old.png b/graphics/door_anims/battle_tower_old.png index 645c00613..326763f56 100644 Binary files a/graphics/door_anims/battle_tower_old.png and b/graphics/door_anims/battle_tower_old.png differ diff --git a/graphics/door_anims/birchs_lab.png b/graphics/door_anims/birchs_lab.png index 69bd93f89..0df0383c9 100644 Binary files a/graphics/door_anims/birchs_lab.png and b/graphics/door_anims/birchs_lab.png differ diff --git a/graphics/door_anims/cable_club.png b/graphics/door_anims/cable_club.png index a1dfd7bc2..3b45cb101 100644 Binary files a/graphics/door_anims/cable_club.png and b/graphics/door_anims/cable_club.png differ diff --git a/graphics/door_anims/contest.png b/graphics/door_anims/contest.png index dc466be11..8719b23ad 100644 Binary files a/graphics/door_anims/contest.png and b/graphics/door_anims/contest.png differ diff --git a/graphics/door_anims/cycling_road.png b/graphics/door_anims/cycling_road.png index 0c22c9182..cb1fb3034 100644 Binary files a/graphics/door_anims/cycling_road.png and b/graphics/door_anims/cycling_road.png differ diff --git a/graphics/door_anims/fallarbor_light_roof.png b/graphics/door_anims/fallarbor_light_roof.png index 4c81ba10e..a4c959f88 100644 Binary files a/graphics/door_anims/fallarbor_light_roof.png and b/graphics/door_anims/fallarbor_light_roof.png differ diff --git a/graphics/door_anims/general.png b/graphics/door_anims/general.png index fdab84132..7c9b7d64d 100644 Binary files a/graphics/door_anims/general.png and b/graphics/door_anims/general.png differ diff --git a/graphics/door_anims/gym.png b/graphics/door_anims/gym.png index fce000751..065181a9d 100644 Binary files a/graphics/door_anims/gym.png and b/graphics/door_anims/gym.png differ diff --git a/graphics/door_anims/lilycove.png b/graphics/door_anims/lilycove.png index ad5e43cc3..17a120a32 100644 Binary files a/graphics/door_anims/lilycove.png and b/graphics/door_anims/lilycove.png differ diff --git a/graphics/door_anims/lilycove_dept_store.png b/graphics/door_anims/lilycove_dept_store.png index 4f036c51d..7c64ab6da 100644 Binary files a/graphics/door_anims/lilycove_dept_store.png and b/graphics/door_anims/lilycove_dept_store.png differ diff --git a/graphics/door_anims/lilycove_wooden.png b/graphics/door_anims/lilycove_wooden.png index 99b94e72d..7c3680c28 100644 Binary files a/graphics/door_anims/lilycove_wooden.png and b/graphics/door_anims/lilycove_wooden.png differ diff --git a/graphics/door_anims/mauville.png b/graphics/door_anims/mauville.png index 63167408a..fec5f344f 100644 Binary files a/graphics/door_anims/mauville.png and b/graphics/door_anims/mauville.png differ diff --git a/graphics/door_anims/mossdeep_space_center.png b/graphics/door_anims/mossdeep_space_center.png index 4f2ccb6ff..c778b1718 100644 Binary files a/graphics/door_anims/mossdeep_space_center.png and b/graphics/door_anims/mossdeep_space_center.png differ diff --git a/graphics/door_anims/pacifidlog.png b/graphics/door_anims/pacifidlog.png index 3e0528825..841c31658 100644 Binary files a/graphics/door_anims/pacifidlog.png and b/graphics/door_anims/pacifidlog.png differ diff --git a/graphics/door_anims/petalburg_gym.png b/graphics/door_anims/petalburg_gym.png new file mode 100644 index 000000000..42a1e1dfd Binary files /dev/null and b/graphics/door_anims/petalburg_gym.png differ diff --git a/graphics/door_anims/poke_center.png b/graphics/door_anims/poke_center.png index 865810714..8bf5cb146 100644 Binary files a/graphics/door_anims/poke_center.png and b/graphics/door_anims/poke_center.png differ diff --git a/graphics/door_anims/pokemon_league.png b/graphics/door_anims/pokemon_league.png index cac740f56..34419ac0a 100644 Binary files a/graphics/door_anims/pokemon_league.png and b/graphics/door_anims/pokemon_league.png differ diff --git a/graphics/door_anims/rustboro_gray.png b/graphics/door_anims/rustboro_gray.png index 2cf62b6da..99211c11a 100644 Binary files a/graphics/door_anims/rustboro_gray.png and b/graphics/door_anims/rustboro_gray.png differ diff --git a/graphics/door_anims/rustboro_tan.png b/graphics/door_anims/rustboro_tan.png index d8a1b185e..7a0ba149c 100644 Binary files a/graphics/door_anims/rustboro_tan.png and b/graphics/door_anims/rustboro_tan.png differ diff --git a/graphics/door_anims/safari_zone.png b/graphics/door_anims/safari_zone.png index 89807f843..eae6a0e3e 100644 Binary files a/graphics/door_anims/safari_zone.png and b/graphics/door_anims/safari_zone.png differ diff --git a/graphics/door_anims/sootopolis.png b/graphics/door_anims/sootopolis.png index faac1f59d..3b3833daa 100644 Binary files a/graphics/door_anims/sootopolis.png and b/graphics/door_anims/sootopolis.png differ diff --git a/graphics/door_anims/sootopolis_peaked_roof.png b/graphics/door_anims/sootopolis_peaked_roof.png index b4ccfb5f9..7d8ea1f33 100644 Binary files a/graphics/door_anims/sootopolis_peaked_roof.png and b/graphics/door_anims/sootopolis_peaked_roof.png differ diff --git a/graphics/door_anims/trainer_hill_lobby_elevator.png b/graphics/door_anims/trainer_hill_lobby_elevator.png index aeb7eaf26..bdd1c3b27 100644 Binary files a/graphics/door_anims/trainer_hill_lobby_elevator.png and b/graphics/door_anims/trainer_hill_lobby_elevator.png differ diff --git a/graphics/door_anims/unknown.png b/graphics/door_anims/unused_battle_frontier.png similarity index 100% rename from graphics/door_anims/unknown.png rename to graphics/door_anims/unused_battle_frontier.png diff --git a/include/battle_anim.h b/include/battle_anim.h index d472d60f0..95944c8b5 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -64,7 +64,7 @@ void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible) bool8 IsContest(void); s8 BattleAnimAdjustPanning(s8 pan); s8 BattleAnimAdjustPanning2(s8 pan); -s16 KeepPanInRange(s16 a, int oldPan); +s16 KeepPanInRange(s16 panArg, int oldPan); s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan); void RelocateBattleBgPal(u16 paletteNum, u16 *dest, u32 offset, bool8 largeScreen); void ResetBattleAnimBg(bool8); @@ -95,14 +95,14 @@ bool8 AnimTranslateLinear(struct Sprite *sprite); void TranslateAnimSpriteToTargetMonLocation(struct Sprite *sprite); u8 GetBattlerSpriteCoord2(u8 battlerId, u8 attributeId); void InitAnimLinearTranslationWithSpeed(struct Sprite *sprite); -u16 ArcTan2Neg(s16 a, s16 b); -void TrySetSpriteRotScale(struct Sprite *sprite, bool8 a2, s16 xScale, s16 yScale, u16 rotation); +u16 ArcTan2Neg(s16 x, s16 y); +void TrySetSpriteRotScale(struct Sprite *sprite, bool8 recalcCenterVector, s16 xScale, s16 yScale, u16 rotation); void RunStoredCallbackWhenAffineAnimEnds(struct Sprite *sprite); void TranslateSpriteLinearAndFlicker(struct Sprite *sprite); void SetSpriteCoordsToAnimAttackerCoords(struct Sprite *sprite); void RunStoredCallbackWhenAnimEnds(struct Sprite *sprite); -void SetAnimSpriteInitialXOffset(struct Sprite *sprite, s16 a2); -s16 GetBattlerSpriteCoordAttr(u8 battlerId, u8 a2); +void SetAnimSpriteInitialXOffset(struct Sprite *sprite, s16 xOffset); +s16 GetBattlerSpriteCoordAttr(u8 battlerId, u8 attr); u8 GetBattlerYCoordWithElevation(u8 battlerId); void WaitAnimForDuration(struct Sprite *sprite); void AnimTravelDiagonally(struct Sprite *sprite); @@ -113,7 +113,7 @@ void *LoadPointerFromVars(s16 bottom, s16 top); void StorePointerInVars(s16 *bottom, s16 *top, const void *ptr); void InitPrioritiesForVisibleBattlers(void); void GetBattleAnimBg1Data(struct BattleAnimBgData*); -void GetBattleAnimBgData(struct BattleAnimBgData*, u32 arg1); +void GetBattleAnimBgData(struct BattleAnimBgData*, u32 bgId); u8 GetBattlerSpriteSubpriority(u8 battlerId); bool8 TranslateAnimHorizontalArc(struct Sprite *sprite); void TranslateSpriteLinearByIdFixedPoint(struct Sprite *sprite); @@ -122,7 +122,7 @@ void SetSpriteRotScale(u8 spriteId, s16 xScale, s16 yScale, u16 rotation); void InitSpriteDataForLinearTranslation(struct Sprite *sprite); void PrepareBattlerSpriteForRotScale(u8 spriteId, u8 objMode); void SetBattlerSpriteYOffsetFromRotation(u8 spriteId); -u32 GetBattleBgPalettesMask(u8 battleBackground, u8 attacker, u8 target, u8 attackerPartner, u8 targetPartner, u8 a6, u8 a7); +u32 GetBattlePalettesMask(bool8 battleBackground, bool8 attacker, bool8 target, bool8 attackerPartner, bool8 targetPartner, bool8 anim1, bool8 anim2); u32 GetBattleMonSpritePalettesMask(u8 playerLeft, u8 playerRight, u8 opponentLeft, u8 opponentRight); u8 AnimDummyReturnArg(u8 battler); s16 CloneBattlerSpriteWithBlend(u8); @@ -133,7 +133,7 @@ void AnimLoadCompressedBgGfx(u32, const u32*, u32); void UpdateAnimBg3ScreenSize(bool8); void TranslateSpriteInGrowingCircle(struct Sprite *); void SetBattlerSpriteYOffsetFromYScale(u8 spriteId); -void PrepareEruptAnimTaskData(struct Task *task, u8 a2, s16 a3, s16 a4, s16 a5, s16 a6, u16 a7); +void PrepareEruptAnimTaskData(struct Task *task, u8 spriteId, s16 xScaleStart, s16 yScaleStart, s16 xScaleEnd, s16 yScaleEnd, u16 duration); u8 UpdateEruptAnimTask(struct Task *task); void DestroyAnimSpriteAndDisableBlend(struct Sprite *); void AnimLoadCompressedBgTilemap(u32 bgId, const void *src); @@ -150,7 +150,7 @@ void PrepareAffineAnimInTaskData(struct Task *task, u8 spriteId, const union Aff bool8 RunAffineAnimFromTaskData(struct Task *task); void AnimThrowProjectile(struct Sprite *sprite); void GetBgDataForTransform(struct BattleAnimBgData *dest, u8 battlerId); -u8 CreateAdditionalMonSpriteForMoveAnim(u16 species, bool8 isBackpic, u8 a3, s16 x, s16 y, u8 subpriority, u32 personality, u32 trainerId, u32 battlerId, bool32 ignoreDeoxysForm); +u8 CreateAdditionalMonSpriteForMoveAnim(u16 species, bool8 isBackpic, u8 id, s16 x, s16 y, u8 subpriority, u32 personality, u32 trainerId, u32 battlerId, bool32 ignoreDeoxysForm); void ResetSpriteRotScale_PreserveAffine(struct Sprite *sprite); void TradeMenuBouncePartySprites(struct Sprite *sprite); void DestroyAnimVisualTaskAndDisableBlend(u8 taskId); @@ -185,7 +185,7 @@ enum u8 GetBattlerSpriteCoord(u8 battlerId, u8 attributeId); bool8 IsBattlerSpritePresent(u8 battlerId); -void ClearBattleAnimBg(u32 arg0); +void ClearBattleAnimBg(u32 bgId); u8 GetAnimBattlerSpriteId(u8 wantedBattler); bool8 IsDoubleBattle(void); u8 GetBattleBgPaletteNum(void); @@ -219,12 +219,12 @@ extern const union AffineAnimCmd *const gAffineAnims_SpinningBone[]; void TryShinyAnimation(u8 battler, struct Pokemon *mon); u8 ItemIdToBallId(u16 itemId); u8 AnimateBallOpenParticles(u8 x, u8 y, u8 priority, u8 subpriority, u8 ballId); -u8 LaunchBallFadeMonTask(bool8 unFadeLater, u8 battlerId, u32 selectedPalettes, u8 ballId); +u8 LaunchBallFadeMonTask(bool8 unFadeLater, u8 spritePalNum, u32 selectedPalettes, u8 ballId); bool32 IsCriticalCapture(void); // battle_anim_utility_funcs.c void InitStatsChangeAnimation(u8); -void StartMonScrollingBgMask(u8 taskId, int unused, u16 arg2, u8 battler1, u8 arg4, u8 arg5, u8 arg6, u8 arg7, const u32 *arg8, const u32 *arg9, const u32 *palette); +void StartMonScrollingBgMask(u8 taskId, int unused, u16 scrollSpeed, u8 battler, bool8 includePartner, u8 numFadeSteps, u8 fadeStepDelay, u8 duration, const u32 *gfx, const u32 *tilemap, const u32 *palette); // battle_anim_effects_1.c void SetSpriteNextToMonHead(u8 battler, struct Sprite* sprite); @@ -351,9 +351,9 @@ extern const union AffineAnimCmd *const gAffineAnims_LusterPurgeCircle[]; void AnimPsychoBoost(struct Sprite *sprite); // battle_anim_smokescreen.c -u8 SmokescreenImpact(s16 x, s16 y, u8 a3); +u8 SmokescreenImpact(s16 x, s16 y, bool8 persist); -u32 UnpackSelectedBattleBgPalettes(s16); +u32 UnpackSelectedBattlePalettes(s16); u8 GetBattlerSpriteFinal_Y(u8, u16, u8); diff --git a/include/battle_controllers.h b/include/battle_controllers.h index 74304f4d6..71c1f3af0 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -228,7 +228,7 @@ void BtlController_EmitPrintSelectionString(u8 bufferId, u16 stringId); void BtlController_EmitChooseAction(u8 bufferId, u8 action, u16 itemId); void BtlController_EmitYesNoBox(u8 bufferId); void BtlController_EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct *movePpData); -void BtlController_EmitChooseItem(u8 bufferId, u8* arg1); +void BtlController_EmitChooseItem(u8 bufferId, u8* battlePartyOrder); void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 slotId, u16 abilityId, u8* data); void BtlController_EmitCmd23(u8 bufferId); // unused void BtlController_EmitHealthBarUpdate(u8 bufferId, u16 hpValue); @@ -239,11 +239,11 @@ void BtlController_EmitStatusXor(u8 bufferId, u8 b); // unused void BtlController_EmitDataTransfer(u8 bufferId, u16 size, void *data); void BtlController_EmitDMA3Transfer(u8 bufferId, void *dst, u16 size, void *data); // unused void BtlController_EmitPlayBGM(u8 bufferId, u16 songId, void *data); // unused -void BtlController_EmitCmd32(u8 bufferId, u16 size, void *c); // unused -void BtlController_EmitTwoReturnValues(u8 bufferId, u8 arg1, u32 arg2); -void BtlController_EmitChosenMonReturnValue(u8 bufferId, u8 b, u8 *c); -void BtlController_EmitOneReturnValue(u8 bufferId, u16 arg1); -void BtlController_EmitOneReturnValue_Duplicate(u8 bufferId, u16 b); +void BtlController_EmitCmd32(u8 bufferId, u16 size, void *data); // unused +void BtlController_EmitTwoReturnValues(u8 bufferId, u8 ret8, u32 ret32); +void BtlController_EmitChosenMonReturnValue(u8 bufferId, u8 partyId, u8 *battlePartyOrder); +void BtlController_EmitOneReturnValue(u8 bufferId, u16 ret); +void BtlController_EmitOneReturnValue_Duplicate(u8 bufferId, u16 ret); void BtlController_EmitClearUnkVar(u8 bufferId); // unused void BtlController_EmitSetUnkVar(u8 bufferId, u8 b); // unused void BtlController_EmitClearUnkFlag(u8 bufferId); // unused @@ -260,7 +260,7 @@ void BtlController_EmitHidePartyStatusSummary(u8 bufferId); void BtlController_EmitEndBounceEffect(u8 bufferId); void BtlController_EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible); void BtlController_EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument); -void BtlController_EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 record); +void BtlController_EmitLinkStandbyMsg(u8 bufferId, u8 mode, bool32 record); void BtlController_EmitResetActionMoveSelection(u8 bufferId, u8 caseId); void BtlController_EmitEndLinkBattle(u8 bufferId, u8 battleOutcome); void BtlController_EmitDebugMenu(u8 bufferId); diff --git a/include/battle_gfx_sfx_util.h b/include/battle_gfx_sfx_util.h index e716fd9df..3e940995d 100644 --- a/include/battle_gfx_sfx_util.h +++ b/include/battle_gfx_sfx_util.h @@ -18,7 +18,7 @@ void DecompressTrainerBackPic(u16 backPicId, u8 battlerId); void BattleGfxSfxDummy3(u8 gender); void FreeTrainerFrontPicPalette(u16 frontPicId); bool8 BattleLoadAllHealthBoxesGfx(u8 state); -void LoadBattleBarGfx(u8 arg0); +void LoadBattleBarGfx(u8 unused); bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId); void ClearSpritesHealthboxAnimData(void); void CopyAllBattleSpritesInvisibilities(void); diff --git a/include/battle_interface.h b/include/battle_interface.h index de1b39cdc..29cb45b0f 100644 --- a/include/battle_interface.h +++ b/include/battle_interface.h @@ -91,10 +91,10 @@ void HideMegaTriggerSprite(void); void DestroyMegaTriggerSprite(void); u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which); void DestroyMegaIndicatorSprite(u32 healthboxSpriteId); -u8 CreatePartyStatusSummarySprites(u8 battler, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart); +u8 CreatePartyStatusSummarySprites(u8 battler, struct HpAndStatus *partyInfo, bool8 skipPlayer, bool8 isBattleStart); void Task_HidePartyStatusSummary(u8 taskId); void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elementId); -s32 MoveBattleBar(u8 battler, u8 healthboxSpriteId, u8 whichBar, u8 arg3); +s32 MoveBattleBar(u8 battler, u8 healthboxSpriteId, u8 whichBar, u8 unused); u8 GetScaledHPFraction(s16 hp, s16 maxhp, u8 scale); u8 GetHPBarLevel(s16 hp, s16 maxhp); void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle); diff --git a/include/battle_main.h b/include/battle_main.h index 62d8411a6..7991696e7 100644 --- a/include/battle_main.h +++ b/include/battle_main.h @@ -22,8 +22,6 @@ struct MultiPartnerMenuPokemon /*0x1D*/ u8 language; }; -#define TYPE_NAME_LENGTH 6 - #if B_EXPANDED_ABILITY_NAMES #define ABILITY_NAME_LENGTH 16 #else diff --git a/include/battle_setup.h b/include/battle_setup.h index 5ec7e35d5..e29b3155f 100644 --- a/include/battle_setup.h +++ b/include/battle_setup.h @@ -32,7 +32,7 @@ void StartRegiBattle(void); u8 BattleSetup_GetTerrainId(void); u8 GetWildBattleTransition(void); u8 GetTrainerBattleTransition(void); -u8 GetSpecialBattleTransition(s32 arg0); +u8 GetSpecialBattleTransition(s32 id); void ChooseStarter(void); void ResetTrainerOpponentIds(void); void SetMapVarsToTrainer(void); diff --git a/include/battle_util.h b/include/battle_util.h index 877adeca7..e45acdb89 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -79,7 +79,7 @@ void PressurePPLoseOnUsingImprison(u8 attacker); void MarkAllBattlersForControllerExec(void); // unused bool32 IsBattlerMarkedForControllerExec(u8 battlerId); void MarkBattlerForControllerExec(u8 battlerId); -void MarkBattlerReceivedLinkData(u8 arg0); +void MarkBattlerReceivedLinkData(u8 battlerId); void CancelMultiTurnMoves(u8 battlerId); bool8 WasUnableToUseMove(u8 battlerId); void PrepareStringBattle(u16 stringId, u8 battlerId); diff --git a/include/constants/battle.h b/include/constants/battle.h index 71252ae34..a06e3e11e 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -421,7 +421,7 @@ #define B_WIN_TYPE_NORMAL 0 #define B_WIN_TYPE_ARENA 1 -// Window Ids for gStandardBattleWindowTemplates / gBattleArenaWindowTemplates +// Window Ids for sStandardBattleWindowTemplates / sBattleArenaWindowTemplates #define B_WIN_MSG 0 #define B_WIN_ACTION_PROMPT 1 // "What will {x} do?" #define B_WIN_ACTION_MENU 2 // "Fight/Pokémon/Bag/Run" menu diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h index a5490949d..d15b6876e 100644 --- a/include/constants/battle_anim.h +++ b/include/constants/battle_anim.h @@ -613,4 +613,21 @@ #define ANIM_SURF_PAL_MUDDY_WATER 1 #define ANIM_SURF_PAL_SLUDGE_WAVE 2 +// Flags given to various functions to indicate which palettes to consider. +// Handled by UnpackSelectedBattlePalettes +#define F_PAL_BG (1 << 0) +#define F_PAL_ATTACKER (1 << 1) +#define F_PAL_TARGET (1 << 2) +#define F_PAL_ATK_PARTNER (1 << 3) +#define F_PAL_DEF_PARTNER (1 << 4) +#define F_PAL_ANIM_1 (1 << 5) // Palette set for GetBattleAnimBg1Data/GetBgDataForTransform. Only used (ineffectually?) by Aromatherapy. +#define F_PAL_ANIM_2 (1 << 6) // Palette set for GetBattleAnimBgData/GetBgDataForTransform. Unused. +#define F_PAL_ATK_SIDE (F_PAL_ATTACKER | F_PAL_ATK_PARTNER) +#define F_PAL_DEF_SIDE (F_PAL_TARGET | F_PAL_DEF_PARTNER) +#define F_PAL_BATTLERS (F_PAL_ATK_SIDE | F_PAL_DEF_SIDE) +// The below are only used by AnimTask_BlendBattleAnimPal to get battler sprite palettes by position rather than by role. +// It's redundant with F_PAL_BATTLERS, because they're only ever used together to refer to all the battlers at once. +#define F_PAL_BATTLERS_2 (1 << 7 | 1 << 8 | 1 << 9 | 1 << 10) + + #endif // GUARD_CONSTANTS_BATTLE_ANIM_H diff --git a/include/constants/battle_frontier.h b/include/constants/battle_frontier.h index 32dc05518..44abf2030 100644 --- a/include/constants/battle_frontier.h +++ b/include/constants/battle_frontier.h @@ -1,6 +1,8 @@ #ifndef GUARD_CONSTANTS_BATTLE_FRONTIER_H #define GUARD_CONSTANTS_BATTLE_FRONTIER_H +#include "constants/pokemon.h" + #define FRONTIER_CHALLENGE(facility, mode) ((facility << 8) + mode) // Battle Frontier facility ids. @@ -47,6 +49,14 @@ #define MAX_BATTLE_FRONTIER_POINTS 9999 #define MAX_STREAK 9999 +#define FRONTIER_MAX_LEVEL_50 50 +#define FRONTIER_MIN_LEVEL_OPEN 60 +#define FRONTIER_MAX_LEVEL_OPEN MAX_LEVEL + +// This is the default number of battles (or floors, in Battle Pyramid) per challenge. +// There are 2 facilities that differ: Battle Dome (DOME_ROUNDS_COUNT) and Battle Pike (NUM_PIKE_ROOMS). +#define FRONTIER_STAGES_PER_CHALLENGE 7 + // These sets of facility ids would be redundant if the order was consistent // The order is important for this set so that all the non-link records can be continuous #define RANKING_HALL_TOWER_SINGLES 0 diff --git a/include/constants/battle_pike.h b/include/constants/battle_pike.h index 76309436e..eebfd741a 100644 --- a/include/constants/battle_pike.h +++ b/include/constants/battle_pike.h @@ -1,6 +1,8 @@ #ifndef GUARD_CONSTANTS_BATTLE_PIKE_H #define GUARD_CONSTANTS_BATTLE_PIKE_H +#define NUM_PIKE_ROOMS 14 + #define PIKE_ROOM_SINGLE_BATTLE 0 #define PIKE_ROOM_HEAL_FULL 1 #define PIKE_ROOM_NPC 2 diff --git a/include/constants/battle_pyramid.h b/include/constants/battle_pyramid.h index ebb753882..297f3b1ff 100644 --- a/include/constants/battle_pyramid.h +++ b/include/constants/battle_pyramid.h @@ -14,6 +14,13 @@ #define HINT_EXIT_FAR_REMAINING_TRAINERS 7 #define HINT_EXIT_FAR_REMAINING_ITEMS 8 +#define MAX_PYRAMID_TRAINERS 8 + +// Each floor of the Battle Pyramid is 32x32 metatiles, subdivided into a 4x4 grid of 8x8 metatile squares +#define PYRAMID_FLOOR_SQUARES_WIDE 4 +#define PYRAMID_FLOOR_SQUARES_HIGH 4 +#define NUM_PYRAMID_FLOOR_SQUARES (PYRAMID_FLOOR_SQUARES_WIDE * PYRAMID_FLOOR_SQUARES_HIGH) + #define OBJ_TRAINERS 0 #define OBJ_ITEMS 1 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 3498e0e61..39092410a 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -893,7 +893,7 @@ #define B_MSG_WRAPPED_MAGMA_STORM 6 #define B_MSG_WRAPPED_INFESTATION 7 #define B_MSG_WRAPPED_SNAP_TRAP 8 -#define TRAPPING_MOVES_COUNT 9 +#define NUM_TRAPPING_MOVES 9 // z effects #define B_MSG_Z_RESET_STATS 0 diff --git a/include/constants/battle_tent.h b/include/constants/battle_tent.h index 666ada6bd..6f9989b7a 100644 --- a/include/constants/battle_tent.h +++ b/include/constants/battle_tent.h @@ -1,6 +1,12 @@ #ifndef GUARD_CONSTANTS_BATTLE_TENT_H #define GUARD_CONSTANTS_BATTLE_TENT_H +#define TENT_MIN_LEVEL 30 + +// The number of battles in each Battle Tent challenge. +// Battle Tent equivalent of FRONTIER_STAGES_PER_CHALLENGE. +#define TENT_STAGES_PER_CHALLENGE 3 + #define VERDANTURF_TENT_FUNC_INIT 0 #define VERDANTURF_TENT_FUNC_GET_PRIZE 1 #define VERDANTURF_TENT_FUNC_SET_PRIZE 2 diff --git a/include/constants/event_objects.h b/include/constants/event_objects.h index 6b99f19bd..8278c6a66 100644 --- a/include/constants/event_objects.h +++ b/include/constants/event_objects.h @@ -241,6 +241,15 @@ #define OBJ_EVENT_GFX_LUGIA 237 #define OBJ_EVENT_GFX_HOOH 238 +// NOTE: By default, the max value for NUM_OBJ_EVENT_GFX is 239. +// +// Object event graphics ids are 1 byte in size (max value of 255), and the dynamic +// graphics ids that start after NUM_OBJ_EVENT_GFX reach this limit. No graphics id +// uses the value 239 itself, so removing the "+ 1" in OBJ_EVENT_GFX_VARS would +// allow increasing NUM_OBJ_EVENT_GFX to 240. There are also a handful of unused +// object graphics that can be removed. If more graphics are needed, anything that +// stores graphics ids will need to be increased in size. See wiki entry below: +// https://github.com/pret/pokeemerald/wiki/Feature-Branches#overworld-expansion #define NUM_OBJ_EVENT_GFX 239 diff --git a/include/constants/flags.h b/include/constants/flags.h index eacb2426d..8fbc24630 100644 --- a/include/constants/flags.h +++ b/include/constants/flags.h @@ -1634,7 +1634,7 @@ #define FLAGS_COUNT (DAILY_FLAGS_END + 1) -// Special Flags (Stored in EWRAM (gSpecialFlags), not in the SaveBlock) +// Special Flags (Stored in EWRAM (sSpecialFlags), not in the SaveBlock) #define SPECIAL_FLAGS_START 0x4000 #define FLAG_HIDE_MAP_NAME_POPUP (SPECIAL_FLAGS_START + 0x0) #define FLAG_DONT_TRANSITION_MUSIC (SPECIAL_FLAGS_START + 0x1) diff --git a/include/constants/global.h b/include/constants/global.h index 096094220..e4a08c35c 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -101,6 +101,7 @@ #define WONDER_NEWS_TEXT_LENGTH 40 #define WONDER_CARD_BODY_TEXT_LINES 4 #define WONDER_NEWS_BODY_TEXT_LINES 10 +#define TYPE_NAME_LENGTH 6 #define MAX_STAMP_CARD_STAMPS 7 diff --git a/include/constants/metatile_labels.h b/include/constants/metatile_labels.h index 3c484e39a..ff10f52ee 100644 --- a/include/constants/metatile_labels.h +++ b/include/constants/metatile_labels.h @@ -99,6 +99,7 @@ #define METATILE_PetalburgGym_SlidingDoor_Frame2 0x21A #define METATILE_PetalburgGym_SlidingDoor_Frame3 0x21B #define METATILE_PetalburgGym_SlidingDoor_Frame4 0x21C +#define METATILE_PetalburgGym_Door 0x224 // gTileset_MossdeepGym from R/S #define METATILE_RS_MossdeepGym_RedArrow_Right 0x204 @@ -128,7 +129,6 @@ // gTileset_BattleFrontier #define METATILE_BattleFrontier_Door_Elevator 0x20E -#define METATILE_BattleFrontier_Door_Corridor 0x224 #define METATILE_BattleFrontier_Door_MultiCorridor 0x2AD #define METATILE_BattleFrontier_CorridorOpenDoor_Top 0x207 #define METATILE_BattleFrontier_CorridorOpenDoor_Bottom 0x20F diff --git a/include/constants/moves.h b/include/constants/moves.h index 746076cb3..822853e93 100644 --- a/include/constants/moves.h +++ b/include/constants/moves.h @@ -829,4 +829,7 @@ #define MOVES_COUNT_Z (LAST_Z_MOVE + 1) +// Used for checks for moves affected by Disable, Mimic, etc. +#define MOVE_UNAVAILABLE 0xFFFF + #endif // GUARD_CONSTANTS_MOVES_H diff --git a/include/constants/tv.h b/include/constants/tv.h index 4c8dd4fa8..87748a31d 100644 --- a/include/constants/tv.h +++ b/include/constants/tv.h @@ -274,4 +274,21 @@ #define SMARTSHOPPER_NUM_ITEMS 3 +// TV Show states for Bravo Trainer's Battle Tower interview +#define BRAVOTOWER_STATE_INTRO 0 +#define BRAVOTOWER_STATE_NEW_RECORD 1 +#define BRAVOTOWER_STATE_LOST 2 +#define BRAVOTOWER_STATE_WON 3 +#define BRAVOTOWER_STATE_LOST_FINAL 4 +#define BRAVOTOWER_STATE_SATISFIED 5 +#define BRAVOTOWER_STATE_UNSATISFIED 6 +#define BRAVOTOWER_STATE_UNUSED_1 7 +#define BRAVOTOWER_STATE_UNUSED_2 8 +#define BRAVOTOWER_STATE_UNUSED_3 9 +#define BRAVOTOWER_STATE_UNUSED_4 10 +#define BRAVOTOWER_STATE_RESPONSE 11 +#define BRAVOTOWER_STATE_RESPONSE_SATISFIED 12 +#define BRAVOTOWER_STATE_RESPONSE_UNSATISFIED 13 +#define BRAVOTOWER_STATE_OUTRO 14 + #endif //GUARD_CONSTANTS_TV_H diff --git a/include/constants/union_room.h b/include/constants/union_room.h index 6e08c9ebb..f47a8723f 100644 --- a/include/constants/union_room.h +++ b/include/constants/union_room.h @@ -11,6 +11,8 @@ #define UNION_ROOM_SPAWN_IN 1 #define UNION_ROOM_SPAWN_OUT 2 +#define UNION_ROOM_MAX_LEVEL 30 + #define ACTIVITY_NONE 0 #define ACTIVITY_BATTLE_SINGLE 1 #define ACTIVITY_BATTLE_DOUBLE 2 diff --git a/include/contest.h b/include/contest.h index e7acb5a11..d0630a801 100644 --- a/include/contest.h +++ b/include/contest.h @@ -324,7 +324,6 @@ extern u16 gSpecialVar_ContestRank; extern u8 gNumLinkContestPlayers; extern u8 gHighestRibbonRank; extern struct ContestResources *gContestResources; -extern u8 sContestBgCopyFlags; extern struct ContestWinner gCurContestWinner; extern u8 gCurContestWinnerIsForArtist; extern u8 gCurContestWinnerSaveIdx; @@ -340,11 +339,11 @@ void SetLinkAIContestants(u8 contestType, u8 rank, bool32 isPostgame); u8 GetContestEntryEligibility(struct Pokemon *pkmn); void CalculateRound1Points(u8 contestCategory); bool8 IsSpeciesNotUnown(u16 species); -bool8 Contest_IsMonsTurnDisabled(u8 a); +bool8 Contest_IsMonsTurnDisabled(u8 contestant); void SaveLinkContestResults(void); -void SortContestants(bool8 a); -void SetContestantEffectStringID(u8 a, u8 b); -void SetContestantEffectStringID2(u8 a, u8 b); +void SortContestants(bool8 useRanking); +void SetContestantEffectStringID(u8 contestant, u8 effectStringId); +void SetContestantEffectStringID2(u8 contestant, u8 effectStringId); void SetStartledString(u8 contestant, u8 jam); void MakeContestantNervous(u8 p); s8 Contest_GetMoveExcitement(u16 move); diff --git a/include/decompress.h b/include/decompress.h index 02412defb..14906211c 100644 --- a/include/decompress.h +++ b/include/decompress.h @@ -13,7 +13,7 @@ void LoadCompressedSpriteSheetOverrideBuffer(const struct CompressedSpriteSheet bool8 LoadCompressedSpriteSheetUsingHeap(const struct CompressedSpriteSheet* src); void LoadCompressedSpritePalette(const struct CompressedSpritePalette *src); -void LoadCompressedSpritePaletteOverrideBuffer(const struct CompressedSpritePalette *a, void *buffer); +void LoadCompressedSpritePaletteOverrideBuffer(const struct CompressedSpritePalette *src, void *buffer); bool8 LoadCompressedSpritePaletteUsingHeap(const struct CompressedSpritePalette *src); void DecompressPicFromTable(const struct CompressedSpriteSheet *src, void* buffer, s32 species); diff --git a/include/digit_obj_util.h b/include/digit_obj_util.h index aca97e2c7..4442fb0ec 100644 --- a/include/digit_obj_util.h +++ b/include/digit_obj_util.h @@ -18,9 +18,9 @@ struct DigitObjUtilTemplate bool32 DigitObjUtil_Init(u32 count); void DigitObjUtil_Free(void); bool32 DigitObjUtil_CreatePrinter(u32 id, s32 num, const struct DigitObjUtilTemplate *template); -void DigitObjUtil_PrintNumOn(u32 id, s32 arg1); +void DigitObjUtil_PrintNumOn(u32 id, s32 num); void DigitObjUtil_DeletePrinter(u32 id); -void DigitObjUtil_HideOrShow(u32 id, bool32 arg1); +void DigitObjUtil_HideOrShow(u32 id, bool32 hide); u8 GetTilesPerImage(u32 shape, u32 size); #endif // GUARD_DIGIT_OBJ_UTIL_H diff --git a/include/event_scripts.h b/include/event_scripts.h index a19d4553a..4e0a88f82 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -21,21 +21,21 @@ extern const u8 gTVBravoTrainerText05[]; extern const u8 gTVBravoTrainerText06[]; extern const u8 gTVBravoTrainerText07[]; extern const u8 gTVBravoTrainerText08[]; -extern const u8 gTVBravoTrainerBattleTowerText00[]; -extern const u8 gTVBravoTrainerBattleTowerText01[]; -extern const u8 gTVBravoTrainerBattleTowerText02[]; -extern const u8 gTVBravoTrainerBattleTowerText03[]; -extern const u8 gTVBravoTrainerBattleTowerText04[]; -extern const u8 gTVBravoTrainerBattleTowerText05[]; -extern const u8 gTVBravoTrainerBattleTowerText06[]; -extern const u8 gTVBravoTrainerBattleTowerText07[]; -extern const u8 gTVBravoTrainerBattleTowerText08[]; -extern const u8 gTVBravoTrainerBattleTowerText09[]; -extern const u8 gTVBravoTrainerBattleTowerText10[]; -extern const u8 gTVBravoTrainerBattleTowerText11[]; -extern const u8 gTVBravoTrainerBattleTowerText12[]; -extern const u8 gTVBravoTrainerBattleTowerText13[]; -extern const u8 gTVBravoTrainerBattleTowerText14[]; +extern const u8 BravoTrainerBattleTower_Text_Intro[]; +extern const u8 BravoTrainerBattleTower_Text_NewRecord[]; +extern const u8 BravoTrainerBattleTower_Text_Lost[]; +extern const u8 BravoTrainerBattleTower_Text_Won[]; +extern const u8 BravoTrainerBattleTower_Text_LostFinal[]; +extern const u8 BravoTrainerBattleTower_Text_Satisfied[]; +extern const u8 BravoTrainerBattleTower_Text_Unsatisfied[]; +extern const u8 BravoTrainerBattleTower_Text_None1[]; +extern const u8 BravoTrainerBattleTower_Text_None2[]; +extern const u8 BravoTrainerBattleTower_Text_None3[]; +extern const u8 BravoTrainerBattleTower_Text_None4[]; +extern const u8 BravoTrainerBattleTower_Text_Response[]; +extern const u8 BravoTrainerBattleTower_Text_ResponseSatisfied[]; +extern const u8 BravoTrainerBattleTower_Text_ResponseUnsatisfied[]; +extern const u8 BravoTrainerBattleTower_Text_Outro[]; extern const u8 gTVFanClubOpinionsText00[]; extern const u8 gTVFanClubOpinionsText01[]; extern const u8 gTVFanClubOpinionsText02[]; diff --git a/include/evolution_graphics.h b/include/evolution_graphics.h index 61051c69a..eab5c6eb7 100644 --- a/include/evolution_graphics.h +++ b/include/evolution_graphics.h @@ -3,7 +3,7 @@ void LoadEvoSparkleSpriteAndPal(void); -u8 EvolutionSparkles_SpiralUpward(u16 arg0); +u8 EvolutionSparkles_SpiralUpward(u16 palNum); u8 EvolutionSparkles_ArcDown(void); u8 EvolutionSparkles_CircleInward(void); u8 EvolutionSparkles_SprayAndFlash(u16 species); diff --git a/include/field_camera.h b/include/field_camera.h index b245fca84..6e8af1a53 100644 --- a/include/field_camera.h +++ b/include/field_camera.h @@ -17,14 +17,14 @@ extern u16 gTotalCameraPixelOffsetY; void DrawWholeMapView(void); void CurrentMapDrawMetatileAt(int x, int y); -void GetCameraOffsetWithPan(s16 *a0, s16 *a1); +void GetCameraOffsetWithPan(s16 *x, s16 *y); void DrawDoorMetatileAt(int x, int y, u16 *arr); void ResetFieldCamera(void); void ResetCameraUpdateInfo(void); -u32 InitCameraUpdateCallback(u8 a); +u32 InitCameraUpdateCallback(u8 trackedSpriteId); void CameraUpdate(void); -void SetCameraPanningCallback(void (*a)(void)); -void SetCameraPanning(s16 a, s16 b); +void SetCameraPanningCallback(void (*callback)(void)); +void SetCameraPanning(s16 horizontal, s16 vertical); void InstallCameraPanAheadCallback(void); void UpdateCameraPanning(void); void FieldUpdateBgTilemapScroll(void); diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index d382de08c..2bf2df269 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -11,29 +11,29 @@ void PlayerGetDestCoords(s16 *, s16 *); u8 GetPlayerFacingDirection(void); u8 GetPlayerMovementDirection(void); u8 PlayerGetCopyableMovement(void); -void PlayerWalkNormal(u8); -void PlayerWalkFast(u8); -void PlayerRideWaterCurrent(u8); -void PlayerWalkFaster(u8); -void PlayerOnBikeCollide(u8); -void PlayerFaceDirection(u8 a); -void PlayerTurnInPlace(u8 a); -void PlayerJumpLedge(u8 a); -void PlayerIdleWheelie(u8 a); -void PlayerStartWheelie(u8 a); -void PlayerEndWheelie(u8 a); -void PlayerStandingHoppingWheelie(u8 a); -void PlayerMovingHoppingWheelie(u8 a); -void PlayerLedgeHoppingWheelie(u8 a); -void PlayerAcroTurnJump(u8 a); -void PlayerSetAnimId(u8 a, u8 b); +void PlayerWalkNormal(u8 direction); +void PlayerWalkFast(u8 direction); +void PlayerRideWaterCurrent(u8 direction); +void PlayerWalkFaster(u8 direction); +void PlayerOnBikeCollide(u8 direction); +void PlayerFaceDirection(u8 direction); +void PlayerTurnInPlace(u8 direction); +void PlayerJumpLedge(u8 direction); +void PlayerIdleWheelie(u8 direction); +void PlayerStartWheelie(u8 direction); +void PlayerEndWheelie(u8 direction); +void PlayerStandingHoppingWheelie(u8 direction); +void PlayerMovingHoppingWheelie(u8 direction); +void PlayerLedgeHoppingWheelie(u8 direction); +void PlayerAcroTurnJump(u8 direction); +void PlayerSetAnimId(u8 movementActionId, u8 copyableMovement); bool8 IsPlayerCollidingWithFarawayIslandMew(u8 direction); void PlayerOnBikeCollideWithFarawayIslandMew(u8 direction); -u8 CheckForObjectEventCollision(struct ObjectEvent *a, s16 b, s16 c, u8 d, u8 e); +u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction, u8 metatileBehavior); u8 PlayerGetElevation(void); -void SetPlayerAvatarTransitionFlags(u16 a); +void SetPlayerAvatarTransitionFlags(u16 transitionFlags); void CancelPlayerForcedMovement(void); -void InitPlayerAvatar(s16 a, s16 b, u8 c, u8 d); +void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender); void PlayerFreeze(void); void StopPlayerAvatar(void); void SetSpinStartFacingDir(u8); @@ -41,8 +41,8 @@ void GetXYCoordsOneStepInFrontOfPlayer(s16 *xPtr, s16 *yPtr); u8 GetRivalAvatarGraphicsIdByStateIdAndGender(u8, u8); void SetPlayerAvatarFieldMove(void); u8 GetPlayerAvatarGraphicsIdByCurrentState(void); -void SetPlayerAvatarStateMask(u8 a); -u8 GetPlayerAvatarGraphicsIdByStateId(u8 a); +void SetPlayerAvatarStateMask(u8 flags); +u8 GetPlayerAvatarGraphicsIdByStateId(u8 state); u8 GetJumpSpecialMovementAction(u32); bool8 PartyHasMonWithSurf(void); bool8 IsPlayerFacingSurfableFishableWater(void); diff --git a/include/field_special_scene.h b/include/field_special_scene.h index 3f701f41b..111723c83 100644 --- a/include/field_special_scene.h +++ b/include/field_special_scene.h @@ -1,14 +1,8 @@ #ifndef GUARD_FIELD_SPECIAL_SCENE_H #define GUARD_FIELD_SPECIAL_SCENE_H -s16 GetTruckCameraBobbingY(int a1); -s16 GetTruckBoxMovement(int a1); -void Task_Truck1(u8 taskId); -void Task_Truck2(u8 taskId); -void Task_Truck3(u8 taskId); -void Task_HandleTruckSequence(u8 taskId); void ExecuteTruckSequence(void); -void EndTruckSequence(u8); +void EndTruckSequence(u8 taskId); void FieldCB_ShowPortholeView(void); #endif // GUARD_FIELD_SPECIAL_SCENE_H diff --git a/include/fldeff.h b/include/fldeff.h index 597ce6f47..0ad0e3d60 100644 --- a/include/fldeff.h +++ b/include/fldeff.h @@ -25,8 +25,8 @@ void ChooseMonForSoftboiled(u8 taskId); // flash bool8 SetUpFieldMove_Flash(void); void CB2_DoChangeMap(void); -bool8 GetMapPairFadeToType(u8 a1, u8 a2); -bool8 GetMapPairFadeFromType(u8 a1, u8 a2); +bool8 GetMapPairFadeToType(u8 _fromType, u8 _toType); +bool8 GetMapPairFadeFromType(u8 _fromType, u8 _toType); // strength bool8 SetUpFieldMove_Strength(void); diff --git a/include/fldeff_misc.h b/include/fldeff_misc.h index 4acca7944..61078466d 100644 --- a/include/fldeff_misc.h +++ b/include/fldeff_misc.h @@ -1,8 +1,8 @@ #ifndef GUARD_FLDEFF_MISC_H #define GUARD_FLDEFF_MISC_H -void ComputerScreenOpenEffect(u16 a0, u16 a1, u8 a2); -void ComputerScreenCloseEffect(u16 a0, u16 a1, u8 a2); +void ComputerScreenOpenEffect(u16 increment, u16 unused, u8 priority); +void ComputerScreenCloseEffect(u16 increment, u16 unused, u8 priority); bool8 IsComputerScreenOpenEffectActive(void); bool8 IsComputerScreenCloseEffectActive(void); bool8 SetUpFieldMove_SecretPower(void); @@ -22,7 +22,7 @@ void PlaySecretBaseMusicNoteMatSound(s16 metatileId); void DoSecretBaseGlitterMatSparkle(void); bool8 FldEff_SandPillar(void); void InteractWithShieldOrTVDecoration(void); -bool8 IsLargeBreakableDecoration(u16 arg0, u8 arg1); +bool8 IsLargeBreakableDecoration(u16 metatileId, bool8 checkBase); void FldEffPoison_Start(void); bool32 FldEffPoison_IsActive(void); void DoWateringBerryTreeAnim(void); diff --git a/include/gba/m4a_internal.h b/include/gba/m4a_internal.h index a057c2da6..40a25ba05 100644 --- a/include/gba/m4a_internal.h +++ b/include/gba/m4a_internal.h @@ -423,7 +423,7 @@ void Clear64byte(void *addr); void SoundInit(struct SoundInfo *soundInfo); void MPlayExtender(struct CgbChannel *cgbChans); void m4aSoundMode(u32 mode); -void MPlayOpen(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track, u8 a3); +void MPlayOpen(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *tracks, u8 trackCount); void CgbSound(void); void CgbOscOff(u8); void CgbModVol(struct CgbChannel *chan); diff --git a/include/global.h b/include/global.h index e1d19cdec..f3013fca9 100644 --- a/include/global.h +++ b/include/global.h @@ -142,6 +142,10 @@ #define NUM_FLAG_BYTES ROUND_BITS_TO_BYTES(FLAGS_COUNT) #define NUM_ADDITIONAL_PHRASE_BYTES ROUND_BITS_TO_BYTES(NUM_ADDITIONAL_PHRASES) +// This produces an error at compile-time if expr is zero. +// It looks like file.c:line: size of array `id' is negative +#define STATIC_ASSERT(expr, id) typedef char id[(expr) ? 1 : -1]; + struct Coords8 { s8 x; @@ -412,7 +416,7 @@ struct BattleFrontier /*0xE1A*/ u16 pyramidWinStreaks[FRONTIER_LVL_MODE_COUNT]; /*0xE1E*/ u16 pyramidRecordStreaks[FRONTIER_LVL_MODE_COUNT]; /*0xE22*/ u16 pyramidRandoms[4]; - /*0xE2A*/ u8 pyramidTrainerFlags; + /*0xE2A*/ u8 pyramidTrainerFlags; // 1 bit for each trainer (MAX_PYRAMID_TRAINERS) /*0xE2C*/ struct PyramidBag pyramidBag; /*0xE68*/ u8 pyramidLightRadius; /*0xE6A*/ u16 verdanturfTentPrize; diff --git a/include/intro_credits_graphics.h b/include/intro_credits_graphics.h index bed30ffe8..c6f4a73c5 100644 --- a/include/intro_credits_graphics.h +++ b/include/intro_credits_graphics.h @@ -33,11 +33,11 @@ extern const struct CompressedSpriteSheet gSpriteSheet_CreditsRivalBrendan[]; extern const struct CompressedSpriteSheet gSpriteSheet_CreditsRivalMay[]; extern const struct SpritePalette gSpritePalettes_Credits[]; -void LoadIntroPart2Graphics(u8 scene); -void SetIntroPart2BgCnt(u8 a); +void LoadIntroPart2Graphics(u8 scenery); +void SetIntroPart2BgCnt(u8 scenery); void LoadCreditsSceneGraphics(u8); void SetCreditsSceneBgCnt(u8); -u8 CreateBicycleBgAnimationTask(u8 a, u16 b, u16 c, u16 d); +u8 CreateBicycleBgAnimationTask(u8 mode, u16 bg1Speed, u16 bg2Speed, u16 bg3Speed); void CycleSceneryPalette(u8); u8 CreateIntroBrendanSprite(s16 x, s16 y); u8 CreateIntroMaySprite(s16 x, s16 y); diff --git a/include/link.h b/include/link.h index 96a76e120..120c25784 100644 --- a/include/link.h +++ b/include/link.h @@ -300,7 +300,7 @@ void LocalLinkPlayerToBlock(void); void LinkPlayerFromBlock(u32 who); bool32 Link_AnyPartnersPlayingFRLG_JP(void); void ResetLinkPlayerCount(void); -void SaveLinkPlayers(u8 a0); +void SaveLinkPlayers(u8 playerCount); void SetWirelessCommType0(void); bool32 IsLinkRecvQueueAtOverworldMax(void); diff --git a/include/list_menu.h b/include/list_menu.h index 1c18f3dff..e70a92bab 100644 --- a/include/list_menu.h +++ b/include/list_menu.h @@ -98,9 +98,9 @@ struct CursorStruct extern struct ScrollArrowsTemplate gTempScrollArrowTemplate; extern struct ListMenuTemplate gMultiuseListMenuTemplate; -s32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum); +s32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const struct ListMenuTemplate *listMenuTemplate, u8 drawMode, u16 tileNum, u16 palNum); u8 ListMenuInit(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow); -u8 ListMenuInitInRect(struct ListMenuTemplate *listMenuTemplate, struct ListMenuWindowRect *arg1, u16 scrollOffset, u16 selectedRow); +u8 ListMenuInitInRect(struct ListMenuTemplate *listMenuTemplate, struct ListMenuWindowRect *rect, u16 scrollOffset, u16 selectedRow); s32 ListMenu_ProcessInput(u8 listTaskId); void DestroyListMenuTask(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow); void RedrawListMenu(u8 listTaskId); @@ -111,10 +111,10 @@ void ListMenuGetCurrentItemArrayId(u8 listTaskId, u16 *arrayId); void ListMenuGetScrollAndRow(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow); u16 ListMenuGetYCoordForPrintingArrowCursor(u8 listTaskId); void ListMenuOverrideSetColors(u8 cursorPal, u8 fillValue, u8 cursorShadowPal); -void ListMenuDefaultCursorMoveFunc(s32 arg0, u8 arg1, struct ListMenu *list); +void ListMenuDefaultCursorMoveFunc(s32 itemIndex, u8 onInit, struct ListMenu *list); s32 ListMenuGetUnkIndicatorsStructFields(u8 taskId, u8 field); void ListMenuSetUnkIndicatorsStructField(u8 taskId, u8 field, s32 value); -u8 AddScrollIndicatorArrowPair(const struct ScrollArrowsTemplate *arrowInfo, u16 *arg1); +u8 AddScrollIndicatorArrowPair(const struct ScrollArrowsTemplate *arrowInfo, u16 *scrollOffset); u8 AddScrollIndicatorArrowPairParameterized(u32 arrowType, s32 commonPos, s32 firstPos, s32 secondPos, s32 fullyDownThreshold, s32 tileTag, s32 palTag, u16 *currItemPtr); void RemoveScrollIndicatorArrowPair(u8 taskId); void Task_ScrollIndicatorArrowPairOnMainMenu(u8 taskId); diff --git a/include/main_menu.h b/include/main_menu.h index 1944f4ecc..5f92719d5 100644 --- a/include/main_menu.h +++ b/include/main_menu.h @@ -2,6 +2,6 @@ #define GUARD_MAIN_MENU_H void CB2_InitMainMenu(void); -void CreateYesNoMenuParameterized(u8 a, u8 b, u16 c, u16 d, u8 e, u8 f); +void CreateYesNoMenuParameterized(u8 x, u8 y, u16 baseTileNum, u16 baseBlock, u8 yesNoPalNum, u8 winPalNum); #endif // GUARD_MAIN_MENU_H diff --git a/include/mauville_old_man.h b/include/mauville_old_man.h index b22294f1b..9e5986ee8 100644 --- a/include/mauville_old_man.h +++ b/include/mauville_old_man.h @@ -7,8 +7,8 @@ void SetMauvilleOldMan(void); u8 GetCurrentMauvilleOldMan(void); void SetMauvilleOldManObjEventGfx(void); void SanitizeMauvilleOldManForRuby(OldMan *dest); -void SanitizeReceivedRubyOldMan(union OldMan * oldMan, u32 r1, u32 r6); -void SanitizeReceivedEmeraldOldMan(union OldMan * oldMan, u32 unused, u32 a2); +void SanitizeReceivedRubyOldMan(union OldMan * oldMan, u32 version, u32 language); +void SanitizeReceivedEmeraldOldMan(union OldMan * oldMan, u32 version, u32 language); void ResetMauvilleOldManFlag(void); #endif // GUARD_MAUVILLE_OLD_MAN_H diff --git a/include/menu.h b/include/menu.h index bf3f56aea..c38e87cbd 100644 --- a/include/menu.h +++ b/include/menu.h @@ -56,9 +56,9 @@ void SetStandardWindowBorderStyle(u8 windowId, bool8 copyToVram); void DisplayYesNoMenuDefaultYes(void); u32 GetPlayerTextSpeed(void); u8 GetPlayerTextSpeedDelay(void); -void Menu_LoadStdPalAt(u16 arg0); -void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextPrinterTemplate *, u16)); -void BgDmaFill(u32 bg, u8 a1, int a2, int a3); +void Menu_LoadStdPalAt(u16 offset); +void AddTextPrinterWithCallbackForMessage(bool8 canSpeedUp, void (*callback)(struct TextPrinterTemplate *, u16)); +void BgDmaFill(u32 bg, u8 value, int offset, int size); void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const u8 *color, s8 speed, const u8 *str); void ClearStdWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram); void SetWindowTemplateFields(struct WindowTemplate* template, u8 priority, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 palNum, u16 baseBlock); @@ -69,7 +69,7 @@ u8 InitMenuInUpperLeftCornerNormal(u8 windowId, u8 numItems, u8 initialCursorPos u8 Menu_GetCursorPos(void); s8 Menu_ProcessInput(void); s8 Menu_ProcessInputNoWrap(void); -void BlitMenuInfoIcon(u8 winId, u8 a2, u16 x, u16 y); +void BlitMenuInfoIcon(u8 windowId, u8 iconId, u16 x, u16 y); void ResetTempTileDataBuffers(void); void *DecompressAndCopyTileDataToVram(u8 bgId, const void *src, u32 size, u16 offset, u8 mode); bool8 FreeTempTileDataBuffersIfPossible(void); @@ -81,14 +81,14 @@ s8 ProcessMenuInput_other(void); void DoScheduledBgTilemapCopiesToVram(void); void ClearScheduledBgCopiesToVram(void); void AddTextPrinterParameterized4(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, const u8 *color, s8 speed, const u8 *str); -void DrawDialogFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 a2, u8 a3); +void DrawDialogFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 tileNum, u8 paletteNum); void PrintMenuActionTextsInUpperLeftCorner(u8 windowId, u8 optionsNo, const struct MenuAction *actions, const u8 *actionIds); void ClearDialogWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram); void *malloc_and_decompress(const void *src, u32 *sizeOut); u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode); void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress); -void PrintMenuActionTexts(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a8); -void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8); +void PrintMenuActionTexts(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds); +void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 horizontalCount, u8 verticalCount, const struct MenuAction *menuActions, const u8 *actionIds); u8 InitMenuActionGrid(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCursorPos); u8 ChangeMenuGridCursorPosition(s8 deltaX, s8 deltaY); u8 GetStartMenuWindowId(void); diff --git a/include/menu_helpers.h b/include/menu_helpers.h index 0e063e5c1..f9a418a93 100644 --- a/include/menu_helpers.h +++ b/include/menu_helpers.h @@ -18,11 +18,11 @@ struct YesNoFuncTable void ResetVramOamAndBgCntRegs(void); void ResetAllBgsCoordinates(void); void SetVBlankHBlankCallbacksToNull(void); -void DisplayMessageAndContinueTask(u8 taskId, u8 windowId, u16 arg2, u8 arg3, u8 fontId, u8 textSpeed, const u8 *string, void *taskFunc); +void DisplayMessageAndContinueTask(u8 taskId, u8 windowId, u16 tileNum, u8 paletteNum, u8 fontId, u8 textSpeed, const u8 *string, void *taskFunc); bool16 RunTextPrintersRetIsActive(u8 textPrinterId); void DoYesNoFuncWithChoice(u8 taskId, const struct YesNoFuncTable *data); -void CreateYesNoMenuWithCallbacks(u8 taskId, const struct WindowTemplate *template, u8 arg2, u8 arg3, u8 arg4, u16 tileStart, u8 palette, const struct YesNoFuncTable *yesNo); -bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1); +void CreateYesNoMenuWithCallbacks(u8 taskId, const struct WindowTemplate *template, u8 unused1, u8 unused2, u8 unused3, u16 tileStart, u8 palette, const struct YesNoFuncTable *yesNo); +bool8 AdjustQuantityAccordingToDPadInput(s16 *quantity, u16 max); u8 GetLRKeysPressed(void); u8 GetLRKeysPressedAndHeld(void); bool8 IsHoldingItemAllowed(u16 itemId); diff --git a/include/menu_specialized.h b/include/menu_specialized.h index d1e30d4d6..10a211046 100644 --- a/include/menu_specialized.h +++ b/include/menu_specialized.h @@ -95,7 +95,7 @@ void ConditionGraph_Draw(struct ConditionGraph *graph); bool8 ConditionGraph_TryUpdate(struct ConditionGraph *graph); void ConditionGraph_Update(struct ConditionGraph *graph); void ConditionGraph_CalcPositions(u8 *conditions, struct UCoords16 *positions); -void ConditionGraph_SetNewPositions(struct ConditionGraph *graph, struct UCoords16 *arg1, struct UCoords16 *arg2); +void ConditionGraph_SetNewPositions(struct ConditionGraph *graph, struct UCoords16 *old, struct UCoords16 *new); // Condition menu bool8 ConditionMenu_UpdateMonEnter(struct ConditionGraph *graph, s16 *x); diff --git a/include/overworld.h b/include/overworld.h index b8794ea70..adaa6aad0 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -77,7 +77,7 @@ void SetWarpDestinationToMapWarp(s8 mapGroup, s8 mapNum, s8 warpId); void SetDynamicWarp(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId); void SetDynamicWarpWithCoords(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void SetWarpDestinationToDynamicWarp(u8 unused); -void SetWarpDestinationToHealLocation(u8 a1); +void SetWarpDestinationToHealLocation(u8 healLocationId); void SetWarpDestinationToLastHealLocation(void); void SetLastHealLocationWarp(u8 healLocationId); void UpdateEscapeWarp(s16 x, s16 y); @@ -86,7 +86,7 @@ void SetWarpDestinationToEscapeWarp(void); void SetFixedDiveWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void SetFixedHoleWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void SetWarpDestinationToFixedHoleWarp(s16 x, s16 y); -void SetContinueGameWarpToHealLocation(u8 a1); +void SetContinueGameWarpToHealLocation(u8 healLocationId); void SetContinueGameWarpToDynamicWarp(int unused); const struct MapConnection *GetMapConnection(u8 dir); bool8 SetDiveWarpEmerge(u16 x, u16 y); @@ -130,7 +130,7 @@ void CB1_Overworld(void); void CB2_OverworldBasic(void); void CB2_Overworld(void); void SetMainCallback1(void (*cb)(void)); -void SetUnusedCallback(void *a0); +void SetUnusedCallback(void *func); void CB2_NewGame(void); void CB2_WhiteOut(void); void CB2_LoadMap(void); diff --git a/include/pokeball.h b/include/pokeball.h index 297788db1..1149791b8 100644 --- a/include/pokeball.h +++ b/include/pokeball.h @@ -34,8 +34,8 @@ extern const struct SpriteTemplate gBallSpriteTemplates[]; #define POKEBALL_OPPONENT_SENDOUT 0xFE u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow); -void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 battler, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 g, u32 h, u16 species); -u8 CreateTradePokeballSprite(u8 a, u8 b, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 g, u32 h); +void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 delay, u32 fadePalettes, u16 species); +u8 CreateTradePokeballSprite(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 delay, u32 fadePalettes); void StartHealthboxSlideIn(u8 battler); void DoHitAnimHealthboxEffect(u8 battler); void LoadBallGfx(u8 ballId); diff --git a/include/pokemon.h b/include/pokemon.h index ec57e525d..4a9ab8d08 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -213,8 +213,8 @@ struct BaseStats /* 0x0A */ u16 evYield_Speed:2; /* 0x0B */ u16 evYield_SpAttack:2; /* 0x0B */ u16 evYield_SpDefense:2; - /* 0x0C */ u16 item1; - /* 0x0E */ u16 item2; + /* 0x0C */ u16 itemCommon; + /* 0x0E */ u16 itemRare; /* 0x10 */ u8 genderRatio; /* 0x11 */ u8 eggCycles; /* 0x12 */ u8 friendship; @@ -342,7 +342,7 @@ u8 GetBoxMonGender(struct BoxPokemon *boxMon); u8 GetGenderFromSpeciesAndPersonality(u16 species, u32 personality); void SetMultiuseSpriteTemplateToPokemon(u16 speciesTag, u8 battlerPosition); void SetMultiuseSpriteTemplateToTrainerBack(u16 trainerSpriteId, u8 battlerPosition); -void SetMultiuseSpriteTemplateToTrainerFront(u16 arg0, u8 battlerPosition); +void SetMultiuseSpriteTemplateToTrainerFront(u16 trainerPicId, u8 battlerPosition); // These are full type signatures for GetMonData() and GetBoxMonData(), // but they are not used since some code erroneously omits the third arg. @@ -387,11 +387,11 @@ u16 SpeciesToNationalPokedexNum(u16 species); u16 SpeciesToHoennPokedexNum(u16 species); u16 HoennToNationalOrder(u16 hoennNum); u16 SpeciesToCryId(u16 species); -void DrawSpindaSpots(u16 species, u32 personality, u8 *dest, u8 a4); +void DrawSpindaSpots(u16 species, u32 personality, u8 *dest, bool8 isFrontPic); void EvolutionRenameMon(struct Pokemon *mon, u16 oldSpecies, u16 newSpecies); u8 GetPlayerFlankId(void); u16 GetLinkTrainerFlankId(u8 id); -s32 GetBattlerMultiplayerId(u16 a1); +s32 GetBattlerMultiplayerId(u16 id); u8 GetTrainerEncounterMusicId(u16 trainerOpponentId); u16 ModifyStatByNature(u8 nature, u16 n, u8 statIndex); void AdjustFriendship(struct Pokemon *mon, u8 event); @@ -432,8 +432,8 @@ void SetWildMonHeldItem(void); bool8 IsMonShiny(struct Pokemon *mon); bool8 IsShinyOtIdPersonality(u32 otId, u32 personality); const u8 *GetTrainerPartnerName(void); -void BattleAnimateFrontSprite(struct Sprite* sprite, u16 species, bool8 noCry, u8 arg3); -void DoMonFrontSpriteAnimation(struct Sprite* sprite, u16 species, bool8 noCry, u8 arg3); +void BattleAnimateFrontSprite(struct Sprite* sprite, u16 species, bool8 noCry, u8 panMode); +void DoMonFrontSpriteAnimation(struct Sprite* sprite, u16 species, bool8 noCry, u8 panModeAnimFlag); void PokemonSummaryDoMonAnimation(struct Sprite* sprite, u16 species, bool8 oneFrame); void StopPokemonAnimationDelayTask(void); void BattleAnimateBackSprite(struct Sprite* sprite, u16 species); diff --git a/include/pokemon_storage_system.h b/include/pokemon_storage_system.h index b7fca2331..eb25c0ff2 100644 --- a/include/pokemon_storage_system.h +++ b/include/pokemon_storage_system.h @@ -26,7 +26,7 @@ struct PokemonStorage extern struct PokemonStorage *gPokemonStoragePtr; -void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 arg2, u8 arg3, s32 bytesToBuffer); +void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero2, s32 bytesToBuffer); u8 CountMonsInBox(u8 boxId); s16 GetFirstFreeBoxSpot(u8 boxId); u8 CountPartyAliveNonEggMonsExcept(u8 slotToIgnore); @@ -52,7 +52,7 @@ void ZeroBoxMonAt(u8 boxId, u8 boxPosition); void BoxMonAtToMon(u8 boxId, u8 boxPosition, struct Pokemon *dst); struct BoxPokemon *GetBoxedMonPtr(u8 boxId, u8 boxPosition); u8 *GetBoxNamePtr(u8 boxId); -s16 AdvanceStorageMonIndex(struct BoxPokemon *boxMons, u8 currIndex, u8 maxIndex, u8 arg3); +s16 AdvanceStorageMonIndex(struct BoxPokemon *boxMons, u8 currIndex, u8 maxIndex, u8 mode); bool8 CheckFreePokemonStorageSpace(void); bool32 CheckBoxMonSanityAt(u32 boxId, u32 boxPosition); u32 CountStorageNonEggMons(void); diff --git a/include/pokenav.h b/include/pokenav.h index d3edb1422..593c68489 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -356,10 +356,10 @@ void MatchCall_GetNameAndDesc(u32 idx, const u8 **desc, const u8 **name); // pokenav_main_menu.c bool32 InitPokenavMainMenu(void); void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 bufferOffset, u32 size); -void RunMainMenuLoopedTask(u32 a0); +void RunMainMenuLoopedTask(u32 state); u32 IsActiveMenuLoopTaskActive(void); -void LoadLeftHeaderGfxForIndex(u32 arg0); -void ShowLeftHeaderGfx(u32 menugfxId, bool32 arg1, bool32 isOnRightSide); +void LoadLeftHeaderGfxForIndex(u32 menuGfxId); +void ShowLeftHeaderGfx(u32 menugfxId, bool32 isMain, bool32 isOnRightSide); void PokenavFadeScreen(s32 fadeType); bool32 AreLeftHeaderSpritesMoving(void); void InitBgTemplates(const struct BgTemplate *templates, int count); @@ -373,7 +373,7 @@ void PokenavCopyPalette(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u1 void FadeToBlackExceptPrimary(void); struct Sprite *GetSpinningPokenavSprite(void); void HideSpinningPokenavSprite(void); -void UpdateRegionMapRightHeaderTiles(u32 arg0); +void UpdateRegionMapRightHeaderTiles(u32 menuGfxId); void HideMainOrSubMenuLeftHeader(u32 id, bool32 onRightSide); void SlideMenuHeaderUp(void); void PokenavFillPalette(u32 palIndex, u16 fillValue); @@ -412,13 +412,13 @@ int GetNumberRegistered(void); struct PokenavMatchCallEntry *GetMatchCallList(void); u16 GetMatchCallMapSec(int); bool32 ShouldDrawRematchPokeballIcon(int index); -void ClearRematchPokeballIcon(u16 windowId, u32 a1); +void ClearRematchPokeballIcon(u16 windowId, u32 tileOffset); int GetMatchCallTrainerPic(int index); const u8 *GetMatchCallFlavorText(int index, int textType); const u8 *GetMatchCallMessageText(int index, bool8 *newRematchRequest); u16 GetMatchCallOptionCursorPos(void); -u16 GetMatchCallOptionId(int arg0); -void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntry * arg0, u8 *str); +u16 GetMatchCallOptionId(int optionId); +void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntry *matchCallEntry, u8 *str); u8 GetMatchTableMapSectionId(int rematchIndex); int GetIndexDeltaOfNextCheckPageDown(int index); int GetIndexDeltaOfNextCheckPageUp(int index); diff --git a/include/region_map.h b/include/region_map.h index 02d711afa..85793badc 100644 --- a/include/region_map.h +++ b/include/region_map.h @@ -99,7 +99,7 @@ u8 DoRegionMapInputCallback(void); bool8 UpdateRegionMapZoom(void); void FreeRegionMapIconResources(void); u16 GetRegionMapSecIdAt(u16 x, u16 y); -void CreateRegionMapPlayerIcon(u16 x, u16 y); +void CreateRegionMapPlayerIcon(u16 tileTag, u16 paletteTag); void CreateRegionMapCursor(u16 tileTag, u16 paletteTag); bool32 IsEventIslandMapSecId(u8 mapSecId); u8 *GetMapName(u8 *, u16, u16); diff --git a/include/scanline_effect.h b/include/scanline_effect.h index 5bd8b5546..ae534d969 100644 --- a/include/scanline_effect.h +++ b/include/scanline_effect.h @@ -43,6 +43,6 @@ void ScanlineEffect_Stop(void); void ScanlineEffect_Clear(void); void ScanlineEffect_SetParams(struct ScanlineEffectParams); void ScanlineEffect_InitHBlankDmaTransfer(void); -u8 ScanlineEffect_InitWave(u8 startLine, u8 endLine, u8 frequency, u8 amplitude, u8 delayInterval, u8 regOffset, bool8 a7); +u8 ScanlineEffect_InitWave(u8 startLine, u8 endLine, u8 frequency, u8 amplitude, u8 delayInterval, u8 regOffset, bool8 applyBattleBgOffsets); #endif // GUARD_SCANLINE_EFFECT_H diff --git a/include/trade.h b/include/trade.h index a0cb320a8..27b5ee8bd 100644 --- a/include/trade.h +++ b/include/trade.h @@ -12,8 +12,8 @@ extern const struct WindowTemplate gTradeEvolutionSceneYesNoWindowTemplate; s32 GetGameProgressForLinkTrade(void); void CB2_StartCreateTradeMenu(void); void CB2_LinkTrade(void); -int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData a0, u16, u16, u8); -int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData a0, struct RfuGameCompatibilityData a1, u16 a2, u16 a3, u8 a4, u16 a5, u8 a6); +int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isEventLegal); +int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isEventLegal); int CanSpinTradeMon(struct Pokemon*, u16); void InitTradeSequenceBgGpuRegs(void); void LinkTradeDrawWindow(void); diff --git a/include/trainer_card.h b/include/trainer_card.h index f5e73da83..f14335ae8 100644 --- a/include/trainer_card.h +++ b/include/trainer_card.h @@ -69,7 +69,7 @@ u32 CountPlayerTrainerStars(void); u8 GetTrainerCardStars(u8 cardId); void CopyTrainerCardData(struct TrainerCard *dst, struct TrainerCard *src, u8 gameVersion); void ShowPlayerTrainerCard(void (*callback)(void)); -void ShowTrainerCardInLink(u8 arg0, void (*callback)(void)); +void ShowTrainerCardInLink(u8 cardId, void (*callback)(void)); void TrainerCard_GenerateCardForLinkPlayer(struct TrainerCard *); #endif // GUARD_TRAINER_CARD_H diff --git a/spritesheet_rules.mk b/spritesheet_rules.mk index 9fb184638..87293669c 100644 --- a/spritesheet_rules.mk +++ b/spritesheet_rules.mk @@ -674,3 +674,6 @@ $(FLDEFFGFXDIR)/secret_power_tree.4bpp: %.4bpp: %.png $(FLDEFFGFXDIR)/record_mix_lights.4bpp: %.4bpp: %.png $(GFX) $< $@ -mwidth 4 -mheight 1 + +graphics/door_anims/battle_tower_multi_corridor.4bpp: %.4bpp: %.png + $(GFX) $< $@ -mwidth 2 -mheight 4 diff --git a/src/agb_flash_1m.c b/src/agb_flash_1m.c index e249fab9a..6fc4f3d60 100644 --- a/src/agb_flash_1m.c +++ b/src/agb_flash_1m.c @@ -3,7 +3,7 @@ static const char AgbLibFlashVersion[] = "FLASH1M_V103"; -const struct FlashSetupInfo * const sSetupInfos[] = +static const struct FlashSetupInfo * const sSetupInfos[] = { &MX29L010, &LE26FV10N1TS, diff --git a/src/bard_music.c b/src/bard_music.c index bdc5ac808..dd986371d 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -7,9 +7,9 @@ #include "data/bard_music/default_sound.h" #include "data/bard_music/length_table.h" -static s16 CalcWordPitch(int arg0, int songPos) +static s16 CalcWordPitch(int pitchIdx, int songPos) { - return sBardSoundPitchTables[arg0][songPos]; + return sBardSoundPitchTables[pitchIdx][songPos]; } const struct BardSound *GetWordSounds(u16 word) diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 1a4bcd6e0..034bb59e8 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -4,6 +4,7 @@ #include "battle_ai_util.h" #include "battle_anim.h" #include "battle_controllers.h" +#include "battle_main.h" #include "battle_setup.h" #include "data.h" #include "pokemon.h" @@ -25,18 +26,18 @@ void GetAIPartyIndexes(u32 battlerId, s32 *firstId, s32 *lastId) { if (BATTLE_TWO_VS_ONE_OPPONENT && (battlerId & BIT_SIDE) == B_SIDE_OPPONENT) { - *firstId = 0, *lastId = 6; + *firstId = 0, *lastId = PARTY_SIZE; } else if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_INGAME_PARTNER | BATTLE_TYPE_TOWER_LINK_MULTI)) { if ((battlerId & BIT_FLANK) == B_FLANK_LEFT) - *firstId = 0, *lastId = 3; + *firstId = 0, *lastId = PARTY_SIZE / 2; else - *firstId = 3, *lastId = 6; + *firstId = PARTY_SIZE / 2, *lastId = PARTY_SIZE; } else { - *firstId = 0, *lastId = 6; + *firstId = 0, *lastId = PARTY_SIZE; } } @@ -149,9 +150,9 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) if (HasSuperEffectiveMoveAgainstOpponents(TRUE) && Random() % 3 != 0) return FALSE; - if (gLastLandedMoves[gActiveBattler] == 0) + if (gLastLandedMoves[gActiveBattler] == MOVE_NONE) return FALSE; - if (gLastLandedMoves[gActiveBattler] == 0xFFFF) + if (gLastLandedMoves[gActiveBattler] == MOVE_UNAVAILABLE) return FALSE; if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0) return FALSE; @@ -236,13 +237,16 @@ static bool8 ShouldSwitchIfNaturalCure(void) if (gBattleMons[gActiveBattler].hp < gBattleMons[gActiveBattler].maxHP / 2) return FALSE; - if ((gLastLandedMoves[gActiveBattler] == 0 || gLastLandedMoves[gActiveBattler] == 0xFFFF) && Random() & 1) + if ((gLastLandedMoves[gActiveBattler] == MOVE_NONE + || gLastLandedMoves[gActiveBattler] == MOVE_UNAVAILABLE) + && Random() & 1) { *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE; BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SWITCH, 0); return TRUE; } - else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0 && Random() & 1) + else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0 + && Random() & 1) { *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE; BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SWITCH, 0); @@ -340,9 +344,9 @@ static bool8 FindMonWithFlagsAndSuperEffective(u16 flags, u8 moduloPercent) s32 i, j; u16 move; - if (gLastLandedMoves[gActiveBattler] == 0) + if (gLastLandedMoves[gActiveBattler] == MOVE_NONE) return FALSE; - if (gLastLandedMoves[gActiveBattler] == 0xFFFF) + if (gLastLandedMoves[gActiveBattler] == MOVE_UNAVAILABLE) return FALSE; if (gLastHitBy[gActiveBattler] == 0xFF) return FALSE; diff --git a/src/battle_anim_dragon.c b/src/battle_anim_dragon.c index 57ed24e1e..54304732e 100644 --- a/src/battle_anim_dragon.c +++ b/src/battle_anim_dragon.c @@ -14,7 +14,7 @@ static void AnimDragonRushStep(struct Sprite *sprite); static void AnimSpinningDracoMeteor(struct Sprite *sprite); static void AnimSpinningDracoMeteorFinish(struct Sprite *sprite); -EWRAM_DATA static u16 gUnusedOverheatData[7] = {0}; +EWRAM_DATA static u16 sUnusedOverheatData[7] = {0}; static const union AnimCmd sAnim_OutrageOverheatFire_0[] = { @@ -555,7 +555,7 @@ void AnimOverheatFlame(struct Sprite *sprite) sprite->data[3] = gBattleAnimArgs[3]; sprite->callback = AnimOverheatFlame_Step; for (i = 0; i < 7; i++) - gUnusedOverheatData[i] = sprite->data[i]; + sUnusedOverheatData[i] = sprite->data[i]; } static void AnimOverheatFlame_Step(struct Sprite *sprite) diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index c66bc9726..ddd625a87 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -113,7 +113,7 @@ static void AnimHornHit_Step(struct Sprite *); static void AnimSuperFang(struct Sprite *); static void AnimWavyMusicNotes(struct Sprite *); static void AnimWavyMusicNotes_Step(struct Sprite *); -static void AnimWavyMusicNotesGetNextPos(s16, s16, s16 *, s16 *, s8); +static void AnimWavyMusicNotes_CalcVelocity(s16, s16, s16 *, s16 *, s8); static void AnimFlyingMusicNotes(struct Sprite *); static void AnimFlyingMusicNotes_Step(struct Sprite *); static void AnimBellyDrumHand(struct Sprite *); @@ -5449,7 +5449,7 @@ static void AnimLockOnTarget_Step4(struct Sprite* sprite) sprite->data[1] = 0; } - BlendPalettes(GetBattleBgPalettesMask(1, 1, 1, 1, 1, 0, 0), sprite->data[1], RGB(31, 31, 31)); + BlendPalettes(GetBattlePalettesMask(TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE), sprite->data[1], RGB(31, 31, 31)); if (sprite->data[1] == 16) { int pal; @@ -6104,7 +6104,7 @@ static void AnimMoonlightSparkle_Step(struct Sprite* sprite) void AnimTask_MoonlightEndFade(u8 taskId) { - int a = GetBattleBgPalettesMask(1, 0, 0, 0, 0, 0, 0) & 0xFFFF; + int a = GetBattlePalettesMask(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) & 0xFFFF; int b; int c; int d; @@ -6385,79 +6385,87 @@ void AnimTask_MusicNotesClearRainbowBlend(u8 taskId) DestroyAnimVisualTask(taskId); } +#define sMoveTimer data[0] +#define sBlendTableIdx data[1] +#define sBlendTimer data[2] +#define sBlendCycleTime data[3] +#define sX data[4] +#define sY data[5] +#define sVelocX data[6] +#define sVelocY data[7] + static void AnimWavyMusicNotes(struct Sprite* sprite) { u8 index; - u8 a; - u8 b; + u8 x, y; SetSpriteCoordsToAnimAttackerCoords(sprite); StartSpriteAnim(sprite, gBattleAnimArgs[0]); if ((index = IndexOfSpritePaletteTag(gParticlesColorBlendTable[gBattleAnimArgs[1]][0])) != 0xFF) sprite->oam.paletteNum = index; - sprite->data[1] = gBattleAnimArgs[1]; - sprite->data[2] = 0; - sprite->data[3] = gBattleAnimArgs[2]; + sprite->sBlendTableIdx = gBattleAnimArgs[1]; + sprite->sBlendTimer = 0; + sprite->sBlendCycleTime = gBattleAnimArgs[2]; if (IsContest()) { - a = 48; - b = 40; + x = 48; + y = 40; } else { - a = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); - b = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); + x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); + y = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); } - sprite->data[4] = sprite->x << 4; - sprite->data[5] = sprite->y << 4; - AnimWavyMusicNotesGetNextPos(a - sprite->x, b - sprite->y, &sprite->data[6], &sprite->data[7], 40); + sprite->sX = sprite->x << 4; + sprite->sY = sprite->y << 4; + AnimWavyMusicNotes_CalcVelocity(x - sprite->x, y - sprite->y, &sprite->sVelocX, &sprite->sVelocY, 40); sprite->callback = AnimWavyMusicNotes_Step; } -static void AnimWavyMusicNotesGetNextPos(s16 a, s16 b, s16* c, s16* d, s8 e) +static void AnimWavyMusicNotes_CalcVelocity(s16 x, s16 y, s16* velocX, s16* velocY, s8 xSpeedFactor) { - int f; - int g; - if (a < 0) - e = -e; + int x2; + int time; + if (x < 0) + xSpeedFactor = -xSpeedFactor; - f = a << 8; - g = f / e; - if (g == 0) - g = 1; + x2 = x * 256; + time = x2 / xSpeedFactor; + if (time == 0) + time = 1; - *c = f / g; - *d = (b << 8) / g; + *velocX = x2 / time; + *velocY = (y * 256) / time; } static void AnimWavyMusicNotes_Step(struct Sprite* sprite) { - s16 y, yDelta; + s16 y, trigIdx; u8 index; - sprite->data[0]++; - yDelta = sprite->data[0] * 5 - ((sprite->data[0] * 5 / 256) << 8); - sprite->data[4] += sprite->data[6]; - sprite->data[5] += sprite->data[7]; - sprite->x = sprite->data[4] >> 4; - sprite->y = sprite->data[5] >> 4; - sprite->y2 = Sin(yDelta, 15); + sprite->sMoveTimer++; + trigIdx = sprite->sMoveTimer * 5 - ((sprite->sMoveTimer * 5 / 256) << 8); + sprite->sX += sprite->sVelocX; + sprite->sY += sprite->sVelocY; + sprite->x = sprite->sX >> 4; + sprite->y = sprite->sY >> 4; + sprite->y2 = Sin(trigIdx, 15); y = sprite->y; - if (sprite->x < -16 || sprite->x > 256 || y < -16 || y > 128) + if (sprite->x < -16 || sprite->x > DISPLAY_WIDTH + 16 || y < -16 || y > DISPLAY_HEIGHT - 32) { DestroySpriteAndMatrix(sprite); } else { - if (sprite->data[3] && ++sprite->data[2] > sprite->data[3]) + if (sprite->sBlendCycleTime && ++sprite->sBlendTimer > sprite->sBlendCycleTime) { - sprite->data[2] = 0; - if (++sprite->data[1] > 3) - sprite->data[1] = 0; + sprite->sBlendTimer = 0; + if (++sprite->sBlendTableIdx > (int)ARRAY_COUNT(gParticlesColorBlendTable) - 1) + sprite->sBlendTableIdx = 0; - index = IndexOfSpritePaletteTag(gParticlesColorBlendTable[sprite->data[1]][0]); + index = IndexOfSpritePaletteTag(gParticlesColorBlendTable[sprite->sBlendTableIdx][0]); if (index != 0xFF) sprite->oam.paletteNum = index; } @@ -6573,7 +6581,7 @@ void SetSpriteNextToMonHead(u8 battler, struct Sprite* sprite) void AnimThoughtBubble(struct Sprite* sprite) { - u8 a; + u8 animNum; u8 battler; if (gBattleAnimArgs[0] == 0) battler = gBattleAnimAttacker; @@ -6581,10 +6589,10 @@ void AnimThoughtBubble(struct Sprite* sprite) battler = gBattleAnimTarget; SetSpriteNextToMonHead(battler, sprite); - a = (GetBattlerSide(battler) == B_SIDE_PLAYER) ? 0 : 1; + animNum = (GetBattlerSide(battler) == B_SIDE_PLAYER) ? 0 : 1; sprite->data[0] = gBattleAnimArgs[1]; - sprite->data[1] = a + 2; - StartSpriteAnim(sprite, a); + sprite->data[1] = animNum + 2; + StartSpriteAnim(sprite, animNum); StoreSpriteCallbackInData6(sprite, AnimThoughtBubble_Step); sprite->callback = RunStoredCallbackWhenAnimEnds; } diff --git a/src/battle_anim_effects_2.c b/src/battle_anim_effects_2.c index ab2794e7e..f1ed8a473 100755 --- a/src/battle_anim_effects_2.c +++ b/src/battle_anim_effects_2.c @@ -3152,7 +3152,7 @@ static void AnimTask_FakeOut_Step2(u8 taskId) { gTasks[taskId].data[11] = 0x88; SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_LIGHTEN); - BlendPalettes(GetBattleBgPalettesMask(1, 0, 0, 0, 0, 0, 0), 16, RGB(31, 31, 31)); + BlendPalettes(GetBattlePalettesMask(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), 16, RGB(31, 31, 31)); } else if (gTasks[taskId].data[10] > 4) { diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c index cf57d23db..6a12331ed 100755 --- a/src/battle_anim_effects_3.c +++ b/src/battle_anim_effects_3.c @@ -1306,7 +1306,7 @@ void AnimTask_SmokescreenImpact(u8 taskId) SmokescreenImpact( GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) + 8, GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + 8, - 0); + FALSE); DestroyAnimVisualTask(taskId); } @@ -3810,6 +3810,26 @@ void AnimTask_SlideMonForFocusBand(u8 taskId) gTasks[taskId].func = AnimTask_SlideMonForFocusBand_Step1; } +#define IDX_ACTIVE_SPRITES 2 // Used by the sprite callback to modify the number of active sprites + +// Task data for AnimTask_SquishAndSweatDroplets +#define tState data[0] +#define tTimer data[1] +#define tActiveSprites data[IDX_ACTIVE_SPRITES] +#define tNumSquishes data[3] +#define tBaseX data[4] +#define tBaseY data[5] +#define tSubpriority data[6] +// data[7]-data[15] used by PrepareAffineAnimInTaskData +#define tBattlerSpriteId data[15] + +// Sprite data for AnimFacadeSweatDrop +#define sTimer data[0] +#define sVelocX data[1] +#define sVelocY data[2] +#define sTaskId data[3] +#define sActiveSpritesIdx data[4] + // Squishes the mon vertically and emits sweat droplets a few times. // arg 0: battler // arg 1: num squishes @@ -3821,20 +3841,20 @@ void AnimTask_SquishAndSweatDroplets(u8 taskId) if (!gBattleAnimArgs[1]) DestroyAnimVisualTask(taskId); - task->data[0] = 0; - task->data[1] = 0; - task->data[2] = 0; - task->data[3] = gBattleAnimArgs[1]; + task->tState = 0; + task->tTimer = 0; + task->tActiveSprites = 0; + task->tNumSquishes = gBattleAnimArgs[1]; if (gBattleAnimArgs[0] == ANIM_ATTACKER) battler = gBattleAnimAttacker; else battler = gBattleAnimTarget; - task->data[4] = GetBattlerSpriteCoord(battler, BATTLER_COORD_X); - task->data[5] = GetBattlerSpriteCoord(battler, BATTLER_COORD_Y); - task->data[6] = GetBattlerSpriteSubpriority(battler); - task->data[15] = GetAnimBattlerSpriteId(gBattleAnimArgs[0]); - PrepareAffineAnimInTaskData(task, task->data[15], gFacadeSquishAffineAnimCmds); + task->tBaseX = GetBattlerSpriteCoord(battler, BATTLER_COORD_X); + task->tBaseY = GetBattlerSpriteCoord(battler, BATTLER_COORD_Y); + task->tSubpriority = GetBattlerSpriteSubpriority(battler); + task->tBattlerSpriteId = GetAnimBattlerSpriteId(gBattleAnimArgs[0]); + PrepareAffineAnimInTaskData(task, task->tBattlerSpriteId, gFacadeSquishAffineAnimCmds); task->func = AnimTask_SquishAndSweatDroplets_Step; } @@ -3842,37 +3862,40 @@ static void AnimTask_SquishAndSweatDroplets_Step(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: - task->data[1]++; - if (task->data[1] == 6) + task->tTimer++; + if (task->tTimer == 6) CreateSweatDroplets(taskId, TRUE); - if (task->data[1] == 18) + if (task->tTimer == 18) CreateSweatDroplets(taskId, FALSE); if (!RunAffineAnimFromTaskData(task)) { - if (--task->data[3] == 0) + if (--task->tNumSquishes == 0) { - task->data[0]++; + // Animation is finished + task->tState++; } else { - task->data[1] = 0; - PrepareAffineAnimInTaskData(task, task->data[15], gFacadeSquishAffineAnimCmds); + // Animation continues, more droplet sprites to create + task->tTimer = 0; + PrepareAffineAnimInTaskData(task, task->tBattlerSpriteId, gFacadeSquishAffineAnimCmds); } } break; case 1: - if (task->data[2] == 0) + // Wait for sprites to be destroyed before ending task + if (task->tActiveSprites == 0) DestroyAnimVisualTask(taskId); break; } } -static void CreateSweatDroplets(u8 taskId, bool8 arg1) +static void CreateSweatDroplets(u8 taskId, bool8 lowerDroplets) { u8 i; s8 xOffset, yOffset; @@ -3881,7 +3904,7 @@ static void CreateSweatDroplets(u8 taskId, bool8 arg1) s16 yCoords[2]; task = &gTasks[taskId]; - if (!arg1) + if (!lowerDroplets) { xOffset = 18; yOffset = -20; @@ -3892,39 +3915,54 @@ static void CreateSweatDroplets(u8 taskId, bool8 arg1) yOffset = 20; } - xCoords[0] = task->data[4] - xOffset; - xCoords[1] = task->data[4] - xOffset - 4; - xCoords[2] = task->data[4] + xOffset; - xCoords[3] = task->data[4] + xOffset + 4; - yCoords[0] = task->data[5] + yOffset; - yCoords[1] = task->data[5] + yOffset + 6; + xCoords[0] = task->tBaseX - xOffset; + xCoords[1] = task->tBaseX - xOffset - 4; + xCoords[2] = task->tBaseX + xOffset; + xCoords[3] = task->tBaseX + xOffset + 4; + yCoords[0] = task->tBaseY + yOffset; + yCoords[1] = task->tBaseY + yOffset + 6; for (i = 0; i < 4; i++) { - u8 spriteId = CreateSprite(&gFacadeSweatDropSpriteTemplate, xCoords[i], yCoords[i & 1], task->data[6] - 5); + u8 spriteId = CreateSprite(&gFacadeSweatDropSpriteTemplate, xCoords[i], yCoords[i & 1], task->tSubpriority - 5); if (spriteId != MAX_SPRITES) { - gSprites[spriteId].data[0] = 0; - gSprites[spriteId].data[1] = i < 2 ? -2 : 2; - gSprites[spriteId].data[2] = -1; - gSprites[spriteId].data[3] = taskId; - gSprites[spriteId].data[4] = 2; - task->data[2]++; + gSprites[spriteId].sTimer = 0; + gSprites[spriteId].sVelocX = i < 2 ? -2 : 2; // First two travel left, remaining travel right + gSprites[spriteId].sVelocY = -1; + gSprites[spriteId].sTaskId = taskId; + gSprites[spriteId].sActiveSpritesIdx = IDX_ACTIVE_SPRITES; + task->tActiveSprites++; } } } static void AnimFacadeSweatDrop(struct Sprite *sprite) { - sprite->x += sprite->data[1]; - sprite->y += sprite->data[2]; - if (++sprite->data[0] > 6) + sprite->x += sprite->sVelocX; + sprite->y += sprite->sVelocY; + if (++sprite->sTimer > 6) { - gTasks[sprite->data[3]].data[sprite->data[4]]--; + gTasks[sprite->sTaskId].data[sprite->sActiveSpritesIdx]--; DestroySprite(sprite); } } +#undef IDX_ACTIVE_SPRITES +#undef tState +#undef tTimer +#undef tActiveSprites +#undef tNumSquishes +#undef tBaseX +#undef tBaseY +#undef tSubpriority +#undef tBattlerSpriteId +#undef sTimer +#undef sVelocX +#undef sVelocY +#undef sTaskId +#undef sActiveSpritesIdx + // Blends the mon sprite's color with a rotating set of colors. // arg 0: battler // arg 1: duration @@ -4020,6 +4058,26 @@ static void AnimRoarNoiseLine_Step(struct Sprite *sprite) DestroyAnimSprite(sprite); } +#define IDX_ACTIVE_SPRITES 10 // Used by the sprite callback to modify the number of active sprites + +// Task data for AnimTask_GlareEyeDots +#define tState data[0] +#define tTimer data[1] +#define tPairNum data[2] +#define tPairMax data[5] +#define tDotOffset data[6] +#define tIsContest data[7] +#define tActiveSprites data[IDX_ACTIVE_SPRITES] +#define tStartX data[11] +#define tStartY data[12] +#define tEndX data[13] +#define tEndY data[14] + +// Sprite data for AnimGlareEyeDot +#define sTimer data[0] +#define sTaskId data[1] +#define sActiveSpritesIdx data[2] + // Makes a series of dots in a trail from the attacker to the target. // arg 0: unused void AnimTask_GlareEyeDots(u8 taskId) @@ -4028,25 +4086,25 @@ void AnimTask_GlareEyeDots(u8 taskId) if (IsContest()) { - task->data[5] = 8; - task->data[6] = 3; - task->data[7] = 1; + task->tPairMax = 8; + task->tDotOffset = 3; + task->tIsContest = TRUE; } else { - task->data[5] = 12; - task->data[6] = 3; - task->data[7] = 0; + task->tPairMax = 12; + task->tDotOffset = 3; + task->tIsContest = FALSE; } if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER) - task->data[11] = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2) + GetBattlerSpriteCoordAttr(gBattleAnimAttacker, BATTLER_COORD_ATTR_HEIGHT) / 4; + task->tStartX = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2) + GetBattlerSpriteCoordAttr(gBattleAnimAttacker, BATTLER_COORD_ATTR_HEIGHT) / 4; else - task->data[11] = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2) - GetBattlerSpriteCoordAttr(gBattleAnimAttacker, BATTLER_COORD_ATTR_HEIGHT) / 4; + task->tStartX = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2) - GetBattlerSpriteCoordAttr(gBattleAnimAttacker, BATTLER_COORD_ATTR_HEIGHT) / 4; - task->data[12] = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET) - GetBattlerSpriteCoordAttr(gBattleAnimAttacker, BATTLER_COORD_ATTR_HEIGHT) / 4; - task->data[13] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); - task->data[14] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); + task->tStartY = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET) - GetBattlerSpriteCoordAttr(gBattleAnimAttacker, BATTLER_COORD_ATTR_HEIGHT) / 4; + task->tEndX = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); + task->tEndY = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); task->func = AnimTask_GlareEyeDots_Step; } @@ -4056,103 +4114,122 @@ static void AnimTask_GlareEyeDots_Step(u8 taskId) s16 x, y; struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: - if (++task->data[1] > 3) + // Wait to create next pair of dots + if (++task->tTimer > 3) { - task->data[1] = 0; + task->tTimer = 0; GetGlareEyeDotCoords( - task->data[11], - task->data[12], - task->data[13], - task->data[14], - task->data[5], - task->data[2], + task->tStartX, + task->tStartY, + task->tEndX, + task->tEndY, + task->tPairMax, + task->tPairNum, &x, &y); + // Create dot pair for (i = 0; i < 2; i++) { u8 spriteId = CreateSprite(&gGlareEyeDotSpriteTemplate, x, y, 35); if (spriteId != MAX_SPRITES) { - if (task->data[7] == 0) + if (!task->tIsContest) { if (i == 0) - gSprites[spriteId].x2 = gSprites[spriteId].y2 = -task->data[6]; + gSprites[spriteId].x2 = gSprites[spriteId].y2 = -task->tDotOffset; else - gSprites[spriteId].x2 = gSprites[spriteId].y2 = task->data[6]; + gSprites[spriteId].x2 = gSprites[spriteId].y2 = task->tDotOffset; } else { if (i == 0) { - gSprites[spriteId].x2 = -task->data[6]; - gSprites[spriteId].y2 = task->data[6]; + gSprites[spriteId].x2 = -task->tDotOffset; + gSprites[spriteId].y2 = task->tDotOffset; } else { - gSprites[spriteId].x2 = task->data[6]; - gSprites[spriteId].y2 = -task->data[6]; + gSprites[spriteId].x2 = task->tDotOffset; + gSprites[spriteId].y2 = -task->tDotOffset; } } - gSprites[spriteId].data[0] = 0; - gSprites[spriteId].data[1] = taskId; - gSprites[spriteId].data[2] = 10; - task->data[10]++; + gSprites[spriteId].sTimer = 0; + gSprites[spriteId].sTaskId = taskId; + gSprites[spriteId].sActiveSpritesIdx = IDX_ACTIVE_SPRITES; + task->tActiveSprites++; } } - if (task->data[2] == task->data[5]) - task->data[0]++; + if (task->tPairNum == task->tPairMax) + task->tState++; - task->data[2]++; + task->tPairNum++; } break; case 1: - if (task->data[10] == 0) + // Wait for sprites to be destroyed before ending task + if (task->tActiveSprites == 0) DestroyAnimVisualTask(taskId); break; } } -static void GetGlareEyeDotCoords(s16 arg0, s16 arg1, s16 arg2, s16 arg3, u8 arg4, u8 arg5, s16 *x, s16 *y) +static void GetGlareEyeDotCoords(s16 startX, s16 startY, s16 endX, s16 endY, u8 pairMax, u8 pairNum, s16 *x, s16 *y) { int x2; int y2; - if (arg5 == 0) + if (pairNum == 0) { - *x = arg0; - *y = arg1; + *x = startX; + *y = startY; return; } - if (arg5 >= arg4) + if (pairNum >= pairMax) { - *x = arg2; - *y = arg3; + *x = endX; + *y = endY; return; } - arg4--; - x2 = (arg0 << 8) + arg5 * (((arg2 - arg0) << 8) / arg4); - y2 = (arg1 << 8) + arg5 * (((arg3 - arg1) << 8) / arg4); + pairMax--; + x2 = (startX << 8) + pairNum * (((endX - startX) << 8) / pairMax); + y2 = (startY << 8) + pairNum * (((endY - startY) << 8) / pairMax); *x = x2 >> 8; *y = y2 >> 8; } static void AnimGlareEyeDot(struct Sprite *sprite) { - if (++sprite->data[0] > 36) + if (++sprite->sTimer > 36) { - gTasks[sprite->data[1]].data[sprite->data[2]]--; + gTasks[sprite->sTaskId].data[sprite->sActiveSpritesIdx]--; DestroySprite(sprite); } } +#undef IDX_ACTIVE_SPRITES +#undef tState +#undef tTimer +#undef tPairNum +#undef tPairMax +#undef tDotOffset +#undef tIsContest +#undef tActiveSprites +#undef tStartX +#undef tStartY +#undef tEndX +#undef tEndY +#undef sTimer +#undef sTaskId +#undef sActiveSpritesIdx + // Moves a pawprint in a straight line. // arg 0: initial x position // arg 1: initial y position diff --git a/src/battle_anim_fire.c b/src/battle_anim_fire.c index d96030ba8..e898d9cc4 100644 --- a/src/battle_anim_fire.c +++ b/src/battle_anim_fire.c @@ -22,18 +22,18 @@ static void AnimFireRing_Step3(struct Sprite *); static void UpdateFireRingCircleOffset(struct Sprite *); static void AnimFireSpiralOutward_Step1(struct Sprite *); static void AnimFireSpiralOutward_Step2(struct Sprite *); -static void AnimTask_EruptionLaunchRocks_Step(u8 taskId); -static void CreateEruptionLaunchRocks(u8 spriteId, u8 taskId, u8 a3); +static void AnimTask_EruptionLaunchRocks_Step(u8); +static void CreateEruptionLaunchRocks(u8, u8, u8); static void AnimEruptionLaunchRock(struct Sprite *); -static u16 GetEruptionLaunchRockInitialYPos(u8 spriteId); -static void InitEruptionLaunchRockCoordData(struct Sprite *sprite, s16 x, s16 y); +static u16 GetEruptionLaunchRockInitialYPos(u8); +static void InitEruptionLaunchRockCoordData(struct Sprite *, s16, s16); static void UpdateEruptionLaunchRockPos(struct Sprite *); static void AnimEruptionFallingRock_Step(struct Sprite *); static void AnimWillOWispOrb_Step(struct Sprite *); static void AnimWillOWispFire(struct Sprite *); -static void AnimTask_MoveHeatWaveTargets_Step(u8 taskId); -static void AnimLavaPlumeOrbitScatter(struct Sprite *sprite); -static void AnimLavaPlumeOrbitScatterStep(struct Sprite *sprite); +static void AnimTask_MoveHeatWaveTargets_Step(u8); +static void AnimLavaPlumeOrbitScatter(struct Sprite *); +static void AnimLavaPlumeOrbitScatterStep(struct Sprite *); static const union AnimCmd sAnim_FireSpiralSpread_0[] = { @@ -375,7 +375,7 @@ const struct SpriteTemplate gEruptionLaunchRockSpriteTemplate = .callback = AnimEruptionLaunchRock, }; -static const s16 sEruptionLaunchRockCoords[][2] = +static const s16 sEruptionLaunchRockSpeeds[][2] = { {-2, -5}, {-1, -1}, @@ -852,22 +852,43 @@ static void AnimFireSpiralOutward_Step2(struct Sprite *sprite) DestroyAnimSprite(sprite); } +#define IDX_ACTIVE_SPRITES 6 // Used by the sprite callback to modify the number of active sprites + +#define tState data[0] +#define tTimer1 data[1] +#define tTimer2 data[2] +#define tTimer3 data[3] +#define tAttackerY data[4] +#define tAttackerSide data[5] +#define tActiveSprites data[IDX_ACTIVE_SPRITES] +// data[8]-data[15] used by PrepareEruptAnimTaskData / UpdateEruptAnimTask +#define tAttackerSpriteId data[15] + +#define sSpeedDelay data[0] +#define sLaunchStage data[1] +#define sX data[2] +#define sY data[3] +#define sSpeedX data[4] +#define sSpeedY data[5] +#define sTaskId data[6] +#define sActiveSpritesIdx data[7] + // Animates first stage of Eruption where the attacker squishes and launches rocks away from themself void AnimTask_EruptionLaunchRocks(u8 taskId) { struct Task *task = &gTasks[taskId]; - task->data[15] = GetAnimBattlerSpriteId(ANIM_ATTACKER); + task->tAttackerSpriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER); - task->data[0] = 0; - task->data[1] = 0; - task->data[2] = 0; - task->data[3] = 0; - task->data[4] = gSprites[task->data[15]].y; - task->data[5] = GetBattlerSide(gBattleAnimAttacker); - task->data[6] = 0; + task->tState = 0; + task->tTimer1 = 0; + task->tTimer2 = 0; + task->tTimer3 = 0; + task->tAttackerY = gSprites[task->tAttackerSpriteId].y; + task->tAttackerSide = GetBattlerSide(gBattleAnimAttacker); + task->tActiveSprites = 0; - PrepareBattlerSpriteForRotScale(task->data[15], ST_OAM_OBJ_NORMAL); + PrepareBattlerSpriteForRotScale(task->tAttackerSpriteId, ST_OAM_OBJ_NORMAL); task->func = AnimTask_EruptionLaunchRocks_Step; } @@ -876,102 +897,102 @@ static void AnimTask_EruptionLaunchRocks_Step(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: - PrepareEruptAnimTaskData(task, task->data[15], 0x100, 0x100, 0xE0, 0x200, 32); - task->data[0]++; + PrepareEruptAnimTaskData(task, task->tAttackerSpriteId, 0x100, 0x100, 0xE0, 0x200, 32); + task->tState++; case 1: - if (++task->data[1] > 1) + if (++task->tTimer1 > 1) { - task->data[1] = 0; + task->tTimer1 = 0; - if (++task->data[2] & 0x1) - gSprites[task->data[15]].x2 = 3; + if (++task->tTimer2 & 1) + gSprites[task->tAttackerSpriteId].x2 = 3; else - gSprites[task->data[15]].x2 = -3; + gSprites[task->tAttackerSpriteId].x2 = -3; } - if (task->data[5] != B_SIDE_PLAYER) + if (task->tAttackerSide != B_SIDE_PLAYER) { - if (++task->data[3] > 4) + if (++task->tTimer3 > 4) { - task->data[3] = 0; - gSprites[task->data[15]].y++; + task->tTimer3 = 0; + gSprites[task->tAttackerSpriteId].y++; } } if(!UpdateEruptAnimTask(task)) { - SetBattlerSpriteYOffsetFromYScale(task->data[15]); - gSprites[task->data[15]].x2 = 0; + SetBattlerSpriteYOffsetFromYScale(task->tAttackerSpriteId); + gSprites[task->tAttackerSpriteId].x2 = 0; - task->data[1] = 0; - task->data[2] = 0; - task->data[3] = 0; - task->data[0]++; + task->tTimer1 = 0; + task->tTimer2 = 0; + task->tTimer3 = 0; + task->tState++; } break; case 2: - if (++task->data[1] > 4) + if (++task->tTimer1 > 4) { - if (task->data[5] != B_SIDE_PLAYER) - PrepareEruptAnimTaskData(task, task->data[15], 0xE0, 0x200, 0x180, 0xF0, 6); + if (task->tAttackerSide != B_SIDE_PLAYER) + PrepareEruptAnimTaskData(task, task->tAttackerSpriteId, 0xE0, 0x200, 0x180, 0xF0, 6); else - PrepareEruptAnimTaskData(task, task->data[15], 0xE0, 0x200, 0x180, 0xC0, 6); + PrepareEruptAnimTaskData(task, task->tAttackerSpriteId, 0xE0, 0x200, 0x180, 0xC0, 6); - task->data[1] = 0; - task->data[0]++; + task->tTimer1 = 0; + task->tState++; } break; case 3: if (!UpdateEruptAnimTask(task)) { - CreateEruptionLaunchRocks(task->data[15], taskId, 6); - task->data[0]++; + CreateEruptionLaunchRocks(task->tAttackerSpriteId, taskId, IDX_ACTIVE_SPRITES); + task->tState++; } break; case 4: - if (++task->data[1] > 1) + if (++task->tTimer1 > 1) { - task->data[1] = 0; + task->tTimer1 = 0; - if (++task->data[2] & 1) - gSprites[task->data[15]].y2 += 3; + if (++task->tTimer2 & 1) + gSprites[task->tAttackerSpriteId].y2 += 3; else - gSprites[task->data[15]].y2 -= 3; + gSprites[task->tAttackerSpriteId].y2 -= 3; } - if (++task->data[3] > 0x18) + if (++task->tTimer3 > 24) { - if (task->data[5] != B_SIDE_PLAYER) - PrepareEruptAnimTaskData(task, task->data[15], 0x180, 0xF0, 0x100, 0x100, 8); + if (task->tAttackerSide != B_SIDE_PLAYER) + PrepareEruptAnimTaskData(task, task->tAttackerSpriteId, 0x180, 0xF0, 0x100, 0x100, 8); else - PrepareEruptAnimTaskData(task, task->data[15], 0x180, 0xC0, 0x100, 0x100, 8); + PrepareEruptAnimTaskData(task, task->tAttackerSpriteId, 0x180, 0xC0, 0x100, 0x100, 8); - if (task->data[2] & 1) - gSprites[task->data[15]].y2 -= 3; + if (task->tTimer2 & 1) + gSprites[task->tAttackerSpriteId].y2 -= 3; - task->data[1] = 0; - task->data[2] = 0; - task->data[3] = 0; - task->data[0]++; + task->tTimer1 = 0; + task->tTimer2 = 0; + task->tTimer3 = 0; + task->tState++; } break; case 5: - if (task->data[5] != B_SIDE_PLAYER) - gSprites[task->data[15]].y--; + if (task->tAttackerSide != B_SIDE_PLAYER) + gSprites[task->tAttackerSpriteId].y--; if (!UpdateEruptAnimTask(task)) { - gSprites[task->data[15]].y = task->data[4]; - ResetSpriteRotScale(task->data[15]); - task->data[2] = 0; - task->data[0]++; + gSprites[task->tAttackerSpriteId].y = task->tAttackerY; + ResetSpriteRotScale(task->tAttackerSpriteId); + task->tTimer2 = 0; + task->tState++; } break; case 6: - if (!task->data[6]) + if (task->tActiveSprites == 0) DestroyAnimVisualTask(taskId); break; default: @@ -979,7 +1000,7 @@ static void AnimTask_EruptionLaunchRocks_Step(u8 taskId) } } -static void CreateEruptionLaunchRocks(u8 spriteId, u8 taskId, u8 a3) +static void CreateEruptionLaunchRocks(u8 spriteId, u8 taskId, u8 activeSpritesIdx) { u16 i, j; s8 sign; @@ -989,12 +1010,12 @@ static void CreateEruptionLaunchRocks(u8 spriteId, u8 taskId, u8 a3) if(!GetBattlerSide(gBattleAnimAttacker)) { - x -= 0xC; + x -= 12; sign = 1; } else { - x += 0x10; + x += 16; sign = -1; } @@ -1002,18 +1023,18 @@ static void CreateEruptionLaunchRocks(u8 spriteId, u8 taskId, u8 a3) { u8 spriteId = CreateSprite(&gEruptionLaunchRockSpriteTemplate, x, y, 2); - if (spriteId != 0x40) + if (spriteId != MAX_SPRITES) { gSprites[spriteId].oam.tileNum += j * 4 + 0x40; if (++j >= 5) j = 0; - InitEruptionLaunchRockCoordData(&gSprites[spriteId], sEruptionLaunchRockCoords[i][0] * sign, sEruptionLaunchRockCoords[i][1]); - gSprites[spriteId].data[6] = taskId; - gSprites[spriteId].data[7] = a3; + InitEruptionLaunchRockCoordData(&gSprites[spriteId], sEruptionLaunchRockSpeeds[i][0] * sign, sEruptionLaunchRockSpeeds[i][1]); + gSprites[spriteId].sTaskId = taskId; + gSprites[spriteId].sActiveSpritesIdx = activeSpritesIdx; - gTasks[taskId].data[a3]++; + gTasks[taskId].data[activeSpritesIdx]++; } } } @@ -1024,7 +1045,7 @@ static void AnimEruptionLaunchRock(struct Sprite *sprite) if (sprite->invisible) { - gTasks[sprite->data[6]].data[sprite->data[7]]--; + gTasks[sprite->sTaskId].data[sprite->sActiveSpritesIdx]--; DestroySprite(sprite); } } @@ -1041,46 +1062,71 @@ static u16 GetEruptionLaunchRockInitialYPos(u8 spriteId) return y; } -static void InitEruptionLaunchRockCoordData(struct Sprite *sprite, s16 x, s16 y) +static void InitEruptionLaunchRockCoordData(struct Sprite *sprite, s16 speedX, s16 speedY) { - sprite->data[0] = 0; - sprite->data[1] = 0; - sprite->data[2] = (u16)sprite->x * 8; - sprite->data[3] = (u16)sprite->y * 8; - sprite->data[4] = x * 8; - sprite->data[5] = y * 8; + sprite->sSpeedDelay = 0; + sprite->sLaunchStage = 0; + sprite->sX = (u16)sprite->x * 8; + sprite->sY = (u16)sprite->y * 8; + sprite->sSpeedX = speedX * 8; + sprite->sSpeedY = speedY * 8; } static void UpdateEruptionLaunchRockPos(struct Sprite *sprite) { - int var1; - if (++sprite->data[0] > 2) + int extraLaunchSpeed; + if (++sprite->sSpeedDelay > 2) { - sprite->data[0] = 0; - ++sprite->data[1]; - var1 = (u16)sprite->data[1] * (u16)sprite->data[1]; - sprite->data[3] += var1; + sprite->sSpeedDelay = 0; + ++sprite->sLaunchStage; + extraLaunchSpeed = (u16)sprite->sLaunchStage * (u16)sprite->sLaunchStage; + sprite->sY += extraLaunchSpeed; } - sprite->data[2] += sprite->data[4]; - sprite->x = sprite->data[2] >> 3; - sprite->data[3] += sprite->data[5]; - sprite->y = sprite->data[3] >> 3; + sprite->sX += sprite->sSpeedX; + sprite->x = sprite->sX >> 3; + sprite->sY += sprite->sSpeedY; + sprite->y = sprite->sY >> 3; - if (sprite->x < -8 || sprite->x > 0xf8 || sprite->y < -8 || sprite->y > 120) + if (sprite->x < -8 || sprite->x > DISPLAY_WIDTH + 8 || sprite->y < -8 || sprite->y > 120) sprite->invisible = TRUE; } +#undef IDX_ACTIVE_SPRITES +#undef tState +#undef tTimer1 +#undef tTimer2 +#undef tTimer3 +#undef tAttackerY +#undef tAttackerSide +#undef tActiveSprites +#undef tAttackerSpriteId +#undef sSpeedDelay +#undef sLaunchStage +#undef sX +#undef sY +#undef sSpeedX +#undef sSpeedY +#undef sTaskId +#undef sActiveSpritesIdx + +#define sState data[0] +#define sBounceTimer data[1] +#define sBounceDir data[2] +#define sEndTimer data[3] +#define sFallDelay data[6] +#define sTargetY data[7] + void AnimEruptionFallingRock(struct Sprite *sprite) { sprite->x = gBattleAnimArgs[0]; sprite->y = gBattleAnimArgs[1]; - sprite->data[0] = 0; - sprite->data[1] = 0; - sprite->data[2] = 0; - sprite->data[6] = gBattleAnimArgs[2]; - sprite->data[7] = gBattleAnimArgs[3]; + sprite->sState = 0; + sprite->sBounceTimer = 0; + sprite->sBounceDir = 0; + sprite->sFallDelay = gBattleAnimArgs[2]; + sprite->sTargetY = gBattleAnimArgs[3]; sprite->oam.tileNum += gBattleAnimArgs[4] * 16; sprite->callback = AnimEruptionFallingRock_Step; @@ -1088,47 +1134,51 @@ void AnimEruptionFallingRock(struct Sprite *sprite) static void AnimEruptionFallingRock_Step(struct Sprite *sprite) { - switch (sprite->data[0]) + switch (sprite->sState) { case 0: - if (sprite->data[6] != 0) + // Wait to begin falling + if (sprite->sFallDelay != 0) { - sprite->data[6]--; + sprite->sFallDelay--; return; } - sprite->data[0]++; + sprite->sState++; // fall through case 1: + // Rock is falling sprite->y += 8; - if (sprite->y >= sprite->data[7]) + if (sprite->y >= sprite->sTargetY) { - sprite->y = sprite->data[7]; - sprite->data[0]++; + sprite->y = sprite->sTargetY; + sprite->sState++; } break; case 2: - if (++sprite->data[1] > 1) + // Bounce up and down on landing spot + if (++sprite->sBounceTimer > 1) { - sprite->data[1] = 0; - if ((++sprite->data[2] & 1) != 0) - { + sprite->sBounceTimer = 0; + if ((++sprite->sBounceDir & 1) != 0) sprite->y2 = -3; - } else - { sprite->y2 = 3; - } } - if (++sprite->data[3] > 16) - { + if (++sprite->sEndTimer > 16) DestroyAnimSprite(sprite); - } break; } } +#undef sState +#undef sBounceTimer +#undef sBounceDir +#undef sEndTimer +#undef sFallDelay +#undef sTargetY + void AnimWillOWispOrb(struct Sprite *sprite) { switch (sprite->data[0]) diff --git a/src/battle_anim_ghost.c b/src/battle_anim_ghost.c index f6bee63d2..eb270cf40 100644 --- a/src/battle_anim_ghost.c +++ b/src/battle_anim_ghost.c @@ -719,9 +719,9 @@ static void AnimTask_SpiteTargetShadow_Step1(u8 taskId) startLine = 0; if (position == 1) - task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, SCANLINE_EFFECT_REG_BG1HOFS, 1); + task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, SCANLINE_EFFECT_REG_BG1HOFS, TRUE); else - task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, SCANLINE_EFFECT_REG_BG2HOFS, 1); + task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, SCANLINE_EFFECT_REG_BG2HOFS, TRUE); task->data[15]++; break; @@ -1079,7 +1079,7 @@ static void AnimTask_CurseStretchingBlackBg_Step1(u8 taskId) right = DISPLAY_WIDTH; top = 0; bottom = 112; - selectedPalettes = GetBattleBgPalettesMask(1, 0, 0, 0, 0, 0, 0); + selectedPalettes = GetBattlePalettesMask(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE); BeginNormalPaletteFade(selectedPalettes, 0, 16, 16, RGB(0, 0, 0)); gTasks[taskId].func = AnimTask_CurseStretchingBlackBg_Step2; } diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index 32eb525eb..27730ec94 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -948,13 +948,17 @@ bool8 IsDoubleBattle(void) return IS_DOUBLE_BATTLE(); } +#define BG_ANIM_PAL_1 8 +#define BG_ANIM_PAL_2 9 +#define BG_ANIM_PAL_CONTEST 14 + void GetBattleAnimBg1Data(struct BattleAnimBgData *out) { if (IsContest()) { out->bgTiles = gBattleAnimBgTileBuffer; out->bgTilemap = (u16 *)gBattleAnimBgTilemapBuffer; - out->paletteId = 14; + out->paletteId = BG_ANIM_PAL_CONTEST; out->bgId = 1; out->tilesOffset = 0; out->unused = 0; @@ -963,7 +967,7 @@ void GetBattleAnimBg1Data(struct BattleAnimBgData *out) { out->bgTiles = gBattleAnimBgTileBuffer; out->bgTilemap = (u16 *)gBattleAnimBgTilemapBuffer; - out->paletteId = 8; + out->paletteId = BG_ANIM_PAL_1; out->bgId = 1; out->tilesOffset = 0x200; out->unused = 0; @@ -976,7 +980,7 @@ void GetBattleAnimBgData(struct BattleAnimBgData *out, u32 bgId) { out->bgTiles = gBattleAnimBgTileBuffer; out->bgTilemap = (u16 *)gBattleAnimBgTilemapBuffer; - out->paletteId = 14; + out->paletteId = BG_ANIM_PAL_CONTEST; out->bgId = 1; out->tilesOffset = 0; out->unused = 0; @@ -989,7 +993,7 @@ void GetBattleAnimBgData(struct BattleAnimBgData *out, u32 bgId) { out->bgTiles = gBattleAnimBgTileBuffer; out->bgTilemap = (u16 *)gBattleAnimBgTilemapBuffer; - out->paletteId = 9; + out->paletteId = BG_ANIM_PAL_2; out->bgId = 2; out->tilesOffset = 0x300; out->unused = 0; @@ -1002,21 +1006,21 @@ void GetBgDataForTransform(struct BattleAnimBgData *out, u8 battlerId) out->bgTilemap = (u16 *)gBattleAnimBgTilemapBuffer; if (IsContest()) { - out->paletteId = 14; + out->paletteId = BG_ANIM_PAL_CONTEST; out->bgId = 1; out->tilesOffset = 0; out->unused = 0; } else if (GetBattlerSpriteBGPriorityRank(gBattleAnimAttacker) == 1) { - out->paletteId = 8; + out->paletteId = BG_ANIM_PAL_1; out->bgId = 1; out->tilesOffset = 0x200; out->unused = 0; } else { - out->paletteId = 9; + out->paletteId = BG_ANIM_PAL_2; out->bgId = 2; out->tilesOffset = 0x300; out->unused = 0; @@ -1401,14 +1405,14 @@ void ResetSpriteRotScale_PreserveAffine(struct Sprite *sprite) CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, sprite->oam.affineMode); } -static u16 ArcTan2_(s16 a, s16 b) +static u16 ArcTan2_(s16 x, s16 y) { - return ArcTan2(a, b); + return ArcTan2(x, y); } -u16 ArcTan2Neg(s16 a, s16 b) +u16 ArcTan2Neg(s16 x, s16 y) { - u16 var = ArcTan2_(a, b); + u16 var = ArcTan2_(x, y); return -var; } @@ -1441,7 +1445,7 @@ void SetGrayscaleOrOriginalPalette(u16 paletteNum, bool8 restoreOriginalColor) } } -u32 GetBattleBgPalettesMask(u8 battleBackground, u8 attacker, u8 target, u8 attackerPartner, u8 targetPartner, u8 a6, u8 a7) +u32 GetBattlePalettesMask(bool8 battleBackground, bool8 attacker, bool8 target, bool8 attackerPartner, bool8 targetPartner, bool8 anim1, bool8 anim2) { u32 selectedPalettes = 0; u32 shift; @@ -1449,7 +1453,7 @@ u32 GetBattleBgPalettesMask(u8 battleBackground, u8 attacker, u8 target, u8 atta if (battleBackground) { if (!IsContest()) - selectedPalettes = 0xe; + selectedPalettes = 0xe; // Palettes 1, 2, and 3 else selectedPalettes = 1 << GetBattleBgPaletteNum(); } @@ -1479,17 +1483,17 @@ u32 GetBattleBgPalettesMask(u8 battleBackground, u8 attacker, u8 target, u8 atta selectedPalettes |= 1 << shift; } } - if (a6) + if (anim1) { if (!IsContest()) - selectedPalettes |= 0x100; + selectedPalettes |= 1 << BG_ANIM_PAL_1; else - selectedPalettes |= 0x4000; + selectedPalettes |= 1 << BG_ANIM_PAL_CONTEST; } - if (a7) + if (anim2) { if (!IsContest()) - selectedPalettes |= 0x200; + selectedPalettes |= 1 << BG_ANIM_PAL_2; } return selectedPalettes; } diff --git a/src/battle_anim_normal.c b/src/battle_anim_normal.c index 524abccb1..a9e1b8526 100644 --- a/src/battle_anim_normal.c +++ b/src/battle_anim_normal.c @@ -389,7 +389,7 @@ static void AnimConfusionDuck_Step(struct Sprite *sprite) // arg 4: blend color static void AnimSimplePaletteBlend(struct Sprite *sprite) { - u32 selectedPalettes = UnpackSelectedBattleBgPalettes(gBattleAnimArgs[0]); + u32 selectedPalettes = UnpackSelectedBattlePalettes(gBattleAnimArgs[0]); BeginNormalPaletteFade(selectedPalettes, gBattleAnimArgs[1], gBattleAnimArgs[2], gBattleAnimArgs[3], gBattleAnimArgs[4]); sprite->invisible = TRUE; sprite->callback = AnimSimplePaletteBlend_Step; @@ -397,23 +397,23 @@ static void AnimSimplePaletteBlend(struct Sprite *sprite) // Unpacks a bitfield and returns a bitmask of its selected palettes. // Bits 0-6 of the selector parameter result in the following palettes being selected: -// 0: battle background palettes (BG palettes 1, 2, and 3) -// 1: gBattleAnimAttacker OBJ palette -// 2: gBattleAnimTarget OBJ palette -// 3: gBattleAnimAttacker partner OBJ palette -// 4: gBattleAnimTarget partner OBJ palette -// 5: BG palette 4 -// 6: BG palette 5 -u32 UnpackSelectedBattleBgPalettes(s16 selector) +// 0: F_PAL_BG, battle background palettes (BG palettes 1, 2, and 3) +// 1: F_PAL_ATTACKER, gBattleAnimAttacker OBJ palette +// 2: F_PAL_TARGET, gBattleAnimTarget OBJ palette +// 3: F_PAL_ATK_PARTNER, gBattleAnimAttacker partner OBJ palette +// 4: F_PAL_DEF_PARTNER, gBattleAnimTarget partner OBJ palette +// 5: F_PAL_ANIM_1, BG palette 8 (or 14, if in Contest) +// 6: F_PAL_ANIM_2, BG palette 9 +u32 UnpackSelectedBattlePalettes(s16 selector) { - u8 battleBackground = selector & 1; - u8 attacker = (selector >> 1) & 1; - u8 target = (selector >> 2) & 1; - u8 attackerPartner = (selector >> 3) & 1; - u8 targetPartner = (selector >> 4) & 1; - u8 arg5 = (selector >> 5) & 1; - u8 arg6 = (selector >> 6) & 1; - return GetBattleBgPalettesMask(battleBackground, attacker, target, attackerPartner, targetPartner, arg5, arg6); + bool8 battleBackground = selector & 1; + bool8 attacker = (selector >> 1) & 1; + bool8 target = (selector >> 2) & 1; + bool8 attackerPartner = (selector >> 3) & 1; + bool8 targetPartner = (selector >> 4) & 1; + bool8 anim1 = (selector >> 5) & 1; + bool8 anim2 = (selector >> 6) & 1; + return GetBattlePalettesMask(battleBackground, attacker, target, attackerPartner, targetPartner, anim1, anim2); } static void AnimSimplePaletteBlend_Step(struct Sprite *sprite) @@ -435,7 +435,7 @@ static void AnimComplexPaletteBlend(struct Sprite *sprite) sprite->data[6] = gBattleAnimArgs[6]; sprite->data[7] = gBattleAnimArgs[0]; - selectedPalettes = UnpackSelectedBattleBgPalettes(sprite->data[7]); + selectedPalettes = UnpackSelectedBattlePalettes(sprite->data[7]); BlendPalettes(selectedPalettes, gBattleAnimArgs[4], gBattleAnimArgs[3]); sprite->invisible = TRUE; sprite->callback = AnimComplexPaletteBlend_Step1; @@ -460,7 +460,7 @@ static void AnimComplexPaletteBlend_Step1(struct Sprite *sprite) return; } - selectedPalettes = UnpackSelectedBattleBgPalettes(sprite->data[7]); + selectedPalettes = UnpackSelectedBattlePalettes(sprite->data[7]); if (sprite->data[1] & 0x100) BlendPalettes(selectedPalettes, sprite->data[4], sprite->data[3]); else @@ -477,7 +477,7 @@ static void AnimComplexPaletteBlend_Step2(struct Sprite *sprite) if (!gPaletteFade.active) { - selectedPalettes = UnpackSelectedBattleBgPalettes(sprite->data[7]); + selectedPalettes = UnpackSelectedBattlePalettes(sprite->data[7]); BlendPalettes(selectedPalettes, 0, 0); DestroyAnimSprite(sprite); } @@ -527,7 +527,7 @@ void AnimTask_BlendColorCycle(u8 taskId) static void BlendColorCycle(u8 taskId, u8 startBlendAmount, u8 targetBlendAmount) { - u32 selectedPalettes = UnpackSelectedBattleBgPalettes(gTasks[taskId].tPalSelector); + u32 selectedPalettes = UnpackSelectedBattlePalettes(gTasks[taskId].tPalSelector); BeginNormalPaletteFade( selectedPalettes, gTasks[taskId].tDelay, @@ -804,7 +804,7 @@ void AnimTask_InvertScreenColor(u8 taskId) u32 selectedPalettes = 0; if (gBattleAnimArgs[0] & 0x1) - selectedPalettes = GetBattleBgPalettesMask(1, 0, 0, 0, 0, 0, 0); + selectedPalettes = GetBattlePalettesMask(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE); if (gBattleAnimArgs[0] & 0x2) selectedPalettes |= (0x10000 << gBattleAnimAttacker); if (gBattleAnimArgs[0] & 0x4) diff --git a/src/battle_anim_psychic.c b/src/battle_anim_psychic.c index 5e42a2426..51b535af9 100644 --- a/src/battle_anim_psychic.c +++ b/src/battle_anim_psychic.c @@ -700,9 +700,9 @@ static void AnimWallSparkle(struct Sprite *sprite) { if (sprite->data[0] == 0) { - int arg3 = gBattleAnimArgs[3]; + bool32 ignoreOffsets = gBattleAnimArgs[3]; bool8 respectMonPicOffsets = FALSE; - if (arg3 == 0) + if (!ignoreOffsets) respectMonPicOffsets = TRUE; if (!IsContest() && IsDoubleBattle()) diff --git a/src/battle_anim_smokescreen.c b/src/battle_anim_smokescreen.c index 0819796d2..c7be8d41c 100644 --- a/src/battle_anim_smokescreen.c +++ b/src/battle_anim_smokescreen.c @@ -7,8 +7,13 @@ #include "util.h" #include "constants/battle_palace.h" -static void SmokescreenImpact_Callback(struct Sprite *); -static void SpriteCB_DestroySprite(struct Sprite *sprite); +#define TAG_SMOKESCREEN 55019 + +#define PALTAG_SHADOW 55039 +#define GFXTAG_SHADOW 55129 + +static void SpriteCB_SmokescreenImpactMain(struct Sprite *); +static void SpriteCB_SmokescreenImpact(struct Sprite *); // The below data for smokescreen starts and ends with some data that belongs to battle_gfx_sfx_util.c @@ -43,12 +48,12 @@ const u8 gBattlePalaceNatureToMoveTarget[NUM_NATURES] = static const struct CompressedSpriteSheet sSmokescreenImpactSpriteSheet = { - .data = gSmokescreenImpactTiles, .size = 0x180, .tag = 55019 + .data = gSmokescreenImpactTiles, .size = 0x180, .tag = TAG_SMOKESCREEN }; static const struct CompressedSpritePalette sSmokescreenImpactSpritePalette = { - .data = gSmokescreenImpactPalette, .tag = 55019 + .data = gSmokescreenImpactPalette, .tag = TAG_SMOKESCREEN }; static const struct OamData sOamData_SmokescreenImpact = @@ -110,18 +115,18 @@ static const union AnimCmd *const sAnims_SmokescreenImpact[] = static const struct SpriteTemplate sSmokescreenImpactSpriteTemplate = { - .tileTag = 55019, - .paletteTag = 55019, + .tileTag = TAG_SMOKESCREEN, + .paletteTag = TAG_SMOKESCREEN, .oam = &sOamData_SmokescreenImpact, .anims = sAnims_SmokescreenImpact, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCB_DestroySprite + .callback = SpriteCB_SmokescreenImpact }; const struct CompressedSpriteSheet gSpriteSheet_EnemyShadow = { - .data = gEnemyMonShadow_Gfx, .size = 0x80, .tag = 55129 + .data = gEnemyMonShadow_Gfx, .size = 0x80, .tag = GFXTAG_SHADOW }; static const struct OamData sOamData_EnemyShadow = @@ -143,8 +148,8 @@ static const struct OamData sOamData_EnemyShadow = const struct SpriteTemplate gSpriteTemplate_EnemyShadow = { - .tileTag = 55129, - .paletteTag = 55039, + .tileTag = GFXTAG_SHADOW, + .paletteTag = PALTAG_SHADOW, .oam = &sOamData_EnemyShadow, .anims = gDummySpriteAnimTable, .images = NULL, @@ -152,7 +157,12 @@ const struct SpriteTemplate gSpriteTemplate_EnemyShadow = .callback = SpriteCB_SetInvisible }; -u8 SmokescreenImpact(s16 x, s16 y, u8 a3) +#define sActiveSprites data[0] +#define sPersist data[1] + +#define sMainSpriteId data[0] + +u8 SmokescreenImpact(s16 x, s16 y, bool8 persist) { u8 mainSpriteId; u8 spriteId1, spriteId2, spriteId3, spriteId4; @@ -164,54 +174,58 @@ u8 SmokescreenImpact(s16 x, s16 y, u8 a3) LoadCompressedSpritePaletteUsingHeap(&sSmokescreenImpactSpritePalette); } - mainSpriteId = CreateInvisibleSpriteWithCallback(SmokescreenImpact_Callback); + mainSpriteId = CreateInvisibleSpriteWithCallback(SpriteCB_SmokescreenImpactMain); mainSprite = &gSprites[mainSpriteId]; - mainSprite->data[1] = a3; + mainSprite->sPersist = persist; + // Top left sprite spriteId1 = CreateSprite(&sSmokescreenImpactSpriteTemplate, x - 16, y - 16, 2); - gSprites[spriteId1].data[0] = mainSpriteId; - mainSprite->data[0]++; + gSprites[spriteId1].sMainSpriteId = mainSpriteId; + mainSprite->sActiveSprites++; AnimateSprite(&gSprites[spriteId1]); + // Top right sprite spriteId2 = CreateSprite(&sSmokescreenImpactSpriteTemplate, x, y - 16, 2); - gSprites[spriteId2].data[0] = mainSpriteId; - mainSprite->data[0]++; + gSprites[spriteId2].sMainSpriteId = mainSpriteId; + mainSprite->sActiveSprites++; StartSpriteAnim(&gSprites[spriteId2], 1); AnimateSprite(&gSprites[spriteId2]); + // Bottom left sprite spriteId3 = CreateSprite(&sSmokescreenImpactSpriteTemplate, x - 16, y, 2); - gSprites[spriteId3].data[0] = mainSpriteId; - mainSprite->data[0]++; + gSprites[spriteId3].sMainSpriteId = mainSpriteId; + mainSprite->sActiveSprites++; StartSpriteAnim(&gSprites[spriteId3], 2); AnimateSprite(&gSprites[spriteId3]); + // Bottom right sprite spriteId4 = CreateSprite(&sSmokescreenImpactSpriteTemplate, x, y, 2); - gSprites[spriteId4].data[0] = mainSpriteId; - mainSprite->data[0]++; + gSprites[spriteId4].sMainSpriteId = mainSpriteId; + mainSprite->sActiveSprites++; StartSpriteAnim(&gSprites[spriteId4], 3); AnimateSprite(&gSprites[spriteId4]); return mainSpriteId; } -static void SmokescreenImpact_Callback(struct Sprite *sprite) +static void SpriteCB_SmokescreenImpactMain(struct Sprite *sprite) { - if (!sprite->data[0]) + if (sprite->sActiveSprites == 0) { FreeSpriteTilesByTag(sSmokescreenImpactSpriteSheet.tag); FreeSpritePaletteByTag(sSmokescreenImpactSpritePalette.tag); - if (!sprite->data[1]) + if (!sprite->sPersist) DestroySprite(sprite); else sprite->callback = SpriteCallbackDummy; } } -static void SpriteCB_DestroySprite(struct Sprite *sprite) +static void SpriteCB_SmokescreenImpact(struct Sprite *sprite) { if (sprite->animEnded) { - gSprites[sprite->data[0]].data[0]--; + gSprites[sprite->sMainSpriteId].sActiveSprites--; DestroySprite(sprite); } } diff --git a/src/battle_anim_sound_tasks.c b/src/battle_anim_sound_tasks.c index f04d9177d..8f47864b1 100644 --- a/src/battle_anim_sound_tasks.c +++ b/src/battle_anim_sound_tasks.c @@ -139,10 +139,12 @@ void SoundTask_PlayCryHighPitch(u8 taskId) { if (gBattleAnimArgs[0] == ANIM_ATTACKER) species = gContestResources->moveAnim->species; - #ifndef UBFIX + // Destroying the task twice (here and at end of function) + // results in an incorrect value for gAnimVisualTaskCount + #ifndef BUGFIX else - DestroyAnimVisualTask(taskId); // UB: task gets destroyed twice. - #endif + DestroyAnimVisualTask(taskId); + #endif } else { @@ -185,10 +187,12 @@ void SoundTask_PlayDoubleCry(u8 taskId) { if (gBattleAnimArgs[0] == ANIM_ATTACKER) species = gContestResources->moveAnim->species; - #ifndef UBFIX + // Destroying the task twice (here and at end of function) + // results in an incorrect value for gAnimVisualTaskCount + #ifndef BUGFIX else - DestroyAnimVisualTask(taskId); // UB: task gets destroyed twice. - #endif + DestroyAnimVisualTask(taskId); + #endif } else { diff --git a/src/battle_anim_status_effects.c b/src/battle_anim_status_effects.c index 98bed8a80..fb2f97956 100644 --- a/src/battle_anim_status_effects.c +++ b/src/battle_anim_status_effects.c @@ -248,7 +248,7 @@ static const struct SubspriteTable sFrozenIceCubeSubspriteTable[] = {ARRAY_COUNT(sFrozenIceCubeSubsprites), sFrozenIceCubeSubsprites}, }; -static const struct SpriteTemplate gFrozenIceCubeSpriteTemplate = +static const struct SpriteTemplate sFrozenIceCubeSpriteTemplate = { .tileTag = ANIM_TAG_ICE_CUBE, .paletteTag = ANIM_TAG_ICE_CUBE, @@ -389,7 +389,7 @@ void AnimTask_FrozenIceCubeAttacker(u8 taskId) x -= 6; SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); - spriteId = CreateSprite(&gFrozenIceCubeSpriteTemplate, x, y, 4); + spriteId = CreateSprite(&sFrozenIceCubeSpriteTemplate, x, y, 4); if (GetSpriteTileStartByTag(ANIM_TAG_ICE_CUBE) == 0xFFFF) gSprites[spriteId].invisible = TRUE; SetSubspriteTables(&gSprites[spriteId], sFrozenIceCubeSubspriteTable); @@ -408,7 +408,7 @@ void AnimTask_FrozenIceCube(u8 taskId) x -= 6; SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); - spriteId = CreateSprite(&gFrozenIceCubeSpriteTemplate, x, y, 4); + spriteId = CreateSprite(&sFrozenIceCubeSpriteTemplate, x, y, 4); if (GetSpriteTileStartByTag(ANIM_TAG_ICE_CUBE) == 0xFFFF) gSprites[spriteId].invisible = TRUE; SetSubspriteTables(&gSprites[spriteId], sFrozenIceCubeSubspriteTable); @@ -568,7 +568,7 @@ void LaunchStatusAnimation(u8 battlerId, u8 statusAnimId) gBattleAnimAttacker = battlerId; gBattleAnimTarget = battlerId; - LaunchBattleAnimation(gBattleAnims_StatusConditions, statusAnimId, 0); + LaunchBattleAnimation(gBattleAnims_StatusConditions, statusAnimId, FALSE); taskId = CreateTask(Task_DoStatusAnimation, 10); gTasks[taskId].data[0] = battlerId; } diff --git a/src/battle_anim_throw.c b/src/battle_anim_throw.c index 592a4104f..2f33094e5 100755 --- a/src/battle_anim_throw.c +++ b/src/battle_anim_throw.c @@ -691,7 +691,7 @@ void AnimTask_SwitchOutBallEffect(u8 taskId) priority = gSprites[spriteId].oam.priority; subpriority = gSprites[spriteId].subpriority; gTasks[taskId].data[10] = AnimateBallOpenParticles(x, y + 32, priority, subpriority, ballId); - selectedPalettes = GetBattleBgPalettesMask(1, 0, 0, 0, 0, 0, 0); + selectedPalettes = GetBattlePalettesMask(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE); gTasks[taskId].data[11] = LaunchBallFadeMonTask(FALSE, gBattleAnimAttacker, selectedPalettes, ballId); gTasks[taskId].data[0]++; break; @@ -2035,24 +2035,24 @@ static void DestroyBallOpenAnimationParticle(struct Sprite *sprite) #define tPaletteHi data[11] #define tBallId data[15] -u8 LaunchBallFadeMonTask(bool8 unfadeLater, u8 battler, u32 selectedPalettes, u8 ballId) +u8 LaunchBallFadeMonTask(bool8 unfadeLater, u8 spritePalNum, u32 selectedPalettes, u8 ballId) { u8 taskId; taskId = CreateTask(Task_FadeMon_ToBallColor, 5); gTasks[taskId].tBallId = ballId; - gTasks[taskId].tPalOffset = battler; + gTasks[taskId].tPalOffset = spritePalNum; gTasks[taskId].tPaletteLo = selectedPalettes; gTasks[taskId].tPaletteHi = selectedPalettes >> 16; if (!unfadeLater) { - BlendPalette(battler * 16 + 0x100, 16, 0, gBallOpenFadeColors[ballId]); + BlendPalette(spritePalNum * 16 + 0x100, 16, 0, gBallOpenFadeColors[ballId]); gTasks[taskId].tdCoeff = 1; } else { - BlendPalette(battler * 16 + 0x100, 16, 16, gBallOpenFadeColors[ballId]); + BlendPalette(spritePalNum * 16 + 0x100, 16, 16, gBallOpenFadeColors[ballId]); gTasks[taskId].tCoeff = 16; gTasks[taskId].tdCoeff = -1; gTasks[taskId].func = Task_FadeMon_ToNormal; diff --git a/src/battle_anim_utility_funcs.c b/src/battle_anim_utility_funcs.c index 70982993b..9c927593f 100644 --- a/src/battle_anim_utility_funcs.c +++ b/src/battle_anim_utility_funcs.c @@ -47,7 +47,7 @@ const u8 gBattleAnimBgCntGet[] = {REG_OFFSET_BG0CNT, REG_OFFSET_BG1CNT, REG_OFFS void AnimTask_BlendBattleAnimPal(u8 taskId) { - u32 selectedPalettes = UnpackSelectedBattleBgPalettes(gBattleAnimArgs[0]); + u32 selectedPalettes = UnpackSelectedBattlePalettes(gBattleAnimArgs[0]); selectedPalettes |= GetBattleMonSpritePalettesMask((gBattleAnimArgs[0] >> 7) & 1, (gBattleAnimArgs[0] >> 8) & 1, (gBattleAnimArgs[0] >> 9) & 1, @@ -62,7 +62,7 @@ void AnimTask_BlendBattleAnimPalExclude(u8 taskId) u8 animBattlers[2]; animBattlers[1] = 0xFF; - selectedPalettes = UnpackSelectedBattleBgPalettes(1); + selectedPalettes = UnpackSelectedBattlePalettes(F_PAL_BG); switch (gBattleAnimArgs[0]) { case 2: @@ -105,7 +105,7 @@ void AnimTask_BlendBattleAnimPalExclude(u8 taskId) void AnimTask_SetCamouflageBlend(u8 taskId) { - u32 selectedPalettes = UnpackSelectedBattleBgPalettes(gBattleAnimArgs[0]); + u32 selectedPalettes = UnpackSelectedBattlePalettes(gBattleAnimArgs[0]); switch (gBattleTerrain) { case BATTLE_TERRAIN_GRASS: @@ -595,8 +595,7 @@ static void StatsChangeAnimation_Step3(u8 taskId) if (gTasks[taskId].data[6] == 1) gSprites[gTasks[taskId].data[7]].oam.priority++; - Free(sAnimStatsChangeData); - sAnimStatsChangeData = NULL; + FREE_AND_SET_NULL(sAnimStatsChangeData); DestroyAnimVisualTask(taskId); break; } @@ -608,7 +607,7 @@ void AnimTask_Flash(u8 taskId) SetPalettesToColor(selectedPalettes, RGB_BLACK); gTasks[taskId].data[14] = selectedPalettes >> 16; - selectedPalettes = GetBattleBgPalettesMask(1, 0, 0, 0, 0, 0, 0) & 0xFFFF; + selectedPalettes = GetBattlePalettesMask(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) & 0xFFFF; SetPalettesToColor(selectedPalettes, RGB_WHITEALPHA); gTasks[taskId].data[15] = selectedPalettes; @@ -930,7 +929,7 @@ void AnimTask_CopyPalUnfadedToBackup(u8 taskId) if (gBattleAnimArgs[0] == 0) { - selectedPalettes = GetBattleBgPalettesMask(1, 0, 0, 0, 0, 0, 0); + selectedPalettes = GetBattlePalettesMask(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE); while ((selectedPalettes & 1) == 0) { selectedPalettes >>= 1; @@ -957,7 +956,7 @@ void AnimTask_CopyPalUnfadedFromBackup(u8 taskId) if (gBattleAnimArgs[0] == 0) { - selectedPalettes = GetBattleBgPalettesMask(1, 0, 0, 0, 0, 0, 0); + selectedPalettes = GetBattlePalettesMask(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE); while ((selectedPalettes & 1) == 0) { selectedPalettes >>= 1; @@ -984,7 +983,7 @@ void AnimTask_CopyPalFadedToUnfaded(u8 taskId) if (gBattleAnimArgs[0] == 0) { - selectedPalettes = GetBattleBgPalettesMask(1, 0, 0, 0, 0, 0, 0); + selectedPalettes = GetBattlePalettesMask(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE); while ((selectedPalettes & 1) == 0) { selectedPalettes >>= 1; diff --git a/src/battle_bg.c b/src/battle_bg.c index 36d3642d6..60519b8a8 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -161,7 +161,7 @@ const struct BgTemplate gBattleBgTemplates[] = }, }; -static const struct WindowTemplate gStandardBattleWindowTemplates[] = +static const struct WindowTemplate sStandardBattleWindowTemplates[] = { [B_WIN_MSG] = { .bg = 0, @@ -382,7 +382,7 @@ static const struct WindowTemplate gStandardBattleWindowTemplates[] = DUMMY_WIN_TEMPLATE }; -static const struct WindowTemplate gBattleArenaWindowTemplates[] = +static const struct WindowTemplate sBattleArenaWindowTemplates[] = { [B_WIN_MSG] = { .bg = 0, @@ -596,8 +596,8 @@ static const struct WindowTemplate gBattleArenaWindowTemplates[] = const struct WindowTemplate * const gBattleWindowTemplates[] = { - [B_WIN_TYPE_NORMAL] = gStandardBattleWindowTemplates, - [B_WIN_TYPE_ARENA] = gBattleArenaWindowTemplates, + [B_WIN_TYPE_NORMAL] = sStandardBattleWindowTemplates, + [B_WIN_TYPE_ARENA] = sBattleArenaWindowTemplates, }; static const struct BattleBackground sBattleTerrainTable[] = diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index fe5fea8bc..ee939a612 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -107,18 +107,18 @@ static void HandleMoveSwitching(void); static void SwitchIn_HandleSoundAndEnd(void); static void WaitForMonSelection(void); static void CompleteWhenChoseItem(void); -static void Task_LaunchLvlUpAnim(u8 taskId); -static void Task_PrepareToGiveExpWithExpBar(u8 taskId); -static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId); -static void Task_GiveExpWithExpBar(u8 taskId); -static void Task_UpdateLvlInHealthbox(u8 taskId); +static void Task_LaunchLvlUpAnim(u8); +static void Task_PrepareToGiveExpWithExpBar(u8); +static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8); +static void Task_GiveExpWithExpBar(u8); +static void Task_UpdateLvlInHealthbox(u8); static void PrintLinkStandbyMsg(void); -static u32 CopyPlayerMonData(u8 monId, u8 *dst); -static void SetPlayerMonData(u8 monId); -static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit); +static u32 CopyPlayerMonData(u8, u8 *); +static void SetPlayerMonData(u8); +static void StartSendOutAnim(u8, bool8); static void DoSwitchOutAnimation(void); static void PlayerDoMoveAnimation(void); -static void Task_StartSendOutAnim(u8 taskId); +static void Task_StartSendOutAnim(u8); static void EndDrawPartyStatusSummary(void); static void ReloadMoveNames(void); @@ -1728,11 +1728,11 @@ static void MoveSelectionDisplayMoveType(void) BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MOVE_TYPE); } -void MoveSelectionCreateCursorAt(u8 cursorPosition, u8 arg1) +void MoveSelectionCreateCursorAt(u8 cursorPosition, u8 baseTileNum) { u16 src[2]; - src[0] = arg1 + 1; - src[1] = arg1 + 2; + src[0] = baseTileNum + 1; + src[1] = baseTileNum + 2; CopyToBgTilemapBufferRect_ChangePalette(0, src, 9 * (cursorPosition & 1) + 1, 55 + (cursorPosition & 2), 1, 2, 0x11); CopyBgTilemapBufferToVram(0); @@ -1748,7 +1748,7 @@ void MoveSelectionDestroyCursorAt(u8 cursorPosition) CopyBgTilemapBufferToVram(0); } -void ActionSelectionCreateCursorAt(u8 cursorPosition, u8 arg1) +void ActionSelectionCreateCursorAt(u8 cursorPosition, u8 baseTileNum) { u16 src[2]; src[0] = 1; diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 6e43d0161..427a9bf0d 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -1178,13 +1178,13 @@ void BtlController_EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpN PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, sizeof(*movePpData) + 4); } -void BtlController_EmitChooseItem(u8 bufferId, u8 *arg1) +void BtlController_EmitChooseItem(u8 bufferId, u8 *battlePartyOrder) { s32 i; sBattleBuffersTransferData[0] = CONTROLLER_OPENBAG; - for (i = 0; i < 3; i++) - sBattleBuffersTransferData[1 + i] = arg1[i]; + for (i = 0; i < PARTY_SIZE / 2; i++) + sBattleBuffersTransferData[1 + i] = battlePartyOrder[i]; PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } @@ -1321,14 +1321,14 @@ void BtlController_EmitCmd32(u8 bufferId, u16 size, void *data) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, size + 3); } -void BtlController_EmitTwoReturnValues(u8 bufferId, u8 arg1, u32 arg2) +void BtlController_EmitTwoReturnValues(u8 bufferId, u8 ret8, u32 ret32) { sBattleBuffersTransferData[0] = CONTROLLER_TWORETURNVALUES; - sBattleBuffersTransferData[1] = arg1; - sBattleBuffersTransferData[2] = arg2; - sBattleBuffersTransferData[3] = (arg2 & 0x0000FF00) >> 8; - sBattleBuffersTransferData[4] = (arg2 & 0x00FF0000) >> 16; - sBattleBuffersTransferData[5] = (arg2 & 0xFF000000) >> 24; + sBattleBuffersTransferData[1] = ret8; + sBattleBuffersTransferData[2] = ret32; + sBattleBuffersTransferData[3] = (ret32 & 0x0000FF00) >> 8; + sBattleBuffersTransferData[4] = (ret32 & 0x00FF0000) >> 16; + sBattleBuffersTransferData[5] = (ret32 & 0xFF000000) >> 24; PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 6); } @@ -1343,20 +1343,20 @@ void BtlController_EmitChosenMonReturnValue(u8 bufferId, u8 partyId, u8 *battleP PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 5); } -void BtlController_EmitOneReturnValue(u8 bufferId, u16 arg1) +void BtlController_EmitOneReturnValue(u8 bufferId, u16 ret) { sBattleBuffersTransferData[0] = CONTROLLER_ONERETURNVALUE; - sBattleBuffersTransferData[1] = arg1; - sBattleBuffersTransferData[2] = (arg1 & 0xFF00) >> 8; + sBattleBuffersTransferData[1] = ret; + sBattleBuffersTransferData[2] = (ret & 0xFF00) >> 8; sBattleBuffersTransferData[3] = 0; PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } -void BtlController_EmitOneReturnValue_Duplicate(u8 bufferId, u16 b) +void BtlController_EmitOneReturnValue_Duplicate(u8 bufferId, u16 ret) { sBattleBuffersTransferData[0] = CONTROLLER_ONERETURNVALUE_DUPLICATE; - sBattleBuffersTransferData[1] = b; - sBattleBuffersTransferData[2] = (b & 0xFF00) >> 8; + sBattleBuffersTransferData[1] = ret; + sBattleBuffersTransferData[2] = (ret & 0xFF00) >> 8; sBattleBuffersTransferData[3] = 0; PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } diff --git a/src/battle_dome.c b/src/battle_dome.c index 2e338dcf7..39a85ede6 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -73,40 +73,43 @@ struct TourneyTreeLineSection #define tMode data[2] #define tPrevTaskId data[3] -// This file's functions. -static u8 GetDomeTrainerMonIvs(u16 trainerId); -static void SwapDomeTrainers(int id1, int id2, u16 *statsArray); -static void CalcDomeMonStats(u16 species, int level, int ivs, u8 evBits, u8 nature, int *stats); -static void CreateDomeOpponentMons(u16 tournamentTrainerId); -static int SelectOpponentMonsUsingPersonality(u16 tournamentTrainerId, bool8 arg1); -static int SelectOpponentMonsUsingOtId(u16 tournamentTrainerId, bool8 arg1); -static int GetTypeEffectivenessPoints(int move, int species, int arg2); -static int SelectOpponentMonsFromParty(int *arr, bool8 arg1); -static void Task_ShowTourneyInfoCard(u8 taskId); -static void Task_HandleInfoCardInput(u8 taskId); -static u8 Task_GetInfoCardInput(u8 taskId); +#define EFFECTIVENESS_MODE_GOOD 0 +#define EFFECTIVENESS_MODE_BAD 1 +#define EFFECTIVENESS_MODE_AI_VS_AI 2 + +static u8 GetDomeTrainerMonIvs(u16); +static void SwapDomeTrainers(int, int, u16 *); +static void CalcDomeMonStats(u16, int, int, u8, u8, int *); +static void CreateDomeOpponentMons(u16); +static int SelectOpponentMons_Good(u16, bool8); +static int SelectOpponentMons_Bad(u16, bool8); +static int GetTypeEffectivenessPoints(int, int, int); +static int SelectOpponentMonsFromParty(int *, bool8); +static void Task_ShowTourneyInfoCard(u8); +static void Task_HandleInfoCardInput(u8); +static u8 Task_GetInfoCardInput(u8); static void SetFacilityTrainerAndMonPtrs(void); -static int TrainerIdToTournamentId(u16 trainerId); +static int TrainerIdToTournamentId(u16); static u16 TrainerIdOfPlayerOpponent(void); -static void Task_ShowTourneyTree(u8 taskId); -static void Task_HandleStaticTourneyTreeInput(u8 taskId); +static void Task_ShowTourneyTree(u8); +static void Task_HandleStaticTourneyTreeInput(u8); static void CB2_TourneyTree(void); static void VblankCb_TourneyInfoCard(void); -static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo); -static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId); +static void DisplayMatchInfoOnCard(u8, u8); +static void DisplayTrainerInfoOnCard(u8, u8); static int BufferDomeWinString(u8, u8*); static u8 GetDomeBrainTrainerPicId(void); static u8 GetDomeBrainTrainerClass(void); -static void CopyDomeBrainTrainerName(u8 *str); -static void CopyDomeTrainerName(u8 *str, u16 trainerId); +static void CopyDomeBrainTrainerName(u8 *); +static void CopyDomeTrainerName(u8 *, u16); static void HblankCb_TourneyTree(void); static void VblankCb_TourneyTree(void); -static u8 UpdateTourneyTreeCursor(u8 taskId); -static void DecideRoundWinners(u8 roundId); -static u8 GetOpposingNPCTournamentIdByRound(u8 tournamentId, u8); +static u8 UpdateTourneyTreeCursor(u8); +static void DecideRoundWinners(u8); +static u8 GetOpposingNPCTournamentIdByRound(u8, u8); static void DrawTourneyAdvancementLine(u8, u8); -static void SpriteCb_HorizontalScrollArrow(struct Sprite *sprite); -static void SpriteCb_VerticalScrollArrow(struct Sprite *sprite); +static void SpriteCb_HorizontalScrollArrow(struct Sprite *); +static void SpriteCb_VerticalScrollArrow(struct Sprite *); static void InitDomeChallenge(void); static void GetDomeData(void); static void SetDomeData(void); @@ -130,7 +133,6 @@ static void BufferLastDomeWinnerName(void); static void InitRandomTourneyTreeResults(void); static void InitDomeTrainers(void); -// EWRAM variables. EWRAM_DATA u32 gPlayerPartyLostHP = 0; // never read static EWRAM_DATA u32 sPlayerPartyMaxHP = 0; // never read static EWRAM_DATA struct TourneyTreeInfoCard *sInfoCard = {0}; @@ -2080,7 +2082,6 @@ static const u8 sTourneyTreeLineSectionArrayCounts[DOME_TOURNAMENT_TRAINERS_COUN {ARRAY_COUNT(sLineSectionTrainer16Round1), ARRAY_COUNT(sLineSectionTrainer16Round2), ARRAY_COUNT(sLineSectionTrainer16Semifinal), ARRAY_COUNT(sLineSectionTrainer16Final)}, }; -// code void CallBattleDomeFunction(void) { sBattleDomeFunctions[gSpecialVar_0x8004](); @@ -2592,28 +2593,33 @@ static void CreateDomeOpponentMons(u16 tournamentTrainerId) } } +// Returns a bitmask representing which 2 of the trainer's 3 pokemon to select. +// The choice is calculated solely depending on the type effectiveness of their +// movesets against the player's pokemon. +// There is a 50% chance of either a "good" or "bad" selection mode being used. +// In the good mode movesets are preferred which are more effective against the +// player, and in the bad mode the opposite is true. If all 3 pokemon tie, the +// other mode will be tried. If they tie again, the pokemon selection is random. int GetDomeTrainerSelectedMons(u16 tournamentTrainerId) { int selectedMonBits; if (Random() & 1) { - selectedMonBits = SelectOpponentMonsUsingPersonality(tournamentTrainerId, FALSE); + selectedMonBits = SelectOpponentMons_Good(tournamentTrainerId, FALSE); if (selectedMonBits == 0) - selectedMonBits = SelectOpponentMonsUsingOtId(tournamentTrainerId, TRUE); + selectedMonBits = SelectOpponentMons_Bad(tournamentTrainerId, TRUE); } else { - selectedMonBits = SelectOpponentMonsUsingOtId(tournamentTrainerId, FALSE); + selectedMonBits = SelectOpponentMons_Bad(tournamentTrainerId, FALSE); if (selectedMonBits == 0) - selectedMonBits = SelectOpponentMonsUsingPersonality(tournamentTrainerId, TRUE); + selectedMonBits = SelectOpponentMons_Good(tournamentTrainerId, TRUE); } return selectedMonBits; } -// Could probably use a better name once GetTypeEffectivenessPoints is clarified -// Personality seems to be used to select a different weighting system for type effectiveness points -static int SelectOpponentMonsUsingPersonality(u16 tournamentTrainerId, bool8 allowRandom) +static int SelectOpponentMons_Good(u16 tournamentTrainerId, bool8 allowRandom) { int i, moveId, playerMonId; int partyMovePoints[FRONTIER_PARTY_SIZE]; @@ -2628,12 +2634,12 @@ static int SelectOpponentMonsUsingPersonality(u16 tournamentTrainerId, bool8 all if (DOME_TRAINERS[tournamentTrainerId].trainerId == TRAINER_FRONTIER_BRAIN) { partyMovePoints[i] += GetTypeEffectivenessPoints(GetFrontierBrainMonMove(i, moveId), - GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), MON_DATA_PERSONALITY); + GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), EFFECTIVENESS_MODE_GOOD); } else { partyMovePoints[i] += GetTypeEffectivenessPoints(gFacilityTrainerMons[DOME_MONS[tournamentTrainerId][i]].moves[moveId], - GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), MON_DATA_PERSONALITY); + GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), EFFECTIVENESS_MODE_GOOD); } } } @@ -2641,8 +2647,8 @@ static int SelectOpponentMonsUsingPersonality(u16 tournamentTrainerId, bool8 all return SelectOpponentMonsFromParty(partyMovePoints, allowRandom); } -// See above function, identical but uses MON_DATA_OT_ID -static int SelectOpponentMonsUsingOtId(u16 tournamentTrainerId, bool8 allowRandom) +// Identical to function above, but uses EFFECTIVENESS_MODE_BAD +static int SelectOpponentMons_Bad(u16 tournamentTrainerId, bool8 allowRandom) { int i, moveId, playerMonId; int partyMovePoints[FRONTIER_PARTY_SIZE]; @@ -2657,12 +2663,12 @@ static int SelectOpponentMonsUsingOtId(u16 tournamentTrainerId, bool8 allowRando if (DOME_TRAINERS[tournamentTrainerId].trainerId == TRAINER_FRONTIER_BRAIN) { partyMovePoints[i] += GetTypeEffectivenessPoints(GetFrontierBrainMonMove(i, moveId), - GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), MON_DATA_OT_ID); + GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), EFFECTIVENESS_MODE_BAD); } else { partyMovePoints[i] += GetTypeEffectivenessPoints(gFacilityTrainerMons[DOME_MONS[tournamentTrainerId][i]].moves[moveId], - GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), MON_DATA_OT_ID); + GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), EFFECTIVENESS_MODE_BAD); } } } @@ -2735,14 +2741,13 @@ static int SelectOpponentMonsFromParty(int *partyMovePoints, bool8 allowRandom) #define TYPE_x2 40 #define TYPE_x4 80 -// arg2 is either 2, a personality, or an OTID -static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2) +static int GetTypeEffectivenessPoints(int move, int targetSpecies, int mode) { int defType1, defType2, defAbility, moveType; int i = 0; int typePower = TYPE_x1; - if (move == MOVE_NONE || move == 0xFFFF || gBattleMoves[move].power == 0) + if (move == MOVE_NONE || move == MOVE_UNAVAILABLE || gBattleMoves[move].power == 0) return 0; defType1 = gBaseStats[targetSpecies].type1; @@ -2752,8 +2757,15 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2) if (defAbility == ABILITY_LEVITATE && moveType == TYPE_GROUND) { - if (arg2 == 1) + // They likely meant to return here, as 8 is the number of points normally used in this mode for moves with no effect. + // Because there's no return the value instead gets interpreted by the switch, and the number of points becomes 0. + if (mode == EFFECTIVENESS_MODE_BAD) + { typePower = 8; + #ifdef BUGFIX + return; + #endif + } } else { @@ -2764,18 +2776,19 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2) if (defType2 != defType1) typePower = (typeEffectiveness2 * typePower) / 10; - if (defAbility == ABILITY_WONDER_GUARD && typeEffectiveness1 != 20 && typeEffectiveness2 != 20) + if (defAbility == ABILITY_WONDER_GUARD && typeEffectiveness1 != TYPE_x1 && typeEffectiveness2 != TYPE_x1) typePower = 0; } - switch (arg2) + switch (mode) { - case 0: + case EFFECTIVENESS_MODE_GOOD: + // Weights moves that more effective. switch (typePower) { - case TYPE_x0_50: - case TYPE_x0_25: case TYPE_x0: + case TYPE_x0_25: + case TYPE_x0_50: default: typePower = 0; break; @@ -2790,22 +2803,24 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2) break; } break; - case 1: + case EFFECTIVENESS_MODE_BAD: + // Weights moves that are less effective. + // Odd that there's no limit on this being used, even the Frontier Brain could end up using this. switch (typePower) { - default: - case TYPE_x1: - typePower = 0; + case TYPE_x0: + typePower = 8; break; case TYPE_x0_25: typePower = 4; break; - case TYPE_x0: - typePower = 8; - break; case TYPE_x0_50: typePower = 2; break; + default: + case TYPE_x1: + typePower = 0; + break; case TYPE_x2: typePower = -2; break; @@ -2814,7 +2829,9 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2) break; } break; - case 2: + case EFFECTIVENESS_MODE_AI_VS_AI: + // Used as part of calculating the winner in a battle between two AIs. + // Weights moves that are more effective much more strongly in both directions. switch (typePower) { case TYPE_x0: @@ -5828,7 +5845,7 @@ static void InitRandomTourneyTreeResults(void) DOME_TRAINERS[i].forfeited = FALSE; } - monLevel = 50; + monLevel = FRONTIER_MAX_LEVEL_50; for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++) { monTypesBits = 0; @@ -5971,7 +5988,7 @@ static void DecideRoundWinners(u8 roundId) for (monId2 = 0; monId2 < FRONTIER_PARTY_SIZE; monId2++) { points1 += GetTypeEffectivenessPoints(gFacilityTrainerMons[DOME_MONS[tournamentId1][monId1]].moves[moveSlot], - gFacilityTrainerMons[DOME_MONS[tournamentId2][monId2]].species, 2); + gFacilityTrainerMons[DOME_MONS[tournamentId2][monId2]].species, EFFECTIVENESS_MODE_AI_VS_AI); } } species = gFacilityTrainerMons[DOME_MONS[tournamentId1][monId1]].species; @@ -5994,7 +6011,7 @@ static void DecideRoundWinners(u8 roundId) for (monId2 = 0; monId2 < FRONTIER_PARTY_SIZE; monId2++) { points2 += GetTypeEffectivenessPoints(gFacilityTrainerMons[DOME_MONS[tournamentId2][monId1]].moves[moveSlot], - gFacilityTrainerMons[DOME_MONS[tournamentId1][monId2]].species, 2); + gFacilityTrainerMons[DOME_MONS[tournamentId1][monId2]].species, EFFECTIVENESS_MODE_AI_VS_AI); } } species = gFacilityTrainerMons[DOME_MONS[tournamentId2][monId1]].species; diff --git a/src/battle_factory.c b/src/battle_factory.c index a9793935f..12e477e32 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -12,15 +12,15 @@ #include "constants/battle_factory.h" #include "constants/battle_frontier.h" #include "constants/battle_frontier_mons.h" +#include "constants/battle_tent.h" #include "constants/frontier_util.h" #include "constants/layouts.h" #include "constants/trainers.h" #include "constants/moves.h" +#include "constants/items.h" -// IWRAM bss static bool8 sPerformedRentalSwap; -// This file's functions. static void InitFactoryChallenge(void); static void GetBattleFactoryData(void); static void SetBattleFactoryData(void); @@ -212,7 +212,7 @@ static void InitFactoryChallenge(void) } sPerformedRentalSwap = FALSE; - for (i = 0; i < 6; i++) + for (i = 0; i < ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons); i++) gSaveBlock2Ptr->frontier.rentalMons[i].monId = 0xFFFF; for (i = 0; i < FRONTIER_PARTY_SIZE; i++) gFrontierTempParty[i] = 0xFFFF; @@ -310,11 +310,12 @@ static void GenerateOpponentMons(void) u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); u32 winStreak = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode]; - u32 challengeNum = winStreak / 7; + u32 challengeNum = winStreak / FRONTIER_STAGES_PER_CHALLENGE; gFacilityTrainers = gBattleFrontierTrainers; do { + // Choose a random trainer, ensuring no repeats in this challenge trainerId = GetRandomScaledFrontierTrainerId(challengeNum, gSaveBlock2Ptr->frontier.curChallengeBattleNum); for (i = 0; i < gSaveBlock2Ptr->frontier.curChallengeBattleNum; i++) { @@ -324,27 +325,32 @@ static void GenerateOpponentMons(void) } while (i != gSaveBlock2Ptr->frontier.curChallengeBattleNum); gTrainerBattleOpponent_A = trainerId; - if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 6) + if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < FRONTIER_STAGES_PER_CHALLENGE - 1) gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = trainerId; i = 0; while (i != FRONTIER_PARTY_SIZE) { u16 monId = GetFactoryMonId(lvlMode, challengeNum, FALSE); + + // Unown (FRONTIER_MON_UNOWN) is forbidden on opponent Factory teams. if (gFacilityTrainerMons[monId].species == SPECIES_UNOWN) continue; - for (j = 0; j < 6; j++) + // Ensure none of the opponent's pokemon are the same as the potential rental pokemon for the player + for (j = 0; j < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons); j++) { if (gFacilityTrainerMons[monId].species == gFacilityTrainerMons[gSaveBlock2Ptr->frontier.rentalMons[j].monId].species) break; } - if (j != 6) + if (j != (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons)) continue; + // "High tier" pokemon are only allowed on open level mode if (lvlMode == FRONTIER_LVL_50 && monId > FRONTIER_MONS_HIGH_TIER) continue; + // Ensure this species hasn't already been chosen for the opponent for (k = firstMonId; k < firstMonId + i; k++) { if (species[k] == gFacilityTrainerMons[monId].species) @@ -353,14 +359,16 @@ static void GenerateOpponentMons(void) if (k != firstMonId + i) continue; + // Ensure held items don't repeat on the opponent's team for (k = firstMonId; k < firstMonId + i; k++) { - if (heldItems[k] != 0 && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]) + if (heldItems[k] != ITEM_NONE && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]) break; } if (k != firstMonId + i) continue; + // Successful selection species[i] = gFacilityTrainerMons[monId].species; heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]; gFrontierTempParty[i] = monId; @@ -406,15 +414,15 @@ static void SetPlayerAndOpponentParties(void) if (gSaveBlock2Ptr->frontier.lvlMode == FRONTIER_LVL_TENT) { gFacilityTrainerMons = gSlateportBattleTentMons; - monLevel = 30; + monLevel = TENT_MIN_LEVEL; } else { gFacilityTrainerMons = gBattleFrontierMons; if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50) - monLevel = 100; + monLevel = FRONTIER_MAX_LEVEL_OPEN; else - monLevel = 50; + monLevel = FRONTIER_MAX_LEVEL_50; } if (gSpecialVar_0x8005 < 2) @@ -618,9 +626,9 @@ static void GetOpponentMostCommonMonType(void) // Determine which are the two most-common types. // The second most-common type is only updated if // its count is equal to the most-common type. - mostCommonTypes[0] = TYPE_NORMAL; - mostCommonTypes[1] = TYPE_NORMAL; - for (i = TYPE_FIGHTING; i < NUMBER_OF_MON_TYPES; i++) + mostCommonTypes[0] = 0; + mostCommonTypes[1] = 0; + for (i = 1; i < NUMBER_OF_MON_TYPES; i++) { if (typeCounts[mostCommonTypes[0]] < typeCounts[i]) mostCommonTypes[0] = i; @@ -765,15 +773,15 @@ void FillFactoryBrainParty(void) if (gFacilityTrainerMons[monId].species == SPECIES_UNOWN) continue; - if (monLevel == 50 && monId > FRONTIER_MONS_HIGH_TIER) + if (monLevel == FRONTIER_MAX_LEVEL_50 && monId > FRONTIER_MONS_HIGH_TIER) continue; - for (j = 0; j < 6; j++) + for (j = 0; j < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons); j++) { if (monId == gSaveBlock2Ptr->frontier.rentalMons[j].monId) break; } - if (j != 6) + if (j != (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons)) continue; for (k = 0; k < i; k++) @@ -786,7 +794,7 @@ void FillFactoryBrainParty(void) for (k = 0; k < i; k++) { - if (heldItems[k] != 0 && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]) + if (heldItems[k] != ITEM_NONE && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]) break; } if (k != i) diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index 787dc4740..14c63b7b8 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -1131,8 +1131,7 @@ static void CB2_InitSelectScreen(void) switch (gMain.state) { case 0: - if (sFactorySelectMons != NULL) - FREE_AND_SET_NULL(sFactorySelectMons); + TRY_FREE_AND_SET_NULL(sFactorySelectMons); SetHBlankCallback(NULL); SetVBlankCallback(NULL); CpuFill32(0, (void *)VRAM, VRAM_SIZE); @@ -4221,17 +4220,12 @@ static void Task_OpenMonPic(u8 taskId) return; break; default: - #ifndef UBFIX DestroyTask(taskId); - #endif - // UB: Should not use the task after it has been deleted. + // Accessing data of destroyed task. Task data isn't reset until a new task needs that task id. if (gTasks[taskId].tIsSwapScreen == TRUE) Swap_CreateMonSprite(); else Select_CreateMonSprite(); - #ifdef UBFIX - DestroyTask(taskId); - #endif return; } task->tState++; diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index df5fa69ac..3506f53a8 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -354,12 +354,12 @@ void SpriteCB_WaitForBattlerBallReleaseAnim(struct Sprite *sprite) } } -static void UnusedDoBattleSpriteAffineAnim(struct Sprite *sprite, bool8 arg1) +static void UnusedDoBattleSpriteAffineAnim(struct Sprite *sprite, bool8 pointless) { sprite->animPaused = TRUE; sprite->callback = SpriteCallbackDummy; - if (!arg1) + if (!pointless) StartSpriteAffineAnim(sprite, 1); else StartSpriteAffineAnim(sprite, 1); @@ -608,7 +608,7 @@ static void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId, bool32 op if (species == SPECIES_CASTFORM || species == SPECIES_CHERRIM) { paletteOffset = 0x100 + battlerId * 16; - LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[CASTFORM_NORMAL]); + LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette); LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[battlerId]], paletteOffset, 0x20); } @@ -743,7 +743,7 @@ bool8 BattleLoadAllHealthBoxesGfx(u8 state) return retVal; } -void LoadBattleBarGfx(u8 arg0) +void LoadBattleBarGfx(u8 unused) { LZDecompressWram(gBattleInterfaceGfx_BattleBar, gMonSpritesGfxPtr->barFontGfx); } @@ -929,7 +929,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 castform, bo if (targetSpecies == SPECIES_CASTFORM || targetSpecies == SPECIES_CHERRIM) { gSprites[gBattlerSpriteIds[battlerAtk]].anims = gMonFrontAnimsPtrTable[targetSpecies]; - LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[CASTFORM_NORMAL]); + LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette); LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[battlerDef]], paletteOffset, 32); } diff --git a/src/battle_interface.c b/src/battle_interface.c index 6502acd4d..4dc19f207 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -157,44 +157,44 @@ enum HEALTHBOX_GFX_FRAME_END_BAR, }; -static const u8 *GetHealthboxElementGfxPtr(u8 elementId); -static u8* AddTextPrinterAndCreateWindowOnHealthbox(const u8 *str, u32 x, u32 y, u32 bgColor, u32 *windowId); +static const u8 *GetHealthboxElementGfxPtr(u8); +static u8* AddTextPrinterAndCreateWindowOnHealthbox(const u8 *, u32, u32, u32, u32 *); static void RemoveWindowOnHealthbox(u32 windowId); -static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent); -static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId); +static void UpdateHpTextInHealthboxInDoubles(u8, s16, u8); +static void UpdateStatusIconInHealthbox(u8); -static void TextIntoHealthboxObject(void *dest, u8 *windowTileData, s32 windowWidth); -static void SafariTextIntoHealthboxObject(void *dest, u8 *windowTileData, u32 windowWidth); -static void HpTextIntoHealthboxObject(void *dest, u8 *windowTileData, u32 windowWidth); -static void FillHealthboxObject(void *dest, u32 arg1, u32 arg2); +static void TextIntoHealthboxObject(void *, u8 *, s32); +static void SafariTextIntoHealthboxObject(void *, u8 *, u32); +static void HpTextIntoHealthboxObject(void *, u8 *, u32); +static void FillHealthboxObject(void *, u32, u32); -static void Task_HidePartyStatusSummary_BattleStart_1(u8 taskId); -static void Task_HidePartyStatusSummary_BattleStart_2(u8 taskId); -static void Task_HidePartyStatusSummary_DuringBattle(u8 taskId); +static void Task_HidePartyStatusSummary_BattleStart_1(u8); +static void Task_HidePartyStatusSummary_BattleStart_2(u8); +static void Task_HidePartyStatusSummary_DuringBattle(u8); -static void SpriteCB_HealthBoxOther(struct Sprite *sprite); -static void SpriteCB_HealthBar(struct Sprite *sprite); -static void SpriteCB_StatusSummaryBar_Enter(struct Sprite *sprite); -static void SpriteCB_StatusSummaryBar_Exit(struct Sprite *sprite); -static void SpriteCB_StatusSummaryBalls_Enter(struct Sprite *sprite); -static void SpriteCB_StatusSummaryBalls_Exit(struct Sprite *sprite); -static void SpriteCB_StatusSummaryBalls_OnSwitchout(struct Sprite *sprite); +static void SpriteCB_HealthBoxOther(struct Sprite *); +static void SpriteCB_HealthBar(struct Sprite *); +static void SpriteCB_StatusSummaryBar_Enter(struct Sprite *); +static void SpriteCB_StatusSummaryBar_Exit(struct Sprite *); +static void SpriteCB_StatusSummaryBalls_Enter(struct Sprite *); +static void SpriteCB_StatusSummaryBalls_Exit(struct Sprite *); +static void SpriteCB_StatusSummaryBalls_OnSwitchout(struct Sprite *); -static void SpriteCb_MegaTrigger(struct Sprite *sprite); -static void SpriteCb_MegaIndicator(struct Sprite *sprite); +static void SpriteCb_MegaTrigger(struct Sprite *); +static void SpriteCb_MegaIndicator(struct Sprite *); -static u8 GetStatusIconForBattlerId(u8 statusElementId, u8 battlerId); -static s32 CalcNewBarValue(s32 maxValue, s32 currValue, s32 receivedValue, s32 *arg3, u8 arg4, u16 arg5); -static u8 GetScaledExpFraction(s32 currValue, s32 receivedValue, s32 maxValue, u8 scale); -static void MoveBattleBarGraphically(u8 battlerId, u8 whichBar); -static u8 CalcBarFilledPixels(s32 maxValue, s32 oldValue, s32 receivedValue, s32 *currValue, u8 *arg4, u8 scale); +static u8 GetStatusIconForBattlerId(u8, u8); +static s32 CalcNewBarValue(s32, s32, s32, s32 *, u8, u16); +static u8 GetScaledExpFraction(s32, s32, s32, u8); +static void MoveBattleBarGraphically(u8, u8); +static u8 CalcBarFilledPixels(s32, s32, s32, s32 *, u8 *, u8); -static void SpriteCb_AbilityPopUp(struct Sprite *sprite); -static void Task_FreeAbilityPopUpGfx(u8 taskId); +static void SpriteCb_AbilityPopUp(struct Sprite *); +static void Task_FreeAbilityPopUpGfx(u8); -static void SpriteCB_LastUsedBall(struct Sprite *sprite); -static void SpriteCB_LastUsedBallWin(struct Sprite *sprite); +static void SpriteCB_LastUsedBall(struct Sprite *); +static void SpriteCB_LastUsedBallWin(struct Sprite *); static const struct OamData sOamData_64x32 = { @@ -1644,7 +1644,7 @@ static void SpriteCb_MegaIndicator(struct Sprite *sprite) #define tIsBattleStart data[10] #define tBlend data[15] -u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart) +u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, bool8 skipPlayer, bool8 isBattleStart) { bool8 isOpponent; s16 bar_X, bar_Y, bar_pos2_X, bar_data0; @@ -1653,7 +1653,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, u8 ballIconSpritesIds[PARTY_SIZE]; u8 taskId; - if (!arg2 || GetBattlerPosition(battlerId) != B_POSITION_OPPONENT_RIGHT) + if (!skipPlayer || GetBattlerPosition(battlerId) != B_POSITION_OPPONENT_RIGHT) { if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) { @@ -1666,7 +1666,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, { isOpponent = TRUE; - if (!arg2 || !IsDoubleBattle()) + if (!skipPlayer || !IsDoubleBattle()) bar_X = 104, bar_Y = 40; else bar_X = 104, bar_Y = 16; @@ -2614,7 +2614,7 @@ static s32 CalcNewBarValue(s32 maxValue, s32 oldValue, s32 receivedValue, s32 *c return ret; } -static u8 CalcBarFilledPixels(s32 maxValue, s32 oldValue, s32 receivedValue, s32 *currValue, u8 *arg4, u8 scale) +static u8 CalcBarFilledPixels(s32 maxValue, s32 oldValue, s32 receivedValue, s32 *currValue, u8 *pixelsArray, u8 scale) { u8 pixels, filledPixels, totalPixels; u8 i; @@ -2628,7 +2628,7 @@ static u8 CalcBarFilledPixels(s32 maxValue, s32 oldValue, s32 receivedValue, s32 totalPixels = scale * 8; for (i = 0; i < scale; i++) - arg4[i] = 0; + pixelsArray[i] = 0; if (maxValue < totalPixels) pixels = (*currValue * totalPixels / maxValue) >> 8; @@ -2639,7 +2639,7 @@ static u8 CalcBarFilledPixels(s32 maxValue, s32 oldValue, s32 receivedValue, s32 if (filledPixels == 0 && newValue > 0) { - arg4[0] = 1; + pixelsArray[0] = 1; filledPixels = 1; } else @@ -2648,11 +2648,11 @@ static u8 CalcBarFilledPixels(s32 maxValue, s32 oldValue, s32 receivedValue, s32 { if (pixels >= 8) { - arg4[i] = 8; + pixelsArray[i] = 8; } else { - arg4[i] = pixels; + pixelsArray[i] = pixels; break; } pixels -= 8; @@ -2740,9 +2740,9 @@ static void RemoveWindowOnHealthbox(u32 windowId) RemoveWindow(windowId); } -static void FillHealthboxObject(void *dest, u32 arg1, u32 arg2) +static void FillHealthboxObject(void *dest, u32 valMult, u32 numTiles) { - CpuFill32(0x11111111 * arg1, dest, arg2 * TILE_SIZE_4BPP); + CpuFill32(0x11111111 * valMult, dest, numTiles * TILE_SIZE_4BPP); } static void HpTextIntoHealthboxObject(void *dest, u8 *windowTileData, u32 windowWidth) diff --git a/src/battle_main.c b/src/battle_main.c index ff8b6a58d..147c6ec41 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -1377,8 +1377,7 @@ static void CB2_PreInitMultiBattle(void) gBattleTypeFlags = *savedBattleTypeFlags; gMain.savedCallback = *savedCallback; SetMainCallback2(CB2_InitBattleInternal); - Free(sMultiPartnerPartyBuffer); - sMultiPartnerPartyBuffer = NULL; + FREE_AND_SET_NULL(sMultiPartnerPartyBuffer); } } else if (gReceivedRemoteLinkPlayers == 0) @@ -1386,8 +1385,7 @@ static void CB2_PreInitMultiBattle(void) gBattleTypeFlags = *savedBattleTypeFlags; gMain.savedCallback = *savedCallback; SetMainCallback2(CB2_InitBattleInternal); - Free(sMultiPartnerPartyBuffer); - sMultiPartnerPartyBuffer = NULL; + FREE_AND_SET_NULL(sMultiPartnerPartyBuffer); } break; } @@ -1423,8 +1421,7 @@ static void CB2_PreInitIngamePlayerPartnerBattle(void) gBattleTypeFlags = *savedBattleTypeFlags; gMain.savedCallback = *savedCallback; SetMainCallback2(CB2_InitBattleInternal); - Free(sMultiPartnerPartyBuffer); - sMultiPartnerPartyBuffer = NULL; + FREE_AND_SET_NULL(sMultiPartnerPartyBuffer); } break; } diff --git a/src/battle_message.c b/src/battle_message.c index 523fa2848..79467287f 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -1599,7 +1599,7 @@ const u16 gFirstTurnOfTwoStringIds[] = }; // Index copied from move's index in sTrappingMoves -const u16 gWrappedStringIds[TRAPPING_MOVES_COUNT] = +const u16 gWrappedStringIds[NUM_TRAPPING_MOVES] = { [B_MSG_WRAPPED_BIND] = STRINGID_PKMNSQUEEZEDBYBIND, // MOVE_BIND [B_MSG_WRAPPED_WRAP] = STRINGID_PKMNWRAPPEDBY, // MOVE_WRAP diff --git a/src/battle_pike.c b/src/battle_pike.c index 2f36dbc29..2b24e9583 100644 --- a/src/battle_pike.c +++ b/src/battle_pike.c @@ -685,7 +685,7 @@ static void SetBattlePikeData(void) static void IsNextRoomFinal(void) { - if (gSaveBlock2Ptr->frontier.curChallengeBattleNum > 14) + if (gSaveBlock2Ptr->frontier.curChallengeBattleNum > NUM_PIKE_ROOMS) gSpecialVar_Result = TRUE; else gSpecialVar_Result = FALSE; @@ -1119,20 +1119,20 @@ bool32 TryGenerateBattlePikeWildMon(bool8 checkKeenEyeIntimidate) if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50) { monLevel = GetHighestLevelInPlayerParty(); - if (monLevel < 60) + if (monLevel < FRONTIER_MIN_LEVEL_OPEN) { - monLevel = 60; + monLevel = FRONTIER_MIN_LEVEL_OPEN; } else { monLevel -= wildMons[headerId][pikeMonId].levelDelta; - if (monLevel < 60) - monLevel = 60; + if (monLevel < FRONTIER_MIN_LEVEL_OPEN) + monLevel = FRONTIER_MIN_LEVEL_OPEN; } } else { - monLevel = 50 - wildMons[headerId][pikeMonId].levelDelta; + monLevel = FRONTIER_MAX_LEVEL_50 - wildMons[headerId][pikeMonId].levelDelta; } if (checkKeenEyeIntimidate == TRUE && !CanEncounterWildMon(monLevel)) @@ -1160,11 +1160,11 @@ u8 GetBattlePikeWildMonHeaderId(void) u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; u16 winStreak = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode]; - if (winStreak <= 280) + if (winStreak <= 20 * NUM_PIKE_ROOMS) headerId = 0; - else if (winStreak <= 560) + else if (winStreak <= 40 * NUM_PIKE_ROOMS) headerId = 1; - else if (winStreak <= 840) + else if (winStreak <= 60 * NUM_PIKE_ROOMS) headerId = 2; else headerId = 3; @@ -1394,10 +1394,10 @@ static void PrepareOneTrainer(bool8 difficult) if (!difficult) battleNum = 1; else - battleNum = 6; + battleNum = FRONTIER_STAGES_PER_CHALLENGE - 1; lvlMode = gSaveBlock2Ptr->frontier.lvlMode; - challengeNum = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] / 14; + challengeNum = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] / NUM_PIKE_ROOMS; do { trainerId = GetRandomScaledFrontierTrainerId(challengeNum, battleNum); @@ -1411,7 +1411,7 @@ static void PrepareOneTrainer(bool8 difficult) gTrainerBattleOpponent_A = trainerId; gFacilityTrainers = gBattleFrontierTrainers; SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_A, 0); - if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 14) + if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < NUM_PIKE_ROOMS) gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum - 1] = gTrainerBattleOpponent_A; } @@ -1420,7 +1420,7 @@ static void PrepareTwoTrainers(void) int i; u16 trainerId; u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; - u16 challengeNum = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] / 14; + u16 challengeNum = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] / NUM_PIKE_ROOMS; gFacilityTrainers = gBattleFrontierTrainers; do @@ -1435,7 +1435,7 @@ static void PrepareTwoTrainers(void) gTrainerBattleOpponent_A = trainerId; SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_A, 0); - if (gSaveBlock2Ptr->frontier.curChallengeBattleNum <= 14) + if (gSaveBlock2Ptr->frontier.curChallengeBattleNum <= NUM_PIKE_ROOMS) gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum - 1] = gTrainerBattleOpponent_A; do @@ -1450,7 +1450,7 @@ static void PrepareTwoTrainers(void) gTrainerBattleOpponent_B = trainerId; SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_B, 1); - if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 14) + if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < NUM_PIKE_ROOMS) gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum - 2] = gTrainerBattleOpponent_B; } @@ -1458,7 +1458,7 @@ static void ClearPikeTrainerIds(void) { u8 i; - for (i = 0; i < 14; i++) + for (i = 0; i < NUM_PIKE_ROOMS; i++) gSaveBlock2Ptr->frontier.trainerIds[i] = 0xFFFF; } diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 9039f60f2..a885f1c8e 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -83,18 +83,18 @@ static void ClearPyramidPartyHeldItems(void); static void SetPyramidFloorPalette(void); static void BattlePyramidStartMenu(void); static void RestorePyramidPlayerParty(void); -static void InitPyramidBagItems(u8 lvlMode); +static void InitPyramidBagItems(u8); static u8 GetPyramidFloorTemplateId(void); static u8 GetPostBattleDirectionHintTextIndex(int *, u8, u8); -static void Task_SetPyramidFloorPalette(u8 taskId); -static void MarkPyramidTrainerAsBattled(u16 trainerId); -static void GetPyramidFloorLayoutOffsets(u8 *layoutOffsets); +static void Task_SetPyramidFloorPalette(u8); +static void MarkPyramidTrainerAsBattled(u16); +static void GetPyramidFloorLayoutOffsets(u8 *); static void GetPyramidEntranceAndExitSquareIds(u8 *, u8 *); static void SetPyramidObjectPositionsUniformly(u8); static bool8 SetPyramidObjectPositionsInAndNearSquare(u8, u8); static bool8 SetPyramidObjectPositionsNearSquare(u8, u8); -static bool8 TrySetPyramidObjectEventPositionInSquare(u8 arg0, u8 *floorLayoutOffsets, u8 squareId, u8 objectEventId); -static bool8 TrySetPyramidObjectEventPositionAtCoords(bool8 objType, u8 x, u8 y, u8 *floorLayoutOffsets, u8 squareId, u8 objectEventId); +static bool8 TrySetPyramidObjectEventPositionInSquare(u8, u8 *, u8, u8); +static bool8 TrySetPyramidObjectEventPositionAtCoords(bool8, u8, u8, u8 *, u8, u8); // Const rom data. #define ABILITY_RANDOM 2 // For wild mons data. @@ -279,9 +279,9 @@ static const u8 sPyramidFloorTemplateOptions[][2] = {100, 15} }; -static const u8 sFloorTemplateOffsets[] = +static const u8 sFloorTemplateOffsets[FRONTIER_STAGES_PER_CHALLENGE] = { - 0, 4, 9, 14, 19, 24, 29, 0 + 0, 4, 9, 14, 19, 24, 29 }; static const u16 sPickupItemsLvl50[TOTAL_ROUNDS][PICKUP_ITEMS_PER_ROUND] = @@ -406,7 +406,7 @@ static const u8 sPickupItemSlots[][2] = {100, 9}, }; -static const u8 sPickupItemOffsets[] = {0, 9, 18, 27, 36, 45, 54}; +static const u8 sPickupItemOffsets[FRONTIER_STAGES_PER_CHALLENGE] = {0, 9, 18, 27, 36, 45, 54}; static const struct PyramidTrainerEncounterMusic sTrainerClassEncounterMusic[54] = { @@ -963,7 +963,7 @@ static void SeedPyramidFloor(void) { int i; - for (i = 0; i < 4; i++) + for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.pyramidRandoms); i++) gSaveBlock2Ptr->frontier.pyramidRandoms[i] = Random(); gSaveBlock2Ptr->frontier.pyramidTrainerFlags = 0; @@ -977,7 +977,7 @@ static void SetPickupItem(void) u8 id; u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; u32 floor = gSaveBlock2Ptr->frontier.curChallengeBattleNum; - u32 round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / 7) % TOTAL_ROUNDS; + u32 round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / FRONTIER_STAGES_PER_CHALLENGE) % TOTAL_ROUNDS; if (round >= TOTAL_ROUNDS) round = TOTAL_ROUNDS - 1; @@ -1016,8 +1016,8 @@ static void HidePyramidItem(void) { // Rather than using event flags to hide the item object event, // it moves them far off the map bounds. - events[i].x = 0x7FFF; - events[i].y = 0x7FFF; + events[i].x = SHRT_MAX; + events[i].y = SHRT_MAX; break; } i++; @@ -1063,7 +1063,7 @@ static void ShowPostBattleHintText(void) case HINT_REMAINING_ITEMS: for (i = 0; i < GetNumBattlePyramidObjectEvents(); i++) { - if (events[i].graphicsId == OBJ_EVENT_GFX_ITEM_BALL && events[i].x != 0x7FFF && events[i].y != 0x7FFF) + if (events[i].graphicsId == OBJ_EVENT_GFX_ITEM_BALL && events[i].x != SHRT_MAX && events[i].y != SHRT_MAX) textIndex++; } i = 1; @@ -1071,7 +1071,7 @@ static void ShowPostBattleHintText(void) case HINT_REMAINING_TRAINERS: id = GetPyramidFloorTemplateId(); textIndex = sPyramidFloorTemplates[id].numTrainers; - for (i = 0; i < 8; i++) + for (i = 0; i < MAX_PYRAMID_TRAINERS; i++) { if (gBitTable[i] & gSaveBlock2Ptr->frontier.pyramidTrainerFlags) textIndex--; @@ -1326,7 +1326,7 @@ static void MarkPyramidTrainerAsBattled(u16 trainerId) { int i; - for (i = 0; i < 8; i++) + for (i = 0; i < MAX_PYRAMID_TRAINERS; i++) { if (gSaveBlock2Ptr->frontier.trainerIds[i] == trainerId) gSaveBlock2Ptr->frontier.pyramidTrainerFlags |= gBitTable[i]; @@ -1345,7 +1345,7 @@ void GenerateBattlePyramidWildMon(void) const struct PyramidWildMon *wildMons; u32 id; u32 lvl = gSaveBlock2Ptr->frontier.lvlMode; - u16 round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvl] / 7) % TOTAL_ROUNDS; + u16 round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvl] / FRONTIER_STAGES_PER_CHALLENGE) % TOTAL_ROUNDS; if (round >= TOTAL_ROUNDS) round = TOTAL_ROUNDS - 1; @@ -1488,13 +1488,13 @@ static u16 GetUniqueTrainerId(u8 objectEventId) int i; u16 trainerId; u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; - u32 challengeNum = gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / 7; - u32 battleNum = gSaveBlock2Ptr->frontier.curChallengeBattleNum; - if (battleNum == 7) + u32 challengeNum = gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / FRONTIER_STAGES_PER_CHALLENGE; + u32 floor = gSaveBlock2Ptr->frontier.curChallengeBattleNum; + if (floor == FRONTIER_STAGES_PER_CHALLENGE) { do { - trainerId = GetRandomScaledFrontierTrainerId(challengeNum + 1, battleNum); + trainerId = GetRandomScaledFrontierTrainerId(challengeNum + 1, floor); for (i = 0; i < objectEventId; i++) { if (gSaveBlock2Ptr->frontier.trainerIds[i] == trainerId) @@ -1506,7 +1506,7 @@ static u16 GetUniqueTrainerId(u8 objectEventId) { do { - trainerId = GetRandomScaledFrontierTrainerId(challengeNum, battleNum); + trainerId = GetRandomScaledFrontierTrainerId(challengeNum, floor); for (i = 0; i < objectEventId; i++) { if (gSaveBlock2Ptr->frontier.trainerIds[i] == trainerId) @@ -1523,11 +1523,11 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio int y, x; int i; u8 entranceSquareId, exitSquareId; - u8 *floorLayoutOffsets = AllocZeroed(16); + u8 *floorLayoutOffsets = AllocZeroed(NUM_PYRAMID_FLOOR_SQUARES); GetPyramidFloorLayoutOffsets(floorLayoutOffsets); GetPyramidEntranceAndExitSquareIds(&entranceSquareId, &exitSquareId); - for (i = 0; i < 16; i++) + for (i = 0; i < NUM_PYRAMID_FLOOR_SQUARES; i++) { u16 *map; int yOffset, xOffset; @@ -1535,11 +1535,11 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio const u16 *layoutMap = mapLayout->map; gBackupMapLayout.map = backupMapData; - gBackupMapLayout.width = mapLayout->width * 4 + MAP_OFFSET_W; - gBackupMapLayout.height = mapLayout->height * 4 + MAP_OFFSET_H; + gBackupMapLayout.width = mapLayout->width * PYRAMID_FLOOR_SQUARES_WIDE + MAP_OFFSET_W; + gBackupMapLayout.height = mapLayout->height * PYRAMID_FLOOR_SQUARES_HIGH + MAP_OFFSET_H; map = backupMapData; - yOffset = ((i / 4 * mapLayout->height) + MAP_OFFSET) * gBackupMapLayout.width; - xOffset = (i % 4 * mapLayout->width) + MAP_OFFSET; + yOffset = ((i / PYRAMID_FLOOR_SQUARES_WIDE * mapLayout->height) + MAP_OFFSET) * gBackupMapLayout.width; + xOffset = (i % PYRAMID_FLOOR_SQUARES_WIDE * mapLayout->width) + MAP_OFFSET; map += yOffset + xOffset; for (y = 0; y < mapLayout->height; y++) { @@ -1553,8 +1553,8 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio { if (i == entranceSquareId && setPlayerPosition == FALSE) { - gSaveBlock1Ptr->pos.x = (mapLayout->width * (i % 4)) + x; - gSaveBlock1Ptr->pos.y = (mapLayout->height * (i / 4)) + y; + gSaveBlock1Ptr->pos.x = (mapLayout->width * (i % PYRAMID_FLOOR_SQUARES_WIDE)) + x; + gSaveBlock1Ptr->pos.y = (mapLayout->height * (i / PYRAMID_FLOOR_SQUARES_WIDE)) + y; } map[x] = (layoutMap[x] & (MAPGRID_ELEVATION_MASK | MAPGRID_COLLISION_MASK)) | METATILE_BattlePyramid_Floor; } @@ -1563,7 +1563,7 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio map[x] = layoutMap[x]; } } - map += MAP_OFFSET_W + (mapLayout->width * 4); + map += MAP_OFFSET_W + (mapLayout->width * PYRAMID_FLOOR_SQUARES_WIDE); layoutMap += mapLayout->width; } } @@ -1577,7 +1577,7 @@ void LoadBattlePyramidObjectEventTemplates(void) u8 id; u8 entranceSquareId, exitSquareId; - for (i = 0; i < 8; i++) + for (i = 0; i < MAX_PYRAMID_TRAINERS; i++) gSaveBlock2Ptr->frontier.trainerIds[i] = 0xFFFF; id = GetPyramidFloorTemplateId(); @@ -1633,13 +1633,13 @@ void LoadBattlePyramidFloorObjectEventScripts(void) static void GetPyramidEntranceAndExitSquareIds(u8 *entranceSquareId, u8 *exitSquareId) { - *entranceSquareId = gSaveBlock2Ptr->frontier.pyramidRandoms[3] % 16; - *exitSquareId = gSaveBlock2Ptr->frontier.pyramidRandoms[0] % 16; + *entranceSquareId = gSaveBlock2Ptr->frontier.pyramidRandoms[3] % NUM_PYRAMID_FLOOR_SQUARES; + *exitSquareId = gSaveBlock2Ptr->frontier.pyramidRandoms[0] % NUM_PYRAMID_FLOOR_SQUARES; if (*entranceSquareId == *exitSquareId) { - *entranceSquareId = (gSaveBlock2Ptr->frontier.pyramidRandoms[3] + 1 ) % 16; - *exitSquareId = (gSaveBlock2Ptr->frontier.pyramidRandoms[0] + 15) % 16; + *entranceSquareId = (gSaveBlock2Ptr->frontier.pyramidRandoms[3] + 1 ) % NUM_PYRAMID_FLOOR_SQUARES; + *exitSquareId = (gSaveBlock2Ptr->frontier.pyramidRandoms[0] + NUM_PYRAMID_FLOOR_SQUARES - 1) % NUM_PYRAMID_FLOOR_SQUARES; } } @@ -1651,10 +1651,10 @@ static void SetPyramidObjectPositionsUniformly(u8 objType) int squareId; u32 bits = 0; u8 id = GetPyramidFloorTemplateId(); - u8 *floorLayoutOffsets = AllocZeroed(16); + u8 *floorLayoutOffsets = AllocZeroed(NUM_PYRAMID_FLOOR_SQUARES); GetPyramidFloorLayoutOffsets(floorLayoutOffsets); - squareId = gSaveBlock2Ptr->frontier.pyramidRandoms[2] % 16; + squareId = gSaveBlock2Ptr->frontier.pyramidRandoms[2] % NUM_PYRAMID_FLOOR_SQUARES; if (objType == OBJ_TRAINERS) { numObjects = sPyramidFloorTemplates[id].numTrainers; @@ -1682,10 +1682,10 @@ static void SetPyramidObjectPositionsUniformly(u8 objType) if (gBitTable[squareId] & gSaveBlock2Ptr->frontier.pyramidRandoms[3]) bits |= 2; } - if (++squareId >= 16) + if (++squareId >= NUM_PYRAMID_FLOOR_SQUARES) squareId = 0; - if (squareId == gSaveBlock2Ptr->frontier.pyramidRandoms[2] % 16) + if (squareId == gSaveBlock2Ptr->frontier.pyramidRandoms[2] % NUM_PYRAMID_FLOOR_SQUARES) { if (bits & 1) bits |= 6; @@ -1709,7 +1709,7 @@ static bool8 SetPyramidObjectPositionsInAndNearSquare(u8 objType, u8 squareId) int numPlacedObjects = 0; int numObjects; u8 id = GetPyramidFloorTemplateId(); - u8 *floorLayoutOffsets = AllocZeroed(16); + u8 *floorLayoutOffsets = AllocZeroed(NUM_PYRAMID_FLOOR_SQUARES); GetPyramidFloorLayoutOffsets(floorLayoutOffsets); if (objType == OBJ_TRAINERS) @@ -1775,7 +1775,7 @@ static bool8 SetPyramidObjectPositionsNearSquare(u8 objType, u8 squareId) int r8 = 0; int numObjects; u8 id = GetPyramidFloorTemplateId(); - u8 *floorLayoutOffsets = AllocZeroed(16); + u8 *floorLayoutOffsets = AllocZeroed(NUM_PYRAMID_FLOOR_SQUARES); GetPyramidFloorLayoutOffsets(floorLayoutOffsets); if (objType == OBJ_TRAINERS) @@ -1900,7 +1900,7 @@ static void GetPyramidFloorLayoutOffsets(u8 *layoutOffsets) int rand = (gSaveBlock2Ptr->frontier.pyramidRandoms[0]) | (gSaveBlock2Ptr->frontier.pyramidRandoms[1] << 16); u8 id = GetPyramidFloorTemplateId(); - for (i = 0; i < 16; i++) + for (i = 0; i < NUM_PYRAMID_FLOOR_SQUARES; i++) { layoutOffsets[i] = sPyramidFloorTemplates[id].layoutOffsets[rand & 0x7]; rand >>= 3; @@ -1931,7 +1931,7 @@ u8 GetNumBattlePyramidObjectEvents(void) u8 i; struct ObjectEventTemplate *events = gSaveBlock1Ptr->objectEventTemplates; - for (i = 0; i < 16; i++) + for (i = 0; i < OBJECT_EVENTS_COUNT; i++) { if (events[i].localId == 0) break; @@ -1959,7 +1959,7 @@ u16 GetBattlePyramidPickupItemId(void) int rand; u32 i; u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; - int round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / 7); + int round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / FRONTIER_STAGES_PER_CHALLENGE); if (round >= TOTAL_ROUNDS) round = TOTAL_ROUNDS - 1; diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index d1b946146..66b4cd97d 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -1410,7 +1410,7 @@ void TryStoreHeldItemsInPyramidBag(void) memcpy(newItems, gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode], PYRAMID_BAG_ITEMS_COUNT * sizeof(u16)); memcpy(newQuantities, gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode], PYRAMID_BAG_ITEMS_COUNT * sizeof(u8)); - for (i = 0; i < 3; i++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { heldItem = GetMonData(&party[i], MON_DATA_HELD_ITEM); if (heldItem != ITEM_NONE && !AddBagItem(heldItem, 1)) @@ -1426,10 +1426,8 @@ void TryStoreHeldItemsInPyramidBag(void) } heldItem = ITEM_NONE; - for (i = 0; i < 3; i++) - { + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) SetMonData(&party[i], MON_DATA_HELD_ITEM, &heldItem); - } gSpecialVar_Result = 0; Free(newItems); Free(newQuantities); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 0cfeb8ebc..cabe013af 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -282,7 +282,7 @@ static const s32 sExperienceScalingFactors[] = 159767, }; -static const u16 sTrappingMoves[TRAPPING_MOVES_COUNT] = +static const u16 sTrappingMoves[NUM_TRAPPING_MOVES] = { MOVE_BIND, MOVE_WRAP, MOVE_FIRE_SPIN, MOVE_CLAMP, MOVE_WHIRLPOOL, MOVE_SAND_TOMB, MOVE_MAGMA_STORM, MOVE_INFESTATION, MOVE_SNAP_TRAP, }; @@ -2998,9 +2998,9 @@ void SetMoveEffect(bool32 primary, u32 certain) case MOVE_EFFECT_PAYDAY: if (GET_BATTLER_SIDE(gBattlerAttacker) == B_SIDE_PLAYER) { - u16 PayDay = gPaydayMoney; + u16 payday = gPaydayMoney; gPaydayMoney += (gBattleMons[gBattlerAttacker].level * 5); - if (PayDay > gPaydayMoney) + if (payday > gPaydayMoney) gPaydayMoney = 0xFFFF; } BattleScriptPush(gBattlescriptCurrInstr + 1); @@ -3050,7 +3050,7 @@ void SetMoveEffect(bool32 primary, u32 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleScripting.moveEffect]; - for (gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattleCommunication[MULTISTRING_CHOOSER] < TRAPPING_MOVES_COUNT; gBattleCommunication[MULTISTRING_CHOOSER]++) + for (gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattleCommunication[MULTISTRING_CHOOSER] < NUM_TRAPPING_MOVES; gBattleCommunication[MULTISTRING_CHOOSER]++) { if (sTrappingMoves[gBattleCommunication[MULTISTRING_CHOOSER]] == gCurrentMove) break; @@ -3200,9 +3200,9 @@ void SetMoveEffect(bool32 primary, u32 certain) gLastUsedAbility = gBattleMons[gBattlerTarget].ability; RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); } - else if (gBattleMons[gBattlerAttacker].item != 0 + else if (gBattleMons[gBattlerAttacker].item != ITEM_NONE || gBattleMons[gBattlerTarget].item == ITEM_ENIGMA_BERRY - || gBattleMons[gBattlerTarget].item == 0) + || gBattleMons[gBattlerTarget].item == ITEM_NONE) { gBattlescriptCurrInstr++; } @@ -4997,8 +4997,8 @@ static void Cmd_moveend(void) u32 endMode, endState; u32 originallyUsedMove; - if (gChosenMove == 0xFFFF) - originallyUsedMove = 0; + if (gChosenMove == MOVE_UNAVAILABLE) + originallyUsedMove = MOVE_NONE; else originallyUsedMove = gChosenMove; @@ -5074,10 +5074,13 @@ static void Cmd_moveend(void) break; case MOVEEND_RAGE: // rage check if (gBattleMons[gBattlerTarget].status2 & STATUS2_RAGE - && gBattleMons[gBattlerTarget].hp != 0 && gBattlerAttacker != gBattlerTarget + && gBattleMons[gBattlerTarget].hp != 0 + && gBattlerAttacker != gBattlerTarget && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget) - && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && TARGET_TURN_DAMAGED - && gBattleMoves[gCurrentMove].power && CompareStat(gBattlerTarget, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN)) + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && TARGET_TURN_DAMAGED + && gBattleMoves[gCurrentMove].power != 0 + && CompareStat(gBattlerTarget, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN)) { gBattleMons[gBattlerTarget].statStages[STAT_ATK]++; BattleScriptPushCursor(); @@ -5088,9 +5091,11 @@ static void Cmd_moveend(void) break; case MOVEEND_DEFROST: // defrosting check if (gBattleMons[gBattlerTarget].status1 & STATUS1_FREEZE - && gBattleMons[gBattlerTarget].hp != 0 && gBattlerAttacker != gBattlerTarget + && gBattleMons[gBattlerTarget].hp != 0 + && gBattlerAttacker != gBattlerTarget && gSpecialStatuses[gBattlerTarget].specialDmg - && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && (moveType == TYPE_FIRE || gBattleMoves[gCurrentMove].effect == EFFECT_SCALD)) + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && (moveType == TYPE_FIRE || gBattleMoves[gCurrentMove].effect == EFFECT_SCALD)) { gBattleMons[gBattlerTarget].status1 &= ~STATUS1_FREEZE; gActiveBattler = gBattlerTarget; @@ -5132,7 +5137,7 @@ static void Cmd_moveend(void) if (gHitMarker & HITMARKER_OBEYS && (HOLD_EFFECT_CHOICE(holdEffectAtk) || GetBattlerAbility(gBattlerAttacker) == ABILITY_GORILLA_TACTICS) && gChosenMove != MOVE_STRUGGLE - && (*choicedMoveAtk == 0 || *choicedMoveAtk == 0xFFFF)) + && (*choicedMoveAtk == MOVE_NONE || *choicedMoveAtk == MOVE_UNAVAILABLE)) { if ((gBattleMoves[gChosenMove].effect == EFFECT_BATON_PASS || gBattleMoves[gChosenMove].effect == EFFECT_HEALING_WISH) @@ -5149,16 +5154,16 @@ static void Cmd_moveend(void) break; } if (i == MAX_MON_MOVES) - *choicedMoveAtk = 0; + *choicedMoveAtk = MOVE_NONE; ++gBattleScripting.moveendState; break; case MOVEEND_CHANGED_ITEMS: // changed held items for (i = 0; i < gBattlersCount; i++) { - if (gBattleStruct->changedItems[i] != 0) + if (gBattleStruct->changedItems[i] != ITEM_NONE) { gBattleMons[i].item = gBattleStruct->changedItems[i]; - gBattleStruct->changedItems[i] = 0; + gBattleStruct->changedItems[i] = ITEM_NONE; } } gBattleScripting.moveendState++; @@ -5303,8 +5308,8 @@ static void Cmd_moveend(void) } else { - gLastMoves[gBattlerAttacker] = 0xFFFF; - gLastResultingMoves[gBattlerAttacker] = 0xFFFF; + gLastMoves[gBattlerAttacker] = MOVE_UNAVAILABLE; + gLastResultingMoves[gBattlerAttacker] = MOVE_UNAVAILABLE; } if (!(gHitMarker & HITMARKER_FAINTED(gBattlerTarget))) @@ -5312,7 +5317,7 @@ static void Cmd_moveend(void) if (gHitMarker & HITMARKER_OBEYS && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { - if (gChosenMove == 0xFFFF) + if (gChosenMove == MOVE_UNAVAILABLE) { gLastLandedMoves[gBattlerTarget] = gChosenMove; } @@ -5324,15 +5329,18 @@ static void Cmd_moveend(void) } else { - gLastLandedMoves[gBattlerTarget] = 0xFFFF; + gLastLandedMoves[gBattlerTarget] = MOVE_UNAVAILABLE; } } gBattleScripting.moveendState++; break; case MOVEEND_MIRROR_MOVE: // mirror move - if (!(gAbsentBattlerFlags & gBitTable[gBattlerAttacker]) && !(gBattleStruct->absentBattlerFlags & gBitTable[gBattlerAttacker]) - && gBattleMoves[originallyUsedMove].flags & FLAG_MIRROR_MOVE_AFFECTED && gHitMarker & HITMARKER_OBEYS - && gBattlerAttacker != gBattlerTarget && !(gHitMarker & HITMARKER_FAINTED(gBattlerTarget)) + if (!(gAbsentBattlerFlags & gBitTable[gBattlerAttacker]) + && !(gBattleStruct->absentBattlerFlags & gBitTable[gBattlerAttacker]) + && gBattleMoves[originallyUsedMove].flags & FLAG_MIRROR_MOVE_AFFECTED + && gHitMarker & HITMARKER_OBEYS + && gBattlerAttacker != gBattlerTarget + && !(gHitMarker & HITMARKER_FAINTED(gBattlerTarget)) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { gBattleStruct->lastTakenMove[gBattlerTarget] = gChosenMove; @@ -9822,38 +9830,38 @@ static void Cmd_trymirrormove(void) s32 validMovesCount; s32 i; u16 move; - u16 movesArray[4] = {0}; + u16 validMoves[MAX_BATTLERS_COUNT] = {0}; for (validMovesCount = 0, i = 0; i < gBattlersCount; i++) { if (i != gBattlerAttacker) { move = gBattleStruct->lastTakenMoveFrom[gBattlerAttacker][i]; - if (move != 0 && move != 0xFFFF) + if (move != MOVE_NONE && move != MOVE_UNAVAILABLE) { - movesArray[validMovesCount] = move; + validMoves[validMovesCount] = move; validMovesCount++; } } } move = gBattleStruct->lastTakenMove[gBattlerAttacker]; - if (move != 0 && move != 0xFFFF) + if (move != MOVE_NONE && move != MOVE_UNAVAILABLE) { gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; gCurrentMove = move; gBattlerTarget = GetMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE); gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; } - else if (validMovesCount) + else if (validMovesCount != 0) { gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; i = Random() % validMovesCount; - gCurrentMove = movesArray[i]; + gCurrentMove = validMoves[i]; gBattlerTarget = GetMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE); gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; } - else + else // no valid moves found { gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE; gBattlescriptCurrInstr++; @@ -10669,7 +10677,7 @@ static void Cmd_forcerandomswitch(void) || (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER && gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) || (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)) { - if ((gBattlerTarget & BIT_FLANK) != 0) + if ((gBattlerTarget & BIT_FLANK) != B_FLANK_LEFT) { firstMonId = 3; lastMonId = 6; @@ -10687,7 +10695,7 @@ static void Cmd_forcerandomswitch(void) else if ((gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) || (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK)) { - if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(gBattlerTarget)) == 1) + if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(gBattlerTarget)) == B_FLANK_RIGHT) { firstMonId = 3; lastMonId = 6; @@ -10713,7 +10721,7 @@ static void Cmd_forcerandomswitch(void) } else { - if ((gBattlerTarget & BIT_FLANK) != 0) + if ((gBattlerTarget & BIT_FLANK) != B_FLANK_LEFT) { firstMonId = 3; lastMonId = 6; @@ -10836,7 +10844,7 @@ static void Cmd_tryconversiontypechange(void) // randomly changes user's type to one of its moves' type while (validMoves < MAX_MON_MOVES) { - if (gBattleMons[gBattlerAttacker].moves[validMoves] == 0) + if (gBattleMons[gBattlerAttacker].moves[validMoves] == MOVE_NONE) break; validMoves++; @@ -11203,7 +11211,7 @@ static void Cmd_setfocusenergy(void) static void Cmd_transformdataexecution(void) { - gChosenMove = 0xFFFF; + gChosenMove = MOVE_UNAVAILABLE; gBattlescriptCurrInstr++; if (gBattleMons[gBattlerTarget].status2 & STATUS2_TRANSFORMED || gBattleStruct->illusion[gBattlerTarget].on @@ -11218,7 +11226,7 @@ static void Cmd_transformdataexecution(void) u8 *battleMonAttacker, *battleMonTarget; gBattleMons[gBattlerAttacker].status2 |= STATUS2_TRANSFORMED; - gDisableStructs[gBattlerAttacker].disabledMove = 0; + gDisableStructs[gBattlerAttacker].disabledMove = MOVE_NONE; gDisableStructs[gBattlerAttacker].disableTimer = 0; gDisableStructs[gBattlerAttacker].transformedMonPersonality = gBattleMons[gBattlerTarget].personality; gDisableStructs[gBattlerAttacker].mimickedMoves = 0; @@ -11278,7 +11286,7 @@ static void Cmd_mimicattackcopy(void) { if ((sForbiddenMoves[gLastMoves[gBattlerTarget]] & FORBIDDEN_MIMIC) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED) - || gLastMoves[gBattlerTarget] == 0xFFFF) + || gLastMoves[gBattlerTarget] == MOVE_UNAVAILABLE) { gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } @@ -11407,7 +11415,7 @@ static void Cmd_disablelastusedattack(void) if (gBattleMons[gBattlerTarget].moves[i] == gLastMoves[gBattlerTarget]) break; } - if (gDisableStructs[gBattlerTarget].disabledMove == 0 + if (gDisableStructs[gBattlerTarget].disabledMove == MOVE_NONE && i != MAX_MON_MOVES && gBattleMons[gBattlerTarget].pp[i] != 0) { PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerTarget].moves[i]) @@ -11442,11 +11450,11 @@ static void Cmd_trysetencore(void) || gLastMoves[gBattlerTarget] == MOVE_ENCORE || gLastMoves[gBattlerTarget] == MOVE_MIRROR_MOVE) { - i = 4; + i = MAX_MON_MOVES; } - if (gDisableStructs[gBattlerTarget].encoredMove == 0 - && i != 4 && gBattleMons[gBattlerTarget].pp[i] != 0) + if (gDisableStructs[gBattlerTarget].encoredMove == MOVE_NONE + && i != MAX_MON_MOVES && gBattleMons[gBattlerTarget].pp[i] != 0) { gDisableStructs[gBattlerTarget].encoredMove = gBattleMons[gBattlerTarget].moves[i]; gDisableStructs[gBattlerTarget].encoredMovePos = i; @@ -11487,7 +11495,7 @@ static void Cmd_painsplitdmgcalc(void) static void Cmd_settypetorandomresistance(void) // conversion 2 { if (gLastLandedMoves[gBattlerAttacker] == MOVE_NONE - || gLastLandedMoves[gBattlerAttacker] == 0xFFFF) + || gLastLandedMoves[gBattlerAttacker] == MOVE_UNAVAILABLE) { gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } @@ -11545,12 +11553,12 @@ static void Cmd_setalwayshitflag(void) static void Cmd_copymovepermanently(void) // sketch { - gChosenMove = 0xFFFF; + gChosenMove = MOVE_UNAVAILABLE; if (!(gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED) && gLastPrintedMoves[gBattlerTarget] != MOVE_STRUGGLE - && gLastPrintedMoves[gBattlerTarget] != 0 - && gLastPrintedMoves[gBattlerTarget] != 0xFFFF + && gLastPrintedMoves[gBattlerTarget] != MOVE_NONE + && gLastPrintedMoves[gBattlerTarget] != MOVE_UNAVAILABLE && gLastPrintedMoves[gBattlerTarget] != MOVE_SKETCH) { s32 i; @@ -11599,11 +11607,11 @@ static void Cmd_copymovepermanently(void) // sketch static bool8 IsTwoTurnsMove(u16 move) { if (gBattleMoves[move].effect == EFFECT_SKULL_BASH - || gBattleMoves[move].effect == EFFECT_TWO_TURNS_ATTACK - || gBattleMoves[move].effect == EFFECT_SOLAR_BEAM - || gBattleMoves[move].effect == EFFECT_SEMI_INVULNERABLE - || gBattleMoves[move].effect == EFFECT_BIDE - || gBattleMoves[move].effect == EFFECT_METEOR_BEAM) + || gBattleMoves[move].effect == EFFECT_TWO_TURNS_ATTACK + || gBattleMoves[move].effect == EFFECT_SOLAR_BEAM + || gBattleMoves[move].effect == EFFECT_SEMI_INVULNERABLE + || gBattleMoves[move].effect == EFFECT_BIDE + || gBattleMoves[move].effect == EFFECT_METEOR_BEAM) return TRUE; else return FALSE; @@ -11618,10 +11626,10 @@ static u8 AttacksThisTurn(u8 battlerId, u16 move) // Note: returns 1 if it's a c return 2; if (gBattleMoves[move].effect == EFFECT_SKULL_BASH - || gBattleMoves[move].effect == EFFECT_TWO_TURNS_ATTACK - || gBattleMoves[move].effect == EFFECT_SOLAR_BEAM - || gBattleMoves[move].effect == EFFECT_SEMI_INVULNERABLE - || gBattleMoves[move].effect == EFFECT_BIDE) + || gBattleMoves[move].effect == EFFECT_TWO_TURNS_ATTACK + || gBattleMoves[move].effect == EFFECT_SOLAR_BEAM + || gBattleMoves[move].effect == EFFECT_SEMI_INVULNERABLE + || gBattleMoves[move].effect == EFFECT_BIDE) { if ((gHitMarker & HITMARKER_CHARGING)) return 1; @@ -11705,8 +11713,8 @@ static void Cmd_settailwind(void) static void Cmd_tryspiteppreduce(void) { - if (gLastMoves[gBattlerTarget] != 0 - && gLastMoves[gBattlerTarget] != 0xFFFF) + if (gLastMoves[gBattlerTarget] != MOVE_NONE + && gLastMoves[gBattlerTarget] != MOVE_UNAVAILABLE) { s32 i; @@ -12633,7 +12641,7 @@ static void Cmd_tryswapitems(void) // trick } // can't swap if two pokemon don't have an item // or if either of them is an enigma berry or a mail - else if ((gBattleMons[gBattlerAttacker].item == 0 && gBattleMons[gBattlerTarget].item == 0) + else if ((gBattleMons[gBattlerAttacker].item == ITEM_NONE && gBattleMons[gBattlerTarget].item == ITEM_NONE) || !CanBattlerGetOrLoseItem(gBattlerAttacker, gBattleMons[gBattlerAttacker].item) || !CanBattlerGetOrLoseItem(gBattlerAttacker, gBattleMons[gBattlerTarget].item) || !CanBattlerGetOrLoseItem(gBattlerTarget, gBattleMons[gBattlerTarget].item) @@ -12975,7 +12983,7 @@ static void Cmd_assistattackselect(void) s32 chooseableMovesNo = 0; struct Pokemon* party; s32 monId, moveId; - u16* movesArray = gBattleStruct->assistPossibleMoves; + u16* validMoves = gBattleStruct->assistPossibleMoves; if (GET_BATTLER_SIDE(gBattlerAttacker) != B_SIDE_PLAYER) party = gEnemyParty; @@ -12999,14 +13007,14 @@ static void Cmd_assistattackselect(void) if (sForbiddenMoves[move] & FORBIDDEN_ASSIST) continue; - movesArray[chooseableMovesNo] = move; + validMoves[chooseableMovesNo] = move; chooseableMovesNo++; } } if (chooseableMovesNo) { gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED; - gCalledMove = movesArray[((Random() & 0xFF) * chooseableMovesNo) >> 8]; + gCalledMove = validMoves[((Random() & 0xFF) * chooseableMovesNo) >> 8]; gBattlerTarget = GetMoveTarget(gCalledMove, NO_TARGET_OVERRIDE); gBattlescriptCurrInstr += 5; } diff --git a/src/battle_setup.c b/src/battle_setup.c index 7e7f85093..705e8a284 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -716,21 +716,22 @@ static u8 GetBattleTransitionTypeByMap(void) PlayerGetDestCoords(&x, &y); tileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if (GetFlashLevel()) return TRANSITION_TYPE_FLASH; - if (!MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior)) + + if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior)) + return TRANSITION_TYPE_WATER; + + switch (gMapHeader.mapType) { - switch (gMapHeader.mapType) - { - case MAP_TYPE_UNDERGROUND: - return TRANSITION_TYPE_CAVE; - case MAP_TYPE_UNDERWATER: - return TRANSITION_TYPE_WATER; - default: - return TRANSITION_TYPE_NORMAL; - } + case MAP_TYPE_UNDERGROUND: + return TRANSITION_TYPE_CAVE; + case MAP_TYPE_UNDERWATER: + return TRANSITION_TYPE_WATER; + default: + return TRANSITION_TYPE_NORMAL; } - return TRANSITION_TYPE_WATER; } static u16 GetSumOfPlayerPartyLevel(u8 numMons) diff --git a/src/battle_tent.c b/src/battle_tent.c index 53c91c871..dba9e6e8a 100644 --- a/src/battle_tent.c +++ b/src/battle_tent.c @@ -56,10 +56,8 @@ static void GenerateInitialRentalMons(void); * */ -// IWRAM bss -static u16 sRandMonSetId; +static u16 sRandMonId; -// const rom data void static (*const sVerdanturfTentFuncs[])(void) = { [VERDANTURF_TENT_FUNC_INIT] = InitVerdanturfTentChallenge, @@ -357,7 +355,7 @@ static void GenerateOpponentMons(void) const u16 *monSet; u16 species[FRONTIER_PARTY_SIZE]; u16 heldItems[FRONTIER_PARTY_SIZE]; - s32 monId = 0; + s32 numMons = 0; gFacilityTrainers = gSlateportBattleTentTrainers; gFacilityTrainerMons = gSlateportBattleTentMons; @@ -366,6 +364,7 @@ static void GenerateOpponentMons(void) { do { + // Choose a random trainer, ensuring no repeats in this challenge trainerId = Random() % NUM_BATTLE_TENT_TRAINERS; for (i = 0; i < gSaveBlock2Ptr->frontier.curChallengeBattleNum; i++) { @@ -376,48 +375,53 @@ static void GenerateOpponentMons(void) gTrainerBattleOpponent_A = trainerId; monSet = gFacilityTrainers[gTrainerBattleOpponent_A].monSet; - while (monSet[monId] != 0xFFFF) - monId++; - if (monId > 8) + while (monSet[numMons] != 0xFFFF) + numMons++; + if (numMons > 8) break; - monId = 0; + numMons = 0; } - if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 2) + if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < TENT_STAGES_PER_CHALLENGE - 1) gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = gTrainerBattleOpponent_A; monSet = gFacilityTrainers[gTrainerBattleOpponent_A].monSet; i = 0; while (i != FRONTIER_PARTY_SIZE) { - sRandMonSetId = monSet[Random() % monId]; - for (j = 0; j < 6; j++) + sRandMonId = monSet[Random() % numMons]; + + // Ensure none of the opponent's pokemon are the same as the potential rental pokemon for the player + for (j = 0; j < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons); j++) { - if (gFacilityTrainerMons[sRandMonSetId].species == gFacilityTrainerMons[gSaveBlock2Ptr->frontier.rentalMons[j].monId].species) + if (gFacilityTrainerMons[sRandMonId].species == gFacilityTrainerMons[gSaveBlock2Ptr->frontier.rentalMons[j].monId].species) break; } - if (j != 6) + if (j != (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons)) continue; + // Ensure this species hasn't already been chosen for the opponent for (k = 0; k < i; k++) { - if (species[k] == gFacilityTrainerMons[sRandMonSetId].species) + if (species[k] == gFacilityTrainerMons[sRandMonId].species) break; } if (k != i) continue; + // Ensure held items don't repeat on the opponent's team for (k = 0; k < i; k++) { - if (heldItems[k] != 0 && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonSetId].itemTableId]) + if (heldItems[k] != ITEM_NONE && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonId].itemTableId]) break; } if (k != i) continue; - species[i] = gFacilityTrainerMons[sRandMonSetId].species; - heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonSetId].itemTableId]; - gFrontierTempParty[i] = sRandMonSetId; + // Successful selection + species[i] = gFacilityTrainerMons[sRandMonId].species; + heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonId].itemTableId]; + gFrontierTempParty[i] = sRandMonId; i++; } } diff --git a/src/battle_tower.c b/src/battle_tower.c index 697991bb4..8446785ee 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -27,6 +27,7 @@ #include "constants/battle_dome.h" #include "constants/battle_frontier.h" #include "constants/battle_frontier_mons.h" +#include "constants/battle_tent.h" #include "constants/battle_tent_mons.h" #include "constants/battle_tent_trainers.h" #include "constants/battle_tower.h" @@ -687,7 +688,7 @@ struct { u32 facilityClass; const u8 *const *strings; -} const sPartnerTrainerTextTables[] = +} static const sPartnerTrainerTextTables[] = { {FACILITY_CLASS_LASS, sPartnerTextsLass}, {FACILITY_CLASS_YOUNGSTER, sPartnerTextsYoungster}, @@ -769,7 +770,7 @@ struct u8 nature; u8 evs[NUM_STATS]; u16 moves[MAX_MON_MOVES]; -} const sStevenMons[MULTI_PARTY_SIZE] = +} static const sStevenMons[MULTI_PARTY_SIZE] = { { .species = SPECIES_METANG, @@ -1060,7 +1061,7 @@ static void SetNextFacilityOpponent(void) u16 id; u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); u16 winStreak = GetCurrentFacilityWinStreak(); - u32 challengeNum = winStreak / 7; + u32 challengeNum = winStreak / FRONTIER_STAGES_PER_CHALLENGE; SetFacilityPtrsGetLevel(); if (battleMode == FRONTIER_MODE_MULTIS || battleMode == FRONTIER_MODE_LINK_MULTIS) @@ -1095,7 +1096,7 @@ static void SetNextFacilityOpponent(void) gTrainerBattleOpponent_A = id; SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_A, 0); - if (gSaveBlock2Ptr->frontier.curChallengeBattleNum + 1 < 7) + if (gSaveBlock2Ptr->frontier.curChallengeBattleNum + 1 < FRONTIER_STAGES_PER_CHALLENGE) gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = gTrainerBattleOpponent_A; } } @@ -1107,7 +1108,7 @@ u16 GetRandomScaledFrontierTrainerId(u8 challengeNum, u8 battleNum) if (challengeNum <= 7) { - if (battleNum == 6) + if (battleNum == FRONTIER_STAGES_PER_CHALLENGE - 1) { // The last battle in each challenge has a jump in difficulty, pulls from a table with higher ranges trainerId = (sFrontierTrainerIdRangesHard[challengeNum][1] - sFrontierTrainerIdRangesHard[challengeNum][0]) + 1; @@ -1136,7 +1137,7 @@ static void GetRandomScaledFrontierTrainerIdRange(u8 challengeNum, u8 battleNum, if (challengeNum <= 7) { - if (battleNum == 6) + if (battleNum == FRONTIER_STAGES_PER_CHALLENGE - 1) { // The last battle in each challenge has a jump in difficulty, pulls from a table with higher ranges range = (sFrontierTrainerIdRangesHard[challengeNum][1] - sFrontierTrainerIdRangesHard[challengeNum][0]) + 1; @@ -1326,19 +1327,19 @@ void PutNewBattleTowerRecord(struct EmeraldBattleTowerRecord *newRecordEm) if (gSaveBlock2Ptr->frontier.towerRecords[i].trainerId[j] != newRecord->trainerId[j]) break; } - if (j == 4) + if (j == TRAINER_ID_LENGTH) { for (k = 0; k < PLAYER_NAME_LENGTH; k++) { - #ifdef BUGFIX - if (gSaveBlock2Ptr->frontier.towerRecords[i].name[k] != newRecord->name[k]) + // Incorrect index being used + #ifdef BUGFIX + #define INDEX k + #else + #define INDEX j + #endif + if (gSaveBlock2Ptr->frontier.towerRecords[i].name[INDEX] != newRecord->name[INDEX]) break; - if (newRecord->name[k] == EOS) - #else - if (gSaveBlock2Ptr->frontier.towerRecords[i].name[j] != newRecord->name[j]) - break; - if (newRecord->name[j] == EOS) - #endif + if (newRecord->name[INDEX] == EOS) { k = PLAYER_NAME_LENGTH; break; @@ -1643,7 +1644,7 @@ static void FillTentTrainerParty(u8 monsCount) static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount) { s32 i, j; - u16 chosenMonIndices[4]; + u16 chosenMonIndices[MAX_FRONTIER_PARTY_SIZE]; u8 friendship = MAX_FRIENDSHIP; u8 level = SetFacilityPtrsGetLevel(); u8 fixedIV = 0; @@ -1659,7 +1660,7 @@ static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount) } else if (trainerId == TRAINER_EREADER) { - for (i = firstMonId; i < firstMonId + 3; i++) + for (i = firstMonId; i < firstMonId + FRONTIER_PARTY_SIZE; i++) CreateBattleTowerMon(&gEnemyParty[i], &gSaveBlock2Ptr->frontier.ereaderTrainer.party[i - firstMonId]); return; } @@ -1684,7 +1685,7 @@ static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount) else { // Apprentice. - for (i = firstMonId; i < firstMonId + 3; i++) + for (i = firstMonId; i < firstMonId + FRONTIER_PARTY_SIZE; i++) CreateApprenticeMon(&gEnemyParty[i], &gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE], i - firstMonId); return; } @@ -1700,7 +1701,10 @@ static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount) while (i != monCount) { u16 monId = monSet[Random() % bfMonCount]; - if ((level == 50 || level == 20) && monId > FRONTIER_MONS_HIGH_TIER) + + // "High tier" pokemon are only allowed on open level mode + // 20 is not a possible value for level here + if ((level == FRONTIER_MAX_LEVEL_50 || level == 20) && monId > FRONTIER_MONS_HIGH_TIER) continue; // Ensure this pokemon species isn't a duplicate. @@ -1776,11 +1780,11 @@ static void Unused_CreateApprenticeMons(u16 trainerId, u8 firstMonId) fixedIV = 9; if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50) - level = 100; + level = FRONTIER_MAX_LEVEL_OPEN; else - level = 50; + level = FRONTIER_MAX_LEVEL_50; - for (i = 0; i != 3; i++) + for (i = 0; i != FRONTIER_PARTY_SIZE; i++) { CreateMonWithEVSpread(&gEnemyParty[firstMonId + i], apprentice->party[i].species, level, fixedIV, 8); friendship = MAX_FRIENDSHIP; @@ -1811,8 +1815,10 @@ u16 GetRandomFrontierMonFromSet(u16 trainerId) do { + // "High tier" pokemon are only allowed on open level mode + // 20 is not a possible value for level here monId = monSet[Random() % numMons]; - } while((level == 50 || level == 20) && monId > FRONTIER_MONS_HIGH_TIER); + } while((level == FRONTIER_MAX_LEVEL_50 || level == 20) && monId > FRONTIER_MONS_HIGH_TIER); return monId; } @@ -1840,18 +1846,18 @@ static void FillFactoryFrontierTrainerParty(u16 trainerId, u8 firstMonId) u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); // By mistake Battle Tower's Level 50 challenge number is used to determine the IVs for Battle Factory. #ifdef BUGFIX - u8 challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / 7; + u8 challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE; #else - u8 challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][FRONTIER_LVL_50] / 7; + u8 challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][FRONTIER_LVL_50] / FRONTIER_STAGES_PER_CHALLENGE; #endif - if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 6) + if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < FRONTIER_STAGES_PER_CHALLENGE - 1) fixedIV = GetFactoryMonFixedIV(challengeNum, FALSE); else fixedIV = GetFactoryMonFixedIV(challengeNum, TRUE); // Last trainer in challenge uses higher IVs } else if (trainerId == TRAINER_EREADER) { - for (i = firstMonId; i < firstMonId + 3; i++) + for (i = firstMonId; i < firstMonId + FRONTIER_PARTY_SIZE; i++) CreateBattleTowerMon(&gEnemyParty[i], &gSaveBlock2Ptr->frontier.ereaderTrainer.party[i - firstMonId]); return; } @@ -1891,7 +1897,7 @@ static void FillFactoryTentTrainerParty(u16 trainerId, u8 firstMonId) { u8 i, j; u8 friendship; - u8 level = 30; + u8 level = TENT_MIN_LEVEL; u8 fixedIV = 0; u32 otID = T1_READ_32(gSaveBlock2Ptr->playerTrainerId); @@ -2059,7 +2065,7 @@ void DoSpecialTrainerBattle(void) break; case SPECIAL_BATTLE_EREADER: ZeroEnemyPartyMons(); - for (i = 0; i < 3; i++) + for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.ereaderTrainer.party); i++) CreateBattleTowerMon(&gEnemyParty[i], &gSaveBlock2Ptr->frontier.ereaderTrainer.party[i]); gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_EREADER_TRAINER; gTrainerBattleOpponent_A = 0; @@ -2233,7 +2239,7 @@ static void SaveTowerChallenge(void) { u16 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; u16 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); - s32 challengeNum = (signed)(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / 7); + s32 challengeNum = (signed)(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE); if (gSpecialVar_0x8005 == 0 && (challengeNum > 1 || gSaveBlock2Ptr->frontier.curChallengeBattleNum != 0)) SaveBattleTowerRecord(); @@ -2323,7 +2329,7 @@ static void LoadMultiPartnerCandidatesData(void) objEventTemplates = gSaveBlock1Ptr->objectEventTemplates; lvlMode = gSaveBlock2Ptr->frontier.lvlMode; battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); - challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / 7; + challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE; species1 = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES, NULL); species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL); level = SetFacilityPtrsGetLevel(); @@ -2382,7 +2388,7 @@ static void LoadMultiPartnerCandidatesData(void) for (i = 0; i < APPRENTICE_COUNT; i++) { if (gSaveBlock2Ptr->apprentices[i].lvlMode != 0 - && sApprenticeChallengeThreshold[gSaveBlock2Ptr->apprentices[i].numQuestions] / 7 <= challengeNum + && sApprenticeChallengeThreshold[gSaveBlock2Ptr->apprentices[i].numQuestions] / FRONTIER_STAGES_PER_CHALLENGE <= challengeNum && gSaveBlock2Ptr->apprentices[i].lvlMode - 1 == lvlMode) { k = 0; @@ -2421,7 +2427,7 @@ static void LoadMultiPartnerCandidatesData(void) checksum += record[j]; } - if (gSaveBlock2Ptr->frontier.towerRecords[i].winStreak / 7 <= challengeNum + if (gSaveBlock2Ptr->frontier.towerRecords[i].winStreak / FRONTIER_STAGES_PER_CHALLENGE <= challengeNum && gSaveBlock2Ptr->frontier.towerRecords[i].lvlMode == lvlMode && recordHasData && gSaveBlock2Ptr->frontier.towerRecords[i].checksum == checksum) @@ -2502,7 +2508,7 @@ static void ShowPartnerCandidateMessage(void) s32 monId; s32 level = SetFacilityPtrsGetLevel(); u16 winStreak = GetCurrentFacilityWinStreak(); - s32 challengeNum = winStreak / 7; + s32 challengeNum = winStreak / FRONTIER_STAGES_PER_CHALLENGE; s32 k = gSpecialVar_LastTalked - 2; s32 trainerId = gSaveBlock2Ptr->frontier.trainerIds[k]; @@ -2561,7 +2567,7 @@ static void ShowPartnerCandidateMessage(void) gSaveBlock2Ptr->frontier.trainerIds[18] = gFrontierTempParty[0]; gSaveBlock2Ptr->frontier.trainerIds[19] = gFrontierTempParty[1]; } - for (k = 0; k < 14; k++) + for (k = 0; k < FRONTIER_STAGES_PER_CHALLENGE * 2; k++) { while (1) { @@ -2620,7 +2626,7 @@ static void LoadLinkMultiOpponentsData(void) case 0: if (battleMode == FRONTIER_MODE_LINK_MULTIS) { - challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / 7; + challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE; if (IsLinkTaskFinished()) { SendBlock(BitmaskAllOtherLinkPlayers(), &challengeNum, sizeof(challengeNum)); @@ -2640,7 +2646,7 @@ static void LoadLinkMultiOpponentsData(void) challengeNum = gBlockRecvBuffer[0][0]; else challengeNum = gBlockRecvBuffer[1][0]; - for (i = 0; i < 14; i++) + for (i = 0; i < FRONTIER_STAGES_PER_CHALLENGE * 2; i++) { do { @@ -2781,8 +2787,8 @@ u16 GetCurrentBattleTowerWinStreak(u8 lvlMode, u8 battleMode) { u16 winStreak = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode]; - if (winStreak > 9999) - return 9999; + if (winStreak > MAX_STREAK) + return MAX_STREAK; else return winStreak; } @@ -2884,7 +2890,7 @@ static void FillEReaderTrainerWithPlayerData(void) ereaderTrainer->winStreak = 1; j = 7; - for (i = 0; i < 6; i++) + for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++) { ereaderTrainer->greeting[i] = gSaveBlock1Ptr->easyChatBattleStart[i]; ereaderTrainer->farewellPlayerLost[i] = j; @@ -2892,7 +2898,7 @@ static void FillEReaderTrainerWithPlayerData(void) j++; } - for (i = 0; i < 3; i++) + for (i = 0; i < (int)ARRAY_COUNT(ereaderTrainer->party); i++) ConvertPokemonToBattleTowerPokemon(&gPlayerParty[i], &ereaderTrainer->party[i]); SetEReaderTrainerChecksum(ereaderTrainer); @@ -3356,12 +3362,12 @@ u8 GetFrontierEnemyMonLevel(u8 lvlMode) { default: case FRONTIER_LVL_50: - level = 50; + level = FRONTIER_MAX_LEVEL_50; break; case FRONTIER_LVL_OPEN: level = GetHighestLevelInPlayerParty(); - if (level < 60) - level = 60; + if (level < FRONTIER_MIN_LEVEL_OPEN) + level = FRONTIER_MIN_LEVEL_OPEN; break; } @@ -3431,7 +3437,7 @@ static u16 GetBattleTentTrainerId(void) static u8 SetTentPtrsGetLevel(void) { - u8 level = 30; + u8 level = TENT_MIN_LEVEL; u32 facility = VarGet(VAR_FRONTIER_FACILITY); if (facility == FRONTIER_FACILITY_FACTORY) @@ -3456,8 +3462,8 @@ static u8 SetTentPtrsGetLevel(void) } level = GetHighestLevelInPlayerParty(); - if (level < 30) - level = 30; + if (level < TENT_MIN_LEVEL) + level = TENT_MIN_LEVEL; return level; } @@ -3479,7 +3485,7 @@ static void SetNextBattleTentOpponent(void) gTrainerBattleOpponent_A = trainerId; SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_A, 0); - if (gSaveBlock2Ptr->frontier.curChallengeBattleNum + 1 < 3) + if (gSaveBlock2Ptr->frontier.curChallengeBattleNum + 1 < TENT_STAGES_PER_CHALLENGE) gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = gTrainerBattleOpponent_A; } diff --git a/src/battle_transition.c b/src/battle_transition.c index 1e421b5e4..c523cbe7b 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -4762,10 +4762,8 @@ static bool8 FrontierSquaresScroll_End(struct Task *task) BlendPalettes(PALETTES_ALL, 16, RGB_BLACK); DestroyTask(FindTaskIdByFunc(task->func)); + task->tState++; // Changing value of a destroyed task -#ifndef UBFIX - task->tState++; // UB: changing value of a destroyed task -#endif return FALSE; } diff --git a/src/battle_util.c b/src/battle_util.c index e13b5b378..830fb8379 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1870,7 +1870,7 @@ u8 TrySetCantSelectMoveBattleScript(void) } gPotentialItemEffectBattler = gActiveBattler; - if (HOLD_EFFECT_CHOICE(holdEffect) && *choicedMove != MOVE_NONE && *choicedMove != 0xFFFF && *choicedMove != move) + if (HOLD_EFFECT_CHOICE(holdEffect) && *choicedMove != MOVE_NONE && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != move) { gCurrentMove = *choicedMove; gLastUsedItem = gBattleMons[gActiveBattler].item; @@ -1899,7 +1899,7 @@ u8 TrySetCantSelectMoveBattleScript(void) } } if ((GetBattlerAbility(gActiveBattler) == ABILITY_GORILLA_TACTICS) && *choicedMove != MOVE_NONE - && *choicedMove != 0xFFFF && *choicedMove != move) + && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != move) { gCurrentMove = *choicedMove; gLastUsedItem = gBattleMons[gActiveBattler].item; @@ -1962,7 +1962,7 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check) else if (gDisableStructs[battlerId].encoreTimer && gDisableStructs[battlerId].encoredMove != gBattleMons[battlerId].moves[i]) unusableMoves |= gBitTable[i]; // Choice Items - else if (HOLD_EFFECT_CHOICE(holdEffect) && *choicedMove != MOVE_NONE && *choicedMove != 0xFFFF && *choicedMove != gBattleMons[battlerId].moves[i]) + else if (HOLD_EFFECT_CHOICE(holdEffect) && *choicedMove != MOVE_NONE && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != gBattleMons[battlerId].moves[i]) unusableMoves |= gBitTable[i]; // Assault Vest else if (holdEffect == HOLD_EFFECT_ASSAULT_VEST && gBattleMoves[gBattleMons[battlerId].moves[i]].power == 0 && gBattleMons[battlerId].moves[i] != MOVE_ME_FIRST) @@ -1983,7 +1983,7 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check) else if (gBattleMons[battlerId].moves[i] == MOVE_STUFF_CHEEKS && ItemId_GetPocket(gBattleMons[gActiveBattler].item) != POCKET_BERRIES) unusableMoves |= gBitTable[i]; // Gorilla Tactics - else if (GetBattlerAbility(battlerId) == ABILITY_GORILLA_TACTICS && *choicedMove != MOVE_NONE && *choicedMove != 0xFFFF && *choicedMove != gBattleMons[battlerId].moves[i]) + else if (GetBattlerAbility(battlerId) == ABILITY_GORILLA_TACTICS && *choicedMove != MOVE_NONE && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != gBattleMons[battlerId].moves[i]) unusableMoves |= gBitTable[i]; } return unusableMoves; @@ -2143,7 +2143,7 @@ u8 DoFieldEndTurnEffects(void) s32 j; for (j = i + 1; j < gBattlersCount; j++) { - if (GetWhoStrikesFirst(gBattlerByTurnOrder[i], gBattlerByTurnOrder[j], 0)) + if (GetWhoStrikesFirst(gBattlerByTurnOrder[i], gBattlerByTurnOrder[j], FALSE)) SwapTurnOrder(i, j); } } diff --git a/src/berry_blender.c b/src/berry_blender.c index 9b74c7bab..bdf7858ce 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -2238,7 +2238,7 @@ static void CB2_PlayBlender(void) UpdatePaletteFade(); } -static void Blender_DummiedOutFunc(s16 a0, s16 a1) +static void Blender_DummiedOutFunc(s16 bgX, s16 bgY) { } diff --git a/src/berry_crush.c b/src/berry_crush.c index e7a5df951..e6e2d8742 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -2254,7 +2254,7 @@ static u32 Cmd_PrintMessage(struct BerryCrushGame *game, u8 *args) switch (game->cmdState) { case 0: - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); if (args[1] & F_MSG_EXPAND) { StringExpandPlaceholders(gStringVar4, sMessages[args[0]]); @@ -3241,7 +3241,7 @@ static u32 Cmd_SaveGame(struct BerryCrushGame *game, u8 *args) case 2: if (!IsLinkTaskFinished()) return 0; - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); AddTextPrinterParameterized2(0, FONT_NORMAL, gText_SavingDontTurnOffPower, 0, 0, 2, 1, 3); CopyWindowToVram(0, COPYWIN_FULL); CreateTask(Task_LinkFullSave, 0); @@ -3389,7 +3389,7 @@ static u32 Cmd_StopGame(struct BerryCrushGame *game, u8 *args) switch (game->cmdState) { case 0: - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); if (game->playAgainState == PLAY_AGAIN_NO_BERRIES) AddTextPrinterParameterized2(0, FONT_NORMAL, sMessages[MSG_NO_BERRIES], game->textSpeed, 0, 2, 1, 3); else diff --git a/src/coins.c b/src/coins.c index 17fd147b7..4c4739999 100644 --- a/src/coins.c +++ b/src/coins.c @@ -8,7 +8,7 @@ #include "international_string_util.h" #include "constants/coins.h" -EWRAM_DATA u8 sCoinsWindowId = 0; +static EWRAM_DATA u8 sCoinsWindowId = 0; void PrintCoinsString(u32 coinAmount) { diff --git a/src/contest.c b/src/contest.c index 4069d8d22..06809010b 100644 --- a/src/contest.c +++ b/src/contest.c @@ -93,7 +93,7 @@ static void Task_ContestReturnToField(u8); static void FieldCB_ContestReturnToField(void); static bool8 IsPlayerLinkLeader(void); static void PrintContestantTrainerName(u8); -static void PrintContestantTrainerNameWithColor(u8 a0, u8 a1); +static void PrintContestantTrainerNameWithColor(u8, u8); static void PrintContestantMonName(u8); static void PrintContestantMonNameWithColor(u8, u8); static u8 CreateJudgeSprite(void); @@ -352,7 +352,7 @@ EWRAM_DATA u16 gSpecialVar_ContestRank = 0; EWRAM_DATA u8 gNumLinkContestPlayers = 0; EWRAM_DATA u8 gHighestRibbonRank = 0; EWRAM_DATA struct ContestResources *gContestResources = NULL; -EWRAM_DATA u8 sContestBgCopyFlags = 0; +static EWRAM_DATA u8 sContestBgCopyFlags = 0; EWRAM_DATA struct ContestWinner gCurContestWinner = {0}; EWRAM_DATA bool8 gCurContestWinnerIsForArtist = 0; EWRAM_DATA u8 gCurContestWinnerSaveIdx = 0; @@ -625,7 +625,7 @@ static const struct SpriteTemplate sSpriteTemplate_ApplauseMeter = .callback = SpriteCallbackDummy }; -const struct OamData sOam_Judge = +static const struct OamData sOam_Judge = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -639,7 +639,7 @@ const struct OamData sOam_Judge = .paletteNum = 2, }; -const struct SpriteTemplate sSpriteTemplate_Judge = +static const struct SpriteTemplate sSpriteTemplate_Judge = { .tileTag = TAG_JUDGE, .paletteTag = TAG_JUDGE, @@ -650,7 +650,7 @@ const struct SpriteTemplate sSpriteTemplate_Judge = .callback = SpriteCallbackDummy }; -const struct CompressedSpriteSheet sSpriteSheet_Judge = +static const struct CompressedSpriteSheet sSpriteSheet_Judge = { .data = gContestJudgeGfx, .size = 0x800, @@ -664,13 +664,13 @@ static const struct CompressedSpriteSheet sSpriteSheet_JudgeSymbols = .tag = TAG_JUDGE_SYMBOLS_GFX }; -const struct CompressedSpritePalette sSpritePalette_JudgeSymbols = +static const struct CompressedSpritePalette sSpritePalette_JudgeSymbols = { .data = gContestJudgeSymbolsPal, .tag = TAG_CONTEST_SYMBOLS_PAL }; -const struct SpriteTemplate sSpriteTemplate_JudgeSpeechBubble = +static const struct SpriteTemplate sSpriteTemplate_JudgeSpeechBubble = { .tileTag = TAG_JUDGE_SYMBOLS_GFX, .paletteTag = TAG_CONTEST_SYMBOLS_PAL, @@ -876,7 +876,7 @@ static const struct SpritePalette sSpritePalettes_ContestantsTurnBlinkEffect[CON } }; -const struct OamData sOam_ContestantsTurnBlinkEffect = +static const struct OamData sOam_ContestantsTurnBlinkEffect = { .y = 0, .affineMode = ST_OAM_AFFINE_DOUBLE, @@ -891,13 +891,13 @@ const struct OamData sOam_ContestantsTurnBlinkEffect = .affineParam = 0, }; -const union AffineAnimCmd sAffineAnim_ContestantsTurnBlinkEffect_0[] = +static const union AffineAnimCmd sAffineAnim_ContestantsTurnBlinkEffect_0[] = { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), AFFINEANIMCMD_END }; -const union AffineAnimCmd sAffineAnim_ContestantsTurnBlinkEffect_1[] = +static const union AffineAnimCmd sAffineAnim_ContestantsTurnBlinkEffect_1[] = { AFFINEANIMCMD_FRAME(3, 3, 0, 15), AFFINEANIMCMD_FRAME(-3, -3, 0, 15), @@ -906,13 +906,13 @@ const union AffineAnimCmd sAffineAnim_ContestantsTurnBlinkEffect_1[] = AFFINEANIMCMD_END }; -const union AffineAnimCmd *const sAffineAnims_ContestantsTurnBlinkEffect[] = +static const union AffineAnimCmd *const sAffineAnims_ContestantsTurnBlinkEffect[] = { sAffineAnim_ContestantsTurnBlinkEffect_0, sAffineAnim_ContestantsTurnBlinkEffect_1 }; -const struct SpriteTemplate sSpriteTemplates_ContestantsTurnBlinkEffect[CONTESTANT_COUNT] = +static const struct SpriteTemplate sSpriteTemplates_ContestantsTurnBlinkEffect[CONTESTANT_COUNT] = { { .tileTag = TAG_BLINK_EFFECT_CONTESTANT0, @@ -952,7 +952,7 @@ const struct SpriteTemplate sSpriteTemplates_ContestantsTurnBlinkEffect[CONTESTA } }; -static const s8 gContestExcitementTable[CONTEST_CATEGORIES_COUNT][CONTEST_CATEGORIES_COUNT] = +static const s8 sContestExcitementTable[CONTEST_CATEGORIES_COUNT][CONTEST_CATEGORIES_COUNT] = { [CONTEST_CATEGORY_COOL] = { [CONTEST_CATEGORY_COOL] = +1, @@ -3186,14 +3186,14 @@ static u16 GetMoveEffectSymbolTileOffset(u16 move, u8 contestant) return offset; } -static void PrintContestMoveDescription(u16 a) +static void PrintContestMoveDescription(u16 move) { u8 category; u16 categoryTile; u8 numHearts; // The contest category icon is implemented as a 5x2 group of tiles. - category = gContestMoves[a].contestCategory; + category = gContestMoves[move].contestCategory; if (category == CONTEST_CATEGORY_COOL) categoryTile = 0x4040; else if (category == CONTEST_CATEGORY_BEAUTY) @@ -3209,27 +3209,27 @@ static void PrintContestMoveDescription(u16 a) ContestBG_FillBoxWithIncrementingTile(0, categoryTile + 0x10, 0x0b, 0x20, 0x05, 0x01, 0x11, 0x01); // Appeal hearts - if (gContestEffects[gContestMoves[a].effect].appeal == 0xFF) + if (gContestEffects[gContestMoves[move].effect].appeal == 0xFF) numHearts = 0; else - numHearts = gContestEffects[gContestMoves[a].effect].appeal / 10; + numHearts = gContestEffects[gContestMoves[move].effect].appeal / 10; if (numHearts > MAX_CONTEST_MOVE_HEARTS) numHearts = MAX_CONTEST_MOVE_HEARTS; ContestBG_FillBoxWithTile(0, TILE_EMPTY_APPEAL_HEART, 0x15, 0x1f, MAX_CONTEST_MOVE_HEARTS, 0x01, 0x11); ContestBG_FillBoxWithTile(0, TILE_FILLED_APPEAL_HEART, 0x15, 0x1f, numHearts, 0x01, 0x11); // Jam hearts - if (gContestEffects[gContestMoves[a].effect].jam == 0xFF) + if (gContestEffects[gContestMoves[move].effect].jam == 0xFF) numHearts = 0; else - numHearts = gContestEffects[gContestMoves[a].effect].jam / 10; + numHearts = gContestEffects[gContestMoves[move].effect].jam / 10; if (numHearts > MAX_CONTEST_MOVE_HEARTS) numHearts = MAX_CONTEST_MOVE_HEARTS; ContestBG_FillBoxWithTile(0, TILE_EMPTY_JAM_HEART, 0x15, 0x20, MAX_CONTEST_MOVE_HEARTS, 0x01, 0x11); ContestBG_FillBoxWithTile(0, TILE_FILLED_JAM_HEART, 0x15, 0x20, numHearts, 0x01, 0x11); FillWindowPixelBuffer(WIN_MOVE_DESCRIPTION, PIXEL_FILL(0)); - Contest_PrintTextToBg0WindowStd(WIN_MOVE_DESCRIPTION, gContestEffectDescriptionPointers[gContestMoves[a].effect]); + Contest_PrintTextToBg0WindowStd(WIN_MOVE_DESCRIPTION, gContestEffectDescriptionPointers[gContestMoves[move].effect]); Contest_PrintTextToBg0WindowStd(WIN_SLASH, gText_Slash); } @@ -4537,14 +4537,14 @@ static void CalculateAppealMoveImpact(u8 contestant) eContestantStatus[contestant].contestantAnimTarget = i; } -void SetContestantEffectStringID(u8 a, u8 b) +void SetContestantEffectStringID(u8 contestant, u8 effectStringId) { - eContestantStatus[a].effectStringId = b; + eContestantStatus[contestant].effectStringId = effectStringId; } -void SetContestantEffectStringID2(u8 a, u8 b) +void SetContestantEffectStringID2(u8 contestant, u8 effectStringId) { - eContestantStatus[a].effectStringId2 = b; + eContestantStatus[contestant].effectStringId2 = effectStringId; } void SetStartledString(u8 contestant, u8 jam) @@ -4744,7 +4744,7 @@ static void UpdateApplauseMeter(void) s8 Contest_GetMoveExcitement(u16 move) { - return gContestExcitementTable[gSpecialVar_ContestCategory][gContestMoves[move].contestCategory]; + return sContestExcitementTable[gSpecialVar_ContestCategory][gContestMoves[move].contestCategory]; } static u8 StartApplauseOverflowAnimation(void) @@ -5694,6 +5694,8 @@ static void SetContestLiveUpdateFlags(u8 contestant) } } +#define APPEAL_MOVES_END 0xFFFF + static void CalculateContestLiveUpdateData(void) { u8 loser; @@ -5758,7 +5760,7 @@ static void CalculateContestLiveUpdateData(void) appealMoves[i] = MOVE_NONE; numMoveUses[i] = 0; } - appealMoves[CONTEST_NUM_APPEALS] = 0xFFFF; + appealMoves[CONTEST_NUM_APPEALS] = APPEAL_MOVES_END; numMoveUses[CONTEST_NUM_APPEALS] = 0; for (i = 0; i < CONTEST_NUM_APPEALS; i++) @@ -5787,7 +5789,7 @@ static void CalculateContestLiveUpdateData(void) moveCandidates[0] = appealMoves[0]; mostUses = numMoveUses[0]; numMoveCandidates = 0; - for (i = 1; appealMoves[i] != 0xFFFF; i++) + for (i = 1; appealMoves[i] != APPEAL_MOVES_END; i++) { if (mostUses < numMoveUses[i]) { diff --git a/src/contest_util.c b/src/contest_util.c index 1ca217526..d8726d860 100644 --- a/src/contest_util.c +++ b/src/contest_util.c @@ -77,7 +77,10 @@ enum { #define TAG_CONFETTI 3017 #define TAG_WIRELESS_INDICATOR_WINDOW 22222 -#define MAX_BAR_LENGTH 87 +// Length of the score bar on the results screen +#define NUM_BAR_SEGMENTS 11 +#define BAR_SEGMENT_LENGTH 8 // Each segment of the results bar is a single tile, so 8 pixels long +#define MAX_BAR_LENGTH (NUM_BAR_SEGMENTS * BAR_SEGMENT_LENGTH) // Starting x/y for the sliding results screen text box #define TEXT_BOX_X (DISPLAY_WIDTH + 32) @@ -96,7 +99,7 @@ struct ContestResultsInternal u8 winnerMonSpriteId; bool8 destroyConfetti; bool8 pointsFlashing; - s16 unkC[CONTESTANT_COUNT]; + s16 barLength[CONTESTANT_COUNT]; u8 numBarsUpdating; }; @@ -1748,7 +1751,7 @@ static void CalculateContestantsResultData(void) if ((*sContestResults->monResults)[i].lostPoints) barLengthRound2 *= -1; - if (barLengthPreliminary + barLengthRound2 == MAX_BAR_LENGTH + 1) + if (barLengthPreliminary + barLengthRound2 == MAX_BAR_LENGTH) { if (barLengthRound2 > 0) (*sContestResults->monResults)[i].barLengthRound2--; @@ -1841,47 +1844,52 @@ static void Task_UpdateContestResultBar(u8 taskId) s16 target = gTasks[taskId].tTarget; s16 decreasing = gTasks[taskId].tDecreasing; + // Has the results bar reached the limit? if (decreasing) { - if (sContestResults->data->unkC[monId] <= 0) + if (sContestResults->data->barLength[monId] <= 0) minMaxReached = TRUE; } else { - if (sContestResults->data->unkC[monId] > MAX_BAR_LENGTH) + if (sContestResults->data->barLength[monId] >= MAX_BAR_LENGTH) minMaxReached = TRUE; } - if (sContestResults->data->unkC[monId] == target) + if (sContestResults->data->barLength[monId] == target) targetReached = TRUE; if (!targetReached) { + // Target length has not been reached, update bar length if (minMaxReached) - sContestResults->data->unkC[monId] = target; + sContestResults->data->barLength[monId] = target; else if (decreasing) - sContestResults->data->unkC[monId] = sContestResults->data->unkC[monId] - 1; + sContestResults->data->barLength[monId]--; else - sContestResults->data->unkC[monId] = sContestResults->data->unkC[monId] + 1; + sContestResults->data->barLength[monId]++; } + // Update the tiles of the results bar if it's still changing if (!minMaxReached && !targetReached) { - u8 var0; + u8 tileOffset; u16 tileNum; - for (i = 0; i < 11; i++) + for (i = 0; i < NUM_BAR_SEGMENTS; i++) { - if (sContestResults->data->unkC[monId] >= (i + 1) * 8) - var0 = 8; - else if (sContestResults->data->unkC[monId] >= i * 8) - var0 = sContestResults->data->unkC[monId] % 8; + if (sContestResults->data->barLength[monId] >= (i + 1) * BAR_SEGMENT_LENGTH) + tileOffset = 8; // Bar segment is full + else if (sContestResults->data->barLength[monId] >= i * BAR_SEGMENT_LENGTH) + tileOffset = sContestResults->data->barLength[monId] % 8; // Bar segment is between full and empty else - var0 = 0; + tileOffset = 0; // Bar segment is empty - if (var0 < 4) - tileNum = 0x504C + var0; + // The first 4 bar segment tiles are not adjacent in the tileset to the + // remaining bar segment tiles; choose the base tile number accordingly. + if (tileOffset < 4) + tileNum = 0x504C + tileOffset; else - tileNum = 0x5057 + var0; + tileNum = 0x5057 + tileOffset; FillBgTilemapBufferRect_Palette0(2, tileNum, i + 7, monId * 3 + 6, 1, 1); } diff --git a/src/credits.c b/src/credits.c index 43c8d6628..33362fb38 100644 --- a/src/credits.c +++ b/src/credits.c @@ -1285,18 +1285,18 @@ static void ResetCreditsTasks(u8 taskId) gIntroCredits_MovingSceneryState = INTROCRED_SCENERY_DESTROY; } -static void LoadTheEndScreen(u16 arg0, u16 arg1, u16 palOffset) +static void LoadTheEndScreen(u16 tileOffsetLoad, u16 tileOffsetWrite, u16 palOffset) { u16 baseTile; u16 i; - LZ77UnCompVram(sCreditsCopyrightEnd_Gfx, (void *)(VRAM + arg0)); + LZ77UnCompVram(sCreditsCopyrightEnd_Gfx, (void *)(VRAM + tileOffsetLoad)); LoadPalette(gIntroCopyright_Pal, palOffset, sizeof(gIntroCopyright_Pal)); baseTile = (palOffset / 16) << 12; for (i = 0; i < 32 * 32; i++) - ((u16 *) (VRAM + arg1))[i] = baseTile + 1; + ((u16 *) (VRAM + tileOffsetWrite))[i] = baseTile + 1; } static u16 GetLetterMapTile(u8 baseTiles) diff --git a/src/data/battle_frontier/battle_pyramid_open_level_wild_mons.h b/src/data/battle_frontier/battle_pyramid_open_level_wild_mons.h index 043488b93..f87c1bfc4 100644 --- a/src/data/battle_frontier/battle_pyramid_open_level_wild_mons.h +++ b/src/data/battle_frontier/battle_pyramid_open_level_wild_mons.h @@ -1038,7 +1038,7 @@ static const struct PyramidWildMon sOpenLevelWildMons_Round20[] = } }; -static const struct PyramidWildMon *const sOpenLevelWildMonPointers[] = +static const struct PyramidWildMon *const sOpenLevelWildMonPointers[TOTAL_ROUNDS] = { sOpenLevelWildMons_Round1, sOpenLevelWildMons_Round2, diff --git a/src/data/field_effects/field_effect_objects.h b/src/data/field_effects/field_effect_objects.h index 598b88932..938b6bfc5 100755 --- a/src/data/field_effects/field_effect_objects.h +++ b/src/data/field_effects/field_effect_objects.h @@ -1272,7 +1272,7 @@ static const union AnimCmd *const sAnimTable_RayquazaSpotlightEffect[] = { sAnim_RayquazaSpotlightEffect, }; -const struct SpriteFrameImage sPicTable_RayquazaSpotlightEffect[] = { +static const struct SpriteFrameImage sPicTable_RayquazaSpotlightEffect[] = { overworld_frame(gObjectEventPic_Rayquaza, 4, 4, 0), }; diff --git a/src/data/pokemon/base_stats.h b/src/data/pokemon/base_stats.h index 141631643..e60192e84 100644 --- a/src/data/pokemon/base_stats.h +++ b/src/data/pokemon/base_stats.h @@ -20,8 +20,8 @@ .evYield_Speed = 2, \ .evYield_SpAttack = 2, \ .evYield_SpDefense = 2, \ - .item1 = ITEM_NONE, \ - .item2 = ITEM_NONE, \ + .itemCommon = ITEM_NONE, \ + .itemRare = ITEM_NONE, \ .genderRatio = MON_GENDERLESS, \ .eggCycles = 120, \ .friendship = 0, \ @@ -56,8 +56,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -88,8 +88,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -120,8 +120,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -152,8 +152,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -184,8 +184,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -216,8 +216,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 3, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -248,8 +248,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -280,8 +280,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -312,8 +312,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 3, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -344,8 +344,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -376,8 +376,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -408,8 +408,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_SILVER_POWDER, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SILVER_POWDER, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -440,8 +440,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -472,8 +472,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -504,8 +504,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_POISON_BARB, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_POISON_BARB, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -536,8 +536,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -568,8 +568,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -600,8 +600,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 3, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -632,8 +632,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -664,8 +664,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -696,8 +696,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -728,8 +728,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_SHARP_BEAK, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SHARP_BEAK, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -760,8 +760,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -792,8 +792,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -824,8 +824,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_ORAN_BERRY, - .item2 = ITEM_LIGHT_BALL, + .itemCommon = ITEM_ORAN_BERRY, + .itemRare = ITEM_LIGHT_BALL, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 10, .friendship = 70, @@ -856,8 +856,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 3, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_ORAN_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_ORAN_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 10, .friendship = 70, @@ -888,8 +888,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_QUICK_CLAW, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_QUICK_CLAW, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -920,8 +920,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_QUICK_CLAW, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_QUICK_CLAW, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -952,8 +952,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_FEMALE, .eggCycles = 20, .friendship = 70, @@ -984,8 +984,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_FEMALE, .eggCycles = 20, .friendship = 70, @@ -1016,8 +1016,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_FEMALE, .eggCycles = 20, .friendship = 70, @@ -1048,8 +1048,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_MALE, .eggCycles = 20, .friendship = 70, @@ -1080,8 +1080,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_MALE, .eggCycles = 20, .friendship = 70, @@ -1112,8 +1112,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_MALE, .eggCycles = 20, .friendship = 70, @@ -1144,8 +1144,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_LEPPA_BERRY, - .item2 = ITEM_MOON_STONE, + .itemCommon = ITEM_LEPPA_BERRY, + .itemRare = ITEM_MOON_STONE, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 10, .friendship = 140, @@ -1176,8 +1176,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_LEPPA_BERRY, - .item2 = ITEM_MOON_STONE, + .itemCommon = ITEM_LEPPA_BERRY, + .itemRare = ITEM_MOON_STONE, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 10, .friendship = 140, @@ -1208,8 +1208,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_RAWST_BERRY, - .item2 = ITEM_RAWST_BERRY, + .itemCommon = ITEM_RAWST_BERRY, + .itemRare = ITEM_RAWST_BERRY, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 20, .friendship = 70, @@ -1240,8 +1240,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_RAWST_BERRY, - .item2 = ITEM_RAWST_BERRY, + .itemCommon = ITEM_RAWST_BERRY, + .itemRare = ITEM_RAWST_BERRY, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 20, .friendship = 70, @@ -1272,8 +1272,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 10, .friendship = 70, @@ -1304,8 +1304,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 10, .friendship = 70, @@ -1336,8 +1336,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -1368,8 +1368,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -1400,8 +1400,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1432,8 +1432,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1464,8 +1464,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 3, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1496,8 +1496,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_TINY_MUSHROOM, - .item2 = ITEM_BIG_MUSHROOM, + .itemCommon = ITEM_TINY_MUSHROOM, + .itemRare = ITEM_BIG_MUSHROOM, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1528,8 +1528,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_TINY_MUSHROOM, - .item2 = ITEM_BIG_MUSHROOM, + .itemCommon = ITEM_TINY_MUSHROOM, + .itemRare = ITEM_BIG_MUSHROOM, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1560,8 +1560,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1592,8 +1592,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1624,8 +1624,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1656,8 +1656,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1688,8 +1688,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1720,8 +1720,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1752,8 +1752,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1784,8 +1784,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1816,8 +1816,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1848,8 +1848,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1880,8 +1880,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_RAWST_BERRY, - .item2 = ITEM_RAWST_BERRY, + .itemCommon = ITEM_RAWST_BERRY, + .itemRare = ITEM_RAWST_BERRY, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 20, .friendship = 70, @@ -1912,8 +1912,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_RAWST_BERRY, - .item2 = ITEM_RAWST_BERRY, + .itemCommon = ITEM_RAWST_BERRY, + .itemRare = ITEM_RAWST_BERRY, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 20, .friendship = 70, @@ -1944,8 +1944,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -1976,8 +1976,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_KINGS_ROCK, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_KINGS_ROCK, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2008,8 +2008,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_KINGS_ROCK, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_KINGS_ROCK, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2040,8 +2040,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_TWISTED_SPOON, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_TWISTED_SPOON, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 20, .friendship = 70, @@ -2072,8 +2072,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_TWISTED_SPOON, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_TWISTED_SPOON, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 20, .friendship = 70, @@ -2104,8 +2104,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 3, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_TWISTED_SPOON, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_TWISTED_SPOON, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 20, .friendship = 70, @@ -2136,8 +2136,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 20, .friendship = 70, @@ -2168,8 +2168,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 20, .friendship = 70, @@ -2200,8 +2200,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 20, .friendship = 70, @@ -2232,8 +2232,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2264,8 +2264,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2296,8 +2296,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2328,8 +2328,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2360,8 +2360,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2392,8 +2392,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_EVERSTONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_EVERSTONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -2424,8 +2424,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_EVERSTONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_EVERSTONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -2456,8 +2456,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_EVERSTONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_EVERSTONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -2488,8 +2488,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2520,8 +2520,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2552,8 +2552,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_KINGS_ROCK, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_KINGS_ROCK, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2584,8 +2584,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_KINGS_ROCK, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_KINGS_ROCK, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2616,8 +2616,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_METAL_COAT, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_METAL_COAT, .genderRatio = MON_GENDERLESS, .eggCycles = 20, .friendship = 70, @@ -2648,8 +2648,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_METAL_COAT, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_METAL_COAT, .genderRatio = MON_GENDERLESS, .eggCycles = 20, .friendship = 70, @@ -2680,8 +2680,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_STICK, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_STICK, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2712,8 +2712,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_SHARP_BEAK, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SHARP_BEAK, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2744,8 +2744,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_SHARP_BEAK, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SHARP_BEAK, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2776,8 +2776,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2808,8 +2808,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2840,8 +2840,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NUGGET, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NUGGET, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2872,8 +2872,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NUGGET, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NUGGET, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2904,8 +2904,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_PEARL, - .item2 = ITEM_BIG_PEARL, + .itemCommon = ITEM_PEARL, + .itemRare = ITEM_BIG_PEARL, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2936,8 +2936,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_PEARL, - .item2 = ITEM_BIG_PEARL, + .itemCommon = ITEM_PEARL, + .itemRare = ITEM_BIG_PEARL, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -2968,8 +2968,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3000,8 +3000,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3032,8 +3032,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 3, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3064,8 +3064,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 70, @@ -3096,8 +3096,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3128,8 +3128,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3160,8 +3160,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3192,8 +3192,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3224,8 +3224,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 20, .friendship = 70, @@ -3256,8 +3256,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 20, .friendship = 70, @@ -3288,8 +3288,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3320,8 +3320,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3352,8 +3352,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_THICK_CLUB, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_THICK_CLUB, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3384,8 +3384,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_THICK_CLUB, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_THICK_CLUB, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3416,8 +3416,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_MALE, .eggCycles = 25, .friendship = 70, @@ -3448,8 +3448,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_MALE, .eggCycles = 25, .friendship = 70, @@ -3480,8 +3480,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3512,8 +3512,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_SMOKE_BALL, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SMOKE_BALL, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3544,8 +3544,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_SMOKE_BALL, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SMOKE_BALL, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3576,8 +3576,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3608,8 +3608,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3640,8 +3640,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_LUCKY_EGG, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_LUCKY_EGG, .genderRatio = MON_FEMALE, .eggCycles = 40, .friendship = 140, @@ -3672,8 +3672,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3704,8 +3704,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_FEMALE, .eggCycles = 20, .friendship = 70, @@ -3736,8 +3736,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_DRAGON_SCALE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_DRAGON_SCALE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3768,8 +3768,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_DRAGON_SCALE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_DRAGON_SCALE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3800,8 +3800,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3832,8 +3832,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -3864,8 +3864,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_STARDUST, - .item2 = ITEM_STAR_PIECE, + .itemCommon = ITEM_STARDUST, + .itemRare = ITEM_STAR_PIECE, .genderRatio = MON_GENDERLESS, .eggCycles = 20, .friendship = 70, @@ -3896,8 +3896,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_STARDUST, - .item2 = ITEM_STAR_PIECE, + .itemCommon = ITEM_STARDUST, + .itemRare = ITEM_STAR_PIECE, .genderRatio = MON_GENDERLESS, .eggCycles = 20, .friendship = 70, @@ -3928,8 +3928,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_LEPPA_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_LEPPA_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 70, @@ -3960,8 +3960,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 70, @@ -3992,8 +3992,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_ASPEAR_BERRY, - .item2 = ITEM_ASPEAR_BERRY, + .itemCommon = ITEM_ASPEAR_BERRY, + .itemRare = ITEM_ASPEAR_BERRY, .genderRatio = MON_FEMALE, .eggCycles = 25, .friendship = 70, @@ -4024,8 +4024,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 25, .friendship = 70, @@ -4056,8 +4056,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_RAWST_BERRY, - .item2 = ITEM_RAWST_BERRY, + .itemCommon = ITEM_RAWST_BERRY, + .itemRare = ITEM_RAWST_BERRY, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 25, .friendship = 70, @@ -4088,8 +4088,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 70, @@ -4120,8 +4120,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_MALE, .eggCycles = 20, .friendship = 70, @@ -4152,8 +4152,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 5, .friendship = 70, @@ -4184,8 +4184,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 5, .friendship = 70, @@ -4216,8 +4216,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 40, .friendship = 70, @@ -4248,8 +4248,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_METAL_POWDER, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_METAL_POWDER, .genderRatio = MON_GENDERLESS, .eggCycles = 20, .friendship = 70, @@ -4280,8 +4280,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 35, .friendship = 70, @@ -4312,8 +4312,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 35, .friendship = 70, @@ -4344,8 +4344,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 35, .friendship = 70, @@ -4376,8 +4376,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 35, .friendship = 70, @@ -4408,8 +4408,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 20, .friendship = 70, @@ -4440,8 +4440,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 30, .friendship = 70, @@ -4472,8 +4472,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 30, .friendship = 70, @@ -4504,8 +4504,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 30, .friendship = 70, @@ -4536,8 +4536,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 30, .friendship = 70, @@ -4568,8 +4568,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 35, .friendship = 70, @@ -4600,8 +4600,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_LEFTOVERS, - .item2 = ITEM_LEFTOVERS, + .itemCommon = ITEM_LEFTOVERS, + .itemRare = ITEM_LEFTOVERS, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 40, .friendship = 70, @@ -4632,8 +4632,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 3, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 80, .friendship = 35, @@ -4664,8 +4664,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 3, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 80, .friendship = 35, @@ -4696,8 +4696,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 3, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 80, .friendship = 35, @@ -4728,8 +4728,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_DRAGON_SCALE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_DRAGON_SCALE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 40, .friendship = 35, @@ -4760,8 +4760,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_DRAGON_SCALE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_DRAGON_SCALE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 40, .friendship = 35, @@ -4792,8 +4792,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_DRAGON_SCALE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_DRAGON_SCALE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 40, .friendship = 35, @@ -4824,8 +4824,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 3, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 120, .friendship = 0, @@ -4856,8 +4856,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_LUM_BERRY, - .item2 = ITEM_LUM_BERRY, + .itemCommon = ITEM_LUM_BERRY, + .itemRare = ITEM_LUM_BERRY, .genderRatio = MON_GENDERLESS, .eggCycles = 120, .friendship = 100, @@ -4888,8 +4888,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -4920,8 +4920,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -4952,8 +4952,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -4984,8 +4984,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -5016,8 +5016,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -5048,8 +5048,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 3, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -5080,8 +5080,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -5112,8 +5112,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -5144,8 +5144,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -5176,8 +5176,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_ORAN_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_ORAN_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -5208,8 +5208,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_ORAN_BERRY, - .item2 = ITEM_SITRUS_BERRY, + .itemCommon = ITEM_ORAN_BERRY, + .itemRare = ITEM_SITRUS_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -5240,8 +5240,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -5272,8 +5272,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -5304,8 +5304,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -5336,8 +5336,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -5368,8 +5368,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -5400,8 +5400,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -5432,8 +5432,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 3, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -5464,8 +5464,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_YELLOW_SHARD, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_YELLOW_SHARD, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -5496,8 +5496,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_YELLOW_SHARD, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_YELLOW_SHARD, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -5528,8 +5528,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_ORAN_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_ORAN_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 10, .friendship = 70, @@ -5560,8 +5560,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_LEPPA_BERRY, - .item2 = ITEM_MOON_STONE, + .itemCommon = ITEM_LEPPA_BERRY, + .itemRare = ITEM_MOON_STONE, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 10, .friendship = 140, @@ -5592,8 +5592,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 10, .friendship = 70, @@ -5624,8 +5624,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 10, .friendship = 70, @@ -5656,8 +5656,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 10, .friendship = 70, @@ -5688,8 +5688,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -5720,8 +5720,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -5752,8 +5752,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -5784,8 +5784,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -5816,8 +5816,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 3, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -5848,8 +5848,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 3, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -5880,8 +5880,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 10, .friendship = 70, @@ -5912,8 +5912,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 10, .friendship = 70, @@ -5944,8 +5944,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -5976,8 +5976,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 3, - .item1 = ITEM_NONE, - .item2 = ITEM_KINGS_ROCK, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_KINGS_ROCK, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6008,8 +6008,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6040,8 +6040,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6072,8 +6072,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 3, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6104,8 +6104,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6136,8 +6136,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6168,8 +6168,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6200,8 +6200,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6232,8 +6232,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6264,8 +6264,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6296,8 +6296,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 35, .friendship = 70, @@ -6328,8 +6328,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 35, .friendship = 35, @@ -6360,8 +6360,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 35, @@ -6392,8 +6392,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 3, - .item1 = ITEM_NONE, - .item2 = ITEM_KINGS_ROCK, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_KINGS_ROCK, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6424,8 +6424,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_SPELL_TAG, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SPELL_TAG, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 35, @@ -6456,8 +6456,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 40, .friendship = 70, @@ -6488,8 +6488,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6520,8 +6520,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_PERSIM_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_PERSIM_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6552,8 +6552,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6584,8 +6584,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6616,8 +6616,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6648,8 +6648,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6680,8 +6680,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_METAL_COAT, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_METAL_COAT, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 70, @@ -6712,8 +6712,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 20, .friendship = 70, @@ -6744,8 +6744,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 20, .friendship = 70, @@ -6776,8 +6776,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6808,8 +6808,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 70, @@ -6840,8 +6840,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_ORAN_BERRY, - .item2 = ITEM_ORAN_BERRY, + .itemCommon = ITEM_ORAN_BERRY, + .itemRare = ITEM_ORAN_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6872,8 +6872,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 70, @@ -6904,8 +6904,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_QUICK_CLAW, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_QUICK_CLAW, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 35, @@ -6936,8 +6936,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -6968,8 +6968,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -7000,8 +7000,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -7032,8 +7032,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -7064,8 +7064,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -7096,8 +7096,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -7128,8 +7128,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_RED_SHARD, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_RED_SHARD, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 20, .friendship = 70, @@ -7160,8 +7160,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -7192,8 +7192,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -7224,8 +7224,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -7256,8 +7256,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 70, @@ -7288,8 +7288,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 70, @@ -7320,8 +7320,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 35, @@ -7352,8 +7352,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 35, @@ -7384,8 +7384,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_DRAGON_SCALE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_DRAGON_SCALE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -7416,8 +7416,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -7448,8 +7448,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -7480,8 +7480,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 20, .friendship = 70, @@ -7512,8 +7512,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -7544,8 +7544,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -7576,8 +7576,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_MALE, .eggCycles = 25, .friendship = 70, @@ -7608,8 +7608,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_MALE, .eggCycles = 25, .friendship = 70, @@ -7640,8 +7640,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_ASPEAR_BERRY, - .item2 = ITEM_ASPEAR_BERRY, + .itemCommon = ITEM_ASPEAR_BERRY, + .itemRare = ITEM_ASPEAR_BERRY, .genderRatio = MON_FEMALE, .eggCycles = 25, .friendship = 70, @@ -7672,8 +7672,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 25, .friendship = 70, @@ -7704,8 +7704,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_RAWST_BERRY, - .item2 = ITEM_RAWST_BERRY, + .itemCommon = ITEM_RAWST_BERRY, + .itemRare = ITEM_RAWST_BERRY, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 25, .friendship = 70, @@ -7736,8 +7736,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_MOOMOO_MILK, - .item2 = ITEM_MOOMOO_MILK, + .itemCommon = ITEM_MOOMOO_MILK, + .itemRare = ITEM_MOOMOO_MILK, .genderRatio = MON_FEMALE, .eggCycles = 20, .friendship = 70, @@ -7768,8 +7768,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_LUCKY_EGG, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_LUCKY_EGG, .genderRatio = MON_FEMALE, .eggCycles = 40, .friendship = 140, @@ -7800,8 +7800,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 80, .friendship = 35, @@ -7832,8 +7832,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 80, .friendship = 35, @@ -7864,8 +7864,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 80, .friendship = 35, @@ -7896,8 +7896,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 40, .friendship = 35, @@ -7928,8 +7928,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 40, .friendship = 35, @@ -7960,8 +7960,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 40, .friendship = 35, @@ -7992,8 +7992,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 3, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 120, .friendship = 0, @@ -8024,8 +8024,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 3, - .item1 = ITEM_SACRED_ASH, - .item2 = ITEM_SACRED_ASH, + .itemCommon = ITEM_SACRED_ASH, + .itemRare = ITEM_SACRED_ASH, .genderRatio = MON_GENDERLESS, .eggCycles = 120, .friendship = 0, @@ -8056,8 +8056,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_LUM_BERRY, - .item2 = ITEM_LUM_BERRY, + .itemCommon = ITEM_LUM_BERRY, + .itemRare = ITEM_LUM_BERRY, .genderRatio = MON_GENDERLESS, .eggCycles = 120, .friendship = 100, @@ -8138,8 +8138,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -8170,8 +8170,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -8202,8 +8202,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 3, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -8234,8 +8234,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -8266,8 +8266,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -8298,8 +8298,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -8330,8 +8330,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -8362,8 +8362,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -8394,8 +8394,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 20, .friendship = 70, @@ -8426,8 +8426,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_PECHA_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_PECHA_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8458,8 +8458,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_PECHA_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_PECHA_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8490,8 +8490,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_ORAN_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_ORAN_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8522,8 +8522,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_ORAN_BERRY, - .item2 = ITEM_SITRUS_BERRY, + .itemCommon = ITEM_ORAN_BERRY, + .itemRare = ITEM_SITRUS_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8554,8 +8554,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8586,8 +8586,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8618,8 +8618,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 3, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_SILVER_POWDER, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SILVER_POWDER, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8650,8 +8650,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8682,8 +8682,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 3, - .item1 = ITEM_NONE, - .item2 = ITEM_SILVER_POWDER, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SILVER_POWDER, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8714,8 +8714,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8746,8 +8746,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8778,8 +8778,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 3, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8810,8 +8810,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8842,8 +8842,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8874,8 +8874,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8906,8 +8906,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8938,8 +8938,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -8970,8 +8970,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 15, .friendship = 70, @@ -9002,8 +9002,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -9034,8 +9034,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -9066,8 +9066,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -9098,8 +9098,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -9130,8 +9130,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_CHESTO_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_CHESTO_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -9162,8 +9162,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -9194,8 +9194,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -9226,8 +9226,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -9258,8 +9258,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_SILVER_POWDER, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SILVER_POWDER, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -9290,8 +9290,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 40, .friendship = 70, @@ -9322,8 +9322,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 40, .friendship = 70, @@ -9354,8 +9354,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_LEPPA_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_LEPPA_BERRY, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 15, .friendship = 70, @@ -9386,8 +9386,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_LEPPA_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_LEPPA_BERRY, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 15, .friendship = 70, @@ -9418,8 +9418,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_PERSIM_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_PERSIM_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -9450,8 +9450,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 20, .friendship = 70, @@ -9482,8 +9482,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 20, .friendship = 70, @@ -9514,8 +9514,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -9546,8 +9546,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -9578,8 +9578,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 35, @@ -9610,8 +9610,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -9642,8 +9642,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -9674,8 +9674,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_HEART_SCALE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_HEART_SCALE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 20, .friendship = 70, @@ -9706,8 +9706,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -9738,8 +9738,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -9770,8 +9770,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -9802,8 +9802,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -9834,8 +9834,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 35, @@ -9866,8 +9866,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 35, @@ -9898,8 +9898,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_SOFT_SAND, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SOFT_SAND, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -9930,8 +9930,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -9962,8 +9962,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -9994,8 +9994,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 20, .friendship = 70, @@ -10026,8 +10026,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_KINGS_ROCK, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_KINGS_ROCK, .genderRatio = PERCENT_FEMALE(25), .eggCycles = 20, .friendship = 70, @@ -10058,8 +10058,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10090,8 +10090,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10122,8 +10122,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_RAWST_BERRY, - .item2 = ITEM_RAWST_BERRY, + .itemCommon = ITEM_RAWST_BERRY, + .itemRare = ITEM_RAWST_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10154,8 +10154,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_RAWST_BERRY, - .item2 = ITEM_RAWST_BERRY, + .itemCommon = ITEM_RAWST_BERRY, + .itemRare = ITEM_RAWST_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10186,8 +10186,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10218,8 +10218,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10250,8 +10250,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10282,8 +10282,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_POISON_BARB, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_POISON_BARB, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 35, @@ -10314,8 +10314,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_POISON_BARB, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_POISON_BARB, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 35, @@ -10346,8 +10346,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10378,8 +10378,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NEVER_MELT_ICE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NEVER_MELT_ICE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10410,8 +10410,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_MOON_STONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_MOON_STONE, .genderRatio = MON_GENDERLESS, .eggCycles = 25, .friendship = 70, @@ -10442,8 +10442,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_SUN_STONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SUN_STONE, .genderRatio = MON_GENDERLESS, .eggCycles = 25, .friendship = 70, @@ -10474,8 +10474,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(75), .eggCycles = 10, .friendship = 70, @@ -10506,8 +10506,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10538,8 +10538,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10570,8 +10570,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10602,8 +10602,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10634,8 +10634,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10666,8 +10666,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10698,8 +10698,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10730,8 +10730,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10762,8 +10762,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10794,8 +10794,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10826,8 +10826,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_SPELL_TAG, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SPELL_TAG, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 35, @@ -10858,8 +10858,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_SPELL_TAG, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SPELL_TAG, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 35, @@ -10890,8 +10890,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_POISON_BARB, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_POISON_BARB, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -10922,8 +10922,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -10954,8 +10954,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 2, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -10986,8 +10986,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 15, .friendship = 70, @@ -11018,8 +11018,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_BIG_PEARL, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_BIG_PEARL, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -11050,8 +11050,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_BIG_PEARL, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_BIG_PEARL, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -11082,8 +11082,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 70, @@ -11114,8 +11114,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_CHESTO_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_CHESTO_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -11146,8 +11146,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_CHESTO_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_CHESTO_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -11178,8 +11178,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_CHESTO_BERRY, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_CHESTO_BERRY, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -11210,8 +11210,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_BLUE_SHARD, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_BLUE_SHARD, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -11242,8 +11242,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -11274,8 +11274,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -11306,8 +11306,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 35, @@ -11338,8 +11338,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_SPELL_TAG, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SPELL_TAG, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 35, @@ -11370,8 +11370,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_SPELL_TAG, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_SPELL_TAG, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 35, @@ -11402,8 +11402,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -11434,8 +11434,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 70, @@ -11466,8 +11466,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_GREEN_SHARD, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_GREEN_SHARD, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 40, .friendship = 70, @@ -11498,8 +11498,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_HARD_STONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_HARD_STONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 35, .friendship = 35, @@ -11530,8 +11530,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_HARD_STONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_HARD_STONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 35, .friendship = 35, @@ -11562,8 +11562,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_HARD_STONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_HARD_STONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 35, .friendship = 35, @@ -11594,8 +11594,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_MYSTIC_WATER, - .item2 = ITEM_MYSTIC_WATER, + .itemCommon = ITEM_MYSTIC_WATER, + .itemRare = ITEM_MYSTIC_WATER, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 70, @@ -11626,8 +11626,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_MALE, .eggCycles = 15, .friendship = 70, @@ -11658,8 +11658,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_FEMALE, .eggCycles = 15, .friendship = 70, @@ -11690,8 +11690,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 30, .friendship = 70, @@ -11722,8 +11722,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 2, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 30, .friendship = 70, @@ -11754,8 +11754,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 30, .friendship = 70, @@ -11786,8 +11786,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(12.5), .eggCycles = 30, .friendship = 70, @@ -11818,8 +11818,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 35, @@ -11850,8 +11850,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 2, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 35, @@ -11882,8 +11882,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 3, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 20, .friendship = 35, @@ -11914,8 +11914,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_DRAGON_SCALE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_DRAGON_SCALE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 40, .friendship = 35, @@ -11946,8 +11946,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_DRAGON_SCALE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_DRAGON_SCALE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 40, .friendship = 35, @@ -11978,8 +11978,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_DRAGON_SCALE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_DRAGON_SCALE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 40, .friendship = 35, @@ -12010,8 +12010,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_METAL_COAT, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_METAL_COAT, .genderRatio = MON_GENDERLESS, .eggCycles = 40, .friendship = 35, @@ -12042,8 +12042,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_METAL_COAT, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_METAL_COAT, .genderRatio = MON_GENDERLESS, .eggCycles = 40, .friendship = 35, @@ -12074,8 +12074,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_METAL_COAT, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_METAL_COAT, .genderRatio = MON_GENDERLESS, .eggCycles = 40, .friendship = 35, @@ -12106,8 +12106,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 80, .friendship = 35, @@ -12138,8 +12138,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 3, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 80, .friendship = 35, @@ -12170,8 +12170,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 80, .friendship = 35, @@ -12202,8 +12202,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 3, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 120, .friendship = 0, @@ -12234,8 +12234,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 120, .friendship = 0, @@ -12266,8 +12266,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 120, .friendship = 0, @@ -12298,8 +12298,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 3, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_FEMALE, .eggCycles = 120, .friendship = 90, @@ -12330,8 +12330,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 3, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_MALE, .eggCycles = 120, .friendship = 90, @@ -12362,8 +12362,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 0, .evYield_SpDefense = 0, - .item1 = ITEM_STAR_PIECE, - .item2 = ITEM_STAR_PIECE, + .itemCommon = ITEM_STAR_PIECE, + .itemRare = ITEM_STAR_PIECE, .genderRatio = MON_GENDERLESS, .eggCycles = 120, .friendship = 100, @@ -12394,8 +12394,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 1, .evYield_SpAttack = 1, .evYield_SpDefense = 0, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = MON_GENDERLESS, .eggCycles = 120, .friendship = 0, @@ -12426,8 +12426,8 @@ const struct BaseStats gBaseStats[] = .evYield_Speed = 0, .evYield_SpAttack = 1, .evYield_SpDefense = 1, - .item1 = ITEM_NONE, - .item2 = ITEM_NONE, + .itemCommon = ITEM_NONE, + .itemRare = ITEM_NONE, .genderRatio = PERCENT_FEMALE(50), .eggCycles = 25, .friendship = 70, diff --git a/src/data/trade.h b/src/data/trade.h index b26072763..80d17a49b 100644 --- a/src/data/trade.h +++ b/src/data/trade.h @@ -174,10 +174,10 @@ static const struct SpriteTemplate sSpriteTemplate_MenuText = .callback = SpriteCallbackDummy, }; -static const u16 TradeScreenTextPalette[] = INCBIN_U16("graphics/trade/text.gbapal"); -static const struct SpritePalette gSpritePalette_TradeScreenText = +static const u16 sTradeScreenTextPalette[] = INCBIN_U16("graphics/trade/text.gbapal"); +static const struct SpritePalette sSpritePalette_TradeScreenText = { - .data = TradeScreenTextPalette, + .data = sTradeScreenTextPalette, .tag = PALTAG_MENU_TEXT }; diff --git a/src/data/trainer_graphics/back_pic_anims.h b/src/data/trainer_graphics/back_pic_anims.h index 821039cb3..ed12e0cb4 100644 --- a/src/data/trainer_graphics/back_pic_anims.h +++ b/src/data/trainer_graphics/back_pic_anims.h @@ -1,4 +1,4 @@ -static const union AnimCmd gAnimCmd_Brendan_1[] = +static const union AnimCmd sAnimCmd_Brendan_1[] = { ANIMCMD_FRAME(0, 24), ANIMCMD_FRAME(1, 9), @@ -8,7 +8,7 @@ static const union AnimCmd gAnimCmd_Brendan_1[] = ANIMCMD_END, }; -static const union AnimCmd gAnimCmd_May_Steven_1[] = +static const union AnimCmd sAnimCmd_May_Steven_1[] = { ANIMCMD_FRAME(0, 24), ANIMCMD_FRAME(1, 9), @@ -18,7 +18,7 @@ static const union AnimCmd gAnimCmd_May_Steven_1[] = ANIMCMD_END, }; -static const union AnimCmd gAnimCmd_Wally_1[] = +static const union AnimCmd sAnimCmd_Wally_1[] = { ANIMCMD_FRAME(0, 24), ANIMCMD_FRAME(1, 9), @@ -28,7 +28,7 @@ static const union AnimCmd gAnimCmd_Wally_1[] = ANIMCMD_END, }; -static const union AnimCmd gAnimCmd_Red_1[] = +static const union AnimCmd sAnimCmd_Red_1[] = { ANIMCMD_FRAME(1, 20), ANIMCMD_FRAME(2, 6), @@ -38,7 +38,7 @@ static const union AnimCmd gAnimCmd_Red_1[] = ANIMCMD_END, }; -static const union AnimCmd gAnimCmd_Leaf_1[] = +static const union AnimCmd sAnimCmd_Leaf_1[] = { ANIMCMD_FRAME(1, 20), ANIMCMD_FRAME(2, 6), @@ -48,7 +48,7 @@ static const union AnimCmd gAnimCmd_Leaf_1[] = ANIMCMD_END, }; -static const union AnimCmd gAnimCmd_RubySapphireBrendan_1[] = +static const union AnimCmd sAnimCmd_RubySapphireBrendan_1[] = { ANIMCMD_FRAME(0, 24), ANIMCMD_FRAME(1, 9), @@ -58,7 +58,7 @@ static const union AnimCmd gAnimCmd_RubySapphireBrendan_1[] = ANIMCMD_END, }; -static const union AnimCmd gAnimCmd_RubySapphireMay_1[] = +static const union AnimCmd sAnimCmd_RubySapphireMay_1[] = { ANIMCMD_FRAME(0, 24), ANIMCMD_FRAME(1, 9), @@ -71,49 +71,49 @@ static const union AnimCmd gAnimCmd_RubySapphireMay_1[] = static const union AnimCmd *const sBackAnims_Brendan[] = { sAnim_GeneralFrame3, - gAnimCmd_Brendan_1, + sAnimCmd_Brendan_1, }; static const union AnimCmd *const sBackAnims_May[] = { sAnim_GeneralFrame3, - gAnimCmd_May_Steven_1, + sAnimCmd_May_Steven_1, }; static const union AnimCmd *const sBackAnims_Red[] = { sAnim_GeneralFrame0, - gAnimCmd_Red_1, + sAnimCmd_Red_1, }; static const union AnimCmd *const sBackAnims_Leaf[] = { sAnim_GeneralFrame0, - gAnimCmd_Leaf_1, + sAnimCmd_Leaf_1, }; static const union AnimCmd *const sBackAnims_RubySapphireBrendan[] = { sAnim_GeneralFrame3, - gAnimCmd_RubySapphireBrendan_1, + sAnimCmd_RubySapphireBrendan_1, }; static const union AnimCmd *const sBackAnims_RubySapphireMay[] = { sAnim_GeneralFrame3, - gAnimCmd_RubySapphireMay_1, + sAnimCmd_RubySapphireMay_1, }; static const union AnimCmd *const sBackAnims_Wally[] = { sAnim_GeneralFrame3, - gAnimCmd_Wally_1, + sAnimCmd_Wally_1, }; static const union AnimCmd *const sBackAnims_Steven[] = { sAnim_GeneralFrame3, - gAnimCmd_May_Steven_1, + sAnimCmd_May_Steven_1, }; const union AnimCmd *const *const gTrainerBackAnimsPtrTable[] = diff --git a/src/decompress.c b/src/decompress.c index b74d4e814..92c840a63 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -51,13 +51,13 @@ void LoadCompressedSpritePalette(const struct CompressedSpritePalette *src) LoadSpritePalette(&dest); } -void LoadCompressedSpritePaletteOverrideBuffer(const struct CompressedSpritePalette *a, void *buffer) +void LoadCompressedSpritePaletteOverrideBuffer(const struct CompressedSpritePalette *src, void *buffer) { struct SpritePalette dest; - LZ77UnCompWram(a->data, buffer); + LZ77UnCompWram(src->data, buffer); dest.data = buffer; - dest.tag = a->tag; + dest.tag = src->tag; LoadSpritePalette(&dest); } diff --git a/src/decoration.c b/src/decoration.c index 7e102251a..547b05acf 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -826,7 +826,7 @@ static void ReturnToActionsMenuFromCategories(u8 taskId) { RemoveDecorationWindow(WINDOW_DECORATION_CATEGORIES); AddDecorationActionsWindow(); - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); PrintCurMainMenuDescription(); gTasks[taskId].func = HandleDecorationActionsMenuInput; } @@ -2664,7 +2664,7 @@ static void FieldCB_StopPuttingAwayDecorations(void) u8 taskId; FadeInFromBlack(); - DrawDialogueFrame(0, 1); + DrawDialogueFrame(0, TRUE); InitDecorationActionsWindow(); taskId = CreateTask(Task_ReinitializeDecorationMenuHandler, 8); gTasks[taskId].tState = 0; diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 691ca6b2a..b87fe3092 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -2879,10 +2879,10 @@ static u8 TryGivePrize(void) return PRIZE_RECEIVED; } -static u32 IncrementWithLimit(u32 a, u32 max) +static u32 IncrementWithLimit(u32 num, u32 max) { - if (a < max) - return a + 1; + if (num < max) + return num + 1; else return max; } @@ -4546,7 +4546,7 @@ struct { u8 id; void (*func)(void); -} const sGfxFuncs[] = +} static const sGfxFuncs[] = { {GFXFUNC_LOAD, LoadGfx}, // Element not used, LoadGfx is passed directly to SetGfxFunc {GFXFUNC_SHOW_NAMES, ShowNames}, diff --git a/src/easy_chat.c b/src/easy_chat.c index 734fd4f18..2bbd16cb2 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -1492,7 +1492,7 @@ void ShowEasyChatScreen(void) displayedPersonType = EASY_CHAT_PERSON_REPORTER_MALE; break; case EASY_CHAT_TYPE_BATTLE_TOWER_INTERVIEW: - words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanclubOpinions.words18; + words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].bravoTrainerTower.words; displayedPersonType = EASY_CHAT_PERSON_REPORTER_FEMALE; break; case EASY_CHAT_TYPE_GOOD_SAYING: @@ -1672,8 +1672,7 @@ static bool8 InitEasyChatScreenStruct(u8 type, u16 *words, u8 displayedPersonTyp static void FreeEasyChatScreenStruct(void) { - if (sEasyChatScreen != NULL) - FREE_AND_SET_NULL(sEasyChatScreen); + TRY_FREE_AND_SET_NULL(sEasyChatScreen); } // Returns the function ID of the action to take as a result of player's input. @@ -3075,8 +3074,7 @@ static bool8 LoadEasyChatScreen(void) static void FreeEasyChatScreenControl(void) { - if (sScreenControl) - FREE_AND_SET_NULL(sScreenControl); + TRY_FREE_AND_SET_NULL(sScreenControl); } static void StartEasyChatFunction(u16 funcId) @@ -5573,8 +5571,7 @@ static bool8 InitEasyChatScreenWordData(void) static void FreeEasyChatScreenWordData(void) { - if (sWordData) - FREE_AND_SET_NULL(sWordData); + TRY_FREE_AND_SET_NULL(sWordData); } static void SetUnlockedEasyChatGroups(void) diff --git a/src/ereader_helpers.c b/src/ereader_helpers.c index f53bd6907..314fb1734 100755 --- a/src/ereader_helpers.c +++ b/src/ereader_helpers.c @@ -15,6 +15,8 @@ #include "constants/items.h" #include "constants/trainer_hill.h" +STATIC_ASSERT(sizeof(struct TrainerHillChallenge) <= SECTOR_DATA_SIZE, TrainerHillChallengeFreeSpace); + struct SendRecvMgr { bool8 isParent; diff --git a/src/event_data.c b/src/event_data.c index e2af6c3d0..22ebdb0d1 100644 --- a/src/event_data.c +++ b/src/event_data.c @@ -30,7 +30,7 @@ EWRAM_DATA u16 gSpecialVar_Facing = 0; EWRAM_DATA u16 gSpecialVar_MonBoxId = 0; EWRAM_DATA u16 gSpecialVar_MonBoxPos = 0; EWRAM_DATA u16 gSpecialVar_Unused_0x8014 = 0; -EWRAM_DATA static u8 gSpecialFlags[SPECIAL_FLAGS_SIZE] = {0}; +EWRAM_DATA static u8 sSpecialFlags[SPECIAL_FLAGS_SIZE] = {0}; extern u16 *const gSpecialVars[]; @@ -38,7 +38,7 @@ void InitEventData(void) { memset(gSaveBlock1Ptr->flags, 0, sizeof(gSaveBlock1Ptr->flags)); memset(gSaveBlock1Ptr->vars, 0, sizeof(gSaveBlock1Ptr->vars)); - memset(gSpecialFlags, 0, sizeof(gSpecialFlags)); + memset(sSpecialFlags, 0, sizeof(sSpecialFlags)); } void ClearTempFieldEventData(void) @@ -205,7 +205,7 @@ u8 *GetFlagPointer(u16 id) else if (id < SPECIAL_FLAGS_START) return &gSaveBlock1Ptr->flags[id / 8]; else - return &gSpecialFlags[(id - SPECIAL_FLAGS_START) / 8]; + return &sSpecialFlags[(id - SPECIAL_FLAGS_START) / 8]; } u8 FlagSet(u16 id) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index eb699e89f..90e713e63 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -164,7 +164,7 @@ static void CreateLevitateMovementTask(struct ObjectEvent *); static void DestroyLevitateMovementTask(u8); static bool8 NpcTakeStep(struct Sprite *); static bool8 IsElevationMismatchAt(u8, s16, s16); -static bool8 AreElevationsCompatible(u8 a, u8 b); +static bool8 AreElevationsCompatible(u8, u8); static const struct SpriteFrameImage sPicTable_PechaBerryTree[]; @@ -7837,7 +7837,7 @@ void GroundEffect_FlowingWater(struct ObjectEvent *objEvent, struct Sprite *spri StartFieldEffectForObjectEvent(FLDEFF_FEET_IN_FLOWING_WATER, objEvent); } -static void (*const sGroundEffectTracksFuncs[])(struct ObjectEvent *objEvent, struct Sprite *sprite, u8 a) = { +static void (*const sGroundEffectTracksFuncs[])(struct ObjectEvent *objEvent, struct Sprite *sprite, bool8 isDeepSand) = { [TRACKS_NONE] = DoTracksGroundEffect_None, [TRACKS_FOOT] = DoTracksGroundEffect_Footprints, [TRACKS_BIKE_TIRE] = DoTracksGroundEffect_BikeTireTracks, @@ -7846,20 +7846,20 @@ static void (*const sGroundEffectTracksFuncs[])(struct ObjectEvent *objEvent, st void GroundEffect_SandTracks(struct ObjectEvent *objEvent, struct Sprite *sprite) { const struct ObjectEventGraphicsInfo *info = GetObjectEventGraphicsInfo(objEvent->graphicsId); - sGroundEffectTracksFuncs[info->tracks](objEvent, sprite, 0); + sGroundEffectTracksFuncs[info->tracks](objEvent, sprite, FALSE); } void GroundEffect_DeepSandTracks(struct ObjectEvent *objEvent, struct Sprite *sprite) { const struct ObjectEventGraphicsInfo *info = GetObjectEventGraphicsInfo(objEvent->graphicsId); - sGroundEffectTracksFuncs[info->tracks](objEvent, sprite, 1); + sGroundEffectTracksFuncs[info->tracks](objEvent, sprite, TRUE); } -static void DoTracksGroundEffect_None(struct ObjectEvent *objEvent, struct Sprite *sprite, u8 a) +static void DoTracksGroundEffect_None(struct ObjectEvent *objEvent, struct Sprite *sprite, bool8 isDeepSand) { } -static void DoTracksGroundEffect_Footprints(struct ObjectEvent *objEvent, struct Sprite *sprite, u8 a) +static void DoTracksGroundEffect_Footprints(struct ObjectEvent *objEvent, struct Sprite *sprite, bool8 isDeepSand) { // First half-word is a Field Effect script id. (gFieldEffectScriptPointers) u16 sandFootprints_FieldEffectData[2] = { @@ -7872,10 +7872,10 @@ static void DoTracksGroundEffect_Footprints(struct ObjectEvent *objEvent, struct gFieldEffectArguments[2] = 149; gFieldEffectArguments[3] = 2; gFieldEffectArguments[4] = objEvent->facingDirection; - FieldEffectStart(sandFootprints_FieldEffectData[a]); + FieldEffectStart(sandFootprints_FieldEffectData[isDeepSand]); } -static void DoTracksGroundEffect_BikeTireTracks(struct ObjectEvent *objEvent, struct Sprite *sprite, u8 a) +static void DoTracksGroundEffect_BikeTireTracks(struct ObjectEvent *objEvent, struct Sprite *sprite, bool8 isDeepSand) { // Specifies which bike track shape to show next. // For example, when the bike turns from up to right, it will show @@ -8251,11 +8251,11 @@ static const SpriteStepFunc *const sNpcStepFuncTables[] = { }; static const s16 sStepTimes[] = { - [MOVE_SPEED_NORMAL] = 16, - [MOVE_SPEED_FAST_1] = 8, - [MOVE_SPEED_FAST_2] = 6, - [MOVE_SPEED_FASTER] = 4, - [MOVE_SPEED_FASTEST] = 2, + [MOVE_SPEED_NORMAL] = ARRAY_COUNT(sStep1Funcs), + [MOVE_SPEED_FAST_1] = ARRAY_COUNT(sStep2Funcs), + [MOVE_SPEED_FAST_2] = ARRAY_COUNT(sStep3Funcs), + [MOVE_SPEED_FASTER] = ARRAY_COUNT(sStep4Funcs), + [MOVE_SPEED_FASTEST] = ARRAY_COUNT(sStep8Funcs), }; static bool8 NpcTakeStep(struct Sprite *sprite) diff --git a/src/evolution_graphics.c b/src/evolution_graphics.c index 5d17cca84..a6b558195 100644 --- a/src/evolution_graphics.c +++ b/src/evolution_graphics.c @@ -92,11 +92,22 @@ static const struct SpriteTemplate sEvoSparkleSpriteTemplate = .callback = SpriteCB_Sparkle_Dummy }; -static const s16 sEvoSparkleMatrices[] = +static const u16 sEvoSparkleMatrices[] = { - 0x3C0, 0x380, 0x340, 0x300, 0x2C0, 0x280, 0x240, 0x200, 0x1C0, - 0x180, 0x140, 0x100, -4, 0x10, -3, 0x30, -2, 0x50, - -1, 0x70, 0x1, 0x70, 0x2, 0x50, 0x3, 0x30, 0x4, 0x10 + 0x3C0, 0x380, 0x340, 0x300, 0x2C0, 0x280, + 0x240, 0x200, 0x1C0, 0x180, 0x140, 0x100 +}; + +static const s16 sUnused[] = +{ + -4, 0x10, + -3, 0x30, + -2, 0x50, + -1, 0x70, + 1, 0x70, + 2, 0x50, + 3, 0x30, + 4, 0x10 }; static void SpriteCB_Sparkle_Dummy(struct Sprite *sprite) @@ -107,30 +118,33 @@ static void SpriteCB_Sparkle_Dummy(struct Sprite *sprite) static void SetEvoSparklesMatrices(void) { u16 i; - for (i = 0; i < 12; i++) - { + for (i = 0; i < ARRAY_COUNT(sEvoSparkleMatrices); i++) SetOamMatrix(20 + i, sEvoSparkleMatrices[i], 0, 0, sEvoSparkleMatrices[i]); - } } +#define sSpeed data[3] +#define sAmplitude data[5] +#define sTrigIdx data[6] +#define sTimer data[7] + static void SpriteCB_Sparkle_SpiralUpward(struct Sprite* sprite) { if (sprite->y > 8) { u8 matrixNum; - sprite->y = 88 - (sprite->data[7] * sprite->data[7]) / 80; - sprite->y2 = Sin((u8)(sprite->data[6]), sprite->data[5]) / 4; - sprite->x2 = Cos((u8)(sprite->data[6]), sprite->data[5]); - sprite->data[6] += 4; - if (sprite->data[7] & 1) - sprite->data[5]--; - sprite->data[7]++; + sprite->y = 88 - (sprite->sTimer * sprite->sTimer) / 80; + sprite->y2 = Sin((u8)sprite->sTrigIdx, sprite->sAmplitude) / 4; + sprite->x2 = Cos((u8)sprite->sTrigIdx, sprite->sAmplitude); + sprite->sTrigIdx += 4; + if (sprite->sTimer & 1) + sprite->sAmplitude--; + sprite->sTimer++; if (sprite->y2 > 0) sprite->subpriority = 1; else sprite->subpriority = 20; - matrixNum = sprite->data[5] / 4 + 20; + matrixNum = sprite->sAmplitude / 4 + 20; if (matrixNum > 31) matrixNum = 31; sprite->oam.matrixNum = matrixNum; @@ -139,17 +153,17 @@ static void SpriteCB_Sparkle_SpiralUpward(struct Sprite* sprite) DestroySprite(sprite); } -static void CreateSparkle_SpiralUpward(u8 arg0) +static void CreateSparkle_SpiralUpward(u8 trigIdx) { - u8 spriteID = CreateSprite(&sEvoSparkleSpriteTemplate, 120, 88, 0); - if (spriteID != MAX_SPRITES) + u8 spriteId = CreateSprite(&sEvoSparkleSpriteTemplate, DISPLAY_WIDTH / 2, 88, 0); + if (spriteId != MAX_SPRITES) { - gSprites[spriteID].data[5] = 48; - gSprites[spriteID].data[6] = arg0; - gSprites[spriteID].data[7] = 0; - gSprites[spriteID].oam.affineMode = ST_OAM_AFFINE_NORMAL; - gSprites[spriteID].oam.matrixNum = 31; - gSprites[spriteID].callback = SpriteCB_Sparkle_SpiralUpward; + gSprites[spriteId].sAmplitude = 48; + gSprites[spriteId].sTrigIdx = trigIdx; + gSprites[spriteId].sTimer = 0; + gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; + gSprites[spriteId].oam.matrixNum = 31; + gSprites[spriteId].callback = SpriteCB_Sparkle_SpiralUpward; } } @@ -157,85 +171,85 @@ static void SpriteCB_Sparkle_ArcDown(struct Sprite* sprite) { if (sprite->y < 88) { - sprite->y = 8 + (sprite->data[7] * sprite->data[7]) / 5; - sprite->y2 = Sin((u8)(sprite->data[6]), sprite->data[5]) / 4; - sprite->x2 = Cos((u8)(sprite->data[6]), sprite->data[5]); - sprite->data[5] = 8 + Sin((u8)(sprite->data[7] * 4), 40); - sprite->data[7]++; + sprite->y = 8 + (sprite->sTimer * sprite->sTimer) / 5; + sprite->y2 = Sin((u8)sprite->sTrigIdx, sprite->sAmplitude) / 4; + sprite->x2 = Cos((u8)sprite->sTrigIdx, sprite->sAmplitude); + sprite->sAmplitude = 8 + Sin((u8)(sprite->sTimer * 4), 40); + sprite->sTimer++; } else DestroySprite(sprite); } -static void CreateSparkle_ArcDown(u8 arg0) +static void CreateSparkle_ArcDown(u8 trigIdx) { - u8 spriteID = CreateSprite(&sEvoSparkleSpriteTemplate, 120, 8, 0); - if (spriteID != MAX_SPRITES) + u8 spriteId = CreateSprite(&sEvoSparkleSpriteTemplate, DISPLAY_WIDTH / 2, 8, 0); + if (spriteId != MAX_SPRITES) { - gSprites[spriteID].data[5] = 8; - gSprites[spriteID].data[6] = arg0; - gSprites[spriteID].data[7] = 0; - gSprites[spriteID].oam.affineMode = ST_OAM_AFFINE_NORMAL; - gSprites[spriteID].oam.matrixNum = 25; - gSprites[spriteID].subpriority = 1; - gSprites[spriteID].callback = SpriteCB_Sparkle_ArcDown; + gSprites[spriteId].sAmplitude = 8; + gSprites[spriteId].sTrigIdx = trigIdx; + gSprites[spriteId].sTimer = 0; + gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; + gSprites[spriteId].oam.matrixNum = 25; + gSprites[spriteId].subpriority = 1; + gSprites[spriteId].callback = SpriteCB_Sparkle_ArcDown; } } static void SpriteCB_Sparkle_CircleInward(struct Sprite* sprite) { - if (sprite->data[5] > 8) + if (sprite->sAmplitude > 8) { - sprite->y2 = Sin((u8)(sprite->data[6]), sprite->data[5]); - sprite->x2 = Cos((u8)(sprite->data[6]), sprite->data[5]); - sprite->data[5] -= sprite->data[3]; - sprite->data[6] += 4; + sprite->y2 = Sin((u8)sprite->sTrigIdx, sprite->sAmplitude); + sprite->x2 = Cos((u8)sprite->sTrigIdx, sprite->sAmplitude); + sprite->sAmplitude -= sprite->sSpeed; + sprite->sTrigIdx += 4; } else DestroySprite(sprite); } -static void CreateSparkle_CircleInward(u8 arg0, u8 arg1) +static void CreateSparkle_CircleInward(u8 trigIdx, u8 speed) { - u8 spriteID = CreateSprite(&sEvoSparkleSpriteTemplate, 120, 56, 0); - if (spriteID != MAX_SPRITES) + u8 spriteId = CreateSprite(&sEvoSparkleSpriteTemplate, DISPLAY_WIDTH / 2, 56, 0); + if (spriteId != MAX_SPRITES) { - gSprites[spriteID].data[3] = arg1; - gSprites[spriteID].data[5] = 120; - gSprites[spriteID].data[6] = arg0; - gSprites[spriteID].data[7] = 0; - gSprites[spriteID].oam.affineMode = ST_OAM_AFFINE_NORMAL; - gSprites[spriteID].oam.matrixNum = 31; - gSprites[spriteID].subpriority = 1; - gSprites[spriteID].callback = SpriteCB_Sparkle_CircleInward; + gSprites[spriteId].sSpeed = speed; + gSprites[spriteId].sAmplitude = 120; + gSprites[spriteId].sTrigIdx = trigIdx; + gSprites[spriteId].sTimer = 0; + gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; + gSprites[spriteId].oam.matrixNum = 31; + gSprites[spriteId].subpriority = 1; + gSprites[spriteId].callback = SpriteCB_Sparkle_CircleInward; } } static void SpriteCB_Sparkle_Spray(struct Sprite* sprite) { - if (!(sprite->data[7] & 3)) + if (!(sprite->sTimer & 3)) sprite->y++; - if (sprite->data[6] < 128) + if (sprite->sTrigIdx < 128) { u8 matrixNum; - sprite->y2 = -Sin((u8)(sprite->data[6]), sprite->data[5]); - sprite->x = 120 + (sprite->data[3] * sprite->data[7]) / 3; - sprite->data[6]++; - matrixNum = 31 - (sprite->data[6] * 12 / 128); - if (sprite->data[6] > 64) + sprite->y2 = -Sin((u8)sprite->sTrigIdx, sprite->sAmplitude); + sprite->x = (DISPLAY_WIDTH / 2) + (sprite->sSpeed * sprite->sTimer) / 3; + sprite->sTrigIdx++; + matrixNum = 31 - (sprite->sTrigIdx * 12 / 128); + if (sprite->sTrigIdx > 64) sprite->subpriority = 1; else { sprite->invisible = FALSE; sprite->subpriority = 20; - if (sprite->data[6] > 112 && sprite->data[6] & 1) + if (sprite->sTrigIdx > 112 && sprite->sTrigIdx & 1) sprite->invisible = TRUE; } if (matrixNum < 20) matrixNum = 20; sprite->oam.matrixNum = matrixNum; - sprite->data[7]++; + sprite->sTimer++; } else DestroySprite(sprite); @@ -243,16 +257,16 @@ static void SpriteCB_Sparkle_Spray(struct Sprite* sprite) static void CreateSparkle_Spray(u8 id) { - u8 spriteID = CreateSprite(&sEvoSparkleSpriteTemplate, 120, 56, 0); - if (spriteID != MAX_SPRITES) + u8 spriteId = CreateSprite(&sEvoSparkleSpriteTemplate, DISPLAY_WIDTH / 2, 56, 0); + if (spriteId != MAX_SPRITES) { - gSprites[spriteID].data[3] = 3 - (Random() % 7); - gSprites[spriteID].data[5] = 48 + (Random() & 0x3F); - gSprites[spriteID].data[7] = 0; - gSprites[spriteID].oam.affineMode = ST_OAM_AFFINE_NORMAL; - gSprites[spriteID].oam.matrixNum = 31; - gSprites[spriteID].subpriority = 20; - gSprites[spriteID].callback = SpriteCB_Sparkle_Spray; + gSprites[spriteId].sSpeed = 3 - (Random() % 7); + gSprites[spriteId].sAmplitude = 48 + (Random() & 0x3F); + gSprites[spriteId].sTimer = 0; + gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; + gSprites[spriteId].oam.matrixNum = 31; + gSprites[spriteId].subpriority = 20; + gSprites[spriteId].callback = SpriteCB_Sparkle_Spray; } } @@ -289,7 +303,7 @@ static void Task_Sparkles_SpiralUpward(u8 taskId) { u8 i; for (i = 0; i < 4; i++) - CreateSparkle_SpiralUpward((0x78 & gTasks[taskId].tTimer) * 2 + i * 64); + CreateSparkle_SpiralUpward((gTasks[taskId].tTimer & 120) * 2 + i * 64); } gTasks[taskId].tTimer++; } diff --git a/src/evolution_scene.c b/src/evolution_scene.c index bde11ddb5..eb458d39d 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -816,8 +816,7 @@ static void Task_EvolutionScene(u8 taskId) DestroyTask(taskId); FreeMonSpritesGfx(); - Free(sEvoStructPtr); - sEvoStructPtr = NULL; + FREE_AND_SET_NULL(sEvoStructPtr); FreeAllWindowBuffers(); SetMainCallback2(gCB2_AfterEvolution); } @@ -1223,8 +1222,7 @@ static void Task_TradeEvolutionScene(u8 taskId) if (!IsTextPrinterActive(0)) { DestroyTask(taskId); - Free(sEvoStructPtr); - sEvoStructPtr = NULL; + FREE_AND_SET_NULL(sEvoStructPtr); gTextFlags.useAlternateDownArrow = 0; SetMainCallback2(gCB2_AfterEvolution); } diff --git a/src/field_camera.c b/src/field_camera.c index 0a00dcbee..9b129e6b2 100644 --- a/src/field_camera.c +++ b/src/field_camera.c @@ -212,13 +212,13 @@ void CurrentMapDrawMetatileAt(int x, int y) } } -void DrawDoorMetatileAt(int x, int y, u16 *arr) +void DrawDoorMetatileAt(int x, int y, u16 *tiles) { int offset = MapPosToBgTilemapOffset(&sFieldCameraOffset, x, y); if (offset >= 0) { - DrawMetatile(METATILE_LAYER_TYPE_COVERED, arr, offset); + DrawMetatile(METATILE_LAYER_TYPE_COVERED, tiles, offset); sFieldCameraOffset.copyBGToVRAM = TRUE; } } @@ -404,9 +404,9 @@ void CameraUpdate(void) } gFieldCamera.x += movementSpeedX; - gFieldCamera.x = gFieldCamera.x - 16 * (gFieldCamera.x / 16); + gFieldCamera.x %= 16; gFieldCamera.y += movementSpeedY; - gFieldCamera.y = gFieldCamera.y - 16 * (gFieldCamera.y / 16); + gFieldCamera.y %= 16; if (deltaX != 0 || deltaY != 0) { @@ -437,10 +437,10 @@ void SetCameraPanningCallback(void (*callback)(void)) sFieldCameraPanningCallback = callback; } -void SetCameraPanning(s16 a, s16 b) +void SetCameraPanning(s16 horizontal, s16 vertical) { - sHorizontalCameraPan = a; - sVerticalCameraPan = b + 32; + sHorizontalCameraPan = horizontal; + sVerticalCameraPan = vertical + 32; } void InstallCameraPanAheadCallback(void) diff --git a/src/field_door.c b/src/field_door.c index 988ea615d..756d0dabf 100644 --- a/src/field_door.c +++ b/src/field_door.c @@ -18,7 +18,7 @@ struct DoorGraphics u8 sound; u8 size; const void *tiles; - const void *palette; + const void *palettes; }; struct DoorAnimFrame @@ -74,7 +74,7 @@ static const u8 sDoorAnimTiles_PokemonLeague[] = INCBIN_U8("graphics/door_anims/ static const u16 sDoorNullPalette20[16] = {}; static const u8 sDoorAnimTiles_Pacifidlog[] = INCBIN_U8("graphics/door_anims/pacifidlog.4bpp"); static const u16 sDoorNullPalette21[16] = {}; -static const u8 sDoorAnimTiles_BattleTowerCorridor[] = INCBIN_U8("graphics/door_anims/battle_tower_corridor.4bpp"); +static const u8 sDoorAnimTiles_PetalburgGym[] = INCBIN_U8("graphics/door_anims/petalburg_gym.4bpp"); static const u16 sDoorNullPalette22[16] = {}; static const u8 sDoorAnimTiles_CyclingRoad[] = INCBIN_U8("graphics/door_anims/cycling_road.4bpp"); static const u16 sDoorNullPalette23[16] = {}; @@ -98,7 +98,7 @@ static const u8 sDoorAnimTiles_BattleTowerOld[] = INCBIN_U8("graphics/door_anims static const u16 sDoorNullPalette32[16] = {}; static const u8 sDoorAnimTiles_BattleTowerElevator[] = INCBIN_U8("graphics/door_anims/battle_tower_elevator.4bpp"); static const u16 sDoorNullPalette33[16] = {}; -static const u8 sDoorAnimTiles_34[] = INCBIN_U8("graphics/door_anims/unknown.4bpp"); +static const u8 sDoorAnimTiles_UnusedBattleFrontier[] = INCBIN_U8("graphics/door_anims/unused_battle_frontier.4bpp"); static const u16 sDoorNullPalette34[16] = {}; static const u8 sDoorAnimTiles_BattleDome[] = INCBIN_U8("graphics/door_anims/battle_dome.4bpp"); static const u16 sDoorNullPalette35[16] = {}; @@ -190,7 +190,7 @@ static const u8 sDoorAnimPalettes_Mauville[] = {7, 7, 7, 7, 7, 7, 7, 7}; static const u8 sDoorAnimPalettes_Verdanturf[] = {6, 6, 5, 5, 5, 5, 5, 5}; static const u8 sDoorAnimPalettes_LilycoveWooden[] = {5, 5, 5, 5, 5, 5, 5, 5}; static const u8 sDoorAnimPalettes_Contest[] = {1, 1, 1, 1, 1, 1, 1, 1}; -static const u8 sDoorAnimPalettes_BattleTowerCorridor[] = {6, 6, 6, 6, 6, 6, 6, 6}; +static const u8 sDoorAnimPalettes_PetalburgGym[] = {6, 6, 6, 6, 6, 6, 6, 6}; static const u8 sDoorAnimPalettes_CyclingRoad[] = {7, 7, 7, 7, 7, 7, 7, 7}; static const u8 sDoorAnimPalettes_LilycoveDeptStore[] = {5, 5, 5, 5, 5, 5, 5, 5}; static const u8 sDoorAnimPalettes_SafariZone[] = {9, 9, 9, 9, 9, 9, 9, 9}; @@ -202,7 +202,7 @@ static const u8 sDoorAnimPalettes_AbandonedShipRoom[] = {7, 7, 7, 7, 7, 7, 7, 7} static const u8 sDoorAnimPalettes_LilycoveDeptStoreElevator[] = {6, 6, 7, 7, 7, 7, 7, 7}; static const u8 sDoorAnimPalettes_BattleTowerOld[] = {9, 9, 9, 9, 9, 9, 9, 9}; static const u8 sDoorAnimPalettes_BattleTowerElevator[] = {7, 7, 7, 7, 7, 7, 7, 7}; -static const u8 sDoorAnimPalettes_34[] = {9, 9, 9, 9, 9, 9, 9, 9}; +static const u8 sDoorAnimPalettes_UnusedBattleFrontier[] = {9, 9, 9, 9, 9, 9, 9, 9}; static const u8 sDoorAnimPalettes_BattleDome[] = {1, 1, 1, 1, 1, 1, 1, 1}; static const u8 sDoorAnimPalettes_BattleFactory[] = {9, 9, 9, 9, 9, 9, 9, 9}; static const u8 sDoorAnimPalettes_BattleTower[] = {0, 0, 0, 0, 0, 0, 0, 0}; @@ -244,7 +244,7 @@ static const struct DoorGraphics sDoorAnimGraphicsTable[] = {METATILE_Sootopolis_Door, DOOR_SOUND_NORMAL, 1, sDoorAnimTiles_Sootopolis, sDoorAnimPalettes_Sootopolis}, {METATILE_EverGrande_Door_PokemonLeague, DOOR_SOUND_SLIDING, 1, sDoorAnimTiles_PokemonLeague, sDoorAnimPalettes_PokemonLeague}, {METATILE_Pacifidlog_Door, DOOR_SOUND_NORMAL, 1, sDoorAnimTiles_Pacifidlog, sDoorAnimPalettes_Pacifidlog}, - {METATILE_BattleFrontier_Door_Corridor, DOOR_SOUND_NORMAL, 1, sDoorAnimTiles_BattleTowerCorridor, sDoorAnimPalettes_BattleTowerCorridor}, + {METATILE_PetalburgGym_Door, DOOR_SOUND_NORMAL, 1, sDoorAnimTiles_PetalburgGym, sDoorAnimPalettes_PetalburgGym}, {METATILE_Mauville_Door_CyclingRoad, DOOR_SOUND_NORMAL, 1, sDoorAnimTiles_CyclingRoad, sDoorAnimPalettes_CyclingRoad}, {METATILE_Lilycove_Door_DeptStore, DOOR_SOUND_SLIDING, 1, sDoorAnimTiles_LilycoveDeptStore, sDoorAnimPalettes_LilycoveDeptStore}, {METATILE_Lilycove_Door_SafariZone, DOOR_SOUND_SLIDING, 1, sDoorAnimTiles_SafariZone, sDoorAnimPalettes_SafariZone}, @@ -256,7 +256,9 @@ static const struct DoorGraphics sDoorAnimGraphicsTable[] = {METATILE_Shop_Door_Elevator, DOOR_SOUND_SLIDING, 1, sDoorAnimTiles_LilycoveDeptStoreElevator, sDoorAnimPalettes_LilycoveDeptStoreElevator}, {METATILE_Dewford_Door_BattleTower, DOOR_SOUND_SLIDING, 1, sDoorAnimTiles_BattleTowerOld, sDoorAnimPalettes_BattleTowerOld}, {METATILE_BattleFrontier_Door_Elevator, DOOR_SOUND_SLIDING, 1, sDoorAnimTiles_BattleTowerElevator, sDoorAnimPalettes_BattleTowerElevator}, - {0x3B0, /* TODO: Missing metatile ID */ DOOR_SOUND_SLIDING, 1, sDoorAnimTiles_34, sDoorAnimPalettes_34}, + // The metatile for this door doesn't seem to correspond to a door in any Emerald tileset. Given the surrounding door animations, it was likely cut from the Battle Frontier. + // From the palettes array we know it uses palette 9, and the door's shadow looks correct using either the Battle Tent or Battle Frontier Outside's 9th palette. + {0x3B0, DOOR_SOUND_SLIDING, 1, sDoorAnimTiles_UnusedBattleFrontier, sDoorAnimPalettes_UnusedBattleFrontier}, {METATILE_BattleFrontierOutsideWest_Door_BattleDome, DOOR_SOUND_SLIDING, 1, sDoorAnimTiles_BattleDome, sDoorAnimPalettes_BattleDome}, {METATILE_BattleFrontierOutsideWest_Door_BattleFactory, DOOR_SOUND_SLIDING, 1, sDoorAnimTiles_BattleFactory, sDoorAnimPalettes_BattleFactory}, {METATILE_BattleFrontierOutsideEast_Door_BattleTower, DOOR_SOUND_SLIDING, 1, sDoorAnimTiles_BattleTower, sDoorAnimPalettes_BattleTower}, @@ -278,52 +280,71 @@ static const struct DoorGraphics sDoorAnimGraphicsTable[] = {}, }; +// NOTE: The tiles of a door's animation must be copied to VRAM because they are not already part of any given tileset. +// This means that if there are any pre-existing tiles in this copied region that are visible when the door +// animation is played they will be overwritten. +#define DOOR_TILE_START_SIZE1 (NUM_TILES_TOTAL - 8) +#define DOOR_TILE_START_SIZE2 (NUM_TILES_TOTAL - 16) + static void CopyDoorTilesToVram(const struct DoorGraphics *gfx, const struct DoorAnimFrame *frame) { if (gfx->size == 2) - CpuFastSet(gfx->tiles + frame->offset, (void *)(VRAM + 0x7E00), 0x80); + CpuFastCopy(gfx->tiles + frame->offset, (void *)(VRAM + TILE_OFFSET_4BPP(DOOR_TILE_START_SIZE2)), 16 * TILE_SIZE_4BPP); else - CpuFastSet(gfx->tiles + frame->offset, (void *)(VRAM + 0x7F00), 0x40); + CpuFastCopy(gfx->tiles + frame->offset, (void *)(VRAM + TILE_OFFSET_4BPP(DOOR_TILE_START_SIZE1)), 8 * TILE_SIZE_4BPP); } -static void door_build_blockdef(u16 *a, u16 b, const u8 *c) +static void BuildDoorTiles(u16 *tiles, u16 tileNum, const u8 *paletteNums) { int i; - u16 unk; + u16 tile; + // Only the first 4 tiles of each metatile (bottom layer) actually use the door tiles for (i = 0; i < 4; i++) { - unk = *(c++) << 12; - a[i] = unk | (b + i); + tile = *(paletteNums++) << 12; + tiles[i] = tile | (tileNum + i); } + + // The remaining layers are left as tile 0 (with the same palette) for (; i < 8; i++) { - unk = *(c++) << 12; - a[i] = unk; + tile = *(paletteNums++) << 12; + tiles[i] = tile; } } -static void DrawCurrentDoorAnimFrame(const struct DoorGraphics *gfx, u32 x, u32 y, const u8 *pal) +static void DrawCurrentDoorAnimFrame(const struct DoorGraphics *gfx, u32 x, u32 y, const u8 *paletteNums) { - u16 arr[24]; + u16 tiles[24]; if (gfx->size == 2) { - door_build_blockdef(&arr[8], 0x3F0, pal); - DrawDoorMetatileAt(x, y - 1, &arr[8]); - door_build_blockdef(&arr[8], 0x3F4, pal + 4); - DrawDoorMetatileAt(x, y, &arr[8]); - door_build_blockdef(&arr[8], 0x3F8, pal); - DrawDoorMetatileAt(x + 1, y - 1, &arr[8]); - door_build_blockdef(&arr[8], 0x3FC, pal + 4); - DrawDoorMetatileAt(x + 1, y, &arr[8]); + // Top left metatile + BuildDoorTiles(&tiles[8], DOOR_TILE_START_SIZE2 + 0, &paletteNums[0]); + DrawDoorMetatileAt(x, y - 1, &tiles[8]); + + // Bottom left metatile + BuildDoorTiles(&tiles[8], DOOR_TILE_START_SIZE2 + 4, &paletteNums[4]); + DrawDoorMetatileAt(x, y, &tiles[8]); + + // Top right metatile + BuildDoorTiles(&tiles[8], DOOR_TILE_START_SIZE2 + 8, &paletteNums[0]); + DrawDoorMetatileAt(x + 1, y - 1, &tiles[8]); + + // Bottom right metatile + BuildDoorTiles(&tiles[8], DOOR_TILE_START_SIZE2 + 12, &paletteNums[4]); + DrawDoorMetatileAt(x + 1, y, &tiles[8]); } else { - door_build_blockdef(&arr[0], 0x3F8, pal); - DrawDoorMetatileAt(x, y - 1, &arr[0]); - door_build_blockdef(&arr[0], 0x3FC, pal + 4); - DrawDoorMetatileAt(x, y, &arr[0]); + // Top metatile + BuildDoorTiles(&tiles[0], DOOR_TILE_START_SIZE1 + 0, &paletteNums[0]); + DrawDoorMetatileAt(x, y - 1, &tiles[0]); + + // Bottom metatile + BuildDoorTiles(&tiles[0], DOOR_TILE_START_SIZE1 + 4, &paletteNums[4]); + DrawDoorMetatileAt(x, y, &tiles[0]); } } @@ -350,9 +371,9 @@ static void DrawDoor(const struct DoorGraphics *gfx, const struct DoorAnimFrame else { CopyDoorTilesToVram(gfx, frame); - DrawCurrentDoorAnimFrame(gfx, x, y, gfx->palette); + DrawCurrentDoorAnimFrame(gfx, x, y, gfx->palettes); if (ShouldUseMultiCorridorDoor()) - DrawCurrentDoorAnimFrame(gfx, gSpecialVar_0x8004 + MAP_OFFSET, gSpecialVar_0x8005 + MAP_OFFSET, gfx->palette); + DrawCurrentDoorAnimFrame(gfx, gSpecialVar_0x8004 + MAP_OFFSET, gSpecialVar_0x8005 + MAP_OFFSET, gfx->palettes); } } diff --git a/src/field_effect.c b/src/field_effect.c index f57ce8cdd..369239f6b 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -481,13 +481,13 @@ static const struct Subsprite sSubsprites_HofMonitorBig[] = static const struct SubspriteTable sSubspriteTable_HofMonitorBig = subsprite_table(sSubsprites_HofMonitorBig); -const union AnimCmd sAnim_Static[] = +static const union AnimCmd sAnim_Static[] = { ANIMCMD_FRAME(.imageValue = 0, .duration = 1), ANIMCMD_JUMP(0) }; -const union AnimCmd sAnim_Flicker[] = +static const union AnimCmd sAnim_Flicker[] = { ANIMCMD_FRAME(.imageValue = 0, .duration = 16), ANIMCMD_FRAME(.imageValue = 1, .duration = 16), @@ -501,7 +501,7 @@ const union AnimCmd sAnim_Flicker[] = }; // Flicker on and off, for the Pokéballs / monitors during the PokéCenter heal effect -const union AnimCmd *const sAnims_Flicker[] = +static const union AnimCmd *const sAnims_Flicker[] = { sAnim_Static, sAnim_Flicker @@ -556,7 +556,7 @@ static const struct SpriteTemplate sSpriteTemplate_HofMonitorSmall = .callback = SpriteCB_HallOfFameMonitor }; -void (*const sPokecenterHealEffectFuncs[])(struct Task *) = +static void (*const sPokecenterHealEffectFuncs[])(struct Task *) = { PokecenterHealEffect_Init, PokecenterHealEffect_WaitForBallPlacement, @@ -564,7 +564,7 @@ void (*const sPokecenterHealEffectFuncs[])(struct Task *) = PokecenterHealEffect_WaitForSoundAndEnd }; -void (*const sHallOfFameRecordEffectFuncs[])(struct Task *) = +static void (*const sHallOfFameRecordEffectFuncs[])(struct Task *) = { HallOfFameRecordEffect_Init, HallOfFameRecordEffect_WaitForBallPlacement, @@ -572,7 +572,7 @@ void (*const sHallOfFameRecordEffectFuncs[])(struct Task *) = HallOfFameRecordEffect_WaitForSoundAndEnd }; -void (*const sPokeballGlowEffectFuncs[])(struct Sprite *) = +static void (*const sPokeballGlowEffectFuncs[])(struct Sprite *) = { PokeballGlowEffect_PlaceBalls, PokeballGlowEffect_TryPlaySe, @@ -598,7 +598,7 @@ static const u8 sPokeballGlowReds[] = {16, 12, 8, 0}; static const u8 sPokeballGlowGreens[] = {16, 12, 8, 0}; static const u8 sPokeballGlowBlues[] = { 0, 0, 0, 0}; -bool8 (*const sFallWarpFieldEffectFuncs[])(struct Task *) = +static bool8 (*const sFallWarpFieldEffectFuncs[])(struct Task *) = { FallWarpEffect_Init, FallWarpEffect_WaitWeather, @@ -609,7 +609,7 @@ bool8 (*const sFallWarpFieldEffectFuncs[])(struct Task *) = FallWarpEffect_End, }; -bool8 (*const sEscalatorWarpOutFieldEffectFuncs[])(struct Task *) = +static bool8 (*const sEscalatorWarpOutFieldEffectFuncs[])(struct Task *) = { EscalatorWarpOut_Init, EscalatorWarpOut_WaitForPlayer, @@ -619,7 +619,7 @@ bool8 (*const sEscalatorWarpOutFieldEffectFuncs[])(struct Task *) = EscalatorWarpOut_Down_End, }; -bool8 (*const sEscalatorWarpInFieldEffectFuncs[])(struct Task *) = +static bool8 (*const sEscalatorWarpInFieldEffectFuncs[])(struct Task *) = { EscalatorWarpIn_Init, EscalatorWarpIn_Down_Init, @@ -630,7 +630,7 @@ bool8 (*const sEscalatorWarpInFieldEffectFuncs[])(struct Task *) = EscalatorWarpIn_End, }; -bool8 (*const sWaterfallFieldEffectFuncs[])(struct Task *, struct ObjectEvent *) = +static bool8 (*const sWaterfallFieldEffectFuncs[])(struct Task *, struct ObjectEvent *) = { WaterfallFieldEffect_Init, WaterfallFieldEffect_ShowMon, @@ -639,14 +639,14 @@ bool8 (*const sWaterfallFieldEffectFuncs[])(struct Task *, struct ObjectEvent *) WaterfallFieldEffect_ContinueRideOrEnd, }; -bool8 (*const sDiveFieldEffectFuncs[])(struct Task *) = +static bool8 (*const sDiveFieldEffectFuncs[])(struct Task *) = { DiveFieldEffect_Init, DiveFieldEffect_ShowMon, DiveFieldEffect_TryWarp, }; -bool8 (*const sLavaridgeGymB1FWarpEffectFuncs[])(struct Task *, struct ObjectEvent *, struct Sprite *) = +static bool8 (*const sLavaridgeGymB1FWarpEffectFuncs[])(struct Task *, struct ObjectEvent *, struct Sprite *) = { LavaridgeGymB1FWarpEffect_Init, LavaridgeGymB1FWarpEffect_CameraShake, @@ -656,7 +656,7 @@ bool8 (*const sLavaridgeGymB1FWarpEffectFuncs[])(struct Task *, struct ObjectEve LavaridgeGymB1FWarpEffect_Warp, }; -bool8 (*const sLavaridgeGymB1FWarpExitEffectFuncs[])(struct Task *, struct ObjectEvent *, struct Sprite *) = +static bool8 (*const sLavaridgeGymB1FWarpExitEffectFuncs[])(struct Task *, struct ObjectEvent *, struct Sprite *) = { LavaridgeGymB1FWarpExitEffect_Init, LavaridgeGymB1FWarpExitEffect_StartPopOut, @@ -664,7 +664,7 @@ bool8 (*const sLavaridgeGymB1FWarpExitEffectFuncs[])(struct Task *, struct Objec LavaridgeGymB1FWarpExitEffect_End, }; -bool8 (*const sLavaridgeGym1FWarpEffectFuncs[])(struct Task *, struct ObjectEvent *, struct Sprite *) = +static bool8 (*const sLavaridgeGym1FWarpEffectFuncs[])(struct Task *, struct ObjectEvent *, struct Sprite *) = { LavaridgeGym1FWarpEffect_Init, LavaridgeGym1FWarpEffect_AshPuff, @@ -673,7 +673,7 @@ bool8 (*const sLavaridgeGym1FWarpEffectFuncs[])(struct Task *, struct ObjectEven LavaridgeGym1FWarpEffect_Warp, }; -void (*const sEscapeRopeWarpOutEffectFuncs[])(struct Task *) = +static void (*const sEscapeRopeWarpOutEffectFuncs[])(struct Task *) = { EscapeRopeWarpOutEffect_Init, EscapeRopeWarpOutEffect_Spin, @@ -2277,7 +2277,7 @@ static void EscapeRopeWarpOutEffect_Spin(struct Task *task) } } -void (*const sEscapeRopeWarpInEffectFuncs[])(struct Task *) = { +static void (*const sEscapeRopeWarpInEffectFuncs[])(struct Task *) = { EscapeRopeWarpInEffect_Init, EscapeRopeWarpInEffect_Spin }; @@ -2448,7 +2448,7 @@ static void FieldCallback_TeleportWarpIn(void) CreateTask(Task_TeleportWarpIn, 0); } -void (*const sTeleportWarpInFieldEffectFuncs[])(struct Task *) = { +static void (*const sTeleportWarpInFieldEffectFuncs[])(struct Task *) = { TeleportWarpInFieldEffect_Init, TeleportWarpInFieldEffect_SpinEnter, TeleportWarpInFieldEffect_SpinGround @@ -2582,7 +2582,7 @@ bool8 FldEff_FieldMoveShowMonInit(void) return FALSE; } -void (*const sFieldMoveShowMonOutdoorsEffectFuncs[])(struct Task *) = { +static void (*const sFieldMoveShowMonOutdoorsEffectFuncs[])(struct Task *) = { FieldMoveShowMonOutdoorsEffect_Init, FieldMoveShowMonOutdoorsEffect_LoadGfx, FieldMoveShowMonOutdoorsEffect_CreateBanner, @@ -2750,7 +2750,7 @@ static void LoadFieldMoveOutdoorStreaksTilemap(u16 offs) #define tBgOffset data[4] #define tMonSpriteId data[15] -void (*const sFieldMoveShowMonIndoorsEffectFuncs[])(struct Task *) = { +static void (*const sFieldMoveShowMonIndoorsEffectFuncs[])(struct Task *) = { FieldMoveShowMonIndoorsEffect_Init, FieldMoveShowMonIndoorsEffect_LoadGfx, FieldMoveShowMonIndoorsEffect_SlideBannerOn, @@ -2978,7 +2978,7 @@ u8 FldEff_UseSurf(void) return FALSE; } -void (*const sSurfFieldEffectFuncs[])(struct Task *) = { +static void (*const sSurfFieldEffectFuncs[])(struct Task *) = { SurfFieldEffect_Init, SurfFieldEffect_FieldMovePose, SurfFieldEffect_ShowMon, @@ -3154,7 +3154,7 @@ u8 FldEff_UseFly(void) return 0; } -void (*const sFlyOutFieldEffectFuncs[])(struct Task *) = { +static void (*const sFlyOutFieldEffectFuncs[])(struct Task *) = { FlyOutFieldEffect_FieldMovePose, FlyOutFieldEffect_ShowMon, FlyOutFieldEffect_BirdLeaveBall, @@ -3444,7 +3444,7 @@ u8 FldEff_FlyIn(void) return 0; } -void (*const sFlyInFieldEffectFuncs[])(struct Task *) = { +static void (*const sFlyInFieldEffectFuncs[])(struct Task *) = { FlyInFieldEffect_BirdSwoopDown, FlyInFieldEffect_FlyInWithBird, FlyInFieldEffect_JumpOffBird, @@ -3675,7 +3675,7 @@ static void StartEndingDeoxysRockCameraShake(u8 taskId) #undef tEndDelay #undef tEnding -void (*const sDestroyDeoxysRockEffectFuncs[])(s16*, u8) = { +static void (*const sDestroyDeoxysRockEffectFuncs[])(s16*, u8) = { DestroyDeoxysRockEffect_CameraShake, DestroyDeoxysRockEffect_RockFragments, DestroyDeoxysRockEffect_WaitAndEnd, diff --git a/src/field_message_box.c b/src/field_message_box.c index 74afb5677..95d0a94c9 100755 --- a/src/field_message_box.c +++ b/src/field_message_box.c @@ -33,7 +33,7 @@ static void Task_DrawFieldMessage(u8 taskId) task->tState++; break; case 1: - DrawDialogueFrame(0, 1); + DrawDialogueFrame(0, TRUE); task->tState++; break; case 2: diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 418fa7948..93f94aa15 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -79,13 +79,13 @@ static bool8 TryPushBoulder(s16, s16, u8); static void CheckAcroBikeCollision(s16, s16, u8, u8 *); static void DoPlayerAvatarTransition(void); -static void PlayerAvatarTransition_Dummy(struct ObjectEvent *a); -static void PlayerAvatarTransition_Normal(struct ObjectEvent *a); -static void PlayerAvatarTransition_MachBike(struct ObjectEvent *a); -static void PlayerAvatarTransition_AcroBike(struct ObjectEvent *a); -static void PlayerAvatarTransition_Surfing(struct ObjectEvent *a); -static void PlayerAvatarTransition_Underwater(struct ObjectEvent *a); -static void PlayerAvatarTransition_ReturnToField(struct ObjectEvent *a); +static void PlayerAvatarTransition_Dummy(struct ObjectEvent *); +static void PlayerAvatarTransition_Normal(struct ObjectEvent *); +static void PlayerAvatarTransition_MachBike(struct ObjectEvent *); +static void PlayerAvatarTransition_AcroBike(struct ObjectEvent *); +static void PlayerAvatarTransition_Surfing(struct ObjectEvent *); +static void PlayerAvatarTransition_Underwater(struct ObjectEvent *); +static void PlayerAvatarTransition_ReturnToField(struct ObjectEvent *); static bool8 PlayerAnimIsMultiFrameStationary(void); static bool8 PlayerAnimIsMultiFrameStationaryAndStateNotTurning(void); @@ -96,51 +96,51 @@ static void PlayerRun(u8); static void PlayerNotOnBikeCollide(u8); static void PlayerNotOnBikeCollideWithFarawayIslandMew(u8); -static void PlayCollisionSoundIfNotFacingWarp(u8 a); +static void PlayCollisionSoundIfNotFacingWarp(u8); static void HideShowWarpArrow(struct ObjectEvent *); static void StartStrengthAnim(u8, u8); -static void Task_PushBoulder(u8 taskId); -static bool8 PushBoulder_Start(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject); -static bool8 PushBoulder_Move(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject); -static bool8 PushBoulder_End(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject); +static void Task_PushBoulder(u8); +static bool8 PushBoulder_Start(struct Task *, struct ObjectEvent *, struct ObjectEvent *); +static bool8 PushBoulder_Move(struct Task *, struct ObjectEvent *, struct ObjectEvent *); +static bool8 PushBoulder_End(struct Task *, struct ObjectEvent *, struct ObjectEvent *); static void DoPlayerMatJump(void); -static void DoPlayerAvatarSecretBaseMatJump(u8 taskId); -static u8 PlayerAvatar_DoSecretBaseMatJump(struct Task *task, struct ObjectEvent *objectEvent); +static void DoPlayerAvatarSecretBaseMatJump(u8); +static u8 PlayerAvatar_DoSecretBaseMatJump(struct Task *, struct ObjectEvent *); static void DoPlayerMatSpin(void); -static void PlayerAvatar_DoSecretBaseMatSpin(u8 taskId); -static bool8 PlayerAvatar_SecretBaseMatSpinStep0(struct Task *task, struct ObjectEvent *objectEvent); -static bool8 PlayerAvatar_SecretBaseMatSpinStep1(struct Task *task, struct ObjectEvent *objectEvent); -static bool8 PlayerAvatar_SecretBaseMatSpinStep2(struct Task *task, struct ObjectEvent *objectEvent); -static bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task *task, struct ObjectEvent *objectEvent); +static void PlayerAvatar_DoSecretBaseMatSpin(u8); +static bool8 PlayerAvatar_SecretBaseMatSpinStep0(struct Task *, struct ObjectEvent *); +static bool8 PlayerAvatar_SecretBaseMatSpinStep1(struct Task *, struct ObjectEvent *); +static bool8 PlayerAvatar_SecretBaseMatSpinStep2(struct Task *, struct ObjectEvent *); +static bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task *, struct ObjectEvent *); static void CreateStopSurfingTask(u8); -static void Task_StopSurfingInit(u8 taskId); -static void Task_WaitStopSurfing(u8 taskId); +static void Task_StopSurfingInit(u8); +static void Task_WaitStopSurfing(u8); -static void Task_Fishing(u8 taskId); -static u8 Fishing_Init(struct Task *task); -static u8 Fishing_GetRodOut(struct Task *task); -static u8 Fishing_WaitBeforeDots(struct Task *task); -static u8 Fishing_InitDots(struct Task *task); -static u8 Fishing_ShowDots(struct Task *task); -static u8 Fishing_CheckForBite(struct Task *task); -static u8 Fishing_GotBite(struct Task *task); -static u8 Fishing_WaitForA(struct Task *task); -static u8 Fishing_CheckMoreDots(struct Task *task); -static u8 Fishing_MonOnHook(struct Task *task); -static u8 Fishing_StartEncounter(struct Task *task); -static u8 Fishing_NotEvenNibble(struct Task *task); -static u8 Fishing_GotAway(struct Task *task); -static u8 Fishing_NoMon(struct Task *task); -static u8 Fishing_PutRodAway(struct Task *task); -static u8 Fishing_EndNoMon(struct Task *task); +static void Task_Fishing(u8); +static u8 Fishing_Init(struct Task *); +static u8 Fishing_GetRodOut(struct Task *); +static u8 Fishing_WaitBeforeDots(struct Task *); +static u8 Fishing_InitDots(struct Task *); +static u8 Fishing_ShowDots(struct Task *); +static u8 Fishing_CheckForBite(struct Task *); +static u8 Fishing_GotBite(struct Task *); +static u8 Fishing_WaitForA(struct Task *); +static u8 Fishing_CheckMoreDots(struct Task *); +static u8 Fishing_MonOnHook(struct Task *); +static u8 Fishing_StartEncounter(struct Task *); +static u8 Fishing_NotEvenNibble(struct Task *); +static u8 Fishing_GotAway(struct Task *); +static u8 Fishing_NoMon(struct Task *); +static u8 Fishing_PutRodAway(struct Task *); +static u8 Fishing_EndNoMon(struct Task *); static void AlignFishingAnimationFrames(void); -static u8 TrySpinPlayerForWarp(struct ObjectEvent *object, s16 *a1); +static u8 TrySpinPlayerForWarp(struct ObjectEvent *, s16 *); static bool8 (*const sForcedMovementTestFuncs[NUM_FORCED_MOVEMENTS])(u8) = { @@ -1445,68 +1445,68 @@ static void HideShowWarpArrow(struct ObjectEvent *objectEvent) /* Strength */ -static void StartStrengthAnim(u8 a, u8 b) +#define tState data[0] +#define tBoulderObjId data[1] +#define tDirection data[2] + +static void StartStrengthAnim(u8 objectEventId, u8 direction) { u8 taskId = CreateTask(Task_PushBoulder, 0xFF); - gTasks[taskId].data[1] = a; - gTasks[taskId].data[2] = b; + gTasks[taskId].tBoulderObjId = objectEventId; + gTasks[taskId].tDirection = direction; Task_PushBoulder(taskId); } static void Task_PushBoulder(u8 taskId) { - while (sPushBoulderFuncs[gTasks[taskId].data[0]](&gTasks[taskId], + while (sPushBoulderFuncs[gTasks[taskId].tState](&gTasks[taskId], &gObjectEvents[gPlayerAvatar.objectEventId], - &gObjectEvents[gTasks[taskId].data[1]])) + &gObjectEvents[gTasks[taskId].tBoulderObjId])) ; } -static bool8 PushBoulder_Start(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) +static bool8 PushBoulder_Start(struct Task *task, struct ObjectEvent *player, struct ObjectEvent *boulder) { ScriptContext2_Enable(); gPlayerAvatar.preventStep = TRUE; - task->data[0]++; + task->tState++; return FALSE; } -static bool8 PushBoulder_Move(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) +static bool8 PushBoulder_Move(struct Task *task, struct ObjectEvent *player, struct ObjectEvent *boulder) { - if (ObjectEventIsHeldMovementActive(playerObject)) - { - ObjectEventClearHeldMovementIfFinished(playerObject); - } + if (ObjectEventIsHeldMovementActive(player)) + ObjectEventClearHeldMovementIfFinished(player); - if (ObjectEventIsHeldMovementActive(strengthObject)) - { - ObjectEventClearHeldMovementIfFinished(strengthObject); - } + if (ObjectEventIsHeldMovementActive(boulder)) + ObjectEventClearHeldMovementIfFinished(boulder); - if (!ObjectEventIsMovementOverridden(playerObject) - && !ObjectEventIsMovementOverridden(strengthObject)) + if (!ObjectEventIsMovementOverridden(player) + && !ObjectEventIsMovementOverridden(boulder)) { - ObjectEventClearHeldMovementIfFinished(playerObject); - ObjectEventClearHeldMovementIfFinished(strengthObject); - ObjectEventSetHeldMovement(playerObject, GetWalkInPlaceNormalMovementAction((u8)task->data[2])); - ObjectEventSetHeldMovement(strengthObject, GetWalkSlowMovementAction((u8)task->data[2])); - gFieldEffectArguments[0] = strengthObject->currentCoords.x; - gFieldEffectArguments[1] = strengthObject->currentCoords.y; - gFieldEffectArguments[2] = strengthObject->previousElevation; - gFieldEffectArguments[3] = gSprites[strengthObject->spriteId].oam.priority; + ObjectEventClearHeldMovementIfFinished(player); + ObjectEventClearHeldMovementIfFinished(boulder); + ObjectEventSetHeldMovement(player, GetWalkInPlaceNormalMovementAction((u8)task->tDirection)); + ObjectEventSetHeldMovement(boulder, GetWalkSlowMovementAction((u8)task->tDirection)); + gFieldEffectArguments[0] = boulder->currentCoords.x; + gFieldEffectArguments[1] = boulder->currentCoords.y; + gFieldEffectArguments[2] = boulder->previousElevation; + gFieldEffectArguments[3] = gSprites[boulder->spriteId].oam.priority; FieldEffectStart(FLDEFF_DUST); PlaySE(SE_M_STRENGTH); - task->data[0]++; + task->tState++; } return FALSE; } -static bool8 PushBoulder_End(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) +static bool8 PushBoulder_End(struct Task *task, struct ObjectEvent *player, struct ObjectEvent *boulder) { - if (ObjectEventCheckHeldMovementStatus(playerObject) - && ObjectEventCheckHeldMovementStatus(strengthObject)) + if (ObjectEventCheckHeldMovementStatus(player) + && ObjectEventCheckHeldMovementStatus(boulder)) { - ObjectEventClearHeldMovementIfFinished(playerObject); - ObjectEventClearHeldMovementIfFinished(strengthObject); + ObjectEventClearHeldMovementIfFinished(player); + ObjectEventClearHeldMovementIfFinished(boulder); gPlayerAvatar.preventStep = FALSE; ScriptContext2_Disable(); DestroyTask(FindTaskIdByFunc(Task_PushBoulder)); @@ -1514,6 +1514,10 @@ static bool8 PushBoulder_End(struct Task *task, struct ObjectEvent *playerObject return FALSE; } +#undef tState +#undef tBoulderObjId +#undef tDirection + /* Some field effect */ static void DoPlayerMatJump(void) diff --git a/src/field_region_map.c b/src/field_region_map.c index 26ae736a6..adf5e4ed7 100644 --- a/src/field_region_map.c +++ b/src/field_region_map.c @@ -192,10 +192,7 @@ static void FieldUpdateRegionMap(void) { FreeRegionMapIconResources(); SetMainCallback2(sFieldRegionMapHandler->callback); - if (sFieldRegionMapHandler != NULL) - { - FREE_AND_SET_NULL(sFieldRegionMapHandler); - } + TRY_FREE_AND_SET_NULL(sFieldRegionMapHandler); FreeAllWindowBuffers(); } break; diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index eda146725..77978c269 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -53,7 +53,7 @@ static void Task_EnableScriptAfterMusicFade(u8 taskId); static const u16 sFlashLevelToRadius[] = { 200, 72, 64, 56, 48, 40, 32, 24, 0 }; const s32 gMaxFlashLevel = ARRAY_COUNT(sFlashLevelToRadius) - 1; -const struct ScanlineEffectParams sFlashEffectParams = +static const struct ScanlineEffectParams sFlashEffectParams = { ®_WIN0H, ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, diff --git a/src/field_special_scene.c b/src/field_special_scene.c index d8b9eb05d..749346728 100644 --- a/src/field_special_scene.c +++ b/src/field_special_scene.c @@ -19,7 +19,19 @@ #include "constants/songs.h" #include "constants/metatile_labels.h" -#define SECONDS(value) ((signed) (60.0 * value + 0.5)) +// Most of the boxes in the moving truck are map tiles, with the +// exception of three boxes that are map events that jostle around +// while the truck is driving. In addition, their sprite's placement +// is slightly offset to make them look less perfectly stacked. +// Box 1 (LOCALID_TRUCK_BOX_TOP) +#define BOX1_X_OFFSET 3 +#define BOX1_Y_OFFSET 3 +// Box 2 (LOCALID_TRUCK_BOX_BOTTOM_L) +#define BOX2_X_OFFSET 0 +#define BOX2_Y_OFFSET -3 +// Box 3 (LOCALID_TRUCK_BOX_BOTTOM_R) +#define BOX3_X_OFFSET -3 +#define BOX3_Y_OFFSET 0 // porthole states enum @@ -30,8 +42,7 @@ enum EXIT_PORTHOLE, }; -//. rodata -static const s8 gTruckCamera_HorizontalTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, -1, -1, -1, 0}; +static const s8 sTruckCamera_HorizontalTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, -1, -1, -1, 0}; static const u8 sSSTidalSailEastMovementScript[] = { @@ -45,175 +56,194 @@ static const u8 sSSTidalSailWestMovementScript[] = MOVEMENT_ACTION_STEP_END }; -// .text static void Task_Truck3(u8); -s16 GetTruckCameraBobbingY(int a1) +static s16 GetTruckCameraBobbingY(int time) { - if (!(a1 % 120)) + if (!(time % 120)) return -1; - else if ((a1 % 10) <= 4) + else if ((time % 10) <= 4) return 1; return 0; } -s16 GetTruckBoxMovement(int a1) // for the box movement? +// Determines the frequency that the truck boxes bounce at. +// The return value of this function is multiplied and added +// to the boxes resting y offset, the result of which is that +// when it returns 0 they remain vertically still and when it +// returns -1 they jump upward. +// Box 1 has 30 added to the time so it jumps earlier, and +// box 2 has the return value multiplied by less, so it doesn't +// jump as high. +static s16 GetTruckBoxYMovement(int time) { - if (!((a1 + 120) % 180)) + if (!((time + 120) % 180)) return -1; return 0; } -void Task_Truck1(u8 taskId) +#define tTimer data[0] + +static void Task_Truck1(u8 taskId) { s16 *data = gTasks[taskId].data; s16 cameraXpan = 0, cameraYpan = 0; - s16 box1, box2, box3; + s16 yBox1, yBox2, yBox3; - box1 = GetTruckBoxMovement(data[0] + 30) * 4; - SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_TOP, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3 - cameraXpan, box1 + 3); - box2 = GetTruckBoxMovement(data[0]) * 2; - SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_L, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -cameraXpan, box2 - 3); - box3 = GetTruckBoxMovement(data[0]) * 4; - SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_R, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3 - cameraXpan, box3); + yBox1 = GetTruckBoxYMovement(tTimer + 30) * 4; + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_TOP, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, BOX1_X_OFFSET - cameraXpan, BOX1_Y_OFFSET + yBox1); + yBox2 = GetTruckBoxYMovement(tTimer) * 2; + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_L, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, BOX2_X_OFFSET - cameraXpan, BOX2_Y_OFFSET + yBox2); + yBox3 = GetTruckBoxYMovement(tTimer) * 4; + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_R, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, BOX3_X_OFFSET - cameraXpan, BOX3_Y_OFFSET + yBox3); - if (++data[0] == SECONDS(500)) // this will never run - data[0] = 0; // reset the timer if it gets stuck. + // Arbitrary timer limit that won't be reached + if (++tTimer == 30000) + tTimer = 0; - cameraYpan = GetTruckCameraBobbingY(data[0]); + cameraYpan = GetTruckCameraBobbingY(tTimer); SetCameraPanning(cameraXpan, cameraYpan); } -void Task_Truck2(u8 taskId) +#undef tTimer + +#define tTimerHorizontal data[0] +#define tMoveStep data[1] +#define tTimerVertical data[2] + +static void Task_Truck2(u8 taskId) { s16 *data = gTasks[taskId].data; - s16 cameraYpan; - s16 cameraXpan; - s16 box1; - s16 box2; - s16 box3; + s16 cameraYpan, cameraXpan; + s16 yBox1, yBox2, yBox3; - data[0]++; - data[2]++; + tTimerHorizontal++; + tTimerVertical++; - if (data[0] > 5) + if (tTimerHorizontal > 5) { - data[0] = 0; - data[1]++; + tTimerHorizontal = 0; + tMoveStep++; } - if ((u16)data[1] == 19) + if ((u16)tMoveStep == ARRAY_COUNT(sTruckCamera_HorizontalTable)) { + // Never reached, the task function is changed below before finishing the table DestroyTask(taskId); } else { - if (gTruckCamera_HorizontalTable[data[1]] == 2) + if (sTruckCamera_HorizontalTable[tMoveStep] == 2) gTasks[taskId].func = Task_Truck3; - cameraXpan = gTruckCamera_HorizontalTable[data[1]]; - cameraYpan = GetTruckCameraBobbingY(data[2]); + cameraXpan = sTruckCamera_HorizontalTable[tMoveStep]; + cameraYpan = GetTruckCameraBobbingY(tTimerVertical); SetCameraPanning(cameraXpan, cameraYpan); - box1 = GetTruckBoxMovement(data[2] + 30) * 4; - SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_TOP, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3 - cameraXpan, box1 + 3); - box2 = GetTruckBoxMovement(data[2]) * 2; - SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_L, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -cameraXpan, box2 - 3); - box3 = GetTruckBoxMovement(data[2]) * 4; - SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_R, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3 - cameraXpan, box3); + yBox1 = GetTruckBoxYMovement(tTimerVertical + 30) * 4; + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_TOP, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, BOX1_X_OFFSET - cameraXpan, BOX1_Y_OFFSET + yBox1); + yBox2 = GetTruckBoxYMovement(tTimerVertical) * 2; + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_L, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, BOX2_X_OFFSET - cameraXpan, BOX2_Y_OFFSET + yBox2); + yBox3 = GetTruckBoxYMovement(tTimerVertical) * 4; + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_R, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, BOX3_X_OFFSET - cameraXpan, BOX3_Y_OFFSET + yBox3); } } static void Task_Truck3(u8 taskId) { s16 *data = gTasks[taskId].data; - s16 cameraXpan; - s16 cameraYpan; + s16 cameraXpan, cameraYpan; - data[0]++; + tTimerHorizontal++; - if (data[0] > 5) + if (tTimerHorizontal > 5) { - data[0] = 0; - data[1]++; + tTimerHorizontal = 0; + tMoveStep++; } - if ((u16)data[1] == 19) + if ((u16)tMoveStep == ARRAY_COUNT(sTruckCamera_HorizontalTable)) { DestroyTask(taskId); } else { - cameraXpan = gTruckCamera_HorizontalTable[data[1]]; + cameraXpan = sTruckCamera_HorizontalTable[tMoveStep]; cameraYpan = 0; - SetCameraPanning(cameraXpan, 0); - SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_TOP, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3 - cameraXpan, cameraYpan + 3); - SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_L, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -cameraXpan, cameraYpan - 3); - SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_R, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3 - cameraXpan, cameraYpan); + SetCameraPanning(cameraXpan, cameraYpan); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_TOP, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, BOX1_X_OFFSET - cameraXpan, BOX1_Y_OFFSET + cameraYpan); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_L, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, BOX2_X_OFFSET - cameraXpan, BOX2_Y_OFFSET + cameraYpan); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_R, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, BOX3_X_OFFSET - cameraXpan, BOX3_Y_OFFSET + cameraYpan); } } -void Task_HandleTruckSequence(u8 taskId) +#undef tTimerHorizontal +#undef tMoveStep +#undef tTimerVertical + +#define tState data[0] +#define tTimer data[1] +#define tTaskId1 data[2] +#define tTaskId2 data[3] + +static void Task_HandleTruckSequence(u8 taskId) { s16 *data = gTasks[taskId].data; - switch (data[0]) + switch (tState) { - /* - Each case has a timer which is handled with data[1], incrementing - until it reaches the if function's condition, which sets the next task up. - */ case 0: - data[1]++; - if (data[1] == SECONDS(1.5)) + tTimer++; + if (tTimer == 90) { SetCameraPanningCallback(NULL); - data[1] = 0; // reset the timer. - data[2] = CreateTask(Task_Truck1, 0xA); - data[0] = 1; // run the next case. + tTimer = 0; + tTaskId1 = CreateTask(Task_Truck1, 0xA); + tState = 1; PlaySE(SE_TRUCK_MOVE); } break; case 1: - data[1]++; - if (data[1] == SECONDS(2.5)) + tTimer++; + if (tTimer == 150) { FadeInFromBlack(); - data[1] = 0; - data[0] = 2; + tTimer = 0; + tState = 2; } break; case 2: - data[1]++; - if (!gPaletteFade.active && data[1] > SECONDS(5)) + tTimer++; + if (!gPaletteFade.active && tTimer > 300) { - data[1] = 0; - DestroyTask(data[2]); - data[3] = CreateTask(Task_Truck2, 0xA); - data[0] = 3; + tTimer = 0; + DestroyTask(tTaskId1); + tTaskId2 = CreateTask(Task_Truck2, 0xA); + tState = 3; PlaySE(SE_TRUCK_STOP); } break; case 3: - if (!gTasks[data[3]].isActive) // is Truck2 no longer active (is Truck3 active?) + if (!gTasks[tTaskId2].isActive) { + // Task_Truck2 / Task_Truck3 has finished InstallCameraPanAheadCallback(); - data[1] = 0; - data[0] = 4; + tTimer = 0; + tState = 4; } break; case 4: - data[1]++; - if (data[1] == 90) + tTimer++; + if (tTimer == 90) { PlaySE(SE_TRUCK_UNLOAD); - data[1] = 0; - data[0] = 5; + tTimer = 0; + tState = 5; } break; case 5: - data[1]++; - if (data[1] == 120) + tTimer++; + if (tTimer == 120) { MapGridSetMetatileIdAt(4 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_InsideOfTruck_ExitLight_Top); MapGridSetMetatileIdAt(4 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_InsideOfTruck_ExitLight_Mid); @@ -242,9 +272,9 @@ void EndTruckSequence(u8 taskId) { if (!FuncIsActiveTask(Task_HandleTruckSequence)) { - SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_TOP, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3, 3); - SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_L, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 0, -3); - SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_R, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3, 0); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_TOP, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, BOX1_X_OFFSET, BOX1_Y_OFFSET); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_L, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, BOX2_X_OFFSET, BOX2_Y_OFFSET); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_R, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, BOX3_X_OFFSET, BOX3_Y_OFFSET); } } @@ -259,7 +289,7 @@ bool8 TrySetPortholeWarpDestination(void) } else { - SetWarpDestination(mapGroup, mapNum, -1, x, y); + SetWarpDestination(mapGroup, mapNum, WARP_ID_NONE, x, y); return TRUE; } } diff --git a/src/field_specials.c b/src/field_specials.c index a4cdafafc..4ed2a2e03 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -90,44 +90,44 @@ void SetPlayerGotFirstFans(void); u16 GetNumFansOfPlayerInTrainerFanClub(void); static void RecordCyclingRoadResults(u32, u8); -static void LoadLinkPartnerObjectEventSpritePalette(u8 graphicsId, u8 localEventId, u8 paletteNum); -static void Task_PetalburgGymSlideOpenRoomDoors(u8 taskId); -static void PetalburgGymSetDoorMetatiles(u8 roomNumber, u16 metatileId); +static void LoadLinkPartnerObjectEventSpritePalette(u8, u8, u8); +static void Task_PetalburgGymSlideOpenRoomDoors(u8); +static void PetalburgGymSetDoorMetatiles(u8, u16); static void Task_PCTurnOnEffect(u8); static void PCTurnOnEffect_0(struct Task *); static void PCTurnOnEffect_1(s16, s8, s8); static void PCTurnOffEffect(void); static void Task_LotteryCornerComputerEffect(u8); static void LotteryCornerComputerEffect(struct Task *); -static void Task_ShakeCamera(u8 taskId); -static void StopCameraShake(u8 taskId); -static void Task_MoveElevator(u8 taskId); -static void MoveElevatorWindowLights(u16 floorDelta, bool8 descending); -static void Task_MoveElevatorWindowLights(u8 taskId); -static void Task_ShowScrollableMultichoice(u8 taskId); -static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection); -static void ShowBattleFrontierTutorWindow(u8 menu, u16 selection); +static void Task_ShakeCamera(u8); +static void StopCameraShake(u8); +static void Task_MoveElevator(u8); +static void MoveElevatorWindowLights(u16, bool8); +static void Task_MoveElevatorWindowLights(u8); +static void Task_ShowScrollableMultichoice(u8); +static void FillFrontierExchangeCornerWindowAndItemIcon(u16, u16); +static void ShowBattleFrontierTutorWindow(u8, u16); static void InitScrollableMultichoice(void); -static void ScrollableMultichoice_ProcessInput(u8 taskId); -static void ScrollableMultichoice_UpdateScrollArrows(u8 taskId); -static void ScrollableMultichoice_MoveCursor(s32 itemIndex, bool8 onInit, struct ListMenu *list); -static void HideFrontierExchangeCornerItemIcon(u16 menu, u16 unused); -static void ShowBattleFrontierTutorMoveDescription(u8 menu, u16 selection); -static void CloseScrollableMultichoice(u8 taskId); -static void ScrollableMultichoice_RemoveScrollArrows(u8 taskId); -static void Task_ScrollableMultichoice_WaitReturnToList(u8 taskId); -static void Task_ScrollableMultichoice_ReturnToList(u8 taskId); -static void ShowFrontierExchangeCornerItemIcon(u16 item); -static void Task_DeoxysRockInteraction(u8 taskId); -static void ChangeDeoxysRockLevel(u8 a0); -static void WaitForDeoxysRockMovement(u8 taskId); -static void Task_LinkRetireStatusWithBattleTowerPartner(u8 taskId); -static void Task_LoopWingFlapSE(u8 taskId); -static void Task_CloseBattlePikeCurtain(u8 taskId); +static void ScrollableMultichoice_ProcessInput(u8); +static void ScrollableMultichoice_UpdateScrollArrows(u8); +static void ScrollableMultichoice_MoveCursor(s32, bool8, struct ListMenu *); +static void HideFrontierExchangeCornerItemIcon(u16, u16); +static void ShowBattleFrontierTutorMoveDescription(u8, u16); +static void CloseScrollableMultichoice(u8); +static void ScrollableMultichoice_RemoveScrollArrows(u8); +static void Task_ScrollableMultichoice_WaitReturnToList(u8); +static void Task_ScrollableMultichoice_ReturnToList(u8); +static void ShowFrontierExchangeCornerItemIcon(u16); +static void Task_DeoxysRockInteraction(u8); +static void ChangeDeoxysRockLevel(u8); +static void WaitForDeoxysRockMovement(u8); +static void Task_LinkRetireStatusWithBattleTowerPartner(u8); +static void Task_LoopWingFlapSE(u8); +static void Task_CloseBattlePikeCurtain(u8); static u8 DidPlayerGetFirstFans(void); static void SetInitialFansOfPlayer(void); static u16 PlayerGainRandomTrainerFan(void); -static void BufferFanClubTrainerName_(struct LinkBattleRecords *linkRecords, u8 a, u8 b); +static void BufferFanClubTrainerName_(struct LinkBattleRecords *, u8, u8); void Special_ShowDiploma(void) { diff --git a/src/field_weather.c b/src/field_weather.c index cd3436441..f7a7f8129 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -72,7 +72,7 @@ static const u8 *sPaletteGammaTypes; // The drought weather effect uses a precalculated color lookup table. Presumably this // is because the underlying color shift calculation is slow. -const u16 sDroughtWeatherColors[][0x1000] = { +static const u16 sDroughtWeatherColors[][0x1000] = { INCBIN_U16("graphics/weather/drought/colors_0.bin"), INCBIN_U16("graphics/weather/drought/colors_1.bin"), INCBIN_U16("graphics/weather/drought/colors_2.bin"), @@ -863,10 +863,10 @@ void LoadCustomWeatherSpritePalette(const u16 *palette) UpdateSpritePaletteWithWeather(gWeatherPtr->weatherPicSpritePalIndex); } -static void LoadDroughtWeatherPalette(u8 *gammaIndexPtr, u8 *a1) +static void LoadDroughtWeatherPalette(u8 *palsIndex, u8 *palsOffset) { - *gammaIndexPtr = 0x20; - *a1 = 0x20; + *palsIndex = 0x20; + *palsOffset = 0x20; } void ResetDroughtWeatherPaletteLoading(void) diff --git a/src/field_weather_effect.c b/src/field_weather_effect.c index 2b87557c2..8349de559 100644 --- a/src/field_weather_effect.c +++ b/src/field_weather_effect.c @@ -14,11 +14,9 @@ #include "trig.h" #include "gpu_regs.h" -// EWRAM -EWRAM_DATA static u8 gCurrentAbnormalWeather = 0; -EWRAM_DATA static u16 gUnusedWeatherRelated = 0; +EWRAM_DATA static u8 sCurrentAbnormalWeather = 0; +EWRAM_DATA static u16 sUnusedWeatherRelated = 0; -// CONST const u16 gCloudsWeatherPalette[] = INCBIN_U16("graphics/weather/cloud.gbapal"); const u16 gSandstormWeatherPalette[] = INCBIN_U16("graphics/weather/sandstorm.gbapal"); const u8 gWeatherFogDiagonalTiles[] = INCBIN_U8("graphics/weather/fog_diagonal.4bpp"); @@ -1815,7 +1813,7 @@ static void UpdateFogDiagonalMovement(void) gWeatherPtr->fogDPosY = gSpriteCoordOffsetY + gWeatherPtr->fogDYOffset; } -static const struct SpriteSheet gFogDiagonalSpriteSheet = +static const struct SpriteSheet sFogDiagonalSpriteSheet = { .data = gWeatherFogDiagonalTiles, .size = sizeof(gWeatherFogDiagonalTiles), @@ -1870,7 +1868,7 @@ static void CreateFogDiagonalSprites(void) if (!gWeatherPtr->fogDSpritesCreated) { - fogDiagonalSpriteSheet = gFogDiagonalSpriteSheet; + fogDiagonalSpriteSheet = sFogDiagonalSpriteSheet; LoadSpriteSheet(&fogDiagonalSpriteSheet); for (i = 0; i < NUM_FOG_DIAGONAL_SPRITES; i++) { @@ -2427,34 +2425,39 @@ static void UpdateBubbleSprite(struct Sprite *sprite) //------------------------------------------------------------------------------ // Unused function. -static void UnusedSetCurrentAbnormalWeather(u32 a0, u32 a1) +static void UnusedSetCurrentAbnormalWeather(u32 weather, u32 unknown) { - gCurrentAbnormalWeather = a0; - gUnusedWeatherRelated = a1; + sCurrentAbnormalWeather = weather; + sUnusedWeatherRelated = unknown; } +#define tState data[0] +#define tWeatherA data[1] +#define tWeatherB data[2] +#define tDelay data[15] + static void Task_DoAbnormalWeather(u8 taskId) { s16 *data = gTasks[taskId].data; - switch (data[0]) + switch (tState) { case 0: - if (data[15]-- <= 0) + if (tDelay-- <= 0) { - SetNextWeather(data[1]); - gCurrentAbnormalWeather = data[1]; - data[15] = 600; - data[0]++; + SetNextWeather(tWeatherA); + sCurrentAbnormalWeather = tWeatherA; + tDelay = 600; + tState++; } break; case 1: - if (data[15]-- <= 0) + if (tDelay-- <= 0) { - SetNextWeather(data[2]); - gCurrentAbnormalWeather = data[2]; - data[15] = 600; - data[0] = 0; + SetNextWeather(tWeatherB); + sCurrentAbnormalWeather = tWeatherB; + tDelay = 600; + tState = 0; } break; } @@ -2465,25 +2468,33 @@ static void CreateAbnormalWeatherTask(void) u8 taskId = CreateTask(Task_DoAbnormalWeather, 0); s16 *data = gTasks[taskId].data; - data[15] = 600; - if (gCurrentAbnormalWeather == WEATHER_DOWNPOUR) + tDelay = 600; + if (sCurrentAbnormalWeather == WEATHER_DOWNPOUR) { - data[1] = WEATHER_DROUGHT; - data[2] = WEATHER_DOWNPOUR; + // Currently Downpour, next will be Drought + tWeatherA = WEATHER_DROUGHT; + tWeatherB = WEATHER_DOWNPOUR; } - else if (gCurrentAbnormalWeather == WEATHER_DROUGHT) + else if (sCurrentAbnormalWeather == WEATHER_DROUGHT) { - data[1] = WEATHER_DOWNPOUR; - data[2] = WEATHER_DROUGHT; + // Currently Drought, next will be Downpour + tWeatherA = WEATHER_DOWNPOUR; + tWeatherB = WEATHER_DROUGHT; } else { - gCurrentAbnormalWeather = WEATHER_DOWNPOUR; - data[1] = WEATHER_DROUGHT; - data[2] = WEATHER_DOWNPOUR; + // Default to starting with Downpour + sCurrentAbnormalWeather = WEATHER_DOWNPOUR; + tWeatherA = WEATHER_DROUGHT; + tWeatherB = WEATHER_DOWNPOUR; } } +#undef tState +#undef tWeatherA +#undef tWeatherB +#undef tDelay + static u8 TranslateWeatherNum(u8); static void UpdateRainCounter(u8, u8); @@ -2526,13 +2537,13 @@ void DoCurrentWeather(void) { if (!FuncIsActiveTask(Task_DoAbnormalWeather)) CreateAbnormalWeatherTask(); - weather = gCurrentAbnormalWeather; + weather = sCurrentAbnormalWeather; } else { if (FuncIsActiveTask(Task_DoAbnormalWeather)) DestroyTask(FindTaskIdByFunc(Task_DoAbnormalWeather)); - gCurrentAbnormalWeather = WEATHER_DOWNPOUR; + sCurrentAbnormalWeather = WEATHER_DOWNPOUR; } SetNextWeather(weather); } @@ -2545,13 +2556,13 @@ void ResumePausedWeather(void) { if (!FuncIsActiveTask(Task_DoAbnormalWeather)) CreateAbnormalWeatherTask(); - weather = gCurrentAbnormalWeather; + weather = sCurrentAbnormalWeather; } else { if (FuncIsActiveTask(Task_DoAbnormalWeather)) DestroyTask(FindTaskIdByFunc(Task_DoAbnormalWeather)); - gCurrentAbnormalWeather = WEATHER_DOWNPOUR; + sCurrentAbnormalWeather = WEATHER_DOWNPOUR; } SetCurrentAndNextWeather(weather); } diff --git a/src/fieldmap.c b/src/fieldmap.c index 4dbf981cf..a02355e72 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -25,10 +25,10 @@ struct ConnectionFlags u8 east:1; }; -EWRAM_DATA static u16 gBackupMapData[MAX_MAP_DATA_SIZE] = {0}; +EWRAM_DATA static u16 sBackupMapData[MAX_MAP_DATA_SIZE] = {0}; EWRAM_DATA struct MapHeader gMapHeader = {0}; EWRAM_DATA struct Camera gCamera = {0}; -EWRAM_DATA static struct ConnectionFlags gMapConnectionFlags = {0}; +EWRAM_DATA static struct ConnectionFlags sMapConnectionFlags = {0}; EWRAM_DATA static u32 sFiller = 0; // without this, the next file won't align properly struct BackupMapLayout gBackupMapLayout; @@ -87,14 +87,14 @@ void InitMapFromSavedGame(void) void InitBattlePyramidMap(bool8 setPlayerPosition) { - CpuFastFill(MAPGRID_UNDEFINED << 16 | MAPGRID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData)); - GenerateBattlePyramidFloorLayout(gBackupMapData, setPlayerPosition); + CpuFastFill(MAPGRID_UNDEFINED << 16 | MAPGRID_UNDEFINED, sBackupMapData, sizeof(sBackupMapData)); + GenerateBattlePyramidFloorLayout(sBackupMapData, setPlayerPosition); } void InitTrainerHillMap(void) { - CpuFastFill(MAPGRID_UNDEFINED << 16 | MAPGRID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData)); - GenerateTrainerHillFloorLayout(gBackupMapData); + CpuFastFill(MAPGRID_UNDEFINED << 16 | MAPGRID_UNDEFINED, sBackupMapData, sizeof(sBackupMapData)); + GenerateTrainerHillFloorLayout(sBackupMapData); } static void InitMapLayoutData(struct MapHeader *mapHeader) @@ -103,8 +103,8 @@ static void InitMapLayoutData(struct MapHeader *mapHeader) int width; int height; mapLayout = mapHeader->mapLayout; - CpuFastFill16(MAPGRID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData)); - gBackupMapLayout.map = gBackupMapData; + CpuFastFill16(MAPGRID_UNDEFINED, sBackupMapData, sizeof(sBackupMapData)); + gBackupMapLayout.map = sBackupMapData; width = mapLayout->width + MAP_OFFSET_W; gBackupMapLayout.width = width; height = mapLayout->height + MAP_OFFSET_H; @@ -140,7 +140,7 @@ static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader) { count = mapHeader->connections->count; connection = mapHeader->connections->connections; - gMapConnectionFlags = sDummyConnectionFlags; + sMapConnectionFlags = sDummyConnectionFlags; for (i = 0; i < count; i++, connection++) { struct MapHeader const *cMap = GetMapHeaderFromConnection(connection); @@ -149,19 +149,19 @@ static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader) { case CONNECTION_SOUTH: FillSouthConnection(mapHeader, cMap, offset); - gMapConnectionFlags.south = TRUE; + sMapConnectionFlags.south = TRUE; break; case CONNECTION_NORTH: FillNorthConnection(mapHeader, cMap, offset); - gMapConnectionFlags.north = TRUE; + sMapConnectionFlags.north = TRUE; break; case CONNECTION_WEST: FillWestConnection(mapHeader, cMap, offset); - gMapConnectionFlags.west = TRUE; + sMapConnectionFlags.west = TRUE; break; case CONNECTION_EAST: FillEastConnection(mapHeader, cMap, offset); - gMapConnectionFlags.east = TRUE; + sMapConnectionFlags.east = TRUE; break; } } @@ -436,7 +436,7 @@ void SaveMapView(void) for (i = y; i < y + MAP_OFFSET_H; i++) { for (j = x; j < x + MAP_OFFSET_W; j++) - *mapView++ = gBackupMapData[width * i + j]; + *mapView++ = sBackupMapData[width * i + j]; } } @@ -491,8 +491,8 @@ static void LoadSavedMapView(void) for (j = x; j < x + MAP_OFFSET_W; j++) { - if (!SkipCopyingMetatileFromSavedMap(&gBackupMapData[j + width * i], width, yMode)) - gBackupMapData[j + width * i] = *mapView; + if (!SkipCopyingMetatileFromSavedMap(&sBackupMapData[j + width * i], width, yMode)) + sBackupMapData[j + width * i] = *mapView; mapView++; } } @@ -554,7 +554,7 @@ static void MoveMapViewToBackup(u8 direction) desti = width * (y + y0); srci = (y + r8) * MAP_OFFSET_W + r9; src = &mapView[srci + i]; - dest = &gBackupMapData[x0 + desti + j]; + dest = &sBackupMapData[x0 + desti + j]; *dest = *src; i++; j++; @@ -570,28 +570,28 @@ int GetMapBorderIdAt(int x, int y) if (x >= (gBackupMapLayout.width - (MAP_OFFSET + 1))) { - if (!gMapConnectionFlags.east) + if (!sMapConnectionFlags.east) return CONNECTION_INVALID; return CONNECTION_EAST; } else if (x < MAP_OFFSET) { - if (!gMapConnectionFlags.west) + if (!sMapConnectionFlags.west) return CONNECTION_INVALID; return CONNECTION_WEST; } else if (y >= (gBackupMapLayout.height - MAP_OFFSET)) { - if (!gMapConnectionFlags.south) + if (!sMapConnectionFlags.south) return CONNECTION_INVALID; return CONNECTION_SOUTH; } else if (y < MAP_OFFSET) { - if (!gMapConnectionFlags.north) + if (!sMapConnectionFlags.north) return CONNECTION_INVALID; return CONNECTION_NORTH; diff --git a/src/frontier_util.c b/src/frontier_util.c index 53e2e7c2b..b1f12e18f 100644 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -29,6 +29,7 @@ #include "load_save.h" #include "battle_dome.h" #include "constants/battle_frontier.h" +#include "constants/battle_pike.h" #include "constants/frontier_util.h" #include "constants/trainers.h" #include "constants/game_stat.h" @@ -499,94 +500,94 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ static const u8 sBattlePointAwards[][NUM_FRONTIER_FACILITIES][FRONTIER_MODE_COUNT] = { { - {1, 2, 3, 3}, {1, 1, 0, 0}, {4, 5, 0, 0}, {1, 0, 0, 0}, {3, 4, 0, 0}, {1, 0, 0, 0}, {5, 0, 0, 0} + {1, 2, 3, 3}, {1, 1}, {4, 5}, {1}, {3, 4}, {1}, {5} }, { - {2, 3, 4, 4}, {1, 1, 0, 0}, {4, 5, 0, 0}, {1, 0, 0, 0}, {3, 4, 0, 0}, {1, 0, 0, 0}, {5, 0, 0, 0} + {2, 3, 4, 4}, {1, 1}, {4, 5}, {1}, {3, 4}, {1}, {5} }, { - {3, 4, 5, 5}, {2, 2, 0, 0}, {5, 6, 0, 0}, {1, 0, 0, 0}, {4, 5, 0, 0}, {2, 0, 0, 0}, {6, 0, 0, 0} + {3, 4, 5, 5}, {2, 2}, {5, 6}, {1}, {4, 5}, {2}, {6} }, { - {4, 5, 6, 6}, {2, 2, 0, 0}, {5, 6, 0, 0}, {2, 0, 0, 0}, {4, 5, 0, 0}, {2, 0, 0, 0}, {6, 0, 0, 0} + {4, 5, 6, 6}, {2, 2}, {5, 6}, {2}, {4, 5}, {2}, {6} }, { - {5, 6, 7, 7}, {3, 3, 0, 0}, {6, 7, 0, 0}, {2, 0, 0, 0}, {5, 6, 0, 0}, {2, 0, 0, 0}, {7, 0, 0, 0} + {5, 6, 7, 7}, {3, 3}, {6, 7}, {2}, {5, 6}, {2}, {7} }, { - {6, 7, 8, 8}, {3, 3, 0, 0}, {6, 7, 0, 0}, {2, 0, 0, 0}, {5, 6, 0, 0}, {4, 0, 0, 0}, {7, 0, 0, 0} + {6, 7, 8, 8}, {3, 3}, {6, 7}, {2}, {5, 6}, {4}, {7} }, { - {7, 8, 9, 9}, {4, 4, 0, 0}, {7, 8, 0, 0}, {3, 0, 0, 0}, {6, 7, 0, 0}, {4, 0, 0, 0}, {8, 0, 0, 0} + {7, 8, 9, 9}, {4, 4}, {7, 8}, {3}, {6, 7}, {4}, {8} }, { - {8, 9, 10, 10}, {4, 4, 0, 0}, {7, 8, 0, 0}, {3, 0, 0, 0},{6, 7, 0, 0}, {4, 0, 0, 0}, {8, 0, 0, 0} + {8, 9, 10, 10}, {4, 4}, {7, 8}, {3},{6, 7}, {4}, {8} }, { - {9, 10, 11, 11}, {5, 5, 0, 0}, {8, 9, 0, 0}, {4, 0, 0, 0}, {7, 8, 0, 0}, {8, 0, 0, 0}, {9, 0, 0, 0} + {9, 10, 11, 11}, {5, 5}, {8, 9}, {4}, {7, 8}, {8}, {9} }, { - {10, 11, 12, 12}, {5, 5, 0, 0}, {8, 9, 0, 0}, {4, 0, 0, 0}, {7, 8, 0, 0}, {8, 0, 0, 0}, {9, 0, 0, 0} + {10, 11, 12, 12}, {5, 5}, {8, 9}, {4}, {7, 8}, {8}, {9} }, { - {11, 12, 13, 13}, {6, 6, 0, 0}, {9, 10, 0, 0}, {5, 0, 0,0}, {8, 9, 0, 0}, {8, 0, 0, 0}, {10, 0, 0, 0} + {11, 12, 13, 13}, {6, 6}, {9, 10}, {5,0}, {8, 9}, {8}, {10} }, { - {12, 13, 14, 14}, {6, 6, 0, 0}, {9, 10, 0, 0}, {6, 0, 0,0}, {8, 9, 0, 0}, {8, 0, 0, 0}, {10, 0, 0, 0} + {12, 13, 14, 14}, {6, 6}, {9, 10}, {6,0}, {8, 9}, {8}, {10} }, { - {13, 14, 15, 15}, {7, 7, 0, 0}, {10, 11, 0, 0}, {7, 0, 0, 0}, {9, 10, 0, 0}, {10, 0, 0, 0}, {11, 0, 0, 0} + {13, 14, 15, 15}, {7, 7}, {10, 11}, {7}, {9, 10}, {10}, {11} }, { - {14, 15, 15, 15}, {7, 7, 0, 0}, {10, 11, 0, 0}, {8, 0, 0, 0}, {9, 10, 0, 0}, {10, 0, 0, 0}, {11, 0, 0, 0} + {14, 15, 15, 15}, {7, 7}, {10, 11}, {8}, {9, 10}, {10}, {11} }, { - {15, 15, 15, 15}, {8, 8, 0, 0}, {11, 12, 0, 0}, {9, 0, 0, 0}, {10, 11, 0, 0}, {10, 0, 0, 0}, {12, 0, 0, 0} + {15, 15, 15, 15}, {8, 8}, {11, 12}, {9}, {10, 11}, {10}, {12} }, { - {15, 15, 15, 15}, {8, 8, 0, 0}, {11, 12, 0, 0}, {10, 0, 0, 0}, {10, 11, 0, 0}, {10, 0, 0, 0}, {12, 0, 0, 0} + {15, 15, 15, 15}, {8, 8}, {11, 12}, {10}, {10, 11}, {10}, {12} }, { - {15, 15, 15, 15}, {9, 9, 0, 0}, {12, 13, 0, 0}, {11, 0, 0, 0}, {11, 12, 0, 0}, {12, 0, 0, 0}, {13, 0, 0, 0} + {15, 15, 15, 15}, {9, 9}, {12, 13}, {11}, {11, 12}, {12}, {13} }, { - {15, 15, 15, 15}, {9, 9, 0, 0}, {12, 13, 0, 0}, {12, 0, 0, 0}, {11, 12, 0, 0}, {12, 0, 0, 0}, {13, 0, 0, 0} + {15, 15, 15, 15}, {9, 9}, {12, 13}, {12}, {11, 12}, {12}, {13} }, { - {15, 15, 15, 15}, {10, 10, 0, 0}, {13, 14, 0, 0}, {13, 0, 0, 0}, {12, 13, 0, 0}, {12, 0, 0, 0}, {14, 0, 0, 0} + {15, 15, 15, 15}, {10, 10}, {13, 14}, {13}, {12, 13}, {12}, {14} }, { - {15, 15, 15, 15}, {10, 10, 0, 0}, {13, 14, 0, 0}, {14, 0, 0, 0}, {12, 13, 0, 0}, {12, 0, 0, 0}, {14, 0, 0, 0} + {15, 15, 15, 15}, {10, 10}, {13, 14}, {14}, {12, 13}, {12}, {14} }, { - {15, 15, 15, 15}, {11, 11, 0, 0}, {14, 15, 0, 0}, {15, 0, 0, 0}, {13, 14, 0, 0}, {12, 0, 0, 0}, {15, 0, 0, 0} + {15, 15, 15, 15}, {11, 11}, {14, 15}, {15}, {13, 14}, {12}, {15} }, { - {15, 15, 15, 15}, {11, 11, 0, 0}, {14, 15, 0, 0}, {15, 0, 0, 0}, {13, 14, 0, 0}, {14, 0, 0, 0}, {15, 0, 0, 0} + {15, 15, 15, 15}, {11, 11}, {14, 15}, {15}, {13, 14}, {14}, {15} }, { - {15, 15, 15, 15}, {12, 12, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {14, 15, 0, 0}, {14, 0, 0, 0}, {15, 0, 0, 0} + {15, 15, 15, 15}, {12, 12}, {15, 15}, {15}, {14, 15}, {14}, {15} }, { - {15, 15, 15, 15}, {12, 12, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {14, 15, 0, 0}, {14, 0, 0, 0}, {15, 0, 0, 0} + {15, 15, 15, 15}, {12, 12}, {15, 15}, {15}, {14, 15}, {14}, {15} }, { - {15, 15, 15, 15}, {13, 13, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 15, 0, 0}, {14, 0, 0, 0}, {15, 0, 0, 0} + {15, 15, 15, 15}, {13, 13}, {15, 15}, {15}, {15, 15}, {14}, {15} }, { - {15, 15, 15, 15}, {13, 13, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 0, 0, 0} + {15, 15, 15, 15}, {13, 13}, {15, 15}, {15}, {15, 15}, {15}, {15} }, { - {15, 15, 15, 15}, {14, 14, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 0, 0, 0} + {15, 15, 15, 15}, {14, 14}, {15, 15}, {15}, {15, 15}, {15}, {15} }, { - {15, 15, 15, 15}, {14, 14, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 0, 0, 0} + {15, 15, 15, 15}, {14, 14}, {15, 15}, {15}, {15, 15}, {15}, {15} }, { - {15, 15, 15, 15}, {15, 15, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 0, 0, 0} + {15, 15, 15, 15}, {15, 15}, {15, 15}, {15}, {15, 15}, {15}, {15} }, { - {15, 15, 15, 15}, {15, 15, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 0, 0, 0} + {15, 15, 15, 15}, {15, 15}, {15, 15}, {15}, {15, 15}, {15}, {15} }, }; @@ -594,13 +595,13 @@ static const u8 sBattlePointAwards[][NUM_FRONTIER_FACILITIES][FRONTIER_MODE_COUN // First bit is has battled them before and not won yet, second bit is has battled them and won (obtained a Symbol) static const u16 sBattledBrainBitFlags[NUM_FRONTIER_FACILITIES][2] = { - [FRONTIER_FACILITY_TOWER] = {0x0001, 0x0002}, - [FRONTIER_FACILITY_DOME] = {0x0004, 0x0008}, - [FRONTIER_FACILITY_PALACE] = {0x0010, 0x0020}, - [FRONTIER_FACILITY_ARENA] = {0x0040, 0x0080}, - [FRONTIER_FACILITY_FACTORY] = {0x0100, 0x0200}, - [FRONTIER_FACILITY_PIKE] = {0x0400, 0x0800}, - [FRONTIER_FACILITY_PYRAMID] = {0x1000, 0x2000}, + [FRONTIER_FACILITY_TOWER] = {1 << 0, 1 << 1}, + [FRONTIER_FACILITY_DOME] = {1 << 2, 1 << 3}, + [FRONTIER_FACILITY_PALACE] = {1 << 4, 1 << 5}, + [FRONTIER_FACILITY_ARENA] = {1 << 6, 1 << 7}, + [FRONTIER_FACILITY_FACTORY] = {1 << 8, 1 << 9}, + [FRONTIER_FACILITY_PIKE] = {1 << 10, 1 << 11}, + [FRONTIER_FACILITY_PYRAMID] = {1 << 12, 1 << 13}, }; static void (* const sFrontierUtilFuncs[])(void) = @@ -635,8 +636,8 @@ static const struct WindowTemplate sFrontierResultsWindowTemplate = .bg = 0, .tilemapLeft = 1, .tilemapTop = 1, - .width = 0x1c, - .height = 0x12, + .width = 28, + .height = 18, .paletteNum = 15, .baseBlock = 1 }; @@ -646,7 +647,7 @@ static const struct WindowTemplate sLinkContestResultsWindowTemplate = .bg = 0, .tilemapLeft = 2, .tilemapTop = 2, - .width = 0x1a, + .width = 26, .height = 15, .paletteNum = 15, .baseBlock = 1 @@ -657,7 +658,7 @@ static const struct WindowTemplate sRankingHallRecordsWindowTemplate = .bg = 0, .tilemapLeft = 2, .tilemapTop = 1, - .width = 0x1a, + .width = 26, .height = 17, .paletteNum = 15, .baseBlock = 1 @@ -958,7 +959,7 @@ static bool8 IsWinStreakActive(u32 challenge) static void PrintAligned(const u8 *str, s32 y) { - s32 x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 224); + s32 x = GetStringCenterAlignXOffset(FONT_NORMAL, str, DISPLAY_WIDTH - 16); y = (y * 8) + 1; AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str, x, y, TEXT_SKIP_DRAW, NULL); } @@ -968,7 +969,7 @@ static void PrintHyphens(s32 y) s32 i; u8 text[37]; - for (i = 0; i < 36; i++) + for (i = 0; i < (int)ARRAY_COUNT(text) - 1; i++) text[i] = CHAR_HYPHEN; text[i] = EOS; @@ -1860,25 +1861,25 @@ static void GiveBattlePoints(void) switch (facility) { case FRONTIER_FACILITY_TOWER: - challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / 7; + challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE; break; case FRONTIER_FACILITY_DOME: challengeNum = gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode]; break; case FRONTIER_FACILITY_PALACE: - challengeNum = gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode] / 7; + challengeNum = gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE; break; case FRONTIER_FACILITY_ARENA: - challengeNum = gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] / 7; + challengeNum = gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] / FRONTIER_STAGES_PER_CHALLENGE; break; case FRONTIER_FACILITY_FACTORY: - challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / 7; + challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE; break; case FRONTIER_FACILITY_PIKE: - challengeNum = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] / 14; + challengeNum = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] / NUM_PIKE_ROOMS; break; case FRONTIER_FACILITY_PYRAMID: - challengeNum = gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / 7; + challengeNum = gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / FRONTIER_STAGES_PER_CHALLENGE; break; } @@ -1982,7 +1983,7 @@ static void AppendIfValid(u16 species, u16 heldItem, u16 hp, u8 lvlMode, u8 monL if (gFrontierBannedSpecies[i] != 0xFFFF) return; - if (lvlMode == FRONTIER_LVL_50 && monLevel > 50) + if (lvlMode == FRONTIER_LVL_50 && monLevel > FRONTIER_MAX_LEVEL_50) return; for (i = 0; i < *count && speciesArray[i] != species; i++) @@ -2344,7 +2345,7 @@ static void PrintHallRecords(s32 hallFacilityId, s32 lvlMode) StringCopy(gStringVar1, sRecordsWindowChallengeTexts[hallFacilityId][0]); StringExpandPlaceholders(gStringVar4, sRecordsWindowChallengeTexts[hallFacilityId][1]); AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, NULL); - x = GetStringRightAlignXOffset(FONT_NORMAL, sLevelModeText[lvlMode], 0xD0); + x = GetStringRightAlignXOffset(FONT_NORMAL, sLevelModeText[lvlMode], DISPLAY_WIDTH - 32); AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, sLevelModeText[lvlMode], x, 1, TEXT_SKIP_DRAW, NULL); if (hallFacilityId == RANKING_HALL_TOWER_LINK) { diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index d134f2265..38f096af8 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -52,6 +52,8 @@ struct HallofFameTeam struct HallofFameMon mon[PARTY_SIZE]; }; +STATIC_ASSERT(sizeof(struct HallofFameTeam) * HALL_OF_FAME_MAX_TEAMS <= SECTOR_DATA_SIZE * NUM_HOF_SECTORS, HallOfFameFreeSpace); + struct HofGfx { u16 state; @@ -512,7 +514,7 @@ static void Task_Hof_InitTeamSaveData(u8 taskId) } *lastSavedTeam = *sHofMonPtr; - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); AddTextPrinterParameterized2(0, FONT_NORMAL, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3); CopyWindowToVram(0, COPYWIN_FULL); gTasks[taskId].func = Task_Hof_TrySaveData; @@ -527,10 +529,8 @@ static void Task_Hof_TrySaveData(u8 taskId) UnsetBgTilemapBuffer(3); FreeAllWindowBuffers(); - if (sHofGfxPtr != NULL) - FREE_AND_SET_NULL(sHofGfxPtr); - if (sHofMonPtr != NULL) - FREE_AND_SET_NULL(sHofMonPtr); + TRY_FREE_AND_SET_NULL(sHofGfxPtr); + TRY_FREE_AND_SET_NULL(sHofMonPtr); DestroyTask(taskId); } @@ -722,7 +722,7 @@ static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId) { FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); HallOfFame_PrintPlayerInfo(1, 2); - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); AddTextPrinterParameterized2(0, FONT_NORMAL, gText_LeagueChamp, 0, NULL, 2, 1, 3); CopyWindowToVram(0, COPYWIN_FULL); gTasks[taskId].func = Task_Hof_ExitOnKeyPressed; @@ -771,10 +771,8 @@ static void Task_Hof_HandleExit(u8 taskId) ResetBgsAndClearDma3BusyFlags(0); DestroyTask(taskId); - if (sHofGfxPtr != NULL) - FREE_AND_SET_NULL(sHofGfxPtr); - if (sHofMonPtr != NULL) - FREE_AND_SET_NULL(sHofMonPtr); + TRY_FREE_AND_SET_NULL(sHofGfxPtr); + TRY_FREE_AND_SET_NULL(sHofMonPtr); StartCredits(); } @@ -1079,10 +1077,8 @@ static void Task_HofPC_HandleExit(u8 taskId) ResetBgsAndClearDma3BusyFlags(0); DestroyTask(taskId); - if (sHofGfxPtr != NULL) - FREE_AND_SET_NULL(sHofGfxPtr); - if (sHofMonPtr != NULL) - FREE_AND_SET_NULL(sHofMonPtr); + TRY_FREE_AND_SET_NULL(sHofGfxPtr); + TRY_FREE_AND_SET_NULL(sHofMonPtr); ReturnFromHallOfFamePC(); } @@ -1091,7 +1087,7 @@ static void Task_HofPC_HandleExit(u8 taskId) static void Task_HofPC_PrintDataIsCorrupted(u8 taskId) { HofPCTopBar_Print(gText_AButtonExit, 8, TRUE); - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); AddTextPrinterParameterized2(0, FONT_NORMAL, gText_HOFCorrupted, 0, NULL, 2, 1, 3); CopyWindowToVram(0, COPYWIN_FULL); gTasks[taskId].func = Task_HofPC_ExitOnButtonPress; diff --git a/src/intro.c b/src/intro.c index 827ce80be..a1d0508f4 100644 --- a/src/intro.c +++ b/src/intro.c @@ -1848,7 +1848,7 @@ static void Task_Scene3_StartGroudon(u8 taskId) { gTasks[taskId].tState = 0; gTasks[taskId].func = Task_Scene3_Groudon; - ScanlineEffect_InitWave(0, 160, 4, 4, 1, SCANLINE_EFFECT_REG_BG1HOFS, 0); + ScanlineEffect_InitWave(0, 160, 4, 4, 1, SCANLINE_EFFECT_REG_BG1HOFS, FALSE); } #define tScreenX data[1] @@ -2058,7 +2058,7 @@ static void Task_Scene3_LoadKyogre(u8 taskId) gTasks[taskId].tDelay = 16; gTasks[taskId].tZoom = 256; PanFadeAndZoomScreen(gTasks[taskId].tScreenX, gTasks[taskId].tScreenY, gTasks[taskId].tZoom, 0); - ScanlineEffect_InitWave(0, 0xA0, 4, 4, 1, SCANLINE_EFFECT_REG_BG1VOFS, 0); + ScanlineEffect_InitWave(0, 0xA0, 4, 4, 1, SCANLINE_EFFECT_REG_BG1VOFS, FALSE); } static void Task_Scene3_Kyogre(u8 taskId) diff --git a/src/intro_credits_graphics.c b/src/intro_credits_graphics.c index e7039e02b..0942e82f1 100644 --- a/src/intro_credits_graphics.c +++ b/src/intro_credits_graphics.c @@ -757,10 +757,9 @@ void LoadIntroPart2Graphics(u8 scenery) gReservedSpritePaletteCount = 8; } -// Note: This is only called with a=1. +// Note: This is only called with scenery=1. void SetIntroPart2BgCnt(u8 scenery) { - // Only called with scenery = 1 switch (scenery) { default: diff --git a/src/item_menu.c b/src/item_menu.c index 9eaca9597..cd0bc159d 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1344,7 +1344,7 @@ static void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, bool16 skipEraseLis DrawPocketIndicatorSquare(newPocket, TRUE); FillBgTilemapBufferRect_Palette0(2, 11, 14, 2, 15, 16); ScheduleBgCopyTilemapToVram(2); - SetBagVisualPocketId(newPocket, 1); + SetBagVisualPocketId(newPocket, TRUE); RemoveBagSprite(ITEMMENUSPRITE_BALL); AddSwitchPocketRotatingBallSprite(deltaBagPocketId); SetTaskFuncWithFollowupFunc(taskId, Task_SwitchBagPocket, gTasks[taskId].func); diff --git a/src/item_menu_icons.c b/src/item_menu_icons.c index a5c265f90..5ac44f5ad 100644 --- a/src/item_menu_icons.c +++ b/src/item_menu_icons.c @@ -35,8 +35,8 @@ static void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite); // static const rom data static const u16 sRotatingBall_Pal[] = INCBIN_U16("graphics/bag/rotating_ball.gbapal"); static const u8 sRotatingBall_Gfx[] = INCBIN_U8("graphics/bag/rotating_ball.4bpp"); -static const u8 gCherryUnused[] = INCBIN_U8("graphics/unused/cherry.4bpp"); -static const u16 gCherryUnused_Pal[] = INCBIN_U16("graphics/unused/cherry.gbapal"); +static const u8 sCherryUnused[] = INCBIN_U8("graphics/unused/cherry.4bpp"); +static const u16 sCherryUnused_Pal[] = INCBIN_U16("graphics/unused/cherry.gbapal"); static const struct OamData sBagOamData = { @@ -269,7 +269,7 @@ static const struct SpriteFrameImage sBerryPicSpriteImageTable[] = {&gDecompressionBuffer[0], 0x800}, }; -static const struct SpriteTemplate gBerryPicSpriteTemplate = +static const struct SpriteTemplate sBerryPicSpriteTemplate = { .tileTag = TAG_NONE, .paletteTag = TAG_BERRY_PIC_PAL, @@ -308,7 +308,7 @@ static const union AffineAnimCmd *const sBerryPicRotatingAnimCmds[] = sSpriteAffineAnim_BerryPicRotation2 }; -static const struct SpriteTemplate gBerryPicRotatingSpriteTemplate = +static const struct SpriteTemplate sBerryPicRotatingSpriteTemplate = { .tileTag = TAG_NONE, .paletteTag = TAG_BERRY_PIC_PAL, @@ -404,7 +404,7 @@ static const union AnimCmd *const sBerryCheckCircleSpriteAnimTable[] = sSpriteAnim_BerryCheckCircle }; -static const struct SpriteTemplate gBerryCheckCircleSpriteTemplate = +static const struct SpriteTemplate sBerryCheckCircleSpriteTemplate = { .tileTag = TAG_BERRY_CHECK_CIRCLE_GFX, .paletteTag = TAG_BERRY_CHECK_CIRCLE_GFX, @@ -544,7 +544,22 @@ void AddBagItemIconSprite(u16 itemId, u8 id) void RemoveBagItemIconSprite(u8 id) { +// BUG: For one frame, the item you scroll to in the Bag menu +// will have an incorrect palette and may be seen as a flicker. +#ifdef BUGFIX + u8 *spriteId = &gBagMenu->spriteIds[ITEMMENUSPRITE_ITEM]; + + if (spriteId[id ^ 1] != SPRITE_NONE) + gSprites[spriteId[id ^ 1]].invisible = TRUE; + + if (spriteId[id] != SPRITE_NONE) + { + DestroySpriteAndFreeResources(&gSprites[spriteId[id]]); + spriteId[id] = SPRITE_NONE; + } +#else RemoveBagSprite(id + ITEMMENUSPRITE_ITEM); +#endif } void CreateItemMenuSwapLine(void) @@ -609,7 +624,7 @@ static void LoadBerryGfx(u8 berryId) u8 CreateBerryTagSprite(u8 id, s16 x, s16 y) { LoadBerryGfx(id); - return CreateSprite(&gBerryPicSpriteTemplate, x, y, 0); + return CreateSprite(&sBerryPicSpriteTemplate, x, y, 0); } void FreeBerryTagSpritePalette(void) @@ -624,7 +639,7 @@ u8 CreateSpinningBerrySprite(u8 berryId, u8 x, u8 y, bool8 startAffine) FreeSpritePaletteByTag(TAG_BERRY_PIC_PAL); LoadBerryGfx(berryId); - spriteId = CreateSprite(&gBerryPicRotatingSpriteTemplate, x, y, 0); + spriteId = CreateSprite(&sBerryPicRotatingSpriteTemplate, x, y, 0); if (startAffine == TRUE) StartSpriteAffineAnim(&gSprites[spriteId], 1); @@ -633,5 +648,5 @@ u8 CreateSpinningBerrySprite(u8 berryId, u8 x, u8 y, bool8 startAffine) u8 CreateBerryFlavorCircleSprite(s16 x) { - return CreateSprite(&gBerryCheckCircleSpriteTemplate, x, 116, 0); + return CreateSprite(&sBerryCheckCircleSpriteTemplate, x, 116, 0); } diff --git a/src/item_use.c b/src/item_use.c index caf8bf286..1a5640783 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -43,33 +43,33 @@ #include "constants/items.h" #include "constants/songs.h" -static void SetUpItemUseCallback(u8 taskId); +static void SetUpItemUseCallback(u8); static void FieldCB_UseItemOnField(void); -static void Task_CallItemUseOnFieldCallback(u8 taskId); -static void Task_UseItemfinder(u8 taskId); -static void Task_CloseItemfinderMessage(u8 taskId); -static void Task_HiddenItemNearby(u8 taskId); -static void Task_StandingOnHiddenItem(u8 taskId); +static void Task_CallItemUseOnFieldCallback(u8); +static void Task_UseItemfinder(u8); +static void Task_CloseItemfinderMessage(u8); +static void Task_HiddenItemNearby(u8); +static void Task_StandingOnHiddenItem(u8); static bool8 ItemfinderCheckForHiddenItems(const struct MapEvents *, u8); -static u8 GetDirectionToHiddenItem(s16 distanceX, s16 distanceY); -static void PlayerFaceHiddenItem(u8 a); -static void CheckForHiddenItemsInMapConnection(u8 taskId); -static void Task_OpenRegisteredPokeblockCase(u8 taskId); -static void ItemUseOnFieldCB_Bike(u8 taskId); +static u8 GetDirectionToHiddenItem(s16, s16); +static void PlayerFaceHiddenItem(u8); +static void CheckForHiddenItemsInMapConnection(u8); +static void Task_OpenRegisteredPokeblockCase(u8); +static void ItemUseOnFieldCB_Bike(u8); static void ItemUseOnFieldCB_Rod(u8); static void ItemUseOnFieldCB_Itemfinder(u8); -static void ItemUseOnFieldCB_Berry(u8 taskId); -static void ItemUseOnFieldCB_WailmerPailBerry(u8 taskId); -static void ItemUseOnFieldCB_WailmerPailSudowoodo(u8 taskId); +static void ItemUseOnFieldCB_Berry(u8); +static void ItemUseOnFieldCB_WailmerPailBerry(u8); +static void ItemUseOnFieldCB_WailmerPailSudowoodo(u8); static bool8 TryToWaterSudowoodo(void); -static void BootUpSoundTMHM(u8 taskId); -static void Task_ShowTMHMContainedMessage(u8 taskId); -static void UseTMHMYesNo(u8 taskId); -static void UseTMHM(u8 taskId); -static void Task_StartUseRepel(u8 taskId); -static void Task_UseRepel(u8 taskId); -static void Task_CloseCantUseKeyItemMessage(u8 taskId); -static void SetDistanceOfClosestHiddenItem(u8 taskId, s16 x, s16 y); +static void BootUpSoundTMHM(u8); +static void Task_ShowTMHMContainedMessage(u8); +static void UseTMHMYesNo(u8); +static void UseTMHM(u8); +static void Task_StartUseRepel(u8); +static void Task_UseRepel(u8); +static void Task_CloseCantUseKeyItemMessage(u8); +static void SetDistanceOfClosestHiddenItem(u8, s16, s16); static void CB2_OpenPokeblockFromBag(void); // EWRAM variables diff --git a/src/landmark.c b/src/landmark.c index 52d52500a..615a9bfe3 100644 --- a/src/landmark.c +++ b/src/landmark.c @@ -336,7 +336,7 @@ static const struct Landmark *const Landmarks_MtChimney_2[] = NULL, }; -static const struct LandmarkList gLandmarkLists[] = +static const struct LandmarkList sLandmarkLists[] = { {MAPSEC_ROUTE_103, 2, Landmarks_Route103_2}, {MAPSEC_ROUTE_104, 0, Landmarks_Route104_0}, @@ -420,21 +420,21 @@ static const struct Landmark *const *GetLandmarks(u8 mapSection, u8 id) { u16 i = 0; - for (; gLandmarkLists[i].mapSection != MAPSEC_NONE; i++) + for (; sLandmarkLists[i].mapSection != MAPSEC_NONE; i++) { - if (gLandmarkLists[i].mapSection > mapSection) + if (sLandmarkLists[i].mapSection > mapSection) return NULL; - if (gLandmarkLists[i].mapSection == mapSection) + if (sLandmarkLists[i].mapSection == mapSection) break; } - if (gLandmarkLists[i].mapSection == MAPSEC_NONE) + if (sLandmarkLists[i].mapSection == MAPSEC_NONE) return NULL; - for (; gLandmarkLists[i].mapSection == mapSection; i++) + for (; sLandmarkLists[i].mapSection == mapSection; i++) { - if (gLandmarkLists[i].id == id) - return gLandmarkLists[i].landmarks; + if (sLandmarkLists[i].id == id) + return sLandmarkLists[i].landmarks; } return NULL; diff --git a/src/link.c b/src/link.c index aa9a0d73d..e88cde55a 100644 --- a/src/link.c +++ b/src/link.c @@ -120,18 +120,18 @@ static EWRAM_DATA void *sLinkErrorBgTilemapBuffer = NULL; static void InitLocalLinkPlayer(void); static void VBlankCB_LinkError(void); static void CB2_LinkTest(void); -static void ProcessRecvCmds(u8 unused); +static void ProcessRecvCmds(u8); static void LinkCB_SendHeldKeys(void); static void ResetBlockSend(void); -static bool32 InitBlockSend(const void *src, size_t size); +static bool32 InitBlockSend(const void *, size_t); static void LinkCB_BlockSendBegin(void); static void LinkCB_BlockSend(void); static void LinkCB_BlockSendEnd(void); -static void SetBlockReceivedFlag(u8 who); -static u16 LinkTestCalcBlockChecksum(const u16 *src, u16 size); -static void LinkTest_PrintHex(u32 pos, u8 a0, u8 a1, u8 a2); +static void SetBlockReceivedFlag(u8); +static u16 LinkTestCalcBlockChecksum(const u16 *, u16); +static void LinkTest_PrintHex(u32, u8, u8, u8); static void LinkCB_RequestPlayerDataExchange(void); -static void Task_PrintTestData(u8 taskId); +static void Task_PrintTestData(u8); static void LinkCB_ReadyCloseLink(void); static void LinkCB_WaitCloseLink(void); diff --git a/src/list_menu.c b/src/list_menu.c index ccb183891..8ba13a6cf 100644 --- a/src/list_menu.c +++ b/src/list_menu.c @@ -312,14 +312,14 @@ static void ListMenuDummyTask(u8 taskId) } -s32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum) +s32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const struct ListMenuTemplate *listMenuTemplate, u8 drawMode, u16 tileNum, u16 palNum) { switch (sMysteryGiftLinkMenu.state) { case 0: default: sMysteryGiftLinkMenu.windowId = AddWindow(windowTemplate); - switch (arg2) + switch (drawMode) { case 2: LoadUserWindowBorderGfx(sMysteryGiftLinkMenu.windowId, tileNum, palNum); @@ -346,13 +346,13 @@ s32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const str } if (sMysteryGiftLinkMenu.state == 2) { - if (arg2 == 0) + if (drawMode == 0) { ClearWindowTilemap(sMysteryGiftLinkMenu.windowId); } else { - switch (arg2) + switch (drawMode) { case 0: // can never be reached, because of the if statement above ClearStdWindowAndFrame(sMysteryGiftLinkMenu.windowId, FALSE); diff --git a/src/m4a_1.s b/src/m4a_1.s index cc5d3238d..3f1578806 100644 --- a/src/m4a_1.s +++ b/src/m4a_1.s @@ -680,7 +680,7 @@ SoundMainRAM_Unk2: ldr r1, [r4, o_SoundChannel_wav] add r2, r2, r1 add r2, r2, 0x10 - ldr r5, =gDecodingBuffer + ldr r5, =sDecodingBuffer ldr r6, =gDeltaEncodingTable mov r7, 0x40 ldrb lr, [r2], 1 @@ -701,7 +701,7 @@ _081DD57C: subs r7, r7, 2 bgt _081DD568 _081DD594: - ldr r5, =gDecodingBuffer + ldr r5, =sDecodingBuffer and r0, r3, 0x3F ldrsb r1, [r5, r0] pop {r0,r2,r5-r7,pc} @@ -1911,6 +1911,6 @@ _081DDD90: .align 2, 0 @ Don't pad with nop. .bss -gDecodingBuffer: @ Used as a buffer for audio decoded from compressed DPCM +sDecodingBuffer: @ Used as a buffer for audio decoded from compressed DPCM .space 0x40 - .size gDecodingBuffer, .-gDecodingBuffer + .size sDecodingBuffer, .-sDecodingBuffer diff --git a/src/main.c b/src/main.c index 2b96a8698..5fd236447 100644 --- a/src/main.c +++ b/src/main.c @@ -69,7 +69,7 @@ u8 gLinkVSyncDisabled; u32 IntrMain_Buffer[0x200]; s8 gPcmDmaCounter; -static EWRAM_DATA u16 gTrainerId = 0; +static EWRAM_DATA u16 sTrainerId = 0; //EWRAM_DATA void (**gFlashTimerIntrFunc)(void) = NULL; @@ -201,12 +201,12 @@ void SeedRngAndSetTrainerId(void) u16 val = REG_TM1CNT_L; SeedRng(val); REG_TM1CNT_H = 0; - gTrainerId = val; + sTrainerId = val; } u16 GetGeneratedTrainerIdLower(void) { - return gTrainerId; + return sTrainerId; } void EnableVCountIntrAtLine150(void) diff --git a/src/main_menu.c b/src/main_menu.c index ed6158a9c..d11784133 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -198,7 +198,7 @@ static void NewGameBirchSpeech_ShowDialogueWindow(u8, u8); static void NewGameBirchSpeech_ClearWindow(u8); static void Task_NewGameBirchSpeech_ThisIsAPokemon(u8); static void Task_NewGameBirchSpeech_MainSpeech(u8); -static void NewGameBirchSpeech_WaitForThisIsPokemonText(struct TextPrinterTemplate *printer, u16 a); +static void NewGameBirchSpeech_WaitForThisIsPokemonText(struct TextPrinterTemplate *, u16); static void Task_NewGameBirchSpeech_AndYouAre(u8); static void Task_NewGameBirchSpeechSub_WaitForLotad(u8); static void Task_NewGameBirchSpeech_StartBirchLotadPlatformFade(u8); @@ -371,7 +371,7 @@ static const struct WindowTemplate sWindowTemplates_MainMenu[] = DUMMY_WIN_TEMPLATE }; -static const struct WindowTemplate gNewGameBirchSpeechTextWindows[] = +static const struct WindowTemplate sNewGameBirchSpeechTextWindows[] = { { .bg = 0, @@ -457,7 +457,7 @@ static const struct MenuAction sMenuActions_Gender[] = { {gText_BirchGirl, NULL} }; -static const u8 *const gMalePresetNames[] = { +static const u8 *const sMalePresetNames[] = { gText_DefaultNameStu, gText_DefaultNameMilton, gText_DefaultNameTom, @@ -480,7 +480,7 @@ static const u8 *const gMalePresetNames[] = { gText_DefaultNameQuincy }; -static const u8 *const gFemalePresetNames[] = { +static const u8 *const sFemalePresetNames[] = { gText_DefaultNameKimmy, gText_DefaultNameTiara, gText_DefaultNameBella, @@ -1325,7 +1325,7 @@ static void Task_NewGameBirchSpeech_WaitForSpriteFadeInWelcome(u8 taskId) } else { - InitWindows(gNewGameBirchSpeechTextWindows); + InitWindows(sNewGameBirchSpeechTextWindows); LoadMainMenuWindowFrameTiles(0, 0xF3); LoadMessageBoxGfx(0, 0xFC, 0xF0); NewGameBirchSpeech_ShowDialogueWindow(0, 1); @@ -1371,7 +1371,7 @@ static void Task_NewGameBirchSpeechSub_InitPokeBall(u8 taskId) gSprites[spriteId].invisible = FALSE; gSprites[spriteId].data[0] = 0; - CreatePokeballSpriteToReleaseMon(spriteId, gSprites[spriteId].oam.paletteNum, 112, 58, 0, 0, 32, 0x0000FFFF, SPECIES_LOTAD); + CreatePokeballSpriteToReleaseMon(spriteId, gSprites[spriteId].oam.paletteNum, 112, 58, 0, 0, 32, PALETTES_BG, SPECIES_LOTAD); gTasks[taskId].func = Task_NewGameBirchSpeechSub_WaitForLotad; gTasks[sBirchSpeechMainTaskId].tTimer = 0; } @@ -1851,7 +1851,7 @@ static void CB2_NewGameBirchSpeech_ReturnFromNamingScreen(void) REG_IME = savedIme; SetVBlankCallback(VBlankCB_MainMenu); SetMainCallback2(CB2_MainMenu); - InitWindows(gNewGameBirchSpeechTextWindows); + InitWindows(sNewGameBirchSpeechTextWindows); LoadMainMenuWindowFrameTiles(0, 0xF3); LoadMessageBoxGfx(0, 0xFC, 0xF0); PutWindowTilemap(0); @@ -2087,7 +2087,7 @@ static void NewGameBirchSpeech_StartFadePlatformOut(u8 taskId, u8 delay) static void NewGameBirchSpeech_ShowGenderMenu(void) { - DrawMainMenuWindowBorder(&gNewGameBirchSpeechTextWindows[1], 0xF3); + DrawMainMenuWindowBorder(&sNewGameBirchSpeechTextWindows[1], 0xF3); FillWindowPixelBuffer(1, PIXEL_FILL(1)); PrintMenuTable(1, ARRAY_COUNT(sMenuActions_Gender), sMenuActions_Gender); InitMenuInUpperLeftCornerNormal(1, ARRAY_COUNT(sMenuActions_Gender), 0); @@ -2106,9 +2106,9 @@ static void NewGameBirchSpeech_SetDefaultPlayerName(u8 nameId) u8 i; if (gSaveBlock2Ptr->playerGender == MALE) - name = gMalePresetNames[nameId]; + name = sMalePresetNames[nameId]; else - name = gFemalePresetNames[nameId]; + name = sFemalePresetNames[nameId]; for (i = 0; i < PLAYER_NAME_LENGTH; i++) gSaveBlock2Ptr->playerName[i] = name[i]; gSaveBlock2Ptr->playerName[PLAYER_NAME_LENGTH] = EOS; @@ -2221,9 +2221,9 @@ static void ClearMainMenuWindowTilemap(const struct WindowTemplate *template) CopyBgTilemapBufferToVram(template->bg); } -static void NewGameBirchSpeech_ClearGenderWindowTilemap(u8 a, u8 b, u8 c, u8 d, u8 e, u8 unused) +static void NewGameBirchSpeech_ClearGenderWindowTilemap(u8 bg, u8 x, u8 y, u8 width, u8 height, u8 unused) { - FillBgTilemapBufferRect(a, 0, b + 0xFF, c + 0xFF, d + 2, e + 2, 2); + FillBgTilemapBufferRect(bg, 0, x + 255, y + 255, width + 2, height + 2, 2); } static void NewGameBirchSpeech_ClearGenderWindow(u8 windowId, bool8 copyToVram) @@ -2247,7 +2247,7 @@ static void NewGameBirchSpeech_ClearWindow(u8 windowId) CopyWindowToVram(windowId, COPYWIN_GFX); } -static void NewGameBirchSpeech_WaitForThisIsPokemonText(struct TextPrinterTemplate *printer, u16 a) +static void NewGameBirchSpeech_WaitForThisIsPokemonText(struct TextPrinterTemplate *printer, u16 renderCmd) { // Wait for Birch's "This is a Pokémon" text to reach the pause // Then start the PokéBall release (if it hasn't been started already) @@ -2270,24 +2270,25 @@ static void NewGameBirchSpeech_ShowDialogueWindow(u8 windowId, u8 copyToVram) FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); PutWindowTilemap(windowId); if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } -static void NewGameBirchSpeech_CreateDialogueWindowBorder(u8 a, u8 b, u8 c, u8 d, u8 e, u8 f) +static void NewGameBirchSpeech_CreateDialogueWindowBorder(u8 bg, u8 x, u8 y, u8 width, u8 height, u8 palNum) { - FillBgTilemapBufferRect(a, 0xFD, b-2, c-1, 1, 1, f); - FillBgTilemapBufferRect(a, 0xFF, b-1, c-1, 1, 1, f); - FillBgTilemapBufferRect(a, 0x100, b, c-1, d, 1, f); - FillBgTilemapBufferRect(a, 0x101, b+d-1, c-1, 1, 1, f); - FillBgTilemapBufferRect(a, 0x102, b+d, c-1, 1, 1, f); - FillBgTilemapBufferRect(a, 0x103, b-2, c, 1, 5, f); - FillBgTilemapBufferRect(a, 0x105, b-1, c, d+1, 5, f); - FillBgTilemapBufferRect(a, 0x106, b+d, c, 1, 5, f); - FillBgTilemapBufferRect(a, BG_TILE_V_FLIP(0xFD), b-2, c+e, 1, 1, f); - FillBgTilemapBufferRect(a, BG_TILE_V_FLIP(0xFF), b-1, c+e, 1, 1, f); - FillBgTilemapBufferRect(a, BG_TILE_V_FLIP(0x100), b, c+e, d-1, 1, f); - FillBgTilemapBufferRect(a, BG_TILE_V_FLIP(0x101), b+d-1, c+e, 1, 1, f); - FillBgTilemapBufferRect(a, BG_TILE_V_FLIP(0x102), b+d, c+e, 1, 1, f); + FillBgTilemapBufferRect(bg, 0xFD, x-2, y-1, 1, 1, palNum); + FillBgTilemapBufferRect(bg, 0xFF, x-1, y-1, 1, 1, palNum); + FillBgTilemapBufferRect(bg, 0x100, x, y-1, width, 1, palNum); + FillBgTilemapBufferRect(bg, 0x101, x+width-1, y-1, 1, 1, palNum); + FillBgTilemapBufferRect(bg, 0x102, x+width, y-1, 1, 1, palNum); + FillBgTilemapBufferRect(bg, 0x103, x-2, y, 1, 5, palNum); + FillBgTilemapBufferRect(bg, 0x105, x-1, y, width+1, 5, palNum); + FillBgTilemapBufferRect(bg, 0x106, x+width, y, 1, 5, palNum); + + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(0xFD), x-2, y+height, 1, 1, palNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(0xFF), x-1, y+height, 1, 1, palNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(0x100), x, y+height, width-1, 1, palNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(0x101), x+width-1, y+height, 1, 1, palNum); + FillBgTilemapBufferRect(bg, BG_TILE_V_FLIP(0x102), x+width, y+height, 1, 1, palNum); } static void Task_NewGameBirchSpeech_ReturnFromNamingScreenShowTextbox(u8 taskId) diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 8cf1a6bab..9eaa035ca 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -12,6 +12,7 @@ #include "string_util.h" #include "task.h" #include "text.h" +#include "constants/battle_frontier.h" #include "constants/layouts.h" #include "constants/region_map_sections.h" #include "constants/weather.h" @@ -176,25 +177,25 @@ static const u8 sRegionMapSectionId_To_PopUpThemeIdMapping[] = [MAPSEC_TRAINER_HILL - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_MARBLE }; -static const u8 gText_PyramidFloor1[] = _("PYRAMID FLOOR 1"); -static const u8 gText_PyramidFloor2[] = _("PYRAMID FLOOR 2"); -static const u8 gText_PyramidFloor3[] = _("PYRAMID FLOOR 3"); -static const u8 gText_PyramidFloor4[] = _("PYRAMID FLOOR 4"); -static const u8 gText_PyramidFloor5[] = _("PYRAMID FLOOR 5"); -static const u8 gText_PyramidFloor6[] = _("PYRAMID FLOOR 6"); -static const u8 gText_PyramidFloor7[] = _("PYRAMID FLOOR 7"); -static const u8 gText_Pyramid[] = _("PYRAMID"); +static const u8 sText_PyramidFloor1[] = _("PYRAMID FLOOR 1"); +static const u8 sText_PyramidFloor2[] = _("PYRAMID FLOOR 2"); +static const u8 sText_PyramidFloor3[] = _("PYRAMID FLOOR 3"); +static const u8 sText_PyramidFloor4[] = _("PYRAMID FLOOR 4"); +static const u8 sText_PyramidFloor5[] = _("PYRAMID FLOOR 5"); +static const u8 sText_PyramidFloor6[] = _("PYRAMID FLOOR 6"); +static const u8 sText_PyramidFloor7[] = _("PYRAMID FLOOR 7"); +static const u8 sText_Pyramid[] = _("PYRAMID"); -static const u8 * const gBattlePyramid_MapHeaderStrings[] = +static const u8 * const sBattlePyramid_MapHeaderStrings[FRONTIER_STAGES_PER_CHALLENGE + 1] = { - gText_PyramidFloor1, - gText_PyramidFloor2, - gText_PyramidFloor3, - gText_PyramidFloor4, - gText_PyramidFloor5, - gText_PyramidFloor6, - gText_PyramidFloor7, - gText_Pyramid, + sText_PyramidFloor1, + sText_PyramidFloor2, + sText_PyramidFloor3, + sText_PyramidFloor4, + sText_PyramidFloor5, + sText_PyramidFloor6, + sText_PyramidFloor7, + sText_Pyramid, }; // Unused @@ -309,12 +310,12 @@ static void ShowMapNamePopUpWindow(void) if (gMapHeader.mapLayoutId == LAYOUT_BATTLE_FRONTIER_BATTLE_PYRAMID_TOP) { withoutPrefixPtr = &(mapDisplayHeader[3]); - mapDisplayHeaderSource = gBattlePyramid_MapHeaderStrings[7]; + mapDisplayHeaderSource = sBattlePyramid_MapHeaderStrings[FRONTIER_STAGES_PER_CHALLENGE]; } else { withoutPrefixPtr = &(mapDisplayHeader[3]); - mapDisplayHeaderSource = gBattlePyramid_MapHeaderStrings[gSaveBlock2Ptr->frontier.curChallengeBattleNum]; + mapDisplayHeaderSource = sBattlePyramid_MapHeaderStrings[gSaveBlock2Ptr->frontier.curChallengeBattleNum]; } StringCopy(withoutPrefixPtr, mapDisplayHeaderSource); } diff --git a/src/match_call.c b/src/match_call.c index de7f13416..8b25d5b44 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -33,6 +33,13 @@ #include "constants/songs.h" #include "constants/trainers.h" +// In this file only the values normally associated with Battle Pike and Factory are swapped. +// Note that this is *not* a bug, because they are properly swapped consistently in this file. +// There would only be an issue if anything in this file interacted with something expecting +// the usual value order, or vice versa. +#define MATCH_CALL_FACTORY FRONTIER_FACILITY_PIKE +#define MATCH_CALL_PIKE FRONTIER_FACILITY_FACTORY + // Each match call message has variables that can be populated randomly or // dependent on the trainer. The below are IDs for how to populate the vars // in a given message. @@ -1590,6 +1597,7 @@ static const struct MatchCallText *GetGeneralMatchCallText(int matchCallId, u8 * rand = Random(); if (!(rand & 1)) { + // Count the number of facilities with a win streak for (count = 0, i = 0; i < NUM_FRONTIER_FACILITIES; i++) { if (GetFrontierStreakInfo(i, &topic) > 1) @@ -1598,6 +1606,8 @@ static const struct MatchCallText *GetGeneralMatchCallText(int matchCallId, u8 * if (count) { + // At least one facility with a win streak + // Randomly choose one to have a call about count = Random() % count; for (i = 0; i < NUM_FRONTIER_FACILITIES; i++) { @@ -1807,15 +1817,15 @@ static void PopulateSpeciesFromTrainerParty(int matchCallId, u8 *destStr) StringCopy(destStr, speciesName); } -static const u8 *const sBattleFrontierFacilityNames[] = +static const u8 *const sBattleFrontierFacilityNames[NUM_FRONTIER_FACILITIES] = { - gText_BattleTower2, - gText_BattleDome, - gText_BattlePalace, - gText_BattleArena, - gText_BattlePike, - gText_BattleFactory, - gText_BattlePyramid, + [FRONTIER_FACILITY_TOWER] = gText_BattleTower2, + [FRONTIER_FACILITY_DOME] = gText_BattleDome, + [FRONTIER_FACILITY_PALACE] = gText_BattlePalace, + [FRONTIER_FACILITY_ARENA] = gText_BattleArena, + [MATCH_CALL_PIKE] = gText_BattlePike, + [MATCH_CALL_FACTORY] = gText_BattleFactory, + [FRONTIER_FACILITY_PYRAMID] = gText_BattlePyramid, }; static void PopulateBattleFrontierFacilityName(int matchCallId, u8 *destStr) @@ -1899,7 +1909,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) switch (facilityId) { case FRONTIER_FACILITY_DOME: - for (i = 0; i < 2; i++) + for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.domeRecordWinStreaks); i++) { for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++) { @@ -1909,11 +1919,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) } *topicTextId = GEN_TOPIC_B_DOME - 1; break; - #ifdef BUGFIX - case FRONTIER_FACILITY_PIKE: - #else - case FRONTIER_FACILITY_FACTORY: - #endif + case MATCH_CALL_PIKE: for (i = 0; i < FRONTIER_LVL_MODE_COUNT; i++) { if (streak < gSaveBlock2Ptr->frontier.pikeRecordStreaks[i]) @@ -1922,7 +1928,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) *topicTextId = GEN_TOPIC_B_PIKE - 1; break; case FRONTIER_FACILITY_TOWER: - for (i = 0; i < 4; i++) + for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.towerRecordWinStreaks); i++) { for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++) { @@ -1933,7 +1939,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) *topicTextId = GEN_TOPIC_STREAK_RECORD - 1; break; case FRONTIER_FACILITY_PALACE: - for (i = 0; i < 2; i++) + for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.palaceRecordWinStreaks); i++) { for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++) { @@ -1943,12 +1949,8 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId) } *topicTextId = GEN_TOPIC_STREAK_RECORD - 1; break; - #ifdef BUGFIX - case FRONTIER_FACILITY_FACTORY: - #else - case FRONTIER_FACILITY_PIKE: - #endif - for (i = 0; i < 2; i++) + case MATCH_CALL_FACTORY: + for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.factoryRecordWinStreaks); i++) { for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++) { diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 681a3dadf..2b6c71c8a 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -438,14 +438,14 @@ static void EnableTextPrinters(void) gDisableTextPrinters = FALSE; } -static void DisableTextPrinters(struct TextPrinterTemplate * printer, u16 a1) +static void DisableTextPrinters(struct TextPrinterTemplate * printer, u16 renderCmd) { gDisableTextPrinters = TRUE; } static void DrawSongTextWindow(const u8 * str) { - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); AddTextPrinterParameterized(0, FONT_NORMAL, str, 0, 1, 1, DisableTextPrinters); gDisableTextPrinters = TRUE; CopyWindowToVram(0, COPYWIN_FULL); diff --git a/src/menu.c b/src/menu.c index ea0a9d4e6..8f452aa29 100644 --- a/src/menu.c +++ b/src/menu.c @@ -543,9 +543,9 @@ void RemoveMapNamePopUpWindow(void) } } -void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextPrinterTemplate *, u16)) +void AddTextPrinterWithCallbackForMessage(bool8 canSpeedUp, void (*callback)(struct TextPrinterTemplate *, u16)) { - gTextFlags.canABSpeedUpPrint = a1; + gTextFlags.canABSpeedUpPrint = canSpeedUp; AddTextPrinterParameterized2(0, FONT_NORMAL, gStringVar4, GetPlayerTextSpeedDelay(), callback, 2, 1, 3); } @@ -1246,9 +1246,9 @@ static void PrintMenuActionGridText(u8 windowId, u8 fontId, u8 left, u8 top, u8 } // Unused -static void PrintMenuActionGridTextAtTop(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struct MenuAction *menuActions) +static void PrintMenuActionGridTextAtTop(u8 windowId, u8 fontId, u8 width, u8 height, u8 columns, u8 rows, const struct MenuAction *menuActions) { - PrintMenuActionGridText(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 0, a2, a3, a4, a5, menuActions); + PrintMenuActionGridText(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 0, width, height, columns, rows, menuActions); } void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 horizontalCount, u8 verticalCount, const struct MenuAction *menuActions, const u8 *actionIds) diff --git a/src/menu_helpers.c b/src/menu_helpers.c index e9f3e571f..7decd695c 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -153,7 +153,7 @@ void DoYesNoFuncWithChoice(u8 taskId, const struct YesNoFuncTable *data) gTasks[taskId].func = Task_CallYesOrNoCallback; } -void CreateYesNoMenuWithCallbacks(u8 taskId, const struct WindowTemplate *template, u8 arg2, u8 arg3, u8 arg4, u16 tileStart, u8 palette, const struct YesNoFuncTable *yesNo) +void CreateYesNoMenuWithCallbacks(u8 taskId, const struct WindowTemplate *template, u8 unused1, u8 unused2, u8 unused3, u16 tileStart, u8 palette, const struct YesNoFuncTable *yesNo) { CreateYesNoMenu(template, tileStart, palette, 0); sYesNo = *yesNo; @@ -176,17 +176,18 @@ static void Task_CallYesOrNoCallback(u8 taskId) } } -bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1) +// Returns TRUE if the quantity was changed, FALSE if it remained the same +bool8 AdjustQuantityAccordingToDPadInput(s16 *quantity, u16 max) { - s16 valBefore = (*arg0); + s16 valBefore = *quantity; - if ((JOY_REPEAT(DPAD_ANY)) == DPAD_UP) + if (JOY_REPEAT(DPAD_ANY) == DPAD_UP) { - (*arg0)++; - if ((*arg0) > arg1) - (*arg0) = 1; + (*quantity)++; + if (*quantity > max) + *quantity = 1; - if ((*arg0) == valBefore) + if (*quantity == valBefore) { return FALSE; } @@ -196,13 +197,13 @@ bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1) return TRUE; } } - else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_DOWN) + else if (JOY_REPEAT(DPAD_ANY) == DPAD_DOWN) { - (*arg0)--; - if ((*arg0) <= 0) - (*arg0) = arg1; + (*quantity)--; + if (*quantity <= 0) + *quantity = max; - if ((*arg0) == valBefore) + if (*quantity == valBefore) { return FALSE; } @@ -212,13 +213,13 @@ bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1) return TRUE; } } - else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_RIGHT) + else if (JOY_REPEAT(DPAD_ANY) == DPAD_RIGHT) { - (*arg0) += 10; - if ((*arg0) > arg1) - (*arg0) = arg1; + *quantity += 10; + if (*quantity > max) + *quantity = max; - if ((*arg0) == valBefore) + if (*quantity == valBefore) { return FALSE; } @@ -228,13 +229,13 @@ bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1) return TRUE; } } - else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_LEFT) + else if (JOY_REPEAT(DPAD_ANY) == DPAD_LEFT) { - (*arg0) -= 10; - if ((*arg0) <= 0) - (*arg0) = 1; + *quantity -= 10; + if (*quantity <= 0) + *quantity = 1; - if ((*arg0) == valBefore) + if (*quantity == valBefore) { return FALSE; } diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c index 5f08c6294..e0f789bcb 100644 --- a/src/mystery_event_script.c +++ b/src/mystery_event_script.c @@ -19,8 +19,8 @@ extern ScrCmdFunc gMysteryEventScriptCmdTable[]; extern ScrCmdFunc gMysteryEventScriptCmdTableEnd[]; -#define LANGUAGE_MASK 0x1 -#define VERSION_MASK 0x200 +// 0x1 in FireRed, 0x2 in LeafGreen, 0x80 in Ruby, 0x100 in Sapphire +#define VERSION_MASK (1 << 9) #define mScriptBase data[0] #define mOffset data[1] @@ -29,18 +29,21 @@ extern ScrCmdFunc gMysteryEventScriptCmdTableEnd[]; EWRAM_DATA static struct ScriptContext sMysteryEventScriptContext = {0}; -static bool32 CheckCompatibility(u16 a1, u32 a2, u16 a3, u32 a4) +static bool32 CheckCompatibility(u16 unk0, u32 unk1, u16 unk2, u32 version) { - if (!(a1 & LANGUAGE_MASK)) + // 0x1 in English FRLG, 0x2 in English RS, 0x4 in German RS + if (!(unk0 & 0x1)) return FALSE; - if (!(a2 & LANGUAGE_MASK)) + // Same as above + if (!(unk1 & 0x1)) return FALSE; - if (!(a3 & 0x4)) + // 0x1 in FRLG, 0x4 in RS + if (!(unk2 & 0x4)) return FALSE; - if (!(a4 & VERSION_MASK)) + if (!(version & VERSION_MASK)) return FALSE; return TRUE; @@ -174,18 +177,18 @@ bool8 MEScrCmd_end(struct ScriptContext *ctx) bool8 MEScrCmd_checkcompat(struct ScriptContext *ctx) { - u16 v1; - u32 v2; - u16 v3; - u32 v4; + u16 unk0; + u32 unk1; + u16 unk2; + u32 version; ctx->mOffset = ScriptReadWord(ctx); - v1 = ScriptReadHalfword(ctx); - v2 = ScriptReadWord(ctx); - v3 = ScriptReadHalfword(ctx); - v4 = ScriptReadWord(ctx); + unk0 = ScriptReadHalfword(ctx); + unk1 = ScriptReadWord(ctx); + unk2 = ScriptReadHalfword(ctx); + version = ScriptReadWord(ctx); - if (CheckCompatibility(v1, v2, v3, v4) == TRUE) + if (CheckCompatibility(unk0, unk1, unk2, version) == TRUE) ctx->mValid = TRUE; else SetIncompatible(); diff --git a/src/mystery_gift_client.c b/src/mystery_gift_client.c index adf3ce8a6..567751bad 100644 --- a/src/mystery_gift_client.c +++ b/src/mystery_gift_client.c @@ -44,8 +44,7 @@ u32 MysteryGiftClient_Run(u16 * endVal) { *endVal = sClient->param; MysteryGiftClient_Free(sClient); - Free(sClient); - sClient = NULL; + FREE_AND_SET_NULL(sClient); } return result; } @@ -203,7 +202,7 @@ static u32 Client_Run(struct MysteryGiftClient * client) MysteryGiftLink_InitSend(&client->link, MG_LINKID_GAME_DATA, client->sendBuffer, sizeof(struct MysteryGiftLinkGameData)); break; case CLI_LOAD_TOSS_RESPONSE: - // param here is set by MG_STATE_LINK_ASK_TOSS or MG_STATE_LINK_ASK_TOSS_UNRECEIVED + // param here is set by MG_STATE_CLIENT_ASK_TOSS or MG_STATE_CLIENT_ASK_TOSS_UNRECEIVED MysteryGiftClient_InitSendWord(client, MG_LINKID_RESPONSE, client->param); break; case CLI_SAVE_CARD: @@ -230,7 +229,7 @@ static u32 Client_Run(struct MysteryGiftClient * client) MysteryGift_TrySaveStamp(client->recvBuffer); break; case CLI_SAVE_RAM_SCRIPT: - InitRamScript_NoObjectEvent(client->recvBuffer, 1000); + InitRamScript_NoObjectEvent(client->recvBuffer, sizeof(struct RamScriptData)); break; case CLI_RECV_EREADER_TRAINER: memcpy(&gSaveBlock2Ptr->frontier.ereaderTrainer, client->recvBuffer, sizeof(gSaveBlock2Ptr->frontier.ereaderTrainer)); diff --git a/src/mystery_gift_server.c b/src/mystery_gift_server.c index 0e0acb642..891870659 100644 --- a/src/mystery_gift_server.c +++ b/src/mystery_gift_server.c @@ -44,8 +44,7 @@ u32 MysterGiftServer_Run(u16 * endVal) { *endVal = sServer->param; MysteryGiftServer_Free(sServer); - Free(sServer); - sServer = NULL; + FREE_AND_SET_NULL(sServer); } return result; } diff --git a/src/mystery_gift_view.c b/src/mystery_gift_view.c index 3047a219e..ff34c8853 100644 --- a/src/mystery_gift_view.c +++ b/src/mystery_gift_view.c @@ -207,8 +207,7 @@ void WonderCard_Destroy(void) if (sWonderCardData != NULL) { *sWonderCardData = (struct WonderCardData){}; - Free(sWonderCardData); - sWonderCardData = NULL; + FREE_AND_SET_NULL(sWonderCardData); } } @@ -660,8 +659,7 @@ void WonderNews_Destroy(void) if (sWonderNewsData != NULL) { *sWonderNewsData = (struct WonderNewsData){}; - Free(sWonderNewsData); - sWonderNewsData = NULL; + FREE_AND_SET_NULL(sWonderNewsData); } } diff --git a/src/overworld.c b/src/overworld.c index 5fca94b68..8d4b7961d 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -318,7 +318,7 @@ static u8 MovementEventModeCB_Normal(struct LinkPlayerObjectEvent *, struct Obje static u8 MovementEventModeCB_Ignored(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8); static u8 MovementEventModeCB_Scripted(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8); -static u8 (*const gLinkPlayerMovementModes[])(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8) = +static u8 (*const sLinkPlayerMovementModes[])(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8) = { [MOVEMENT_MODE_FREE] = MovementEventModeCB_Normal, [MOVEMENT_MODE_FROZEN] = MovementEventModeCB_Ignored, @@ -330,7 +330,7 @@ static u8 FacingHandler_DpadMovement(struct LinkPlayerObjectEvent *, struct Obje static u8 FacingHandler_ForcedFacingChange(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8); // These handlers return TRUE if the movement was scripted and successful, and FALSE otherwise. -static bool8 (*const gLinkPlayerFacingHandlers[])(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8) = +static bool8 (*const sLinkPlayerFacingHandlers[])(struct LinkPlayerObjectEvent *, struct ObjectEvent *, u8) = { FacingHandler_DoNothing, FacingHandler_DpadMovement, @@ -349,7 +349,7 @@ static void MovementStatusHandler_EnterFreeMode(struct LinkPlayerObjectEvent *, static void MovementStatusHandler_TryAdvanceScript(struct LinkPlayerObjectEvent *, struct ObjectEvent *); // These handlers are run after an attempted movement. -static void (*const gMovementStatusHandler[])(struct LinkPlayerObjectEvent *, struct ObjectEvent *) = +static void (*const sMovementStatusHandler[])(struct LinkPlayerObjectEvent *, struct ObjectEvent *) = { // FALSE: MovementStatusHandler_EnterFreeMode, @@ -2482,9 +2482,9 @@ static u16 KeyInterCB_ReadButtons(u32 key) return LINK_KEY_CODE_EMPTY; } -static u16 GetDirectionForDpadKey(u16 a1) +static u16 GetDirectionForDpadKey(u16 key) { - switch (a1) + switch (key) { case LINK_KEY_CODE_DPAD_RIGHT: return FACING_RIGHT; @@ -2603,7 +2603,7 @@ static u16 KeyInterCB_Ready(u32 keyOrPlayerId) } } -static u16 KeyInterCB_SetReady(u32 a1) +static u16 KeyInterCB_SetReady(u32 key) { SetKeyInterceptCallback(KeyInterCB_Ready); return LINK_KEY_CODE_READY; @@ -3053,9 +3053,9 @@ static void SetPlayerFacingDirection(u8 linkPlayerId, u8 facing) { // This is a hack to split this code onto two separate lines, without declaring a local variable. // C++ style inline variables would be nice here. - #define TEMP gLinkPlayerMovementModes[linkPlayerObjEvent->movementMode](linkPlayerObjEvent, objEvent, facing) + #define TEMP sLinkPlayerMovementModes[linkPlayerObjEvent->movementMode](linkPlayerObjEvent, objEvent, facing) - gMovementStatusHandler[TEMP](linkPlayerObjEvent, objEvent); + sMovementStatusHandler[TEMP](linkPlayerObjEvent, objEvent); // Clean up the hack. #undef TEMP @@ -3066,7 +3066,7 @@ static void SetPlayerFacingDirection(u8 linkPlayerId, u8 facing) static u8 MovementEventModeCB_Normal(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir) { - return gLinkPlayerFacingHandlers[dir](linkPlayerObjEvent, objEvent, dir); + return sLinkPlayerFacingHandlers[dir](linkPlayerObjEvent, objEvent, dir); } static u8 MovementEventModeCB_Ignored(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir) @@ -3077,7 +3077,7 @@ static u8 MovementEventModeCB_Ignored(struct LinkPlayerObjectEvent *linkPlayerOb // Identical to MovementEventModeCB_Normal static u8 MovementEventModeCB_Scripted(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir) { - return gLinkPlayerFacingHandlers[dir](linkPlayerObjEvent, objEvent, dir); + return sLinkPlayerFacingHandlers[dir](linkPlayerObjEvent, objEvent, dir); } static bool8 FacingHandler_DoNothing(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 dir) diff --git a/src/palette.c b/src/palette.c index 9fec449bc..577257eff 100644 --- a/src/palette.c +++ b/src/palette.c @@ -60,13 +60,13 @@ static void Task_BlendPalettesGradually(u8 taskId); // unaligned word reads are issued in BlendPalette otherwise ALIGNED(4) EWRAM_DATA u16 gPlttBufferUnfaded[PLTT_BUFFER_SIZE] = {0}; ALIGNED(4) EWRAM_DATA u16 gPlttBufferFaded[PLTT_BUFFER_SIZE] = {0}; -EWRAM_DATA struct PaletteStruct sPaletteStructs[NUM_PALETTE_STRUCTS] = {0}; +static EWRAM_DATA struct PaletteStruct sPaletteStructs[NUM_PALETTE_STRUCTS] = {0}; EWRAM_DATA struct PaletteFadeControl gPaletteFade = {0}; static EWRAM_DATA u32 sFiller = 0; static EWRAM_DATA u32 sPlttBufferTransferPending = 0; EWRAM_DATA u8 gPaletteDecompressionBuffer[PLTT_DECOMP_BUFFER_SIZE] = {0}; -static const struct PaletteStructTemplate gDummyPaletteStructTemplate = { +static const struct PaletteStructTemplate sDummyPaletteStructTemplate = { .id = 0xFFFF, .state = 1 }; @@ -237,63 +237,63 @@ static void PaletteStruct_Run(u8 a1, u32 *unkFlags) } } -static void PaletteStruct_Copy(struct PaletteStruct *a1, u32 *unkFlags) +static void PaletteStruct_Copy(struct PaletteStruct *palStruct, u32 *unkFlags) { s32 srcIndex; s32 srcCount; u8 i = 0; - u16 srcOffset = a1->srcIndex * a1->template->size; + u16 srcOffset = palStruct->srcIndex * palStruct->template->size; - if (!a1->template->pst_field_8_0) + if (!palStruct->template->pst_field_8_0) { - while (i < a1->template->size) + while (i < palStruct->template->size) { - gPlttBufferUnfaded[a1->destOffset] = a1->template->src[srcOffset]; - gPlttBufferFaded[a1->destOffset] = a1->template->src[srcOffset]; + gPlttBufferUnfaded[palStruct->destOffset] = palStruct->template->src[srcOffset]; + gPlttBufferFaded[palStruct->destOffset] = palStruct->template->src[srcOffset]; i++; - a1->destOffset++; + palStruct->destOffset++; srcOffset++; } } else { - while (i < a1->template->size) + while (i < palStruct->template->size) { - gPlttBufferFaded[a1->destOffset] = a1->template->src[srcOffset]; + gPlttBufferFaded[palStruct->destOffset] = palStruct->template->src[srcOffset]; i++; - a1->destOffset++; + palStruct->destOffset++; srcOffset++; } } - a1->destOffset = a1->baseDestOffset; - a1->countdown1 = a1->template->time1; - a1->srcIndex++; + palStruct->destOffset = palStruct->baseDestOffset; + palStruct->countdown1 = palStruct->template->time1; + palStruct->srcIndex++; - srcIndex = a1->srcIndex; - srcCount = a1->template->srcCount; + srcIndex = palStruct->srcIndex; + srcCount = palStruct->template->srcCount; if (srcIndex >= srcCount) { - if (a1->countdown2) - a1->countdown2--; - a1->srcIndex = 0; + if (palStruct->countdown2) + palStruct->countdown2--; + palStruct->srcIndex = 0; } - *unkFlags |= 1 << (a1->baseDestOffset >> 4); + *unkFlags |= 1 << (palStruct->baseDestOffset >> 4); } -static void PaletteStruct_Blend(struct PaletteStruct *a1, u32 *unkFlags) +static void PaletteStruct_Blend(struct PaletteStruct *palStruct, u32 *unkFlags) { - if (gPaletteFade.active && ((1 << (a1->baseDestOffset >> 4)) & gPaletteFade_selectedPalettes)) + if (gPaletteFade.active && ((1 << (palStruct->baseDestOffset >> 4)) & gPaletteFade_selectedPalettes)) { - if (!a1->template->pst_field_8_0) + if (!palStruct->template->pst_field_8_0) { if (gPaletteFade.delayCounter != gPaletteFade_delay) { BlendPalette( - a1->baseDestOffset, - a1->template->size, + palStruct->baseDestOffset, + palStruct->template->size, gPaletteFade.y, gPaletteFade.blendColor); } @@ -302,13 +302,13 @@ static void PaletteStruct_Blend(struct PaletteStruct *a1, u32 *unkFlags) { if (!gPaletteFade.delayCounter) { - if (a1->countdown1 != a1->template->time1) + if (palStruct->countdown1 != palStruct->template->time1) { - u32 srcOffset = a1->srcIndex * a1->template->size; + u32 srcOffset = palStruct->srcIndex * palStruct->template->size; u8 i; - for (i = 0; i < a1->template->size; i++) - gPlttBufferFaded[a1->baseDestOffset + i] = a1->template->src[srcOffset + i]; + for (i = 0; i < palStruct->template->size; i++) + gPlttBufferFaded[palStruct->baseDestOffset + i] = palStruct->template->src[srcOffset + i]; } } } @@ -352,7 +352,7 @@ void PaletteStruct_ResetById(u16 id) static void PaletteStruct_Reset(u8 paletteNum) { - sPaletteStructs[paletteNum].template = &gDummyPaletteStructTemplate; + sPaletteStructs[paletteNum].template = &sDummyPaletteStructTemplate; sPaletteStructs[paletteNum].active = FALSE; sPaletteStructs[paletteNum].baseDestOffset = 0; sPaletteStructs[paletteNum].destOffset = 0; diff --git a/src/party_menu.c b/src/party_menu.c index 1137458f4..4323b4656 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -4975,7 +4975,7 @@ static void Task_TryLearnNewMoves(u8 taskId) { u16 learnMove; - if (WaitFanfare(0) && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) + if (WaitFanfare(FALSE) && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) { RemoveLevelUpStatsWindow(); learnMove = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], TRUE); @@ -5657,11 +5657,11 @@ static u8 GetBattleEntryLevelCap(void) case FACILITY_MULTI_OR_EREADER: return MAX_LEVEL; case FACILITY_UNION_ROOM: - return 30; + return UNION_ROOM_MAX_LEVEL; default: // Battle Frontier if (gSpecialVar_0x8004 == FRONTIER_LVL_50) - return 50; - return MAX_LEVEL; + return FRONTIER_MAX_LEVEL_50; + return FRONTIER_MAX_LEVEL_OPEN; } } diff --git a/src/player_pc.c b/src/player_pc.c index bf8479ce1..0ca78dea8 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -97,84 +97,84 @@ struct ItemStorageMenu u8 swapLineSpriteIds[SWAP_LINE_LENGTH]; }; -static void InitPlayerPCMenu(u8 taskId); -static void PlayerPCProcessMenuInput(u8 taskId); -static void InitItemStorageMenu(u8 taskId, u8 var); +static void InitPlayerPCMenu(u8); +static void PlayerPCProcessMenuInput(u8); +static void InitItemStorageMenu(u8, u8); static u8 GetMailboxMailCount(void); static void Mailbox_CompactMailList(void); -static void Mailbox_DrawMailboxMenu(u8 taskId); -static void Mailbox_ProcessInput(u8 taskId); -static void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId); +static void Mailbox_DrawMailboxMenu(u8); +static void Mailbox_ProcessInput(u8); +static void Mailbox_PrintWhatToDoWithPlayerMailText(u8); static void Mailbox_ReturnToPlayerPC(u8); -static void Mailbox_PrintMailOptions(u8 taskId); -static void Mailbox_MailOptionsProcessInput(u8 taskId); +static void Mailbox_PrintMailOptions(u8); +static void Mailbox_MailOptionsProcessInput(u8); -static void PlayerPC_ItemStorage(u8 taskId); -static void PlayerPC_Mailbox(u8 taskId); -static void PlayerPC_Decoration(u8 var); -static void PlayerPC_TurnOff(u8 taskId); +static void PlayerPC_ItemStorage(u8); +static void PlayerPC_Mailbox(u8); +static void PlayerPC_Decoration(u8); +static void PlayerPC_TurnOff(u8); -static void Mailbox_DoMailMoveToBag(u8 taskId); -static void Mailbox_DoMailRead(u8 taskId); -static void Mailbox_MoveToBag(u8 taskId); -static void Mailbox_Give(u8 taskId); -static void Mailbox_Cancel(u8 taskId); +static void Mailbox_DoMailMoveToBag(u8); +static void Mailbox_DoMailRead(u8); +static void Mailbox_MoveToBag(u8); +static void Mailbox_Give(u8); +static void Mailbox_Cancel(u8); -static void Mailbox_CancelMoveToBag(u8 taskId); -static void Mailbox_HandleConfirmMoveToBag(u8 taskId); -static void Mailbox_AskConfirmMoveToBag(u8 taskId); -static void Mailbox_DoGiveMailPokeMenu(u8 taskId); -static void Mailbox_NoPokemonForMail(u8 taskId); +static void Mailbox_CancelMoveToBag(u8); +static void Mailbox_HandleConfirmMoveToBag(u8); +static void Mailbox_AskConfirmMoveToBag(u8); +static void Mailbox_DoGiveMailPokeMenu(u8); +static void Mailbox_NoPokemonForMail(u8); -static void Mailbox_FadeAndReadMail(u8 taskId); +static void Mailbox_FadeAndReadMail(u8); static void Mailbox_ReturnToFieldFromReadMail(void); static void Mailbox_ReshowAfterMail(void); -static void Mailbox_HandleReturnToProcessInput(u8 taskId); +static void Mailbox_HandleReturnToProcessInput(u8); static void Mailbox_UpdateMailListAfterDeposit(void); -static void ItemStorage_Withdraw(u8 taskId); -static void ItemStorage_Deposit(u8 taskId); -static void ItemStorage_Toss(u8 taskId); -static void ItemStorage_Exit(u8 taskId); -static void ItemStorage_TossItemYes(u8 taskId); -static void ItemStorage_TossItemNo(u8 taskId); +static void ItemStorage_Withdraw(u8); +static void ItemStorage_Deposit(u8); +static void ItemStorage_Toss(u8); +static void ItemStorage_Exit(u8); +static void ItemStorage_TossItemYes(u8); +static void ItemStorage_TossItemNo(u8); static void ItemStorageMenuPrint(const u8 *); -static void ItemStorageMenuProcessInput(u8 taskId); +static void ItemStorageMenuProcessInput(u8); static void SetPlayerPCListCount(u8); -static void ItemStorage_HandleReturnToProcessInput(u8 taskId); +static void ItemStorage_HandleReturnToProcessInput(u8); -static void ItemStorage_Enter(u8 taskId, bool8 toss); -static void ItemStorage_CreateListMenu(u8 taskId); -static void ItemStorage_ProcessInput(u8 taskId); -static void Task_ItemStorage_Deposit(u8 taskId); +static void ItemStorage_Enter(u8, bool8); +static void ItemStorage_CreateListMenu(u8); +static void ItemStorage_ProcessInput(u8); +static void Task_ItemStorage_Deposit(u8); static void ItemStorage_ReshowAfterBagMenu(void); -static void ItemStorage_DoItemWithdraw(u8 taskId); -static void ItemStorage_DoItemToss(u8 taskid); -static void ItemStorage_HandleQuantityRolling(u8 taskid); -static void ItemStorage_ExitItemList(u8 taskId); -static void ItemStorage_StartItemSwap(u8 taskId); -static void ItemStorage_DoItemAction(u8 taskId); -static void ItemStorage_FinishItemSwap(u8 taskId, bool8 a); -static void ItemStorage_HandleRemoveItem(u8 taskId); -static void ItemStorage_HandleErrorMessageInput(u8 taskId); -static void ItemStorage_ReturnToListInput(u8 taskId); +static void ItemStorage_DoItemWithdraw(u8); +static void ItemStorage_DoItemToss(u8); +static void ItemStorage_HandleQuantityRolling(u8); +static void ItemStorage_ExitItemList(u8); +static void ItemStorage_StartItemSwap(u8); +static void ItemStorage_DoItemAction(u8); +static void ItemStorage_FinishItemSwap(u8, bool8); +static void ItemStorage_HandleRemoveItem(u8); +static void ItemStorage_HandleErrorMessageInput(u8); +static void ItemStorage_ReturnToListInput(u8); static const u8* ItemStorage_GetMessage(u16); -static void CopyItemName_PlayerPC(u8 *string, u16 itemId); +static void CopyItemName_PlayerPC(u8 *, u16); static void ItemStorage_Init(void); -static void ItemStorage_DrawSwapArrow(u8 y, u8, u8 speed); +static void ItemStorage_DrawSwapArrow(u8, u8, u8); static void ItemStorage_RemoveWindow(u8); static void ItemStorage_UpdateSwapLinePos(u8); -static void ItemStorage_ProcessItemSwapInput(u8 taskId); +static void ItemStorage_ProcessItemSwapInput(u8); static void ItemStorage_EraseItemIcon(void); -static void ItemStorage_DrawItemIcon(u16 itemId); -static void ItemStorage_PrintDescription(s32 id); -static void ItemStorage_EraseMainMenu(u8 taskId); -static void ItemStorage_MoveCursor(s32 id, bool8 b, struct ListMenu * thisMenu); -static void ItemStorage_PrintMenuItem(u8 windowId, u32 id, u8 yOffset); +static void ItemStorage_DrawItemIcon(u16); +static void ItemStorage_PrintDescription(s32); +static void ItemStorage_EraseMainMenu(u8); +static void ItemStorage_MoveCursor(s32, bool8, struct ListMenu *); +static void ItemStorage_PrintMenuItem(u8, u32, u8); static EWRAM_DATA const u8 *sTopMenuOptionOrder = NULL; static EWRAM_DATA u8 sTopMenuNumOptions = 0; @@ -518,7 +518,7 @@ static void InitItemStorageMenu(u8 taskId, u8 var) static void ItemStorageMenuPrint(const u8 *textPtr) { - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); AddTextPrinterParameterized(0, FONT_NORMAL, textPtr, 0, 1, 0, 0); } @@ -572,7 +572,7 @@ void CB2_PlayerPCExitBagMenu(void) static void ItemStorage_ReshowAfterBagMenu(void) { LoadMessageBoxAndBorderGfx(); - DrawDialogueFrame(0, 1); + DrawDialogueFrame(0, TRUE); InitItemStorageMenu(CreateTask(ItemStorage_HandleReturnToProcessInput, 0), 1); FadeInFromBlack(); } @@ -1241,7 +1241,7 @@ static void ItemStorage_ReturnToMenuSelect(u8 taskId) s16 *data = gTasks[taskId].data; if (!IsDma3ManagerBusyWithBgCopy()) { - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); // Select Withdraw/Toss by default depending on which was just exited if (!tInTossMenu) diff --git a/src/pokeball.c b/src/pokeball.c index 85ae5b2a8..97530b6db 100644 --- a/src/pokeball.c +++ b/src/pokeball.c @@ -429,7 +429,7 @@ static void SpriteCB_BallThrow(struct Sprite *sprite) sprite->y2 = 0; sprite->data[5] = 0; ballId = ItemIdToBallId(GetBattlerPokeballItemId(opponentBattler)); - AnimateBallOpenParticles(sprite->x, sprite->y - 5, 1, 0x1C, ballId); + AnimateBallOpenParticles(sprite->x, sprite->y - 5, 1, 28, ballId); sprite->data[0] = LaunchBallFadeMonTask(FALSE, opponentBattler, 14, ballId); sprite->sBattler = opponentBattler; sprite->data[7] = noOfShakes; @@ -743,7 +743,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite) StartSpriteAnim(sprite, 1); ballId = ItemIdToBallId(GetBattlerPokeballItemId(battlerId)); - AnimateBallOpenParticles(sprite->x, sprite->y - 5, 1, 0x1C, ballId); + AnimateBallOpenParticles(sprite->x, sprite->y - 5, 1, 28, ballId); sprite->data[0] = LaunchBallFadeMonTask(TRUE, sprite->sBattler, 14, ballId); sprite->callback = HandleBallAnimEnd; @@ -995,37 +995,50 @@ static void SpriteCB_OpponentMonSendOut(struct Sprite *sprite) #undef sBattler -static u8 AnimateBallOpenParticlesForPokeball(u8 x, u8 y, u8 kindOfStars, u8 d) +static u8 AnimateBallOpenParticlesForPokeball(u8 x, u8 y, u8 kindOfStars, u8 subpriority) { - return AnimateBallOpenParticles(x, y, kindOfStars, d, BALL_POKE); + return AnimateBallOpenParticles(x, y, kindOfStars, subpriority, BALL_POKE); } -static u8 LaunchBallFadeMonTaskForPokeball(bool8 unFadeLater, u8 battlerId, u32 arg2) +static u8 LaunchBallFadeMonTaskForPokeball(bool8 unFadeLater, u8 spritePalNum, u32 selectedPalettes) { - return LaunchBallFadeMonTask(unFadeLater, battlerId, arg2, BALL_POKE); + return LaunchBallFadeMonTask(unFadeLater, spritePalNum, selectedPalettes, BALL_POKE); } +// Sprite data for the pokemon +#define sSpecies data[7] + +// Sprite data for the pokeball +#define sMonSpriteId data[0] +#define sDelay data[1] +#define sMonPalNum data[2] +#define sFadePalsLo data[3] +#define sFadePalsHi data[4] +#define sFinalMonX data[5] +#define sFinalMonY data[6] +#define sTrigIdx data[7] + // Pokeball in Birch intro, and when receiving via trade -void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 battlerId, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 g, u32 h, u16 species) +void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 delay, u32 fadePalettes, u16 species) { u8 spriteId; - LoadCompressedSpriteSheetUsingHeap(&gBallSpriteSheets[0]); - LoadCompressedSpritePaletteUsingHeap(&gBallSpritePalettes[0]); - spriteId = CreateSprite(&gBallSpriteTemplates[0], x, y, subpriortiy); + LoadCompressedSpriteSheetUsingHeap(&gBallSpriteSheets[BALL_POKE]); + LoadCompressedSpritePaletteUsingHeap(&gBallSpritePalettes[BALL_POKE]); + spriteId = CreateSprite(&gBallSpriteTemplates[BALL_POKE], x, y, subpriortiy); - gSprites[spriteId].data[0] = monSpriteId; - gSprites[spriteId].data[5] = gSprites[monSpriteId].x; - gSprites[spriteId].data[6] = gSprites[monSpriteId].y; + gSprites[spriteId].sMonSpriteId = monSpriteId; + gSprites[spriteId].sFinalMonX = gSprites[monSpriteId].x; + gSprites[spriteId].sFinalMonY = gSprites[monSpriteId].y; gSprites[monSpriteId].x = x; gSprites[monSpriteId].y = y; - gSprites[monSpriteId].data[7] = species; + gSprites[monSpriteId].sSpecies = species; - gSprites[spriteId].data[1] = g; - gSprites[spriteId].data[2] = battlerId; - gSprites[spriteId].data[3] = h; - gSprites[spriteId].data[4] = h >> 0x10; + gSprites[spriteId].sDelay = delay; + gSprites[spriteId].sMonPalNum = monPalNum; + gSprites[spriteId].sFadePalsLo = fadePalettes; + gSprites[spriteId].sFadePalsHi = fadePalettes >> 16; gSprites[spriteId].oam.priority = oamPriority; gSprites[spriteId].callback = SpriteCB_PokeballReleaseMon; @@ -1034,92 +1047,103 @@ void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 battlerId, u8 x, u8 y, static void SpriteCB_PokeballReleaseMon(struct Sprite *sprite) { - if (sprite->data[1] == 0) + if (sprite->sDelay == 0) { - u8 r5; - u8 r7 = sprite->data[0]; - u8 battlerId = sprite->data[2]; - u32 r4 = (u16)sprite->data[3] | ((u16)sprite->data[4] << 16); + u8 subpriority; + u8 spriteId = sprite->sMonSpriteId; + u8 monPalNum = sprite->sMonPalNum; + u32 selectedPalettes = (u16)sprite->sFadePalsLo | ((u16)sprite->sFadePalsHi << 16); if (sprite->subpriority != 0) - r5 = sprite->subpriority - 1; + subpriority = sprite->subpriority - 1; else - r5 = 0; + subpriority = 0; StartSpriteAnim(sprite, 1); - AnimateBallOpenParticlesForPokeball(sprite->x, sprite->y - 5, sprite->oam.priority, r5); - sprite->data[1] = LaunchBallFadeMonTaskForPokeball(1, battlerId, r4); + AnimateBallOpenParticlesForPokeball(sprite->x, sprite->y - 5, sprite->oam.priority, subpriority); + // sDelay re-used to store task id but never read + sprite->sDelay = LaunchBallFadeMonTaskForPokeball(1, monPalNum, selectedPalettes); sprite->callback = SpriteCB_ReleasedMonFlyOut; - gSprites[r7].invisible = FALSE; - StartSpriteAffineAnim(&gSprites[r7], BATTLER_AFFINE_EMERGE); - AnimateSprite(&gSprites[r7]); - gSprites[r7].data[1] = 0x1000; - sprite->data[7] = 0; + gSprites[spriteId].invisible = FALSE; + StartSpriteAffineAnim(&gSprites[spriteId], BATTLER_AFFINE_EMERGE); + AnimateSprite(&gSprites[spriteId]); + gSprites[spriteId].data[1] = 0x1000; + sprite->sTrigIdx = 0; } else { - sprite->data[1]--; + sprite->sDelay--; } } static void SpriteCB_ReleasedMonFlyOut(struct Sprite *sprite) { - bool8 r12 = FALSE; - bool8 r6 = FALSE; - u8 monSpriteId = sprite->data[0]; - u16 var1; - u16 var2; + bool8 emergeAnimFinished = FALSE; + bool8 atFinalPosition = FALSE; + u8 monSpriteId = sprite->sMonSpriteId; + u16 x, y; if (sprite->animEnded) sprite->invisible = TRUE; + if (gSprites[monSpriteId].affineAnimEnded) { StartSpriteAffineAnim(&gSprites[monSpriteId], BATTLER_AFFINE_NORMAL); - r12 = TRUE; + emergeAnimFinished = TRUE; } - var1 = (sprite->data[5] - sprite->x) * sprite->data[7] / 128 + sprite->x; - var2 = (sprite->data[6] - sprite->y) * sprite->data[7] / 128 + sprite->y; - gSprites[monSpriteId].x = var1; - gSprites[monSpriteId].y = var2; - if (sprite->data[7] < 128) - { - s16 sine = -(gSineTable[(u8)sprite->data[7]] / 8); - sprite->data[7] += 4; + x = (sprite->sFinalMonX - sprite->x) * sprite->sTrigIdx / 128 + sprite->x; + y = (sprite->sFinalMonY - sprite->y) * sprite->sTrigIdx / 128 + sprite->y; + gSprites[monSpriteId].x = x; + gSprites[monSpriteId].y = y; + + if (sprite->sTrigIdx < 128) + { + s16 sine = -(gSineTable[(u8)sprite->sTrigIdx] / 8); + + sprite->sTrigIdx += 4; gSprites[monSpriteId].x2 = sine; gSprites[monSpriteId].y2 = sine; } else { - gSprites[monSpriteId].x = sprite->data[5]; - gSprites[monSpriteId].y = sprite->data[6]; + gSprites[monSpriteId].x = sprite->sFinalMonX; + gSprites[monSpriteId].y = sprite->sFinalMonY; gSprites[monSpriteId].x2 = 0; gSprites[monSpriteId].y2 = 0; - r6 = TRUE; + atFinalPosition = TRUE; } - if (sprite->animEnded && r12 && r6) + if (sprite->animEnded && emergeAnimFinished && atFinalPosition) { - if (gSprites[monSpriteId].data[7] == SPECIES_EGG) - DoMonFrontSpriteAnimation(&gSprites[monSpriteId], gSprites[monSpriteId].data[7], TRUE, 0); + if (gSprites[monSpriteId].sSpecies == SPECIES_EGG) + DoMonFrontSpriteAnimation(&gSprites[monSpriteId], gSprites[monSpriteId].sSpecies, TRUE, 0); else - DoMonFrontSpriteAnimation(&gSprites[monSpriteId], gSprites[monSpriteId].data[7], FALSE, 0); + DoMonFrontSpriteAnimation(&gSprites[monSpriteId], gSprites[monSpriteId].sSpecies, FALSE, 0); DestroySpriteAndFreeResources(sprite); } } -u8 CreateTradePokeballSprite(u8 a, u8 b, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 g, u32 h) +#undef sSpecies +#undef sFinalMonX +#undef sFinalMonY +#undef sTrigIdx + + +#define sTimer data[5] + +u8 CreateTradePokeballSprite(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 delay, u32 fadePalettes) { u8 spriteId; - LoadCompressedSpriteSheetUsingHeap(&gBallSpriteSheets[0]); - LoadCompressedSpritePaletteUsingHeap(&gBallSpritePalettes[0]); - spriteId = CreateSprite(&gBallSpriteTemplates[0], x, y, subPriority); - gSprites[spriteId].data[0] = a; - gSprites[spriteId].data[1] = g; - gSprites[spriteId].data[2] = b; - gSprites[spriteId].data[3] = h; - gSprites[spriteId].data[4] = h >> 16; + LoadCompressedSpriteSheetUsingHeap(&gBallSpriteSheets[BALL_POKE]); + LoadCompressedSpritePaletteUsingHeap(&gBallSpritePalettes[BALL_POKE]); + spriteId = CreateSprite(&gBallSpriteTemplates[BALL_POKE], x, y, subPriority); + gSprites[spriteId].sMonSpriteId = monSpriteId; + gSprites[spriteId].sDelay = delay; + gSprites[spriteId].sMonPalNum = monPalNum; + gSprites[spriteId].sFadePalsLo = fadePalettes; + gSprites[spriteId].sFadePalsHi = fadePalettes >> 16; gSprites[spriteId].oam.priority = oamPriority; gSprites[spriteId].callback = SpriteCB_TradePokeball; return spriteId; @@ -1127,21 +1151,22 @@ u8 CreateTradePokeballSprite(u8 a, u8 b, u8 x, u8 y, u8 oamPriority, u8 subPrior static void SpriteCB_TradePokeball(struct Sprite *sprite) { - if (sprite->data[1] == 0) + if (sprite->sDelay == 0) { - u8 r6; - u8 monSpriteId = sprite->data[0]; - u8 r8 = sprite->data[2]; - u32 r5 = (u16)sprite->data[3] | ((u16)sprite->data[4] << 16); + u8 subpriority; + u8 monSpriteId = sprite->sMonSpriteId; + u8 monPalNum = sprite->sMonPalNum; + u32 selectedPalettes = (u16)sprite->sFadePalsLo | ((u16)sprite->sFadePalsHi << 16); if (sprite->subpriority != 0) - r6 = sprite->subpriority - 1; + subpriority = sprite->subpriority - 1; else - r6 = 0; + subpriority = 0; StartSpriteAnim(sprite, 1); - AnimateBallOpenParticlesForPokeball(sprite->x, sprite->y - 5, sprite->oam.priority, r6); - sprite->data[1] = LaunchBallFadeMonTaskForPokeball(1, r8, r5); + AnimateBallOpenParticlesForPokeball(sprite->x, sprite->y - 5, sprite->oam.priority, subpriority); + // sDelay re-used to store task id but never read + sprite->sDelay = LaunchBallFadeMonTaskForPokeball(1, monPalNum, selectedPalettes); sprite->callback = SpriteCB_TradePokeballSendOff; #ifdef BUGFIX // FIX: If this is used on a sprite that has previously had an affine animation, it will not @@ -1154,7 +1179,7 @@ static void SpriteCB_TradePokeball(struct Sprite *sprite) } else { - sprite->data[1]--; + sprite->sDelay--; } } @@ -1162,15 +1187,16 @@ static void SpriteCB_TradePokeballSendOff(struct Sprite *sprite) { u8 monSpriteId; - sprite->data[5]++; - if (sprite->data[5] == 11) + sprite->sTimer++; + if (sprite->sTimer == 11) PlaySE(SE_BALL_TRADE); - monSpriteId = sprite->data[0]; + + monSpriteId = sprite->sMonSpriteId; if (gSprites[monSpriteId].affineAnimEnded) { StartSpriteAnim(sprite, 2); gSprites[monSpriteId].invisible = TRUE; - sprite->data[5] = 0; + sprite->sTimer = 0; sprite->callback = SpriteCB_TradePokeballEnd; } else @@ -1186,6 +1212,13 @@ static void SpriteCB_TradePokeballEnd(struct Sprite *sprite) sprite->callback = SpriteCallbackDummy; } +#undef sMonSpriteId +#undef sDelay +#undef sMonPalNum +#undef sFadePalsLo +#undef sFadePalsHi +#undef sTimer + static void Unref_DestroySpriteAndFreeResources(struct Sprite *sprite) { DestroySpriteAndFreeResources(sprite); diff --git a/src/pokedex.c b/src/pokedex.c index 3f2afacb6..722bc2d23 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -840,7 +840,7 @@ static const u8 sText_No000[] = _("{NO}000"); static const u8 sCaughtBall_Gfx[] = INCBIN_U8("graphics/pokedex/caught_ball.4bpp"); static const u8 sText_TenDashes[] = _("----------"); -ALIGNED(4) static const u8 gExpandedPlaceholder_PokedexDescription[] = _(""); +ALIGNED(4) static const u8 sExpandedPlaceholder_PokedexDescription[] = _(""); #include "data/pokemon/pokedex_text.h" #include "data/pokemon/pokedex_entries.h" @@ -4140,7 +4140,7 @@ static void PrintMonInfo(u32 num, u32 value, u32 owned, u32 newEntry) if (owned) description = gPokedexEntries[num].description; else - description = gExpandedPlaceholder_PokedexDescription; + description = sExpandedPlaceholder_PokedexDescription; PrintInfoScreenText(description, GetStringCenterAlignXOffset(FONT_NORMAL, description, 0xF0), 0x5F); } @@ -4430,37 +4430,37 @@ bool16 HasAllMons(void) return TRUE; } -static void ResetOtherVideoRegisters(u16 a) +static void ResetOtherVideoRegisters(u16 regBits) { - if (!(a & DISPCNT_BG0_ON)) + if (!(regBits & DISPCNT_BG0_ON)) { ClearGpuRegBits(0, DISPCNT_BG0_ON); SetGpuReg(REG_OFFSET_BG0CNT, 0); SetGpuReg(REG_OFFSET_BG0HOFS, 0); SetGpuReg(REG_OFFSET_BG0VOFS, 0); } - if (!(a & DISPCNT_BG1_ON)) + if (!(regBits & DISPCNT_BG1_ON)) { ClearGpuRegBits(0, DISPCNT_BG1_ON); SetGpuReg(REG_OFFSET_BG1CNT, 0); SetGpuReg(REG_OFFSET_BG1HOFS, 0); SetGpuReg(REG_OFFSET_BG1VOFS, 0); } - if (!(a & DISPCNT_BG2_ON)) + if (!(regBits & DISPCNT_BG2_ON)) { ClearGpuRegBits(0, DISPCNT_BG2_ON); SetGpuReg(REG_OFFSET_BG2CNT, 0); SetGpuReg(REG_OFFSET_BG2HOFS, 0); SetGpuReg(REG_OFFSET_BG2VOFS, 0); } - if (!(a & DISPCNT_BG3_ON)) + if (!(regBits & DISPCNT_BG3_ON)) { ClearGpuRegBits(0, DISPCNT_BG3_ON); SetGpuReg(REG_OFFSET_BG3CNT, 0); SetGpuReg(REG_OFFSET_BG3HOFS, 0); SetGpuReg(REG_OFFSET_BG3VOFS, 0); } - if (!(a & DISPCNT_OBJ_ON)) + if (!(regBits & DISPCNT_OBJ_ON)) { ClearGpuRegBits(0, DISPCNT_OBJ_ON); ResetSpriteData(); diff --git a/src/pokedex_area_region_map.c b/src/pokedex_area_region_map.c index 4926c019d..ff32f8eef 100644 --- a/src/pokedex_area_region_map.c +++ b/src/pokedex_area_region_map.c @@ -63,7 +63,7 @@ void FreePokedexAreaMapBgNum(void) TRY_FREE_AND_SET_NULL(sPokedexAreaMapBgNum); } -void PokedexAreaMapChangeBgY(u32 a0) +void PokedexAreaMapChangeBgY(u32 move) { - ChangeBgY(*sPokedexAreaMapBgNum, a0 * 0x100, BG_COORD_SET); + ChangeBgY(*sPokedexAreaMapBgNum, move * 0x100, BG_COORD_SET); } diff --git a/src/pokemon.c b/src/pokemon.c index 4439665ed..874db8f12 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2079,10 +2079,12 @@ static const s8 sFriendshipEventModifiers[][3] = [FRIENDSHIP_EVENT_FAINT_LARGE] = {-5, -5, -10}, }; +#define HM_MOVES_END 0xFFFF + static const u16 sHMMoves[] = { MOVE_CUT, MOVE_FLY, MOVE_SURF, MOVE_STRENGTH, MOVE_FLASH, - MOVE_ROCK_SMASH, MOVE_WATERFALL, MOVE_DIVE, 0xFFFF + MOVE_ROCK_SMASH, MOVE_WATERFALL, MOVE_DIVE, HM_MOVES_END }; static const struct SpeciesItem sAlteringCaveWildMonHeldItems[] = @@ -2450,7 +2452,7 @@ void CreateBattleTowerMon_HandleLevel(struct Pokemon *mon, struct BattleTowerPok if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50) level = GetFrontierEnemyMonLevel(gSaveBlock2Ptr->frontier.lvlMode); else if (lvl50) - level = 50; + level = FRONTIER_MAX_LEVEL_50; else level = src->level; @@ -5171,10 +5173,10 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit) return offset; } -static void BufferStatRoseMessage(s32 arg0) +static void BufferStatRoseMessage(s32 statIdx) { gBattlerTarget = gBattlerInMenuId; - StringCopy(gBattleTextBuff1, gStatNamesTable[sStatsToRaise[arg0]]); + StringCopy(gBattleTextBuff1, gStatNamesTable[sStatsToRaise[statIdx]]); if (B_X_ITEMS_BUFF >= GEN_7) { StringCopy(gBattleTextBuff2, gText_StatSharply); @@ -5634,13 +5636,13 @@ u16 GetLinkTrainerFlankId(u8 linkPlayerId) return flankId; } -s32 GetBattlerMultiplayerId(u16 a1) +s32 GetBattlerMultiplayerId(u16 id) { - s32 id; - for (id = 0; id < MAX_LINK_PLAYERS; id++) - if (gLinkPlayers[id].id == a1) + s32 multiplayerId; + for (multiplayerId = 0; multiplayerId < MAX_LINK_PLAYERS; multiplayerId++) + if (gLinkPlayers[multiplayerId].id == id) break; - return id; + return multiplayerId; } u8 GetTrainerEncounterMusicId(u16 trainerOpponentId) @@ -6338,7 +6340,7 @@ const struct CompressedSpritePalette *GetMonSpritePalStructFromOtIdPersonality(u bool32 IsHMMove2(u16 move) { int i = 0; - while (sHMMoves[i] != 0xFFFF) + while (sHMMoves[i] != HM_MOVES_END) { if (sHMMoves[i++] == move) return TRUE; @@ -6446,7 +6448,7 @@ void SetWildMonHeldItem(void) u16 rnd; u16 species; u16 chanceNoItem = 45; - u16 chanceCommon = 95; + u16 chanceNotRare = 95; u16 count = (WILD_DOUBLE_BATTLE) ? 2 : 1; u16 i; @@ -6455,7 +6457,7 @@ void SetWildMonHeldItem(void) || GetMonAbility(&gPlayerParty[0]) == ABILITY_SUPER_LUCK)) { chanceNoItem = 20; - chanceCommon = 80; + chanceNotRare = 80; } for (i = 0; i < count; i++) @@ -6471,7 +6473,7 @@ void SetWildMonHeldItem(void) if (alteringCaveId != 0) { // In active Altering Cave, use special item list - if (rnd < chanceCommon) + if (rnd < chanceNotRare) continue; SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &sAlteringCaveWildMonHeldItems[alteringCaveId].item); } @@ -6480,27 +6482,27 @@ void SetWildMonHeldItem(void) // In inactive Altering Cave, use normal items if (rnd < chanceNoItem) continue; - if (rnd < chanceCommon) - SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBaseStats[species].item1); + if (rnd < chanceNotRare) + SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBaseStats[species].itemCommon); else - SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBaseStats[species].item2); + SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBaseStats[species].itemRare); } } else { - if (gBaseStats[species].item1 == gBaseStats[species].item2 && gBaseStats[species].item1 != ITEM_NONE) + if (gBaseStats[species].itemCommon == gBaseStats[species].itemRare && gBaseStats[species].itemCommon != ITEM_NONE) { // Both held items are the same, 100% chance to hold item - SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBaseStats[species].item1); + SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBaseStats[species].itemCommon); } else { if (rnd < chanceNoItem) continue; - if (rnd < chanceCommon) - SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBaseStats[species].item1); + if (rnd < chanceNotRare) + SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBaseStats[species].itemCommon); else - SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBaseStats[species].item2); + SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBaseStats[species].itemRare); } } } diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index f6aa82391..32333ee67 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -2205,7 +2205,7 @@ static bool32 AreLinkQueuesEmpty(void) return !gRfu.recvQueue.count && !gRfu.sendQueue.count; } -static int GetNumPlayersForBonus(u8 *arg0) +static int GetNumPlayersForBonus(u8 *atJumpPeak) { int i = 0; int flags = 0; @@ -2213,7 +2213,7 @@ static int GetNumPlayersForBonus(u8 *arg0) for (; i < MAX_RFU_PLAYERS; i++) { - if (arg0[i]) + if (atJumpPeak[i]) { flags |= 1 << i; count++; @@ -3612,7 +3612,6 @@ static u32 AddMessageWindow(u32 left, u32 top, u32 width, u32 height) static void CreatePokeJumpYesNoMenu(u16 left, u16 top, u8 cursorPos) { struct WindowTemplate window; - u8 a = cursorPos; window.bg = BG_INTERFACE; window.tilemapLeft = left; @@ -3622,7 +3621,7 @@ static void CreatePokeJumpYesNoMenu(u16 left, u16 top, u8 cursorPos) window.paletteNum = 2; window.baseBlock = 0x2B; - CreateYesNoMenu(&window, 1, 0xD, a); + CreateYesNoMenu(&window, 1, 0xD, cursorPos); } // "Points" for jump score and "times" for number of jumps in a row diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 8bf12c2bd..008fae3c9 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1040,7 +1040,7 @@ static const struct BgTemplate sBgTemplates[] = }, }; -static const struct SpritePalette gWaveformSpritePalette = +static const struct SpritePalette sWaveformSpritePalette = { sWaveform_Pal, PALTAG_MISC_2 }; @@ -3844,7 +3844,7 @@ static bool8 InitPokeStorageWindows(void) static void LoadWaveformSpritePalette(void) { - LoadSpritePalette(&gWaveformSpritePalette); + LoadSpritePalette(&sWaveformSpritePalette); } static void InitPalettesAndSprites(void) @@ -5417,8 +5417,7 @@ static bool32 WaitForWallpaperGfxLoad(void) if (IsDma3ManagerBusyWithBgCopy()) return FALSE; - if (sStorage->wallpaperTiles != NULL) - FREE_AND_SET_NULL(sStorage->wallpaperTiles); + TRY_FREE_AND_SET_NULL(sStorage->wallpaperTiles); return TRUE; } @@ -8476,11 +8475,11 @@ static void MultiMove_ClearIconFromBg(u8 x, u8 y) } } -static void MultiMove_InitMove(u16 x, u16 y, u16 arg2) +static void MultiMove_InitMove(u16 x, u16 y, u16 moveSteps) { sMultiMove->bgX = x; sMultiMove->bgY = y; - sMultiMove->bgMoveSteps = arg2; + sMultiMove->bgMoveSteps = moveSteps; } static u8 MultiMove_UpdateMove(void) diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index c778d641b..044858206 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -198,62 +198,62 @@ static bool8 LoadGraphics(void); static void CB2_InitSummaryScreen(void); static void InitBGs(void); static bool8 DecompressGraphics(void); -static void CopyMonToSummaryStruct(struct Pokemon* a); -static bool8 ExtractMonDataToSummaryStruct(struct Pokemon* a); +static void CopyMonToSummaryStruct(struct Pokemon*); +static bool8 ExtractMonDataToSummaryStruct(struct Pokemon*); static void SetDefaultTilemaps(void); -static void CloseSummaryScreen(u8 taskId); -static void Task_HandleInput(u8 taskId); -static void ChangeSummaryPokemon(u8 taskId, s8 a); -static void Task_ChangeSummaryMon(u8 taskId); -static s8 AdvanceMonIndex(s8 delta); -static s8 AdvanceMultiBattleMonIndex(s8 delta); -static bool8 IsValidToViewInMulti(struct Pokemon* mon); -static void ChangePage(u8 taskId, s8 a); -static void PssScrollRight(u8 taskId); -static void PssScrollRightEnd(u8 taskId); -static void PssScrollLeft(u8 taskId); -static void PssScrollLeftEnd(u8 taskId); +static void CloseSummaryScreen(u8); +static void Task_HandleInput(u8); +static void ChangeSummaryPokemon(u8, s8); +static void Task_ChangeSummaryMon(u8); +static s8 AdvanceMonIndex(s8); +static s8 AdvanceMultiBattleMonIndex(s8); +static bool8 IsValidToViewInMulti(struct Pokemon*); +static void ChangePage(u8, s8); +static void PssScrollRight(u8); +static void PssScrollRightEnd(u8); +static void PssScrollLeft(u8); +static void PssScrollLeftEnd(u8); static void TryDrawExperienceProgressBar(void); -static void SwitchToMoveSelection(u8 taskId); -static void Task_HandleInput_MoveSelect(u8 taskId); +static void SwitchToMoveSelection(u8); +static void Task_HandleInput_MoveSelect(u8); static bool8 HasMoreThanOneMove(void); -static void ChangeSelectedMove(s16 *taskData, s8 direction, u8 *moveIndexPtr); -static void CloseMoveSelectMode(u8 taskId); -static void SwitchToMovePositionSwitchMode(u8 a); -static void Task_HandleInput_MovePositionSwitch(u8 taskId); -static void ExitMovePositionSwitchMode(u8 taskId, bool8 swapMoves); -static void SwapMonMoves(struct Pokemon *mon, u8 moveIndex1, u8 moveIndex2); -static void SwapBoxMonMoves(struct BoxPokemon *mon, u8 moveIndex1, u8 moveIndex2); -static void Task_SetHandleReplaceMoveInput(u8 taskId); -static void Task_HandleReplaceMoveInput(u8 taskId); +static void ChangeSelectedMove(s16 *, s8, u8 *); +static void CloseMoveSelectMode(u8); +static void SwitchToMovePositionSwitchMode(u8); +static void Task_HandleInput_MovePositionSwitch(u8); +static void ExitMovePositionSwitchMode(u8, bool8); +static void SwapMonMoves(struct Pokemon *, u8, u8); +static void SwapBoxMonMoves(struct BoxPokemon *, u8, u8); +static void Task_SetHandleReplaceMoveInput(u8); +static void Task_HandleReplaceMoveInput(u8); static bool8 CanReplaceMove(void); -static void ShowCantForgetHMsWindow(u8 taskId); -static void Task_HandleInputCantForgetHMsMoves(u8 taskId); +static void ShowCantForgetHMsWindow(u8); +static void Task_HandleInputCantForgetHMsMoves(u8); static void DrawPagination(void); -static void HandlePowerAccTilemap(u16 a, s16 b); -static void Task_ShowPowerAccWindow(u8 taskId); -static void HandleAppealJamTilemap(u16 a, s16 b, u16 c); -static void Task_ShowAppealJamWindow(u8 taskId); -static void HandleStatusTilemap(u16 a, s16 b); -static void Task_ShowStatusWindow(u8 taskId); -static void TilemapFiveMovesDisplay(u16 *dst, u16 palette, bool8 remove); -static void DrawPokerusCuredSymbol(struct Pokemon* mon); -static void DrawExperienceProgressBar(struct Pokemon* mon); -static void DrawContestMoveHearts(u16 move); +static void HandlePowerAccTilemap(u16, s16); +static void Task_ShowPowerAccWindow(u8); +static void HandleAppealJamTilemap(u16, s16, u16); +static void Task_ShowAppealJamWindow(u8); +static void HandleStatusTilemap(u16, s16); +static void Task_ShowStatusWindow(u8); +static void TilemapFiveMovesDisplay(u16 *, u16, bool8); +static void DrawPokerusCuredSymbol(struct Pokemon*); +static void DrawExperienceProgressBar(struct Pokemon*); +static void DrawContestMoveHearts(u16); static void LimitEggSummaryPageDisplay(void); static void ResetWindows(void); static void PrintMonInfo(void); static void PrintNotEggInfo(void); static void PrintEggInfo(void); -static void PrintGenderSymbol(struct Pokemon *mon, u16 a); +static void PrintGenderSymbol(struct Pokemon *, u16); static void PrintPageNamesAndStats(void); -static void PutPageWindowTilemaps(u8 a); -static void ClearPageWindowTilemaps(u8 a); -static void RemoveWindowByIndex(u8 a); -static void PrintPageSpecificText(u8 a); -static void CreateTextPrinterTask(u8 a); +static void PutPageWindowTilemaps(u8); +static void ClearPageWindowTilemaps(u8); +static void RemoveWindowByIndex(u8); +static void PrintPageSpecificText(u8); +static void CreateTextPrinterTask(u8); static void PrintInfoPageText(void); -static void Task_PrintInfoPage(u8 taskId); +static void Task_PrintInfoPage(u8); static void PrintMonOTName(void); static void PrintMonOTID(void); static void PrintMonAbilityName(void); @@ -261,7 +261,7 @@ static void PrintMonAbilityDescription(void); static void BufferMonTrainerMemo(void); static void PrintMonTrainerMemo(void); static void BufferNatureString(void); -static void GetMetLevelString(u8 *a); +static void GetMetLevelString(u8 *); static bool8 DoesMonOTMatchOwner(void); static bool8 DidMonComeFromGBAGames(void); static bool8 IsInGamePartnerMon(void); @@ -269,7 +269,7 @@ static void PrintEggOTName(void); static void PrintEggOTID(void); static void PrintEggState(void); static void PrintEggMemo(void); -static void Task_PrintSkillsPage(u8 taskId); +static void Task_PrintSkillsPage(u8); static void PrintHeldItemName(void); static void PrintSkillsPageText(void); static void PrintRibbonCount(void); @@ -279,18 +279,18 @@ static void BufferRightColumnStats(void); static void PrintRightColumnStats(void); static void PrintExpPointsNextLevel(void); static void PrintBattleMoves(void); -static void Task_PrintBattleMoves(u8 taskId); -static void PrintMoveNameAndPP(u8 a); +static void Task_PrintBattleMoves(u8); +static void PrintMoveNameAndPP(u8); static void PrintContestMoves(void); -static void Task_PrintContestMoves(u8 taskId); -static void PrintContestMoveDescription(u8 a); -static void PrintMoveDetails(u16 a); +static void Task_PrintContestMoves(u8); +static void PrintContestMoveDescription(u8); +static void PrintMoveDetails(u16); static void PrintNewMoveDetailsOrCancelText(void); static void AddAndFillMoveNamesWindow(void); -static void SwapMovesNamesPP(u8 moveIndex1, u8 moveIndex2); +static void SwapMovesNamesPP(u8, u8); static void PrintHMMovesCantBeForgotten(void); static void ResetSpriteIds(void); -static void SetSpriteInvisibility(u8 spriteArrayId, bool8 invisible); +static void SetSpriteInvisibility(u8, bool8); static void HidePageSpecificSprites(void); static void SetTypeIcons(void); static void CreateMoveTypeIcons(void); @@ -298,20 +298,20 @@ static void SetMonTypeIcons(void); static void SetMoveTypeIcons(void); static void SetContestMoveTypeIcons(void); static void SetNewMoveTypeIcon(void); -static void SwapMovesTypeSprites(u8 moveIndex1, u8 moveIndex2); -static u8 LoadMonGfxAndSprite(struct Pokemon *a, s16 *b); -static u8 CreateMonSprite(struct Pokemon *unused); +static void SwapMovesTypeSprites(u8, u8); +static u8 LoadMonGfxAndSprite(struct Pokemon *, s16 *); +static u8 CreateMonSprite(struct Pokemon *); static void SpriteCB_Pokemon(struct Sprite *); static void StopPokemonAnimations(void); -static void CreateMonMarkingsSprite(struct Pokemon *mon); -static void RemoveAndCreateMonMarkingsSprite(struct Pokemon *mon); -static void CreateCaughtBallSprite(struct Pokemon *mon); +static void CreateMonMarkingsSprite(struct Pokemon *); +static void RemoveAndCreateMonMarkingsSprite(struct Pokemon *); +static void CreateCaughtBallSprite(struct Pokemon *); static void CreateSetStatusSprite(void); -static void CreateMoveSelectorSprites(u8 idArrayStart); -static void SpriteCb_MoveSelector(struct Sprite *sprite); -static void DestroyMoveSelectorSprites(u8 firstArrayId); -static void SetMainMoveSelectorColor(u8 whichColor); -static void KeepMoveSelectorVisible(u8 firstSpriteId); +static void CreateMoveSelectorSprites(u8); +static void SpriteCb_MoveSelector(struct Sprite *); +static void DestroyMoveSelectorSprites(u8); +static void SetMainMoveSelectorColor(u8); +static void KeepMoveSelectorVisible(u8); static void SummaryScreen_DestroyAnimDelayTask(void); // const rom data @@ -2406,69 +2406,69 @@ u8 GetMoveSlotToReplace(void) static void DrawPagination(void) // Updates the pagination dots at the top of the summary screen { - u16 *alloced = Alloc(32); + u16 *tilemap = Alloc(8 * PSS_PAGE_COUNT); u8 i; - for (i = 0; i < 4; i++) + for (i = 0; i < PSS_PAGE_COUNT; i++) { u8 j = i * 2; if (i < sMonSummaryScreen->minPageIndex) { - alloced[j + 0] = 0x40; - alloced[j + 1] = 0x40; - alloced[j + 8] = 0x50; - alloced[j + 9] = 0x50; + tilemap[j + 0] = 0x40; + tilemap[j + 1] = 0x40; + tilemap[j + 2 * PSS_PAGE_COUNT] = 0x50; + tilemap[j + 2 * PSS_PAGE_COUNT + 1] = 0x50; } else if (i > sMonSummaryScreen->maxPageIndex) { - alloced[j + 0] = 0x4A; - alloced[j + 1] = 0x4A; - alloced[j + 8] = 0x5A; - alloced[j + 9] = 0x5A; + tilemap[j + 0] = 0x4A; + tilemap[j + 1] = 0x4A; + tilemap[j + 2 * PSS_PAGE_COUNT] = 0x5A; + tilemap[j + 2 * PSS_PAGE_COUNT + 1] = 0x5A; } else if (i < sMonSummaryScreen->currPageIndex) { - alloced[j + 0] = 0x46; - alloced[j + 1] = 0x47; - alloced[j + 8] = 0x56; - alloced[j + 9] = 0x57; + tilemap[j + 0] = 0x46; + tilemap[j + 1] = 0x47; + tilemap[j + 2 * PSS_PAGE_COUNT] = 0x56; + tilemap[j + 2 * PSS_PAGE_COUNT + 1] = 0x57; } else if (i == sMonSummaryScreen->currPageIndex) { if (i != sMonSummaryScreen->maxPageIndex) { - alloced[j + 0] = 0x41; - alloced[j + 1] = 0x42; - alloced[j + 8] = 0x51; - alloced[j + 9] = 0x52; + tilemap[j + 0] = 0x41; + tilemap[j + 1] = 0x42; + tilemap[j + 2 * PSS_PAGE_COUNT] = 0x51; + tilemap[j + 2 * PSS_PAGE_COUNT + 1] = 0x52; } else { - alloced[j + 0] = 0x4B; - alloced[j + 1] = 0x4C; - alloced[j + 8] = 0x5B; - alloced[j + 9] = 0x5C; + tilemap[j + 0] = 0x4B; + tilemap[j + 1] = 0x4C; + tilemap[j + 2 * PSS_PAGE_COUNT] = 0x5B; + tilemap[j + 2 * PSS_PAGE_COUNT + 1] = 0x5C; } } else if (i != sMonSummaryScreen->maxPageIndex) { - alloced[j + 0] = 0x43; - alloced[j + 1] = 0x44; - alloced[j + 8] = 0x53; - alloced[j + 9] = 0x54; + tilemap[j + 0] = 0x43; + tilemap[j + 1] = 0x44; + tilemap[j + 2 * PSS_PAGE_COUNT] = 0x53; + tilemap[j + 2 * PSS_PAGE_COUNT + 1] = 0x54; } else { - alloced[j + 0] = 0x48; - alloced[j + 1] = 0x49; - alloced[j + 8] = 0x58; - alloced[j + 9] = 0x59; + tilemap[j + 0] = 0x48; + tilemap[j + 1] = 0x49; + tilemap[j + 2 * PSS_PAGE_COUNT] = 0x58; + tilemap[j + 2 * PSS_PAGE_COUNT + 1] = 0x59; } } - CopyToBgTilemapBufferRect_ChangePalette(3, alloced, 11, 0, 8, 2, 16); + CopyToBgTilemapBufferRect_ChangePalette(3, tilemap, 11, 0, PSS_PAGE_COUNT * 2, 2, 16); ScheduleBgCopyTilemapToVram(3); - Free(alloced); + Free(tilemap); } static void ChangeTilemap(const struct TilemapCtrl *unkStruct, u16 *dest, u8 c, bool8 d) @@ -2531,7 +2531,7 @@ static void Task_ShowPowerAccWindow(u8 taskId) { if (data[0] < 0) { - if (sMonSummaryScreen->currPageIndex == 2) + if (sMonSummaryScreen->currPageIndex == PSS_PAGE_BATTLE_MOVES) PutWindowTilemap(PSS_LABEL_WINDOW_MOVES_POWER_ACC); } else @@ -2584,7 +2584,7 @@ static void Task_ShowAppealJamWindow(u8 taskId) { if (data[0] < 0) { - if (sMonSummaryScreen->currPageIndex == 3 && FuncIsActiveTask(PssScrollRight) == 0) + if (sMonSummaryScreen->currPageIndex == PSS_PAGE_CONTEST_MOVES && FuncIsActiveTask(PssScrollRight) == 0) PutWindowTilemap(PSS_LABEL_WINDOW_MOVES_APPEAL_JAM); DrawContestMoveHearts(data[2]); } diff --git a/src/pokenav.c b/src/pokenav.c index f9a6614a8..03f48ee36 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -37,16 +37,16 @@ struct PokenavCallbacks static u32 GetCurrentMenuCB(void); static u32 IsActiveMenuLoopTaskActive_(void); -static bool32 SetActivePokenavMenu(u32 menuId); +static bool32 SetActivePokenavMenu(u32); static bool32 AnyMonHasRibbon(void); -static void InitPokenavResources(struct PokenavResources *a0); +static void InitPokenavResources(struct PokenavResources *); static void InitKeys_(void); static void FreePokenavResources(void); static void VBlankCB_Pokenav(void); static void CB2_Pokenav(void); -static void Task_RunLoopedTask_LinkMode(u8 a0); -static void Task_RunLoopedTask(u8 taskId); -static void Task_Pokenav(u8 taskId); +static void Task_RunLoopedTask_LinkMode(u8); +static void Task_RunLoopedTask(u8); +static void Task_Pokenav(u8); static void CB2_InitPokenavForTutorial(void); const struct PokenavCallbacks PokenavMenuCallbacks[15] = @@ -557,8 +557,7 @@ void *GetSubstructPtr(u32 index) void FreePokenavSubstruct(u32 index) { - if (gPokenavResources->substructPtrs[index] != NULL) - FREE_AND_SET_NULL(gPokenavResources->substructPtrs[index]); + TRY_FREE_AND_SET_NULL(gPokenavResources->substructPtrs[index]); } u32 GetPokenavMode(void) diff --git a/src/pokenav_conditions.c b/src/pokenav_conditions.c index 94ed4e8d8..e0645bac0 100644 --- a/src/pokenav_conditions.c +++ b/src/pokenav_conditions.c @@ -332,7 +332,7 @@ u8 *CopyStringLeftAlignedToConditionData(u8 *dst, const u8 *src, s16 n) return dst; } -static u8 *CopyConditionMonNameGender(u8 *str, u16 listId, bool8 arg3) +static u8 *CopyConditionMonNameGender(u8 *str, u16 listId, bool8 skipPadding) { u16 boxId, monId, gender, species, level, lvlDigits; struct BoxPokemon *boxMon; @@ -412,7 +412,7 @@ static u8 *CopyConditionMonNameGender(u8 *str, u16 listId, bool8 arg3) str_ = ConvertIntToDecimalStringN(str_, level, STR_CONV_MODE_LEFT_ALIGN, 3); lvlDigits = str_ - txtPtr; *(str_++) = CHAR_SPACE; - if (!arg3) + if (!skipPadding) { lvlDigits = 3 - lvlDigits; while (lvlDigits-- != 0) diff --git a/src/pokenav_list.c b/src/pokenav_list.c index bdba1d2c0..350a78504 100644 --- a/src/pokenav_list.c +++ b/src/pokenav_list.c @@ -40,7 +40,7 @@ struct PokenavListWindowState { struct PokenavListSub { struct PokenavListMenuWindow listWindow; - u32 unk10; + u32 printStart; u32 printIndex; u32 itemSize; void * listPtr; @@ -59,7 +59,7 @@ struct PokenavListSub struct PokenavList { - struct PokenavListSub list; + struct PokenavListSub sub; u8 tilemapBuffer[BG_SCREEN_SIZE]; struct PokenavListWindowState windowState; s32 eraseIndex; @@ -100,12 +100,12 @@ static EWRAM_DATA u32 sMoveWindowDownIndex = 0; // Read, but pointlessly bool32 CreatePokenavList(const struct BgTemplate *bgTemplate, struct PokenavListTemplate *listTemplate, s32 tileOffset) { - struct PokenavList *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_LIST, sizeof(struct PokenavList)); - if (structPtr == NULL) + struct PokenavList *list = AllocSubstruct(POKENAV_SUBSTRUCT_LIST, sizeof(struct PokenavList)); + if (list == NULL) return FALSE; - InitPokenavListWindowState(&structPtr->windowState, listTemplate); - if (!CopyPokenavListMenuTemplate(&structPtr->list, bgTemplate, listTemplate, tileOffset)) + InitPokenavListWindowState(&list->windowState, listTemplate); + if (!CopyPokenavListMenuTemplate(&list->sub, bgTemplate, listTemplate, tileOffset)) return FALSE; CreateLoopedTask(LoopedTask_CreatePokenavList, 6); @@ -119,31 +119,31 @@ bool32 IsCreatePokenavListTaskActive(void) void DestroyPokenavList(void) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - DestroyListArrows(&structPtr->list); - RemoveWindow(structPtr->list.listWindow.windowId); + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + DestroyListArrows(&list->sub); + RemoveWindow(list->sub.listWindow.windowId); FreePokenavSubstruct(POKENAV_SUBSTRUCT_LIST); } static u32 LoopedTask_CreatePokenavList(s32 state) { - struct PokenavList *structPtr; + struct PokenavList *list; if (IsDma3ManagerBusyWithBgCopy()) return LT_PAUSE; - structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); switch (state) { case 0: - InitPokenavListBg(structPtr); + InitPokenavListBg(list); return LT_INC_AND_PAUSE; case 1: - InitPokenavListWindow(&structPtr->list.listWindow); + InitPokenavListWindow(&list->sub.listWindow); return LT_INC_AND_PAUSE; case 2: - InitListItems(&structPtr->windowState, &structPtr->list); + InitListItems(&list->windowState, &list->sub); return LT_INC_AND_PAUSE; case 3: if (IsPrintListItemsTaskActive()) @@ -156,24 +156,24 @@ static u32 LoopedTask_CreatePokenavList(s32 state) return LT_INC_AND_CONTINUE; } case 4: - CreateListArrowSprites(&structPtr->windowState, &structPtr->list); + CreateListArrowSprites(&list->windowState, &list->sub); return LT_FINISH; default: return LT_FINISH; } } -static void InitPokenavListBg(struct PokenavList *a0) +static void InitPokenavListBg(struct PokenavList *list) { - u16 tileNum = (a0->list.listWindow.fillValue << 12) | a0->list.listWindow.tileOffset; - BgDmaFill(a0->list.listWindow.bg, PIXEL_FILL(1), a0->list.listWindow.tileOffset, 1); - BgDmaFill(a0->list.listWindow.bg, PIXEL_FILL(4), a0->list.listWindow.tileOffset + 1, 1); - SetBgTilemapBuffer(a0->list.listWindow.bg, a0->tilemapBuffer); - FillBgTilemapBufferRect_Palette0(a0->list.listWindow.bg, tileNum, 0, 0, 32, 32); - ChangeBgY(a0->list.listWindow.bg, 0, BG_COORD_SET); - ChangeBgX(a0->list.listWindow.bg, 0, BG_COORD_SET); - ChangeBgY(a0->list.listWindow.bg, a0->list.listWindow.y << 11, BG_COORD_SUB); - CopyBgTilemapBufferToVram(a0->list.listWindow.bg); + u16 tileNum = (list->sub.listWindow.fillValue << 12) | list->sub.listWindow.tileOffset; + BgDmaFill(list->sub.listWindow.bg, PIXEL_FILL(1), list->sub.listWindow.tileOffset, 1); + BgDmaFill(list->sub.listWindow.bg, PIXEL_FILL(4), list->sub.listWindow.tileOffset + 1, 1); + SetBgTilemapBuffer(list->sub.listWindow.bg, list->tilemapBuffer); + FillBgTilemapBufferRect_Palette0(list->sub.listWindow.bg, tileNum, 0, 0, 32, 32); + ChangeBgY(list->sub.listWindow.bg, 0, BG_COORD_SET); + ChangeBgX(list->sub.listWindow.bg, 0, BG_COORD_SET); + ChangeBgY(list->sub.listWindow.bg, list->sub.listWindow.y << 11, BG_COORD_SUB); + CopyBgTilemapBufferToVram(list->sub.listWindow.bg); } static void InitPokenavListWindow(struct PokenavListMenuWindow *listWindow) @@ -183,16 +183,16 @@ static void InitPokenavListWindow(struct PokenavListMenuWindow *listWindow) CopyWindowToVram(listWindow->windowId, COPYWIN_MAP); } -static void InitListItems(struct PokenavListWindowState *windowState, struct PokenavListSub *a1) +static void InitListItems(struct PokenavListWindowState *windowState, struct PokenavListSub *subPtr) { s32 numToPrint = windowState->listLength - windowState->windowTopIndex; if (numToPrint > windowState->entriesOnscreen) numToPrint = windowState->entriesOnscreen; - PrintListItems(windowState->listPtr, windowState->windowTopIndex, numToPrint, windowState->listItemSize, 0, a1); + PrintListItems(windowState->listPtr, windowState->windowTopIndex, numToPrint, windowState->listItemSize, 0, subPtr); } -static void PrintListItems(void * listPtr, u32 topIndex, u32 numItems, u32 itemSize, u32 a4, struct PokenavListSub *list) +static void PrintListItems(void * listPtr, u32 topIndex, u32 numItems, u32 itemSize, u32 printStart, struct PokenavListSub *list) { if (numItems == 0) return; @@ -202,7 +202,7 @@ static void PrintListItems(void * listPtr, u32 topIndex, u32 numItems, u32 itemS list->listWindow.numPrinted = 0; list->listWindow.numToPrint = numItems; list->printIndex = topIndex; - list->unk10 = a4; + list->printStart = printStart; CreateLoopedTask(LoopedTask_PrintListItems, 5); } @@ -214,31 +214,31 @@ static bool32 IsPrintListItemsTaskActive(void) static u32 LoopedTask_PrintListItems(s32 state) { u32 row; - struct PokenavListSub *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavListSub *listSub = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); switch (state) { case 0: - row = (structPtr->listWindow.unkA + structPtr->listWindow.numPrinted + structPtr->unk10) & 0xF; - structPtr->bufferItemFunc(structPtr->listPtr, structPtr->itemTextBuffer); - if (structPtr->iconDrawFunc != NULL) - structPtr->iconDrawFunc(structPtr->listWindow.windowId, structPtr->printIndex, row); + row = (listSub->listWindow.unkA + listSub->listWindow.numPrinted + listSub->printStart) & 0xF; + listSub->bufferItemFunc(listSub->listPtr, listSub->itemTextBuffer); + if (listSub->iconDrawFunc != NULL) + listSub->iconDrawFunc(listSub->listWindow.windowId, listSub->printIndex, row); - AddTextPrinterParameterized(structPtr->listWindow.windowId, structPtr->listWindow.fontId, structPtr->itemTextBuffer, 8, (row << 4) + 1, TEXT_SKIP_DRAW, NULL); - if (++structPtr->listWindow.numPrinted >= structPtr->listWindow.numToPrint) + AddTextPrinterParameterized(listSub->listWindow.windowId, listSub->listWindow.fontId, listSub->itemTextBuffer, 8, (row << 4) + 1, TEXT_SKIP_DRAW, NULL); + if (++listSub->listWindow.numPrinted >= listSub->listWindow.numToPrint) { // Finished printing items. If icons were being drawn, draw the // window tilemap and graphics. Otherwise just do the graphics - if (structPtr->iconDrawFunc != NULL) - CopyWindowToVram(structPtr->listWindow.windowId, COPYWIN_FULL); + if (listSub->iconDrawFunc != NULL) + CopyWindowToVram(listSub->listWindow.windowId, COPYWIN_FULL); else - CopyWindowToVram(structPtr->listWindow.windowId, COPYWIN_GFX); + CopyWindowToVram(listSub->listWindow.windowId, COPYWIN_GFX); return LT_INC_AND_PAUSE; } else { - structPtr->listPtr += structPtr->itemSize; - structPtr->printIndex++; + listSub->listPtr += listSub->itemSize; + listSub->printIndex++; return LT_CONTINUE; } case 1: @@ -251,42 +251,42 @@ static u32 LoopedTask_PrintListItems(s32 state) static bool32 ShouldShowUpArrow(void) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - return (structPtr->windowState.windowTopIndex != 0); + return (list->windowState.windowTopIndex != 0); } static bool32 ShouldShowDownArrow(void) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - struct PokenavListWindowState *subPtr = &structPtr->windowState; + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavListWindowState *windowState = &list->windowState; - return (subPtr->windowTopIndex + subPtr->entriesOnscreen < subPtr->listLength); + return (windowState->windowTopIndex + windowState->entriesOnscreen < windowState->listLength); } static void MoveListWindow(s32 delta, bool32 printItems) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - struct PokenavListWindowState *subPtr = &structPtr->windowState; + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavListWindowState *windowState = &list->windowState; if (delta < 0) { - if (subPtr->windowTopIndex + delta < 0) - delta = -1 * subPtr->windowTopIndex; + if (windowState->windowTopIndex + delta < 0) + delta = -1 * windowState->windowTopIndex; if (printItems) - PrintListItems(subPtr->listPtr, subPtr->windowTopIndex + delta, delta * -1, subPtr->listItemSize, delta, &structPtr->list); + PrintListItems(windowState->listPtr, windowState->windowTopIndex + delta, delta * -1, windowState->listItemSize, delta, &list->sub); } else if (printItems) { - s32 index = sMoveWindowDownIndex = subPtr->windowTopIndex + subPtr->entriesOnscreen; - if (index + delta >= subPtr->listLength) - delta = subPtr->listLength - index; + s32 index = sMoveWindowDownIndex = windowState->windowTopIndex + windowState->entriesOnscreen; + if (index + delta >= windowState->listLength) + delta = windowState->listLength - index; - PrintListItems(subPtr->listPtr, index, delta, subPtr->listItemSize, subPtr->entriesOnscreen, &structPtr->list); + PrintListItems(windowState->listPtr, index, delta, windowState->listItemSize, windowState->entriesOnscreen, &list->sub); } - CreateMoveListWindowTask(delta, &structPtr->list); - subPtr->windowTopIndex += delta; + CreateMoveListWindowTask(delta, &list->sub); + windowState->windowTopIndex += delta; } static void CreateMoveListWindowTask(s32 delta, struct PokenavListSub *list) @@ -305,8 +305,8 @@ static u32 LoopedTask_MoveListWindow(s32 state) { s32 oldY, newY; bool32 finished; - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - struct PokenavListSub *subPtr = &structPtr->list; + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavListSub *subPtr = &list->sub; switch (state) { @@ -342,23 +342,23 @@ static u32 LoopedTask_MoveListWindow(s32 state) bool32 PokenavList_IsMoveWindowTaskActive(void) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - return IsLoopedTaskActive(structPtr->list.loopedTaskId); + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + return IsLoopedTaskActive(list->sub.loopedTaskId); } static struct PokenavListWindowState *GetPokenavListWindowState(void) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - return &structPtr->windowState; + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + return &list->windowState; } int PokenavList_MoveCursorUp(void) { - struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); + struct PokenavListWindowState *windowState = GetPokenavListWindowState(); - if (structPtr->selectedIndexOffset != 0) + if (windowState->selectedIndexOffset != 0) { - structPtr->selectedIndexOffset--; + windowState->selectedIndexOffset--; return 1; } if (ShouldShowUpArrow()) @@ -371,13 +371,13 @@ int PokenavList_MoveCursorUp(void) int PokenavList_MoveCursorDown(void) { - struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); + struct PokenavListWindowState *windowState = GetPokenavListWindowState(); - if (structPtr->windowTopIndex + structPtr->selectedIndexOffset >= structPtr->listLength - 1) + if (windowState->windowTopIndex + windowState->selectedIndexOffset >= windowState->listLength - 1) return 0; - if (structPtr->selectedIndexOffset < structPtr->entriesOnscreen - 1) + if (windowState->selectedIndexOffset < windowState->entriesOnscreen - 1) { - structPtr->selectedIndexOffset++; + windowState->selectedIndexOffset++; return 1; } if (ShouldShowDownArrow()) @@ -391,20 +391,20 @@ int PokenavList_MoveCursorDown(void) int PokenavList_PageUp(void) { s32 scroll; - struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); + struct PokenavListWindowState *windowState = GetPokenavListWindowState(); if (ShouldShowUpArrow()) { - if (structPtr->windowTopIndex >= structPtr->entriesOnscreen) - scroll = structPtr->entriesOnscreen; + if (windowState->windowTopIndex >= windowState->entriesOnscreen) + scroll = windowState->entriesOnscreen; else - scroll = structPtr->windowTopIndex; + scroll = windowState->windowTopIndex; MoveListWindow(scroll * -1, TRUE); return 2; } - else if (structPtr->selectedIndexOffset != 0) + else if (windowState->selectedIndexOffset != 0) { - structPtr->selectedIndexOffset = 0; + windowState->selectedIndexOffset = 0; return 1; } return 0; @@ -412,112 +412,112 @@ int PokenavList_PageUp(void) int PokenavList_PageDown(void) { - struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); + struct PokenavListWindowState *windowState = GetPokenavListWindowState(); if (ShouldShowDownArrow()) { - s32 windowBottomIndex = structPtr->windowTopIndex + structPtr->entriesOnscreen; - s32 scroll = structPtr->entriesOffscreen - structPtr->windowTopIndex; + s32 windowBottomIndex = windowState->windowTopIndex + windowState->entriesOnscreen; + s32 scroll = windowState->entriesOffscreen - windowState->windowTopIndex; - if (windowBottomIndex <= structPtr->entriesOffscreen) - scroll = structPtr->entriesOnscreen; + if (windowBottomIndex <= windowState->entriesOffscreen) + scroll = windowState->entriesOnscreen; MoveListWindow(scroll, TRUE); return 2; } else { s32 cursor, lastVisibleIndex; - if (structPtr->listLength >= structPtr->entriesOnscreen) + if (windowState->listLength >= windowState->entriesOnscreen) { - cursor = structPtr->selectedIndexOffset; - lastVisibleIndex = structPtr->entriesOnscreen; + cursor = windowState->selectedIndexOffset; + lastVisibleIndex = windowState->entriesOnscreen; } else { - cursor = structPtr->selectedIndexOffset; - lastVisibleIndex = structPtr->listLength; + cursor = windowState->selectedIndexOffset; + lastVisibleIndex = windowState->listLength; } lastVisibleIndex -= 1; if (cursor >= lastVisibleIndex) return 0; - structPtr->selectedIndexOffset = lastVisibleIndex; + windowState->selectedIndexOffset = lastVisibleIndex; return 1; } } u32 PokenavList_GetSelectedIndex(void) { - struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); + struct PokenavListWindowState *windowState = GetPokenavListWindowState(); - return structPtr->windowTopIndex + structPtr->selectedIndexOffset; + return windowState->windowTopIndex + windowState->selectedIndexOffset; } u32 PokenavList_GetTopIndex(void) { - struct PokenavListWindowState *structPtr = GetPokenavListWindowState(); + struct PokenavListWindowState *windowState = GetPokenavListWindowState(); - return structPtr->windowTopIndex; + return windowState->windowTopIndex; } void PokenavList_EraseListForCheckPage(void) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - structPtr->eraseIndex = 0; - structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_EraseListForCheckPage, 6); + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + list->eraseIndex = 0; + list->loopedTaskId = CreateLoopedTask(LoopedTask_EraseListForCheckPage, 6); } void PrintCheckPageInfo(s16 delta) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - structPtr->windowState.windowTopIndex += delta; - structPtr->eraseIndex = 0; - structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_PrintCheckPageInfo, 6); + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + list->windowState.windowTopIndex += delta; + list->eraseIndex = 0; + list->loopedTaskId = CreateLoopedTask(LoopedTask_PrintCheckPageInfo, 6); } void PokenavList_ReshowListFromCheckPage(void) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - structPtr->eraseIndex = 0; - structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_ReshowListFromCheckPage, 6); + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + list->eraseIndex = 0; + list->loopedTaskId = CreateLoopedTask(LoopedTask_ReshowListFromCheckPage, 6); } bool32 PokenavList_IsTaskActive(void) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - return IsLoopedTaskActive(structPtr->loopedTaskId); + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + return IsLoopedTaskActive(list->loopedTaskId); } void PokenavList_DrawCurrentItemIcon(void) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - struct PokenavListWindowState *subPtr = &structPtr->windowState; - structPtr->list.iconDrawFunc(structPtr->list.listWindow.windowId, subPtr->windowTopIndex + subPtr->selectedIndexOffset, (structPtr->list.listWindow.unkA + subPtr->selectedIndexOffset) & 0xF); - CopyWindowToVram(structPtr->list.listWindow.windowId, COPYWIN_MAP); + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavListWindowState *windowState = &list->windowState; + list->sub.iconDrawFunc(list->sub.listWindow.windowId, windowState->windowTopIndex + windowState->selectedIndexOffset, (list->sub.listWindow.unkA + windowState->selectedIndexOffset) & 0xF); + CopyWindowToVram(list->sub.listWindow.windowId, COPYWIN_MAP); } static u32 LoopedTask_EraseListForCheckPage(s32 state) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); switch (state) { case 0: - ToggleListArrows(&structPtr->list, 1); + ToggleListArrows(&list->sub, 1); // fall-through case 1: - if (structPtr->eraseIndex != structPtr->windowState.selectedIndexOffset) - EraseListEntry(&structPtr->list.listWindow, structPtr->eraseIndex, 1); + if (list->eraseIndex != list->windowState.selectedIndexOffset) + EraseListEntry(&list->sub.listWindow, list->eraseIndex, 1); - structPtr->eraseIndex++; + list->eraseIndex++; return LT_INC_AND_PAUSE; case 2: if (!IsDma3ManagerBusyWithBgCopy()) { - if (structPtr->eraseIndex != structPtr->windowState.entriesOnscreen) + if (list->eraseIndex != list->windowState.entriesOnscreen) return LT_SET_STATE(1); - if (structPtr->windowState.selectedIndexOffset != 0) - EraseListEntry(&structPtr->list.listWindow, structPtr->eraseIndex, structPtr->windowState.selectedIndexOffset); + if (list->windowState.selectedIndexOffset != 0) + EraseListEntry(&list->sub.listWindow, list->eraseIndex, list->windowState.selectedIndexOffset); return LT_INC_AND_PAUSE; } @@ -525,9 +525,9 @@ static u32 LoopedTask_EraseListForCheckPage(s32 state) case 3: if (!IsDma3ManagerBusyWithBgCopy()) { - if (structPtr->windowState.selectedIndexOffset != 0) + if (list->windowState.selectedIndexOffset != 0) { - MoveListWindow(structPtr->windowState.selectedIndexOffset, FALSE); + MoveListWindow(list->windowState.selectedIndexOffset, FALSE); return LT_INC_AND_PAUSE; } return LT_FINISH; @@ -537,7 +537,7 @@ static u32 LoopedTask_EraseListForCheckPage(s32 state) if (PokenavList_IsMoveWindowTaskActive()) return LT_PAUSE; - structPtr->windowState.selectedIndexOffset = 0; + list->windowState.selectedIndexOffset = 0; return LT_FINISH; } return LT_FINISH; @@ -545,35 +545,35 @@ static u32 LoopedTask_EraseListForCheckPage(s32 state) static u32 LoopedTask_PrintCheckPageInfo(s32 state) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); if (IsDma3ManagerBusyWithBgCopy()) return LT_PAUSE; switch (state) { case 0: - PrintCheckPageTrainerName(&structPtr->windowState, &structPtr->list); + PrintCheckPageTrainerName(&list->windowState, &list->sub); break; case 1: - PrintMatchCallFieldNames(&structPtr->list, 0); + PrintMatchCallFieldNames(&list->sub, 0); break; case 2: - PrintMatchCallFlavorText(&structPtr->windowState, &structPtr->list, CHECK_PAGE_STRATEGY); + PrintMatchCallFlavorText(&list->windowState, &list->sub, CHECK_PAGE_STRATEGY); break; case 3: - PrintMatchCallFieldNames(&structPtr->list, 1); + PrintMatchCallFieldNames(&list->sub, 1); break; case 4: - PrintMatchCallFlavorText(&structPtr->windowState, &structPtr->list, CHECK_PAGE_POKEMON); + PrintMatchCallFlavorText(&list->windowState, &list->sub, CHECK_PAGE_POKEMON); break; case 5: - PrintMatchCallFieldNames(&structPtr->list, 2); + PrintMatchCallFieldNames(&list->sub, 2); break; case 6: - PrintMatchCallFlavorText(&structPtr->windowState, &structPtr->list, CHECK_PAGE_INTRO_1); + PrintMatchCallFlavorText(&list->windowState, &list->sub, CHECK_PAGE_INTRO_1); break; case 7: - PrintMatchCallFlavorText(&structPtr->windowState, &structPtr->list, CHECK_PAGE_INTRO_2); + PrintMatchCallFlavorText(&list->windowState, &list->sub, CHECK_PAGE_INTRO_2); break; default: return LT_FINISH; @@ -583,30 +583,30 @@ static u32 LoopedTask_PrintCheckPageInfo(s32 state) static u32 LoopedTask_ReshowListFromCheckPage(s32 state) { - struct PokenavList *structPtr; + struct PokenavList *list; struct PokenavListWindowState *windowState; - struct PokenavListSub *subPtr0; + struct PokenavListSub *subPtr; s32 r5, *ptr; if (IsDma3ManagerBusyWithBgCopy()) return LT_PAUSE; - structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - windowState = &structPtr->windowState; - subPtr0 = &structPtr->list; + list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + windowState = &list->windowState; + subPtr = &list->sub; switch (state) { case 0: // Rewrite the name of the trainer whose check page was just being viewed. // This is done to erase the red background it had. - PrintMatchCallListTrainerName(windowState, subPtr0); + PrintMatchCallListTrainerName(windowState, subPtr); return LT_INC_AND_PAUSE; case 1: - ptr = &structPtr->eraseIndex; - if (++(*ptr) < structPtr->windowState.entriesOnscreen) + ptr = &list->eraseIndex; + if (++(*ptr) < list->windowState.entriesOnscreen) { - EraseListEntry(&subPtr0->listWindow, *ptr, 1); + EraseListEntry(&subPtr->listWindow, *ptr, 1); return LT_PAUSE; } @@ -617,7 +617,7 @@ static u32 LoopedTask_ReshowListFromCheckPage(s32 state) { s32 r4 = windowState->windowTopIndex; r5 = -r4; - EraseListEntry(&subPtr0->listWindow, r5, r4); + EraseListEntry(&subPtr->listWindow, r5, r4); windowState->selectedIndexOffset = r4; *ptr = r5; return LT_INC_AND_PAUSE; @@ -629,7 +629,7 @@ static u32 LoopedTask_ReshowListFromCheckPage(s32 state) { s32 r4 = windowState->windowTopIndex + windowState->entriesOnscreen - windowState->listLength; r5 = -r4; - EraseListEntry(&subPtr0->listWindow, r5, r4); + EraseListEntry(&subPtr->listWindow, r5, r4); windowState->selectedIndexOffset = r4; *ptr = r5; return LT_INC_AND_PAUSE; @@ -637,55 +637,55 @@ static u32 LoopedTask_ReshowListFromCheckPage(s32 state) } return LT_SET_STATE(4); case 2: - MoveListWindow(structPtr->eraseIndex, FALSE); + MoveListWindow(list->eraseIndex, FALSE); return LT_INC_AND_PAUSE; case 3: if (!PokenavList_IsMoveWindowTaskActive()) { - structPtr->eraseIndex = 0; + list->eraseIndex = 0; return LT_INC_AND_CONTINUE; } return LT_PAUSE; case 4: - PrintListItems(windowState->listPtr, windowState->windowTopIndex + structPtr->eraseIndex, 1, windowState->listItemSize, structPtr->eraseIndex, &structPtr->list); + PrintListItems(windowState->listPtr, windowState->windowTopIndex + list->eraseIndex, 1, windowState->listItemSize, list->eraseIndex, &list->sub); return LT_INC_AND_PAUSE; case 5: if (IsPrintListItemsTaskActive()) return LT_PAUSE; - if (++structPtr->eraseIndex >= windowState->listLength || structPtr->eraseIndex >= windowState->entriesOnscreen) + if (++list->eraseIndex >= windowState->listLength || list->eraseIndex >= windowState->entriesOnscreen) return LT_INC_AND_CONTINUE; return LT_SET_STATE(4); case 6: - ToggleListArrows(subPtr0, 0); + ToggleListArrows(subPtr, 0); return LT_FINISH; } return LT_FINISH; } -static void EraseListEntry(struct PokenavListMenuWindow *listWindow, s32 a1, s32 a2) +static void EraseListEntry(struct PokenavListMenuWindow *listWindow, s32 offset, s32 entries) { u8 *tileData = (u8*)GetWindowAttribute(listWindow->windowId, WINDOW_TILE_DATA); u32 width = listWindow->width * 64; - a1 = (listWindow->unkA + a1) & 0xF; - if (a1 + a2 <= 16) + offset = (listWindow->unkA + offset) & 0xF; + if (offset + entries <= 16) { - CpuFastFill8(PIXEL_FILL(1), tileData + a1 * width, a2 * width); + CpuFastFill8(PIXEL_FILL(1), tileData + offset * width, entries * width); CopyWindowToVram(listWindow->windowId, COPYWIN_GFX); } else { - u32 v3 = 16 - a1; - u32 v4 = a2 - v3; + u32 v3 = 16 - offset; + u32 v4 = entries - v3; - CpuFastFill8(PIXEL_FILL(1), tileData + a1 * width, v3 * width); + CpuFastFill8(PIXEL_FILL(1), tileData + offset * width, v3 * width); CpuFastFill8(PIXEL_FILL(1), tileData, v4 * width); CopyWindowToVram(listWindow->windowId, COPYWIN_GFX); } - for (a2--; a2 != -1; a1 = (a1 + 1) & 0xF, a2--) - ClearRematchPokeballIcon(listWindow->windowId, a1); + for (entries--; entries != -1; offset = (offset + 1) & 0xF, entries--) + ClearRematchPokeballIcon(listWindow->windowId, offset); CopyWindowToVram(listWindow->windowId, COPYWIN_MAP); } @@ -744,7 +744,7 @@ static void PrintMatchCallFieldNames(struct PokenavListSub *list, u32 fieldId) CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_GFX, 0, top << 1, list->listWindow.width, 2); } -static void PrintMatchCallFlavorText(struct PokenavListWindowState *a0, struct PokenavListSub *list, u32 checkPageEntry) +static void PrintMatchCallFlavorText(struct PokenavListWindowState *windowState, struct PokenavListSub *list, u32 checkPageEntry) { // lines 1, 3, and 5 are the field names printed by PrintMatchCallFieldNames static const u8 lineOffsets[CHECK_PAGE_ENTRY_COUNT] = { @@ -755,7 +755,7 @@ static void PrintMatchCallFlavorText(struct PokenavListWindowState *a0, struct P }; u32 r6 = (list->listWindow.unkA + lineOffsets[checkPageEntry]) & 0xF; - const u8 *str = GetMatchCallFlavorText(a0->windowTopIndex, checkPageEntry); + const u8 *str = GetMatchCallFlavorText(windowState->windowTopIndex, checkPageEntry); if (str != NULL) { @@ -894,8 +894,8 @@ static void ToggleListArrows(struct PokenavListSub *list, bool32 invisible) static void SpriteCB_RightArrow(struct Sprite *sprite) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - sprite->y2 = structPtr->windowState.selectedIndexOffset << 4; + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + sprite->y2 = list->windowState.selectedIndexOffset << 4; } #define sTimer data[0] @@ -940,9 +940,9 @@ static void SpriteCB_UpArrow(struct Sprite *sprite) void PokenavList_ToggleVerticalArrows(bool32 invisible) { - struct PokenavList *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); - structPtr->list.upArrow->sInvisible = invisible; - structPtr->list.downArrow->sInvisible = invisible; + struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST); + list->sub.upArrow->sInvisible = invisible; + list->sub.downArrow->sInvisible = invisible; } #undef sTimer diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c index 318ed520d..7d668c67f 100644 --- a/src/pokenav_main_menu.c +++ b/src/pokenav_main_menu.c @@ -105,7 +105,7 @@ static const u8 sHelpBarTextColors[3] = TEXT_COLOR_RED, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY }; -static const struct CompressedSpriteSheet gSpinningPokenavSpriteSheet[] = +static const struct CompressedSpriteSheet sSpinningPokenavSpriteSheet[] = { { .data = sSpinningPokenav_Gfx, @@ -114,7 +114,7 @@ static const struct CompressedSpriteSheet gSpinningPokenavSpriteSheet[] = } }; -static const struct SpritePalette gSpinningNavgearPalettes[] = +static const struct SpritePalette sSpinningNavgearPalettes[] = { { .data = sSpinningPokenav_Pal, @@ -583,10 +583,10 @@ static void InitPokenavMainMenuResources(void) u8 spriteId; struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - for (i = 0; i < ARRAY_COUNT(gSpinningPokenavSpriteSheet); i++) - LoadCompressedSpriteSheet(&gSpinningPokenavSpriteSheet[i]); + for (i = 0; i < ARRAY_COUNT(sSpinningPokenavSpriteSheet); i++) + LoadCompressedSpriteSheet(&sSpinningPokenavSpriteSheet[i]); - Pokenav_AllocAndLoadPalettes(gSpinningNavgearPalettes); + Pokenav_AllocAndLoadPalettes(sSpinningNavgearPalettes); menu->palettes = ~1 & ~(0x10000 << IndexOfSpritePaletteTag(0)); spriteId = CreateSprite(&sSpinningPokenavSpriteTemplate, 220, 12, 0); menu->spinningPokenav = &gSprites[spriteId]; diff --git a/src/pokenav_match_call_data.c b/src/pokenav_match_call_data.c index 29dd62621..2e8cc40b5 100644 --- a/src/pokenav_match_call_data.c +++ b/src/pokenav_match_call_data.c @@ -324,7 +324,7 @@ static const match_call_text_data_t sWallyTextScripts[] = { { NULL, 0xFFFF, 0xFFFF } }; -const struct MatchCallLocationOverride sWallyLocationData[] = { +static const struct MatchCallLocationOverride sWallyLocationData[] = { { FLAG_HIDE_MAUVILLE_CITY_WALLY, MAPSEC_VERDANTURF_TOWN }, { FLAG_GROUDON_AWAKENED_MAGMA_HIDEOUT, MAPSEC_NONE }, { FLAG_HIDE_VICTORY_ROAD_ENTRANCE_WALLY, MAPSEC_VICTORY_ROAD }, diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index 16ba48070..828bd525d 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -146,7 +146,7 @@ static const struct WindowTemplate sMapSecInfoWindowTemplate = #include "data/region_map/city_map_entries.h" -const struct OamData sCityZoomTextSprite_OamData = +static const struct OamData sCityZoomTextSprite_OamData = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, diff --git a/src/record_mixing.c b/src/record_mixing.c index 6efded838..4365f2cb3 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -285,7 +285,7 @@ static void ReceiveExchangePacket(u32 multiplayerId) static void PrintTextOnRecordMixing(const u8 *src) { - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); AddTextPrinterParameterized(0, FONT_NORMAL, src, 0, 1, 0, NULL); CopyWindowToVram(0, COPYWIN_FULL); } diff --git a/src/recorded_battle.c b/src/recorded_battle.c index fd2b3a06b..951572636 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -67,6 +67,8 @@ struct RecordedBattleSave u32 checksum; }; +STATIC_ASSERT(sizeof(struct RecordedBattleSave) <= SECTOR_DATA_SIZE, RecordedBattleSaveFreeSpace); + EWRAM_DATA u32 gRecordedBattleRngSeed = 0; EWRAM_DATA u32 gBattlePalaceMoveSelectionRngValue = 0; EWRAM_DATA static u8 sBattleRecords[MAX_BATTLERS_COUNT][BATTLER_RECORD_SIZE] = {0}; diff --git a/src/region_map.c b/src/region_map.c index 09e2d69bf..a4db1cb04 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -64,7 +64,7 @@ struct MultiNameFlyDest // Static RAM declarations -static EWRAM_DATA struct RegionMap *gRegionMap = NULL; +static EWRAM_DATA struct RegionMap *sRegionMap = NULL; static EWRAM_DATA struct { void (*callback)(void); @@ -516,49 +516,49 @@ void InitRegionMap(struct RegionMap *regionMap, bool8 zoomed) void InitRegionMapData(struct RegionMap *regionMap, const struct BgTemplate *template, bool8 zoomed) { - gRegionMap = regionMap; - gRegionMap->initStep = 0; - gRegionMap->zoomed = zoomed; - gRegionMap->inputCallback = zoomed == TRUE ? ProcessRegionMapInput_Zoomed : ProcessRegionMapInput_Full; + sRegionMap = regionMap; + sRegionMap->initStep = 0; + sRegionMap->zoomed = zoomed; + sRegionMap->inputCallback = zoomed == TRUE ? ProcessRegionMapInput_Zoomed : ProcessRegionMapInput_Full; if (template != NULL) { - gRegionMap->bgNum = template->bg; - gRegionMap->charBaseIdx = template->charBaseIndex; - gRegionMap->mapBaseIdx = template->mapBaseIndex; - gRegionMap->bgManaged = TRUE; + sRegionMap->bgNum = template->bg; + sRegionMap->charBaseIdx = template->charBaseIndex; + sRegionMap->mapBaseIdx = template->mapBaseIndex; + sRegionMap->bgManaged = TRUE; } else { - gRegionMap->bgNum = 2; - gRegionMap->charBaseIdx = 2; - gRegionMap->mapBaseIdx = 28; - gRegionMap->bgManaged = FALSE; + sRegionMap->bgNum = 2; + sRegionMap->charBaseIdx = 2; + sRegionMap->mapBaseIdx = 28; + sRegionMap->bgManaged = FALSE; } } void ShowRegionMapForPokedexAreaScreen(struct RegionMap *regionMap) { - gRegionMap = regionMap; + sRegionMap = regionMap; InitMapBasedOnPlayerLocation(); - gRegionMap->playerIconSpritePosX = gRegionMap->cursorPosX; - gRegionMap->playerIconSpritePosY = gRegionMap->cursorPosY; + sRegionMap->playerIconSpritePosX = sRegionMap->cursorPosX; + sRegionMap->playerIconSpritePosY = sRegionMap->cursorPosY; } bool8 LoadRegionMapGfx(void) { - switch (gRegionMap->initStep) + switch (sRegionMap->initStep) { case 0: - if (gRegionMap->bgManaged) - DecompressAndCopyTileDataToVram(gRegionMap->bgNum, sRegionMapBg_GfxLZ, 0, 0, 0); + if (sRegionMap->bgManaged) + DecompressAndCopyTileDataToVram(sRegionMap->bgNum, sRegionMapBg_GfxLZ, 0, 0, 0); else LZ77UnCompVram(sRegionMapBg_GfxLZ, (u16 *)BG_CHAR_ADDR(2)); break; case 1: - if (gRegionMap->bgManaged) + if (sRegionMap->bgManaged) { if (!FreeTempTileDataBuffersIfPossible()) - DecompressAndCopyTileDataToVram(gRegionMap->bgNum, sRegionMapBg_TilemapLZ, 0, 0, 1); + DecompressAndCopyTileDataToVram(sRegionMap->bgNum, sRegionMapBg_TilemapLZ, 0, 0, 1); } else { @@ -570,54 +570,54 @@ bool8 LoadRegionMapGfx(void) LoadPalette(sRegionMapBg_Pal, 0x70, 0x60); break; case 3: - LZ77UnCompWram(sRegionMapCursorSmallGfxLZ, gRegionMap->cursorSmallImage); + LZ77UnCompWram(sRegionMapCursorSmallGfxLZ, sRegionMap->cursorSmallImage); break; case 4: - LZ77UnCompWram(sRegionMapCursorLargeGfxLZ, gRegionMap->cursorLargeImage); + LZ77UnCompWram(sRegionMapCursorLargeGfxLZ, sRegionMap->cursorLargeImage); break; case 5: InitMapBasedOnPlayerLocation(); - gRegionMap->playerIconSpritePosX = gRegionMap->cursorPosX; - gRegionMap->playerIconSpritePosY = gRegionMap->cursorPosY; - gRegionMap->mapSecId = CorrectSpecialMapSecId_Internal(gRegionMap->mapSecId); - gRegionMap->mapSecType = GetMapsecType(gRegionMap->mapSecId); - GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, MAP_NAME_LENGTH); + sRegionMap->playerIconSpritePosX = sRegionMap->cursorPosX; + sRegionMap->playerIconSpritePosY = sRegionMap->cursorPosY; + sRegionMap->mapSecId = CorrectSpecialMapSecId_Internal(sRegionMap->mapSecId); + sRegionMap->mapSecType = GetMapsecType(sRegionMap->mapSecId); + GetMapName(sRegionMap->mapSecName, sRegionMap->mapSecId, MAP_NAME_LENGTH); break; case 6: - if (gRegionMap->zoomed == FALSE) + if (sRegionMap->zoomed == FALSE) { CalcZoomScrollParams(0, 0, 0, 0, 0x100, 0x100, 0); } else { - gRegionMap->scrollX = gRegionMap->cursorPosX * 8 - 0x34; - gRegionMap->scrollY = gRegionMap->cursorPosY * 8 - 0x44; - gRegionMap->zoomedCursorPosX = gRegionMap->cursorPosX; - gRegionMap->zoomedCursorPosY = gRegionMap->cursorPosY; - CalcZoomScrollParams(gRegionMap->scrollX, gRegionMap->scrollY, 0x38, 0x48, 0x80, 0x80, 0); + sRegionMap->scrollX = sRegionMap->cursorPosX * 8 - 0x34; + sRegionMap->scrollY = sRegionMap->cursorPosY * 8 - 0x44; + sRegionMap->zoomedCursorPosX = sRegionMap->cursorPosX; + sRegionMap->zoomedCursorPosY = sRegionMap->cursorPosY; + CalcZoomScrollParams(sRegionMap->scrollX, sRegionMap->scrollY, 0x38, 0x48, 0x80, 0x80, 0); } break; case 7: GetPositionOfCursorWithinMapSec(); UpdateRegionMapVideoRegs(); - gRegionMap->cursorSprite = NULL; - gRegionMap->playerIconSprite = NULL; - gRegionMap->cursorMovementFrameCounter = 0; - gRegionMap->blinkPlayerIcon = FALSE; - if (gRegionMap->bgManaged) + sRegionMap->cursorSprite = NULL; + sRegionMap->playerIconSprite = NULL; + sRegionMap->cursorMovementFrameCounter = 0; + sRegionMap->blinkPlayerIcon = FALSE; + if (sRegionMap->bgManaged) { - SetBgAttribute(gRegionMap->bgNum, BG_ATTR_SCREENSIZE, 2); - SetBgAttribute(gRegionMap->bgNum, BG_ATTR_CHARBASEINDEX, gRegionMap->charBaseIdx); - SetBgAttribute(gRegionMap->bgNum, BG_ATTR_MAPBASEINDEX, gRegionMap->mapBaseIdx); - SetBgAttribute(gRegionMap->bgNum, BG_ATTR_WRAPAROUND, 1); - SetBgAttribute(gRegionMap->bgNum, BG_ATTR_PALETTEMODE, 1); + SetBgAttribute(sRegionMap->bgNum, BG_ATTR_SCREENSIZE, 2); + SetBgAttribute(sRegionMap->bgNum, BG_ATTR_CHARBASEINDEX, sRegionMap->charBaseIdx); + SetBgAttribute(sRegionMap->bgNum, BG_ATTR_MAPBASEINDEX, sRegionMap->mapBaseIdx); + SetBgAttribute(sRegionMap->bgNum, BG_ATTR_WRAPAROUND, 1); + SetBgAttribute(sRegionMap->bgNum, BG_ATTR_PALETTEMODE, 1); } - gRegionMap->initStep++; + sRegionMap->initStep++; return FALSE; default: return FALSE; } - gRegionMap->initStep++; + sRegionMap->initStep++; return TRUE; } @@ -629,23 +629,23 @@ void BlendRegionMap(u16 color, u32 coeff) void FreeRegionMapIconResources(void) { - if (gRegionMap->cursorSprite != NULL) + if (sRegionMap->cursorSprite != NULL) { - DestroySprite(gRegionMap->cursorSprite); - FreeSpriteTilesByTag(gRegionMap->cursorTileTag); - FreeSpritePaletteByTag(gRegionMap->cursorPaletteTag); + DestroySprite(sRegionMap->cursorSprite); + FreeSpriteTilesByTag(sRegionMap->cursorTileTag); + FreeSpritePaletteByTag(sRegionMap->cursorPaletteTag); } - if (gRegionMap->playerIconSprite != NULL) + if (sRegionMap->playerIconSprite != NULL) { - DestroySprite(gRegionMap->playerIconSprite); - FreeSpriteTilesByTag(gRegionMap->playerIconTileTag); - FreeSpritePaletteByTag(gRegionMap->playerIconPaletteTag); + DestroySprite(sRegionMap->playerIconSprite); + FreeSpriteTilesByTag(sRegionMap->playerIconTileTag); + FreeSpritePaletteByTag(sRegionMap->playerIconPaletteTag); } } u8 DoRegionMapInputCallback(void) { - return gRegionMap->inputCallback(); + return sRegionMap->inputCallback(); } static u8 ProcessRegionMapInput_Full(void) @@ -653,26 +653,26 @@ static u8 ProcessRegionMapInput_Full(void) u8 input; input = MAP_INPUT_NONE; - gRegionMap->cursorDeltaX = 0; - gRegionMap->cursorDeltaY = 0; - if (JOY_HELD(DPAD_UP) && gRegionMap->cursorPosY > MAPCURSOR_Y_MIN) + sRegionMap->cursorDeltaX = 0; + sRegionMap->cursorDeltaY = 0; + if (JOY_HELD(DPAD_UP) && sRegionMap->cursorPosY > MAPCURSOR_Y_MIN) { - gRegionMap->cursorDeltaY = -1; + sRegionMap->cursorDeltaY = -1; input = MAP_INPUT_MOVE_START; } - if (JOY_HELD(DPAD_DOWN) && gRegionMap->cursorPosY < MAPCURSOR_Y_MAX) + if (JOY_HELD(DPAD_DOWN) && sRegionMap->cursorPosY < MAPCURSOR_Y_MAX) { - gRegionMap->cursorDeltaY = +1; + sRegionMap->cursorDeltaY = +1; input = MAP_INPUT_MOVE_START; } - if (JOY_HELD(DPAD_LEFT) && gRegionMap->cursorPosX > MAPCURSOR_X_MIN) + if (JOY_HELD(DPAD_LEFT) && sRegionMap->cursorPosX > MAPCURSOR_X_MIN) { - gRegionMap->cursorDeltaX = -1; + sRegionMap->cursorDeltaX = -1; input = MAP_INPUT_MOVE_START; } - if (JOY_HELD(DPAD_RIGHT) && gRegionMap->cursorPosX < MAPCURSOR_X_MAX) + if (JOY_HELD(DPAD_RIGHT) && sRegionMap->cursorPosX < MAPCURSOR_X_MAX) { - gRegionMap->cursorDeltaX = +1; + sRegionMap->cursorDeltaX = +1; input = MAP_INPUT_MOVE_START; } if (JOY_NEW(A_BUTTON)) @@ -685,8 +685,8 @@ static u8 ProcessRegionMapInput_Full(void) } if (input == MAP_INPUT_MOVE_START) { - gRegionMap->cursorMovementFrameCounter = 4; - gRegionMap->inputCallback = MoveRegionMapCursor_Full; + sRegionMap->cursorMovementFrameCounter = 4; + sRegionMap->inputCallback = MoveRegionMapCursor_Full; } return input; } @@ -695,35 +695,35 @@ static u8 MoveRegionMapCursor_Full(void) { u16 mapSecId; - if (gRegionMap->cursorMovementFrameCounter != 0) + if (sRegionMap->cursorMovementFrameCounter != 0) return MAP_INPUT_MOVE_CONT; - if (gRegionMap->cursorDeltaX > 0) + if (sRegionMap->cursorDeltaX > 0) { - gRegionMap->cursorPosX++; + sRegionMap->cursorPosX++; } - if (gRegionMap->cursorDeltaX < 0) + if (sRegionMap->cursorDeltaX < 0) { - gRegionMap->cursorPosX--; + sRegionMap->cursorPosX--; } - if (gRegionMap->cursorDeltaY > 0) + if (sRegionMap->cursorDeltaY > 0) { - gRegionMap->cursorPosY++; + sRegionMap->cursorPosY++; } - if (gRegionMap->cursorDeltaY < 0) + if (sRegionMap->cursorDeltaY < 0) { - gRegionMap->cursorPosY--; + sRegionMap->cursorPosY--; } - mapSecId = GetMapSecIdAt(gRegionMap->cursorPosX, gRegionMap->cursorPosY); - gRegionMap->mapSecType = GetMapsecType(mapSecId); - if (mapSecId != gRegionMap->mapSecId) + mapSecId = GetMapSecIdAt(sRegionMap->cursorPosX, sRegionMap->cursorPosY); + sRegionMap->mapSecType = GetMapsecType(mapSecId); + if (mapSecId != sRegionMap->mapSecId) { - gRegionMap->mapSecId = mapSecId; - GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, MAP_NAME_LENGTH); + sRegionMap->mapSecId = mapSecId; + GetMapName(sRegionMap->mapSecName, sRegionMap->mapSecId, MAP_NAME_LENGTH); } GetPositionOfCursorWithinMapSec(); - gRegionMap->inputCallback = ProcessRegionMapInput_Full; + sRegionMap->inputCallback = ProcessRegionMapInput_Full; return MAP_INPUT_MOVE_END; } @@ -732,26 +732,26 @@ static u8 ProcessRegionMapInput_Zoomed(void) u8 input; input = MAP_INPUT_NONE; - gRegionMap->zoomedCursorDeltaX = 0; - gRegionMap->zoomedCursorDeltaY = 0; - if (JOY_HELD(DPAD_UP) && gRegionMap->scrollY > -0x34) + sRegionMap->zoomedCursorDeltaX = 0; + sRegionMap->zoomedCursorDeltaY = 0; + if (JOY_HELD(DPAD_UP) && sRegionMap->scrollY > -0x34) { - gRegionMap->zoomedCursorDeltaY = -1; + sRegionMap->zoomedCursorDeltaY = -1; input = MAP_INPUT_MOVE_START; } - if (JOY_HELD(DPAD_DOWN) && gRegionMap->scrollY < 0x3c) + if (JOY_HELD(DPAD_DOWN) && sRegionMap->scrollY < 0x3c) { - gRegionMap->zoomedCursorDeltaY = +1; + sRegionMap->zoomedCursorDeltaY = +1; input = MAP_INPUT_MOVE_START; } - if (JOY_HELD(DPAD_LEFT) && gRegionMap->scrollX > -0x2c) + if (JOY_HELD(DPAD_LEFT) && sRegionMap->scrollX > -0x2c) { - gRegionMap->zoomedCursorDeltaX = -1; + sRegionMap->zoomedCursorDeltaX = -1; input = MAP_INPUT_MOVE_START; } - if (JOY_HELD(DPAD_RIGHT) && gRegionMap->scrollX < 0xac) + if (JOY_HELD(DPAD_RIGHT) && sRegionMap->scrollX < 0xac) { - gRegionMap->zoomedCursorDeltaX = +1; + sRegionMap->zoomedCursorDeltaX = +1; input = MAP_INPUT_MOVE_START; } if (JOY_NEW(A_BUTTON)) @@ -764,8 +764,8 @@ static u8 ProcessRegionMapInput_Zoomed(void) } if (input == MAP_INPUT_MOVE_START) { - gRegionMap->inputCallback = MoveRegionMapCursor_Zoomed; - gRegionMap->zoomedCursorMovementFrameCounter = 0; + sRegionMap->inputCallback = MoveRegionMapCursor_Zoomed; + sRegionMap->zoomedCursorMovementFrameCounter = 0; } return input; } @@ -776,29 +776,29 @@ static u8 MoveRegionMapCursor_Zoomed(void) u16 y; u16 mapSecId; - gRegionMap->scrollY += gRegionMap->zoomedCursorDeltaY; - gRegionMap->scrollX += gRegionMap->zoomedCursorDeltaX; - RegionMap_SetBG2XAndBG2Y(gRegionMap->scrollX, gRegionMap->scrollY); - gRegionMap->zoomedCursorMovementFrameCounter++; - if (gRegionMap->zoomedCursorMovementFrameCounter == 8) + sRegionMap->scrollY += sRegionMap->zoomedCursorDeltaY; + sRegionMap->scrollX += sRegionMap->zoomedCursorDeltaX; + RegionMap_SetBG2XAndBG2Y(sRegionMap->scrollX, sRegionMap->scrollY); + sRegionMap->zoomedCursorMovementFrameCounter++; + if (sRegionMap->zoomedCursorMovementFrameCounter == 8) { - x = (gRegionMap->scrollX + 0x2c) / 8 + 1; - y = (gRegionMap->scrollY + 0x34) / 8 + 2; - if (x != gRegionMap->zoomedCursorPosX || y != gRegionMap->zoomedCursorPosY) + x = (sRegionMap->scrollX + 0x2c) / 8 + 1; + y = (sRegionMap->scrollY + 0x34) / 8 + 2; + if (x != sRegionMap->zoomedCursorPosX || y != sRegionMap->zoomedCursorPosY) { - gRegionMap->zoomedCursorPosX = x; - gRegionMap->zoomedCursorPosY = y; + sRegionMap->zoomedCursorPosX = x; + sRegionMap->zoomedCursorPosY = y; mapSecId = GetMapSecIdAt(x, y); - gRegionMap->mapSecType = GetMapsecType(mapSecId); - if (mapSecId != gRegionMap->mapSecId) + sRegionMap->mapSecType = GetMapsecType(mapSecId); + if (mapSecId != sRegionMap->mapSecId) { - gRegionMap->mapSecId = mapSecId; - GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, MAP_NAME_LENGTH); + sRegionMap->mapSecId = mapSecId; + GetMapName(sRegionMap->mapSecName, sRegionMap->mapSecId, MAP_NAME_LENGTH); } GetPositionOfCursorWithinMapSec(); } - gRegionMap->zoomedCursorMovementFrameCounter = 0; - gRegionMap->inputCallback = ProcessRegionMapInput_Zoomed; + sRegionMap->zoomedCursorMovementFrameCounter = 0; + sRegionMap->inputCallback = ProcessRegionMapInput_Zoomed; return MAP_INPUT_MOVE_END; } return MAP_INPUT_MOVE_CONT; @@ -806,35 +806,35 @@ static u8 MoveRegionMapCursor_Zoomed(void) void SetRegionMapDataForZoom(void) { - if (gRegionMap->zoomed == FALSE) + if (sRegionMap->zoomed == FALSE) { - gRegionMap->scrollY = 0; - gRegionMap->scrollX = 0; - gRegionMap->unk_040 = 0; - gRegionMap->unk_03c = 0; - gRegionMap->unk_060 = gRegionMap->cursorPosX * 8 - 0x34; - gRegionMap->unk_062 = gRegionMap->cursorPosY * 8 - 0x44; - gRegionMap->unk_044 = (gRegionMap->unk_060 << 8) / 16; - gRegionMap->unk_048 = (gRegionMap->unk_062 << 8) / 16; - gRegionMap->zoomedCursorPosX = gRegionMap->cursorPosX; - gRegionMap->zoomedCursorPosY = gRegionMap->cursorPosY; - gRegionMap->unk_04c = 0x10000; - gRegionMap->unk_050 = -0x800; + sRegionMap->scrollY = 0; + sRegionMap->scrollX = 0; + sRegionMap->unk_040 = 0; + sRegionMap->unk_03c = 0; + sRegionMap->unk_060 = sRegionMap->cursorPosX * 8 - 0x34; + sRegionMap->unk_062 = sRegionMap->cursorPosY * 8 - 0x44; + sRegionMap->unk_044 = (sRegionMap->unk_060 << 8) / 16; + sRegionMap->unk_048 = (sRegionMap->unk_062 << 8) / 16; + sRegionMap->zoomedCursorPosX = sRegionMap->cursorPosX; + sRegionMap->zoomedCursorPosY = sRegionMap->cursorPosY; + sRegionMap->unk_04c = 0x10000; + sRegionMap->unk_050 = -0x800; } else { - gRegionMap->unk_03c = gRegionMap->scrollX * 0x100; - gRegionMap->unk_040 = gRegionMap->scrollY * 0x100; - gRegionMap->unk_060 = 0; - gRegionMap->unk_062 = 0; - gRegionMap->unk_044 = -(gRegionMap->unk_03c / 16); - gRegionMap->unk_048 = -(gRegionMap->unk_040 / 16); - gRegionMap->cursorPosX = gRegionMap->zoomedCursorPosX; - gRegionMap->cursorPosY = gRegionMap->zoomedCursorPosY; - gRegionMap->unk_04c = 0x8000; - gRegionMap->unk_050 = 0x800; + sRegionMap->unk_03c = sRegionMap->scrollX * 0x100; + sRegionMap->unk_040 = sRegionMap->scrollY * 0x100; + sRegionMap->unk_060 = 0; + sRegionMap->unk_062 = 0; + sRegionMap->unk_044 = -(sRegionMap->unk_03c / 16); + sRegionMap->unk_048 = -(sRegionMap->unk_040 / 16); + sRegionMap->cursorPosX = sRegionMap->zoomedCursorPosX; + sRegionMap->cursorPosY = sRegionMap->zoomedCursorPosY; + sRegionMap->unk_04c = 0x8000; + sRegionMap->unk_050 = 0x800; } - gRegionMap->unk_06e = 0; + sRegionMap->unk_06e = 0; FreeRegionMapCursorSprite(); HideRegionMapPlayerIcon(); } @@ -843,60 +843,60 @@ bool8 UpdateRegionMapZoom(void) { bool8 retVal; - if (gRegionMap->unk_06e >= 16) + if (sRegionMap->unk_06e >= 16) { return FALSE; } - gRegionMap->unk_06e++; - if (gRegionMap->unk_06e == 16) + sRegionMap->unk_06e++; + if (sRegionMap->unk_06e == 16) { - gRegionMap->unk_044 = 0; - gRegionMap->unk_048 = 0; - gRegionMap->scrollX = gRegionMap->unk_060; - gRegionMap->scrollY = gRegionMap->unk_062; - gRegionMap->unk_04c = (gRegionMap->zoomed == FALSE) ? (128 << 8) : (256 << 8); - gRegionMap->zoomed = !gRegionMap->zoomed; - gRegionMap->inputCallback = (gRegionMap->zoomed == FALSE) ? ProcessRegionMapInput_Full : ProcessRegionMapInput_Zoomed; - CreateRegionMapCursor(gRegionMap->cursorTileTag, gRegionMap->cursorPaletteTag); + sRegionMap->unk_044 = 0; + sRegionMap->unk_048 = 0; + sRegionMap->scrollX = sRegionMap->unk_060; + sRegionMap->scrollY = sRegionMap->unk_062; + sRegionMap->unk_04c = (sRegionMap->zoomed == FALSE) ? (128 << 8) : (256 << 8); + sRegionMap->zoomed = !sRegionMap->zoomed; + sRegionMap->inputCallback = (sRegionMap->zoomed == FALSE) ? ProcessRegionMapInput_Full : ProcessRegionMapInput_Zoomed; + CreateRegionMapCursor(sRegionMap->cursorTileTag, sRegionMap->cursorPaletteTag); UnhideRegionMapPlayerIcon(); retVal = FALSE; } else { - gRegionMap->unk_03c += gRegionMap->unk_044; - gRegionMap->unk_040 += gRegionMap->unk_048; - gRegionMap->scrollX = gRegionMap->unk_03c >> 8; - gRegionMap->scrollY = gRegionMap->unk_040 >> 8; - gRegionMap->unk_04c += gRegionMap->unk_050; - if ((gRegionMap->unk_044 < 0 && gRegionMap->scrollX < gRegionMap->unk_060) || (gRegionMap->unk_044 > 0 && gRegionMap->scrollX > gRegionMap->unk_060)) + sRegionMap->unk_03c += sRegionMap->unk_044; + sRegionMap->unk_040 += sRegionMap->unk_048; + sRegionMap->scrollX = sRegionMap->unk_03c >> 8; + sRegionMap->scrollY = sRegionMap->unk_040 >> 8; + sRegionMap->unk_04c += sRegionMap->unk_050; + if ((sRegionMap->unk_044 < 0 && sRegionMap->scrollX < sRegionMap->unk_060) || (sRegionMap->unk_044 > 0 && sRegionMap->scrollX > sRegionMap->unk_060)) { - gRegionMap->scrollX = gRegionMap->unk_060; - gRegionMap->unk_044 = 0; + sRegionMap->scrollX = sRegionMap->unk_060; + sRegionMap->unk_044 = 0; } - if ((gRegionMap->unk_048 < 0 && gRegionMap->scrollY < gRegionMap->unk_062) || (gRegionMap->unk_048 > 0 && gRegionMap->scrollY > gRegionMap->unk_062)) + if ((sRegionMap->unk_048 < 0 && sRegionMap->scrollY < sRegionMap->unk_062) || (sRegionMap->unk_048 > 0 && sRegionMap->scrollY > sRegionMap->unk_062)) { - gRegionMap->scrollY = gRegionMap->unk_062; - gRegionMap->unk_048 = 0; + sRegionMap->scrollY = sRegionMap->unk_062; + sRegionMap->unk_048 = 0; } - if (gRegionMap->zoomed == FALSE) + if (sRegionMap->zoomed == FALSE) { - if (gRegionMap->unk_04c < (128 << 8)) + if (sRegionMap->unk_04c < (128 << 8)) { - gRegionMap->unk_04c = (128 << 8); - gRegionMap->unk_050 = 0; + sRegionMap->unk_04c = (128 << 8); + sRegionMap->unk_050 = 0; } } else { - if (gRegionMap->unk_04c > (256 << 8)) + if (sRegionMap->unk_04c > (256 << 8)) { - gRegionMap->unk_04c = (256 << 8); - gRegionMap->unk_050 = 0; + sRegionMap->unk_04c = (256 << 8); + sRegionMap->unk_050 = 0; } } retVal = TRUE; } - CalcZoomScrollParams(gRegionMap->scrollX, gRegionMap->scrollY, 0x38, 0x48, gRegionMap->unk_04c >> 8, gRegionMap->unk_04c >> 8, 0); + CalcZoomScrollParams(sRegionMap->scrollX, sRegionMap->scrollY, 0x38, 0x48, sRegionMap->unk_04c >> 8, sRegionMap->unk_04c >> 8, 0); return retVal; } @@ -907,42 +907,42 @@ static void CalcZoomScrollParams(s16 scrollX, s16 scrollY, s16 c, s16 d, u16 e, s32 var3; s32 var4; - gRegionMap->bg2pa = e * gSineTable[rotation + 64] >> 8; - gRegionMap->bg2pc = e * -gSineTable[rotation] >> 8; - gRegionMap->bg2pb = f * gSineTable[rotation] >> 8; - gRegionMap->bg2pd = f * gSineTable[rotation + 64] >> 8; + sRegionMap->bg2pa = e * gSineTable[rotation + 64] >> 8; + sRegionMap->bg2pc = e * -gSineTable[rotation] >> 8; + sRegionMap->bg2pb = f * gSineTable[rotation] >> 8; + sRegionMap->bg2pd = f * gSineTable[rotation + 64] >> 8; var1 = (scrollX << 8) + (c << 8); - var2 = d * gRegionMap->bg2pb + gRegionMap->bg2pa * c; - gRegionMap->bg2x = var1 - var2; + var2 = d * sRegionMap->bg2pb + sRegionMap->bg2pa * c; + sRegionMap->bg2x = var1 - var2; var3 = (scrollY << 8) + (d << 8); - var4 = gRegionMap->bg2pd * d + gRegionMap->bg2pc * c; - gRegionMap->bg2y = var3 - var4; + var4 = sRegionMap->bg2pd * d + sRegionMap->bg2pc * c; + sRegionMap->bg2y = var3 - var4; - gRegionMap->needUpdateVideoRegs = TRUE; + sRegionMap->needUpdateVideoRegs = TRUE; } static void RegionMap_SetBG2XAndBG2Y(s16 x, s16 y) { - gRegionMap->bg2x = (x << 8) + 0x1c00; - gRegionMap->bg2y = (y << 8) + 0x2400; - gRegionMap->needUpdateVideoRegs = TRUE; + sRegionMap->bg2x = (x << 8) + 0x1c00; + sRegionMap->bg2y = (y << 8) + 0x2400; + sRegionMap->needUpdateVideoRegs = TRUE; } void UpdateRegionMapVideoRegs(void) { - if (gRegionMap->needUpdateVideoRegs) + if (sRegionMap->needUpdateVideoRegs) { - SetGpuReg(REG_OFFSET_BG2PA, gRegionMap->bg2pa); - SetGpuReg(REG_OFFSET_BG2PB, gRegionMap->bg2pb); - SetGpuReg(REG_OFFSET_BG2PC, gRegionMap->bg2pc); - SetGpuReg(REG_OFFSET_BG2PD, gRegionMap->bg2pd); - SetGpuReg(REG_OFFSET_BG2X_L, gRegionMap->bg2x); - SetGpuReg(REG_OFFSET_BG2X_H, gRegionMap->bg2x >> 16); - SetGpuReg(REG_OFFSET_BG2Y_L, gRegionMap->bg2y); - SetGpuReg(REG_OFFSET_BG2Y_H, gRegionMap->bg2y >> 16); - gRegionMap->needUpdateVideoRegs = FALSE; + SetGpuReg(REG_OFFSET_BG2PA, sRegionMap->bg2pa); + SetGpuReg(REG_OFFSET_BG2PB, sRegionMap->bg2pb); + SetGpuReg(REG_OFFSET_BG2PC, sRegionMap->bg2pc); + SetGpuReg(REG_OFFSET_BG2PD, sRegionMap->bg2pd); + SetGpuReg(REG_OFFSET_BG2X_L, sRegionMap->bg2x); + SetGpuReg(REG_OFFSET_BG2X_H, sRegionMap->bg2x >> 16); + SetGpuReg(REG_OFFSET_BG2Y_L, sRegionMap->bg2y); + SetGpuReg(REG_OFFSET_BG2Y_H, sRegionMap->bg2y >> 16); + sRegionMap->needUpdateVideoRegs = FALSE; } } @@ -950,10 +950,10 @@ void PokedexAreaScreen_UpdateRegionMapVariablesAndVideoRegs(s16 x, s16 y) { CalcZoomScrollParams(x, y, 0x38, 0x48, 0x100, 0x100, 0); UpdateRegionMapVideoRegs(); - if (gRegionMap->playerIconSprite != NULL) + if (sRegionMap->playerIconSprite != NULL) { - gRegionMap->playerIconSprite->x2 = -x; - gRegionMap->playerIconSprite->y2 = -y; + sRegionMap->playerIconSprite->x2 = -x; + sRegionMap->playerIconSprite->y2 = -y; } } @@ -996,22 +996,22 @@ static void InitMapBasedOnPlayerLocation(void) case MAP_TYPE_ROUTE: case MAP_TYPE_UNDERWATER: case MAP_TYPE_OCEAN_ROUTE: - gRegionMap->mapSecId = gMapHeader.regionMapSectionId; - gRegionMap->playerIsInCave = FALSE; + sRegionMap->mapSecId = gMapHeader.regionMapSectionId; + sRegionMap->playerIsInCave = FALSE; mapWidth = gMapHeader.mapLayout->width; mapHeight = gMapHeader.mapLayout->height; x = gSaveBlock1Ptr->pos.x; y = gSaveBlock1Ptr->pos.y; - if (gRegionMap->mapSecId == MAPSEC_UNDERWATER_SEAFLOOR_CAVERN || gRegionMap->mapSecId == MAPSEC_UNDERWATER_MARINE_CAVE) - gRegionMap->playerIsInCave = TRUE; + if (sRegionMap->mapSecId == MAPSEC_UNDERWATER_SEAFLOOR_CAVERN || sRegionMap->mapSecId == MAPSEC_UNDERWATER_MARINE_CAVE) + sRegionMap->playerIsInCave = TRUE; break; case MAP_TYPE_UNDERGROUND: case MAP_TYPE_UNKNOWN: if (gMapHeader.allowEscaping) { mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->escapeWarp.mapGroup, gSaveBlock1Ptr->escapeWarp.mapNum); - gRegionMap->mapSecId = mapHeader->regionMapSectionId; - gRegionMap->playerIsInCave = TRUE; + sRegionMap->mapSecId = mapHeader->regionMapSectionId; + sRegionMap->playerIsInCave = TRUE; mapWidth = mapHeader->mapLayout->width; mapHeight = mapHeader->mapLayout->height; x = gSaveBlock1Ptr->escapeWarp.x; @@ -1019,8 +1019,8 @@ static void InitMapBasedOnPlayerLocation(void) } else { - gRegionMap->mapSecId = gMapHeader.regionMapSectionId; - gRegionMap->playerIsInCave = TRUE; + sRegionMap->mapSecId = gMapHeader.regionMapSectionId; + sRegionMap->playerIsInCave = TRUE; mapWidth = 1; mapHeight = 1; x = 1; @@ -1029,16 +1029,16 @@ static void InitMapBasedOnPlayerLocation(void) break; case MAP_TYPE_SECRET_BASE: mapHeader = Overworld_GetMapHeaderByGroupAndId((u16)gSaveBlock1Ptr->dynamicWarp.mapGroup, (u16)gSaveBlock1Ptr->dynamicWarp.mapNum); - gRegionMap->mapSecId = mapHeader->regionMapSectionId; - gRegionMap->playerIsInCave = TRUE; + sRegionMap->mapSecId = mapHeader->regionMapSectionId; + sRegionMap->playerIsInCave = TRUE; mapWidth = mapHeader->mapLayout->width; mapHeight = mapHeader->mapLayout->height; x = gSaveBlock1Ptr->dynamicWarp.x; y = gSaveBlock1Ptr->dynamicWarp.y; break; case MAP_TYPE_INDOOR: - gRegionMap->mapSecId = gMapHeader.regionMapSectionId; - if (gRegionMap->mapSecId != MAPSEC_DYNAMIC) + sRegionMap->mapSecId = gMapHeader.regionMapSectionId; + if (sRegionMap->mapSecId != MAPSEC_DYNAMIC) { warp = &gSaveBlock1Ptr->escapeWarp; mapHeader = Overworld_GetMapHeaderByGroupAndId(warp->mapGroup, warp->mapNum); @@ -1047,13 +1047,13 @@ static void InitMapBasedOnPlayerLocation(void) { warp = &gSaveBlock1Ptr->dynamicWarp; mapHeader = Overworld_GetMapHeaderByGroupAndId(warp->mapGroup, warp->mapNum); - gRegionMap->mapSecId = mapHeader->regionMapSectionId; + sRegionMap->mapSecId = mapHeader->regionMapSectionId; } - if (IsPlayerInAquaHideout(gRegionMap->mapSecId)) - gRegionMap->playerIsInCave = TRUE; + if (IsPlayerInAquaHideout(sRegionMap->mapSecId)) + sRegionMap->playerIsInCave = TRUE; else - gRegionMap->playerIsInCave = FALSE; + sRegionMap->playerIsInCave = FALSE; mapWidth = mapHeader->mapLayout->width; mapHeight = mapHeader->mapLayout->height; @@ -1064,29 +1064,29 @@ static void InitMapBasedOnPlayerLocation(void) xOnMap = x; - dimensionScale = mapWidth / gRegionMapEntries[gRegionMap->mapSecId].width; + dimensionScale = mapWidth / gRegionMapEntries[sRegionMap->mapSecId].width; if (dimensionScale == 0) { dimensionScale = 1; } x /= dimensionScale; - if (x >= gRegionMapEntries[gRegionMap->mapSecId].width) + if (x >= gRegionMapEntries[sRegionMap->mapSecId].width) { - x = gRegionMapEntries[gRegionMap->mapSecId].width - 1; + x = gRegionMapEntries[sRegionMap->mapSecId].width - 1; } - dimensionScale = mapHeight / gRegionMapEntries[gRegionMap->mapSecId].height; + dimensionScale = mapHeight / gRegionMapEntries[sRegionMap->mapSecId].height; if (dimensionScale == 0) { dimensionScale = 1; } y /= dimensionScale; - if (y >= gRegionMapEntries[gRegionMap->mapSecId].height) + if (y >= gRegionMapEntries[sRegionMap->mapSecId].height) { - y = gRegionMapEntries[gRegionMap->mapSecId].height - 1; + y = gRegionMapEntries[sRegionMap->mapSecId].height - 1; } - switch (gRegionMap->mapSecId) + switch (sRegionMap->mapSecId) { case MAPSEC_ROUTE_114: if (y != 0) @@ -1116,11 +1116,11 @@ static void InitMapBasedOnPlayerLocation(void) x++; break; case MAPSEC_UNDERWATER_MARINE_CAVE: - GetMarineCaveCoords(&gRegionMap->cursorPosX, &gRegionMap->cursorPosY); + GetMarineCaveCoords(&sRegionMap->cursorPosX, &sRegionMap->cursorPosY); return; } - gRegionMap->cursorPosX = gRegionMapEntries[gRegionMap->mapSecId].x + x + MAPCURSOR_X_MIN; - gRegionMap->cursorPosY = gRegionMapEntries[gRegionMap->mapSecId].y + y + MAPCURSOR_Y_MIN; + sRegionMap->cursorPosX = gRegionMapEntries[sRegionMap->mapSecId].x + x + MAPCURSOR_X_MIN; + sRegionMap->cursorPosY = gRegionMapEntries[sRegionMap->mapSecId].y + y + MAPCURSOR_Y_MIN; } static void RegionMap_InitializeStateBasedOnSSTidalLocation(void) @@ -1139,40 +1139,40 @@ static void RegionMap_InitializeStateBasedOnSSTidalLocation(void) switch (GetSSTidalLocation(&mapGroup, &mapNum, &xOnMap, &yOnMap)) { case SS_TIDAL_LOCATION_SLATEPORT: - gRegionMap->mapSecId = MAPSEC_SLATEPORT_CITY; + sRegionMap->mapSecId = MAPSEC_SLATEPORT_CITY; break; case SS_TIDAL_LOCATION_LILYCOVE: - gRegionMap->mapSecId = MAPSEC_LILYCOVE_CITY; + sRegionMap->mapSecId = MAPSEC_LILYCOVE_CITY; break; case SS_TIDAL_LOCATION_ROUTE124: - gRegionMap->mapSecId = MAPSEC_ROUTE_124; + sRegionMap->mapSecId = MAPSEC_ROUTE_124; break; case SS_TIDAL_LOCATION_ROUTE131: - gRegionMap->mapSecId = MAPSEC_ROUTE_131; + sRegionMap->mapSecId = MAPSEC_ROUTE_131; break; default: case SS_TIDAL_LOCATION_CURRENTS: mapHeader = Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum); - gRegionMap->mapSecId = mapHeader->regionMapSectionId; - dimensionScale = mapHeader->mapLayout->width / gRegionMapEntries[gRegionMap->mapSecId].width; + sRegionMap->mapSecId = mapHeader->regionMapSectionId; + dimensionScale = mapHeader->mapLayout->width / gRegionMapEntries[sRegionMap->mapSecId].width; if (dimensionScale == 0) dimensionScale = 1; x = xOnMap / dimensionScale; - if (x >= gRegionMapEntries[gRegionMap->mapSecId].width) - x = gRegionMapEntries[gRegionMap->mapSecId].width - 1; + if (x >= gRegionMapEntries[sRegionMap->mapSecId].width) + x = gRegionMapEntries[sRegionMap->mapSecId].width - 1; - dimensionScale = mapHeader->mapLayout->height / gRegionMapEntries[gRegionMap->mapSecId].height; + dimensionScale = mapHeader->mapLayout->height / gRegionMapEntries[sRegionMap->mapSecId].height; if (dimensionScale == 0) dimensionScale = 1; y = yOnMap / dimensionScale; - if (y >= gRegionMapEntries[gRegionMap->mapSecId].height) - y = gRegionMapEntries[gRegionMap->mapSecId].height - 1; + if (y >= gRegionMapEntries[sRegionMap->mapSecId].height) + y = gRegionMapEntries[sRegionMap->mapSecId].height - 1; break; } - gRegionMap->playerIsInCave = FALSE; - gRegionMap->cursorPosX = gRegionMapEntries[gRegionMap->mapSecId].x + x + MAPCURSOR_X_MIN; - gRegionMap->cursorPosY = gRegionMapEntries[gRegionMap->mapSecId].y + y + MAPCURSOR_Y_MIN; + sRegionMap->playerIsInCave = FALSE; + sRegionMap->cursorPosX = gRegionMapEntries[sRegionMap->mapSecId].x + x + MAPCURSOR_X_MIN; + sRegionMap->cursorPosY = gRegionMapEntries[sRegionMap->mapSecId].y + y + MAPCURSOR_Y_MIN; } static u8 GetMapsecType(u16 mapSecId) @@ -1300,20 +1300,20 @@ static void GetPositionOfCursorWithinMapSec(void) u16 y; u16 posWithinMapSec; - if (gRegionMap->mapSecId == MAPSEC_NONE) + if (sRegionMap->mapSecId == MAPSEC_NONE) { - gRegionMap->posWithinMapSec = 0; + sRegionMap->posWithinMapSec = 0; return; } - if (!gRegionMap->zoomed) + if (!sRegionMap->zoomed) { - x = gRegionMap->cursorPosX; - y = gRegionMap->cursorPosY; + x = sRegionMap->cursorPosX; + y = sRegionMap->cursorPosY; } else { - x = gRegionMap->zoomedCursorPosX; - y = gRegionMap->zoomedCursorPosY; + x = sRegionMap->zoomedCursorPosX; + y = sRegionMap->zoomedCursorPosY; } posWithinMapSec = 0; while (1) @@ -1333,13 +1333,13 @@ static void GetPositionOfCursorWithinMapSec(void) else { x--; - if (GetMapSecIdAt(x, y) == gRegionMap->mapSecId) + if (GetMapSecIdAt(x, y) == sRegionMap->mapSecId) { posWithinMapSec++; } } } - gRegionMap->posWithinMapSec = posWithinMapSec; + sRegionMap->posWithinMapSec = posWithinMapSec; } static bool8 RegionMap_IsMapSecIdInNextRow(u16 y) @@ -1352,7 +1352,7 @@ static bool8 RegionMap_IsMapSecIdInNextRow(u16 y) } for (x = MAPCURSOR_X_MIN; x <= MAPCURSOR_X_MAX; x++) { - if (GetMapSecIdAt(x, y) == gRegionMap->mapSecId) + if (GetMapSecIdAt(x, y) == sRegionMap->mapSecId) { return TRUE; } @@ -1362,11 +1362,11 @@ static bool8 RegionMap_IsMapSecIdInNextRow(u16 y) static void SpriteCB_CursorMapFull(struct Sprite *sprite) { - if (gRegionMap->cursorMovementFrameCounter != 0) + if (sRegionMap->cursorMovementFrameCounter != 0) { - sprite->x += 2 * gRegionMap->cursorDeltaX; - sprite->y += 2 * gRegionMap->cursorDeltaY; - gRegionMap->cursorMovementFrameCounter--; + sprite->x += 2 * sRegionMap->cursorDeltaX; + sprite->y += 2 * sRegionMap->cursorDeltaY; + sRegionMap->cursorMovementFrameCounter--; } } @@ -1386,20 +1386,20 @@ void CreateRegionMapCursor(u16 tileTag, u16 paletteTag) template = sRegionMapCursorSpriteTemplate; sheet.tag = tileTag; template.tileTag = tileTag; - gRegionMap->cursorTileTag = tileTag; + sRegionMap->cursorTileTag = tileTag; palette.tag = paletteTag; template.paletteTag = paletteTag; - gRegionMap->cursorPaletteTag = paletteTag; - if (!gRegionMap->zoomed) + sRegionMap->cursorPaletteTag = paletteTag; + if (!sRegionMap->zoomed) { - sheet.data = gRegionMap->cursorSmallImage; - sheet.size = sizeof(gRegionMap->cursorSmallImage); + sheet.data = sRegionMap->cursorSmallImage; + sheet.size = sizeof(sRegionMap->cursorSmallImage); template.callback = SpriteCB_CursorMapFull; } else { - sheet.data = gRegionMap->cursorLargeImage; - sheet.size = sizeof(gRegionMap->cursorLargeImage); + sheet.data = sRegionMap->cursorLargeImage; + sheet.size = sizeof(sRegionMap->cursorLargeImage); template.callback = SpriteCB_CursorMapZoomed; } LoadSpriteSheet(&sheet); @@ -1407,46 +1407,46 @@ void CreateRegionMapCursor(u16 tileTag, u16 paletteTag) spriteId = CreateSprite(&template, 0x38, 0x48, 0); if (spriteId != MAX_SPRITES) { - gRegionMap->cursorSprite = &gSprites[spriteId]; - if (gRegionMap->zoomed == TRUE) + sRegionMap->cursorSprite = &gSprites[spriteId]; + if (sRegionMap->zoomed == TRUE) { - gRegionMap->cursorSprite->oam.size = SPRITE_SIZE(32x32); - gRegionMap->cursorSprite->x -= 8; - gRegionMap->cursorSprite->y -= 8; - StartSpriteAnim(gRegionMap->cursorSprite, 1); + sRegionMap->cursorSprite->oam.size = SPRITE_SIZE(32x32); + sRegionMap->cursorSprite->x -= 8; + sRegionMap->cursorSprite->y -= 8; + StartSpriteAnim(sRegionMap->cursorSprite, 1); } else { - gRegionMap->cursorSprite->oam.size = SPRITE_SIZE(16x16); - gRegionMap->cursorSprite->x = 8 * gRegionMap->cursorPosX + 4; - gRegionMap->cursorSprite->y = 8 * gRegionMap->cursorPosY + 4; + sRegionMap->cursorSprite->oam.size = SPRITE_SIZE(16x16); + sRegionMap->cursorSprite->x = 8 * sRegionMap->cursorPosX + 4; + sRegionMap->cursorSprite->y = 8 * sRegionMap->cursorPosY + 4; } - gRegionMap->cursorSprite->data[1] = 2; - gRegionMap->cursorSprite->data[2] = (IndexOfSpritePaletteTag(paletteTag) << 4) + 0x101; - gRegionMap->cursorSprite->data[3] = TRUE; + sRegionMap->cursorSprite->data[1] = 2; + sRegionMap->cursorSprite->data[2] = (IndexOfSpritePaletteTag(paletteTag) << 4) + 0x101; + sRegionMap->cursorSprite->data[3] = TRUE; } } static void FreeRegionMapCursorSprite(void) { - if (gRegionMap->cursorSprite != NULL) + if (sRegionMap->cursorSprite != NULL) { - DestroySprite(gRegionMap->cursorSprite); - FreeSpriteTilesByTag(gRegionMap->cursorTileTag); - FreeSpritePaletteByTag(gRegionMap->cursorPaletteTag); + DestroySprite(sRegionMap->cursorSprite); + FreeSpriteTilesByTag(sRegionMap->cursorTileTag); + FreeSpritePaletteByTag(sRegionMap->cursorPaletteTag); } } // Unused static void SetUnkCursorSpriteData(void) { - gRegionMap->cursorSprite->data[3] = TRUE; + sRegionMap->cursorSprite->data[3] = TRUE; } // Unused static void ClearUnkCursorSpriteData(void) { - gRegionMap->cursorSprite->data[3] = FALSE; + sRegionMap->cursorSprite->data[3] = FALSE; } void CreateRegionMapPlayerIcon(u16 tileTag, u16 paletteTag) @@ -1458,7 +1458,7 @@ void CreateRegionMapPlayerIcon(u16 tileTag, u16 paletteTag) if (IsEventIslandMapSecId(gMapHeader.regionMapSectionId)) { - gRegionMap->playerIconSprite = NULL; + sRegionMap->playerIconSprite = NULL; return; } if (gSaveBlock2Ptr->playerGender == FEMALE) @@ -1469,49 +1469,49 @@ void CreateRegionMapPlayerIcon(u16 tileTag, u16 paletteTag) LoadSpriteSheet(&sheet); LoadSpritePalette(&palette); spriteId = CreateSprite(&template, 0, 0, 1); - gRegionMap->playerIconSprite = &gSprites[spriteId]; - if (!gRegionMap->zoomed) + sRegionMap->playerIconSprite = &gSprites[spriteId]; + if (!sRegionMap->zoomed) { - gRegionMap->playerIconSprite->x = gRegionMap->playerIconSpritePosX * 8 + 4; - gRegionMap->playerIconSprite->y = gRegionMap->playerIconSpritePosY * 8 + 4; - gRegionMap->playerIconSprite->callback = SpriteCB_PlayerIconMapFull; + sRegionMap->playerIconSprite->x = sRegionMap->playerIconSpritePosX * 8 + 4; + sRegionMap->playerIconSprite->y = sRegionMap->playerIconSpritePosY * 8 + 4; + sRegionMap->playerIconSprite->callback = SpriteCB_PlayerIconMapFull; } else { - gRegionMap->playerIconSprite->x = gRegionMap->playerIconSpritePosX * 16 - 0x30; - gRegionMap->playerIconSprite->y = gRegionMap->playerIconSpritePosY * 16 - 0x42; - gRegionMap->playerIconSprite->callback = SpriteCB_PlayerIconMapZoomed; + sRegionMap->playerIconSprite->x = sRegionMap->playerIconSpritePosX * 16 - 0x30; + sRegionMap->playerIconSprite->y = sRegionMap->playerIconSpritePosY * 16 - 0x42; + sRegionMap->playerIconSprite->callback = SpriteCB_PlayerIconMapZoomed; } } static void HideRegionMapPlayerIcon(void) { - if (gRegionMap->playerIconSprite != NULL) + if (sRegionMap->playerIconSprite != NULL) { - gRegionMap->playerIconSprite->invisible = TRUE; - gRegionMap->playerIconSprite->callback = SpriteCallbackDummy; + sRegionMap->playerIconSprite->invisible = TRUE; + sRegionMap->playerIconSprite->callback = SpriteCallbackDummy; } } static void UnhideRegionMapPlayerIcon(void) { - if (gRegionMap->playerIconSprite != NULL) + if (sRegionMap->playerIconSprite != NULL) { - if (gRegionMap->zoomed == TRUE) + if (sRegionMap->zoomed == TRUE) { - gRegionMap->playerIconSprite->x = gRegionMap->playerIconSpritePosX * 16 - 0x30; - gRegionMap->playerIconSprite->y = gRegionMap->playerIconSpritePosY * 16 - 0x42; - gRegionMap->playerIconSprite->callback = SpriteCB_PlayerIconMapZoomed; - gRegionMap->playerIconSprite->invisible = FALSE; + sRegionMap->playerIconSprite->x = sRegionMap->playerIconSpritePosX * 16 - 0x30; + sRegionMap->playerIconSprite->y = sRegionMap->playerIconSpritePosY * 16 - 0x42; + sRegionMap->playerIconSprite->callback = SpriteCB_PlayerIconMapZoomed; + sRegionMap->playerIconSprite->invisible = FALSE; } else { - gRegionMap->playerIconSprite->x = gRegionMap->playerIconSpritePosX * 8 + 4; - gRegionMap->playerIconSprite->y = gRegionMap->playerIconSpritePosY * 8 + 4; - gRegionMap->playerIconSprite->x2 = 0; - gRegionMap->playerIconSprite->y2 = 0; - gRegionMap->playerIconSprite->callback = SpriteCB_PlayerIconMapFull; - gRegionMap->playerIconSprite->invisible = FALSE; + sRegionMap->playerIconSprite->x = sRegionMap->playerIconSpritePosX * 8 + 4; + sRegionMap->playerIconSprite->y = sRegionMap->playerIconSpritePosY * 8 + 4; + sRegionMap->playerIconSprite->x2 = 0; + sRegionMap->playerIconSprite->y2 = 0; + sRegionMap->playerIconSprite->callback = SpriteCB_PlayerIconMapFull; + sRegionMap->playerIconSprite->invisible = FALSE; } } } @@ -1523,8 +1523,8 @@ static void UnhideRegionMapPlayerIcon(void) static void SpriteCB_PlayerIconMapZoomed(struct Sprite *sprite) { - sprite->x2 = -2 * gRegionMap->scrollX; - sprite->y2 = -2 * gRegionMap->scrollY; + sprite->x2 = -2 * sRegionMap->scrollX; + sprite->y2 = -2 * sRegionMap->scrollY; sprite->sY = sprite->y + sprite->y2 + sprite->centerToCornerVecY; sprite->sX = sprite->x + sprite->x2 + sprite->centerToCornerVecX; if (sprite->sY < -8 || sprite->sY > DISPLAY_HEIGHT + 8 || sprite->sX < -8 || sprite->sX > DISPLAY_WIDTH + 8) @@ -1545,7 +1545,7 @@ static void SpriteCB_PlayerIconMapFull(struct Sprite *sprite) static void SpriteCB_PlayerIcon(struct Sprite *sprite) { - if (gRegionMap->blinkPlayerIcon) + if (sRegionMap->blinkPlayerIcon) { if (++sprite->sTimer > 16) { @@ -1561,8 +1561,8 @@ static void SpriteCB_PlayerIcon(struct Sprite *sprite) void TrySetPlayerIconBlink(void) { - if (gRegionMap->playerIsInCave) - gRegionMap->blinkPlayerIcon = TRUE; + if (sRegionMap->playerIsInCave) + sRegionMap->blinkPlayerIcon = TRUE; } #undef sY @@ -1634,7 +1634,7 @@ static void GetMapSecDimensions(u16 mapSecId, u16 *x, u16 *y, u16 *width, u16 *h bool8 IsRegionMapZoomed(void) { - return gRegionMap->zoomed; + return sRegionMap->zoomed; } bool32 IsEventIslandMapSecId(u8 mapSecId) @@ -2024,11 +2024,7 @@ static void CB_ExitFlyMap(void) { SetMainCallback2(CB2_ReturnToPartyMenuFromFlyMap); } - if (sFlyMap != NULL) - { - free(sFlyMap); - sFlyMap = NULL; - } + TRY_FREE_AND_SET_NULL(sFlyMap); FreeAllWindowBuffers(); } break; diff --git a/src/rom_header_gf.c b/src/rom_header_gf.c index 782a05c75..b854c899e 100644 --- a/src/rom_header_gf.c +++ b/src/rom_header_gf.c @@ -30,10 +30,10 @@ struct GFRomHeader u32 pokedexFlag; u32 mysteryEventFlag; u32 pokedexCount; - u8 unk1; + u8 playerNameLength; u8 unk2; - u8 unk3; - u8 unk4; + u8 pokemonNameLength1; + u8 pokemonNameLength2; u8 unk5; u8 unk6; u8 unk7; @@ -79,8 +79,8 @@ struct GFRomHeader u32 pcItemsOffset; u32 giftRibbonsOffset; u32 enigmaBerryOffset; - u32 mapViewOffset; - u32 unk19; + u32 enigmaBerrySize; + const u8 * moveDescriptions; u32 unk20; }; @@ -110,23 +110,24 @@ static const struct GFRomHeader sGFRomHeader = { .pokedexFlag = FLAG_RECEIVED_POKEDEX_FROM_BIRCH, .mysteryEventFlag = FLAG_SYS_MYSTERY_EVENT_ENABLE, .pokedexCount = NATIONAL_DEX_COUNT, - .unk1 = 0x07, - .unk2 = 0x0a, - .unk3 = 0x0a, - .unk4 = 0x0a, - .unk5 = 0x0c, - .unk6 = 0x0c, - .unk7 = 0x06, - .unk8 = 0x0c, - .unk9 = 0x06, - .unk10 = 0x10, - .unk11 = 0x12, - .unk12 = 0x0c, - .unk13 = 0x0f, - .unk14 = 0x0b, - .unk15 = 0x01, - .unk16 = 0x08, - .unk17 = 0x0c, + .playerNameLength = PLAYER_NAME_LENGTH, + .unk2 = 10, + .pokemonNameLength1 = POKEMON_NAME_LENGTH, + .pokemonNameLength2 = POKEMON_NAME_LENGTH, + // Two of the below 12s are likely move/ability name length, given their presence in this header + .unk5 = 12, + .unk6 = 12, + .unk7 = 6, + .unk8 = 12, + .unk9 = 6, + .unk10 = 16, + .unk11 = 18, + .unk12 = 12, + .unk13 = 15, + .unk14 = 11, + .unk15 = 1, + .unk16 = 8, + .unk17 = 12, .saveBlock2Size = sizeof(struct SaveBlock2), .saveBlock1Size = sizeof(struct SaveBlock1), .partyCountOffset = offsetof(struct SaveBlock1, playerPartyCount), @@ -159,7 +160,7 @@ static const struct GFRomHeader sGFRomHeader = { .pcItemsOffset = offsetof(struct SaveBlock1, pcItems), .giftRibbonsOffset = offsetof(struct SaveBlock1, giftRibbons), .enigmaBerryOffset = offsetof(struct SaveBlock1, enigmaBerry), - .mapViewOffset = offsetof(struct SaveBlock1, mapView), - .unk19 = 0x00000000, + .enigmaBerrySize = sizeof(struct EnigmaBerry), + .moveDescriptions = NULL, .unk20 = 0x00000000, // 0xFFFFFFFF in FRLG }; diff --git a/src/rotating_gate.c b/src/rotating_gate.c index f839d22c3..e2fd575a1 100644 --- a/src/rotating_gate.c +++ b/src/rotating_gate.c @@ -612,12 +612,10 @@ static const u8 sRotatingGate_ArmLayout[][4 * 2] = }, }; -// ewram -static EWRAM_DATA u8 gRotatingGate_GateSpriteIds[ROTATING_GATE_PUZZLE_MAX] = {0}; -static EWRAM_DATA const struct RotatingGatePuzzle *gRotatingGate_PuzzleConfig = NULL; -static EWRAM_DATA u8 gRotatingGate_PuzzleCount = 0; +static EWRAM_DATA u8 sRotatingGate_GateSpriteIds[ROTATING_GATE_PUZZLE_MAX] = {0}; +static EWRAM_DATA const struct RotatingGatePuzzle *sRotatingGate_PuzzleConfig = NULL; +static EWRAM_DATA u8 sRotatingGate_PuzzleCount = 0; -// text static s32 GetCurrentMapRotatingGatePuzzleType(void) { if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(FORTREE_CITY_GYM) && @@ -640,9 +638,9 @@ static void RotatingGate_ResetAllGateOrientations(void) s32 i; u8 *ptr = (u8 *)GetVarPointer(VAR_TEMP_0); - for (i = 0; i < gRotatingGate_PuzzleCount; i++) + for (i = 0; i < sRotatingGate_PuzzleCount; i++) { - ptr[i] = gRotatingGate_PuzzleConfig[i].orientation; + ptr[i] = sRotatingGate_PuzzleConfig[i].orientation; } } @@ -683,12 +681,12 @@ static void RotatingGate_LoadPuzzleConfig(void) switch (puzzleType) { case PUZZLE_FORTREE_CITY_GYM: - gRotatingGate_PuzzleConfig = sRotatingGate_FortreePuzzleConfig; - gRotatingGate_PuzzleCount = ARRAY_COUNT(sRotatingGate_FortreePuzzleConfig); + sRotatingGate_PuzzleConfig = sRotatingGate_FortreePuzzleConfig; + sRotatingGate_PuzzleCount = ARRAY_COUNT(sRotatingGate_FortreePuzzleConfig); break; case PUZZLE_ROUTE110_TRICK_HOUSE_PUZZLE6: - gRotatingGate_PuzzleConfig = sRotatingGate_TrickHousePuzzleConfig; - gRotatingGate_PuzzleCount = ARRAY_COUNT(sRotatingGate_TrickHousePuzzleConfig); + sRotatingGate_PuzzleConfig = sRotatingGate_TrickHousePuzzleConfig; + sRotatingGate_PuzzleCount = ARRAY_COUNT(sRotatingGate_TrickHousePuzzleConfig); break; case PUZZLE_NONE: default: @@ -696,7 +694,7 @@ static void RotatingGate_LoadPuzzleConfig(void) } for (i = 0; i < ROTATING_GATE_PUZZLE_MAX - 1; i++) - gRotatingGate_GateSpriteIds[i] = MAX_SPRITES; + sRotatingGate_GateSpriteIds[i] = MAX_SPRITES; } static void RotatingGate_CreateGatesWithinViewport(s16 deltaX, s16 deltaY) @@ -710,15 +708,15 @@ static void RotatingGate_CreateGatesWithinViewport(s16 deltaX, s16 deltaY) s16 y = gSaveBlock1Ptr->pos.y - 2; s16 y2 = gSaveBlock1Ptr->pos.y + MAP_OFFSET_H; - for (i = 0; i < gRotatingGate_PuzzleCount; i++) + for (i = 0; i < sRotatingGate_PuzzleCount; i++) { - s16 x3 = gRotatingGate_PuzzleConfig[i].x + MAP_OFFSET; - s16 y3 = gRotatingGate_PuzzleConfig[i].y + MAP_OFFSET; + s16 x3 = sRotatingGate_PuzzleConfig[i].x + MAP_OFFSET; + s16 y3 = sRotatingGate_PuzzleConfig[i].y + MAP_OFFSET; if (y <= y3 && y2 >= y3 && x <= x3 && x2 >= x3 && - gRotatingGate_GateSpriteIds[i] == MAX_SPRITES) + sRotatingGate_GateSpriteIds[i] == MAX_SPRITES) { - gRotatingGate_GateSpriteIds[i] = RotatingGate_CreateGate(i, deltaX, deltaY); + sRotatingGate_GateSpriteIds[i] = RotatingGate_CreateGate(i, deltaX, deltaY); } } } @@ -730,7 +728,7 @@ static u8 RotatingGate_CreateGate(u8 gateId, s16 deltaX, s16 deltaY) u8 spriteId; s16 x, y; - const struct RotatingGatePuzzle *gate = &gRotatingGate_PuzzleConfig[gateId]; + const struct RotatingGatePuzzle *gate = &sRotatingGate_PuzzleConfig[gateId]; if (gate->shape == GATE_SHAPE_L1 || gate->shape == GATE_SHAPE_T1) template = sSpriteTemplate_RotatingGateRegular; @@ -827,20 +825,20 @@ static void RotatingGate_DestroyGatesOutsideViewport(void) s16 y = gSaveBlock1Ptr->pos.y - 2; s16 y2 = gSaveBlock1Ptr->pos.y + MAP_OFFSET_H; - for (i = 0; i < gRotatingGate_PuzzleCount; i++) + for (i = 0; i < sRotatingGate_PuzzleCount; i++) { - s16 xGate = gRotatingGate_PuzzleConfig[i].x + MAP_OFFSET; - s16 yGate = gRotatingGate_PuzzleConfig[i].y + MAP_OFFSET; + s16 xGate = sRotatingGate_PuzzleConfig[i].x + MAP_OFFSET; + s16 yGate = sRotatingGate_PuzzleConfig[i].y + MAP_OFFSET; - if (gRotatingGate_GateSpriteIds[i] == MAX_SPRITES) + if (sRotatingGate_GateSpriteIds[i] == MAX_SPRITES) continue; if (xGate < x || xGate > x2 || yGate < y || yGate > y2) { - struct Sprite *sprite = &gSprites[gRotatingGate_GateSpriteIds[i]]; + struct Sprite *sprite = &gSprites[sRotatingGate_GateSpriteIds[i]]; FreeSpriteOamMatrix(sprite); DestroySprite(sprite); - gRotatingGate_GateSpriteIds[i] = MAX_SPRITES; + sRotatingGate_GateSpriteIds[i] = MAX_SPRITES; } } } @@ -862,9 +860,9 @@ static s32 RotatingGate_CanRotate(u8 gateId, s32 rotationDirection) orientation = RotatingGate_GetGateOrientation(gateId); - shape = gRotatingGate_PuzzleConfig[gateId].shape; - x = gRotatingGate_PuzzleConfig[gateId].x + MAP_OFFSET; - y = gRotatingGate_PuzzleConfig[gateId].y + MAP_OFFSET; + shape = sRotatingGate_PuzzleConfig[gateId].shape; + x = sRotatingGate_PuzzleConfig[gateId].x + MAP_OFFSET; + y = sRotatingGate_PuzzleConfig[gateId].y + MAP_OFFSET; // Loop through the gate's "arms" clockwise (north, south, east, west) for (i = GATE_ARM_NORTH; i <= GATE_ARM_WEST; i++) @@ -891,15 +889,15 @@ static s32 RotatingGate_HasArm(u8 gateId, u8 armInfo) s32 isLongArm = armInfo % 2; s8 armOrientation = (arm - RotatingGate_GetGateOrientation(gateId) + 4) % 4; - s32 shape = gRotatingGate_PuzzleConfig[gateId].shape; + s32 shape = sRotatingGate_PuzzleConfig[gateId].shape; return sRotatingGate_ArmLayout[shape][armOrientation * 2 + isLongArm]; } static void RotatingGate_TriggerRotationAnimation(u8 gateId, s32 rotationDirection) { - if (gRotatingGate_GateSpriteIds[gateId] != MAX_SPRITES) + if (sRotatingGate_GateSpriteIds[gateId] != MAX_SPRITES) { - struct Sprite *sprite = &gSprites[gRotatingGate_GateSpriteIds[gateId]]; + struct Sprite *sprite = &gSprites[sRotatingGate_GateSpriteIds[gateId]]; sprite->data[1] = rotationDirection; sprite->data[2] = RotatingGate_GetGateOrientation(gateId); } @@ -957,10 +955,10 @@ bool8 CheckForRotatingGatePuzzleCollision(u8 direction, s16 x, s16 y) if (!GetCurrentMapRotatingGatePuzzleType()) return FALSE; - for (i = 0; i < gRotatingGate_PuzzleCount; i++) + for (i = 0; i < sRotatingGate_PuzzleCount; i++) { - s16 gateX = gRotatingGate_PuzzleConfig[i].x + MAP_OFFSET; - s16 gateY = gRotatingGate_PuzzleConfig[i].y + MAP_OFFSET; + s16 gateX = sRotatingGate_PuzzleConfig[i].x + MAP_OFFSET; + s16 gateY = sRotatingGate_PuzzleConfig[i].y + MAP_OFFSET; if (gateX - 2 <= x && x <= gateX + 1 && gateY - 2 <= y && y <= gateY + 1) { @@ -995,10 +993,10 @@ bool8 CheckForRotatingGatePuzzleCollisionWithoutAnimation(u8 direction, s16 x, s if (!GetCurrentMapRotatingGatePuzzleType()) return FALSE; - for (i = 0; i < gRotatingGate_PuzzleCount; i++) + for (i = 0; i < sRotatingGate_PuzzleCount; i++) { - s16 gateX = gRotatingGate_PuzzleConfig[i].x + MAP_OFFSET; - s16 gateY = gRotatingGate_PuzzleConfig[i].y + MAP_OFFSET; + s16 gateX = sRotatingGate_PuzzleConfig[i].x + MAP_OFFSET; + s16 gateY = sRotatingGate_PuzzleConfig[i].y + MAP_OFFSET; if (gateX - 2 <= x && x <= gateX + 1 && gateY - 2 <= y && y <= gateY + 1) { diff --git a/src/rotating_tile_puzzle.c b/src/rotating_tile_puzzle.c index 2e919f550..4581f6e5b 100644 --- a/src/rotating_tile_puzzle.c +++ b/src/rotating_tile_puzzle.c @@ -81,14 +81,11 @@ static const u8 sMovement_FaceUp[] = MOVEMENT_ACTION_STEP_END }; -// This file's functions. -static void SaveRotatingTileObject(u8 eventTemplateId, u8 arg1); -static void TurnUnsavedRotatingTileObject(u8 eventTemplateId, u8 arg1); +static void SaveRotatingTileObject(u8, u8); +static void TurnUnsavedRotatingTileObject(u8, u8); -// EWRAM vars EWRAM_DATA static struct RotatingTilePuzzle *sRotatingTilePuzzle = NULL; -// code void InitRotatingTilePuzzle(bool8 isTrickHouse) { if (sRotatingTilePuzzle == NULL) @@ -101,8 +98,7 @@ void FreeRotatingTilePuzzle(void) { u8 id; - if (sRotatingTilePuzzle != NULL) - FREE_AND_SET_NULL(sRotatingTilePuzzle); + TRY_FREE_AND_SET_NULL(sRotatingTilePuzzle); id = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0); ObjectEventClearHeldMovementIfFinished(&gObjectEvents[id]); diff --git a/src/save.c b/src/save.c index dafc20868..52cdaa5dd 100644 --- a/src/save.c +++ b/src/save.c @@ -73,6 +73,12 @@ struct SAVEBLOCK_CHUNK(struct PokemonStorage, 8), // SECTOR_ID_PKMN_STORAGE_END }; +// These will produce an error if a save struct is larger than the space +// alloted for it in the flash. +STATIC_ASSERT(sizeof(struct SaveBlock2) <= SECTOR_DATA_SIZE, SaveBlock2FreeSpace); +STATIC_ASSERT(sizeof(struct SaveBlock1) <= SECTOR_DATA_SIZE * (SECTOR_ID_SAVEBLOCK1_END - SECTOR_ID_SAVEBLOCK1_START + 1), SaveBlock1FreeSpace); +STATIC_ASSERT(sizeof(struct PokemonStorage) <= SECTOR_DATA_SIZE * (SECTOR_ID_PKMN_STORAGE_END - SECTOR_ID_PKMN_STORAGE_START + 1), PokemonStorageFreeSpace); + u16 gLastWrittenSector; u32 gLastSaveCounter; u16 gLastKnownGoodSector; diff --git a/src/script_movement.c b/src/script_movement.c index 92f36e92d..10517dfc8 100644 --- a/src/script_movement.c +++ b/src/script_movement.c @@ -6,7 +6,6 @@ #include "constants/event_objects.h" #include "constants/event_object_movement.h" -// static functions static void ScriptMovement_StartMoveObjects(u8 priority); static u8 GetMoveObjectsTaskId(void); static bool8 ScriptMovement_TryAddNewMovement(u8 taskId, u8 objEventId, const u8 *movementScript); @@ -17,10 +16,8 @@ static void ScriptMovement_UnfreezeActiveObjects(u8 taskId); static void ScriptMovement_MoveObjects(u8 taskId); static void ScriptMovement_TakeStep(u8 taskId, u8 moveScrId, u8 objEventId, const u8 *movementScript); -// EWRAM_DATA -static EWRAM_DATA const u8 *gMovementScripts[OBJECT_EVENTS_COUNT] = {0}; +static EWRAM_DATA const u8 *sMovementScripts[OBJECT_EVENTS_COUNT] = {0}; -// text bool8 ScriptMovement_StartObjectMovementScript(u8 localId, u8 mapNum, u8 mapGroup, const u8 *movementScript) { u8 objEventId; @@ -167,12 +164,12 @@ static bool8 IsMovementScriptFinished(u8 taskId, u8 moveScrId) static void SetMovementScript(u8 moveScrId, const u8 *movementScript) { - gMovementScripts[moveScrId] = movementScript; + sMovementScripts[moveScrId] = movementScript; } static const u8 *GetMovementScript(u8 moveScrId) { - return gMovementScripts[moveScrId]; + return sMovementScripts[moveScrId]; } static void ScriptMovement_AddNewMovement(u8 taskId, u8 moveScrId, u8 objEventId, const u8 *movementScript) diff --git a/src/siirtc.c b/src/siirtc.c index 5f4fc0a23..0e598f717 100644 --- a/src/siirtc.c +++ b/src/siirtc.c @@ -4,6 +4,7 @@ #include "gba/gba.h" #include "siirtc.h" +#include "config.h" #define STATUS_INTFE 0x02 // frequency interrupt enable #define STATUS_INTME 0x08 // per-minute interrupt enable diff --git a/src/slot_machine.c b/src/slot_machine.c index 1dfa026e5..cb6a380d6 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -1390,7 +1390,7 @@ static bool8 SlotTask_HandleBetInput(struct Task *task) // SLOTTASK_MSG_NEED_3_COINS static bool8 SlotTask_PrintMsg_Need3Coins(struct Task *task) { - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); AddTextPrinterParameterized(0, FONT_NORMAL, gText_YouDontHaveThreeCoins, 0, 1, 0, 0); CopyWindowToVram(0, COPYWIN_FULL); sSlotMachine->state = SLOTTASK_WAIT_MSG_NEED_3_COINS; @@ -1655,7 +1655,7 @@ static bool8 SlotTask_NoMatches(struct Task *task) // SLOTTASK_ASK_QUIT static bool8 SlotTask_AskQuit(struct Task *task) { - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); AddTextPrinterParameterized(0, FONT_NORMAL, gText_QuitTheGame, 0, 1, 0, 0); CopyWindowToVram(0, COPYWIN_FULL); CreateYesNoMenuParameterized(0x15, 7, 0x214, 0x180, 0xE, 0xF); @@ -1687,7 +1687,7 @@ static bool8 SlotTask_HandleQuitInput(struct Task *task) // SLOTTASK_MSG_MAX_COINS static bool8 SlotTask_PrintMsg_MaxCoins(struct Task *task) { - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); AddTextPrinterParameterized(0, FONT_NORMAL, gText_YouveGot9999Coins, 0, 1, 0, 0); CopyWindowToVram(0, COPYWIN_FULL); sSlotMachine->state = SLOTTASK_WAIT_MSG_MAX_COINS; @@ -1708,7 +1708,7 @@ static bool8 SlotTask_WaitMsg_MaxCoins(struct Task *task) // SLOTTASK_MSG_NO_MORE_COINS static bool8 SlotTask_PrintMsg_NoMoreCoins(struct Task *task) { - DrawDialogueFrame(0, 0); + DrawDialogueFrame(0, FALSE); AddTextPrinterParameterized(0, FONT_NORMAL, gText_YouveRunOutOfCoins, 0, 1, 0, 0); CopyWindowToVram(0, COPYWIN_FULL); sSlotMachine->state = SLOTTASK_WAIT_MSG_NO_MORE_COINS; @@ -1756,14 +1756,10 @@ static bool8 SlotTask_FreeDataStructures(struct Task *task) FREE_AND_SET_NULL(sImageTable_DigitalDisplay_Number); FREE_AND_SET_NULL(sImageTable_DigitalDisplay_Pokeball); FREE_AND_SET_NULL(sImageTable_DigitalDisplay_DPad); - if (sImageTable_ReelTimePikachu != NULL) - FREE_AND_SET_NULL(sImageTable_ReelTimePikachu); - if (sImageTable_ReelTimeMachineAntennae != NULL) - FREE_AND_SET_NULL(sImageTable_ReelTimeMachineAntennae); - if (sImageTable_ReelTimeMachine != NULL) - FREE_AND_SET_NULL(sImageTable_ReelTimeMachine); - if (sImageTable_BrokenReelTimeMachine != NULL) - FREE_AND_SET_NULL(sImageTable_BrokenReelTimeMachine); + TRY_FREE_AND_SET_NULL(sImageTable_ReelTimePikachu); + TRY_FREE_AND_SET_NULL(sImageTable_ReelTimeMachineAntennae); + TRY_FREE_AND_SET_NULL(sImageTable_ReelTimeMachine); + TRY_FREE_AND_SET_NULL(sImageTable_BrokenReelTimeMachine); FREE_AND_SET_NULL(sMenuGfx); FREE_AND_SET_NULL(sSelectedPikaPowerTile); FREE_AND_SET_NULL(sReelOverlay_Tilemap); @@ -3865,21 +3861,15 @@ static void ReelTime_EndFailure(struct Task *task) static void LoadReelTimeWindowTilemap(s16 a0, s16 a1) { s16 i; - for (i = 4; i < 15; i++) - { LoadBgTilemap(1, &sReelTimeWindow_Tilemap[a1 + (i - 4) * 20], 2, 32 * i + a0); - } } static void ClearReelTimeWindowTilemap(s16 a0) { u8 i; - for (i = 4; i < 15; i++) - { LoadBgTilemap(1, sEmptyTilemap, 2, 32 * i + a0); - } } #undef tState @@ -4116,32 +4106,44 @@ static void CreateCreditPayoutNumberSprites(void) CreateCoinNumberSprite(x, 23, TRUE, i); } -static void CreateCoinNumberSprite(s16 x, s16 y, bool8 isPayout, s16 a3) +#define sIsPayout data[0] +#define sDigitMin data[1] +#define sDigitMax data[2] +#define sCurNum data[3] // Only used to determine whether the sprite has already been updated to show the correct digit + +static void CreateCoinNumberSprite(s16 x, s16 y, bool8 isPayout, s16 digitMult) { struct Sprite *sprite = &gSprites[CreateSprite(&sSpriteTemplate_CoinNumber, x, y, 13)]; sprite->oam.priority = 2; - sprite->data[0] = isPayout; - sprite->data[1] = a3; - sprite->data[2] = a3 * 10; - sprite->data[3] = -1; + sprite->sIsPayout = isPayout; + sprite->sDigitMin = digitMult; + sprite->sDigitMax = digitMult * 10; + sprite->sCurNum = -1; } static void SpriteCB_CoinNumber(struct Sprite *sprite) { u16 tag = sSlotMachine->coins; - if (sprite->data[0]) + if (sprite->sIsPayout) tag = sSlotMachine->payout; - if (sprite->data[3] != tag) + if (sprite->sCurNum != tag) { - sprite->data[3] = tag; - tag %= (u16)sprite->data[2]; - tag /= (u16)sprite->data[1]; - tag += 7; + // Convert total to current digit + sprite->sCurNum = tag; + tag %= (u16)sprite->sDigitMax; + tag /= (u16)sprite->sDigitMin; + + tag += GFXTAG_NUM_0; sprite->sheetTileStart = GetSpriteTileStartByTag(tag); SetSpriteSheetFrameTileNum(sprite); } } +#undef sIsPayout +#undef sDigitMin +#undef sDigitMax +#undef sCurNum + static void CreateReelBackgroundSprite(void) { u8 spriteId = CreateSprite(&sSpriteTemplate_ReelBackground, 88, 72, 15); @@ -4178,8 +4180,7 @@ static void CreateReelTimePikachuSprite(void) static void DestroyReelTimePikachuSprite(void) { DestroySprite(&gSprites[sSlotMachine->reelTimePikachuSpriteId]); - if (sImageTable_ReelTimePikachu != NULL) - FREE_AND_SET_NULL(sImageTable_ReelTimePikachu); + TRY_FREE_AND_SET_NULL(sImageTable_ReelTimePikachu); } static void SpriteCB_ReelTimePikachu(struct Sprite *sprite) @@ -4308,10 +4309,8 @@ static void DestroyReelTimeMachineSprites(void) for (i = 0; i < ARRAY_COUNT(sSlotMachine->reelTimeMachineSpriteIds); i++) DestroySprite(&gSprites[sSlotMachine->reelTimeMachineSpriteIds[i]]); - if (sImageTable_ReelTimeMachineAntennae != NULL) - FREE_AND_SET_NULL(sImageTable_ReelTimeMachineAntennae); - if (sImageTable_ReelTimeMachine != NULL) - FREE_AND_SET_NULL(sImageTable_ReelTimeMachine); + TRY_FREE_AND_SET_NULL(sImageTable_ReelTimeMachineAntennae); + TRY_FREE_AND_SET_NULL(sImageTable_ReelTimeMachine); for (i = 0; i < ARRAY_COUNT(sSlotMachine->reelTimeNumberSpriteIds); i++) DestroySprite(&gSprites[sSlotMachine->reelTimeNumberSpriteIds[i]]); @@ -4328,8 +4327,7 @@ static void DestroyReelTimeShadowSprites(void) static void DestroyBrokenReelTimeMachineSprite(void) { DestroySprite(&gSprites[sSlotMachine->reelTimeBrokenMachineSpriteId]); - if (sImageTable_BrokenReelTimeMachine != NULL) - FREE_AND_SET_NULL(sImageTable_BrokenReelTimeMachine); + TRY_FREE_AND_SET_NULL(sImageTable_BrokenReelTimeMachine); } #define sDelayTimer data[0] diff --git a/src/start_menu.c b/src/start_menu.c index 90230c3dd..11189ee83 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -42,9 +42,10 @@ #include "text_window.h" #include "trainer_card.h" #include "window.h" -#include "constants/songs.h" #include "union_room.h" +#include "constants/battle_frontier.h" #include "constants/rgb.h" +#include "constants/songs.h" // Menu actions enum @@ -138,7 +139,7 @@ static bool8 FieldCB_ReturnToFieldStartMenu(void); static const struct WindowTemplate sSafariBallsWindowTemplate = {0, 1, 1, 9, 4, 0xF, 8}; -static const u8* const sPyramidFloorNames[] = +static const u8* const sPyramidFloorNames[FRONTIER_STAGES_PER_CHALLENGE + 1] = { gText_Floor1, gText_Floor2, @@ -392,7 +393,7 @@ static void ShowSafariBallsWindow(void) static void ShowPyramidFloorWindow(void) { - if (gSaveBlock2Ptr->frontier.curChallengeBattleNum == 7) + if (gSaveBlock2Ptr->frontier.curChallengeBattleNum == FRONTIER_STAGES_PER_CHALLENGE) sBattlePyramidFloorWindowId = AddWindow(&sPyramidFloorWindowTemplate_1); else sBattlePyramidFloorWindowId = AddWindow(&sPyramidFloorWindowTemplate_2); diff --git a/src/tileset_anims.c b/src/tileset_anims.c index 3676006a6..6a7589e36 100644 --- a/src/tileset_anims.c +++ b/src/tileset_anims.c @@ -537,7 +537,7 @@ const u16 *const gTilesetAnims_BattlePyramid_StatueShadow[] = { gTilesetAnims_BattlePyramid_StatueShadow_Frame2 }; -static const u16 *const gTilesetAnims_BattleDomeFloorLightPals[] = { +static const u16 *const sTilesetAnims_BattleDomeFloorLightPals[] = { gTilesetAnims_BattleDomePals0_0, gTilesetAnims_BattleDomePals0_1, gTilesetAnims_BattleDomePals0_2, @@ -1167,7 +1167,7 @@ static void QueueAnimTiles_BattlePyramid_StatueShadow(u16 timer) static void BlendAnimPalette_BattleDome_FloorLights(u16 timer) { - CpuCopy16(gTilesetAnims_BattleDomeFloorLightPals[timer % ARRAY_COUNT(gTilesetAnims_BattleDomeFloorLightPals)], &gPlttBufferUnfaded[0x80], 32); + CpuCopy16(sTilesetAnims_BattleDomeFloorLightPals[timer % ARRAY_COUNT(sTilesetAnims_BattleDomeFloorLightPals)], &gPlttBufferUnfaded[0x80], 32); BlendPalette(0x80, 16, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF); if ((u8)FindTaskIdByFunc(Task_BattleTransition_Intro) != TASK_NONE) { @@ -1178,7 +1178,7 @@ static void BlendAnimPalette_BattleDome_FloorLights(u16 timer) static void BlendAnimPalette_BattleDome_FloorLightsNoBlend(u16 timer) { - CpuCopy16(gTilesetAnims_BattleDomeFloorLightPals[timer % ARRAY_COUNT(gTilesetAnims_BattleDomeFloorLightPals)], &gPlttBufferUnfaded[0x80], 32); + CpuCopy16(sTilesetAnims_BattleDomeFloorLightPals[timer % ARRAY_COUNT(sTilesetAnims_BattleDomeFloorLightPals)], &gPlttBufferUnfaded[0x80], 32); if ((u8)FindTaskIdByFunc(Task_BattleTransition_Intro) == TASK_NONE) { BlendPalette(0x80, 16, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF); diff --git a/src/trade.c b/src/trade.c index dd0851bbd..25614c91a 100644 --- a/src/trade.c +++ b/src/trade.c @@ -2195,7 +2195,7 @@ static bool8 LoadTradeMenuSpriteSheetsAndPalettes(void) sTradeMenuData->timer++; break; case GFXTAG_MENU_TEXT_COUNT: - LoadSpritePalette(&gSpritePalette_TradeScreenText); + LoadSpritePalette(&sSpritePalette_TradeScreenText); sTradeMenuData->timer++; break; case GFXTAG_MENU_TEXT_COUNT + 1: @@ -2435,7 +2435,7 @@ static bool32 IsDeoxysOrMewUntradable(u16 species, bool8 isEventLegal) return FALSE; } -int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, u8 isEventLegal) +int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isEventLegal) { bool8 playerHasNationalDex = player.hasNationalDex; bool8 playerIsChampion = player.isChampion; @@ -2496,7 +2496,7 @@ int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct Rf return UR_TRADE_MSG_NONE; } -int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, u8 isEventLegal) +int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isEventLegal) { bool8 hasNationalDex = player.hasNationalDex; @@ -3744,7 +3744,7 @@ static bool8 AnimateTradeSequenceCable(void) gSprites[sTradeData->monSpriteIds[TRADE_PARTNER]].x2 = 0; gSprites[sTradeData->monSpriteIds[TRADE_PARTNER]].y2 = 0; StartSpriteAnim(&gSprites[sTradeData->monSpriteIds[TRADE_PARTNER]], 0); - CreatePokeballSpriteToReleaseMon(sTradeData->monSpriteIds[TRADE_PARTNER], gSprites[sTradeData->monSpriteIds[TRADE_PARTNER]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, sTradeData->monSpecies[TRADE_PARTNER]); + CreatePokeballSpriteToReleaseMon(sTradeData->monSpriteIds[TRADE_PARTNER], gSprites[sTradeData->monSpriteIds[TRADE_PARTNER]].oam.paletteNum, 120, 84, 2, 1, 20, PALETTES_BG | (0xF << 16), sTradeData->monSpecies[TRADE_PARTNER]); FreeSpriteOamMatrix(&gSprites[sTradeData->bouncingPokeballSpriteId]); DestroySprite(&gSprites[sTradeData->bouncingPokeballSpriteId]); sTradeData->state++; @@ -4244,7 +4244,7 @@ static bool8 AnimateTradeSequenceWireless(void) gSprites[sTradeData->monSpriteIds[TRADE_PARTNER]].x2 = 0; gSprites[sTradeData->monSpriteIds[TRADE_PARTNER]].y2 = 0; StartSpriteAnim(&gSprites[sTradeData->monSpriteIds[TRADE_PARTNER]], 0); - CreatePokeballSpriteToReleaseMon(sTradeData->monSpriteIds[TRADE_PARTNER], gSprites[sTradeData->monSpriteIds[TRADE_PARTNER]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, sTradeData->monSpecies[TRADE_PARTNER]); + CreatePokeballSpriteToReleaseMon(sTradeData->monSpriteIds[TRADE_PARTNER], gSprites[sTradeData->monSpriteIds[TRADE_PARTNER]].oam.paletteNum, 120, 84, 2, 1, 20, PALETTES_BG | (0xF << 16), sTradeData->monSpecies[TRADE_PARTNER]); FreeSpriteOamMatrix(&gSprites[sTradeData->bouncingPokeballSpriteId]); DestroySprite(&gSprites[sTradeData->bouncingPokeballSpriteId]); sTradeData->state++; @@ -4813,7 +4813,7 @@ static void CheckPartnersMonForRibbons(void) { u8 i; u8 numRibbons = 0; - for (i = 0; i < 12; i ++) + for (i = 0; i < (MON_DATA_UNUSED_RIBBONS - MON_DATA_CHAMPION_RIBBON); i ++) { numRibbons += GetMonData(&gEnemyParty[gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE], MON_DATA_CHAMPION_RIBBON + i); } diff --git a/src/tv.c b/src/tv.c index b9d064026..2f3d17ee2 100644 --- a/src/tv.c +++ b/src/tv.c @@ -373,21 +373,21 @@ static const u8 *const sTV3CheersForPokeblocksTextGroup[] = { }; static const u8 *const sTVBravoTrainerBattleTowerTextGroup[] = { - gTVBravoTrainerBattleTowerText00, - gTVBravoTrainerBattleTowerText01, - gTVBravoTrainerBattleTowerText02, - gTVBravoTrainerBattleTowerText03, - gTVBravoTrainerBattleTowerText04, - gTVBravoTrainerBattleTowerText05, - gTVBravoTrainerBattleTowerText06, - gTVBravoTrainerBattleTowerText07, - gTVBravoTrainerBattleTowerText08, - gTVBravoTrainerBattleTowerText09, - gTVBravoTrainerBattleTowerText10, - gTVBravoTrainerBattleTowerText11, - gTVBravoTrainerBattleTowerText12, - gTVBravoTrainerBattleTowerText13, - gTVBravoTrainerBattleTowerText14 + [BRAVOTOWER_STATE_INTRO] = BravoTrainerBattleTower_Text_Intro, + [BRAVOTOWER_STATE_NEW_RECORD] = BravoTrainerBattleTower_Text_NewRecord, + [BRAVOTOWER_STATE_LOST] = BravoTrainerBattleTower_Text_Lost, + [BRAVOTOWER_STATE_WON] = BravoTrainerBattleTower_Text_Won, + [BRAVOTOWER_STATE_LOST_FINAL] = BravoTrainerBattleTower_Text_LostFinal, + [BRAVOTOWER_STATE_SATISFIED] = BravoTrainerBattleTower_Text_Satisfied, + [BRAVOTOWER_STATE_UNSATISFIED] = BravoTrainerBattleTower_Text_Unsatisfied, + [BRAVOTOWER_STATE_UNUSED_1] = BravoTrainerBattleTower_Text_None1, + [BRAVOTOWER_STATE_UNUSED_2] = BravoTrainerBattleTower_Text_None2, + [BRAVOTOWER_STATE_UNUSED_3] = BravoTrainerBattleTower_Text_None3, + [BRAVOTOWER_STATE_UNUSED_4] = BravoTrainerBattleTower_Text_None4, + [BRAVOTOWER_STATE_RESPONSE] = BravoTrainerBattleTower_Text_Response, + [BRAVOTOWER_STATE_RESPONSE_SATISFIED] = BravoTrainerBattleTower_Text_ResponseSatisfied, + [BRAVOTOWER_STATE_RESPONSE_UNSATISFIED] = BravoTrainerBattleTower_Text_ResponseUnsatisfied, + [BRAVOTOWER_STATE_OUTRO] = BravoTrainerBattleTower_Text_Outro }; static const u8 *const sTVContestLiveUpdatesTextGroup[] = { @@ -723,7 +723,7 @@ static const u8 *const sTVInSearchOfTrainersTextGroup[] = { // Secret Base Secrets TV Show states for actions that can be taken in a secret base // The flags that determine whether or not the action was taken are commented -const u8 sTVSecretBaseSecretsActions[NUM_SECRET_BASE_FLAGS] = +static const u8 sTVSecretBaseSecretsActions[NUM_SECRET_BASE_FLAGS] = { SBSECRETS_STATE_USED_CHAIR, // SECRET_BASE_USED_CHAIR SBSECRETS_STATE_USED_BALLOON, // SECRET_BASE_USED_BALLOON @@ -1449,7 +1449,7 @@ static void InterviewAfter_BravoTrainerPokemonProfile(void) } } -void BravoTrainerPokemonProfile_BeforeInterview1(u16 a0) +void BravoTrainerPokemonProfile_BeforeInterview1(u16 move) { TVShow *show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; InterviewBefore_BravoTrainerPkmnProfile(); @@ -1457,7 +1457,7 @@ void BravoTrainerPokemonProfile_BeforeInterview1(u16 a0) if (sCurTVShowSlot != -1) { DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, LAST_TVSHOW_IDX); - show->bravoTrainer.move = a0; + show->bravoTrainer.move = move; show->bravoTrainer.kind = TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE; } } @@ -1490,9 +1490,9 @@ static void InterviewAfter_BravoTrainerBattleTowerProfile(void) show->bravoTrainerTower.numFights = GetCurrentBattleTowerWinStreak(gSaveBlock2Ptr->frontier.towerLvlMode, 0); show->bravoTrainerTower.wonTheChallenge = gSaveBlock2Ptr->frontier.towerBattleOutcome; if (gSaveBlock2Ptr->frontier.towerLvlMode == FRONTIER_LVL_50) - show->bravoTrainerTower.btLevel = 50; + show->bravoTrainerTower.btLevel = FRONTIER_MAX_LEVEL_50; else - show->bravoTrainerTower.btLevel = 100; + show->bravoTrainerTower.btLevel = FRONTIER_MAX_LEVEL_OPEN; show->bravoTrainerTower.interviewResponse = gSpecialVar_0x8004; StorePlayerIdInNormalShow(show); show->bravoTrainerTower.language = gGameLanguage; @@ -4371,6 +4371,9 @@ static void DoTVShowBravoTrainerPokemonProfile(void) ShowFieldMessage(sTVBravoTrainerTextGroup[state]); } +// This is the TV show triggered by accepting the reporter's interview in the lobby of Battle Tower. +// The reporter had asked the player if they were satisfied or not with the challenge, and then asked +// for a one word Easy Chat description of their feelings about the challenge. static void DoTVShowBravoTrainerBattleTower(void) { TVShow *show; @@ -4381,85 +4384,83 @@ static void DoTVShowBravoTrainerBattleTower(void) state = sTVShowState; switch(state) { - case 0: + case BRAVOTOWER_STATE_INTRO: TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.species]); - if (show->bravoTrainerTower.numFights >= 7) - sTVShowState = 1; + if (show->bravoTrainerTower.numFights >= FRONTIER_STAGES_PER_CHALLENGE) + sTVShowState = BRAVOTOWER_STATE_NEW_RECORD; else - sTVShowState = 2; + sTVShowState = BRAVOTOWER_STATE_LOST; break; - case 1: - if (show->bravoTrainerTower.btLevel == 50) - { + case BRAVOTOWER_STATE_NEW_RECORD: + // The TV show states a "new record" was achieved as long as all the battles in the challenge were attempted, + // regardless of any previous records or whether the final battle was won or lost. + if (show->bravoTrainerTower.btLevel == FRONTIER_MAX_LEVEL_50) StringCopy(gStringVar1, gText_Lv50); - } else - { StringCopy(gStringVar1, gText_OpenLevel); - } ConvertIntToDecimalString(1, show->bravoTrainerTower.numFights); if (show->bravoTrainerTower.wonTheChallenge == TRUE) - sTVShowState = 3; + sTVShowState = BRAVOTOWER_STATE_WON; else - sTVShowState = 4; + sTVShowState = BRAVOTOWER_STATE_LOST_FINAL; break; - case 2: + case BRAVOTOWER_STATE_LOST: TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); ConvertIntToDecimalString(1, show->bravoTrainerTower.numFights + 1); if (show->bravoTrainerTower.interviewResponse == 0) - sTVShowState = 5; + sTVShowState = BRAVOTOWER_STATE_SATISFIED; else - sTVShowState = 6; + sTVShowState = BRAVOTOWER_STATE_UNSATISFIED; break; - case 3: + case BRAVOTOWER_STATE_WON: TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.defeatedSpecies]); if (show->bravoTrainerTower.interviewResponse == 0) - sTVShowState = 5; + sTVShowState = BRAVOTOWER_STATE_SATISFIED; else - sTVShowState = 6; + sTVShowState = BRAVOTOWER_STATE_UNSATISFIED; break; - case 4: + case BRAVOTOWER_STATE_LOST_FINAL: TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.defeatedSpecies]); if (show->bravoTrainerTower.interviewResponse == 0) - sTVShowState = 5; + sTVShowState = BRAVOTOWER_STATE_SATISFIED; else - sTVShowState = 6; + sTVShowState = BRAVOTOWER_STATE_UNSATISFIED; break; - case 5: + case BRAVOTOWER_STATE_SATISFIED: TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); - sTVShowState = 11; + sTVShowState = BRAVOTOWER_STATE_RESPONSE; break; - case 6: + case BRAVOTOWER_STATE_UNSATISFIED: TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); - sTVShowState = 11; + sTVShowState = BRAVOTOWER_STATE_RESPONSE; break; - case 7: - sTVShowState = 11; + case BRAVOTOWER_STATE_UNUSED_1: + sTVShowState = BRAVOTOWER_STATE_RESPONSE; break; - case 8: - case 9: - case 10: + case BRAVOTOWER_STATE_UNUSED_2: + case BRAVOTOWER_STATE_UNUSED_3: + case BRAVOTOWER_STATE_UNUSED_4: TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); - sTVShowState = 11; + sTVShowState = BRAVOTOWER_STATE_RESPONSE; break; - case 11: + case BRAVOTOWER_STATE_RESPONSE: CopyEasyChatWord(gStringVar1, show->bravoTrainerTower.words[0]); if (show->bravoTrainerTower.interviewResponse == 0) - sTVShowState = 12; + sTVShowState = BRAVOTOWER_STATE_RESPONSE_SATISFIED; else - sTVShowState = 13; + sTVShowState = BRAVOTOWER_STATE_RESPONSE_UNSATISFIED; break; - case 12: - case 13: + case BRAVOTOWER_STATE_RESPONSE_SATISFIED: + case BRAVOTOWER_STATE_RESPONSE_UNSATISFIED: CopyEasyChatWord(gStringVar1, show->bravoTrainerTower.words[0]); TVShowConvertInternationalString(gStringVar2, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); TVShowConvertInternationalString(gStringVar3, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); - sTVShowState = 14; + sTVShowState = BRAVOTOWER_STATE_OUTRO; break; - case 14: + case BRAVOTOWER_STATE_OUTRO: TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.species]); TVShowDone(); diff --git a/src/union_room.c b/src/union_room.c index 9a743dbab..05b41a088 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -4318,7 +4318,7 @@ static bool32 HasAtLeastTwoMonsOfLevel30OrLower(void) for (i = 0; i < gPlayerPartyCount; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) <= 30 + if (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) <= UNION_ROOM_MAX_LEVEL && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) count++; } diff --git a/src/union_room_chat.c b/src/union_room_chat.c index 9890bc1f8..f8513b9f4 100755 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -2160,8 +2160,7 @@ static bool32 IsDisplaySubtask0Active(void) static void FreeDisplay(void) { FreeSprites(); - if (sDisplay) - FREE_AND_SET_NULL(sDisplay); + TRY_FREE_AND_SET_NULL(sDisplay); FreeAllWindowBuffers(); gScanlineEffect.state = 3; diff --git a/tools/mid2agb/agb.cpp b/tools/mid2agb/agb.cpp index d4d79f133..caa6f0ecd 100644 --- a/tools/mid2agb/agb.cpp +++ b/tools/mid2agb/agb.cpp @@ -18,6 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#include #include #include #include @@ -503,7 +504,7 @@ void PrintAgbTrack(std::vector& events) ResetTrackVars(); break; case EventType::Tempo: - PrintByte("TEMPO , %u*%s_tbs/2", 60000000 / event.param2, g_asmLabel.c_str()); + PrintByte("TEMPO , %u*%s_tbs/2", static_cast(round(60000000.0f / static_cast(event.param2))), g_asmLabel.c_str()); PrintWait(event.time); break; case EventType::InstrumentChange: