diff --git a/include/pokemon.h b/include/pokemon.h index c087568..d1f1aa7 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -34,6 +34,7 @@ public: byte rand_reverse_mod(byte modulo_divisor, byte target_mod); byte get_rand_gender_byte(byte index_num, byte attack_DVs); byte get_dex_number(); + bool get_validity(); private: @@ -69,6 +70,7 @@ private: byte ivs[6]; byte ribbons[4]; u32 iv_egg_ability; + bool is_valid; }; #endif diff --git a/include/pokemon_data.h b/include/pokemon_data.h index 01f0804..77874da 100644 --- a/include/pokemon_data.h +++ b/include/pokemon_data.h @@ -29,6 +29,7 @@ extern const bool NUM_ABILITIES[252]; extern const byte MOVESETS[252][32]; extern const byte FIRST_MOVES[252]; extern const std::string_view NAMES[252]; +extern const u16 JPN_NAMES[252][6]; extern const u8 EVOLUTIONS[252]; extern const u8 POWER_POINTS[252]; extern const byte gen_1_index_array[191]; diff --git a/include/save_data_manager.h b/include/save_data_manager.h index 359dbcc..f3d031e 100644 --- a/include/save_data_manager.h +++ b/include/save_data_manager.h @@ -43,6 +43,7 @@ bool is_caught(int dex_num); void set_caught(int dex_num); int get_def_lang(); void set_def_lang(int nLang); +int get_def_lang_num(); int get_gamecode(); int get_version(); int get_language(); diff --git a/include/script_builder.h b/include/script_builder.h index d70ff4b..da3414e 100644 --- a/include/script_builder.h +++ b/include/script_builder.h @@ -173,6 +173,7 @@ private: void callstd(u8 function_index); void release(); void end(); + void killscript(); // ASM commands void push(u16 register_list); diff --git a/source/main.cpp b/source/main.cpp index a10bd74..48668d6 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -39,33 +39,22 @@ RESEARCH: LINK CABLE: - Figure out JP Gen 2 -CONVERSION: -- Add Korean conversion - INJECTION: -- Set flags for the number of Pokemon injected -- Check what happens when the PC is full, but the last Pokemon doesn't exist (is zero) - Hall of Fame / Mystery Gift confirmation -- Korean GS Conversion -- Add in Rare Candies for new Pokemon -- Wonder Card -- Kill script? +- Wonder Card/Kill script +- Add in check for no valid Pokemon SAVE DATA: - Add warning - Add ability to erase - Add check for Hall of Fame - Clear the empty data as part of the initalization -- Fix default language selection TESTING: - Test all the aspects of a Pokemon (Shiny, Pokerus, etc.) - Make sure hall of fame data isn't corrupted - Test all 14 different memory locations -DEBUG: -- Remove number from "game didn't load" text - GENERAL: - Music - Finalize Graphics @@ -73,6 +62,8 @@ GENERAL: - Generalize graphics implementation? Load them only when needed and have one standard function? - Add in sound effects for pressing buttons - Credits (List all programs, people, and code- plus TPCI) +- Simplify the sprite initalization +- Restart the program after a transfer? Transfering twice without restarting corrupts the data (level included?) FUTURE: - Minigame @@ -200,8 +191,8 @@ void game_load_error(void) REG_BG2VOFS = 0; tte_set_pos(40, 24); tte_set_margins(40, 24, 206, 104); - tte_write("The Pokemon save\nfile was not loaded successfully. Please\nrestart the console,\nload the Pokemon\ngame normally, and\nthen upload the\nprogram again."); - tte_write(std::to_string(get_gamecode() >> 8).c_str()); + tte_write("The Pok@mon save\nfile was not loaded successfully.\n\nPlease remove and\nreinsert the Game\nPak, and then press the A button."); + // tte_write(std::to_string(get_gamecode() >> 8).c_str()); key_poll(); while (!key_hit(KEY_A)) { @@ -280,7 +271,7 @@ int main(void) // Set up blend to fade to white/black - int curr_lang_btn_num = 3; + int curr_lang_btn_num = get_def_lang_num(); int old_lang_btn_num = -1; set_arrow_point(curr_lang_btn_num); diff --git a/source/pokemon.cpp b/source/pokemon.cpp index b8df61b..cc494b3 100644 --- a/source/pokemon.cpp +++ b/source/pokemon.cpp @@ -111,8 +111,10 @@ void Pokemon::convert_to_gen_three() species_index_struct == 0 || // Checks that the Pokemon isn't a blank party space species_index_struct != species_index_party) // Checks that the Pokemon isn't a hybrid or an egg { + is_valid = false; return; } + is_valid = true; // Generate PID u32 n_pid = generate_pid(species_index_struct, *(vu32 *)exp % 25, &dvs[0]); for (int i = 0; i < 4; i++) @@ -203,7 +205,7 @@ void Pokemon::convert_to_gen_three() iv_egg_ability |= ((pid[0] & 0x1) ? get_num_abilities(species_index_struct) : 0) << 31; // Origin info - origin_info |= ((caught_data[0] & 0b10000000) << 8); // OT gender - We would shift left 15 bits, but the bit is already shifted over 7 + origin_info |= ((caught_data[1] & 0b10000000) << 8); // OT gender - We would shift left 15 bits, but the bit is already shifted over 7 origin_info |= (4 << 11); // Ball origin_info |= (((gen == 1) ? 4 : 7) << 7); // Game origin_info |= level; // Level met @@ -242,16 +244,68 @@ void Pokemon::convert_to_gen_three() language = get_def_lang(); } - gen_3_pkmn[18] = language; // Language - gen_3_pkmn[19] = 0b00000010; // Egg Name - copy_from_to(convert_text(&nickname[0], 10, gen, language), &gen_3_pkmn[8], 10, false); // Nickname - copy_from_to(convert_text(&trainer_name[0], 7, gen, language), &gen_3_pkmn[20], 7, false); // OT Name - gen_3_pkmn[27] = 0b00000000; // Markings - // ??? + if (language == KOR_ID) + { + + gen_3_pkmn[18] = JPN_ID; // Set to JPN + byte new_nickname[10]; + byte new_ot[7]; + for(int i = 0; i < 6; i++) + { // Read the JPN name and convert it + new_nickname[i] = get_gen_3_char(JPN_NAMES[species_index_struct][i], true); + } + + if (gen == 1) + { + // レッド (Red) + new_ot[0] = 0x7A; // レ + new_ot[1] = 0xA0; // ッ + new_ot[2] = 0x95; // ド + new_ot[3] = 0xFF; + } + else + { + if (((caught_data[1] & 0b10000000) >> 7) == 1) // Checks if the Gen 2 player is male or female + { + // クリス (Kurisu) + new_ot[0] = 0x58; // ク + new_ot[1] = 0x78; // リ + new_ot[2] = 0x5D; // ス + new_ot[3] = 0xFF; + } + else + { + // ヒビキ (Hibiki) + new_ot[0] = 0x6B; // ヒ + new_ot[1] = 0x97; // ビ + new_ot[2] = 0x57; // キ + new_ot[3] = 0xFF; + } + } + copy_from_to(&new_nickname[0], &gen_3_pkmn[8], 10, false); // Nickname + copy_from_to(&new_ot[0], &gen_3_pkmn[20], 7, false); // OT Name + } + else + { + gen_3_pkmn[18] = language; // Language + copy_from_to(convert_text(&nickname[0], 10, gen, language), &gen_3_pkmn[8], 10, false); // Nickname + copy_from_to(convert_text(&trainer_name[0], 7, gen, language), &gen_3_pkmn[20], 7, false); // OT Name + } + gen_3_pkmn[19] = 0b00000010; // Egg Name (has species sanity flag) + gen_3_pkmn[27] = 0b00000000; // Markings // Data: data_section_G[0] = species_index_struct; data_section_G[1] = 0x00; // Species Index, check for glitch Pokemon + if (!is_caught(species_index_struct)) + { + data_section_G[2] = 0x44; + } + else + { + data_section_G[2] = 0x00; + } + data_section_G[3] = 0x00; copy_from_to(&exp[0], &data_section_G[4], 3, false); data_section_G[8] = (pp_bonus[0] << 0 | pp_bonus[1] << 2 | pp_bonus[2] << 4 | pp_bonus[3] << 6); @@ -554,6 +608,12 @@ byte Pokemon::get_rand_gender_byte(byte index_num, byte attack_DVs) } } -byte Pokemon::get_dex_number(){ - return species_index_party; +byte Pokemon::get_dex_number() +{ + return species_index_struct; +} + +bool Pokemon::get_validity() +{ + return is_valid; } \ No newline at end of file diff --git a/source/pokemon_data.cpp b/source/pokemon_data.cpp index a31a2f5..cf024ba 100644 --- a/source/pokemon_data.cpp +++ b/source/pokemon_data.cpp @@ -260,7 +260,6 @@ const byte gen_1_index_array[191] = { 0x46, // Weepinbell 0x47, // Victreebel }; - const u16 gen_1_Jpn_char_array[256]{ 0x20, 0x30A4, @@ -4368,6 +4367,260 @@ const std::string_view NAMES[252]{ "Ho-Oh", "Celebi", }; +const u16 JPN_NAMES[252][6]{ + {}, // Offset the list to remove "off by one" errors + {0x30D5, 0x30B7, 0x30AE, 0x30C0, 0x30CD, 0x19E}, // Bulbasaur + {0x30D5, 0x30B7, 0x30AE, 0x30BD, 0x30A6, 0x19E}, // Ivysaur + {0x30D5, 0x30B7, 0x30AE, 0x30D0, 0x30CA, 0x19E}, // Venusaur + {0x30D2, 0x30C8, 0x30AB, 0x30B2, 0x19E}, // Charmander + {0x30EA, 0x30B6, 0x30FC, 0x30C9, 0x19E}, // Charmeleon + {0x30EA, 0x30B6, 0x30FC, 0x30C9, 0x30F3, 0x19E}, // Charizard + {0x30BC, 0x30CB, 0x30AC, 0x30E1, 0x19E}, // Squirtle + {0x30AB, 0x30E1, 0x30FC, 0x30EB, 0x19E}, // Wartortle + {0x30AB, 0x30E1, 0x30C3, 0x30AF, 0x30B9, 0x19E}, // Blastoise + {0x30AD, 0x30E3, 0x30BF, 0x30D4, 0x30FC, 0x19E}, // Caterpie + {0x30C8, 0x30E9, 0x30F3, 0x30BB, 0x30EB, 0x19E}, // Metapod + {0x30D0, 0x30BF, 0x30D5, 0x30EA, 0x30FC, 0x19E}, // Butterfree + {0x30D3, 0x30FC, 0x30C9, 0x30EB, 0x19E}, // Weedle + {0x30B3, 0x30AF, 0x30FC, 0x30F3, 0x19E}, // Kakuna + {0x30B9, 0x30D4, 0x30A2, 0x30FC, 0x19E}, // Beedrill + {0x30DD, 0x30C3, 0x30DD, 0x19E}, // Pidgey + {0x30D4, 0x30B8, 0x30E7, 0x30F3, 0x19E}, // Pidgeotto + {0x30D4, 0x30B8, 0x30E7, 0x30C3, 0x30C8, 0x19E}, // Pidgeot + {0x30B3, 0x30E9, 0x30C3, 0x30BF, 0x19E}, // Rattata + {0x30E9, 0x30C3, 0x30BF, 0x19E}, // Raticate + {0x30AA, 0x30CB, 0x30B9, 0x30BA, 0x30E1, 0x19E}, // Spearow + {0x30AA, 0x30CB, 0x30C9, 0x30EA, 0x30EB, 0x19E}, // Fearow + {0x30A2, 0x30FC, 0x30DC, 0x19E}, // Ekans + {0x30A2, 0x30FC, 0x30DC, 0x30C3, 0x30AF, 0x19E}, // Arbok + {0x30D4, 0x30AB, 0x30C1, 0x30E5, 0x30A6, 0x19E}, // Pikachu + {0x30E9, 0x30A4, 0x30C1, 0x30E5, 0x30A6, 0x19E}, // Raichu + {0x30B5, 0x30F3, 0x30C9, 0x19E}, // Sandshrew + {0x30B5, 0x30F3, 0x30C9, 0x30D1, 0x30F3, 0x19E}, // Sandslash + {0x30CB, 0x30C9, 0x30E9, 0x30F3, 0x2640, 0x19E}, // Nidoran♀ + {0x30CB, 0x30C9, 0x30EA, 0x30FC, 0x30CA, 0x19E}, // Nidorina + {0x30CB, 0x30C9, 0x30AF, 0x30A4, 0x30F3, 0x19E}, // Nidoqueen + {0x30CB, 0x30C9, 0x30E9, 0x30F3, 0x2642, 0x19E}, // Nidoran♂ + {0x30CB, 0x30C9, 0x30EA, 0x30FC, 0x30CE, 0x19E}, // Nidorino + {0x30CB, 0x30C9, 0x30AD, 0x30F3, 0x30B0, 0x19E}, // Nidoking + {0x30D4, 0x30C3, 0x30D4, 0x19E}, // Clefairy + {0x30D4, 0x30AF, 0x30B7, 0x30FC, 0x19E}, // Clefable + {0x30ED, 0x30B3, 0x30F3, 0x19E}, // Vulpix + {0x30AD, 0x30E5, 0x30A6, 0x30B3, 0x30F3, 0x19E}, // Ninetales + {0x30D7, 0x30EA, 0x30F3, 0x19E}, // Jigglypuff + {0x30D7, 0x30AF, 0x30EA, 0x30F3, 0x19E}, // Wigglytuff + {0x30BA, 0x30D0, 0x30C3, 0x30C8, 0x19E}, // Zubat + {0x30B4, 0x30EB, 0x30D0, 0x30C3, 0x30C8, 0x19E}, // Golbat + {0x30CA, 0x30BE, 0x30CE, 0x30AF, 0x30B5, 0x19E}, // Oddish + {0x30AF, 0x30B5, 0x30A4, 0x30CF, 0x30CA, 0x19E}, // Gloom + {0x30E9, 0x30D5, 0x30EC, 0x30B7, 0x30A2, 0x19E}, // Vileplume + {0x30D1, 0x30E9, 0x30B9, 0x19E}, // Paras + {0x30D1, 0x30E9, 0x30BB, 0x30AF, 0x30C8, 0x19E}, // Parasect + {0x30B3, 0x30F3, 0x30D1, 0x30F3, 0x19E}, // Venonat + {0x30E2, 0x30EB, 0x30D5, 0x30A9, 0x30F3, 0x19E}, // Venomoth + {0x30C7, 0x30A3, 0x30B0, 0x30C0, 0x19E}, // Diglett + {0x30C0, 0x30B0, 0x30C8, 0x30EA, 0x30AA, 0x19E}, // Dugtrio + {0x30CB, 0x30E3, 0x30FC, 0x30B9, 0x19E}, // Meowth + {0x30DA, 0x30EB, 0x30B7, 0x30A2, 0x30F3, 0x19E}, // Persian + {0x30B3, 0x30C0, 0x30C3, 0x30AF, 0x19E}, // Psyduck + {0x30B4, 0x30EB, 0x30C0, 0x30C3, 0x30AF, 0x19E}, // Golduck + {0x30DE, 0x30F3, 0x30AD, 0x30FC, 0x19E}, // Mankey + {0x30AA, 0x30B3, 0x30EA, 0x30B6, 0x30EB, 0x19E}, // Primeape + {0x30AC, 0x30FC, 0x30C7, 0x30A3, 0x19E}, // Growlithe + {0x30A6, 0x30A4, 0x30F3, 0x30C7, 0x30A3, 0x19E}, // Arcanine + {0x30CB, 0x30E7, 0x30ED, 0x30E2, 0x19E}, // Poliwag + {0x30CB, 0x30E7, 0x30ED, 0x30BE, 0x19E}, // Poliwhirl + {0x30CB, 0x30E7, 0x30ED, 0x30DC, 0x30F3, 0x19E}, // Poliwrath + {0x30B1, 0x30FC, 0x30B7, 0x30A3, 0x19E}, // Abra + {0x30E6, 0x30F3, 0x30B2, 0x30E9, 0x30FC, 0x19E}, // Kadabra + {0x30D5, 0x30FC, 0x30C7, 0x30A3, 0x30F3, 0x19E}, // Alakazam + {0x30EF, 0x30F3, 0x30EA, 0x30AD, 0x30FC, 0x19E}, // Machop + {0x30B4, 0x30FC, 0x30EA, 0x30AD, 0x30FC, 0x19E}, // Machoke + {0x30AB, 0x30A4, 0x30EA, 0x30AD, 0x30FC, 0x19E}, // Machamp + {0x30DE, 0x30C0, 0x30C4, 0x30DC, 0x30DF, 0x19E}, // Bellsprout + {0x30A6, 0x30C4, 0x30C9, 0x30F3, 0x19E}, // Weepinbell + {0x30A6, 0x30C4, 0x30DC, 0x30C3, 0x30C8, 0x19E}, // Victreebel + {0x30E1, 0x30CE, 0x30AF, 0x30E9, 0x30B2, 0x19E}, // Tentacool + {0x30C9, 0x30AF, 0x30AF, 0x30E9, 0x30B2, 0x19E}, // Tentacruel + {0x30A4, 0x30B7, 0x30C4, 0x30D6, 0x30C6, 0x19E}, // Geodude + {0x30B4, 0x30ED, 0x30FC, 0x30F3, 0x19E}, // Graveler + {0x30B4, 0x30ED, 0x30FC, 0x30CB, 0x30E3, 0x19E}, // Golem + {0x30DD, 0x30CB, 0x30FC, 0x30BF, 0x19E}, // Ponyta + {0x30AE, 0x30E3, 0x30ED, 0x30C3, 0x30D7, 0x19E}, // Rapidash + {0x30E4, 0x30C9, 0x30F3, 0x19E}, // Slowpoke + {0x30E4, 0x30C9, 0x30E9, 0x30F3, 0x19E}, // Slowbro + {0x30B3, 0x30A4, 0x30EB, 0x19E}, // Magnemite + {0x30EC, 0x30A2, 0x30B3, 0x30A4, 0x30EB, 0x19E}, // Magneton + {0x30AB, 0x30E2, 0x30CD, 0x30AE, 0x19E}, // Farfetch'd + {0x30C9, 0x30FC, 0x30C9, 0x30FC, 0x19E}, // Doduo + {0x30C9, 0x30FC, 0x30C9, 0x30EA, 0x30AA, 0x19E}, // Dodrio + {0x30D1, 0x30A6, 0x30EF, 0x30A6, 0x19E}, // Seel + {0x30B8, 0x30E5, 0x30B4, 0x30F3, 0x19E}, // Dewgong + {0x30D9, 0x30C8, 0x30D9, 0x30BF, 0x30FC, 0x19E}, // Grimer + {0x30D9, 0x30C8, 0x30D9, 0x30C8, 0x30F3, 0x19E}, // Muk + {0x30B7, 0x30A7, 0x30EB, 0x30C0, 0x30FC, 0x19E}, // Shellder + {0x30D1, 0x30EB, 0x30B7, 0x30A7, 0x30F3, 0x19E}, // Cloyster + {0x30B4, 0x30FC, 0x30B9, 0x19E}, // Gastly + {0x30B4, 0x30FC, 0x30B9, 0x30C8, 0x19E}, // Haunter + {0x30B2, 0x30F3, 0x30AC, 0x30FC, 0x19E}, // Gengar + {0x30A4, 0x30EF, 0x30FC, 0x30AF, 0x19E}, // Onix + {0x30B9, 0x30EA, 0x30FC, 0x30D7, 0x19E}, // Drowzee + {0x30B9, 0x30EA, 0x30FC, 0x30D1, 0x30FC, 0x19E}, // Hypno + {0x30AF, 0x30E9, 0x30D6, 0x19E}, // Krabby + {0x30AD, 0x30F3, 0x30B0, 0x30E9, 0x30FC, 0x19E}, // Kingler + {0x30D3, 0x30EA, 0x30EA, 0x30C0, 0x30DE, 0x19E}, // Voltorb + {0x30DE, 0x30EB, 0x30DE, 0x30A4, 0x30F3, 0x19E}, // Electrode + {0x30BF, 0x30DE, 0x30BF, 0x30DE, 0x19E}, // Exeggcute + {0x30CA, 0x30C3, 0x30B7, 0x30FC, 0x19E}, // Exeggutor + {0x30AB, 0x30E9, 0x30AB, 0x30E9, 0x19E}, // Cubone + {0x30AC, 0x30E9, 0x30AC, 0x30E9, 0x19E}, // Marowak + {0x30B5, 0x30EF, 0x30E0, 0x30E9, 0x30FC, 0x19E}, // Hitmonlee + {0x30A8, 0x30D3, 0x30EF, 0x30E9, 0x30FC, 0x19E}, // Hitmonchan + {0x30D9, 0x30ED, 0x30EA, 0x30F3, 0x30AC, 0x19E}, // Lickitung + {0x30C9, 0x30AC, 0x30FC, 0x30B9, 0x19E}, // Koffing + {0x30DE, 0x30BF, 0x30C9, 0x30AC, 0x30B9, 0x19E}, // Weezing + {0x30B5, 0x30A4, 0x30DB, 0x30FC, 0x30F3, 0x19E}, // Rhyhorn + {0x30B5, 0x30A4, 0x30C9, 0x30F3, 0x19E}, // Rhydon + {0x30E9, 0x30C3, 0x30AD, 0x30FC, 0x19E}, // Chansey + {0x30E2, 0x30F3, 0x30B8, 0x30E3, 0x30E9, 0x19E}, // Tangela + {0x30AC, 0x30EB, 0x30FC, 0x30E9, 0x19E}, // Kangaskhan + {0x30BF, 0x30C3, 0x30C4, 0x30FC, 0x19E}, // Horsea + {0x30B7, 0x30FC, 0x30C9, 0x30E9, 0x19E}, // Seadra + {0x30C8, 0x30B5, 0x30AD, 0x30F3, 0x30C8, 0x19E}, // Goldeen + {0x30A2, 0x30BA, 0x30DE, 0x30AA, 0x30A6, 0x19E}, // Seaking + {0x30D2, 0x30C8, 0x30C7, 0x30DE, 0x30F3, 0x19E}, // Staryu + {0x30B9, 0x30BF, 0x30FC, 0x30DF, 0x30FC, 0x19E}, // Starmie + {0x30D0, 0x30EA, 0x30E4, 0x30FC, 0x30C9, 0x19E}, // Mr. Mime + {0x30B9, 0x30C8, 0x30E9, 0x30A4, 0x30AF, 0x19E}, // Scyther + {0x30EB, 0x30FC, 0x30B8, 0x30E5, 0x30E9, 0x19E}, // Jynx + {0x30A8, 0x30EC, 0x30D6, 0x30FC, 0x19E}, // Electabuzz + {0x30D6, 0x30FC, 0x30D0, 0x30FC, 0x19E}, // Magmar + {0x30AB, 0x30A4, 0x30ED, 0x30B9, 0x19E}, // Pinsir + {0x30B1, 0x30F3, 0x30BF, 0x30ED, 0x30B9, 0x19E}, // Tauros + {0x30B3, 0x30A4, 0x30AD, 0x30F3, 0x30B0, 0x19E}, // Magikarp + {0x30AE, 0x30E3, 0x30E9, 0x30C9, 0x30B9, 0x19E}, // Gyarados + {0x30E9, 0x30D7, 0x30E9, 0x30B9, 0x19E}, // Lapras + {0x30E1, 0x30BF, 0x30E2, 0x30F3, 0x19E}, // Ditto + {0x30A4, 0x30FC, 0x30D6, 0x30A4, 0x19E}, // Eevee + {0x30B7, 0x30E3, 0x30EF, 0x30FC, 0x30BA, 0x19E}, // Vaporeon + {0x30B5, 0x30F3, 0x30C0, 0x30FC, 0x30B9, 0x19E}, // Jolteon + {0x30D6, 0x30FC, 0x30B9, 0x30BF, 0x30FC, 0x19E}, // Flareon + {0x30DD, 0x30EA, 0x30B4, 0x30F3, 0x19E}, // Porygon + {0x30AA, 0x30E0, 0x30CA, 0x30A4, 0x30C8, 0x19E}, // Omanyte + {0x30AA, 0x30E0, 0x30B9, 0x30BF, 0x30FC, 0x19E}, // Omastar + {0x30AB, 0x30D6, 0x30C8, 0x19E}, // Kabuto + {0x30AB, 0x30D6, 0x30C8, 0x30D7, 0x30B9, 0x19E}, // Kabutops + {0x30D7, 0x30C6, 0x30E9, 0x19E}, // Aerodactyl + {0x30AB, 0x30D3, 0x30B4, 0x30F3, 0x19E}, // Snorlax + {0x30D5, 0x30EA, 0x30FC, 0x30B6, 0x30FC, 0x19E}, // Articuno + {0x30B5, 0x30F3, 0x30C0, 0x30FC, 0x19E}, // Zapdos + {0x30D5, 0x30A1, 0x30A4, 0x30E4, 0x30FC, 0x19E}, // Moltres + {0x30DF, 0x30CB, 0x30EA, 0x30E5, 0x30A6, 0x19E}, // Dratini + {0x30CF, 0x30AF, 0x30EA, 0x30E5, 0x30FC, 0x19E}, // Dragonair + {0x30AB, 0x30A4, 0x30EA, 0x30E5, 0x30FC, 0x19E}, // Dragonite + {0x30DF, 0x30E5, 0x30A6, 0x30C4, 0x30FC, 0x19E}, // Mewtwo + {0x30DF, 0x30E5, 0x30A6, 0x19E}, // Mew + {0x30C1, 0x30B3, 0x30EA, 0x30FC, 0x30BF, 0x19E}, // Chikorita + {0x30D9, 0x30A4, 0x30EA, 0x30FC, 0x30D5, 0x19E}, // Bayleef + {0x30E1, 0x30AC, 0x30CB, 0x30A6, 0x30E0, 0x19E}, // Meganium + {0x30D2, 0x30CE, 0x30A2, 0x30E9, 0x30B7, 0x19E}, // Cyndaquil + {0x30DE, 0x30B0, 0x30DE, 0x30E9, 0x30B7, 0x19E}, // Quilava + {0x30D0, 0x30AF, 0x30D5, 0x30FC, 0x30F3, 0x19E}, // Typhlosion + {0x30EF, 0x30CB, 0x30CE, 0x30B3, 0x19E}, // Totodile + {0x30A2, 0x30EA, 0x30B2, 0x30A4, 0x30C4, 0x19E}, // Croconaw + {0x30AA, 0x30FC, 0x30C0, 0x30A4, 0x30EB, 0x19E}, // Feraligatr + {0x30AA, 0x30BF, 0x30C1, 0x19E}, // Sentret + {0x30AA, 0x30AA, 0x30BF, 0x30C1, 0x19E}, // Furret + {0x30DB, 0x30FC, 0x30DB, 0x30FC, 0x19E}, // Hoothoot + {0x30E8, 0x30EB, 0x30CE, 0x30BA, 0x30AF, 0x19E}, // Noctowl + {0x30EC, 0x30C7, 0x30A3, 0x30D0, 0x19E}, // Ledyba + {0x30EC, 0x30C7, 0x30A3, 0x30A2, 0x30F3, 0x19E}, // Ledian + {0x30A4, 0x30C8, 0x30DE, 0x30EB, 0x19E}, // Spinarak + {0x30A2, 0x30EA, 0x30A2, 0x30C9, 0x30B9, 0x19E}, // Ariados + {0x30AF, 0x30ED, 0x30D0, 0x30C3, 0x30C8, 0x19E}, // Crobat + {0x30C1, 0x30E7, 0x30F3, 0x30C1, 0x30FC, 0x19E}, // Chinchou + {0x30E9, 0x30F3, 0x30BF, 0x30FC, 0x30F3, 0x19E}, // Lanturn + {0x30D4, 0x30C1, 0x30E5, 0x30FC, 0x19E}, // Pichu + {0x30D4, 0x30A3, 0x19E}, // Cleffa + {0x30D7, 0x30D7, 0x30EA, 0x30F3, 0x19E}, // Igglybuff + {0x30C8, 0x30B2, 0x30D4, 0x30FC, 0x19E}, // Togepi + {0x30C8, 0x30B2, 0x30C1, 0x30C3, 0x30AF, 0x19E}, // Togetic + {0x30CD, 0x30A4, 0x30C6, 0x30A3, 0x19E}, // Natu + {0x30CD, 0x30A4, 0x30C6, 0x30A3, 0x30AA, 0x19E}, // Xatu + {0x30E1, 0x30EA, 0x30FC, 0x30D7, 0x19E}, // Mareep + {0x30E2, 0x30B3, 0x30B3, 0x19E}, // Flaaffy + {0x30C7, 0x30F3, 0x30EA, 0x30E5, 0x30A6, 0x19E}, // Ampharos + {0x30AD, 0x30EC, 0x30A4, 0x30CF, 0x30CA, 0x19E}, // Bellossom + {0x30DE, 0x30EA, 0x30EB, 0x19E}, // Marill + {0x30DE, 0x30EA, 0x30EB, 0x30EA, 0x19E}, // Azumarill + {0x30A6, 0x30BD, 0x30C3, 0x30AD, 0x30FC, 0x19E}, // Sudowoodo + {0x30CB, 0x30E7, 0x30ED, 0x30C8, 0x30CE, 0x19E}, // Politoed + {0x30CF, 0x30CD, 0x30C3, 0x30B3, 0x19E}, // Hoppip + {0x30DD, 0x30DD, 0x30C3, 0x30B3, 0x19E}, // Skiploom + {0x30EF, 0x30BF, 0x30C3, 0x30B3, 0x19E}, // Jumpluff + {0x30A8, 0x30A4, 0x30D1, 0x30E0, 0x19E}, // Aipom + {0x30D2, 0x30DE, 0x30CA, 0x30C3, 0x30C4, 0x19E}, // Sunkern + {0x30AD, 0x30DE, 0x30EF, 0x30EA, 0x19E}, // Sunflora + {0x30E4, 0x30F3, 0x30E4, 0x30F3, 0x30DE, 0x19E}, // Yanma + {0x30A6, 0x30D1, 0x30FC, 0x19E}, // Wooper + {0x30CC, 0x30AA, 0x30FC, 0x19E}, // Quagsire + {0x30A8, 0x30FC, 0x30D5, 0x30A3, 0x19E}, // Espeon + {0x30D6, 0x30E9, 0x30C3, 0x30AD, 0x30FC, 0x19E}, // Umbreon + {0x30E4, 0x30DF, 0x30AB, 0x30E9, 0x30B9, 0x19E}, // Murkrow + {0x30E4, 0x30C9, 0x30AD, 0x30F3, 0x30B0, 0x19E}, // Slowking + {0x30E0, 0x30A6, 0x30DE, 0x19E}, // Misdreavus + {0x30A2, 0x30F3, 0x30CE, 0x30FC, 0x30F3, 0x19E}, // Unown + {0x30BD, 0x30FC, 0x30CA, 0x30F3, 0x30B9, 0x19E}, // Wobbuffet + {0x30AD, 0x30EA, 0x30F3, 0x30EA, 0x30AD, 0x19E}, // Girafarig + {0x30AF, 0x30CC, 0x30AE, 0x30C0, 0x30DE, 0x19E}, // Pineco + {0x30D5, 0x30A9, 0x30EC, 0x30C8, 0x30B9, 0x19E}, // Forretress + {0x30CE, 0x30B3, 0x30C3, 0x30C1, 0x19E}, // Dunsparce + {0x30B0, 0x30E9, 0x30A4, 0x30AC, 0x30FC, 0x19E}, // Gligar + {0x30CF, 0x30AC, 0x30CD, 0x30FC, 0x30EB, 0x19E}, // Steelix + {0x30D6, 0x30EB, 0x30FC, 0x19E}, // Snubbull + {0x30B0, 0x30E9, 0x30F3, 0x30D6, 0x30EB, 0x19E}, // Granbull + {0x30CF, 0x30EA, 0x30FC, 0x30BB, 0x30F3, 0x19E}, // Qwilfish + {0x30CF, 0x30C3, 0x30B5, 0x30E0, 0x19E}, // Scizor + {0x30C4, 0x30DC, 0x30C4, 0x30DC, 0x19E}, // Shuckle + {0x30D8, 0x30E9, 0x30AF, 0x30ED, 0x30B9, 0x19E}, // Heracross + {0x30CB, 0x30E5, 0x30FC, 0x30E9, 0x19E}, // Sneasel + {0x30D2, 0x30E1, 0x30B0, 0x30DE, 0x19E}, // Teddiursa + {0x30EA, 0x30F3, 0x30B0, 0x30DE, 0x19E}, // Ursaring + {0x30DE, 0x30B0, 0x30DE, 0x30C3, 0x30B0, 0x19E}, // Slugma + {0x30DE, 0x30B0, 0x30AB, 0x30EB, 0x30B4, 0x19E}, // Magcargo + {0x30A6, 0x30EA, 0x30E0, 0x30FC, 0x19E}, // Swinub + {0x30A4, 0x30CE, 0x30E0, 0x30FC, 0x19E}, // Piloswine + {0x30B5, 0x30CB, 0x30FC, 0x30B4, 0x19E}, // Corsola + {0x30C6, 0x30C3, 0x30DD, 0x30A6, 0x30AA, 0x19E}, // Remoraid + {0x30AA, 0x30AF, 0x30BF, 0x30F3, 0x19E}, // Octillery + {0x30C7, 0x30EA, 0x30D0, 0x30FC, 0x30C9, 0x19E}, // Delibird + {0x30DE, 0x30F3, 0x30BF, 0x30A4, 0x30F3, 0x19E}, // Mantine + {0x30A8, 0x30A2, 0x30FC, 0x30E0, 0x30C9, 0x19E}, // Skarmory + {0x30C7, 0x30EB, 0x30D3, 0x30EB, 0x19E}, // Houndour + {0x30D8, 0x30EB, 0x30AC, 0x30FC, 0x19E}, // Houndoom + {0x30AD, 0x30F3, 0x30B0, 0x30C9, 0x30E9, 0x19E}, // Kingdra + {0x30B4, 0x30DE, 0x30BE, 0x30A6, 0x19E}, // Phanpy + {0x30C9, 0x30F3, 0x30D5, 0x30A1, 0x30F3, 0x19E}, // Donphan + {0x30DD, 0x30EA, 0x30B4, 0x30F3, 0xFF12, 0x19E}, // Porygon2 + {0x30AA, 0x30C9, 0x30B7, 0x30B7, 0x19E}, // Stantler + {0x30C9, 0x30FC, 0x30D6, 0x30EB, 0x19E}, // Smeargle + {0x30D0, 0x30EB, 0x30AD, 0x30FC, 0x19E}, // Tyrogue + {0x30AB, 0x30DD, 0x30A8, 0x30E9, 0x30FC, 0x19E}, // Hitmontop + {0x30E0, 0x30C1, 0x30E5, 0x30FC, 0x30EB, 0x19E}, // Smoochum + {0x30A8, 0x30EC, 0x30AD, 0x30C3, 0x30C9, 0x19E}, // Elekid + {0x30D6, 0x30D3, 0x30A3, 0x19E}, // Magby + {0x30DF, 0x30EB, 0x30BF, 0x30F3, 0x30AF, 0x19E}, // Miltank + {0x30CF, 0x30D4, 0x30CA, 0x30B9, 0x19E}, // Blissey + {0x30E9, 0x30A4, 0x30B3, 0x30A6, 0x19E}, // Raikou + {0x30A8, 0x30F3, 0x30C6, 0x30A4, 0x19E}, // Entei + {0x30B9, 0x30A4, 0x30AF, 0x30F3, 0x19E}, // Suicune + {0x30E8, 0x30FC, 0x30AE, 0x30E9, 0x30B9, 0x19E}, // Larvitar + {0x30B5, 0x30CA, 0x30AE, 0x30E9, 0x30B9, 0x19E}, // Pupitar + {0x30D0, 0x30F3, 0x30AE, 0x30E9, 0x30B9, 0x19E}, // Tyranitar + {0x30EB, 0x30AE, 0x30A2, 0x19E}, // Lugia + {0x30DB, 0x30A6, 0x30AA, 0x30A6, 0x19E}, // Ho-Oh + {0x30BB, 0x30EC, 0x30D3, 0x30A3, 0x19E}, // Celebi +}; const u8 EVOLUTIONS[252]{ 0, // Offset the list to remove "off by one" errors 0x0, // Bulbasaur is a base evolution diff --git a/source/pokemon_party.cpp b/source/pokemon_party.cpp index ad00e6e..f1e22a8 100644 --- a/source/pokemon_party.cpp +++ b/source/pokemon_party.cpp @@ -46,9 +46,9 @@ byte debug_party_data[GEN2_INT_SIZE + 4] = { // International Gen 2 0x81, 0x00, 0x37, 0x21, 0x2C, 0x2B, 0x25, 0xDA, 0x00, 0x00, 0xA7, 0x00, 0x46, 0x00, 0x5C, 0x00, 0x44, 0x00, 0x28, 0x00, 0x46, 0xFA, 0xAA, 0x1F, 0x1E, 0xC0, 0x00, 0x45, 0xF2, 0x85, 0x81, 0x05, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x13, 0x00, 0x0A, 0x00, 0x09, 0x00, 0x0B, 0x00, 0x0B, 0x00, 0x0A, 0xC9, 0x00, 0x21, 0x27, 0xED, 0x00, 0x25, 0xDA, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2D, 0x11, 0x23, 0x1E, 0x00, 0x00, 0x46, 0x00, 0x82, 0x82, 0x02, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x0D, 0x00, 0x07, 0x00, 0x06, 0x00, 0x07, 0x00, 0x06, 0x00, 0x06, 0xA1, 0x00, 0x21, 0x00, 0x00, 0x00, 0x25, 0xDA, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x8B, 0x23, 0x00, 0x00, 0x00, 0x46, 0x00, 0x83, 0x82, 0x03, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0F, 0x00, 0x08, 0x00, 0x07, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, - 0x97, 0x00, 0x21, 0x00, 0x00, 0x00, 0x25, 0xDA, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDB, 0x87, 0x21, 0x00, 0x00, 0x00, 0x46, 0x00, 0x82, 0x82, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0D, 0x00, 0x07, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x07, - 0xFB, 0x00, 0x21, 0x00, 0x00, 0x00, 0x25, 0xDA, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x34, 0x21, 0x00, 0x00, 0x00, 0x46, 0x00, 0x83, 0x82, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0F, 0x00, 0x07, 0x00, 0x07, 0x00, 0x06, 0x00, 0x07, 0x00, 0x07, - 0x24, 0x00, 0x01, 0x2F, 0x21, 0x00, 0x25, 0xDA, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x23, 0x00, 0x00, 0x00, 0x46, 0x00, 0x82, 0x82, 0x02, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x0D, 0x00, 0x07, 0x00, 0x06, 0x00, 0x05, 0x00, 0x06, 0x00, 0x06, + 0x97, 0x00, 0x21, 0x00, 0x00, 0x00, 0x25, 0xDA, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDB, 0x87, 0x21, 0x00, 0x00, 0x00, 0x46, 0x00, 0x82, 0x02, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0D, 0x00, 0x07, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x07, + 0xFB, 0x00, 0x21, 0x00, 0x00, 0x00, 0x25, 0xDA, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x34, 0x21, 0x00, 0x00, 0x00, 0x46, 0x00, 0x83, 0x02, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0F, 0x00, 0x07, 0x00, 0x07, 0x00, 0x06, 0x00, 0x07, 0x00, 0x07, + 0x24, 0x00, 0x01, 0x2F, 0x21, 0x00, 0x25, 0xDA, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x23, 0x00, 0x00, 0x00, 0x46, 0x00, 0x82, 0x02, 0x02, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x0D, 0x00, 0x07, 0x00, 0x06, 0x00, 0x05, 0x00, 0x06, 0x00, 0x06, 0x8A, 0x91, 0x88, 0x92, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x8A, 0x91, 0x88, 0x92, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, diff --git a/source/save_data_manager.cpp b/source/save_data_manager.cpp index dfacc69..f21e162 100644 --- a/source/save_data_manager.cpp +++ b/source/save_data_manager.cpp @@ -79,6 +79,10 @@ int get_def_lang() } } +int get_def_lang_num(){ + return save_data_array[DEFAULT_LANGUAGE]; +} + void set_def_lang(int nLang) { save_data_array[DEFAULT_LANGUAGE] = nLang; diff --git a/source/script.cpp b/source/script.cpp index 440407a..8a09664 100644 --- a/source/script.cpp +++ b/source/script.cpp @@ -46,15 +46,25 @@ void inject_mystery(Pokemon incoming_party_aray[]) // Set flags flash_read(memory_section_array[1 + ((script.get_offset_flags() + (FLAG_ID_START / 8)) / 0xF80)], &global_memory_buffer[0], 0x1000); - global_memory_buffer[(script.get_offset_flags() + (FLAG_ID_START / 8)) % 0xF80] |= (0b00111111 << (FLAG_ID_START % 8)); // Set "to obtain" flags to 1 - global_memory_buffer[(script.get_offset_flags() + (FLAG_ID_START / 8)) % 0xF80] &= (~0b01000000 << (FLAG_ID_START % 8)); // Set "collected all" flag to 0 + global_memory_buffer[(script.get_offset_flags() + (FLAG_ID_START / 8)) % 0xF80] &= (~0b01111111 << (FLAG_ID_START % 8)); // Set "collected all" flag to 0 and reset the "to obtain" flags + for (int i = 0; i < 6; i++) + { + if (incoming_party_aray[i].get_validity()) + { + global_memory_buffer[(script.get_offset_flags() + (FLAG_ID_START / 8)) % 0xF80] |= ((1 << i) << (FLAG_ID_START % 8)); // Set "to obtain" flags accordingly + } + } + update_memory_buffer_checksum(); flash_write(memory_section_array[1 + ((script.get_offset_flags() + (FLAG_ID_START / 8)) / 0xF80)], &global_memory_buffer[0], 0x1000); // Update and save custom save data for (int i = 0; i < 6; i++) { - set_caught(incoming_party_aray[i].get_dex_number()); // Add the Pokemon to the dream dex + if (incoming_party_aray[i].get_validity()) + { + set_caught(incoming_party_aray[i].get_dex_number()); // Add the Pokemon to the dream dex + } } write_custom_save_data(); } \ No newline at end of file diff --git a/source/script_builder.cpp b/source/script_builder.cpp index c3b5444..9c18857 100644 --- a/source/script_builder.cpp +++ b/source/script_builder.cpp @@ -227,7 +227,8 @@ void mystery_gift_script::build_script(Pokemon incoming_party_array[]) waitmsg(); // Wait for the message waitkeypress(); // Wait for the player to press A/B release(); // Release the player - end(); // End the script + //end(); // End the script + killscript(); // Erase RAMscript /**/ set_jump_destination(JUMP_BOX_FULL); // Set the destination for if the box is full virtualmsgbox(TEXT_FULL); // Display the full box message waitmsg(); // Wait for the message @@ -644,6 +645,12 @@ void mystery_gift_script::end() add_command(1); } +void mystery_gift_script::killscript() +{ + value_buffer[0] = 0x0D; + add_command(1); +} + void mystery_gift_script::init_npc_location(u8 bank, u8 map, u8 npc) { mg_script[0] = 0x33; // File ID?