diff --git a/PCCS b/PCCS index 31ec2e6..8ab65c8 160000 --- a/PCCS +++ b/PCCS @@ -1 +1 @@ -Subproject commit 31ec2e656888d7a99e99f67972b2516fa2ed126c +Subproject commit 8ab65c81df1fea33a0ecc3e0cfef953d249cc4c2 diff --git a/include/script_array.h b/include/script_array.h index f43f4db..a3576a7 100644 --- a/include/script_array.h +++ b/include/script_array.h @@ -62,8 +62,6 @@ extern const script_obj_params transfer_script_params[]; extern const script_obj_params event_script_params[]; extern rom_data curr_GBA_rom; -void populate_lang_menu(); -void populate_game_menu(int lang); bool run_conditional(int index); // These should be removed eventually, or added to PCCS. diff --git a/source/box_menu.cpp b/source/box_menu.cpp index d9cdac2..8c61c77 100644 --- a/source/box_menu.cpp +++ b/source/box_menu.cpp @@ -16,6 +16,7 @@ Box_Menu::Box_Menu() {}; int Box_Menu::box_main(PokeBox* box) { + PokemonTables pkmnTables; u8 names_decompression_buffer[2048]; u8 single_name_buffer[16]; const u8 **chunkList; @@ -143,7 +144,7 @@ int Box_Menu::box_main(PokeBox* box) u32 nameEntryIndex = curr_pkmn->getSpeciesIndexNumber(); tte_set_pos(6, 88); - curr_pkmn->externalConvertNickname(val); + curr_pkmn->externalConvertNickname(&pkmnTables, val); ptgb_write_simple(val, true); if (curr_pkmn->getIsShiny()) { diff --git a/source/dbg/debug_menu_functions.cpp b/source/dbg/debug_menu_functions.cpp index bc1fc6c..381426b 100644 --- a/source/dbg/debug_menu_functions.cpp +++ b/source/dbg/debug_menu_functions.cpp @@ -233,7 +233,7 @@ void dbg_inject_pkmn(void *context, unsigned user_param) PokemonTables tables; tables.load_gen3_charset(game_lang); - Gen3Pokemon celebi(&tables); + Gen3Pokemon celebi; celebi.loadData(RSEFL_10_ANIV_Celebi_0BF5_ENG_, false); // front_sprite_tile_id is reserved behind the box sprites diff --git a/source/mystery_gift_injector.cpp b/source/mystery_gift_injector.cpp index 4c6ea1e..bdd28df 100644 --- a/source/mystery_gift_injector.cpp +++ b/source/mystery_gift_injector.cpp @@ -56,6 +56,7 @@ static u16 calc_crc16(const u8 *buffer, u32 size) // Implementation taken from P /** * @brief This function injects the PokeBox pokémons into section30 at offset 0x0, which is what the payload expects. + * It assumes that all the pokemons in the box are already converted. (should be done by script_array.cpp) * * @param box pointer to the PokeBox instance containing the Pokémon to inject. * @param section30Buffer The buffer representing section 30 of the save file. @@ -65,7 +66,6 @@ static void __attribute__((noinline)) injectBoxIntoSection30(PokeBox* box, u8* s u8 dex_nums[MAX_PKMN_IN_BOX] = {}; u8 *curSection30 = section30Buffer; - box->convertAll(); for (int i = 0; i < MAX_PKMN_IN_BOX; i++) // Add in the Pokemon data { Gen3Pokemon *curr_pkmn = box->getGen3Pokemon(i); diff --git a/source/script_array.cpp b/source/script_array.cpp index 4ea23b9..9245556 100644 --- a/source/script_array.cpp +++ b/source/script_array.cpp @@ -17,8 +17,7 @@ #include int last_error; -PokemonTables pokeTable; -PokeBox box(&pokeTable); +PokeBox box; Select_Menu langs(false, LANG_MENU, 18, 0); Select_Menu games(false, CART_MENU, 18, 0); @@ -487,55 +486,10 @@ const script_obj_params event_script_params[SCRIPT_SIZE] = { {}, // COND_CHECK_MISSINGNO }; -void populate_lang_menu() +static void __attribute__((noinline)) convertPokeBox() { - langs.clear_options(); - - langs.add_option(GENERAL_option_english, ENG_ID); - langs.add_option(GENERAL_option_japanese, JPN_ID); - langs.add_option(GENERAL_option_spanish, SPA_ID); - langs.add_option(GENERAL_option_french, FRE_ID); - langs.add_option(GENERAL_option_german, GER_ID); - langs.add_option(GENERAL_option_italian, ITA_ID); - langs.add_option(GENERAL_option_korean, KOR_ID); - // TODO: Removing the cancel option for the time being, since canceling the - // link trade when there is no link connection crashes the game - // langs.add_option(GENERAL_option_cancel, UINT8_MAX); -} - -void populate_game_menu(int lang) -{ - games.clear_options(); - - switch (lang) - { - case (JPN_ID): - games.add_option(GENERAL_option_red, RED_ID); - games.add_option(GENERAL_option_green, GREEN_ID); - games.add_option(GENERAL_option_blue, BLUE_ID); - games.add_option(GENERAL_option_yellow, YELLOW_ID); - games.add_option(GENERAL_option_gold, GOLD_ID); - games.add_option(GENERAL_option_silver, SILVER_ID); - games.add_option(GENERAL_option_crystal, CRYSTAL_ID); - games.add_option(GENERAL_option_cancel, UINT8_MAX); - break; - - case (KOR_ID): - games.add_option(GENERAL_option_gold, GOLD_ID); - games.add_option(GENERAL_option_silver, SILVER_ID); - games.add_option(GENERAL_option_cancel, UINT8_MAX); - break; - - default: - games.add_option(GENERAL_option_red, RED_ID); - games.add_option(GENERAL_option_blue, BLUE_ID); - games.add_option(GENERAL_option_yellow, YELLOW_ID); - games.add_option(GENERAL_option_gold, GOLD_ID); - games.add_option(GENERAL_option_silver, SILVER_ID); - games.add_option(GENERAL_option_crystal, CRYSTAL_ID); - games.add_option(GENERAL_option_cancel, UINT8_MAX); - break; - } + PokemonTables tables; + box.convertAll(&tables); } bool run_conditional(int index) @@ -709,8 +663,8 @@ bool run_conditional(int index) obj_unhide(gb_flag, 0); obj_set_pos(gb_flag, 1.5 * 8, 14 * 8); - globalLinkCable.skipPrint = false; - globalLinkCable.pauseOnPacket = true; + // globalLinkCable.skipPrint = false; + // globalLinkCable.pauseOnPacket = true; byte boxDataArray[1122]; @@ -727,9 +681,9 @@ bool run_conditional(int index) return true; case CMD_IMPORT_POKEMON: + convertPokeBox(); inject_mystery(&box); return true; - case CMD_BACK_TO_MENU: set_text_exit(); REG_BG1HOFS = 0; diff --git a/tools/gba-payload-generator/include/script_array.h b/tools/gba-payload-generator/include/script_array.h index 6367cd4..2f1ae9a 100644 --- a/tools/gba-payload-generator/include/script_array.h +++ b/tools/gba-payload-generator/include/script_array.h @@ -63,8 +63,6 @@ extern const script_obj_params transfer_script_params[]; extern const script_obj_params event_script_params[]; extern rom_data curr_GBA_rom; -void populate_lang_menu(); -void populate_game_menu(int lang); bool run_conditional(int index); #endif \ No newline at end of file