diff --git a/common_syms/battle_factory_screen.txt b/common_syms/battle_factory_screen.txt index 9f6868139..3ddeb6d3b 100644 --- a/common_syms/battle_factory_screen.txt +++ b/common_syms/battle_factory_screen.txt @@ -1 +1 @@ -gUnknown_030062E8 +gFactorySelect_CurrentOptionFunc diff --git a/constants/m4a_constants.inc b/constants/m4a_constants.inc index 08d888acd..1a744dc7f 100644 --- a/constants/m4a_constants.inc +++ b/constants/m4a_constants.inc @@ -1,6 +1,7 @@ .equiv ID_NUMBER, 0x68736d53 .equiv PCM_DMA_BUF_SIZE, 1584 + .equiv MAX_DIRECTSOUND_CHANNELS, 12 .equiv C_V, 0x40 @@ -93,7 +94,7 @@ struct_field o_SoundInfo_plynote, 4 struct_field o_SoundInfo_ExtVolPit, 4 struct_field o_SoundInfo_gap2, 16 - struct_field o_SoundInfo_chans, 768 + struct_field o_SoundInfo_chans, MAX_DIRECTSOUND_CHANNELS * 64 struct_field o_SoundInfo_pcmBuffer, PCM_DMA_BUF_SIZE * 2 struct_field SoundInfo_size, 0 diff --git a/data/battle_ai_scripts.s b/data/battle_ai_scripts.s index d1dd1caed..56be92c5e 100644 --- a/data/battle_ai_scripts.s +++ b/data/battle_ai_scripts.s @@ -462,18 +462,18 @@ AI_CBM_Attract: @ 82DC5F5 get_ability AI_TARGET if_equal ABILITY_OBLIVIOUS, Score_Minus10 get_gender AI_USER - if_equal 0, AI_CBM_Attract_CheckIfTargetIsFemale - if_equal 254, AI_CBM_Attract_CheckIfTargetIsMale + if_equal MON_MALE, AI_CBM_Attract_CheckIfTargetIsFemale + if_equal MON_FEMALE, AI_CBM_Attract_CheckIfTargetIsMale goto Score_Minus10 AI_CBM_Attract_CheckIfTargetIsFemale: @ 82DC61A get_gender AI_TARGET - if_equal 254, AI_CBM_Attract_End + if_equal MON_FEMALE, AI_CBM_Attract_End goto Score_Minus10 AI_CBM_Attract_CheckIfTargetIsMale: @ 82DC627 get_gender AI_TARGET - if_equal 0, AI_CBM_Attract_End + if_equal MON_MALE, AI_CBM_Attract_End goto Score_Minus10 AI_CBM_Attract_End: @ 82DC634 @@ -2057,12 +2057,22 @@ AI_CV_Protect_ScoreDown2: AI_CV_Protect_End: end +@ BUG: Foresight is only encouraged if the user is Ghost type or +@ has high evasion, but should check target instead AI_CV_Foresight: +.ifdef BUGFIX + get_target_type1 + if_equal TYPE_GHOST, AI_CV_Foresight2 + get_target_type2 + if_equal TYPE_GHOST, AI_CV_Foresight2 + if_stat_level_more_than AI_TARGET, STAT_EVASION, 8, AI_CV_Foresight3 +.else get_user_type1 if_equal TYPE_GHOST, AI_CV_Foresight2 get_user_type2 if_equal TYPE_GHOST, AI_CV_Foresight2 if_stat_level_more_than AI_USER, STAT_EVASION, 8, AI_CV_Foresight3 +.endif score -2 goto AI_CV_Foresight_End @@ -2329,13 +2339,13 @@ AI_CV_SemiInvulnerable2: if_status2 AI_TARGET, STATUS2_CURSED, AI_CV_SemiInvulnerable_TryEncourage if_status3 AI_TARGET, STATUS3_LEECHSEED, AI_CV_SemiInvulnerable_TryEncourage get_weather - .ifdef BUGFIX +.ifdef BUGFIX if_equal AI_WEATHER_HAIL, AI_CV_SemiInvulnerable_CheckIceType if_equal AI_WEATHER_SANDSTORM, AI_CV_SemiInvulnerable_CheckSandstormTypes - .else +.else if_equal AI_WEATHER_HAIL, AI_CV_SemiInvulnerable_CheckSandstormTypes if_equal AI_WEATHER_SANDSTORM, AI_CV_SemiInvulnerable_CheckIceType - .endif +.endif goto AI_CV_SemiInvulnerable5 AI_CV_SemiInvulnerable_CheckSandstormTypes: @@ -2404,11 +2414,11 @@ AI_CV_Hail_End: @ BUG: Facade score is increased if the target is statused, but should be if the user is AI_CV_Facade: - .ifdef BUGFIX +.ifdef BUGFIX if_not_status AI_USER, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, AI_CV_Facade_End - .else +.else if_not_status AI_TARGET, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, AI_CV_Facade_End - .endif +.endif score +1 AI_CV_Facade_End: end diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index b4bb33993..2344007a5 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -374,41 +374,41 @@ gBattleAnims_Moves:: .align 2 gBattleAnims_StatusConditions:: - .4byte Status_Poison - .4byte Status_Confusion - .4byte Status_Burn - .4byte Status_Infatuation - .4byte Status_Sleep - .4byte Status_Paralysis - .4byte Status_Freeze - .4byte Status_Curse - .4byte Status_Nightmare + .4byte Status_Poison @ B_ANIM_STATUS_PSN + .4byte Status_Confusion @ B_ANIM_STATUS_CONFUSION + .4byte Status_Burn @ B_ANIM_STATUS_BRN + .4byte Status_Infatuation @ B_ANIM_STATUS_INFATUATION + .4byte Status_Sleep @ B_ANIM_STATUS_SLP + .4byte Status_Paralysis @ B_ANIM_STATUS_PRZ + .4byte Status_Freeze @ B_ANIM_STATUS_FRZ + .4byte Status_Curse @ B_ANIM_STATUS_CURSED + .4byte Status_Nightmare @ B_ANIM_STATUS_NIGHTMARE .align 2 gBattleAnims_General:: - .4byte General_CastformChange - .4byte General_StatsChange - .4byte General_SubstituteFade - .4byte General_SubstituteAppear - .4byte General_PokeblockThrow - .4byte General_ItemKnockoff - .4byte General_TurnTrap - .4byte General_HeldItemEffect - .4byte General_SmokeballEscape - .4byte General_FocusBand - .4byte General_Rain - .4byte General_Sun - .4byte General_Sandstorm - .4byte General_Hail - .4byte General_LeechSeedDrain - .4byte General_MonHit - .4byte General_ItemSteal - .4byte General_SnatchMove - .4byte General_FutureSightHit - .4byte General_DoomDesireHit - .4byte General_FocusPunchSetUp - .4byte General_IngrainHeal - .4byte General_WishHeal + .4byte General_CastformChange @ B_ANIM_CASTFORM_CHANGE + .4byte General_StatsChange @ B_ANIM_STATS_CHANGE + .4byte General_SubstituteFade @ B_ANIM_SUBSTITUTE_FADE + .4byte General_SubstituteAppear @ B_ANIM_SUBSTITUTE_APPEAR + .4byte General_PokeblockThrow @ B_ANIM_POKEBLOCK_THROW + .4byte General_ItemKnockoff @ B_ANIM_ITEM_KNOCKOFF + .4byte General_TurnTrap @ B_ANIM_TURN_TRAP + .4byte General_HeldItemEffect @ B_ANIM_HELD_ITEM_EFFECT + .4byte General_SmokeballEscape @ B_ANIM_SMOKEBALL_ESCAPE + .4byte General_FocusBand @ B_ANIM_FOCUS_BAND + .4byte General_Rain @ B_ANIM_RAIN_CONTINUES + .4byte General_Sun @ B_ANIM_SUN_CONTINUES + .4byte General_Sandstorm @ B_ANIM_SANDSTORM_CONTINUES + .4byte General_Hail @ B_ANIM_HAIL_CONTINUES + .4byte General_LeechSeedDrain @ B_ANIM_LEECH_SEED_DRAIN + .4byte General_MonHit @ B_ANIM_MON_HIT + .4byte General_ItemSteal @ B_ANIM_ITEM_STEAL + .4byte General_SnatchMove @ B_ANIM_SNATCH_MOVE + .4byte General_FutureSightHit @ B_ANIM_FUTURE_SIGHT_HIT + .4byte General_DoomDesireHit @ B_ANIM_DOOM_DESIRE_HIT + .4byte General_FocusPunchSetUp @ B_ANIM_FOCUS_PUNCH_SETUP + .4byte General_IngrainHeal @ B_ANIM_INGRAIN_HEAL + .4byte General_WishHeal @ B_ANIM_WISH_HEAL .align 2 gBattleAnims_Special:: diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 873425c63..1c3f3ea5b 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2860,7 +2860,7 @@ BattleScript_FaintedMonTryChooseAnother:: switchhandleorder BS_FAINTED, 0x2 jumpifnotbattletype BATTLE_TYPE_TRAINER, BattleScript_FaintedMonChooseAnother jumpifbattletype BATTLE_TYPE_LINK, BattleScript_FaintedMonChooseAnother - jumpifbattletype BATTLE_TYPE_x2000000, BattleScript_FaintedMonChooseAnother + jumpifbattletype BATTLE_TYPE_RECORDED_LINK, BattleScript_FaintedMonChooseAnother jumpifbattletype BATTLE_TYPE_FRONTIER, BattleScript_FaintedMonChooseAnother jumpifbattletype BATTLE_TYPE_DOUBLE, BattleScript_FaintedMonChooseAnother jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_x400000, BattleScript_FaintedMonChooseAnother @@ -2978,7 +2978,7 @@ BattleScript_LocalBattleLostPrintTrainersWinText:: trainerslidein BS_ATTACKER waitstate printstring STRINGID_TRAINER1WINTEXT - jumpifbattletype BATTLE_TYPE_x800000, BattleScript_LocalBattleLostDoTrainer2WinText + jumpifbattletype BATTLE_TYPE_TOWER_LINK_MULTI, BattleScript_LocalBattleLostDoTrainer2WinText jumpifnotbattletype BATTLE_TYPE_TWO_OPPONENTS, BattleScript_LocalBattleLostEnd_ BattleScript_LocalBattleLostDoTrainer2WinText:: trainerslideout B_POSITION_OPPONENT_LEFT @@ -3834,7 +3834,7 @@ BattleScript_MoveUsedIsConfusedNoMore:: return BattleScript_PrintPayDayMoneyString:: - printstring STRINGID_PKMNPICKEDUPITEM + printstring STRINGID_PLAYERPICKEDUPMONEY waitmessage 0x40 return diff --git a/data/maps/BattleFrontier_BattleFactoryPreBattleRoom/scripts.inc b/data/maps/BattleFrontier_BattleFactoryPreBattleRoom/scripts.inc index 48d2bcc3a..e85697146 100644 --- a/data/maps/BattleFrontier_BattleFactoryPreBattleRoom/scripts.inc +++ b/data/maps/BattleFrontier_BattleFactoryPreBattleRoom/scripts.inc @@ -168,7 +168,7 @@ BattleFrontier_BattleFactoryPreBattleRoom_EventScript_SwapMons:: @ 8259DF2 fadescreen FADE_TO_BLACK factory_swapmons waitstate - compare VAR_RESULT, 1 + compare VAR_RESULT, TRUE @ Did player keep current pokemon goto_if_eq BattleFrontier_BattleFactoryPreBattleRoom_EventScript_EnterBattleRoom factory_setswapped msgbox BattleFrontier_BattleFactoryPreBattleRoom_Text_YourSwapIsComplete, MSGBOX_DEFAULT diff --git a/data/maps/CaveOfOrigin_1F/scripts.inc b/data/maps/CaveOfOrigin_1F/scripts.inc index de1d979d4..943a9e9ed 100644 --- a/data/maps/CaveOfOrigin_1F/scripts.inc +++ b/data/maps/CaveOfOrigin_1F/scripts.inc @@ -3,5 +3,5 @@ CaveOfOrigin_1F_MapScripts:: @ 8235768 .byte 0 CaveOfOrigin_1F_OnTransition: @ 823576E - call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_SetTempVars + call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_DisableTriggers end diff --git a/data/maps/CaveOfOrigin_UnusedRubySapphireMap1/scripts.inc b/data/maps/CaveOfOrigin_UnusedRubySapphireMap1/scripts.inc index 326ea21e3..9f3fefdeb 100644 --- a/data/maps/CaveOfOrigin_UnusedRubySapphireMap1/scripts.inc +++ b/data/maps/CaveOfOrigin_UnusedRubySapphireMap1/scripts.inc @@ -3,5 +3,5 @@ CaveOfOrigin_UnusedRubySapphireMap1_MapScripts:: @ 8235778 .byte 0 CaveOfOrigin_UnusedRubySapphireMap1_OnTransition: @ 823577E - call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_SetTempVars + call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_DisableTriggers end diff --git a/data/maps/CaveOfOrigin_UnusedRubySapphireMap2/scripts.inc b/data/maps/CaveOfOrigin_UnusedRubySapphireMap2/scripts.inc index 5e92a7d45..60b1f0cca 100644 --- a/data/maps/CaveOfOrigin_UnusedRubySapphireMap2/scripts.inc +++ b/data/maps/CaveOfOrigin_UnusedRubySapphireMap2/scripts.inc @@ -3,6 +3,6 @@ CaveOfOrigin_UnusedRubySapphireMap2_MapScripts:: @ 8235788 .byte 0 CaveOfOrigin_UnusedRubySapphireMap2_OnTransition: @ 823578E - call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_SetTempVars + call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_DisableTriggers end diff --git a/data/maps/CaveOfOrigin_UnusedRubySapphireMap3/scripts.inc b/data/maps/CaveOfOrigin_UnusedRubySapphireMap3/scripts.inc index 2f0e2b66c..e30b50cbe 100644 --- a/data/maps/CaveOfOrigin_UnusedRubySapphireMap3/scripts.inc +++ b/data/maps/CaveOfOrigin_UnusedRubySapphireMap3/scripts.inc @@ -3,6 +3,6 @@ CaveOfOrigin_UnusedRubySapphireMap3_MapScripts:: @ 8235798 .byte 0 CaveOfOrigin_UnusedRubySapphireMap3_OnTransition: @ 823579E - call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_SetTempVars + call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_DisableTriggers end diff --git a/data/script_cmd_table.inc b/data/script_cmd_table.inc index 0971358a1..7edb5c4b7 100644 --- a/data/script_cmd_table.inc +++ b/data/script_cmd_table.inc @@ -209,7 +209,7 @@ gScriptCmdTable:: @ 81DB67C .4byte ScrCmd_checkmonobedience @ 0xce .4byte ScrCmd_gotoram @ 0xcf .4byte ScrCmd_nop1 @ 0xd0 - .4byte ScrCmd_warpD1 @ 0xd1 + .4byte ScrCmd_warpspinenter @ 0xd1 .4byte ScrCmd_setmonmetlocation @ 0xd2 .4byte ScrCmd_moverotatingtileobjects @ 0xd3 .4byte ScrCmd_turnrotatingtileobjects @ 0xd4 diff --git a/data/scripts/cave_of_origin.inc b/data/scripts/cave_of_origin.inc index 52a1da84f..579efdb89 100644 --- a/data/scripts/cave_of_origin.inc +++ b/data/scripts/cave_of_origin.inc @@ -36,7 +36,7 @@ CaveOfOrigin_EventScript_Shake:: @ 82722A7 releaseall end -CaveOfOrigin_EventScript_SetTempVars:: @ 82722C1 +CaveOfOrigin_EventScript_DisableTriggers:: @ 82722C1 setvar VAR_TEMP_1, 1 setvar VAR_TEMP_2, 1 setvar VAR_TEMP_3, 1 diff --git a/data/scripts/pkmn_center_nurse.inc b/data/scripts/pkmn_center_nurse.inc index a26e9e22a..6b4bbe2ef 100644 --- a/data/scripts/pkmn_center_nurse.inc +++ b/data/scripts/pkmn_center_nurse.inc @@ -65,7 +65,7 @@ EventScript_PkmnCenterNurse_ReturnPkmn:: @ 82719E2 goto_if_eq EventScript_PkmnCenterNurse_ReturnPkmn2 message gText_RestoredPkmnToFullHealth waitmessage - applymovement VAR_0x800B, EventScript_PkmnCenterNurse_Bow + applymovement VAR_0x800B, Movement_PkmnCenterNurse_Bow waitmovement 0 message gText_WeHopeToSeeYouAgain return @@ -73,7 +73,7 @@ EventScript_PkmnCenterNurse_ReturnPkmn:: @ 82719E2 EventScript_PkmnCenterNurse_ReturnPkmn2:: @ 8271A03 message gText_ThankYouForWaiting waitmessage - applymovement VAR_0x800B, EventScript_PkmnCenterNurse_Bow + applymovement VAR_0x800B, Movement_PkmnCenterNurse_Bow waitmovement 0 message gText_WeHopeToSeeYouAgain2 return @@ -84,7 +84,7 @@ EventScript_PkmnCenterNurse_PlayerWaitingInUnionRoom:: @ 8271A19 setflag FLAG_NURSE_UNION_ROOM_REMINDER message CableClub_Text_PlayerIsWaiting waitmessage - applymovement VAR_0x800B, EventScript_PkmnCenterNurse_Bow + applymovement VAR_0x800B, Movement_PkmnCenterNurse_Bow waitmovement 0 message gText_WeHopeToSeeYouAgain return @@ -129,7 +129,7 @@ EventScript_PkmnCenterNurse_GoldCardHealPkmn:: @ 8271AC5 goto EventScript_PkmnCenterNurse_HealPkmn end -EventScript_PkmnCenterNurse_Bow: @ 8271AD0 +Movement_PkmnCenterNurse_Bow: @ 8271AD0 nurse_joy_bow delay_4 step_end diff --git a/data/scripts/record_mix.inc b/data/scripts/record_mix.inc index 23f224ae4..e058816ab 100644 --- a/data/scripts/record_mix.inc +++ b/data/scripts/record_mix.inc @@ -6,16 +6,15 @@ EventScript_MixRecordsPrompt:: @ 8271D5E compare VAR_RESULT, YES goto_if_eq EventScript_MixRecords compare VAR_RESULT, NO - goto_if_eq EventScript_DeclineMixRecords - goto EventScript_DeclineMixRecords + goto_if_eq EventScript_EndMixRecords + goto EventScript_EndMixRecords EventScript_MixRecords:: @ 8271D83 special RecordMixingPlayerSpotTriggered waitstate lock faceplayer - -EventScript_DeclineMixRecords:: @ 8271D89 +EventScript_EndMixRecords:: @ 8271D89 message Text_WeHopeToSeeYouAgain waitmessage waitbuttonpress diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 285718598..ce06c1489 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -1,7 +1,7 @@ # 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` preprocessor variable will fix some of these automatically. +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: @@ -13,55 +13,9 @@ Fixes are written in the `diff` format. If you've used Git before, this should l ## Contents -- [RNG does not get seeded](#rng-does-not-get-seeded) - [Scrolling through items in the bag causes the image to flicker](#scrolling-through-items-in-the-bag-causes-the-image-to-flicker) -## RNG does not get seeded - -**Fix:** Add the following function to [src/main.c](https://github.com/pret/pokeemerald/blob/master/src/main.c): -```diff -+static void SeedRngWithRtc(void) -+{ -+ u32 seed = RtcGetMinuteCount(); -+ seed = (seed >> 16) ^ (seed & 0xFFFF); -+ SeedRng(seed); -+} -``` - -And edit `AgbMain`: - -```diff - ... - RtcInit(); - CheckForFlashMemory(); - InitMainCallbacks(); - InitMapMusic(); -+ SeedRngWithRtc(); - ClearDma3Requests(); - ... -``` - -This restores the code of Ruby/Sapphire. - -**Alternate Fix:** Edit the following function in [src/title_screen.c](https://github.com/pret/pokeemerald/blob/master/src/title_screen.c): - -```diff -void CB2_InitTitleScreen(void) -{ - switch (gMain.state) - { - default: - case 0: - SetVBlankCallback(NULL); -+ StartTimer1(); - SetGpuReg(REG_OFFSET_BLDCNT, 0); - SetGpuReg(REG_OFFSET_BLDALPHA, 0); - SetGpuReg(REG_OFFSET_BLDY, 0); - ... -``` -This matches what FRLG does and obtains the seed differently than RS, independently of the RTC. - ## 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): @@ -89,27 +43,9 @@ Then edit `BagMenu_MoveCursorCallback` in [src/item_menu.c](https://github.com/p ```diff ... { -- RemoveBagItemIconSprite(1 ^ gBagMenu->unk81B_1); -+ HideBagItemIconSprite(gBagMenu->unk81B_1 ^ 1); -+ RemoveBagItemIconSprite(gBagMenu->unk81B_1); - if (a != -2) +- RemoveBagItemIconSprite(1 ^ gBagMenu->itemIconSlot); ++ HideBagItemIconSprite(gBagMenu->itemIconSlot ^ 1); ++ RemoveBagItemIconSprite(gBagMenu->itemIconSlot); + if (itemIndex != LIST_CANCEL) ... ``` - -## Pokémon that have an affine transform as part of their entry animation glitch when going in and out of Poké Balls without a screen transition in between - -**Fix:** Edit `sub_817F77C` in [src/pokemon_animation.c](https://github.com/pret/pokeemerald/blob/master/src/pokemon_animation.c#L1028): - -```diff - ... --#ifdef BUGFIX - else - { - // FIX: Reset these back to normal after they were changed so Poké Ball catch/release - // animations without a screen transition in between don't break - sprite->affineAnimPaused = FALSE; - sprite->affineAnims = gUnknown_082FF694; - } --#endif // BUGFIX -} -``` diff --git a/gflib/malloc.c b/gflib/malloc.c index 4d1a9fe5c..38fc8939e 100644 --- a/gflib/malloc.c +++ b/gflib/malloc.c @@ -2,7 +2,7 @@ static void *sHeapStart; static u32 sHeapSize; -static u32 malloc_c_unused_0300000c; // needed to align dma3_manager.o(.bss) +static u32 sFiller; // needed to align dma3_manager.o(.bss) #define MALLOC_SYSTEM_ID 0xA3A3 diff --git a/gflib/sprite.c b/gflib/sprite.c index c7e3d09a3..2616aeaed 100644 --- a/gflib/sprite.c +++ b/gflib/sprite.c @@ -1320,6 +1320,11 @@ void ApplyAffineAnimFrameRelativeAndUpdateMatrix(u8 matrixNum, struct AffineAnim s16 ConvertScaleParam(s16 scale) { s32 val = 0x10000; + // UB: possible division by zero +#ifdef UBFIX + if (scale == 0) + return 0; +#endif //UBFIX return val / scale; } diff --git a/gflib/text.c b/gflib/text.c index 4cbad1376..ffce2cb56 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -165,7 +165,6 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, voi { int i; u16 j; - u8 *ptr; if (!gFonts) return FALSE; @@ -1235,7 +1234,6 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) bool8 isJapanese; int minGlyphWidth; u32 (*func)(u16 glyphId, bool32 isJapanese); - s32 result; int localLetterSpacing; u32 lineWidth; const u8 *bufferPointer; diff --git a/graphics/battle_anims/sprites/substitute.bin b/graphics/battle_anims/sprites/substitute.bin deleted file mode 100644 index d30c07d4e..000000000 Binary files a/graphics/battle_anims/sprites/substitute.bin and /dev/null differ diff --git a/graphics/battle_anims/sprites/substitute_back.png b/graphics/battle_anims/sprites/substitute_back.png new file mode 100644 index 000000000..8ea1f7ff8 Binary files /dev/null and b/graphics/battle_anims/sprites/substitute_back.png differ diff --git a/graphics/battle_frontier/factory_screen/action_box_left.png b/graphics/battle_frontier/factory_screen/action_box_left.png new file mode 100644 index 000000000..c4c943a15 Binary files /dev/null and b/graphics/battle_frontier/factory_screen/action_box_left.png differ diff --git a/graphics/battle_frontier/factory_screen/action_box_right.png b/graphics/battle_frontier/factory_screen/action_box_right.png new file mode 100644 index 000000000..984244660 Binary files /dev/null and b/graphics/battle_frontier/factory_screen/action_box_right.png differ diff --git a/graphics/battle_frontier/factory_screen/action_highlight_left.png b/graphics/battle_frontier/factory_screen/action_highlight_left.png new file mode 100644 index 000000000..873049e64 Binary files /dev/null and b/graphics/battle_frontier/factory_screen/action_highlight_left.png differ diff --git a/graphics/battle_frontier/factory_screen/action_highlight_middle.png b/graphics/battle_frontier/factory_screen/action_highlight_middle.png new file mode 100644 index 000000000..e2bebe11b Binary files /dev/null and b/graphics/battle_frontier/factory_screen/action_highlight_middle.png differ diff --git a/graphics/battle_frontier/factory_screen/action_highlight_right.png b/graphics/battle_frontier/factory_screen/action_highlight_right.png new file mode 100644 index 000000000..e2bebe11b Binary files /dev/null and b/graphics/battle_frontier/factory_screen/action_highlight_right.png differ diff --git a/graphics/battle_frontier/factory_screen/arrow.png b/graphics/battle_frontier/factory_screen/arrow.png new file mode 100644 index 000000000..d0ec83dee Binary files /dev/null and b/graphics/battle_frontier/factory_screen/arrow.png differ diff --git a/graphics/unknown/unknown_60F17C.pal b/graphics/battle_frontier/factory_screen/interface.pal similarity index 100% rename from graphics/unknown/unknown_60F17C.pal rename to graphics/battle_frontier/factory_screen/interface.pal diff --git a/graphics/battle_frontier/factory_screen/menu_highlight_left.png b/graphics/battle_frontier/factory_screen/menu_highlight_left.png new file mode 100644 index 000000000..1c39f7250 Binary files /dev/null and b/graphics/battle_frontier/factory_screen/menu_highlight_left.png differ diff --git a/graphics/battle_frontier/factory_screen/menu_highlight_right.png b/graphics/battle_frontier/factory_screen/menu_highlight_right.png new file mode 100644 index 000000000..9e6800733 Binary files /dev/null and b/graphics/battle_frontier/factory_screen/menu_highlight_right.png differ diff --git a/graphics/unknown/unknown_61023C.bin b/graphics/battle_frontier/factory_screen/mon_pic_bg.bin similarity index 100% rename from graphics/unknown/unknown_61023C.bin rename to graphics/battle_frontier/factory_screen/mon_pic_bg.bin diff --git a/graphics/battle_frontier/factory_screen/mon_pic_bg.png b/graphics/battle_frontier/factory_screen/mon_pic_bg.png new file mode 100644 index 000000000..b72da6f44 Binary files /dev/null and b/graphics/battle_frontier/factory_screen/mon_pic_bg.png differ diff --git a/graphics/battle_frontier/factory_screen/mon_pic_bg_anim.png b/graphics/battle_frontier/factory_screen/mon_pic_bg_anim.png new file mode 100644 index 000000000..324063d0d Binary files /dev/null and b/graphics/battle_frontier/factory_screen/mon_pic_bg_anim.png differ diff --git a/graphics/battle_frontier/factory_screen/pokeball.png b/graphics/battle_frontier/factory_screen/pokeball.png new file mode 100644 index 000000000..b3426fc72 Binary files /dev/null and b/graphics/battle_frontier/factory_screen/pokeball.png differ diff --git a/graphics/unknown/unknown_60F13C.pal b/graphics/battle_frontier/factory_screen/pokeball_gray.pal similarity index 100% rename from graphics/unknown/unknown_60F13C.pal rename to graphics/battle_frontier/factory_screen/pokeball_gray.pal diff --git a/graphics/unknown/unknown_60F15C.pal b/graphics/battle_frontier/factory_screen/pokeball_selected.pal similarity index 100% rename from graphics/unknown/unknown_60F15C.pal rename to graphics/battle_frontier/factory_screen/pokeball_selected.pal diff --git a/graphics/unknown/unknown_61046C.pal b/graphics/battle_frontier/factory_screen/text.pal similarity index 100% rename from graphics/unknown/unknown_61046C.pal rename to graphics/battle_frontier/factory_screen/text.pal diff --git a/graphics/unknown/unknown_60F1BC.png b/graphics/unknown/unknown_60F1BC.png deleted file mode 100644 index 185b93d57..000000000 Binary files a/graphics/unknown/unknown_60F1BC.png and /dev/null differ diff --git a/graphics/unknown/unknown_60F3BC.png b/graphics/unknown/unknown_60F3BC.png deleted file mode 100644 index 3114f2eb8..000000000 Binary files a/graphics/unknown/unknown_60F3BC.png and /dev/null differ diff --git a/graphics/unknown/unknown_60F43C.png b/graphics/unknown/unknown_60F43C.png deleted file mode 100644 index 3c2c1d5cd..000000000 Binary files a/graphics/unknown/unknown_60F43C.png and /dev/null differ diff --git a/graphics/unknown/unknown_60F53C.png b/graphics/unknown/unknown_60F53C.png deleted file mode 100644 index 65450c7b3..000000000 Binary files a/graphics/unknown/unknown_60F53C.png and /dev/null differ diff --git a/graphics/unknown/unknown_60F63C.png b/graphics/unknown/unknown_60F63C.png deleted file mode 100644 index 01fcea2fa..000000000 Binary files a/graphics/unknown/unknown_60F63C.png and /dev/null differ diff --git a/graphics/unknown/unknown_60F6BC.png b/graphics/unknown/unknown_60F6BC.png deleted file mode 100644 index bda46587f..000000000 Binary files a/graphics/unknown/unknown_60F6BC.png and /dev/null differ diff --git a/graphics/unknown/unknown_60F7BC.png b/graphics/unknown/unknown_60F7BC.png deleted file mode 100644 index 487b428bd..000000000 Binary files a/graphics/unknown/unknown_60F7BC.png and /dev/null differ diff --git a/graphics/unknown/unknown_60F83C.png b/graphics/unknown/unknown_60F83C.png deleted file mode 100644 index 2a44e9455..000000000 Binary files a/graphics/unknown/unknown_60F83C.png and /dev/null differ diff --git a/graphics/unknown/unknown_60F93C.png b/graphics/unknown/unknown_60F93C.png deleted file mode 100644 index 2a44e9455..000000000 Binary files a/graphics/unknown/unknown_60F93C.png and /dev/null differ diff --git a/graphics/unknown/unknown_60FA3C.png b/graphics/unknown/unknown_60FA3C.png deleted file mode 100644 index c4ae096d0..000000000 Binary files a/graphics/unknown/unknown_60FA3C.png and /dev/null differ diff --git a/graphics/unknown/unknown_61033C.png b/graphics/unknown/unknown_61033C.png deleted file mode 100644 index ec874f98c..000000000 Binary files a/graphics/unknown/unknown_61033C.png and /dev/null differ diff --git a/graphics/unknown/unknown_61039C.pal b/graphics/unknown/unknown_61039C.pal deleted file mode 100644 index 89f527ce4..000000000 --- a/graphics/unknown/unknown_61039C.pal +++ /dev/null @@ -1,19 +0,0 @@ -JASC-PAL -0100 -16 -0 0 0 -213 255 238 -213 255 238 -213 255 238 -213 255 238 -213 255 238 -213 255 238 -213 255 238 -213 255 238 -213 255 238 -213 255 238 -213 255 238 -213 255 238 -213 255 238 -213 255 238 -213 255 238 diff --git a/include/battle_controllers.h b/include/battle_controllers.h index 32918fefb..5b1ada11a 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -85,8 +85,8 @@ enum struct UnusedControllerStruct { - u8 field_0:7; - u8 flag_x80:1; + u8 unk:7; + u8 flag:1; }; struct HpAndStatus @@ -145,19 +145,19 @@ enum CONTROLLER_STATUSXOR, CONTROLLER_DATATRANSFER, CONTROLLER_DMA3TRANSFER, - CONTROLLER_31, + CONTROLLER_PLAYBGM, CONTROLLER_32, CONTROLLER_TWORETURNVALUES, CONTROLLER_CHOSENMONRETURNVALUE, CONTROLLER_ONERETURNVALUE, CONTROLLER_ONERETURNVALUE_DUPLICATE, - CONTROLLER_37, - CONTROLLER_38, - CONTROLLER_39, - CONTROLLER_40, + CONTROLLER_CLEARUNKVAR, + CONTROLLER_SETUNKVAR, + CONTROLLER_CLEARUNKFLAG, + CONTROLLER_TOGGLEUNKFLAG, CONTROLLER_HITANIMATION, CONTROLLER_42, - CONTROLLER_EFFECTIVENESSSOUND, + CONTROLLER_PLAYSE, CONTROLLER_PLAYFANFAREORBGM, CONTROLLER_FAINTINGCRY, CONTROLLER_INTROSLIDE, @@ -175,7 +175,7 @@ enum CONTROLLER_CMDS_COUNT }; -extern struct UnusedControllerStruct gUnknown_02022D0C; +extern struct UnusedControllerStruct gUnusedControllerStruct; // general functions void HandleLinkBattleSetup(void); @@ -222,10 +222,10 @@ void BtlController_EmitTwoReturnValues(u8 bufferId, u8 arg1, u16 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_EmitCmd37(u8 bufferId); // unused -void BtlController_EmitCmd38(u8 bufferId, u8 b); // unused -void BtlController_EmitCmd39(u8 bufferId); // unused -void BtlController_EmitCmd40(u8 bufferId); // unused +void BtlController_EmitClearUnkVar(u8 bufferId); // unused +void BtlController_EmitSetUnkVar(u8 bufferId, u8 b); // unused +void BtlController_EmitClearUnkFlag(u8 bufferId); // unused +void BtlController_EmitToggleUnkFlag(u8 bufferId); // unused void BtlController_EmitHitAnimation(u8 bufferId); void BtlController_EmitCmd42(u8 bufferId); void BtlController_EmitPlaySE(u8 bufferId, u16 songId); diff --git a/include/constants/battle.h b/include/constants/battle.h index fa8f422c4..e6ebc85e4 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -44,38 +44,38 @@ #define BIT_FLANK 2 // Battle Type Flags -#define BATTLE_TYPE_DOUBLE (1 << 0) -#define BATTLE_TYPE_LINK (1 << 1) -#define BATTLE_TYPE_IS_MASTER (1 << 2) // In not-link battles, it's always set. -#define BATTLE_TYPE_TRAINER (1 << 3) -#define BATTLE_TYPE_FIRST_BATTLE (1 << 4) -#define BATTLE_TYPE_20 (1 << 5) -#define BATTLE_TYPE_MULTI (1 << 6) -#define BATTLE_TYPE_SAFARI (1 << 7) -#define BATTLE_TYPE_BATTLE_TOWER (1 << 8) -#define BATTLE_TYPE_WALLY_TUTORIAL (1 << 9) -#define BATTLE_TYPE_ROAMER (1 << 10) -#define BATTLE_TYPE_EREADER_TRAINER (1 << 11) -#define BATTLE_TYPE_KYOGRE_GROUDON (1 << 12) -#define BATTLE_TYPE_LEGENDARY (1 << 13) -#define BATTLE_TYPE_REGI (1 << 14) -#define BATTLE_TYPE_TWO_OPPONENTS (1 << 15) -#define BATTLE_TYPE_DOME (1 << 16) -#define BATTLE_TYPE_PALACE (1 << 17) -#define BATTLE_TYPE_ARENA (1 << 18) -#define BATTLE_TYPE_FACTORY (1 << 19) -#define BATTLE_TYPE_PIKE (1 << 20) -#define BATTLE_TYPE_PYRAMID (1 << 21) -#define BATTLE_TYPE_INGAME_PARTNER (1 << 22) -#define BATTLE_TYPE_x800000 (1 << 23) -#define BATTLE_TYPE_RECORDED (1 << 24) -#define BATTLE_TYPE_x2000000 (1 << 25) -#define BATTLE_TYPE_TRAINER_HILL (1 << 26) -#define BATTLE_TYPE_SECRET_BASE (1 << 27) -#define BATTLE_TYPE_GROUDON (1 << 28) -#define BATTLE_TYPE_KYOGRE (1 << 29) -#define BATTLE_TYPE_RAYQUAZA (1 << 30) -#define BATTLE_TYPE_x80000000 (1 << 31) +#define BATTLE_TYPE_DOUBLE (1 << 0) +#define BATTLE_TYPE_LINK (1 << 1) +#define BATTLE_TYPE_IS_MASTER (1 << 2) // In not-link battles, it's always set. +#define BATTLE_TYPE_TRAINER (1 << 3) +#define BATTLE_TYPE_FIRST_BATTLE (1 << 4) +#define BATTLE_TYPE_LINK_IN_BATTLE (1 << 5) // Set on battle entry, cleared on exit. Checked rarely +#define BATTLE_TYPE_MULTI (1 << 6) +#define BATTLE_TYPE_SAFARI (1 << 7) +#define BATTLE_TYPE_BATTLE_TOWER (1 << 8) +#define BATTLE_TYPE_WALLY_TUTORIAL (1 << 9) +#define BATTLE_TYPE_ROAMER (1 << 10) +#define BATTLE_TYPE_EREADER_TRAINER (1 << 11) +#define BATTLE_TYPE_KYOGRE_GROUDON (1 << 12) +#define BATTLE_TYPE_LEGENDARY (1 << 13) +#define BATTLE_TYPE_REGI (1 << 14) +#define BATTLE_TYPE_TWO_OPPONENTS (1 << 15) +#define BATTLE_TYPE_DOME (1 << 16) +#define BATTLE_TYPE_PALACE (1 << 17) +#define BATTLE_TYPE_ARENA (1 << 18) +#define BATTLE_TYPE_FACTORY (1 << 19) +#define BATTLE_TYPE_PIKE (1 << 20) +#define BATTLE_TYPE_PYRAMID (1 << 21) +#define BATTLE_TYPE_INGAME_PARTNER (1 << 22) +#define BATTLE_TYPE_TOWER_LINK_MULTI (1 << 23) +#define BATTLE_TYPE_RECORDED (1 << 24) +#define BATTLE_TYPE_RECORDED_LINK (1 << 25) +#define BATTLE_TYPE_TRAINER_HILL (1 << 26) +#define BATTLE_TYPE_SECRET_BASE (1 << 27) +#define BATTLE_TYPE_GROUDON (1 << 28) +#define BATTLE_TYPE_KYOGRE (1 << 29) +#define BATTLE_TYPE_RAYQUAZA (1 << 30) +#define BATTLE_TYPE_RECORDED_IS_MASTER (1 << 31) #define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID) #define BATTLE_TYPE_FRONTIER_NO_PYRAMID (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE) diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h index ebc422b18..5f8900bf6 100644 --- a/include/constants/battle_anim.h +++ b/include/constants/battle_anim.h @@ -346,51 +346,51 @@ #define BG_SOLARBEAM_PLAYER 25 #define BG_SOLARBEAM_CONTESTS 26 -// table ids for general animations -#define B_ANIM_CASTFORM_CHANGE 0x0 -#define B_ANIM_STATS_CHANGE 0x1 -#define B_ANIM_SUBSTITUTE_FADE 0x2 -#define B_ANIM_SUBSTITUTE_APPEAR 0x3 -#define B_ANIM_POKEBLOCK_THROW 0x4 -#define B_ANIM_ITEM_KNOCKOFF 0x5 -#define B_ANIM_TURN_TRAP 0x6 -#define B_ANIM_HELD_ITEM_EFFECT 0x7 -#define B_ANIM_SMOKEBALL_ESCAPE 0x8 -#define B_ANIM_FOCUS_BAND 0x9 -#define B_ANIM_RAIN_CONTINUES 0xA -#define B_ANIM_SUN_CONTINUES 0xB -#define B_ANIM_SANDSTORM_CONTINUES 0xC -#define B_ANIM_HAIL_CONTINUES 0xD -#define B_ANIM_LEECH_SEED_DRAIN 0xE -#define B_ANIM_MON_HIT 0xF -#define B_ANIM_ITEM_STEAL 0x10 -#define B_ANIM_SNATCH_MOVE 0x11 -#define B_ANIM_FUTURE_SIGHT_HIT 0x12 -#define B_ANIM_DOOM_DESIRE_HIT 0x13 -#define B_ANIM_FOCUS_PUNCH_SETUP 0x14 -#define B_ANIM_INGRAIN_HEAL 0x15 -#define B_ANIM_WISH_HEAL 0x16 +// table ids for general animations (gBattleAnims_General) +#define B_ANIM_CASTFORM_CHANGE 0 +#define B_ANIM_STATS_CHANGE 1 +#define B_ANIM_SUBSTITUTE_FADE 2 +#define B_ANIM_SUBSTITUTE_APPEAR 3 +#define B_ANIM_POKEBLOCK_THROW 4 +#define B_ANIM_ITEM_KNOCKOFF 5 +#define B_ANIM_TURN_TRAP 6 +#define B_ANIM_HELD_ITEM_EFFECT 7 +#define B_ANIM_SMOKEBALL_ESCAPE 8 +#define B_ANIM_FOCUS_BAND 9 +#define B_ANIM_RAIN_CONTINUES 10 +#define B_ANIM_SUN_CONTINUES 11 +#define B_ANIM_SANDSTORM_CONTINUES 12 +#define B_ANIM_HAIL_CONTINUES 13 +#define B_ANIM_LEECH_SEED_DRAIN 14 +#define B_ANIM_MON_HIT 15 +#define B_ANIM_ITEM_STEAL 16 +#define B_ANIM_SNATCH_MOVE 17 +#define B_ANIM_FUTURE_SIGHT_HIT 18 +#define B_ANIM_DOOM_DESIRE_HIT 19 +#define B_ANIM_FOCUS_PUNCH_SETUP 20 +#define B_ANIM_INGRAIN_HEAL 21 +#define B_ANIM_WISH_HEAL 22 -// special animations table -#define B_ANIM_LVL_UP 0x0 -#define B_ANIM_SWITCH_OUT_PLAYER_MON 0x1 -#define B_ANIM_SWITCH_OUT_OPPONENT_MON 0x2 -#define B_ANIM_BALL_THROW 0x3 -#define B_ANIM_BALL_THROW_WITH_TRAINER 0x4 -#define B_ANIM_SUBSTITUTE_TO_MON 0x5 -#define B_ANIM_MON_TO_SUBSTITUTE 0x6 +// special animations table (gBattleAnims_Special) +#define B_ANIM_LVL_UP 0 +#define B_ANIM_SWITCH_OUT_PLAYER_MON 1 +#define B_ANIM_SWITCH_OUT_OPPONENT_MON 2 +#define B_ANIM_BALL_THROW 3 +#define B_ANIM_BALL_THROW_WITH_TRAINER 4 +#define B_ANIM_SUBSTITUTE_TO_MON 5 +#define B_ANIM_MON_TO_SUBSTITUTE 6 -// status animation table -#define B_ANIM_STATUS_PSN 0x0 -#define B_ANIM_STATUS_CONFUSION 0x1 -#define B_ANIM_STATUS_BRN 0x2 -#define B_ANIM_STATUS_INFATUATION 0x3 -#define B_ANIM_STATUS_SLP 0x4 -#define B_ANIM_STATUS_PRZ 0x5 -#define B_ANIM_STATUS_FRZ 0x6 -#define B_ANIM_STATUS_CURSED 0x7 -#define B_ANIM_STATUS_NIGHTMARE 0x8 -#define B_ANIM_STATUS_WRAPPED 0x9 // does not actually exist +// status animation table (gBattleAnims_StatusConditions) +#define B_ANIM_STATUS_PSN 0 +#define B_ANIM_STATUS_CONFUSION 1 +#define B_ANIM_STATUS_BRN 2 +#define B_ANIM_STATUS_INFATUATION 3 +#define B_ANIM_STATUS_SLP 4 +#define B_ANIM_STATUS_PRZ 5 +#define B_ANIM_STATUS_FRZ 6 +#define B_ANIM_STATUS_CURSED 7 +#define B_ANIM_STATUS_NIGHTMARE 8 +#define B_ANIM_STATUS_WRAPPED 9 // does not actually exist // Tasks with return values often assign them to gBattleAnimArgs[7]. #define ARG_RET_ID 7 diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index b54f01353..cc62208fa 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -216,4 +216,6 @@ #define EFFECT_DRAGON_DANCE 212 #define EFFECT_CAMOUFLAGE 213 +#define NUM_BATTLE_MOVE_EFFECTS 214 + #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 9e0d8e0be..1886043f1 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -124,7 +124,7 @@ #define STRINGID_PKMNSTORINGENERGY 120 #define STRINGID_PKMNUNLEASHEDENERGY 121 #define STRINGID_PKMNFATIGUECONFUSION 122 -#define STRINGID_PKMNPICKEDUPITEM 123 +#define STRINGID_PLAYERPICKEDUPMONEY 123 #define STRINGID_PKMNUNAFFECTED 124 #define STRINGID_PKMNTRANSFORMEDINTO 125 #define STRINGID_PKMNMADESUBSTITUTE 126 diff --git a/include/constants/items.h b/include/constants/items.h index 95c6aacfe..71338da8e 100644 --- a/include/constants/items.h +++ b/include/constants/items.h @@ -17,7 +17,11 @@ #define ITEM_LUXURY_BALL 11 #define ITEM_PREMIER_BALL 12 -#define LAST_BALL ITEM_PREMIER_BALL +// Note: If moving ball IDs around, updating FIRST_BALL/LAST_BALL is not sufficient +// Several places expect the ball IDs to be first and contiguous (e.g. gBattlescriptsForBallThrow and MON_DATA_POKEBALL) +// If adding new balls, it's easiest to insert them after the last ball and increment the below IDs (and removing ITEM_034 for example) +#define FIRST_BALL ITEM_MASTER_BALL +#define LAST_BALL ITEM_PREMIER_BALL // Pokemon Items #define ITEM_POTION 13 @@ -145,6 +149,8 @@ #define ITEM_FAB_MAIL 131 #define ITEM_RETRO_MAIL 132 +#define FIRST_MAIL_INDEX ITEM_ORANGE_MAIL + // Berries #define ITEM_CHERI_BERRY 133 #define ITEM_CHESTO_BERRY 134 @@ -189,6 +195,10 @@ #define ITEM_LANSAT_BERRY 173 #define ITEM_STARF_BERRY 174 #define ITEM_ENIGMA_BERRY 175 + +#define FIRST_BERRY_INDEX ITEM_CHERI_BERRY +#define LAST_BERRY_INDEX ITEM_ENIGMA_BERRY + #define ITEM_0B0 176 #define ITEM_0B1 177 #define ITEM_0B2 178 @@ -467,9 +477,6 @@ #define ITEMS_COUNT 377 #define ITEM_FIELD_ARROW ITEMS_COUNT -#define FIRST_BERRY_INDEX ITEM_CHERI_BERRY -#define LAST_BERRY_INDEX ITEM_ENIGMA_BERRY - // Range of berries given out by various NPCS #define FIRST_BERRY_MASTER_BERRY ITEM_POMEG_BERRY #define LAST_BERRY_MASTER_BERRY ITEM_NOMEL_BERRY @@ -506,6 +513,21 @@ #define GOOD_ROD 1 #define SUPER_ROD 2 +// Secondary IDs for bikes +#define MACH_BIKE 0 +#define ACRO_BIKE 1 + +// Item type IDs (used to determine the exit callback) +#define ITEM_USE_MAIL 0 +#define ITEM_USE_PARTY_MENU 1 +#define ITEM_USE_FIELD 2 +#define ITEM_USE_PBLOCK_CASE 3 +#define ITEM_USE_BAG_MENU 4 // No exit callback, stays in bag menu + +// Item battle usage IDs (only checked to see if nonzero) +#define ITEM_B_USE_MEDICINE 1 +#define ITEM_B_USE_OTHER 2 + // Check if the item is one that can be used on a Pokemon. #define ITEM_HAS_EFFECT(item) ((item) >= ITEM_POTION && (item) <= ITEM_0B2) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index df11815a3..849b0402d 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -233,6 +233,9 @@ #define STATUS_PRIMARY_POKERUS 6 #define STATUS_PRIMARY_FAINTED 7 +#define MAX_PER_STAT_IVS 31 +#define MAX_IV_MASK 31 +#define USE_RANDOM_IVS (MAX_PER_STAT_IVS + 1) #define MAX_PER_STAT_EVS 255 #define MAX_TOTAL_EVS 510 #define EV_ITEM_RAISE_LIMIT 100 diff --git a/include/constants/rgb.h b/include/constants/rgb.h index 69f07763f..3e0bf6fe0 100644 --- a/include/constants/rgb.h +++ b/include/constants/rgb.h @@ -5,19 +5,22 @@ #define GET_G(color) (((color) >> 5) & 0x1F) #define GET_B(color) (((color) >> 10) & 0x1F) -#define RGB(r, g, b) ((r) | ((g) << 5) | ((b) << 10)) +#define RGB(r, g, b) ((r) | ((g) << 5) | ((b) << 10)) #define RGB2(r, g, b) (((b) << 10) | ((g) << 5) | (r)) #define _RGB(r, g, b) ((((b) & 0x1F) << 10) + (((g) & 0x1F) << 5) + ((r) & 0x1F)) -#define RGB_BLACK RGB(0, 0, 0) -#define RGB_WHITE RGB(31, 31, 31) -#define RGB_RED RGB(31, 0, 0) -#define RGB_GREEN RGB(0, 31, 0) -#define RGB_BLUE RGB(0, 0, 31) -#define RGB_PURPLE RGB(24, 0, 24) -#define RGB_YELLOW RGB(31, 31, 0) -#define RGB_MAGENTA RGB(31, 0, 31) -#define RGB_CYAN RGB(0, 31, 31) -#define RGB_WHITEALPHA (RGB_WHITE | 0x8000) +#define RGB_ALPHA (1 << 15) +#define IS_ALPHA(color) ((color) & RGB_ALPHA) + +#define RGB_BLACK RGB(0, 0, 0) +#define RGB_WHITE RGB(31, 31, 31) +#define RGB_RED RGB(31, 0, 0) +#define RGB_GREEN RGB(0, 31, 0) +#define RGB_BLUE RGB(0, 0, 31) +#define RGB_PURPLE RGB(24, 0, 24) +#define RGB_YELLOW RGB(31, 31, 0) +#define RGB_MAGENTA RGB(31, 0, 31) +#define RGB_CYAN RGB(0, 31, 31) +#define RGB_WHITEALPHA (RGB_WHITE | RGB_ALPHA) #endif // GUARD_RGB_H diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 9b4d9302f..cd76cac11 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -16,14 +16,22 @@ enum SpinnerRunnerFollowPatterns RUNFOLLOW_SOUTH_EAST_WEST }; +enum ReflectionTypes +{ + REFL_TYPE_NONE, + REFL_TYPE_ICE, + REFL_TYPE_WATER, + NUM_REFLECTION_TYPES +}; + #define FIGURE_8_LENGTH 72 #define GROUND_EFFECT_FLAG_TALL_GRASS_ON_SPAWN (1 << 0) #define GROUND_EFFECT_FLAG_TALL_GRASS_ON_MOVE (1 << 1) #define GROUND_EFFECT_FLAG_LONG_GRASS_ON_SPAWN (1 << 2) #define GROUND_EFFECT_FLAG_LONG_GRASS_ON_MOVE (1 << 3) -#define GROUND_EFFECT_FLAG_ICE_REFLECTION (1 << 4) -#define GROUND_EFFECT_FLAG_REFLECTION (1 << 5) +#define GROUND_EFFECT_FLAG_WATER_REFLECTION (1 << 4) +#define GROUND_EFFECT_FLAG_ICE_REFLECTION (1 << 5) #define GROUND_EFFECT_FLAG_SHALLOW_FLOWING_WATER (1 << 6) #define GROUND_EFFECT_FLAG_SAND (1 << 7) #define GROUND_EFFECT_FLAG_DEEP_SAND (1 << 8) @@ -414,10 +422,10 @@ u8 MovementType_RunInPlace_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementType_Invisible_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementType_Invisible_Step1(struct ObjectEvent *, struct Sprite *); u8 MovementType_Invisible_Step2(struct ObjectEvent *, struct Sprite *); -void SetObjectEventSpriteInvisibility(u8 var, bool32 var2); -bool32 IsObjectEventSpriteInvisible(u8 var); -void SetObjectEventSpriteGraphics(u8 var1, u8 graphicsId); -void SetObjectEventSpriteAnim(u8 var1, u8 var2); -bool32 IsObjectEventSpriteAnimating(u8 var); +void SetObjectEventSpriteInvisibility(u8 objectEventId, bool32 invisible); +bool32 IsObjectEventSpriteInvisible(u8 objectEventId); +void SetObjectEventSpriteGraphics(u8 objectEventId, u8 graphicsId); +void SetObjectEventSpriteAnim(u8 objectEventId, u8 animNum); +bool32 IsObjectEventSpriteAnimating(u8 objectEventId); #endif //GUARD_EVENT_OBJECT_MOVEMENT_H diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index 722fe4444..aa1a2e0dc 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -36,7 +36,7 @@ void sub_808BCE8(void); void InitPlayerAvatar(s16 a, s16 b, u8 c, u8 d); void sub_808B864(void); void sub_808BCF4(void); -void sub_808D074(u8); +void SetSpinStartFacingDir(u8); void GetXYCoordsOneStepInFrontOfPlayer(s16 *xPtr, s16 *yPtr); u8 GetRivalAvatarGraphicsIdByStateIdAndGender(u8, u8); void SetPlayerAvatarFieldMove(void); @@ -57,10 +57,10 @@ void PlayerWheelieMove(u8 direction); void PlayerPopWheelieWhileMoving(u8 direction); void PlayerUseAcroBikeOnBumpySlope(u8 direction); void PlayerEndWheelieWhileMoving(u8 direction); -void sub_808D194(void); -void sub_808D1C8(void); -bool32 sub_808D1B4(void); -bool32 sub_808D1E8(void); +void DoPlayerSpinEntrance(void); +void DoPlayerSpinExit(void); +bool32 IsPlayerSpinEntranceActive(void); +bool32 IsPlayerSpinExitActive(void); void SetPlayerInvisibility(bool8 invisible); u8 player_get_pos_including_state_based_drift(s16 *x, s16 *y); void StartFishing(u8 rod); diff --git a/include/field_screen_effect.h b/include/field_screen_effect.h index 951bf0788..4e4725041 100644 --- a/include/field_screen_effect.h +++ b/include/field_screen_effect.h @@ -18,8 +18,8 @@ void FieldCB_WarpExitFadeFromBlack(void); void FieldCB_WarpExitFadeFromWhite(void); bool8 FieldCB_ReturnToFieldOpenStartMenu(void); void ReturnToFieldOpenStartMenu(void); -void sub_80AF6D4(void); -void sub_80AF6F0(void); +void FieldCB_ReturnToFieldNoScript(void); +void FieldCB_ReturnToFieldNoScriptCheckMusic(void); void DoWarp(void); void DoDiveWarp(void); void DoSootopolisLegendWarp(void); @@ -35,8 +35,8 @@ void DoCableClubWarp(void); void DoContestHallWarp(void); void AnimateFlash(u8 flashLevel); void WriteBattlePyramidViewScanlineEffectBuffer(void); -void sub_80B0244(void); -void sub_80B0268(void); +void DoSpinEnterWarp(void); +void DoSpinExitWarp(void); void DoOrbEffect(void); void FadeOutOrbEffect(void); void sub_80B05B4(void); diff --git a/include/graphics.h b/include/graphics.h index 423e27deb..6e4223be9 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -7529,8 +7529,8 @@ extern const u32 gConfetti_Gfx[]; extern const u32 gConfetti_Pal[]; extern const u32 gUnknown_08C093F0[]; -extern const u32 gSubstituteDollTilemap[]; -extern const u32 gSubstituteDollGfx[]; +extern const u32 gSubstituteDollBackGfx[]; +extern const u32 gSubstituteDollFrontGfx[]; extern const u32 gSubstituteDollPal[]; extern const u32 gHealthboxSinglesPlayerGfx[]; extern const u32 gHealthboxSinglesOpponentGfx[]; @@ -8456,6 +8456,11 @@ extern const u16 gPokenavMessageBox_Pal[]; extern const u32 gPokenavOptions_Gfx[]; extern const u16 gPokenavOptions_Pal[]; +// Battle Factory Screen +extern const u8 gFrontierFactorySelectMenu_Gfx[]; +extern const u8 gFrontierFactorySelectMenu_Tilemap[]; +extern const u16 gFrontierFactorySelectMenu_Pal[]; + // Object event pals extern const u16 gObjectEventPal_Brendan[]; extern const u16 gObjectEventPal_May[]; diff --git a/include/pokemon.h b/include/pokemon.h index 107241a3e..e761c97b9 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -16,6 +16,7 @@ struct PokemonSubstruct0 u32 experience; u8 ppBonuses; u8 friendship; + u16 filler; }; struct PokemonSubstruct1 @@ -243,6 +244,15 @@ struct Evolution u16 targetSpecies; }; +#define NUM_UNOWN_FORMS 28 + +#define GET_UNOWN_LETTER(personality) (( \ + (((personality) & 0x03000000) >> 18) \ + | (((personality) & 0x00030000) >> 12) \ + | (((personality) & 0x00000300) >> 6) \ + | (((personality) & 0x00000003) >> 0) \ +) % NUM_UNOWN_FORMS) + extern u8 gPlayerPartyCount; extern struct Pokemon gPlayerParty[PARTY_SIZE]; extern u8 gEnemyPartyCount; diff --git a/include/recorded_battle.h b/include/recorded_battle.h index 252b25502..55353a6d1 100644 --- a/include/recorded_battle.h +++ b/include/recorded_battle.h @@ -3,7 +3,7 @@ extern u32 gRecordedBattleRngSeed; extern u32 gBattlePalaceMoveSelectionRngValue; -extern u8 gUnknown_0203C7B4; +extern u8 gRecordedBattleMultiplayerId; void sub_8184DA4(u8 arg0); void sub_8184E58(void); diff --git a/include/strings.h b/include/strings.h index 7018f9e0d..294ab8aa6 100644 --- a/include/strings.h +++ b/include/strings.h @@ -2988,4 +2988,31 @@ extern const u8 gText_SavingDontTurnOff2[]; extern const u8 gText_BlenderMaxSpeedRecord[]; extern const u8 gText_234Players[]; +// Battle Factory Screen +extern const u8 gText_RentalPkmn2[]; +extern const u8 gText_SelectFirstPkmn[]; +extern const u8 gText_SelectSecondPkmn[]; +extern const u8 gText_SelectThirdPkmn[]; +extern const u8 gText_TheseThreePkmnOkay[]; +extern const u8 gText_CantSelectSamePkmn[]; +extern const u8 gText_Summary[]; +extern const u8 gText_Rechoose[]; +extern const u8 gText_Deselect[]; +extern const u8 gText_Rent[]; +extern const u8 gText_Others2[]; +extern const u8 gText_Yes2[]; +extern const u8 gText_Yes3[]; +extern const u8 gText_No2[]; +extern const u8 gText_No3[]; +extern const u8 gText_QuitSwapping[]; +extern const u8 gText_AcceptThisPkmn[]; +extern const u8 gText_SelectPkmnToAccept[]; +extern const u8 gText_SelectPkmnToSwap[]; +extern const u8 gText_PkmnSwap[]; +extern const u8 gText_Swap[]; +extern const u8 gText_Summary2[]; +extern const u8 gText_PkmnForSwap[]; +extern const u8 gText_SamePkmnInPartyAlready[]; +extern const u8 gText_Cancel3[]; + #endif // GUARD_STRINGS_H diff --git a/include/tv.h b/include/tv.h index 4dc14143c..482909499 100644 --- a/include/tv.h +++ b/include/tv.h @@ -8,7 +8,7 @@ extern u8 *const gTVStringVarPtrs[3]; void ClearTVShowData(void); void sub_80EE184(void); -void sub_80EE35C(u16 foeSpecies, u16 species, u8 moveIdx, const u16 *movePtr, u16 betterMove); +void TryPutBattleSeminarOnAir(u16 foeSpecies, u16 species, u8 moveIdx, const u16 *movePtr, u16 betterMove); void TryPutFrontierTVShowOnAir(u16 winStreak, u8 facility); void DoTVShow(void); void DoTVShowInSearchOfTrainers(void); diff --git a/src/bard_music.c b/src/bard_music.c index 6c2578071..1a61c25ff 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -25,8 +25,8 @@ const struct BardSound *GetWordSounds(u16 word) { return gBardSound_InvalidWord; } - category = word >> 9; - subword = word & 0x1ff; + category = EC_GROUP(word); + subword = EC_INDEX(word); switch (category) { case EC_GROUP_POKEMON: diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index b7679429c..10eb013fe 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -293,7 +293,7 @@ void BattleAI_HandleItemUseBeforeAISetup(u8 defaultScoreMoves) if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER) && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_SAFARI | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_SECRET_BASE | BATTLE_TYPE_FRONTIER - | BATTLE_TYPE_INGAME_PARTNER | BATTLE_TYPE_x2000000) + | BATTLE_TYPE_INGAME_PARTNER | BATTLE_TYPE_RECORDED_LINK) ) ) { diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 1663c2561..263c1e7cc 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -62,7 +62,7 @@ static bool8 ShouldSwitchIfWonderGuard(void) } // Get party information. - if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) + if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_TOWER_LINK_MULTI)) { if ((gActiveBattler & BIT_FLANK) == B_FLANK_LEFT) firstId = 0, lastId = 3; @@ -158,7 +158,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) if (gBattleMons[gActiveBattler].ability == absorbingTypeAbility) return FALSE; - if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) + if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_TOWER_LINK_MULTI)) { if ((gActiveBattler & BIT_FLANK) == B_FLANK_LEFT) firstId = 0, lastId = 3; @@ -353,7 +353,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) battlerIn2 = gActiveBattler; } - if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) + if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_TOWER_LINK_MULTI)) { if ((gActiveBattler & BIT_FLANK) == 0) firstId = 0, lastId = 3; @@ -464,7 +464,7 @@ static bool8 ShouldSwitch(void) battlerIn2 = *activeBattlerPtr; } - if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) + if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_TOWER_LINK_MULTI)) { if ((gActiveBattler & BIT_FLANK) == B_FLANK_LEFT) firstId = 0, lastId = 3; @@ -555,7 +555,7 @@ void AI_TrySwitchOrUseItem(void) battlerIn2 = GetBattlerAtPosition(battlerIdentity ^ BIT_FLANK); } - if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) + if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_TOWER_LINK_MULTI)) { if ((gActiveBattler & BIT_FLANK) == B_FLANK_LEFT) firstId = 0, lastId = 3; @@ -661,7 +661,7 @@ u8 GetMostSuitableMonToSwitchInto(void) battlerIn2 = gActiveBattler; } - if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) + if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_TOWER_LINK_MULTI)) { if ((gActiveBattler & BIT_FLANK) == B_FLANK_LEFT) firstId = 0, lastId = 3; diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c index 665c10c19..73b1e1a00 100755 --- a/src/battle_anim_effects_3.c +++ b/src/battle_anim_effects_3.c @@ -4947,7 +4947,6 @@ static void AnimTask_OdorSleuthMovementWaitFinish(u8 taskId) static void MoveOdorSleuthClone(struct Sprite *sprite) { - int zero = 0; if (++sprite->data[1] > 1) { sprite->data[1] = 0; diff --git a/src/battle_anim_flying.c b/src/battle_anim_flying.c index f8d47f4ec..7d96fed8c 100644 --- a/src/battle_anim_flying.c +++ b/src/battle_anim_flying.c @@ -708,7 +708,6 @@ static void sub_810E520(struct Sprite *sprite) } } data->unk0_0d = 0; - data->unk2; } data->unk0_1 = 0; break; diff --git a/src/battle_anim_normal.c b/src/battle_anim_normal.c index f7df9a4a9..e32ff3151 100644 --- a/src/battle_anim_normal.c +++ b/src/battle_anim_normal.c @@ -564,8 +564,6 @@ static void AnimTask_BlendColorCycleExcludeLoop(u8 taskId) // See AnimTask_BlendColorCycle. Same, but selects palette by ANIM_TAG_* void AnimTask_BlendColorCycleByTag(u8 taskId) { - u8 paletteIndex; - gTasks[taskId].tPalTag = gBattleAnimArgs[0]; gTasks[taskId].tDelay = gBattleAnimArgs[1]; gTasks[taskId].tNumBlends = gBattleAnimArgs[2]; diff --git a/src/battle_anim_throw.c b/src/battle_anim_throw.c index fef301326..0da766036 100755 --- a/src/battle_anim_throw.c +++ b/src/battle_anim_throw.c @@ -1551,8 +1551,6 @@ static void SpriteCB_Ball_Block_Step(struct Sprite *sprite) static void LoadBallParticleGfx(u8 ballId) { - u8 taskId; - if (GetSpriteTileStartByTag(sBallParticleSpriteSheets[ballId].tag) == 0xFFFF) { LoadCompressedSpriteSheetUsingHeap(&sBallParticleSpriteSheets[ballId]); diff --git a/src/battle_anim_water.c b/src/battle_anim_water.c index 2bb90e585..f157102b0 100644 --- a/src/battle_anim_water.c +++ b/src/battle_anim_water.c @@ -881,8 +881,6 @@ static void AnimTask_CreateSurfWave_Step1(u8 taskId) u16 rgbBuffer; u16 *BGptrX = &gBattle_BG1_X; u16 *BGptrY = &gBattle_BG1_Y; - u32 palOffset; - u16 palNum; *BGptrX += gTasks[taskId].data[0]; *BGptrY += gTasks[taskId].data[1]; diff --git a/src/battle_bg.c b/src/battle_bg.c index 7c9b05b25..ad992f7b3 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -759,7 +759,7 @@ void LoadBattleMenuWindowGfx(void) void DrawMainBattleBackground(void) { - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_RECORDED_LINK)) { LZDecompressVram(gBattleTerrainTiles_Building, (void*)(BG_CHAR_ADDR(2))); LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(BG_SCREEN_ADDR(26))); @@ -1140,7 +1140,7 @@ void DrawBattleEntryBackground(void) gBattle_BG2_Y = 0xFF5C; LoadCompressedSpriteSheetUsingHeap(&sVsLettersSpriteSheet); } - else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER)) + else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_EREADER_TRAINER)) { if (!(gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) || gPartnerTrainerId == TRAINER_STEVEN_PARTNER) { @@ -1221,7 +1221,7 @@ bool8 LoadChosenBattleElement(u8 caseId) LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40); break; case 3: - if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER)) + if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_EREADER_TRAINER)) { LZDecompressVram(gBattleTerrainTiles_Building, (void*)(BG_CHAR_ADDR(2))); } @@ -1280,7 +1280,7 @@ bool8 LoadChosenBattleElement(u8 caseId) } break; case 4: - if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER)) + if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_EREADER_TRAINER)) { LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(BG_SCREEN_ADDR(26))); } @@ -1342,7 +1342,7 @@ bool8 LoadChosenBattleElement(u8 caseId) } break; case 5: - if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER)) + if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_EREADER_TRAINER)) { LoadCompressedPalette(gBattleTerrainPalette_Frontier, 0x20, 0x60); } diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index b6278dd59..ed88bb1a9 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -69,10 +69,10 @@ static void LinkOpponentHandleTwoReturnValues(void); static void LinkOpponentHandleChosenMonReturnValue(void); static void LinkOpponentHandleOneReturnValue(void); static void LinkOpponentHandleOneReturnValue_Duplicate(void); -static void LinkOpponentHandleCmd37(void); -static void LinkOpponentHandleCmd38(void); -static void LinkOpponentHandleCmd39(void); -static void LinkOpponentHandleCmd40(void); +static void LinkOpponentHandleClearUnkVar(void); +static void LinkOpponentHandleSetUnkVar(void); +static void LinkOpponentHandleClearUnkFlag(void); +static void LinkOpponentHandleToggleUnkFlag(void); static void LinkOpponentHandleHitAnimation(void); static void LinkOpponentHandleCmd42(void); static void LinkOpponentHandlePlaySE(void); @@ -104,63 +104,63 @@ static void sub_806782C(void); static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { - LinkOpponentHandleGetMonData, - LinkOpponentHandleGetRawMonData, - LinkOpponentHandleSetMonData, - LinkOpponentHandleSetRawMonData, - LinkOpponentHandleLoadMonSprite, - LinkOpponentHandleSwitchInAnim, - LinkOpponentHandleReturnMonToBall, - LinkOpponentHandleDrawTrainerPic, - LinkOpponentHandleTrainerSlide, - LinkOpponentHandleTrainerSlideBack, - LinkOpponentHandleFaintAnimation, - LinkOpponentHandlePaletteFade, - LinkOpponentHandleSuccessBallThrowAnim, - LinkOpponentHandleBallThrowAnim, - LinkOpponentHandlePause, - LinkOpponentHandleMoveAnimation, - LinkOpponentHandlePrintString, - LinkOpponentHandlePrintSelectionString, - LinkOpponentHandleChooseAction, - LinkOpponentHandleUnknownYesNoBox, - LinkOpponentHandleChooseMove, - LinkOpponentHandleChooseItem, - LinkOpponentHandleChoosePokemon, - LinkOpponentHandleCmd23, - LinkOpponentHandleHealthBarUpdate, - LinkOpponentHandleExpUpdate, - LinkOpponentHandleStatusIconUpdate, - LinkOpponentHandleStatusAnimation, - LinkOpponentHandleStatusXor, - LinkOpponentHandleDataTransfer, - LinkOpponentHandleDMA3Transfer, - LinkOpponentHandlePlayBGM, - LinkOpponentHandleCmd32, - LinkOpponentHandleTwoReturnValues, - LinkOpponentHandleChosenMonReturnValue, - LinkOpponentHandleOneReturnValue, - LinkOpponentHandleOneReturnValue_Duplicate, - LinkOpponentHandleCmd37, - LinkOpponentHandleCmd38, - LinkOpponentHandleCmd39, - LinkOpponentHandleCmd40, - LinkOpponentHandleHitAnimation, - LinkOpponentHandleCmd42, - LinkOpponentHandlePlaySE, - LinkOpponentHandlePlayFanfareOrBGM, - LinkOpponentHandleFaintingCry, - LinkOpponentHandleIntroSlide, - LinkOpponentHandleIntroTrainerBallThrow, - LinkOpponentHandleDrawPartyStatusSummary, - LinkOpponentHandleHidePartyStatusSummary, - LinkOpponentHandleEndBounceEffect, - LinkOpponentHandleSpriteInvisibility, - LinkOpponentHandleBattleAnimation, - LinkOpponentHandleLinkStandbyMsg, - LinkOpponentHandleResetActionMoveSelection, - LinkOpponentHandleCmd55, - LinkOpponentCmdEnd + [CONTROLLER_GETMONDATA] = LinkOpponentHandleGetMonData, + [CONTROLLER_GETRAWMONDATA] = LinkOpponentHandleGetRawMonData, + [CONTROLLER_SETMONDATA] = LinkOpponentHandleSetMonData, + [CONTROLLER_SETRAWMONDATA] = LinkOpponentHandleSetRawMonData, + [CONTROLLER_LOADMONSPRITE] = LinkOpponentHandleLoadMonSprite, + [CONTROLLER_SWITCHINANIM] = LinkOpponentHandleSwitchInAnim, + [CONTROLLER_RETURNMONTOBALL] = LinkOpponentHandleReturnMonToBall, + [CONTROLLER_DRAWTRAINERPIC] = LinkOpponentHandleDrawTrainerPic, + [CONTROLLER_TRAINERSLIDE] = LinkOpponentHandleTrainerSlide, + [CONTROLLER_TRAINERSLIDEBACK] = LinkOpponentHandleTrainerSlideBack, + [CONTROLLER_FAINTANIMATION] = LinkOpponentHandleFaintAnimation, + [CONTROLLER_PALETTEFADE] = LinkOpponentHandlePaletteFade, + [CONTROLLER_SUCCESSBALLTHROWANIM] = LinkOpponentHandleSuccessBallThrowAnim, + [CONTROLLER_BALLTHROWANIM] = LinkOpponentHandleBallThrowAnim, + [CONTROLLER_PAUSE] = LinkOpponentHandlePause, + [CONTROLLER_MOVEANIMATION] = LinkOpponentHandleMoveAnimation, + [CONTROLLER_PRINTSTRING] = LinkOpponentHandlePrintString, + [CONTROLLER_PRINTSTRINGPLAYERONLY] = LinkOpponentHandlePrintSelectionString, + [CONTROLLER_CHOOSEACTION] = LinkOpponentHandleChooseAction, + [CONTROLLER_UNKNOWNYESNOBOX] = LinkOpponentHandleUnknownYesNoBox, + [CONTROLLER_CHOOSEMOVE] = LinkOpponentHandleChooseMove, + [CONTROLLER_OPENBAG] = LinkOpponentHandleChooseItem, + [CONTROLLER_CHOOSEPOKEMON] = LinkOpponentHandleChoosePokemon, + [CONTROLLER_23] = LinkOpponentHandleCmd23, + [CONTROLLER_HEALTHBARUPDATE] = LinkOpponentHandleHealthBarUpdate, + [CONTROLLER_EXPUPDATE] = LinkOpponentHandleExpUpdate, + [CONTROLLER_STATUSICONUPDATE] = LinkOpponentHandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = LinkOpponentHandleStatusAnimation, + [CONTROLLER_STATUSXOR] = LinkOpponentHandleStatusXor, + [CONTROLLER_DATATRANSFER] = LinkOpponentHandleDataTransfer, + [CONTROLLER_DMA3TRANSFER] = LinkOpponentHandleDMA3Transfer, + [CONTROLLER_PLAYBGM] = LinkOpponentHandlePlayBGM, + [CONTROLLER_32] = LinkOpponentHandleCmd32, + [CONTROLLER_TWORETURNVALUES] = LinkOpponentHandleTwoReturnValues, + [CONTROLLER_CHOSENMONRETURNVALUE] = LinkOpponentHandleChosenMonReturnValue, + [CONTROLLER_ONERETURNVALUE] = LinkOpponentHandleOneReturnValue, + [CONTROLLER_ONERETURNVALUE_DUPLICATE] = LinkOpponentHandleOneReturnValue_Duplicate, + [CONTROLLER_CLEARUNKVAR] = LinkOpponentHandleClearUnkVar, + [CONTROLLER_SETUNKVAR] = LinkOpponentHandleSetUnkVar, + [CONTROLLER_CLEARUNKFLAG] = LinkOpponentHandleClearUnkFlag, + [CONTROLLER_TOGGLEUNKFLAG] = LinkOpponentHandleToggleUnkFlag, + [CONTROLLER_HITANIMATION] = LinkOpponentHandleHitAnimation, + [CONTROLLER_42] = LinkOpponentHandleCmd42, + [CONTROLLER_PLAYSE] = LinkOpponentHandlePlaySE, + [CONTROLLER_PLAYFANFAREORBGM] = LinkOpponentHandlePlayFanfareOrBGM, + [CONTROLLER_FAINTINGCRY] = LinkOpponentHandleFaintingCry, + [CONTROLLER_INTROSLIDE] = LinkOpponentHandleIntroSlide, + [CONTROLLER_INTROTRAINERBALLTHROW] = LinkOpponentHandleIntroTrainerBallThrow, + [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = LinkOpponentHandleDrawPartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = LinkOpponentHandleHidePartyStatusSummary, + [CONTROLLER_ENDBOUNCE] = LinkOpponentHandleEndBounceEffect, + [CONTROLLER_SPRITEINVISIBILITY] = LinkOpponentHandleSpriteInvisibility, + [CONTROLLER_BATTLEANIMATION] = LinkOpponentHandleBattleAnimation, + [CONTROLLER_LINKSTANDBYMSG] = LinkOpponentHandleLinkStandbyMsg, + [CONTROLLER_RESETACTIONMOVESELECTION] = LinkOpponentHandleResetActionMoveSelection, + [CONTROLLER_55] = LinkOpponentHandleCmd55, + [CONTROLLER_TERMINATOR_NOP] = LinkOpponentCmdEnd }; static void nullsub_28(void) @@ -1603,27 +1603,27 @@ static void LinkOpponentHandleOneReturnValue_Duplicate(void) LinkOpponentBufferExecCompleted(); } -static void LinkOpponentHandleCmd37(void) +static void LinkOpponentHandleClearUnkVar(void) { - gUnknown_02022D0C.field_0 = 0; + gUnusedControllerStruct.unk = 0; LinkOpponentBufferExecCompleted(); } -static void LinkOpponentHandleCmd38(void) +static void LinkOpponentHandleSetUnkVar(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnusedControllerStruct.unk = gBattleBufferA[gActiveBattler][1]; LinkOpponentBufferExecCompleted(); } -static void LinkOpponentHandleCmd39(void) +static void LinkOpponentHandleClearUnkFlag(void) { - gUnknown_02022D0C.flag_x80 = 0; + gUnusedControllerStruct.flag = 0; LinkOpponentBufferExecCompleted(); } -static void LinkOpponentHandleCmd40(void) +static void LinkOpponentHandleToggleUnkFlag(void) { - gUnknown_02022D0C.flag_x80 ^= 1; + gUnusedControllerStruct.flag ^= 1; LinkOpponentBufferExecCompleted(); } @@ -1692,7 +1692,6 @@ static void LinkOpponentHandleIntroSlide(void) static void LinkOpponentHandleIntroTrainerBallThrow(void) { - u8 paletteNum; u8 taskId; SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index c6cb101fc..daf1ff4fd 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -67,10 +67,10 @@ static void LinkPartnerHandleTwoReturnValues(void); static void LinkPartnerHandleChosenMonReturnValue(void); static void LinkPartnerHandleOneReturnValue(void); static void LinkPartnerHandleOneReturnValue_Duplicate(void); -static void LinkPartnerHandleCmd37(void); -static void LinkPartnerHandleCmd38(void); -static void LinkPartnerHandleCmd39(void); -static void LinkPartnerHandleCmd40(void); +static void LinkPartnerHandleClearUnkVar(void); +static void LinkPartnerHandleSetUnkVar(void); +static void LinkPartnerHandleClearUnkFlag(void); +static void LinkPartnerHandleToggleUnkFlag(void); static void LinkPartnerHandleHitAnimation(void); static void LinkPartnerHandleCmd42(void); static void LinkPartnerHandlePlaySE(void); @@ -101,63 +101,63 @@ static void sub_814DE9C(void); static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { - LinkPartnerHandleGetMonData, - LinkPartnerHandleGetRawMonData, - LinkPartnerHandleSetMonData, - LinkPartnerHandleSetRawMonData, - LinkPartnerHandleLoadMonSprite, - LinkPartnerHandleSwitchInAnim, - LinkPartnerHandleReturnMonToBall, - LinkPartnerHandleDrawTrainerPic, - LinkPartnerHandleTrainerSlide, - LinkPartnerHandleTrainerSlideBack, - LinkPartnerHandleFaintAnimation, - LinkPartnerHandlePaletteFade, - LinkPartnerHandleSuccessBallThrowAnim, - LinkPartnerHandleBallThrowAnim, - LinkPartnerHandlePause, - LinkPartnerHandleMoveAnimation, - LinkPartnerHandlePrintString, - LinkPartnerHandlePrintSelectionString, - LinkPartnerHandleChooseAction, - LinkPartnerHandleUnknownYesNoBox, - LinkPartnerHandleChooseMove, - LinkPartnerHandleChooseItem, - LinkPartnerHandleChoosePokemon, - LinkPartnerHandleCmd23, - LinkPartnerHandleHealthBarUpdate, - LinkPartnerHandleExpUpdate, - LinkPartnerHandleStatusIconUpdate, - LinkPartnerHandleStatusAnimation, - LinkPartnerHandleStatusXor, - LinkPartnerHandleDataTransfer, - LinkPartnerHandleDMA3Transfer, - LinkPartnerHandlePlayBGM, - LinkPartnerHandleCmd32, - LinkPartnerHandleTwoReturnValues, - LinkPartnerHandleChosenMonReturnValue, - LinkPartnerHandleOneReturnValue, - LinkPartnerHandleOneReturnValue_Duplicate, - LinkPartnerHandleCmd37, - LinkPartnerHandleCmd38, - LinkPartnerHandleCmd39, - LinkPartnerHandleCmd40, - LinkPartnerHandleHitAnimation, - LinkPartnerHandleCmd42, - LinkPartnerHandlePlaySE, - LinkPartnerHandlePlayFanfareOrBGM, - LinkPartnerHandleFaintingCry, - LinkPartnerHandleIntroSlide, - LinkPartnerHandleIntroTrainerBallThrow, - LinkPartnerHandleDrawPartyStatusSummary, - LinkPartnerHandleHidePartyStatusSummary, - LinkPartnerHandleEndBounceEffect, - LinkPartnerHandleSpriteInvisibility, - LinkPartnerHandleBattleAnimation, - LinkPartnerHandleLinkStandbyMsg, - LinkPartnerHandleResetActionMoveSelection, - LinkPartnerHandleCmd55, - LinkPartnerCmdEnd + [CONTROLLER_GETMONDATA] = LinkPartnerHandleGetMonData, + [CONTROLLER_GETRAWMONDATA] = LinkPartnerHandleGetRawMonData, + [CONTROLLER_SETMONDATA] = LinkPartnerHandleSetMonData, + [CONTROLLER_SETRAWMONDATA] = LinkPartnerHandleSetRawMonData, + [CONTROLLER_LOADMONSPRITE] = LinkPartnerHandleLoadMonSprite, + [CONTROLLER_SWITCHINANIM] = LinkPartnerHandleSwitchInAnim, + [CONTROLLER_RETURNMONTOBALL] = LinkPartnerHandleReturnMonToBall, + [CONTROLLER_DRAWTRAINERPIC] = LinkPartnerHandleDrawTrainerPic, + [CONTROLLER_TRAINERSLIDE] = LinkPartnerHandleTrainerSlide, + [CONTROLLER_TRAINERSLIDEBACK] = LinkPartnerHandleTrainerSlideBack, + [CONTROLLER_FAINTANIMATION] = LinkPartnerHandleFaintAnimation, + [CONTROLLER_PALETTEFADE] = LinkPartnerHandlePaletteFade, + [CONTROLLER_SUCCESSBALLTHROWANIM] = LinkPartnerHandleSuccessBallThrowAnim, + [CONTROLLER_BALLTHROWANIM] = LinkPartnerHandleBallThrowAnim, + [CONTROLLER_PAUSE] = LinkPartnerHandlePause, + [CONTROLLER_MOVEANIMATION] = LinkPartnerHandleMoveAnimation, + [CONTROLLER_PRINTSTRING] = LinkPartnerHandlePrintString, + [CONTROLLER_PRINTSTRINGPLAYERONLY] = LinkPartnerHandlePrintSelectionString, + [CONTROLLER_CHOOSEACTION] = LinkPartnerHandleChooseAction, + [CONTROLLER_UNKNOWNYESNOBOX] = LinkPartnerHandleUnknownYesNoBox, + [CONTROLLER_CHOOSEMOVE] = LinkPartnerHandleChooseMove, + [CONTROLLER_OPENBAG] = LinkPartnerHandleChooseItem, + [CONTROLLER_CHOOSEPOKEMON] = LinkPartnerHandleChoosePokemon, + [CONTROLLER_23] = LinkPartnerHandleCmd23, + [CONTROLLER_HEALTHBARUPDATE] = LinkPartnerHandleHealthBarUpdate, + [CONTROLLER_EXPUPDATE] = LinkPartnerHandleExpUpdate, + [CONTROLLER_STATUSICONUPDATE] = LinkPartnerHandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = LinkPartnerHandleStatusAnimation, + [CONTROLLER_STATUSXOR] = LinkPartnerHandleStatusXor, + [CONTROLLER_DATATRANSFER] = LinkPartnerHandleDataTransfer, + [CONTROLLER_DMA3TRANSFER] = LinkPartnerHandleDMA3Transfer, + [CONTROLLER_PLAYBGM] = LinkPartnerHandlePlayBGM, + [CONTROLLER_32] = LinkPartnerHandleCmd32, + [CONTROLLER_TWORETURNVALUES] = LinkPartnerHandleTwoReturnValues, + [CONTROLLER_CHOSENMONRETURNVALUE] = LinkPartnerHandleChosenMonReturnValue, + [CONTROLLER_ONERETURNVALUE] = LinkPartnerHandleOneReturnValue, + [CONTROLLER_ONERETURNVALUE_DUPLICATE] = LinkPartnerHandleOneReturnValue_Duplicate, + [CONTROLLER_CLEARUNKVAR] = LinkPartnerHandleClearUnkVar, + [CONTROLLER_SETUNKVAR] = LinkPartnerHandleSetUnkVar, + [CONTROLLER_CLEARUNKFLAG] = LinkPartnerHandleClearUnkFlag, + [CONTROLLER_TOGGLEUNKFLAG] = LinkPartnerHandleToggleUnkFlag, + [CONTROLLER_HITANIMATION] = LinkPartnerHandleHitAnimation, + [CONTROLLER_42] = LinkPartnerHandleCmd42, + [CONTROLLER_PLAYSE] = LinkPartnerHandlePlaySE, + [CONTROLLER_PLAYFANFAREORBGM] = LinkPartnerHandlePlayFanfareOrBGM, + [CONTROLLER_FAINTINGCRY] = LinkPartnerHandleFaintingCry, + [CONTROLLER_INTROSLIDE] = LinkPartnerHandleIntroSlide, + [CONTROLLER_INTROTRAINERBALLTHROW] = LinkPartnerHandleIntroTrainerBallThrow, + [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = LinkPartnerHandleDrawPartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = LinkPartnerHandleHidePartyStatusSummary, + [CONTROLLER_ENDBOUNCE] = LinkPartnerHandleEndBounceEffect, + [CONTROLLER_SPRITEINVISIBILITY] = LinkPartnerHandleSpriteInvisibility, + [CONTROLLER_BATTLEANIMATION] = LinkPartnerHandleBattleAnimation, + [CONTROLLER_LINKSTANDBYMSG] = LinkPartnerHandleLinkStandbyMsg, + [CONTROLLER_RESETACTIONMOVESELECTION] = LinkPartnerHandleResetActionMoveSelection, + [CONTROLLER_55] = LinkPartnerHandleCmd55, + [CONTROLLER_TERMINATOR_NOP] = LinkPartnerCmdEnd }; static void SpriteCB_Null2(void) @@ -1427,27 +1427,27 @@ static void LinkPartnerHandleOneReturnValue_Duplicate(void) LinkPartnerBufferExecCompleted(); } -static void LinkPartnerHandleCmd37(void) +static void LinkPartnerHandleClearUnkVar(void) { - gUnknown_02022D0C.field_0 = 0; + gUnusedControllerStruct.unk = 0; LinkPartnerBufferExecCompleted(); } -static void LinkPartnerHandleCmd38(void) +static void LinkPartnerHandleSetUnkVar(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnusedControllerStruct.unk = gBattleBufferA[gActiveBattler][1]; LinkPartnerBufferExecCompleted(); } -static void LinkPartnerHandleCmd39(void) +static void LinkPartnerHandleClearUnkFlag(void) { - gUnknown_02022D0C.flag_x80 = 0; + gUnusedControllerStruct.flag = 0; LinkPartnerBufferExecCompleted(); } -static void LinkPartnerHandleCmd40(void) +static void LinkPartnerHandleToggleUnkFlag(void) { - gUnknown_02022D0C.flag_x80 ^= 1; + gUnusedControllerStruct.flag ^= 1; LinkPartnerBufferExecCompleted(); } diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 4c8eff859..82c69802b 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -74,10 +74,10 @@ static void OpponentHandleTwoReturnValues(void); static void OpponentHandleChosenMonReturnValue(void); static void OpponentHandleOneReturnValue(void); static void OpponentHandleOneReturnValue_Duplicate(void); -static void OpponentHandleCmd37(void); -static void OpponentHandleCmd38(void); -static void OpponentHandleCmd39(void); -static void OpponentHandleCmd40(void); +static void OpponentHandleClearUnkVar(void); +static void OpponentHandleSetUnkVar(void); +static void OpponentHandleClearUnkFlag(void); +static void OpponentHandleToggleUnkFlag(void); static void OpponentHandleHitAnimation(void); static void OpponentHandleCmd42(void); static void OpponentHandlePlaySE(void); @@ -109,67 +109,67 @@ static void sub_8062A2C(void); static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { - OpponentHandleGetMonData, - OpponentHandleGetRawMonData, - OpponentHandleSetMonData, - OpponentHandleSetRawMonData, - OpponentHandleLoadMonSprite, - OpponentHandleSwitchInAnim, - OpponentHandleReturnMonToBall, - OpponentHandleDrawTrainerPic, - OpponentHandleTrainerSlide, - OpponentHandleTrainerSlideBack, - OpponentHandleFaintAnimation, - OpponentHandlePaletteFade, - OpponentHandleSuccessBallThrowAnim, - OpponentHandleBallThrow, - OpponentHandlePause, - OpponentHandleMoveAnimation, - OpponentHandlePrintString, - OpponentHandlePrintSelectionString, - OpponentHandleChooseAction, - OpponentHandleUnknownYesNoBox, - OpponentHandleChooseMove, - OpponentHandleChooseItem, - OpponentHandleChoosePokemon, - OpponentHandleCmd23, - OpponentHandleHealthBarUpdate, - OpponentHandleExpUpdate, - OpponentHandleStatusIconUpdate, - OpponentHandleStatusAnimation, - OpponentHandleStatusXor, - OpponentHandleDataTransfer, - OpponentHandleDMA3Transfer, - OpponentHandlePlayBGM, - OpponentHandleCmd32, - OpponentHandleTwoReturnValues, - OpponentHandleChosenMonReturnValue, - OpponentHandleOneReturnValue, - OpponentHandleOneReturnValue_Duplicate, - OpponentHandleCmd37, - OpponentHandleCmd38, - OpponentHandleCmd39, - OpponentHandleCmd40, - OpponentHandleHitAnimation, - OpponentHandleCmd42, - OpponentHandlePlaySE, - OpponentHandlePlayFanfareOrBGM, - OpponentHandleFaintingCry, - OpponentHandleIntroSlide, - OpponentHandleIntroTrainerBallThrow, - OpponentHandleDrawPartyStatusSummary, - OpponentHandleHidePartyStatusSummary, - OpponentHandleEndBounceEffect, - OpponentHandleSpriteInvisibility, - OpponentHandleBattleAnimation, - OpponentHandleLinkStandbyMsg, - OpponentHandleResetActionMoveSelection, - OpponentHandleCmd55, - OpponentCmdEnd + [CONTROLLER_GETMONDATA] = OpponentHandleGetMonData, + [CONTROLLER_GETRAWMONDATA] = OpponentHandleGetRawMonData, + [CONTROLLER_SETMONDATA] = OpponentHandleSetMonData, + [CONTROLLER_SETRAWMONDATA] = OpponentHandleSetRawMonData, + [CONTROLLER_LOADMONSPRITE] = OpponentHandleLoadMonSprite, + [CONTROLLER_SWITCHINANIM] = OpponentHandleSwitchInAnim, + [CONTROLLER_RETURNMONTOBALL] = OpponentHandleReturnMonToBall, + [CONTROLLER_DRAWTRAINERPIC] = OpponentHandleDrawTrainerPic, + [CONTROLLER_TRAINERSLIDE] = OpponentHandleTrainerSlide, + [CONTROLLER_TRAINERSLIDEBACK] = OpponentHandleTrainerSlideBack, + [CONTROLLER_FAINTANIMATION] = OpponentHandleFaintAnimation, + [CONTROLLER_PALETTEFADE] = OpponentHandlePaletteFade, + [CONTROLLER_SUCCESSBALLTHROWANIM] = OpponentHandleSuccessBallThrowAnim, + [CONTROLLER_BALLTHROWANIM] = OpponentHandleBallThrow, + [CONTROLLER_PAUSE] = OpponentHandlePause, + [CONTROLLER_MOVEANIMATION] = OpponentHandleMoveAnimation, + [CONTROLLER_PRINTSTRING] = OpponentHandlePrintString, + [CONTROLLER_PRINTSTRINGPLAYERONLY] = OpponentHandlePrintSelectionString, + [CONTROLLER_CHOOSEACTION] = OpponentHandleChooseAction, + [CONTROLLER_UNKNOWNYESNOBOX] = OpponentHandleUnknownYesNoBox, + [CONTROLLER_CHOOSEMOVE] = OpponentHandleChooseMove, + [CONTROLLER_OPENBAG] = OpponentHandleChooseItem, + [CONTROLLER_CHOOSEPOKEMON] = OpponentHandleChoosePokemon, + [CONTROLLER_23] = OpponentHandleCmd23, + [CONTROLLER_HEALTHBARUPDATE] = OpponentHandleHealthBarUpdate, + [CONTROLLER_EXPUPDATE] = OpponentHandleExpUpdate, + [CONTROLLER_STATUSICONUPDATE] = OpponentHandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = OpponentHandleStatusAnimation, + [CONTROLLER_STATUSXOR] = OpponentHandleStatusXor, + [CONTROLLER_DATATRANSFER] = OpponentHandleDataTransfer, + [CONTROLLER_DMA3TRANSFER] = OpponentHandleDMA3Transfer, + [CONTROLLER_PLAYBGM] = OpponentHandlePlayBGM, + [CONTROLLER_32] = OpponentHandleCmd32, + [CONTROLLER_TWORETURNVALUES] = OpponentHandleTwoReturnValues, + [CONTROLLER_CHOSENMONRETURNVALUE] = OpponentHandleChosenMonReturnValue, + [CONTROLLER_ONERETURNVALUE] = OpponentHandleOneReturnValue, + [CONTROLLER_ONERETURNVALUE_DUPLICATE] = OpponentHandleOneReturnValue_Duplicate, + [CONTROLLER_CLEARUNKVAR] = OpponentHandleClearUnkVar, + [CONTROLLER_SETUNKVAR] = OpponentHandleSetUnkVar, + [CONTROLLER_CLEARUNKFLAG] = OpponentHandleClearUnkFlag, + [CONTROLLER_TOGGLEUNKFLAG] = OpponentHandleToggleUnkFlag, + [CONTROLLER_HITANIMATION] = OpponentHandleHitAnimation, + [CONTROLLER_42] = OpponentHandleCmd42, + [CONTROLLER_PLAYSE] = OpponentHandlePlaySE, + [CONTROLLER_PLAYFANFAREORBGM] = OpponentHandlePlayFanfareOrBGM, + [CONTROLLER_FAINTINGCRY] = OpponentHandleFaintingCry, + [CONTROLLER_INTROSLIDE] = OpponentHandleIntroSlide, + [CONTROLLER_INTROTRAINERBALLTHROW] = OpponentHandleIntroTrainerBallThrow, + [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = OpponentHandleDrawPartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = OpponentHandleHidePartyStatusSummary, + [CONTROLLER_ENDBOUNCE] = OpponentHandleEndBounceEffect, + [CONTROLLER_SPRITEINVISIBILITY] = OpponentHandleSpriteInvisibility, + [CONTROLLER_BATTLEANIMATION] = OpponentHandleBattleAnimation, + [CONTROLLER_LINKSTANDBYMSG] = OpponentHandleLinkStandbyMsg, + [CONTROLLER_RESETACTIONMOVESELECTION] = OpponentHandleResetActionMoveSelection, + [CONTROLLER_55] = OpponentHandleCmd55, + [CONTROLLER_TERMINATOR_NOP] = OpponentCmdEnd }; // unknown unused data -static const u8 sUnknown_0831C7AC[] = {0xB0, 0xB0, 0xC8, 0x98, 0x28, 0x28, 0x28, 0x20}; +static const u8 sUnused[] = {0xB0, 0xB0, 0xC8, 0x98, 0x28, 0x28, 0x28, 0x20}; static void nullsub_26(void) { @@ -1259,7 +1259,7 @@ static void OpponentHandleDrawTrainerPic(void) } else if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) { - if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) + if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_TOWER_LINK_MULTI)) { if (gActiveBattler == 1) trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A); @@ -1343,7 +1343,7 @@ static void OpponentHandleTrainerSlide(void) } else if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) { - if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) + if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_TOWER_LINK_MULTI)) { if (gActiveBattler == 1) trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A); @@ -1631,7 +1631,7 @@ static void OpponentHandleChoosePokemon(void) battler2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); } - if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) + if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_TOWER_LINK_MULTI)) { if (gActiveBattler == 1) firstId = 0, lastId = 3; @@ -1768,27 +1768,27 @@ static void OpponentHandleOneReturnValue_Duplicate(void) OpponentBufferExecCompleted(); } -static void OpponentHandleCmd37(void) +static void OpponentHandleClearUnkVar(void) { - gUnknown_02022D0C.field_0 = 0; + gUnusedControllerStruct.unk = 0; OpponentBufferExecCompleted(); } -static void OpponentHandleCmd38(void) +static void OpponentHandleSetUnkVar(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnusedControllerStruct.unk = gBattleBufferA[gActiveBattler][1]; OpponentBufferExecCompleted(); } -static void OpponentHandleCmd39(void) +static void OpponentHandleClearUnkFlag(void) { - gUnknown_02022D0C.flag_x80 = 0; + gUnusedControllerStruct.flag = 0; OpponentBufferExecCompleted(); } -static void OpponentHandleCmd40(void) +static void OpponentHandleToggleUnkFlag(void) { - gUnknown_02022D0C.flag_x80 ^= 1; + gUnusedControllerStruct.flag ^= 1; OpponentBufferExecCompleted(); } @@ -1857,7 +1857,6 @@ static void OpponentHandleIntroSlide(void) static void OpponentHandleIntroTrainerBallThrow(void) { - u8 paletteNum; u8 taskId; SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 1d26221fe..ba762fdb4 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -75,10 +75,10 @@ static void PlayerHandleTwoReturnValues(void); static void PlayerHandleChosenMonReturnValue(void); static void PlayerHandleOneReturnValue(void); static void PlayerHandleOneReturnValue_Duplicate(void); -static void PlayerHandleCmd37(void); -static void PlayerHandleCmd38(void); -static void PlayerHandleCmd39(void); -static void PlayerHandleCmd40(void); +static void PlayerHandleClearUnkVar(void); +static void PlayerHandleSetUnkVar(void); +static void PlayerHandleClearUnkFlag(void); +static void PlayerHandleToggleUnkFlag(void); static void PlayerHandleHitAnimation(void); static void PlayerHandleCmd42(void); static void PlayerHandlePlaySE(void); @@ -125,69 +125,69 @@ static void sub_805CE38(void); static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { - PlayerHandleGetMonData, - PlayerHandleGetRawMonData, - PlayerHandleSetMonData, - PlayerHandleSetRawMonData, - PlayerHandleLoadMonSprite, - PlayerHandleSwitchInAnim, - PlayerHandleReturnMonToBall, - PlayerHandleDrawTrainerPic, - PlayerHandleTrainerSlide, - PlayerHandleTrainerSlideBack, - PlayerHandleFaintAnimation, - PlayerHandlePaletteFade, - PlayerHandleSuccessBallThrowAnim, - PlayerHandleBallThrowAnim, - PlayerHandlePause, - PlayerHandleMoveAnimation, - PlayerHandlePrintString, - PlayerHandlePrintSelectionString, - PlayerHandleChooseAction, - PlayerHandleUnknownYesNoBox, - PlayerHandleChooseMove, - PlayerHandleChooseItem, - PlayerHandleChoosePokemon, - PlayerHandleCmd23, - PlayerHandleHealthBarUpdate, - PlayerHandleExpUpdate, - PlayerHandleStatusIconUpdate, - PlayerHandleStatusAnimation, - PlayerHandleStatusXor, - PlayerHandleDataTransfer, - PlayerHandleDMA3Transfer, - PlayerHandlePlayBGM, - PlayerHandleCmd32, - PlayerHandleTwoReturnValues, - PlayerHandleChosenMonReturnValue, - PlayerHandleOneReturnValue, - PlayerHandleOneReturnValue_Duplicate, - PlayerHandleCmd37, - PlayerHandleCmd38, - PlayerHandleCmd39, - PlayerHandleCmd40, - PlayerHandleHitAnimation, - PlayerHandleCmd42, - PlayerHandlePlaySE, - PlayerHandlePlayFanfareOrBGM, - PlayerHandleFaintingCry, - PlayerHandleIntroSlide, - PlayerHandleIntroTrainerBallThrow, - PlayerHandleDrawPartyStatusSummary, - PlayerHandleHidePartyStatusSummary, - PlayerHandleEndBounceEffect, - PlayerHandleSpriteInvisibility, - PlayerHandleBattleAnimation, - PlayerHandleLinkStandbyMsg, - PlayerHandleResetActionMoveSelection, - PlayerHandleCmd55, - PlayerCmdEnd + [CONTROLLER_GETMONDATA] = PlayerHandleGetMonData, + [CONTROLLER_GETRAWMONDATA] = PlayerHandleGetRawMonData, + [CONTROLLER_SETMONDATA] = PlayerHandleSetMonData, + [CONTROLLER_SETRAWMONDATA] = PlayerHandleSetRawMonData, + [CONTROLLER_LOADMONSPRITE] = PlayerHandleLoadMonSprite, + [CONTROLLER_SWITCHINANIM] = PlayerHandleSwitchInAnim, + [CONTROLLER_RETURNMONTOBALL] = PlayerHandleReturnMonToBall, + [CONTROLLER_DRAWTRAINERPIC] = PlayerHandleDrawTrainerPic, + [CONTROLLER_TRAINERSLIDE] = PlayerHandleTrainerSlide, + [CONTROLLER_TRAINERSLIDEBACK] = PlayerHandleTrainerSlideBack, + [CONTROLLER_FAINTANIMATION] = PlayerHandleFaintAnimation, + [CONTROLLER_PALETTEFADE] = PlayerHandlePaletteFade, + [CONTROLLER_SUCCESSBALLTHROWANIM] = PlayerHandleSuccessBallThrowAnim, + [CONTROLLER_BALLTHROWANIM] = PlayerHandleBallThrowAnim, + [CONTROLLER_PAUSE] = PlayerHandlePause, + [CONTROLLER_MOVEANIMATION] = PlayerHandleMoveAnimation, + [CONTROLLER_PRINTSTRING] = PlayerHandlePrintString, + [CONTROLLER_PRINTSTRINGPLAYERONLY] = PlayerHandlePrintSelectionString, + [CONTROLLER_CHOOSEACTION] = PlayerHandleChooseAction, + [CONTROLLER_UNKNOWNYESNOBOX] = PlayerHandleUnknownYesNoBox, + [CONTROLLER_CHOOSEMOVE] = PlayerHandleChooseMove, + [CONTROLLER_OPENBAG] = PlayerHandleChooseItem, + [CONTROLLER_CHOOSEPOKEMON] = PlayerHandleChoosePokemon, + [CONTROLLER_23] = PlayerHandleCmd23, + [CONTROLLER_HEALTHBARUPDATE] = PlayerHandleHealthBarUpdate, + [CONTROLLER_EXPUPDATE] = PlayerHandleExpUpdate, + [CONTROLLER_STATUSICONUPDATE] = PlayerHandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = PlayerHandleStatusAnimation, + [CONTROLLER_STATUSXOR] = PlayerHandleStatusXor, + [CONTROLLER_DATATRANSFER] = PlayerHandleDataTransfer, + [CONTROLLER_DMA3TRANSFER] = PlayerHandleDMA3Transfer, + [CONTROLLER_PLAYBGM] = PlayerHandlePlayBGM, + [CONTROLLER_32] = PlayerHandleCmd32, + [CONTROLLER_TWORETURNVALUES] = PlayerHandleTwoReturnValues, + [CONTROLLER_CHOSENMONRETURNVALUE] = PlayerHandleChosenMonReturnValue, + [CONTROLLER_ONERETURNVALUE] = PlayerHandleOneReturnValue, + [CONTROLLER_ONERETURNVALUE_DUPLICATE] = PlayerHandleOneReturnValue_Duplicate, + [CONTROLLER_CLEARUNKVAR] = PlayerHandleClearUnkVar, + [CONTROLLER_SETUNKVAR] = PlayerHandleSetUnkVar, + [CONTROLLER_CLEARUNKFLAG] = PlayerHandleClearUnkFlag, + [CONTROLLER_TOGGLEUNKFLAG] = PlayerHandleToggleUnkFlag, + [CONTROLLER_HITANIMATION] = PlayerHandleHitAnimation, + [CONTROLLER_42] = PlayerHandleCmd42, + [CONTROLLER_PLAYSE] = PlayerHandlePlaySE, + [CONTROLLER_PLAYFANFAREORBGM] = PlayerHandlePlayFanfareOrBGM, + [CONTROLLER_FAINTINGCRY] = PlayerHandleFaintingCry, + [CONTROLLER_INTROSLIDE] = PlayerHandleIntroSlide, + [CONTROLLER_INTROTRAINERBALLTHROW] = PlayerHandleIntroTrainerBallThrow, + [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = PlayerHandleDrawPartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = PlayerHandleHidePartyStatusSummary, + [CONTROLLER_ENDBOUNCE] = PlayerHandleEndBounceEffect, + [CONTROLLER_SPRITEINVISIBILITY] = PlayerHandleSpriteInvisibility, + [CONTROLLER_BATTLEANIMATION] = PlayerHandleBattleAnimation, + [CONTROLLER_LINKSTANDBYMSG] = PlayerHandleLinkStandbyMsg, + [CONTROLLER_RESETACTIONMOVESELECTION] = PlayerHandleResetActionMoveSelection, + [CONTROLLER_55] = PlayerHandleCmd55, + [CONTROLLER_TERMINATOR_NOP] = PlayerCmdEnd }; static const u8 sTargetIdentities[] = {B_POSITION_PLAYER_LEFT, B_POSITION_PLAYER_RIGHT, B_POSITION_OPPONENT_RIGHT, B_POSITION_OPPONENT_LEFT}; // unknown unused data -static const u8 sUnknown_0831C5FC[] = {0x48, 0x48, 0x20, 0x5a, 0x50, 0x50, 0x50, 0x58}; +static const u8 sUnused[] = {0x48, 0x48, 0x20, 0x5a, 0x50, 0x50, 0x50, 0x58}; void nullsub_21(void) { @@ -2821,27 +2821,27 @@ static void PlayerHandleOneReturnValue_Duplicate(void) PlayerBufferExecCompleted(); } -static void PlayerHandleCmd37(void) +static void PlayerHandleClearUnkVar(void) { - gUnknown_02022D0C.field_0 = 0; + gUnusedControllerStruct.unk = 0; PlayerBufferExecCompleted(); } -static void PlayerHandleCmd38(void) +static void PlayerHandleSetUnkVar(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnusedControllerStruct.unk = gBattleBufferA[gActiveBattler][1]; PlayerBufferExecCompleted(); } -static void PlayerHandleCmd39(void) +static void PlayerHandleClearUnkFlag(void) { - gUnknown_02022D0C.flag_x80 = 0; + gUnusedControllerStruct.flag = 0; PlayerBufferExecCompleted(); } -static void PlayerHandleCmd40(void) +static void PlayerHandleToggleUnkFlag(void) { - gUnknown_02022D0C.flag_x80 ^= 1; + gUnusedControllerStruct.flag ^= 1; PlayerBufferExecCompleted(); } diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index ca3db1738..ccbfcfb82 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -65,10 +65,10 @@ static void PlayerPartnerHandleTwoReturnValues(void); static void PlayerPartnerHandleChosenMonReturnValue(void); static void PlayerPartnerHandleOneReturnValue(void); static void PlayerPartnerHandleOneReturnValue_Duplicate(void); -static void PlayerPartnerHandleCmd37(void); -static void PlayerPartnerHandleCmd38(void); -static void PlayerPartnerHandleCmd39(void); -static void PlayerPartnerHandleCmd40(void); +static void PlayerPartnerHandleClearUnkVar(void); +static void PlayerPartnerHandleSetUnkVar(void); +static void PlayerPartnerHandleClearUnkFlag(void); +static void PlayerPartnerHandleToggleUnkFlag(void); static void PlayerPartnerHandleHitAnimation(void); static void PlayerPartnerHandleCmd42(void); static void PlayerPartnerHandlePlaySE(void); @@ -105,67 +105,67 @@ static void sub_81BE498(void); static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { - PlayerPartnerHandleGetMonData, - PlayerPartnerHandleGetRawMonData, - PlayerPartnerHandleSetMonData, - PlayerPartnerHandleSetRawMonData, - PlayerPartnerHandleLoadMonSprite, - PlayerPartnerHandleSwitchInAnim, - PlayerPartnerHandleReturnMonToBall, - PlayerPartnerHandleDrawTrainerPic, - PlayerPartnerHandleTrainerSlide, - PlayerPartnerHandleTrainerSlideBack, - PlayerPartnerHandleFaintAnimation, - PlayerPartnerHandlePaletteFade, - PlayerPartnerHandleSuccessBallThrowAnim, - PlayerPartnerHandleBallThrowAnim, - PlayerPartnerHandlePause, - PlayerPartnerHandleMoveAnimation, - PlayerPartnerHandlePrintString, - PlayerPartnerHandlePrintSelectionString, - PlayerPartnerHandleChooseAction, - PlayerPartnerHandleUnknownYesNoBox, - PlayerPartnerHandleChooseMove, - PlayerPartnerHandleChooseItem, - PlayerPartnerHandleChoosePokemon, - PlayerPartnerHandleCmd23, - PlayerPartnerHandleHealthBarUpdate, - PlayerPartnerHandleExpUpdate, - PlayerPartnerHandleStatusIconUpdate, - PlayerPartnerHandleStatusAnimation, - PlayerPartnerHandleStatusXor, - PlayerPartnerHandleDataTransfer, - PlayerPartnerHandleDMA3Transfer, - PlayerPartnerHandlePlayBGM, - PlayerPartnerHandleCmd32, - PlayerPartnerHandleTwoReturnValues, - PlayerPartnerHandleChosenMonReturnValue, - PlayerPartnerHandleOneReturnValue, - PlayerPartnerHandleOneReturnValue_Duplicate, - PlayerPartnerHandleCmd37, - PlayerPartnerHandleCmd38, - PlayerPartnerHandleCmd39, - PlayerPartnerHandleCmd40, - PlayerPartnerHandleHitAnimation, - PlayerPartnerHandleCmd42, - PlayerPartnerHandlePlaySE, - PlayerPartnerHandlePlayFanfareOrBGM, - PlayerPartnerHandleFaintingCry, - PlayerPartnerHandleIntroSlide, - PlayerPartnerHandleIntroTrainerBallThrow, - PlayerPartnerHandleDrawPartyStatusSummary, - PlayerPartnerHandleHidePartyStatusSummary, - PlayerPartnerHandleEndBounceEffect, - PlayerPartnerHandleSpriteInvisibility, - PlayerPartnerHandleBattleAnimation, - PlayerPartnerHandleLinkStandbyMsg, - PlayerPartnerHandleResetActionMoveSelection, - PlayerPartnerHandleCmd55, - PlayerPartnerCmdEnd + [CONTROLLER_GETMONDATA] = PlayerPartnerHandleGetMonData, + [CONTROLLER_GETRAWMONDATA] = PlayerPartnerHandleGetRawMonData, + [CONTROLLER_SETMONDATA] = PlayerPartnerHandleSetMonData, + [CONTROLLER_SETRAWMONDATA] = PlayerPartnerHandleSetRawMonData, + [CONTROLLER_LOADMONSPRITE] = PlayerPartnerHandleLoadMonSprite, + [CONTROLLER_SWITCHINANIM] = PlayerPartnerHandleSwitchInAnim, + [CONTROLLER_RETURNMONTOBALL] = PlayerPartnerHandleReturnMonToBall, + [CONTROLLER_DRAWTRAINERPIC] = PlayerPartnerHandleDrawTrainerPic, + [CONTROLLER_TRAINERSLIDE] = PlayerPartnerHandleTrainerSlide, + [CONTROLLER_TRAINERSLIDEBACK] = PlayerPartnerHandleTrainerSlideBack, + [CONTROLLER_FAINTANIMATION] = PlayerPartnerHandleFaintAnimation, + [CONTROLLER_PALETTEFADE] = PlayerPartnerHandlePaletteFade, + [CONTROLLER_SUCCESSBALLTHROWANIM] = PlayerPartnerHandleSuccessBallThrowAnim, + [CONTROLLER_BALLTHROWANIM] = PlayerPartnerHandleBallThrowAnim, + [CONTROLLER_PAUSE] = PlayerPartnerHandlePause, + [CONTROLLER_MOVEANIMATION] = PlayerPartnerHandleMoveAnimation, + [CONTROLLER_PRINTSTRING] = PlayerPartnerHandlePrintString, + [CONTROLLER_PRINTSTRINGPLAYERONLY] = PlayerPartnerHandlePrintSelectionString, + [CONTROLLER_CHOOSEACTION] = PlayerPartnerHandleChooseAction, + [CONTROLLER_UNKNOWNYESNOBOX] = PlayerPartnerHandleUnknownYesNoBox, + [CONTROLLER_CHOOSEMOVE] = PlayerPartnerHandleChooseMove, + [CONTROLLER_OPENBAG] = PlayerPartnerHandleChooseItem, + [CONTROLLER_CHOOSEPOKEMON] = PlayerPartnerHandleChoosePokemon, + [CONTROLLER_23] = PlayerPartnerHandleCmd23, + [CONTROLLER_HEALTHBARUPDATE] = PlayerPartnerHandleHealthBarUpdate, + [CONTROLLER_EXPUPDATE] = PlayerPartnerHandleExpUpdate, + [CONTROLLER_STATUSICONUPDATE] = PlayerPartnerHandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = PlayerPartnerHandleStatusAnimation, + [CONTROLLER_STATUSXOR] = PlayerPartnerHandleStatusXor, + [CONTROLLER_DATATRANSFER] = PlayerPartnerHandleDataTransfer, + [CONTROLLER_DMA3TRANSFER] = PlayerPartnerHandleDMA3Transfer, + [CONTROLLER_PLAYBGM] = PlayerPartnerHandlePlayBGM, + [CONTROLLER_32] = PlayerPartnerHandleCmd32, + [CONTROLLER_TWORETURNVALUES] = PlayerPartnerHandleTwoReturnValues, + [CONTROLLER_CHOSENMONRETURNVALUE] = PlayerPartnerHandleChosenMonReturnValue, + [CONTROLLER_ONERETURNVALUE] = PlayerPartnerHandleOneReturnValue, + [CONTROLLER_ONERETURNVALUE_DUPLICATE] = PlayerPartnerHandleOneReturnValue_Duplicate, + [CONTROLLER_CLEARUNKVAR] = PlayerPartnerHandleClearUnkVar, + [CONTROLLER_SETUNKVAR] = PlayerPartnerHandleSetUnkVar, + [CONTROLLER_CLEARUNKFLAG] = PlayerPartnerHandleClearUnkFlag, + [CONTROLLER_TOGGLEUNKFLAG] = PlayerPartnerHandleToggleUnkFlag, + [CONTROLLER_HITANIMATION] = PlayerPartnerHandleHitAnimation, + [CONTROLLER_42] = PlayerPartnerHandleCmd42, + [CONTROLLER_PLAYSE] = PlayerPartnerHandlePlaySE, + [CONTROLLER_PLAYFANFAREORBGM] = PlayerPartnerHandlePlayFanfareOrBGM, + [CONTROLLER_FAINTINGCRY] = PlayerPartnerHandleFaintingCry, + [CONTROLLER_INTROSLIDE] = PlayerPartnerHandleIntroSlide, + [CONTROLLER_INTROTRAINERBALLTHROW] = PlayerPartnerHandleIntroTrainerBallThrow, + [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = PlayerPartnerHandleDrawPartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = PlayerPartnerHandleHidePartyStatusSummary, + [CONTROLLER_ENDBOUNCE] = PlayerPartnerHandleEndBounceEffect, + [CONTROLLER_SPRITEINVISIBILITY] = PlayerPartnerHandleSpriteInvisibility, + [CONTROLLER_BATTLEANIMATION] = PlayerPartnerHandleBattleAnimation, + [CONTROLLER_LINKSTANDBYMSG] = PlayerPartnerHandleLinkStandbyMsg, + [CONTROLLER_RESETACTIONMOVESELECTION] = PlayerPartnerHandleResetActionMoveSelection, + [CONTROLLER_55] = PlayerPartnerHandleCmd55, + [CONTROLLER_TERMINATOR_NOP] = PlayerPartnerCmdEnd }; // unknown unused data -static const u8 sUnknown_08617254[] = +static const u8 sUnused[] = { 0x83, 0x4d, 0xf3, 0x5f, 0x6f, 0x4f, 0xeb, 0x3e, 0x67, 0x2e, 0x10, 0x46, 0x8c, 0x3d, 0x28, 0x35, @@ -1678,27 +1678,27 @@ static void PlayerPartnerHandleOneReturnValue_Duplicate(void) PlayerPartnerBufferExecCompleted(); } -static void PlayerPartnerHandleCmd37(void) +static void PlayerPartnerHandleClearUnkVar(void) { - gUnknown_02022D0C.field_0 = 0; + gUnusedControllerStruct.unk = 0; PlayerPartnerBufferExecCompleted(); } -static void PlayerPartnerHandleCmd38(void) +static void PlayerPartnerHandleSetUnkVar(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnusedControllerStruct.unk = gBattleBufferA[gActiveBattler][1]; PlayerPartnerBufferExecCompleted(); } -static void PlayerPartnerHandleCmd39(void) +static void PlayerPartnerHandleClearUnkFlag(void) { - gUnknown_02022D0C.flag_x80 = 0; + gUnusedControllerStruct.flag = 0; PlayerPartnerBufferExecCompleted(); } -static void PlayerPartnerHandleCmd40(void) +static void PlayerPartnerHandleToggleUnkFlag(void) { - gUnknown_02022D0C.flag_x80 ^= 1; + gUnusedControllerStruct.flag ^= 1; PlayerPartnerBufferExecCompleted(); } diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 7bbac36e4..c6e7c238c 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -69,10 +69,10 @@ static void RecordedOpponentHandleTwoReturnValues(void); static void RecordedOpponentHandleChosenMonReturnValue(void); static void RecordedOpponentHandleOneReturnValue(void); static void RecordedOpponentHandleOneReturnValue_Duplicate(void); -static void RecordedOpponentHandleCmd37(void); -static void RecordedOpponentHandleCmd38(void); -static void RecordedOpponentHandleCmd39(void); -static void RecordedOpponentHandleCmd40(void); +static void RecordedOpponentHandleClearUnkVar(void); +static void RecordedOpponentHandleSetUnkVar(void); +static void RecordedOpponentHandleClearUnkFlag(void); +static void RecordedOpponentHandleToggleUnkFlag(void); static void RecordedOpponentHandleHitAnimation(void); static void RecordedOpponentHandleCmd42(void); static void RecordedOpponentHandlePlaySE(void); @@ -104,63 +104,63 @@ static void sub_818975C(void); static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { - RecordedOpponentHandleGetMonData, - RecordedOpponentHandleGetRawMonData, - RecordedOpponentHandleSetMonData, - RecordedOpponentHandleSetRawMonData, - RecordedOpponentHandleLoadMonSprite, - RecordedOpponentHandleSwitchInAnim, - RecordedOpponentHandleReturnMonToBall, - RecordedOpponentHandleDrawTrainerPic, - RecordedOpponentHandleTrainerSlide, - RecordedOpponentHandleTrainerSlideBack, - RecordedOpponentHandleFaintAnimation, - RecordedOpponentHandlePaletteFade, - RecordedOpponentHandleSuccessBallThrowAnim, - RecordedOpponentHandleBallThrowAnim, - RecordedOpponentHandlePause, - RecordedOpponentHandleMoveAnimation, - RecordedOpponentHandlePrintString, - RecordedOpponentHandlePrintSelectionString, - RecordedOpponentHandleChooseAction, - RecordedOpponentHandleUnknownYesNoBox, - RecordedOpponentHandleChooseMove, - RecordedOpponentHandleChooseItem, - RecordedOpponentHandleChoosePokemon, - RecordedOpponentHandleCmd23, - RecordedOpponentHandleHealthBarUpdate, - RecordedOpponentHandleExpUpdate, - RecordedOpponentHandleStatusIconUpdate, - RecordedOpponentHandleStatusAnimation, - RecordedOpponentHandleStatusXor, - RecordedOpponentHandleDataTransfer, - RecordedOpponentHandleDMA3Transfer, - RecordedOpponentHandlePlayBGM, - RecordedOpponentHandleCmd32, - RecordedOpponentHandleTwoReturnValues, - RecordedOpponentHandleChosenMonReturnValue, - RecordedOpponentHandleOneReturnValue, - RecordedOpponentHandleOneReturnValue_Duplicate, - RecordedOpponentHandleCmd37, - RecordedOpponentHandleCmd38, - RecordedOpponentHandleCmd39, - RecordedOpponentHandleCmd40, - RecordedOpponentHandleHitAnimation, - RecordedOpponentHandleCmd42, - RecordedOpponentHandlePlaySE, - RecordedOpponentHandlePlayFanfareOrBGM, - RecordedOpponentHandleFaintingCry, - RecordedOpponentHandleIntroSlide, - RecordedOpponentHandleIntroTrainerBallThrow, - RecordedOpponentHandleDrawPartyStatusSummary, - RecordedOpponentHandleHidePartyStatusSummary, - RecordedOpponentHandleEndBounceEffect, - RecordedOpponentHandleSpriteInvisibility, - RecordedOpponentHandleBattleAnimation, - RecordedOpponentHandleLinkStandbyMsg, - RecordedOpponentHandleResetActionMoveSelection, - RecordedOpponentHandleCmd55, - RecordedOpponentCmdEnd + [CONTROLLER_GETMONDATA] = RecordedOpponentHandleGetMonData, + [CONTROLLER_GETRAWMONDATA] = RecordedOpponentHandleGetRawMonData, + [CONTROLLER_SETMONDATA] = RecordedOpponentHandleSetMonData, + [CONTROLLER_SETRAWMONDATA] = RecordedOpponentHandleSetRawMonData, + [CONTROLLER_LOADMONSPRITE] = RecordedOpponentHandleLoadMonSprite, + [CONTROLLER_SWITCHINANIM] = RecordedOpponentHandleSwitchInAnim, + [CONTROLLER_RETURNMONTOBALL] = RecordedOpponentHandleReturnMonToBall, + [CONTROLLER_DRAWTRAINERPIC] = RecordedOpponentHandleDrawTrainerPic, + [CONTROLLER_TRAINERSLIDE] = RecordedOpponentHandleTrainerSlide, + [CONTROLLER_TRAINERSLIDEBACK] = RecordedOpponentHandleTrainerSlideBack, + [CONTROLLER_FAINTANIMATION] = RecordedOpponentHandleFaintAnimation, + [CONTROLLER_PALETTEFADE] = RecordedOpponentHandlePaletteFade, + [CONTROLLER_SUCCESSBALLTHROWANIM] = RecordedOpponentHandleSuccessBallThrowAnim, + [CONTROLLER_BALLTHROWANIM] = RecordedOpponentHandleBallThrowAnim, + [CONTROLLER_PAUSE] = RecordedOpponentHandlePause, + [CONTROLLER_MOVEANIMATION] = RecordedOpponentHandleMoveAnimation, + [CONTROLLER_PRINTSTRING] = RecordedOpponentHandlePrintString, + [CONTROLLER_PRINTSTRINGPLAYERONLY] = RecordedOpponentHandlePrintSelectionString, + [CONTROLLER_CHOOSEACTION] = RecordedOpponentHandleChooseAction, + [CONTROLLER_UNKNOWNYESNOBOX] = RecordedOpponentHandleUnknownYesNoBox, + [CONTROLLER_CHOOSEMOVE] = RecordedOpponentHandleChooseMove, + [CONTROLLER_OPENBAG] = RecordedOpponentHandleChooseItem, + [CONTROLLER_CHOOSEPOKEMON] = RecordedOpponentHandleChoosePokemon, + [CONTROLLER_23] = RecordedOpponentHandleCmd23, + [CONTROLLER_HEALTHBARUPDATE] = RecordedOpponentHandleHealthBarUpdate, + [CONTROLLER_EXPUPDATE] = RecordedOpponentHandleExpUpdate, + [CONTROLLER_STATUSICONUPDATE] = RecordedOpponentHandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = RecordedOpponentHandleStatusAnimation, + [CONTROLLER_STATUSXOR] = RecordedOpponentHandleStatusXor, + [CONTROLLER_DATATRANSFER] = RecordedOpponentHandleDataTransfer, + [CONTROLLER_DMA3TRANSFER] = RecordedOpponentHandleDMA3Transfer, + [CONTROLLER_PLAYBGM] = RecordedOpponentHandlePlayBGM, + [CONTROLLER_32] = RecordedOpponentHandleCmd32, + [CONTROLLER_TWORETURNVALUES] = RecordedOpponentHandleTwoReturnValues, + [CONTROLLER_CHOSENMONRETURNVALUE] = RecordedOpponentHandleChosenMonReturnValue, + [CONTROLLER_ONERETURNVALUE] = RecordedOpponentHandleOneReturnValue, + [CONTROLLER_ONERETURNVALUE_DUPLICATE] = RecordedOpponentHandleOneReturnValue_Duplicate, + [CONTROLLER_CLEARUNKVAR] = RecordedOpponentHandleClearUnkVar, + [CONTROLLER_SETUNKVAR] = RecordedOpponentHandleSetUnkVar, + [CONTROLLER_CLEARUNKFLAG] = RecordedOpponentHandleClearUnkFlag, + [CONTROLLER_TOGGLEUNKFLAG] = RecordedOpponentHandleToggleUnkFlag, + [CONTROLLER_HITANIMATION] = RecordedOpponentHandleHitAnimation, + [CONTROLLER_42] = RecordedOpponentHandleCmd42, + [CONTROLLER_PLAYSE] = RecordedOpponentHandlePlaySE, + [CONTROLLER_PLAYFANFAREORBGM] = RecordedOpponentHandlePlayFanfareOrBGM, + [CONTROLLER_FAINTINGCRY] = RecordedOpponentHandleFaintingCry, + [CONTROLLER_INTROSLIDE] = RecordedOpponentHandleIntroSlide, + [CONTROLLER_INTROTRAINERBALLTHROW] = RecordedOpponentHandleIntroTrainerBallThrow, + [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = RecordedOpponentHandleDrawPartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = RecordedOpponentHandleHidePartyStatusSummary, + [CONTROLLER_ENDBOUNCE] = RecordedOpponentHandleEndBounceEffect, + [CONTROLLER_SPRITEINVISIBILITY] = RecordedOpponentHandleSpriteInvisibility, + [CONTROLLER_BATTLEANIMATION] = RecordedOpponentHandleBattleAnimation, + [CONTROLLER_LINKSTANDBYMSG] = RecordedOpponentHandleLinkStandbyMsg, + [CONTROLLER_RESETACTIONMOVESELECTION] = RecordedOpponentHandleResetActionMoveSelection, + [CONTROLLER_55] = RecordedOpponentHandleCmd55, + [CONTROLLER_TERMINATOR_NOP] = RecordedOpponentCmdEnd }; static void nullsub_70(void) @@ -1235,7 +1235,7 @@ static void RecordedOpponentHandleDrawTrainerPic(void) } else { - trainerPicId = PlayerGenderToFrontTrainerPicId(gLinkPlayers[gUnknown_0203C7B4 ^ BIT_SIDE].gender); + trainerPicId = PlayerGenderToFrontTrainerPicId(gLinkPlayers[gRecordedBattleMultiplayerId ^ BIT_SIDE].gender); } } @@ -1543,27 +1543,27 @@ static void RecordedOpponentHandleOneReturnValue_Duplicate(void) RecordedOpponentBufferExecCompleted(); } -static void RecordedOpponentHandleCmd37(void) +static void RecordedOpponentHandleClearUnkVar(void) { - gUnknown_02022D0C.field_0 = 0; + gUnusedControllerStruct.unk = 0; RecordedOpponentBufferExecCompleted(); } -static void RecordedOpponentHandleCmd38(void) +static void RecordedOpponentHandleSetUnkVar(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnusedControllerStruct.unk = gBattleBufferA[gActiveBattler][1]; RecordedOpponentBufferExecCompleted(); } -static void RecordedOpponentHandleCmd39(void) +static void RecordedOpponentHandleClearUnkFlag(void) { - gUnknown_02022D0C.flag_x80 = 0; + gUnusedControllerStruct.flag = 0; RecordedOpponentBufferExecCompleted(); } -static void RecordedOpponentHandleCmd40(void) +static void RecordedOpponentHandleToggleUnkFlag(void) { - gUnknown_02022D0C.flag_x80 ^= 1; + gUnusedControllerStruct.flag ^= 1; RecordedOpponentBufferExecCompleted(); } @@ -1632,7 +1632,6 @@ static void RecordedOpponentHandleIntroSlide(void) static void RecordedOpponentHandleIntroTrainerBallThrow(void) { - u8 paletteNum; u8 taskId; SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 1f4847b00..8f3f1d1f2 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -65,10 +65,10 @@ static void RecordedPlayerHandleTwoReturnValues(void); static void RecordedPlayerHandleChosenMonReturnValue(void); static void RecordedPlayerHandleOneReturnValue(void); static void RecordedPlayerHandleOneReturnValue_Duplicate(void); -static void RecordedPlayerHandleCmd37(void); -static void RecordedPlayerHandleCmd38(void); -static void RecordedPlayerHandleCmd39(void); -static void RecordedPlayerHandleCmd40(void); +static void RecordedPlayerHandleClearUnkVar(void); +static void RecordedPlayerHandleSetUnkVar(void); +static void RecordedPlayerHandleClearUnkFlag(void); +static void RecordedPlayerHandleToggleUnkFlag(void); static void RecordedPlayerHandleHitAnimation(void); static void RecordedPlayerHandleCmd42(void); static void RecordedPlayerHandlePlaySE(void); @@ -99,63 +99,63 @@ static void sub_818CDF4(void); static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { - RecordedPlayerHandleGetMonData, - RecordedPlayerHandleGetRawMonData, - RecordedPlayerHandleSetMonData, - RecordedPlayerHandleSetRawMonData, - RecordedPlayerHandleLoadMonSprite, - RecordedPlayerHandleSwitchInAnim, - RecordedPlayerHandleReturnMonToBall, - RecordedPlayerHandleDrawTrainerPic, - RecordedPlayerHandleTrainerSlide, - RecordedPlayerHandleTrainerSlideBack, - RecordedPlayerHandleFaintAnimation, - RecordedPlayerHandlePaletteFade, - RecordedPlayerHandleSuccessBallThrowAnim, - RecordedPlayerHandleBallThrowAnim, - RecordedPlayerHandlePause, - RecordedPlayerHandleMoveAnimation, - RecordedPlayerHandlePrintString, - RecordedPlayerHandlePrintSelectionString, - RecordedPlayerHandleChooseAction, - RecordedPlayerHandleUnknownYesNoBox, - RecordedPlayerHandleChooseMove, - RecordedPlayerHandleChooseItem, - RecordedPlayerHandleChoosePokemon, - RecordedPlayerHandleCmd23, - RecordedPlayerHandleHealthBarUpdate, - RecordedPlayerHandleExpUpdate, - RecordedPlayerHandleStatusIconUpdate, - RecordedPlayerHandleStatusAnimation, - RecordedPlayerHandleStatusXor, - RecordedPlayerHandleDataTransfer, - RecordedPlayerHandleDMA3Transfer, - RecordedPlayerHandlePlayBGM, - RecordedPlayerHandleCmd32, - RecordedPlayerHandleTwoReturnValues, - RecordedPlayerHandleChosenMonReturnValue, - RecordedPlayerHandleOneReturnValue, - RecordedPlayerHandleOneReturnValue_Duplicate, - RecordedPlayerHandleCmd37, - RecordedPlayerHandleCmd38, - RecordedPlayerHandleCmd39, - RecordedPlayerHandleCmd40, - RecordedPlayerHandleHitAnimation, - RecordedPlayerHandleCmd42, - RecordedPlayerHandlePlaySE, - RecordedPlayerHandlePlayFanfareOrBGM, - RecordedPlayerHandleFaintingCry, - RecordedPlayerHandleIntroSlide, - RecordedPlayerHandleIntroTrainerBallThrow, - RecordedPlayerHandleDrawPartyStatusSummary, - RecordedPlayerHandleHidePartyStatusSummary, - RecordedPlayerHandleEndBounceEffect, - RecordedPlayerHandleSpriteInvisibility, - RecordedPlayerHandleBattleAnimation, - RecordedPlayerHandleLinkStandbyMsg, - RecordedPlayerHandleResetActionMoveSelection, - RecordedPlayerHandleCmd55, - RecordedPlayerCmdEnd + [CONTROLLER_GETMONDATA] = RecordedPlayerHandleGetMonData, + [CONTROLLER_GETRAWMONDATA] = RecordedPlayerHandleGetRawMonData, + [CONTROLLER_SETMONDATA] = RecordedPlayerHandleSetMonData, + [CONTROLLER_SETRAWMONDATA] = RecordedPlayerHandleSetRawMonData, + [CONTROLLER_LOADMONSPRITE] = RecordedPlayerHandleLoadMonSprite, + [CONTROLLER_SWITCHINANIM] = RecordedPlayerHandleSwitchInAnim, + [CONTROLLER_RETURNMONTOBALL] = RecordedPlayerHandleReturnMonToBall, + [CONTROLLER_DRAWTRAINERPIC] = RecordedPlayerHandleDrawTrainerPic, + [CONTROLLER_TRAINERSLIDE] = RecordedPlayerHandleTrainerSlide, + [CONTROLLER_TRAINERSLIDEBACK] = RecordedPlayerHandleTrainerSlideBack, + [CONTROLLER_FAINTANIMATION] = RecordedPlayerHandleFaintAnimation, + [CONTROLLER_PALETTEFADE] = RecordedPlayerHandlePaletteFade, + [CONTROLLER_SUCCESSBALLTHROWANIM] = RecordedPlayerHandleSuccessBallThrowAnim, + [CONTROLLER_BALLTHROWANIM] = RecordedPlayerHandleBallThrowAnim, + [CONTROLLER_PAUSE] = RecordedPlayerHandlePause, + [CONTROLLER_MOVEANIMATION] = RecordedPlayerHandleMoveAnimation, + [CONTROLLER_PRINTSTRING] = RecordedPlayerHandlePrintString, + [CONTROLLER_PRINTSTRINGPLAYERONLY] = RecordedPlayerHandlePrintSelectionString, + [CONTROLLER_CHOOSEACTION] = RecordedPlayerHandleChooseAction, + [CONTROLLER_UNKNOWNYESNOBOX] = RecordedPlayerHandleUnknownYesNoBox, + [CONTROLLER_CHOOSEMOVE] = RecordedPlayerHandleChooseMove, + [CONTROLLER_OPENBAG] = RecordedPlayerHandleChooseItem, + [CONTROLLER_CHOOSEPOKEMON] = RecordedPlayerHandleChoosePokemon, + [CONTROLLER_23] = RecordedPlayerHandleCmd23, + [CONTROLLER_HEALTHBARUPDATE] = RecordedPlayerHandleHealthBarUpdate, + [CONTROLLER_EXPUPDATE] = RecordedPlayerHandleExpUpdate, + [CONTROLLER_STATUSICONUPDATE] = RecordedPlayerHandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = RecordedPlayerHandleStatusAnimation, + [CONTROLLER_STATUSXOR] = RecordedPlayerHandleStatusXor, + [CONTROLLER_DATATRANSFER] = RecordedPlayerHandleDataTransfer, + [CONTROLLER_DMA3TRANSFER] = RecordedPlayerHandleDMA3Transfer, + [CONTROLLER_PLAYBGM] = RecordedPlayerHandlePlayBGM, + [CONTROLLER_32] = RecordedPlayerHandleCmd32, + [CONTROLLER_TWORETURNVALUES] = RecordedPlayerHandleTwoReturnValues, + [CONTROLLER_CHOSENMONRETURNVALUE] = RecordedPlayerHandleChosenMonReturnValue, + [CONTROLLER_ONERETURNVALUE] = RecordedPlayerHandleOneReturnValue, + [CONTROLLER_ONERETURNVALUE_DUPLICATE] = RecordedPlayerHandleOneReturnValue_Duplicate, + [CONTROLLER_CLEARUNKVAR] = RecordedPlayerHandleClearUnkVar, + [CONTROLLER_SETUNKVAR] = RecordedPlayerHandleSetUnkVar, + [CONTROLLER_CLEARUNKFLAG] = RecordedPlayerHandleClearUnkFlag, + [CONTROLLER_TOGGLEUNKFLAG] = RecordedPlayerHandleToggleUnkFlag, + [CONTROLLER_HITANIMATION] = RecordedPlayerHandleHitAnimation, + [CONTROLLER_42] = RecordedPlayerHandleCmd42, + [CONTROLLER_PLAYSE] = RecordedPlayerHandlePlaySE, + [CONTROLLER_PLAYFANFAREORBGM] = RecordedPlayerHandlePlayFanfareOrBGM, + [CONTROLLER_FAINTINGCRY] = RecordedPlayerHandleFaintingCry, + [CONTROLLER_INTROSLIDE] = RecordedPlayerHandleIntroSlide, + [CONTROLLER_INTROTRAINERBALLTHROW] = RecordedPlayerHandleIntroTrainerBallThrow, + [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = RecordedPlayerHandleDrawPartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = RecordedPlayerHandleHidePartyStatusSummary, + [CONTROLLER_ENDBOUNCE] = RecordedPlayerHandleEndBounceEffect, + [CONTROLLER_SPRITEINVISIBILITY] = RecordedPlayerHandleSpriteInvisibility, + [CONTROLLER_BATTLEANIMATION] = RecordedPlayerHandleBattleAnimation, + [CONTROLLER_LINKSTANDBYMSG] = RecordedPlayerHandleLinkStandbyMsg, + [CONTROLLER_RESETACTIONMOVESELECTION] = RecordedPlayerHandleResetActionMoveSelection, + [CONTROLLER_55] = RecordedPlayerHandleCmd55, + [CONTROLLER_TERMINATOR_NOP] = RecordedPlayerCmdEnd }; static void nullsub_120(void) @@ -1186,12 +1186,12 @@ static void RecordedPlayerHandleDrawTrainerPic(void) s16 xPos, yPos; u32 trainerPicId; - if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI) trainerPicId = GetActiveBattlerLinkPlayerGender(); else - trainerPicId = gLinkPlayers[gUnknown_0203C7B4].gender; + trainerPicId = gLinkPlayers[gRecordedBattleMultiplayerId].gender; } else { @@ -1560,27 +1560,27 @@ static void RecordedPlayerHandleOneReturnValue_Duplicate(void) RecordedPlayerBufferExecCompleted(); } -static void RecordedPlayerHandleCmd37(void) +static void RecordedPlayerHandleClearUnkVar(void) { - gUnknown_02022D0C.field_0 = 0; + gUnusedControllerStruct.unk = 0; RecordedPlayerBufferExecCompleted(); } -static void RecordedPlayerHandleCmd38(void) +static void RecordedPlayerHandleSetUnkVar(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnusedControllerStruct.unk = gBattleBufferA[gActiveBattler][1]; RecordedPlayerBufferExecCompleted(); } -static void RecordedPlayerHandleCmd39(void) +static void RecordedPlayerHandleClearUnkFlag(void) { - gUnknown_02022D0C.flag_x80 = 0; + gUnusedControllerStruct.flag = 0; RecordedPlayerBufferExecCompleted(); } -static void RecordedPlayerHandleCmd40(void) +static void RecordedPlayerHandleToggleUnkFlag(void) { - gUnknown_02022D0C.flag_x80 ^= 1; + gUnusedControllerStruct.flag ^= 1; RecordedPlayerBufferExecCompleted(); } @@ -1665,7 +1665,7 @@ static void RecordedPlayerHandleIntroTrainerBallThrow(void) StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1); paletteNum = AllocSpritePalette(0xD6F9); - if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender; else trainerPicId = gSaveBlock2Ptr->playerGender; diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 9cb427e12..b357c689f 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -62,10 +62,10 @@ static void SafariHandleTwoReturnValues(void); static void SafariHandleChosenMonReturnValue(void); static void SafariHandleOneReturnValue(void); static void SafariHandleOneReturnValue_Duplicate(void); -static void SafariHandleCmd37(void); -static void SafariHandleCmd38(void); -static void SafariHandleCmd39(void); -static void SafariHandleCmd40(void); +static void SafariHandleClearUnkVar(void); +static void SafariHandleSetUnkVar(void); +static void SafariHandleClearUnkFlag(void); +static void SafariHandleToggleUnkFlag(void); static void SafariHandleHitAnimation(void); static void SafariHandleCmd42(void); static void SafariHandlePlaySE(void); @@ -89,63 +89,63 @@ static void CompleteWhenChosePokeblock(void); static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { - SafariHandleGetMonData, - SafariHandleGetRawMonData, - SafariHandleSetMonData, - SafariHandleSetRawMonData, - SafariHandleLoadMonSprite, - SafariHandleSwitchInAnim, - SafariHandleReturnMonToBall, - SafariHandleDrawTrainerPic, - SafariHandleTrainerSlide, - SafariHandleTrainerSlideBack, - SafariHandleFaintAnimation, - SafariHandlePaletteFade, - SafariHandleSuccessBallThrowAnim, - SafariHandleBallThrowAnim, - SafariHandlePause, - SafariHandleMoveAnimation, - SafariHandlePrintString, - SafariHandlePrintSelectionString, - SafariHandleChooseAction, - SafariHandleUnknownYesNoBox, - SafariHandleChooseMove, - SafariHandleChooseItem, - SafariHandleChoosePokemon, - SafariHandleCmd23, - SafariHandleHealthBarUpdate, - SafariHandleExpUpdate, - SafariHandleStatusIconUpdate, - SafariHandleStatusAnimation, - SafariHandleStatusXor, - SafariHandleDataTransfer, - SafariHandleDMA3Transfer, - SafariHandlePlayBGM, - SafariHandleCmd32, - SafariHandleTwoReturnValues, - SafariHandleChosenMonReturnValue, - SafariHandleOneReturnValue, - SafariHandleOneReturnValue_Duplicate, - SafariHandleCmd37, - SafariHandleCmd38, - SafariHandleCmd39, - SafariHandleCmd40, - SafariHandleHitAnimation, - SafariHandleCmd42, - SafariHandlePlaySE, - SafariHandlePlayFanfareOrBGM, - SafariHandleFaintingCry, - SafariHandleIntroSlide, - SafariHandleIntroTrainerBallThrow, - SafariHandleDrawPartyStatusSummary, - SafariHandleHidePartyStatusSummary, - SafariHandleEndBounceEffect, - SafariHandleSpriteInvisibility, - SafariHandleBattleAnimation, - SafariHandleLinkStandbyMsg, - SafariHandleResetActionMoveSelection, - SafariHandleCmd55, - SafariCmdEnd + [CONTROLLER_GETMONDATA] = SafariHandleGetMonData, + [CONTROLLER_GETRAWMONDATA] = SafariHandleGetRawMonData, + [CONTROLLER_SETMONDATA] = SafariHandleSetMonData, + [CONTROLLER_SETRAWMONDATA] = SafariHandleSetRawMonData, + [CONTROLLER_LOADMONSPRITE] = SafariHandleLoadMonSprite, + [CONTROLLER_SWITCHINANIM] = SafariHandleSwitchInAnim, + [CONTROLLER_RETURNMONTOBALL] = SafariHandleReturnMonToBall, + [CONTROLLER_DRAWTRAINERPIC] = SafariHandleDrawTrainerPic, + [CONTROLLER_TRAINERSLIDE] = SafariHandleTrainerSlide, + [CONTROLLER_TRAINERSLIDEBACK] = SafariHandleTrainerSlideBack, + [CONTROLLER_FAINTANIMATION] = SafariHandleFaintAnimation, + [CONTROLLER_PALETTEFADE] = SafariHandlePaletteFade, + [CONTROLLER_SUCCESSBALLTHROWANIM] = SafariHandleSuccessBallThrowAnim, + [CONTROLLER_BALLTHROWANIM] = SafariHandleBallThrowAnim, + [CONTROLLER_PAUSE] = SafariHandlePause, + [CONTROLLER_MOVEANIMATION] = SafariHandleMoveAnimation, + [CONTROLLER_PRINTSTRING] = SafariHandlePrintString, + [CONTROLLER_PRINTSTRINGPLAYERONLY] = SafariHandlePrintSelectionString, + [CONTROLLER_CHOOSEACTION] = SafariHandleChooseAction, + [CONTROLLER_UNKNOWNYESNOBOX] = SafariHandleUnknownYesNoBox, + [CONTROLLER_CHOOSEMOVE] = SafariHandleChooseMove, + [CONTROLLER_OPENBAG] = SafariHandleChooseItem, + [CONTROLLER_CHOOSEPOKEMON] = SafariHandleChoosePokemon, + [CONTROLLER_23] = SafariHandleCmd23, + [CONTROLLER_HEALTHBARUPDATE] = SafariHandleHealthBarUpdate, + [CONTROLLER_EXPUPDATE] = SafariHandleExpUpdate, + [CONTROLLER_STATUSICONUPDATE] = SafariHandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = SafariHandleStatusAnimation, + [CONTROLLER_STATUSXOR] = SafariHandleStatusXor, + [CONTROLLER_DATATRANSFER] = SafariHandleDataTransfer, + [CONTROLLER_DMA3TRANSFER] = SafariHandleDMA3Transfer, + [CONTROLLER_PLAYBGM] = SafariHandlePlayBGM, + [CONTROLLER_32] = SafariHandleCmd32, + [CONTROLLER_TWORETURNVALUES] = SafariHandleTwoReturnValues, + [CONTROLLER_CHOSENMONRETURNVALUE] = SafariHandleChosenMonReturnValue, + [CONTROLLER_ONERETURNVALUE] = SafariHandleOneReturnValue, + [CONTROLLER_ONERETURNVALUE_DUPLICATE] = SafariHandleOneReturnValue_Duplicate, + [CONTROLLER_CLEARUNKVAR] = SafariHandleClearUnkVar, + [CONTROLLER_SETUNKVAR] = SafariHandleSetUnkVar, + [CONTROLLER_CLEARUNKFLAG] = SafariHandleClearUnkFlag, + [CONTROLLER_TOGGLEUNKFLAG] = SafariHandleToggleUnkFlag, + [CONTROLLER_HITANIMATION] = SafariHandleHitAnimation, + [CONTROLLER_42] = SafariHandleCmd42, + [CONTROLLER_PLAYSE] = SafariHandlePlaySE, + [CONTROLLER_PLAYFANFAREORBGM] = SafariHandlePlayFanfareOrBGM, + [CONTROLLER_FAINTINGCRY] = SafariHandleFaintingCry, + [CONTROLLER_INTROSLIDE] = SafariHandleIntroSlide, + [CONTROLLER_INTROTRAINERBALLTHROW] = SafariHandleIntroTrainerBallThrow, + [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = SafariHandleDrawPartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = SafariHandleHidePartyStatusSummary, + [CONTROLLER_ENDBOUNCE] = SafariHandleEndBounceEffect, + [CONTROLLER_SPRITEINVISIBILITY] = SafariHandleSpriteInvisibility, + [CONTROLLER_BATTLEANIMATION] = SafariHandleBattleAnimation, + [CONTROLLER_LINKSTANDBYMSG] = SafariHandleLinkStandbyMsg, + [CONTROLLER_RESETACTIONMOVESELECTION] = SafariHandleResetActionMoveSelection, + [CONTROLLER_55] = SafariHandleCmd55, + [CONTROLLER_TERMINATOR_NOP] = SafariCmdEnd }; static void SpriteCB_Null4(void) @@ -470,8 +470,6 @@ static void SafariHandleChooseMove(void) static void SafariHandleChooseItem(void) { - s32 i; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gBattlerControllerFuncs[gActiveBattler] = SafariOpenPokeblockCase; gBattlerInMenuId = gActiveBattler; @@ -553,22 +551,22 @@ static void SafariHandleOneReturnValue_Duplicate(void) SafariBufferExecCompleted(); } -static void SafariHandleCmd37(void) +static void SafariHandleClearUnkVar(void) { SafariBufferExecCompleted(); } -static void SafariHandleCmd38(void) +static void SafariHandleSetUnkVar(void) { SafariBufferExecCompleted(); } -static void SafariHandleCmd39(void) +static void SafariHandleClearUnkFlag(void) { SafariBufferExecCompleted(); } -static void SafariHandleCmd40(void) +static void SafariHandleToggleUnkFlag(void) { SafariBufferExecCompleted(); } diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 300837380..18bc5b2eb 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -70,10 +70,10 @@ static void WallyHandleTwoReturnValues(void); static void WallyHandleChosenMonReturnValue(void); static void WallyHandleOneReturnValue(void); static void WallyHandleOneReturnValue_Duplicate(void); -static void WallyHandleCmd37(void); -static void WallyHandleCmd38(void); -static void WallyHandleCmd39(void); -static void WallyHandleCmd40(void); +static void WallyHandleClearUnkVar(void); +static void WallyHandleSetUnkVar(void); +static void WallyHandleClearUnkFlag(void); +static void WallyHandleToggleUnkFlag(void); static void WallyHandleHitAnimation(void); static void WallyHandleCmd42(void); static void WallyHandlePlaySE(void); @@ -102,63 +102,63 @@ static void sub_816AC04(u8 taskId); static void (*const sWallyBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { - WallyHandleGetMonData, - WallyHandleGetRawMonData, - WallyHandleSetMonData, - WallyHandleSetRawMonData, - WallyHandleLoadMonSprite, - WallyHandleSwitchInAnim, - WallyHandleReturnMonToBall, - WallyHandleDrawTrainerPic, - WallyHandleTrainerSlide, - WallyHandleTrainerSlideBack, - WallyHandleFaintAnimation, - WallyHandlePaletteFade, - WallyHandleSuccessBallThrowAnim, - WallyHandleBallThrowAnim, - WallyHandlePause, - WallyHandleMoveAnimation, - WallyHandlePrintString, - WallyHandlePrintSelectionString, - WallyHandleChooseAction, - WallyHandleUnknownYesNoBox, - WallyHandleChooseMove, - WallyHandleChooseItem, - WallyHandleChoosePokemon, - WallyHandleCmd23, - WallyHandleHealthBarUpdate, - WallyHandleExpUpdate, - WallyHandleStatusIconUpdate, - WallyHandleStatusAnimation, - WallyHandleStatusXor, - WallyHandleDataTransfer, - WallyHandleDMA3Transfer, - WallyHandlePlayBGM, - WallyHandleCmd32, - WallyHandleTwoReturnValues, - WallyHandleChosenMonReturnValue, - WallyHandleOneReturnValue, - WallyHandleOneReturnValue_Duplicate, - WallyHandleCmd37, - WallyHandleCmd38, - WallyHandleCmd39, - WallyHandleCmd40, - WallyHandleHitAnimation, - WallyHandleCmd42, - WallyHandlePlaySE, - WallyHandlePlayFanfareOrBGM, - WallyHandleFaintingCry, - WallyHandleIntroSlide, - WallyHandleIntroTrainerBallThrow, - WallyHandleDrawPartyStatusSummary, - WallyHandleHidePartyStatusSummary, - WallyHandleEndBounceEffect, - WallyHandleSpriteInvisibility, - WallyHandleBattleAnimation, - WallyHandleLinkStandbyMsg, - WallyHandleResetActionMoveSelection, - WallyHandleCmd55, - WallyCmdEnd + [CONTROLLER_GETMONDATA] = WallyHandleGetMonData, + [CONTROLLER_GETRAWMONDATA] = WallyHandleGetRawMonData, + [CONTROLLER_SETMONDATA] = WallyHandleSetMonData, + [CONTROLLER_SETRAWMONDATA] = WallyHandleSetRawMonData, + [CONTROLLER_LOADMONSPRITE] = WallyHandleLoadMonSprite, + [CONTROLLER_SWITCHINANIM] = WallyHandleSwitchInAnim, + [CONTROLLER_RETURNMONTOBALL] = WallyHandleReturnMonToBall, + [CONTROLLER_DRAWTRAINERPIC] = WallyHandleDrawTrainerPic, + [CONTROLLER_TRAINERSLIDE] = WallyHandleTrainerSlide, + [CONTROLLER_TRAINERSLIDEBACK] = WallyHandleTrainerSlideBack, + [CONTROLLER_FAINTANIMATION] = WallyHandleFaintAnimation, + [CONTROLLER_PALETTEFADE] = WallyHandlePaletteFade, + [CONTROLLER_SUCCESSBALLTHROWANIM] = WallyHandleSuccessBallThrowAnim, + [CONTROLLER_BALLTHROWANIM] = WallyHandleBallThrowAnim, + [CONTROLLER_PAUSE] = WallyHandlePause, + [CONTROLLER_MOVEANIMATION] = WallyHandleMoveAnimation, + [CONTROLLER_PRINTSTRING] = WallyHandlePrintString, + [CONTROLLER_PRINTSTRINGPLAYERONLY] = WallyHandlePrintSelectionString, + [CONTROLLER_CHOOSEACTION] = WallyHandleChooseAction, + [CONTROLLER_UNKNOWNYESNOBOX] = WallyHandleUnknownYesNoBox, + [CONTROLLER_CHOOSEMOVE] = WallyHandleChooseMove, + [CONTROLLER_OPENBAG] = WallyHandleChooseItem, + [CONTROLLER_CHOOSEPOKEMON] = WallyHandleChoosePokemon, + [CONTROLLER_23] = WallyHandleCmd23, + [CONTROLLER_HEALTHBARUPDATE] = WallyHandleHealthBarUpdate, + [CONTROLLER_EXPUPDATE] = WallyHandleExpUpdate, + [CONTROLLER_STATUSICONUPDATE] = WallyHandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = WallyHandleStatusAnimation, + [CONTROLLER_STATUSXOR] = WallyHandleStatusXor, + [CONTROLLER_DATATRANSFER] = WallyHandleDataTransfer, + [CONTROLLER_DMA3TRANSFER] = WallyHandleDMA3Transfer, + [CONTROLLER_PLAYBGM] = WallyHandlePlayBGM, + [CONTROLLER_32] = WallyHandleCmd32, + [CONTROLLER_TWORETURNVALUES] = WallyHandleTwoReturnValues, + [CONTROLLER_CHOSENMONRETURNVALUE] = WallyHandleChosenMonReturnValue, + [CONTROLLER_ONERETURNVALUE] = WallyHandleOneReturnValue, + [CONTROLLER_ONERETURNVALUE_DUPLICATE] = WallyHandleOneReturnValue_Duplicate, + [CONTROLLER_CLEARUNKVAR] = WallyHandleClearUnkVar, + [CONTROLLER_SETUNKVAR] = WallyHandleSetUnkVar, + [CONTROLLER_CLEARUNKFLAG] = WallyHandleClearUnkFlag, + [CONTROLLER_TOGGLEUNKFLAG] = WallyHandleToggleUnkFlag, + [CONTROLLER_HITANIMATION] = WallyHandleHitAnimation, + [CONTROLLER_42] = WallyHandleCmd42, + [CONTROLLER_PLAYSE] = WallyHandlePlaySE, + [CONTROLLER_PLAYFANFAREORBGM] = WallyHandlePlayFanfareOrBGM, + [CONTROLLER_FAINTINGCRY] = WallyHandleFaintingCry, + [CONTROLLER_INTROSLIDE] = WallyHandleIntroSlide, + [CONTROLLER_INTROTRAINERBALLTHROW] = WallyHandleIntroTrainerBallThrow, + [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = WallyHandleDrawPartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = WallyHandleHidePartyStatusSummary, + [CONTROLLER_ENDBOUNCE] = WallyHandleEndBounceEffect, + [CONTROLLER_SPRITEINVISIBILITY] = WallyHandleSpriteInvisibility, + [CONTROLLER_BATTLEANIMATION] = WallyHandleBattleAnimation, + [CONTROLLER_LINKSTANDBYMSG] = WallyHandleLinkStandbyMsg, + [CONTROLLER_RESETACTIONMOVESELECTION] = WallyHandleResetActionMoveSelection, + [CONTROLLER_55] = WallyHandleCmd55, + [CONTROLLER_TERMINATOR_NOP] = WallyCmdEnd }; static void SpriteCB_Null7(void) @@ -1345,22 +1345,22 @@ static void WallyHandleOneReturnValue_Duplicate(void) WallyBufferExecCompleted(); } -static void WallyHandleCmd37(void) +static void WallyHandleClearUnkVar(void) { WallyBufferExecCompleted(); } -static void WallyHandleCmd38(void) +static void WallyHandleSetUnkVar(void) { WallyBufferExecCompleted(); } -static void WallyHandleCmd39(void) +static void WallyHandleClearUnkFlag(void) { WallyBufferExecCompleted(); } -static void WallyHandleCmd40(void) +static void WallyHandleToggleUnkFlag(void) { WallyBufferExecCompleted(); } diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 3ebc5d3bd..20e638777 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -17,7 +17,7 @@ static EWRAM_DATA u8 sLinkSendTaskId = 0; static EWRAM_DATA u8 sLinkReceiveTaskId = 0; static EWRAM_DATA u8 sUnknown_02022D0A = 0; -EWRAM_DATA struct UnusedControllerStruct gUnknown_02022D0C = {}; +EWRAM_DATA struct UnusedControllerStruct gUnusedControllerStruct = {}; // Debug? Unused code that writes to it, never read static EWRAM_DATA u8 sBattleBuffersTransferData[0x100] = {}; // this file's funcionts @@ -64,7 +64,7 @@ void SetUpBattleVarsAndBirchZigzagoon(void) if (gBattleTypeFlags & BATTLE_TYPE_FIRST_BATTLE) { ZeroEnemyPartyMons(); - CreateMon(&gEnemyParty[0], SPECIES_ZIGZAGOON, 2, 32, 0, 0, OT_ID_PLAYER_ID, 0); + CreateMon(&gEnemyParty[0], SPECIES_ZIGZAGOON, 2, USE_RANDOM_IVS, 0, 0, OT_ID_PLAYER_ID, 0); i = 0; SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, &i); } @@ -174,9 +174,9 @@ static void InitSinglePlayerBtlControllers(void) if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { - if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) { - if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER) { gBattleMainFunc = BeginBattleIntro; @@ -259,9 +259,9 @@ static void InitSinglePlayerBtlControllers(void) } else if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - u8 var; // multiplayer Id in a recorded battle? + u8 multiplayerId; - for (var = gUnknown_0203C7B4, i = 0; i < MAX_BATTLERS_COUNT; i++) + for (multiplayerId = gRecordedBattleMultiplayerId, i = 0; i < MAX_BATTLERS_COUNT; i++) { switch (gLinkPlayers[i].id) { @@ -275,7 +275,7 @@ static void InitSinglePlayerBtlControllers(void) break; } - if (i == var) + if (i == multiplayerId) { gBattlerControllerFuncs[gLinkPlayers[i].id] = SetControllerToRecordedPlayer; switch (gLinkPlayers[i].id) @@ -292,8 +292,8 @@ static void InitSinglePlayerBtlControllers(void) break; } } - else if ((!(gLinkPlayers[i].id & 1) && !(gLinkPlayers[var].id & 1)) - || ((gLinkPlayers[i].id & 1) && (gLinkPlayers[var].id & 1))) + else if ((!(gLinkPlayers[i].id & 1) && !(gLinkPlayers[multiplayerId].id & 1)) + || ((gLinkPlayers[i].id & 1) && (gLinkPlayers[multiplayerId].id & 1))) { gBattlerControllerFuncs[gLinkPlayers[i].id] = SetControllerToRecordedPlayer; switch (gLinkPlayers[i].id) @@ -337,7 +337,7 @@ static void InitSinglePlayerBtlControllers(void) gBattlerControllerFuncs[2] = SetControllerToRecordedPlayer; gBattlerPositions[2] = B_POSITION_PLAYER_RIGHT; - if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) { gBattlerControllerFuncs[1] = SetControllerToRecordedOpponent; gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; @@ -362,7 +362,7 @@ static void InitSinglePlayerBtlControllers(void) gBattlerControllerFuncs[3] = SetControllerToRecordedPlayer; gBattlerPositions[3] = B_POSITION_PLAYER_RIGHT; - if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) { gBattlerControllerFuncs[0] = SetControllerToRecordedOpponent; gBattlerPositions[0] = B_POSITION_OPPONENT_LEFT; @@ -825,7 +825,7 @@ void sub_8033648(void) s32 j; u8 *recvBuffer; - if (gReceivedRemoteLinkPlayers != 0 && (gBattleTypeFlags & BATTLE_TYPE_20)) + if (gReceivedRemoteLinkPlayers != 0 && (gBattleTypeFlags & BATTLE_TYPE_LINK_IN_BATTLE)) { DestroyTask_RfuIdle(); for (i = 0; i < GetLinkPlayerCount(); i++) @@ -1282,7 +1282,7 @@ void BtlController_EmitPlayBGM(u8 bufferId, u16 songId, void *unusedDumbDataPara { s32 i; - sBattleBuffersTransferData[0] = CONTROLLER_31; + sBattleBuffersTransferData[0] = CONTROLLER_PLAYBGM; sBattleBuffersTransferData[1] = songId; sBattleBuffersTransferData[2] = (songId & 0xFF00) >> 8; for (i = 0; i < songId; i++) // ???? @@ -1340,37 +1340,37 @@ void BtlController_EmitOneReturnValue_Duplicate(u8 bufferId, u16 b) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } -void BtlController_EmitCmd37(u8 bufferId) +void BtlController_EmitClearUnkVar(u8 bufferId) { - sBattleBuffersTransferData[0] = CONTROLLER_37; - sBattleBuffersTransferData[1] = CONTROLLER_37; - sBattleBuffersTransferData[2] = CONTROLLER_37; - sBattleBuffersTransferData[3] = CONTROLLER_37; + sBattleBuffersTransferData[0] = CONTROLLER_CLEARUNKVAR; + sBattleBuffersTransferData[1] = CONTROLLER_CLEARUNKVAR; + sBattleBuffersTransferData[2] = CONTROLLER_CLEARUNKVAR; + sBattleBuffersTransferData[3] = CONTROLLER_CLEARUNKVAR; PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } -void BtlController_EmitCmd38(u8 bufferId, u8 b) +void BtlController_EmitSetUnkVar(u8 bufferId, u8 b) { - sBattleBuffersTransferData[0] = CONTROLLER_38; + sBattleBuffersTransferData[0] = CONTROLLER_SETUNKVAR; sBattleBuffersTransferData[1] = b; PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 2); } -void BtlController_EmitCmd39(u8 bufferId) +void BtlController_EmitClearUnkFlag(u8 bufferId) { - sBattleBuffersTransferData[0] = CONTROLLER_39; - sBattleBuffersTransferData[1] = CONTROLLER_39; - sBattleBuffersTransferData[2] = CONTROLLER_39; - sBattleBuffersTransferData[3] = CONTROLLER_39; + sBattleBuffersTransferData[0] = CONTROLLER_CLEARUNKFLAG; + sBattleBuffersTransferData[1] = CONTROLLER_CLEARUNKFLAG; + sBattleBuffersTransferData[2] = CONTROLLER_CLEARUNKFLAG; + sBattleBuffersTransferData[3] = CONTROLLER_CLEARUNKFLAG; PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } -void BtlController_EmitCmd40(u8 bufferId) +void BtlController_EmitToggleUnkFlag(u8 bufferId) { - sBattleBuffersTransferData[0] = CONTROLLER_40; - sBattleBuffersTransferData[1] = CONTROLLER_40; - sBattleBuffersTransferData[2] = CONTROLLER_40; - sBattleBuffersTransferData[3] = CONTROLLER_40; + sBattleBuffersTransferData[0] = CONTROLLER_TOGGLEUNKFLAG; + sBattleBuffersTransferData[1] = CONTROLLER_TOGGLEUNKFLAG; + sBattleBuffersTransferData[2] = CONTROLLER_TOGGLEUNKFLAG; + sBattleBuffersTransferData[3] = CONTROLLER_TOGGLEUNKFLAG; PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } @@ -1394,7 +1394,7 @@ void BtlController_EmitCmd42(u8 bufferId) void BtlController_EmitPlaySE(u8 bufferId, u16 songId) { - sBattleBuffersTransferData[0] = CONTROLLER_EFFECTIVENESSSOUND; + sBattleBuffersTransferData[0] = CONTROLLER_PLAYSE; sBattleBuffersTransferData[1] = songId; sBattleBuffersTransferData[2] = (songId & 0xFF00) >> 8; sBattleBuffersTransferData[3] = 0; diff --git a/src/battle_dome.c b/src/battle_dome.c index de8bb2843..de8fa660e 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -2875,7 +2875,7 @@ static u8 GetDomeTrainerMonIvs(u16 trainerId) else if (trainerId <= FRONTIER_TRAINER_TESS) // 200 - 219 fixedIv = 21; else // 220+ (- 299) - fixedIv = 31; + fixedIv = MAX_PER_STAT_IVS; return fixedIv; } diff --git a/src/battle_factory.c b/src/battle_factory.c index a2b1d337a..9ba13b0d3 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -25,8 +25,8 @@ static void InitFactoryChallenge(void); static void GetBattleFactoryData(void); static void SetBattleFactoryData(void); static void SaveFactoryChallenge(void); -static void nullsub_75(void); -static void nullsub_123(void); +static void FactoryDummy1(void); +static void FactoryDummy2(void); static void SelectInitialRentalMons(void); static void SwapRentalMons(void); static void SetPerformedRentalSwap(void); @@ -41,8 +41,16 @@ static void RestorePlayerPartyHeldItems(void); static u16 GetFactoryMonId(u8 lvlMode, u8 challengeNum, bool8 arg2); static u8 GetMoveBattleStyle(u16 move); -// Const rom data. -static const u8 sRequiredMoveCounts[] = {3, 3, 3, 2, 2, 2, 2}; +// Number of moves needed on the team to be considered using a certain battle style +static const u8 sRequiredMoveCounts[FACTORY_NUM_STYLES - 1] = { + [FACTORY_STYLE_PREPARATION - 1] = 3, + [FACTORY_STYLE_SLOW_STEADY - 1] = 3, + [FACTORY_STYLE_ENDURANCE - 1] = 3, + [FACTORY_STYLE_HIGH_RISK - 1] = 2, + [FACTORY_STYLE_WEAKENING - 1] = 2, + [FACTORY_STYLE_UNPREDICTABLE - 1] = 2, + [FACTORY_STYLE_WEATHER - 1] = 2 +}; static const u16 sMoves_TotalPreparation[] = { @@ -119,8 +127,8 @@ static void (* const sBattleFactoryFunctions[])(void) = [BATTLE_FACTORY_FUNC_GET_DATA] = GetBattleFactoryData, [BATTLE_FACTORY_FUNC_SET_DATA] = SetBattleFactoryData, [BATTLE_FACTORY_FUNC_SAVE] = SaveFactoryChallenge, - [BATTLE_FACTORY_FUNC_NULL] = nullsub_75, - [BATTLE_FACTORY_FUNC_NULL2] = nullsub_123, + [BATTLE_FACTORY_FUNC_NULL] = FactoryDummy1, + [BATTLE_FACTORY_FUNC_NULL2] = FactoryDummy2, [BATTLE_FACTORY_FUNC_SELECT_RENT_MONS] = SelectInitialRentalMons, [BATTLE_FACTORY_FUNC_SWAP_RENT_MONS] = SwapRentalMons, [BATTLE_FACTORY_FUNC_SET_SWAPPED] = SetPerformedRentalSwap, @@ -266,12 +274,12 @@ static void SaveFactoryChallenge(void) SaveGameFrontier(); } -static void nullsub_75(void) +static void FactoryDummy1(void) { } -static void nullsub_123(void) +static void FactoryDummy2(void) { } @@ -376,10 +384,10 @@ static void SetRentalsToOpponentParty(void) for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { - gSaveBlock2Ptr->frontier.rentalMons[i + 3].monId = gFrontierTempParty[i]; - gSaveBlock2Ptr->frontier.rentalMons[i + 3].ivs = GetBoxMonData(&gEnemyParty[i].box, MON_DATA_ATK_IV, NULL); - gSaveBlock2Ptr->frontier.rentalMons[i + 3].personality = GetMonData(&gEnemyParty[i], MON_DATA_PERSONALITY, NULL); - gSaveBlock2Ptr->frontier.rentalMons[i + 3].abilityNum = GetBoxMonData(&gEnemyParty[i].box, MON_DATA_ABILITY_NUM, NULL); + gSaveBlock2Ptr->frontier.rentalMons[i + FRONTIER_PARTY_SIZE].monId = gFrontierTempParty[i]; + gSaveBlock2Ptr->frontier.rentalMons[i + FRONTIER_PARTY_SIZE].ivs = GetBoxMonData(&gEnemyParty[i].box, MON_DATA_ATK_IV, NULL); + gSaveBlock2Ptr->frontier.rentalMons[i + FRONTIER_PARTY_SIZE].personality = GetMonData(&gEnemyParty[i], MON_DATA_PERSONALITY, NULL); + gSaveBlock2Ptr->frontier.rentalMons[i + FRONTIER_PARTY_SIZE].abilityNum = GetBoxMonData(&gEnemyParty[i].box, MON_DATA_ABILITY_NUM, NULL); SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[gFrontierTempParty[i]].itemTableId]); } } @@ -455,13 +463,13 @@ static void SetPlayerAndOpponentParties(void) case 2: for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { - monId = gSaveBlock2Ptr->frontier.rentalMons[i + 3].monId; - ivs = gSaveBlock2Ptr->frontier.rentalMons[i + 3].ivs; + monId = gSaveBlock2Ptr->frontier.rentalMons[i + FRONTIER_PARTY_SIZE].monId; + ivs = gSaveBlock2Ptr->frontier.rentalMons[i + FRONTIER_PARTY_SIZE].ivs; CreateMon(&gEnemyParty[i], gFacilityTrainerMons[monId].species, monLevel, ivs, - TRUE, gSaveBlock2Ptr->frontier.rentalMons[i + 3].personality, + TRUE, gSaveBlock2Ptr->frontier.rentalMons[i + FRONTIER_PARTY_SIZE].personality, OT_ID_PLAYER_ID, 0); count = 0; @@ -484,7 +492,7 @@ static void SetPlayerAndOpponentParties(void) for (k = 0; k < MAX_MON_MOVES; k++) SetMonMoveAvoidReturn(&gEnemyParty[i], gFacilityTrainerMons[monId].moves[k], k); SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]); - SetMonData(&gEnemyParty[i], MON_DATA_ABILITY_NUM, &gSaveBlock2Ptr->frontier.rentalMons[i + 3].abilityNum); + SetMonData(&gEnemyParty[i], MON_DATA_ABILITY_NUM, &gSaveBlock2Ptr->frontier.rentalMons[i + FRONTIER_PARTY_SIZE].abilityNum); } break; } @@ -639,7 +647,7 @@ static void GetOpponentBattleStyle(void) } } - gSpecialVar_Result = 0; + gSpecialVar_Result = FACTORY_STYLE_NONE; for (i = 1; i < FACTORY_NUM_STYLES; i++) { if (stylePoints[i] >= sRequiredMoveCounts[i - 1]) diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index cbe4fc432..2cacba2a1 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -25,52 +25,77 @@ #include "util.h" #include "trainer_pokemon_sprites.h" #include "starter_choose.h" +#include "strings.h" +#include "graphics.h" #include "constants/battle_frontier.h" #include "constants/songs.h" #include "constants/rgb.h" -// Select_ refers to the first Pokemon selection screen where you choose 3 Pokemon. -// Swap_ refers to the consecutive selection screen where you can keep your Pokemon or swap one with beaten trainer's. +// Select_ refers to the first Pokemon selection screen where you choose your initial 3 rental Pokemon. +// Swap_ refers to the subsequent selection screens where you can swap a Pokemon with one from the beaten trainer -#define MENU_SUMMARY 0 -#define MENU_RENT 1 -#define MENU_DESELECT 1 -#define MENU_OTHERS 2 -#define MENU_OPTIONS_COUNT 3 +// Note that, generally, "Action" will refer to the immediate actions that can be taken on each screen, +// i.e. selecting a pokemon or selecting the Cancel button +// The "Options menu" will refer to the popup menu that shows when some actions have been selected + +#define SWAP_PLAYER_SCREEN 0 // The screen where the player selects which of their pokemon to swap away +#define SWAP_ENEMY_SCREEN 1 // The screen where the player selects which new pokemon from the defeated party to swap for #define SELECTABLE_MONS_COUNT 6 -#define TAG_PAL_BALL_GREY 0x64 -#define TAG_PAL_BALL_SELECTED 0x65 -#define TAG_PAL_66 0x66 -#define TAG_PAL_67 0x67 +enum { + PALTAG_BALL_GRAY = 100, + PALTAG_BALL_SELECTED, + PALTAG_INTERFACE, + PALTAG_MON_PIC_BG, +}; -#define TAG_TILE_64 0x64 -#define TAG_TILE_65 0x65 -#define TAG_TILE_66 0x66 -#define TAG_TILE_67 0x67 -#define TAG_TILE_68 0x68 -#define TAG_TILE_69 0x69 -#define TAG_TILE_6A 0x6A -#define TAG_TILE_6B 0x6B -#define TAG_TILE_6C 0x6C -#define TAG_TILE_6D 0x6D +enum { + GFXTAG_BALL = 100, + GFXTAG_ARROW, + GFXTAG_MENU_HIGHLIGHT_LEFT, + GFXTAG_MENU_HIGHLIGHT_RIGHT, + GFXTAG_ACTION_BOX_LEFT, + GFXTAG_ACTION_BOX_RIGHT, + GFXTAG_ACTION_HIGHLIGHT_LEFT, + GFXTAG_ACTION_HIGHLIGHT_MIDDLE, + GFXTAG_ACTION_HIGHLIGHT_RIGHT, + GFXTAG_MON_PIC_BG_ANIM, +}; -struct FactorySelecteableMon +// Tasks in this file universally use data[0] as a state for switches +#define tState data[0] + +// States for both Select/Swap versions of Task_FadeSpeciesName +enum { + FADESTATE_INIT, + FADESTATE_RUN, + FADESTATE_DELAY +}; + +// Return states for the Select Actions +enum { + SELECT_SUMMARY, + SELECT_CONTINUE_CHOOSING, + SELECT_CONFIRM_MONS, + SELECT_INVALID_MON, +}; + +struct FactorySelectableMon { u16 monId; - u16 spriteId; + u16 ballSpriteId; u8 selectedId; // 0 - not selected, 1 - first pokemon, 2 - second pokemon, 3 - third pokemon struct Pokemon monData; }; -struct UnkFactoryStruct +struct FactoryMonPic { - u8 field0; - u8 field1; + u8 monSpriteId; + u8 bgSpriteId; }; -struct FactorySelectMonsStruct +struct FactorySelectScreen { u8 menuCursorPos; u8 menuCursor1SpriteId; @@ -80,206 +105,201 @@ struct FactorySelectMonsStruct u8 selectingMonsState; bool8 fromSummaryScreen; u8 yesNoCursorPos; - u8 unused8; - struct FactorySelecteableMon mons[SELECTABLE_MONS_COUNT]; - struct UnkFactoryStruct unk294[3]; - bool8 unk2A0; + u8 unused; + struct FactorySelectableMon mons[SELECTABLE_MONS_COUNT]; + struct FactoryMonPic monPics[FRONTIER_PARTY_SIZE]; // Array so all chosen mons can be shown at once + bool8 monPicAnimating; u8 fadeSpeciesNameTaskId; - bool8 unk2A2; - u16 unk2A4; - bool8 unk2A6; - u8 unk2A7; - u8 unk2A8; - u8 unk2A9; + bool8 fadeSpeciesNameActive; + u16 speciesNameColorBackup; + bool8 fadeSpeciesNameFadeOut; + u8 fadeSpeciesNameCoeffDelay; + u8 fadeSpeciesNameCoeff; + u8 faceSpeciesNameDelay; }; -// 'Action' refers to the 3 Selectable mons, Cancel, Pknm for swap windows. -#define ACTIONS_PLAYER_SCREEN 0 -#define ACTIONS_ENEMY_SCREEN 1 - -struct SwapActionIdAndFunc +struct SwapScreenAction { u8 id; void (*func)(u8 taskId); }; -struct FactorySwapMonsStruct +struct FactorySwapScreen { u8 menuCursorPos; u8 menuCursor1SpriteId; u8 menuCursor2SpriteId; u8 cursorPos; u8 cursorSpriteId; - u8 ballSpriteIds[3]; - u8 unk8[2][3]; - u8 unkE[2][2]; + u8 ballSpriteIds[FRONTIER_PARTY_SIZE]; + u8 pkmnForSwapButtonSpriteIds[2][3]; // For this and sprite ID array below, [0][i] is the button background, [1][i] is the button highlight + u8 cancelButtonSpriteIds[2][2]; u8 playerMonId; u8 enemyMonId; bool8 inEnemyScreen; bool8 fromSummaryScreen; u8 yesNoCursorPos; u8 actionsCount; - const struct SwapActionIdAndFunc *actionsData; - u8 unused1C[4]; + const struct SwapScreenAction *actionsData; + u8 unused[4]; bool8 monSwapped; u8 fadeSpeciesNameTaskId; - bool8 unk22; - u16 unk24; - bool8 unk26; - u8 unk27; - u8 unk28; - u8 unk29; - struct UnkFactoryStruct unk2C; - bool8 unk30; + bool8 fadeSpeciesNameActive; + u16 speciesNameColorBackup; + bool8 fadeSpeciesNameFadeOut; + u8 fadeSpeciesNameCoeffDelay; + u8 fadeSpeciesNameCoeff; + u8 faceSpeciesNameDelay; + struct FactoryMonPic monPic; + bool8 monPicAnimating; }; -// This file's functions. -static void sub_819A44C(struct Sprite *sprite); +static void SpriteCB_Pokeball(struct Sprite *); +static void SpriteCB_OpenMonPic(struct Sprite *); +static void OpenMonPic(u8 *, bool8 *, bool8); +static void HideMonPic(struct FactoryMonPic, bool8 *); +static void CloseMonPic(struct FactoryMonPic, bool8 *, bool8); +static void Task_OpenMonPic(u8); +static void Task_CloseMonPic(u8); + +// Select screen static void CB2_InitSelectScreen(void); -static void Select_SetWinRegs(s16 mWin0H, s16 nWin0H, s16 mWin0V, s16 nWin0V); +static void Select_SetWinRegs(s16, s16, s16, s16); static void Select_InitMonsData(void); static void Select_InitAllSprites(void); -static void Select_ShowSummaryMonSprite(void); +static void Select_ReshowMonSprite(void); static void Select_PrintSelectMonString(void); static void Select_PrintMonSpecies(void); static void Select_PrintMonCategory(void); static void Select_PrintRentalPkmnString(void); static void Select_CopyMonsToPlayerParty(void); -static void sub_819C4B4(void); +static void Select_ShowChosenMons(void); static void Select_ShowYesNoOptions(void); -static void sub_819C568(void); +static void Select_HideChosenMons(void); static void Select_ShowMenuOptions(void); static void Select_PrintMenuOptions(void); static void Select_PrintYesNoOptions(void); -static void Task_SelectFadeSpeciesName(u8 taskId); -static void sub_819C1D0(u8 taskId); -static void Task_HandleSelectionScreenChooseMons(u8 taskId); -static void Task_HandleSelectionScreenMenu(u8 taskId); -static void CreateFrontierFactorySelectableMons(u8 firstMonId); -static void CreateTentFactorySelectableMons(u8 firstMonId); -static void Select_SetBallSpritePaletteNum(u8 id); -static void sub_819F444(struct UnkFactoryStruct arg0, bool8 *arg1); -static void sub_819B958(u8 windowId); -static void sub_819F2B4(u8 *arg0, bool8 *arg1, bool8 swapScreen); -static void sub_819F3F8(struct UnkFactoryStruct arg0, bool8 *arg1, bool8 swapScreen); +static void Select_Task_FadeSpeciesName(u8); +static void Select_Task_OpenChosenMonPics(u8); +static void Select_Task_HandleChooseMons(u8); +static void Select_Task_HandleMenu(u8); +static void CreateFrontierFactorySelectableMons(u8); +static void CreateSlateportTentSelectableMons(u8); +static void Select_SetBallSpritePaletteNum(u8); +static void Select_ErasePopupMenu(u8); static u8 Select_RunMenuOptionFunc(void); -static u8 sub_819BC9C(void); +static u8 Select_DeclineChosenMons(void); static u8 Select_OptionSummary(void); static u8 Select_OptionOthers(void); static u8 Select_OptionRentDeselect(void); -static bool32 Select_AreSpeciesValid(u16 monId); +static bool32 Select_AreSpeciesValid(u16); + +// Swap screen +static void CB2_InitSwapScreen(void); static void Swap_DestroyAllSprites(void); static void Swap_ShowYesNoOptions(void); -static void sub_819E8EC(void); -static void sub_819EAC0(void); -static void Swap_UpdateYesNoCursorPosition(s8 direction); -static void Swap_UpdateMenuCursorPosition(s8 direction); -static void sub_819EA64(u8 windowId); -static void sub_819D770(u8 taskId); -static void Task_HandleSwapScreenChooseMons(u8 taskId); -static void sub_819D588(u8 taskId); -static void sub_819F7B4(u8 taskId); -static void Swap_PrintOnInfoWindow(const u8 *str); +static void Swap_HideActionButtonHighlights(void); +static void Swap_EraseSpeciesWindow(void); +static void Swap_UpdateYesNoCursorPosition(s8); +static void Swap_UpdateMenuCursorPosition(s8); +static void Swap_ErasePopupMenu(u8); +static void Swap_Task_ScreenInfoTransitionIn(u8); +static void Swap_Task_HandleChooseMons(u8); +static void Swap_Task_ScreenInfoTransitionOut(u8); +static void Swap_PrintOnInfoWindow(const u8 *); static void Swap_ShowMenuOptions(void); static void Swap_PrintMenuOptions(void); static void Swap_PrintYesNoOptions(void); static void Swap_PrintMonSpecies(void); -static void Swap_PrintMonSpecies2(void); -static void Swap_PrintMonSpecies3(void); +static void Swap_PrintMonSpeciesAtFade(void); +static void Swap_PrintMonSpeciesForTransition(void); static void Swap_PrintMonCategory(void); static void Swap_InitAllSprites(void); static void Swap_PrintPkmnSwap(void); -static void sub_819EADC(void); -static void sub_819EAF8(void); -static void CB2_InitSwapScreen(void); +static void Swap_EraseSpeciesAtFadeWindow(void); +static void Swap_EraseActionFadeWindow(void); static void Swap_ShowSummaryMonSprite(void); -static void Swap_UpdateActionCursorPosition(s8 direction); -static void Swap_UpdateBallCursorPosition(s8 direction); -static void Swap_RunMenuOptionFunc(u8 taskId); -static void sub_819F0CC(u8 taskId); -static void sub_819F114(u8 taskId); -static void sub_819F134(u8 taskId); -static void Swap_RunActionFunc(u8 taskId); -static void sub_819F69C(u8 taskId); -static void Task_SwapCantHaveSameMons(u8 taskId); -static void Swap_ShowMonSprite(void); +static void Swap_UpdateActionCursorPosition(s8); +static void Swap_UpdateBallCursorPosition(s8); +static void Swap_RunMenuOptionFunc(u8); +static void Swap_OptionSwap(u8); +static void Swap_OptionSummary(u8); +static void Swap_OptionRechoose(u8); +static void Swap_RunActionFunc(u8); +static void Swap_TaskCantHaveSameMons(u8); +static void Swap_CreateMonSprite(void); static void Swap_PrintActionStrings(void); static void Swap_PrintActionStrings2(void); -static void Swap_PrintOneActionString(u8 which); -static void Swap_InitActions(u8 id); -static void sub_819E838(u8 arg0); -static bool8 Swap_AlreadyHasSameSpecies(u8 monId); -static void sub_819F600(struct Sprite *sprite); -static void Swap_ActionMon(u8 taskId); -static void Swap_ActionCancel(u8 taskId); -static void Swap_ActionPkmnForSwap(u8 taskId); +static void Swap_PrintOneActionString(u8); +static void Swap_InitActions(u8); +static void Swap_HighlightActionButton(u8); +static bool8 Swap_AlreadyHasSameSpecies(u8); +static void Swap_ActionMon(u8); +static void Swap_ActionCancel(u8); +static void Swap_ActionPkmnForSwap(u8); -// Ewram variables static EWRAM_DATA u8 *sSelectMenuTilesetBuffer = NULL; -static EWRAM_DATA u8 *sSelectMonCardBgTilesetBuffer = NULL; +static EWRAM_DATA u8 *sSelectMonPicBgTilesetBuffer = NULL; static EWRAM_DATA u8 *sSelectMenuTilemapBuffer = NULL; -static EWRAM_DATA u8 *sSelectMonCardBgTilemapBuffer = NULL; +static EWRAM_DATA u8 *sSelectMonPicBgTilemapBuffer = NULL; static EWRAM_DATA struct Pokemon *sFactorySelectMons = NULL; static EWRAM_DATA u8 *sSwapMenuTilesetBuffer = NULL; -static EWRAM_DATA u8 *sSwapMonCardBgTilesetBuffer = NULL; +static EWRAM_DATA u8 *sSwapMonPicBgTilesetBuffer = NULL; static EWRAM_DATA u8 *sSwapMenuTilemapBuffer = NULL; -static EWRAM_DATA u8 *sSwapMonCardBgTilemapBuffer = NULL; +static EWRAM_DATA u8 *sSwapMonPicBgTilemapBuffer = NULL; -// IWRAM bss -static struct FactorySelectMonsStruct *sFactorySelectScreen; -static void (*sSwap_CurrentTableFunc)(u8 taskId); -static struct FactorySwapMonsStruct *sFactorySwapScreen; +static struct FactorySelectScreen *sFactorySelectScreen; +static void (*sSwap_CurrentOptionFunc)(u8 taskId); +static struct FactorySwapScreen *sFactorySwapScreen; -// IWRAM common -u8 (*gUnknown_030062E8)(void); +u8 (*gFactorySelect_CurrentOptionFunc)(void); -// Const rom data. -static const u16 gUnknown_0860F13C[] = INCBIN_U16("graphics/unknown/unknown_60F13C.gbapal"); -static const u16 gUnknown_0860F15C[] = INCBIN_U16("graphics/unknown/unknown_60F15C.gbapal"); -static const u16 gUnknown_0860F17C[] = INCBIN_U16("graphics/unknown/unknown_60F17C.gbapal"); -static const u8 gUnknown_0860F1BC[] = INCBIN_U8("graphics/unknown/unknown_60F1BC.4bpp"); -static const u8 gUnknown_0860F3BC[] = INCBIN_U8("graphics/unknown/unknown_60F3BC.4bpp"); -static const u8 gUnknown_0860F43C[] = INCBIN_U8("graphics/unknown/unknown_60F43C.4bpp"); -static const u8 gUnknown_0860F53C[] = INCBIN_U8("graphics/unknown/unknown_60F53C.4bpp"); -static const u8 gUnknown_0860F63C[] = INCBIN_U8("graphics/unknown/unknown_60F63C.4bpp"); -static const u8 gUnknown_0860F6BC[] = INCBIN_U8("graphics/unknown/unknown_60F6BC.4bpp"); -static const u8 gUnknown_0860F7BC[] = INCBIN_U8("graphics/unknown/unknown_60F7BC.4bpp"); -static const u8 gUnknown_0860F83C[] = INCBIN_U8("graphics/unknown/unknown_60F83C.4bpp"); -static const u8 gUnknown_0860F93C[] = INCBIN_U8("graphics/unknown/unknown_60F93C.4bpp"); -static const u8 gUnknown_0860FA3C[] = INCBIN_U8("graphics/unknown/unknown_60FA3C.4bpp"); -static const u8 gUnknown_0861023C[] = INCBIN_U8("graphics/unknown/unknown_61023C.bin"); -static const u8 gUnknown_0861033C[] = INCBIN_U8("graphics/unknown/unknown_61033C.4bpp"); -static const u16 gUnknown_0861039C[] = INCBIN_U16("graphics/unknown/unknown_61039C.gbapal"); +static const u16 sPokeballGray_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/pokeball_gray.gbapal"); +static const u16 sPokeballSelected_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/pokeball_selected.gbapal"); +static const u16 sInterface_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/interface.gbapal"); // Arrow, menu/action highlights, action box, etc +static const u8 sPokeball_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/pokeball.4bpp"); // Unused, gPokeballSelection_Gfx used instead +static const u8 sArrow_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/arrow.4bpp"); +static const u8 sMenuHighlightLeft_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/menu_highlight_left.4bpp"); +static const u8 sMenuHighlightRight_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/menu_highlight_right.4bpp"); +static const u8 sActionBoxLeft_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_box_left.4bpp"); +static const u8 sActionBoxRight_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_box_right.4bpp"); +static const u8 sActionHighlightLeft_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_highlight_left.4bpp"); +static const u8 sActionHighlightMiddle_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_highlight_middle.4bpp"); +static const u8 sActionHighlightRight_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_highlight_right.4bpp"); +static const u8 sMonPicBgAnim_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg_anim.4bpp"); +static const u8 sMonPicBg_Tilemap[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg.bin"); +static const u8 sMonPicBg_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg.4bpp"); +static const u16 sMonPicBg_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/mon_pic_bg.gbapal"); -static const struct SpriteSheet gUnknown_086103BC[] = +static const struct SpriteSheet sSelect_SpriteSheets[] = { - {gUnknown_0860F3BC, sizeof(gUnknown_0860F3BC), TAG_TILE_65}, - {gUnknown_0860F43C, sizeof(gUnknown_0860F43C), TAG_TILE_66}, - {gUnknown_0860F53C, sizeof(gUnknown_0860F53C), TAG_TILE_67}, - {gUnknown_0860FA3C, sizeof(gUnknown_0860FA3C), TAG_TILE_6D}, + {sArrow_Gfx, sizeof(sArrow_Gfx), GFXTAG_ARROW}, + {sMenuHighlightLeft_Gfx, sizeof(sMenuHighlightLeft_Gfx), GFXTAG_MENU_HIGHLIGHT_LEFT}, + {sMenuHighlightRight_Gfx, sizeof(sMenuHighlightRight_Gfx), GFXTAG_MENU_HIGHLIGHT_RIGHT}, + {sMonPicBgAnim_Gfx, sizeof(sMonPicBgAnim_Gfx), GFXTAG_MON_PIC_BG_ANIM}, {}, }; -static const struct CompressedSpriteSheet gUnknown_086103E4[] = +static const struct CompressedSpriteSheet sSelect_BallGfx[] = { - {gPokeballSelection_Gfx, 0x800, TAG_TILE_64}, + {gPokeballSelection_Gfx, 0x800, GFXTAG_BALL}, {}, }; -static const struct SpritePalette gUnknown_086103F4[] = +static const struct SpritePalette sSelect_SpritePalettes[] = { - {gUnknown_0860F13C, TAG_PAL_BALL_GREY}, - {gUnknown_0860F15C, TAG_PAL_BALL_SELECTED}, - {gUnknown_0860F17C, TAG_PAL_66}, - {gUnknown_0861039C, TAG_PAL_67}, + {sPokeballGray_Pal, PALTAG_BALL_GRAY}, + {sPokeballSelected_Pal, PALTAG_BALL_SELECTED}, + {sInterface_Pal, PALTAG_INTERFACE}, + {sMonPicBg_Pal, PALTAG_MON_PIC_BG}, {}, }; u8 static (* const sSelect_MenuOptionFuncs[])(void) = { - [MENU_SUMMARY] = Select_OptionSummary, - [MENU_RENT] /*Or Deselect*/ = Select_OptionRentDeselect, - [MENU_OTHERS] = Select_OptionOthers + Select_OptionSummary, + Select_OptionRentDeselect, + Select_OptionOthers }; static const struct BgTemplate sSelect_BgTemplates[] = @@ -313,9 +333,18 @@ static const struct BgTemplate sSelect_BgTemplates[] = }, }; +enum { + SELECT_WIN_TITLE, + SELECT_WIN_SPECIES, + SELECT_WIN_INFO, + SELECT_WIN_OPTIONS, + SELECT_WIN_YES_NO, + SELECT_WIN_MON_CATEGORY, +}; + static const struct WindowTemplate sSelect_WindowTemplates[] = { - { + [SELECT_WIN_TITLE] = { .bg = 0, .tilemapLeft = 0, .tilemapTop = 2, @@ -324,7 +353,7 @@ static const struct WindowTemplate sSelect_WindowTemplates[] = .paletteNum = 15, .baseBlock = 0x0001, }, - { + [SELECT_WIN_SPECIES] = { .bg = 0, .tilemapLeft = 19, .tilemapTop = 2, @@ -333,7 +362,7 @@ static const struct WindowTemplate sSelect_WindowTemplates[] = .paletteNum = 14, .baseBlock = 0x0019, }, - { + [SELECT_WIN_INFO] = { .bg = 0, .tilemapLeft = 0, .tilemapTop = 15, @@ -342,7 +371,7 @@ static const struct WindowTemplate sSelect_WindowTemplates[] = .paletteNum = 15, .baseBlock = 0x002f, }, - { + [SELECT_WIN_OPTIONS] = { .bg = 0, .tilemapLeft = 22, .tilemapTop = 14, @@ -351,7 +380,7 @@ static const struct WindowTemplate sSelect_WindowTemplates[] = .paletteNum = 15, .baseBlock = 0x006b, }, - { + [SELECT_WIN_YES_NO] = { .bg = 0, .tilemapLeft = 22, .tilemapTop = 14, @@ -360,7 +389,7 @@ static const struct WindowTemplate sSelect_WindowTemplates[] = .paletteNum = 15, .baseBlock = 0x009b, }, - { + [SELECT_WIN_MON_CATEGORY] = { .bg = 0, .tilemapLeft = 15, .tilemapTop = 0, @@ -372,12 +401,11 @@ static const struct WindowTemplate sSelect_WindowTemplates[] = DUMMY_WIN_TEMPLATE, }; -static const u16 gUnknown_0861046C[] = INCBIN_U16("graphics/unknown/unknown_61046C.gbapal"); - +static const u16 sSelectText_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/text.gbapal"); static const u8 sMenuOptionTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GREY, TEXT_COLOR_TRANSPARENT}; static const u8 sSpeciesNameTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_RED, TEXT_COLOR_TRANSPARENT}; -static const struct OamData gUnknown_0861047C = +static const struct OamData sOam_Select_Pokeball = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -394,7 +422,7 @@ static const struct OamData gUnknown_0861047C = .affineParam = 0, }; -static const struct OamData gUnknown_08610484 = +static const struct OamData sOam_Select_Arrow = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -411,7 +439,7 @@ static const struct OamData gUnknown_08610484 = .affineParam = 0, }; -static const struct OamData gUnknown_0861048C = +static const struct OamData sOam_Select_MenuHighlight = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -428,7 +456,7 @@ static const struct OamData gUnknown_0861048C = .affineParam = 0, }; -static const struct OamData gUnknown_08610494 = +static const struct OamData sOam_Select_MonPicBgAnim = { .y = 0, .affineMode = ST_OAM_AFFINE_DOUBLE, @@ -445,25 +473,25 @@ static const struct OamData gUnknown_08610494 = .affineParam = 1, }; -static const union AnimCmd gUnknown_0861049C[] = +static const union AnimCmd sAnim_Select_Interface[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_086104A4[] = +static const union AnimCmd sAnim_Select_MonPicBgAnim[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_086104AC[] = +static const union AnimCmd sAnim_Select_Pokeball_Still[] = { ANIMCMD_FRAME(0, 30), ANIMCMD_END, }; -static const union AnimCmd gUnknown_086104B4[] = +static const union AnimCmd sAnim_Select_Pokeball_Moving[] = { ANIMCMD_FRAME(16, 4), ANIMCMD_FRAME(0, 4), @@ -485,20 +513,20 @@ static const union AnimCmd gUnknown_086104B4[] = ANIMCMD_END, }; -static const union AnimCmd * const gUnknown_086104FC[] = +static const union AnimCmd * const sAnims_Select_Interface[] = { - gUnknown_0861049C, + sAnim_Select_Interface, }; -static const union AnimCmd * const gUnknown_08610500[] = +static const union AnimCmd * const sAnims_Select_MonPicBgAnim[] = { - gUnknown_086104A4, + sAnim_Select_MonPicBgAnim, }; -static const union AnimCmd * const gUnknown_08610504[] = +static const union AnimCmd * const sAnims_Select_Pokeball[] = { - gUnknown_086104AC, - gUnknown_086104B4, + sAnim_Select_Pokeball_Still, + sAnim_Select_Pokeball_Moving, }; static const union AffineAnimCmd gUnknown_0861050C[] = @@ -537,98 +565,98 @@ static const union AffineAnimCmd gUnknown_086105BC[] = AFFINEANIMCMD_END, }; -static const union AffineAnimCmd * const gUnknown_086105CC[] = +static const union AffineAnimCmd * const sAffineAnims_Select_MonPicBgAnim[] = { gUnknown_0861050C, gUnknown_0861056C, gUnknown_086105BC, }; -static const struct SpriteTemplate gUnknown_086105D8 = +static const struct SpriteTemplate sSpriteTemplate_Select_Pokeball = { - .tileTag = TAG_TILE_64, - .paletteTag = TAG_PAL_BALL_GREY, - .oam = &gUnknown_0861047C, - .anims = gUnknown_08610504, + .tileTag = GFXTAG_BALL, + .paletteTag = PALTAG_BALL_GRAY, + .oam = &sOam_Select_Pokeball, + .anims = sAnims_Select_Pokeball, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_819A44C + .callback = SpriteCB_Pokeball }; -static const struct SpriteTemplate gUnknown_086105F0 = +static const struct SpriteTemplate sSpriteTemplate_Select_Arrow = { - .tileTag = TAG_TILE_65, - .paletteTag = TAG_PAL_66, - .oam = &gUnknown_08610484, - .anims = gUnknown_086104FC, + .tileTag = GFXTAG_ARROW, + .paletteTag = PALTAG_INTERFACE, + .oam = &sOam_Select_Arrow, + .anims = sAnims_Select_Interface, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate gUnknown_08610608 = +static const struct SpriteTemplate sSpriteTemplate_Select_MenuHighlightLeft = { - .tileTag = TAG_TILE_66, - .paletteTag = TAG_PAL_66, - .oam = &gUnknown_0861048C, - .anims = gUnknown_086104FC, + .tileTag = GFXTAG_MENU_HIGHLIGHT_LEFT, + .paletteTag = PALTAG_INTERFACE, + .oam = &sOam_Select_MenuHighlight, + .anims = sAnims_Select_Interface, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate gUnknown_08610620 = +static const struct SpriteTemplate sSpriteTemplate_Select_MenuHighlightRight = { - .tileTag = TAG_TILE_67, - .paletteTag = TAG_PAL_66, - .oam = &gUnknown_0861048C, - .anims = gUnknown_086104FC, + .tileTag = GFXTAG_MENU_HIGHLIGHT_RIGHT, + .paletteTag = PALTAG_INTERFACE, + .oam = &sOam_Select_MenuHighlight, + .anims = sAnims_Select_Interface, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate gUnknown_08610638 = +static const struct SpriteTemplate sSpriteTemplate_Select_MonPicBgAnim = { - .tileTag = TAG_TILE_6D, - .paletteTag = TAG_PAL_67, - .oam = &gUnknown_08610494, - .anims = gUnknown_08610500, + .tileTag = GFXTAG_MON_PIC_BG_ANIM, + .paletteTag = PALTAG_MON_PIC_BG, + .oam = &sOam_Select_MonPicBgAnim, + .anims = sAnims_Select_MonPicBgAnim, .images = NULL, - .affineAnims = gUnknown_086105CC, + .affineAnims = sAffineAnims_Select_MonPicBgAnim, .callback = SpriteCallbackDummy }; -static const struct SpriteSheet gUnknown_08610650[] = +static const struct SpriteSheet sSwap_SpriteSheets[] = { - {gUnknown_0860F3BC, sizeof(gUnknown_0860F3BC), TAG_TILE_65}, - {gUnknown_0860F43C, sizeof(gUnknown_0860F43C), TAG_TILE_66}, - {gUnknown_0860F53C, sizeof(gUnknown_0860F53C), TAG_TILE_67}, - {gUnknown_0860F63C, sizeof(gUnknown_0860F63C), TAG_TILE_68}, - {gUnknown_0860F6BC, sizeof(gUnknown_0860F6BC), TAG_TILE_69}, - {gUnknown_0860F7BC, 0x100, TAG_TILE_6A}, - {gUnknown_0860F83C, sizeof(gUnknown_0860F83C), TAG_TILE_6B}, - {gUnknown_0860F93C, sizeof(gUnknown_0860F93C), TAG_TILE_6C}, - {gUnknown_0860FA3C, sizeof(gUnknown_0860FA3C), TAG_TILE_6D}, + {sArrow_Gfx, sizeof(sArrow_Gfx), GFXTAG_ARROW}, + {sMenuHighlightLeft_Gfx, sizeof(sMenuHighlightLeft_Gfx), GFXTAG_MENU_HIGHLIGHT_LEFT}, + {sMenuHighlightRight_Gfx, sizeof(sMenuHighlightRight_Gfx), GFXTAG_MENU_HIGHLIGHT_RIGHT}, + {sActionBoxLeft_Gfx, sizeof(sActionBoxLeft_Gfx), GFXTAG_ACTION_BOX_LEFT}, + {sActionBoxRight_Gfx, sizeof(sActionBoxRight_Gfx), GFXTAG_ACTION_BOX_RIGHT}, + {sActionHighlightLeft_Gfx, 0x100, GFXTAG_ACTION_HIGHLIGHT_LEFT}, + {sActionHighlightMiddle_Gfx, sizeof(sActionHighlightMiddle_Gfx), GFXTAG_ACTION_HIGHLIGHT_MIDDLE}, + {sActionHighlightRight_Gfx, sizeof(sActionHighlightRight_Gfx), GFXTAG_ACTION_HIGHLIGHT_RIGHT}, + {sMonPicBgAnim_Gfx, sizeof(sMonPicBgAnim_Gfx), GFXTAG_MON_PIC_BG_ANIM}, {}, }; -static const struct CompressedSpriteSheet gUnknown_086106A0[] = +static const struct CompressedSpriteSheet sSwap_BallGfx[] = { - {gPokeballSelection_Gfx, 0x800, TAG_TILE_64}, + {gPokeballSelection_Gfx, 0x800, GFXTAG_BALL}, {}, }; -static const struct SpritePalette gUnknown_086106B0[] = +static const struct SpritePalette sSwap_SpritePalettes[] = { - {gUnknown_0860F13C, TAG_PAL_BALL_GREY}, - {gUnknown_0860F15C, TAG_PAL_BALL_SELECTED}, - {gUnknown_0860F17C, TAG_PAL_66}, - {gUnknown_0861039C, TAG_PAL_67}, + {sPokeballGray_Pal, PALTAG_BALL_GRAY}, + {sPokeballSelected_Pal, PALTAG_BALL_SELECTED}, + {sInterface_Pal, PALTAG_INTERFACE}, + {sMonPicBg_Pal, PALTAG_MON_PIC_BG}, {}, }; -static const struct OamData gUnknown_086106D8 = +static const struct OamData sOam_Swap_Pokeball = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -645,7 +673,7 @@ static const struct OamData gUnknown_086106D8 = .affineParam = 0, }; -static const struct OamData gUnknown_086106E0 = +static const struct OamData sOam_Swap_Arrow = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -662,7 +690,7 @@ static const struct OamData gUnknown_086106E0 = .affineParam = 0, }; -static const struct OamData gUnknown_086106E8 = +static const struct OamData sOam_Swap_MenuHighlight = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -679,7 +707,7 @@ static const struct OamData gUnknown_086106E8 = .affineParam = 0, }; -static const struct OamData gUnknown_086106F0 = +static const struct OamData sOam_Swap_MonPicBgAnim = { .y = 0, .affineMode = ST_OAM_AFFINE_DOUBLE, @@ -696,25 +724,25 @@ static const struct OamData gUnknown_086106F0 = .affineParam = 1, }; -static const union AnimCmd gUnknown_086106F8[] = +static const union AnimCmd sAnim_Swap_Interface[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_08610700[] = +static const union AnimCmd sAnim_Swap_MonPicBgAnim[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_08610708[] = +static const union AnimCmd sAnim_Swap_Pokeball_Still[] = { ANIMCMD_FRAME(0, 30), ANIMCMD_END, }; -static const union AnimCmd gUnknown_08610710[] = +static const union AnimCmd sAnim_Swap_Pokeball_Moving[] = { ANIMCMD_FRAME(16, 4), ANIMCMD_FRAME(0, 4), @@ -736,20 +764,20 @@ static const union AnimCmd gUnknown_08610710[] = ANIMCMD_END, }; -static const union AnimCmd * const gUnknown_08610758[] = +static const union AnimCmd * const sAnims_Swap_Interface[] = { - gUnknown_086106F8, + sAnim_Swap_Interface, }; -static const union AnimCmd * const gUnknown_0861075C[] = +static const union AnimCmd * const sAnims_Swap_MonPicBgAnim[] = { - gUnknown_08610700, + sAnim_Swap_MonPicBgAnim, }; -static const union AnimCmd * const gUnknown_08610760[] = +static const union AnimCmd * const sAnims_Swap_Pokeball[] = { - gUnknown_08610708, - gUnknown_08610710, + sAnim_Swap_Pokeball_Still, + sAnim_Swap_Pokeball_Moving, }; static const union AffineAnimCmd gUnknown_08610768[] = @@ -788,73 +816,73 @@ static const union AffineAnimCmd gUnknown_08610818[] = AFFINEANIMCMD_END, }; -static const union AffineAnimCmd * const gUnknown_08610828[] = +static const union AffineAnimCmd * const sAffineAnims_Swap_MonPicBgAnim[] = { gUnknown_08610768, gUnknown_086107C8, gUnknown_08610818, }; -static const struct SpriteTemplate gUnknown_08610834 = +static const struct SpriteTemplate sSpriteTemplate_Swap_Pokeball = { - .tileTag = TAG_TILE_64, - .paletteTag = TAG_PAL_BALL_GREY, - .oam = &gUnknown_086106D8, - .anims = gUnknown_08610760, + .tileTag = GFXTAG_BALL, + .paletteTag = PALTAG_BALL_GRAY, + .oam = &sOam_Swap_Pokeball, + .anims = sAnims_Swap_Pokeball, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_819A44C + .callback = SpriteCB_Pokeball }; -static const struct SpriteTemplate gUnknown_0861084C = +static const struct SpriteTemplate sSpriteTemplate_Swap_Arrow = { - .tileTag = TAG_TILE_65, - .paletteTag = TAG_PAL_66, - .oam = &gUnknown_086106E0, - .anims = gUnknown_08610758, + .tileTag = GFXTAG_ARROW, + .paletteTag = PALTAG_INTERFACE, + .oam = &sOam_Swap_Arrow, + .anims = sAnims_Swap_Interface, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate gUnknown_08610864 = +static const struct SpriteTemplate sSpriteTemplate_Swap_MenuHighlightLeft = { - .tileTag = TAG_TILE_66, - .paletteTag = TAG_PAL_66, - .oam = &gUnknown_086106E8, - .anims = gUnknown_08610758, + .tileTag = GFXTAG_MENU_HIGHLIGHT_LEFT, + .paletteTag = PALTAG_INTERFACE, + .oam = &sOam_Swap_MenuHighlight, + .anims = sAnims_Swap_Interface, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate gUnknown_0861087C = +static const struct SpriteTemplate sSpriteTemplate_Swap_MenuHighlightRight = { - .tileTag = TAG_TILE_67, - .paletteTag = TAG_PAL_66, - .oam = &gUnknown_086106E8, - .anims = gUnknown_08610758, + .tileTag = GFXTAG_MENU_HIGHLIGHT_RIGHT, + .paletteTag = PALTAG_INTERFACE, + .oam = &sOam_Swap_MenuHighlight, + .anims = sAnims_Swap_Interface, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate gUnknown_08610894 = +static const struct SpriteTemplate sSpriteTemplate_Swap_MonPicBgAnim = { - .tileTag = TAG_TILE_6D, - .paletteTag = TAG_PAL_67, - .oam = &gUnknown_086106F0, - .anims = gUnknown_0861075C, + .tileTag = GFXTAG_MON_PIC_BG_ANIM, + .paletteTag = PALTAG_MON_PIC_BG, + .oam = &sOam_Swap_MonPicBgAnim, + .anims = sAnims_Swap_MonPicBgAnim, .images = NULL, - .affineAnims = gUnknown_08610828, + .affineAnims = sAffineAnims_Swap_MonPicBgAnim, .callback = SpriteCallbackDummy }; void static (* const sSwap_MenuOptionFuncs[])(u8 taskId) = { - sub_819F114, - sub_819F0CC, - sub_819F134, + Swap_OptionSummary, + Swap_OptionSwap, + Swap_OptionRechoose, }; static const struct BgTemplate sSwap_BgTemplates[4] = @@ -897,9 +925,21 @@ static const struct BgTemplate sSwap_BgTemplates[4] = }, }; +enum { + SWAP_WIN_TITLE, + SWAP_WIN_SPECIES, + SWAP_WIN_INFO, + SWAP_WIN_OPTIONS, + SWAP_WIN_YES_NO, + SWAP_WIN_ACTION_FADE, // Used for action text fading out during screen transition + SWAP_WIN_UNUSED, + SWAP_WIN_SPECIES_AT_FADE, // Used to print species name stopped at current fade level + SWAP_WIN_MON_CATEGORY, +}; + static const struct WindowTemplate sSwap_WindowTemplates[] = { - { + [SWAP_WIN_TITLE] = { .bg = 0, .tilemapLeft = 0, .tilemapTop = 2, @@ -908,7 +948,7 @@ static const struct WindowTemplate sSwap_WindowTemplates[] = .paletteNum = 15, .baseBlock = 0x0001, }, - { + [SWAP_WIN_SPECIES] = { .bg = 2, .tilemapLeft = 19, .tilemapTop = 2, @@ -917,7 +957,7 @@ static const struct WindowTemplate sSwap_WindowTemplates[] = .paletteNum = 14, .baseBlock = 0x0019, }, - { + [SWAP_WIN_INFO] = { .bg = 0, .tilemapLeft = 0, .tilemapTop = 15, @@ -926,7 +966,7 @@ static const struct WindowTemplate sSwap_WindowTemplates[] = .paletteNum = 15, .baseBlock = 0x002f, }, - { + [SWAP_WIN_OPTIONS] = { .bg = 0, .tilemapLeft = 21, .tilemapTop = 14, @@ -935,7 +975,7 @@ static const struct WindowTemplate sSwap_WindowTemplates[] = .paletteNum = 15, .baseBlock = 0x006b, }, - { + [SWAP_WIN_YES_NO] = { .bg = 0, .tilemapLeft = 22, .tilemapTop = 14, @@ -944,7 +984,7 @@ static const struct WindowTemplate sSwap_WindowTemplates[] = .paletteNum = 15, .baseBlock = 0x00a1, }, - { + [SWAP_WIN_ACTION_FADE] = { .bg = 2, .tilemapLeft = 21, .tilemapTop = 15, @@ -953,7 +993,7 @@ static const struct WindowTemplate sSwap_WindowTemplates[] = .paletteNum = 14, .baseBlock = 0x006b, }, - { + [SWAP_WIN_UNUSED] = { .bg = 2, .tilemapLeft = 10, .tilemapTop = 2, @@ -962,7 +1002,7 @@ static const struct WindowTemplate sSwap_WindowTemplates[] = .paletteNum = 14, .baseBlock = 0x00c1, }, - { + [SWAP_WIN_SPECIES_AT_FADE] = { .bg = 0, .tilemapLeft = 19, .tilemapTop = 2, @@ -971,7 +1011,7 @@ static const struct WindowTemplate sSwap_WindowTemplates[] = .paletteNum = 15, .baseBlock = 0x00c9, }, - { + [SWAP_WIN_MON_CATEGORY] = { .bg = 0, .tilemapLeft = 15, .tilemapTop = 0, @@ -983,64 +1023,36 @@ static const struct WindowTemplate sSwap_WindowTemplates[] = DUMMY_WIN_TEMPLATE, }; -static const u16 gUnknown_08610918[] = {RGB_BLACK, RGB_BLACK, RGB_WHITE, RGB_BLACK, RGB_RED}; // Palette. +static const u16 sSwapText_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/text.gbapal"); // Identical to sSelectText_Pal static const u8 sSwapMenuOptionsTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GREY, TEXT_COLOR_TRANSPARENT}; static const u8 sSwapSpeciesNameTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_RED, TEXT_COLOR_TRANSPARENT}; -static const struct SwapActionIdAndFunc sSwap_PlayerScreenActions[] = +#define SWAPACTION_MON 1 +#define SWAPACTION_PKMN_FOR_SWAP 2 +#define SWAPACTION_CANCEL 3 + +static const struct SwapScreenAction sSwap_PlayerScreenActions[] = { - {1, Swap_ActionMon}, - {1, Swap_ActionMon}, - {1, Swap_ActionMon}, - {3, Swap_ActionCancel}, + {.id = SWAPACTION_MON, .func = Swap_ActionMon}, + {.id = SWAPACTION_MON, .func = Swap_ActionMon}, + {.id = SWAPACTION_MON, .func = Swap_ActionMon}, + {.id = SWAPACTION_CANCEL, .func = Swap_ActionCancel}, }; -static const struct SwapActionIdAndFunc sSwap_EnemyScreenActions[] = +static const struct SwapScreenAction sSwap_EnemyScreenActions[] = { - {1, Swap_ActionMon}, - {1, Swap_ActionMon}, - {1, Swap_ActionMon}, - {2, Swap_ActionPkmnForSwap}, - {3, Swap_ActionCancel}, + {.id = SWAPACTION_MON, .func = Swap_ActionMon}, + {.id = SWAPACTION_MON, .func = Swap_ActionMon}, + {.id = SWAPACTION_MON, .func = Swap_ActionMon}, + {.id = SWAPACTION_PKMN_FOR_SWAP, .func = Swap_ActionPkmnForSwap}, + {.id = SWAPACTION_CANCEL, .func = Swap_ActionCancel}, }; -// gfx -extern const u8 gFrontierFactorySelectMenu_Gfx[]; -extern const u8 gFrontierFactorySelectMenu_Tilemap[]; -extern const u16 gFrontierFactorySelectMenu_Pal[]; - -// text -extern const u8 gText_RentalPkmn2[]; -extern const u8 gText_SelectFirstPkmn[]; -extern const u8 gText_SelectSecondPkmn[]; -extern const u8 gText_SelectThirdPkmn[]; -extern const u8 gText_TheseThreePkmnOkay[]; -extern const u8 gText_CantSelectSamePkmn[]; -extern const u8 gText_Summary[]; -extern const u8 gText_Rechoose[]; -extern const u8 gText_Deselect[]; -extern const u8 gText_Rent[]; -extern const u8 gText_Others2[]; -extern const u8 gText_Yes2[]; -extern const u8 gText_Yes3[]; -extern const u8 gText_No2[]; -extern const u8 gText_No3[]; -extern const u8 gText_QuitSwapping[]; -extern const u8 gText_AcceptThisPkmn[]; -extern const u8 gText_SelectPkmnToAccept[]; -extern const u8 gText_SelectPkmnToSwap[]; -extern const u8 gText_PkmnSwap[]; -extern const u8 gText_Swap[]; -extern const u8 gText_Summary2[]; -extern const u8 gText_PkmnForSwap[]; -extern const u8 gText_SamePkmnInPartyAlready[]; -extern const u8 gText_Cancel3[]; - -// code -static void sub_819A44C(struct Sprite *sprite) +static void SpriteCB_Pokeball(struct Sprite *sprite) { - if (sprite->oam.paletteNum == IndexOfSpritePaletteTag(TAG_PAL_BALL_SELECTED)) + if (sprite->oam.paletteNum == IndexOfSpritePaletteTag(PALTAG_BALL_SELECTED)) { + // Pokeball selected, do rocking animation if (sprite->animEnded) { if (sprite->data[0] != 0) @@ -1064,11 +1076,12 @@ static void sub_819A44C(struct Sprite *sprite) } else { + // Pokeball not selected, remain still StartSpriteAnimIfDifferent(sprite, 0); } } -static void Select_CB2(void) +static void CB2_SelectScreen(void) { AnimateSprites(); BuildOamBuffer(); @@ -1077,7 +1090,7 @@ static void Select_CB2(void) RunTasks(); } -static void Select_VblankCb(void) +static void VBlankCB_SelectScreen(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -1090,6 +1103,27 @@ void DoBattleFactorySelectScreen(void) SetMainCallback2(CB2_InitSelectScreen); } +// Main select states +// States for the main tasks of the Select_ functions after initialization, including: +// Select_Task_OpenSummaryScreen, Select_Task_HandleYesNo, Select_Task_HandleMenu, and Select_Task_HandleChooseMons +// Unnecessarily complicated, could easily have just kept states numbered in each task always starting at 0 +// There's only one instance (Select_Task_HandleChooseMons) where a non-initial case is used +// Select_Task_Exit has its own straightforward states +#define STATE_CHOOSE_MONS_INIT 0 +#define STATE_CHOOSE_MONS_HANDLE_INPUT 1 +#define STATE_MENU_INIT 2 +#define STATE_MENU_HANDLE_INPUT 3 +#define STATE_YESNO_SHOW_OPTIONS 4 +#define STATE_YESNO_HANDLE_INPUT 5 +#define STATE_SUMMARY_FADE 6 +#define STATE_SUMMARY_CLEAN 7 +#define STATE_SUMMARY_SHOW 8 +#define STATE_MENU_SHOW_OPTIONS 9 +#define STATE_YESNO_SHOW_MONS 10 +#define STATE_CHOOSE_MONS_INVALID 11 +#define STATE_MENU_REINIT 12 +#define STATE_MENU_RESHOW 13 + static void CB2_InitSelectScreen(void) { u8 taskId; @@ -1110,9 +1144,9 @@ static void CB2_InitSelectScreen(void) break; case 1: sSelectMenuTilesetBuffer = Alloc(0x440); - sSelectMonCardBgTilesetBuffer = AllocZeroed(0x440); - sSelectMenuTilemapBuffer = Alloc(0x800); - sSelectMonCardBgTilemapBuffer = AllocZeroed(0x800); + sSelectMonPicBgTilesetBuffer = AllocZeroed(0x440); + sSelectMenuTilemapBuffer = Alloc(BG_SCREEN_SIZE); + sSelectMonPicBgTilemapBuffer = AllocZeroed(BG_SCREEN_SIZE); ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); ChangeBgX(1, 0, 0); @@ -1137,45 +1171,45 @@ static void CB2_InitSelectScreen(void) ResetTasks(); FreeAllSpritePalettes(); CpuCopy16(gFrontierFactorySelectMenu_Gfx, sSelectMenuTilesetBuffer, 0x440); - CpuCopy16(gUnknown_0861033C, sSelectMonCardBgTilesetBuffer, 0x60); + CpuCopy16(sMonPicBg_Gfx, sSelectMonPicBgTilesetBuffer, 0x60); LoadBgTiles(1, sSelectMenuTilesetBuffer, 0x440, 0); - LoadBgTiles(3, sSelectMonCardBgTilesetBuffer, 0x60, 0); - CpuCopy16(gFrontierFactorySelectMenu_Tilemap, sSelectMenuTilemapBuffer, 0x800); - LoadBgTilemap(1, sSelectMenuTilemapBuffer, 0x800, 0); + LoadBgTiles(3, sSelectMonPicBgTilesetBuffer, 0x60, 0); + CpuCopy16(gFrontierFactorySelectMenu_Tilemap, sSelectMenuTilemapBuffer, BG_SCREEN_SIZE); + LoadBgTilemap(1, sSelectMenuTilemapBuffer, BG_SCREEN_SIZE, 0); LoadPalette(gFrontierFactorySelectMenu_Pal, 0, 0x40); - LoadPalette(gUnknown_0861046C, 0xF0, 8); - LoadPalette(gUnknown_0861046C, 0xE0, 10); - #if MODERN + LoadPalette(sSelectText_Pal, 0xF0, 8); + LoadPalette(sSelectText_Pal, 0xE0, 10); +#ifdef UBFIX if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen) - #else +#else if (sFactorySelectScreen->fromSummaryScreen == TRUE) - #endif - gPlttBufferUnfaded[228] = sFactorySelectScreen->unk2A4; - LoadPalette(gUnknown_0861039C, 0x20, 4); +#endif + gPlttBufferUnfaded[228] = sFactorySelectScreen->speciesNameColorBackup; + LoadPalette(sMonPicBg_Pal, 0x20, 4); gMain.state++; break; case 3: - SetBgTilemapBuffer(3, sSelectMonCardBgTilemapBuffer); - CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 11, 4, 8, 8); - CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 2, 4, 8, 8); - CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 20, 4, 8, 8); + SetBgTilemapBuffer(3, sSelectMonPicBgTilemapBuffer); + CopyToBgTilemapBufferRect(3, sMonPicBg_Tilemap, 11, 4, 8, 8); + CopyToBgTilemapBufferRect(3, sMonPicBg_Tilemap, 2, 4, 8, 8); + CopyToBgTilemapBufferRect(3, sMonPicBg_Tilemap, 20, 4, 8, 8); CopyBgTilemapBufferToVram(3); gMain.state++; break; case 4: - LoadSpritePalettes(gUnknown_086103F4); - LoadSpriteSheets(gUnknown_086103BC); - LoadCompressedSpriteSheet(gUnknown_086103E4); + LoadSpritePalettes(sSelect_SpritePalettes); + LoadSpriteSheets(sSelect_SpriteSheets); + LoadCompressedSpriteSheet(sSelect_BallGfx); ShowBg(0); ShowBg(1); - SetVBlankCallback(Select_VblankCb); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); + SetVBlankCallback(VBlankCB_SelectScreen); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_1D_MAP); - #if MODERN +#ifdef UBFIX if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen) - #else +#else if (sFactorySelectScreen->fromSummaryScreen == TRUE) - #endif +#endif { Select_SetWinRegs(88, 152, 32, 96); ShowBg(3); @@ -1189,54 +1223,54 @@ static void CB2_InitSelectScreen(void) gMain.state++; break; case 5: - #if MODERN +#ifdef UBFIX if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen) - #else +#else if (sFactorySelectScreen->fromSummaryScreen == TRUE) - #endif +#endif sFactorySelectScreen->cursorPos = gLastViewedMonIndex; Select_InitMonsData(); Select_InitAllSprites(); if (sFactorySelectScreen->fromSummaryScreen == TRUE) - Select_ShowSummaryMonSprite(); + Select_ReshowMonSprite(); gMain.state++; break; case 6: Select_PrintSelectMonString(); - PutWindowTilemap(2); + PutWindowTilemap(SELECT_WIN_INFO); gMain.state++; break; case 7: Select_PrintMonCategory(); - PutWindowTilemap(5); + PutWindowTilemap(SELECT_WIN_MON_CATEGORY); gMain.state++; break; case 8: Select_PrintMonSpecies(); - PutWindowTilemap(1); + PutWindowTilemap(SELECT_WIN_SPECIES); gMain.state++; break; case 9: Select_PrintRentalPkmnString(); - PutWindowTilemap(0); + PutWindowTilemap(SELECT_WIN_TITLE); gMain.state++; break; case 10: - sFactorySelectScreen->fadeSpeciesNameTaskId = CreateTask(Task_SelectFadeSpeciesName, 0); + sFactorySelectScreen->fadeSpeciesNameTaskId = CreateTask(Select_Task_FadeSpeciesName, 0); if (!sFactorySelectScreen->fromSummaryScreen) { - gTasks[sFactorySelectScreen->fadeSpeciesNameTaskId].data[0] = 0; - taskId = CreateTask(Task_HandleSelectionScreenChooseMons, 0); - gTasks[taskId].data[0] = 0; + gTasks[sFactorySelectScreen->fadeSpeciesNameTaskId].tState = FADESTATE_INIT; + taskId = CreateTask(Select_Task_HandleChooseMons, 0); + gTasks[taskId].tState = STATE_CHOOSE_MONS_INIT; } else { - gTasks[sFactorySelectScreen->fadeSpeciesNameTaskId].data[0] = 1; - sFactorySelectScreen->unk2A2 = FALSE; - taskId = CreateTask(Task_HandleSelectionScreenMenu, 0); - gTasks[taskId].data[0] = 13; + gTasks[sFactorySelectScreen->fadeSpeciesNameTaskId].tState = FADESTATE_RUN; + sFactorySelectScreen->fadeSpeciesNameActive = FALSE; + taskId = CreateTask(Select_Task_HandleMenu, 0); + gTasks[taskId].tState = STATE_MENU_RESHOW; } - SetMainCallback2(Select_CB2); + SetMainCallback2(CB2_SelectScreen); break; } } @@ -1258,7 +1292,7 @@ static void Select_InitMonsData(void) if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_TENT) CreateFrontierFactorySelectableMons(0); else - CreateTentFactorySelectableMons(0); + CreateSlateportTentSelectableMons(0); } static void Select_InitAllSprites(void) @@ -1268,15 +1302,15 @@ static void Select_InitAllSprites(void) for (i = 0; i < SELECTABLE_MONS_COUNT; i++) { - sFactorySelectScreen->mons[i].spriteId = CreateSprite(&gUnknown_086105D8, (35 * i) + 32, 64, 1); - gSprites[sFactorySelectScreen->mons[i].spriteId].data[0] = 0; + sFactorySelectScreen->mons[i].ballSpriteId = CreateSprite(&sSpriteTemplate_Select_Pokeball, (35 * i) + 32, 64, 1); + gSprites[sFactorySelectScreen->mons[i].ballSpriteId].data[0] = 0; Select_SetBallSpritePaletteNum(i); } cursorPos = sFactorySelectScreen->cursorPos; - x = gSprites[sFactorySelectScreen->mons[cursorPos].spriteId].pos1.x; - sFactorySelectScreen->cursorSpriteId = CreateSprite(&gUnknown_086105F0, x, 88, 0); - sFactorySelectScreen->menuCursor1SpriteId = CreateSprite(&gUnknown_08610608, 176, 112, 0); - sFactorySelectScreen->menuCursor2SpriteId = CreateSprite(&gUnknown_08610620, 176, 144, 0); + x = gSprites[sFactorySelectScreen->mons[cursorPos].ballSpriteId].pos1.x; + sFactorySelectScreen->cursorSpriteId = CreateSprite(&sSpriteTemplate_Select_Arrow, x, 88, 0); + sFactorySelectScreen->menuCursor1SpriteId = CreateSprite(&sSpriteTemplate_Select_MenuHighlightLeft, 176, 112, 0); + sFactorySelectScreen->menuCursor2SpriteId = CreateSprite(&sSpriteTemplate_Select_MenuHighlightRight, 176, 144, 0); gSprites[sFactorySelectScreen->menuCursor1SpriteId].invisible = TRUE; gSprites[sFactorySelectScreen->menuCursor2SpriteId].invisible = TRUE; @@ -1292,7 +1326,7 @@ static void Select_DestroyAllSprites(void) u8 i; for (i = 0; i < SELECTABLE_MONS_COUNT; i++) - DestroySprite(&gSprites[sFactorySelectScreen->mons[i].spriteId]); + DestroySprite(&gSprites[sFactorySelectScreen->mons[i].ballSpriteId]); DestroySprite(&gSprites[sFactorySelectScreen->cursorSpriteId]); DestroySprite(&gSprites[sFactorySelectScreen->menuCursor1SpriteId]); @@ -1318,14 +1352,14 @@ static void Select_UpdateBallCursorPosition(s8 direction) } cursorPos = sFactorySelectScreen->cursorPos; - gSprites[sFactorySelectScreen->cursorSpriteId].pos1.x = gSprites[sFactorySelectScreen->mons[cursorPos].spriteId].pos1.x; + gSprites[sFactorySelectScreen->cursorSpriteId].pos1.x = gSprites[sFactorySelectScreen->mons[cursorPos].ballSpriteId].pos1.x; } static void Select_UpdateMenuCursorPosition(s8 direction) { if (direction > 0) // Move cursor down. { - if (sFactorySelectScreen->menuCursorPos != MENU_OPTIONS_COUNT - 1) + if (sFactorySelectScreen->menuCursorPos != ARRAY_COUNT(sSelect_MenuOptionFuncs) - 1) sFactorySelectScreen->menuCursorPos++; else sFactorySelectScreen->menuCursorPos = 0; @@ -1335,7 +1369,7 @@ static void Select_UpdateMenuCursorPosition(s8 direction) if (sFactorySelectScreen->menuCursorPos != 0) sFactorySelectScreen->menuCursorPos--; else - sFactorySelectScreen->menuCursorPos = MENU_OPTIONS_COUNT - 1; + sFactorySelectScreen->menuCursorPos = ARRAY_COUNT(sSelect_MenuOptionFuncs) - 1; } gSprites[sFactorySelectScreen->menuCursor1SpriteId].pos1.y = (sFactorySelectScreen->menuCursorPos * 16) + 112; @@ -1369,12 +1403,13 @@ static void Select_HandleMonSelectionChange(void) u8 cursorPos = sFactorySelectScreen->cursorPos; if (sFactorySelectScreen->mons[cursorPos].selectedId) // Deselect a mon. { - paletteNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_GREY); - if (sFactorySelectScreen->selectingMonsState == 3 && sFactorySelectScreen->mons[cursorPos].selectedId == 1) + paletteNum = IndexOfSpritePaletteTag(PALTAG_BALL_GRAY); + if (sFactorySelectScreen->selectingMonsState == FRONTIER_PARTY_SIZE + && sFactorySelectScreen->mons[cursorPos].selectedId == 1) { for (i = 0; i < SELECTABLE_MONS_COUNT; i++) { - if (sFactorySelectScreen->mons[i].selectedId == 2) + if (sFactorySelectScreen->mons[i].selectedId == FRONTIER_PARTY_SIZE - 1) break; } if (i == SELECTABLE_MONS_COUNT) @@ -1387,12 +1422,12 @@ static void Select_HandleMonSelectionChange(void) } else // Select a mon. { - paletteNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_SELECTED); + paletteNum = IndexOfSpritePaletteTag(PALTAG_BALL_SELECTED); sFactorySelectScreen->mons[cursorPos].selectedId = sFactorySelectScreen->selectingMonsState; sFactorySelectScreen->selectingMonsState++; } - gSprites[sFactorySelectScreen->mons[cursorPos].spriteId].oam.paletteNum = paletteNum; + gSprites[sFactorySelectScreen->mons[cursorPos].ballSpriteId].oam.paletteNum = paletteNum; } static void Select_SetBallSpritePaletteNum(u8 id) @@ -1400,191 +1435,196 @@ static void Select_SetBallSpritePaletteNum(u8 id) u8 palNum; if (sFactorySelectScreen->mons[id].selectedId) - palNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_SELECTED); + palNum = IndexOfSpritePaletteTag(PALTAG_BALL_SELECTED); else - palNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_GREY); + palNum = IndexOfSpritePaletteTag(PALTAG_BALL_GRAY); - gSprites[sFactorySelectScreen->mons[id].spriteId].oam.paletteNum = palNum; + gSprites[sFactorySelectScreen->mons[id].ballSpriteId].oam.paletteNum = palNum; } -static void Task_FromSelectScreenToSummaryScreen(u8 taskId) +static void Select_Task_OpenSummaryScreen(u8 taskId) { u8 i; u8 currMonId; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { - case 6: + case STATE_SUMMARY_FADE: gPlttBufferUnfaded[228] = gPlttBufferFaded[228]; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].data[0] = 7; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gTasks[taskId].tState = STATE_SUMMARY_CLEAN; break; - case 7: + case STATE_SUMMARY_CLEAN: if (!gPaletteFade.active) { DestroyTask(sFactorySelectScreen->fadeSpeciesNameTaskId); - sub_819F444(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0); + HideMonPic(sFactorySelectScreen->monPics[1], &sFactorySelectScreen->monPicAnimating); Select_DestroyAllSprites(); FREE_AND_SET_NULL(sSelectMenuTilesetBuffer); - FREE_AND_SET_NULL(sSelectMonCardBgTilesetBuffer); + FREE_AND_SET_NULL(sSelectMonPicBgTilesetBuffer); FREE_AND_SET_NULL(sSelectMenuTilemapBuffer); - FREE_AND_SET_NULL(sSelectMonCardBgTilemapBuffer); + FREE_AND_SET_NULL(sSelectMonPicBgTilemapBuffer); FreeAllWindowBuffers(); - gTasks[taskId].data[0] = 8; + gTasks[taskId].tState = STATE_SUMMARY_SHOW; } break; - case 8: - sFactorySelectScreen->unk2A4 = gPlttBufferUnfaded[228]; + case STATE_SUMMARY_SHOW: + sFactorySelectScreen->speciesNameColorBackup = gPlttBufferUnfaded[228]; DestroyTask(taskId); sFactorySelectScreen->fromSummaryScreen = TRUE; currMonId = sFactorySelectScreen->cursorPos; sFactorySelectMons = AllocZeroed(sizeof(struct Pokemon) * SELECTABLE_MONS_COUNT); for (i = 0; i < SELECTABLE_MONS_COUNT; i++) sFactorySelectMons[i] = sFactorySelectScreen->mons[i].monData; - ShowPokemonSummaryScreen(1, sFactorySelectMons, currMonId, SELECTABLE_MONS_COUNT - 1, CB2_InitSelectScreen); + ShowPokemonSummaryScreen(PSS_MODE_LOCK_MOVES, sFactorySelectMons, currMonId, SELECTABLE_MONS_COUNT - 1, CB2_InitSelectScreen); break; } } -static void Task_CloseSelectionScreen(u8 taskId) +static void Select_Task_Exit(u8 taskId) { - if (sFactorySelectScreen->unk2A0 != TRUE) + if (sFactorySelectScreen->monPicAnimating == TRUE) + return; + + switch (gTasks[taskId].tState) { - switch (gTasks[taskId].data[0]) + case 0: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gTasks[taskId].tState++; + break; + case 1: + if (!UpdatePaletteFade()) { - case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].data[0]++; - break; - case 1: - if (!UpdatePaletteFade()) - { - Select_CopyMonsToPlayerParty(); - DestroyTask(sFactorySelectScreen->fadeSpeciesNameTaskId); - Select_DestroyAllSprites(); - FREE_AND_SET_NULL(sSelectMenuTilesetBuffer); - FREE_AND_SET_NULL(sSelectMenuTilemapBuffer); - FREE_AND_SET_NULL(sSelectMonCardBgTilemapBuffer); - FREE_AND_SET_NULL(sFactorySelectScreen); - FreeAllWindowBuffers(); - SetMainCallback2(CB2_ReturnToFieldContinueScript); - DestroyTask(taskId); - } - break; + Select_CopyMonsToPlayerParty(); + DestroyTask(sFactorySelectScreen->fadeSpeciesNameTaskId); + Select_DestroyAllSprites(); + FREE_AND_SET_NULL(sSelectMenuTilesetBuffer); + FREE_AND_SET_NULL(sSelectMenuTilemapBuffer); + FREE_AND_SET_NULL(sSelectMonPicBgTilemapBuffer); + FREE_AND_SET_NULL(sFactorySelectScreen); + FreeAllWindowBuffers(); + SetMainCallback2(CB2_ReturnToFieldContinueScript); + DestroyTask(taskId); } + break; } } -static void Task_HandleSelectionScreenYesNo(u8 taskId) +// Handles the Yes/No prompt when confirming the 3 selected rental pokemon +static void Select_Task_HandleYesNo(u8 taskId) { - if (sFactorySelectScreen->unk2A0 != TRUE) + if (sFactorySelectScreen->monPicAnimating == TRUE) + return; + + switch (gTasks[taskId].tState) { - switch (gTasks[taskId].data[0]) + case STATE_YESNO_SHOW_MONS: + Select_ShowChosenMons(); + gTasks[taskId].tState = STATE_YESNO_SHOW_OPTIONS; + break; + case STATE_YESNO_SHOW_OPTIONS: + Select_ShowYesNoOptions(); + gTasks[taskId].tState = STATE_YESNO_HANDLE_INPUT; + break; + case STATE_YESNO_HANDLE_INPUT: + if (JOY_NEW(A_BUTTON)) { - case 10: - sub_819C4B4(); - gTasks[taskId].data[0] = 4; - break; - case 4: - Select_ShowYesNoOptions(); - gTasks[taskId].data[0] = 5; - break; - case 5: - if (JOY_NEW(A_BUTTON)) + PlaySE(SE_SELECT); + if (sFactorySelectScreen->yesNoCursorPos == 0) { - PlaySE(SE_SELECT); - if (sFactorySelectScreen->yesNoCursorPos == 0) - { - sub_819C568(); - gTasks[taskId].data[0] = 0; - gTasks[taskId].func = Task_CloseSelectionScreen; - } - else - { - sub_819B958(4); - sub_819BC9C(); - sFactorySelectScreen->unk2A2 = TRUE; - gTasks[taskId].data[0] = 1; - gTasks[taskId].func = Task_HandleSelectionScreenChooseMons; - } + // Selected Yes, confirmed selected pokemon + Select_HideChosenMons(); + gTasks[taskId].tState = 0; + gTasks[taskId].func = Select_Task_Exit; } - else if (JOY_NEW(B_BUTTON)) + else { - PlaySE(SE_SELECT); - sub_819B958(4); - sub_819BC9C(); - sFactorySelectScreen->unk2A2 = TRUE; - gTasks[taskId].data[0] = 1; - gTasks[taskId].func = Task_HandleSelectionScreenChooseMons; + // Selected No, continue choosing pokemon + Select_ErasePopupMenu(SELECT_WIN_YES_NO); + Select_DeclineChosenMons(); + sFactorySelectScreen->fadeSpeciesNameActive = TRUE; + gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT; + gTasks[taskId].func = Select_Task_HandleChooseMons; } - else if (JOY_REPEAT(DPAD_UP)) - { - PlaySE(SE_SELECT); - Select_UpdateYesNoCursorPosition(-1); - } - else if (JOY_REPEAT(DPAD_DOWN)) - { - PlaySE(SE_SELECT); - Select_UpdateYesNoCursorPosition(1); - } - break; } + else if (JOY_NEW(B_BUTTON)) + { + // Pressed B, Continue choosing pokemon + PlaySE(SE_SELECT); + Select_ErasePopupMenu(SELECT_WIN_YES_NO); + Select_DeclineChosenMons(); + sFactorySelectScreen->fadeSpeciesNameActive = TRUE; + gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT; + gTasks[taskId].func = Select_Task_HandleChooseMons; + } + else if (JOY_REPEAT(DPAD_UP)) + { + PlaySE(SE_SELECT); + Select_UpdateYesNoCursorPosition(-1); + } + else if (JOY_REPEAT(DPAD_DOWN)) + { + PlaySE(SE_SELECT); + Select_UpdateYesNoCursorPosition(1); + } + break; } } -static void Task_HandleSelectionScreenMenu(u8 taskId) +// Handles the popup menu that shows when a pokemon is selected +static void Select_Task_HandleMenu(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { - case 2: + case STATE_MENU_INIT: if (!sFactorySelectScreen->fromSummaryScreen) - sub_819F2B4(&sFactorySelectScreen->unk294[1].field1, &sFactorySelectScreen->unk2A0, FALSE); - gTasks[taskId].data[0] = 9; + OpenMonPic(&sFactorySelectScreen->monPics[1].bgSpriteId, &sFactorySelectScreen->monPicAnimating, FALSE); + gTasks[taskId].tState = STATE_MENU_SHOW_OPTIONS; break; - case 9: - if (sFactorySelectScreen->unk2A0 != TRUE) + case STATE_MENU_SHOW_OPTIONS: + if (sFactorySelectScreen->monPicAnimating != TRUE) { Select_ShowMenuOptions(); sFactorySelectScreen->fromSummaryScreen = FALSE; - gTasks[taskId].data[0] = 3; + gTasks[taskId].tState = STATE_MENU_HANDLE_INPUT; } break; - case 3: + case STATE_MENU_HANDLE_INPUT: if (JOY_NEW(A_BUTTON)) { u8 retVal; PlaySE(SE_SELECT); retVal = Select_RunMenuOptionFunc(); - if (retVal == 1) + if (retVal == SELECT_CONTINUE_CHOOSING) { - sFactorySelectScreen->unk2A2 = TRUE; - gTasks[taskId].data[0] = 1; - gTasks[taskId].func = Task_HandleSelectionScreenChooseMons; + sFactorySelectScreen->fadeSpeciesNameActive = TRUE; + gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT; + gTasks[taskId].func = Select_Task_HandleChooseMons; } - else if (retVal == 2) + else if (retVal == SELECT_CONFIRM_MONS) { - gTasks[taskId].data[0] = 10; - gTasks[taskId].func = Task_HandleSelectionScreenYesNo; + gTasks[taskId].tState = STATE_YESNO_SHOW_MONS; + gTasks[taskId].func = Select_Task_HandleYesNo; } - else if (retVal == 3) + else if (retVal == SELECT_INVALID_MON) { - gTasks[taskId].data[0] = 11; - gTasks[taskId].func = Task_HandleSelectionScreenChooseMons; + gTasks[taskId].tState = STATE_CHOOSE_MONS_INVALID; + gTasks[taskId].func = Select_Task_HandleChooseMons; } - else + else // SELECT_SUMMARY { - gTasks[taskId].data[0] = 6; - gTasks[taskId].func = Task_FromSelectScreenToSummaryScreen; + gTasks[taskId].tState = STATE_SUMMARY_FADE; + gTasks[taskId].func = Select_Task_OpenSummaryScreen; } } else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); - sub_819F3F8(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0, FALSE); - sub_819B958(3); - sFactorySelectScreen->unk2A2 = TRUE; - gTasks[taskId].data[0] = 1; - gTasks[taskId].func = Task_HandleSelectionScreenChooseMons; + CloseMonPic(sFactorySelectScreen->monPics[1], &sFactorySelectScreen->monPicAnimating, FALSE); + Select_ErasePopupMenu(SELECT_WIN_OPTIONS); + sFactorySelectScreen->fadeSpeciesNameActive = TRUE; + gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT; + gTasks[taskId].func = Select_Task_HandleChooseMons; } else if (JOY_REPEAT(DPAD_UP)) { @@ -1597,81 +1637,97 @@ static void Task_HandleSelectionScreenMenu(u8 taskId) Select_UpdateMenuCursorPosition(1); } break; - case 12: + case STATE_MENU_REINIT: if (!gPaletteFade.active) { if (sFactorySelectScreen->fromSummaryScreen == TRUE) { - gPlttBufferFaded[228] = sFactorySelectScreen->unk2A4; + gPlttBufferFaded[228] = sFactorySelectScreen->speciesNameColorBackup; gPlttBufferUnfaded[228] = gPlttBufferUnfaded[244]; } sFactorySelectScreen->fromSummaryScreen = FALSE; - gTasks[taskId].data[0] = 3; + gTasks[taskId].tState = STATE_MENU_HANDLE_INPUT; } break; - case 13: + case STATE_MENU_RESHOW: Select_ShowMenuOptions(); - gTasks[taskId].data[0] = 12; + gTasks[taskId].tState = STATE_MENU_REINIT; break; } } -static void Task_HandleSelectionScreenChooseMons(u8 taskId) +// Handles input on the main selection screen, when no popup menu is open +static void Select_Task_HandleChooseMons(u8 taskId) { - if (sFactorySelectScreen->unk2A0 != TRUE) + if (sFactorySelectScreen->monPicAnimating == TRUE) + return; + + switch (gTasks[taskId].tState) { - switch (gTasks[taskId].data[0]) + case STATE_CHOOSE_MONS_INIT: + if (!gPaletteFade.active) { - case 0: - if (!gPaletteFade.active) - { - gTasks[taskId].data[0] = 1; - sFactorySelectScreen->unk2A2 = TRUE; - } - break; - case 1: - if (JOY_NEW(A_BUTTON)) - { - PlaySE(SE_SELECT); - sFactorySelectScreen->unk2A2 = FALSE; - gTasks[taskId].data[0] = 2; - gTasks[taskId].func = Task_HandleSelectionScreenMenu; - } - else if (JOY_REPEAT(DPAD_LEFT)) - { - PlaySE(SE_SELECT); - Select_UpdateBallCursorPosition(-1); - Select_PrintMonCategory(); - Select_PrintMonSpecies(); - } - else if (JOY_REPEAT(DPAD_RIGHT)) - { - PlaySE(SE_SELECT); - Select_UpdateBallCursorPosition(1); - Select_PrintMonCategory(); - Select_PrintMonSpecies(); - } - break; - case 11: - if (JOY_NEW(A_BUTTON)) - { - PlaySE(SE_SELECT); - sub_819F3F8(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0, FALSE); - Select_PrintSelectMonString(); - sFactorySelectScreen->unk2A2 = TRUE; - gTasks[taskId].data[0] = 1; - } - break; + gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT; + sFactorySelectScreen->fadeSpeciesNameActive = TRUE; } + break; + case STATE_CHOOSE_MONS_HANDLE_INPUT: + if (JOY_NEW(A_BUTTON)) + { + PlaySE(SE_SELECT); + sFactorySelectScreen->fadeSpeciesNameActive = FALSE; + gTasks[taskId].tState = STATE_MENU_INIT; + gTasks[taskId].func = Select_Task_HandleMenu; + } + else if (JOY_REPEAT(DPAD_LEFT)) + { + PlaySE(SE_SELECT); + Select_UpdateBallCursorPosition(-1); + Select_PrintMonCategory(); + Select_PrintMonSpecies(); + } + else if (JOY_REPEAT(DPAD_RIGHT)) + { + PlaySE(SE_SELECT); + Select_UpdateBallCursorPosition(1); + Select_PrintMonCategory(); + Select_PrintMonSpecies(); + } + break; + case STATE_CHOOSE_MONS_INVALID: + if (JOY_NEW(A_BUTTON)) + { + PlaySE(SE_SELECT); + CloseMonPic(sFactorySelectScreen->monPics[1], &sFactorySelectScreen->monPicAnimating, FALSE); + Select_PrintSelectMonString(); + sFactorySelectScreen->fadeSpeciesNameActive = TRUE; + gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT; + } + break; } } +#undef STATE_CHOOSE_MONS_INIT +#undef STATE_CHOOSE_MONS_HANDLE_INPUT +#undef STATE_MENU_INIT +#undef STATE_MENU_HANDLE_INPUT +#undef STATE_YESNO_SHOW_OPTIONS +#undef STATE_YESNO_HANDLE_INPUT +#undef STATE_SUMMARY_FADE +#undef STATE_SUMMARY_CLEAN +#undef STATE_SUMMARY_SHOW +#undef STATE_MENU_SHOW_OPTIONS +#undef STATE_YESNO_SHOW_MONS +#undef STATE_CHOOSE_MONS_INVALID +#undef STATE_MENU_REINIT +#undef STATE_MENU_RESHOW + static void CreateFrontierFactorySelectableMons(u8 firstMonId) { u8 i, j = 0; u8 ivs = 0; u8 level = 0; - u8 happiness = 0; + u8 friendship = 0; u32 otId = 0; u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; @@ -1702,20 +1758,20 @@ static void CreateFrontierFactorySelectableMons(u8 firstMonId) ivs, gFacilityTrainerMons[monId].evSpread, otId); - happiness = 0; + friendship = 0; for (j = 0; j < MAX_MON_MOVES; j++) SetMonMoveAvoidReturn(&sFactorySelectScreen->mons[i + firstMonId].monData, gFacilityTrainerMons[monId].moves[j], j); - SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &happiness); + SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &friendship); SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]); } } -static void CreateTentFactorySelectableMons(u8 firstMonId) +static void CreateSlateportTentSelectableMons(u8 firstMonId) { u8 i, j; u8 ivs = 0; u8 level = 30; - u8 happiness = 0; + u8 friendship = 0; u32 otId = 0; gFacilityTrainerMons = gSlateportBattleTentMons; @@ -1732,10 +1788,10 @@ static void CreateTentFactorySelectableMons(u8 firstMonId) ivs, gFacilityTrainerMons[monId].evSpread, otId); - happiness = 0; + friendship = 0; for (j = 0; j < MAX_MON_MOVES; j++) SetMonMoveAvoidReturn(&sFactorySelectScreen->mons[i + firstMonId].monData, gFacilityTrainerMons[monId].moves[j], j); - SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &happiness); + SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &friendship); SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]); } } @@ -1744,7 +1800,7 @@ static void Select_CopyMonsToPlayerParty(void) { u8 i, j; - for (i = 0; i < 3; i++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { for (j = 0; j < SELECTABLE_MONS_COUNT; j++) { @@ -1793,7 +1849,7 @@ static void Select_ShowYesNoOptions(void) Select_PrintYesNoOptions(); } -static void sub_819B958(u8 windowId) +static void Select_ErasePopupMenu(u8 windowId) { gSprites[sFactorySelectScreen->menuCursor1SpriteId].invisible = TRUE; gSprites[sFactorySelectScreen->menuCursor2SpriteId].invisible = TRUE; @@ -1804,9 +1860,9 @@ static void sub_819B958(u8 windowId) static void Select_PrintRentalPkmnString(void) { - FillWindowPixelBuffer(0, PIXEL_FILL(0)); - AddTextPrinterParameterized(0, 1, gText_RentalPkmn2, 2, 1, 0, NULL); - CopyWindowToVram(0, 3); + FillWindowPixelBuffer(SELECT_WIN_TITLE, PIXEL_FILL(0)); + AddTextPrinterParameterized(SELECT_WIN_TITLE, 1, gText_RentalPkmn2, 2, 1, 0, NULL); + CopyWindowToVram(SELECT_WIN_TITLE, 3); } static void Select_PrintMonSpecies(void) @@ -1815,19 +1871,19 @@ static void Select_PrintMonSpecies(void) u8 x; u8 monId = sFactorySelectScreen->cursorPos; - FillWindowPixelBuffer(1, PIXEL_FILL(0)); + FillWindowPixelBuffer(SELECT_WIN_SPECIES, PIXEL_FILL(0)); species = GetMonData(&sFactorySelectScreen->mons[monId].monData, MON_DATA_SPECIES, NULL); StringCopy(gStringVar4, gSpeciesNames[species]); x = GetStringRightAlignXOffset(1, gStringVar4, 86); - AddTextPrinterParameterized3(1, 1, x, 1, sSpeciesNameTextColors, 0, gStringVar4); - CopyWindowToVram(1, 2); + AddTextPrinterParameterized3(SELECT_WIN_SPECIES, 1, x, 1, sSpeciesNameTextColors, 0, gStringVar4); + CopyWindowToVram(SELECT_WIN_SPECIES, 2); } static void Select_PrintSelectMonString(void) { const u8 *str = NULL; - FillWindowPixelBuffer(2, PIXEL_FILL(0)); + FillWindowPixelBuffer(SELECT_WIN_INFO, PIXEL_FILL(0)); if (sFactorySelectScreen->selectingMonsState == 1) str = gText_SelectFirstPkmn; else if (sFactorySelectScreen->selectingMonsState == 2) @@ -1837,46 +1893,46 @@ static void Select_PrintSelectMonString(void) else str = gText_TheseThreePkmnOkay; - AddTextPrinterParameterized(2, 1, str, 2, 5, 0, NULL); - CopyWindowToVram(2, 2); + AddTextPrinterParameterized(SELECT_WIN_INFO, 1, str, 2, 5, 0, NULL); + CopyWindowToVram(SELECT_WIN_INFO, 2); } static void Select_PrintCantSelectSameMon(void) { - FillWindowPixelBuffer(2, PIXEL_FILL(0)); - AddTextPrinterParameterized(2, 1, gText_CantSelectSamePkmn, 2, 5, 0, NULL); - CopyWindowToVram(2, 2); + FillWindowPixelBuffer(SELECT_WIN_INFO, PIXEL_FILL(0)); + AddTextPrinterParameterized(SELECT_WIN_INFO, 1, gText_CantSelectSamePkmn, 2, 5, 0, NULL); + CopyWindowToVram(SELECT_WIN_INFO, 2); } static void Select_PrintMenuOptions(void) { u8 selectedId = sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].selectedId; - PutWindowTilemap(3); - FillWindowPixelBuffer(3, PIXEL_FILL(0)); - AddTextPrinterParameterized3(3, 1, 7, 1, sMenuOptionTextColors, 0, gText_Summary); + PutWindowTilemap(SELECT_WIN_OPTIONS); + FillWindowPixelBuffer(SELECT_WIN_OPTIONS, PIXEL_FILL(0)); + AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, 1, 7, 1, sMenuOptionTextColors, 0, gText_Summary); if (selectedId != 0) - AddTextPrinterParameterized3(3, 1, 7, 17, sMenuOptionTextColors, 0, gText_Deselect); + AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, 1, 7, 17, sMenuOptionTextColors, 0, gText_Deselect); else - AddTextPrinterParameterized3(3, 1, 7, 17, sMenuOptionTextColors, 0, gText_Rent); + AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, 1, 7, 17, sMenuOptionTextColors, 0, gText_Rent); - AddTextPrinterParameterized3(3, 1, 7, 33, sMenuOptionTextColors, 0, gText_Others2); - CopyWindowToVram(3, 3); + AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, 1, 7, 33, sMenuOptionTextColors, 0, gText_Others2); + CopyWindowToVram(SELECT_WIN_OPTIONS, 3); } static void Select_PrintYesNoOptions(void) { - PutWindowTilemap(4); - FillWindowPixelBuffer(4, PIXEL_FILL(0)); - AddTextPrinterParameterized3(4, 1, 7, 1, sMenuOptionTextColors, 0, gText_Yes2); - AddTextPrinterParameterized3(4, 1, 7, 17, sMenuOptionTextColors, 0, gText_No2); - CopyWindowToVram(4, 3); + PutWindowTilemap(SELECT_WIN_YES_NO); + FillWindowPixelBuffer(SELECT_WIN_YES_NO, PIXEL_FILL(0)); + AddTextPrinterParameterized3(SELECT_WIN_YES_NO, 1, 7, 1, sMenuOptionTextColors, 0, gText_Yes2); + AddTextPrinterParameterized3(SELECT_WIN_YES_NO, 1, 7, 17, sMenuOptionTextColors, 0, gText_No2); + CopyWindowToVram(SELECT_WIN_YES_NO, 3); } static u8 Select_RunMenuOptionFunc(void) { - gUnknown_030062E8 = sSelect_MenuOptionFuncs[sFactorySelectScreen->menuCursorPos]; - return gUnknown_030062E8(); + gFactorySelect_CurrentOptionFunc = sSelect_MenuOptionFuncs[sFactorySelectScreen->menuCursorPos]; + return gFactorySelect_CurrentOptionFunc(); } static u8 Select_OptionRentDeselect(void) @@ -1886,29 +1942,29 @@ static u8 Select_OptionRentDeselect(void) if (selectedId == 0 && !Select_AreSpeciesValid(monId)) { Select_PrintCantSelectSameMon(); - sub_819B958(3); - return 3; + Select_ErasePopupMenu(SELECT_WIN_OPTIONS); + return SELECT_INVALID_MON; } else { - sub_819F3F8(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0, FALSE); + CloseMonPic(sFactorySelectScreen->monPics[1], &sFactorySelectScreen->monPicAnimating, FALSE); Select_HandleMonSelectionChange(); Select_PrintSelectMonString(); - sub_819B958(3); - if (sFactorySelectScreen->selectingMonsState > 3) - return 2; + Select_ErasePopupMenu(SELECT_WIN_OPTIONS); + if (sFactorySelectScreen->selectingMonsState > FRONTIER_PARTY_SIZE) + return SELECT_CONFIRM_MONS; else - return 1; + return SELECT_CONTINUE_CHOOSING; } } -static u8 sub_819BC9C(void) +static u8 Select_DeclineChosenMons(void) { - sub_819C568(); + Select_HideChosenMons(); Select_HandleMonSelectionChange(); Select_PrintSelectMonString(); - sub_819B958(3); - if (sFactorySelectScreen->selectingMonsState > 3) + Select_ErasePopupMenu(SELECT_WIN_OPTIONS); + if (sFactorySelectScreen->selectingMonsState > FRONTIER_PARTY_SIZE) return 2; else return 1; @@ -1916,14 +1972,14 @@ static u8 sub_819BC9C(void) static u8 Select_OptionSummary(void) { - return 0; + return SELECT_SUMMARY; } static u8 Select_OptionOthers(void) { - sub_819F3F8(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0, FALSE); - sub_819B958(3); - return 1; + CloseMonPic(sFactorySelectScreen->monPics[1], &sFactorySelectScreen->monPicAnimating, FALSE); + Select_ErasePopupMenu(SELECT_WIN_OPTIONS); + return SELECT_CONTINUE_CHOOSING; } static void Select_PrintMonCategory(void) @@ -1934,17 +1990,17 @@ static void Select_PrintMonCategory(void) u8 monId = sFactorySelectScreen->cursorPos; if (monId < SELECTABLE_MONS_COUNT) { - PutWindowTilemap(5); - FillWindowPixelBuffer(5, PIXEL_FILL(0)); + PutWindowTilemap(SELECT_WIN_MON_CATEGORY); + FillWindowPixelBuffer(SELECT_WIN_MON_CATEGORY, PIXEL_FILL(0)); species = GetMonData(&sFactorySelectScreen->mons[monId].monData, MON_DATA_SPECIES, NULL); CopyMonCategoryText(SpeciesToNationalPokedexNum(species), text); x = GetStringRightAlignXOffset(1, text, 0x76); - AddTextPrinterParameterized(5, 1, text, x, 1, 0, NULL); - CopyWindowToVram(5, 2); + AddTextPrinterParameterized(SELECT_WIN_MON_CATEGORY, 1, text, x, 1, 0, NULL); + CopyWindowToVram(SELECT_WIN_MON_CATEGORY, 2); } } -static void Summary_ShowMonSprite(void) +static void Select_CreateMonSprite(void) { u8 monId = sFactorySelectScreen->cursorPos; struct Pokemon *mon = &sFactorySelectScreen->mons[monId].monData; @@ -1952,44 +2008,44 @@ static void Summary_ShowMonSprite(void) u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); u32 otId = GetMonData(mon, MON_DATA_OT_ID, NULL); - sFactorySelectScreen->unk294[1].field0 = CreateMonPicSprite(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF); - gSprites[sFactorySelectScreen->unk294[1].field0].centerToCornerVecX = 0; - gSprites[sFactorySelectScreen->unk294[1].field0].centerToCornerVecY = 0; + sFactorySelectScreen->monPics[1].monSpriteId = CreateMonPicSprite(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF); + gSprites[sFactorySelectScreen->monPics[1].monSpriteId].centerToCornerVecX = 0; + gSprites[sFactorySelectScreen->monPics[1].monSpriteId].centerToCornerVecY = 0; - sFactorySelectScreen->unk2A0 = FALSE; + sFactorySelectScreen->monPicAnimating = FALSE; } -static void sub_819BE20(bool8 arg0) +static void Select_SetMonPicAnimating(bool8 animating) { - sFactorySelectScreen->unk2A0 = arg0; + sFactorySelectScreen->monPicAnimating = animating; } -static void Select_ShowSummaryMonSprite(void) +static void Select_ReshowMonSprite(void) { struct Pokemon *mon; u16 species; u32 personality, otId; - sFactorySelectScreen->unk294[1].field1 = CreateSprite(&gUnknown_08610638, 120, 64, 1); - StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->unk294[1].field1], 2); + sFactorySelectScreen->monPics[1].bgSpriteId = CreateSprite(&sSpriteTemplate_Select_MonPicBgAnim, 120, 64, 1); + StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->monPics[1].bgSpriteId], 2); mon = &sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].monData; species = GetMonData(mon, MON_DATA_SPECIES, NULL); personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); otId = GetMonData(mon, MON_DATA_OT_ID, NULL); - sFactorySelectScreen->unk294[1].field0 = CreateMonPicSprite(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF); - gSprites[sFactorySelectScreen->unk294[1].field0].centerToCornerVecX = 0; - gSprites[sFactorySelectScreen->unk294[1].field0].centerToCornerVecY = 0; + sFactorySelectScreen->monPics[1].monSpriteId = CreateMonPicSprite(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF); + gSprites[sFactorySelectScreen->monPics[1].monSpriteId].centerToCornerVecX = 0; + gSprites[sFactorySelectScreen->monPics[1].monSpriteId].centerToCornerVecY = 0; - gSprites[sFactorySelectScreen->unk294[1].field1].invisible = TRUE; + gSprites[sFactorySelectScreen->monPics[1].bgSpriteId].invisible = TRUE; } -static void Select_ShowChosenMonsSprites(void) +static void Select_CreateChosenMonsSprites(void) { u8 i, j; - for (i = 0; i < 3; i++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { for (j = 0; j < SELECTABLE_MONS_COUNT; j++) { @@ -2000,66 +2056,80 @@ static void Select_ShowChosenMonsSprites(void) u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); u32 otId = GetMonData(mon, MON_DATA_OT_ID, NULL); - sFactorySelectScreen->unk294[i].field0 = CreateMonPicSprite(species, otId, personality, TRUE, (i * 72) + 16, 32, i + 13, 0xFFFF); - gSprites[sFactorySelectScreen->unk294[i].field0].centerToCornerVecX = 0; - gSprites[sFactorySelectScreen->unk294[i].field0].centerToCornerVecY = 0; + sFactorySelectScreen->monPics[i].monSpriteId = CreateMonPicSprite(species, otId, personality, TRUE, (i * 72) + 16, 32, i + 13, 0xFFFF); + gSprites[sFactorySelectScreen->monPics[i].monSpriteId].centerToCornerVecX = 0; + gSprites[sFactorySelectScreen->monPics[i].monSpriteId].centerToCornerVecY = 0; break; } } } - sFactorySelectScreen->unk2A0 = FALSE; + sFactorySelectScreen->monPicAnimating = FALSE; } -static void sub_819C040(struct Sprite *sprite) +static void SpriteCB_OpenChosenMonPics(struct Sprite *sprite) { u8 taskId; + // Current sprite is monPics[1] if (sprite->affineAnimEnded - && gSprites[sFactorySelectScreen->unk294[0].field1].affineAnimEnded - && gSprites[sFactorySelectScreen->unk294[2].field1].affineAnimEnded) + && gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].affineAnimEnded + && gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].affineAnimEnded) { sprite->invisible = TRUE; - gSprites[sFactorySelectScreen->unk294[0].field1].invisible = TRUE; - gSprites[sFactorySelectScreen->unk294[2].field1].invisible = TRUE; + gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].invisible = TRUE; + gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].invisible = TRUE; - taskId = CreateTask(sub_819C1D0, 1); + taskId = CreateTask(Select_Task_OpenChosenMonPics, 1); gTasks[taskId].func(taskId); sprite->callback = SpriteCallbackDummy; } } -static void sub_819C100(struct Sprite *sprite) +static void SpriteCB_CloseChosenMonPics(struct Sprite *sprite) { + // Current sprite is monPics[1] if (sprite->affineAnimEnded - && gSprites[sFactorySelectScreen->unk294[0].field1].affineAnimEnded - && gSprites[sFactorySelectScreen->unk294[2].field1].affineAnimEnded) + && gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].affineAnimEnded + && gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].affineAnimEnded) { FreeOamMatrix(sprite->oam.matrixNum); - FreeOamMatrix(gSprites[sFactorySelectScreen->unk294[0].field1].oam.matrixNum); - FreeOamMatrix(gSprites[sFactorySelectScreen->unk294[2].field1].oam.matrixNum); + FreeOamMatrix(gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].oam.matrixNum); + FreeOamMatrix(gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].oam.matrixNum); - sFactorySelectScreen->unk2A0 = FALSE; + sFactorySelectScreen->monPicAnimating = FALSE; - DestroySprite(&gSprites[sFactorySelectScreen->unk294[0].field1]); - DestroySprite(&gSprites[sFactorySelectScreen->unk294[2].field1]); + DestroySprite(&gSprites[sFactorySelectScreen->monPics[0].bgSpriteId]); + DestroySprite(&gSprites[sFactorySelectScreen->monPics[2].bgSpriteId]); DestroySprite(sprite); } } -static void sub_819C1D0(u8 taskId) +// Task data for Select_Task_OpenChosenMonPics, Select_Task_CloseChosenMonPics, Task_CloseMonPic, and Task_OpenMonPic +#define tWinLeft data[3] +#ifndef UBFIX +#define tWinRight data[24] // UB: Typo? Likely meant data[4], 24 is out of bounds +#else +#define tWinRight data[4] +#endif +#define tWinTop data[5] +#define tWinBottom data[8] +#define tSpriteId data[6] // TODO: Clarify, what sprite +#define tIsSwapScreen data[7] + +static void Select_Task_OpenChosenMonPics(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: - task->data[3] = 16; - task->data[24] = 224; // BUG: writing outside the array's bounds. - task->data[5] = 64; - task->data[8] = 65; + task->tWinLeft = 16; + task->tWinRight = DISPLAY_WIDTH - 16; + task->tWinTop = 64; + task->tWinBottom = 65; SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[24])); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[8])); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWinLeft, task->tWinRight)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom)); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ); break; @@ -2069,97 +2139,97 @@ static void sub_819C1D0(u8 taskId) SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4)); break; case 2: - task->data[5] -= 4; - task->data[8] += 4; - if (task->data[5] <= 32 || task->data[8] >= 96) + task->tWinTop -= 4; + task->tWinBottom += 4; + if (task->tWinTop <= 32 || task->tWinBottom >= 96) { - task->data[5] = 32; - task->data[8] = 96; + task->tWinTop = 32; + task->tWinBottom = 96; ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); } - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[8])); - if (task->data[5] != 32) + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom)); + if (task->tWinTop != 32) return; break; default: DestroyTask(taskId); - Select_ShowChosenMonsSprites(); + Select_CreateChosenMonsSprites(); return; } - task->data[0]++; + task->tState++; } -static void sub_819C2D4(u8 taskId) +static void Select_Task_CloseChosenMonPics(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { + case 0: + task->tWinLeft = 16; + task->tWinRight = DISPLAY_WIDTH - 16; + task->tWinTop = 32; + task->tWinBottom = 96; + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWinLeft, task->tWinRight)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom)); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ); + task->tState++; + break; + case 1: + task->tWinTop += 4; + task->tWinBottom -= 4; + if (task->tWinTop >= 64 || task->tWinBottom <= 65) + { + task->tWinTop = 64; + task->tWinBottom = 65; + } + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom)); + if (task->tWinTop == 64) + task->tState++; + break; default: HideBg(3); - gSprites[sFactorySelectScreen->unk294[1].field1].invisible = FALSE; - gSprites[sFactorySelectScreen->unk294[1].field1].callback = sub_819C100; - gSprites[sFactorySelectScreen->unk294[0].field1].invisible = FALSE; - gSprites[sFactorySelectScreen->unk294[0].field1].callback = SpriteCallbackDummy; - gSprites[sFactorySelectScreen->unk294[2].field1].invisible = FALSE; - gSprites[sFactorySelectScreen->unk294[2].field1].callback = SpriteCallbackDummy; - StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->unk294[1].field1], 1); - StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->unk294[0].field1], 1); - StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->unk294[2].field1], 1); + gSprites[sFactorySelectScreen->monPics[1].bgSpriteId].invisible = FALSE; + gSprites[sFactorySelectScreen->monPics[1].bgSpriteId].callback = SpriteCB_CloseChosenMonPics; + gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].invisible = FALSE; + gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].callback = SpriteCallbackDummy; + gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].invisible = FALSE; + gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].callback = SpriteCallbackDummy; + StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->monPics[1].bgSpriteId], 1); + StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->monPics[0].bgSpriteId], 1); + StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->monPics[2].bgSpriteId], 1); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); DestroyTask(taskId); break; - case 0: - task->data[3] = 16; - task->data[24] = 224; // BUG: writing outside the array's bounds. - task->data[5] = 32; - task->data[8] = 96; - SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[24])); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[8])); - SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ); - SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ); - task->data[0]++; - break; - case 1: - task->data[5] += 4; - task->data[8] -= 4; - if (task->data[5] >= 64 || task->data[8] <= 65) - { - task->data[5] = 64; - task->data[8] = 65; - } - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[8])); - if (task->data[5] == 64) - task->data[0]++; - break; } } -static void sub_819C4B4(void) +static void Select_ShowChosenMons(void) { - sFactorySelectScreen->unk294[1].field1 = CreateSprite(&gUnknown_08610638, 120, 64, 1); - sFactorySelectScreen->unk294[0].field1 = CreateSprite(&gUnknown_08610638, 44, 64, 1); - sFactorySelectScreen->unk294[2].field1 = CreateSprite(&gUnknown_08610638, 196, 64, 1); + sFactorySelectScreen->monPics[1].bgSpriteId = CreateSprite(&sSpriteTemplate_Select_MonPicBgAnim, 120, 64, 1); + sFactorySelectScreen->monPics[0].bgSpriteId = CreateSprite(&sSpriteTemplate_Select_MonPicBgAnim, 44, 64, 1); + sFactorySelectScreen->monPics[2].bgSpriteId = CreateSprite(&sSpriteTemplate_Select_MonPicBgAnim, 196, 64, 1); - gSprites[sFactorySelectScreen->unk294[1].field1].callback = sub_819C040; - gSprites[sFactorySelectScreen->unk294[0].field1].callback = SpriteCallbackDummy; - gSprites[sFactorySelectScreen->unk294[2].field1].callback = SpriteCallbackDummy; + gSprites[sFactorySelectScreen->monPics[1].bgSpriteId].callback = SpriteCB_OpenChosenMonPics; + gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].callback = SpriteCallbackDummy; + gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].callback = SpriteCallbackDummy; - sFactorySelectScreen->unk2A0 = TRUE; + sFactorySelectScreen->monPicAnimating = TRUE; } -static void sub_819C568(void) +static void Select_HideChosenMons(void) { u8 taskId; - FreeAndDestroyMonPicSprite(sFactorySelectScreen->unk294[0].field0); - FreeAndDestroyMonPicSprite(sFactorySelectScreen->unk294[1].field0); - FreeAndDestroyMonPicSprite(sFactorySelectScreen->unk294[2].field0); + FreeAndDestroyMonPicSprite(sFactorySelectScreen->monPics[0].monSpriteId); + FreeAndDestroyMonPicSprite(sFactorySelectScreen->monPics[1].monSpriteId); + FreeAndDestroyMonPicSprite(sFactorySelectScreen->monPics[2].monSpriteId); - taskId = CreateTask(sub_819C2D4, 1); + taskId = CreateTask(Select_Task_CloseChosenMonPics, 1); gTasks[taskId].func(taskId); - sFactorySelectScreen->unk2A0 = TRUE; + sFactorySelectScreen->monPicAnimating = TRUE; } static void Select_SetWinRegs(s16 mWin0H, s16 nWin0H, s16 mWin0V, s16 nWin0V) @@ -2190,60 +2260,59 @@ static bool32 Select_AreSpeciesValid(u16 monId) } } } - return TRUE; } -static void Task_SelectFadeSpeciesName(u8 taskId) +static void Select_Task_FadeSpeciesName(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { - case 0: - sFactorySelectScreen->unk2A7 = 0; - sFactorySelectScreen->unk2A8 = 0; - sFactorySelectScreen->unk2A6 = TRUE; - gTasks[taskId].data[0] = 1; + case FADESTATE_INIT: + sFactorySelectScreen->fadeSpeciesNameCoeffDelay = 0; + sFactorySelectScreen->fadeSpeciesNameCoeff = 0; + sFactorySelectScreen->fadeSpeciesNameFadeOut = TRUE; + gTasks[taskId].tState = FADESTATE_RUN; break; - case 1: - if (sFactorySelectScreen->unk2A2) + case FADESTATE_RUN: + if (sFactorySelectScreen->fadeSpeciesNameActive) { - if (sFactorySelectScreen->unk2A9) + if (sFactorySelectScreen->faceSpeciesNameDelay) { - gTasks[taskId].data[0] = 2; + gTasks[taskId].tState = FADESTATE_DELAY; } else { - sFactorySelectScreen->unk2A7++; - if (sFactorySelectScreen->unk2A7 > 6) + sFactorySelectScreen->fadeSpeciesNameCoeffDelay++; + if (sFactorySelectScreen->fadeSpeciesNameCoeffDelay > 6) { - sFactorySelectScreen->unk2A7 = 0; - if (!sFactorySelectScreen->unk2A6) - sFactorySelectScreen->unk2A8--; + sFactorySelectScreen->fadeSpeciesNameCoeffDelay = 0; + if (!sFactorySelectScreen->fadeSpeciesNameFadeOut) + sFactorySelectScreen->fadeSpeciesNameCoeff--; else - sFactorySelectScreen->unk2A8++; + sFactorySelectScreen->fadeSpeciesNameCoeff++; } - BlendPalettes(0x4000, sFactorySelectScreen->unk2A8, 0); - if (sFactorySelectScreen->unk2A8 > 5) + BlendPalettes(0x4000, sFactorySelectScreen->fadeSpeciesNameCoeff, 0); + if (sFactorySelectScreen->fadeSpeciesNameCoeff > 5) { - sFactorySelectScreen->unk2A6 = FALSE; + sFactorySelectScreen->fadeSpeciesNameFadeOut = FALSE; } - else if (sFactorySelectScreen->unk2A8 == 0) + else if (sFactorySelectScreen->fadeSpeciesNameCoeff == 0) { - gTasks[taskId].data[0] = 2; - sFactorySelectScreen->unk2A6 = TRUE; + gTasks[taskId].tState = FADESTATE_DELAY; + sFactorySelectScreen->fadeSpeciesNameFadeOut = TRUE; } } } break; - case 2: - if (sFactorySelectScreen->unk2A9 > 14) + case FADESTATE_DELAY: + if (sFactorySelectScreen->faceSpeciesNameDelay > 14) { - sFactorySelectScreen->unk2A9 = 0; - gTasks[taskId].data[0] = 1; + sFactorySelectScreen->faceSpeciesNameDelay = 0; + gTasks[taskId].tState = FADESTATE_RUN; } else { - sFactorySelectScreen->unk2A9++; + sFactorySelectScreen->faceSpeciesNameDelay++; } break; } @@ -2269,233 +2338,257 @@ static void Swap_VblankCb(void) static void CopySwappedMonData(void) { - u8 happiness; + u8 friendship; gPlayerParty[sFactorySwapScreen->playerMonId] = gEnemyParty[sFactorySwapScreen->enemyMonId]; - happiness = 0; - SetMonData(&gPlayerParty[sFactorySwapScreen->playerMonId], MON_DATA_FRIENDSHIP, &happiness); - gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->playerMonId].monId = gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->enemyMonId + 3].monId; - gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->playerMonId].ivs = gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->enemyMonId + 3].ivs; + friendship = 0; + SetMonData(&gPlayerParty[sFactorySwapScreen->playerMonId], MON_DATA_FRIENDSHIP, &friendship); + gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->playerMonId].monId = gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->enemyMonId + FRONTIER_PARTY_SIZE].monId; + gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->playerMonId].ivs = gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->enemyMonId + FRONTIER_PARTY_SIZE].ivs; gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->playerMonId].personality = GetMonData(&gEnemyParty[sFactorySwapScreen->enemyMonId], MON_DATA_PERSONALITY, NULL); gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->playerMonId].abilityNum = GetBoxMonData(&gEnemyParty[sFactorySwapScreen->enemyMonId].box, MON_DATA_ABILITY_NUM, NULL); } -static void Task_FromSwapScreenToSummaryScreen(u8 taskId) +// Main swap states +// States for the main tasks of the Swap_ functions after initialization, including: +// Swap_Task_OpenSummaryScreen, Swap_Task_HandleYesNo, Swap_Task_HandleMenu, and Swap_Task_HandleChooseMons +// Tasks sharing states was unnecessary, see "Main select states" +#define STATE_CHOOSE_MONS_INIT 0 +#define STATE_CHOOSE_MONS_HANDLE_INPUT 1 +#define STATE_MENU_INIT 2 +#define STATE_MENU_HANDLE_INPUT 3 +#define STATE_YESNO_SHOW 4 +#define STATE_YESNO_HANDLE_INPUT 5 +#define STATE_SUMMARY_FADE 6 +#define STATE_SUMMARY_CLEAN 7 +#define STATE_SUMMARY_SHOW 8 +#define STATE_MENU_SHOW_OPTIONS 9 + +static void Swap_Task_OpenSummaryScreen(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { - case 6: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].data[0] = 7; + case STATE_SUMMARY_FADE: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gTasks[taskId].tState = STATE_SUMMARY_CLEAN; break; - case 7: + case STATE_SUMMARY_CLEAN: if (!gPaletteFade.active) { DestroyTask(sFactorySwapScreen->fadeSpeciesNameTaskId); - sub_819F444(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30); + HideMonPic(sFactorySwapScreen->monPic, &sFactorySwapScreen->monPicAnimating); Swap_DestroyAllSprites(); FREE_AND_SET_NULL(sSwapMenuTilesetBuffer); - FREE_AND_SET_NULL(sSwapMonCardBgTilesetBuffer); + FREE_AND_SET_NULL(sSwapMonPicBgTilesetBuffer); FREE_AND_SET_NULL(sSwapMenuTilemapBuffer); - FREE_AND_SET_NULL(sSwapMonCardBgTilemapBuffer); + FREE_AND_SET_NULL(sSwapMonPicBgTilemapBuffer); FreeAllWindowBuffers(); - gTasks[taskId].data[0] = 8; + gTasks[taskId].tState = STATE_SUMMARY_SHOW; } break; - case 8: + case STATE_SUMMARY_SHOW: DestroyTask(taskId); sFactorySwapScreen->fromSummaryScreen = TRUE; - sFactorySwapScreen->unk24 = gPlttBufferUnfaded[244]; - ShowPokemonSummaryScreen(0, gPlayerParty, sFactorySwapScreen->cursorPos, 3 - 1, CB2_InitSwapScreen); + sFactorySwapScreen->speciesNameColorBackup = gPlttBufferUnfaded[244]; + ShowPokemonSummaryScreen(PSS_MODE_NORMAL, gPlayerParty, sFactorySwapScreen->cursorPos, FRONTIER_PARTY_SIZE - 1, CB2_InitSwapScreen); break; } } -static void Task_CloseSwapScreen(u8 taskId) +static void Swap_Task_Exit(u8 taskId) { - if (sFactorySwapScreen->unk30 != TRUE) + if (sFactorySwapScreen->monPicAnimating == TRUE) + return; + + switch (gTasks[taskId].tState) { - switch (gTasks[taskId].data[0]) + case 0: + // Set return value for script + // TRUE if player kept their current pokemon + if (sFactorySwapScreen->monSwapped == TRUE) { - case 0: - if (sFactorySwapScreen->monSwapped == TRUE) - { - gTasks[taskId].data[0]++; - gSpecialVar_Result = 0; - } - else - { - gTasks[taskId].data[0] = 2; - gSpecialVar_Result = 1; - } - break; - case 1: - if (sFactorySwapScreen->monSwapped == TRUE) - { - sFactorySwapScreen->enemyMonId = sFactorySwapScreen->cursorPos; - CopySwappedMonData(); - } - gTasks[taskId].data[0]++; - break; - case 2: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].data[0]++; - break; - case 3: - if (!UpdatePaletteFade()) - { - DestroyTask(sFactorySwapScreen->fadeSpeciesNameTaskId); - Swap_DestroyAllSprites(); - FREE_AND_SET_NULL(sSwapMenuTilesetBuffer); - FREE_AND_SET_NULL(sSwapMonCardBgTilesetBuffer); - FREE_AND_SET_NULL(sSwapMenuTilemapBuffer); - FREE_AND_SET_NULL(sSwapMonCardBgTilemapBuffer); - FREE_AND_SET_NULL(sFactorySwapScreen); - FreeAllWindowBuffers(); - SetMainCallback2(CB2_ReturnToFieldContinueScript); - DestroyTask(taskId); - } - break; + gTasks[taskId].tState++; + gSpecialVar_Result = FALSE; } + else + { + gTasks[taskId].tState = 2; + gSpecialVar_Result = TRUE; + } + break; + case 1: + if (sFactorySwapScreen->monSwapped == TRUE) + { + sFactorySwapScreen->enemyMonId = sFactorySwapScreen->cursorPos; + CopySwappedMonData(); + } + gTasks[taskId].tState++; + break; + case 2: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gTasks[taskId].tState++; + break; + case 3: + if (!UpdatePaletteFade()) + { + DestroyTask(sFactorySwapScreen->fadeSpeciesNameTaskId); + Swap_DestroyAllSprites(); + FREE_AND_SET_NULL(sSwapMenuTilesetBuffer); + FREE_AND_SET_NULL(sSwapMonPicBgTilesetBuffer); + FREE_AND_SET_NULL(sSwapMenuTilemapBuffer); + FREE_AND_SET_NULL(sSwapMonPicBgTilemapBuffer); + FREE_AND_SET_NULL(sFactorySwapScreen); + FreeAllWindowBuffers(); + SetMainCallback2(CB2_ReturnToFieldContinueScript); + DestroyTask(taskId); + } + break; } } -static void Task_HandleSwapScreenYesNo(u8 taskId) +#define tSaidYes data[1] +#define tFollowUpTaskState data[5] +#define tFollowUpTaskPtrHi data[6] +#define tFollowUpTaskPtrLo data[7] + +static void Swap_Task_HandleYesNo(u8 taskId) { u16 loPtr, hiPtr; - if (sFactorySwapScreen->unk30 != TRUE) + if (sFactorySwapScreen->monPicAnimating == TRUE) + return; + + switch (gTasks[taskId].tState) { - switch (gTasks[taskId].data[0]) + case STATE_YESNO_SHOW: + Swap_ShowYesNoOptions(); + gTasks[taskId].tState = STATE_YESNO_HANDLE_INPUT; + break; + case STATE_YESNO_HANDLE_INPUT: + if (JOY_NEW(A_BUTTON)) { - case 4: - Swap_ShowYesNoOptions(); - gTasks[taskId].data[0] = 5; - break; - case 5: - if (JOY_NEW(A_BUTTON)) + PlaySE(SE_SELECT); + if (sFactorySwapScreen->yesNoCursorPos == 0) { - PlaySE(SE_SELECT); - if (sFactorySwapScreen->yesNoCursorPos == 0) - { - gTasks[taskId].data[1] = 1; - hiPtr = gTasks[taskId].data[6]; - loPtr = gTasks[taskId].data[7]; - gTasks[taskId].func = (void*)((hiPtr << 16) | loPtr); - } - else - { - gTasks[taskId].data[1] = 0; - sub_819EA64(4); - hiPtr = gTasks[taskId].data[6]; - loPtr = gTasks[taskId].data[7]; - gTasks[taskId].func = (void*)((hiPtr << 16) | loPtr); - } - } - else if (JOY_NEW(B_BUTTON)) - { - PlaySE(SE_SELECT); - gTasks[taskId].data[1] = 0; - sub_819EA64(4); - hiPtr = gTasks[taskId].data[6]; - loPtr = gTasks[taskId].data[7]; + // Selected Yes + gTasks[taskId].tSaidYes = TRUE; + hiPtr = gTasks[taskId].tFollowUpTaskPtrHi; + loPtr = gTasks[taskId].tFollowUpTaskPtrLo; gTasks[taskId].func = (void*)((hiPtr << 16) | loPtr); } - else if (JOY_REPEAT(DPAD_UP)) + else { - PlaySE(SE_SELECT); - Swap_UpdateYesNoCursorPosition(-1); + // Selected No + gTasks[taskId].tSaidYes = FALSE; + Swap_ErasePopupMenu(SWAP_WIN_YES_NO); + hiPtr = gTasks[taskId].tFollowUpTaskPtrHi; + loPtr = gTasks[taskId].tFollowUpTaskPtrLo; + gTasks[taskId].func = (void*)((hiPtr << 16) | loPtr); } - else if (JOY_REPEAT(DPAD_DOWN)) - { - PlaySE(SE_SELECT); - Swap_UpdateYesNoCursorPosition(1); - } - break; } + else if (JOY_NEW(B_BUTTON)) + { + PlaySE(SE_SELECT); + gTasks[taskId].tSaidYes = FALSE; + Swap_ErasePopupMenu(SWAP_WIN_YES_NO); + hiPtr = gTasks[taskId].tFollowUpTaskPtrHi; + loPtr = gTasks[taskId].tFollowUpTaskPtrLo; + gTasks[taskId].func = (void*)((hiPtr << 16) | loPtr); + } + else if (JOY_REPEAT(DPAD_UP)) + { + PlaySE(SE_SELECT); + Swap_UpdateYesNoCursorPosition(-1); + } + else if (JOY_REPEAT(DPAD_DOWN)) + { + PlaySE(SE_SELECT); + Swap_UpdateYesNoCursorPosition(1); + } + break; } } -static void sub_819CBDC(u8 taskId) +static void Swap_HandleQuitSwappingResposne(u8 taskId) { - if (gTasks[taskId].data[1] == 1) + if (gTasks[taskId].tSaidYes == TRUE) { - gTasks[taskId].data[0] = 0; - gTasks[taskId].func = Task_CloseSwapScreen; + gTasks[taskId].tState = 0; + gTasks[taskId].func = Swap_Task_Exit; } else { - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[6] = (u32)(Task_HandleSwapScreenChooseMons) >> 16; - gTasks[taskId].data[7] = (u32)(Task_HandleSwapScreenChooseMons); - gTasks[taskId].data[5] = 1; - gTasks[taskId].func = sub_819D770; + gTasks[taskId].tState = 0; + gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_HandleChooseMons) >> 16; + gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_HandleChooseMons); + gTasks[taskId].tFollowUpTaskState = STATE_CHOOSE_MONS_HANDLE_INPUT; + gTasks[taskId].func = Swap_Task_ScreenInfoTransitionIn; } } -static void sub_819CC24(u8 taskId) +static void Swap_AskQuitSwapping(u8 taskId) { - if (gTasks[taskId].data[0] == 0) + if (gTasks[taskId].tState == 0) { Swap_PrintOnInfoWindow(gText_QuitSwapping); sFactorySwapScreen->monSwapped = FALSE; - gTasks[taskId].data[0] = 4; - gTasks[taskId].data[6] = (u32)(sub_819CBDC) >> 16; - gTasks[taskId].data[7] = (u32)(sub_819CBDC); - gTasks[taskId].func = Task_HandleSwapScreenYesNo; + gTasks[taskId].tState = STATE_YESNO_SHOW; + gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_HandleQuitSwappingResposne) >> 16; + gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_HandleQuitSwappingResposne); + gTasks[taskId].func = Swap_Task_HandleYesNo; } } -static void sub_819CC74(u8 taskId) +static void Swap_HandleAcceptMonResponse(u8 taskId) { - sub_819F3F8(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30, TRUE); - if (gTasks[taskId].data[1] == 1) + CloseMonPic(sFactorySwapScreen->monPic, &sFactorySwapScreen->monPicAnimating, TRUE); + if (gTasks[taskId].tSaidYes == TRUE) { - gTasks[taskId].data[0] = 0; - gTasks[taskId].func = Task_CloseSwapScreen; + gTasks[taskId].tState = 0; + gTasks[taskId].func = Swap_Task_Exit; } else { - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[6] = (u32)(Task_HandleSwapScreenChooseMons) >> 16; - gTasks[taskId].data[7] = (u32)(Task_HandleSwapScreenChooseMons); - gTasks[taskId].data[5] = 1; - gTasks[taskId].func = sub_819D770; + gTasks[taskId].tState = 0; + gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_HandleChooseMons) >> 16; + gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_HandleChooseMons); + gTasks[taskId].tFollowUpTaskState = STATE_CHOOSE_MONS_HANDLE_INPUT; + gTasks[taskId].func = Swap_Task_ScreenInfoTransitionIn; } } -static void sub_819CCD4(u8 taskId) +static void Swap_AskAcceptMon(u8 taskId) { - if (gTasks[taskId].data[0] == 0) + if (gTasks[taskId].tState == 0) { - sub_819F2B4(&sFactorySwapScreen->unk2C.field1, &sFactorySwapScreen->unk30, TRUE); + OpenMonPic(&sFactorySwapScreen->monPic.bgSpriteId, &sFactorySwapScreen->monPicAnimating, TRUE); Swap_PrintOnInfoWindow(gText_AcceptThisPkmn); sFactorySwapScreen->monSwapped = TRUE; - gTasks[taskId].data[0] = 4; - gTasks[taskId].data[6] = (u32)(sub_819CC74) >> 16; - gTasks[taskId].data[7] = (u32)(sub_819CC74); - gTasks[taskId].func = Task_HandleSwapScreenYesNo; + gTasks[taskId].tState = STATE_YESNO_SHOW; + gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_HandleAcceptMonResponse) >> 16; + gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_HandleAcceptMonResponse); + gTasks[taskId].func = Swap_Task_HandleYesNo; } } -static void Task_HandleSwapScreenMenu(u8 taskId) +static void Swap_Task_HandleMenu(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { - case 2: + case STATE_MENU_INIT: if (!sFactorySwapScreen->fromSummaryScreen) - sub_819F2B4(&sFactorySwapScreen->unk2C.field1, &sFactorySwapScreen->unk30, TRUE); - gTasks[taskId].data[0] = 9; + OpenMonPic(&sFactorySwapScreen->monPic.bgSpriteId, &sFactorySwapScreen->monPicAnimating, TRUE); + gTasks[taskId].tState = STATE_MENU_SHOW_OPTIONS; break; - case 9: - if (sFactorySwapScreen->unk30 != TRUE) + case STATE_MENU_SHOW_OPTIONS: + if (sFactorySwapScreen->monPicAnimating != TRUE) { Swap_ShowMenuOptions(); - gTasks[taskId].data[0] = 3; + gTasks[taskId].tState = STATE_MENU_HANDLE_INPUT; } break; - case 3: - if (sFactorySwapScreen->unk30 != TRUE) + case STATE_MENU_HANDLE_INPUT: + if (sFactorySwapScreen->monPicAnimating != TRUE) { if (JOY_NEW(A_BUTTON)) { @@ -2505,13 +2598,13 @@ static void Task_HandleSwapScreenMenu(u8 taskId) else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); - sub_819F3F8(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30, TRUE); - sub_819EA64(3); - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[6] = (u32)(Task_HandleSwapScreenChooseMons) >> 16; - gTasks[taskId].data[7] = (u32)(Task_HandleSwapScreenChooseMons); - gTasks[taskId].data[5] = 1; - gTasks[taskId].func = sub_819D770; + CloseMonPic(sFactorySwapScreen->monPic, &sFactorySwapScreen->monPicAnimating, TRUE); + Swap_ErasePopupMenu(SWAP_WIN_OPTIONS); + gTasks[taskId].tState = 0; + gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_HandleChooseMons) >> 16; + gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_HandleChooseMons); + gTasks[taskId].tFollowUpTaskState = STATE_CHOOSE_MONS_HANDLE_INPUT; + gTasks[taskId].func = Swap_Task_ScreenInfoTransitionIn; } else if (JOY_REPEAT(DPAD_UP)) { @@ -2526,37 +2619,40 @@ static void Task_HandleSwapScreenMenu(u8 taskId) } } -static void Task_HandleSwapScreenChooseMons(u8 taskId) +// Handles input on the two main swap screens (choosing a current pokeon to get rid of, and choosing a new pokemon to receive) +static void Swap_Task_HandleChooseMons(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { - case 0: + case STATE_CHOOSE_MONS_INIT: if (!gPaletteFade.active) { - sFactorySwapScreen->unk22 = TRUE; - gTasks[taskId].data[0] = 1; + sFactorySwapScreen->fadeSpeciesNameActive = TRUE; + gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT; } break; - case 1: + case STATE_CHOOSE_MONS_HANDLE_INPUT: if (JOY_NEW(A_BUTTON)) { + // Run whatever action is currently selected (a pokeball, the Cancel button, etc.) PlaySE(SE_SELECT); - sFactorySwapScreen->unk22 = FALSE; - Swap_PrintMonSpecies2(); - sub_819EAC0(); + sFactorySwapScreen->fadeSpeciesNameActive = FALSE; + Swap_PrintMonSpeciesAtFade(); + Swap_EraseSpeciesWindow(); Swap_RunActionFunc(taskId); } else if (JOY_NEW(B_BUTTON)) { + // Ask if player wants to quit swapping PlaySE(SE_SELECT); - sFactorySwapScreen->unk22 = FALSE; - Swap_PrintMonSpecies2(); - sub_819EAC0(); - gTasks[taskId].data[6] = (u32)(sub_819CC24) >> 16; - gTasks[taskId].data[7] = (u32)(sub_819CC24); - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[5] = 0; - gTasks[taskId].func = sub_819D588; + sFactorySwapScreen->fadeSpeciesNameActive = FALSE; + Swap_PrintMonSpeciesAtFade(); + Swap_EraseSpeciesWindow(); + gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_AskQuitSwapping) >> 16; + gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_AskQuitSwapping); + gTasks[taskId].tState = 0; + gTasks[taskId].tFollowUpTaskState = 0; + gTasks[taskId].func = Swap_Task_ScreenInfoTransitionOut; } else if (JOY_REPEAT(DPAD_LEFT)) { @@ -2586,116 +2682,121 @@ static void Task_HandleSwapScreenChooseMons(u8 taskId) } } -static void Task_SwapFadeSpeciesName(u8 taskId) +static void Swap_Task_FadeSpeciesName(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { - case 0: - sFactorySwapScreen->unk27 = 0; - sFactorySwapScreen->unk28 = 0; - sFactorySwapScreen->unk26 = TRUE; - gTasks[taskId].data[0] = 1; + case FADESTATE_INIT: + sFactorySwapScreen->fadeSpeciesNameCoeffDelay = 0; + sFactorySwapScreen->fadeSpeciesNameCoeff = 0; + sFactorySwapScreen->fadeSpeciesNameFadeOut = TRUE; + gTasks[taskId].tState = FADESTATE_RUN; break; - case 1: - if (sFactorySwapScreen->unk22) + case FADESTATE_RUN: + if (sFactorySwapScreen->fadeSpeciesNameActive) { - if (sFactorySwapScreen->unk29) + if (sFactorySwapScreen->faceSpeciesNameDelay) { - gTasks[taskId].data[0] = 2; + gTasks[taskId].tState = FADESTATE_DELAY; } else { - sFactorySwapScreen->unk27++; - if (sFactorySwapScreen->unk27 > 6) + sFactorySwapScreen->fadeSpeciesNameCoeffDelay++; + if (sFactorySwapScreen->fadeSpeciesNameCoeffDelay > 6) { - sFactorySwapScreen->unk27 = 0; - if (!sFactorySwapScreen->unk26) - sFactorySwapScreen->unk28--; + sFactorySwapScreen->fadeSpeciesNameCoeffDelay = 0; + if (!sFactorySwapScreen->fadeSpeciesNameFadeOut) + sFactorySwapScreen->fadeSpeciesNameCoeff--; else - sFactorySwapScreen->unk28++; + sFactorySwapScreen->fadeSpeciesNameCoeff++; } - BlendPalettes(0x4000, sFactorySwapScreen->unk28, 0); - if (sFactorySwapScreen->unk28 > 5) + BlendPalettes(0x4000, sFactorySwapScreen->fadeSpeciesNameCoeff, 0); + if (sFactorySwapScreen->fadeSpeciesNameCoeff > 5) { - sFactorySwapScreen->unk26 = FALSE; + sFactorySwapScreen->fadeSpeciesNameFadeOut = FALSE; } - else if (sFactorySwapScreen->unk28 == 0) + else if (sFactorySwapScreen->fadeSpeciesNameCoeff == 0) { - gTasks[taskId].data[0] = 2; - sFactorySwapScreen->unk26 = TRUE; + gTasks[taskId].tState = FADESTATE_DELAY; + sFactorySwapScreen->fadeSpeciesNameFadeOut = TRUE; } } } break; - case 2: - if (sFactorySwapScreen->unk29 > 14) + case FADESTATE_DELAY: + if (sFactorySwapScreen->faceSpeciesNameDelay > 14) { - sFactorySwapScreen->unk29 = 0; - gTasks[taskId].data[0] = 1; + sFactorySwapScreen->faceSpeciesNameDelay = 0; + gTasks[taskId].tState = FADESTATE_RUN; } else { - sFactorySwapScreen->unk29++; + sFactorySwapScreen->faceSpeciesNameDelay++; } break; } } -static void Task_SwapFadeSpeciesName2(u8 taskId) +#define tFadeOutFinished data[4] + +static void Swap_Task_FadeOutSpeciesName(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: - sFactorySwapScreen->unk27 = 0; - gTasks[taskId].data[4] = 0; - gTasks[taskId].data[0]++; + sFactorySwapScreen->fadeSpeciesNameCoeffDelay = 0; + gTasks[taskId].tFadeOutFinished = FALSE; + gTasks[taskId].tState++; break; case 1: LoadPalette(&gPlttBufferUnfaded[0xF0], 0xE0, 0xA); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; break; case 2: - if (sFactorySwapScreen->unk28 > 15) + if (sFactorySwapScreen->fadeSpeciesNameCoeff > 15) { - gTasks[taskId].data[4] = 1; - gTasks[taskId].data[0]++; + gTasks[taskId].tFadeOutFinished = TRUE; + gTasks[taskId].tState++; } - sFactorySwapScreen->unk27++; - if (sFactorySwapScreen->unk27 > 3) + sFactorySwapScreen->fadeSpeciesNameCoeffDelay++; + if (sFactorySwapScreen->fadeSpeciesNameCoeffDelay > 3) { - sFactorySwapScreen->unk27 = 0; + sFactorySwapScreen->fadeSpeciesNameCoeffDelay = 0; gPlttBufferUnfaded[244] = gPlttBufferFaded[228]; - sFactorySwapScreen->unk28++; + sFactorySwapScreen->fadeSpeciesNameCoeff++; } - BlendPalettes(0x4000, sFactorySwapScreen->unk28, 0); + BlendPalettes(0x4000, sFactorySwapScreen->fadeSpeciesNameCoeff, 0); break; } } -static void sub_819D12C(u8 taskId) +// Slide current pokeballs offscreen to the right and new pokeballs onscreen from +// the left during transition between player's/enemy's party screens +#define tBallCycled(i) data[(i) + 1] +static void Swap_Task_SlideCycleBalls(u8 taskId) { s8 i; - u8 var_2C; - bool8 destroyTask; + u8 lastX; + bool8 finished; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: - gTasks[taskId].data[1] = 0; - gTasks[taskId].data[2] = 0; - gTasks[taskId].data[3] = 0; - gTasks[taskId].data[0] = 1; + gTasks[taskId].tBallCycled(0) = FALSE; + gTasks[taskId].tBallCycled(1) = FALSE; + gTasks[taskId].tBallCycled(2) = FALSE; + gTasks[taskId].tState = 1; break; case 1: - var_2C = 0; - for (i = 2; i >= 0; i--) + lastX = 0; + for (i = FRONTIER_PARTY_SIZE - 1; i >= 0; i--) { - if (i != 2) + if (i != FRONTIER_PARTY_SIZE - 1) { - u8 posX = var_2C - gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x; - if (posX == 16 || gTasks[taskId].data[i + 2] == 1) + u8 posX = lastX - gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x; + if (posX == 16 || gTasks[taskId].tBallCycled(i + 1) == TRUE) { - var_2C = gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x; + lastX = gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x; gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x += 10; } else if (posX > 16) @@ -2705,402 +2806,449 @@ static void sub_819D12C(u8 taskId) } else { - var_2C = gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x; + lastX = gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x; gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x += 10; } - if (gTasks[taskId].data[i + 1] == 1) + if (gTasks[taskId].tBallCycled(i) == TRUE) { + // New ball coming in from left, check if it has reached dest if (gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x > (i * 48) + 72) { + // Overshot dest, set x and finish gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x = (i * 48) + 72; - destroyTask = TRUE; + finished = TRUE; } else if (gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x == (i * 48) + 72) { - destroyTask = TRUE; + finished = TRUE; } else { - destroyTask = FALSE; + finished = FALSE; } } else { - destroyTask = FALSE; + finished = FALSE; } - if (gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x - 16 > 240) + if (gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x - 16 > DISPLAY_WIDTH) { - var_2C = gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x; + // Ball is offscreen right, cycle its palette and move to left side of screen + lastX = gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x; gSprites[sFactorySwapScreen->ballSpriteIds[i]].pos1.x = -16; if (sFactorySwapScreen->inEnemyScreen == TRUE) - gSprites[sFactorySwapScreen->ballSpriteIds[i]].oam.paletteNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_SELECTED); + gSprites[sFactorySwapScreen->ballSpriteIds[i]].oam.paletteNum = IndexOfSpritePaletteTag(PALTAG_BALL_SELECTED); else - gSprites[sFactorySwapScreen->ballSpriteIds[i]].oam.paletteNum = IndexOfSpritePaletteTag(TAG_PAL_BALL_GREY); + gSprites[sFactorySwapScreen->ballSpriteIds[i]].oam.paletteNum = IndexOfSpritePaletteTag(PALTAG_BALL_GRAY); - gTasks[taskId].data[i + 1] = 1; + gTasks[taskId].tBallCycled(i) = TRUE; } } - if (destroyTask == TRUE) + if (finished == TRUE) DestroyTask(taskId); break; } } -static void sub_819D324(u8 taskId) +// For sliding the action buttons (Cancel, Pkmn for Swap) on/off screen + +#define SLIDE_BUTTON_PKMN 0 +#define SLIDE_BUTTON_CANCEL 1 + +#define tTaskId data[1] +#define tSlidingOn data[2] +#define tXIncrement data[3] + +// Data to be used by the task that creates this task +#define tSecondSlideDelay data[2] +#define tSlideFinishedPkmn data[3] +#define tSlideFinishedCancel data[4] + +static void Swap_Task_SlideButtonOnOffScreen(u8 taskId) { u8 i, j; s32 posX = 0; - s8 r4 = gTasks[taskId].data[3]; - bool8 r1; + s8 deltaX = gTasks[taskId].tXIncrement; + bool8 sliding; s16 currPosX; - u8 taskId2; + u8 prevTaskId; - if (gTasks[taskId].data[2] == 1) - r4 *= -1; + if (gTasks[taskId].tSlidingOn == TRUE) + deltaX *= -1; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { - case 0: - currPosX = gSprites[sFactorySwapScreen->unk8[0][0]].pos1.x; - if (!gTasks[taskId].data[2]) + case SLIDE_BUTTON_PKMN: + currPosX = gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][0]].pos1.x; + if (!gTasks[taskId].tSlidingOn) { - if (currPosX + r4 < 240) + // Sliding "Pkmn for Swap" offscreen + if (currPosX + deltaX < DISPLAY_WIDTH) { - r1 = TRUE; + sliding = TRUE; } else { - r1 = FALSE; - posX = 240; + sliding = FALSE; + posX = DISPLAY_WIDTH; } } else { - if (currPosX + r4 > 160) + // Sliding "Pkmn for Swap" onscreen + if (currPosX + deltaX > 160) { - r1 = TRUE; + sliding = TRUE; } else { - r1 = FALSE; + sliding = FALSE; posX = 160; } } - if (r1 == TRUE) + if (sliding == TRUE) { - for (i = 0; i < 3; i++) + // Do movement + for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0]); i++) { - for (j = 0; j < 2; j++) - gSprites[sFactorySwapScreen->unk8[j][i]].pos1.x += r4; + for (j = 0; j < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds); j++) + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[j][i]].pos1.x += deltaX; } } else { - for (j = 0; j < 2; j++) + // Set final position + for (j = 0; j < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds); j++) { - gSprites[sFactorySwapScreen->unk8[j][0]].pos1.x = posX; - gSprites[sFactorySwapScreen->unk8[j][1]].pos1.x = posX + 16; - gSprites[sFactorySwapScreen->unk8[j][2]].pos1.x = posX + 48; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[j][0]].pos1.x = posX; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[j][1]].pos1.x = posX + 16; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[j][2]].pos1.x = posX + 48; } - taskId2 = gTasks[taskId].data[1]; - gTasks[taskId2].data[3] = 1; + prevTaskId = gTasks[taskId].tTaskId; + gTasks[prevTaskId].tSlideFinishedPkmn = TRUE; DestroyTask(taskId); } break; - case 1: - currPosX = gSprites[sFactorySwapScreen->unkE[0][0]].pos1.x; - if (!gTasks[taskId].data[2]) + case SLIDE_BUTTON_CANCEL: + currPosX = gSprites[sFactorySwapScreen->cancelButtonSpriteIds[0][0]].pos1.x; + if (!gTasks[taskId].tSlidingOn) { - if (currPosX + r4 < 240) + // Sliding "Cancel" offscreen + if (currPosX + deltaX < DISPLAY_WIDTH) { - r1 = TRUE; + sliding = TRUE; } else { - r1 = FALSE; - posX = 240; + sliding = FALSE; + posX = DISPLAY_WIDTH; } } else { - if (currPosX + r4 > 192) + // Sliding "Cancel" onscreen + if (currPosX + deltaX > 192) { - r1 = TRUE; + sliding = TRUE; } else { - r1 = FALSE; + sliding = FALSE; posX = 192; } } - if (r1 == TRUE) + if (sliding == TRUE) { - for (i = 0; i < 2; i++) + // Do movement + for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds); i++) { - for (j = 0; j < 2; j++) - gSprites[sFactorySwapScreen->unkE[j][i]].pos1.x += r4; + for (j = 0; j < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds[0]); j++) + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[j][i]].pos1.x += deltaX; } } else { - for (j = 0; j < 2; j++) + // Set final position + for (j = 0; j < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds); j++) { - gSprites[sFactorySwapScreen->unkE[j][0]].pos1.x = posX; - gSprites[sFactorySwapScreen->unkE[j][1]].pos1.x = posX + 16; + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[j][0]].pos1.x = posX; + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[j][1]].pos1.x = posX + 16; } - taskId2 = gTasks[taskId].data[1]; - gTasks[taskId2].data[4] = 1; + prevTaskId = gTasks[taskId].tTaskId; + gTasks[prevTaskId].tSlideFinishedCancel = TRUE; DestroyTask(taskId); } break; } } -static void sub_819D588(u8 taskId) +// Slide action buttons offscreen +static void Swap_Task_ScreenInfoTransitionOut(u8 taskId) { - u8 anotherTaskId; - u16 loPtr, hiPtr; + u8 slideTaskId; + u16 hiPtr, loPtr; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: - LoadPalette(gUnknown_08610918, 0xE0, sizeof(gUnknown_08610918)); + LoadPalette(sSwapText_Pal, 0xE0, sizeof(sSwapText_Pal)); Swap_PrintActionStrings(); - PutWindowTilemap(5); - gTasks[taskId].data[0]++; + PutWindowTilemap(SWAP_WIN_ACTION_FADE); + gTasks[taskId].tState++; break; case 1: - sub_819EA64(3); - gTasks[taskId].data[0]++; + Swap_ErasePopupMenu(SWAP_WIN_OPTIONS); + gTasks[taskId].tState++; break; case 2: - BeginNormalPaletteFade(0x4000, 0, 0, 0x10, gUnknown_0860F13C[37]); - gTasks[taskId].data[0]++; + BeginNormalPaletteFade(0x4000, 0, 0, 16, sPokeballGray_Pal[37]); + gTasks[taskId].tState++; break; case 3: if (!gPaletteFade.active) { - FillWindowPixelBuffer(5, PIXEL_FILL(0)); - CopyWindowToVram(5, 2); + FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0)); + CopyWindowToVram(SWAP_WIN_ACTION_FADE, 2); if (sFactorySwapScreen->inEnemyScreen == TRUE) { - anotherTaskId = CreateTask(sub_819D324, 0); - gTasks[taskId].data[3] = 0; - gTasks[anotherTaskId].data[1] = taskId; - gTasks[anotherTaskId].data[0] = 0; - gTasks[anotherTaskId].data[2] = 0; - gTasks[anotherTaskId].data[3] = 6; - gTasks[taskId].data[2] = 5; - gTasks[taskId].data[0]++; + // Start "Pkmn for Swap" button slide offscreen + slideTaskId = CreateTask(Swap_Task_SlideButtonOnOffScreen, 0); + gTasks[taskId].tSlideFinishedPkmn = FALSE; + gTasks[slideTaskId].tTaskId = taskId; + gTasks[slideTaskId].tState = SLIDE_BUTTON_PKMN; + gTasks[slideTaskId].tSlidingOn = FALSE; + gTasks[slideTaskId].tXIncrement = 6; + gTasks[taskId].tSecondSlideDelay = 5; + gTasks[taskId].tState++; } else { - anotherTaskId = CreateTask(sub_819D324, 0); - gTasks[taskId].data[3] = 1; - gTasks[taskId].data[4] = 0; - gTasks[anotherTaskId].data[1] = taskId; - gTasks[anotherTaskId].data[0] = 1; - gTasks[anotherTaskId].data[2] = 0; - gTasks[anotherTaskId].data[3] = 6; - gTasks[taskId].data[0] += 2; + // Start "Cancel" button slide offscreen + slideTaskId = CreateTask(Swap_Task_SlideButtonOnOffScreen, 0); + gTasks[taskId].tSlideFinishedPkmn = TRUE; + gTasks[taskId].tSlideFinishedCancel = FALSE; + gTasks[slideTaskId].tTaskId = taskId; + gTasks[slideTaskId].tState = SLIDE_BUTTON_CANCEL; + gTasks[slideTaskId].tSlidingOn = FALSE; + gTasks[slideTaskId].tXIncrement = 6; + gTasks[taskId].tState += 2; } } break; case 4: - if (gTasks[taskId].data[2] == 0) + // Start "Cancel" button slide offscreen for screens with both buttons + if (gTasks[taskId].tSecondSlideDelay == 0) { - anotherTaskId = CreateTask(sub_819D324, 0); - gTasks[taskId].data[4] = 0; - gTasks[anotherTaskId].data[1] = taskId; - gTasks[anotherTaskId].data[0] = 1; - gTasks[anotherTaskId].data[2] = 0; - gTasks[anotherTaskId].data[3] = 6; - gTasks[taskId].data[0]++; + slideTaskId = CreateTask(Swap_Task_SlideButtonOnOffScreen, 0); + gTasks[taskId].tSlideFinishedCancel = FALSE; + gTasks[slideTaskId].tTaskId = taskId; + gTasks[slideTaskId].tState = SLIDE_BUTTON_CANCEL; + gTasks[slideTaskId].tSlidingOn = FALSE; + gTasks[slideTaskId].tXIncrement = 6; + gTasks[taskId].tState++; } else { - gTasks[taskId].data[2]--; + gTasks[taskId].tSecondSlideDelay--; } break; case 5: - if (gTasks[taskId].data[3] == 1 && gTasks[taskId].data[4] == 1) + if (gTasks[taskId].tSlideFinishedPkmn == TRUE + && gTasks[taskId].tSlideFinishedCancel == TRUE) { - gTasks[taskId].data[0] = gTasks[taskId].data[5]; - loPtr = gTasks[taskId].data[6]; - hiPtr = gTasks[taskId].data[7]; - gTasks[taskId].func = (void *)((loPtr << 0x10) | (hiPtr)); + gTasks[taskId].tState = gTasks[taskId].tFollowUpTaskState; + hiPtr = gTasks[taskId].tFollowUpTaskPtrHi; + loPtr = gTasks[taskId].tFollowUpTaskPtrLo; + gTasks[taskId].func = (void *)((hiPtr << 16) | (loPtr)); } break; } } -static void sub_819D770(u8 taskId) +// Slide action buttons onscreen, reprint swap dialogue and mon info +static void Swap_Task_ScreenInfoTransitionIn(u8 taskId) { - u8 anotherTaskId; - u16 loPtr, hiPtr; - if (sFactorySwapScreen->unk30 == TRUE) + u8 slideTaskId; + u16 hiPtr, loPtr; + if (sFactorySwapScreen->monPicAnimating == TRUE) return; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: if (sFactorySwapScreen->inEnemyScreen == TRUE) { - anotherTaskId = CreateTask(sub_819D324, 0); - gTasks[taskId].data[3] = 0; - gTasks[anotherTaskId].data[1] = taskId; - gTasks[anotherTaskId].data[0] = 0; - gTasks[anotherTaskId].data[2] = 1; - gTasks[anotherTaskId].data[3] = 6; - gTasks[taskId].data[2] = 10; - gTasks[taskId].data[0]++; + // Start "Pkmn for Swap" button slide onscreen + slideTaskId = CreateTask(Swap_Task_SlideButtonOnOffScreen, 0); + gTasks[taskId].tSlideFinishedPkmn = FALSE; + gTasks[slideTaskId].tTaskId = taskId; + gTasks[slideTaskId].tState = SLIDE_BUTTON_PKMN; + gTasks[slideTaskId].tSlidingOn = TRUE; + gTasks[slideTaskId].tXIncrement = 6; + gTasks[taskId].tSecondSlideDelay = 10; + gTasks[taskId].tState++; } else { - anotherTaskId = CreateTask(sub_819D324, 0); - gTasks[taskId].data[3] = 1; - gTasks[taskId].data[4] = 0; - gTasks[anotherTaskId].data[1] = taskId; - gTasks[anotherTaskId].data[0] = 1; - gTasks[anotherTaskId].data[2] = 1; - gTasks[anotherTaskId].data[3] = 6; - gTasks[taskId].data[0] += 2; + // Start "Cancel" button slide onscreen + slideTaskId = CreateTask(Swap_Task_SlideButtonOnOffScreen, 0); + gTasks[taskId].tSlideFinishedPkmn = TRUE; + gTasks[taskId].tSlideFinishedCancel = FALSE; + gTasks[slideTaskId].tTaskId = taskId; + gTasks[slideTaskId].tState = SLIDE_BUTTON_CANCEL; + gTasks[slideTaskId].tSlidingOn = TRUE; + gTasks[slideTaskId].tXIncrement = 6; + gTasks[taskId].tState += 2; } break; case 1: - if (gTasks[taskId].data[2] == 0) + // Start "Cancel" button slide onscreen for screens with both buttons + if (gTasks[taskId].tSecondSlideDelay == 0) { - anotherTaskId = CreateTask(sub_819D324, 0); - gTasks[taskId].data[4] = 0; - gTasks[anotherTaskId].data[1] = taskId; - gTasks[anotherTaskId].data[0] = 1; - gTasks[anotherTaskId].data[2] = 1; - gTasks[anotherTaskId].data[3] = 6; - gTasks[taskId].data[0]++; + slideTaskId = CreateTask(Swap_Task_SlideButtonOnOffScreen, 0); + gTasks[taskId].tSlideFinishedCancel = FALSE; + gTasks[slideTaskId].tTaskId = taskId; + gTasks[slideTaskId].tState = SLIDE_BUTTON_CANCEL; + gTasks[slideTaskId].tSlidingOn = TRUE; + gTasks[slideTaskId].tXIncrement = 6; + gTasks[taskId].tState++; } else { - gTasks[taskId].data[2]--; + gTasks[taskId].tSecondSlideDelay--; } break; case 2: - if (gTasks[taskId].data[3] == 1 && gTasks[taskId].data[4] == 1) + if (gTasks[taskId].tSlideFinishedPkmn == TRUE + && gTasks[taskId].tSlideFinishedCancel == TRUE) { - gPlttBufferFaded[226] = gUnknown_0860F13C[37]; + gPlttBufferFaded[226] = sPokeballGray_Pal[37]; Swap_PrintActionStrings(); - PutWindowTilemap(5); - gTasks[taskId].data[0]++; + PutWindowTilemap(SWAP_WIN_ACTION_FADE); + gTasks[taskId].tState++; } break; case 3: - BeginNormalPaletteFade(0x4000, 0, 0x10, 0, gUnknown_0860F13C[37]); - gTasks[taskId].data[0]++; + BeginNormalPaletteFade(0x4000, 0, 16, 0, sPokeballGray_Pal[37]); + gTasks[taskId].tState++; break; case 4: if (!gPaletteFade.active) { Swap_PrintOneActionString(0); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 5: Swap_PrintOneActionString(1); - PutWindowTilemap(3); - gTasks[taskId].data[0]++; + PutWindowTilemap(SWAP_WIN_OPTIONS); + gTasks[taskId].tState++; break; case 6: - FillWindowPixelBuffer(5, PIXEL_FILL(0)); - CopyWindowToVram(5, 2); - gTasks[taskId].data[0]++; + FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0)); + CopyWindowToVram(SWAP_WIN_ACTION_FADE, 2); + gTasks[taskId].tState++; break; case 7: if (!sFactorySwapScreen->inEnemyScreen) Swap_PrintOnInfoWindow(gText_SelectPkmnToSwap); else Swap_PrintOnInfoWindow(gText_SelectPkmnToAccept); - if (sFactorySwapScreen->cursorPos < 3) + if (sFactorySwapScreen->cursorPos < FRONTIER_PARTY_SIZE) gSprites[sFactorySwapScreen->cursorSpriteId].invisible = FALSE; Swap_PrintMonCategory(); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; break; case 8: - Swap_PrintMonSpecies3(); - sub_819EADC(); - sFactorySwapScreen->unk22 = TRUE; - gTasks[taskId].data[0] = gTasks[taskId].data[5]; - loPtr = gTasks[taskId].data[6]; - hiPtr = gTasks[taskId].data[7]; - gTasks[taskId].func = (void *)((loPtr << 0x10) | (hiPtr)); + Swap_PrintMonSpeciesForTransition(); + Swap_EraseSpeciesAtFadeWindow(); + sFactorySwapScreen->fadeSpeciesNameActive = TRUE; + gTasks[taskId].tState = gTasks[taskId].tFollowUpTaskState; + hiPtr = gTasks[taskId].tFollowUpTaskPtrHi; + loPtr = gTasks[taskId].tFollowUpTaskPtrLo; + gTasks[taskId].func = (void *)((hiPtr << 16) | (loPtr)); break; } } -static void sub_819D9EC(u8 taskId) +#undef tTaskId +#undef tSlidingOn +#undef tXIncrement +#undef tSlideFinishedPkmn +#undef tSlideFinishedCancel + +// For switching between the swap screens with the player's / enemy's parties +static void Swap_Task_SwitchPartyScreen(u8 taskId) { u8 i; - if (sFactorySwapScreen->unk30 == TRUE) + if (sFactorySwapScreen->monPicAnimating == TRUE) return; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: - Swap_PrintMonSpecies3(); - gTasks[taskId].data[0]++; + Swap_PrintMonSpeciesForTransition(); + gTasks[taskId].tState++; break; case 1: - sub_819EADC(); + Swap_EraseSpeciesAtFadeWindow(); gSprites[sFactorySwapScreen->cursorSpriteId].invisible = TRUE; - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; break; case 2: - CreateTask(sub_819D12C, 0); - gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].func = Task_SwapFadeSpeciesName2; - gTasks[taskId].data[0]++; + CreateTask(Swap_Task_SlideCycleBalls, 0); + gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].func = Swap_Task_FadeOutSpeciesName; + gTasks[taskId].tState++; break; case 3: - if (!FuncIsActiveTask(sub_819D12C) && gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].data[4] == 1) + if (!FuncIsActiveTask(Swap_Task_SlideCycleBalls) + && gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].tFadeOutFinished == TRUE) { - sub_819EAC0(); + Swap_EraseSpeciesWindow(); if (!sFactorySwapScreen->inEnemyScreen) { - Swap_InitActions(ACTIONS_ENEMY_SCREEN); + Swap_InitActions(SWAP_ENEMY_SCREEN); } else { - Swap_InitActions(ACTIONS_PLAYER_SCREEN); - for (i = 0; i < 3; i++) - gSprites[sFactorySwapScreen->unk8[1][i]].invisible = TRUE; + Swap_InitActions(SWAP_PLAYER_SCREEN); + + // Hide "Pkmn for Swap" button + for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0]); i++) + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][i]].invisible = TRUE; } gSprites[sFactorySwapScreen->cursorSpriteId].pos1.x = gSprites[sFactorySwapScreen->ballSpriteIds[sFactorySwapScreen->cursorPos]].pos1.x; - gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].func = Task_SwapFadeSpeciesName; - sFactorySwapScreen->unk27 = 0; - sFactorySwapScreen->unk28 = 6; - sFactorySwapScreen->unk26 = FALSE; - gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].data[0] = 1; - gTasks[taskId].data[0]++; + gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].func = Swap_Task_FadeSpeciesName; + sFactorySwapScreen->fadeSpeciesNameCoeffDelay = 0; + sFactorySwapScreen->fadeSpeciesNameCoeff = 6; + sFactorySwapScreen->fadeSpeciesNameFadeOut = FALSE; + gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].tState = FADESTATE_RUN; + gTasks[taskId].tState++; } break; case 4: - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[6] = (u32)(Task_HandleSwapScreenChooseMons) >> 0x10; - gTasks[taskId].data[7] = (u32)(Task_HandleSwapScreenChooseMons); - gTasks[taskId].data[5] = 1; - gTasks[taskId].func = sub_819D770; + gTasks[taskId].tState = 0; + gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_HandleChooseMons) >> 16; + gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_HandleChooseMons); + gTasks[taskId].tFollowUpTaskState = STATE_CHOOSE_MONS_HANDLE_INPUT; + gTasks[taskId].func = Swap_Task_ScreenInfoTransitionIn; break; } } +#undef tFadeOutFinished + static void Swap_InitStruct(void) { if (sFactorySwapScreen == NULL) { sFactorySwapScreen = AllocZeroed(sizeof(*sFactorySwapScreen)); sFactorySwapScreen->cursorPos = 0; - sFactorySwapScreen->unk30 = FALSE; + sFactorySwapScreen->monPicAnimating = FALSE; sFactorySwapScreen->fromSummaryScreen = FALSE; } } @@ -3129,9 +3277,9 @@ static void CB2_InitSwapScreen(void) break; case 1: sSwapMenuTilesetBuffer = Alloc(0x440); - sSwapMonCardBgTilesetBuffer = AllocZeroed(0x440); - sSwapMenuTilemapBuffer = Alloc(0x800); - sSwapMonCardBgTilemapBuffer = AllocZeroed(0x800); + sSwapMonPicBgTilesetBuffer = AllocZeroed(0x440); + sSwapMenuTilemapBuffer = Alloc(BG_SCREEN_SIZE); + sSwapMonPicBgTilemapBuffer = AllocZeroed(BG_SCREEN_SIZE); ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); ChangeBgX(1, 0, 0); @@ -3157,36 +3305,36 @@ static void CB2_InitSwapScreen(void) FreeAllSpritePalettes(); ResetAllPicSprites(); CpuCopy16(gFrontierFactorySelectMenu_Gfx, sSwapMenuTilesetBuffer, 0x440); - CpuCopy16(gUnknown_0861033C, sSwapMonCardBgTilesetBuffer, 0x60); + CpuCopy16(sMonPicBg_Gfx, sSwapMonPicBgTilesetBuffer, 0x60); LoadBgTiles(1, sSwapMenuTilesetBuffer, 0x440, 0); - LoadBgTiles(3, sSwapMonCardBgTilesetBuffer, 0x60, 0); - CpuCopy16(gFrontierFactorySelectMenu_Tilemap, sSwapMenuTilemapBuffer, 0x800); - LoadBgTilemap(1, sSwapMenuTilemapBuffer, 0x800, 0); + LoadBgTiles(3, sSwapMonPicBgTilesetBuffer, 0x60, 0); + CpuCopy16(gFrontierFactorySelectMenu_Tilemap, sSwapMenuTilemapBuffer, BG_SCREEN_SIZE); + LoadBgTilemap(1, sSwapMenuTilemapBuffer, BG_SCREEN_SIZE, 0); LoadPalette(gFrontierFactorySelectMenu_Pal, 0, 0x40); - LoadPalette(gUnknown_08610918, 0xF0, sizeof(gUnknown_08610918)); - LoadPalette(gUnknown_08610918, 0xE0, sizeof(gUnknown_08610918)); - LoadPalette(gUnknown_0861039C, 0x20, 4); + LoadPalette(sSwapText_Pal, 0xF0, sizeof(sSwapText_Pal)); + LoadPalette(sSwapText_Pal, 0xE0, sizeof(sSwapText_Pal)); + LoadPalette(sMonPicBg_Pal, 0x20, 4); gMain.state++; break; case 3: - SetBgTilemapBuffer(3, sSwapMonCardBgTilemapBuffer); - CopyToBgTilemapBufferRect(3, gUnknown_0861023C, 11, 4, 8, 8); + SetBgTilemapBuffer(3, sSwapMonPicBgTilemapBuffer); + CopyToBgTilemapBufferRect(3, sMonPicBg_Tilemap, 11, 4, 8, 8); CopyBgTilemapBufferToVram(3); gMain.state++; break; case 4: - LoadSpritePalettes(gUnknown_086106B0); - LoadSpriteSheets(gUnknown_08610650); - LoadCompressedSpriteSheet(gUnknown_086106A0); + LoadSpritePalettes(sSwap_SpritePalettes); + LoadSpriteSheets(sSwap_SpriteSheets); + LoadCompressedSpriteSheet(sSwap_BallGfx); SetVBlankCallback(Swap_VblankCb); gMain.state++; break; case 5: - #if MODERN +#ifdef UBFIX if (sFactorySwapScreen && sFactorySwapScreen->fromSummaryScreen) - #else +#else if (sFactorySwapScreen->fromSummaryScreen == TRUE) - #endif +#endif sFactorySwapScreen->cursorPos = gLastViewedMonIndex; gMain.state++; break; @@ -3195,28 +3343,28 @@ static void CB2_InitSwapScreen(void) Swap_InitAllSprites(); if (sFactorySwapScreen->fromSummaryScreen == TRUE) Swap_ShowSummaryMonSprite(); - Swap_InitActions(ACTIONS_PLAYER_SCREEN); + Swap_InitActions(SWAP_PLAYER_SCREEN); gMain.state++; break; case 7: Swap_PrintOnInfoWindow(gText_SelectPkmnToSwap); - PutWindowTilemap(2); + PutWindowTilemap(SWAP_WIN_INFO); gMain.state++; break; case 8: Swap_PrintMonCategory(); - PutWindowTilemap(8); + PutWindowTilemap(SWAP_WIN_MON_CATEGORY); gMain.state++; break; case 9: if (!sFactorySwapScreen->fromSummaryScreen) Swap_PrintMonSpecies(); - PutWindowTilemap(1); + PutWindowTilemap(SWAP_WIN_SPECIES); gMain.state++; break; case 10: Swap_PrintPkmnSwap(); - PutWindowTilemap(0); + PutWindowTilemap(SWAP_WIN_TITLE); gMain.state++; break; case 11: @@ -3224,16 +3372,16 @@ static void CB2_InitSwapScreen(void) break; case 12: if (sFactorySwapScreen->fromSummaryScreen) - Swap_PrintMonSpecies2(); + Swap_PrintMonSpeciesAtFade(); gMain.state++; break; case 13: Swap_PrintActionStrings2(); - PutWindowTilemap(3); + PutWindowTilemap(SWAP_WIN_OPTIONS); gMain.state++; break; case 14: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); ShowBg(0); ShowBg(1); @@ -3251,20 +3399,20 @@ static void CB2_InitSwapScreen(void) gMain.state++; break; case 15: - sFactorySwapScreen->fadeSpeciesNameTaskId = CreateTask(Task_SwapFadeSpeciesName, 0); + sFactorySwapScreen->fadeSpeciesNameTaskId = CreateTask(Swap_Task_FadeSpeciesName, 0); if (!sFactorySwapScreen->fromSummaryScreen) { - gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].data[0] = 0; - taskId = CreateTask(Task_HandleSwapScreenChooseMons, 0); - gTasks[taskId].data[0] = 0; + gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].tState = FADESTATE_INIT; + taskId = CreateTask(Swap_Task_HandleChooseMons, 0); + gTasks[taskId].tState = STATE_CHOOSE_MONS_INIT; } else { - sub_819EAF8(); - gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].data[0] = 1; - sFactorySwapScreen->unk22 = FALSE; - taskId = CreateTask(Task_HandleSwapScreenMenu, 0); - gTasks[taskId].data[0] = 2; + Swap_EraseActionFadeWindow(); + gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].tState = FADESTATE_RUN; + sFactorySwapScreen->fadeSpeciesNameActive = FALSE; + taskId = CreateTask(Swap_Task_HandleMenu, 0); + gTasks[taskId].tState = STATE_MENU_INIT; } SetMainCallback2(Swap_CB2); break; @@ -3277,17 +3425,17 @@ static void Swap_InitAllSprites(void) u8 x; struct SpriteTemplate spriteTemplate; - spriteTemplate = gUnknown_08610834; - spriteTemplate.paletteTag = TAG_PAL_BALL_SELECTED; + spriteTemplate = sSpriteTemplate_Swap_Pokeball; + spriteTemplate.paletteTag = PALTAG_BALL_SELECTED; - for (i = 0; i < 3; i++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { sFactorySwapScreen->ballSpriteIds[i] = CreateSprite(&spriteTemplate, (48 * i) + 72, 64, 1); gSprites[sFactorySwapScreen->ballSpriteIds[i]].data[0] = 0; } - sFactorySwapScreen->cursorSpriteId = CreateSprite(&gUnknown_0861084C, gSprites[sFactorySwapScreen->ballSpriteIds[sFactorySwapScreen->cursorPos]].pos1.x, 88, 0); - sFactorySwapScreen->menuCursor1SpriteId = CreateSprite(&gUnknown_08610864, 176, 112, 0); - sFactorySwapScreen->menuCursor2SpriteId = CreateSprite(&gUnknown_0861087C, 176, 144, 0); + sFactorySwapScreen->cursorSpriteId = CreateSprite(&sSpriteTemplate_Swap_Arrow, gSprites[sFactorySwapScreen->ballSpriteIds[sFactorySwapScreen->cursorPos]].pos1.x, 88, 0); + sFactorySwapScreen->menuCursor1SpriteId = CreateSprite(&sSpriteTemplate_Swap_MenuHighlightLeft, 176, 112, 0); + sFactorySwapScreen->menuCursor2SpriteId = CreateSprite(&sSpriteTemplate_Swap_MenuHighlightRight, 176, 144, 0); gSprites[sFactorySwapScreen->menuCursor1SpriteId].invisible = TRUE; gSprites[sFactorySwapScreen->menuCursor2SpriteId].invisible = TRUE; gSprites[sFactorySwapScreen->menuCursor1SpriteId].centerToCornerVecX = 0; @@ -3296,105 +3444,110 @@ static void Swap_InitAllSprites(void) gSprites[sFactorySwapScreen->menuCursor2SpriteId].centerToCornerVecY = 0; if (sFactorySwapScreen->fromSummaryScreen == TRUE) - x = 240; + x = DISPLAY_WIDTH; else - x = 192; + x = DISPLAY_WIDTH - 48; - spriteTemplate = gUnknown_0861084C; - spriteTemplate.tileTag = TAG_TILE_68; - sFactorySwapScreen->unk8[0][0] = CreateSprite(&spriteTemplate, 240, 120, 10); + // Unusual way to create sprites + // The sprite template for the selector arrow is re-used + // with the tiles swapped out + spriteTemplate = sSpriteTemplate_Swap_Arrow; + spriteTemplate.tileTag = GFXTAG_ACTION_BOX_LEFT; + sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][0] = CreateSprite(&spriteTemplate, DISPLAY_WIDTH, 120, 10); - spriteTemplate = gUnknown_08610864; - spriteTemplate.tileTag = TAG_TILE_69; - sFactorySwapScreen->unk8[0][1] = CreateSprite(&spriteTemplate, 256, 120, 10); - sFactorySwapScreen->unk8[0][2] = CreateSprite(&spriteTemplate, 288, 120, 10); + spriteTemplate = sSpriteTemplate_Swap_MenuHighlightLeft; + spriteTemplate.tileTag = GFXTAG_ACTION_BOX_RIGHT; + sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][1] = CreateSprite(&spriteTemplate, DISPLAY_WIDTH + 16, 120, 10); + sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][2] = CreateSprite(&spriteTemplate, DISPLAY_WIDTH + 48, 120, 10); - spriteTemplate = gUnknown_0861084C; - spriteTemplate.tileTag = TAG_TILE_6A; - sFactorySwapScreen->unk8[1][0] = CreateSprite(&spriteTemplate, 240, 120, 1); + spriteTemplate = sSpriteTemplate_Swap_Arrow; + spriteTemplate.tileTag = GFXTAG_ACTION_HIGHLIGHT_LEFT; + sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][0] = CreateSprite(&spriteTemplate, DISPLAY_WIDTH, 120, 1); - spriteTemplate = gUnknown_08610864; - spriteTemplate.tileTag = TAG_TILE_6B; - sFactorySwapScreen->unk8[1][1] = CreateSprite(&spriteTemplate, 256, 120, 1); - spriteTemplate.tileTag = TAG_TILE_6C; - sFactorySwapScreen->unk8[1][2] = CreateSprite(&spriteTemplate, 288, 120, 1); + spriteTemplate = sSpriteTemplate_Swap_MenuHighlightLeft; + spriteTemplate.tileTag = GFXTAG_ACTION_HIGHLIGHT_MIDDLE; + sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][1] = CreateSprite(&spriteTemplate, DISPLAY_WIDTH + 16, 120, 1); + spriteTemplate.tileTag = GFXTAG_ACTION_HIGHLIGHT_RIGHT; + sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][2] = CreateSprite(&spriteTemplate, DISPLAY_WIDTH + 48, 120, 1); - spriteTemplate = gUnknown_0861084C; - spriteTemplate.tileTag = TAG_TILE_68; - sFactorySwapScreen->unkE[0][0] = CreateSprite(&spriteTemplate, x, 144, 10); + spriteTemplate = sSpriteTemplate_Swap_Arrow; + spriteTemplate.tileTag = GFXTAG_ACTION_BOX_LEFT; + sFactorySwapScreen->cancelButtonSpriteIds[0][0] = CreateSprite(&spriteTemplate, x, 144, 10); - spriteTemplate = gUnknown_08610864; - spriteTemplate.tileTag = TAG_TILE_69; - sFactorySwapScreen->unkE[0][1] = CreateSprite(&spriteTemplate, x + 16, 144, 10); + spriteTemplate = sSpriteTemplate_Swap_MenuHighlightLeft; + spriteTemplate.tileTag = GFXTAG_ACTION_BOX_RIGHT; + sFactorySwapScreen->cancelButtonSpriteIds[0][1] = CreateSprite(&spriteTemplate, x + 16, 144, 10); - spriteTemplate = gUnknown_0861084C; - spriteTemplate.tileTag = TAG_TILE_6A; - sFactorySwapScreen->unkE[1][0] = CreateSprite(&spriteTemplate, x, 144, 1); + spriteTemplate = sSpriteTemplate_Swap_Arrow; + spriteTemplate.tileTag = GFXTAG_ACTION_HIGHLIGHT_LEFT; + sFactorySwapScreen->cancelButtonSpriteIds[1][0] = CreateSprite(&spriteTemplate, x, 144, 1); - spriteTemplate = gUnknown_08610864; - spriteTemplate.tileTag = TAG_TILE_6C; - sFactorySwapScreen->unkE[1][1] = CreateSprite(&spriteTemplate, x + 16, 144, 1); + spriteTemplate = sSpriteTemplate_Swap_MenuHighlightLeft; + spriteTemplate.tileTag = GFXTAG_ACTION_HIGHLIGHT_RIGHT; + sFactorySwapScreen->cancelButtonSpriteIds[1][1] = CreateSprite(&spriteTemplate, x + 16, 144, 1); for (i = 0; i < 2; i++) { - gSprites[sFactorySwapScreen->unk8[i][0]].centerToCornerVecX = 0; - gSprites[sFactorySwapScreen->unk8[i][0]].centerToCornerVecY = 0; - gSprites[sFactorySwapScreen->unk8[i][1]].centerToCornerVecX = 0; - gSprites[sFactorySwapScreen->unk8[i][1]].centerToCornerVecY = 0; - gSprites[sFactorySwapScreen->unk8[i][2]].centerToCornerVecX = 0; - gSprites[sFactorySwapScreen->unk8[i][2]].centerToCornerVecY = 0; - gSprites[sFactorySwapScreen->unkE[i][0]].centerToCornerVecX = 0; - gSprites[sFactorySwapScreen->unkE[i][0]].centerToCornerVecY = 0; - gSprites[sFactorySwapScreen->unkE[i][1]].centerToCornerVecX = 0; - gSprites[sFactorySwapScreen->unkE[i][1]].centerToCornerVecY = 0; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][0]].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][0]].centerToCornerVecY = 0; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][1]].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][1]].centerToCornerVecY = 0; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][2]].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][2]].centerToCornerVecY = 0; + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][0]].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][0]].centerToCornerVecY = 0; + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][1]].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][1]].centerToCornerVecY = 0; - gSprites[sFactorySwapScreen->unk8[i][0]].invisible = TRUE; - gSprites[sFactorySwapScreen->unk8[i][1]].invisible = TRUE; - gSprites[sFactorySwapScreen->unk8[i][2]].invisible = TRUE; - gSprites[sFactorySwapScreen->unkE[i][0]].invisible = TRUE; - gSprites[sFactorySwapScreen->unkE[i][1]].invisible = TRUE; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][0]].invisible = TRUE; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][1]].invisible = TRUE; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][2]].invisible = TRUE; + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][0]].invisible = TRUE; + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][1]].invisible = TRUE; } - gSprites[sFactorySwapScreen->unkE[0][0]].invisible = FALSE; - gSprites[sFactorySwapScreen->unkE[0][1]].invisible = FALSE; - gSprites[sFactorySwapScreen->unk8[0][0]].invisible = FALSE; - gSprites[sFactorySwapScreen->unk8[0][1]].invisible = FALSE; - gSprites[sFactorySwapScreen->unk8[0][2]].invisible = FALSE; + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[0][0]].invisible = FALSE; + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[0][1]].invisible = FALSE; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][0]].invisible = FALSE; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][1]].invisible = FALSE; + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][2]].invisible = FALSE; } static void Swap_DestroyAllSprites(void) { u8 i, j; - for (i = 0; i < 3; i++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) DestroySprite(&gSprites[sFactorySwapScreen->ballSpriteIds[i]]); DestroySprite(&gSprites[sFactorySwapScreen->cursorSpriteId]); DestroySprite(&gSprites[sFactorySwapScreen->menuCursor1SpriteId]); DestroySprite(&gSprites[sFactorySwapScreen->menuCursor2SpriteId]); - for (i = 0; i < 2; i++) + for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds); i++) { - for (j = 0; j < 3; j++) - DestroySprite(&gSprites[sFactorySwapScreen->unk8[i][j]]); + for (j = 0; j < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0]); j++) + DestroySprite(&gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][j]]); } - for (i = 0; i < 2; i++) + for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds); i++) { - for (j = 0; j < 2; j++) - DestroySprite(&gSprites[sFactorySwapScreen->unkE[i][j]]); + for (j = 0; j < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds[0]); j++) + DestroySprite(&gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][j]]); } } static void Swap_HandleActionCursorChange(u8 cursorId) { - if (cursorId < 3) + if (cursorId < FRONTIER_PARTY_SIZE) { + // Cursor is on one of the pokemon gSprites[sFactorySwapScreen->cursorSpriteId].invisible = FALSE; - sub_819E8EC(); + Swap_HideActionButtonHighlights(); gSprites[sFactorySwapScreen->cursorSpriteId].pos1.x = gSprites[sFactorySwapScreen->ballSpriteIds[cursorId]].pos1.x; } else { + // Cursor is on an action button gSprites[sFactorySwapScreen->cursorSpriteId].invisible = TRUE; - sub_819E838(sFactorySwapScreen->actionsData[cursorId].id); + Swap_HighlightActionButton(sFactorySwapScreen->actionsData[cursorId].id); } } @@ -3427,8 +3580,8 @@ static void Swap_UpdateActionCursorPosition(s8 direction) PlaySE(SE_SELECT); if (direction > 0) // Move cursor down. { - if (sFactorySwapScreen->cursorPos < 3) - sFactorySwapScreen->cursorPos = 3; + if (sFactorySwapScreen->cursorPos < FRONTIER_PARTY_SIZE) + sFactorySwapScreen->cursorPos = FRONTIER_PARTY_SIZE; else if (sFactorySwapScreen->cursorPos + 1 != sFactorySwapScreen->actionsCount) sFactorySwapScreen->cursorPos++; else @@ -3436,7 +3589,7 @@ static void Swap_UpdateActionCursorPosition(s8 direction) } else // Move cursor up. { - if (sFactorySwapScreen->cursorPos < 3) + if (sFactorySwapScreen->cursorPos < FRONTIER_PARTY_SIZE) sFactorySwapScreen->cursorPos = sFactorySwapScreen->actionsCount - 1; else if (sFactorySwapScreen->cursorPos != 0) sFactorySwapScreen->cursorPos--; @@ -3474,7 +3627,7 @@ static void Swap_UpdateMenuCursorPosition(s8 direction) PlaySE(SE_SELECT); if (direction > 0) // Move cursor down. { - if (sFactorySwapScreen->menuCursorPos != MENU_OPTIONS_COUNT - 1) + if (sFactorySwapScreen->menuCursorPos != ARRAY_COUNT(sSwap_MenuOptionFuncs) - 1) sFactorySwapScreen->menuCursorPos++; else sFactorySwapScreen->menuCursorPos = 0; @@ -3484,43 +3637,52 @@ static void Swap_UpdateMenuCursorPosition(s8 direction) if (sFactorySwapScreen->menuCursorPos != 0) sFactorySwapScreen->menuCursorPos--; else - sFactorySwapScreen->menuCursorPos = MENU_OPTIONS_COUNT - 1; + sFactorySwapScreen->menuCursorPos = ARRAY_COUNT(sSwap_MenuOptionFuncs) - 1; } gSprites[sFactorySwapScreen->menuCursor1SpriteId].pos1.y = (sFactorySwapScreen->menuCursorPos * 16) + 112; gSprites[sFactorySwapScreen->menuCursor2SpriteId].pos1.y = (sFactorySwapScreen->menuCursorPos * 16) + 112; } -static void sub_819E838(u8 arg0) +static void Swap_HighlightActionButton(u8 actionId) { u8 i; - for (i = 0; i < 3; i++) + for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0]); i++) { - if (arg0 == 2) + if (actionId == SWAPACTION_PKMN_FOR_SWAP) { - gSprites[sFactorySwapScreen->unk8[1][i]].invisible = FALSE; - if (i < 2) - gSprites[sFactorySwapScreen->unkE[1][i]].invisible = TRUE; + // Show button highlight on "Pkmn for Swap" + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][i]].invisible = FALSE; + + // Hide button highlight on Cancel + if (i < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds[0])) + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[1][i]].invisible = TRUE; } - else if (arg0 == 3) + else if (actionId == SWAPACTION_CANCEL) { - if (i < 2) - gSprites[sFactorySwapScreen->unkE[1][i]].invisible = FALSE; - gSprites[sFactorySwapScreen->unk8[1][i]].invisible = TRUE; + // Show button highlight on Cancel + if (i < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds[0])) + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[1][i]].invisible = FALSE; + + // Hide button highlight on "Pkmn for Swap" + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][i]].invisible = TRUE; } } } -static void sub_819E8EC(void) +static void Swap_HideActionButtonHighlights(void) { u8 i; - for (i = 0; i < 3; i++) + for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0]); i++) { - gSprites[sFactorySwapScreen->unk8[1][i]].invisible = TRUE; - if (i < 2) - gSprites[sFactorySwapScreen->unkE[1][i]].invisible = TRUE; + // Hide button highlight on "Pkmn for Swap" + gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][i]].invisible = TRUE; + + // Hide button highlight on Cancel + if (i < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds[0])) + gSprites[sFactorySwapScreen->cancelButtonSpriteIds[1][i]].invisible = TRUE; } } @@ -3557,7 +3719,7 @@ static void Swap_ShowYesNoOptions(void) Swap_PrintYesNoOptions(); } -static void sub_819EA64(u8 windowId) +static void Swap_ErasePopupMenu(u8 windowId) { gSprites[sFactorySwapScreen->menuCursor1SpriteId].invisible = TRUE; gSprites[sFactorySwapScreen->menuCursor2SpriteId].invisible = TRUE; @@ -3566,33 +3728,33 @@ static void sub_819EA64(u8 windowId) ClearWindowTilemap(windowId); } -static void sub_819EAC0(void) +static void Swap_EraseSpeciesWindow(void) { - PutWindowTilemap(1); - FillWindowPixelBuffer(1, PIXEL_FILL(0)); - CopyWindowToVram(1, 2); + PutWindowTilemap(SWAP_WIN_SPECIES); + FillWindowPixelBuffer(SWAP_WIN_SPECIES, PIXEL_FILL(0)); + CopyWindowToVram(SWAP_WIN_SPECIES, 2); } -static void sub_819EADC(void) +static void Swap_EraseSpeciesAtFadeWindow(void) { - PutWindowTilemap(7); - FillWindowPixelBuffer(7, PIXEL_FILL(0)); - CopyWindowToVram(7, 2); + PutWindowTilemap(SWAP_WIN_SPECIES_AT_FADE); + FillWindowPixelBuffer(SWAP_WIN_SPECIES_AT_FADE, PIXEL_FILL(0)); + CopyWindowToVram(SWAP_WIN_SPECIES_AT_FADE, 2); } -static void sub_819EAF8(void) +static void Swap_EraseActionFadeWindow(void) { - sub_819EAC0(); - PutWindowTilemap(5); - FillWindowPixelBuffer(5, PIXEL_FILL(0)); - CopyWindowToVram(5, 2); + Swap_EraseSpeciesWindow(); + PutWindowTilemap(SWAP_WIN_ACTION_FADE); + FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0)); + CopyWindowToVram(SWAP_WIN_ACTION_FADE, 2); } static void Swap_PrintPkmnSwap(void) { - FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized(0, 1, gText_PkmnSwap, 2, 1, 0, NULL); - CopyWindowToVram(0, 3); + FillWindowPixelBuffer(SWAP_WIN_TITLE, PIXEL_FILL(1)); + AddTextPrinterParameterized(SWAP_WIN_TITLE, 1, gText_PkmnSwap, 2, 1, 0, NULL); + CopyWindowToVram(SWAP_WIN_TITLE, 3); } static void Swap_PrintMonSpecies(void) @@ -3600,10 +3762,10 @@ static void Swap_PrintMonSpecies(void) u16 species; u8 x; - FillWindowPixelBuffer(1, PIXEL_FILL(0)); - if (sFactorySwapScreen->cursorPos > 2) + FillWindowPixelBuffer(SWAP_WIN_SPECIES, PIXEL_FILL(0)); + if (sFactorySwapScreen->cursorPos >= FRONTIER_PARTY_SIZE) { - CopyWindowToVram(1, 2); + CopyWindowToVram(SWAP_WIN_SPECIES, 2); } else { @@ -3614,35 +3776,35 @@ static void Swap_PrintMonSpecies(void) species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL); StringCopy(gStringVar4, gSpeciesNames[species]); x = GetStringRightAlignXOffset(1, gStringVar4, 86); - AddTextPrinterParameterized3(1, 1, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4); - CopyWindowToVram(1, 3); + AddTextPrinterParameterized3(SWAP_WIN_SPECIES, 1, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4); + CopyWindowToVram(SWAP_WIN_SPECIES, 3); } } static void Swap_PrintOnInfoWindow(const u8 *str) { - FillWindowPixelBuffer(2, PIXEL_FILL(0)); - AddTextPrinterParameterized(2, 1, str, 2, 5, 0, NULL); - CopyWindowToVram(2, 2); + FillWindowPixelBuffer(SWAP_WIN_INFO, PIXEL_FILL(0)); + AddTextPrinterParameterized(SWAP_WIN_INFO, 1, str, 2, 5, 0, NULL); + CopyWindowToVram(SWAP_WIN_INFO, 2); } static void Swap_PrintMenuOptions(void) { - PutWindowTilemap(3); - FillWindowPixelBuffer(3, PIXEL_FILL(0)); - AddTextPrinterParameterized3(3, 1, 15, 1, sSwapMenuOptionsTextColors, 0, gText_Summary2); - AddTextPrinterParameterized3(3, 1, 15, 17, sSwapMenuOptionsTextColors, 0, gText_Swap); - AddTextPrinterParameterized3(3, 1, 15, 33, sSwapMenuOptionsTextColors, 0, gText_Rechoose); - CopyWindowToVram(3, 3); + PutWindowTilemap(SWAP_WIN_OPTIONS); + FillWindowPixelBuffer(SWAP_WIN_OPTIONS, PIXEL_FILL(0)); + AddTextPrinterParameterized3(SWAP_WIN_OPTIONS, 1, 15, 1, sSwapMenuOptionsTextColors, 0, gText_Summary2); + AddTextPrinterParameterized3(SWAP_WIN_OPTIONS, 1, 15, 17, sSwapMenuOptionsTextColors, 0, gText_Swap); + AddTextPrinterParameterized3(SWAP_WIN_OPTIONS, 1, 15, 33, sSwapMenuOptionsTextColors, 0, gText_Rechoose); + CopyWindowToVram(SWAP_WIN_OPTIONS, 3); } static void Swap_PrintYesNoOptions(void) { - PutWindowTilemap(4); - FillWindowPixelBuffer(4, PIXEL_FILL(0)); - AddTextPrinterParameterized3(4, 1, 7, 1, sSwapMenuOptionsTextColors, 0, gText_Yes3); - AddTextPrinterParameterized3(4, 1, 7, 17, sSwapMenuOptionsTextColors, 0, gText_No3); - CopyWindowToVram(4, 3); + PutWindowTilemap(SWAP_WIN_YES_NO); + FillWindowPixelBuffer(SWAP_WIN_YES_NO, PIXEL_FILL(0)); + AddTextPrinterParameterized3(SWAP_WIN_YES_NO, 1, 7, 1, sSwapMenuOptionsTextColors, 0, gText_Yes3); + AddTextPrinterParameterized3(SWAP_WIN_YES_NO, 1, 7, 17, sSwapMenuOptionsTextColors, 0, gText_No3); + CopyWindowToVram(SWAP_WIN_YES_NO, 3); } static void Swap_PrintActionString(const u8 *str, u32 y, u32 windowId) @@ -3653,30 +3815,30 @@ static void Swap_PrintActionString(const u8 *str, u32 y, u32 windowId) static void Swap_PrintActionStrings(void) { - FillWindowPixelBuffer(5, PIXEL_FILL(0)); + FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0)); switch (sFactorySwapScreen->inEnemyScreen) { case TRUE: - Swap_PrintActionString(gText_PkmnForSwap, 0, 5); + Swap_PrintActionString(gText_PkmnForSwap, 0, SWAP_WIN_ACTION_FADE); case FALSE: - Swap_PrintActionString(gText_Cancel3, 24, 5); + Swap_PrintActionString(gText_Cancel3, 24, SWAP_WIN_ACTION_FADE); break; } - CopyWindowToVram(5, 3); + CopyWindowToVram(SWAP_WIN_ACTION_FADE, 3); } static void Swap_PrintActionStrings2(void) { - FillWindowPixelBuffer(3, PIXEL_FILL(0)); + FillWindowPixelBuffer(SWAP_WIN_OPTIONS, PIXEL_FILL(0)); switch (sFactorySwapScreen->inEnemyScreen) { case TRUE: - Swap_PrintActionString(gText_PkmnForSwap, 8, 3); + Swap_PrintActionString(gText_PkmnForSwap, 8, SWAP_WIN_OPTIONS); case FALSE: - Swap_PrintActionString(gText_Cancel3, 32, 3); + Swap_PrintActionString(gText_Cancel3, 32, SWAP_WIN_OPTIONS); break; } - CopyWindowToVram(3, 3); + CopyWindowToVram(SWAP_WIN_OPTIONS, 3); } static void Swap_PrintOneActionString(u8 which) @@ -3685,33 +3847,34 @@ static void Swap_PrintOneActionString(u8 which) { case 0: if (sFactorySwapScreen->inEnemyScreen == TRUE) - Swap_PrintActionString(gText_PkmnForSwap, 8, 3); + Swap_PrintActionString(gText_PkmnForSwap, 8, SWAP_WIN_OPTIONS); break; case 1: - Swap_PrintActionString(gText_Cancel3, 32, 3); + Swap_PrintActionString(gText_Cancel3, 32, SWAP_WIN_OPTIONS); break; } - CopyWindowToVram(3, 3); + CopyWindowToVram(SWAP_WIN_OPTIONS, 3); } -static void Swap_PrintMonSpecies2(void) +// For printing the species name once its selected. Keep the current fade but don't keep fading in and out +static void Swap_PrintMonSpeciesAtFade(void) { u16 species; u8 x; u16 pal[5]; - CpuCopy16(gUnknown_08610918, pal, 8); + CpuCopy16(sSwapText_Pal, pal, 8); if (!sFactorySwapScreen->fromSummaryScreen) pal[4] = gPlttBufferFaded[228]; else - pal[4] = sFactorySwapScreen->unk24; - LoadPalette(pal, 0xF0, 0xA); + pal[4] = sFactorySwapScreen->speciesNameColorBackup; + LoadPalette(pal, 0xF0, sizeof(sSwapText_Pal)); - PutWindowTilemap(7); - FillWindowPixelBuffer(7, PIXEL_FILL(0)); - if (sFactorySwapScreen->cursorPos > 2) + PutWindowTilemap(SWAP_WIN_SPECIES_AT_FADE); + FillWindowPixelBuffer(SWAP_WIN_SPECIES_AT_FADE, PIXEL_FILL(0)); + if (sFactorySwapScreen->cursorPos >= FRONTIER_PARTY_SIZE) { - CopyWindowToVram(7, 3); + CopyWindowToVram(SWAP_WIN_SPECIES_AT_FADE, 3); } else { @@ -3722,22 +3885,23 @@ static void Swap_PrintMonSpecies2(void) species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL); StringCopy(gStringVar4, gSpeciesNames[species]); x = GetStringRightAlignXOffset(1, gStringVar4, 86); - AddTextPrinterParameterized3(7, 1, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4); - CopyWindowToVram(7, 3); + AddTextPrinterParameterized3(SWAP_WIN_SPECIES_AT_FADE, 1, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4); + CopyWindowToVram(SWAP_WIN_SPECIES_AT_FADE, 3); } } -static void Swap_PrintMonSpecies3(void) +// Reprints the species name over the faded one after a transition +static void Swap_PrintMonSpeciesForTransition(void) { u16 species; u8 x; - LoadPalette(gUnknown_08610918, 0xE0, sizeof(gUnknown_08610918)); - CpuCopy16(gPlttBufferUnfaded + 240, gPlttBufferFaded + 224, 10); + LoadPalette(sSwapText_Pal, 0xE0, sizeof(sSwapText_Pal)); + CpuCopy16(&gPlttBufferUnfaded[240], &gPlttBufferFaded[224], 10); - if (sFactorySwapScreen->cursorPos > 2) + if (sFactorySwapScreen->cursorPos >= FRONTIER_PARTY_SIZE) { - CopyWindowToVram(1, 2); + CopyWindowToVram(SWAP_WIN_SPECIES, 2); } else { @@ -3748,8 +3912,8 @@ static void Swap_PrintMonSpecies3(void) species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL); StringCopy(gStringVar4, gSpeciesNames[species]); x = GetStringRightAlignXOffset(1, gStringVar4, 86); - AddTextPrinterParameterized3(1, 1, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4); - CopyWindowToVram(1, 3); + AddTextPrinterParameterized3(SWAP_WIN_SPECIES, 1, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4); + CopyWindowToVram(SWAP_WIN_SPECIES, 3); } } @@ -3760,22 +3924,22 @@ static void Swap_PrintMonCategory(void) u8 x; u8 monId = sFactorySwapScreen->cursorPos; - FillWindowPixelBuffer(8, PIXEL_FILL(0)); - if (monId > 2) + FillWindowPixelBuffer(SWAP_WIN_MON_CATEGORY, PIXEL_FILL(0)); + if (monId >= FRONTIER_PARTY_SIZE) { - CopyWindowToVram(8, 2); + CopyWindowToVram(SWAP_WIN_MON_CATEGORY, 2); } else { - PutWindowTilemap(8); + PutWindowTilemap(SWAP_WIN_MON_CATEGORY); if (!sFactorySwapScreen->inEnemyScreen) species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, NULL); else species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL); CopyMonCategoryText(SpeciesToNationalPokedexNum(species), text); x = GetStringRightAlignXOffset(1, text, 0x76); - AddTextPrinterParameterized(8, 1, text, x, 1, 0, NULL); - CopyWindowToVram(8, 2); + AddTextPrinterParameterized(SWAP_WIN_MON_CATEGORY, 1, text, x, 1, 0, NULL); + CopyWindowToVram(SWAP_WIN_MON_CATEGORY, 2); } } @@ -3785,13 +3949,13 @@ static void Swap_InitActions(u8 id) { switch (id) { - case ACTIONS_PLAYER_SCREEN: + case SWAP_PLAYER_SCREEN: sFactorySwapScreen->inEnemyScreen = FALSE; sFactorySwapScreen->cursorPos = 0; sFactorySwapScreen->actionsCount = ARRAY_COUNT(sSwap_PlayerScreenActions); sFactorySwapScreen->actionsData = sSwap_PlayerScreenActions; break; - case ACTIONS_ENEMY_SCREEN: + case SWAP_ENEMY_SCREEN: sFactorySwapScreen->inEnemyScreen = TRUE; sFactorySwapScreen->cursorPos = 0; sFactorySwapScreen->actionsCount = ARRAY_COUNT(sSwap_EnemyScreenActions); @@ -3803,92 +3967,94 @@ static void Swap_InitActions(u8 id) static void Swap_RunMenuOptionFunc(u8 taskId) { - sSwap_CurrentTableFunc = sSwap_MenuOptionFuncs[sFactorySwapScreen->menuCursorPos]; - sSwap_CurrentTableFunc(taskId); + sSwap_CurrentOptionFunc = sSwap_MenuOptionFuncs[sFactorySwapScreen->menuCursorPos]; + sSwap_CurrentOptionFunc(taskId); } -static void sub_819F0CC(u8 taskId) +static void Swap_OptionSwap(u8 taskId) { - sub_819F3F8(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30, TRUE); + CloseMonPic(sFactorySwapScreen->monPic, &sFactorySwapScreen->monPicAnimating, TRUE); sFactorySwapScreen->playerMonId = sFactorySwapScreen->cursorPos; - sub_819EA64(3); - gTasks[taskId].data[0] = 0; - gTasks[taskId].func = sub_819D9EC; + Swap_ErasePopupMenu(SWAP_WIN_OPTIONS); + gTasks[taskId].tState = 0; + gTasks[taskId].func = Swap_Task_SwitchPartyScreen; } -static void sub_819F114(u8 taskId) +static void Swap_OptionSummary(u8 taskId) { - gTasks[taskId].data[0] = 6; - gTasks[taskId].func = Task_FromSwapScreenToSummaryScreen; + gTasks[taskId].tState = STATE_SUMMARY_FADE; + gTasks[taskId].func = Swap_Task_OpenSummaryScreen; } -static void sub_819F134(u8 taskId) +static void Swap_OptionRechoose(u8 taskId) { - sub_819F3F8(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30, TRUE); - sub_819EA64(3); - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[6] = (u32)(Task_HandleSwapScreenChooseMons) >> 0x10; - gTasks[taskId].data[7] = (u32)(Task_HandleSwapScreenChooseMons); - gTasks[taskId].data[5] = 1; - gTasks[taskId].func = sub_819D770; + CloseMonPic(sFactorySwapScreen->monPic, &sFactorySwapScreen->monPicAnimating, TRUE); + Swap_ErasePopupMenu(SWAP_WIN_OPTIONS); + gTasks[taskId].tState = 0; + gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_HandleChooseMons) >> 16; + gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_HandleChooseMons); + gTasks[taskId].tFollowUpTaskState = STATE_CHOOSE_MONS_HANDLE_INPUT; + gTasks[taskId].func = Swap_Task_ScreenInfoTransitionIn; } static void Swap_RunActionFunc(u8 taskId) { - sSwap_CurrentTableFunc = sFactorySwapScreen->actionsData[sFactorySwapScreen->cursorPos].func; - sSwap_CurrentTableFunc(taskId); + sSwap_CurrentOptionFunc = sFactorySwapScreen->actionsData[sFactorySwapScreen->cursorPos].func; + sSwap_CurrentOptionFunc(taskId); } static void Swap_ActionCancel(u8 taskId) { - gTasks[taskId].data[6] = (u32)(sub_819CC24) >> 0x10; - gTasks[taskId].data[7] = (u32)(sub_819CC24); - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[5] = 0; - gTasks[taskId].func = sub_819D588; + gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_AskQuitSwapping) >> 16; + gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_AskQuitSwapping); + gTasks[taskId].tState = 0; + gTasks[taskId].tFollowUpTaskState = 0; + gTasks[taskId].func = Swap_Task_ScreenInfoTransitionOut; } static void Swap_ActionPkmnForSwap(u8 taskId) { - gTasks[taskId].data[6] = (u32)(sub_819D9EC) >> 0x10; - gTasks[taskId].data[7] = (u32)(sub_819D9EC); - gTasks[taskId].data[5] = 0; - gTasks[taskId].data[0] = 0; - gTasks[taskId].func = sub_819D588; + gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_SwitchPartyScreen) >> 16; + gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_SwitchPartyScreen); + gTasks[taskId].tFollowUpTaskState = 0; + gTasks[taskId].tState = 0; + gTasks[taskId].func = Swap_Task_ScreenInfoTransitionOut; } static void Swap_ActionMon(u8 taskId) { if (!sFactorySwapScreen->inEnemyScreen) { - gTasks[taskId].data[6] = (u32)(Task_HandleSwapScreenMenu) >> 0x10; - gTasks[taskId].data[7] = (u32)(Task_HandleSwapScreenMenu); - gTasks[taskId].data[5] = 2; + gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_HandleMenu) >> 16; + gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_HandleMenu); + gTasks[taskId].tFollowUpTaskState = STATE_MENU_INIT; } else if (Swap_AlreadyHasSameSpecies(sFactorySwapScreen->cursorPos) == TRUE) { - sub_819F2B4(&sFactorySwapScreen->unk2C.field1, &sFactorySwapScreen->unk30, TRUE); - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[5] = 1; - gTasks[taskId].func = Task_SwapCantHaveSameMons; + OpenMonPic(&sFactorySwapScreen->monPic.bgSpriteId, &sFactorySwapScreen->monPicAnimating, TRUE); + gTasks[taskId].tState = 0; + gTasks[taskId].tFollowUpTaskState = STATE_CHOOSE_MONS_HANDLE_INPUT; + gTasks[taskId].func = Swap_TaskCantHaveSameMons; return; } else { - gTasks[taskId].data[6] = (u32)(sub_819CCD4) >> 0x10; - gTasks[taskId].data[7] = (u32)(sub_819CCD4); - gTasks[taskId].data[5] = 0; + gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_AskAcceptMon) >> 16; + gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_AskAcceptMon); + gTasks[taskId].tFollowUpTaskState = 0; } - gTasks[taskId].data[0] = 0; - gTasks[taskId].func = sub_819D588; + gTasks[taskId].tState = 0; + gTasks[taskId].func = Swap_Task_ScreenInfoTransitionOut; } -static void sub_819F2B4(u8 *arg0, bool8 *arg1, bool8 swapScreen) +#define sIsSwapScreen data[7] + +static void OpenMonPic(u8 *spriteId, bool8 *animating, bool8 swapScreen) { - *arg0 = CreateSprite(&gUnknown_08610894, 120, 64, 1); - gSprites[*arg0].callback = sub_819F600; - gSprites[*arg0].data[7] = swapScreen; - *arg1 = TRUE; + *spriteId = CreateSprite(&sSpriteTemplate_Swap_MonPicBgAnim, 120, 64, 1); + gSprites[*spriteId].callback = SpriteCB_OpenMonPic; + gSprites[*spriteId].sIsSwapScreen = swapScreen; + *animating = TRUE; } static void Swap_ShowSummaryMonSprite(void) @@ -3897,83 +4063,83 @@ static void Swap_ShowSummaryMonSprite(void) u16 species; u32 personality, otId; - sFactorySwapScreen->unk2C.field1 = CreateSprite(&gUnknown_08610894, 120, 64, 1); - StartSpriteAffineAnim(&gSprites[sFactorySwapScreen->unk2C.field1], 2); + sFactorySwapScreen->monPic.bgSpriteId = CreateSprite(&sSpriteTemplate_Swap_MonPicBgAnim, 120, 64, 1); + StartSpriteAffineAnim(&gSprites[sFactorySwapScreen->monPic.bgSpriteId], 2); mon = &gPlayerParty[sFactorySwapScreen->cursorPos]; species = GetMonData(mon, MON_DATA_SPECIES, NULL); personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); otId = GetMonData(mon, MON_DATA_OT_ID, NULL); - #ifdef BUGFIX - sFactorySwapScreen->unk2C.field0 = CreateMonPicSprite(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF); - #else - sFactorySwapScreen->unk2C.field0 = CreateMonPicSprite(species, personality, otId, TRUE, 88, 32, 15, 0xFFFF); - #endif - gSprites[sFactorySwapScreen->unk2C.field0].centerToCornerVecX = 0; - gSprites[sFactorySwapScreen->unk2C.field0].centerToCornerVecY = 0; +#ifdef BUGFIX + sFactorySwapScreen->monPic.monSpriteId = CreateMonPicSprite(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF); +#else + sFactorySwapScreen->monPic.monSpriteId = CreateMonPicSprite(species, personality, otId, TRUE, 88, 32, 15, 0xFFFF); +#endif + gSprites[sFactorySwapScreen->monPic.monSpriteId].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->monPic.monSpriteId].centerToCornerVecY = 0; - gSprites[sFactorySwapScreen->unk2C.field1].invisible = TRUE; + gSprites[sFactorySwapScreen->monPic.bgSpriteId].invisible = TRUE; } -static void sub_819F3F8(struct UnkFactoryStruct arg0, bool8 *arg1, bool8 swapScreen) +static void CloseMonPic(struct FactoryMonPic pic, bool8 *animating, bool8 swapScreen) { u8 taskId; - FreeAndDestroyMonPicSprite(arg0.field0); - taskId = CreateTask(sub_819F7B4, 1); - gTasks[taskId].data[7] = swapScreen; - gTasks[taskId].data[6] = arg0.field1; + FreeAndDestroyMonPicSprite(pic.monSpriteId); + taskId = CreateTask(Task_CloseMonPic, 1); + gTasks[taskId].tIsSwapScreen = swapScreen; + gTasks[taskId].tSpriteId = pic.bgSpriteId; gTasks[taskId].func(taskId); - *arg1 = TRUE; + *animating = TRUE; } -static void sub_819F444(struct UnkFactoryStruct arg0, bool8 *arg1) +static void HideMonPic(struct FactoryMonPic pic, bool8 *animating) { - FreeAndDestroyMonPicSprite(arg0.field0); - FreeOamMatrix(gSprites[arg0.field1].oam.matrixNum); - DestroySprite(&gSprites[arg0.field1]); - *arg1 = FALSE; + FreeAndDestroyMonPicSprite(pic.monSpriteId); + FreeOamMatrix(gSprites[pic.bgSpriteId].oam.matrixNum); + DestroySprite(&gSprites[pic.bgSpriteId]); + *animating = FALSE; } -static void Task_SwapCantHaveSameMons(u8 taskId) +static void Swap_TaskCantHaveSameMons(u8 taskId) { - if (sFactorySwapScreen->unk30 == TRUE) + if (sFactorySwapScreen->monPicAnimating == TRUE) return; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: Swap_PrintOnInfoWindow(gText_SamePkmnInPartyAlready); sFactorySwapScreen->monSwapped = FALSE; - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; break; case 1: if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); - sub_819F3F8(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30, TRUE); - gTasks[taskId].data[0]++; + CloseMonPic(sFactorySwapScreen->monPic, &sFactorySwapScreen->monPicAnimating, TRUE); + gTasks[taskId].tState++; } break; case 2: - if (sFactorySwapScreen->unk30 != TRUE) + if (sFactorySwapScreen->monPicAnimating != TRUE) { - FillWindowPixelBuffer(5, PIXEL_FILL(0)); - CopyWindowToVram(5, 2); - gTasks[taskId].data[0]++; + FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0)); + CopyWindowToVram(SWAP_WIN_ACTION_FADE, 2); + gTasks[taskId].tState++; } break; case 3: Swap_PrintOnInfoWindow(gText_SelectPkmnToAccept); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; break; case 4: - Swap_PrintMonSpecies3(); - sub_819EADC(); - sFactorySwapScreen->unk22 = TRUE; - gTasks[taskId].data[0] = gTasks[taskId].data[5]; - gTasks[taskId].func = Task_HandleSwapScreenChooseMons; + Swap_PrintMonSpeciesForTransition(); + Swap_EraseSpeciesAtFadeWindow(); + sFactorySwapScreen->fadeSpeciesNameActive = TRUE; + gTasks[taskId].tState = gTasks[taskId].tFollowUpTaskState; + gTasks[taskId].func = Swap_Task_HandleChooseMons; break; } } @@ -3983,7 +4149,7 @@ static bool8 Swap_AlreadyHasSameSpecies(u8 monId) u8 i; u16 species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL); - for (i = 0; i < 3; i++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { if (i != sFactorySwapScreen->playerMonId && (u16)(GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL)) == species) return TRUE; @@ -3991,120 +4157,126 @@ static bool8 Swap_AlreadyHasSameSpecies(u8 monId) return FALSE; } -static void sub_819F600(struct Sprite *sprite) +static void SpriteCB_OpenMonPic(struct Sprite *sprite) { u8 taskId; if (sprite->affineAnimEnded) { sprite->invisible = TRUE; - taskId = CreateTask(sub_819F69C, 1); - gTasks[taskId].data[7] = sprite->data[7]; + taskId = CreateTask(Task_OpenMonPic, 1); + gTasks[taskId].tIsSwapScreen = sprite->sIsSwapScreen; gTasks[taskId].func(taskId); sprite->callback = SpriteCallbackDummy; } } -static void sub_819F654(struct Sprite *sprite) +static void SpriteCB_CloseMonPic(struct Sprite *sprite) { if (sprite->affineAnimEnded) { FreeOamMatrix(sprite->oam.matrixNum); - if (sprite->data[7] == TRUE) - sFactorySwapScreen->unk30 = FALSE; + if (sprite->sIsSwapScreen == TRUE) + sFactorySwapScreen->monPicAnimating = FALSE; else - sub_819BE20(FALSE); + Select_SetMonPicAnimating(FALSE); DestroySprite(sprite); } } -static void sub_819F69C(u8 taskId) +static void Task_OpenMonPic(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: - task->data[3] = 88; - task->data[24] = 152; // BUG: writing outside the array's bounds. - task->data[5] = 64; - task->data[8] = 65; + // Init + task->tWinLeft = 88; + task->tWinRight = DISPLAY_WIDTH - 88; + task->tWinTop = 64; + task->tWinBottom = 65; SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[24])); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[8])); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWinLeft, task->tWinRight)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom)); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ); break; case 1: + // Show mon pic bg ShowBg(3); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_OBJ); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4)); break; case 2: - task->data[5] -= 4; - task->data[8] += 4; - if (task->data[5] <= 32 || task->data[8] >= 96) + // Animate mon pic bg + task->tWinTop -= 4; + task->tWinBottom += 4; + if (task->tWinTop <= 32 || task->tWinBottom >= 96) { - task->data[5] = 32; - task->data[8] = 96; + task->tWinTop = 32; + task->tWinBottom = 96; } - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[8])); - if (task->data[5] != 32) + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom)); + if (task->tWinTop != 32) return; break; default: DestroyTask(taskId); // UB: Should not use the task after it has been deleted. - if (gTasks[taskId].data[7] == TRUE) - Swap_ShowMonSprite(); + if (gTasks[taskId].tIsSwapScreen == TRUE) + Swap_CreateMonSprite(); else - Summary_ShowMonSprite(); + Select_CreateMonSprite(); return; } - task->data[0]++; + task->tState++; } -static void sub_819F7B4(u8 taskId) +static void Task_CloseMonPic(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { + case 0: + // Init + task->tWinLeft = 88; + task->tWinRight = DISPLAY_WIDTH - 88; + task->tWinTop = 32; + task->tWinBottom = 96; + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWinLeft, task->tWinRight)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom)); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ); + task->tState++; + break; + case 1: + // Animate bg + task->tWinTop += 4; + task->tWinBottom -= 4; + if (task->tWinTop >= 64 || task->tWinBottom <= 65) + { + task->tWinTop = 64; + task->tWinBottom = 65; + } + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom)); + if (task->tWinTop == 64) + task->tState++; + break; default: + // Hide bg HideBg(3); - gSprites[task->data[6]].data[7] = task->data[7]; - gSprites[task->data[6]].invisible = FALSE; - gSprites[task->data[6]].callback = sub_819F654; - StartSpriteAffineAnim(&gSprites[task->data[6]], 1); + gSprites[task->tSpriteId].sIsSwapScreen = task->tIsSwapScreen; + gSprites[task->tSpriteId].invisible = FALSE; + gSprites[task->tSpriteId].callback = SpriteCB_CloseMonPic; + StartSpriteAffineAnim(&gSprites[task->tSpriteId], 1); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); DestroyTask(taskId); break; - case 0: - task->data[3] = 88; - task->data[24] = 152; // BUG: writing outside the array's bounds. - task->data[5] = 32; - task->data[8] = 96; - SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[24])); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[8])); - SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ); - SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ); - task->data[0]++; - break; - case 1: - task->data[5] += 4; - task->data[8] -= 4; - if (task->data[5] >= 64 || task->data[8] <= 65) - { - task->data[5] = 64; - task->data[8] = 65; - } - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[8])); - if (task->data[5] == 64) - task->data[0]++; - break; } } -static void Swap_ShowMonSprite(void) +static void Swap_CreateMonSprite(void) { struct Pokemon *mon; u16 species; @@ -4119,9 +4291,9 @@ static void Swap_ShowMonSprite(void) personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL); otId = GetMonData(mon, MON_DATA_OT_ID, NULL); - sFactorySwapScreen->unk2C.field0 = CreateMonPicSprite(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF); - gSprites[sFactorySwapScreen->unk2C.field0].centerToCornerVecX = 0; - gSprites[sFactorySwapScreen->unk2C.field0].centerToCornerVecY = 0; + sFactorySwapScreen->monPic.monSpriteId = CreateMonPicSprite(species, otId, personality, TRUE, 88, 32, 15, 0xFFFF); + gSprites[sFactorySwapScreen->monPic.monSpriteId].centerToCornerVecX = 0; + gSprites[sFactorySwapScreen->monPic.monSpriteId].centerToCornerVecY = 0; - sFactorySwapScreen->unk30 = FALSE; + sFactorySwapScreen->monPicAnimating = FALSE; } diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index a1712a027..d09b7f018 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -988,11 +988,11 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 battlerId, bool8 loadMonSprite) position = GetBattlerPosition(battlerId); if (IsContest()) - LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites.ptr[position]); + LZDecompressVram(gSubstituteDollBackGfx, gMonSpritesGfxPtr->sprites.ptr[position]); else if (GetBattlerSide(battlerId) != B_SIDE_PLAYER) - LZDecompressVram(gSubstituteDollGfx, gMonSpritesGfxPtr->sprites.ptr[position]); + LZDecompressVram(gSubstituteDollFrontGfx, gMonSpritesGfxPtr->sprites.ptr[position]); else - LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites.ptr[position]); + LZDecompressVram(gSubstituteDollBackGfx, gMonSpritesGfxPtr->sprites.ptr[position]); for (i = 1; i < 4; i++) { diff --git a/src/battle_interface.c b/src/battle_interface.c index adbef019d..df123630c 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -1897,7 +1897,6 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon) { u8 nickname[POKEMON_NAME_LENGTH + 1]; void *ptr; - const u8 *genderTxt; u32 windowId, spriteTileNum; u8 *windowTileData; u16 species; diff --git a/src/battle_intro.c b/src/battle_intro.c index 36ff325f5..2d5e602d1 100644 --- a/src/battle_intro.c +++ b/src/battle_intro.c @@ -357,7 +357,7 @@ static void BattleIntroSlide3(u8 taskId) SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(8, 8)); SetGpuReg(REG_OFFSET_BLDY, 0); gTasks[taskId].data[4] = BLDALPHA_BLEND(8, 8); - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) { gTasks[taskId].data[2] = 16; gTasks[taskId].data[0]++; diff --git a/src/battle_main.c b/src/battle_main.c index 9b79a4fe6..16ae72c28 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -572,13 +572,9 @@ const u8 * const gStatusConditionStringsTable[7][2] = {gStatusConditionString_LoveJpn, gText_Love} }; -static const u8 sPkblToEscapeFactor[][3] = {{0, 0, 0}, {3, 5, 0}, {2, 3, 0}, {1, 2, 0}, {1, 1, 0}}; -static const u8 sGoNearCounterToCatchFactor[] = {4, 3, 2, 1}; -static const u8 sGoNearCounterToEscapeFactor[] = {4, 4, 4, 4}; - +// code void CB2_InitBattle(void) { - u32 i; MoveSaveBlocks_ResetHeap(); AllocateBattleResources(); AllocateBattleSpritesData(); @@ -1112,7 +1108,7 @@ static void CB2_HandleStartBattle(void) SetMainCallback2(BattleMainCB2); if (gBattleTypeFlags & BATTLE_TYPE_LINK) { - gBattleTypeFlags |= BATTLE_TYPE_20; + gBattleTypeFlags |= BATTLE_TYPE_LINK_IN_BATTLE; } } break; @@ -1366,7 +1362,7 @@ static void CB2_HandleStartMultiPartnerBattle(void) SetMainCallback2(BattleMainCB2); if (gBattleTypeFlags & BATTLE_TYPE_LINK) { - gBattleTypeFlags |= BATTLE_TYPE_20; + gBattleTypeFlags |= BATTLE_TYPE_LINK_IN_BATTLE; } } break; @@ -1818,7 +1814,7 @@ static void CB2_HandleStartMultiBattle(void) if (gBattleTypeFlags & BATTLE_TYPE_LINK) { gTrainerBattleOpponent_A = TRAINER_LINK_OPPONENT; - gBattleTypeFlags |= BATTLE_TYPE_20; + gBattleTypeFlags |= BATTLE_TYPE_LINK_IN_BATTLE; } } break; @@ -1971,7 +1967,7 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir nameHash += gSpeciesNames[partyData[i].species][j]; personalityValue += nameHash << 8; - fixedIV = partyData[i].iv * 31 / 255; + fixedIV = partyData[i].iv * MAX_PER_STAT_IVS / 255; CreateMon(&party[i], partyData[i].species, partyData[i].lvl, fixedIV, TRUE, personalityValue, OT_ID_RANDOM_NO_SHINY, 0); break; } @@ -1983,7 +1979,7 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir nameHash += gSpeciesNames[partyData[i].species][j]; personalityValue += nameHash << 8; - fixedIV = partyData[i].iv * 31 / 255; + fixedIV = partyData[i].iv * MAX_PER_STAT_IVS / 255; CreateMon(&party[i], partyData[i].species, partyData[i].lvl, fixedIV, TRUE, personalityValue, OT_ID_RANDOM_NO_SHINY, 0); for (j = 0; j < MAX_MON_MOVES; j++) @@ -2001,7 +1997,7 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir nameHash += gSpeciesNames[partyData[i].species][j]; personalityValue += nameHash << 8; - fixedIV = partyData[i].iv * 31 / 255; + fixedIV = partyData[i].iv * MAX_PER_STAT_IVS / 255; CreateMon(&party[i], partyData[i].species, partyData[i].lvl, fixedIV, TRUE, personalityValue, OT_ID_RANDOM_NO_SHINY, 0); SetMonData(&party[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem); @@ -2015,7 +2011,7 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir nameHash += gSpeciesNames[partyData[i].species][j]; personalityValue += nameHash << 8; - fixedIV = partyData[i].iv * 31 / 255; + fixedIV = partyData[i].iv * MAX_PER_STAT_IVS / 255; CreateMon(&party[i], partyData[i].species, partyData[i].lvl, fixedIV, TRUE, personalityValue, OT_ID_RANDOM_NO_SHINY, 0); SetMonData(&party[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem); @@ -2182,7 +2178,7 @@ void sub_8038D64(void) SetHBlankCallback(NULL); SetVBlankCallback(NULL); - gBattleTypeFlags &= ~(BATTLE_TYPE_20); + gBattleTypeFlags &= ~(BATTLE_TYPE_LINK_IN_BATTLE); if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) { @@ -2798,7 +2794,7 @@ void SpriteCb_OpponentMonFromBall(struct Sprite *sprite) { if (sprite->affineAnimEnded) { - if (!(gHitMarker & HITMARKER_NO_ANIMATIONS) || gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (!(gHitMarker & HITMARKER_NO_ANIMATIONS) || gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) { if (HasTwoFramesAnimation(sprite->sSpeciesId)) StartSpriteAnim(sprite, 1); @@ -3036,7 +3032,7 @@ static void BattleStartClearSetData(void) if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && gSaveBlock2Ptr->optionsBattleSceneOff == TRUE) gHitMarker |= HITMARKER_NO_ANIMATIONS; } - else if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) && GetBattleSceneInRecordedBattle()) + else if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) && GetBattleSceneInRecordedBattle()) gHitMarker |= HITMARKER_NO_ANIMATIONS; gBattleScripting.battleStyle = gSaveBlock2Ptr->optionsBattleStyle; @@ -3391,7 +3387,7 @@ static void BattleIntroDrawTrainersOrMonsSprites(void) && !(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK - | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_TRAINER_HILL))) { HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBattler].species), FLAG_SET_SEEN, gBattleMons[gActiveBattler].personality); @@ -3404,7 +3400,7 @@ static void BattleIntroDrawTrainersOrMonsSprites(void) if (!(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK - | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_TRAINER_HILL))) { HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBattler].species), FLAG_SET_SEEN, gBattleMons[gActiveBattler].personality); @@ -3539,9 +3535,9 @@ static void BattleIntroPrintOpponentSendsOut(void) if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) position = B_POSITION_OPPONENT_LEFT; - else if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + else if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) { - if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER) position = B_POSITION_OPPONENT_LEFT; else position = B_POSITION_PLAYER_LEFT; @@ -3559,9 +3555,9 @@ static void BattleIntroOpponent2SendsOutMonAnimation(void) if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) position = B_POSITION_OPPONENT_RIGHT; - else if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + else if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) { - if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER) position = B_POSITION_OPPONENT_RIGHT; else position = B_POSITION_PLAYER_RIGHT; @@ -3587,9 +3583,9 @@ static void BattleIntroOpponent1SendsOutMonAnimation(void) if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { - if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) { - if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER) position = B_POSITION_OPPONENT_LEFT; else position = B_POSITION_PLAYER_LEFT; @@ -3630,7 +3626,7 @@ static void BattleIntroRecordMonsToDex(void) && !(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK - | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_TRAINER_HILL))) { HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBattler].species), FLAG_SET_SEEN, gBattleMons[gActiveBattler].personality); @@ -3654,9 +3650,9 @@ static void BattleIntroPrintPlayerSendsOut(void) if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) position = B_POSITION_PLAYER_LEFT; - else if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + else if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) { - if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER) position = B_POSITION_PLAYER_LEFT; else position = B_POSITION_OPPONENT_LEFT; @@ -3677,9 +3673,9 @@ static void BattleIntroPlayer2SendsOutMonAnimation(void) if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) position = B_POSITION_PLAYER_RIGHT; - else if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + else if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) { - if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER) position = B_POSITION_PLAYER_RIGHT; else position = B_POSITION_OPPONENT_RIGHT; @@ -3709,9 +3705,9 @@ static void BattleIntroPlayer1SendsOutMonAnimation(void) if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) position = B_POSITION_PLAYER_LEFT; - else if (gBattleTypeFlags & BATTLE_TYPE_x2000000) + else if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) { - if (gBattleTypeFlags & BATTLE_TYPE_x80000000) + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER) position = B_POSITION_PLAYER_LEFT; else position = B_POSITION_OPPONENT_LEFT; @@ -4150,7 +4146,7 @@ static void HandleTurnActionSelectionState(void) if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER_NO_PYRAMID | BATTLE_TYPE_EREADER_TRAINER - | BATTLE_TYPE_x2000000)) + | BATTLE_TYPE_RECORDED_LINK)) { RecordedBattle_ClearBattlerAction(gActiveBattler, 1); gSelectionBattleScripts[gActiveBattler] = BattleScript_ActionSelectionItemsCantBeUsed; @@ -4258,7 +4254,7 @@ static void HandleTurnActionSelectionState(void) return; } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER - && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) && gBattleBufferB[gActiveBattler][1] == B_ACTION_RUN) { BattleScriptExecute(BattleScript_PrintCantRunFromTrainer); @@ -4569,7 +4565,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) } // badge boost - if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_FRONTIER)) + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_FRONTIER)) && FlagGet(FLAG_BADGE03_GET) && GetBattlerSide(battler1) == B_SIDE_PLAYER) { @@ -4603,7 +4599,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) } // badge boost - if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_FRONTIER)) + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_FRONTIER)) && FlagGet(FLAG_BADGE03_GET) && GetBattlerSide(battler2) == B_SIDE_PLAYER) { @@ -4887,7 +4883,7 @@ static void HandleEndTurn_BattleWon(void) { gCurrentActionFuncId = 0; - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) { gSpecialVar_Result = gBattleOutcome; gBattleTextBuff1[0] = gBattleOutcome; @@ -4945,7 +4941,7 @@ static void HandleEndTurn_BattleLost(void) { gCurrentActionFuncId = 0; - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) { if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) { @@ -5026,7 +5022,7 @@ static void HandleEndTurn_FinishBattle(void) if (gCurrentActionFuncId == B_ACTION_TRY_FINISH || gCurrentActionFuncId == B_ACTION_FINISHED) { if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK - | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_EREADER_TRAINER @@ -5053,7 +5049,7 @@ static void HandleEndTurn_FinishBattle(void) } if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK - | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI diff --git a/src/battle_message.c b/src/battle_message.c index 727c7080c..247f9688a 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -180,7 +180,7 @@ static const u8 sText_PkmnStayedAwakeUsing[] = _("{B_DEF_NAME_WITH_PREFIX} staye static const u8 sText_PkmnStoringEnergy[] = _("{B_ATK_NAME_WITH_PREFIX} is storing\nenergy!"); static const u8 sText_PkmnUnleashedEnergy[] = _("{B_ATK_NAME_WITH_PREFIX} unleashed\nenergy!"); static const u8 sText_PkmnFatigueConfusion[] = _("{B_ATK_NAME_WITH_PREFIX} became\nconfused due to fatigue!"); -static const u8 sText_PkmnPickedUpItem[] = _("{B_PLAYER_NAME} picked up\n¥{B_BUFF1}!\p"); +static const u8 sText_PlayerPickedUpMoney[] = _("{B_PLAYER_NAME} picked up\n¥{B_BUFF1}!\p"); static const u8 sText_PkmnUnaffected[] = _("{B_DEF_NAME_WITH_PREFIX} is\nunaffected!"); static const u8 sText_PkmnTransformedInto[] = _("{B_ATK_NAME_WITH_PREFIX} transformed\ninto {B_BUFF1}!"); static const u8 sText_PkmnMadeSubstitute[] = _("{B_ATK_NAME_WITH_PREFIX} made\na SUBSTITUTE!"); @@ -340,9 +340,9 @@ static const u8 sText_ButItFailed[] = _("But it failed!"); static const u8 sText_ItHurtConfusion[] = _("It hurt itself in its\nconfusion!"); static const u8 sText_MirrorMoveFailed[] = _("The MIRROR MOVE failed!"); static const u8 sText_StartedToRain[] = _("It started to rain!"); -static const u8 sText_DownpourStarted[] = _("A downpour started!"); +static const u8 sText_DownpourStarted[] = _("A downpour started!"); // corresponds to DownpourText in pokegold and pokecrystal and is used by Rain Dance in GSC static const u8 sText_RainContinues[] = _("Rain continues to fall."); -static const u8 sText_DownpourContinues[] = _("The downpour continues."); +static const u8 sText_DownpourContinues[] = _("The downpour continues."); // unused static const u8 sText_RainStopped[] = _("The rain stopped."); static const u8 sText_SandstormBrewed[] = _("A sandstorm brewed!"); static const u8 sText_SandstormRages[] = _("The sandstorm rages."); @@ -632,7 +632,7 @@ const u8 * const gBattleStringsTable[BATTLESTRINGS_COUNT] = [STRINGID_PKMNSTORINGENERGY - 12] = sText_PkmnStoringEnergy, [STRINGID_PKMNUNLEASHEDENERGY - 12] = sText_PkmnUnleashedEnergy, [STRINGID_PKMNFATIGUECONFUSION - 12] = sText_PkmnFatigueConfusion, - [STRINGID_PKMNPICKEDUPITEM - 12] = sText_PkmnPickedUpItem, + [STRINGID_PLAYERPICKEDUPMONEY - 12] = sText_PlayerPickedUpMoney, [STRINGID_PKMNUNAFFECTED - 12] = sText_PkmnUnaffected, [STRINGID_PKMNTRANSFORMEDINTO - 12] = sText_PkmnTransformedInto, [STRINGID_PKMNMADESUBSTITUTE - 12] = sText_PkmnMadeSubstitute, @@ -2009,9 +2009,9 @@ void BufferStringBattle(u16 stringID) case STRINGID_INTROMSG: // first battle msg if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) { - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) { - if (gBattleTypeFlags & BATTLE_TYPE_x800000) + if (gBattleTypeFlags & BATTLE_TYPE_TOWER_LINK_MULTI) { stringPtr = sText_TwoTrainersWantToBattle; } @@ -2079,18 +2079,18 @@ void BufferStringBattle(u16 stringID) { if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) stringPtr = sText_TwoTrainersSentPkmn; - else if (gBattleTypeFlags & BATTLE_TYPE_x800000) + else if (gBattleTypeFlags & BATTLE_TYPE_TOWER_LINK_MULTI) stringPtr = sText_TwoTrainersSentPkmn; else if (gBattleTypeFlags & BATTLE_TYPE_MULTI) stringPtr = sText_TwoLinkTrainersSentOutPkmn; - else if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + else if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) stringPtr = sText_LinkTrainerSentOutTwoPkmn; else stringPtr = sText_Trainer1SentOutTwoPkmn; } else { - if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))) + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK))) stringPtr = sText_Trainer1SentOutPkmn; else if (gTrainerBattleOpponent_A == TRAINER_UNION_ROOM) stringPtr = sText_Trainer1SentOutPkmn; @@ -2113,7 +2113,7 @@ void BufferStringBattle(u16 stringID) } else { - if (gTrainerBattleOpponent_A == TRAINER_LINK_OPPONENT || gBattleTypeFlags & BATTLE_TYPE_x2000000) + if (gTrainerBattleOpponent_A == TRAINER_LINK_OPPONENT || gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI) stringPtr = sText_LinkTrainer2WithdrewPkmn; @@ -2140,9 +2140,9 @@ void BufferStringBattle(u16 stringID) } else { - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) { - if (gBattleTypeFlags & BATTLE_TYPE_x800000) + if (gBattleTypeFlags & BATTLE_TYPE_TOWER_LINK_MULTI) { if (gBattleScripting.battler == 1) stringPtr = sText_Trainer1SentOutPkmn2; @@ -2210,7 +2210,7 @@ void BufferStringBattle(u16 stringID) switch (gBattleTextBuff1[0]) { case B_OUTCOME_WON: - if (gBattleTypeFlags & BATTLE_TYPE_x800000) + if (gBattleTypeFlags & BATTLE_TYPE_TOWER_LINK_MULTI) stringPtr = sText_TwoInGameTrainersDefeated; else stringPtr = sText_TwoLinkTrainersDefeated; @@ -2336,8 +2336,8 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) u8 multiplayerId; s32 i; - if (gBattleTypeFlags & BATTLE_TYPE_x2000000) - multiplayerId = gUnknown_0203C7B4; + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) + multiplayerId = gRecordedBattleMultiplayerId; else multiplayerId = GetMultiplayerId(); @@ -2477,7 +2477,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) toCpy = gMoveNames[gBattleMsgDataPtr->originallyUsedMove]; break; case B_TXT_LAST_ITEM: // last used item - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) { if (gLastUsedItem == ITEM_ENIGMA_BERRY) { @@ -2858,7 +2858,7 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst) break; case B_BUFF_ITEM: // item name hword = T1_READ_16(&src[srcID + 1]); - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) { if (hword == ITEM_ENIGMA_BERRY) { @@ -3018,7 +3018,7 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId) if (windowId == 0 || windowId == 0x16) { - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) speed = 1; else if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) speed = sRecordedBattleTextSpeeds[GetTextSpeedInRecordedBattle()]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 22f6bf503..ffae4f526 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2713,7 +2713,7 @@ void SetMoveEffect(bool8 primary, u8 certain) (BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK - | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_SECRET_BASE))) { gBattlescriptCurrInstr++; @@ -2722,7 +2722,7 @@ void SetMoveEffect(bool8 primary, u8 certain) (BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK - | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_SECRET_BASE)) && (gWishFutureKnock.knockedOffMons[side] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]])) { @@ -3228,7 +3228,7 @@ static void Cmd_getexp(void) case 0: // check if should receive exp at all if (GetBattlerSide(gBattlerFainted) != B_SIDE_OPPONENT || (gBattleTypeFlags & (BATTLE_TYPE_LINK - | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_TRAINER_HILL | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_SAFARI @@ -3533,7 +3533,7 @@ static void Cmd_unknown_24(void) if (HP_count == 0) gBattleOutcome |= B_OUTCOME_WON; - if (gBattleOutcome == 0 && (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))) + if (gBattleOutcome == 0 && (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK))) { s32 foundPlayer = 0; s32 foundOpponent; @@ -4634,7 +4634,7 @@ static void Cmd_switchinanim(void) if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_EREADER_TRAINER - | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_TRAINER_HILL | BATTLE_TYPE_FRONTIER))) HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBattler].species), FLAG_SET_SEEN, gBattleMons[gActiveBattler].personality); @@ -4691,7 +4691,7 @@ static void Cmd_jumpifcantswitch(void) } else if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if (gBattleTypeFlags & BATTLE_TYPE_x800000) + if (gBattleTypeFlags & BATTLE_TYPE_TOWER_LINK_MULTI) { if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { @@ -7137,7 +7137,7 @@ static void Cmd_forcerandomswitch(void) party = gEnemyParty; if ((gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER && gBattleTypeFlags & BATTLE_TYPE_LINK) - || (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER && gBattleTypeFlags & BATTLE_TYPE_x2000000) + || (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER && gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) || (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)) { if ((gBattlerTarget & BIT_FLANK) != 0) @@ -7156,7 +7156,7 @@ static void Cmd_forcerandomswitch(void) battler1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK]; } else if ((gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) - || (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_x2000000)) + || (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK)) { if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(gBattlerTarget)) == 1) { @@ -7256,8 +7256,8 @@ static void Cmd_forcerandomswitch(void) if ((gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) || (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI) - || (gBattleTypeFlags & BATTLE_TYPE_x2000000 && gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) - || (gBattleTypeFlags & BATTLE_TYPE_x2000000 && gBattleTypeFlags & BATTLE_TYPE_MULTI)) + || (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) + || (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI)) { SwitchPartyOrderLinkMulti(gBattlerTarget, i, 0); SwitchPartyOrderLinkMulti(gBattlerTarget ^ BIT_FLANK, i, 1); @@ -7337,7 +7337,7 @@ static void Cmd_tryconversiontypechange(void) // randomly changes user's type to static void Cmd_givepaydaymoney(void) { - if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) && gPaydayMoney != 0) + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) && gPaydayMoney != 0) { u32 bonusMoney = gPaydayMoney * gBattleStruct->moneyMultiplier; AddMoney(&gSaveBlock1Ptr->money, bonusMoney); @@ -9044,7 +9044,7 @@ static void Cmd_tryswapitems(void) // trick | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_SECRET_BASE - | BATTLE_TYPE_x2000000)))) + | BATTLE_TYPE_RECORDED_LINK)))) { gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } @@ -9058,7 +9058,7 @@ static void Cmd_tryswapitems(void) // trick | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_SECRET_BASE - | BATTLE_TYPE_x2000000)) + | BATTLE_TYPE_RECORDED_LINK)) && (gWishFutureKnock.knockedOffMons[sideAttacker] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]] || gWishFutureKnock.knockedOffMons[sideTarget] & gBitTable[gBattlerPartyIndexes[gBattlerTarget]])) { diff --git a/src/battle_setup.c b/src/battle_setup.c index 40b5993f0..0a5e7e8b4 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -607,7 +607,7 @@ static void CB2_EndWildBattle(void) else { SetMainCallback2(CB2_ReturnToField); - gFieldCallback = sub_80AF6F0; + gFieldCallback = FieldCB_ReturnToFieldNoScriptCheckMusic; } } diff --git a/src/battle_tower.c b/src/battle_tower.c index ee75feeb4..51d695f9b 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -775,7 +775,7 @@ struct { { .species = SPECIES_METANG, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .level = 42, .nature = NATURE_BRAVE, .evs = {0, 252, 252, 0, 6, 0}, @@ -783,7 +783,7 @@ struct }, { .species = SPECIES_SKARMORY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .level = 43, .nature = NATURE_IMPISH, .evs = {252, 0, 0, 0, 6, 252}, @@ -791,7 +791,7 @@ struct }, { .species = SPECIES_AGGRON, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .level = 44, .nature = NATURE_ADAMANT, .evs = {0, 252, 0, 0, 252, 6}, @@ -1854,7 +1854,7 @@ static void FillFactoryFrontierTrainerParty(u16 trainerId, u8 firstMonId) } else { - fixedIV = 31; + fixedIV = MAX_PER_STAT_IVS; } level = SetFacilityPtrsGetLevel(); @@ -2024,7 +2024,7 @@ void DoSpecialTrainerBattle(void) gBattleTypeFlags |= BATTLE_TYPE_DOUBLE | BATTLE_TYPE_INGAME_PARTNER | BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS; break; case FRONTIER_MODE_LINK_MULTIS: - gBattleTypeFlags |= BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_MULTI | BATTLE_TYPE_x800000; + gBattleTypeFlags |= BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_MULTI | BATTLE_TYPE_TOWER_LINK_MULTI; FillFrontierTrainersParties(FRONTIER_MULTI_PARTY_SIZE); break; } @@ -3295,7 +3295,7 @@ static u8 GetFrontierTrainerFixedIvs(u16 trainerId) else if (trainerId <= FRONTIER_TRAINER_TESS) // 200 - 219 fixedIv = 21; else // 220+ (- 299) - fixedIv = 31; + fixedIv = MAX_PER_STAT_IVS; return fixedIv; } @@ -3521,7 +3521,7 @@ bool32 ValidateBattleTowerRecord(u8 recordId) // unused void TrySetLinkBattleTowerEnemyPartyLevel(void) { - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) { s32 i; u8 enemyLevel = SetFacilityPtrsGetLevel(); diff --git a/src/battle_tv.c b/src/battle_tv.c index 7e311fdab..8c8ea90ab 100644 --- a/src/battle_tv.c +++ b/src/battle_tv.c @@ -8,15 +8,68 @@ #include "constants/moves.h" #include "battle_message.h" #include "tv.h" +#include "constants/battle_move_effects.h" // this file's functions -static bool8 sub_817E0B8(u16 stringId); +static bool8 IsNotSpecialBattleString(u16 stringId); static void AddMovePoints(u8 caseId, u16 arg1, u8 arg2, u8 arg3); static void TrySetBattleSeminarShow(void); static void AddPointsOnFainting(bool8 targetFainted); static void AddPointsBasedOnWeather(u16 weatherFlags, u16 moveId, u8 moveSlot); static bool8 ShouldCalculateDamage(u16 moveId, s32 *dmg, u16 *powerOverride); +#define TABLE_END ((u16)-1) + +enum { + PTS_MOVE_EFFECT, + PTS_EFFECTIVENESS, + PTS_SET_UP, // Broadly. Used by Wish, Future Sight, Ingrain, etc. + PTS_RAIN, + PTS_SUN, + PTS_SANDSTORM, + PTS_HAIL, + PTS_ELECTRIC, + PTS_STATUS_DMG, + PTS_STATUS, + PTS_SPIKES, + PTS_WATER_SPORT, + PTS_MUD_SPORT, + PTS_REFLECT, + PTS_LIGHT_SCREEN, + PTS_SAFEGUARD, + PTS_MIST, + PTS_BREAK_WALL, + PTS_CRITICAL_HIT, + PTS_FAINT, + PTS_FAINT_SET_UP, + PTS_FLINCHED, + PTS_STAT_INCREASE_1, + PTS_STAT_INCREASE_2, + PTS_STAT_DECREASE_SELF, + PTS_STAT_DECREASE_1, + PTS_STAT_DECREASE_2, + PTS_STAT_INCREASE_NOT_SELF, +}; + +enum { + FNT_NONE, + FNT_CURSE, + FNT_LEECH_SEED, + FNT_POISON, + FNT_BURN, + FNT_NIGHTMARE, + FNT_WRAP, + FNT_SPIKES, + FNT_FUTURE_SIGHT, + FNT_DOOM_DESIRE, + FNT_PERISH_SONG, + FNT_DESTINY_BOND, + FNT_CONFUSION, + FNT_EXPLOSION, + FNT_RECOIL, + FNT_OTHER, +}; + // const rom data static const u16 sVariableDmgMoves[] = { @@ -26,180 +79,462 @@ static const u16 sVariableDmgMoves[] = MOVE_WATER_SPOUT, MOVE_DREAM_EATER, MOVE_WEATHER_BALL, MOVE_SNORE, MOVE_PAIN_SPLIT, MOVE_GUILLOTINE, MOVE_FRUSTRATION, MOVE_RETURN, MOVE_ENDEAVOR, - MOVE_PRESENT, MOVE_REVENGE, 0xFFFF, + MOVE_PRESENT, MOVE_REVENGE, TABLE_END, // those are handled by the function itself - MOVE_MAGNITUDE, MOVE_PSYWAVE, 0xFFFF + MOVE_MAGNITUDE, MOVE_PSYWAVE, TABLE_END }; -static const u16 sUnknown_0860A4E0[] = +static const u16 sPoints_MoveEffect[NUM_BATTLE_MOVE_EFFECTS] = { - 0x0001, 0x0001, 0x0001, 0x0004, 0x0001, 0x0001, 0x0001, 0x0000, 0x0005, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, - 0x0001, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0005, 0x0005, 0x0004, 0x0005, 0x0001, 0x0003, 0x0001, - 0x0003, 0x0005, 0x0001, 0x0007, 0x0001, 0x0007, 0x0007, 0x0001, 0x0005, 0x0002, 0x0004, 0x0001, 0x0001, 0x0001, 0x0005, 0x0001, - 0x0002, 0x0004, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, - 0x0001, 0x0007, 0x0004, 0x0004, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0004, 0x0001, 0x0001, 0x0001, 0x0004, - 0x0005, 0x0002, 0x0004, 0x0001, 0x0004, 0x0001, 0x0007, 0x0002, 0x0001, 0x0005, 0x0007, 0x0003, 0x0003, 0x0004, 0x0003, 0x0003, - 0x0003, 0x0003, 0x0003, 0x0002, 0x0004, 0x0001, 0x0005, 0x0001, 0x0001, 0x0004, 0x0005, 0x0003, 0x0001, 0x0002, 0x0001, 0x0005, - 0x0004, 0x0003, 0x0006, 0x0004, 0x0003, 0x0003, 0x0003, 0x0002, 0x0004, 0x0001, 0x0001, 0x0001, 0x0005, 0x0001, 0x0001, 0x0007, - 0x0002, 0x0002, 0x0001, 0x0001, 0x0004, 0x0004, 0x0004, 0x0001, 0x0004, 0x0004, 0x0001, 0x0001, 0x0001, 0x0001, 0x0007, 0x0007, - 0x0006, 0x0003, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0002, 0x0003, 0x0001, 0x0001, 0x0004, 0x0004, - 0x0003, 0x0003, 0x0003, 0x0001, 0x0004, 0x0007, 0x0007, 0x0005, 0x0007, 0x0001, 0x0007, 0x0001, 0x0005, 0x0000, 0x0004, 0x0004, - 0x0004, 0x0004, 0x0004, 0x0002, 0x0002, 0x0006, 0x0003, 0x0006, 0x0004, 0x0004, 0x0002, 0x0005, 0x0002, 0x0001, 0x0001, 0x0006, - 0x0006, 0x0006, 0x0001, 0x0001, 0x0001, 0x0001, 0x0002, 0x0006, 0x0001, 0x0004, 0x0001, 0x0001, 0x0003, 0x0001, 0x0001, 0x0001, - 0x0001, 0x0001, 0x0004, 0x0001, 0x0001, 0x0003 + [EFFECT_HIT] = 1, + [EFFECT_SLEEP] = 1, + [EFFECT_POISON_HIT] = 1, + [EFFECT_ABSORB] = 4, + [EFFECT_BURN_HIT] = 1, + [EFFECT_FREEZE_HIT] = 1, + [EFFECT_PARALYZE_HIT] = 1, + [EFFECT_EXPLOSION] = 0, + [EFFECT_DREAM_EATER] = 5, + [EFFECT_MIRROR_MOVE] = 1, + [EFFECT_ATTACK_UP] = 1, + [EFFECT_DEFENSE_UP] = 1, + [EFFECT_SPEED_UP] = 1, + [EFFECT_SPECIAL_ATTACK_UP] = 1, + [EFFECT_SPECIAL_DEFENSE_UP] = 1, + [EFFECT_ACCURACY_UP] = 1, + [EFFECT_EVASION_UP] = 1, + [EFFECT_ALWAYS_HIT] = 2, + [EFFECT_ATTACK_DOWN] = 1, + [EFFECT_DEFENSE_DOWN] = 1, + [EFFECT_SPEED_DOWN] = 1, + [EFFECT_SPECIAL_ATTACK_DOWN] = 1, + [EFFECT_SPECIAL_DEFENSE_DOWN] = 1, + [EFFECT_ACCURACY_DOWN] = 1, + [EFFECT_EVASION_DOWN] = 1, + [EFFECT_HAZE] = 5, + [EFFECT_BIDE] = 5, + [EFFECT_RAMPAGE] = 4, + [EFFECT_ROAR] = 5, + [EFFECT_MULTI_HIT] = 1, + [EFFECT_CONVERSION] = 3, + [EFFECT_FLINCH_HIT] = 1, + [EFFECT_RESTORE_HP] = 3, + [EFFECT_TOXIC] = 5, + [EFFECT_PAY_DAY] = 1, + [EFFECT_LIGHT_SCREEN] = 7, + [EFFECT_TRI_ATTACK] = 1, + [EFFECT_REST] = 7, + [EFFECT_OHKO] = 7, + [EFFECT_RAZOR_WIND] = 1, + [EFFECT_SUPER_FANG] = 5, + [EFFECT_DRAGON_RAGE] = 2, + [EFFECT_TRAP] = 4, + [EFFECT_HIGH_CRITICAL] = 1, + [EFFECT_DOUBLE_HIT] = 1, + [EFFECT_RECOIL_IF_MISS] = 1, + [EFFECT_MIST] = 5, + [EFFECT_FOCUS_ENERGY] = 1, + [EFFECT_RECOIL] = 2, + [EFFECT_CONFUSE] = 4, + [EFFECT_ATTACK_UP_2] = 1, + [EFFECT_DEFENSE_UP_2] = 1, + [EFFECT_SPEED_UP_2] = 1, + [EFFECT_SPECIAL_ATTACK_UP_2] = 1, + [EFFECT_SPECIAL_DEFENSE_UP_2] = 1, + [EFFECT_ACCURACY_UP_2] = 1, + [EFFECT_EVASION_UP_2] = 1, + [EFFECT_TRANSFORM] = 0, + [EFFECT_ATTACK_DOWN_2] = 1, + [EFFECT_DEFENSE_DOWN_2] = 1, + [EFFECT_SPEED_DOWN_2] = 1, + [EFFECT_SPECIAL_ATTACK_DOWN_2] = 1, + [EFFECT_SPECIAL_DEFENSE_DOWN_2] = 1, + [EFFECT_ACCURACY_DOWN_2] = 1, + [EFFECT_EVASION_DOWN_2] = 1, + [EFFECT_REFLECT] = 7, + [EFFECT_POISON] = 4, + [EFFECT_PARALYZE] = 4, + [EFFECT_ATTACK_DOWN_HIT] = 1, + [EFFECT_DEFENSE_DOWN_HIT] = 1, + [EFFECT_SPEED_DOWN_HIT] = 1, + [EFFECT_SPECIAL_ATTACK_DOWN_HIT] = 1, + [EFFECT_SPECIAL_DEFENSE_DOWN_HIT] = 1, + [EFFECT_ACCURACY_DOWN_HIT] = 1, + [EFFECT_EVASION_DOWN_HIT] = 1, + [EFFECT_SKY_ATTACK] = 4, + [EFFECT_CONFUSE_HIT] = 1, + [EFFECT_TWINEEDLE] = 1, + [EFFECT_VITAL_THROW] = 1, + [EFFECT_SUBSTITUTE] = 4, + [EFFECT_RECHARGE] = 5, + [EFFECT_RAGE] = 2, + [EFFECT_MIMIC] = 4, + [EFFECT_METRONOME] = 1, + [EFFECT_LEECH_SEED] = 4, + [EFFECT_SPLASH] = 1, + [EFFECT_DISABLE] = 7, + [EFFECT_LEVEL_DAMAGE] = 2, + [EFFECT_PSYWAVE] = 1, + [EFFECT_COUNTER] = 5, + [EFFECT_ENCORE] = 7, + [EFFECT_PAIN_SPLIT] = 3, + [EFFECT_SNORE] = 3, + [EFFECT_CONVERSION_2] = 4, + [EFFECT_LOCK_ON] = 3, + [EFFECT_SKETCH] = 3, + [EFFECT_UNUSED_60] = 3, + [EFFECT_SLEEP_TALK] = 3, + [EFFECT_DESTINY_BOND] = 3, + [EFFECT_FLAIL] = 2, + [EFFECT_SPITE] = 4, + [EFFECT_FALSE_SWIPE] = 1, + [EFFECT_HEAL_BELL] = 5, + [EFFECT_QUICK_ATTACK] = 1, + [EFFECT_TRIPLE_KICK] = 1, + [EFFECT_THIEF] = 4, + [EFFECT_MEAN_LOOK] = 5, + [EFFECT_NIGHTMARE] = 3, + [EFFECT_MINIMIZE] = 1, + [EFFECT_CURSE] = 2, + [EFFECT_UNUSED_6E] = 1, + [EFFECT_PROTECT] = 5, + [EFFECT_SPIKES] = 4, + [EFFECT_FORESIGHT] = 3, + [EFFECT_PERISH_SONG] = 6, + [EFFECT_SANDSTORM] = 4, + [EFFECT_ENDURE] = 3, + [EFFECT_ROLLOUT] = 3, + [EFFECT_SWAGGER] = 3, + [EFFECT_FURY_CUTTER] = 2, + [EFFECT_ATTRACT] = 4, + [EFFECT_RETURN] = 1, + [EFFECT_PRESENT] = 1, + [EFFECT_FRUSTRATION] = 1, + [EFFECT_SAFEGUARD] = 5, + [EFFECT_THAW_HIT] = 1, + [EFFECT_MAGNITUDE] = 1, + [EFFECT_BATON_PASS] = 7, + [EFFECT_PURSUIT] = 2, + [EFFECT_RAPID_SPIN] = 2, + [EFFECT_SONICBOOM] = 1, + [EFFECT_UNUSED_83] = 1, + [EFFECT_MORNING_SUN] = 4, + [EFFECT_SYNTHESIS] = 4, + [EFFECT_MOONLIGHT] = 4, + [EFFECT_HIDDEN_POWER] = 1, + [EFFECT_RAIN_DANCE] = 4, + [EFFECT_SUNNY_DAY] = 4, + [EFFECT_DEFENSE_UP_HIT] = 1, + [EFFECT_ATTACK_UP_HIT] = 1, + [EFFECT_ALL_STATS_UP_HIT] = 1, + [EFFECT_UNUSED_8D] = 1, + [EFFECT_BELLY_DRUM] = 7, + [EFFECT_PSYCH_UP] = 7, + [EFFECT_MIRROR_COAT] = 6, + [EFFECT_SKULL_BASH] = 3, + [EFFECT_TWISTER] = 1, + [EFFECT_EARTHQUAKE] = 1, + [EFFECT_FUTURE_SIGHT] = 1, + [EFFECT_GUST] = 1, + [EFFECT_FLINCH_MINIMIZE_HIT] = 1, + [EFFECT_SOLARBEAM] = 1, + [EFFECT_THUNDER] = 1, + [EFFECT_TELEPORT] = 1, + [EFFECT_BEAT_UP] = 2, + [EFFECT_SEMI_INVULNERABLE] = 3, + [EFFECT_DEFENSE_CURL] = 1, + [EFFECT_SOFTBOILED] = 1, + [EFFECT_FAKE_OUT] = 4, + [EFFECT_UPROAR] = 4, + [EFFECT_STOCKPILE] = 3, + [EFFECT_SPIT_UP] = 3, + [EFFECT_SWALLOW] = 3, + [EFFECT_UNUSED_A3] = 1, + [EFFECT_HAIL] = 4, + [EFFECT_TORMENT] = 7, + [EFFECT_FLATTER] = 7, + [EFFECT_WILL_O_WISP] = 5, + [EFFECT_MEMENTO] = 7, + [EFFECT_FACADE] = 1, + [EFFECT_FOCUS_PUNCH] = 7, + [EFFECT_SMELLINGSALT] = 1, + [EFFECT_FOLLOW_ME] = 5, + [EFFECT_NATURE_POWER] = 0, + [EFFECT_CHARGE] = 4, + [EFFECT_TAUNT] = 4, + [EFFECT_HELPING_HAND] = 4, + [EFFECT_TRICK] = 4, + [EFFECT_ROLE_PLAY] = 4, + [EFFECT_WISH] = 2, + [EFFECT_ASSIST] = 2, + [EFFECT_INGRAIN] = 6, + [EFFECT_SUPERPOWER] = 3, + [EFFECT_MAGIC_COAT] = 6, + [EFFECT_RECYCLE] = 4, + [EFFECT_REVENGE] = 4, + [EFFECT_BRICK_BREAK] = 2, + [EFFECT_YAWN] = 5, + [EFFECT_KNOCK_OFF] = 2, + [EFFECT_ENDEAVOR] = 1, + [EFFECT_ERUPTION] = 1, + [EFFECT_SKILL_SWAP] = 6, + [EFFECT_IMPRISON] = 6, + [EFFECT_REFRESH] = 6, + [EFFECT_GRUDGE] = 1, + [EFFECT_SNATCH] = 1, + [EFFECT_LOW_KICK] = 1, + [EFFECT_SECRET_POWER] = 1, + [EFFECT_DOUBLE_EDGE] = 2, + [EFFECT_TEETER_DANCE] = 6, + [EFFECT_BLAZE_KICK] = 1, + [EFFECT_MUD_SPORT] = 4, + [EFFECT_POISON_FANG] = 1, + [EFFECT_WEATHER_BALL] = 1, + [EFFECT_OVERHEAT] = 3, + [EFFECT_TICKLE] = 1, + [EFFECT_COSMIC_POWER] = 1, + [EFFECT_SKY_UPPERCUT] = 1, + [EFFECT_BULK_UP] = 1, + [EFFECT_POISON_TAIL] = 1, + [EFFECT_WATER_SPORT] = 4, + [EFFECT_CALM_MIND] = 1, + [EFFECT_DRAGON_DANCE] = 1, + [EFFECT_CAMOUFLAGE] = 3 }; -static const u16 sUnknown_0860A68C[] = + +static const u16 sPoints_Effectiveness[] = { - 0x0004, 0xfffd, 0xfffa + 4, // Super Effective + -3, // Not Very Effective + -6 // No Effect }; -static const u16 sUnknown_0860A692[] = +static const u16 sPoints_SetUp[] = { - 0x0004, 0x0004, 0x0006, 0x0006, 0x0007, 0x0006, 0x0002 + 4, // Future Sight + 4, // Doom Desire + 6, + 6, // Wish + 7, // Grudge + 6, + 2 // Ingrain }; -static const u16 sUnknown_0860A6A0[] = +static const u16 sPoints_RainMoves[] = { - 0x0091, 0x0003, 0x00fa, 0x0003, 0x00be, 0x0003, 0x0080, 0x0003, 0x006e, 0x0003, 0x0098, 0x0003, 0x0143, 0x0003, 0x0123, 0x0003, - 0x007f, 0x0003, 0x014a, 0x0003, 0x0039, 0x0003, 0x0134, 0x0003, 0x0038, 0x0003, 0x003d, 0x0003, 0x015a, 0x0000, 0x0037, 0x0003, - 0x0160, 0x0003, 0x0137, 0x0003, 0x0057, 0x0003, 0x004c, 0xfffc, 0x013b, 0xfffc, 0x00ac, 0xfffc, 0x0035, 0xfffc, 0x00dd, 0xfffc, - 0x007e, 0xfffc, 0x0101, 0xfffc, 0x0034, 0xfffc, 0x0133, 0xfffc, 0x012b, 0xfffc, 0x011c, 0xfffc, 0x0053, 0xfffc, 0x0007, 0xfffc, - 0x004c, 0xfffc, 0xffff, 0x0000 + MOVE_BUBBLE, 3, + MOVE_WHIRLPOOL, 3, + MOVE_OCTAZOOKA, 3, + MOVE_CLAMP, 3, + MOVE_WITHDRAW, 3, + MOVE_CRABHAMMER, 3, + MOVE_WATER_SPOUT, 3, + MOVE_DIVE, 3, + MOVE_WATERFALL, 3, + MOVE_MUDDY_WATER, 3, + MOVE_SURF, 3, + MOVE_HYDRO_CANNON, 3, + MOVE_HYDRO_PUMP, 3, + MOVE_BUBBLE_BEAM, 3, + MOVE_WATER_SPORT, 0, // Unnecessary, unlisted moves are already given 0 points + MOVE_WATER_GUN, 3, + MOVE_WATER_PULSE, 3, + MOVE_WEATHER_BALL, 3, + MOVE_THUNDER, 3, + MOVE_SOLAR_BEAM, -4, + MOVE_OVERHEAT, -4, + MOVE_FLAME_WHEEL, -4, + MOVE_FLAMETHROWER, -4, + MOVE_SACRED_FIRE, -4, + MOVE_FIRE_BLAST, -4, + MOVE_HEAT_WAVE, -4, + MOVE_EMBER, -4, + MOVE_BLAST_BURN, -4, + MOVE_BLAZE_KICK, -4, + MOVE_ERUPTION, -4, + MOVE_FIRE_SPIN, -4, + MOVE_FIRE_PUNCH, -4, + MOVE_SOLAR_BEAM, -4, // Repeated + TABLE_END, 0 }; -static const u16 sUnknown_0860A728[] = +static const u16 sPoints_SunMoves[] = { - 0x013b, 0x0003, 0x00ac, 0x0003, 0x0035, 0x0003, 0x00dd, 0x0003, 0x007e, 0x0003, 0x0101, 0x0003, 0x0034, 0x0003, 0x0133, 0x0003, - 0x012b, 0x0003, 0x011c, 0x0003, 0x0053, 0x0003, 0x0007, 0x0003, 0x004c, 0x0005, 0x00eb, 0x0003, 0x00ea, 0x0003, 0x00ec, 0x0003, - 0x0137, 0x0003, 0xffff, 0x0000 + MOVE_OVERHEAT, 3, + MOVE_FLAME_WHEEL, 3, + MOVE_FLAMETHROWER, 3, + MOVE_SACRED_FIRE, 3, + MOVE_FIRE_BLAST, 3, + MOVE_HEAT_WAVE, 3, + MOVE_EMBER, 3, + MOVE_BLAST_BURN, 3, + MOVE_BLAZE_KICK, 3, + MOVE_ERUPTION, 3, + MOVE_FIRE_SPIN, 3, + MOVE_FIRE_PUNCH, 3, + MOVE_SOLAR_BEAM, 5, + MOVE_SYNTHESIS, 3, + MOVE_MORNING_SUN, 3, + MOVE_MOONLIGHT, 3, + MOVE_WEATHER_BALL, 3, + TABLE_END, 0 }; -static const u16 sUnknown_0860A770[] = +static const u16 sPoints_SandstormMoves[] = { - 0x0137, 0x0003, 0x004c, 0xfffd, 0xffff, 0x0000 + MOVE_WEATHER_BALL, 3, + MOVE_SOLAR_BEAM, -3, + TABLE_END, 0 }; -static const u16 sUnknown_0860A77C[] = +static const u16 sPoints_HailMoves[] = { - 0x0137, 0x0003, 0x004c, 0xfffd, 0xffff, 0x0000 + MOVE_WEATHER_BALL, 3, + MOVE_SOLAR_BEAM, -3, + TABLE_END, 0 }; -static const u16 sUnknown_0860A788[] = +static const u16 sPoints_ElectricMoves[] = { - 0x0055, 0x0003, 0x0009, 0x0003, 0x00d1, 0x0003, 0x0054, 0x0003, 0x00c0, 0x0003, 0x015f, 0x0003, 0x0056, 0x0000, 0x0057, 0x0003, - 0x0158, 0x0003, 0xffff, 0x0000 + MOVE_THUNDERBOLT, 3, + MOVE_THUNDER_PUNCH, 3, + MOVE_SPARK, 3, + MOVE_THUNDER_SHOCK, 3, + MOVE_ZAP_CANNON, 3, + MOVE_SHOCK_WAVE, 3, + MOVE_THUNDER_WAVE, 0, // Unnecessary, unlisted moves are already given 0 points + MOVE_THUNDER, 3, + MOVE_VOLT_TACKLE, 3, + TABLE_END, 0 }; -static const u16 sUnknown_0860A7B0[] = +static const u16 sPoints_StatusDmg[] = { - 0x0005, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003 + 5, // Curse + 3, // Leech Seed + 3, // Poison + 3, // Toxic + 3, // Burn + 3, // Nightmare + 3 // Wrap (Trapping move) }; -static const u16 sUnknown_0860A7BE[] = +static const u16 sPoints_Status[] = { - 0x0005, 0x0005, 0x0005, 0x0005, 0x0005 + 5, // Attraction + 5, // Confusion + 5, // Paralysis + 5, // Sleep + 5 // Freeze }; -static const u16 sUnknown_0860A7C8[] = + +static const u16 sPoints_Spikes[] = { 4 }; +static const u16 sPoints_WaterSport[] = { 5 }; +static const u16 sPoints_MudSport[] = { 5 }; +static const u16 sPoints_Reflect[] = { 3 }; +static const u16 sPoints_LightScreen[] = { 3 }; +static const u16 sPoints_Safeguard[] = { 4 }; +static const u16 sPoints_Mist[] = { 3 }; +static const u16 sPoints_BreakWall[] = { 6 }; +static const u16 sPoints_CriticalHit[] = { 6 }; +static const u16 sPoints_Faint[] = { 6 }; +static const u16 sPoints_Flinched[] = { 4 }; + +static const u16 sPoints_StatIncrease1[NUM_BATTLE_STATS - 1] = { - 0x0004 + [STAT_ATK - 1] = 2, + [STAT_DEF - 1] = 2, + [STAT_SPEED - 1] = 2, + [STAT_SPATK - 1] = 2, + [STAT_SPDEF - 1] = 2, + [STAT_ACC - 1] = 2, + [STAT_EVASION - 1] = 2 }; -static const u16 sUnknown_0860A7CA[] = +static const u16 sPoints_StatIncrease2[NUM_BATTLE_STATS - 1] = { - 0x0005 + [STAT_ATK - 1] = 4, + [STAT_DEF - 1] = 4, + [STAT_SPEED - 1] = 4, + [STAT_SPATK - 1] = 4, + [STAT_SPDEF - 1] = 4, + [STAT_ACC - 1] = 4, + [STAT_EVASION - 1] = 4 }; -static const u16 sUnknown_0860A7CC[] = +static const u16 sPoints_StatDecreaseSelf[NUM_BATTLE_STATS - 1] = { - 0x0005 + [STAT_ATK - 1] = -1, + [STAT_DEF - 1] = -1, + [STAT_SPEED - 1] = -1, + [STAT_SPATK - 1] = -1, + [STAT_SPDEF - 1] = -1, + [STAT_ACC - 1] = -1, + [STAT_EVASION - 1] = -1 }; -static const u16 sUnknown_0860A7CE[] = +static const u16 sPoints_StatDecrease1[NUM_BATTLE_STATS - 1] = { - 0x0003 + [STAT_ATK - 1] = 2, + [STAT_DEF - 1] = 2, + [STAT_SPEED - 1] = 2, + [STAT_SPATK - 1] = 2, + [STAT_SPDEF - 1] = 2, + [STAT_ACC - 1] = 2, + [STAT_EVASION - 1] = 2 }; -static const u16 sUnknown_0860A7D0[] = +static const u16 sPoints_StatDecrease2[NUM_BATTLE_STATS - 1] = { - 0x0003 + [STAT_ATK - 1] = 4, + [STAT_DEF - 1] = 4, + [STAT_SPEED - 1] = 4, + [STAT_SPATK - 1] = 4, + [STAT_SPDEF - 1] = 4, + [STAT_ACC - 1] = 4, + [STAT_EVASION - 1] = 4 }; -static const u16 sUnknown_0860A7D2[] = +static const u16 sPoints_StatIncreaseNotSelf[NUM_BATTLE_STATS - 1] = { - 0x0004 -}; -static const u16 sUnknown_0860A7D4[] = -{ - 0x0003 -}; -static const u16 sUnknown_0860A7D6[] = -{ - 0x0006 -}; -static const u16 sUnknown_0860A7D8[] = -{ - 0x0006 -}; -static const u16 sUnknown_0860A7DA[] = -{ - 0x0006 -}; -static const u16 sUnknown_0860A7DC[] = -{ - 0x0004 -}; -static const u16 sUnknown_0860A7DE[] = -{ - 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002 -}; -static const u16 sUnknown_0860A7EC[] = -{ - 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004 -}; -static const u16 sUnknown_0860A7FA[] = -{ - 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff -}; -static const u16 sUnknown_0860A808[] = -{ - 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002 -}; -static const u16 sUnknown_0860A816[] = -{ - 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004 -}; -static const u16 sUnknown_0860A824[] = -{ - 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe + [STAT_ATK - 1] = -2, + [STAT_DEF - 1] = -2, + [STAT_SPEED - 1] = -2, + [STAT_SPATK - 1] = -2, + [STAT_SPDEF - 1] = -2, + [STAT_ACC - 1] = -2, + [STAT_EVASION - 1] = -2 }; static const u16 *const sPointsArray[] = { - sUnknown_0860A4E0, - sUnknown_0860A68C, - sUnknown_0860A692, - sUnknown_0860A6A0, - sUnknown_0860A728, - sUnknown_0860A770, - sUnknown_0860A77C, - sUnknown_0860A788, - sUnknown_0860A7B0, - sUnknown_0860A7BE, - sUnknown_0860A7C8, - sUnknown_0860A7CA, - sUnknown_0860A7CC, - sUnknown_0860A7CE, - sUnknown_0860A7D0, - sUnknown_0860A7D2, - sUnknown_0860A7D4, - sUnknown_0860A7D6, - sUnknown_0860A7D8, - sUnknown_0860A7DA, - sUnknown_0860A7DA, - sUnknown_0860A7DC, - sUnknown_0860A7DE, - sUnknown_0860A7EC, - sUnknown_0860A7FA, - sUnknown_0860A808, - sUnknown_0860A816, - sUnknown_0860A824 + [PTS_MOVE_EFFECT] = sPoints_MoveEffect, + [PTS_EFFECTIVENESS] = sPoints_Effectiveness, + [PTS_SET_UP] = sPoints_SetUp, + [PTS_RAIN] = sPoints_RainMoves, + [PTS_SUN] = sPoints_SunMoves, + [PTS_SANDSTORM] = sPoints_SandstormMoves, + [PTS_HAIL] = sPoints_HailMoves, + [PTS_ELECTRIC] = sPoints_ElectricMoves, + [PTS_STATUS_DMG] = sPoints_StatusDmg, + [PTS_STATUS] = sPoints_Status, + [PTS_SPIKES] = sPoints_Spikes, + [PTS_WATER_SPORT] = sPoints_WaterSport, + [PTS_MUD_SPORT] = sPoints_MudSport, + [PTS_REFLECT] = sPoints_Reflect, + [PTS_LIGHT_SCREEN] = sPoints_LightScreen, + [PTS_SAFEGUARD] = sPoints_Safeguard, + [PTS_MIST] = sPoints_Mist, + [PTS_BREAK_WALL] = sPoints_BreakWall, + [PTS_CRITICAL_HIT] = sPoints_CriticalHit, + [PTS_FAINT] = sPoints_Faint, + [PTS_FAINT_SET_UP] = sPoints_Faint, + [PTS_FLINCHED] = sPoints_Flinched, + [PTS_STAT_INCREASE_1] = sPoints_StatIncrease1, + [PTS_STAT_INCREASE_2] = sPoints_StatIncrease2, + [PTS_STAT_DECREASE_SELF] = sPoints_StatDecreaseSelf, + [PTS_STAT_DECREASE_1] = sPoints_StatDecrease1, + [PTS_STAT_DECREASE_2] = sPoints_StatDecrease2, + [PTS_STAT_INCREASE_NOT_SELF] = sPoints_StatIncreaseNotSelf }; -static const u16 sUnknown_0860A8A4[] = +// Points will always be calculated for these messages +// even if current pokemon does not have corresponding move +static const u16 sSpecialBattleStrings[] = { STRINGID_PKMNPERISHCOUNTFELL, STRINGID_PKMNWISHCAMETRUE, STRINGID_PKMNLOSTPPGRUDGE, STRINGID_PKMNTOOKFOE, STRINGID_PKMNABSORBEDNUTRIENTS, STRINGID_PKMNANCHOREDITSELF, STRINGID_PKMNAFFLICTEDBYCURSE, STRINGID_PKMNSAPPEDBYLEECHSEED, STRINGID_PKMNLOCKEDINNIGHTMARE, STRINGID_PKMNHURTBY, STRINGID_PKMNHURTBYBURN, STRINGID_PKMNHURTBYPOISON, STRINGID_PKMNHURTBYSPIKES, STRINGID_ATTACKERFAINTED, STRINGID_TARGETFAINTED, - STRINGID_PKMNHITWITHRECOIL, STRINGID_PKMNCRASHED, 0xFFFF + STRINGID_PKMNHITWITHRECOIL, STRINGID_PKMNCRASHED, TABLE_END }; // code @@ -235,9 +570,9 @@ void BattleTv_SetDataBasedOnString(u16 stringId) moveSlot = GetBattlerMoveSlotId(gBattlerAttacker, gBattleMsgDataPtr->currentMove); - if (moveSlot >= 4 && sub_817E0B8(stringId) && stringId > BATTLESTRINGS_ID_ADDER) + if (moveSlot >= MAX_MON_MOVES && IsNotSpecialBattleString(stringId) && stringId > BATTLESTRINGS_ID_ADDER) { - tvPtr->side[atkSide].faintCause = 15; + tvPtr->side[atkSide].faintCause = FNT_OTHER; return; } @@ -252,17 +587,17 @@ void BattleTv_SetDataBasedOnString(u16 stringId) switch (stringId) { case STRINGID_ITDOESNTAFFECT: - AddMovePoints(1, moveSlot, 2, 0); + AddMovePoints(PTS_EFFECTIVENESS, moveSlot, 2, 0); if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) TrySetBattleSeminarShow(); break; case STRINGID_NOTVERYEFFECTIVE: - AddMovePoints(1, moveSlot, 1, 0); + AddMovePoints(PTS_EFFECTIVENESS, moveSlot, 1, 0); if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && GetMonData(defMon, MON_DATA_HP, NULL) != 0) TrySetBattleSeminarShow(); break; case STRINGID_SUPEREFFECTIVE: - AddMovePoints(1, moveSlot, 0, 0); + AddMovePoints(PTS_EFFECTIVENESS, moveSlot, 0, 0); break; case STRINGID_PKMNFORESAWATTACK: tvPtr->side[atkSide].futureSightMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; @@ -279,12 +614,12 @@ void BattleTv_SetDataBasedOnString(u16 stringId) break; case STRINGID_PKMNPERISHCOUNTFELL: if (*perishCount == 0) - tvPtr->side[atkSide].faintCause = 10; + tvPtr->side[atkSide].faintCause = FNT_PERISH_SONG; break; case STRINGID_PKMNWISHCAMETRUE: if (tvPtr->side[defSide].wishMonId != 0) { - AddMovePoints(2, 3, defSide, + AddMovePoints(PTS_SET_UP, 3, defSide, (tvPtr->side[defSide].wishMonId - 1) * 4 + tvPtr->side[defSide].wishMoveSlot); } break; @@ -295,7 +630,7 @@ void BattleTv_SetDataBasedOnString(u16 stringId) case STRINGID_PKMNLOSTPPGRUDGE: if (tvPtr->side[defSide].grudgeMonId != 0) { - AddMovePoints(2, 4, defSide, + AddMovePoints(PTS_SET_UP, 4, defSide, (tvPtr->side[defSide].grudgeMonId - 1) * 4 + tvPtr->side[defSide].grudgeMoveSlot); } break; @@ -305,7 +640,7 @@ void BattleTv_SetDataBasedOnString(u16 stringId) break; case STRINGID_PKMNTOOKFOE: if (tvPtr->side[defSide].destinyBondMonId != 0) - tvPtr->side[atkSide].faintCause = 11; + tvPtr->side[atkSide].faintCause = FNT_DESTINY_BOND; break; case STRINGID_PKMNPLANTEDROOTS: tvPtr->pos[atkSide][atkFlank].ingrainMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; @@ -314,14 +649,14 @@ void BattleTv_SetDataBasedOnString(u16 stringId) case STRINGID_PKMNABSORBEDNUTRIENTS: if (tvPtr->pos[atkSide][atkFlank].ingrainMonId != 0) { - AddMovePoints(2, 6, atkSide, + AddMovePoints(PTS_SET_UP, 6, atkSide, (tvPtr->pos[atkSide][atkFlank].ingrainMonId - 1) * 4 + tvPtr->pos[atkSide][atkFlank].ingrainMoveSlot); } break; case STRINGID_PKMNANCHOREDITSELF: if (tvPtr->pos[defSide][defFlank].ingrainMonId != 0) { - AddMovePoints(2, 6, defSide, + AddMovePoints(PTS_SET_UP, 6, defSide, (tvPtr->pos[defSide][defFlank].ingrainMonId - 1) * 4 + tvPtr->pos[defSide][defFlank].ingrainMoveSlot); } break; @@ -329,15 +664,15 @@ void BattleTv_SetDataBasedOnString(u16 stringId) gBattleStruct->anyMonHasTransformed = TRUE; break; case STRINGID_CRITICALHIT: - AddMovePoints(0x12, moveSlot, 0, 0); + AddMovePoints(PTS_CRITICAL_HIT, moveSlot, 0, 0); break; case STRINGID_PKMNSSTATCHANGED: if (gBattleTextBuff1[2] != 0) { if (*statStringId == STRINGID_STATSHARPLY) - AddMovePoints(0x17, moveSlot, gBattleTextBuff1[2] - 1, 0); + AddMovePoints(PTS_STAT_INCREASE_2, moveSlot, gBattleTextBuff1[2] - 1, 0); else - AddMovePoints(0x16, moveSlot, gBattleTextBuff1[2] - 1, 0); + AddMovePoints(PTS_STAT_INCREASE_1, moveSlot, gBattleTextBuff1[2] - 1, 0); } break; case STRINGID_PKMNSSTATCHANGED2: @@ -346,27 +681,27 @@ void BattleTv_SetDataBasedOnString(u16 stringId) if (gBattlerAttacker == gBattlerTarget) { if (*statStringId == STRINGID_STATSHARPLY) - AddMovePoints(0x17, moveSlot, gBattleTextBuff1[2] - 1, 0); + AddMovePoints(PTS_STAT_INCREASE_2, moveSlot, gBattleTextBuff1[2] - 1, 0); else - AddMovePoints(0x16, moveSlot, gBattleTextBuff1[2] - 1, 0); + AddMovePoints(PTS_STAT_INCREASE_1, moveSlot, gBattleTextBuff1[2] - 1, 0); } else { - AddMovePoints(0x1B, moveSlot, gBattleTextBuff1[2] - 1, 0); + AddMovePoints(PTS_STAT_INCREASE_NOT_SELF, moveSlot, gBattleTextBuff1[2] - 1, 0); } } break; case STRINGID_PKMNSSTATCHANGED3: if (gBattleTextBuff1[2] != 0) - AddMovePoints(0x18, moveSlot, gBattleTextBuff1[2] - 1, 0); + AddMovePoints(PTS_STAT_DECREASE_SELF, moveSlot, gBattleTextBuff1[2] - 1, 0); break; case STRINGID_PKMNSSTATCHANGED4: if (gBattleTextBuff1[2] != 0) { if (*statStringId == STRINGID_STATHARSHLY) - AddMovePoints(0x1A, moveSlot, gBattleTextBuff1[2] - 1, 0); + AddMovePoints(PTS_STAT_DECREASE_2, moveSlot, gBattleTextBuff1[2] - 1, 0); else - AddMovePoints(0x19, moveSlot, gBattleTextBuff1[2] - 1, 0); + AddMovePoints(PTS_STAT_DECREASE_1, moveSlot, gBattleTextBuff1[2] - 1, 0); } break; case STRINGID_PKMNLAIDCURSE: @@ -377,8 +712,8 @@ void BattleTv_SetDataBasedOnString(u16 stringId) if (GetMonData(atkMon, MON_DATA_HP, NULL) && tvPtr->pos[atkSide][atkFlank].curseMonId != 0) { - AddMovePoints(8, 0, tvPtr->pos[atkSide][atkFlank].curseMonId - 1, tvPtr->pos[atkSide][atkFlank].curseMoveSlot); - tvPtr->side[atkSide].faintCause = 1; + AddMovePoints(PTS_STATUS_DMG, 0, tvPtr->pos[atkSide][atkFlank].curseMonId - 1, tvPtr->pos[atkSide][atkFlank].curseMoveSlot); + tvPtr->side[atkSide].faintCause = FNT_CURSE; tvPtr->side[atkSide].faintCauseMonId = atkFlank; } break; @@ -389,8 +724,8 @@ void BattleTv_SetDataBasedOnString(u16 stringId) case STRINGID_PKMNSAPPEDBYLEECHSEED: if (tvPtr->pos[atkSide][atkFlank].leechSeedMonId != 0) { - AddMovePoints(8, 1, tvPtr->pos[atkSide][atkFlank].leechSeedMonId - 1, tvPtr->pos[atkSide][atkFlank].leechSeedMoveSlot); - tvPtr->side[atkSide].faintCause = 2; + AddMovePoints(PTS_STATUS_DMG, 1, tvPtr->pos[atkSide][atkFlank].leechSeedMonId - 1, tvPtr->pos[atkSide][atkFlank].leechSeedMoveSlot); + tvPtr->side[atkSide].faintCause = FNT_LEECH_SEED; tvPtr->side[atkSide].faintCauseMonId = atkFlank; } break; @@ -402,8 +737,8 @@ void BattleTv_SetDataBasedOnString(u16 stringId) if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0 && tvPtr->pos[atkSide][atkFlank].nightmareMonId != 0) { - AddMovePoints(8, 5, tvPtr->pos[atkSide][atkFlank].nightmareMonId - 1, tvPtr->pos[atkSide][atkFlank].nightmareMoveSlot); - tvPtr->side[atkSide].faintCause = 5; + AddMovePoints(PTS_STATUS_DMG, 5, tvPtr->pos[atkSide][atkFlank].nightmareMonId - 1, tvPtr->pos[atkSide][atkFlank].nightmareMoveSlot); + tvPtr->side[atkSide].faintCause = FNT_NIGHTMARE; tvPtr->side[atkSide].faintCauseMonId = atkFlank; } break; @@ -419,8 +754,8 @@ void BattleTv_SetDataBasedOnString(u16 stringId) if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0 && tvPtr->pos[atkSide][atkFlank].wrapMonId != 0) { - AddMovePoints(8, 6, tvPtr->pos[atkSide][atkFlank].wrapMonId - 1, tvPtr->pos[atkSide][atkFlank].wrapMoveSlot); - tvPtr->side[atkSide].faintCause = 6; + AddMovePoints(PTS_STATUS_DMG, 6, tvPtr->pos[atkSide][atkFlank].wrapMonId - 1, tvPtr->pos[atkSide][atkFlank].wrapMoveSlot); + tvPtr->side[atkSide].faintCause = FNT_WRAP; tvPtr->side[atkSide].faintCauseMonId = atkFlank; } break; @@ -432,8 +767,8 @@ void BattleTv_SetDataBasedOnString(u16 stringId) if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0) { if (tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMonId != 0) - AddMovePoints(8, 4, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMoveSlot); - tvPtr->side[atkSide].faintCause = 4; + AddMovePoints(PTS_STATUS_DMG, 4, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMoveSlot); + tvPtr->side[atkSide].faintCause = FNT_BURN; tvPtr->side[atkSide].faintCauseMonId = gBattlerPartyIndexes[gBattlerAttacker]; } break; @@ -449,10 +784,10 @@ void BattleTv_SetDataBasedOnString(u16 stringId) if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0) { if (tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMonId != 0) - AddMovePoints(8, 2, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMoveSlot); + AddMovePoints(PTS_STATUS_DMG, 2, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMoveSlot); if (tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMonId != 0) - AddMovePoints(8, 3, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMoveSlot); - tvPtr->side[atkSide].faintCause = 3; + AddMovePoints(PTS_STATUS_DMG, 3, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMoveSlot); + tvPtr->side[atkSide].faintCause = FNT_POISON; tvPtr->side[atkSide].faintCauseMonId = gBattlerPartyIndexes[gBattlerAttacker]; } break; @@ -462,7 +797,7 @@ void BattleTv_SetDataBasedOnString(u16 stringId) break; case STRINGID_PKMNIMMOBILIZEDBYLOVE: if (tvPtr->pos[atkSide][atkFlank].attractMonId != 0) - AddMovePoints(9, 0, tvPtr->pos[atkSide][atkFlank].attractMonId - 1, tvPtr->pos[atkSide][atkFlank].attractMoveSlot); + AddMovePoints(PTS_STATUS, 0, tvPtr->pos[atkSide][atkFlank].attractMonId - 1, tvPtr->pos[atkSide][atkFlank].attractMoveSlot); break; case STRINGID_PKMNWASPARALYZED: tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].prlzMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; @@ -470,7 +805,7 @@ void BattleTv_SetDataBasedOnString(u16 stringId) break; case STRINGID_PKMNISPARALYZED: if (tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMonId != 0) - AddMovePoints(9, 2, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMoveSlot); + AddMovePoints(PTS_STATUS, 2, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMoveSlot); break; case STRINGID_PKMNFELLASLEEP: tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].slpMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; @@ -480,7 +815,7 @@ void BattleTv_SetDataBasedOnString(u16 stringId) if (tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMonId != 0 && gBattleMsgDataPtr->currentMove != MOVE_SNORE && gBattleMsgDataPtr->currentMove != MOVE_SLEEP_TALK) - AddMovePoints(9, 3, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMoveSlot); + AddMovePoints(PTS_STATUS, 3, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMoveSlot); break; case STRINGID_PKMNWASFROZEN: tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].frzMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; @@ -488,7 +823,7 @@ void BattleTv_SetDataBasedOnString(u16 stringId) break; case STRINGID_PKMNISFROZEN: if (tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMonId != 0) - AddMovePoints(9, 4, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMoveSlot); + AddMovePoints(PTS_STATUS, 4, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMoveSlot); break; case STRINGID_PKMNWASCONFUSED: tvPtr->pos[effSide][effFlank].confusionMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; @@ -496,8 +831,8 @@ void BattleTv_SetDataBasedOnString(u16 stringId) break; case STRINGID_ITHURTCONFUSION: if (tvPtr->pos[atkSide][atkFlank].confusionMonId != 0) - AddMovePoints(9, 1, tvPtr->pos[atkSide][atkFlank].confusionMonId - 1, tvPtr->pos[atkSide][atkFlank].confusionMoveSlot); - tvPtr->side[atkSide].faintCause = 12; + AddMovePoints(PTS_STATUS, 1, tvPtr->pos[atkSide][atkFlank].confusionMonId - 1, tvPtr->pos[atkSide][atkFlank].confusionMoveSlot); + tvPtr->side[atkSide].faintCause = FNT_CONFUSION; break; case STRINGID_SPIKESSCATTERED: tvPtr->side[defSide].spikesMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; @@ -506,8 +841,8 @@ void BattleTv_SetDataBasedOnString(u16 stringId) case STRINGID_PKMNHURTBYSPIKES: if (tvPtr->side[scriptingSide].spikesMonId != 0) { - AddMovePoints(10, scriptingSide ^ BIT_SIDE, tvPtr->side[scriptingSide].spikesMonId - 1, tvPtr->side[scriptingSide].spikesMoveSlot); - tvPtr->side[scriptingSide].faintCause = 7; + AddMovePoints(PTS_SPIKES, scriptingSide ^ BIT_SIDE, tvPtr->side[scriptingSide].spikesMonId - 1, tvPtr->side[scriptingSide].spikesMoveSlot); + tvPtr->side[scriptingSide].faintCause = FNT_SPIKES; } break; case STRINGID_PKMNBLEWAWAYSPIKES: @@ -582,7 +917,7 @@ void BattleTv_SetDataBasedOnString(u16 stringId) break; case STRINGID_PKMNUSEDSAFEGUARD: if (tvPtr->side[defSide].safeguardMonId != 0) - AddMovePoints(15, 0, tvPtr->side[defSide].safeguardMonId - 1, tvPtr->side[defSide].safeguardMoveSlot); + AddMovePoints(PTS_SAFEGUARD, 0, tvPtr->side[defSide].safeguardMonId - 1, tvPtr->side[defSide].safeguardMoveSlot); break; case STRINGID_PKMNSAFEGUARDEXPIRED: tvPtr->side[atkSide].safeguardMonId = 0; @@ -594,40 +929,40 @@ void BattleTv_SetDataBasedOnString(u16 stringId) break; case STRINGID_PKMNPROTECTEDBYMIST: if (tvPtr->side[defSide].mistMonId != 0) - AddMovePoints(16, 0, tvPtr->side[defSide].mistMonId - 1, tvPtr->side[defSide].mistMoveSlot); + AddMovePoints(PTS_MIST, 0, tvPtr->side[defSide].mistMonId - 1, tvPtr->side[defSide].mistMoveSlot); break; case STRINGID_THEWALLSHATTERED: tvPtr->side[defSide].reflectMonId = 0; tvPtr->side[defSide].reflectMoveSlot = 0; tvPtr->side[defSide].lightScreenMonId = 0; tvPtr->side[defSide].lightScreenMoveSlot = 0; - AddMovePoints(17, 0, gBattlerPartyIndexes[gBattlerAttacker], moveSlot); + AddMovePoints(PTS_BREAK_WALL, 0, gBattlerPartyIndexes[gBattlerAttacker], moveSlot); break; case STRINGID_PKMNFLINCHED: if (tvPtr->pos[atkSide][0].attackedByMonId != 0) - AddMovePoints(21, 0, tvPtr->pos[atkSide][0].attackedByMonId - 1, tvPtr->pos[atkSide][0].attackedByMoveSlot); + AddMovePoints(PTS_FLINCHED, 0, tvPtr->pos[atkSide][0].attackedByMonId - 1, tvPtr->pos[atkSide][0].attackedByMoveSlot); if (tvPtr->pos[atkSide][1].attackedByMonId != 0) - AddMovePoints(21, 0, tvPtr->pos[atkSide][1].attackedByMonId - 1, tvPtr->pos[atkSide][1].attackedByMoveSlot); + AddMovePoints(PTS_FLINCHED, 0, tvPtr->pos[atkSide][1].attackedByMonId - 1, tvPtr->pos[atkSide][1].attackedByMoveSlot); break; case STRINGID_PKMNCRASHED: case STRINGID_PKMNHITWITHRECOIL: - tvPtr->side[atkSide].faintCause = 14; + tvPtr->side[atkSide].faintCause = FNT_RECOIL; break; } } -static bool8 sub_817E0B8(u16 stringId) +static bool8 IsNotSpecialBattleString(u16 stringId) { s32 i = 0; do { - if (sUnknown_0860A8A4[i] == stringId) + if (sSpecialBattleStrings[i] == stringId) break; i++; - } while (sUnknown_0860A8A4[i] != 0xFFFF); + } while (sSpecialBattleStrings[i] != TABLE_END); - if (sUnknown_0860A8A4[i] == 0xFFFF) + if (sSpecialBattleStrings[i] == TABLE_END) return TRUE; else return FALSE; @@ -648,19 +983,19 @@ void BattleTv_SetDataBasedOnMove(u16 move, u16 weatherFlags, struct DisableStruc defSide = GetBattlerSide(gBattlerTarget); moveSlot = GetBattlerMoveSlotId(gBattlerAttacker, move); - if (moveSlot >= 4) + if (moveSlot >= MAX_MON_MOVES) { - tvPtr->side[atkSide].faintCause = 15; + tvPtr->side[atkSide].faintCause = FNT_OTHER; return; } tvPtr->pos[defSide][GetBattlerPosition(gBattlerAttacker) / 2].attackedByMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; tvPtr->pos[defSide][GetBattlerPosition(gBattlerAttacker) / 2].attackedByMoveSlot = moveSlot; tvPtr->side[atkSide].usedMoveSlot = moveSlot; - AddMovePoints(0, moveSlot, gBattleMoves[move].effect, 0); + AddMovePoints(PTS_MOVE_EFFECT, moveSlot, gBattleMoves[move].effect, 0); AddPointsBasedOnWeather(weatherFlags, move, moveSlot); if (disableStructPtr->chargeTimer != 0) - AddMovePoints(7, move, moveSlot, 0); + AddMovePoints(PTS_ELECTRIC, move, moveSlot, 0); if (move == MOVE_WISH) { @@ -671,14 +1006,14 @@ void BattleTv_SetDataBasedOnMove(u16 move, u16 weatherFlags, struct DisableStruc { tvPtr->side[atkSide ^ BIT_SIDE].explosionMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; tvPtr->side[atkSide ^ BIT_SIDE].explosionMoveSlot = moveSlot; - tvPtr->side[atkSide ^ BIT_SIDE].faintCause = 13; - tvPtr->side[atkSide ^ BIT_SIDE].explosion = 1; + tvPtr->side[atkSide ^ BIT_SIDE].faintCause = FNT_EXPLOSION; + tvPtr->side[atkSide ^ BIT_SIDE].explosion = TRUE; } - AddMovePoints(13, gBattleMoves[move].type, gBattleMoves[move].power, 0); - AddMovePoints(14, gBattleMoves[move].type, gBattleMoves[move].power, 0); - AddMovePoints(11, gBattleMoves[move].type, 0, 0); - AddMovePoints(12, gBattleMoves[move].type, 0, 0); + AddMovePoints(PTS_REFLECT, gBattleMoves[move].type, gBattleMoves[move].power, 0); + AddMovePoints(PTS_LIGHT_SCREEN, gBattleMoves[move].type, gBattleMoves[move].power, 0); + AddMovePoints(PTS_WATER_SPORT, gBattleMoves[move].type, 0, 0); + AddMovePoints(PTS_MUD_SPORT, gBattleMoves[move].type, 0, 0); } void BattleTv_SetDataBasedOnAnimation(u8 animationId) @@ -696,17 +1031,17 @@ void BattleTv_SetDataBasedOnAnimation(u8 animationId) case B_ANIM_FUTURE_SIGHT_HIT: if (tvPtr->side[atkSide].futureSightMonId != 0) { - AddMovePoints(2, 0, atkSide, + AddMovePoints(PTS_SET_UP, 0, atkSide, (tvPtr->side[atkSide].futureSightMonId - 1) * 4 + tvPtr->side[atkSide].futureSightMoveSlot); - tvPtr->side[atkSide].faintCause = 8; + tvPtr->side[atkSide].faintCause = FNT_FUTURE_SIGHT; } break; case B_ANIM_DOOM_DESIRE_HIT: if (tvPtr->side[atkSide].doomDesireMonId != 0) { - AddMovePoints(2, 1, atkSide, + AddMovePoints(PTS_SET_UP, 1, atkSide, (tvPtr->side[atkSide].doomDesireMonId - 1) * 4 + tvPtr->side[atkSide].doomDesireMoveSlot); - tvPtr->side[atkSide].faintCause = 9; + tvPtr->side[atkSide].faintCause = FNT_DOOM_DESIRE; } break; } @@ -819,49 +1154,67 @@ static void AddMovePoints(u8 caseId, u16 arg1, u8 arg2, u8 arg3) switch (caseId) { - case 0: - case 1: - case 18: - case 22 ... 27: + case PTS_MOVE_EFFECT: + case PTS_EFFECTIVENESS: + case PTS_CRITICAL_HIT: + case PTS_STAT_INCREASE_1: + case PTS_STAT_INCREASE_2: + case PTS_STAT_DECREASE_SELF: + case PTS_STAT_DECREASE_1: + case PTS_STAT_DECREASE_2: + case PTS_STAT_INCREASE_NOT_SELF: movePoints->points[atkSide][gBattlerPartyIndexes[gBattlerAttacker] * 4 + arg1] += sPointsArray[caseId][arg2]; break; - case 3 ... 7: + +#define move arg1 + case PTS_RAIN: + case PTS_SUN: + case PTS_SANDSTORM: + case PTS_HAIL: + case PTS_ELECTRIC: i = 0; ptr = sPointsArray[caseId]; do { - if (arg1 == ptr[i]) + if (move == ptr[i]) { movePoints->points[atkSide][gBattlerPartyIndexes[gBattlerAttacker] * 4 + arg2] += ptr[i+1]; break; } i += 2; - } while (ptr[i] != 0xFFFF); + } while (ptr[i] != TABLE_END); break; - case 19: - tvPtr->side[arg2 ^ 1].faintCause = 0; +#undef move + + case PTS_FAINT: + tvPtr->side[arg2 ^ 1].faintCause = FNT_NONE; movePoints->points[arg2][0 * 4 + arg3] += sPointsArray[caseId][arg1]; break; - case 20: - tvPtr->side[arg2].faintCause = 0; - case 2: + case PTS_FAINT_SET_UP: + tvPtr->side[arg2].faintCause = FNT_NONE; + // fallthrough + case PTS_SET_UP: movePoints->points[arg2][0 * 4 + arg3] += sPointsArray[caseId][arg1]; break; - case 17: + case PTS_BREAK_WALL: movePoints->points[atkSide][arg2 * 4 + arg3] += sPointsArray[caseId][arg1]; break; - case 8: - case 9: - case 15: - case 16: - case 21: + case PTS_STATUS_DMG: + case PTS_STATUS: + case PTS_SAFEGUARD: + case PTS_MIST: + case PTS_FLINCHED: movePoints->points[atkSide ^ BIT_SIDE][arg2 * 4 + arg3] += sPointsArray[caseId][arg1]; break; - case 10: + case PTS_SPIKES: movePoints->points[arg1][arg2 * 4 + arg3] += sPointsArray[caseId][0]; break; - case 11: - if (tvPtr->pos[defSide][0].waterSportMonId != -(tvPtr->pos[defSide][1].waterSportMonId) && arg1 == 10) + +#define type arg1 +#define power arg2 + case PTS_WATER_SPORT: + // If used fire move during Water Sport + if (tvPtr->pos[defSide][0].waterSportMonId != -(tvPtr->pos[defSide][1].waterSportMonId) && type == TYPE_FIRE) { if (tvPtr->pos[defSide][0].waterSportMonId != 0) { @@ -875,8 +1228,9 @@ static void AddMovePoints(u8 caseId, u16 arg1, u8 arg2, u8 arg3) } } break; - case 12: - if (tvPtr->pos[defSide][0].mudSportMonId != -(tvPtr->pos[defSide][1].mudSportMonId) && arg1 == 13) + case PTS_MUD_SPORT: + // If used Electric move during Mud Sport + if (tvPtr->pos[defSide][0].mudSportMonId != -(tvPtr->pos[defSide][1].mudSportMonId) && type == TYPE_ELECTRIC) { if (tvPtr->pos[defSide][0].mudSportMonId != 0) { @@ -890,20 +1244,24 @@ static void AddMovePoints(u8 caseId, u16 arg1, u8 arg2, u8 arg3) } } break; - case 13: - if (arg1 <= 8 && arg2 != 0 && tvPtr->side[defSide].reflectMonId != 0) + case PTS_REFLECT: + // If hit Reflect with damaging physical move + if (type < TYPE_MYSTERY && power != 0 && tvPtr->side[defSide].reflectMonId != 0) { u32 id = (tvPtr->side[defSide].reflectMonId - 1) * 4; movePoints->points[defSide][id + tvPtr->side[defSide].reflectMoveSlot] += sPointsArray[caseId][0]; } break; - case 14: - if (arg1 > 8 && arg2 != 0 && tvPtr->side[defSide].lightScreenMonId != 0) + case PTS_LIGHT_SCREEN: + // If hit Light Screen with damaging special move + if (type >= TYPE_MYSTERY && power != 0 && tvPtr->side[defSide].lightScreenMonId != 0) { u32 id = (tvPtr->side[defSide].lightScreenMonId - 1) * 4; movePoints->points[defSide][id + tvPtr->side[defSide].lightScreenMoveSlot] += sPointsArray[caseId][0]; } break; +#undef type +#undef power } } @@ -915,144 +1273,144 @@ static void AddPointsOnFainting(bool8 targetFainted) u32 atkArrId = tvPtr->side[atkSide].faintCauseMonId; s32 i; - if (tvPtr->side[atkSide].faintCause != 0) + if (tvPtr->side[atkSide].faintCause != FNT_NONE) { switch (tvPtr->side[atkSide].faintCause) { - case 1: + case FNT_CURSE: if (tvPtr->pos[atkSide][atkArrId].curseMonId != 0) { - AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + AddMovePoints(PTS_FAINT, 0, atkSide ^ BIT_SIDE, (tvPtr->pos[atkSide][atkArrId].curseMonId - 1) * 4 + tvPtr->pos[atkSide][atkArrId].curseMoveSlot); } break; - case 2: + case FNT_LEECH_SEED: if (tvPtr->pos[atkSide][atkArrId].leechSeedMonId != 0) { - AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + AddMovePoints(PTS_FAINT, 0, atkSide ^ BIT_SIDE, (tvPtr->pos[atkSide][atkArrId].leechSeedMonId - 1) * 4 + tvPtr->pos[atkSide][atkArrId].leechSeedMoveSlot); } break; - case 3: + case FNT_POISON: if (tvPtr->mon[atkSide][atkArrId].psnMonId != 0) { - AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + AddMovePoints(PTS_FAINT, 0, atkSide ^ BIT_SIDE, (tvPtr->mon[atkSide][atkArrId].psnMonId - 1) * 4 + tvPtr->mon[atkSide][atkArrId].psnMoveSlot); } if (tvPtr->mon[atkSide][atkArrId].badPsnMonId != 0) { - AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + AddMovePoints(PTS_FAINT, 0, atkSide ^ BIT_SIDE, (tvPtr->mon[atkSide][atkArrId].badPsnMonId - 1) * 4 + tvPtr->mon[atkSide][atkArrId].badPsnMoveSlot); } break; - case 4: + case FNT_BURN: if (tvPtr->mon[atkSide][atkArrId].brnMonId != 0) { - AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + AddMovePoints(PTS_FAINT, 0, atkSide ^ BIT_SIDE, (tvPtr->mon[atkSide][atkArrId].brnMonId - 1) * 4 + tvPtr->mon[atkSide][atkArrId].brnMoveSlot); } break; - case 5: + case FNT_NIGHTMARE: if (tvPtr->pos[atkSide][atkArrId].nightmareMonId != 0) { - AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + AddMovePoints(PTS_FAINT, 0, atkSide ^ BIT_SIDE, (tvPtr->pos[atkSide][atkArrId].nightmareMonId - 1) * 4 + tvPtr->pos[atkSide][atkArrId].nightmareMoveSlot); } break; - case 6: + case FNT_WRAP: if (tvPtr->pos[atkSide][atkArrId].wrapMonId != 0) { - AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + AddMovePoints(PTS_FAINT, 0, atkSide ^ BIT_SIDE, (tvPtr->pos[atkSide][atkArrId].wrapMonId - 1) * 4 + tvPtr->pos[atkSide][atkArrId].wrapMoveSlot); } break; - case 7: + case FNT_SPIKES: if (tvPtr->side[atkSide].spikesMonId != 0) { - AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + AddMovePoints(PTS_FAINT, 0, atkSide ^ BIT_SIDE, (tvPtr->side[atkSide].spikesMonId - 1) * 4 + tvPtr->side[atkSide].spikesMoveSlot); } break; - case 8: + case FNT_FUTURE_SIGHT: if (tvPtr->side[atkSide].futureSightMonId != 0) { - AddMovePoints(20, 0, atkSide, + AddMovePoints(PTS_FAINT_SET_UP, 0, atkSide, (tvPtr->side[atkSide].futureSightMonId - 1) * 4 + tvPtr->side[atkSide].futureSightMoveSlot); } break; - case 9: + case FNT_DOOM_DESIRE: if (tvPtr->side[atkSide].doomDesireMonId != 0) { - AddMovePoints(20, 0, atkSide, + AddMovePoints(PTS_FAINT_SET_UP, 0, atkSide, (tvPtr->side[atkSide].doomDesireMonId - 1) * 4 + tvPtr->side[atkSide].doomDesireMoveSlot); } break; - case 10: + case FNT_PERISH_SONG: if (tvPtr->side[atkSide].perishSong && tvPtr->side[atkSide].perishSongMonId - 1 != gBattlerPartyIndexes[gBattlerAttacker]) { - AddMovePoints(19, 0, atkSide, + AddMovePoints(PTS_FAINT, 0, atkSide, (tvPtr->side[atkSide].perishSongMonId - 1) * 4 + tvPtr->side[atkSide].perishSongMoveSlot); } if (tvPtr->side[atkSide ^ BIT_SIDE].perishSong) { - AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + AddMovePoints(PTS_FAINT, 0, atkSide ^ BIT_SIDE, (tvPtr->side[atkSide ^ BIT_SIDE].perishSongMonId - 1) * 4 + tvPtr->side[atkSide ^ BIT_SIDE].perishSongMoveSlot); } break; - case 11: + case FNT_DESTINY_BOND: if (tvPtr->side[atkSide ^ BIT_SIDE].destinyBondMonId != 0) { - AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + AddMovePoints(PTS_FAINT, 0, atkSide ^ BIT_SIDE, (tvPtr->side[atkSide ^ BIT_SIDE].destinyBondMonId - 1) * 4 + tvPtr->side[atkSide ^ BIT_SIDE].destinyBondMoveSlot); } break; - case 12: + case FNT_CONFUSION: for (i = 0; i < 2; i++) { if (tvPtr->pos[atkSide][i].confusionMonId != 0) { - AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + AddMovePoints(PTS_FAINT, 0, atkSide ^ BIT_SIDE, (tvPtr->pos[atkSide][i].confusionMonId - 1) * 4 + tvPtr->pos[atkSide][i].confusionMoveSlot); } } break; - case 13: + case FNT_EXPLOSION: if (tvPtr->side[atkSide].explosion) { - AddMovePoints(19, 0, atkSide, + AddMovePoints(PTS_FAINT, 0, atkSide, (tvPtr->side[atkSide].explosionMonId - 1) * 4 + tvPtr->side[atkSide].explosionMoveSlot); } if (tvPtr->side[atkSide ^ BIT_SIDE].explosion) { - AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + AddMovePoints(PTS_FAINT, 0, atkSide ^ BIT_SIDE, (tvPtr->side[atkSide ^ BIT_SIDE].explosionMonId - 1) * 4 + tvPtr->side[atkSide ^ BIT_SIDE].explosionMoveSlot); } break; - case 14: + case FNT_RECOIL: if (targetFainted == TRUE) { - AddMovePoints(20, 0, atkSide, + AddMovePoints(PTS_FAINT_SET_UP, 0, atkSide, (gBattlerPartyIndexes[gBattlerAttacker]) * 4 + tvPtr->side[atkSide].usedMoveSlot); } break; - case 15: + case FNT_OTHER: break; } } else { - if (tvPtr->side[defSide].faintCause == 7) + if (tvPtr->side[defSide].faintCause == FNT_SPIKES) { if (tvPtr->side[defSide].spikesMonId != 0) { - AddMovePoints(19, 0, defSide ^ BIT_SIDE, + AddMovePoints(PTS_FAINT, 0, defSide ^ BIT_SIDE, (tvPtr->side[defSide].spikesMonId - 1) * 4 + tvPtr->side[defSide].spikesMoveSlot); } } else { - AddMovePoints(20, 0, atkSide, + AddMovePoints(PTS_FAINT_SET_UP, 0, atkSide, (gBattlerPartyIndexes[gBattlerAttacker]) * 4 + tvPtr->side[atkSide].usedMoveSlot); } } @@ -1061,11 +1419,11 @@ static void AddPointsOnFainting(bool8 targetFainted) static void TrySetBattleSeminarShow(void) { s32 i; - s32 dmgByMove[4]; + s32 dmgByMove[MAX_MON_MOVES]; u16 powerOverride; u16 currMoveSaved; - if (gBattleTypeFlags & (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) return; else if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) return; @@ -1087,9 +1445,9 @@ static void TrySetBattleSeminarShow(void) if (currMoveSaved == sVariableDmgMoves[i]) break; i++; - } while (sVariableDmgMoves[i] != 0xFFFF); + } while (sVariableDmgMoves[i] != TABLE_END); - if (sVariableDmgMoves[i] != 0xFFFF) + if (sVariableDmgMoves[i] != TABLE_END) return; dmgByMove[gMoveSelectionCursor[gBattlerAttacker]] = gBattleMoveDamage; @@ -1138,7 +1496,7 @@ static void TrySetBattleSeminarShow(void) opponentSpecies = GetMonData(&gEnemyParty [gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_SPECIES, NULL); playerSpecies = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_SPECIES, NULL); - sub_80EE35C(opponentSpecies, playerSpecies, gMoveSelectionCursor[gBattlerAttacker], gBattleMons[gBattlerAttacker].moves, gBattleMons[gBattlerAttacker].moves[bestMoveId]); + TryPutBattleSeminarOnAir(opponentSpecies, playerSpecies, gMoveSelectionCursor[gBattlerAttacker], gBattleMons[gBattlerAttacker].moves, gBattleMons[gBattlerAttacker].moves[bestMoveId]); break; } } @@ -1162,9 +1520,9 @@ static bool8 ShouldCalculateDamage(u16 moveId, s32 *dmg, u16 *powerOverride) if (moveId == sVariableDmgMoves[i]) break; i++; - } while (sVariableDmgMoves[i] != 0xFFFF); + } while (sVariableDmgMoves[i] != TABLE_END); - if (sVariableDmgMoves[i] != 0xFFFF) + if (sVariableDmgMoves[i] != TABLE_END) { *dmg = 0; return FALSE; @@ -1193,8 +1551,8 @@ void BattleTv_ClearExplosionFaintCause(void) { struct BattleTv *tvPtr = &gBattleStruct->tv; - tvPtr->side[B_SIDE_PLAYER].faintCause = 0; - tvPtr->side[B_SIDE_OPPONENT].faintCause = 0; + tvPtr->side[B_SIDE_PLAYER].faintCause = FNT_NONE; + tvPtr->side[B_SIDE_OPPONENT].faintCause = FNT_NONE; tvPtr->side[B_SIDE_PLAYER].faintCauseMonId = 0; tvPtr->side[B_SIDE_OPPONENT].faintCauseMonId = 0; @@ -1205,8 +1563,8 @@ void BattleTv_ClearExplosionFaintCause(void) tvPtr->side[B_SIDE_PLAYER].explosionMoveSlot = 0; tvPtr->side[B_SIDE_OPPONENT].explosionMoveSlot = 0; - tvPtr->side[B_SIDE_PLAYER].explosion = 0; - tvPtr->side[B_SIDE_OPPONENT].explosion = 0; + tvPtr->side[B_SIDE_PLAYER].explosion = FALSE; + tvPtr->side[B_SIDE_OPPONENT].explosion = FALSE; } } @@ -1236,11 +1594,11 @@ u8 GetBattlerMoveSlotId(u8 battlerId, u16 moveId) static void AddPointsBasedOnWeather(u16 weatherFlags, u16 moveId, u8 moveSlot) { if (weatherFlags & WEATHER_RAIN_ANY) - AddMovePoints(3, moveId, moveSlot, 0); + AddMovePoints(PTS_RAIN, moveId, moveSlot, 0); else if (weatherFlags & WEATHER_SUN_ANY) - AddMovePoints(4, moveId, moveSlot, 0); + AddMovePoints(PTS_SUN, moveId, moveSlot, 0); else if (weatherFlags & WEATHER_SANDSTORM_ANY) - AddMovePoints(5, moveId, moveSlot, 0); + AddMovePoints(PTS_SANDSTORM, moveId, moveSlot, 0); else if (weatherFlags & WEATHER_HAIL_ANY) - AddMovePoints(6, moveId, moveSlot, 0); + AddMovePoints(PTS_HAIL, moveId, moveSlot, 0); } diff --git a/src/battle_util.c b/src/battle_util.c index e929de091..7ea4566d2 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -452,7 +452,7 @@ void HandleAction_Run(void) { gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber]; - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) { gCurrentTurnActionNumber = gBattlersCount; @@ -2245,7 +2245,7 @@ bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2) } else if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if (gBattleTypeFlags & BATTLE_TYPE_x800000) + if (gBattleTypeFlags & BATTLE_TYPE_TOWER_LINK_MULTI) { if (GetBattlerSide(battler) == B_SIDE_PLAYER) { @@ -3966,7 +3966,7 @@ u8 IsMonDisobedient(void) s32 calc; u8 obedienceLevel = 0; - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) return 0; if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) return 0; diff --git a/src/berry_blender.c b/src/berry_blender.c index 573affbd5..08a25c58a 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -2390,7 +2390,7 @@ static s16 Debug_GetGameTimeStage(void) static void CalculatePokeblock(struct BlenderBerry *berries, struct Pokeblock *pokeblock, u8 numPlayers, u8 *flavors, u16 maxRPM) { s32 i, j; - s32 multiuseVar, var2; + s32 multiuseVar; u8 numNegatives; for (i = 0; i < FLAVOR_COUNT + 1; i++) diff --git a/src/berry_crush.c b/src/berry_crush.c index 90bc7150d..84e2e2eba 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -877,7 +877,7 @@ void StartBerryCrush(MainCallback callback) static void GetBerryFromBag(void) { if (gSpecialVar_ItemId < FIRST_BERRY_INDEX || gSpecialVar_ItemId > LAST_BERRY_INDEX + 1) - gSpecialVar_ItemId = ITEM_CHERI_BERRY; + gSpecialVar_ItemId = FIRST_BERRY_INDEX; else RemoveBagItem(gSpecialVar_ItemId, 1); @@ -1573,7 +1573,6 @@ static void Task_ShowBerryCrushRankings(u8 taskId) u8 i = 0, j, xPos, yPos; u32 score = 0; s16 *data = gTasks[taskId].data; - u8 *str; switch (data[0]) { @@ -1714,8 +1713,7 @@ void sub_8022588(struct BerryCrushGame *r5) void sub_8022600(struct BerryCrushGame *r6) { - u8 r7, r2; - u8 *r4; + u8 r7; for (r7 = 0; r7 < r6->unk9; ++r7) { diff --git a/src/cable_club.c b/src/cable_club.c index f02683c9d..cd0baefcd 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -128,8 +128,6 @@ static void UpdateLinkPlayerCountDisplay(u8 taskId, u8 numPlayers) static u32 ExchangeDataAndGetLinkupStatus(u8 minPlayers, u8 maxPlayers) { - int playerCount; - switch (GetLinkPlayerDataExchangeStatusTimed(minPlayers, maxPlayers)) { case EXCHANGE_COMPLETE: @@ -511,7 +509,6 @@ static void FinishLinkup(u16 *linkupStatus, u32 taskId) static void Task_LinkupAwaitTrainerCardData(u8 taskId) { u8 index; - struct TrainerCard *trainerCards; if (CheckLinkErrored(taskId) == TRUE) return; @@ -993,7 +990,7 @@ static void CB2_ReturnFromUnionRoomBattle(void) void CB2_ReturnFromCableClubBattle(void) { - gBattleTypeFlags &= ~BATTLE_TYPE_20; + gBattleTypeFlags &= ~BATTLE_TYPE_LINK_IN_BATTLE; Overworld_ResetMapMusic(); LoadPlayerParty(); SavePlayerBag(); diff --git a/src/contest.c b/src/contest.c index 02f3089f9..d2c18e3a1 100644 --- a/src/contest.c +++ b/src/contest.c @@ -4419,7 +4419,6 @@ static void CalculateAppealMoveImpact(u8 contestant) u16 move; u8 effect; u8 rnd; - bool8 canUseTurn; s32 i; eContestantStatus[contestant].appeal = 0; diff --git a/src/credits.c b/src/credits.c index 80c67f393..946d5d5b9 100644 --- a/src/credits.c +++ b/src/credits.c @@ -1159,7 +1159,7 @@ static void CB2_RunCreditsSequence(void) static void sub_8175548(void) { ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sBackgroundTemplates, 1); + InitBgsFromTemplates(0, sBackgroundTemplates, ARRAY_COUNT(sBackgroundTemplates)); SetBgTilemapBuffer(0, AllocZeroed(BG_SCREEN_SIZE)); LoadPalette(gUnknown_085E56F0, 0x80, 0x40); InitWindows(sWindowTemplates); @@ -1306,8 +1306,6 @@ static void sub_8175808(u8 taskIdA) static void c2_080C9BFC(u8 taskIdA) { - u16 backup; - SetVBlankCallback(NULL); if (sub_8176AB0(gTasks[taskIdA].data[TDA_7], taskIdA)) diff --git a/src/data/bard_music/bard_sounds.h b/src/data/bard_music/bard_sounds.h index 4a0911726..1ec1f0d97 100644 --- a/src/data/bard_music/bard_sounds.h +++ b/src/data/bard_music/bard_sounds.h @@ -24,29 +24,29 @@ #include "events.h" #include "trendysaying.h" -const struct BardSound (*const gBardSoundsTable[])[6] = { - NULL, - gBardSounds_Trainer, - gBardSounds_Status, - gBardSounds_Battle, - gBardSounds_Greetings, - gBardSounds_People, - gBardSounds_Voices, - gBardSounds_Speech, - gBardSounds_Endings, - gBardSounds_Feelings, - gBardSounds_Conditions, - gBardSounds_Actions, - gBardSounds_Lifestyle, - gBardSounds_Hobbies, - gBardSounds_Time, - gBardSounds_Misc, - gBardSounds_Adjectives, - gBardSounds_Events, - NULL, - NULL, - gBardSounds_TrendySaying, - NULL +const struct BardSound (*const gBardSoundsTable[EC_NUM_GROUPS])[6] = { + [EC_GROUP_POKEMON] = NULL, // Handled by gBardSounds_Pokemon + [EC_GROUP_TRAINER] = gBardSounds_Trainer, + [EC_GROUP_STATUS] = gBardSounds_Status, + [EC_GROUP_BATTLE] = gBardSounds_Battle, + [EC_GROUP_GREETINGS] = gBardSounds_Greetings, + [EC_GROUP_PEOPLE] = gBardSounds_People, + [EC_GROUP_VOICES] = gBardSounds_Voices, + [EC_GROUP_SPEECH] = gBardSounds_Speech, + [EC_GROUP_ENDINGS] = gBardSounds_Endings, + [EC_GROUP_FEELINGS] = gBardSounds_Feelings, + [EC_GROUP_CONDITIONS] = gBardSounds_Conditions, + [EC_GROUP_ACTIONS] = gBardSounds_Actions, + [EC_GROUP_LIFESTYLE] = gBardSounds_Lifestyle, + [EC_GROUP_HOBBIES] = gBardSounds_Hobbies, + [EC_GROUP_TIME] = gBardSounds_Time, + [EC_GROUP_MISC] = gBardSounds_Misc, + [EC_GROUP_ADJECTIVES] = gBardSounds_Adjectives, + [EC_GROUP_EVENTS] = gBardSounds_Events, + [EC_GROUP_MOVE_1] = NULL, // Handled by gBardSounds_Moves + [EC_GROUP_MOVE_2] = NULL, // Handled by gBardSounds_Moves + [EC_GROUP_TRENDY_SAYING] = gBardSounds_TrendySaying, + [EC_GROUP_POKEMON_2] = NULL // Handled by gBardSounds_Pokemon }; #endif //GUARD_BARD_SOUNDS_TABLE_H diff --git a/src/data/battle_frontier/trainer_hill.h b/src/data/battle_frontier/trainer_hill.h index 0268526a6..f090385b0 100644 --- a/src/data/battle_frontier/trainer_hill.h +++ b/src/data/battle_frontier/trainer_hill.h @@ -1244,12 +1244,12 @@ static const struct TrHillFloor sDataTagNormal_Floors[] = .attackEV = 252, .speedEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0xCB, .nickname = _("SKITTY"), @@ -2717,11 +2717,11 @@ static const struct TrHillFloor sDataTagVariety_Floors[] = { .spAttackEV = 255, .otId = TRAINER_HILL_OTID, .hpIV = 30, - .attackIV = 31, + .attackIV = MAX_PER_STAT_IVS, .defenseIV = 30, - .speedIV = 31, + .speedIV = MAX_PER_STAT_IVS, .spAttackIV = 30, - .spDefenseIV = 31, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x202, .nickname = _("UNOWN"), @@ -2738,11 +2738,11 @@ static const struct TrHillFloor sDataTagVariety_Floors[] = { .spAttackEV = 255, .otId = TRAINER_HILL_OTID, .hpIV = 30, - .attackIV = 31, - .defenseIV = 31, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, .speedIV = 30, .spAttackIV = 30, - .spDefenseIV = 31, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x10001, .nickname = _("UNOWN"), @@ -2921,11 +2921,11 @@ static const struct TrHillFloor sDataTagVariety_Floors[] = { .spAttackEV = 255, .otId = TRAINER_HILL_OTID, .hpIV = 30, - .attackIV = 31, + .attackIV = MAX_PER_STAT_IVS, .defenseIV = 30, .speedIV = 30, .spAttackIV = 30, - .spDefenseIV = 31, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x302, .nickname = _("UNOWN"), @@ -2941,10 +2941,10 @@ static const struct TrHillFloor sDataTagVariety_Floors[] = { .hpEV = 255, .attackEV = 255, .otId = TRAINER_HILL_OTID, - .hpIV = 31, + .hpIV = MAX_PER_STAT_IVS, .attackIV = 30, - .defenseIV = 31, - .speedIV = 31, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, .spAttackIV = 30, .spDefenseIV = 30, .abilityNum = 0, @@ -2962,12 +2962,12 @@ static const struct TrHillFloor sDataTagVariety_Floors[] = { .hpEV = 255, .spAttackEV = 255, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, .defenseIV = 30, .speedIV = 30, - .spAttackIV = 31, - .spDefenseIV = 31, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x301, .nickname = _("UNOWN"), @@ -3820,12 +3820,12 @@ static const struct TrHillFloor sDataTagUnique_Floors[] = { .speedEV = 252, .spAttackEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x32, .nickname = _("SMOOCHUM"), @@ -3842,12 +3842,12 @@ static const struct TrHillFloor sDataTagUnique_Floors[] = { .speedEV = 252, .spAttackEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0xC8, .nickname = _("AZURILL"), @@ -3864,12 +3864,12 @@ static const struct TrHillFloor sDataTagUnique_Floors[] = { .speedEV = 252, .spAttackEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x0, .nickname = _("ELEKID"), @@ -3886,12 +3886,12 @@ static const struct TrHillFloor sDataTagUnique_Floors[] = { .attackEV = 252, .speedEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x0, .nickname = _("CLEFFA"), @@ -3908,12 +3908,12 @@ static const struct TrHillFloor sDataTagUnique_Floors[] = { .defenseEV = 130, .spDefenseEV = 130, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x84, .nickname = _("WYNAUT"), @@ -3930,12 +3930,12 @@ static const struct TrHillFloor sDataTagUnique_Floors[] = { .speedEV = 252, .spAttackEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0xF, .nickname = _("MAGBY"), @@ -4319,12 +4319,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 252, .defenseEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x35, .nickname = _("SNORLAX"), @@ -4341,12 +4341,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 252, .speedEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x3, .nickname = _("MILTANK"), @@ -4363,12 +4363,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 252, .spAttackEV = 6, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x7F, .nickname = _("URSARING"), @@ -4385,12 +4385,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 252, .spDefenseEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x80, .nickname = _("SLAKING"), @@ -4407,12 +4407,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 252, .speedEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x3, .nickname = _("KANGASKHAN"), @@ -4429,12 +4429,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 252, .speedEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x80, .nickname = _("ZANGOOSE"), @@ -4464,12 +4464,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .defenseEV = 110, .spAttackEV = 200, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 1, .personality = 0xF, .nickname = _("SLOWKING"), @@ -4486,12 +4486,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 252, .spAttackEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x28, .nickname = _("ESPEON"), @@ -4508,12 +4508,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 252, .spAttackEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 1, .personality = 0xF, .nickname = _("STARMIE"), @@ -4530,12 +4530,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 252, .spAttackEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0xF, .nickname = _("GENGAR"), @@ -4552,12 +4552,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 252, .spAttackEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0xF, .nickname = _("GARDEVOIR"), @@ -4574,12 +4574,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 252, .spAttackEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0xF, .nickname = _("ALAKAZAM"), @@ -4641,12 +4641,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 252, .spDefenseEV = 6, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x3, .nickname = _("SWELLOW"), @@ -4663,12 +4663,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 252, .spDefenseEV = 6, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x3, .nickname = _("MACHAMP"), @@ -4685,12 +4685,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 252, .spDefenseEV = 6, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x3, .nickname = _("URSARING"), @@ -4707,12 +4707,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 252, .spDefenseEV = 6, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x80, .nickname = _("KINGLER"), @@ -4729,12 +4729,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 252, .defenseEV = 6, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x80, .nickname = _("TYRANITAR"), @@ -4751,12 +4751,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 252, .spDefenseEV = 6, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x80, .nickname = _("DRAGONITE"), @@ -4786,12 +4786,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 252, .spAttackEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0xA, .nickname = _("JOLTEON"), @@ -4808,12 +4808,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 252, .spAttackEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0xA, .nickname = _("ALAKAZAM"), @@ -4830,12 +4830,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 252, .spAttackEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 1, .personality = 0xA, .nickname = _("STARMIE"), @@ -4852,12 +4852,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .defenseEV = 252, .spDefenseEV = 6, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x82, .nickname = _("DUSCLOPS"), @@ -4874,12 +4874,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 252, .spAttackEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0xD2, .nickname = _("NINETALES"), @@ -4896,12 +4896,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .defenseEV = 252, .spDefenseEV = 6, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x85, .nickname = _("BANETTE"), @@ -4963,12 +4963,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .defenseEV = 130, .spDefenseEV = 130, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x94, .nickname = _("WOBBUFFET"), @@ -4985,12 +4985,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .defenseEV = 130, .spDefenseEV = 130, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x85, .nickname = _("EXPLOUD"), @@ -5007,12 +5007,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .defenseEV = 130, .spDefenseEV = 130, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x0, .nickname = _("CROBAT"), @@ -5029,12 +5029,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 252, .speedEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 1, .personality = 0xD, .nickname = _("DUGTRIO"), @@ -5051,12 +5051,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .defenseEV = 252, .spAttackEV = 6, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x5, .nickname = _("ELECTRODE"), @@ -5073,12 +5073,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 252, .spDefenseEV = 6, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x14, .nickname = _("GENGAR"), @@ -5108,12 +5108,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .defenseEV = 130, .spDefenseEV = 130, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x82, .nickname = _("LAPRAS"), @@ -5130,12 +5130,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .defenseEV = 6, .speedEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x8A, .nickname = _("ABSOL"), @@ -5152,12 +5152,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .spAttackEV = 6, .spDefenseEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x0, .nickname = _("ALTARIA"), @@ -5174,12 +5174,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 252, .spAttackEV = 6, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x14, .nickname = _("DEWGONG"), @@ -5196,12 +5196,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .spAttackEV = 6, .spDefenseEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 1, .personality = 0x14, .nickname = _("POLITOED"), @@ -5218,12 +5218,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 6, .spDefenseEV = 252, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 1, .personality = 0x17, .nickname = _("MAROWAK"), @@ -5285,12 +5285,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 200, .spDefenseEV = 200, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x3, .nickname = _("FORRETRESS"), @@ -5306,12 +5306,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 255, .spAttackEV = 255, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 1, .personality = 0xC, .nickname = _("ELECTRODE"), @@ -5327,12 +5327,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 255, .spAttackEV = 255, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x7F, .nickname = _("EXEGGUTOR"), @@ -5349,12 +5349,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .defenseEV = 200, .spDefenseEV = 200, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x93, .nickname = _("DUSCLOPS"), @@ -5370,12 +5370,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 255, .spAttackEV = 255, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0xF, .nickname = _("NINETALES"), @@ -5391,12 +5391,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .hpEV = 255, .spAttackEV = 255, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x96, .nickname = _("BANETTE"), @@ -5425,12 +5425,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 255, .spAttackEV = 255, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x95, .nickname = _("SALAMENCE"), @@ -5446,12 +5446,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .speedEV = 255, .spAttackEV = 255, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x8C, .nickname = _("GENGAR"), @@ -5467,12 +5467,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 255, .speedEV = 255, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x3, .nickname = _("GYARADOS"), @@ -5488,12 +5488,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .attackEV = 255, .speedEV = 255, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x3, .nickname = _("GENGAR"), @@ -5510,12 +5510,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .defenseEV = 200, .spDefenseEV = 200, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x14, .nickname = _("DUSCLOPS"), @@ -5532,12 +5532,12 @@ static const struct TrHillFloor sDataTagExpert_Floors[] = { .defenseEV = 180, .spDefenseEV = 150, .otId = TRAINER_HILL_OTID, - .hpIV = 31, - .attackIV = 31, - .defenseIV = 31, - .speedIV = 31, - .spAttackIV = 31, - .spDefenseIV = 31, + .hpIV = MAX_PER_STAT_IVS, + .attackIV = MAX_PER_STAT_IVS, + .defenseIV = MAX_PER_STAT_IVS, + .speedIV = MAX_PER_STAT_IVS, + .spAttackIV = MAX_PER_STAT_IVS, + .spDefenseIV = MAX_PER_STAT_IVS, .abilityNum = 0, .personality = 0x85, .nickname = _("MISDREAVUS"), diff --git a/src/data/decoration/header.h b/src/data/decoration/header.h index 55458c7a3..c57498828 100644 --- a/src/data/decoration/header.h +++ b/src/data/decoration/header.h @@ -1,1091 +1,1454 @@ -const struct Decoration gDecorations[] = { +const struct Decoration gDecorations[] = +{ + [DECOR_NONE] = { - DECOR_NONE, - _("SMALL DESK"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_1x1, - DECORCAT_DESK, - 0, - DecorDesc_SMALL_DESK, - DecorGfx_SMALL_DESK - }, { - DECOR_SMALL_DESK, - _("SMALL DESK"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_1x1, - DECORCAT_DESK, - 3000, - DecorDesc_SMALL_DESK, - DecorGfx_SMALL_DESK - }, { - DECOR_POKEMON_DESK, - _("POKéMON DESK"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_1x1, - DECORCAT_DESK, - 3000, - DecorDesc_POKEMON_DESK, - DecorGfx_POKEMON_DESK - }, { - DECOR_HEAVY_DESK, - _("HEAVY DESK"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_3x2, - DECORCAT_DESK, - 6000, - DecorDesc_HEAVY_DESK, - DecorGfx_HEAVY_DESK - }, { - DECOR_RAGGED_DESK, - _("RAGGED DESK"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_3x2, - DECORCAT_DESK, - 6000, - DecorDesc_RAGGED_DESK, - DecorGfx_RAGGED_DESK - }, { - DECOR_COMFORT_DESK, - _("COMFORT DESK"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_3x2, - DECORCAT_DESK, - 6000, - DecorDesc_COMFORT_DESK, - DecorGfx_COMFORT_DESK - }, { - DECOR_PRETTY_DESK, - _("PRETTY DESK"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_3x3, - DECORCAT_DESK, - 9000, - DecorDesc_PRETTY_DESK, - DecorGfx_PRETTY_DESK - }, { - DECOR_BRICK_DESK, - _("BRICK DESK"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_3x3, - DECORCAT_DESK, - 9000, - DecorDesc_BRICK_DESK, - DecorGfx_BRICK_DESK - }, { - DECOR_CAMP_DESK, - _("CAMP DESK"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_3x3, - DECORCAT_DESK, - 9000, - DecorDesc_CAMP_DESK, - DecorGfx_CAMP_DESK - }, { - DECOR_HARD_DESK, - _("HARD DESK"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_3x3, - DECORCAT_DESK, - 9000, - DecorDesc_HARD_DESK, - DecorGfx_HARD_DESK - }, { - DECOR_SMALL_CHAIR, - _("SMALL CHAIR"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_CHAIR, - 2000, - DecorDesc_SMALL_CHAIR, - DecorGfx_SMALL_CHAIR - }, { - DECOR_POKEMON_CHAIR, - _("POKéMON CHAIR"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_CHAIR, - 2000, - DecorDesc_POKEMON_CHAIR, - DecorGfx_POKEMON_CHAIR - }, { - DECOR_HEAVY_CHAIR, - _("HEAVY CHAIR"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_CHAIR, - 2000, - DecorDesc_HEAVY_CHAIR, - DecorGfx_HEAVY_CHAIR - }, { - DECOR_PRETTY_CHAIR, - _("PRETTY CHAIR"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_CHAIR, - 2000, - DecorDesc_PRETTY_CHAIR, - DecorGfx_PRETTY_CHAIR - }, { - DECOR_COMFORT_CHAIR, - _("COMFORT CHAIR"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_CHAIR, - 2000, - DecorDesc_COMFORT_CHAIR, - DecorGfx_COMFORT_CHAIR - }, { - DECOR_RAGGED_CHAIR, - _("RAGGED CHAIR"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_CHAIR, - 2000, - DecorDesc_RAGGED_CHAIR, - DecorGfx_RAGGED_CHAIR - }, { - DECOR_BRICK_CHAIR, - _("BRICK CHAIR"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_CHAIR, - 2000, - DecorDesc_BRICK_CHAIR, - DecorGfx_BRICK_CHAIR - }, { - DECOR_CAMP_CHAIR, - _("CAMP CHAIR"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_CHAIR, - 2000, - DecorDesc_CAMP_CHAIR, - DecorGfx_CAMP_CHAIR - }, { - DECOR_HARD_CHAIR, - _("HARD CHAIR"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_CHAIR, - 2000, - DecorDesc_HARD_CHAIR, - DecorGfx_HARD_CHAIR - }, { - DECOR_RED_PLANT, - _("RED PLANT"), - DECORPERM_BEHIND_FLOOR, - DECORSHAPE_1x2, - DECORCAT_PLANT, - 3000, - DecorDesc_RED_PLANT, - DecorGfx_RED_PLANT - }, { - DECOR_TROPICAL_PLANT, - _("TROPICAL PLANT"), - DECORPERM_BEHIND_FLOOR, - DECORSHAPE_1x2, - DECORCAT_PLANT, - 3000, - DecorDesc_TROPICAL_PLANT, - DecorGfx_TROPICAL_PLANT - }, { - DECOR_PRETTY_FLOWERS, - _("PRETTY FLOWERS"), - DECORPERM_BEHIND_FLOOR, - DECORSHAPE_1x2, - DECORCAT_PLANT, - 3000, - DecorDesc_PRETTY_FLOWERS, - DecorGfx_PRETTY_FLOWERS - }, { - DECOR_COLORFUL_PLANT, - _("COLORFUL PLANT"), - DECORPERM_BEHIND_FLOOR, - DECORSHAPE_2x2, - DECORCAT_PLANT, - 5000, - DecorDesc_COLORFUL_PLANT, - DecorGfx_COLORFUL_PLANT - }, { - DECOR_BIG_PLANT, - _("BIG PLANT"), - DECORPERM_BEHIND_FLOOR, - DECORSHAPE_2x2, - DECORCAT_PLANT, - 5000, - DecorDesc_BIG_PLANT, - DecorGfx_BIG_PLANT - }, { - DECOR_GORGEOUS_PLANT, - _("GORGEOUS PLANT"), - DECORPERM_BEHIND_FLOOR, - DECORSHAPE_2x2, - DECORCAT_PLANT, - 5000, - DecorDesc_GORGEOUS_PLANT, - DecorGfx_GORGEOUS_PLANT - }, { - DECOR_RED_BRICK, - _("RED BRICK"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_1x2, - DECORCAT_ORNAMENT, - 500, - DecorDesc_RED_BRICK, - DecorGfx_RED_BRICK - }, { - DECOR_YELLOW_BRICK, - _("YELLOW BRICK"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_1x2, - DECORCAT_ORNAMENT, - 500, - DecorDesc_YELLOW_BRICK, - DecorGfx_YELLOW_BRICK - }, { - DECOR_BLUE_BRICK, - _("BLUE BRICK"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_1x2, - DECORCAT_ORNAMENT, - 500, - DecorDesc_BLUE_BRICK, - DecorGfx_BLUE_BRICK - }, { - DECOR_RED_BALLOON, - _("RED BALLOON"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_ORNAMENT, - 500, - DecorDesc_RED_BALLOON, - DecorGfx_RED_BALLOON - }, { - DECOR_BLUE_BALLOON, - _("BLUE BALLOON"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_ORNAMENT, - 500, - DecorDesc_BLUE_BALLOON, - DecorGfx_BLUE_BALLOON - }, { - DECOR_YELLOW_BALLOON, - _("YELLOW BALLOON"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_ORNAMENT, - 500, - DecorDesc_YELLOW_BALLOON, - DecorGfx_YELLOW_BALLOON - }, { - DECOR_RED_TENT, - _("RED TENT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_3x3, - DECORCAT_ORNAMENT, - 10000, - DecorDesc_RED_TENT, - DecorGfx_RED_TENT - }, { - DECOR_BLUE_TENT, - _("BLUE TENT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_3x3, - DECORCAT_ORNAMENT, - 10000, - DecorDesc_BLUE_TENT, - DecorGfx_BLUE_TENT - }, { - DECOR_SOLID_BOARD, - _("SOLID BOARD"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x2, - DECORCAT_ORNAMENT, - 3000, - DecorDesc_SOLID_BOARD, - DecorGfx_SOLID_BOARD - }, { - DECOR_SLIDE, - _("SLIDE"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_2x4, - DECORCAT_ORNAMENT, - 8000, - DecorDesc_SLIDE, - DecorGfx_SLIDE - }, { - DECOR_FENCE_LENGTH, - _("FENCE LENGTH"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_1x1, - DECORCAT_ORNAMENT, - 500, - DecorDesc_FENCE_LENGTH, - DecorGfx_FENCE_LENGTH - }, { - DECOR_FENCE_WIDTH, - _("FENCE WIDTH"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_1x1, - DECORCAT_ORNAMENT, - 500, - DecorDesc_FENCE_WIDTH, - DecorGfx_FENCE_WIDTH - }, { - DECOR_TIRE, - _("TIRE"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_2x2, - DECORCAT_ORNAMENT, - 800, - DecorDesc_TIRE, - DecorGfx_TIRE - }, { - DECOR_STAND, - _("STAND"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_4x2, - DECORCAT_ORNAMENT, - 7000, - DecorDesc_STAND, - DecorGfx_STAND - }, { - DECOR_MUD_BALL, - _("MUD BALL"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_ORNAMENT, - 200, - DecorDesc_MUD_BALL, - DecorGfx_MUD_BALL - }, { - DECOR_BREAKABLE_DOOR, - _("BREAKABLE DOOR"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x2, - DECORCAT_ORNAMENT, - 3000, - DecorDesc_BREAKABLE_DOOR, - DecorGfx_BREAKABLE_DOOR - }, { - DECOR_SAND_ORNAMENT, - _("SAND ORNAMENT"), - DECORPERM_BEHIND_FLOOR, - DECORSHAPE_1x2, - DECORCAT_ORNAMENT, - 3000, - DecorDesc_SAND_ORNAMENT, - DecorGfx_SAND_ORNAMENT - }, { - DECOR_SILVER_SHIELD, - _("SILVER SHIELD"), - DECORPERM_BEHIND_FLOOR, - DECORSHAPE_1x2, - DECORCAT_ORNAMENT, - 0, - DecorDesc_SILVER_SHIELD, - DecorGfx_SILVER_SHIELD - }, { - DECOR_GOLD_SHIELD, - _("GOLD SHIELD"), - DECORPERM_BEHIND_FLOOR, - DECORSHAPE_1x2, - DECORCAT_ORNAMENT, - 0, - DecorDesc_GOLD_SHIELD, - DecorGfx_GOLD_SHIELD - }, { - DECOR_GLASS_ORNAMENT, - _("GLASS ORNAMENT"), - DECORPERM_BEHIND_FLOOR, - DECORSHAPE_1x2, - DECORCAT_ORNAMENT, - 0, - DecorDesc_GLASS_ORNAMENT, - DecorGfx_GLASS_ORNAMENT - }, { - DECOR_TV, - _("TV"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_1x1, - DECORCAT_ORNAMENT, - 3000, - DecorDesc_TV, - DecorGfx_TV - }, { - DECOR_ROUND_TV, - _("ROUND TV"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_1x1, - DECORCAT_ORNAMENT, - 4000, - DecorDesc_ROUND_TV, - DecorGfx_ROUND_TV - }, { - DECOR_CUTE_TV, - _("CUTE TV"), - DECORPERM_SOLID_FLOOR, - DECORSHAPE_1x1, - DECORCAT_ORNAMENT, - 4000, - DecorDesc_CUTE_TV, - DecorGfx_CUTE_TV - }, { - DECOR_GLITTER_MAT, - _("GLITTER MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_MAT, - 2000, - DecorDesc_GLITTER_MAT, - DecorGfx_GLITTER_MAT - }, { - DECOR_JUMP_MAT, - _("JUMP MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_MAT, - 2000, - DecorDesc_JUMP_MAT, - DecorGfx_JUMP_MAT - }, { - DECOR_SPIN_MAT, - _("SPIN MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_MAT, - 2000, - DecorDesc_SPIN_MAT, - DecorGfx_SPIN_MAT - }, { - DECOR_C_LOW_NOTE_MAT, - _("C Low NOTE MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_MAT, - 500, - DecorDesc_C_LOW_NOTE_MAT, - DecorGfx_C_LOW_NOTE_MAT - }, { - DECOR_D_NOTE_MAT, - _("D NOTE MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_MAT, - 500, - DecorDesc_D_NOTE_MAT, - DecorGfx_D_NOTE_MAT - }, { - DECOR_E_NOTE_MAT, - _("E NOTE MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_MAT, - 500, - DecorDesc_E_NOTE_MAT, - DecorGfx_E_NOTE_MAT - }, { - DECOR_F_NOTE_MAT, - _("F NOTE MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_MAT, - 500, - DecorDesc_F_NOTE_MAT, - DecorGfx_F_NOTE_MAT - }, { - DECOR_G_NOTE_MAT, - _("G NOTE MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_MAT, - 500, - DecorDesc_G_NOTE_MAT, - DecorGfx_G_NOTE_MAT - }, { - DECOR_A_NOTE_MAT, - _("A NOTE MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_MAT, - 500, - DecorDesc_A_NOTE_MAT, - DecorGfx_A_NOTE_MAT - }, { - DECOR_B_NOTE_MAT, - _("B NOTE MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_MAT, - 500, - DecorDesc_B_NOTE_MAT, - DecorGfx_B_NOTE_MAT - }, { - DECOR_C_HIGH_NOTE_MAT, - _("C High NOTE MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_1x1, - DECORCAT_MAT, - 500, - DecorDesc_C_HIGH_NOTE_MAT, - DecorGfx_C_HIGH_NOTE_MAT - }, { - DECOR_SURF_MAT, - _("SURF MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_3x3, - DECORCAT_MAT, - 4000, - DecorDesc_SURF_MAT, - DecorGfx_SURF_MAT - }, { - DECOR_THUNDER_MAT, - _("THUNDER MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_3x3, - DECORCAT_MAT, - 4000, - DecorDesc_THUNDER_MAT, - DecorGfx_THUNDER_MAT - }, { - DECOR_FIRE_BLAST_MAT, - _("FIRE BLAST MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_3x3, - DECORCAT_MAT, - 4000, - DecorDesc_FIRE_BLAST_MAT, - DecorGfx_FIRE_BLAST_MAT - }, { - DECOR_POWDER_SNOW_MAT, - _("POWDER SNOW MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_3x3, - DECORCAT_MAT, - 4000, - DecorDesc_POWDER_SNOW_MAT, - DecorGfx_POWDER_SNOW_MAT - }, { - DECOR_ATTRACT_MAT, - _("ATTRACT MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_3x3, - DECORCAT_MAT, - 4000, - DecorDesc_ATTRACT_MAT, - DecorGfx_ATTRACT_MAT - }, { - DECOR_FISSURE_MAT, - _("FISSURE MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_3x3, - DECORCAT_MAT, - 4000, - DecorDesc_FISSURE_MAT, - DecorGfx_FISSURE_MAT - }, { - DECOR_SPIKES_MAT, - _("SPIKES MAT"), - DECORPERM_PASS_FLOOR, - DECORSHAPE_3x3, - DECORCAT_MAT, - 4000, - DecorDesc_SPIKES_MAT, - DecorGfx_SPIKES_MAT - }, { - DECOR_BALL_POSTER, - _("BALL POSTER"), - DECORPERM_NA_WALL, - DECORSHAPE_1x1, - DECORCAT_POSTER, - 1000, - DecorDesc_BALL_POSTER, - DecorGfx_BALL_POSTER - }, { - DECOR_GREEN_POSTER, - _("GREEN POSTER"), - DECORPERM_NA_WALL, - DECORSHAPE_1x1, - DECORCAT_POSTER, - 1000, - DecorDesc_GREEN_POSTER, - DecorGfx_GREEN_POSTER - }, { - DECOR_RED_POSTER, - _("RED POSTER"), - DECORPERM_NA_WALL, - DECORSHAPE_1x1, - DECORCAT_POSTER, - 1000, - DecorDesc_RED_POSTER, - DecorGfx_RED_POSTER - }, { - DECOR_BLUE_POSTER, - _("BLUE POSTER"), - DECORPERM_NA_WALL, - DECORSHAPE_1x1, - DECORCAT_POSTER, - 1000, - DecorDesc_BLUE_POSTER, - DecorGfx_BLUE_POSTER - }, { - DECOR_CUTE_POSTER, - _("CUTE POSTER"), - DECORPERM_NA_WALL, - DECORSHAPE_1x1, - DECORCAT_POSTER, - 1000, - DecorDesc_CUTE_POSTER, - DecorGfx_CUTE_POSTER - }, { - DECOR_PIKA_POSTER, - _("PIKA POSTER"), - DECORPERM_NA_WALL, - DECORSHAPE_2x1, - DECORCAT_POSTER, - 1500, - DecorDesc_PIKA_POSTER, - DecorGfx_PIKA_POSTER - }, { - DECOR_LONG_POSTER, - _("LONG POSTER"), - DECORPERM_NA_WALL, - DECORSHAPE_2x1, - DECORCAT_POSTER, - 1500, - DecorDesc_LONG_POSTER, - DecorGfx_LONG_POSTER - }, { - DECOR_SEA_POSTER, - _("SEA POSTER"), - DECORPERM_NA_WALL, - DECORSHAPE_2x1, - DECORCAT_POSTER, - 1500, - DecorDesc_SEA_POSTER, - DecorGfx_SEA_POSTER - }, { - DECOR_SKY_POSTER, - _("SKY POSTER"), - DECORPERM_NA_WALL, - DECORSHAPE_2x1, - DECORCAT_POSTER, - 1500, - DecorDesc_SKY_POSTER, - DecorGfx_SKY_POSTER - }, { - DECOR_KISS_POSTER, - _("KISS POSTER"), - DECORPERM_NA_WALL, - DECORSHAPE_2x1, - DECORCAT_POSTER, - 1500, - DecorDesc_KISS_POSTER, - DecorGfx_KISS_POSTER - }, { - DECOR_PICHU_DOLL, - _("PICHU DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_PICHU_DOLL, - DecorGfx_PICHU_DOLL - }, { - DECOR_PIKACHU_DOLL, - _("PIKACHU DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_PIKACHU_DOLL, - DecorGfx_PIKACHU_DOLL - }, { - DECOR_MARILL_DOLL, - _("MARILL DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_MARILL_DOLL, - DecorGfx_MARILL_DOLL - }, { - DECOR_TOGEPI_DOLL, - _("TOGEPI DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_TOGEPI_DOLL, - DecorGfx_TOGEPI_DOLL - }, { - DECOR_CYNDAQUIL_DOLL, - _("CYNDAQUIL DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_CYNDAQUIL_DOLL, - DecorGfx_CYNDAQUIL_DOLL - }, { - DECOR_CHIKORITA_DOLL, - _("CHIKORITA DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_CHIKORITA_DOLL, - DecorGfx_CHIKORITA_DOLL - }, { - DECOR_TOTODILE_DOLL, - _("TOTODILE DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_TOTODILE_DOLL, - DecorGfx_TOTODILE_DOLL - }, { - DECOR_JIGGLYPUFF_DOLL, - _("JIGGLYPUFF DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_JIGGLYPUFF_DOLL, - DecorGfx_JIGGLYPUFF_DOLL - }, { - DECOR_MEOWTH_DOLL, - _("MEOWTH DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_MEOWTH_DOLL, - DecorGfx_MEOWTH_DOLL - }, { - DECOR_CLEFAIRY_DOLL, - _("CLEFAIRY DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_CLEFAIRY_DOLL, - DecorGfx_CLEFAIRY_DOLL - }, { - DECOR_DITTO_DOLL, - _("DITTO DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_DITTO_DOLL, - DecorGfx_DITTO_DOLL - }, { - DECOR_SMOOCHUM_DOLL, - _("SMOOCHUM DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_SMOOCHUM_DOLL, - DecorGfx_SMOOCHUM_DOLL - }, { - DECOR_TREECKO_DOLL, - _("TREECKO DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_TREECKO_DOLL, - DecorGfx_TREECKO_DOLL - }, { - DECOR_TORCHIC_DOLL, - _("TORCHIC DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_TORCHIC_DOLL, - DecorGfx_TORCHIC_DOLL - }, { - DECOR_MUDKIP_DOLL, - _("MUDKIP DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_MUDKIP_DOLL, - DecorGfx_MUDKIP_DOLL - }, { - DECOR_DUSKULL_DOLL, - _("DUSKULL DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_DUSKULL_DOLL, - DecorGfx_DUSKULL_DOLL - }, { - DECOR_WYNAUT_DOLL, - _("WYNAUT DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_WYNAUT_DOLL, - DecorGfx_WYNAUT_DOLL - }, { - DECOR_BALTOY_DOLL, - _("BALTOY DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_BALTOY_DOLL, - DecorGfx_BALTOY_DOLL - }, { - DECOR_KECLEON_DOLL, - _("KECLEON DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_KECLEON_DOLL, - DecorGfx_KECLEON_DOLL - }, { - DECOR_AZURILL_DOLL, - _("AZURILL DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_AZURILL_DOLL, - DecorGfx_AZURILL_DOLL - }, { - DECOR_SKITTY_DOLL, - _("SKITTY DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_SKITTY_DOLL, - DecorGfx_SKITTY_DOLL - }, { - DECOR_SWABLU_DOLL, - _("SWABLU DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_SWABLU_DOLL, - DecorGfx_SWABLU_DOLL - }, { - DECOR_GULPIN_DOLL, - _("GULPIN DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_GULPIN_DOLL, - DecorGfx_GULPIN_DOLL - }, { - DECOR_LOTAD_DOLL, - _("LOTAD DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_LOTAD_DOLL, - DecorGfx_LOTAD_DOLL - }, { - DECOR_SEEDOT_DOLL, - _("SEEDOT DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_DOLL, - 3000, - DecorDesc_SEEDOT_DOLL, - DecorGfx_SEEDOT_DOLL - }, { - DECOR_PIKA_CUSHION, - _("PIKA CUSHION"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_CUSHION, - 2000, - DecorDesc_PIKA_CUSHION, - DecorGfx_PIKA_CUSHION - }, { - DECOR_ROUND_CUSHION, - _("ROUND CUSHION"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_CUSHION, - 2000, - DecorDesc_ROUND_CUSHION, - DecorGfx_ROUND_CUSHION - }, { - DECOR_KISS_CUSHION, - _("KISS CUSHION"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_CUSHION, - 2000, - DecorDesc_KISS_CUSHION, - DecorGfx_KISS_CUSHION - }, { - DECOR_ZIGZAG_CUSHION, - _("ZIGZAG CUSHION"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_CUSHION, - 2000, - DecorDesc_ZIGZAG_CUSHION, - DecorGfx_ZIGZAG_CUSHION - }, { - DECOR_SPIN_CUSHION, - _("SPIN CUSHION"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_CUSHION, - 2000, - DecorDesc_SPIN_CUSHION, - DecorGfx_SPIN_CUSHION - }, { - DECOR_DIAMOND_CUSHION, - _("DIAMOND CUSHION"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_CUSHION, - 2000, - DecorDesc_DIAMOND_CUSHION, - DecorGfx_DIAMOND_CUSHION - }, { - DECOR_BALL_CUSHION, - _("BALL CUSHION"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_CUSHION, - 2000, - DecorDesc_BALL_CUSHION, - DecorGfx_BALL_CUSHION - }, { - DECOR_GRASS_CUSHION, - _("GRASS CUSHION"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_CUSHION, - 2000, - DecorDesc_GRASS_CUSHION, - DecorGfx_GRASS_CUSHION - }, { - DECOR_FIRE_CUSHION, - _("FIRE CUSHION"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_CUSHION, - 2000, - DecorDesc_FIRE_CUSHION, - DecorGfx_FIRE_CUSHION - }, { - DECOR_WATER_CUSHION, - _("WATER CUSHION"), - DECORPERM_SPRITE, - DECORSHAPE_1x1, - DECORCAT_CUSHION, - 2000, - DecorDesc_WATER_CUSHION, - DecorGfx_WATER_CUSHION - }, { - DECOR_SNORLAX_DOLL, - _("SNORLAX DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x2, - DECORCAT_DOLL, - 10000, - DecorDesc_SNORLAX_DOLL, - DecorGfx_SNORLAX_DOLL - }, { - DECOR_RHYDON_DOLL, - _("RHYDON DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x2, - DECORCAT_DOLL, - 10000, - DecorDesc_RHYDON_DOLL, - DecorGfx_RHYDON_DOLL - }, { - DECOR_LAPRAS_DOLL, - _("LAPRAS DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x2, - DECORCAT_DOLL, - 10000, - DecorDesc_LAPRAS_DOLL, - DecorGfx_LAPRAS_DOLL - }, { - DECOR_VENUSAUR_DOLL, - _("VENUSAUR DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x2, - DECORCAT_DOLL, - 10000, - DecorDesc_VENUSAUR_DOLL, - DecorGfx_VENUSAUR_DOLL - }, { - DECOR_CHARIZARD_DOLL, - _("CHARIZARD DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x2, - DECORCAT_DOLL, - 10000, - DecorDesc_CHARIZARD_DOLL, - DecorGfx_CHARIZARD_DOLL - }, { - DECOR_BLASTOISE_DOLL, - _("BLASTOISE DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x2, - DECORCAT_DOLL, - 10000, - DecorDesc_BLASTOISE_DOLL, - DecorGfx_BLASTOISE_DOLL - }, { - DECOR_WAILMER_DOLL, - _("WAILMER DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x2, - DECORCAT_DOLL, - 10000, - DecorDesc_WAILMER_DOLL, - DecorGfx_WAILMER_DOLL - }, { - DECOR_REGIROCK_DOLL, - _("REGIROCK DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x2, - DECORCAT_DOLL, - 10000, - DecorDesc_REGIROCK_DOLL, - DecorGfx_REGIROCK_DOLL - }, { - DECOR_REGICE_DOLL, - _("REGICE DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x2, - DECORCAT_DOLL, - 10000, - DecorDesc_REGICE_DOLL, - DecorGfx_REGICE_DOLL - }, { - DECOR_REGISTEEL_DOLL, - _("REGISTEEL DOLL"), - DECORPERM_SPRITE, - DECORSHAPE_1x2, - DECORCAT_DOLL, - 10000, - DecorDesc_REGISTEEL_DOLL, - DecorGfx_REGISTEEL_DOLL} + .id = DECOR_NONE, + .name = _("SMALL DESK"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DESK, + .price = 0, + .description = DecorDesc_SMALL_DESK, + .tiles = DecorGfx_SMALL_DESK, + }, + + [DECOR_SMALL_DESK] = + { + .id = DECOR_SMALL_DESK, + .name = _("SMALL DESK"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DESK, + .price = 3000, + .description = DecorDesc_SMALL_DESK, + .tiles = DecorGfx_SMALL_DESK, + }, + + [DECOR_POKEMON_DESK] = + { + .id = DECOR_POKEMON_DESK, + .name = _("POKéMON DESK"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DESK, + .price = 3000, + .description = DecorDesc_POKEMON_DESK, + .tiles = DecorGfx_POKEMON_DESK, + }, + + [DECOR_HEAVY_DESK] = + { + .id = DECOR_HEAVY_DESK, + .name = _("HEAVY DESK"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x2, + .category = DECORCAT_DESK, + .price = 6000, + .description = DecorDesc_HEAVY_DESK, + .tiles = DecorGfx_HEAVY_DESK, + }, + + [DECOR_RAGGED_DESK] = + { + .id = DECOR_RAGGED_DESK, + .name = _("RAGGED DESK"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x2, + .category = DECORCAT_DESK, + .price = 6000, + .description = DecorDesc_RAGGED_DESK, + .tiles = DecorGfx_RAGGED_DESK, + }, + + [DECOR_COMFORT_DESK] = + { + .id = DECOR_COMFORT_DESK, + .name = _("COMFORT DESK"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x2, + .category = DECORCAT_DESK, + .price = 6000, + .description = DecorDesc_COMFORT_DESK, + .tiles = DecorGfx_COMFORT_DESK, + }, + + [DECOR_PRETTY_DESK] = + { + .id = DECOR_PRETTY_DESK, + .name = _("PRETTY DESK"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_DESK, + .price = 9000, + .description = DecorDesc_PRETTY_DESK, + .tiles = DecorGfx_PRETTY_DESK, + }, + + [DECOR_BRICK_DESK] = + { + .id = DECOR_BRICK_DESK, + .name = _("BRICK DESK"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_DESK, + .price = 9000, + .description = DecorDesc_BRICK_DESK, + .tiles = DecorGfx_BRICK_DESK, + }, + + [DECOR_CAMP_DESK] = + { + .id = DECOR_CAMP_DESK, + .name = _("CAMP DESK"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_DESK, + .price = 9000, + .description = DecorDesc_CAMP_DESK, + .tiles = DecorGfx_CAMP_DESK, + }, + + [DECOR_HARD_DESK] = + { + .id = DECOR_HARD_DESK, + .name = _("HARD DESK"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_DESK, + .price = 9000, + .description = DecorDesc_HARD_DESK, + .tiles = DecorGfx_HARD_DESK, + }, + + [DECOR_SMALL_CHAIR] = + { + .id = DECOR_SMALL_CHAIR, + .name = _("SMALL CHAIR"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_SMALL_CHAIR, + .tiles = DecorGfx_SMALL_CHAIR, + }, + + [DECOR_POKEMON_CHAIR] = + { + .id = DECOR_POKEMON_CHAIR, + .name = _("POKéMON CHAIR"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_POKEMON_CHAIR, + .tiles = DecorGfx_POKEMON_CHAIR, + }, + + [DECOR_HEAVY_CHAIR] = + { + .id = DECOR_HEAVY_CHAIR, + .name = _("HEAVY CHAIR"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_HEAVY_CHAIR, + .tiles = DecorGfx_HEAVY_CHAIR, + }, + + [DECOR_PRETTY_CHAIR] = + { + .id = DECOR_PRETTY_CHAIR, + .name = _("PRETTY CHAIR"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_PRETTY_CHAIR, + .tiles = DecorGfx_PRETTY_CHAIR, + }, + + [DECOR_COMFORT_CHAIR] = + { + .id = DECOR_COMFORT_CHAIR, + .name = _("COMFORT CHAIR"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_COMFORT_CHAIR, + .tiles = DecorGfx_COMFORT_CHAIR, + }, + + [DECOR_RAGGED_CHAIR] = + { + .id = DECOR_RAGGED_CHAIR, + .name = _("RAGGED CHAIR"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_RAGGED_CHAIR, + .tiles = DecorGfx_RAGGED_CHAIR, + }, + + [DECOR_BRICK_CHAIR] = + { + .id = DECOR_BRICK_CHAIR, + .name = _("BRICK CHAIR"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_BRICK_CHAIR, + .tiles = DecorGfx_BRICK_CHAIR, + }, + + [DECOR_CAMP_CHAIR] = + { + .id = DECOR_CAMP_CHAIR, + .name = _("CAMP CHAIR"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_CAMP_CHAIR, + .tiles = DecorGfx_CAMP_CHAIR, + }, + + [DECOR_HARD_CHAIR] = + { + .id = DECOR_HARD_CHAIR, + .name = _("HARD CHAIR"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CHAIR, + .price = 2000, + .description = DecorDesc_HARD_CHAIR, + .tiles = DecorGfx_HARD_CHAIR, + }, + + [DECOR_RED_PLANT] = + { + .id = DECOR_RED_PLANT, + .name = _("RED PLANT"), + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_PLANT, + .price = 3000, + .description = DecorDesc_RED_PLANT, + .tiles = DecorGfx_RED_PLANT, + }, + + [DECOR_TROPICAL_PLANT] = + { + .id = DECOR_TROPICAL_PLANT, + .name = _("TROPICAL PLANT"), + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_PLANT, + .price = 3000, + .description = DecorDesc_TROPICAL_PLANT, + .tiles = DecorGfx_TROPICAL_PLANT, + }, + + [DECOR_PRETTY_FLOWERS] = + { + .id = DECOR_PRETTY_FLOWERS, + .name = _("PRETTY FLOWERS"), + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_PLANT, + .price = 3000, + .description = DecorDesc_PRETTY_FLOWERS, + .tiles = DecorGfx_PRETTY_FLOWERS, + }, + + [DECOR_COLORFUL_PLANT] = + { + .id = DECOR_COLORFUL_PLANT, + .name = _("COLORFUL PLANT"), + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_2x2, + .category = DECORCAT_PLANT, + .price = 5000, + .description = DecorDesc_COLORFUL_PLANT, + .tiles = DecorGfx_COLORFUL_PLANT, + }, + + [DECOR_BIG_PLANT] = + { + .id = DECOR_BIG_PLANT, + .name = _("BIG PLANT"), + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_2x2, + .category = DECORCAT_PLANT, + .price = 5000, + .description = DecorDesc_BIG_PLANT, + .tiles = DecorGfx_BIG_PLANT, + }, + + [DECOR_GORGEOUS_PLANT] = + { + .id = DECOR_GORGEOUS_PLANT, + .name = _("GORGEOUS PLANT"), + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_2x2, + .category = DECORCAT_PLANT, + .price = 5000, + .description = DecorDesc_GORGEOUS_PLANT, + .tiles = DecorGfx_GORGEOUS_PLANT, + }, + + [DECOR_RED_BRICK] = + { + .id = DECOR_RED_BRICK, + .name = _("RED BRICK"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_RED_BRICK, + .tiles = DecorGfx_RED_BRICK, + }, + + [DECOR_YELLOW_BRICK] = + { + .id = DECOR_YELLOW_BRICK, + .name = _("YELLOW BRICK"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_YELLOW_BRICK, + .tiles = DecorGfx_YELLOW_BRICK, + }, + + [DECOR_BLUE_BRICK] = + { + .id = DECOR_BLUE_BRICK, + .name = _("BLUE BRICK"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_BLUE_BRICK, + .tiles = DecorGfx_BLUE_BRICK, + }, + + [DECOR_RED_BALLOON] = + { + .id = DECOR_RED_BALLOON, + .name = _("RED BALLOON"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_RED_BALLOON, + .tiles = DecorGfx_RED_BALLOON, + }, + + [DECOR_BLUE_BALLOON] = + { + .id = DECOR_BLUE_BALLOON, + .name = _("BLUE BALLOON"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_BLUE_BALLOON, + .tiles = DecorGfx_BLUE_BALLOON, + }, + + [DECOR_YELLOW_BALLOON] = + { + .id = DECOR_YELLOW_BALLOON, + .name = _("YELLOW BALLOON"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_YELLOW_BALLOON, + .tiles = DecorGfx_YELLOW_BALLOON, + }, + + [DECOR_RED_TENT] = + { + .id = DECOR_RED_TENT, + .name = _("RED TENT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_ORNAMENT, + .price = 10000, + .description = DecorDesc_RED_TENT, + .tiles = DecorGfx_RED_TENT, + }, + + [DECOR_BLUE_TENT] = + { + .id = DECOR_BLUE_TENT, + .name = _("BLUE TENT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_ORNAMENT, + .price = 10000, + .description = DecorDesc_BLUE_TENT, + .tiles = DecorGfx_BLUE_TENT, + }, + + [DECOR_SOLID_BOARD] = + { + .id = DECOR_SOLID_BOARD, + .name = _("SOLID BOARD"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 3000, + .description = DecorDesc_SOLID_BOARD, + .tiles = DecorGfx_SOLID_BOARD, + }, + + [DECOR_SLIDE] = + { + .id = DECOR_SLIDE, + .name = _("SLIDE"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_2x4, + .category = DECORCAT_ORNAMENT, + .price = 8000, + .description = DecorDesc_SLIDE, + .tiles = DecorGfx_SLIDE, + }, + + [DECOR_FENCE_LENGTH] = + { + .id = DECOR_FENCE_LENGTH, + .name = _("FENCE LENGTH"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_FENCE_LENGTH, + .tiles = DecorGfx_FENCE_LENGTH, + }, + + [DECOR_FENCE_WIDTH] = + { + .id = DECOR_FENCE_WIDTH, + .name = _("FENCE WIDTH"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 500, + .description = DecorDesc_FENCE_WIDTH, + .tiles = DecorGfx_FENCE_WIDTH, + }, + + [DECOR_TIRE] = + { + .id = DECOR_TIRE, + .name = _("TIRE"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_2x2, + .category = DECORCAT_ORNAMENT, + .price = 800, + .description = DecorDesc_TIRE, + .tiles = DecorGfx_TIRE, + }, + + [DECOR_STAND] = + { + .id = DECOR_STAND, + .name = _("STAND"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_4x2, + .category = DECORCAT_ORNAMENT, + .price = 7000, + .description = DecorDesc_STAND, + .tiles = DecorGfx_STAND, + }, + + [DECOR_MUD_BALL] = + { + .id = DECOR_MUD_BALL, + .name = _("MUD BALL"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 200, + .description = DecorDesc_MUD_BALL, + .tiles = DecorGfx_MUD_BALL, + }, + + [DECOR_BREAKABLE_DOOR] = + { + .id = DECOR_BREAKABLE_DOOR, + .name = _("BREAKABLE DOOR"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 3000, + .description = DecorDesc_BREAKABLE_DOOR, + .tiles = DecorGfx_BREAKABLE_DOOR, + }, + + [DECOR_SAND_ORNAMENT] = + { + .id = DECOR_SAND_ORNAMENT, + .name = _("SAND ORNAMENT"), + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 3000, + .description = DecorDesc_SAND_ORNAMENT, + .tiles = DecorGfx_SAND_ORNAMENT, + }, + + [DECOR_SILVER_SHIELD] = + { + .id = DECOR_SILVER_SHIELD, + .name = _("SILVER SHIELD"), + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 0, + .description = DecorDesc_SILVER_SHIELD, + .tiles = DecorGfx_SILVER_SHIELD, + }, + + [DECOR_GOLD_SHIELD] = + { + .id = DECOR_GOLD_SHIELD, + .name = _("GOLD SHIELD"), + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 0, + .description = DecorDesc_GOLD_SHIELD, + .tiles = DecorGfx_GOLD_SHIELD, + }, + + [DECOR_GLASS_ORNAMENT] = + { + .id = DECOR_GLASS_ORNAMENT, + .name = _("GLASS ORNAMENT"), + .permission = DECORPERM_BEHIND_FLOOR, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_ORNAMENT, + .price = 0, + .description = DecorDesc_GLASS_ORNAMENT, + .tiles = DecorGfx_GLASS_ORNAMENT, + }, + + [DECOR_TV] = + { + .id = DECOR_TV, + .name = _("TV"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 3000, + .description = DecorDesc_TV, + .tiles = DecorGfx_TV, + }, + + [DECOR_ROUND_TV] = + { + .id = DECOR_ROUND_TV, + .name = _("ROUND TV"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 4000, + .description = DecorDesc_ROUND_TV, + .tiles = DecorGfx_ROUND_TV, + }, + + [DECOR_CUTE_TV] = + { + .id = DECOR_CUTE_TV, + .name = _("CUTE TV"), + .permission = DECORPERM_SOLID_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_ORNAMENT, + .price = 4000, + .description = DecorDesc_CUTE_TV, + .tiles = DecorGfx_CUTE_TV, + }, + + [DECOR_GLITTER_MAT] = + { + .id = DECOR_GLITTER_MAT, + .name = _("GLITTER MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 2000, + .description = DecorDesc_GLITTER_MAT, + .tiles = DecorGfx_GLITTER_MAT, + }, + + [DECOR_JUMP_MAT] = + { + .id = DECOR_JUMP_MAT, + .name = _("JUMP MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 2000, + .description = DecorDesc_JUMP_MAT, + .tiles = DecorGfx_JUMP_MAT, + }, + + [DECOR_SPIN_MAT] = + { + .id = DECOR_SPIN_MAT, + .name = _("SPIN MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 2000, + .description = DecorDesc_SPIN_MAT, + .tiles = DecorGfx_SPIN_MAT, + }, + + [DECOR_C_LOW_NOTE_MAT] = + { + .id = DECOR_C_LOW_NOTE_MAT, + .name = _("C Low NOTE MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_C_LOW_NOTE_MAT, + .tiles = DecorGfx_C_LOW_NOTE_MAT, + }, + + [DECOR_D_NOTE_MAT] = + { + .id = DECOR_D_NOTE_MAT, + .name = _("D NOTE MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_D_NOTE_MAT, + .tiles = DecorGfx_D_NOTE_MAT, + }, + + [DECOR_E_NOTE_MAT] = + { + .id = DECOR_E_NOTE_MAT, + .name = _("E NOTE MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_E_NOTE_MAT, + .tiles = DecorGfx_E_NOTE_MAT, + }, + + [DECOR_F_NOTE_MAT] = + { + .id = DECOR_F_NOTE_MAT, + .name = _("F NOTE MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_F_NOTE_MAT, + .tiles = DecorGfx_F_NOTE_MAT, + }, + + [DECOR_G_NOTE_MAT] = + { + .id = DECOR_G_NOTE_MAT, + .name = _("G NOTE MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_G_NOTE_MAT, + .tiles = DecorGfx_G_NOTE_MAT, + }, + + [DECOR_A_NOTE_MAT] = + { + .id = DECOR_A_NOTE_MAT, + .name = _("A NOTE MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_A_NOTE_MAT, + .tiles = DecorGfx_A_NOTE_MAT, + }, + + [DECOR_B_NOTE_MAT] = + { + .id = DECOR_B_NOTE_MAT, + .name = _("B NOTE MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_B_NOTE_MAT, + .tiles = DecorGfx_B_NOTE_MAT, + }, + + [DECOR_C_HIGH_NOTE_MAT] = + { + .id = DECOR_C_HIGH_NOTE_MAT, + .name = _("C High NOTE MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_MAT, + .price = 500, + .description = DecorDesc_C_HIGH_NOTE_MAT, + .tiles = DecorGfx_C_HIGH_NOTE_MAT, + }, + + [DECOR_SURF_MAT] = + { + .id = DECOR_SURF_MAT, + .name = _("SURF MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_SURF_MAT, + .tiles = DecorGfx_SURF_MAT, + }, + + [DECOR_THUNDER_MAT] = + { + .id = DECOR_THUNDER_MAT, + .name = _("THUNDER MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_THUNDER_MAT, + .tiles = DecorGfx_THUNDER_MAT, + }, + + [DECOR_FIRE_BLAST_MAT] = + { + .id = DECOR_FIRE_BLAST_MAT, + .name = _("FIRE BLAST MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_FIRE_BLAST_MAT, + .tiles = DecorGfx_FIRE_BLAST_MAT, + }, + + [DECOR_POWDER_SNOW_MAT] = + { + .id = DECOR_POWDER_SNOW_MAT, + .name = _("POWDER SNOW MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_POWDER_SNOW_MAT, + .tiles = DecorGfx_POWDER_SNOW_MAT, + }, + + [DECOR_ATTRACT_MAT] = + { + .id = DECOR_ATTRACT_MAT, + .name = _("ATTRACT MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_ATTRACT_MAT, + .tiles = DecorGfx_ATTRACT_MAT, + }, + + [DECOR_FISSURE_MAT] = + { + .id = DECOR_FISSURE_MAT, + .name = _("FISSURE MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_FISSURE_MAT, + .tiles = DecorGfx_FISSURE_MAT, + }, + + [DECOR_SPIKES_MAT] = + { + .id = DECOR_SPIKES_MAT, + .name = _("SPIKES MAT"), + .permission = DECORPERM_PASS_FLOOR, + .shape = DECORSHAPE_3x3, + .category = DECORCAT_MAT, + .price = 4000, + .description = DecorDesc_SPIKES_MAT, + .tiles = DecorGfx_SPIKES_MAT, + }, + + [DECOR_BALL_POSTER] = + { + .id = DECOR_BALL_POSTER, + .name = _("BALL POSTER"), + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_POSTER, + .price = 1000, + .description = DecorDesc_BALL_POSTER, + .tiles = DecorGfx_BALL_POSTER, + }, + + [DECOR_GREEN_POSTER] = + { + .id = DECOR_GREEN_POSTER, + .name = _("GREEN POSTER"), + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_POSTER, + .price = 1000, + .description = DecorDesc_GREEN_POSTER, + .tiles = DecorGfx_GREEN_POSTER, + }, + + [DECOR_RED_POSTER] = + { + .id = DECOR_RED_POSTER, + .name = _("RED POSTER"), + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_POSTER, + .price = 1000, + .description = DecorDesc_RED_POSTER, + .tiles = DecorGfx_RED_POSTER, + }, + + [DECOR_BLUE_POSTER] = + { + .id = DECOR_BLUE_POSTER, + .name = _("BLUE POSTER"), + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_POSTER, + .price = 1000, + .description = DecorDesc_BLUE_POSTER, + .tiles = DecorGfx_BLUE_POSTER, + }, + + [DECOR_CUTE_POSTER] = + { + .id = DECOR_CUTE_POSTER, + .name = _("CUTE POSTER"), + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_POSTER, + .price = 1000, + .description = DecorDesc_CUTE_POSTER, + .tiles = DecorGfx_CUTE_POSTER, + }, + + [DECOR_PIKA_POSTER] = + { + .id = DECOR_PIKA_POSTER, + .name = _("PIKA POSTER"), + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_2x1, + .category = DECORCAT_POSTER, + .price = 1500, + .description = DecorDesc_PIKA_POSTER, + .tiles = DecorGfx_PIKA_POSTER, + }, + + [DECOR_LONG_POSTER] = + { + .id = DECOR_LONG_POSTER, + .name = _("LONG POSTER"), + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_2x1, + .category = DECORCAT_POSTER, + .price = 1500, + .description = DecorDesc_LONG_POSTER, + .tiles = DecorGfx_LONG_POSTER, + }, + + [DECOR_SEA_POSTER] = + { + .id = DECOR_SEA_POSTER, + .name = _("SEA POSTER"), + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_2x1, + .category = DECORCAT_POSTER, + .price = 1500, + .description = DecorDesc_SEA_POSTER, + .tiles = DecorGfx_SEA_POSTER, + }, + + [DECOR_SKY_POSTER] = + { + .id = DECOR_SKY_POSTER, + .name = _("SKY POSTER"), + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_2x1, + .category = DECORCAT_POSTER, + .price = 1500, + .description = DecorDesc_SKY_POSTER, + .tiles = DecorGfx_SKY_POSTER, + }, + + [DECOR_KISS_POSTER] = + { + .id = DECOR_KISS_POSTER, + .name = _("KISS POSTER"), + .permission = DECORPERM_NA_WALL, + .shape = DECORSHAPE_2x1, + .category = DECORCAT_POSTER, + .price = 1500, + .description = DecorDesc_KISS_POSTER, + .tiles = DecorGfx_KISS_POSTER, + }, + + [DECOR_PICHU_DOLL] = + { + .id = DECOR_PICHU_DOLL, + .name = _("PICHU DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_PICHU_DOLL, + .tiles = DecorGfx_PICHU_DOLL, + }, + + [DECOR_PIKACHU_DOLL] = + { + .id = DECOR_PIKACHU_DOLL, + .name = _("PIKACHU DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_PIKACHU_DOLL, + .tiles = DecorGfx_PIKACHU_DOLL, + }, + + [DECOR_MARILL_DOLL] = + { + .id = DECOR_MARILL_DOLL, + .name = _("MARILL DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_MARILL_DOLL, + .tiles = DecorGfx_MARILL_DOLL, + }, + + [DECOR_TOGEPI_DOLL] = + { + .id = DECOR_TOGEPI_DOLL, + .name = _("TOGEPI DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_TOGEPI_DOLL, + .tiles = DecorGfx_TOGEPI_DOLL, + }, + + [DECOR_CYNDAQUIL_DOLL] = + { + .id = DECOR_CYNDAQUIL_DOLL, + .name = _("CYNDAQUIL DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_CYNDAQUIL_DOLL, + .tiles = DecorGfx_CYNDAQUIL_DOLL, + }, + + [DECOR_CHIKORITA_DOLL] = + { + .id = DECOR_CHIKORITA_DOLL, + .name = _("CHIKORITA DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_CHIKORITA_DOLL, + .tiles = DecorGfx_CHIKORITA_DOLL, + }, + + [DECOR_TOTODILE_DOLL] = + { + .id = DECOR_TOTODILE_DOLL, + .name = _("TOTODILE DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_TOTODILE_DOLL, + .tiles = DecorGfx_TOTODILE_DOLL, + }, + + [DECOR_JIGGLYPUFF_DOLL] = + { + .id = DECOR_JIGGLYPUFF_DOLL, + .name = _("JIGGLYPUFF DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_JIGGLYPUFF_DOLL, + .tiles = DecorGfx_JIGGLYPUFF_DOLL, + }, + + [DECOR_MEOWTH_DOLL] = + { + .id = DECOR_MEOWTH_DOLL, + .name = _("MEOWTH DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_MEOWTH_DOLL, + .tiles = DecorGfx_MEOWTH_DOLL, + }, + + [DECOR_CLEFAIRY_DOLL] = + { + .id = DECOR_CLEFAIRY_DOLL, + .name = _("CLEFAIRY DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_CLEFAIRY_DOLL, + .tiles = DecorGfx_CLEFAIRY_DOLL, + }, + + [DECOR_DITTO_DOLL] = + { + .id = DECOR_DITTO_DOLL, + .name = _("DITTO DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_DITTO_DOLL, + .tiles = DecorGfx_DITTO_DOLL, + }, + + [DECOR_SMOOCHUM_DOLL] = + { + .id = DECOR_SMOOCHUM_DOLL, + .name = _("SMOOCHUM DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_SMOOCHUM_DOLL, + .tiles = DecorGfx_SMOOCHUM_DOLL, + }, + + [DECOR_TREECKO_DOLL] = + { + .id = DECOR_TREECKO_DOLL, + .name = _("TREECKO DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_TREECKO_DOLL, + .tiles = DecorGfx_TREECKO_DOLL, + }, + + [DECOR_TORCHIC_DOLL] = + { + .id = DECOR_TORCHIC_DOLL, + .name = _("TORCHIC DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_TORCHIC_DOLL, + .tiles = DecorGfx_TORCHIC_DOLL, + }, + + [DECOR_MUDKIP_DOLL] = + { + .id = DECOR_MUDKIP_DOLL, + .name = _("MUDKIP DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_MUDKIP_DOLL, + .tiles = DecorGfx_MUDKIP_DOLL, + }, + + [DECOR_DUSKULL_DOLL] = + { + .id = DECOR_DUSKULL_DOLL, + .name = _("DUSKULL DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_DUSKULL_DOLL, + .tiles = DecorGfx_DUSKULL_DOLL, + }, + + [DECOR_WYNAUT_DOLL] = + { + .id = DECOR_WYNAUT_DOLL, + .name = _("WYNAUT DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_WYNAUT_DOLL, + .tiles = DecorGfx_WYNAUT_DOLL, + }, + + [DECOR_BALTOY_DOLL] = + { + .id = DECOR_BALTOY_DOLL, + .name = _("BALTOY DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_BALTOY_DOLL, + .tiles = DecorGfx_BALTOY_DOLL, + }, + + [DECOR_KECLEON_DOLL] = + { + .id = DECOR_KECLEON_DOLL, + .name = _("KECLEON DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_KECLEON_DOLL, + .tiles = DecorGfx_KECLEON_DOLL, + }, + + [DECOR_AZURILL_DOLL] = + { + .id = DECOR_AZURILL_DOLL, + .name = _("AZURILL DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_AZURILL_DOLL, + .tiles = DecorGfx_AZURILL_DOLL, + }, + + [DECOR_SKITTY_DOLL] = + { + .id = DECOR_SKITTY_DOLL, + .name = _("SKITTY DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_SKITTY_DOLL, + .tiles = DecorGfx_SKITTY_DOLL, + }, + + [DECOR_SWABLU_DOLL] = + { + .id = DECOR_SWABLU_DOLL, + .name = _("SWABLU DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_SWABLU_DOLL, + .tiles = DecorGfx_SWABLU_DOLL, + }, + + [DECOR_GULPIN_DOLL] = + { + .id = DECOR_GULPIN_DOLL, + .name = _("GULPIN DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_GULPIN_DOLL, + .tiles = DecorGfx_GULPIN_DOLL, + }, + + [DECOR_LOTAD_DOLL] = + { + .id = DECOR_LOTAD_DOLL, + .name = _("LOTAD DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_LOTAD_DOLL, + .tiles = DecorGfx_LOTAD_DOLL, + }, + + [DECOR_SEEDOT_DOLL] = + { + .id = DECOR_SEEDOT_DOLL, + .name = _("SEEDOT DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_DOLL, + .price = 3000, + .description = DecorDesc_SEEDOT_DOLL, + .tiles = DecorGfx_SEEDOT_DOLL, + }, + + [DECOR_PIKA_CUSHION] = + { + .id = DECOR_PIKA_CUSHION, + .name = _("PIKA CUSHION"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_PIKA_CUSHION, + .tiles = DecorGfx_PIKA_CUSHION, + }, + + [DECOR_ROUND_CUSHION] = + { + .id = DECOR_ROUND_CUSHION, + .name = _("ROUND CUSHION"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_ROUND_CUSHION, + .tiles = DecorGfx_ROUND_CUSHION, + }, + + [DECOR_KISS_CUSHION] = + { + .id = DECOR_KISS_CUSHION, + .name = _("KISS CUSHION"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_KISS_CUSHION, + .tiles = DecorGfx_KISS_CUSHION, + }, + + [DECOR_ZIGZAG_CUSHION] = + { + .id = DECOR_ZIGZAG_CUSHION, + .name = _("ZIGZAG CUSHION"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_ZIGZAG_CUSHION, + .tiles = DecorGfx_ZIGZAG_CUSHION, + }, + + [DECOR_SPIN_CUSHION] = + { + .id = DECOR_SPIN_CUSHION, + .name = _("SPIN CUSHION"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_SPIN_CUSHION, + .tiles = DecorGfx_SPIN_CUSHION, + }, + + [DECOR_DIAMOND_CUSHION] = + { + .id = DECOR_DIAMOND_CUSHION, + .name = _("DIAMOND CUSHION"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_DIAMOND_CUSHION, + .tiles = DecorGfx_DIAMOND_CUSHION, + }, + + [DECOR_BALL_CUSHION] = + { + .id = DECOR_BALL_CUSHION, + .name = _("BALL CUSHION"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_BALL_CUSHION, + .tiles = DecorGfx_BALL_CUSHION, + }, + + [DECOR_GRASS_CUSHION] = + { + .id = DECOR_GRASS_CUSHION, + .name = _("GRASS CUSHION"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_GRASS_CUSHION, + .tiles = DecorGfx_GRASS_CUSHION, + }, + + [DECOR_FIRE_CUSHION] = + { + .id = DECOR_FIRE_CUSHION, + .name = _("FIRE CUSHION"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_FIRE_CUSHION, + .tiles = DecorGfx_FIRE_CUSHION, + }, + + [DECOR_WATER_CUSHION] = + { + .id = DECOR_WATER_CUSHION, + .name = _("WATER CUSHION"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x1, + .category = DECORCAT_CUSHION, + .price = 2000, + .description = DecorDesc_WATER_CUSHION, + .tiles = DecorGfx_WATER_CUSHION, + }, + + [DECOR_SNORLAX_DOLL] = + { + .id = DECOR_SNORLAX_DOLL, + .name = _("SNORLAX DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_SNORLAX_DOLL, + .tiles = DecorGfx_SNORLAX_DOLL, + }, + + [DECOR_RHYDON_DOLL] = + { + .id = DECOR_RHYDON_DOLL, + .name = _("RHYDON DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_RHYDON_DOLL, + .tiles = DecorGfx_RHYDON_DOLL, + }, + + [DECOR_LAPRAS_DOLL] = + { + .id = DECOR_LAPRAS_DOLL, + .name = _("LAPRAS DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_LAPRAS_DOLL, + .tiles = DecorGfx_LAPRAS_DOLL, + }, + + [DECOR_VENUSAUR_DOLL] = + { + .id = DECOR_VENUSAUR_DOLL, + .name = _("VENUSAUR DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_VENUSAUR_DOLL, + .tiles = DecorGfx_VENUSAUR_DOLL, + }, + + [DECOR_CHARIZARD_DOLL] = + { + .id = DECOR_CHARIZARD_DOLL, + .name = _("CHARIZARD DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_CHARIZARD_DOLL, + .tiles = DecorGfx_CHARIZARD_DOLL, + }, + + [DECOR_BLASTOISE_DOLL] = + { + .id = DECOR_BLASTOISE_DOLL, + .name = _("BLASTOISE DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_BLASTOISE_DOLL, + .tiles = DecorGfx_BLASTOISE_DOLL, + }, + + [DECOR_WAILMER_DOLL] = + { + .id = DECOR_WAILMER_DOLL, + .name = _("WAILMER DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_WAILMER_DOLL, + .tiles = DecorGfx_WAILMER_DOLL, + }, + + [DECOR_REGIROCK_DOLL] = + { + .id = DECOR_REGIROCK_DOLL, + .name = _("REGIROCK DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_REGIROCK_DOLL, + .tiles = DecorGfx_REGIROCK_DOLL, + }, + + [DECOR_REGICE_DOLL] = + { + .id = DECOR_REGICE_DOLL, + .name = _("REGICE DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_REGICE_DOLL, + .tiles = DecorGfx_REGICE_DOLL, + }, + + [DECOR_REGISTEEL_DOLL] = + { + .id = DECOR_REGISTEEL_DOLL, + .name = _("REGISTEEL DOLL"), + .permission = DECORPERM_SPRITE, + .shape = DECORSHAPE_1x2, + .category = DECORCAT_DOLL, + .price = 10000, + .description = DecorDesc_REGISTEEL_DOLL, + .tiles = DecorGfx_REGISTEEL_DOLL, + } }; diff --git a/src/data/decoration/tilemaps.h b/src/data/decoration/tilemaps.h index 12fe31dc0..eebb3acb2 100644 --- a/src/data/decoration/tilemaps.h +++ b/src/data/decoration/tilemaps.h @@ -1,37 +1,37 @@ -const u8 Unknown_085A6FB0[] = { +static const u8 sDecorTilemap_1x1_Tiles[] = { 0x00, 0x01, 0x02, 0x03 }; -const u8 Unknown_085A6FB4[] = { +static const u8 sDecorTilemap_3x1_Tiles[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d }; -const u8 Unknown_085A6FC0[] = { +static const u8 sDecorTilemap_2x2_Tiles[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; -const u8 Unknown_085A6FD0[] = { +static const u8 sDecorTilemap_1x3_Tiles[] = { 0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0c, 0x0d, 0x10, 0x11, 0x14, 0x15 }; -const u8 Unknown_085A6FDC[] = { +static const u8 sDecorTilemap_2x1_Tiles[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; -const u8 Unknown_085A6FE4[] = { +static const u8 sDecorTilemap_4x2_Tiles[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }; -const u8 Unknown_085A7004[] = { +static const u8 sDecorTilemap_3x3_Tiles[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, @@ -40,60 +40,60 @@ const u8 Unknown_085A7004[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d }; -const u8 Unknown_085A7028[] = { +static const u8 sDecorTilemap_3x2_Tiles[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d }; -const u8 Unknown_085A7040[] = { +static const u8 sDecorTilemap_1x1_Y[] = { 0x00, 0x00, 0x00, 0x00 }; -const u8 Unknown_085A7044[] = { +static const u8 sDecorTilemap_2x1_Y[] = { 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01 }; -const u8 Unknown_085A704C[] = { +static const u8 sDecorTilemap_3x1_Y[] = { 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02 }; -const u8 Unknown_085A7058[] = { +static const u8 sDecorTilemap_4x2_Y[] = { 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, 0x07, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, 0x07 }; -const u8 Unknown_085A7078[] = { +static const u8 sDecorTilemap_2x2_Y[] = { 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03 }; -const u8 Unknown_085A7088[] = { +static const u8 sDecorTilemap_1x2_Y[] = { 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01 }; -const u8 Unknown_085A7090[] = { +static const u8 sDecorTilemap_1x3_Y[] = { 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02 }; -const u8 Unknown_085A709C[] = { +static const u8 sDecorTilemap_2x4_Y[] = { 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, 0x07, 0x06, 0x06, 0x07, 0x07 }; -const u8 Unknown_085A70BC[] = { +static const u8 sDecorTilemap_3x3_Y[] = { 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, @@ -102,60 +102,60 @@ const u8 Unknown_085A70BC[] = { 0x06, 0x06, 0x07, 0x07, 0x08, 0x08 }; -const u8 Unknown_085A70E0[] = { +static const u8 sDecorTilemap_3x2_Y[] = { 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05 }; -const u8 Unknown_085A70F8[] = { +static const u8 sDecorTilemap_1x1_X[] = { 0x04, 0x05, 0x06, 0x07 }; -const u8 Unknown_085A70FC[] = { +static const u8 sDecorTilemap_2x1_X[] = { 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07 }; -const u8 Unknown_085A7104[] = { +static const u8 sDecorTilemap_3x1_X[] = { 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07 }; -const u8 Unknown_085A7110[] = { +static const u8 sDecorTilemap_4x2_X[] = { 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07 }; -const u8 Unknown_085A7130[] = { +static const u8 sDecorTilemap_2x2_X[] = { 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07 }; -const u8 Unknown_085A7140[] = { +static const u8 sDecorTilemap_1x2_X[] = { 0x04, 0x05, 0x06, 0x07, 0x04, 0x05, 0x06, 0x07 }; -const u8 Unknown_085A7148[] = { +static const u8 sDecorTilemap_1x3_X[] = { 0x04, 0x05, 0x06, 0x07, 0x04, 0x05, 0x06, 0x07, 0x04, 0x05, 0x06, 0x07 }; -const u8 Unknown_085A7154[] = { +static const u8 sDecorTilemap_2x4_X[] = { 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07 }; -const u8 Unknown_085A7174[] = { +static const u8 sDecorTilemap_3x3_X[] = { 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, @@ -164,67 +164,78 @@ const u8 Unknown_085A7174[] = { 0x06, 0x07, 0x06, 0x07, 0x06, 0x07 }; -const u8 Unknown_085A7198[] = { +static const u8 sDecorTilemap_3x2_X[] = { 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07 }; -const struct { +#define DECORSIZE(width, height)((width) * (height) * 4) + +static const struct { const u8 *tiles; const u8 *y; const u8 *x; u8 size; -} gUnknown_085A71B0[] = { - { - Unknown_085A6FB0, - Unknown_085A7040, - Unknown_085A70F8, - 0x04 - }, { - Unknown_085A6FDC, - Unknown_085A7044, - Unknown_085A70FC, - 0x08 - }, { - Unknown_085A6FB4, - Unknown_085A704C, - Unknown_085A7104, - 0x0c - }, { - Unknown_085A6FE4, - Unknown_085A7058, - Unknown_085A7110, - 0x20 - }, { - Unknown_085A6FC0, - Unknown_085A7078, - Unknown_085A7130, - 0x10 - }, { - Unknown_085A6FDC, - Unknown_085A7088, - Unknown_085A7140, - 0x08 - }, { - Unknown_085A6FD0, - Unknown_085A7090, - Unknown_085A7148, - 0x0c - }, { - Unknown_085A6FE4, - Unknown_085A709C, - Unknown_085A7154, - 0x20 - }, { - Unknown_085A7004, - Unknown_085A70BC, - Unknown_085A7174, - 0x24 - }, { - Unknown_085A7028, - Unknown_085A70E0, - Unknown_085A7198, - 0x18 +} sDecorTilemaps[] = { + [DECORSHAPE_1x1] = { + .tiles = sDecorTilemap_1x1_Tiles, + .y = sDecorTilemap_1x1_Y, + .x = sDecorTilemap_1x1_X, + .size = DECORSIZE(1, 1) + }, + [DECORSHAPE_2x1] = { + .tiles = sDecorTilemap_2x1_Tiles, + .y = sDecorTilemap_2x1_Y, + .x = sDecorTilemap_2x1_X, + .size = DECORSIZE(2, 1) + }, + [DECORSHAPE_3x1] = { + .tiles = sDecorTilemap_3x1_Tiles, + .y = sDecorTilemap_3x1_Y, + .x = sDecorTilemap_3x1_X, + .size = DECORSIZE(3, 1) + }, + [DECORSHAPE_4x2] = { + .tiles = sDecorTilemap_4x2_Tiles, + .y = sDecorTilemap_4x2_Y, + .x = sDecorTilemap_4x2_X, + .size = DECORSIZE(4, 2) + }, + [DECORSHAPE_2x2] = { + .tiles = sDecorTilemap_2x2_Tiles, + .y = sDecorTilemap_2x2_Y, + .x = sDecorTilemap_2x2_X, + .size = DECORSIZE(2, 2) + }, + [DECORSHAPE_1x2] = { + .tiles = sDecorTilemap_2x1_Tiles, + .y = sDecorTilemap_1x2_Y, + .x = sDecorTilemap_1x2_X, + .size = DECORSIZE(1, 2) + }, + [DECORSHAPE_1x3] = { + .tiles = sDecorTilemap_1x3_Tiles, + .y = sDecorTilemap_1x3_Y, + .x = sDecorTilemap_1x3_X, + .size = DECORSIZE(1, 3) + }, + [DECORSHAPE_2x4] = { + .tiles = sDecorTilemap_4x2_Tiles, + .y = sDecorTilemap_2x4_Y, + .x = sDecorTilemap_2x4_X, + .size = DECORSIZE(2, 4) + }, + [DECORSHAPE_3x3] = { + .tiles = sDecorTilemap_3x3_Tiles, + .y = sDecorTilemap_3x3_Y, + .x = sDecorTilemap_3x3_X, + .size = DECORSIZE(3, 3) + }, + [DECORSHAPE_3x2] = { + .tiles = sDecorTilemap_3x2_Tiles, + .y = sDecorTilemap_3x2_Y, + .x = sDecorTilemap_3x2_X, + .size = DECORSIZE(3, 2) }}; diff --git a/src/data/decoration/tiles.h b/src/data/decoration/tiles.h index de5c43575..1b25da3d4 100644 --- a/src/data/decoration/tiles.h +++ b/src/data/decoration/tiles.h @@ -1,4 +1,4 @@ -#define DECOR_TILE(name) (METATILE_SecretBase_##name - 0x200) +#define DECOR_TILE(name) (METATILE_SecretBase_##name - NUM_TILES_IN_PRIMARY) const u16 DecorGfx_SMALL_DESK[] = { DECOR_TILE(SmallDesk) diff --git a/src/data/easy_chat/easy_chat_groups.h b/src/data/easy_chat/easy_chat_groups.h index df114d980..a89f228fe 100755 --- a/src/data/easy_chat/easy_chat_groups.h +++ b/src/data/easy_chat/easy_chat_groups.h @@ -26,112 +26,112 @@ const struct EasyChatGroup gEasyChatGroups[] = { { .wordData = {.valueList = gEasyChatGroup_Pokemon}, - .numWords = 202, - .numEnabledWords = 202, + .numWords = ARRAY_COUNT(gEasyChatGroup_Pokemon), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Pokemon), }, { .wordData = {.words = gEasyChatGroup_Trainer}, - .numWords = 27, - .numEnabledWords = 21, + .numWords = ARRAY_COUNT(gEasyChatGroup_Trainer), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Trainer) - 6, // Excludes Red, Green, Flame, Gold, Leaf, and Silver }, { .wordData = {.words = gEasyChatGroup_Status}, - .numWords = 109, - .numEnabledWords = 109, + .numWords = ARRAY_COUNT(gEasyChatGroup_Status), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Status), }, { .wordData = {.words = gEasyChatGroup_Battle}, - .numWords = 63, - .numEnabledWords = 63, + .numWords = ARRAY_COUNT(gEasyChatGroup_Battle), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Battle), }, { .wordData = {.words = gEasyChatGroup_Greetings}, - .numWords = 42, - .numEnabledWords = 42, + .numWords = ARRAY_COUNT(gEasyChatGroup_Greetings), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Greetings), }, { .wordData = {.words = gEasyChatGroup_People}, - .numWords = 75, - .numEnabledWords = 75, + .numWords = ARRAY_COUNT(gEasyChatGroup_People), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_People), }, { .wordData = {.words = gEasyChatGroup_Voices}, - .numWords = 63, - .numEnabledWords = 63, + .numWords = ARRAY_COUNT(gEasyChatGroup_Voices), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Voices), }, { .wordData = {.words = gEasyChatGroup_Speech}, - .numWords = 60, - .numEnabledWords = 60, + .numWords = ARRAY_COUNT(gEasyChatGroup_Speech), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Speech), }, { .wordData = {.words = gEasyChatGroup_Endings}, - .numWords = 69, - .numEnabledWords = 69, + .numWords = ARRAY_COUNT(gEasyChatGroup_Endings), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Endings), }, { .wordData = {.words = gEasyChatGroup_Feelings}, - .numWords = 69, - .numEnabledWords = 69, + .numWords = ARRAY_COUNT(gEasyChatGroup_Feelings), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Feelings), }, { .wordData = {.words = gEasyChatGroup_Conditions}, - .numWords = 69, - .numEnabledWords = 69, + .numWords = ARRAY_COUNT(gEasyChatGroup_Conditions), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Conditions), }, { .wordData = {.words = gEasyChatGroup_Actions}, - .numWords = 78, - .numEnabledWords = 78, + .numWords = ARRAY_COUNT(gEasyChatGroup_Actions), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Actions), }, { .wordData = {.words = gEasyChatGroup_Lifestyle}, - .numWords = 45, - .numEnabledWords = 45, + .numWords = ARRAY_COUNT(gEasyChatGroup_Lifestyle), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Lifestyle), }, { .wordData = {.words = gEasyChatGroup_Hobbies}, - .numWords = 54, - .numEnabledWords = 54, + .numWords = ARRAY_COUNT(gEasyChatGroup_Hobbies), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Hobbies), }, { .wordData = {.words = gEasyChatGroup_Time}, - .numWords = 45, - .numEnabledWords = 45, + .numWords = ARRAY_COUNT(gEasyChatGroup_Time), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Time), }, { .wordData = {.words = gEasyChatGroup_Misc}, - .numWords = 42, - .numEnabledWords = 42, + .numWords = ARRAY_COUNT(gEasyChatGroup_Misc), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Misc), }, { .wordData = {.words = gEasyChatGroup_Adjectives}, - .numWords = 36, - .numEnabledWords = 36, + .numWords = ARRAY_COUNT(gEasyChatGroup_Adjectives), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Adjectives), }, { .wordData = {.words = gEasyChatGroup_Events}, - .numWords = 29, - .numEnabledWords = 29, + .numWords = ARRAY_COUNT(gEasyChatGroup_Events), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Events), }, { .wordData = {.valueList = gEasyChatGroup_Move1}, - .numWords = 154, - .numEnabledWords = 154, + .numWords = ARRAY_COUNT(gEasyChatGroup_Move1), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Move1), }, { .wordData = {.valueList = gEasyChatGroup_Move2}, - .numWords = 200, - .numEnabledWords = 200, + .numWords = ARRAY_COUNT(gEasyChatGroup_Move2), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Move2), }, { .wordData = {.words = gEasyChatGroup_TrendySaying}, - .numWords = 33, - .numEnabledWords = 33, + .numWords = ARRAY_COUNT(gEasyChatGroup_TrendySaying), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_TrendySaying), }, { .wordData = {.valueList = gEasyChatGroup_Pokemon2}, - .numWords = 251, - .numEnabledWords = 251, + .numWords = ARRAY_COUNT(gEasyChatGroup_Pokemon2), + .numEnabledWords = ARRAY_COUNT(gEasyChatGroup_Pokemon2), }, }; diff --git a/src/data/items.h b/src/data/items.h index 30beb5352..443c45f1a 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -7,9 +7,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, // Pokeballs @@ -21,10 +20,10 @@ const struct Item gItems[] = .price = 0, .description = sMasterBallDesc, .pocket = POCKET_POKE_BALLS, - .type = 0, - .battleUsage = 2, + .type = ITEM_MASTER_BALL - FIRST_BALL, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_PokeBall, - .secondaryId = 0, + .secondaryId = ITEM_MASTER_BALL - FIRST_BALL, }, [ITEM_ULTRA_BALL] = @@ -34,10 +33,10 @@ const struct Item gItems[] = .price = 1200, .description = sUltraBallDesc, .pocket = POCKET_POKE_BALLS, - .type = 1, - .battleUsage = 2, + .type = ITEM_ULTRA_BALL - FIRST_BALL, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_PokeBall, - .secondaryId = 1, + .secondaryId = ITEM_ULTRA_BALL - FIRST_BALL, }, [ITEM_GREAT_BALL] = @@ -47,10 +46,10 @@ const struct Item gItems[] = .price = 600, .description = sGreatBallDesc, .pocket = POCKET_POKE_BALLS, - .type = 2, - .battleUsage = 2, + .type = ITEM_GREAT_BALL - FIRST_BALL, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_PokeBall, - .secondaryId = 2, + .secondaryId = ITEM_GREAT_BALL - FIRST_BALL, }, [ITEM_POKE_BALL] = @@ -60,10 +59,10 @@ const struct Item gItems[] = .price = 200, .description = sPokeBallDesc, .pocket = POCKET_POKE_BALLS, - .type = 3, - .battleUsage = 2, + .type = ITEM_POKE_BALL - FIRST_BALL, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_PokeBall, - .secondaryId = 3, + .secondaryId = ITEM_POKE_BALL - FIRST_BALL, }, [ITEM_SAFARI_BALL] = @@ -73,10 +72,10 @@ const struct Item gItems[] = .price = 0, .description = sSafariBallDesc, .pocket = POCKET_POKE_BALLS, - .type = 4, - .battleUsage = 2, + .type = ITEM_SAFARI_BALL - FIRST_BALL, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_PokeBall, - .secondaryId = 4, + .secondaryId = ITEM_SAFARI_BALL - FIRST_BALL, }, [ITEM_NET_BALL] = @@ -86,10 +85,10 @@ const struct Item gItems[] = .price = 1000, .description = sNetBallDesc, .pocket = POCKET_POKE_BALLS, - .type = 5, - .battleUsage = 2, + .type = ITEM_NET_BALL - FIRST_BALL, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_PokeBall, - .secondaryId = 5, + .secondaryId = ITEM_NET_BALL - FIRST_BALL, }, [ITEM_DIVE_BALL] = @@ -99,10 +98,10 @@ const struct Item gItems[] = .price = 1000, .description = sDiveBallDesc, .pocket = POCKET_POKE_BALLS, - .type = 6, - .battleUsage = 2, + .type = ITEM_DIVE_BALL - FIRST_BALL, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_PokeBall, - .secondaryId = 6, + .secondaryId = ITEM_DIVE_BALL - FIRST_BALL, }, [ITEM_NEST_BALL] = @@ -112,10 +111,10 @@ const struct Item gItems[] = .price = 1000, .description = sNestBallDesc, .pocket = POCKET_POKE_BALLS, - .type = 7, - .battleUsage = 2, + .type = ITEM_NEST_BALL - FIRST_BALL, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_PokeBall, - .secondaryId = 7, + .secondaryId = ITEM_NEST_BALL - FIRST_BALL, }, [ITEM_REPEAT_BALL] = @@ -125,10 +124,10 @@ const struct Item gItems[] = .price = 1000, .description = sRepeatBallDesc, .pocket = POCKET_POKE_BALLS, - .type = 8, - .battleUsage = 2, + .type = ITEM_REPEAT_BALL - FIRST_BALL, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_PokeBall, - .secondaryId = 8, + .secondaryId = ITEM_REPEAT_BALL - FIRST_BALL, }, [ITEM_TIMER_BALL] = @@ -138,10 +137,10 @@ const struct Item gItems[] = .price = 1000, .description = sTimerBallDesc, .pocket = POCKET_POKE_BALLS, - .type = 9, - .battleUsage = 2, + .type = ITEM_TIMER_BALL - FIRST_BALL, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_PokeBall, - .secondaryId = 9, + .secondaryId = ITEM_TIMER_BALL - FIRST_BALL, }, [ITEM_LUXURY_BALL] = @@ -151,10 +150,10 @@ const struct Item gItems[] = .price = 1000, .description = sLuxuryBallDesc, .pocket = POCKET_POKE_BALLS, - .type = 10, - .battleUsage = 2, + .type = ITEM_LUXURY_BALL - FIRST_BALL, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_PokeBall, - .secondaryId = 10, + .secondaryId = ITEM_LUXURY_BALL - FIRST_BALL, }, [ITEM_PREMIER_BALL] = @@ -164,10 +163,10 @@ const struct Item gItems[] = .price = 200, .description = sPremierBallDesc, .pocket = POCKET_POKE_BALLS, - .type = 11, - .battleUsage = 2, + .type = ITEM_PREMIER_BALL - FIRST_BALL, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_PokeBall, - .secondaryId = 11, + .secondaryId = ITEM_PREMIER_BALL - FIRST_BALL, }, // Medicine @@ -180,11 +179,10 @@ const struct Item gItems[] = .holdEffectParam = 20, .description = sPotionDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_ANTIDOTE] = @@ -194,11 +192,10 @@ const struct Item gItems[] = .price = 100, .description = sAntidoteDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_BURN_HEAL] = @@ -208,11 +205,10 @@ const struct Item gItems[] = .price = 250, .description = sBurnHealDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_ICE_HEAL] = @@ -222,11 +218,10 @@ const struct Item gItems[] = .price = 250, .description = sIceHealDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_AWAKENING] = @@ -236,11 +231,10 @@ const struct Item gItems[] = .price = 250, .description = sAwakeningDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_PARALYZE_HEAL] = @@ -250,11 +244,10 @@ const struct Item gItems[] = .price = 200, .description = sParalyzeHealDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_FULL_RESTORE] = @@ -265,11 +258,10 @@ const struct Item gItems[] = .holdEffectParam = 255, .description = sFullRestoreDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_MAX_POTION] = @@ -280,11 +272,10 @@ const struct Item gItems[] = .holdEffectParam = 255, .description = sMaxPotionDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_HYPER_POTION] = @@ -295,11 +286,10 @@ const struct Item gItems[] = .holdEffectParam = 200, .description = sHyperPotionDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_SUPER_POTION] = @@ -310,11 +300,10 @@ const struct Item gItems[] = .holdEffectParam = 50, .description = sSuperPotionDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_FULL_HEAL] = @@ -324,11 +313,10 @@ const struct Item gItems[] = .price = 600, .description = sFullHealDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_REVIVE] = @@ -338,11 +326,10 @@ const struct Item gItems[] = .price = 1500, .description = sReviveDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_MAX_REVIVE] = @@ -352,11 +339,10 @@ const struct Item gItems[] = .price = 4000, .description = sMaxReviveDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_FRESH_WATER] = @@ -367,11 +353,10 @@ const struct Item gItems[] = .holdEffectParam = 50, .description = sFreshWaterDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_SODA_POP] = @@ -382,11 +367,10 @@ const struct Item gItems[] = .holdEffectParam = 60, .description = sSodaPopDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_LEMONADE] = @@ -397,11 +381,10 @@ const struct Item gItems[] = .holdEffectParam = 80, .description = sLemonadeDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_MOOMOO_MILK] = @@ -412,11 +395,10 @@ const struct Item gItems[] = .holdEffectParam = 100, .description = sMoomooMilkDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_ENERGY_POWDER] = @@ -426,11 +408,10 @@ const struct Item gItems[] = .price = 500, .description = sEnergyPowderDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_ENERGY_ROOT] = @@ -440,11 +421,10 @@ const struct Item gItems[] = .price = 800, .description = sEnergyRootDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_HEAL_POWDER] = @@ -454,11 +434,10 @@ const struct Item gItems[] = .price = 450, .description = sHealPowderDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_REVIVAL_HERB] = @@ -468,11 +447,10 @@ const struct Item gItems[] = .price = 2800, .description = sRevivalHerbDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_ETHER] = @@ -483,11 +461,10 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sEtherDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_PPRecovery, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_PPRecovery, - .secondaryId = 0, }, [ITEM_MAX_ETHER] = @@ -498,11 +475,10 @@ const struct Item gItems[] = .holdEffectParam = 255, .description = sMaxEtherDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_PPRecovery, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_PPRecovery, - .secondaryId = 0, }, [ITEM_ELIXIR] = @@ -513,11 +489,10 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sElixirDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_PPRecovery, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_PPRecovery, - .secondaryId = 0, }, [ITEM_MAX_ELIXIR] = @@ -528,11 +503,10 @@ const struct Item gItems[] = .holdEffectParam = 255, .description = sMaxElixirDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_PPRecovery, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_PPRecovery, - .secondaryId = 0, }, [ITEM_LAVA_COOKIE] = @@ -542,11 +516,10 @@ const struct Item gItems[] = .price = 200, .description = sLavaCookieDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_BLUE_FLUTE] = @@ -556,11 +529,10 @@ const struct Item gItems[] = .price = 100, .description = sBlueFluteDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_YELLOW_FLUTE] = @@ -570,11 +542,10 @@ const struct Item gItems[] = .price = 200, .description = sYellowFluteDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_RED_FLUTE] = @@ -584,11 +555,10 @@ const struct Item gItems[] = .price = 300, .description = sRedFluteDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_BLACK_FLUTE] = @@ -599,9 +569,8 @@ const struct Item gItems[] = .holdEffectParam = 50, .description = sBlackFluteDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_BlackWhiteFlute, - .secondaryId = 0, }, [ITEM_WHITE_FLUTE] = @@ -612,9 +581,8 @@ const struct Item gItems[] = .holdEffectParam = 150, .description = sWhiteFluteDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_BlackWhiteFlute, - .secondaryId = 0, }, [ITEM_BERRY_JUICE] = @@ -626,11 +594,10 @@ const struct Item gItems[] = .holdEffectParam = 20, .description = sBerryJuiceDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_SACRED_ASH] = @@ -640,9 +607,8 @@ const struct Item gItems[] = .price = 200, .description = sSacredAshDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_SacredAsh, - .secondaryId = 0, }, // Collectibles @@ -654,9 +620,8 @@ const struct Item gItems[] = .price = 20, .description = sShoalSaltDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SHOAL_SHELL] = @@ -666,9 +631,8 @@ const struct Item gItems[] = .price = 20, .description = sShoalShellDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_RED_SHARD] = @@ -678,9 +642,8 @@ const struct Item gItems[] = .price = 200, .description = sRedShardDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_BLUE_SHARD] = @@ -690,9 +653,8 @@ const struct Item gItems[] = .price = 200, .description = sBlueShardDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_YELLOW_SHARD] = @@ -702,9 +664,8 @@ const struct Item gItems[] = .price = 200, .description = sYellowShardDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_GREEN_SHARD] = @@ -714,9 +675,8 @@ const struct Item gItems[] = .price = 200, .description = sGreenShardDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_034] = @@ -726,9 +686,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_035] = @@ -738,9 +697,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_036] = @@ -750,9 +708,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_037] = @@ -762,9 +719,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_038] = @@ -774,9 +730,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_039] = @@ -786,9 +741,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_03A] = @@ -798,9 +752,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_03B] = @@ -810,9 +763,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_03C] = @@ -822,9 +774,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_03D] = @@ -834,9 +785,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_03E] = @@ -846,9 +796,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, // Vitamins @@ -860,9 +809,8 @@ const struct Item gItems[] = .price = 9800, .description = sHPUpDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .secondaryId = 0, }, [ITEM_PROTEIN] = @@ -872,9 +820,8 @@ const struct Item gItems[] = .price = 9800, .description = sProteinDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .secondaryId = 0, }, [ITEM_IRON] = @@ -884,9 +831,8 @@ const struct Item gItems[] = .price = 9800, .description = sIronDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .secondaryId = 0, }, [ITEM_CARBOS] = @@ -896,9 +842,8 @@ const struct Item gItems[] = .price = 9800, .description = sCarbosDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .secondaryId = 0, }, [ITEM_CALCIUM] = @@ -908,9 +853,8 @@ const struct Item gItems[] = .price = 9800, .description = sCalciumDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .secondaryId = 0, }, [ITEM_RARE_CANDY] = @@ -920,9 +864,8 @@ const struct Item gItems[] = .price = 4800, .description = sRareCandyDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_RareCandy, - .secondaryId = 0, }, [ITEM_PP_UP] = @@ -932,9 +875,8 @@ const struct Item gItems[] = .price = 9800, .description = sPPUpDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_PPUp, - .secondaryId = 0, }, [ITEM_ZINC] = @@ -944,9 +886,8 @@ const struct Item gItems[] = .price = 9800, .description = sZincDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .secondaryId = 0, }, [ITEM_PP_MAX] = @@ -956,9 +897,8 @@ const struct Item gItems[] = .price = 9800, .description = sPPMaxDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_PPUp, - .secondaryId = 0, }, [ITEM_048] = @@ -968,9 +908,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, // Battle items @@ -982,11 +921,10 @@ const struct Item gItems[] = .price = 700, .description = sGuardSpecDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = 2, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_StatIncrease, - .secondaryId = 0, }, [ITEM_DIRE_HIT] = @@ -996,11 +934,10 @@ const struct Item gItems[] = .price = 650, .description = sDireHitDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = 2, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_StatIncrease, - .secondaryId = 0, }, [ITEM_X_ATTACK] = @@ -1010,11 +947,10 @@ const struct Item gItems[] = .price = 500, .description = sXAttackDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = 2, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_StatIncrease, - .secondaryId = 0, }, [ITEM_X_DEFEND] = @@ -1024,11 +960,10 @@ const struct Item gItems[] = .price = 550, .description = sXDefendDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = 2, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_StatIncrease, - .secondaryId = 0, }, [ITEM_X_SPEED] = @@ -1038,11 +973,10 @@ const struct Item gItems[] = .price = 350, .description = sXSpeedDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = 2, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_StatIncrease, - .secondaryId = 0, }, [ITEM_X_ACCURACY] = @@ -1052,11 +986,10 @@ const struct Item gItems[] = .price = 950, .description = sXAccuracyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = 2, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_StatIncrease, - .secondaryId = 0, }, [ITEM_X_SPECIAL] = @@ -1066,11 +999,10 @@ const struct Item gItems[] = .price = 350, .description = sXSpecialDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = 2, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_StatIncrease, - .secondaryId = 0, }, [ITEM_POKE_DOLL] = @@ -1080,11 +1012,10 @@ const struct Item gItems[] = .price = 1000, .description = sPokeDollDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = 2, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_Escape, - .secondaryId = 0, }, [ITEM_FLUFFY_TAIL] = @@ -1094,11 +1025,10 @@ const struct Item gItems[] = .price = 1000, .description = sFluffyTailDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = 2, + .battleUsage = ITEM_B_USE_OTHER, .battleUseFunc = ItemUseInBattle_Escape, - .secondaryId = 0, }, [ITEM_052] = @@ -1108,9 +1038,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, // Field items @@ -1123,9 +1052,8 @@ const struct Item gItems[] = .holdEffectParam = 200, .description = sSuperRepelDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_Repel, - .secondaryId = 0, }, [ITEM_MAX_REPEL] = @@ -1136,9 +1064,8 @@ const struct Item gItems[] = .holdEffectParam = 250, .description = sMaxRepelDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_Repel, - .secondaryId = 0, }, [ITEM_ESCAPE_ROPE] = @@ -1148,9 +1075,8 @@ const struct Item gItems[] = .price = 550, .description = sEscapeRopeDesc, .pocket = POCKET_ITEMS, - .type = 2, + .type = ITEM_USE_FIELD, .fieldUseFunc = ItemUseOutOfBattle_EscapeRope, - .secondaryId = 0, }, [ITEM_REPEL] = @@ -1161,9 +1087,8 @@ const struct Item gItems[] = .holdEffectParam = 100, .description = sRepelDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_Repel, - .secondaryId = 0, }, [ITEM_057] = @@ -1173,9 +1098,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_058] = @@ -1185,9 +1109,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_059] = @@ -1197,9 +1120,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_05A] = @@ -1209,9 +1131,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_05B] = @@ -1221,9 +1142,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_05C] = @@ -1233,9 +1153,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, // Evolution stones @@ -1247,9 +1166,8 @@ const struct Item gItems[] = .price = 2100, .description = sSunStoneDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_EvolutionStone, - .secondaryId = 0, }, [ITEM_MOON_STONE] = @@ -1259,9 +1177,8 @@ const struct Item gItems[] = .price = 0, .description = sMoonStoneDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_EvolutionStone, - .secondaryId = 0, }, [ITEM_FIRE_STONE] = @@ -1271,9 +1188,8 @@ const struct Item gItems[] = .price = 2100, .description = sFireStoneDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_EvolutionStone, - .secondaryId = 0, }, [ITEM_THUNDER_STONE] = @@ -1283,9 +1199,8 @@ const struct Item gItems[] = .price = 2100, .description = sThunderStoneDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_EvolutionStone, - .secondaryId = 0, }, [ITEM_WATER_STONE] = @@ -1295,9 +1210,8 @@ const struct Item gItems[] = .price = 2100, .description = sWaterStoneDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_EvolutionStone, - .secondaryId = 0, }, [ITEM_LEAF_STONE] = @@ -1307,9 +1221,8 @@ const struct Item gItems[] = .price = 2100, .description = sLeafStoneDesc, .pocket = POCKET_ITEMS, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_EvolutionStone, - .secondaryId = 0, }, [ITEM_063] = @@ -1319,9 +1232,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_064] = @@ -1331,9 +1243,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_065] = @@ -1343,9 +1254,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_066] = @@ -1355,9 +1265,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, // Valuable items @@ -1369,9 +1278,8 @@ const struct Item gItems[] = .price = 500, .description = sTinyMushroomDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_BIG_MUSHROOM] = @@ -1381,9 +1289,8 @@ const struct Item gItems[] = .price = 5000, .description = sBigMushroomDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_069] = @@ -1393,9 +1300,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_PEARL] = @@ -1405,9 +1311,8 @@ const struct Item gItems[] = .price = 1400, .description = sPearlDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_BIG_PEARL] = @@ -1417,9 +1322,8 @@ const struct Item gItems[] = .price = 7500, .description = sBigPearlDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_STARDUST] = @@ -1429,9 +1333,8 @@ const struct Item gItems[] = .price = 2000, .description = sStardustDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_STAR_PIECE] = @@ -1441,9 +1344,8 @@ const struct Item gItems[] = .price = 9800, .description = sStarPieceDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_NUGGET] = @@ -1453,9 +1355,8 @@ const struct Item gItems[] = .price = 10000, .description = sNuggetDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_HEART_SCALE] = @@ -1465,9 +1366,8 @@ const struct Item gItems[] = .price = 100, .description = sHeartScaleDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_070] = @@ -1477,9 +1377,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_071] = @@ -1489,9 +1388,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_072] = @@ -1501,9 +1399,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_073] = @@ -1513,9 +1410,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_074] = @@ -1525,9 +1421,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_075] = @@ -1537,9 +1432,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_076] = @@ -1549,9 +1443,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_077] = @@ -1561,9 +1454,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_078] = @@ -1573,9 +1465,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, // Mail @@ -1586,9 +1477,9 @@ const struct Item gItems[] = .price = 50, .description = sOrangeMailDesc, .pocket = POCKET_ITEMS, - .type = 0, + .type = ITEM_USE_MAIL, .fieldUseFunc = ItemUseOutOfBattle_Mail, - .secondaryId = 0, + .secondaryId = ITEM_ORANGE_MAIL - FIRST_MAIL_INDEX, }, [ITEM_HARBOR_MAIL] = @@ -1598,9 +1489,9 @@ const struct Item gItems[] = .price = 50, .description = sHarborMailDesc, .pocket = POCKET_ITEMS, - .type = 0, + .type = ITEM_USE_MAIL, .fieldUseFunc = ItemUseOutOfBattle_Mail, - .secondaryId = 1, + .secondaryId = ITEM_HARBOR_MAIL - FIRST_MAIL_INDEX, }, [ITEM_GLITTER_MAIL] = @@ -1610,9 +1501,9 @@ const struct Item gItems[] = .price = 50, .description = sGlitterMailDesc, .pocket = POCKET_ITEMS, - .type = 0, + .type = ITEM_USE_MAIL, .fieldUseFunc = ItemUseOutOfBattle_Mail, - .secondaryId = 2, + .secondaryId = ITEM_GLITTER_MAIL - FIRST_MAIL_INDEX, }, [ITEM_MECH_MAIL] = @@ -1622,9 +1513,9 @@ const struct Item gItems[] = .price = 50, .description = sMechMailDesc, .pocket = POCKET_ITEMS, - .type = 0, + .type = ITEM_USE_MAIL, .fieldUseFunc = ItemUseOutOfBattle_Mail, - .secondaryId = 3, + .secondaryId = ITEM_MECH_MAIL - FIRST_MAIL_INDEX, }, [ITEM_WOOD_MAIL] = @@ -1634,9 +1525,9 @@ const struct Item gItems[] = .price = 50, .description = sWoodMailDesc, .pocket = POCKET_ITEMS, - .type = 0, + .type = ITEM_USE_MAIL, .fieldUseFunc = ItemUseOutOfBattle_Mail, - .secondaryId = 4, + .secondaryId = ITEM_WOOD_MAIL - FIRST_MAIL_INDEX, }, [ITEM_WAVE_MAIL] = @@ -1646,9 +1537,9 @@ const struct Item gItems[] = .price = 50, .description = sWaveMailDesc, .pocket = POCKET_ITEMS, - .type = 0, + .type = ITEM_USE_MAIL, .fieldUseFunc = ItemUseOutOfBattle_Mail, - .secondaryId = 5, + .secondaryId = ITEM_WAVE_MAIL - FIRST_MAIL_INDEX, }, [ITEM_BEAD_MAIL] = @@ -1658,9 +1549,9 @@ const struct Item gItems[] = .price = 50, .description = sBeadMailDesc, .pocket = POCKET_ITEMS, - .type = 0, + .type = ITEM_USE_MAIL, .fieldUseFunc = ItemUseOutOfBattle_Mail, - .secondaryId = 6, + .secondaryId = ITEM_BEAD_MAIL - FIRST_MAIL_INDEX, }, [ITEM_SHADOW_MAIL] = @@ -1670,9 +1561,9 @@ const struct Item gItems[] = .price = 50, .description = sShadowMailDesc, .pocket = POCKET_ITEMS, - .type = 0, + .type = ITEM_USE_MAIL, .fieldUseFunc = ItemUseOutOfBattle_Mail, - .secondaryId = 7, + .secondaryId = ITEM_SHADOW_MAIL - FIRST_MAIL_INDEX, }, [ITEM_TROPIC_MAIL] = @@ -1682,9 +1573,9 @@ const struct Item gItems[] = .price = 50, .description = sTropicMailDesc, .pocket = POCKET_ITEMS, - .type = 0, + .type = ITEM_USE_MAIL, .fieldUseFunc = ItemUseOutOfBattle_Mail, - .secondaryId = 8, + .secondaryId = ITEM_TROPIC_MAIL - FIRST_MAIL_INDEX, }, [ITEM_DREAM_MAIL] = @@ -1694,9 +1585,9 @@ const struct Item gItems[] = .price = 50, .description = sDreamMailDesc, .pocket = POCKET_ITEMS, - .type = 0, + .type = ITEM_USE_MAIL, .fieldUseFunc = ItemUseOutOfBattle_Mail, - .secondaryId = 9, + .secondaryId = ITEM_DREAM_MAIL - FIRST_MAIL_INDEX, }, [ITEM_FAB_MAIL] = @@ -1706,9 +1597,9 @@ const struct Item gItems[] = .price = 50, .description = sFabMailDesc, .pocket = POCKET_ITEMS, - .type = 0, + .type = ITEM_USE_MAIL, .fieldUseFunc = ItemUseOutOfBattle_Mail, - .secondaryId = 10, + .secondaryId = ITEM_FAB_MAIL - FIRST_MAIL_INDEX, }, [ITEM_RETRO_MAIL] = @@ -1718,9 +1609,9 @@ const struct Item gItems[] = .price = 0, .description = sRetroMailDesc, .pocket = POCKET_ITEMS, - .type = 0, + .type = ITEM_USE_MAIL, .fieldUseFunc = ItemUseOutOfBattle_Mail, - .secondaryId = 11, + .secondaryId = ITEM_RETRO_MAIL - FIRST_MAIL_INDEX, }, // Berries @@ -1733,11 +1624,10 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_CURE_PAR, .description = sCheriBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_CHESTO_BERRY] = @@ -1748,11 +1638,10 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_CURE_SLP, .description = sChestoBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_PECHA_BERRY] = @@ -1763,11 +1652,10 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_CURE_PSN, .description = sPechaBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_RAWST_BERRY] = @@ -1778,11 +1666,10 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_CURE_BRN, .description = sRawstBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_ASPEAR_BERRY] = @@ -1793,11 +1680,10 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_CURE_FRZ, .description = sAspearBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_LEPPA_BERRY] = @@ -1809,11 +1695,10 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sLeppaBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_PPRecovery, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_PPRecovery, - .secondaryId = 0, }, [ITEM_ORAN_BERRY] = @@ -1825,11 +1710,10 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sOranBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_PERSIM_BERRY] = @@ -1840,11 +1724,10 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_CURE_CONFUSION, .description = sPersimBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_LUM_BERRY] = @@ -1855,11 +1738,10 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_CURE_STATUS, .description = sLumBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_SITRUS_BERRY] = @@ -1871,11 +1753,10 @@ const struct Item gItems[] = .holdEffectParam = 30, .description = sSitrusBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_Medicine, - .secondaryId = 0, }, [ITEM_FIGY_BERRY] = @@ -1887,9 +1768,8 @@ const struct Item gItems[] = .holdEffectParam = 8, .description = sFigyBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_WIKI_BERRY] = @@ -1901,9 +1781,8 @@ const struct Item gItems[] = .holdEffectParam = 8, .description = sWikiBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_MAGO_BERRY] = @@ -1915,9 +1794,8 @@ const struct Item gItems[] = .holdEffectParam = 8, .description = sMagoBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_AGUAV_BERRY] = @@ -1929,9 +1807,8 @@ const struct Item gItems[] = .holdEffectParam = 8, .description = sAguavBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_IAPAPA_BERRY] = @@ -1943,9 +1820,8 @@ const struct Item gItems[] = .holdEffectParam = 8, .description = sIapapaBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_RAZZ_BERRY] = @@ -1955,9 +1831,8 @@ const struct Item gItems[] = .price = 20, .description = sRazzBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_BLUK_BERRY] = @@ -1967,9 +1842,8 @@ const struct Item gItems[] = .price = 20, .description = sBlukBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_NANAB_BERRY] = @@ -1979,9 +1853,8 @@ const struct Item gItems[] = .price = 20, .description = sNanabBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_WEPEAR_BERRY] = @@ -1991,9 +1864,8 @@ const struct Item gItems[] = .price = 20, .description = sWepearBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_PINAP_BERRY] = @@ -2003,9 +1875,8 @@ const struct Item gItems[] = .price = 20, .description = sPinapBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_POMEG_BERRY] = @@ -2015,9 +1886,8 @@ const struct Item gItems[] = .price = 20, .description = sPomegBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_ReduceEV, - .secondaryId = 0, }, [ITEM_KELPSY_BERRY] = @@ -2027,9 +1897,8 @@ const struct Item gItems[] = .price = 20, .description = sKelpsyBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_ReduceEV, - .secondaryId = 0, }, [ITEM_QUALOT_BERRY] = @@ -2039,9 +1908,8 @@ const struct Item gItems[] = .price = 20, .description = sQualotBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_ReduceEV, - .secondaryId = 0, }, [ITEM_HONDEW_BERRY] = @@ -2051,9 +1919,8 @@ const struct Item gItems[] = .price = 20, .description = sHondewBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_ReduceEV, - .secondaryId = 0, }, [ITEM_GREPA_BERRY] = @@ -2063,9 +1930,8 @@ const struct Item gItems[] = .price = 20, .description = sGrepaBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_ReduceEV, - .secondaryId = 0, }, [ITEM_TAMATO_BERRY] = @@ -2075,9 +1941,8 @@ const struct Item gItems[] = .price = 20, .description = sTamatoBerryDesc, .pocket = POCKET_BERRIES, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_ReduceEV, - .secondaryId = 0, }, [ITEM_CORNN_BERRY] = @@ -2087,9 +1952,8 @@ const struct Item gItems[] = .price = 20, .description = sCornnBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_MAGOST_BERRY] = @@ -2099,9 +1963,8 @@ const struct Item gItems[] = .price = 20, .description = sMagostBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_RABUTA_BERRY] = @@ -2111,9 +1974,8 @@ const struct Item gItems[] = .price = 20, .description = sRabutaBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_NOMEL_BERRY] = @@ -2123,9 +1985,8 @@ const struct Item gItems[] = .price = 20, .description = sNomelBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SPELON_BERRY] = @@ -2135,9 +1996,8 @@ const struct Item gItems[] = .price = 20, .description = sSpelonBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_PAMTRE_BERRY] = @@ -2147,9 +2007,8 @@ const struct Item gItems[] = .price = 20, .description = sPamtreBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_WATMEL_BERRY] = @@ -2159,9 +2018,8 @@ const struct Item gItems[] = .price = 20, .description = sWatmelBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_DURIN_BERRY] = @@ -2171,9 +2029,8 @@ const struct Item gItems[] = .price = 20, .description = sDurinBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_BELUE_BERRY] = @@ -2183,9 +2040,8 @@ const struct Item gItems[] = .price = 20, .description = sBelueBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_LIECHI_BERRY] = @@ -2197,9 +2053,8 @@ const struct Item gItems[] = .holdEffectParam = 4, .description = sLiechiBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_GANLON_BERRY] = @@ -2211,9 +2066,8 @@ const struct Item gItems[] = .holdEffectParam = 4, .description = sGanlonBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SALAC_BERRY] = @@ -2225,9 +2079,8 @@ const struct Item gItems[] = .holdEffectParam = 4, .description = sSalacBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_PETAYA_BERRY] = @@ -2239,9 +2092,8 @@ const struct Item gItems[] = .holdEffectParam = 4, .description = sPetayaBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_APICOT_BERRY] = @@ -2253,9 +2105,8 @@ const struct Item gItems[] = .holdEffectParam = 4, .description = sApicotBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_LANSAT_BERRY] = @@ -2267,9 +2118,8 @@ const struct Item gItems[] = .holdEffectParam = 4, .description = sLansatBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_STARF_BERRY] = @@ -2281,9 +2131,8 @@ const struct Item gItems[] = .holdEffectParam = 4, .description = sStarfBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_ENIGMA_BERRY] = @@ -2293,11 +2142,10 @@ const struct Item gItems[] = .price = 20, .description = sEnigmaBerryDesc, .pocket = POCKET_BERRIES, - .type = 4, + .type = ITEM_USE_BAG_MENU, // Type handled by ItemUseOutOfBattle_EnigmaBerry .fieldUseFunc = ItemUseOutOfBattle_EnigmaBerry, - .battleUsage = 1, + .battleUsage = ITEM_B_USE_MEDICINE, .battleUseFunc = ItemUseInBattle_EnigmaBerry, - .secondaryId = 0, }, [ITEM_0B0] = @@ -2307,9 +2155,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0B1] = @@ -2319,9 +2166,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0B2] = @@ -2331,9 +2177,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, // Hold items @@ -2347,9 +2192,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sBrightPowderDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_WHITE_HERB] = @@ -2360,9 +2204,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_RESTORE_STATS, .description = sWhiteHerbDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_MACHO_BRACE] = @@ -2373,9 +2216,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_MACHO_BRACE, .description = sMachoBraceDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_EXP_SHARE] = @@ -2386,9 +2228,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_EXP_SHARE, .description = sExpShareDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_QUICK_CLAW] = @@ -2400,9 +2241,8 @@ const struct Item gItems[] = .holdEffectParam = 20, .description = sQuickClawDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SOOTHE_BELL] = @@ -2413,9 +2253,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_HAPPINESS_UP, .description = sSootheBellDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_MENTAL_HERB] = @@ -2426,9 +2265,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_CURE_ATTRACT, .description = sMentalHerbDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_CHOICE_BAND] = @@ -2439,9 +2277,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_CHOICE_BAND, .description = sChoiceBandDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_KINGS_ROCK] = @@ -2453,9 +2290,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sKingsRockDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SILVER_POWDER] = @@ -2467,9 +2303,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sSilverPowderDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_AMULET_COIN] = @@ -2481,9 +2316,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sAmuletCoinDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_CLEANSE_TAG] = @@ -2494,9 +2328,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_REPEL, .description = sCleanseTagDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SOUL_DEW] = @@ -2507,9 +2340,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_SOUL_DEW, .description = sSoulDewDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_DEEP_SEA_TOOTH] = @@ -2520,9 +2352,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_DEEP_SEA_TOOTH, .description = sDeepSeaToothDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_DEEP_SEA_SCALE] = @@ -2533,9 +2364,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_DEEP_SEA_SCALE, .description = sDeepSeaScaleDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SMOKE_BALL] = @@ -2546,9 +2376,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_CAN_ALWAYS_RUN, .description = sSmokeBallDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_EVERSTONE] = @@ -2559,9 +2388,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_PREVENT_EVOLVE, .description = sEverstoneDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_FOCUS_BAND] = @@ -2573,9 +2401,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sFocusBandDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_LUCKY_EGG] = @@ -2586,9 +2413,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_LUCKY_EGG, .description = sLuckyEggDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SCOPE_LENS] = @@ -2599,9 +2425,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_SCOPE_LENS, .description = sScopeLensDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_METAL_COAT] = @@ -2613,9 +2438,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sMetalCoatDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_LEFTOVERS] = @@ -2627,9 +2451,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sLeftoversDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_DRAGON_SCALE] = @@ -2641,9 +2464,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sDragonScaleDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_LIGHT_BALL] = @@ -2654,9 +2476,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_LIGHT_BALL, .description = sLightBallDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SOFT_SAND] = @@ -2668,9 +2489,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sSoftSandDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_HARD_STONE] = @@ -2682,9 +2502,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sHardStoneDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_MIRACLE_SEED] = @@ -2696,9 +2515,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sMiracleSeedDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_BLACK_GLASSES] = @@ -2710,9 +2528,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sBlackGlassesDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_BLACK_BELT] = @@ -2724,9 +2541,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sBlackBeltDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_MAGNET] = @@ -2738,9 +2554,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sMagnetDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_MYSTIC_WATER] = @@ -2752,9 +2567,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sMysticWaterDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SHARP_BEAK] = @@ -2766,9 +2580,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sSharpBeakDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_POISON_BARB] = @@ -2780,9 +2593,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sPoisonBarbDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_NEVER_MELT_ICE] = @@ -2794,9 +2606,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sNeverMeltIceDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SPELL_TAG] = @@ -2808,9 +2619,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sSpellTagDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_TWISTED_SPOON] = @@ -2822,9 +2632,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sTwistedSpoonDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_CHARCOAL] = @@ -2836,9 +2645,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sCharcoalDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_DRAGON_FANG] = @@ -2850,9 +2658,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sDragonFangDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SILK_SCARF] = @@ -2864,9 +2671,8 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sSilkScarfDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_UP_GRADE] = @@ -2877,9 +2683,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_UP_GRADE, .description = sUpGradeDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SHELL_BELL] = @@ -2891,9 +2696,8 @@ const struct Item gItems[] = .holdEffectParam = 8, .description = sShellBellDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SEA_INCENSE] = @@ -2905,9 +2709,8 @@ const struct Item gItems[] = .holdEffectParam = 5, .description = sSeaIncenseDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_LAX_INCENSE] = @@ -2919,9 +2722,8 @@ const struct Item gItems[] = .holdEffectParam = 5, .description = sLaxIncenseDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_LUCKY_PUNCH] = @@ -2932,9 +2734,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_LUCKY_PUNCH, .description = sLuckyPunchDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_METAL_POWDER] = @@ -2945,9 +2746,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_METAL_POWDER, .description = sMetalPowderDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_THICK_CLUB] = @@ -2958,9 +2758,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_THICK_CLUB, .description = sThickClubDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_STICK] = @@ -2971,9 +2770,8 @@ const struct Item gItems[] = .holdEffect = HOLD_EFFECT_STICK, .description = sStickDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0E2] = @@ -2983,9 +2781,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0E3] = @@ -2995,9 +2792,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0E4] = @@ -3007,9 +2803,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0E5] = @@ -3019,9 +2814,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0E6] = @@ -3031,9 +2825,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0E7] = @@ -3043,9 +2836,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0E8] = @@ -3055,9 +2847,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0E9] = @@ -3067,9 +2858,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0EA] = @@ -3079,9 +2869,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0EB] = @@ -3091,9 +2880,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0EC] = @@ -3103,9 +2891,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0ED] = @@ -3115,9 +2902,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0EE] = @@ -3127,9 +2913,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0EF] = @@ -3139,9 +2924,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0F0] = @@ -3151,9 +2935,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0F1] = @@ -3163,9 +2946,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0F2] = @@ -3175,9 +2957,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0F3] = @@ -3187,9 +2968,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0F4] = @@ -3199,9 +2979,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0F5] = @@ -3211,9 +2990,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0F6] = @@ -3223,9 +3001,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0F7] = @@ -3235,9 +3012,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0F8] = @@ -3247,9 +3023,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0F9] = @@ -3259,9 +3034,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0FA] = @@ -3271,9 +3045,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0FB] = @@ -3283,9 +3056,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0FC] = @@ -3295,9 +3067,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_0FD] = @@ -3307,9 +3078,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_RED_SCARF] = @@ -3319,9 +3089,8 @@ const struct Item gItems[] = .price = 100, .description = sRedScarfDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_BLUE_SCARF] = @@ -3331,9 +3100,8 @@ const struct Item gItems[] = .price = 100, .description = sBlueScarfDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_PINK_SCARF] = @@ -3343,9 +3111,8 @@ const struct Item gItems[] = .price = 100, .description = sPinkScarfDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_GREEN_SCARF] = @@ -3355,9 +3122,8 @@ const struct Item gItems[] = .price = 100, .description = sGreenScarfDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_YELLOW_SCARF] = @@ -3367,9 +3133,8 @@ const struct Item gItems[] = .price = 100, .description = sYellowScarfDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, // Key items @@ -3383,9 +3148,9 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 2, + .type = ITEM_USE_FIELD, .fieldUseFunc = ItemUseOutOfBattle_Bike, - .secondaryId = 0, + .secondaryId = MACH_BIKE, }, [ITEM_COIN_CASE] = @@ -3396,9 +3161,8 @@ const struct Item gItems[] = .description = sCoinCaseDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CoinCase, - .secondaryId = 0, }, [ITEM_ITEMFINDER] = @@ -3410,9 +3174,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 2, + .type = ITEM_USE_FIELD, .fieldUseFunc = ItemUseOutOfBattle_Itemfinder, - .secondaryId = 0, }, [ITEM_OLD_ROD] = @@ -3424,7 +3187,7 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 2, + .type = ITEM_USE_FIELD, .fieldUseFunc = ItemUseOutOfBattle_Rod, .secondaryId = OLD_ROD, }, @@ -3438,7 +3201,7 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 2, + .type = ITEM_USE_FIELD, .fieldUseFunc = ItemUseOutOfBattle_Rod, .secondaryId = GOOD_ROD, }, @@ -3452,7 +3215,7 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 2, + .type = ITEM_USE_FIELD, .fieldUseFunc = ItemUseOutOfBattle_Rod, .secondaryId = SUPER_ROD, }, @@ -3465,9 +3228,8 @@ const struct Item gItems[] = .description = sSSTicketDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_CONTEST_PASS] = @@ -3478,9 +3240,8 @@ const struct Item gItems[] = .description = sContestPassDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_10B] = @@ -3490,9 +3251,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_WAILMER_PAIL] = @@ -3503,9 +3263,8 @@ const struct Item gItems[] = .description = sWailmerPailDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 2, + .type = ITEM_USE_FIELD, .fieldUseFunc = ItemUseOutOfBattle_WailmerPail, - .secondaryId = 0, }, [ITEM_DEVON_GOODS] = @@ -3516,9 +3275,8 @@ const struct Item gItems[] = .description = sDevonGoodsDesc, .importance = 2, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SOOT_SACK] = @@ -3529,9 +3287,8 @@ const struct Item gItems[] = .description = sSootSackDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_BASEMENT_KEY] = @@ -3542,9 +3299,8 @@ const struct Item gItems[] = .description = sBasementKeyDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_ACRO_BIKE] = @@ -3556,9 +3312,9 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 2, + .type = ITEM_USE_FIELD, .fieldUseFunc = ItemUseOutOfBattle_Bike, - .secondaryId = 1, + .secondaryId = ACRO_BIKE, }, [ITEM_POKEBLOCK_CASE] = @@ -3570,9 +3326,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 3, + .type = ITEM_USE_PBLOCK_CASE, .fieldUseFunc = ItemUseOutOfBattle_PokeblockCase, - .secondaryId = 0, }, [ITEM_LETTER] = @@ -3583,9 +3338,8 @@ const struct Item gItems[] = .description = sLetterDesc, .importance = 2, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_EON_TICKET] = @@ -3596,7 +3350,7 @@ const struct Item gItems[] = .description = sEonTicketDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, .secondaryId = 1, }, @@ -3609,9 +3363,8 @@ const struct Item gItems[] = .description = sRedOrbDesc, .importance = 2, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_BLUE_ORB] = @@ -3622,9 +3375,8 @@ const struct Item gItems[] = .description = sBlueOrbDesc, .importance = 2, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SCANNER] = @@ -3635,9 +3387,8 @@ const struct Item gItems[] = .description = sScannerDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_GO_GOGGLES] = @@ -3648,9 +3399,8 @@ const struct Item gItems[] = .description = sGoGogglesDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_METEORITE] = @@ -3661,9 +3411,8 @@ const struct Item gItems[] = .description = sMeteoriteDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_ROOM_1_KEY] = @@ -3674,9 +3423,8 @@ const struct Item gItems[] = .description = sRoom1KeyDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_ROOM_2_KEY] = @@ -3687,9 +3435,8 @@ const struct Item gItems[] = .description = sRoom2KeyDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_ROOM_4_KEY] = @@ -3700,9 +3447,8 @@ const struct Item gItems[] = .description = sRoom4KeyDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_ROOM_6_KEY] = @@ -3713,9 +3459,8 @@ const struct Item gItems[] = .description = sRoom6KeyDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_STORAGE_KEY] = @@ -3726,9 +3471,8 @@ const struct Item gItems[] = .description = sStorageKeyDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_ROOT_FOSSIL] = @@ -3739,9 +3483,8 @@ const struct Item gItems[] = .description = sRootFossilDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_CLAW_FOSSIL] = @@ -3752,9 +3495,8 @@ const struct Item gItems[] = .description = sClawFossilDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_DEVON_SCOPE] = @@ -3765,9 +3507,8 @@ const struct Item gItems[] = .description = sDevonScopeDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, // TMs/HMs @@ -3779,9 +3520,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM01Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM02_DRAGON_CLAW] = @@ -3791,9 +3531,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM02Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM03_WATER_PULSE] = @@ -3803,9 +3542,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM03Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM04_CALM_MIND] = @@ -3815,9 +3553,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM04Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM05_ROAR] = @@ -3827,9 +3564,8 @@ const struct Item gItems[] = .price = 1000, .description = sTM05Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM06_TOXIC] = @@ -3839,9 +3575,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM06Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM07_HAIL] = @@ -3851,9 +3586,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM07Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM08_BULK_UP] = @@ -3863,9 +3597,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM08Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM09_BULLET_SEED] = @@ -3875,9 +3608,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM09Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM10_HIDDEN_POWER] = @@ -3887,9 +3619,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM10Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM11_SUNNY_DAY] = @@ -3899,9 +3630,8 @@ const struct Item gItems[] = .price = 2000, .description = sTM11Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM12_TAUNT] = @@ -3911,9 +3641,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM12Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM13_ICE_BEAM] = @@ -3923,9 +3652,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM13Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM14_BLIZZARD] = @@ -3935,9 +3663,8 @@ const struct Item gItems[] = .price = 5500, .description = sTM14Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM15_HYPER_BEAM] = @@ -3947,9 +3674,8 @@ const struct Item gItems[] = .price = 7500, .description = sTM15Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM16_LIGHT_SCREEN] = @@ -3959,9 +3685,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM16Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM17_PROTECT] = @@ -3971,9 +3696,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM17Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM18_RAIN_DANCE] = @@ -3983,9 +3707,8 @@ const struct Item gItems[] = .price = 2000, .description = sTM18Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM19_GIGA_DRAIN] = @@ -3995,9 +3718,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM19Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM20_SAFEGUARD] = @@ -4007,9 +3729,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM20Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM21_FRUSTRATION] = @@ -4019,9 +3740,8 @@ const struct Item gItems[] = .price = 1000, .description = sTM21Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM22_SOLARBEAM] = @@ -4031,9 +3751,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM22Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM23_IRON_TAIL] = @@ -4043,9 +3762,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM23Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM24_THUNDERBOLT] = @@ -4055,9 +3773,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM24Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM25_THUNDER] = @@ -4067,9 +3784,8 @@ const struct Item gItems[] = .price = 5500, .description = sTM25Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM26_EARTHQUAKE] = @@ -4079,9 +3795,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM26Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM27_RETURN] = @@ -4091,9 +3806,8 @@ const struct Item gItems[] = .price = 1000, .description = sTM27Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM28_DIG] = @@ -4103,9 +3817,8 @@ const struct Item gItems[] = .price = 2000, .description = sTM28Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM29_PSYCHIC] = @@ -4115,9 +3828,8 @@ const struct Item gItems[] = .price = 2000, .description = sTM29Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM30_SHADOW_BALL] = @@ -4127,9 +3839,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM30Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM31_BRICK_BREAK] = @@ -4139,9 +3850,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM31Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM32_DOUBLE_TEAM] = @@ -4151,9 +3861,8 @@ const struct Item gItems[] = .price = 2000, .description = sTM32Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM33_REFLECT] = @@ -4163,9 +3872,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM33Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM34_SHOCK_WAVE] = @@ -4175,9 +3883,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM34Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM35_FLAMETHROWER] = @@ -4187,9 +3894,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM35Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM36_SLUDGE_BOMB] = @@ -4199,9 +3905,8 @@ const struct Item gItems[] = .price = 1000, .description = sTM36Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM37_SANDSTORM] = @@ -4211,9 +3916,8 @@ const struct Item gItems[] = .price = 2000, .description = sTM37Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM38_FIRE_BLAST] = @@ -4223,9 +3927,8 @@ const struct Item gItems[] = .price = 5500, .description = sTM38Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM39_ROCK_TOMB] = @@ -4235,9 +3938,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM39Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM40_AERIAL_ACE] = @@ -4247,9 +3949,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM40Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM41_TORMENT] = @@ -4259,9 +3960,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM41Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM42_FACADE] = @@ -4271,9 +3971,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM42Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM43_SECRET_POWER] = @@ -4283,9 +3982,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM43Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM44_REST] = @@ -4295,9 +3993,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM44Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM45_ATTRACT] = @@ -4307,9 +4004,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM45Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM46_THIEF] = @@ -4319,9 +4015,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM46Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM47_STEEL_WING] = @@ -4331,9 +4026,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM47Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM48_SKILL_SWAP] = @@ -4343,9 +4037,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM48Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM49_SNATCH] = @@ -4355,9 +4048,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM49Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_TM50_OVERHEAT] = @@ -4367,9 +4059,8 @@ const struct Item gItems[] = .price = 3000, .description = sTM50Desc, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_HM01_CUT] = @@ -4380,9 +4071,8 @@ const struct Item gItems[] = .description = sHM01Desc, .importance = 1, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_HM02_FLY] = @@ -4393,9 +4083,8 @@ const struct Item gItems[] = .description = sHM02Desc, .importance = 1, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_HM03_SURF] = @@ -4406,9 +4095,8 @@ const struct Item gItems[] = .description = sHM03Desc, .importance = 1, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_HM04_STRENGTH] = @@ -4419,9 +4107,8 @@ const struct Item gItems[] = .description = sHM04Desc, .importance = 1, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_HM05_FLASH] = @@ -4432,9 +4119,8 @@ const struct Item gItems[] = .description = sHM05Desc, .importance = 1, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_HM06_ROCK_SMASH] = @@ -4445,9 +4131,8 @@ const struct Item gItems[] = .description = sHM06Desc, .importance = 1, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_HM07_WATERFALL] = @@ -4458,9 +4143,8 @@ const struct Item gItems[] = .description = sHM07Desc, .importance = 1, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_HM08_DIVE] = @@ -4471,9 +4155,8 @@ const struct Item gItems[] = .description = sHM08Desc, .importance = 1, .pocket = POCKET_TM_HM, - .type = 1, + .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_TMHM, - .secondaryId = 0, }, [ITEM_15B] = @@ -4483,9 +4166,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_15C] = @@ -4495,9 +4177,8 @@ const struct Item gItems[] = .price = 0, .description = sDummyDesc, .pocket = POCKET_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, // FireRed/LeafGreen key items @@ -4510,9 +4191,8 @@ const struct Item gItems[] = .description = sOaksParcelDesc, .importance = 2, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_POKE_FLUTE] = @@ -4523,9 +4203,8 @@ const struct Item gItems[] = .description = sPokeFluteDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SECRET_KEY] = @@ -4536,9 +4215,8 @@ const struct Item gItems[] = .description = sSecretKeyDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_BIKE_VOUCHER] = @@ -4549,9 +4227,8 @@ const struct Item gItems[] = .description = sBikeVoucherDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_GOLD_TEETH] = @@ -4562,9 +4239,8 @@ const struct Item gItems[] = .description = sGoldTeethDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_OLD_AMBER] = @@ -4575,9 +4251,8 @@ const struct Item gItems[] = .description = sOldAmberDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_CARD_KEY] = @@ -4588,9 +4263,8 @@ const struct Item gItems[] = .description = sCardKeyDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_LIFT_KEY] = @@ -4601,9 +4275,8 @@ const struct Item gItems[] = .description = sLiftKeyDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_HELIX_FOSSIL] = @@ -4614,9 +4287,8 @@ const struct Item gItems[] = .description = sHelixFossilDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_DOME_FOSSIL] = @@ -4627,9 +4299,8 @@ const struct Item gItems[] = .description = sDomeFossilDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SILPH_SCOPE] = @@ -4640,9 +4311,8 @@ const struct Item gItems[] = .description = sSilphScopeDesc, .importance = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_BICYCLE] = @@ -4654,9 +4324,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 2, + .type = ITEM_USE_FIELD, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_TOWN_MAP] = @@ -4668,9 +4337,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_VS_SEEKER] = @@ -4682,9 +4350,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 2, + .type = ITEM_USE_FIELD, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_FAME_CHECKER] = @@ -4696,9 +4363,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_TM_CASE] = @@ -4710,9 +4376,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_BERRY_POUCH] = @@ -4724,9 +4389,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_TEACHY_TV] = @@ -4738,9 +4402,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 2, + .type = ITEM_USE_FIELD, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_TRI_PASS] = @@ -4752,9 +4415,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_RAINBOW_PASS] = @@ -4766,9 +4428,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_TEA] = @@ -4780,9 +4441,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_MYSTIC_TICKET] = @@ -4794,9 +4454,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_AURORA_TICKET] = @@ -4808,9 +4467,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_POWDER_JAR] = @@ -4822,9 +4480,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_PowderJar, - .secondaryId = 0, }, [ITEM_RUBY] = @@ -4836,9 +4493,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_SAPPHIRE] = @@ -4850,9 +4506,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, // Emerald-specific key items @@ -4866,9 +4521,8 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, [ITEM_OLD_SEA_MAP] = @@ -4880,8 +4534,7 @@ const struct Item gItems[] = .importance = 1, .unk19 = 1, .pocket = POCKET_KEY_ITEMS, - .type = 4, + .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .secondaryId = 0, }, }; diff --git a/src/data/party_menu.h b/src/data/party_menu.h index ee1462c52..c36d7877b 100644 --- a/src/data/party_menu.h +++ b/src/data/party_menu.h @@ -1180,62 +1180,62 @@ static const u8 *const sUnused_StatStrings[] = static const u16 sTMHMMoves[] = { - MOVE_FOCUS_PUNCH, - MOVE_DRAGON_CLAW, - MOVE_WATER_PULSE, - MOVE_CALM_MIND, - MOVE_ROAR, - MOVE_TOXIC, - MOVE_HAIL, - MOVE_BULK_UP, - MOVE_BULLET_SEED, - MOVE_HIDDEN_POWER, - MOVE_SUNNY_DAY, - MOVE_TAUNT, - MOVE_ICE_BEAM, - MOVE_BLIZZARD, - MOVE_HYPER_BEAM, - MOVE_LIGHT_SCREEN, - MOVE_PROTECT, - MOVE_RAIN_DANCE, - MOVE_GIGA_DRAIN, - MOVE_SAFEGUARD, - MOVE_FRUSTRATION, - MOVE_SOLAR_BEAM, - MOVE_IRON_TAIL, - MOVE_THUNDERBOLT, - MOVE_THUNDER, - MOVE_EARTHQUAKE, - MOVE_RETURN, - MOVE_DIG, - MOVE_PSYCHIC, - MOVE_SHADOW_BALL, - MOVE_BRICK_BREAK, - MOVE_DOUBLE_TEAM, - MOVE_REFLECT, - MOVE_SHOCK_WAVE, - MOVE_FLAMETHROWER, - MOVE_SLUDGE_BOMB, - MOVE_SANDSTORM, - MOVE_FIRE_BLAST, - MOVE_ROCK_TOMB, - MOVE_AERIAL_ACE, - MOVE_TORMENT, - MOVE_FACADE, - MOVE_SECRET_POWER, - MOVE_REST, - MOVE_ATTRACT, - MOVE_THIEF, - MOVE_STEEL_WING, - MOVE_SKILL_SWAP, - MOVE_SNATCH, - MOVE_OVERHEAT, - MOVE_CUT, - MOVE_FLY, - MOVE_SURF, - MOVE_STRENGTH, - MOVE_FLASH, - MOVE_ROCK_SMASH, - MOVE_WATERFALL, - MOVE_DIVE, + [ITEM_TM01 - ITEM_TM01] = MOVE_FOCUS_PUNCH, + [ITEM_TM02 - ITEM_TM01] = MOVE_DRAGON_CLAW, + [ITEM_TM03 - ITEM_TM01] = MOVE_WATER_PULSE, + [ITEM_TM04 - ITEM_TM01] = MOVE_CALM_MIND, + [ITEM_TM05 - ITEM_TM01] = MOVE_ROAR, + [ITEM_TM06 - ITEM_TM01] = MOVE_TOXIC, + [ITEM_TM07 - ITEM_TM01] = MOVE_HAIL, + [ITEM_TM08 - ITEM_TM01] = MOVE_BULK_UP, + [ITEM_TM09 - ITEM_TM01] = MOVE_BULLET_SEED, + [ITEM_TM10 - ITEM_TM01] = MOVE_HIDDEN_POWER, + [ITEM_TM11 - ITEM_TM01] = MOVE_SUNNY_DAY, + [ITEM_TM12 - ITEM_TM01] = MOVE_TAUNT, + [ITEM_TM13 - ITEM_TM01] = MOVE_ICE_BEAM, + [ITEM_TM14 - ITEM_TM01] = MOVE_BLIZZARD, + [ITEM_TM15 - ITEM_TM01] = MOVE_HYPER_BEAM, + [ITEM_TM16 - ITEM_TM01] = MOVE_LIGHT_SCREEN, + [ITEM_TM17 - ITEM_TM01] = MOVE_PROTECT, + [ITEM_TM18 - ITEM_TM01] = MOVE_RAIN_DANCE, + [ITEM_TM19 - ITEM_TM01] = MOVE_GIGA_DRAIN, + [ITEM_TM20 - ITEM_TM01] = MOVE_SAFEGUARD, + [ITEM_TM21 - ITEM_TM01] = MOVE_FRUSTRATION, + [ITEM_TM22 - ITEM_TM01] = MOVE_SOLAR_BEAM, + [ITEM_TM23 - ITEM_TM01] = MOVE_IRON_TAIL, + [ITEM_TM24 - ITEM_TM01] = MOVE_THUNDERBOLT, + [ITEM_TM25 - ITEM_TM01] = MOVE_THUNDER, + [ITEM_TM26 - ITEM_TM01] = MOVE_EARTHQUAKE, + [ITEM_TM27 - ITEM_TM01] = MOVE_RETURN, + [ITEM_TM28 - ITEM_TM01] = MOVE_DIG, + [ITEM_TM29 - ITEM_TM01] = MOVE_PSYCHIC, + [ITEM_TM30 - ITEM_TM01] = MOVE_SHADOW_BALL, + [ITEM_TM31 - ITEM_TM01] = MOVE_BRICK_BREAK, + [ITEM_TM32 - ITEM_TM01] = MOVE_DOUBLE_TEAM, + [ITEM_TM33 - ITEM_TM01] = MOVE_REFLECT, + [ITEM_TM34 - ITEM_TM01] = MOVE_SHOCK_WAVE, + [ITEM_TM35 - ITEM_TM01] = MOVE_FLAMETHROWER, + [ITEM_TM36 - ITEM_TM01] = MOVE_SLUDGE_BOMB, + [ITEM_TM37 - ITEM_TM01] = MOVE_SANDSTORM, + [ITEM_TM38 - ITEM_TM01] = MOVE_FIRE_BLAST, + [ITEM_TM39 - ITEM_TM01] = MOVE_ROCK_TOMB, + [ITEM_TM40 - ITEM_TM01] = MOVE_AERIAL_ACE, + [ITEM_TM41 - ITEM_TM01] = MOVE_TORMENT, + [ITEM_TM42 - ITEM_TM01] = MOVE_FACADE, + [ITEM_TM43 - ITEM_TM01] = MOVE_SECRET_POWER, + [ITEM_TM44 - ITEM_TM01] = MOVE_REST, + [ITEM_TM45 - ITEM_TM01] = MOVE_ATTRACT, + [ITEM_TM46 - ITEM_TM01] = MOVE_THIEF, + [ITEM_TM47 - ITEM_TM01] = MOVE_STEEL_WING, + [ITEM_TM48 - ITEM_TM01] = MOVE_SKILL_SWAP, + [ITEM_TM49 - ITEM_TM01] = MOVE_SNATCH, + [ITEM_TM50 - ITEM_TM01] = MOVE_OVERHEAT, + [ITEM_HM01 - ITEM_TM01] = MOVE_CUT, + [ITEM_HM02 - ITEM_TM01] = MOVE_FLY, + [ITEM_HM03 - ITEM_TM01] = MOVE_SURF, + [ITEM_HM04 - ITEM_TM01] = MOVE_STRENGTH, + [ITEM_HM05 - ITEM_TM01] = MOVE_FLASH, + [ITEM_HM06 - ITEM_TM01] = MOVE_ROCK_SMASH, + [ITEM_HM07 - ITEM_TM01] = MOVE_WATERFALL, + [ITEM_HM08 - ITEM_TM01] = MOVE_DIVE, }; diff --git a/src/daycare.c b/src/daycare.c index 511fa0551..2a1efefcc 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -838,7 +838,7 @@ void CreateEgg(struct Pokemon *mon, u16 species, bool8 setHotSpringsLocation) u8 metLocation; u8 isEgg; - CreateMon(mon, species, EGG_HATCH_LEVEL, 32, FALSE, 0, OT_ID_PLAYER_ID, 0); + CreateMon(mon, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); metLevel = 0; ball = ITEM_POKE_BALL; language = LANGUAGE_JAPANESE; @@ -865,7 +865,7 @@ static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare * u8 language; personality = daycare->offspringPersonality; - CreateMon(mon, species, EGG_HATCH_LEVEL, 32, TRUE, personality, OT_ID_PLAYER_ID, 0); + CreateMon(mon, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, TRUE, personality, OT_ID_PLAYER_ID, 0); metLevel = 0; ball = ITEM_POKE_BALL; language = LANGUAGE_JAPANESE; diff --git a/src/decoration.c b/src/decoration.c index 74dbacdf9..484398aba 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -113,7 +113,7 @@ EWRAM_DATA static u16 sDecorationsCursorPos = 0; EWRAM_DATA static u16 sDecorationsScrollOffset = 0; EWRAM_DATA u8 gCurDecorationIndex = 0; EWRAM_DATA static u8 sCurDecorationCategory = DECORCAT_DESK; -EWRAM_DATA static u32 filler_0203a174[2] = {}; +EWRAM_DATA static u32 sFiller[2] = {}; EWRAM_DATA static struct DecorationPCContext sDecorationContext = {}; EWRAM_DATA static u8 sDecorMenuWindowIds[WINDOW_COUNT] = {}; EWRAM_DATA static struct DecorationItemsMenu *sDecorationItemsMenu = NULL; @@ -1210,7 +1210,7 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, for (i = 0; i < decWidth; i++) { x = mapX + i; - behavior = GetBehaviorByMetatileId(0x200 + gDecorations[decoration].tiles[j * decWidth + i]); + behavior = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + gDecorations[decoration].tiles[j * decWidth + i]); if (MetatileBehavior_IsSecretBaseImpassable(behavior) == TRUE || (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (behavior >> METATILE_ELEVATION_SHIFT))) impassableFlag = METATILE_COLLISION_MASK; else @@ -1224,9 +1224,9 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, elevation = GetDecorationElevation(gDecorations[decoration].id, j * decWidth + i); if (elevation != 0xFFFF) - MapGridSetMetatileEntryAt(x, y, (gDecorations[decoration].tiles[j * decWidth + i] + (0x200 | overlapsWall)) | impassableFlag | elevation); + MapGridSetMetatileEntryAt(x, y, (gDecorations[decoration].tiles[j * decWidth + i] + (NUM_TILES_IN_PRIMARY | overlapsWall)) | impassableFlag | elevation); else - MapGridSetMetatileIdAt(x, y, (gDecorations[decoration].tiles[j * decWidth + i] + (0x200 | overlapsWall)) | impassableFlag); + MapGridSetMetatileIdAt(x, y, (gDecorations[decoration].tiles[j * decWidth + i] + (NUM_TILES_IN_PRIMARY | overlapsWall)) | impassableFlag); } } } @@ -1524,7 +1524,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) { curX = gTasks[taskId].tCursorX + j; behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); - behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK; + behaviorBy = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK; if (!IsFloorOrBoardAndHole(behaviorAt, decoration)) return FALSE; @@ -1545,7 +1545,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) { curX = gTasks[taskId].tCursorX + j; behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); - behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK; + behaviorBy = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK; if (!MetatileBehavior_IsNormal(behaviorAt) && !IsNonBlockNonElevated(behaviorAt, behaviorBy)) return FALSE; @@ -1562,7 +1562,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) { curX = gTasks[taskId].tCursorX + j; behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); - behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[j]) & METATILE_ELEVATION_MASK; + behaviorBy = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + decoration->tiles[j]) & METATILE_ELEVATION_MASK; if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt)) return FALSE; @@ -1971,9 +1971,9 @@ static void SetDecorSelectionMetatiles(struct PlaceDecorationGraphicsDataBuffer u8 shape; shape = data->decoration->shape; - for (i = 0; i < gUnknown_085A71B0[shape].size; i++) + for (i = 0; i < sDecorTilemaps[shape].size; i++) { - data->tiles[gUnknown_085A71B0[shape].tiles[i]] = GetMetatile(data->decoration->tiles[gUnknown_085A71B0[shape].y[i]] * 8 + gUnknown_085A71B0[shape].x[i]); + data->tiles[sDecorTilemaps[shape].tiles[i]] = GetMetatile(data->decoration->tiles[sDecorTilemaps[shape].y[i]] * 8 + sDecorTilemaps[shape].x[i]); } } diff --git a/src/diploma.c b/src/diploma.c index f243d09f9..8f04bb9ad 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -168,7 +168,7 @@ static const struct BgTemplate sDiplomaBgTemplates[2] = static void InitDiplomaBg(void) { ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sDiplomaBgTemplates, 2); + InitBgsFromTemplates(0, sDiplomaBgTemplates, ARRAY_COUNT(sDiplomaBgTemplates)); SetBgTilemapBuffer(1, sDiplomaTilemapPtr); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); ShowBg(0); diff --git a/src/easy_chat.c b/src/easy_chat.c index 2590eea1a..6bb77bc84 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -4073,7 +4073,6 @@ static void sub_811D864(u8 arg0, u8 arg1) { int i, j; u16 easyChatWord; - u8 *str; int y; int var0; diff --git a/src/egg_hatch.c b/src/egg_hatch.c index cdaa032b5..a47fff3f1 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -322,7 +322,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) pokerus = GetMonData(egg, MON_DATA_POKERUS); obedience = GetMonData(egg, MON_DATA_OBEDIENCE); - CreateMon(temp, species, EGG_HATCH_LEVEL, 32, TRUE, personality, OT_ID_PLAYER_ID, 0); + CreateMon(temp, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, TRUE, personality, OT_ID_PLAYER_ID, 0); for (i = 0; i < MAX_MON_MOVES; i++) { diff --git a/src/ereader_screen.c b/src/ereader_screen.c index 3f2cf3217..d27605c1d 100755 --- a/src/ereader_screen.c +++ b/src/ereader_screen.c @@ -211,7 +211,6 @@ static u32 sub_81D4EE4(u8 *arg0, u16 *arg1) void task_add_00_ereader(void) { - int value; struct Unk81D5014 *data; u8 taskId = CreateTask(sub_81D5084, 0); data = (struct Unk81D5014 *)gTasks[taskId].data; diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 12ef4acdc..d9c06eb10 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -87,7 +87,7 @@ static void GetGroundEffectFlags_Puddle(struct ObjectEvent*, u32*); static void GetGroundEffectFlags_Ripple(struct ObjectEvent*, u32*); static void GetGroundEffectFlags_Seaweed(struct ObjectEvent*, u32*); static void GetGroundEffectFlags_JumpLanding(struct ObjectEvent*, u32*); -static u8 ObjectEventCheckForReflectiveSurface(struct ObjectEvent*); +static u8 ObjectEventGetNearbyReflectionType(struct ObjectEvent*); static u8 GetReflectionTypeByMetatileBehavior(u32); static void InitObjectPriorityByZCoord(struct Sprite *sprite, u8 z); static void ObjectEventUpdateSubpriority(struct ObjectEvent*, struct Sprite*); @@ -130,7 +130,6 @@ static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8 localId, static void ClearObjectEventMovement(struct ObjectEvent *, struct Sprite *); static void ObjectEventSetSingleMovement(struct ObjectEvent *, struct Sprite *, u8); static void oamt_npc_ministep_reset(struct Sprite *, u8, u8); -static void UpdateObjectEventSpriteSubpriorityAndVisibility(struct Sprite *); static void InitSpriteForFigure8Anim(struct Sprite *sprite); static bool8 AnimateSpriteInFigure8(struct Sprite *sprite); static void UpdateObjectEventSprite(struct Sprite *); @@ -7514,21 +7513,23 @@ static void ObjectEventUpdateMetatileBehaviors(struct ObjectEvent *objEvent) static void GetGroundEffectFlags_Reflection(struct ObjectEvent *objEvent, u32 *flags) { - u32 reflectionFlags[2] = { GROUND_EFFECT_FLAG_REFLECTION, GROUND_EFFECT_FLAG_ICE_REFLECTION }; - u8 type = ObjectEventCheckForReflectiveSurface(objEvent); + u32 reflectionFlags[NUM_REFLECTION_TYPES - 1] = { + [REFL_TYPE_ICE - 1] = GROUND_EFFECT_FLAG_ICE_REFLECTION, + [REFL_TYPE_WATER - 1] = GROUND_EFFECT_FLAG_WATER_REFLECTION + }; + u8 reflType = ObjectEventGetNearbyReflectionType(objEvent); - if (type) + if (reflType) { - if (!objEvent->hasReflection) + if (objEvent->hasReflection == 0) { - objEvent->hasReflection = 0; - objEvent->hasReflection = 1; - *flags |= reflectionFlags[type - 1]; + objEvent->hasReflection++; + *flags |= reflectionFlags[reflType - 1]; } } else { - objEvent->hasReflection = 0; + objEvent->hasReflection = FALSE; } } @@ -7701,26 +7702,24 @@ static void GetGroundEffectFlags_JumpLanding(struct ObjectEvent *objEvent, u32 * } } -static u8 ObjectEventCheckForReflectiveSurface(struct ObjectEvent *objEvent) +#define RETURN_REFLECTION_TYPE_AT(x, y) \ + b = MapGridGetMetatileBehaviorAt(x, y); \ + result = GetReflectionTypeByMetatileBehavior(b); \ + if (result != REFL_TYPE_NONE) \ + return result; + +static u8 ObjectEventGetNearbyReflectionType(struct ObjectEvent *objEvent) { const struct ObjectEventGraphicsInfo *info = GetObjectEventGraphicsInfo(objEvent->graphicsId); // ceil div by tile width? s16 width = (info->width + 8) >> 4; s16 height = (info->height + 8) >> 4; - s16 i; - s16 j; - u8 result; - u8 b; - s16 one; + s16 i, j; + u8 result, b; // used by RETURN_REFLECTION_TYPE_AT + s16 one = 1; -#define RETURN_REFLECTION_TYPE_AT(x, y) \ - b = MapGridGetMetatileBehaviorAt(x, y); \ - result = GetReflectionTypeByMetatileBehavior(b); \ - if (result != 0) \ - return result; - - for (i = 0, one = 1; i < height; i++) + for (i = 0; i < height; i++) { RETURN_REFLECTION_TYPE_AT(objEvent->currentCoords.x, objEvent->currentCoords.y + one + i) RETURN_REFLECTION_TYPE_AT(objEvent->previousCoords.x, objEvent->previousCoords.y + one + i) @@ -7732,19 +7731,20 @@ static u8 ObjectEventCheckForReflectiveSurface(struct ObjectEvent *objEvent) RETURN_REFLECTION_TYPE_AT(objEvent->previousCoords.x - j, objEvent->previousCoords.y + one + i) } } - return 0; + + return REFL_TYPE_NONE; +} #undef RETURN_REFLECTION_TYPE_AT -} static u8 GetReflectionTypeByMetatileBehavior(u32 behavior) { if (MetatileBehavior_IsIce(behavior)) - return 1; + return REFL_TYPE_ICE; else if (MetatileBehavior_IsReflective(behavior)) - return 2; + return REFL_TYPE_WATER; else - return 0; + return REFL_TYPE_NONE; } u8 GetLedgeJumpDirection(s16 x, s16 y, u8 z) @@ -7945,12 +7945,12 @@ void GroundEffect_StepOnLongGrass(struct ObjectEvent *objEvent, struct Sprite *s void GroundEffect_WaterReflection(struct ObjectEvent *objEvent, struct Sprite *sprite) { - SetUpReflection(objEvent, sprite, 0); + SetUpReflection(objEvent, sprite, FALSE); } void GroundEffect_IceReflection(struct ObjectEvent *objEvent, struct Sprite *sprite) { - SetUpReflection(objEvent, sprite, 1); + SetUpReflection(objEvent, sprite, TRUE); } void GroundEffect_FlowingWater(struct ObjectEvent *objEvent, struct Sprite *sprite) @@ -8117,8 +8117,8 @@ static void (*const sGroundEffectFuncs[])(struct ObjectEvent *objEvent, struct S GroundEffect_StepOnTallGrass, // GROUND_EFFECT_FLAG_TALL_GRASS_ON_MOVE GroundEffect_SpawnOnLongGrass, // GROUND_EFFECT_FLAG_LONG_GRASS_ON_SPAWN GroundEffect_StepOnLongGrass, // GROUND_EFFECT_FLAG_LONG_GRASS_ON_MOVE - GroundEffect_WaterReflection, // GROUND_EFFECT_FLAG_ICE_REFLECTION - GroundEffect_IceReflection, // GROUND_EFFECT_FLAG_REFLECTION + GroundEffect_WaterReflection, // GROUND_EFFECT_FLAG_WATER_REFLECTION + GroundEffect_IceReflection, // GROUND_EFFECT_FLAG_ICE_REFLECTION GroundEffect_FlowingWater, // GROUND_EFFECT_FLAG_SHALLOW_FLOWING_WATER GroundEffect_SandTracks, // GROUND_EFFECT_FLAG_SAND GroundEffect_DeepSandTracks, // GROUND_EFFECT_FLAG_DEEP_SAND @@ -8649,14 +8649,14 @@ static void DestroyObjectEventSprites(void) } } -static int GetObjectEventSpriteId(u8 var) // this should return a u8, because all that call this shifts to u8, but it wont match because it doesnt shift u8 at the end. +static int GetObjectEventSpriteId(u8 objectEventId) // this should return a u8, because all that call this shifts to u8, but it wont match because it doesnt shift u8 at the end. { int i; for (i = 0; i < MAX_SPRITES; i++) { struct Sprite *sprite = &gSprites[i]; - if(sprite->inUse && sprite->callback == UpdateObjectEventSprite && (u8)sprite->data[0] == var) + if (sprite->inUse && sprite->callback == UpdateObjectEventSprite && (u8)sprite->data[0] == objectEventId) return i; } return MAX_SPRITES; @@ -8788,9 +8788,9 @@ static void UpdateObjectEventSpritePosition(struct Sprite *sprite) } } -bool32 IsObjectEventSpriteAnimating(u8 var) +bool32 IsObjectEventSpriteAnimating(u8 objectEventId) { - u8 spriteId = GetObjectEventSpriteId(var); + u8 spriteId = GetObjectEventSpriteId(objectEventId); if (spriteId == MAX_SPRITES) return FALSE; diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 27a62ec80..0438d6e66 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -60,7 +60,6 @@ static void CB2_TradeEvolutionSceneUpdate(void); static void EvoDummyFunc(void); static void VBlankCB_EvolutionScene(void); static void VBlankCB_TradeEvolutionScene(void); -static void sub_81150D8(void); static void sub_8140134(void); static void EvoScene_DoMonAnimation(u8 monSpriteId, u16 speciesId); static bool32 EvoScene_IsMonAnimFinished(u8 monSpriteId); diff --git a/src/faraway_island.c b/src/faraway_island.c index e3d8444c9..bc0814652 100755 --- a/src/faraway_island.c +++ b/src/faraway_island.c @@ -372,7 +372,6 @@ void SetMewAboveGrass(void) { s16 x; s16 y; - u8 spriteId; struct ObjectEvent *mew = &gObjectEvents[GetMewObjectEventId()]; mew->invisible = FALSE; diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index fab14c577..a811901a9 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -730,7 +730,8 @@ static bool8 TryStartWarpEventScript(struct MapPosition *position, u16 metatileB } if (MetatileBehavior_IsWarpOrBridge(metatileBehavior) == TRUE) { - sub_80B0268(); + // Maybe unused? This MB is used by log bridges, but there's never a warp event on them + DoSpinExitWarp(); return TRUE; } if (MetatileBehavior_IsMtPyreHole(metatileBehavior) == TRUE) diff --git a/src/field_effect.c b/src/field_effect.c index 877df4610..16785e438 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -934,43 +934,43 @@ void FreeResourcesAndDestroySprite(struct Sprite *sprite, u8 spriteId) // r, g, b are between 0 and 16 void MultiplyInvertedPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) { - int curRed; - int curGreen; - int curBlue; - u16 outPal; - - outPal = gPlttBufferUnfaded[i]; - curRed = outPal & 0x1f; - curGreen = (outPal & (0x1f << 5)) >> 5; - curBlue = (outPal & (0x1f << 10)) >> 10; - curRed += (((0x1f - curRed) * r) >> 4); - curGreen += (((0x1f - curGreen) * g) >> 4); - curBlue += (((0x1f - curBlue) * b) >> 4); - outPal = curRed; - outPal |= curGreen << 5; - outPal |= curBlue << 10; - gPlttBufferFaded[i] = outPal; + int curRed, curGreen, curBlue; + u16 color = gPlttBufferUnfaded[i]; + + curRed = (color & RGB_RED); + curGreen = (color & RGB_GREEN) >> 5; + curBlue = (color & RGB_BLUE) >> 10; + + curRed += (((0x1F - curRed) * r) >> 4); + curGreen += (((0x1F - curGreen) * g) >> 4); + curBlue += (((0x1F - curBlue) * b) >> 4); + + color = curRed; + color |= (curGreen << 5); + color |= (curBlue << 10); + + gPlttBufferFaded[i] = color; } // r, g, b are between 0 and 16 void MultiplyPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) { - int curRed; - int curGreen; - int curBlue; - u16 outPal; - - outPal = gPlttBufferUnfaded[i]; - curRed = outPal & 0x1f; - curGreen = (outPal & (0x1f << 5)) >> 5; - curBlue = (outPal & (0x1f << 10)) >> 10; - curRed -= ((curRed * r) >> 4); + int curRed, curGreen, curBlue; + u16 color = gPlttBufferUnfaded[i]; + + curRed = (color & RGB_RED); + curGreen = (color & RGB_GREEN) >> 5; + curBlue = (color & RGB_BLUE) >> 10; + + curRed -= ((curRed * r) >> 4); curGreen -= ((curGreen * g) >> 4); - curBlue -= ((curBlue * b) >> 4); - outPal = curRed; - outPal |= curGreen << 5; - outPal |= curBlue << 10; - gPlttBufferFaded[i] = outPal; + curBlue -= ((curBlue * b) >> 4); + + color = curRed; + color |= curGreen << 5; + color |= curBlue << 10; + + gPlttBufferFaded[i] = color; } // Task data for Task_PokecenterHeal and Task_HallOfFameRecord diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index 2322232b8..67102a83b 100755 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -32,6 +32,11 @@ static void CreateBobbingEffect(struct ObjectEvent *, struct Sprite *, struct Sp static void sub_8155850(struct Sprite *); static u32 ShowDisguiseFieldEffect(u8, u8, u8); +#define sReflectionObjEventId data[0] +#define sReflectionObjEventLocalId data[1] +#define sReflectionVerticalOffset data[2] +#define sIsStillReflection data[7] + void SetUpReflection(struct ObjectEvent *objectEvent, struct Sprite *sprite, bool8 stillReflection) { struct Sprite *reflectionSprite; @@ -46,9 +51,9 @@ void SetUpReflection(struct ObjectEvent *objectEvent, struct Sprite *sprite, boo reflectionSprite->affineAnims = gDummySpriteAffineAnimTable; reflectionSprite->affineAnimBeginning = TRUE; reflectionSprite->subspriteMode = SUBSPRITES_OFF; - reflectionSprite->data[0] = sprite->data[0]; - reflectionSprite->data[1] = objectEvent->localId; - reflectionSprite->data[7] = stillReflection; + reflectionSprite->sReflectionObjEventId = sprite->data[0]; + reflectionSprite->sReflectionObjEventLocalId = objectEvent->localId; + reflectionSprite->sIsStillReflection = stillReflection; LoadObjectReflectionPalette(objectEvent, reflectionSprite); if (!stillReflection) @@ -60,19 +65,19 @@ static s16 GetReflectionVerticalOffset(struct ObjectEvent *objectEvent) return GetObjectEventGraphicsInfo(objectEvent->graphicsId)->height - 2; } -static void LoadObjectReflectionPalette(struct ObjectEvent *objectEvent, struct Sprite *sprite) +static void LoadObjectReflectionPalette(struct ObjectEvent *objectEvent, struct Sprite *reflectionSprite) { u8 bridgeType; u16 bridgeReflectionVerticalOffsets[] = { 12, 28, 44 }; - sprite->data[2] = 0; + reflectionSprite->sReflectionVerticalOffset = 0; if (!GetObjectEventGraphicsInfo(objectEvent->graphicsId)->disableReflectionPaletteLoad && ((bridgeType = MetatileBehavior_GetBridgeType(objectEvent->previousMetatileBehavior)) || (bridgeType = MetatileBehavior_GetBridgeType(objectEvent->currentMetatileBehavior)))) { - sprite->data[2] = bridgeReflectionVerticalOffsets[bridgeType - 1]; - LoadObjectHighBridgeReflectionPalette(objectEvent, sprite->oam.paletteNum); + reflectionSprite->sReflectionVerticalOffset = bridgeReflectionVerticalOffsets[bridgeType - 1]; + LoadObjectHighBridgeReflectionPalette(objectEvent, reflectionSprite->oam.paletteNum); } else { - LoadObjectRegularReflectionPalette(objectEvent, sprite->oam.paletteNum); + LoadObjectRegularReflectionPalette(objectEvent, reflectionSprite->oam.paletteNum); } } @@ -118,9 +123,9 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite) struct ObjectEvent *objectEvent; struct Sprite *mainSprite; - objectEvent = &gObjectEvents[reflectionSprite->data[0]]; + objectEvent = &gObjectEvents[reflectionSprite->sReflectionObjEventId]; mainSprite = &gSprites[objectEvent->spriteId]; - if (!objectEvent->active || !objectEvent->hasReflection || objectEvent->localId != reflectionSprite->data[1]) + if (!objectEvent->active || !objectEvent->hasReflection || objectEvent->localId != reflectionSprite->sReflectionObjEventLocalId) { reflectionSprite->inUse = FALSE; } @@ -135,8 +140,7 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite) reflectionSprite->subspriteTableNum = mainSprite->subspriteTableNum; reflectionSprite->invisible = mainSprite->invisible; reflectionSprite->pos1.x = mainSprite->pos1.x; - // reflectionSprite->data[2] holds an additional vertical offset, used by the high bridges on Route 120 - reflectionSprite->pos1.y = mainSprite->pos1.y + GetReflectionVerticalOffset(objectEvent) + reflectionSprite->data[2]; + reflectionSprite->pos1.y = mainSprite->pos1.y + GetReflectionVerticalOffset(objectEvent) + reflectionSprite->sReflectionVerticalOffset; reflectionSprite->centerToCornerVecX = mainSprite->centerToCornerVecX; reflectionSprite->centerToCornerVecY = mainSprite->centerToCornerVecY; reflectionSprite->pos2.x = mainSprite->pos2.x; @@ -146,8 +150,7 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite) if (objectEvent->hideReflection == TRUE) reflectionSprite->invisible = TRUE; - // Check if the reflection is not still. - if (reflectionSprite->data[7] == FALSE) + if (reflectionSprite->sIsStillReflection == FALSE) { // Sets the reflection sprite's rot/scale matrix to the appropriate // matrix based on whether or not the main sprite is horizontally flipped. @@ -159,6 +162,11 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite) } } +#undef sReflectionObjEventId +#undef sReflectionObjEventLocalId +#undef sReflectionVerticalOffset +#undef sIsStillReflection + extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[]; u8 CreateWarpArrowSprite(void) diff --git a/src/field_message_box.c b/src/field_message_box.c index 1b760c7df..b98425b66 100755 --- a/src/field_message_box.c +++ b/src/field_message_box.c @@ -1,6 +1,5 @@ #include "global.h" #include "menu.h" -#include "string.h" #include "string_util.h" #include "task.h" #include "text.h" diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index f57cc9979..cc4c03c9d 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -31,7 +31,7 @@ #include "constants/songs.h" #include "constants/trainer_types.h" -static EWRAM_DATA u8 gUnknown_0203734C = 0; +static EWRAM_DATA u8 sSpinStartFacingDir = 0; EWRAM_DATA struct ObjectEvent gObjectEvents[OBJECT_EVENTS_COUNT] = {}; EWRAM_DATA struct PlayerAvatar gPlayerAvatar = {}; @@ -138,7 +138,7 @@ static u8 Fishing_PutRodAway(struct Task *task); static u8 Fishing_EndNoMon(struct Task *task); static void AlignFishingAnimationFrames(void); -static u8 sub_808D38C(struct ObjectEvent *object, s16 *a1); +static u8 TrySpinPlayerForWarp(struct ObjectEvent *object, s16 *a1); // .rodata @@ -2050,54 +2050,64 @@ static void AlignFishingAnimationFrames(void) SetSurfBobWhileFishingState(gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId, 1, playerSprite->pos2.y); } -void sub_808D074(u8 a0) +void SetSpinStartFacingDir(u8 direction) { - gUnknown_0203734C = a0; + sSpinStartFacingDir = direction; } -static u8 sub_808D080(void) +static u8 GetSpinStartFacingDir(void) { - if (gUnknown_0203734C == 0) - { - return 1; - } - return gUnknown_0203734C; + if (sSpinStartFacingDir == DIR_NONE) + return DIR_SOUTH; + + return sSpinStartFacingDir; } -static void sub_808D094(u8 taskId) +// Task data for Task_DoPlayerSpinEntrance and Task_DoPlayerSpinExit +#define tState data[0] +#define tSpinDelayTimer data[1] +#define tSpeed data[2] +#define tCurY data[3] +#define tDestY data[4] +#define tStartDir data[5] +#define tPriority data[6] +#define tSubpriority data[7] +#define tGroundTimer data[8] + +static void Task_DoPlayerSpinExit(u8 taskId) { struct ObjectEvent *object = &gObjectEvents[gPlayerAvatar.objectEventId]; struct Sprite *sprite = &gSprites[object->spriteId]; s16 *data = gTasks[taskId].data; - switch (data[0]) + switch (tState) { - case 0: + case 0: // Init if (!ObjectEventClearHeldMovementIfFinished(object)) - { return; - } - sub_808D074(object->facingDirection); - data[1] = 0; - data[2] = 1; - data[3] = (u16)(sprite->pos1.y + sprite->pos2.y) << 4; + SetSpinStartFacingDir(object->facingDirection); + tSpinDelayTimer = 0; + tSpeed = 1; + tCurY = (u16)(sprite->pos1.y + sprite->pos2.y) << 4; sprite->pos2.y = 0; CameraObjectReset2(); object->fixedPriority = TRUE; sprite->oam.priority = 0; sprite->subpriority = 0; sprite->subspriteMode = SUBSPRITES_OFF; - data[0]++; - case 1: - sub_808D38C(object, &data[1]); - data[3] -= data[2]; - data[2] += 3; - sprite->pos1.y = data[3] >> 4; + tState++; + case 1: // Spin while rising + TrySpinPlayerForWarp(object, &tSpinDelayTimer); + + // Rise and accelerate + tCurY -= tSpeed; + tSpeed += 3; + sprite->pos1.y = tCurY >> 4; + + // Check if offscreen if (sprite->pos1.y + (s16)gTotalCameraPixelOffsetY < -32) - { - data[0]++; - } + tState++; break; case 2: DestroyTask(taskId); @@ -2105,84 +2115,86 @@ static void sub_808D094(u8 taskId) } } -static void sub_808D1FC(u8 taskId); +static void Task_DoPlayerSpinEntrance(u8 taskId); -void sub_808D194(void) +void DoPlayerSpinEntrance(void) { - sub_808D1FC(CreateTask(sub_808D1FC, 0)); + Task_DoPlayerSpinEntrance(CreateTask(Task_DoPlayerSpinEntrance, 0)); } -bool32 sub_808D1B4(void) +bool32 IsPlayerSpinEntranceActive(void) { - return FuncIsActiveTask(sub_808D1FC); + return FuncIsActiveTask(Task_DoPlayerSpinEntrance); } -void sub_808D1C8(void) +void DoPlayerSpinExit(void) { - sub_808D094(CreateTask(sub_808D094, 0)); + Task_DoPlayerSpinExit(CreateTask(Task_DoPlayerSpinExit, 0)); } -bool32 sub_808D1E8(void) +bool32 IsPlayerSpinExitActive(void) { - return FuncIsActiveTask(sub_808D094); + return FuncIsActiveTask(Task_DoPlayerSpinExit); } -static const u8 gUnknown_084975BC[] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; +static const u8 sSpinDirections[] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; -static void sub_808D1FC(u8 taskId) +static void Task_DoPlayerSpinEntrance(u8 taskId) { struct ObjectEvent *object = &gObjectEvents[gPlayerAvatar.objectEventId]; struct Sprite *sprite = &gSprites[object->spriteId]; s16 *data = gTasks[taskId].data; - switch (data[0]) + switch (tState) { case 0: - data[5] = sub_808D080(); - ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(gUnknown_084975BC[data[5]])); - data[1] = 0; - data[2] = 116; - data[4] = sprite->pos1.y; - data[6] = sprite->oam.priority; - data[7] = sprite->subpriority; - data[3] = -((u16)sprite->pos2.y + 32) * 16; + // Because the spin start facing direction is never set for this + // warp type, the player will always exit the warp facing South. + // This may have been intentional, unclear + tStartDir = GetSpinStartFacingDir(); + ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(sSpinDirections[tStartDir])); + tSpinDelayTimer = 0; + tSpeed = 116; + tDestY = sprite->pos1.y; + tPriority = sprite->oam.priority; + tSubpriority = sprite->subpriority; + tCurY = -((u16)sprite->pos2.y + 32) * 16; sprite->pos2.y = 0; CameraObjectReset2(); object->fixedPriority = TRUE; sprite->oam.priority = 1; sprite->subpriority = 0; sprite->subspriteMode = SUBSPRITES_OFF; - data[0]++; - case 1: - sub_808D38C(object, &data[1]); - data[3] += data[2]; - data[2] -= 3; - if (data[2] < 4) + tState++; + case 1: // Spin while descending + TrySpinPlayerForWarp(object, &tSpinDelayTimer); + + // Fall and decelerate + tCurY += tSpeed; + tSpeed -= 3; + if (tSpeed < 4) + tSpeed = 4; + sprite->pos1.y = tCurY >> 4; + + // Check if reached dest + if (sprite->pos1.y >= tDestY) { - data[2] = 4; - } - sprite->pos1.y = data[3] >> 4; - if (sprite->pos1.y >= data[4]) - { - sprite->pos1.y = data[4]; - data[8] = 0; - data[0]++; + sprite->pos1.y = tDestY; + tGroundTimer = 0; + tState++; } break; - case 2: - sub_808D38C(object, &data[1]); - data[8]++; - if (data[8] > 8) - { - data[0]++; - } + case 2: // Spin on ground + TrySpinPlayerForWarp(object, &tSpinDelayTimer); + if (++tGroundTimer > 8) + tState++; break; - case 3: - if (data[5] == sub_808D38C(object, &data[1])) + case 3: // Spin until facing original direction + if (tStartDir == TrySpinPlayerForWarp(object, &tSpinDelayTimer)) { object->fixedPriority = 0; - sprite->oam.priority = data[6]; - sprite->subpriority = data[7]; + sprite->oam.priority = tPriority; + sprite->subpriority = tSubpriority; CameraObjectReset1(); DestroyTask(taskId); } @@ -2190,19 +2202,15 @@ static void sub_808D1FC(u8 taskId) } } -static u8 sub_808D38C(struct ObjectEvent *object, s16 *a1) +static u8 TrySpinPlayerForWarp(struct ObjectEvent *object, s16 *delayTimer) { - if (*a1 < 8 && ++(*a1) < 8) - { + if (*delayTimer < 8 && ++(*delayTimer) < 8) return object->facingDirection; - } if (!ObjectEventCheckHeldMovementStatus(object)) - { return object->facingDirection; - } - ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(gUnknown_084975BC[object->facingDirection])); - *a1 = 0; - return gUnknown_084975BC[object->facingDirection]; + ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(sSpinDirections[object->facingDirection])); + *delayTimer = 0; + return sSpinDirections[object->facingDirection]; } diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index 9becd2166..db82d667c 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -42,11 +42,14 @@ static void Task_DoContestHallWarp(u8); static void FillPalBufferWhite(void); static void Task_ExitDoor(u8); static bool32 WaitForWeatherFadeIn(void); -static void Task_TeleportTileWarpExit(u8 taskId); +static void Task_SpinEnterWarp(u8 taskId); static void Task_WarpAndLoadMap(u8 taskId); static void Task_DoDoorWarp(u8 taskId); static void Task_EnableScriptAfterMusicFade(u8 taskId); +// data[0] is used universally by tasks in this file as a state for switches +#define tState data[0] + // const static const u16 sFlashLevelPixelRadii[] = { 200, 72, 64, 56, 48, 40, 32, 24, 0 }; const s32 gMaxFlashLevel = ARRAY_COUNT(sFlashLevelPixelRadii) - 1; @@ -156,17 +159,17 @@ static void Task_ReturnToFieldCableLink(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: task->data[1] = CreateTask_ReestablishCableClubLink(); - task->data[0]++; + task->tState++; break; case 1: if (gTasks[task->data[1]].isActive != TRUE) { WarpFadeInScreen(); - task->data[0]++; + task->tState++; } break; case 2: @@ -191,11 +194,11 @@ static void Task_ReturnToFieldWirelessLink(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: SetLinkStandbyCallback(); - task->data[0]++; + task->tState++; break; case 1: if (!IsLinkTaskFinished()) @@ -206,7 +209,7 @@ static void Task_ReturnToFieldWirelessLink(u8 taskId) else { WarpFadeInScreen(); - task->data[0]++; + task->tState++; } break; case 2: @@ -224,16 +227,16 @@ void Task_ReturnToFieldRecordMixing(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: SetLinkStandbyCallback(); - task->data[0]++; + task->tState++; break; case 1: if (IsLinkTaskFinished()) { - task->data[0]++; + task->tState++; } break; case 2: @@ -295,12 +298,12 @@ void FieldCB_WarpExitFadeFromBlack(void) ScriptContext2_Enable(); } -static void FieldCB_TeleportTileWarpExit(void) +static void FieldCB_SpinEnterWarp(void) { Overworld_PlaySpecialMapMusic(); WarpFadeInScreen(); PlaySE(SE_WARP_OUT); - CreateTask(Task_TeleportTileWarpExit, 10); + CreateTask(Task_SpinEnterWarp, 10); ScriptContext2_Enable(); } @@ -320,14 +323,14 @@ static void Task_ExitDoor(u8 taskId) s16 *x = &task->data[2]; s16 *y = &task->data[3]; - switch (task->data[0]) + switch (task->tState) { case 0: SetPlayerVisibility(FALSE); FreezeObjectEvents(); PlayerGetDestCoords(x, y); FieldSetDoorOpened(*x, *y); - task->data[0] = 1; + task->tState = 1; break; case 1: if (WaitForWeatherFadeIn()) @@ -336,7 +339,7 @@ static void Task_ExitDoor(u8 taskId) SetPlayerVisibility(TRUE); objEventId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0); ObjectEventSetHeldMovement(&gObjectEvents[objEventId], MOVEMENT_ACTION_WALK_NORMAL_DOWN); - task->data[0] = 2; + task->tState = 2; } break; case 2: @@ -346,14 +349,14 @@ static void Task_ExitDoor(u8 taskId) task->data[1] = FieldAnimateDoorClose(*x, *y); objEventId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0); ObjectEventClearHeldMovementIfFinished(&gObjectEvents[objEventId]); - task->data[0] = 3; + task->tState = 3; } break; case 3: if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE) { UnfreezeObjectEvents(); - task->data[0] = 4; + task->tState = 4; } break; case 4: @@ -369,13 +372,13 @@ static void Task_ExitNonAnimDoor(u8 taskId) s16 *x = &task->data[2]; s16 *y = &task->data[3]; - switch (task->data[0]) + switch (task->tState) { case 0: SetPlayerVisibility(FALSE); FreezeObjectEvents(); PlayerGetDestCoords(x, y); - task->data[0] = 1; + task->tState = 1; break; case 1: if (WaitForWeatherFadeIn()) @@ -384,14 +387,14 @@ static void Task_ExitNonAnimDoor(u8 taskId) SetPlayerVisibility(TRUE); objEventId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0); ObjectEventSetHeldMovement(&gObjectEvents[objEventId], GetWalkNormalMovementAction(GetPlayerFacingDirection())); - task->data[0] = 2; + task->tState = 2; } break; case 2: if (IsPlayerStandingStill()) { UnfreezeObjectEvents(); - task->data[0] = 3; + task->tState = 3; } break; case 3: @@ -403,12 +406,12 @@ static void Task_ExitNonAnimDoor(u8 taskId) static void Task_ExitNonDoor(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: FreezeObjectEvents(); ScriptContext2_Enable(); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; break; case 1: if (WaitForWeatherFadeIn()) @@ -443,7 +446,7 @@ bool8 FieldCB_ReturnToFieldOpenStartMenu(void) return FALSE; } -static void task_mpl_807E3C8(u8 taskId) +static void Task_ReturnToFieldNoScript(u8 taskId) { if (WaitForWeatherFadeIn() == 1) { @@ -453,19 +456,19 @@ static void task_mpl_807E3C8(u8 taskId) } } -void sub_80AF6D4(void) +void FieldCB_ReturnToFieldNoScript(void) { ScriptContext2_Enable(); FadeInFromBlack(); - CreateTask(task_mpl_807E3C8, 10); + CreateTask(Task_ReturnToFieldNoScript, 10); } -void sub_80AF6F0(void) +void FieldCB_ReturnToFieldNoScriptCheckMusic(void) { ScriptContext2_Enable(); Overworld_PlaySpecialMapMusic(); FadeInFromBlack(); - CreateTask(task_mpl_807E3C8, 10); + CreateTask(Task_ReturnToFieldNoScript, 10); } static bool32 PaletteFadeActive(void) @@ -543,7 +546,9 @@ void DoLavaridgeGym1FWarp(void) StartLavaridgeGym1FWarp(10); } -// Warp from a teleporting tile, e.g. in Aqua Hideout (For the move Teleport see FldEff_TeleportWarpOut) +// DoSpinEnterWarp but with a fade out +// Screen fades out to exit current map, player spins down from top to enter new map +// Used by teleporting tiles, e.g. in Aqua Hideout (For the move Teleport see FldEff_TeleportWarpOut) void DoTeleportTileWarp(void) { ScriptContext2_Enable(); @@ -551,7 +556,7 @@ void DoTeleportTileWarp(void) WarpFadeOutScreen(); PlaySE(SE_WARP_IN); CreateTask(Task_WarpAndLoadMap, 10); - gFieldCallback = FieldCB_TeleportTileWarpExit; + gFieldCallback = FieldCB_SpinEnterWarp; } void DoMossdeepGymWarp(void) @@ -574,8 +579,6 @@ void DoPortholeWarp(void) gFieldCallback = FieldCB_ShowPortholeView; } -#define tState data[0] - static void Task_DoCableClubWarp(u8 taskId) { struct Task *task = &gTasks[taskId]; @@ -598,8 +601,6 @@ static void Task_DoCableClubWarp(u8 taskId) } } -#undef tState - void DoCableClubWarp(void) { ScriptContext2_Enable(); @@ -613,20 +614,20 @@ static void Task_ReturnToWorldFromLinkRoom(u8 taskId) { s16 *data = gTasks[taskId].data; - switch (data[0]) + switch (tState) { case 0: ClearLinkCallback_2(); FadeScreen(FADE_TO_BLACK, 0); TryFadeOutOldMapMusic(); PlaySE(SE_EXIT); - data[0]++; + tState++; break; case 1: if (!PaletteFadeActive() && BGMusicStopped()) { SetCloseLinkCallback(); - data[0]++; + tState++; } break; case 2: @@ -649,12 +650,12 @@ static void Task_WarpAndLoadMap(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: FreezeObjectEvents(); ScriptContext2_Enable(); - task->data[0]++; + task->tState++; break; case 1: if (!PaletteFadeActive()) @@ -665,7 +666,7 @@ static void Task_WarpAndLoadMap(u8 taskId) task->data[1] = 1; } if (BGMusicStopped()) - task->data[0]++; + task->tState++; } break; case 2: @@ -682,14 +683,14 @@ static void Task_DoDoorWarp(u8 taskId) s16 *x = &task->data[2]; s16 *y = &task->data[3]; - switch (task->data[0]) + switch (task->tState) { case 0: FreezeObjectEvents(); PlayerGetDestCoords(x, y); PlaySE(GetDoorSoundEffect(*x, *y - 1)); task->data[1] = FieldAnimateDoorOpen(*x, *y - 1); - task->data[0] = 1; + task->tState = 1; break; case 1: if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE) @@ -699,7 +700,7 @@ static void Task_DoDoorWarp(u8 taskId) ObjectEventClearHeldMovementIfActive(&gObjectEvents[objEventId]); objEventId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0); ObjectEventSetHeldMovement(&gObjectEvents[objEventId], MOVEMENT_ACTION_WALK_NORMAL_UP); - task->data[0] = 2; + task->tState = 2; } break; case 2: @@ -710,20 +711,20 @@ static void Task_DoDoorWarp(u8 taskId) objEventId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0); ObjectEventClearHeldMovementIfFinished(&gObjectEvents[objEventId]); SetPlayerVisibility(FALSE); - task->data[0] = 3; + task->tState = 3; } break; case 3: if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE) { - task->data[0] = 4; + task->tState = 4; } break; case 4: TryFadeOutOldMapMusic(); WarpFadeOutScreen(); PlayRainStoppingSoundEffect(); - task->data[0] = 0; + task->tState = 0; task->func = Task_WarpAndLoadMap; break; } @@ -733,17 +734,17 @@ static void Task_DoContestHallWarp(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: FreezeObjectEvents(); ScriptContext2_Enable(); - task->data[0]++; + task->tState++; break; case 1: if (!PaletteFadeActive() && BGMusicStopped()) { - task->data[0]++; + task->tState++; } break; case 2: @@ -850,22 +851,22 @@ static void UpdateFlashLevelEffect(u8 taskId) { s16 *data = gTasks[taskId].data; - switch (data[0]) + switch (tState) { case 0: SetFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius); - data[0] = 1; + tState = 1; break; case 1: SetFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius); - data[0] = 0; + tState = 0; tCurFlashRadius += tFlashRadiusDelta; if (tCurFlashRadius > tDestFlashRadius) { if (tClearScanlineEffect == 1) { ScanlineEffect_Stop(); - data[0] = 2; + tState = 2; } else { @@ -884,22 +885,22 @@ static void UpdateOrbFlashEffect(u8 taskId) { s16 *data = gTasks[taskId].data; - switch (data[0]) + switch (tState) { case 0: SetOrbFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius); - data[0] = 1; + tState = 1; break; case 1: SetOrbFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius); - data[0] = 0; + tState = 0; tCurFlashRadius += tFlashRadiusDelta; if (tCurFlashRadius > tDestFlashRadius) { if (tClearScanlineEffect == 1) { ScanlineEffect_Stop(); - data[0] = 2; + tState = 2; } else { @@ -914,7 +915,7 @@ static void UpdateOrbFlashEffect(u8 taskId) } } -static void sub_80AFF90(u8 taskId) +static void Task_WaitForFlashUpdate(u8 taskId) { if (!FuncIsActiveTask(UpdateFlashLevelEffect)) { @@ -923,13 +924,13 @@ static void sub_80AFF90(u8 taskId) } } -static void sub_80AFFB8(void) +static void StartWaitForFlashUpdate(void) { - if (!FuncIsActiveTask(sub_80AFF90)) - CreateTask(sub_80AFF90, 80); + if (!FuncIsActiveTask(Task_WaitForFlashUpdate)) + CreateTask(Task_WaitForFlashUpdate, 80); } -static u8 sub_80AFFDC(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 destFlashRadius, s32 clearScanlineEffect, u8 delta) +static u8 StartUpdateFlashLevelEffect(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 destFlashRadius, s32 clearScanlineEffect, u8 delta) { u8 taskId = CreateTask(UpdateFlashLevelEffect, 80); s16 *data = gTasks[taskId].data; @@ -948,7 +949,7 @@ static u8 sub_80AFFDC(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 dest return taskId; } -static u8 sub_80B003C(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 destFlashRadius, s32 clearScanlineEffect, u8 delta) +static u8 StartUpdateOrbFlashEffect(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 destFlashRadius, s32 clearScanlineEffect, u8 delta) { u8 taskId = CreateTask(UpdateOrbFlashEffect, 80); s16 *data = gTasks[taskId].data; @@ -972,14 +973,15 @@ static u8 sub_80B003C(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 dest #undef tFlashRadiusDelta #undef tClearScanlineEffect +// A higher flashLevel value is a smaller flash radius (more darkness). 0 is full brightness void AnimateFlash(u8 flashLevel) { u8 curFlashLevel = Overworld_GetFlashLevel(); - u8 value = 0; + bool8 fullBrightness = FALSE; if (!flashLevel) - value = 1; - sub_80AFFDC(DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, sFlashLevelPixelRadii[curFlashLevel], sFlashLevelPixelRadii[flashLevel], value, 1); - sub_80AFFB8(); + fullBrightness = TRUE; + StartUpdateFlashLevelEffect(DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, sFlashLevelPixelRadii[curFlashLevel], sFlashLevelPixelRadii[flashLevel], fullBrightness, 1); + StartWaitForFlashUpdate(); ScriptContext2_Enable(); } @@ -998,18 +1000,18 @@ void WriteBattlePyramidViewScanlineEffectBuffer(void) CpuFastSet(&gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 480); } -static void Task_TeleportTileWarpExit(u8 taskId) +static void Task_SpinEnterWarp(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: FreezeObjectEvents(); ScriptContext2_Enable(); - sub_808D194(); - gTasks[taskId].data[0]++; + DoPlayerSpinEntrance(); + gTasks[taskId].tState++; break; case 1: - if (WaitForWeatherFadeIn() && sub_808D1B4() != TRUE) + if (WaitForWeatherFadeIn() && IsPlayerSpinEntranceActive() != TRUE) { UnfreezeObjectEvents(); ScriptContext2_Disable(); @@ -1019,29 +1021,29 @@ static void Task_TeleportTileWarpExit(u8 taskId) } } -static void sub_80B01BC(u8 taskId) +static void Task_SpinExitWarp(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: FreezeObjectEvents(); ScriptContext2_Enable(); PlaySE(SE_WARP_IN); - sub_808D1C8(); - task->data[0]++; + DoPlayerSpinExit(); + task->tState++; break; case 1: - if (!sub_808D1E8()) + if (!IsPlayerSpinExitActive()) { WarpFadeOutScreen(); - task->data[0]++; + task->tState++; } break; case 2: if (!PaletteFadeActive() && BGMusicStopped()) - task->data[0]++; + task->tState++; break; case 3: WarpIntoMap(); @@ -1051,18 +1053,22 @@ static void sub_80B01BC(u8 taskId) } } -void sub_80B0244(void) +// Only called by an unused function +// DoTeleportTileWarp is used instead +void DoSpinEnterWarp(void) { ScriptContext2_Enable(); CreateTask(Task_WarpAndLoadMap, 10); - gFieldCallback = FieldCB_TeleportTileWarpExit; + gFieldCallback = FieldCB_SpinEnterWarp; } -void sub_80B0268(void) +// Opposite of DoSpinEnterWarp / DoTeleportTileWarp +// Player exits current map by spinning up offscreen, enters new map with a fade in +void DoSpinExitWarp(void) { ScriptContext2_Enable(); gFieldCallback = FieldCB_DefaultWarpExit; - CreateTask(sub_80B01BC, 10); + CreateTask(Task_SpinExitWarp, 10); } static void LoadOrbEffectPalette(bool8 blueOrb) @@ -1109,7 +1115,6 @@ static bool8 sub_80B02C8(u16 shakeDir) return FALSE; } -#define tState data[0] #define tBlueOrb data[1] #define tCenterX data[2] #define tCenterY data[3] @@ -1148,7 +1153,7 @@ static void Task_OrbEffect(u8 taskId) case 1: sub_8199DF0(0, PIXEL_FILL(1), 0, 1); LoadOrbEffectPalette(tBlueOrb); - sub_80B003C(tCenterX, tCenterY, 1, 160, 1, 2); + StartUpdateOrbFlashEffect(tCenterX, tCenterY, 1, 160, 1, 2); tState = 2; break; case 2: @@ -1243,7 +1248,6 @@ void FadeOutOrbEffect(void) gTasks[taskId].tState = 6; } -#undef tState #undef tBlueOrb #undef tCenterX #undef tCenterY diff --git a/src/field_specials.c b/src/field_specials.c index 51030a387..a6831ec5b 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1414,7 +1414,7 @@ void GiveLeadMonEffortRibbon(void) bool8 Special_AreLeadMonEVsMaxedOut(void) { - if (GetMonEVCount(&gPlayerParty[GetLeadMonIndex()]) >= 510) + if (GetMonEVCount(&gPlayerParty[GetLeadMonIndex()]) >= MAX_TOTAL_EVS) { return TRUE; } @@ -1449,7 +1449,7 @@ void SetShoalItemFlag(u16 unused) void PutZigzagoonInPlayerParty(void) { u16 monData; - CreateMon(&gPlayerParty[0], SPECIES_ZIGZAGOON, 7, 32, FALSE, 0, OT_ID_PLAYER_ID, 0); + CreateMon(&gPlayerParty[0], SPECIES_ZIGZAGOON, 7, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); monData = TRUE; SetMonData(&gPlayerParty[0], MON_DATA_ABILITY_NUM, &monData); monData = MOVE_TACKLE; diff --git a/src/fieldmap.c b/src/fieldmap.c index 296c4edf2..2961d2f49 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -28,7 +28,7 @@ EWRAM_DATA static u16 gBackupMapData[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 u32 sFiller_02037344 = 0; // without this, the next file won't align properly +EWRAM_DATA static u32 sFiller = 0; // without this, the next file won't align properly struct BackupMapLayout gBackupMapLayout; diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c index 0458f7621..446633a53 100644 --- a/src/fldeff_cut.c +++ b/src/fldeff_cut.c @@ -62,7 +62,6 @@ static void HandleLongGrassOnHyper(u8, s16, s16); static u8 sCutSquareSide; static u8 sTileCountFromPlayer_X; static u8 sTileCountFromPlayer_Y; -static u32 sUnused; static bool8 sHyperCutTiles[CUT_HYPER_AREA]; // EWRAM variables diff --git a/src/fldeff_escalator.c b/src/fldeff_escalator.c index 7a96eaa82..733dca722 100644 --- a/src/fldeff_escalator.c +++ b/src/fldeff_escalator.c @@ -10,8 +10,6 @@ static EWRAM_DATA u8 sEscalatorAnim_TaskId = 0; static void SetEscalatorMetatile(u8 taskId, const s16 *metatileIds, u16 metatileMasks); static void Task_DrawEscalator(u8 taskId); -static void Task_DrawTeleporterHousing(u8 taskId); -static void Task_DrawTeleporterCable(u8 taskId); #define ESCALATOR_STAGES 3 #define LAST_ESCALATOR_STAGE (ESCALATOR_STAGES - 1) diff --git a/src/frontier_util.c b/src/frontier_util.c index 021e7f6ed..e0ad3971c 100644 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -129,7 +129,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_RAIKOU, .heldItem = ITEM_LUM_BERRY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_MODEST, .evs = {158, 0, 252, 100, 0, 0}, .moves = {MOVE_THUNDERBOLT, MOVE_CALM_MIND, MOVE_REFLECT, MOVE_REST}, @@ -137,7 +137,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_LATIOS, .heldItem = ITEM_BRIGHT_POWDER, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_MODEST, .evs = {252, 0, 252, 6, 0, 0}, .moves = {MOVE_PSYCHIC, MOVE_CALM_MIND, MOVE_RECOVER, MOVE_DRAGON_CLAW}, @@ -145,7 +145,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_SNORLAX, .heldItem = ITEM_CHESTO_BERRY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_ADAMANT, .evs = {252, 252, 0, 0, 6, 0}, .moves = {MOVE_CURSE, MOVE_RETURN, MOVE_REST, MOVE_SHADOW_BALL}, @@ -186,7 +186,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_SWAMPERT, .heldItem = ITEM_LEFTOVERS, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_BRAVE, .evs = {252, 252, 6, 0, 0, 0}, .moves = {MOVE_SURF, MOVE_EARTHQUAKE, MOVE_ICE_BEAM, MOVE_MIRROR_COAT}, @@ -194,7 +194,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_METAGROSS, .heldItem = ITEM_QUICK_CLAW, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_BRAVE, .evs = {252, 252, 6, 0, 0, 0}, .moves = {MOVE_PSYCHIC, MOVE_METEOR_MASH, MOVE_EARTHQUAKE, MOVE_PROTECT}, @@ -202,7 +202,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_LATIAS, .heldItem = ITEM_CHESTO_BERRY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_MODEST, .evs = {252, 0, 252, 6, 0, 0}, .moves = {MOVE_THUNDERBOLT, MOVE_PSYCHIC, MOVE_CALM_MIND, MOVE_REST}, @@ -243,7 +243,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_ARCANINE, .heldItem = ITEM_WHITE_HERB, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_HASTY, .evs = {6, 252, 252, 0, 0, 0}, .moves = {MOVE_OVERHEAT, MOVE_EXTREME_SPEED, MOVE_ROAR, MOVE_PROTECT}, @@ -251,7 +251,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_SLAKING, .heldItem = ITEM_SCOPE_LENS, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_HARDY, .evs = {6, 252, 0, 252, 0, 0}, .moves = {MOVE_HYPER_BEAM, MOVE_EARTHQUAKE, MOVE_SHADOW_BALL, MOVE_YAWN}, @@ -259,7 +259,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_SUICUNE, .heldItem = ITEM_KINGS_ROCK, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_HASTY, .evs = {252, 0, 252, 6, 0, 0}, .moves = {MOVE_BLIZZARD, MOVE_SURF, MOVE_BITE, MOVE_CALM_MIND}, @@ -300,7 +300,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_UMBREON, .heldItem = ITEM_CHESTO_BERRY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_CALM, .evs = {252, 0, 0, 0, 252, 6}, .moves = {MOVE_DOUBLE_EDGE, MOVE_CONFUSE_RAY, MOVE_REST, MOVE_PSYCHIC}, @@ -308,7 +308,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_GENGAR, .heldItem = ITEM_LEFTOVERS, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_MODEST, .evs = {252, 0, 252, 0, 6, 0}, .moves = {MOVE_PSYCHIC, MOVE_HYPNOSIS, MOVE_DREAM_EATER, MOVE_DESTINY_BOND}, @@ -316,7 +316,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_BRELOOM, .heldItem = ITEM_LUM_BERRY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_JOLLY, .evs = {6, 252, 0, 252, 0, 0}, .moves = {MOVE_SPORE, MOVE_FOCUS_PUNCH, MOVE_GIGA_DRAIN, MOVE_HEADBUTT}, @@ -331,7 +331,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_METANG, .heldItem = ITEM_SITRUS_BERRY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_BRAVE, .evs = {0, 252, 252, 0, 6, 0}, .moves = {MOVE_LIGHT_SCREEN, MOVE_PSYCHIC, MOVE_REFLECT, MOVE_METAL_CLAW}, @@ -339,7 +339,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_SKARMORY, .heldItem = ITEM_SITRUS_BERRY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_IMPISH, .evs = {252, 0, 0, 0, 6, 252}, .moves = {MOVE_TOXIC, MOVE_AERIAL_ACE, MOVE_PROTECT, MOVE_STEEL_WING}, @@ -347,7 +347,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_AGGRON, .heldItem = ITEM_SITRUS_BERRY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_ADAMANT, .evs = {0, 252, 0, 0, 252, 6}, .moves = {MOVE_THUNDERBOLT, MOVE_PROTECT, MOVE_SOLAR_BEAM, MOVE_DRAGON_CLAW}, @@ -357,7 +357,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_METANG, .heldItem = ITEM_SITRUS_BERRY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_BRAVE, .evs = {0, 252, 252, 0, 6, 0}, .moves = {MOVE_LIGHT_SCREEN, MOVE_PSYCHIC, MOVE_REFLECT, MOVE_METAL_CLAW}, @@ -365,7 +365,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_SKARMORY, .heldItem = ITEM_SITRUS_BERRY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_IMPISH, .evs = {252, 0, 0, 0, 6, 252}, .moves = {MOVE_TOXIC, MOVE_AERIAL_ACE, MOVE_PROTECT, MOVE_STEEL_WING}, @@ -373,7 +373,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_AGGRON, .heldItem = ITEM_SITRUS_BERRY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_ADAMANT, .evs = {0, 252, 0, 0, 252, 6}, .moves = {MOVE_THUNDERBOLT, MOVE_PROTECT, MOVE_SOLAR_BEAM, MOVE_DRAGON_CLAW}, @@ -414,7 +414,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_SEVIPER, .heldItem = ITEM_FOCUS_BAND, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_BOLD, .evs = {252, 0, 0, 0, 252, 6}, .moves = {MOVE_SWAGGER, MOVE_CRUNCH, MOVE_SLUDGE_BOMB, MOVE_GIGA_DRAIN}, @@ -422,7 +422,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_STEELIX, .heldItem = ITEM_BRIGHT_POWDER, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_BRAVE, .evs = {252, 0, 0, 0, 6, 252}, .moves = {MOVE_EARTHQUAKE, MOVE_ROCK_SLIDE, MOVE_EXPLOSION, MOVE_SCREECH}, @@ -430,7 +430,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_GYARADOS, .heldItem = ITEM_CHESTO_BERRY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_ADAMANT, .evs = {252, 6, 0, 0, 0, 252}, .moves = {MOVE_DRAGON_DANCE, MOVE_RETURN, MOVE_ROAR, MOVE_REST}, @@ -471,7 +471,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_ARTICUNO, .heldItem = ITEM_SCOPE_LENS, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_MILD, .evs = {6, 0, 252, 252, 0, 0}, .moves = {MOVE_BLIZZARD, MOVE_WATER_PULSE, MOVE_AERIAL_ACE, MOVE_REFLECT}, @@ -479,7 +479,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_ZAPDOS, .heldItem = ITEM_LUM_BERRY, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_MILD, .evs = {6, 0, 252, 252, 0, 0}, .moves = {MOVE_THUNDER, MOVE_DETECT, MOVE_DRILL_PECK, MOVE_LIGHT_SCREEN}, @@ -487,7 +487,7 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ { .species = SPECIES_MOLTRES, .heldItem = ITEM_BRIGHT_POWDER, - .fixedIV = 31, + .fixedIV = MAX_PER_STAT_IVS, .nature = NATURE_MILD, .evs = {6, 0, 252, 252, 0, 0}, .moves = {MOVE_FIRE_BLAST, MOVE_HYPER_BEAM, MOVE_AERIAL_ACE, MOVE_SAFEGUARD}, @@ -1513,9 +1513,9 @@ static void ShowLinkContestResultsWindow(void) AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Smart, x, 89, TEXT_SPEED_FF, NULL); AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Tough, x, 105, TEXT_SPEED_FF, NULL); - for (i = 0; i < 5; i++) + for (i = 0; i < CONTEST_CATEGORIES_COUNT; i++) { - for (j = 0; j < 4; j++) + for (j = 0; j < CONTESTANT_COUNT; j++) { ConvertIntToDecimalStringN(gStringVar4, gSaveBlock2Ptr->contestLinkResults[i][j], STR_CONV_MODE_RIGHT_ALIGN, 4); AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, (j * 38) + 64, (i * 16) + 41, TEXT_SPEED_FF, NULL); diff --git a/src/graphics.c b/src/graphics.c index 8f8ced5cb..4f61d3a65 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -862,8 +862,8 @@ const u32 gBattleAnimSpriteGfx_Confetti[] = INCBIN_U32("graphics/battle_anims/sp const u32 gBattleAnimSpritePal_Confetti[] = INCBIN_U32("graphics/battle_anims/sprites/confetti.gbapal.lz"); const u32 gSubstituteDollPal[] = INCBIN_U32("graphics/battle_anims/sprites/substitute.gbapal.lz"); -const u32 gSubstituteDollGfx[] = INCBIN_U32("graphics/battle_anims/sprites/substitute.4bpp.lz"); -const u32 gSubstituteDollTilemap[] = INCBIN_U32("graphics/battle_anims/sprites/substitute.bin.lz"); +const u32 gSubstituteDollFrontGfx[] = INCBIN_U32("graphics/battle_anims/sprites/substitute.4bpp.lz"); +const u32 gSubstituteDollBackGfx[] = INCBIN_U32("graphics/battle_anims/sprites/substitute_back.4bpp.lz"); const u32 gBattleAnimSpriteGfx_GreenStar[] = INCBIN_U32("graphics/battle_anims/sprites/green_star.4bpp.lz"); const u32 gBattleAnimSpritePal_GreenStar[] = INCBIN_U32("graphics/battle_anims/sprites/green_star.gbapal.lz"); diff --git a/src/image_processing_effects.c b/src/image_processing_effects.c index cbd8b9b37..224de6fe1 100644 --- a/src/image_processing_effects.c +++ b/src/image_processing_effects.c @@ -129,11 +129,11 @@ static void ApplyImageEffect_RedChannelGrayscale(u8 delta) u16 *pixel = &pixelRow[gCanvasColumnStart]; for (i = 0; i < gCanvasColumnEnd; i++, pixel++) { - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) { // Gets the grayscale value, based on the pixel's red channel. // Also adds a delta to skew lighter or darker. - u8 grayValue = (31 & *pixel); + u8 grayValue = (*pixel & RGB_RED); grayValue += delta; if (grayValue > 31) grayValue = 31; @@ -154,9 +154,9 @@ static void ApplyImageEffect_RedChannelGrayscaleHighlight(u8 highlight) u16 *pixel = &pixelRow[gCanvasColumnStart]; for (i = 0; i < gCanvasColumnEnd; i++, pixel++) { - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) { - u8 grayValue = (31 & *pixel); + u8 grayValue = (*pixel & RGB_RED); if (grayValue > 31 - highlight) grayValue = 31 - (highlight >> 1); @@ -183,7 +183,7 @@ static void ApplyImageEffect_Grayscale(void) u16 *pixel = &pixelRow[gCanvasColumnStart]; for (i = 0; i < gCanvasColumnEnd; i++, pixel++) { - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) *pixel = ConvertColorToGrayscale(pixel); } } @@ -203,7 +203,7 @@ static void ApplyImageEffect_Blur(void) pixel += gCanvasWidth; while (j < gCanvasRowEnd - 1) { - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) { *pixel = QuantizePixel_Blur(&prevPixel, pixel, pixel + gCanvasWidth); prevPixel = *pixel; @@ -225,7 +225,7 @@ static void ApplyImageEffect_PersonalityColor(u8 personality) u16 *pixel = &pixelRow[gCanvasColumnStart]; for (i = 0; i < gCanvasColumnEnd; i++, pixel++) { - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) *pixel = QuantizePixel_PersonalityColor(pixel, personality); } } @@ -241,7 +241,7 @@ static void ApplyImageEffect_BlackAndWhite(void) u16 *pixel = &pixelRow[gCanvasColumnStart]; for (i = 0; i < gCanvasColumnEnd; i++, pixel++) { - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) *pixel = QuantizePixel_BlackAndWhite(pixel); } } @@ -293,7 +293,7 @@ static void ApplyImageEffect_Invert(void) u16 *pixel = &pixelRow[gCanvasColumnStart]; for (i = 0; i < gCanvasColumnEnd; i++, pixel++) { - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) *pixel = QuantizePixel_Invert(pixel); } } @@ -311,7 +311,7 @@ static void ApplyImageEffect_Shimmer(void) { for (j = 0; j < 64; j++, pixel++) { - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) *pixel = QuantizePixel_Invert(pixel); } } @@ -321,30 +321,30 @@ static void ApplyImageEffect_Shimmer(void) { pixel = &gCanvasPixels[j]; prevPixel = *pixel; - *pixel = 0x8000; + *pixel = RGB_ALPHA; for (i = 1, pixel += 64; i < 63; i++, pixel += 64) { - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) { *pixel = QuantizePixel_BlurHard(&prevPixel, pixel, pixel + 64); prevPixel = *pixel; } } - *pixel = 0x8000; + *pixel = RGB_ALPHA; pixel = &gCanvasPixels[j]; prevPixel = *pixel; - *pixel = 0x8000; + *pixel = RGB_ALPHA; for (i = 1, pixel += 64; i < 63; i++, pixel += 64) { - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) { *pixel = QuantizePixel_BlurHard(&prevPixel, pixel, pixel + 64); prevPixel = *pixel; } } - *pixel = 0x8000; + *pixel = RGB_ALPHA; } // Finally, invert colors back to the original color space. @@ -355,7 +355,7 @@ static void ApplyImageEffect_Shimmer(void) { for (j = 0; j < 64; j++, pixel++) { - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) *pixel = QuantizePixel_Invert(pixel); } } @@ -372,7 +372,7 @@ static void ApplyImageEffect_BlurRight(void) u16 prevPixel = *pixel; for (i = 1, pixel++; i < gCanvasColumnEnd - 1; i++, pixel++) { - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) { *pixel = QuantizePixel_MotionBlur(&prevPixel, pixel); prevPixel = *pixel; @@ -392,7 +392,7 @@ static void ApplyImageEffect_BlurDown(void) u16 prevPixel = *pixel; for (j = 1, pixel += gCanvasWidth; j < gCanvasRowEnd - 1; j++, pixel += gCanvasWidth) { - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) { *pixel = QuantizePixel_MotionBlur(&prevPixel, pixel); prevPixel = *pixel; @@ -447,11 +447,11 @@ static void AddPointillismPoints(u16 arg0) { u16 *pixel = &gCanvasPixels[points[i].row * 64] + points[i].column; - if (!(0x8000 & *pixel)) + if (!IS_ALPHA(*pixel)) { - u16 red = (*pixel) & 0x1F; - u16 green = (*pixel >> 5) & 0x1F; - u16 blue = (*pixel >> 10) & 0x1F; + u16 red = GET_R(*pixel); + u16 green = GET_G(*pixel); + u16 blue = GET_B(*pixel); switch (colorType) { @@ -501,9 +501,9 @@ static void AddPointillismPoints(u16 arg0) static u16 ConvertColorToGrayscale(u16 *color) { s32 clr = *color; - s32 r = clr & 0x1F; - s32 g = (clr >> 5) & 0x1F; - s32 b = (clr >> 10) & 0x1F; + s32 r = GET_R(clr); + s32 g = GET_G(clr); + s32 b = GET_B(clr); s32 gray = (r * Q_8_8(0.3) + g * Q_8_8(0.59) + b * Q_8_8(0.1133)) >> 8; return RGB2(gray, gray, gray); } @@ -512,9 +512,9 @@ static u16 ConvertColorToGrayscale(u16 *color) // Everything else is white. static u16 QuantizePixel_PersonalityColor(u16 *color, u8 personality) { - u16 red = *color & 0x1F; - u16 green = (*color >> 5) & 0x1F; - u16 blue = (*color >> 10) & 0x1F; + u16 red = GET_R(*color); + u16 green = GET_G(*color); + u16 blue = GET_B(*color); if (red < 17 && green < 17 && blue < 17) return GetColorFromPersonality(personality); @@ -526,9 +526,9 @@ static u16 QuantizePixel_PersonalityColor(u16 *color, u8 personality) // the mon's personality value, return a color. static u16 GetColorFromPersonality(u8 personality) { - u16 red = 0; + u16 red = 0; u16 green = 0; - u16 blue = 0; + u16 blue = 0; u8 strength = (personality / 6) % 3; u8 colorType = personality % 6; @@ -577,9 +577,9 @@ static u16 GetColorFromPersonality(u8 personality) static u16 QuantizePixel_BlackAndWhite(u16 *color) { - u16 red = *color & 0x1F; - u16 green = (*color >> 5) & 0x1F; - u16 blue = (*color >> 10) & 0x1F; + u16 red = GET_R(*color); + u16 green = GET_G(*color); + u16 blue = GET_B(*color); if (red < 17 && green < 17 && blue < 17) return RGB_BLACK; @@ -591,9 +591,9 @@ static u16 QuantizePixel_BlackOutline(u16 *pixelA, u16 *pixelB) { if (*pixelA != RGB_BLACK) { - if (*pixelA & 0x8000) - return 0x8000; - if (*pixelB & 0x8000) + if (IS_ALPHA(*pixelA)) + return RGB_ALPHA; + if (IS_ALPHA(*pixelB)) return RGB_BLACK; return *pixelA; @@ -604,13 +604,13 @@ static u16 QuantizePixel_BlackOutline(u16 *pixelA, u16 *pixelB) static u16 QuantizePixel_Invert(u16 *color) { - u16 red = *color & 0x1F; - u16 green = (*color >> 5) & 0x1F; - u16 blue = (*color >> 10) & 0x1F; + u16 red = GET_R(*color); + u16 green = GET_G(*color); + u16 blue = GET_B(*color); - red = 31 - red; + red = 31 - red; green = 31 - green; - blue = 31 - blue; + blue = 31 - blue; return RGB2(red, green, blue); } @@ -626,12 +626,12 @@ static u16 QuantizePixel_MotionBlur(u16 *prevPixel, u16 *curPixel) if (*prevPixel == *curPixel) return *curPixel; - pixelChannels[0][0] = (*prevPixel >> 0) & 0x1F; - pixelChannels[0][1] = (*prevPixel >> 5) & 0x1F; - pixelChannels[0][2] = (*prevPixel >> 10) & 0x1F; - pixelChannels[1][0] = (*curPixel >> 0) & 0x1F; - pixelChannels[1][1] = (*curPixel >> 5) & 0x1F; - pixelChannels[1][2] = (*curPixel >> 10) & 0x1F; + pixelChannels[0][0] = GET_R(*prevPixel); + pixelChannels[0][1] = GET_G(*prevPixel); + pixelChannels[0][2] = GET_B(*prevPixel); + pixelChannels[1][0] = GET_R(*curPixel); + pixelChannels[1][1] = GET_G(*curPixel); + pixelChannels[1][2] = GET_B(*curPixel); // Don't blur light colors. if (pixelChannels[0][0] > 25 && pixelChannels[0][1] > 25 && pixelChannels[0][2] > 25) @@ -667,9 +667,9 @@ static u16 QuantizePixel_MotionBlur(u16 *prevPixel, u16 *curPixel) largestDiff = diffs[0]; } - red = (pixelChannels[1][0] * (31 - largestDiff / 2)) / 31; + red = (pixelChannels[1][0] * (31 - largestDiff / 2)) / 31; green = (pixelChannels[1][1] * (31 - largestDiff / 2)) / 31; - blue = (pixelChannels[1][2] * (31 - largestDiff / 2)) / 31; + blue = (pixelChannels[1][2] * (31 - largestDiff / 2)) / 31; return RGB2(red, green, blue); } @@ -684,13 +684,13 @@ static u16 QuantizePixel_Blur(u16 *prevPixel, u16 *curPixel, u16 *nextPixel) if (*prevPixel == *curPixel && *nextPixel == *curPixel) return *curPixel; - red = (*curPixel >> 0) & 0x1F; - green = (*curPixel >> 5) & 0x1F; - blue = (*curPixel >> 10) & 0x1F; + red = GET_R(*curPixel); + green = GET_G(*curPixel); + blue = GET_B(*curPixel); - prevAvg = (((*prevPixel >> 0) & 0x1F) + ((*prevPixel >> 5) & 0x1F) + ((*prevPixel >> 10) & 0x1F)) / 3; - curAvg = (((*curPixel >> 0) & 0x1F) + ((*curPixel >> 5) & 0x1F) + ((*curPixel >> 10) & 0x1F)) / 3; - nextAvg = (((*nextPixel >> 0) & 0x1F) + ((*nextPixel >> 5) & 0x1F) + ((*nextPixel >> 10) & 0x1F)) / 3; + prevAvg = (GET_R(*prevPixel) + GET_G(*prevPixel) + GET_B(*prevPixel)) / 3; + curAvg = (GET_R(*curPixel) + GET_G(*curPixel) + GET_B(*curPixel)) / 3; + nextAvg = (GET_R(*nextPixel) + GET_G(*nextPixel) + GET_B(*nextPixel)) / 3; if (prevAvg == curAvg && nextAvg == curAvg) return *curPixel; @@ -728,14 +728,14 @@ static u16 QuantizePixel_BlurHard(u16 *prevPixel, u16 *curPixel, u16 *nextPixel) if (*prevPixel == *curPixel && *nextPixel == *curPixel) return *curPixel; - red = (*curPixel >> 0) & 0x1F; - green = (*curPixel >> 5) & 0x1F; - blue = (*curPixel >> 10) & 0x1F; - - prevAvg = (((*prevPixel >> 0) & 0x1F) + ((*prevPixel >> 5) & 0x1F) + ((*prevPixel >> 10) & 0x1F)) / 3; - curAvg = (((*curPixel >> 0) & 0x1F) + ((*curPixel >> 5) & 0x1F) + ((*curPixel >> 10) & 0x1F)) / 3; - nextAvg = (((*nextPixel >> 0) & 0x1F) + ((*nextPixel >> 5) & 0x1F) + ((*nextPixel >> 10) & 0x1F)) / 3; - + red = GET_R(*curPixel); + green = GET_G(*curPixel); + blue = GET_B(*curPixel); + + prevAvg = (GET_R(*prevPixel) + GET_G(*prevPixel) + GET_B(*prevPixel)) / 3; + curAvg = (GET_R(*curPixel) + GET_G(*curPixel) + GET_B(*curPixel)) / 3; + nextAvg = (GET_R(*nextPixel) + GET_G(*nextPixel) + GET_B(*nextPixel)) / 3; + if (prevAvg == curAvg && nextAvg == curAvg) return *curPixel; @@ -851,37 +851,37 @@ void ApplyImageProcessingQuantization(struct ImageProcessingContext *context) static void SetPresetPalette_PrimaryColors(void) { - gCanvasPalette[0] = RGB2(0, 0, 0); - gCanvasPalette[1] = RGB2(6, 6, 6); - gCanvasPalette[2] = RGB2(29, 29, 29); - gCanvasPalette[3] = RGB2(11, 11, 11); - gCanvasPalette[4] = RGB2(29, 6, 6); - gCanvasPalette[5] = RGB2(6, 29, 6); - gCanvasPalette[6] = RGB2(6, 6, 29); - gCanvasPalette[7] = RGB2(29, 29, 6); - gCanvasPalette[8] = RGB2(29, 6, 29); - gCanvasPalette[9] = RGB2(6, 29, 29); - gCanvasPalette[10] = RGB2(29, 11, 6); - gCanvasPalette[11] = RGB2(11, 29, 6); - gCanvasPalette[12] = RGB2(6, 11, 29); - gCanvasPalette[13] = RGB2(29, 6, 11); - gCanvasPalette[14] = RGB2(6, 29, 11); - gCanvasPalette[15] = RGB2(11, 6, 29); + gCanvasPalette[0] = RGB_BLACK; + gCanvasPalette[1] = RGB(6, 6, 6); + gCanvasPalette[2] = RGB(29, 29, 29); + gCanvasPalette[3] = RGB(11, 11, 11); + gCanvasPalette[4] = RGB(29, 6, 6); + gCanvasPalette[5] = RGB(6, 29, 6); + gCanvasPalette[6] = RGB(6, 6, 29); + gCanvasPalette[7] = RGB(29, 29, 6); + gCanvasPalette[8] = RGB(29, 6, 29); + gCanvasPalette[9] = RGB(6, 29, 29); + gCanvasPalette[10] = RGB(29, 11, 6); + gCanvasPalette[11] = RGB(11, 29, 6); + gCanvasPalette[12] = RGB(6, 11, 29); + gCanvasPalette[13] = RGB(29, 6, 11); + gCanvasPalette[14] = RGB(6, 29, 11); + gCanvasPalette[15] = RGB(11, 6, 29); } static void SetPresetPalette_BlackAndWhite(void) { - gCanvasPalette[0] = RGB2(0, 0, 0); - gCanvasPalette[1] = RGB2(0, 0, 0); - gCanvasPalette[2] = RGB2(31, 31, 31); + gCanvasPalette[0] = RGB_BLACK; + gCanvasPalette[1] = RGB_BLACK; + gCanvasPalette[2] = RGB_WHITE; } static void SetPresetPalette_GrayscaleSmall(void) { u8 i; - gCanvasPalette[0] = RGB2(0, 0, 0); - gCanvasPalette[1] = RGB2(0, 0, 0); + gCanvasPalette[0] = RGB_BLACK; + gCanvasPalette[1] = RGB_BLACK; for (i = 0; i < 14; i++) gCanvasPalette[i + 2] = RGB2(2 * (i + 2), 2 * (i + 2), 2 * (i + 2)); } @@ -890,7 +890,7 @@ static void SetPresetPalette_Grayscale(void) { u8 i; - gCanvasPalette[0] = RGB2(0, 0, 0); + gCanvasPalette[0] = RGB_BLACK; for (i = 0; i < 32; i++) gCanvasPalette[i + 1] = RGB2(i, i, i); } @@ -914,7 +914,7 @@ static void QuantizePalette_Standard(bool8 useLimitedPalette) u16 *pixel = &pixelRow[gCanvasColumnStart]; for (i = 0; i < gCanvasColumnEnd; i++, pixel++) { - if (*pixel & 0x8000) + if (IS_ALPHA(*pixel)) { *pixel = gCanvasPaletteStart; } @@ -982,7 +982,7 @@ static void QuantizePalette_BlackAndWhite(void) u16 *pixel = &pixelRow[gCanvasColumnStart]; for (i = 0; i < gCanvasColumnEnd; i++, pixel++) { - if (*pixel & 0x8000) + if (IS_ALPHA(*pixel)) { *pixel = gCanvasPaletteStart; } @@ -1013,7 +1013,7 @@ static void QuantizePalette_GrayscaleSmall(void) u16 *pixel = &pixelRow[gCanvasColumnStart]; for (i = 0; i < gCanvasColumnEnd; i++, pixel++) { - if (*pixel & 0x8000) + if (IS_ALPHA(*pixel)) *pixel = gCanvasPaletteStart; else *pixel = QuantizePixel_GrayscaleSmall(pixel) + gCanvasPaletteStart; @@ -1031,7 +1031,7 @@ static void QuantizePalette_Grayscale(void) u16 *pixel = &pixelRow[gCanvasColumnStart]; for (i = 0; i < gCanvasColumnEnd; i++, pixel++) { - if (*pixel & 0x8000) + if (IS_ALPHA(*pixel)) *pixel = gCanvasPaletteStart; else *pixel = QuantizePixel_Grayscale(pixel) + gCanvasPaletteStart; @@ -1049,7 +1049,7 @@ static void QuantizePalette_PrimaryColors(void) u16 *pixel = &pixelRow[gCanvasColumnStart]; for (i = 0; i < gCanvasColumnEnd; i++, pixel++) { - if (*pixel & 0x8000) + if (IS_ALPHA(*pixel)) *pixel = gCanvasPaletteStart; else *pixel = QuantizePixel_PrimaryColors(pixel) + gCanvasPaletteStart; @@ -1060,9 +1060,9 @@ static void QuantizePalette_PrimaryColors(void) // Quantizes the pixel's color channels to nearest multiple of 4, and clamps to [6, 30]. static u16 QuantizePixel_Standard(u16 *pixel) { - u16 red = *pixel & 0x1F; - u16 green = (*pixel >> 5) & 0x1F; - u16 blue = (*pixel >> 10) & 0x1F; + u16 red = GET_R(*pixel); + u16 green = GET_G(*pixel); + u16 blue = GET_B(*pixel); // Quantize color channels to muliples of 4, rounding up. if (red & 3) @@ -1091,10 +1091,10 @@ static u16 QuantizePixel_Standard(u16 *pixel) static u16 QuantizePixel_PrimaryColors(u16* color) { - u16 red = *color & 0x1F; - u16 green = (*color >> 5) & 0x1F; - u16 blue = (*color >> 10) & 0x1F; - + u16 red = GET_R(*color); + u16 green = GET_G(*color); + u16 blue = GET_B(*color); + if (red < 12 && green < 11 && blue < 11) return 1; @@ -1206,9 +1206,9 @@ static u16 QuantizePixel_PrimaryColors(u16* color) static u16 QuantizePixel_GrayscaleSmall(u16 *color) { - u16 red = *color & 0x1F; - u16 green = (*color >> 5) & 0x1F; - u16 blue = (*color >> 10) & 0x1F; + u16 red = GET_R(*color); + u16 green = GET_G(*color); + u16 blue = GET_B(*color); u16 average = ((red + green + blue) / 3) & 0x1E; if (average == 0) return 1; @@ -1218,9 +1218,9 @@ static u16 QuantizePixel_GrayscaleSmall(u16 *color) static u16 QuantizePixel_Grayscale(u16 *color) { - u16 red = *color & 0x1F; - u16 green = (*color >> 5) & 0x1F; - u16 blue = (*color >> 10) & 0x1F; + u16 red = GET_R(*color); + u16 green = GET_G(*color); + u16 blue = GET_B(*color); u16 average = (red + green + blue) / 3; return average + 1; } diff --git a/src/intro.c b/src/intro.c index 7dab2ad46..7c92913b6 100644 --- a/src/intro.c +++ b/src/intro.c @@ -986,8 +986,6 @@ static void SerialCB_CopyrightScreen(void) static u8 SetUpCopyrightScreen(void) { - u16 ime; - switch (gMain.state) { case 0: @@ -1302,7 +1300,6 @@ static void Task_IntroStartBikeRide(u8 taskId) static void Task_IntroHandleBikeAndFlygonMovement(u8 taskId) { - s16 a; u16 offset; if (gIntroFrameCounter == 1856) diff --git a/src/item.c b/src/item.c index 0b6366048..91d2f1a0a 100644 --- a/src/item.c +++ b/src/item.c @@ -102,8 +102,8 @@ void CopyItemNameHandlePlural(u16 itemId, u8 *dst, u32 quantity) } else { - if (itemId >= ITEM_CHERI_BERRY && itemId <= ITEM_ENIGMA_BERRY) - GetBerryCountString(dst, gBerries[itemId - ITEM_CHERI_BERRY].name, quantity); + if (itemId >= FIRST_BERRY_INDEX && itemId <= LAST_BERRY_INDEX) + GetBerryCountString(dst, gBerries[itemId - FIRST_BERRY_INDEX].name, quantity); else StringCopy(dst, ItemId_GetName(itemId)); } diff --git a/src/item_menu.c b/src/item_menu.c index 80035b945..6d30038d0 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -41,7 +41,6 @@ #include "shop.h" #include "sound.h" #include "sprite.h" -#include "string.h" #include "strings.h" #include "string_util.h" #include "task.h" @@ -628,7 +627,6 @@ void CB2_Bag(void) bool8 SetupBagMenu(void) { - u32 index; u8 taskId; switch (gMain.state) @@ -743,7 +741,7 @@ void BagMenu_InitBGs(void) ResetVramOamAndBgCntRegs(); memset(gBagMenu->tilemapBuffer, 0, 0x800); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sBgTemplates_ItemMenu, 3); + InitBgsFromTemplates(0, sBgTemplates_ItemMenu, ARRAY_COUNT(sBgTemplates_ItemMenu)); SetBgTilemapBuffer(2, gBagMenu->tilemapBuffer); ResetAllBgsCoordinates(); ScheduleBgCopyTilemapToVram(2); @@ -866,7 +864,7 @@ void GetItemName(s8 *dest, u16 itemId) } break; case BERRIES_POCKET: - ConvertIntToDecimalStringN(gStringVar1, itemId - ITEM_CHERI_BERRY + 1, STR_CONV_MODE_LEADING_ZEROS, 2); + ConvertIntToDecimalStringN(gStringVar1, itemId - FIRST_BERRY_INDEX + 1, STR_CONV_MODE_LEADING_ZEROS, 2); CopyItemName(itemId, gStringVar2); StringExpandPlaceholders(dest, gText_NumberVar1Clear7Var2); break; @@ -1722,7 +1720,7 @@ void ItemMenu_UseOutOfBattle(u8 taskId) if (ItemId_GetFieldFunc(gSpecialVar_ItemId)) { BagMenu_RemoveSomeWindow(); - if (CalculatePlayerPartyCount() == 0 && ItemId_GetType(gSpecialVar_ItemId) == 1) + if (CalculatePlayerPartyCount() == 0 && ItemId_GetType(gSpecialVar_ItemId) == ITEM_USE_PARTY_MENU) BagMenu_PrintThereIsNoPokemon(taskId); else { diff --git a/src/item_use.c b/src/item_use.c index 9ab755a5e..af0ca9ee5 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -53,7 +53,7 @@ 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 sub_80FDC00(u8 taskId); +static void Task_OpenRegisteredPokeblockCase(u8 taskId); static void ItemUseOnFieldCB_Bike(u8 taskId); static void ItemUseOnFieldCB_Rod(u8); static void ItemUseOnFieldCB_Itemfinder(u8); @@ -69,7 +69,7 @@ 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 CB2_OpenPokeblockCaseOnField(void); +static void CB2_OpenPokeblockFromBag(void); // EWRAM variables EWRAM_DATA static void(*sItemUseOnFieldCB)(u8 taskId) = NULL; @@ -77,13 +77,13 @@ EWRAM_DATA static void(*sItemUseOnFieldCB)(u8 taskId) = NULL; // Below is set TRUE by UseRegisteredKeyItemOnField #define tUsingRegisteredKeyItem data[3] -// .rodata - +// UB here if an item with type ITEM_USE_MAIL or ITEM_USE_BAG_MENU uses SetUpItemUseCallback +// Never occurs in vanilla, but can occur with improperly created items static const MainCallback sItemUseCallbacks[] = { - CB2_ShowPartyMenuForItemUse, - CB2_ReturnToField, - NULL, + [ITEM_USE_PARTY_MENU - 1] = CB2_ShowPartyMenuForItemUse, + [ITEM_USE_FIELD - 1] = CB2_ReturnToField, + [ITEM_USE_PBLOCK_CASE - 1] = NULL, }; static const u8 sClockwiseDirections[] = {DIR_NORTH, DIR_EAST, DIR_SOUTH, DIR_WEST}; @@ -94,13 +94,12 @@ static const struct YesNoFuncTable sUseTMHMYesNoFuncTable = .noFunc = BagMenu_InitListsMenu, }; -// .text - +#define tEnigmaBerryType data[4] static void SetUpItemUseCallback(u8 taskId) { u8 type; if (gSpecialVar_ItemId == ITEM_ENIGMA_BERRY) - type = gTasks[taskId].data[4] - 1; + type = gTasks[taskId].tEnigmaBerryType - 1; else type = ItemId_GetType(gSpecialVar_ItemId) - 1; if (!InBattlePyramid()) @@ -218,9 +217,9 @@ void ItemUseOutOfBattle_Bike(u8 taskId) static void ItemUseOnFieldCB_Bike(u8 taskId) { - if (!ItemId_GetSecondaryId(gSpecialVar_ItemId)) + if (ItemId_GetSecondaryId(gSpecialVar_ItemId) == MACH_BIKE) GetOnOffBike(PLAYER_AVATAR_FLAG_MACH_BIKE); - else + else // ACRO_BIKE GetOnOffBike(PLAYER_AVATAR_FLAG_ACRO_BIKE); ScriptUnfreezeObjectEvents(); ScriptContext2_Disable(); @@ -615,23 +614,23 @@ void ItemUseOutOfBattle_PokeblockCase(u8 taskId) } else if (gTasks[taskId].tUsingRegisteredKeyItem != TRUE) { - gBagMenu->exitCallback = CB2_OpenPokeblockCaseOnField; + gBagMenu->exitCallback = CB2_OpenPokeblockFromBag; Task_FadeAndCloseBagMenu(taskId); } else { - gFieldCallback = sub_80AF6D4; + gFieldCallback = FieldCB_ReturnToFieldNoScript; FadeScreen(FADE_TO_BLACK, 0); - gTasks[taskId].func = sub_80FDC00; + gTasks[taskId].func = Task_OpenRegisteredPokeblockCase; } } -static void CB2_OpenPokeblockCaseOnField(void) +static void CB2_OpenPokeblockFromBag(void) { OpenPokeblockCase(PBLOCK_CASE_FIELD, CB2_ReturnToBagMenuPocket); } -static void sub_80FDC00(u8 taskId) +static void Task_OpenRegisteredPokeblockCase(u8 taskId) { if (!gPaletteFade.active) { @@ -1065,28 +1064,28 @@ void ItemUseOutOfBattle_EnigmaBerry(u8 taskId) case ITEM_EFFECT_SPDEF_EV: case ITEM_EFFECT_SPEED_EV: case ITEM_EFFECT_DEF_EV: - gTasks[taskId].data[4] = 1; + gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU; ItemUseOutOfBattle_Medicine(taskId); break; case ITEM_EFFECT_SACRED_ASH: - gTasks[taskId].data[4] = 1; + gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU; ItemUseOutOfBattle_SacredAsh(taskId); break; case ITEM_EFFECT_RAISE_LEVEL: - gTasks[taskId].data[4] = 1; + gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU; ItemUseOutOfBattle_RareCandy(taskId); break; case ITEM_EFFECT_PP_UP: case ITEM_EFFECT_PP_MAX: - gTasks[taskId].data[4] = 1; + gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU; ItemUseOutOfBattle_PPUp(taskId); break; case ITEM_EFFECT_HEAL_PP: - gTasks[taskId].data[4] = 1; + gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU; ItemUseOutOfBattle_PPRecovery(taskId); break; default: - gTasks[taskId].data[4] = 4; + gTasks[taskId].tEnigmaBerryType = ITEM_USE_BAG_MENU; ItemUseOutOfBattle_CannotUse(taskId); break; } diff --git a/src/librfu_rfu.c b/src/librfu_rfu.c index fe1d10834..7cb9b1bd6 100644 --- a/src/librfu_rfu.c +++ b/src/librfu_rfu.c @@ -1724,7 +1724,6 @@ static void rfu_constructSendLLFrame(void) u32 pakcketSize, currSize; u8 i; u8 *llf_p; - struct RfuSlotStatusNI *slotStatusNI; if (gRfuLinkStatus->parentChild != MODE_NEUTRAL && gRfuLinkStatus->sendSlotNIFlag | gRfuLinkStatus->recvSlotNIFlag | gRfuLinkStatus->sendSlotUNIFlag) diff --git a/src/link.c b/src/link.c index 9fd35a10b..dffb5b4cd 100644 --- a/src/link.c +++ b/src/link.c @@ -1489,7 +1489,7 @@ static void LinkCB_WaitCloseLink(void) if (count == linkPlayerCount) { // All ready, close link - gBattleTypeFlags &= ~BATTLE_TYPE_20; + gBattleTypeFlags &= ~BATTLE_TYPE_LINK_IN_BATTLE; gLinkVSyncDisabled = TRUE; CloseLink(); gLinkCallback = NULL; @@ -1551,7 +1551,7 @@ static void LinkCB_WaitCloseLinkWithJP(void) if (count == linkPlayerCount) { // All ready, close link - gBattleTypeFlags &= ~BATTLE_TYPE_20; + gBattleTypeFlags &= ~BATTLE_TYPE_LINK_IN_BATTLE; gLinkVSyncDisabled = TRUE; CloseLink(); gLinkCallback = NULL; diff --git a/src/link_rfu_2.c b/src/link_rfu_2.c index 5e0ef0aa4..b7713fa3f 100644 --- a/src/link_rfu_2.c +++ b/src/link_rfu_2.c @@ -1380,7 +1380,7 @@ static void WaitAllReadyToCloseLink(void) if (count == playerCount) { // All ready, close link - gBattleTypeFlags &= ~BATTLE_TYPE_20; + gBattleTypeFlags &= ~BATTLE_TYPE_LINK_IN_BATTLE; if (Rfu.parentChild == MODE_CHILD) { Rfu.errorState = 3; diff --git a/src/mail.c b/src/mail.c index 01574f53a..cfdfb341c 100644 --- a/src/mail.c +++ b/src/mail.c @@ -125,7 +125,7 @@ static void CB2_ExitMailReadFreeVars(void); // .rodata -static const struct BgTemplate sUnknown_0859F290[] = { +static const struct BgTemplate sBgTemplates[] = { { .bg = 0, .charBaseIndex = 2, @@ -254,7 +254,7 @@ void ReadMail(struct MailStruct *mail, void (*callback)(void), bool8 flag) sMailRead->parserMultiple = ConvertEasyChatWordsToString; if (IS_ITEM_MAIL(mail->itemId)) { - sMailRead->mailType = mail->itemId - ITEM_ORANGE_MAIL; + sMailRead->mailType = mail->itemId - FIRST_MAIL_INDEX; } else { @@ -279,10 +279,10 @@ void ReadMail(struct MailStruct *mail, void (*callback)(void), bool8 flag) default: sMailRead->animsActive = 0; break; - case ITEM_BEAD_MAIL - ITEM_ORANGE_MAIL: + case ITEM_BEAD_MAIL - FIRST_MAIL_INDEX: sMailRead->animsActive = 1; break; - case ITEM_DREAM_MAIL - ITEM_ORANGE_MAIL: + case ITEM_DREAM_MAIL - FIRST_MAIL_INDEX: sMailRead->animsActive = 2; break; } @@ -336,7 +336,7 @@ static bool8 MailReadBuildGraphics(void) break; case 6: ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sUnknown_0859F290, 3); + InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates)); SetBgTilemapBuffer(1, sMailRead->bg1TilemapBuffer); SetBgTilemapBuffer(2, sMailRead->bg2TilemapBuffer); break; diff --git a/src/main.c b/src/main.c index 9fd1d0a35..992d23ead 100644 --- a/src/main.c +++ b/src/main.c @@ -75,7 +75,7 @@ static EWRAM_DATA u16 gTrainerId = 0; static void UpdateLinkAndCallCallbacks(void); static void InitMainCallbacks(void); static void CallCallbacks(void); -//static void SeedRngWithRtc(void); +static void SeedRngWithRtc(void); static void ReadKeys(void); void InitIntrHandlers(void); static void WaitForVBlank(void); @@ -102,7 +102,9 @@ void AgbMain() CheckForFlashMemory(); InitMainCallbacks(); InitMapMusic(); - //SeedRngWithRtc(); see comment at SeedRngWithRtc declaration below +#ifdef BUGFIX + SeedRngWithRtc(); // see comment at SeedRngWithRtc definition below +#endif ClearDma3Requests(); ResetBgs(); SetDefaultFontsPointer(); @@ -213,13 +215,15 @@ void EnableVCountIntrAtLine150(void) EnableInterrupts(INTR_FLAG_VCOUNT); } -// oops! FRLG commented this out to remove RTC, however Emerald didnt undo this! -//static void SeedRngWithRtc(void) -//{ -// u32 seed = RtcGetMinuteCount(); -// seed = (seed >> 16) ^ (seed & 0xFFFF); -// SeedRng(seed); -//} +// FRLG commented this out to remove RTC, however Emerald didn't undo this! +#ifdef BUGFIX +static void SeedRngWithRtc(void) +{ + u32 seed = RtcGetMinuteCount(); + seed = (seed >> 16) ^ (seed & 0xFFFF); + SeedRng(seed); +} +#endif void InitKeys(void) { @@ -294,7 +298,7 @@ void InitIntrHandlers(void) REG_IME = 1; - EnableInterrupts(0x1); + EnableInterrupts(INTR_FLAG_VBLANK); } void SetVBlankCallback(IntrCallback callback) diff --git a/src/main_menu.c b/src/main_menu.c index 5b39b6d45..74af96da8 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -28,7 +28,6 @@ #include "scanline_effect.h" #include "sound.h" #include "sprite.h" -#include "string.h" #include "strings.h" #include "string_util.h" #include "task.h" @@ -1800,7 +1799,7 @@ static void CB2_NewGameBirchSpeech_ReturnFromNamingScreen(void) ResetBgsAndClearDma3BusyFlags(0); SetGpuReg(REG_OFFSET_DISPCNT, 0); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); - InitBgsFromTemplates(0, sMainMenuBgTemplates, 2); + InitBgsFromTemplates(0, sMainMenuBgTemplates, ARRAY_COUNT(sMainMenuBgTemplates)); InitBgFromTemplate(&sBirchBgTemplate); SetVBlankCallback(NULL); SetGpuReg(REG_OFFSET_BG2CNT, 0); @@ -2098,7 +2097,7 @@ static void NewGameBirchSpeech_ShowGenderMenu(void) { DrawMainMenuWindowBorder(&gNewGameBirchSpeechTextWindows[1], 0xF3); FillWindowPixelBuffer(1, PIXEL_FILL(1)); - PrintMenuTable(1, 2, sMenuActions_Gender); + PrintMenuTable(1, ARRAY_COUNT(sMenuActions_Gender), sMenuActions_Gender); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(1, 2, 0); PutWindowTilemap(1); CopyWindowToVram(1, 3); diff --git a/src/match_call.c b/src/match_call.c index 723562ade..7e8d0c38a 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -1494,7 +1494,6 @@ static const struct MatchCallText *GetGeneralMatchCallText(int matchCallId, u8 * int count; u32 topic, id; u16 rand; - u16 var3; rand = Random(); if (!(rand & 1)) diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index af68c6116..c97ee94f3 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -1324,7 +1324,6 @@ static void PrintStoryList(void) { s32 i; s32 width = GetStringWidth(1, gText_Exit, 0); - u8 tileWidth; for (i = 0; i < NUM_STORYTELLER_TALES; i++) { s32 curWidth; diff --git a/src/mevent_server.c b/src/mevent_server.c index 0d3afea30..2e7b3d89a 100644 --- a/src/mevent_server.c +++ b/src/mevent_server.c @@ -288,8 +288,8 @@ static u32 (*const func_tbl[])(struct mevent_srv_common *) = { static u32 mevent_srv_exec_common(struct mevent_srv_common * svr) { u32 response; - AGB_ASSERT(svr->mainseqno < NELEMS(func_tbl)); + AGB_ASSERT(svr->mainseqno < ARRAY_COUNT(func_tbl)); response = func_tbl[svr->mainseqno](svr); - AGB_ASSERT(svr->mainseqno < NELEMS(func_tbl)); + AGB_ASSERT(svr->mainseqno < ARRAY_COUNT(func_tbl)); return response; } diff --git a/src/minigame_countdown.c b/src/minigame_countdown.c index cd5710d44..d2f7d3ea8 100644 --- a/src/minigame_countdown.c +++ b/src/minigame_countdown.c @@ -14,7 +14,6 @@ static void sub_802E83C(u8 taskId); static void sub_802E8C8(u8 taskId); static void sub_802EA50(u8 taskId); static void sub_802EAB0(u8 taskId); -static void sub_802EB98(u8 taskId); static void Task_MinigameCountdown(u8 taskId); static bool32 RunMinigameCountdownDigitsAnim(u8 spriteId); static bool32 IsStartGraphicAnimRunning(u8 spriteId); diff --git a/src/overworld.c b/src/overworld.c index 72aa17929..cbfc70898 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -174,7 +174,6 @@ static u8 sPlayerTradingStates[MAX_LINK_PLAYERS]; static u16 (*sPlayerKeyInterceptCallback)(u32); static bool8 sUnknown_03000E18; static u8 sRfuKeepAliveTimer; -static u32 sUnusedVar; // IWRAM common u16 *gBGTilemapBuffers1; diff --git a/src/palette.c b/src/palette.c index 320e11ecc..ece753d21 100644 --- a/src/palette.c +++ b/src/palette.c @@ -60,7 +60,7 @@ 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[0x10] = {0}; EWRAM_DATA struct PaletteFadeControl gPaletteFade = {0}; -static EWRAM_DATA u32 gFiller_2037FE0 = 0; +static EWRAM_DATA u32 sFiller = 0; static EWRAM_DATA u32 sPlttBufferTransferPending = 0; EWRAM_DATA u8 gPaletteDecompressionBuffer[PLTT_DECOMP_BUFFER_SIZE] = {0}; @@ -624,7 +624,7 @@ static u8 UpdateFastPaletteFade(void) if (b < b0) b = b0; - gPlttBufferFaded[i] = r | (g << 5) | (b << 10); + gPlttBufferFaded[i] = RGB(r, g, b); } break; case FAST_FADE_OUT_TO_WHITE: @@ -642,7 +642,7 @@ static u8 UpdateFastPaletteFade(void) if (b > 31) b = 31; - gPlttBufferFaded[i] = r | (g << 5) | (b << 10); + gPlttBufferFaded[i] = RGB(r, g, b); } break; case FAST_FADE_IN_FROM_BLACK: @@ -668,7 +668,7 @@ static u8 UpdateFastPaletteFade(void) if (b > b0) b = b0; - gPlttBufferFaded[i] = r | (g << 5) | (b << 10); + gPlttBufferFaded[i] = RGB(r, g, b); } break; case FAST_FADE_OUT_TO_BLACK: @@ -686,7 +686,7 @@ static u8 UpdateFastPaletteFade(void) if (b < 0) b = 0; - gPlttBufferFaded[i] = r | (g << 5) | (b << 10); + gPlttBufferFaded[i] = RGB(r, g, b); } } @@ -856,13 +856,13 @@ void TintPalette_GrayScale(u16 *palette, u16 count) for (i = 0; i < count; i++) { - r = (*palette >> 0) & 0x1F; - g = (*palette >> 5) & 0x1F; - b = (*palette >> 10) & 0x1F; + r = GET_R(*palette); + g = GET_G(*palette); + b = GET_B(*palette); gray = (r * Q_8_8(0.3) + g * Q_8_8(0.59) + b * Q_8_8(0.1133)) >> 8; - *palette++ = (gray << 10) | (gray << 5) | (gray << 0); + *palette++ = RGB2(gray, gray, gray); } } @@ -873,18 +873,18 @@ void TintPalette_GrayScale2(u16 *palette, u16 count) for (i = 0; i < count; i++) { - r = (*palette >> 0) & 0x1F; - g = (*palette >> 5) & 0x1F; - b = (*palette >> 10) & 0x1F; + r = GET_R(*palette); + g = GET_G(*palette); + b = GET_B(*palette); gray = (r * Q_8_8(0.3) + g * Q_8_8(0.59) + b * Q_8_8(0.1133)) >> 8; - if (gray > 0x1F) - gray = 0x1F; + if (gray > 31) + gray = 31; gray = sRoundedDownGrayscaleMap[gray]; - *palette++ = (gray << 10) | (gray << 5) | (gray << 0); + *palette++ = RGB2(gray, gray, gray); } } @@ -895,9 +895,9 @@ void TintPalette_SepiaTone(u16 *palette, u16 count) for (i = 0; i < count; i++) { - r = (*palette >> 0) & 0x1F; - g = (*palette >> 5) & 0x1F; - b = (*palette >> 10) & 0x1F; + r = GET_R(*palette); + g = GET_G(*palette); + b = GET_B(*palette); gray = (r * Q_8_8(0.3) + g * Q_8_8(0.59) + b * Q_8_8(0.1133)) >> 8; @@ -908,7 +908,7 @@ void TintPalette_SepiaTone(u16 *palette, u16 count) if (r > 31) r = 31; - *palette++ = (b << 10) | (g << 5) | (r << 0); + *palette++ = RGB2(r, g, b); } } @@ -919,9 +919,9 @@ void TintPalette_CustomTone(u16 *palette, u16 count, u16 rTone, u16 gTone, u16 b for (i = 0; i < count; i++) { - r = (*palette >> 0) & 0x1F; - g = (*palette >> 5) & 0x1F; - b = (*palette >> 10) & 0x1F; + r = GET_R(*palette); + g = GET_G(*palette); + b = GET_B(*palette); gray = (r * Q_8_8(0.3) + g * Q_8_8(0.59) + b * Q_8_8(0.1133)) >> 8; @@ -936,7 +936,7 @@ void TintPalette_CustomTone(u16 *palette, u16 count, u16 rTone, u16 gTone, u16 b if (b > 31) b = 31; - *palette++ = (b << 10) | (g << 5) | (r << 0); + *palette++ = RGB2(r, g, b); } } diff --git a/src/party_menu.c b/src/party_menu.c index 7c2f6f771..2d4432367 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -151,7 +151,7 @@ static EWRAM_DATA u16 *sSlot1TilemapBuffer = 0; // for switching party slots static EWRAM_DATA u16 *sSlot2TilemapBuffer = 0; // EWRAM_DATA u8 gSelectedOrderFromParty[MAX_FRONTIER_PARTY_SIZE] = {0}; static EWRAM_DATA u16 sPartyMenuItemId = 0; -static EWRAM_DATA u16 sUnused_0203CEFE = 0; +static EWRAM_DATA u16 sUnused = 0; EWRAM_DATA u8 gBattlePartyCurrentOrder[PARTY_SIZE / 2] = {0}; // bits 0-3 are the current pos of Slot 1, 4-7 are Slot 2, and so on // IWRAM common @@ -1221,16 +1221,16 @@ static void HandleChooseMonSelection(u8 taskId, s8 *slotPtr) } else { - switch (gPartyMenu.action - 3) + switch (gPartyMenu.action) { - case PARTY_ACTION_SOFTBOILED - 3: + case PARTY_ACTION_SOFTBOILED: if (IsSelectedMonNotEgg((u8*)slotPtr)) { PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); Task_TryUseSoftboiledOnPartyMon(taskId); } break; - case PARTY_ACTION_USE_ITEM - 3: + case PARTY_ACTION_USE_ITEM: if (IsSelectedMonNotEgg((u8*)slotPtr)) { if (gPartyMenu.menuType == PARTY_MENU_TYPE_IN_BATTLE) @@ -1240,7 +1240,7 @@ static void HandleChooseMonSelection(u8 taskId, s8 *slotPtr) gItemUseCB(taskId, Task_ClosePartyMenuAfterText); } break; - case PARTY_ACTION_MOVE_TUTOR - 3: + case PARTY_ACTION_MOVE_TUTOR: if (IsSelectedMonNotEgg((u8*)slotPtr)) { PlaySE(SE_SELECT); @@ -1248,7 +1248,7 @@ static void HandleChooseMonSelection(u8 taskId, s8 *slotPtr) TryTutorSelectedMon(taskId); } break; - case PARTY_ACTION_GIVE_MAILBOX_MAIL - 3: + case PARTY_ACTION_GIVE_MAILBOX_MAIL: if (IsSelectedMonNotEgg((u8*)slotPtr)) { PlaySE(SE_SELECT); @@ -1256,8 +1256,8 @@ static void HandleChooseMonSelection(u8 taskId, s8 *slotPtr) TryGiveMailToSelectedMon(taskId); } break; - case PARTY_ACTION_GIVE_ITEM - 3: - case PARTY_ACTION_GIVE_PC_ITEM - 3: + case PARTY_ACTION_GIVE_ITEM: + case PARTY_ACTION_GIVE_PC_ITEM: if (IsSelectedMonNotEgg((u8*)slotPtr)) { PlaySE(SE_SELECT); @@ -1265,23 +1265,23 @@ static void HandleChooseMonSelection(u8 taskId, s8 *slotPtr) TryGiveItemOrMailToSelectedMon(taskId); } break; - case PARTY_ACTION_SWITCH - 3: + case PARTY_ACTION_SWITCH: PlaySE(SE_SELECT); SwitchSelectedMons(taskId); break; - case PARTY_ACTION_CHOOSE_AND_CLOSE - 3: + case PARTY_ACTION_CHOOSE_AND_CLOSE: PlaySE(SE_SELECT); Task_ClosePartyMenu(taskId); break; - case PARTY_ACTION_MINIGAME - 3: + case PARTY_ACTION_MINIGAME: if (IsSelectedMonNotEgg((u8*)slotPtr)) { TryEnterMonForMinigame(taskId, (u8)*slotPtr); } break; default: - case PARTY_ACTION_ABILITY_PREVENTS - 3: - case PARTY_ACTION_SWITCHING - 3: + case PARTY_ACTION_ABILITY_PREVENTS: + case PARTY_ACTION_SWITCHING: PlaySE(SE_SELECT); Task_TryCreateSelectionWindow(taskId); break; @@ -1961,9 +1961,9 @@ static u8 CanMonLearnTMTutor(struct Pokemon *mon, u16 item, u8 tutor) if (GetMonData(mon, MON_DATA_IS_EGG)) return CANNOT_LEARN_MOVE_IS_EGG; - if (item >= ITEM_TM01_FOCUS_PUNCH) + if (item >= ITEM_TM01) { - if (!CanMonLearnTMHM(mon, item - ITEM_TM01_FOCUS_PUNCH)) + if (!CanMonLearnTMHM(mon, item - ITEM_TM01)) return CANNOT_LEARN_MOVE; else move = ItemIdToBattleMoveId(item); @@ -4607,7 +4607,7 @@ void ItemUseCB_PPUp(u8 taskId, TaskFunc task) u16 ItemIdToBattleMoveId(u16 item) { - u16 tmNumber = item - ITEM_TM01_FOCUS_PUNCH; + u16 tmNumber = item - ITEM_TM01; return sTMHMMoves[tmNumber]; } diff --git a/src/player_pc.c b/src/player_pc.c index 928aac706..1f293a195 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -443,7 +443,7 @@ static void InitItemStorageMenu(u8 taskId, u8 var) windowTemplate.width = GetMaxWidthInMenuTable(gPCText_ItemPCOptionsText, 4); data[4] = AddWindow(&windowTemplate); SetStandardWindowBorderStyle(data[4], 0); - PrintMenuTable(data[4], 4, gPCText_ItemPCOptionsText); + PrintMenuTable(data[4], ARRAY_COUNT(gPCText_ItemPCOptionsText), gPCText_ItemPCOptionsText); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[4], 4, var); ScheduleBgCopyTilemapToVram(0); ItemStorageMenuPrint(gPCText_OptionDescList[var]); @@ -686,7 +686,7 @@ static void Mailbox_ReturnToPlayerPC(u8 taskId) static void Mailbox_PrintMailOptions(u8 taskId) { u8 r4 = sub_81D1C84(2); - PrintMenuTable(r4, 4, gMailboxMailOptions); + PrintMenuTable(r4, ARRAY_COUNT(gMailboxMailOptions), gMailboxMailOptions); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(r4, 4, 0); ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = Mailbox_MailOptionsProcessInput; @@ -1058,7 +1058,6 @@ static void ItemStorage_ProcessWithdrawTossInput(u8 taskId) s16 *data; bool32 toss; u32 i, x; - u8 windowId; const u8* text; data = gTasks[taskId].data; diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index e2202b59e..36471fb62 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -61,7 +61,6 @@ static void HandleInitWindows(void); static void LaunchPokeblockFeedTask(void); static void SetPokeblockSpritePal(u8 pokeblockCaseId); static void sub_817A5CC(void); -static void sub_8148108(u8 spriteId, bool8 a1); static void DoPokeblockCaseThrowEffect(u8 spriteId, bool8 arg1); static void PrepareMonToMoveToPokeblock(u8 spriteId); static void Task_HandleMonAtePokeblock(u8 taskId); diff --git a/src/pokedex.c b/src/pokedex.c index 32c495530..3cd93203e 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -1373,7 +1373,7 @@ static const struct SearchOptionText sDexSearchColorOptions[] = {}, }; -static const struct SearchOptionText sDexSearchTypeOptions[] = +static const struct SearchOptionText sDexSearchTypeOptions[NUMBER_OF_MON_TYPES + 1] = // + 2 for "None" and terminator, - 1 for Mystery { {gText_DexEmptyString, gText_DexSearchTypeNone}, {gText_DexEmptyString, gTypeNames[TYPE_NORMAL]}, @@ -1407,7 +1407,7 @@ static const u8 sOrderOptions[] = ORDER_SMALLEST, }; -static const u8 sDexSearchTypeIds[] = +static const u8 sDexSearchTypeIds[NUMBER_OF_MON_TYPES] = { TYPE_NONE, TYPE_NORMAL, @@ -1585,9 +1585,6 @@ static void ResetPokedexView(struct PokedexView *pokedexView) void CB2_OpenPokedex(void) { - u8 *addr; - u32 size; - switch (gMain.state) { case 0: @@ -3040,7 +3037,7 @@ static void SpriteCB_PokedexListMonSprite(struct Sprite *sprite) if (gSineTable[sprite->data[5] + 64] != 0) var = 0x10000 / gSineTable[sprite->data[5] + 64]; else - var = 0xFFFF; + var = 0; #else var = 0x10000 / gSineTable[sprite->data[5] + 64]; #endif //UBFIX diff --git a/src/pokedex_area_screen.c b/src/pokedex_area_screen.c index 7a3b38dc2..b63b00290 100755 --- a/src/pokedex_area_screen.c +++ b/src/pokedex_area_screen.c @@ -489,7 +489,6 @@ static bool8 MonListHasMon(const struct WildPokemonInfo *info, u16 species, u16 static void BuildAreaGlowTilemap(void) { u16 i, y, x, j; - u16 val; for (i = 0; i < ARRAY_COUNT(sPokedexAreaScreen->areaGlowTilemap); i++) sPokedexAreaScreen->areaGlowTilemap[i] = 0; diff --git a/src/pokemon.c b/src/pokemon.c index 1f6fc9832..ed4c69dc5 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3047,7 +3047,7 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, SetBoxMonData(boxMon, MON_DATA_POKEBALL, &value); SetBoxMonData(boxMon, MON_DATA_OT_GENDER, &gSaveBlock2Ptr->playerGender); - if (fixedIV < 32) + if (fixedIV < USE_RANDOM_IVS) { SetBoxMonData(boxMon, MON_DATA_HP_IV, &fixedIV); SetBoxMonData(boxMon, MON_DATA_ATK_IV, &fixedIV); @@ -3061,20 +3061,20 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, u32 iv; value = Random(); - iv = value & 0x1F; + iv = value & MAX_IV_MASK; SetBoxMonData(boxMon, MON_DATA_HP_IV, &iv); - iv = (value & 0x3E0) >> 5; + iv = (value & (MAX_IV_MASK << 5)) >> 5; SetBoxMonData(boxMon, MON_DATA_ATK_IV, &iv); - iv = (value & 0x7C00) >> 10; + iv = (value & (MAX_IV_MASK << 10)) >> 10; SetBoxMonData(boxMon, MON_DATA_DEF_IV, &iv); value = Random(); - iv = value & 0x1F; + iv = value & MAX_IV_MASK; SetBoxMonData(boxMon, MON_DATA_SPEED_IV, &iv); - iv = (value & 0x3E0) >> 5; + iv = (value & (MAX_IV_MASK << 5)) >> 5; SetBoxMonData(boxMon, MON_DATA_SPATK_IV, &iv); - iv = (value & 0x7C00) >> 10; + iv = (value & (MAX_IV_MASK << 10)) >> 10; SetBoxMonData(boxMon, MON_DATA_SPDEF_IV, &iv); } @@ -3104,14 +3104,14 @@ void CreateMonWithGenderNatureLetter(struct Pokemon *mon, u16 species, u8 level, { u32 personality; - if ((u8)(unownLetter - 1) < 28) + if ((u8)(unownLetter - 1) < NUM_UNOWN_FORMS) { u16 actualLetter; do { personality = Random32(); - actualLetter = ((((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 0x3)) % 28); + actualLetter = GET_UNOWN_LETTER(personality); } while (nature != GetNatureFromPersonality(personality) || gender != GetGenderFromSpeciesAndPersonality(species, personality) @@ -3142,7 +3142,7 @@ void CreateMaleMon(struct Pokemon *mon, u16 species, u8 level) personality = Random32(); } while (GetGenderFromSpeciesAndPersonality(species, personality) != MON_MALE); - CreateMon(mon, species, level, 32, 1, personality, OT_ID_PRESET, otId); + CreateMon(mon, species, level, USE_RANDOM_IVS, 1, personality, OT_ID_PRESET, otId); } void CreateMonWithIVsPersonality(struct Pokemon *mon, u16 species, u8 level, u32 ivs, u32 personality) @@ -3324,7 +3324,7 @@ void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 m CreateMon(mon, src->party[monId].species, GetFrontierEnemyMonLevel(src->lvlMode - 1), - 0x1F, + MAX_PER_STAT_IVS, TRUE, personality, OT_ID_PRESET, @@ -3484,8 +3484,8 @@ u16 GetUnionRoomTrainerPic(void) u8 linkId; u32 arrId; - if (gBattleTypeFlags & BATTLE_TYPE_x2000000) - linkId = gUnknown_0203C7B4 ^ 1; + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) + linkId = gRecordedBattleMultiplayerId ^ 1; else linkId = GetMultiplayerId() ^ 1; @@ -3499,8 +3499,8 @@ u16 GetUnionRoomTrainerClass(void) u8 linkId; u32 arrId; - if (gBattleTypeFlags & BATTLE_TYPE_x2000000) - linkId = gUnknown_0203C7B4 ^ 1; + if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK) + linkId = gRecordedBattleMultiplayerId ^ 1; else linkId = GetMultiplayerId() ^ 1; @@ -3516,7 +3516,7 @@ void CreateObedientEnemyMon(void) s32 itemId = gSpecialVar_0x8006; ZeroEnemyPartyMons(); - CreateObedientMon(&gEnemyParty[0], species, level, 32, 0, 0, 0, 0); + CreateObedientMon(&gEnemyParty[0], species, level, USE_RANDOM_IVS, 0, 0, 0, 0); if (itemId) { u8 heldItem[2]; @@ -3614,13 +3614,14 @@ void CalculateMonStats(struct Pokemon *mon) { if (currentHP == 0 && oldMaxHP == 0) currentHP = newMaxHP; - else if (currentHP != 0) + else if (currentHP != 0) { // BUG: currentHP is unintentionally able to become <= 0 after the instruction below. This causes the pomeg berry glitch. currentHP += newMaxHP - oldMaxHP; #ifdef BUGFIX if (currentHP <= 0) currentHP = 1; #endif + } else return; } @@ -4113,7 +4114,7 @@ u8 CountAliveMonsInBattle(u8 caseId) static bool8 ShouldGetStatBadgeBoost(u16 badgeFlag, u8 battlerId) { - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_x2000000 | BATTLE_TYPE_FRONTIER)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_FRONTIER)) return FALSE; else if (GetBattlerSide(battlerId) != B_SIDE_PLAYER) return FALSE; @@ -5062,12 +5063,12 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) case MON_DATA_IVS: { u32 ivs = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); - substruct3->hpIV = ivs & 0x1F; - substruct3->attackIV = (ivs >> 5) & 0x1F; - substruct3->defenseIV = (ivs >> 10) & 0x1F; - substruct3->speedIV = (ivs >> 15) & 0x1F; - substruct3->spAttackIV = (ivs >> 20) & 0x1F; - substruct3->spDefenseIV = (ivs >> 25) & 0x1F; + substruct3->hpIV = ivs & MAX_IV_MASK; + substruct3->attackIV = (ivs >> 5) & MAX_IV_MASK; + substruct3->defenseIV = (ivs >> 10) & MAX_IV_MASK; + substruct3->speedIV = (ivs >> 15) & MAX_IV_MASK; + substruct3->spAttackIV = (ivs >> 20) & MAX_IV_MASK; + substruct3->spDefenseIV = (ivs >> 25) & MAX_IV_MASK; break; } default: @@ -5406,7 +5407,6 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov u32 var_28 = 0; u16 heldItem; u8 r10; - u32 r4; u32 r5; s8 r2; u16 evCount; @@ -7112,7 +7112,7 @@ u16 GetBattleBGM(void) return MUS_VS_KYOGRE_GROUDON; else if (gBattleTypeFlags & BATTLE_TYPE_REGI) return MUS_VS_REGI; - else if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + else if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) return MUS_VS_TRAINER; else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) { @@ -7492,7 +7492,7 @@ static void Task_PokemonSummaryAnimateAfterDelay(u8 taskId) void BattleAnimateFrontSprite(struct Sprite* sprite, u16 species, bool8 noCry, u8 arg3) { - if (gHitMarker & HITMARKER_NO_ANIMATIONS && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))) + if (gHitMarker & HITMARKER_NO_ANIMATIONS && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK))) DoMonFrontSpriteAnimation(sprite, species, noCry, arg3 | 0x80); else DoMonFrontSpriteAnimation(sprite, species, noCry, arg3); @@ -7570,7 +7570,7 @@ void StopPokemonAnimationDelayTask(void) void BattleAnimateBackSprite(struct Sprite* sprite, u16 species) { - if (gHitMarker & HITMARKER_NO_ANIMATIONS && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))) + if (gHitMarker & HITMARKER_NO_ANIMATIONS && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK))) { sprite->callback = SpriteCallbackDummy; } diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c index 477cad135..2d1634ec8 100644 --- a/src/pokemon_animation.c +++ b/src/pokemon_animation.c @@ -6,6 +6,7 @@ #include "task.h" #include "trig.h" #include "util.h" +#include "data.h" #include "constants/battle_anim.h" #include "constants/rgb.h" diff --git a/src/pokemon_icon.c b/src/pokemon_icon.c index d3c75bb1b..9180dabf6 100644 --- a/src/pokemon_icon.c +++ b/src/pokemon_icon.c @@ -2604,7 +2604,7 @@ u16 GetUnownLetterByPersonality(u32 personality) if (!personality) return 0; else - return (((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 0x3)) % 0x1C; + return GET_UNOWN_LETTER(personality); } u16 sub_80D2E84(u16 species) diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index b619507a9..68fc391a4 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -8389,7 +8389,7 @@ static u8 sub_80D0894(void) static void sub_80D08CC(void) { - s32 i, j, r8, r9; + s32 i, j; s32 rowCount, columnCount; u8 boxId; u8 monArrayId; diff --git a/src/pokenav_conditions_3.c b/src/pokenav_conditions_3.c index d02d844d0..2a1dda1fa 100644 --- a/src/pokenav_conditions_3.c +++ b/src/pokenav_conditions_3.c @@ -419,7 +419,7 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state) switch (state) { case 0: - InitBgTemplates(sConditionSearchResultBgTemplates, NELEMS(sConditionSearchResultBgTemplates)); + InitBgTemplates(sConditionSearchResultBgTemplates, ARRAY_COUNT(sConditionSearchResultBgTemplates)); DecompressAndCopyTileDataToVram(1, sConditionSearchResultTiles, 0, 0, 0); SetBgTilemapBuffer(1, searchList->buff); CopyToBgTilemapBuffer(1, sConditionSearchResultTilemap, 0, 0); diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c index 009cf783f..21bddf1cd 100644 --- a/src/pokenav_main_menu.c +++ b/src/pokenav_main_menu.c @@ -496,7 +496,7 @@ void PokenavCopyPalette(const u16 *src, const u16 *dest, int size, int a3, int a g1 = ((((GET_G(*dest) << 8) - (g << 8)) / a3) * a4) >> 8; b1 = ((((GET_B(*dest) << 8) - (b << 8)) / a3) * a4) >> 8; - r = (r + r1) & 0x1F; //_RGB(r + r1, g + g1, b + b1); doesn't match; I have to assign the value of ((r + r1) & 0x1F) to r1 + r = (r + r1) & 0x1F; //_RGB(r + r1, g + g1, b + b1); doesn't match; I have to assign the value of ((r + r1) & 0x1F) to r g = (g + g1) & 0x1F; //See above b = (b + b1) & 0x1F; //See above diff --git a/src/pokenav_menu_handler_2.c b/src/pokenav_menu_handler_2.c index 3fcd41dc9..eea8131a9 100644 --- a/src/pokenav_menu_handler_2.c +++ b/src/pokenav_menu_handler_2.c @@ -750,7 +750,7 @@ static void LoadPokenavOptionPalettes(void) { s32 i; - for (i = 0; i < NELEMS(sPokenavOptionsSpriteSheets); i++) + for (i = 0; i < ARRAY_COUNT(sPokenavOptionsSpriteSheets); i++) LoadCompressedSpriteSheet(&sPokenavOptionsSpriteSheets[i]); Pokenav_AllocAndLoadPalettes(sPokenavOptionsSpritePalettes); } diff --git a/src/pokenav_ribbons_1.c b/src/pokenav_ribbons_1.c index 9c171dd45..397e1e749 100644 --- a/src/pokenav_ribbons_1.c +++ b/src/pokenav_ribbons_1.c @@ -427,7 +427,7 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state) switch (state) { case 0: - InitBgTemplates(sMonRibbonListBgTemplates, NELEMS(sMonRibbonListBgTemplates)); + InitBgTemplates(sMonRibbonListBgTemplates, ARRAY_COUNT(sMonRibbonListBgTemplates)); DecompressAndCopyTileDataToVram(1, sMonRibbonListFrameTiles, 0, 0, 0); SetBgTilemapBuffer(1, monMenu->buff); CopyToBgTilemapBuffer(1, sMonRibbonListFrameTilemap, 0, 0); diff --git a/src/record_mixing.c b/src/record_mixing.c index 898459c0a..2028cc647 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -94,7 +94,6 @@ static void *sApprenticesSave; static void *sBattleTowerSave_Duplicate; static u32 sRecordStructSize; static u8 gUnknown_03001160; -static u32 filler_03001164; static struct PlayerHallRecords *gUnknown_03001168[3]; static EWRAM_DATA struct RecordMixingDayCareMail gUnknown_02039F9C = {0}; diff --git a/src/recorded_battle.c b/src/recorded_battle.c index 881c2d3ec..6fcbe04f1 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -55,7 +55,7 @@ struct RecordedBattleSave u16 opponentA; u16 opponentB; u16 partnerId; - u16 field_4FA; + u16 multiplayerId; u8 lvlMode; u8 frontierFacility; u8 frontierBrainSymbol; @@ -83,7 +83,7 @@ EWRAM_DATA static u8 sLvlMode = 0; EWRAM_DATA static u8 sFrontierFacility = 0; EWRAM_DATA static u8 sFrontierBrainSymbol = 0; EWRAM_DATA static MainCallback sCallback2_AfterRecordedBattle = NULL; -EWRAM_DATA u8 gUnknown_0203C7B4 = 0; +EWRAM_DATA u8 gRecordedBattleMultiplayerId = 0; EWRAM_DATA static u8 sUnknown_0203C7B5 = 0; EWRAM_DATA static u8 sBattleScene = 0; EWRAM_DATA static u8 sTextSpeed = 0; @@ -154,7 +154,7 @@ void sub_8184E58(void) u8 linkPlayersCount; u8 text[30]; - gUnknown_0203C7B4 = GetMultiplayerId(); + gRecordedBattleMultiplayerId = GetMultiplayerId(); linkPlayersCount = GetLinkPlayerCount(); for (i = 0; i < MAX_BATTLERS_COUNT; i++) @@ -362,11 +362,14 @@ bool32 MoveRecordedBattleToSaveData(void) if (sBattleFlags & BATTLE_TYPE_LINK) { - battleSave->battleFlags = (sBattleFlags & ~(BATTLE_TYPE_LINK | BATTLE_TYPE_20)) | BATTLE_TYPE_x2000000; + battleSave->battleFlags = (sBattleFlags & ~(BATTLE_TYPE_LINK | BATTLE_TYPE_LINK_IN_BATTLE)) | BATTLE_TYPE_RECORDED_LINK; + // BATTLE_TYPE_RECORDED_IS_MASTER set indicates battle will play + // out from player's perspective (i.e. player with back to camera) + // Otherwise player will appear on "opponent" side if (sBattleFlags & BATTLE_TYPE_IS_MASTER) { - battleSave->battleFlags |= BATTLE_TYPE_x80000000; + battleSave->battleFlags |= BATTLE_TYPE_RECORDED_IS_MASTER; } else if (sBattleFlags & BATTLE_TYPE_MULTI) { @@ -374,13 +377,13 @@ bool32 MoveRecordedBattleToSaveData(void) { case 0: case 2: - if (!(sPlayers[gUnknown_0203C7B4].battlerId & 1)) - battleSave->battleFlags |= BATTLE_TYPE_x80000000; + if (!(sPlayers[gRecordedBattleMultiplayerId].battlerId & 1)) + battleSave->battleFlags |= BATTLE_TYPE_RECORDED_IS_MASTER; break; case 1: case 3: - if ((sPlayers[gUnknown_0203C7B4].battlerId & 1)) - battleSave->battleFlags |= BATTLE_TYPE_x80000000; + if ((sPlayers[gRecordedBattleMultiplayerId].battlerId & 1)) + battleSave->battleFlags |= BATTLE_TYPE_RECORDED_IS_MASTER; break; } } @@ -393,7 +396,7 @@ bool32 MoveRecordedBattleToSaveData(void) battleSave->opponentA = gTrainerBattleOpponent_A; battleSave->opponentB = gTrainerBattleOpponent_B; battleSave->partnerId = gPartnerTrainerId; - battleSave->field_4FA = gUnknown_0203C7B4; + battleSave->multiplayerId = gRecordedBattleMultiplayerId; battleSave->lvlMode = gSaveBlock2Ptr->frontier.lvlMode; battleSave->frontierFacility = sFrontierFacility; battleSave->frontierBrainSymbol = sFrontierBrainSymbol; @@ -573,7 +576,7 @@ static void SetVariablesForRecordedBattle(struct RecordedBattleSave *src) gTrainerBattleOpponent_A = src->opponentA; gTrainerBattleOpponent_B = src->opponentB; gPartnerTrainerId = src->partnerId; - gUnknown_0203C7B4 = src->field_4FA; + gRecordedBattleMultiplayerId = src->multiplayerId; sLvlMode = gSaveBlock2Ptr->frontier.lvlMode; sFrontierFacility = src->frontierFacility; sFrontierBrainSymbol = src->frontierBrainSymbol; @@ -715,7 +718,7 @@ void RecordedBattle_CopyBattlerMoves(void) if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT) return; - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) return; if (sUnknown_0203C7AC == 2) return; @@ -732,7 +735,7 @@ void sub_818603C(u8 arg0) { s32 battlerId, j, k; - if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK)) return; for (battlerId = 0; battlerId < gBattlersCount; battlerId++) diff --git a/src/region_map.c b/src/region_map.c index c2a5b4e9c..22b925a6f 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -1677,7 +1677,7 @@ void CB2_OpenFlyMap(void) break; case 1: ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(1, sFlyMapBgTemplates, 3); + InitBgsFromTemplates(1, sFlyMapBgTemplates, ARRAY_COUNT(sFlyMapBgTemplates)); gMain.state++; break; case 2: diff --git a/src/safari_zone.c b/src/safari_zone.c index e8827e124..3b86bc464 100644 --- a/src/safari_zone.c +++ b/src/safari_zone.c @@ -107,7 +107,7 @@ void CB2_EndSafariBattle(void) { ScriptContext2_RunNewScript(SafariZone_EventScript_OutOfBallsMidBattle); WarpIntoMap(); - gFieldCallback = sub_80AF6F0; + gFieldCallback = FieldCB_ReturnToFieldNoScriptCheckMusic; SetMainCallback2(CB2_LoadMap); } else if (gBattleOutcome == B_OUTCOME_CAUGHT) diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 9bf0e7ed4..50ceeb74e 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -62,7 +62,7 @@ static const struct OamData sClockOamData = .affineParam = 0 }; -static const struct BgTemplate gUnknown_085EFD88[3] = +static const struct BgTemplate sBgTemplates[3] = { { .bg = 0, @@ -212,7 +212,7 @@ static void CB2_SaveFailedScreen(void) LZ77UnCompVram(gBirchGrassTilemap, (void *)(BG_SCREEN_ADDR(15))); LZ77UnCompVram(sSaveFailedClockGfx, (void *)(VRAM + 0x10020)); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_085EFD88, 3); + InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates)); SetBgTilemapBuffer(0, (void *)&gDecompressionBuffer[0x2000]); CpuFill32(0, &gDecompressionBuffer[0x2000], 0x800); LoadBgTiles(0, gTextWindowFrame1_Gfx, 0x120, 0x214); diff --git a/src/scrcmd.c b/src/scrcmd.c index ef0b3f86b..f36a44187 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2235,7 +2235,9 @@ bool8 ScrCmd_gotoram(struct ScriptContext *ctx) return FALSE; } -bool8 ScrCmd_warpD1(struct ScriptContext *ctx) +// Unused +// For the warp used by the Aqua Hideout, see DoTeleportTileWarp +bool8 ScrCmd_warpspinenter(struct ScriptContext *ctx) { u8 mapGroup = ScriptReadByte(ctx); u8 mapNum = ScriptReadByte(ctx); @@ -2244,8 +2246,8 @@ bool8 ScrCmd_warpD1(struct ScriptContext *ctx) u16 y = VarGet(ScriptReadHalfword(ctx)); SetWarpDestination(mapGroup, mapNum, warpId, x, y); - sub_808D074(GetPlayerFacingDirection()); - sub_80B0244(); + SetSpinStartFacingDir(GetPlayerFacingDirection()); + DoSpinEnterWarp(); ResetInitialPlayerAvatarState(); return TRUE; } diff --git a/src/script.c b/src/script.c index 9ba1a7429..e6557aa75 100644 --- a/src/script.c +++ b/src/script.c @@ -11,9 +11,7 @@ extern const u8* gUnknown_020375C0; // ewram bss static u8 sScriptContext1Status; -static u32 sUnusedVariable1; static struct ScriptContext sScriptContext1; -static u32 sUnusedVariable2; static struct ScriptContext sScriptContext2; static bool8 sScriptContext2Enabled; diff --git a/src/script_pokemon_util.c b/src/script_pokemon_util.c index c9a2127ac..ad1a55230 100755 --- a/src/script_pokemon_util.c +++ b/src/script_pokemon_util.c @@ -66,7 +66,7 @@ u8 ScriptGiveMon(u16 species, u8 level, u16 item, u32 unused1, u32 unused2, u8 u u8 heldItem[2]; struct Pokemon mon; - CreateMon(&mon, species, level, 32, 0, 0, OT_ID_PLAYER_ID, 0); + CreateMon(&mon, species, level, USE_RANDOM_IVS, 0, 0, OT_ID_PLAYER_ID, 0); heldItem[0] = item; heldItem[1] = item >> 8; SetMonData(&mon, MON_DATA_HELD_ITEM, heldItem); @@ -139,7 +139,7 @@ void CreateScriptedWildMon(u16 species, u8 level, u16 item) u8 heldItem[2]; ZeroEnemyPartyMons(); - CreateMon(&gEnemyParty[0], species, level, 32, 0, 0, OT_ID_PLAYER_ID, 0); + CreateMon(&gEnemyParty[0], species, level, USE_RANDOM_IVS, 0, 0, OT_ID_PLAYER_ID, 0); if (item) { heldItem[0] = item; diff --git a/src/secret_base.c b/src/secret_base.c index 8e0929593..d49eef277 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -996,7 +996,7 @@ static void ShowRegistryMenuActions(u8 taskId) template.width = GetMaxWidthInMenuTable(sRegistryMenuActions, 2); data[7] = AddWindow(&template); SetStandardWindowBorderStyle(data[7], 0); - PrintMenuTable(data[7], 2, sRegistryMenuActions); + PrintMenuTable(data[7], ARRAY_COUNT(sRegistryMenuActions), sRegistryMenuActions); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[7], 2, 0); ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = HandleRegistryMenuActionsInput; diff --git a/src/shop.c b/src/shop.c index 44ab0885c..a447982fc 100755 --- a/src/shop.c +++ b/src/shop.c @@ -489,7 +489,6 @@ static void BuyMenuFreeMemory(void) static void BuyMenuBuildListMenuTemplate(void) { u16 i; - u16 itemCount; gUnknown_02039F74 = Alloc((gMartInfo.itemCount + 1) * sizeof(*gUnknown_02039F74)); gUnknown_02039F78 = Alloc((gMartInfo.itemCount + 1) * sizeof(*gUnknown_02039F78)); diff --git a/src/start_menu.c b/src/start_menu.c index 35eb53475..bfced1858 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -138,7 +138,7 @@ static bool8 FieldCB_ReturnToFieldStartMenu(void); static const struct WindowTemplate sSafariBallsWindowTemplate = {0, 1, 1, 9, 4, 0xF, 8}; -static const u8* const sPyramindFloorNames[] = +static const u8* const sPyramidFloorNames[] = { gText_Floor1, gText_Floor2, @@ -383,7 +383,7 @@ static void ShowPyramidFloorWindow(void) PutWindowTilemap(sBattlePyramidFloorWindowId); DrawStdWindowFrame(sBattlePyramidFloorWindowId, FALSE); - StringCopy(gStringVar1, sPyramindFloorNames[gSaveBlock2Ptr->frontier.curChallengeBattleNum]); + StringCopy(gStringVar1, sPyramidFloorNames[gSaveBlock2Ptr->frontier.curChallengeBattleNum]); StringExpandPlaceholders(gStringVar4, gText_BattlePyramidFloor); AddTextPrinterParameterized(sBattlePyramidFloorWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL); CopyWindowToVram(sBattlePyramidFloorWindowId, 2); diff --git a/src/starter_choose.c b/src/starter_choose.c index 771db961e..f7ffcfc2c 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -378,7 +378,6 @@ static void VblankCB_StarterChoose(void) void CB2_ChooseStarter(void) { - u16 savedIme; u8 taskId; u8 spriteId; diff --git a/src/task.c b/src/task.c index a97496009..3a3ddadfd 100644 --- a/src/task.c +++ b/src/task.c @@ -136,32 +136,20 @@ void TaskDummy(u8 taskId) { } -#define TASK_DATA_OP(taskId, offset, op) \ -{ \ - u32 tasksAddr = (u32)gTasks; \ - u32 addr = taskId * sizeof(struct Task) + offset; \ - u32 dataAddr = tasksAddr + offsetof(struct Task, data); \ - addr += dataAddr; \ - op; \ -} - void SetTaskFuncWithFollowupFunc(u8 taskId, TaskFunc func, TaskFunc followupFunc) { - TASK_DATA_OP(taskId, 28, *((u16 *)addr) = (u32)followupFunc) - TASK_DATA_OP(taskId, 30, *((u16 *)addr) = (u32)followupFunc >> 16) + u8 followupFuncIndex = NUM_TASK_DATA - 2; // Should be const. + + gTasks[taskId].data[followupFuncIndex] = (s16)((u32)followupFunc); + gTasks[taskId].data[followupFuncIndex + 1] = (s16)((u32)followupFunc >> 16); // Store followupFunc as two half-words in the data array. gTasks[taskId].func = func; } void SwitchTaskToFollowupFunc(u8 taskId) { - s32 func; + u8 followupFuncIndex = NUM_TASK_DATA - 2; // Should be const. - gTasks[taskId].func = NULL; - - TASK_DATA_OP(taskId, 28, func = *((u16 *)addr)) - TASK_DATA_OP(taskId, 30, func |= *((s16 *)addr) << 16) - - gTasks[taskId].func = (TaskFunc)func; + gTasks[taskId].func = (TaskFunc)((u16)(gTasks[taskId].data[followupFuncIndex]) | (gTasks[taskId].data[followupFuncIndex + 1] << 16)); } bool8 FuncIsActiveTask(TaskFunc func) @@ -183,7 +171,7 @@ u8 FindTaskIdByFunc(TaskFunc func) if (gTasks[i].isActive == TRUE && gTasks[i].func == func) return (u8)i; - return 0xFF; + return TAIL_SENTINEL; // No task was found. } u8 GetTaskCount(void) diff --git a/src/trade.c b/src/trade.c index 0013f912f..06ce47793 100644 --- a/src/trade.c +++ b/src/trade.c @@ -379,7 +379,7 @@ static void CB2_CreateTradeMenu(void) for (i = 0; i < PARTY_SIZE; i++) { - CreateMon(&gEnemyParty[i], SPECIES_NONE, 0, 32, FALSE, 0, OT_ID_PLAYER_ID, 0); + CreateMon(&gEnemyParty[i], SPECIES_NONE, 0, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); } PrintTradeMessage(TRADE_MSG_STANDBY); @@ -4429,7 +4429,7 @@ static void _CreateInGameTradePokemon(u8 whichPlayerMon, u8 whichInGameTrade) u8 isMail; struct Pokemon *pokemon = &gEnemyParty[0]; - CreateMon(pokemon, inGameTrade->species, level, 32, TRUE, inGameTrade->personality, OT_ID_PRESET, inGameTrade->otId); + CreateMon(pokemon, inGameTrade->species, level, USE_RANDOM_IVS, TRUE, inGameTrade->personality, OT_ID_PRESET, inGameTrade->otId); SetMonData(pokemon, MON_DATA_HP_IV, &inGameTrade->ivs[0]); SetMonData(pokemon, MON_DATA_ATK_IV, &inGameTrade->ivs[1]); diff --git a/src/tv.c b/src/tv.c index 748915c7a..effd3e4b2 100644 --- a/src/tv.c +++ b/src/tv.c @@ -2085,7 +2085,6 @@ static void sub_80EDE98(TVShow *show) u16 k; u8 n; u8 deco; - u8 x; for (i = 0; i < DECOR_MAX_SECRET_BASE; i ++) { @@ -2307,7 +2306,7 @@ void TryPutLotteryWinnerReportOnAir(void) } } -void sub_80EE35C(u16 foeSpecies, u16 species, u8 moveIdx, const u16 *movePtr, u16 betterMove) +void TryPutBattleSeminarOnAir(u16 foeSpecies, u16 species, u8 moveIdx, const u16 *movePtr, u16 betterMove) { TVShow *show; u8 i; @@ -4095,7 +4094,6 @@ static void sub_80F0E58(PokeNews *dest[16], PokeNews *src[16]) static bool8 sub_80F0E84(PokeNews *dest, PokeNews *src, s8 slot) { u8 i; - u8 kind; if (src->kind == POKENEWS_NONE) { @@ -6602,7 +6600,6 @@ static void DoTVShowSpotTheCuties(void) { TVShow *show; u8 state; - u32 playerId; show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004]; gSpecialVar_Result = FALSE; @@ -6707,7 +6704,6 @@ static void DoTVShowPokemonNewsBattleFrontier(void) { TVShow *show; u8 state; - u32 playerId; show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004]; gSpecialVar_Result = FALSE; @@ -6856,7 +6852,6 @@ static void DoTVShowWhatsNo1InHoennToday(void) { TVShow *show; u8 state; - u32 playerId; show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004]; gSpecialVar_Result = FALSE; diff --git a/tools/aif2pcm/main.c b/tools/aif2pcm/main.c index cd5ac4a50..3dad6fcf8 100644 --- a/tools/aif2pcm/main.c +++ b/tools/aif2pcm/main.c @@ -351,6 +351,12 @@ const int gDeltaEncodingTable[] = { -64, -49, -36, -25, -16, -9, -4, -1, }; +#define POSITIVE_DELTAS_START 0 +#define POSITIVE_DELTAS_END 8 + +#define NEGATIVE_DELTAS_START 8 +#define NEGATIVE_DELTAS_END 16 + struct Bytes *delta_decompress(struct Bytes *delta, unsigned int expected_length) { struct Bytes *pcm = malloc(sizeof(struct Bytes)); @@ -418,15 +424,32 @@ struct Bytes *delta_decompress(struct Bytes *delta, unsigned int expected_length return pcm; } +#define U8_TO_S8(value) ((value) < 128 ? (value) : (value) - 256) +#define ABS(value) ((value) >= 0 ? (value) : -(value)) + int get_delta_index(uint8_t sample, uint8_t prev_sample) { int best_error = INT_MAX; int best_index = -1; + int delta_table_start_index; + int delta_table_end_index; + int sample_signed = U8_TO_S8(sample); + int prev_sample_signed = U8_TO_S8(prev_sample); - for (int i = 0; i < 16; i++) + // if we're going up (or equal), only choose positive deltas + if (prev_sample_signed <= sample_signed) { + delta_table_start_index = POSITIVE_DELTAS_START; + delta_table_end_index = POSITIVE_DELTAS_END; + } else { + delta_table_start_index = NEGATIVE_DELTAS_START; + delta_table_end_index = NEGATIVE_DELTAS_END; + } + + for (int i = delta_table_start_index; i < delta_table_end_index; i++) { uint8_t new_sample = prev_sample + gDeltaEncodingTable[i]; - int error = sample > new_sample ? sample - new_sample : new_sample - sample; + int new_sample_signed = U8_TO_S8(new_sample); + int error = ABS(new_sample_signed - sample_signed); if (error < best_error) {