diff options
Diffstat (limited to 'src')
90 files changed, 10513 insertions, 9977 deletions
diff --git a/src/apprentice.c b/src/apprentice.c index 189647991..2c8959024 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -22,1052 +22,117 @@ #include "strings.h" #include "task.h" #include "text.h" -#include "constants/apprentice.h" +#include "constants/battle_frontier.h" +#include "constants/easy_chat.h" #include "constants/items.h" +#include "constants/pokemon.h" #include "constants/songs.h" #include "constants/species.h" +#include "constants/trainers.h" #include "constants/moves.h" +/* Summary of Apprentice, because (as of writing at least) its not very well documented online + * + * ## Basic info + * In the Battle Tower lobby there is an NPC which asks to be taught by the player + * They can be any 1 of 16 NPC trainers, each with their own name, class, and set of possible party species + * They ask the player a series of questions once per day, and eventually depart the lobby to be replaced by a new Apprentice + * + * ## Initial Questions + * The first question they always ask is a request to be taught, which cannot be rejected + * The second question (which follows immediately after) is whether they should participate in Battle Tower Lv 50 or Open Lv + * After these opening questions they always ask the player to choose between 2 mons, which they repeat 3 times + * + * ## Random Questions + * After choosing 3 mons for them, the Apprentice will randomly ask between 1 and 8 questions of 4 different types, as follows + * - Asking which mon to lead with, which they will only ask at most once + * - Asking which move a mon should use, which they will ask at most 5 times + * - Asking what held item to give to a mon, which they will ask at most 3 times (once for each mon) + * - Asking what they should say when they win a battle, which will always be their final question before departing + * + * ## After departing + * After telling them what they should say when they win a battle they will leave the lobby for a final time + * They will then be replaced by a new random Apprentice (they can repeat) + * Up to 4 old Apprentices are saved and can be encountered (or partnered with) during challenges of the mode they were told to battle in + * They can also be record mixed to and from other Emerald games + * Old/record mixed Apprentices are stored in struct Apprentice apprentices of SaveBlock2 + * and the current Apprentice is stored in struct PlayersApprentice playerApprentice of SaveBlock2 + */ + #define PLAYER_APPRENTICE gSaveBlock2Ptr->playerApprentice +#define CURRENT_QUESTION_NUM PLAYER_APPRENTICE.questionsAnswered - NUM_WHICH_MON_QUESTIONS -struct Unk030062ECStruct +struct ApprenticePartyMovesData { - u8 unk0; - u16 unk2[3][5]; - u8 unk20[3][5]; + u8 moveCounter; + u16 moves[MULTI_PARTY_SIZE][NUM_WHICH_MOVE_QUESTIONS]; + u8 moveSlots[MULTI_PARTY_SIZE][NUM_WHICH_MOVE_QUESTIONS]; }; -struct Unk030062F0Struct +struct ApprenticeQuestionData { - u16 unk0; - u16 unk2; - u16 unk4; - u16 unk6; + u16 speciesId; + u16 altSpeciesId; + u16 moveId1; + u16 moveId2; }; -// data/scripts/apprentice.inc -extern const u8 gText_082B7229[]; -extern const u8 gText_082B731C[]; -extern const u8 gText_082B735B[]; -extern const u8 gText_082B7423[]; -extern const u8 gText_082B74C1[]; -extern const u8 gText_082B756F[]; -extern const u8 gText_082B75B2[]; -extern const u8 gText_082B763F[]; -extern const u8 gText_082B76AC[]; -extern const u8 gText_082B7772[]; -extern const u8 gText_082B77CE[]; -extern const u8 gText_082B7871[]; -extern const u8 gText_082B78D4[]; -extern const u8 gText_082B7B1A[]; -extern const u8 gText_082B7C13[]; -extern const u8 gText_082B7D18[]; -extern const u8 gText_082B7DD4[]; -extern const u8 gText_082B7EE5[]; -extern const u8 gText_082B7F35[]; -extern const u8 gText_082B7FE8[]; -extern const u8 gText_082B8087[]; -extern const u8 gText_082B822B[]; -extern const u8 gText_082B8286[]; -extern const u8 gText_082B8356[]; -extern const u8 gText_082B83CE[]; -extern const u8 gText_082B84FC[]; -extern const u8 gText_082B8559[]; -extern const u8 gText_082B8656[]; -extern const u8 gText_082B86EA[]; -extern const u8 gText_082B87DA[]; -extern const u8 gText_082B887C[]; -extern const u8 gText_082B8957[]; -extern const u8 gText_082B89C6[]; -extern const u8 gText_082B8ACF[]; -extern const u8 gText_082B8B66[]; -extern const u8 gText_082B8C20[]; -extern const u8 gText_082B8CAA[]; -extern const u8 gText_082B8DD3[]; -extern const u8 gText_082B8E24[]; -extern const u8 gText_082B8ED5[]; -extern const u8 gText_082B8F45[]; -extern const u8 gText_082B905F[]; -extern const u8 gText_082B910E[]; -extern const u8 gText_082B9204[]; -extern const u8 gText_082B929C[]; -extern const u8 gText_082B9438[]; -extern const u8 gText_082B9488[]; -extern const u8 gText_082B9564[]; -extern const u8 gText_082B95D8[]; -extern const u8 gText_082B9763[]; -extern const u8 gText_082B97E5[]; -extern const u8 gText_082B989A[]; -extern const u8 gText_082B992D[]; -extern const u8 gText_082B9A84[]; -extern const u8 gText_082B9AB9[]; -extern const u8 gText_082B9B76[]; -extern const u8 gText_082B9BF2[]; -extern const u8 gText_082B9D83[]; -extern const u8 gText_082B9DF9[]; -extern const u8 gText_082B9EAA[]; -extern const u8 gText_082B9F55[]; -extern const u8 gText_082BA084[]; -extern const u8 gText_082BA11D[]; -extern const u8 gText_082BA1F3[]; - -extern const u8 gText_082BE50D[]; -extern const u8 gText_082BE5F5[]; -extern const u8 gText_082BE679[]; -extern const u8 gText_082BE71E[]; -extern const u8 gText_082BE762[]; -extern const u8 gText_082BE7F8[]; -extern const u8 gText_082BE850[]; -extern const u8 gText_082BE99C[]; -extern const u8 gText_082BEA1B[]; -extern const u8 gText_082BEAE9[]; -extern const u8 gText_082BEB72[]; -extern const u8 gText_082BEC8E[]; -extern const u8 gText_082BED16[]; -extern const u8 gText_082BEE29[]; -extern const u8 gText_082BEEB4[]; -extern const u8 gText_082BEFE2[]; -extern const u8 gText_082BF04E[]; -extern const u8 gText_082BF11D[]; -extern const u8 gText_082BF1A8[]; -extern const u8 gText_082BF268[]; -extern const u8 gText_082BF2D1[]; -extern const u8 gText_082BF3CF[]; -extern const u8 gText_082BF46A[]; -extern const u8 gText_082BF551[]; -extern const u8 gText_082BF5C3[]; -extern const u8 gText_082BF6E5[]; -extern const u8 gText_082BF773[]; -extern const u8 gText_082BF869[]; -extern const u8 gText_082BF8DD[]; -extern const u8 gText_082BF9BA[]; -extern const u8 gText_082BFA5A[]; -extern const u8 gText_082BFB4E[]; - -extern const u8 gText_082BA2A3[]; -extern const u8 gText_082BA34E[]; -extern const u8 gText_082BA380[]; -extern const u8 gText_082BA3D2[]; -extern const u8 gText_082BA448[]; -extern const u8 gText_082BA4D3[]; -extern const u8 gText_082BA58C[]; -extern const u8 gText_082BA5BF[]; -extern const u8 gText_082BA5F3[]; -extern const u8 gText_082BA635[]; -extern const u8 gText_082BA6E6[]; -extern const u8 gText_082BA742[]; -extern const u8 gText_082BA770[]; -extern const u8 gText_082BA78F[]; -extern const u8 gText_082BA7D8[]; -extern const u8 gText_082BA867[]; -extern const u8 gText_082BA96B[]; -extern const u8 gText_082BA9B7[]; -extern const u8 gText_082BAA1B[]; -extern const u8 gText_082BAA81[]; -extern const u8 gText_082BAB22[]; -extern const u8 gText_082BAC43[]; -extern const u8 gText_082BAC78[]; -extern const u8 gText_082BAD17[]; -extern const u8 gText_082BADB6[]; -extern const u8 gText_082BAE36[]; -extern const u8 gText_082BAF4E[]; -extern const u8 gText_082BAF8F[]; -extern const u8 gText_082BAFDB[]; -extern const u8 gText_082BB05F[]; -extern const u8 gText_082BB0D4[]; -extern const u8 gText_082BB18C[]; -extern const u8 gText_082BB1CE[]; -extern const u8 gText_082BB242[]; -extern const u8 gText_082BB2D9[]; -extern const u8 gText_082BB370[]; -extern const u8 gText_082BB4C3[]; -extern const u8 gText_082BB4FB[]; -extern const u8 gText_082BB575[]; -extern const u8 gText_082BB5E1[]; -extern const u8 gText_082BB656[]; -extern const u8 gText_082BB6E5[]; -extern const u8 gText_082BB72C[]; -extern const u8 gText_082BB7A2[]; -extern const u8 gText_082BB84A[]; -extern const u8 gText_082BB8CD[]; -extern const u8 gText_082BB970[]; -extern const u8 gText_082BB9AE[]; -extern const u8 gText_082BBA05[]; -extern const u8 gText_082BBA6C[]; -extern const u8 gText_082BBB01[]; -extern const u8 gText_082BBC1C[]; -extern const u8 gText_082BBC4B[]; -extern const u8 gText_082BBCF6[]; -extern const u8 gText_082BBD90[]; -extern const u8 gText_082BBE0B[]; -extern const u8 gText_082BBEE5[]; -extern const u8 gText_082BBF25[]; -extern const u8 gText_082BBFA4[]; -extern const u8 gText_082BC024[]; -extern const u8 gText_082BC0C8[]; -extern const u8 gText_082BC213[]; -extern const u8 gText_082BC247[]; -extern const u8 gText_082BC2DD[]; -extern const u8 gText_082BC373[]; -extern const u8 gText_082BC40E[]; -extern const u8 gText_082BC514[]; -extern const u8 gText_082BC555[]; -extern const u8 gText_082BC5CE[]; -extern const u8 gText_082BC666[]; -extern const u8 gText_082BC714[]; -extern const u8 gText_082BC808[]; -extern const u8 gText_082BC84D[]; -extern const u8 gText_082BC8EA[]; -extern const u8 gText_082BC984[]; -extern const u8 gText_082BCA4D[]; -extern const u8 gText_082BCB75[]; -extern const u8 gText_082BCBA6[]; -extern const u8 gText_082BCBFC[]; -extern const u8 gText_082BCCA4[]; - -extern const u8 gText_082BFBF2[]; -extern const u8 gText_082BFCAE[]; -extern const u8 gText_082BFD26[]; -extern const u8 gText_082BFDB1[]; -extern const u8 gText_082BFE24[]; -extern const u8 gText_082BFEAD[]; -extern const u8 gText_082BFF0A[]; -extern const u8 gText_082C0032[]; -extern const u8 gText_082C0090[]; -extern const u8 gText_082C016E[]; -extern const u8 gText_082C01F7[]; -extern const u8 gText_082C034C[]; -extern const u8 gText_082C03CA[]; -extern const u8 gText_082C046E[]; -extern const u8 gText_082C04F9[]; -extern const u8 gText_082C0598[]; -extern const u8 gText_082C0602[]; -extern const u8 gText_082C06D8[]; -extern const u8 gText_082C074A[]; -extern const u8 gText_082C0809[]; -extern const u8 gText_082C086E[]; -extern const u8 gText_082C0982[]; -extern const u8 gText_082C0A1D[]; -extern const u8 gText_082C0AFD[]; -extern const u8 gText_082C0B6F[]; -extern const u8 gText_082C0C7D[]; -extern const u8 gText_082C0D0B[]; -extern const u8 gText_082C0DFE[]; -extern const u8 gText_082C0E71[]; -extern const u8 gText_082C0F6D[]; -extern const u8 gText_082C1003[]; -extern const u8 gText_082C1122[]; - -extern const u8 gText_082BCD68[]; -extern const u8 gText_082BCE64[]; -extern const u8 gText_082BCEF2[]; -extern const u8 gText_082BCF61[]; -extern const u8 gText_082BCFA1[]; -extern const u8 gText_082BD03C[]; -extern const u8 gText_082BD06D[]; -extern const u8 gText_082BD18A[]; -extern const u8 gText_082BD222[]; -extern const u8 gText_082BD325[]; -extern const u8 gText_082BD3B1[]; -extern const u8 gText_082BD493[]; -extern const u8 gText_082BD51C[]; -extern const u8 gText_082BD609[]; -extern const u8 gText_082BD697[]; -extern const u8 gText_082BD797[]; -extern const u8 gText_082BD806[]; -extern const u8 gText_082BD8F5[]; -extern const u8 gText_082BD9BE[]; -extern const u8 gText_082BDAE1[]; -extern const u8 gText_082BDB4E[]; -extern const u8 gText_082BDC6B[]; -extern const u8 gText_082BDD0D[]; -extern const u8 gText_082BDDEC[]; -extern const u8 gText_082BDE68[]; -extern const u8 gText_082BDF4D[]; -extern const u8 gText_082BDFD8[]; -extern const u8 gText_082BE0FD[]; -extern const u8 gText_082BE189[]; -extern const u8 gText_082BE2A5[]; -extern const u8 gText_082BE33E[]; -extern const u8 gText_082BE46C[]; - -extern const u8 gText_082C11D1[]; -extern const u8 gText_082C12D5[]; -extern const u8 gText_082C13AB[]; -extern const u8 gText_082C1444[]; -extern const u8 gText_082C1501[]; -extern const u8 gText_082C15B6[]; -extern const u8 gText_082C165E[]; -extern const u8 gText_082C174F[]; -extern const u8 gText_082C1862[]; -extern const u8 gText_082C19A0[]; -extern const u8 gText_082C1A76[]; -extern const u8 gText_082C1C16[]; -extern const u8 gText_082C1CF5[]; -extern const u8 gText_082C1DC1[]; -extern const u8 gText_082C1EDC[]; -extern const u8 gText_082C1FEC[]; -extern const u8 gText_082C20D1[]; -extern const u8 gText_082C21FF[]; -extern const u8 gText_082C231C[]; -extern const u8 gText_082C2407[]; -extern const u8 gText_082C24B5[]; -extern const u8 gText_082C25B1[]; -extern const u8 gText_082C2707[]; -extern const u8 gText_082C27D4[]; -extern const u8 gText_082C28D6[]; -extern const u8 gText_082C2A0B[]; -extern const u8 gText_082C2B50[]; -extern const u8 gText_082C2C77[]; -extern const u8 gText_082C2D67[]; -extern const u8 gText_082C2E41[]; -extern const u8 gText_082C2EF5[]; -extern const u8 gText_082C3023[]; - -extern const u8 gText_082B6EA5[]; -extern const u8 gText_082B6EEC[]; -extern const u8 gText_082B6F16[]; -extern const u8 gText_082B6F4C[]; -extern const u8 gText_082B6F92[]; -extern const u8 gText_082B6FC9[]; -extern const u8 gText_082B700C[]; -extern const u8 gText_082B703A[]; -extern const u8 gText_082B706A[]; -extern const u8 gText_082B709C[]; -extern const u8 gText_082B70CC[]; -extern const u8 gText_082B710A[]; -extern const u8 gText_082B714D[]; -extern const u8 gText_082B7185[]; -extern const u8 gText_082B71C1[]; -extern const u8 gText_082B71F9[]; - // IWRAM common -struct Unk030062ECStruct *gUnknown_030062EC; -struct Unk030062F0Struct *gUnknown_030062F0; -void (*gUnknown_030062F4)(void); +struct ApprenticePartyMovesData *gApprenticePartyMovesData; +struct ApprenticeQuestionData *gApprenticeQuestionData; +void (*gApprenticeFunc)(void); // This file's functions. -static u16 sub_819FF98(u8 arg0); -static bool8 sub_81A0194(u8 arg0, u16 moveId); +static u16 GetRandomAlternateMove(u8 monId); +static bool8 TrySetMove(u8 monId, u16 moveId); static void CreateChooseAnswerTask(bool8 noBButton, u8 itemsCount, u8 windowId); static u8 CreateAndShowWindow(u8 left, u8 top, u8 width, u8 height); static void RemoveAndHideWindow(u8 windowId); static void ExecuteFuncAfterButtonPress(void (*func)(void)); -static void Script_IsPlayersApprenticeActive(void); -static void Script_SetPlayersApprenticeLvlMode(void); -static void sub_81A0978(void); -static void sub_819FC60(void); -static void sub_81A0984(void); -static void sub_81A0990(void); -static void sub_81A09D0(void); +static void Script_GivenApprenticeLvlMode(void); +static void Script_SetApprenticeLvlMode(void); +static void Script_SetApprenticeId(void); +static void ShuffleApprenticeSpecies(void); +static void Script_SetRandomQuestionData(void); +static void IncrementQuestionsAnswered(void); +static void IsFinalQuestion(void); static void Script_CreateApprenticeMenu(void); -static void Script_PrintMessage(void); +static void Script_PrintApprenticeMessage(void); static void Script_ResetPlayerApprentice(void); -static void sub_81A1638(void); -static void sub_81A0CC0(void); -static void sub_81A09B4(void); -static void sub_81A0D40(void); -static void sub_81A0DD4(void); -static void sub_81A0FE4(void); -static void sub_81A0FFC(void); -static void sub_81A0D80(void); -static void sub_81A11F8(void); -static void sub_81A1218(void); -static void sub_81A1224(void); -static void sub_81A1438(void); -static void sub_81A150C(void); -static void Script_SetPlayerApprenticeTrainerGfxId(void); -static void sub_81A1644(void); -static void sub_81A1370(void); - -// rodata - -const struct ApprenticeTrainer gApprentices[] = -{ - { - .name = {_("サダヒロ"), _("ALANN"), _("ALAIN"), _("ADELFO"), _("CLAUS"), _("TEO")}, - .otId = 0xBDC9, - .facilityClass = 0x43, - .species = {SPECIES_BEAUTIFLY, SPECIES_DUSTOX, SPECIES_ILLUMISE, SPECIES_SHIFTRY, SPECIES_BRELOOM, SPECIES_NINJASK, SPECIES_SHEDINJA, SPECIES_PINSIR, SPECIES_HERACROSS, SPECIES_VOLBEAT}, - .id = 0, - .easyChatWords = {0x81D, 0x143E, 0xC00, 0xA01, 0x630, 0x1444}, - }, - { - .name = {_("ヒロオ"), _("LIONEL"), _("LIONEL"), _("CAIO"), _("LUDWIG"), _("LEO")}, - .otId = 0xCF09, - .facilityClass = 0x2B, - .species = {SPECIES_SWELLOW, SPECIES_SWALOT, SPECIES_SHUCKLE, SPECIES_MANECTRIC, SPECIES_TORKOAL, SPECIES_HARIYAMA, SPECIES_MIGHTYENA, SPECIES_LUDICOLO, SPECIES_CRAWDAUNT, SPECIES_WHISCASH}, - .id = 1, - .easyChatWords = {0xC38, 0xA01, 0x630, 0xA06, 0x1020, 0x2213}, - }, - { - .name = {_("ケイジ"), _("SONNY"), _("HERVE"), _("FEDRO"), _("WENZEL"), _("SANTI")}, - .otId = 0x2E34, - .facilityClass = 0x26, - .species = {SPECIES_LINOONE, SPECIES_MIGHTYENA, SPECIES_WHISCASH, SPECIES_ZANGOOSE, SPECIES_SEVIPER, SPECIES_NINETALES, SPECIES_KECLEON, SPECIES_SHUCKLE, SPECIES_MANECTRIC, SPECIES_MACHAMP}, - .id = 2, - .easyChatWords = {0xA01, 0x160A, 0xE15, 0x630, 0xC3B, 0xC04}, - }, - { - .name = {_("ユラ"), _("LAYLA"), _("LAYLA"), _("ASTRID"), _("SONJA"), _("LOLA")}, - .otId = 0x84EF, - .facilityClass = 0x47, - .species = {SPECIES_SWALOT, SPECIES_XATU, SPECIES_ALTARIA, SPECIES_GOLDUCK, SPECIES_FLYGON, SPECIES_ALAKAZAM, SPECIES_GARDEVOIR, SPECIES_WAILORD, SPECIES_GRUMPIG, SPECIES_MIGHTYENA}, - .id = 3, - .easyChatWords = {0x100B, 0x1E0F, 0x1039, 0x1421, 0xC03, 0xFFFF}, - }, - { - .name = {_("ヨウカ"), _("MACY"), _("AMELIE"), _("CLEO"), _("MARIA"), _("ELISA")}, - .otId = 0x1E43, - .facilityClass = 0x27, - .species = {SPECIES_WIGGLYTUFF, SPECIES_LINOONE, SPECIES_KINGDRA, SPECIES_DELCATTY, SPECIES_RAICHU, SPECIES_FEAROW, SPECIES_STARMIE, SPECIES_MEDICHAM, SPECIES_SHIFTRY, SPECIES_BEAUTIFLY}, - .id = 4, - .easyChatWords = {0x1E0F, 0x1014, 0x1006, 0x280F, 0x1C1C, 0x1C13}, - }, - { - .name = {_("ヤスシ"), _("DONTE"), _("BRAHIM"), _("GLAUCO"), _("JOSEF"), _("ROQUE")}, - .otId = 0x379F, - .facilityClass = 0x30, - .species = {SPECIES_STARMIE, SPECIES_DODRIO, SPECIES_AGGRON, SPECIES_MAGNETON, SPECIES_MACHAMP, SPECIES_ARMALDO, SPECIES_HERACROSS, SPECIES_NOSEPASS, SPECIES_EXPLOUD, SPECIES_MIGHTYENA}, - .id = 5, - .easyChatWords = {0xA29, 0x1408, 0x102F, 0x1638, 0x820, 0xC00}, - }, - { - .name = {_("ミサオ"), _("AMIRA"), _("LAURE"), _("DAFNE"), _("AMELIE"), _("LARA")}, - .otId = 0xF555, - .facilityClass = 0x31, - .species = {SPECIES_STARMIE, SPECIES_DODRIO, SPECIES_MAGNETON, SPECIES_MEDICHAM, SPECIES_MIGHTYENA, SPECIES_GLALIE, SPECIES_GOLEM, SPECIES_ELECTRODE, SPECIES_PELIPPER, SPECIES_SHARPEDO}, - .id = 6, - .easyChatWords = {0xC0B, 0x123E, 0xC00, 0xA31, 0x1430, 0xC00}, - }, - { - .name = {_("カズサ"), _("KALI"), _("JODIE"), _("ILENIA"), _("KARO"), _("ELSA")}, - .otId = 0x8D26, - .facilityClass = 0x14, - .species = {SPECIES_NINETALES, SPECIES_ALAKAZAM, SPECIES_SCEPTILE, SPECIES_SALAMENCE, SPECIES_GOLDUCK, SPECIES_MAWILE, SPECIES_WEEZING, SPECIES_LANTURN, SPECIES_GARDEVOIR, SPECIES_MILOTIC}, - .id = 7, - .easyChatWords = {0xA06, 0x620, 0xA1F, 0xA02, 0xC03, 0xFFFF}, - }, - { - .name = {_("スミレ"), _("ANNIE"), _("ANNIE"), _("IMELDA"), _("INES"), _("ROSA")}, - .otId = 0x800C, - .facilityClass = 0xD, - .species = {SPECIES_SCEPTILE, SPECIES_VILEPLUME, SPECIES_BELLOSSOM, SPECIES_ROSELIA, SPECIES_CORSOLA, SPECIES_FLYGON, SPECIES_BRELOOM, SPECIES_MILOTIC, SPECIES_ALTARIA, SPECIES_CRADILY}, - .id = 8, - .easyChatWords = {0x1E22, 0x433, 0x20E, 0xA02, 0x101E, 0xC00}, - }, - { - .name = {_("アキノリ"), _("DILLEN"), _("RENE"), _("INDRO"), _("DETLEF"), _("PEDRO")}, - .otId = 0x469f, - .facilityClass = 0, - .species = {SPECIES_SKARMORY, SPECIES_GOLEM, SPECIES_BLAZIKEN, SPECIES_CAMERUPT, SPECIES_DONPHAN, SPECIES_MUK, SPECIES_SALAMENCE, SPECIES_TROPIUS, SPECIES_SOLROCK, SPECIES_RHYDON}, - .id = 9, - .easyChatWords = {0xA3D, 0x1011, 0xE1E, 0x201C, 0xC04, 0xFFFF}, - }, - { - .name = {_("トウゾウ"), _("DALLAS"), _("BRUNO"), _("LEARCO"), _("ANSGAR"), _("MANOLO")}, - .otId = 0x71FC, - .facilityClass = 0x2D, - .species = {SPECIES_SEAKING, SPECIES_STARMIE, SPECIES_GOLDUCK, SPECIES_TENTACRUEL, SPECIES_OCTILLERY, SPECIES_GOREBYSS, SPECIES_GLALIE, SPECIES_WAILORD, SPECIES_SHARPEDO, SPECIES_KINGDRA}, - .id = 10, - .easyChatWords = {0xA05, 0x606, 0x160E, 0xA14, 0xC00, 0xFFFF}, - }, - { - .name = {_("セイヤ"), _("FRANK"), _("FRANK"), _("OLINDO"), _("FRANK"), _("MAURO")}, - .otId = 0xA39E, - .facilityClass = 0x3A, - .species = {SPECIES_QUAGSIRE, SPECIES_STARMIE, SPECIES_PELIPPER, SPECIES_CRAWDAUNT, SPECIES_WAILORD, SPECIES_GYARADOS, SPECIES_SWAMPERT, SPECIES_LANTURN, SPECIES_WHISCASH, SPECIES_SHUCKLE}, - .id = 11, - .easyChatWords = {0x280E, 0x103D, 0x240F, 0xA14, 0x1E23, 0x1024}, - }, - { - .name = {_("リュウジ"), _("LAMONT"), _("XAV"), _("ORFEO"), _("JÜRGEN"), _("JORGE")}, - .otId = 0xE590, - .facilityClass = 0x19, - .species = {SPECIES_ABSOL, SPECIES_CROBAT, SPECIES_EXPLOUD, SPECIES_MAGNETON, SPECIES_SHARPEDO, SPECIES_MANECTRIC, SPECIES_METAGROSS, SPECIES_ELECTRODE, SPECIES_NOSEPASS, SPECIES_WEEZING}, - .id = 12, - .easyChatWords = {0x1020, 0x62E, 0x100B, 0x1E22, 0x1E0F, 0x100B}, - }, - { - .name = {_("カツアキ"), _("TYRESE"), _("ANDY"), _("PARIDE"), _("DAVID"), _("CHICHO")}, - .otId = 0xD018, - .facilityClass = 10, - .species = {SPECIES_BLAZIKEN, SPECIES_GOLEM, SPECIES_MACHAMP, SPECIES_RHYDON, SPECIES_HARIYAMA, SPECIES_AGGRON, SPECIES_MEDICHAM, SPECIES_ZANGOOSE, SPECIES_VIGOROTH, SPECIES_SLAKING}, - .id = 13, - .easyChatWords = {0xA29, 0x63A, 0xE15, 0x1435, 0x1034, 0x61E}, - }, - { - .name = {_("トシミツ"), _("DANTE"), _("DANTE"), _("RAOUL"), _("LOTHAR"), _("PABLO")}, - .otId = 0xBC75, - .facilityClass = 14, - .species = {SPECIES_SCEPTILE, SPECIES_SANDSLASH, SPECIES_FLYGON, SPECIES_CLAYDOL, SPECIES_ARMALDO, SPECIES_CROBAT, SPECIES_CRADILY, SPECIES_SOLROCK, SPECIES_LUNATONE, SPECIES_GOLEM}, - .id = 14, - .easyChatWords = {0xA01, 0x1017, 0x1243, 0x1E22, 0x100B, 0x280F}, - }, - { - .name = {_("ローウェン"), _("ARTURO"), _("ARTURO"), _("ROMOLO"), _("BRIAN"), _("ARTURO")}, - .otId = 0xFA02, - .facilityClass = 0x20, - .species = {SPECIES_ABSOL, SPECIES_MIGHTYENA, SPECIES_ALAKAZAM, SPECIES_BANETTE, SPECIES_NINETALES, SPECIES_CLAYDOL, SPECIES_MUK, SPECIES_SALAMENCE, SPECIES_WALREIN, SPECIES_DUSCLOPS}, - .id = 15, - .easyChatWords = {0x1E0F, 0x1404, 0x102F, 0x1006, 0x1020, 0xE03}, - }, -}; - -static const u8 *const gUnknown_08610EF0[][4] = -{ - {gText_082B7229, gText_082B731C, gText_082B735B, gText_082B7423}, - {gText_082B74C1, gText_082B756F, gText_082B75B2, gText_082B763F}, - {gText_082B76AC, gText_082B7772, gText_082B77CE, gText_082B7871}, - {gText_082B78D4, gText_082B7B1A, gText_082B7C13, gText_082B7D18}, - {gText_082B7DD4, gText_082B7EE5, gText_082B7F35, gText_082B7FE8}, - {gText_082B8087, gText_082B822B, gText_082B8286, gText_082B8356}, - {gText_082B83CE, gText_082B84FC, gText_082B8559, gText_082B8656}, - {gText_082B86EA, gText_082B87DA, gText_082B887C, gText_082B8957}, - {gText_082B89C6, gText_082B8ACF, gText_082B8B66, gText_082B8C20}, - {gText_082B8CAA, gText_082B8DD3, gText_082B8E24, gText_082B8ED5}, - {gText_082B8F45, gText_082B905F, gText_082B910E, gText_082B9204}, - {gText_082B929C, gText_082B9438, gText_082B9488, gText_082B9564}, - {gText_082B95D8, gText_082B9763, gText_082B97E5, gText_082B989A}, - {gText_082B992D, gText_082B9A84, gText_082B9AB9, gText_082B9B76}, - {gText_082B9BF2, gText_082B9D83, gText_082B9DF9, gText_082B9EAA}, - {gText_082B9F55, gText_082BA084, gText_082BA11D, gText_082BA1F3}, -}; - -static const u8 *const gUnknown_08610FF0[][2] = -{ - {gText_082BE50D, gText_082BE5F5}, - {gText_082BE679, gText_082BE71E}, - {gText_082BE762, gText_082BE7F8}, - {gText_082BE850, gText_082BE99C}, - {gText_082BEA1B, gText_082BEAE9}, - {gText_082BEB72, gText_082BEC8E}, - {gText_082BED16, gText_082BEE29}, - {gText_082BEEB4, gText_082BEFE2}, - {gText_082BF04E, gText_082BF11D}, - {gText_082BF1A8, gText_082BF268}, - {gText_082BF2D1, gText_082BF3CF}, - {gText_082BF46A, gText_082BF551}, - {gText_082BF5C3, gText_082BF6E5}, - {gText_082BF773, gText_082BF869}, - {gText_082BF8DD, gText_082BF9BA}, - {gText_082BFA5A, gText_082BFB4E}, -}; - -static const u8 *const gUnknown_08611070[][5] = -{ - {gText_082BA2A3, gText_082BA34E, gText_082BA380, gText_082BA3D2, gText_082BA448}, - {gText_082BA4D3, gText_082BA58C, gText_082BA5BF, gText_082BA5F3, gText_082BA635}, - {gText_082BA6E6, gText_082BA742, gText_082BA770, gText_082BA78F, gText_082BA7D8}, - {gText_082BA867, gText_082BA96B, gText_082BA9B7, gText_082BAA1B, gText_082BAA81}, - {gText_082BAB22, gText_082BAC43, gText_082BAC78, gText_082BAD17, gText_082BADB6}, - {gText_082BAE36, gText_082BAF4E, gText_082BAF8F, gText_082BAFDB, gText_082BB05F}, - {gText_082BB0D4, gText_082BB18C, gText_082BB1CE, gText_082BB242, gText_082BB2D9}, - {gText_082BB370, gText_082BB4C3, gText_082BB4FB, gText_082BB575, gText_082BB5E1}, - {gText_082BB656, gText_082BB6E5, gText_082BB72C, gText_082BB7A2, gText_082BB84A}, - {gText_082BB8CD, gText_082BB970, gText_082BB9AE, gText_082BBA05, gText_082BBA6C}, - {gText_082BBB01, gText_082BBC1C, gText_082BBC4B, gText_082BBCF6, gText_082BBD90}, - {gText_082BBE0B, gText_082BBEE5, gText_082BBF25, gText_082BBFA4, gText_082BC024}, - {gText_082BC0C8, gText_082BC213, gText_082BC247, gText_082BC2DD, gText_082BC373}, - {gText_082BC40E, gText_082BC514, gText_082BC555, gText_082BC5CE, gText_082BC666}, - {gText_082BC714, gText_082BC808, gText_082BC84D, gText_082BC8EA, gText_082BC984}, - {gText_082BCA4D, gText_082BCB75, gText_082BCBA6, gText_082BCBFC, gText_082BCCA4}, -}; - -static const u8 *const gUnknown_086111B0[][2] = -{ - {gText_082BFBF2, gText_082BFCAE}, - {gText_082BFD26, gText_082BFDB1}, - {gText_082BFE24, gText_082BFEAD}, - {gText_082BFF0A, gText_082C0032}, - {gText_082C0090, gText_082C016E}, - {gText_082C01F7, gText_082C034C}, - {gText_082C03CA, gText_082C046E}, - {gText_082C04F9, gText_082C0598}, - {gText_082C0602, gText_082C06D8}, - {gText_082C074A, gText_082C0809}, - {gText_082C086E, gText_082C0982}, - {gText_082C0A1D, gText_082C0AFD}, - {gText_082C0B6F, gText_082C0C7D}, - {gText_082C0D0B, gText_082C0DFE}, - {gText_082C0E71, gText_082C0F6D}, - {gText_082C1003, gText_082C1122}, -}; - -static const u8 *const gUnknown_08611230[][2] = -{ - {gText_082BCD68, gText_082BCE64}, - {gText_082BCEF2, gText_082BCF61}, - {gText_082BCFA1, gText_082BD03C}, - {gText_082BD06D, gText_082BD18A}, - {gText_082BD222, gText_082BD325}, - {gText_082BD3B1, gText_082BD493}, - {gText_082BD51C, gText_082BD609}, - {gText_082BD697, gText_082BD797}, - {gText_082BD806, gText_082BD8F5}, - {gText_082BD9BE, gText_082BDAE1}, - {gText_082BDB4E, gText_082BDC6B}, - {gText_082BDD0D, gText_082BDDEC}, - {gText_082BDE68, gText_082BDF4D}, - {gText_082BDFD8, gText_082BE0FD}, - {gText_082BE189, gText_082BE2A5}, - {gText_082BE33E, gText_082BE46C}, -}; - -static const u8 *const gUnknown_086112B0[][2] = -{ - {gText_082C11D1, gText_082C12D5}, - {gText_082C13AB, gText_082C1444}, - {gText_082C1501, gText_082C15B6}, - {gText_082C165E, gText_082C174F}, - {gText_082C1862, gText_082C19A0}, - {gText_082C1A76, gText_082C1C16}, - {gText_082C1CF5, gText_082C1DC1}, - {gText_082C1EDC, gText_082C1FEC}, - {gText_082C20D1, gText_082C21FF}, - {gText_082C231C, gText_082C2407}, - {gText_082C24B5, gText_082C25B1}, - {gText_082C2707, gText_082C27D4}, - {gText_082C28D6, gText_082C2A0B}, - {gText_082C2B50, gText_082C2C77}, - {gText_082C2D67, gText_082C2E41}, - {gText_082C2EF5, gText_082C3023}, -}; - -static const u8 *const gUnknown_08611330[] = -{ - gText_082B6EA5, - gText_082B6EEC, - gText_082B6F16, - gText_082B6F4C, - gText_082B6F92, - gText_082B6FC9, - gText_082B700C, - gText_082B703A, - gText_082B706A, - gText_082B709C, - gText_082B70CC, - gText_082B710A, - gText_082B714D, - gText_082B7185, - gText_082B71C1, - gText_082B71F9, -}; - -static const bool8 gUnknown_08611370[MOVES_COUNT] = -{ - [MOVE_NONE] = FALSE, - [MOVE_POUND] = FALSE, - [MOVE_KARATE_CHOP] = TRUE, - [MOVE_DOUBLE_SLAP] = TRUE, - [MOVE_COMET_PUNCH] = FALSE, - [MOVE_MEGA_PUNCH] = TRUE, - [MOVE_PAY_DAY] = FALSE, - [MOVE_FIRE_PUNCH] = TRUE, - [MOVE_ICE_PUNCH] = TRUE, - [MOVE_THUNDER_PUNCH] = TRUE, - [MOVE_SCRATCH] = FALSE, - [MOVE_VICE_GRIP] = FALSE, - [MOVE_GUILLOTINE] = TRUE, - [MOVE_RAZOR_WIND] = FALSE, - [MOVE_SWORDS_DANCE] = TRUE, - [MOVE_CUT] = FALSE, - [MOVE_GUST] = FALSE, - [MOVE_WING_ATTACK] = FALSE, - [MOVE_WHIRLWIND] = TRUE, - [MOVE_FLY] = TRUE, - [MOVE_BIND] = TRUE, - [MOVE_SLAM] = TRUE, - [MOVE_VINE_WHIP] = FALSE, - [MOVE_STOMP] = TRUE, - [MOVE_DOUBLE_KICK] = TRUE, - [MOVE_MEGA_KICK] = TRUE, - [MOVE_JUMP_KICK] = TRUE, - [MOVE_ROLLING_KICK] = TRUE, - [MOVE_SAND_ATTACK] = TRUE, - [MOVE_HEADBUTT] = TRUE, - [MOVE_HORN_ATTACK] = FALSE, - [MOVE_FURY_ATTACK] = FALSE, - [MOVE_HORN_DRILL] = TRUE, - [MOVE_TACKLE] = FALSE, - [MOVE_BODY_SLAM] = TRUE, - [MOVE_WRAP] = TRUE, - [MOVE_TAKE_DOWN] = TRUE, - [MOVE_THRASH] = TRUE, - [MOVE_DOUBLE_EDGE] = TRUE, - [MOVE_TAIL_WHIP] = FALSE, - [MOVE_POISON_STING] = FALSE, - [MOVE_TWINEEDLE] = TRUE, - [MOVE_PIN_MISSILE] = FALSE, - [MOVE_LEER] = FALSE, - [MOVE_BITE] = TRUE, - [MOVE_GROWL] = FALSE, - [MOVE_ROAR] = TRUE, - [MOVE_SING] = TRUE, - [MOVE_SUPERSONIC] = TRUE, - [MOVE_SONIC_BOOM] = TRUE, - [MOVE_DISABLE] = TRUE, - [MOVE_ACID] = FALSE, - [MOVE_EMBER] = FALSE, - [MOVE_FLAMETHROWER] = TRUE, - [MOVE_MIST] = TRUE, - [MOVE_WATER_GUN] = FALSE, - [MOVE_HYDRO_PUMP] = TRUE, - [MOVE_SURF] = TRUE, - [MOVE_ICE_BEAM] = TRUE, - [MOVE_BLIZZARD] = TRUE, - [MOVE_PSYBEAM] = TRUE, - [MOVE_BUBBLE_BEAM] = FALSE, - [MOVE_AURORA_BEAM] = FALSE, - [MOVE_HYPER_BEAM] = TRUE, - [MOVE_PECK] = FALSE, - [MOVE_DRILL_PECK] = TRUE, - [MOVE_SUBMISSION] = TRUE, - [MOVE_LOW_KICK] = TRUE, - [MOVE_COUNTER] = TRUE, - [MOVE_SEISMIC_TOSS] = TRUE, - [MOVE_STRENGTH] = TRUE, - [MOVE_ABSORB] = FALSE, - [MOVE_MEGA_DRAIN] = FALSE, - [MOVE_LEECH_SEED] = TRUE, - [MOVE_GROWTH] = TRUE, - [MOVE_RAZOR_LEAF] = TRUE, - [MOVE_SOLAR_BEAM] = TRUE, - [MOVE_POISON_POWDER] = TRUE, - [MOVE_STUN_SPORE] = TRUE, - [MOVE_SLEEP_POWDER] = TRUE, - [MOVE_PETAL_DANCE] = TRUE, - [MOVE_STRING_SHOT] = FALSE, - [MOVE_DRAGON_RAGE] = TRUE, - [MOVE_FIRE_SPIN] = TRUE, - [MOVE_THUNDER_SHOCK] = FALSE, - [MOVE_THUNDERBOLT] = TRUE, - [MOVE_THUNDER_WAVE] = TRUE, - [MOVE_THUNDER] = TRUE, - [MOVE_ROCK_THROW] = FALSE, - [MOVE_EARTHQUAKE] = TRUE, - [MOVE_FISSURE] = TRUE, - [MOVE_DIG] = TRUE, - [MOVE_TOXIC] = TRUE, - [MOVE_CONFUSION] = FALSE, - [MOVE_PSYCHIC] = TRUE, - [MOVE_HYPNOSIS] = TRUE, - [MOVE_MEDITATE] = TRUE, - [MOVE_AGILITY] = TRUE, - [MOVE_QUICK_ATTACK] = TRUE, - [MOVE_RAGE] = FALSE, - [MOVE_TELEPORT] = FALSE, - [MOVE_NIGHT_SHADE] = TRUE, - [MOVE_MIMIC] = TRUE, - [MOVE_SCREECH] = TRUE, - [MOVE_DOUBLE_TEAM] = TRUE, - [MOVE_RECOVER] = TRUE, - [MOVE_HARDEN] = TRUE, - [MOVE_MINIMIZE] = TRUE, - [MOVE_SMOKESCREEN] = TRUE, - [MOVE_CONFUSE_RAY] = TRUE, - [MOVE_WITHDRAW] = TRUE, - [MOVE_DEFENSE_CURL] = TRUE, - [MOVE_BARRIER] = TRUE, - [MOVE_LIGHT_SCREEN] = TRUE, - [MOVE_HAZE] = TRUE, - [MOVE_REFLECT] = TRUE, - [MOVE_FOCUS_ENERGY] = TRUE, - [MOVE_BIDE] = FALSE, - [MOVE_METRONOME] = TRUE, - [MOVE_MIRROR_MOVE] = TRUE, - [MOVE_SELF_DESTRUCT] = TRUE, - [MOVE_EGG_BOMB] = TRUE, - [MOVE_LICK] = TRUE, - [MOVE_SMOG] = FALSE, - [MOVE_SLUDGE] = FALSE, - [MOVE_BONE_CLUB] = FALSE, - [MOVE_FIRE_BLAST] = TRUE, - [MOVE_WATERFALL] = TRUE, - [MOVE_CLAMP] = TRUE, - [MOVE_SWIFT] = TRUE, - [MOVE_SKULL_BASH] = TRUE, - [MOVE_SPIKE_CANNON] = FALSE, - [MOVE_CONSTRICT] = FALSE, - [MOVE_AMNESIA] = TRUE, - [MOVE_KINESIS] = TRUE, - [MOVE_SOFT_BOILED] = TRUE, - [MOVE_HI_JUMP_KICK] = TRUE, - [MOVE_GLARE] = TRUE, - [MOVE_DREAM_EATER] = TRUE, - [MOVE_POISON_GAS] = FALSE, - [MOVE_BARRAGE] = FALSE, - [MOVE_LEECH_LIFE] = FALSE, - [MOVE_LOVELY_KISS] = TRUE, - [MOVE_SKY_ATTACK] = TRUE, - [MOVE_TRANSFORM] = TRUE, - [MOVE_BUBBLE] = FALSE, - [MOVE_DIZZY_PUNCH] = TRUE, - [MOVE_SPORE] = TRUE, - [MOVE_FLASH] = TRUE, - [MOVE_PSYWAVE] = TRUE, - [MOVE_SPLASH] = FALSE, - [MOVE_ACID_ARMOR] = TRUE, - [MOVE_CRABHAMMER] = TRUE, - [MOVE_EXPLOSION] = TRUE, - [MOVE_FURY_SWIPES] = FALSE, - [MOVE_BONEMERANG] = TRUE, - [MOVE_REST] = TRUE, - [MOVE_ROCK_SLIDE] = TRUE, - [MOVE_HYPER_FANG] = TRUE, - [MOVE_SHARPEN] = TRUE, - [MOVE_CONVERSION] = TRUE, - [MOVE_TRI_ATTACK] = TRUE, - [MOVE_SUPER_FANG] = TRUE, - [MOVE_SLASH] = TRUE, - [MOVE_SUBSTITUTE] = TRUE, - [MOVE_STRUGGLE] = TRUE, - [MOVE_SKETCH] = TRUE, - [MOVE_TRIPLE_KICK] = TRUE, - [MOVE_THIEF] = TRUE, - [MOVE_SPIDER_WEB] = TRUE, - [MOVE_MIND_READER] = TRUE, - [MOVE_NIGHTMARE] = TRUE, - [MOVE_FLAME_WHEEL] = FALSE, - [MOVE_SNORE] = TRUE, - [MOVE_CURSE] = TRUE, - [MOVE_FLAIL] = TRUE, - [MOVE_CONVERSION_2] = TRUE, - [MOVE_AEROBLAST] = TRUE, - [MOVE_COTTON_SPORE] = TRUE, - [MOVE_REVERSAL] = TRUE, - [MOVE_SPITE] = TRUE, - [MOVE_POWDER_SNOW] = FALSE, - [MOVE_PROTECT] = TRUE, - [MOVE_MACH_PUNCH] = TRUE, - [MOVE_SCARY_FACE] = TRUE, - [MOVE_FAINT_ATTACK] = TRUE, - [MOVE_SWEET_KISS] = TRUE, - [MOVE_BELLY_DRUM] = TRUE, - [MOVE_SLUDGE_BOMB] = TRUE, - [MOVE_MUD_SLAP] = TRUE, - [MOVE_OCTAZOOKA] = TRUE, - [MOVE_SPIKES] = TRUE, - [MOVE_ZAP_CANNON] = TRUE, - [MOVE_FORESIGHT] = TRUE, - [MOVE_DESTINY_BOND] = TRUE, - [MOVE_PERISH_SONG] = TRUE, - [MOVE_ICY_WIND] = TRUE, - [MOVE_DETECT] = TRUE, - [MOVE_BONE_RUSH] = FALSE, - [MOVE_LOCK_ON] = TRUE, - [MOVE_OUTRAGE] = TRUE, - [MOVE_SANDSTORM] = TRUE, - [MOVE_GIGA_DRAIN] = TRUE, - [MOVE_ENDURE] = TRUE, - [MOVE_CHARM] = TRUE, - [MOVE_ROLLOUT] = TRUE, - [MOVE_FALSE_SWIPE] = TRUE, - [MOVE_SWAGGER] = TRUE, - [MOVE_MILK_DRINK] = TRUE, - [MOVE_SPARK] = FALSE, - [MOVE_FURY_CUTTER] = TRUE, - [MOVE_STEEL_WING] = TRUE, - [MOVE_MEAN_LOOK] = TRUE, - [MOVE_ATTRACT] = TRUE, - [MOVE_SLEEP_TALK] = TRUE, - [MOVE_HEAL_BELL] = TRUE, - [MOVE_RETURN] = TRUE, - [MOVE_PRESENT] = TRUE, - [MOVE_FRUSTRATION] = TRUE, - [MOVE_SAFEGUARD] = TRUE, - [MOVE_PAIN_SPLIT] = TRUE, - [MOVE_SACRED_FIRE] = TRUE, - [MOVE_MAGNITUDE] = FALSE, - [MOVE_DYNAMIC_PUNCH] = TRUE, - [MOVE_MEGAHORN] = TRUE, - [MOVE_DRAGON_BREATH] = TRUE, - [MOVE_BATON_PASS] = TRUE, - [MOVE_ENCORE] = TRUE, - [MOVE_PURSUIT] = TRUE, - [MOVE_RAPID_SPIN] = TRUE, - [MOVE_SWEET_SCENT] = TRUE, - [MOVE_IRON_TAIL] = TRUE, - [MOVE_METAL_CLAW] = TRUE, - [MOVE_VITAL_THROW] = TRUE, - [MOVE_MORNING_SUN] = TRUE, - [MOVE_SYNTHESIS] = TRUE, - [MOVE_MOONLIGHT] = TRUE, - [MOVE_HIDDEN_POWER] = TRUE, - [MOVE_CROSS_CHOP] = TRUE, - [MOVE_TWISTER] = FALSE, - [MOVE_RAIN_DANCE] = TRUE, - [MOVE_SUNNY_DAY] = TRUE, - [MOVE_CRUNCH] = TRUE, - [MOVE_MIRROR_COAT] = TRUE, - [MOVE_PSYCH_UP] = TRUE, - [MOVE_EXTREME_SPEED] = TRUE, - [MOVE_ANCIENT_POWER] = TRUE, - [MOVE_SHADOW_BALL] = TRUE, - [MOVE_FUTURE_SIGHT] = TRUE, - [MOVE_ROCK_SMASH] = TRUE, - [MOVE_WHIRLPOOL] = TRUE, - [MOVE_BEAT_UP] = TRUE, - [MOVE_FAKE_OUT] = TRUE, - [MOVE_UPROAR] = TRUE, - [MOVE_STOCKPILE] = TRUE, - [MOVE_SPIT_UP] = TRUE, - [MOVE_SWALLOW] = TRUE, - [MOVE_HEAT_WAVE] = TRUE, - [MOVE_HAIL] = TRUE, - [MOVE_TORMENT] = TRUE, - [MOVE_FLATTER] = TRUE, - [MOVE_WILL_O_WISP] = TRUE, - [MOVE_MEMENTO] = TRUE, - [MOVE_FACADE] = TRUE, - [MOVE_FOCUS_PUNCH] = TRUE, - [MOVE_SMELLING_SALT] = TRUE, - [MOVE_FOLLOW_ME] = TRUE, - [MOVE_NATURE_POWER] = TRUE, - [MOVE_CHARGE] = TRUE, - [MOVE_TAUNT] = TRUE, - [MOVE_HELPING_HAND] = TRUE, - [MOVE_TRICK] = TRUE, - [MOVE_ROLE_PLAY] = TRUE, - [MOVE_WISH] = TRUE, - [MOVE_ASSIST] = TRUE, - [MOVE_INGRAIN] = TRUE, - [MOVE_SUPERPOWER] = TRUE, - [MOVE_MAGIC_COAT] = TRUE, - [MOVE_RECYCLE] = TRUE, - [MOVE_REVENGE] = TRUE, - [MOVE_BRICK_BREAK] = TRUE, - [MOVE_YAWN] = TRUE, - [MOVE_KNOCK_OFF] = TRUE, - [MOVE_ENDEAVOR] = TRUE, - [MOVE_ERUPTION] = TRUE, - [MOVE_SKILL_SWAP] = TRUE, - [MOVE_IMPRISON] = TRUE, - [MOVE_REFRESH] = TRUE, - [MOVE_GRUDGE] = TRUE, - [MOVE_SNATCH] = TRUE, - [MOVE_SECRET_POWER] = TRUE, - [MOVE_DIVE] = TRUE, - [MOVE_ARM_THRUST] = FALSE, - [MOVE_CAMOUFLAGE] = TRUE, - [MOVE_TAIL_GLOW] = TRUE, - [MOVE_LUSTER_PURGE] = TRUE, - [MOVE_MIST_BALL] = TRUE, - [MOVE_FEATHER_DANCE] = TRUE, - [MOVE_TEETER_DANCE] = TRUE, - [MOVE_BLAZE_KICK] = TRUE, - [MOVE_MUD_SPORT] = TRUE, - [MOVE_ICE_BALL] = FALSE, - [MOVE_NEEDLE_ARM] = TRUE, - [MOVE_SLACK_OFF] = TRUE, - [MOVE_HYPER_VOICE] = TRUE, - [MOVE_POISON_FANG] = FALSE, - [MOVE_CRUSH_CLAW] = TRUE, - [MOVE_BLAST_BURN] = TRUE, - [MOVE_HYDRO_CANNON] = TRUE, - [MOVE_METEOR_MASH] = TRUE, - [MOVE_ASTONISH] = TRUE, - [MOVE_WEATHER_BALL] = TRUE, - [MOVE_AROMATHERAPY] = TRUE, - [MOVE_FAKE_TEARS] = TRUE, - [MOVE_AIR_CUTTER] = TRUE, - [MOVE_OVERHEAT] = TRUE, - [MOVE_ODOR_SLEUTH] = TRUE, - [MOVE_ROCK_TOMB] = TRUE, - [MOVE_SILVER_WIND] = TRUE, - [MOVE_METAL_SOUND] = TRUE, - [MOVE_GRASS_WHISTLE] = TRUE, - [MOVE_TICKLE] = TRUE, - [MOVE_COSMIC_POWER] = TRUE, - [MOVE_WATER_SPOUT] = TRUE, - [MOVE_SIGNAL_BEAM] = TRUE, - [MOVE_SHADOW_PUNCH] = TRUE, - [MOVE_EXTRASENSORY] = TRUE, - [MOVE_SKY_UPPERCUT] = TRUE, - [MOVE_SAND_TOMB] = TRUE, - [MOVE_SHEER_COLD] = TRUE, - [MOVE_MUDDY_WATER] = TRUE, - [MOVE_BULLET_SEED] = FALSE, - [MOVE_AERIAL_ACE] = TRUE, - [MOVE_ICICLE_SPEAR] = FALSE, - [MOVE_IRON_DEFENSE] = TRUE, - [MOVE_BLOCK] = TRUE, - [MOVE_HOWL] = TRUE, - [MOVE_DRAGON_CLAW] = TRUE, - [MOVE_FRENZY_PLANT] = TRUE, - [MOVE_BULK_UP] = TRUE, - [MOVE_BOUNCE] = TRUE, - [MOVE_MUD_SHOT] = FALSE, - [MOVE_POISON_TAIL] = TRUE, - [MOVE_COVET] = TRUE, - [MOVE_VOLT_TACKLE] = TRUE, - [MOVE_MAGICAL_LEAF] = TRUE, - [MOVE_WATER_SPORT] = TRUE, - [MOVE_CALM_MIND] = TRUE, - [MOVE_LEAF_BLADE] = TRUE, - [MOVE_DRAGON_DANCE] = TRUE, - [MOVE_ROCK_BLAST] = FALSE, - [MOVE_SHOCK_WAVE] = TRUE, - [MOVE_WATER_PULSE] = TRUE, - [MOVE_DOOM_DESIRE] = TRUE, - [MOVE_PSYCHO_BOOST] = TRUE, -}; - -static const u8 gUnknown_086114D3[] = {0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00}; - -static void (* const sApprenticeFunctions[])(void) = -{ - Script_IsPlayersApprenticeActive, - Script_SetPlayersApprenticeLvlMode, - sub_81A0978, - sub_819FC60, - sub_81A0984, - sub_81A0990, - sub_81A09D0, - Script_CreateApprenticeMenu, - Script_PrintMessage, - Script_ResetPlayerApprentice, - sub_81A1638, - sub_81A0CC0, - sub_81A09B4, - sub_81A0D40, - sub_81A0DD4, - sub_81A0FE4, - sub_81A0FFC, - sub_81A0D80, - sub_81A11F8, - sub_81A1218, - sub_81A1224, - sub_81A1438, - sub_81A150C, - Script_SetPlayerApprenticeTrainerGfxId, - sub_81A1644, - sub_81A1370, -}; - -static const u8 gUnknown_08611548[8] = {0x00, 0x01, 0x02, 0x03, 0x06, 0x07, 0x08, 0x09}; - -// text -extern const u8 gText_Give[]; -extern const u8 gText_NoNeed[]; -extern const u8 gText_Yes[]; -extern const u8 gText_No[]; - -void CopyFriendsApprenticeChallengeText(u8 saveblockApprenticeId) -{ - u8 i, var; - const u8 *str; - - var = gSaveBlock2Ptr->apprentices[saveblockApprenticeId].number; - for (i = 0; var != 0 && i < 4; var /= 10, i++) +static void GetShouldCheckApprenticeGone(void); +static void ApprenticeGetQuestion(void); +static void GetNumApprenticePartyMonsAssigned(void); +static void SetApprenticePartyMon(void); +static void InitQuestionData(void); +static void FreeQuestionData(void); +static void ApprenticeBufferString(void); +static void SetApprenticeMonMove(void); +static void SetLeadApprenticeMon(void); +static void Script_ApprenticeOpenBagMenu(void); +static void TrySetApprenticeHeldItem(void); +static void SaveApprentice(void); +static void SetSavedApprenticeTrainerGfxId(void); +static void SetPlayerApprenticeTrainerGfxId(void); +static void GetShouldApprenticeLeave(void); +static void ShiftSavedApprentices(void); + +#include "data/battle_frontier/apprentice.h" + +void BufferApprenticeChallengeText(u8 saveApprenticeId) +{ + u8 i, num; + const u8 *challengeText; + + num = gSaveBlock2Ptr->apprentices[saveApprenticeId].number; + for (i = 0; num != 0 && i < APPRENTICE_COUNT; num /= 10, i++) ; - StringCopy7(gStringVar1, gSaveBlock2Ptr->apprentices[saveblockApprenticeId].playerName); - ConvertInternationalString(gStringVar1, gSaveBlock2Ptr->apprentices[saveblockApprenticeId].language); - ConvertIntToDecimalStringN(gStringVar2, gSaveBlock2Ptr->apprentices[saveblockApprenticeId].number, STR_CONV_MODE_RIGHT_ALIGN, i); - str = gUnknown_08611330[gSaveBlock2Ptr->apprentices[saveblockApprenticeId].id]; - StringExpandPlaceholders(gStringVar4, str); + StringCopy7(gStringVar1, gSaveBlock2Ptr->apprentices[saveApprenticeId].playerName); + ConvertInternationalString(gStringVar1, gSaveBlock2Ptr->apprentices[saveApprenticeId].language); + ConvertIntToDecimalStringN(gStringVar2, gSaveBlock2Ptr->apprentices[saveApprenticeId].number, STR_CONV_MODE_RIGHT_ALIGN, i); + challengeText = sApprenticeChallengeTexts[gSaveBlock2Ptr->apprentices[saveApprenticeId].id]; + StringExpandPlaceholders(gStringVar4, challengeText); } void Apprentice_EnableBothScriptContexts(void) @@ -1079,27 +144,27 @@ void ResetApprenticeStruct(struct Apprentice *apprentice) { u8 i; - for (i = 0; i < 6; i++) - apprentice->easyChatWords[i] = 0xFFFF; + for (i = 0; i < ARRAY_COUNT(apprentice->speechWon); i++) + apprentice->speechWon[i] = 0xFFFF; apprentice->playerName[0] = EOS; - apprentice->id = 16; + apprentice->id = NUM_APPRENTICES; } void ResetAllApprenticeData(void) { u8 i, j; - PLAYER_APPRENTICE.field_B2_1 = 0; - for (i = 0; i < 4; i++) + PLAYER_APPRENTICE.saveId = 0; + for (i = 0; i < APPRENTICE_COUNT; i++) { - for (j = 0; j < 6; j++) - gSaveBlock2Ptr->apprentices[i].easyChatWords[j] = 0xFFFF; - gSaveBlock2Ptr->apprentices[i].id = 16; + for (j = 0; j < ARRAY_COUNT(gSaveBlock2Ptr->apprentices[i].speechWon); j++) + gSaveBlock2Ptr->apprentices[i].speechWon[j] = 0xFFFF; + gSaveBlock2Ptr->apprentices[i].id = NUM_APPRENTICES; gSaveBlock2Ptr->apprentices[i].playerName[0] = EOS; gSaveBlock2Ptr->apprentices[i].lvlMode = 0; gSaveBlock2Ptr->apprentices[i].number = 0; - gSaveBlock2Ptr->apprentices[i].field_1 = 0; + gSaveBlock2Ptr->apprentices[i].numQuestions = 0; for (j = 0; j < TRAINER_ID_LENGTH; j++) gSaveBlock2Ptr->apprentices[i].playerId[j] = 0; gSaveBlock2Ptr->apprentices[i].language = gGameLanguage; @@ -1109,174 +174,184 @@ void ResetAllApprenticeData(void) Script_ResetPlayerApprentice(); } -static bool8 IsPlayersApprenticeActive(void) +static bool8 GivenApprenticeLvlMode(void) { - return (PLAYER_APPRENTICE.activeLvlMode != 0); + return (PLAYER_APPRENTICE.lvlMode != 0); } -static void sub_819FBC8(void) +static void SetApprenticeId(void) { if (gSaveBlock2Ptr->apprentices[0].number == 0) { do { - PLAYER_APPRENTICE.id = gUnknown_08611548[Random() % ARRAY_COUNT(gUnknown_08611548)]; + PLAYER_APPRENTICE.id = sInitialApprenticeIds[Random() % ARRAY_COUNT(sInitialApprenticeIds)]; } while (PLAYER_APPRENTICE.id == gSaveBlock2Ptr->apprentices[0].id); } else { do { - PLAYER_APPRENTICE.id = Random() % 16; + PLAYER_APPRENTICE.id = Random() % (NUM_APPRENTICES); } while (PLAYER_APPRENTICE.id == gSaveBlock2Ptr->apprentices[0].id); } } static void SetPlayersApprenticeLvlMode(u8 mode) { - PLAYER_APPRENTICE.activeLvlMode = mode; + PLAYER_APPRENTICE.lvlMode = mode; } -static void sub_819FC60(void) +static void ShuffleApprenticeSpecies(void) { - u8 array[APPRENTICE_SPECIES_COUNT]; + u8 species[APPRENTICE_SPECIES_COUNT]; u8 i; - for (i = 0; i < ARRAY_COUNT(array); i++) - array[i] = i; + for (i = 0; i < ARRAY_COUNT(species); i++) + species[i] = i; + // Shuffle the possible species an arbitrary 50 times for (i = 0; i < 50; i++) { u8 temp; - u8 var1 = Random() % ARRAY_COUNT(array); - u8 var2 = Random() % ARRAY_COUNT(array); - SWAP(array[var1], array[var2], temp); + u8 rand1 = Random() % ARRAY_COUNT(species); + u8 rand2 = Random() % ARRAY_COUNT(species); + SWAP(species[rand1], species[rand2], temp); } - for (i = 0; i < 3; i++) - PLAYER_APPRENTICE.monIds[i] = ((array[i * 2] & 0xF) << 4) | ((array[i * 2 + 1]) & 0xF); + for (i = 0; i < MULTI_PARTY_SIZE; i++) + PLAYER_APPRENTICE.speciesIds[i] = ((species[i * 2] & 0xF) << 4) | ((species[i * 2 + 1]) & 0xF); } -static u8 sub_819FCF8(u8 val, u8 *arg1, u8 *arg2) +// Pick one of the Apprentice's mons to ask the question about +// Picking a move chooses a random mon, picking a held item is sequential (so that none are repeated) +static u8 GetMonIdForQuestion(u8 questionId, u8 *party, u8 *partySlot) { u8 i, count; - u8 ret = 0; + u8 monId = 0; - if (val == 2) + if (questionId == QUESTION_ID_WHICH_MOVE) { do { - ret = Random() % 3; - for (count = 0, i = 0; i < 5; i++) + monId = Random() % (MULTI_PARTY_SIZE); + for (count = 0, i = 0; i < NUM_WHICH_MOVE_QUESTIONS; i++) { - if (gUnknown_030062EC->unk2[ret][i] != 0) + if (gApprenticePartyMovesData->moves[monId][i] != MOVE_NONE) count++; } - } while (count > 3); + } while (count > MULTI_PARTY_SIZE); } - else if (val == 1) + else if (questionId == QUESTION_ID_WHAT_ITEM) { - ret = arg1[*arg2]; - (*arg2)++; + monId = party[*partySlot]; + (*partySlot)++; } - return ret; + return monId; } -static void sub_819FD64(void) +// Sets the random order and data for the remaining questions after the initial "choose mon" questions +static void SetRandomQuestionData(void) { - u8 sp_0[10]; - u8 sp_C[3]; - u8 sp_10; + u8 questionOrder[APPRENTICE_MAX_QUESTIONS + 1]; + u8 partyOrder[MULTI_PARTY_SIZE]; + u8 partySlot; u8 i, j; u8 rand1, rand2; u8 id; - for (i = 0; i < 3; i++) - sp_C[i] = i; + for (i = 0; i < ARRAY_COUNT(partyOrder); i++) + partyOrder[i] = i; + + // Shuffle the party an arbitrary 10 times for (i = 0; i < 10; i++) { u8 temp; - rand1 = Random() % ARRAY_COUNT(sp_C); - rand2 = Random() % ARRAY_COUNT(sp_C); - SWAP(sp_C[rand1], sp_C[rand2], temp); + rand1 = Random() % ARRAY_COUNT(partyOrder); + rand2 = Random() % ARRAY_COUNT(partyOrder); + SWAP(partyOrder[rand1], partyOrder[rand2], temp); } - for (i = 0; i < 10; i++) - sp_0[i] = gUnknown_086114D3[i]; + for (i = 0; i < ARRAY_COUNT(questionOrder); i++) + questionOrder[i] = sQuestionPossibilities[i]; + + // Shuffle the questions an arbitrary 50 times for (i = 0; i < 50; i++) { u8 temp; - rand1 = Random() % ARRAY_COUNT(sp_0); - rand2 = Random() % ARRAY_COUNT(sp_0); - SWAP(sp_0[rand1], sp_0[rand2], temp); + rand1 = Random() % ARRAY_COUNT(questionOrder); + rand2 = Random() % ARRAY_COUNT(questionOrder); + SWAP(questionOrder[rand1], questionOrder[rand2], temp); } - gUnknown_030062EC = AllocZeroed(sizeof(*gUnknown_030062EC)); - gUnknown_030062EC->unk0 = 0; - for (i = 0; i < 5; i++) + gApprenticePartyMovesData = AllocZeroed(sizeof(*gApprenticePartyMovesData)); + gApprenticePartyMovesData->moveCounter = 0; + for (i = 0; i < NUM_WHICH_MOVE_QUESTIONS; i++) { - for (j = 0; j < 3; j++) - gUnknown_030062EC->unk20[j][i] = 4; + for (j = 0; j < MULTI_PARTY_SIZE; j++) + gApprenticePartyMovesData->moveSlots[j][i] = MAX_MON_MOVES; } - sp_10 = 0; - for (i = 0; i < 9; i++) + partySlot = 0; + for (i = 0; i < APPRENTICE_MAX_QUESTIONS; i++) { - PLAYER_APPRENTICE.field_B8[i].unk0_0 = sp_0[i]; - if (sp_0[i] != 3) + PLAYER_APPRENTICE.questions[i].questionId = questionOrder[i]; + if (questionOrder[i] != QUESTION_ID_WHICH_FIRST) { - PLAYER_APPRENTICE.field_B8[i].unk0_1 = sub_819FCF8(sp_0[i], sp_C, &sp_10); - id = PLAYER_APPRENTICE.field_B8[i].unk0_1; - if (sp_0[i] == 2) + PLAYER_APPRENTICE.questions[i].monId = GetMonIdForQuestion(questionOrder[i], partyOrder, &partySlot); + id = PLAYER_APPRENTICE.questions[i].monId; + if (questionOrder[i] == QUESTION_ID_WHICH_MOVE) { do { - rand1 = Random() % 4; - for (j = 0; j < gUnknown_030062EC->unk0 + 1; j++) + rand1 = Random() % MAX_MON_MOVES; + for (j = 0; j < gApprenticePartyMovesData->moveCounter + 1; j++) { - if (gUnknown_030062EC->unk20[id][j] == rand1) + if (gApprenticePartyMovesData->moveSlots[id][j] == rand1) break; } - } while (j != gUnknown_030062EC->unk0 + 1); + } while (j != gApprenticePartyMovesData->moveCounter + 1); - gUnknown_030062EC->unk20[id][gUnknown_030062EC->unk0] = rand1; - PLAYER_APPRENTICE.field_B8[i].unk0_2 = rand1; - PLAYER_APPRENTICE.field_B8[i].unk2 = sub_819FF98(PLAYER_APPRENTICE.field_B8[i].unk0_1); + gApprenticePartyMovesData->moveSlots[id][gApprenticePartyMovesData->moveCounter] = rand1; + PLAYER_APPRENTICE.questions[i].moveSlot = rand1; + PLAYER_APPRENTICE.questions[i].data = GetRandomAlternateMove(PLAYER_APPRENTICE.questions[i].monId); } } } - FREE_AND_SET_NULL(gUnknown_030062EC); + FREE_AND_SET_NULL(gApprenticePartyMovesData); } // No idea why a do-while loop is needed, but it will not match without it. -#define APPRENTICE_SPECIES_ID(speciesArrId, monId) speciesArrId = (PLAYER_APPRENTICE.monIds[monId] >> \ - (((PLAYER_APPRENTICE.field_B2_0 >> monId) & 1) << 2)) & 0xF; \ +#define APPRENTICE_SPECIES_ID(speciesArrId, monId) speciesArrId = (PLAYER_APPRENTICE.speciesIds[monId] >> \ + (((PLAYER_APPRENTICE.party >> monId) & 1) << 2)) & 0xF; \ do {} while (0) // Why the need to have two macros do the exact thing differently? -#define APPRENTICE_SPECIES_ID_2(speciesArrId, monId) { u8 a0 = ((PLAYER_APPRENTICE.field_B2_0 >> monId) & 1);\ - speciesArrId = PLAYER_APPRENTICE.monIds[monId]; \ +#define APPRENTICE_SPECIES_ID_2(speciesArrId, monId) { u8 a0 = ((PLAYER_APPRENTICE.party >> monId) & 1);\ + speciesArrId = PLAYER_APPRENTICE.speciesIds[monId]; \ speciesArrId = ((speciesArrId) >> (a0 << 2)) & 0xF; \ } -static u16 sub_819FF98(u8 arg0) +// Get the second move choice for the "Which move" question +// Unlike the first move choice, this can be either a level up move or a TM/HM move +static u16 GetRandomAlternateMove(u8 monId) { u8 i, j; u8 id; - u8 knownMovesCount; + u8 numLearnsetMoves; u16 species; const u16 *learnset; - bool32 var_24 = FALSE; - u16 moveId = 0; - bool32 valid; + bool32 needTMs = FALSE; + u16 moveId = MOVE_NONE; + bool32 shouldUseMove; u8 level; - if (arg0 < 3) + if (monId < MULTI_PARTY_SIZE) { - APPRENTICE_SPECIES_ID(id, arg0); + APPRENTICE_SPECIES_ID(id, monId); } else { @@ -1286,207 +361,224 @@ static u16 sub_819FF98(u8 arg0) species = gApprentices[PLAYER_APPRENTICE.id].species[id]; learnset = gLevelUpLearnsets[species]; j = 0; - if (PLAYER_APPRENTICE.activeLvlMode == 1) + + // Despite being open level, level up moves are only read up to level 60 + if (PLAYER_APPRENTICE.lvlMode == APPRENTICE_LVL_MODE_50) level = 50; - else + else // == APPRENTICE_LVL_MODE_OPEN level = 60; - for (j = 0; learnset[j] != 0xFFFF; j++) + for (j = 0; learnset[j] != LEVEL_UP_END; j++) { - if ((learnset[j] & 0xFE00) > (level << 9)) + if ((learnset[j] & LEVEL_UP_MOVE_LV) > (level << 9)) break; } - knownMovesCount = j; + numLearnsetMoves = j; i = 0; - while (i <= MAX_MON_MOVES) + + // i < 5 here is arbitrary, i isnt used and is only incremented when the selected move isnt in sValidApprenticeMoves + // This while loop contains 3 potential infinite loops, though none of them would occur in the base game + while (i < 5) { - if (Random() % 2 == 0 || var_24 == TRUE) + if (Random() % 2 == 0 || needTMs == TRUE) { + // Get TM move + // NOTE: Below is an infinite loop if a species that only learns TMs for moves + // that are also in its level up learnset is assigned to an Apprentice do { + // NOTE: Below is an infinite loop if a species which cannot learn TMs is assigned to an Apprentice do { id = Random() % (NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES); - valid = CanSpeciesLearnTMHM(species, id); + shouldUseMove = CanSpeciesLearnTMHM(species, id); } - while (!valid); + while (!shouldUseMove); moveId = ItemIdToBattleMoveId(ITEM_TM01 + id); - valid = TRUE; + shouldUseMove = TRUE; - if (knownMovesCount < 5) + if (numLearnsetMoves <= MAX_MON_MOVES) j = 0; else - j = knownMovesCount - MAX_MON_MOVES; + j = numLearnsetMoves - MAX_MON_MOVES; - for (; j < knownMovesCount; j++) + for (; j < numLearnsetMoves; j++) { - if ((learnset[j] & 0x1FF) == moveId) + // Keep looking for TMs until one not in the level up learnset is found + if ((learnset[j] & LEVEL_UP_MOVE_ID) == moveId) { - valid = FALSE; + shouldUseMove = FALSE; break; } } - } while (valid != TRUE); + } while (shouldUseMove != TRUE); } else { - if (knownMovesCount <= MAX_MON_MOVES) + if (numLearnsetMoves <= MAX_MON_MOVES) { - var_24 = TRUE; + needTMs = TRUE; continue; } else { + // Get level up move + // NOTE: Below is an infinite loop if a mon whose last 4 moves contain + // all the moves in the rest of its learnset is assigned to an Apprentice do { - u8 learnsetId = Random() % (knownMovesCount - MAX_MON_MOVES); - moveId = learnset[learnsetId] & 0x1FF; - valid = TRUE; - for (j = knownMovesCount - MAX_MON_MOVES; j < knownMovesCount; j++) + // Get a random move excluding the 4 it would know at max level + u8 learnsetId = Random() % (numLearnsetMoves - MAX_MON_MOVES); + moveId = learnset[learnsetId] & LEVEL_UP_MOVE_ID; + shouldUseMove = TRUE; + + for (j = numLearnsetMoves - MAX_MON_MOVES; j < numLearnsetMoves; j++) { - if ((learnset[j] & 0x1FF) == moveId) + // Keep looking for moves until one not in the last 4 is found + if ((learnset[j] & LEVEL_UP_MOVE_ID) == moveId) { - valid = FALSE; + shouldUseMove = FALSE; break; } } - } while (valid != TRUE); + } while (shouldUseMove != TRUE); } } - if (sub_81A0194(arg0, moveId)) + if (TrySetMove(monId, moveId)) { - if (gUnknown_08611370[moveId]) + if (sValidApprenticeMoves[moveId]) break; i++; } } - gUnknown_030062EC->unk0++; + gApprenticePartyMovesData->moveCounter++; return moveId; } -static bool8 sub_81A0194(u8 arg0, u16 moveId) +static bool8 TrySetMove(u8 monId, u16 moveId) { u8 i; - for (i = 0; i < 5; i++) + for (i = 0; i < NUM_WHICH_MOVE_QUESTIONS; i++) { - if (gUnknown_030062EC->unk2[arg0][i] == moveId) + if (gApprenticePartyMovesData->moves[monId][i] == moveId) return FALSE; } - gUnknown_030062EC->unk2[arg0][gUnknown_030062EC->unk0] = moveId; + gApprenticePartyMovesData->moves[monId][gApprenticePartyMovesData->moveCounter] = moveId; return TRUE; } static void GetLatestLearnedMoves(u16 species, u16 *moves) { u8 i, j; - u8 level, knownMovesCount; + u8 level, numLearnsetMoves; const u16 *learnset; - if (PLAYER_APPRENTICE.activeLvlMode == 1) + if (PLAYER_APPRENTICE.lvlMode == APPRENTICE_LVL_MODE_50) level = 50; - else + else // == APPRENTICE_LVL_MODE_OPEN level = 60; learnset = gLevelUpLearnsets[species]; - for (i = 0; learnset[i] != 0xFFFF; i++) + for (i = 0; learnset[i] != LEVEL_UP_END; i++) { - if ((learnset[i] & 0xFE00) > (level << 9)) + if ((learnset[i] & LEVEL_UP_MOVE_LV) > (level << 9)) break; } - knownMovesCount = i; - if (knownMovesCount > MAX_MON_MOVES) - knownMovesCount = MAX_MON_MOVES; + numLearnsetMoves = i; + if (numLearnsetMoves > MAX_MON_MOVES) + numLearnsetMoves = MAX_MON_MOVES; - for (j = 0; j < knownMovesCount; j++) - moves[j] = learnset[(i - 1) - j] & 0x1FF; + for (j = 0; j < numLearnsetMoves; j++) + moves[j] = learnset[(i - 1) - j] & LEVEL_UP_MOVE_ID; } -static u16 sub_81A0284(u8 arg0, u8 speciesTableId, u8 arg2) +// Get the level up move or previously suggested move to be the first move choice +// Compare to GetRandomAlternateMove, which gets the move that will be the second choice +static u16 GetDefaultMove(u8 monId, u8 speciesArrayId, u8 moveSlot) { u16 moves[MAX_MON_MOVES]; - u8 i, count; + u8 i, numQuestions; - if (PLAYER_APPRENTICE.field_B1_1 < 3) - return 0; + if (PLAYER_APPRENTICE.questionsAnswered < NUM_WHICH_MON_QUESTIONS) + return MOVE_NONE; - count = 0; - for (i = 0; i < 9; i++) - { - if (PLAYER_APPRENTICE.field_B8[i].unk0_0 == 0) - break; - count++; - } + numQuestions = 0; + for (i = 0; i < APPRENTICE_MAX_QUESTIONS && PLAYER_APPRENTICE.questions[i].questionId != QUESTION_ID_WIN_SPEECH; i++) + numQuestions++; - GetLatestLearnedMoves(gApprentices[PLAYER_APPRENTICE.id].species[speciesTableId], moves); - for (i = 0; i < count && i < PLAYER_APPRENTICE.field_B1_1 - 3; i++) + GetLatestLearnedMoves(gApprentices[PLAYER_APPRENTICE.id].species[speciesArrayId], moves); + for (i = 0; i < numQuestions && i < CURRENT_QUESTION_NUM; i++) { - if (PLAYER_APPRENTICE.field_B8[i].unk0_0 == 2 - && PLAYER_APPRENTICE.field_B8[i].unk0_1 == arg0 - && PLAYER_APPRENTICE.field_B8[i].unk0_3 != 0) + if (PLAYER_APPRENTICE.questions[i].questionId == QUESTION_ID_WHICH_MOVE + && PLAYER_APPRENTICE.questions[i].monId == monId + && PLAYER_APPRENTICE.questions[i].suggestedChange) { - moves[PLAYER_APPRENTICE.field_B8[i].unk0_2] = PLAYER_APPRENTICE.field_B8[i].unk2; + moves[PLAYER_APPRENTICE.questions[i].moveSlot] = PLAYER_APPRENTICE.questions[i].data; } } - return moves[arg2]; + return moves[moveSlot]; } -static void sub_81A0390(u8 arg0) +static void SaveApprenticeParty(u8 numQuestions) { - struct ApprenticeMon *apprenticeMons[3]; + struct ApprenticeMon *apprenticeMons[MULTI_PARTY_SIZE]; u8 i, j; u32 speciesTableId; - for (i = 0; i < 3; i++) + for (i = 0; i < MULTI_PARTY_SIZE; i++) { - gSaveBlock2Ptr->apprentices[0].party[i].species = 0; - gSaveBlock2Ptr->apprentices[0].party[i].item = 0; + gSaveBlock2Ptr->apprentices[0].party[i].species = SPECIES_NONE; + gSaveBlock2Ptr->apprentices[0].party[i].item = ITEM_NONE; for (j = 0; j < MAX_MON_MOVES; j++) - gSaveBlock2Ptr->apprentices[0].party[i].moves[j] = 0; + gSaveBlock2Ptr->apprentices[0].party[i].moves[j] = MOVE_NONE; } - j = PLAYER_APPRENTICE.field_B1_2; - for (i = 0; i < 3; i++) + // Save party order + j = PLAYER_APPRENTICE.leadMonId; + for (i = 0; i < MULTI_PARTY_SIZE; i++) { apprenticeMons[j] = &gSaveBlock2Ptr->apprentices[0].party[i]; - j = (j + 1) % 3; + j = (j + 1) % (MULTI_PARTY_SIZE); } - for (i = 0; i < 3; i++) + // Save party species + for (i = 0; i < MULTI_PARTY_SIZE; i++) { APPRENTICE_SPECIES_ID(speciesTableId, i); apprenticeMons[i]->species = gApprentices[PLAYER_APPRENTICE.id].species[speciesTableId]; GetLatestLearnedMoves(apprenticeMons[i]->species, apprenticeMons[i]->moves); } - for (i = 0; i < arg0; i++) + // Update party based on response to held item / move choice questions + for (i = 0; i < numQuestions; i++) { - u8 var1 = PLAYER_APPRENTICE.field_B8[i].unk0_0; - u8 monId = PLAYER_APPRENTICE.field_B8[i].unk0_1; - if (var1 == 1) + u8 questionId = PLAYER_APPRENTICE.questions[i].questionId; + u8 monId = PLAYER_APPRENTICE.questions[i].monId; + if (questionId == QUESTION_ID_WHAT_ITEM) { - if (PLAYER_APPRENTICE.field_B8[i].unk0_3 != 0) - apprenticeMons[monId]->item = PLAYER_APPRENTICE.field_B8[i].unk2; + if (PLAYER_APPRENTICE.questions[i].suggestedChange) + apprenticeMons[monId]->item = PLAYER_APPRENTICE.questions[i].data; } - else if (var1 == 2) + else if (questionId == QUESTION_ID_WHICH_MOVE) { - if (PLAYER_APPRENTICE.field_B8[i].unk0_3 != 0) + if (PLAYER_APPRENTICE.questions[i].suggestedChange) { - u32 moveSlot = PLAYER_APPRENTICE.field_B8[i].unk0_2; - apprenticeMons[monId]->moves[moveSlot] = PLAYER_APPRENTICE.field_B8[i].unk2; + u32 moveSlot = PLAYER_APPRENTICE.questions[i].moveSlot; + apprenticeMons[monId]->moves[moveSlot] = PLAYER_APPRENTICE.questions[i].data; } } } } -static void CreateMenuWithAnswers(u8 arg0) +static void CreateApprenticeMenu(u8 menu) { u8 i; u8 windowId; @@ -1497,19 +589,19 @@ static void CreateMenuWithAnswers(u8 arg0) u8 top; s32 pixelWidth; - switch (arg0) + switch (menu) { case APPRENTICE_ASK_WHICH_LEVEL: - left = 0x12; + left = 18; top = 8; strings[0] = gText_Lv50; strings[1] = gText_OpenLevel; break; case APPRENTICE_ASK_3SPECIES: - count = 3; - left = 0x12; + count = MULTI_PARTY_SIZE; + left = 18; top = 6; - for (i = 0; i < 3; i++) + for (i = 0; i < MULTI_PARTY_SIZE; i++) { u16 species; u32 speciesTableId; @@ -1520,27 +612,27 @@ static void CreateMenuWithAnswers(u8 arg0) } break; case APPRENTICE_ASK_2SPECIES: - left = 0x12; + left = 18; top = 8; - if (PLAYER_APPRENTICE.field_B1_1 > 2) + if (PLAYER_APPRENTICE.questionsAnswered >= NUM_WHICH_MON_QUESTIONS) return; - strings[1] = gSpeciesNames[gUnknown_030062F0->unk2]; - strings[0] = gSpeciesNames[gUnknown_030062F0->unk0]; + strings[1] = gSpeciesNames[gApprenticeQuestionData->altSpeciesId]; + strings[0] = gSpeciesNames[gApprenticeQuestionData->speciesId]; break; case APPRENTICE_ASK_MOVES: - left = 0x11; + left = 17; top = 8; - strings[0] = gMoveNames[gUnknown_030062F0->unk4]; - strings[1] = gMoveNames[gUnknown_030062F0->unk6]; + strings[0] = gMoveNames[gApprenticeQuestionData->moveId1]; + strings[1] = gMoveNames[gApprenticeQuestionData->moveId2]; break; case APPRENTICE_ASK_GIVE: - left = 0x12; + left = 18; top = 8; strings[0] = gText_Give; strings[1] = gText_NoNeed; break; case APPRENTICE_ASK_YES_NO: - left = 0x14; + left = 20; top = 8; strings[0] = gText_Yes; strings[1] = gText_No; @@ -1623,12 +715,12 @@ static void RemoveAndHideWindow(u8 windowId) RemoveWindow(windowId); } -static void CreateChooseAnswerTask(bool8 noBButton, u8 itemsCount, u8 windowId) +static void CreateChooseAnswerTask(bool8 noBButton, u8 answers, u8 windowId) { u8 taskId = CreateTask(Task_ChooseAnswer, 80); gTasks[taskId].tNoBButton = noBButton; - if (itemsCount > 3) + if (answers > 3) gTasks[taskId].tWrapAround = TRUE; else gTasks[taskId].tWrapAround = FALSE; @@ -1649,71 +741,79 @@ static void Script_ResetPlayerApprentice(void) { u8 i; - sub_819FBC8(); - PLAYER_APPRENTICE.activeLvlMode = 0; - PLAYER_APPRENTICE.field_B1_1 = 0; - PLAYER_APPRENTICE.field_B1_2 = 0; - PLAYER_APPRENTICE.field_B2_0 = 0; + SetApprenticeId(); + PLAYER_APPRENTICE.lvlMode = 0; + PLAYER_APPRENTICE.questionsAnswered = 0; + PLAYER_APPRENTICE.leadMonId = 0; + PLAYER_APPRENTICE.party = 0; - for (i = 0; i < 3; i++) - PLAYER_APPRENTICE.monIds[i] = 0; + for (i = 0; i < MULTI_PARTY_SIZE; i++) + PLAYER_APPRENTICE.speciesIds[i] = 0; - for (i = 0; i < 9; i++) + for (i = 0; i < APPRENTICE_MAX_QUESTIONS; i++) { - PLAYER_APPRENTICE.field_B8[i].unk0_0 = 0; - PLAYER_APPRENTICE.field_B8[i].unk0_1 = 0; - PLAYER_APPRENTICE.field_B8[i].unk0_2 = 0; - PLAYER_APPRENTICE.field_B8[i].unk0_3 = 0; - PLAYER_APPRENTICE.field_B8[i].unk2 = 0; + PLAYER_APPRENTICE.questions[i].questionId = 0; + PLAYER_APPRENTICE.questions[i].monId = 0; + PLAYER_APPRENTICE.questions[i].moveSlot = 0; + PLAYER_APPRENTICE.questions[i].suggestedChange = 0; + PLAYER_APPRENTICE.questions[i].data = 0; } } -static void Script_IsPlayersApprenticeActive(void) +static void Script_GivenApprenticeLvlMode(void) { - if (!IsPlayersApprenticeActive()) + if (!GivenApprenticeLvlMode()) gSpecialVar_Result = FALSE; else gSpecialVar_Result = TRUE; } -static void Script_SetPlayersApprenticeLvlMode(void) +// VAR_0x8005 is 1 + the selection value from the multichoice APPRENTICE_ASK_WHICH_LEVEL +// i.e. APPRENTICE_LVL_MODE_50 or APPRENTICE_LVL_MODE_OPEN +static void Script_SetApprenticeLvlMode(void) { SetPlayersApprenticeLvlMode(gSpecialVar_0x8005); } -static void sub_81A0978(void) +// Never called, APPRENTICE_FUNC_SET_ID is unused +static void Script_SetApprenticeId(void) { - sub_819FBC8(); + SetApprenticeId(); } -static void sub_81A0984(void) +static void Script_SetRandomQuestionData(void) { - sub_819FD64(); + SetRandomQuestionData(); } -static void sub_81A0990(void) +static void IncrementQuestionsAnswered(void) { - PLAYER_APPRENTICE.field_B1_1++; + PLAYER_APPRENTICE.questionsAnswered++; } -static void sub_81A09B4(void) +// The first 3 questions answered after meeting the Apprentice are always selecting party mons +// after which this is never called +static void GetNumApprenticePartyMonsAssigned(void) { - gSpecialVar_Result = PLAYER_APPRENTICE.field_B1_1; + gSpecialVar_Result = PLAYER_APPRENTICE.questionsAnswered; } -static void sub_81A09D0(void) +// Never called, APPRENTICE_FUNC_IS_FINAL_QUESTION is unused +static void IsFinalQuestion(void) { - s32 var = PLAYER_APPRENTICE.field_B1_1 - 3; - if (var < 0) + s32 questionNum = CURRENT_QUESTION_NUM; + + if (questionNum < 0) { + // Not finished asking initial questions gSpecialVar_Result = FALSE; } else { - if (var > 8) + if (questionNum > APPRENTICE_MAX_QUESTIONS - 1) gSpecialVar_Result = TRUE; - if (!PLAYER_APPRENTICE.field_B8[var].unk0_0) + if (PLAYER_APPRENTICE.questions[questionNum].questionId == QUESTION_ID_WIN_SPEECH) gSpecialVar_Result = TRUE; else gSpecialVar_Result = FALSE; @@ -1722,7 +822,7 @@ static void sub_81A09D0(void) static void Script_CreateApprenticeMenu(void) { - CreateMenuWithAnswers(gSpecialVar_0x8005); + CreateApprenticeMenu(gSpecialVar_0x8005); } static void Task_WaitForPrintingMessage(u8 taskId) @@ -1737,77 +837,77 @@ static void Task_WaitForPrintingMessage(u8 taskId) } } -static void PrintMessage(void) +static void PrintApprenticeMessage(void) { const u8 *string; - if (gSpecialVar_0x8006 == 6) + if (gSpecialVar_0x8006 == APPRENTICE_MSG_WHICH_MON) { - string = gUnknown_08610FF0[PLAYER_APPRENTICE.id][0]; + string = sApprenticeWhichMonTexts[PLAYER_APPRENTICE.id][0]; } - else if (gSpecialVar_0x8006 == 7) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_THANKS_MON) { - string = gUnknown_08610FF0[PLAYER_APPRENTICE.id][1]; + string = sApprenticeWhichMonTexts[PLAYER_APPRENTICE.id][1]; } - else if (gSpecialVar_0x8006 == 8) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_WHICH_MOVE) { - string = gUnknown_086111B0[PLAYER_APPRENTICE.id][0]; + string = sApprenticeWhichMoveTexts[PLAYER_APPRENTICE.id][0]; } - else if (gSpecialVar_0x8006 == 9) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_THANKS_MOVE) { - string = gUnknown_086111B0[PLAYER_APPRENTICE.id][1]; + string = sApprenticeWhichMoveTexts[PLAYER_APPRENTICE.id][1]; } - else if (gSpecialVar_0x8006 == 4) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_WHICH_MON_FIRST) { - string = gUnknown_08611230[PLAYER_APPRENTICE.id][0]; + string = sApprenticeWhichMonFirstTexts[PLAYER_APPRENTICE.id][0]; } - else if (gSpecialVar_0x8006 == 5) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_THANKS_MON_FIRST) { - string = gUnknown_08611230[PLAYER_APPRENTICE.id][1]; + string = sApprenticeWhichMonFirstTexts[PLAYER_APPRENTICE.id][1]; } - else if (gSpecialVar_0x8006 == 10) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_WHAT_HELD_ITEM) { - string = gUnknown_08611070[PLAYER_APPRENTICE.id][0]; + string = sApprenticeHeldItemTexts[PLAYER_APPRENTICE.id][0]; } - else if (gSpecialVar_0x8006 == 11) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_PICK_WIN_SPEECH) { - string = gUnknown_086112B0[PLAYER_APPRENTICE.id][0]; + string = sApprenticePickWinSpeechTexts[PLAYER_APPRENTICE.id][0]; } - else if (gSpecialVar_0x8006 == 12) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_THANKS_HELD_ITEM) { - string = gUnknown_08611070[PLAYER_APPRENTICE.id][3]; + string = sApprenticeHeldItemTexts[PLAYER_APPRENTICE.id][3]; } - else if (gSpecialVar_0x8006 == 13) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_HOLD_NOTHING) { - string = gUnknown_08611070[PLAYER_APPRENTICE.id][1]; + string = sApprenticeHeldItemTexts[PLAYER_APPRENTICE.id][1]; } - else if (gSpecialVar_0x8006 == 16) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_ITEM_ALREADY_SUGGESTED) { - string = gUnknown_08611070[PLAYER_APPRENTICE.id][4]; + string = sApprenticeHeldItemTexts[PLAYER_APPRENTICE.id][4]; } - else if (gSpecialVar_0x8006 == 14) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_THANKS_NO_HELD_ITEM) { - string = gUnknown_08611070[PLAYER_APPRENTICE.id][2]; + string = sApprenticeHeldItemTexts[PLAYER_APPRENTICE.id][2]; } - else if (gSpecialVar_0x8006 == 15) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_THANKS_WIN_SPEECH) { - string = gUnknown_086112B0[PLAYER_APPRENTICE.id][1]; + string = sApprenticePickWinSpeechTexts[PLAYER_APPRENTICE.id][1]; } - else if (gSpecialVar_0x8006 == 0) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_PLEASE_TEACH) { - string = gUnknown_08610EF0[PLAYER_APPRENTICE.id][0]; + string = sApprenticeFirstMeetingTexts[PLAYER_APPRENTICE.id][0]; } - else if (gSpecialVar_0x8006 == 1) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_REJECT) { - string = gUnknown_08610EF0[PLAYER_APPRENTICE.id][1]; + string = sApprenticeFirstMeetingTexts[PLAYER_APPRENTICE.id][1]; } - else if (gSpecialVar_0x8006 == 2) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_WHICH_LVL_MODE) { - string = gUnknown_08610EF0[PLAYER_APPRENTICE.id][2]; + string = sApprenticeFirstMeetingTexts[PLAYER_APPRENTICE.id][2]; } - else if (gSpecialVar_0x8006 == 3) + else if (gSpecialVar_0x8006 == APPRENTICE_MSG_THANKS_LVL_MODE) { - string = gUnknown_08610EF0[PLAYER_APPRENTICE.id][3]; + string = sApprenticeFirstMeetingTexts[PLAYER_APPRENTICE.id][3]; } else { @@ -1820,121 +920,129 @@ static void PrintMessage(void) CreateTask(Task_WaitForPrintingMessage, 1); } -static void Script_PrintMessage(void) +static void Script_PrintApprenticeMessage(void) { ScriptContext2_Enable(); FreezeEventObjects(); sub_808B864(); sub_808BCF4(); DrawDialogueFrame(0, 1); - PrintMessage(); + PrintApprenticeMessage(); } -static void sub_81A0CC0(void) +static void ApprenticeGetQuestion(void) { - if (PLAYER_APPRENTICE.field_B1_1 < 3) + if (PLAYER_APPRENTICE.questionsAnswered < NUM_WHICH_MON_QUESTIONS) { - gSpecialVar_Result = 2; + gSpecialVar_Result = APPRENTICE_QUESTION_WHICH_MON; } - else if (PLAYER_APPRENTICE.field_B1_1 > 11) + else if (PLAYER_APPRENTICE.questionsAnswered > (APPRENTICE_MAX_QUESTIONS + NUM_WHICH_MON_QUESTIONS - 1)) { - gSpecialVar_Result = 5; + gSpecialVar_Result = APPRENTICE_QUESTION_WIN_SPEECH; } else { - s32 id = PLAYER_APPRENTICE.field_B1_1 - 3; - switch (PLAYER_APPRENTICE.field_B8[id].unk0_0) + s32 id = CURRENT_QUESTION_NUM; + switch (PLAYER_APPRENTICE.questions[id].questionId) { - case 1: - gSpecialVar_Result = 4; + case QUESTION_ID_WHAT_ITEM: + gSpecialVar_Result = APPRENTICE_QUESTION_WHAT_ITEM; break; - case 2: - gSpecialVar_Result = 3; + case QUESTION_ID_WHICH_MOVE: + gSpecialVar_Result = APPRENTICE_QUESTION_WHICH_MOVE; break; - case 3: - gSpecialVar_Result = 1; + case QUESTION_ID_WHICH_FIRST: + gSpecialVar_Result = APPRENTICE_QUESTION_WHICH_FIRST; break; default: - gSpecialVar_Result = 5; + //case QUESTION_ID_WIN_SPEECH: + gSpecialVar_Result = APPRENTICE_QUESTION_WIN_SPEECH; break; } } } -static void sub_81A0D40(void) +// gSpecialVar_0x8005 is 0 or 1 for the mon selection (0 is already on the team) +// gSpecialVar_0x8006 is 0-2 for the number of party mons selected so far +static void SetApprenticePartyMon(void) { if (gSpecialVar_0x8005) { - u8 bitNo = gSpecialVar_0x8006; - PLAYER_APPRENTICE.field_B2_0 |= 1 << bitNo; + u8 partySlot = gSpecialVar_0x8006; + PLAYER_APPRENTICE.party |= 1 << partySlot; } } -static void sub_81A0D80(void) +// gSpecialVar_0x8005 is 0 or 1 for the move selection +// Selection 0 is implicitly the default move assigned +static void SetApprenticeMonMove(void) { - if (PLAYER_APPRENTICE.field_B1_1 >= 3) + if (PLAYER_APPRENTICE.questionsAnswered >= NUM_WHICH_MON_QUESTIONS) { - u8 id = PLAYER_APPRENTICE.field_B1_1 - 3; + u8 id = CURRENT_QUESTION_NUM; if (gSpecialVar_0x8005) - PLAYER_APPRENTICE.field_B8[id].unk0_3 = 1; + PLAYER_APPRENTICE.questions[id].suggestedChange = TRUE; else - PLAYER_APPRENTICE.field_B8[id].unk0_3 = 0; + PLAYER_APPRENTICE.questions[id].suggestedChange = FALSE; } } -static void sub_81A0DD4(void) +static void InitQuestionData(void) { u8 i; u8 count = 0; u8 id1, id2; - for (i = 0; i < 9 && PLAYER_APPRENTICE.field_B8[i].unk0_0; count++, i++) + for (i = 0; i < APPRENTICE_MAX_QUESTIONS && (PLAYER_APPRENTICE.questions[i].questionId != QUESTION_ID_WIN_SPEECH); count++, i++) ; - gUnknown_030062F0 = AllocZeroed(sizeof(*gUnknown_030062F0)); - if (gSpecialVar_0x8005 == 2) + gApprenticeQuestionData = AllocZeroed(sizeof(*gApprenticeQuestionData)); + if (gSpecialVar_0x8005 == APPRENTICE_QUESTION_WHICH_MON) { - if (PLAYER_APPRENTICE.field_B1_1 < 3) + if (PLAYER_APPRENTICE.questionsAnswered < NUM_WHICH_MON_QUESTIONS) { - id1 = PLAYER_APPRENTICE.monIds[PLAYER_APPRENTICE.field_B1_1] >> 4; - gUnknown_030062F0->unk2 = gApprentices[PLAYER_APPRENTICE.id].species[id1]; + // For the first MULTI_PARTY_SIZE (3) questions, a mon is asked to be selected for the Apprentice's party + id1 = PLAYER_APPRENTICE.speciesIds[PLAYER_APPRENTICE.questionsAnswered] >> 4; + gApprenticeQuestionData->altSpeciesId = gApprentices[PLAYER_APPRENTICE.id].species[id1]; - id2 = PLAYER_APPRENTICE.monIds[PLAYER_APPRENTICE.field_B1_1] & 0xF; - gUnknown_030062F0->unk0 = gApprentices[PLAYER_APPRENTICE.id].species[id2]; + id2 = PLAYER_APPRENTICE.speciesIds[PLAYER_APPRENTICE.questionsAnswered] & 0xF; + gApprenticeQuestionData->speciesId = gApprentices[PLAYER_APPRENTICE.id].species[id2]; } } - else if (gSpecialVar_0x8005 == 3) + else if (gSpecialVar_0x8005 == APPRENTICE_QUESTION_WHICH_MOVE) { - if (PLAYER_APPRENTICE.field_B1_1 >= 3 - && PLAYER_APPRENTICE.field_B1_1 < count + 3 - && PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk0_0 == 2) + if (PLAYER_APPRENTICE.questionsAnswered >= NUM_WHICH_MON_QUESTIONS + && PLAYER_APPRENTICE.questionsAnswered < count + NUM_WHICH_MON_QUESTIONS + && PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].questionId == QUESTION_ID_WHICH_MOVE) { - count = PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk0_1; + // count re-used as monId + count = PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].monId; APPRENTICE_SPECIES_ID_2(id1, count); - gUnknown_030062F0->unk0 = gApprentices[PLAYER_APPRENTICE.id].species[id1]; - gUnknown_030062F0->unk4 = sub_81A0284(count, id1, PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk0_2); - gUnknown_030062F0->unk6 = PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk2; + gApprenticeQuestionData->speciesId = gApprentices[PLAYER_APPRENTICE.id].species[id1]; + gApprenticeQuestionData->moveId1 = GetDefaultMove(count, id1, PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].moveSlot); + gApprenticeQuestionData->moveId2 = PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].data; } } - else if (gSpecialVar_0x8005 == 4) + else if (gSpecialVar_0x8005 == APPRENTICE_QUESTION_WHAT_ITEM) { - if (PLAYER_APPRENTICE.field_B1_1 >= 3 - && PLAYER_APPRENTICE.field_B1_1 < count + 3 - && PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk0_0 == 1) + if (PLAYER_APPRENTICE.questionsAnswered >= NUM_WHICH_MON_QUESTIONS + && PLAYER_APPRENTICE.questionsAnswered < count + NUM_WHICH_MON_QUESTIONS + && PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].questionId == QUESTION_ID_WHAT_ITEM) { - count = PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk0_1; + // count re-used as monId + count = PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].monId; APPRENTICE_SPECIES_ID_2(id2, count); - gUnknown_030062F0->unk0 = gApprentices[PLAYER_APPRENTICE.id].species[id2]; + gApprenticeQuestionData->speciesId = gApprentices[PLAYER_APPRENTICE.id].species[id2]; } } } -static void sub_81A0FE4(void) +static void FreeQuestionData(void) { - FREE_AND_SET_NULL(gUnknown_030062F0); + FREE_AND_SET_NULL(gApprenticeQuestionData); } -static void sub_81A0FFC(void) +static void ApprenticeBufferString(void) { u8 *stringDst; u8 text[16]; @@ -1958,41 +1066,41 @@ static void sub_81A0FFC(void) switch (gSpecialVar_0x8006) { case APPRENTICE_BUFF_SPECIES1: - StringCopy(stringDst, gSpeciesNames[gUnknown_030062F0->unk0]); + StringCopy(stringDst, gSpeciesNames[gApprenticeQuestionData->speciesId]); break; case APPRENTICE_BUFF_SPECIES2: - StringCopy(stringDst, gSpeciesNames[gUnknown_030062F0->unk2]); + StringCopy(stringDst, gSpeciesNames[gApprenticeQuestionData->altSpeciesId]); break; case APPRENTICE_BUFF_SPECIES3: - StringCopy(stringDst, gSpeciesNames[gUnknown_030062F0->unk0]); + StringCopy(stringDst, gSpeciesNames[gApprenticeQuestionData->speciesId]); break; case APPRENTICE_BUFF_MOVE1: - StringCopy(stringDst, gMoveNames[gUnknown_030062F0->unk4]); + StringCopy(stringDst, gMoveNames[gApprenticeQuestionData->moveId1]); break; case APPRENTICE_BUFF_MOVE2: - StringCopy(stringDst, gMoveNames[gUnknown_030062F0->unk6]); + StringCopy(stringDst, gMoveNames[gApprenticeQuestionData->moveId2]); break; case APPRENTICE_BUFF_ITEM: - StringCopy(stringDst, ItemId_GetName(PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk2)); + StringCopy(stringDst, ItemId_GetName(PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].data)); break; case APPRENTICE_BUFF_NAME: TVShowConvertInternationalString(text, GetApprenticeNameInLanguage(PLAYER_APPRENTICE.id, LANGUAGE_ENGLISH), LANGUAGE_ENGLISH); StringCopy(stringDst, text); break; case APPRENTICE_BUFF_LEVEL: - if (PLAYER_APPRENTICE.activeLvlMode == 1) + if (PLAYER_APPRENTICE.lvlMode == APPRENTICE_LVL_MODE_50) StringCopy(stringDst, gText_Lv50); - else + else // == APPRENTICE_LVL_MODE_OPEN StringCopy(stringDst, gText_OpenLevel); break; - case APPRENTICE_BUFF_EASY_CHAT: - FrontierSpeechToString(gSaveBlock2Ptr->apprentices[0].easyChatWords); + case APPRENTICE_BUFF_WIN_SPEECH: + FrontierSpeechToString(gSaveBlock2Ptr->apprentices[0].speechWon); StringCopy(stringDst, gStringVar4); break; - case APPRENTICE_BUFF_SPECIES4: - if (PLAYER_APPRENTICE.field_B1_2 < 3) + case APPRENTICE_BUFF_LEAD_MON_SPECIES: + if (PLAYER_APPRENTICE.leadMonId < MULTI_PARTY_SIZE) { - APPRENTICE_SPECIES_ID(speciesArrayId, PLAYER_APPRENTICE.field_B1_2); + APPRENTICE_SPECIES_ID(speciesArrayId, PLAYER_APPRENTICE.leadMonId); } else { @@ -2003,56 +1111,57 @@ static void sub_81A0FFC(void) } } -static void sub_81A11F8(void) +static void SetLeadApprenticeMon(void) { - PLAYER_APPRENTICE.field_B1_2 = gSpecialVar_0x8005; + PLAYER_APPRENTICE.leadMonId = gSpecialVar_0x8005; } -static void sub_81A1218(void) +static void Script_ApprenticeOpenBagMenu(void) { - sub_81AAC28(); + ApprenticeOpenBagMenu(); } -static void sub_81A1224(void) +static void TrySetApprenticeHeldItem(void) { u8 i, j; u8 count; - if (PLAYER_APPRENTICE.field_B1_1 < 3) + if (PLAYER_APPRENTICE.questionsAnswered < NUM_WHICH_MON_QUESTIONS) return; - for (count = 0, j = 0; j < 9 && PLAYER_APPRENTICE.field_B8[j].unk0_0; count++, j++) + for (count = 0, j = 0; j < APPRENTICE_MAX_QUESTIONS && PLAYER_APPRENTICE.questions[j].questionId != QUESTION_ID_WIN_SPEECH; count++, j++) ; - for (i = 0; i < count && i < PLAYER_APPRENTICE.field_B1_1 - 3; i++) + // Make sure the item hasnt already been suggested in previous questions + for (i = 0; i < count && i < CURRENT_QUESTION_NUM; i++) { do {} while(0); - if (PLAYER_APPRENTICE.field_B8[i].unk0_0 == 1 - && PLAYER_APPRENTICE.field_B8[i].unk0_3 - && PLAYER_APPRENTICE.field_B8[i].unk2 == gSpecialVar_0x8005) + if (PLAYER_APPRENTICE.questions[i].questionId == QUESTION_ID_WHAT_ITEM + && PLAYER_APPRENTICE.questions[i].suggestedChange + && PLAYER_APPRENTICE.questions[i].data == gSpecialVar_0x8005) { - PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk0_3 = 0; - PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk2 = gSpecialVar_0x8005; - gSpecialVar_Result = 0; + PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].suggestedChange = FALSE; + PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].data = gSpecialVar_0x8005; + gSpecialVar_Result = FALSE; return; } } - PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk0_3 = 1; - PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk2 = gSpecialVar_0x8005; - gSpecialVar_Result = 1; + PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].suggestedChange = TRUE; + PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].data = gSpecialVar_0x8005; + gSpecialVar_Result = TRUE; } -static void sub_81A1370(void) +static void ShiftSavedApprentices(void) { s32 i; - s32 r10; - s32 r9; + s32 apprenticeNum; + s32 apprenticeIdx; if (gSaveBlock2Ptr->apprentices[0].playerName[0] == EOS) return; - for (i = 0; i < 3; i++) + for (i = 0; i < APPRENTICE_COUNT - 1; i++) { if (gSaveBlock2Ptr->apprentices[i + 1].playerName[0] == EOS) { @@ -2061,37 +1170,39 @@ static void sub_81A1370(void) } } - r10 = 0xFFFF; - r9 = -1; - for (i = 1; i < TRAINER_ID_LENGTH; i++) + apprenticeNum = 0xFFFF; + apprenticeIdx = -1; + for (i = 1; i < APPRENTICE_COUNT; i++) { if (GetTrainerId(gSaveBlock2Ptr->apprentices[i].playerId) == GetTrainerId(gSaveBlock2Ptr->playerTrainerId) - && gSaveBlock2Ptr->apprentices[i].number < r10) + && gSaveBlock2Ptr->apprentices[i].number < apprenticeNum) { - r10 = gSaveBlock2Ptr->apprentices[i].number; - r9 = i; + apprenticeNum = gSaveBlock2Ptr->apprentices[i].number; + apprenticeIdx = i; } } - if (r9 > 0) - gSaveBlock2Ptr->apprentices[r9] = gSaveBlock2Ptr->apprentices[0]; + if (apprenticeIdx > 0) + gSaveBlock2Ptr->apprentices[apprenticeIdx] = gSaveBlock2Ptr->apprentices[0]; } -static void sub_81A1438(void) +// Apprentice is always saved in the first slot. Pre-existing Apprentices are moved by ShiftSavedApprentices +static void SaveApprentice(void) { u8 i; gSaveBlock2Ptr->apprentices[0].id = PLAYER_APPRENTICE.id; - gSaveBlock2Ptr->apprentices[0].lvlMode = PLAYER_APPRENTICE.activeLvlMode; + gSaveBlock2Ptr->apprentices[0].lvlMode = PLAYER_APPRENTICE.lvlMode; - for (i = 0; i < 9 && PLAYER_APPRENTICE.field_B8[i].unk0_0; i++) + // Count questions asked until the final (win speech) question was reached + for (i = 0; i < APPRENTICE_MAX_QUESTIONS && (PLAYER_APPRENTICE.questions[i].questionId != QUESTION_ID_WIN_SPEECH); i++) ; - gSaveBlock2Ptr->apprentices[0].field_1 = i; + gSaveBlock2Ptr->apprentices[0].numQuestions = i; if (gSaveBlock2Ptr->apprentices[0].number < 255) gSaveBlock2Ptr->apprentices[0].number++; - sub_81A0390(gSaveBlock2Ptr->apprentices[0].field_1); + SaveApprenticeParty(gSaveBlock2Ptr->apprentices[0].numQuestions); for (i = 0; i < TRAINER_ID_LENGTH; i++) gSaveBlock2Ptr->apprentices[0].playerId[i] = gSaveBlock2Ptr->playerTrainerId[i]; @@ -2100,13 +1211,13 @@ static void sub_81A1438(void) CalcApprenticeChecksum(&gSaveBlock2Ptr->apprentices[0]); } -static void sub_81A150C(void) +// Never called, APPRENTICE_FUNC_SET_GFX_SAVED is unused +static void SetSavedApprenticeTrainerGfxId(void) { u8 i; u8 mapObjectGfxId; u8 class = gApprentices[gSaveBlock2Ptr->apprentices[0].id].facilityClass; - // Search male classes. for (i = 0; i < ARRAY_COUNT(gTowerMaleFacilityClasses) && gTowerMaleFacilityClasses[i] != class; i++) ; if (i != ARRAY_COUNT(gTowerMaleFacilityClasses)) @@ -2125,7 +1236,7 @@ static void sub_81A150C(void) } } -static void Script_SetPlayerApprenticeTrainerGfxId(void) +static void SetPlayerApprenticeTrainerGfxId(void) { u8 i; u8 mapObjectGfxId; @@ -2149,14 +1260,16 @@ static void Script_SetPlayerApprenticeTrainerGfxId(void) } } -static void sub_81A1638(void) +// Both of the below functions may have been dummied / used for debug +// In all cases theres a conditional for VAR_0x8004 right after the call to these functions +static void GetShouldCheckApprenticeGone(void) { - gSpecialVar_0x8004 = 1; + gSpecialVar_0x8004 = TRUE; } -static void sub_81A1644(void) +static void GetShouldApprenticeLeave(void) { - gSpecialVar_0x8004 = 1; + gSpecialVar_0x8004 = TRUE; } const u8 *GetApprenticeNameInLanguage(u32 apprenticeId, s32 language) @@ -2181,7 +1294,8 @@ const u8 *GetApprenticeNameInLanguage(u32 apprenticeId, s32 language) } } -static void sub_81A16B4(u8 taskId) +// Functionally unused +static void Task_SwitchToFollowupFuncAfterButtonPress(u8 taskId) { if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) SwitchTaskToFollowupFunc(taskId); @@ -2191,8 +1305,8 @@ static void Task_ExecuteFuncAfterButtonPress(u8 taskId) { if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) { - gUnknown_030062F4 = (void*)(u32)(((u16)gTasks[taskId].data[0] | (gTasks[taskId].data[1] << 0x10))); - gUnknown_030062F4(); + gApprenticeFunc = (void*)(u32)(((u16)gTasks[taskId].data[0] | (gTasks[taskId].data[1] << 16))); + gApprenticeFunc(); DestroyTask(taskId); } } @@ -2204,8 +1318,9 @@ static void ExecuteFuncAfterButtonPress(void (*func)(void)) gTasks[taskId].data[1] = (u32)(func) >> 16; } -static void sub_81A175C(TaskFunc taskFunc) +// Unused +static void ExecuteFollowupFuncAfterButtonPress(TaskFunc task) { - u8 taskId = CreateTask(sub_81A16B4, 1); - SetTaskFuncWithFollowupFunc(taskId, sub_81A16B4, taskFunc); + u8 taskId = CreateTask(Task_SwitchToFollowupFuncAfterButtonPress, 1); + SetTaskFuncWithFollowupFunc(taskId, Task_SwitchToFollowupFuncAfterButtonPress, task); } diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index b581a8bbc..c9a6a6606 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -54,105 +54,105 @@ static void BattleAI_DoAIProcessing(void); static void AIStackPushVar(const u8 *); static bool8 AIStackPop(void); -static void BattleAICmd_if_random_less_than(void); -static void BattleAICmd_if_random_greater_than(void); -static void BattleAICmd_if_random_equal(void); -static void BattleAICmd_if_random_not_equal(void); -static void BattleAICmd_score(void); -static void BattleAICmd_if_hp_less_than(void); -static void BattleAICmd_if_hp_more_than(void); -static void BattleAICmd_if_hp_equal(void); -static void BattleAICmd_if_hp_not_equal(void); -static void BattleAICmd_if_status(void); -static void BattleAICmd_if_not_status(void); -static void BattleAICmd_if_status2(void); -static void BattleAICmd_if_not_status2(void); -static void BattleAICmd_if_status3(void); -static void BattleAICmd_if_not_status3(void); -static void BattleAICmd_if_side_affecting(void); -static void BattleAICmd_if_not_side_affecting(void); -static void BattleAICmd_if_less_than(void); -static void BattleAICmd_if_more_than(void); -static void BattleAICmd_if_equal(void); -static void BattleAICmd_if_not_equal(void); -static void BattleAICmd_if_less_than_ptr(void); -static void BattleAICmd_if_more_than_ptr(void); -static void BattleAICmd_if_equal_ptr(void); -static void BattleAICmd_if_not_equal_ptr(void); -static void BattleAICmd_if_move(void); -static void BattleAICmd_if_not_move(void); -static void BattleAICmd_if_in_bytes(void); -static void BattleAICmd_if_not_in_bytes(void); -static void BattleAICmd_if_in_hwords(void); -static void BattleAICmd_if_not_in_hwords(void); -static void BattleAICmd_if_user_has_attacking_move(void); -static void BattleAICmd_if_user_has_no_attacking_moves(void); -static void BattleAICmd_get_turn_count(void); -static void BattleAICmd_get_type(void); -static void BattleAICmd_get_considered_move_power(void); -static void BattleAICmd_get_how_powerful_move_is(void); -static void BattleAICmd_get_last_used_battler_move(void); -static void BattleAICmd_if_equal_(void); -static void BattleAICmd_if_not_equal_(void); -static void BattleAICmd_if_user_goes(void); -static void BattleAICmd_if_user_doesnt_go(void); -static void BattleAICmd_nullsub_2A(void); -static void BattleAICmd_nullsub_2B(void); -static void BattleAICmd_count_usable_party_mons(void); -static void BattleAICmd_get_considered_move(void); -static void BattleAICmd_get_considered_move_effect(void); -static void BattleAICmd_get_ability(void); -static void BattleAICmd_get_highest_type_effectiveness(void); -static void BattleAICmd_if_type_effectiveness(void); -static void BattleAICmd_nullsub_32(void); -static void BattleAICmd_nullsub_33(void); -static void BattleAICmd_if_status_in_party(void); -static void BattleAICmd_if_status_not_in_party(void); -static void BattleAICmd_get_weather(void); -static void BattleAICmd_if_effect(void); -static void BattleAICmd_if_not_effect(void); -static void BattleAICmd_if_stat_level_less_than(void); -static void BattleAICmd_if_stat_level_more_than(void); -static void BattleAICmd_if_stat_level_equal(void); -static void BattleAICmd_if_stat_level_not_equal(void); -static void BattleAICmd_if_can_faint(void); -static void BattleAICmd_if_cant_faint(void); -static void BattleAICmd_if_has_move(void); -static void BattleAICmd_if_doesnt_have_move(void); -static void BattleAICmd_if_has_move_with_effect(void); -static void BattleAICmd_if_doesnt_have_move_with_effect(void); -static void BattleAICmd_if_any_move_disabled_or_encored(void); -static void BattleAICmd_if_curr_move_disabled_or_encored(void); -static void BattleAICmd_flee(void); -static void BattleAICmd_if_random_safari_flee(void); -static void BattleAICmd_watch(void); -static void BattleAICmd_get_hold_effect(void); -static void BattleAICmd_get_gender(void); -static void BattleAICmd_is_first_turn_for(void); -static void BattleAICmd_get_stockpile_count(void); -static void BattleAICmd_is_double_battle(void); -static void BattleAICmd_get_used_held_item(void); -static void BattleAICmd_get_move_type_from_result(void); -static void BattleAICmd_get_move_power_from_result(void); -static void BattleAICmd_get_move_effect_from_result(void); -static void BattleAICmd_get_protect_count(void); -static void BattleAICmd_nullsub_52(void); -static void BattleAICmd_nullsub_53(void); -static void BattleAICmd_nullsub_54(void); -static void BattleAICmd_nullsub_55(void); -static void BattleAICmd_nullsub_56(void); -static void BattleAICmd_nullsub_57(void); -static void BattleAICmd_call(void); -static void BattleAICmd_goto(void); -static void BattleAICmd_end(void); -static void BattleAICmd_if_level_cond(void); -static void BattleAICmd_if_target_taunted(void); -static void BattleAICmd_if_target_not_taunted(void); -static void BattleAICmd_check_ability(void); -static void BattleAICmd_is_of_type(void); -static void BattleAICmd_if_target_is_ally(void); -static void BattleAICmd_if_flash_fired(void); -static void BattleAICmd_if_holds_item(void); +static void Cmd_if_random_less_than(void); +static void Cmd_if_random_greater_than(void); +static void Cmd_if_random_equal(void); +static void Cmd_if_random_not_equal(void); +static void Cmd_score(void); +static void Cmd_if_hp_less_than(void); +static void Cmd_if_hp_more_than(void); +static void Cmd_if_hp_equal(void); +static void Cmd_if_hp_not_equal(void); +static void Cmd_if_status(void); +static void Cmd_if_not_status(void); +static void Cmd_if_status2(void); +static void Cmd_if_not_status2(void); +static void Cmd_if_status3(void); +static void Cmd_if_not_status3(void); +static void Cmd_if_side_affecting(void); +static void Cmd_if_not_side_affecting(void); +static void Cmd_if_less_than(void); +static void Cmd_if_more_than(void); +static void Cmd_if_equal(void); +static void Cmd_if_not_equal(void); +static void Cmd_if_less_than_ptr(void); +static void Cmd_if_more_than_ptr(void); +static void Cmd_if_equal_ptr(void); +static void Cmd_if_not_equal_ptr(void); +static void Cmd_if_move(void); +static void Cmd_if_not_move(void); +static void Cmd_if_in_bytes(void); +static void Cmd_if_not_in_bytes(void); +static void Cmd_if_in_hwords(void); +static void Cmd_if_not_in_hwords(void); +static void Cmd_if_user_has_attacking_move(void); +static void Cmd_if_user_has_no_attacking_moves(void); +static void Cmd_get_turn_count(void); +static void Cmd_get_type(void); +static void Cmd_get_considered_move_power(void); +static void Cmd_get_how_powerful_move_is(void); +static void Cmd_get_last_used_battler_move(void); +static void Cmd_if_equal_(void); +static void Cmd_if_not_equal_(void); +static void Cmd_if_user_goes(void); +static void Cmd_if_user_doesnt_go(void); +static void Cmd_nullsub_2A(void); +static void Cmd_nullsub_2B(void); +static void Cmd_count_usable_party_mons(void); +static void Cmd_get_considered_move(void); +static void Cmd_get_considered_move_effect(void); +static void Cmd_get_ability(void); +static void Cmd_get_highest_type_effectiveness(void); +static void Cmd_if_type_effectiveness(void); +static void Cmd_nullsub_32(void); +static void Cmd_nullsub_33(void); +static void Cmd_if_status_in_party(void); +static void Cmd_if_status_not_in_party(void); +static void Cmd_get_weather(void); +static void Cmd_if_effect(void); +static void Cmd_if_not_effect(void); +static void Cmd_if_stat_level_less_than(void); +static void Cmd_if_stat_level_more_than(void); +static void Cmd_if_stat_level_equal(void); +static void Cmd_if_stat_level_not_equal(void); +static void Cmd_if_can_faint(void); +static void Cmd_if_cant_faint(void); +static void Cmd_if_has_move(void); +static void Cmd_if_doesnt_have_move(void); +static void Cmd_if_has_move_with_effect(void); +static void Cmd_if_doesnt_have_move_with_effect(void); +static void Cmd_if_any_move_disabled_or_encored(void); +static void Cmd_if_curr_move_disabled_or_encored(void); +static void Cmd_flee(void); +static void Cmd_if_random_safari_flee(void); +static void Cmd_watch(void); +static void Cmd_get_hold_effect(void); +static void Cmd_get_gender(void); +static void Cmd_is_first_turn_for(void); +static void Cmd_get_stockpile_count(void); +static void Cmd_is_double_battle(void); +static void Cmd_get_used_held_item(void); +static void Cmd_get_move_type_from_result(void); +static void Cmd_get_move_power_from_result(void); +static void Cmd_get_move_effect_from_result(void); +static void Cmd_get_protect_count(void); +static void Cmd_nullsub_52(void); +static void Cmd_nullsub_53(void); +static void Cmd_nullsub_54(void); +static void Cmd_nullsub_55(void); +static void Cmd_nullsub_56(void); +static void Cmd_nullsub_57(void); +static void Cmd_call(void); +static void Cmd_goto(void); +static void Cmd_end(void); +static void Cmd_if_level_cond(void); +static void Cmd_if_target_taunted(void); +static void Cmd_if_target_not_taunted(void); +static void Cmd_check_ability(void); +static void Cmd_is_of_type(void); +static void Cmd_if_target_is_ally(void); +static void Cmd_if_flash_fired(void); +static void Cmd_if_holds_item(void); // ewram EWRAM_DATA const u8 *gAIScriptPtr = NULL; @@ -163,105 +163,105 @@ typedef void (*BattleAICmdFunc)(void); static const BattleAICmdFunc sBattleAICmdTable[] = { - BattleAICmd_if_random_less_than, // 0x0 - BattleAICmd_if_random_greater_than, // 0x1 - BattleAICmd_if_random_equal, // 0x2 - BattleAICmd_if_random_not_equal, // 0x3 - BattleAICmd_score, // 0x4 - BattleAICmd_if_hp_less_than, // 0x5 - BattleAICmd_if_hp_more_than, // 0x6 - BattleAICmd_if_hp_equal, // 0x7 - BattleAICmd_if_hp_not_equal, // 0x8 - BattleAICmd_if_status, // 0x9 - BattleAICmd_if_not_status, // 0xA - BattleAICmd_if_status2, // 0xB - BattleAICmd_if_not_status2, // 0xC - BattleAICmd_if_status3, // 0xD - BattleAICmd_if_not_status3, // 0xE - BattleAICmd_if_side_affecting, // 0xF - BattleAICmd_if_not_side_affecting, // 0x10 - BattleAICmd_if_less_than, // 0x11 - BattleAICmd_if_more_than, // 0x12 - BattleAICmd_if_equal, // 0x13 - BattleAICmd_if_not_equal, // 0x14 - BattleAICmd_if_less_than_ptr, // 0x15 - BattleAICmd_if_more_than_ptr, // 0x16 - BattleAICmd_if_equal_ptr, // 0x17 - BattleAICmd_if_not_equal_ptr, // 0x18 - BattleAICmd_if_move, // 0x19 - BattleAICmd_if_not_move, // 0x1A - BattleAICmd_if_in_bytes, // 0x1B - BattleAICmd_if_not_in_bytes, // 0x1C - BattleAICmd_if_in_hwords, // 0x1D - BattleAICmd_if_not_in_hwords, // 0x1E - BattleAICmd_if_user_has_attacking_move, // 0x1F - BattleAICmd_if_user_has_no_attacking_moves, // 0x20 - BattleAICmd_get_turn_count, // 0x21 - BattleAICmd_get_type, // 0x22 - BattleAICmd_get_considered_move_power, // 0x23 - BattleAICmd_get_how_powerful_move_is, // 0x24 - BattleAICmd_get_last_used_battler_move, // 0x25 - BattleAICmd_if_equal_, // 0x26 - BattleAICmd_if_not_equal_, // 0x27 - BattleAICmd_if_user_goes, // 0x28 - BattleAICmd_if_user_doesnt_go, // 0x29 - BattleAICmd_nullsub_2A, // 0x2A - BattleAICmd_nullsub_2B, // 0x2B - BattleAICmd_count_usable_party_mons, // 0x2C - BattleAICmd_get_considered_move, // 0x2D - BattleAICmd_get_considered_move_effect, // 0x2E - BattleAICmd_get_ability, // 0x2F - BattleAICmd_get_highest_type_effectiveness, // 0x30 - BattleAICmd_if_type_effectiveness, // 0x31 - BattleAICmd_nullsub_32, // 0x32 - BattleAICmd_nullsub_33, // 0x33 - BattleAICmd_if_status_in_party, // 0x34 - BattleAICmd_if_status_not_in_party, // 0x35 - BattleAICmd_get_weather, // 0x36 - BattleAICmd_if_effect, // 0x37 - BattleAICmd_if_not_effect, // 0x38 - BattleAICmd_if_stat_level_less_than, // 0x39 - BattleAICmd_if_stat_level_more_than, // 0x3A - BattleAICmd_if_stat_level_equal, // 0x3B - BattleAICmd_if_stat_level_not_equal, // 0x3C - BattleAICmd_if_can_faint, // 0x3D - BattleAICmd_if_cant_faint, // 0x3E - BattleAICmd_if_has_move, // 0x3F - BattleAICmd_if_doesnt_have_move, // 0x40 - BattleAICmd_if_has_move_with_effect, // 0x41 - BattleAICmd_if_doesnt_have_move_with_effect, // 0x42 - BattleAICmd_if_any_move_disabled_or_encored, // 0x43 - BattleAICmd_if_curr_move_disabled_or_encored, // 0x44 - BattleAICmd_flee, // 0x45 - BattleAICmd_if_random_safari_flee, // 0x46 - BattleAICmd_watch, // 0x47 - BattleAICmd_get_hold_effect, // 0x48 - BattleAICmd_get_gender, // 0x49 - BattleAICmd_is_first_turn_for, // 0x4A - BattleAICmd_get_stockpile_count, // 0x4B - BattleAICmd_is_double_battle, // 0x4C - BattleAICmd_get_used_held_item, // 0x4D - BattleAICmd_get_move_type_from_result, // 0x4E - BattleAICmd_get_move_power_from_result, // 0x4F - BattleAICmd_get_move_effect_from_result, // 0x50 - BattleAICmd_get_protect_count, // 0x51 - BattleAICmd_nullsub_52, // 0x52 - BattleAICmd_nullsub_53, // 0x53 - BattleAICmd_nullsub_54, // 0x54 - BattleAICmd_nullsub_55, // 0x55 - BattleAICmd_nullsub_56, // 0x56 - BattleAICmd_nullsub_57, // 0x57 - BattleAICmd_call, // 0x58 - BattleAICmd_goto, // 0x59 - BattleAICmd_end, // 0x5A - BattleAICmd_if_level_cond, // 0x5B - BattleAICmd_if_target_taunted, // 0x5C - BattleAICmd_if_target_not_taunted, // 0x5D - BattleAICmd_if_target_is_ally, // 0x5E - BattleAICmd_is_of_type, // 0x5F - BattleAICmd_check_ability, // 0x60 - BattleAICmd_if_flash_fired, // 0x61 - BattleAICmd_if_holds_item, // 0x62 + Cmd_if_random_less_than, // 0x0 + Cmd_if_random_greater_than, // 0x1 + Cmd_if_random_equal, // 0x2 + Cmd_if_random_not_equal, // 0x3 + Cmd_score, // 0x4 + Cmd_if_hp_less_than, // 0x5 + Cmd_if_hp_more_than, // 0x6 + Cmd_if_hp_equal, // 0x7 + Cmd_if_hp_not_equal, // 0x8 + Cmd_if_status, // 0x9 + Cmd_if_not_status, // 0xA + Cmd_if_status2, // 0xB + Cmd_if_not_status2, // 0xC + Cmd_if_status3, // 0xD + Cmd_if_not_status3, // 0xE + Cmd_if_side_affecting, // 0xF + Cmd_if_not_side_affecting, // 0x10 + Cmd_if_less_than, // 0x11 + Cmd_if_more_than, // 0x12 + Cmd_if_equal, // 0x13 + Cmd_if_not_equal, // 0x14 + Cmd_if_less_than_ptr, // 0x15 + Cmd_if_more_than_ptr, // 0x16 + Cmd_if_equal_ptr, // 0x17 + Cmd_if_not_equal_ptr, // 0x18 + Cmd_if_move, // 0x19 + Cmd_if_not_move, // 0x1A + Cmd_if_in_bytes, // 0x1B + Cmd_if_not_in_bytes, // 0x1C + Cmd_if_in_hwords, // 0x1D + Cmd_if_not_in_hwords, // 0x1E + Cmd_if_user_has_attacking_move, // 0x1F + Cmd_if_user_has_no_attacking_moves, // 0x20 + Cmd_get_turn_count, // 0x21 + Cmd_get_type, // 0x22 + Cmd_get_considered_move_power, // 0x23 + Cmd_get_how_powerful_move_is, // 0x24 + Cmd_get_last_used_battler_move, // 0x25 + Cmd_if_equal_, // 0x26 + Cmd_if_not_equal_, // 0x27 + Cmd_if_user_goes, // 0x28 + Cmd_if_user_doesnt_go, // 0x29 + Cmd_nullsub_2A, // 0x2A + Cmd_nullsub_2B, // 0x2B + Cmd_count_usable_party_mons, // 0x2C + Cmd_get_considered_move, // 0x2D + Cmd_get_considered_move_effect, // 0x2E + Cmd_get_ability, // 0x2F + Cmd_get_highest_type_effectiveness, // 0x30 + Cmd_if_type_effectiveness, // 0x31 + Cmd_nullsub_32, // 0x32 + Cmd_nullsub_33, // 0x33 + Cmd_if_status_in_party, // 0x34 + Cmd_if_status_not_in_party, // 0x35 + Cmd_get_weather, // 0x36 + Cmd_if_effect, // 0x37 + Cmd_if_not_effect, // 0x38 + Cmd_if_stat_level_less_than, // 0x39 + Cmd_if_stat_level_more_than, // 0x3A + Cmd_if_stat_level_equal, // 0x3B + Cmd_if_stat_level_not_equal, // 0x3C + Cmd_if_can_faint, // 0x3D + Cmd_if_cant_faint, // 0x3E + Cmd_if_has_move, // 0x3F + Cmd_if_doesnt_have_move, // 0x40 + Cmd_if_has_move_with_effect, // 0x41 + Cmd_if_doesnt_have_move_with_effect, // 0x42 + Cmd_if_any_move_disabled_or_encored, // 0x43 + Cmd_if_curr_move_disabled_or_encored, // 0x44 + Cmd_flee, // 0x45 + Cmd_if_random_safari_flee, // 0x46 + Cmd_watch, // 0x47 + Cmd_get_hold_effect, // 0x48 + Cmd_get_gender, // 0x49 + Cmd_is_first_turn_for, // 0x4A + Cmd_get_stockpile_count, // 0x4B + Cmd_is_double_battle, // 0x4C + Cmd_get_used_held_item, // 0x4D + Cmd_get_move_type_from_result, // 0x4E + Cmd_get_move_power_from_result, // 0x4F + Cmd_get_move_effect_from_result, // 0x50 + Cmd_get_protect_count, // 0x51 + Cmd_nullsub_52, // 0x52 + Cmd_nullsub_53, // 0x53 + Cmd_nullsub_54, // 0x54 + Cmd_nullsub_55, // 0x55 + Cmd_nullsub_56, // 0x56 + Cmd_nullsub_57, // 0x57 + Cmd_call, // 0x58 + Cmd_goto, // 0x59 + Cmd_end, // 0x5A + Cmd_if_level_cond, // 0x5B + Cmd_if_target_taunted, // 0x5C + Cmd_if_target_not_taunted, // 0x5D + Cmd_if_target_is_ally, // 0x5E + Cmd_is_of_type, // 0x5F + Cmd_check_ability, // 0x60 + Cmd_if_flash_fired, // 0x61 + Cmd_if_holds_item, // 0x62 }; static const u16 sDiscouragedPowerfulMoveEffects[] = @@ -653,7 +653,7 @@ void ClearBattlerItemEffectHistory(u8 battlerId) BATTLE_HISTORY->itemEffects[battlerId] = 0; } -static void BattleAICmd_if_random_less_than(void) +static void Cmd_if_random_less_than(void) { u16 random = Random(); @@ -663,7 +663,7 @@ static void BattleAICmd_if_random_less_than(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_random_greater_than(void) +static void Cmd_if_random_greater_than(void) { u16 random = Random(); @@ -673,7 +673,7 @@ static void BattleAICmd_if_random_greater_than(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_random_equal(void) +static void Cmd_if_random_equal(void) { u16 random = Random(); @@ -683,7 +683,7 @@ static void BattleAICmd_if_random_equal(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_random_not_equal(void) +static void Cmd_if_random_not_equal(void) { u16 random = Random(); @@ -693,7 +693,7 @@ static void BattleAICmd_if_random_not_equal(void) gAIScriptPtr += 6; } -static void BattleAICmd_score(void) +static void Cmd_score(void) { AI_THINKING_STRUCT->score[AI_THINKING_STRUCT->movesetIndex] += gAIScriptPtr[1]; // Add the result to the array of the move consider's score. @@ -703,7 +703,7 @@ static void BattleAICmd_score(void) gAIScriptPtr += 2; // AI return. } -static void BattleAICmd_if_hp_less_than(void) +static void Cmd_if_hp_less_than(void) { u16 battlerId; @@ -718,7 +718,7 @@ static void BattleAICmd_if_hp_less_than(void) gAIScriptPtr += 7; } -static void BattleAICmd_if_hp_more_than(void) +static void Cmd_if_hp_more_than(void) { u16 battlerId; @@ -733,7 +733,7 @@ static void BattleAICmd_if_hp_more_than(void) gAIScriptPtr += 7; } -static void BattleAICmd_if_hp_equal(void) +static void Cmd_if_hp_equal(void) { u16 battlerId; @@ -748,7 +748,7 @@ static void BattleAICmd_if_hp_equal(void) gAIScriptPtr += 7; } -static void BattleAICmd_if_hp_not_equal(void) +static void Cmd_if_hp_not_equal(void) { u16 battlerId; @@ -763,7 +763,7 @@ static void BattleAICmd_if_hp_not_equal(void) gAIScriptPtr += 7; } -static void BattleAICmd_if_status(void) +static void Cmd_if_status(void) { u16 battlerId; u32 status; @@ -781,7 +781,7 @@ static void BattleAICmd_if_status(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_not_status(void) +static void Cmd_if_not_status(void) { u16 battlerId; u32 status; @@ -799,7 +799,7 @@ static void BattleAICmd_if_not_status(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_status2(void) +static void Cmd_if_status2(void) { u16 battlerId; u32 status; @@ -817,7 +817,7 @@ static void BattleAICmd_if_status2(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_not_status2(void) +static void Cmd_if_not_status2(void) { u16 battlerId; u32 status; @@ -835,7 +835,7 @@ static void BattleAICmd_if_not_status2(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_status3(void) +static void Cmd_if_status3(void) { u16 battlerId; u32 status; @@ -853,7 +853,7 @@ static void BattleAICmd_if_status3(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_not_status3(void) +static void Cmd_if_not_status3(void) { u16 battlerId; u32 status; @@ -871,7 +871,7 @@ static void BattleAICmd_if_not_status3(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_side_affecting(void) +static void Cmd_if_side_affecting(void) { u16 battlerId; u32 side, status; @@ -890,7 +890,7 @@ static void BattleAICmd_if_side_affecting(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_not_side_affecting(void) +static void Cmd_if_not_side_affecting(void) { u16 battlerId; u32 side, status; @@ -909,7 +909,7 @@ static void BattleAICmd_if_not_side_affecting(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_less_than(void) +static void Cmd_if_less_than(void) { if (AI_THINKING_STRUCT->funcResult < gAIScriptPtr[1]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -917,7 +917,7 @@ static void BattleAICmd_if_less_than(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_more_than(void) +static void Cmd_if_more_than(void) { if (AI_THINKING_STRUCT->funcResult > gAIScriptPtr[1]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -925,7 +925,7 @@ static void BattleAICmd_if_more_than(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_equal(void) +static void Cmd_if_equal(void) { if (AI_THINKING_STRUCT->funcResult == gAIScriptPtr[1]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -933,7 +933,7 @@ static void BattleAICmd_if_equal(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_not_equal(void) +static void Cmd_if_not_equal(void) { if (AI_THINKING_STRUCT->funcResult != gAIScriptPtr[1]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -941,7 +941,7 @@ static void BattleAICmd_if_not_equal(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_less_than_ptr(void) +static void Cmd_if_less_than_ptr(void) { const u8 *value = T1_READ_PTR(gAIScriptPtr + 1); @@ -951,7 +951,7 @@ static void BattleAICmd_if_less_than_ptr(void) gAIScriptPtr += 9; } -static void BattleAICmd_if_more_than_ptr(void) +static void Cmd_if_more_than_ptr(void) { const u8 *value = T1_READ_PTR(gAIScriptPtr + 1); @@ -961,7 +961,7 @@ static void BattleAICmd_if_more_than_ptr(void) gAIScriptPtr += 9; } -static void BattleAICmd_if_equal_ptr(void) +static void Cmd_if_equal_ptr(void) { const u8 *value = T1_READ_PTR(gAIScriptPtr + 1); @@ -971,7 +971,7 @@ static void BattleAICmd_if_equal_ptr(void) gAIScriptPtr += 9; } -static void BattleAICmd_if_not_equal_ptr(void) +static void Cmd_if_not_equal_ptr(void) { const u8 *value = T1_READ_PTR(gAIScriptPtr + 1); @@ -981,7 +981,7 @@ static void BattleAICmd_if_not_equal_ptr(void) gAIScriptPtr += 9; } -static void BattleAICmd_if_move(void) +static void Cmd_if_move(void) { u16 move = T1_READ_16(gAIScriptPtr + 1); @@ -991,7 +991,7 @@ static void BattleAICmd_if_move(void) gAIScriptPtr += 7; } -static void BattleAICmd_if_not_move(void) +static void Cmd_if_not_move(void) { u16 move = T1_READ_16(gAIScriptPtr + 1); @@ -1001,7 +1001,7 @@ static void BattleAICmd_if_not_move(void) gAIScriptPtr += 7; } -static void BattleAICmd_if_in_bytes(void) +static void Cmd_if_in_bytes(void) { const u8 *ptr = T1_READ_PTR(gAIScriptPtr + 1); @@ -1017,7 +1017,7 @@ static void BattleAICmd_if_in_bytes(void) gAIScriptPtr += 9; } -static void BattleAICmd_if_not_in_bytes(void) +static void Cmd_if_not_in_bytes(void) { const u8 *ptr = T1_READ_PTR(gAIScriptPtr + 1); @@ -1033,7 +1033,7 @@ static void BattleAICmd_if_not_in_bytes(void) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5); } -static void BattleAICmd_if_in_hwords(void) +static void Cmd_if_in_hwords(void) { const u16 *ptr = (const u16 *)T1_READ_PTR(gAIScriptPtr + 1); @@ -1049,7 +1049,7 @@ static void BattleAICmd_if_in_hwords(void) gAIScriptPtr += 9; } -static void BattleAICmd_if_not_in_hwords(void) +static void Cmd_if_not_in_hwords(void) { const u16 *ptr = (const u16 *)T1_READ_PTR(gAIScriptPtr + 1); @@ -1065,7 +1065,7 @@ static void BattleAICmd_if_not_in_hwords(void) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5); } -static void BattleAICmd_if_user_has_attacking_move(void) +static void Cmd_if_user_has_attacking_move(void) { s32 i; @@ -1082,7 +1082,7 @@ static void BattleAICmd_if_user_has_attacking_move(void) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); } -static void BattleAICmd_if_user_has_no_attacking_moves(void) +static void Cmd_if_user_has_no_attacking_moves(void) { s32 i; @@ -1099,13 +1099,13 @@ static void BattleAICmd_if_user_has_no_attacking_moves(void) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); } -static void BattleAICmd_get_turn_count(void) +static void Cmd_get_turn_count(void) { AI_THINKING_STRUCT->funcResult = gBattleResults.battleTurnCounter; gAIScriptPtr += 1; } -static void BattleAICmd_get_type(void) +static void Cmd_get_type(void) { u8 typeVar = gAIScriptPtr[1]; @@ -1146,7 +1146,7 @@ static u8 BattleAI_GetWantedBattler(u8 wantedBattler) } } -static void BattleAICmd_is_of_type(void) +static void Cmd_is_of_type(void) { u8 battlerId = BattleAI_GetWantedBattler(gAIScriptPtr[1]); @@ -1158,13 +1158,13 @@ static void BattleAICmd_is_of_type(void) gAIScriptPtr += 3; } -static void BattleAICmd_get_considered_move_power(void) +static void Cmd_get_considered_move_power(void) { AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power; gAIScriptPtr += 1; } -static void BattleAICmd_get_how_powerful_move_is(void) +static void Cmd_get_how_powerful_move_is(void) { s32 i, checkedMove; s32 moveDmgs[MAX_MON_MOVES]; @@ -1228,7 +1228,7 @@ static void BattleAICmd_get_how_powerful_move_is(void) gAIScriptPtr++; } -static void BattleAICmd_get_last_used_battler_move(void) +static void Cmd_get_last_used_battler_move(void) { if (gAIScriptPtr[1] == AI_USER) AI_THINKING_STRUCT->funcResult = gLastMoves[sBattler_AI]; @@ -1238,7 +1238,7 @@ static void BattleAICmd_get_last_used_battler_move(void) gAIScriptPtr += 2; } -static void BattleAICmd_if_equal_(void) // Same as if_equal. +static void Cmd_if_equal_(void) // Same as if_equal. { if (gAIScriptPtr[1] == AI_THINKING_STRUCT->funcResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -1246,7 +1246,7 @@ static void BattleAICmd_if_equal_(void) // Same as if_equal. gAIScriptPtr += 6; } -static void BattleAICmd_if_not_equal_(void) // Same as if_not_equal. +static void Cmd_if_not_equal_(void) // Same as if_not_equal. { if (gAIScriptPtr[1] != AI_THINKING_STRUCT->funcResult) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -1254,7 +1254,7 @@ static void BattleAICmd_if_not_equal_(void) // Same as if_not_equal. gAIScriptPtr += 6; } -static void BattleAICmd_if_user_goes(void) +static void Cmd_if_user_goes(void) { if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) == gAIScriptPtr[1]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -1262,7 +1262,7 @@ static void BattleAICmd_if_user_goes(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_user_doesnt_go(void) +static void Cmd_if_user_doesnt_go(void) { if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) != gAIScriptPtr[1]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -1270,15 +1270,15 @@ static void BattleAICmd_if_user_doesnt_go(void) gAIScriptPtr += 6; } -static void BattleAICmd_nullsub_2A(void) +static void Cmd_nullsub_2A(void) { } -static void BattleAICmd_nullsub_2B(void) +static void Cmd_nullsub_2B(void) { } -static void BattleAICmd_count_usable_party_mons(void) +static void Cmd_count_usable_party_mons(void) { u8 battlerId; u8 battlerOnField1, battlerOnField2; @@ -1324,19 +1324,19 @@ static void BattleAICmd_count_usable_party_mons(void) gAIScriptPtr += 2; } -static void BattleAICmd_get_considered_move(void) +static void Cmd_get_considered_move(void) { AI_THINKING_STRUCT->funcResult = AI_THINKING_STRUCT->moveConsidered; gAIScriptPtr += 1; } -static void BattleAICmd_get_considered_move_effect(void) +static void Cmd_get_considered_move_effect(void) { AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect; gAIScriptPtr += 1; } -static void BattleAICmd_get_ability(void) +static void Cmd_get_ability(void) { u8 battlerId; @@ -1393,7 +1393,7 @@ static void BattleAICmd_get_ability(void) gAIScriptPtr += 2; } -static void BattleAICmd_check_ability(void) +static void Cmd_check_ability(void) { u32 battlerId = BattleAI_GetWantedBattler(gAIScriptPtr[1]); u32 ability = gAIScriptPtr[2]; @@ -1453,7 +1453,7 @@ static void BattleAICmd_check_ability(void) gAIScriptPtr += 3; } -static void BattleAICmd_get_highest_type_effectiveness(void) +static void Cmd_get_highest_type_effectiveness(void) { s32 i; u8 *dynamicMoveType; @@ -1495,7 +1495,7 @@ static void BattleAICmd_get_highest_type_effectiveness(void) gAIScriptPtr += 1; } -static void BattleAICmd_if_type_effectiveness(void) +static void Cmd_if_type_effectiveness(void) { u8 damageVar; @@ -1531,15 +1531,15 @@ static void BattleAICmd_if_type_effectiveness(void) gAIScriptPtr += 6; } -static void BattleAICmd_nullsub_32(void) +static void Cmd_nullsub_32(void) { } -static void BattleAICmd_nullsub_33(void) +static void Cmd_nullsub_33(void) { } -static void BattleAICmd_if_status_in_party(void) +static void Cmd_if_status_in_party(void) { struct Pokemon *party; s32 i; @@ -1576,7 +1576,7 @@ static void BattleAICmd_if_status_in_party(void) gAIScriptPtr += 10; } -static void BattleAICmd_if_status_not_in_party(void) +static void Cmd_if_status_not_in_party(void) { struct Pokemon *party; s32 i; @@ -1613,7 +1613,7 @@ static void BattleAICmd_if_status_not_in_party(void) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6); } -static void BattleAICmd_get_weather(void) +static void Cmd_get_weather(void) { if (gBattleWeather & WEATHER_RAIN_ANY) AI_THINKING_STRUCT->funcResult = AI_WEATHER_RAIN; @@ -1627,7 +1627,7 @@ static void BattleAICmd_get_weather(void) gAIScriptPtr += 1; } -static void BattleAICmd_if_effect(void) +static void Cmd_if_effect(void) { if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect == gAIScriptPtr[1]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -1635,7 +1635,7 @@ static void BattleAICmd_if_effect(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_not_effect(void) +static void Cmd_if_not_effect(void) { if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect != gAIScriptPtr[1]) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2); @@ -1643,7 +1643,7 @@ static void BattleAICmd_if_not_effect(void) gAIScriptPtr += 6; } -static void BattleAICmd_if_stat_level_less_than(void) +static void Cmd_if_stat_level_less_than(void) { u32 battlerId; @@ -1658,7 +1658,7 @@ static void BattleAICmd_if_stat_level_less_than(void) gAIScriptPtr += 8; } -static void BattleAICmd_if_stat_level_more_than(void) +static void Cmd_if_stat_level_more_than(void) { u32 battlerId; @@ -1673,7 +1673,7 @@ static void BattleAICmd_if_stat_level_more_than(void) gAIScriptPtr += 8; } -static void BattleAICmd_if_stat_level_equal(void) +static void Cmd_if_stat_level_equal(void) { u32 battlerId; @@ -1688,7 +1688,7 @@ static void BattleAICmd_if_stat_level_equal(void) gAIScriptPtr += 8; } -static void BattleAICmd_if_stat_level_not_equal(void) +static void Cmd_if_stat_level_not_equal(void) { u32 battlerId; @@ -1703,7 +1703,7 @@ static void BattleAICmd_if_stat_level_not_equal(void) gAIScriptPtr += 8; } -static void BattleAICmd_if_can_faint(void) +static void Cmd_if_can_faint(void) { if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power < 2) { @@ -1732,7 +1732,7 @@ static void BattleAICmd_if_can_faint(void) gAIScriptPtr += 5; } -static void BattleAICmd_if_cant_faint(void) +static void Cmd_if_cant_faint(void) { if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power < 2) { @@ -1759,7 +1759,7 @@ static void BattleAICmd_if_cant_faint(void) gAIScriptPtr += 5; } -static void BattleAICmd_if_has_move(void) +static void Cmd_if_has_move(void) { s32 i; const u16 *movePtr = (u16 *)(gAIScriptPtr + 2); @@ -1811,7 +1811,7 @@ static void BattleAICmd_if_has_move(void) } } -static void BattleAICmd_if_doesnt_have_move(void) +static void Cmd_if_doesnt_have_move(void) { s32 i; const u16 *movePtr = (u16 *)(gAIScriptPtr + 2); @@ -1845,7 +1845,7 @@ static void BattleAICmd_if_doesnt_have_move(void) } } -static void BattleAICmd_if_has_move_with_effect(void) +static void Cmd_if_has_move_with_effect(void) { s32 i; @@ -1879,7 +1879,7 @@ static void BattleAICmd_if_has_move_with_effect(void) } } -static void BattleAICmd_if_doesnt_have_move_with_effect(void) +static void Cmd_if_doesnt_have_move_with_effect(void) { s32 i; @@ -1912,7 +1912,7 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void) } } -static void BattleAICmd_if_any_move_disabled_or_encored(void) +static void Cmd_if_any_move_disabled_or_encored(void) { u8 battlerId; @@ -1941,7 +1941,7 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void) } } -static void BattleAICmd_if_curr_move_disabled_or_encored(void) +static void Cmd_if_curr_move_disabled_or_encored(void) { switch (gAIScriptPtr[1]) { @@ -1963,12 +1963,12 @@ static void BattleAICmd_if_curr_move_disabled_or_encored(void) } } -static void BattleAICmd_flee(void) +static void Cmd_flee(void) { AI_THINKING_STRUCT->aiAction |= (AI_ACTION_DONE | AI_ACTION_FLEE | AI_ACTION_DO_NOT_ATTACK); } -static void BattleAICmd_if_random_safari_flee(void) +static void Cmd_if_random_safari_flee(void) { u8 safariFleeRate = gBattleStruct->safariEscapeFactor * 5; // Safari flee rate, from 0-20. @@ -1978,12 +1978,12 @@ static void BattleAICmd_if_random_safari_flee(void) gAIScriptPtr += 5; } -static void BattleAICmd_watch(void) +static void Cmd_watch(void) { AI_THINKING_STRUCT->aiAction |= (AI_ACTION_DONE | AI_ACTION_WATCH | AI_ACTION_DO_NOT_ATTACK); } -static void BattleAICmd_get_hold_effect(void) +static void Cmd_get_hold_effect(void) { u8 battlerId; @@ -2000,7 +2000,7 @@ static void BattleAICmd_get_hold_effect(void) gAIScriptPtr += 2; } -static void BattleAICmd_if_holds_item(void) +static void Cmd_if_holds_item(void) { u8 battlerId = BattleAI_GetWantedBattler(gAIScriptPtr[1]); u16 item; @@ -2021,7 +2021,7 @@ static void BattleAICmd_if_holds_item(void) gAIScriptPtr += 8; } -static void BattleAICmd_get_gender(void) +static void Cmd_get_gender(void) { u8 battlerId; @@ -2035,7 +2035,7 @@ static void BattleAICmd_get_gender(void) gAIScriptPtr += 2; } -static void BattleAICmd_is_first_turn_for(void) +static void Cmd_is_first_turn_for(void) { u8 battlerId; @@ -2049,7 +2049,7 @@ static void BattleAICmd_is_first_turn_for(void) gAIScriptPtr += 2; } -static void BattleAICmd_get_stockpile_count(void) +static void Cmd_get_stockpile_count(void) { u8 battlerId; @@ -2063,14 +2063,14 @@ static void BattleAICmd_get_stockpile_count(void) gAIScriptPtr += 2; } -static void BattleAICmd_is_double_battle(void) +static void Cmd_is_double_battle(void) { AI_THINKING_STRUCT->funcResult = gBattleTypeFlags & BATTLE_TYPE_DOUBLE; gAIScriptPtr += 1; } -static void BattleAICmd_get_used_held_item(void) +static void Cmd_get_used_held_item(void) { u8 battlerId; @@ -2089,28 +2089,28 @@ static void BattleAICmd_get_used_held_item(void) gAIScriptPtr += 2; } -static void BattleAICmd_get_move_type_from_result(void) +static void Cmd_get_move_type_from_result(void) { AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->funcResult].type; gAIScriptPtr += 1; } -static void BattleAICmd_get_move_power_from_result(void) +static void Cmd_get_move_power_from_result(void) { AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->funcResult].power; gAIScriptPtr += 1; } -static void BattleAICmd_get_move_effect_from_result(void) +static void Cmd_get_move_effect_from_result(void) { AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->funcResult].effect; gAIScriptPtr += 1; } -static void BattleAICmd_get_protect_count(void) +static void Cmd_get_protect_count(void) { u8 battlerId; @@ -2124,48 +2124,48 @@ static void BattleAICmd_get_protect_count(void) gAIScriptPtr += 2; } -static void BattleAICmd_nullsub_52(void) +static void Cmd_nullsub_52(void) { } -static void BattleAICmd_nullsub_53(void) +static void Cmd_nullsub_53(void) { } -static void BattleAICmd_nullsub_54(void) +static void Cmd_nullsub_54(void) { } -static void BattleAICmd_nullsub_55(void) +static void Cmd_nullsub_55(void) { } -static void BattleAICmd_nullsub_56(void) +static void Cmd_nullsub_56(void) { } -static void BattleAICmd_nullsub_57(void) +static void Cmd_nullsub_57(void) { } -static void BattleAICmd_call(void) +static void Cmd_call(void) { AIStackPushVar(gAIScriptPtr + 5); gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); } -static void BattleAICmd_goto(void) +static void Cmd_goto(void) { gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); } -static void BattleAICmd_end(void) +static void Cmd_end(void) { if (AIStackPop() == 0) AI_THINKING_STRUCT->aiAction |= AI_ACTION_DONE; } -static void BattleAICmd_if_level_cond(void) +static void Cmd_if_level_cond(void) { switch (gAIScriptPtr[1]) { @@ -2190,7 +2190,7 @@ static void BattleAICmd_if_level_cond(void) } } -static void BattleAICmd_if_target_taunted(void) +static void Cmd_if_target_taunted(void) { if (gDisableStructs[gBattlerTarget].tauntTimer != 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -2198,7 +2198,7 @@ static void BattleAICmd_if_target_taunted(void) gAIScriptPtr += 5; } -static void BattleAICmd_if_target_not_taunted(void) +static void Cmd_if_target_not_taunted(void) { if (gDisableStructs[gBattlerTarget].tauntTimer == 0) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -2206,7 +2206,7 @@ static void BattleAICmd_if_target_not_taunted(void) gAIScriptPtr += 5; } -static void BattleAICmd_if_target_is_ally(void) +static void Cmd_if_target_is_ally(void) { if ((sBattler_AI & BIT_SIDE) == (gBattlerTarget & BIT_SIDE)) gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1); @@ -2214,7 +2214,7 @@ static void BattleAICmd_if_target_is_ally(void) gAIScriptPtr += 5; } -static void BattleAICmd_if_flash_fired(void) +static void Cmd_if_flash_fired(void) { u8 battlerId = BattleAI_GetWantedBattler(gAIScriptPtr[1]); diff --git a/src/battle_bg.c b/src/battle_bg.c index a08873857..567625a99 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -36,7 +36,7 @@ struct BattleBackground // .rodata static const u16 sUnrefArray[] = {0x0300, 0x0000}; //OamData? -static const struct OamData gUnknown_0831A988 = +static const struct OamData sVsLetter_V_OamData = { .y = 0, .affineMode = 3, @@ -53,7 +53,7 @@ static const struct OamData gUnknown_0831A988 = .affineParam = 0, }; -static const struct OamData gUnknown_0831A990 = +static const struct OamData sVsLetter_S_OamData = { .y = 0, .affineMode = 3, @@ -70,13 +70,13 @@ static const struct OamData gUnknown_0831A990 = .affineParam = 0, }; -static const union AffineAnimCmd gUnknown_0831A998[] = +static const union AffineAnimCmd sVsLetterAffineAnimCmds0[] = { AFFINEANIMCMD_FRAME(0x0080, 0x0080, 0x00, 0x00), AFFINEANIMCMD_END, }; -static const union AffineAnimCmd gUnknown_0831A9A8[] = +static const union AffineAnimCmd sVsLetterAffineAnimCmds1[] = { AFFINEANIMCMD_FRAME(0x0080, 0x0080, 0x00, 0x00), AFFINEANIMCMD_FRAME(0x0018, 0x0018, 0x00, 0x80), @@ -84,37 +84,39 @@ static const union AffineAnimCmd gUnknown_0831A9A8[] = AFFINEANIMCMD_END, }; -static const union AffineAnimCmd * const gUnknown_0831A9C8[] = +static const union AffineAnimCmd *const sVsLetterAffineAnimTable[] = { - gUnknown_0831A998, - gUnknown_0831A9A8, + sVsLetterAffineAnimCmds0, + sVsLetterAffineAnimCmds1, }; -static const struct SpriteTemplate gUnknown_0831A9D0 = +#define TAG_VS_LETTERS 10000 + +static const struct SpriteTemplate sVsLetter_V_SpriteTemplate = { - .tileTag = 0x2710, - .paletteTag = 0x2710, - .oam = &gUnknown_0831A988, + .tileTag = TAG_VS_LETTERS, + .paletteTag = TAG_VS_LETTERS, + .oam = &sVsLetter_V_OamData, .anims = gDummySpriteAnimTable, .images = NULL, - .affineAnims = gUnknown_0831A9C8, + .affineAnims = sVsLetterAffineAnimTable, .callback = nullsub_17 }; -static const struct SpriteTemplate gUnknown_0831A9E8 = +static const struct SpriteTemplate sVsLetter_S_SpriteTemplate = { - .tileTag = 0x2710, - .paletteTag = 0x2710, - .oam = &gUnknown_0831A990, + .tileTag = TAG_VS_LETTERS, + .paletteTag = TAG_VS_LETTERS, + .oam = &sVsLetter_S_OamData, .anims = gDummySpriteAnimTable, .images = NULL, - .affineAnims = gUnknown_0831A9C8, + .affineAnims = sVsLetterAffineAnimTable, .callback = nullsub_17 }; -static const struct CompressedSpriteSheet gUnknown_0831AA00 = +static const struct CompressedSpriteSheet sVsLettersSpriteSheet = { - gUnknown_08D77B0C, 0x1000, 0x2710 + gVsLettersGfx, 0x1000, TAG_VS_LETTERS }; const struct BgTemplate gBattleBgTemplates[] = @@ -689,7 +691,6 @@ static const struct BattleBackground gBattleTerrainTable[] = }, }; -// .text void BattleInitBgsAndWindows(void) { ResetBgsAndClearDma3BusyFlags(0); @@ -710,7 +711,7 @@ void BattleInitBgsAndWindows(void) DeactivateAllTextPrinters(); } -void sub_80356D0(void) +void InitBattleBgsVideo(void) { DisableInterrupts(INTR_FLAG_HBLANK); EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL); @@ -725,10 +726,11 @@ void LoadBattleMenuWindowGfx(void) { LoadUserWindowBorderGfx(2, 0x12, 0x10); LoadUserWindowBorderGfx(2, 0x22, 0x10); - LoadCompressedPalette(gUnknown_08D85600, 0x50, 0x20); + LoadCompressedPalette(gBattleWindowTextPalette, 0x50, 0x20); if (gBattleTypeFlags & BATTLE_TYPE_ARENA) { + // Load graphics for the Battle Arena referee's mid-battle messages. Menu_LoadStdPalAt(0x70); LoadMessageBoxGfx(0, 0x30, 0x70); gPlttBufferUnfaded[0x76] = 0; @@ -837,86 +839,81 @@ void DrawMainBattleBackground(void) void LoadBattleTextboxAndBackground(void) { - LZDecompressVram(gBattleTextboxTiles, (void*)(VRAM)); + LZDecompressVram(gBattleTextboxTiles, (void*)(BG_CHAR_ADDR(0))); CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0); CopyBgTilemapBufferToVram(0); LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40); LoadBattleMenuWindowGfx(); - DrawMainBattleBackground(); } -static void sub_8035AE4(u8 taskId, u8 battlerId, u8 bgId, u8 destX, u8 destY) +static void DrawLinkBattleParticipantPokeballs(u8 taskId, u8 multiplayerId, u8 bgId, u8 destX, u8 destY) { s32 i; - u16 var = 0; - u16 src[6]; + u16 pokeballStatuses = 0; + u16 tiles[6]; if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { if (gTasks[taskId].data[5] != 0) { - switch (battlerId) + switch (multiplayerId) { case 0: - var = 0x3F & gTasks[taskId].data[3]; + pokeballStatuses = 0x3F & gTasks[taskId].data[3]; break; case 1: - var = (0xFC0 & gTasks[taskId].data[4]) >> 6; + pokeballStatuses = (0xFC0 & gTasks[taskId].data[4]) >> 6; break; case 2: - var = (0xFC0 & gTasks[taskId].data[3]) >> 6; + pokeballStatuses = (0xFC0 & gTasks[taskId].data[3]) >> 6; break; case 3: - var = 0x3F & gTasks[taskId].data[4]; + pokeballStatuses = 0x3F & gTasks[taskId].data[4]; break; } } else { - switch (battlerId) + switch (multiplayerId) { case 0: - var = 0x3F & gTasks[taskId].data[3]; + pokeballStatuses = 0x3F & gTasks[taskId].data[3]; break; case 1: - var = 0x3F & gTasks[taskId].data[4]; + pokeballStatuses = 0x3F & gTasks[taskId].data[4]; break; case 2: - var = (0xFC0 & gTasks[taskId].data[3]) >> 6; + pokeballStatuses = (0xFC0 & gTasks[taskId].data[3]) >> 6; break; case 3: - var = (0xFC0 & gTasks[taskId].data[4]) >> 6; + pokeballStatuses = (0xFC0 & gTasks[taskId].data[4]) >> 6; break; } } for (i = 0; i < 3; i++) - { - src[i] = ((var & (3 << (i * 2))) >> (i * 2)) + 0x6001; - } + tiles[i] = ((pokeballStatuses & (3 << (i * 2))) >> (i * 2)) + 0x6001; - CopyToBgTilemapBufferRect_ChangePalette(bgId, src, destX, destY, 3, 1, 0x11); + CopyToBgTilemapBufferRect_ChangePalette(bgId, tiles, destX, destY, 3, 1, 0x11); CopyBgTilemapBufferToVram(bgId); } else { - if (battlerId == gBattleScripting.multiplayerId) - var = gTasks[taskId].data[3]; + if (multiplayerId == gBattleScripting.multiplayerId) + pokeballStatuses = gTasks[taskId].data[3]; else - var = gTasks[taskId].data[4]; + pokeballStatuses = gTasks[taskId].data[4]; for (i = 0; i < 6; i++) - { - src[i] = ((var & (3 << (i * 2))) >> (i * 2)) + 0x6001; - } + tiles[i] = ((pokeballStatuses & (3 << (i * 2))) >> (i * 2)) + 0x6001; - CopyToBgTilemapBufferRect_ChangePalette(bgId, src, destX, destY, 6, 1, 0x11); + CopyToBgTilemapBufferRect_ChangePalette(bgId, tiles, destX, destY, 6, 1, 0x11); CopyBgTilemapBufferToVram(bgId); } } -static void sub_8035C4C(void) +static void DrawLinkBattleVsScreenOutcomeText(void) { if (gBattleOutcome == B_OUTCOME_DREW) { @@ -997,7 +994,7 @@ static void sub_8035C4C(void) } } -void sub_8035D74(u8 taskId) +void InitLinkBattleVsScreen(u8 taskId) { struct LinkPlayer *linkPlayer; u8 *name; @@ -1017,19 +1014,19 @@ void sub_8035D74(u8 taskId) { case 0: BattlePutTextOnWindow(name, 0x11); - sub_8035AE4(taskId, linkPlayer->id, 1, 2, 4); + DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 1, 2, 4); break; case 1: BattlePutTextOnWindow(name, 0x12); - sub_8035AE4(taskId, linkPlayer->id, 2, 2, 4); + DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 2, 2, 4); break; case 2: BattlePutTextOnWindow(name, 0x13); - sub_8035AE4(taskId, linkPlayer->id, 1, 2, 8); + DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 1, 2, 8); break; case 3: BattlePutTextOnWindow(name, 0x14); - sub_8035AE4(taskId, linkPlayer->id, 2, 2, 8); + DrawLinkBattleParticipantPokeballs(taskId, linkPlayer->id, 2, 2, 8); break; } } @@ -1049,16 +1046,16 @@ void sub_8035D74(u8 taskId) name = gLinkPlayers[opponentId].name; BattlePutTextOnWindow(name, 0x10); - sub_8035AE4(taskId, playerId, 1, 2, 7); - sub_8035AE4(taskId, opponentId, 2, 2, 7); + DrawLinkBattleParticipantPokeballs(taskId, playerId, 1, 2, 7); + DrawLinkBattleParticipantPokeballs(taskId, opponentId, 2, 2, 7); } gTasks[taskId].data[0]++; break; case 1: - palId = AllocSpritePalette(0x2710); + palId = AllocSpritePalette(TAG_VS_LETTERS); gPlttBufferUnfaded[palId * 16 + 0x10F] = gPlttBufferFaded[palId * 16 + 0x10F] = 0x7FFF; - gBattleStruct->linkBattleVsSpriteId_V = CreateSprite(&gUnknown_0831A9D0, 111, 80, 0); - gBattleStruct->linkBattleVsSpriteId_S = CreateSprite(&gUnknown_0831A9E8, 129, 80, 0); + gBattleStruct->linkBattleVsSpriteId_V = CreateSprite(&sVsLetter_V_SpriteTemplate, 111, 80, 0); + gBattleStruct->linkBattleVsSpriteId_S = CreateSprite(&sVsLetter_S_SpriteTemplate, 129, 80, 0); gSprites[gBattleStruct->linkBattleVsSpriteId_V].invisible = TRUE; gSprites[gBattleStruct->linkBattleVsSpriteId_S].invisible = TRUE; gTasks[taskId].data[0]++; @@ -1087,7 +1084,7 @@ void sub_8035D74(u8 taskId) else { if (gTasks[taskId].data[5] != 0) - sub_8035C4C(); + DrawLinkBattleVsScreenOutcomeText(); PlaySE(SE_W231); DestroyTask(taskId); @@ -1110,7 +1107,7 @@ void DrawBattleEntryBackground(void) if (gBattleTypeFlags & BATTLE_TYPE_LINK) { LZDecompressVram(gUnknown_08D778F0, (void*)(BG_CHAR_ADDR(1))); - LZDecompressVram(gUnknown_08D77B0C, (void*)(VRAM + 0x10000)); + LZDecompressVram(gVsLettersGfx, (void*)(VRAM + 0x10000)); LoadCompressedPalette(gUnknown_08D77AE4, 0x60, 0x20); SetBgAttribute(1, BG_ATTR_SCREENSIZE, 1); SetGpuReg(REG_OFFSET_BG1CNT, 0x5C04); @@ -1122,7 +1119,7 @@ void DrawBattleEntryBackground(void) SetGpuReg(REG_OFFSET_WINOUT, 0x36); gBattle_BG1_Y = 0xFF5C; gBattle_BG2_Y = 0xFF5C; - LoadCompressedSpriteSheetUsingHeap(&gUnknown_0831AA00); + LoadCompressedSpriteSheetUsingHeap(&sVsLettersSpriteSheet); } else if (gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_EREADER_TRAINER)) { @@ -1195,7 +1192,7 @@ bool8 LoadChosenBattleElement(u8 caseId) switch (caseId) { case 0: - LZDecompressVram(gBattleTextboxTiles, (void*)(VRAM)); + LZDecompressVram(gBattleTextboxTiles, (void*)(BG_CHAR_ADDR(0))); break; case 1: CopyToBgTilemapBuffer(0, gBattleTextboxTilemap, 0, 0); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 1be5def47..57239bca6 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -31,6 +31,7 @@ #include "constants/battle_anim.h" #include "constants/items.h" #include "constants/moves.h" +#include "constants/party_menu.h" #include "constants/songs.h" #include "constants/trainers.h" #include "constants/rgb.h" @@ -1341,10 +1342,10 @@ static void WaitForMonSelection(void) { if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active) { - if (gUnknown_0203CEE8 == 1) - BtlController_EmitChosenMonReturnValue(1, gUnknown_0203CEE9, gUnknown_0203CF00); + if (gPartyMenuUseExitCallback == TRUE) + BtlController_EmitChosenMonReturnValue(1, gSelectedMonPartyId, gBattlePartyCurrentOrder); else - BtlController_EmitChosenMonReturnValue(1, 6, NULL); + BtlController_EmitChosenMonReturnValue(1, PARTY_SIZE, NULL); if ((gBattleBufferA[gActiveBattler][1] & 0xF) == 1) PrintLinkStandbyMsg(); @@ -1531,12 +1532,12 @@ void ActionSelectionDestroyCursorAt(u8 cursorPosition) CopyBgTilemapBufferToVram(0); } -void SetCB2ToReshowScreenAfterMenu(void) +void CB2_SetUpReshowBattleScreenAfterMenu(void) { SetMainCallback2(ReshowBattleScreenAfterMenu); } -void SetCB2ToReshowScreenAfterMenu2(void) +void CB2_SetUpReshowBattleScreenAfterMenu2(void) { SetMainCallback2(ReshowBattleScreenAfterMenu); } @@ -2632,20 +2633,20 @@ static void PlayerHandleChooseItem(void) gBattlerControllerFuncs[gActiveBattler] = OpenBagAndChooseItem; gBattlerInMenuId = gActiveBattler; - for (i = 0; i < 3; i++) - gUnknown_0203CF00[i] = gBattleBufferA[gActiveBattler][1 + i]; + for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++) + gBattlePartyCurrentOrder[i] = gBattleBufferA[gActiveBattler][1 + i]; } static void PlayerHandleChoosePokemon(void) { s32 i; - for (i = 0; i < 3; i++) - gUnknown_0203CF00[i] = gBattleBufferA[gActiveBattler][4 + i]; + for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++) + gBattlePartyCurrentOrder[i] = gBattleBufferA[gActiveBattler][4 + i]; - if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleBufferA[gActiveBattler][1] & 0xF) != PARTY_CANT_SWITCH) + if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleBufferA[gActiveBattler][1] & 0xF) != PARTY_ACTION_CANT_SWITCH) { - BtlController_EmitChosenMonReturnValue(1, gBattlerPartyIndexes[gActiveBattler] + 1, gUnknown_0203CF00); + BtlController_EmitChosenMonReturnValue(1, gBattlerPartyIndexes[gActiveBattler] + 1, gBattlePartyCurrentOrder); PlayerBufferExecCompleted(); } else diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 17db0b868..d0e76ab1b 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -95,7 +95,7 @@ void sub_8032768(void) if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { for (i = 0; i < gBattlersCount; i++) - sub_81B8D64(i, 0); + BufferBattlePartyCurrentOrderBySide(i, 0); } for (i = 0; i < sizeof(gBattleStruct->tvMovePoints); i++) @@ -144,10 +144,10 @@ static void InitSinglePlayerBtlControllers(void) gBattlersCount = MAX_BATTLERS_COUNT; - sub_81B8D64(0, 0); - sub_81B8D64(1, 0); - sub_81B8D64(2, 1); - sub_81B8D64(3, 1); + BufferBattlePartyCurrentOrderBySide(0, 0); + BufferBattlePartyCurrentOrderBySide(1, 0); + BufferBattlePartyCurrentOrderBySide(2, 1); + BufferBattlePartyCurrentOrderBySide(3, 1); gBattlerPartyIndexes[0] = 0; gBattlerPartyIndexes[1] = 0; @@ -247,10 +247,10 @@ static void InitSinglePlayerBtlControllers(void) gBattlersCount = MAX_BATTLERS_COUNT; - sub_81B8D64(0, 0); - sub_81B8D64(1, 0); - sub_81B8D64(2, 1); - sub_81B8D64(3, 1); + BufferBattlePartyCurrentOrderBySide(0, 0); + BufferBattlePartyCurrentOrderBySide(1, 0); + BufferBattlePartyCurrentOrderBySide(2, 1); + BufferBattlePartyCurrentOrderBySide(3, 1); gBattlerPartyIndexes[0] = 0; gBattlerPartyIndexes[1] = 0; @@ -267,11 +267,11 @@ static void InitSinglePlayerBtlControllers(void) { case 0: case 3: - sub_81B8D64(gLinkPlayers[i].id, 0); + BufferBattlePartyCurrentOrderBySide(gLinkPlayers[i].id, 0); break; case 1: case 2: - sub_81B8D64(gLinkPlayers[i].id, 1); + BufferBattlePartyCurrentOrderBySide(gLinkPlayers[i].id, 1); break; } @@ -487,10 +487,10 @@ static void InitLinkBtlControllers(void) gBattlersCount = MAX_BATTLERS_COUNT; } - sub_81B8D64(0, 0); - sub_81B8D64(1, 0); - sub_81B8D64(2, 1); - sub_81B8D64(3, 1); + BufferBattlePartyCurrentOrderBySide(0, 0); + BufferBattlePartyCurrentOrderBySide(1, 0); + BufferBattlePartyCurrentOrderBySide(2, 1); + BufferBattlePartyCurrentOrderBySide(3, 1); gBattlerPartyIndexes[0] = 0; gBattlerPartyIndexes[1] = 0; gBattlerPartyIndexes[2] = 3; @@ -509,11 +509,11 @@ static void InitLinkBtlControllers(void) { case 0: case 3: - sub_81B8D64(gLinkPlayers[i].id, 0); + BufferBattlePartyCurrentOrderBySide(gLinkPlayers[i].id, 0); break; case 1: case 2: - sub_81B8D64(gLinkPlayers[i].id, 1); + BufferBattlePartyCurrentOrderBySide(gLinkPlayers[i].id, 1); break; } @@ -1175,13 +1175,13 @@ void BtlController_EmitChooseItem(u8 bufferId, u8 *arg1) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } -void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8 *arg4) +void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 slotId, u8 abilityId, u8 *arg4) { s32 i; sBattleBuffersTransferData[0] = CONTROLLER_CHOOSEPOKEMON; sBattleBuffersTransferData[1] = caseId; - sBattleBuffersTransferData[2] = arg2; + sBattleBuffersTransferData[2] = slotId; sBattleBuffersTransferData[3] = abilityId; for (i = 0; i < 3; i++) sBattleBuffersTransferData[4 + i] = arg4[i]; @@ -1311,14 +1311,14 @@ void BtlController_EmitTwoReturnValues(u8 bufferId, u8 arg1, u16 arg2) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } -void BtlController_EmitChosenMonReturnValue(u8 bufferId, u8 b, u8 *c) +void BtlController_EmitChosenMonReturnValue(u8 bufferId, u8 partyId, u8 *battlePartyOrder) { s32 i; sBattleBuffersTransferData[0] = CONTROLLER_CHOSENMONRETURNVALUE; - sBattleBuffersTransferData[1] = b; - for (i = 0; i < 3; i++) - sBattleBuffersTransferData[2 + i] = c[i]; + sBattleBuffersTransferData[1] = partyId; + for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++) + sBattleBuffersTransferData[2 + i] = battlePartyOrder[i]; PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 5); } diff --git a/src/battle_dome.c b/src/battle_dome.c index 22a1ecaf2..9c63bba42 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -2330,7 +2330,7 @@ static void GetDomeData(void) } break; case 8: - sub_81B8558(); + ClearSelectedPartyOrder(); gSelectedOrderFromParty[0] = gSaveBlock2Ptr->frontier.field_CB0; gSelectedOrderFromParty[1] = gSaveBlock2Ptr->frontier.field_CB0 >> 8; break; @@ -3414,7 +3414,7 @@ static void Task_ShowOpponentInfo(u8 taskId) LoadCompressedSpriteSheet(sDomeOptionsSpriteSheet); LoadCompressedPalette(gUnknown_08D85358, 0, 0x200); LoadCompressedPalette(gUnknown_08D85444, 0x100, 0x200); - LoadCompressedPalette(gUnknown_08D85600, 0xF0, 0x20); + LoadCompressedPalette(gBattleWindowTextPalette, 0xF0, 0x20); if (r9 == 2) LoadCompressedPalette(gUnknown_08D854C8, 0x50, 0x20); CpuFill32(0, gPlttBufferFaded, 0x400); @@ -5574,7 +5574,7 @@ static void Task_ShowTourneyTree(u8 taskId) DecompressAndLoadBgGfxUsingHeap(3, gUnknown_08D83C3C, 0x2000, 0, 1); LoadCompressedPalette(gUnknown_08D85358, 0, 0x200); LoadCompressedPalette(gUnknown_08D85444, 0x100, 0x200); - LoadCompressedPalette(gUnknown_08D85600, 0xF0, 0x20); + LoadCompressedPalette(gBattleWindowTextPalette, 0xF0, 0x20); CpuFill32(0, gPlttBufferFaded, 0x400); ShowBg(0); ShowBg(1); diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 737e6b61e..341cd4a6a 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -811,7 +811,7 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId) break; case 6: LoadAndCreateEnemyShadowSprites(); - sub_81B8C68(); + BufferBattlePartyCurrentOrder(); retVal = TRUE; break; } @@ -1061,8 +1061,8 @@ void HandleBattleLowHpMusicChange(void) { u8 playerBattler1 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); u8 playerBattler2 = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); - u8 battler1PartyId = pokemon_order_func(gBattlerPartyIndexes[playerBattler1]); - u8 battler2PartyId = pokemon_order_func(gBattlerPartyIndexes[playerBattler2]); + u8 battler1PartyId = GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[playerBattler1]); + u8 battler2PartyId = GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[playerBattler2]); if (GetMonData(&gPlayerParty[battler1PartyId], MON_DATA_HP) != 0) HandleLowHpMusicChange(&gPlayerParty[battler1PartyId], playerBattler1); diff --git a/src/battle_main.c b/src/battle_main.c index a8f17dc3b..196053ad2 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -54,6 +54,7 @@ #include "constants/hold_effects.h" #include "constants/items.h" #include "constants/moves.h" +#include "constants/party_menu.h" #include "constants/rgb.h" #include "constants/songs.h" #include "constants/species.h" @@ -166,8 +167,8 @@ EWRAM_DATA static u32 sUnusedUnknownArray[25] = {0}; EWRAM_DATA u32 gBattleTypeFlags = 0; EWRAM_DATA u8 gBattleTerrain = 0; EWRAM_DATA u32 gUnknown_02022FF4 = 0; -EWRAM_DATA struct UnknownPokemonStruct4 gUnknown_02022FF8[3] = {0}; // what is it used for? -EWRAM_DATA struct UnknownPokemonStruct4* gUnknown_02023058 = NULL; // what is it used for? +EWRAM_DATA struct UnknownPokemonStruct4 gMultiPartnerParty[MULTI_PARTY_SIZE] = {0}; +EWRAM_DATA static struct UnknownPokemonStruct4* sMultiPartnerPartyBuffer = NULL; EWRAM_DATA u8 *gUnknown_0202305C = NULL; EWRAM_DATA u8 *gUnknown_02023060 = NULL; EWRAM_DATA u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200] = {0}; @@ -453,7 +454,7 @@ const u8 gTypeEffectiveness[336] = TYPE_ENDTABLE, TYPE_ENDTABLE, TYPE_MUL_NO_EFFECT }; -const u8 gTypeNames[][TYPE_NAME_LENGTH + 1] = +const u8 gTypeNames[NUMBER_OF_MON_TYPES][TYPE_NAME_LENGTH + 1] = { _("NORMAL"), _("FIGHT"), @@ -686,7 +687,7 @@ static void CB2_InitBattleInternal(void) if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) gBattleTerrain = BATTLE_TERRAIN_BUILDING; - sub_80356D0(); + InitBattleBgsVideo(); LoadBattleTextboxAndBackground(); ResetSpriteData(); ResetTasks(); @@ -1023,7 +1024,7 @@ static void CB2_HandleStartBattle(void) ResetBlockReceivedFlags(); sub_8036EB8(2, playerMultiplayerId); SetAllPlayersBerryData(); - taskId = CreateTask(sub_8035D74, 0); + taskId = CreateTask(InitLinkBattleVsScreen, 0); gTasks[taskId].data[1] = 0x10E; gTasks[taskId].data[2] = 0x5A; gTasks[taskId].data[5] = 0; @@ -1225,7 +1226,7 @@ static void CB2_HandleStartMultiPartnerBattle(void) ResetBlockReceivedFlags(); sub_8036EB8(2, playerMultiplayerId); SetAllPlayersBerryData(); - taskId = CreateTask(sub_8035D74, 0); + taskId = CreateTask(InitLinkBattleVsScreen, 0); gTasks[taskId].data[1] = 0x10E; gTasks[taskId].data[2] = 0x5A; gTasks[taskId].data[5] = 0; @@ -1248,12 +1249,12 @@ static void CB2_HandleStartMultiPartnerBattle(void) if (gLinkPlayers[playerMultiplayerId].id != 0) { memcpy(gPlayerParty, gBlockRecvBuffer[enemyMultiplayerId], sizeof(struct Pokemon) * 2); - memcpy(gPlayerParty + 3, gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon) * 2); + memcpy(gPlayerParty + MULTI_PARTY_SIZE, gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon) * 2); } else { memcpy(gPlayerParty, gBlockRecvBuffer[playerMultiplayerId], sizeof(struct Pokemon) * 2); - memcpy(gPlayerParty + 3, gBlockRecvBuffer[enemyMultiplayerId], sizeof(struct Pokemon) * 2); + memcpy(gPlayerParty + MULTI_PARTY_SIZE, gBlockRecvBuffer[enemyMultiplayerId], sizeof(struct Pokemon) * 2); } gBattleCommunication[MULTIUSE_STATE]++; } @@ -1396,22 +1397,22 @@ static void sub_80379F8(u8 arrayIdPlus) { s32 i; - for (i = 0; i < 3; i++) - { - gUnknown_02022FF8[i].species = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_SPECIES); - gUnknown_02022FF8[i].heldItem = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_HELD_ITEM); - GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_NICKNAME, gUnknown_02022FF8[i].nickname); - gUnknown_02022FF8[i].level = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_LEVEL); - gUnknown_02022FF8[i].hp = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_HP); - gUnknown_02022FF8[i].maxhp = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_MAX_HP); - gUnknown_02022FF8[i].status = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_STATUS); - gUnknown_02022FF8[i].personality = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_PERSONALITY); - gUnknown_02022FF8[i].gender = GetMonGender(&gPlayerParty[arrayIdPlus + i]); - StripExtCtrlCodes(gUnknown_02022FF8[i].nickname); + for (i = 0; i < (int)ARRAY_COUNT(gMultiPartnerParty); i++) + { + gMultiPartnerParty[i].species = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_SPECIES); + gMultiPartnerParty[i].heldItem = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_HELD_ITEM); + GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_NICKNAME, gMultiPartnerParty[i].nickname); + gMultiPartnerParty[i].level = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_LEVEL); + gMultiPartnerParty[i].hp = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_HP); + gMultiPartnerParty[i].maxhp = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_MAX_HP); + gMultiPartnerParty[i].status = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_STATUS); + gMultiPartnerParty[i].personality = GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_PERSONALITY); + gMultiPartnerParty[i].gender = GetMonGender(&gPlayerParty[arrayIdPlus + i]); + StripExtCtrlCodes(gMultiPartnerParty[i].nickname); if (GetMonData(&gPlayerParty[arrayIdPlus + i], MON_DATA_LANGUAGE) != LANGUAGE_JAPANESE) - PadNameString(gUnknown_02022FF8[i].nickname, CHAR_SPACE); + PadNameString(gMultiPartnerParty[i].nickname, CHAR_SPACE); } - memcpy(gUnknown_02023058, gUnknown_02022FF8, sizeof(gUnknown_02022FF8)); + memcpy(sMultiPartnerPartyBuffer, gMultiPartnerParty, sizeof(gMultiPartnerParty)); } static void CB2_PreInitMultiBattle(void) @@ -1443,9 +1444,9 @@ static void CB2_PreInitMultiBattle(void) case 0: if (gReceivedRemoteLinkPlayers != 0 && IsLinkTaskFinished()) { - gUnknown_02023058 = Alloc(sizeof(struct UnknownPokemonStruct4) * 3); + sMultiPartnerPartyBuffer = Alloc(sizeof(struct UnknownPokemonStruct4) * ARRAY_COUNT(gMultiPartnerParty)); sub_80379F8(0); - SendBlock(bitmask_all_link_players_but_self(), gUnknown_02023058, sizeof(struct UnknownPokemonStruct4) * 3); + SendBlock(bitmask_all_link_players_but_self(), sMultiPartnerPartyBuffer, sizeof(struct UnknownPokemonStruct4) * ARRAY_COUNT(gMultiPartnerParty)); gBattleCommunication[MULTIUSE_STATE]++; } break; @@ -1458,24 +1459,24 @@ static void CB2_PreInitMultiBattle(void) if (i == playerMultiplierId) continue; - if (numPlayers == 4) + if (numPlayers == MAX_LINK_PLAYERS) { if ((!(gLinkPlayers[i].id & 1) && !(gLinkPlayers[playerMultiplierId].id & 1)) || (gLinkPlayers[i].id & 1 && gLinkPlayers[playerMultiplierId].id & 1)) { - memcpy(gUnknown_02022FF8, gBlockRecvBuffer[i], sizeof(struct UnknownPokemonStruct4) * 3); + memcpy(gMultiPartnerParty, gBlockRecvBuffer[i], sizeof(struct UnknownPokemonStruct4) * ARRAY_COUNT(gMultiPartnerParty)); } } else { - memcpy(gUnknown_02022FF8, gBlockRecvBuffer[i], sizeof(struct UnknownPokemonStruct4) * 3); + memcpy(gMultiPartnerParty, gBlockRecvBuffer[i], sizeof(struct UnknownPokemonStruct4) * ARRAY_COUNT(gMultiPartnerParty)); } } gBattleCommunication[MULTIUSE_STATE]++; *savedCallback = gMain.savedCallback; *savedBattleTypeFlags = gBattleTypeFlags; gMain.savedCallback = CB2_PreInitMultiBattle; - sub_81B9150(); + ShowPartyMenuToShowcaseMultiBattleParty(); } break; case 2: @@ -1496,8 +1497,8 @@ static void CB2_PreInitMultiBattle(void) gBattleTypeFlags = *savedBattleTypeFlags; gMain.savedCallback = *savedCallback; SetMainCallback2(CB2_InitBattleInternal); - Free(gUnknown_02023058); - gUnknown_02023058 = NULL; + Free(sMultiPartnerPartyBuffer); + sMultiPartnerPartyBuffer = NULL; } } else if (gReceivedRemoteLinkPlayers == 0) @@ -1505,8 +1506,8 @@ static void CB2_PreInitMultiBattle(void) gBattleTypeFlags = *savedBattleTypeFlags; gMain.savedCallback = *savedCallback; SetMainCallback2(CB2_InitBattleInternal); - Free(gUnknown_02023058); - gUnknown_02023058 = NULL; + Free(sMultiPartnerPartyBuffer); + sMultiPartnerPartyBuffer = NULL; } break; } @@ -1527,13 +1528,13 @@ static void CB2_PreInitIngamePlayerPartnerBattle(void) switch (gBattleCommunication[MULTIUSE_STATE]) { case 0: - gUnknown_02023058 = Alloc(sizeof(struct UnknownPokemonStruct4) * 3); + sMultiPartnerPartyBuffer = Alloc(sizeof(struct UnknownPokemonStruct4) * ARRAY_COUNT(gMultiPartnerParty)); sub_80379F8(3); gBattleCommunication[MULTIUSE_STATE]++; *savedCallback = gMain.savedCallback; *savedBattleTypeFlags = gBattleTypeFlags; gMain.savedCallback = CB2_PreInitIngamePlayerPartnerBattle; - sub_81B9150(); + ShowPartyMenuToShowcaseMultiBattleParty(); break; case 1: if (!gPaletteFade.active) @@ -1542,8 +1543,8 @@ static void CB2_PreInitIngamePlayerPartnerBattle(void) gBattleTypeFlags = *savedBattleTypeFlags; gMain.savedCallback = *savedCallback; SetMainCallback2(CB2_InitBattleInternal); - Free(gUnknown_02023058); - gUnknown_02023058 = NULL; + Free(sMultiPartnerPartyBuffer); + sMultiPartnerPartyBuffer = NULL; } break; } @@ -1611,7 +1612,7 @@ static void CB2_HandleStartMultiBattle(void) sub_8036EB8(4, playerMultiplayerId); SetAllPlayersBerryData(); SetDeoxysStats(); - var = CreateTask(sub_8035D74, 0); + var = CreateTask(InitLinkBattleVsScreen, 0); gTasks[var].data[1] = 0x10E; gTasks[var].data[2] = 0x5A; gTasks[var].data[5] = 0; @@ -1666,7 +1667,7 @@ static void CB2_HandleStartMultiBattle(void) break; case 1: case 2: - memcpy(gPlayerParty + 3, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + memcpy(gPlayerParty + MULTI_PARTY_SIZE, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); break; } } @@ -1683,7 +1684,7 @@ static void CB2_HandleStartMultiBattle(void) break; case 1: case 2: - memcpy(gPlayerParty + 3, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + memcpy(gPlayerParty + MULTI_PARTY_SIZE, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); break; } } @@ -1697,7 +1698,7 @@ static void CB2_HandleStartMultiBattle(void) break; case 1: case 2: - memcpy(gEnemyParty + 3, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); + memcpy(gEnemyParty + MULTI_PARTY_SIZE, gBlockRecvBuffer[id], sizeof(struct Pokemon) * 2); break; } } @@ -2249,7 +2250,7 @@ void sub_8038D64(void) gBattle_BG3_X = 0; gBattle_BG3_Y = 0; - sub_80356D0(); + InitBattleBgsVideo(); LoadCompressedPalette(gBattleTextboxPalette, 0, 64); LoadBattleMenuWindowGfx(); ResetSpriteData(); @@ -2260,7 +2261,7 @@ void sub_8038D64(void) gReservedSpritePaletteCount = 4; SetVBlankCallback(VBlankCB_Battle); - taskId = CreateTask(sub_8035D74, 0); + taskId = CreateTask(InitLinkBattleVsScreen, 0); gTasks[taskId].data[1] = 0x10E; gTasks[taskId].data[2] = 0x5A; gTasks[taskId].data[5] = 1; @@ -2445,7 +2446,7 @@ static void sub_80392A8(void) gBattle_BG2_Y = 0; gBattle_BG3_X = 0; gBattle_BG3_Y = 0; - sub_80356D0(); + InitBattleBgsVideo(); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); LoadBattleMenuWindowGfx(); @@ -3953,7 +3954,7 @@ static void TryDoEventsBeforeFirstTurn(void) *(&gBattleStruct->turnEffectsBattlerId) = 0; *(&gBattleStruct->wishPerishSongState) = 0; *(&gBattleStruct->wishPerishSongBattlerId) = 0; - gBattleScripting.atk49_state = 0; + gBattleScripting.moveendState = 0; gBattleStruct->faintedActionsState = 0; gBattleStruct->turnCountersTracker = 0; gMoveResultFlags = 0; @@ -4016,7 +4017,7 @@ void BattleTurnPassed(void) gHitMarker &= ~(HITMARKER_x100000); gBattleScripting.animTurn = 0; gBattleScripting.animTargetsHit = 0; - gBattleScripting.atk49_state = 0; + gBattleScripting.moveendState = 0; gBattleMoveDamage = 0; gMoveResultFlags = 0; @@ -4121,34 +4122,34 @@ u8 IsRunningFromBattleImpossible(void) return 0; } -void sub_803BDA0(u8 battler) +void SwitchPartyOrder(u8 battler) { s32 i; - u8 r4; - u8 r1; + u8 partyId1; + u8 partyId2; // gBattleStruct->field_60[battler][i] - for (i = 0; i < 3; i++) - gUnknown_0203CF00[i] = *(battler * 3 + i + (u8*)(gBattleStruct->field_60)); + for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++) + gBattlePartyCurrentOrder[i] = *(battler * 3 + i + (u8*)(gBattleStruct->field_60)); - r4 = pokemon_order_func(gBattlerPartyIndexes[battler]); - r1 = pokemon_order_func(*(gBattleStruct->monToSwitchIntoId + battler)); - sub_81B8FB0(r4, r1); + partyId1 = GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[battler]); + partyId2 = GetPartyIdFromBattlePartyId(*(gBattleStruct->monToSwitchIntoId + battler)); + SwitchPartyMonSlots(partyId1, partyId2); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - for (i = 0; i < 3; i++) + for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++) { - *(battler * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; - *(BATTLE_PARTNER(battler) * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; + *(battler * 3 + i + (u8*)(gBattleStruct->field_60)) = gBattlePartyCurrentOrder[i]; + *(BATTLE_PARTNER(battler) * 3 + i + (u8*)(gBattleStruct->field_60)) = gBattlePartyCurrentOrder[i]; } } else { - for (i = 0; i < 3; i++) + for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++) { - *(battler * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; + *(battler * 3 + i + (u8*)(gBattleStruct->field_60)) = gBattlePartyCurrentOrder[i]; } } } @@ -4283,7 +4284,7 @@ static void HandleTurnActionSelectionState(void) || gBattleTypeFlags & BATTLE_TYPE_ARENA || gStatuses3[gActiveBattler] & STATUS3_ROOTED) { - BtlController_EmitChoosePokemon(0, PARTY_CANT_SWITCH, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); + BtlController_EmitChoosePokemon(0, PARTY_ACTION_CANT_SWITCH, PARTY_SIZE, ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); } else if ((i = ABILITY_ON_OPPOSING_FIELD(gActiveBattler, ABILITY_SHADOW_TAG)) || ((i = ABILITY_ON_OPPOSING_FIELD(gActiveBattler, ABILITY_ARENA_TRAP)) @@ -4292,16 +4293,16 @@ static void HandleTurnActionSelectionState(void) || ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BATTLER, gActiveBattler, ABILITY_MAGNET_PULL, 0, 0)) && IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_STEEL))) { - BtlController_EmitChoosePokemon(0, ((i - 1) << 4) | PARTY_ABILITY_PREVENTS, 6, gLastUsedAbility, gBattleStruct->field_60[gActiveBattler]); + BtlController_EmitChoosePokemon(0, ((i - 1) << 4) | PARTY_ACTION_ABILITY_PREVENTS, PARTY_SIZE, gLastUsedAbility, gBattleStruct->field_60[gActiveBattler]); } else { if (gActiveBattler == 2 && gChosenActionByBattler[0] == B_ACTION_SWITCH) - BtlController_EmitChoosePokemon(0, PARTY_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); + BtlController_EmitChoosePokemon(0, PARTY_ACTION_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); else if (gActiveBattler == 3 && gChosenActionByBattler[1] == B_ACTION_SWITCH) - BtlController_EmitChoosePokemon(0, PARTY_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); + BtlController_EmitChoosePokemon(0, PARTY_ACTION_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); else - BtlController_EmitChoosePokemon(0, PARTY_CHOOSE_MON, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); + BtlController_EmitChoosePokemon(0, PARTY_ACTION_CHOOSE_MON, PARTY_SIZE, ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); } MarkBattlerForControllerExec(gActiveBattler); break; @@ -4589,7 +4590,7 @@ static void HandleTurnActionSelectionState(void) for (i = 0; i < gBattlersCount; i++) { if (gChosenActionByBattler[i] == B_ACTION_SWITCH) - sub_80571DC(i, *(gBattleStruct->monToSwitchIntoId + i)); + SwitchPartyOrderInGameMulti(i, *(gBattleStruct->monToSwitchIntoId + i)); } } } @@ -5884,7 +5885,7 @@ static void HandleAction_ActionFinished(void) gLastHitByType[gBattlerAttacker] = 0; gBattleStruct->dynamicMoveType = 0; gDynamicBasePower = 0; - gBattleScripting.atk49_state = 0; + gBattleScripting.moveendState = 0; gBattleCommunication[3] = 0; gBattleCommunication[4] = 0; gBattleScripting.multihitMoveEffect = 0; diff --git a/src/battle_message.c b/src/battle_message.c index 22cdee0b8..1701f26ec 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -20,9 +20,11 @@ #include "trainer_hill.h" #include "window.h" #include "constants/battle_string_ids.h" +#include "constants/frontier_util.h" #include "constants/items.h" #include "constants/moves.h" #include "constants/trainers.h" +#include "constants/trainer_hill.h" struct BattleWindowText { @@ -874,8 +876,8 @@ const u8 * const gBattleStringsTable[BATTLESTRINGS_COUNT] = [STRINGID_FORFEITEDMATCH - 12] = sText_ForfeitedMatch, [STRINGID_PKMNTRANSFERREDSOMEONESPC - 12] = gText_PkmnTransferredSomeonesPC, [STRINGID_PKMNTRANSFERREDLANETTESPC - 12] = gText_PkmnTransferredLanettesPC, - [STRINGID_PKMNBOXSOMEONESPCFULL - 12] = gText_PkmnBoxSomeonesPCFull, - [STRINGID_PKMNBOXLANETTESPCFULL - 12] = gText_PkmnBoxLanettesPCFull, + [STRINGID_PKMNBOXSOMEONESPCFULL - 12] = gText_PkmnTransferredSomeonesPCBoxFull, + [STRINGID_PKMNBOXLANETTESPCFULL - 12] = gText_PkmnTransferredLanettesPCBoxFull, [STRINGID_TRAINER1WINTEXT - 12] = sText_Trainer1WinText, [STRINGID_TRAINER2WINTEXT - 12] = sText_Trainer2WinText, }; @@ -2573,7 +2575,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL) { - CopyTrainerHillTrainerText(4, gTrainerBattleOpponent_A); + CopyTrainerHillTrainerText(TRAINER_HILL_TEXT_PLAYER_WON, gTrainerBattleOpponent_A); toCpy = gStringVar4; } else @@ -2589,7 +2591,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL) { - CopyTrainerHillTrainerText(3, gTrainerBattleOpponent_A); + CopyTrainerHillTrainerText(TRAINER_HILL_TEXT_PLAYER_LOST, gTrainerBattleOpponent_A); toCpy = gStringVar4; } break; @@ -2670,7 +2672,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL) { - CopyTrainerHillTrainerText(4, gTrainerBattleOpponent_B); + CopyTrainerHillTrainerText(TRAINER_HILL_TEXT_PLAYER_WON, gTrainerBattleOpponent_B); toCpy = gStringVar4; } else @@ -2686,7 +2688,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst) } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL) { - CopyTrainerHillTrainerText(3, gTrainerBattleOpponent_B); + CopyTrainerHillTrainerText(TRAINER_HILL_TEXT_PLAYER_LOST, gTrainerBattleOpponent_B); toCpy = gStringVar4; } break; diff --git a/src/battle_pike.c b/src/battle_pike.c index a81d88145..36bf8dcbf 100644 --- a/src/battle_pike.c +++ b/src/battle_pike.c @@ -22,6 +22,7 @@ #include "constants/trainers.h" #include "constants/species.h" #include "constants/moves.h" +#include "constants/party_menu.h" #include "constants/battle_pike.h" struct PikeRoomNPC @@ -922,7 +923,7 @@ static bool8 TryInflictRandomStatus(void) for (i = 0; i < 3; i++) { mon = &gPlayerParty[indices[i]]; - if (pokemon_ailments_get_primary(GetMonData(mon, MON_DATA_STATUS)) == 0 + if (GetAilmentFromStatus(GetMonData(mon, MON_DATA_STATUS)) == AILMENT_NONE && GetMonData(mon, MON_DATA_HP) != 0) { j++; @@ -964,7 +965,7 @@ static bool8 TryInflictRandomStatus(void) for (i = 0; i < 3; i++) { mon = &gPlayerParty[indices[i]]; - if (pokemon_ailments_get_primary(GetMonData(mon, MON_DATA_STATUS)) == 0 + if (GetAilmentFromStatus(GetMonData(mon, MON_DATA_STATUS)) == AILMENT_NONE && GetMonData(mon, MON_DATA_HP) != 0) { j++; @@ -996,7 +997,7 @@ static bool8 AtLeastOneHealthyMon(void) for (i = 0; i < 3; i++) { struct Pokemon *mon = &gPlayerParty[i]; - if (pokemon_ailments_get_primary(GetMonData(mon, MON_DATA_STATUS)) == 0 + if (GetAilmentFromStatus(GetMonData(mon, MON_DATA_STATUS)) == AILMENT_NONE && GetMonData(mon, MON_DATA_HP) != 0) { healthyMonsCount++; @@ -1285,7 +1286,7 @@ static void TryHealMons(u8 healCount) { canBeHealed = TRUE; } - else if (pokemon_ailments_get_primary(GetMonData(mon, MON_DATA_STATUS)) != 0) + else if (GetAilmentFromStatus(GetMonData(mon, MON_DATA_STATUS)) != AILMENT_NONE) { canBeHealed = TRUE; } @@ -1556,7 +1557,7 @@ static void CanAnyPartyMonsBeHealed(void) struct Pokemon *mon = &gPlayerParty[i]; u16 curr = GetMonData(mon, MON_DATA_HP); u16 max = GetMonData(mon, MON_DATA_MAX_HP); - if (curr >= max && pokemon_ailments_get_primary(GetMonData(mon, MON_DATA_STATUS)) == 0) + if (curr >= max && GetAilmentFromStatus(GetMonData(mon, MON_DATA_STATUS)) == AILMENT_NONE) { u8 ppBonuses = GetMonData(mon, MON_DATA_PP_BONUSES); for (j = 0; j < MAX_MON_MOVES; j++) diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index a17a93499..c904d4e98 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -346,12 +346,12 @@ void InitBattlePyramidBagCursorPosition(void) void CB2_PyramidBagMenuFromStartMenu(void) { - sub_81C4F98(0, CB2_ReturnToFieldWithOpenMenu); + GoToBattlePyramidBagMenu(0, CB2_ReturnToFieldWithOpenMenu); } static void sub_81C4F10(void) { - sub_81C4F98(1, SetCB2ToReshowScreenAfterMenu2); + GoToBattlePyramidBagMenu(1, CB2_SetUpReshowBattleScreenAfterMenu2); } void sub_81C4F24(void) @@ -366,18 +366,18 @@ static void sub_81C4F44(u8 taskId) if (!gPaletteFade.active) { CleanupOverworldWindowsAndTilemaps(); - gFieldCallback2 = hm_add_c3_without_phase_2; - sub_81C4F98(3, CB2_ReturnToField); + gFieldCallback2 = CB2_FadeFromPartyMenu; + GoToBattlePyramidBagMenu(3, CB2_ReturnToField); DestroyTask(taskId); } } -void sub_81C4F84(void) +void CB2_ReturnToPyramidBagMenu(void) { - sub_81C4F98(4, gPyramidBagCursorData.callback); + GoToBattlePyramidBagMenu(4, gPyramidBagCursorData.callback); } -void sub_81C4F98(u8 a0, void (*callback)(void)) +void GoToBattlePyramidBagMenu(u8 a0, void (*callback)(void)) { gPyramidBagResources = AllocZeroed(sizeof(*gPyramidBagResources)); @@ -981,7 +981,7 @@ static void HandleMenuActionInput(u8 taskId) sub_8199134(0, 1); } } - else if (gMain.newKeys & DPAD_LEFT || GetLRKeysState() == 1) + else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) { if (id & 1 && IsValidMenuAction(id - 1)) { @@ -989,7 +989,7 @@ static void HandleMenuActionInput(u8 taskId) sub_8199134(-1, 0); } } - else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysState() == 2) + else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) { if (!(id & 1) && IsValidMenuAction(id + 1)) { @@ -1202,7 +1202,7 @@ static void BagAction_Give(u8 taskId) } else if (!ItemId_GetImportance(gSpecialVar_ItemId)) { - gPyramidBagResources->callback2 = sub_81B7F60; + gPyramidBagResources->callback2 = CB2_ChooseMonToGiveItem; sub_81C5B14(taskId); } else @@ -1350,7 +1350,7 @@ static void sub_81C6A14(u8 taskId) SetTaskToMainPyramidBagInputHandler(taskId); } -void sub_81C6A94(void) +void TryStoreHeldItemsInPyramidBag(void) { u8 i; struct Pokemon *party = gPlayerParty; @@ -1363,8 +1363,9 @@ void sub_81C6A94(void) for (i = 0; i < 3; i++) { heldItem = GetMonData(&party[i], MON_DATA_HELD_ITEM); - if (heldItem != 0 && !AddBagItem(heldItem, 1)) + if (heldItem != ITEM_NONE && !AddBagItem(heldItem, 1)) { + // Cant store party held items in pyramid bag because bag is full memcpy(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode], newItems, PYRAMID_BAG_ITEMS_COUNT * sizeof(u16)); memcpy(gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode], newQuantities, PYRAMID_BAG_ITEMS_COUNT * sizeof(u8)); Free(newItems); @@ -1374,7 +1375,7 @@ void sub_81C6A94(void) } } - heldItem = 0; + heldItem = ITEM_NONE; for (i = 0; i < 3; i++) { SetMonData(&party[i], MON_DATA_HELD_ITEM, &heldItem); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 3c3e2480f..eab7b7d04 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -52,6 +52,7 @@ #include "menu_specialized.h" #include "constants/rgb.h" #include "data.h" +#include "constants/party_menu.h" extern struct MusicPlayerInfo gMPlayInfo_BGM; @@ -76,507 +77,507 @@ static void PutLevelAndGenderOnLvlUpBox(void); static void SpriteCB_MonIconOnLvlUpBox(struct Sprite* sprite); -static void atk00_attackcanceler(void); -static void atk01_accuracycheck(void); -static void atk02_attackstring(void); -static void atk03_ppreduce(void); -static void atk04_critcalc(void); -static void atk05_damagecalc(void); -static void atk06_typecalc(void); -static void atk07_adjustnormaldamage(void); -static void atk08_adjustnormaldamage2(void); -static void atk09_attackanimation(void); -static void atk0A_waitanimation(void); -static void atk0B_healthbarupdate(void); -static void atk0C_datahpupdate(void); -static void atk0D_critmessage(void); -static void atk0E_effectivenesssound(void); -static void atk0F_resultmessage(void); -static void atk10_printstring(void); -static void atk11_printselectionstring(void); -static void atk12_waitmessage(void); -static void atk13_printfromtable(void); -static void atk14_printselectionstringfromtable(void); -static void atk15_seteffectwithchance(void); -static void atk16_seteffectprimary(void); -static void atk17_seteffectsecondary(void); -static void atk18_clearstatusfromeffect(void); -static void atk19_tryfaintmon(void); -static void atk1A_dofaintanimation(void); -static void atk1B_cleareffectsonfaint(void); -static void atk1C_jumpifstatus(void); -static void atk1D_jumpifstatus2(void); -static void atk1E_jumpifability(void); -static void atk1F_jumpifsideaffecting(void); -static void atk20_jumpifstat(void); -static void atk21_jumpifstatus3condition(void); -static void atk22_jumpiftype(void); -static void atk23_getexp(void); -static void atk24(void); -static void atk25_movevaluescleanup(void); -static void atk26_setmultihit(void); -static void atk27_decrementmultihit(void); -static void atk28_goto(void); -static void atk29_jumpifbyte(void); -static void atk2A_jumpifhalfword(void); -static void atk2B_jumpifword(void); -static void atk2C_jumpifarrayequal(void); -static void atk2D_jumpifarraynotequal(void); -static void atk2E_setbyte(void); -static void atk2F_addbyte(void); -static void atk30_subbyte(void); -static void atk31_copyarray(void); -static void atk32_copyarraywithindex(void); -static void atk33_orbyte(void); -static void atk34_orhalfword(void); -static void atk35_orword(void); -static void atk36_bicbyte(void); -static void atk37_bichalfword(void); -static void atk38_bicword(void); -static void atk39_pause(void); -static void atk3A_waitstate(void); -static void atk3B_healthbar_update(void); -static void atk3C_return(void); -static void atk3D_end(void); -static void atk3E_end2(void); -static void atk3F_end3(void); -static void atk40_jumpifaffectedbyprotect(void); -static void atk41_call(void); -static void atk42_jumpiftype2(void); -static void atk43_jumpifabilitypresent(void); -static void atk44_endselectionscript(void); -static void atk45_playanimation(void); -static void atk46_playanimation2(void); -static void atk47_setgraphicalstatchangevalues(void); -static void atk48_playstatchangeanimation(void); -static void atk49_moveend(void); -static void atk4A_typecalc2(void); -static void atk4B_returnatktoball(void); -static void atk4C_getswitchedmondata(void); -static void atk4D_switchindataupdate(void); -static void atk4E_switchinanim(void); -static void atk4F_jumpifcantswitch(void); -static void atk50_openpartyscreen(void); -static void atk51_switchhandleorder(void); -static void atk52_switchineffects(void); -static void atk53_trainerslidein(void); -static void atk54_playse(void); -static void atk55_fanfare(void); -static void atk56_playfaintcry(void); -static void atk57(void); -static void atk58_returntoball(void); -static void atk59_handlelearnnewmove(void); -static void atk5A_yesnoboxlearnmove(void); -static void atk5B_yesnoboxstoplearningmove(void); -static void atk5C_hitanimation(void); -static void atk5D_getmoneyreward(void); -static void atk5E(void); -static void atk5F_swapattackerwithtarget(void); -static void atk60_incrementgamestat(void); -static void atk61_drawpartystatussummary(void); -static void atk62_hidepartystatussummary(void); -static void atk63_jumptocalledmove(void); -static void atk64_statusanimation(void); -static void atk65_status2animation(void); -static void atk66_chosenstatusanimation(void); -static void atk67_yesnobox(void); -static void atk68_cancelallactions(void); -static void atk69_adjustsetdamage(void); -static void atk6A_removeitem(void); -static void atk6B_atknameinbuff1(void); -static void atk6C_drawlvlupbox(void); -static void atk6D_resetsentmonsvalue(void); -static void atk6E_setatktoplayer0(void); -static void atk6F_makevisible(void); -static void atk70_recordlastability(void); -static void atk71_buffermovetolearn(void); -static void atk72_jumpifplayerran(void); -static void atk73_hpthresholds(void); -static void atk74_hpthresholds2(void); -static void atk75_useitemonopponent(void); -static void atk76_various(void); -static void atk77_setprotectlike(void); -static void atk78_faintifabilitynotdamp(void); -static void atk79_setatkhptozero(void); -static void atk7A_jumpifnexttargetvalid(void); -static void atk7B_tryhealhalfhealth(void); -static void atk7C_trymirrormove(void); -static void atk7D_setrain(void); -static void atk7E_setreflect(void); -static void atk7F_setseeded(void); -static void atk80_manipulatedamage(void); -static void atk81_trysetrest(void); -static void atk82_jumpifnotfirstturn(void); -static void atk83_nop(void); -static void atk84_jumpifcantmakeasleep(void); -static void atk85_stockpile(void); -static void atk86_stockpiletobasedamage(void); -static void atk87_stockpiletohpheal(void); -static void atk88_negativedamage(void); -static void atk89_statbuffchange(void); -static void atk8A_normalisebuffs(void); -static void atk8B_setbide(void); -static void atk8C_confuseifrepeatingattackends(void); -static void atk8D_setmultihitcounter(void); -static void atk8E_initmultihitstring(void); -static void atk8F_forcerandomswitch(void); -static void atk90_tryconversiontypechange(void); -static void atk91_givepaydaymoney(void); -static void atk92_setlightscreen(void); -static void atk93_tryKO(void); -static void atk94_damagetohalftargethp(void); -static void atk95_setsandstorm(void); -static void atk96_weatherdamage(void); -static void atk97_tryinfatuating(void); -static void atk98_updatestatusicon(void); -static void atk99_setmist(void); -static void atk9A_setfocusenergy(void); -static void atk9B_transformdataexecution(void); -static void atk9C_setsubstitute(void); -static void atk9D_mimicattackcopy(void); -static void atk9E_metronome(void); -static void atk9F_dmgtolevel(void); -static void atkA0_psywavedamageeffect(void); -static void atkA1_counterdamagecalculator(void); -static void atkA2_mirrorcoatdamagecalculator(void); -static void atkA3_disablelastusedattack(void); -static void atkA4_trysetencore(void); -static void atkA5_painsplitdmgcalc(void); -static void atkA6_settypetorandomresistance(void); -static void atkA7_setalwayshitflag(void); -static void atkA8_copymovepermanently(void); -static void atkA9_trychoosesleeptalkmove(void); -static void atkAA_setdestinybond(void); -static void atkAB_trysetdestinybondtohappen(void); -static void atkAC_remaininghptopower(void); -static void atkAD_tryspiteppreduce(void); -static void atkAE_healpartystatus(void); -static void atkAF_cursetarget(void); -static void atkB0_trysetspikes(void); -static void atkB1_setforesight(void); -static void atkB2_trysetperishsong(void); -static void atkB3_rolloutdamagecalculation(void); -static void atkB4_jumpifconfusedandstatmaxed(void); -static void atkB5_furycuttercalc(void); -static void atkB6_happinesstodamagecalculation(void); -static void atkB7_presentdamagecalculation(void); -static void atkB8_setsafeguard(void); -static void atkB9_magnitudedamagecalculation(void); -static void atkBA_jumpifnopursuitswitchdmg(void); -static void atkBB_setsunny(void); -static void atkBC_maxattackhalvehp(void); -static void atkBD_copyfoestats(void); -static void atkBE_rapidspinfree(void); -static void atkBF_setdefensecurlbit(void); -static void atkC0_recoverbasedonsunlight(void); -static void atkC1_hiddenpowercalc(void); -static void atkC2_selectfirstvalidtarget(void); -static void atkC3_trysetfutureattack(void); -static void atkC4_trydobeatup(void); -static void atkC5_setsemiinvulnerablebit(void); -static void atkC6_clearsemiinvulnerablebit(void); -static void atkC7_setminimize(void); -static void atkC8_sethail(void); -static void atkC9_jumpifattackandspecialattackcannotfall(void); -static void atkCA_setforcedtarget(void); -static void atkCB_setcharge(void); -static void atkCC_callterrainattack(void); -static void atkCD_cureifburnedparalysedorpoisoned(void); -static void atkCE_settorment(void); -static void atkCF_jumpifnodamage(void); -static void atkD0_settaunt(void); -static void atkD1_trysethelpinghand(void); -static void atkD2_tryswapitems(void); -static void atkD3_trycopyability(void); -static void atkD4_trywish(void); -static void atkD5_trysetroots(void); -static void atkD6_doubledamagedealtifdamaged(void); -static void atkD7_setyawn(void); -static void atkD8_setdamagetohealthdifference(void); -static void atkD9_scaledamagebyhealthratio(void); -static void atkDA_tryswapabilities(void); -static void atkDB_tryimprison(void); -static void atkDC_trysetgrudge(void); -static void atkDD_weightdamagecalculation(void); -static void atkDE_assistattackselect(void); -static void atkDF_trysetmagiccoat(void); -static void atkE0_trysetsnatch(void); -static void atkE1_trygetintimidatetarget(void); -static void atkE2_switchoutabilities(void); -static void atkE3_jumpifhasnohp(void); -static void atkE4_getsecretpowereffect(void); -static void atkE5_pickup(void); -static void atkE6_docastformchangeanimation(void); -static void atkE7_trycastformdatachange(void); -static void atkE8_settypebasedhalvers(void); -static void atkE9_setweatherballtype(void); -static void atkEA_tryrecycleitem(void); -static void atkEB_settypetoterrain(void); -static void atkEC_pursuitrelated(void); -static void atkEF_snatchsetbattlers(void); -static void atkEE_removelightscreenreflect(void); -static void atkEF_handleballthrow(void); -static void atkF0_givecaughtmon(void); -static void atkF1_trysetcaughtmondexflags(void); -static void atkF2_displaydexinfo(void); -static void atkF3_trygivecaughtmonnick(void); -static void atkF4_subattackerhpbydmg(void); -static void atkF5_removeattackerstatus1(void); -static void atkF6_finishaction(void); -static void atkF7_finishturn(void); -static void atkF8_trainerslideout(void); +static void Cmd_attackcanceler(void); +static void Cmd_accuracycheck(void); +static void Cmd_attackstring(void); +static void Cmd_ppreduce(void); +static void Cmd_critcalc(void); +static void Cmd_damagecalc(void); +static void Cmd_typecalc(void); +static void Cmd_adjustnormaldamage(void); +static void Cmd_adjustnormaldamage2(void); +static void Cmd_attackanimation(void); +static void Cmd_waitanimation(void); +static void Cmd_healthbarupdate(void); +static void Cmd_datahpupdate(void); +static void Cmd_critmessage(void); +static void Cmd_effectivenesssound(void); +static void Cmd_resultmessage(void); +static void Cmd_printstring(void); +static void Cmd_printselectionstring(void); +static void Cmd_waitmessage(void); +static void Cmd_printfromtable(void); +static void Cmd_printselectionstringfromtable(void); +static void Cmd_seteffectwithchance(void); +static void Cmd_seteffectprimary(void); +static void Cmd_seteffectsecondary(void); +static void Cmd_clearstatusfromeffect(void); +static void Cmd_tryfaintmon(void); +static void Cmd_dofaintanimation(void); +static void Cmd_cleareffectsonfaint(void); +static void Cmd_jumpifstatus(void); +static void Cmd_jumpifstatus2(void); +static void Cmd_jumpifability(void); +static void Cmd_jumpifsideaffecting(void); +static void Cmd_jumpifstat(void); +static void Cmd_jumpifstatus3condition(void); +static void Cmd_jumpiftype(void); +static void Cmd_getexp(void); +static void Cmd_unknown_24(void); +static void Cmd_movevaluescleanup(void); +static void Cmd_setmultihit(void); +static void Cmd_decrementmultihit(void); +static void Cmd_goto(void); +static void Cmd_jumpifbyte(void); +static void Cmd_jumpifhalfword(void); +static void Cmd_jumpifword(void); +static void Cmd_jumpifarrayequal(void); +static void Cmd_jumpifarraynotequal(void); +static void Cmd_setbyte(void); +static void Cmd_addbyte(void); +static void Cmd_subbyte(void); +static void Cmd_copyarray(void); +static void Cmd_copyarraywithindex(void); +static void Cmd_orbyte(void); +static void Cmd_orhalfword(void); +static void Cmd_orword(void); +static void Cmd_bicbyte(void); +static void Cmd_bichalfword(void); +static void Cmd_bicword(void); +static void Cmd_pause(void); +static void Cmd_waitstate(void); +static void Cmd_healthbar_update(void); +static void Cmd_return(void); +static void Cmd_end(void); +static void Cmd_end2(void); +static void Cmd_end3(void); +static void Cmd_jumpifaffectedbyprotect(void); +static void Cmd_call(void); +static void Cmd_jumpiftype2(void); +static void Cmd_jumpifabilitypresent(void); +static void Cmd_endselectionscript(void); +static void Cmd_playanimation(void); +static void Cmd_playanimation2(void); +static void Cmd_setgraphicalstatchangevalues(void); +static void Cmd_playstatchangeanimation(void); +static void Cmd_moveend(void); +static void Cmd_typecalc2(void); +static void Cmd_returnatktoball(void); +static void Cmd_getswitchedmondata(void); +static void Cmd_switchindataupdate(void); +static void Cmd_switchinanim(void); +static void Cmd_jumpifcantswitch(void); +static void Cmd_openpartyscreen(void); +static void Cmd_switchhandleorder(void); +static void Cmd_switchineffects(void); +static void Cmd_trainerslidein(void); +static void Cmd_playse(void); +static void Cmd_fanfare(void); +static void Cmd_playfaintcry(void); +static void Cmd_unknown_57(void); +static void Cmd_returntoball(void); +static void Cmd_handlelearnnewmove(void); +static void Cmd_yesnoboxlearnmove(void); +static void Cmd_yesnoboxstoplearningmove(void); +static void Cmd_hitanimation(void); +static void Cmd_getmoneyreward(void); +static void Cmd_unknown_5E(void); +static void Cmd_swapattackerwithtarget(void); +static void Cmd_incrementgamestat(void); +static void Cmd_drawpartystatussummary(void); +static void Cmd_hidepartystatussummary(void); +static void Cmd_jumptocalledmove(void); +static void Cmd_statusanimation(void); +static void Cmd_status2animation(void); +static void Cmd_chosenstatusanimation(void); +static void Cmd_yesnobox(void); +static void Cmd_cancelallactions(void); +static void Cmd_adjustsetdamage(void); +static void Cmd_removeitem(void); +static void Cmd_atknameinbuff1(void); +static void Cmd_drawlvlupbox(void); +static void Cmd_resetsentmonsvalue(void); +static void Cmd_setatktoplayer0(void); +static void Cmd_makevisible(void); +static void Cmd_recordlastability(void); +static void Cmd_buffermovetolearn(void); +static void Cmd_jumpifplayerran(void); +static void Cmd_hpthresholds(void); +static void Cmd_hpthresholds2(void); +static void Cmd_useitemonopponent(void); +static void Cmd_various(void); +static void Cmd_setprotectlike(void); +static void Cmd_faintifabilitynotdamp(void); +static void Cmd_setatkhptozero(void); +static void Cmd_jumpifnexttargetvalid(void); +static void Cmd_tryhealhalfhealth(void); +static void Cmd_trymirrormove(void); +static void Cmd_setrain(void); +static void Cmd_setreflect(void); +static void Cmd_setseeded(void); +static void Cmd_manipulatedamage(void); +static void Cmd_trysetrest(void); +static void Cmd_jumpifnotfirstturn(void); +static void Cmd_nop(void); +static void Cmd_jumpifcantmakeasleep(void); +static void Cmd_stockpile(void); +static void Cmd_stockpiletobasedamage(void); +static void Cmd_stockpiletohpheal(void); +static void Cmd_negativedamage(void); +static void Cmd_statbuffchange(void); +static void Cmd_normalisebuffs(void); +static void Cmd_setbide(void); +static void Cmd_confuseifrepeatingattackends(void); +static void Cmd_setmultihitcounter(void); +static void Cmd_initmultihitstring(void); +static void Cmd_forcerandomswitch(void); +static void Cmd_tryconversiontypechange(void); +static void Cmd_givepaydaymoney(void); +static void Cmd_setlightscreen(void); +static void Cmd_tryKO(void); +static void Cmd_damagetohalftargethp(void); +static void Cmd_setsandstorm(void); +static void Cmd_weatherdamage(void); +static void Cmd_tryinfatuating(void); +static void Cmd_updatestatusicon(void); +static void Cmd_setmist(void); +static void Cmd_setfocusenergy(void); +static void Cmd_transformdataexecution(void); +static void Cmd_setsubstitute(void); +static void Cmd_mimicattackcopy(void); +static void Cmd_metronome(void); +static void Cmd_dmgtolevel(void); +static void Cmd_psywavedamageeffect(void); +static void Cmd_counterdamagecalculator(void); +static void Cmd_mirrorcoatdamagecalculator(void); +static void Cmd_disablelastusedattack(void); +static void Cmd_trysetencore(void); +static void Cmd_painsplitdmgcalc(void); +static void Cmd_settypetorandomresistance(void); +static void Cmd_setalwayshitflag(void); +static void Cmd_copymovepermanently(void); +static void Cmd_trychoosesleeptalkmove(void); +static void Cmd_setdestinybond(void); +static void Cmd_trysetdestinybondtohappen(void); +static void Cmd_remaininghptopower(void); +static void Cmd_tryspiteppreduce(void); +static void Cmd_healpartystatus(void); +static void Cmd_cursetarget(void); +static void Cmd_trysetspikes(void); +static void Cmd_setforesight(void); +static void Cmd_trysetperishsong(void); +static void Cmd_rolloutdamagecalculation(void); +static void Cmd_jumpifconfusedandstatmaxed(void); +static void Cmd_furycuttercalc(void); +static void Cmd_happinesstodamagecalculation(void); +static void Cmd_presentdamagecalculation(void); +static void Cmd_setsafeguard(void); +static void Cmd_magnitudedamagecalculation(void); +static void Cmd_jumpifnopursuitswitchdmg(void); +static void Cmd_setsunny(void); +static void Cmd_maxattackhalvehp(void); +static void Cmd_copyfoestats(void); +static void Cmd_rapidspinfree(void); +static void Cmd_setdefensecurlbit(void); +static void Cmd_recoverbasedonsunlight(void); +static void Cmd_hiddenpowercalc(void); +static void Cmd_selectfirstvalidtarget(void); +static void Cmd_trysetfutureattack(void); +static void Cmd_trydobeatup(void); +static void Cmd_setsemiinvulnerablebit(void); +static void Cmd_clearsemiinvulnerablebit(void); +static void Cmd_setminimize(void); +static void Cmd_sethail(void); +static void Cmd_jumpifattackandspecialattackcannotfall(void); +static void Cmd_setforcedtarget(void); +static void Cmd_setcharge(void); +static void Cmd_callterrainattack(void); +static void Cmd_cureifburnedparalysedorpoisoned(void); +static void Cmd_settorment(void); +static void Cmd_jumpifnodamage(void); +static void Cmd_settaunt(void); +static void Cmd_trysethelpinghand(void); +static void Cmd_tryswapitems(void); +static void Cmd_trycopyability(void); +static void Cmd_trywish(void); +static void Cmd_trysetroots(void); +static void Cmd_doubledamagedealtifdamaged(void); +static void Cmd_setyawn(void); +static void Cmd_setdamagetohealthdifference(void); +static void Cmd_scaledamagebyhealthratio(void); +static void Cmd_tryswapabilities(void); +static void Cmd_tryimprison(void); +static void Cmd_trysetgrudge(void); +static void Cmd_weightdamagecalculation(void); +static void Cmd_assistattackselect(void); +static void Cmd_trysetmagiccoat(void); +static void Cmd_trysetsnatch(void); +static void Cmd_trygetintimidatetarget(void); +static void Cmd_switchoutabilities(void); +static void Cmd_jumpifhasnohp(void); +static void Cmd_getsecretpowereffect(void); +static void Cmd_pickup(void); +static void Cmd_docastformchangeanimation(void); +static void Cmd_trycastformdatachange(void); +static void Cmd_settypebasedhalvers(void); +static void Cmd_setweatherballtype(void); +static void Cmd_tryrecycleitem(void); +static void Cmd_settypetoterrain(void); +static void Cmd_pursuitrelated(void); +static void Cmd_snatchsetbattlers(void); +static void Cmd_removelightscreenreflect(void); +static void Cmd_handleballthrow(void); +static void Cmd_givecaughtmon(void); +static void Cmd_trysetcaughtmondexflags(void); +static void Cmd_displaydexinfo(void); +static void Cmd_trygivecaughtmonnick(void); +static void Cmd_subattackerhpbydmg(void); +static void Cmd_removeattackerstatus1(void); +static void Cmd_finishaction(void); +static void Cmd_finishturn(void); +static void Cmd_trainerslideout(void); void (* const gBattleScriptingCommandsTable[])(void) = { - atk00_attackcanceler, - atk01_accuracycheck, - atk02_attackstring, - atk03_ppreduce, - atk04_critcalc, - atk05_damagecalc, - atk06_typecalc, - atk07_adjustnormaldamage, - atk08_adjustnormaldamage2, - atk09_attackanimation, - atk0A_waitanimation, - atk0B_healthbarupdate, - atk0C_datahpupdate, - atk0D_critmessage, - atk0E_effectivenesssound, - atk0F_resultmessage, - atk10_printstring, - atk11_printselectionstring, - atk12_waitmessage, - atk13_printfromtable, - atk14_printselectionstringfromtable, - atk15_seteffectwithchance, - atk16_seteffectprimary, - atk17_seteffectsecondary, - atk18_clearstatusfromeffect, - atk19_tryfaintmon, - atk1A_dofaintanimation, - atk1B_cleareffectsonfaint, - atk1C_jumpifstatus, - atk1D_jumpifstatus2, - atk1E_jumpifability, - atk1F_jumpifsideaffecting, - atk20_jumpifstat, - atk21_jumpifstatus3condition, - atk22_jumpiftype, - atk23_getexp, - atk24, - atk25_movevaluescleanup, - atk26_setmultihit, - atk27_decrementmultihit, - atk28_goto, - atk29_jumpifbyte, - atk2A_jumpifhalfword, - atk2B_jumpifword, - atk2C_jumpifarrayequal, - atk2D_jumpifarraynotequal, - atk2E_setbyte, - atk2F_addbyte, - atk30_subbyte, - atk31_copyarray, - atk32_copyarraywithindex, - atk33_orbyte, - atk34_orhalfword, - atk35_orword, - atk36_bicbyte, - atk37_bichalfword, - atk38_bicword, - atk39_pause, - atk3A_waitstate, - atk3B_healthbar_update, - atk3C_return, - atk3D_end, - atk3E_end2, - atk3F_end3, - atk40_jumpifaffectedbyprotect, - atk41_call, - atk42_jumpiftype2, - atk43_jumpifabilitypresent, - atk44_endselectionscript, - atk45_playanimation, - atk46_playanimation2, - atk47_setgraphicalstatchangevalues, - atk48_playstatchangeanimation, - atk49_moveend, - atk4A_typecalc2, - atk4B_returnatktoball, - atk4C_getswitchedmondata, - atk4D_switchindataupdate, - atk4E_switchinanim, - atk4F_jumpifcantswitch, - atk50_openpartyscreen, - atk51_switchhandleorder, - atk52_switchineffects, - atk53_trainerslidein, - atk54_playse, - atk55_fanfare, - atk56_playfaintcry, - atk57, - atk58_returntoball, - atk59_handlelearnnewmove, - atk5A_yesnoboxlearnmove, - atk5B_yesnoboxstoplearningmove, - atk5C_hitanimation, - atk5D_getmoneyreward, - atk5E, - atk5F_swapattackerwithtarget, - atk60_incrementgamestat, - atk61_drawpartystatussummary, - atk62_hidepartystatussummary, - atk63_jumptocalledmove, - atk64_statusanimation, - atk65_status2animation, - atk66_chosenstatusanimation, - atk67_yesnobox, - atk68_cancelallactions, - atk69_adjustsetdamage, - atk6A_removeitem, - atk6B_atknameinbuff1, - atk6C_drawlvlupbox, - atk6D_resetsentmonsvalue, - atk6E_setatktoplayer0, - atk6F_makevisible, - atk70_recordlastability, - atk71_buffermovetolearn, - atk72_jumpifplayerran, - atk73_hpthresholds, - atk74_hpthresholds2, - atk75_useitemonopponent, - atk76_various, - atk77_setprotectlike, - atk78_faintifabilitynotdamp, - atk79_setatkhptozero, - atk7A_jumpifnexttargetvalid, - atk7B_tryhealhalfhealth, - atk7C_trymirrormove, - atk7D_setrain, - atk7E_setreflect, - atk7F_setseeded, - atk80_manipulatedamage, - atk81_trysetrest, - atk82_jumpifnotfirstturn, - atk83_nop, - atk84_jumpifcantmakeasleep, - atk85_stockpile, - atk86_stockpiletobasedamage, - atk87_stockpiletohpheal, - atk88_negativedamage, - atk89_statbuffchange, - atk8A_normalisebuffs, - atk8B_setbide, - atk8C_confuseifrepeatingattackends, - atk8D_setmultihitcounter, - atk8E_initmultihitstring, - atk8F_forcerandomswitch, - atk90_tryconversiontypechange, - atk91_givepaydaymoney, - atk92_setlightscreen, - atk93_tryKO, - atk94_damagetohalftargethp, - atk95_setsandstorm, - atk96_weatherdamage, - atk97_tryinfatuating, - atk98_updatestatusicon, - atk99_setmist, - atk9A_setfocusenergy, - atk9B_transformdataexecution, - atk9C_setsubstitute, - atk9D_mimicattackcopy, - atk9E_metronome, - atk9F_dmgtolevel, - atkA0_psywavedamageeffect, - atkA1_counterdamagecalculator, - atkA2_mirrorcoatdamagecalculator, - atkA3_disablelastusedattack, - atkA4_trysetencore, - atkA5_painsplitdmgcalc, - atkA6_settypetorandomresistance, - atkA7_setalwayshitflag, - atkA8_copymovepermanently, - atkA9_trychoosesleeptalkmove, - atkAA_setdestinybond, - atkAB_trysetdestinybondtohappen, - atkAC_remaininghptopower, - atkAD_tryspiteppreduce, - atkAE_healpartystatus, - atkAF_cursetarget, - atkB0_trysetspikes, - atkB1_setforesight, - atkB2_trysetperishsong, - atkB3_rolloutdamagecalculation, - atkB4_jumpifconfusedandstatmaxed, - atkB5_furycuttercalc, - atkB6_happinesstodamagecalculation, - atkB7_presentdamagecalculation, - atkB8_setsafeguard, - atkB9_magnitudedamagecalculation, - atkBA_jumpifnopursuitswitchdmg, - atkBB_setsunny, - atkBC_maxattackhalvehp, - atkBD_copyfoestats, - atkBE_rapidspinfree, - atkBF_setdefensecurlbit, - atkC0_recoverbasedonsunlight, - atkC1_hiddenpowercalc, - atkC2_selectfirstvalidtarget, - atkC3_trysetfutureattack, - atkC4_trydobeatup, - atkC5_setsemiinvulnerablebit, - atkC6_clearsemiinvulnerablebit, - atkC7_setminimize, - atkC8_sethail, - atkC9_jumpifattackandspecialattackcannotfall, - atkCA_setforcedtarget, - atkCB_setcharge, - atkCC_callterrainattack, - atkCD_cureifburnedparalysedorpoisoned, - atkCE_settorment, - atkCF_jumpifnodamage, - atkD0_settaunt, - atkD1_trysethelpinghand, - atkD2_tryswapitems, - atkD3_trycopyability, - atkD4_trywish, - atkD5_trysetroots, - atkD6_doubledamagedealtifdamaged, - atkD7_setyawn, - atkD8_setdamagetohealthdifference, - atkD9_scaledamagebyhealthratio, - atkDA_tryswapabilities, - atkDB_tryimprison, - atkDC_trysetgrudge, - atkDD_weightdamagecalculation, - atkDE_assistattackselect, - atkDF_trysetmagiccoat, - atkE0_trysetsnatch, - atkE1_trygetintimidatetarget, - atkE2_switchoutabilities, - atkE3_jumpifhasnohp, - atkE4_getsecretpowereffect, - atkE5_pickup, - atkE6_docastformchangeanimation, - atkE7_trycastformdatachange, - atkE8_settypebasedhalvers, - atkE9_setweatherballtype, - atkEA_tryrecycleitem, - atkEB_settypetoterrain, - atkEC_pursuitrelated, - atkEF_snatchsetbattlers, - atkEE_removelightscreenreflect, - atkEF_handleballthrow, - atkF0_givecaughtmon, - atkF1_trysetcaughtmondexflags, - atkF2_displaydexinfo, - atkF3_trygivecaughtmonnick, - atkF4_subattackerhpbydmg, - atkF5_removeattackerstatus1, - atkF6_finishaction, - atkF7_finishturn, - atkF8_trainerslideout + Cmd_attackcanceler, //0x0 + Cmd_accuracycheck, //0x1 + Cmd_attackstring, //0x2 + Cmd_ppreduce, //0x3 + Cmd_critcalc, //0x4 + Cmd_damagecalc, //0x5 + Cmd_typecalc, //0x6 + Cmd_adjustnormaldamage, //0x7 + Cmd_adjustnormaldamage2, //0x8 + Cmd_attackanimation, //0x9 + Cmd_waitanimation, //0xA + Cmd_healthbarupdate, //0xB + Cmd_datahpupdate, //0xC + Cmd_critmessage, //0xD + Cmd_effectivenesssound, //0xE + Cmd_resultmessage, //0xF + Cmd_printstring, //0x10 + Cmd_printselectionstring, //0x11 + Cmd_waitmessage, //0x12 + Cmd_printfromtable, //0x13 + Cmd_printselectionstringfromtable, //0x14 + Cmd_seteffectwithchance, //0x15 + Cmd_seteffectprimary, //0x16 + Cmd_seteffectsecondary, //0x17 + Cmd_clearstatusfromeffect, //0x18 + Cmd_tryfaintmon, //0x19 + Cmd_dofaintanimation, //0x1A + Cmd_cleareffectsonfaint, //0x1B + Cmd_jumpifstatus, //0x1C + Cmd_jumpifstatus2, //0x1D + Cmd_jumpifability, //0x1E + Cmd_jumpifsideaffecting, //0x1F + Cmd_jumpifstat, //0x20 + Cmd_jumpifstatus3condition, //0x21 + Cmd_jumpiftype, //0x22 + Cmd_getexp, //0x23 + Cmd_unknown_24, //0x24 + Cmd_movevaluescleanup, //0x25 + Cmd_setmultihit, //0x26 + Cmd_decrementmultihit, //0x27 + Cmd_goto, //0x28 + Cmd_jumpifbyte, //0x29 + Cmd_jumpifhalfword, //0x2A + Cmd_jumpifword, //0x2B + Cmd_jumpifarrayequal, //0x2C + Cmd_jumpifarraynotequal, //0x2D + Cmd_setbyte, //0x2E + Cmd_addbyte, //0x2F + Cmd_subbyte, //0x30 + Cmd_copyarray, //0x31 + Cmd_copyarraywithindex, //0x32 + Cmd_orbyte, //0x33 + Cmd_orhalfword, //0x34 + Cmd_orword, //0x35 + Cmd_bicbyte, //0x36 + Cmd_bichalfword, //0x37 + Cmd_bicword, //0x38 + Cmd_pause, //0x39 + Cmd_waitstate, //0x3A + Cmd_healthbar_update, //0x3B + Cmd_return, //0x3C + Cmd_end, //0x3D + Cmd_end2, //0x3E + Cmd_end3, //0x3F + Cmd_jumpifaffectedbyprotect, //0x40 + Cmd_call, //0x41 + Cmd_jumpiftype2, //0x42 + Cmd_jumpifabilitypresent, //0x43 + Cmd_endselectionscript, //0x44 + Cmd_playanimation, //0x45 + Cmd_playanimation2, //0x46 + Cmd_setgraphicalstatchangevalues, //0x47 + Cmd_playstatchangeanimation, //0x48 + Cmd_moveend, //0x49 + Cmd_typecalc2, //0x4A + Cmd_returnatktoball, //0x4B + Cmd_getswitchedmondata, //0x4C + Cmd_switchindataupdate, //0x4D + Cmd_switchinanim, //0x4E + Cmd_jumpifcantswitch, //0x4F + Cmd_openpartyscreen, //0x50 + Cmd_switchhandleorder, //0x51 + Cmd_switchineffects, //0x52 + Cmd_trainerslidein, //0x53 + Cmd_playse, //0x54 + Cmd_fanfare, //0x55 + Cmd_playfaintcry, //0x56 + Cmd_unknown_57, //0x57 + Cmd_returntoball, //0x58 + Cmd_handlelearnnewmove, //0x59 + Cmd_yesnoboxlearnmove, //0x5A + Cmd_yesnoboxstoplearningmove, //0x5B + Cmd_hitanimation, //0x5C + Cmd_getmoneyreward, //0x5D + Cmd_unknown_5E, //0x5E + Cmd_swapattackerwithtarget, //0x5F + Cmd_incrementgamestat, //0x60 + Cmd_drawpartystatussummary, //0x61 + Cmd_hidepartystatussummary, //0x62 + Cmd_jumptocalledmove, //0x63 + Cmd_statusanimation, //0x64 + Cmd_status2animation, //0x65 + Cmd_chosenstatusanimation, //0x66 + Cmd_yesnobox, //0x67 + Cmd_cancelallactions, //0x68 + Cmd_adjustsetdamage, //0x69 + Cmd_removeitem, //0x6A + Cmd_atknameinbuff1, //0x6B + Cmd_drawlvlupbox, //0x6C + Cmd_resetsentmonsvalue, //0x6D + Cmd_setatktoplayer0, //0x6E + Cmd_makevisible, //0x6F + Cmd_recordlastability, //0x70 + Cmd_buffermovetolearn, //0x71 + Cmd_jumpifplayerran, //0x72 + Cmd_hpthresholds, //0x73 + Cmd_hpthresholds2, //0x74 + Cmd_useitemonopponent, //0x75 + Cmd_various, //0x76 + Cmd_setprotectlike, //0x77 + Cmd_faintifabilitynotdamp, //0x78 + Cmd_setatkhptozero, //0x79 + Cmd_jumpifnexttargetvalid, //0x7A + Cmd_tryhealhalfhealth, //0x7B + Cmd_trymirrormove, //0x7C + Cmd_setrain, //0x7D + Cmd_setreflect, //0x7E + Cmd_setseeded, //0x7F + Cmd_manipulatedamage, //0x80 + Cmd_trysetrest, //0x81 + Cmd_jumpifnotfirstturn, //0x82 + Cmd_nop, //0x83 + Cmd_jumpifcantmakeasleep, //0x84 + Cmd_stockpile, //0x85 + Cmd_stockpiletobasedamage, //0x86 + Cmd_stockpiletohpheal, //0x87 + Cmd_negativedamage, //0x88 + Cmd_statbuffchange, //0x89 + Cmd_normalisebuffs, //0x8A + Cmd_setbide, //0x8B + Cmd_confuseifrepeatingattackends, //0x8C + Cmd_setmultihitcounter, //0x8D + Cmd_initmultihitstring, //0x8E + Cmd_forcerandomswitch, //0x8F + Cmd_tryconversiontypechange, //0x90 + Cmd_givepaydaymoney, //0x91 + Cmd_setlightscreen, //0x92 + Cmd_tryKO, //0x93 + Cmd_damagetohalftargethp, //0x94 + Cmd_setsandstorm, //0x95 + Cmd_weatherdamage, //0x96 + Cmd_tryinfatuating, //0x97 + Cmd_updatestatusicon, //0x98 + Cmd_setmist, //0x99 + Cmd_setfocusenergy, //0x9A + Cmd_transformdataexecution, //0x9B + Cmd_setsubstitute, //0x9C + Cmd_mimicattackcopy, //0x9D + Cmd_metronome, //0x9E + Cmd_dmgtolevel, //0x9F + Cmd_psywavedamageeffect, //0xA0 + Cmd_counterdamagecalculator, //0xA1 + Cmd_mirrorcoatdamagecalculator, //0xA2 + Cmd_disablelastusedattack, //0xA3 + Cmd_trysetencore, //0xA4 + Cmd_painsplitdmgcalc, //0xA5 + Cmd_settypetorandomresistance, //0xA6 + Cmd_setalwayshitflag, //0xA7 + Cmd_copymovepermanently, //0xA8 + Cmd_trychoosesleeptalkmove, //0xA9 + Cmd_setdestinybond, //0xAA + Cmd_trysetdestinybondtohappen, //0xAB + Cmd_remaininghptopower, //0xAC + Cmd_tryspiteppreduce, //0xAD + Cmd_healpartystatus, //0xAE + Cmd_cursetarget, //0xAF + Cmd_trysetspikes, //0xB0 + Cmd_setforesight, //0xB1 + Cmd_trysetperishsong, //0xB2 + Cmd_rolloutdamagecalculation, //0xB3 + Cmd_jumpifconfusedandstatmaxed, //0xB4 + Cmd_furycuttercalc, //0xB5 + Cmd_happinesstodamagecalculation, //0xB6 + Cmd_presentdamagecalculation, //0xB7 + Cmd_setsafeguard, //0xB8 + Cmd_magnitudedamagecalculation, //0xB9 + Cmd_jumpifnopursuitswitchdmg, //0xBA + Cmd_setsunny, //0xBB + Cmd_maxattackhalvehp, //0xBC + Cmd_copyfoestats, //0xBD + Cmd_rapidspinfree, //0xBE + Cmd_setdefensecurlbit, //0xBF + Cmd_recoverbasedonsunlight, //0xC0 + Cmd_hiddenpowercalc, //0xC1 + Cmd_selectfirstvalidtarget, //0xC2 + Cmd_trysetfutureattack, //0xC3 + Cmd_trydobeatup, //0xC4 + Cmd_setsemiinvulnerablebit, //0xC5 + Cmd_clearsemiinvulnerablebit, //0xC6 + Cmd_setminimize, //0xC7 + Cmd_sethail, //0xC8 + Cmd_jumpifattackandspecialattackcannotfall, //0xC9 + Cmd_setforcedtarget, //0xCA + Cmd_setcharge, //0xCB + Cmd_callterrainattack, //0xCC + Cmd_cureifburnedparalysedorpoisoned, //0xCD + Cmd_settorment, //0xCE + Cmd_jumpifnodamage, //0xCF + Cmd_settaunt, //0xD0 + Cmd_trysethelpinghand, //0xD1 + Cmd_tryswapitems, //0xD2 + Cmd_trycopyability, //0xD3 + Cmd_trywish, //0xD4 + Cmd_trysetroots, //0xD5 + Cmd_doubledamagedealtifdamaged, //0xD6 + Cmd_setyawn, //0xD7 + Cmd_setdamagetohealthdifference, //0xD8 + Cmd_scaledamagebyhealthratio, //0xD9 + Cmd_tryswapabilities, //0xDA + Cmd_tryimprison, //0xDB + Cmd_trysetgrudge, //0xDC + Cmd_weightdamagecalculation, //0xDD + Cmd_assistattackselect, //0xDE + Cmd_trysetmagiccoat, //0xDF + Cmd_trysetsnatch, //0xE0 + Cmd_trygetintimidatetarget, //0xE1 + Cmd_switchoutabilities, //0xE2 + Cmd_jumpifhasnohp, //0xE3 + Cmd_getsecretpowereffect, //0xE4 + Cmd_pickup, //0xE5 + Cmd_docastformchangeanimation, //0xE6 + Cmd_trycastformdatachange, //0xE7 + Cmd_settypebasedhalvers, //0xE8 + Cmd_setweatherballtype, //0xE9 + Cmd_tryrecycleitem, //0xEA + Cmd_settypetoterrain, //0xEB + Cmd_pursuitrelated, //0xEC + Cmd_snatchsetbattlers, //0xED + Cmd_removelightscreenreflect, //0xEE + Cmd_handleballthrow, //0xEF + Cmd_givecaughtmon, //0xF0 + Cmd_trysetcaughtmondexflags, //0xF1 + Cmd_displaydexinfo, //0xF2 + Cmd_trygivecaughtmonnick, //0xF3 + Cmd_subattackerhpbydmg, //0xF4 + Cmd_removeattackerstatus1, //0xF5 + Cmd_finishaction, //0xF6 + Cmd_finishturn, //0xF7 + Cmd_trainerslideout //0xF8 }; struct StatFractions @@ -917,7 +918,7 @@ static const u8 sUnknown_0831C4F8[] = 0x03, 0x00, 0x00, 0x00 }; -static void atk00_attackcanceler(void) +static void Cmd_attackcanceler(void) { s32 i; @@ -1029,7 +1030,7 @@ static void JumpIfMoveFailed(u8 adder, u16 move) gBattlescriptCurrInstr = BS_ptr; } -static void atk40_jumpifaffectedbyprotect(void) +static void Cmd_jumpifaffectedbyprotect(void) { if (DEFENDER_IS_PROTECTED) { @@ -1101,7 +1102,7 @@ static bool8 AccuracyCalcHelper(u16 move) return FALSE; } -static void atk01_accuracycheck(void) +static void Cmd_accuracycheck(void) { u16 move = T2_READ_16(gBattlescriptCurrInstr + 5); @@ -1193,7 +1194,7 @@ static void atk01_accuracycheck(void) } } -static void atk02_attackstring(void) +static void Cmd_attackstring(void) { if (gBattleControllerExecFlags) return; @@ -1206,7 +1207,7 @@ static void atk02_attackstring(void) gBattleCommunication[MSG_DISPLAY] = 0; } -static void atk03_ppreduce(void) +static void Cmd_ppreduce(void) { s32 ppToDeduct = 1; @@ -1253,7 +1254,7 @@ static void atk03_ppreduce(void) gBattlescriptCurrInstr++; } -static void atk04_critcalc(void) +static void Cmd_critcalc(void) { u8 holdEffect; u16 item, critChance; @@ -1290,7 +1291,7 @@ static void atk04_critcalc(void) gBattlescriptCurrInstr++; } -static void atk05_damagecalc(void) +static void Cmd_damagecalc(void) { u16 sideStatus = gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)]; gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerTarget], gCurrentMove, @@ -1355,7 +1356,7 @@ static void ModulateDmgByType(u8 multiplier) } } -static void atk06_typecalc(void) +static void Cmd_typecalc(void) { s32 i = 0; u8 moveType; @@ -1657,7 +1658,7 @@ static void Unused_ApplyRandomDmgMultiplier(void) ApplyRandomDmgMultiplier(); } -static void atk07_adjustnormaldamage(void) +static void Cmd_adjustnormaldamage(void) { u8 holdEffect, param; @@ -1699,7 +1700,7 @@ static void atk07_adjustnormaldamage(void) gBattlescriptCurrInstr++; } -static void atk08_adjustnormaldamage2(void) // The same as 0x7 except it doesn't check for false swipe move effect. +static void Cmd_adjustnormaldamage2(void) // The same as adjustnormaldamage except it doesn't check for false swipe move effect. { u8 holdEffect, param; @@ -1741,7 +1742,7 @@ static void atk08_adjustnormaldamage2(void) // The same as 0x7 except it doesn't gBattlescriptCurrInstr++; } -static void atk09_attackanimation(void) +static void Cmd_attackanimation(void) { if (gBattleControllerExecFlags) return; @@ -1795,13 +1796,13 @@ static void atk09_attackanimation(void) } } -static void atk0A_waitanimation(void) +static void Cmd_waitanimation(void) { if (gBattleControllerExecFlags == 0) gBattlescriptCurrInstr++; } -static void atk0B_healthbarupdate(void) +static void Cmd_healthbarupdate(void) { if (gBattleControllerExecFlags) return; @@ -1837,7 +1838,7 @@ static void atk0B_healthbarupdate(void) gBattlescriptCurrInstr += 2; } -static void atk0C_datahpupdate(void) +static void Cmd_datahpupdate(void) { u32 moveType; @@ -1963,7 +1964,7 @@ static void atk0C_datahpupdate(void) gBattlescriptCurrInstr += 2; } -static void atk0D_critmessage(void) +static void Cmd_critmessage(void) { if (gBattleControllerExecFlags == 0) { @@ -1976,7 +1977,7 @@ static void atk0D_critmessage(void) } } -static void atk0E_effectivenesssound(void) +static void Cmd_effectivenesssound(void) { if (gBattleControllerExecFlags) return; @@ -2023,7 +2024,7 @@ static void atk0E_effectivenesssound(void) gBattlescriptCurrInstr++; } -static void atk0F_resultmessage(void) +static void Cmd_resultmessage(void) { u32 stringId = 0; @@ -2112,7 +2113,7 @@ static void atk0F_resultmessage(void) gBattlescriptCurrInstr++; } -static void atk10_printstring(void) +static void Cmd_printstring(void) { if (gBattleControllerExecFlags == 0) { @@ -2123,7 +2124,7 @@ static void atk10_printstring(void) } } -static void atk11_printselectionstring(void) +static void Cmd_printselectionstring(void) { gActiveBattler = gBattlerAttacker; @@ -2134,7 +2135,7 @@ static void atk11_printselectionstring(void) gBattleCommunication[MSG_DISPLAY] = 1; } -static void atk12_waitmessage(void) +static void Cmd_waitmessage(void) { if (gBattleControllerExecFlags == 0) { @@ -2155,7 +2156,7 @@ static void atk12_waitmessage(void) } } -static void atk13_printfromtable(void) +static void Cmd_printfromtable(void) { if (gBattleControllerExecFlags == 0) { @@ -2169,7 +2170,7 @@ static void atk13_printfromtable(void) } } -static void atk14_printselectionstringfromtable(void) +static void Cmd_printselectionstringfromtable(void) { if (gBattleControllerExecFlags == 0) { @@ -2881,7 +2882,7 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattleCommunication[MOVE_EFFECT_BYTE] = 0; } -static void atk15_seteffectwithchance(void) +static void Cmd_seteffectwithchance(void) { u32 percentChance; @@ -2914,17 +2915,17 @@ static void atk15_seteffectwithchance(void) gBattleScripting.multihitMoveEffect = 0; } -static void atk16_seteffectprimary(void) +static void Cmd_seteffectprimary(void) { SetMoveEffect(TRUE, 0); } -static void atk17_seteffectsecondary(void) +static void Cmd_seteffectsecondary(void) { SetMoveEffect(FALSE, 0); } -static void atk18_clearstatusfromeffect(void) +static void Cmd_clearstatusfromeffect(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); @@ -2938,7 +2939,7 @@ static void atk18_clearstatusfromeffect(void) gBattleScripting.multihitMoveEffect = 0; } -static void atk19_tryfaintmon(void) +static void Cmd_tryfaintmon(void) { const u8 *BS_ptr; @@ -3025,7 +3026,7 @@ static void atk19_tryfaintmon(void) } } -static void atk1A_dofaintanimation(void) +static void Cmd_dofaintanimation(void) { if (gBattleControllerExecFlags == 0) { @@ -3036,7 +3037,7 @@ static void atk1A_dofaintanimation(void) } } -static void atk1B_cleareffectsonfaint(void) +static void Cmd_cleareffectsonfaint(void) { if (gBattleControllerExecFlags == 0) { @@ -3054,7 +3055,7 @@ static void atk1B_cleareffectsonfaint(void) } } -static void atk1C_jumpifstatus(void) +static void Cmd_jumpifstatus(void) { u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); u32 flags = T2_READ_32(gBattlescriptCurrInstr + 2); @@ -3066,7 +3067,7 @@ static void atk1C_jumpifstatus(void) gBattlescriptCurrInstr += 10; } -static void atk1D_jumpifstatus2(void) +static void Cmd_jumpifstatus2(void) { u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); u32 flags = T2_READ_32(gBattlescriptCurrInstr + 2); @@ -3078,7 +3079,7 @@ static void atk1D_jumpifstatus2(void) gBattlescriptCurrInstr += 10; } -static void atk1E_jumpifability(void) +static void Cmd_jumpifability(void) { u8 battlerId; u8 ability = gBattlescriptCurrInstr[2]; @@ -3125,7 +3126,7 @@ static void atk1E_jumpifability(void) } } -static void atk1F_jumpifsideaffecting(void) +static void Cmd_jumpifsideaffecting(void) { u8 side; u16 flags; @@ -3145,7 +3146,7 @@ static void atk1F_jumpifsideaffecting(void) gBattlescriptCurrInstr += 8; } -static void atk20_jumpifstat(void) +static void Cmd_jumpifstat(void) { u8 ret = 0; u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); @@ -3185,7 +3186,7 @@ static void atk20_jumpifstat(void) gBattlescriptCurrInstr += 9; } -static void atk21_jumpifstatus3condition(void) +static void Cmd_jumpifstatus3condition(void) { u32 flags; const u8 *jumpPtr; @@ -3210,7 +3211,7 @@ static void atk21_jumpifstatus3condition(void) } } -static void atk22_jumpiftype(void) +static void Cmd_jumpiftype(void) { u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); u8 type = gBattlescriptCurrInstr[2]; @@ -3222,7 +3223,7 @@ static void atk22_jumpiftype(void) gBattlescriptCurrInstr += 7; } -static void atk23_getexp(void) +static void Cmd_getexp(void) { u16 item; s32 i; // also used as stringId @@ -3234,7 +3235,7 @@ static void atk23_getexp(void) gBattlerFainted = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); sentIn = gSentPokesToOpponent[(gBattlerFainted & 2) >> 1]; - switch (gBattleScripting.atk23_state) + switch (gBattleScripting.getexpState) { case 0: // check if should receive exp at all if (GetBattlerSide(gBattlerFainted) != B_SIDE_OPPONENT || (gBattleTypeFlags & @@ -3246,11 +3247,11 @@ static void atk23_getexp(void) | BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_EREADER_TRAINER))) { - gBattleScripting.atk23_state = 6; // goto last case + gBattleScripting.getexpState = 6; // goto last case } else { - gBattleScripting.atk23_state++; + gBattleScripting.getexpState++; gBattleStruct->givenExpMons |= gBitTable[gBattlerPartyIndexes[gBattlerFainted]]; } break; @@ -3297,7 +3298,7 @@ static void atk23_getexp(void) gExpShareExp = 0; } - gBattleScripting.atk23_state++; + gBattleScripting.getexpState++; gBattleStruct->expGetterMonId = 0; gBattleStruct->sentInPokes = sentIn; } @@ -3315,13 +3316,13 @@ static void atk23_getexp(void) if (holdEffect != HOLD_EFFECT_EXP_SHARE && !(gBattleStruct->sentInPokes & 1)) { *(&gBattleStruct->sentInPokes) >>= 1; - gBattleScripting.atk23_state = 5; + gBattleScripting.getexpState = 5; gBattleMoveDamage = 0; // used for exp } else if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) == MAX_LEVEL) { *(&gBattleStruct->sentInPokes) >>= 1; - gBattleScripting.atk23_state = 5; + gBattleScripting.getexpState = 5; gBattleMoveDamage = 0; // used for exp } else @@ -3393,7 +3394,7 @@ static void atk23_getexp(void) MonGainEVs(&gPlayerParty[gBattleStruct->expGetterMonId], gBattleMons[gBattlerFainted].species); } gBattleStruct->sentInPokes >>= 1; - gBattleScripting.atk23_state++; + gBattleScripting.getexpState++; } } break; @@ -3414,7 +3415,7 @@ static void atk23_getexp(void) BtlController_EmitExpUpdate(0, gBattleStruct->expGetterMonId, gBattleMoveDamage); MarkBattlerForControllerExec(gActiveBattler); } - gBattleScripting.atk23_state++; + gBattleScripting.getexpState++; } break; case 4: // lvl up if necessary @@ -3464,27 +3465,27 @@ static void atk23_getexp(void) gBattleMons[2].spAttack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPATK); } - gBattleScripting.atk23_state = 5; + gBattleScripting.getexpState = 5; } else { gBattleMoveDamage = 0; - gBattleScripting.atk23_state = 5; + gBattleScripting.getexpState = 5; } } break; case 5: // looper increment if (gBattleMoveDamage) // there is exp to give, goto case 3 that gives exp { - gBattleScripting.atk23_state = 3; + gBattleScripting.getexpState = 3; } else { gBattleStruct->expGetterMonId++; if (gBattleStruct->expGetterMonId <= 5) - gBattleScripting.atk23_state = 2; // loop again + gBattleScripting.getexpState = 2; // loop again else - gBattleScripting.atk23_state = 6; // we're done + gBattleScripting.getexpState = 6; // we're done } break; case 6: // increment instruction @@ -3500,7 +3501,7 @@ static void atk23_getexp(void) } #ifdef NONMATCHING -static void atk24(void) +static void Cmd_unknown_24(void) { u16 HP_count = 0; s32 i; @@ -3583,7 +3584,7 @@ static void atk24(void) } #else NAKED -static void atk24(void) +static void Cmd_unknown_24(void) { asm("\n\ .syntax unified\n\ @@ -3888,19 +3889,19 @@ static void MoveValuesCleanUp(void) gHitMarker &= ~(HITMARKER_SYNCHRONISE_EFFECT); } -static void atk25_movevaluescleanup(void) +static void Cmd_movevaluescleanup(void) { MoveValuesCleanUp(); gBattlescriptCurrInstr += 1; } -static void atk26_setmultihit(void) +static void Cmd_setmultihit(void) { gMultiHitCounter = gBattlescriptCurrInstr[1]; gBattlescriptCurrInstr += 2; } -static void atk27_decrementmultihit(void) +static void Cmd_decrementmultihit(void) { if (--gMultiHitCounter == 0) gBattlescriptCurrInstr += 5; @@ -3908,12 +3909,12 @@ static void atk27_decrementmultihit(void) gBattlescriptCurrInstr = T2_READ_PTR(gBattlescriptCurrInstr + 1); } -static void atk28_goto(void) +static void Cmd_goto(void) { gBattlescriptCurrInstr = T2_READ_PTR(gBattlescriptCurrInstr + 1); } -static void atk29_jumpifbyte(void) +static void Cmd_jumpifbyte(void) { u8 caseID = gBattlescriptCurrInstr[1]; const u8* memByte = T2_READ_PTR(gBattlescriptCurrInstr + 2); @@ -3951,7 +3952,7 @@ static void atk29_jumpifbyte(void) } } -static void atk2A_jumpifhalfword(void) +static void Cmd_jumpifhalfword(void) { u8 caseID = gBattlescriptCurrInstr[1]; const u16* memHword = T2_READ_PTR(gBattlescriptCurrInstr + 2); @@ -3989,7 +3990,7 @@ static void atk2A_jumpifhalfword(void) } } -static void atk2B_jumpifword(void) +static void Cmd_jumpifword(void) { u8 caseID = gBattlescriptCurrInstr[1]; const u32* memWord = T2_READ_PTR(gBattlescriptCurrInstr + 2); @@ -4027,7 +4028,7 @@ static void atk2B_jumpifword(void) } } -static void atk2C_jumpifarrayequal(void) +static void Cmd_jumpifarrayequal(void) { const u8* mem1 = T2_READ_PTR(gBattlescriptCurrInstr + 1); const u8* mem2 = T2_READ_PTR(gBattlescriptCurrInstr + 5); @@ -4049,7 +4050,7 @@ static void atk2C_jumpifarrayequal(void) gBattlescriptCurrInstr = jumpPtr; } -static void atk2D_jumpifarraynotequal(void) +static void Cmd_jumpifarraynotequal(void) { u8 equalBytes = 0; const u8* mem1 = T2_READ_PTR(gBattlescriptCurrInstr + 1); @@ -4073,7 +4074,7 @@ static void atk2D_jumpifarraynotequal(void) gBattlescriptCurrInstr += 14; } -static void atk2E_setbyte(void) +static void Cmd_setbyte(void) { u8* memByte = T2_READ_PTR(gBattlescriptCurrInstr + 1); *memByte = gBattlescriptCurrInstr[5]; @@ -4081,21 +4082,21 @@ static void atk2E_setbyte(void) gBattlescriptCurrInstr += 6; } -static void atk2F_addbyte(void) +static void Cmd_addbyte(void) { u8* memByte = T2_READ_PTR(gBattlescriptCurrInstr + 1); *memByte += gBattlescriptCurrInstr[5]; gBattlescriptCurrInstr += 6; } -static void atk30_subbyte(void) +static void Cmd_subbyte(void) { u8* memByte = T2_READ_PTR(gBattlescriptCurrInstr + 1); *memByte -= gBattlescriptCurrInstr[5]; gBattlescriptCurrInstr += 6; } -static void atk31_copyarray(void) +static void Cmd_copyarray(void) { u8* dest = T2_READ_PTR(gBattlescriptCurrInstr + 1); const u8* src = T2_READ_PTR(gBattlescriptCurrInstr + 5); @@ -4110,7 +4111,7 @@ static void atk31_copyarray(void) gBattlescriptCurrInstr += 10; } -static void atk32_copyarraywithindex(void) +static void Cmd_copyarraywithindex(void) { u8* dest = T2_READ_PTR(gBattlescriptCurrInstr + 1); const u8* src = T2_READ_PTR(gBattlescriptCurrInstr + 5); @@ -4126,14 +4127,14 @@ static void atk32_copyarraywithindex(void) gBattlescriptCurrInstr += 14; } -static void atk33_orbyte(void) +static void Cmd_orbyte(void) { u8* memByte = T2_READ_PTR(gBattlescriptCurrInstr + 1); *memByte |= gBattlescriptCurrInstr[5]; gBattlescriptCurrInstr += 6; } -static void atk34_orhalfword(void) +static void Cmd_orhalfword(void) { u16* memHword = T2_READ_PTR(gBattlescriptCurrInstr + 1); u16 val = T2_READ_16(gBattlescriptCurrInstr + 5); @@ -4142,7 +4143,7 @@ static void atk34_orhalfword(void) gBattlescriptCurrInstr += 7; } -static void atk35_orword(void) +static void Cmd_orword(void) { u32* memWord = T2_READ_PTR(gBattlescriptCurrInstr + 1); u32 val = T2_READ_32(gBattlescriptCurrInstr + 5); @@ -4151,14 +4152,14 @@ static void atk35_orword(void) gBattlescriptCurrInstr += 9; } -static void atk36_bicbyte(void) +static void Cmd_bicbyte(void) { u8* memByte = T2_READ_PTR(gBattlescriptCurrInstr + 1); *memByte &= ~(gBattlescriptCurrInstr[5]); gBattlescriptCurrInstr += 6; } -static void atk37_bichalfword(void) +static void Cmd_bichalfword(void) { u16* memHword = T2_READ_PTR(gBattlescriptCurrInstr + 1); u16 val = T2_READ_16(gBattlescriptCurrInstr + 5); @@ -4167,7 +4168,7 @@ static void atk37_bichalfword(void) gBattlescriptCurrInstr += 7; } -static void atk38_bicword(void) +static void Cmd_bicword(void) { u32* memWord = T2_READ_PTR(gBattlescriptCurrInstr + 1); u32 val = T2_READ_32(gBattlescriptCurrInstr + 5); @@ -4176,7 +4177,7 @@ static void atk38_bicword(void) gBattlescriptCurrInstr += 9; } -static void atk39_pause(void) +static void Cmd_pause(void) { if (gBattleControllerExecFlags == 0) { @@ -4189,13 +4190,13 @@ static void atk39_pause(void) } } -static void atk3A_waitstate(void) +static void Cmd_waitstate(void) { if (gBattleControllerExecFlags == 0) gBattlescriptCurrInstr++; } -static void atk3B_healthbar_update(void) +static void Cmd_healthbar_update(void) { if (gBattlescriptCurrInstr[1] == BS_TARGET) gActiveBattler = gBattlerTarget; @@ -4207,12 +4208,12 @@ static void atk3B_healthbar_update(void) gBattlescriptCurrInstr += 2; } -static void atk3C_return(void) +static void Cmd_return(void) { BattleScriptPop(); } -static void atk3D_end(void) +static void Cmd_end(void) { if (gBattleTypeFlags & BATTLE_TYPE_ARENA) BattleArena_AddSkillPoints(gBattlerAttacker); @@ -4222,13 +4223,13 @@ static void atk3D_end(void) gCurrentActionFuncId = B_ACTION_TRY_FINISH; } -static void atk3E_end2(void) +static void Cmd_end2(void) { gActiveBattler = 0; gCurrentActionFuncId = B_ACTION_TRY_FINISH; } -static void atk3F_end3(void) // pops the main function stack +static void Cmd_end3(void) // pops the main function stack { BattleScriptPop(); if (gBattleResources->battleCallbackStack->size != 0) @@ -4236,13 +4237,13 @@ static void atk3F_end3(void) // pops the main function stack gBattleMainFunc = gBattleResources->battleCallbackStack->function[gBattleResources->battleCallbackStack->size]; } -static void atk41_call(void) +static void Cmd_call(void) { BattleScriptPush(gBattlescriptCurrInstr + 5); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } -static void atk42_jumpiftype2(void) +static void Cmd_jumpiftype2(void) { u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); @@ -4252,7 +4253,7 @@ static void atk42_jumpiftype2(void) gBattlescriptCurrInstr += 7; } -static void atk43_jumpifabilitypresent(void) +static void Cmd_jumpifabilitypresent(void) { if (AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, gBattlescriptCurrInstr[1], 0, 0)) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2); @@ -4260,12 +4261,12 @@ static void atk43_jumpifabilitypresent(void) gBattlescriptCurrInstr += 6; } -static void atk44_endselectionscript(void) +static void Cmd_endselectionscript(void) { *(gBattlerAttacker + gBattleStruct->selectionScriptFinished) = TRUE; } -static void atk45_playanimation(void) +static void Cmd_playanimation(void) { const u16* argumentPtr; @@ -4306,7 +4307,7 @@ static void atk45_playanimation(void) } } -static void atk46_playanimation2(void) // animation Id is stored in the first pointer +static void Cmd_playanimation2(void) // animation Id is stored in the first pointer { const u16* argumentPtr; const u8* animationIdPtr; @@ -4348,7 +4349,7 @@ static void atk46_playanimation2(void) // animation Id is stored in the first po } } -static void atk47_setgraphicalstatchangevalues(void) +static void Cmd_setgraphicalstatchangevalues(void) { u8 value = 0; switch (GET_STAT_BUFF_VALUE2(gBattleScripting.statChanger)) @@ -4371,7 +4372,7 @@ static void atk47_setgraphicalstatchangevalues(void) gBattlescriptCurrInstr++; } -static void atk48_playstatchangeanimation(void) +static void Cmd_playstatchangeanimation(void) { u32 currStat = 0; u16 statAnimId = 0; @@ -4381,10 +4382,10 @@ static void atk48_playstatchangeanimation(void) gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); statsToCheck = gBattlescriptCurrInstr[2]; - if (gBattlescriptCurrInstr[3] & ATK48_STAT_NEGATIVE) // goes down + if (gBattlescriptCurrInstr[3] & STAT_CHANGE_NEGATIVE) // goes down { s16 startingStatAnimId; - if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) + if (gBattlescriptCurrInstr[3] & STAT_CHANGE_BY_TWO) startingStatAnimId = STAT_ANIM_MINUS2 - 1; else startingStatAnimId = STAT_ANIM_MINUS1 - 1; @@ -4393,7 +4394,7 @@ static void atk48_playstatchangeanimation(void) { if (statsToCheck & 1) { - if (gBattlescriptCurrInstr[3] & ATK48_DONT_CHECK_LOWER) + if (gBattlescriptCurrInstr[3] & STAT_CHANGE_CANT_PREVENT) { if (gBattleMons[gActiveBattler].statStages[currStat] > 0) { @@ -4419,7 +4420,7 @@ static void atk48_playstatchangeanimation(void) if (changeableStatsCount > 1) // more than one stat, so the color is gray { - if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) + if (gBattlescriptCurrInstr[3] & STAT_CHANGE_BY_TWO) statAnimId = STAT_ANIM_MULTIPLE_MINUS2; else statAnimId = STAT_ANIM_MULTIPLE_MINUS1; @@ -4428,7 +4429,7 @@ static void atk48_playstatchangeanimation(void) else // goes up { s16 startingStatAnimId; - if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) + if (gBattlescriptCurrInstr[3] & STAT_CHANGE_BY_TWO) startingStatAnimId = STAT_ANIM_PLUS2 - 1; else startingStatAnimId = STAT_ANIM_PLUS1 - 1; @@ -4445,14 +4446,14 @@ static void atk48_playstatchangeanimation(void) if (changeableStatsCount > 1) // more than one stat, so the color is gray { - if (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) + if (gBattlescriptCurrInstr[3] & STAT_CHANGE_BY_TWO) statAnimId = STAT_ANIM_MULTIPLE_PLUS2; else statAnimId = STAT_ANIM_MULTIPLE_PLUS1; } } - if (gBattlescriptCurrInstr[3] & ATK48_ONLY_MULTIPLE && changeableStatsCount < 2) + if (gBattlescriptCurrInstr[3] & STAT_CHANGE_MULTIPLE_STATS && changeableStatsCount < 2) { gBattlescriptCurrInstr += 4; } @@ -4460,7 +4461,7 @@ static void atk48_playstatchangeanimation(void) { BtlController_EmitBattleAnimation(0, B_ANIM_STATS_CHANGE, statAnimId); MarkBattlerForControllerExec(gActiveBattler); - if (gBattlescriptCurrInstr[3] & ATK48_ONLY_MULTIPLE && changeableStatsCount > 1) + if (gBattlescriptCurrInstr[3] & STAT_CHANGE_MULTIPLE_STATS && changeableStatsCount > 1) gBattleScripting.statAnimPlayed = TRUE; gBattlescriptCurrInstr += 4; } @@ -4470,7 +4471,7 @@ static void atk48_playstatchangeanimation(void) } } -static void atk49_moveend(void) +static void Cmd_moveend(void) { s32 i; bool32 effect = FALSE; @@ -4498,9 +4499,9 @@ static void atk49_moveend(void) do { - switch (gBattleScripting.atk49_state) + switch (gBattleScripting.moveendState) { - case ATK49_RAGE: // rage check + case MOVEEND_RAGE: // rage check if (gBattleMons[gBattlerTarget].status2 & STATUS2_RAGE && gBattleMons[gBattlerTarget].hp != 0 && gBattlerAttacker != gBattlerTarget && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget) @@ -4512,9 +4513,9 @@ static void atk49_moveend(void) gBattlescriptCurrInstr = BattleScript_RageIsBuilding; effect = TRUE; } - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_DEFROST: // defrosting check + case MOVEEND_DEFROST: // defrosting check if (gBattleMons[gBattlerTarget].status1 & STATUS1_FREEZE && gBattleMons[gBattlerTarget].hp != 0 && gBattlerAttacker != gBattlerTarget && gSpecialStatuses[gBattlerTarget].specialDmg @@ -4528,38 +4529,38 @@ static void atk49_moveend(void) gBattlescriptCurrInstr = BattleScript_DefrostedViaFireMove; effect = TRUE; } - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_SYNCHRONIZE_TARGET: // target synchronize + case MOVEEND_SYNCHRONIZE_TARGET: // target synchronize if (AbilityBattleEffects(ABILITYEFFECT_SYNCHRONIZE, gBattlerTarget, 0, 0, 0)) effect = TRUE; - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_MOVE_END_ABILITIES: // Such as abilities activating on contact(Poison Spore, Rough Skin, etc.). - if (AbilityBattleEffects(ABILITYEFFECT_MOVE_END, gBattlerTarget, 0, 0, 0)) + case MOVEEND_ON_DAMAGE_ABILITIES: // Contact abilities and Color Change + if (AbilityBattleEffects(ABILITYEFFECT_ON_DAMAGE, gBattlerTarget, 0, 0, 0)) effect = TRUE; - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_STATUS_IMMUNITY_ABILITIES: // status immunities + case MOVEEND_IMMUNITY_ABILITIES: // status immunities if (AbilityBattleEffects(ABILITYEFFECT_IMMUNITY, 0, 0, 0, 0)) effect = TRUE; // it loops through all battlers, so we increment after its done with all battlers else - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_SYNCHRONIZE_ATTACKER: // attacker synchronize + case MOVEEND_SYNCHRONIZE_ATTACKER: // attacker synchronize if (AbilityBattleEffects(ABILITYEFFECT_ATK_SYNCHRONIZE, gBattlerAttacker, 0, 0, 0)) effect = TRUE; - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_CHOICE_MOVE: // update choice band move + case MOVEEND_CHOICE_MOVE: // update choice band move if (gHitMarker & HITMARKER_OBEYS && holdEffectAtk == HOLD_EFFECT_CHOICE_BAND - && gChosenMove != MOVE_STRUGGLE + && gChosenMove != MOVE_STRUGGLE && (*choicedMoveAtk == 0 || *choicedMoveAtk == 0xFFFF)) { if (gChosenMove == MOVE_BATON_PASS && !(gMoveResultFlags & MOVE_RESULT_FAILED)) { - ++gBattleScripting.atk49_state; + ++gBattleScripting.moveendState; break; } *choicedMoveAtk = gChosenMove; @@ -4571,9 +4572,9 @@ static void atk49_moveend(void) } if (i == MAX_MON_MOVES) *choicedMoveAtk = 0; - ++gBattleScripting.atk49_state; + ++gBattleScripting.moveendState; break; - case ATK49_CHANGED_ITEMS: // changed held items + case MOVEEND_CHANGED_ITEMS: // changed held items for (i = 0; i < gBattlersCount; i++) { u16* changedItem = &gBattleStruct->changedItems[i]; @@ -4583,32 +4584,32 @@ static void atk49_moveend(void) *changedItem = 0; } } - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_ITEM_EFFECTS_ALL: // item effects for all battlers + case MOVEEND_ITEM_EFFECTS_ALL: // item effects for all battlers if (ItemBattleEffects(ITEMEFFECT_MOVE_END, 0, FALSE)) effect = TRUE; else - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_KINGSROCK_SHELLBELL: // king's rock and shell bell + case MOVEEND_KINGSROCK_SHELLBELL: // king's rock and shell bell if (ItemBattleEffects(ITEMEFFECT_KINGSROCK_SHELLBELL, 0, FALSE)) effect = TRUE; - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_ATTACKER_INVISIBLE: // make attacker sprite invisible + case MOVEEND_ATTACKER_INVISIBLE: // make attacker sprite invisible if (gStatuses3[gBattlerAttacker] & (STATUS3_SEMI_INVULNERABLE) && gHitMarker & HITMARKER_NO_ANIMATIONS) { gActiveBattler = gBattlerAttacker; BtlController_EmitSpriteInvisibility(0, TRUE); MarkBattlerForControllerExec(gActiveBattler); - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; return; } - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_ATTACKER_VISIBLE: // make attacker sprite visible + case MOVEEND_ATTACKER_VISIBLE: // make attacker sprite visible if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT || !(gStatuses3[gBattlerAttacker] & (STATUS3_SEMI_INVULNERABLE)) || WasUnableToUseMove(gBattlerAttacker)) @@ -4618,12 +4619,12 @@ static void atk49_moveend(void) MarkBattlerForControllerExec(gActiveBattler); gStatuses3[gBattlerAttacker] &= ~(STATUS3_SEMI_INVULNERABLE); gSpecialStatuses[gBattlerAttacker].restoredBattlerSprite = 1; - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; return; } - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_TARGET_VISIBLE: // make target sprite visible + case MOVEEND_TARGET_VISIBLE: // make target sprite visible if (!gSpecialStatuses[gBattlerTarget].restoredBattlerSprite && gBattlerTarget < gBattlersCount && !(gStatuses3[gBattlerTarget] & STATUS3_SEMI_INVULNERABLE)) { @@ -4631,20 +4632,20 @@ static void atk49_moveend(void) BtlController_EmitSpriteInvisibility(0, FALSE); MarkBattlerForControllerExec(gActiveBattler); gStatuses3[gBattlerTarget] &= ~(STATUS3_SEMI_INVULNERABLE); - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; return; } - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_SUBSTITUTE: // update substitute + case MOVEEND_SUBSTITUTE: // update substitute for (i = 0; i < gBattlersCount; i++) { if (gDisableStructs[i].substituteHP == 0) gBattleMons[i].status2 &= ~(STATUS2_SUBSTITUTE); } - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_UPDATE_LAST_MOVES: + case MOVEEND_UPDATE_LAST_MOVES: if (gHitMarker & HITMARKER_SWAP_ATTACKER_TARGET) { gActiveBattler = gBattlerAttacker; @@ -4691,9 +4692,9 @@ static void atk49_moveend(void) gLastLandedMoves[gBattlerTarget] = 0xFFFF; } } - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_MIRROR_MOVE: // mirror move + case MOVEEND_MIRROR_MOVE: // mirror move if (!(gAbsentBattlerFlags & gBitTable[gBattlerAttacker]) && !(gBattleStruct->field_91 & gBitTable[gBattlerAttacker]) && gBattleMoves[originallyUsedMove].flags & FLAG_MIRROR_MOVE_AFFECTED && gHitMarker & HITMARKER_OBEYS && gBattlerAttacker != gBattlerTarget && !(gHitMarker & HITMARKER_FAINTED(gBattlerTarget)) @@ -4712,9 +4713,9 @@ static void atk49_moveend(void) attacker = gBattlerAttacker; *(attacker * 2 + target * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) = gChosenMove >> 8; } - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_NEXT_TARGET: // For moves hitting two opposing Pokemon. + case MOVEEND_NEXT_TARGET: // For moves hitting two opposing Pokemon. if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) && gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !gProtectStructs[gBattlerAttacker].chargingTurn && gBattleMoves[gCurrentMove].target == MOVE_TARGET_BOTH && !(gHitMarker & HITMARKER_NO_ATTACKSTRING)) @@ -4724,7 +4725,7 @@ static void atk49_moveend(void) { gBattlerTarget = battlerId; gHitMarker |= HITMARKER_NO_ATTACKSTRING; - gBattleScripting.atk49_state = 0; + gBattleScripting.moveendState = 0; MoveValuesCleanUp(); BattleScriptPush(gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]); gBattlescriptCurrInstr = BattleScript_FlushMessageBox; @@ -4735,24 +4736,24 @@ static void atk49_moveend(void) gHitMarker |= HITMARKER_NO_ATTACKSTRING; } } - gBattleScripting.atk49_state++; + gBattleScripting.moveendState++; break; - case ATK49_COUNT: + case MOVEEND_COUNT: break; } if (arg1 == 1 && effect == FALSE) - gBattleScripting.atk49_state = ATK49_COUNT; - if (arg1 == 2 && arg2 == gBattleScripting.atk49_state) - gBattleScripting.atk49_state = ATK49_COUNT; + gBattleScripting.moveendState = MOVEEND_COUNT; + if (arg1 == 2 && arg2 == gBattleScripting.moveendState) + gBattleScripting.moveendState = MOVEEND_COUNT; - } while (gBattleScripting.atk49_state != ATK49_COUNT && effect == FALSE); + } while (gBattleScripting.moveendState != MOVEEND_COUNT && effect == FALSE); - if (gBattleScripting.atk49_state == ATK49_COUNT && effect == FALSE) + if (gBattleScripting.moveendState == MOVEEND_COUNT && effect == FALSE) gBattlescriptCurrInstr += 3; } -static void atk4A_typecalc2(void) +static void Cmd_typecalc2(void) { u8 flags = 0; s32 i = 0; @@ -4847,7 +4848,7 @@ static void atk4A_typecalc2(void) gBattlescriptCurrInstr++; } -static void atk4B_returnatktoball(void) +static void Cmd_returnatktoball(void) { gActiveBattler = gBattlerAttacker; if (!(gHitMarker & HITMARKER_FAINTED(gActiveBattler))) @@ -4858,7 +4859,7 @@ static void atk4B_returnatktoball(void) gBattlescriptCurrInstr++; } -static void atk4C_getswitchedmondata(void) +static void Cmd_getswitchedmondata(void) { if (gBattleControllerExecFlags) return; @@ -4873,7 +4874,7 @@ static void atk4C_getswitchedmondata(void) gBattlescriptCurrInstr += 2; } -static void atk4D_switchindataupdate(void) +static void Cmd_switchindataupdate(void) { struct BattlePokemon oldData; s32 i; @@ -4926,7 +4927,7 @@ static void atk4D_switchindataupdate(void) gBattlescriptCurrInstr += 2; } -static void atk4E_switchinanim(void) +static void Cmd_switchinanim(void) { if (gBattleControllerExecFlags) return; @@ -4952,15 +4953,15 @@ static void atk4E_switchinanim(void) BattleArena_InitPoints(); } -static void atk4F_jumpifcantswitch(void) +static void Cmd_jumpifcantswitch(void) { s32 i; s32 lastMonId; struct Pokemon *party; - gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(ATK4F_DONT_CHECK_STATUSES)); + gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(SWITCH_IGNORE_ESCAPE_PREVENTION)); - if (!(gBattlescriptCurrInstr[1] & ATK4F_DONT_CHECK_STATUSES) + if (!(gBattlescriptCurrInstr[1] & SWITCH_IGNORE_ESCAPE_PREVENTION) && ((gBattleMons[gActiveBattler].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)) || (gStatuses3[gActiveBattler] & STATUS3_ROOTED))) { @@ -5107,17 +5108,17 @@ static void atk4F_jumpifcantswitch(void) } } -static void sub_804CF10(u8 arg0) +static void sub_804CF10(u8 slotId) { *(gBattleStruct->field_58 + gActiveBattler) = gBattlerPartyIndexes[gActiveBattler]; - *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6; + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = PARTY_SIZE; gBattleStruct->field_93 &= ~(gBitTable[gActiveBattler]); - BtlController_EmitChoosePokemon(0, PARTY_MUST_CHOOSE_MON, arg0, 0, gBattleStruct->field_60[gActiveBattler]); + BtlController_EmitChoosePokemon(0, PARTY_ACTION_SEND_OUT, slotId, ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); MarkBattlerForControllerExec(gActiveBattler); } -static void atk50_openpartyscreen(void) +static void Cmd_openpartyscreen(void) { u32 flags; u8 hitmarkerFaintBits; @@ -5145,7 +5146,7 @@ static void atk50_openpartyscreen(void) } else if (!gSpecialStatuses[gActiveBattler].flag40) { - sub_804CF10(6); + sub_804CF10(PARTY_SIZE); gSpecialStatuses[gActiveBattler].flag40 = 1; } } @@ -5352,9 +5353,9 @@ static void atk50_openpartyscreen(void) else { if (gBattlescriptCurrInstr[1] & 0x80) - hitmarkerFaintBits = PARTY_CHOOSE_MON; // Used here as the caseId for the EmitChoose function. + hitmarkerFaintBits = PARTY_ACTION_CHOOSE_MON; // Used here as the caseId for the EmitChoose function. else - hitmarkerFaintBits = PARTY_MUST_CHOOSE_MON; + hitmarkerFaintBits = PARTY_ACTION_SEND_OUT; battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(0x80)); if (gSpecialStatuses[battlerId].flag40) @@ -5375,7 +5376,7 @@ static void atk50_openpartyscreen(void) *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6; gBattleStruct->field_93 &= ~(gBitTable[gActiveBattler]); - BtlController_EmitChoosePokemon(0, hitmarkerFaintBits, *(gBattleStruct->monToSwitchIntoId + (gActiveBattler ^ 2)), 0, gBattleStruct->field_60[gActiveBattler]); + BtlController_EmitChoosePokemon(0, hitmarkerFaintBits, *(gBattleStruct->monToSwitchIntoId + (gActiveBattler ^ 2)), ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 6; @@ -5407,7 +5408,7 @@ static void atk50_openpartyscreen(void) } } -static void atk51_switchhandleorder(void) +static void Cmd_switchhandleorder(void) { s32 i; if (gBattleControllerExecFlags) @@ -5433,7 +5434,7 @@ static void atk51_switchhandleorder(void) break; case 1: if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) - sub_803BDA0(gActiveBattler); + SwitchPartyOrder(gActiveBattler); break; case 2: if (!(gBattleStruct->field_93 & gBitTable[gActiveBattler])) @@ -5458,11 +5459,11 @@ static void atk51_switchhandleorder(void) } else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) { - sub_80571DC(gActiveBattler, *(gBattleStruct->monToSwitchIntoId + gActiveBattler)); + SwitchPartyOrderInGameMulti(gActiveBattler, *(gBattleStruct->monToSwitchIntoId + gActiveBattler)); } else { - sub_803BDA0(gActiveBattler); + SwitchPartyOrder(gActiveBattler); } PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].species) @@ -5474,7 +5475,7 @@ static void atk51_switchhandleorder(void) gBattlescriptCurrInstr += 3; } -static void atk52_switchineffects(void) +static void Cmd_switchineffects(void) { s32 i; @@ -5556,7 +5557,7 @@ static void atk52_switchineffects(void) } } -static void atk53_trainerslidein(void) +static void Cmd_trainerslidein(void) { gActiveBattler = GetBattlerAtPosition(gBattlescriptCurrInstr[1]); BtlController_EmitTrainerSlide(0); @@ -5565,7 +5566,7 @@ static void atk53_trainerslidein(void) gBattlescriptCurrInstr += 2; } -static void atk54_playse(void) +static void Cmd_playse(void) { gActiveBattler = gBattlerAttacker; BtlController_EmitPlaySE(0, T2_READ_16(gBattlescriptCurrInstr + 1)); @@ -5574,7 +5575,7 @@ static void atk54_playse(void) gBattlescriptCurrInstr += 3; } -static void atk55_fanfare(void) +static void Cmd_fanfare(void) { gActiveBattler = gBattlerAttacker; BtlController_EmitPlayFanfareOrBGM(0, T2_READ_16(gBattlescriptCurrInstr + 1), FALSE); @@ -5583,7 +5584,7 @@ static void atk55_fanfare(void) gBattlescriptCurrInstr += 3; } -static void atk56_playfaintcry(void) +static void Cmd_playfaintcry(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); BtlController_EmitFaintingCry(0); @@ -5592,7 +5593,7 @@ static void atk56_playfaintcry(void) gBattlescriptCurrInstr += 2; } -static void atk57(void) +static void Cmd_unknown_57(void) { gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); BtlController_EmitCmd55(0, gBattleOutcome); @@ -5601,7 +5602,7 @@ static void atk57(void) gBattlescriptCurrInstr += 1; } -static void atk58_returntoball(void) +static void Cmd_returntoball(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); BtlController_EmitReturnMonToBall(0, 1); @@ -5610,20 +5611,20 @@ static void atk58_returntoball(void) gBattlescriptCurrInstr += 2; } -static void atk59_handlelearnnewmove(void) +static void Cmd_handlelearnnewmove(void) { const u8 *jumpPtr1 = T1_READ_PTR(gBattlescriptCurrInstr + 1); const u8 *jumpPtr2 = T1_READ_PTR(gBattlescriptCurrInstr + 5); - u16 ret = MonTryLearningNewMove(&gPlayerParty[gBattleStruct->expGetterMonId], gBattlescriptCurrInstr[9]); - while (ret == 0xFFFE) - ret = MonTryLearningNewMove(&gPlayerParty[gBattleStruct->expGetterMonId], 0); + u16 learnMove = MonTryLearningNewMove(&gPlayerParty[gBattleStruct->expGetterMonId], gBattlescriptCurrInstr[9]); + while (learnMove == MON_ALREADY_KNOWS_MOVE) + learnMove = MonTryLearningNewMove(&gPlayerParty[gBattleStruct->expGetterMonId], FALSE); - if (ret == 0) + if (learnMove == 0) { gBattlescriptCurrInstr = jumpPtr2; } - else if (ret == 0xFFFF) + else if (learnMove == MON_HAS_MAX_MOVES) { gBattlescriptCurrInstr += 10; } @@ -5634,7 +5635,7 @@ static void atk59_handlelearnnewmove(void) if (gBattlerPartyIndexes[gActiveBattler] == gBattleStruct->expGetterMonId && !(gBattleMons[gActiveBattler].status2 & STATUS2_TRANSFORMED)) { - GiveMoveToBattleMon(&gBattleMons[gActiveBattler], ret); + GiveMoveToBattleMon(&gBattleMons[gActiveBattler], learnMove); } if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { @@ -5642,7 +5643,7 @@ static void atk59_handlelearnnewmove(void) if (gBattlerPartyIndexes[gActiveBattler] == gBattleStruct->expGetterMonId && !(gBattleMons[gActiveBattler].status2 & STATUS2_TRANSFORMED)) { - GiveMoveToBattleMon(&gBattleMons[gActiveBattler], ret); + GiveMoveToBattleMon(&gBattleMons[gActiveBattler], learnMove); } } @@ -5650,7 +5651,7 @@ static void atk59_handlelearnnewmove(void) } } -static void atk5A_yesnoboxlearnmove(void) +static void Cmd_yesnoboxlearnmove(void) { gActiveBattler = 0; @@ -5715,8 +5716,8 @@ static void atk5A_yesnoboxlearnmove(void) case 4: if (!gPaletteFade.active && gMain.callback2 == BattleMainCB2) { - u8 movePosition = sub_81C1B94(); - if (movePosition == 4) + u8 movePosition = GetMoveSlotToReplace(); + if (movePosition == MAX_MON_MOVES) { gBattleScripting.learnMoveState = 5; } @@ -5769,7 +5770,7 @@ static void atk5A_yesnoboxlearnmove(void) } } -static void atk5B_yesnoboxstoplearningmove(void) +static void Cmd_yesnoboxstoplearningmove(void) { switch (gBattleScripting.learnMoveState) { @@ -5816,7 +5817,7 @@ static void atk5B_yesnoboxstoplearningmove(void) } } -static void atk5C_hitanimation(void) +static void Cmd_hitanimation(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); @@ -5893,7 +5894,7 @@ static u32 GetTrainerMoneyToGive(u16 trainerId) return moneyReward; } -static void atk5D_getmoneyreward(void) +static void Cmd_getmoneyreward(void) { u32 moneyReward = GetTrainerMoneyToGive(gTrainerBattleOpponent_A); if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) @@ -5905,7 +5906,7 @@ static void atk5D_getmoneyreward(void) gBattlescriptCurrInstr++; } -static void atk5E(void) +static void Cmd_unknown_5E(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); @@ -5932,7 +5933,7 @@ static void atk5E(void) } } -static void atk5F_swapattackerwithtarget(void) +static void Cmd_swapattackerwithtarget(void) { gActiveBattler = gBattlerAttacker; gBattlerAttacker = gBattlerTarget; @@ -5946,7 +5947,7 @@ static void atk5F_swapattackerwithtarget(void) gBattlescriptCurrInstr++; } -static void atk60_incrementgamestat(void) +static void Cmd_incrementgamestat(void) { if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) IncrementGameStat(gBattlescriptCurrInstr[1]); @@ -5954,7 +5955,7 @@ static void atk60_incrementgamestat(void) gBattlescriptCurrInstr += 2; } -static void atk61_drawpartystatussummary(void) +static void Cmd_drawpartystatussummary(void) { s32 i; struct Pokemon *party; @@ -5991,7 +5992,7 @@ static void atk61_drawpartystatussummary(void) gBattlescriptCurrInstr += 2; } -static void atk62_hidepartystatussummary(void) +static void Cmd_hidepartystatussummary(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); BtlController_EmitHidePartyStatusSummary(0); @@ -6000,7 +6001,7 @@ static void atk62_hidepartystatussummary(void) gBattlescriptCurrInstr += 2; } -static void atk63_jumptocalledmove(void) +static void Cmd_jumptocalledmove(void) { if (gBattlescriptCurrInstr[1]) gCurrentMove = gCalledMove; @@ -6010,7 +6011,7 @@ static void atk63_jumptocalledmove(void) gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; } -static void atk64_statusanimation(void) +static void Cmd_statusanimation(void) { if (gBattleControllerExecFlags == 0) { @@ -6026,7 +6027,7 @@ static void atk64_statusanimation(void) } } -static void atk65_status2animation(void) +static void Cmd_status2animation(void) { u32 wantedToAnimate; @@ -6045,7 +6046,7 @@ static void atk65_status2animation(void) } } -static void atk66_chosenstatusanimation(void) +static void Cmd_chosenstatusanimation(void) { u32 wantedStatus; @@ -6064,7 +6065,7 @@ static void atk66_chosenstatusanimation(void) } } -static void atk67_yesnobox(void) +static void Cmd_yesnobox(void) { switch (gBattleCommunication[0]) { @@ -6107,7 +6108,7 @@ static void atk67_yesnobox(void) } } -static void atk68_cancelallactions(void) +static void Cmd_cancelallactions(void) { s32 i; @@ -6117,7 +6118,7 @@ static void atk68_cancelallactions(void) gBattlescriptCurrInstr++; } -static void atk69_adjustsetdamage(void) // The same as 0x7, except there's no random damage multiplier. +static void Cmd_adjustsetdamage(void) // The same as adjustnormaldamage, except there's no random damage multiplier. { u8 holdEffect, param; @@ -6157,7 +6158,7 @@ static void atk69_adjustsetdamage(void) // The same as 0x7, except there's no ra gBattlescriptCurrInstr++; } -static void atk6A_removeitem(void) +static void Cmd_removeitem(void) { u16* usedHeldItem; @@ -6173,35 +6174,35 @@ static void atk6A_removeitem(void) gBattlescriptCurrInstr += 2; } -static void atk6B_atknameinbuff1(void) +static void Cmd_atknameinbuff1(void) { PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattlerAttacker, gBattlerPartyIndexes[gBattlerAttacker]) gBattlescriptCurrInstr++; } -static void atk6C_drawlvlupbox(void) +static void Cmd_drawlvlupbox(void) { - if (gBattleScripting.atk6C_state == 0) + if (gBattleScripting.drawlvlupboxState == 0) { if (IsMonGettingExpSentOut()) - gBattleScripting.atk6C_state = 3; + gBattleScripting.drawlvlupboxState = 3; else - gBattleScripting.atk6C_state = 1; + gBattleScripting.drawlvlupboxState = 1; } - switch (gBattleScripting.atk6C_state) + switch (gBattleScripting.drawlvlupboxState) { case 1: gBattle_BG2_Y = 0x60; SetBgAttribute(2, BG_ATTR_PRIORITY, 0); ShowBg(2); sub_804F17C(); - gBattleScripting.atk6C_state = 2; + gBattleScripting.drawlvlupboxState = 2; break; case 2: if (!sub_804F1CC()) - gBattleScripting.atk6C_state = 3; + gBattleScripting.drawlvlupboxState = 3; break; case 3: gBattle_BG1_X = 0; @@ -6211,20 +6212,20 @@ static void atk6C_drawlvlupbox(void) ShowBg(0); ShowBg(1); HandleBattleWindow(0x12, 7, 0x1D, 0x13, WINDOW_x80); - gBattleScripting.atk6C_state = 4; + gBattleScripting.drawlvlupboxState = 4; break; case 4: DrawLevelUpWindow1(); PutWindowTilemap(13); CopyWindowToVram(13, 3); - gBattleScripting.atk6C_state++; + gBattleScripting.drawlvlupboxState++; break; case 5: case 7: if (!IsDma3ManagerBusyWithBgCopy()) { gBattle_BG1_Y = 0; - gBattleScripting.atk6C_state++; + gBattleScripting.drawlvlupboxState++; } break; case 6: @@ -6233,7 +6234,7 @@ static void atk6C_drawlvlupbox(void) PlaySE(SE_SELECT); DrawLevelUpWindow2(); CopyWindowToVram(13, 2); - gBattleScripting.atk6C_state++; + gBattleScripting.drawlvlupboxState++; } break; case 8: @@ -6241,7 +6242,7 @@ static void atk6C_drawlvlupbox(void) { PlaySE(SE_SELECT); HandleBattleWindow(0x12, 7, 0x1D, 0x13, WINDOW_x80 | WINDOW_CLEAR); - gBattleScripting.atk6C_state++; + gBattleScripting.drawlvlupboxState++; } break; case 9: @@ -6256,7 +6257,7 @@ static void atk6C_drawlvlupbox(void) SetBgAttribute(2, BG_ATTR_PRIORITY, 2); ShowBg(2); - gBattleScripting.atk6C_state = 10; + gBattleScripting.drawlvlupboxState = 10; } break; case 10: @@ -6454,19 +6455,19 @@ static bool32 IsMonGettingExpSentOut(void) return FALSE; } -static void atk6D_resetsentmonsvalue(void) +static void Cmd_resetsentmonsvalue(void) { ResetSentPokesToOpponentValue(); gBattlescriptCurrInstr++; } -static void atk6E_setatktoplayer0(void) +static void Cmd_setatktoplayer0(void) { gBattlerAttacker = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); gBattlescriptCurrInstr++; } -static void atk6F_makevisible(void) +static void Cmd_makevisible(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); BtlController_EmitSpriteInvisibility(0, FALSE); @@ -6475,7 +6476,7 @@ static void atk6F_makevisible(void) gBattlescriptCurrInstr += 2; } -static void atk70_recordlastability(void) +static void Cmd_recordlastability(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); RecordAbilityBattle(gActiveBattler, gLastUsedAbility); @@ -6487,13 +6488,13 @@ void BufferMoveToLearnIntoBattleTextBuff2(void) PREPARE_MOVE_BUFFER(gBattleTextBuff2, gMoveToLearn); } -static void atk71_buffermovetolearn(void) +static void Cmd_buffermovetolearn(void) { BufferMoveToLearnIntoBattleTextBuff2(); gBattlescriptCurrInstr++; } -static void atk72_jumpifplayerran(void) +static void Cmd_jumpifplayerran(void) { if (TryRunFromBattle(gBattlerFainted)) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); @@ -6501,7 +6502,7 @@ static void atk72_jumpifplayerran(void) gBattlescriptCurrInstr += 5; } -static void atk73_hpthresholds(void) +static void Cmd_hpthresholds(void) { u8 opposingBank; s32 result; @@ -6528,7 +6529,7 @@ static void atk73_hpthresholds(void) gBattlescriptCurrInstr += 2; } -static void atk74_hpthresholds2(void) +static void Cmd_hpthresholds2(void) { u8 opposingBank; s32 result; @@ -6554,14 +6555,14 @@ static void atk74_hpthresholds2(void) gBattlescriptCurrInstr += 2; } -static void atk75_useitemonopponent(void) +static void Cmd_useitemonopponent(void) { gBattlerInMenuId = gBattlerAttacker; PokemonUseItemEffects(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]], gLastUsedItem, gBattlerPartyIndexes[gBattlerAttacker], 0, 1); gBattlescriptCurrInstr += 1; } -static void atk76_various(void) +static void Cmd_various(void) { u8 side; s32 i; @@ -6740,7 +6741,7 @@ static void atk76_various(void) gBattlescriptCurrInstr += 3; } -static void atk77_setprotectlike(void) // protect and endure +static void Cmd_setprotectlike(void) // protect and endure { bool8 notLastTurn = TRUE; u16 lastMove = gLastResultingMoves[gBattlerAttacker]; @@ -6775,7 +6776,7 @@ static void atk77_setprotectlike(void) // protect and endure gBattlescriptCurrInstr++; } -static void atk78_faintifabilitynotdamp(void) +static void Cmd_faintifabilitynotdamp(void) { if (gBattleControllerExecFlags) return; @@ -6810,7 +6811,7 @@ static void atk78_faintifabilitynotdamp(void) } } -static void atk79_setatkhptozero(void) +static void Cmd_setatkhptozero(void) { if (gBattleControllerExecFlags) return; @@ -6823,7 +6824,7 @@ static void atk79_setatkhptozero(void) gBattlescriptCurrInstr++; } -static void atk7A_jumpifnexttargetvalid(void) +static void Cmd_jumpifnexttargetvalid(void) { const u8 *jumpPtr = T1_READ_PTR(gBattlescriptCurrInstr + 1); @@ -6848,7 +6849,7 @@ static void atk7A_jumpifnexttargetvalid(void) } } -static void atk7B_tryhealhalfhealth(void) +static void Cmd_tryhealhalfhealth(void) { const u8* failPtr = T1_READ_PTR(gBattlescriptCurrInstr + 1); @@ -6866,7 +6867,7 @@ static void atk7B_tryhealhalfhealth(void) gBattlescriptCurrInstr += 6; } -static void atk7C_trymirrormove(void) +static void Cmd_trymirrormove(void) { s32 validMovesCount; s32 i; @@ -6916,7 +6917,7 @@ static void atk7C_trymirrormove(void) } } -static void atk7D_setrain(void) +static void Cmd_setrain(void) { if (gBattleWeather & WEATHER_RAIN_ANY) { @@ -6932,7 +6933,7 @@ static void atk7D_setrain(void) gBattlescriptCurrInstr++; } -static void atk7E_setreflect(void) +static void Cmd_setreflect(void) { if (gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] & SIDE_STATUS_REFLECT) { @@ -6953,7 +6954,7 @@ static void atk7E_setreflect(void) gBattlescriptCurrInstr++; } -static void atk7F_setseeded(void) +static void Cmd_setseeded(void) { if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT || gStatuses3[gBattlerTarget] & STATUS3_LEECHSEED) { @@ -6975,21 +6976,21 @@ static void atk7F_setseeded(void) gBattlescriptCurrInstr++; } -static void atk80_manipulatedamage(void) +static void Cmd_manipulatedamage(void) { switch (gBattlescriptCurrInstr[1]) { - case ATK80_DMG_CHANGE_SIGN: + case DMG_CHANGE_SIGN: gBattleMoveDamage *= -1; break; - case ATK80_DMG_HALF_BY_TWO_NOT_MORE_THAN_HALF_MAX_HP: + case DMG_RECOIL_FROM_MISS: gBattleMoveDamage /= 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; if ((gBattleMons[gBattlerTarget].maxHP / 2) < gBattleMoveDamage) gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP / 2; break; - case ATK80_DMG_DOUBLED: + case DMG_DOUBLED: gBattleMoveDamage *= 2; break; } @@ -6997,7 +6998,7 @@ static void atk80_manipulatedamage(void) gBattlescriptCurrInstr += 2; } -static void atk81_trysetrest(void) +static void Cmd_trysetrest(void) { const u8 *failJump = T1_READ_PTR(gBattlescriptCurrInstr + 1); gActiveBattler = gBattlerTarget = gBattlerAttacker; @@ -7021,7 +7022,7 @@ static void atk81_trysetrest(void) } } -static void atk82_jumpifnotfirstturn(void) +static void Cmd_jumpifnotfirstturn(void) { const u8* failJump = T1_READ_PTR(gBattlescriptCurrInstr + 1); @@ -7031,7 +7032,7 @@ static void atk82_jumpifnotfirstturn(void) gBattlescriptCurrInstr = failJump; } -static void atk83_nop(void) +static void Cmd_nop(void) { gBattlescriptCurrInstr++; } @@ -7063,7 +7064,7 @@ bool8 UproarWakeUpCheck(u8 battlerId) return TRUE; } -static void atk84_jumpifcantmakeasleep(void) +static void Cmd_jumpifcantmakeasleep(void) { const u8 *jumpPtr = T1_READ_PTR(gBattlescriptCurrInstr + 1); @@ -7085,7 +7086,7 @@ static void atk84_jumpifcantmakeasleep(void) } } -static void atk85_stockpile(void) +static void Cmd_stockpile(void) { if (gDisableStructs[gBattlerAttacker].stockpileCounter == 3) { @@ -7103,7 +7104,7 @@ static void atk85_stockpile(void) gBattlescriptCurrInstr++; } -static void atk86_stockpiletobasedamage(void) +static void Cmd_stockpiletobasedamage(void) { const u8* jumpPtr = T1_READ_PTR(gBattlescriptCurrInstr + 1); if (gDisableStructs[gBattlerAttacker].stockpileCounter == 0) @@ -7129,7 +7130,7 @@ static void atk86_stockpiletobasedamage(void) } } -static void atk87_stockpiletohpheal(void) +static void Cmd_stockpiletohpheal(void) { const u8* jumpPtr = T1_READ_PTR(gBattlescriptCurrInstr + 1); @@ -7160,7 +7161,7 @@ static void atk87_stockpiletohpheal(void) } } -static void atk88_negativedamage(void) +static void Cmd_negativedamage(void) { gBattleMoveDamage = -(gHpDealt / 2); if (gBattleMoveDamage == 0) @@ -7169,8 +7170,8 @@ static void atk88_negativedamage(void) gBattlescriptCurrInstr++; } -#define STAT_CHANGE_WORKED 0 -#define STAT_CHANGE_DIDNT_WORK 1 +#define STAT_BUFF_WORKED 0 +#define STAT_BUFF_DIDNT_WORK 1 static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) { @@ -7189,9 +7190,9 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) certain++; flags &= ~(MOVE_EFFECT_CERTAIN); - if (flags & STAT_CHANGE_NOT_PROTECT_AFFECTED) + if (flags & STAT_BUFF_NOT_PROTECT_AFFECTED) notProtectAffected++; - flags &= ~(STAT_CHANGE_NOT_PROTECT_AFFECTED); + flags &= ~(STAT_BUFF_NOT_PROTECT_AFFECTED); PREPARE_STAT_BUFFER(gBattleTextBuff1, statId) @@ -7200,7 +7201,7 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) if (gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].mistTimer && !certain && gCurrentMove != MOVE_CURSE) { - if (flags == STAT_CHANGE_BS_PTR) + if (flags == STAT_BUFF_ALLOW_PTR) { if (gSpecialStatuses[gActiveBattler].statLowered) { @@ -7214,19 +7215,19 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) gSpecialStatuses[gActiveBattler].statLowered = 1; } } - return STAT_CHANGE_DIDNT_WORK; + return STAT_BUFF_DIDNT_WORK; } else if (gCurrentMove != MOVE_CURSE && notProtectAffected != TRUE && JumpIfMoveAffectedByProtect(0)) { gBattlescriptCurrInstr = BattleScript_ButItFailed; - return STAT_CHANGE_DIDNT_WORK; + return STAT_BUFF_DIDNT_WORK; } else if ((gBattleMons[gActiveBattler].ability == ABILITY_CLEAR_BODY || gBattleMons[gActiveBattler].ability == ABILITY_WHITE_SMOKE) && !certain && gCurrentMove != MOVE_CURSE) { - if (flags == STAT_CHANGE_BS_PTR) + if (flags == STAT_BUFF_ALLOW_PTR) { if (gSpecialStatuses[gActiveBattler].statLowered) { @@ -7242,12 +7243,12 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) gSpecialStatuses[gActiveBattler].statLowered = 1; } } - return STAT_CHANGE_DIDNT_WORK; + return STAT_BUFF_DIDNT_WORK; } else if (gBattleMons[gActiveBattler].ability == ABILITY_KEEN_EYE && !certain && statId == STAT_ACC) { - if (flags == STAT_CHANGE_BS_PTR) + if (flags == STAT_BUFF_ALLOW_PTR) { BattleScriptPush(BS_ptr); gBattleScripting.battler = gActiveBattler; @@ -7255,12 +7256,12 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) gLastUsedAbility = gBattleMons[gActiveBattler].ability; RecordAbilityBattle(gActiveBattler, gLastUsedAbility); } - return STAT_CHANGE_DIDNT_WORK; + return STAT_BUFF_DIDNT_WORK; } else if (gBattleMons[gActiveBattler].ability == ABILITY_HYPER_CUTTER && !certain && statId == STAT_ATK) { - if (flags == STAT_CHANGE_BS_PTR) + if (flags == STAT_BUFF_ALLOW_PTR) { BattleScriptPush(BS_ptr); gBattleScripting.battler = gActiveBattler; @@ -7268,11 +7269,11 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) gLastUsedAbility = gBattleMons[gActiveBattler].ability; RecordAbilityBattle(gActiveBattler, gLastUsedAbility); } - return STAT_CHANGE_DIDNT_WORK; + return STAT_BUFF_DIDNT_WORK; } else if (gBattleMons[gActiveBattler].ability == ABILITY_SHIELD_DUST && flags == 0) { - return STAT_CHANGE_DIDNT_WORK; + return STAT_BUFF_DIDNT_WORK; } else // try to decrease { @@ -7333,23 +7334,23 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) if (gBattleMons[gActiveBattler].statStages[statId] > 0xC) gBattleMons[gActiveBattler].statStages[statId] = 0xC; - if (gBattleCommunication[MULTISTRING_CHOOSER] == 2 && flags & STAT_CHANGE_BS_PTR) + if (gBattleCommunication[MULTISTRING_CHOOSER] == 2 && flags & STAT_BUFF_ALLOW_PTR) gMoveResultFlags |= MOVE_RESULT_MISSED; - if (gBattleCommunication[MULTISTRING_CHOOSER] == 2 && !(flags & STAT_CHANGE_BS_PTR)) - return STAT_CHANGE_DIDNT_WORK; + if (gBattleCommunication[MULTISTRING_CHOOSER] == 2 && !(flags & STAT_BUFF_ALLOW_PTR)) + return STAT_BUFF_DIDNT_WORK; - return STAT_CHANGE_WORKED; + return STAT_BUFF_WORKED; } -static void atk89_statbuffchange(void) +static void Cmd_statbuffchange(void) { const u8* jumpPtr = T1_READ_PTR(gBattlescriptCurrInstr + 2); - if (ChangeStatBuffs(gBattleScripting.statChanger & 0xF0, GET_STAT_BUFF_ID(gBattleScripting.statChanger), gBattlescriptCurrInstr[1], jumpPtr) == STAT_CHANGE_WORKED) + if (ChangeStatBuffs(gBattleScripting.statChanger & 0xF0, GET_STAT_BUFF_ID(gBattleScripting.statChanger), gBattlescriptCurrInstr[1], jumpPtr) == STAT_BUFF_WORKED) gBattlescriptCurrInstr += 6; } -static void atk8A_normalisebuffs(void) // haze +static void Cmd_normalisebuffs(void) // haze { s32 i, j; @@ -7362,7 +7363,7 @@ static void atk8A_normalisebuffs(void) // haze gBattlescriptCurrInstr++; } -static void atk8B_setbide(void) +static void Cmd_setbide(void) { gBattleMons[gBattlerAttacker].status2 |= STATUS2_MULTIPLETURNS; gLockedMoves[gBattlerAttacker] = gCurrentMove; @@ -7372,7 +7373,7 @@ static void atk8B_setbide(void) gBattlescriptCurrInstr++; } -static void atk8C_confuseifrepeatingattackends(void) +static void Cmd_confuseifrepeatingattackends(void) { if (!(gBattleMons[gBattlerAttacker].status2 & STATUS2_LOCK_CONFUSE)) gBattleCommunication[MOVE_EFFECT_BYTE] = (MOVE_EFFECT_THRASH | MOVE_EFFECT_AFFECTS_USER); @@ -7380,7 +7381,7 @@ static void atk8C_confuseifrepeatingattackends(void) gBattlescriptCurrInstr++; } -static void atk8D_setmultihitcounter(void) +static void Cmd_setmultihitcounter(void) { if (gBattlescriptCurrInstr[1]) { @@ -7398,7 +7399,7 @@ static void atk8D_setmultihitcounter(void) gBattlescriptCurrInstr += 2; } -static void atk8E_initmultihitstring(void) +static void Cmd_initmultihitstring(void) { PREPARE_BYTE_NUMBER_BUFFER(gBattleScripting.multihitString, 1, 0) @@ -7426,7 +7427,7 @@ static bool8 TryDoForceSwitchOut(void) return TRUE; } -static void atk8F_forcerandomswitch(void) +static void Cmd_forcerandomswitch(void) { s32 i; s32 battler1PartyId = 0; @@ -7566,19 +7567,19 @@ static void atk8F_forcerandomswitch(void) *(gBattleStruct->monToSwitchIntoId + gBattlerTarget) = i; if (!IsMultiBattle()) - sub_803BDA0(gBattlerTarget); + SwitchPartyOrder(gBattlerTarget); 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)) { - sub_81B8E80(gBattlerTarget, i, 0); - sub_81B8E80(gBattlerTarget ^ BIT_FLANK, i, 1); + SwitchPartyOrderLinkMulti(gBattlerTarget, i, 0); + SwitchPartyOrderLinkMulti(gBattlerTarget ^ BIT_FLANK, i, 1); } if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) - sub_80571DC(gBattlerTarget, i); + SwitchPartyOrderInGameMulti(gBattlerTarget, i); } } else @@ -7587,7 +7588,7 @@ static void atk8F_forcerandomswitch(void) } } -static void atk90_tryconversiontypechange(void) // randomly changes user's type to one of its moves' type +static void Cmd_tryconversiontypechange(void) // randomly changes user's type to one of its moves' type { u8 validMoves = 0; u8 moveChecked; @@ -7649,7 +7650,7 @@ static void atk90_tryconversiontypechange(void) // randomly changes user's type } } -static void atk91_givepaydaymoney(void) +static void Cmd_givepaydaymoney(void) { if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) && gPaydayMoney != 0) { @@ -7667,7 +7668,7 @@ static void atk91_givepaydaymoney(void) } } -static void atk92_setlightscreen(void) +static void Cmd_setlightscreen(void) { if (gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] & SIDE_STATUS_LIGHTSCREEN) { @@ -7689,7 +7690,7 @@ static void atk92_setlightscreen(void) gBattlescriptCurrInstr++; } -static void atk93_tryKO(void) +static void Cmd_tryKO(void) { u8 holdEffect, param; @@ -7775,7 +7776,7 @@ static void atk93_tryKO(void) } } -static void atk94_damagetohalftargethp(void) // super fang +static void Cmd_damagetohalftargethp(void) // super fang { gBattleMoveDamage = gBattleMons[gBattlerTarget].hp / 2; if (gBattleMoveDamage == 0) @@ -7784,7 +7785,7 @@ static void atk94_damagetohalftargethp(void) // super fang gBattlescriptCurrInstr++; } -static void atk95_setsandstorm(void) +static void Cmd_setsandstorm(void) { if (gBattleWeather & WEATHER_SANDSTORM_ANY) { @@ -7800,7 +7801,7 @@ static void atk95_setsandstorm(void) gBattlescriptCurrInstr++; } -static void atk96_weatherdamage(void) +static void Cmd_weatherdamage(void) { if (WEATHER_HAS_EFFECT) { @@ -7825,7 +7826,7 @@ static void atk96_weatherdamage(void) gBattleMoveDamage = 0; } } - if (gBattleWeather & WEATHER_HAIL) + if (gBattleWeather & WEATHER_HAIL_ANY) { if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE) && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND) @@ -7852,7 +7853,7 @@ static void atk96_weatherdamage(void) gBattlescriptCurrInstr++; } -static void atk97_tryinfatuating(void) +static void Cmd_tryinfatuating(void) { struct Pokemon *monAttacker, *monTarget; u16 speciesAttacker, speciesTarget; @@ -7897,7 +7898,7 @@ static void atk97_tryinfatuating(void) } } -static void atk98_updatestatusicon(void) +static void Cmd_updatestatusicon(void) { if (gBattleControllerExecFlags) return; @@ -7930,7 +7931,7 @@ static void atk98_updatestatusicon(void) } } -static void atk99_setmist(void) +static void Cmd_setmist(void) { if (gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].mistTimer) { @@ -7947,7 +7948,7 @@ static void atk99_setmist(void) gBattlescriptCurrInstr++; } -static void atk9A_setfocusenergy(void) +static void Cmd_setfocusenergy(void) { if (gBattleMons[gBattlerAttacker].status2 & STATUS2_FOCUS_ENERGY) { @@ -7962,7 +7963,7 @@ static void atk9A_setfocusenergy(void) gBattlescriptCurrInstr++; } -static void atk9B_transformdataexecution(void) +static void Cmd_transformdataexecution(void) { gChosenMove = 0xFFFF; gBattlescriptCurrInstr++; @@ -8006,7 +8007,7 @@ static void atk9B_transformdataexecution(void) } } -static void atk9C_setsubstitute(void) +static void Cmd_setsubstitute(void) { u32 hp = gBattleMons[gBattlerAttacker].maxHP / 4; if (gBattleMons[gBattlerAttacker].maxHP / 4 == 0) @@ -8042,7 +8043,7 @@ static bool8 IsMoveUncopyableByMimic(u16 move) return (sMovesForbiddenToCopy[i] != MIMIC_FORBIDDEN_END); } -static void atk9D_mimicattackcopy(void) +static void Cmd_mimicattackcopy(void) { gChosenMove = 0xFFFF; @@ -8084,7 +8085,7 @@ static void atk9D_mimicattackcopy(void) } } -static void atk9E_metronome(void) +static void Cmd_metronome(void) { while (1) { @@ -8116,13 +8117,13 @@ static void atk9E_metronome(void) } } -static void atk9F_dmgtolevel(void) +static void Cmd_dmgtolevel(void) { gBattleMoveDamage = gBattleMons[gBattlerAttacker].level; gBattlescriptCurrInstr++; } -static void atkA0_psywavedamageeffect(void) +static void Cmd_psywavedamageeffect(void) { s32 randDamage; @@ -8133,7 +8134,7 @@ static void atkA0_psywavedamageeffect(void) gBattlescriptCurrInstr++; } -static void atkA1_counterdamagecalculator(void) +static void Cmd_counterdamagecalculator(void) { u8 sideAttacker = GetBattlerSide(gBattlerAttacker); u8 sideTarget = GetBattlerSide(gProtectStructs[gBattlerAttacker].physicalBattlerId); @@ -8158,7 +8159,7 @@ static void atkA1_counterdamagecalculator(void) } } -static void atkA2_mirrorcoatdamagecalculator(void) // a copy of atkA1 with the physical -> special field changes +static void Cmd_mirrorcoatdamagecalculator(void) // a copy of Cmd with the physical -> special field changes { u8 sideAttacker = GetBattlerSide(gBattlerAttacker); u8 sideTarget = GetBattlerSide(gProtectStructs[gBattlerAttacker].specialBattlerId); @@ -8181,7 +8182,7 @@ static void atkA2_mirrorcoatdamagecalculator(void) // a copy of atkA1 with the p } } -static void atkA3_disablelastusedattack(void) +static void Cmd_disablelastusedattack(void) { s32 i; @@ -8206,7 +8207,7 @@ static void atkA3_disablelastusedattack(void) } } -static void atkA4_trysetencore(void) +static void Cmd_trysetencore(void) { s32 i; @@ -8238,7 +8239,7 @@ static void atkA4_trysetencore(void) } } -static void atkA5_painsplitdmgcalc(void) +static void Cmd_painsplitdmgcalc(void) { if (!(gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE)) { @@ -8262,7 +8263,7 @@ static void atkA5_painsplitdmgcalc(void) } } -static void atkA6_settypetorandomresistance(void) // conversion 2 +static void Cmd_settypetorandomresistance(void) // conversion 2 { if (gLastLandedMoves[gBattlerAttacker] == 0 || gLastLandedMoves[gBattlerAttacker] == 0xFFFF) @@ -8322,7 +8323,7 @@ static void atkA6_settypetorandomresistance(void) // conversion 2 } } -static void atkA7_setalwayshitflag(void) +static void Cmd_setalwayshitflag(void) { gStatuses3[gBattlerTarget] &= ~(STATUS3_ALWAYS_HITS); gStatuses3[gBattlerTarget] |= 0x10; @@ -8330,7 +8331,7 @@ static void atkA7_setalwayshitflag(void) gBattlescriptCurrInstr++; } -static void atkA8_copymovepermanently(void) // sketch +static void Cmd_copymovepermanently(void) // sketch { gChosenMove = 0xFFFF; @@ -8425,7 +8426,7 @@ static u8 AttacksThisTurn(u8 battlerId, u16 move) // Note: returns 1 if it's a c return 2; } -static void atkA9_trychoosesleeptalkmove(void) +static void Cmd_trychoosesleeptalkmove(void) { s32 i; u8 unusableMovesBits = 0; @@ -8464,7 +8465,7 @@ static void atkA9_trychoosesleeptalkmove(void) } } -static void atkAA_setdestinybond(void) +static void Cmd_setdestinybond(void) { gBattleMons[gBattlerAttacker].status2 |= STATUS2_DESTINY_BOND; gBattlescriptCurrInstr++; @@ -8482,13 +8483,13 @@ static void TrySetDestinyBondToHappen(void) } } -static void atkAB_trysetdestinybondtohappen(void) +static void Cmd_trysetdestinybondtohappen(void) { TrySetDestinyBondToHappen(); gBattlescriptCurrInstr++; } -static void atkAC_remaininghptopower(void) +static void Cmd_remaininghptopower(void) { s32 i; s32 hpFraction = GetScaledHPFraction(gBattleMons[gBattlerAttacker].hp, gBattleMons[gBattlerAttacker].maxHP, 48); @@ -8503,7 +8504,7 @@ static void atkAC_remaininghptopower(void) gBattlescriptCurrInstr++; } -static void atkAD_tryspiteppreduce(void) +static void Cmd_tryspiteppreduce(void) { if (gLastMoves[gBattlerTarget] != 0 && gLastMoves[gBattlerTarget] != 0xFFFF) @@ -8554,7 +8555,7 @@ static void atkAD_tryspiteppreduce(void) } } -static void atkAE_healpartystatus(void) +static void Cmd_healpartystatus(void) { u32 zero = 0; u8 toHeal = 0; @@ -8650,7 +8651,7 @@ static void atkAE_healpartystatus(void) gBattlescriptCurrInstr++; } -static void atkAF_cursetarget(void) +static void Cmd_cursetarget(void) { if (gBattleMons[gBattlerTarget].status2 & STATUS2_CURSED) { @@ -8667,7 +8668,7 @@ static void atkAF_cursetarget(void) } } -static void atkB0_trysetspikes(void) +static void Cmd_trysetspikes(void) { u8 targetSide = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE; @@ -8684,13 +8685,13 @@ static void atkB0_trysetspikes(void) } } -static void atkB1_setforesight(void) +static void Cmd_setforesight(void) { gBattleMons[gBattlerTarget].status2 |= STATUS2_FORESIGHT; gBattlescriptCurrInstr++; } -static void atkB2_trysetperishsong(void) +static void Cmd_trysetperishsong(void) { s32 i; s32 notAffectedCount = 0; @@ -8718,7 +8719,7 @@ static void atkB2_trysetperishsong(void) gBattlescriptCurrInstr += 5; } -static void atkB3_rolloutdamagecalculation(void) +static void Cmd_rolloutdamagecalculation(void) { if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { @@ -8753,7 +8754,7 @@ static void atkB3_rolloutdamagecalculation(void) } } -static void atkB4_jumpifconfusedandstatmaxed(void) +static void Cmd_jumpifconfusedandstatmaxed(void) { if (gBattleMons[gBattlerTarget].status2 & STATUS2_CONFUSION && gBattleMons[gBattlerTarget].statStages[gBattlescriptCurrInstr[1]] == 0xC) @@ -8762,7 +8763,7 @@ static void atkB4_jumpifconfusedandstatmaxed(void) gBattlescriptCurrInstr += 6; } -static void atkB5_furycuttercalc(void) +static void Cmd_furycuttercalc(void) { if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { @@ -8785,7 +8786,7 @@ static void atkB5_furycuttercalc(void) } } -static void atkB6_happinesstodamagecalculation(void) +static void Cmd_happinesstodamagecalculation(void) { if (gBattleMoves[gCurrentMove].effect == EFFECT_RETURN) gDynamicBasePower = 10 * (gBattleMons[gBattlerAttacker].friendship) / 25; @@ -8795,7 +8796,7 @@ static void atkB6_happinesstodamagecalculation(void) gBattlescriptCurrInstr++; } -static void atkB7_presentdamagecalculation(void) +static void Cmd_presentdamagecalculation(void) { s32 rand = Random() & 0xFF; @@ -8823,7 +8824,7 @@ static void atkB7_presentdamagecalculation(void) } } -static void atkB8_setsafeguard(void) +static void Cmd_setsafeguard(void) { if (gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] & SIDE_STATUS_SAFEGUARD) { @@ -8841,7 +8842,7 @@ static void atkB8_setsafeguard(void) gBattlescriptCurrInstr++; } -static void atkB9_magnitudedamagecalculation(void) +static void Cmd_magnitudedamagecalculation(void) { s32 magnitude = Random() % 100; @@ -8895,7 +8896,7 @@ static void atkB9_magnitudedamagecalculation(void) gBattlescriptCurrInstr++; } -static void atkBA_jumpifnopursuitswitchdmg(void) +static void Cmd_jumpifnopursuitswitchdmg(void) { if (gMultiHitCounter == 1) { @@ -8939,7 +8940,7 @@ static void atkBA_jumpifnopursuitswitchdmg(void) } } -static void atkBB_setsunny(void) +static void Cmd_setsunny(void) { if (gBattleWeather & WEATHER_SUN_ANY) { @@ -8956,7 +8957,7 @@ static void atkBB_setsunny(void) gBattlescriptCurrInstr++; } -static void atkBC_maxattackhalvehp(void) // belly drum +static void Cmd_maxattackhalvehp(void) // belly drum { u32 halfHp = gBattleMons[gBattlerAttacker].maxHP / 2; @@ -8979,7 +8980,7 @@ static void atkBC_maxattackhalvehp(void) // belly drum } } -static void atkBD_copyfoestats(void) // psych up +static void Cmd_copyfoestats(void) // psych up { s32 i; @@ -8991,7 +8992,7 @@ static void atkBD_copyfoestats(void) // psych up gBattlescriptCurrInstr += 5; // Has an unused jump ptr(possibly for a failed attempt) parameter. } -static void atkBE_rapidspinfree(void) +static void Cmd_rapidspinfree(void) { if (gBattleMons[gBattlerAttacker].status2 & STATUS2_WRAPPED) { @@ -9028,13 +9029,13 @@ static void atkBE_rapidspinfree(void) } } -static void atkBF_setdefensecurlbit(void) +static void Cmd_setdefensecurlbit(void) { gBattleMons[gBattlerAttacker].status2 |= STATUS2_DEFENSE_CURL; gBattlescriptCurrInstr++; } -static void atkC0_recoverbasedonsunlight(void) +static void Cmd_recoverbasedonsunlight(void) { gBattlerTarget = gBattlerAttacker; @@ -9059,7 +9060,7 @@ static void atkC0_recoverbasedonsunlight(void) } } -static void atkC1_hiddenpowercalc(void) +static void Cmd_hiddenpowercalc(void) { u8 powerBits; u8 typeBits; @@ -9088,7 +9089,7 @@ static void atkC1_hiddenpowercalc(void) gBattlescriptCurrInstr++; } -static void atkC2_selectfirstvalidtarget(void) +static void Cmd_selectfirstvalidtarget(void) { for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) { @@ -9100,7 +9101,7 @@ static void atkC2_selectfirstvalidtarget(void) gBattlescriptCurrInstr++; } -static void atkC3_trysetfutureattack(void) +static void Cmd_trysetfutureattack(void) { if (gWishFutureKnock.futureSightCounter[gBattlerTarget] != 0) { @@ -9128,7 +9129,7 @@ static void atkC3_trysetfutureattack(void) } } -static void atkC4_trydobeatup(void) +static void Cmd_trydobeatup(void) { struct Pokemon *party; @@ -9175,7 +9176,7 @@ static void atkC4_trydobeatup(void) } } -static void atkC5_setsemiinvulnerablebit(void) +static void Cmd_setsemiinvulnerablebit(void) { switch (gCurrentMove) { @@ -9194,7 +9195,7 @@ static void atkC5_setsemiinvulnerablebit(void) gBattlescriptCurrInstr++; } -static void atkC6_clearsemiinvulnerablebit(void) +static void Cmd_clearsemiinvulnerablebit(void) { switch (gCurrentMove) { @@ -9213,7 +9214,7 @@ static void atkC6_clearsemiinvulnerablebit(void) gBattlescriptCurrInstr++; } -static void atkC7_setminimize(void) +static void Cmd_setminimize(void) { if (gHitMarker & HITMARKER_OBEYS) gStatuses3[gBattlerAttacker] |= STATUS3_MINIMIZED; @@ -9221,7 +9222,7 @@ static void atkC7_setminimize(void) gBattlescriptCurrInstr++; } -static void atkC8_sethail(void) +static void Cmd_sethail(void) { if (gBattleWeather & WEATHER_HAIL_ANY) { @@ -9238,7 +9239,7 @@ static void atkC8_sethail(void) gBattlescriptCurrInstr++; } -static void atkC9_jumpifattackandspecialattackcannotfall(void) // memento +static void Cmd_jumpifattackandspecialattackcannotfall(void) // memento { if (gBattleMons[gBattlerTarget].statStages[STAT_ATK] == 0 && gBattleMons[gBattlerTarget].statStages[STAT_SPATK] == 0 @@ -9256,14 +9257,14 @@ static void atkC9_jumpifattackandspecialattackcannotfall(void) // memento } } -static void atkCA_setforcedtarget(void) // follow me +static void Cmd_setforcedtarget(void) // follow me { gSideTimers[GetBattlerSide(gBattlerAttacker)].followmeTimer = 1; gSideTimers[GetBattlerSide(gBattlerAttacker)].followmeTarget = gBattlerAttacker; gBattlescriptCurrInstr++; } -static void atkCB_setcharge(void) +static void Cmd_setcharge(void) { gStatuses3[gBattlerAttacker] |= STATUS3_CHARGED_UP; gDisableStructs[gBattlerAttacker].chargeTimer = 2; @@ -9271,7 +9272,7 @@ static void atkCB_setcharge(void) gBattlescriptCurrInstr++; } -static void atkCC_callterrainattack(void) // nature power +static void Cmd_callterrainattack(void) // nature power { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gCurrentMove = sNaturePowerMoves[gBattleTerrain]; @@ -9280,7 +9281,7 @@ static void atkCC_callterrainattack(void) // nature power gBattlescriptCurrInstr++; } -static void atkCD_cureifburnedparalysedorpoisoned(void) // refresh +static void Cmd_cureifburnedparalysedorpoisoned(void) // refresh { if (gBattleMons[gBattlerAttacker].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)) { @@ -9296,7 +9297,7 @@ static void atkCD_cureifburnedparalysedorpoisoned(void) // refresh } } -static void atkCE_settorment(void) +static void Cmd_settorment(void) { if (gBattleMons[gBattlerTarget].status2 & STATUS2_TORMENT) { @@ -9309,7 +9310,7 @@ static void atkCE_settorment(void) } } -static void atkCF_jumpifnodamage(void) +static void Cmd_jumpifnodamage(void) { if (gProtectStructs[gBattlerAttacker].physicalDmg || gProtectStructs[gBattlerAttacker].specialDmg) gBattlescriptCurrInstr += 5; @@ -9317,7 +9318,7 @@ static void atkCF_jumpifnodamage(void) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } -static void atkD0_settaunt(void) +static void Cmd_settaunt(void) { if (gDisableStructs[gBattlerTarget].tauntTimer == 0) { @@ -9331,7 +9332,7 @@ static void atkD0_settaunt(void) } } -static void atkD1_trysethelpinghand(void) +static void Cmd_trysethelpinghand(void) { gBattlerTarget = GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) ^ BIT_FLANK); @@ -9349,7 +9350,7 @@ static void atkD1_trysethelpinghand(void) } } -static void atkD2_tryswapitems(void) // trick +static void Cmd_tryswapitems(void) // trick { // opponent can't swap items with player in regular battles if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL @@ -9436,7 +9437,7 @@ static void atkD2_tryswapitems(void) // trick } } -static void atkD3_trycopyability(void) // role play +static void Cmd_trycopyability(void) // role play { if (gBattleMons[gBattlerTarget].ability != 0 && gBattleMons[gBattlerTarget].ability != ABILITY_WONDER_GUARD) @@ -9451,7 +9452,7 @@ static void atkD3_trycopyability(void) // role play } } -static void atkD4_trywish(void) +static void Cmd_trywish(void) { switch (gBattlescriptCurrInstr[1]) { @@ -9484,7 +9485,7 @@ static void atkD4_trywish(void) } } -static void atkD5_trysetroots(void) // ingrain +static void Cmd_trysetroots(void) // ingrain { if (gStatuses3[gBattlerAttacker] & STATUS3_ROOTED) { @@ -9497,7 +9498,7 @@ static void atkD5_trysetroots(void) // ingrain } } -static void atkD6_doubledamagedealtifdamaged(void) +static void Cmd_doubledamagedealtifdamaged(void) { if ((gProtectStructs[gBattlerAttacker].physicalDmg && gProtectStructs[gBattlerAttacker].physicalBattlerId == gBattlerTarget) @@ -9510,7 +9511,7 @@ static void atkD6_doubledamagedealtifdamaged(void) gBattlescriptCurrInstr++; } -static void atkD7_setyawn(void) +static void Cmd_setyawn(void) { if (gStatuses3[gBattlerTarget] & STATUS3_YAWN || gBattleMons[gBattlerTarget].status1 & STATUS1_ANY) @@ -9524,7 +9525,7 @@ static void atkD7_setyawn(void) } } -static void atkD8_setdamagetohealthdifference(void) +static void Cmd_setdamagetohealthdifference(void) { if (gBattleMons[gBattlerTarget].hp <= gBattleMons[gBattlerAttacker].hp) { @@ -9537,7 +9538,7 @@ static void atkD8_setdamagetohealthdifference(void) } } -static void atkD9_scaledamagebyhealthratio(void) +static void Cmd_scaledamagebyhealthratio(void) { if (gDynamicBasePower == 0) { @@ -9549,7 +9550,7 @@ static void atkD9_scaledamagebyhealthratio(void) gBattlescriptCurrInstr++; } -static void atkDA_tryswapabilities(void) // skill swap +static void Cmd_tryswapabilities(void) // skill swap { if ((gBattleMons[gBattlerAttacker].ability == 0 && gBattleMons[gBattlerTarget].ability == 0) @@ -9569,7 +9570,7 @@ static void atkDA_tryswapabilities(void) // skill swap } } -static void atkDB_tryimprison(void) +static void Cmd_tryimprison(void) { if ((gStatuses3[gBattlerAttacker] & STATUS3_IMPRISONED_OTHERS)) { @@ -9611,7 +9612,7 @@ static void atkDB_tryimprison(void) } } -static void atkDC_trysetgrudge(void) +static void Cmd_trysetgrudge(void) { if (gStatuses3[gBattlerAttacker] & STATUS3_GRUDGE) { @@ -9624,7 +9625,7 @@ static void atkDC_trysetgrudge(void) } } -static void atkDD_weightdamagecalculation(void) +static void Cmd_weightdamagecalculation(void) { s32 i; for (i = 0; sWeightToDamageTable[i] != 0xFFFF; i += 2) @@ -9641,7 +9642,7 @@ static void atkDD_weightdamagecalculation(void) gBattlescriptCurrInstr++; } -static void atkDE_assistattackselect(void) +static void Cmd_assistattackselect(void) { s32 chooseableMovesNo = 0; struct Pokemon* party; @@ -9694,7 +9695,7 @@ static void atkDE_assistattackselect(void) } } -static void atkDF_trysetmagiccoat(void) +static void Cmd_trysetmagiccoat(void) { gBattlerTarget = gBattlerAttacker; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; @@ -9709,7 +9710,7 @@ static void atkDF_trysetmagiccoat(void) } } -static void atkE0_trysetsnatch(void) // snatch +static void Cmd_trysetsnatch(void) // snatch { gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn @@ -9723,7 +9724,7 @@ static void atkE0_trysetsnatch(void) // snatch } } -static void atkE1_trygetintimidatetarget(void) +static void Cmd_trygetintimidatetarget(void) { u8 side; @@ -9746,7 +9747,7 @@ static void atkE1_trygetintimidatetarget(void) gBattlescriptCurrInstr += 5; } -static void atkE2_switchoutabilities(void) +static void Cmd_switchoutabilities(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); @@ -9762,7 +9763,7 @@ static void atkE2_switchoutabilities(void) gBattlescriptCurrInstr += 2; } -static void atkE3_jumpifhasnohp(void) +static void Cmd_jumpifhasnohp(void) { gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); @@ -9772,7 +9773,7 @@ static void atkE3_jumpifhasnohp(void) gBattlescriptCurrInstr += 6; } -static void atkE4_getsecretpowereffect(void) +static void Cmd_getsecretpowereffect(void) { switch (gBattleTerrain) { @@ -9807,7 +9808,7 @@ static void atkE4_getsecretpowereffect(void) gBattlescriptCurrInstr++; } -static void atkE5_pickup(void) +static void Cmd_pickup(void) { s32 i; u16 species, heldItem; @@ -9884,7 +9885,7 @@ static void atkE5_pickup(void) gBattlescriptCurrInstr++; } -static void atkE6_docastformchangeanimation(void) +static void Cmd_docastformchangeanimation(void) { gActiveBattler = gBattleScripting.battler; @@ -9897,7 +9898,7 @@ static void atkE6_docastformchangeanimation(void) gBattlescriptCurrInstr++; } -static void atkE7_trycastformdatachange(void) +static void Cmd_trycastformdatachange(void) { u8 form; @@ -9910,7 +9911,7 @@ static void atkE7_trycastformdatachange(void) } } -static void atkE8_settypebasedhalvers(void) // water and mud sport +static void Cmd_settypebasedhalvers(void) // water and mud sport { bool8 worked = FALSE; @@ -9939,7 +9940,7 @@ static void atkE8_settypebasedhalvers(void) // water and mud sport gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } -static void atkE9_setweatherballtype(void) +static void Cmd_setweatherballtype(void) { if (WEATHER_HAS_EFFECT) { @@ -9960,7 +9961,7 @@ static void atkE9_setweatherballtype(void) gBattlescriptCurrInstr++; } -static void atkEA_tryrecycleitem(void) +static void Cmd_tryrecycleitem(void) { u16 *usedHeldItem; @@ -9983,7 +9984,7 @@ static void atkEA_tryrecycleitem(void) } } -static void atkEB_settypetoterrain(void) +static void Cmd_settypetoterrain(void) { if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, sTerrainToType[gBattleTerrain])) { @@ -9998,7 +9999,7 @@ static void atkEB_settypetoterrain(void) } } -static void atkEC_pursuitrelated(void) +static void Cmd_pursuitrelated(void) { gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) ^ BIT_FLANK); @@ -10020,7 +10021,7 @@ static void atkEC_pursuitrelated(void) } } -static void atkEF_snatchsetbattlers(void) +static void Cmd_snatchsetbattlers(void) { gEffectBattler = gBattlerAttacker; @@ -10033,7 +10034,7 @@ static void atkEF_snatchsetbattlers(void) gBattlescriptCurrInstr++; } -static void atkEE_removelightscreenreflect(void) // brick break +static void Cmd_removelightscreenreflect(void) // brick break { u8 opposingSide = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE; @@ -10055,7 +10056,7 @@ static void atkEE_removelightscreenreflect(void) // brick break gBattlescriptCurrInstr++; } -static void atkEF_handleballthrow(void) +static void Cmd_handleballthrow(void) { u8 ballMultiplier = 0; @@ -10203,7 +10204,7 @@ static void atkEF_handleballthrow(void) } } -static void atkF0_givecaughtmon(void) +static void Cmd_givecaughtmon(void) { if (GiveMonToPlayer(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]]) != MON_GIVEN_TO_PARTY) { @@ -10232,7 +10233,7 @@ static void atkF0_givecaughtmon(void) gBattlescriptCurrInstr++; } -static void atkF1_trysetcaughtmondexflags(void) +static void Cmd_trysetcaughtmondexflags(void) { u16 species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL); u32 personality = GetMonData(&gEnemyParty[0], MON_DATA_PERSONALITY, NULL); @@ -10248,7 +10249,7 @@ static void atkF1_trysetcaughtmondexflags(void) } } -static void atkF2_displaydexinfo(void) +static void Cmd_displaydexinfo(void) { u16 species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL); @@ -10278,7 +10279,7 @@ static void atkF2_displaydexinfo(void) } break; case 3: - sub_80356D0(); + InitBattleBgsVideo(); LoadBattleTextboxAndBackground(); gBattle_BG3_X = 0x100; gBattleCommunication[0]++; @@ -10367,7 +10368,7 @@ void BattleDestroyYesNoCursorAt(u8 cursorPosition) CopyBgTilemapBufferToVram(0); } -static void atkF3_trygivecaughtmonnick(void) +static void Cmd_trygivecaughtmonnick(void) { switch (gBattleCommunication[MULTIUSE_STATE]) { @@ -10443,30 +10444,30 @@ static void atkF3_trygivecaughtmonnick(void) } } -static void atkF4_subattackerhpbydmg(void) +static void Cmd_subattackerhpbydmg(void) { gBattleMons[gBattlerAttacker].hp -= gBattleMoveDamage; gBattlescriptCurrInstr++; } -static void atkF5_removeattackerstatus1(void) +static void Cmd_removeattackerstatus1(void) { gBattleMons[gBattlerAttacker].status1 = 0; gBattlescriptCurrInstr++; } -static void atkF6_finishaction(void) +static void Cmd_finishaction(void) { gCurrentActionFuncId = B_ACTION_FINISHED; } -static void atkF7_finishturn(void) +static void Cmd_finishturn(void) { gCurrentActionFuncId = B_ACTION_FINISHED; gCurrentTurnActionNumber = gBattlersCount; } -static void atkF8_trainerslideout(void) +static void Cmd_trainerslideout(void) { gActiveBattler = GetBattlerAtPosition(gBattlescriptCurrInstr[1]); BtlController_EmitTrainerSlideBack(0); diff --git a/src/battle_setup.c b/src/battle_setup.c index f166c7375..b98b5df06 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1,25 +1,18 @@ #include "global.h" -#include "constants/trainers.h" #include "battle.h" -#include "constants/battle_setup.h" #include "battle_setup.h" #include "battle_transition.h" #include "main.h" #include "task.h" #include "safari_zone.h" #include "script.h" -#include "constants/game_stat.h" #include "event_data.h" -#include "constants/species.h" -#include "constants/songs.h" #include "metatile_behavior.h" -#include "constants/maps.h" #include "field_player_avatar.h" #include "fieldmap.h" #include "random.h" #include "starter_choose.h" #include "script_pokemon_80F8.h" -#include "constants/items.h" #include "palette.h" #include "window.h" #include "event_object_movement.h" @@ -42,10 +35,18 @@ #include "fldeff_misc.h" #include "field_control_avatar.h" #include "mirage_tower.h" -#include "constants/map_types.h" -#include "constants/battle_frontier.h" #include "field_screen_effect.h" #include "data.h" +#include "constants/battle_frontier.h" +#include "constants/battle_setup.h" +#include "constants/game_stat.h" +#include "constants/items.h" +#include "constants/songs.h" +#include "constants/map_types.h" +#include "constants/maps.h" +#include "constants/species.h" +#include "constants/trainers.h" +#include "constants/trainer_hill.h" enum { @@ -897,7 +898,7 @@ static void CB2_GiveStarter(void) *GetVarPointer(VAR_STARTER_MON) = gSpecialVar_Result; starterMon = GetStarterPokemon(gSpecialVar_Result); - ScriptGiveMon(starterMon, 5, 0, 0, 0, 0); + ScriptGiveMon(starterMon, 5, ITEM_NONE, 0, 0, 0); ResetTasks(); PlayBattleBGM(); SetMainCallback2(CB2_StartFirstBattle); @@ -1140,7 +1141,7 @@ const u8 *BattleSetup_ConfigureTrainerBattle(const u8 *data) case TRAINER_BATTLE_SET_TRAINER_B: TrainerBattleLoadArgs(sTrainerBOrdinaryBattleParams, data); return NULL; - case TRAINER_BATTLE_12: + case TRAINER_BATTLE_HILL: if (gApproachingTrainerId == 0) { TrainerBattleLoadArgs(sOrdinaryBattleParams, data); @@ -1288,7 +1289,7 @@ void BattleSetup_StartTrainerBattle(void) sNoOfPossibleTrainerRetScripts = gNoOfApproachingTrainers; gNoOfApproachingTrainers = 0; sShouldCheckTrainerBScript = FALSE; - gUnknown_03006080 = 0; + gWhichTrainerToFaceAfterBattle = 0; gMain.savedCallback = CB2_EndTrainerBattle; if (InBattlePyramid() || InTrainerHillChallenge()) @@ -1364,9 +1365,9 @@ void ShowTrainerIntroSpeech(void) else if (InTrainerHillChallenge()) { if (gNoOfApproachingTrainers == 0 || gNoOfApproachingTrainers == 1) - CopyTrainerHillTrainerText(2, LocalIdToHillTrainerId(gSpecialVar_LastTalked)); + CopyTrainerHillTrainerText(TRAINER_HILL_TEXT_INTRO, LocalIdToHillTrainerId(gSpecialVar_LastTalked)); else - CopyTrainerHillTrainerText(2, LocalIdToHillTrainerId(gEventObjects[gApproachingTrainers[gApproachingTrainerId].eventObjectId].localId)); + CopyTrainerHillTrainerText(TRAINER_HILL_TEXT_INTRO, LocalIdToHillTrainerId(gEventObjects[gApproachingTrainers[gApproachingTrainerId].eventObjectId].localId)); sub_80982B8(); } @@ -1391,7 +1392,7 @@ const u8 *BattleSetup_GetTrainerPostBattleScript(void) sShouldCheckTrainerBScript = FALSE; if (sTrainerBBattleScriptRetAddr != NULL) { - gUnknown_03006080 = 1; + gWhichTrainerToFaceAfterBattle = 1; return sTrainerBBattleScriptRetAddr; } } @@ -1399,7 +1400,7 @@ const u8 *BattleSetup_GetTrainerPostBattleScript(void) { if (sTrainerABattleScriptRetAddr != NULL) { - gUnknown_03006080 = 0; + gWhichTrainerToFaceAfterBattle = 0; return sTrainerABattleScriptRetAddr; } } diff --git a/src/battle_tower.c b/src/battle_tower.c index c55180965..aa4ca84e6 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -24,15 +24,17 @@ #include "tv.h" #include "battle_factory.h" #include "constants/battle_frontier.h" +#include "constants/battle_tower.h" #include "constants/items.h" #include "constants/trainers.h" #include "constants/event_objects.h" #include "constants/moves.h" #include "constants/species.h" #include "constants/easy_chat.h" +#include "constants/tv.h" -extern const u8 MossdeepCity_SpaceCenter_2F_EventScript_224157[]; -extern const u8 MossdeepCity_SpaceCenter_2F_EventScript_224166[]; +extern const u8 MossdeepCity_SpaceCenter_2F_EventScript_MaxieTrainer[]; +extern const u8 MossdeepCity_SpaceCenter_2F_EventScript_TabithaTrainer[]; // EWRAM vars. EWRAM_DATA const struct BattleFrontierTrainer *gFacilityTrainers = NULL; @@ -51,7 +53,7 @@ static void AwardBattleTowerRibbons(void); static void SaveBattleTowerProgress(void); static void sub_8163914(void); static void nullsub_61(void); -static void SpriteCB_Null6(void); +static void nullsub_116(void); static void sub_81642A0(void); static void sub_8164828(void); static void sub_8164B74(void); @@ -1050,24 +1052,24 @@ struct #include "data/battle_frontier/battle_tent.h" -static void (* const gUnknown_085DF96C[])(void) = -{ - sub_8161F94, - sub_8162054, - sub_81620F4, - ChooseNextBattleTowerTrainer, - sub_81621C0, - AwardBattleTowerRibbons, - SaveBattleTowerProgress, - sub_8163914, - nullsub_61, - SpriteCB_Null6, - sub_81642A0, - sub_8164828, - sub_8164B74, - sub_8164DCC, - sub_8164DE4, - sub_8164E04, +static void (* const sBattleTowerFuncs[])(void) = +{ + [BATTLE_TOWER_FUNC_0] = sub_8161F94, + [BATTLE_TOWER_FUNC_1] = sub_8162054, + [BATTLE_TOWER_FUNC_2] = sub_81620F4, + [BATTLE_TOWER_FUNC_CHOOSE_TRAINER] = ChooseNextBattleTowerTrainer, + [BATTLE_TOWER_FUNC_4] = sub_81621C0, + [BATTLE_TOWER_FUNC_GIVE_RIBBONS] = AwardBattleTowerRibbons, + [BATTLE_TOWER_FUNC_SAVE] = SaveBattleTowerProgress, + [BATTLE_TOWER_FUNC_7] = sub_8163914, + [BATTLE_TOWER_FUNC_NOP] = nullsub_61, + [BATTLE_TOWER_FUNC_NOP2] = nullsub_116, + [BATTLE_TOWER_FUNC_10] = sub_81642A0, + [BATTLE_TOWER_FUNC_11] = sub_8164828, + [BATTLE_TOWER_FUNC_12] = sub_8164B74, + [BATTLE_TOWER_FUNC_13] = sub_8164DCC, + [BATTLE_TOWER_FUNC_14] = sub_8164DE4, + [BATTLE_TOWER_FUNC_15] = sub_8164E04, }; static const u32 gUnknown_085DF9AC[][2] = @@ -1144,9 +1146,9 @@ static const u16 gUnknown_085DFA52[] = }; // code -void sub_8161F74(void) +void CallBattleTowerFunc(void) { - gUnknown_085DF96C[gSpecialVar_0x8004](); + sBattleTowerFuncs[gSpecialVar_0x8004](); } static void sub_8161F94(void) @@ -1270,10 +1272,10 @@ static bool8 ChooseSpecialBattleTowerTrainer(void) if (battleMode == FRONTIER_MODE_SINGLES) { ValidateApprenticesChecksums(); - for (i = 0; i < 4; i++) + for (i = 0; i < APPRENTICE_COUNT; i++) { if (gSaveBlock2Ptr->apprentices[i].lvlMode != 0 - && gUnknown_085DF9EC[gSaveBlock2Ptr->apprentices[i].field_1] == winStreak + && gUnknown_085DF9EC[gSaveBlock2Ptr->apprentices[i].numQuestions] == winStreak && gSaveBlock2Ptr->apprentices[i].lvlMode - 1 == lvlMode) { trainerIds[idsCount] = i + TRAINER_RECORD_MIXING_APPRENTICE; @@ -1998,7 +2000,7 @@ static void Unused_CreateApprenticeMons(u16 trainerId, u8 firstMonId) u8 fixedIV = 0; struct Apprentice *apprentice = &gSaveBlock2Ptr->apprentices[0]; - if (apprentice->field_1 < 5) + if (apprentice->numQuestions < 5) fixedIV = 6; else fixedIV = 9; @@ -2176,7 +2178,7 @@ static void sub_8163914(void) else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) FrontierSpeechToString(gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].greeting); else - CopyFriendsApprenticeChallengeText(trainerId - TRAINER_RECORD_MIXING_APPRENTICE); + BufferApprenticeChallengeText(trainerId - TRAINER_RECORD_MIXING_APPRENTICE); } static void HandleSpecialTrainerBattleEnd(void) @@ -2349,9 +2351,9 @@ void DoSpecialTrainerBattle(void) gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_DOUBLE | BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER; FillPartnerParty(TRAINER_STEVEN_PARTNER); gApproachingTrainerId = 0; - BattleSetup_ConfigureTrainerBattle(MossdeepCity_SpaceCenter_2F_EventScript_224157 + 1); + BattleSetup_ConfigureTrainerBattle(MossdeepCity_SpaceCenter_2F_EventScript_MaxieTrainer + 1); gApproachingTrainerId = 1; - BattleSetup_ConfigureTrainerBattle(MossdeepCity_SpaceCenter_2F_EventScript_224166 + 1); + BattleSetup_ConfigureTrainerBattle(MossdeepCity_SpaceCenter_2F_EventScript_TabithaTrainer + 1); gPartnerTrainerId = TRAINER_STEVEN_PARTNER; CreateTask(Task_StartBattleAfterTransition, 1); PlayMapChosenOrBattleBGM(0); @@ -2437,7 +2439,7 @@ static void nullsub_61(void) } -static void SpriteCB_Null6(void) +static void nullsub_116(void) { } @@ -2567,10 +2569,10 @@ static void sub_81642A0(void) r10 = 0; ValidateApprenticesChecksums(); - for (i = 0; i < 4; i++) + for (i = 0; i < APPRENTICE_COUNT; i++) { if (gSaveBlock2Ptr->apprentices[i].lvlMode != 0 - && gUnknown_085DF9EC[gSaveBlock2Ptr->apprentices[i].field_1] / 7 <= challengeNum + && gUnknown_085DF9EC[gSaveBlock2Ptr->apprentices[i].numQuestions] / 7 <= challengeNum && gSaveBlock2Ptr->apprentices[i].lvlMode - 1 == lvlMode) { k = 0; @@ -3026,9 +3028,9 @@ static void AwardBattleTowerRibbons(void) ribbons[i] = prevBest; } } - if (ribbons[0].count > 4) + if (ribbons[0].count > NUM_CUTIES_RIBBONS) { - sub_80EE4DC(&gSaveBlock1Ptr->playerParty[ribbons[0].partyIndex], ribbonType); + TryPutSpotTheCutiesOnAir(&gSaveBlock1Ptr->playerParty[ribbons[0].partyIndex], ribbonType); } } } @@ -3191,7 +3193,7 @@ static void FillPartnerParty(u16 trainerId) sStevenMons[i].fixedIV, TRUE, i, // BUG: personality was stored in the 'j' variable. As a result, Steven's pokemon do not have the intended natures. OT_ID_PRESET, STEVEN_OTID); - for (j = 0; j < 6; j++) + for (j = 0; j < PARTY_SIZE; j++) SetMonData(&gPlayerParty[3 + i], MON_DATA_HP_EV + j, &sStevenMons[i].evs[j]); for (j = 0; j < MAX_MON_MOVES; j++) SetMonMoveSlot(&gPlayerParty[3 + i], sStevenMons[i].moves[j], j); @@ -3391,7 +3393,7 @@ static void ValidateApprenticesChecksums(void) { s32 i, j; - for (i = 0; i < 4; i++) + for (i = 0; i < APPRENTICE_COUNT; i++) { u32 *data = (u32*) &gSaveBlock2Ptr->apprentices[i]; u32 checksum = 0; diff --git a/src/battle_util.c b/src/battle_util.c index 4d3ad3c7c..8587bb88e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2084,7 +2084,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA } } break; - case ABILITYEFFECT_MOVE_END: // Think contact abilities. + case ABILITYEFFECT_ON_DAMAGE: // Contact abilities and Color Change switch (gLastUsedAbility) { case ABILITY_COLOR_CHANGE: diff --git a/src/battle_util2.c b/src/battle_util2.c index ce2153b2d..fd0dda76b 100644 --- a/src/battle_util2.c +++ b/src/battle_util2.c @@ -102,7 +102,7 @@ void AdjustFriendshipOnBattleFaint(u8 battlerId) } } -void sub_80571DC(u8 battlerId, u8 arg1) +void SwitchPartyOrderInGameMulti(u8 battlerId, u8 arg1) { if (GetBattlerSide(battlerId) != B_SIDE_OPPONENT) { @@ -110,13 +110,13 @@ void sub_80571DC(u8 battlerId, u8 arg1) // gBattleStruct->field_60[0][i] - for (i = 0; i < 3; i++) - gUnknown_0203CF00[i] = *(0 * 3 + i + (u8*)(gBattleStruct->field_60)); + for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++) + gBattlePartyCurrentOrder[i] = *(0 * 3 + i + (u8*)(gBattleStruct->field_60)); - sub_81B8FB0(pokemon_order_func(gBattlerPartyIndexes[battlerId]), pokemon_order_func(arg1)); + SwitchPartyMonSlots(GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[battlerId]), GetPartyIdFromBattlePartyId(arg1)); - for (i = 0; i < 3; i++) - *(0 * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; + for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++) + *(0 * 3 + i + (u8*)(gBattleStruct->field_60)) = gBattlePartyCurrentOrder[i]; } } diff --git a/src/berry_blender.c b/src/berry_blender.c index b4874c3b1..72f3056d3 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -1030,7 +1030,7 @@ static void sub_807FAC8(void) UnsetBgTilemapBuffer(2); UnsetBgTilemapBuffer(1); SetVBlankCallback(NULL); - sub_81AABF0(sub_807FFA4); + ChooseBerrySetCallback(sub_807FFA4); sBerryBlenderData->mainState = 0; } @@ -1109,7 +1109,7 @@ static void Blender_SetPlayerNamesLocal(u8 opponentsNum) sBerryBlenderData->playersNo = 2; StringCopy(gLinkPlayers[0].name, gSaveBlock2Ptr->playerName); - if (!FlagGet(FLAG_HIDE_LILYCOVE_CONTEST_HALL_BLEND_MASTER_ONLOOKERS)) + if (!FlagGet(FLAG_HIDE_LILYCOVE_CONTEST_HALL_BLEND_MASTER)) StringCopy(gLinkPlayers[1].name, sBlenderOpponentsNames[BLENDER_MASTER]); else StringCopy(gLinkPlayers[1].name, sBlenderOpponentsNames[BLENDER_MISTER]); @@ -1432,7 +1432,7 @@ static void Blender_SetOpponentsBerryData(u16 playerBerryItemId, u8 playersNum, { opponentBerryId = sOpponentBerrySets[opponentSetId][i]; var = playerBerryItemId - 163; - if (!FlagGet(FLAG_HIDE_LILYCOVE_CONTEST_HALL_BLEND_MASTER_ONLOOKERS) && gSpecialVar_0x8004 == 1) + if (!FlagGet(FLAG_HIDE_LILYCOVE_CONTEST_HALL_BLEND_MASTER) && gSpecialVar_0x8004 == 1) { opponentSetId %= 5; opponentBerryId = sSpecialOpponentBerrySets[opponentSetId]; @@ -1632,7 +1632,7 @@ static void sub_80808D4(void) if (gSpecialVar_0x8004 == 1) { - if (!FlagGet(FLAG_HIDE_LILYCOVE_CONTEST_HALL_BLEND_MASTER_ONLOOKERS)) + if (!FlagGet(FLAG_HIDE_LILYCOVE_CONTEST_HALL_BLEND_MASTER)) sBerryBlenderData->field_120[0] = CreateTask(sub_8081224, 10); else sBerryBlenderData->field_120[0] = CreateTask(sUnknown_083399EC[0], 10); diff --git a/src/berry_crush.c b/src/berry_crush.c index 8b4c7a545..74a71f089 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -249,7 +249,7 @@ static void sub_8020D8C(void) void sub_8020E1C(void) { DestroyTask(gUnknown_02022C90->unkA); - sub_81AABF0(sub_8020D8C); + ChooseBerrySetCallback(sub_8020D8C); } static void sub_8020E3C(void) diff --git a/src/cable_club.c b/src/cable_club.c index 1375789c3..b1675030b 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -203,7 +203,7 @@ static void sub_80B2634(u8 taskId) if (data[0] == 0) { OpenLinkTimed(); - sub_800AB98(); + ResetLinkPlayerCount(); ResetLinkPlayers(); data[5] = AddWindow(&gUnknown_08550594); } @@ -678,23 +678,23 @@ static void sub_80B2EE4(u8 taskId) } } -void sub_80B2FD8(void) +void TryBerryBlenderLinkup(void) { - gLinkType = LINKTYPE_0x4411; + gLinkType = LINKTYPE_BERRY_BLENDER_SETUP; gBattleTypeFlags = 0; sub_80B236C(2, 4); } -void sub_80B3000(void) +void TryContestGModeLinkup(void) { - gLinkType = LINKTYPE_0x6601; + gLinkType = LINKTYPE_CONTEST_GMODE; gBattleTypeFlags = 0; sub_80B236C(4, 4); } -void sub_80B3028(void) +void TryContestEModeLinkup(void) { - gLinkType = LINKTYPE_0x6602; + gLinkType = LINKTYPE_CONTEST_EMODE; gBattleTypeFlags = 0; sub_80B236C(2, 4); } @@ -970,7 +970,7 @@ void sub_80B360C(void) Overworld_ResetMapMusic(); LoadPlayerParty(); SavePlayerBag(); - sub_813BF10(); + UpdateTrainerFansAfterLinkBattle(); if (gSpecialVar_0x8004 == USING_SINGLE_BATTLE || gSpecialVar_0x8004 == USING_DOUBLE_BATTLE) { diff --git a/src/coins.c b/src/coins.c index b838c303e..1b9656abd 100644 --- a/src/coins.c +++ b/src/coins.c @@ -6,8 +6,7 @@ #include "string_util.h" #include "menu.h" #include "international_string_util.h" - -#define MAX_COINS 9999 +#include "constants/coins.h" EWRAM_DATA u8 sCoinsWindowId = 0; diff --git a/src/contest.c b/src/contest.c index a3914cf30..4830e05d5 100644 --- a/src/contest.c +++ b/src/contest.c @@ -219,15 +219,15 @@ static void sub_80DF9E0(u8 *, s32); static void SwapMoveDescAndContestTilemaps(void); // EWRAM vars. -EWRAM_DATA struct ContestPokemon gContestMons[4] = {0}; -EWRAM_DATA s16 gContestMonConditions[4] = {0}; -EWRAM_DATA s16 gUnknown_02039F08[4] = {0}; -EWRAM_DATA s16 gUnknown_02039F10[4] = {0}; -EWRAM_DATA s16 gUnknown_02039F18[4] = {0}; -EWRAM_DATA u8 gContestFinalStandings[4] = {0}; +EWRAM_DATA struct ContestPokemon gContestMons[CONTESTANT_COUNT] = {0}; +EWRAM_DATA s16 gContestMonConditions[CONTESTANT_COUNT] = {0}; +EWRAM_DATA s16 gUnknown_02039F08[CONTESTANT_COUNT] = {0}; +EWRAM_DATA s16 gUnknown_02039F10[CONTESTANT_COUNT] = {0}; +EWRAM_DATA s16 gUnknown_02039F18[CONTESTANT_COUNT] = {0}; +EWRAM_DATA u8 gContestFinalStandings[CONTESTANT_COUNT] = {0}; EWRAM_DATA u8 gContestMonPartyIndex = 0; EWRAM_DATA u8 gContestPlayerMonIndex = 0; -EWRAM_DATA u8 gContestantTurnOrder[4] = {0}; +EWRAM_DATA u8 gContestantTurnOrder[CONTESTANT_COUNT] = {0}; EWRAM_DATA u8 gLinkContestFlags = 0; // Bit 0: Is a link contest // Bit 1: Link contest uses wireless adapter @@ -238,7 +238,7 @@ EWRAM_DATA u8 gNumLinkContestPlayers = 0; EWRAM_DATA u8 gHighestRibbonRank = 0; EWRAM_DATA struct ContestResources *gContestResources = NULL; EWRAM_DATA u8 sContestBgCopyFlags = 0; -EWRAM_DATA struct ContestWinner gUnknown_02039F3C = {0}; +EWRAM_DATA struct ContestWinner gCurContestWinner = {0}; EWRAM_DATA u8 gUnknown_02039F5C = 0; EWRAM_DATA u8 gUnknown_02039F5D = 0; @@ -246,29 +246,8 @@ EWRAM_DATA u8 gUnknown_02039F5D = 0; u32 gContestRngValue; extern const u8 gText_LinkStandby4[]; -extern const u8 gText_0827D55A[]; -extern const u8 gText_0827E793[]; -extern const u8 gText_0827E32E[]; -extern const u8 gText_0827E35B[]; -extern const u8 gText_0827E38D[]; -extern const u8 gText_0827E2FE[]; -extern const u8 gText_RepeatedAppeal[]; -extern const u8 gText_0827E73C[]; -extern const u8 gText_0827E717[]; -extern const u8 gText_0827E76A[]; -extern const u8 gText_0827E7EA[]; -extern const u8 gText_0827E817[]; -extern const u8 gText_0827E58A[]; -extern const u8 gText_0827D56F[]; -extern const u8 gText_0827D597[]; -extern const u8 gText_Contest_Shyness[]; -extern const u8 gText_Contest_Anxiety[]; -extern const u8 gText_Contest_Laziness[]; -extern const u8 gText_Contest_Hesitancy[]; -extern const u8 gText_Contest_Fear[]; extern const u8 gText_BDot[]; extern const u8 gText_CDot[]; -extern const u8 *const gUnknown_08587E10[]; extern void (*const gContestEffectFuncs[])(void); static const u8 gUnknown_08587A6C[] = @@ -1345,9 +1324,9 @@ static void sub_80D833C(u8 taskId) DmaCopy32Defvars(3, gPlttBufferUnfaded, eUnknownHeap1A004.unk18204, PLTT_BUFFER_SIZE * 2); ConvertIntToDecimalStringN(gStringVar1, eContest.turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1); if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex)) - StringCopy(gDisplayedStringBattle, gText_0827D507); + StringCopy(gDisplayedStringBattle, gText_AppealNumWhichMoveWillBePlayed); else - StringCopy(gDisplayedStringBattle, gText_0827D531); + StringCopy(gDisplayedStringBattle, gText_AppealNumButItCantParticipate); ContestClearGeneralTextWindow(); StringExpandPlaceholders(gStringVar4, gDisplayedStringBattle); Contest_StartTextPrinter(gStringVar4, TRUE); @@ -1443,9 +1422,9 @@ static void sub_80D8610(u8 taskId) sub_80DC490(FALSE); ConvertIntToDecimalStringN(gStringVar1, eContest.turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1); if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex)) - StringCopy(gDisplayedStringBattle, gText_0827D507); + StringCopy(gDisplayedStringBattle, gText_AppealNumWhichMoveWillBePlayed); else - StringCopy(gDisplayedStringBattle, gText_0827D531); + StringCopy(gDisplayedStringBattle, gText_AppealNumButItCantParticipate); ContestClearGeneralTextWindow(); StringExpandPlaceholders(gStringVar4, gDisplayedStringBattle); Contest_StartTextPrinter(gStringVar4, 0); @@ -1574,7 +1553,7 @@ static void sub_80D8A88(u8 taskId) { s32 i; - for (i = 0; i + gNumLinkContestPlayers < 4; i++) + for (i = 0; i + gNumLinkContestPlayers < CONTESTANT_COUNT; i++) { eContestantStatus[gNumLinkContestPlayers + i].currMove = GetChosenMove(gNumLinkContestPlayers + i); } @@ -1673,8 +1652,8 @@ static void sub_80D8B38(u8 taskId) if (eContestantStatus[r6].currMove < MOVES_COUNT) StringCopy(gStringVar2, gMoveNames[eContestantStatus[r6].currMove]); else - StringCopy(gStringVar2, gUnknown_08587F1C[eContestantStatus[r6].moveCategory]); - StringExpandPlaceholders(gStringVar4, gText_0827D55A); + StringCopy(gStringVar2, sInvalidContestMoveNames[eContestantStatus[r6].moveCategory]); + StringExpandPlaceholders(gStringVar4, gText_MonAppealedWithMove); Contest_StartTextPrinter(gStringVar4, 1); gTasks[taskId].data[0] = 6; } @@ -1735,7 +1714,7 @@ static void sub_80D8B38(u8 taskId) { if (eContestantStatus[r6].effectStringId2 != CONTEST_STRING_NONE) { - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (i != r6 && eContestantStatus[i].effectStringId != CONTEST_STRING_NONE) break; @@ -1838,10 +1817,10 @@ static void sub_80D8B38(u8 taskId) s32 r2 = 0; r3 = 0; - for (i = gTasks[taskId].data[1]; i < 4; i++) + for (i = gTasks[taskId].data[1]; i < CONTESTANT_COUNT; i++) { r3 = 0; - for (r2 = 0; r2 < 4; r2++) + for (r2 = 0; r2 < CONTESTANT_COUNT; r2++) { if (r2 != r6 && gContestantTurnOrder[r2] == i && eContestantStatus[r2].effectStringId != CONTEST_STRING_NONE) @@ -1906,7 +1885,7 @@ static void sub_80D8B38(u8 taskId) } return; case 30: - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (gContestantTurnOrder[i] == gTasks[taskId].data[1]) break; @@ -1932,7 +1911,7 @@ static void sub_80D8B38(u8 taskId) { ContestClearGeneralTextWindow(); StringCopy(gStringVar1, gContestMons[r6].nickname); - StringExpandPlaceholders(gStringVar4, gText_0827E793); + StringExpandPlaceholders(gStringVar4, gText_MonCantAppealNextTurn); Contest_StartTextPrinter(gStringVar4, 1); } gTasks[taskId].data[0] = 52; @@ -1953,11 +1932,11 @@ static void sub_80D8B38(u8 taskId) { ContestClearGeneralTextWindow(); if (r3 == 1) - Contest_StartTextPrinter(gText_0827E32E, TRUE); + Contest_StartTextPrinter(gText_AppealComboWentOverWell, TRUE); else if (r3 == 2) - Contest_StartTextPrinter(gText_0827E35B, TRUE); + Contest_StartTextPrinter(gText_AppealComboWentOverVeryWell, TRUE); else - Contest_StartTextPrinter(gText_0827E38D, TRUE); + Contest_StartTextPrinter(gText_AppealComboWentOverExcellently, TRUE); sub_80DD720(3); gTasks[taskId].data[10] = 0; gTasks[taskId].data[0] = 45; @@ -1966,7 +1945,7 @@ static void sub_80D8B38(u8 taskId) { ContestClearGeneralTextWindow(); StringCopy(gStringVar1, gContestMons[r6].nickname); - StringExpandPlaceholders(gStringVar4, gText_0827E2FE); + StringExpandPlaceholders(gStringVar4, gText_JudgeLookedAtMonExpectantly); Contest_StartTextPrinter(gStringVar4, 1); sub_80DD720(2); gTasks[taskId].data[10] = 0; @@ -2056,7 +2035,7 @@ static void sub_80D8B38(u8 taskId) } else { - StringCopy(gStringVar3, gUnknown_08587F08[gContestMoves[eContestantStatus[r6].currMove].contestCategory]); + StringCopy(gStringVar3, sContestConditions[gContestMoves[eContestantStatus[r6].currMove].contestCategory]); } if (r3 > 0) { @@ -2075,11 +2054,11 @@ static void sub_80D8B38(u8 taskId) else { if (r3 < 0) - StringExpandPlaceholders(gStringVar4, gText_0827E73C); + StringExpandPlaceholders(gStringVar4, gText_MonsXDidntGoOverWell); else if (r3 > 0 && eContest.applauseLevel <= 4) - StringExpandPlaceholders(gStringVar4, gText_0827E717); + StringExpandPlaceholders(gStringVar4, gText_MonsXWentOverGreat); else - StringExpandPlaceholders(gStringVar4, gText_0827E76A); + StringExpandPlaceholders(gStringVar4, gText_MonsXGotTheCrowdGoing); Contest_StartTextPrinter(gStringVar4, 1); gTasks[taskId].data[10] = 0; gTasks[taskId].data[11] = 0; @@ -2189,7 +2168,7 @@ static void sub_80D8B38(u8 taskId) StringCopy(gStringVar3, gContestMons[gContestResources->field_10->excitementFreezer].nickname); StringCopy(gStringVar1, gContestMons[r6].nickname); StringCopy(gStringVar2, gMoveNames[eContestantStatus[r6].currMove]); - StringExpandPlaceholders(gStringVar4, gText_0827E7EA); + StringExpandPlaceholders(gStringVar4, gText_CrowdContinuesToWatchMon); Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[0] = 58; return; @@ -2197,7 +2176,7 @@ static void sub_80D8B38(u8 taskId) if (!Contest_RunTextPrinters()) { ContestClearGeneralTextWindow(); - StringExpandPlaceholders(gStringVar4, gText_0827E817); + StringExpandPlaceholders(gStringVar4, gText_MonsMoveIsIgnored); Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[0] = 59; } @@ -2215,7 +2194,7 @@ static void sub_80D8B38(u8 taskId) sub_80DC9B4(r6); StringCopy(gStringVar1, gContestMons[r6].nickname); StringCopy(gStringVar2, gMoveNames[eContestantStatus[r6].currMove]); - StringExpandPlaceholders(gStringVar4, gText_0827E58A); + StringExpandPlaceholders(gStringVar4, gText_MonWasTooNervousToMove); Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[0] = 34; return; @@ -2259,7 +2238,7 @@ static void sub_80D8B38(u8 taskId) case 31: ContestClearGeneralTextWindow(); StringCopy(gStringVar1, gContestMons[r6].nickname); - StringExpandPlaceholders(gStringVar4, gText_0827D56F); + StringExpandPlaceholders(gStringVar4, gText_MonWasWatchingOthers); Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[0] = 32; return; @@ -2427,11 +2406,11 @@ static void sub_80DA3CC(u8 taskId) { if (gTasks[taskId].data[0] == 0) { - u8 r4 = eContestantStatus[gContestPlayerMonIndex].attentionLevel; + u8 attention = eContestantStatus[gContestPlayerMonIndex].attentionLevel; ContestClearGeneralTextWindow(); StringCopy(gStringVar1, gContestMons[gContestPlayerMonIndex].nickname); - StringExpandPlaceholders(gStringVar4, gUnknown_08587D90[r4]); + StringExpandPlaceholders(gStringVar4, sRoundResultTexts[attention]); Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[0]++; } @@ -2509,7 +2488,7 @@ static void sub_80DA5E8(u8 taskId) gBattle_BG0_Y = 0; gBattle_BG2_Y = 0; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) gUnknown_02039F10[i] = eContestantStatus[i].pointTotal; sub_80DBD18(); ContestClearGeneralTextWindow(); @@ -2522,7 +2501,7 @@ static void sub_80DA5E8(u8 taskId) ContestDebugPrintBitStrings(); } gContestRngValue = gRngValue; - StringExpandPlaceholders(gStringVar4, gText_0827D597); + StringExpandPlaceholders(gStringVar4, gText_AllOutOfAppealTime); Contest_StartTextPrinter(gStringVar4, TRUE); gTasks[taskId].data[2] = 0; gTasks[taskId].func = sub_80DA6B4; @@ -2786,9 +2765,9 @@ void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame) opponents[opponentsCount++] = i; } opponents[opponentsCount] = 0xFF; - for (i = 0; i < 4 - gNumLinkContestPlayers; i++) + for (i = 0; i < CONTESTANT_COUNT - gNumLinkContestPlayers; i++) { - u16 rnd = sub_80F903C() % opponentsCount; + u16 rnd = GetContestRand() % opponentsCount; gContestMons[gNumLinkContestPlayers + i] = gContestOpponents[opponents[rnd]]; sub_80DF9D4(gContestMons[gNumLinkContestPlayers + i].trainerName); @@ -2799,16 +2778,15 @@ void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame) } } -// GetContestAvailability? -u8 sub_80DAE0C(struct Pokemon *pkmn) +u8 GetContestEntryEligibility(struct Pokemon *pkmn) { u8 ribbon; - u8 retVal; + u8 eligibility; if (GetMonData(pkmn, MON_DATA_IS_EGG)) - return 3; + return CANT_ENTER_CONTEST_EGG; if (GetMonData(pkmn, MON_DATA_HP) == 0) - return 4; + return CANT_ENTER_CONTEST_FAINTED; switch (gSpecialVar_ContestCategory) { case CONTEST_CATEGORY_COOL: @@ -2827,19 +2805,19 @@ u8 sub_80DAE0C(struct Pokemon *pkmn) ribbon = GetMonData(pkmn, MON_DATA_TOUGH_RIBBON); break; default: - return 0; + return CANT_ENTER_CONTEST; } // Couldn't get this to match any other way. // Returns 2, 1, or 0 respectively if ribbon's rank is above, equal, or below // the current contest rank. if (ribbon > gSpecialVar_ContestRank) - retVal = 2; + eligibility = CAN_ENTER_CONTEST_HIGH_RANK; else if (ribbon >= gSpecialVar_ContestRank) - retVal = 1; + eligibility = CAN_ENTER_CONTEST_EQUAL_RANK; else - retVal = 0; - return retVal; + eligibility = CANT_ENTER_CONTEST; + return eligibility; } static void DrawContestantWindowText(void) @@ -2935,7 +2913,7 @@ void sub_80DB09C(u8 contestCategory) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) gContestMonConditions[i] = sub_80DAFE0(i, contestCategory); } @@ -3102,7 +3080,7 @@ static void sub_80DB584(void) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) sub_80DB4E0(eContestantStatus[i].currMove, i); } @@ -3213,7 +3191,7 @@ static void sub_80DB884(void) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) sub_80DB798(i); } @@ -3863,7 +3841,7 @@ static void sub_80DC864(void) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) sub_80DC87C(i); } @@ -4260,7 +4238,7 @@ static void sub_80DD080(u8 contestant) eContestResources8.jam2 = eContestResources8.jam; eContestResources8.contestant = contestant; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { eContestantStatus[i].jam = 0; eContestResources8.unnervedPokes[i] = 0; @@ -4382,7 +4360,7 @@ static void sub_80DD45C(u8 contestant, u8 stringId) StringCopy(gStringVar3, gText_Contest_Hesitancy); else StringCopy(gStringVar3, gText_Contest_Fear); - StringExpandPlaceholders(gStringVar4, gUnknown_08587E10[stringId]); + StringExpandPlaceholders(gStringVar4, sAppealResultTexts[stringId]); ContestClearGeneralTextWindow(); Contest_StartTextPrinter(gStringVar4, 1); } @@ -4797,7 +4775,7 @@ static void sub_80DE008(bool8 a) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (eContestantStatus[i].turnOrderMod != 0 && a) { @@ -5303,7 +5281,7 @@ void ResetContestLinkResults(void) gSaveBlock2Ptr->contestLinkResults[i][j] = 0; } -bool8 sub_80DEDA8(u8 a) +bool8 sub_80DEDA8(u8 rank) { s32 i; u8 r7 = Random() % 3; @@ -5313,7 +5291,7 @@ bool8 sub_80DEDA8(u8 a) if (gContestFinalStandings[i] == 0) break; } - if (a == 0xFF && i != gContestPlayerMonIndex) + if (rank == 0xFF && i != gContestPlayerMonIndex) return FALSE; switch (gSpecialVar_ContestCategory) { @@ -5333,9 +5311,9 @@ bool8 sub_80DEDA8(u8 a) r7 += 12; break; } - if (a != 0xFE) + if (rank != 0xFE) { - u8 r4 = sub_80DEFA8(a, 1); + u8 r4 = sub_80DEFA8(rank, 1); gSaveBlock1Ptr->contestWinners[r4].personality = gContestMons[i].personality; gSaveBlock1Ptr->contestWinners[r4].species = gContestMons[i].species; @@ -5343,44 +5321,44 @@ bool8 sub_80DEDA8(u8 a) StringCopy(gSaveBlock1Ptr->contestWinners[r4].monName, gContestMons[i].nickname); StringCopy(gSaveBlock1Ptr->contestWinners[r4].trainerName, gContestMons[i].trainerName); if(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) - gSaveBlock1Ptr->contestWinners[r4].contestRank = 4; + gSaveBlock1Ptr->contestWinners[r4].contestRank = CONTEST_RANK_LINK; else gSaveBlock1Ptr->contestWinners[r4].contestRank = gSpecialVar_ContestRank; - if (a != 0xFF) + if (rank != 0xFF) gSaveBlock1Ptr->contestWinners[r4].contestCategory = gSpecialVar_ContestCategory; else gSaveBlock1Ptr->contestWinners[r4].contestCategory = r7; } else { - gUnknown_02039F3C.personality = gContestMons[i].personality; - gUnknown_02039F3C.trainerId = gContestMons[i].otId; - gUnknown_02039F3C.species = gContestMons[i].species; - StringCopy(gUnknown_02039F3C.monName, gContestMons[i].nickname); - StringCopy(gUnknown_02039F3C.trainerName, gContestMons[i].trainerName); - gUnknown_02039F3C.contestCategory = r7; + gCurContestWinner.personality = gContestMons[i].personality; + gCurContestWinner.trainerId = gContestMons[i].otId; + gCurContestWinner.species = gContestMons[i].species; + StringCopy(gCurContestWinner.monName, gContestMons[i].nickname); + StringCopy(gCurContestWinner.trainerName, gContestMons[i].trainerName); + gCurContestWinner.contestCategory = r7; } return TRUE; } -u8 sub_80DEFA8(u8 a, u8 b) +u8 sub_80DEFA8(u8 rank, u8 b) { s32 i; - switch (a) + switch (rank) { - case 0: - case 1: - case 2: - case 3: + case CONTEST_RANK_NORMAL: + case CONTEST_RANK_SUPER: + case CONTEST_RANK_HYPER: + case CONTEST_RANK_MASTER: if (b != 0) { for (i = 5; i >= 1; i--) memcpy(&gSaveBlock1Ptr->contestWinners[i], &gSaveBlock1Ptr->contestWinners[i - 1], sizeof(struct ContestWinner)); } return 0; - default: + default: // CONTEST_RANK_LINK switch (gSpecialVar_ContestCategory) { case CONTEST_CATEGORY_COOL: @@ -5435,7 +5413,7 @@ static void sub_80DF080(u8 contestant) gContestResources->field_1c[contestant].unkC |= 8; } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (i != contestant && eContestantStatus[i].jam != 0) { @@ -5482,7 +5460,7 @@ static void sub_80DF250(void) r1 = 0; var_38 = 0; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (gContestFinalStandings[i] == 0) var_38 = i; @@ -5509,7 +5487,7 @@ static void sub_80DF250(void) r12 = FALSE; r8 = FALSE; - for (j = 0; j < 4; j++) + for (j = 0; j < CONTESTANT_COUNT; j++) { if (gContestMonConditions[i] > gContestMonConditions[j]) r12 = TRUE; diff --git a/src/contest_link_80F57C4.c b/src/contest_link_80F57C4.c index 54b2326d0..872aed14e 100644 --- a/src/contest_link_80F57C4.c +++ b/src/contest_link_80F57C4.c @@ -39,6 +39,7 @@ #include "constants/game_stat.h" #include "constants/rgb.h" #include "constants/songs.h" +#include "constants/tv.h" #include "constants/vars.h" #include "contest.h" @@ -265,7 +266,7 @@ void sub_80F5AE0(void) { int i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) sub_80F5A74(i); CopyBgTilemapBufferToVram(1); @@ -355,17 +356,17 @@ static void sub_80F5CE4(u8 taskId) InterviewAfter(); } - sub_813BADC(2); + TryGainNewFanFromCounter(2); sub_80DEDA8(gSpecialVar_ContestRank); sub_80DEDA8(0xFE); gUnknown_02039F5C = 1; gUnknown_02039F5D = sub_80DEFA8(0xFE, 0); - var = VarGet(VAR_LINK_CONTEST_ROOM_STATE); - VarSet(VAR_LINK_CONTEST_ROOM_STATE, 0); + var = VarGet(VAR_CONTEST_HALL_STATE); + VarSet(VAR_CONTEST_HALL_STATE, 0); SetContinueGameWarpStatusToDynamicWarp(); TrySavingData(SAVE_LINK); ClearContinueGameWarpStatus2(); - VarSet(VAR_LINK_CONTEST_ROOM_STATE, var); + VarSet(VAR_CONTEST_HALL_STATE, var); gTasks[taskId].data[0]++; break; case 1: @@ -410,7 +411,7 @@ static void sub_80F5CE4(u8 taskId) sub_80DEDA8(0xFE); gUnknown_02039F5C = 1; gUnknown_02039F5D = sub_80DEFA8(0xFE, 0); - sub_813BADC(2); + TryGainNewFanFromCounter(2); gTasks[taskId].func = sub_80F5F74; } } @@ -576,7 +577,7 @@ static void sub_80F6204(u8 taskId) } break; case 2: - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { newTaskId = CreateTask(sub_80F73DC, 10); gTasks[newTaskId].data[0] = gContestFinalStandings[i]; @@ -592,7 +593,7 @@ static void sub_80F6204(u8 taskId) gTasks[taskId].data[1] = 0; CreateTask(sub_80F74BC, 10); gTasks[taskId].data[0]++; - for (i = 0; i < 4 && gContestFinalStandings[i] != 0; i++) + for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++) ; sub_80F77E0(i, 14); @@ -603,7 +604,7 @@ static void sub_80F6204(u8 taskId) if (++gTasks[taskId].data[1] == 21) { gTasks[taskId].data[1] = 0; - for (i = 0; i < 4 && gContestFinalStandings[i] != 0; i++) + for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++) ; StringCopy(gStringVar1, gContestMons[i].trainerName); @@ -636,7 +637,7 @@ static void sub_80F6404(u8 taskId) case 0: gBattle_WIN0H = 0x00F0; gBattle_WIN0V = 0x5050; - for (i = 0; i < 4 && gContestFinalStandings[i] != 0; i++) + for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++) ; species = gContestMons[i].species; @@ -732,7 +733,7 @@ static void sub_80F66B4(u8 taskId) { if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)) { - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { nationalDexNum = SpeciesToNationalPokedexNum(gContestMons[i].species); GetSetPokedexFlag(nationalDexNum, FLAG_SET_SEEN); @@ -874,7 +875,7 @@ static void LoadAllContestMonIcons(u8 srcOffset, u8 useDmaNow) { int i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) sub_80F69B8(gContestMons[i].species, i, srcOffset, useDmaNow, gContestMons[i].personality); } @@ -882,7 +883,7 @@ static void sub_80F6A9C(void) { int i, species; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { species = gContestMons[i].species; LoadPalette(gMonIconPalettes[gMonIconPaletteIndices[GetIconSpecies(species, 0)]], i * 0x10 + 0xA0, 0x20); @@ -1423,48 +1424,48 @@ static void sub_80F71C8(void) CopyToBgTilemapBufferRect(2, gUnknown_08DC6498, 5, 1, 5, 2); x = 10; } - else if (gSpecialVar_ContestRank == 0) + else if (gSpecialVar_ContestRank == CONTEST_RANK_NORMAL) { CopyToBgTilemapBufferRect(2, gUnknown_08DC63F8, 5, 1, 10, 2); x = 15; } - else if (gSpecialVar_ContestRank == 1) + else if (gSpecialVar_ContestRank == CONTEST_RANK_SUPER) { CopyToBgTilemapBufferRect(2, gUnknown_08DC6420, 5, 1, 10, 2); x = 15; } - else if (gSpecialVar_ContestRank == 2) + else if (gSpecialVar_ContestRank == CONTEST_RANK_HYPER) { CopyToBgTilemapBufferRect(2, gUnknown_08DC6448, 5, 1, 10, 2); x = 15; } - else + else // CONTEST_RANK_MASTER { CopyToBgTilemapBufferRect(2, gUnknown_08DC6470, 5, 1, 10, 2); x = 15; } - if (gSpecialVar_ContestCategory == 0) + if (gSpecialVar_ContestCategory == CONTEST_CATEGORY_COOL) { palette = 0; CopyToBgTilemapBufferRect(2, gUnknown_08DC64AC, x, y, 5, 2); } - else if (gSpecialVar_ContestCategory == 1) + else if (gSpecialVar_ContestCategory == CONTEST_CATEGORY_BEAUTY) { palette = 1; CopyToBgTilemapBufferRect(2, gUnknown_08DC64C0, x, y, 5, 2); } - else if (gSpecialVar_ContestCategory == 2) + else if (gSpecialVar_ContestCategory == CONTEST_CATEGORY_CUTE) { palette = 2; CopyToBgTilemapBufferRect(2, gUnknown_08DC64D4, x, y, 5, 2); } - else if (gSpecialVar_ContestCategory == 3) + else if (gSpecialVar_ContestCategory == CONTEST_CATEGORY_SMART) { palette = 3; CopyToBgTilemapBufferRect(2, gUnknown_08DC64E8, x, y, 5, 2); } - else + else // CONTEST_CATEGORY_TOUGH { palette = 4; CopyToBgTilemapBufferRect(2, gUnknown_08DC64FC, x, y, 5, 2); @@ -1550,7 +1551,7 @@ static void sub_80F73DC(u8 taskId) static void sub_80F74BC(u8 taskId) { int i; - for (i = 0; i < 4 && gContestFinalStandings[i] != 0; i++) + for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++) ; CopyToBgTilemapBufferRect_ChangePalette(2, i * 0xC0 + 0x100 + gUnknown_0203A034->unkC[2], 0, i * 3 + 4, 32, 3, 9); @@ -1706,7 +1707,7 @@ static void sub_80F7880(void) } } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { r4 = (gContestMonConditions[i] * 1000) / abs(r2); if (r4 % 10 > 4) @@ -1933,50 +1934,52 @@ static void sub_80F7ED0(int windowId, u8 *str, int arg2) PutWindowTilemap(windowId); } -void sub_80F7F30(void) +void TryEnterContestMon(void) { - u8 result = sub_80DAE0C(&gPlayerParty[gContestMonPartyIndex]); - if (result) + u8 eligibility = GetContestEntryEligibility(&gPlayerParty[gContestMonPartyIndex]); + + // Nonzero eligibility can still be non-eligibile, if mon is fainted or egg + if (eligibility) { sub_80DAB8C(gSpecialVar_ContestCategory, gSpecialVar_ContestRank); sub_80DB09C(gSpecialVar_ContestCategory); } - gSpecialVar_Result = result; + gSpecialVar_Result = eligibility; } -u16 sub_80F7F7C(void) +u16 HasMonWonThisContestBefore(void) { - u16 result = 0; + u16 hasRankRibbon = FALSE; struct Pokemon *mon = &gPlayerParty[gContestMonPartyIndex]; switch (gSpecialVar_ContestCategory) { case CONTEST_CATEGORY_COOL: if (GetMonData(mon, MON_DATA_COOL_RIBBON) > gSpecialVar_ContestRank) - result = 1; + hasRankRibbon = TRUE; break; case CONTEST_CATEGORY_BEAUTY: if (GetMonData(mon, MON_DATA_BEAUTY_RIBBON) > gSpecialVar_ContestRank) - result = 1; + hasRankRibbon = TRUE; break; case CONTEST_CATEGORY_CUTE: if (GetMonData(mon, MON_DATA_CUTE_RIBBON) > gSpecialVar_ContestRank) - result = 1; + hasRankRibbon = TRUE; break; case CONTEST_CATEGORY_SMART: if (GetMonData(mon, MON_DATA_SMART_RIBBON) > gSpecialVar_ContestRank) - result = 1; + hasRankRibbon = TRUE; break; case CONTEST_CATEGORY_TOUGH: if (GetMonData(mon, MON_DATA_TOUGH_RIBBON) > gSpecialVar_ContestRank) - result = 1; + hasRankRibbon = TRUE; break; } - return result; + return hasRankRibbon; } -void sub_80F7FFC(void) +void GiveMonContestRibbon(void) { u8 ribbonData; @@ -1991,8 +1994,8 @@ void sub_80F7FFC(void) { ribbonData++; SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_COOL_RIBBON, &ribbonData); - if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > 4) - sub_80EE4DC(&gPlayerParty[gContestMonPartyIndex], MON_DATA_COOL_RIBBON); + if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > NUM_CUTIES_RIBBONS) + TryPutSpotTheCutiesOnAir(&gPlayerParty[gContestMonPartyIndex], MON_DATA_COOL_RIBBON); } break; case CONTEST_CATEGORY_BEAUTY: @@ -2001,8 +2004,8 @@ void sub_80F7FFC(void) { ribbonData++; SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_BEAUTY_RIBBON, &ribbonData); - if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > 4) - sub_80EE4DC(&gPlayerParty[gContestMonPartyIndex], MON_DATA_BEAUTY_RIBBON); + if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > NUM_CUTIES_RIBBONS) + TryPutSpotTheCutiesOnAir(&gPlayerParty[gContestMonPartyIndex], MON_DATA_BEAUTY_RIBBON); } break; case CONTEST_CATEGORY_CUTE: @@ -2011,8 +2014,8 @@ void sub_80F7FFC(void) { ribbonData++; SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_CUTE_RIBBON, &ribbonData); - if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > 4) - sub_80EE4DC(&gPlayerParty[gContestMonPartyIndex], MON_DATA_CUTE_RIBBON); + if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > NUM_CUTIES_RIBBONS) + TryPutSpotTheCutiesOnAir(&gPlayerParty[gContestMonPartyIndex], MON_DATA_CUTE_RIBBON); } break; case CONTEST_CATEGORY_SMART: @@ -2021,8 +2024,8 @@ void sub_80F7FFC(void) { ribbonData++; SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_SMART_RIBBON, &ribbonData); - if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > 4) - sub_80EE4DC(&gPlayerParty[gContestMonPartyIndex], MON_DATA_SMART_RIBBON); + if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > NUM_CUTIES_RIBBONS) + TryPutSpotTheCutiesOnAir(&gPlayerParty[gContestMonPartyIndex], MON_DATA_SMART_RIBBON); } break; case CONTEST_CATEGORY_TOUGH: @@ -2031,95 +2034,96 @@ void sub_80F7FFC(void) { ribbonData++; SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_TOUGH_RIBBON, &ribbonData); - if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > 4) - sub_80EE4DC(&gPlayerParty[gContestMonPartyIndex], MON_DATA_TOUGH_RIBBON); + if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > NUM_CUTIES_RIBBONS) + TryPutSpotTheCutiesOnAir(&gPlayerParty[gContestMonPartyIndex], MON_DATA_TOUGH_RIBBON); } break; } } -void sub_80F8264(void) +void BufferContestantTrainerName(void) { StringCopy(gStringVar1, gContestMons[gSpecialVar_0x8006].trainerName); sub_81DB5AC(gStringVar1); } -void sub_80F8290(void) +void BufferContestantMonNickname(void) { StringCopy(gStringVar3, gContestMons[gSpecialVar_0x8006].nickname); } -void sub_80F82B4(void) +// Unused script special +void GetContestMonConditionRanking(void) { - u8 i, count; + u8 i, rank; - for (i = 0, count = 0; i < 4; i++) + for (i = 0, rank = 0; i < CONTESTANT_COUNT; i++) { if (gContestMonConditions[gSpecialVar_0x8006] < gContestMonConditions[i]) - count++; + rank++; } - gSpecialVar_0x8004 = count; + gSpecialVar_0x8004 = rank; } -void sub_80F82FC(void) +void GetContestMonCondition(void) { gSpecialVar_0x8004 = gContestMonConditions[gSpecialVar_0x8006]; } -void sub_80F831C(void) +void GetContestWinnerId(void) { u8 i; - for (i = 0; i < 4 && gContestFinalStandings[i] != 0; i++) + for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++) ; gSpecialVar_0x8005 = i; } -void sub_80F834C(void) +void BufferContestWinnerTrainerName(void) { u8 i; - for (i = 0; i < 4 && gContestFinalStandings[i] != 0; i++) + for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++) ; StringCopy(gStringVar3, gContestMons[i].trainerName); sub_81DB5AC(gStringVar3); } -void sub_80F8390(void) +void BufferContestWinnerMonName(void) { u8 i; - for (i = 0; i < 4 && gContestFinalStandings[i] != 0; i++) + for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++) ; StringCopy(gStringVar1, gContestMons[i].nickname); } -void sub_80F83D0(void) +void CB2_SetStartContestCallback(void) { SetMainCallback2(CB2_StartContest); } -static void sub_80F83E0(u8 taskId) +static void Task_StartContest(u8 taskId) { if (!gPaletteFade.active) { DestroyTask(taskId); - SetMainCallback2(sub_80F83D0); + SetMainCallback2(CB2_SetStartContestCallback); } } -void sub_80F840C(void) +void StartContest(void) { ScriptContext2_Enable(); - CreateTask(sub_80F83E0, 10); + CreateTask(Task_StartContest, 10); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); } -void sub_80F8438(void) +void BufferContestantMonSpecies(void) { gSpecialVar_0x8004 = gContestMons[gSpecialVar_0x8006].species; } @@ -2140,7 +2144,7 @@ void sub_80F8484(void) BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); } -void sub_80F84B0(void) +void GetContestPlayerId(void) { gSpecialVar_0x8004 = gContestPlayerMonIndex; } @@ -2246,7 +2250,7 @@ void sub_80F8714(u8 taskId) } else { - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) StringGetEnd10(gContestMons[i].nickname); DestroyTask(taskId); diff --git a/src/contest_painting.c b/src/contest_painting.c index 2b36d5e38..7f33cac09 100644 --- a/src/contest_painting.c +++ b/src/contest_painting.c @@ -5,10 +5,10 @@ #include "bg.h" #include "contest.h" #include "contest_painting.h" -#include "contest_painting_effects.h" #include "data.h" #include "decompress.h" #include "gpu_regs.h" +#include "image_processing_effects.h" #include "international_string_util.h" #include "main.h" #include "lilycove_lady.h" @@ -22,9 +22,9 @@ #include "constants/rgb.h" // IWRAM common -u16 (*gUnknown_03006190)[][32]; -struct Unk030061A0 gUnknown_030061A0; -struct ContestWinner *gUnknown_030061C0; +u16 (*gContestMonPixels)[][32]; +struct ImageProcessingContext gImageProcessingContext; +struct ContestWinner *gContestPaintingWinner; u16 *gContestPaintingMonPalette; // IWRAM bss @@ -39,10 +39,10 @@ static void HoldContestPainting(void); static void InitContestPaintingWindow(void); static void InitContestPaintingBg(void); static void InitContestPaintingVars(bool8); -static void sub_8130884(u8, u8); +static void CreateContestPaintingPicture(u8, u8); static void PrintContestPaintingCaption(u8, u8); static void VBlankCB_ContestPainting(void); -static void sub_8130380(u8 *spritePixels, u16 *palette, u16 (*destColorBuffer)[64][64]); +static void _InitContestMonPixels(u8 *spriteGfx, u16 *palette, u16 (*destPixels)[64][64]); extern const u8 gUnknown_0827EA0C[]; extern const u8 gContestCoolness[]; @@ -85,7 +85,7 @@ const u8 gPictureFrameTilemap_3[] = INCBIN_U8("graphics/picture_frame/frame3_map const u8 gPictureFrameTilemap_4[] = INCBIN_U8("graphics/picture_frame/frame4_map.bin.rl"); const u8 gPictureFrameTilemap_5[] = INCBIN_U8("graphics/picture_frame/frame5_map.bin.rl"); -const u8 *const gUnknown_085B07C0[] = +static const u8 *const sContestCategoryNames_Unused[] = { gContestCoolness, gContestBeauty, @@ -94,7 +94,7 @@ const u8 *const gUnknown_085B07C0[] = gContestToughness, }; -const u8 *const gContestRankTextPointers[] = +static const u8 *const sContestRankNames[] = { gContestRankNormal, gContestRankSuper, @@ -103,7 +103,7 @@ const u8 *const gContestRankTextPointers[] = gContestLink, }; -const struct BgTemplate gUnknown_085B07E8[] = +static const struct BgTemplate sContestPaintingBgTemplates[] = { { .bg = 1, @@ -116,7 +116,7 @@ const struct BgTemplate gUnknown_085B07E8[] = }, }; -const struct WindowTemplate gUnknown_085B07EC = +static const struct WindowTemplate sContestPaintingWindowTemplate = { .bg = 1, .tilemapLeft = 2, @@ -127,7 +127,7 @@ const struct WindowTemplate gUnknown_085B07EC = .baseBlock = 1, }; -const u8 *const gContestPaintingDescriptionPointers[] = +static const u8 *const sContestPaintingDescriptionPointers[] = { gContestPaintingCool1, gContestPaintingCool2, @@ -146,7 +146,7 @@ const u8 *const gContestPaintingDescriptionPointers[] = gContestPaintingTough3, }; -const struct OamData gUnknown_085B0830 = +static const struct OamData sContestPaintingMonOamData = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -163,13 +163,13 @@ const struct OamData gUnknown_085B0830 = const u16 gUnknown_085B0838[] = {RGB(0, 0, 0), RGB(0, 0, 0)}; -void sub_812FDA8(int contestWinner) +void SetContestWinnerForPainting(int contestWinnerId) { // probably fakematching u8 *ptr1 = &gUnknown_02039F5D; u8 *ptr2 = &gUnknown_02039F5C; - gUnknown_02039F3C = gSaveBlock1Ptr->contestWinners[contestWinner - 1]; - *ptr1 = contestWinner - 1; + gCurContestWinner = gSaveBlock1Ptr->contestWinners[contestWinnerId - 1]; + *ptr1 = contestWinnerId - 1; *ptr2 = 0; } @@ -189,7 +189,7 @@ static void CB2_QuitContestPainting(void) { SetMainCallback2(gMain.savedCallback); FREE_AND_SET_NULL(gContestPaintingMonPalette); - FREE_AND_SET_NULL(gUnknown_03006190); + FREE_AND_SET_NULL(gContestMonPixels); RemoveWindow(gContestPaintingWindowId); Free(GetBgTilemapBuffer(1)); FreeMonSpritesGfx(); @@ -203,7 +203,7 @@ static void ShowContestPainting(void) ScanlineEffect_Stop(); SetVBlankCallback(NULL); AllocateMonSpritesGfx(); - gUnknown_030061C0 = &gUnknown_02039F3C; + gContestPaintingWinner = &gCurContestWinner; InitContestPaintingVars(1); InitContestPaintingBg(); gMain.state++; @@ -221,7 +221,7 @@ static void ShowContestPainting(void) gMain.state++; break; case 3: - sub_8130884(gUnknown_02039F5D, gUnknown_02039F5C); + CreateContestPaintingPicture(gUnknown_02039F5D, gUnknown_02039F5C); gMain.state++; break; case 4: @@ -269,11 +269,11 @@ static void HoldContestPainting(void) static void InitContestPaintingWindow(void) { ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_085B07E8, ARRAY_COUNT(gUnknown_085B07E8)); + InitBgsFromTemplates(0, sContestPaintingBgTemplates, ARRAY_COUNT(sContestPaintingBgTemplates)); ChangeBgX(1, 0, 0); ChangeBgY(1, 0, 0); SetBgTilemapBuffer(1, AllocZeroed(BG_SCREEN_SIZE)); - gContestPaintingWindowId = AddWindow(&gUnknown_085B07EC); + gContestPaintingWindowId = AddWindow(&sContestPaintingWindowTemplate); DeactivateAllTextPrinters(); FillWindowPixelBuffer(gContestPaintingWindowId, PIXEL_FILL(0)); PutWindowTilemap(gContestPaintingWindowId); @@ -289,21 +289,21 @@ static void PrintContestPaintingCaption(u8 contestType, u8 arg1) if (arg1 == TRUE) return; - category = gUnknown_030061C0->contestCategory; + category = gContestPaintingWinner->contestCategory; if (contestType < 8) { BufferContestName(gStringVar1, category); StringAppend(gStringVar1, gText_Space); - StringAppend(gStringVar1, gContestRankTextPointers[gUnknown_030061C0->contestRank]); - StringCopy(gStringVar2, gUnknown_030061C0->trainerName); + StringAppend(gStringVar1, sContestRankNames[gContestPaintingWinner->contestRank]); + StringCopy(gStringVar2, gContestPaintingWinner->trainerName); sub_81DB5AC(gStringVar2); - StringCopy(gStringVar3, gUnknown_030061C0->monName); + StringCopy(gStringVar3, gContestPaintingWinner->monName); StringExpandPlaceholders(gStringVar4, gUnknown_0827EA0C); } else { - StringCopy(gStringVar1, gUnknown_030061C0->monName); - StringExpandPlaceholders(gStringVar4, gContestPaintingDescriptionPointers[category]); + StringCopy(gStringVar1, gContestPaintingWinner->monName); + StringExpandPlaceholders(gStringVar4, sContestPaintingDescriptionPointers[category]); } x = GetStringCenterAlignXOffset(1, gStringVar4, 208); @@ -360,18 +360,18 @@ static void VBlankCB_ContestPainting(void) TransferPlttBuffer(); } -void sub_81302E8(u16 species, u8 arg1) +static void InitContestMonPixels(u16 species, u8 whichSprite) { - const void *pal = GetMonSpritePalFromSpeciesAndPersonality(species, gUnknown_030061C0->trainerId, gUnknown_030061C0->personality); + const void *pal = GetMonSpritePalFromSpeciesAndPersonality(species, gContestPaintingWinner->trainerId, gContestPaintingWinner->personality); LZDecompressVram(pal, gContestPaintingMonPalette); - if (!arg1) + if (whichSprite == 0) { HandleLoadSpecialPokePic_DontHandleDeoxys( &gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[1], species, - gUnknown_030061C0->personality); - sub_8130380(gMonSpritesGfxPtr->sprites[1], gContestPaintingMonPalette, (void *)gUnknown_03006190); + gContestPaintingWinner->personality); + _InitContestMonPixels(gMonSpritesGfxPtr->sprites[1], gContestPaintingMonPalette, (void *)gContestMonPixels); } else { @@ -379,14 +379,14 @@ void sub_81302E8(u16 species, u8 arg1) &gMonBackPicTable[species], gMonSpritesGfxPtr->sprites[0], species, - gUnknown_030061C0->personality); - sub_8130380(gMonSpritesGfxPtr->sprites[0], gContestPaintingMonPalette, (void *)gUnknown_03006190); + gContestPaintingWinner->personality); + _InitContestMonPixels(gMonSpritesGfxPtr->sprites[0], gContestPaintingMonPalette, (void *)gContestMonPixels); } } #ifdef NONMATCHING // functionally equivalent. -static void sub_8130380(u8 *spritePixels, u16 *palette, u16 (*destColorBuffer)[64][64]) +static void _InitContestMonPixels(u8 *spriteGfx, u16 *palette, u16 (*destPixels)[64][64]) { u16 tileY, tileX, pixelY, pixelX; u8 colorIndex; @@ -400,16 +400,16 @@ static void sub_8130380(u8 *spritePixels, u16 *palette, u16 (*destColorBuffer)[6 for (pixelX = 0; pixelX < 8; pixelX++) { int offset = 32 * (8 * tileY + tileX) + (pixelY * 4 + pixelX / 2); - colorIndex = spritePixels[offset]; + colorIndex = spriteGfx[offset]; if (pixelX & 1) colorIndex >>= 4; else colorIndex &= 0xF; if (colorIndex == 0) // transparent pixel - (*destColorBuffer)[8 * tileY + pixelY][tileX * 8 + pixelX] = 0x8000; + (*destPixels)[8 * tileY + pixelY][tileX * 8 + pixelX] = 0x8000; else - (*destColorBuffer)[8 * tileY + pixelY][tileX * 8 + pixelX] = palette[colorIndex]; + (*destPixels)[8 * tileY + pixelY][tileX * 8 + pixelX] = palette[colorIndex]; } } } @@ -417,7 +417,7 @@ static void sub_8130380(u8 *spritePixels, u16 *palette, u16 (*destColorBuffer)[6 } #else NAKED -static void sub_8130380(u8 *spritePixels, u16 *palette, u16 (*destColorBuffer)[64][64]) +static void _InitContestMonPixels(u8 *spriteGfx, u16 *palette, u16 (*destPixels)[64][64]) { asm_unified("\n\ push {r4-r7,lr}\n\ @@ -519,34 +519,34 @@ _081303F8:\n\ } #endif -static void sub_8130430(u8 arg0, u8 arg1) +static void LoadContestPaintingFrame(u8 contestWinnerId, u8 arg1) { u8 x, y; LoadPalette(gPictureFramePalettes, 0, 0x100); if (arg1 == 1) { - switch (gUnknown_030061C0->contestCategory / 3) + switch (gContestPaintingWinner->contestCategory / 3) { case CONTEST_CATEGORY_COOL: RLUnCompVram(gPictureFrameTiles_0, (void *)VRAM); - RLUnCompWram(gPictureFrameTilemap_0, gUnknown_03006190); + RLUnCompWram(gPictureFrameTilemap_0, gContestMonPixels); break; case CONTEST_CATEGORY_BEAUTY: RLUnCompVram(gPictureFrameTiles_1, (void *)VRAM); - RLUnCompWram(gPictureFrameTilemap_1, gUnknown_03006190); + RLUnCompWram(gPictureFrameTilemap_1, gContestMonPixels); break; case CONTEST_CATEGORY_CUTE: RLUnCompVram(gPictureFrameTiles_2, (void *)VRAM); - RLUnCompWram(gPictureFrameTilemap_2, gUnknown_03006190); + RLUnCompWram(gPictureFrameTilemap_2, gContestMonPixels); break; case CONTEST_CATEGORY_SMART: RLUnCompVram(gPictureFrameTiles_3, (void *)VRAM); - RLUnCompWram(gPictureFrameTilemap_3, gUnknown_03006190); + RLUnCompWram(gPictureFrameTilemap_3, gContestMonPixels); break; case CONTEST_CATEGORY_TOUGH: RLUnCompVram(gPictureFrameTiles_4, (void *)VRAM); - RLUnCompWram(gPictureFrameTilemap_4, gUnknown_03006190); + RLUnCompWram(gPictureFrameTilemap_4, gContestMonPixels); break; } @@ -563,23 +563,23 @@ static void sub_8130430(u8 arg0, u8 arg1) for (y = 0; y < 10; y++) { for (x = 0; x < 18; x++) - VRAM_PICTURE_DATA(x + 6, y + 2) = (*gUnknown_03006190)[y + 2][x + 6]; + VRAM_PICTURE_DATA(x + 6, y + 2) = (*gContestMonPixels)[y + 2][x + 6]; } // Re-set the entire top row to the first top frame part for (x = 0; x < 16; x++) - VRAM_PICTURE_DATA(x + 7, 2) = (*gUnknown_03006190)[2][7]; + VRAM_PICTURE_DATA(x + 7, 2) = (*gContestMonPixels)[2][7]; #undef VRAM_PICTURE_DATA } - else if (arg0 < 8) + else if (contestWinnerId < 8) { RLUnCompVram(gPictureFrameTiles_5, (void *)VRAM); RLUnCompVram(gPictureFrameTilemap_5, (void *)(BG_SCREEN_ADDR(12))); } else { - switch (gUnknown_030061C0->contestCategory / 3) + switch (gContestPaintingWinner->contestCategory / 3) { case CONTEST_CATEGORY_COOL: RLUnCompVram(gPictureFrameTiles_0, (void *)VRAM); @@ -605,100 +605,99 @@ static void sub_8130430(u8 arg0, u8 arg1) } } -static void sub_8130688(u8 arg0) +static void InitPaintingMonOamData(u8 contestWinnerId) { //Some hacks just to get the asm to match #ifndef NONMATCHING - asm(""::"r"(arg0)); + asm(""::"r"(contestWinnerId)); #endif - gMain.oamBuffer[0] = gUnknown_085B0830; + gMain.oamBuffer[0] = sContestPaintingMonOamData; gMain.oamBuffer[0].tileNum = 0; #ifndef NONMATCHING - if (arg0) arg0 = gMain.oamBuffer[0].tileNum; + if (contestWinnerId) contestWinnerId = gMain.oamBuffer[0].tileNum; #endif gMain.oamBuffer[0].x = 88; gMain.oamBuffer[0].y = 24; } -static u8 sub_81306CC(u8 arg0) +static u8 GetImageEffectForContestWinner(u8 contestWinnerId) { u8 contestCategory; - if (arg0 < 8) - contestCategory = gUnknown_030061C0->contestCategory; + if (contestWinnerId < 8) + contestCategory = gContestPaintingWinner->contestCategory; else - contestCategory = gUnknown_030061C0->contestCategory / 3; + contestCategory = gContestPaintingWinner->contestCategory / 3; switch (contestCategory) { case CONTEST_CATEGORY_COOL: - return CONTESTRESULT_COOL; + return IMAGE_EFFECT_OUTLINE_COLORED; case CONTEST_CATEGORY_BEAUTY: - return CONTESTRESULT_BEAUTY; + return IMAGE_EFFECT_SHIMMER; case CONTEST_CATEGORY_CUTE: - return CONTESTRESULT_CUTE; + return IMAGE_EFFECT_POINTILLISM; case CONTEST_CATEGORY_SMART: - return CONTESTRESULT_SMART; + return IMAGE_EFFECT_CHARCOAL; case CONTEST_CATEGORY_TOUGH: - return CONTESTRESULT_TOUGH; + return IMAGE_EFFECT_GRAYSCALE_LIGHT; } return contestCategory; } -static void sub_8130738(void) +static void AllocPaintingResources(void) { - gContestPaintingMonPalette = AllocZeroed(0x200); - gUnknown_03006190 = AllocZeroed(0x2000); + gContestPaintingMonPalette = AllocZeroed(OBJ_PLTT_SIZE); + gContestMonPixels = AllocZeroed(0x2000); } -static void sub_8130760(u8 contestResult) +static void DoContestPaintingImageProcessing(u8 imageEffect) { - gUnknown_030061A0.var_4 = gUnknown_03006190; - gUnknown_030061A0.var_8 = gContestPaintingMonPalette; - gUnknown_030061A0.var_18 = 0; - gUnknown_030061A0.var_1F = gUnknown_030061C0->personality % 256; - gUnknown_030061A0.var_19 = 0; - gUnknown_030061A0.var_1A = 0; - gUnknown_030061A0.var_1B = 64; - gUnknown_030061A0.var_1C = 64; - gUnknown_030061A0.var_1D = 64; - gUnknown_030061A0.var_1E = 64; - - switch (contestResult) + gImageProcessingContext.canvasPixels = gContestMonPixels; + gImageProcessingContext.canvasPalette = gContestPaintingMonPalette; + gImageProcessingContext.paletteStart = 0; + gImageProcessingContext.personality = gContestPaintingWinner->personality % 256; + gImageProcessingContext.columnStart = 0; + gImageProcessingContext.rowStart = 0; + gImageProcessingContext.columnEnd = 64; + gImageProcessingContext.rowEnd = 64; + gImageProcessingContext.canvasWidth = 64; + gImageProcessingContext.canvasHeight = 64; + + switch (imageEffect) { - case CONTESTRESULT_SMART: - case CONTESTRESULT_TOUGH: - gUnknown_030061A0.var_14 = 3; + case IMAGE_EFFECT_CHARCOAL: + case IMAGE_EFFECT_GRAYSCALE_LIGHT: + gImageProcessingContext.quantizeEffect = QUANTIZE_EFFECT_GRAYSCALE; break; - case CONTESTRESULT_COOL: - case CONTESTRESULT_BEAUTY: - case CONTESTRESULT_CUTE: + case IMAGE_EFFECT_OUTLINE_COLORED: + case IMAGE_EFFECT_SHIMMER: + case IMAGE_EFFECT_POINTILLISM: default: - gUnknown_030061A0.var_14 = 1; + gImageProcessingContext.quantizeEffect = QUANTIZE_EFFECT_STANDARD_LIMITED_COLORS; break; } - gUnknown_030061A0.var_16 = 2; - gUnknown_030061A0.var_0 = contestResult; - gUnknown_030061A0.var_10 = OBJ_VRAM0; - - sub_8124F2C(&gUnknown_030061A0); - sub_81261A4(&gUnknown_030061A0); - sub_8126058(&gUnknown_030061A0); + gImageProcessingContext.var_16 = 2; + gImageProcessingContext.effect = imageEffect; + gImageProcessingContext.dest = (void *)OBJ_VRAM0; + ApplyImageProcessingEffects(&gImageProcessingContext); + ApplyImageProcessingQuantization(&gImageProcessingContext); + ConvertImageProcessingToGBA(&gImageProcessingContext); LoadPalette(gContestPaintingMonPalette, 0x100, 0x200); } -static void sub_8130884(u8 arg0, u8 arg1) +static void CreateContestPaintingPicture(u8 contestWinnerId, u8 arg1) { - sub_8130738(); - sub_81302E8(gUnknown_030061C0->species, 0); - sub_8130760(sub_81306CC(arg0)); - sub_8130688(arg0); - sub_8130430(arg0, arg1); + AllocPaintingResources(); + InitContestMonPixels(gContestPaintingWinner->species, 0); + DoContestPaintingImageProcessing(GetImageEffectForContestWinner(contestWinnerId)); + InitPaintingMonOamData(contestWinnerId); + LoadContestPaintingFrame(contestWinnerId, arg1); } diff --git a/src/contest_painting_effects.c b/src/contest_painting_effects.c deleted file mode 100644 index a791df65c..000000000 --- a/src/contest_painting_effects.c +++ /dev/null @@ -1,1365 +0,0 @@ -#include "global.h" -#include "contest_painting_effects.h" -#include "contest_painting.h" -#include "constants/rgb.h" - -struct Unk8125954 -{ - u8 unk0; - u8 unk1; - u16 unk2; -}; - -// IWRAM common -u8 gUnknown_03006164; -u16 (*gUnknown_03006168)[][32]; -u8 gUnknown_0300616C; -u8 gUnknown_03006170; -u8 gUnknown_03006174; -u8 gUnknown_03006178; -u8 gUnknown_0300617C; -u8 gUnknown_03006180; -u16 *gUnknown_03006184; -u16 gUnknown_03006188; - -static void sub_8125230(void); -static void sub_81252E8(void); -static void sub_81254E0(void); -static void sub_8125630(void); -static void sub_8125448(void); -static void sub_81257F8(void); -static void sub_81258A0(void); -static void sub_81256C8(void); -static void sub_8125250(void); -static void sub_81253A4(u8); -static void sub_81250B8(u8); -static void sub_8125170(u8); -static void sub_8125954(u16); -static u16 ConvertColorToGrayscale(u16*); -static u16 sub_8125E18(u16*, u16*, u16*); -static u16 ConvertCoolColor(u16*, u8); -static u16 ConvertToBlackOrWhite(u16*); -static u16 sub_8125C98(u16*, u16*); -static u16 InvertColor(u16*); -static u16 sub_8125F38(u16*, u16*, u16*); -static u16 sub_8125CF4(u16*, u16*); -static u16 GetCoolColorFromPersonality(u8); -static void sub_81263A4(bool8); -static void sub_8126270(void); -static void sub_8126714(void); -static void sub_8126370(void); -static void sub_8126664(void); -static void sub_8126334(void); -static void sub_81265B4(void); -static void sub_8126318(void); -static void sub_81264FC(void); -static u16 sub_81267C4(u16*); -static u16 sub_8126908(u16*); -static u16 sub_812693C(u16*); -static u16 sub_8126838(u16*); - -extern const u8 gUnknown_085A1F94[][3]; - -void sub_8124F2C(struct Unk030061A0 *info) -{ - gUnknown_03006168 = info->var_4; - gUnknown_0300617C = info->var_1F; - gUnknown_03006164 = info->var_19; - gUnknown_03006178 = info->var_1A; - gUnknown_03006174 = info->var_1B; - gUnknown_0300616C = info->var_1C; - gUnknown_03006180 = info->var_1D; - gUnknown_03006170 = info->var_1E; - switch (info->var_0) - { - case 2: - sub_8125230(); - break; - case 8: - sub_81252E8(); - break; - case 9: - sub_81254E0(); - sub_81253A4(gUnknown_0300617C); - break; - case 10: - sub_81254E0(); - sub_8125630(); - sub_8125448(); - case 31: - sub_8125630(); - break; - case 11: - sub_81254E0(); - sub_81257F8(); - sub_81257F8(); - sub_81258A0(); - sub_8125448(); - break; - case 13: - sub_81256C8(); - break; - case 30: - sub_81254E0(); - break; - case 32: - sub_81257F8(); - break; - case 33: - sub_81258A0(); - break; - case 6: - sub_8125250(); - sub_81250B8(3); - break; - case 36: - sub_81254E0(); - sub_81257F8(); - sub_81258A0(); - sub_8125448(); - sub_81252E8(); - sub_81252E8(); - sub_81250B8(2); - sub_8125170(4); - break; - } -} - -static void sub_81250B8(u8 a0) // it changes palette someway somehow... .__. -{ - u8 i, j; - - for (i = 0; i < gUnknown_0300616C; i++) - { - u16* var2 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; - u16* pal = &var2[gUnknown_03006164]; - for (j = 0; j < gUnknown_03006174; j++, pal++) - { - if (!(0x8000 & *pal)) - { - u8 val = (31 & *pal); - val += a0; - if (val > 31) - val = 31; - - *pal = RGB2(val, val, val); - } - } - } -} - -static void sub_8125170(u8 a0) -{ - u8 i, j; - - for (i = 0; i < gUnknown_0300616C; i++) - { - u16* var2 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; - u16* pal = &var2[gUnknown_03006164]; - for (j = 0; j < gUnknown_03006174; j++, pal++) - { - if (!(0x8000 & *pal)) - { - u8 val = (31 & *pal); - if (val > 31 - a0) - val = 31 - (a0 >> 1); - - *pal = RGB2(val, val, val); - } - } - } -} - -static void sub_8125230(void) -{ - u32 i; - for (i = 0; i < 3200; i++) - sub_8125954(i); -} - -static void sub_8125250(void) -{ - u8 i, j; - - for (i = 0; i < gUnknown_0300616C; i++) - { - u16* var2 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; - u16* color = &var2[gUnknown_03006164]; - for (j = 0; j < gUnknown_03006174; j++, color++) - { - if (!(0x8000 & *color)) - { - *color = ConvertColorToGrayscale(color); - } - } - } -} - -static void sub_81252E8(void) -{ - u8 i, j; - - for (i = 0; i < gUnknown_03006174; i++) - { - u16* var0 = &(*gUnknown_03006168)[0][gUnknown_03006178 * gUnknown_03006180]; - u16* palette = &var0[gUnknown_03006164 + i]; - u16 color = *palette; - - j = 1; - palette += gUnknown_03006180; - while (j < gUnknown_0300616C - 1) - { - if (!(0x8000 & *palette)) - { - *palette = sub_8125E18(&color, palette, palette + gUnknown_03006180); - color = *palette; - } - - j++; - palette += gUnknown_03006180; - } - } -} - -static void sub_81253A4(u8 arg0) -{ - u8 i, j; - - for (i = 0; i < gUnknown_0300616C; i++) - { - u16* var0 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; - u16* color = &var0[gUnknown_03006164]; - for (j = 0; j < gUnknown_03006174; j++, color++) - { - if (!(0x8000 & *color)) - { - *color = ConvertCoolColor(color, arg0); - } - } - } -} - -static void sub_8125448(void) -{ - u8 i, j; - - for (i = 0; i < gUnknown_0300616C; i++) - { - u16* var0 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; - u16* color = &var0[gUnknown_03006164]; - for (j = 0; j < gUnknown_03006174; j++, color++) - { - if (!(0x8000 & *color)) - { - *color = ConvertToBlackOrWhite(color); - } - } - } -} - -static void sub_81254E0(void) -{ - u8 i, j; - u16 *palette; - - for (i = 0; i < gUnknown_0300616C; i++) - { - u16 *var0 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; - palette = &var0[gUnknown_03006164]; - *palette = sub_8125C98(palette, palette + 1); - for (j = 1, palette = palette + 1; j < gUnknown_03006174 - 1; j++, palette++) - { - *palette = sub_8125C98(palette, palette + 1); - *palette = sub_8125C98(palette, palette - 1); - } - - *palette = sub_8125C98(palette, palette - 1); - } - - for (j = 0; j < gUnknown_03006174; j++) - { - u16 *var0 = &(*gUnknown_03006168)[0][gUnknown_03006178 * gUnknown_03006180]; - palette = &var0[gUnknown_03006164 + j]; - *palette = sub_8125C98(palette, palette + gUnknown_03006180); - for (i = 1, palette = palette + gUnknown_03006180; i < gUnknown_0300616C - 1; i++, palette += gUnknown_03006180) - { - *palette = sub_8125C98(palette, palette + gUnknown_03006180); - *palette = sub_8125C98(palette, palette - gUnknown_03006180); - } - - *palette = sub_8125C98(palette, palette - gUnknown_03006180); - } -} - -static void sub_8125630(void) -{ - u8 i, j; - - for (i = 0; i < gUnknown_0300616C; i++) - { - u16 *var0 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; - u16 *color = &var0[gUnknown_03006164]; - for (j = 0; j < gUnknown_03006174; j++, color++) - { - if (!(0x8000 & *color)) - { - *color = InvertColor(color); - } - } - } -} - -static void sub_81256C8(void) -{ - u8 i, j; - u16 *palette; - u16 color; - - palette = (*gUnknown_03006168)[0]; - for (i = 0; i < 64; i++) - { - for (j = 0; j < 64; j++, palette++) - { - if (!(0x8000 & *palette)) - { - *palette = InvertColor(palette); - } - } - } - - for (j = 0; j < 64; j++) - { - palette = &(*gUnknown_03006168)[0][j]; - color = *palette; - *palette = 0x8000; - for (i = 1, palette += 64; i < 63; i++, palette += 64) - { - if (!(0x8000 & *palette)) - { - *palette = sub_8125F38(&color, palette, palette + 64); - color = *palette; - } - } - - *palette = 0x8000; - palette = &(*gUnknown_03006168)[0][j]; - color = *palette; - *palette = 0x8000; - for (i = 1, palette += 64; i < 63; i++, palette += 64) - { - if (!(0x8000 & *palette)) - { - *palette = sub_8125F38(&color, palette, palette + 64); - color = *palette; - } - } - - *palette = 0x8000; - } - - palette = (*gUnknown_03006168)[0]; - for (i = 0; i < 64; i++) - { - for (j = 0; j < 64; j++, palette++) - { - if (!(0x8000 & *palette)) - { - *palette = InvertColor(palette); - } - } - } -} - -static void sub_81257F8(void) -{ - u8 i, j; - - for (i = 0; i < gUnknown_0300616C; i++) - { - u16 *var0 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; - u16 *palette = &var0[gUnknown_03006164]; - u16 color = *palette; - for (j = 1, palette++; j < gUnknown_03006174 - 1; j++, palette++) - { - if (!(0x8000 & *palette)) - { - *palette = sub_8125CF4(&color, palette); - color = *palette; - } - } - } -} - -static void sub_81258A0(void) -{ - u8 i, j; - - for (i = 0; i < gUnknown_03006174; i++) - { - u16* var0 = &(*gUnknown_03006168)[0][gUnknown_03006178 * gUnknown_03006180]; - u16* palette = &var0[gUnknown_03006164 + i]; - u16 color = *palette; - for (j = 1, palette += gUnknown_03006180; j < gUnknown_0300616C - 1; j++, palette += gUnknown_03006180) - { - if (!(0x8000 & *palette)) - { - *palette = sub_8125CF4(&color, palette); - color = *palette; - } - } - } -} - -static void sub_8125954(u16 arg0) -{ - u8 i; - u8 r5, r9; - struct Unk8125954 unkStruct[6]; - - unkStruct[0].unk0 = gUnknown_085A1F94[arg0][0]; - unkStruct[0].unk1 = gUnknown_085A1F94[arg0][1]; - unkStruct[0].unk2 = (gUnknown_085A1F94[arg0][2] >> 3) & 7; - - r9 = (gUnknown_085A1F94[arg0][2] >> 1) & 3; - r5 = gUnknown_085A1F94[arg0][2] & 1; - for (i = 1; i < unkStruct[0].unk2; i++) - { - if (!r5) - { - unkStruct[i].unk0 = unkStruct[0].unk0 - i; - unkStruct[i].unk1 = unkStruct[0].unk1 + i; - } - else - { - unkStruct[i].unk0 = unkStruct[0].unk0 + 1; - unkStruct[i].unk1 = unkStruct[0].unk1 - 1; - } - - if (unkStruct[i].unk0 > 63 || unkStruct[i].unk1 > 63) - { - unkStruct[0].unk2 = i - 1; - break; - } - - unkStruct[i].unk2 = unkStruct[0].unk2 - i; - } - - for (i = 0; i < unkStruct[0].unk2; i++) - { - u16 *pal = &(*gUnknown_03006168)[unkStruct[i].unk1 * 2][unkStruct[i].unk0]; - - if (!(0x8000 & *pal)) - { - u16 r = (*pal) & 0x1F; - u16 g = (*pal >> 5) & 0x1F; - u16 b = (*pal >> 10) & 0x1F; - - switch (r9) - { - case 0: - case 1: - switch (((gUnknown_085A1F94[arg0][2] >> 3) & 7) % 3) - { - case 0: - if (r >= unkStruct[i].unk2) - r -= unkStruct[i].unk2; - else - r = 0; - break; - case 1: - if (g >= unkStruct[i].unk2) - g -= unkStruct[i].unk2; - else - g = 0; - break; - case 2: - if (b >= unkStruct[i].unk2) - b -= unkStruct[i].unk2; - else - b = 0; - break; - } - break; - case 2: - case 3: - r += unkStruct[i].unk2; - g += unkStruct[i].unk2; - b += unkStruct[i].unk2; - if (r > 31) - r = 31; - if (g > 31) - g = 31; - if (b > 31) - b = 31; - break; - } - - *pal = RGB2(r, g, b); - } - } -} - -static u16 ConvertColorToGrayscale(u16 *color) -{ - s32 clr = *color; - s32 r = clr & 0x1F; - s32 g = (clr >> 5) & 0x1F; - s32 b = (clr >> 10) & 0x1F; - 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); -} - -// The dark colors are the colored edges of the Cool painting effect. -// Everything else is white. -static u16 ConvertCoolColor(u16 *color, u8 personality) -{ - u16 red = *color & 0x1F; - u16 green = (*color >> 5) & 0x1F; - u16 blue = (*color >> 10) & 0x1F; - - if (red < 17 && green < 17 && blue < 17) - return GetCoolColorFromPersonality(personality); - else - return RGB_WHITE; -} - -// Based on the given value, which comes from the first 8 bits of -// the mon's personality value, return a color. -static u16 GetCoolColorFromPersonality(u8 personality) -{ - u16 red = 0; - u16 green = 0; - u16 blue = 0; - u8 strength = (personality / 6) % 3; - u8 colorType = personality % 6; - - switch (colorType) - { - case 0: - // Teal color - green = 21 - strength; - blue = green; - red = 0; - break; - case 1: - // Yellow color - blue = 0; - red = 21 - strength; - green = red; - break; - case 2: - // Purple color - blue = 21 - strength; - green = 0; - red = blue; - break; - case 3: - // Red color - blue = 0; - green = 0; - red = 23 - strength; - break; - case 4: - // Blue color - blue = 23 - strength; - green = 0; - red = 0; - break; - case 5: - // Green color - blue = 0; - green = 23 - strength; - red = 0; - break; - } - - return RGB2(red, green, blue); -} - -static u16 ConvertToBlackOrWhite(u16 *color) -{ - u16 red = *color & 0x1F; - u16 green = (*color >> 5) & 0x1F; - u16 blue = (*color >> 10) & 0x1F; - - if (red < 17 && green < 17 && blue < 17) - return RGB_BLACK; - else - return RGB_WHITE; -} - -static u16 sub_8125C98(u16 *colorA, u16 *colorB) -{ - if (*colorA) - { - if (*colorA & 0x8000) - return 0x8000; - if (*colorB & 0x8000) - return RGB_BLACK; - - return *colorA; - } - - return RGB_BLACK; -} - -static u16 InvertColor(u16 *color) -{ - u16 red = *color & 0x1F; - u16 green = (*color >> 5) & 0x1F; - u16 blue = (*color >> 10) & 0x1F; - - red = 31 - red; - green = 31 - green; - blue = 31 - blue; - - return RGB2(red, green, blue); -} - -static u16 sub_8125CF4(u16 *a0, u16 *a1) -{ - u16 sp0[2][3]; - u16 spC[3]; - u8 r4; - u16 r2; - u16 r, g, b; - - if (*a0 == *a1) - return *a1; - - sp0[0][0] = (*a0 >> 0) & 0x1F; - sp0[0][1] = (*a0 >> 5) & 0x1F; - sp0[0][2] = (*a0 >> 10) & 0x1F; - sp0[1][0] = (*a1 >> 0) & 0x1F; - sp0[1][1] = (*a1 >> 5) & 0x1F; - sp0[1][2] = (*a1 >> 10) & 0x1F; - - if (sp0[0][0] > 25 && sp0[0][1] > 25 && sp0[0][2] > 25) - return *a1; - if (sp0[1][0] > 25 && sp0[1][1] > 25 && sp0[1][2] > 25) - return *a1; - - for (r4 = 0; r4 < 3; r4++) - { - if (sp0[0][r4] > sp0[1][r4]) - spC[r4] = sp0[0][r4] - sp0[1][r4]; - else - spC[r4] = sp0[1][r4] - sp0[0][r4]; - } - - if (spC[0] >= spC[1]) - { - if (spC[0] >= spC[2]) - r2 = spC[0]; - else if (spC[1] >= spC[2]) - r2 = spC[1]; - else - r2 = spC[2]; - } - else - { - if (spC[1] >= spC[2]) - r2 = spC[1]; - else if (spC[2] >= spC[0]) - r2 = spC[2]; - else - r2 = spC[0]; - } - - r = (sp0[1][0] * (31 - r2 / 2)) / 31; - g = (sp0[1][1] * (31 - r2 / 2)) / 31; - b = (sp0[1][2] * (31 - r2 / 2)) / 31; - return RGB2(r, g, b); -} - -static u16 sub_8125E18(u16 * a0, u16 * a1, u16 * a2) -{ - u16 red, green, blue; - u16 avg0, avg1, avg2; - u16 diff1, diff2; - u32 minimum; - u16 factor; - - if (*a0 == *a1 && *a2 == *a1) - return *a1; - - red = (*a1 >> 0) & 0x1F; - green = (*a1 >> 5) & 0x1F; - blue = (*a1 >> 10) & 0x1F; - - avg0 = (((*a0 >> 0) & 0x1F) + ((*a0 >> 5) & 0x1F) + ((*a0 >> 10) & 0x1F)) / 3; - avg1 = (((*a1 >> 0) & 0x1F) + ((*a1 >> 5) & 0x1F) + ((*a1 >> 10) & 0x1F)) / 3; - avg2 = (((*a2 >> 0) & 0x1F) + ((*a2 >> 5) & 0x1F) + ((*a2 >> 10) & 0x1F)) / 3; - - if (avg0 == avg1 && avg2 == avg1) - return *a1; - - if (avg0 > avg1) - diff1 = avg0 - avg1; - else - diff1 = avg1 - avg0; - - if (avg2 > avg1) - diff2 = avg2 - avg1; - else - diff2 = avg1 - avg2; - - if (diff1 >= diff2) - minimum = diff1; - else - minimum = diff2; - - factor = 31 - minimum / 2; - red = red * factor / 31; - green = green * factor / 31; - blue = blue * factor / 31; - return RGB2(red, green, blue); -} - -static u16 sub_8125F38(u16 *a0, u16 *a1, u16 *a2) -{ - u16 red, green, blue; - u16 avg0, avg1, avg2; - u16 diff1, diff2; - u32 minimum; - u16 factor; - - if (*a0 == *a1 && *a2 == *a1) - return *a1; - - red = (*a1 >> 0) & 0x1F; - green = (*a1 >> 5) & 0x1F; - blue = (*a1 >> 10) & 0x1F; - - avg0 = (((*a0 >> 0) & 0x1F) + ((*a0 >> 5) & 0x1F) + ((*a0 >> 10) & 0x1F)) / 3; - avg1 = (((*a1 >> 0) & 0x1F) + ((*a1 >> 5) & 0x1F) + ((*a1 >> 10) & 0x1F)) / 3; - avg2 = (((*a2 >> 0) & 0x1F) + ((*a2 >> 5) & 0x1F) + ((*a2 >> 10) & 0x1F)) / 3; - - if (avg0 == avg1 && avg2 == avg1) - return *a1; - - if (avg0 > avg1) - diff1 = avg0 - avg1; - else - diff1 = avg1 - avg0; - - if (avg2 > avg1) - diff2 = avg2 - avg1; - else - diff2 = avg1 - avg2; - - if (diff1 >= diff2) - minimum = diff1; - else - minimum = diff2; - - factor = 31 - minimum; - red = red * factor / 31; - green = green * factor / 31; - blue = blue * factor / 31; - return RGB2(red, green, blue); -} - -/* -void sub_8126058(struct Unk030061A0 *arg0) -{ - u16 i, j, k; - u8 r5 = arg0->var_1D >> 3; - u8 var_24 = arg0->var_1E >> 3; - u16 (*var_2C)[][32] = arg0->var_4; - u32 var_28 = arg0->var_10; - - if (arg0->var_16 == 2) - { - for (i = 0; i < var_24; i++) - { - for (j = 0; j < r5; j++) - { - for (k = 0; k < 8; k++) - { - (*var_2C)[][]; - } - } - } - } -} -*/ - -NAKED -void sub_8126058(struct Unk030061A0 *arg0) -{ - asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0xC\n\ - ldrb r1, [r0, 0x1D]\n\ - lsrs r5, r1, 3\n\ - ldrb r1, [r0, 0x1E]\n\ - lsrs r1, 3\n\ - str r1, [sp, 0x8]\n\ - ldr r1, [r0, 0x4]\n\ - str r1, [sp]\n\ - ldr r2, [r0, 0x10]\n\ - str r2, [sp, 0x4]\n\ - ldrh r0, [r0, 0x16]\n\ - cmp r0, 0x2\n\ - bne _08126108\n\ - movs r1, 0\n\ - ldr r0, [sp, 0x8]\n\ - cmp r1, r0\n\ - bcc _08126086\n\ - b _08126194\n\ -_08126086:\n\ - movs r0, 0\n\ - adds r2, r1, 0x1\n\ - mov r10, r2\n\ - cmp r0, r5\n\ - bcs _081260FA\n\ - adds r2, r1, 0\n\ - muls r2, r5\n\ - mov r9, r2\n\ - lsls r1, 3\n\ - mov r8, r1\n\ -_0812609A:\n\ - movs r4, 0\n\ - lsls r6, r0, 4\n\ - adds r7, r0, 0x1\n\ - add r0, r9\n\ - lsls r0, 6\n\ - ldr r1, [sp, 0x4]\n\ - adds r1, r0\n\ - mov r12, r1\n\ -_081260AA:\n\ - lsls r0, r4, 3\n\ - mov r2, r12\n\ - adds r3, r2, r0\n\ - mov r1, r8\n\ - adds r0, r1, r4\n\ - lsls r0, 3\n\ - muls r0, r5\n\ - lsls r0, 1\n\ - ldr r2, [sp]\n\ - adds r0, r2, r0\n\ - adds r2, r0, r6\n\ - ldrh r0, [r2, 0x2]\n\ - lsls r0, 8\n\ - ldrh r1, [r2]\n\ - orrs r0, r1\n\ - strh r0, [r3]\n\ - ldrh r0, [r2, 0x6]\n\ - lsls r0, 8\n\ - ldrh r1, [r2, 0x4]\n\ - orrs r0, r1\n\ - strh r0, [r3, 0x2]\n\ - ldrh r0, [r2, 0xA]\n\ - lsls r0, 8\n\ - ldrh r1, [r2, 0x8]\n\ - orrs r0, r1\n\ - strh r0, [r3, 0x4]\n\ - ldrh r0, [r2, 0xE]\n\ - lsls r0, 8\n\ - ldrh r1, [r2, 0xC]\n\ - orrs r0, r1\n\ - strh r0, [r3, 0x6]\n\ - adds r0, r4, 0x1\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - cmp r4, 0x7\n\ - bls _081260AA\n\ - lsls r0, r7, 16\n\ - lsrs r0, 16\n\ - cmp r0, r5\n\ - bcc _0812609A\n\ -_081260FA:\n\ - mov r1, r10\n\ - lsls r0, r1, 16\n\ - lsrs r1, r0, 16\n\ - ldr r2, [sp, 0x8]\n\ - cmp r1, r2\n\ - bcc _08126086\n\ - b _08126194\n\ -_08126108:\n\ - movs r1, 0\n\ - ldr r0, [sp, 0x8]\n\ - cmp r1, r0\n\ - bcs _08126194\n\ -_08126110:\n\ - movs r0, 0\n\ - adds r2, r1, 0x1\n\ - mov r10, r2\n\ - cmp r0, r5\n\ - bcs _08126188\n\ - adds r2, r1, 0\n\ - muls r2, r5\n\ - mov r9, r2\n\ - lsls r1, 3\n\ - mov r8, r1\n\ -_08126124:\n\ - movs r4, 0\n\ - lsls r6, r0, 4\n\ - adds r7, r0, 0x1\n\ - add r0, r9\n\ - lsls r0, 5\n\ - ldr r1, [sp, 0x4]\n\ - adds r1, r0\n\ - mov r12, r1\n\ -_08126134:\n\ - lsls r0, r4, 2\n\ - mov r2, r12\n\ - adds r3, r2, r0\n\ - mov r1, r8\n\ - adds r0, r1, r4\n\ - lsls r0, 3\n\ - muls r0, r5\n\ - lsls r0, 1\n\ - ldr r2, [sp]\n\ - adds r0, r2, r0\n\ - adds r2, r0, r6\n\ - ldrh r1, [r2, 0x2]\n\ - lsls r1, 4\n\ - ldrh r0, [r2]\n\ - orrs r1, r0\n\ - ldrh r0, [r2, 0x4]\n\ - lsls r0, 8\n\ - orrs r1, r0\n\ - ldrh r0, [r2, 0x6]\n\ - lsls r0, 12\n\ - orrs r1, r0\n\ - strh r1, [r3]\n\ - ldrh r1, [r2, 0xA]\n\ - lsls r1, 4\n\ - ldrh r0, [r2, 0x8]\n\ - orrs r1, r0\n\ - ldrh r0, [r2, 0xC]\n\ - lsls r0, 8\n\ - orrs r1, r0\n\ - ldrh r0, [r2, 0xE]\n\ - lsls r0, 12\n\ - orrs r1, r0\n\ - strh r1, [r3, 0x2]\n\ - adds r0, r4, 0x1\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - cmp r4, 0x7\n\ - bls _08126134\n\ - lsls r0, r7, 16\n\ - lsrs r0, 16\n\ - cmp r0, r5\n\ - bcc _08126124\n\ -_08126188:\n\ - mov r1, r10\n\ - lsls r0, r1, 16\n\ - lsrs r1, r0, 16\n\ - ldr r2, [sp, 0x8]\n\ - cmp r1, r2\n\ - bcc _08126110\n\ -_08126194:\n\ - add sp, 0xC\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0"); -} - -void sub_81261A4(struct Unk030061A0 *arg0) -{ - gUnknown_03006188 = arg0->var_18 * 16; - gUnknown_03006184 = &arg0->var_8[gUnknown_03006188]; - gUnknown_03006168 = arg0->var_4; - gUnknown_03006164 = arg0->var_19; - gUnknown_03006178 = arg0->var_1A; - gUnknown_03006174 = arg0->var_1B; - gUnknown_0300616C = arg0->var_1C; - gUnknown_03006180 = arg0->var_1D; - gUnknown_03006170 = arg0->var_1E; - - switch (arg0->var_14) - { - case 0: - sub_81263A4(FALSE); - break; - case 1: - sub_81263A4(TRUE); - break; - case 2: - sub_8126270(); - sub_8126714(); - break; - case 3: - sub_8126370(); - sub_8126664(); - break; - case 4: - sub_8126334(); - sub_81265B4(); - break; - case 5: - sub_8126318(); - sub_81264FC(); - break; - } -} - -static void sub_8126270(void) -{ - gUnknown_03006184[0] = RGB2(0, 0, 0); - gUnknown_03006184[1] = RGB2(6, 6, 6); - gUnknown_03006184[2] = RGB2(29, 29, 29); - gUnknown_03006184[3] = RGB2(11, 11, 11); - gUnknown_03006184[4] = RGB2(29, 6, 6); - gUnknown_03006184[5] = RGB2(6, 29, 6); - gUnknown_03006184[6] = RGB2(6, 6, 29); - gUnknown_03006184[7] = RGB2(29, 29, 6); - gUnknown_03006184[8] = RGB2(29, 6, 29); - gUnknown_03006184[9] = RGB2(6, 29, 29); - gUnknown_03006184[10] = RGB2(29, 11, 6); - gUnknown_03006184[11] = RGB2(11, 29, 6); - gUnknown_03006184[12] = RGB2(6, 11, 29); - gUnknown_03006184[13] = RGB2(29, 6, 11); - gUnknown_03006184[14] = RGB2(6, 29, 11); - gUnknown_03006184[15] = RGB2(11, 6, 29); -} - -static void sub_8126318(void) -{ - gUnknown_03006184[0] = RGB2(0, 0, 0); - gUnknown_03006184[1] = RGB2(0, 0, 0); - gUnknown_03006184[2] = RGB2(31, 31, 31); -} - -static void sub_8126334(void) -{ - u8 i; - - gUnknown_03006184[0] = RGB2(0, 0, 0); - gUnknown_03006184[1] = RGB2(0, 0, 0); - for (i = 0; i < 14; i++) - gUnknown_03006184[i + 2] = RGB2(2 * (i + 2), 2 * (i + 2), 2 * (i + 2)); -} - -static void sub_8126370(void) -{ - u8 i; - - gUnknown_03006184[0] = RGB2(0, 0, 0); - for (i = 0; i < 32; i++) - gUnknown_03006184[i + 1] = RGB2(i, i, i); -} - -static void sub_81263A4(bool8 arg0) -{ - u8 i, j; - u16 maxIndex; - - maxIndex = 0xDF; - if (!arg0) - maxIndex = 0xFF; - - for (j = 0; j < maxIndex; j++) - gUnknown_03006184[j] = 0; - - gUnknown_03006184[maxIndex] = RGB2(15, 15, 15); - for (i = 0; i < gUnknown_0300616C; i++) - { - u16* var2 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; - u16* pal = &var2[gUnknown_03006164]; - for (j = 0; j < gUnknown_03006174; j++, pal++) - { - if (*pal & 0x8000) - { - *pal = gUnknown_03006188; - } - else - { - u16 color = sub_81267C4(pal); - u8 curIndex = 1; - if (curIndex < maxIndex) - { - if (gUnknown_03006184[curIndex] == RGB_BLACK) - { - gUnknown_03006184[curIndex] = color; - *pal = gUnknown_03006188 + curIndex; - } - else - { - while (curIndex < maxIndex) - { - if (gUnknown_03006184[curIndex] == RGB_BLACK) - { - gUnknown_03006184[curIndex] = color; - *pal = gUnknown_03006188 + curIndex; - break; - } - - if (gUnknown_03006184[curIndex] == color) - { - *pal = gUnknown_03006188 + curIndex; - break; - } - - curIndex++; - } - } - } - - if (curIndex == maxIndex) - { - curIndex = maxIndex; - *pal = curIndex; - } - } - } - } -} - -static void sub_81264FC(void) -{ - u8 i, j; - - for (i = 0; i < gUnknown_0300616C; i++) - { - u16* var2 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; - u16* pal = &var2[gUnknown_03006164]; - for (j = 0; j < gUnknown_03006174; j++, pal++) - { - if (*pal & 0x8000) - { - *pal = gUnknown_03006188; - } - else - { - if (ConvertToBlackOrWhite(pal) == RGB_BLACK) - *pal = gUnknown_03006188 + 1; - else - *pal = gUnknown_03006188 + 2; - } - } - } -} - -static void sub_81265B4(void) -{ - u8 i, j; - - for (i = 0; i < gUnknown_0300616C; i++) - { - u16* var2 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; - u16* pal = &var2[gUnknown_03006164]; - for (j = 0; j < gUnknown_03006174; j++, pal++) - { - if (*pal & 0x8000) - *pal = gUnknown_03006188; - else - *pal = sub_8126908(pal) + gUnknown_03006188; - } - } -} - -static void sub_8126664(void) -{ - u8 i, j; - - for (i = 0; i < gUnknown_0300616C; i++) - { - u16* var2 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; - u16* pal = &var2[gUnknown_03006164]; - for (j = 0; j < gUnknown_03006174; j++, pal++) - { - if (*pal & 0x8000) - *pal = gUnknown_03006188; - else - *pal = sub_812693C(pal) + gUnknown_03006188; - } - } -} - -static void sub_8126714(void) -{ - u8 i, j; - - for (i = 0; i < gUnknown_0300616C; i++) - { - u16* var2 = &(*gUnknown_03006168)[0][(gUnknown_03006178 + i) * gUnknown_03006180]; - u16* pal = &var2[gUnknown_03006164]; - for (j = 0; j < gUnknown_03006174; j++, pal++) - { - if (*pal & 0x8000) - *pal = gUnknown_03006188; - else - *pal = sub_8126838(pal) + gUnknown_03006188; - } - } -} - -static u16 sub_81267C4(u16 *color) -{ - u16 red = *color & 0x1F; - u16 green = (*color >> 5) & 0x1F; - u16 blue = (*color >> 10) & 0x1F; - - if (red & 3) - red = (red & 0x1C) + 4; - if (green & 3) - green = (green & 0x1C) + 4; - if (blue & 3) - blue = (blue & 0x1C) + 4; - - if (red < 6) - red = 6; - if (red > 30) - red = 30; - - if (green < 6) - green = 6; - if (green > 30) - green = 30; - - if (blue < 6) - blue = 6; - if (blue > 30) - blue = 30; - - return RGB2(red, green, blue); -} - -static u16 sub_8126838(u16* color) -{ - u16 red = *color & 0x1F; - u16 green = (*color >> 5) & 0x1F; - u16 blue = (*color >> 10) & 0x1F; - - if (red < 12 && green < 11 && blue < 11) - return 1; - - if (red > 19 && green > 19 && blue > 19) - return 2; - - if (red > 19) - { - if (green > 19) - { - if (blue > 14) - return 2; - else - return 7; - } - else if (blue > 19) - { - if (green > 14) - return 2; - else - return 8; - } - } - - if (green > 19 && blue > 19) - { - if (red > 14) - return 2; - else - return 9; - } - - if (red > 19) - { - if (green > 11) - { - if (blue > 11) - { - if (green < blue) - return 8; - else - return 7; - } - else - { - return 10; - } - } - else if (blue > 11) - { - return 13; - } - else - { - return 4; - } - } - - if (green > 19) - { - if (red > 11) - { - if (blue > 11) - { - if (red < blue) - return 9; - else - return 7; - } - else - { - return 11; - } - } - else - { - if (blue > 11) - return 14; - else - return 5; - } - } - - if (blue > 19) - { - if (red > 11) - { - if (green > 11) - { - if (red < green) - return 9; - else - return 8; - } - } - else if (green > 11) - { - return 12; - } - - if (blue > 11) - return 15; - else - return 6; - } - - return 3; -} - -static u16 sub_8126908(u16 *color) -{ - u16 red = *color & 0x1F; - u16 green = (*color >> 5) & 0x1F; - u16 blue = (*color >> 10) & 0x1F; - u16 average = ((red + green + blue) / 3) & 0x1E; - if (average == 0) - return 1; - else - return average / 2; -} - -static u16 sub_812693C(u16 *color) -{ - u16 red = *color & 0x1F; - u16 green = (*color >> 5) & 0x1F; - u16 blue = (*color >> 10) & 0x1F; - u16 average = (red + green + blue) / 3; - return average + 1; -} diff --git a/src/credits.c b/src/credits.c index e2c125d3f..323146f1e 100644 --- a/src/credits.c +++ b/src/credits.c @@ -128,16 +128,17 @@ enum TDE_TASK_A_ID = 2, }; -struct Unk201C000 -{ - u16 unk0[71]; - u16 unk8E; - u16 unk90; - u16 unk92; - u16 unk94; - u16 unk96[NATIONAL_DEX_COUNT]; - u16 unk39A; - u16 unk39C[7]; +#define NUM_MON_SLIDES 71 +struct CreditsData +{ + u16 monToShow[NUM_MON_SLIDES]; // List of Pokemon species ids that will show during the credits + u16 imgCounter; //how many mon images have been shown + u16 nextImgPos; //if the next image spawns left/center/right + u16 currShownMon; //index into monToShow + u16 numMonToShow; //number of pokemon to show, always NUM_MON_SLIDES after determine function + u16 caughtMonIds[NATIONAL_DEX_COUNT]; //temporary location to hold a condensed array of all caught pokemon + u16 numCaughtMon; //count of filled spaces in caughtMonIds + u16 unk39C[7]; // unused padding? }; struct CreditsEntry @@ -151,7 +152,7 @@ static EWRAM_DATA s16 gUnknown_0203BCE0 = 0; static EWRAM_DATA u16 gUnknown_0203BCE2 = 0; // TASK A EWRAM_DATA bool8 gHasHallOfFameRecords = 0; static EWRAM_DATA u8 gUnknown_0203BCE5 = 0; -static EWRAM_DATA struct Unk201C000 *gUnknown_0203BCE8 = {0}; +static EWRAM_DATA struct CreditsData *sCreditsData = {0}; static const u16 gUnknown_085E56F0[][16] = { @@ -959,7 +960,7 @@ static const struct WindowTemplate sWindowTemplates[] = }, DUMMY_WIN_TEMPLATE, }; -static const u8 gUnknown_085E6F7C[][2] = +static const u8 sMonSpritePos[][2] = { {104, 36}, {120, 36}, @@ -1127,8 +1128,8 @@ static void LoadTheEndScreen(u16, u16, u16); static void sub_8176E40(u16 arg0, u16 palette); static void sub_8176EE8(struct Sprite *sprite); static void sub_8176F90(struct Sprite *sprite); -static u8 sub_8177224(u16 species, s16 x, s16 y, u16 position); -static void sub_8177388(void); +static u8 MakeMonSprite(u16 species, s16 x, s16 y, u16 position); +static void DeterminePokemonToShow(void); static void CreditsVBlankCallback(void) { @@ -1241,13 +1242,13 @@ void CB2_StartCreditsSequence(void) m4aSongNumStart(MUS_THANKFOR); SetMainCallback2(CB2_RunCreditsSequence); gUnknown_0203BCE5 = 0; - gUnknown_0203BCE8 = AllocZeroed(sizeof(struct Unk201C000)); + sCreditsData = AllocZeroed(sizeof(struct CreditsData)); - sub_8177388(); + DeterminePokemonToShow(); - gUnknown_0203BCE8->unk8E = 0; - gUnknown_0203BCE8->unk90 = 0; - gUnknown_0203BCE8->unk92 = 0; + sCreditsData->imgCounter = 0; + sCreditsData->nextImgPos = 0; + sCreditsData->currShownMon = 0; gUnknown_0203BCE2 = taskIdA; } @@ -1604,7 +1605,7 @@ static void sub_8175DA0(u8 taskIdB) gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_4] = 1; DestroyTask(taskIdB); sub_81755A4(); - FREE_AND_SET_NULL(gUnknown_0203BCE8); + FREE_AND_SET_NULL(sCreditsData); return; } } @@ -1683,29 +1684,29 @@ static void sub_81760FC(u8 taskIdD) case 0: break; case 1: - if (gUnknown_0203BCE8->unk90 == 0 && gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].data[TDA_14] == 0) + if (sCreditsData->nextImgPos == 0 && gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].data[TDA_14] == 0) break; gTasks[taskIdD].data[TDD_STATE]++; break; case 2: - if (gUnknown_0203BCE8->unk8E == 71 || gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].func != Task_ProgressCreditTasks) + if (sCreditsData->imgCounter == NUM_MON_SLIDES || gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].func != Task_ProgressCreditTasks) break; - r2 = sub_8177224(gUnknown_0203BCE8->unk0[gUnknown_0203BCE8->unk92], gUnknown_085E6F7C[gUnknown_0203BCE8->unk90][0], gUnknown_085E6F7C[gUnknown_0203BCE8->unk90][1], gUnknown_0203BCE8->unk90); - if (gUnknown_0203BCE8->unk92 < gUnknown_0203BCE8->unk94 - 1) + r2 = MakeMonSprite(sCreditsData->monToShow[sCreditsData->currShownMon], sMonSpritePos[sCreditsData->nextImgPos][0], sMonSpritePos[sCreditsData->nextImgPos][1], sCreditsData->nextImgPos); + if (sCreditsData->currShownMon < sCreditsData->numMonToShow - 1) { - gUnknown_0203BCE8->unk92++; + sCreditsData->currShownMon++; gSprites[r2].data[3] = 50; } else { - gUnknown_0203BCE8->unk92 = 0; + sCreditsData->currShownMon = 0; gSprites[r2].data[3] = 512; } - gUnknown_0203BCE8->unk8E++; - if (gUnknown_0203BCE8->unk90 == 2) - gUnknown_0203BCE8->unk90 = 0; + sCreditsData->imgCounter++; + if (sCreditsData->nextImgPos == 2) + sCreditsData->nextImgPos = 0; else - gUnknown_0203BCE8->unk90++; + sCreditsData->nextImgPos++; gTasks[taskIdD].data[TDD_3] = 50; gTasks[taskIdD].data[TDD_STATE]++; break; @@ -2256,7 +2257,7 @@ static void sub_8177050(struct Sprite *sprite) } } -static u8 sub_8177224(u16 nationalDexNum, s16 x, s16 y, u16 position) +static u8 MakeMonSprite(u16 nationalDexNum, s16 x, s16 y, u16 position) { u8 spriteId; u8 spriteId2; @@ -2292,73 +2293,86 @@ static void sub_81772B8(struct Sprite *sprite) sprite->pos1.y = gSprites[sprite->data[0]].pos1.y; } -static void sub_8177388(void) +static void DeterminePokemonToShow(void) { u16 starter = SpeciesToNationalPokedexNum(GetStarterPokemon(VarGet(VAR_STARTER_MON))); u16 page; u16 dexNum; u16 j; - + + // Go through the Pokedex, and anything that has gotten caught we put into our massive array. + // This basically packs all of the caught pokemon into the front of the array for (dexNum = 1, j = 0; dexNum < NATIONAL_DEX_COUNT; dexNum++) { if (GetSetPokedexFlag(dexNum, FLAG_GET_CAUGHT)) { - gUnknown_0203BCE8->unk96[j] = dexNum; + sCreditsData->caughtMonIds[j] = dexNum; j++; } } + // Fill the rest of the array with zeroes for (dexNum = j; dexNum < NATIONAL_DEX_COUNT; dexNum++) - gUnknown_0203BCE8->unk96[dexNum] = 0; + sCreditsData->caughtMonIds[dexNum] = 0; - gUnknown_0203BCE8->unk39A = j; - if (gUnknown_0203BCE8->unk39A < 71) - gUnknown_0203BCE8->unk94 = j; + // Cap the number of pokemon we care about to NUM_MON_SLIDES, the max we show in the credits scene (-1 for the starter) + sCreditsData->numCaughtMon = j; + if (sCreditsData->numCaughtMon < NUM_MON_SLIDES) + sCreditsData->numMonToShow = j; else - gUnknown_0203BCE8->unk94 = 71; + sCreditsData->numMonToShow = NUM_MON_SLIDES; + // Loop through our list of caught pokemon and select randomly from it to fill the images to show j = 0; do { - page = Random() % gUnknown_0203BCE8->unk39A; - gUnknown_0203BCE8->unk0[j] = gUnknown_0203BCE8->unk96[page]; - + // Select a random mon, insert into array + page = Random() % sCreditsData->numCaughtMon; + sCreditsData->monToShow[j] = sCreditsData->caughtMonIds[page]; + + // Remove the select mon from the array, and condense array entries j++; - gUnknown_0203BCE8->unk96[page] = 0; - gUnknown_0203BCE8->unk39A--; - if (page != gUnknown_0203BCE8->unk39A) + sCreditsData->caughtMonIds[page] = 0; + sCreditsData->numCaughtMon--; + if (page != sCreditsData->numCaughtMon) { - gUnknown_0203BCE8->unk96[page] = gUnknown_0203BCE8->unk96[gUnknown_0203BCE8->unk39A]; - gUnknown_0203BCE8->unk96[gUnknown_0203BCE8->unk39A] = 0; + // Instead of looping through and moving everything down, just take from the end. Order doesn't matter after all. + sCreditsData->caughtMonIds[page] = sCreditsData->caughtMonIds[sCreditsData->numCaughtMon]; + sCreditsData->caughtMonIds[sCreditsData->numCaughtMon] = 0; } } - while (gUnknown_0203BCE8->unk39A != 0 && j < 71); + while (sCreditsData->numCaughtMon != 0 && j < NUM_MON_SLIDES); - if (gUnknown_0203BCE8->unk94 < 71) + // If we don't have enough pokemon in the dex to fill everything, copy the selected mon into the end of the array, so it loops + if (sCreditsData->numMonToShow < NUM_MON_SLIDES) { - for (j = gUnknown_0203BCE8->unk94, page = 0; j < 71; j++) + for (j = sCreditsData->numMonToShow, page = 0; j < NUM_MON_SLIDES; j++) { - gUnknown_0203BCE8->unk0[j] = gUnknown_0203BCE8->unk0[page]; + sCreditsData->monToShow[j] = sCreditsData->monToShow[page]; page++; - if (page == gUnknown_0203BCE8->unk94) + if (page == sCreditsData->numMonToShow) page = 0; } - gUnknown_0203BCE8->unk0[70] = starter; + // Ensure the last pokemon is our starter + sCreditsData->monToShow[NUM_MON_SLIDES-1] = starter; } else { - for (dexNum = 0; gUnknown_0203BCE8->unk0[dexNum] != starter && dexNum < 71; dexNum++); + // Check to see if our starter has already appeared in this list, break if it has + for (dexNum = 0; sCreditsData->monToShow[dexNum] != starter && dexNum < NUM_MON_SLIDES; dexNum++); - if (dexNum < gUnknown_0203BCE8->unk94 - 1) + // If it has, swap it with the last pokemon, to ensure our starter is the last image + if (dexNum < sCreditsData->numMonToShow - 1) { - gUnknown_0203BCE8->unk0[dexNum] = gUnknown_0203BCE8->unk0[70]; - gUnknown_0203BCE8->unk0[70] = starter; + sCreditsData->monToShow[dexNum] = sCreditsData->monToShow[NUM_MON_SLIDES-1]; + sCreditsData->monToShow[NUM_MON_SLIDES-1] = starter; } else { - gUnknown_0203BCE8->unk0[70] = starter; + // Ensure the last pokemon is our starter + sCreditsData->monToShow[NUM_MON_SLIDES-1] = starter; } } - gUnknown_0203BCE8->unk94 = 71; + sCreditsData->numMonToShow = NUM_MON_SLIDES; } diff --git a/src/data/battle_frontier/apprentice.h b/src/data/battle_frontier/apprentice.h new file mode 100644 index 000000000..0fdb87f96 --- /dev/null +++ b/src/data/battle_frontier/apprentice.h @@ -0,0 +1,982 @@ +// data/text/apprentice.inc +extern const u8 gText_ApprenticePleaseTeach0[]; +extern const u8 gText_ApprenticePleaseTeach1[]; +extern const u8 gText_ApprenticePleaseTeach2[]; +extern const u8 gText_ApprenticePleaseTeach3[]; +extern const u8 gText_ApprenticePleaseTeach4[]; +extern const u8 gText_ApprenticePleaseTeach5[]; +extern const u8 gText_ApprenticePleaseTeach6[]; +extern const u8 gText_ApprenticePleaseTeach7[]; +extern const u8 gText_ApprenticePleaseTeach8[]; +extern const u8 gText_ApprenticePleaseTeach9[]; +extern const u8 gText_ApprenticePleaseTeach10[]; +extern const u8 gText_ApprenticePleaseTeach11[]; +extern const u8 gText_ApprenticePleaseTeach12[]; +extern const u8 gText_ApprenticePleaseTeach13[]; +extern const u8 gText_ApprenticePleaseTeach14[]; +extern const u8 gText_ApprenticePleaseTeach15[]; +extern const u8 gText_ApprenticeRejectTeaching0[]; +extern const u8 gText_ApprenticeRejectTeaching1[]; +extern const u8 gText_ApprenticeRejectTeaching2[]; +extern const u8 gText_ApprenticeRejectTeaching3[]; +extern const u8 gText_ApprenticeRejectTeaching4[]; +extern const u8 gText_ApprenticeRejectTeaching5[]; +extern const u8 gText_ApprenticeRejectTeaching6[]; +extern const u8 gText_ApprenticeRejectTeaching7[]; +extern const u8 gText_ApprenticeRejectTeaching8[]; +extern const u8 gText_ApprenticeRejectTeaching9[]; +extern const u8 gText_ApprenticeRejectTeaching10[]; +extern const u8 gText_ApprenticeRejectTeaching11[]; +extern const u8 gText_ApprenticeRejectTeaching12[]; +extern const u8 gText_ApprenticeRejectTeaching13[]; +extern const u8 gText_ApprenticeRejectTeaching14[]; +extern const u8 gText_ApprenticeRejectTeaching15[]; +extern const u8 gText_ApprenticeWhichLevelMode0[]; +extern const u8 gText_ApprenticeWhichLevelMode1[]; +extern const u8 gText_ApprenticeWhichLevelMode2[]; +extern const u8 gText_ApprenticeWhichLevelMode3[]; +extern const u8 gText_ApprenticeWhichLevelMode4[]; +extern const u8 gText_ApprenticeWhichLevelMode5[]; +extern const u8 gText_ApprenticeWhichLevelMode6[]; +extern const u8 gText_ApprenticeWhichLevelMode7[]; +extern const u8 gText_ApprenticeWhichLevelMode8[]; +extern const u8 gText_ApprenticeWhichLevelMode9[]; +extern const u8 gText_ApprenticeWhichLevelMode10[]; +extern const u8 gText_ApprenticeWhichLevelMode11[]; +extern const u8 gText_ApprenticeWhichLevelMode12[]; +extern const u8 gText_ApprenticeWhichLevelMode13[]; +extern const u8 gText_ApprenticeWhichLevelMode14[]; +extern const u8 gText_ApprenticeWhichLevelMode15[]; +extern const u8 gText_ApprenticeLevelModeThanks0[]; +extern const u8 gText_ApprenticeLevelModeThanks1[]; +extern const u8 gText_ApprenticeLevelModeThanks2[]; +extern const u8 gText_ApprenticeLevelModeThanks3[]; +extern const u8 gText_ApprenticeLevelModeThanks4[]; +extern const u8 gText_ApprenticeLevelModeThanks5[]; +extern const u8 gText_ApprenticeLevelModeThanks6[]; +extern const u8 gText_ApprenticeLevelModeThanks7[]; +extern const u8 gText_ApprenticeLevelModeThanks8[]; +extern const u8 gText_ApprenticeLevelModeThanks9[]; +extern const u8 gText_ApprenticeLevelModeThanks10[]; +extern const u8 gText_ApprenticeLevelModeThanks11[]; +extern const u8 gText_ApprenticeLevelModeThanks12[]; +extern const u8 gText_ApprenticeLevelModeThanks13[]; +extern const u8 gText_ApprenticeLevelModeThanks14[]; +extern const u8 gText_ApprenticeLevelModeThanks15[]; + +extern const u8 gText_ApprenticeWhichMon0[]; +extern const u8 gText_ApprenticeWhichMon1[]; +extern const u8 gText_ApprenticeWhichMon2[]; +extern const u8 gText_ApprenticeWhichMon3[]; +extern const u8 gText_ApprenticeWhichMon4[]; +extern const u8 gText_ApprenticeWhichMon5[]; +extern const u8 gText_ApprenticeWhichMon6[]; +extern const u8 gText_ApprenticeWhichMon7[]; +extern const u8 gText_ApprenticeWhichMon8[]; +extern const u8 gText_ApprenticeWhichMon9[]; +extern const u8 gText_ApprenticeWhichMon10[]; +extern const u8 gText_ApprenticeWhichMon11[]; +extern const u8 gText_ApprenticeWhichMon12[]; +extern const u8 gText_ApprenticeWhichMon13[]; +extern const u8 gText_ApprenticeWhichMon14[]; +extern const u8 gText_ApprenticeWhichMon15[]; +extern const u8 gText_ApprenticeMonThanks0[]; +extern const u8 gText_ApprenticeMonThanks1[]; +extern const u8 gText_ApprenticeMonThanks2[]; +extern const u8 gText_ApprenticeMonThanks3[]; +extern const u8 gText_ApprenticeMonThanks4[]; +extern const u8 gText_ApprenticeMonThanks5[]; +extern const u8 gText_ApprenticeMonThanks6[]; +extern const u8 gText_ApprenticeMonThanks7[]; +extern const u8 gText_ApprenticeMonThanks8[]; +extern const u8 gText_ApprenticeMonThanks9[]; +extern const u8 gText_ApprenticeMonThanks10[]; +extern const u8 gText_ApprenticeMonThanks11[]; +extern const u8 gText_ApprenticeMonThanks12[]; +extern const u8 gText_ApprenticeMonThanks13[]; +extern const u8 gText_ApprenticeMonThanks14[]; +extern const u8 gText_ApprenticeMonThanks15[]; + +extern const u8 gText_ApprenticeWhatHeldItem0[]; +extern const u8 gText_ApprenticeWhatHeldItem1[]; +extern const u8 gText_ApprenticeWhatHeldItem2[]; +extern const u8 gText_ApprenticeWhatHeldItem3[]; +extern const u8 gText_ApprenticeWhatHeldItem4[]; +extern const u8 gText_ApprenticeWhatHeldItem5[]; +extern const u8 gText_ApprenticeWhatHeldItem6[]; +extern const u8 gText_ApprenticeWhatHeldItem7[]; +extern const u8 gText_ApprenticeWhatHeldItem8[]; +extern const u8 gText_ApprenticeWhatHeldItem9[]; +extern const u8 gText_ApprenticeWhatHeldItem10[]; +extern const u8 gText_ApprenticeWhatHeldItem11[]; +extern const u8 gText_ApprenticeWhatHeldItem12[]; +extern const u8 gText_ApprenticeWhatHeldItem13[]; +extern const u8 gText_ApprenticeWhatHeldItem14[]; +extern const u8 gText_ApprenticeWhatHeldItem15[]; +extern const u8 gText_ApprenticeHoldNothing0[]; +extern const u8 gText_ApprenticeHoldNothing1[]; +extern const u8 gText_ApprenticeHoldNothing2[]; +extern const u8 gText_ApprenticeHoldNothing3[]; +extern const u8 gText_ApprenticeHoldNothing4[]; +extern const u8 gText_ApprenticeHoldNothing5[]; +extern const u8 gText_ApprenticeHoldNothing6[]; +extern const u8 gText_ApprenticeHoldNothing7[]; +extern const u8 gText_ApprenticeHoldNothing8[]; +extern const u8 gText_ApprenticeHoldNothing9[]; +extern const u8 gText_ApprenticeHoldNothing10[]; +extern const u8 gText_ApprenticeHoldNothing11[]; +extern const u8 gText_ApprenticeHoldNothing12[]; +extern const u8 gText_ApprenticeHoldNothing13[]; +extern const u8 gText_ApprenticeHoldNothing14[]; +extern const u8 gText_ApprenticeHoldNothing15[]; +extern const u8 gText_ApprenticeThanksNoHeldItem0[]; +extern const u8 gText_ApprenticeThanksNoHeldItem1[]; +extern const u8 gText_ApprenticeThanksNoHeldItem2[]; +extern const u8 gText_ApprenticeThanksNoHeldItem3[]; +extern const u8 gText_ApprenticeThanksNoHeldItem4[]; +extern const u8 gText_ApprenticeThanksNoHeldItem5[]; +extern const u8 gText_ApprenticeThanksNoHeldItem6[]; +extern const u8 gText_ApprenticeThanksNoHeldItem7[]; +extern const u8 gText_ApprenticeThanksNoHeldItem8[]; +extern const u8 gText_ApprenticeThanksNoHeldItem9[]; +extern const u8 gText_ApprenticeThanksNoHeldItem10[]; +extern const u8 gText_ApprenticeThanksNoHeldItem11[]; +extern const u8 gText_ApprenticeThanksNoHeldItem12[]; +extern const u8 gText_ApprenticeThanksNoHeldItem13[]; +extern const u8 gText_ApprenticeThanksNoHeldItem14[]; +extern const u8 gText_ApprenticeThanksNoHeldItem15[]; +extern const u8 gText_ApprenticeThanksHeldItem0[]; +extern const u8 gText_ApprenticeThanksHeldItem1[]; +extern const u8 gText_ApprenticeThanksHeldItem2[]; +extern const u8 gText_ApprenticeThanksHeldItem3[]; +extern const u8 gText_ApprenticeThanksHeldItem4[]; +extern const u8 gText_ApprenticeThanksHeldItem5[]; +extern const u8 gText_ApprenticeThanksHeldItem6[]; +extern const u8 gText_ApprenticeThanksHeldItem7[]; +extern const u8 gText_ApprenticeThanksHeldItem8[]; +extern const u8 gText_ApprenticeThanksHeldItem9[]; +extern const u8 gText_ApprenticeThanksHeldItem10[]; +extern const u8 gText_ApprenticeThanksHeldItem11[]; +extern const u8 gText_ApprenticeThanksHeldItem12[]; +extern const u8 gText_ApprenticeThanksHeldItem13[]; +extern const u8 gText_ApprenticeThanksHeldItem14[]; +extern const u8 gText_ApprenticeThanksHeldItem15[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended0[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended1[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended2[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended3[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended4[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended5[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended6[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended7[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended8[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended9[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended10[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended11[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended12[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended13[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended14[]; +extern const u8 gText_ApprenticeItemAlreadyRecommended15[]; + +extern const u8 gText_ApprenticeWhichMove0[]; +extern const u8 gText_ApprenticeWhichMove1[]; +extern const u8 gText_ApprenticeWhichMove2[]; +extern const u8 gText_ApprenticeWhichMove3[]; +extern const u8 gText_ApprenticeWhichMove4[]; +extern const u8 gText_ApprenticeWhichMove5[]; +extern const u8 gText_ApprenticeWhichMove6[]; +extern const u8 gText_ApprenticeWhichMove7[]; +extern const u8 gText_ApprenticeWhichMove8[]; +extern const u8 gText_ApprenticeWhichMove9[]; +extern const u8 gText_ApprenticeWhichMove10[]; +extern const u8 gText_ApprenticeWhichMove11[]; +extern const u8 gText_ApprenticeWhichMove12[]; +extern const u8 gText_ApprenticeWhichMove13[]; +extern const u8 gText_ApprenticeWhichMove14[]; +extern const u8 gText_ApprenticeWhichMove15[]; +extern const u8 gText_ApprenticeMoveThanks0[]; +extern const u8 gText_ApprenticeMoveThanks1[]; +extern const u8 gText_ApprenticeMoveThanks2[]; +extern const u8 gText_ApprenticeMoveThanks3[]; +extern const u8 gText_ApprenticeMoveThanks4[]; +extern const u8 gText_ApprenticeMoveThanks5[]; +extern const u8 gText_ApprenticeMoveThanks6[]; +extern const u8 gText_ApprenticeMoveThanks7[]; +extern const u8 gText_ApprenticeMoveThanks8[]; +extern const u8 gText_ApprenticeMoveThanks9[]; +extern const u8 gText_ApprenticeMoveThanks10[]; +extern const u8 gText_ApprenticeMoveThanks11[]; +extern const u8 gText_ApprenticeMoveThanks12[]; +extern const u8 gText_ApprenticeMoveThanks13[]; +extern const u8 gText_ApprenticeMoveThanks14[]; +extern const u8 gText_ApprenticeMoveThanks15[]; + +extern const u8 gText_ApprenticeWhichMonFirst0[]; +extern const u8 gText_ApprenticeWhichMonFirst1[]; +extern const u8 gText_ApprenticeWhichMonFirst2[]; +extern const u8 gText_ApprenticeWhichMonFirst3[]; +extern const u8 gText_ApprenticeWhichMonFirst4[]; +extern const u8 gText_ApprenticeWhichMonFirst5[]; +extern const u8 gText_ApprenticeWhichMonFirst6[]; +extern const u8 gText_ApprenticeWhichMonFirst7[]; +extern const u8 gText_ApprenticeWhichMonFirst8[]; +extern const u8 gText_ApprenticeWhichMonFirst9[]; +extern const u8 gText_ApprenticeWhichMonFirst10[]; +extern const u8 gText_ApprenticeWhichMonFirst11[]; +extern const u8 gText_ApprenticeWhichMonFirst12[]; +extern const u8 gText_ApprenticeWhichMonFirst13[]; +extern const u8 gText_ApprenticeWhichMonFirst14[]; +extern const u8 gText_ApprenticeWhichMonFirst15[]; +extern const u8 gText_ApprenticeMonFirstThanks0[]; +extern const u8 gText_ApprenticeMonFirstThanks1[]; +extern const u8 gText_ApprenticeMonFirstThanks2[]; +extern const u8 gText_ApprenticeMonFirstThanks3[]; +extern const u8 gText_ApprenticeMonFirstThanks4[]; +extern const u8 gText_ApprenticeMonFirstThanks5[]; +extern const u8 gText_ApprenticeMonFirstThanks6[]; +extern const u8 gText_ApprenticeMonFirstThanks7[]; +extern const u8 gText_ApprenticeMonFirstThanks8[]; +extern const u8 gText_ApprenticeMonFirstThanks9[]; +extern const u8 gText_ApprenticeMonFirstThanks10[]; +extern const u8 gText_ApprenticeMonFirstThanks11[]; +extern const u8 gText_ApprenticeMonFirstThanks12[]; +extern const u8 gText_ApprenticeMonFirstThanks13[]; +extern const u8 gText_ApprenticeMonFirstThanks14[]; +extern const u8 gText_ApprenticeMonFirstThanks15[]; + +extern const u8 gText_ApprenticePickWinSpeech0[]; +extern const u8 gText_ApprenticePickWinSpeech1[]; +extern const u8 gText_ApprenticePickWinSpeech2[]; +extern const u8 gText_ApprenticePickWinSpeech3[]; +extern const u8 gText_ApprenticePickWinSpeech4[]; +extern const u8 gText_ApprenticePickWinSpeech5[]; +extern const u8 gText_ApprenticePickWinSpeech6[]; +extern const u8 gText_ApprenticePickWinSpeech7[]; +extern const u8 gText_ApprenticePickWinSpeech8[]; +extern const u8 gText_ApprenticePickWinSpeech9[]; +extern const u8 gText_ApprenticePickWinSpeech10[]; +extern const u8 gText_ApprenticePickWinSpeech11[]; +extern const u8 gText_ApprenticePickWinSpeech12[]; +extern const u8 gText_ApprenticePickWinSpeech13[]; +extern const u8 gText_ApprenticePickWinSpeech14[]; +extern const u8 gText_ApprenticePickWinSpeech15[]; +extern const u8 gText_ApprenticeWinSpeechThanks0[]; +extern const u8 gText_ApprenticeWinSpeechThanks1[]; +extern const u8 gText_ApprenticeWinSpeechThanks2[]; +extern const u8 gText_ApprenticeWinSpeechThanks3[]; +extern const u8 gText_ApprenticeWinSpeechThanks4[]; +extern const u8 gText_ApprenticeWinSpeechThanks5[]; +extern const u8 gText_ApprenticeWinSpeechThanks6[]; +extern const u8 gText_ApprenticeWinSpeechThanks7[]; +extern const u8 gText_ApprenticeWinSpeechThanks8[]; +extern const u8 gText_ApprenticeWinSpeechThanks9[]; +extern const u8 gText_ApprenticeWinSpeechThanks10[]; +extern const u8 gText_ApprenticeWinSpeechThanks11[]; +extern const u8 gText_ApprenticeWinSpeechThanks12[]; +extern const u8 gText_ApprenticeWinSpeechThanks13[]; +extern const u8 gText_ApprenticeWinSpeechThanks14[]; +extern const u8 gText_ApprenticeWinSpeechThanks15[]; + +extern const u8 gText_ApprenticeChallenge0[]; +extern const u8 gText_ApprenticeChallenge1[]; +extern const u8 gText_ApprenticeChallenge2[]; +extern const u8 gText_ApprenticeChallenge3[]; +extern const u8 gText_ApprenticeChallenge4[]; +extern const u8 gText_ApprenticeChallenge5[]; +extern const u8 gText_ApprenticeChallenge6[]; +extern const u8 gText_ApprenticeChallenge7[]; +extern const u8 gText_ApprenticeChallenge8[]; +extern const u8 gText_ApprenticeChallenge9[]; +extern const u8 gText_ApprenticeChallenge10[]; +extern const u8 gText_ApprenticeChallenge11[]; +extern const u8 gText_ApprenticeChallenge12[]; +extern const u8 gText_ApprenticeChallenge13[]; +extern const u8 gText_ApprenticeChallenge14[]; +extern const u8 gText_ApprenticeChallenge15[]; + +const struct ApprenticeTrainer gApprentices[NUM_APPRENTICES] = +{ + { + .name = {_("サダヒロ"), _("ALANN"), _("ALAIN"), _("ADELFO"), _("CLAUS"), _("TEO")}, + .otId = 0xBDC9, + .facilityClass = FACILITY_CLASS_BUG_CATCHER, + .species = {SPECIES_BEAUTIFLY, SPECIES_DUSTOX, SPECIES_ILLUMISE, SPECIES_SHIFTRY, SPECIES_BRELOOM, SPECIES_NINJASK, SPECIES_SHEDINJA, SPECIES_PINSIR, SPECIES_HERACROSS, SPECIES_VOLBEAT}, + .id = 0, + .speechLost = {EC_WORD_NO, EC_WORD_MISTAKE, EC_WORD_EXCL, EC_WORD_I, EC_WORD_LOST, EC_WORD_BADLY}, + }, + { + .name = {_("ヒロオ"), _("LIONEL"), _("LIONEL"), _("CAIO"), _("LUDWIG"), _("LEO")}, + .otId = 0xCF09, + .facilityClass = FACILITY_CLASS_YOUNGSTER, + .species = {SPECIES_SWELLOW, SPECIES_SWALOT, SPECIES_SHUCKLE, SPECIES_MANECTRIC, SPECIES_TORKOAL, SPECIES_HARIYAMA, SPECIES_MIGHTYENA, SPECIES_LUDICOLO, SPECIES_CRAWDAUNT, SPECIES_WHISCASH}, + .id = 1, + .speechLost = {EC_WORD_OKAY, EC_WORD_I, EC_WORD_LOST, EC_WORD_YOU_RE, EC_WORD_A, EC_WORD_MASTER}, + }, + { + .name = {_("ケイジ"), _("SONNY"), _("HERVE"), _("FEDRO"), _("WENZEL"), _("SANTI")}, + .otId = 0x2E34, + .facilityClass = FACILITY_CLASS_SCHOOL_KID_M, + .species = {SPECIES_LINOONE, SPECIES_MIGHTYENA, SPECIES_WHISCASH, SPECIES_ZANGOOSE, SPECIES_SEVIPER, SPECIES_NINETALES, SPECIES_KECLEON, SPECIES_SHUCKLE, SPECIES_MANECTRIC, SPECIES_MACHAMP}, + .id = 2, + .speechLost = {EC_WORD_I, EC_WORD_WENT, EC_WORD_AND, EC_WORD_LOST, EC_WORD_AWW, EC_WORD_ELLIPSIS}, + }, + { + .name = {_("ユラ"), _("LAYLA"), _("LAYLA"), _("ASTRID"), _("SONJA"), _("LOLA")}, + .otId = 0x84EF, + .facilityClass = FACILITY_CLASS_LASS, + .species = {SPECIES_SWALOT, SPECIES_XATU, SPECIES_ALTARIA, SPECIES_GOLDUCK, SPECIES_FLYGON, SPECIES_ALAKAZAM, SPECIES_GARDEVOIR, SPECIES_WAILORD, SPECIES_GRUMPIG, SPECIES_MIGHTYENA}, + .id = 3, + .speechLost = {EC_WORD_IS, EC_WORD_THIS, EC_WORD_TOO, EC_WORD_MUCH, EC_WORD_QUES, 0xFFFF}, + }, + { + .name = {_("ヨウカ"), _("MACY"), _("AMELIE"), _("CLEO"), _("MARIA"), _("ELISA")}, + .otId = 0x1E43, + .facilityClass = FACILITY_CLASS_SCHOOL_KID_F, + .species = {SPECIES_WIGGLYTUFF, SPECIES_LINOONE, SPECIES_KINGDRA, SPECIES_DELCATTY, SPECIES_RAICHU, SPECIES_FEAROW, SPECIES_STARMIE, SPECIES_MEDICHAM, SPECIES_SHIFTRY, SPECIES_BEAUTIFLY}, + .id = 4, + .speechLost = {EC_WORD_THIS, EC_WORD_WON_T, EC_WORD_BE, EC_WORD_HAPPENING, EC_WORD_NEXT, EC_WORD_TIME}, + }, + { + .name = {_("ヤスシ"), _("DONTE"), _("BRAHIM"), _("GLAUCO"), _("JOSEF"), _("ROQUE")}, + .otId = 0x379F, + .facilityClass = FACILITY_CLASS_RUNNING_TRIATHLETE_M, + .species = {SPECIES_STARMIE, SPECIES_DODRIO, SPECIES_AGGRON, SPECIES_MAGNETON, SPECIES_MACHAMP, SPECIES_ARMALDO, SPECIES_HERACROSS, SPECIES_NOSEPASS, SPECIES_EXPLOUD, SPECIES_MIGHTYENA}, + .id = 5, + .speechLost = {EC_WORD_I_AM, EC_WORD_GOING, EC_WORD_TO, EC_WORD_RUN, EC_WORD_BYE_BYE, EC_WORD_EXCL}, + }, + { + .name = {_("ミサオ"), _("AMIRA"), _("LAURE"), _("DAFNE"), _("AMELIE"), _("LARA")}, + .otId = 0xF555, + .facilityClass = FACILITY_CLASS_RUNNING_TRIATHLETE_F, + .species = {SPECIES_STARMIE, SPECIES_DODRIO, SPECIES_MAGNETON, SPECIES_MEDICHAM, SPECIES_MIGHTYENA, SPECIES_GLALIE, SPECIES_GOLEM, SPECIES_ELECTRODE, SPECIES_PELIPPER, SPECIES_SHARPEDO}, + .id = 6, + .speechLost = {EC_WORD_AHAHA, EC_WORD_DEFEATED, EC_WORD_EXCL, EC_WORD_IT_S, EC_WORD_NOTHING, EC_WORD_EXCL}, + }, + { + .name = {_("カズサ"), _("KALI"), _("JODIE"), _("ILENIA"), _("KARO"), _("ELSA")}, + .otId = 0x8D26, + .facilityClass = FACILITY_CLASS_BEAUTY, + .species = {SPECIES_NINETALES, SPECIES_ALAKAZAM, SPECIES_SCEPTILE, SPECIES_SALAMENCE, SPECIES_GOLDUCK, SPECIES_MAWILE, SPECIES_WEEZING, SPECIES_LANTURN, SPECIES_GARDEVOIR, SPECIES_MILOTIC}, + .id = 7, + .speechLost = {EC_WORD_YOU_RE, EC_WORD_STRONG, EC_WORD_AREN_T, EC_WORD_YOU, EC_WORD_QUES, 0xFFFF}, + }, + { + .name = {_("スミレ"), _("ANNIE"), _("ANNIE"), _("IMELDA"), _("INES"), _("ROSA")}, + .otId = 0x800C, + .facilityClass = FACILITY_CLASS_AROMA_LADY, + .species = {SPECIES_SCEPTILE, SPECIES_VILEPLUME, SPECIES_BELLOSSOM, SPECIES_ROSELIA, SPECIES_CORSOLA, SPECIES_FLYGON, SPECIES_BRELOOM, SPECIES_MILOTIC, SPECIES_ALTARIA, SPECIES_CRADILY}, + .id = 8, + .speechLost = {EC_WORD_WHAT, EC_WORD_TOUGH, EC_WORD_POKEMON, EC_WORD_YOU, EC_WORD_HAVE, EC_WORD_EXCL}, + }, + { + .name = {_("アキノリ"), _("DILLEN"), _("RENE"), _("INDRO"), _("DETLEF"), _("PEDRO")}, + .otId = 0x469f, + .facilityClass = FACILITY_CLASS_HIKER, + .species = {SPECIES_SKARMORY, SPECIES_GOLEM, SPECIES_BLAZIKEN, SPECIES_CAMERUPT, SPECIES_DONPHAN, SPECIES_MUK, SPECIES_SALAMENCE, SPECIES_TROPIUS, SPECIES_SOLROCK, SPECIES_RHYDON}, + .id = 9, + .speechLost = {EC_WORD_WE, EC_WORD_WERE, EC_WORD_JUST, EC_WORD_SHREDDED, EC_WORD_ELLIPSIS, 0xFFFF}, + }, + { + .name = {_("トウゾウ"), _("DALLAS"), _("BRUNO"), _("LEARCO"), _("ANSGAR"), _("MANOLO")}, + .otId = 0x71FC, + .facilityClass = FACILITY_CLASS_FISHERMAN, + .species = {SPECIES_SEAKING, SPECIES_STARMIE, SPECIES_GOLDUCK, SPECIES_TENTACRUEL, SPECIES_OCTILLERY, SPECIES_GOREBYSS, SPECIES_GLALIE, SPECIES_WAILORD, SPECIES_SHARPEDO, SPECIES_KINGDRA}, + .id = 10, + .speechLost = {EC_WORD_YOUR, EC_WORD_WIN, EC_WORD_ANGERS, EC_WORD_ME, EC_WORD_EXCL, 0xFFFF}, + }, + { + .name = {_("セイヤ"), _("FRANK"), _("FRANK"), _("OLINDO"), _("FRANK"), _("MAURO")}, + .otId = 0xA39E, + .facilityClass = FACILITY_CLASS_SAILOR, + .species = {SPECIES_QUAGSIRE, SPECIES_STARMIE, SPECIES_PELIPPER, SPECIES_CRAWDAUNT, SPECIES_WAILORD, SPECIES_GYARADOS, SPECIES_SWAMPERT, SPECIES_LANTURN, SPECIES_WHISCASH, SPECIES_SHUCKLE}, + .id = 11, + .speechLost = {EC_WORD_LOSING, EC_WORD_DOESN_T, EC_MOVE(CUT), EC_WORD_ME, EC_WORD_DEEP, EC_WORD_OK_QUES}, + }, + { + .name = {_("リュウジ"), _("LAMONT"), _("XAV"), _("ORFEO"), _("JÜRGEN"), _("JORGE")}, + .otId = 0xE590, + .facilityClass = FACILITY_CLASS_GUITARIST, + .species = {SPECIES_ABSOL, SPECIES_CROBAT, SPECIES_EXPLOUD, SPECIES_MAGNETON, SPECIES_SHARPEDO, SPECIES_MANECTRIC, SPECIES_METAGROSS, SPECIES_ELECTRODE, SPECIES_NOSEPASS, SPECIES_WEEZING}, + .id = 12, + .speechLost = {EC_WORD_A, EC_WORD_LOSS, EC_WORD_IS, EC_WORD_WHAT, EC_WORD_THIS, EC_WORD_IS}, + }, + { + .name = {_("カツアキ"), _("TYRESE"), _("ANDY"), _("PARIDE"), _("DAVID"), _("CHICHO")}, + .otId = 0xD018, + .facilityClass = FACILITY_CLASS_BLACK_BELT, + .species = {SPECIES_BLAZIKEN, SPECIES_GOLEM, SPECIES_MACHAMP, SPECIES_RHYDON, SPECIES_HARIYAMA, SPECIES_AGGRON, SPECIES_MEDICHAM, SPECIES_ZANGOOSE, SPECIES_VIGOROTH, SPECIES_SLAKING}, + .id = 13, + .speechLost = {EC_WORD_I_AM, EC_WORD_TOO_WEAK, EC_WORD_AND, EC_WORD_LOW, EC_WORD_OF, EC_WORD_POWER}, + }, + { + .name = {_("トシミツ"), _("DANTE"), _("DANTE"), _("RAOUL"), _("LOTHAR"), _("PABLO")}, + .otId = 0xBC75, + .facilityClass = FACILITY_CLASS_RUIN_MANIAC, + .species = {SPECIES_SCEPTILE, SPECIES_SANDSLASH, SPECIES_FLYGON, SPECIES_CLAYDOL, SPECIES_ARMALDO, SPECIES_CROBAT, SPECIES_CRADILY, SPECIES_SOLROCK, SPECIES_LUNATONE, SPECIES_GOLEM}, + .id = 14, + .speechLost = {EC_WORD_I, EC_WORD_DON_T, EC_WORD_UNDERSTAND, EC_WORD_WHAT, EC_WORD_IS, EC_WORD_HAPPENING}, + }, + { + .name = {_("ローウェン"), _("ARTURO"), _("ARTURO"), _("ROMOLO"), _("BRIAN"), _("ARTURO")}, + .otId = 0xFA02, + .facilityClass = FACILITY_CLASS_GENTLEMAN, + .species = {SPECIES_ABSOL, SPECIES_MIGHTYENA, SPECIES_ALAKAZAM, SPECIES_BANETTE, SPECIES_NINETALES, SPECIES_CLAYDOL, SPECIES_MUK, SPECIES_SALAMENCE, SPECIES_WALREIN, SPECIES_DUSCLOPS}, + .id = 15, + .speechLost = {EC_WORD_THIS, EC_WORD_HAS, EC_WORD_TO, EC_WORD_BE, EC_WORD_A, EC_WORD_LIE}, + }, +}; + +// Sequence of 4 messages for the first meeting with the apprentice +static const u8 *const sApprenticeFirstMeetingTexts[NUM_APPRENTICES][4] = +{ + {gText_ApprenticePleaseTeach0, gText_ApprenticeRejectTeaching0, gText_ApprenticeWhichLevelMode0, gText_ApprenticeLevelModeThanks0}, + {gText_ApprenticePleaseTeach1, gText_ApprenticeRejectTeaching1, gText_ApprenticeWhichLevelMode1, gText_ApprenticeLevelModeThanks1}, + {gText_ApprenticePleaseTeach2, gText_ApprenticeRejectTeaching2, gText_ApprenticeWhichLevelMode2, gText_ApprenticeLevelModeThanks2}, + {gText_ApprenticePleaseTeach3, gText_ApprenticeRejectTeaching3, gText_ApprenticeWhichLevelMode3, gText_ApprenticeLevelModeThanks3}, + {gText_ApprenticePleaseTeach4, gText_ApprenticeRejectTeaching4, gText_ApprenticeWhichLevelMode4, gText_ApprenticeLevelModeThanks4}, + {gText_ApprenticePleaseTeach5, gText_ApprenticeRejectTeaching5, gText_ApprenticeWhichLevelMode5, gText_ApprenticeLevelModeThanks5}, + {gText_ApprenticePleaseTeach6, gText_ApprenticeRejectTeaching6, gText_ApprenticeWhichLevelMode6, gText_ApprenticeLevelModeThanks6}, + {gText_ApprenticePleaseTeach7, gText_ApprenticeRejectTeaching7, gText_ApprenticeWhichLevelMode7, gText_ApprenticeLevelModeThanks7}, + {gText_ApprenticePleaseTeach8, gText_ApprenticeRejectTeaching8, gText_ApprenticeWhichLevelMode8, gText_ApprenticeLevelModeThanks8}, + {gText_ApprenticePleaseTeach9, gText_ApprenticeRejectTeaching9, gText_ApprenticeWhichLevelMode9, gText_ApprenticeLevelModeThanks9}, + {gText_ApprenticePleaseTeach10, gText_ApprenticeRejectTeaching10, gText_ApprenticeWhichLevelMode10, gText_ApprenticeLevelModeThanks10}, + {gText_ApprenticePleaseTeach11, gText_ApprenticeRejectTeaching11, gText_ApprenticeWhichLevelMode11, gText_ApprenticeLevelModeThanks11}, + {gText_ApprenticePleaseTeach12, gText_ApprenticeRejectTeaching12, gText_ApprenticeWhichLevelMode12, gText_ApprenticeLevelModeThanks12}, + {gText_ApprenticePleaseTeach13, gText_ApprenticeRejectTeaching13, gText_ApprenticeWhichLevelMode13, gText_ApprenticeLevelModeThanks13}, + {gText_ApprenticePleaseTeach14, gText_ApprenticeRejectTeaching14, gText_ApprenticeWhichLevelMode14, gText_ApprenticeLevelModeThanks14}, + {gText_ApprenticePleaseTeach15, gText_ApprenticeRejectTeaching15, gText_ApprenticeWhichLevelMode15, gText_ApprenticeLevelModeThanks15}, +}; + +static const u8 *const sApprenticeWhichMonTexts[NUM_APPRENTICES][2] = +{ + {gText_ApprenticeWhichMon0, gText_ApprenticeMonThanks0}, + {gText_ApprenticeWhichMon1, gText_ApprenticeMonThanks1}, + {gText_ApprenticeWhichMon2, gText_ApprenticeMonThanks2}, + {gText_ApprenticeWhichMon3, gText_ApprenticeMonThanks3}, + {gText_ApprenticeWhichMon4, gText_ApprenticeMonThanks4}, + {gText_ApprenticeWhichMon5, gText_ApprenticeMonThanks5}, + {gText_ApprenticeWhichMon6, gText_ApprenticeMonThanks6}, + {gText_ApprenticeWhichMon7, gText_ApprenticeMonThanks7}, + {gText_ApprenticeWhichMon8, gText_ApprenticeMonThanks8}, + {gText_ApprenticeWhichMon9, gText_ApprenticeMonThanks9}, + {gText_ApprenticeWhichMon10, gText_ApprenticeMonThanks10}, + {gText_ApprenticeWhichMon11, gText_ApprenticeMonThanks11}, + {gText_ApprenticeWhichMon12, gText_ApprenticeMonThanks12}, + {gText_ApprenticeWhichMon13, gText_ApprenticeMonThanks13}, + {gText_ApprenticeWhichMon14, gText_ApprenticeMonThanks14}, + {gText_ApprenticeWhichMon15, gText_ApprenticeMonThanks15}, +}; + +// Sequence of 5 messages for suggesting a held item to the apprentice +static const u8 *const sApprenticeHeldItemTexts[NUM_APPRENTICES][5] = +{ + {gText_ApprenticeWhatHeldItem0, gText_ApprenticeHoldNothing0, gText_ApprenticeThanksNoHeldItem0, gText_ApprenticeThanksHeldItem0, gText_ApprenticeItemAlreadyRecommended0}, + {gText_ApprenticeWhatHeldItem1, gText_ApprenticeHoldNothing1, gText_ApprenticeThanksNoHeldItem1, gText_ApprenticeThanksHeldItem1, gText_ApprenticeItemAlreadyRecommended1}, + {gText_ApprenticeWhatHeldItem2, gText_ApprenticeHoldNothing2, gText_ApprenticeThanksNoHeldItem2, gText_ApprenticeThanksHeldItem2, gText_ApprenticeItemAlreadyRecommended2}, + {gText_ApprenticeWhatHeldItem3, gText_ApprenticeHoldNothing3, gText_ApprenticeThanksNoHeldItem3, gText_ApprenticeThanksHeldItem3, gText_ApprenticeItemAlreadyRecommended3}, + {gText_ApprenticeWhatHeldItem4, gText_ApprenticeHoldNothing4, gText_ApprenticeThanksNoHeldItem4, gText_ApprenticeThanksHeldItem4, gText_ApprenticeItemAlreadyRecommended4}, + {gText_ApprenticeWhatHeldItem5, gText_ApprenticeHoldNothing5, gText_ApprenticeThanksNoHeldItem5, gText_ApprenticeThanksHeldItem5, gText_ApprenticeItemAlreadyRecommended5}, + {gText_ApprenticeWhatHeldItem6, gText_ApprenticeHoldNothing6, gText_ApprenticeThanksNoHeldItem6, gText_ApprenticeThanksHeldItem6, gText_ApprenticeItemAlreadyRecommended6}, + {gText_ApprenticeWhatHeldItem7, gText_ApprenticeHoldNothing7, gText_ApprenticeThanksNoHeldItem7, gText_ApprenticeThanksHeldItem7, gText_ApprenticeItemAlreadyRecommended7}, + {gText_ApprenticeWhatHeldItem8, gText_ApprenticeHoldNothing8, gText_ApprenticeThanksNoHeldItem8, gText_ApprenticeThanksHeldItem8, gText_ApprenticeItemAlreadyRecommended8}, + {gText_ApprenticeWhatHeldItem9, gText_ApprenticeHoldNothing9, gText_ApprenticeThanksNoHeldItem9, gText_ApprenticeThanksHeldItem9, gText_ApprenticeItemAlreadyRecommended9}, + {gText_ApprenticeWhatHeldItem10, gText_ApprenticeHoldNothing10, gText_ApprenticeThanksNoHeldItem10, gText_ApprenticeThanksHeldItem10, gText_ApprenticeItemAlreadyRecommended10}, + {gText_ApprenticeWhatHeldItem11, gText_ApprenticeHoldNothing11, gText_ApprenticeThanksNoHeldItem11, gText_ApprenticeThanksHeldItem11, gText_ApprenticeItemAlreadyRecommended11}, + {gText_ApprenticeWhatHeldItem12, gText_ApprenticeHoldNothing12, gText_ApprenticeThanksNoHeldItem12, gText_ApprenticeThanksHeldItem12, gText_ApprenticeItemAlreadyRecommended12}, + {gText_ApprenticeWhatHeldItem13, gText_ApprenticeHoldNothing13, gText_ApprenticeThanksNoHeldItem13, gText_ApprenticeThanksHeldItem13, gText_ApprenticeItemAlreadyRecommended13}, + {gText_ApprenticeWhatHeldItem14, gText_ApprenticeHoldNothing14, gText_ApprenticeThanksNoHeldItem14, gText_ApprenticeThanksHeldItem14, gText_ApprenticeItemAlreadyRecommended14}, + {gText_ApprenticeWhatHeldItem15, gText_ApprenticeHoldNothing15, gText_ApprenticeThanksNoHeldItem15, gText_ApprenticeThanksHeldItem15, gText_ApprenticeItemAlreadyRecommended15}, +}; + +static const u8 *const sApprenticeWhichMoveTexts[NUM_APPRENTICES][2] = +{ + {gText_ApprenticeWhichMove0, gText_ApprenticeMoveThanks0}, + {gText_ApprenticeWhichMove1, gText_ApprenticeMoveThanks1}, + {gText_ApprenticeWhichMove2, gText_ApprenticeMoveThanks2}, + {gText_ApprenticeWhichMove3, gText_ApprenticeMoveThanks3}, + {gText_ApprenticeWhichMove4, gText_ApprenticeMoveThanks4}, + {gText_ApprenticeWhichMove5, gText_ApprenticeMoveThanks5}, + {gText_ApprenticeWhichMove6, gText_ApprenticeMoveThanks6}, + {gText_ApprenticeWhichMove7, gText_ApprenticeMoveThanks7}, + {gText_ApprenticeWhichMove8, gText_ApprenticeMoveThanks8}, + {gText_ApprenticeWhichMove9, gText_ApprenticeMoveThanks9}, + {gText_ApprenticeWhichMove10, gText_ApprenticeMoveThanks10}, + {gText_ApprenticeWhichMove11, gText_ApprenticeMoveThanks11}, + {gText_ApprenticeWhichMove12, gText_ApprenticeMoveThanks12}, + {gText_ApprenticeWhichMove13, gText_ApprenticeMoveThanks13}, + {gText_ApprenticeWhichMove14, gText_ApprenticeMoveThanks14}, + {gText_ApprenticeWhichMove15, gText_ApprenticeMoveThanks15}, +}; + +static const u8 *const sApprenticeWhichMonFirstTexts[NUM_APPRENTICES][2] = +{ + {gText_ApprenticeWhichMonFirst0, gText_ApprenticeMonFirstThanks0}, + {gText_ApprenticeWhichMonFirst1, gText_ApprenticeMonFirstThanks1}, + {gText_ApprenticeWhichMonFirst2, gText_ApprenticeMonFirstThanks2}, + {gText_ApprenticeWhichMonFirst3, gText_ApprenticeMonFirstThanks3}, + {gText_ApprenticeWhichMonFirst4, gText_ApprenticeMonFirstThanks4}, + {gText_ApprenticeWhichMonFirst5, gText_ApprenticeMonFirstThanks5}, + {gText_ApprenticeWhichMonFirst6, gText_ApprenticeMonFirstThanks6}, + {gText_ApprenticeWhichMonFirst7, gText_ApprenticeMonFirstThanks7}, + {gText_ApprenticeWhichMonFirst8, gText_ApprenticeMonFirstThanks8}, + {gText_ApprenticeWhichMonFirst9, gText_ApprenticeMonFirstThanks9}, + {gText_ApprenticeWhichMonFirst10, gText_ApprenticeMonFirstThanks10}, + {gText_ApprenticeWhichMonFirst11, gText_ApprenticeMonFirstThanks11}, + {gText_ApprenticeWhichMonFirst12, gText_ApprenticeMonFirstThanks12}, + {gText_ApprenticeWhichMonFirst13, gText_ApprenticeMonFirstThanks13}, + {gText_ApprenticeWhichMonFirst14, gText_ApprenticeMonFirstThanks14}, + {gText_ApprenticeWhichMonFirst15, gText_ApprenticeMonFirstThanks15}, +}; + +static const u8 *const sApprenticePickWinSpeechTexts[NUM_APPRENTICES][2] = +{ + {gText_ApprenticePickWinSpeech0, gText_ApprenticeWinSpeechThanks0}, + {gText_ApprenticePickWinSpeech1, gText_ApprenticeWinSpeechThanks1}, + {gText_ApprenticePickWinSpeech2, gText_ApprenticeWinSpeechThanks2}, + {gText_ApprenticePickWinSpeech3, gText_ApprenticeWinSpeechThanks3}, + {gText_ApprenticePickWinSpeech4, gText_ApprenticeWinSpeechThanks4}, + {gText_ApprenticePickWinSpeech5, gText_ApprenticeWinSpeechThanks5}, + {gText_ApprenticePickWinSpeech6, gText_ApprenticeWinSpeechThanks6}, + {gText_ApprenticePickWinSpeech7, gText_ApprenticeWinSpeechThanks7}, + {gText_ApprenticePickWinSpeech8, gText_ApprenticeWinSpeechThanks8}, + {gText_ApprenticePickWinSpeech9, gText_ApprenticeWinSpeechThanks9}, + {gText_ApprenticePickWinSpeech10, gText_ApprenticeWinSpeechThanks10}, + {gText_ApprenticePickWinSpeech11, gText_ApprenticeWinSpeechThanks11}, + {gText_ApprenticePickWinSpeech12, gText_ApprenticeWinSpeechThanks12}, + {gText_ApprenticePickWinSpeech13, gText_ApprenticeWinSpeechThanks13}, + {gText_ApprenticePickWinSpeech14, gText_ApprenticeWinSpeechThanks14}, + {gText_ApprenticePickWinSpeech15, gText_ApprenticeWinSpeechThanks15}, +}; + +static const u8 *const sApprenticeChallengeTexts[NUM_APPRENTICES] = +{ + gText_ApprenticeChallenge0, + gText_ApprenticeChallenge1, + gText_ApprenticeChallenge2, + gText_ApprenticeChallenge3, + gText_ApprenticeChallenge4, + gText_ApprenticeChallenge5, + gText_ApprenticeChallenge6, + gText_ApprenticeChallenge7, + gText_ApprenticeChallenge8, + gText_ApprenticeChallenge9, + gText_ApprenticeChallenge10, + gText_ApprenticeChallenge11, + gText_ApprenticeChallenge12, + gText_ApprenticeChallenge13, + gText_ApprenticeChallenge14, + gText_ApprenticeChallenge15, +}; + +// Unclear what the criteria are for valid moves +// Notably, a large percentage of multi-strike moves are not valid +static const bool8 sValidApprenticeMoves[MOVES_COUNT] = +{ + [MOVE_NONE] = FALSE, + [MOVE_POUND] = FALSE, + [MOVE_KARATE_CHOP] = TRUE, + [MOVE_DOUBLE_SLAP] = TRUE, + [MOVE_COMET_PUNCH] = FALSE, + [MOVE_MEGA_PUNCH] = TRUE, + [MOVE_PAY_DAY] = FALSE, + [MOVE_FIRE_PUNCH] = TRUE, + [MOVE_ICE_PUNCH] = TRUE, + [MOVE_THUNDER_PUNCH] = TRUE, + [MOVE_SCRATCH] = FALSE, + [MOVE_VICE_GRIP] = FALSE, + [MOVE_GUILLOTINE] = TRUE, + [MOVE_RAZOR_WIND] = FALSE, + [MOVE_SWORDS_DANCE] = TRUE, + [MOVE_CUT] = FALSE, + [MOVE_GUST] = FALSE, + [MOVE_WING_ATTACK] = FALSE, + [MOVE_WHIRLWIND] = TRUE, + [MOVE_FLY] = TRUE, + [MOVE_BIND] = TRUE, + [MOVE_SLAM] = TRUE, + [MOVE_VINE_WHIP] = FALSE, + [MOVE_STOMP] = TRUE, + [MOVE_DOUBLE_KICK] = TRUE, + [MOVE_MEGA_KICK] = TRUE, + [MOVE_JUMP_KICK] = TRUE, + [MOVE_ROLLING_KICK] = TRUE, + [MOVE_SAND_ATTACK] = TRUE, + [MOVE_HEADBUTT] = TRUE, + [MOVE_HORN_ATTACK] = FALSE, + [MOVE_FURY_ATTACK] = FALSE, + [MOVE_HORN_DRILL] = TRUE, + [MOVE_TACKLE] = FALSE, + [MOVE_BODY_SLAM] = TRUE, + [MOVE_WRAP] = TRUE, + [MOVE_TAKE_DOWN] = TRUE, + [MOVE_THRASH] = TRUE, + [MOVE_DOUBLE_EDGE] = TRUE, + [MOVE_TAIL_WHIP] = FALSE, + [MOVE_POISON_STING] = FALSE, + [MOVE_TWINEEDLE] = TRUE, + [MOVE_PIN_MISSILE] = FALSE, + [MOVE_LEER] = FALSE, + [MOVE_BITE] = TRUE, + [MOVE_GROWL] = FALSE, + [MOVE_ROAR] = TRUE, + [MOVE_SING] = TRUE, + [MOVE_SUPERSONIC] = TRUE, + [MOVE_SONIC_BOOM] = TRUE, + [MOVE_DISABLE] = TRUE, + [MOVE_ACID] = FALSE, + [MOVE_EMBER] = FALSE, + [MOVE_FLAMETHROWER] = TRUE, + [MOVE_MIST] = TRUE, + [MOVE_WATER_GUN] = FALSE, + [MOVE_HYDRO_PUMP] = TRUE, + [MOVE_SURF] = TRUE, + [MOVE_ICE_BEAM] = TRUE, + [MOVE_BLIZZARD] = TRUE, + [MOVE_PSYBEAM] = TRUE, + [MOVE_BUBBLE_BEAM] = FALSE, + [MOVE_AURORA_BEAM] = FALSE, + [MOVE_HYPER_BEAM] = TRUE, + [MOVE_PECK] = FALSE, + [MOVE_DRILL_PECK] = TRUE, + [MOVE_SUBMISSION] = TRUE, + [MOVE_LOW_KICK] = TRUE, + [MOVE_COUNTER] = TRUE, + [MOVE_SEISMIC_TOSS] = TRUE, + [MOVE_STRENGTH] = TRUE, + [MOVE_ABSORB] = FALSE, + [MOVE_MEGA_DRAIN] = FALSE, + [MOVE_LEECH_SEED] = TRUE, + [MOVE_GROWTH] = TRUE, + [MOVE_RAZOR_LEAF] = TRUE, + [MOVE_SOLAR_BEAM] = TRUE, + [MOVE_POISON_POWDER] = TRUE, + [MOVE_STUN_SPORE] = TRUE, + [MOVE_SLEEP_POWDER] = TRUE, + [MOVE_PETAL_DANCE] = TRUE, + [MOVE_STRING_SHOT] = FALSE, + [MOVE_DRAGON_RAGE] = TRUE, + [MOVE_FIRE_SPIN] = TRUE, + [MOVE_THUNDER_SHOCK] = FALSE, + [MOVE_THUNDERBOLT] = TRUE, + [MOVE_THUNDER_WAVE] = TRUE, + [MOVE_THUNDER] = TRUE, + [MOVE_ROCK_THROW] = FALSE, + [MOVE_EARTHQUAKE] = TRUE, + [MOVE_FISSURE] = TRUE, + [MOVE_DIG] = TRUE, + [MOVE_TOXIC] = TRUE, + [MOVE_CONFUSION] = FALSE, + [MOVE_PSYCHIC] = TRUE, + [MOVE_HYPNOSIS] = TRUE, + [MOVE_MEDITATE] = TRUE, + [MOVE_AGILITY] = TRUE, + [MOVE_QUICK_ATTACK] = TRUE, + [MOVE_RAGE] = FALSE, + [MOVE_TELEPORT] = FALSE, + [MOVE_NIGHT_SHADE] = TRUE, + [MOVE_MIMIC] = TRUE, + [MOVE_SCREECH] = TRUE, + [MOVE_DOUBLE_TEAM] = TRUE, + [MOVE_RECOVER] = TRUE, + [MOVE_HARDEN] = TRUE, + [MOVE_MINIMIZE] = TRUE, + [MOVE_SMOKESCREEN] = TRUE, + [MOVE_CONFUSE_RAY] = TRUE, + [MOVE_WITHDRAW] = TRUE, + [MOVE_DEFENSE_CURL] = TRUE, + [MOVE_BARRIER] = TRUE, + [MOVE_LIGHT_SCREEN] = TRUE, + [MOVE_HAZE] = TRUE, + [MOVE_REFLECT] = TRUE, + [MOVE_FOCUS_ENERGY] = TRUE, + [MOVE_BIDE] = FALSE, + [MOVE_METRONOME] = TRUE, + [MOVE_MIRROR_MOVE] = TRUE, + [MOVE_SELF_DESTRUCT] = TRUE, + [MOVE_EGG_BOMB] = TRUE, + [MOVE_LICK] = TRUE, + [MOVE_SMOG] = FALSE, + [MOVE_SLUDGE] = FALSE, + [MOVE_BONE_CLUB] = FALSE, + [MOVE_FIRE_BLAST] = TRUE, + [MOVE_WATERFALL] = TRUE, + [MOVE_CLAMP] = TRUE, + [MOVE_SWIFT] = TRUE, + [MOVE_SKULL_BASH] = TRUE, + [MOVE_SPIKE_CANNON] = FALSE, + [MOVE_CONSTRICT] = FALSE, + [MOVE_AMNESIA] = TRUE, + [MOVE_KINESIS] = TRUE, + [MOVE_SOFT_BOILED] = TRUE, + [MOVE_HI_JUMP_KICK] = TRUE, + [MOVE_GLARE] = TRUE, + [MOVE_DREAM_EATER] = TRUE, + [MOVE_POISON_GAS] = FALSE, + [MOVE_BARRAGE] = FALSE, + [MOVE_LEECH_LIFE] = FALSE, + [MOVE_LOVELY_KISS] = TRUE, + [MOVE_SKY_ATTACK] = TRUE, + [MOVE_TRANSFORM] = TRUE, + [MOVE_BUBBLE] = FALSE, + [MOVE_DIZZY_PUNCH] = TRUE, + [MOVE_SPORE] = TRUE, + [MOVE_FLASH] = TRUE, + [MOVE_PSYWAVE] = TRUE, + [MOVE_SPLASH] = FALSE, + [MOVE_ACID_ARMOR] = TRUE, + [MOVE_CRABHAMMER] = TRUE, + [MOVE_EXPLOSION] = TRUE, + [MOVE_FURY_SWIPES] = FALSE, + [MOVE_BONEMERANG] = TRUE, + [MOVE_REST] = TRUE, + [MOVE_ROCK_SLIDE] = TRUE, + [MOVE_HYPER_FANG] = TRUE, + [MOVE_SHARPEN] = TRUE, + [MOVE_CONVERSION] = TRUE, + [MOVE_TRI_ATTACK] = TRUE, + [MOVE_SUPER_FANG] = TRUE, + [MOVE_SLASH] = TRUE, + [MOVE_SUBSTITUTE] = TRUE, + [MOVE_STRUGGLE] = TRUE, + [MOVE_SKETCH] = TRUE, + [MOVE_TRIPLE_KICK] = TRUE, + [MOVE_THIEF] = TRUE, + [MOVE_SPIDER_WEB] = TRUE, + [MOVE_MIND_READER] = TRUE, + [MOVE_NIGHTMARE] = TRUE, + [MOVE_FLAME_WHEEL] = FALSE, + [MOVE_SNORE] = TRUE, + [MOVE_CURSE] = TRUE, + [MOVE_FLAIL] = TRUE, + [MOVE_CONVERSION_2] = TRUE, + [MOVE_AEROBLAST] = TRUE, + [MOVE_COTTON_SPORE] = TRUE, + [MOVE_REVERSAL] = TRUE, + [MOVE_SPITE] = TRUE, + [MOVE_POWDER_SNOW] = FALSE, + [MOVE_PROTECT] = TRUE, + [MOVE_MACH_PUNCH] = TRUE, + [MOVE_SCARY_FACE] = TRUE, + [MOVE_FAINT_ATTACK] = TRUE, + [MOVE_SWEET_KISS] = TRUE, + [MOVE_BELLY_DRUM] = TRUE, + [MOVE_SLUDGE_BOMB] = TRUE, + [MOVE_MUD_SLAP] = TRUE, + [MOVE_OCTAZOOKA] = TRUE, + [MOVE_SPIKES] = TRUE, + [MOVE_ZAP_CANNON] = TRUE, + [MOVE_FORESIGHT] = TRUE, + [MOVE_DESTINY_BOND] = TRUE, + [MOVE_PERISH_SONG] = TRUE, + [MOVE_ICY_WIND] = TRUE, + [MOVE_DETECT] = TRUE, + [MOVE_BONE_RUSH] = FALSE, + [MOVE_LOCK_ON] = TRUE, + [MOVE_OUTRAGE] = TRUE, + [MOVE_SANDSTORM] = TRUE, + [MOVE_GIGA_DRAIN] = TRUE, + [MOVE_ENDURE] = TRUE, + [MOVE_CHARM] = TRUE, + [MOVE_ROLLOUT] = TRUE, + [MOVE_FALSE_SWIPE] = TRUE, + [MOVE_SWAGGER] = TRUE, + [MOVE_MILK_DRINK] = TRUE, + [MOVE_SPARK] = FALSE, + [MOVE_FURY_CUTTER] = TRUE, + [MOVE_STEEL_WING] = TRUE, + [MOVE_MEAN_LOOK] = TRUE, + [MOVE_ATTRACT] = TRUE, + [MOVE_SLEEP_TALK] = TRUE, + [MOVE_HEAL_BELL] = TRUE, + [MOVE_RETURN] = TRUE, + [MOVE_PRESENT] = TRUE, + [MOVE_FRUSTRATION] = TRUE, + [MOVE_SAFEGUARD] = TRUE, + [MOVE_PAIN_SPLIT] = TRUE, + [MOVE_SACRED_FIRE] = TRUE, + [MOVE_MAGNITUDE] = FALSE, + [MOVE_DYNAMIC_PUNCH] = TRUE, + [MOVE_MEGAHORN] = TRUE, + [MOVE_DRAGON_BREATH] = TRUE, + [MOVE_BATON_PASS] = TRUE, + [MOVE_ENCORE] = TRUE, + [MOVE_PURSUIT] = TRUE, + [MOVE_RAPID_SPIN] = TRUE, + [MOVE_SWEET_SCENT] = TRUE, + [MOVE_IRON_TAIL] = TRUE, + [MOVE_METAL_CLAW] = TRUE, + [MOVE_VITAL_THROW] = TRUE, + [MOVE_MORNING_SUN] = TRUE, + [MOVE_SYNTHESIS] = TRUE, + [MOVE_MOONLIGHT] = TRUE, + [MOVE_HIDDEN_POWER] = TRUE, + [MOVE_CROSS_CHOP] = TRUE, + [MOVE_TWISTER] = FALSE, + [MOVE_RAIN_DANCE] = TRUE, + [MOVE_SUNNY_DAY] = TRUE, + [MOVE_CRUNCH] = TRUE, + [MOVE_MIRROR_COAT] = TRUE, + [MOVE_PSYCH_UP] = TRUE, + [MOVE_EXTREME_SPEED] = TRUE, + [MOVE_ANCIENT_POWER] = TRUE, + [MOVE_SHADOW_BALL] = TRUE, + [MOVE_FUTURE_SIGHT] = TRUE, + [MOVE_ROCK_SMASH] = TRUE, + [MOVE_WHIRLPOOL] = TRUE, + [MOVE_BEAT_UP] = TRUE, + [MOVE_FAKE_OUT] = TRUE, + [MOVE_UPROAR] = TRUE, + [MOVE_STOCKPILE] = TRUE, + [MOVE_SPIT_UP] = TRUE, + [MOVE_SWALLOW] = TRUE, + [MOVE_HEAT_WAVE] = TRUE, + [MOVE_HAIL] = TRUE, + [MOVE_TORMENT] = TRUE, + [MOVE_FLATTER] = TRUE, + [MOVE_WILL_O_WISP] = TRUE, + [MOVE_MEMENTO] = TRUE, + [MOVE_FACADE] = TRUE, + [MOVE_FOCUS_PUNCH] = TRUE, + [MOVE_SMELLING_SALT] = TRUE, + [MOVE_FOLLOW_ME] = TRUE, + [MOVE_NATURE_POWER] = TRUE, + [MOVE_CHARGE] = TRUE, + [MOVE_TAUNT] = TRUE, + [MOVE_HELPING_HAND] = TRUE, + [MOVE_TRICK] = TRUE, + [MOVE_ROLE_PLAY] = TRUE, + [MOVE_WISH] = TRUE, + [MOVE_ASSIST] = TRUE, + [MOVE_INGRAIN] = TRUE, + [MOVE_SUPERPOWER] = TRUE, + [MOVE_MAGIC_COAT] = TRUE, + [MOVE_RECYCLE] = TRUE, + [MOVE_REVENGE] = TRUE, + [MOVE_BRICK_BREAK] = TRUE, + [MOVE_YAWN] = TRUE, + [MOVE_KNOCK_OFF] = TRUE, + [MOVE_ENDEAVOR] = TRUE, + [MOVE_ERUPTION] = TRUE, + [MOVE_SKILL_SWAP] = TRUE, + [MOVE_IMPRISON] = TRUE, + [MOVE_REFRESH] = TRUE, + [MOVE_GRUDGE] = TRUE, + [MOVE_SNATCH] = TRUE, + [MOVE_SECRET_POWER] = TRUE, + [MOVE_DIVE] = TRUE, + [MOVE_ARM_THRUST] = FALSE, + [MOVE_CAMOUFLAGE] = TRUE, + [MOVE_TAIL_GLOW] = TRUE, + [MOVE_LUSTER_PURGE] = TRUE, + [MOVE_MIST_BALL] = TRUE, + [MOVE_FEATHER_DANCE] = TRUE, + [MOVE_TEETER_DANCE] = TRUE, + [MOVE_BLAZE_KICK] = TRUE, + [MOVE_MUD_SPORT] = TRUE, + [MOVE_ICE_BALL] = FALSE, + [MOVE_NEEDLE_ARM] = TRUE, + [MOVE_SLACK_OFF] = TRUE, + [MOVE_HYPER_VOICE] = TRUE, + [MOVE_POISON_FANG] = FALSE, + [MOVE_CRUSH_CLAW] = TRUE, + [MOVE_BLAST_BURN] = TRUE, + [MOVE_HYDRO_CANNON] = TRUE, + [MOVE_METEOR_MASH] = TRUE, + [MOVE_ASTONISH] = TRUE, + [MOVE_WEATHER_BALL] = TRUE, + [MOVE_AROMATHERAPY] = TRUE, + [MOVE_FAKE_TEARS] = TRUE, + [MOVE_AIR_CUTTER] = TRUE, + [MOVE_OVERHEAT] = TRUE, + [MOVE_ODOR_SLEUTH] = TRUE, + [MOVE_ROCK_TOMB] = TRUE, + [MOVE_SILVER_WIND] = TRUE, + [MOVE_METAL_SOUND] = TRUE, + [MOVE_GRASS_WHISTLE] = TRUE, + [MOVE_TICKLE] = TRUE, + [MOVE_COSMIC_POWER] = TRUE, + [MOVE_WATER_SPOUT] = TRUE, + [MOVE_SIGNAL_BEAM] = TRUE, + [MOVE_SHADOW_PUNCH] = TRUE, + [MOVE_EXTRASENSORY] = TRUE, + [MOVE_SKY_UPPERCUT] = TRUE, + [MOVE_SAND_TOMB] = TRUE, + [MOVE_SHEER_COLD] = TRUE, + [MOVE_MUDDY_WATER] = TRUE, + [MOVE_BULLET_SEED] = FALSE, + [MOVE_AERIAL_ACE] = TRUE, + [MOVE_ICICLE_SPEAR] = FALSE, + [MOVE_IRON_DEFENSE] = TRUE, + [MOVE_BLOCK] = TRUE, + [MOVE_HOWL] = TRUE, + [MOVE_DRAGON_CLAW] = TRUE, + [MOVE_FRENZY_PLANT] = TRUE, + [MOVE_BULK_UP] = TRUE, + [MOVE_BOUNCE] = TRUE, + [MOVE_MUD_SHOT] = FALSE, + [MOVE_POISON_TAIL] = TRUE, + [MOVE_COVET] = TRUE, + [MOVE_VOLT_TACKLE] = TRUE, + [MOVE_MAGICAL_LEAF] = TRUE, + [MOVE_WATER_SPORT] = TRUE, + [MOVE_CALM_MIND] = TRUE, + [MOVE_LEAF_BLADE] = TRUE, + [MOVE_DRAGON_DANCE] = TRUE, + [MOVE_ROCK_BLAST] = FALSE, + [MOVE_SHOCK_WAVE] = TRUE, + [MOVE_WATER_PULSE] = TRUE, + [MOVE_DOOM_DESIRE] = TRUE, + [MOVE_PSYCHO_BOOST] = TRUE, +}; + +// The possible questions to ask after the initial 3 WHICH MON questions. Retrieved from here and shuffled +// WHAT_ITEM has max 3 occurrences, one for each party member +// WHICH_MOVE has max 5 occurrences, defined as NUM_WHICH_MOVE_QUESTIONS +// WHICH_FIRST has max 1 occurrence, lead mon should only be chosen once +// WHICH_SPEECH has max 1 occurrence, as the apprentice leaves after its asked +static const u8 sQuestionPossibilities[] = +{ + QUESTION_ID_WHAT_ITEM, + QUESTION_ID_WHAT_ITEM, + QUESTION_ID_WHAT_ITEM, + QUESTION_ID_WHICH_MOVE, + QUESTION_ID_WHICH_MOVE, + QUESTION_ID_WHICH_MOVE, + QUESTION_ID_WHICH_MOVE, + QUESTION_ID_WHICH_MOVE, + QUESTION_ID_WHICH_FIRST, + QUESTION_ID_WIN_SPEECH +}; + +static void (* const sApprenticeFunctions[])(void) = +{ + [APPRENTICE_FUNC_GAVE_LVLMODE] = Script_GivenApprenticeLvlMode, + [APPRENTICE_FUNC_SET_LVLMODE] = Script_SetApprenticeLvlMode, + [APPRENTICE_FUNC_SET_ID] = Script_SetApprenticeId, + [APPRENTICE_FUNC_SHUFFLE_SPECIES] = ShuffleApprenticeSpecies, + [APPRENTICE_FUNC_RANDOMIZE_QUESTIONS] = Script_SetRandomQuestionData, + [APPRENTICE_FUNC_ANSWERED_QUESTION] = IncrementQuestionsAnswered, + [APPRENTICE_FUNC_IS_FINAL_QUESTION] = IsFinalQuestion, + [APPRENTICE_FUNC_MENU] = Script_CreateApprenticeMenu, + [APPRENTICE_FUNC_PRINT_MSG] = Script_PrintApprenticeMessage, + [APPRENTICE_FUNC_RESET] = Script_ResetPlayerApprentice, + [APPRENTICE_FUNC_CHECK_GONE] = GetShouldCheckApprenticeGone, + [APPRENTICE_FUNC_GET_QUESTION] = ApprenticeGetQuestion, + [APPRENTICE_FUNC_GET_NUM_PARTY_MONS] = GetNumApprenticePartyMonsAssigned, + [APPRENTICE_FUNC_SET_PARTY_MON] = SetApprenticePartyMon, + [APPRENTICE_FUNC_INIT_QUESTION_DATA] = InitQuestionData, + [APPRENTICE_FUNC_FREE_QUESTION_DATA] = FreeQuestionData, + [APPRENTICE_FUNC_BUFFER_STRING] = ApprenticeBufferString, + [APPRENTICE_FUNC_SET_MOVE] = SetApprenticeMonMove, + [APPRENTICE_FUNC_SET_LEAD_MON] = SetLeadApprenticeMon, + [APPRENTICE_FUNC_OPEN_BAG] = Script_ApprenticeOpenBagMenu, + [APPRENTICE_FUNC_TRY_SET_HELD_ITEM] = TrySetApprenticeHeldItem, + [APPRENTICE_FUNC_SAVE] = SaveApprentice, + [APPRENTICE_FUNC_SET_GFX_SAVED] = SetSavedApprenticeTrainerGfxId, + [APPRENTICE_FUNC_SET_GFX] = SetPlayerApprenticeTrainerGfxId, + [APPRENTICE_FUNC_SHOULD_LEAVE] = GetShouldApprenticeLeave, + [APPRENTICE_FUNC_SHIFT_SAVED] = ShiftSavedApprentices, +}; + +// The first Apprentice can only be one of these +static const u8 sInitialApprenticeIds[8] = {0, 1, 2, 3, 6, 7, 8, 9}; diff --git a/src/data/battle_frontier/battle_frontier_exchange_corner.h b/src/data/battle_frontier/battle_frontier_exchange_corner.h index bcb3cdd62..d29dbdc44 100644 --- a/src/data/battle_frontier/battle_frontier_exchange_corner.h +++ b/src/data/battle_frontier/battle_frontier_exchange_corner.h @@ -50,50 +50,50 @@ static const u16 sFrontierExchangeCorner_HoldItems[] = static const u8 *const sFrontierExchangeCorner_Decor1Descriptions[] = { - BattleFrontier_BattlePointExchangeServiceCorner_Text_2601AA, - BattleFrontier_BattlePointExchangeServiceCorner_Text_2601D0, - BattleFrontier_BattlePointExchangeServiceCorner_Text_260201, - BattleFrontier_BattlePointExchangeServiceCorner_Text_26022F, - BattleFrontier_BattlePointExchangeServiceCorner_Text_26025B, - BattleFrontier_BattlePointExchangeServiceCorner_Text_260287, - BattleFrontier_BattlePointExchangeServiceCorner_Text_2602B5, - BattleFrontier_BattlePointExchangeServiceCorner_Text_2602E0, - BattleFrontier_BattlePointExchangeServiceCorner_Text_26030F, - BattleFrontier_BattlePointExchangeServiceCorner_Text_26033E, + BattleFrontier_ExchangeServiceCorner_Text_KissPosterDesc, + BattleFrontier_ExchangeServiceCorner_Text_KissCushionDesc, + BattleFrontier_ExchangeServiceCorner_Text_SmoochumDollDesc, + BattleFrontier_ExchangeServiceCorner_Text_TogepiDollDesc, + BattleFrontier_ExchangeServiceCorner_Text_MeowthDollDesc, + BattleFrontier_ExchangeServiceCorner_Text_ClefairyDollDesc, + BattleFrontier_ExchangeServiceCorner_Text_DittoDollDesc, + BattleFrontier_ExchangeServiceCorner_Text_CyndaquilDollDesc, + BattleFrontier_ExchangeServiceCorner_Text_ChikoritaDollDesc, + BattleFrontier_ExchangeServiceCorner_Text_TotodileDollDesc, gText_Exit, }; static const u8 *const sFrontierExchangeCorner_Decor2Descriptions[] = { - BattleFrontier_BattlePointExchangeServiceCorner_Text_26036C, - BattleFrontier_BattlePointExchangeServiceCorner_Text_26036C, - BattleFrontier_BattlePointExchangeServiceCorner_Text_26036C, - BattleFrontier_BattlePointExchangeServiceCorner_Text_26036C, - BattleFrontier_BattlePointExchangeServiceCorner_Text_26036C, + BattleFrontier_ExchangeServiceCorner_Text_LargeDollDesc, + BattleFrontier_ExchangeServiceCorner_Text_LargeDollDesc, + BattleFrontier_ExchangeServiceCorner_Text_LargeDollDesc, + BattleFrontier_ExchangeServiceCorner_Text_LargeDollDesc, + BattleFrontier_ExchangeServiceCorner_Text_LargeDollDesc, gText_Exit }; static const u8 *const sFrontierExchangeCorner_VitaminsDescriptions[] = { - BattleFrontier_BattlePointExchangeServiceCorner_Text_260397, - BattleFrontier_BattlePointExchangeServiceCorner_Text_2603BE, - BattleFrontier_BattlePointExchangeServiceCorner_Text_2603E6, - BattleFrontier_BattlePointExchangeServiceCorner_Text_26040E, - BattleFrontier_BattlePointExchangeServiceCorner_Text_260436, - BattleFrontier_BattlePointExchangeServiceCorner_Text_26045C, + BattleFrontier_ExchangeServiceCorner_Text_ProteinDesc, + BattleFrontier_ExchangeServiceCorner_Text_CalciumDesc, + BattleFrontier_ExchangeServiceCorner_Text_IronDesc, + BattleFrontier_ExchangeServiceCorner_Text_ZincDesc, + BattleFrontier_ExchangeServiceCorner_Text_CarbosDesc, + BattleFrontier_ExchangeServiceCorner_Text_HPUpDesc, gText_Exit }; static const u8 *const sFrontierExchangeCorner_HoldItemsDescriptions[] = { - BattleFrontier_BattlePointExchangeServiceCorner_Text_26047A, - BattleFrontier_BattlePointExchangeServiceCorner_Text_2604AC, - BattleFrontier_BattlePointExchangeServiceCorner_Text_2604D8, - BattleFrontier_BattlePointExchangeServiceCorner_Text_26050F, - BattleFrontier_BattlePointExchangeServiceCorner_Text_260542, - BattleFrontier_BattlePointExchangeServiceCorner_Text_260575, - BattleFrontier_BattlePointExchangeServiceCorner_Text_2605A8, - BattleFrontier_BattlePointExchangeServiceCorner_Text_2605E2, - BattleFrontier_BattlePointExchangeServiceCorner_Text_260613, + BattleFrontier_ExchangeServiceCorner_Text_LeftoversDesc, + BattleFrontier_ExchangeServiceCorner_Text_WhiteHerbDesc, + BattleFrontier_ExchangeServiceCorner_Text_QuickClawDesc, + BattleFrontier_ExchangeServiceCorner_Text_MentalHerbDesc, + BattleFrontier_ExchangeServiceCorner_Text_BrightpowderDesc, + BattleFrontier_ExchangeServiceCorner_Text_ChoiceBandDesc, + BattleFrontier_ExchangeServiceCorner_Text_KingsRockDesc, + BattleFrontier_ExchangeServiceCorner_Text_FocusBandDesc, + BattleFrontier_ExchangeServiceCorner_Text_ScopeLensDesc, gText_Exit }; diff --git a/src/data/battle_frontier/trainer_hill.h b/src/data/battle_frontier/trainer_hill.h index 54d49422a..f38cfcc38 100644 --- a/src/data/battle_frontier/trainer_hill.h +++ b/src/data/battle_frontier/trainer_hill.h @@ -1,16 +1,17 @@ #define TRAINER_HILL_OTID 0x10000000 -static const struct TrHillTag gUnknown_0862609C = { - .unkField_0 = 4, +static const struct TrHillTag sDataTagJPDefault = { + .numTrainers = NUM_TRAINER_HILL_TRAINERS_JP, .unused1 = 1, - .numFloors = 2, + .numFloors = NUM_TRAINER_HILL_FLOORS_JP, .checksum = 0x0 }; -static const struct TrHillFloor gUnknown_0862609C_floors[] = { + +static const struct TrHillFloor sDataTagJPDefault_Floors[] = { [0] = { - .unk0 = 0, - .unk1 = 0, + .trainerNum1 = 0, + .trainerNum2 = 0, .trainers = { [0] = { .name = __("シゲノブ$$$$ "), @@ -33,7 +34,7 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { .speedEV = 100, .spAttackEV = 0, .spDefenseEV = 100, - .otId = 0x10000000, + .otId = TRAINER_HILL_OTID, .hpIV = 5, .attackIV = 5, .defenseIV = 5, @@ -57,7 +58,7 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { .speedEV = 0, .spAttackEV = 150, .spDefenseEV = 120, - .otId = 0x10000000, + .otId = TRAINER_HILL_OTID, .hpIV = 5, .attackIV = 5, .defenseIV = 5, @@ -81,7 +82,7 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { .speedEV = 0, .spAttackEV = 0, .spDefenseEV = 200, - .otId = 0x10000000, + .otId = TRAINER_HILL_OTID, .hpIV = 5, .attackIV = 5, .defenseIV = 5, @@ -122,7 +123,7 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { .speedEV = 0, .spAttackEV = 100, .spDefenseEV = 100, - .otId = 0x10000000, + .otId = TRAINER_HILL_OTID, .hpIV = 5, .attackIV = 5, .defenseIV = 5, @@ -146,7 +147,7 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { .speedEV = 0, .spAttackEV = 100, .spDefenseEV = 100, - .otId = 0x10000000, + .otId = TRAINER_HILL_OTID, .hpIV = 5, .attackIV = 5, .defenseIV = 5, @@ -170,7 +171,7 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { .speedEV = 0, .spAttackEV = 100, .spDefenseEV = 100, - .otId = 0x10000000, + .otId = TRAINER_HILL_OTID, .hpIV = 5, .attackIV = 5, .defenseIV = 5, @@ -194,8 +195,8 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { } }, [1] = { - .unk0 = 0, - .unk1 = 0, + .trainerNum1 = 0, + .trainerNum2 = 0, .trainers = { [0] = { .name = __("シゲゾウ$$$$ "), @@ -218,7 +219,7 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { .speedEV = 120, .spAttackEV = 150, .spDefenseEV = 0, - .otId = 0x10000000, + .otId = TRAINER_HILL_OTID, .hpIV = 5, .attackIV = 5, .defenseIV = 5, @@ -242,7 +243,7 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { .speedEV = 0, .spAttackEV = 100, .spDefenseEV = 100, - .otId = 0x10000000, + .otId = TRAINER_HILL_OTID, .hpIV = 5, .attackIV = 5, .defenseIV = 5, @@ -266,7 +267,7 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { .speedEV = 0, .spAttackEV = 110, .spDefenseEV = 100, - .otId = 0x10000000, + .otId = TRAINER_HILL_OTID, .hpIV = 5, .attackIV = 5, .defenseIV = 5, @@ -307,7 +308,7 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { .speedEV = 0, .spAttackEV = 110, .spDefenseEV = 100, - .otId = 0x10000000, + .otId = TRAINER_HILL_OTID, .hpIV = 5, .attackIV = 5, .defenseIV = 5, @@ -331,7 +332,7 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { .speedEV = 100, .spAttackEV = 110, .spDefenseEV = 100, - .otId = 0x10000000, + .otId = TRAINER_HILL_OTID, .hpIV = 5, .attackIV = 5, .defenseIV = 5, @@ -355,7 +356,7 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { .speedEV = 80, .spAttackEV = 80, .spDefenseEV = 80, - .otId = 0x10000000, + .otId = TRAINER_HILL_OTID, .hpIV = 5, .attackIV = 5, .defenseIV = 5, @@ -382,18 +383,18 @@ static const struct TrHillFloor gUnknown_0862609C_floors[] = { static const struct TrHillTag sDataTagNormal = { - .unkField_0 = 8, + .numTrainers = NUM_TRAINER_HILL_TRAINERS, .unused1 = 2, - .numFloors = 4, + .numFloors = NUM_TRAINER_HILL_FLOORS, .checksum = 0x00051E05 }; -static const struct TrHillFloor sDataTagNormal_floors[] = +static const struct TrHillFloor sDataTagNormal_Floors[] = { [0] = { - .unk0 = 0x11, - .unk1 = 0x12, + .trainerNum1 = 17, + .trainerNum2 = 18, .trainers = { [0] = @@ -694,8 +695,8 @@ static const struct TrHillFloor sDataTagNormal_floors[] = }, [1] = { - .unk0 = 0x13, - .unk1 = 0x14, + .trainerNum1 = 19, + .trainerNum2 = 20, .trainers = { [0] = @@ -999,8 +1000,8 @@ static const struct TrHillFloor sDataTagNormal_floors[] = }, [2] = { - .unk0 = 0x15, - .unk1 = 0x16, + .trainerNum1 = 21, + .trainerNum2 = 22, .trainers = { [0] = @@ -1303,8 +1304,8 @@ static const struct TrHillFloor sDataTagNormal_floors[] = }, [3] = { - .unk0 = 0x17, - .unk1 = 0x18, + .trainerNum1 = 23, + .trainerNum2 = 24, .trainers = { [0] = @@ -1602,17 +1603,17 @@ static const struct TrHillFloor sDataTagNormal_floors[] = static const struct TrHillTag sDataTagVariety = { - .unkField_0 = 8, + .numTrainers = NUM_TRAINER_HILL_TRAINERS, .unused1 = 1, - .numFloors = 4, + .numFloors = NUM_TRAINER_HILL_FLOORS, .checksum = 0x00054C15 }; -static const struct TrHillFloor sDataTagVariety_floors[] = { +static const struct TrHillFloor sDataTagVariety_Floors[] = { [0] = { - .unk0 = 0x29, - .unk1 = 0x2A, + .trainerNum1 = 41, + .trainerNum2 = 42, .trainers = { [0] = @@ -1904,8 +1905,8 @@ static const struct TrHillFloor sDataTagVariety_floors[] = { }, [1] = { - .unk0 = 0x2B, - .unk1 = 0x2C, + .trainerNum1 = 43, + .trainerNum2 = 44, .trainers = { [0] = @@ -2227,8 +2228,8 @@ static const struct TrHillFloor sDataTagVariety_floors[] = { }, [2] = { - .unk0 = 0x2D, - .unk1 = 0x2E, + .trainerNum1 = 45, + .trainerNum2 = 46, .trainers = { [0] = @@ -2531,8 +2532,8 @@ static const struct TrHillFloor sDataTagVariety_floors[] = { }, [3] = { - .unk0 = 0x2F, - .unk1 = 0x30, + .trainerNum1 = 47, + .trainerNum2 = 48, .trainers = { [0] = @@ -2828,17 +2829,17 @@ static const struct TrHillFloor sDataTagVariety_floors[] = { static const struct TrHillTag sDataTagUnique = { - .unkField_0 = 8, + .numTrainers = NUM_TRAINER_HILL_TRAINERS, .unused1 = 3, - .numFloors = 4, + .numFloors = NUM_TRAINER_HILL_FLOORS, .checksum = 0x000652F3 }; -static const struct TrHillFloor sDataTagUnique_floors[] = { +static const struct TrHillFloor sDataTagUnique_Floors[] = { [0] = { - .unk0 = 0x31, - .unk1 = 0x32, + .trainerNum1 = 49, + .trainerNum2 = 50, .trainers = { [0] = @@ -3135,8 +3136,8 @@ static const struct TrHillFloor sDataTagUnique_floors[] = { }, [1] = { - .unk0 = 0x33, - .unk1 = 0x34, + .trainerNum1 = 51, + .trainerNum2 = 52, .trainers = { [0] = @@ -3439,8 +3440,8 @@ static const struct TrHillFloor sDataTagUnique_floors[] = { }, [2] = { - .unk0 = 0x35, - .unk1 = 0x36, + .trainerNum1 = 53, + .trainerNum2 = 54, .trainers = { [0] = @@ -3743,8 +3744,8 @@ static const struct TrHillFloor sDataTagUnique_floors[] = { }, [3] = { - .unk0 = 0x38, - .unk1 = 0x37, + .trainerNum1 = 56, + .trainerNum2 = 55, .trainers = { [0] = @@ -4039,17 +4040,17 @@ static const struct TrHillFloor sDataTagUnique_floors[] = { static const struct TrHillTag sDataTagExpert = { - .unkField_0 = 8, + .numTrainers = NUM_TRAINER_HILL_TRAINERS, .unused1 = 1, - .numFloors = 4, + .numFloors = NUM_TRAINER_HILL_FLOORS, .checksum = 0x00061F3F }; -static const struct TrHillFloor sDataTagExpert_floors[] = { +static const struct TrHillFloor sDataTagExpert_Floors[] = { [0] = { - .unk0 = 0x39, - .unk1 = 0x3A, + .trainerNum1 = 57, + .trainerNum2 = 58, .trainers = { [0] = @@ -4353,8 +4354,8 @@ static const struct TrHillFloor sDataTagExpert_floors[] = { }, [1] = { - .unk0 = 0x3B, - .unk1 = 0x3C, + .trainerNum1 = 59, + .trainerNum2 = 60, .trainers = { [0] = @@ -4658,8 +4659,8 @@ static const struct TrHillFloor sDataTagExpert_floors[] = { }, [2] = { - .unk0 = 0x3D, - .unk1 = 0x3E, + .trainerNum1 = 61, + .trainerNum2 = 62, .trainers = { [0] = @@ -4963,8 +4964,8 @@ static const struct TrHillFloor sDataTagExpert_floors[] = { }, [3] = { - .unk0 = 0x3F, - .unk1 = 0x40, + .trainerNum1 = 63, + .trainerNum2 = 64, .trainers = { [0] = diff --git a/src/data/contest_text_tables.h b/src/data/contest_text_tables.h index 8375520d1..f893bc66a 100644 --- a/src/data/contest_text_tables.h +++ b/src/data/contest_text_tables.h @@ -1,414 +1,439 @@ #include "global.h" -extern const u8 gContestEffect00hDescription[]; -extern const u8 gContestEffect01hDescription[]; -extern const u8 gContestEffect02hDescription[]; -extern const u8 gContestEffect03hDescription[]; -extern const u8 gContestEffect04hDescription[]; -extern const u8 gContestEffect05hDescription[]; -extern const u8 gContestEffect06hDescription[]; -extern const u8 gContestEffect07hDescription[]; -extern const u8 gContestEffect08hDescription[]; -extern const u8 gContestEffect09hDescription[]; -extern const u8 gContestEffect0AhDescription[]; -extern const u8 gContestEffect0BhDescription[]; -extern const u8 gContestEffect0ChDescription[]; -extern const u8 gContestEffect0DhDescription[]; -extern const u8 gContestEffect0EhDescription[]; -extern const u8 gContestEffect0FhDescription[]; -extern const u8 gContestEffect10hDescription[]; -extern const u8 gContestEffect11hDescription[]; -extern const u8 gContestEffect12hDescription[]; -extern const u8 gContestEffect13hDescription[]; -extern const u8 gContestEffect14hDescription[]; -extern const u8 gContestEffect15hDescription[]; -extern const u8 gContestEffect16hDescription[]; -extern const u8 gContestEffect17hDescription[]; -extern const u8 gContestEffect18hDescription[]; -extern const u8 gContestEffect19hDescription[]; -extern const u8 gContestEffect1AhDescription[]; -extern const u8 gContestEffect1BhDescription[]; -extern const u8 gContestEffect1ChDescription[]; -extern const u8 gContestEffect1DhDescription[]; -extern const u8 gContestEffect1EhDescription[]; -extern const u8 gContestEffect1FhDescription[]; -extern const u8 gContestEffect20hDescription[]; -extern const u8 gContestEffect21hDescription[]; -extern const u8 gContestEffect22hDescription[]; -extern const u8 gContestEffect23hDescription[]; -extern const u8 gContestEffect24hDescription[]; -extern const u8 gContestEffect25hDescription[]; -extern const u8 gContestEffect26hDescription[]; -extern const u8 gContestEffect27hDescription[]; -extern const u8 gContestEffect28hDescription[]; -extern const u8 gContestEffect29hDescription[]; -extern const u8 gContestEffect2AhDescription[]; -extern const u8 gContestEffect2BhDescription[]; -extern const u8 gContestEffect2ChDescription[]; -extern const u8 gContestEffect2DhDescription[]; -extern const u8 gContestEffect2EhDescription[]; -extern const u8 gContestEffect2FhDescription[]; +// gContestEffectDescriptionPointers +extern const u8 gText_HighlyAppealingMove[]; +extern const u8 gText_UserMoreEasilyStartled[]; +extern const u8 gText_GreatAppealButNoMoreToEnd[]; +extern const u8 gText_UsedRepeatedlyWithoutBoringJudge[]; +extern const u8 gText_AvoidStartledByOthersOnce[]; +extern const u8 gText_AvoidStartledByOthers[]; +extern const u8 gText_AvoidStartledByOthersLittle[]; +extern const u8 gText_UserLessLikelyStartled[]; +extern const u8 gText_SlightlyStartleFrontMon[]; +extern const u8 gText_SlightlyStartleAppealed[]; +extern const u8 gText_StartleAppealedBeforeUser[]; +extern const u8 gText_StartleAllAppealed[]; +extern const u8 gText_BadlyStartleFrontMon[]; +extern const u8 gText_BadlyStartleAppealed[]; +extern const u8 gText_StartleAppealedBeforeUser2[]; +extern const u8 gText_StartleAllAppealed2[]; +extern const u8 gText_ShiftJudgesAttentionFromOthers[]; +extern const u8 gText_StartleMonHasJudgesAttention[]; +extern const u8 gText_JamOthersMissesTurn[]; +extern const u8 gText_StartleMonsMadeSameTypeAppeal[]; +extern const u8 gText_BadlyStartleCoolAppeals[]; +extern const u8 gText_BadlyStartleBeautyAppeals[]; +extern const u8 gText_BadlyStartleCuteAppeals[]; +extern const u8 gText_BadlyStartleSmartAppeals[]; +extern const u8 gText_BadlyStartleToughAppeals[]; +extern const u8 gText_MakeMonAfterUserNervous[]; +extern const u8 gText_MakeAllMonsAfterUserNervous[]; +extern const u8 gText_WorsenConditionOfThoseMadeAppeals[]; +extern const u8 gText_BadlyStartleMonsGoodCondition[]; +extern const u8 gText_AppealGreatIfPerformedFirst[]; +extern const u8 gText_AppealGreatIfPerformedLast[]; +extern const u8 gText_AppealAsGoodAsThoseBeforeIt[]; +extern const u8 gText_AppealAsGoodAsOneBeforeIt[]; +extern const u8 gText_AppealBetterLaterItsPerformed[]; +extern const u8 gText_AppealVariesDependingOnTiming[]; +extern const u8 gText_WorksWellIfSameTypeAsBefore[]; +extern const u8 gText_WorksWellIfDifferentTypeAsBefore[]; +extern const u8 gText_AffectedByAppealInFront[]; +extern const u8 gText_UpsConditionHelpsPreventNervousness[]; +extern const u8 gText_AppealWorksWellIfConditionGood[]; +extern const u8 gText_NextAppealMadeEarlier[]; +extern const u8 gText_NextAppealMadeLater[]; +extern const u8 gText_TurnOrderMoreEasilyScrambled[]; +extern const u8 gText_ScrambleOrderOfNextAppeals[]; +extern const u8 gText_AppealExcitesAudienceInAnyContest[]; +extern const u8 gText_BadlyStartlesMonsGoodAppeals[]; +extern const u8 gText_AppealBestMoreCrowdExcited[]; +extern const u8 gText_TemporarilyStopCrowdExcited[]; -extern const u8 gUnusedContestMoveName0[]; -extern const u8 gUnusedContestMoveName1[]; -extern const u8 gUnusedContestMoveName2[]; -extern const u8 gUnusedContestMoveName3[]; -extern const u8 gUnusedContestMoveName4[]; -extern const u8 gUnusedContestMoveName5[]; -extern const u8 gUnusedContestMoveName6[]; -extern const u8 gUnusedContestMoveName7[]; -extern const u8 gUnusedContestMoveName8[]; -extern const u8 gUnusedContestMoveName9[]; -extern const u8 gUnusedContestMoveName10[]; -extern const u8 gUnusedContestMoveName11[]; -extern const u8 gUnusedContestMoveName12[]; +// sUnusedComboMoveNameTexts +extern const u8 gText_RainDance[]; +extern const u8 gText_Rage[]; +extern const u8 gText_FocusEnergy[]; +extern const u8 gText_Hypnosis[]; +extern const u8 gText_Softboiled[]; +extern const u8 gText_HornAttack[]; +extern const u8 gText_SwordsDance[]; +extern const u8 gText_Conversion[]; +extern const u8 gText_SunnyDay[]; +extern const u8 gText_Rest2[]; +extern const u8 gText_Vicegrip[]; +extern const u8 gText_DefenseCurl[]; +extern const u8 gText_LockOn[]; +// gContestMoveTypeTextPointers extern const u8 gContestMoveTypeCoolText[]; extern const u8 gContestMoveTypeBeautyText[]; extern const u8 gContestMoveTypeCuteText[]; extern const u8 gContestMoveTypeSmartText[]; extern const u8 gContestMoveTypeToughText[]; -extern const u8 gText_0827D5C1[]; -extern const u8 gText_0827D5DC[]; -extern const u8 gText_0827D600[]; -extern const u8 gText_0827D612[]; -extern const u8 gText_0827D612[]; -extern const u8 gText_0827D62D[]; -extern const u8 gText_0827D654[]; -extern const u8 gText_0827D67E[]; -extern const u8 gText_0827D69C[]; -extern const u8 gText_0827D6BA[]; -extern const u8 gText_0827D6E5[]; -extern const u8 gText_0827D706[]; -extern const u8 gText_0827D71D[]; +// sUnusedAppealResultTexts +extern const u8 gText_ButAppealWasJammed[]; +extern const u8 gText_FollowedAnotherMonsLead[]; +extern const u8 gText_ButItMessedUp[]; +extern const u8 gText_WentBetterThanUsual[]; +extern const u8 gText_JudgeLookedAwayForSomeReason[]; +extern const u8 gText_WorkedHardToBuildOnPastMistakes[]; +extern const u8 gText_CantMakeAnyMoreMoves[]; +extern const u8 gText_WorkedFrighteninglyWell[]; +extern const u8 gText_WorkedHardAsStandoutMon[]; +extern const u8 gText_JudgedLookedOnExpectantly[]; +extern const u8 gText_WorkedRatherWell[]; +extern const u8 gText_WorkedLittleBetterThanUsual[]; -extern const u8 gText_0827D743[]; -extern const u8 gText_0827D764[]; -extern const u8 gText_0827D785[]; -extern const u8 gText_0827D7A5[]; -extern const u8 gText_0827D7C8[]; -extern const u8 gText_0827D7E8[]; -extern const u8 gText_0827D831[]; -extern const u8 gText_0827D855[]; -extern const u8 gText_0827D830[]; -extern const u8 gText_0827D872[]; -extern const u8 gText_0827D88F[]; -extern const u8 gText_0827D8B5[]; -extern const u8 gText_0827D8E4[]; -extern const u8 gText_0827D8FE[]; -extern const u8 gText_0827D926[]; -extern const u8 gText_0827D947[]; -extern const u8 gText_0827D961[]; -extern const u8 gText_0827D986[]; -extern const u8 gText_0827D9B1[]; -extern const u8 gText_0827D9D9[]; -extern const u8 gText_0827DA03[]; -extern const u8 gText_0827DA31[]; -extern const u8 gText_0827DA5B[]; -extern const u8 gText_0827DA85[]; -extern const u8 gText_0827DAB2[]; -extern const u8 gText_0827DADA[]; -extern const u8 gText_0827DB03[]; -extern const u8 gText_0827D830[]; -extern const u8 gText_0827D830[]; -extern const u8 gText_0827D830[]; -extern const u8 gText_0827DB1F[]; -extern const u8 gText_0827DB4E[]; +// sRoundResultTexts +extern const u8 gText_MonFailedToStandOutAtAll[]; +extern const u8 gText_MonDidntStandOutVeryMuch[]; +extern const u8 gText_MonCaughtALittleAttention[]; +extern const u8 gText_MonAttractedALotOfAttention[]; +extern const u8 gText_MonCommandedTotalAttention[]; +extern const u8 gText_MonHasntMadeItsAppeal[]; +extern const u8 gText_JudgesViewsOnMonHeldFirm[]; +extern const u8 gText_MonsXChangedPerceptions[]; +extern const u8 gText_EmptyContestString[]; +extern const u8 gText_MonsAppealEffectWoreOff[]; +extern const u8 gText_SpecialAppealsEffectWoreOff[]; +extern const u8 gText_EveryonesAppealsMadeToLookSame[]; +extern const u8 gText_CheapenedMonsAppeal[]; +extern const u8 gText_CheapenedMonsAppeal2[]; +extern const u8 gText_CheapenedAppealOfThoseAhead[]; +extern const u8 gText_CheapenedAppealOfThoseAhead2[]; +extern const u8 gText_StoleAttentionAwayFromMon[]; +extern const u8 gText_SeverelyCheapenedOtherAppeals[]; +extern const u8 gText_AnticipationSwelledForMonsAppealNext[]; +extern const u8 gText_CheapenedJudgesFavoriteAppeal[]; +extern const u8 gText_AppealsOfOthersCheapenedByHalf[]; +extern const u8 gText_StoodOutToMakeUpForBeingJammed[]; +extern const u8 gText_CantParticipateInAppealsAnyMore[]; +extern const u8 gText_TouchedJudgeForFantasticAppeal[]; +extern const u8 gText_AnticipationRoseForUpcomingAppeals[]; +extern const u8 gText_StoodOutAsMuchAsSpecialAppeals[]; +extern const u8 gText_StoodOutAsMuchAsMon[]; +extern const u8 gText_JammedAppealsMadeEvenLessNoticeable[]; +extern const u8 gText_EveryonesAppealsMadeSame[]; -extern const u8 gText_827DB75[]; -extern const u8 gText_827DBB0[]; -extern const u8 gText_827DBE0[]; -extern const u8 gText_827DC0F[]; -extern const u8 gText_827DC45[]; -extern const u8 gText_827DC7C[]; -extern const u8 gText_827DCB4[]; -extern const u8 gText_827DCE7[]; -extern const u8 gText_827DD12[]; -extern const u8 gText_827DD3D[]; -extern const u8 gText_827DD6F[]; -extern const u8 gText_827DD8E[]; -extern const u8 gText_827DDC7[]; -extern const u8 gText_827DDF2[]; -extern const u8 gText_827DE14[]; -extern const u8 gText_827DE44[]; -extern const u8 gText_827DE73[]; -extern const u8 gText_827DEA5[]; -extern const u8 gText_827DED9[]; -extern const u8 gText_827DF02[]; -extern const u8 gText_827DF3A[]; -extern const u8 gText_827DF63[]; -extern const u8 gText_827DF8C[]; -extern const u8 gText_827DFB8[]; -extern const u8 gText_827DFE2[]; -extern const u8 gText_827E00C[]; -extern const u8 gText_827E02F[]; -extern const u8 gText_827E05F[]; -extern const u8 gText_827E08B[]; -extern const u8 gText_827E0B5[]; -extern const u8 gText_827E0DD[]; -extern const u8 gText_827E107[]; -extern const u8 gText_827E143[]; -extern const u8 gText_827E17F[]; -extern const u8 gText_827E1BB[]; -extern const u8 gText_827E1F3[]; -extern const u8 gText_827E220[]; -extern const u8 gText_827E254[]; -extern const u8 gText_827E289[]; -extern const u8 gText_827E2C5[]; -extern const u8 gText_0827E2FE[]; -extern const u8 gText_0827E32E[]; -extern const u8 gText_0827E35B[]; -extern const u8 gText_0827E38D[]; -extern const u8 gText_0827E3C1[]; -extern const u8 gText_0827E3EB[]; -extern const u8 gText_0827E416[]; -extern const u8 gText_0827E448[]; -extern const u8 gText_0827E473[]; -extern const u8 gText_0827E4A6[]; -extern const u8 gText_0827E4D5[]; -extern const u8 gText_0827E504[]; -extern const u8 gText_0827E531[]; -extern const u8 gText_0827E55A[]; -extern const u8 gText_0827E5B2[]; -extern const u8 gText_0827E5D0[]; -extern const u8 gText_0827E606[]; -extern const u8 gText_0827E638[]; -extern const u8 gText_0827E658[]; -extern const u8 gText_0827E68B[]; -extern const u8 gText_0827E6C4[]; -extern const u8 gText_0827E7BA[]; +// sAppealResultTexts +extern const u8 gText_BecameMoreConsciousOfOtherMons[]; +extern const u8 gText_MonCantMakeAnAppealAfterThis[]; +extern const u8 gText_SettledDownJustLittleBit[]; +extern const u8 gText_BecameObliviousToOtherMons[]; +extern const u8 gText_BecameLessAwareOfOtherMons[]; +extern const u8 gText_StoppedCaringAboutOtherMons[]; +extern const u8 gText_TriedToStartleOtherMons[]; +extern const u8 gText_TriedToDazzleOthers[]; +extern const u8 gText_JudgeLookedAwayFromMon[]; +extern const u8 gText_TriedToUnnerveNextMon[]; +extern const u8 gText_MonBecameNervous[]; +extern const u8 gText_AppealTriedToUnnerveWaitingMons[]; +extern const u8 gText_TauntedMonsDoingWell[]; +extern const u8 gText_MonRegainedItsForm[]; +extern const u8 gText_TriedToJamMonDoingWell[]; +extern const u8 gText_StandoutMonHustledEvenMore[]; +extern const u8 gText_LargelyUnnoticedMonWorkedHard[]; +extern const u8 gText_WorkedAsMuchAsMonBefore[]; +extern const u8 gText_WorkedAsMuchAsPrecedingMon[]; +extern const u8 gText_MonsAppealWasDud[]; +extern const u8 gText_MonsAppealDidNotGoWell[]; +extern const u8 gText_MonsAppealDidNotGoWell2[]; +extern const u8 gText_MonsAppealDidNotGoWell3[]; +extern const u8 gText_MonsAppealDidNotWorkVeryWell[]; +extern const u8 gText_MonsAppealWentSlightlyWell[]; +extern const u8 gText_MonsAppealWentSlightlyWell2[]; +extern const u8 gText_MonsAppealWentPrettyWell[]; +extern const u8 gText_MonsAppealWentPrettyWell2[]; +extern const u8 gText_MonsAppealWentVeryWell[]; +extern const u8 gText_MonsAppealWentExcellently[]; +extern const u8 gText_MonsAppealWentExcellently2[]; +extern const u8 gText_SameTypeAsOneBeforeGood[]; +extern const u8 gText_NotSameTypeAsOneBeforeGood[]; +extern const u8 gText_StoodOutMuchMoreThanMonBefore[]; +extern const u8 gText_DidntDoAsWellAsMonBefore[]; +extern const u8 gText_MonsConditionRoseAboveUsual[]; +extern const u8 gText_MonsHotStatusMadeGreatAppeal[]; +extern const u8 gText_MovedUpInLineForNextAppeal[]; +extern const u8 gText_MovedBackInLineForNextAppeal[]; +extern const u8 gText_ScrambledUpOrderForNextTurn[]; +extern const u8 gText_JudgeLookedAtMonExpectantly[]; +extern const u8 gText_AppealComboWentOverWell[]; +extern const u8 gText_AppealComboWentOverVeryWell[]; +extern const u8 gText_AppealComboWentOverExcellently[]; +extern const u8 gText_MonManagedToAvertGaze[]; +extern const u8 gText_MonManagedToAvoidSeeingIt[]; +extern const u8 gText_MonIsntFazedByThatSortOfThing[]; +extern const u8 gText_MonBecameALittleDistracted[]; +extern const u8 gText_TriedToStartleOtherPokemon[]; +extern const u8 gText_MonLookedDownOutOfDistraction[]; +extern const u8 gText_MonTurnedBackOutOfDistraction[]; +extern const u8 gText_MonCouldntHelpUtteringCry[]; +extern const u8 gText_MonCouldntHelpLeapingUp[]; +extern const u8 gText_MonTrippedOutOfDistraction[]; +extern const u8 gText_ButItMessedUp2[]; +extern const u8 gText_ButItFailedToMakeTargetNervous[]; +extern const u8 gText_ButItFailedToMakeAnyoneNervous[]; +extern const u8 gText_ButItWasIgnored[]; +extern const u8 gText_CouldntImproveItsCondition[]; +extern const u8 gText_BadConditionResultedInWeakAppeal[]; +extern const u8 gText_MonWasUnaffected[]; +extern const u8 gText_AttractedCrowdsAttention[]; + +// sContestConditions +extern const u8 gText_Contest_Coolness[]; +extern const u8 gText_Contest_Beauty[]; +extern const u8 gText_Contest_Cuteness[]; +extern const u8 gText_Contest_Smartness[]; +extern const u8 gText_Contest_Toughness[]; -extern const u8 gText_0827E85F[]; -extern const u8 gText_0827E868[]; -extern const u8 gText_0827E86F[]; -extern const u8 gText_0827E878[]; -extern const u8 gText_0827E882[]; +// sInvalidContestMoveNames +extern const u8 gText_CoolMove[]; +extern const u8 gText_BeautyMove[]; +extern const u8 gText_CuteMove[]; +extern const u8 gText_SmartMove[]; +extern const u8 gText_ToughMove[]; +extern const u8 gText_3QuestionMarks[]; -extern const u8 gText_0827E894[]; -extern const u8 gText_0827E89E[]; -extern const u8 gText_0827E8AA[]; -extern const u8 gText_0827E8B4[]; -extern const u8 gText_0827E8BF[]; -extern const u8 gText_0827E8CA[]; +// Misc, used directly +extern const u8 gText_MonAppealedWithMove[]; +extern const u8 gText_MonCantAppealNextTurn[]; +extern const u8 gText_RepeatedAppeal[]; +extern const u8 gText_MonsXDidntGoOverWell[]; +extern const u8 gText_MonsXWentOverGreat[]; +extern const u8 gText_MonsXGotTheCrowdGoing[]; +extern const u8 gText_CrowdContinuesToWatchMon[]; +extern const u8 gText_MonsMoveIsIgnored[]; +extern const u8 gText_MonWasTooNervousToMove[]; +extern const u8 gText_MonWasWatchingOthers[]; +extern const u8 gText_AllOutOfAppealTime[]; +extern const u8 gText_Contest_Shyness[]; +extern const u8 gText_Contest_Anxiety[]; +extern const u8 gText_Contest_Laziness[]; +extern const u8 gText_Contest_Hesitancy[]; +extern const u8 gText_Contest_Fear[]; +extern const u8 gText_AppealNumWhichMoveWillBePlayed[]; +extern const u8 gText_AppealNumButItCantParticipate[]; const u8 *const gContestEffectDescriptionPointers[] = { - gContestEffect00hDescription, - gContestEffect01hDescription, - gContestEffect02hDescription, - gContestEffect03hDescription, - gContestEffect04hDescription, - gContestEffect05hDescription, - gContestEffect06hDescription, - gContestEffect07hDescription, - gContestEffect08hDescription, - gContestEffect09hDescription, - gContestEffect0AhDescription, - gContestEffect0BhDescription, - gContestEffect0ChDescription, - gContestEffect0DhDescription, - gContestEffect0EhDescription, - gContestEffect0FhDescription, - gContestEffect10hDescription, - gContestEffect11hDescription, - gContestEffect12hDescription, - gContestEffect13hDescription, - gContestEffect14hDescription, - gContestEffect15hDescription, - gContestEffect16hDescription, - gContestEffect17hDescription, - gContestEffect18hDescription, - gContestEffect19hDescription, - gContestEffect1AhDescription, - gContestEffect1BhDescription, - gContestEffect1ChDescription, - gContestEffect1DhDescription, - gContestEffect1EhDescription, - gContestEffect1FhDescription, - gContestEffect20hDescription, - gContestEffect21hDescription, - gContestEffect22hDescription, - gContestEffect23hDescription, - gContestEffect24hDescription, - gContestEffect25hDescription, - gContestEffect26hDescription, - gContestEffect27hDescription, - gContestEffect28hDescription, - gContestEffect29hDescription, - gContestEffect2AhDescription, - gContestEffect2BhDescription, - gContestEffect2ChDescription, - gContestEffect2DhDescription, - gContestEffect2EhDescription, - gContestEffect2FhDescription + [CONTEST_EFFECT_HIGHLY_APPEALING] = gText_HighlyAppealingMove, + [CONTEST_EFFECT_USER_MORE_EASILY_STARTLED] = gText_UserMoreEasilyStartled, + [CONTEST_EFFECT_GREAT_APPEAL_BUT_NO_MORE_MOVES] = gText_GreatAppealButNoMoreToEnd, + [CONTEST_EFFECT_REPETITION_NOT_BORING] = gText_UsedRepeatedlyWithoutBoringJudge, + [CONTEST_EFFECT_AVOID_STARTLE_ONCE] = gText_AvoidStartledByOthersOnce, + [CONTEST_EFFECT_AVOID_STARTLE] = gText_AvoidStartledByOthers, + [CONTEST_EFFECT_AVOID_STARTLE_SLIGHTLY] = gText_AvoidStartledByOthersLittle, + [CONTEST_EFFECT_USER_LESS_EASILY_STARTLED] = gText_UserLessLikelyStartled, + [CONTEST_EFFECT_STARTLE_FRONT_MON] = gText_SlightlyStartleFrontMon, + [CONTEST_EFFECT_SLIGHTLY_STARTLE_PREV_MONS] = gText_SlightlyStartleAppealed, + [CONTEST_EFFECT_STARTLE_PREV_MON] = gText_StartleAppealedBeforeUser, + [CONTEST_EFFECT_STARTLE_PREV_MONS] = gText_StartleAllAppealed, + [CONTEST_EFFECT_BADLY_STARTLE_FRONT_MON] = gText_BadlyStartleFrontMon, + [CONTEST_EFFECT_BADLY_STARTLE_PREV_MONS] = gText_BadlyStartleAppealed, + [CONTEST_EFFECT_STARTLE_PREV_MON_2] = gText_StartleAppealedBeforeUser2, + [CONTEST_EFFECT_STARTLE_PREV_MONS_2] = gText_StartleAllAppealed2, + [CONTEST_EFFECT_SHIFT_JUDGE_ATTENTION] = gText_ShiftJudgesAttentionFromOthers, + [CONTEST_EFFECT_STARTLE_MON_WITH_JUDGES_ATTENTION] = gText_StartleMonHasJudgesAttention, + [CONTEST_EFFECT_JAMS_OTHERS_BUT_MISS_ONE_TURN] = gText_JamOthersMissesTurn, + [CONTEST_EFFECT_STARTLE_MONS_SAME_TYPE_APPEAL] = gText_StartleMonsMadeSameTypeAppeal, + [CONTEST_EFFECT_STARTLE_MONS_COOL_APPEAL] = gText_BadlyStartleCoolAppeals, + [CONTEST_EFFECT_STARTLE_MONS_BEAUTY_APPEAL] = gText_BadlyStartleBeautyAppeals, + [CONTEST_EFFECT_STARTLE_MONS_CUTE_APPEAL] = gText_BadlyStartleCuteAppeals, + [CONTEST_EFFECT_STARTLE_MONS_SMART_APPEAL] = gText_BadlyStartleSmartAppeals, + [CONTEST_EFFECT_STARTLE_MONS_TOUGH_APPEAL] = gText_BadlyStartleToughAppeals, + [CONTEST_EFFECT_MAKE_FOLLOWING_MON_NERVOUS] = gText_MakeMonAfterUserNervous, + [CONTEST_EFFECT_MAKE_FOLLOWING_MONS_NERVOUS] = gText_MakeAllMonsAfterUserNervous, + [CONTEST_EFFECT_WORSEN_CONDITION_OF_PREV_MONS] = gText_WorsenConditionOfThoseMadeAppeals, + [CONTEST_EFFECT_BADLY_STARTLES_MONS_IN_GOOD_CONDITION] = gText_BadlyStartleMonsGoodCondition, + [CONTEST_EFFECT_BETTER_IF_FIRST] = gText_AppealGreatIfPerformedFirst, + [CONTEST_EFFECT_BETTER_IF_LAST] = gText_AppealGreatIfPerformedLast, + [CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONES] = gText_AppealAsGoodAsThoseBeforeIt, + [CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONE] = gText_AppealAsGoodAsOneBeforeIt, + [CONTEST_EFFECT_BETTER_WHEN_LATER] = gText_AppealBetterLaterItsPerformed, + [CONTEST_EFFECT_QUALITY_DEPENDS_ON_TIMING] = gText_AppealVariesDependingOnTiming, + [CONTEST_EFFECT_BETTER_IF_SAME_TYPE] = gText_WorksWellIfSameTypeAsBefore, + [CONTEST_EFFECT_BETTER_IF_DIFF_TYPE] = gText_WorksWellIfDifferentTypeAsBefore, + [CONTEST_EFFECT_AFFECTED_BY_PREV_APPEAL] = gText_AffectedByAppealInFront, + [CONTEST_EFFECT_IMPROVE_CONDITION_PREVENT_NERVOUSNESS] = gText_UpsConditionHelpsPreventNervousness, + [CONTEST_EFFECT_BETTER_WITH_GOOD_CONDITION] = gText_AppealWorksWellIfConditionGood, + [CONTEST_EFFECT_NEXT_APPEAL_EARLIER] = gText_NextAppealMadeEarlier, + [CONTEST_EFFECT_NEXT_APPEAL_LATER] = gText_NextAppealMadeLater, + [CONTEST_EFFECT_MAKE_SCRAMBLING_TURN_ORDER_EASIER] = gText_TurnOrderMoreEasilyScrambled, + [CONTEST_EFFECT_SCRAMBLE_NEXT_TURN_ORDER] = gText_ScrambleOrderOfNextAppeals, + [CONTEST_EFFECT_EXCITE_AUDIENCE_IN_ANY_CONTEST] = gText_AppealExcitesAudienceInAnyContest, + [CONTEST_EFFECT_BADLY_STARTLE_MONS_WITH_GOOD_APPEALS] = gText_BadlyStartlesMonsGoodAppeals, + [CONTEST_EFFECT_BETTER_WHEN_AUDIENCE_EXCITED] = gText_AppealBestMoreCrowdExcited, + [CONTEST_EFFECT_DONT_EXCITE_AUDIENCE] = gText_TemporarilyStopCrowdExcited }; // Unreferenced array of pointers to move names. // All of the moves except Conversion are combo starters, so this may have // been an early list of combo starters. -const u8 *const gUnknown_8587D10[] = +static const u8 *const sUnusedComboMoveNameTexts[] = { - gUnusedContestMoveName0, - gUnusedContestMoveName0, - gUnusedContestMoveName1, - gUnusedContestMoveName2, - gUnusedContestMoveName3, - gUnusedContestMoveName4, - gUnusedContestMoveName5, - gUnusedContestMoveName6, - gUnusedContestMoveName7, - gUnusedContestMoveName8, - gUnusedContestMoveName9, - gUnusedContestMoveName10, - gUnusedContestMoveName11, - gUnusedContestMoveName12 + gText_RainDance, + gText_RainDance, + gText_Rage, + gText_FocusEnergy, + gText_Hypnosis, + gText_Softboiled, + gText_HornAttack, + gText_SwordsDance, + gText_Conversion, + gText_SunnyDay, + gText_Rest2, + gText_Vicegrip, + gText_DefenseCurl, + gText_LockOn }; const u8 *const gContestMoveTypeTextPointers[] = { - gContestMoveTypeCoolText, - gContestMoveTypeBeautyText, - gContestMoveTypeCuteText, - gContestMoveTypeSmartText, - gContestMoveTypeToughText + [CONTEST_CATEGORY_COOL] = gContestMoveTypeCoolText, + [CONTEST_CATEGORY_BEAUTY] = gContestMoveTypeBeautyText, + [CONTEST_CATEGORY_CUTE] = gContestMoveTypeCuteText, + [CONTEST_CATEGORY_SMART] = gContestMoveTypeSmartText, + [CONTEST_CATEGORY_TOUGH] = gContestMoveTypeToughText }; -const u8 *const gUnknown_08587D5C[] = +static const u8 *const sUnusedAppealResultTexts[] = { - gText_0827D5C1, - gText_0827D5DC, - gText_0827D600, - gText_0827D612, - gText_0827D612, - gText_0827D62D, - gText_0827D654, - gText_0827D67E, - gText_0827D69C, - gText_0827D6BA, - gText_0827D6E5, - gText_0827D706, - gText_0827D71D + gText_ButAppealWasJammed, + gText_FollowedAnotherMonsLead, + gText_ButItMessedUp, + gText_WentBetterThanUsual, + gText_WentBetterThanUsual, + gText_JudgeLookedAwayForSomeReason, + gText_WorkedHardToBuildOnPastMistakes, + gText_CantMakeAnyMoreMoves, + gText_WorkedFrighteninglyWell, + gText_WorkedHardAsStandoutMon, + gText_JudgedLookedOnExpectantly, + gText_WorkedRatherWell, + gText_WorkedLittleBetterThanUsual }; -const u8 *const gUnknown_08587D90[] = +// Takes the .attentionLevel of a contestant as an index. Only 0-5 are used +static const u8 *const sRoundResultTexts[] = { - gText_0827D743, - gText_0827D764, - gText_0827D785, - gText_0827D7A5, - gText_0827D7C8, - gText_0827D7E8, - gText_0827D831, - gText_0827D855, - gText_0827D830, - gText_0827D872, - gText_0827D88F, - gText_0827D8B5, - gText_0827D8E4, - gText_0827D8FE, - gText_0827D926, - gText_0827D947, - gText_0827D961, - gText_0827D986, - gText_0827D9B1, - gText_0827D9D9, - gText_0827DA03, - gText_0827DA31, - gText_0827DA5B, - gText_0827DA85, - gText_0827DAB2, - gText_0827DADA, - gText_0827DB03, - gText_0827D830, - gText_0827D830, - gText_0827D830, - gText_0827DB1F, - gText_0827DB4E + gText_MonFailedToStandOutAtAll, + gText_MonDidntStandOutVeryMuch, + gText_MonCaughtALittleAttention, + gText_MonAttractedALotOfAttention, + gText_MonCommandedTotalAttention, + gText_MonHasntMadeItsAppeal, + gText_JudgesViewsOnMonHeldFirm, // here below unused + gText_MonsXChangedPerceptions, + gText_EmptyContestString, + gText_MonsAppealEffectWoreOff, + gText_SpecialAppealsEffectWoreOff, + gText_EveryonesAppealsMadeToLookSame, + gText_CheapenedMonsAppeal, + gText_CheapenedAppealOfThoseAhead, + gText_StoleAttentionAwayFromMon, + gText_CheapenedMonsAppeal2, + gText_SeverelyCheapenedOtherAppeals, + gText_AnticipationSwelledForMonsAppealNext, + gText_CheapenedAppealOfThoseAhead2, + gText_CheapenedJudgesFavoriteAppeal, + gText_AppealsOfOthersCheapenedByHalf, + gText_StoodOutToMakeUpForBeingJammed, + gText_CantParticipateInAppealsAnyMore, + gText_TouchedJudgeForFantasticAppeal, + gText_AnticipationRoseForUpcomingAppeals, + gText_StoodOutAsMuchAsSpecialAppeals, + gText_StoodOutAsMuchAsMon, + gText_EmptyContestString, + gText_EmptyContestString, + gText_EmptyContestString, + gText_JammedAppealsMadeEvenLessNoticeable, + gText_EveryonesAppealsMadeSame }; -const u8 *const gUnknown_08587E10[] = +static const u8 *const sAppealResultTexts[] = { - gText_827DB75, - gText_827DBB0, - gText_827DBE0, - gText_827DC0F, - gText_827DC45, - gText_827DC7C, - gText_827DCB4, - gText_827DCE7, - gText_827DD12, - gText_827DD3D, - gText_827DD6F, - gText_827DD8E, - gText_827DDC7, - gText_827DDF2, - gText_827DE14, - gText_827DE44, - gText_827DE73, - gText_827DEA5, - gText_827DED9, - gText_827DF02, - gText_827DF3A, - gText_827DF63, - gText_827DF8C, - gText_827DFB8, - gText_827DFE2, - gText_827E00C, - gText_827E02F, - gText_827E05F, - gText_827E08B, - gText_827E0B5, - gText_827E0DD, - gText_827E107, - gText_827E143, - gText_827E17F, - gText_827E1BB, - gText_827E1F3, - gText_827E220, - gText_827E254, - gText_827E289, - gText_827E2C5, - gText_0827E2FE, - gText_0827E32E, - gText_0827E35B, - gText_0827E38D, - gText_0827E3C1, - gText_0827E3EB, - gText_0827E416, - gText_0827E448, - gText_0827E473, - gText_0827E4A6, - gText_0827E4D5, - gText_0827E504, - gText_0827E531, - gText_0827E55A, - gText_0827E5B2, - gText_0827E5D0, - gText_0827E606, - gText_0827E638, - gText_0827E658, - gText_0827E68B, - gText_0827E6C4, - gText_0827E7BA + [CONTEST_STRING_MORE_CONSCIOUS] = gText_BecameMoreConsciousOfOtherMons, + [CONTEST_STRING_NO_APPEAL] = gText_MonCantMakeAnAppealAfterThis, + [CONTEST_STRING_SETTLE_DOWN] = gText_SettledDownJustLittleBit, + [CONTEST_STRING_OBLIVIOUS_TO_OTHERS] = gText_BecameObliviousToOtherMons, + [CONTEST_STRING_LESS_AWARE] = gText_BecameLessAwareOfOtherMons, + [CONTEST_STRING_STOPPED_CARING] = gText_StoppedCaringAboutOtherMons, + [CONTEST_STRING_STARTLE_ATTEMPT] = gText_TriedToStartleOtherMons, + [CONTEST_STRING_DAZZLE_ATTEMPT] = gText_TriedToDazzleOthers, + [CONTEST_STRING_JUDGE_LOOK_AWAY2] = gText_JudgeLookedAwayFromMon, + [CONTEST_STRING_UNNERVE_ATTEMPT] = gText_TriedToUnnerveNextMon, + [CONTEST_STRING_NERVOUS] = gText_MonBecameNervous, + [CONTEST_STRING_UNNERVE_WAITING] = gText_AppealTriedToUnnerveWaitingMons, + [CONTEST_STRING_TAUNT_WELL] = gText_TauntedMonsDoingWell, + [CONTEST_STRING_REGAINED_FORM] = gText_MonRegainedItsForm, + [CONTEST_STRING_JAM_WELL] = gText_TriedToJamMonDoingWell, + [CONTEST_STRING_HUSTLE_STANDOUT] = gText_StandoutMonHustledEvenMore, + [CONTEST_STRING_WORK_HARD_UNNOTICED] = gText_LargelyUnnoticedMonWorkedHard, + [CONTEST_STRING_WORK_BEFORE] = gText_WorkedAsMuchAsMonBefore, + [CONTEST_STRING_APPEAL_NOT_WELL] = gText_MonsAppealDidNotGoWell, + [CONTEST_STRING_WORK_PRECEDING] = gText_WorkedAsMuchAsPrecedingMon, + [CONTEST_STRING_APPEAL_NOT_WELL2] = gText_MonsAppealDidNotGoWell2, + [CONTEST_STRING_APPEAL_NOT_SHOWN_WELL] = gText_MonsAppealDidNotGoWell3, + [CONTEST_STRING_APPEAL_SLIGHTLY_WELL] = gText_MonsAppealWentSlightlyWell, + [CONTEST_STRING_APPEAL_PRETTY_WELL] = gText_MonsAppealWentPrettyWell, + [CONTEST_STRING_APPEAL_EXCELLENTLY] = gText_MonsAppealWentExcellently, + [CONTEST_STRING_APPEAL_DUD] = gText_MonsAppealWasDud, + [CONTEST_STRING_APPEAL_NOT_VERY_WELL] = gText_MonsAppealDidNotWorkVeryWell, + [CONTEST_STRING_APPEAL_SLIGHTLY_WELL2] = gText_MonsAppealWentSlightlyWell2, + [CONTEST_STRING_APPEAL_PRETTY_WELL2] = gText_MonsAppealWentPrettyWell2, + [CONTEST_STRING_APPEAL_VERY_WELL] = gText_MonsAppealWentVeryWell, + [CONTEST_STRING_APPEAL_EXCELLENTLY2] = gText_MonsAppealWentExcellently2, + [CONTEST_STRING_SAME_TYPE_GOOD] = gText_SameTypeAsOneBeforeGood, + [CONTEST_STRING_DIFF_TYPE_GOOD] = gText_NotSameTypeAsOneBeforeGood, + [CONTEST_STRING_STOOD_OUT_AS_MUCH] = gText_StoodOutMuchMoreThanMonBefore, + [CONTEST_STRING_NOT_AS_WELL] = gText_DidntDoAsWellAsMonBefore, + [CONTEST_STRING_CONDITION_ROSE] = gText_MonsConditionRoseAboveUsual, + [CONTEST_STRING_HOT_STATUS] = gText_MonsHotStatusMadeGreatAppeal, + [CONTEST_STRING_MOVE_UP_LINE] = gText_MovedUpInLineForNextAppeal, + [CONTEST_STRING_MOVE_BACK_LINE] = gText_MovedBackInLineForNextAppeal, + [CONTEST_STRING_SCRAMBLE_ORDER] = gText_ScrambledUpOrderForNextTurn, + [CONTEST_STRING_JUDGE_EXPECTANTLY2] = gText_JudgeLookedAtMonExpectantly, + [CONTEST_STRING_WENT_OVER_WELL] = gText_AppealComboWentOverWell, + [CONTEST_STRING_WENT_OVER_VERY_WELL] = gText_AppealComboWentOverVeryWell, + [CONTEST_STRING_APPEAL_COMBO_EXCELLENTLY] = gText_AppealComboWentOverExcellently, + [CONTEST_STRING_AVERT_GAZE] = gText_MonManagedToAvertGaze, + [CONTEST_STRING_AVOID_SEEING] = gText_MonManagedToAvoidSeeingIt, + [CONTEST_STRING_NOT_FAZED] = gText_MonIsntFazedByThatSortOfThing, + [CONTEST_STRING_LITTLE_DISTRACTED] = gText_MonBecameALittleDistracted, + [CONTEST_STRING_ATTEMPT_STARTLE] = gText_TriedToStartleOtherPokemon, + [CONTEST_STRING_LOOKED_DOWN] = gText_MonLookedDownOutOfDistraction, + [CONTEST_STRING_TURNED_BACK] = gText_MonTurnedBackOutOfDistraction, + [CONTEST_STRING_UTTER_CRY] = gText_MonCouldntHelpUtteringCry, + [CONTEST_STRING_LEAPT_UP] = gText_MonCouldntHelpLeapingUp, + [CONTEST_STRING_TRIPPED_OVER] = gText_MonTrippedOutOfDistraction, + [CONTEST_STRING_MESSED_UP2] = gText_ButItMessedUp2, + [CONTEST_STRING_FAILED_TARGET_NERVOUS] = gText_ButItFailedToMakeTargetNervous, + [CONTEST_STRING_FAILED_ANYONE_NERVOUS] = gText_ButItFailedToMakeAnyoneNervous, + [CONTEST_STRING_IGNORED] = gText_ButItWasIgnored, + [CONTEST_STRING_NO_CONDITION_IMPROVE] = gText_CouldntImproveItsCondition, + [CONTEST_STRING_BAD_CONDITION_WEAK_APPEAL] = gText_BadConditionResultedInWeakAppeal, + [CONTEST_STRING_UNAFFECTED] = gText_MonWasUnaffected, + [CONTEST_STRING_ATTRACTED_ATTENTION] = gText_AttractedCrowdsAttention }; -const u8 *const gUnknown_08587F08[] = +static const u8 *const sContestConditions[] = { - gText_0827E85F, - gText_0827E868, - gText_0827E86F, - gText_0827E878, - gText_0827E882 + [CONTEST_CATEGORY_COOL] = gText_Contest_Coolness, + [CONTEST_CATEGORY_BEAUTY] = gText_Contest_Beauty, + [CONTEST_CATEGORY_CUTE] = gText_Contest_Cuteness, + [CONTEST_CATEGORY_SMART] = gText_Contest_Smartness, + [CONTEST_CATEGORY_TOUGH] = gText_Contest_Toughness }; -const u8 *const gUnknown_08587F1C[] = +static const u8 *const sInvalidContestMoveNames[] = { - gText_0827E894, - gText_0827E89E, - gText_0827E8AA, - gText_0827E8B4, - gText_0827E8BF, - gText_0827E8CA + [CONTEST_CATEGORY_COOL] = gText_CoolMove, + [CONTEST_CATEGORY_BEAUTY] = gText_BeautyMove, + [CONTEST_CATEGORY_CUTE] = gText_CuteMove, + [CONTEST_CATEGORY_SMART] = gText_SmartMove, + [CONTEST_CATEGORY_TOUGH] = gText_ToughMove, + [CONTEST_CATEGORIES_COUNT] = gText_3QuestionMarks }; diff --git a/src/data/field_event_obj/event_object_graphics_info_pointers.h b/src/data/field_event_obj/event_object_graphics_info_pointers.h index 0b8aa79b2..661539d57 100755 --- a/src/data/field_event_obj/event_object_graphics_info_pointers.h +++ b/src/data/field_event_obj/event_object_graphics_info_pointers.h @@ -489,11 +489,11 @@ const struct EventObjectGraphicsInfo *const gEventObjectGraphicsInfoPointers[] = }; const struct EventObjectGraphicsInfo *const gMauvilleOldManGraphicsInfoPointers[] = { - &gEventObjectGraphicsInfo_Bard, - &gEventObjectGraphicsInfo_Hipster, - &gEventObjectGraphicsInfo_Trader, - &gEventObjectGraphicsInfo_Storyteller, - &gEventObjectGraphicsInfo_Giddy, - &gEventObjectGraphicsInfo_UnusedMauvilleOldMan1, - &gEventObjectGraphicsInfo_UnusedMauvilleOldMan2, + [MAUVILLE_MAN_BARD] = &gEventObjectGraphicsInfo_Bard, + [MAUVILLE_MAN_HIPSTER] = &gEventObjectGraphicsInfo_Hipster, + [MAUVILLE_MAN_TRADER] = &gEventObjectGraphicsInfo_Trader, + [MAUVILLE_MAN_STORYTELLER] = &gEventObjectGraphicsInfo_Storyteller, + [MAUVILLE_MAN_GIDDY] = &gEventObjectGraphicsInfo_Giddy, + [MAUVILLE_MAN_UNUSED1] = &gEventObjectGraphicsInfo_UnusedMauvilleOldMan1, + [MAUVILLE_MAN_UNUSED2] = &gEventObjectGraphicsInfo_UnusedMauvilleOldMan2, }; diff --git a/src/data/party_menu.h b/src/data/party_menu.h new file mode 100644 index 000000000..6af8ee2a6 --- /dev/null +++ b/src/data/party_menu.h @@ -0,0 +1,1255 @@ +static const struct BgTemplate sPartyMenuBgTemplates[] = +{ + { + .bg = 0, + .charBaseIndex = 0, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 1, + .baseTile = 0 + }, + { + .bg = 1, + .charBaseIndex = 0, + .mapBaseIndex = 30, + .screenSize = 0, + .paletteMode = 0, + .priority = 2, + .baseTile = 0 + }, + { + .bg = 2, + .charBaseIndex = 0, + .mapBaseIndex = 28, + .screenSize = 1, + .paletteMode = 0, + .priority = 0, + .baseTile = 0 + }, +}; + +enum +{ + PARTY_BOX_LEFT_COLUMN, + PARTY_BOX_RIGHT_COLUMN +}; + +static const struct PartyMenuBoxInfoRects sPartyBoxInfoRects[] = +{ + [PARTY_BOX_LEFT_COLUMN] = + { + BlitBitmapToPartyWindow_LeftColumn, + { + //The below are the x, y, width, and height for each of the following info + 24, 11, 40, 13, // Nickname + 32, 20, 32, 8, // Level + 64, 20, 8, 8, // Gender + 38, 37, 24, 8, // HP + 53, 37, 24, 8, // Max HP + 24, 35, 48, 3 // HP bar + }, + 12, 34, 64, 16 // Description text (e.g. NO USE) + }, + [PARTY_BOX_RIGHT_COLUMN] = + { + BlitBitmapToPartyWindow_RightColumn, + { + // See above comment + 22, 3, 40, 13, // Nickname + 30, 12, 32, 8, // Level + 62, 12, 8, 8, // Gender + 102, 12, 24, 8, // HP + 117, 12, 24, 8, // Max HP + 88, 10, 48, 3 // HP bar + }, + 77, 4, 64, 16 // Description text + }, +}; + + +// Each layout array has an array for each of the 6 party slots +// The array for each slot has the sprite coords of its various sprites in the following order +// Pokemon icon (x, y), held item (x, y), status condition (x, y), menu pokeball (x, y) +static const u8 sPartyMenuSpriteCoords[PARTY_LAYOUT_COUNT][PARTY_SIZE][4 * 2] = +{ + [PARTY_LAYOUT_SINGLE] = + { + { 16, 40, 20, 50, 50, 52, 16, 34}, + {104, 18, 108, 28, 136, 27, 102, 25}, + {104, 42, 108, 52, 136, 51, 102, 49}, + {104, 66, 108, 76, 136, 75, 102, 73}, + {104, 90, 108, 100, 136, 99, 102, 97}, + {104, 114, 108, 124, 136, 123, 102, 121}, + }, + [PARTY_LAYOUT_DOUBLE] = + { + {16, 24, 20, 34, 50, 36, 16, 18}, + {16, 80, 20, 90, 50, 92, 16, 74}, + {104, 18, 108, 28, 136, 27, 102, 25}, + {104, 50, 108, 60, 136, 59, 102, 57}, + {104, 82, 108, 92, 136, 91, 102, 89}, + {104, 114, 108, 124, 136, 123, 102, 121}, + }, + [PARTY_LAYOUT_MULTI] = + { + {16, 24, 20, 34, 50, 36, 16, 18}, + {16, 80, 20, 90, 50, 92, 16, 74}, + {104, 26, 106, 36, 136, 35, 102, 33}, + {104, 50, 106, 60, 136, 59, 102, 57}, + {104, 82, 106, 92, 136, 91, 102, 89}, + {104, 106, 106, 116, 136, 115, 102, 113}, + }, + [PARTY_LAYOUT_MULTI_SHOWCASE] = + { + {16, 32, 20, 42, 50, 44, 16, 26}, + {104, 34, 106, 44, 136, 43, 102, 41}, + {104, 58, 106, 68, 136, 67, 102, 65}, + {16, 104, 20, 114, 50, 116, 16, 98}, + {104, 106, 106, 116, 136, 115, 102, 113}, + {104, 130, 106, 140, 136, 139, 102, 137}, + }, +}; + +// Used only when both Cancel and Confirm are present +static const u32 sConfirmButton_Tilemap[] = INCBIN_U32("graphics/interface/party_menu_confirm_button.bin"); +static const u32 sCancelButton_Tilemap[] = INCBIN_U32("graphics/interface/party_menu_cancel_button.bin"); + +// Text colors for BG, FG, and Shadow in that order +static const u8 sFontColorTable[][3] = +{ + {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_LIGHT_GREY, TEXT_COLOR_DARK_GREY}, // Default + {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_GREEN}, // Unused + {TEXT_COLOR_TRANSPARENT, TEXT_DYNAMIC_COLOR_2, TEXT_DYNAMIC_COLOR_3}, // Gender symbol + {TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY}, // Selection actions + {TEXT_COLOR_WHITE, TEXT_COLOR_BLUE, TEXT_COLOR_LIGHT_BLUE}, // Field moves + {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY}, // Unused +}; + +static const struct WindowTemplate sSinglePartyMenuWindowTemplate[] = +{ + { + .bg = 0, + .tilemapLeft = 1, + .tilemapTop = 3, + .width = 10, + .height = 7, + .paletteNum = 3, + .baseBlock = 0x63, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 1, + .width = 18, + .height = 3, + .paletteNum = 4, + .baseBlock = 0xA9, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 4, + .width = 18, + .height = 3, + .paletteNum = 5, + .baseBlock = 0xDF, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 7, + .width = 18, + .height = 3, + .paletteNum = 6, + .baseBlock = 0x115, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 10, + .width = 18, + .height = 3, + .paletteNum = 7, + .baseBlock = 0x14B, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 13, + .width = 18, + .height = 3, + .paletteNum = 8, + .baseBlock = 0x181, + }, + { + .bg = 2, + .tilemapLeft = 1, + .tilemapTop = 15, + .width = 28, + .height = 4, + .paletteNum = 14, + .baseBlock = 0x1DF, + }, + DUMMY_WIN_TEMPLATE +}; + +static const struct WindowTemplate sDoublePartyMenuWindowTemplate[] = +{ + { + .bg = 0, + .tilemapLeft = 1, + .tilemapTop = 1, + .width = 10, + .height = 7, + .paletteNum = 3, + .baseBlock = 0x63, + }, + { + .bg = 0, + .tilemapLeft = 1, + .tilemapTop = 8, + .width = 10, + .height = 7, + .paletteNum = 4, + .baseBlock = 0xA9, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 1, + .width = 18, + .height = 3, + .paletteNum = 5, + .baseBlock = 0xEF, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 5, + .width = 18, + .height = 3, + .paletteNum = 6, + .baseBlock = 0x125, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 9, + .width = 18, + .height = 3, + .paletteNum = 7, + .baseBlock = 0x15B, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 13, + .width = 18, + .height = 3, + .paletteNum = 8, + .baseBlock = 0x191, + }, + { + .bg = 2, + .tilemapLeft = 1, + .tilemapTop = 15, + .width = 28, + .height = 4, + .paletteNum = 14, + .baseBlock = 0x1DF, + }, + DUMMY_WIN_TEMPLATE +}; + +static const struct WindowTemplate sMultiPartyMenuWindowTemplate[] = +{ + { + .bg = 0, + .tilemapLeft = 1, + .tilemapTop = 1, + .width = 10, + .height = 7, + .paletteNum = 3, + .baseBlock = 0x63, + }, + { + .bg = 0, + .tilemapLeft = 1, + .tilemapTop = 8, + .width = 10, + .height = 7, + .paletteNum = 4, + .baseBlock = 0xA9, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 2, + .width = 18, + .height = 3, + .paletteNum = 5, + .baseBlock = 0xEF, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 5, + .width = 18, + .height = 3, + .paletteNum = 6, + .baseBlock = 0x125, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 9, + .width = 18, + .height = 3, + .paletteNum = 7, + .baseBlock = 0x15B, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 12, + .width = 18, + .height = 3, + .paletteNum = 8, + .baseBlock = 0x191, + }, + { + .bg = 2, + .tilemapLeft = 1, + .tilemapTop = 15, + .width = 28, + .height = 4, + .paletteNum = 14, + .baseBlock = 0x1DF, + }, + DUMMY_WIN_TEMPLATE +}; + +static const struct WindowTemplate sShowcaseMultiPartyMenuWindowTemplate[] = +{ + { + .bg = 0, + .tilemapLeft = 1, + .tilemapTop = 2, + .width = 10, + .height = 7, + .paletteNum = 3, + .baseBlock = 0x63, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 3, + .width = 18, + .height = 3, + .paletteNum = 5, + .baseBlock = 0xA9, + }, + { + .bg = 0, + .tilemapLeft = 12, + .tilemapTop = 6, + .width = 18, + .height = 3, + .paletteNum = 6, + .baseBlock = 0xDF, + }, + { + .bg = 2, + .tilemapLeft = 1, + .tilemapTop = 11, + .width = 10, + .height = 7, + .paletteNum = 4, + .baseBlock = 0x115, + }, + { + .bg = 2, + .tilemapLeft = 12, + .tilemapTop = 12, + .width = 18, + .height = 3, + .paletteNum = 7, + .baseBlock = 0x16B, + }, + { + .bg = 2, + .tilemapLeft = 12, + .tilemapTop = 15, + .width = 18, + .height = 3, + .paletteNum = 8, + .baseBlock = 0x1A1, + }, + DUMMY_WIN_TEMPLATE +}; + +static const struct WindowTemplate sCancelButtonWindowTemplate = +{ + .bg = 0, + .tilemapLeft = 24, + .tilemapTop = 17, + .width = 6, + .height = 2, + .paletteNum = 3, + .baseBlock = 0x1C7, +}; + +static const struct WindowTemplate sMultiCancelButtonWindowTemplate = +{ + .bg = 0, + .tilemapLeft = 24, + .tilemapTop = 18, + .width = 6, + .height = 2, + .paletteNum = 3, + .baseBlock = 0x1C7, +}; + +static const struct WindowTemplate sConfirmButtonWindowTemplate = +{ + .bg = 0, + .tilemapLeft = 24, + .tilemapTop = 16, + .width = 6, + .height = 2, + .paletteNum = 3, + .baseBlock = 0x1D3, +}; + +static const struct WindowTemplate sDefaultPartyMsgWindowTemplate = +{ + .bg = 2, + .tilemapLeft = 1, + .tilemapTop = 17, + .width = 21, + .height = 2, + .paletteNum = 15, + .baseBlock = 0x24F, +}; + +static const struct WindowTemplate sDoWhatWithMonMsgWindowTemplate = +{ + .bg = 2, + .tilemapLeft = 1, + .tilemapTop = 17, + .width = 16, + .height = 2, + .paletteNum = 15, + .baseBlock = 0x279, +}; + +static const struct WindowTemplate sDoWhatWithItemMsgWindowTemplate = +{ + .bg = 2, + .tilemapLeft = 1, + .tilemapTop = 17, + .width = 20, + .height = 2, + .paletteNum = 15, + .baseBlock = 0x299, +}; + +static const struct WindowTemplate sDoWhatWithMailMsgWindowTemplate = +{ + .bg = 2, + .tilemapLeft = 1, + .tilemapTop = 17, + .width = 18, + .height = 2, + .paletteNum = 15, + .baseBlock = 0x299, +}; + +static const struct WindowTemplate sWhichMoveMsgWindowTemplate = +{ + .bg = 2, + .tilemapLeft = 1, + .tilemapTop = 17, + .width = 16, + .height = 2, + .paletteNum = 15, + .baseBlock = 0x299, +}; + +static const struct WindowTemplate sAlreadyHoldingOneMsgWindowTemplate = +{ + .bg = 2, + .tilemapLeft = 1, + .tilemapTop = 15, + .width = 20, + .height = 4, + .paletteNum = 15, + .baseBlock = 0x299, +}; + +static const struct WindowTemplate sItemGiveTakeWindowTemplate = +{ + .bg = 2, + .tilemapLeft = 23, + .tilemapTop = 13, + .width = 6, + .height = 6, + .paletteNum = 14, + .baseBlock = 0x39D, +}; + +static const struct WindowTemplate sMailReadTakeWindowTemplate = +{ + .bg = 2, + .tilemapLeft = 21, + .tilemapTop = 13, + .width = 8, + .height = 6, + .paletteNum = 14, + .baseBlock = 0x39D, +}; + +static const struct WindowTemplate sMoveSelectWindowTemplate = +{ + .bg = 2, + .tilemapLeft = 19, + .tilemapTop = 11, + .width = 10, + .height = 8, + .paletteNum = 14, + .baseBlock = 0x2E9, +}; + +static const struct WindowTemplate sPartyMenuYesNoWindowTemplate = +{ + .bg = 2, + .tilemapLeft = 21, + .tilemapTop = 9, + .width = 5, + .height = 4, + .paletteNum = 14, + .baseBlock = 0x2E9, +}; + +static const struct WindowTemplate sLevelUpStatsWindowTemplate = +{ + .bg = 2, + .tilemapLeft = 19, + .tilemapTop = 1, + .width = 10, + .height = 11, + .paletteNum = 14, + .baseBlock = 0x2E9, +}; + +static const struct WindowTemplate sUnusedWindowTemplate_08615978 = +{ + .bg = 2, + .tilemapLeft = 2, + .tilemapTop = 15, + .width = 27, + .height = 4, + .paletteNum = 14, + .baseBlock = 0x1DF, +}; + +static const struct WindowTemplate sUnusedWindowTemplate_08615980 = +{ + .bg = 2, + .tilemapLeft = 0, + .tilemapTop = 13, + .width = 18, + .height = 3, + .paletteNum = 12, + .baseBlock = 0x39D, +}; + +// Tile nums +static const u8 sMainSlotTileNums[] = {24, 25, 25, 25, 25, 25, 25, 25, 25, 26, + 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, + 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, + 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, + 40, 59, 60, 58, 58, 58, 58, 58, 58, 61, + 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, + 46, 47, 47, 47, 47, 47, 47, 47, 47, 48}; + +static const u8 sMainSlotTileNums_Egg[] = {24, 25, 25, 25, 25, 25, 25, 25, 25, 26, + 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, + 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, + 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, + 40, 41, 41, 41, 41, 41, 41, 41, 41, 42, + 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, + 46, 47, 47, 47, 47, 47, 47, 47, 47, 48}; + +static const u8 sOtherSlotsTileNums[] = {43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, + 49, 33, 33, 33, 33, 33, 33, 33, 33, 52, 53, 51, 51, 51, 51, 51, 51, 54, + 55, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 57}; + +static const u8 sOtherSlotsTileNums_Egg[] = {43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, + 49, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 50, + 55, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 57}; + +static const u8 sEmptySlotTileNums[] = {21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, + 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, + 37, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 39}; + +// Palette offsets +static const u8 sGenderPalOffsets[] = {11, 12}; +static const u8 sHPBarPalOffsets[] = {9, 10}; +static const u8 sPartyBoxPalOffsets1[] = {4, 5, 6}; +static const u8 sPartyBoxPalOffsets2[] = {1, 7, 8}; +static const u8 sPartyBoxNoMonPalOffsets[] = {1, 11, 12}; + +// Palette ids +static const u8 sGenderMalePalIds[] = {59, 60}; +static const u8 sGenderFemalePalIds[] = {75, 76}; +static const u8 sHPBarGreenPalIds[] = {57, 58}; +static const u8 sHPBarYellowPalIds[] = {73, 74}; +static const u8 sHPBarRedPalIds[] = {89, 90}; +static const u8 sPartyBoxEmptySlotPalIds1[] = {52, 53, 54}; +static const u8 sPartyBoxMultiPalIds1[] = {68, 69, 70}; +static const u8 sPartyBoxFaintedPalIds1[] = {84, 85, 86}; +static const u8 sPartyBoxCurrSelectionPalIds1[] = {116, 117, 118}; +static const u8 sPartyBoxCurrSelectionMultiPalIds[] = {132, 133, 134}; +static const u8 sPartyBoxCurrSelectionFaintedPalIds[] = {148, 149, 150}; +static const u8 sPartyBoxSelectedForActionPalIds1[] = {100, 101, 102}; +static const u8 sPartyBoxEmptySlotPalIds2[] = {49, 55, 56}; +static const u8 sPartyBoxMultiPalIds2[] = {65, 71, 72}; +static const u8 sPartyBoxFaintedPalIds2[] = {81, 87, 88}; +static const u8 sPartyBoxCurrSelectionPalIds2[] = {97, 103, 104}; +static const u8 sPartyBoxSelectedForActionPalIds2[] = {161, 167, 168}; +static const u8 sPartyBoxNoMonPalIds[] = {17, 27, 28}; + +static const u8 *const sActionStringTable[] = +{ + [PARTY_MSG_CHOOSE_MON] = gText_ChoosePokemon, + [PARTY_MSG_CHOOSE_MON_OR_CANCEL] = gText_ChoosePokemonCancel, + [PARTY_MSG_CHOOSE_MON_AND_CONFIRM] = gText_ChoosePokemonConfirm, + [PARTY_MSG_MOVE_TO_WHERE] = gText_MoveToWhere, + [PARTY_MSG_TEACH_WHICH_MON] = gText_TeachWhichPokemon, + [PARTY_MSG_USE_ON_WHICH_MON] = gText_UseOnWhichPokemon, + [PARTY_MSG_GIVE_TO_WHICH_MON] = gText_GiveToWhichPokemon, + [PARTY_MSG_NOTHING_TO_CUT] = gText_NothingToCut, + [PARTY_MSG_CANT_SURF_HERE] = gText_CantSurfHere, + [PARTY_MSG_ALREADY_SURFING] = gText_AlreadySurfing, + [PARTY_MSG_CURRENT_TOO_FAST] = gText_CurrentIsTooFast, + [PARTY_MSG_ENJOY_CYCLING] = gText_EnjoyCycling, + [PARTY_MSG_ALREADY_IN_USE] = gText_InUseAlready_PM, + [PARTY_MSG_CANT_USE_HERE] = gText_CantUseHere, + [PARTY_MSG_NO_MON_FOR_BATTLE] = gText_NoPokemonForBattle, + [PARTY_MSG_CHOOSE_MON_2] = gText_ChoosePokemon2, + [PARTY_MSG_NOT_ENOUGH_HP] = gText_NotEnoughHp, + [PARTY_MSG_X_MONS_ARE_NEEDED] = gText_PokemonAreNeeded, + [PARTY_MSG_MONS_CANT_BE_SAME] = gText_PokemonCantBeSame, + [PARTY_MSG_NO_SAME_HOLD_ITEMS] = gText_NoIdenticalHoldItems, + [PARTY_MSG_UNUSED] = gText_EmptyString2, + [PARTY_MSG_DO_WHAT_WITH_MON] = gText_DoWhatWithPokemon, + [PARTY_MSG_RESTORE_WHICH_MOVE] = gText_RestoreWhichMove, + [PARTY_MSG_BOOST_PP_WHICH_MOVE] = gText_BoostPp, + [PARTY_MSG_DO_WHAT_WITH_ITEM] = gText_DoWhatWithItem, + [PARTY_MSG_DO_WHAT_WITH_MAIL] = gText_DoWhatWithMail, + [PARTY_MSG_ALREADY_HOLDING_ONE] = gText_AlreadyHoldingOne, +}; + +static const u8 *const sDescriptionStringTable[] = +{ + [PARTYBOX_DESC_NO_USE] = gText_NoUse, + [PARTYBOX_DESC_ABLE_3] = gText_Able, + [PARTYBOX_DESC_FIRST] = gText_First_PM, + [PARTYBOX_DESC_SECOND] = gText_Second_PM, + [PARTYBOX_DESC_THIRD] = gText_Third_PM, + [PARTYBOX_DESC_FOURTH] = gText_Fourth, + [PARTYBOX_DESC_ABLE] = gText_Able2, + [PARTYBOX_DESC_NOT_ABLE] = gText_NotAble, + [PARTYBOX_DESC_ABLE_2] = gText_Able3, + [PARTYBOX_DESC_NOT_ABLE_2] = gText_NotAble2, + [PARTYBOX_DESC_LEARNED] = gText_Learned, + [PARTYBOX_DESC_HAVE] = gText_Have, + [PARTYBOX_DESC_DONT_HAVE] = gText_DontHave, +}; + +static const u16 sUnused_08615B94[] = +{ + 0x0108, 0x0151, 0x0160, 0x015b, 0x002e, 0x005c, 0x0102, 0x0153, 0x014b, 0x00ed, 0x00f1, 0x010d, 0x003a, 0x003b, 0x003f, 0x0071, + 0x00b6, 0x00f0, 0x00ca, 0x00db, 0x00da, 0x004c, 0x00e7, 0x0055, 0x0057, 0x0059, 0x00d8, 0x005b, 0x005e, 0x00f7, 0x0118, 0x0068, + 0x0073, 0x015f, 0x0035, 0x00bc, 0x00c9, 0x007e, 0x013d, 0x014c, 0x0103, 0x0107, 0x0122, 0x009c, 0x00d5, 0x00a8, 0x00d3, 0x011d, + 0x0121, 0x013b, 0x000f, 0x0013, 0x0039, 0x0046, 0x0094, 0x00f9, 0x007f, 0x0123, +}; + +enum +{ + MENU_SUMMARY, + MENU_SWITCH, + MENU_CANCEL1, + MENU_ITEM, + MENU_GIVE, + MENU_TAKE_ITEM, + MENU_MAIL, + MENU_TAKE_MAIL, + MENU_READ, + MENU_CANCEL2, + MENU_SHIFT, + MENU_SEND_OUT, + MENU_ENTER, + MENU_NO_ENTRY, + MENU_STORE, + MENU_REGISTER, + MENU_TRADE1, + MENU_TRADE2, + MENU_TOSS, + MENU_FIELD_MOVES, +}; + +enum +{ + FIELD_MOVE_CUT, + FIELD_MOVE_FLASH, + FIELD_MOVE_ROCK_SMASH, + FIELD_MOVE_STRENGTH, + FIELD_MOVE_SURF, + FIELD_MOVE_FLY, + FIELD_MOVE_DIVE, + FIELD_MOVE_WATERFALL, + FIELD_MOVE_TELEPORT, + FIELD_MOVE_DIG, + FIELD_MOVE_SECRET_POWER, + FIELD_MOVE_MILK_DRINK, + FIELD_MOVE_SOFT_BOILED, + FIELD_MOVE_SWEET_SCENT, +}; + +// What a weird choice of table termination; +#define FIELD_MOVE_TERMINATOR MOVE_SWORDS_DANCE + +struct +{ + const u8 *text; + TaskFunc func; +} static const sCursorOptions[] = +{ + [MENU_SUMMARY] = {gText_Summary5, CursorCb_Summary}, + [MENU_SWITCH] = {gText_Switch2, CursorCb_Switch}, + [MENU_CANCEL1] = {gText_Cancel2, CursorCb_Cancel1}, + [MENU_ITEM] = {gText_Item, CursorCb_Item}, + [MENU_GIVE] = {gMenuText_Give, CursorCb_Give}, + [MENU_TAKE_ITEM] = {gText_Take, CursorCb_TakeItem}, + [MENU_MAIL] = {gText_Mail, CursorCb_Mail}, + [MENU_TAKE_MAIL] = {gText_Take2, CursorCb_TakeMail}, + [MENU_READ] = {gText_Read2, CursorCb_Read}, + [MENU_CANCEL2] = {gText_Cancel2, CursorCb_Cancel2}, + [MENU_SHIFT] = {gText_Shift, CursorCb_SendMon}, + [MENU_SEND_OUT] = {gText_SendOut, CursorCb_SendMon}, + [MENU_ENTER] = {gText_Enter, CursorCb_Enter}, + [MENU_NO_ENTRY] = {gText_NoEntry, CursorCb_NoEntry}, + [MENU_STORE] = {gText_Store, CursorCb_Store}, + [MENU_REGISTER] = {gText_Register, CursorCb_Register}, + [MENU_TRADE1] = {gText_Trade4, CursorCb_Trade1}, + [MENU_TRADE2] = {gText_Trade4, CursorCb_Trade2}, + [MENU_TOSS] = {gMenuText_Toss, CursorCb_Toss}, + [MENU_FIELD_MOVES + FIELD_MOVE_CUT] = {gMoveNames[MOVE_CUT], CursorCb_FieldMove}, + [MENU_FIELD_MOVES + FIELD_MOVE_FLASH] = {gMoveNames[MOVE_FLASH], CursorCb_FieldMove}, + [MENU_FIELD_MOVES + FIELD_MOVE_ROCK_SMASH] = {gMoveNames[MOVE_ROCK_SMASH], CursorCb_FieldMove}, + [MENU_FIELD_MOVES + FIELD_MOVE_STRENGTH] = {gMoveNames[MOVE_STRENGTH], CursorCb_FieldMove}, + [MENU_FIELD_MOVES + FIELD_MOVE_SURF] = {gMoveNames[MOVE_SURF], CursorCb_FieldMove}, + [MENU_FIELD_MOVES + FIELD_MOVE_FLY] = {gMoveNames[MOVE_FLY], CursorCb_FieldMove}, + [MENU_FIELD_MOVES + FIELD_MOVE_DIVE] = {gMoveNames[MOVE_DIVE], CursorCb_FieldMove}, + [MENU_FIELD_MOVES + FIELD_MOVE_WATERFALL] = {gMoveNames[MOVE_WATERFALL], CursorCb_FieldMove}, + [MENU_FIELD_MOVES + FIELD_MOVE_TELEPORT] = {gMoveNames[MOVE_TELEPORT], CursorCb_FieldMove}, + [MENU_FIELD_MOVES + FIELD_MOVE_DIG] = {gMoveNames[MOVE_DIG], CursorCb_FieldMove}, + [MENU_FIELD_MOVES + FIELD_MOVE_SECRET_POWER] = {gMoveNames[MOVE_SECRET_POWER], CursorCb_FieldMove}, + [MENU_FIELD_MOVES + FIELD_MOVE_MILK_DRINK] = {gMoveNames[MOVE_MILK_DRINK], CursorCb_FieldMove}, + [MENU_FIELD_MOVES + FIELD_MOVE_SOFT_BOILED] = {gMoveNames[MOVE_SOFT_BOILED], CursorCb_FieldMove}, + [MENU_FIELD_MOVES + FIELD_MOVE_SWEET_SCENT] = {gMoveNames[MOVE_SWEET_SCENT], CursorCb_FieldMove}, +}; + +static const u8 sPartyMenuAction_SummarySwitchCancel[] = {MENU_SUMMARY, MENU_SWITCH, MENU_CANCEL1}; +static const u8 sPartyMenuAction_ShiftSummaryCancel[] = {MENU_SHIFT, MENU_SUMMARY, MENU_CANCEL1}; +static const u8 sPartyMenuAction_SendOutSummaryCancel[] = {MENU_SEND_OUT, MENU_SUMMARY, MENU_CANCEL1}; +static const u8 sPartyMenuAction_SummaryCancel[] = {MENU_SUMMARY, MENU_CANCEL1}; +static const u8 sPartyMenuAction_EnterSummaryCancel[] = {MENU_ENTER, MENU_SUMMARY, MENU_CANCEL1}; +static const u8 sPartyMenuAction_NoEntrySummaryCancel[] = {MENU_NO_ENTRY, MENU_SUMMARY, MENU_CANCEL1}; +static const u8 sPartyMenuAction_StoreSummaryCancel[] = {MENU_STORE, MENU_SUMMARY, MENU_CANCEL1}; +static const u8 sPartyMenuAction_GiveTakeItemCancel[] = {MENU_GIVE, MENU_TAKE_ITEM, MENU_CANCEL2}; +static const u8 sPartyMenuAction_ReadTakeMailCancel[] = {MENU_READ, MENU_TAKE_MAIL, MENU_CANCEL2}; +static const u8 sPartyMenuAction_RegisterSummaryCancel[] = {MENU_REGISTER, MENU_SUMMARY, MENU_CANCEL1}; +static const u8 sPartyMenuAction_TradeSummaryCancel1[] = {MENU_TRADE1, MENU_SUMMARY, MENU_CANCEL1}; +static const u8 sPartyMenuAction_TradeSummaryCancel2[] = {MENU_TRADE2, MENU_SUMMARY, MENU_CANCEL1}; +static const u8 sPartyMenuAction_TakeItemTossCancel[] = {MENU_TAKE_ITEM, MENU_TOSS, MENU_CANCEL1}; + +// IDs for the action lists that appear when a party mon is selected +enum +{ + ACTIONS_NONE, + ACTIONS_SWITCH, + ACTIONS_SHIFT, + ACTIONS_SEND_OUT, + ACTIONS_ENTER, + ACTIONS_NO_ENTRY, + ACTIONS_STORE, + ACTIONS_SUMMARY_ONLY, + ACTIONS_ITEM, + ACTIONS_MAIL, + ACTIONS_REGISTER, + ACTIONS_TRADE, + ACTIONS_SPIN_TRADE, + ACTIONS_TAKEITEM_TOSS +}; + +static const u8 *const sPartyMenuActions[] = +{ + [ACTIONS_NONE] = NULL, + [ACTIONS_SWITCH] = sPartyMenuAction_SummarySwitchCancel, + [ACTIONS_SHIFT] = sPartyMenuAction_ShiftSummaryCancel, + [ACTIONS_SEND_OUT] = sPartyMenuAction_SendOutSummaryCancel, + [ACTIONS_ENTER] = sPartyMenuAction_EnterSummaryCancel, + [ACTIONS_NO_ENTRY] = sPartyMenuAction_NoEntrySummaryCancel, + [ACTIONS_STORE] = sPartyMenuAction_StoreSummaryCancel, + [ACTIONS_SUMMARY_ONLY] = sPartyMenuAction_SummaryCancel, + [ACTIONS_ITEM] = sPartyMenuAction_GiveTakeItemCancel, + [ACTIONS_MAIL] = sPartyMenuAction_ReadTakeMailCancel, + [ACTIONS_REGISTER] = sPartyMenuAction_RegisterSummaryCancel, + [ACTIONS_TRADE] = sPartyMenuAction_TradeSummaryCancel1, + [ACTIONS_SPIN_TRADE] = sPartyMenuAction_TradeSummaryCancel2, + [ACTIONS_TAKEITEM_TOSS] = sPartyMenuAction_TakeItemTossCancel, +}; + +static const u8 sPartyMenuActionCounts[] = +{ + [ACTIONS_NONE] = 0, + [ACTIONS_SWITCH] = ARRAY_COUNT(sPartyMenuAction_SummarySwitchCancel), + [ACTIONS_SHIFT] = ARRAY_COUNT(sPartyMenuAction_ShiftSummaryCancel), + [ACTIONS_SEND_OUT] = ARRAY_COUNT(sPartyMenuAction_SendOutSummaryCancel), + [ACTIONS_ENTER] = ARRAY_COUNT(sPartyMenuAction_EnterSummaryCancel), + [ACTIONS_NO_ENTRY] = ARRAY_COUNT(sPartyMenuAction_NoEntrySummaryCancel), + [ACTIONS_STORE] = ARRAY_COUNT(sPartyMenuAction_StoreSummaryCancel), + [ACTIONS_SUMMARY_ONLY] = ARRAY_COUNT(sPartyMenuAction_SummaryCancel), + [ACTIONS_ITEM] = ARRAY_COUNT(sPartyMenuAction_GiveTakeItemCancel), + [ACTIONS_MAIL] = ARRAY_COUNT(sPartyMenuAction_ReadTakeMailCancel), + [ACTIONS_REGISTER] = ARRAY_COUNT(sPartyMenuAction_RegisterSummaryCancel), + [ACTIONS_TRADE] = ARRAY_COUNT(sPartyMenuAction_TradeSummaryCancel1), + [ACTIONS_SPIN_TRADE] = ARRAY_COUNT(sPartyMenuAction_TradeSummaryCancel2), + [ACTIONS_TAKEITEM_TOSS] = ARRAY_COUNT(sPartyMenuAction_TakeItemTossCancel) +}; + +static const u16 sFieldMoves[] = +{ + MOVE_CUT, MOVE_FLASH, MOVE_ROCK_SMASH, MOVE_STRENGTH, MOVE_SURF, MOVE_FLY, MOVE_DIVE, MOVE_WATERFALL, MOVE_TELEPORT, + MOVE_DIG, MOVE_SECRET_POWER, MOVE_MILK_DRINK, MOVE_SOFT_BOILED, MOVE_SWEET_SCENT, FIELD_MOVE_TERMINATOR +}; + +struct +{ + bool8 (*fieldMoveFunc)(void); + u8 msgId; +} static const sFieldMoveCursorCallbacks[] = +{ + [FIELD_MOVE_CUT] = {SetUpFieldMove_Cut, PARTY_MSG_NOTHING_TO_CUT}, + [FIELD_MOVE_FLASH] = {SetUpFieldMove_Flash, PARTY_MSG_CANT_USE_HERE}, + [FIELD_MOVE_ROCK_SMASH] = {SetUpFieldMove_RockSmash, PARTY_MSG_CANT_USE_HERE}, + [FIELD_MOVE_STRENGTH] = {SetUpFieldMove_Strength, PARTY_MSG_CANT_USE_HERE}, + [FIELD_MOVE_SURF] = {SetUpFieldMove_Surf, PARTY_MSG_CANT_SURF_HERE}, + [FIELD_MOVE_FLY] = {SetUpFieldMove_Fly, PARTY_MSG_CANT_USE_HERE}, + [FIELD_MOVE_DIVE] = {SetUpFieldMove_Dive, PARTY_MSG_CANT_USE_HERE}, + [FIELD_MOVE_WATERFALL] = {SetUpFieldMove_Waterfall, PARTY_MSG_CANT_USE_HERE}, + [FIELD_MOVE_TELEPORT] = {SetUpFieldMove_Teleport, PARTY_MSG_CANT_USE_HERE}, + [FIELD_MOVE_DIG] = {SetUpFieldMove_Dig, PARTY_MSG_CANT_USE_HERE}, + [FIELD_MOVE_SECRET_POWER] = {SetUpFieldMove_SecretPower, PARTY_MSG_CANT_USE_HERE}, + [FIELD_MOVE_MILK_DRINK] = {SetUpFieldMove_SoftBoiled, PARTY_MSG_NOT_ENOUGH_HP}, + [FIELD_MOVE_SOFT_BOILED] = {SetUpFieldMove_SoftBoiled, PARTY_MSG_NOT_ENOUGH_HP}, + [FIELD_MOVE_SWEET_SCENT] = {SetUpFieldMove_SweetScent, PARTY_MSG_CANT_USE_HERE}, +}; + +static const u8 *const sUnionRoomTradeMessages[] = +{ + [UR_TRADE_MSG_NOT_MON_PARTNER_WANTS - 1] = gText_NotPkmnOtherTrainerWants, + [UR_TRADE_MSG_NOT_EGG - 1] = gText_ThatIsntAnEgg, + [UR_TRADE_MSG_MON_CANT_BE_TRADED_1 - 1] = gText_PkmnCantBeTradedNow, + [UR_TRADE_MSG_MON_CANT_BE_TRADED_2 - 1] = gText_PkmnCantBeTradedNow, + [UR_TRADE_MSG_PARTNERS_MON_CANT_BE_TRADED - 1] = gText_OtherTrainersPkmnCantBeTraded, + [UR_TRADE_MSG_EGG_CANT_BE_TRADED -1] = gText_EggCantBeTradedNow, + [UR_TRADE_MSG_PARTNER_CANT_ACCEPT_MON - 1] = gText_OtherTrainerCantAcceptPkmn, + [UR_TRADE_MSG_CANT_TRADE_WITH_PARTNER_1 - 1] = gText_CantTradeWithTrainer, + [UR_TRADE_MSG_CANT_TRADE_WITH_PARTNER_2 - 1] = gText_CantTradeWithTrainer, +}; + +static const u32 sHeldItemGfx[] = INCBIN_U32("graphics/interface/hold_icons.4bpp"); +static const u16 sHeldItemPalette[] = INCBIN_U16("graphics/interface/hold_icons.gbapal"); + +static const struct OamData sOamData_HeldItem = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = SPRITE_SHAPE(8x8), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(8x8), + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; + +static const union AnimCmd sSpriteAnim_HeldItem[] = +{ + ANIMCMD_FRAME(0, 1), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_HeldMail[] = +{ + ANIMCMD_FRAME(1, 1), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteAnimTable_HeldItem[] = +{ + sSpriteAnim_HeldItem, + sSpriteAnim_HeldMail, +}; + +static const struct SpriteSheet sSpriteSheet_HeldItem = +{ + sHeldItemGfx, sizeof(sHeldItemGfx), 0xd750 +}; + +static const struct SpritePalette sSpritePalette_HeldItem = +{ + sHeldItemPalette, 0xd750 +}; + +static const struct SpriteTemplate sSpriteTemplate_HeldItem = +{ + 0xd750, + 0xd750, + &sOamData_HeldItem, + sSpriteAnimTable_HeldItem, + NULL, + gDummySpriteAffineAnimTable, + SpriteCallbackDummy +}; + +static const struct OamData sOamData_MenuPokeball = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = SPRITE_SHAPE(32x32), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(32x32), + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0 +}; + +static const union AnimCmd sPokeballAnim_Closed[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd sPokeballAnim_Open[] = +{ + ANIMCMD_FRAME(16, 0), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteAnimTable_MenuPokeball[] = +{ + sPokeballAnim_Closed, + sPokeballAnim_Open +}; + +static const struct CompressedSpriteSheet sSpriteSheet_MenuPokeball = +{ + gPartyMenuPokeball_Gfx, 0x400, 0x04b0 +}; + +static const struct CompressedSpritePalette sSpritePalette_MenuPokeball = +{ + gPartyMenuPokeball_Pal, 0x04b0 +}; + +// Used for the pokeball sprite on each party slot / Cancel button +static const struct SpriteTemplate sSpriteTemplate_MenuPokeball = +{ + .tileTag = 0x04b0, + .paletteTag = 0x04b0, + .oam = &sOamData_MenuPokeball, + .anims = sSpriteAnimTable_MenuPokeball, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +static const struct OamData sOamData_MenuPokeballSmall = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = SPRITE_SHAPE(16x16), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(16x16), + .tileNum = 0, + .priority = 2, + .paletteNum = 0, + .affineParam = 0 +}; + +static const union AnimCmd sSmallPokeballAnim_Closed[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSmallPokeballAnim_Open[] = +{ + ANIMCMD_FRAME(4, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSmallPokeballAnim_Blank1[] = +{ + ANIMCMD_FRAME(8, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSmallPokeballAnim_Blank2[] = +{ + ANIMCMD_FRAME(12, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSmallPokeballAnim_Blank3[] = +{ + ANIMCMD_FRAME(16, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSmallPokeballAnim_Blank4[] = +{ + ANIMCMD_FRAME(20, 0), + ANIMCMD_END +}; + +// The blanks below are never used. See SpriteCB_BounceConfirmCancelButton, where they were intended to be used +static const union AnimCmd *const sSpriteAnimTable_MenuPokeballSmall[] = +{ + sSmallPokeballAnim_Closed, + sSmallPokeballAnim_Open, + sSmallPokeballAnim_Blank1, + sSmallPokeballAnim_Blank2, + sSmallPokeballAnim_Blank3, + sSmallPokeballAnim_Blank4 +}; + +static const struct CompressedSpriteSheet sSpriteSheet_MenuPokeballSmall = +{ + gPartyMenuPokeballSmall_Gfx, 0x0300, 0x04b1 +}; + +// Used for the pokeball sprite next to Cancel and Confirm when both are present, otherwise sSpriteTemplate_MenuPokeball is used +static const struct SpriteTemplate sSpriteTemplate_MenuPokeballSmall = +{ + .tileTag = 1201, + .paletteTag = 1200, + .oam = &sOamData_MenuPokeballSmall, + .anims = sSpriteAnimTable_MenuPokeballSmall, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +static const struct OamData sOamData_StatusCondition = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = SPRITE_SHAPE(32x8), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(32x8), + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0 +}; + +static const union AnimCmd sSpriteAnim_StatusPoison[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_StatusParalyzed[] = +{ + ANIMCMD_FRAME(4, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_StatusSleep[] = +{ + ANIMCMD_FRAME(8, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_StatusFrozen[] = +{ + ANIMCMD_FRAME(12, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_StatusBurn[] = +{ + ANIMCMD_FRAME(16, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_StatusPokerus[] = +{ + ANIMCMD_FRAME(20, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_StatusFaint[] = +{ + ANIMCMD_FRAME(24, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_Blank[] = +{ + ANIMCMD_FRAME(28, 0), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteTemplate_StatusCondition[] = +{ + sSpriteAnim_StatusPoison, + sSpriteAnim_StatusParalyzed, + sSpriteAnim_StatusSleep, + sSpriteAnim_StatusFrozen, + sSpriteAnim_StatusBurn, + sSpriteAnim_StatusPokerus, + sSpriteAnim_StatusFaint, + sSpriteAnim_Blank +}; + +static const struct CompressedSpriteSheet sSpriteSheet_StatusIcons = +{ + gStatusGfx_Icons, 0x400, 1202 +}; + +static const struct CompressedSpritePalette sSpritePalette_StatusIcons = +{ + gStatusPal_Icons, 1202 +}; + +static const struct SpriteTemplate sSpriteTemplate_StatusIcons = +{ + .tileTag = 1202, + .paletteTag = 1202, + .oam = &sOamData_StatusCondition, + .anims = sSpriteTemplate_StatusCondition, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +// Mask for the partners party in a multi battle. TRUE if in the partners party, FALSE otherwise +// The 7th slot is Cancel, and the 8th slot is unreachable +// Used only to determine whether or not to show the Deoxys form icon sprite +static const bool8 sMultiBattlePartnersPartyMask[PARTY_SIZE + 2] = +{ + FALSE, + TRUE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE +}; + +static const u8 *const sUnused_StatStrings[] = +{ + gText_HP4, + gText_Attack3, + gText_Defense3, + gText_SpAtk4, + gText_SpDef4, + gText_Speed2 +}; + +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, +}; diff --git a/src/data/pokemon/level_up_learnsets.h b/src/data/pokemon/level_up_learnsets.h index 727cc0959..c78b9ef0a 100644 --- a/src/data/pokemon/level_up_learnsets.h +++ b/src/data/pokemon/level_up_learnsets.h @@ -1,5 +1,4 @@ #define LEVEL_UP_MOVE(lvl, move) ((lvl << 9) | move) -#define LEVEL_UP_END 0xffff static const u16 sBulbasaurLevelUpLearnset[] = { LEVEL_UP_MOVE( 1, MOVE_TACKLE), diff --git a/src/data/trainer_parties.h b/src/data/trainer_parties.h index 252eed760..477967b95 100644 --- a/src/data/trainer_parties.h +++ b/src/data/trainer_parties.h @@ -6,7 +6,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Sawyer1[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt1[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntAquaHideout1[] = { { .iv = 0, .lvl = 32, @@ -14,7 +14,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt1[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt2[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntAquaHideout2[] = { { .iv = 0, .lvl = 31, @@ -27,7 +27,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt2[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt3[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntAquaHideout3[] = { { .iv = 0, .lvl = 32, @@ -35,7 +35,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt3[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt4[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntAquaHideout4[] = { { .iv = 0, .lvl = 32, @@ -43,7 +43,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt4[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt5[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntSeafloorCavern1[] = { { .iv = 0, .lvl = 36, @@ -51,7 +51,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt5[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt6[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntSeafloorCavern2[] = { { .iv = 0, .lvl = 36, @@ -59,7 +59,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt6[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt7[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntSeafloorCavern3[] = { { .iv = 0, .lvl = 36, @@ -100,7 +100,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Gabrielle1[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt8[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntPetalburgWoods[] = { { .iv = 0, .lvl = 9, @@ -147,7 +147,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Ed[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt9[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntSeafloorCavern4[] = { { .iv = 0, .lvl = 36, @@ -163,7 +163,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Declan[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt10[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntRusturfTunnel[] = { { .iv = 0, .lvl = 11, @@ -171,7 +171,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt10[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt11[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntWeatherInst1[] = { { .iv = 0, .lvl = 27, @@ -184,7 +184,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt11[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt12[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntWeatherInst2[] = { { .iv = 0, .lvl = 27, @@ -197,7 +197,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt12[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt13[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntWeatherInst3[] = { { .iv = 0, .lvl = 26, @@ -215,7 +215,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt13[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt14[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMuseum1[] = { { .iv = 0, .lvl = 15, @@ -223,7 +223,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt14[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt15[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMuseum2[] = { { .iv = 0, .lvl = 14, @@ -236,7 +236,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt15[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt16[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntSpaceCenter1[] = { { .iv = 0, .lvl = 32, @@ -244,7 +244,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt16[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt17[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMtPyre1[] = { { .iv = 0, .lvl = 32, @@ -252,7 +252,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt17[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt18[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMtPyre2[] = { { .iv = 0, .lvl = 32, @@ -260,7 +260,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt18[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt19[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMtPyre3[] = { { .iv = 0, .lvl = 30, @@ -273,7 +273,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt19[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt20[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntWeatherInst4[] = { { .iv = 0, .lvl = 28, @@ -281,7 +281,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt20[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt21[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntAquaHideout5[] = { { .iv = 0, .lvl = 32, @@ -289,7 +289,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt21[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt22[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntAquaHideout6[] = { { .iv = 0, .lvl = 32, @@ -1474,7 +1474,7 @@ static const struct TrainerMonItemCustomMoves sParty_Daphne[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt23[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntSpaceCenter2[] = { { .iv = 0, .lvl = 26, @@ -1803,7 +1803,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Mark[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt24[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMtChimney1[] = { { .iv = 0, .lvl = 20, @@ -2312,7 +2312,7 @@ static const struct TrainerMonNoItemCustomMoves sParty_Kirk[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt25[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntAquaHideout7[] = { { .iv = 0, .lvl = 31, @@ -2325,7 +2325,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt25[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt26[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntAquaHideout8[] = { { .iv = 0, .lvl = 32, @@ -7594,7 +7594,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Julio[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt27[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntSeafloorCavern5[] = { { .iv = 50, .lvl = 35, @@ -7607,7 +7607,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt27[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt28[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntUnused[] = { { .iv = 0, .lvl = 31, @@ -7620,7 +7620,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt28[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt29[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMtPyre4[] = { { .iv = 0, .lvl = 30, @@ -7633,7 +7633,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt29[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt30[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntJaggedPass[] = { { .iv = 50, .lvl = 22, @@ -7724,7 +7724,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Harrison[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt31[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMtChimney2[] = { { .iv = 0, .lvl = 20, @@ -7780,7 +7780,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Nicholas[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt32[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntSpaceCenter3[] = { { .iv = 0, .lvl = 31, @@ -7793,7 +7793,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt32[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt33[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntSpaceCenter4[] = { { .iv = 0, .lvl = 32, @@ -7801,7 +7801,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt33[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt34[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntSpaceCenter5[] = { { .iv = 0, .lvl = 32, @@ -7809,7 +7809,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt34[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt35[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntSpaceCenter6[] = { { .iv = 0, .lvl = 32, @@ -7817,7 +7817,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt35[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt36[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntSpaceCenter7[] = { { .iv = 0, .lvl = 32, @@ -7880,7 +7880,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Isabella[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt37[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntWeatherInst5[] = { { .iv = 0, .lvl = 27, @@ -9645,7 +9645,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Deandre[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt38[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout1[] = { { .iv = 0, .lvl = 29, @@ -9653,7 +9653,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt38[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt39[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout2[] = { { .iv = 0, .lvl = 29, @@ -9661,7 +9661,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt39[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt40[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout3[] = { { .iv = 0, .lvl = 29, @@ -9669,7 +9669,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt40[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt41[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout4[] = { { .iv = 0, .lvl = 28, @@ -9682,7 +9682,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt41[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt42[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout5[] = { { .iv = 0, .lvl = 28, @@ -9695,7 +9695,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt42[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt43[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout6[] = { { .iv = 0, .lvl = 29, @@ -9703,7 +9703,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt43[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt44[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout7[] = { { .iv = 0, .lvl = 29, @@ -9711,7 +9711,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt44[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt45[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout8[] = { { .iv = 0, .lvl = 29, @@ -9719,7 +9719,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt45[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt46[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout9[] = { { .iv = 0, .lvl = 29, @@ -9727,7 +9727,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt46[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt47[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout10[] = { { .iv = 0, .lvl = 29, @@ -9735,7 +9735,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt47[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt48[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout11[] = { { .iv = 0, .lvl = 29, @@ -9743,7 +9743,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt48[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt49[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout12[] = { { .iv = 0, .lvl = 29, @@ -9751,7 +9751,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt49[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt50[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout13[] = { { .iv = 0, .lvl = 29, @@ -9759,7 +9759,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt50[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt51[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout14[] = { { .iv = 0, .lvl = 29, @@ -9767,7 +9767,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt51[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt52[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout15[] = { { .iv = 0, .lvl = 29, @@ -9775,7 +9775,7 @@ static const struct TrainerMonNoItemDefaultMoves sParty_Grunt52[] = { } }; -static const struct TrainerMonNoItemDefaultMoves sParty_Grunt53[] = { +static const struct TrainerMonNoItemDefaultMoves sParty_GruntMagmaHideout16[] = { { .iv = 0, .lvl = 29, diff --git a/src/data/trainers.h b/src/data/trainers.h index c30d21afd..327107007 100644 --- a/src/data/trainers.h +++ b/src/data/trainers.h @@ -27,7 +27,7 @@ const struct Trainer gTrainers[] = { .party = {.NoItemDefaultMoves = sParty_Sawyer1}, }, - [TRAINER_GRUNT_1] = + [TRAINER_GRUNT_AQUA_HIDEOUT_1] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -37,11 +37,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt1), - .party = {.NoItemDefaultMoves = sParty_Grunt1}, + .partySize = ARRAY_COUNT(sParty_GruntAquaHideout1), + .party = {.NoItemDefaultMoves = sParty_GruntAquaHideout1}, }, - [TRAINER_GRUNT_2] = + [TRAINER_GRUNT_AQUA_HIDEOUT_2] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -51,11 +51,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt2), - .party = {.NoItemDefaultMoves = sParty_Grunt2}, + .partySize = ARRAY_COUNT(sParty_GruntAquaHideout2), + .party = {.NoItemDefaultMoves = sParty_GruntAquaHideout2}, }, - [TRAINER_GRUNT_3] = + [TRAINER_GRUNT_AQUA_HIDEOUT_3] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -65,11 +65,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt3), - .party = {.NoItemDefaultMoves = sParty_Grunt3}, + .partySize = ARRAY_COUNT(sParty_GruntAquaHideout3), + .party = {.NoItemDefaultMoves = sParty_GruntAquaHideout3}, }, - [TRAINER_GRUNT_4] = + [TRAINER_GRUNT_AQUA_HIDEOUT_4] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -79,11 +79,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt4), - .party = {.NoItemDefaultMoves = sParty_Grunt4}, + .partySize = ARRAY_COUNT(sParty_GruntAquaHideout4), + .party = {.NoItemDefaultMoves = sParty_GruntAquaHideout4}, }, - [TRAINER_GRUNT_5] = + [TRAINER_GRUNT_SEAFLOOR_CAVERN_1] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -93,11 +93,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt5), - .party = {.NoItemDefaultMoves = sParty_Grunt5}, + .partySize = ARRAY_COUNT(sParty_GruntSeafloorCavern1), + .party = {.NoItemDefaultMoves = sParty_GruntSeafloorCavern1}, }, - [TRAINER_GRUNT_6] = + [TRAINER_GRUNT_SEAFLOOR_CAVERN_2] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -107,11 +107,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt6), - .party = {.NoItemDefaultMoves = sParty_Grunt6}, + .partySize = ARRAY_COUNT(sParty_GruntSeafloorCavern2), + .party = {.NoItemDefaultMoves = sParty_GruntSeafloorCavern2}, }, - [TRAINER_GRUNT_7] = + [TRAINER_GRUNT_SEAFLOOR_CAVERN_3] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -121,8 +121,8 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt7), - .party = {.NoItemDefaultMoves = sParty_Grunt7}, + .partySize = ARRAY_COUNT(sParty_GruntSeafloorCavern3), + .party = {.NoItemDefaultMoves = sParty_GruntSeafloorCavern3}, }, [TRAINER_GABRIELLE_1] = @@ -139,7 +139,7 @@ const struct Trainer gTrainers[] = { .party = {.NoItemDefaultMoves = sParty_Gabrielle1}, }, - [TRAINER_GRUNT_8] = + [TRAINER_GRUNT_PETALBURG_WOODS] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -149,8 +149,8 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt8), - .party = {.NoItemDefaultMoves = sParty_Grunt8}, + .partySize = ARRAY_COUNT(sParty_GruntPetalburgWoods), + .party = {.NoItemDefaultMoves = sParty_GruntPetalburgWoods}, }, [TRAINER_MARCEL] = @@ -195,7 +195,7 @@ const struct Trainer gTrainers[] = { .party = {.NoItemDefaultMoves = sParty_Ed}, }, - [TRAINER_GRUNT_9] = + [TRAINER_GRUNT_SEAFLOOR_CAVERN_4] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -205,8 +205,8 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt9), - .party = {.NoItemDefaultMoves = sParty_Grunt9}, + .partySize = ARRAY_COUNT(sParty_GruntSeafloorCavern4), + .party = {.NoItemDefaultMoves = sParty_GruntSeafloorCavern4}, }, [TRAINER_DECLAN] = @@ -223,7 +223,7 @@ const struct Trainer gTrainers[] = { .party = {.NoItemDefaultMoves = sParty_Declan}, }, - [TRAINER_GRUNT_10] = + [TRAINER_GRUNT_RUSTURF_TUNNEL] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -233,11 +233,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt10), - .party = {.NoItemDefaultMoves = sParty_Grunt10}, + .partySize = ARRAY_COUNT(sParty_GruntRusturfTunnel), + .party = {.NoItemDefaultMoves = sParty_GruntRusturfTunnel}, }, - [TRAINER_GRUNT_11] = + [TRAINER_GRUNT_WEATHER_INST_1] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -247,11 +247,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt11), - .party = {.NoItemDefaultMoves = sParty_Grunt11}, + .partySize = ARRAY_COUNT(sParty_GruntWeatherInst1), + .party = {.NoItemDefaultMoves = sParty_GruntWeatherInst1}, }, - [TRAINER_GRUNT_12] = + [TRAINER_GRUNT_WEATHER_INST_2] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -261,11 +261,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt12), - .party = {.NoItemDefaultMoves = sParty_Grunt12}, + .partySize = ARRAY_COUNT(sParty_GruntWeatherInst2), + .party = {.NoItemDefaultMoves = sParty_GruntWeatherInst2}, }, - [TRAINER_GRUNT_13] = + [TRAINER_GRUNT_WEATHER_INST_3] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -275,11 +275,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt13), - .party = {.NoItemDefaultMoves = sParty_Grunt13}, + .partySize = ARRAY_COUNT(sParty_GruntWeatherInst3), + .party = {.NoItemDefaultMoves = sParty_GruntWeatherInst3}, }, - [TRAINER_GRUNT_14] = + [TRAINER_GRUNT_MUSEUM_1] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -289,11 +289,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt14), - .party = {.NoItemDefaultMoves = sParty_Grunt14}, + .partySize = ARRAY_COUNT(sParty_GruntMuseum1), + .party = {.NoItemDefaultMoves = sParty_GruntMuseum1}, }, - [TRAINER_GRUNT_15] = + [TRAINER_GRUNT_MUSEUM_2] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -303,11 +303,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt15), - .party = {.NoItemDefaultMoves = sParty_Grunt15}, + .partySize = ARRAY_COUNT(sParty_GruntMuseum2), + .party = {.NoItemDefaultMoves = sParty_GruntMuseum2}, }, - [TRAINER_GRUNT_16] = + [TRAINER_GRUNT_SPACE_CENTER_1] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -317,11 +317,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt16), - .party = {.NoItemDefaultMoves = sParty_Grunt16}, + .partySize = ARRAY_COUNT(sParty_GruntSpaceCenter1), + .party = {.NoItemDefaultMoves = sParty_GruntSpaceCenter1}, }, - [TRAINER_GRUNT_17] = + [TRAINER_GRUNT_MT_PYRE_1] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -331,11 +331,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt17), - .party = {.NoItemDefaultMoves = sParty_Grunt17}, + .partySize = ARRAY_COUNT(sParty_GruntMtPyre1), + .party = {.NoItemDefaultMoves = sParty_GruntMtPyre1}, }, - [TRAINER_GRUNT_18] = + [TRAINER_GRUNT_MT_PYRE_2] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -345,11 +345,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt18), - .party = {.NoItemDefaultMoves = sParty_Grunt18}, + .partySize = ARRAY_COUNT(sParty_GruntMtPyre2), + .party = {.NoItemDefaultMoves = sParty_GruntMtPyre2}, }, - [TRAINER_GRUNT_19] = + [TRAINER_GRUNT_MT_PYRE_3] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -359,11 +359,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt19), - .party = {.NoItemDefaultMoves = sParty_Grunt19}, + .partySize = ARRAY_COUNT(sParty_GruntMtPyre3), + .party = {.NoItemDefaultMoves = sParty_GruntMtPyre3}, }, - [TRAINER_GRUNT_20] = + [TRAINER_GRUNT_WEATHER_INST_4] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -373,11 +373,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt20), - .party = {.NoItemDefaultMoves = sParty_Grunt20}, + .partySize = ARRAY_COUNT(sParty_GruntWeatherInst4), + .party = {.NoItemDefaultMoves = sParty_GruntWeatherInst4}, }, - [TRAINER_GRUNT_21] = + [TRAINER_GRUNT_AQUA_HIDEOUT_5] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -387,11 +387,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt21), - .party = {.NoItemDefaultMoves = sParty_Grunt21}, + .partySize = ARRAY_COUNT(sParty_GruntAquaHideout5), + .party = {.NoItemDefaultMoves = sParty_GruntAquaHideout5}, }, - [TRAINER_GRUNT_22] = + [TRAINER_GRUNT_AQUA_HIDEOUT_6] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -401,8 +401,8 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt22), - .party = {.NoItemDefaultMoves = sParty_Grunt22}, + .partySize = ARRAY_COUNT(sParty_GruntAquaHideout6), + .party = {.NoItemDefaultMoves = sParty_GruntAquaHideout6}, }, [TRAINER_FREDRICK] = @@ -1623,7 +1623,7 @@ const struct Trainer gTrainers[] = { .party = {.ItemCustomMoves = sParty_Daphne}, }, - [TRAINER_GRUNT_23] = + [TRAINER_GRUNT_SPACE_CENTER_2] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -1633,8 +1633,8 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt23), - .party = {.NoItemDefaultMoves = sParty_Grunt23}, + .partySize = ARRAY_COUNT(sParty_GruntSpaceCenter2), + .party = {.NoItemDefaultMoves = sParty_GruntSpaceCenter2}, }, [TRAINER_CINDY_2] = @@ -2043,7 +2043,7 @@ const struct Trainer gTrainers[] = { .party = {.NoItemDefaultMoves = sParty_Mark}, }, - [TRAINER_GRUNT_24] = + [TRAINER_GRUNT_MT_CHIMNEY_1] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -2053,8 +2053,8 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt24), - .party = {.NoItemDefaultMoves = sParty_Grunt24}, + .partySize = ARRAY_COUNT(sParty_GruntMtChimney1), + .party = {.NoItemDefaultMoves = sParty_GruntMtChimney1}, }, [TRAINER_STEVE_2] = @@ -2687,7 +2687,7 @@ const struct Trainer gTrainers[] = { .party = {.NoItemCustomMoves = sParty_Kirk}, }, - [TRAINER_GRUNT_25] = + [TRAINER_GRUNT_AQUA_HIDEOUT_7] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -2697,11 +2697,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt25), - .party = {.NoItemDefaultMoves = sParty_Grunt25}, + .partySize = ARRAY_COUNT(sParty_GruntAquaHideout7), + .party = {.NoItemDefaultMoves = sParty_GruntAquaHideout7}, }, - [TRAINER_GRUNT_26] = + [TRAINER_GRUNT_AQUA_HIDEOUT_8] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -2711,8 +2711,8 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt26), - .party = {.NoItemDefaultMoves = sParty_Grunt26}, + .partySize = ARRAY_COUNT(sParty_GruntAquaHideout8), + .party = {.NoItemDefaultMoves = sParty_GruntAquaHideout8}, }, [TRAINER_SHAWN] = @@ -7937,7 +7937,7 @@ const struct Trainer gTrainers[] = { .party = {.NoItemDefaultMoves = sParty_Julio}, }, - [TRAINER_GRUNT_27] = + [TRAINER_GRUNT_SEAFLOOR_CAVERN_5] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -7947,11 +7947,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt27), - .party = {.NoItemDefaultMoves = sParty_Grunt27}, + .partySize = ARRAY_COUNT(sParty_GruntSeafloorCavern5), + .party = {.NoItemDefaultMoves = sParty_GruntSeafloorCavern5}, }, - [TRAINER_GRUNT_28] = + [TRAINER_GRUNT_UNUSED] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -7961,11 +7961,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt28), - .party = {.NoItemDefaultMoves = sParty_Grunt28}, + .partySize = ARRAY_COUNT(sParty_GruntUnused), + .party = {.NoItemDefaultMoves = sParty_GruntUnused}, }, - [TRAINER_GRUNT_29] = + [TRAINER_GRUNT_MT_PYRE_4] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -7975,11 +7975,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt29), - .party = {.NoItemDefaultMoves = sParty_Grunt29}, + .partySize = ARRAY_COUNT(sParty_GruntMtPyre4), + .party = {.NoItemDefaultMoves = sParty_GruntMtPyre4}, }, - [TRAINER_GRUNT_30] = + [TRAINER_GRUNT_JAGGED_PASS] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -7989,8 +7989,8 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt30), - .party = {.NoItemDefaultMoves = sParty_Grunt30}, + .partySize = ARRAY_COUNT(sParty_GruntJaggedPass), + .party = {.NoItemDefaultMoves = sParty_GruntJaggedPass}, }, [TRAINER_MARC] = @@ -8105,7 +8105,7 @@ const struct Trainer gTrainers[] = { .party = {.NoItemDefaultMoves = sParty_Harrison}, }, - [TRAINER_GRUNT_31] = + [TRAINER_GRUNT_MT_CHIMNEY_2] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -8115,8 +8115,8 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt31), - .party = {.NoItemDefaultMoves = sParty_Grunt31}, + .partySize = ARRAY_COUNT(sParty_GruntMtChimney2), + .party = {.NoItemDefaultMoves = sParty_GruntMtChimney2}, }, [TRAINER_CLARENCE] = @@ -8203,7 +8203,7 @@ const struct Trainer gTrainers[] = { .party = {.NoItemDefaultMoves = sParty_Nicholas}, }, - [TRAINER_GRUNT_32] = + [TRAINER_GRUNT_SPACE_CENTER_3] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -8213,11 +8213,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt32), - .party = {.NoItemDefaultMoves = sParty_Grunt32}, + .partySize = ARRAY_COUNT(sParty_GruntSpaceCenter3), + .party = {.NoItemDefaultMoves = sParty_GruntSpaceCenter3}, }, - [TRAINER_GRUNT_33] = + [TRAINER_GRUNT_SPACE_CENTER_4] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -8227,11 +8227,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt33), - .party = {.NoItemDefaultMoves = sParty_Grunt33}, + .partySize = ARRAY_COUNT(sParty_GruntSpaceCenter4), + .party = {.NoItemDefaultMoves = sParty_GruntSpaceCenter4}, }, - [TRAINER_GRUNT_34] = + [TRAINER_GRUNT_SPACE_CENTER_5] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -8241,11 +8241,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt34), - .party = {.NoItemDefaultMoves = sParty_Grunt34}, + .partySize = ARRAY_COUNT(sParty_GruntSpaceCenter5), + .party = {.NoItemDefaultMoves = sParty_GruntSpaceCenter5}, }, - [TRAINER_GRUNT_35] = + [TRAINER_GRUNT_SPACE_CENTER_6] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -8255,11 +8255,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt35), - .party = {.NoItemDefaultMoves = sParty_Grunt35}, + .partySize = ARRAY_COUNT(sParty_GruntSpaceCenter6), + .party = {.NoItemDefaultMoves = sParty_GruntSpaceCenter6}, }, - [TRAINER_GRUNT_36] = + [TRAINER_GRUNT_SPACE_CENTER_7] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -8269,8 +8269,8 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt36), - .party = {.NoItemDefaultMoves = sParty_Grunt36}, + .partySize = ARRAY_COUNT(sParty_GruntSpaceCenter7), + .party = {.NoItemDefaultMoves = sParty_GruntSpaceCenter7}, }, [TRAINER_MACEY] = @@ -8343,7 +8343,7 @@ const struct Trainer gTrainers[] = { .party = {.NoItemDefaultMoves = sParty_Isabella}, }, - [TRAINER_GRUNT_37] = + [TRAINER_GRUNT_WEATHER_INST_5] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_AQUA, @@ -8353,8 +8353,8 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt37), - .party = {.NoItemDefaultMoves = sParty_Grunt37}, + .partySize = ARRAY_COUNT(sParty_GruntWeatherInst5), + .party = {.NoItemDefaultMoves = sParty_GruntWeatherInst5}, }, [TRAINER_TABITHA_2] = @@ -10023,7 +10023,7 @@ const struct Trainer gTrainers[] = { .party = {.NoItemDefaultMoves = sParty_Deandre}, }, - [TRAINER_GRUNT_38] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_1] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10033,11 +10033,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt38), - .party = {.NoItemDefaultMoves = sParty_Grunt38}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout1), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout1}, }, - [TRAINER_GRUNT_39] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_2] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10047,11 +10047,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt39), - .party = {.NoItemDefaultMoves = sParty_Grunt39}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout2), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout2}, }, - [TRAINER_GRUNT_40] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_3] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10061,11 +10061,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt40), - .party = {.NoItemDefaultMoves = sParty_Grunt40}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout3), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout3}, }, - [TRAINER_GRUNT_41] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_4] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10075,11 +10075,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt41), - .party = {.NoItemDefaultMoves = sParty_Grunt41}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout4), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout4}, }, - [TRAINER_GRUNT_42] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_5] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10089,11 +10089,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt42), - .party = {.NoItemDefaultMoves = sParty_Grunt42}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout5), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout5}, }, - [TRAINER_GRUNT_43] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_6] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10103,11 +10103,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt43), - .party = {.NoItemDefaultMoves = sParty_Grunt43}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout6), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout6}, }, - [TRAINER_GRUNT_44] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_7] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10117,11 +10117,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt44), - .party = {.NoItemDefaultMoves = sParty_Grunt44}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout7), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout7}, }, - [TRAINER_GRUNT_45] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_8] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10131,11 +10131,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt45), - .party = {.NoItemDefaultMoves = sParty_Grunt45}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout8), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout8}, }, - [TRAINER_GRUNT_46] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_9] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10145,11 +10145,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt46), - .party = {.NoItemDefaultMoves = sParty_Grunt46}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout9), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout9}, }, - [TRAINER_GRUNT_47] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_10] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10159,11 +10159,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt47), - .party = {.NoItemDefaultMoves = sParty_Grunt47}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout10), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout10}, }, - [TRAINER_GRUNT_48] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_11] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10173,11 +10173,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt48), - .party = {.NoItemDefaultMoves = sParty_Grunt48}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout11), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout11}, }, - [TRAINER_GRUNT_49] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_12] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10187,11 +10187,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt49), - .party = {.NoItemDefaultMoves = sParty_Grunt49}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout12), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout12}, }, - [TRAINER_GRUNT_50] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_13] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10201,11 +10201,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt50), - .party = {.NoItemDefaultMoves = sParty_Grunt50}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout13), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout13}, }, - [TRAINER_GRUNT_51] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_14] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10215,11 +10215,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt51), - .party = {.NoItemDefaultMoves = sParty_Grunt51}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout14), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout14}, }, - [TRAINER_GRUNT_52] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_15] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10229,11 +10229,11 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt52), - .party = {.NoItemDefaultMoves = sParty_Grunt52}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout15), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout15}, }, - [TRAINER_GRUNT_53] = + [TRAINER_GRUNT_MAGMA_HIDEOUT_16] = { .partyFlags = 0, .trainerClass = TRAINER_CLASS_TEAM_MAGMA, @@ -10243,8 +10243,8 @@ const struct Trainer gTrainers[] = { .items = {}, .doubleBattle = FALSE, .aiFlags = AI_SCRIPT_CHECK_BAD_MOVE, - .partySize = ARRAY_COUNT(sParty_Grunt53), - .party = {.NoItemDefaultMoves = sParty_Grunt53}, + .partySize = ARRAY_COUNT(sParty_GruntMagmaHideout16), + .party = {.NoItemDefaultMoves = sParty_GruntMagmaHideout16}, }, [TRAINER_TABITHA_3] = diff --git a/src/data/union_room.h b/src/data/union_room.h index abe91b010..de155aee8 100644 --- a/src/data/union_room.h +++ b/src/data/union_room.h @@ -440,7 +440,7 @@ ALIGNED(4) const u8 sText_CancelRegistrationOfMon[] = _("Cancel the registration ALIGNED(4) const u8 sText_CancelRegistrationOfEgg[] = _("Cancel the registration of your\nEGG?"); ALIGNED(4) const u8 sText_RegistrationCanceled2[] = _("The registration has been canceled.\p"); ALIGNED(4) const u8 sText_TradeTrainersWillBeListed[] = _("TRAINERS wishing to make a trade\nwill be listed."); // unused -ALIGNED(4) const u8 sText_ChooseTrainerToTradeWith[] = _("Please choose the TRAINER with whom\nyou would like to trade POKéMON."); // unused +ALIGNED(4) const u8 sText_ChooseTrainerToTradeWith2[] = _("Please choose the TRAINER with whom\nyou would like to trade POKéMON."); // unused ALIGNED(4) const u8 sText_AskTrainerToMakeTrade[] = _("Would you like to ask {STR_VAR_1} to\nmake a trade?"); ALIGNED(4) const u8 sText_AwaitingResponseFromTrainer[] = _("Awaiting a response from\nthe other TRAINER…"); // unused ALIGNED(4) const u8 sText_NotRegisteredAMonForTrade[] = _("You have not registered a POKéMON\nfor trading.\p"); // unused @@ -457,50 +457,51 @@ const u8 *const sUnionRoomTexts_CantTradeRightNow[] = { ALIGNED(4) const u8 sText_TradeOfferRejected[] = _("Your trade offer was rejected.\p"); ALIGNED(4) const u8 sText_EggTrade[] = _("EGG TRADE"); -ALIGNED(4) const u8 gUnknown_082EF7DC[] = _("{DPAD_UPDOWN}CHOOSE {A_BUTTON}JOIN {B_BUTTON}CANCEL"); -ALIGNED(4) const u8 gUnknown_082EF7F8[] = _("Please choose a TRAINER."); -ALIGNED(4) const u8 gUnknown_082EF814[] = _("Please choose a TRAINER for\na SINGLE BATTLE."); -ALIGNED(4) const u8 gUnknown_082EF844[] = _("Please choose a TRAINER for\na DOUBLE BATTLE."); -ALIGNED(4) const u8 gUnknown_082EF874[] = _("Please choose the LEADER\nfor a MULTI BATTLE."); -ALIGNED(4) const u8 gUnknown_082EF8A4[] = _("Please choose the TRAINER to\ntrade with."); -ALIGNED(4) const u8 gUnknown_082EF8D0[] = _("Please choose the TRAINER who is\nsharing WONDER CARDS."); -ALIGNED(4) const u8 gUnknown_082EF908[] = _("Please choose the TRAINER who is\nsharing WONDER NEWS."); -ALIGNED(4) const u8 gUnknown_082EF940[] = _("Jump with mini POKéMON!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EF974[] = _("BERRY CRUSH!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EF99C[] = _("DODRIO BERRY-PICKING!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EF9CC[] = _("BERRY BLENDER!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EF9F8[] = _("RECORD CORNER!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFA24[] = _("COOLNESS CONTEST!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFA50[] = _("BEAUTY CONTEST!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFA7C[] = _("CUTENESS CONTEST!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFAA8[] = _("SMARTNESS CONTEST!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFAD8[] = _("TOUGHNESS CONTEST!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFB08[] = _("BATTLE TOWER LEVEL 50!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFB3C[] = _("BATTLE TOWER OPEN LEVEL!\nPlease choose the LEADER."); - -const u8 *const gUnknown_082EFB70[] = { - gUnknown_082EF814, - gUnknown_082EF844, - gUnknown_082EF874, - gUnknown_082EF8A4, - gUnknown_082EF940, - gUnknown_082EF974, - gUnknown_082EF99C, - gUnknown_082EF8D0, - gUnknown_082EF908, - NULL, - NULL, - NULL, - gUnknown_082EF9F8, - gUnknown_082EF9CC, - NULL, - gUnknown_082EFA24, - gUnknown_082EFA50, - gUnknown_082EFA7C, - gUnknown_082EFAA8, - gUnknown_082EFAD8, - gUnknown_082EFB08, - gUnknown_082EFB3C +ALIGNED(4) const u8 sText_ChooseJoinCancel[] = _("{DPAD_UPDOWN}CHOOSE {A_BUTTON}JOIN {B_BUTTON}CANCEL"); +ALIGNED(4) const u8 sText_ChooseTrainer[] = _("Please choose a TRAINER."); +ALIGNED(4) const u8 sText_ChooseTrainerSingleBattle[] = _("Please choose a TRAINER for\na SINGLE BATTLE."); +ALIGNED(4) const u8 sText_ChooseTrainerDoubleBattle[] = _("Please choose a TRAINER for\na DOUBLE BATTLE."); +ALIGNED(4) const u8 sText_ChooseLeaderMultiBattle[] = _("Please choose the LEADER\nfor a MULTI BATTLE."); +ALIGNED(4) const u8 sText_ChooseTrainerToTradeWith[] = _("Please choose the TRAINER to\ntrade with."); +ALIGNED(4) const u8 sText_ChooseTrainerToShareWonderCards[] = _("Please choose the TRAINER who is\nsharing WONDER CARDS."); +ALIGNED(4) const u8 sText_ChooseTrainerToShareWonderNews[] = _("Please choose the TRAINER who is\nsharing WONDER NEWS."); +ALIGNED(4) const u8 sText_ChooseLeaderPokemonJump[] = _("Jump with mini POKéMON!\nPlease choose the LEADER."); +ALIGNED(4) const u8 sText_ChooseLeaderBerryCrush[] = _("BERRY CRUSH!\nPlease choose the LEADER."); +ALIGNED(4) const u8 sText_ChooseLeaderBerryPicking[] = _("DODRIO BERRY-PICKING!\nPlease choose the LEADER."); +ALIGNED(4) const u8 sText_ChooseLeaderBerryBlender[] = _("BERRY BLENDER!\nPlease choose the LEADER."); +ALIGNED(4) const u8 sText_ChooseLeaderRecordCorner[] = _("RECORD CORNER!\nPlease choose the LEADER."); +ALIGNED(4) const u8 sText_ChooseLeaderCoolContest[] = _("COOLNESS CONTEST!\nPlease choose the LEADER."); +ALIGNED(4) const u8 sText_ChooseLeaderBeautyContest[] = _("BEAUTY CONTEST!\nPlease choose the LEADER."); +ALIGNED(4) const u8 sText_ChooseLeaderCuteContest[] = _("CUTENESS CONTEST!\nPlease choose the LEADER."); +ALIGNED(4) const u8 sText_ChooseLeaderSmartContest[] = _("SMARTNESS CONTEST!\nPlease choose the LEADER."); +ALIGNED(4) const u8 sText_ChooseLeaderToughContest[] = _("TOUGHNESS CONTEST!\nPlease choose the LEADER."); +ALIGNED(4) const u8 sText_ChooseLeaderBattleTowerLv50[] = _("BATTLE TOWER LEVEL 50!\nPlease choose the LEADER."); +ALIGNED(4) const u8 sText_ChooseLeaderBattleTowerOpenLv[] = _("BATTLE TOWER OPEN LEVEL!\nPlease choose the LEADER."); + +static const u8 *const sChooseTrainerTexts[NUM_LINK_GROUP_TYPES] = +{ + [LINK_GROUP_SINGLE_BATTLE] = sText_ChooseTrainerSingleBattle, + [LINK_GROUP_DOUBLE_BATTLE] = sText_ChooseTrainerDoubleBattle, + [LINK_GROUP_MULTI_BATTLE] = sText_ChooseLeaderMultiBattle, + [LINK_GROUP_TRADE] = sText_ChooseTrainerToTradeWith, + [LINK_GROUP_POKEMON_JUMP] = sText_ChooseLeaderPokemonJump, + [LINK_GROUP_BERRY_CRUSH] = sText_ChooseLeaderBerryCrush, + [LINK_GROUP_BERRY_PICKING] = sText_ChooseLeaderBerryPicking, + [LINK_GROUP_WONDER_CARD] = sText_ChooseTrainerToShareWonderCards, + [LINK_GROUP_WONDER_NEWS] = sText_ChooseTrainerToShareWonderNews, + [LINK_GROUP_UNK_9] = NULL, + [LINK_GROUP_UNK_10] = NULL, + [LINK_GROUP_UNK_11] = NULL, + [LINK_GROUP_RECORD_CORNER] = sText_ChooseLeaderRecordCorner, + [LINK_GROUP_BERRY_BLENDER] = sText_ChooseLeaderBerryBlender, + [LINK_GROUP_UNK_14] = NULL, + [LINK_GROUP_COOL_CONTEST] = sText_ChooseLeaderCoolContest, + [LINK_GROUP_BEAUTY_CONTEST] = sText_ChooseLeaderBeautyContest, + [LINK_GROUP_CUTE_CONTEST] = sText_ChooseLeaderCuteContest, + [LINK_GROUP_SMART_CONTEST] = sText_ChooseLeaderSmartContest, + [LINK_GROUP_TOUGH_CONTEST] = sText_ChooseLeaderToughContest, + [LINK_GROUP_BATTLE_TOWER] = sText_ChooseLeaderBattleTowerLv50, + [LINK_GROUP_BATTLE_TOWER_OPEN] = sText_ChooseLeaderBattleTowerOpenLv }; ALIGNED(4) const u8 gUnknown_082EFBC8[] = _("Searching for a WIRELESS\nCOMMUNICATION SYSTEM. Wait..."); @@ -524,39 +525,39 @@ ALIGNED(4) const u8 gUnknown_082EFD7C[] = _("EXIT"); ALIGNED(4) const u8 gUnknown_082EFD84[] = _("EXIT"); ALIGNED(4) const u8 gUnknown_082EFD8C[] = _("INFO"); ALIGNED(4) const u8 gUnknown_082EFD94[] = _("NAME{CLEAR_TO 0x3C}WANTED{CLEAR_TO 0x6E}OFFER{CLEAR_TO 0xC6}LV."); -ALIGNED(4) const u8 gUnknown_082EFDB0[] = _("SINGLE BATTLE"); -ALIGNED(4) const u8 gUnknown_082EFDC0[] = _("DOUBLE BATTLE"); -ALIGNED(4) const u8 gUnknown_082EFDD0[] = _("MULTI BATTLE"); -ALIGNED(4) const u8 gUnknown_082EFDE0[] = _("POKéMON TRADES"); -ALIGNED(4) const u8 gUnknown_082EFDF0[] = _("CHAT"); -ALIGNED(4) const u8 gUnknown_082EFDF8[] = _("CARDS"); -ALIGNED(4) const u8 gUnknown_082EFE00[] = _("WONDER CARDS"); -ALIGNED(4) const u8 gUnknown_082EFE10[] = _("WONDER NEWS"); -ALIGNED(4) const u8 gUnknown_082EFE1C[] = _("POKéMON JUMP"); -ALIGNED(4) const u8 gUnknown_082EFE2C[] = _("BERRY CRUSH"); -ALIGNED(4) const u8 gUnknown_082EFE38[] = _("BERRY-PICKING"); -ALIGNED(4) const u8 gUnknown_082EFE48[] = _("SEARCH"); -ALIGNED(4) const u8 gUnknown_082EFE50[] = _("BERRY BLENDER"); -ALIGNED(4) const u8 gUnknown_082EFE60[] = _("RECORD CORNER"); -ALIGNED(4) const u8 gUnknown_082EFE70[] = _("COOL CONTEST"); -ALIGNED(4) const u8 gUnknown_082EFE80[] = _("BEAUTY CONTEST"); -ALIGNED(4) const u8 gUnknown_082EFE90[] = _("CUTE CONTEST"); -ALIGNED(4) const u8 gUnknown_082EFEA0[] = _("SMART CONTEST"); -ALIGNED(4) const u8 gUnknown_082EFEB0[] = _("TOUGH CONTEST"); -ALIGNED(4) const u8 gUnknown_082EFEC0[] = _("BATTLE TOWER LV. 50"); -ALIGNED(4) const u8 gUnknown_082EFED4[] = _("BATTLE TOWER OPEN LEVEL"); -ALIGNED(4) const u8 gUnknown_082EFEEC[] = _("It's a NORMAL CARD."); -ALIGNED(4) const u8 gUnknown_082EFF00[] = _("It's a BRONZE CARD!"); -ALIGNED(4) const u8 gUnknown_082EFF14[] = _("It's a COPPER CARD!"); -ALIGNED(4) const u8 gUnknown_082EFF28[] = _("It's a SILVER CARD!"); -ALIGNED(4) const u8 gUnknown_082EFF3C[] = _("It's a GOLD CARD!"); - -const u8 *const gUnknown_082EFF50[] = { - gUnknown_082EFEEC, - gUnknown_082EFF00, - gUnknown_082EFF14, - gUnknown_082EFF28, - gUnknown_082EFF3C +ALIGNED(4) const u8 sText_SingleBattle[] = _("SINGLE BATTLE"); +ALIGNED(4) const u8 sText_DoubleBattle[] = _("DOUBLE BATTLE"); +ALIGNED(4) const u8 sText_MultiBattle[] = _("MULTI BATTLE"); +ALIGNED(4) const u8 sText_PokemonTrades[] = _("POKéMON TRADES"); +ALIGNED(4) const u8 sText_Chat[] = _("CHAT"); +ALIGNED(4) const u8 sText_Cards[] = _("CARDS"); +ALIGNED(4) const u8 sText_WonderCards[] = _("WONDER CARDS"); +ALIGNED(4) const u8 sText_WonderNews[] = _("WONDER NEWS"); +ALIGNED(4) const u8 sText_PokemonJump[] = _("POKéMON JUMP"); +ALIGNED(4) const u8 sText_BerryCrush[] = _("BERRY CRUSH"); +ALIGNED(4) const u8 sText_BerryPicking[] = _("BERRY-PICKING"); +ALIGNED(4) const u8 sText_Search[] = _("SEARCH"); +ALIGNED(4) const u8 sText_BerryBlender[] = _("BERRY BLENDER"); +ALIGNED(4) const u8 sText_RecordCorner[] = _("RECORD CORNER"); +ALIGNED(4) const u8 sText_CoolContest[] = _("COOL CONTEST"); +ALIGNED(4) const u8 sText_BeautyContest[] = _("BEAUTY CONTEST"); +ALIGNED(4) const u8 sText_CuteContest[] = _("CUTE CONTEST"); +ALIGNED(4) const u8 sText_SmartContest[] = _("SMART CONTEST"); +ALIGNED(4) const u8 sText_ToughContest[] = _("TOUGH CONTEST"); +ALIGNED(4) const u8 sText_BattleTowerLv50[] = _("BATTLE TOWER LV. 50"); +ALIGNED(4) const u8 sText_BattleTowerOpenLv[] = _("BATTLE TOWER OPEN LEVEL"); +ALIGNED(4) const u8 sText_ItsNormalCard[] = _("It's a NORMAL CARD."); +ALIGNED(4) const u8 sText_ItsBronzeCard[] = _("It's a BRONZE CARD!"); +ALIGNED(4) const u8 sText_ItsCopperCard[] = _("It's a COPPER CARD!"); +ALIGNED(4) const u8 sText_ItsSilverCard[] = _("It's a SILVER CARD!"); +ALIGNED(4) const u8 sText_ItsGoldCard[] = _("It's a GOLD CARD!"); + +static const u8 *const sCardColorTexts[] = { + sText_ItsNormalCard, + sText_ItsBronzeCard, + sText_ItsCopperCard, + sText_ItsSilverCard, + sText_ItsGoldCard }; ALIGNED(4) const u8 gUnknown_082EFF64[] = _("This is {SPECIAL_F7 0x00} {SPECIAL_F7 0x01}'s\nTRAINER CARD…\l{SPECIAL_F7 0x02}\pPOKéDEX: {SPECIAL_F7 0x03}\nTIME: {SPECIAL_F7 0x04}:{SPECIAL_F7 0x05}\p"); @@ -573,34 +574,34 @@ ALIGNED(4) const u8 gUnknown_082F0020[] = _("Finished checking {SPECIAL_F7 0x01} const u8 *const gUnknown_082F0048[] = { gText_EmptyString, - gUnknown_082EFDB0, - gUnknown_082EFDC0, - gUnknown_082EFDD0, - gUnknown_082EFDE0, - gUnknown_082EFDF0, - gUnknown_082EFE00, - gUnknown_082EFE10, - gUnknown_082EFDF8, - gUnknown_082EFE1C, - gUnknown_082EFE2C, - gUnknown_082EFE38, - gUnknown_082EFE48, + sText_SingleBattle, + sText_DoubleBattle, + sText_MultiBattle, + sText_PokemonTrades, + sText_Chat, + sText_WonderCards, + sText_WonderNews, + sText_Cards, + sText_PokemonJump, + sText_BerryCrush, + sText_BerryPicking, + sText_Search, gText_EmptyString, - gUnknown_082EFED4, - gUnknown_082EFE60, - gUnknown_082EFE50, + sText_BattleTowerOpenLv, + sText_RecordCorner, + sText_BerryBlender, gText_EmptyString, gText_EmptyString, gText_EmptyString, gText_EmptyString, - gUnknown_082EFE00, - gUnknown_082EFE10, - gUnknown_082EFE70, - gUnknown_082EFE80, - gUnknown_082EFE90, - gUnknown_082EFEA0, - gUnknown_082EFEB0, - gUnknown_082EFEC0 + sText_WonderCards, + sText_WonderNews, + sText_CoolContest, + sText_BeautyContest, + sText_CuteContest, + sText_SmartContest, + sText_ToughContest, + sText_BattleTowerLv50 }; const struct WindowTemplate gUnknown_082F00BC = { @@ -613,7 +614,7 @@ const struct WindowTemplate gUnknown_082F00BC = { .baseBlock = 0x0008 }; -const u32 gUnknown_082F00C4[] = { +const u32 gUnknown_082F00C4[NUM_LINK_GROUP_TYPES] = { 0x0201, 0x0202, 0x0403, @@ -1012,7 +1013,7 @@ ALIGNED(4) const u8 gUnknown_082F04CC[] = {0x1b, 0xff}; ALIGNED(4) const u8 gUnknown_082F04D0[] = {0x1c, 0xff}; ALIGNED(4) const u8 gUnknown_082F04D4[] = {0x0e, 0xff}; -const u8 *const gUnknown_082F04D8[] = { +const u8 *const gUnknown_082F04D8[NUM_LINK_GROUP_TYPES] = { gUnknown_082F0474, gUnknown_082F0478, gUnknown_082F047C, @@ -1037,8 +1038,29 @@ const u8 *const gUnknown_082F04D8[] = { gUnknown_082F04D4 }; -const u8 gUnknown_082F0530[] = { - 0x01, 0x02, 0x03, 0x04, 0x09, 0x0a, 0x0b, 0x15, - 0x16, 0x00, 0x00, 0x00, 0x0f, 0x10, 0x00, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x0e, 0x00, 0x00 +// Link group type to ID for gUnknown_02022C2C +const u8 gUnknown_082F0530[NUM_LINK_GROUP_TYPES + 2] = +{ + 0x01, + 0x02, + 0x03, + 0x04, + 0x09, + 0x0a, + 0x0b, + 0x15, + 0x16, + 0x00, + 0x00, + 0x00, + 0x0f, + 0x10, + 0x00, + 0x17, + 0x18, + 0x19, + 0x1a, + 0x1b, + 0x1c, + 0x0e }; diff --git a/src/daycare.c b/src/daycare.c index e5445ee21..42c69465b 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -231,11 +231,8 @@ static void ApplyDaycareExperience(struct Pokemon *mon) while ((learnedMove = MonTryLearningNewMove(mon, firstMove)) != 0) { firstMove = FALSE; - if (learnedMove == 0xFFFF) - { - // Mon already knows 4 moves. + if (learnedMove == MON_HAS_MAX_MOVES) DeleteFirstMoveAndGiveMoveToMon(mon, gMoveToLearn); - } } } else @@ -666,7 +663,7 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru { if (sHatchedEggFatherMoves[i] == sHatchedEggEggMoves[j]) { - if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == 0xFFFF) + if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == MON_HAS_MAX_MOVES) DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFatherMoves[i]); break; } @@ -685,7 +682,7 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru { if (sHatchedEggFatherMoves[i] == ItemIdToBattleMoveId(ITEM_TM01_FOCUS_PUNCH + j) && CanMonLearnTMHM(egg, j)) { - if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == 0xFFFF) + if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == MON_HAS_MAX_MOVES) DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFatherMoves[i]); } } @@ -710,7 +707,7 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru { if (sHatchedEggLevelUpMoves[j] != MOVE_NONE && sHatchedEggFinalMoves[i] == sHatchedEggLevelUpMoves[j]) { - if (GiveMoveToMon(egg, sHatchedEggFinalMoves[i]) == 0xFFFF) + if (GiveMoveToMon(egg, sHatchedEggFinalMoves[i]) == MON_HAS_MAX_MOVES) DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFinalMoves[i]); break; } @@ -755,7 +752,7 @@ static void GiveVoltTackleIfLightBall(struct Pokemon *mon, struct DayCare *dayca if (motherItem == ITEM_LIGHT_BALL || fatherItem == ITEM_LIGHT_BALL) { - if (GiveMoveToMon(mon, MOVE_VOLT_TACKLE) == 0xFFFF) + if (GiveMoveToMon(mon, MOVE_VOLT_TACKLE) == MON_HAS_MAX_MOVES) DeleteFirstMoveAndGiveMoveToMon(mon, MOVE_VOLT_TACKLE); } } @@ -1295,6 +1292,6 @@ void ShowDaycareLevelMenu(void) void ChooseSendDaycareMon(void) { - sub_81B9328(); + ChooseMonForDaycare(); gMain.savedCallback = CB2_ReturnToField; } diff --git a/src/easy_chat.c b/src/easy_chat.c index 827b47085..32478ff1a 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -31,6 +31,7 @@ #include "constants/event_objects.h" #include "constants/flags.h" #include "constants/lilycove_lady.h" +#include "constants/mauville_old_man.h" #include "constants/songs.h" #include "constants/species.h" #include "constants/rgb.h" @@ -220,7 +221,7 @@ static void sub_811E0EC(s8, s8); static void sub_811E1A4(s8, s8); static void sub_811E2DC(struct Sprite *); static void sub_811E34C(u8, u8); -static bool8 sub_811F0F8(void); +static bool8 EasyChatIsNationalPokedexEnabled(void); static u16 sub_811F108(void); static void sub_811F2D4(void); static void sub_811F46C(void); @@ -531,11 +532,11 @@ static const u16 sMysteryGiftPhrase[] = { }; static const u16 sBerryMasterWifePhrases[][2] = { - {EC_WORD_GREAT, EC_WORD_BATTLE}, - {EC_WORD_CHALLENGE, EC_WORD_CONTEST}, - {EC_WORD_OVERWHELMING, EC_POKEMON(LATIAS)}, - {EC_WORD_COOL, EC_POKEMON(LATIOS)}, - {EC_WORD_SUPER, EC_WORD_HUSTLE}, + [PHRASE_GREAT_BATTLE - 1] = {EC_WORD_GREAT, EC_WORD_BATTLE}, + [PHRASE_CHALLENGE_CONTEST - 1] = {EC_WORD_CHALLENGE, EC_WORD_CONTEST}, + [PHRASE_OVERWHELMING_LATIAS - 1] = {EC_WORD_OVERWHELMING, EC_POKEMON(LATIAS)}, + [PHRASE_COOL_LATIOS - 1] = {EC_WORD_COOL, EC_POKEMON(LATIOS)}, + [PHRASE_SUPER_HUSTLE - 1] = {EC_WORD_SUPER, EC_WORD_HUSTLE}, }; static const u16 sEasyChatTriangleCursorPalette[] = INCBIN_U16("graphics/easy_chat/triangle_cursor.gbapal"); @@ -1263,7 +1264,7 @@ void ShowEasyChatScreen(void) break; case EASY_CHAT_TYPE_BARD_SONG: bard = &gSaveBlock1Ptr->oldMan.bard; - for (i = 0; i < 6; i ++) + for (i = 0; i < BARD_SONG_LENGTH; i ++) bard->temporaryLyrics[i] = bard->songLyrics[i]; words = bard->temporaryLyrics; @@ -1319,7 +1320,7 @@ void ShowEasyChatScreen(void) words = &gSaveBlock1Ptr->lilycoveLady.quiz.correctAnswer; break; case EASY_CHAT_TYPE_APPRENTICE: - words = gSaveBlock2Ptr->apprentices[0].easyChatWords; + words = gSaveBlock2Ptr->apprentices[0].speechWon; break; case EASY_CHAT_TYPE_QUESTIONNAIRE: words = sub_801B058(); @@ -4809,7 +4810,7 @@ static void sub_811E948(void) PutWindowTilemap(windowId); } -static bool8 sub_811EA28(u8 groupId) +static bool8 IsEasyChatGroupUnlocked(u8 groupId) { switch (groupId) { @@ -4820,7 +4821,7 @@ static bool8 sub_811EA28(u8 groupId) case EC_GROUP_MOVE_2: return FlagGet(FLAG_SYS_GAME_CLEAR); case EC_GROUP_POKEMON_2: - return sub_811F0F8(); + return EasyChatIsNationalPokedexEnabled(); default: return TRUE; } @@ -4831,7 +4832,7 @@ u16 EasyChat_GetNumWordsInGroup(u8 groupId) if (groupId == EC_GROUP_POKEMON) return GetNationalPokedexCount(FLAG_GET_SEEN); - if (sub_811EA28(groupId)) + if (IsEasyChatGroupUnlocked(groupId)) return gEasyChatGroups[groupId].numEnabledWords; return 0; @@ -5071,7 +5072,7 @@ u16 sub_811EE38(u16 groupId) u16 sub_811EE90(u16 groupId) { - if (!sub_811EA28(groupId)) + if (!IsEasyChatGroupUnlocked(groupId)) return 0xFFFF; if (groupId == EC_GROUP_POKEMON) @@ -5129,16 +5130,16 @@ void sub_811EF6C(void) CopyEasyChatWord(gStringVar2, easyChatWord); } -static bool8 sub_811EF98(u8 additionalPhraseId) +static bool8 IsAdditionalPhraseUnlocked(u8 additionalPhraseId) { int byteOffset = additionalPhraseId / 8; int shift = additionalPhraseId % 8; return (gSaveBlock1Ptr->additionalPhrases[byteOffset] >> shift) & 1; } -void sub_811EFC0(u8 additionalPhraseId) +void UnlockAdditionalPhrase(u8 additionalPhraseId) { - if (additionalPhraseId < 33) + if (additionalPhraseId < NUM_ADDITIONAL_PHRASES) { int byteOffset = additionalPhraseId / 8; int shift = additionalPhraseId % 8; @@ -5146,32 +5147,32 @@ void sub_811EFC0(u8 additionalPhraseId) } } -u8 sub_811EFF0(void) +static u8 GetNumAdditionalPhrasesUnlocked(void) { u8 i; u8 numAdditionalPhrasesUnlocked; - for (i = 0, numAdditionalPhrasesUnlocked = 0; i < 33; i++) + for (i = 0, numAdditionalPhrasesUnlocked = 0; i < NUM_ADDITIONAL_PHRASES; i++) { - if (sub_811EF98(i)) + if (IsAdditionalPhraseUnlocked(i)) numAdditionalPhrasesUnlocked++; } return numAdditionalPhrasesUnlocked; } -u16 sub_811F01C(void) +u16 GetNewHipsterPhraseToTeach(void) { u16 i; u16 additionalPhraseId; - u8 numAdditionalPhrasesUnlocked = sub_811EFF0(); - if (numAdditionalPhrasesUnlocked == 33) + u8 numAdditionalPhrasesUnlocked = GetNumAdditionalPhrasesUnlocked(); + if (numAdditionalPhrasesUnlocked == NUM_ADDITIONAL_PHRASES) return 0xFFFF; - additionalPhraseId = Random() % (33 - numAdditionalPhrasesUnlocked); - for (i = 0; i < 33; i++) + additionalPhraseId = Random() % (NUM_ADDITIONAL_PHRASES - numAdditionalPhrasesUnlocked); + for (i = 0; i < NUM_ADDITIONAL_PHRASES; i++) { - if (!sub_811EF98(i)) + if (!IsAdditionalPhraseUnlocked(i)) { if (additionalPhraseId) { @@ -5179,7 +5180,7 @@ u16 sub_811F01C(void) } else { - sub_811EFC0(i); + UnlockAdditionalPhrase(i); return EC_WORD(EC_GROUP_TRENDY_SAYING, i); } } @@ -5188,17 +5189,18 @@ u16 sub_811F01C(void) return 0xFFFF; } -u16 sub_811F090(void) +// Unused +u16 GetRandomTaughtHipsterPhrase(void) { u16 i; - u16 additionalPhraseId = sub_811EFF0(); + u16 additionalPhraseId = GetNumAdditionalPhrasesUnlocked(); if (additionalPhraseId == 0) return 0xFFFF; additionalPhraseId = Random() % additionalPhraseId; - for (i = 0; i < 33; i++) + for (i = 0; i < NUM_ADDITIONAL_PHRASES; i++) { - if (sub_811EF98(i)) + if (IsAdditionalPhraseUnlocked(i)) { if (additionalPhraseId) additionalPhraseId--; @@ -5210,7 +5212,7 @@ u16 sub_811F090(void) return 0xFFFF; } -static bool8 sub_811F0F8(void) +static bool8 EasyChatIsNationalPokedexEnabled(void) { return IsNationalPokedexEnabled(); } @@ -5497,7 +5499,7 @@ static bool8 sub_811F764(u16 wordIndex, u8 groupId) case EC_GROUP_MOVE_2: return TRUE; case EC_GROUP_TRENDY_SAYING: - return sub_811EF98(wordIndex); + return IsAdditionalPhraseUnlocked(wordIndex); default: return gEasyChatGroups[groupId].wordData.words[wordIndex].enabled; } @@ -5545,7 +5547,7 @@ bool32 sub_811F8D8(int easyChatWord) int groupId = EC_GROUP(easyChatWord); int mask = 0x7F; int index = EC_INDEX(easyChatWord); - if (!sub_811EA28(groupId & mask)) + if (!IsEasyChatGroupUnlocked(groupId & mask)) return FALSE; else return sub_811F764(index, groupId & mask); diff --git a/src/ereader_helpers.c b/src/ereader_helpers.c index 7f0887790..2419c2806 100755 --- a/src/ereader_helpers.c +++ b/src/ereader_helpers.c @@ -448,7 +448,7 @@ static bool32 TryWriteTrainerHill_r(struct EReaderTrainerHillSet *ttdata, struct AGB_ASSERT_EX(ttdata->id == 0, "cereader_tool.c", 452); memset(buffer2, 0, 0x1000); - buffer2->unkField_0 = ttdata->count; + buffer2->numTrainers = ttdata->count; buffer2->unused1 = sub_81D38D4(); buffer2->numFloors = (ttdata->count + 1) / 2; @@ -456,13 +456,13 @@ static bool32 TryWriteTrainerHill_r(struct EReaderTrainerHillSet *ttdata, struct { if (!(i & 1)) { - buffer2->floors[i / 2].unk0 = ttdata->unk_8[i].unk0; + buffer2->floors[i / 2].trainerNum1 = ttdata->unk_8[i].unk0; buffer2->floors[i / 2].display = ttdata->unk_8[i].unk14C; buffer2->floors[i / 2].trainers[0] = ttdata->unk_8[i].unk4; } else { - buffer2->floors[i / 2].unk1 = ttdata->unk_8[i].unk0; + buffer2->floors[i / 2].trainerNum2 = ttdata->unk_8[i].unk0; buffer2->floors[i / 2].trainers[1] = ttdata->unk_8[i].unk4; } } diff --git a/src/event_object_movement.c b/src/event_object_movement.c index b3daaad67..c746f08b1 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -26,6 +26,7 @@ #include "constants/event_objects.h" #include "constants/field_effects.h" #include "constants/items.h" +#include "constants/mauville_old_man.h" // this file was known as evobjmv.c in Game Freak's original source diff --git a/src/evolution_scene.c b/src/evolution_scene.c index af560bc40..019d48416 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -235,7 +235,7 @@ void EvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, bool8 canStopEvo, gBattleTerrain = BATTLE_TERRAIN_PLAIN; - sub_80356D0(); + InitBattleBgsVideo(); LoadBattleTextboxAndBackground(); ResetSpriteData(); ScanlineEffect_Stop(); @@ -341,7 +341,7 @@ static void CB2_EvolutionSceneLoadGraphics(void) gBattleTerrain = BATTLE_TERRAIN_PLAIN; - sub_80356D0(); + InitBattleBgsVideo(); LoadBattleTextboxAndBackground(); ResetSpriteData(); FreeAllSpritePalettes(); @@ -743,12 +743,12 @@ static void Task_EvolutionScene(u8 taskID) GetMonData(mon, MON_DATA_NICKNAME, text); StringCopy10(gBattleTextBuff1, text); - if (var == 0xFFFF) // no place to learn it + if (var == MON_HAS_MAX_MOVES) gTasks[taskID].tState = 22; - else if (var == 0xFFFE) // it already knows that move + else if (var == MON_ALREADY_KNOWS_MOVE) break; else - gTasks[taskID].tState = 20; // has less than 4 moves, so it's been learned + gTasks[taskID].tState = 20; // move has been learned } else // no move to learn { @@ -909,8 +909,8 @@ static void Task_EvolutionScene(u8 taskID) case 6: if (!gPaletteFade.active && gMain.callback2 == CB2_EvolutionSceneUpdate) { - var = sub_81C1B94(); // moveID - if (var == 4) + var = GetMoveSlotToReplace(); + if (var == MAX_MON_MOVES) { gTasks[taskID].tLearnMoveState = 10; } @@ -1100,9 +1100,9 @@ static void Task_TradeEvolutionScene(u8 taskID) GetMonData(mon, MON_DATA_NICKNAME, text); StringCopy10(gBattleTextBuff1, text); - if (var == 0xFFFF) + if (var == MON_HAS_MAX_MOVES) gTasks[taskID].tState = 20; - else if (var == 0xFFFE) + else if (var == MON_ALREADY_KNOWS_MOVE) break; else gTasks[taskID].tState = 18; @@ -1243,8 +1243,8 @@ static void Task_TradeEvolutionScene(u8 taskID) case 6: if (!gPaletteFade.active && gMain.callback2 == CB2_TradeEvolutionSceneUpdate) { - var = sub_81C1B94(); // moveID - if (var == 4) + var = GetMoveSlotToReplace(); + if (var == MAX_MON_MOVES) { gTasks[taskID].tLearnMoveState = 9; } diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 47246d75a..8b4c7380c 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -30,9 +30,11 @@ #include "wild_encounter.h" #include "constants/bg_event_constants.h" #include "constants/event_objects.h" +#include "constants/field_poison.h" #include "constants/map_types.h" #include "constants/maps.h" #include "constants/songs.h" +#include "constants/trainer_hill.h" static EWRAM_DATA u8 sWildEncounterImmunitySteps = 0; static EWRAM_DATA u16 sPreviousPlayerMetatileBehavior = 0; @@ -223,8 +225,8 @@ static bool8 TryStartInteractionScript(struct MapPosition *position, u16 metatil return FALSE; // Don't play interaction sound for certain scripts. - if (script != EventScript_PlayerPCMale - && script != EventScript_PlayerPCFemale + if (script != LittlerootTown_BrendansHouse_2F_EventScript_PC + && script != LittlerootTown_MaysHouse_2F_EventScript_PC && script != SecretBase_EventScript_PC && script != SecretBase_EventScript_RecordMixingPC && script != SecretBase_EventScript_DollInteract @@ -373,14 +375,14 @@ static const u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 me return EventScript_PC; if (MetatileBehavior_IsClosedSootopolisDoor(metatileBehavior) == TRUE) return EventScript_ClosedSootopolisDoor; - if (MetatileBehavior_IsUnknownClosedDoor(metatileBehavior) == TRUE) - return SkyPillar_Outside_EventScript_2393F9; + if (MetatileBehavior_IsSkyPillarClosedDoor(metatileBehavior) == TRUE) + return SkyPillar_Outside_EventScript_ClosedDoor; if (MetatileBehavior_IsCableBoxResults1(metatileBehavior) == TRUE) return EventScript_CableBoxResults; if (MetatileBehavior_IsPokeblockFeeder(metatileBehavior) == TRUE) return EventScript_PokeBlockFeeder; if (MetatileBehavior_IsTrickHousePuzzleDoor(metatileBehavior) == TRUE) - return Route110_TrickHouseEntrance_EventScript_26A22A; + return Route110_TrickHousePuzzle_EventScript_Door; if (MetatileBehavior_IsRegionMap(metatileBehavior) == TRUE) return EventScript_RegionMap; if (MetatileBehavior_IsRunningShoesManual(metatileBehavior) == TRUE) @@ -563,22 +565,22 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior) } if (ShouldDoBrailleRegicePuzzle() == TRUE) { - ScriptContext1_SetupScript(IslandCave_EventScript_238EAF); + ScriptContext1_SetupScript(IslandCave_EventScript_OpenRegiEntrance); return TRUE; } if (ShouldDoWallyCall() == TRUE) { - ScriptContext1_SetupScript(MauvilleCity_EventScript_1DF7BA); + ScriptContext1_SetupScript(MauvilleCity_EventScript_RegisterWallyCall); return TRUE; } - if (ShouldDoWinonaCall() == TRUE) + if (ShouldDoScottFortreeCall() == TRUE) { - ScriptContext1_SetupScript(Route119_EventScript_1F49EC); + ScriptContext1_SetupScript(Route119_EventScript_ScottWonAtFortreeGymCall); return TRUE; } - if (ShouldDoScottCall() == TRUE) + if (ShouldDoScottBattleFrontierCall() == TRUE) { - ScriptContext1_SetupScript(LittlerootTown_ProfessorBirchsLab_EventScript_1FA4D6); + ScriptContext1_SetupScript(LittlerootTown_ProfessorBirchsLab_EventScript_ScottAboardSSTidalCall); return TRUE; } if (ShouldDoRoxanneCall() == TRUE) @@ -588,7 +590,7 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior) } if (ShouldDoRivalRayquazaCall() == TRUE) { - ScriptContext1_SetupScript(MossdeepCity_SpaceCenter_2F_EventScript_224175); + ScriptContext1_SetupScript(MossdeepCity_SpaceCenter_2F_EventScript_RivalRayquazaCall); return TRUE; } } @@ -597,7 +599,7 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior) return TRUE; if (CountSSTidalStep(1) == TRUE) { - ScriptContext1_SetupScript(SSTidalCorridor_EventScript_23C050); + ScriptContext1_SetupScript(SSTidalCorridor_EventScript_ReachedStepCount); return TRUE; } if (TryStartMatchCall()) @@ -646,11 +648,11 @@ static bool8 UpdatePoisonStepCounter(void) { switch (DoPoisonFieldEffect()) { - case 0: + case FLDPSN_NONE: return FALSE; - case 1: + case FLDPSN_PSN: return FALSE; - case 2: + case FLDPSN_FNT: return TRUE; } } @@ -792,20 +794,16 @@ static void SetupWarp(struct MapHeader *unused, s8 warpEventId, struct MapPositi if (trainerHillMapId) { - if (trainerHillMapId == sub_81D6490()) + if (trainerHillMapId == GetNumFloorsInTrainerHillChallenge()) { if (warpEventId == 0) - { warpEvent = &gMapHeader.events->warps[0]; - } else - { - warpEvent = sub_81D6120(); - } + warpEvent = SetWarpDestinationTrainerHill4F(); } - else if (trainerHillMapId == 5) + else if (trainerHillMapId == TRAINER_HILL_ROOF) { - warpEvent = sub_81D6134(warpEventId); + warpEvent = SetWarpDestinationTrainerHillFinalFloor(warpEventId); } else { diff --git a/src/field_effect.c b/src/field_effect.c index 7569bdc75..99abcdcb0 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -63,7 +63,7 @@ static void PokeballGlowEffect_7(struct Sprite *); static u8 PokecenterHealEffectHelper(s16, s16); static void HallOfFameRecordEffectHelper(s16, s16, s16, u8); -static void mapldr_080842E8(void); +static void FieldCallback_Fly(void); static void task00_8084310(u8); static void mapldr_08084390(void); static void c3_080843F8(u8); @@ -1364,13 +1364,13 @@ void SpriteCB_HallOfFameMonitor(struct Sprite *sprite) } -void sub_80B69DC(void) +void ReturnToFieldFromFlyMapSelect(void) { SetMainCallback2(CB2_ReturnToField); - gFieldCallback = mapldr_080842E8; + gFieldCallback = FieldCallback_Fly; } -static void mapldr_080842E8(void) +static void FieldCallback_Fly(void) { pal_fill_black(); CreateTask(task00_8084310, 0); diff --git a/src/field_poison.c b/src/field_poison.c index d10a28a76..8385966d4 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -15,6 +15,7 @@ #include "task.h" #include "trainer_hill.h" #include "constants/field_poison.h" +#include "constants/party_menu.h" #include "constants/species.h" static bool32 IsMonValidSpecies(struct Pokemon *pokemon) @@ -56,7 +57,7 @@ static void FaintFromFieldPoison(u8 partyIdx) static bool32 MonFaintedFromPoison(u8 partyIdx) { struct Pokemon *pokemon = gPlayerParty + partyIdx; - if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 0 && pokemon_ailments_get_primary(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) + if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 0 && GetAilmentFromStatus(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) { return TRUE; } @@ -124,7 +125,7 @@ s32 DoPoisonFieldEffect(void) u32 numFainted = 0; for (i = 0; i < PARTY_SIZE; i++) { - if (GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && pokemon_ailments_get_primary(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) + if (GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && GetAilmentFromStatus(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) { hp = GetMonData(pokemon, MON_DATA_HP); if (hp == 0 || --hp == 0) diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index 505315539..076859c28 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -34,7 +34,7 @@ #include "event_obj_lock.h" #include "fldeff.h" -extern const u16 gUnknown_82EC7CC[]; +extern const u16 gOrbEffectBackgroundLayerFlags[]; // This file's functions. static void sub_8080B9C(u8); @@ -752,7 +752,7 @@ static void task0A_fade_n_map_maybe(u8 taskId) } } -void sub_80AFC60(void) +void DoContestHallWarp(void) { ScriptContext2_Enable(); TryFadeOutOldMapMusic(); @@ -800,7 +800,7 @@ static void SetFlashScanlineEffectWindowBoundaries(u16 *dest, s32 centerX, s32 c } } -static void SetFlash2ScanlineEffectWindowBoundary(u16 *dest, u32 y, s32 left, s32 right) +static void SetOrbFlashScanlineEffectWindowBoundary(u16 *dest, u32 y, s32 left, s32 right) { if (y <= 160) { @@ -816,17 +816,17 @@ static void SetFlash2ScanlineEffectWindowBoundary(u16 *dest, u32 y, s32 left, s3 } } -static void SetFlash2ScanlineEffectWindowBoundaries(u16 *dest, s32 centerX, s32 centerY, s32 radius) +static void SetOrbFlashScanlineEffectWindowBoundaries(u16 *dest, s32 centerX, s32 centerY, s32 radius) { s32 r = radius; s32 v2 = radius; s32 v3 = 0; while (r >= v3) { - SetFlash2ScanlineEffectWindowBoundary(dest, centerY - v3, centerX - r, centerX + r); - SetFlash2ScanlineEffectWindowBoundary(dest, centerY + v3, centerX - r, centerX + r); - SetFlash2ScanlineEffectWindowBoundary(dest, centerY - r, centerX - v3, centerX + v3); - SetFlash2ScanlineEffectWindowBoundary(dest, centerY + r, centerX - v3, centerX + v3); + SetOrbFlashScanlineEffectWindowBoundary(dest, centerY - v3, centerX - r, centerX + r); + SetOrbFlashScanlineEffectWindowBoundary(dest, centerY + v3, centerX - r, centerX + r); + SetOrbFlashScanlineEffectWindowBoundary(dest, centerY - r, centerX - v3, centerX + v3); + SetOrbFlashScanlineEffectWindowBoundary(dest, centerY + r, centerX - v3, centerX + v3); v2 -= (v3 * 2) - 1; v3++; if (v2 < 0) @@ -878,18 +878,18 @@ static void UpdateFlashLevelEffect(u8 taskId) } } -static void UpdateFlash2LevelEffect(u8 taskId) +static void UpdateOrbFlashEffect(u8 taskId) { s16 *data = gTasks[taskId].data; switch (data[0]) { case 0: - SetFlash2ScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius); + SetOrbFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius); data[0] = 1; break; case 1: - SetFlash2ScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius); + SetOrbFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius); data[0] = 0; tCurFlashRadius += tFlashRadiusDelta; if (tCurFlashRadius > tDestFlashRadius) @@ -948,7 +948,7 @@ static u8 sub_80AFFDC(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 dest static u8 sub_80B003C(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 destFlashRadius, s32 clearScanlineEffect, u8 delta) { - u8 taskId = CreateTask(UpdateFlash2LevelEffect, 80); + u8 taskId = CreateTask(UpdateOrbFlashEffect, 80); s16 *data = gTasks[taskId].data; tCurFlashRadius = initialFlashRadius; @@ -1063,12 +1063,12 @@ void sub_80B0268(void) CreateTask(sub_80B01BC, 10); } -static void sub_80B028C(u8 a1) +static void LoadOrbEffectPalette(bool8 blueOrb) { int i; u16 color[1]; - if (!a1) + if (!blueOrb) color[0] = RGB_RED; else color[0] = RGB_BLUE; @@ -1079,12 +1079,12 @@ static void sub_80B028C(u8 a1) } } -static bool8 sub_80B02C8(u16 a1) +static bool8 sub_80B02C8(u16 shakeDir) { u8 lo = REG_BLDALPHA & 0xFF; u8 hi = REG_BLDALPHA >> 8; - if (a1) + if (shakeDir != 0) { if (lo) { @@ -1107,58 +1107,69 @@ static bool8 sub_80B02C8(u16 a1) return FALSE; } -static void sub_80B0318(u8 taskId) +#define tState data[0] +#define tBlueOrb data[1] +#define tCenterX data[2] +#define tCenterY data[3] +#define tShakeDelay data[4] +#define tShakeDir data[5] +#define tDispCnt data[6] +#define tBldCnt data[7] +#define tBldAlpha data[8] +#define tWinIn data[9] +#define tWinOut data[10] + +static void Task_OrbEffect(u8 taskId) { s16 *data = gTasks[taskId].data; - switch (data[0]) + switch (tState) { case 0: - data[6] = REG_DISPCNT; - data[7] = REG_BLDCNT; - data[8] = REG_BLDALPHA; - data[9] = REG_WININ; - data[10] = REG_WINOUT; + tDispCnt = REG_DISPCNT; + tBldCnt = REG_BLDCNT; + tBldAlpha = REG_BLDALPHA; + tWinIn = REG_WININ; + tWinOut = REG_WINOUT; ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN1_ON); - SetGpuRegBits(REG_OFFSET_BLDCNT, gUnknown_82EC7CC[0]); + SetGpuRegBits(REG_OFFSET_BLDCNT, gOrbEffectBackgroundLayerFlags[0]); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(12, 7)); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ); - sub_8199C30(0, 0, 0, 0x1E, 0x14, 0xF); + SetBgTilemapPalette(0, 0, 0, 0x1E, 0x14, 0xF); schedule_bg_copy_tilemap_to_vram(0); - SetFlash2ScanlineEffectWindowBoundaries(&gScanlineEffectRegBuffers[0][0], data[2], data[3], 1); + SetOrbFlashScanlineEffectWindowBoundaries(&gScanlineEffectRegBuffers[0][0], tCenterX, tCenterY, 1); CpuFastSet(&gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 480); ScanlineEffect_SetParams(sFlashEffectParams); - data[0] = 1; + tState = 1; break; case 1: sub_8199DF0(0, PIXEL_FILL(1), 0, 1); - sub_80B028C(data[1]); - sub_80B003C(data[2], data[3], 1, 160, 1, 2); - data[0] = 2; + LoadOrbEffectPalette(tBlueOrb); + sub_80B003C(tCenterX, tCenterY, 1, 160, 1, 2); + tState = 2; break; case 2: - if (!FuncIsActiveTask(UpdateFlash2LevelEffect)) + if (!FuncIsActiveTask(UpdateOrbFlashEffect)) { EnableBothScriptContexts(); - data[0] = 3; + tState = 3; } break; case 3: InstallCameraPanAheadCallback(); SetCameraPanningCallback(NULL); - data[5] = 0; - data[4] = 4; - data[0] = 4; + tShakeDir = 0; + tShakeDelay = 4; + tState = 4; break; case 4: - data[4]--; - if (!data[4]) + if (--tShakeDelay == 0) { s32 panning; - data[4] = 4; - data[5] ^= 1; - if (data[5]) + tShakeDelay = 4; + tShakeDir ^= 1; + if (tShakeDir) panning = 4; else panning = -4; @@ -1167,70 +1178,81 @@ static void sub_80B0318(u8 taskId) break; case 6: InstallCameraPanAheadCallback(); - data[4] = 8; - data[0] = 7; + tShakeDelay = 8; + tState = 7; break; case 7: - data[4]--; - if (!data[4]) + if (--tShakeDelay == 0) { - data[4] = 8; - data[5] ^= 1; - if (sub_80B02C8(data[5]) == TRUE) + tShakeDelay = 8; + tShakeDir ^= 1; + if (sub_80B02C8(tShakeDir) == TRUE) { - data[0] = 5; + tState = 5; sub_8199DF0(0, PIXEL_FILL(0), 0, 1); } } break; case 5: SetGpuReg(REG_OFFSET_WIN0H, 255); - SetGpuReg(REG_OFFSET_DISPCNT, data[6]); - SetGpuReg(REG_OFFSET_BLDCNT, data[7]); - SetGpuReg(REG_OFFSET_BLDALPHA, data[8]); - SetGpuReg(REG_OFFSET_WININ, data[9]); - SetGpuReg(REG_OFFSET_WINOUT, data[10]); + SetGpuReg(REG_OFFSET_DISPCNT, tDispCnt); + SetGpuReg(REG_OFFSET_BLDCNT, tBldCnt); + SetGpuReg(REG_OFFSET_BLDALPHA, tBldAlpha); + SetGpuReg(REG_OFFSET_WININ, tWinIn); + SetGpuReg(REG_OFFSET_WINOUT, tWinOut); EnableBothScriptContexts(); DestroyTask(taskId); break; } } -void sub_80B0534(void) +void DoOrbEffect(void) { - u8 taskId = CreateTask(sub_80B0318, 80); + u8 taskId = CreateTask(Task_OrbEffect, 80); s16 *data = gTasks[taskId].data; if (gSpecialVar_Result == 0) { - data[1] = 0; - data[2] = 104; + tBlueOrb = FALSE; + tCenterX = 104; } else if (gSpecialVar_Result == 1) { - data[1] = 1; - data[2] = 136; + tBlueOrb = TRUE; + tCenterX = 136; } else if (gSpecialVar_Result == 2) { - data[1] = 0; - data[2] = 120; + tBlueOrb = FALSE; + tCenterX = 120; } else { - data[1] = 1; - data[2] = 120; + tBlueOrb = TRUE; + tCenterX = 120; } - data[3] = 80; + tCenterY = 80; } -void sub_80B058C(void) +void FadeOutOrbEffect(void) { - u8 taskId = FindTaskIdByFunc(sub_80B0318); - gTasks[taskId].data[0] = 6; + u8 taskId = FindTaskIdByFunc(Task_OrbEffect); + gTasks[taskId].tState = 6; } +#undef tState +#undef tBlueOrb +#undef tCenterX +#undef tCenterY +#undef tShakeDelay +#undef tShakeDir +#undef tDispCnt +#undef tBldCnt +#undef tBldAlpha +#undef tWinIn +#undef tWinOut + void Script_FadeOutMapMusic(void) { Overworld_FadeOutMapMusic(); diff --git a/src/field_special_scene.c b/src/field_special_scene.c index 231f4dd42..439b1855a 100644 --- a/src/field_special_scene.c +++ b/src/field_special_scene.c @@ -14,6 +14,8 @@ #include "sprite.h" #include "task.h" #include "constants/event_objects.h" +#include "constants/event_object_movement_constants.h" +#include "constants/field_specials.h" #include "constants/songs.h" #include "constants/vars.h" #include "constants/metatile_labels.h" @@ -31,8 +33,18 @@ enum //. rodata static const s8 gTruckCamera_HorizontalTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, -1, -1, -1, 0}; -const u8 gUnknown_0858E8AB[] = {0x18, 0xFE}; -const u8 gUnknown_0858E8AD[] = {0x17, 0xFE}; + +static const u8 sSSTidalSailEastMovementScript[] = +{ + MOVEMENT_ACTION_WALK_FAST_RIGHT, + MOVEMENT_ACTION_STEP_END +}; + +static const u8 sSSTidalSailWestMovementScript[] = +{ + MOVEMENT_ACTION_WALK_FAST_LEFT, + MOVEMENT_ACTION_STEP_END +}; // .text static void Task_Truck3(u8); @@ -256,7 +268,7 @@ bool8 sub_80FB59C(void) void Task_HandlePorthole(u8 taskId) { s16 *data = gTasks[taskId].data; - u16 *var = GetVarPointer(VAR_PORTHOLE_STATE); + u16 *cruiseState = GetVarPointer(VAR_SS_TIDAL_STATE); struct WarpData *location = &gSaveBlock1Ptr->location; switch (data[0]) @@ -268,40 +280,41 @@ void Task_HandlePorthole(u8 taskId) data[0] = EXECUTE_MOVEMENT; // execute movement before checking if should be exited. strange? } break; - case IDLE_CHECK: // idle and move. + case IDLE_CHECK: if (gMain.newKeys & A_BUTTON) data[1] = 1; - if (!ScriptMovement_IsObjectMovementFinished(0xFF, location->mapNum, location->mapGroup)) + if (!ScriptMovement_IsObjectMovementFinished(EVENT_OBJ_ID_PLAYER, location->mapNum, location->mapGroup)) return; if (CountSSTidalStep(1) == TRUE) { - if (*var == 2) - *var = 9; + if (*cruiseState == SS_TIDAL_DEPART_SLATEPORT) + *cruiseState = SS_TIDAL_EXIT_CURRENTS_RIGHT; else - *var = 10; - data[0] = 3; + *cruiseState = SS_TIDAL_EXIT_CURRENTS_LEFT; + data[0] = EXIT_PORTHOLE; return; } - data[0] = 2; - case EXECUTE_MOVEMENT: // execute movement. + data[0] = EXECUTE_MOVEMENT; + //fallthrough + case EXECUTE_MOVEMENT: if (data[1]) { - data[0] = EXIT_PORTHOLE; // exit porthole. + data[0] = EXIT_PORTHOLE; return; } - // run this once. - if (*var == 2) // which direction? + + if (*cruiseState == SS_TIDAL_DEPART_SLATEPORT) { - ScriptMovement_StartObjectMovementScript(0xFF, location->mapNum, location->mapGroup, gUnknown_0858E8AB); - data[0] = IDLE_CHECK; // run case 1. + ScriptMovement_StartObjectMovementScript(EVENT_OBJ_ID_PLAYER, location->mapNum, location->mapGroup, sSSTidalSailEastMovementScript); + data[0] = IDLE_CHECK; } else { - ScriptMovement_StartObjectMovementScript(0xFF, location->mapNum, location->mapGroup, gUnknown_0858E8AD); - data[0] = IDLE_CHECK; // run case 1. + ScriptMovement_StartObjectMovementScript(EVENT_OBJ_ID_PLAYER, location->mapNum, location->mapGroup, sSSTidalSailWestMovementScript); + data[0] = IDLE_CHECK; } break; - case EXIT_PORTHOLE: // exit porthole. + case EXIT_PORTHOLE: FlagClear(FLAG_DONT_TRANSITION_MUSIC); FlagClear(FLAG_HIDE_MAP_NAME_POPUP); SetWarpDestinationToDynamicWarp(0); @@ -311,32 +324,28 @@ void Task_HandlePorthole(u8 taskId) } } -void sub_80FB6EC(void) +static void ShowSSTidalWhileSailing(void) { u8 spriteId = AddPseudoEventObject(EVENT_OBJ_GFX_SS_TIDAL, SpriteCallbackDummy, 112, 80, 0); gSprites[spriteId].coordOffsetEnabled = FALSE; - if (VarGet(VAR_PORTHOLE_STATE) == 2) - { - StartSpriteAnim(&gSprites[spriteId], GetFaceDirectionAnimNum(4)); - } + if (VarGet(VAR_SS_TIDAL_STATE) == SS_TIDAL_DEPART_SLATEPORT) + StartSpriteAnim(&gSprites[spriteId], GetFaceDirectionAnimNum(DIR_EAST)); else - { - StartSpriteAnim(&gSprites[spriteId], GetFaceDirectionAnimNum(3)); - } + StartSpriteAnim(&gSprites[spriteId], GetFaceDirectionAnimNum(DIR_WEST)); } void sub_80FB768(void) { - sub_80FB6EC(); + ShowSSTidalWhileSailing(); gEventObjects[gPlayerAvatar.eventObjectId].invisible = TRUE; pal_fill_black(); CreateTask(Task_HandlePorthole, 80); ScriptContext2_Enable(); } -void sub_80FB7A4(void) +void LookThroughPorthole(void) { FlagSet(FLAG_SYS_CRUISE_MODE); FlagSet(FLAG_DONT_TRANSITION_MUSIC); diff --git a/src/field_specials.c b/src/field_specials.c index b92e956d4..830c2246d 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -55,11 +55,13 @@ #include "constants/heal_locations.h" #include "constants/map_types.h" #include "constants/maps.h" +#include "constants/mevent.h" #include "constants/tv.h" #include "constants/script_menu.h" #include "constants/songs.h" #include "constants/species.h" #include "constants/moves.h" +#include "constants/party_menu.h" #include "constants/vars.h" #include "constants/battle_frontier.h" #include "constants/weather.h" @@ -90,9 +92,9 @@ extern const u16 gEventObjectPalette17[]; extern const u16 gEventObjectPalette33[]; extern const u16 gEventObjectPalette34[]; -void UpdateMovedLilycoveFanClubMembers(void); -void sub_813BF60(void); -u16 GetNumMovedLilycoveFanClubMembers(void); +void TryLoseFansFromPlayTime(void); +void SetPlayerGotFirstFans(void); +u16 GetNumFansOfPlayerInTrainerFanClub(void); static void RecordCyclingRoadResults(u32, u8); static void LoadLinkPartnerEventObjectSpritePalette(u8 graphicsId, u8 localEventId, u8 paletteNum); @@ -129,10 +131,10 @@ static void WaitForDeoxysRockMovement(u8 taskId); static void sub_813B57C(u8 taskId); static void Task_LoopWingFlapSE(u8 taskId); static void Task_CloseBattlePikeCurtain(u8 taskId); -static u8 sub_813BF44(void); -static void sub_813BD84(void); -static u16 sub_813BB74(void); -static void sub_813BE30(struct LinkBattleRecords *linkRecords, u8 a, u8 b); +static u8 DidPlayerGetFirstFans(void); +static void SetInitialFansOfPlayer(void); +static u16 PlayerGainRandomTrainerFan(void); +static void BufferFanClubTrainerName_(struct LinkBattleRecords *linkRecords, u8 a, u8 b); void Special_ShowDiploma(void) { @@ -301,9 +303,10 @@ void ResetSSTidalFlag(void) FlagClear(FLAG_SYS_CRUISE_MODE); } +// Returns TRUE if the Cruise is over bool32 CountSSTidalStep(u16 delta) { - if (!FlagGet(FLAG_SYS_CRUISE_MODE) || (*GetVarPointer(VAR_CRUISE_STEP_COUNT) += delta) <= 0xcc) + if (!FlagGet(FLAG_SYS_CRUISE_MODE) || (*GetVarPointer(VAR_CRUISE_STEP_COUNT) += delta) < SS_TIDAL_MAX_STEPS) { return FALSE; } @@ -313,21 +316,21 @@ bool32 CountSSTidalStep(u16 delta) u8 GetSSTidalLocation(s8 *mapGroup, s8 *mapNum, s16 *x, s16 *y) { u16 *varCruiseStepCount = GetVarPointer(VAR_CRUISE_STEP_COUNT); - switch (*GetVarPointer(VAR_PORTHOLE_STATE)) + switch (*GetVarPointer(VAR_SS_TIDAL_STATE)) { - case 1: - case 8: + case SS_TIDAL_BOARD_SLATEPORT: + case SS_TIDAL_LAND_SLATEPORT: return SS_TIDAL_LOCATION_SLATEPORT; - case 3: - case 9: + case SS_TIDAL_HALFWAY_LILYCOVE: + case SS_TIDAL_EXIT_CURRENTS_RIGHT: return SS_TIDAL_LOCATION_ROUTE131; - case 4: - case 5: + case SS_TIDAL_LAND_LILYCOVE: + case SS_TIDAL_BOARD_LILYCOVE: return SS_TIDAL_LOCATION_LILYCOVE; - case 6: - case 10: + case SS_TIDAL_DEPART_LILYCOVE: + case SS_TIDAL_EXIT_CURRENTS_LEFT: return SS_TIDAL_LOCATION_ROUTE124; - case 2: + case SS_TIDAL_DEPART_SLATEPORT: if (*varCruiseStepCount < 60) { *mapNum = MAP_NUM(ROUTE134); @@ -344,7 +347,7 @@ u8 GetSSTidalLocation(s8 *mapGroup, s8 *mapNum, s16 *x, s16 *y) *x = *varCruiseStepCount - 140; } break; - case 7: + case SS_TIDAL_HALFWAY_SLATEPORT: if (*varCruiseStepCount < 66) { *mapNum = MAP_NUM(ROUTE132); @@ -393,9 +396,9 @@ bool32 ShouldDoWallyCall(void) return TRUE; } -bool32 ShouldDoWinonaCall(void) +bool32 ShouldDoScottFortreeCall(void) { - if (FlagGet(FLAG_REGISTER_WINONA_POKENAV)) + if (FlagGet(FLAG_SCOTT_CALL_FORTREE_GYM)) { switch (gMapHeader.mapType) { @@ -403,7 +406,7 @@ bool32 ShouldDoWinonaCall(void) case MAP_TYPE_CITY: case MAP_TYPE_ROUTE: case MAP_TYPE_OCEAN_ROUTE: - if (++(*GetVarPointer(VAR_WINONA_CALL_STEP_COUNTER)) < 10) + if (++(*GetVarPointer(VAR_SCOTT_FORTREE_CALL_STEP_COUNTER)) < 10) { return FALSE; } @@ -420,9 +423,9 @@ bool32 ShouldDoWinonaCall(void) return TRUE; } -bool32 ShouldDoScottCall(void) +bool32 ShouldDoScottBattleFrontierCall(void) { - if (FlagGet(FLAG_SCOTT_CALL_NATIONAL_DEX)) + if (FlagGet(FLAG_SCOTT_CALL_BATTLE_FRONTIER)) { switch (gMapHeader.mapType) { @@ -430,7 +433,7 @@ bool32 ShouldDoScottCall(void) case MAP_TYPE_CITY: case MAP_TYPE_ROUTE: case MAP_TYPE_OCEAN_ROUTE: - if (++(*GetVarPointer(VAR_SCOTT_CALL_STEP_COUNTER)) < 10) + if (++(*GetVarPointer(VAR_SCOTT_BF_CALL_STEP_COUNTER)) < 10) { return FALSE; } @@ -973,7 +976,7 @@ void CableCarWarp(void) } } -void SetFlagInVar(void) +void SetHiddenItemFlag(void) { FlagSet(gSpecialVar_0x8004); } @@ -1408,9 +1411,9 @@ void GiveLeadMonEffortRibbon(void) ribbonSet = TRUE; leadMon = &gPlayerParty[GetLeadMonIndex()]; SetMonData(leadMon, MON_DATA_EFFORT_RIBBON, &ribbonSet); - if (GetRibbonCount(leadMon) > 4) + if (GetRibbonCount(leadMon) > NUM_CUTIES_RIBBONS) { - sub_80EE4DC(leadMon, 0x47); + TryPutSpotTheCutiesOnAir(leadMon, 0x47); } } @@ -1425,7 +1428,9 @@ bool8 Special_AreLeadMonEVsMaxedOut(void) u8 TryUpdateRusturfTunnelState(void) { - if (!FlagGet(FLAG_RUSTURF_TUNNEL_OPENED) && gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(RUSTURF_TUNNEL) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(RUSTURF_TUNNEL)) + if (!FlagGet(FLAG_RUSTURF_TUNNEL_OPENED) + && gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(RUSTURF_TUNNEL) + && gSaveBlock1Ptr->location.mapNum == MAP_NUM(RUSTURF_TUNNEL)) { if (FlagGet(FLAG_HIDE_RUSTURF_TUNNEL_ROCK_1)) { @@ -1605,18 +1610,16 @@ u16 SetPacifidlogTMReceivedDay(void) return gLocalTime.days; } -bool8 MonOTNameMatchesPlayer(void) +bool8 MonOTNameNotPlayer(void) { if (GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_LANGUAGE) != GAME_LANGUAGE) - { - return TRUE; // huh? - } + return TRUE; GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_OT_NAME, gStringVar1); + if (!StringCompare(gSaveBlock2Ptr->playerName, gStringVar1)) - { return FALSE; - } + return TRUE; } @@ -1654,19 +1657,19 @@ void BufferLottoTicketNumber(void) } } -u16 sub_813986C(void) +u16 GetMysteryEventCardVal(void) { switch (gSpecialVar_Result) { - case 0: - return mevent_081445C0(3); - case 1: - return mevent_081445C0(4); - case 2: - return mevent_081445C0(0); - case 3: + case GET_NUM_STAMPS: + return mevent_081445C0(GET_NUM_STAMPS_INTERNAL); + case GET_MAX_STAMPS: + return mevent_081445C0(GET_MAX_STAMPS_INTERNAL); + case GET_CARD_BATTLES_WON: + return mevent_081445C0(GET_CARD_BATTLES_WON_INTERNAL); + case 3: // Never occurs return mevent_081445C0(1); - case 4: + case 4: // Never occurs return mevent_081445C0(2); default: return 0; @@ -2080,78 +2083,78 @@ void ShowFrontierManiacMessage(void) { [FRONTIER_MANIAC_BATTLE_TOWER_SINGLES] = { - BattleFrontier_Lounge2_Text_260971, - BattleFrontier_Lounge2_Text_260A1E, - BattleFrontier_Lounge2_Text_260AE7 + BattleFrontier_Lounge2_Text_SalonMaidenIsThere, + BattleFrontier_Lounge2_Text_SalonMaidenSilverMons, + BattleFrontier_Lounge2_Text_SalonMaidenGoldMons }, [FRONTIER_MANIAC_BATTLE_TOWER_DOUBLES] = { - BattleFrontier_Lounge2_Text_2619AC, - BattleFrontier_Lounge2_Text_261A91, - BattleFrontier_Lounge2_Text_261B0C + BattleFrontier_Lounge2_Text_DoubleBattleAdvice1, + BattleFrontier_Lounge2_Text_DoubleBattleAdvice2, + BattleFrontier_Lounge2_Text_DoubleBattleAdvice3 }, [FRONTIER_MANIAC_BATTLE_TOWER_MULTIS] = { - BattleFrontier_Lounge2_Text_261B95, - BattleFrontier_Lounge2_Text_261B95, - BattleFrontier_Lounge2_Text_261B95 + BattleFrontier_Lounge2_Text_MultiBattleAdvice, + BattleFrontier_Lounge2_Text_MultiBattleAdvice, + BattleFrontier_Lounge2_Text_MultiBattleAdvice }, - [FRONTIER_MANIAC_BATTLE_TOWER_LINK_MULTIS] = + [FRONTIER_MANIAC_BATTLE_TOWER_LINK] = { - BattleFrontier_Lounge2_Text_261C1A, - BattleFrontier_Lounge2_Text_261C1A, - BattleFrontier_Lounge2_Text_261C1A + BattleFrontier_Lounge2_Text_LinkMultiBattleAdvice, + BattleFrontier_Lounge2_Text_LinkMultiBattleAdvice, + BattleFrontier_Lounge2_Text_LinkMultiBattleAdvice }, [FRONTIER_MANIAC_BATTLE_DOME] = { - BattleFrontier_Lounge2_Text_260BC4, - BattleFrontier_Lounge2_Text_260C6D, - BattleFrontier_Lounge2_Text_260D3A + BattleFrontier_Lounge2_Text_DomeAceIsThere, + BattleFrontier_Lounge2_Text_DomeAceSilverMons, + BattleFrontier_Lounge2_Text_DomeAceGoldMons }, [FRONTIER_MANIAC_BATTLE_FACTORY] = { - BattleFrontier_Lounge2_Text_260E1E, - BattleFrontier_Lounge2_Text_260EC7, - BattleFrontier_Lounge2_Text_260F74 + BattleFrontier_Lounge2_Text_FactoryHeadIsThere, + BattleFrontier_Lounge2_Text_FactoryHeadSilverMons, + BattleFrontier_Lounge2_Text_FactoryHeadGoldMons }, [FRONTIER_MANIAC_BATTLE_PALACE] = { - BattleFrontier_Lounge2_Text_2614E6, - BattleFrontier_Lounge2_Text_261591, - BattleFrontier_Lounge2_Text_26166F + BattleFrontier_Lounge2_Text_PalaceMavenIsThere, + BattleFrontier_Lounge2_Text_PalaceMavenSilverMons, + BattleFrontier_Lounge2_Text_PalaceMavenGoldMons }, [FRONTIER_MANIAC_BATTLE_ARENA] = { - BattleFrontier_Lounge2_Text_261282, - BattleFrontier_Lounge2_Text_261329, - BattleFrontier_Lounge2_Text_261403 + BattleFrontier_Lounge2_Text_ArenaTycoonIsThere, + BattleFrontier_Lounge2_Text_ArenaTycoonSilverMons, + BattleFrontier_Lounge2_Text_ArenaTycoonGoldMons }, [FRONTIER_MANIAC_BATTLE_PIKE] = { - BattleFrontier_Lounge2_Text_261026, - BattleFrontier_Lounge2_Text_2610CC, - BattleFrontier_Lounge2_Text_261194 + BattleFrontier_Lounge2_Text_PikeQueenIsThere, + BattleFrontier_Lounge2_Text_PikeQueenSilverMons, + BattleFrontier_Lounge2_Text_PikeQueenGoldMons }, [FRONTIER_MANIAC_BATTLE_PYRAMID] = { - BattleFrontier_Lounge2_Text_26174D, - BattleFrontier_Lounge2_Text_2617F9, - BattleFrontier_Lounge2_Text_2618C4 + BattleFrontier_Lounge2_Text_PyramidKingIsThere, + BattleFrontier_Lounge2_Text_PyramidKingSilverMons, + BattleFrontier_Lounge2_Text_PyramidKingGoldMons }, }; static const u8 sFrontierManiacStreakThresholds[][FRONTIER_MANIAC_MESSAGE_COUNT - 1] = { - [FRONTIER_MANIAC_BATTLE_TOWER_SINGLES] = { 21, 56 }, - [FRONTIER_MANIAC_BATTLE_TOWER_DOUBLES] = { 21, 35 }, - [FRONTIER_MANIAC_BATTLE_TOWER_MULTIS] = { 255, 255 }, - [FRONTIER_MANIAC_BATTLE_TOWER_LINK_MULTIS] = { 255, 255 }, - [FRONTIER_MANIAC_BATTLE_DOME] = { 2, 4 }, - [FRONTIER_MANIAC_BATTLE_FACTORY] = { 7, 21 }, - [FRONTIER_MANIAC_BATTLE_PALACE] = { 7, 21 }, - [FRONTIER_MANIAC_BATTLE_ARENA] = { 14, 28 }, - [FRONTIER_MANIAC_BATTLE_PIKE] = { 13, 112 }, //BUG: 112 (0x70) is probably a mistake; the Pike Queen is battled twice well before that - [FRONTIER_MANIAC_BATTLE_PYRAMID] = { 7, 56 } + [FRONTIER_MANIAC_BATTLE_TOWER_SINGLES] = { 21, 56 }, + [FRONTIER_MANIAC_BATTLE_TOWER_DOUBLES] = { 21, 35 }, + [FRONTIER_MANIAC_BATTLE_TOWER_MULTIS] = { 255, 255 }, + [FRONTIER_MANIAC_BATTLE_TOWER_LINK] = { 255, 255 }, + [FRONTIER_MANIAC_BATTLE_DOME] = { 2, 4 }, + [FRONTIER_MANIAC_BATTLE_FACTORY] = { 7, 21 }, + [FRONTIER_MANIAC_BATTLE_PALACE] = { 7, 21 }, + [FRONTIER_MANIAC_BATTLE_ARENA] = { 14, 28 }, + [FRONTIER_MANIAC_BATTLE_PIKE] = { 13, 112 }, //BUG: 112 (0x70) is probably a mistake; the Pike Queen is battled twice well before that + [FRONTIER_MANIAC_BATTLE_PYRAMID] = { 7, 56 } }; u8 i; @@ -2163,7 +2166,7 @@ void ShowFrontierManiacMessage(void) case FRONTIER_MANIAC_BATTLE_TOWER_SINGLES: case FRONTIER_MANIAC_BATTLE_TOWER_DOUBLES: case FRONTIER_MANIAC_BATTLE_TOWER_MULTIS: - case FRONTIER_MANIAC_BATTLE_TOWER_LINK_MULTIS: + case FRONTIER_MANIAC_BATTLE_TOWER_LINK: if (gSaveBlock2Ptr->frontier.towerWinStreaks[facility][FRONTIER_LVL_50] >= gSaveBlock2Ptr->frontier.towerWinStreaks[facility][FRONTIER_LVL_OPEN]) { @@ -2901,18 +2904,18 @@ void ShowFrontierGamblerLookingMessage(void) { static const u8 *const sFrontierGamblerLookingMessages[] = { - BattleFrontier_Lounge3_Text_262261, - BattleFrontier_Lounge3_Text_26230D, - BattleFrontier_Lounge3_Text_2623B9, - BattleFrontier_Lounge3_Text_262464, - BattleFrontier_Lounge3_Text_26250E, - BattleFrontier_Lounge3_Text_2625B8, - BattleFrontier_Lounge3_Text_26266A, - BattleFrontier_Lounge3_Text_26271C, - BattleFrontier_Lounge3_Text_2627C9, - BattleFrontier_Lounge3_Text_262876, - BattleFrontier_Lounge3_Text_26291A, - BattleFrontier_Lounge3_Text_2629BC, + BattleFrontier_Lounge3_Text_ChallengeBattleTowerSingle, + BattleFrontier_Lounge3_Text_ChallengeBattleTowerDouble, + BattleFrontier_Lounge3_Text_ChallengeBattleTowerMulti, + BattleFrontier_Lounge3_Text_ChallengeBattleDomeSingle, + BattleFrontier_Lounge3_Text_ChallengeBattleDomeDouble, + BattleFrontier_Lounge3_Text_ChallengeBattleFactorySingle, + BattleFrontier_Lounge3_Text_ChallengeBattleFactoryDouble, + BattleFrontier_Lounge3_Text_ChallengeBattlePalaceSingle, + BattleFrontier_Lounge3_Text_ChallengeBattlePalaceDouble, + BattleFrontier_Lounge3_Text_ChallengeBattleArena, + BattleFrontier_Lounge3_Text_ChallengeBattlePike, + BattleFrontier_Lounge3_Text_ChallengeBattlePyramid, }; u16 challenge = VarGet(VAR_FRONTIER_GAMBLER_CHALLENGE); @@ -2924,18 +2927,18 @@ void ShowFrontierGamblerGoMessage(void) { static const u8 *const sFrontierGamblerGoMessages[] = { - BattleFrontier_Lounge3_Text_262C04, - BattleFrontier_Lounge3_Text_262C90, - BattleFrontier_Lounge3_Text_262D1C, - BattleFrontier_Lounge3_Text_262DA7, - BattleFrontier_Lounge3_Text_262E34, - BattleFrontier_Lounge3_Text_262EC1, - BattleFrontier_Lounge3_Text_262F56, - BattleFrontier_Lounge3_Text_262FEB, - BattleFrontier_Lounge3_Text_263078, - BattleFrontier_Lounge3_Text_263105, - BattleFrontier_Lounge3_Text_26318C, - BattleFrontier_Lounge3_Text_263211, + BattleFrontier_Lounge3_Text_GetToBattleTowerSingle, + BattleFrontier_Lounge3_Text_GetToBattleTowerDouble, + BattleFrontier_Lounge3_Text_GetToBattleTowerMulti, + BattleFrontier_Lounge3_Text_GetToBattleDomeSingle, + BattleFrontier_Lounge3_Text_GetToBattleDomeDouble, + BattleFrontier_Lounge3_Text_GetToBattleFactorySingle, + BattleFrontier_Lounge3_Text_GetToBattleFactoryDouble, + BattleFrontier_Lounge3_Text_GetToBattlePalaceSingle, + BattleFrontier_Lounge3_Text_GetToBattlePalaceDouble, + BattleFrontier_Lounge3_Text_GetToBattleArena, + BattleFrontier_Lounge3_Text_GetToBattlePike, + BattleFrontier_Lounge3_Text_GetToBattlePyramid, }; ShowFieldMessage(sFrontierGamblerGoMessages[VarGet(VAR_FRONTIER_GAMBLER_SET_CHALLENGE)]); @@ -3210,31 +3213,31 @@ static void ShowBattleFrontierTutorMoveDescription(u8 menu, u16 selection) { static const u8 *const sBattleFrontier_TutorMoveDescriptions1[] = { - BattleFrontier_Lounge7_Text_265E30, - BattleFrontier_Lounge7_Text_265E5B, - BattleFrontier_Lounge7_Text_265E8A, - BattleFrontier_Lounge7_Text_265EC0, - BattleFrontier_Lounge7_Text_265EED, - BattleFrontier_Lounge7_Text_265F1C, - BattleFrontier_Lounge7_Text_265F47, - BattleFrontier_Lounge7_Text_265F77, - BattleFrontier_Lounge7_Text_265FAA, - BattleFrontier_Lounge7_Text_265FDD, + BattleFrontier_Lounge7_Text_SoftboiledDesc, + BattleFrontier_Lounge7_Text_SeismicTossDesc, + BattleFrontier_Lounge7_Text_DreamEaterDesc, + BattleFrontier_Lounge7_Text_MegaPunchDesc, + BattleFrontier_Lounge7_Text_MegaKickDesc, + BattleFrontier_Lounge7_Text_BodySlamDesc, + BattleFrontier_Lounge7_Text_RockSlideDesc, + BattleFrontier_Lounge7_Text_CounterDesc, + BattleFrontier_Lounge7_Text_ThunderWaveDesc, + BattleFrontier_Lounge7_Text_SwordsDanceDesc, gText_Exit, }; static const u8 *const sBattleFrontier_TutorMoveDescriptions2[] = { - BattleFrontier_Lounge7_Text_26600A, - BattleFrontier_Lounge7_Text_26603E, - BattleFrontier_Lounge7_Text_266070, - BattleFrontier_Lounge7_Text_2660A6, - BattleFrontier_Lounge7_Text_2660D0, - BattleFrontier_Lounge7_Text_2660FF, - BattleFrontier_Lounge7_Text_26612D, - BattleFrontier_Lounge7_Text_26615F, - BattleFrontier_Lounge7_Text_266185, - BattleFrontier_Lounge7_Text_2661B5, + BattleFrontier_Lounge7_Text_DefenseCurlDesc, + BattleFrontier_Lounge7_Text_SnoreDesc, + BattleFrontier_Lounge7_Text_MudSlapDesc, + BattleFrontier_Lounge7_Text_SwiftDesc, + BattleFrontier_Lounge7_Text_IcyWindDesc, + BattleFrontier_Lounge7_Text_EndureDesc, + BattleFrontier_Lounge7_Text_PsychUpDesc, + BattleFrontier_Lounge7_Text_IcePunchDesc, + BattleFrontier_Lounge7_Text_ThunderPunchDesc, + BattleFrontier_Lounge7_Text_FirePunchDesc, gText_Exit, }; @@ -3481,7 +3484,7 @@ void IncrementBirthIslandRockStepCount(void) } } -void sub_813B1D0(void) +void SetDeoxysRockPalette(void) { LoadPalette(&sDeoxysRockPalettes[(u8)VarGet(VAR_DEOXYS_ROCK_LEVEL)], 0x1A0, 8); BlendPalettes(0x04000000, 16, 0); @@ -3996,10 +3999,10 @@ bool8 InPokemonCenter(void) MAP_EVER_GRANDE_CITY_POKEMON_CENTER_1F, MAP_EVER_GRANDE_CITY_POKEMON_LEAGUE_1F, MAP_BATTLE_FRONTIER_POKEMON_CENTER_1F, - MAP_SINGLE_BATTLE_COLOSSEUM, + MAP_BATTLE_COLOSSEUM_2P, MAP_TRADE_CENTER, MAP_RECORD_CORNER, - MAP_DOUBLE_BATTLE_COLOSSEUM, + MAP_BATTLE_COLOSSEUM_4P, 0xFFFF }; @@ -4016,28 +4019,72 @@ bool8 InPokemonCenter(void) return FALSE; } +/* Summary of the Lilycove Trainer Fan Club, because it's a little messy + + ## The Fan Club room itself + There are initially 4 members of the Fan Club (+ an interviewer), none of whom are fans of the player + After becoming the champion there will be 8 members of the Fan Club, 3 of whom are automatically fans of the player + After this point, if a club member is a fan of the player they will sit at the front table and comment on the player + If they are not fans of the player, they will sit at the far table and can make comments about a different trainer (see BufferFanClubTrainerName) + + ## Gaining/losing fans + After every link battle the player will gain a fan if they won, or lose a fan if they lost + If the player has at least 3 fans, this is the only way to gain fans + If the player has fewer than 3 fans, they may also gain fans by completing certain tasks enough times (see TryGainNewFanFromCounter) + If the player has at least 5 fans, they can lose a fan every 12 real-time hours, or more often if the timer variable is reset (see TryLoseFansFromPlayTime) + If the player has only 1 fan left it cannot be lost + + ## Variables + VAR_FANCLUB_FAN_COUNTER, a bitfield for tracking the fans + Bits 1-7: Counter for when to add new fans + Bit 8: Flag set after receiving the initial 3 fans + Bits 9-16: Flags for each of the 8 club members, set to 1 when theyre a fan of the player and 0 when theyre not + + VAR_FANCLUB_LOSE_FAN_TIMER, a timer for when to lose fans + Compared against playTimeHours. When theyre equal, a fan is ready to be lost + For every fan thats lost this way 12 hours are added to the timer + + VAR_LILYCOVE_FAN_CLUB_STATE + 0: Player is not the champion yet + 1: Player is the champion, ready to meet their initial fans + 2: Player has met their initial fans +*/ + +#define FANCLUB_BITFIELD (gSaveBlock1Ptr->vars[VAR_FANCLUB_FAN_COUNTER - VARS_START]) +#define FANCLUB_COUNTER 0x007F +#define FANCLUB_FAN_FLAGS 0xFF80 + +#define GET_TRAINER_FAN_CLUB_FLAG(flag) (FANCLUB_BITFIELD >> (flag) & 1) +#define SET_TRAINER_FAN_CLUB_FLAG(flag) (FANCLUB_BITFIELD |= 1 << (flag)) +#define FLIP_TRAINER_FAN_CLUB_FLAG(flag)(FANCLUB_BITFIELD ^= 1 << (flag)) + +#define GET_TRAINER_FAN_CLUB_COUNTER (FANCLUB_BITFIELD & FANCLUB_COUNTER) +#define SET_TRAINER_FAN_CLUB_COUNTER(count) (FANCLUB_BITFIELD = (FANCLUB_BITFIELD & FANCLUB_FAN_FLAGS) | (count)) +#define INCR_TRAINER_FAN_CLUB_COUNTER(count)(FANCLUB_BITFIELD += (count)) +#define CLEAR_TRAINER_FAN_CLUB_COUNTER (FANCLUB_BITFIELD &= ~(FANCLUB_COUNTER)) + void ResetFanClub(void) { - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] = 0; - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] = 0; + gSaveBlock1Ptr->vars[VAR_FANCLUB_FAN_COUNTER - VARS_START] = 0; + gSaveBlock1Ptr->vars[VAR_FANCLUB_LOSE_FAN_TIMER - VARS_START] = 0; } -void sub_813BA30(void) +void TryLoseFansFromPlayTimeAfterLinkBattle(void) { - if (sub_813BF44() != 0) + if (DidPlayerGetFirstFans()) { - UpdateMovedLilycoveFanClubMembers(); - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] = gSaveBlock2Ptr->playTimeHours; + TryLoseFansFromPlayTime(); + gSaveBlock1Ptr->vars[VAR_FANCLUB_LOSE_FAN_TIMER - VARS_START] = gSaveBlock2Ptr->playTimeHours; } } -void sub_813BA60(void) +void UpdateTrainerFanClubGameClear(void) { - if (!((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> 7) & 1)) + if (!GET_TRAINER_FAN_CLUB_FLAG(FANCLUB_GOT_FIRST_FANS)) { - sub_813BF60(); - sub_813BD84(); - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] = gSaveBlock2Ptr->playTimeHours; + SetPlayerGotFirstFans(); + SetInitialFansOfPlayer(); + gSaveBlock1Ptr->vars[VAR_FANCLUB_LOSE_FAN_TIMER - VARS_START] = gSaveBlock2Ptr->playTimeHours; FlagClear(FLAG_HIDE_FANCLUB_OLD_LADY); FlagClear(FLAG_HIDE_FANCLUB_BOY); FlagClear(FLAG_HIDE_FANCLUB_LITTLE_BOY); @@ -4047,186 +4094,216 @@ void sub_813BA60(void) } } -u8 sub_813BADC(u8 a0) +// If the player has < 3 fans, gain a new fan whenever the counter reaches 20+ +// Defeating Drake or participating in a Link Contest increments the counter by 2 +// Participating at Battle Tower or in a Secret Base battle increments the counter by 1 +u8 TryGainNewFanFromCounter(u8 incrementId) { - static const u8 gUnknown_085B3470[] = { 0x02, 0x01, 0x02, 0x01 }; + static const u8 sCounterIncrements[] = { 2, 1, 2, 1 }; if (VarGet(VAR_LILYCOVE_FAN_CLUB_STATE) == 2) { - if ((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] & 0x7F) + gUnknown_085B3470[a0] > 19) + if (GET_TRAINER_FAN_CLUB_COUNTER + sCounterIncrements[incrementId] > 19) { - if (GetNumMovedLilycoveFanClubMembers() < 3) + if (GetNumFansOfPlayerInTrainerFanClub() < 3) { - sub_813BB74(); - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] &= 0xFF80; + PlayerGainRandomTrainerFan(); + CLEAR_TRAINER_FAN_CLUB_COUNTER; } else { - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] = (gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] & 0xFF80) | 0x14; + SET_TRAINER_FAN_CLUB_COUNTER(20); } } else { - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] += gUnknown_085B3470[a0]; + INCR_TRAINER_FAN_CLUB_COUNTER(sCounterIncrements[incrementId]); } } - return gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] & 0x7F; + return GET_TRAINER_FAN_CLUB_COUNTER; } -static u16 sub_813BB74(void) + +// Loop through the fan club members, and if theyre not a fan of the player there is a 50% chance for them to become a fan +// Stops when a fan is gained +// If no new fan was gained while looping, the last non-fan in the list becomes a fan +// If all the members are already fans of the player then this redundantly sets the first fan in the list to be a fan +static u16 PlayerGainRandomTrainerFan(void) { - static const u8 gUnknown_085B3474[] = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; + static const u8 sFanClubMemberIds[NUM_TRAINER_FAN_CLUB_MEMBERS] = + { + FANCLUB_MEMBER1, + FANCLUB_MEMBER2, + FANCLUB_MEMBER3, + FANCLUB_MEMBER4, + FANCLUB_MEMBER5, + FANCLUB_MEMBER6, + FANCLUB_MEMBER7, + FANCLUB_MEMBER8 + }; u8 i; - u8 retVal = 0; + u8 idx = 0; - for (i = 0; i < 8; i++) + for (i = 0; i < ARRAY_COUNT(sFanClubMemberIds); i++) { - if (!((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> gUnknown_085B3474[i]) & 1)) + if (!GET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[i])) { - retVal = i; - if ((Random() & 1) != 0) + idx = i; + if (Random() & 1) { - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 1 << gUnknown_085B3474[retVal]; - return retVal; + SET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]); + return idx; } } } - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 1 << gUnknown_085B3474[retVal]; - return retVal; + SET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]); + return idx; } -static u16 sub_813BC00(void) +// Loops through the fan club members, and if theyre a fan of the player there is a 50% chance for them to stop being a fan +// Stops if a fan is removed, or if the player has only one fan left +// If no fan was lost while looping, the last current fan in the list will stop being a fan +static u16 PlayerLoseRandomTrainerFan(void) { - static const u8 gUnknown_085B347C[] = { 0x08, 0x0d, 0x0e, 0x0b, 0x0a, 0x0c, 0x0f, 0x09 }; + static const u8 sFanClubMemberIds[NUM_TRAINER_FAN_CLUB_MEMBERS] = + { + FANCLUB_MEMBER1, + FANCLUB_MEMBER6, + FANCLUB_MEMBER7, + FANCLUB_MEMBER4, + FANCLUB_MEMBER3, + FANCLUB_MEMBER5, + FANCLUB_MEMBER8, + FANCLUB_MEMBER2 + }; u8 i; - u8 retVal = 0; + u8 idx = 0; - if (GetNumMovedLilycoveFanClubMembers() == 1) + if (GetNumFansOfPlayerInTrainerFanClub() == 1) { return 0; } - for (i = 0; i < 8; i++) + for (i = 0; i < ARRAY_COUNT(sFanClubMemberIds); i++) { - if (((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> gUnknown_085B347C[i]) & 1) != 0) + if (GET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[i])) { - retVal = i; - if ((Random() & 1) != 0) + idx = i; + if (Random() & 1) { - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] ^= 1 << gUnknown_085B347C[retVal]; - return retVal; + FLIP_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]); + return idx; } } } - if (((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> gUnknown_085B347C[retVal]) & 1)) + if (GET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx])) { - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] ^= 1 << gUnknown_085B347C[retVal]; + FLIP_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]); } - return retVal; + return idx; } -u16 GetNumMovedLilycoveFanClubMembers(void) +u16 GetNumFansOfPlayerInTrainerFanClub(void) { u8 i; - u8 retVal = 0; + u8 numFans = 0; - for (i = 0; i < 8; i++) + for (i = 0; i < NUM_TRAINER_FAN_CLUB_MEMBERS; i++) { - if (((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> (i + 8)) & 1) != 0) - { - retVal++; - } + if (GET_TRAINER_FAN_CLUB_FLAG(i + FANCLUB_MEMBER1)) + numFans++; } - return retVal; + return numFans; } -void UpdateMovedLilycoveFanClubMembers(void) +// If the player has > 5 fans in the Trainer Fan Club, then lose 1 fan for every 12 hours since the last fan loss / timer reset +void TryLoseFansFromPlayTime(void) { u8 i = 0; if (gSaveBlock2Ptr->playTimeHours < 999) { while (TRUE) { - if (GetNumMovedLilycoveFanClubMembers() < 5) + if (GetNumFansOfPlayerInTrainerFanClub() < 5) { - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] = gSaveBlock2Ptr->playTimeHours; + gSaveBlock1Ptr->vars[VAR_FANCLUB_LOSE_FAN_TIMER - VARS_START] = gSaveBlock2Ptr->playTimeHours; break; } - else if (i == 8) + else if (i == NUM_TRAINER_FAN_CLUB_MEMBERS) { break; } - else if (gSaveBlock2Ptr->playTimeHours - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] < 12) + else if (gSaveBlock2Ptr->playTimeHours - gSaveBlock1Ptr->vars[VAR_FANCLUB_LOSE_FAN_TIMER - VARS_START] < 12) { return; } - sub_813BC00(); - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] += 12; + PlayerLoseRandomTrainerFan(); + gSaveBlock1Ptr->vars[VAR_FANCLUB_LOSE_FAN_TIMER - VARS_START] += 12; i++; } } } -bool8 ShouldMoveLilycoveFanClubMember(void) +bool8 IsFanClubMemberFanOfPlayer(void) { - return (gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> gSpecialVar_0x8004) & 1; + return GET_TRAINER_FAN_CLUB_FLAG(gSpecialVar_0x8004); } -static void sub_813BD84(void) +static void SetInitialFansOfPlayer(void) { - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 0x2000; - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 0x100; - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 0x400; + SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_MEMBER6); + SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_MEMBER1); + SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_MEMBER3); } -void BufferStreakTrainerText(void) +void BufferFanClubTrainerName(void) { - u8 a = 0; - u8 b = 0; + u8 whichLinkTrainer = 0; + u8 whichNPCTrainer = 0; switch (gSpecialVar_0x8004) { - case 8: + case FANCLUB_MEMBER1: break; - case 9: + case FANCLUB_MEMBER2: break; - case 10: - a = 0; - b = 3; + case FANCLUB_MEMBER3: + whichLinkTrainer = 0; + whichNPCTrainer = 3; break; - case 11: - a = 0; - b = 1; + case FANCLUB_MEMBER4: + whichLinkTrainer = 0; + whichNPCTrainer = 1; break; - case 12: - a = 1; - b = 0; + case FANCLUB_MEMBER5: + whichLinkTrainer = 1; + whichNPCTrainer = 0; break; - case 13: - a = 0; - b = 4; + case FANCLUB_MEMBER6: + whichLinkTrainer = 0; + whichNPCTrainer = 4; break; - case 14: - a = 1; - b = 5; + case FANCLUB_MEMBER7: + whichLinkTrainer = 1; + whichNPCTrainer = 5; break; - case 15: + case FANCLUB_MEMBER8: break; } - sub_813BE30(&gSaveBlock1Ptr->linkBattleRecords, a, b); + BufferFanClubTrainerName_(&gSaveBlock1Ptr->linkBattleRecords, whichLinkTrainer, whichNPCTrainer); } -static void sub_813BE30(struct LinkBattleRecords *linkRecords, u8 a, u8 b) +static void BufferFanClubTrainerName_(struct LinkBattleRecords *linkRecords, u8 whichLinkTrainer, u8 whichNPCTrainer) { - struct LinkBattleRecord *record = &linkRecords->entries[a]; + struct LinkBattleRecord *record = &linkRecords->entries[whichLinkTrainer]; if (record->name[0] == EOS) { - switch (b) + switch (whichNPCTrainer) { case 0: StringCopy(gStringVar1, gText_Wallace); @@ -4253,39 +4330,36 @@ static void sub_813BE30(struct LinkBattleRecords *linkRecords, u8 a, u8 b) } else { - StringCopyN(gStringVar1, record->name, 7); - gStringVar1[7] = EOS; - ConvertInternationalString(gStringVar1, linkRecords->languages[a]); + StringCopyN(gStringVar1, record->name, PLAYER_NAME_LENGTH); + gStringVar1[PLAYER_NAME_LENGTH] = EOS; + ConvertInternationalString(gStringVar1, linkRecords->languages[whichLinkTrainer]); } } -void sub_813BF10(void) +void UpdateTrainerFansAfterLinkBattle(void) { if (VarGet(VAR_LILYCOVE_FAN_CLUB_STATE) == 2) { - sub_813BA30(); - if (gBattleOutcome == 1) - { - sub_813BB74(); - } + TryLoseFansFromPlayTimeAfterLinkBattle(); + if (gBattleOutcome == B_OUTCOME_WON) + PlayerGainRandomTrainerFan(); else - { - sub_813BC00(); - } + PlayerLoseRandomTrainerFan(); } } -static bool8 sub_813BF44(void) +static bool8 DidPlayerGetFirstFans(void) { - return (gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> 7) & 1; + return GET_TRAINER_FAN_CLUB_FLAG(FANCLUB_GOT_FIRST_FANS); } -void sub_813BF60(void) +void SetPlayerGotFirstFans(void) { - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 0x80; + SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_GOT_FIRST_FANS); } -u8 sub_813BF7C(void) +// return value is always ignored +u8 Script_TryGainNewFanFromCounter(void) { - return sub_813BADC(gSpecialVar_0x8004); + return TryGainNewFanFromCounter(gSpecialVar_0x8004); } diff --git a/src/fieldmap.c b/src/fieldmap.c index b2b80a2df..f595803ff 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -75,7 +75,7 @@ void InitBattlePyramidMap(bool8 setPlayerPosition) void InitTrainerHillMap(void) { CpuFastFill(0x03ff03ff, gBackupMapData, sizeof(gBackupMapData)); - sub_81D5FB4(gBackupMapData); + GenerateTrainerHillFloorLayout(gBackupMapData); } static void InitMapLayoutData(struct MapHeader *mapHeader) diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c index 00eed7624..fe21ff060 100644 --- a/src/fldeff_cut.c +++ b/src/fldeff_cut.c @@ -25,7 +25,7 @@ extern struct MapPosition gPlayerFacingPosition; extern const u8 EventScript_FldEffCut[]; -extern const u8 FarawayIsland_Interior_EventScript_267EDB[]; +extern const u8 FarawayIsland_Interior_EventScript_HideMewWhenGrassCut[]; extern const u8 gFieldEffectPic_CutGrass[]; extern const u16 gFieldEffectObjectPalette6[]; @@ -584,7 +584,7 @@ static void CutGrassSpriteCallbackEnd(struct Sprite *sprite) ScriptContext2_Disable(); if (IsMewPlayingHideAndSeek() == TRUE) - ScriptContext1_SetupScript(FarawayIsland_Interior_EventScript_267EDB); + ScriptContext1_SetupScript(FarawayIsland_Interior_EventScript_HideMewWhenGrassCut); } void FixLongGrassMetatilesWindowTop(s16 x, s16 y) diff --git a/src/fldeff_flash.c b/src/fldeff_flash.c index a2457307b..fedf38cf5 100644 --- a/src/fldeff_flash.c +++ b/src/fldeff_flash.c @@ -26,8 +26,8 @@ struct FlashStruct }; // static functions -static void hm2_flash(void); -static void sub_81371B4(void); +static void FieldCallback_Flash(void); +static void FldEff_UseFlash(void); static bool8 sub_8137304(void); static void sub_81373F0(void); static void sub_8137404(u8 taskId); @@ -86,26 +86,26 @@ bool8 SetUpFieldMove_Flash(void) else if (gMapHeader.cave == TRUE && !FlagGet(FLAG_SYS_USE_FLASH)) { gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; - gPostMenuFieldCallback = hm2_flash; + gPostMenuFieldCallback = FieldCallback_Flash; return TRUE; } return FALSE; } -static void hm2_flash(void) +static void FieldCallback_Flash(void) { u8 taskId = oei_task_add(); gFieldEffectArguments[0] = GetCursorSelectionMonId(); - gTasks[taskId].data[8] = (uintptr_t)sub_81371B4 >> 16; - gTasks[taskId].data[9] = (uintptr_t)sub_81371B4; + gTasks[taskId].data[8] = (uintptr_t)FldEff_UseFlash >> 16; + gTasks[taskId].data[9] = (uintptr_t)FldEff_UseFlash; } -static void sub_81371B4(void) +static void FldEff_UseFlash(void) { PlaySE(SE_W115); FlagSet(FLAG_SYS_USE_FLASH); - ScriptContext1_SetupScript(EventScript_2926F8); + ScriptContext1_SetupScript(EventScript_FldEffFlash); } static void sub_81371D4(void) diff --git a/src/fldeff_softboiled.c b/src/fldeff_softboiled.c index 733263bbc..1a42b297d 100644 --- a/src/fldeff_softboiled.c +++ b/src/fldeff_softboiled.c @@ -7,12 +7,13 @@ #include "string_util.h" #include "strings.h" #include "task.h" +#include "constants/party_menu.h" #include "constants/songs.h" -static void sub_816166C(u8 taskId); -static void sub_81616C0(u8 taskId); -static void sub_8161724(u8 taskId); -static void sub_81617B8(u8 taskId); +static void Task_SoftboiledRestoreHealth(u8 taskId); +static void Task_DisplayHPRestoredMessage(u8 taskId); +static void Task_FinishSoftboiled(u8 taskId); +static void CantUseSoftboiledOnMon(u8 taskId); bool8 SetUpFieldMove_SoftBoiled(void) { @@ -29,81 +30,82 @@ bool8 SetUpFieldMove_SoftBoiled(void) return FALSE; } -void sub_8161560(u8 taskId) +void ChooseMonForSoftboiled(u8 taskId) { - gUnknown_0203CEC8.unkB = 0xA; - gUnknown_0203CEC8.unkA = gUnknown_0203CEC8.slotId; - sub_81B0FCC(GetCursorSelectionMonId(), 0x1); - DisplayPartyMenuStdMessage(5); - gTasks[taskId].func = sub_81B1370; + gPartyMenu.action = PARTY_ACTION_SOFTBOILED; + gPartyMenu.slotId2 = gPartyMenu.slotId; + AnimatePartySlot(GetCursorSelectionMonId(), 1); + DisplayPartyMenuStdMessage(PARTY_MSG_USE_ON_WHICH_MON); + gTasks[taskId].func = Task_HandleChooseMonInput; } -void sub_81615A8(u8 taskId) +void Task_TryUseSoftboiledOnPartyMon(u8 taskId) { u16 hp; - u8 slotId = gUnknown_0203CEC8.slotId; - u8 pokemonIndex = gUnknown_0203CEC8.unkA; - if(pokemonIndex > 6) + u8 userPartyId = gPartyMenu.slotId; + u8 recipientPartyId = gPartyMenu.slotId2; + if(recipientPartyId > PARTY_SIZE) { - gUnknown_0203CEC8.unkB = 0; - DisplayPartyMenuStdMessage(0); - gTasks[taskId].func = sub_81B1370; + gPartyMenu.action = 0; + DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); + gTasks[taskId].func = Task_HandleChooseMonInput; return; } - hp = GetMonData(&gPlayerParty[pokemonIndex], MON_DATA_HP); - if(hp == 0 || slotId == pokemonIndex || GetMonData(&gPlayerParty[pokemonIndex], MON_DATA_MAX_HP) == hp) + hp = GetMonData(&gPlayerParty[recipientPartyId], MON_DATA_HP); + if(hp == 0 || userPartyId == recipientPartyId || GetMonData(&gPlayerParty[recipientPartyId], MON_DATA_MAX_HP) == hp) { - sub_81617B8(taskId); + CantUseSoftboiledOnMon(taskId); return; } + // Take away Softboiled user's health first (-1) PlaySE(SE_KAIFUKU); - sub_81B1F18(taskId, slotId, -1, GetMonData(&gPlayerParty[slotId], MON_DATA_MAX_HP)/5, sub_816166C); + PartyMenuModifyHP(taskId, userPartyId, -1, GetMonData(&gPlayerParty[userPartyId], MON_DATA_MAX_HP)/5, Task_SoftboiledRestoreHealth); } -static void sub_816166C(u8 taskId) +static void Task_SoftboiledRestoreHealth(u8 taskId) { PlaySE(SE_KAIFUKU); - sub_81B1F18(taskId, gUnknown_0203CEC8.unkA, 1, GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_MAX_HP)/5, sub_81616C0); + PartyMenuModifyHP(taskId, gPartyMenu.slotId2, 1, GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_MAX_HP)/5, Task_DisplayHPRestoredMessage); } -static void sub_81616C0(u8 taskId) +static void Task_DisplayHPRestoredMessage(u8 taskId) { - GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.unkA], gStringVar1); + GetMonNickname(&gPlayerParty[gPartyMenu.slotId2], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnHPRestoredByVar2); - DisplayPartyMenuMessage(gStringVar4, 0); + DisplayPartyMenuMessage(gStringVar4, FALSE); schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = sub_8161724; + gTasks[taskId].func = Task_FinishSoftboiled; } -static void sub_8161724(u8 taskId) +static void Task_FinishSoftboiled(u8 taskId) { - if(sub_81B1BD4() == 1) + if(IsPartyMenuTextPrinterActive() == TRUE) return; - gUnknown_0203CEC8.unkB = 0x0; - sub_81B0FCC(gUnknown_0203CEC8.slotId, 0); - gUnknown_0203CEC8.slotId = gUnknown_0203CEC8.unkA; - sub_81B0FCC(gUnknown_0203CEC8.unkA, 1); - ClearStdWindowAndFrameToTransparent(0x6, FALSE); - ClearWindowTilemap(0x6); - DisplayPartyMenuStdMessage(0); - gTasks[taskId].func = sub_81B1370; + gPartyMenu.action = 0; + AnimatePartySlot(gPartyMenu.slotId, 0); + gPartyMenu.slotId = gPartyMenu.slotId2; + AnimatePartySlot(gPartyMenu.slotId2, 1); + ClearStdWindowAndFrameToTransparent(6, FALSE); + ClearWindowTilemap(6); + DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); + gTasks[taskId].func = Task_HandleChooseMonInput; } -static void sub_8161784(u8 taskId) +static void Task_ChooseNewMonForSoftboiled(u8 taskId) { - if(sub_81B1BD4() == 1) + if(IsPartyMenuTextPrinterActive() == TRUE) return; - DisplayPartyMenuStdMessage(5); - gTasks[taskId].func = sub_81B1370; + DisplayPartyMenuStdMessage(PARTY_MSG_USE_ON_WHICH_MON); + gTasks[taskId].func = Task_HandleChooseMonInput; } -static void sub_81617B8(u8 taskId) +static void CantUseSoftboiledOnMon(u8 taskId) { PlaySE(SE_SELECT); - DisplayPartyMenuMessage(gText_CantBeUsedOnPkmn, 0); + DisplayPartyMenuMessage(gText_CantBeUsedOnPkmn, FALSE); schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = sub_8161784; + gTasks[taskId].func = Task_ChooseNewMonForSoftboiled; } diff --git a/src/frontier_util.c b/src/frontier_util.c index d7d76066f..87aff022e 100644 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -29,6 +29,7 @@ #include "load_save.h" #include "battle_dome.h" #include "constants/battle_frontier.h" +#include "constants/frontier_util.h" #include "constants/trainers.h" #include "constants/species.h" #include "constants/game_stat.h" @@ -51,26 +52,26 @@ struct FrontierBrainMon static void sub_81A17A0(void); static void sub_81A1830(void); static void sub_81A1968(void); -static void sub_81A1AD4(void); +static void LoadSelectedParty(void); static void DoSoftReset_(void); -static void sub_81A1B28(void); +static void SetFrontierTrainers(void); static void sub_81A1B38(void); static void ShowFacilityResultsWindow(void); static void sub_81A31FC(void); static void sub_81A35EC(void); -static void sub_81A3B00(void); +static void IsTrainerFrontierBrain(void); static void sub_81A3B64(void); -static void sub_81A3D30(void); -static void sub_81A3D58(void); -static void sub_81A3DA0(void); +static void GetFacilitySymbolCount(void); +static void GiveFacilitySymbol(void); +static void CheckBattleTypeFlag(void); static void sub_81A3FD4(void); -static void sub_81A4224(void); +static void ValidateVisitingTrainer(void); static void sub_81A4230(void); static void sub_81A43A8(void); static void sub_81A4410(void); -static void sub_81A443C(void); +static void BufferFrontierTrainerName(void); static void sub_81A447C(void); -static void sub_81A457C(void); +static void SetFacilityBrainEventObject(void); static void ShowTowerResultsWindow(u8); static void ShowDomeResultsWindow(u8); static void ShowPalaceResultsWindow(u8); @@ -603,29 +604,29 @@ static const u16 gUnknown_08611BFC[][2] = static void (* const sFrontierUtilFuncs[])(void) = { - sub_81A17A0, - sub_81A1830, - sub_81A1968, - sub_81A1AD4, - DoSoftReset_, - sub_81A1B28, - sub_81A1B38, - ShowFacilityResultsWindow, - sub_81A31FC, - sub_81A35EC, - sub_81A3B00, - sub_81A3B64, - sub_81A3D30, - sub_81A3D58, - sub_81A3DA0, - sub_81A3FD4, - sub_81A4224, - sub_81A4230, - sub_81A43A8, - sub_81A4410, - sub_81A443C, - sub_81A447C, - sub_81A457C, + [FRONTIER_UTIL_FUNC_0] = sub_81A17A0, + [FRONTIER_UTIL_FUNC_1] = sub_81A1830, + [FRONTIER_UTIL_FUNC_2] = sub_81A1968, + [FRONTIER_UTIL_FUNC_LOAD_SELECTED_PARTY] = LoadSelectedParty, + [FRONTIER_UTIL_FUNC_SOFT_RESET] = DoSoftReset_, + [FRONTIER_UTIL_FUNC_SET_FRONTIER_TRAINERS] = SetFrontierTrainers, + [FRONTIER_UTIL_FUNC_6] = sub_81A1B38, + [FRONTIER_UTIL_FUNC_RESULTS_WINDOW] = ShowFacilityResultsWindow, + [FRONTIER_UTIL_FUNC_8] = sub_81A31FC, + [FRONTIER_UTIL_FUNC_9] = sub_81A35EC, + [FRONTIER_UTIL_FUNC_IS_FRONTIER_BRAIN] = IsTrainerFrontierBrain, + [FRONTIER_UTIL_FUNC_11] = sub_81A3B64, + [FRONTIER_UTIL_FUNC_GET_FACILITY_SYMBOLS] = GetFacilitySymbolCount, + [FRONTIER_UTIL_FUNC_GIVE_FACILITY_SYMBOL] = GiveFacilitySymbol, + [FRONTIER_UTIL_FUNC_CHECK_BATTLE_TYPE] = CheckBattleTypeFlag, + [FRONTIER_UTIL_FUNC_15] = sub_81A3FD4, + [FRONTIER_UTIL_FUNC_CHECK_VISIT_TRAINER] = ValidateVisitingTrainer, + [FRONTIER_UTIL_FUNC_17] = sub_81A4230, + [FRONTIER_UTIL_FUNC_18] = sub_81A43A8, + [FRONTIER_UTIL_FUNC_19] = sub_81A4410, + [FRONTIER_UTIL_FUNC_BUFFER_TRAINER_NAME] = BufferFrontierTrainerName, + [FRONTIER_UTIL_FUNC_21] = sub_81A447C, + [FRONTIER_UTIL_FUNC_SET_BRAIN_OBJECT] = SetFacilityBrainEventObject, }; static const struct WindowTemplate gUnknown_08611C74 = @@ -679,38 +680,38 @@ const u16 gFrontierBannedSpecies[] = SPECIES_KYOGRE, SPECIES_GROUDON, SPECIES_RAYQUAZA, SPECIES_JIRACHI, SPECIES_DEOXYS, 0xFFFF }; -static const u8 *const gUnknown_08611CB0[][2] = -{ - {gText_BattleTower2, gUnknown_085ED164}, - {gText_BattleTower2, gUnknown_085ED170}, - {gText_BattleTower2, gUnknown_085ED17C}, - {gText_BattleDome, gUnknown_085ED164}, - {gText_BattlePalace, gUnknown_085ED164}, - {gText_BattleArena, gUnknown_085ED190}, - {gText_BattleFactory, gUnknown_085ED164}, - {gText_BattlePike, gUnknown_085ED190}, - {gText_BattlePyramid, gUnknown_085ED190}, - {gText_BattleTower2, gUnknown_085ED188}, +static const u8 *const sRecordsWindowChallengeTexts[][2] = +{ + [RANKING_HALL_BATTLE_TOWER_SINGLES] = {gText_BattleTower2, gText_FacilitySingle}, + [RANKING_HALL_BATTLE_TOWER_DOUBLES] = {gText_BattleTower2, gText_FacilityDouble}, + [RANKING_HALL_BATTLE_TOWER_MULTIS] = {gText_BattleTower2, gText_FacilityMulti}, + [RANKING_HALL_BATTLE_DOME] = {gText_BattleDome, gText_FacilitySingle}, + [RANKING_HALL_BATTLE_PALACE] = {gText_BattlePalace, gText_FacilitySingle}, + [RANKING_HALL_BATTLE_ARENA] = {gText_BattleArena, gText_Facility}, + [RANKING_HALL_BATTLE_FACTORY] = {gText_BattleFactory, gText_FacilitySingle}, + [RANKING_HALL_BATTLE_PIKE] = {gText_BattlePike, gText_Facility}, + [RANKING_HALL_BATTLE_PYRAMID] = {gText_BattlePyramid, gText_Facility}, + [RANKING_HALL_BATTLE_TOWER_LINK] = {gText_BattleTower2, gText_FacilityLink}, }; -static const u8 *const gLevelModeText[] = +static const u8 *const sLevelModeText[] = { gText_RecordsLv50, gText_RecordsOpenLevel, }; -static const u8 *const gHallFacilityToRecordsText[] = -{ - gText_FrontierFacilityWinStreak, - gText_FrontierFacilityWinStreak, - gText_FrontierFacilityWinStreak, - gText_FrontierFacilityClearStreak, - gText_FrontierFacilityWinStreak, - gText_FrontierFacilityKOsStreak, - gText_FrontierFacilityWinStreak, - gText_FrontierFacilityRoomsCleared, - gText_FrontierFacilityFloorsCleared, - gText_FrontierFacilityWinStreak, +static const u8 *const sHallFacilityToRecordsText[] = +{ + [RANKING_HALL_BATTLE_TOWER_SINGLES] = gText_FrontierFacilityWinStreak, + [RANKING_HALL_BATTLE_TOWER_DOUBLES] = gText_FrontierFacilityWinStreak, + [RANKING_HALL_BATTLE_TOWER_MULTIS] = gText_FrontierFacilityWinStreak, + [RANKING_HALL_BATTLE_DOME] = gText_FrontierFacilityClearStreak, + [RANKING_HALL_BATTLE_PALACE] = gText_FrontierFacilityWinStreak, + [RANKING_HALL_BATTLE_ARENA] = gText_FrontierFacilityKOsStreak, + [RANKING_HALL_BATTLE_FACTORY] = gText_FrontierFacilityWinStreak, + [RANKING_HALL_BATTLE_PIKE] = gText_FrontierFacilityRoomsCleared, + [RANKING_HALL_BATTLE_PYRAMID] = gText_FrontierFacilityFloorsCleared, + [RANKING_HALL_BATTLE_TOWER_LINK] = gText_FrontierFacilityWinStreak, }; static const u16 gFacilityToBrainTrainerId[] = @@ -880,11 +881,11 @@ static void sub_81A1968(void) } } -static void sub_81A1AD4(void) +static void LoadSelectedParty(void) { s32 i; - sub_81B8558(); + ClearSelectedPartyOrder(); for (i = 0; i < gSpecialVar_0x8005; i++) gSelectedOrderFromParty[i] = gSaveBlock2Ptr->frontier.selectedPartyMons[i]; ReducePlayerPartyToSelectedMons(); @@ -895,7 +896,7 @@ static void DoSoftReset_(void) DoSoftReset(); } -static void sub_81A1B28(void) +static void SetFrontierTrainers(void) { gFacilityTrainers = gBattleFrontierTrainers; } @@ -1697,7 +1698,7 @@ void CopyFrontierTrainerText(u8 whichText, u16 trainerId) else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) FrontierSpeechToString(gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].greeting); else - CopyFriendsApprenticeChallengeText(trainerId - TRAINER_RECORD_MIXING_APPRENTICE); + BufferApprenticeChallengeText(trainerId - TRAINER_RECORD_MIXING_APPRENTICE); break; case FRONTIER_PLAYER_LOST_TEXT: if (trainerId == TRAINER_EREADER) @@ -1724,7 +1725,7 @@ void CopyFrontierTrainerText(u8 whichText, u16 trainerId) if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) FrontierSpeechToString(GetRecordedBattleEasyChatSpeech()); else - FrontierSpeechToString(gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].easyChatWords); + FrontierSpeechToString(gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].speechWon); } break; case FRONTIER_PLAYER_WON_TEXT: @@ -1752,12 +1753,12 @@ void CopyFrontierTrainerText(u8 whichText, u16 trainerId) if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { trainerId = GetRecordedBattleApprenticeId(); - FrontierSpeechToString(gApprentices[trainerId].easyChatWords); + FrontierSpeechToString(gApprentices[trainerId].speechLost); } else { trainerId = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].id; - FrontierSpeechToString(gApprentices[trainerId].easyChatWords); + FrontierSpeechToString(gApprentices[trainerId].speechLost); } } break; @@ -1827,7 +1828,7 @@ void sub_81A3ACC(void) gSaveBlock2Ptr->frontier.trainerIds[i] = 0xFFFF; } -static void sub_81A3B00(void) +static void IsTrainerFrontierBrain(void) { if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN) gSpecialVar_Result = TRUE; @@ -1900,13 +1901,13 @@ static void sub_81A3B64(void) gSaveBlock2Ptr->frontier.field_EBA = points; } -static void sub_81A3D30(void) +static void GetFacilitySymbolCount(void) { s32 facility = VarGet(VAR_FRONTIER_FACILITY); gSpecialVar_Result = GetPlayerSymbolCountForFacility(facility); } -static void sub_81A3D58(void) +static void GiveFacilitySymbol(void) { s32 facility = VarGet(VAR_FRONTIER_FACILITY); if (GetPlayerSymbolCountForFacility(facility) == 0) @@ -1915,7 +1916,7 @@ static void sub_81A3D58(void) FlagSet(FLAG_SYS_TOWER_GOLD + facility * 2); } -static void sub_81A3DA0(void) +static void CheckBattleTypeFlag(void) { if (gBattleTypeFlags & gSpecialVar_0x8005) gSpecialVar_Result = TRUE; @@ -2087,7 +2088,7 @@ static void sub_81A3FD4(void) } } -static void sub_81A4224(void) +static void ValidateVisitingTrainer(void) { ValidateEReaderTrainer(); } @@ -2160,7 +2161,7 @@ static void sub_81A4410(void) gSaveBlock2Ptr->frontier.field_CA9_b = 1; } -static void sub_81A443C(void) +static void BufferFrontierTrainerName(void) { switch (gSpecialVar_0x8005) { @@ -2198,7 +2199,7 @@ static void sub_81A447C(void) } } -static void sub_81A457C(void) +static void SetFacilityBrainEventObject(void) { SetFrontierBrainEventObjGfx(VarGet(VAR_FRONTIER_FACILITY)); } @@ -2219,8 +2220,8 @@ static void Print1PRecord(s32 position, s32 x, s32 y, struct RankingHall1P *hall if (winStreak > 9999) winStreak = 9999; ConvertIntToDecimalStringN(gStringVar2, winStreak, STR_CONV_MODE_RIGHT_ALIGN, 4); - StringExpandPlaceholders(gStringVar4, gHallFacilityToRecordsText[hallFacilityId]); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, GetStringRightAlignXOffset(1, gHallFacilityToRecordsText[hallFacilityId], 0xC8), (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); + StringExpandPlaceholders(gStringVar4, sHallFacilityToRecordsText[hallFacilityId]); + AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, GetStringRightAlignXOffset(1, sHallFacilityToRecordsText[hallFacilityId], 0xC8), (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); } } @@ -2246,8 +2247,8 @@ static void Print2PRecord(s32 position, s32 x, s32 y, struct RankingHall2P *hall if (winStreak > 9999) winStreak = 9999; ConvertIntToDecimalStringN(gStringVar2, winStreak, STR_CONV_MODE_RIGHT_ALIGN, 4); - StringExpandPlaceholders(gStringVar4, gHallFacilityToRecordsText[9]); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, GetStringRightAlignXOffset(1, gHallFacilityToRecordsText[9], 0xC8), (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); + StringExpandPlaceholders(gStringVar4, sHallFacilityToRecordsText[RANKING_HALL_BATTLE_TOWER_LINK]); + AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, GetStringRightAlignXOffset(1, sHallFacilityToRecordsText[RANKING_HALL_BATTLE_TOWER_LINK], 0xC8), (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); } } @@ -2326,12 +2327,12 @@ static void PrintHallRecords(s32 hallFacilityId, s32 lvlMode) struct RankingHall1P records1P[3]; struct RankingHall2P records2P[3]; - StringCopy(gStringVar1, gUnknown_08611CB0[hallFacilityId][0]); - StringExpandPlaceholders(gStringVar4, gUnknown_08611CB0[hallFacilityId][1]); + StringCopy(gStringVar1, sRecordsWindowChallengeTexts[hallFacilityId][0]); + StringExpandPlaceholders(gStringVar4, sRecordsWindowChallengeTexts[hallFacilityId][1]); AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL); - x = GetStringRightAlignXOffset(1, gLevelModeText[lvlMode], 0xD0); - AddTextPrinterParameterized(gRecordsWindowId, 1, gLevelModeText[lvlMode], x, 1, TEXT_SPEED_FF, NULL); - if (hallFacilityId == HALL_FACILITIES_COUNT) + x = GetStringRightAlignXOffset(1, sLevelModeText[lvlMode], 0xD0); + AddTextPrinterParameterized(gRecordsWindowId, 1, sLevelModeText[lvlMode], x, 1, TEXT_SPEED_FF, NULL); + if (hallFacilityId == RANKING_HALL_BATTLE_TOWER_LINK) { gSaveBlock2Ptr->frontier.opponentName[0][PLAYER_NAME_LENGTH] = EOS; gSaveBlock2Ptr->frontier.opponentName[1][PLAYER_NAME_LENGTH] = EOS; diff --git a/src/graphics.c b/src/graphics.c index 22478a7b6..82765e913 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -960,7 +960,7 @@ const u32 gUnknown_08D778F0[] = INCBIN_U32("graphics/battle_transitions/vs_frame const u32 gUnknown_08D779D8[] = INCBIN_U32("graphics/battle_transitions/vs_frame.bin.lz"); const u32 gUnknown_08D77AE4[] = INCBIN_U32("graphics/battle_transitions/vs_frame.gbapal.lz"); -const u32 gUnknown_08D77B0C[] = INCBIN_U32("graphics/battle_transitions/vs.4bpp.lz"); +const u32 gVsLettersGfx[] = INCBIN_U32("graphics/battle_transitions/vs.4bpp.lz"); #include "data/graphics/battle_terrain.h" @@ -987,7 +987,7 @@ const u32 gUnknown_08D854C8[] = INCBIN_U32("graphics/battle_frontier/options_pal const u32 gBattleArenaJudgementSymbolsGfx[] = INCBIN_U32("graphics/battle_frontier/arena_judgement_symbols.4bpp.lz"); const u32 gBattleArenaJudgementSymbolsPalette[] = INCBIN_U32("graphics/battle_frontier/arena_judgement_symbols.gbapal.lz"); -const u32 gUnknown_08D85600[] = INCBIN_U32("graphics/battle_frontier/text.gbapal.lz"); +const u32 gBattleWindowTextPalette[] = INCBIN_U32("graphics/battle_interface/text.gbapal.lz"); const u16 gUnknown_08D85620[] = INCBIN_U16("graphics/battle_frontier/text_pp.gbapal"); const u16 gTilesetAnims_BattleDomePals0_0[] = INCBIN_U16("graphics/battle_frontier/dome_anim1.gbapal"); @@ -1138,9 +1138,9 @@ const u32 gBattleAnimSpritePal_Slash2[] = INCBIN_U32("graphics/battle_anims/spri const u32 gBattleAnimSpriteGfx_WhiteShadow[] = INCBIN_U32("graphics/battle_anims/sprites/white_shadow.4bpp.lz"); const u32 gBattleAnimSpritePal_WhiteShadow[] = INCBIN_U32("graphics/battle_anims/sprites/white_shadow.gbapal.lz"); -const u32 gPartyMenuMisc_Gfx[] = INCBIN_U32("graphics/interface/party_menu_misc.4bpp.lz"); -const u32 gPartyMenuMisc_Pal[] = INCBIN_U32("graphics/interface/party_menu_misc.gbapal.lz"); -const u32 gPartyMenuMisc_Tilemap[] = INCBIN_U32("graphics/interface/party_menu_misc.bin.lz"); +const u32 gPartyMenuBg_Gfx[] = INCBIN_U32("graphics/interface/party_menu_bg.4bpp.lz"); +const u32 gPartyMenuBg_Pal[] = INCBIN_U32("graphics/interface/party_menu_bg.gbapal.lz"); +const u32 gPartyMenuBg_Tilemap[] = INCBIN_U32("graphics/interface/party_menu_bg.bin.lz"); const u32 gPartyMenuPokeball_Gfx[] = INCBIN_U32("graphics/interface/party_menu_pokeball.4bpp.lz"); const u32 gPartyMenuPokeballSmall_Gfx[] = INCBIN_U32("graphics/interface/party_menu_pokeball_small.4bpp.lz"); //unused diff --git a/src/image_processing_effects.c b/src/image_processing_effects.c new file mode 100644 index 000000000..13794faf0 --- /dev/null +++ b/src/image_processing_effects.c @@ -0,0 +1,1226 @@ +#include "global.h" +#include "image_processing_effects.h" +#include "contest_painting.h" +#include "constants/rgb.h" + +// IWRAM common +u8 gCanvasColumnStart; +u16 (*gCanvasPixels)[][32]; +u8 gCanvasRowEnd; +u8 gCanvasHeight; +u8 gCanvasColumnEnd; +u8 gCanvasRowStart; +u8 gCanvasMonPersonality; +u8 gCanvasWidth; +u16 *gCanvasPalette; +u16 gCanvasPaletteStart; + +static void ApplyImageEffect_Pointillism(void); +static void ApplyImageEffect_Blur(void); +static void ApplyImageEffect_BlackOutline(void); +static void ApplyImageEffect_Invert(void); +static void ApplyImageEffect_BlackAndWhite(void); +static void ApplyImageEffect_BlurRight(void); +static void ApplyImageEffect_BlurDown(void); +static void ApplyImageEffect_Shimmer(void); +static void ApplyImageEffect_Grayscale(void); +static void ApplyImageEffect_PersonalityColor(u8); +static void ApplyImageEffect_RedChannelGrayscale(u8); +static void ApplyImageEffect_RedChannelGrayscaleHighlight(u8); +static void AddPointillismPoints(u16); +static u16 ConvertColorToGrayscale(u16*); +static u16 QuantizePixel_Blur(u16*, u16*, u16*); +static u16 QuantizePixel_PersonalityColor(u16*, u8); +static u16 QuantizePixel_BlackAndWhite(u16*); +static u16 QuantizePixel_BlackOutline(u16*, u16*); +static u16 QuantizePixel_Invert(u16*); +static u16 QuantizePixel_BlurHard(u16*, u16*, u16*); +static u16 QuantizePixel_MotionBlur(u16*, u16*); +static u16 GetColorFromPersonality(u8); +static void QuantizePalette_Standard(bool8); +static void SetPresetPalette_PrimaryColors(void); +static void QuantizePalette_PrimaryColors(void); +static void SetPresetPalette_Grayscale(void); +static void QuantizePalette_Grayscale(void); +static void SetPresetPalette_GrayscaleSmall(void); +static void QuantizePalette_GrayscaleSmall(void); +static void SetPresetPalette_BlackAndWhite(void); +static void QuantizePalette_BlackAndWhite(void); +static u16 QuantizePixel_Standard(u16*); +static u16 QuantizePixel_GrayscaleSmall(u16*); +static u16 QuantizePixel_Grayscale(u16*); +static u16 QuantizePixel_PrimaryColors(u16*); + +extern const u8 gPointillismPoints[][3]; + +void ApplyImageProcessingEffects(struct ImageProcessingContext *context) +{ + gCanvasPixels = context->canvasPixels; + gCanvasMonPersonality = context->personality; + gCanvasColumnStart = context->columnStart; + gCanvasRowStart = context->rowStart; + gCanvasColumnEnd = context->columnEnd; + gCanvasRowEnd = context->rowEnd; + gCanvasWidth = context->canvasWidth; + gCanvasHeight = context->canvasHeight; + + switch (context->effect) + { + case IMAGE_EFFECT_POINTILLISM: + ApplyImageEffect_Pointillism(); + break; + case IMAGE_EFFECT_BLUR: + ApplyImageEffect_Blur(); + break; + case IMAGE_EFFECT_OUTLINE_COLORED: + ApplyImageEffect_BlackOutline(); + ApplyImageEffect_PersonalityColor(gCanvasMonPersonality); + break; + case IMAGE_EFFECT_INVERT_BLACK_WHITE: + ApplyImageEffect_BlackOutline(); + ApplyImageEffect_Invert(); + ApplyImageEffect_BlackAndWhite(); + case IMAGE_EFFECT_INVERT: + ApplyImageEffect_Invert(); + break; + case IMAGE_EFFECT_THICK_BLACK_WHITE: + ApplyImageEffect_BlackOutline(); + ApplyImageEffect_BlurRight(); + ApplyImageEffect_BlurRight(); + ApplyImageEffect_BlurDown(); + ApplyImageEffect_BlackAndWhite(); + break; + case IMAGE_EFFECT_SHIMMER: + ApplyImageEffect_Shimmer(); + break; + case IMAGE_EFFECT_OUTLINE: + ApplyImageEffect_BlackOutline(); + break; + case IMAGE_EFFECT_BLUR_RIGHT: + ApplyImageEffect_BlurRight(); + break; + case IMAGE_EFFECT_BLUR_DOWN: + ApplyImageEffect_BlurDown(); + break; + case IMAGE_EFFECT_GRAYSCALE_LIGHT: + ApplyImageEffect_Grayscale(); + ApplyImageEffect_RedChannelGrayscale(3); + break; + case IMAGE_EFFECT_CHARCOAL: + ApplyImageEffect_BlackOutline(); + ApplyImageEffect_BlurRight(); + ApplyImageEffect_BlurDown(); + ApplyImageEffect_BlackAndWhite(); + ApplyImageEffect_Blur(); + ApplyImageEffect_Blur(); + ApplyImageEffect_RedChannelGrayscale(2); + ApplyImageEffect_RedChannelGrayscaleHighlight(4); + break; + } +} + +static void ApplyImageEffect_RedChannelGrayscale(u8 delta) +{ + u8 i, j; + + for (j = 0; j < gCanvasRowEnd; j++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart]; + for (i = 0; i < gCanvasColumnEnd; i++, pixel++) + { + if (!(0x8000 & *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); + grayValue += delta; + if (grayValue > 31) + grayValue = 31; + + *pixel = RGB2(grayValue, grayValue, grayValue); + } + } + } +} + +static void ApplyImageEffect_RedChannelGrayscaleHighlight(u8 highlight) +{ + u8 i, j; + + for (j = 0; j < gCanvasRowEnd; j++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart]; + for (i = 0; i < gCanvasColumnEnd; i++, pixel++) + { + if (!(0x8000 & *pixel)) + { + u8 grayValue = (31 & *pixel); + if (grayValue > 31 - highlight) + grayValue = 31 - (highlight >> 1); + + *pixel = RGB2(grayValue, grayValue, grayValue); + } + } + } +} + +static void ApplyImageEffect_Pointillism(void) +{ + u32 i; + for (i = 0; i < 3200; i++) + AddPointillismPoints(i); +} + +static void ApplyImageEffect_Grayscale(void) +{ + u8 i, j; + + for (j = 0; j < gCanvasRowEnd; j++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart]; + for (i = 0; i < gCanvasColumnEnd; i++, pixel++) + { + if (!(0x8000 & *pixel)) + *pixel = ConvertColorToGrayscale(pixel); + } + } +} + +static void ApplyImageEffect_Blur(void) +{ + u8 i, j; + + for (i = 0; i < gCanvasColumnEnd; i++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][gCanvasRowStart * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart + i]; + u16 prevPixel = *pixel; + + j = 1; + pixel += gCanvasWidth; + while (j < gCanvasRowEnd - 1) + { + if (!(0x8000 & *pixel)) + { + *pixel = QuantizePixel_Blur(&prevPixel, pixel, pixel + gCanvasWidth); + prevPixel = *pixel; + } + + j++; + pixel += gCanvasWidth; + } + } +} + +static void ApplyImageEffect_PersonalityColor(u8 personality) +{ + u8 i, j; + + for (j = 0; j < gCanvasRowEnd; j++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart]; + for (i = 0; i < gCanvasColumnEnd; i++, pixel++) + { + if (!(0x8000 & *pixel)) + *pixel = QuantizePixel_PersonalityColor(pixel, personality); + } + } +} + +static void ApplyImageEffect_BlackAndWhite(void) +{ + u8 i, j; + + for (j = 0; j < gCanvasRowEnd; j++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart]; + for (i = 0; i < gCanvasColumnEnd; i++, pixel++) + { + if (!(0x8000 & *pixel)) + *pixel = QuantizePixel_BlackAndWhite(pixel); + } + } +} + +static void ApplyImageEffect_BlackOutline(void) +{ + u8 i, j; + u16 *pixel; + + // Handle top row of pixels first. + for (j = 0; j < gCanvasRowEnd; j++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth]; + pixel = &pixelRow[gCanvasColumnStart]; + *pixel = QuantizePixel_BlackOutline(pixel, pixel + 1); + for (i = 1, pixel++; i < gCanvasColumnEnd - 1; i++, pixel++) + { + *pixel = QuantizePixel_BlackOutline(pixel, pixel + 1); + *pixel = QuantizePixel_BlackOutline(pixel, pixel - 1); + } + + *pixel = QuantizePixel_BlackOutline(pixel, pixel - 1); + } + + // Handle each column from left to right. + for (i = 0; i < gCanvasColumnEnd; i++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][gCanvasRowStart * gCanvasWidth]; + pixel = &pixelRow[gCanvasColumnStart + i]; + *pixel = QuantizePixel_BlackOutline(pixel, pixel + gCanvasWidth); + for (j = 1, pixel += gCanvasWidth; j < gCanvasRowEnd - 1; j++, pixel += gCanvasWidth) + { + *pixel = QuantizePixel_BlackOutline(pixel, pixel + gCanvasWidth); + *pixel = QuantizePixel_BlackOutline(pixel, pixel - gCanvasWidth); + } + + *pixel = QuantizePixel_BlackOutline(pixel, pixel - gCanvasWidth); + } +} + +static void ApplyImageEffect_Invert(void) +{ + u8 i, j; + + for (j = 0; j < gCanvasRowEnd; j++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart]; + for (i = 0; i < gCanvasColumnEnd; i++, pixel++) + { + if (!(0x8000 & *pixel)) + *pixel = QuantizePixel_Invert(pixel); + } + } +} + +static void ApplyImageEffect_Shimmer(void) +{ + u8 i, j; + u16 *pixel; + u16 prevPixel; + + // First, invert all of the colors. + pixel = (*gCanvasPixels)[0]; + for (i = 0; i < 64; i++) + { + for (j = 0; j < 64; j++, pixel++) + { + if (!(0x8000 & *pixel)) + *pixel = QuantizePixel_Invert(pixel); + } + } + + // Blur the pixels twice. + for (j = 0; j < 64; j++) + { + pixel = &(*gCanvasPixels)[0][j]; + prevPixel = *pixel; + *pixel = 0x8000; + for (i = 1, pixel += 64; i < 63; i++, pixel += 64) + { + if (!(0x8000 & *pixel)) + { + *pixel = QuantizePixel_BlurHard(&prevPixel, pixel, pixel + 64); + prevPixel = *pixel; + } + } + + *pixel = 0x8000; + pixel = &(*gCanvasPixels)[0][j]; + prevPixel = *pixel; + *pixel = 0x8000; + for (i = 1, pixel += 64; i < 63; i++, pixel += 64) + { + if (!(0x8000 & *pixel)) + { + *pixel = QuantizePixel_BlurHard(&prevPixel, pixel, pixel + 64); + prevPixel = *pixel; + } + } + + *pixel = 0x8000; + } + + // Finally, invert colors back to the original color space. + // The above blur causes the outline areas to darken, which makes + // this inversion give the effect of light outlines. + pixel = (*gCanvasPixels)[0]; + for (i = 0; i < 64; i++) + { + for (j = 0; j < 64; j++, pixel++) + { + if (!(0x8000 & *pixel)) + *pixel = QuantizePixel_Invert(pixel); + } + } +} + +static void ApplyImageEffect_BlurRight(void) +{ + u8 i, j; + + for (j = 0; j < gCanvasRowEnd; j++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart]; + u16 prevPixel = *pixel; + for (i = 1, pixel++; i < gCanvasColumnEnd - 1; i++, pixel++) + { + if (!(0x8000 & *pixel)) + { + *pixel = QuantizePixel_MotionBlur(&prevPixel, pixel); + prevPixel = *pixel; + } + } + } +} + +static void ApplyImageEffect_BlurDown(void) +{ + u8 i, j; + + for (i = 0; i < gCanvasColumnEnd; i++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][gCanvasRowStart * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart + i]; + u16 prevPixel = *pixel; + for (j = 1, pixel += gCanvasWidth; j < gCanvasRowEnd - 1; j++, pixel += gCanvasWidth) + { + if (!(0x8000 & *pixel)) + { + *pixel = QuantizePixel_MotionBlur(&prevPixel, pixel); + prevPixel = *pixel; + } + } + } +} + +struct PointillismPoint +{ + u8 column; + u8 row; + u16 delta; +}; + +static void AddPointillismPoints(u16 arg0) +{ + u8 i; + bool8 offsetDownLeft; + u8 colorType; + struct PointillismPoint points[6]; + + points[0].column = gPointillismPoints[arg0][0]; + points[0].row = gPointillismPoints[arg0][1]; + points[0].delta = (gPointillismPoints[arg0][2] >> 3) & 7; + + colorType = (gPointillismPoints[arg0][2] >> 1) & 3; + offsetDownLeft = gPointillismPoints[arg0][2] & 1; + for (i = 1; i < points[0].delta; i++) + { + if (!offsetDownLeft) + { + points[i].column = points[0].column - i; + points[i].row = points[0].row + i; + } + else + { + points[i].column = points[0].column + 1; + points[i].row = points[0].row - 1; + } + + if (points[i].column > 63 || points[i].row > 63) + { + points[0].delta = i - 1; + break; + } + + points[i].delta = points[0].delta - i; + } + + for (i = 0; i < points[0].delta; i++) + { + u16 *pixel = &(*gCanvasPixels)[points[i].row * 2][points[i].column]; + + if (!(0x8000 & *pixel)) + { + u16 red = (*pixel) & 0x1F; + u16 green = (*pixel >> 5) & 0x1F; + u16 blue = (*pixel >> 10) & 0x1F; + + switch (colorType) + { + case 0: + case 1: + switch (((gPointillismPoints[arg0][2] >> 3) & 7) % 3) + { + case 0: + if (red >= points[i].delta) + red -= points[i].delta; + else + red = 0; + break; + case 1: + if (green >= points[i].delta) + green -= points[i].delta; + else + green = 0; + break; + case 2: + if (blue >= points[i].delta) + blue -= points[i].delta; + else + blue = 0; + break; + } + break; + case 2: + case 3: + red += points[i].delta; + green += points[i].delta; + blue += points[i].delta; + if (red > 31) + red = 31; + if (green > 31) + green = 31; + if (blue > 31) + blue = 31; + break; + } + + *pixel = RGB2(red, green, blue); + } + } +} + +static u16 ConvertColorToGrayscale(u16 *color) +{ + s32 clr = *color; + s32 r = clr & 0x1F; + s32 g = (clr >> 5) & 0x1F; + s32 b = (clr >> 10) & 0x1F; + 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); +} + +// The dark colors are the colored edges of the Cool painting effect. +// 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; + + if (red < 17 && green < 17 && blue < 17) + return GetColorFromPersonality(personality); + else + return RGB_WHITE; +} + +// Based on the given value, which comes from the first 8 bits of +// the mon's personality value, return a color. +static u16 GetColorFromPersonality(u8 personality) +{ + u16 red = 0; + u16 green = 0; + u16 blue = 0; + u8 strength = (personality / 6) % 3; + u8 colorType = personality % 6; + + switch (colorType) + { + case 0: + // Teal color + green = 21 - strength; + blue = green; + red = 0; + break; + case 1: + // Yellow color + blue = 0; + red = 21 - strength; + green = red; + break; + case 2: + // Purple color + blue = 21 - strength; + green = 0; + red = blue; + break; + case 3: + // Red color + blue = 0; + green = 0; + red = 23 - strength; + break; + case 4: + // Blue color + blue = 23 - strength; + green = 0; + red = 0; + break; + case 5: + // Green color + blue = 0; + green = 23 - strength; + red = 0; + break; + } + + return RGB2(red, green, blue); +} + +static u16 QuantizePixel_BlackAndWhite(u16 *color) +{ + u16 red = *color & 0x1F; + u16 green = (*color >> 5) & 0x1F; + u16 blue = (*color >> 10) & 0x1F; + + if (red < 17 && green < 17 && blue < 17) + return RGB_BLACK; + else + return RGB_WHITE; +} + +static u16 QuantizePixel_BlackOutline(u16 *pixelA, u16 *pixelB) +{ + if (*pixelA != RGB_BLACK) + { + if (*pixelA & 0x8000) + return 0x8000; + if (*pixelB & 0x8000) + return RGB_BLACK; + + return *pixelA; + } + + return RGB_BLACK; +} + +static u16 QuantizePixel_Invert(u16 *color) +{ + u16 red = *color & 0x1F; + u16 green = (*color >> 5) & 0x1F; + u16 blue = (*color >> 10) & 0x1F; + + red = 31 - red; + green = 31 - green; + blue = 31 - blue; + + return RGB2(red, green, blue); +} + +static u16 QuantizePixel_MotionBlur(u16 *prevPixel, u16 *curPixel) +{ + u16 pixelChannels[2][3]; + u16 diffs[3]; + u8 i; + u16 largestDiff; + u16 red, green, blue; + + 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; + + // Don't blur light colors. + if (pixelChannels[0][0] > 25 && pixelChannels[0][1] > 25 && pixelChannels[0][2] > 25) + return *curPixel; + if (pixelChannels[1][0] > 25 && pixelChannels[1][1] > 25 && pixelChannels[1][2] > 25) + return *curPixel; + + for (i = 0; i < 3; i++) + { + if (pixelChannels[0][i] > pixelChannels[1][i]) + diffs[i] = pixelChannels[0][i] - pixelChannels[1][i]; + else + diffs[i] = pixelChannels[1][i] - pixelChannels[0][i]; + } + + // Find the largest diff of any of the color channels. + if (diffs[0] >= diffs[1]) + { + if (diffs[0] >= diffs[2]) + largestDiff = diffs[0]; + else if (diffs[1] >= diffs[2]) + largestDiff = diffs[1]; + else + largestDiff = diffs[2]; + } + else + { + if (diffs[1] >= diffs[2]) + largestDiff = diffs[1]; + else if (diffs[2] >= diffs[0]) + largestDiff = diffs[2]; + else + largestDiff = diffs[0]; + } + + red = (pixelChannels[1][0] * (31 - largestDiff / 2)) / 31; + green = (pixelChannels[1][1] * (31 - largestDiff / 2)) / 31; + blue = (pixelChannels[1][2] * (31 - largestDiff / 2)) / 31; + return RGB2(red, green, blue); +} + +static u16 QuantizePixel_Blur(u16 *prevPixel, u16 *curPixel, u16 *nextPixel) +{ + u16 red, green, blue; + u16 prevAvg, curAvg, nextAvg; + u16 prevDiff, nextDiff; + u32 diff; + u16 factor; + + 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; + + if (prevAvg == curAvg && nextAvg == curAvg) + return *curPixel; + + if (prevAvg > curAvg) + prevDiff = prevAvg - curAvg; + else + prevDiff = curAvg - prevAvg; + + if (nextAvg > curAvg) + nextDiff = nextAvg - curAvg; + else + nextDiff = curAvg - nextAvg; + + if (prevDiff >= nextDiff) + diff = prevDiff; + else + diff = nextDiff; + + factor = 31 - diff / 2; + red = (red * factor) / 31; + green = (green * factor) / 31; + blue = (blue * factor) / 31; + return RGB2(red, green, blue); +} + +static u16 QuantizePixel_BlurHard(u16 *prevPixel, u16 *curPixel, u16 *nextPixel) +{ + u16 red, green, blue; + u16 prevAvg, curAvg, nextAvg; + u16 prevDiff, nextDiff; + u32 diff; + u16 factor; + + 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; + + if (prevAvg == curAvg && nextAvg == curAvg) + return *curPixel; + + if (prevAvg > curAvg) + prevDiff = prevAvg - curAvg; + else + prevDiff = curAvg - prevAvg; + + if (nextAvg > curAvg) + nextDiff = nextAvg - curAvg; + else + nextDiff = curAvg - nextAvg; + + if (prevDiff >= nextDiff) + diff = prevDiff; + else + diff = nextDiff; + + factor = 31 - diff; + red = (red * factor) / 31; + green = (green * factor) / 31; + blue = (blue * factor) / 31; + return RGB2(red, green, blue); +} + +void ConvertImageProcessingToGBA(struct ImageProcessingContext *context) +{ + u16 i, j, k; + u16 *src, *dest, *src_, *dest_; + u16 width, height; + + width = context->canvasWidth >> 3; + height = context->canvasHeight >> 3; + src_ = context->canvasPixels; + dest_ = context->dest; + + if (context->var_16 == 2) + { + for (i = 0; i < height; i++) + { + for (j = 0; j < width; j++) + { + for (k = 0; k < 8; k++) + { + dest = dest_ + ((i * width + j) << 5) + (k << 2); + src = src_ + ((((i << 3) + k) << 3) * width) + (j << 3); + + dest[0] = src[0] | (src[1] << 8); + dest[1] = src[2] | (src[3] << 8); + dest[2] = src[4] | (src[5] << 8); + dest[3] = src[6] | (src[7] << 8); + } + } + } + } + else + { + for (i = 0; i < height; i++) + { + for (j = 0; j < width; j++) + { + for (k = 0; k < 8; k++) + { + dest = dest_ + ((i * width + j) << 4) + (k << 1); + src = src_ + ((((i << 3) + k) << 3) * width) + (j << 3); + + dest[0] = src[0] | (src[1] << 4) | (src[2] << 8) | (src[3] << 0xC); + dest[1] = src[4] | (src[5] << 4) | (src[6] << 8) | (src[7] << 0xC); + } + } + } + } +} + +void ApplyImageProcessingQuantization(struct ImageProcessingContext *context) +{ + gCanvasPaletteStart = context->paletteStart * 16; + gCanvasPalette = &context->canvasPalette[gCanvasPaletteStart]; + gCanvasPixels = context->canvasPixels; + gCanvasColumnStart = context->columnStart; + gCanvasRowStart = context->rowStart; + gCanvasColumnEnd = context->columnEnd; + gCanvasRowEnd = context->rowEnd; + gCanvasWidth = context->canvasWidth; + gCanvasHeight = context->canvasHeight; + + switch (context->quantizeEffect) + { + case QUANTIZE_EFFECT_STANDARD: + QuantizePalette_Standard(FALSE); + break; + case QUANTIZE_EFFECT_STANDARD_LIMITED_COLORS: + QuantizePalette_Standard(TRUE); + break; + case QUANTIZE_EFFECT_PRIMARY_COLORS: + SetPresetPalette_PrimaryColors(); + QuantizePalette_PrimaryColors(); + break; + case QUANTIZE_EFFECT_GRAYSCALE: + SetPresetPalette_Grayscale(); + QuantizePalette_Grayscale(); + break; + case QUANTIZE_EFFECT_GRAYSCALE_SMALL: + SetPresetPalette_GrayscaleSmall(); + QuantizePalette_GrayscaleSmall(); + break; + case QUANTIZE_EFFECT_BLACK_WHITE: + SetPresetPalette_BlackAndWhite(); + QuantizePalette_BlackAndWhite(); + break; + } +} + +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); +} + +static void SetPresetPalette_BlackAndWhite(void) +{ + gCanvasPalette[0] = RGB2(0, 0, 0); + gCanvasPalette[1] = RGB2(0, 0, 0); + gCanvasPalette[2] = RGB2(31, 31, 31); +} + +static void SetPresetPalette_GrayscaleSmall(void) +{ + u8 i; + + gCanvasPalette[0] = RGB2(0, 0, 0); + gCanvasPalette[1] = RGB2(0, 0, 0); + for (i = 0; i < 14; i++) + gCanvasPalette[i + 2] = RGB2(2 * (i + 2), 2 * (i + 2), 2 * (i + 2)); +} + +static void SetPresetPalette_Grayscale(void) +{ + u8 i; + + gCanvasPalette[0] = RGB2(0, 0, 0); + for (i = 0; i < 32; i++) + gCanvasPalette[i + 1] = RGB2(i, i, i); +} + +static void QuantizePalette_Standard(bool8 useLimitedPalette) +{ + u8 i, j; + u16 maxIndex; + + maxIndex = 0xDF; + if (!useLimitedPalette) + maxIndex = 0xFF; + + for (i = 0; i < maxIndex; i++) + gCanvasPalette[i] = RGB_BLACK; + + gCanvasPalette[maxIndex] = RGB2(15, 15, 15); + for (j = 0; j < gCanvasRowEnd; j++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart]; + for (i = 0; i < gCanvasColumnEnd; i++, pixel++) + { + if (*pixel & 0x8000) + { + *pixel = gCanvasPaletteStart; + } + else + { + u16 quantizedColor = QuantizePixel_Standard(pixel); + u8 curIndex = 1; + if (curIndex < maxIndex) + { + if (gCanvasPalette[curIndex] == RGB_BLACK) + { + // The quantized color does not match any existing color in the + // palette, so we add it to the palette. + // This if block seems pointless because the below while loop handles + // this same logic. + gCanvasPalette[curIndex] = quantizedColor; + *pixel = gCanvasPaletteStart + curIndex; + } + else + { + while (curIndex < maxIndex) + { + if (gCanvasPalette[curIndex] == RGB_BLACK) + { + // The quantized color does not match any existing color in the + // palette, so we add it to the palette. + gCanvasPalette[curIndex] = quantizedColor; + *pixel = gCanvasPaletteStart + curIndex; + break; + } + + if (gCanvasPalette[curIndex] == quantizedColor) + { + // The quantized color matches this existing color in the + // palette, so we use this existing color for the pixel. + *pixel = gCanvasPaletteStart + curIndex; + break; + } + + curIndex++; + } + } + } + + if (curIndex == maxIndex) + { + // The entire palette's colors are already in use, which means + // the base image has too many colors to handle. This error is handled + // by marking such pixels as gray color. + curIndex = maxIndex; + *pixel = curIndex; + } + } + } + } +} + +static void QuantizePalette_BlackAndWhite(void) +{ + u8 i, j; + + for (j = 0; j < gCanvasRowEnd; j++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart]; + for (i = 0; i < gCanvasColumnEnd; i++, pixel++) + { + if (*pixel & 0x8000) + { + *pixel = gCanvasPaletteStart; + } + else + { + if (QuantizePixel_BlackAndWhite(pixel) == RGB_BLACK) + { + // Black is the first color in the quantized palette. + *pixel = gCanvasPaletteStart + 1; + } + else + { + // White is the second color in the quantized palette. + *pixel = gCanvasPaletteStart + 2; + } + } + } + } +} + +static void QuantizePalette_GrayscaleSmall(void) +{ + u8 i, j; + + for (j = 0; j < gCanvasRowEnd; j++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart]; + for (i = 0; i < gCanvasColumnEnd; i++, pixel++) + { + if (*pixel & 0x8000) + *pixel = gCanvasPaletteStart; + else + *pixel = QuantizePixel_GrayscaleSmall(pixel) + gCanvasPaletteStart; + } + } +} + +static void QuantizePalette_Grayscale(void) +{ + u8 i, j; + + for (j = 0; j < gCanvasRowEnd; j++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart]; + for (i = 0; i < gCanvasColumnEnd; i++, pixel++) + { + if (*pixel & 0x8000) + *pixel = gCanvasPaletteStart; + else + *pixel = QuantizePixel_Grayscale(pixel) + gCanvasPaletteStart; + } + } +} + +static void QuantizePalette_PrimaryColors(void) +{ + u8 i, j; + + for (j = 0; j < gCanvasRowEnd; j++) + { + u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth]; + u16 *pixel = &pixelRow[gCanvasColumnStart]; + for (i = 0; i < gCanvasColumnEnd; i++, pixel++) + { + if (*pixel & 0x8000) + *pixel = gCanvasPaletteStart; + else + *pixel = QuantizePixel_PrimaryColors(pixel) + gCanvasPaletteStart; + } + } +} + +// 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; + + // Quantize color channels to muliples of 4, rounding up. + if (red & 3) + red = (red & 0x1C) + 4; + if (green & 3) + green = (green & 0x1C) + 4; + if (blue & 3) + blue = (blue & 0x1C) + 4; + + // Clamp channels to [6, 30]. + if (red < 6) + red = 6; + if (red > 30) + red = 30; + if (green < 6) + green = 6; + if (green > 30) + green = 30; + if (blue < 6) + blue = 6; + if (blue > 30) + blue = 30; + + return RGB2(red, green, blue); +} + +static u16 QuantizePixel_PrimaryColors(u16* color) +{ + u16 red = *color & 0x1F; + u16 green = (*color >> 5) & 0x1F; + u16 blue = (*color >> 10) & 0x1F; + + if (red < 12 && green < 11 && blue < 11) + return 1; + + if (red > 19 && green > 19 && blue > 19) + return 2; + + if (red > 19) + { + if (green > 19) + { + if (blue > 14) + return 2; + else + return 7; + } + else if (blue > 19) + { + if (green > 14) + return 2; + else + return 8; + } + } + + if (green > 19 && blue > 19) + { + if (red > 14) + return 2; + else + return 9; + } + + if (red > 19) + { + if (green > 11) + { + if (blue > 11) + { + if (green < blue) + return 8; + else + return 7; + } + else + { + return 10; + } + } + else if (blue > 11) + { + return 13; + } + else + { + return 4; + } + } + + if (green > 19) + { + if (red > 11) + { + if (blue > 11) + { + if (red < blue) + return 9; + else + return 7; + } + else + { + return 11; + } + } + else + { + if (blue > 11) + return 14; + else + return 5; + } + } + + if (blue > 19) + { + if (red > 11) + { + if (green > 11) + { + if (red < green) + return 9; + else + return 8; + } + } + else if (green > 11) + { + return 12; + } + + if (blue > 11) + return 15; + else + return 6; + } + + return 3; +} + +static u16 QuantizePixel_GrayscaleSmall(u16 *color) +{ + u16 red = *color & 0x1F; + u16 green = (*color >> 5) & 0x1F; + u16 blue = (*color >> 10) & 0x1F; + u16 average = ((red + green + blue) / 3) & 0x1E; + if (average == 0) + return 1; + else + return average / 2; +} + +static u16 QuantizePixel_Grayscale(u16 *color) +{ + u16 red = *color & 0x1F; + u16 green = (*color >> 5) & 0x1F; + u16 blue = (*color >> 10) & 0x1F; + u16 average = (red + green + blue) / 3; + return average + 1; +} diff --git a/src/item.c b/src/item.c index 6b8f51f12..7b8b37c06 100644 --- a/src/item.c +++ b/src/item.c @@ -142,7 +142,7 @@ bool8 CheckBagHasItem(u16 itemId, u16 count) if (ItemId_GetPocket(itemId) == 0) return FALSE; - if (InBattlePyramid() || FlagGet(FLAG_SPECIAL_FLAG_0x4004) == TRUE) + if (InBattlePyramid() || FlagGet(FLAG_STORING_ITEMS_IN_PYRAMID_BAG) == TRUE) return CheckPyramidBagHasItem(itemId, count); pocket = ItemId_GetPocket(itemId) - 1; // Check for item slots that contain the item @@ -189,7 +189,7 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count) if (ItemId_GetPocket(itemId) == POCKET_NONE) return FALSE; - if (InBattlePyramid() || FlagGet(FLAG_SPECIAL_FLAG_0x4004) == TRUE) + if (InBattlePyramid() || FlagGet(FLAG_STORING_ITEMS_IN_PYRAMID_BAG) == TRUE) { return CheckPyramidBagHasSpace(itemId, count); } @@ -404,7 +404,7 @@ bool8 AddBagItem(u16 itemId, u16 count) return FALSE; // check Battle Pyramid Bag - if (InBattlePyramid() || FlagGet(FLAG_SPECIAL_FLAG_0x4004) == TRUE) + if (InBattlePyramid() || FlagGet(FLAG_STORING_ITEMS_IN_PYRAMID_BAG) == TRUE) { return AddPyramidBagItem(itemId, count); } @@ -517,7 +517,7 @@ bool8 RemoveBagItem(u16 itemId, u16 count) return FALSE; // check Battle Pyramid Bag - if (InBattlePyramid() || FlagGet(FLAG_SPECIAL_FLAG_0x4004) == TRUE) + if (InBattlePyramid() || FlagGet(FLAG_STORING_ITEMS_IN_PYRAMID_BAG) == TRUE) { return RemovePyramidBagItem(itemId, count); } diff --git a/src/item_menu.c b/src/item_menu.c index 16008b4bb..3c5095551 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -4,6 +4,7 @@ #include "battle_controllers.h" #include "battle_pyramid.h" #include "frontier_util.h" +#include "battle_pyramid_bag.h" #include "berry_tag_screen.h" #include "bg.h" #include "constants/items.h" @@ -118,7 +119,7 @@ void sub_81AD9C0(u8); void sub_81ADB14(u8); void sub_81ADA7C(u8); void sub_81ADC0C(u8); -void bag_menu_leave_maybe(void); +void CB2_ApprenticeExitBagMenu(void); void CB2_FavorLadyExitBagMenu(void); void CB2_QuizLadyExitBagMenu(void); void sub_81ABA6C(void); @@ -466,9 +467,9 @@ void CB2_BagMenuFromStartMenu(void) void sub_81AABB0(void) { if (!InBattlePyramid()) - GoToBagMenu(RETURN_LOCATION_BATTLE, POCKETS_COUNT, SetCB2ToReshowScreenAfterMenu2); + GoToBagMenu(RETURN_LOCATION_BATTLE, POCKETS_COUNT, CB2_SetUpReshowBattleScreenAfterMenu2); else - sub_81C4F98(1, SetCB2ToReshowScreenAfterMenu2); + GoToBattlePyramidBagMenu(1, CB2_SetUpReshowBattleScreenAfterMenu2); } void CB2_ChooseBerry(void) @@ -476,7 +477,7 @@ void CB2_ChooseBerry(void) GoToBagMenu(RETURN_LOCATION_FIELD_2, BERRIES_POCKET, CB2_ReturnToFieldContinueScript); } -void sub_81AABF0(void (*callback)(void)) +void ChooseBerrySetCallback(void (*callback)(void)) { GoToBagMenu(RETURN_LOCATION_FIELD_3, BERRIES_POCKET, callback); } @@ -491,23 +492,23 @@ void sub_81AAC14(void) GoToBagMenu(RETURN_LOCATION_PC, POCKETS_COUNT, sub_816B31C); } -void sub_81AAC28(void) +void ApprenticeOpenBagMenu(void) { - GoToBagMenu(RETURN_LOCATION_FIELD_6, POCKETS_COUNT, bag_menu_leave_maybe); - gSpecialVar_0x8005 = 0; - gSpecialVar_Result = 0; + GoToBagMenu(RETURN_LOCATION_FIELD_6, POCKETS_COUNT, CB2_ApprenticeExitBagMenu); + gSpecialVar_0x8005 = ITEM_NONE; + gSpecialVar_Result = FALSE; } void FavorLadyOpenBagMenu(void) { GoToBagMenu(RETURN_LOCATION_FIELD_4, POCKETS_COUNT, CB2_FavorLadyExitBagMenu); - gSpecialVar_Result = 0; + gSpecialVar_Result = FALSE; } void QuizLadyOpenBagMenu(void) { GoToBagMenu(RETURN_LOCATION_FIELD_5, POCKETS_COUNT, CB2_QuizLadyExitBagMenu); - gSpecialVar_Result = 0; + gSpecialVar_Result = FALSE; } void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()) @@ -1148,13 +1149,13 @@ u8 GetSwitchBagPocketDirection(void) u8 LRKeys; if (gBagMenu->unk81B != 0) return 0; - LRKeys = GetLRKeysState(); - if ((gMain.newKeys & DPAD_LEFT) || LRKeys == 1) + LRKeys = GetLRKeysPressed(); + if ((gMain.newKeys & DPAD_LEFT) || LRKeys == MENU_L_PRESSED) { PlaySE(SE_SELECT); return 1; } - if ((gMain.newKeys & DPAD_RIGHT) || LRKeys == 2) + if ((gMain.newKeys & DPAD_RIGHT) || LRKeys == MENU_R_PRESSED) { PlaySE(SE_SELECT); return 2; @@ -1581,7 +1582,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) sub_8199134(0, 1); } } - else if ((gMain.newKeys & DPAD_LEFT) || GetLRKeysState() == 1) + else if ((gMain.newKeys & DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED) { if ((cursorPos & 1) && sub_81ACDFC(cursorPos - 1)) { @@ -1589,7 +1590,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) sub_8199134(-1, 0); } } - else if ((gMain.newKeys & DPAD_RIGHT) || GetLRKeysState() == 2) + else if ((gMain.newKeys & DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED) { if (!(cursorPos & 1) && sub_81ACDFC(cursorPos + 1)) { @@ -1782,7 +1783,7 @@ void ItemMenu_Give(u8 taskId) BagMenu_PrintThereIsNoPokemon(taskId); else { - gBagMenu->mainCallback2 = sub_81B7F60; + gBagMenu->mainCallback2 = CB2_ChooseMonToGiveItem; unknown_ItemMenu_Confirm(taskId); } } @@ -2157,7 +2158,7 @@ void DoWallyTutorialBagMenu(void) PrepareBagForWallyTutorial(); AddBagItem(ITEM_POTION, 1); AddBagItem(ITEM_POKE_BALL, 1); - GoToBagMenu(RETURN_LOCATION_BATTLE_2, ITEMS_POCKET, SetCB2ToReshowScreenAfterMenu2); + GoToBagMenu(RETURN_LOCATION_BATTLE_2, ITEMS_POCKET, CB2_SetUpReshowBattleScreenAfterMenu2); } void Task_WallyTutorialBagMenu(u8 taskId) @@ -2202,7 +2203,7 @@ void unknown_ItemMenu_Show(u8 taskId) unknown_ItemMenu_Confirm(taskId); } -void bag_menu_leave_maybe(void) +void CB2_ApprenticeExitBagMenu(void) { gFieldCallback = Apprentice_EnableBothScriptContexts; SetMainCallback2(CB2_ReturnToField); diff --git a/src/item_use.c b/src/item_use.c index 456a39339..a777bb2ec 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -64,10 +64,10 @@ void sub_80FDC00(u8 taskId); void ItemUseOnFieldCB_Berry(u8 taskId); void ItemUseOnFieldCB_WailmerPailBerry(u8 taskId); void ItemUseOnFieldCB_WailmerPailSudowoodo(u8 taskId); -void sub_80FDF90(u8 taskId); -void task08_0809AD8C(u8 taskId); -void sub_80FE024(u8 taskId); -void sub_80FE03C(u8 taskId); +static void BootUpSoundTMHM(u8 taskId); +static void Task_ShowTMHMContainedMessage(u8 taskId); +static void UseTMHMYesNo(u8 taskId); +static void UseTMHM(u8 taskId); void sub_80FE124(u8 taskId); void sub_80FE164(u8 taskId); @@ -91,16 +91,16 @@ EWRAM_DATA static void(*gUnknown_0203A0F4)(u8 taskId) = NULL; static const MainCallback gUnknown_085920D8[] = { - sub_81B617C, + CB2_ShowPartyMenuForItemUse, CB2_ReturnToField, NULL, }; static const u8 gUnknown_085920E4[] = {DIR_NORTH, DIR_EAST, DIR_SOUTH, DIR_WEST}; -static const struct YesNoFuncTable gUnknown_085920E8 = +static const struct YesNoFuncTable sUseTMHMYesNoFuncTable = { - .yesFunc = sub_80FE03C, + .yesFunc = UseTMHM, .noFunc = BagMenu_InitListsMenu, }; @@ -350,7 +350,7 @@ bool8 ItemfinderCheckForHiddenItems(const struct MapEvents *events, u8 taskId) gTasks[taskId].data[2] = FALSE; for (i = 0; i < events->bgEventCount; i++) { - if (events->bgEvents[i].kind == BG_EVENT_HIDDEN_ITEM && !FlagGet(events->bgEvents[i].bgUnion.hiddenItem.hiddenItemId + 0x1F4)) + if (events->bgEvents[i].kind == BG_EVENT_HIDDEN_ITEM && !FlagGet(events->bgEvents[i].bgUnion.hiddenItem.hiddenItemId + FLAG_HIDDEN_ITEMS_START)) { distanceX = (u16)events->bgEvents[i].x + 7; newDistanceX = distanceX - x; @@ -379,7 +379,7 @@ bool8 sub_80FD6D4(const struct MapEvents *events, s16 x, s16 y) { if (bgEvent[i].kind == BG_EVENT_HIDDEN_ITEM && x == (u16)bgEvent[i].x && y == (u16)bgEvent[i].y) // hidden item and coordinates matches x and y passed? { - if (!FlagGet(bgEvent[i].bgUnion.hiddenItem.hiddenItemId + 0x1F4)) + if (!FlagGet(bgEvent[i].bgUnion.hiddenItem.hiddenItemId + FLAG_HIDDEN_ITEMS_START)) return TRUE; else return FALSE; @@ -722,72 +722,72 @@ void ItemUseOnFieldCB_WailmerPailSudowoodo(u8 taskId) void ItemUseOutOfBattle_Medicine(u8 taskId) { - gUnknown_03006328 = ItemUseCB_Medicine; + gItemUseCB = ItemUseCB_Medicine; SetUpItemUseCallback(taskId); } void ItemUseOutOfBattle_ReduceEV(u8 taskId) { - gUnknown_03006328 = sub_81B67C8; + gItemUseCB = ItemUseCB_ReduceEV; SetUpItemUseCallback(taskId); } void ItemUseOutOfBattle_SacredAsh(u8 taskId) { - gUnknown_03006328 = sub_81B79E8; + gItemUseCB = ItemUseCB_SacredAsh; SetUpItemUseCallback(taskId); } void ItemUseOutOfBattle_PPRecovery(u8 taskId) { - gUnknown_03006328 = dp05_ether; + gItemUseCB = ItemUseCB_PPRecovery; SetUpItemUseCallback(taskId); } void ItemUseOutOfBattle_PPUp(u8 taskId) { - gUnknown_03006328 = dp05_pp_up; + gItemUseCB = ItemUseCB_PPUp; SetUpItemUseCallback(taskId); } void ItemUseOutOfBattle_RareCandy(u8 taskId) { - gUnknown_03006328 = dp05_rare_candy; + gItemUseCB = ItemUseCB_RareCandy; SetUpItemUseCallback(taskId); } void ItemUseOutOfBattle_TMHM(u8 taskId) { if (gSpecialVar_ItemId >= ITEM_HM01_CUT) - DisplayItemMessage(taskId, 1, gText_BootedUpHM, sub_80FDF90); // HM + DisplayItemMessage(taskId, 1, gText_BootedUpHM, BootUpSoundTMHM); // HM else - DisplayItemMessage(taskId, 1, gText_BootedUpTM, sub_80FDF90); // TM + DisplayItemMessage(taskId, 1, gText_BootedUpTM, BootUpSoundTMHM); // TM } -void sub_80FDF90(u8 taskId) +static void BootUpSoundTMHM(u8 taskId) { PlaySE(SE_PC_LOGIN); - gTasks[taskId].func = task08_0809AD8C; + gTasks[taskId].func = Task_ShowTMHMContainedMessage; } -void task08_0809AD8C(u8 taskId) +static void Task_ShowTMHMContainedMessage(u8 taskId) { if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { StringCopy(gStringVar1, gMoveNames[ItemIdToBattleMoveId(gSpecialVar_ItemId)]); StringExpandPlaceholders(gStringVar4, gText_TMHMContainedVar1); - DisplayItemMessage(taskId, 1, gStringVar4, sub_80FE024); + DisplayItemMessage(taskId, 1, gStringVar4, UseTMHMYesNo); } } -void sub_80FE024(u8 taskId) +static void UseTMHMYesNo(u8 taskId) { - BagMenu_YesNo(taskId, 6, &gUnknown_085920E8); + BagMenu_YesNo(taskId, 6, &sUseTMHMYesNoFuncTable); } -void sub_80FE03C(u8 taskId) +static void UseTMHM(u8 taskId) { - gUnknown_03006328 = sub_81B6DC4; + gItemUseCB = ItemUseCB_TMHM; SetUpItemUseCallback(taskId); } @@ -912,7 +912,7 @@ void ItemUseOutOfBattle_EscapeRope(u8 taskId) void ItemUseOutOfBattle_EvolutionStone(u8 taskId) { - gUnknown_03006328 = sub_81B7C74; + gItemUseCB = ItemUseCB_EvolutionStone; SetUpItemUseCallback(taskId); } @@ -976,36 +976,37 @@ void ItemUseInBattle_StatIncrease(u8 taskId) } } -void sub_80FE54C(u8 taskId) +static void ItemUseInBattle_ShowPartyMenu(u8 taskId) { if (!InBattlePyramid()) { - gBagMenu->mainCallback2 = sub_81B89F0; + gBagMenu->mainCallback2 = ChooseMonForInBattleItem; unknown_ItemMenu_Confirm(taskId); } else { - gPyramidBagResources->callback2 = sub_81B89F0; + gPyramidBagResources->callback2 = ChooseMonForInBattleItem; sub_81C5B14(taskId); } } void ItemUseInBattle_Medicine(u8 taskId) { - gUnknown_03006328 = ItemUseCB_Medicine; - sub_80FE54C(taskId); + gItemUseCB = ItemUseCB_Medicine; + ItemUseInBattle_ShowPartyMenu(taskId); } -void sub_80FE5AC(u8 taskId) +// Unused. Sacred Ash cannot be used in battle +void ItemUseInBattle_SacredAsh(u8 taskId) { - gUnknown_03006328 = sub_81B79E8; - sub_80FE54C(taskId); + gItemUseCB = ItemUseCB_SacredAsh; + ItemUseInBattle_ShowPartyMenu(taskId); } void ItemUseInBattle_PPRecovery(u8 taskId) { - gUnknown_03006328 = dp05_ether; - sub_80FE54C(taskId); + gItemUseCB = ItemUseCB_PPRecovery; + ItemUseInBattle_ShowPartyMenu(taskId); } void ItemUseInBattle_Escape(u8 taskId) diff --git a/src/link.c b/src/link.c index 3ca8236ed..b010558a5 100644 --- a/src/link.c +++ b/src/link.c @@ -1399,7 +1399,7 @@ void sub_800AB18(void) } } -void sub_800AB98(void) +void ResetLinkPlayerCount(void) { gSavedLinkPlayerCount = 0; gSavedMultiplayerId = 0; diff --git a/src/mail_data.c b/src/mail_data.c index 809dcc2a8..b0b05e8fe 100644 --- a/src/mail_data.c +++ b/src/mail_data.c @@ -63,7 +63,7 @@ u8 GiveMailToMon(struct Pokemon *mon, u16 itemId) gSaveBlock1Ptr->mail[id].playerName[i] = EOS; PadNameString(gSaveBlock1Ptr->mail[id].playerName, CHAR_SPACE); - for (i = 0; i < 4; i++) + for (i = 0; i < TRAINER_ID_LENGTH; i++) gSaveBlock1Ptr->mail[id].trainerId[i] = gSaveBlock2Ptr->playerTrainerId[i]; species = GetBoxMonData(&mon->box, MON_DATA_SPECIES); diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index f55dd2b8b..add48efd8 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -22,6 +22,7 @@ #include "field_message_box.h" #include "script_menu.h" #include "trader.h" +#include "constants/mauville_old_man.h" #define CHAR_SONG_WORD_SEPARATOR 0x37 @@ -41,7 +42,7 @@ static EWRAM_DATA u16 sUnknownBardRelated = 0; static EWRAM_DATA struct MauvilleManStoryteller * sStorytellerPtr = NULL; static EWRAM_DATA u8 sStorytellerWindowId = 0; -static const u16 sDefaultBardSongLyrics[6] = { +static const u16 sDefaultBardSongLyrics[BARD_SONG_LENGTH] = { EC_WORD_SHAKE, EC_WORD_IT, EC_WORD_DO, @@ -80,7 +81,7 @@ static void SetupBard(void) bard->id = MAUVILLE_MAN_BARD; bard->hasChangedSong = FALSE; bard->language = gGameLanguage; - for (i = 0; i < 6; i++) + for (i = 0; i < BARD_SONG_LENGTH; i++) bard->songLyrics[i] = sDefaultBardSongLyrics[i]; } @@ -166,10 +167,10 @@ void ScrSpecial_SaveBardSongLyrics(void) StringCopy(bard->playerName, gSaveBlock2Ptr->playerName); - for (i = 0; i < 4; i++) + for (i = 0; i < TRAINER_ID_LENGTH; i++) bard->playerTrainerId[i] = gSaveBlock2Ptr->playerTrainerId[i]; - for (i = 0; i < 6; i++) + for (i = 0; i < BARD_SONG_LENGTH; i++) bard->songLyrics[i] = bard->temporaryLyrics[i]; bard->hasChangedSong = TRUE; @@ -248,15 +249,15 @@ void ScrSpecial_SetHipsterSpokenFlag(void) void ScrSpecial_HipsterTeachWord(void) { - u16 var = sub_811F01C(); + u16 phrase = GetNewHipsterPhraseToTeach(); - if (var == 0xFFFF) + if (phrase == 0xFFFF) { gSpecialVar_Result = FALSE; } else { - CopyEasyChatWord(gStringVar1, var); + CopyEasyChatWord(gStringVar1, phrase); gSpecialVar_Result = TRUE; } } @@ -458,7 +459,7 @@ static void BardSing(struct Task *task, struct BardSong *song) lyrics = bard->songLyrics; else lyrics = bard->temporaryLyrics; - for (i = 0; i < 6; i++) + for (i = 0; i < BARD_SONG_LENGTH; i++) song->lyrics[i] = lyrics[i]; song->currWord = 0; } @@ -683,14 +684,14 @@ void ScrSpecial_SetMauvilleOldManEventObjGfx(void) void sub_8120B70(union OldMan * oldMan) { s32 i; - u8 sp00[8]; + u8 playerName[PLAYER_NAME_LENGTH + 1]; switch (oldMan->common.id) { case MAUVILLE_MAN_TRADER: { struct MauvilleOldManTrader * trader = &oldMan->trader; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_TRADER_ITEMS; i++) { if (trader->language[i] == LANGUAGE_JAPANESE) { @@ -702,17 +703,17 @@ void sub_8120B70(union OldMan * oldMan) case MAUVILLE_MAN_STORYTELLER: { struct MauvilleManStoryteller * storyteller = &oldMan->storyteller; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { if (storyteller->gameStatIDs[i] != 0) { - memcpy(sp00, storyteller->trainerNames[i], 7); - sp00[7] = EOS; - if (IsStringJapanese(sp00)) + memcpy(playerName, storyteller->trainerNames[i], PLAYER_NAME_LENGTH); + playerName[PLAYER_NAME_LENGTH] = EOS; + if (IsStringJapanese(playerName)) { - memset(sp00, CHAR_SPACE, 8); - StringCopy(sp00, gText_Friend); - memcpy(storyteller->trainerNames[i], sp00, 7); + memset(playerName, CHAR_SPACE, PLAYER_NAME_LENGTH + 1); + StringCopy(playerName, gText_Friend); + memcpy(storyteller->trainerNames[i], playerName, PLAYER_NAME_LENGTH); storyteller->language[i] = GAME_LANGUAGE; } } @@ -732,7 +733,7 @@ void sub_8120C0C(union OldMan * oldMan, u32 r8, u32 r7, u32 r3) { struct MauvilleOldManTrader * trader = &oldMan->trader; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_TRADER_ITEMS; i++) { if (IsStringJapanese(trader->playerNames[i])) { @@ -749,7 +750,7 @@ void sub_8120C0C(union OldMan * oldMan, u32 r8, u32 r7, u32 r3) { struct MauvilleManStoryteller * storyteller = &oldMan->storyteller; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { if (IsStringJapanese(storyteller->trainerNames[i])) { @@ -797,19 +798,19 @@ void sub_8120C0C(union OldMan * oldMan, u32 r8, u32 r7, u32 r3) void SanitizeReceivedEmeraldOldMan(union OldMan * oldMan, u32 version, u32 language) { - u8 sp00[8]; + u8 playerName[PLAYER_NAME_LENGTH + 1]; s32 i; if (oldMan->common.id == MAUVILLE_MAN_STORYTELLER && language == LANGUAGE_JAPANESE) { struct MauvilleManStoryteller * storyteller = &oldMan->storyteller; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { if (storyteller->gameStatIDs[i] != 0) { - memcpy(sp00, storyteller->trainerNames[i], 7); - sp00[7] = EOS; - if (IsStringJapanese(sp00)) + memcpy(playerName, storyteller->trainerNames[i], PLAYER_NAME_LENGTH); + playerName[PLAYER_NAME_LENGTH] = EOS; + if (IsStringJapanese(playerName)) storyteller->language[i] = LANGUAGE_JAPANESE; else storyteller->language[i] = GAME_LANGUAGE; @@ -831,7 +832,7 @@ void SanitizeReceivedRubyOldMan(union OldMan * oldMan, u32 version, u32 language if (isRuby) { - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_TRADER_ITEMS; i++) { u8 * str = trader->playerNames[i]; if (str[0] == EXT_CTRL_CODE_BEGIN && str[1] == EXT_CTRL_CODE_JPN) @@ -845,7 +846,7 @@ void SanitizeReceivedRubyOldMan(union OldMan * oldMan, u32 version, u32 language } else { - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_TRADER_ITEMS; i++) { if (trader->language[i] == LANGUAGE_JAPANESE) { @@ -863,7 +864,7 @@ void SanitizeReceivedRubyOldMan(union OldMan * oldMan, u32 version, u32 language if (isRuby) { - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { if (storyteller->gameStatIDs[i] != 0) storyteller->language[i] = language; @@ -914,42 +915,223 @@ struct Story }; static const struct Story sStorytellerStories[] = { - {GAME_STAT_NUM_UNION_ROOM_BATTLES, 1, MauvilleCity_PokemonCenter_1F_Text_28E930, MauvilleCity_PokemonCenter_1F_Text_28E947, MauvilleCity_PokemonCenter_1F_Text_28E956}, - {GAME_STAT_STARTED_TRENDS, 1, MauvilleCity_PokemonCenter_1F_Text_28E9D7, MauvilleCity_PokemonCenter_1F_Text_28E9EF, MauvilleCity_PokemonCenter_1F_Text_28E9FE}, - {GAME_STAT_PLANTED_BERRIES, 1, MauvilleCity_PokemonCenter_1F_Text_28EA7D, MauvilleCity_PokemonCenter_1F_Text_28EA98, MauvilleCity_PokemonCenter_1F_Text_28EAA8}, - {GAME_STAT_TRADED_BIKES, 1, MauvilleCity_PokemonCenter_1F_Text_28EB19, MauvilleCity_PokemonCenter_1F_Text_28EB31, MauvilleCity_PokemonCenter_1F_Text_28EB3E}, - {GAME_STAT_GOT_INTERVIEWED, 1, MauvilleCity_PokemonCenter_1F_Text_28EBB5, MauvilleCity_PokemonCenter_1F_Text_28EBCD, MauvilleCity_PokemonCenter_1F_Text_28EBDD}, - {GAME_STAT_TRAINER_BATTLES, 1, MauvilleCity_PokemonCenter_1F_Text_28EC60, MauvilleCity_PokemonCenter_1F_Text_28EC79, MauvilleCity_PokemonCenter_1F_Text_28EC81}, - {GAME_STAT_POKEMON_CAPTURES, 1, MauvilleCity_PokemonCenter_1F_Text_28ED04, MauvilleCity_PokemonCenter_1F_Text_28ED21, MauvilleCity_PokemonCenter_1F_Text_28ED30}, - {GAME_STAT_FISHING_CAPTURES, 1, MauvilleCity_PokemonCenter_1F_Text_28EDA1, MauvilleCity_PokemonCenter_1F_Text_28EDB5, MauvilleCity_PokemonCenter_1F_Text_28EDCF}, - {GAME_STAT_HATCHED_EGGS, 1, MauvilleCity_PokemonCenter_1F_Text_28EE45, MauvilleCity_PokemonCenter_1F_Text_28EE5D, MauvilleCity_PokemonCenter_1F_Text_28EE6A}, - {GAME_STAT_EVOLVED_POKEMON, 1, MauvilleCity_PokemonCenter_1F_Text_28EEDD, MauvilleCity_PokemonCenter_1F_Text_28EEF1, MauvilleCity_PokemonCenter_1F_Text_28EF01}, - {GAME_STAT_USED_POKECENTER, 1, MauvilleCity_PokemonCenter_1F_Text_28EF73, MauvilleCity_PokemonCenter_1F_Text_28EF95, MauvilleCity_PokemonCenter_1F_Text_28EFAA}, - {GAME_STAT_RESTED_AT_HOME, 1, MauvilleCity_PokemonCenter_1F_Text_28F045, MauvilleCity_PokemonCenter_1F_Text_28F05A, MauvilleCity_PokemonCenter_1F_Text_28F071}, - {GAME_STAT_ENTERED_SAFARI_ZONE, 1, MauvilleCity_PokemonCenter_1F_Text_28F0F3, MauvilleCity_PokemonCenter_1F_Text_28F10D, MauvilleCity_PokemonCenter_1F_Text_28F125}, - {GAME_STAT_USED_CUT, 1, MauvilleCity_PokemonCenter_1F_Text_28F1BE, MauvilleCity_PokemonCenter_1F_Text_28F1D5, MauvilleCity_PokemonCenter_1F_Text_28F1DE}, - {GAME_STAT_USED_ROCK_SMASH, 1, MauvilleCity_PokemonCenter_1F_Text_28F24F, MauvilleCity_PokemonCenter_1F_Text_28F269, MauvilleCity_PokemonCenter_1F_Text_28F277}, - {GAME_STAT_MOVED_SECRET_BASE, 1, MauvilleCity_PokemonCenter_1F_Text_28F2FC, MauvilleCity_PokemonCenter_1F_Text_28F314, MauvilleCity_PokemonCenter_1F_Text_28F32A}, - {GAME_STAT_USED_SPLASH, 1, MauvilleCity_PokemonCenter_1F_Text_28F3AD, MauvilleCity_PokemonCenter_1F_Text_28F3C6, MauvilleCity_PokemonCenter_1F_Text_28F3D2}, - {GAME_STAT_USED_STRUGGLE, 1, MauvilleCity_PokemonCenter_1F_Text_28F44B, MauvilleCity_PokemonCenter_1F_Text_28F461, MauvilleCity_PokemonCenter_1F_Text_28F47C}, - {GAME_STAT_SLOT_JACKPOTS, 1, MauvilleCity_PokemonCenter_1F_Text_28F50C, MauvilleCity_PokemonCenter_1F_Text_28F51B, MauvilleCity_PokemonCenter_1F_Text_28F538}, - {GAME_STAT_CONSECUTIVE_ROULETTE_WINS, 2, MauvilleCity_PokemonCenter_1F_Text_28F5BE, MauvilleCity_PokemonCenter_1F_Text_28F5D1, MauvilleCity_PokemonCenter_1F_Text_28F5F2}, - {GAME_STAT_ENTERED_BATTLE_TOWER, 1, MauvilleCity_PokemonCenter_1F_Text_28F678, MauvilleCity_PokemonCenter_1F_Text_28F694, MauvilleCity_PokemonCenter_1F_Text_28F6B4}, - {GAME_STAT_POKEBLOCKS, 1, MauvilleCity_PokemonCenter_1F_Text_28F751, MauvilleCity_PokemonCenter_1F_Text_28F76A, MauvilleCity_PokemonCenter_1F_Text_28F776}, - {GAME_STAT_ENTERED_CONTEST, 1, MauvilleCity_PokemonCenter_1F_Text_28F7F6, MauvilleCity_PokemonCenter_1F_Text_28F811, MauvilleCity_PokemonCenter_1F_Text_28F822}, - {GAME_STAT_WON_CONTEST, 1, MauvilleCity_PokemonCenter_1F_Text_28F89C, MauvilleCity_PokemonCenter_1F_Text_28F8AF, MauvilleCity_PokemonCenter_1F_Text_28F8BC}, - {GAME_STAT_SHOPPED, 1, MauvilleCity_PokemonCenter_1F_Text_28F92F, MauvilleCity_PokemonCenter_1F_Text_28F941, MauvilleCity_PokemonCenter_1F_Text_28F949}, - {GAME_STAT_USED_ITEMFINDER, 1, MauvilleCity_PokemonCenter_1F_Text_28F9D1, MauvilleCity_PokemonCenter_1F_Text_28F9EA, MauvilleCity_PokemonCenter_1F_Text_28F9FD}, - {GAME_STAT_GOT_RAINED_ON, 1, MauvilleCity_PokemonCenter_1F_Text_28FA81, MauvilleCity_PokemonCenter_1F_Text_28FA99, MauvilleCity_PokemonCenter_1F_Text_28FAA7}, - {GAME_STAT_CHECKED_POKEDEX, 1, MauvilleCity_PokemonCenter_1F_Text_28FB1D, MauvilleCity_PokemonCenter_1F_Text_28FB35, MauvilleCity_PokemonCenter_1F_Text_28FB47}, - {GAME_STAT_RECEIVED_RIBBONS, 1, MauvilleCity_PokemonCenter_1F_Text_28FBC4, MauvilleCity_PokemonCenter_1F_Text_28FBD9, MauvilleCity_PokemonCenter_1F_Text_28FBEA}, - {GAME_STAT_JUMPED_DOWN_LEDGES, 1, MauvilleCity_PokemonCenter_1F_Text_28FC6B, MauvilleCity_PokemonCenter_1F_Text_28FC85, MauvilleCity_PokemonCenter_1F_Text_28FC98}, - {GAME_STAT_WATCHED_TV, 1, MauvilleCity_PokemonCenter_1F_Text_28FD1D, MauvilleCity_PokemonCenter_1F_Text_28FD35, MauvilleCity_PokemonCenter_1F_Text_28FD40}, - {GAME_STAT_CHECKED_CLOCK, 1, MauvilleCity_PokemonCenter_1F_Text_28FDA2, MauvilleCity_PokemonCenter_1F_Text_28FDBD, MauvilleCity_PokemonCenter_1F_Text_28FDCE}, - {GAME_STAT_WON_POKEMON_LOTTERY, 1, MauvilleCity_PokemonCenter_1F_Text_28FE57, MauvilleCity_PokemonCenter_1F_Text_28FE72, MauvilleCity_PokemonCenter_1F_Text_28FE88}, - {GAME_STAT_USED_DAYCARE, 1, MauvilleCity_PokemonCenter_1F_Text_28FF0C, MauvilleCity_PokemonCenter_1F_Text_28FF27, MauvilleCity_PokemonCenter_1F_Text_28FF44}, - {GAME_STAT_RODE_CABLE_CAR, 1, MauvilleCity_PokemonCenter_1F_Text_28FFDD, MauvilleCity_PokemonCenter_1F_Text_28FFFA, MauvilleCity_PokemonCenter_1F_Text_29000D}, - {GAME_STAT_ENTERED_HOT_SPRINGS, 1, MauvilleCity_PokemonCenter_1F_Text_290097, MauvilleCity_PokemonCenter_1F_Text_2900B5, MauvilleCity_PokemonCenter_1F_Text_2900CB} + // The 50 below is replaced with GAME_STAT_SAVED_GAME + { + 50, 1, + MauvilleCity_PokemonCenter_1F_Text_SavedGameTitle, + MauvilleCity_PokemonCenter_1F_Text_SavedGameAction, + MauvilleCity_PokemonCenter_1F_Text_SavedGameStory + }, + { + GAME_STAT_STARTED_TRENDS, 1, + MauvilleCity_PokemonCenter_1F_Text_TrendsStartedTitle, + MauvilleCity_PokemonCenter_1F_Text_TrendsStartedAction, + MauvilleCity_PokemonCenter_1F_Text_TrendsStartedStory + }, + { + GAME_STAT_PLANTED_BERRIES, 1, + MauvilleCity_PokemonCenter_1F_Text_BerriesPlantedTitle, + MauvilleCity_PokemonCenter_1F_Text_BerriesPlantedAction, + MauvilleCity_PokemonCenter_1F_Text_BerriesPlantedStory + }, + { + GAME_STAT_TRADED_BIKES, 1, + MauvilleCity_PokemonCenter_1F_Text_BikeTradesTitle, + MauvilleCity_PokemonCenter_1F_Text_BikeTradesAction, + MauvilleCity_PokemonCenter_1F_Text_BikeTradesStory + }, + { + GAME_STAT_GOT_INTERVIEWED, 1, + MauvilleCity_PokemonCenter_1F_Text_InterviewsTitle, + MauvilleCity_PokemonCenter_1F_Text_InterviewsAction, + MauvilleCity_PokemonCenter_1F_Text_InterviewsStory + }, + { + GAME_STAT_TRAINER_BATTLES, 1, + MauvilleCity_PokemonCenter_1F_Text_TrainerBattlesTitle, + MauvilleCity_PokemonCenter_1F_Text_TrainerBattlesAction, + MauvilleCity_PokemonCenter_1F_Text_TrainerBattlesStory + }, + { + GAME_STAT_POKEMON_CAPTURES, 1, + MauvilleCity_PokemonCenter_1F_Text_PokemonCaughtTitle, + MauvilleCity_PokemonCenter_1F_Text_PokemonCaughtAction, + MauvilleCity_PokemonCenter_1F_Text_PokemonCaughtStory + }, + { + GAME_STAT_FISHING_CAPTURES, 1, + MauvilleCity_PokemonCenter_1F_Text_FishingPokemonCaughtTitle, + MauvilleCity_PokemonCenter_1F_Text_FishingPokemonCaughtAction, + MauvilleCity_PokemonCenter_1F_Text_FishingPokemonCaughtStory + }, + { + GAME_STAT_HATCHED_EGGS, 1, + MauvilleCity_PokemonCenter_1F_Text_EggsHatchedTitle, + MauvilleCity_PokemonCenter_1F_Text_EggsHatchedAction, + MauvilleCity_PokemonCenter_1F_Text_EggsHatchedStory + }, + { + GAME_STAT_EVOLVED_POKEMON, 1, + MauvilleCity_PokemonCenter_1F_Text_PokemonEvolvedTitle, + MauvilleCity_PokemonCenter_1F_Text_PokemonEvolvedAction, + MauvilleCity_PokemonCenter_1F_Text_PokemonEvolvedStory + }, + { + GAME_STAT_USED_POKECENTER, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedPokemonCenterTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedPokemonCenterAction, + MauvilleCity_PokemonCenter_1F_Text_UsedPokemonCenterStory + }, + { + GAME_STAT_RESTED_AT_HOME, 1, + MauvilleCity_PokemonCenter_1F_Text_RestedAtHomeTitle, + MauvilleCity_PokemonCenter_1F_Text_RestedAtHomeAction, + MauvilleCity_PokemonCenter_1F_Text_RestedAtHomeStory + }, + { + GAME_STAT_ENTERED_SAFARI_ZONE, 1, + MauvilleCity_PokemonCenter_1F_Text_SafariGamesTitle, + MauvilleCity_PokemonCenter_1F_Text_SafariGamesAction, + MauvilleCity_PokemonCenter_1F_Text_SafariGamesStory + }, + { + GAME_STAT_USED_CUT, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedCutTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedCutAction, + MauvilleCity_PokemonCenter_1F_Text_UsedCutStory + }, + { + GAME_STAT_USED_ROCK_SMASH, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedRockSmashTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedRockSmashAction, + MauvilleCity_PokemonCenter_1F_Text_UsedRockSmashStory + }, + { + GAME_STAT_MOVED_SECRET_BASE, 1, + MauvilleCity_PokemonCenter_1F_Text_MovedBasesTitle, + MauvilleCity_PokemonCenter_1F_Text_MovedBasesAction, + MauvilleCity_PokemonCenter_1F_Text_MovedBasesStory + }, + { + GAME_STAT_USED_SPLASH, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedSplashTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedSplashAction, + MauvilleCity_PokemonCenter_1F_Text_UsedSplashStory + }, + { + GAME_STAT_USED_STRUGGLE, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedStruggleTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedStruggleAction, + MauvilleCity_PokemonCenter_1F_Text_UsedStruggleStory + }, + { + GAME_STAT_SLOT_JACKPOTS, 1, + MauvilleCity_PokemonCenter_1F_Text_SlotJackpotsTitle, + MauvilleCity_PokemonCenter_1F_Text_SlotJackpotsAction, + MauvilleCity_PokemonCenter_1F_Text_SlotJackpotsStory + }, + { + GAME_STAT_CONSECUTIVE_ROULETTE_WINS, 2, + MauvilleCity_PokemonCenter_1F_Text_RouletteWinsTitle, + MauvilleCity_PokemonCenter_1F_Text_RouletteWinsAction, + MauvilleCity_PokemonCenter_1F_Text_RouletteWinsStory + }, + { + GAME_STAT_ENTERED_BATTLE_TOWER, 1, + MauvilleCity_PokemonCenter_1F_Text_BattleTowerChallengesTitle, + MauvilleCity_PokemonCenter_1F_Text_BattleTowerChallengesAction, + MauvilleCity_PokemonCenter_1F_Text_BattleTowerChallengesStory + }, + { + GAME_STAT_POKEBLOCKS, 1, + MauvilleCity_PokemonCenter_1F_Text_MadePokeblocksTitle, + MauvilleCity_PokemonCenter_1F_Text_MadePokeblocksAction, + MauvilleCity_PokemonCenter_1F_Text_MadePokeblocksStory + }, + { + GAME_STAT_ENTERED_CONTEST, 1, + MauvilleCity_PokemonCenter_1F_Text_EnteredContestsTitle, + MauvilleCity_PokemonCenter_1F_Text_EnteredContestsAction, + MauvilleCity_PokemonCenter_1F_Text_EnteredContestsStory + }, + { + GAME_STAT_WON_CONTEST, 1, + MauvilleCity_PokemonCenter_1F_Text_WonContestsTitle, + MauvilleCity_PokemonCenter_1F_Text_WonContestsAction, + MauvilleCity_PokemonCenter_1F_Text_WonContestsStory + }, + { + GAME_STAT_SHOPPED, 1, + MauvilleCity_PokemonCenter_1F_Text_TimesShoppedTitle, + MauvilleCity_PokemonCenter_1F_Text_TimesShoppedAction, + MauvilleCity_PokemonCenter_1F_Text_TimesShoppedStory + }, + { + GAME_STAT_USED_ITEMFINDER, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedItemFinderTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedItemFinderAction, + MauvilleCity_PokemonCenter_1F_Text_UsedItemFinderStory + }, + { + GAME_STAT_GOT_RAINED_ON, 1, + MauvilleCity_PokemonCenter_1F_Text_TimesRainedTitle, + MauvilleCity_PokemonCenter_1F_Text_TimesRainedAction, + MauvilleCity_PokemonCenter_1F_Text_TimesRainedStory + }, + { + GAME_STAT_CHECKED_POKEDEX, 1, + MauvilleCity_PokemonCenter_1F_Text_CheckedPokedexTitle, + MauvilleCity_PokemonCenter_1F_Text_CheckedPokedexAction, + MauvilleCity_PokemonCenter_1F_Text_CheckedPokedexStory + }, + { + GAME_STAT_RECEIVED_RIBBONS, 1, + MauvilleCity_PokemonCenter_1F_Text_ReceivedRibbonsTitle, + MauvilleCity_PokemonCenter_1F_Text_ReceivedRibbonsAction, + MauvilleCity_PokemonCenter_1F_Text_ReceivedRibbonsStory + }, + { + GAME_STAT_JUMPED_DOWN_LEDGES, 1, + MauvilleCity_PokemonCenter_1F_Text_LedgesJumpedTitle, + MauvilleCity_PokemonCenter_1F_Text_LedgesJumpedAction, + MauvilleCity_PokemonCenter_1F_Text_LedgesJumpedStory + }, + { + GAME_STAT_WATCHED_TV, 1, + MauvilleCity_PokemonCenter_1F_Text_TVWatchedTitle, + MauvilleCity_PokemonCenter_1F_Text_TVWatchedAction, + MauvilleCity_PokemonCenter_1F_Text_TVWatchedStory + }, + { + GAME_STAT_CHECKED_CLOCK, 1, + MauvilleCity_PokemonCenter_1F_Text_CheckedClockTitle, + MauvilleCity_PokemonCenter_1F_Text_CheckedClockAction, + MauvilleCity_PokemonCenter_1F_Text_CheckedClockStory + }, + { + GAME_STAT_WON_POKEMON_LOTTERY, 1, + MauvilleCity_PokemonCenter_1F_Text_WonLotteryTitle, + MauvilleCity_PokemonCenter_1F_Text_WonLotteryAction, + MauvilleCity_PokemonCenter_1F_Text_WonLotteryStory + }, + { + GAME_STAT_USED_DAYCARE, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedDaycareTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedDaycareAction, + MauvilleCity_PokemonCenter_1F_Text_UsedDaycareStory + }, + { + GAME_STAT_RODE_CABLE_CAR, 1, + MauvilleCity_PokemonCenter_1F_Text_RodeCableCarTitle, + MauvilleCity_PokemonCenter_1F_Text_RodeCableCarAction, + MauvilleCity_PokemonCenter_1F_Text_RodeCableCarStory + }, + { + GAME_STAT_ENTERED_HOT_SPRINGS, 1, + MauvilleCity_PokemonCenter_1F_Text_HotSpringsTitle, + MauvilleCity_PokemonCenter_1F_Text_HotSpringsAction, + MauvilleCity_PokemonCenter_1F_Text_HotSpringsStory + } }; static void StorytellerSetup(void) @@ -959,7 +1141,7 @@ static void StorytellerSetup(void) sStorytellerPtr->id = MAUVILLE_MAN_STORYTELLER; sStorytellerPtr->alreadyRecorded = FALSE; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { sStorytellerPtr->gameStatIDs[i] = 0; sStorytellerPtr->trainerNames[0][i] = EOS; // Maybe they meant storyteller->trainerNames[i][0] instead? @@ -977,7 +1159,7 @@ static void Storyteller_ResetFlag(void) static u32 StorytellerGetGameStat(u8 stat) { if (stat == 50) - stat = 0; + stat = GAME_STAT_SAVED_GAME; return GetGameStat(stat); } @@ -985,12 +1167,12 @@ static const struct Story *GetStoryByStat(u32 stat) { s32 i; - for (i = 0; i < 36; i++) + for (i = 0; i < (int)ARRAY_COUNT(sStorytellerStories); i++) { if (sStorytellerStories[i].stat == stat) return &sStorytellerStories[i]; } - return &sStorytellerStories[35]; + return &sStorytellerStories[ARRAY_COUNT(sStorytellerStories) - 1]; } static const u8 *GetStoryTitleByStat(u32 stat) @@ -1012,7 +1194,7 @@ static u8 GetFreeStorySlot(void) { u8 i; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { if (sStorytellerPtr->gameStatIDs[i] == 0) break; @@ -1049,15 +1231,15 @@ static void GetStoryByStattellerPlayerName(u32 player, void *dst) { u8 *name = sStorytellerPtr->trainerNames[player]; - memset(dst, EOS, 8); - memcpy(dst, name, 7); + memset(dst, EOS, PLAYER_NAME_LENGTH + 1); + memcpy(dst, name, PLAYER_NAME_LENGTH); } static void StorytellerSetPlayerName(u32 player, const u8 * src) { u8 * name = sStorytellerPtr->trainerNames[player]; - memset(name, EOS, 7); - memcpy(name, src, 7); + memset(name, EOS, PLAYER_NAME_LENGTH); + memcpy(name, src, PLAYER_NAME_LENGTH); } @@ -1110,15 +1292,15 @@ static bool8 StorytellerInitializeRandomStat(void) u8 stat = sStorytellerStories[arr[i]].stat; u8 minVal = sStorytellerStories[arr[i]].minVal; - for (j = 0; j < 4; j++) + for (j = 0; j < NUM_STORYTELLER_TALES; j++) { if (sStorytellerPtr->gameStatIDs[j] == stat) break; } - if (j == 4 && StorytellerGetGameStat(stat) >= minVal) + if (j == NUM_STORYTELLER_TALES && StorytellerGetGameStat(stat) >= minVal) { sStorytellerPtr->alreadyRecorded = TRUE; - if (GetFreeStorySlot() == 4) + if (GetFreeStorySlot() == NUM_STORYTELLER_TALES) StorytellerRecordNewStat(sSelectedStory, stat); else StorytellerRecordNewStat(GetFreeStorySlot(), stat); @@ -1144,7 +1326,7 @@ static void PrintStoryList(void) s32 i; s32 width = GetStringWidth(1, gText_Exit, 0); u8 tileWidth; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { s32 curWidth; u16 gameStatID = sStorytellerPtr->gameStatIDs[i]; @@ -1157,7 +1339,7 @@ static void PrintStoryList(void) } sStorytellerWindowId = CreateWindowFromRect(0, 0, ConvertPixelWidthToTileWidth(width), GetFreeStorySlot() * 2 + 2); SetStandardWindowBorderStyle(sStorytellerWindowId, 0); - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { u16 gameStatID = sStorytellerPtr->gameStatIDs[i]; if (gameStatID == 0) @@ -1169,7 +1351,7 @@ static void PrintStoryList(void) CopyWindowToVram(sStorytellerWindowId, 3); } -static void Task_StoryListMenu(u8 taskId) // Task_StoryListMenu +static void Task_StoryListMenu(u8 taskId) { struct Task *task = &gTasks[taskId]; s32 selection; diff --git a/src/menu.c b/src/menu.c index e349ff43a..056fc6a9d 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1433,13 +1433,13 @@ s8 sub_8199284(void) sub_8199134(0, 1); return MENU_NOTHING_CHOSEN; } - else if (gMain.newKeys & DPAD_LEFT || GetLRKeysState() == 1) + else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) { PlaySE(SE_SELECT); sub_8199134(-1, 0); return MENU_NOTHING_CHOSEN; } - else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysState() == 2) + else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) { PlaySE(SE_SELECT); sub_8199134(1, 0); @@ -1474,13 +1474,13 @@ s8 Menu_ProcessInputGridLayout(void) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if (gMain.newKeys & DPAD_LEFT || GetLRKeysState() == 1) + else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) { if (oldPos != sub_81991F8(-1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysState() == 2) + else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) { if (oldPos != sub_81991F8(1, 0)) PlaySE(SE_SELECT); @@ -1513,13 +1513,13 @@ s8 sub_81993D8(void) sub_8199134(0, 1); return MENU_NOTHING_CHOSEN; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || sub_812210C() == 1) + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) { PlaySE(SE_SELECT); sub_8199134(-1, 0); return MENU_NOTHING_CHOSEN; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || sub_812210C() == 2) + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) { PlaySE(SE_SELECT); sub_8199134(1, 0); @@ -1554,13 +1554,13 @@ s8 sub_8199484(void) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || sub_812210C() == 1) + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) { if (oldPos != sub_81991F8(-1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || sub_812210C() == 2) + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) { if (oldPos != sub_81991F8(1, 0)) PlaySE(SE_SELECT); @@ -1868,7 +1868,7 @@ u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16 } } -void sub_8199C30(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette) +void SetBgTilemapPalette(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette) { u8 i; u8 j; @@ -1883,7 +1883,7 @@ void sub_8199C30(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette) } } -void sub_8199CBC(u8 bgId, u16 *dest, u8 left, u8 top, u8 width, u8 height) +void CopyToBufferFromBgTilemap(u8 bgId, u16 *dest, u8 left, u8 top, u8 width, u8 height) { u8 i; u8 j; @@ -2159,7 +2159,7 @@ void sub_819A344(u8 a0, u8 *dest, u8 color) ConvertIntToDecimalStringN(string, gSaveBlock2Ptr->playTimeMinutes, STR_CONV_MODE_LEADING_ZEROS, 2); break; case 3: - sub_81245DC(string, gMapHeader.regionMapSectionId); + GetMapNameGeneric(string, gMapHeader.regionMapSectionId); break; case 4: for (curFlag = FLAG_BADGE01_GET, flagCount = 0, endOfString = string + 1; curFlag <= FLAG_BADGE08_GET; curFlag++) diff --git a/src/menu_helpers.c b/src/menu_helpers.c index cb0d621c6..2b7a7f419 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -251,27 +251,27 @@ bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1) return FALSE; } -u8 GetLRKeysState(void) +u8 GetLRKeysPressed(void) { if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR) { if (gMain.newKeys & L_BUTTON) - return 1; + return MENU_L_PRESSED; if (gMain.newKeys & R_BUTTON) - return 2; + return MENU_R_PRESSED; } return 0; } -u8 sub_812210C(void) +u8 GetLRKeysPressedAndHeld(void) { if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR) { if (gMain.newAndRepeatedKeys & L_BUTTON) - return 1; + return MENU_L_PRESSED; if (gMain.newAndRepeatedKeys & R_BUTTON) - return 2; + return MENU_R_PRESSED; } return 0; diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index 16298183b..435ad7233 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -244,7 +244,7 @@ static const u8 sTileBitAttributes[] = [MB_CABLE_BOX_RESULTS_2] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_WIRELESS_BOX_RESULTS] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_TRAINER_HILL_TIMER] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), - [MB_UNKNOWN_CLOSED_DOOR] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + [MB_SKY_PILLAR_CLOSED_DOOR] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_UNUSED_EB] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_UNUSED_EC] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_UNUSED_ED] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), @@ -1172,9 +1172,9 @@ bool8 MetatileBehavior_IsClosedSootopolisDoor(u8 metatileBehavior) return FALSE; } -bool8 MetatileBehavior_IsUnknownClosedDoor(u8 metatileBehavior) +bool8 MetatileBehavior_IsSkyPillarClosedDoor(u8 metatileBehavior) { - if (metatileBehavior == MB_UNKNOWN_CLOSED_DOOR) + if (metatileBehavior == MB_SKY_PILLAR_CLOSED_DOOR) return TRUE; else return FALSE; diff --git a/src/mevent2.c b/src/mevent2.c index f36e5d06b..aedc7b366 100755 --- a/src/mevent2.c +++ b/src/mevent2.c @@ -9,6 +9,7 @@ #include "string_util.h" #include "new_game.h" #include "mevent.h" +#include "constants/mevent.h" #include "constants/species.h" static EWRAM_DATA bool32 gUnknown_02022C70 = FALSE; @@ -493,7 +494,7 @@ u16 mevent_081445C0(u32 command) { switch (command) { - case 0: + case GET_CARD_BATTLES_WON_INTERNAL: { struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data; if (data->unk_08_0 == 2) @@ -503,7 +504,7 @@ u16 mevent_081445C0(u32 command) } break; } - case 1: + case 1: // Never occurs { struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data; if (data->unk_08_0 == 2) @@ -513,7 +514,7 @@ u16 mevent_081445C0(u32 command) } break; } - case 2: + case 2: // Never occurs { struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data; if (data->unk_08_0 == 2) @@ -523,14 +524,14 @@ u16 mevent_081445C0(u32 command) } break; } - case 3: + case GET_NUM_STAMPS_INTERNAL: { struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data; if (data->unk_08_0 == 1) return sub_801B4CC(); break; } - case 4: + case GET_MAX_STAMPS_INTERNAL: { struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data; if (data->unk_08_0 == 1) diff --git a/src/move_relearner.c b/src/move_relearner.c index 121ac66e8..b5202e006 100644 --- a/src/move_relearner.c +++ b/src/move_relearner.c @@ -513,7 +513,7 @@ static void DoMoveRelearnerMain(void) if (selection == 0) { - if (GiveMoveToMon(&gPlayerParty[sMoveRelearnerStruct->partyMon], GetCurrentSelectedMove()) != 0xFFFF) + if (GiveMoveToMon(&gPlayerParty[sMoveRelearnerStruct->partyMon], GetCurrentSelectedMove()) != MON_HAS_MAX_MOVES) { FormatAndPrintText(gText_MoveRelearnerPkmnLearnedMove); gSpecialVar_0x8004 = TRUE; @@ -778,7 +778,7 @@ static void HandleInput(bool8 showContest) switch (itemId) { case LIST_NOTHING_CHOSEN: - if (!(gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) && !GetLRKeysState()) + if (!(gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) && !GetLRKeysPressed()) { break; } diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c index dba914b51..76f340c60 100644 --- a/src/mystery_event_script.c +++ b/src/mystery_event_script.c @@ -286,7 +286,7 @@ bool8 MEScrCmd_givenationaldex(struct ScriptContext *ctx) bool8 MEScrCmd_addrareword(struct ScriptContext *ctx) { - sub_811EFC0(ScriptReadByte(ctx)); + UnlockAdditionalPhrase(ScriptReadByte(ctx)); StringExpandPlaceholders(gStringVar4, gText_MysteryGiftRareWord); ctx->data[2] = 2; return FALSE; diff --git a/src/naming_screen.c b/src/naming_screen.c index cc73031aa..73eda32c8 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -34,10 +34,6 @@ extern u16 gKeyRepeatStartDelay; // extern text extern const u8 gExpandedPlaceholder_Empty[]; -extern const u8 gText_PkmnTransferredSomeonesPC[]; -extern const u8 gText_PkmnTransferredLanettesPC[]; -extern const u8 gText_PkmnBoxSomeonesPCFull[]; -extern const u8 gText_PkmnBoxLanettesPCFull[]; extern const u8 gText_MoveOkBack[]; extern const u8 gText_YourName[]; extern const u8 gText_BoxName[]; @@ -51,12 +47,12 @@ static const u8 gSpriteImage_858BCB8[] = INCBIN_U8("graphics/naming_screen/pc_ic static const u16 gUnknown_0858BD78[] = INCBIN_U16("graphics/naming_screen/0.gbapal"); static const u16 gUnknown_0858BD98[] = INCBIN_U16("graphics/naming_screen/1.gbapal"); -static const u8 *const gUnknown_0858BDB8[] = +static const u8 *const sTransferredToPCMessages[] = { gText_PkmnTransferredSomeonesPC, gText_PkmnTransferredLanettesPC, - gText_PkmnBoxSomeonesPCFull, - gText_PkmnBoxLanettesPCFull + gText_PkmnTransferredSomeonesPCBoxFull, + gText_PkmnTransferredLanettesPCBoxFull }; static const u8 gUnknown_0858BDC8[] = _("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!"); @@ -562,7 +558,7 @@ static void DisplaySentToPCMessage(void) if (FlagGet(FLAG_SYS_PC_LANETTE)) stringToDisplay++; - StringExpandPlaceholders(gStringVar4, gUnknown_0858BDB8[stringToDisplay]); + StringExpandPlaceholders(gStringVar4, sTransferredToPCMessages[stringToDisplay]); DrawDialogueFrame(0, 0); gTextFlags.canABSpeedUpPrint = TRUE; AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), 0, 2, 1, 3); diff --git a/src/overworld.c b/src/overworld.c index 55afe2fcf..c2e3d2789 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -64,6 +64,7 @@ #include "constants/region_map_sections.h" #include "constants/songs.h" #include "constants/species.h" +#include "constants/trainer_hill.h" #include "constants/weather.h" #define PLAYER_TRADING_STATE_IDLE 0x80 @@ -88,16 +89,16 @@ extern const u8 EventScript_DoLinkRoomExit[]; extern const u8 CableClub_EventScript_TooBusyToNotice[]; extern const u8 CableClub_EventScript_ReadTrainerCard[]; extern const u8 CableClub_EventScript_ReadTrainerCardColored[]; -extern const u8 EventScript_DoubleBattleColosseum_PlayerSpot0[]; -extern const u8 EventScript_DoubleBattleColosseum_PlayerSpot1[]; -extern const u8 EventScript_DoubleBattleColosseum_PlayerSpot2[]; -extern const u8 EventScript_DoubleBattleColosseum_PlayerSpot3[]; +extern const u8 EventScript_BattleColosseum4P_PlayerSpot0[]; +extern const u8 EventScript_BattleColosseum4P_PlayerSpot1[]; +extern const u8 EventScript_BattleColosseum4P_PlayerSpot2[]; +extern const u8 EventScript_BattleColosseum4P_PlayerSpot3[]; extern const u8 EventScript_RecordCenter_Spot0[]; extern const u8 EventScript_RecordCenter_Spot1[]; extern const u8 EventScript_RecordCenter_Spot2[]; extern const u8 EventScript_RecordCenter_Spot3[]; -extern const u8 EventScript_SingleBattleColosseum_PlayerSpot0[]; -extern const u8 EventScript_SingleBattleColosseum_PlayerSpot1[]; +extern const u8 EventScript_BattleColosseum2P_PlayerSpot0[]; +extern const u8 EventScript_BattleColosseum2P_PlayerSpot1[]; extern const u8 EventScript_TradeCenter_Chair1[]; extern const u8 EventScript_TradeCenter_Chair0[]; extern const u8 EventScript_ConfirmLeaveTradeRoom[]; @@ -854,7 +855,7 @@ static void mli0_load_map(u32 a1) if (gMapHeader.mapLayoutId == LAYOUT_BATTLE_FRONTIER_BATTLE_PYRAMID_EMPTY_SQUARE) LoadBattlePyramidEventObjectTemplates(); else if (InTrainerHill()) - sub_81D5DF8(); + LoadTrainerHillEventObjectTemplates(); else LoadEventObjTemplatesFromHeader(); } @@ -1721,8 +1722,8 @@ void CB2_ContinueSavedGame(void) trainerHillMapId = GetCurrentTrainerHillMapId(); if (gMapHeader.mapLayoutId == LAYOUT_BATTLE_FRONTIER_BATTLE_PYRAMID_EMPTY_SQUARE) LoadBattlePyramidFloorEventObjectScripts(); - else if (trainerHillMapId != 0 && trainerHillMapId != 6) - sub_81D5F48(); + else if (trainerHillMapId != 0 && trainerHillMapId != TRAINER_HILL_ENTRANCE) + LoadTrainerHillFloorEventObjectScripts(); else LoadSaveblockEventObjScripts(); @@ -2781,13 +2782,13 @@ static const u8 *TryInteractWithPlayer(struct TradeRoomPlayer *player) // these event scripts runs. static u16 GetDirectionForEventScript(const u8 *script) { - if (script == EventScript_DoubleBattleColosseum_PlayerSpot0) + if (script == EventScript_BattleColosseum4P_PlayerSpot0) return FACING_FORCED_RIGHT; - else if (script == EventScript_DoubleBattleColosseum_PlayerSpot1) + else if (script == EventScript_BattleColosseum4P_PlayerSpot1) return FACING_FORCED_LEFT; - else if (script == EventScript_DoubleBattleColosseum_PlayerSpot2) + else if (script == EventScript_BattleColosseum4P_PlayerSpot2) return FACING_FORCED_RIGHT; - else if (script == EventScript_DoubleBattleColosseum_PlayerSpot3) + else if (script == EventScript_BattleColosseum4P_PlayerSpot3) return FACING_FORCED_LEFT; else if (script == EventScript_RecordCenter_Spot0) return FACING_FORCED_RIGHT; @@ -2797,9 +2798,9 @@ static u16 GetDirectionForEventScript(const u8 *script) return FACING_FORCED_RIGHT; else if (script == EventScript_RecordCenter_Spot3) return FACING_FORCED_LEFT; - else if (script == EventScript_SingleBattleColosseum_PlayerSpot0) + else if (script == EventScript_BattleColosseum2P_PlayerSpot0) return FACING_FORCED_RIGHT; - else if (script == EventScript_SingleBattleColosseum_PlayerSpot1) + else if (script == EventScript_BattleColosseum2P_PlayerSpot1) return FACING_FORCED_LEFT; else if (script == EventScript_TradeCenter_Chair0) return FACING_FORCED_RIGHT; diff --git a/src/party_menu.c b/src/party_menu.c index 46d5a16c1..c711881b0 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -72,11 +72,26 @@ #include "constants/items.h" #include "constants/maps.h" #include "constants/moves.h" +#include "constants/party_menu.h" #include "constants/rgb.h" #include "constants/songs.h" #include "constants/species.h" #include "constants/vars.h" +#define PARTY_PAL_SELECTED (1 << 0) +#define PARTY_PAL_FAINTED (1 << 1) +#define PARTY_PAL_TO_SWITCH (1 << 2) +#define PARTY_PAL_MULTI_ALT (1 << 3) +#define PARTY_PAL_SWITCHING (1 << 4) +#define PARTY_PAL_TO_SOFTBOIL (1 << 5) +#define PARTY_PAL_NO_MON (1 << 6) +#define PARTY_PAL_UNUSED (1 << 7) + +#define MENU_DIR_DOWN 1 +#define MENU_DIR_UP -1 +#define MENU_DIR_RIGHT 2 +#define MENU_DIR_LEFT -2 + enum { CAN_LEARN_MOVE, @@ -85,28 +100,28 @@ enum CANNOT_LEARN_MOVE_IS_EGG }; -struct Unk_Rodata1 +struct PartyMenuBoxInfoRects { - void (*unk0)(u8, u8, u8, u8, u8, u8); - u8 unk4[24]; - u8 unk1C; - u8 unk1D; - u8 unk1E; - u8 unk1F; + void (*blitFunc)(u8, u8, u8, u8, u8, u8); + u8 dimensions[24]; + u8 descTextLeft; + u8 descTextTop; + u8 descTextWidth; + u8 descTextHeight; }; -struct Struct203CEC4 +struct PartyMenuInternal { TaskFunc task; MainCallback exitCallback; - u32 unk8_0:1; - u32 unk8_1:3; - u32 unk8_2:7; - u32 unk9_0:7; + u32 chooseHalf:1; + u32 lastSelectedSlot:3; // Used to return to same slot when going left/right bewtween columns + u32 spriteIdConfirmPokeball:7; + u32 spriteIdCancelPokeball:7; u32 messageId:14; u8 windowId[3]; u8 actions[8]; - u8 listSize; + u8 numActions; // In vanilla Emerald, only the first 0xB0 hwords (0x160 bytes) are actually used. // However, a full 0x100 hwords (0x200 bytes) are allocated. // It is likely that the 0x160 value used below is a constant defined by @@ -115,10 +130,10 @@ struct Struct203CEC4 s16 data[16]; }; -struct Struct203CEDC +struct PartyMenuBox { - const struct Unk_Rodata1 *unk0; - const u8 *unk4; + const struct PartyMenuBoxInfoRects *infoRects; + const u8 *spriteCoords; u8 windowId; u8 monSpriteId; u8 itemSpriteId; @@ -127,268 +142,267 @@ struct Struct203CEDC }; // EWRAM vars -static EWRAM_DATA struct Struct203CEC4 *gUnknown_0203CEC4 = NULL; -EWRAM_DATA struct Struct203CEC8 gUnknown_0203CEC8 = {0}; -static EWRAM_DATA struct Struct203CEDC *gUnknown_0203CEDC = NULL; -static EWRAM_DATA u8 *gUnknown_0203CEE0 = NULL; -static EWRAM_DATA u8 *gUnknown_0203CEE4 = NULL; -EWRAM_DATA u8 gUnknown_0203CEE8 = 0; -EWRAM_DATA u8 gUnknown_0203CEE9 = 0; +static EWRAM_DATA struct PartyMenuInternal *sPartyMenuInternal = NULL; +EWRAM_DATA struct PartyMenu gPartyMenu = {0}; +static EWRAM_DATA struct PartyMenuBox *sPartyMenuBoxes = NULL; +static EWRAM_DATA u8 *sPartyBgGfxTilemap = NULL; +static EWRAM_DATA u8 *sPartyBgTilemapBuffer = NULL; +EWRAM_DATA bool8 gPartyMenuUseExitCallback = 0; +EWRAM_DATA u8 gSelectedMonPartyId = 0; EWRAM_DATA MainCallback gPostMenuFieldCallback = NULL; -static EWRAM_DATA u16 *gUnknown_0203CEF0 = 0; -static EWRAM_DATA u16 *gUnknown_0203CEF4 = 0; +static EWRAM_DATA u16 *sSlot1TilemapBuffer = 0; // for switching party slots +static EWRAM_DATA u16 *sSlot2TilemapBuffer = 0; // EWRAM_DATA u8 gSelectedOrderFromParty[4] = {0}; -static EWRAM_DATA u16 gUnknown_0203CEFC = 0; -static EWRAM_DATA u16 gUnknown_0203CEFE = 0; // unused -EWRAM_DATA u8 gUnknown_0203CF00[3] = {0}; +static EWRAM_DATA u16 sPartyMenuItemId = 0; +static EWRAM_DATA u16 sUnused_0203CEFE = 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 -void (*gUnknown_03006328)(u8, TaskFunc); +void (*gItemUseCB)(u8, TaskFunc); -static void reset_brm(void); -static void PartyMenuInitCallback(void); -static bool8 PartyMenuSetup(void); -static void sub_81B209C(void); -static void PartyMenuExit(void); +static void ResetPartyMenu(void); +static void CB2_InitPartyMenu(void); +static bool8 ShowPartyMenu(void); +static void SetPartyMonsAllowedInMinigame(void); +static void ExitPartyMenu(void); static bool8 AllocPartyMenuBg(void); -static bool8 AllocPartyMiscGfx(void); -static void sub_81B239C(u8); -static void PartyMenuInitHelperStructs(u8); +static bool8 AllocPartyMenuBgGfx(void); +static void InitPartyMenuWindows(u8); +static void InitPartyMenuBoxes(u8); static void LoadPartyMenuPokeballGfx(void); static void LoadPartyMenuAilmentGfx(void); -static bool8 party_menu_add_per_mon_objects(void); +static bool8 CreatePartyMonSpritesLoop(void); static bool8 RenderPartyMenuBoxes(void); -static void sub_81B0F28(void); -static void sub_81B2428(u8); -static void PartyMenuExitTask(u8); +static void CreateCancelConfirmPokeballSprites(void); +static void CreateCancelConfirmWindows(u8); +static void Task_ExitPartyMenu(u8); static void FreePartyPointers(void); static void PartyPaletteBufferCopy(u8); -static void sub_81B0CEC(u8); -static void UpdateSelectedPartyBox(struct Struct203CEDC *, u8); +static void DisplayPartyPokemonDataForMultiBattle(u8); +static void LoadPartyBoxPalette(struct PartyMenuBox *, u8); static void DrawEmptySlot(u8 windowId); -static void DisplayPartyPokemonSelectForRelearner(u8); -static void DisplayPartyPokemonSelectForContest(u8); -static void DisplayPartyPokemonSelectForBattle(u8); -static void sub_81B0B98(u8); -static void DisplayPartyPokemonSelectHeldItemRelated(u8); -static bool8 sub_81B0BFC(u8); +static void DisplayPartyPokemonDataForRelearner(u8); +static void DisplayPartyPokemonDataForContest(u8); +static void DisplayPartyPokemonDataForChooseHalf(u8); +static void DisplayPartyPokemonDataForWirelessMinigame(u8); +static void DisplayPartyPokemonDataForBattlePyramidHeldItem(u8); +static bool8 DisplayPartyPokemonDataForMoveTutorOrEvolutionItem(u8); static void DisplayPartyPokemonData(u8); -static void DisplayPartyPokemonNickname(struct Pokemon *, struct Struct203CEDC *, u8); -static void DisplayPartyPokemonLevelCheck(struct Pokemon *, struct Struct203CEDC *, u8); -static void DisplayPartyPokemonGenderNidoranCheck(struct Pokemon *, struct Struct203CEDC *, u8); -static void DisplayPartyPokemonHPCheck(struct Pokemon *, struct Struct203CEDC *, u8); -static void DisplayPartyPokemonMaxHPCheck(struct Pokemon *, struct Struct203CEDC *, u8); -static void DisplayPartyPokemonHPBarCheck(struct Pokemon *, struct Struct203CEDC *); -static void DisplayPartyPokemonSelectionText(u8, struct Struct203CEDC *, u8); -static u8 sub_81B8830(void); -static bool8 GetBattleEntryEligibility(struct Pokemon *); -static bool8 sub_81B218C(u8); -static void DisplayPartyPokemonSelectToTeachMove(u8, u16, u8); +static void DisplayPartyPokemonNickname(struct Pokemon *, struct PartyMenuBox *, u8); +static void DisplayPartyPokemonLevelCheck(struct Pokemon *, struct PartyMenuBox *, u8); +static void DisplayPartyPokemonGenderNidoranCheck(struct Pokemon *, struct PartyMenuBox *, u8); +static void DisplayPartyPokemonHPCheck(struct Pokemon *, struct PartyMenuBox *, u8); +static void DisplayPartyPokemonMaxHPCheck(struct Pokemon *, struct PartyMenuBox *, u8); +static void DisplayPartyPokemonHPBarCheck(struct Pokemon *, struct PartyMenuBox *); +static void DisplayPartyPokemonDescriptionText(u8, struct PartyMenuBox *, u8); +static bool8 IsMonAllowedInMinigame(u8); +static void DisplayPartyPokemonDataToTeachMove(u8, u16, u8); static u8 CanMonLearnTMTutor(struct Pokemon *, u16, u8); static void DisplayPartyPokemonBarDetail(u8, const u8*, u8, const u8*); -static void DisplayPartyPokemonLevel(u8, struct Struct203CEDC *); -static void DisplayPartyPokemonGender(u8, u16, u8*, struct Struct203CEDC *); -static void DisplayPartyPokemonHP(u16, struct Struct203CEDC *); -static void DisplayPartyPokemonMaxHP(u16, struct Struct203CEDC *); -static void DisplayPartyPokemonHPBar(u16, u16, struct Struct203CEDC *); -static void party_menu_link_mon_icon_anim(u16, u32, struct Struct203CEDC *, u8, u32); -static void party_menu_link_mon_held_item_object(u16, u16, struct Struct203CEDC *); -static void party_menu_link_mon_pokeball_object(u16, struct Struct203CEDC *); -static void party_menu_link_mon_status_condition_object(u16, u8, struct Struct203CEDC *); -static void party_menu_held_item_object(struct Pokemon *, struct Struct203CEDC *); -static void party_menu_pokeball_object(struct Pokemon *, struct Struct203CEDC *); -static void party_menu_icon_anim(struct Pokemon *, struct Struct203CEDC *, u32); -static void party_menu_status_condition_object(struct Pokemon *, struct Struct203CEDC *); -static u8 sub_81B5F74(u8, u8); -static void sub_81B120C(void); -static u8 sub_81B5F34(u8, u8); +static void DisplayPartyPokemonLevel(u8, struct PartyMenuBox *); +static void DisplayPartyPokemonGender(u8, u16, u8*, struct PartyMenuBox *); +static void DisplayPartyPokemonHP(u16, struct PartyMenuBox *); +static void DisplayPartyPokemonMaxHP(u16, struct PartyMenuBox *); +static void DisplayPartyPokemonHPBar(u16, u16, struct PartyMenuBox *); +static void CreatePartyMonIconSpriteParameterized(u16, u32, struct PartyMenuBox *, u8, u32); +static void CreatePartyMonHeldItemSpriteParameterized(u16, u16, struct PartyMenuBox *); +static void CreatePartyMonPokeballSpriteParameterized(u16, struct PartyMenuBox *); +static void CreatePartyMonStatusSpriteParameterized(u16, u8, struct PartyMenuBox *); +// These next 4 functions are essentially redundant with the above 4 +// The only difference is that rather than receive the data directly they retrieve it from the mon struct +static void CreatePartyMonHeldItemSprite(struct Pokemon *, struct PartyMenuBox *); +static void CreatePartyMonPokeballSprite(struct Pokemon *, struct PartyMenuBox *); +static void CreatePartyMonIconSprite(struct Pokemon *, struct PartyMenuBox *, u32); +static void CreatePartyMonStatusSprite(struct Pokemon *, struct PartyMenuBox *); +static u8 CreateSmallPokeballButtonSprite(u8, u8); +static void DrawCancelConfirmButtons(void); +static u8 CreatePokeballButtonSprite(u8, u8); static void AnimateSelectedPartyIcon(u8, u8); -static void sub_81B5F98(u8, u8); -static u8 GetPartyBoxPalBitfield(u8, u8); +static void PartyMenuStartSpriteAnim(u8, u8); +static u8 GetPartyBoxPaletteFlags(u8, u8); static bool8 PartyBoxPal_ParnterOrDisqualifiedInArena(u8); -static u8 sub_81B8F38(u8); +static u8 GetPartyIdFromBattleSlot(u8); static void Task_ClosePartyMenuAndSetCB2(u8); -static void sub_81B9080(void); -static void sub_81B4F88(void); -static void sub_81B15D0(u8, s8*); -static void sub_81B140C(u8, s8*); +static void UpdatePartyToFieldOrder(void); +static void MoveCursorToConfirm(void); +static void HandleChooseMonCancel(u8, s8*); +static void HandleChooseMonSelection(u8, s8*); static u16 PartyMenuButtonHandler(s8*); -static s8* sub_81B13EC(void); -static bool8 sub_81B15A4(u8*); +static s8* GetCurrentPartySlotPtr(void); +static bool8 IsSelectedMonNotEgg(u8*); static void PartyMenuRemoveWindow(u8*); -static void sub_81B9140(void); -static void sub_81B6794(u8); -static void sub_81B7E4C(u8); -static void sub_81B8474(u8); -static void sub_81B7FAC(u8); -static void sub_81B3938(u8); -static void sub_81B21AC(u8, u8); -static void sub_81B36FC(u8); -static void sub_81B407C(u8); -static void sub_81B2210(u8); -static bool8 sub_81B1660(u8); -static const u8* sub_81B88BC(void); -static void sub_81B16D4(u8); -static void sub_81B334C(void); -static void sub_81B1708(u8); -static void sub_81B1C1C(u8); +static void CB2_SetUpExitToBattleScreen(void); +static void Task_ClosePartyMenuAfterText(u8); +static void TryTutorSelectedMon(u8); +static void TryGiveMailToSelectedMon(u8); +static void TryGiveItemOrMailToSelectedMon(u8); +static void SwitchSelectedMons(u8); +static void TryEnterMonForMinigame(u8, u8); +static void Task_TryCreateSelectionWindow(u8); +static void FinishTwoMonAction(u8); +static void CancelParticipationPrompt(u8); +static bool8 DisplayCancelChooseMonYesNo(u8); +static const u8* GetFacilityCancelString(void); +static void Task_CancelChooseMonYesNo(u8); +static void PartyMenuDisplayYesNoMenu(void); +static void Task_HandleCancelChooseMonYesNoInput(u8); +static void Task_ReturnToChooseMonAfterText(u8); static void UpdateCurrentPartySelection(s8*, s8); -static void SetNewPartySelectTarget1(s8*, s8); -static void SetNewPartySelectTarget2(s8*, s8); -static s8 sub_81B1B00(s8, s8); +static void UpdatePartySelectionSingleLayout(s8*, s8); +static void UpdatePartySelectionDoubleLayout(s8*, s8); +static s8 GetNewSlotDoubleLayout(s8, s8); static void PartyMenuPrintText(const u8*); -static void sub_81B1B8C(u8); -static void DisplayPartyPokemonHPCheck(struct Pokemon*, struct Struct203CEDC*, u8); -static void DisplayPartyPokemonHPBarCheck(struct Pokemon*, struct Struct203CEDC*); +static void Task_PrintAndWaitForText(u8); static bool16 IsMonAllowedInPokemonJump(struct Pokemon*); -static bool16 sub_81B2164(struct Pokemon*); -static void sub_81B2248(u8); -static void sub_81B227C(u8); +static bool16 IsMonAllowedInDodrioBerryPicking(struct Pokemon*); +static void Task_CancelParticipationYesNo(u8); +static void Task_HandleCancelParticipationYesNoInput(u8); static bool8 CanLearnTutorMove(u16, u8); static u16 GetTutorMove(u8); -static bool8 sub_81B314C(void); -static void CreateActionList(struct Pokemon*, u8); -static u8 sub_81B8A2C(struct Pokemon*); -static u8 sub_81B856C(s8); -static void sub_81B469C(u8); -static void HandleMenuInput(u8); -static void sub_81B3828(void); -static void pokemon_change_order(void); -static void sub_81B3894(void); -static void sub_81B3CC0(u8); -static void sub_81B3D48(u8); -static void swap_pokemon_and_oams(void); -static void sub_81B3E60(u8); -static void sub_81B41C4(void); -static void c2_8123744(void); -static void sub_81B452C(void); -static void sub_81B4350(u8); -static void sub_81B42D0(u8); -static void sub_81B43A8(u8); -static void sub_81B43DC(u8); -static void sub_81B44FC(u8); -static void sub_81B4578(void); -static void sub_81B4624(u8); -static void sub_81B5C94(struct Pokemon*, struct Struct203CEDC*); -static void sub_81B48A8(u8); -static void sub_81B48DC(u8); -static void sub_81B4988(u8); -static void sub_81B4A98(void); -static void sub_81B4AE0(void); -static void sub_81B4B6C(u8); -static void sub_81B4BA0(u8); -static void sub_81B4C60(u8); -static void sub_81B4C94(u8); -static bool8 sub_81B8A7C(void); -static void sub_81B53FC(u8); -static void sub_81B5430(u8); -static void task_brm_cancel_1_on_keypad_a_or_b(u8); -static void sub_81B5674(u8); -static void sub_81B57DC(void); -static void sub_81B5864(void); -static void sub_81B56A4(u8); -static void sub_81B56D8(u8); -static void task_launch_hm_phase_2(u8); -static u16 brm_get_selected_species(void); -static void sub_81B5B38(u8, struct Pokemon*); -static void UpdatePartyMonIconFrame(struct Sprite*); -static void UpdatePartyMonIconFrameAndBounce(struct Sprite*); -static void sub_81B5CB0(u16, struct Struct203CEDC*); +static bool8 ShouldUseChooseMonText(void); +static void SetPartyMonFieldSelectionActions(struct Pokemon*, u8); +static u8 GetPartyMenuActionsTypeInBattle(struct Pokemon*); +static u8 GetPartySlotEntryStatus(s8); +static void Task_UpdateHeldItemSprite(u8); +static void Task_HandleSelectionMenuInput(u8); +static void CB2_ShowPokemonSummaryScreen(void); +static void UpdatePartyToBattleOrder(void); +static void CB2_ReturnToPartyMenuFromSummaryScreen(void); +static void SlidePartyMenuBoxOneStep(u8); +static void Task_SlideSelectedSlotsOffscreen(u8); +static void SwitchPartyMon(void); +static void Task_SlideSelectedSlotsOnscreen(u8); +static void CB2_SelectBagItemToGive(void); +static void CB2_GiveHoldItem(void); +static void CB2_WriteMailToGiveMon(void); +static void Task_SwitchHoldItemsPrompt(u8); +static void Task_GiveHoldItem(u8); +static void Task_SwitchItemsYesNo(u8); +static void Task_HandleSwitchItemsYesNoInput(u8); +static void Task_WriteMailToGiveMonAfterText(u8); +static void CB2_ReturnToPartyMenuFromWritingMail(void); +static void Task_DisplayGaveMailFromPartyMessage(u8); +static void UpdatePartyMonHeldItemSprite(struct Pokemon*, struct PartyMenuBox*); +static void Task_TossHeldItemYesNo(u8 taskId); +static void Task_HandleTossHeldItemYesNoInput(u8); +static void Task_TossHeldItem(u8); +static void CB2_ReadHeldMail(void); +static void CB2_ReturnToPartyMenuFromReadingMail(void); +static void Task_SendMailToPCYesNo(u8); +static void Task_HandleSendMailToPCYesNoInput(u8); +static void Task_LoseMailMessageYesNo(u8); +static void Task_HandleLoseMailMessageYesNoInput(u8); +static bool8 TrySwitchInPokemon(void); +static void Task_SpinTradeYesNo(u8); +static void Task_HandleSpinTradeYesNoInput(u8); +static void Task_CancelAfterAorBPress(u8); +static void DisplayFieldMoveExitAreaMessage(u8); +static void DisplayCantUseFlashMessage(void); +static void DisplayCantUseSurfMessage(void); +static void Task_FieldMoveExitAreaYesNo(u8); +static void Task_HandleFieldMoveExitAreaYesNoInput(u8); +static void Task_FieldMoveWaitForFade(u8); +static u16 GetFieldMoveMonSpecies(void); +static void UpdatePartyMonHPBar(u8, struct Pokemon*); +static void SpriteCB_UpdatePartyMonIcon(struct Sprite*); +static void SpriteCB_BouncePartyMonIcon(struct Sprite*); +static void ShowOrHideHeldItemSprite(u16, struct PartyMenuBox*); static void CreateHeldItemSpriteForTrade(u8, bool8); static void SpriteCB_HeldItem(struct Sprite*); -static void party_menu_get_status_condition_and_update_object(struct Pokemon*, struct Struct203CEDC*); -static void party_menu_update_status_condition_object(u8, struct Struct203CEDC*); -static u8 sub_81B8984(void); -static void sub_81B6280(u8); -static void c2_815ABFC(void); -static void sub_81B672C(u8); +static void SetPartyMonAilmentGfx(struct Pokemon*, struct PartyMenuBox*); +static void UpdatePartyMonAilmentGfx(u8, struct PartyMenuBox*); +static u8 GetPartyLayoutFromBattleType(void); +static void Task_SetSacredAshCB(u8); +static void CB2_ReturnToBagMenu(void); +static void Task_DisplayHPRestoredMessage(u8); static u16 ItemEffectToMonEv(struct Pokemon*, u8); static void ItemEffectToStatString(u8, u8*); -static void sub_81B6BB4(u8); -static void ether_effect_related_2(u8); -static void ether_effect_related(u8); -static void sub_81B6EB4(u8); -static void sub_81B6FF4(u8); -static void sub_81B6F60(u8); -static void sub_81B6F98(u8); -static void sub_81B77AC(u8); -static void sub_81B7028(u8); -static void sub_81B7088(u8); -static void sub_81B7230(u8); -static void sub_81B70B8(void); -static void sub_81B70F0(void); -static void sub_81B711C(u8); -static void sub_81B7154(u8); -static void sub_81B71D4(u8); -static void sub_81B7294(u8); -static void sub_81B72C8(u8); -static void sub_81B73E4(u8); -static void sub_81B79A0(struct Pokemon*, s16*); -static void sub_81B754C(u8, struct Pokemon*); -static void sub_81B75D4(u8); -static void sub_81B767C(u8); -static void sub_81B7634(u8); -static void sub_81B76C8(u8); -static void sub_81B7704(u8); -static void sub_81B7810(u8); -static void sub_81B787C(u8); -static void sub_81B7910(u8, u16); -static void sub_81B7A28(u8); -static void task_sacred_ash_party_loop(u8); -static void sub_81B7C10(u8); -static void sub_81B8044(u8); -static void sub_81B83B8(u8); -static void sub_81B82A0(u8); -static void sub_81B83F0(u16); -static void sub_81B814C(void); -static void sub_81B8088(u8); -static void sub_81B8104(u8); -static void sub_81B81A8(void); -static bool8 sub_81B841C(u16); -static void sub_81B8230(u8); -static void sub_81B82D4(u8); -static void sub_81B879C(u8); +static void ReturnToUseOnWhichMon(u8); +static void SetSelectedMoveForPPItem(u8); +static void TryUsePPItem(u8); +static void Task_LearnedMove(u8); +static void Task_ReplaceMoveYesNo(u8); +static void Task_DoLearnedMoveFanfareAfterText(u8); +static void Task_LearnNextMoveOrClosePartyMenu(u8); +static void Task_TryLearningNextMove(u8); +static void Task_HandleReplaceMoveYesNoInput(u8); +static void Task_ShowSummaryScreenToForgetMove(u8); +static void StopLearningMovePrompt(u8); +static void CB2_ShowSummaryScreenToForgetMove(void); +static void CB2_ReturnToPartyMenuWhileLearningMove(void); +static void Task_ReturnToPartyMenuWhileLearningMove(u8); +static void DisplayPartyMenuForgotMoveMessage(u8); +static void Task_PartyMenuReplaceMove(u8); +static void Task_StopLearningMoveYesNo(u8); +static void Task_HandleStopLearningMoveYesNoInput(u8); +static void Task_TryLearningNextMoveAfterText(u8); +static void BufferMonStatsToTaskData(struct Pokemon*, s16*); +static void UpdateMonDisplayInfoAfterRareCandy(u8, struct Pokemon*); +static void Task_DisplayLevelUpStatsPg1(u8); +static void DisplayLevelUpStatsPg1(u8); +static void Task_DisplayLevelUpStatsPg2(u8); +static void DisplayLevelUpStatsPg2(u8); +static void Task_TryLearnNewMoves(u8); +static void PartyMenuTryEvolution(u8); +static void DisplayMonNeedsToReplaceMove(u8); +static void DisplayMonLearnedMove(u8, u16); +static void UseSacredAsh(u8); +static void Task_SacredAshLoop(u8); +static void Task_SacredAshDisplayHPRestored(u8); +static void GiveItemOrMailToSelectedMon(u8); +static void DisplayItemMustBeRemovedFirstMessage(u8); +static void Task_SwitchItemsFromBagYesNo(u8); +static void RemoveItemToGiveFromBag(u16); +static void CB2_WriteMailToGiveMonFromBag(void); +static void GiveItemToSelectedMon(u8); +static void Task_UpdateHeldItemSpriteAndClosePartyMenu(u8); +static void CB2_ReturnToPartyOrBagMenuFromWritingMail(void); +static bool8 ReturnGiveItemToBagOrPC(u16); +static void Task_DisplayGaveMailFromBagMessage(u8); +static void Task_HandleSwitchItemsFromBagYesNoInput(u8); +static void Task_ValidateChosenHalfParty(u8); static bool8 GetBattleEntryEligibility(struct Pokemon*); -static bool8 sub_81B8770(u8); -static u8 sub_81B8888(void); -static u8 sub_81B885C(void); -static void sub_81B87E8(u8); -static void sub_81B8C88(u8*, bool8); -static void sub_81B8D88(u8*, u8, u8); -static void sub_81B917C(u8); -static void sub_81B91B4(u8); -static void sub_81B9294(u8); -static void sub_81B9240(u8); -static void sub_81B9390(void); -static void task_hm_without_phase_2(u8); -static void sub_81B9424(u8); -static void sub_81B9470(void); -static void sub_81B94D0(u8); -static void sub_81B953C(u8); -static void sub_81B9588(void); -static void sub_81B9640(u8); -static void sub_81B97DC(struct Pokemon*, u8, u8); -static void BlitBitmapToPartyWindow_Default1(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 f); -static void BlitBitmapToPartyWindow_Default2(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 f); -static void CursorCb_Summary(u8 taskId); -static void CursorCb_Switch(u8 taskId); -static void CursorCb_Cancel1(u8 taskId); -static void CursorCb_Item(u8 taskId); -static void CursorCb_Give(u8 taskId); -static void CursorCb_TakeItem(u8 taskId); -static void CursorCb_Mail(u8 taskId); -static void CursorCb_Read(u8 taskId); -static void CursorCb_TakeMail(u8 taskId); -static void CursorCb_Cancel2(u8 taskId); -static void CursorCb_SendMon(u8 taskId); -static void CursorCb_Enter(u8 taskId); -static void CursorCb_NoEntry(u8 taskId); -static void CursorCb_Store(u8 taskId); -static void CursorCb_Register(u8 taskId); -static void CursorCb_Trade1(u8 taskId); -static void CursorCb_Trade2(u8 taskId); -static void CursorCb_Toss(u8 taskId); -static void CursorCb_FieldMove(u8 taskId); +static bool8 HasPartySlotAlreadyBeenSelected(u8); +static u8 GetBattleEntryLevelCap(void); +static u8 GetMaxBattleEntries(void); +static u8 GetMinBattleEntries(void); +static void Task_ContinueChoosingHalfParty(u8); +static void BufferBattlePartyOrder(u8*, bool8); +static void BufferBattlePartyOrderBySide(u8*, u8, u8); +static void Task_InitMultiPartnerPartySlideIn(u8); +static void Task_MultiPartnerPartySlideIn(u8); +static void SlideMultiPartyMenuBoxSpritesOneStep(u8); +static void Task_WaitAfterMultiPartnerPartySlideIn(u8); +static void BufferMonSelection(void); +static void Task_PartyMenuWaitForFade(u8 taskId); +static void Task_ChooseContestMon(u8 taskId); +static void CB2_ChooseContestMon(void); +static void Task_ChoosePartyMon(u8 taskId); +static void Task_ChooseMonForMoveRelearner(u8); +static void CB2_ChooseMonForMoveRelearner(void); +static void Task_BattlePyramidChooseMonHeldItems(u8); +static void ShiftMoveSlot(struct Pokemon*, u8, u8); +static void BlitBitmapToPartyWindow_LeftColumn(u8, u8, u8, u8, u8, u8); +static void BlitBitmapToPartyWindow_RightColumn(u8, u8, u8, u8, u8, u8); +static void CursorCb_Summary(u8); +static void CursorCb_Switch(u8); +static void CursorCb_Cancel1(u8); +static void CursorCb_Item(u8); +static void CursorCb_Give(u8); +static void CursorCb_TakeItem(u8); +static void CursorCb_Mail(u8); +static void CursorCb_Read(u8); +static void CursorCb_TakeMail(u8); +static void CursorCb_Cancel2(u8); +static void CursorCb_SendMon(u8); +static void CursorCb_Enter(u8); +static void CursorCb_NoEntry(u8); +static void CursorCb_Store(u8); +static void CursorCb_Register(u8); +static void CursorCb_Trade1(u8); +static void CursorCb_Trade2(u8); +static void CursorCb_Toss(u8); +static void CursorCb_FieldMove(u8); static bool8 SetUpFieldMove_Surf(void); static bool8 SetUpFieldMove_Fly(void); static bool8 SetUpFieldMove_Waterfall(void); @@ -396,1234 +410,56 @@ static bool8 SetUpFieldMove_Dive(void); // static const data #include "data/pokemon/tutor_learnsets.h" - -static const struct BgTemplate gUnknown_086156B8[] = -{ - { - .bg = 0, - .charBaseIndex = 0, - .mapBaseIndex = 31, - .screenSize = 0, - .paletteMode = 0, - .priority = 1, - .baseTile = 0 - }, - { - .bg = 1, - .charBaseIndex = 0, - .mapBaseIndex = 30, - .screenSize = 0, - .paletteMode = 0, - .priority = 2, - .baseTile = 0 - }, - { - .bg = 2, - .charBaseIndex = 0, - .mapBaseIndex = 28, - .screenSize = 1, - .paletteMode = 0, - .priority = 0, - .baseTile = 0 - }, -}; - -static const struct Unk_Rodata1 gUnknown_086156C4[] = -{ - {BlitBitmapToPartyWindow_Default1, {0x18, 0xB, 0x28, 0xD, 0x20, 0x14, 0x20, 8, 0x40, 0x14, 8, 8, 0x26, 0x25, 0x18, 8, 0x35, 0x25, 0x18, 8, 0x18, 0x23, 0x30, 3}, 0xC, 0x22, 0x40, 0x10}, - {BlitBitmapToPartyWindow_Default2, {0x16, 3, 0x28, 0xD, 0x1E, 0xC, 0x20, 8, 0x3E, 0xC, 8, 8, 0x66, 0xC, 0x18, 8, 0x75, 0xC, 0x18, 8, 0x58, 0xA, 0x30, 3}, 0x4D, 4, 0x40, 0x10}, -}; - -static const u8 gUnknown_08615704[][6][8] = -{ - { - {16, 40, 20, 50, 50, 52, 16, 34}, - {104, 18, 108, 28, 136, 27, 102, 25}, - {104, 42, 108, 52, 136, 51, 102, 49}, - {104, 66, 108, 76, 136, 75, 102, 73}, - {104, 90, 108, 100, 136, 99, 102, 97}, - {104, 114, 108, 124, 136, 123, 102, 121}, - }, - { - {16, 24, 20, 34, 50, 36, 16, 18}, - {16, 80, 20, 90, 50, 92, 16, 74}, - {104, 18, 108, 28, 136, 27, 102, 25}, - {104, 50, 108, 60, 136, 59, 102, 57}, - {104, 82, 108, 92, 136, 91, 102, 89}, - {104, 114, 108, 124, 136, 123, 102, 121}, - }, - { - {16, 24, 20, 34, 50, 36, 16, 18}, - {16, 80, 20, 90, 50, 92, 16, 74}, - {104, 26, 106, 36, 136, 35, 102, 33}, - {104, 50, 106, 60, 136, 59, 102, 57}, - {104, 82, 106, 92, 136, 91, 102, 89}, - {104, 106, 106, 116, 136, 115, 102, 113}, - }, - { - {16, 32, 20, 42, 50, 44, 16, 26}, - {104, 34, 106, 44, 136, 43, 102, 41}, - {104, 58, 106, 68, 136, 67, 102, 65}, - {16, 104, 20, 114, 50, 116, 16, 98}, - {104, 106, 106, 116, 136, 115, 102, 113}, - {104, 130, 106, 140, 136, 139, 102, 137}, - }, -}; - -static const u32 gUnknown_086157C4[] = INCBIN_U32("graphics/interface/unknown_6157C4.bin"); -static const u32 gUnknown_086157E0[] = INCBIN_U32("graphics/interface/unknown_6157E0.bin"); - -static const u8 sFontColorTable[][3] = -{ - {0, 3, 2}, - {0, 1, 6}, - {0, 11, 12}, - {1, 2, 3}, - {1, 8, 9}, - {0, 1, 2}, -}; - -static const struct WindowTemplate gUnknown_08615810[] = -{ - { - .bg = 0, - .tilemapLeft = 1, - .tilemapTop = 3, - .width = 10, - .height = 7, - .paletteNum = 3, - .baseBlock = 0x63, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 1, - .width = 18, - .height = 3, - .paletteNum = 4, - .baseBlock = 0xA9, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 4, - .width = 18, - .height = 3, - .paletteNum = 5, - .baseBlock = 0xDF, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 7, - .width = 18, - .height = 3, - .paletteNum = 6, - .baseBlock = 0x115, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 10, - .width = 18, - .height = 3, - .paletteNum = 7, - .baseBlock = 0x14B, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 13, - .width = 18, - .height = 3, - .paletteNum = 8, - .baseBlock = 0x181, - }, - { - .bg = 2, - .tilemapLeft = 1, - .tilemapTop = 15, - .width = 28, - .height = 4, - .paletteNum = 14, - .baseBlock = 0x1DF, - }, - DUMMY_WIN_TEMPLATE -}; - -static const struct WindowTemplate gUnknown_08615850[] = -{ - { - .bg = 0, - .tilemapLeft = 1, - .tilemapTop = 1, - .width = 10, - .height = 7, - .paletteNum = 3, - .baseBlock = 0x63, - }, - { - .bg = 0, - .tilemapLeft = 1, - .tilemapTop = 8, - .width = 10, - .height = 7, - .paletteNum = 4, - .baseBlock = 0xA9, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 1, - .width = 18, - .height = 3, - .paletteNum = 5, - .baseBlock = 0xEF, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 5, - .width = 18, - .height = 3, - .paletteNum = 6, - .baseBlock = 0x125, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 9, - .width = 18, - .height = 3, - .paletteNum = 7, - .baseBlock = 0x15B, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 13, - .width = 18, - .height = 3, - .paletteNum = 8, - .baseBlock = 0x191, - }, - { - .bg = 2, - .tilemapLeft = 1, - .tilemapTop = 15, - .width = 28, - .height = 4, - .paletteNum = 14, - .baseBlock = 0x1DF, - }, - DUMMY_WIN_TEMPLATE -}; - -static const struct WindowTemplate gUnknown_08615890[] = -{ - { - .bg = 0, - .tilemapLeft = 1, - .tilemapTop = 1, - .width = 10, - .height = 7, - .paletteNum = 3, - .baseBlock = 0x63, - }, - { - .bg = 0, - .tilemapLeft = 1, - .tilemapTop = 8, - .width = 10, - .height = 7, - .paletteNum = 4, - .baseBlock = 0xA9, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 2, - .width = 18, - .height = 3, - .paletteNum = 5, - .baseBlock = 0xEF, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 5, - .width = 18, - .height = 3, - .paletteNum = 6, - .baseBlock = 0x125, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 9, - .width = 18, - .height = 3, - .paletteNum = 7, - .baseBlock = 0x15B, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 12, - .width = 18, - .height = 3, - .paletteNum = 8, - .baseBlock = 0x191, - }, - { - .bg = 2, - .tilemapLeft = 1, - .tilemapTop = 15, - .width = 28, - .height = 4, - .paletteNum = 14, - .baseBlock = 0x1DF, - }, - DUMMY_WIN_TEMPLATE -}; - -static const struct WindowTemplate gUnknown_086158D0[] = -{ - { - .bg = 0, - .tilemapLeft = 1, - .tilemapTop = 2, - .width = 10, - .height = 7, - .paletteNum = 3, - .baseBlock = 0x63, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 3, - .width = 18, - .height = 3, - .paletteNum = 5, - .baseBlock = 0xA9, - }, - { - .bg = 0, - .tilemapLeft = 12, - .tilemapTop = 6, - .width = 18, - .height = 3, - .paletteNum = 6, - .baseBlock = 0xDF, - }, - { - .bg = 2, - .tilemapLeft = 1, - .tilemapTop = 11, - .width = 10, - .height = 7, - .paletteNum = 4, - .baseBlock = 0x115, - }, - { - .bg = 2, - .tilemapLeft = 12, - .tilemapTop = 12, - .width = 18, - .height = 3, - .paletteNum = 7, - .baseBlock = 0x16B, - }, - { - .bg = 2, - .tilemapLeft = 12, - .tilemapTop = 15, - .width = 18, - .height = 3, - .paletteNum = 8, - .baseBlock = 0x1A1, - }, - DUMMY_WIN_TEMPLATE -}; - -static const struct WindowTemplate gUnknown_08615908 = -{ - .bg = 0, - .tilemapLeft = 24, - .tilemapTop = 17, - .width = 6, - .height = 2, - .paletteNum = 3, - .baseBlock = 0x1C7, -}; - -static const struct WindowTemplate gUnknown_08615910 = -{ - .bg = 0, - .tilemapLeft = 24, - .tilemapTop = 18, - .width = 6, - .height = 2, - .paletteNum = 3, - .baseBlock = 0x1C7, -}; - -static const struct WindowTemplate gUnknown_08615918 = -{ - .bg = 0, - .tilemapLeft = 24, - .tilemapTop = 16, - .width = 6, - .height = 2, - .paletteNum = 3, - .baseBlock = 0x1D3, -}; - -static const struct WindowTemplate gUnknown_08615920 = -{ - .bg = 2, - .tilemapLeft = 1, - .tilemapTop = 17, - .width = 21, - .height = 2, - .paletteNum = 15, - .baseBlock = 0x24F, -}; - -static const struct WindowTemplate gUnknown_08615928 = -{ - .bg = 2, - .tilemapLeft = 1, - .tilemapTop = 17, - .width = 16, - .height = 2, - .paletteNum = 15, - .baseBlock = 0x279, -}; - -static const struct WindowTemplate gUnknown_08615930 = -{ - .bg = 2, - .tilemapLeft = 1, - .tilemapTop = 17, - .width = 20, - .height = 2, - .paletteNum = 15, - .baseBlock = 0x299, -}; - -static const struct WindowTemplate gUnknown_08615938 = -{ - .bg = 2, - .tilemapLeft = 1, - .tilemapTop = 17, - .width = 18, - .height = 2, - .paletteNum = 15, - .baseBlock = 0x299, -}; - -static const struct WindowTemplate gUnknown_08615940 = -{ - .bg = 2, - .tilemapLeft = 1, - .tilemapTop = 17, - .width = 16, - .height = 2, - .paletteNum = 15, - .baseBlock = 0x299, -}; - -static const struct WindowTemplate gUnknown_08615948 = -{ - .bg = 2, - .tilemapLeft = 1, - .tilemapTop = 15, - .width = 20, - .height = 4, - .paletteNum = 15, - .baseBlock = 0x299, -}; - -static const struct WindowTemplate gUnknown_08615950 = -{ - .bg = 2, - .tilemapLeft = 23, - .tilemapTop = 13, - .width = 6, - .height = 6, - .paletteNum = 14, - .baseBlock = 0x39D, -}; - -static const struct WindowTemplate gUnknown_08615958 = -{ - .bg = 2, - .tilemapLeft = 21, - .tilemapTop = 13, - .width = 8, - .height = 6, - .paletteNum = 14, - .baseBlock = 0x39D, -}; - -static const struct WindowTemplate gUnknown_08615960 = -{ - .bg = 2, - .tilemapLeft = 19, - .tilemapTop = 11, - .width = 10, - .height = 8, - .paletteNum = 14, - .baseBlock = 0x2E9, -}; - -static const struct WindowTemplate gUnknown_08615968 = -{ - .bg = 2, - .tilemapLeft = 21, - .tilemapTop = 9, - .width = 5, - .height = 4, - .paletteNum = 14, - .baseBlock = 0x2E9, -}; - -static const struct WindowTemplate gUnknown_08615970 = -{ - .bg = 2, - .tilemapLeft = 19, - .tilemapTop = 1, - .width = 10, - .height = 11, - .paletteNum = 14, - .baseBlock = 0x2E9, -}; - -// Unused. -static const struct WindowTemplate gUnknown_08615978 = -{ - .bg = 2, - .tilemapLeft = 2, - .tilemapTop = 15, - .width = 27, - .height = 4, - .paletteNum = 14, - .baseBlock = 0x1DF, -}; - -// Unused. -static const struct WindowTemplate gUnknown_08615980 = -{ - .bg = 2, - .tilemapLeft = 0, - .tilemapTop = 13, - .width = 18, - .height = 3, - .paletteNum = 12, - .baseBlock = 0x39D, -}; - -static const u8 sMainSlotTileNums[] = {24, 25, 25, 25, 25, 25, 25, 25, 25, 26, - 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, - 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, - 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, - 40, 59, 60, 58, 58, 58, 58, 58, 58, 61, - 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, - 46, 47, 47, 47, 47, 47, 47, 47, 47, 48}; - -static const u8 sMainSlotTileNums_Egg[] = {24, 25, 25, 25, 25, 25, 25, 25, 25, 26, - 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, - 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, - 32, 33, 33, 33, 33, 33, 33, 33, 33, 34, - 40, 41, 41, 41, 41, 41, 41, 41, 41, 42, - 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, - 46, 47, 47, 47, 47, 47, 47, 47, 47, 48}; - -static const u8 sOtherSlotsTileNums[] = {43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, - 49, 33, 33, 33, 33, 33, 33, 33, 33, 52, 53, 51, 51, 51, 51, 51, 51, 54, - 55, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 57}; - -static const u8 sOtherSlotsTileNums_Egg[] = {43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, - 49, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 50, - 55, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 57}; - -static const u8 sEmptySlotTileNums[] = {21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, - 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, - 37, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 39}; -static const u8 gUnknown_08615AB6[] = {11, 12}; -static const u8 gUnknown_08615AB8[] = {9, 10}; -static const u8 gUnknown_08615ABA[] = {4, 5, 6}; -static const u8 gUnknown_08615ABD[] = {1, 7, 8}; -static const u8 gUnknown_08615AC0[] = {1, 11, 12}; -static const u8 gUnknown_08615AC3[] = {59, 60}; -static const u8 gUnknown_08615AC5[] = {75, 76}; -static const u8 gUnknown_08615AC7[] = {57, 58}; -static const u8 gUnknown_08615AC9[] = {73, 74}; -static const u8 gUnknown_08615ACB[] = {89, 90}; -static const u8 gUnknown_08615ACD[] = {52, 53, 54}; -static const u8 gUnknown_08615AD0[] = {68, 69, 70}; -static const u8 gUnknown_08615AD3[] = {84, 85, 86}; -static const u8 gUnknown_08615AD6[] = {116, 117, 118}; -static const u8 gUnknown_08615AD9[] = {132, 133, 134}; -static const u8 gUnknown_08615ADC[] = {148, 149, 150}; -static const u8 gUnknown_08615ADF[] = {100, 101, 102}; -static const u8 gUnknown_08615AE2[] = {49, 55, 56}; -static const u8 gUnknown_08615AE5[] = {65, 71, 72}; -static const u8 gUnknown_08615AE8[] = {81, 87, 88}; -static const u8 gUnknown_08615AEB[] = {97, 103, 104}; -static const u8 gUnknown_08615AEE[] = {161, 167, 168}; -static const u8 gUnknown_08615AF1[] = {17, 27, 28}; - -static const u8 *const sActionStringTable[] = -{ - gText_ChoosePokemon, - gText_ChoosePokemonCancel, - gText_ChoosePokemonConfirm, - gText_MoveToWhere, - gText_TeachWhichPokemon, - gText_UseOnWhichPokemon, - gText_GiveToWhichPokemon, - gText_NothingToCut, - gText_CantSurfHere, - gText_AlreadySurfing, - gText_CurrentIsTooFast, - gText_EnjoyCycling, - gText_InUseAlready_PM, - gText_CantUseHere, - gText_NoPokemonForBattle, - gText_ChoosePokemon2, - gText_NotEnoughHp, - gText_PokemonAreNeeded, - gText_PokemonCantBeSame, - gText_NoIdenticalHoldItems, - gText_EmptyString2, - gText_DoWhatWithPokemon, - gText_RestoreWhichMove, - gText_BoostPp, - gText_DoWhatWithItem, - gText_DoWhatWithMail, - gText_AlreadyHoldingOne, -}; - -static const u8 *const sSelectionStringTable[] = -{ - gText_NoUse, - gText_Able, - gText_First_PM, - gText_Second_PM, - gText_Third_PM, - gText_Fourth, - gText_Able2, - gText_NotAble, - gText_Able3, - gText_NotAble2, - gText_Learned, - gText_Have, - gText_DontHave, -}; - -// Unknown unused data. Feel free to remove. -static const u16 gUnknown_08615B94[] = -{ - 0x0108, 0x0151, 0x0160, 0x015b, 0x002e, 0x005c, 0x0102, 0x0153, 0x014b, 0x00ed, 0x00f1, 0x010d, 0x003a, 0x003b, 0x003f, 0x0071, - 0x00b6, 0x00f0, 0x00ca, 0x00db, 0x00da, 0x004c, 0x00e7, 0x0055, 0x0057, 0x0059, 0x00d8, 0x005b, 0x005e, 0x00f7, 0x0118, 0x0068, - 0x0073, 0x015f, 0x0035, 0x00bc, 0x00c9, 0x007e, 0x013d, 0x014c, 0x0103, 0x0107, 0x0122, 0x009c, 0x00d5, 0x00a8, 0x00d3, 0x011d, - 0x0121, 0x013b, 0x000f, 0x0013, 0x0039, 0x0046, 0x0094, 0x00f9, 0x007f, 0x0123, -}; - -enum -{ - MENU_SUMMARY, - MENU_SWITCH, - MENU_CANCEL1, - MENU_ITEM, - MENU_GIVE, - MENU_TAKE_ITEM, - MENU_MAIL, - MENU_TAKE_MAIL, - MENU_READ, - MENU_CANCEL2, - MENU_SHIFT, - MENU_SEND_OUT, - MENU_ENTER, - MENU_NO_ENTRY, - MENU_STORE, - MENU_REGISTER, - MENU_TRADE1, - MENU_TRADE2, - MENU_TOSS, - MENU_FIELD_MOVES, -}; - -enum -{ - FIELD_MOVE_CUT, - FIELD_MOVE_FLASH, - FIELD_MOVE_ROCK_SMASH, - FIELD_MOVE_STRENGTH, - FIELD_MOVE_SURF, - FIELD_MOVE_FLY, - FIELD_MOVE_DIVE, - FIELD_MOVE_WATERFALL, - FIELD_MOVE_TELEPORT, - FIELD_MOVE_DIG, - FIELD_MOVE_SECRET_POWER, - FIELD_MOVE_MILK_DRINK, - FIELD_MOVE_SOFT_BOILED, - FIELD_MOVE_SWEET_SCENT, -}; - -// What a weird choice of table termination; -#define FIELD_MOVE_TERMINATOR MOVE_SWORDS_DANCE - -struct -{ - const u8 *text; - TaskFunc func; -} static const sCursorOptions[] = -{ - [MENU_SUMMARY] = {gText_Summary5, CursorCb_Summary}, - [MENU_SWITCH] = {gText_Switch2, CursorCb_Switch}, - [MENU_CANCEL1] = {gText_Cancel2, CursorCb_Cancel1}, - [MENU_ITEM] = {gText_Item, CursorCb_Item}, - [MENU_GIVE] = {gMenuText_Give, CursorCb_Give}, - [MENU_TAKE_ITEM] = {gText_Take, CursorCb_TakeItem}, - [MENU_MAIL] = {gText_Mail, CursorCb_Mail}, - [MENU_TAKE_MAIL] = {gText_Take2, CursorCb_TakeMail}, - [MENU_READ] = {gText_Read2, CursorCb_Read}, - [MENU_CANCEL2] = {gText_Cancel2, CursorCb_Cancel2}, - [MENU_SHIFT] = {gText_Shift, CursorCb_SendMon}, - [MENU_SEND_OUT] = {gText_SendOut, CursorCb_SendMon}, - [MENU_ENTER] = {gText_Enter, CursorCb_Enter}, - [MENU_NO_ENTRY] = {gText_NoEntry, CursorCb_NoEntry}, - [MENU_STORE] = {gText_Store, CursorCb_Store}, - [MENU_REGISTER] = {gText_Register, CursorCb_Register}, - [MENU_TRADE1] = {gText_Trade4, CursorCb_Trade1}, - [MENU_TRADE2] = {gText_Trade4, CursorCb_Trade2}, - [MENU_TOSS] = {gMenuText_Toss, CursorCb_Toss}, - [MENU_FIELD_MOVES + FIELD_MOVE_CUT] = {gMoveNames[MOVE_CUT], CursorCb_FieldMove}, - [MENU_FIELD_MOVES + FIELD_MOVE_FLASH] = {gMoveNames[MOVE_FLASH], CursorCb_FieldMove}, - [MENU_FIELD_MOVES + FIELD_MOVE_ROCK_SMASH] = {gMoveNames[MOVE_ROCK_SMASH], CursorCb_FieldMove}, - [MENU_FIELD_MOVES + FIELD_MOVE_STRENGTH] = {gMoveNames[MOVE_STRENGTH], CursorCb_FieldMove}, - [MENU_FIELD_MOVES + FIELD_MOVE_SURF] = {gMoveNames[MOVE_SURF], CursorCb_FieldMove}, - [MENU_FIELD_MOVES + FIELD_MOVE_FLY] = {gMoveNames[MOVE_FLY], CursorCb_FieldMove}, - [MENU_FIELD_MOVES + FIELD_MOVE_DIVE] = {gMoveNames[MOVE_DIVE], CursorCb_FieldMove}, - [MENU_FIELD_MOVES + FIELD_MOVE_WATERFALL] = {gMoveNames[MOVE_WATERFALL], CursorCb_FieldMove}, - [MENU_FIELD_MOVES + FIELD_MOVE_TELEPORT] = {gMoveNames[MOVE_TELEPORT], CursorCb_FieldMove}, - [MENU_FIELD_MOVES + FIELD_MOVE_DIG] = {gMoveNames[MOVE_DIG], CursorCb_FieldMove}, - [MENU_FIELD_MOVES + FIELD_MOVE_SECRET_POWER] = {gMoveNames[MOVE_SECRET_POWER], CursorCb_FieldMove}, - [MENU_FIELD_MOVES + FIELD_MOVE_MILK_DRINK] = {gMoveNames[MOVE_MILK_DRINK], CursorCb_FieldMove}, - [MENU_FIELD_MOVES + FIELD_MOVE_SOFT_BOILED] = {gMoveNames[MOVE_SOFT_BOILED], CursorCb_FieldMove}, - [MENU_FIELD_MOVES + FIELD_MOVE_SWEET_SCENT] = {gMoveNames[MOVE_SWEET_SCENT], CursorCb_FieldMove}, -}; - -static const u8 gUnknown_08615D10[] = {MENU_SUMMARY, MENU_SWITCH, MENU_CANCEL1}; -static const u8 gUnknown_08615D13[] = {MENU_SHIFT, MENU_SUMMARY, MENU_CANCEL1}; -static const u8 gUnknown_08615D16[] = {MENU_SEND_OUT, MENU_SUMMARY, MENU_CANCEL1}; -static const u8 gUnknown_08615D19[] = {MENU_SUMMARY, MENU_CANCEL1}; -static const u8 gUnknown_08615D1B[] = {MENU_ENTER, MENU_SUMMARY, MENU_CANCEL1}; -static const u8 gUnknown_08615D1E[] = {MENU_NO_ENTRY, MENU_SUMMARY, MENU_CANCEL1}; -static const u8 gUnknown_08615D21[] = {MENU_STORE, MENU_SUMMARY, MENU_CANCEL1}; -static const u8 gUnknown_08615D24[] = {MENU_GIVE, MENU_TAKE_ITEM, MENU_CANCEL2}; -static const u8 gUnknown_08615D27[] = {MENU_READ, MENU_TAKE_MAIL, MENU_CANCEL2}; -static const u8 gUnknown_08615D2A[] = {MENU_REGISTER, MENU_SUMMARY, MENU_CANCEL1}; -static const u8 gUnknown_08615D2D[] = {MENU_TRADE1, MENU_SUMMARY, MENU_CANCEL1}; -static const u8 gUnknown_08615D30[] = {MENU_TRADE2, MENU_SUMMARY, MENU_CANCEL1}; -static const u8 gUnknown_08615D33[] = {MENU_TAKE_ITEM, MENU_TOSS, MENU_CANCEL1}; - -static const u8 *const sActionTable[] = -{ - NULL, - gUnknown_08615D10, - gUnknown_08615D13, - gUnknown_08615D16, - gUnknown_08615D1B, - gUnknown_08615D1E, - gUnknown_08615D21, - gUnknown_08615D19, - gUnknown_08615D24, - gUnknown_08615D27, - gUnknown_08615D2A, - gUnknown_08615D2D, - gUnknown_08615D30, - gUnknown_08615D33, -}; - -static const u8 sListSizeTable[] = -{ - 0x00, - ARRAY_COUNT(gUnknown_08615D10), - ARRAY_COUNT(gUnknown_08615D13), - ARRAY_COUNT(gUnknown_08615D16), - ARRAY_COUNT(gUnknown_08615D1B), - ARRAY_COUNT(gUnknown_08615D1E), - ARRAY_COUNT(gUnknown_08615D21), - ARRAY_COUNT(gUnknown_08615D19), - ARRAY_COUNT(gUnknown_08615D24), - ARRAY_COUNT(gUnknown_08615D27), - ARRAY_COUNT(gUnknown_08615D2A), - ARRAY_COUNT(gUnknown_08615D2D), - ARRAY_COUNT(gUnknown_08615D30), - ARRAY_COUNT(gUnknown_08615D33) -}; - -static const u16 sFieldMoves[] = -{ - MOVE_CUT, MOVE_FLASH, MOVE_ROCK_SMASH, MOVE_STRENGTH, MOVE_SURF, MOVE_FLY, MOVE_DIVE, MOVE_WATERFALL, MOVE_TELEPORT, - MOVE_DIG, MOVE_SECRET_POWER, MOVE_MILK_DRINK, MOVE_SOFT_BOILED, MOVE_SWEET_SCENT, FIELD_MOVE_TERMINATOR -}; - -struct -{ - bool8 (*fieldMoveFunc)(void); - u8 msgId; -} static const sFieldMoveCursorCallbacks[] = -{ - [FIELD_MOVE_CUT] = {SetUpFieldMove_Cut, 0x07}, - [FIELD_MOVE_FLASH] = {SetUpFieldMove_Flash, 0x0d}, - [FIELD_MOVE_ROCK_SMASH] = {SetUpFieldMove_RockSmash, 0x0d}, - [FIELD_MOVE_STRENGTH] = {SetUpFieldMove_Strength, 0x0d}, - [FIELD_MOVE_SURF] = {SetUpFieldMove_Surf, 0x08}, - [FIELD_MOVE_FLY] = {SetUpFieldMove_Fly, 0x0d}, - [FIELD_MOVE_DIVE] = {SetUpFieldMove_Dive, 0x0d}, - [FIELD_MOVE_WATERFALL] = {SetUpFieldMove_Waterfall, 0x0d}, - [FIELD_MOVE_TELEPORT] = {SetUpFieldMove_Teleport, 0x0d}, - [FIELD_MOVE_DIG] = {SetUpFieldMove_Dig, 0x0d}, - [FIELD_MOVE_SECRET_POWER] = {SetUpFieldMove_SecretPower, 0x0d}, - [FIELD_MOVE_MILK_DRINK] = {SetUpFieldMove_SoftBoiled, 0x10}, - [FIELD_MOVE_SOFT_BOILED] = {SetUpFieldMove_SoftBoiled, 0x10}, - [FIELD_MOVE_SWEET_SCENT] = {SetUpFieldMove_SweetScent, 0x0d}, -}; - -static const u8 *const sUnionRoomTradeMessages[] = -{ - [UR_TRADE_MSG_NOT_MON_PARTNER_WANTS - 1] = gText_NotPkmnOtherTrainerWants, - [UR_TRADE_MSG_NOT_EGG - 1] = gText_ThatIsntAnEgg, - [UR_TRADE_MSG_MON_CANT_BE_TRADED_1 - 1] = gText_PkmnCantBeTradedNow, - [UR_TRADE_MSG_MON_CANT_BE_TRADED_2 - 1] = gText_PkmnCantBeTradedNow, - [UR_TRADE_MSG_PARTNERS_MON_CANT_BE_TRADED - 1] = gText_OtherTrainersPkmnCantBeTraded, - [UR_TRADE_MSG_EGG_CANT_BE_TRADED -1] = gText_EggCantBeTradedNow, - [UR_TRADE_MSG_PARTNER_CANT_ACCEPT_MON - 1] = gText_OtherTrainerCantAcceptPkmn, - [UR_TRADE_MSG_CANT_TRADE_WITH_PARTNER_1 - 1] = gText_CantTradeWithTrainer, - [UR_TRADE_MSG_CANT_TRADE_WITH_PARTNER_2 - 1] = gText_CantTradeWithTrainer, -}; - -static const u32 sHeldItemGfx[] = INCBIN_U32("graphics/interface/hold_icons.4bpp"); -static const u16 sHeldItemPalette[] = INCBIN_U16("graphics/interface/hold_icons.gbapal"); - -static const struct OamData sOamData_HeldItem = -{ - .y = 0, - .affineMode = 0, - .objMode = 0, - .mosaic = 0, - .bpp = 0, - .shape = SPRITE_SHAPE(8x8), - .x = 0, - .matrixNum = 0, - .size = SPRITE_SIZE(8x8), - .tileNum = 0, - .priority = 1, - .paletteNum = 0, - .affineParam = 0, -}; - -static const union AnimCmd sSpriteAnim_HeldItem[] = -{ - ANIMCMD_FRAME(0, 1), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_HeldMail[] = -{ - ANIMCMD_FRAME(1, 1), - ANIMCMD_END -}; - -static const union AnimCmd *const sSpriteAnimTable_HeldItem[] = -{ - sSpriteAnim_HeldItem, - sSpriteAnim_HeldMail, -}; - -static const struct SpriteSheet sSpriteSheet_HeldItem = -{ - sHeldItemGfx, sizeof(sHeldItemGfx), 0xd750 -}; - -static const struct SpritePalette sSpritePalette_HeldItem = -{ - sHeldItemPalette, 0xd750 -}; - -static const struct SpriteTemplate sSpriteTemplate_HeldItem = -{ - 0xd750, - 0xd750, - &sOamData_HeldItem, - sSpriteAnimTable_HeldItem, - NULL, - gDummySpriteAffineAnimTable, - SpriteCallbackDummy -}; - -static const struct OamData sOamData_MenuPokeball = -{ - .y = 0, - .affineMode = 0, - .objMode = 0, - .mosaic = 0, - .bpp = 0, - .shape = SPRITE_SHAPE(32x32), - .x = 0, - .matrixNum = 0, - .size = SPRITE_SIZE(32x32), - .tileNum = 0, - .priority = 1, - .paletteNum = 0, - .affineParam = 0 -}; - -static const union AnimCmd sPokeballAnim_Closed[] = -{ - ANIMCMD_FRAME(0, 0), - ANIMCMD_END -}; - -static const union AnimCmd sPokeballAnim_Open[] = -{ - ANIMCMD_FRAME(16, 0), - ANIMCMD_END -}; - -static const union AnimCmd *const sSpriteAnimTable_Pokeball[] = -{ - sPokeballAnim_Closed, - sPokeballAnim_Open -}; - -static const struct CompressedSpriteSheet sSpriteSheet_MenuPokeball = -{ - gPartyMenuPokeball_Gfx, 0x400, 0x04b0 -}; - -static const struct CompressedSpritePalette sSpritePalette_MenuPokeball = -{ - gPartyMenuPokeball_Pal, 0x04b0 -}; - -static const struct SpriteTemplate sSpriteTemplate_MenuPokeball = -{ - .tileTag = 0x04b0, - .paletteTag = 0x04b0, - .oam = &sOamData_MenuPokeball, - .anims = sSpriteAnimTable_Pokeball, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCallbackDummy, -}; - -static const struct OamData sOamData_8615F20 = -{ - .y = 0, - .affineMode = 0, - .objMode = 0, - .mosaic = 0, - .bpp = 0, - .shape = SPRITE_SHAPE(16x16), - .x = 0, - .matrixNum = 0, - .size = SPRITE_SIZE(16x16), - .tileNum = 0, - .priority = 2, - .paletteNum = 0, - .affineParam = 0 -}; - -static const union AnimCmd sSpriteAnim_8615F28[] = -{ - ANIMCMD_FRAME(0, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_8615F30[] = -{ - ANIMCMD_FRAME(4, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_8615F38[] = -{ - ANIMCMD_FRAME(8, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_8615F40[] = -{ - ANIMCMD_FRAME(12, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_8615F48[] = -{ - ANIMCMD_FRAME(16, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_8615F50[] = -{ - ANIMCMD_FRAME(20, 0), - ANIMCMD_END -}; - -static const union AnimCmd *const sSpriteAnimTable_8615F58[] = -{ - sSpriteAnim_8615F28, - sSpriteAnim_8615F30, - sSpriteAnim_8615F38, - sSpriteAnim_8615F40, - sSpriteAnim_8615F48, - sSpriteAnim_8615F50 -}; - -static const struct CompressedSpriteSheet sSpriteSheet_MenuPokeballSmall = -{ - gPartyMenuPokeballSmall_Gfx, 0x0300, 0x04b1 -}; - -static const struct SpriteTemplate gSpriteTemplate_8615F78 = -{ - .tileTag = 1201, - .paletteTag = 1200, - .oam = &sOamData_8615F20, - .anims = sSpriteAnimTable_8615F58, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCallbackDummy, -}; - -static const struct OamData sOamData_StatusCondition = -{ - .y = 0, - .affineMode = 0, - .objMode = 0, - .mosaic = 0, - .bpp = 0, - .shape = SPRITE_SHAPE(32x8), - .x = 0, - .matrixNum = 0, - .size = SPRITE_SIZE(32x8), - .tileNum = 0, - .priority = 1, - .paletteNum = 0, - .affineParam = 0 -}; - -static const union AnimCmd sSpriteAnim_StatusPoison[] = -{ - ANIMCMD_FRAME(0, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_StatusParalyzed[] = -{ - ANIMCMD_FRAME(4, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_StatusSleep[] = -{ - ANIMCMD_FRAME(8, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_StatusFrozen[] = -{ - ANIMCMD_FRAME(12, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_StatusBurn[] = -{ - ANIMCMD_FRAME(16, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_StatusPokerus[] = -{ - ANIMCMD_FRAME(20, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_StatusFaint[] = -{ - ANIMCMD_FRAME(24, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_Blank[] = -{ - ANIMCMD_FRAME(28, 0), - ANIMCMD_END -}; - -static const union AnimCmd *const sSpriteTemplate_StatusCondition[] = -{ - sSpriteAnim_StatusPoison, - sSpriteAnim_StatusParalyzed, - sSpriteAnim_StatusSleep, - sSpriteAnim_StatusFrozen, - sSpriteAnim_StatusBurn, - sSpriteAnim_StatusPokerus, - sSpriteAnim_StatusFaint, - sSpriteAnim_Blank -}; - -static const struct CompressedSpriteSheet sSpriteSheet_StatusIcons = -{ - gStatusGfx_Icons, 0x400, 1202 -}; - -static const struct CompressedSpritePalette sSpritePalette_StatusIcons = -{ - gStatusPal_Icons, 1202 -}; - -static const struct SpriteTemplate sSpriteTemplate_StatusIcons = -{ - .tileTag = 1202, - .paletteTag = 1202, - .oam = &sOamData_StatusCondition, - .anims = sSpriteTemplate_StatusCondition, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCallbackDummy, -}; - -static const u8 gUnknown_08616020[] = {0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00}; - -// Unused table of pointers to strings of statistics. -static const u8 *const gUnknown_08616028[] = -{ - gText_HP4, - gText_Attack3, - gText_Defense3, - gText_SpAtk4, - gText_SpDef4, - gText_Speed2 -}; - -static const u16 gTMHMMoves[] = -{ - 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, -}; +#include "data/party_menu.h" // code -static void InitPartyMenu(u8 a, u8 b, u8 c, u8 d, u8 messageId, TaskFunc task, MainCallback callback) +static void InitPartyMenu(u8 menuType, u8 layout, u8 partyAction, bool8 keepCursorPos, u8 messageId, TaskFunc task, MainCallback callback) { u16 i; - reset_brm(); - gUnknown_0203CEC4 = Alloc(sizeof(struct Struct203CEC4)); - if (gUnknown_0203CEC4 == NULL) + ResetPartyMenu(); + sPartyMenuInternal = Alloc(sizeof(struct PartyMenuInternal)); + if (sPartyMenuInternal == NULL) { SetMainCallback2(callback); } else { - gUnknown_0203CEC8.unk8_0 = a; - gUnknown_0203CEC8.exitCallback = callback; - gUnknown_0203CEC8.unkB = c; - gUnknown_0203CEC4->messageId = messageId; - gUnknown_0203CEC4->task = task; - gUnknown_0203CEC4->exitCallback = NULL; - gUnknown_0203CEC4->unk8_1 = 0; - gUnknown_0203CEC4->unk8_2 = 0x7F; - gUnknown_0203CEC4->unk9_0 = 0x7F; - - if (a == 4) - gUnknown_0203CEC4->unk8_0 = TRUE; + gPartyMenu.menuType = menuType; + gPartyMenu.exitCallback = callback; + gPartyMenu.action = partyAction; + sPartyMenuInternal->messageId = messageId; + sPartyMenuInternal->task = task; + sPartyMenuInternal->exitCallback = NULL; + sPartyMenuInternal->lastSelectedSlot = 0; + sPartyMenuInternal->spriteIdConfirmPokeball = 0x7F; + sPartyMenuInternal->spriteIdCancelPokeball = 0x7F; + + if (menuType == PARTY_MENU_TYPE_CHOOSE_HALF) + sPartyMenuInternal->chooseHalf = TRUE; else - gUnknown_0203CEC4->unk8_0 = FALSE; + sPartyMenuInternal->chooseHalf = FALSE; - if (b != 0xFF) - gUnknown_0203CEC8.mode = b; + if (layout != KEEP_PARTY_LAYOUT) + gPartyMenu.layout = layout; - for (i = 0; i <= 15; i++) - gUnknown_0203CEC4->data[i] = 0; - for (i = 0; i < ARRAY_COUNT(gUnknown_0203CEC4->windowId); i++) - gUnknown_0203CEC4->windowId[i] = 0xFF; + for (i = 0; i < ARRAY_COUNT(sPartyMenuInternal->data); i++) + sPartyMenuInternal->data[i] = 0; + for (i = 0; i < ARRAY_COUNT(sPartyMenuInternal->windowId); i++) + sPartyMenuInternal->windowId[i] = 0xFF; - if (d == 0) - gUnknown_0203CEC8.slotId = 0; - else if (gUnknown_0203CEC8.slotId > 5 || GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_SPECIES) == SPECIES_NONE) - gUnknown_0203CEC8.slotId = 0; // wut why is this else if? + if (!keepCursorPos) + gPartyMenu.slotId = 0; + else if (gPartyMenu.slotId > PARTY_SIZE - 1 || GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES) == SPECIES_NONE) + gPartyMenu.slotId = 0; gTextFlags.autoScroll = 0; CalculatePlayerPartyCount(); - SetMainCallback2(PartyMenuInitCallback); + SetMainCallback2(CB2_InitPartyMenu); } } -static void PartyMenuCallback(void) +static void CB2_UpdatePartyMenu(void) { RunTasks(); AnimateSprites(); @@ -1632,23 +468,23 @@ static void PartyMenuCallback(void) UpdatePaletteFade(); } -static void PartyMenuVBlankCallback(void) +static void VBlankCB_PartyMenu(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -static void PartyMenuInitCallback(void) +static void CB2_InitPartyMenu(void) { while (TRUE) { - if (sub_81221EC() == TRUE || PartyMenuSetup() == TRUE || sub_81221AC() == TRUE) + if (sub_81221EC() == TRUE || ShowPartyMenu() == TRUE || sub_81221AC() == TRUE) break; } } -static bool8 PartyMenuSetup(void) +static bool8 ShowPartyMenu(void) { switch (gMain.state) { @@ -1681,32 +517,32 @@ static bool8 PartyMenuSetup(void) gMain.state++; break; case 6: - sub_81B209C(); + SetPartyMonsAllowedInMinigame(); gMain.state++; break; case 7: if (!AllocPartyMenuBg()) { - PartyMenuExit(); + ExitPartyMenu(); return TRUE; } else { - gUnknown_0203CEC4->data[0] = 0; + sPartyMenuInternal->data[0] = 0; gMain.state++; } break; case 8: - if (AllocPartyMiscGfx()) + if (AllocPartyMenuBgGfx()) gMain.state++; break; case 9: - sub_81B239C(gUnknown_0203CEC8.mode); + InitPartyMenuWindows(gPartyMenu.layout); gMain.state++; break; case 10: - PartyMenuInitHelperStructs(gUnknown_0203CEC8.mode); - gUnknown_0203CEC4->data[0] = 0; + InitPartyMenuBoxes(gPartyMenu.layout); + sPartyMenuInternal->data[0] = 0; gMain.state++; break; case 11: @@ -1726,33 +562,33 @@ static bool8 PartyMenuSetup(void) gMain.state++; break; case 15: - if (party_menu_add_per_mon_objects()) + if (CreatePartyMonSpritesLoop()) { - gUnknown_0203CEC4->data[0] = 0; + sPartyMenuInternal->data[0] = 0; gMain.state++; } break; case 16: if (RenderPartyMenuBoxes()) { - gUnknown_0203CEC4->data[0] = 0; + sPartyMenuInternal->data[0] = 0; gMain.state++; } break; case 17: - sub_81B0F28(); + CreateCancelConfirmPokeballSprites(); gMain.state++; break; case 18: - sub_81B2428(gUnknown_0203CEC4->unk8_0); + CreateCancelConfirmWindows(sPartyMenuInternal->chooseHalf); gMain.state++; break; case 19: gMain.state++; break; case 20: - CreateTask(gUnknown_0203CEC4->task, 0); - DisplayPartyMenuStdMessage(gUnknown_0203CEC4->messageId); + CreateTask(sPartyMenuInternal->task, 0); + DisplayPartyMenuStdMessage(sPartyMenuInternal->messageId); gMain.state++; break; case 21: @@ -1765,49 +601,49 @@ static bool8 PartyMenuSetup(void) gMain.state++; break; default: - SetVBlankCallback(PartyMenuVBlankCallback); - SetMainCallback2(PartyMenuCallback); + SetVBlankCallback(VBlankCB_PartyMenu); + SetMainCallback2(CB2_UpdatePartyMenu); return TRUE; } return FALSE; } -static void PartyMenuExit(void) +static void ExitPartyMenu(void) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - CreateTask(PartyMenuExitTask, 0); - SetVBlankCallback(PartyMenuVBlankCallback); - SetMainCallback2(PartyMenuCallback); + CreateTask(Task_ExitPartyMenu, 0); + SetVBlankCallback(VBlankCB_PartyMenu); + SetMainCallback2(CB2_UpdatePartyMenu); } -static void PartyMenuExitTask(u8 taskId) +static void Task_ExitPartyMenu(u8 taskId) { if (!gPaletteFade.active) { - SetMainCallback2(gUnknown_0203CEC8.exitCallback); + SetMainCallback2(gPartyMenu.exitCallback); FreePartyPointers(); DestroyTask(taskId); } } -static void reset_brm(void) +static void ResetPartyMenu(void) { - gUnknown_0203CEC4 = NULL; - gUnknown_0203CEE4 = NULL; - gUnknown_0203CEDC = NULL; - gUnknown_0203CEE0 = NULL; + sPartyMenuInternal = NULL; + sPartyBgTilemapBuffer = NULL; + sPartyMenuBoxes = NULL; + sPartyBgGfxTilemap = NULL; } static bool8 AllocPartyMenuBg(void) { - gUnknown_0203CEE4 = Alloc(0x800); - if (gUnknown_0203CEE4 == NULL) + sPartyBgTilemapBuffer = Alloc(0x800); + if (sPartyBgTilemapBuffer == NULL) return FALSE; - memset(gUnknown_0203CEE4, 0, 0x800); + memset(sPartyBgTilemapBuffer, 0, 0x800); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_086156B8, ARRAY_COUNT(gUnknown_086156B8)); - SetBgTilemapBuffer(1, gUnknown_0203CEE4); + InitBgsFromTemplates(0, sPartyMenuBgTemplates, ARRAY_COUNT(sPartyMenuBgTemplates)); + SetBgTilemapBuffer(1, sPartyBgTilemapBuffer); ResetAllBgsCoordinates(); schedule_bg_copy_tilemap_to_vram(1); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); @@ -1818,48 +654,48 @@ static bool8 AllocPartyMenuBg(void) return TRUE; } -static bool8 AllocPartyMiscGfx(void) +static bool8 AllocPartyMenuBgGfx(void) { u32 sizeout; - switch (gUnknown_0203CEC4->data[0]) + switch (sPartyMenuInternal->data[0]) { case 0: - gUnknown_0203CEE0 = malloc_and_decompress(gPartyMenuMisc_Gfx, &sizeout); - LoadBgTiles(1, gUnknown_0203CEE0, sizeout, 0); - gUnknown_0203CEC4->data[0]++; + sPartyBgGfxTilemap = malloc_and_decompress(gPartyMenuBg_Gfx, &sizeout); + LoadBgTiles(1, sPartyBgGfxTilemap, sizeout, 0); + sPartyMenuInternal->data[0]++; break; case 1: if (!IsDma3ManagerBusyWithBgCopy()) { - LZDecompressWram(gPartyMenuMisc_Tilemap, gUnknown_0203CEE4); - gUnknown_0203CEC4->data[0]++; + LZDecompressWram(gPartyMenuBg_Tilemap, sPartyBgTilemapBuffer); + sPartyMenuInternal->data[0]++; } break; case 2: - LoadCompressedPalette(gPartyMenuMisc_Pal, 0, 0x160); - CpuCopy16(gPlttBufferUnfaded, gUnknown_0203CEC4->palBuffer, 0x160); - gUnknown_0203CEC4->data[0]++; + LoadCompressedPalette(gPartyMenuBg_Pal, 0, 0x160); + CpuCopy16(gPlttBufferUnfaded, sPartyMenuInternal->palBuffer, 0x160); + sPartyMenuInternal->data[0]++; break; case 3: PartyPaletteBufferCopy(4); - gUnknown_0203CEC4->data[0]++; + sPartyMenuInternal->data[0]++; break; case 4: PartyPaletteBufferCopy(5); - gUnknown_0203CEC4->data[0]++; + sPartyMenuInternal->data[0]++; break; case 5: PartyPaletteBufferCopy(6); - gUnknown_0203CEC4->data[0]++; + sPartyMenuInternal->data[0]++; break; case 6: PartyPaletteBufferCopy(7); - gUnknown_0203CEC4->data[0]++; + sPartyMenuInternal->data[0]++; break; case 7: PartyPaletteBufferCopy(8); - gUnknown_0203CEC4->data[0]++; + sPartyMenuInternal->data[0]++; break; default: return TRUE; @@ -1876,84 +712,86 @@ static void PartyPaletteBufferCopy(u8 offset) static void FreePartyPointers(void) { - if (gUnknown_0203CEC4) - Free(gUnknown_0203CEC4); - if (gUnknown_0203CEE4) - Free(gUnknown_0203CEE4); - if (gUnknown_0203CEE0) - Free(gUnknown_0203CEE0); - if (gUnknown_0203CEDC) - Free(gUnknown_0203CEDC); + if (sPartyMenuInternal) + Free(sPartyMenuInternal); + if (sPartyBgTilemapBuffer) + Free(sPartyBgTilemapBuffer); + if (sPartyBgGfxTilemap) + Free(sPartyBgGfxTilemap); + if (sPartyMenuBoxes) + Free(sPartyMenuBoxes); FreeAllWindowBuffers(); } -static void PartyMenuInitHelperStructs(u8 a) +static void InitPartyMenuBoxes(u8 layout) { u8 i; - gUnknown_0203CEDC = Alloc(sizeof(struct Struct203CEDC[PARTY_SIZE])); + sPartyMenuBoxes = Alloc(sizeof(struct PartyMenuBox[PARTY_SIZE])); for (i = 0; i < PARTY_SIZE; i++) { - gUnknown_0203CEDC[i].unk0 = &gUnknown_086156C4[1]; - gUnknown_0203CEDC[i].unk4 = gUnknown_08615704[a][i]; - gUnknown_0203CEDC[i].windowId = i; - gUnknown_0203CEDC[i].monSpriteId = 0xFF; - gUnknown_0203CEDC[i].itemSpriteId = 0xFF; - gUnknown_0203CEDC[i].pokeballSpriteId = 0xFF; - gUnknown_0203CEDC[i].statusSpriteId = 0xFF; + sPartyMenuBoxes[i].infoRects = &sPartyBoxInfoRects[PARTY_BOX_RIGHT_COLUMN]; + sPartyMenuBoxes[i].spriteCoords = sPartyMenuSpriteCoords[layout][i]; + sPartyMenuBoxes[i].windowId = i; + sPartyMenuBoxes[i].monSpriteId = 0xFF; + sPartyMenuBoxes[i].itemSpriteId = 0xFF; + sPartyMenuBoxes[i].pokeballSpriteId = 0xFF; + sPartyMenuBoxes[i].statusSpriteId = 0xFF; } - gUnknown_0203CEDC[0].unk0 = &gUnknown_086156C4[0]; - if (a == 3) - gUnknown_0203CEDC[3].unk0 = &gUnknown_086156C4[0]; - else if (a != 0) - gUnknown_0203CEDC[1].unk0 = &gUnknown_086156C4[0]; + // The first party mon goes in the left column + sPartyMenuBoxes[0].infoRects = &sPartyBoxInfoRects[PARTY_BOX_LEFT_COLUMN]; + + if (layout == PARTY_LAYOUT_MULTI_SHOWCASE) + sPartyMenuBoxes[3].infoRects = &sPartyBoxInfoRects[PARTY_BOX_LEFT_COLUMN]; + else if (layout != PARTY_LAYOUT_SINGLE) + sPartyMenuBoxes[1].infoRects = &sPartyBoxInfoRects[PARTY_BOX_LEFT_COLUMN]; } static void RenderPartyMenuBox(u8 slot) { - if (gUnknown_0203CEC8.unk8_0 == 5 && slot > 2) + if (gPartyMenu.menuType == PARTY_MENU_TYPE_MULTI_SHOWCASE && slot >= MULTI_PARTY_SIZE) { - sub_81B0CEC(slot); - if (gUnknown_02022FF8[slot - 3].species == SPECIES_NONE) - UpdateSelectedPartyBox(&gUnknown_0203CEDC[slot], 0x40); + DisplayPartyPokemonDataForMultiBattle(slot); + if (gMultiPartnerParty[slot - MULTI_PARTY_SIZE].species == SPECIES_NONE) + LoadPartyBoxPalette(&sPartyMenuBoxes[slot], PARTY_PAL_NO_MON); else - UpdateSelectedPartyBox(&gUnknown_0203CEDC[slot], 8); - CopyWindowToVram(gUnknown_0203CEDC[slot].windowId, 2); - PutWindowTilemap(gUnknown_0203CEDC[slot].windowId); + LoadPartyBoxPalette(&sPartyMenuBoxes[slot], PARTY_PAL_MULTI_ALT); + CopyWindowToVram(sPartyMenuBoxes[slot].windowId, 2); + PutWindowTilemap(sPartyMenuBoxes[slot].windowId); schedule_bg_copy_tilemap_to_vram(2); } else { if (GetMonData(&gPlayerParty[slot], MON_DATA_SPECIES) == SPECIES_NONE) { - DrawEmptySlot(gUnknown_0203CEDC[slot].windowId); - UpdateSelectedPartyBox(&gUnknown_0203CEDC[slot], 0x40); - CopyWindowToVram(gUnknown_0203CEDC[slot].windowId, 2); + DrawEmptySlot(sPartyMenuBoxes[slot].windowId); + LoadPartyBoxPalette(&sPartyMenuBoxes[slot], PARTY_PAL_NO_MON); + CopyWindowToVram(sPartyMenuBoxes[slot].windowId, 2); } else { - if (gUnknown_0203CEC8.unk8_0 == 7) - DisplayPartyPokemonSelectForRelearner(slot); - else if (gUnknown_0203CEC8.unk8_0 == 2) - DisplayPartyPokemonSelectForContest(slot); - else if (gUnknown_0203CEC8.unk8_0 == 4) - DisplayPartyPokemonSelectForBattle(slot); - else if (gUnknown_0203CEC8.unk8_0 == 11) - sub_81B0B98(slot); - else if (gUnknown_0203CEC8.unk8_0 == 12) - DisplayPartyPokemonSelectHeldItemRelated(slot); - else if (!sub_81B0BFC(slot)) + if (gPartyMenu.menuType == PARTY_MENU_TYPE_MOVE_RELEARNER) + DisplayPartyPokemonDataForRelearner(slot); + else if (gPartyMenu.menuType == PARTY_MENU_TYPE_CONTEST) + DisplayPartyPokemonDataForContest(slot); + else if (gPartyMenu.menuType == PARTY_MENU_TYPE_CHOOSE_HALF) + DisplayPartyPokemonDataForChooseHalf(slot); + else if (gPartyMenu.menuType == PARTY_MENU_TYPE_MINIGAME) + DisplayPartyPokemonDataForWirelessMinigame(slot); + else if (gPartyMenu.menuType == PARTY_MENU_TYPE_STORE_PYRAMID_HELD_ITEMS) + DisplayPartyPokemonDataForBattlePyramidHeldItem(slot); + else if (!DisplayPartyPokemonDataForMoveTutorOrEvolutionItem(slot)) DisplayPartyPokemonData(slot); - if (gUnknown_0203CEC8.unk8_0 == 5) - sub_81B0FCC(slot, 0); - else if (gUnknown_0203CEC8.slotId == slot) - sub_81B0FCC(slot, 1); + if (gPartyMenu.menuType == PARTY_MENU_TYPE_MULTI_SHOWCASE) + AnimatePartySlot(slot, 0); + else if (gPartyMenu.slotId == slot) + AnimatePartySlot(slot, 1); else - sub_81B0FCC(slot, 0); + AnimatePartySlot(slot, 0); } - PutWindowTilemap(gUnknown_0203CEDC[slot].windowId); + PutWindowTilemap(sPartyMenuBoxes[slot].windowId); schedule_bg_copy_tilemap_to_vram(0); } } @@ -1962,249 +800,251 @@ static void DisplayPartyPokemonData(u8 slot) { if (GetMonData(&gPlayerParty[slot], MON_DATA_IS_EGG)) { - gUnknown_0203CEDC[slot].unk0->unk0(gUnknown_0203CEDC[slot].windowId, 0, 0, 0, 0, 1); - DisplayPartyPokemonNickname(&gPlayerParty[slot], &gUnknown_0203CEDC[slot], 0); + sPartyMenuBoxes[slot].infoRects->blitFunc(sPartyMenuBoxes[slot].windowId, 0, 0, 0, 0, TRUE); + DisplayPartyPokemonNickname(&gPlayerParty[slot], &sPartyMenuBoxes[slot], 0); } else { - gUnknown_0203CEDC[slot].unk0->unk0(gUnknown_0203CEDC[slot].windowId, 0, 0, 0, 0, 0); - DisplayPartyPokemonNickname(&gPlayerParty[slot], &gUnknown_0203CEDC[slot], 0); - DisplayPartyPokemonLevelCheck(&gPlayerParty[slot], &gUnknown_0203CEDC[slot], 0); - DisplayPartyPokemonGenderNidoranCheck(&gPlayerParty[slot], &gUnknown_0203CEDC[slot], 0); - DisplayPartyPokemonHPCheck(&gPlayerParty[slot], &gUnknown_0203CEDC[slot], 0); - DisplayPartyPokemonMaxHPCheck(&gPlayerParty[slot], &gUnknown_0203CEDC[slot], 0); - DisplayPartyPokemonHPBarCheck(&gPlayerParty[slot], &gUnknown_0203CEDC[slot]); + sPartyMenuBoxes[slot].infoRects->blitFunc(sPartyMenuBoxes[slot].windowId, 0, 0, 0, 0, FALSE); + DisplayPartyPokemonNickname(&gPlayerParty[slot], &sPartyMenuBoxes[slot], 0); + DisplayPartyPokemonLevelCheck(&gPlayerParty[slot], &sPartyMenuBoxes[slot], 0); + DisplayPartyPokemonGenderNidoranCheck(&gPlayerParty[slot], &sPartyMenuBoxes[slot], 0); + DisplayPartyPokemonHPCheck(&gPlayerParty[slot], &sPartyMenuBoxes[slot], 0); + DisplayPartyPokemonMaxHPCheck(&gPlayerParty[slot], &sPartyMenuBoxes[slot], 0); + DisplayPartyPokemonHPBarCheck(&gPlayerParty[slot], &sPartyMenuBoxes[slot]); } } -static void DisplayPartyPokemonSelectData(u8 slot, u8 stringID) +static void DisplayPartyPokemonDescriptionData(u8 slot, u8 stringID) { struct Pokemon *mon = &gPlayerParty[slot]; - gUnknown_0203CEDC[slot].unk0->unk0(gUnknown_0203CEDC[slot].windowId, 0, 0, 0, 0, 1); - DisplayPartyPokemonNickname(mon, &gUnknown_0203CEDC[slot], 0); + sPartyMenuBoxes[slot].infoRects->blitFunc(sPartyMenuBoxes[slot].windowId, 0, 0, 0, 0, TRUE); + DisplayPartyPokemonNickname(mon, &sPartyMenuBoxes[slot], 0); if (!GetMonData(mon, MON_DATA_IS_EGG)) { - DisplayPartyPokemonLevelCheck(mon, &gUnknown_0203CEDC[slot], 0); - DisplayPartyPokemonGenderNidoranCheck(mon, &gUnknown_0203CEDC[slot], 0); + DisplayPartyPokemonLevelCheck(mon, &sPartyMenuBoxes[slot], 0); + DisplayPartyPokemonGenderNidoranCheck(mon, &sPartyMenuBoxes[slot], 0); } - DisplayPartyPokemonSelectionText(stringID, &gUnknown_0203CEDC[slot], 0); + DisplayPartyPokemonDescriptionText(stringID, &sPartyMenuBoxes[slot], 0); } -static void DisplayPartyPokemonSelectForBattle(u8 slot) +static void DisplayPartyPokemonDataForChooseHalf(u8 slot) { u8 i; struct Pokemon *mon = &gPlayerParty[slot]; - u8 *ptr = gSelectedOrderFromParty; + u8 *order = gSelectedOrderFromParty; if (!GetBattleEntryEligibility(mon)) { - DisplayPartyPokemonSelectData(slot, 7); + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_NOT_ABLE); return; } else { - for (i = 0; i < sub_81B8830(); i++) + for (i = 0; i < GetMaxBattleEntries(); i++) { - if (ptr[i] != 0 && (ptr[i] - 1) == slot) + if (order[i] != 0 && (order[i] - 1) == slot) { - DisplayPartyPokemonSelectData(slot, i + 2); + DisplayPartyPokemonDescriptionData(slot, i + PARTYBOX_DESC_FIRST); return; } } - DisplayPartyPokemonSelectData(slot, 1); + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_ABLE_3); } } -static void DisplayPartyPokemonSelectForContest(u8 slot) +static void DisplayPartyPokemonDataForContest(u8 slot) { - switch (sub_80DAE0C(&gPlayerParty[slot])) + switch (GetContestEntryEligibility(&gPlayerParty[slot])) { - case 0: - case 3: - case 4: - DisplayPartyPokemonSelectData(slot, 7); + case CANT_ENTER_CONTEST: + case CANT_ENTER_CONTEST_EGG: + case CANT_ENTER_CONTEST_FAINTED: + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_NOT_ABLE); break; - case 1: - case 2: - DisplayPartyPokemonSelectData(slot, 6); + case CAN_ENTER_CONTEST_EQUAL_RANK: + case CAN_ENTER_CONTEST_HIGH_RANK: + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_ABLE); break; } } -static void DisplayPartyPokemonSelectForRelearner(u8 slot) +static void DisplayPartyPokemonDataForRelearner(u8 slot) { if (GetNumberOfRelearnableMoves(&gPlayerParty[slot]) == 0) - DisplayPartyPokemonSelectData(slot, 9); + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_NOT_ABLE_2); else - DisplayPartyPokemonSelectData(slot, 8); + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_ABLE_2); } -static void sub_81B0B98(u8 slot) +static void DisplayPartyPokemonDataForWirelessMinigame(u8 slot) { - if (sub_81B218C(slot) == TRUE) - DisplayPartyPokemonSelectData(slot, 6); + if (IsMonAllowedInMinigame(slot) == TRUE) + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_ABLE); else - DisplayPartyPokemonSelectData(slot, 7); + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_NOT_ABLE); } -static void DisplayPartyPokemonSelectHeldItemRelated(u8 slot) +static void DisplayPartyPokemonDataForBattlePyramidHeldItem(u8 slot) { if (GetMonData(&gPlayerParty[slot], MON_DATA_HELD_ITEM)) - DisplayPartyPokemonSelectData(slot, 11); + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_HAVE); else - DisplayPartyPokemonSelectData(slot, 12); + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_DONT_HAVE); } -static bool8 sub_81B0BFC(u8 slot) +// Returns TRUE if teaching move or cant evolve with item (i.e. description data is shown), FALSE otherwise +static bool8 DisplayPartyPokemonDataForMoveTutorOrEvolutionItem(u8 slot) { struct Pokemon *currentPokemon = &gPlayerParty[slot]; u16 item = gSpecialVar_ItemId; - if (gUnknown_0203CEC8.unkB == 12) + if (gPartyMenu.action == PARTY_ACTION_MOVE_TUTOR) { gSpecialVar_Result = FALSE; - DisplayPartyPokemonSelectToTeachMove(slot, 0, gSpecialVar_0x8005); + DisplayPartyPokemonDataToTeachMove(slot, 0, gSpecialVar_0x8005); } else { - if (gUnknown_0203CEC8.unkB != 3) + if (gPartyMenu.action != PARTY_ACTION_USE_ITEM) return FALSE; switch (CheckIfItemIsTMHMOrEvolutionStone(item)) { default: return FALSE; - case 1: - DisplayPartyPokemonSelectToTeachMove(slot, item, 0); + case 1: // TM/HM + DisplayPartyPokemonDataToTeachMove(slot, item, 0); break; - case 2: + case 2: // Evolution stone if (!GetMonData(currentPokemon, MON_DATA_IS_EGG) && GetEvolutionTargetSpecies(currentPokemon, 3, item) != SPECIES_NONE) return FALSE; - DisplayPartyPokemonSelectData(slot, 0); + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_NO_USE); break; } } return TRUE; } -static void DisplayPartyPokemonSelectToTeachMove(u8 slot, u16 item, u8 tutor) +static void DisplayPartyPokemonDataToTeachMove(u8 slot, u16 item, u8 tutor) { switch (CanMonLearnTMTutor(&gPlayerParty[slot], item, tutor)) { case CANNOT_LEARN_MOVE: case CANNOT_LEARN_MOVE_IS_EGG: - DisplayPartyPokemonSelectData(slot, 9); + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_NOT_ABLE_2); break; case ALREADY_KNOWS_MOVE: - DisplayPartyPokemonSelectData(slot, 10); + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_LEARNED); break; default: - DisplayPartyPokemonSelectData(slot, 8); + DisplayPartyPokemonDescriptionData(slot, PARTYBOX_DESC_ABLE_2); break; } } -static void sub_81B0CEC(u8 slot) +static void DisplayPartyPokemonDataForMultiBattle(u8 slot) { - struct Struct203CEDC *structPtr = &gUnknown_0203CEDC[slot]; - u8 actualSlot = slot - 3; + struct PartyMenuBox *menuBox = &sPartyMenuBoxes[slot]; + u8 actualSlot = slot - (3); - if (gUnknown_02022FF8[actualSlot].species == SPECIES_NONE) + if (gMultiPartnerParty[actualSlot].species == SPECIES_NONE) { - DrawEmptySlot(structPtr->windowId); + DrawEmptySlot(menuBox->windowId); } else { - structPtr->unk0->unk0(structPtr->windowId, 0, 0, 0, 0, 0); - StringCopy(gStringVar1, gUnknown_02022FF8[actualSlot].nickname); + menuBox->infoRects->blitFunc(menuBox->windowId, 0, 0, 0, 0, FALSE); + StringCopy(gStringVar1, gMultiPartnerParty[actualSlot].nickname); StringGetEnd10(gStringVar1); sub_81DB52C(gStringVar1); - DisplayPartyPokemonBarDetail(structPtr->windowId, gStringVar1, 0, structPtr->unk0->unk4); - DisplayPartyPokemonLevel(gUnknown_02022FF8[actualSlot].level, structPtr); - DisplayPartyPokemonGender(gUnknown_02022FF8[actualSlot].gender, gUnknown_02022FF8[actualSlot].species, gUnknown_02022FF8[actualSlot].nickname, structPtr); - DisplayPartyPokemonHP(gUnknown_02022FF8[actualSlot].hp, structPtr); - DisplayPartyPokemonMaxHP(gUnknown_02022FF8[actualSlot].maxhp, structPtr); - DisplayPartyPokemonHPBar(gUnknown_02022FF8[actualSlot].hp, gUnknown_02022FF8[actualSlot].maxhp, structPtr); + DisplayPartyPokemonBarDetail(menuBox->windowId, gStringVar1, 0, menuBox->infoRects->dimensions); + DisplayPartyPokemonLevel(gMultiPartnerParty[actualSlot].level, menuBox); + DisplayPartyPokemonGender(gMultiPartnerParty[actualSlot].gender, gMultiPartnerParty[actualSlot].species, gMultiPartnerParty[actualSlot].nickname, menuBox); + DisplayPartyPokemonHP(gMultiPartnerParty[actualSlot].hp, menuBox); + DisplayPartyPokemonMaxHP(gMultiPartnerParty[actualSlot].maxhp, menuBox); + DisplayPartyPokemonHPBar(gMultiPartnerParty[actualSlot].hp, gMultiPartnerParty[actualSlot].maxhp, menuBox); } } static bool8 RenderPartyMenuBoxes(void) { - RenderPartyMenuBox(gUnknown_0203CEC4->data[0]); - if (++gUnknown_0203CEC4->data[0] == 6) + RenderPartyMenuBox(sPartyMenuInternal->data[0]); + if (++sPartyMenuInternal->data[0] == PARTY_SIZE) return TRUE; else return FALSE; } -static u8* GetPartyMiscGraphicsTile(u16 tileId) +static u8* GetPartyMenuBgTile(u16 tileId) { - return &gUnknown_0203CEE0[tileId << 5]; + return &sPartyBgGfxTilemap[tileId << 5]; } -static void party_menu_add_per_mon_objects_internal(u8 slot) +static void CreatePartyMonSprites(u8 slot) { u8 actualSlot; - if (gUnknown_0203CEC8.unk8_0 == 5 && slot > 2) + if (gPartyMenu.menuType == PARTY_MENU_TYPE_MULTI_SHOWCASE && slot >= MULTI_PARTY_SIZE) { u8 status; - actualSlot = slot - 3; + actualSlot = slot - MULTI_PARTY_SIZE; - if (gUnknown_02022FF8[actualSlot].species != SPECIES_NONE) + if (gMultiPartnerParty[actualSlot].species != SPECIES_NONE) { - party_menu_link_mon_icon_anim(gUnknown_02022FF8[actualSlot].species, gUnknown_02022FF8[actualSlot].personality, &gUnknown_0203CEDC[slot], 0, 0); - party_menu_link_mon_held_item_object(gUnknown_02022FF8[actualSlot].species, gUnknown_02022FF8[actualSlot].heldItem, &gUnknown_0203CEDC[slot]); - party_menu_link_mon_pokeball_object(gUnknown_02022FF8[actualSlot].species, &gUnknown_0203CEDC[slot]); - if (gUnknown_02022FF8[actualSlot].hp == 0) + CreatePartyMonIconSpriteParameterized(gMultiPartnerParty[actualSlot].species, gMultiPartnerParty[actualSlot].personality, &sPartyMenuBoxes[slot], 0, FALSE); + CreatePartyMonHeldItemSpriteParameterized(gMultiPartnerParty[actualSlot].species, gMultiPartnerParty[actualSlot].heldItem, &sPartyMenuBoxes[slot]); + CreatePartyMonPokeballSpriteParameterized(gMultiPartnerParty[actualSlot].species, &sPartyMenuBoxes[slot]); + if (gMultiPartnerParty[actualSlot].hp == 0) status = AILMENT_FNT; else - status = pokemon_ailments_get_primary(gUnknown_02022FF8[actualSlot].status); - party_menu_link_mon_status_condition_object(gUnknown_02022FF8[actualSlot].species, status, &gUnknown_0203CEDC[slot]); + status = GetAilmentFromStatus(gMultiPartnerParty[actualSlot].status); + CreatePartyMonStatusSpriteParameterized(gMultiPartnerParty[actualSlot].species, status, &sPartyMenuBoxes[slot]); } } else if (GetMonData(&gPlayerParty[slot], MON_DATA_SPECIES) != SPECIES_NONE) { - party_menu_icon_anim(&gPlayerParty[slot], &gUnknown_0203CEDC[slot], slot); - party_menu_held_item_object(&gPlayerParty[slot], &gUnknown_0203CEDC[slot]); - party_menu_pokeball_object(&gPlayerParty[slot], &gUnknown_0203CEDC[slot]); - party_menu_status_condition_object(&gPlayerParty[slot], &gUnknown_0203CEDC[slot]); + CreatePartyMonIconSprite(&gPlayerParty[slot], &sPartyMenuBoxes[slot], slot); + CreatePartyMonHeldItemSprite(&gPlayerParty[slot], &sPartyMenuBoxes[slot]); + CreatePartyMonPokeballSprite(&gPlayerParty[slot], &sPartyMenuBoxes[slot]); + CreatePartyMonStatusSprite(&gPlayerParty[slot], &sPartyMenuBoxes[slot]); } } -static bool8 party_menu_add_per_mon_objects(void) +static bool8 CreatePartyMonSpritesLoop(void) { - party_menu_add_per_mon_objects_internal(gUnknown_0203CEC4->data[0]); - if (++gUnknown_0203CEC4->data[0] == 6) + CreatePartyMonSprites(sPartyMenuInternal->data[0]); + if (++sPartyMenuInternal->data[0] == PARTY_SIZE) return TRUE; else return FALSE; } -static void sub_81B0F28(void) +static void CreateCancelConfirmPokeballSprites(void) { - if (gUnknown_0203CEC8.unk8_0 == 5) + if (gPartyMenu.menuType == PARTY_MENU_TYPE_MULTI_SHOWCASE) { + // The showcase has no Cancel/Confirm buttons FillBgTilemapBufferRect(1, 14, 23, 17, 7, 2, 1); } else { - if (gUnknown_0203CEC4->unk8_0) + if (sPartyMenuInternal->chooseHalf) { - gUnknown_0203CEC4->unk8_2 = sub_81B5F74(0xBF, 0x88); - sub_81B120C(); - gUnknown_0203CEC4->unk9_0 = sub_81B5F74(0xBF, 0x98); + sPartyMenuInternal->spriteIdConfirmPokeball = CreateSmallPokeballButtonSprite(0xBF, 0x88); + DrawCancelConfirmButtons(); + sPartyMenuInternal->spriteIdCancelPokeball = CreateSmallPokeballButtonSprite(0xBF, 0x98); } else { - gUnknown_0203CEC4->unk9_0 = sub_81B5F34(0xC6, 0x94); + sPartyMenuInternal->spriteIdCancelPokeball = CreatePokeballButtonSprite(198, 148); } - sub_81B0FCC(gUnknown_0203CEC8.slotId, 1); + AnimatePartySlot(gPartyMenu.slotId, 1); } } -void sub_81B0FCC(u8 slot, u8 b) +void AnimatePartySlot(u8 slot, u8 animNum) { u8 spriteId; @@ -2213,79 +1053,80 @@ void sub_81B0FCC(u8 slot, u8 b) default: if (GetMonData(&gPlayerParty[slot], MON_DATA_SPECIES) != SPECIES_NONE) { - UpdateSelectedPartyBox(&gUnknown_0203CEDC[slot], GetPartyBoxPalBitfield(slot, b)); - AnimateSelectedPartyIcon(gUnknown_0203CEDC[slot].monSpriteId, b); - sub_81B5F98(gUnknown_0203CEDC[slot].pokeballSpriteId, b); + LoadPartyBoxPalette(&sPartyMenuBoxes[slot], GetPartyBoxPaletteFlags(slot, animNum)); + AnimateSelectedPartyIcon(sPartyMenuBoxes[slot].monSpriteId, animNum); + PartyMenuStartSpriteAnim(sPartyMenuBoxes[slot].pokeballSpriteId, animNum); } return; - case 6: - if (b == 0) - sub_8199C30(1, 23, 16, 7, 2, 1); + case PARTY_SIZE: // Confirm + if (animNum == 0) + SetBgTilemapPalette(1, 23, 16, 7, 2, 1); else - sub_8199C30(1, 23, 16, 7, 2, 2); - spriteId = gUnknown_0203CEC4->unk8_2; + SetBgTilemapPalette(1, 23, 16, 7, 2, 2); + spriteId = sPartyMenuInternal->spriteIdConfirmPokeball; break; - case 7: - if (!gUnknown_0203CEC4->unk8_0) + case PARTY_SIZE + 1: // Cancel + // The position of the Cancel button changes if Confirm is present + if (!sPartyMenuInternal->chooseHalf) { - if (b == 0) - sub_8199C30(1, 23, 17, 7, 2, 1); + if (animNum == 0) + SetBgTilemapPalette(1, 23, 17, 7, 2, 1); else - sub_8199C30(1, 23, 17, 7, 2, 2); + SetBgTilemapPalette(1, 23, 17, 7, 2, 2); } - else if (b == 0) + else if (animNum == 0) { - sub_8199C30(1, 23, 18, 7, 2, 1); + SetBgTilemapPalette(1, 23, 18, 7, 2, 1); } else { - sub_8199C30(1, 23, 18, 7, 2, 2); + SetBgTilemapPalette(1, 23, 18, 7, 2, 2); } - spriteId = gUnknown_0203CEC4->unk9_0; + spriteId = sPartyMenuInternal->spriteIdCancelPokeball; break; } - sub_81B5F98(spriteId, b); + PartyMenuStartSpriteAnim(spriteId, animNum); schedule_bg_copy_tilemap_to_vram(1); } -static u8 GetPartyBoxPalBitfield(u8 slot, u8 b) +static u8 GetPartyBoxPaletteFlags(u8 slot, u8 animNum) { - u8 returnVar = 0; + u8 palFlags = 0; - if (b == 1) - returnVar |= 1; + if (animNum == 1) + palFlags |= PARTY_PAL_SELECTED; if (GetMonData(&gPlayerParty[slot], MON_DATA_HP) == 0) - returnVar |= 2; + palFlags |= PARTY_PAL_FAINTED; if (PartyBoxPal_ParnterOrDisqualifiedInArena(slot) == TRUE) - returnVar |= 8; - if (gUnknown_0203CEC8.unkB == 9) - returnVar |= 16; - if (gUnknown_0203CEC8.unkB == 8) + palFlags |= PARTY_PAL_MULTI_ALT; + if (gPartyMenu.action == PARTY_ACTION_SWITCHING) + palFlags |= PARTY_PAL_SWITCHING; + if (gPartyMenu.action == PARTY_ACTION_SWITCH) { - if (slot == gUnknown_0203CEC8.slotId || slot == gUnknown_0203CEC8.unkA) - returnVar |= 4; + if (slot == gPartyMenu.slotId || slot == gPartyMenu.slotId2) + palFlags |= PARTY_PAL_TO_SWITCH; } - if (gUnknown_0203CEC8.unkB == 10 && slot == gUnknown_0203CEC8.slotId ) - returnVar |= 32; + if (gPartyMenu.action == PARTY_ACTION_SOFTBOILED && slot == gPartyMenu.slotId ) + palFlags |= PARTY_PAL_TO_SOFTBOIL; - return returnVar; + return palFlags; } static bool8 PartyBoxPal_ParnterOrDisqualifiedInArena(u8 slot) { - if (gUnknown_0203CEC8.mode == 2 && (slot == 1 || slot == 4 || slot == 5)) + if (gPartyMenu.layout == PARTY_LAYOUT_MULTI && (slot == 1 || slot == 4 || slot == 5)) return TRUE; - if (slot < 3 && (gBattleTypeFlags & BATTLE_TYPE_ARENA) && gMain.inBattle && (gBattleStruct->arenaLostPlayerMons >> sub_81B8F38(slot) & 1)) + if (slot < MULTI_PARTY_SIZE && (gBattleTypeFlags & BATTLE_TYPE_ARENA) && gMain.inBattle && (gBattleStruct->arenaLostPlayerMons >> GetPartyIdFromBattleSlot(slot) & 1)) return TRUE; return FALSE; } -static void sub_81B120C(void) +static void DrawCancelConfirmButtons(void) { - CopyToBgTilemapBufferRect_ChangePalette(1, gUnknown_086157C4, 23, 16, 7, 2, 17); - CopyToBgTilemapBufferRect_ChangePalette(1, gUnknown_086157E0, 23, 18, 7, 2, 17); + CopyToBgTilemapBufferRect_ChangePalette(1, sConfirmButton_Tilemap, 23, 16, 7, 2, 17); + CopyToBgTilemapBufferRect_ChangePalette(1, sCancelButton_Tilemap, 23, 18, 7, 2, 17); schedule_bg_copy_tilemap_to_vram(1); } @@ -2297,13 +1138,13 @@ bool8 IsMultiBattle(void) return FALSE; } -static void sub_81B1288(struct Pokemon *partySlot, struct Pokemon *pokemon) +static void SwapPartyPokemon(struct Pokemon *mon1, struct Pokemon *mon2) { struct Pokemon *temp = Alloc(sizeof(struct Pokemon)); - *temp = *partySlot; - *partySlot = *pokemon; - *pokemon = *temp; + *temp = *mon1; + *mon1 = *mon2; + *mon2 = *temp; Free(temp); } @@ -2318,13 +1159,13 @@ static void Task_ClosePartyMenuAndSetCB2(u8 taskId) { if (!gPaletteFade.active) { - if (gUnknown_0203CEC8.unk8_0 == 1) - sub_81B9080(); + if (gPartyMenu.menuType == PARTY_MENU_TYPE_IN_BATTLE) + UpdatePartyToFieldOrder(); - if (gUnknown_0203CEC4->exitCallback != NULL) - SetMainCallback2(gUnknown_0203CEC4->exitCallback); + if (sPartyMenuInternal->exitCallback != NULL) + SetMainCallback2(sPartyMenuInternal->exitCallback); else - SetMainCallback2(gUnknown_0203CEC8.exitCallback); + SetMainCallback2(gPartyMenu.exitCallback); ResetSpriteData(); FreePartyPointers(); @@ -2334,124 +1175,124 @@ static void Task_ClosePartyMenuAndSetCB2(u8 taskId) u8 GetCursorSelectionMonId(void) { - return gUnknown_0203CEC8.slotId; + return gPartyMenu.slotId; } -u8 sub_81B1360(void) +u8 GetPartyMenuType(void) { - return gUnknown_0203CEC8.unk8_0; + return gPartyMenu.menuType; } -void sub_81B1370(u8 taskId) +void Task_HandleChooseMonInput(u8 taskId) { if (!gPaletteFade.active && sub_81221EC() != TRUE) { - s8 *ptr = sub_81B13EC(); + s8 *slotPtr = GetCurrentPartySlotPtr(); - switch (PartyMenuButtonHandler(ptr)) + switch (PartyMenuButtonHandler(slotPtr)) { - case 1: - sub_81B140C(taskId, ptr); + case 1: // Selected mon + HandleChooseMonSelection(taskId, slotPtr); break; - case 2: - sub_81B15D0(taskId, ptr); + case 2: // Selected Cancel + HandleChooseMonCancel(taskId, slotPtr); break; - case 8: - if (gUnknown_0203CEC4->unk8_0) + case 8: // Start button + if (sPartyMenuInternal->chooseHalf) { PlaySE(SE_SELECT); - sub_81B4F88(); + MoveCursorToConfirm(); } break; } } } -static s8* sub_81B13EC(void) +static s8* GetCurrentPartySlotPtr(void) { - if (gUnknown_0203CEC8.unkB == 8 || gUnknown_0203CEC8.unkB == 10) - return &gUnknown_0203CEC8.unkA; + if (gPartyMenu.action == PARTY_ACTION_SWITCH || gPartyMenu.action == PARTY_ACTION_SOFTBOILED) + return &gPartyMenu.slotId2; else - return &gUnknown_0203CEC8.slotId; + return &gPartyMenu.slotId; } -static void sub_81B140C(u8 taskId, s8 *ptr) +static void HandleChooseMonSelection(u8 taskId, s8 *slotPtr) { - if (*ptr == 6) + if (*slotPtr == PARTY_SIZE) { - gUnknown_0203CEC8.unk4(taskId); + gPartyMenu.task(taskId); } else { - switch (gUnknown_0203CEC8.unkB - 3) + switch (gPartyMenu.action - 3) { - case 7: - if (sub_81B15A4((u8*)ptr)) + case PARTY_ACTION_SOFTBOILED - 3: + if (IsSelectedMonNotEgg((u8*)slotPtr)) { - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - sub_81615A8(taskId); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + Task_TryUseSoftboiledOnPartyMon(taskId); } break; - case 0: - if (sub_81B15A4((u8*)ptr)) + case PARTY_ACTION_USE_ITEM - 3: + if (IsSelectedMonNotEgg((u8*)slotPtr)) { - if (gUnknown_0203CEC8.unk8_0 == 1) - gUnknown_0203CEC4->exitCallback = sub_81B9140; + if (gPartyMenu.menuType == PARTY_MENU_TYPE_IN_BATTLE) + sPartyMenuInternal->exitCallback = CB2_SetUpExitToBattleScreen; - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - gUnknown_03006328(taskId, sub_81B6794); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + gItemUseCB(taskId, Task_ClosePartyMenuAfterText); } break; - case 9: - if (sub_81B15A4((u8*)ptr)) + case PARTY_ACTION_MOVE_TUTOR - 3: + if (IsSelectedMonNotEgg((u8*)slotPtr)) { PlaySE(SE_SELECT); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - sub_81B7E4C(taskId); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + TryTutorSelectedMon(taskId); } break; - case 4: - if (sub_81B15A4((u8*)ptr)) + case PARTY_ACTION_GIVE_MAILBOX_MAIL - 3: + if (IsSelectedMonNotEgg((u8*)slotPtr)) { PlaySE(SE_SELECT); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - sub_81B8474(taskId); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + TryGiveMailToSelectedMon(taskId); } break; - case 2: - case 3: - if (sub_81B15A4((u8*)ptr)) + case PARTY_ACTION_GIVE_ITEM - 3: + case PARTY_ACTION_GIVE_PC_ITEM - 3: + if (IsSelectedMonNotEgg((u8*)slotPtr)) { PlaySE(SE_SELECT); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - sub_81B7FAC(taskId); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + TryGiveItemOrMailToSelectedMon(taskId); } break; - case 5: + case PARTY_ACTION_SWITCH - 3: PlaySE(SE_SELECT); - sub_81B3938(taskId); + SwitchSelectedMons(taskId); break; - case 8: + case PARTY_ACTION_CHOOSE_AND_CLOSE - 3: PlaySE(SE_SELECT); Task_ClosePartyMenu(taskId); break; - case 10: - if (sub_81B15A4((u8*)ptr)) + case PARTY_ACTION_MINIGAME - 3: + if (IsSelectedMonNotEgg((u8*)slotPtr)) { - sub_81B21AC(taskId, (u8)*ptr); + TryEnterMonForMinigame(taskId, (u8)*slotPtr); } break; default: - case 1: - case 6: + case PARTY_ACTION_ABILITY_PREVENTS - 3: + case PARTY_ACTION_SWITCHING - 3: PlaySE(SE_SELECT); - sub_81B36FC(taskId); + Task_TryCreateSelectionWindow(taskId); break; } } } -static bool8 sub_81B15A4(u8 *slotPtr) +static bool8 IsSelectedMonNotEgg(u8 *slotPtr) { if (GetMonData(&gPlayerParty[*slotPtr], MON_DATA_IS_EGG) == TRUE) { @@ -2461,108 +1302,109 @@ static bool8 sub_81B15A4(u8 *slotPtr) return TRUE; } -static void sub_81B15D0(u8 taskId, s8 *ptr) +static void HandleChooseMonCancel(u8 taskId, s8 *slotPtr) { - switch (gUnknown_0203CEC8.unkB) + switch (gPartyMenu.action) { - case 1: + case PARTY_ACTION_SEND_OUT: PlaySE(SE_HAZURE); break; - case 8: - case 10: + case PARTY_ACTION_SWITCH: + case PARTY_ACTION_SOFTBOILED: PlaySE(SE_SELECT); - sub_81B407C(taskId); + FinishTwoMonAction(taskId); break; - case 13: + case PARTY_ACTION_MINIGAME: PlaySE(SE_SELECT); - sub_81B2210(taskId); + CancelParticipationPrompt(taskId); break; default: PlaySE(SE_SELECT); - if (sub_81B1660(taskId) != TRUE) + if (DisplayCancelChooseMonYesNo(taskId) != TRUE) { if (!sub_81221AC()) - gSpecialVar_0x8004 = 7; - gUnknown_0203CEE8 = 0; - *ptr = 7; + gSpecialVar_0x8004 = PARTY_SIZE + 1; + gPartyMenuUseExitCallback = FALSE; + *slotPtr = PARTY_SIZE + 1; Task_ClosePartyMenu(taskId); } break; } } -static bool8 sub_81B1660(u8 taskId) +static bool8 DisplayCancelChooseMonYesNo(u8 taskId) { const u8* stringPtr = NULL; - if (gUnknown_0203CEC8.unk8_0 == 2) + if (gPartyMenu.menuType == PARTY_MENU_TYPE_CONTEST) stringPtr = gText_CancelParticipation; - else if (gUnknown_0203CEC8.unk8_0 == 4) - stringPtr = sub_81B88BC(); + else if (gPartyMenu.menuType == PARTY_MENU_TYPE_CHOOSE_HALF) + stringPtr = GetFacilityCancelString(); if (stringPtr == NULL) return FALSE; - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); StringExpandPlaceholders(gStringVar4, stringPtr); - DisplayPartyMenuMessage(gStringVar4, 1); - gTasks[taskId].func = sub_81B16D4; + DisplayPartyMenuMessage(gStringVar4, TRUE); + gTasks[taskId].func = Task_CancelChooseMonYesNo; return TRUE; } -static void sub_81B16D4(u8 taskId) +static void Task_CancelChooseMonYesNo(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - sub_81B334C(); - gTasks[taskId].func = sub_81B1708; + PartyMenuDisplayYesNoMenu(); + gTasks[taskId].func = Task_HandleCancelChooseMonYesNoInput; } } -static void sub_81B1708(u8 taskId) +static void Task_HandleCancelChooseMonYesNoInput(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { case 0: - gUnknown_0203CEE8 = 0; - gUnknown_0203CEC8.slotId = 7; - sub_81B8558(); + gPartyMenuUseExitCallback = FALSE; + gPartyMenu.slotId = PARTY_SIZE + 1; + ClearSelectedPartyOrder(); Task_ClosePartyMenu(taskId); break; case MENU_B_PRESSED: PlaySE(SE_SELECT); + // fallthrough case 1: - sub_81B1C1C(taskId); + Task_ReturnToChooseMonAfterText(taskId); break; } } -static u16 PartyMenuButtonHandler(s8 *ptr) +static u16 PartyMenuButtonHandler(s8 *slotPtr) { s8 movementDir; switch (gMain.newAndRepeatedKeys) { case DPAD_UP: - movementDir = -1; + movementDir = MENU_DIR_UP; break; case DPAD_DOWN: - movementDir = 1; + movementDir = MENU_DIR_DOWN; break; case DPAD_LEFT: - movementDir = -2; + movementDir = MENU_DIR_LEFT; break; case DPAD_RIGHT: - movementDir = 2; + movementDir = MENU_DIR_RIGHT; break; default: - switch (sub_812210C()) + switch (GetLRKeysPressedAndHeld()) { - case 1: - movementDir = -1; + case MENU_L_PRESSED: + movementDir = MENU_DIR_UP; break; - case 2: - movementDir = 1; + case MENU_R_PRESSED: + movementDir = MENU_DIR_DOWN; break; default: movementDir = 0; @@ -2576,203 +1418,207 @@ static u16 PartyMenuButtonHandler(s8 *ptr) if (movementDir) { - UpdateCurrentPartySelection(ptr, movementDir); + UpdateCurrentPartySelection(slotPtr, movementDir); return 0; } - if ((gMain.newKeys & A_BUTTON) && *ptr == 7) + // Pressed Cancel + if ((gMain.newKeys & A_BUTTON) && *slotPtr == PARTY_SIZE + 1) return 2; return gMain.newKeys & (A_BUTTON | B_BUTTON); } -static void UpdateCurrentPartySelection(s8 *ptr, s8 movementDir) +static void UpdateCurrentPartySelection(s8 *slotPtr, s8 movementDir) { - s8 slot = *ptr; - u8 mode = gUnknown_0203CEC8.mode; + s8 newSlotId = *slotPtr; + u8 layout = gPartyMenu.layout; - if (mode == 0) - SetNewPartySelectTarget1(ptr, movementDir); + if (layout == PARTY_LAYOUT_SINGLE) + UpdatePartySelectionSingleLayout(slotPtr, movementDir); else - SetNewPartySelectTarget2(ptr, movementDir); + UpdatePartySelectionDoubleLayout(slotPtr, movementDir); - if (*ptr != slot) + if (*slotPtr != newSlotId) { PlaySE(SE_SELECT); - sub_81B0FCC(slot, 0); - sub_81B0FCC(*ptr, 1); + AnimatePartySlot(newSlotId, 0); + AnimatePartySlot(*slotPtr, 1); } } -static void SetNewPartySelectTarget1(s8 *ptr, s8 b) +static void UpdatePartySelectionSingleLayout(s8 *slotPtr, s8 movementDir) { - switch (b) + // PARTY_SIZE + 1 is Cancel, PARTY_SIZE is Confirm + switch (movementDir) { - case -1: - if (*ptr == 0) + case MENU_DIR_UP: + if (*slotPtr == 0) { - *ptr = 7; + *slotPtr = PARTY_SIZE + 1; } - else if (*ptr == 6) + else if (*slotPtr == PARTY_SIZE) { - *ptr = gPlayerPartyCount - 1; + *slotPtr = gPlayerPartyCount - 1; } - else if (*ptr == 7) + else if (*slotPtr == PARTY_SIZE + 1) { - if (gUnknown_0203CEC4->unk8_0) - *ptr = 6; + if (sPartyMenuInternal->chooseHalf) + *slotPtr = PARTY_SIZE; else - *ptr = gPlayerPartyCount - 1; + *slotPtr = gPlayerPartyCount - 1; } else { - (*ptr)--; + (*slotPtr)--; } break; - case 1: - if (*ptr == 7) + case MENU_DIR_DOWN: + if (*slotPtr == PARTY_SIZE + 1) { - *ptr = 0; + *slotPtr = 0; } else { - if (*ptr == gPlayerPartyCount - 1) + if (*slotPtr == gPlayerPartyCount - 1) { - if (gUnknown_0203CEC4->unk8_0) - *ptr = 6; + if (sPartyMenuInternal->chooseHalf) + *slotPtr = PARTY_SIZE; else - *ptr = 7; + *slotPtr = PARTY_SIZE + 1; } else { - (*ptr)++; + (*slotPtr)++; } } break; - case 2: - if (gPlayerPartyCount != 1 && *ptr == 0) + case MENU_DIR_RIGHT: + if (gPlayerPartyCount != 1 && *slotPtr == 0) { - if (gUnknown_0203CEC4->unk8_1 == 0) - *ptr = 1; + if (sPartyMenuInternal->lastSelectedSlot == 0) + *slotPtr = 1; else - *ptr = gUnknown_0203CEC4->unk8_1; + *slotPtr = sPartyMenuInternal->lastSelectedSlot; } break; - case -2: - if (*ptr != 0 && *ptr != 6 && *ptr != 7) + case MENU_DIR_LEFT: + if (*slotPtr != 0 && *slotPtr != PARTY_SIZE && *slotPtr != PARTY_SIZE + 1) { - gUnknown_0203CEC4->unk8_1 = *ptr; - *ptr = 0; + sPartyMenuInternal->lastSelectedSlot = *slotPtr; + *slotPtr = 0; } break; } } -static void SetNewPartySelectTarget2(s8 *ptr, s8 b) +static void UpdatePartySelectionDoubleLayout(s8 *slotPtr, s8 movementDir) { - s8 unk2 = b; + // PARTY_SIZE + 1 is Cancel, PARTY_SIZE is Confirm + // newSlot is used temporarily as a movement direction during its later assignment + s8 newSlot = movementDir; - switch (b) + switch (movementDir) { - case -1: - if (*ptr == 0) + case MENU_DIR_UP: + if (*slotPtr == 0) { - *ptr = 7; + *slotPtr = PARTY_SIZE + 1; break; } - else if (*ptr == 6) + else if (*slotPtr == PARTY_SIZE) { - *ptr = gPlayerPartyCount - 1; + *slotPtr = gPlayerPartyCount - 1; break; } - else if (*ptr == 7) + else if (*slotPtr == PARTY_SIZE + 1) { - if (gUnknown_0203CEC4->unk8_0) + if (sPartyMenuInternal->chooseHalf) { - *ptr = 6; + *slotPtr = PARTY_SIZE; break; } - (*ptr)--; + (*slotPtr)--; } - unk2 = sub_81B1B00(*ptr, unk2); - if (unk2 != -1) - *ptr = unk2; + newSlot = GetNewSlotDoubleLayout(*slotPtr, newSlot); + if (newSlot != -1) + *slotPtr = newSlot; break; - case 1: - if (*ptr == 6) + case MENU_DIR_DOWN: + if (*slotPtr == PARTY_SIZE) { - *ptr = 7; + *slotPtr = PARTY_SIZE + 1; } - else if (*ptr == 7) + else if (*slotPtr == PARTY_SIZE + 1) { - *ptr = 0; + *slotPtr = 0; } else { - unk2 = sub_81B1B00(*ptr, 1); - if (unk2 == -1) + newSlot = GetNewSlotDoubleLayout(*slotPtr, MENU_DIR_DOWN); + if (newSlot == -1) { - if (gUnknown_0203CEC4->unk8_0) - *ptr = 6; + if (sPartyMenuInternal->chooseHalf) + *slotPtr = PARTY_SIZE; else - *ptr = 7; + *slotPtr = PARTY_SIZE + 1; } else { - *ptr = unk2; + *slotPtr = newSlot; } } break; - case 2: - if (*ptr == 0) + case MENU_DIR_RIGHT: + if (*slotPtr == 0) { - if (gUnknown_0203CEC4->unk8_1 == 3) + if (sPartyMenuInternal->lastSelectedSlot == 3) { if (GetMonData(&gPlayerParty[3], MON_DATA_SPECIES) != SPECIES_NONE) - *ptr = 3; + *slotPtr = 3; } else if (GetMonData(&gPlayerParty[2], MON_DATA_SPECIES) != SPECIES_NONE) { - *ptr = 2; + *slotPtr = 2; } } - else if (*ptr == 1) + else if (*slotPtr == 1) { - if (gUnknown_0203CEC4->unk8_1 == 5) + if (sPartyMenuInternal->lastSelectedSlot == 5) { if (GetMonData(&gPlayerParty[5], MON_DATA_SPECIES) != SPECIES_NONE) - *ptr = 5; + *slotPtr = 5; } else if (GetMonData(&gPlayerParty[4], MON_DATA_SPECIES) != SPECIES_NONE) { - *ptr = 4; + *slotPtr = 4; } } break; - case -2: - if (*ptr == 2 || *ptr == 3) + case MENU_DIR_LEFT: + if (*slotPtr == 2 || *slotPtr == 3) { - gUnknown_0203CEC4->unk8_1 = *ptr; - *ptr = 0; + sPartyMenuInternal->lastSelectedSlot = *slotPtr; + *slotPtr = 0; } - else if (*ptr == 4 || *ptr == 5) + else if (*slotPtr == 4 || *slotPtr == 5) { - gUnknown_0203CEC4->unk8_1 = *ptr; - *ptr = 1; + sPartyMenuInternal->lastSelectedSlot = *slotPtr; + *slotPtr = 1; } break; } } -static s8 sub_81B1B00(s8 a, s8 b) +static s8 GetNewSlotDoubleLayout(s8 slotId, s8 movementDir) { while (TRUE) { - a += b; - if ((u8)a >= 6) + slotId += movementDir; + if ((u8)slotId >= PARTY_SIZE) return -1; - if (GetMonData(&gPlayerParty[a], MON_DATA_SPECIES) != SPECIES_NONE) - return a; + if (GetMonData(&gPlayerParty[slotId], MON_DATA_SPECIES) != SPECIES_NONE) + return slotId; } } @@ -2782,21 +1628,23 @@ u8* GetMonNickname(struct Pokemon *mon, u8 *dest) return StringGetEnd10(dest); } -u8 DisplayPartyMenuMessage(const u8* str, u8 b) +#define tKeepOpen data[0] + +u8 DisplayPartyMenuMessage(const u8* str, bool8 keepOpen) { u8 taskId; PartyMenuPrintText(str); - taskId = CreateTask(sub_81B1B8C, 1); - gTasks[taskId].data[0] = b; + taskId = CreateTask(Task_PrintAndWaitForText, 1); + gTasks[taskId].tKeepOpen = keepOpen; return taskId; } -static void sub_81B1B8C(u8 taskId) +static void Task_PrintAndWaitForText(u8 taskId) { if (RunTextPrintersRetIsActive(6) != TRUE) { - if (gTasks[taskId].data[0] == 0) + if (gTasks[taskId].tKeepOpen == FALSE) { ClearStdWindowAndFrameToTransparent(6, 0); ClearWindowTilemap(6); @@ -2805,75 +1653,77 @@ static void sub_81B1B8C(u8 taskId) } } -bool8 sub_81B1BD4(void) +#undef tKeepOpen + +bool8 IsPartyMenuTextPrinterActive(void) { - return FuncIsActiveTask(sub_81B1B8C); + return FuncIsActiveTask(Task_PrintAndWaitForText); } -static void sub_81B1BE8(u8 taskId) +static void Task_WaitForLinkAndReturnToChooseMon(u8 taskId) { if (sub_81221EC() != TRUE) { - DisplayPartyMenuStdMessage(0); - gTasks[taskId].func = sub_81B1370; + DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); + gTasks[taskId].func = Task_HandleChooseMonInput; } } -static void sub_81B1C1C(u8 taskId) +static void Task_ReturnToChooseMonAfterText(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { ClearStdWindowAndFrameToTransparent(6, 0); ClearWindowTilemap(6); if (sub_81221AC() == TRUE) { - gTasks[taskId].func = sub_81B1BE8; + gTasks[taskId].func = Task_WaitForLinkAndReturnToChooseMon; } else { - DisplayPartyMenuStdMessage(0); - gTasks[taskId].func = sub_81B1370; + DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); + gTasks[taskId].func = Task_HandleChooseMonInput; } } } -static void sub_81B1C84(struct Pokemon *mon, u16 item, u8 c, u8 unused) +static void DisplayGaveHeldItemMessage(struct Pokemon *mon, u16 item, bool8 keepOpen, u8 unused) { GetMonNickname(mon, gStringVar1); CopyItemName(item, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_PkmnWasGivenItem); - DisplayPartyMenuMessage(gStringVar4, c); + DisplayPartyMenuMessage(gStringVar4, keepOpen); schedule_bg_copy_tilemap_to_vram(2); } -static void sub_81B1CD0(struct Pokemon *mon, u16 item, u8 c) +static void DisplayTookHeldItemMessage(struct Pokemon *mon, u16 item, bool8 keepOpen) { GetMonNickname(mon, gStringVar1); CopyItemName(item, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_ReceivedItemFromPkmn); - DisplayPartyMenuMessage(gStringVar4, c); + DisplayPartyMenuMessage(gStringVar4, keepOpen); schedule_bg_copy_tilemap_to_vram(2); } -static void sub_81B1D1C(struct Pokemon *mon, u16 item, u8 c) +static void DisplayAlreadyHoldingItemSwitchMessage(struct Pokemon *mon, u16 item, bool8 keepOpen) { GetMonNickname(mon, gStringVar1); CopyItemName(item, gStringVar2); - StringExpandPlaceholders(gStringVar4, gText_SwitchPkmnItem); - DisplayPartyMenuMessage(gStringVar4, c); + StringExpandPlaceholders(gStringVar4, gText_PkmnAlreadyHoldingItemSwitch); + DisplayPartyMenuMessage(gStringVar4, keepOpen); schedule_bg_copy_tilemap_to_vram(2); } -static void sub_81B1D68(u16 item, u16 item2, u8 c) +static void DisplaySwitchedHeldItemMessage(u16 item, u16 item2, bool8 keepOpen) { CopyItemName(item, gStringVar1); CopyItemName(item2, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_SwitchedPkmnItem); - DisplayPartyMenuMessage(gStringVar4, c); + DisplayPartyMenuMessage(gStringVar4, keepOpen); schedule_bg_copy_tilemap_to_vram(2); } -static void sub_81B1DB8(struct Pokemon *mon, u16 item) +static void GiveItemToMon(struct Pokemon *mon, u16 item) { u8 itemBytes[2]; @@ -2901,71 +1751,89 @@ static u8 TryTakeMonItem(struct Pokemon* mon) return 2; } -static void pokemon_item_not_removed(u16 itemUnused) +static void BufferBagFullCantTakeItemMessage(u16 itemUnused) { StringExpandPlaceholders(gStringVar4, gText_BagFullCouldNotRemoveItem); } -static void sub_81B1E60(u8 taskId) +#define tHP data[0] +#define tMaxHP data[1] +#define tHPIncrement data[2] +#define tHPToAdd data[3] +#define tPartyId data[4] +#define tStartHP data[5] + +static void Task_PartyMenuModifyHP(u8 taskId) { s16 *data = gTasks[taskId].data; - data[0] += data[2]; - data[3]--; - SetMonData(&gPlayerParty[data[4]], MON_DATA_HP, &data[0]); - DisplayPartyPokemonHPCheck(&gPlayerParty[data[4]], &gUnknown_0203CEDC[data[4]], 1); - DisplayPartyPokemonHPBarCheck(&gPlayerParty[data[4]], &gUnknown_0203CEDC[data[4]]); - if (data[3] == 0 || data[0] == 0 || data[0] == data[1]) + tHP += tHPIncrement; + tHPToAdd--; + SetMonData(&gPlayerParty[tPartyId], MON_DATA_HP, &tHP); + DisplayPartyPokemonHPCheck(&gPlayerParty[tPartyId], &sPartyMenuBoxes[tPartyId], 1); + DisplayPartyPokemonHPBarCheck(&gPlayerParty[tPartyId], &sPartyMenuBoxes[tPartyId]); + if (tHPToAdd == 0 || tHP == 0 || tHP == tMaxHP) { - if (data[0] > data[5]) - ConvertIntToDecimalStringN(gStringVar2, data[0] - data[5], STR_CONV_MODE_LEFT_ALIGN, 3); + // If HP was recovered, buffer the amount recovered + if (tHP > tStartHP) + ConvertIntToDecimalStringN(gStringVar2, tHP - tStartHP, STR_CONV_MODE_LEFT_ALIGN, 3); + SwitchTaskToFollowupFunc(taskId); } } -void sub_81B1F18(u8 taskId, u8 slot, s8 c, s16 HPDifference, TaskFunc func) +void PartyMenuModifyHP(u8 taskId, u8 slot, s8 hpIncrement, s16 hpDifference, TaskFunc task) { struct Pokemon *mon = &gPlayerParty[slot]; s16 *data = gTasks[taskId].data; - data[0] = GetMonData(mon, MON_DATA_HP); - data[1] = GetMonData(mon, MON_DATA_MAX_HP); - data[2] = c; - data[3] = HPDifference; - data[4] = slot; - data[5] = data[0]; - SetTaskFuncWithFollowupFunc(taskId, sub_81B1E60, func); + tHP = GetMonData(mon, MON_DATA_HP); + tMaxHP = GetMonData(mon, MON_DATA_MAX_HP); + tHPIncrement = hpIncrement; + tHPToAdd = hpDifference; + tPartyId = slot; + tStartHP = tHP; + SetTaskFuncWithFollowupFunc(taskId, Task_PartyMenuModifyHP, task); } -static void sub_81B1FA8(u8 taskId, u8 b, u32 hp) +// The usage of hp in this function is mostly nonsense +// Because caseId is always passed 0, none of the other cases ever occur +static void ResetHPTaskData(u8 taskId, u8 caseId, u32 hp) { s16 *data = gTasks[taskId].data; - switch (b) // only case 0 is used + switch (caseId) // always zero { case 0: - data[0] = hp; - data[5] = hp; + tHP = hp; + tStartHP = hp; break; case 1: - data[1] = hp; + tMaxHP = hp; break; case 2: - data[2] = hp; + tHPIncrement = hp; break; case 3: - data[3] = hp; + tHPToAdd = hp; break; case 4: - data[4] = hp; + tPartyId = hp; break; case 5: - SetTaskFuncWithFollowupFunc(taskId, sub_81B1E60, (TaskFunc)hp); // >casting hp as a taskfunc + SetTaskFuncWithFollowupFunc(taskId, Task_PartyMenuModifyHP, (TaskFunc)hp); // >casting hp as a taskfunc break; } } -u8 pokemon_ailments_get_primary(u32 status) +#undef tHP +#undef tMaxHP +#undef tHPIncrement +#undef tHPToAdd +#undef tPartyId +#undef tStartHP + +u8 GetAilmentFromStatus(u32 status) { if (status & STATUS1_PSN_ANY) return AILMENT_PSN; @@ -2986,7 +1854,7 @@ u8 GetMonAilment(struct Pokemon *mon) if (GetMonData(mon, MON_DATA_HP) == 0) return AILMENT_FNT; - ailment = pokemon_ailments_get_primary(GetMonData(mon, MON_DATA_STATUS)); + ailment = GetAilmentFromStatus(GetMonData(mon, MON_DATA_STATUS)); if (ailment != AILMENT_NONE) return ailment; if (CheckPartyPokerus(mon, 0)) @@ -2994,16 +1862,16 @@ u8 GetMonAilment(struct Pokemon *mon) return AILMENT_NONE; } -static void sub_81B209C(void) +static void SetPartyMonsAllowedInMinigame(void) { u16 *ptr; - if (gUnknown_0203CEC8.unk8_0 == 11) + if (gPartyMenu.menuType == PARTY_MENU_TYPE_MINIGAME) { u8 i; - ptr = &gUnknown_0203CEC8.unkE; - gUnknown_0203CEC8.unkE = 0; + ptr = &gPartyMenu.data1; + gPartyMenu.data1 = 0; if (gSpecialVar_0x8005 == 0) { for (i = 0; i < gPlayerPartyCount; i++) @@ -3012,7 +1880,7 @@ static void sub_81B209C(void) else { for (i = 0; i < gPlayerPartyCount; i++) - *ptr += sub_81B2164(&gPlayerParty[i]) << i; + *ptr += IsMonAllowedInDodrioBerryPicking(&gPlayerParty[i]) << i; } } } @@ -3024,25 +1892,24 @@ static bool16 IsMonAllowedInPokemonJump(struct Pokemon *mon) return FALSE; } -// Dodrio Berry Picking select? -static bool16 sub_81B2164(struct Pokemon *mon) +static bool16 IsMonAllowedInDodrioBerryPicking(struct Pokemon *mon) { if (GetMonData(mon, MON_DATA_IS_EGG) != TRUE && GetMonData(mon, MON_DATA_SPECIES) == SPECIES_DODRIO) return TRUE; return FALSE; } -static bool8 sub_81B218C(u8 slot) +static bool8 IsMonAllowedInMinigame(u8 slot) { - if (!((gUnknown_0203CEC8.unkE >> slot) & 1)) + if (!((gPartyMenu.data1 >> slot) & 1)) return FALSE; return TRUE; } -static void sub_81B21AC(u8 taskId, u8 slot) +static void TryEnterMonForMinigame(u8 taskId, u8 slot) { - if (sub_81B218C(slot) == TRUE) + if (IsMonAllowedInMinigame(slot) == TRUE) { PlaySE(SE_SELECT); gSpecialVar_0x8004 = slot; @@ -3051,40 +1918,41 @@ static void sub_81B21AC(u8 taskId, u8 slot) else { PlaySE(SE_HAZURE); - DisplayPartyMenuMessage(gText_PkmnCantParticipate, 0); + DisplayPartyMenuMessage(gText_PkmnCantParticipate, FALSE); schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = sub_81B1C1C; + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; } } -static void sub_81B2210(u8 taskId) +static void CancelParticipationPrompt(u8 taskId) { - DisplayPartyMenuMessage(gText_CancelParticipation, 1); + DisplayPartyMenuMessage(gText_CancelParticipation, TRUE); schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = sub_81B2248; + gTasks[taskId].func = Task_CancelParticipationYesNo; } -static void sub_81B2248(u8 taskId) +static void Task_CancelParticipationYesNo(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - sub_81B334C(); - gTasks[taskId].func = sub_81B227C; + PartyMenuDisplayYesNoMenu(); + gTasks[taskId].func = Task_HandleCancelParticipationYesNoInput; } } -static void sub_81B227C(u8 taskId) +static void Task_HandleCancelParticipationYesNoInput(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { case 0: - gSpecialVar_0x8004 = 7; + gSpecialVar_0x8004 = PARTY_SIZE + 1; Task_ClosePartyMenu(taskId); break; case MENU_B_PRESSED: PlaySE(SE_SELECT); + // fallthrough case 1: - gTasks[taskId].func = sub_81B1C1C; + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; break; } } @@ -3132,23 +2000,23 @@ static bool8 CanLearnTutorMove(u16 species, u8 tutor) return FALSE; } -static void sub_81B239C(u8 a) +static void InitPartyMenuWindows(u8 layout) { u8 i; - switch (a) + switch (layout) { - case 0: - InitWindows(gUnknown_08615810); + case PARTY_LAYOUT_SINGLE: + InitWindows(sSinglePartyMenuWindowTemplate); break; - case 1: - InitWindows(gUnknown_08615850); + case PARTY_LAYOUT_DOUBLE: + InitWindows(sDoublePartyMenuWindowTemplate); break; - case 2: - InitWindows(gUnknown_08615890); + case PARTY_LAYOUT_MULTI: + InitWindows(sMultiPartyMenuWindowTemplate); break; - default: - InitWindows(gUnknown_086158D0); + default: // PARTY_LAYOUT_MULTI_SHOWCASE + InitWindows(sShowcaseMultiPartyMenuWindowTemplate); break; } DeactivateAllTextPrinters(); @@ -3159,51 +2027,53 @@ static void sub_81B239C(u8 a) LoadPalette(gUnknown_0860F074, 0xF0, 0x20); } -static void sub_81B2428(bool8 a) +static void CreateCancelConfirmWindows(bool8 chooseHalf) { - u8 firstWindowId; - u8 windowId; + u8 confirmWindowId; + u8 cancelWindowId; u8 offset; u8 mainOffset; - if (gUnknown_0203CEC8.unk8_0 != 5) + if (gPartyMenu.menuType != PARTY_MENU_TYPE_MULTI_SHOWCASE) { - if (a == TRUE) + if (chooseHalf == TRUE) { - firstWindowId = AddWindow(&gUnknown_08615918); - FillWindowPixelBuffer(firstWindowId, PIXEL_FILL(0)); + confirmWindowId = AddWindow(&sConfirmButtonWindowTemplate); + FillWindowPixelBuffer(confirmWindowId, PIXEL_FILL(0)); mainOffset = GetStringCenterAlignXOffset(0, gMenuText_Confirm, 48); - AddTextPrinterParameterized4(firstWindowId, 0, mainOffset, 1, 0, 0, sFontColorTable[0], -1, gMenuText_Confirm); - PutWindowTilemap(firstWindowId); - CopyWindowToVram(firstWindowId, 2); - windowId = AddWindow(&gUnknown_08615910); + AddTextPrinterParameterized4(confirmWindowId, 0, mainOffset, 1, 0, 0, sFontColorTable[0], -1, gMenuText_Confirm); + PutWindowTilemap(confirmWindowId); + CopyWindowToVram(confirmWindowId, 2); + cancelWindowId = AddWindow(&sMultiCancelButtonWindowTemplate); offset = 0; } else { - windowId = AddWindow(&gUnknown_08615908); + cancelWindowId = AddWindow(&sCancelButtonWindowTemplate); offset = 3; } - FillWindowPixelBuffer(windowId, PIXEL_FILL(0)); - if (gUnknown_0203CEC8.unk8_0 != 10) + FillWindowPixelBuffer(cancelWindowId, PIXEL_FILL(0)); + + // Branches are functionally identical. Second branch is never reached, Spin Trade wasnt fully implemented + if (gPartyMenu.menuType != PARTY_MENU_TYPE_SPIN_TRADE) { mainOffset = GetStringCenterAlignXOffset(0, gText_Cancel, 48); - AddTextPrinterParameterized3(windowId, 0, mainOffset + offset, 1, sFontColorTable[0], -1, gText_Cancel); + AddTextPrinterParameterized3(cancelWindowId, 0, mainOffset + offset, 1, sFontColorTable[0], -1, gText_Cancel); } else { mainOffset = GetStringCenterAlignXOffset(0, gText_Cancel2, 48); - AddTextPrinterParameterized3(windowId, 0, mainOffset + offset, 1, sFontColorTable[0], -1, gText_Cancel2); + AddTextPrinterParameterized3(cancelWindowId, 0, mainOffset + offset, 1, sFontColorTable[0], -1, gText_Cancel2); } - PutWindowTilemap(windowId); - CopyWindowToVram(windowId, 2); + PutWindowTilemap(cancelWindowId); + CopyWindowToVram(cancelWindowId, 2); schedule_bg_copy_tilemap_to_vram(0); } } -static u16* GetPartyMenuPaletteFromBuffer(u8 paletteId) +static u16* GetPartyMenuPalBufferPtr(u8 paletteId) { - return &gUnknown_0203CEC4->palBuffer[paletteId]; + return &sPartyMenuInternal->palBuffer[paletteId]; } static void BlitBitmapToPartyWindow(u8 windowId, const u8 *b, u8 c, u8 x, u8 y, u8 width, u8 height) @@ -3216,14 +2086,14 @@ static void BlitBitmapToPartyWindow(u8 windowId, const u8 *b, u8 c, u8 x, u8 y, for (i = 0; i < height; i++) { for (j = 0; j < width; j++) - CpuCopy16(GetPartyMiscGraphicsTile(b[x + j + ((y + i) * c)]), &pixels[(i * width + j) * 32], 32); + CpuCopy16(GetPartyMenuBgTile(b[x + j + ((y + i) * c)]), &pixels[(i * width + j) * 32], 32); } BlitBitmapToWindow(windowId, pixels, x * 8, y * 8, width * 8, height * 8); Free(pixels); } } -static void BlitBitmapToPartyWindow_Default1(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 isEgg) +static void BlitBitmapToPartyWindow_LeftColumn(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 isEgg) { if (width == 0 && height == 0) { @@ -3236,7 +2106,7 @@ static void BlitBitmapToPartyWindow_Default1(u8 windowId, u8 x, u8 y, u8 width, BlitBitmapToPartyWindow(windowId, sMainSlotTileNums_Egg, 10, x, y, width, height); } -static void BlitBitmapToPartyWindow_Default2(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 isEgg) +static void BlitBitmapToPartyWindow_RightColumn(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 isEgg) { if (width == 0 && height == 0) { @@ -3254,126 +2124,87 @@ static void DrawEmptySlot(u8 windowId) BlitBitmapToPartyWindow(windowId, sEmptySlotTileNums, 18, 0, 0, 18, 3); } -static void UpdateSelectedPartyBox(struct Struct203CEDC *ptr, u8 bitfield) +#define LOAD_PARTY_BOX_PAL(paletteIds, paletteOffsets) \ +{ \ + LoadPalette(GetPartyMenuPalBufferPtr(paletteIds[0]), paletteOffsets[0] + palNum, 2); \ + LoadPalette(GetPartyMenuPalBufferPtr(paletteIds[1]), paletteOffsets[1] + palNum, 2); \ + LoadPalette(GetPartyMenuPalBufferPtr(paletteIds[2]), paletteOffsets[2] + palNum, 2); \ +} + +static void LoadPartyBoxPalette(struct PartyMenuBox *menuBox, u8 palFlags) { - u8 palNum = GetWindowAttribute(ptr->windowId, WINDOW_PALETTE_NUM) * 16; + u8 palNum = GetWindowAttribute(menuBox->windowId, WINDOW_PALETTE_NUM) * 16; - if (bitfield & 0x40) + if (palFlags & PARTY_PAL_NO_MON) { - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AF1[0]), gUnknown_08615AC0[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AF1[1]), gUnknown_08615AC0[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AF1[2]), gUnknown_08615AC0[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxNoMonPalIds, sPartyBoxNoMonPalOffsets); } - else if (bitfield & 0x20) + else if (palFlags & PARTY_PAL_TO_SOFTBOIL) { - if (bitfield & 1) + if (palFlags & PARTY_PAL_SELECTED) { - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[0]), gUnknown_08615ABA[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[1]), gUnknown_08615ABA[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[2]), gUnknown_08615ABA[2] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[0]), gUnknown_08615ABD[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[1]), gUnknown_08615ABD[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[2]), gUnknown_08615ABD[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionPalIds2, sPartyBoxPalOffsets2); } else { - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[0]), gUnknown_08615ABA[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[1]), gUnknown_08615ABA[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[2]), gUnknown_08615ABA[2] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEE[0]), gUnknown_08615ABD[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEE[1]), gUnknown_08615ABD[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEE[2]), gUnknown_08615ABD[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds2, sPartyBoxPalOffsets2); } } - else if (bitfield & 0x10) + else if (palFlags & PARTY_PAL_SWITCHING) { - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[0]), gUnknown_08615ABA[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[1]), gUnknown_08615ABA[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[2]), gUnknown_08615ABA[2] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEE[0]), gUnknown_08615ABD[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEE[1]), gUnknown_08615ABD[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEE[2]), gUnknown_08615ABD[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds2, sPartyBoxPalOffsets2); } - else if (bitfield & 4) + else if (palFlags & PARTY_PAL_TO_SWITCH) { - if (bitfield & 1) + if (palFlags & PARTY_PAL_SELECTED) { - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[0]), gUnknown_08615ABA[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[1]), gUnknown_08615ABA[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[2]), gUnknown_08615ABA[2] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[0]), gUnknown_08615ABD[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[1]), gUnknown_08615ABD[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[2]), gUnknown_08615ABD[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionPalIds2, sPartyBoxPalOffsets2); } else { - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[0]), gUnknown_08615ABA[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[1]), gUnknown_08615ABA[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADF[2]), gUnknown_08615ABA[2] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEE[0]), gUnknown_08615ABD[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEE[1]), gUnknown_08615ABD[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEE[2]), gUnknown_08615ABD[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxSelectedForActionPalIds2, sPartyBoxPalOffsets2); } } - else if (bitfield & 2) + else if (palFlags & PARTY_PAL_FAINTED) { - if (bitfield & 1) + if (palFlags & PARTY_PAL_SELECTED) { - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADC[0]), gUnknown_08615ABA[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADC[1]), gUnknown_08615ABA[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ADC[2]), gUnknown_08615ABA[2] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[0]), gUnknown_08615ABD[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[1]), gUnknown_08615ABD[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[2]), gUnknown_08615ABD[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionFaintedPalIds, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionPalIds2, sPartyBoxPalOffsets2); } else { - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AD3[0]), gUnknown_08615ABA[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AD3[1]), gUnknown_08615ABA[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AD3[2]), gUnknown_08615ABA[2] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AE8[0]), gUnknown_08615ABD[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AE8[1]), gUnknown_08615ABD[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AE8[2]), gUnknown_08615ABD[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxFaintedPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxFaintedPalIds2, sPartyBoxPalOffsets2); } } - else if (bitfield & 8) + else if (palFlags & PARTY_PAL_MULTI_ALT) { - if (bitfield & 1) + if (palFlags & PARTY_PAL_SELECTED) { - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AD9[0]), gUnknown_08615ABA[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AD9[1]), gUnknown_08615ABA[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AD9[2]), gUnknown_08615ABA[2] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[0]), gUnknown_08615ABD[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[1]), gUnknown_08615ABD[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[2]), gUnknown_08615ABD[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionMultiPalIds, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionPalIds2, sPartyBoxPalOffsets2); } else { - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AD0[0]), gUnknown_08615ABA[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AD0[1]), gUnknown_08615ABA[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AD0[2]), gUnknown_08615ABA[2] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AE5[0]), gUnknown_08615ABD[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AE5[1]), gUnknown_08615ABD[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AE5[2]), gUnknown_08615ABD[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxMultiPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxMultiPalIds2, sPartyBoxPalOffsets2); } } - else if (bitfield & 1) + else if (palFlags & PARTY_PAL_SELECTED) { - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AD6[0]), gUnknown_08615ABA[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AD6[1]), gUnknown_08615ABA[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AD6[2]), gUnknown_08615ABA[2] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[0]), gUnknown_08615ABD[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[1]), gUnknown_08615ABD[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AEB[2]), gUnknown_08615ABD[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxCurrSelectionPalIds2, sPartyBoxPalOffsets2); } else { - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ACD[0]), gUnknown_08615ABA[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ACD[1]), gUnknown_08615ABA[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ACD[2]), gUnknown_08615ABA[2] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AE2[0]), gUnknown_08615ABD[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AE2[1]), gUnknown_08615ABD[1] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AE2[2]), gUnknown_08615ABD[2] + palNum, 2); + LOAD_PARTY_BOX_PAL(sPartyBoxEmptySlotPalIds1, sPartyBoxPalOffsets1); + LOAD_PARTY_BOX_PAL(sPartyBoxEmptySlotPalIds2, sPartyBoxPalOffsets2); } } @@ -3382,20 +2213,20 @@ static void DisplayPartyPokemonBarDetail(u8 windowId, const u8 *str, u8 color, c AddTextPrinterParameterized3(windowId, 0, align[0], align[1], sFontColorTable[color], 0, str); } -static void DisplayPartyPokemonNickname(struct Pokemon *mon, struct Struct203CEDC *ptr, u8 c) +static void DisplayPartyPokemonNickname(struct Pokemon *mon, struct PartyMenuBox *menuBox, u8 c) { u8 nickname[POKEMON_NAME_LENGTH + 1]; if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE) { if (c == 1) - ptr->unk0->unk0(ptr->windowId, ptr->unk0->unk4[0] >> 3, ptr->unk0->unk4[1] >> 3, ptr->unk0->unk4[2] >> 3, ptr->unk0->unk4[3] >> 3, 0); + menuBox->infoRects->blitFunc(menuBox->windowId, menuBox->infoRects->dimensions[0] >> 3, menuBox->infoRects->dimensions[1] >> 3, menuBox->infoRects->dimensions[2] >> 3, menuBox->infoRects->dimensions[3] >> 3, FALSE); GetMonNickname(mon, nickname); - DisplayPartyPokemonBarDetail(ptr->windowId, nickname, 0, ptr->unk0->unk4); + DisplayPartyPokemonBarDetail(menuBox->windowId, nickname, 0, menuBox->infoRects->dimensions); } } -static void DisplayPartyPokemonLevelCheck(struct Pokemon *mon, struct Struct203CEDC *ptr, u8 c) +static void DisplayPartyPokemonLevelCheck(struct Pokemon *mon, struct PartyMenuBox *menuBox, u8 c) { if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE) { @@ -3403,34 +2234,34 @@ static void DisplayPartyPokemonLevelCheck(struct Pokemon *mon, struct Struct203C if (ailment == AILMENT_NONE || ailment == AILMENT_PKRS) { if (c != 0) - ptr->unk0->unk0(ptr->windowId, ptr->unk0->unk4[4] >> 3, (ptr->unk0->unk4[5] >> 3) + 1, ptr->unk0->unk4[6] >> 3, ptr->unk0->unk4[7] >> 3, 0); + menuBox->infoRects->blitFunc(menuBox->windowId, menuBox->infoRects->dimensions[4] >> 3, (menuBox->infoRects->dimensions[5] >> 3) + 1, menuBox->infoRects->dimensions[6] >> 3, menuBox->infoRects->dimensions[7] >> 3, FALSE); if (c != 2) - DisplayPartyPokemonLevel(GetMonData(mon, MON_DATA_LEVEL), ptr); + DisplayPartyPokemonLevel(GetMonData(mon, MON_DATA_LEVEL), menuBox); } } } -static void DisplayPartyPokemonLevel(u8 level, struct Struct203CEDC *ptr) +static void DisplayPartyPokemonLevel(u8 level, struct PartyMenuBox *menuBox) { ConvertIntToDecimalStringN(gStringVar2, level, STR_CONV_MODE_LEFT_ALIGN, 3); StringCopy(gStringVar1, gText_LevelSymbol); StringAppend(gStringVar1, gStringVar2); - DisplayPartyPokemonBarDetail(ptr->windowId, gStringVar1, 0, &ptr->unk0->unk4[4]); + DisplayPartyPokemonBarDetail(menuBox->windowId, gStringVar1, 0, &menuBox->infoRects->dimensions[4]); } -static void DisplayPartyPokemonGenderNidoranCheck(struct Pokemon *mon, struct Struct203CEDC *ptr, u8 c) +static void DisplayPartyPokemonGenderNidoranCheck(struct Pokemon *mon, struct PartyMenuBox *menuBox, u8 c) { u8 nickname[POKEMON_NAME_LENGTH + 1]; if (c == 1) - ptr->unk0->unk0(ptr->windowId, ptr->unk0->unk4[8] >> 3, (ptr->unk0->unk4[9] >> 3) + 1, ptr->unk0->unk4[10] >> 3, ptr->unk0->unk4[11] >> 3, 0); + menuBox->infoRects->blitFunc(menuBox->windowId, menuBox->infoRects->dimensions[8] >> 3, (menuBox->infoRects->dimensions[9] >> 3) + 1, menuBox->infoRects->dimensions[10] >> 3, menuBox->infoRects->dimensions[11] >> 3, FALSE); GetMonNickname(mon, nickname); - DisplayPartyPokemonGender(GetMonGender(mon), GetMonData(mon, MON_DATA_SPECIES), nickname, ptr); + DisplayPartyPokemonGender(GetMonGender(mon), GetMonData(mon, MON_DATA_SPECIES), nickname, menuBox); } -static void DisplayPartyPokemonGender(u8 gender, u16 species, u8 *nickname, struct Struct203CEDC *ptr) +static void DisplayPartyPokemonGender(u8 gender, u16 species, u8 *nickname, struct PartyMenuBox *menuBox) { - u8 palNum = GetWindowAttribute(ptr->windowId, WINDOW_PALETTE_NUM) * 16; + u8 palNum = GetWindowAttribute(menuBox->windowId, WINDOW_PALETTE_NUM) * 16; if (species == SPECIES_NONE) return; @@ -3439,108 +2270,108 @@ static void DisplayPartyPokemonGender(u8 gender, u16 species, u8 *nickname, stru switch (gender) { case MON_MALE: - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC3[0]), gUnknown_08615AB6[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC3[1]), gUnknown_08615AB6[1] + palNum, 2); - DisplayPartyPokemonBarDetail(ptr->windowId, gText_MaleSymbol, 2, &ptr->unk0->unk4[8]); + LoadPalette(GetPartyMenuPalBufferPtr(sGenderMalePalIds[0]), sGenderPalOffsets[0] + palNum, 2); + LoadPalette(GetPartyMenuPalBufferPtr(sGenderMalePalIds[1]), sGenderPalOffsets[1] + palNum, 2); + DisplayPartyPokemonBarDetail(menuBox->windowId, gText_MaleSymbol, 2, &menuBox->infoRects->dimensions[8]); break; case MON_FEMALE: - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC5[0]), gUnknown_08615AB6[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC5[1]), gUnknown_08615AB6[1] + palNum, 2); - DisplayPartyPokemonBarDetail(ptr->windowId, gText_FemaleSymbol, 2, &ptr->unk0->unk4[8]); + LoadPalette(GetPartyMenuPalBufferPtr(sGenderFemalePalIds[0]), sGenderPalOffsets[0] + palNum, 2); + LoadPalette(GetPartyMenuPalBufferPtr(sGenderFemalePalIds[1]), sGenderPalOffsets[1] + palNum, 2); + DisplayPartyPokemonBarDetail(menuBox->windowId, gText_FemaleSymbol, 2, &menuBox->infoRects->dimensions[8]); break; } } -static void DisplayPartyPokemonHPCheck(struct Pokemon *mon, struct Struct203CEDC *ptr, u8 c) +static void DisplayPartyPokemonHPCheck(struct Pokemon *mon, struct PartyMenuBox *menuBox, u8 c) { if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE) { if (c != 0) - ptr->unk0->unk0(ptr->windowId, ptr->unk0->unk4[12] >> 3, (ptr->unk0->unk4[13] >> 3) + 1, ptr->unk0->unk4[14] >> 3, ptr->unk0->unk4[15] >> 3, 0); + menuBox->infoRects->blitFunc(menuBox->windowId, menuBox->infoRects->dimensions[12] >> 3, (menuBox->infoRects->dimensions[13] >> 3) + 1, menuBox->infoRects->dimensions[14] >> 3, menuBox->infoRects->dimensions[15] >> 3, FALSE); if (c != 2) - DisplayPartyPokemonHP(GetMonData(mon, MON_DATA_HP), ptr); + DisplayPartyPokemonHP(GetMonData(mon, MON_DATA_HP), menuBox); } } -static void DisplayPartyPokemonHP(u16 hp, struct Struct203CEDC *ptr) +static void DisplayPartyPokemonHP(u16 hp, struct PartyMenuBox *menuBox) { u8 *strOut = ConvertIntToDecimalStringN(gStringVar1, hp, STR_CONV_MODE_RIGHT_ALIGN, 3); strOut[0] = CHAR_SLASH; strOut[1] = EOS; - DisplayPartyPokemonBarDetail(ptr->windowId, gStringVar1, 0, &ptr->unk0->unk4[12]); + DisplayPartyPokemonBarDetail(menuBox->windowId, gStringVar1, 0, &menuBox->infoRects->dimensions[12]); } -static void DisplayPartyPokemonMaxHPCheck(struct Pokemon *mon, struct Struct203CEDC *ptr, u8 c) +static void DisplayPartyPokemonMaxHPCheck(struct Pokemon *mon, struct PartyMenuBox *menuBox, u8 c) { if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE) { if (c != 0) - ptr->unk0->unk0(ptr->windowId, (ptr->unk0->unk4[16] >> 3) + 1, (ptr->unk0->unk4[17] >> 3) + 1, ptr->unk0->unk4[18] >> 3, ptr->unk0->unk4[19] >> 3, 0); + menuBox->infoRects->blitFunc(menuBox->windowId, (menuBox->infoRects->dimensions[16] >> 3) + 1, (menuBox->infoRects->dimensions[17] >> 3) + 1, menuBox->infoRects->dimensions[18] >> 3, menuBox->infoRects->dimensions[19] >> 3, FALSE); if (c != 2) - DisplayPartyPokemonMaxHP(GetMonData(mon, MON_DATA_MAX_HP), ptr); + DisplayPartyPokemonMaxHP(GetMonData(mon, MON_DATA_MAX_HP), menuBox); } } -static void DisplayPartyPokemonMaxHP(u16 maxhp, struct Struct203CEDC *ptr) +static void DisplayPartyPokemonMaxHP(u16 maxhp, struct PartyMenuBox *menuBox) { ConvertIntToDecimalStringN(gStringVar2, maxhp, STR_CONV_MODE_RIGHT_ALIGN, 3); StringCopy(gStringVar1, gText_Slash); StringAppend(gStringVar1, gStringVar2); - DisplayPartyPokemonBarDetail(ptr->windowId, gStringVar1, 0, &ptr->unk0->unk4[16]); + DisplayPartyPokemonBarDetail(menuBox->windowId, gStringVar1, 0, &menuBox->infoRects->dimensions[16]); } -static void DisplayPartyPokemonHPBarCheck(struct Pokemon *mon, struct Struct203CEDC *ptr) +static void DisplayPartyPokemonHPBarCheck(struct Pokemon *mon, struct PartyMenuBox *menuBox) { if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE) - DisplayPartyPokemonHPBar(GetMonData(mon, MON_DATA_HP), GetMonData(mon, MON_DATA_MAX_HP), ptr); + DisplayPartyPokemonHPBar(GetMonData(mon, MON_DATA_HP), GetMonData(mon, MON_DATA_MAX_HP), menuBox); } -static void DisplayPartyPokemonHPBar(u16 hp, u16 maxhp, struct Struct203CEDC *ptr) +static void DisplayPartyPokemonHPBar(u16 hp, u16 maxhp, struct PartyMenuBox *menuBox) { - u8 palNum = GetWindowAttribute(ptr->windowId, WINDOW_PALETTE_NUM) * 16; + u8 palNum = GetWindowAttribute(menuBox->windowId, WINDOW_PALETTE_NUM) * 16; u8 hpFraction; switch (GetHPBarLevel(hp, maxhp)) { case HP_BAR_GREEN: case HP_BAR_FULL: - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC7[0]), gUnknown_08615AB8[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC7[1]), gUnknown_08615AB8[1] + palNum, 2); + LoadPalette(GetPartyMenuPalBufferPtr(sHPBarGreenPalIds[0]), sHPBarPalOffsets[0] + palNum, 2); + LoadPalette(GetPartyMenuPalBufferPtr(sHPBarGreenPalIds[1]), sHPBarPalOffsets[1] + palNum, 2); break; case HP_BAR_YELLOW: - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC9[0]), gUnknown_08615AB8[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615AC9[1]), gUnknown_08615AB8[1] + palNum, 2); + LoadPalette(GetPartyMenuPalBufferPtr(sHPBarYellowPalIds[0]), sHPBarPalOffsets[0] + palNum, 2); + LoadPalette(GetPartyMenuPalBufferPtr(sHPBarYellowPalIds[1]), sHPBarPalOffsets[1] + palNum, 2); break; default: - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ACB[0]), gUnknown_08615AB8[0] + palNum, 2); - LoadPalette(GetPartyMenuPaletteFromBuffer(gUnknown_08615ACB[1]), gUnknown_08615AB8[1] + palNum, 2); + LoadPalette(GetPartyMenuPalBufferPtr(sHPBarRedPalIds[0]), sHPBarPalOffsets[0] + palNum, 2); + LoadPalette(GetPartyMenuPalBufferPtr(sHPBarRedPalIds[1]), sHPBarPalOffsets[1] + palNum, 2); break; } - hpFraction = GetScaledHPFraction(hp, maxhp, ptr->unk0->unk4[22]); - FillWindowPixelRect(ptr->windowId, gUnknown_08615AB8[1], ptr->unk0->unk4[20], ptr->unk0->unk4[21], hpFraction, 1); - FillWindowPixelRect(ptr->windowId, gUnknown_08615AB8[0], ptr->unk0->unk4[20], ptr->unk0->unk4[21] + 1, hpFraction, 2); - if (hpFraction != ptr->unk0->unk4[22]) + hpFraction = GetScaledHPFraction(hp, maxhp, menuBox->infoRects->dimensions[22]); + FillWindowPixelRect(menuBox->windowId, sHPBarPalOffsets[1], menuBox->infoRects->dimensions[20], menuBox->infoRects->dimensions[21], hpFraction, 1); + FillWindowPixelRect(menuBox->windowId, sHPBarPalOffsets[0], menuBox->infoRects->dimensions[20], menuBox->infoRects->dimensions[21] + 1, hpFraction, 2); + if (hpFraction != menuBox->infoRects->dimensions[22]) { // This appears to be an alternating fill - FillWindowPixelRect(ptr->windowId, 0x0D, ptr->unk0->unk4[20] + hpFraction, ptr->unk0->unk4[21], ptr->unk0->unk4[22] - hpFraction, 1); - FillWindowPixelRect(ptr->windowId, 0x02, ptr->unk0->unk4[20] + hpFraction, ptr->unk0->unk4[21] + 1, ptr->unk0->unk4[22] - hpFraction, 2); + FillWindowPixelRect(menuBox->windowId, 0x0D, menuBox->infoRects->dimensions[20] + hpFraction, menuBox->infoRects->dimensions[21], menuBox->infoRects->dimensions[22] - hpFraction, 1); + FillWindowPixelRect(menuBox->windowId, 0x02, menuBox->infoRects->dimensions[20] + hpFraction, menuBox->infoRects->dimensions[21] + 1, menuBox->infoRects->dimensions[22] - hpFraction, 2); } - CopyWindowToVram(ptr->windowId, 2); + CopyWindowToVram(menuBox->windowId, 2); } -static void DisplayPartyPokemonSelectionText(u8 stringID, struct Struct203CEDC *ptr, u8 c) +static void DisplayPartyPokemonDescriptionText(u8 stringID, struct PartyMenuBox *menuBox, u8 c) { - if (c != 0) + if (c) { - int unk = ((ptr->unk0->unk1C % 8) + ptr->unk0->unk1E + 7) / 8; - int unk2 = ((ptr->unk0->unk1D % 8) + ptr->unk0->unk1F + 7) / 8; - ptr->unk0->unk0(ptr->windowId, ptr->unk0->unk1C >> 3, ptr->unk0->unk1D >> 3, unk, unk2, 1); + int width = ((menuBox->infoRects->descTextLeft % 8) + menuBox->infoRects->descTextWidth + 7) / 8; + int height = ((menuBox->infoRects->descTextTop % 8) + menuBox->infoRects->descTextHeight + 7) / 8; + menuBox->infoRects->blitFunc(menuBox->windowId, menuBox->infoRects->descTextLeft >> 3, menuBox->infoRects->descTextTop >> 3, width, height, TRUE); } if (c != 2) - AddTextPrinterParameterized3(ptr->windowId, 1, ptr->unk0->unk1C, ptr->unk0->unk1D, sFontColorTable[0], 0, sSelectionStringTable[stringID]); + AddTextPrinterParameterized3(menuBox->windowId, 1, menuBox->infoRects->descTextLeft, menuBox->infoRects->descTextTop, sFontColorTable[0], 0, sDescriptionStringTable[stringID]); } static void PartyMenuRemoveWindow(u8 *ptr) @@ -3554,110 +2385,111 @@ static void PartyMenuRemoveWindow(u8 *ptr) } } -void DisplayPartyMenuStdMessage(u32 stringID) +void DisplayPartyMenuStdMessage(u32 stringId) { - u8 *windowPtr = &gUnknown_0203CEC4->windowId[1]; + u8 *windowPtr = &sPartyMenuInternal->windowId[1]; if (*windowPtr != 0xFF) PartyMenuRemoveWindow(windowPtr); - if (stringID != 0x7F) + if (stringId != PARTY_MSG_NONE) { - switch (stringID) + switch (stringId) { - case 21: - *windowPtr = AddWindow(&gUnknown_08615928); + case PARTY_MSG_DO_WHAT_WITH_MON: + *windowPtr = AddWindow(&sDoWhatWithMonMsgWindowTemplate); break; - case 24: - *windowPtr = AddWindow(&gUnknown_08615930); + case PARTY_MSG_DO_WHAT_WITH_ITEM: + *windowPtr = AddWindow(&sDoWhatWithItemMsgWindowTemplate); break; - case 25: - *windowPtr = AddWindow(&gUnknown_08615938); + case PARTY_MSG_DO_WHAT_WITH_MAIL: + *windowPtr = AddWindow(&sDoWhatWithMailMsgWindowTemplate); break; - case 22: - case 23: - *windowPtr = AddWindow(&gUnknown_08615940); + case PARTY_MSG_RESTORE_WHICH_MOVE: + case PARTY_MSG_BOOST_PP_WHICH_MOVE: + *windowPtr = AddWindow(&sWhichMoveMsgWindowTemplate); break; - case 26: - *windowPtr = AddWindow(&gUnknown_08615948); + case PARTY_MSG_ALREADY_HOLDING_ONE: + *windowPtr = AddWindow(&sAlreadyHoldingOneMsgWindowTemplate); break; default: - *windowPtr = AddWindow(&gUnknown_08615920); + *windowPtr = AddWindow(&sDefaultPartyMsgWindowTemplate); break; } - if (stringID == 0) + + if (stringId == PARTY_MSG_CHOOSE_MON) { - if (gUnknown_0203CEC4->unk8_0) - stringID = 2; - else if (sub_81B314C() == FALSE) - stringID = 1; + if (sPartyMenuInternal->chooseHalf) + stringId = PARTY_MSG_CHOOSE_MON_AND_CONFIRM; + else if (!ShouldUseChooseMonText()) + stringId = PARTY_MSG_CHOOSE_MON_OR_CANCEL; } DrawStdFrameWithCustomTileAndPalette(*windowPtr, FALSE, 0x4F, 0xD); - StringExpandPlaceholders(gStringVar4, sActionStringTable[stringID]); + StringExpandPlaceholders(gStringVar4, sActionStringTable[stringId]); AddTextPrinterParameterized(*windowPtr, 1, gStringVar4, 0, 1, 0, 0); schedule_bg_copy_tilemap_to_vram(2); } } -static bool8 sub_81B314C(void) +static bool8 ShouldUseChooseMonText(void) { struct Pokemon *party = gPlayerParty; u8 i; - u8 j = 0; + u8 numAliveMons = 0; - if (gUnknown_0203CEC8.unkB == 1) + if (gPartyMenu.action == PARTY_ACTION_SEND_OUT) return TRUE; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE && (GetMonData(&party[i], MON_DATA_HP) != 0 || GetMonData(&party[i], MON_DATA_IS_EGG))) - j++; - if (j > 1) + numAliveMons++; + if (numAliveMons > 1) return TRUE; } return FALSE; } -static u8 sub_81B31B0(u8 a) +static u8 DisplaySelectionWindow(u8 windowType) { struct WindowTemplate window; u8 cursorDimension; u8 fontAttribute; u8 i; - switch (a) + switch (windowType) { - case 0: - SetWindowTemplateFields(&window, 2, 19, 19 - (gUnknown_0203CEC4->listSize * 2), 10, gUnknown_0203CEC4->listSize * 2, 14, 0x2E9); + case SELECTWINDOW_ACTIONS: + SetWindowTemplateFields(&window, 2, 19, 19 - (sPartyMenuInternal->numActions * 2), 10, sPartyMenuInternal->numActions * 2, 14, 0x2E9); break; - case 1: - window = gUnknown_08615950; + case SELECTWINDOW_ITEM: + window = sItemGiveTakeWindowTemplate; break; - case 2: - window = gUnknown_08615958; + case SELECTWINDOW_MAIL: + window = sMailReadTakeWindowTemplate; break; - default: - window = gUnknown_08615960; + default: // SELECTWINDOW_MOVES + window = sMoveSelectWindowTemplate; break; } - gUnknown_0203CEC4->windowId[0] = AddWindow(&window); - DrawStdFrameWithCustomTileAndPalette(gUnknown_0203CEC4->windowId[0], FALSE, 0x4F, 13); - if (a == 3) - return gUnknown_0203CEC4->windowId[0]; + sPartyMenuInternal->windowId[0] = AddWindow(&window); + DrawStdFrameWithCustomTileAndPalette(sPartyMenuInternal->windowId[0], FALSE, 0x4F, 13); + if (windowType == SELECTWINDOW_MOVES) + return sPartyMenuInternal->windowId[0]; cursorDimension = GetMenuCursorDimensionByFont(1, 0); fontAttribute = GetFontAttribute(1, 2); - for (i = 0; i < gUnknown_0203CEC4->listSize; i++) + for (i = 0; i < sPartyMenuInternal->numActions; i++) { - u8 unk = (gUnknown_0203CEC4->actions[i] >= MENU_FIELD_MOVES) ? 4 : 3; - AddTextPrinterParameterized4(gUnknown_0203CEC4->windowId[0], 1, cursorDimension, (i * 16) + 1, fontAttribute, 0, sFontColorTable[unk], 0, sCursorOptions[gUnknown_0203CEC4->actions[i]].text); + u8 fontColorsId = (sPartyMenuInternal->actions[i] >= MENU_FIELD_MOVES) ? 4 : 3; + AddTextPrinterParameterized4(sPartyMenuInternal->windowId[0], 1, cursorDimension, (i * 16) + 1, fontAttribute, 0, sFontColorTable[fontColorsId], 0, sCursorOptions[sPartyMenuInternal->actions[i]].text); } - InitMenuInUpperLeftCorner(gUnknown_0203CEC4->windowId[0], gUnknown_0203CEC4->listSize, 0, 1); + InitMenuInUpperLeftCorner(sPartyMenuInternal->windowId[0], sPartyMenuInternal->numActions, 0, 1); schedule_bg_copy_tilemap_to_vram(2); - return gUnknown_0203CEC4->windowId[0]; + return sPartyMenuInternal->windowId[0]; } static void PartyMenuPrintText(const u8 *text) @@ -3667,53 +2499,55 @@ static void PartyMenuPrintText(const u8 *text) AddTextPrinterParameterized2(6, 1, text, GetPlayerTextSpeedDelay(), 0, 2, 1, 3); } -static void sub_81B334C(void) +static void PartyMenuDisplayYesNoMenu(void) { - CreateYesNoMenu(&gUnknown_08615968, 0x4F, 13, 0); + CreateYesNoMenu(&sPartyMenuYesNoWindowTemplate, 0x4F, 13, 0); } -static u8 sub_81B3364(void) +static u8 CreateLevelUpStatsWindow(void) { - gUnknown_0203CEC4->windowId[0] = AddWindow(&gUnknown_08615970); - DrawStdFrameWithCustomTileAndPalette(gUnknown_0203CEC4->windowId[0], FALSE, 0x4F, 13); - return gUnknown_0203CEC4->windowId[0]; + sPartyMenuInternal->windowId[0] = AddWindow(&sLevelUpStatsWindowTemplate); + DrawStdFrameWithCustomTileAndPalette(sPartyMenuInternal->windowId[0], FALSE, 0x4F, 13); + return sPartyMenuInternal->windowId[0]; } -static void sub_81B3394(void) +static void RemoveLevelUpStatsWindow(void) { - ClearWindowTilemap(gUnknown_0203CEC4->windowId[0]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + ClearWindowTilemap(sPartyMenuInternal->windowId[0]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); } -static void sub_81B33B4(struct Pokemon *mons, u8 slotId, u8 b) +static void SetPartyMonSelectionActions(struct Pokemon *mons, u8 slotId, u8 action) { u8 i; - if (b == 0) + if (action == ACTIONS_NONE) { - CreateActionList(mons, slotId); + SetPartyMonFieldSelectionActions(mons, slotId); } else { - gUnknown_0203CEC4->listSize = sListSizeTable[b]; - for (i = 0; i < gUnknown_0203CEC4->listSize; i++) - gUnknown_0203CEC4->actions[i] = sActionTable[b][i]; + sPartyMenuInternal->numActions = sPartyMenuActionCounts[action]; + for (i = 0; i < sPartyMenuInternal->numActions; i++) + sPartyMenuInternal->actions[i] = sPartyMenuActions[action][i]; } } -static void CreateActionList(struct Pokemon *mons, u8 slotId) +static void SetPartyMonFieldSelectionActions(struct Pokemon *mons, u8 slotId) { u8 i, j; - gUnknown_0203CEC4->listSize = 0; - AppendToList(gUnknown_0203CEC4->actions, &gUnknown_0203CEC4->listSize, MENU_SUMMARY); + sPartyMenuInternal->numActions = 0; + AppendToList(sPartyMenuInternal->actions, &sPartyMenuInternal->numActions, MENU_SUMMARY); + + // Add field moves to action list for (i = 0; i < MAX_MON_MOVES; i++) { for (j = 0; sFieldMoves[j] != FIELD_MOVE_TERMINATOR; j++) { if (GetMonData(&mons[slotId], i + MON_DATA_MOVE1) == sFieldMoves[j]) { - AppendToList(gUnknown_0203CEC4->actions, &gUnknown_0203CEC4->listSize, j + MENU_FIELD_MOVES); + AppendToList(sPartyMenuInternal->actions, &sPartyMenuInternal->numActions, j + MENU_FIELD_MOVES); break; } } @@ -3722,118 +2556,124 @@ static void CreateActionList(struct Pokemon *mons, u8 slotId) if (!InBattlePike()) { if (GetMonData(&mons[1], MON_DATA_SPECIES) != SPECIES_NONE) - AppendToList(gUnknown_0203CEC4->actions, &gUnknown_0203CEC4->listSize, MENU_SWITCH); + AppendToList(sPartyMenuInternal->actions, &sPartyMenuInternal->numActions, MENU_SWITCH); if (ItemIsMail(GetMonData(&mons[slotId], MON_DATA_HELD_ITEM))) - AppendToList(gUnknown_0203CEC4->actions, &gUnknown_0203CEC4->listSize, MENU_MAIL); + AppendToList(sPartyMenuInternal->actions, &sPartyMenuInternal->numActions, MENU_MAIL); else - AppendToList(gUnknown_0203CEC4->actions, &gUnknown_0203CEC4->listSize, MENU_ITEM); + AppendToList(sPartyMenuInternal->actions, &sPartyMenuInternal->numActions, MENU_ITEM); } - AppendToList(gUnknown_0203CEC4->actions, &gUnknown_0203CEC4->listSize, MENU_CANCEL1); + AppendToList(sPartyMenuInternal->actions, &sPartyMenuInternal->numActions, MENU_CANCEL1); } -static u8 sub_81B353C(struct Pokemon *mon) +static u8 GetPartyMenuActionsType(struct Pokemon *mon) { - u32 returnVar; + u32 actionType; - switch (gUnknown_0203CEC8.unk8_0) + switch (gPartyMenu.menuType) { - case 0: + case PARTY_MENU_TYPE_FIELD: if (InMultiBattleRoom() == TRUE || GetMonData(mon, MON_DATA_IS_EGG)) - returnVar = 1; + actionType = ACTIONS_SWITCH; else - returnVar = 0; + actionType = ACTIONS_NONE; // actions populated by SetPartyMonFieldSelectionActions break; - case 1: - returnVar = sub_81B8A2C(mon); + case PARTY_MENU_TYPE_IN_BATTLE: + actionType = GetPartyMenuActionsTypeInBattle(mon); break; - case 4: - switch (sub_81B856C(gUnknown_0203CEC8.slotId)) + case PARTY_MENU_TYPE_CHOOSE_HALF: + switch (GetPartySlotEntryStatus(gPartyMenu.slotId)) { - default: - returnVar = 7; + default: // Not eligible + actionType = ACTIONS_SUMMARY_ONLY; break; - case 0: - returnVar = 4; + case 0: // Eligible + actionType = ACTIONS_ENTER; break; - case 1: - returnVar = 5; + case 1: // Already selected + actionType = ACTIONS_NO_ENTRY; break; } break; - case 6: - returnVar = (GetMonData(mon, MON_DATA_IS_EGG)) ? 7 : 6; + case PARTY_MENU_TYPE_DAYCARE: + actionType = (GetMonData(mon, MON_DATA_IS_EGG)) ? ACTIONS_SUMMARY_ONLY : ACTIONS_STORE; break; - case 8: - returnVar = 10; + case PARTY_MENU_TYPE_UNION_ROOM_REGISTER: + actionType = ACTIONS_REGISTER; break; - case 9: - returnVar = 11; + case PARTY_MENU_TYPE_UNION_ROOM_TRADE: + actionType = ACTIONS_TRADE; break; - case 10: - returnVar = 12; + case PARTY_MENU_TYPE_SPIN_TRADE: + actionType = ACTIONS_SPIN_TRADE; break; - case 12: - returnVar = 13; + case PARTY_MENU_TYPE_STORE_PYRAMID_HELD_ITEMS: + actionType = ACTIONS_TAKEITEM_TOSS; break; + // The following have no selection actions (i.e. they exit immediately upon selection) + // PARTY_MENU_TYPE_CONTEST + // PARTY_MENU_TYPE_CHOOSE_MON + // PARTY_MENU_TYPE_MULTI_SHOWCASE + // PARTY_MENU_TYPE_MOVE_RELEARNER + // PARTY_MENU_TYPE_MINIGAME default: - returnVar = 0; + actionType = ACTIONS_NONE; break; } - return returnVar; + return actionType; } -static bool8 sub_81B3608(u8 taskId) +static bool8 CreateSelectionWindow(u8 taskId) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; u16 item; GetMonNickname(mon, gStringVar1); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - if (gUnknown_0203CEC8.unk8_0 != 12) + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + if (gPartyMenu.menuType != PARTY_MENU_TYPE_STORE_PYRAMID_HELD_ITEMS) { - sub_81B33B4(gPlayerParty, gUnknown_0203CEC8.slotId, sub_81B353C(mon)); - sub_81B31B0(0); - DisplayPartyMenuStdMessage(21); + SetPartyMonSelectionActions(gPlayerParty, gPartyMenu.slotId, GetPartyMenuActionsType(mon)); + DisplaySelectionWindow(SELECTWINDOW_ACTIONS); + DisplayPartyMenuStdMessage(PARTY_MSG_DO_WHAT_WITH_MON); } else { item = GetMonData(mon, MON_DATA_HELD_ITEM); if (item != ITEM_NONE) { - sub_81B33B4(gPlayerParty, gUnknown_0203CEC8.slotId, sub_81B353C(mon)); - sub_81B31B0(1); + SetPartyMonSelectionActions(gPlayerParty, gPartyMenu.slotId, GetPartyMenuActionsType(mon)); + DisplaySelectionWindow(SELECTWINDOW_ITEM); CopyItemName(item, gStringVar2); - DisplayPartyMenuStdMessage(26); + DisplayPartyMenuStdMessage(PARTY_MSG_ALREADY_HOLDING_ONE); } else { StringExpandPlaceholders(gStringVar4, gText_PkmnNotHolding); - DisplayPartyMenuMessage(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, TRUE); schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = sub_81B469C; + gTasks[taskId].func = Task_UpdateHeldItemSprite; return FALSE; } } return TRUE; } -static void sub_81B36FC(u8 taskId) +static void Task_TryCreateSelectionWindow(u8 taskId) { - if (sub_81B3608(taskId)) + if (CreateSelectionWindow(taskId)) { gTasks[taskId].data[0] = 0xFF; - gTasks[taskId].func = HandleMenuInput; + gTasks[taskId].func = Task_HandleSelectionMenuInput; } } -static void HandleMenuInput(u8 taskId) +static void Task_HandleSelectionMenuInput(u8 taskId) { if (!gPaletteFade.active && sub_81221EC() != TRUE) { s8 input; s16 *data = gTasks[taskId].data; - if (gUnknown_0203CEC4->listSize <= 3) + if (sPartyMenuInternal->numActions <= 3) input = Menu_ProcessInputNoWrapAround_other(); else input = ProcessMenuInput_other(); @@ -3845,12 +2685,12 @@ static void HandleMenuInput(u8 taskId) break; case MENU_B_PRESSED: PlaySE(SE_SELECT); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[2]); - sCursorOptions[gUnknown_0203CEC4->actions[gUnknown_0203CEC4->listSize - 1]].func(taskId); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[2]); + sCursorOptions[sPartyMenuInternal->actions[sPartyMenuInternal->numActions - 1]].func(taskId); break; default: - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[2]); - sCursorOptions[gUnknown_0203CEC4->actions[input]].func(taskId); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[2]); + sCursorOptions[sPartyMenuInternal->actions[input]].func(taskId); break; } } @@ -3859,209 +2699,230 @@ static void HandleMenuInput(u8 taskId) static void CursorCb_Summary(u8 taskId) { PlaySE(SE_SELECT); - gUnknown_0203CEC4->exitCallback = sub_81B3828; + sPartyMenuInternal->exitCallback = CB2_ShowPokemonSummaryScreen; Task_ClosePartyMenu(taskId); } -static void sub_81B3828(void) +static void CB2_ShowPokemonSummaryScreen(void) { - if (gUnknown_0203CEC8.unk8_0 == 1) + if (gPartyMenu.menuType == PARTY_MENU_TYPE_IN_BATTLE) { - pokemon_change_order(); - ShowPokemonSummaryScreen(PSS_MODE_UNK1, gPlayerParty, gUnknown_0203CEC8.slotId, gPlayerPartyCount - 1, sub_81B3894); + UpdatePartyToBattleOrder(); + ShowPokemonSummaryScreen(PSS_MODE_UNK1, gPlayerParty, gPartyMenu.slotId, gPlayerPartyCount - 1, CB2_ReturnToPartyMenuFromSummaryScreen); } else { - ShowPokemonSummaryScreen(PSS_MODE_NORMAL, gPlayerParty, gUnknown_0203CEC8.slotId, gPlayerPartyCount - 1, sub_81B3894); + ShowPokemonSummaryScreen(PSS_MODE_NORMAL, gPlayerParty, gPartyMenu.slotId, gPlayerPartyCount - 1, CB2_ReturnToPartyMenuFromSummaryScreen); } } -static void sub_81B3894(void) +static void CB2_ReturnToPartyMenuFromSummaryScreen(void) { gPaletteFade.bufferTransferDisabled = TRUE; - gUnknown_0203CEC8.slotId = gLastViewedMonIndex; - InitPartyMenu(gUnknown_0203CEC8.unk8_0, 0xFF, gUnknown_0203CEC8.unkB, 1, 21, sub_81B36FC, gUnknown_0203CEC8.exitCallback); + gPartyMenu.slotId = gLastViewedMonIndex; + InitPartyMenu(gPartyMenu.menuType, KEEP_PARTY_LAYOUT, gPartyMenu.action, TRUE, PARTY_MSG_DO_WHAT_WITH_MON, Task_TryCreateSelectionWindow, gPartyMenu.exitCallback); } static void CursorCb_Switch(u8 taskId) { PlaySE(SE_SELECT); - gUnknown_0203CEC8.unkB = 8; - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - DisplayPartyMenuStdMessage(3); - sub_81B0FCC(gUnknown_0203CEC8.slotId, 1); - gUnknown_0203CEC8.unkA = gUnknown_0203CEC8.slotId; - gTasks[taskId].func = sub_81B1370; -} - -static void sub_81B3938(u8 taskId) + gPartyMenu.action = PARTY_ACTION_SWITCH; + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + DisplayPartyMenuStdMessage(PARTY_MSG_MOVE_TO_WHERE); + AnimatePartySlot(gPartyMenu.slotId, 1); + gPartyMenu.slotId2 = gPartyMenu.slotId; + gTasks[taskId].func = Task_HandleChooseMonInput; +} + +#define tSlot1Left data[0] +#define tSlot1Top data[1] +#define tSlot1Width data[2] +#define tSlot1Height data[3] +#define tSlot2Left data[4] +#define tSlot2Top data[5] +#define tSlot2Width data[6] +#define tSlot2Height data[7] +#define tSlot1Offset data[8] +#define tSlot2Offset data[9] +#define tSlot1SlideDir data[10] +#define tSlot2SlideDir data[11] + +static void SwitchSelectedMons(u8 taskId) { s16 *data = gTasks[taskId].data; u8 windowIds[2]; - if (gUnknown_0203CEC8.unkA == gUnknown_0203CEC8.slotId) + if (gPartyMenu.slotId2 == gPartyMenu.slotId) { - sub_81B407C(taskId); + FinishTwoMonAction(taskId); } else { - windowIds[0] = gUnknown_0203CEDC[gUnknown_0203CEC8.slotId].windowId; - data[0] = GetWindowAttribute(windowIds[0], WINDOW_TILEMAP_LEFT); - data[1] = GetWindowAttribute(windowIds[0], WINDOW_TILEMAP_TOP); - data[2] = GetWindowAttribute(windowIds[0], WINDOW_WIDTH); - data[3] = GetWindowAttribute(windowIds[0], WINDOW_HEIGHT); - data[8] = 0; - if (data[2] == 10) - data[10] = -1; + // Initialize switching party mons slide animation + windowIds[0] = sPartyMenuBoxes[gPartyMenu.slotId].windowId; + tSlot1Left = GetWindowAttribute(windowIds[0], WINDOW_TILEMAP_LEFT); + tSlot1Top = GetWindowAttribute(windowIds[0], WINDOW_TILEMAP_TOP); + tSlot1Width = GetWindowAttribute(windowIds[0], WINDOW_WIDTH); + tSlot1Height = GetWindowAttribute(windowIds[0], WINDOW_HEIGHT); + tSlot1Offset = 0; + if (tSlot1Width == 10) + tSlot1SlideDir = -1; else - data[10] = 1; - windowIds[1] = gUnknown_0203CEDC[gUnknown_0203CEC8.unkA].windowId; - data[4] = GetWindowAttribute(windowIds[1], WINDOW_TILEMAP_LEFT); - data[5] = GetWindowAttribute(windowIds[1], WINDOW_TILEMAP_TOP); - data[6] = GetWindowAttribute(windowIds[1], WINDOW_WIDTH); - data[7] = GetWindowAttribute(windowIds[1], WINDOW_HEIGHT); - data[9] = 0; - if (data[6] == 10) - data[11] = -1; + tSlot1SlideDir = 1; + windowIds[1] = sPartyMenuBoxes[gPartyMenu.slotId2].windowId; + tSlot2Left = GetWindowAttribute(windowIds[1], WINDOW_TILEMAP_LEFT); + tSlot2Top = GetWindowAttribute(windowIds[1], WINDOW_TILEMAP_TOP); + tSlot2Width = GetWindowAttribute(windowIds[1], WINDOW_WIDTH); + tSlot2Height = GetWindowAttribute(windowIds[1], WINDOW_HEIGHT); + tSlot2Offset = 0; + if (tSlot2Width == 10) + tSlot2SlideDir = -1; else - data[11] = 1; - gUnknown_0203CEF0 = Alloc(data[2] * (data[3] << 1)); - gUnknown_0203CEF4 = Alloc(data[6] * (data[7] << 1)); - sub_8199CBC(0, gUnknown_0203CEF0, data[0], data[1], data[2], data[3]); - sub_8199CBC(0, gUnknown_0203CEF4, data[4], data[5], data[6], data[7]); + tSlot2SlideDir = 1; + sSlot1TilemapBuffer = Alloc(tSlot1Width * (tSlot1Height << 1)); + sSlot2TilemapBuffer = Alloc(tSlot2Width * (tSlot2Height << 1)); + CopyToBufferFromBgTilemap(0, sSlot1TilemapBuffer, tSlot1Left, tSlot1Top, tSlot1Width, tSlot1Height); + CopyToBufferFromBgTilemap(0, sSlot2TilemapBuffer, tSlot2Left, tSlot2Top, tSlot2Width, tSlot2Height); ClearWindowTilemap(windowIds[0]); ClearWindowTilemap(windowIds[1]); - gUnknown_0203CEC8.unkB = 9; - sub_81B0FCC(gUnknown_0203CEC8.slotId, 1); - sub_81B0FCC(gUnknown_0203CEC8.unkA, 1); - sub_81B3CC0(taskId); - gTasks[taskId].func = sub_81B3D48; + gPartyMenu.action = PARTY_ACTION_SWITCHING; + AnimatePartySlot(gPartyMenu.slotId, 1); + AnimatePartySlot(gPartyMenu.slotId2, 1); + SlidePartyMenuBoxOneStep(taskId); + gTasks[taskId].func = Task_SlideSelectedSlotsOffscreen; } } -static bool8 sub_81B3AD8(s16 a, s16 b, u8 *c, u8 *d, u8 *e) +// returns FALSE if the slot has slid fully offscreen / back onscreen +static bool8 TryMovePartySlot(s16 x, s16 width, u8 *leftMove, u8 *newX, u8 *newWidth) { - if ((a + b) < 0) + if ((x + width) < 0) return FALSE; - if (a > 31) + if (x > 31) return FALSE; - if (a < 0) + if (x < 0) { - *c = a * -1; - *d = 0; - *e = b + a; + *leftMove = x * -1; + *newX = 0; + *newWidth = width + x; } else { - *c = 0; - *d = a; - if ((a + b) > 31) - *e = 32 - a; + *leftMove = 0; + *newX = x; + if ((x + width) > 31) + *newWidth = 32 - x; else - *e = b; + *newWidth = width; } return TRUE; } -static void sub_81B3B40(const void *rectSrc, s16 a, s16 b, s16 c, s16 d, s16 e) +static void MoveAndBufferPartySlot(const void *rectSrc, s16 x, s16 y, s16 width, s16 height, s16 dir) { - u8 f, g, h; + // The use of the dimension parameters here is a mess + u8 leftMove, newX, newWidth; // leftMove is used as a srcX, newX is used as both x and srcHeight, newWidth is used as both width and destY - if (sub_81B3AD8(a, c, &f, &g, &h)) + if (TryMovePartySlot(x, width, &leftMove, &newX, &newWidth)) { - FillBgTilemapBufferRect_Palette0(0, 0, g, b, h, d); - if (sub_81B3AD8(a + e, c, &f, &g, &h)) - CopyRectToBgTilemapBufferRect(0, rectSrc, f, 0, c, d, g, b, h, d, 17, 0, 0); + FillBgTilemapBufferRect_Palette0(0, 0, newX, y, newWidth, height); + if (TryMovePartySlot(x + dir, width, &leftMove, &newX, &newWidth)) + CopyRectToBgTilemapBufferRect(0, rectSrc, leftMove, 0, width, height, newX, y, newWidth, height, 17, 0, 0); } } -static void sub_81B3C0C(struct Struct203CEDC *ptr, s16 a) +static void MovePartyMenuBoxSprites(struct PartyMenuBox *menuBox, s16 offset) { - gSprites[ptr->pokeballSpriteId].pos2.x += a * 8; - gSprites[ptr->itemSpriteId].pos2.x += a * 8; - gSprites[ptr->monSpriteId].pos2.x += a * 8; - gSprites[ptr->statusSpriteId].pos2.x += a * 8; + gSprites[menuBox->pokeballSpriteId].pos2.x += offset * 8; + gSprites[menuBox->itemSpriteId].pos2.x += offset * 8; + gSprites[menuBox->monSpriteId].pos2.x += offset * 8; + gSprites[menuBox->statusSpriteId].pos2.x += offset * 8; } -static void sub_81B3C60(u8 taskId) +static void SlidePartyMenuBoxSpritesOneStep(u8 taskId) { s16 *data = gTasks[taskId].data; - if (data[10] != 0) - sub_81B3C0C(&gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], data[10]); - if (data[11] != 0) - sub_81B3C0C(&gUnknown_0203CEDC[gUnknown_0203CEC8.unkA], data[11]); + if (tSlot1SlideDir != 0) + MovePartyMenuBoxSprites(&sPartyMenuBoxes[gPartyMenu.slotId], tSlot1SlideDir); + if (tSlot2SlideDir != 0) + MovePartyMenuBoxSprites(&sPartyMenuBoxes[gPartyMenu.slotId2], tSlot2SlideDir); } -static void sub_81B3CC0(u8 taskId) +static void SlidePartyMenuBoxOneStep(u8 taskId) { s16 *data = gTasks[taskId].data; - if (data[10] != 0) - sub_81B3B40(gUnknown_0203CEF0, data[0] + data[8], data[1], data[2], data[3], data[10]); - if (data[11] != 0) - sub_81B3B40(gUnknown_0203CEF4, data[4] + data[9], data[5], data[6], data[7], data[11]); + if (tSlot1SlideDir != 0) + MoveAndBufferPartySlot(sSlot1TilemapBuffer, tSlot1Left + tSlot1Offset, tSlot1Top, tSlot1Width, tSlot1Height, tSlot1SlideDir); + if (tSlot2SlideDir != 0) + MoveAndBufferPartySlot(sSlot2TilemapBuffer, tSlot2Left + tSlot2Offset, tSlot2Top, tSlot2Width, tSlot2Height, tSlot2SlideDir); schedule_bg_copy_tilemap_to_vram(0); } -static void sub_81B3D48(u8 taskId) +static void Task_SlideSelectedSlotsOffscreen(u8 taskId) { s16 *data = gTasks[taskId].data; - u16 tilemapRelatedMaybe[2]; + u16 slidingSlotPositions[2]; - sub_81B3CC0(taskId); - sub_81B3C60(taskId); - data[8] += data[10]; - data[9] += data[11]; - tilemapRelatedMaybe[0] = data[0] + data[8]; - tilemapRelatedMaybe[1] = data[4] + data[9]; - if (tilemapRelatedMaybe[0] > 33 && tilemapRelatedMaybe[1] > 33) + SlidePartyMenuBoxOneStep(taskId); + SlidePartyMenuBoxSpritesOneStep(taskId); + tSlot1Offset += tSlot1SlideDir; + tSlot2Offset += tSlot2SlideDir; + slidingSlotPositions[0] = tSlot1Left + tSlot1Offset; + slidingSlotPositions[1] = tSlot2Left + tSlot2Offset; + + // Both slots have slid offscreen + if (slidingSlotPositions[0] > 33 && slidingSlotPositions[1] > 33) { - data[10] *= -1; - data[11] *= -1; - swap_pokemon_and_oams(); - DisplayPartyPokemonData(gUnknown_0203CEC8.slotId); - DisplayPartyPokemonData(gUnknown_0203CEC8.unkA); - PutWindowTilemap(gUnknown_0203CEDC[gUnknown_0203CEC8.slotId].windowId); - PutWindowTilemap(gUnknown_0203CEDC[gUnknown_0203CEC8.unkA].windowId); - sub_8199CBC(0, gUnknown_0203CEF0, data[0], data[1], data[2], data[3]); - sub_8199CBC(0, gUnknown_0203CEF4, data[4], data[5], data[6], data[7]); - ClearWindowTilemap(gUnknown_0203CEDC[gUnknown_0203CEC8.slotId].windowId); - ClearWindowTilemap(gUnknown_0203CEDC[gUnknown_0203CEC8.unkA].windowId); - gTasks[taskId].func = sub_81B3E60; + tSlot1SlideDir *= -1; + tSlot2SlideDir *= -1; + SwitchPartyMon(); + DisplayPartyPokemonData(gPartyMenu.slotId); + DisplayPartyPokemonData(gPartyMenu.slotId2); + PutWindowTilemap(sPartyMenuBoxes[gPartyMenu.slotId].windowId); + PutWindowTilemap(sPartyMenuBoxes[gPartyMenu.slotId2].windowId); + CopyToBufferFromBgTilemap(0, sSlot1TilemapBuffer, tSlot1Left, tSlot1Top, tSlot1Width, tSlot1Height); + CopyToBufferFromBgTilemap(0, sSlot2TilemapBuffer, tSlot2Left, tSlot2Top, tSlot2Width, tSlot2Height); + ClearWindowTilemap(sPartyMenuBoxes[gPartyMenu.slotId].windowId); + ClearWindowTilemap(sPartyMenuBoxes[gPartyMenu.slotId2].windowId); + gTasks[taskId].func = Task_SlideSelectedSlotsOnscreen; } } -static void sub_81B3E60(u8 taskId) +static void Task_SlideSelectedSlotsOnscreen(u8 taskId) { s16 *data = gTasks[taskId].data; - sub_81B3CC0(taskId); - sub_81B3C60(taskId); - if (data[10] == 0 && data[11] == 0) + SlidePartyMenuBoxOneStep(taskId); + SlidePartyMenuBoxSpritesOneStep(taskId); + + // Both slots have slid back onscreen + if (tSlot1SlideDir == 0 && tSlot2SlideDir == 0) { - PutWindowTilemap(gUnknown_0203CEDC[gUnknown_0203CEC8.slotId].windowId); - PutWindowTilemap(gUnknown_0203CEDC[gUnknown_0203CEC8.unkA].windowId); + PutWindowTilemap(sPartyMenuBoxes[gPartyMenu.slotId].windowId); + PutWindowTilemap(sPartyMenuBoxes[gPartyMenu.slotId2].windowId); schedule_bg_copy_tilemap_to_vram(0); - Free(gUnknown_0203CEF0); - Free(gUnknown_0203CEF4); - sub_81B407C(taskId); + Free(sSlot1TilemapBuffer); + Free(sSlot2TilemapBuffer); + FinishTwoMonAction(taskId); } + // Continue sliding else { - data[8] += data[10]; - data[9] += data[11]; - if (data[8] == 0) - data[10] = 0; - if (data[9] == 0) - data[11] = 0; + tSlot1Offset += tSlot1SlideDir; + tSlot2Offset += tSlot2SlideDir; + if (tSlot1Offset == 0) + tSlot1SlideDir = 0; + if (tSlot2Offset == 0) + tSlot2SlideDir = 0; } } -static void oamt_swap_pos(u8 *spriteIdPtr1, u8 *spriteIdPtr2) +static void SwitchMenuBoxSprites(u8 *spriteIdPtr1, u8 *spriteIdPtr2) { u8 spriteIdBuffer = *spriteIdPtr1; u16 xBuffer1, yBuffer1, xBuffer2, yBuffer2; @@ -4082,545 +2943,575 @@ static void oamt_swap_pos(u8 *spriteIdPtr1, u8 *spriteIdPtr2) gSprites[*spriteIdPtr2].pos2.y = yBuffer2; } -static void swap_pokemon_and_oams(void) +static void SwitchPartyMon(void) { - struct Struct203CEDC *structPtrs[2]; + struct PartyMenuBox *menuBoxes[2]; struct Pokemon *mon1, *mon2; struct Pokemon *monBuffer; - structPtrs[0] = &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId]; - structPtrs[1] = &gUnknown_0203CEDC[gUnknown_0203CEC8.unkA]; - mon1 = &gPlayerParty[gUnknown_0203CEC8.slotId]; - mon2 = &gPlayerParty[gUnknown_0203CEC8.unkA]; + menuBoxes[0] = &sPartyMenuBoxes[gPartyMenu.slotId]; + menuBoxes[1] = &sPartyMenuBoxes[gPartyMenu.slotId2]; + mon1 = &gPlayerParty[gPartyMenu.slotId]; + mon2 = &gPlayerParty[gPartyMenu.slotId2]; monBuffer = Alloc(sizeof(struct Pokemon)); *monBuffer = *mon1; *mon1 = *mon2; *mon2 = *monBuffer; Free(monBuffer); - oamt_swap_pos(&structPtrs[0]->pokeballSpriteId, &structPtrs[1]->pokeballSpriteId); - oamt_swap_pos(&structPtrs[0]->itemSpriteId, &structPtrs[1]->itemSpriteId); - oamt_swap_pos(&structPtrs[0]->monSpriteId, &structPtrs[1]->monSpriteId); - oamt_swap_pos(&structPtrs[0]->statusSpriteId, &structPtrs[1]->statusSpriteId); -} - -static void sub_81B407C(u8 taskId) -{ - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - gUnknown_0203CEC8.unkB = 0; - sub_81B0FCC(gUnknown_0203CEC8.slotId, 0); - gUnknown_0203CEC8.slotId = gUnknown_0203CEC8.unkA; - sub_81B0FCC(gUnknown_0203CEC8.unkA, 1); - DisplayPartyMenuStdMessage(0); - gTasks[taskId].func = sub_81B1370; -} + SwitchMenuBoxSprites(&menuBoxes[0]->pokeballSpriteId, &menuBoxes[1]->pokeballSpriteId); + SwitchMenuBoxSprites(&menuBoxes[0]->itemSpriteId, &menuBoxes[1]->itemSpriteId); + SwitchMenuBoxSprites(&menuBoxes[0]->monSpriteId, &menuBoxes[1]->monSpriteId); + SwitchMenuBoxSprites(&menuBoxes[0]->statusSpriteId, &menuBoxes[1]->statusSpriteId); +} + +// Finish switching mons or using Softboiled +static void FinishTwoMonAction(u8 taskId) +{ + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + gPartyMenu.action = PARTY_ACTION_CHOOSE_MON; + AnimatePartySlot(gPartyMenu.slotId, 0); + gPartyMenu.slotId = gPartyMenu.slotId2; + AnimatePartySlot(gPartyMenu.slotId2, 1); + DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); + gTasks[taskId].func = Task_HandleChooseMonInput; +} + +#undef tSlot1Left +#undef tSlot1Top +#undef tSlot1Width +#undef tSlot1Height +#undef tSlot2Left +#undef tSlot2Top +#undef tSlot2Width +#undef tSlot2Height +#undef tSlot1Offset +#undef tSlot2Offset +#undef tSlot1SlideDir +#undef tSlot2SlideDir static void CursorCb_Cancel1(u8 taskId) { PlaySE(SE_SELECT); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - if (gUnknown_0203CEC8.unk8_0 == 6) - DisplayPartyMenuStdMessage(15); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + if (gPartyMenu.menuType == PARTY_MENU_TYPE_DAYCARE) + DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON_2); else - DisplayPartyMenuStdMessage(0); - gTasks[taskId].func = sub_81B1370; + DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); + gTasks[taskId].func = Task_HandleChooseMonInput; } static void CursorCb_Item(u8 taskId) { PlaySE(SE_SELECT); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - sub_81B33B4(gPlayerParty, gUnknown_0203CEC8.slotId, 8); - sub_81B31B0(1); - DisplayPartyMenuStdMessage(24); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + SetPartyMonSelectionActions(gPlayerParty, gPartyMenu.slotId, ACTIONS_ITEM); + DisplaySelectionWindow(SELECTWINDOW_ITEM); + DisplayPartyMenuStdMessage(PARTY_MSG_DO_WHAT_WITH_ITEM); gTasks[taskId].data[0] = 0xFF; - gTasks[taskId].func = HandleMenuInput; + gTasks[taskId].func = Task_HandleSelectionMenuInput; } static void CursorCb_Give(u8 taskId) { PlaySE(SE_SELECT); - gUnknown_0203CEC4->exitCallback = sub_81B41C4; + sPartyMenuInternal->exitCallback = CB2_SelectBagItemToGive; Task_ClosePartyMenu(taskId); } -static void sub_81B41C4(void) +static void CB2_SelectBagItemToGive(void) { if (InBattlePyramid() == FALSE) - GoToBagMenu(RETURN_LOCATION_POKEMON_LIST, POCKETS_COUNT, c2_8123744); + GoToBagMenu(RETURN_LOCATION_POKEMON_LIST, POCKETS_COUNT, CB2_GiveHoldItem); else - sub_81C4F98(2, c2_8123744); + GoToBattlePyramidBagMenu(2, CB2_GiveHoldItem); } -static void c2_8123744(void) +static void CB2_GiveHoldItem(void) { if (gSpecialVar_ItemId == ITEM_NONE) { - InitPartyMenu(gUnknown_0203CEC8.unk8_0, 0xFF, gUnknown_0203CEC8.unkB, 1, 0x7F, sub_81B36FC, gUnknown_0203CEC8.exitCallback); + InitPartyMenu(gPartyMenu.menuType, KEEP_PARTY_LAYOUT, gPartyMenu.action, TRUE, PARTY_MSG_NONE, Task_TryCreateSelectionWindow, gPartyMenu.exitCallback); } else { - gUnknown_0203CEFC = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_HELD_ITEM); - if (gUnknown_0203CEFC != ITEM_NONE) + sPartyMenuItemId = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_HELD_ITEM); + + // Already holding item + if (sPartyMenuItemId != ITEM_NONE) { - InitPartyMenu(gUnknown_0203CEC8.unk8_0, 0xFF, gUnknown_0203CEC8.unkB, 1, 0x7F, sub_81B4350, gUnknown_0203CEC8.exitCallback); + InitPartyMenu(gPartyMenu.menuType, KEEP_PARTY_LAYOUT, gPartyMenu.action, TRUE, PARTY_MSG_NONE, Task_SwitchHoldItemsPrompt, gPartyMenu.exitCallback); } + // Give mail else if (ItemIsMail(gSpecialVar_ItemId)) { RemoveBagItem(gSpecialVar_ItemId, 1); - sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.slotId], gSpecialVar_ItemId); - sub_81B452C(); + GiveItemToMon(&gPlayerParty[gPartyMenu.slotId], gSpecialVar_ItemId); + CB2_WriteMailToGiveMon(); } + // Give item else { - InitPartyMenu(gUnknown_0203CEC8.unk8_0, 0xFF, gUnknown_0203CEC8.unkB, 1, 0x7F, sub_81B42D0, gUnknown_0203CEC8.exitCallback); + InitPartyMenu(gPartyMenu.menuType, KEEP_PARTY_LAYOUT, gPartyMenu.action, TRUE, PARTY_MSG_NONE, Task_GiveHoldItem, gPartyMenu.exitCallback); } } } -static void sub_81B42D0(u8 taskId) +static void Task_GiveHoldItem(u8 taskId) { u16 item; if (!gPaletteFade.active) { item = gSpecialVar_ItemId; - sub_81B1C84(&gPlayerParty[gUnknown_0203CEC8.slotId], item, 0, 0); - sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.slotId], item); + DisplayGaveHeldItemMessage(&gPlayerParty[gPartyMenu.slotId], item, FALSE, 0); + GiveItemToMon(&gPlayerParty[gPartyMenu.slotId], item); RemoveBagItem(item, 1); - gTasks[taskId].func = sub_81B469C; + gTasks[taskId].func = Task_UpdateHeldItemSprite; } } -static void sub_81B4350(u8 taskId) +static void Task_SwitchHoldItemsPrompt(u8 taskId) { if (!gPaletteFade.active) { - sub_81B1D1C(&gPlayerParty[gUnknown_0203CEC8.slotId], gUnknown_0203CEFC, 1); - gTasks[taskId].func = sub_81B43A8; + DisplayAlreadyHoldingItemSwitchMessage(&gPlayerParty[gPartyMenu.slotId], sPartyMenuItemId, TRUE); + gTasks[taskId].func = Task_SwitchItemsYesNo; } } -static void sub_81B43A8(u8 taskId) +static void Task_SwitchItemsYesNo(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - sub_81B334C(); - gTasks[taskId].func = sub_81B43DC; + PartyMenuDisplayYesNoMenu(); + gTasks[taskId].func = Task_HandleSwitchItemsYesNoInput; } } -static void sub_81B43DC(u8 taskId) +static void Task_HandleSwitchItemsYesNoInput(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: + case 0: // Yes, switch items RemoveBagItem(gSpecialVar_ItemId, 1); - if (AddBagItem(gUnknown_0203CEFC, 1) == FALSE) + + // No room to return held item to bag + if (AddBagItem(sPartyMenuItemId, 1) == FALSE) { AddBagItem(gSpecialVar_ItemId, 1); - pokemon_item_not_removed(gUnknown_0203CEFC); - DisplayPartyMenuMessage(gStringVar4, 0); - gTasks[taskId].func = sub_81B1C1C; + BufferBagFullCantTakeItemMessage(sPartyMenuItemId); + DisplayPartyMenuMessage(gStringVar4, FALSE); + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; } + // Giving mail else if (ItemIsMail(gSpecialVar_ItemId)) { - sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.slotId], gSpecialVar_ItemId); - gTasks[taskId].func = sub_81B44FC; + GiveItemToMon(&gPlayerParty[gPartyMenu.slotId], gSpecialVar_ItemId); + gTasks[taskId].func = Task_WriteMailToGiveMonAfterText; } + // Giving item else { - sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.slotId], gSpecialVar_ItemId); - sub_81B1D68(gSpecialVar_ItemId, gUnknown_0203CEFC, 1); - gTasks[taskId].func = sub_81B469C; + GiveItemToMon(&gPlayerParty[gPartyMenu.slotId], gSpecialVar_ItemId); + DisplaySwitchedHeldItemMessage(gSpecialVar_ItemId, sPartyMenuItemId, TRUE); + gTasks[taskId].func = Task_UpdateHeldItemSprite; } break; case MENU_B_PRESSED: PlaySE(SE_SELECT); - case 1: - gTasks[taskId].func = sub_81B1C1C; + // fallthrough + case 1: // No + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; break; } } -static void sub_81B44FC(u8 taskId) +static void Task_WriteMailToGiveMonAfterText(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - gUnknown_0203CEC4->exitCallback = sub_81B452C; + sPartyMenuInternal->exitCallback = CB2_WriteMailToGiveMon; Task_ClosePartyMenu(taskId); } } -static void sub_81B452C(void) +static void CB2_WriteMailToGiveMon(void) { - u8 mail = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_MAIL); + u8 mail = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_MAIL); DoEasyChatScreen( - EASY_CHAT_TYPE_MAIL, - gSaveBlock1Ptr->mail[mail].words, - sub_81B4578, - EASY_CHAT_PERSON_DISPLAY_NONE); + EASY_CHAT_TYPE_MAIL, + gSaveBlock1Ptr->mail[mail].words, + CB2_ReturnToPartyMenuFromWritingMail, + EASY_CHAT_PERSON_DISPLAY_NONE); } -static void sub_81B4578(void) +static void CB2_ReturnToPartyMenuFromWritingMail(void) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; u16 item = GetMonData(mon, MON_DATA_HELD_ITEM); + // Canceled writing mail if (gSpecialVar_Result == FALSE) { TakeMailFromMon(mon); - SetMonData(mon, MON_DATA_HELD_ITEM, &gUnknown_0203CEFC); - RemoveBagItem(gUnknown_0203CEFC, 1); + SetMonData(mon, MON_DATA_HELD_ITEM, &sPartyMenuItemId); + RemoveBagItem(sPartyMenuItemId, 1); AddBagItem(item, 1); - InitPartyMenu(gUnknown_0203CEC8.unk8_0, 0xFF, gUnknown_0203CEC8.unkB, 1, 0, sub_81B36FC, gUnknown_0203CEC8.exitCallback); + InitPartyMenu(gPartyMenu.menuType, KEEP_PARTY_LAYOUT, gPartyMenu.action, TRUE, PARTY_MSG_CHOOSE_MON, Task_TryCreateSelectionWindow, gPartyMenu.exitCallback); } + // Wrote mail else { - InitPartyMenu(gUnknown_0203CEC8.unk8_0, 0xFF, gUnknown_0203CEC8.unkB, 1, 0x7F, sub_81B4624, gUnknown_0203CEC8.exitCallback); + InitPartyMenu(gPartyMenu.menuType, KEEP_PARTY_LAYOUT, gPartyMenu.action, TRUE, PARTY_MSG_NONE, Task_DisplayGaveMailFromPartyMessage, gPartyMenu.exitCallback); } } -static void sub_81B4624(u8 taskId) +// Nearly redundant with Task_DisplayGaveMailFromBagMessgae +static void Task_DisplayGaveMailFromPartyMessage(u8 taskId) { if (!gPaletteFade.active) { - if (gUnknown_0203CEFC == ITEM_NONE) - sub_81B1C84(&gPlayerParty[gUnknown_0203CEC8.slotId], gSpecialVar_ItemId, 0, 0); + if (sPartyMenuItemId == ITEM_NONE) + DisplayGaveHeldItemMessage(&gPlayerParty[gPartyMenu.slotId], gSpecialVar_ItemId, FALSE, 0); else - sub_81B1D68(gSpecialVar_ItemId, gUnknown_0203CEFC, 0); - gTasks[taskId].func = sub_81B469C; + DisplaySwitchedHeldItemMessage(gSpecialVar_ItemId, sPartyMenuItemId, FALSE); + gTasks[taskId].func = Task_UpdateHeldItemSprite; } } -static void sub_81B469C(u8 taskId) +static void Task_UpdateHeldItemSprite(u8 taskId) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - sub_81B5C94(mon, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId]); - if (gUnknown_0203CEC8.unk8_0 == 12) + UpdatePartyMonHeldItemSprite(mon, &sPartyMenuBoxes[gPartyMenu.slotId]); + if (gPartyMenu.menuType == PARTY_MENU_TYPE_STORE_PYRAMID_HELD_ITEMS) { if (GetMonData(mon, MON_DATA_HELD_ITEM) != ITEM_NONE) - DisplayPartyPokemonSelectionText(11, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); + DisplayPartyPokemonDescriptionText(PARTYBOX_DESC_HAVE, &sPartyMenuBoxes[gPartyMenu.slotId], 1); else - DisplayPartyPokemonSelectionText(12, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); + DisplayPartyPokemonDescriptionText(PARTYBOX_DESC_DONT_HAVE, &sPartyMenuBoxes[gPartyMenu.slotId], 1); } - sub_81B1C1C(taskId); + Task_ReturnToChooseMonAfterText(taskId); } } static void CursorCb_TakeItem(u8 taskId) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; u16 item = GetMonData(mon, MON_DATA_HELD_ITEM); PlaySE(SE_SELECT); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); switch (TryTakeMonItem(mon)) { - case 0: + case 0: // Not holding item GetMonNickname(mon, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnNotHolding); - DisplayPartyMenuMessage(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, TRUE); break; - case 1: - pokemon_item_not_removed(item); - DisplayPartyMenuMessage(gStringVar4, 1); + case 1: // No room to take item + BufferBagFullCantTakeItemMessage(item); + DisplayPartyMenuMessage(gStringVar4, TRUE); break; - default: - sub_81B1CD0(mon, item, 1); + default: // Took item + DisplayTookHeldItemMessage(mon, item, TRUE); break; } schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = sub_81B469C; + gTasks[taskId].func = Task_UpdateHeldItemSprite; } static void CursorCb_Toss(u8 taskId) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; u16 item = GetMonData(mon, MON_DATA_HELD_ITEM); PlaySE(SE_SELECT); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); if (item == ITEM_NONE) { GetMonNickname(mon, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnNotHolding); - DisplayPartyMenuMessage(gStringVar4, 1); - gTasks[taskId].func = sub_81B469C; + DisplayPartyMenuMessage(gStringVar4, TRUE); + gTasks[taskId].func = Task_UpdateHeldItemSprite; } else { CopyItemName(item, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_ThrowAwayItem); - DisplayPartyMenuMessage(gStringVar4, 1); - gTasks[taskId].func = sub_81B48A8; + DisplayPartyMenuMessage(gStringVar4, TRUE); + gTasks[taskId].func = Task_TossHeldItemYesNo; } } -static void sub_81B48A8(u8 taskId) +static void Task_TossHeldItemYesNo(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - sub_81B334C(); - gTasks[taskId].func = sub_81B48DC; + PartyMenuDisplayYesNoMenu(); + gTasks[taskId].func = Task_HandleTossHeldItemYesNoInput; } } -static void sub_81B48DC(u8 taskId) +static void Task_HandleTossHeldItemYesNoInput(u8 taskId) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; switch (Menu_ProcessInputNoWrapClearOnChoose()) { case 0: CopyItemName(GetMonData(mon, MON_DATA_HELD_ITEM), gStringVar1); StringExpandPlaceholders(gStringVar4, gText_ItemThrownAway); - DisplayPartyMenuMessage(gStringVar4, 0); - gTasks[taskId].func = sub_81B4988; + DisplayPartyMenuMessage(gStringVar4, FALSE); + gTasks[taskId].func = Task_TossHeldItem; break; case MENU_B_PRESSED: PlaySE(SE_SELECT); + // fallthrough case 1: - gTasks[taskId].func = sub_81B1C1C; + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; break; } } -static void sub_81B4988(u8 taskId) +static void Task_TossHeldItem(u8 taskId) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { u16 item = ITEM_NONE; SetMonData(mon, MON_DATA_HELD_ITEM, &item); - sub_81B5C94(mon, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId]); - DisplayPartyPokemonSelectionText(12, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); - gTasks[taskId].func = sub_81B1C1C; + UpdatePartyMonHeldItemSprite(mon, &sPartyMenuBoxes[gPartyMenu.slotId]); + DisplayPartyPokemonDescriptionText(PARTYBOX_DESC_DONT_HAVE, &sPartyMenuBoxes[gPartyMenu.slotId], 1); + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; } } static void CursorCb_Mail(u8 taskId) { PlaySE(SE_SELECT); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - sub_81B33B4(gPlayerParty, gUnknown_0203CEC8.slotId, 9); - sub_81B31B0(2); - DisplayPartyMenuStdMessage(25); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + SetPartyMonSelectionActions(gPlayerParty, gPartyMenu.slotId, ACTIONS_MAIL); + DisplaySelectionWindow(SELECTWINDOW_MAIL); + DisplayPartyMenuStdMessage(PARTY_MSG_DO_WHAT_WITH_MAIL); gTasks[taskId].data[0] = 0xFF; - gTasks[taskId].func = HandleMenuInput; + gTasks[taskId].func = Task_HandleSelectionMenuInput; } static void CursorCb_Read(u8 taskId) { PlaySE(SE_SELECT); - gUnknown_0203CEC4->exitCallback = sub_81B4A98; + sPartyMenuInternal->exitCallback = CB2_ReadHeldMail; Task_ClosePartyMenu(taskId); } -static void sub_81B4A98(void) +static void CB2_ReadHeldMail(void) { - ReadMail(&gSaveBlock1Ptr->mail[GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_MAIL)], sub_81B4AE0, 1); + ReadMail(&gSaveBlock1Ptr->mail[GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_MAIL)], CB2_ReturnToPartyMenuFromReadingMail, 1); } -static void sub_81B4AE0(void) +static void CB2_ReturnToPartyMenuFromReadingMail(void) { gPaletteFade.bufferTransferDisabled = TRUE; - InitPartyMenu(gUnknown_0203CEC8.unk8_0, 0xFF, gUnknown_0203CEC8.unkB, 1, 21, sub_81B36FC, gUnknown_0203CEC8.exitCallback); + InitPartyMenu(gPartyMenu.menuType, KEEP_PARTY_LAYOUT, gPartyMenu.action, TRUE, PARTY_MSG_DO_WHAT_WITH_MON, Task_TryCreateSelectionWindow, gPartyMenu.exitCallback); } static void CursorCb_TakeMail(u8 taskId) { PlaySE(SE_SELECT); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - DisplayPartyMenuMessage(gText_SendMailToPC, 1); - gTasks[taskId].func = sub_81B4B6C; + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + DisplayPartyMenuMessage(gText_SendMailToPC, TRUE); + gTasks[taskId].func = Task_SendMailToPCYesNo; } -static void sub_81B4B6C(u8 taskId) +static void Task_SendMailToPCYesNo(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - sub_81B334C(); - gTasks[taskId].func = sub_81B4BA0; + PartyMenuDisplayYesNoMenu(); + gTasks[taskId].func = Task_HandleSendMailToPCYesNoInput; } } -static void sub_81B4BA0(u8 taskId) +static void Task_HandleSendMailToPCYesNoInput(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - if (TakeMailFromMon2(&gPlayerParty[gUnknown_0203CEC8.slotId]) != 0xFF) + case 0: // Yes, send to PC + if (TakeMailFromMon2(&gPlayerParty[gPartyMenu.slotId]) != 0xFF) { - DisplayPartyMenuMessage(gText_MailSentToPC, 0); - gTasks[taskId].func = sub_81B469C; + DisplayPartyMenuMessage(gText_MailSentToPC, FALSE); + gTasks[taskId].func = Task_UpdateHeldItemSprite; } else { - DisplayPartyMenuMessage(gText_PCMailboxFull, 0); - gTasks[taskId].func = sub_81B1C1C; + DisplayPartyMenuMessage(gText_PCMailboxFull, FALSE); + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; } break; case MENU_B_PRESSED: PlaySE(SE_SELECT); + // fallthrough case 1: - DisplayPartyMenuMessage(gText_MailMessageWillBeLost, 1); - gTasks[taskId].func = sub_81B4C60; + DisplayPartyMenuMessage(gText_MailMessageWillBeLost, TRUE); + gTasks[taskId].func = Task_LoseMailMessageYesNo; break; } } -static void sub_81B4C60(u8 taskId) +static void Task_LoseMailMessageYesNo(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - sub_81B334C(); - gTasks[taskId].func = sub_81B4C94; + PartyMenuDisplayYesNoMenu(); + gTasks[taskId].func = Task_HandleLoseMailMessageYesNoInput; } } -static void sub_81B4C94(u8 taskId) +static void Task_HandleLoseMailMessageYesNoInput(u8 taskId) { u16 item; switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - item = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_HELD_ITEM); + case 0: // Yes, lose mail message + item = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_HELD_ITEM); if (AddBagItem(item, 1) == TRUE) { - TakeMailFromMon(&gPlayerParty[gUnknown_0203CEC8.slotId]); - DisplayPartyMenuMessage(gText_MailTakenFromPkmn, 0); - gTasks[taskId].func = sub_81B469C; + TakeMailFromMon(&gPlayerParty[gPartyMenu.slotId]); + DisplayPartyMenuMessage(gText_MailTakenFromPkmn, FALSE); + gTasks[taskId].func = Task_UpdateHeldItemSprite; } else { - pokemon_item_not_removed(item); - DisplayPartyMenuMessage(gStringVar4, 0); - gTasks[taskId].func = sub_81B1C1C; + BufferBagFullCantTakeItemMessage(item); + DisplayPartyMenuMessage(gStringVar4, FALSE); + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; } break; case MENU_B_PRESSED: PlaySE(SE_SELECT); + // fallthrough case 1: - gTasks[taskId].func = sub_81B1C1C; + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; break; } } static void CursorCb_Cancel2(u8 taskId) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; PlaySE(SE_SELECT); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - sub_81B33B4(gPlayerParty, gUnknown_0203CEC8.slotId, sub_81B353C(mon)); - if (gUnknown_0203CEC8.unk8_0 != 12) + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + SetPartyMonSelectionActions(gPlayerParty, gPartyMenu.slotId, GetPartyMenuActionsType(mon)); + if (gPartyMenu.menuType != PARTY_MENU_TYPE_STORE_PYRAMID_HELD_ITEMS) { - sub_81B31B0(0); - DisplayPartyMenuStdMessage(21); + DisplaySelectionWindow(SELECTWINDOW_ACTIONS); + DisplayPartyMenuStdMessage(PARTY_MSG_DO_WHAT_WITH_MON); } else { - sub_81B31B0(1); + DisplaySelectionWindow(SELECTWINDOW_ITEM); CopyItemName(GetMonData(mon, MON_DATA_HELD_ITEM), gStringVar2); - DisplayPartyMenuStdMessage(26); + DisplayPartyMenuStdMessage(PARTY_MSG_ALREADY_HOLDING_ONE); } gTasks[taskId].data[0] = 0xFF; - gTasks[taskId].func = HandleMenuInput; + gTasks[taskId].func = Task_HandleSelectionMenuInput; } static void CursorCb_SendMon(u8 taskId) { PlaySE(SE_SELECT); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - if (sub_81B8A7C() == TRUE) + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + if (TrySwitchInPokemon() == TRUE) { Task_ClosePartyMenu(taskId); } else { - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - DisplayPartyMenuMessage(gStringVar4, 1); - gTasks[taskId].func = sub_81B1C1C; + // gStringVar4 below is the error message buffered by TrySwitchInPokemon + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + DisplayPartyMenuMessage(gStringVar4, TRUE); + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; } } static void CursorCb_Enter(u8 taskId) { - u8 unk; + u8 maxBattlers; u8 i; - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - unk = sub_81B8830(); - for (i = 0; i < unk; i++) + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + maxBattlers = GetMaxBattleEntries(); + for (i = 0; i < maxBattlers; i++) { if (gSelectedOrderFromParty[i] == 0) { PlaySE(SE_SELECT); - gSelectedOrderFromParty[i] = gUnknown_0203CEC8.slotId + 1; - DisplayPartyPokemonSelectionText(i + 2, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); - if (i == (unk - 1)) - sub_81B4F88(); - DisplayPartyMenuStdMessage(0); - gTasks[taskId].func = sub_81B1370; + gSelectedOrderFromParty[i] = gPartyMenu.slotId + 1; + DisplayPartyPokemonDescriptionText(i + PARTYBOX_DESC_FIRST, &sPartyMenuBoxes[gPartyMenu.slotId], 1); + if (i == (maxBattlers - 1)) + MoveCursorToConfirm(); + DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); + gTasks[taskId].func = Task_HandleChooseMonInput; return; } } - ConvertIntToDecimalStringN(gStringVar1, unk, STR_CONV_MODE_LEFT_ALIGN, 1); + ConvertIntToDecimalStringN(gStringVar1, maxBattlers, STR_CONV_MODE_LEFT_ALIGN, 1); StringExpandPlaceholders(gStringVar4, gText_NoMoreThanVar1Pkmn); PlaySE(SE_HAZURE); - DisplayPartyMenuMessage(gStringVar4, 1); - gTasks[taskId].func = sub_81B1C1C; + DisplayPartyMenuMessage(gStringVar4, TRUE); + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; } -static void sub_81B4F88(void) +static void MoveCursorToConfirm(void) { - sub_81B0FCC(gUnknown_0203CEC8.slotId, 0); - gUnknown_0203CEC8.slotId = 6; - sub_81B0FCC(gUnknown_0203CEC8.slotId, 1); + AnimatePartySlot(gPartyMenu.slotId, 0); + gPartyMenu.slotId = PARTY_SIZE; + AnimatePartySlot(gPartyMenu.slotId, 1); } static void CursorCb_NoEntry(u8 taskId) { - u8 unk; + u8 maxBattlers; u8 i, j; PlaySE(SE_SELECT); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - unk = sub_81B8830(); - for (i = 0; i < unk; i++) + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + maxBattlers = GetMaxBattleEntries(); + for (i = 0; i < maxBattlers; i++) { - if (gSelectedOrderFromParty[i] == (gUnknown_0203CEC8.slotId + 1)) + if (gSelectedOrderFromParty[i] == (gPartyMenu.slotId + 1)) { - for (j = i; j < (unk - 1); j++) + for (j = i; j < (maxBattlers - 1); j++) gSelectedOrderFromParty[j] = gSelectedOrderFromParty[j + 1]; gSelectedOrderFromParty[j] = 0; break; } } - DisplayPartyPokemonSelectionText(1, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); - for (i = 0; i < (unk - 1); i++) + DisplayPartyPokemonDescriptionText(PARTYBOX_DESC_ABLE_3, &sPartyMenuBoxes[gPartyMenu.slotId], 1); + for (i = 0; i < (maxBattlers - 1); i++) { if (gSelectedOrderFromParty[i] != 0) - DisplayPartyPokemonSelectionText(i + 2, &gUnknown_0203CEDC[gSelectedOrderFromParty[i] - 1], 1); + DisplayPartyPokemonDescriptionText(i + PARTYBOX_DESC_FIRST, &sPartyMenuBoxes[gSelectedOrderFromParty[i] - 1], 1); } - DisplayPartyMenuStdMessage(0); - gTasks[taskId].func = sub_81B1370; + DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); + gTasks[taskId].func = Task_HandleChooseMonInput; } static void CursorCb_Store(u8 taskId) @@ -4632,9 +3523,9 @@ static void CursorCb_Store(u8 taskId) // Register mon for the Trading Board in Union Room static void CursorCb_Register(u8 taskId) { - u16 species2 = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_SPECIES2); - u16 species = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_SPECIES); - u8 obedience = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_OBEDIENCE); + u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2); + u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); + u8 obedience = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_OBEDIENCE); switch (CanRegisterMonForTradingBoard(*(struct UnkLinkRfuStruct_02022B14Substruct *)sub_800F7DC(), species2, species, obedience)) { @@ -4650,29 +3541,29 @@ static void CursorCb_Register(u8 taskId) return; } PlaySE(SE_HAZURE); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); StringAppend(gStringVar4, gText_PauseUntilPress); - DisplayPartyMenuMessage(gStringVar4, 1); - gTasks[taskId].func = sub_81B1C1C; + DisplayPartyMenuMessage(gStringVar4, TRUE); + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; } static void CursorCb_Trade1(u8 taskId) { - u16 species2 = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_SPECIES2); - u16 species = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_SPECIES); - u8 obedience = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_OBEDIENCE); + u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2); + u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); + u8 obedience = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_OBEDIENCE); u32 stringId = GetUnionRoomTradeMessageId(*(struct UnkLinkRfuStruct_02022B14Substruct *)sub_800F7DC(), gUnknown_02022C38, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, obedience); if (stringId != UR_TRADE_MSG_NONE) { StringExpandPlaceholders(gStringVar4, sUnionRoomTradeMessages[stringId - 1]); PlaySE(SE_HAZURE); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); StringAppend(gStringVar4, gText_PauseUntilPress); - DisplayPartyMenuMessage(gStringVar4, 1); - gTasks[taskId].func = sub_81B1C1C; + DisplayPartyMenuMessage(gStringVar4, TRUE); + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; } else { @@ -4681,11 +3572,13 @@ static void CursorCb_Trade1(u8 taskId) } } +// Spin Trade (based on the translation of the Japanese trade prompt) +// Not fully implemented, and normally unreachable because PARTY_MENU_TYPE_SPIN_TRADE is never used static void CursorCb_Trade2(u8 taskId) { - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - switch (CanTradeSelectedPartyMenuMon(gPlayerParty, gUnknown_0203CEC8.slotId)) + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + switch (CanSpinTradeMon(gPlayerParty, gPartyMenu.slotId)) { case CANT_TRADE_LAST_MON: StringExpandPlaceholders(gStringVar4, gText_OnlyPkmnForBattle); @@ -4693,33 +3586,34 @@ static void CursorCb_Trade2(u8 taskId) case CANT_TRADE_NATIONAL: StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow); break; - case CANT_TRADE_EGG: + case CANT_TRADE_EGG_YET: StringExpandPlaceholders(gStringVar4, gText_EggCantBeTradedNow); break; - default: + default: // CAN_TRADE_MON PlaySE(SE_SELECT); - GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.slotId], gStringVar1); - StringExpandPlaceholders(gStringVar4, gJPText_PutVar1IntoSpinner); - DisplayPartyMenuMessage(gStringVar4, 1); - gTasks[taskId].func = sub_81B53FC; + GetMonNickname(&gPlayerParty[gPartyMenu.slotId], gStringVar1); + StringExpandPlaceholders(gStringVar4, gJPText_AreYouSureYouWantToSpinTradeMon); + DisplayPartyMenuMessage(gStringVar4, TRUE); + gTasks[taskId].func = Task_SpinTradeYesNo; return; } PlaySE(SE_HAZURE); StringAppend(gStringVar4, gText_PauseUntilPress); - DisplayPartyMenuMessage(gStringVar4, 1); - gTasks[taskId].func = sub_81B1C1C; + DisplayPartyMenuMessage(gStringVar4, TRUE); + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; } -static void sub_81B53FC(u8 taskId) +static void Task_SpinTradeYesNo(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - sub_81B334C(); - gTasks[taskId].func = sub_81B5430; + PartyMenuDisplayYesNoMenu(); + gTasks[taskId].func = Task_HandleSpinTradeYesNoInput; } } -static void sub_81B5430(u8 taskId) +// See comment on CursorCb_Trade2. Because no callback is set, selecting YES (0) to spin trade just closes the party menu +static void Task_HandleSpinTradeYesNoInput(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { @@ -4728,39 +3622,40 @@ static void sub_81B5430(u8 taskId) break; case MENU_B_PRESSED: PlaySE(SE_SELECT); + // fallthrough case 1: - sub_81B1C1C(taskId); + Task_ReturnToChooseMonAfterText(taskId); break; } } static void CursorCb_FieldMove(u8 taskId) { - u8 fieldMove = gUnknown_0203CEC4->actions[Menu_GetCursorPos()] - MENU_FIELD_MOVES; + u8 fieldMove = sPartyMenuInternal->actions[Menu_GetCursorPos()] - MENU_FIELD_MOVES; const struct MapHeader *mapHeader; PlaySE(SE_SELECT); if (sFieldMoveCursorCallbacks[fieldMove].fieldMoveFunc == NULL) return; - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); if (sub_81221AC() == TRUE || InUnionRoom() == TRUE) { if (fieldMove == FIELD_MOVE_MILK_DRINK || fieldMove == FIELD_MOVE_SOFT_BOILED) - DisplayPartyMenuStdMessage(13); + DisplayPartyMenuStdMessage(PARTY_MSG_CANT_USE_HERE); else DisplayPartyMenuStdMessage(sFieldMoveCursorCallbacks[fieldMove].msgId); - gTasks[taskId].func = task_brm_cancel_1_on_keypad_a_or_b; + gTasks[taskId].func = Task_CancelAfterAorBPress; } else { // All field moves before WATERFALL are HMs. if (fieldMove <= FIELD_MOVE_WATERFALL && FlagGet(FLAG_BADGE01_GET + fieldMove) != TRUE) { - DisplayPartyMenuMessage(gText_CantUseUntilNewBadge, 1); - gTasks[taskId].func = sub_81B1C1C; + DisplayPartyMenuMessage(gText_CantUseUntilNewBadge, TRUE); + gTasks[taskId].func = Task_ReturnToChooseMonAfterText; } else if (sFieldMoveCursorCallbacks[fieldMove].fieldMoveFunc() == TRUE) { @@ -4768,80 +3663,82 @@ static void CursorCb_FieldMove(u8 taskId) { case FIELD_MOVE_MILK_DRINK: case FIELD_MOVE_SOFT_BOILED: - sub_8161560(taskId); + ChooseMonForSoftboiled(taskId); break; case FIELD_MOVE_TELEPORT: mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->lastHealLocation.mapGroup, gSaveBlock1Ptr->lastHealLocation.mapNum); - sub_81245DC(gStringVar1, mapHeader->regionMapSectionId); + GetMapNameGeneric(gStringVar1, mapHeader->regionMapSectionId); StringExpandPlaceholders(gStringVar4, gText_ReturnToHealingSpot); - sub_81B5674(taskId); - gUnknown_0203CEC4->data[0] = fieldMove; + DisplayFieldMoveExitAreaMessage(taskId); + sPartyMenuInternal->data[0] = fieldMove; break; case FIELD_MOVE_DIG: mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->escapeWarp.mapGroup, gSaveBlock1Ptr->escapeWarp.mapNum); - sub_81245DC(gStringVar1, mapHeader->regionMapSectionId); + GetMapNameGeneric(gStringVar1, mapHeader->regionMapSectionId); StringExpandPlaceholders(gStringVar4, gText_EscapeFromHere); - sub_81B5674(taskId); - gUnknown_0203CEC4->data[0] = fieldMove; + DisplayFieldMoveExitAreaMessage(taskId); + sPartyMenuInternal->data[0] = fieldMove; break; case FIELD_MOVE_FLY: - gUnknown_0203CEC8.exitCallback = MCB2_FlyMap; + gPartyMenu.exitCallback = MCB2_FlyMap; Task_ClosePartyMenu(taskId); break; default: - gUnknown_0203CEC8.exitCallback = CB2_ReturnToField; + gPartyMenu.exitCallback = CB2_ReturnToField; Task_ClosePartyMenu(taskId); break; } } + // Cant use Field Move else { switch (fieldMove) { case FIELD_MOVE_SURF: - sub_81B5864(); + DisplayCantUseSurfMessage(); break; case FIELD_MOVE_FLASH: - sub_81B57DC(); + DisplayCantUseFlashMessage(); break; default: DisplayPartyMenuStdMessage(sFieldMoveCursorCallbacks[fieldMove].msgId); break; } - gTasks[taskId].func = task_brm_cancel_1_on_keypad_a_or_b; + gTasks[taskId].func = Task_CancelAfterAorBPress; } } } -static void sub_81B5674(u8 taskId) +static void DisplayFieldMoveExitAreaMessage(u8 taskId) { - DisplayPartyMenuMessage(gStringVar4, 1); - gTasks[taskId].func = sub_81B56A4; + DisplayPartyMenuMessage(gStringVar4, TRUE); + gTasks[taskId].func = Task_FieldMoveExitAreaYesNo; } -static void sub_81B56A4(u8 taskId) +static void Task_FieldMoveExitAreaYesNo(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - sub_81B334C(); - gTasks[taskId].func = sub_81B56D8; + PartyMenuDisplayYesNoMenu(); + gTasks[taskId].func = Task_HandleFieldMoveExitAreaYesNoInput; } } -static void sub_81B56D8(u8 taskId) +static void Task_HandleFieldMoveExitAreaYesNoInput(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { case 0: - gUnknown_0203CEC8.exitCallback = CB2_ReturnToField; + gPartyMenu.exitCallback = CB2_ReturnToField; Task_ClosePartyMenu(taskId); break; case MENU_B_PRESSED: PlaySE(SE_SELECT); + // fallthrough case 1: gFieldCallback2 = NULL; gPostMenuFieldCallback = NULL; - sub_81B1C1C(taskId); + Task_ReturnToChooseMonAfterText(taskId); break; } } @@ -4849,40 +3746,40 @@ static void sub_81B56D8(u8 taskId) bool8 FieldCallback_PrepareFadeInFromMenu(void) { pal_fill_black(); - CreateTask(task_launch_hm_phase_2, 8); + CreateTask(Task_FieldMoveWaitForFade, 8); return TRUE; } -static void task_launch_hm_phase_2(u8 taskId) +static void Task_FieldMoveWaitForFade(u8 taskId) { if (IsWeatherNotFadingIn() == TRUE) { - gFieldEffectArguments[0] = brm_get_selected_species(); + gFieldEffectArguments[0] = GetFieldMoveMonSpecies(); gPostMenuFieldCallback(); DestroyTask(taskId); } } -static u16 brm_get_selected_species(void) +static u16 GetFieldMoveMonSpecies(void) { - return GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_SPECIES); + return GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); } -static void task_brm_cancel_1_on_keypad_a_or_b(u8 taskId) +static void Task_CancelAfterAorBPress(u8 taskId) { if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) CursorCb_Cancel1(taskId); } -static void sub_81B57DC(void) +static void DisplayCantUseFlashMessage(void) { if (FlagGet(FLAG_SYS_USE_FLASH) == TRUE) - DisplayPartyMenuStdMessage(12); + DisplayPartyMenuStdMessage(PARTY_MSG_ALREADY_IN_USE); else - DisplayPartyMenuStdMessage(13); + DisplayPartyMenuStdMessage(PARTY_MSG_CANT_USE_HERE); } -static void hm_surf_run_dp02scr(void) +static void FieldCallback_Surf(void) { gFieldEffectArguments[0] = GetCursorSelectionMonId(); FieldEffectStart(FLDEFF_USE_SURF); @@ -4893,18 +3790,18 @@ static bool8 SetUpFieldMove_Surf(void) if (PartyHasMonWithSurf() == TRUE && IsPlayerFacingSurfableFishableWater() == TRUE) { gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; - gPostMenuFieldCallback = hm_surf_run_dp02scr; + gPostMenuFieldCallback = FieldCallback_Surf; return TRUE; } return FALSE; } -static void sub_81B5864(void) +static void DisplayCantUseSurfMessage(void) { if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) - DisplayPartyMenuStdMessage(9); + DisplayPartyMenuStdMessage(PARTY_MSG_ALREADY_SURFING); else - DisplayPartyMenuStdMessage(8); + DisplayPartyMenuStdMessage(PARTY_MSG_CANT_SURF_HERE); } static bool8 SetUpFieldMove_Fly(void) @@ -4915,12 +3812,12 @@ static bool8 SetUpFieldMove_Fly(void) return FALSE; } -void sub_81B58A8(void) +void CB2_ReturnToPartyMenuFromFlyMap(void) { - InitPartyMenu(0, 0, 0, 1, 0, sub_81B1370, CB2_ReturnToFieldWithOpenMenu); + InitPartyMenu(PARTY_MENU_TYPE_FIELD, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_MON, TRUE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, CB2_ReturnToFieldWithOpenMenu); } -static void hm2_waterfall(void) +static void FieldCallback_Waterfall(void) { gFieldEffectArguments[0] = GetCursorSelectionMonId(); FieldEffectStart(FLDEFF_USE_WATERFALL); @@ -4934,13 +3831,13 @@ static bool8 SetUpFieldMove_Waterfall(void) if (MetatileBehavior_IsWaterfall(MapGridGetMetatileBehaviorAt(x, y)) == TRUE && IsPlayerSurfingNorth() == TRUE) { gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; - gPostMenuFieldCallback = hm2_waterfall; + gPostMenuFieldCallback = FieldCallback_Waterfall; return TRUE; } return FALSE; } -static void sub_81B5958(void) +static void FieldCallback_Dive(void) { gFieldEffectArguments[0] = GetCursorSelectionMonId(); FieldEffectStart(FLDEFF_USE_DIVE); @@ -4952,34 +3849,36 @@ static bool8 SetUpFieldMove_Dive(void) if (gFieldEffectArguments[1] != 0) { gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; - gPostMenuFieldCallback = sub_81B5958; + gPostMenuFieldCallback = FieldCallback_Dive; return TRUE; } return FALSE; } -static void party_menu_icon_anim(struct Pokemon *mon, struct Struct203CEDC *ptr, u32 a) +static void CreatePartyMonIconSprite(struct Pokemon *mon, struct PartyMenuBox *menuBox, u32 slot) { - u32 bit = 1; + bool32 handleDeoxys = TRUE; u16 species2; + // If in a multi battle, show partners Deoxys icon as Normal forme if (IsMultiBattle() == TRUE && gMain.inBattle) - bit = (gUnknown_08616020[a] ^ bit) ? 1 : 0; + handleDeoxys = (sMultiBattlePartnersPartyMask[slot] ^ handleDeoxys) ? TRUE : FALSE; + species2 = GetMonData(mon, MON_DATA_SPECIES2); - party_menu_link_mon_icon_anim(species2, GetMonData(mon, MON_DATA_PERSONALITY), ptr, 1, bit); - sub_81B5B38(ptr->monSpriteId, mon); + CreatePartyMonIconSpriteParameterized(species2, GetMonData(mon, MON_DATA_PERSONALITY), menuBox, 1, handleDeoxys); + UpdatePartyMonHPBar(menuBox->monSpriteId, mon); } -static void party_menu_link_mon_icon_anim(u16 species, u32 pid, struct Struct203CEDC *ptr, u8 priority, u32 bit) +static void CreatePartyMonIconSpriteParameterized(u16 species, u32 pid, struct PartyMenuBox *menuBox, u8 priority, bool32 handleDeoxys) { if (species != SPECIES_NONE) { - ptr->monSpriteId = CreateMonIcon(species, UpdateTradeMonIconFrame, ptr->unk4[0], ptr->unk4[1], 4, pid, bit); - gSprites[ptr->monSpriteId].oam.priority = priority; + menuBox->monSpriteId = CreateMonIcon(species, SpriteCB_MonIcon, menuBox->spriteCoords[0], menuBox->spriteCoords[1], 4, pid, handleDeoxys); + gSprites[menuBox->monSpriteId].oam.priority = priority; } } -static void sub_81B5A8C(u8 spriteId, u16 hp, u16 maxhp) +static void UpdateHPBar(u8 spriteId, u16 hp, u16 maxhp) { switch (GetHPBarLevel(hp, maxhp)) { @@ -5001,15 +3900,15 @@ static void sub_81B5A8C(u8 spriteId, u16 hp, u16 maxhp) } } -static void sub_81B5B38(u8 spriteId, struct Pokemon *mon) +static void UpdatePartyMonHPBar(u8 spriteId, struct Pokemon *mon) { - sub_81B5A8C(spriteId, GetMonData(mon, MON_DATA_HP), GetMonData(mon, MON_DATA_MAX_HP)); + UpdateHPBar(spriteId, GetMonData(mon, MON_DATA_HP), GetMonData(mon, MON_DATA_MAX_HP)); } -static void AnimateSelectedPartyIcon(u8 spriteId, u8 a) +static void AnimateSelectedPartyIcon(u8 spriteId, u8 animNum) { gSprites[spriteId].data[0] = 0; - if (a == 0) + if (animNum == 0) { if (gSprites[spriteId].pos1.x == 16) { @@ -5021,71 +3920,71 @@ static void AnimateSelectedPartyIcon(u8 spriteId, u8 a) gSprites[spriteId].pos2.x = -4; gSprites[spriteId].pos2.y = 0; } - gSprites[spriteId].callback = UpdatePartyMonIconFrame; + gSprites[spriteId].callback = SpriteCB_UpdatePartyMonIcon; } else { gSprites[spriteId].pos2.x = 0; gSprites[spriteId].pos2.y = 0; - gSprites[spriteId].callback = UpdatePartyMonIconFrameAndBounce; + gSprites[spriteId].callback = SpriteCB_BouncePartyMonIcon; } } -static void UpdatePartyMonIconFrameAndBounce(struct Sprite *sprite) +static void SpriteCB_BouncePartyMonIcon(struct Sprite *sprite) { - u8 unk = UpdateMonIconFrame(sprite); + u8 animCmd = UpdateMonIconFrame(sprite); - if (unk != 0) + if (animCmd != 0) { - if (unk & 1) + if (animCmd & 1) // % 2 also matches sprite->pos2.y = -3; else sprite->pos2.y = 1; } } -static void UpdatePartyMonIconFrame(struct Sprite *sprite) +static void SpriteCB_UpdatePartyMonIcon(struct Sprite *sprite) { UpdateMonIconFrame(sprite); } -static void party_menu_held_item_object(struct Pokemon *mon, struct Struct203CEDC *ptr) +static void CreatePartyMonHeldItemSprite(struct Pokemon *mon, struct PartyMenuBox *menuBox) { if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE) { - ptr->itemSpriteId = CreateSprite(&sSpriteTemplate_HeldItem, ptr->unk4[2], ptr->unk4[3], 0); - sub_81B5C94(mon, ptr); + menuBox->itemSpriteId = CreateSprite(&sSpriteTemplate_HeldItem, menuBox->spriteCoords[2], menuBox->spriteCoords[3], 0); + UpdatePartyMonHeldItemSprite(mon, menuBox); } } -static void party_menu_link_mon_held_item_object(u16 species, u16 item, struct Struct203CEDC *ptr) +static void CreatePartyMonHeldItemSpriteParameterized(u16 species, u16 item, struct PartyMenuBox *menuBox) { if (species != SPECIES_NONE) { - ptr->itemSpriteId = CreateSprite(&sSpriteTemplate_HeldItem, ptr->unk4[2], ptr->unk4[3], 0); - gSprites[ptr->itemSpriteId].oam.priority = 0; - sub_81B5CB0(item, ptr); + menuBox->itemSpriteId = CreateSprite(&sSpriteTemplate_HeldItem, menuBox->spriteCoords[2], menuBox->spriteCoords[3], 0); + gSprites[menuBox->itemSpriteId].oam.priority = 0; + ShowOrHideHeldItemSprite(item, menuBox); } } -static void sub_81B5C94(struct Pokemon *mon, struct Struct203CEDC *ptr) +static void UpdatePartyMonHeldItemSprite(struct Pokemon *mon, struct PartyMenuBox *menuBox) { - sub_81B5CB0(GetMonData(mon, MON_DATA_HELD_ITEM), ptr); + ShowOrHideHeldItemSprite(GetMonData(mon, MON_DATA_HELD_ITEM), menuBox); } -static void sub_81B5CB0(u16 item, struct Struct203CEDC *ptr) +static void ShowOrHideHeldItemSprite(u16 item, struct PartyMenuBox *menuBox) { if (item == ITEM_NONE) { - gSprites[ptr->itemSpriteId].invisible = TRUE; + gSprites[menuBox->itemSpriteId].invisible = TRUE; } else { if (ItemIsMail(item)) - StartSpriteAnim(&gSprites[ptr->itemSpriteId], 1); + StartSpriteAnim(&gSprites[menuBox->itemSpriteId], 1); else - StartSpriteAnim(&gSprites[ptr->itemSpriteId], 0); - gSprites[ptr->itemSpriteId].invisible = FALSE; + StartSpriteAnim(&gSprites[menuBox->itemSpriteId], 0); + gSprites[menuBox->itemSpriteId].invisible = FALSE; } } @@ -5150,22 +4049,23 @@ static void SpriteCB_HeldItem(struct Sprite *sprite) } } -static void party_menu_pokeball_object(struct Pokemon *mon, struct Struct203CEDC *ptr) +static void CreatePartyMonPokeballSprite(struct Pokemon *mon, struct PartyMenuBox *menuBox) { if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE) - ptr->pokeballSpriteId = CreateSprite(&sSpriteTemplate_MenuPokeball, ptr->unk4[6], ptr->unk4[7], 8); + menuBox->pokeballSpriteId = CreateSprite(&sSpriteTemplate_MenuPokeball, menuBox->spriteCoords[6], menuBox->spriteCoords[7], 8); } -static void party_menu_link_mon_pokeball_object(u16 species, struct Struct203CEDC *ptr) +static void CreatePartyMonPokeballSpriteParameterized(u16 species, struct PartyMenuBox *menuBox) { if (species != SPECIES_NONE) { - ptr->pokeballSpriteId = CreateSprite(&sSpriteTemplate_MenuPokeball, ptr->unk4[6], ptr->unk4[7], 8); - gSprites[ptr->pokeballSpriteId].oam.priority = 0; + menuBox->pokeballSpriteId = CreateSprite(&sSpriteTemplate_MenuPokeball, menuBox->spriteCoords[6], menuBox->spriteCoords[7], 8); + gSprites[menuBox->pokeballSpriteId].oam.priority = 0; } } -static u8 sub_81B5F34(u8 x, u8 y) +// For Cancel when Confirm isnt present +static u8 CreatePokeballButtonSprite(u8 x, u8 y) { u8 spriteId = CreateSprite(&sSpriteTemplate_MenuPokeball, x, y, 8); @@ -5173,19 +4073,22 @@ static u8 sub_81B5F34(u8 x, u8 y) return spriteId; } -static u8 sub_81B5F74(u8 x, u8 y) +// For Confirm and Cancel when both are present +static u8 CreateSmallPokeballButtonSprite(u8 x, u8 y) { - return CreateSprite(&gSpriteTemplate_8615F78, x, y, 8); + return CreateSprite(&sSpriteTemplate_MenuPokeballSmall, x, y, 8); } -static void sub_81B5F98(u8 spriteId, u8 a) +static void PartyMenuStartSpriteAnim(u8 spriteId, u8 animNum) { - StartSpriteAnim(&gSprites[spriteId], a); + StartSpriteAnim(&gSprites[spriteId], animNum); } -static void sub_81B5FBC(u8 spriteId, u8 spriteId2, u8 a) +// Unused. Might explain the large blank section in gPartyMenuPokeballSmall_Gfx +// At the very least this is how the unused anim cmds for sSpriteAnimTable_MenuPokeballSmall were meant to be accessed +static void SpriteCB_BounceConfirmCancelButton(u8 spriteId, u8 spriteId2, u8 animNum) { - if (a == 0) + if (animNum == 0) { StartSpriteAnim(&gSprites[spriteId], 2); StartSpriteAnim(&gSprites[spriteId2], 4); @@ -5208,41 +4111,41 @@ static void LoadPartyMenuPokeballGfx(void) LoadCompressedSpritePalette(&sSpritePalette_MenuPokeball); } -static void party_menu_status_condition_object(struct Pokemon *mon, struct Struct203CEDC *ptr) +static void CreatePartyMonStatusSprite(struct Pokemon *mon, struct PartyMenuBox *menuBox) { if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE) { - ptr->statusSpriteId = CreateSprite(&sSpriteTemplate_StatusIcons, ptr->unk4[4], ptr->unk4[5], 0); - party_menu_get_status_condition_and_update_object(mon, ptr); + menuBox->statusSpriteId = CreateSprite(&sSpriteTemplate_StatusIcons, menuBox->spriteCoords[4], menuBox->spriteCoords[5], 0); + SetPartyMonAilmentGfx(mon, menuBox); } } -static void party_menu_link_mon_status_condition_object(u16 species, u8 status, struct Struct203CEDC *ptr) +static void CreatePartyMonStatusSpriteParameterized(u16 species, u8 status, struct PartyMenuBox *menuBox) { if (species != SPECIES_NONE) { - ptr->statusSpriteId = CreateSprite(&sSpriteTemplate_StatusIcons, ptr->unk4[4], ptr->unk4[5], 0); - party_menu_update_status_condition_object(status, ptr); - gSprites[ptr->statusSpriteId].oam.priority = 0; + menuBox->statusSpriteId = CreateSprite(&sSpriteTemplate_StatusIcons, menuBox->spriteCoords[4], menuBox->spriteCoords[5], 0); + UpdatePartyMonAilmentGfx(status, menuBox); + gSprites[menuBox->statusSpriteId].oam.priority = 0; } } -static void party_menu_get_status_condition_and_update_object(struct Pokemon *mon, struct Struct203CEDC *ptr) +static void SetPartyMonAilmentGfx(struct Pokemon *mon, struct PartyMenuBox *menuBox) { - party_menu_update_status_condition_object(GetMonAilment(mon), ptr); + UpdatePartyMonAilmentGfx(GetMonAilment(mon), menuBox); } -static void party_menu_update_status_condition_object(u8 status, struct Struct203CEDC *ptr) +static void UpdatePartyMonAilmentGfx(u8 status, struct PartyMenuBox *menuBox) { switch (status) { case AILMENT_NONE: case AILMENT_PKRS: - gSprites[ptr->statusSpriteId].invisible = TRUE; + gSprites[menuBox->statusSpriteId].invisible = TRUE; break; default: - StartSpriteAnim(&gSprites[ptr->statusSpriteId], status - 1); - gSprites[ptr->statusSpriteId].invisible = FALSE; + StartSpriteAnim(&gSprites[menuBox->statusSpriteId], status - 1); + gSprites[menuBox->statusSpriteId].invisible = FALSE; break; } } @@ -5253,68 +4156,68 @@ static void LoadPartyMenuAilmentGfx(void) LoadCompressedSpritePalette(&sSpritePalette_StatusIcons); } -void sub_81B617C(void) +void CB2_ShowPartyMenuForItemUse(void) { - MainCallback callback = c2_815ABFC; - u8 doubleBattleStatus; - bool8 inBattle; + MainCallback callback = CB2_ReturnToBagMenu; + u8 partyLayout; + u8 menuType; u8 i; - u8 msgIdMaybe; + u8 msgId; TaskFunc task; if (gMain.inBattle) { - inBattle = TRUE; - doubleBattleStatus = sub_81B8984(); + menuType = PARTY_MENU_TYPE_IN_BATTLE; + partyLayout = GetPartyLayoutFromBattleType(); } else { - inBattle = FALSE; - doubleBattleStatus = 0; + menuType = PARTY_MENU_TYPE_FIELD; + partyLayout = PARTY_LAYOUT_SINGLE; } if (GetItemEffectType(gSpecialVar_ItemId) == ITEM_EFFECT_SACRED_ASH) { - gUnknown_0203CEC8.slotId = 0; + gPartyMenu.slotId = 0; for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE && GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0) { - gUnknown_0203CEC8.slotId = i; + gPartyMenu.slotId = i; break; } } - task = sub_81B6280; - msgIdMaybe = 0x7F; + task = Task_SetSacredAshCB; + msgId = PARTY_MSG_NONE; } else { if (GetPocketByItemId(gSpecialVar_ItemId) == POCKET_TM_HM) - msgIdMaybe = 4; + msgId = PARTY_MSG_TEACH_WHICH_MON; else - msgIdMaybe = 5; + msgId = PARTY_MSG_USE_ON_WHICH_MON; - task = sub_81B1370; + task = Task_HandleChooseMonInput; } - InitPartyMenu(inBattle, doubleBattleStatus, 3, 1, msgIdMaybe, task, callback); + InitPartyMenu(menuType, partyLayout, PARTY_ACTION_USE_ITEM, TRUE, msgId, task, callback); } -static void c2_815ABFC(void) +static void CB2_ReturnToBagMenu(void) { if (InBattlePyramid() == FALSE) GoToBagMenu(RETURN_LOCATION_UNCHANGED, POCKETS_COUNT, NULL); else - sub_81C4F98(4, gPyramidBagCursorData.callback); + GoToBattlePyramidBagMenu(4, gPyramidBagCursorData.callback); } -static void sub_81B6280(u8 taskId) +static void Task_SetSacredAshCB(u8 taskId) { if (!gPaletteFade.active) { - if (gUnknown_0203CEC8.unk8_0 == 1) - gUnknown_0203CEC4->exitCallback = sub_81B9140; - gUnknown_03006328(taskId, sub_81B6794); + if (gPartyMenu.menuType == PARTY_MENU_TYPE_IN_BATTLE) + sPartyMenuInternal->exitCallback = CB2_SetUpExitToBattleScreen; + gItemUseCB(taskId, Task_ClosePartyMenuAfterText); // ItemUseCB_SacredAsh in this case } } @@ -5398,7 +4301,7 @@ static void GetMedicineItemEffectMessage(u16 item) } } -static bool8 UsingHPEVItemOnShedinja(struct Pokemon *mon, u16 item) +static bool8 NotUsingHPEVItemOnShedinja(struct Pokemon *mon, u16 item) { if (GetItemEffectType(item) == ITEM_EFFECT_HP_EV && GetMonData(mon, MON_DATA_SPECIES) == SPECIES_SHEDINJA) return FALSE; @@ -5412,10 +4315,10 @@ static bool8 IsItemFlute(u16 item) return FALSE; } -static bool8 ExecuteTableBasedItemEffect__(u8 partyMonIndex, u16 item, u8 monMoveIndex) +static bool8 ExecuteTableBasedItemEffect_(u8 partyMonIndex, u16 item, u8 monMoveIndex) { if (gMain.inBattle) - return ExecuteTableBasedItemEffect(&gPlayerParty[partyMonIndex], item, sub_81B8F38(partyMonIndex), monMoveIndex); + return ExecuteTableBasedItemEffect(&gPlayerParty[partyMonIndex], item, GetPartyIdFromBattleSlot(partyMonIndex), monMoveIndex); else return ExecuteTableBasedItemEffect(&gPlayerParty[partyMonIndex], item, partyMonIndex, monMoveIndex); } @@ -5423,11 +4326,11 @@ static bool8 ExecuteTableBasedItemEffect__(u8 partyMonIndex, u16 item, u8 monMov void ItemUseCB_Medicine(u8 taskId, TaskFunc task) { u16 hp = 0; - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; u16 item = gSpecialVar_ItemId; bool8 canHeal; - if (UsingHPEVItemOnShedinja(mon, item)) + if (NotUsingHPEVItemOnShedinja(mon, item)) { canHeal = IsHPRecoveryItem(item); if (canHeal == TRUE) @@ -5436,12 +4339,12 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task) if (hp == GetMonData(mon, MON_DATA_MAX_HP)) canHeal = FALSE; } - if (ExecuteTableBasedItemEffect__(gUnknown_0203CEC8.slotId, item, 0)) + if (ExecuteTableBasedItemEffect_(gPartyMenu.slotId, item, 0)) { iTriedHonestlyIDid: - gUnknown_0203CEE8 = 0; + gPartyMenuUseExitCallback = FALSE; PlaySE(SE_SELECT); - DisplayPartyMenuMessage(gText_WontHaveEffect, 1); + DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = task; return; @@ -5449,89 +4352,89 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task) } else { - goto iTriedHonestlyIDid; + goto iTriedHonestlyIDid; //TODO: resolve this goto } - gUnknown_0203CEE8 = 1; - if (IsItemFlute(item) == FALSE) + gPartyMenuUseExitCallback = TRUE; + if (!IsItemFlute(item)) { PlaySE(SE_KAIFUKU); - if (gUnknown_0203CEC8.unkB != 14) + if (gPartyMenu.action != PARTY_ACTION_REUSABLE_ITEM) RemoveBagItem(item, 1); } else { PlaySE(SE_BIDORO); } - party_menu_get_status_condition_and_update_object(mon, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId]); - if (gSprites[gUnknown_0203CEDC[gUnknown_0203CEC8.slotId].statusSpriteId].invisible) - DisplayPartyPokemonLevelCheck(mon, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); + SetPartyMonAilmentGfx(mon, &sPartyMenuBoxes[gPartyMenu.slotId]); + if (gSprites[sPartyMenuBoxes[gPartyMenu.slotId].statusSpriteId].invisible) + DisplayPartyPokemonLevelCheck(mon, &sPartyMenuBoxes[gPartyMenu.slotId], 1); if (canHeal == TRUE) { if (hp == 0) - sub_81B0FCC(gUnknown_0203CEC8.slotId, 1); - sub_81B1F18(taskId, gUnknown_0203CEC8.slotId, 1, GetMonData(mon, MON_DATA_HP) - hp, sub_81B672C); - sub_81B1FA8(taskId, 0, hp); + AnimatePartySlot(gPartyMenu.slotId, 1); + PartyMenuModifyHP(taskId, gPartyMenu.slotId, 1, GetMonData(mon, MON_DATA_HP) - hp, Task_DisplayHPRestoredMessage); + ResetHPTaskData(taskId, 0, hp); return; } else { GetMonNickname(mon, gStringVar1); GetMedicineItemEffectMessage(item); - DisplayPartyMenuMessage(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, TRUE); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = task; } } -static void sub_81B672C(u8 taskId) +static void Task_DisplayHPRestoredMessage(u8 taskId) { - GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.slotId], gStringVar1); + GetMonNickname(&gPlayerParty[gPartyMenu.slotId], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnHPRestoredByVar2); - DisplayPartyMenuMessage(gStringVar4, 0); + DisplayPartyMenuMessage(gStringVar4, FALSE); schedule_bg_copy_tilemap_to_vram(2); HandleBattleLowHpMusicChange(); - gTasks[taskId].func = sub_81B6794; + gTasks[taskId].func = Task_ClosePartyMenuAfterText; } -static void sub_81B6794(u8 taskId) +static void Task_ClosePartyMenuAfterText(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - if (gUnknown_0203CEE8 == 0) - gUnknown_0203CEC4->exitCallback = NULL; + if (gPartyMenuUseExitCallback == FALSE) + sPartyMenuInternal->exitCallback = NULL; Task_ClosePartyMenu(taskId); } } -void sub_81B67C8(u8 taskId, TaskFunc task) +void ItemUseCB_ReduceEV(u8 taskId, TaskFunc task) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; u16 item = gSpecialVar_ItemId; u8 effectType = GetItemEffectType(item); u16 friendship = GetMonData(mon, MON_DATA_FRIENDSHIP); - u16 relevantEV = ItemEffectToMonEv(mon, effectType); - bool8 cannotUseEffect = ExecuteTableBasedItemEffect__(gUnknown_0203CEC8.slotId, item, 0); + u16 ev = ItemEffectToMonEv(mon, effectType); + bool8 cannotUseEffect = ExecuteTableBasedItemEffect_(gPartyMenu.slotId, item, 0); u16 newFriendship = GetMonData(mon, MON_DATA_FRIENDSHIP); - u16 newRelevantEV = ItemEffectToMonEv(mon, effectType); + u16 newEv = ItemEffectToMonEv(mon, effectType); - if (cannotUseEffect || (friendship == newFriendship && relevantEV == newRelevantEV)) + if (cannotUseEffect || (friendship == newFriendship && ev == newEv)) { - gUnknown_0203CEE8 = 0; + gPartyMenuUseExitCallback = FALSE; PlaySE(SE_SELECT); - DisplayPartyMenuMessage(gText_WontHaveEffect, 1); + DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = task; } else { - gUnknown_0203CEE8 = 1; + gPartyMenuUseExitCallback = TRUE; PlaySE(SE_KAIFUKU); RemoveBagItem(item, 1); GetMonNickname(mon, gStringVar1); ItemEffectToStatString(effectType, gStringVar2); if (friendship != newFriendship) { - if (relevantEV != newRelevantEV) + if (ev != newEv) StringExpandPlaceholders(gStringVar4, gText_PkmnFriendlyBaseVar2Fell); else StringExpandPlaceholders(gStringVar4, gText_PkmnFriendlyBaseVar2CantFall); @@ -5540,7 +4443,7 @@ void sub_81B67C8(u8 taskId, TaskFunc task) { StringExpandPlaceholders(gStringVar4, gText_PkmnAdoresBaseVar2Fell); } - DisplayPartyMenuMessage(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, TRUE); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = task; } @@ -5593,18 +4496,18 @@ static void ItemEffectToStatString(u8 effectType, u8 *dest) } } -static void sub_81B6A10(u8 slot) +static void ShowMoveSelectWindow(u8 slot) { u8 i; u8 moveCount = 0; u8 fontId = 1; - u8 windowId = sub_81B31B0(3); + u8 windowId = DisplaySelectionWindow(SELECTWINDOW_MOVES); u16 move; for (i = 0; i < MAX_MON_MOVES; i++) { move = GetMonData(&gPlayerParty[slot], MON_DATA_MOVE1 + i); - AddTextPrinterParameterized(windowId, fontId, gMoveNames[move], 8, (i * 16) + 1, 0xFF, NULL); + AddTextPrinterParameterized(windowId, fontId, gMoveNames[move], 8, (i * 16) + 1, TEXT_SPEED_FF, NULL); if (move != MOVE_NONE) moveCount++; } @@ -5612,7 +4515,7 @@ static void sub_81B6A10(u8 slot) schedule_bg_copy_tilemap_to_vram(2); } -static void ether_effect_related_3(u8 taskId) +static void Task_HandleWhichMoveInput(u8 taskId) { s8 input = Menu_ProcessInput(); @@ -5621,17 +4524,17 @@ static void ether_effect_related_3(u8 taskId) if (input == MENU_B_PRESSED) { PlaySE(SE_SELECT); - sub_81B6BB4(taskId); + ReturnToUseOnWhichMon(taskId); } else { - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - ether_effect_related_2(taskId); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); + SetSelectedMoveForPPItem(taskId); } } } -void dp05_ether(u8 taskId, TaskFunc task) +void ItemUseCB_PPRecovery(u8 taskId, TaskFunc task) { const u8 *effect; u16 item = gSpecialVar_ItemId; @@ -5643,76 +4546,76 @@ void dp05_ether(u8 taskId, TaskFunc task) if (!(effect[4] & ITEM4_HEAL_PP_ONE)) { - gUnknown_0203CEC8.unkE = 0; - ether_effect_related(taskId); + gPartyMenu.data1 = 0; + TryUsePPItem(taskId); } else { PlaySE(SE_SELECT); - DisplayPartyMenuStdMessage(22); - sub_81B6A10(gUnknown_0203CEC8.slotId); - gTasks[taskId].func = ether_effect_related_3; + DisplayPartyMenuStdMessage(PARTY_MSG_RESTORE_WHICH_MOVE); + ShowMoveSelectWindow(gPartyMenu.slotId); + gTasks[taskId].func = Task_HandleWhichMoveInput; } } -static void ether_effect_related_2(u8 taskId) +static void SetSelectedMoveForPPItem(u8 taskId) { - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - gUnknown_0203CEC8.unkE = Menu_GetCursorPos(); - ether_effect_related(taskId); + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + gPartyMenu.data1 = Menu_GetCursorPos(); + TryUsePPItem(taskId); } -static void sub_81B6BB4(u8 taskId) +static void ReturnToUseOnWhichMon(u8 taskId) { - gTasks[taskId].func = sub_81B1370; - gUnknown_0203CEC4->exitCallback = NULL; - PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); - DisplayPartyMenuStdMessage(5); + gTasks[taskId].func = Task_HandleChooseMonInput; + sPartyMenuInternal->exitCallback = NULL; + PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); + DisplayPartyMenuStdMessage(PARTY_MSG_USE_ON_WHICH_MON); } -static void ether_effect_related(u8 taskId) +static void TryUsePPItem(u8 taskId) { u16 move = MOVE_NONE; - s16 *moveslot = &gUnknown_0203CEC8.unkE; + s16 *moveSlot = &gPartyMenu.data1; u16 item = gSpecialVar_ItemId; - struct Struct203CEC8 *ptr = &gUnknown_0203CEC8; + struct PartyMenu *ptr = &gPartyMenu; struct Pokemon *mon; - if (ExecuteTableBasedItemEffect__(ptr->slotId, item, *moveslot)) + if (ExecuteTableBasedItemEffect_(ptr->slotId, item, *moveSlot)) { - gUnknown_0203CEE8 = 0; + gPartyMenuUseExitCallback = FALSE; PlaySE(SE_SELECT); - DisplayPartyMenuMessage(gText_WontHaveEffect, 1); + DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = sub_81B6794; + gTasks[taskId].func = Task_ClosePartyMenuAfterText; } else { - gUnknown_0203CEE8 = 1; + gPartyMenuUseExitCallback = TRUE; mon = &gPlayerParty[ptr->slotId]; PlaySE(SE_KAIFUKU); RemoveBagItem(item, 1); - move = GetMonData(mon, MON_DATA_MOVE1 + *moveslot); + move = GetMonData(mon, MON_DATA_MOVE1 + *moveSlot); StringCopy(gStringVar1, gMoveNames[move]); GetMedicineItemEffectMessage(item); - DisplayPartyMenuMessage(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, TRUE); schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = sub_81B6794; + gTasks[taskId].func = Task_ClosePartyMenuAfterText; } } -void dp05_pp_up(u8 taskId, TaskFunc task) +void ItemUseCB_PPUp(u8 taskId, TaskFunc task) { PlaySE(SE_SELECT); - DisplayPartyMenuStdMessage(23); - sub_81B6A10(gUnknown_0203CEC8.slotId); - gTasks[taskId].func = ether_effect_related_3; + DisplayPartyMenuStdMessage(PARTY_MSG_BOOST_PP_WHICH_MOVE); + ShowMoveSelectWindow(gPartyMenu.slotId); + gTasks[taskId].func = Task_HandleWhichMoveInput; } u16 ItemIdToBattleMoveId(u16 item) { u16 tmNumber = item - ITEM_TM01_FOCUS_PUNCH; - return gTMHMMoves[tmNumber]; + return sTMHMMoves[tmNumber]; } bool8 IsMoveHm(u16 move) @@ -5721,7 +4624,7 @@ bool8 IsMoveHm(u16 move) for (i = 0; i < NUM_HIDDEN_MACHINES; i++) { - if (gTMHMMoves[i + NUM_TECHNICAL_MACHINES] == move) + if (sTMHMMoves[i + NUM_TECHNICAL_MACHINES] == move) return TRUE; } return FALSE; @@ -5739,30 +4642,30 @@ bool8 MonKnowsMove(struct Pokemon *mon, u16 move) return FALSE; } -static void sub_81B6D74(const u8 *str) +static void DisplayLearnMoveMessage(const u8 *str) { StringExpandPlaceholders(gStringVar4, str); - DisplayPartyMenuMessage(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, TRUE); schedule_bg_copy_tilemap_to_vram(2); } -static void sub_81B6D98(u8 taskId, const u8 *str) +static void DisplayLearnMoveMessageAndClose(u8 taskId, const u8 *str) { - sub_81B6D74(str); - gTasks[taskId].func = sub_81B6794; + DisplayLearnMoveMessage(str); + gTasks[taskId].func = Task_ClosePartyMenuAfterText; } // move[1] doesn't use constants cause I don't know if it's actually a move ID storage -void sub_81B6DC4(u8 taskId, TaskFunc task) +void ItemUseCB_TMHM(u8 taskId, TaskFunc task) { struct Pokemon *mon; s16 *move; u16 item; PlaySE(SE_SELECT); - mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; - move = &gUnknown_0203CEC8.unkE; + mon = &gPlayerParty[gPartyMenu.slotId]; + move = &gPartyMenu.data1; item = gSpecialVar_ItemId; GetMonNickname(mon, gStringVar1); move[0] = ItemIdToBattleMoveId(item); @@ -5772,28 +4675,28 @@ void sub_81B6DC4(u8 taskId, TaskFunc task) switch (CanMonLearnTMTutor(mon, item, 0)) { case CANNOT_LEARN_MOVE: - sub_81B6D98(taskId, gText_PkmnCantLearnMove); + DisplayLearnMoveMessageAndClose(taskId, gText_PkmnCantLearnMove); return; case ALREADY_KNOWS_MOVE: - sub_81B6D98(taskId, gText_PkmnAlreadyKnows); + DisplayLearnMoveMessageAndClose(taskId, gText_PkmnAlreadyKnows); return; } - if (GiveMoveToMon(mon, move[0]) != 0xFFFF) + if (GiveMoveToMon(mon, move[0]) != MON_HAS_MAX_MOVES) { - gTasks[taskId].func = sub_81B6EB4; + gTasks[taskId].func = Task_LearnedMove; } else { - sub_81B6D74(gText_PkmnNeedsToReplaceMove); - gTasks[taskId].func = sub_81B6FF4; + DisplayLearnMoveMessage(gText_PkmnNeedsToReplaceMove); + gTasks[taskId].func = Task_ReplaceMoveYesNo; } } -static void sub_81B6EB4(u8 taskId) +static void Task_LearnedMove(u8 taskId) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; - s16 *move = &gUnknown_0203CEC8.unkE; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; + s16 *move = &gPartyMenu.data1; u16 item = gSpecialVar_ItemId; if (move[1] == 0) @@ -5805,186 +4708,188 @@ static void sub_81B6EB4(u8 taskId) GetMonNickname(mon, gStringVar1); StringCopy(gStringVar2, gMoveNames[move[0]]); StringExpandPlaceholders(gStringVar4, gText_PkmnLearnedMove3); - DisplayPartyMenuMessage(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, TRUE); schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = sub_81B6F60; + gTasks[taskId].func = Task_DoLearnedMoveFanfareAfterText; } -static void sub_81B6F60(u8 taskId) +static void Task_DoLearnedMoveFanfareAfterText(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { PlayFanfare(MUS_FANFA1); - gTasks[taskId].func = sub_81B6F98; + gTasks[taskId].func = Task_LearnNextMoveOrClosePartyMenu; } } -static void sub_81B6F98(u8 taskId) +static void Task_LearnNextMoveOrClosePartyMenu(u8 taskId) { if (IsFanfareTaskInactive() && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) { - if (gUnknown_0203CEC8.unk10 == 1) - sub_81B77AC(taskId); + if (gPartyMenu.learnMoveState == 1) + Task_TryLearningNextMove(taskId); else { - if (gUnknown_0203CEC8.unk10 == 2) + if (gPartyMenu.learnMoveState == 2) // never occurs gSpecialVar_Result = TRUE; Task_ClosePartyMenu(taskId); } } } -static void sub_81B6FF4(u8 taskId) +static void Task_ReplaceMoveYesNo(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - sub_81B334C(); - gTasks[taskId].func = sub_81B7028; + PartyMenuDisplayYesNoMenu(); + gTasks[taskId].func = Task_HandleReplaceMoveYesNoInput; } } -static void sub_81B7028(u8 taskId) +static void Task_HandleReplaceMoveYesNoInput(u8 taskId) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { case 0: - DisplayPartyMenuMessage(gText_WhichMoveToForget, 1); - gTasks[taskId].func = sub_81B7088; + DisplayPartyMenuMessage(gText_WhichMoveToForget, TRUE); + gTasks[taskId].func = Task_ShowSummaryScreenToForgetMove; break; case MENU_B_PRESSED: PlaySE(SE_SELECT); + // fallthrough case 1: - sub_81B7230(taskId); + StopLearningMovePrompt(taskId); break; } } -static void sub_81B7088(u8 taskId) +static void Task_ShowSummaryScreenToForgetMove(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - gUnknown_0203CEC4->exitCallback = sub_81B70B8; + sPartyMenuInternal->exitCallback = CB2_ShowSummaryScreenToForgetMove; Task_ClosePartyMenu(taskId); } } -static void sub_81B70B8(void) +static void CB2_ShowSummaryScreenToForgetMove(void) { - ShowSelectMovePokemonSummaryScreen(gPlayerParty, gUnknown_0203CEC8.slotId, gPlayerPartyCount - 1, sub_81B70F0, gUnknown_0203CEC8.unkE); + ShowSelectMovePokemonSummaryScreen(gPlayerParty, gPartyMenu.slotId, gPlayerPartyCount - 1, CB2_ReturnToPartyMenuWhileLearningMove, gPartyMenu.data1); } -static void sub_81B70F0(void) +static void CB2_ReturnToPartyMenuWhileLearningMove(void) { - InitPartyMenu(0, 0, 0, 1, 0x7F, sub_81B711C, gUnknown_0203CEC8.exitCallback); + InitPartyMenu(PARTY_MENU_TYPE_FIELD, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_MON, TRUE, PARTY_MSG_NONE, Task_ReturnToPartyMenuWhileLearningMove, gPartyMenu.exitCallback); } -static void sub_81B711C(u8 taskId) +static void Task_ReturnToPartyMenuWhileLearningMove(u8 taskId) { if (!gPaletteFade.active) { - if (sub_81C1B94() != 4) - sub_81B7154(taskId); + if (GetMoveSlotToReplace() != MAX_MON_MOVES) + DisplayPartyMenuForgotMoveMessage(taskId); else - sub_81B7230(taskId); + StopLearningMovePrompt(taskId); } } -static void sub_81B7154(u8 taskId) +static void DisplayPartyMenuForgotMoveMessage(u8 taskId) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; - u16 move = GetMonData(mon, MON_DATA_MOVE1 + sub_81C1B94()); + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; + u16 move = GetMonData(mon, MON_DATA_MOVE1 + GetMoveSlotToReplace()); GetMonNickname(mon, gStringVar1); StringCopy(gStringVar2, gMoveNames[move]); - sub_81B6D74(gText_12PoofForgotMove); - gTasks[taskId].func = sub_81B71D4; + DisplayLearnMoveMessage(gText_12PoofForgotMove); + gTasks[taskId].func = Task_PartyMenuReplaceMove; } -static void sub_81B71D4(u8 taskId) +static void Task_PartyMenuReplaceMove(u8 taskId) { struct Pokemon *mon; u16 move; - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; - RemoveMonPPBonus(mon, sub_81C1B94()); - move = gUnknown_0203CEC8.unkE; - SetMonMoveSlot(mon, move, sub_81C1B94()); - sub_81B6EB4(taskId); + mon = &gPlayerParty[gPartyMenu.slotId]; + RemoveMonPPBonus(mon, GetMoveSlotToReplace()); + move = gPartyMenu.data1; + SetMonMoveSlot(mon, move, GetMoveSlotToReplace()); + Task_LearnedMove(taskId); } } -static void sub_81B7230(u8 taskId) +static void StopLearningMovePrompt(u8 taskId) { - StringCopy(gStringVar2, gMoveNames[gUnknown_0203CEC8.unkE]); + StringCopy(gStringVar2, gMoveNames[gPartyMenu.data1]); StringExpandPlaceholders(gStringVar4, gText_StopLearningMove2); - DisplayPartyMenuMessage(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, TRUE); schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = sub_81B7294; + gTasks[taskId].func = Task_StopLearningMoveYesNo; } -static void sub_81B7294(u8 taskId) +static void Task_StopLearningMoveYesNo(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - sub_81B334C(); - gTasks[taskId].func = sub_81B72C8; + PartyMenuDisplayYesNoMenu(); + gTasks[taskId].func = Task_HandleStopLearningMoveYesNoInput; } } -static void sub_81B72C8(u8 taskId) +static void Task_HandleStopLearningMoveYesNoInput(u8 taskId) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; switch (Menu_ProcessInputNoWrapClearOnChoose()) { case 0: GetMonNickname(mon, gStringVar1); - StringCopy(gStringVar2, gMoveNames[gUnknown_0203CEC8.unkE]); + StringCopy(gStringVar2, gMoveNames[gPartyMenu.data1]); StringExpandPlaceholders(gStringVar4, gText_MoveNotLearned); - DisplayPartyMenuMessage(gStringVar4, 1); - if (gUnknown_0203CEC8.unk10 == 1) + DisplayPartyMenuMessage(gStringVar4, TRUE); + if (gPartyMenu.learnMoveState == 1) { - gTasks[taskId].func = sub_81B73E4; + gTasks[taskId].func = Task_TryLearningNextMoveAfterText; } else { - if (gUnknown_0203CEC8.unk10 == 2) + if (gPartyMenu.learnMoveState == 2) // never occurs gSpecialVar_Result = FALSE; - gTasks[taskId].func = sub_81B6794; + gTasks[taskId].func = Task_ClosePartyMenuAfterText; } break; case MENU_B_PRESSED: PlaySE(SE_SELECT); + // fallthrough case 1: GetMonNickname(mon, gStringVar1); - StringCopy(gStringVar2, gMoveNames[gUnknown_0203CEC8.unkE]); - sub_81B6D74(gText_PkmnNeedsToReplaceMove); - gTasks[taskId].func = sub_81B6FF4; + StringCopy(gStringVar2, gMoveNames[gPartyMenu.data1]); + DisplayLearnMoveMessage(gText_PkmnNeedsToReplaceMove); + gTasks[taskId].func = Task_ReplaceMoveYesNo; break; } } -static void sub_81B73E4(u8 taskId) +static void Task_TryLearningNextMoveAfterText(u8 taskId) { - if (sub_81B1BD4() != TRUE) - sub_81B77AC(taskId); + if (IsPartyMenuTextPrinterActive() != TRUE) + Task_TryLearningNextMove(taskId); } -void dp05_rare_candy(u8 taskId, TaskFunc task) +void ItemUseCB_RareCandy(u8 taskId, TaskFunc task) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; - struct Struct203CEC4 *ptr = gUnknown_0203CEC4; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; + struct PartyMenuInternal *ptr = sPartyMenuInternal; s16 *arrayPtr = ptr->data; u16 *itemPtr = &gSpecialVar_ItemId; bool8 cannotUseEffect; if (GetMonData(mon, MON_DATA_LEVEL) != MAX_LEVEL) { - sub_81B79A0(mon, arrayPtr); - cannotUseEffect = ExecuteTableBasedItemEffect__(gUnknown_0203CEC8.slotId, *itemPtr, 0); - sub_81B79A0(mon, &ptr->data[6]); + BufferMonStatsToTaskData(mon, arrayPtr); + cannotUseEffect = ExecuteTableBasedItemEffect_(gPartyMenu.slotId, *itemPtr, 0); + BufferMonStatsToTaskData(mon, &ptr->data[NUM_STATS]); } else { @@ -5993,166 +4898,166 @@ void dp05_rare_candy(u8 taskId, TaskFunc task) PlaySE(SE_SELECT); if (cannotUseEffect) { - gUnknown_0203CEE8 = 0; - DisplayPartyMenuMessage(gText_WontHaveEffect, 1); + gPartyMenuUseExitCallback = FALSE; + DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = task; } else { - gUnknown_0203CEE8 = 1; + gPartyMenuUseExitCallback = TRUE; PlayFanfareByFanfareNum(0); - sub_81B754C(gUnknown_0203CEC8.slotId, mon); + UpdateMonDisplayInfoAfterRareCandy(gPartyMenu.slotId, mon); RemoveBagItem(gSpecialVar_ItemId, 1); GetMonNickname(mon, gStringVar1); ConvertIntToDecimalStringN(gStringVar2, GetMonData(mon, MON_DATA_LEVEL), STR_CONV_MODE_LEFT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gText_PkmnElevatedToLvVar2); - DisplayPartyMenuMessage(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, TRUE); schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = sub_81B75D4; + gTasks[taskId].func = Task_DisplayLevelUpStatsPg1; } } -static void sub_81B754C(u8 slot, struct Pokemon *mon) +static void UpdateMonDisplayInfoAfterRareCandy(u8 slot, struct Pokemon *mon) { - party_menu_get_status_condition_and_update_object(mon, &gUnknown_0203CEDC[slot]); - if (gSprites[gUnknown_0203CEDC[slot].statusSpriteId].invisible) - DisplayPartyPokemonLevelCheck(mon, &gUnknown_0203CEDC[slot], 1); - DisplayPartyPokemonHPCheck(mon, &gUnknown_0203CEDC[slot], 1); - DisplayPartyPokemonMaxHPCheck(mon, &gUnknown_0203CEDC[slot], 1); - DisplayPartyPokemonHPBarCheck(mon, &gUnknown_0203CEDC[slot]); - sub_81B5B38(gUnknown_0203CEDC[slot].monSpriteId, mon); - sub_81B0FCC(slot, 1); + SetPartyMonAilmentGfx(mon, &sPartyMenuBoxes[slot]); + if (gSprites[sPartyMenuBoxes[slot].statusSpriteId].invisible) + DisplayPartyPokemonLevelCheck(mon, &sPartyMenuBoxes[slot], 1); + DisplayPartyPokemonHPCheck(mon, &sPartyMenuBoxes[slot], 1); + DisplayPartyPokemonMaxHPCheck(mon, &sPartyMenuBoxes[slot], 1); + DisplayPartyPokemonHPBarCheck(mon, &sPartyMenuBoxes[slot]); + UpdatePartyMonHPBar(sPartyMenuBoxes[slot].monSpriteId, mon); + AnimatePartySlot(slot, 1); schedule_bg_copy_tilemap_to_vram(0); } -static void sub_81B75D4(u8 taskId) +static void Task_DisplayLevelUpStatsPg1(u8 taskId) { - if (WaitFanfare(FALSE) && sub_81B1BD4() != TRUE && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) + if (WaitFanfare(FALSE) && IsPartyMenuTextPrinterActive() != TRUE && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) { PlaySE(SE_SELECT); - sub_81B767C(taskId); - gTasks[taskId].func = sub_81B7634; + DisplayLevelUpStatsPg1(taskId); + gTasks[taskId].func = Task_DisplayLevelUpStatsPg2; } } -static void sub_81B7634(u8 taskId) +static void Task_DisplayLevelUpStatsPg2(u8 taskId) { if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) { PlaySE(SE_SELECT); - sub_81B76C8(taskId); - gTasks[taskId].func = sub_81B7704; + DisplayLevelUpStatsPg2(taskId); + gTasks[taskId].func = Task_TryLearnNewMoves; } } -static void sub_81B767C(u8 taskId) +static void DisplayLevelUpStatsPg1(u8 taskId) { - s16 *arrayPtr = gUnknown_0203CEC4->data; + s16 *arrayPtr = sPartyMenuInternal->data; - arrayPtr[12] = sub_81B3364(); + arrayPtr[12] = CreateLevelUpStatsWindow(); DrawLevelUpWindowPg1(arrayPtr[12], arrayPtr, &arrayPtr[6], 1, 2, 3); CopyWindowToVram(arrayPtr[12], 2); schedule_bg_copy_tilemap_to_vram(2); } -static void sub_81B76C8(u8 taskId) +static void DisplayLevelUpStatsPg2(u8 taskId) { - s16 *arrayPtr = gUnknown_0203CEC4->data; + s16 *arrayPtr = sPartyMenuInternal->data; DrawLevelUpWindowPg2(arrayPtr[12], &arrayPtr[6], 1, 2, 3); CopyWindowToVram(arrayPtr[12], 2); schedule_bg_copy_tilemap_to_vram(2); } -static void sub_81B7704(u8 taskId) +static void Task_TryLearnNewMoves(u8 taskId) { - u16 result; + u16 learnMove; if (WaitFanfare(0) && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) { - sub_81B3394(); - result = MonTryLearningNewMove(&gPlayerParty[gUnknown_0203CEC8.slotId], 1); - gUnknown_0203CEC8.unk10 = 1; - switch (result) + RemoveLevelUpStatsWindow(); + learnMove = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], TRUE); + gPartyMenu.learnMoveState = 1; + switch (learnMove) { - case 0: - sub_81B7810(taskId); + case 0: // No moves to learn + PartyMenuTryEvolution(taskId); break; - case 0xFFFF: - sub_81B787C(taskId); + case MON_HAS_MAX_MOVES: + DisplayMonNeedsToReplaceMove(taskId); break; - case 0xFFFE: - gTasks[taskId].func = sub_81B77AC; + case MON_ALREADY_KNOWS_MOVE: + gTasks[taskId].func = Task_TryLearningNextMove; break; default: - sub_81B7910(taskId, result); + DisplayMonLearnedMove(taskId, learnMove); break; } } } -static void sub_81B77AC(u8 taskId) +static void Task_TryLearningNextMove(u8 taskId) { - u16 result = MonTryLearningNewMove(&gPlayerParty[gUnknown_0203CEC8.slotId], 0); + u16 result = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], FALSE); switch (result) { - case 0: - sub_81B7810(taskId); + case 0: // No moves to learn + PartyMenuTryEvolution(taskId); break; - case 0xFFFF: - sub_81B787C(taskId); + case MON_HAS_MAX_MOVES: + DisplayMonNeedsToReplaceMove(taskId); break; - case 0xFFFE: + case MON_ALREADY_KNOWS_MOVE: return; default: - sub_81B7910(taskId, result); + DisplayMonLearnedMove(taskId, result); break; } } -static void sub_81B7810(u8 taskId) +static void PartyMenuTryEvolution(u8 taskId) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; u16 targetSpecies = GetEvolutionTargetSpecies(mon, 0, 0); if (targetSpecies != SPECIES_NONE) { FreePartyPointers(); - gCB2_AfterEvolution = gUnknown_0203CEC8.exitCallback; - BeginEvolutionScene(mon, targetSpecies, 1, gUnknown_0203CEC8.slotId); + gCB2_AfterEvolution = gPartyMenu.exitCallback; + BeginEvolutionScene(mon, targetSpecies, 1, gPartyMenu.slotId); DestroyTask(taskId); } else { - gTasks[taskId].func = sub_81B6794; + gTasks[taskId].func = Task_ClosePartyMenuAfterText; } } -static void sub_81B787C(u8 taskId) +static void DisplayMonNeedsToReplaceMove(u8 taskId) { - GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.slotId], gStringVar1); + GetMonNickname(&gPlayerParty[gPartyMenu.slotId], gStringVar1); StringCopy(gStringVar2, gMoveNames[gMoveToLearn]); StringExpandPlaceholders(gStringVar4, gText_PkmnNeedsToReplaceMove); - DisplayPartyMenuMessage(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, TRUE); schedule_bg_copy_tilemap_to_vram(2); - gUnknown_0203CEC8.unkE = gMoveToLearn; - gTasks[taskId].func = sub_81B6FF4; + gPartyMenu.data1 = gMoveToLearn; + gTasks[taskId].func = Task_ReplaceMoveYesNo; } -static void sub_81B7910(u8 taskId, u16 move) +static void DisplayMonLearnedMove(u8 taskId, u16 move) { - GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.slotId], gStringVar1); + GetMonNickname(&gPlayerParty[gPartyMenu.slotId], gStringVar1); StringCopy(gStringVar2, gMoveNames[move]); StringExpandPlaceholders(gStringVar4, gText_PkmnLearnedMove3); - DisplayPartyMenuMessage(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, TRUE); schedule_bg_copy_tilemap_to_vram(2); - gUnknown_0203CEC8.unkE = move; - gTasks[taskId].func = sub_81B6F60; + gPartyMenu.data1 = move; + gTasks[taskId].func = Task_DoLearnedMoveFanfareAfterText; } -static void sub_81B79A0(struct Pokemon *mon, s16 *data) +static void BufferMonStatsToTaskData(struct Pokemon *mon, s16 *data) { data[0] = GetMonData(mon, MON_DATA_MAX_HP); data[1] = GetMonData(mon, MON_DATA_ATK); @@ -6162,93 +5067,101 @@ static void sub_81B79A0(struct Pokemon *mon, s16 *data) data[3] = GetMonData(mon, MON_DATA_SPEED); } -void sub_81B79E8(u8 taskId, TaskFunc task) +#define tUsedOnSlot data[0] +#define tHadEffect data[1] +#define tLastSlotUsed data[2] + +void ItemUseCB_SacredAsh(u8 taskId, TaskFunc task) { - gUnknown_0203CEC4->data[0] = 0; - gUnknown_0203CEC4->data[1] = 0; - gUnknown_0203CEC4->data[2] = gUnknown_0203CEC8.slotId; - sub_81B7A28(taskId); + sPartyMenuInternal->tUsedOnSlot = FALSE; + sPartyMenuInternal->tHadEffect = FALSE; + sPartyMenuInternal->tLastSlotUsed = gPartyMenu.slotId; + UseSacredAsh(taskId); } -static void sub_81B7A28(u8 taskId) +static void UseSacredAsh(u8 taskId) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; u16 hp; if (GetMonData(mon, MON_DATA_SPECIES) == SPECIES_NONE) { - gTasks[taskId].func = task_sacred_ash_party_loop; + gTasks[taskId].func = Task_SacredAshLoop; return; } hp = GetMonData(mon, MON_DATA_HP); - if (ExecuteTableBasedItemEffect__(gUnknown_0203CEC8.slotId, gSpecialVar_ItemId, 0)) + if (ExecuteTableBasedItemEffect_(gPartyMenu.slotId, gSpecialVar_ItemId, 0)) { - gTasks[taskId].func = task_sacred_ash_party_loop; + gTasks[taskId].func = Task_SacredAshLoop; return; } PlaySE(SE_KAIFUKU); - party_menu_get_status_condition_and_update_object(mon, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId]); - if (gSprites[gUnknown_0203CEDC[gUnknown_0203CEC8.slotId].statusSpriteId].invisible) - DisplayPartyPokemonLevelCheck(mon, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); - sub_81B0FCC(gUnknown_0203CEC4->data[2], 0); - sub_81B0FCC(gUnknown_0203CEC8.slotId, 1); - sub_81B1F18(taskId, gUnknown_0203CEC8.slotId, 1, GetMonData(mon, MON_DATA_HP) - hp, sub_81B7C10); - sub_81B1FA8(taskId, 0, hp); - gUnknown_0203CEC4->data[0] = 1; - gUnknown_0203CEC4->data[1] = 1; + SetPartyMonAilmentGfx(mon, &sPartyMenuBoxes[gPartyMenu.slotId]); + if (gSprites[sPartyMenuBoxes[gPartyMenu.slotId].statusSpriteId].invisible) + DisplayPartyPokemonLevelCheck(mon, &sPartyMenuBoxes[gPartyMenu.slotId], 1); + AnimatePartySlot(sPartyMenuInternal->tLastSlotUsed, 0); + AnimatePartySlot(gPartyMenu.slotId, 1); + PartyMenuModifyHP(taskId, gPartyMenu.slotId, 1, GetMonData(mon, MON_DATA_HP) - hp, Task_SacredAshDisplayHPRestored); + ResetHPTaskData(taskId, 0, hp); + sPartyMenuInternal->tUsedOnSlot = TRUE; + sPartyMenuInternal->tHadEffect = TRUE; } -static void task_sacred_ash_party_loop(u8 taskId) +static void Task_SacredAshLoop(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - if (gUnknown_0203CEC4->data[0] == 1) + if (sPartyMenuInternal->tUsedOnSlot == TRUE) { - gUnknown_0203CEC4->data[0] = 0; - gUnknown_0203CEC4->data[2] = gUnknown_0203CEC8.slotId; + sPartyMenuInternal->tUsedOnSlot = FALSE; + sPartyMenuInternal->tLastSlotUsed = gPartyMenu.slotId; } - if (++(gUnknown_0203CEC8.slotId) == PARTY_SIZE) + if (++(gPartyMenu.slotId) == PARTY_SIZE) { - if (gUnknown_0203CEC4->data[1] == 0) + if (sPartyMenuInternal->tHadEffect == FALSE) { - gUnknown_0203CEE8 = 0; - DisplayPartyMenuMessage(gText_WontHaveEffect, 1); + gPartyMenuUseExitCallback = FALSE; + DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); schedule_bg_copy_tilemap_to_vram(2); } else { - gUnknown_0203CEE8 = 1; + gPartyMenuUseExitCallback = TRUE; RemoveBagItem(gSpecialVar_ItemId, 1); } - gTasks[taskId].func = sub_81B6794; - gUnknown_0203CEC8.slotId = 0; + gTasks[taskId].func = Task_ClosePartyMenuAfterText; + gPartyMenu.slotId = 0; } else { - sub_81B7A28(taskId); + UseSacredAsh(taskId); } } } -static void sub_81B7C10(u8 taskId) +static void Task_SacredAshDisplayHPRestored(u8 taskId) { - GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.slotId], gStringVar1); + GetMonNickname(&gPlayerParty[gPartyMenu.slotId], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnHPRestoredByVar2); - DisplayPartyMenuMessage(gStringVar4, 0); + DisplayPartyMenuMessage(gStringVar4, FALSE); schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = task_sacred_ash_party_loop; + gTasks[taskId].func = Task_SacredAshLoop; } -void sub_81B7C74(u8 taskId, TaskFunc task) +#undef tUsedOnSlot +#undef tHadEffect +#undef tLastSlotUsed + +void ItemUseCB_EvolutionStone(u8 taskId, TaskFunc task) { PlaySE(SE_SELECT); - gCB2_AfterEvolution = gUnknown_0203CEC8.exitCallback; - if (ExecuteTableBasedItemEffect__(gUnknown_0203CEC8.slotId, gSpecialVar_ItemId, 0)) + gCB2_AfterEvolution = gPartyMenu.exitCallback; + if (ExecuteTableBasedItemEffect_(gPartyMenu.slotId, gSpecialVar_ItemId, 0)) { - gUnknown_0203CEE8 = 0; - DisplayPartyMenuMessage(gText_WontHaveEffect, 1); + gPartyMenuUseExitCallback = FALSE; + DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = task; } @@ -6327,264 +5240,271 @@ u8 GetItemEffectType(u16 item) return ITEM_EFFECT_NONE; } -static void sub_81B7E4C(u8 taskId) +static void TryTutorSelectedMon(u8 taskId) { struct Pokemon *mon; s16 *move; if (!gPaletteFade.active) { - mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; - move = &gUnknown_0203CEC8.unkE; + mon = &gPlayerParty[gPartyMenu.slotId]; + move = &gPartyMenu.data1; GetMonNickname(mon, gStringVar1); - gUnknown_0203CEC8.unkE = GetTutorMove(gSpecialVar_0x8005); - StringCopy(gStringVar2, gMoveNames[gUnknown_0203CEC8.unkE]); + gPartyMenu.data1 = GetTutorMove(gSpecialVar_0x8005); + StringCopy(gStringVar2, gMoveNames[gPartyMenu.data1]); move[1] = 2; switch (CanMonLearnTMTutor(mon, 0, gSpecialVar_0x8005)) { case CANNOT_LEARN_MOVE: - sub_81B6D98(taskId, gText_PkmnCantLearnMove); + DisplayLearnMoveMessageAndClose(taskId, gText_PkmnCantLearnMove); return; case ALREADY_KNOWS_MOVE: - sub_81B6D98(taskId, gText_PkmnAlreadyKnows); + DisplayLearnMoveMessageAndClose(taskId, gText_PkmnAlreadyKnows); return; default: - if (GiveMoveToMon(mon, gUnknown_0203CEC8.unkE) != 0xFFFF) + if (GiveMoveToMon(mon, gPartyMenu.data1) != MON_HAS_MAX_MOVES) { - sub_81B6EB4(taskId); + Task_LearnedMove(taskId); return; } break; } - sub_81B6D74(gText_PkmnNeedsToReplaceMove); - gTasks[taskId].func = sub_81B6FF4; + DisplayLearnMoveMessage(gText_PkmnNeedsToReplaceMove); + gTasks[taskId].func = Task_ReplaceMoveYesNo; } } void CB2_PartyMenuFromStartMenu(void) { - InitPartyMenu(0, 0, 0, 0, 0, sub_81B1370, CB2_ReturnToFieldWithOpenMenu); + InitPartyMenu(PARTY_MENU_TYPE_FIELD, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_MON, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, CB2_ReturnToFieldWithOpenMenu); } -void sub_81B7F60(void) +// Giving an item by selecting Give from the bag menu +// As opposted to by selecting Give in the party menu, which is handled by CursorCb_Give +void CB2_ChooseMonToGiveItem(void) { - MainCallback callback = (InBattlePyramid() == FALSE) ? c2_815ABFC : sub_81C4F84; - InitPartyMenu(0, 0, 5, 0, 6, sub_81B1370, callback); - gUnknown_0203CEC8.unkC = gSpecialVar_ItemId; + MainCallback callback = (InBattlePyramid() == FALSE) ? CB2_ReturnToBagMenu : CB2_ReturnToPyramidBagMenu; + InitPartyMenu(PARTY_MENU_TYPE_FIELD, PARTY_LAYOUT_SINGLE, PARTY_ACTION_GIVE_ITEM, FALSE, PARTY_MSG_GIVE_TO_WHICH_MON, Task_HandleChooseMonInput, callback); + gPartyMenu.bagItem = gSpecialVar_ItemId; } -static void sub_81B7FAC(u8 taskId) +static void TryGiveItemOrMailToSelectedMon(u8 taskId) { - gUnknown_0203CEFC = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_HELD_ITEM); - if (gUnknown_0203CEFC == ITEM_NONE) + sPartyMenuItemId = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_HELD_ITEM); + if (sPartyMenuItemId == ITEM_NONE) { - sub_81B8044(taskId); + GiveItemOrMailToSelectedMon(taskId); } - else if (ItemIsMail(gUnknown_0203CEFC)) + else if (ItemIsMail(sPartyMenuItemId)) { - sub_81B83B8(taskId); + DisplayItemMustBeRemovedFirstMessage(taskId); } else { - sub_81B1D1C(&gPlayerParty[gUnknown_0203CEC8.slotId], gUnknown_0203CEFC, 1); - gTasks[taskId].func = sub_81B82A0; + DisplayAlreadyHoldingItemSwitchMessage(&gPlayerParty[gPartyMenu.slotId], sPartyMenuItemId, TRUE); + gTasks[taskId].func = Task_SwitchItemsFromBagYesNo; } } -static void sub_81B8044(u8 taskId) +static void GiveItemOrMailToSelectedMon(u8 taskId) { - if (ItemIsMail(gUnknown_0203CEC8.unkC)) + if (ItemIsMail(gPartyMenu.bagItem)) { - sub_81B83F0(gUnknown_0203CEC8.unkC); - gUnknown_0203CEC4->exitCallback = sub_81B814C; + RemoveItemToGiveFromBag(gPartyMenu.bagItem); + sPartyMenuInternal->exitCallback = CB2_WriteMailToGiveMonFromBag; Task_ClosePartyMenu(taskId); } else { - sub_81B8088(taskId); + GiveItemToSelectedMon(taskId); } } -static void sub_81B8088(u8 taskId) +static void GiveItemToSelectedMon(u8 taskId) { u16 item; if (!gPaletteFade.active) { - item = gUnknown_0203CEC8.unkC; - sub_81B1C84(&gPlayerParty[gUnknown_0203CEC8.slotId], item, 0, 1); - sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.slotId], item); - sub_81B83F0(item); - gTasks[taskId].func = sub_81B8104; + item = gPartyMenu.bagItem; + DisplayGaveHeldItemMessage(&gPlayerParty[gPartyMenu.slotId], item, FALSE, 1); + GiveItemToMon(&gPlayerParty[gPartyMenu.slotId], item); + RemoveItemToGiveFromBag(item); + gTasks[taskId].func = Task_UpdateHeldItemSpriteAndClosePartyMenu; } } -static void sub_81B8104(u8 taskId) +static void Task_UpdateHeldItemSpriteAndClosePartyMenu(u8 taskId) { - s8 slot = gUnknown_0203CEC8.slotId; + s8 slot = gPartyMenu.slotId; - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - sub_81B5C94(&gPlayerParty[slot], &gUnknown_0203CEDC[slot]); + UpdatePartyMonHeldItemSprite(&gPlayerParty[slot], &sPartyMenuBoxes[slot]); Task_ClosePartyMenu(taskId); } } -static void sub_81B814C(void) +static void CB2_WriteMailToGiveMonFromBag(void) { u8 mail; - sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.slotId], gUnknown_0203CEC8.unkC); - mail = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_MAIL); + GiveItemToMon(&gPlayerParty[gPartyMenu.slotId], gPartyMenu.bagItem); + mail = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_MAIL); DoEasyChatScreen( - EASY_CHAT_TYPE_MAIL, - gSaveBlock1Ptr->mail[mail].words, - sub_81B81A8, - EASY_CHAT_PERSON_DISPLAY_NONE); + EASY_CHAT_TYPE_MAIL, + gSaveBlock1Ptr->mail[mail].words, + CB2_ReturnToPartyOrBagMenuFromWritingMail, + EASY_CHAT_PERSON_DISPLAY_NONE); } -static void sub_81B81A8(void) +static void CB2_ReturnToPartyOrBagMenuFromWritingMail(void) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; u16 item = GetMonData(mon, MON_DATA_HELD_ITEM); + // Canceled writing mail if (gSpecialVar_Result == FALSE) { TakeMailFromMon(mon); - SetMonData(mon, MON_DATA_HELD_ITEM, &gUnknown_0203CEFC); - RemoveBagItem(gUnknown_0203CEFC, 1); - sub_81B841C(item); - SetMainCallback2(gUnknown_0203CEC8.exitCallback); + SetMonData(mon, MON_DATA_HELD_ITEM, &sPartyMenuItemId); + RemoveBagItem(sPartyMenuItemId, 1); + ReturnGiveItemToBagOrPC(item); + SetMainCallback2(gPartyMenu.exitCallback); } + // Wrote mail else { - InitPartyMenu(gUnknown_0203CEC8.unk8_0, 0xFF, gUnknown_0203CEC8.unkB, 1, 0x7F, sub_81B8230, gUnknown_0203CEC8.exitCallback); + InitPartyMenu(gPartyMenu.menuType, KEEP_PARTY_LAYOUT, gPartyMenu.action, TRUE, PARTY_MSG_NONE, Task_DisplayGaveMailFromBagMessage, gPartyMenu.exitCallback); } } -static void sub_81B8230(u8 taskId) +static void Task_DisplayGaveMailFromBagMessage(u8 taskId) { if (!gPaletteFade.active) { - if (gUnknown_0203CEFC != ITEM_NONE) - sub_81B1D68(gUnknown_0203CEC8.unkC, gUnknown_0203CEFC, 0); + if (sPartyMenuItemId != ITEM_NONE) + DisplaySwitchedHeldItemMessage(gPartyMenu.bagItem, sPartyMenuItemId, FALSE); else - sub_81B1C84(&gPlayerParty[gUnknown_0203CEC8.slotId], gUnknown_0203CEC8.unkC, 0, 1); - gTasks[taskId].func = sub_81B8104; + DisplayGaveHeldItemMessage(&gPlayerParty[gPartyMenu.slotId], gPartyMenu.bagItem, FALSE, 1); + gTasks[taskId].func = Task_UpdateHeldItemSpriteAndClosePartyMenu; } } -static void sub_81B82A0(u8 taskId) +static void Task_SwitchItemsFromBagYesNo(u8 taskId) { - if (sub_81B1BD4() != TRUE) + if (IsPartyMenuTextPrinterActive() != TRUE) { - sub_81B334C(); - gTasks[taskId].func = sub_81B82D4; + PartyMenuDisplayYesNoMenu(); + gTasks[taskId].func = Task_HandleSwitchItemsFromBagYesNoInput; } } -static void sub_81B82D4(u8 taskId) +static void Task_HandleSwitchItemsFromBagYesNoInput(u8 taskId) { u16 item; switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - item = gUnknown_0203CEC8.unkC; - sub_81B83F0(item); - if (AddBagItem(gUnknown_0203CEFC, 1) == FALSE) + case 0: // Yes, switch items + item = gPartyMenu.bagItem; + RemoveItemToGiveFromBag(item); + if (AddBagItem(sPartyMenuItemId, 1) == FALSE) { - sub_81B841C(item); - pokemon_item_not_removed(gUnknown_0203CEFC); - DisplayPartyMenuMessage(gStringVar4, 0); - gTasks[taskId].func = sub_81B8104; + ReturnGiveItemToBagOrPC(item); + BufferBagFullCantTakeItemMessage(sPartyMenuItemId); + DisplayPartyMenuMessage(gStringVar4, FALSE); + gTasks[taskId].func = Task_UpdateHeldItemSpriteAndClosePartyMenu; } else if (ItemIsMail(item)) { - gUnknown_0203CEC4->exitCallback = sub_81B814C; + sPartyMenuInternal->exitCallback = CB2_WriteMailToGiveMonFromBag; Task_ClosePartyMenu(taskId); } else { - sub_81B1DB8(&gPlayerParty[gUnknown_0203CEC8.slotId], item); - sub_81B1D68(item, gUnknown_0203CEFC, 1); - gTasks[taskId].func = sub_81B8104; + GiveItemToMon(&gPlayerParty[gPartyMenu.slotId], item); + DisplaySwitchedHeldItemMessage(item, sPartyMenuItemId, TRUE); + gTasks[taskId].func = Task_UpdateHeldItemSpriteAndClosePartyMenu; } break; case MENU_B_PRESSED: PlaySE(SE_SELECT); - case 1: - gTasks[taskId].func = sub_81B8104; + // fallthrough + case 1: // No, dont switch items + gTasks[taskId].func = Task_UpdateHeldItemSpriteAndClosePartyMenu; break; } } -static void sub_81B83B8(u8 taskId) +static void DisplayItemMustBeRemovedFirstMessage(u8 taskId) { - DisplayPartyMenuMessage(gText_RemoveMailBeforeItem, 1); + DisplayPartyMenuMessage(gText_RemoveMailBeforeItem, TRUE); schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = sub_81B8104; + gTasks[taskId].func = Task_UpdateHeldItemSpriteAndClosePartyMenu; } -static void sub_81B83F0(u16 item) +static void RemoveItemToGiveFromBag(u16 item) { - if (gUnknown_0203CEC8.unkB == 6) + if (gPartyMenu.action == PARTY_ACTION_GIVE_PC_ITEM) // Unused, never occurs RemovePCItem(item, 1); else RemoveBagItem(item, 1); } -static bool8 sub_81B841C(u16 item) +// Returns FALSE if there was no space to return the item +// but there always should be, and the return is ignored in all uses +static bool8 ReturnGiveItemToBagOrPC(u16 item) { - if (gUnknown_0203CEC8.unkB == 5) + if (gPartyMenu.action == PARTY_ACTION_GIVE_ITEM) return AddBagItem(item, 1); else return AddPCItem(item, 1); } -void sub_81B8448(void) +void ChooseMonToGiveMailFromMailbox(void) { - InitPartyMenu(0, 0, 7, 0, 6, sub_81B1370, Mailbox_ReturnToMailListAfterDeposit); + InitPartyMenu(PARTY_MENU_TYPE_FIELD, PARTY_LAYOUT_SINGLE, PARTY_ACTION_GIVE_MAILBOX_MAIL, FALSE, PARTY_MSG_GIVE_TO_WHICH_MON, Task_HandleChooseMonInput, Mailbox_ReturnToMailListAfterDeposit); } -static void sub_81B8474(u8 taskId) +static void TryGiveMailToSelectedMon(u8 taskId) { - struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; struct MailStruct *mail; - gUnknown_0203CEE8 = 0; + gPartyMenuUseExitCallback = FALSE; mail = &gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos]; if (GetMonData(mon, MON_DATA_HELD_ITEM) != ITEM_NONE) { - DisplayPartyMenuMessage(gText_PkmnHoldingItemCantHoldMail, 1); + DisplayPartyMenuMessage(gText_PkmnHoldingItemCantHoldMail, TRUE); } else { GiveMailToMon2(mon, mail); ClearMailStruct(mail); - DisplayPartyMenuMessage(gText_MailTransferredFromMailbox, 1); + DisplayPartyMenuMessage(gText_MailTransferredFromMailbox, TRUE); } schedule_bg_copy_tilemap_to_vram(2); - gTasks[taskId].func = sub_81B8104; + gTasks[taskId].func = Task_UpdateHeldItemSpriteAndClosePartyMenu; } void InitChooseHalfPartyForBattle(u8 unused) { - sub_81B8558(); - InitPartyMenu(4, 0, 0, 0, 0, sub_81B1370, gMain.savedCallback); - gUnknown_0203CEC8.unk4 = sub_81B879C; + ClearSelectedPartyOrder(); + InitPartyMenu(PARTY_MENU_TYPE_CHOOSE_HALF, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_MON, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, gMain.savedCallback); + gPartyMenu.task = Task_ValidateChosenHalfParty; } -void sub_81B8558(void) +void ClearSelectedPartyOrder(void) { memset(gSelectedOrderFromParty, 0, sizeof(gSelectedOrderFromParty)); } -static u8 sub_81B856C(s8 slot) +static u8 GetPartySlotEntryStatus(s8 slot) { if (GetBattleEntryEligibility(&gPlayerParty[slot]) == FALSE) return 2; - if (sub_81B8770(slot + 1) == TRUE) + if (HasPartySlotAlreadyBeenSelected(slot + 1) == TRUE) return 1; return 0; } @@ -6595,7 +5515,7 @@ static bool8 GetBattleEntryEligibility(struct Pokemon *mon) u16 species; if (GetMonData(mon, MON_DATA_IS_EGG) - || GetMonData(mon, MON_DATA_LEVEL) > sub_81B8888() + || GetMonData(mon, MON_DATA_LEVEL) > GetBattleEntryLevelCap() || (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(BATTLE_FRONTIER_BATTLE_PYRAMID_LOBBY) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_PYRAMID_LOBBY) && GetMonData(mon, MON_DATA_HELD_ITEM) != ITEM_NONE)) @@ -6603,15 +5523,15 @@ static bool8 GetBattleEntryEligibility(struct Pokemon *mon) return FALSE; } - switch (VarGet(VAR_FRONTIER_FACILITY)) // oddly the specific cases are beyond 6, turns out case 9 is apparently related to link battles + switch (VarGet(VAR_FRONTIER_FACILITY)) { - case 9: + case FACILITY_MULTI_OR_EREADER: if (GetMonData(mon, MON_DATA_HP) != 0) return TRUE; return FALSE; - case 8: + case FACILITY_UNION_ROOM: return TRUE; - default: + default: // Battle Frontier species = GetMonData(mon, MON_DATA_SPECIES); for (; gFrontierBannedSpecies[i] != 0xFFFF; i++) { @@ -6622,49 +5542,49 @@ static bool8 GetBattleEntryEligibility(struct Pokemon *mon) } } -static u8 sub_81B865C(void) +static u8 CheckBattleEntriesAndGetMessage(void) { - u8 unk2; + u8 maxBattlers; u8 i, j; u8 facility; struct Pokemon *party = gPlayerParty; - u8 unk = sub_81B885C(); + u8 minBattlers = GetMinBattleEntries(); u8 *order = gSelectedOrderFromParty; - if (order[unk - 1] == 0) + if (order[minBattlers - 1] == 0) { - if (unk == 1) - return 14; - ConvertIntToDecimalStringN(gStringVar1, unk, STR_CONV_MODE_LEFT_ALIGN, 1); - return 17; + if (minBattlers == 1) + return PARTY_MSG_NO_MON_FOR_BATTLE; + ConvertIntToDecimalStringN(gStringVar1, minBattlers, STR_CONV_MODE_LEFT_ALIGN, 1); + return PARTY_MSG_X_MONS_ARE_NEEDED; } facility = VarGet(VAR_FRONTIER_FACILITY); - if (facility == 8 || facility == 9) + if (facility == FACILITY_UNION_ROOM || facility == FACILITY_MULTI_OR_EREADER) return 0xFF; - unk2 = sub_81B8830(); - for (i = 0; i < unk2 - 1; i++) + maxBattlers = GetMaxBattleEntries(); + for (i = 0; i < maxBattlers - 1; i++) { u16 species = GetMonData(&party[order[i] - 1], MON_DATA_SPECIES); u16 item = GetMonData(&party[order[i] - 1], MON_DATA_HELD_ITEM); - for (j = i + 1; j < unk2; j++) + for (j = i + 1; j < maxBattlers; j++) { if (species == GetMonData(&party[order[j] - 1], MON_DATA_SPECIES)) - return 18; + return PARTY_MSG_MONS_CANT_BE_SAME; if (item != ITEM_NONE && item == GetMonData(&party[order[j] - 1], MON_DATA_HELD_ITEM)) - return 19; + return PARTY_MSG_NO_SAME_HOLD_ITEMS; } } return 0xFF; } -static bool8 sub_81B8770(u8 slot) +static bool8 HasPartySlotAlreadyBeenSelected(u8 slot) { u8 i; - for (i = 0; i < 4; i++) + for (i = 0; i < ARRAY_COUNT(gSelectedOrderFromParty); i++) { if (gSelectedOrderFromParty[i] == slot) return TRUE; @@ -6672,15 +5592,15 @@ static bool8 sub_81B8770(u8 slot) return FALSE; } -static void sub_81B879C(u8 taskId) +static void Task_ValidateChosenHalfParty(u8 taskId) { - u8 msgId = sub_81B865C(); + u8 msgId = CheckBattleEntriesAndGetMessage(); if (msgId != 0xFF) { PlaySE(SE_HAZURE); DisplayPartyMenuStdMessage(msgId); - gTasks[taskId].func = sub_81B87E8; + gTasks[taskId].func = Task_ContinueChoosingHalfParty; } else { @@ -6689,62 +5609,62 @@ static void sub_81B879C(u8 taskId) } } -static void sub_81B87E8(u8 taskId) +static void Task_ContinueChoosingHalfParty(u8 taskId) { if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) { PlaySE(SE_SELECT); - DisplayPartyMenuStdMessage(0); - gTasks[taskId].func = sub_81B1370; + DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); + gTasks[taskId].func = Task_HandleChooseMonInput; } } -static u8 sub_81B8830(void) +static u8 GetMaxBattleEntries(void) { switch (VarGet(VAR_FRONTIER_FACILITY)) { - case 9: + case FACILITY_MULTI_OR_EREADER: return 3; - case 8: + case FACILITY_UNION_ROOM: return 2; - default: + default: // Battle Frontier return gSpecialVar_0x8005; } } -static u8 sub_81B885C(void) +static u8 GetMinBattleEntries(void) { switch (VarGet(VAR_FRONTIER_FACILITY)) { - case 9: + case FACILITY_MULTI_OR_EREADER: return 1; - case 8: + case FACILITY_UNION_ROOM: return 2; - default: + default: // Battle Frontier return gSpecialVar_0x8005; } } -static u8 sub_81B8888(void) +static u8 GetBattleEntryLevelCap(void) { switch (VarGet(VAR_FRONTIER_FACILITY)) { - case 9: - return 100; - case 8: + case FACILITY_MULTI_OR_EREADER: + return MAX_LEVEL; + case FACILITY_UNION_ROOM: return 30; - default: - if (gSpecialVar_0x8004 == 0) + default: // Battle Frontier + if (gSpecialVar_0x8004 == FRONTIER_LVL_50) return 50; - return 100; + return MAX_LEVEL; } } -static const u8* sub_81B88BC(void) +static const u8* GetFacilityCancelString(void) { u8 facilityNum = VarGet(VAR_FRONTIER_FACILITY); - if (!(facilityNum != 8 && facilityNum != 9)) + if (!(facilityNum != FACILITY_UNION_ROOM && facilityNum != FACILITY_MULTI_OR_EREADER)) return gText_CancelBattle; else if (facilityNum == FRONTIER_FACILITY_DOME && gSpecialVar_0x8005 == 2) return gText_ReturnToWaitingRoom; @@ -6752,62 +5672,63 @@ static const u8* sub_81B88BC(void) return gText_CancelChallenge; } -void sub_81B8904(u8 initArg, MainCallback callback) +void ChooseMonForTradingBoard(u8 menuType, MainCallback callback) { - InitPartyMenu(initArg, 0, 0, 0, 0, sub_81B1370, callback); + InitPartyMenu(menuType, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_MON, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, callback); } -void OpenPartyMenuForMoveTutor(void) +void ChooseMonForMoveTutor(void) { - InitPartyMenu(0, 0, 12, 0, 4, sub_81B1370, CB2_ReturnToFieldContinueScriptPlayMapMusic); + InitPartyMenu(PARTY_MENU_TYPE_FIELD, PARTY_LAYOUT_SINGLE, PARTY_ACTION_MOVE_TUTOR, FALSE, PARTY_MSG_TEACH_WHICH_MON, Task_HandleChooseMonInput, CB2_ReturnToFieldContinueScriptPlayMapMusic); } void ChooseMonForWirelessMinigame(void) { - InitPartyMenu(11, 0, 13, 0, 1, sub_81B1370, CB2_ReturnToFieldContinueScriptPlayMapMusic); + InitPartyMenu(PARTY_MENU_TYPE_MINIGAME, PARTY_LAYOUT_SINGLE, PARTY_ACTION_MINIGAME, FALSE, PARTY_MSG_CHOOSE_MON_OR_CANCEL, Task_HandleChooseMonInput, CB2_ReturnToFieldContinueScriptPlayMapMusic); } -static u8 sub_81B8984(void) +static u8 GetPartyLayoutFromBattleType(void) { if (IsDoubleBattle() == FALSE) - return 0; + return PARTY_LAYOUT_SINGLE; if (IsMultiBattle() == TRUE) - return 2; - return 1; + return PARTY_LAYOUT_MULTI; + return PARTY_LAYOUT_DOUBLE; } -void OpenPartyMenuInBattle(u8 arg) +void OpenPartyMenuInBattle(u8 partyAction) { - InitPartyMenu(1, sub_81B8984(), arg, 0, 0, sub_81B1370, SetCB2ToReshowScreenAfterMenu); + InitPartyMenu(PARTY_MENU_TYPE_IN_BATTLE, GetPartyLayoutFromBattleType(), partyAction, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, CB2_SetUpReshowBattleScreenAfterMenu); nullsub_35(); - pokemon_change_order(); + UpdatePartyToBattleOrder(); } -void sub_81B89F0(void) +void ChooseMonForInBattleItem(void) { - InitPartyMenu(1, sub_81B8984(), 3, 0, 5, sub_81B1370, c2_815ABFC); + InitPartyMenu(PARTY_MENU_TYPE_IN_BATTLE, GetPartyLayoutFromBattleType(), PARTY_ACTION_USE_ITEM, FALSE, PARTY_MSG_USE_ON_WHICH_MON, Task_HandleChooseMonInput, CB2_ReturnToBagMenu); nullsub_35(); - pokemon_change_order(); + UpdatePartyToBattleOrder(); } -static u8 sub_81B8A2C(struct Pokemon *mon) +static u8 GetPartyMenuActionsTypeInBattle(struct Pokemon *mon) { if (GetMonData(&gPlayerParty[1], MON_DATA_SPECIES) != SPECIES_NONE && GetMonData(mon, MON_DATA_IS_EGG) == FALSE) { - if (gUnknown_0203CEC8.unkB == 1) - return 3; + if (gPartyMenu.action == PARTY_ACTION_SEND_OUT) + return ACTIONS_SEND_OUT; if (!(gBattleTypeFlags & BATTLE_TYPE_ARENA)) - return 2; + return ACTIONS_SHIFT; } - return 7; + return ACTIONS_SUMMARY_ONLY; } -static bool8 sub_81B8A7C(void) +static bool8 TrySwitchInPokemon(void) { u8 slot = GetCursorSelectionMonId(); u8 newSlot; u8 i; + // In a multi battle, slots 1, 4, and 5 are the partner's pokemon if (IsMultiBattle() == TRUE && (slot == 1 || slot == 4 || slot == 5)) { StringCopy(gStringVar1, GetTrainerPartnerName()); @@ -6822,7 +5743,7 @@ static bool8 sub_81B8A7C(void) } for (i = 0; i < gBattlersCount; i++) { - if (GetBattlerSide(i) == B_SIDE_PLAYER && sub_81B8F38(slot) == gBattlerPartyIndexes[i]) + if (GetBattlerSide(i) == B_SIDE_PLAYER && GetPartyIdFromBattleSlot(slot) == gBattlerPartyIndexes[i]) { GetMonNickname(&gPlayerParty[slot], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnAlreadyInBattle); @@ -6834,67 +5755,69 @@ static bool8 sub_81B8A7C(void) StringExpandPlaceholders(gStringVar4, gText_EggCantBattle); return FALSE; } - if (sub_81B8F38(slot) == gBattleStruct->field_8B) + if (GetPartyIdFromBattleSlot(slot) == gBattleStruct->field_8B) { GetMonNickname(&gPlayerParty[slot], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnAlreadySelected); return FALSE; } - if (gUnknown_0203CEC8.unkB == 4) + if (gPartyMenu.action == PARTY_ACTION_ABILITY_PREVENTS) { SetMonPreventsSwitchingString(); return FALSE; } - if (gUnknown_0203CEC8.unkB == 2) + if (gPartyMenu.action == PARTY_ACTION_CANT_SWITCH) { u8 currBattler = gBattlerInMenuId; - GetMonNickname(&gPlayerParty[pokemon_order_func(gBattlerPartyIndexes[currBattler])], gStringVar1); + GetMonNickname(&gPlayerParty[GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[currBattler])], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnCantSwitchOut); return FALSE; } - gUnknown_0203CEE9 = sub_81B8F38(slot); - gUnknown_0203CEE8 = 1; - newSlot = pokemon_order_func(gBattlerPartyIndexes[gBattlerInMenuId]); - sub_81B8FB0(newSlot, slot); - sub_81B1288(&gPlayerParty[newSlot], &gPlayerParty[slot]); + gSelectedMonPartyId = GetPartyIdFromBattleSlot(slot); + gPartyMenuUseExitCallback = TRUE; + newSlot = GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[gBattlerInMenuId]); + SwitchPartyMonSlots(newSlot, slot); + SwapPartyPokemon(&gPlayerParty[newSlot], &gPlayerParty[slot]); return TRUE; } -void sub_81B8C68(void) +void BufferBattlePartyCurrentOrder(void) { - sub_81B8C88(gUnknown_0203CF00, sub_806D7EC()); + BufferBattlePartyOrder(gBattlePartyCurrentOrder, GetPlayerFlankId()); } -static void sub_81B8C88(u8 *ptr, bool8 multiplayerFlag) +static void BufferBattlePartyOrder(u8 *partyBattleOrder, u8 flankId) { - u8 partyIndexes[6]; + u8 partyIds[PARTY_SIZE]; int i, j; if (IsMultiBattle() == TRUE) { - if (multiplayerFlag) + // Party ids are packed in 4 bits at a time + // i.e. the party id order below would be 0, 3, 5, 4, 2, 1, and the two parties would be 0,5,4 and 3,2,1 + if (flankId != 0) { - ptr[0] = 0 | (3 << 4); - ptr[1] = 5 | (4 << 4); - ptr[2] = 2 | (1 << 4); + partyBattleOrder[0] = 0 | (3 << 4); + partyBattleOrder[1] = 5 | (4 << 4); + partyBattleOrder[2] = 2 | (1 << 4); } else { - ptr[0] = 3 | (0 << 4); - ptr[1] = 2 | (1 << 4); - ptr[2] = 5 | (4 << 4); + partyBattleOrder[0] = 3 | (0 << 4); + partyBattleOrder[1] = 2 | (1 << 4); + partyBattleOrder[2] = 5 | (4 << 4); } return; } else if (IsDoubleBattle() == FALSE) { j = 1; - partyIndexes[0] = gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]; + partyIds[0] = gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]; for (i = 0; i < PARTY_SIZE; i++) { - if (i != partyIndexes[0]) + if (i != partyIds[0]) { - partyIndexes[j] = i; + partyIds[j] = i; j++; } } @@ -6902,29 +5825,30 @@ static void sub_81B8C88(u8 *ptr, bool8 multiplayerFlag) else { j = 2; - partyIndexes[0] = gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]; - partyIndexes[1] = gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT)]; + partyIds[0] = gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]; + partyIds[1] = gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT)]; for (i = 0; i < PARTY_SIZE; i++) { - if (i != partyIndexes[0] && i != partyIndexes[1]) + if (i != partyIds[0] && i != partyIds[1]) { - partyIndexes[j] = i; + partyIds[j] = i; j++; } } } - for (i = 0; i < 3; i++) - ptr[i] = (partyIndexes[0 + (i * 2)] << 4) | partyIndexes[1 + (i * 2)]; + for (i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); i++) + partyBattleOrder[i] = (partyIds[0 + (i * 2)] << 4) | partyIds[1 + (i * 2)]; } -void sub_81B8D64(u8 battlerId, u8 multiplayerFlag) +void BufferBattlePartyCurrentOrderBySide(u8 battlerId, u8 flankId) { - sub_81B8D88(gBattleStruct->field_60[battlerId], multiplayerFlag, battlerId); + BufferBattlePartyOrderBySide(gBattleStruct->field_60[battlerId], flankId, battlerId); } -static void sub_81B8D88(u8 *ptr, bool8 multiplayerFlag, u8 battlerId) +// when GetBattlerSide(battlerId) == B_SIDE_PLAYER, this function is identical the one above +static void BufferBattlePartyOrderBySide(u8 *partyBattleOrder, u8 flankId, u8 battlerId) { - u8 partyIndexes[6]; + u8 partyIndexes[PARTY_SIZE]; int i, j; u8 leftBattler; u8 rightBattler; @@ -6942,17 +5866,17 @@ static void sub_81B8D88(u8 *ptr, bool8 multiplayerFlag, u8 battlerId) if (IsMultiBattle() == TRUE) { - if (multiplayerFlag) + if (flankId != 0) { - ptr[0] = 0 | (3 << 4); - ptr[1] = 5 | (4 << 4); - ptr[2] = 2 | (1 << 4); + partyBattleOrder[0] = 0 | (3 << 4); + partyBattleOrder[1] = 5 | (4 << 4); + partyBattleOrder[2] = 2 | (1 << 4); } else { - ptr[0] = 3 | (0 << 4); - ptr[1] = 2 | (1 << 4); - ptr[2] = 5 | (4 << 4); + partyBattleOrder[0] = 3 | (0 << 4); + partyBattleOrder[1] = 2 | (1 << 4); + partyBattleOrder[2] = 5 | (4 << 4); } return; } @@ -6985,87 +5909,87 @@ static void sub_81B8D88(u8 *ptr, bool8 multiplayerFlag, u8 battlerId) } for (i = 0; i < 3; i++) - ptr[i] = (partyIndexes[0 + (i * 2)] << 4) | partyIndexes[1 + (i * 2)]; + partyBattleOrder[i] = (partyIndexes[0 + (i * 2)] << 4) | partyIndexes[1 + (i * 2)]; } -void sub_81B8E80(u8 battlerId, u8 unk, u8 arrayIndex) +void SwitchPartyOrderLinkMulti(u8 battlerId, u8 slot, u8 slot2) { - u8 possiblePartyIndexes[6]; - u8 unk2 = 0; + u8 partyIds[PARTY_SIZE]; + u8 tempSlot = 0; int i, j; - u8 *battleStructRelated; - u8 possiblePartyIndexBuffer; + u8 *partyBattleOrder; + u8 partyIdBuffer; if (IsMultiBattle()) { - battleStructRelated = gBattleStruct->field_60[battlerId]; + partyBattleOrder = gBattleStruct->field_60[battlerId]; for (i = j = 0; i < 3; j++, i++) { - possiblePartyIndexes[j] = battleStructRelated[i] >> 4; + partyIds[j] = partyBattleOrder[i] >> 4; j++; - possiblePartyIndexes[j] = battleStructRelated[i] & 0xF; + partyIds[j] = partyBattleOrder[i] & 0xF; } - possiblePartyIndexBuffer = possiblePartyIndexes[arrayIndex]; + partyIdBuffer = partyIds[slot2]; for (i = 0; i < PARTY_SIZE; i++) { - if (possiblePartyIndexes[i] == unk) + if (partyIds[i] == slot) { - unk2 = possiblePartyIndexes[i]; - possiblePartyIndexes[i] = possiblePartyIndexBuffer; + tempSlot = partyIds[i]; + partyIds[i] = partyIdBuffer; break; } } if (i != PARTY_SIZE) { - possiblePartyIndexes[arrayIndex] = unk2; - battleStructRelated[0] = (possiblePartyIndexes[0] << 4) | possiblePartyIndexes[1]; - battleStructRelated[1] = (possiblePartyIndexes[2] << 4) | possiblePartyIndexes[3]; - battleStructRelated[2] = (possiblePartyIndexes[4] << 4) | possiblePartyIndexes[5]; + partyIds[slot2] = tempSlot; + partyBattleOrder[0] = (partyIds[0] << 4) | partyIds[1]; + partyBattleOrder[1] = (partyIds[2] << 4) | partyIds[3]; + partyBattleOrder[2] = (partyIds[4] << 4) | partyIds[5]; } } } -static u8 sub_81B8F38(u8 slot) +static u8 GetPartyIdFromBattleSlot(u8 slot) { u8 modResult = slot & 1; u8 retVal; slot /= 2; if (modResult != 0) - retVal = gUnknown_0203CF00[slot] & 0xF; + retVal = gBattlePartyCurrentOrder[slot] & 0xF; else - retVal = gUnknown_0203CF00[slot] >> 4; + retVal = gBattlePartyCurrentOrder[slot] >> 4; return retVal; } -static void sub_81B8F6C(u8 slot, u8 setVal) +static void SetPartyIdAtBattleSlot(u8 slot, u8 setVal) { bool32 modResult = slot & 1; slot /= 2; if (modResult != 0) - gUnknown_0203CF00[slot] = (gUnknown_0203CF00[slot] & 0xF0) | setVal; + gBattlePartyCurrentOrder[slot] = (gBattlePartyCurrentOrder[slot] & 0xF0) | setVal; else - gUnknown_0203CF00[slot] = (gUnknown_0203CF00[slot] & 0xF) | (setVal << 4); + gBattlePartyCurrentOrder[slot] = (gBattlePartyCurrentOrder[slot] & 0xF) | (setVal << 4); } -void sub_81B8FB0(u8 slot, u8 slot2) +void SwitchPartyMonSlots(u8 slot, u8 slot2) { - u8 valBuffer = sub_81B8F38(slot); - sub_81B8F6C(slot, sub_81B8F38(slot2)); - sub_81B8F6C(slot2, valBuffer); + u8 partyId = GetPartyIdFromBattleSlot(slot); + SetPartyIdAtBattleSlot(slot, GetPartyIdFromBattleSlot(slot2)); + SetPartyIdAtBattleSlot(slot2, partyId); } -u8 pokemon_order_func(u8 slot) +u8 GetPartyIdFromBattlePartyId(u8 battlePartyId) { u8 i, j; - for (j = i = 0; i < 3; j++, i++) + for (j = i = 0; i < (int)ARRAY_COUNT(gBattlePartyCurrentOrder); j++, i++) { - if ((gUnknown_0203CF00[i] >> 4) != slot) + if ((gBattlePartyCurrentOrder[i] >> 4) != battlePartyId) { j++; - if ((gUnknown_0203CF00[i] & 0xF) == slot) + if ((gBattlePartyCurrentOrder[i] & 0xF) == battlePartyId) return j; } else @@ -7076,147 +6000,155 @@ u8 pokemon_order_func(u8 slot) return 0; } -static void pokemon_change_order(void) +static void UpdatePartyToBattleOrder(void) { struct Pokemon *partyBuffer = Alloc(sizeof(gPlayerParty)); u8 i; memcpy(partyBuffer, gPlayerParty, sizeof(gPlayerParty)); for (i = 0; i < PARTY_SIZE; i++) - memcpy(&gPlayerParty[pokemon_order_func(i)], &partyBuffer[i], sizeof(struct Pokemon)); + memcpy(&gPlayerParty[GetPartyIdFromBattlePartyId(i)], &partyBuffer[i], sizeof(struct Pokemon)); Free(partyBuffer); } -static void sub_81B9080(void) +static void UpdatePartyToFieldOrder(void) { struct Pokemon *partyBuffer = Alloc(sizeof(gPlayerParty)); u8 i; memcpy(partyBuffer, gPlayerParty, sizeof(gPlayerParty)); for (i = 0; i < PARTY_SIZE; i++) - memcpy(&gPlayerParty[sub_81B8F38(i)], &partyBuffer[i], sizeof(struct Pokemon)); + memcpy(&gPlayerParty[GetPartyIdFromBattleSlot(i)], &partyBuffer[i], sizeof(struct Pokemon)); Free(partyBuffer); } -static void sub_81B90D0(void) +// Unused +static void SwitchAliveMonIntoLeadSlot(void) { u8 i; struct Pokemon *mon; - u8 leadVal; + u8 partyId; for (i = 1; i < PARTY_SIZE; i++) { - mon = &gPlayerParty[sub_81B8F38(i)]; + mon = &gPlayerParty[GetPartyIdFromBattleSlot(i)]; if (GetMonData(mon, MON_DATA_SPECIES) != SPECIES_NONE && GetMonData(mon, MON_DATA_HP) != 0) { - leadVal = sub_81B8F38(0); - sub_81B8FB0(0, i); - sub_81B1288(&gPlayerParty[leadVal], mon); + partyId = GetPartyIdFromBattleSlot(0); + SwitchPartyMonSlots(0, i); + SwapPartyPokemon(&gPlayerParty[partyId], mon); break; } } } -static void sub_81B9140(void) +static void CB2_SetUpExitToBattleScreen(void) { - SetMainCallback2(SetCB2ToReshowScreenAfterMenu); + SetMainCallback2(CB2_SetUpReshowBattleScreenAfterMenu); } -void sub_81B9150(void) +void ShowPartyMenuToShowcaseMultiBattleParty(void) { - InitPartyMenu(5, 3, 0, 0, 0x7F, sub_81B917C, gMain.savedCallback); + InitPartyMenu(PARTY_MENU_TYPE_MULTI_SHOWCASE, PARTY_LAYOUT_MULTI_SHOWCASE, PARTY_ACTION_CHOOSE_MON, FALSE, PARTY_MSG_NONE, Task_InitMultiPartnerPartySlideIn, gMain.savedCallback); } -static void sub_81B917C(u8 taskId) +#define tXPos data[0] + +static void Task_InitMultiPartnerPartySlideIn(u8 taskId) { - gTasks[taskId].data[0] = 256; - sub_81B9294(taskId); + // The first slide step also sets the sprites offscreen + gTasks[taskId].tXPos = 256; + SlideMultiPartyMenuBoxSpritesOneStep(taskId); ChangeBgX(2, 0x10000, 0); - gTasks[taskId].func = sub_81B91B4; + gTasks[taskId].func = Task_MultiPartnerPartySlideIn; } -static void sub_81B91B4(u8 taskId) +static void Task_MultiPartnerPartySlideIn(u8 taskId) { s16 *data = gTasks[taskId].data; u8 i; if (!gPaletteFade.active) { - data[0] -= 8; - sub_81B9294(taskId); - if (data[0] == 0) + tXPos -= 8; + SlideMultiPartyMenuBoxSpritesOneStep(taskId); + if (tXPos == 0) { for (i = 3; i < PARTY_SIZE; i++) { - if (gUnknown_02022FF8[i - 3].species != SPECIES_NONE) - AnimateSelectedPartyIcon(gUnknown_0203CEDC[i].monSpriteId, 0); + if (gMultiPartnerParty[i - MULTI_PARTY_SIZE].species != SPECIES_NONE) + AnimateSelectedPartyIcon(sPartyMenuBoxes[i].monSpriteId, 0); } - PlaySE(SE_W231); // Harden SE? - gTasks[taskId].func = sub_81B9240; + PlaySE(SE_W231); // The Harden SE plays once the partners party mons have slid on screen + gTasks[taskId].func = Task_WaitAfterMultiPartnerPartySlideIn; } } } -static void sub_81B9240(u8 taskId) +static void Task_WaitAfterMultiPartnerPartySlideIn(u8 taskId) { s16 *data = gTasks[taskId].data; - if (++data[0] == 0x100) + // data[0] used as a timer afterwards rather than the x pos + if (++data[0] == 256) Task_ClosePartyMenu(taskId); } -static void sub_81B9270(u8 spriteId, s16 x) +static void MoveMultiPartyMenuBoxSprite(u8 spriteId, s16 x) { if (x >= 0) gSprites[spriteId].pos2.x = x; } -static void sub_81B9294(u8 taskId) +static void SlideMultiPartyMenuBoxSpritesOneStep(u8 taskId) { s16 *data = gTasks[taskId].data; u8 i; for (i = 3; i < PARTY_SIZE; i++) { - if (gUnknown_02022FF8[i - 3].species != SPECIES_NONE) + if (gMultiPartnerParty[i - MULTI_PARTY_SIZE].species != SPECIES_NONE) { - sub_81B9270(gUnknown_0203CEDC[i].monSpriteId, data[0] - 8); - sub_81B9270(gUnknown_0203CEDC[i].itemSpriteId, data[0] - 8); - sub_81B9270(gUnknown_0203CEDC[i].pokeballSpriteId, data[0] - 8); - sub_81B9270(gUnknown_0203CEDC[i].statusSpriteId, data[0] - 8); + MoveMultiPartyMenuBoxSprite(sPartyMenuBoxes[i].monSpriteId, tXPos - 8); + MoveMultiPartyMenuBoxSprite(sPartyMenuBoxes[i].itemSpriteId, tXPos - 8); + MoveMultiPartyMenuBoxSprite(sPartyMenuBoxes[i].pokeballSpriteId, tXPos - 8); + MoveMultiPartyMenuBoxSprite(sPartyMenuBoxes[i].statusSpriteId, tXPos - 8); } } ChangeBgX(2, 0x800, 1); } -void sub_81B9328(void) +#undef tXpos + +void ChooseMonForDaycare(void) { - InitPartyMenu(6, 0, 0, 0, 15, sub_81B1370, sub_81B9390); + InitPartyMenu(PARTY_MENU_TYPE_DAYCARE, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_MON, FALSE, PARTY_MSG_CHOOSE_MON_2, Task_HandleChooseMonInput, BufferMonSelection); } -static void sub_81B9354(u8 arg1) +// Unused +static void ChoosePartyMonByMenuType(u8 menuType) { - gFieldCallback2 = hm_add_c3_without_phase_2; - InitPartyMenu(arg1, 0, 11, 0, 0, sub_81B1370, CB2_ReturnToField); + gFieldCallback2 = CB2_FadeFromPartyMenu; + InitPartyMenu(menuType, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_AND_CLOSE, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, CB2_ReturnToField); } -static void sub_81B9390(void) +static void BufferMonSelection(void) { gSpecialVar_0x8004 = GetCursorSelectionMonId(); if (gSpecialVar_0x8004 >= PARTY_SIZE) gSpecialVar_0x8004 = 0xFF; - gFieldCallback2 = hm_add_c3_without_phase_2; + gFieldCallback2 = CB2_FadeFromPartyMenu; SetMainCallback2(CB2_ReturnToField); } -bool8 hm_add_c3_without_phase_2(void) // might not be bool +bool8 CB2_FadeFromPartyMenu(void) { pal_fill_black(); - CreateTask(task_hm_without_phase_2, 10); + CreateTask(Task_PartyMenuWaitForFade, 10); return TRUE; } -static void task_hm_without_phase_2(u8 taskId) +static void Task_PartyMenuWaitForFade(u8 taskId) { if (IsWeatherNotFadingIn()) { @@ -7226,84 +6158,85 @@ static void task_hm_without_phase_2(u8 taskId) } } -void sub_81B9404(void) +void ChooseContestMon(void) { ScriptContext2_Enable(); FadeScreen(FADE_TO_BLACK, 0); - CreateTask(sub_81B9424, 10); + CreateTask(Task_ChooseContestMon, 10); } -static void sub_81B9424(u8 taskId) +static void Task_ChooseContestMon(u8 taskId) { if (!gPaletteFade.active) { CleanupOverworldWindowsAndTilemaps(); - InitPartyMenu(2, 0, 11, 0, 0, sub_81B1370, sub_81B9470); + InitPartyMenu(PARTY_MENU_TYPE_CONTEST, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_AND_CLOSE, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, CB2_ChooseContestMon); DestroyTask(taskId); } } -static void sub_81B9470(void) +static void CB2_ChooseContestMon(void) { gContestMonPartyIndex = GetCursorSelectionMonId(); if (gContestMonPartyIndex >= PARTY_SIZE) gContestMonPartyIndex = 0xFF; gSpecialVar_0x8004 = gContestMonPartyIndex; - gFieldCallback2 = hm_add_c3_without_phase_2; + gFieldCallback2 = CB2_FadeFromPartyMenu; SetMainCallback2(CB2_ReturnToField); } -void sub_81B94B0(void) +// Used as a script special for showing a party mon to various npcs (e.g. in-game trades, move deleter) +void ChoosePartyMon(void) { ScriptContext2_Enable(); FadeScreen(FADE_TO_BLACK, 0); - CreateTask(sub_81B94D0, 10); + CreateTask(Task_ChoosePartyMon, 10); } -static void sub_81B94D0(u8 taskId) +static void Task_ChoosePartyMon(u8 taskId) { if (!gPaletteFade.active) { CleanupOverworldWindowsAndTilemaps(); - InitPartyMenu(3, 0, 11, 0, 0, sub_81B1370, sub_81B9390); + InitPartyMenu(PARTY_MENU_TYPE_CHOOSE_MON, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_AND_CLOSE, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, BufferMonSelection); DestroyTask(taskId); } } -void sub_81B951C(void) +void ChooseMonForMoveRelearner(void) { ScriptContext2_Enable(); FadeScreen(FADE_TO_BLACK, 0); - CreateTask(sub_81B953C, 10); + CreateTask(Task_ChooseMonForMoveRelearner, 10); } -static void sub_81B953C(u8 taskId) +static void Task_ChooseMonForMoveRelearner(u8 taskId) { if (!gPaletteFade.active) { CleanupOverworldWindowsAndTilemaps(); - InitPartyMenu(7, 0, 11, 0, 0, sub_81B1370, sub_81B9588); + InitPartyMenu(PARTY_MENU_TYPE_MOVE_RELEARNER, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_AND_CLOSE, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, CB2_ChooseMonForMoveRelearner); DestroyTask(taskId); } } -static void sub_81B9588(void) +static void CB2_ChooseMonForMoveRelearner(void) { gSpecialVar_0x8004 = GetCursorSelectionMonId(); if (gSpecialVar_0x8004 >= PARTY_SIZE) gSpecialVar_0x8004 = 0xFF; else gSpecialVar_0x8005 = GetNumberOfRelearnableMoves(&gPlayerParty[gSpecialVar_0x8004]); - gFieldCallback2 = hm_add_c3_without_phase_2; + gFieldCallback2 = CB2_FadeFromPartyMenu; SetMainCallback2(CB2_ReturnToField); } -void sub_81B95E0(void) +void DoBattlePyramidMonsHaveHeldItem(void) { u8 i; gSpecialVar_Result = FALSE; - for (i = 0; i < 3; i++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) != ITEM_NONE) { @@ -7313,42 +6246,44 @@ void sub_81B95E0(void) } } -void sub_81B9620(void) +// Can be called if the Battle Pyramid Bag is full on exiting and at least one party mon still has held items +// The player can then select to toss items from the bag or take/toss held items from the party +void BattlePyramidChooseMonHeldItems(void) { ScriptContext2_Enable(); FadeScreen(FADE_TO_BLACK, 0); - CreateTask(sub_81B9640, 10); + CreateTask(Task_BattlePyramidChooseMonHeldItems, 10); } -static void sub_81B9640(u8 taskId) +static void Task_BattlePyramidChooseMonHeldItems(u8 taskId) { if (!gPaletteFade.active) { CleanupOverworldWindowsAndTilemaps(); - InitPartyMenu(12, 0, 0, 0, 0, sub_81B1370, sub_81B9390); + InitPartyMenu(PARTY_MENU_TYPE_STORE_PYRAMID_HELD_ITEMS, PARTY_LAYOUT_SINGLE, PARTY_ACTION_CHOOSE_MON, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, BufferMonSelection); DestroyTask(taskId); } } -void sub_81B968C(void) +void MoveDeleterChooseMoveToForget(void) { ShowPokemonSummaryScreen(PSS_MODE_SELECT_MOVE, gPlayerParty, gSpecialVar_0x8004, gPlayerPartyCount - 1, CB2_ReturnToField); gFieldCallback = FieldCallback_ReturnToEventScript2; } -void sub_81B96D0(void) +void GetNumMovesSelectedMonHas(void) { u8 i; gSpecialVar_Result = 0; for (i = 0; i < MAX_MON_MOVES; i++) { - if (GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_MOVE1 + i) != ITEM_NONE) + if (GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_MOVE1 + i) != MOVE_NONE) gSpecialVar_Result++; } } -void sub_81B9718(void) +void BufferMoveDeleterNicknameAndMove(void) { struct Pokemon *mon = &gPlayerParty[gSpecialVar_0x8004]; u16 move = GetMonData(mon, MON_DATA_MOVE1 + gSpecialVar_0x8005); @@ -7357,17 +6292,17 @@ void sub_81B9718(void) StringCopy(gStringVar2, gMoveNames[move]); } -void sub_81B9770(void) +void MoveDeleterForgetMove(void) { u16 i; SetMonMoveSlot(&gPlayerParty[gSpecialVar_0x8004], MOVE_NONE, gSpecialVar_0x8005); RemoveMonPPBonus(&gPlayerParty[gSpecialVar_0x8004], gSpecialVar_0x8005); for (i = gSpecialVar_0x8005; i < MAX_MON_MOVES - 1; i++) - sub_81B97DC(&gPlayerParty[gSpecialVar_0x8004], i, i + 1); + ShiftMoveSlot(&gPlayerParty[gSpecialVar_0x8004], i, i + 1); } -static void sub_81B97DC(struct Pokemon *mon, u8 slotTo, u8 slotFrom) +static void ShiftMoveSlot(struct Pokemon *mon, u8 slotTo, u8 slotFrom) { u16 move1 = GetMonData(mon, MON_DATA_MOVE1 + slotTo); u16 move0 = GetMonData(mon, MON_DATA_MOVE1 + slotFrom); @@ -7388,7 +6323,7 @@ static void sub_81B97DC(struct Pokemon *mon, u8 slotTo, u8 slotFrom) SetMonData(mon, MON_DATA_PP_BONUSES, &ppBonuses); } -void sub_81B98DC(void) +void IsSelectedMonEgg(void) { if (GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_IS_EGG)) gSpecialVar_Result = TRUE; @@ -7396,7 +6331,7 @@ void sub_81B98DC(void) gSpecialVar_Result = FALSE; } -void sub_81B9918(void) +void IsLastMonThatKnowsSurf(void) { u16 move; u32 i, j; diff --git a/src/player_pc.c b/src/player_pc.c index dd90bbd8a..94484ab72 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -419,12 +419,12 @@ static void PlayerPC_Decoration(u8 taskId) static void PlayerPC_TurnOff(u8 taskId) { - if (gPcItemMenuOptionsNum == 4) // if the option count is 4, we are at the bedroom PC and not player PC, so do gender specific handling. + if (gPcItemMenuOptionsNum == 4) // if the option count is 4, we are at the bedroom PC, so do gender specific handling. { if (gSaveBlock2Ptr->playerGender == MALE) - ScriptContext1_SetupScript(LittlerootTown_BrendansHouse_2F_EventScript_1F863F); + ScriptContext1_SetupScript(LittlerootTown_BrendansHouse_2F_EventScript_TurnOffPlayerPC); else - ScriptContext1_SetupScript(LittlerootTown_MaysHouse_2F_EventScript_1F958F); + ScriptContext1_SetupScript(LittlerootTown_MaysHouse_2F_EventScript_TurnOffPlayerPC); } else { @@ -824,7 +824,7 @@ static void Mailbox_DoGiveMailPokeMenu(u8 taskId) { sub_81D1EC0(); CleanupOverworldWindowsAndTilemaps(); - sub_81B8448(); + ChooseMonToGiveMailFromMailbox(); DestroyTask(taskId); } } diff --git a/src/pokeblock.c b/src/pokeblock.c index 14e5b6a1f..4c744b537 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -462,7 +462,7 @@ void OpenPokeblockCase(u8 caseId, void (*callback)(void)) void OpenPokeblockCaseInBattle(void) { - OpenPokeblockCase(PBLOCK_CASE_BATTLE, SetCB2ToReshowScreenAfterMenu2); + OpenPokeblockCase(PBLOCK_CASE_BATTLE, CB2_SetUpReshowBattleScreenAfterMenu2); } void OpenPokeblockCaseOnFeeder(void) diff --git a/src/pokedex.c b/src/pokedex.c index 0b04ae3b9..2aa5e30ea 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -140,7 +140,7 @@ void sub_80BB78C(u8); void sub_80BB7D4(u8); void sub_80BBA28(u8); void sub_80BBA78(u8); -void sub_80BBBF4(u8); +void LoadPageOnceMonFinishedMoving(u8); void sub_80BBC74(u8); void sub_80BBD1C(u8); void sub_80BBDE8(u8); @@ -169,7 +169,7 @@ u8 sub_80BDA40(void); u16 GetPokemonSpriteToDisplay(u16); u32 sub_80BDACC(u16, s16, s16); static void CreateInterfaceSprites(u8); -void sub_80BE470(struct Sprite *sprite); +void MoveMonIntoPosition(struct Sprite *sprite); static void SpriteCB_Scrollbar(struct Sprite *sprite); void sub_80BE658(struct Sprite *sprite); void sub_80BE758(struct Sprite *sprite); @@ -177,29 +177,29 @@ void sub_80BE780(struct Sprite *sprite); void sub_80BE44C(struct Sprite *sprite); void sub_80BE834(struct Sprite *sprite); void sub_80BE4E0(struct Sprite *sprite); -u8 sub_80BE91C(struct PokedexListItem*, u8); +u8 SetupInfoScreen(struct PokedexListItem*, u8 monSpriteId); bool8 sub_80BE9C4(u8); u8 sub_80BE9F8(struct PokedexListItem*, u8); -void sub_80BEA24(u8); -void sub_80BEDF4(u8); -void sub_80BEFD0(u8); -void sub_80BF038(u8); -void sub_80BF070(u8); -void sub_80BF0AC(u8); +void LoadInfoScreen(u8); +void ChangePokedexScreen(u8); +void LoadSelectedScreen(u8); +void BeginChangeInfoScreen(u8); +void BeginReturnToPokedex(u8); +void LoadAreaScreen(u8); void sub_80BF1B4(u8); void sub_80BF1EC(u8); -void sub_80BF250(u8); +void LoadCryScreen(u8); void sub_80BF5CC(u8); void sub_80BF790(u8); void sub_80BF7FC(u8); -void sub_80BF82C(u8); +void LoadSizeScreen(u8); void sub_80BFBB0(u8); void sub_80BFC78(u8); void sub_80BFCDC(u16); void sub_80BFCF4(u16); void sub_80BFD0C(u8, u16); void sub_80BFD7C(u8, u16); -void sub_80BFE38(u8); +static void Task_DisplayNewMonData(u8); void sub_80C0088(u8); void blockset_load_palette_to_gpu(u8); void sub_80C01CC(struct Sprite *sprite); @@ -211,8 +211,8 @@ u8 sub_80C0B44(u8, u16, u8, u8); void sub_80C0D30(u8, u16); u16 sub_80C0EF8(u16, s16, s16, s8); u16 sub_80C0E0C(u8, u16, u16, u16); -u8 sub_80C1258(); -void sub_80C12E0(u8); +u8 LoadSearchMenu(void); +void Task_LoadSearchMenu(u8); void sub_80C1570(u8); void sub_80C15B0(u8); void sub_80C16CC(u8); @@ -717,7 +717,7 @@ static const struct SpritePalette sInterfaceSpritePalette[] = static const u8 gUnknown_0855D28C[] = {0x4, 0x8, 0x10, 0x20, 0x20}; static const u8 gUnknown_0855D291[] = {0x8, 0x4, 0x2, 0x1, 0x1}; -static const struct BgTemplate gBgTemplates_0855D298[] = +static const struct BgTemplate sPokedex_BgTemplate[] = { { .bg = 0, @@ -782,7 +782,7 @@ ALIGNED(4) static const u8 gExpandedPlaceholder_PokedexDescription[] = _(""); static const u16 gUnknown_0856E610[] = INCBIN_U16("graphics/pokedex/black.gbapal"); -static const struct BgTemplate gUnknown_0856E630[] = +static const struct BgTemplate sInfoScreen_BgTemplate[] = { { .bg = 0, @@ -822,9 +822,14 @@ static const struct BgTemplate gUnknown_0856E630[] = } }; -static const struct WindowTemplate gUnknown_0856E640[] = +#define WIN_INFO 0 +#define WIN_FOOTPRINT 1 +#define WIN_CRY_WAVE 2 +#define WIN_VU_METER 3 + +static const struct WindowTemplate sInfoScreen_WindowTemplates[] = { - { + { // WIN_INFO .bg = 2, .tilemapLeft = 0, .tilemapTop = 0, @@ -833,7 +838,7 @@ static const struct WindowTemplate gUnknown_0856E640[] = .paletteNum = 0, .baseBlock = 0x0001, }, - { + { // WIN_FOOTPRINT .bg = 2, .tilemapLeft = 25, .tilemapTop = 8, @@ -842,7 +847,7 @@ static const struct WindowTemplate gUnknown_0856E640[] = .paletteNum = 15, .baseBlock = 0x0281, }, - { + { // WIN_CRY_WAVE .bg = 0, .tilemapLeft = 0, .tilemapTop = 12, @@ -851,7 +856,7 @@ static const struct WindowTemplate gUnknown_0856E640[] = .paletteNum = 8, .baseBlock = 0x0285, }, - { + { // WIN_VU_METER .bg = 2, .tilemapLeft = 18, .tilemapTop = 3, @@ -863,7 +868,7 @@ static const struct WindowTemplate gUnknown_0856E640[] = DUMMY_WIN_TEMPLATE }; -static const struct BgTemplate gUnknown_0856E668[] = +static const struct BgTemplate sNewEntryInfoScreen_BgTemplate[] = { { .bg = 2, @@ -885,9 +890,9 @@ static const struct BgTemplate gUnknown_0856E668[] = }, }; -static const struct WindowTemplate gUnknown_0856E670[] = +static const struct WindowTemplate sNewEntryInfoScreen_WindowTemplates[] = { - { + { // WIN_INFO .bg = 2, .tilemapLeft = 0, .tilemapTop = 0, @@ -896,7 +901,7 @@ static const struct WindowTemplate gUnknown_0856E670[] = .paletteNum = 0, .baseBlock = 0x0001, }, - { + { // WIN_FOOTPRINT .bg = 2, .tilemapLeft = 25, .tilemapTop = 8, @@ -1164,7 +1169,7 @@ static const struct UnknownStruct1 gUnknown_0856EFC8[] = {gDexModeOptions, 2, 3, 2}, }; -static const struct BgTemplate gUnknown_0856EFF8[] = +static const struct BgTemplate sSearchMenu_BgTemplate[] = { { .bg = 0, @@ -1204,7 +1209,7 @@ static const struct BgTemplate gUnknown_0856EFF8[] = } }; -static const struct WindowTemplate gUnknown_0856F008[] = +static const struct WindowTemplate sSearchMenu_WindowTemplate[] = { { .bg = 2, @@ -1397,8 +1402,8 @@ void sub_80BB7D4(u8 taskId) { sub_80BD8D0(); BeginNormalPaletteFade(~(1 << (gSprites[sPokedexView->selectedMonSpriteId].oam.paletteNum + 16)), 0, 0, 0x10, RGB_BLACK); - gSprites[sPokedexView->selectedMonSpriteId].callback = sub_80BE470; - gTasks[taskId].func = sub_80BBBF4; + gSprites[sPokedexView->selectedMonSpriteId].callback = MoveMonIntoPosition; + gTasks[taskId].func = LoadPageOnceMonFinishedMoving; PlaySE(SE_PIN); sub_80BC890(); } @@ -1415,7 +1420,7 @@ void sub_80BB7D4(u8 taskId) { PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].data[0] = sub_80C1258(); + gTasks[taskId].data[0] = LoadSearchMenu(); sPokedexView->unk64E = 0; sPokedexView->unk62A = sPokedexView->unk62C; sPokedexView->unk610 = sPokedexView->selectedPokemon; @@ -1508,12 +1513,12 @@ void sub_80BBA78(u8 taskId) } } -void sub_80BBBF4(u8 taskId) +void LoadPageOnceMonFinishedMoving(u8 taskId) { if (gSprites[sPokedexView->selectedMonSpriteId].pos1.x == 48 && gSprites[sPokedexView->selectedMonSpriteId].pos1.y == 56) { sPokedexView->unk64B = sPokedexView->unk64A; - gTasks[taskId].data[0] = sub_80BE91C(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], sPokedexView->selectedMonSpriteId); + gTasks[taskId].data[0] = SetupInfoScreen(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], sPokedexView->selectedMonSpriteId); gTasks[taskId].func = sub_80BBC74; } } @@ -1597,7 +1602,7 @@ void sub_80BBEB8(u8 taskId) sub_80BD8D0(); a = (1 << (gSprites[sPokedexView->selectedMonSpriteId].oam.paletteNum + 16)); - gSprites[sPokedexView->selectedMonSpriteId].callback = sub_80BE470; + gSprites[sPokedexView->selectedMonSpriteId].callback = MoveMonIntoPosition; BeginNormalPaletteFade(~a, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].func = sub_80BC2D4; PlaySE(SE_PIN); @@ -1614,7 +1619,7 @@ void sub_80BBEB8(u8 taskId) else if (gMain.newKeys & SELECT_BUTTON) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].data[0] = sub_80C1258(); + gTasks[taskId].data[0] = LoadSearchMenu(); sPokedexView->unk64E = 0; gTasks[taskId].func = sub_80BBD1C; PlaySE(SE_PC_LOGIN); @@ -1712,7 +1717,7 @@ void sub_80BC2D4(u8 taskId) if (gSprites[sPokedexView->selectedMonSpriteId].pos1.x == 48 && gSprites[sPokedexView->selectedMonSpriteId].pos1.y == 56) { sPokedexView->unk64B = sPokedexView->unk64A; - gTasks[taskId].data[0] = sub_80BE91C(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], sPokedexView->selectedMonSpriteId); + gTasks[taskId].data[0] = SetupInfoScreen(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], sPokedexView->selectedMonSpriteId); sPokedexView->selectedMonSpriteId = -1; gTasks[taskId].func = sub_80BC360; } @@ -1774,7 +1779,7 @@ bool8 sub_80BC514(u8 a) sub_80C09B0(0); SetGpuReg(REG_OFFSET_BG2VOFS, sPokedexView->initialVOffset); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gBgTemplates_0855D298, 4); + InitBgsFromTemplates(0, sPokedex_BgTemplate, 4); SetBgTilemapBuffer(3, AllocZeroed(0x800)); SetBgTilemapBuffer(2, AllocZeroed(0x800)); SetBgTilemapBuffer(1, AllocZeroed(0x800)); @@ -2690,7 +2695,7 @@ void sub_80BE44C(struct Sprite *sprite) } //Move Pokemon into position for description page -void sub_80BE470(struct Sprite *sprite) +void MoveMonIntoPosition(struct Sprite *sprite) { sprite->oam.priority = 0; sprite->oam.affineMode = 0; @@ -2860,25 +2865,27 @@ void sub_80BE8DC(const u8* str, u8 left, u8 top) AddTextPrinterParameterized4(0, 1, left, top, 0, 0, color, -1, str); } -u8 sub_80BE91C(struct PokedexListItem* item, u8 b) +#define tMonSpriteId data[4] + +u8 SetupInfoScreen(struct PokedexListItem* item, u8 monSpriteId) { u8 taskId; sPokedexListItem = item; - taskId = CreateTask(sub_80BEA24, 0); + taskId = CreateTask(LoadInfoScreen, 0); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 1; gTasks[taskId].data[2] = 0; gTasks[taskId].data[3] = 0; - gTasks[taskId].data[4] = b; + gTasks[taskId].tMonSpriteId = monSpriteId; gTasks[taskId].data[5] = 255; ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_0856E630, 4); + InitBgsFromTemplates(0, sInfoScreen_BgTemplate, 4); SetBgTilemapBuffer(3, AllocZeroed(0x800)); SetBgTilemapBuffer(2, AllocZeroed(0x800)); SetBgTilemapBuffer(1, AllocZeroed(0x800)); SetBgTilemapBuffer(0, AllocZeroed(0x800)); - InitWindows(gUnknown_0856E640); + InitWindows(sInfoScreen_WindowTemplates); DeactivateAllTextPrinters(); return taskId; @@ -2886,7 +2893,7 @@ u8 sub_80BE91C(struct PokedexListItem* item, u8 b) bool8 sub_80BE9C4(u8 taskId) { - if (gTasks[taskId].data[0] == 0 && gTasks[taskId].func == sub_80BEDF4) + if (gTasks[taskId].data[0] == 0 && gTasks[taskId].func == ChangePokedexScreen) return FALSE; else return TRUE; @@ -2902,7 +2909,7 @@ u8 sub_80BE9F8(struct PokedexListItem *item, u8 b) return b; } -void sub_80BEA24(u8 taskId) +void LoadInfoScreen(u8 taskId) { switch (gMain.state) { @@ -2956,8 +2963,8 @@ void sub_80BEA24(u8 taskId) case 5: if (gTasks[taskId].data[1] == 0) { - gTasks[taskId].data[4] = (u16)CreateMonSpriteFromNationalDexNumber(sPokedexListItem->dexNum, 48, 56, 0); - gSprites[gTasks[taskId].data[4]].oam.priority = 0; + gTasks[taskId].tMonSpriteId = (u16)CreateMonSpriteFromNationalDexNumber(sPokedexListItem->dexNum, 48, 56, 0); + gSprites[gTasks[taskId].tMonSpriteId].oam.priority = 0; } gMain.state++; break; @@ -2968,7 +2975,7 @@ void sub_80BEA24(u8 taskId) if (gTasks[taskId].data[2] != 0) r3 = 0x14; if (gTasks[taskId].data[1] != 0) - r3 |= (1 << (gSprites[gTasks[taskId].data[4]].oam.paletteNum + 16)); + r3 |= (1 << (gSprites[gTasks[taskId].tMonSpriteId].oam.paletteNum + 16)); BeginNormalPaletteFade(~r3, 0, 16, 0, RGB_BLACK); SetVBlankCallback(gUnknown_030060B4); gMain.state++; @@ -3009,7 +3016,7 @@ void sub_80BEA24(u8 taskId) gTasks[taskId].data[1] = 0; gTasks[taskId].data[2] = 1; gTasks[taskId].data[3] = 1; - gTasks[taskId].func = sub_80BEDF4; + gTasks[taskId].func = ChangePokedexScreen; gMain.state = 0; break; } @@ -3033,19 +3040,19 @@ void sub_80BEDB0(void) Free(r0); } -void sub_80BEDF4(u8 taskId) +void ChangePokedexScreen(u8 taskId) { if (gTasks[taskId].data[0] != 0) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gTasks[taskId].func = sub_80BF038; + gTasks[taskId].func = BeginChangeInfoScreen; PlaySE(SE_Z_SCROLL); return; } if (gMain.newKeys & B_BUTTON) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gTasks[taskId].func = sub_80BF070; + gTasks[taskId].func = BeginReturnToPokedex; PlaySE(SE_PC_OFF); return; } @@ -3056,13 +3063,13 @@ void sub_80BEDF4(u8 taskId) case AREA_SCREEN: BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB_BLACK); sPokedexView->unk64E = 1; - gTasks[taskId].func = sub_80BEFD0; + gTasks[taskId].func = LoadSelectedScreen; PlaySE(SE_PIN); break; case CRY_SCREEN: BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); sPokedexView->unk64E = 2; - gTasks[taskId].func = sub_80BEFD0; + gTasks[taskId].func = LoadSelectedScreen; PlaySE(SE_PIN); break; case SIZE_SCREEN: @@ -3074,13 +3081,13 @@ void sub_80BEDF4(u8 taskId) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); sPokedexView->unk64E = 3; - gTasks[taskId].func = sub_80BEFD0; + gTasks[taskId].func = LoadSelectedScreen; PlaySE(SE_PIN); } break; case CANCEL_SCREEN: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].func = sub_80BF070; + gTasks[taskId].func = BeginReturnToPokedex; PlaySE(SE_PC_OFF); break; } @@ -3106,47 +3113,47 @@ void sub_80BEDF4(u8 taskId) } } -void sub_80BEFD0(u8 taskId) +void LoadSelectedScreen(u8 taskId) { if (!gPaletteFade.active) { - FreeAndDestroyMonPicSprite(gTasks[taskId].data[4]); + FreeAndDestroyMonPicSprite(gTasks[taskId].tMonSpriteId); switch (sPokedexView->unk64E) { case 1: default: - gTasks[taskId].func = sub_80BF0AC; + gTasks[taskId].func = LoadAreaScreen; break; case 2: - gTasks[taskId].func = sub_80BF250; + gTasks[taskId].func = LoadCryScreen; break; case 3: - gTasks[taskId].func = sub_80BF82C; + gTasks[taskId].func = LoadSizeScreen; break; } } } -void sub_80BF038(u8 taskId) +void BeginChangeInfoScreen(u8 taskId) { if (!gPaletteFade.active) { - FreeAndDestroyMonPicSprite(gTasks[taskId].data[4]); - gTasks[taskId].func = sub_80BEA24; + FreeAndDestroyMonPicSprite(gTasks[taskId].tMonSpriteId); + gTasks[taskId].func = LoadInfoScreen; } } -void sub_80BF070(u8 taskId) +void BeginReturnToPokedex(u8 taskId) { if (!gPaletteFade.active) { - FreeAndDestroyMonPicSprite(gTasks[taskId].data[4]); + FreeAndDestroyMonPicSprite(gTasks[taskId].tMonSpriteId); sub_80BEDB0(); DestroyTask(taskId); } } -void sub_80BF0AC(u8 taskId) +void LoadAreaScreen(u8 taskId) { switch (gMain.state) { @@ -3193,16 +3200,16 @@ void sub_80BF1EC(u8 taskId) { case 1: default: - gTasks[taskId].func = sub_80BEA24; + gTasks[taskId].func = LoadInfoScreen; break; case 2: - gTasks[taskId].func = sub_80BF250; + gTasks[taskId].func = LoadCryScreen; break; } } } -void sub_80BF250(u8 taskId) +void LoadCryScreen(u8 taskId) { switch (gMain.state) { @@ -3222,10 +3229,10 @@ void sub_80BF250(u8 taskId) case 1: DecompressAndLoadBgGfxUsingHeap(3, &gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(3, &gPokedexTilemap_CryScreen, 0, 0); - FillWindowPixelBuffer(0, PIXEL_FILL(0)); - PutWindowTilemap(0); - PutWindowTilemap(3); - PutWindowTilemap(2); + FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); + PutWindowTilemap(WIN_INFO); + PutWindowTilemap(WIN_VU_METER); + PutWindowTilemap(WIN_CRY_WAVE); gMain.state++; break; case 2: @@ -3244,8 +3251,8 @@ void sub_80BF250(u8 taskId) gMain.state++; break; case 5: - gTasks[taskId].data[4] = CreateMonSpriteFromNationalDexNumber(sPokedexListItem->dexNum, 48, 56, 0); - gSprites[gTasks[taskId].data[4]].oam.priority = 0; + gTasks[taskId].tMonSpriteId = CreateMonSpriteFromNationalDexNumber(sPokedexListItem->dexNum, 48, 56, 0); + gSprites[gTasks[taskId].tMonSpriteId].oam.priority = 0; gDexCryScreenState = 0; gMain.state++; break; @@ -3274,8 +3281,8 @@ void sub_80BF250(u8 taskId) spC.yPos = 3; if (sub_8145850(&spC, 3) != 0) gMain.state++; - CopyWindowToVram(3, 2); - CopyWindowToVram(0, 3); + CopyWindowToVram(WIN_VU_METER, 2); + CopyWindowToVram(WIN_INFO, 3); CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); @@ -3367,18 +3374,18 @@ void sub_80BF790(u8 taskId) if (!gPaletteFade.active) { sub_8145914(); - FreeAndDestroyMonPicSprite(gTasks[taskId].data[4]); + FreeAndDestroyMonPicSprite(gTasks[taskId].tMonSpriteId); switch (sPokedexView->unk64E) { default: case 1: - gTasks[taskId].func = sub_80BEA24; + gTasks[taskId].func = LoadInfoScreen; break; case 2: - gTasks[taskId].func = sub_80BF0AC; + gTasks[taskId].func = LoadAreaScreen; break; case 3: - gTasks[taskId].func = sub_80BF82C; + gTasks[taskId].func = LoadSizeScreen; break; } } @@ -3395,7 +3402,7 @@ void sub_80BF7FC(u8 a) LoadPalette(&unk, 0x5D, 2); } -void sub_80BF82C(u8 taskId) +void LoadSizeScreen(u8 taskId) { u8 spriteId; @@ -3416,8 +3423,8 @@ void sub_80BF82C(u8 taskId) case 1: DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(3, gPokedexTilemap_SizeScreen, 0, 0); - FillWindowPixelBuffer(0, PIXEL_FILL(0)); - PutWindowTilemap(0); + FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); + PutWindowTilemap(WIN_INFO); gMain.state++; break; case 2: @@ -3459,8 +3466,8 @@ void sub_80BF82C(u8 taskId) gSprites[spriteId].pos2.y = gPokedexEntries[sPokedexListItem->dexNum].pokemonOffset; SetOamMatrix(2, gPokedexEntries[sPokedexListItem->dexNum].pokemonScale, 0, 0, gPokedexEntries[sPokedexListItem->dexNum].pokemonScale); LoadPalette(gUnknown_0856E610, (gSprites[spriteId].oam.paletteNum + 16) * 16, 0x20); - gTasks[taskId].data[4] = spriteId; - CopyWindowToVram(0, 3); + gTasks[taskId].tMonSpriteId = spriteId; + CopyWindowToVram(WIN_INFO, 3); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(3); @@ -3516,16 +3523,16 @@ void sub_80BFC78(u8 taskId) { if (!gPaletteFade.active) { - FreeAndDestroyMonPicSprite(gTasks[taskId].data[4]); + FreeAndDestroyMonPicSprite(gTasks[taskId].tMonSpriteId); FreeAndDestroyTrainerPicSprite(gTasks[taskId].data[5]); switch (sPokedexView->unk64E) { default: case 1: - gTasks[taskId].func = sub_80BEA24; + gTasks[taskId].func = LoadInfoScreen; break; case 2: - gTasks[taskId].func = sub_80BF250; + gTasks[taskId].func = LoadCryScreen; break; } } @@ -3729,7 +3736,7 @@ _080BFDB4:\n\ u8 CreateDexDisplayMonDataTask(u16 dexNum, u32 b, u32 c) { - u8 taskId = CreateTask(sub_80BFE38, 0); + u8 taskId = CreateTask(Task_DisplayNewMonData, 0); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = dexNum; @@ -3740,7 +3747,7 @@ u8 CreateDexDisplayMonDataTask(u16 dexNum, u32 b, u32 c) return taskId; } -void sub_80BFE38(u8 taskId) +static void Task_DisplayNewMonData(u8 taskId) { u8 spriteId; u16 dexNum = gTasks[taskId].data[1]; @@ -3755,10 +3762,10 @@ void sub_80BFE38(u8 taskId) SetVBlankCallback(NULL); sub_80C09B0(0x100); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_0856E668, 2); + InitBgsFromTemplates(0, sNewEntryInfoScreen_BgTemplate, 2); SetBgTilemapBuffer(3, AllocZeroed(0x800)); SetBgTilemapBuffer(2, AllocZeroed(0x800)); - InitWindows(gUnknown_0856E670); + InitWindows(sNewEntryInfoScreen_WindowTemplates); DeactivateAllTextPrinters(); gTasks[taskId].data[0] = 1; } @@ -3766,11 +3773,11 @@ void sub_80BFE38(u8 taskId) case 1: DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(3, gPokedexTilemap_DescriptionScreen, 0, 0); - FillWindowPixelBuffer(0, PIXEL_FILL(0)); - PutWindowTilemap(0); - PutWindowTilemap(1); + FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); + PutWindowTilemap(WIN_INFO); + PutWindowTilemap(WIN_FOOTPRINT); sub_80C0D30(1, gTasks[taskId].data[1]); - CopyWindowToVram(1, 2); + CopyWindowToVram(WIN_FOOTPRINT, 2); ResetPaletteFade(); LoadPokedexBgPalette(0); gTasks[taskId].data[0]++; @@ -3780,7 +3787,7 @@ void sub_80BFE38(u8 taskId) break; case 3: sub_80C020C(dexNum, IsNationalPokedexEnabled(), 1, 1); - CopyWindowToVram(0, 3); + CopyWindowToVram(WIN_INFO, 3); CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(3); gTasks[taskId].data[0]++; @@ -4764,9 +4771,9 @@ int sub_80C0F30(u8 dexMode, u8 sortMode, u8 abcGroup, u8 bodyColor, u8 type1, u8 return resultsCount; } -u8 sub_80C1258(void) +u8 LoadSearchMenu(void) { - return CreateTask(sub_80C12E0, 0); + return CreateTask(Task_LoadSearchMenu, 0); } void sub_80C1270(const u8 *str, u32 left, u32 top) @@ -4784,7 +4791,7 @@ void sub_80C12B0(u32 x, u32 y, u32 width, u32 height) FillWindowPixelRect(0, PIXEL_FILL(0), x, y, width, height); } -void sub_80C12E0(u8 taskId) +void Task_LoadSearchMenu(u8 taskId) { u16 i; @@ -4797,12 +4804,12 @@ void sub_80C12E0(u8 taskId) sPokedexView->unk64A = 2; sub_80C09B0(0); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_0856EFF8, 4); + InitBgsFromTemplates(0, sSearchMenu_BgTemplate, 4); SetBgTilemapBuffer(3, AllocZeroed(0x800)); SetBgTilemapBuffer(2, AllocZeroed(0x800)); SetBgTilemapBuffer(1, AllocZeroed(0x800)); SetBgTilemapBuffer(0, AllocZeroed(0x800)); - InitWindows(gUnknown_0856F008); + InitWindows(sSearchMenu_WindowTemplate); DeactivateAllTextPrinters(); PutWindowTilemap(0); DecompressAndLoadBgGfxUsingHeap(3, gPokedexSearchMenu_Gfx, 0x2000, 0, 0); diff --git a/src/pokemon.c b/src/pokemon.c index c555ca3d7..376f400e6 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -60,6 +60,7 @@ static void EncryptBoxMon(struct BoxPokemon *boxMon); static void DecryptBoxMon(struct BoxPokemon *boxMon); static void sub_806E6CC(u8 taskId); static bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId); +static u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move); // EWRAM vars EWRAM_DATA static u8 sLearningMoveTableID = 0; @@ -2879,22 +2880,22 @@ u16 GiveMoveToMon(struct Pokemon *mon, u16 move) return GiveMoveToBoxMon(&mon->box, move); } -u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move) +static u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move) { s32 i; for (i = 0; i < MAX_MON_MOVES; i++) { u16 existingMove = GetBoxMonData(boxMon, MON_DATA_MOVE1 + i, NULL); - if (!existingMove) + if (existingMove == MOVE_NONE) { SetBoxMonData(boxMon, MON_DATA_MOVE1 + i, &move); SetBoxMonData(boxMon, MON_DATA_PP1 + i, &gBattleMoves[move].pp); return move; } if (existingMove == move) - return -2; + return MON_ALREADY_KNOWS_MOVE; } - return 0xFFFF; + return MON_HAS_MAX_MOVES; } u16 GiveMoveToBattleMon(struct BattlePokemon *mon, u16 move) @@ -2942,14 +2943,14 @@ void GiveBoxMonInitialMoveset(struct BoxPokemon *boxMon) u16 moveLevel; u16 move; - moveLevel = (gLevelUpLearnsets[species][i] & 0xFE00); + moveLevel = (gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_LV); if (moveLevel > (level << 9)) break; - move = (gLevelUpLearnsets[species][i] & 0x1FF); + move = (gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID); - if (GiveMoveToBoxMon(boxMon, move) == 0xFFFF) + if (GiveMoveToBoxMon(boxMon, move) == MON_HAS_MAX_MOVES) DeleteFirstMoveAndGiveMoveToBoxMon(boxMon, move); } } @@ -2968,7 +2969,7 @@ u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove) { sLearningMoveTableID = 0; - while ((gLevelUpLearnsets[species][sLearningMoveTableID] & 0xFE00) != (level << 9)) + while ((gLevelUpLearnsets[species][sLearningMoveTableID] & LEVEL_UP_MOVE_LV) != (level << 9)) { sLearningMoveTableID++; if (gLevelUpLearnsets[species][sLearningMoveTableID] == LEVEL_UP_END) @@ -2976,9 +2977,9 @@ u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove) } } - if ((gLevelUpLearnsets[species][sLearningMoveTableID] & 0xFE00) == (level << 9)) + if ((gLevelUpLearnsets[species][sLearningMoveTableID] & LEVEL_UP_MOVE_LV) == (level << 9)) { - gMoveToLearn = (gLevelUpLearnsets[species][sLearningMoveTableID] & 0x1FF); + gMoveToLearn = (gLevelUpLearnsets[species][sLearningMoveTableID] & LEVEL_UP_MOVE_ID); sLearningMoveTableID++; retVal = GiveMoveToMon(mon, gMoveToLearn); } @@ -3270,7 +3271,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de } // any weather except sun weakens solar beam - if ((gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_HAIL)) && gCurrentMove == MOVE_SOLAR_BEAM) + if ((gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_HAIL_ANY)) && gCurrentMove == MOVE_SOLAR_BEAM) damage /= 2; // sunny @@ -4860,7 +4861,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov if (battlerId != 4) { gAbsentBattlerFlags &= ~gBitTable[battlerId]; - CopyPlayerPartyMonToBattleData(battlerId, pokemon_order_func(gBattlerPartyIndexes[battlerId])); + CopyPlayerPartyMonToBattleData(battlerId, GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[battlerId])); if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER && gBattleResults.numRevivesUsed < 255) gBattleResults.numRevivesUsed++; } @@ -5657,21 +5658,23 @@ void EvolutionRenameMon(struct Pokemon *mon, u16 oldSpecies, u16 newSpecies) SetMonData(mon, MON_DATA_NICKNAME, gSpeciesNames[newSpecies]); } -bool8 sub_806D7EC(void) +// The below two functions determine which side of a multi battle the trainer battles on +// 0 is the left (top in party menu), 1 is right (bottom in party menu) +u8 GetPlayerFlankId(void) { - bool8 retVal = FALSE; + u8 flankId = 0; switch (gLinkPlayers[GetMultiplayerId()].id) { case 0: case 3: - retVal = FALSE; + flankId = 0; break; case 1: case 2: - retVal = TRUE; + flankId = 1; break; } - return retVal; + return flankId; } u16 GetLinkTrainerFlankId(u8 linkPlayerId) @@ -6109,23 +6112,23 @@ u8 GetMoveRelearnerMoves(struct Pokemon *mon, u16 *moves) { u16 moveLevel; - if (gLevelUpLearnsets[species][i] == 0xFFFF) + if (gLevelUpLearnsets[species][i] == LEVEL_UP_END) break; - moveLevel = gLevelUpLearnsets[species][i] & 0xFE00; + moveLevel = gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_LV; if (moveLevel <= (level << 9)) { - for (j = 0; j < MAX_MON_MOVES && learnedMoves[j] != (gLevelUpLearnsets[species][i] & 0x1FF); j++) + for (j = 0; j < MAX_MON_MOVES && learnedMoves[j] != (gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID); j++) ; if (j == MAX_MON_MOVES) { - for (k = 0; k < numMoves && moves[k] != (gLevelUpLearnsets[species][i] & 0x1FF); k++) + for (k = 0; k < numMoves && moves[k] != (gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID); k++) ; if (k == numMoves) - moves[numMoves++] = gLevelUpLearnsets[species][i] & 0x1FF; + moves[numMoves++] = gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID; } } } @@ -6138,8 +6141,8 @@ u8 GetLevelUpMovesBySpecies(u16 species, u16 *moves) u8 numMoves = 0; int i; - for (i = 0; i < 20 && gLevelUpLearnsets[species][i] != 0xFFFF; i++) - moves[numMoves++] = gLevelUpLearnsets[species][i] & 0x1FF; + for (i = 0; i < 20 && gLevelUpLearnsets[species][i] != LEVEL_UP_END; i++) + moves[numMoves++] = gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID; return numMoves; } @@ -6163,23 +6166,23 @@ u8 GetNumberOfRelearnableMoves(struct Pokemon *mon) { u16 moveLevel; - if (gLevelUpLearnsets[species][i] == 0xFFFF) + if (gLevelUpLearnsets[species][i] == LEVEL_UP_END) break; - moveLevel = gLevelUpLearnsets[species][i] & 0xFE00; + moveLevel = gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_LV; if (moveLevel <= (level << 9)) { - for (j = 0; j < MAX_MON_MOVES && learnedMoves[j] != (gLevelUpLearnsets[species][i] & 0x1FF); j++) + for (j = 0; j < MAX_MON_MOVES && learnedMoves[j] != (gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID); j++) ; if (j == MAX_MON_MOVES) { - for (k = 0; k < numMoves && moves[k] != (gLevelUpLearnsets[species][i] & 0x1FF); k++) + for (k = 0; k < numMoves && moves[k] != (gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID); k++) ; if (k == numMoves) - moves[numMoves++] = gLevelUpLearnsets[species][i] & 0x1FF; + moves[numMoves++] = gLevelUpLearnsets[species][i] & LEVEL_UP_MOVE_ID; } } } @@ -6439,11 +6442,11 @@ void SetMonPreventsSwitchingString(void) gBattleTextBuff1[4] = B_BUFF_EOS; if (GetBattlerSide(gBattleStruct->battlerPreventingSwitchout) == B_SIDE_PLAYER) - gBattleTextBuff1[3] = pokemon_order_func(gBattlerPartyIndexes[gBattleStruct->battlerPreventingSwitchout]); + gBattleTextBuff1[3] = GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[gBattleStruct->battlerPreventingSwitchout]); else gBattleTextBuff1[3] = gBattlerPartyIndexes[gBattleStruct->battlerPreventingSwitchout]; - PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff2, gBattlerInMenuId, pokemon_order_func(gBattlerPartyIndexes[gBattlerInMenuId])) + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff2, gBattlerInMenuId, GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[gBattlerInMenuId])) BattleStringExpandPlaceholders(gText_PkmnsXPreventsSwitching, gStringVar4); } diff --git a/src/pokemon_icon.c b/src/pokemon_icon.c index 7d7dadccb..70af9f956 100644 --- a/src/pokemon_icon.c +++ b/src/pokemon_icon.c @@ -1029,13 +1029,13 @@ const u16 sSpriteImageSizes[3][4] = }, }; -u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, u32 personality, bool32 extra) +u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, u32 personality, bool32 handleDeoxys) { u8 spriteId; struct MonIconSpriteTemplate iconTemplate = { .oam = &sMonIconOamData, - .image = GetMonIconPtr(species, personality, extra), + .image = GetMonIconPtr(species, personality, handleDeoxys), .anims = sMonIconAnims, .affineAnims = sMonIconAffineAnims, .callback = callback, @@ -1125,9 +1125,9 @@ u16 sub_80D2E84(u16 species) } } -const u8 *GetMonIconPtr(u16 species, u32 personality, bool32 extra) +const u8 *GetMonIconPtr(u16 species, u32 personality, bool32 handleDeoxys) { - return GetMonIconTiles(GetIconSpecies(species, personality), extra); + return GetMonIconTiles(GetIconSpecies(species, personality), handleDeoxys); } void sub_80D2EF8(struct Sprite *sprite) @@ -1184,17 +1184,17 @@ void FreeMonIconPalette(u16 species) FreeSpritePaletteByTag(gMonIconPaletteTable[palIndex].tag); } -void UpdateTradeMonIconFrame(struct Sprite *sprite) +void SpriteCB_MonIcon(struct Sprite *sprite) { UpdateMonIconFrame(sprite); } -const u8* GetMonIconTiles(u16 species, bool32 extra) +const u8* GetMonIconTiles(u16 species, bool32 handleDeoxys) { const u8* iconSprite = gMonIconTable[species]; - if (species == SPECIES_DEOXYS && extra == TRUE) + if (species == SPECIES_DEOXYS && handleDeoxys == TRUE) { - iconSprite = (const u8*)(0x400 + (u32)iconSprite); //WTF? + iconSprite = (const u8*)(0x400 + (u32)iconSprite); // use the specific Deoxys form icon (Speed in this case) } return iconSprite; } diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 1190b73d5..41c48d008 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -42,6 +42,7 @@ #include "window.h" #include "constants/items.h" #include "constants/moves.h" +#include "constants/party_menu.h" #include "constants/region_map_sections.h" #include "constants/rgb.h" #include "constants/songs.h" @@ -162,7 +163,7 @@ static EWRAM_DATA struct PokemonSummaryScreenData u8 unk_filler4[6]; } *sMonSummaryScreen = NULL; EWRAM_DATA u8 gLastViewedMonIndex = 0; -static EWRAM_DATA u8 sUnknown_0203CF21 = 0; +static EWRAM_DATA u8 sMoveSlotToReplace = 0; ALIGNED(4) static EWRAM_DATA u8 sUnknownTaskId = 0; struct UnkStruct_61CC04 @@ -1491,11 +1492,11 @@ static void HandleInput(u8 taskId) { ChangeSummaryPokemon(taskId, 1); } - else if ((gMain.newKeys & DPAD_LEFT) || GetLRKeysState() == 1) + else if ((gMain.newKeys & DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED) { ChangePage(taskId, -1); } - else if ((gMain.newKeys & DPAD_RIGHT) || GetLRKeysState() == 2) + else if ((gMain.newKeys & DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED) { ChangePage(taskId, 1); } @@ -2159,11 +2160,11 @@ static void HandleReplaceMoveInput(u8 taskId) data[0] = 4; sub_81C1070(data, 1, &sMonSummaryScreen->firstMoveIndex); } - else if (gMain.newKeys & DPAD_LEFT || GetLRKeysState() == 1) + else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) { ChangePage(taskId, -1); } - else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysState() == 2) + else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) { ChangePage(taskId, 1); } @@ -2173,8 +2174,8 @@ static void HandleReplaceMoveInput(u8 taskId) { StopPokemonAnimations(); PlaySE(SE_SELECT); - sUnknown_0203CF21 = sMonSummaryScreen->firstMoveIndex; - gSpecialVar_0x8005 = sUnknown_0203CF21; + sMoveSlotToReplace = sMonSummaryScreen->firstMoveIndex; + gSpecialVar_0x8005 = sMoveSlotToReplace; BeginCloseSummaryScreen(taskId); } else @@ -2188,8 +2189,8 @@ static void HandleReplaceMoveInput(u8 taskId) u32 var1; StopPokemonAnimations(); PlaySE(SE_SELECT); - sUnknown_0203CF21 = 4; - gSpecialVar_0x8005 = 4; + sMoveSlotToReplace = MAX_MON_MOVES; + gSpecialVar_0x8005 = MAX_MON_MOVES; BeginCloseSummaryScreen(taskId); } } @@ -2238,7 +2239,7 @@ static void HandleHMMovesCantBeForgottenInput(u8 taskId) data[1] = 0; gTasks[taskId].func = HandleReplaceMoveInput; } - else if (gMain.newKeys & DPAD_LEFT || GetLRKeysState() == 1) + else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) { if (sMonSummaryScreen->currPageIndex != 2) { @@ -2252,7 +2253,7 @@ static void HandleHMMovesCantBeForgottenInput(u8 taskId) sub_81C1EFC(9, -2, move); } } - else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysState() == 2) + else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) { if (sMonSummaryScreen->currPageIndex != 3) { @@ -2281,9 +2282,9 @@ static void HandleHMMovesCantBeForgottenInput(u8 taskId) } } -u8 sub_81C1B94(void) +u8 GetMoveSlotToReplace(void) { - return sUnknown_0203CF21; + return sMoveSlotToReplace; } static void DrawPagination(void) // Updates the pagination dots at the top of the summary screen @@ -2574,9 +2575,9 @@ static void DrawPokerusCuredSymbol(struct Pokemon *mon) // This checks if the mo static void SetDexNumberColor(bool8 isMonShiny) { if (!isMonShiny) - sub_8199C30(3, 1, 4, 8, 8, 0); + SetBgTilemapPalette(3, 1, 4, 8, 8, 0); else - sub_8199C30(3, 1, 4, 8, 8, 5); + SetBgTilemapPalette(3, 1, 4, 8, 8, 5); schedule_bg_copy_tilemap_to_vram(3); } diff --git a/src/pokenav.c b/src/pokenav.c index 2a1647a6f..9f12380df 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -48,8 +48,8 @@ static void VBlankCB_Pokenav(void); static void CB2_Pokenav(void); static void Task_RunLoopedTask_LinkMode(u8 a0); static void Task_RunLoopedTask(u8 taskId); -static void sub_81C742C(u8 taskId); -static void sub_81C72BC(void); +static void Task_Pokenav(u8 taskId); +static void CB2_InitPokenavForTutorial(void); const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] = { @@ -311,19 +311,19 @@ void CB2_InitPokeNav(void) InitPokenavResources(gPokenavResources); ResetTasks(); SetVBlankCallback(NULL); - CreateTask(sub_81C742C, 0); + CreateTask(Task_Pokenav, 0); SetMainCallback2(CB2_Pokenav); SetVBlankCallback(VBlankCB_Pokenav); } } -void sub_81C72A4(void) +void OpenPokenavForTutorial(void) { - SetMainCallback2(sub_81C72BC); + SetMainCallback2(CB2_InitPokenavForTutorial); FadeScreen(1, 0); } -static void sub_81C72BC(void) +static void CB2_InitPokenavForTutorial(void) { UpdatePaletteFade(); if (gPaletteFade.active) @@ -342,7 +342,7 @@ static void sub_81C72BC(void) ResetSpriteData(); FreeAllSpritePalettes(); SetVBlankCallback(NULL); - CreateTask(sub_81C742C, 0); + CreateTask(Task_Pokenav, 0); SetMainCallback2(CB2_Pokenav); SetVBlankCallback(VBlankCB_Pokenav); } @@ -416,7 +416,7 @@ static void VBlankCB_Pokenav(void) ProcessSpriteCopyRequests(); } -static void sub_81C742C(u8 taskId) +static void Task_Pokenav(u8 taskId) { u32 v1; s16 *data = gTasks[taskId].data; diff --git a/src/post_battle_event_funcs.c b/src/post_battle_event_funcs.c index 41ad37fbf..4fa5d1b21 100644 --- a/src/post_battle_event_funcs.c +++ b/src/post_battle_event_funcs.c @@ -9,6 +9,7 @@ #include "tv.h" #include "constants/heal_locations.h" #include "constants/flags.h" +#include "constants/tv.h" int GameClear(void) { @@ -76,9 +77,9 @@ int GameClear(void) } } - if (ribbonCounts[0].count > 4) + if (ribbonCounts[0].count > NUM_CUTIES_RIBBONS) { - sub_80EE4DC(&gPlayerParty[ribbonCounts[0].partyIndex], MON_DATA_CHAMPION_RIBBON); + TryPutSpotTheCutiesOnAir(&gPlayerParty[ribbonCounts[0].partyIndex], MON_DATA_CHAMPION_RIBBON); } } diff --git a/src/record_mixing.c b/src/record_mixing.c index 8df0a8a8b..4ad47cc21 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -69,7 +69,7 @@ struct PlayerRecordsEmerald /* 0x1124 */ struct EmeraldBattleTowerRecord battleTowerRecord; /* 0x1210 */ u16 giftItem; /* 0x1214 */ LilycoveLady lilycoveLady; - /* 0x1254 */ struct Apprentice apprentice[2]; + /* 0x1254 */ struct Apprentice apprentices[2]; /* 0x12dc */ struct PlayerHallRecords hallRecords; /* 0x1434 */ u8 field_1434[0x10]; }; // 0x1444 @@ -120,8 +120,8 @@ static void sub_80E7B2C(const u8 *); static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *, size_t, u8, TVShow *); static void ReceiveGiftItem(u16 *item, u8 which); static void Task_DoRecordMixing(u8 taskId); -static void sub_80E8110(struct Apprentice *arg0, struct Apprentice *arg1); -static void ReceiveApprenticeData(struct Apprentice *arg0, size_t arg1, u32 arg2); +static void GetSavedApprentices(struct Apprentice *dst, struct Apprentice *src); +static void ReceiveApprenticeData(struct Apprentice *mixApprentice, size_t recordSize, u32 multiplayerId); static void ReceiveRankingHallRecords(struct PlayerHallRecords *hallRecords, size_t arg1, u32 arg2); static void sub_80E89F8(struct RecordMixingDayCareMail *dst); static void SanitizeDayCareMailForRuby(struct RecordMixingDayCareMail *src); @@ -252,7 +252,7 @@ static void PrepareExchangePacket(void) if (GetMultiplayerId() == 0) sSentRecord->emerald.giftItem = GetRecordMixingGift(); - sub_80E8110(sSentRecord->emerald.apprentice, sApprenticesSave); + GetSavedApprentices(sSentRecord->emerald.apprentices, sApprenticesSave); GetPlayerHallRecords(&sSentRecord->emerald.hallRecords); } } @@ -285,7 +285,7 @@ static void ReceiveExchangePacket(u32 which) ReceiveBattleTowerData(&sReceivedRecords->emerald.battleTowerRecord, sizeof(struct PlayerRecordsEmerald), which); ReceiveGiftItem(&sReceivedRecords->emerald.giftItem, which); ReceiveLilycoveLadyData(&sReceivedRecords->emerald.lilycoveLady, sizeof(struct PlayerRecordsEmerald), which); - ReceiveApprenticeData(sReceivedRecords->emerald.apprentice, sizeof(struct PlayerRecordsEmerald), (u8) which); + ReceiveApprenticeData(sReceivedRecords->emerald.apprentices, sizeof(struct PlayerRecordsEmerald), (u8) which); ReceiveRankingHallRecords(&sReceivedRecords->emerald.hallRecords, sizeof(struct PlayerRecordsEmerald), (u8) which); } } @@ -631,7 +631,7 @@ static void ReceiveOldManData(OldMan *oldMan, size_t recordSize, u8 which) u8 version; u16 language; OldMan *dest; - u32 mixIndices[4]; + u32 mixIndices[MAX_LINK_PLAYERS]; ShufflePlayerIndices(mixIndices); dest = (void *)oldMan + recordSize * mixIndices[which]; @@ -651,7 +651,7 @@ static void ReceiveBattleTowerData(void *battleTowerRecord, size_t recordSize, u { struct EmeraldBattleTowerRecord *dest; struct BattleTowerPokemon *btPokemon; - u32 mixIndices[4]; + u32 mixIndices[MAX_LINK_PLAYERS]; s32 i; ShufflePlayerIndices(mixIndices); @@ -682,7 +682,7 @@ static void ReceiveBattleTowerData(void *battleTowerRecord, size_t recordSize, u static void ReceiveLilycoveLadyData(LilycoveLady *lilycoveLady, size_t recordSize, u8 which) { LilycoveLady *dest; - u32 mixIndices[4]; + u32 mixIndices[MAX_LINK_PLAYERS]; ShufflePlayerIndices(mixIndices); memcpy((void *)lilycoveLady + recordSize * which, sLilycoveLadySave, sizeof(LilycoveLady)); @@ -1018,57 +1018,59 @@ static void Task_DoRecordMixing(u8 taskId) // New Emerald functions -static void sub_80E8110(struct Apprentice *dst, struct Apprentice *src) +static void GetSavedApprentices(struct Apprentice *dst, struct Apprentice *src) { s32 i, id; - s32 var_2C, var_28, var_24, r8; + s32 apprenticeSaveId, oldPlayerApprenticeSaveId; + s32 numOldPlayerApprentices, numMixApprentices; dst[0].playerName[0] = EOS; dst[1].playerName[0] = EOS; dst[0] = src[0]; - var_28 = 0; - var_24 = 0; - var_2C = 0; - r8 = 0; + oldPlayerApprenticeSaveId = 0; + numOldPlayerApprentices = 0; + apprenticeSaveId = 0; + numMixApprentices = 0; for (i = 0; i < 2; i++) { - id = ((i + gSaveBlock2Ptr->playerApprentice.field_B2_1) % 3) + 1; + id = ((i + gSaveBlock2Ptr->playerApprentice.saveId) % (APPRENTICE_COUNT - 1)) + 1; if (src[id].playerName[0] != EOS) { if (GetTrainerId(src[id].playerId) != GetTrainerId(gSaveBlock2Ptr->playerTrainerId)) { - r8++; - var_2C = id; + numMixApprentices++; + apprenticeSaveId = id; } if (GetTrainerId(src[id].playerId) == GetTrainerId(gSaveBlock2Ptr->playerTrainerId)) { - var_24++; - var_28 = id; + numOldPlayerApprentices++; + oldPlayerApprenticeSaveId = id; } } } - if (r8 == 0 && var_24 != 0) + // Prefer passing on other mixed Apprentices rather than old player's Apprentices + if (numMixApprentices == 0 && numOldPlayerApprentices != 0) { - r8 = var_24; - var_2C = var_28; + numMixApprentices = numOldPlayerApprentices; + apprenticeSaveId = oldPlayerApprenticeSaveId; } - switch (r8) + switch (numMixApprentices) { case 1: - dst[1] = src[var_2C]; + dst[1] = src[apprenticeSaveId]; break; case 2: if (Random2() > 0x3333) { - dst[1] = src[gSaveBlock2Ptr->playerApprentice.field_B2_1 + 1]; + dst[1] = src[gSaveBlock2Ptr->playerApprentice.saveId + 1]; } else { - dst[1] = src[((gSaveBlock2Ptr->playerApprentice.field_B2_1 + 1) % 3 + 1)]; + dst[1] = src[((gSaveBlock2Ptr->playerApprentice.saveId + 1) % (APPRENTICE_COUNT - 1) + 1)]; } break; } @@ -1113,14 +1115,14 @@ void GetPlayerHallRecords(struct PlayerHallRecords *dst) } } -static bool32 sub_80E841C(struct Apprentice *arg0, struct Apprentice *arg1) +static bool32 IsApprenticeAlreadySaved(struct Apprentice *mixApprentice, struct Apprentice *apprentices) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < APPRENTICE_COUNT; i++) { - if (GetTrainerId(arg0->playerId) == GetTrainerId(arg1[i].playerId) - && arg0->number == arg1[i].number) + if (GetTrainerId(mixApprentice->playerId) == GetTrainerId(apprentices[i].playerId) + && mixApprentice->number == apprentices[i].number) { return TRUE; } @@ -1129,40 +1131,40 @@ static bool32 sub_80E841C(struct Apprentice *arg0, struct Apprentice *arg1) return FALSE; } -static void ReceiveApprenticeData(struct Apprentice *arg0, size_t arg1, u32 arg2) +static void ReceiveApprenticeData(struct Apprentice *mixApprentice, size_t recordSize, u32 multiplayerId) { - s32 i, r7, r8; - struct Apprentice *structPtr; - u32 mixIndices[4]; - u32 structId; + s32 i, numApprentices, apprenticeId; + struct Apprentice *mixApprenticePtr; + u32 mixIndices[MAX_LINK_PLAYERS]; + u32 apprenticeSaveId; ShufflePlayerIndices(mixIndices); - structPtr = (void*)(arg0) + (arg1 * mixIndices[arg2]); - r7 = 0; - r8 = 0; + mixApprenticePtr = (void*)(mixApprentice) + (recordSize * mixIndices[multiplayerId]); + numApprentices = 0; + apprenticeId = 0; for (i = 0; i < 2; i++) { - if (structPtr[i].playerName[0] != EOS && !sub_80E841C(&structPtr[i], &gSaveBlock2Ptr->apprentices[0])) + if (mixApprenticePtr[i].playerName[0] != EOS && !IsApprenticeAlreadySaved(&mixApprenticePtr[i], &gSaveBlock2Ptr->apprentices[0])) { - r7++; - r8 = i; + numApprentices++; + apprenticeId = i; } } - switch (r7) + switch (numApprentices) { case 1: - structId = gSaveBlock2Ptr->playerApprentice.field_B2_1 + 1; - gSaveBlock2Ptr->apprentices[structId] = structPtr[r8]; - gSaveBlock2Ptr->playerApprentice.field_B2_1 = (gSaveBlock2Ptr->playerApprentice.field_B2_1 + 1) % 3; + apprenticeSaveId = gSaveBlock2Ptr->playerApprentice.saveId + 1; + gSaveBlock2Ptr->apprentices[apprenticeSaveId] = mixApprenticePtr[apprenticeId]; + gSaveBlock2Ptr->playerApprentice.saveId = (gSaveBlock2Ptr->playerApprentice.saveId + 1) % (APPRENTICE_COUNT - 1); break; case 2: for (i = 0; i < 2; i++) { - structId = ((i ^ 1) + gSaveBlock2Ptr->playerApprentice.field_B2_1) % 3 + 1; - gSaveBlock2Ptr->apprentices[structId] = structPtr[i]; + apprenticeSaveId = ((i ^ 1) + gSaveBlock2Ptr->playerApprentice.saveId) % (APPRENTICE_COUNT - 1) + 1; + gSaveBlock2Ptr->apprentices[apprenticeSaveId] = mixApprenticePtr[i]; } - gSaveBlock2Ptr->playerApprentice.field_B2_1 = (gSaveBlock2Ptr->playerApprentice.field_B2_1 + 2) % 3; + gSaveBlock2Ptr->playerApprentice.saveId = (gSaveBlock2Ptr->playerApprentice.saveId + 2) % (APPRENTICE_COUNT - 1); break; } } diff --git a/src/recorded_battle.c b/src/recorded_battle.c index bd1974d48..bde2b7bb6 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -409,12 +409,12 @@ bool32 MoveRecordedBattleToSaveData(void) if (sBattleOutcome == B_OUTCOME_WON) { - for (i = 0; i < 6; i++) + for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++) battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_FRIEND].speechLost[i]; } else { - for (i = 0; i < 6; i++) + for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++) battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_FRIEND].speechWon[i]; } battleSave->recordMixFriendLanguage = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_FRIEND].language; @@ -427,12 +427,12 @@ bool32 MoveRecordedBattleToSaveData(void) if (sBattleOutcome == B_OUTCOME_WON) { - for (i = 0; i < 6; i++) + for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++) battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_FRIEND].speechLost[i]; } else { - for (i = 0; i < 6; i++) + for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++) battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_FRIEND].speechWon[i]; } battleSave->recordMixFriendLanguage = gSaveBlock2Ptr->frontier.towerRecords[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_FRIEND].language; @@ -449,15 +449,15 @@ bool32 MoveRecordedBattleToSaveData(void) if (gTrainerBattleOpponent_A >= TRAINER_RECORD_MIXING_APPRENTICE) { battleSave->apprenticeId = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_APPRENTICE].id; - for (i = 0; i < 6; i++) - battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_APPRENTICE].easyChatWords[i]; + for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++) + battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_APPRENTICE].speechWon[i]; battleSave->apprenticeLanguage = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_A - TRAINER_RECORD_MIXING_APPRENTICE].language; } else if (gTrainerBattleOpponent_B >= TRAINER_RECORD_MIXING_APPRENTICE) { battleSave->apprenticeId = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_APPRENTICE].id; - for (i = 0; i < 6; i++) - battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_APPRENTICE].easyChatWords[i]; + for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++) + battleSave->easyChatSpeech[i] = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_APPRENTICE].speechWon[i]; battleSave->apprenticeLanguage = gSaveBlock2Ptr->apprentices[gTrainerBattleOpponent_B - TRAINER_RECORD_MIXING_APPRENTICE].language; } else if (gPartnerTrainerId >= TRAINER_RECORD_MIXING_APPRENTICE) diff --git a/src/region_map.c b/src/region_map.c index 3bb532a19..b6133ee0d 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -55,7 +55,7 @@ static EWRAM_DATA struct { /*0x008*/ struct RegionMap regionMap; /*0x88c*/ u8 unk_88c[0x1c0]; /*0xa4c*/ u8 unk_a4c[0x26]; - /*0xa72*/ bool8 unk_a72; + /*0xa72*/ bool8 choseFlyLocation; } *sFlyMap = NULL; // a74 static bool32 gUnknown_03001180; @@ -1605,7 +1605,8 @@ u8 *GetMapName(u8 *dest, u16 regionMapId, u16 padLength) return str; } -u8 *sub_81245DC(u8 *dest, u16 mapSecId) +// TODO: probably needs a better name +u8 *GetMapNameGeneric(u8 *dest, u16 mapSecId) { switch (mapSecId) { @@ -1626,7 +1627,7 @@ u8 *sub_8124610(u8 *dest, u16 mapSecId) } else { - return sub_81245DC(dest, mapSecId); + return GetMapNameGeneric(dest, mapSecId); } } @@ -1972,13 +1973,13 @@ static void sub_8124D64(void) if (sFlyMap->regionMap.iconDrawType == MAPSECTYPE_CITY_CANFLY || sFlyMap->regionMap.iconDrawType == MAPSECTYPE_BATTLE_FRONTIER) { m4aSongNumStart(SE_SELECT); - sFlyMap->unk_a72 = TRUE; + sFlyMap->choseFlyLocation = TRUE; sub_81248F4(sub_8124E0C); } break; case INPUT_EVENT_B_BUTTON: m4aSongNumStart(SE_SELECT); - sFlyMap->unk_a72 = FALSE; + sFlyMap->choseFlyLocation = FALSE; sub_81248F4(sub_8124E0C); break; } @@ -1997,7 +1998,7 @@ static void sub_8124E0C(void) if (!UpdatePaletteFade()) { FreeRegionMapIconResources(); - if (sFlyMap->unk_a72) + if (sFlyMap->choseFlyLocation) { switch (sFlyMap->regionMap.mapSecId) { @@ -2024,11 +2025,11 @@ static void sub_8124E0C(void) } break; } - sub_80B69DC(); + ReturnToFieldFromFlyMapSelect(); } else { - SetMainCallback2(sub_81B58A8); + SetMainCallback2(CB2_ReturnToPartyMenuFromFlyMap); } if (sFlyMap != NULL) { diff --git a/src/save_location.c b/src/save_location.c index 2443b3161..6bf5eceb0 100644 --- a/src/save_location.c +++ b/src/save_location.c @@ -52,10 +52,10 @@ static const u16 sSaveLocationPokeCenterList[] = MAP_EVER_GRANDE_CITY_POKEMON_LEAGUE_2F, MAP_BATTLE_FRONTIER_POKEMON_CENTER_1F, MAP_BATTLE_FRONTIER_POKEMON_CENTER_2F, - MAP_SINGLE_BATTLE_COLOSSEUM, + MAP_BATTLE_COLOSSEUM_2P, MAP_TRADE_CENTER, MAP_RECORD_CORNER, - MAP_DOUBLE_BATTLE_COLOSSEUM, + MAP_BATTLE_COLOSSEUM_4P, 0xFFFF, }; @@ -118,6 +118,8 @@ void TrySetMapSaveWarpStatus(void) sub_81AFD5C(); } +// Called when receiving the Pokedex +// Only place field_A8 is written (aside from clearing on new game), never read void sub_81AFDA0(void) { gSaveBlock2Ptr->field_A8 |= 0x8000; @@ -129,7 +131,7 @@ void sub_81AFDA0(void) gSaveBlock2Ptr->field_A8 |= 0x8; } -void sub_81AFDD0(void) +void SetChampionSaveWarp(void) { - gSaveBlock2Ptr->specialSaveWarpFlags |= 0x80; + gSaveBlock2Ptr->specialSaveWarpFlags |= CHAMPION_SAVEWARP; } diff --git a/src/scrcmd.c b/src/scrcmd.c index d97e3de47..a9be5c3ef 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -39,7 +39,6 @@ #include "script_menu.h" #include "script_movement.h" #include "script_pokemon_80F8.h" -#include "script_pokemon_81B9.h" #include "shop.h" #include "slot_machine.h" #include "sound.h" @@ -68,7 +67,7 @@ extern const SpecialFunc gSpecials[]; extern const u8 *gStdScripts[]; extern const u8 *gStdScripts_End[]; -void sub_809BDB4(void); +static void CloseBrailleWindow(void); // This is defined in here so the optimizer can't see its value when compiling // script.c. @@ -462,13 +461,13 @@ bool8 ScrCmd_compare_var_to_var(struct ScriptContext *ctx) return FALSE; } +// Note: addvar doesn't support adding from a variable in vanilla. If you were to +// add a VarGet() to the above, make sure you change the `addvar VAR_*, -1` +// in the contest scripts to `subvar VAR_*, 1`, else contests will break. bool8 ScrCmd_addvar(struct ScriptContext *ctx) { u16 *ptr = GetVarPointer(ScriptReadHalfword(ctx)); *ptr += ScriptReadHalfword(ctx); - // Note: addvar doesn't support adding from a variable in vanilla. If you were to - // add a VarGet() to the above, make sure you change the `addvar VAR_0x8006, 65535` - // in the contest scripts to `subvar VAR_0x8006, 1`, else contests will break. return FALSE; } @@ -1468,10 +1467,10 @@ bool8 ScrCmd_hidemonpic(struct ScriptContext *ctx) bool8 ScrCmd_showcontestwinner(struct ScriptContext *ctx) { - u8 v1 = ScriptReadByte(ctx); + u8 contestWinnerId = ScriptReadByte(ctx); + if (contestWinnerId) + SetContestWinnerForPainting(contestWinnerId); - if (v1) - sub_812FDA8(v1); ShowContestWinner(); ScriptContext1_Stop(); return TRUE; @@ -1528,9 +1527,9 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx) return FALSE; } -bool8 ScrCmd_cmdDA(struct ScriptContext *ctx) +bool8 ScrCmd_closebraillemessage(struct ScriptContext *ctx) { - sub_809BDB4(); + CloseBrailleWindow(); return FALSE; } @@ -1938,7 +1937,7 @@ bool8 ScrCmd_getpricereduction(struct ScriptContext *ctx) bool8 ScrCmd_choosecontestmon(struct ScriptContext *ctx) { - sub_81B9404(); + ChooseContestMon(); ScriptContext1_Stop(); return TRUE; } @@ -1946,7 +1945,7 @@ bool8 ScrCmd_choosecontestmon(struct ScriptContext *ctx) bool8 ScrCmd_startcontest(struct ScriptContext *ctx) { - sub_80F840C(); + StartContest(); ScriptContext1_Stop(); return TRUE; } @@ -2257,7 +2256,7 @@ bool8 ScrCmd_setmonmetlocation(struct ScriptContext *ctx) return FALSE; } -void sub_809BDB4(void) +static void CloseBrailleWindow(void) { ClearStdWindowAndFrame(gBrailleWindowId, 1); RemoveWindow(gBrailleWindowId); @@ -2281,7 +2280,7 @@ bool8 ScrCmd_buffertrainername(struct ScriptContext *ctx) return FALSE; } -void sub_809BE48(u16 npcId) +void SetMovingNpcId(u16 npcId) { sMovingNpcId = npcId; } diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c index f8206797b..8c66be30f 100755 --- a/src/script_pokemon_util_80F87D8.c +++ b/src/script_pokemon_util_80F87D8.c @@ -29,6 +29,7 @@ #include "constants/event_objects.h" #include "constants/items.h" #include "constants/species.h" +#include "constants/tv.h" #include "constants/vars.h" #include "constants/battle_frontier.h" @@ -39,8 +40,8 @@ extern const u16 gEventObjectPalette34[]; static const u8 gUnknown_0858D8EC[] = { 3, 4, 5, 14 }; -static void sub_80F8EE8(u8 taskId); -static void sub_80F9088(u8 taskId); +static void Task_ShowContestEntryMonPic(u8 taskId); +static void Task_LinkContestWaitForConnection(u8 taskId); static void CB2_ReturnFromChooseHalfParty(void); static void sub_80F94B8(void); @@ -74,11 +75,11 @@ void sub_80F8814(void) gSpecialVar_0x8004 = var1; } -void sub_80F8850(void) +void BufferContestTrainerAndMonNames(void) { - sub_80F8264(); - sub_80F8290(); - sub_80F8438(); + BufferContestantTrainerName(); + BufferContestantMonNickname(); + BufferContestantMonSpecies(); } void sub_80F8864(void) @@ -110,22 +111,22 @@ void sub_80F8864(void) gSpecialVar_0x8004 = 1; } -void sub_80F88DC(void) +void SaveMuseumContestPainting(void) { sub_80DEDA8(0xFF); } -void sub_80F88E8(void) +void ShouldReadyContestArtist(void) { if (gContestFinalStandings[gContestPlayerMonIndex] == 0 - && gSpecialVar_ContestRank == 3 + && gSpecialVar_ContestRank == CONTEST_RANK_MASTER && gUnknown_02039F08[gContestPlayerMonIndex] >= 800) { - gSpecialVar_0x8004 = 1; + gSpecialVar_0x8004 = TRUE; } else { - gSpecialVar_0x8004 = 0; + gSpecialVar_0x8004 = FALSE; } } @@ -219,11 +220,22 @@ static void ShowContestWinnerCleanup(void) void ShowContestWinner(void) { + /* + if(gUnknown_0203856C) + { + sub_80AAF30(); + gBattleStruct->unk15DDF = 1; + gBattleStruct->unk15DDE = sub_80B2C4C(254, 0); + Contest_SaveWinner(3); + gUnknown_0203856C = 0; + } + */ + SetMainCallback2(CB2_ContestPainting); gMain.savedCallback = ShowContestWinnerCleanup; } -void sub_80F8AFC(void) +void SetLinkContestPlayerGfx(void) { int i; @@ -248,7 +260,7 @@ void sub_80F8AFC(void) } } -void sub_80F8B94(void) +void LoadLinkContestPlayerPalettes(void) { int i; u8 eventObjectId; @@ -287,13 +299,15 @@ u8 GiveMonArtistRibbon(void) u8 hasArtistRibbon; hasArtistRibbon = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_ARTIST_RIBBON); - if (!hasArtistRibbon && gContestFinalStandings[gContestPlayerMonIndex] == 0 && gSpecialVar_ContestRank == 3 - && gUnknown_02039F08[gContestPlayerMonIndex] >= 800) + if (!hasArtistRibbon + && gContestFinalStandings[gContestPlayerMonIndex] == 0 + && gSpecialVar_ContestRank == CONTEST_RANK_MASTER + && gUnknown_02039F08[gContestPlayerMonIndex] >= 800) { hasArtistRibbon = 1; SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_ARTIST_RIBBON, &hasArtistRibbon); - if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > 4) - sub_80EE4DC(&gPlayerParty[gContestMonPartyIndex], MON_DATA_ARTIST_RIBBON); + if (GetRibbonCount(&gPlayerParty[gContestMonPartyIndex]) > NUM_CUTIES_RIBBONS) + TryPutSpotTheCutiesOnAir(&gPlayerParty[gContestMonPartyIndex], MON_DATA_ARTIST_RIBBON); return 1; } @@ -303,9 +317,9 @@ u8 GiveMonArtistRibbon(void) } } -u8 sub_80F8D24(void) +bool8 IsContestDebugActive(void) { - return 0; + return FALSE; // gUnknown_0203856C in pokeruby } void ShowContestEntryMonPic(void) @@ -317,7 +331,7 @@ void ShowContestEntryMonPic(void) u8 taskId; u8 left, top; - if (FindTaskIdByFunc(sub_80F8EE8) == 0xFF) + if (FindTaskIdByFunc(Task_ShowContestEntryMonPic) == 0xFF) { AllocateMonSpritesGfx(); left = 10; @@ -325,7 +339,7 @@ void ShowContestEntryMonPic(void) species = gContestMons[gSpecialVar_0x8006].species; personality = gContestMons[gSpecialVar_0x8006].personality; otId = gContestMons[gSpecialVar_0x8006].otId; - taskId = CreateTask(sub_80F8EE8, 0x50); + taskId = CreateTask(Task_ShowContestEntryMonPic, 0x50); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = species; if (gSpecialVar_0x8006 == gContestPlayerMonIndex) @@ -357,9 +371,9 @@ void ShowContestEntryMonPic(void) } } -void sub_80F8EB8(void) +void HideContestEntryMonPic(void) { - u8 taskId = FindTaskIdByFunc(sub_80F8EE8); + u8 taskId = FindTaskIdByFunc(Task_ShowContestEntryMonPic); if (taskId != 0xFF) { gTasks[taskId].data[0]++; @@ -367,7 +381,7 @@ void sub_80F8EB8(void) } } -static void sub_80F8EE8(u8 taskId) +static void Task_ShowContestEntryMonPic(u8 taskId) { struct Task *task = &gTasks[taskId]; struct Sprite *sprite; @@ -403,10 +417,12 @@ static void sub_80F8EE8(u8 taskId) void ScriptGetMultiplayerId(void) { - if ((gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) && gNumLinkContestPlayers == 4 && !(gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS)) + if ((gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) + && gNumLinkContestPlayers == CONTESTANT_COUNT + && !(gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS)) gSpecialVar_Result = GetMultiplayerId(); else - gSpecialVar_Result = 4; + gSpecialVar_Result = MAX_LINK_PLAYERS; } void ScriptRandom(void) @@ -428,26 +444,26 @@ void ScriptRandom(void) *scriptPtr = random % *scriptPtr; } -u16 sub_80F903C(void) +u16 GetContestRand(void) { gContestRngValue = 1103515245 * gContestRngValue + 24691; return gContestRngValue >> 16; } -u8 sub_80F905C(void) +bool8 LinkContestWaitForConnection(void) { if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) { - CreateTask(sub_80F9088, 5); - return 1; + CreateTask(Task_LinkContestWaitForConnection, 5); + return TRUE; } else { - return 0; + return FALSE; } } -static void sub_80F9088(u8 taskId) +static void Task_LinkContestWaitForConnection(u8 taskId) { switch (gTasks[taskId].data[0]) { @@ -471,7 +487,7 @@ static void sub_80F9088(u8 taskId) } } -void sub_80F90DC(void) +void LinkContestTryShowWirelessIndicator(void) { if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) { @@ -483,7 +499,7 @@ void sub_80F90DC(void) } } -void sub_80F910C(void) +void LinkContestTryHideWirelessIndicator(void) { if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) { @@ -492,25 +508,25 @@ void sub_80F910C(void) } } -u8 sub_80F9134(void) +bool8 IsContestWithRSPlayer(void) { if (gLinkContestFlags & LINK_CONTEST_FLAG_HAS_RS_PLAYER) - return 1; + return TRUE; else - return 0; + return FALSE; } -void sub_80F9154(void) +void ClearLinkContestFlags(void) { gLinkContestFlags = 0; } -u8 sub_80F9160(void) +bool8 IsWirelessContest(void) { if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) - return 1; + return TRUE; else - return 0; + return FALSE; } void HealPlayerParty(void) @@ -646,7 +662,7 @@ void ScriptSetMonMoveSlot(u8 monIndex, u16 move, u8 slot) void ChooseHalfPartyForBattle(void) { gMain.savedCallback = CB2_ReturnFromChooseHalfParty; - VarSet(VAR_FRONTIER_FACILITY, FRONTIER_FACILITY_DOUBLE_COLOSSEUM); + VarSet(VAR_FRONTIER_FACILITY, FACILITY_MULTI_OR_EREADER); InitChooseHalfPartyForBattle(0); } diff --git a/src/secret_base.c b/src/secret_base.c index 76dbe7668..b9826a257 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -1117,7 +1117,7 @@ const u8 *GetSecretBaseTrainerLoseText(void) void PrepSecretBaseBattleFlags(void) { - sub_813BADC(1); + TryGainNewFanFromCounter(1); gTrainerBattleOpponent_A = TRAINER_SECRET_BASE; gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_SECRET_BASE; } diff --git a/src/strings.c b/src/strings.c index ed702958e..afa567b9f 100644 --- a/src/strings.c +++ b/src/strings.c @@ -388,7 +388,7 @@ const u8 gText_PCMailboxFull[] = _("Your PC's MAILBOX is full.{PAUSE_UNTIL_PRESS const u8 gText_MailMessageWillBeLost[] = _("If the MAIL is removed, the\nmessage will be lost. Okay?"); const u8 gText_RemoveMailBeforeItem[] = _("MAIL must be removed before\nholding an item.{PAUSE_UNTIL_PRESS}"); const u8 gText_PkmnWasGivenItem[] = _("{STR_VAR_1} was given the\n{STR_VAR_2} to hold.{PAUSE_UNTIL_PRESS}"); -const u8 gText_SwitchPkmnItem[] = _("{STR_VAR_1} is already holding\none {STR_VAR_2}.\pWould you like to switch the\ntwo items?"); +const u8 gText_PkmnAlreadyHoldingItemSwitch[] = _("{STR_VAR_1} is already holding\none {STR_VAR_2}.\pWould you like to switch the\ntwo items?"); const u8 gText_PkmnNotHolding[] = _("{STR_VAR_1} isn't holding\nanything.{PAUSE_UNTIL_PRESS}"); const u8 gText_ReceivedItemFromPkmn[] = _("Received the {STR_VAR_2}\nfrom {STR_VAR_1}.{PAUSE_UNTIL_PRESS}"); const u8 gText_MailTakenFromPkmn[] = _("MAIL was taken from the\nPOKéMON.{PAUSE_UNTIL_PRESS}"); @@ -471,7 +471,7 @@ const u8 gText_CancelChallenge[] = _("Cancel the challenge?"); const u8 gText_EscapeFromHere[] = _("Want to escape from here and return\nto {STR_VAR_1}?"); const u8 gText_ReturnToHealingSpot[] = _("Want to return to the healing spot\nused last in {STR_VAR_1}?"); const u8 gText_PauseUntilPress[] = _("{PAUSE_UNTIL_PRESS}"); -const u8 gJPText_PutVar1IntoSpinner[] = _("{STR_VAR_1}を ぐるぐるこうかんに\nだして よろしいですか?"); +const u8 gJPText_AreYouSureYouWantToSpinTradeMon[] = _("{STR_VAR_1}を ぐるぐるこうかんに\nだして よろしいですか?"); ALIGNED(4) const u8 gText_OnlyPkmnForBattle[] = _("That's your only\nPOKéMON for battle."); ALIGNED(4) const u8 gText_PkmnCantBeTradedNow[] = _("That POKéMON can't be traded\nnow."); ALIGNED(4) const u8 gText_EggCantBeTradedNow[] = _("An EGG can't be traded now."); @@ -1220,11 +1220,11 @@ const u8 gText_BattleArena[] = _("BATTLE ARENA"); const u8 gText_BattlePike[] = _("BATTLE PIKE"); const u8 gText_BattlePyramid[] = _("BATTLE PYRAMID"); -ALIGNED(4) const u8 gUnknown_085ED164[] = _("{STR_VAR_1} SINGLE"); -ALIGNED(4) const u8 gUnknown_085ED170[] = _("{STR_VAR_1} DOUBLE"); -ALIGNED(4) const u8 gUnknown_085ED17C[] = _("{STR_VAR_1} MULTI"); -ALIGNED(4) const u8 gUnknown_085ED188[] = _("{STR_VAR_1} LINK"); -ALIGNED(4) const u8 gUnknown_085ED190[] = _("{STR_VAR_1}"); +ALIGNED(4) const u8 gText_FacilitySingle[] = _("{STR_VAR_1} SINGLE"); +ALIGNED(4) const u8 gText_FacilityDouble[] = _("{STR_VAR_1} DOUBLE"); +ALIGNED(4) const u8 gText_FacilityMulti[] = _("{STR_VAR_1} MULTI"); +ALIGNED(4) const u8 gText_FacilityLink[] = _("{STR_VAR_1} LINK"); +ALIGNED(4) const u8 gText_Facility[] = _("{STR_VAR_1}"); const u8 gText_Give[] = _("Give"); const u8 gText_NoNeed[] = _("No need"); diff --git a/src/trade.c b/src/trade.c index bfbc24194..909abe540 100644 --- a/src/trade.c +++ b/src/trade.c @@ -481,7 +481,7 @@ static void CB2_CreateTradeMenu(void) { struct Pokemon *mon = &gPlayerParty[i]; sTradeMenuData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), - UpdateTradeMonIconFrame, + SpriteCB_MonIcon, (sTradeMonSpriteCoords[i][0] * 8) + 14, (sTradeMonSpriteCoords[i][1] * 8) - 12, 1, @@ -493,7 +493,7 @@ static void CB2_CreateTradeMenu(void) { struct Pokemon *mon = &gEnemyParty[i]; sTradeMenuData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), - UpdateTradeMonIconFrame, + SpriteCB_MonIcon, (sTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (sTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, 1, @@ -668,7 +668,7 @@ static void CB2_ReturnToTradeMenu(void) { struct Pokemon *mon = &gPlayerParty[i]; sTradeMenuData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), - UpdateTradeMonIconFrame, + SpriteCB_MonIcon, (sTradeMonSpriteCoords[i][0] * 8) + 14, (sTradeMonSpriteCoords[i][1] * 8) - 12, 1, @@ -680,7 +680,7 @@ static void CB2_ReturnToTradeMenu(void) { struct Pokemon *mon = &gEnemyParty[i]; sTradeMenuData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), - UpdateTradeMonIconFrame, + SpriteCB_MonIcon, (sTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (sTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, 1, @@ -1439,8 +1439,8 @@ static void TradeMenuProcessInput_SelectedMon(void) QueueAction(QUEUE_DELAY_MSG, QUEUE_MON_CANT_BE_TRADED); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; break; - case CANT_TRADE_EGG: - case CANT_TRADE_EGG2: + case CANT_TRADE_EGG_YET: + case CANT_TRADE_EGG_YET2: QueueAction(QUEUE_DELAY_MSG, QUEUE_EGG_CANT_BE_TRADED); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; break; @@ -1809,7 +1809,7 @@ static void DrawTradeMenuParty(u8 whichParty) gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[0] = 20; gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[2] = (sTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + sTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[4] = (sTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; - StoreSpriteCallbackInData6(&gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]], UpdateTradeMonIconFrame); + StoreSpriteCallbackInData6(&gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]], SpriteCB_MonIcon); sTradeMenuData->drawPartyState[whichParty]++; TradeMenuBouncePartySprites(&gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]]); CopyToBgTilemapBufferRect_ChangePalette(1, sTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); @@ -1820,7 +1820,7 @@ static void DrawTradeMenuParty(u8 whichParty) PrintNicknamesForTradeMenu(); break; case 2: - if (gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].callback == UpdateTradeMonIconFrame) + if (gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].callback == SpriteCB_MonIcon) sTradeMenuData->drawPartyState[whichParty] = 3; break; case 3: @@ -2352,7 +2352,7 @@ static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int if (!IsNationalPokedexEnabled()) { if (species2[monIdx] == SPECIES_EGG) - return CANT_TRADE_EGG; + return CANT_TRADE_EGG_YET; if (!IsSpeciesInHoennDex(species2[monIdx])) return CANT_TRADE_NATIONAL; @@ -2366,7 +2366,7 @@ static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int if (!(player->progressFlagsCopy & 0xF)) { if (species2[monIdx] == SPECIES_EGG) - return CANT_TRADE_EGG2; + return CANT_TRADE_EGG_YET2; if (!IsSpeciesInHoennDex(species2[monIdx])) return CANT_TRADE_INVALID_MON; @@ -2542,8 +2542,10 @@ int CanRegisterMonForTradingBoard(struct UnkLinkRfuStruct_02022B14Substruct rfuP } // r6/r7 flip. Ugh. +// Spin Trade wasnt fully implemented, but this checks if a mon would be valid to Spin Trade +// Unlike later generations, this version of Spin Trade isnt only for Eggs #ifdef NONMATCHING -int CanTradeSelectedPartyMenuMon(struct Pokemon *mon, u16 monIdx) +int CanSpinTradeMon(struct Pokemon *mon, u16 monIdx) { int i, version, versions, canTradeAnyMon, numMonsLeft; int speciesArray[PARTY_SIZE]; @@ -2592,7 +2594,7 @@ int CanTradeSelectedPartyMenuMon(struct Pokemon *mon, u16 monIdx) return CANT_TRADE_NATIONAL; if (speciesArray[monIdx] == SPECIES_NONE) - return CANT_TRADE_EGG; + return CANT_TRADE_EGG_YET; } numMonsLeft = 0; @@ -2611,7 +2613,7 @@ int CanTradeSelectedPartyMenuMon(struct Pokemon *mon, u16 monIdx) } #else NAKED -int CanTradeSelectedPartyMenuMon(struct Pokemon *mon, u16 a1) +int CanSpinTradeMon(struct Pokemon *mon, u16 a1) { asm_unified("push {r4-r7,lr}\n\ mov r7, r8\n\ diff --git a/src/trader.c b/src/trader.c index a3794a539..e0b780d25 100644 --- a/src/trader.c +++ b/src/trader.c @@ -1,6 +1,6 @@ #include "global.h" #include "constants/decorations.h" -#include "constants/mauville_man.h" +#include "constants/mauville_old_man.h" #include "decoration.h" #include "decoration_inventory.h" #include "event_data.h" @@ -86,7 +86,7 @@ void CreateAvailableDecorationsMenu(u8 taskId) schedule_bg_copy_tilemap_to_vram(0); } -void sub_8133BE4(u8 taskId, u8 decorationId) +void Task_BufferDecorSelectionAndCloseWindow(u8 taskId, u8 decorationId) { s16 * data = gTasks[taskId].data; if (decorationId > NUM_DECORATIONS) @@ -118,14 +118,14 @@ void Task_HandleGetDecorationMenuInput(u8 taskId) case MENU_B_PRESSED: case 4: PlaySE(SE_SELECT); - sub_8133BE4(taskId, 0); + Task_BufferDecorSelectionAndCloseWindow(taskId, 0); break; default: PlaySE(SE_SELECT); gSpecialVar_0x8005 = input; StringCopy(gStringVar1, trader->playerNames[input]); ConvertInternationalString(gStringVar1, trader->language[input]); - sub_8133BE4(taskId, trader->decorIds[input]); + Task_BufferDecorSelectionAndCloseWindow(taskId, trader->decorIds[input]); break; } } diff --git a/src/trainer_hill.c b/src/trainer_hill.c index af6b0621d..b84920a62 100644 --- a/src/trainer_hill.c +++ b/src/trainer_hill.c @@ -22,6 +22,7 @@ #include "trainer_hill.h" #include "window.h" #include "util.h" +#include "constants/battle_ai.h" #include "constants/event_object_movement_constants.h" #include "constants/event_objects.h" #include "constants/items.h" @@ -45,7 +46,7 @@ struct TrHillStruct2 { u8 floorId; struct TrHillTag tag; - struct TrHillFloor floors[4]; + struct TrHillFloor floors[NUM_TRAINER_HILL_FLOORS]; }; static EWRAM_DATA struct TrHillStruct2 *sHillData = NULL; @@ -54,30 +55,30 @@ EWRAM_DATA u32 *gTrainerHillVBlankCounter = NULL; // This file's functions. static void TrainerHillStartChallenge(void); -static void sub_81D58D8(void); -static void sub_81D5924(void); -static void sub_81D59D0(void); +static void GetOwnerState(void); +static void GiveChallengePrize(void); +static void CheckFinalTime(void); static void TrainerHillResumeTimer(void); static void TrainerHillSetPlayerLost(void); static void TrainerHillGetChallengeStatus(void); -static void sub_81D5B2C(void); -static void sub_81D5BBC(void); -static void sub_81D5C00(void); -static void GetInTrainerHill(void); -static void sub_81D62B4(void); -static void sub_81D64AC(void); -static void sub_81D64DC(void); -static void sub_81D64FC(void); -static void sub_81D6518(void); -static void sub_81D6568(void); +static void BufferChallengeTime(void); +static void GetAllFloorsUsed(void); +static void ClearVarResult(void); +static void IsTrainerHillChallengeActive(void); +static void ShowTrainerHillPostBattleText(void); +static void SetAllTrainerFlags(void); +static void GetGameSaved(void); +static void SetGameSaved(void); +static void ClearGameSaved(void); +static void GetChallengeWon(void); static void TrainerHillSetTag(void); static void SetUpDataStruct(void); static void FreeDataStruct(void); static void nullsub_2(void); static void SetTimerValue(u32 *dst, u32 val); static u32 GetTimerValue(u32 *src); -static void sub_81D642C(struct Pokemon *mon, u8 level); -static u16 sub_81D6640(void); +static void SetTrainerHillMonLevel(struct Pokemon *mon, u8 level); +static u16 GetPrizeItemId(void); // const data #include "data/battle_frontier/trainer_hill.h" @@ -86,7 +87,7 @@ struct { u8 trainerClass; u8 musicId; -} static const gUnknown_0862A3B4[] = +} static const sTrainerClassesAndMusic[] = { {TRAINER_CLASS_TEAM_AQUA, TRAINER_ENCOUNTER_MUSIC_AQUA}, {TRAINER_CLASS_AQUA_ADMIN, TRAINER_ENCOUNTER_MUSIC_AQUA}, @@ -144,63 +145,64 @@ struct {TRAINER_CLASS_SCHOOL_KID, TRAINER_ENCOUNTER_MUSIC_MALE}, }; -static const u16 gUnknown_0862A48C[] = {ITEM_RARE_CANDY, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A498[] = {ITEM_LUXURY_BALL, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A4A4[] = {ITEM_MAX_REVIVE, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A4B0[] = {ITEM_MAX_ETHER, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A4BC[] = {ITEM_ELIXIR, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A4C8[] = {ITEM_TM05_ROAR, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A4D4[] = {ITEM_TM36_SLUDGE_BOMB, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A4E0[] = {ITEM_TM06_TOXIC, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A4EC[] = {ITEM_TM11_SUNNY_DAY, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A4F8[] = {ITEM_TM26_EARTHQUAKE, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A504[] = {ITEM_RARE_CANDY, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A510[] = {ITEM_LUXURY_BALL, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A51C[] = {ITEM_MAX_REVIVE, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A528[] = {ITEM_MAX_ETHER, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A534[] = {ITEM_ELIXIR, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A540[] = {ITEM_TM31_BRICK_BREAK, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A54C[] = {ITEM_TM41_TORMENT, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A558[] = {ITEM_TM48_SKILL_SWAP, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A564[] = {ITEM_TM19_GIGA_DRAIN, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; -static const u16 gUnknown_0862A570[] = {ITEM_TM45_ATTRACT, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; - -static const u16 *const gUnknown_0862A57C[] = -{ - gUnknown_0862A48C, - gUnknown_0862A498, - gUnknown_0862A4A4, - gUnknown_0862A4B0, - gUnknown_0862A4BC, - gUnknown_0862A4C8, - gUnknown_0862A4D4, - gUnknown_0862A4E0, - gUnknown_0862A4EC, - gUnknown_0862A4F8 +static const u16 sPrizeListRareCandy1[] = {ITEM_RARE_CANDY, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListLuxuryBall1[] = {ITEM_LUXURY_BALL, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListMaxRevive1[] = {ITEM_MAX_REVIVE, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListMaxEther1[] = {ITEM_MAX_ETHER, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListElixir1[] = {ITEM_ELIXIR, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListRoar[] = {ITEM_TM05_ROAR, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListSludgeBomb[] = {ITEM_TM36_SLUDGE_BOMB, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListToxic[] = {ITEM_TM06_TOXIC, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListSunnyDay[] = {ITEM_TM11_SUNNY_DAY, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListEarthQuake[] = {ITEM_TM26_EARTHQUAKE, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; + +static const u16 sPrizeListRareCandy2[] = {ITEM_RARE_CANDY, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListLuxuryBall2[] = {ITEM_LUXURY_BALL, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListMaxRevive2[] = {ITEM_MAX_REVIVE, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListMaxEther2[] = {ITEM_MAX_ETHER, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListElixir2[] = {ITEM_ELIXIR, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListBrickBreak[] = {ITEM_TM31_BRICK_BREAK, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListTorment[] = {ITEM_TM41_TORMENT, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListSkillSwap[] = {ITEM_TM48_SKILL_SWAP, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListGigaSwap[] = {ITEM_TM19_GIGA_DRAIN, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; +static const u16 sPrizeListAttract[] = {ITEM_TM45_ATTRACT, ITEM_ETHER, ITEM_MAX_POTION, ITEM_REVIVE, ITEM_FLUFFY_TAIL, ITEM_GREAT_BALL}; + +static const u16 *const sPrizeLists1[NUM_TRAINER_HILL_PRIZE_LISTS] = +{ + sPrizeListRareCandy1, + sPrizeListLuxuryBall1, + sPrizeListMaxRevive1, + sPrizeListMaxEther1, + sPrizeListElixir1, + sPrizeListRoar, + sPrizeListSludgeBomb, + sPrizeListToxic, + sPrizeListSunnyDay, + sPrizeListEarthQuake }; -static const u16 *const gUnknown_0862A5A4[] = -{ - gUnknown_0862A504, - gUnknown_0862A510, - gUnknown_0862A51C, - gUnknown_0862A528, - gUnknown_0862A534, - gUnknown_0862A540, - gUnknown_0862A54C, - gUnknown_0862A558, - gUnknown_0862A564, - gUnknown_0862A570 +static const u16 *const sPrizeLists2[NUM_TRAINER_HILL_PRIZE_LISTS] = +{ + sPrizeListRareCandy2, + sPrizeListLuxuryBall2, + sPrizeListMaxRevive2, + sPrizeListMaxEther2, + sPrizeListElixir2, + sPrizeListBrickBreak, + sPrizeListTorment, + sPrizeListSkillSwap, + sPrizeListGigaSwap, + sPrizeListAttract }; -static const u16 *const *const gUnknown_0862A5CC[] = +static const u16 *const *const sPrizeListSets[] = { - gUnknown_0862A57C, - gUnknown_0862A5A4 + sPrizeLists1, + sPrizeLists2 }; -static const u16 gUnknown_0862A5D4[] = INCBIN_U16("graphics/pokenav/862A5D4.gbapal"); -static const u8 sRecordWinColors[] = {0, 2, 3}; +static const u16 sUnknown_0862A5D4[] = INCBIN_U16("graphics/pokenav/862A5D4.gbapal"); +static const u8 sRecordWinColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY}; static const struct TrHillTag *const sDataPerTag[] = { @@ -221,24 +223,24 @@ static const u8 *const sFloorStrings[] = static void (* const sHillFunctions[])(void) = { - TrainerHillStartChallenge, - sub_81D58D8, - sub_81D5924, - sub_81D59D0, - TrainerHillResumeTimer, - TrainerHillSetPlayerLost, - TrainerHillGetChallengeStatus, - sub_81D5B2C, - sub_81D5BBC, - sub_81D5C00, - GetInTrainerHill, - sub_81D62B4, - sub_81D64AC, - sub_81D64DC, - sub_81D64FC, - sub_81D6518, - sub_81D6568, - TrainerHillSetTag, + [TRAINER_HILL_FUNC_START] = TrainerHillStartChallenge, + [TRAINER_HILL_FUNC_GET_OWNER_STATE] = GetOwnerState, + [TRAINER_HILL_FUNC_GIVE_PRIZE] = GiveChallengePrize, + [TRAINER_HILL_FUNC_CHECK_FINAL_TIME] = CheckFinalTime, + [TRAINER_HILL_FUNC_RESUME_TIMER] = TrainerHillResumeTimer, + [TRAINER_HILL_FUNC_SET_LOST] = TrainerHillSetPlayerLost, + [TRAINER_HILL_FUNC_GET_CHALLENGE_STATUS] = TrainerHillGetChallengeStatus, + [TRAINER_HILL_FUNC_GET_CHALLENGE_TIME] = BufferChallengeTime, + [TRAINER_HILL_FUNC_GET_ALL_FLOORS_USED] = GetAllFloorsUsed, + [TRAINER_HILL_FUNC_CLEAR_RESULT] = ClearVarResult, + [TRAINER_HILL_FUNC_IN_CHALLENGE] = IsTrainerHillChallengeActive, + [TRAINER_HILL_FUNC_POST_BATTLE_TEXT] = ShowTrainerHillPostBattleText, + [TRAINER_HILL_FUNC_SET_ALL_TRAINER_FLAGS] = SetAllTrainerFlags, + [TRAINER_HILL_FUNC_GET_GAME_SAVED] = GetGameSaved, + [TRAINER_HILL_FUNC_SET_GAME_SAVED] = SetGameSaved, + [TRAINER_HILL_FUNC_CLEAR_GAME_SAVED] = ClearGameSaved, + [TRAINER_HILL_FUNC_GET_WON] = GetChallengeWon, + [TRAINER_HILL_FUNC_SET_TAG] = TrainerHillSetTag, }; static const u8 *const sTagMatchStrings[] = @@ -249,7 +251,7 @@ static const u8 *const sTagMatchStrings[] = gText_ExpertTagMatch, }; -static const struct EventObjectTemplate gUnknown_0862A670 = +static const struct EventObjectTemplate sTrainerEventObjectTemplate = { .graphicsId = EVENT_OBJ_GFX_RIVAL_BRENDAN_NORMAL, .elevation = 3, @@ -259,8 +261,18 @@ static const struct EventObjectTemplate gUnknown_0862A670 = .trainerType = 1, }; -static const u32 gUnknown_0862A688[] = {MAP_NUM(TRAINER_HILL_2F), MAP_NUM(TRAINER_HILL_3F), MAP_NUM(TRAINER_HILL_4F), MAP_NUM(TRAINER_HILL_ROOF)}; -static const u8 gUnknown_0862A698[][3] = {{0, 1, 2}, {3, 4, 5}}; +static const u32 sNextFloorMapNum[NUM_TRAINER_HILL_FLOORS] = +{ + MAP_NUM(TRAINER_HILL_2F), + MAP_NUM(TRAINER_HILL_3F), + MAP_NUM(TRAINER_HILL_4F), + MAP_NUM(TRAINER_HILL_ROOF) +}; +static const u8 sTrainerPartySlots[][PARTY_SIZE / 2] = +{ + {0, 1, 2}, + {3, 4, 5} +}; // code void CallTrainerHillFunction(void) @@ -274,8 +286,8 @@ void ResetTrainerHillResults(void) { s32 i; - gSaveBlock2Ptr->frontier.field_EF9_1 = 0; - gSaveBlock2Ptr->frontier.field_EF9_0 = 0; + gSaveBlock2Ptr->frontier.savedGame = 0; + gSaveBlock2Ptr->frontier.unk_EF9 = 0; gSaveBlock1Ptr->trainerHill.bestTime = 0; for (i = 0; i < 4; i++) SetTimerValue(&gSaveBlock1Ptr->trainerHillTimes[i], HILL_MAX_TIME); @@ -366,16 +378,16 @@ void CopyTrainerHillTrainerText(u8 which, u16 trainerId) switch (which) { - case 2: + case TRAINER_HILL_TEXT_INTRO: FrontierSpeechToString(sHillData->floors[floorId].trainers[id].speechBefore); break; - case 3: + case TRAINER_HILL_TEXT_PLAYER_LOST: FrontierSpeechToString(sHillData->floors[floorId].trainers[id].speechWin); break; - case 4: + case TRAINER_HILL_TEXT_PLAYER_WON: FrontierSpeechToString(sHillData->floors[floorId].trainers[id].speechLose); break; - case 5: + case TRAINER_HILL_TEXT_AFTER: FrontierSpeechToString(sHillData->floors[floorId].trainers[id].speechAfter); break; } @@ -391,42 +403,42 @@ static void TrainerHillStartChallenge(void) else gSaveBlock1Ptr->trainerHill.field_3D6E_0f = 0; - gSaveBlock1Ptr->trainerHill.field_3D6C = 0; + gSaveBlock1Ptr->trainerHill.unk_3D6C = 0; SetTrainerHillVBlankCounter(&gSaveBlock1Ptr->trainerHill.timer); gSaveBlock1Ptr->trainerHill.timer = 0; - gSaveBlock1Ptr->trainerHill.field_3D6E_0c = 0; - gSaveBlock1Ptr->trainerHill.field_3D6E_0b = 0; + gSaveBlock1Ptr->trainerHill.spokeToOwner = 0; + gSaveBlock1Ptr->trainerHill.checkedFinalTime = 0; gSaveBlock1Ptr->trainerHill.maybeECardScanDuringChallenge = 0; - gSaveBlock2Ptr->frontier.field_EE0 = 0; + gSaveBlock2Ptr->frontier.trainerFlags = 0; gBattleOutcome = 0; - gSaveBlock1Ptr->trainerHill.field_3D6E_0a = 0; + gSaveBlock1Ptr->trainerHill.receivedPrize = 0; } -static void sub_81D58D8(void) +static void GetOwnerState(void) { ClearTrainerHillVBlankCounter(); gSpecialVar_Result = 0; - if (gSaveBlock1Ptr->trainerHill.field_3D6E_0c) + if (gSaveBlock1Ptr->trainerHill.spokeToOwner) gSpecialVar_Result++; - if (gSaveBlock1Ptr->trainerHill.field_3D6E_0a && gSaveBlock1Ptr->trainerHill.field_3D6E_0b) + if (gSaveBlock1Ptr->trainerHill.receivedPrize && gSaveBlock1Ptr->trainerHill.checkedFinalTime) gSpecialVar_Result++; - gSaveBlock1Ptr->trainerHill.field_3D6E_0c = 1; + gSaveBlock1Ptr->trainerHill.spokeToOwner = TRUE; } -static void sub_81D5924(void) +static void GiveChallengePrize(void) { - u16 itemId = sub_81D6640(); + u16 itemId = GetPrizeItemId(); - if (sHillData->tag.numFloors != 4 || gSaveBlock1Ptr->trainerHill.field_3D6E_0a) + if (sHillData->tag.numFloors != NUM_TRAINER_HILL_FLOORS || gSaveBlock1Ptr->trainerHill.receivedPrize) { gSpecialVar_Result = 2; } else if (AddBagItem(itemId, 1) == TRUE) { CopyItemName(itemId, gStringVar2); - gSaveBlock1Ptr->trainerHill.field_3D6E_0a = 1; - gSaveBlock2Ptr->frontier.field_EF9_0 = 0; + gSaveBlock1Ptr->trainerHill.receivedPrize = TRUE; + gSaveBlock2Ptr->frontier.unk_EF9 = 0; gSpecialVar_Result = 0; } else @@ -435,9 +447,11 @@ static void sub_81D5924(void) } } -static void sub_81D59D0(void) +// If bestTime > timer, the challenge was completed faster and its a new record +// Otherwise the owner says it was a slow time and to complete it faster next time +static void CheckFinalTime(void) { - if (gSaveBlock1Ptr->trainerHill.field_3D6E_0b) + if (gSaveBlock1Ptr->trainerHill.checkedFinalTime) { gSpecialVar_Result = 2; } @@ -452,12 +466,12 @@ static void sub_81D59D0(void) gSpecialVar_Result = 1; } - gSaveBlock1Ptr->trainerHill.field_3D6E_0b = 1; + gSaveBlock1Ptr->trainerHill.checkedFinalTime = TRUE; } static void TrainerHillResumeTimer(void) { - if (!gSaveBlock1Ptr->trainerHill.field_3D6E_0c) + if (!gSaveBlock1Ptr->trainerHill.spokeToOwner) { if (gSaveBlock1Ptr->trainerHill.timer >= HILL_MAX_TIME) gSaveBlock1Ptr->trainerHill.timer = HILL_MAX_TIME; @@ -468,7 +482,7 @@ static void TrainerHillResumeTimer(void) static void TrainerHillSetPlayerLost(void) { - gSaveBlock1Ptr->trainerHill.hasLost = 1; + gSaveBlock1Ptr->trainerHill.hasLost = TRUE; } static void TrainerHillGetChallengeStatus(void) @@ -476,7 +490,7 @@ static void TrainerHillGetChallengeStatus(void) if (gSaveBlock1Ptr->trainerHill.hasLost) { // The player lost their last match. - gSaveBlock1Ptr->trainerHill.hasLost = 0; + gSaveBlock1Ptr->trainerHill.hasLost = FALSE; gSpecialVar_Result = TRAINER_HILL_PLAYER_STATUS_LOST; } else if (gSaveBlock1Ptr->trainerHill.maybeECardScanDuringChallenge) @@ -492,7 +506,7 @@ static void TrainerHillGetChallengeStatus(void) } } -static void sub_81D5B2C(void) +static void BufferChallengeTime(void) { s32 total, minutes, secondsWhole, secondsFraction; @@ -511,23 +525,27 @@ static void sub_81D5B2C(void) ConvertIntToDecimalStringN(gStringVar3, secondsFraction, STR_CONV_MODE_LEADING_ZEROS, 2); } -static void sub_81D5BBC(void) +// Returns TRUE if all 4 floors are used +// Returns FALSE otherwise, and buffers the number of floors used +// The only time fewer than all 4 floors are used is for the JP-exclusive E-Reader and Default modes +static void GetAllFloorsUsed(void) { SetUpDataStruct(); - if (sHillData->tag.numFloors != 4) + if (sHillData->tag.numFloors != NUM_TRAINER_HILL_FLOORS) { ConvertIntToDecimalStringN(gStringVar1, sHillData->tag.numFloors, STR_CONV_MODE_LEFT_ALIGN, 1); - gSpecialVar_Result = 0; + gSpecialVar_Result = FALSE; } else { - gSpecialVar_Result = 1; + gSpecialVar_Result = TRUE; } FreeDataStruct(); } -static void sub_81D5C00(void) +// May have been dummied. Every time this is called a conditional for var result occurs afterwards +static void ClearVarResult(void) { SetUpDataStruct(); gSpecialVar_Result = 0; @@ -538,7 +556,7 @@ bool8 InTrainerHillChallenge(void) { if (VarGet(VAR_TRAINER_HILL_IS_ACTIVE) == 0) return FALSE; - else if (gSaveBlock1Ptr->trainerHill.field_3D6E_0c) + else if (gSaveBlock1Ptr->trainerHill.spokeToOwner) return FALSE; else if (GetCurrentTrainerHillMapId() != 0) return TRUE; @@ -546,12 +564,12 @@ bool8 InTrainerHillChallenge(void) return FALSE; } -static void GetInTrainerHill(void) +static void IsTrainerHillChallengeActive(void) { if (!InTrainerHillChallenge()) - gSpecialVar_Result = 0; + gSpecialVar_Result = FALSE; else - gSpecialVar_Result = 1; + gSpecialVar_Result = TRUE; } void nullsub_129(void) @@ -611,12 +629,12 @@ static void SetTimerValue(u32 *dst, u32 val) *dst = val; } -void sub_81D5DF8(void) +void LoadTrainerHillEventObjectTemplates(void) { u8 i, floorId; struct EventObjectTemplate *eventTemplates = gSaveBlock1Ptr->eventObjectTemplates; - if (!sub_81D5F48()) + if (!LoadTrainerHillFloorEventObjectScripts()) return; SetUpDataStruct(); @@ -629,7 +647,7 @@ void sub_81D5DF8(void) { u8 bits; - eventTemplates[i] = gUnknown_0862A670; + eventTemplates[i] = sTrainerEventObjectTemplate; eventTemplates[i].localId = i + 1; eventTemplates[i].graphicsId = FacilityClassToGraphicsId(sHillData->floors[floorId].trainers[i].facilityClass); eventTemplates[i].x = sHillData->floors[floorId].display.coords[i] & 0xF; @@ -637,16 +655,17 @@ void sub_81D5DF8(void) bits = i << 2; eventTemplates[i].movementType = ((sHillData->floors[floorId].display.direction >> bits) & 0xF) + MOVEMENT_TYPE_FACE_UP; eventTemplates[i].trainerRange_berryTreeId = (sHillData->floors[floorId].display.range >> bits) & 0xF; - eventTemplates[i].script = EventScript_2C83F0; + eventTemplates[i].script = TrainerHill_EventScript_TrainerBattle; gSaveBlock2Ptr->frontier.trainerIds[i] = i + 1; } FreeDataStruct(); } -bool32 sub_81D5F48(void) +bool32 LoadTrainerHillFloorEventObjectScripts(void) { SetUpDataStruct(); + // Something may have been dummied here FreeDataStruct(); return TRUE; } @@ -657,8 +676,8 @@ static u32 sub_81D5F58(u8 floorId, u32 bit, u32 arg2, u32 arg3) { u32 var0, var1, var2, var3; - var0 = (sHillData->floors[floorId].unk3A0[arg2] >> (15 - bit)) & 1; - var1 = sHillData->floors[floorId].data[arg2 * arg3 + bit]; + var0 = (sHillData->floors[floorId].display.unk3A0[arg2] >> (15 - bit)) & 1; + var1 = sHillData->floors[floorId].display.data[arg2 * arg3 + bit]; var3 = 0x200; var2 = 0x3000; @@ -716,20 +735,20 @@ static u32 sub_81D5F58(u8 floorId, u32 bit, u32 arg2, u32 arg3) } #endif // NONMATCHING -void sub_81D5FB4(u16 *mapArg) +void GenerateTrainerHillFloorLayout(u16 *mapArg) { s32 i, j; u16 *src, *dst; u8 mapId = GetCurrentTrainerHillMapId(); - if (mapId == 6) + if (mapId == TRAINER_HILL_ENTRANCE) { InitMapFromSavedGame(); return; } SetUpDataStruct(); - if (mapId == 5) + if (mapId == TRAINER_HILL_ROOF) { InitMapFromSavedGame(); FreeDataStruct(); @@ -766,9 +785,9 @@ bool32 InTrainerHill(void) bool32 ret; if (gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_1F - || gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_2F - || gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_3F - || gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_4F) + || gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_2F + || gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_3F + || gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_4F) ret = TRUE; else ret = FALSE; @@ -778,58 +797,61 @@ bool32 InTrainerHill(void) u8 GetCurrentTrainerHillMapId(void) { - u8 ret; + u8 mapId; if (gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_1F) - ret = 1; + mapId = TRAINER_HILL_1F; else if (gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_2F) - ret = 2; + mapId = TRAINER_HILL_2F; else if (gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_3F) - ret = 3; + mapId = TRAINER_HILL_3F; else if (gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_4F) - ret = 4; + mapId = TRAINER_HILL_4F; else if (gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_ROOF) - ret = 5; + mapId = TRAINER_HILL_ROOF; else if (gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_ENTRANCE) - ret = 6; + mapId = TRAINER_HILL_ENTRANCE; else - ret = 0; + mapId = 0; - return ret; + return mapId; } -static bool32 sub_81D6100(void) +// Unused +static bool32 OnTrainerHillRoof(void) { - bool32 ret; + bool32 onRoof; if (gMapHeader.mapLayoutId == LAYOUT_TRAINER_HILL_ROOF) - ret = TRUE; + onRoof = TRUE; else - ret = FALSE; + onRoof = FALSE; - return ret; + return onRoof; } -const struct WarpEvent* sub_81D6120(void) +const struct WarpEvent* SetWarpDestinationTrainerHill4F(void) { const struct MapHeader *header = Overworld_GetMapHeaderByGroupAndId(MAP_GROUP(TRAINER_HILL_4F), MAP_NUM(TRAINER_HILL_4F)); return &header->events->warps[1]; } -const struct WarpEvent* sub_81D6134(u8 warpEventId) +// For warping from the roof in challenges where the 4F is not the final challenge floor +// This would only occur in the JP-exclusive Default and E-Reader challenges +const struct WarpEvent* SetWarpDestinationTrainerHillFinalFloor(u8 warpEventId) { - u8 id; + u8 numFloors; const struct MapHeader *header; if (warpEventId == 1) return &gMapHeader.events->warps[1]; - id = sub_81D6490(); - if (id == 0 || id >= 5) - id = 4; + numFloors = GetNumFloorsInTrainerHillChallenge(); + if (numFloors == 0 || numFloors > NUM_TRAINER_HILL_FLOORS) + numFloors = NUM_TRAINER_HILL_FLOORS; - header = Overworld_GetMapHeaderByGroupAndId(MAP_GROUP(TRAINER_HILL_4F), gUnknown_0862A688[id - 1]); + header = Overworld_GetMapHeaderByGroupAndId(MAP_GROUP(TRAINER_HILL_4F), sNextFloorMapNum[numFloors - 1]); return &header->events->warps[0]; } @@ -843,7 +865,7 @@ bool8 GetHillTrainerFlag(u8 eventObjectId) u32 floorId = GetFloorId() * 2; u8 bitId = gEventObjects[eventObjectId].localId - 1 + floorId; - return gSaveBlock2Ptr->frontier.field_EE0 & gBitTable[bitId]; + return gSaveBlock2Ptr->frontier.trainerFlags & gBitTable[bitId]; } void SetHillTrainerFlag(void) @@ -855,7 +877,7 @@ void SetHillTrainerFlag(void) { if (gSaveBlock2Ptr->frontier.trainerIds[i] == gTrainerBattleOpponent_A) { - gSaveBlock2Ptr->frontier.field_EE0 |= gBitTable[floorId + i]; + gSaveBlock2Ptr->frontier.trainerFlags |= gBitTable[floorId + i]; break; } } @@ -866,7 +888,7 @@ void SetHillTrainerFlag(void) { if (gSaveBlock2Ptr->frontier.trainerIds[i] == gTrainerBattleOpponent_B) { - gSaveBlock2Ptr->frontier.field_EE0 |= gBitTable[floorId + i]; + gSaveBlock2Ptr->frontier.trainerFlags |= gBitTable[floorId + i]; break; } } @@ -875,19 +897,19 @@ void SetHillTrainerFlag(void) const u8 *GetTrainerHillTrainerScript(void) { - return EventScript_2C83F0; + return TrainerHill_EventScript_TrainerBattle; } -static void sub_81D62B4(void) +static void ShowTrainerHillPostBattleText(void) { - CopyTrainerHillTrainerText(5, gSpecialVar_LastTalked); + CopyTrainerHillTrainerText(TRAINER_HILL_TEXT_AFTER, gSpecialVar_LastTalked); sub_80982B8(); } -static void sub_81D62CC(u16 trainerId, u8 firstMonId) +static void CreateNPCTrainerHillParty(u16 trainerId, u8 firstMonId) { u8 trId, level; - s32 i, floorId, arrId; + s32 i, floorId, partySlot; if (trainerId == 0 || trainerId > 2) return; @@ -896,13 +918,13 @@ static void sub_81D62CC(u16 trainerId, u8 firstMonId) SetUpDataStruct(); level = GetHighestLevelInPlayerParty(); floorId = GetFloorId(); - for (i = firstMonId, arrId = 0; i < firstMonId + 3; i++, arrId++) + for (i = firstMonId, partySlot = 0; i < firstMonId + 3; i++, partySlot++) { - u8 id = gUnknown_0862A698[trId][arrId]; + u8 id = sTrainerPartySlots[trId][partySlot]; struct Pokemon *mon = &gEnemyParty[i]; CreateBattleTowerMon(mon, &sHillData->floors[floorId].trainers[trId].mons[id]); - sub_81D642C(mon, level); + SetTrainerHillMonLevel(mon, level); } FreeDataStruct(); @@ -911,22 +933,22 @@ static void sub_81D62CC(u16 trainerId, u8 firstMonId) void FillHillTrainerParty(void) { ZeroEnemyPartyMons(); - sub_81D62CC(gTrainerBattleOpponent_A, 0); + CreateNPCTrainerHillParty(gTrainerBattleOpponent_A, 0); } void FillHillTrainersParties(void) { ZeroEnemyPartyMons(); - sub_81D62CC(gTrainerBattleOpponent_A, 0); - sub_81D62CC(gTrainerBattleOpponent_B, 3); + CreateNPCTrainerHillParty(gTrainerBattleOpponent_A, 0); + CreateNPCTrainerHillParty(gTrainerBattleOpponent_B, 3); } // This function is unused, but my best guess is // it was supposed to return AI scripts for trainer // hill trainers. -u32 sub_81D63C4(void) +u32 GetTrainerHillAIFlags(void) { - return 7; + return (AI_SCRIPT_CHECK_BAD_MOVE | AI_SCRIPT_TRY_TO_FAINT | AI_SCRIPT_CHECK_VIABILITY); } u8 GetTrainerEncounterMusicIdInTrainerHill(u16 trainerId) @@ -939,16 +961,16 @@ u8 GetTrainerEncounterMusicIdInTrainerHill(u16 trainerId) facilityClass = sHillData->floors[sHillData->floorId].trainers[trId].facilityClass; FreeDataStruct(); - for (i = 0; i < ARRAY_COUNT(gUnknown_0862A3B4); i++) + for (i = 0; i < ARRAY_COUNT(sTrainerClassesAndMusic); i++) { - if (gUnknown_0862A3B4[i].trainerClass == gFacilityClassToTrainerClass[facilityClass]) - return gUnknown_0862A3B4[i].musicId; + if (sTrainerClassesAndMusic[i].trainerClass == gFacilityClassToTrainerClass[facilityClass]) + return sTrainerClassesAndMusic[i].musicId; } return 0; } -static void sub_81D642C(struct Pokemon *mon, u8 level) +static void SetTrainerHillMonLevel(struct Pokemon *mon, u8 level) { u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL); u32 exp = gExperienceTables[gBaseStats[species].growthRate][level]; @@ -958,61 +980,63 @@ static void sub_81D642C(struct Pokemon *mon, u8 level) CalculateMonStats(mon); } -u8 sub_81D6490(void) +u8 GetNumFloorsInTrainerHillChallenge(void) { - u8 ret; + u8 floors; SetUpDataStruct(); - ret = sHillData->tag.numFloors; + floors = sHillData->tag.numFloors; FreeDataStruct(); - return ret; + return floors; } -static void sub_81D64AC(void) +static void SetAllTrainerFlags(void) { - gSaveBlock2Ptr->frontier.field_EE0 = 0xFF; + gSaveBlock2Ptr->frontier.trainerFlags = 0xFF; } +// Palette never loaded, sub_81D6534 always FALSE void sub_81D64C0(void) { if (sub_81D6534() == TRUE) - LoadPalette(gUnknown_0862A5D4, 0x70, 0x20); + LoadPalette(sUnknown_0862A5D4, 0x70, 0x20); } -static void sub_81D64DC(void) +static void GetGameSaved(void) { - gSpecialVar_Result = gSaveBlock2Ptr->frontier.field_EF9_1; + gSpecialVar_Result = gSaveBlock2Ptr->frontier.savedGame; } -static void sub_81D64FC(void) +static void SetGameSaved(void) { - gSaveBlock2Ptr->frontier.field_EF9_1 = 1; + gSaveBlock2Ptr->frontier.savedGame = TRUE; } -static void sub_81D6518(void) +static void ClearGameSaved(void) { - gSaveBlock2Ptr->frontier.field_EF9_1 = 0; + gSaveBlock2Ptr->frontier.savedGame = FALSE; } +// Always FALSE bool32 sub_81D6534(void) { - if (!InTrainerHillChallenge() || GetCurrentTrainerHillMapId() == 6) + if (!InTrainerHillChallenge() || GetCurrentTrainerHillMapId() == TRAINER_HILL_ENTRANCE) return FALSE; - sub_81D5C00(); + ClearVarResult(); if (gSpecialVar_Result == 0) return FALSE; else return TRUE; } -static void sub_81D6568(void) +static void GetChallengeWon(void) { if (gSaveBlock1Ptr->trainerHill.hasLost) - gSpecialVar_Result = 0; + gSpecialVar_Result = FALSE; else - gSpecialVar_Result = 1; + gSpecialVar_Result = TRUE; } static void TrainerHillSetTag(void) @@ -1021,49 +1045,50 @@ static void TrainerHillSetTag(void) gSaveBlock1Ptr->trainerHill.bestTime = gSaveBlock1Ptr->trainerHillTimes[gSpecialVar_0x8005]; } -static u8 sub_81D65E8(u8 arg0) +static u8 GetPrizeListId(bool8 maxTrainers) { - u8 var, i, modBy; + u8 prizeListId, i, modBy; - var = 0; - for (i = 0; i < 4; i++) + prizeListId = 0; + for (i = 0; i < NUM_TRAINER_HILL_FLOORS; i++) { - var ^= sHillData->floors[i].unk0 & 0x1F; - var ^= sHillData->floors[i].unk1 & 0x1F; + prizeListId ^= sHillData->floors[i].trainerNum1 & 0x1F; + prizeListId ^= sHillData->floors[i].trainerNum2 & 0x1F; } - if (arg0) - modBy = 10; + // Not possible to win TMs with fewer than 8 trainers + if (maxTrainers) + modBy = NUM_TRAINER_HILL_PRIZE_LISTS; else - modBy = 5; + modBy = NUM_TRAINER_HILL_PRIZE_LISTS / 2; - var %= modBy; - return var; + prizeListId %= modBy; + return prizeListId; } -static u16 sub_81D6640(void) +static u16 GetPrizeItemId(void) { u8 i; - const u16 *ptr; - s32 var = 0, var2, minutes, id; + const u16 *prizeList; + s32 var = 0, prizeListSetId, minutes, id; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_TRAINER_HILL_FLOORS; i++) { - var += sHillData->floors[i].unk0; - var += sHillData->floors[i].unk1; + var += sHillData->floors[i].trainerNum1; + var += sHillData->floors[i].trainerNum2; } - var2 = var / 256; - var2 %= 2; - if (FlagGet(FLAG_SYS_GAME_CLEAR) && sHillData->tag.unkField_0 == 8) - i = sub_81D65E8(1); + prizeListSetId = var / 256; + prizeListSetId %= 2; + if (FlagGet(FLAG_SYS_GAME_CLEAR) && sHillData->tag.numTrainers == NUM_TRAINER_HILL_TRAINERS) + i = GetPrizeListId(TRUE); else - i = sub_81D65E8(0); + i = GetPrizeListId(FALSE); if (gSaveBlock1Ptr->trainerHill.tag == HILL_TAG_EXPERT) - i = (i + 1) % 10; + i = (i + 1) % NUM_TRAINER_HILL_PRIZE_LISTS; - ptr = gUnknown_0862A5CC[var2][i]; + prizeList = sPrizeListSets[prizeListSetId][i]; minutes = (signed)(gSaveBlock1Ptr->trainerHill.timer) / (60 * 60); if (minutes < 12) id = 0; @@ -1078,5 +1103,5 @@ static u16 sub_81D6640(void) else id = 5; - return ptr[id]; + return prizeList[id]; } diff --git a/src/trainer_see.c b/src/trainer_see.c index 22b256a99..72e903728 100644 --- a/src/trainer_see.c +++ b/src/trainer_see.c @@ -14,6 +14,7 @@ #include "util.h" #include "battle_pyramid.h" #include "constants/battle_setup.h" +#include "constants/event_objects.h" #include "constants/event_object_movement_constants.h" #include "constants/field_effects.h" @@ -47,11 +48,11 @@ static bool8 WaitRevealHiddenTrainer(u8 taskId, struct Task *task, struct EventO static void SpriteCB_TrainerIcons(struct Sprite *sprite); // IWRAM common -u16 gUnknown_03006080; -u8 gUnknown_03006084[4]; +u16 gWhichTrainerToFaceAfterBattle; +u8 gPostBattleMovementScript[4]; struct ApproachingTrainer gApproachingTrainers[2]; u8 gNoOfApproachingTrainers; -u8 gUnknown_030060AC; +bool8 gTrainerApproachedPlayer; // EWRAM EWRAM_DATA u8 gApproachingTrainerId = 0; @@ -205,7 +206,7 @@ bool8 CheckForTrainersWantingBattle(void) ResetTrainerOpponentIds(); ConfigureAndSetUpOneTrainerBattle(gApproachingTrainers[gNoOfApproachingTrainers - 1].eventObjectId, gApproachingTrainers[gNoOfApproachingTrainers - 1].trainerScriptPtr); - gUnknown_030060AC = 1; + gTrainerApproachedPlayer = TRUE; return TRUE; } else if (gNoOfApproachingTrainers == 2) @@ -218,12 +219,12 @@ bool8 CheckForTrainersWantingBattle(void) } SetUpTwoTrainersBattle(); gApproachingTrainerId = 0; - gUnknown_030060AC = 1; + gTrainerApproachedPlayer = TRUE; return TRUE; } else { - gUnknown_030060AC = 0; + gTrainerApproachedPlayer = FALSE; return FALSE; } } @@ -764,24 +765,24 @@ u8 GetChosenApproachingTrainerEventObjectId(u8 arrayId) return gApproachingTrainers[1].eventObjectId; } -void sub_80B4808(void) +void PlayerFaceTrainerAfterBattle(void) { - struct EventObject *trainerObj; + struct EventObject *eventObj; - if (gUnknown_030060AC == 1) + if (gTrainerApproachedPlayer == TRUE) { - trainerObj = &gEventObjects[gApproachingTrainers[gUnknown_03006080].eventObjectId]; - gUnknown_03006084[0] = GetFaceDirectionMovementAction(GetOppositeDirection(trainerObj->facingDirection)); - gUnknown_03006084[1] = 0xFE; - ScriptMovement_StartObjectMovementScript(0xFF, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, gUnknown_03006084); + eventObj = &gEventObjects[gApproachingTrainers[gWhichTrainerToFaceAfterBattle].eventObjectId]; + gPostBattleMovementScript[0] = GetFaceDirectionMovementAction(GetOppositeDirection(eventObj->facingDirection)); + gPostBattleMovementScript[1] = MOVEMENT_ACTION_STEP_END; + ScriptMovement_StartObjectMovementScript(EVENT_OBJ_ID_PLAYER, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, gPostBattleMovementScript); } else { - trainerObj = &gEventObjects[gPlayerAvatar.eventObjectId]; - gUnknown_03006084[0] = GetFaceDirectionMovementAction(trainerObj->facingDirection); - gUnknown_03006084[1] = 0xFE; - ScriptMovement_StartObjectMovementScript(0xFF, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, gUnknown_03006084); + eventObj = &gEventObjects[gPlayerAvatar.eventObjectId]; + gPostBattleMovementScript[0] = GetFaceDirectionMovementAction(eventObj->facingDirection); + gPostBattleMovementScript[1] = MOVEMENT_ACTION_STEP_END; + ScriptMovement_StartObjectMovementScript(EVENT_OBJ_ID_PLAYER, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, gPostBattleMovementScript); } - sub_809BE48(0xFF); + SetMovingNpcId(EVENT_OBJ_ID_PLAYER); } @@ -762,7 +762,7 @@ void ClearTVShowData(void) ClearPokemonNews(); } -u8 special_0x44(void) +u8 GetRandomActiveShowIdx(void) { u8 i; u8 j; @@ -771,10 +771,8 @@ u8 special_0x44(void) for (i = 5; i < ARRAY_COUNT(gSaveBlock1Ptr->tvShows) - 1; i ++) { - if (gSaveBlock1Ptr->tvShows[i].common.kind == 0) - { + if (gSaveBlock1Ptr->tvShows[i].common.kind == TVSHOW_OFF_AIR) break; - } } j = Random() % i; selIdx = j; @@ -783,44 +781,38 @@ u8 special_0x44(void) if (GetTVChannelByShowType(gSaveBlock1Ptr->tvShows[j].common.kind) != 4) { if (gSaveBlock1Ptr->tvShows[j].common.active == TRUE) - { return j; - } } else { show = &gSaveBlock1Ptr->tvShows[j]; if (show->massOutbreak.daysLeft == 0 && show->massOutbreak.active == TRUE) - { return j; - } } + if (j == 0) - { j = ARRAY_COUNT(gSaveBlock1Ptr->tvShows) - 2; - } else - { j --; - } + } while (j != selIdx); return 0xFF; } u8 FindAnyTVShowOnTheAir(void) { - u8 response; + u8 show; - response = special_0x44(); - if (response == 0xFF) + show = GetRandomActiveShowIdx(); + if (show == 0xFF) { return 0xFF; } - if (gSaveBlock1Ptr->outbreakPokemonSpecies != SPECIES_NONE && gSaveBlock1Ptr->tvShows[response].common.kind == TVSHOW_MASS_OUTBREAK) + if (gSaveBlock1Ptr->outbreakPokemonSpecies != SPECIES_NONE && gSaveBlock1Ptr->tvShows[show].common.kind == TVSHOW_MASS_OUTBREAK) { return FindFirstActiveTVShowThatIsNotAMassOutbreak(); } - return response; + return show; } void UpdateTVScreensOnMap(int width, int height) @@ -876,7 +868,7 @@ void TurnOnTVScreen(void) DrawWholeMapView(); } -u8 special_0x45(void) +u8 GetSelectedTVShow(void) { return gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004].common.kind; } @@ -887,7 +879,7 @@ u8 FindFirstActiveTVShowThatIsNotAMassOutbreak(void) for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->tvShows) - 1; i ++) { - if (gSaveBlock1Ptr->tvShows[i].common.kind != 0 && gSaveBlock1Ptr->tvShows[i].common.kind != TVSHOW_MASS_OUTBREAK && gSaveBlock1Ptr->tvShows[i].common.active == TRUE) + if (gSaveBlock1Ptr->tvShows[i].common.kind != TVSHOW_OFF_AIR && gSaveBlock1Ptr->tvShows[i].common.kind != TVSHOW_MASS_OUTBREAK && gSaveBlock1Ptr->tvShows[i].common.active == TRUE) { return i; } @@ -895,7 +887,7 @@ u8 FindFirstActiveTVShowThatIsNotAMassOutbreak(void) return 0xFF; } -u8 special_0x4a(void) +u8 GetNextActiveShowIfMassOutbreak(void) { TVShow *tvShow; @@ -2003,7 +1995,7 @@ void sub_80EDC60(const u16 *words) } } -void sub_80EDCE8(void) +void TryPutTreasureInvestigatorsOnAir(void) { TVShow *show; @@ -2298,7 +2290,7 @@ void sub_80EE184(void) } } -void sub_80EE2CC(void) +void TryPutLotteryWinnerReportOnAir(void) { TVShow *show; @@ -2365,7 +2357,7 @@ void sub_80EE44C(u8 nMonsCaught, u8 nPkblkUsed) } } -void sub_80EE4DC(struct Pokemon *pokemon, u8 ribbonMonDataIdx) +void TryPutSpotTheCutiesOnAir(struct Pokemon *pokemon, u8 ribbonMonDataIdx) { TVShow *show; @@ -2440,7 +2432,7 @@ u8 TV_MonDataIdxToRibbon(u8 monDataIdx) return 0; } -void sub_80EE72C(void) +void TrySetUpTrainerFanClubSpecial(void) { TVShow *show; @@ -2458,22 +2450,19 @@ void sub_80EE72C(void) } } -bool8 sub_80EE7C0(void) +bool8 ShouldHideFanClubInterviewer(void) { sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot == -1) - { return TRUE; - } + FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_FAN_CLUB_SPECIAL); if (gSpecialVar_Result == TRUE) - { return TRUE; - } + if (gSaveBlock1Ptr->linkBattleRecords.entries[0].name[0] == EOS) - { return TRUE; - } + return FALSE; } @@ -3149,7 +3138,7 @@ static void InterviewBefore_FanClubSpecial(void) } } -bool8 sub_80EF88C(u8 monIdx) +static bool8 IsPartyMonNicknamedOrNotEnglish(u8 monIdx) { struct Pokemon *pokemon; u8 language; @@ -3164,9 +3153,9 @@ bool8 sub_80EF88C(u8 monIdx) return TRUE; } -bool8 sub_80EF8F8(void) +bool8 IsLeadMonNicknamedOrNotEnglish(void) { - return sub_80EF88C(GetLeadMonIndex()); + return IsPartyMonNicknamedOrNotEnglish(GetLeadMonIndex()); } void DeleteTVShowInArrayByIdx(TVShow *shows, u8 idx) @@ -3436,13 +3425,14 @@ bool8 TV_IsScriptShowKindAlreadyInQueue(void) return FALSE; } -bool8 TV_PutNameRaterShowOnTheAirIfNicknameChanged(void) +bool8 TryPutNameRaterShowOnTheAir(void) { GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, gStringVar1); + + // Nickname wasnt changed if (!StringCompare(gStringVar3, gStringVar1)) - { return FALSE; - } + PutNameRaterShowOnTheAir(); return TRUE; } @@ -3478,22 +3468,18 @@ void ChangeBoxPokemonNickname_CB(void) CB2_ReturnToFieldContinueScriptPlayMapMusic(); } -void TV_CopyNicknameToStringVar1AndEnsureTerminated(void) +void BufferMonNickname(void) { GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, gStringVar1); StringGetEnd10(gStringVar1); } -void TV_CheckMonOTIDEqualsPlayerID(void) +void IsMonOTIDNotPlayers(void) { if (GetPlayerIDAsU32() == GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_OT_ID, NULL)) - { gSpecialVar_Result = FALSE; - } else - { gSpecialVar_Result = TRUE; - } } u8 GetTVChannelByShowType(u8 kind) diff --git a/src/union_room.c b/src/union_room.c index f259a38f0..d6b712558 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -30,6 +30,7 @@ #include "party_menu.h" #include "pokemon_jump.h" #include "random.h" +#include "save_location.h" #include "script.h" #include "script_pokemon_util_80F87D8.h" #include "sound.h" @@ -47,9 +48,11 @@ #include "constants/cable_club.h" #include "constants/game_stat.h" #include "constants/maps.h" +#include "constants/party_menu.h" #include "constants/rgb.h" #include "constants/songs.h" #include "constants/species.h" +#include "constants/union_room.h" EWRAM_DATA u8 sUnionRoomPlayerName[12] = {}; EWRAM_DATA u8 gUnknown_02022C2C = 0; @@ -234,7 +237,7 @@ void sub_8012780(u8 taskId) switch (data->state) { case 0: - if (gSpecialVar_0x8004 == 20 && gSaveBlock2Ptr->frontier.lvlMode == FRONTIER_LVL_OPEN) + if (gSpecialVar_0x8004 == LINK_GROUP_BATTLE_TOWER && gSaveBlock2Ptr->frontier.lvlMode == FRONTIER_LVL_OPEN) gSpecialVar_0x8004++; gUnknown_02022C2C = gUnknown_082F00C4[gSpecialVar_0x8004]; gUnknown_02022C2D = gUnknown_082F00C4[gSpecialVar_0x8004] >> 8; @@ -816,7 +819,7 @@ void sub_80134E8(u8 taskId) switch (data->state) { case 0: - if (gSpecialVar_0x8004 == 20 && gSaveBlock2Ptr->frontier.lvlMode == FRONTIER_LVL_OPEN) + if (gSpecialVar_0x8004 == LINK_GROUP_BATTLE_TOWER && gSaveBlock2Ptr->frontier.lvlMode == FRONTIER_LVL_OPEN) gSpecialVar_0x8004++; gUnknown_02022C2C = gUnknown_082F0530[gSpecialVar_0x8004]; sub_8010F84(gUnknown_02022C2C, 0, 0); @@ -828,7 +831,7 @@ void sub_80134E8(u8 taskId) data->state = 1; break; case 1: - if (PrintOnTextbox(&data->textState, gUnknown_082EFB70[gSpecialVar_0x8004])) + if (PrintOnTextbox(&data->textState, sChooseTrainerTexts[gSpecialVar_0x8004])) data->state = 2; break; case 2: @@ -840,7 +843,7 @@ void sub_80134E8(u8 taskId) data->field_D = AddWindow(&gUnknown_082F017C); FillWindowPixelBuffer(data->field_C, PIXEL_FILL(2)); - sub_80173E0(data->field_C, 0, gUnknown_082EF7DC, 8, 1, 4); + sub_80173E0(data->field_C, 0, sText_ChooseJoinCancel, 8, 1, 4); PutWindowTilemap(data->field_C); CopyWindowToVram(data->field_C, 2); @@ -1077,7 +1080,7 @@ u32 sub_8013B8C(struct UnkStruct_Group *arg0, s32 id) if (gUnknown_02022C2C == 4 && structPtr->unk.field_0.unk_00.unk_01_2 != 3) { - if (!(gSaveBlock2Ptr->specialSaveWarpFlags & 0x80)) + if (!(gSaveBlock2Ptr->specialSaveWarpFlags & CHAMPION_SAVEWARP)) return 1; else if (structPtr->unk.field_0.unk_00.isChampion) return 0; @@ -1469,7 +1472,7 @@ void sub_801440C(u8 taskId) HealPlayerParty(); SavePlayerParty(); LoadPlayerBag(); - sub_8014304(MAP_GROUP(SINGLE_BATTLE_COLOSSEUM), MAP_NUM(SINGLE_BATTLE_COLOSSEUM), 6, 8, USING_SINGLE_BATTLE); + sub_8014304(MAP_GROUP(BATTLE_COLOSSEUM_2P), MAP_NUM(BATTLE_COLOSSEUM_2P), 6, 8, USING_SINGLE_BATTLE); SetMainCallback2(sub_8014384); break; case 2: @@ -1478,7 +1481,7 @@ void sub_801440C(u8 taskId) SavePlayerParty(); LoadPlayerBag(); sub_80143E4(gBlockSendBuffer, TRUE); - sub_8014304(MAP_GROUP(SINGLE_BATTLE_COLOSSEUM), MAP_NUM(SINGLE_BATTLE_COLOSSEUM), 6, 8, USING_DOUBLE_BATTLE); + sub_8014304(MAP_GROUP(BATTLE_COLOSSEUM_2P), MAP_NUM(BATTLE_COLOSSEUM_2P), 6, 8, USING_DOUBLE_BATTLE); SetMainCallback2(sub_8014384); break; case 3: @@ -1487,7 +1490,7 @@ void sub_801440C(u8 taskId) SavePlayerParty(); LoadPlayerBag(); sub_80143E4(gBlockSendBuffer, TRUE); - sub_8014304(MAP_GROUP(DOUBLE_BATTLE_COLOSSEUM), MAP_NUM(DOUBLE_BATTLE_COLOSSEUM), 5, 8, USING_MULTI_BATTLE); + sub_8014304(MAP_GROUP(BATTLE_COLOSSEUM_4P), MAP_NUM(BATTLE_COLOSSEUM_4P), 5, 8, USING_MULTI_BATTLE); SetMainCallback2(sub_8014384); break; case 4: @@ -1896,7 +1899,7 @@ void sub_8014F48(u8 taskId) data->state = 1; break; case 1: - AddTextPrinterToWindow1(gUnknown_082EF7F8); + AddTextPrinterToWindow1(sText_ChooseTrainer); data->state = 2; break; case 2: @@ -2308,7 +2311,9 @@ void sub_80156E0(u8 taskId) data->state = 3; break; case 3: - if ((sub_81B1360() == 8 || sub_81B1360() == 9) && sUnionRoomTrade.field_0 != 0) + if ((GetPartyMenuType() == PARTY_MENU_TYPE_UNION_ROOM_REGISTER + || GetPartyMenuType() == PARTY_MENU_TYPE_UNION_ROOM_TRADE) + && sUnionRoomTrade.field_0 != 0) { id = GetCursorSelectionMonId(); switch (sUnionRoomTrade.field_0) @@ -2876,7 +2881,7 @@ void sub_80156E0(u8 taskId) { sUnionRoomTrade.field_0 = 1; gFieldCallback = sub_80AF128; - sub_81B8904(8, CB2_ReturnToField); + ChooseMonForTradingBoard(PARTY_MENU_TYPE_UNION_ROOM_REGISTER, CB2_ReturnToField); } break; case 52: @@ -2988,7 +2993,7 @@ void sub_80156E0(u8 taskId) gUnionRoomRequestedMonType = data->field_0->arr[taskData[1]].unk.field_0.type; gUnionRoomOfferedSpecies = data->field_0->arr[taskData[1]].unk.field_0.species; gFieldCallback = sub_80AF128; - sub_81B8904(9, CB2_ReturnToField); + ChooseMonForTradingBoard(PARTY_MENU_TYPE_UNION_ROOM_TRADE, CB2_ReturnToField); sub_80156B0(data); sUnionRoomTrade.field_8 = taskData[1]; } @@ -4278,7 +4283,7 @@ void sub_8018220(u8 *unused, struct UnkStruct_URoom *arg1, bool8 arg2) DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, trainerCard->playerName); - StringCopy(arg1->field_174, gUnknown_082EFF50[trainerCard->stars]); + StringCopy(arg1->field_174, sCardColorTexts[trainerCard->stars]); DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, arg1->field_174); ConvertIntToDecimalStringN(arg1->field_C0[2], trainerCard->caughtMonsCount, STR_CONV_MODE_LEFT_ALIGN, 3); |