diff --git a/include/debug_mode.h b/include/debug_mode.h index e84b77f..da1355e 100644 --- a/include/debug_mode.h +++ b/include/debug_mode.h @@ -6,7 +6,7 @@ #define IGNORE_LINK_CABLE true #define IGNORE_MG_E4_FLAGS true -#define DEBUG_GAME EMERALD_ID +#define DEBUG_GAME RUBY_ID #define DEBUG_VERS VERS_1_0 #define DEBUG_LANG LANG_ENG diff --git a/include/mystery_gift_builder.h b/include/mystery_gift_builder.h index 1c4b495..2248ebb 100644 --- a/include/mystery_gift_builder.h +++ b/include/mystery_gift_builder.h @@ -87,7 +87,7 @@ private: void setvirtualaddress(u32 location); void lock(); void faceplayer(); - void checkflag(u8 flag_id); + void checkflag(u16 flag_id); void virtualgotoif(u8 condition, u32 location); void virtualmsgbox(u32 location); void waitmsg(); diff --git a/include/rom_data.h b/include/rom_data.h index 8a762b5..75333eb 100644 --- a/include/rom_data.h +++ b/include/rom_data.h @@ -2,6 +2,7 @@ #define ROM_POINTERS_H #include +#include "rom_values/base_rom_struct.h" #define RUBY_ID 0x415856 // AXV #define SAPPHIRE_ID 0x415850 // AXP @@ -60,6 +61,9 @@ public: u8 def_map_bank; u8 def_map_id; u8 def_npc_id; + + private: + void fill_values(const ROM_DATA *rom_values); }; #endif \ No newline at end of file diff --git a/include/rom_values/base_rom_struct.h b/include/rom_values/base_rom_struct.h new file mode 100644 index 0000000..0fdbb78 --- /dev/null +++ b/include/rom_values/base_rom_struct.h @@ -0,0 +1,67 @@ +#ifndef BASE_ROM_STRUCT_H +#define BASE_ROM_STRUCT_H + +#include + +#define RUBY_ID 0x415856 // AXV +#define SAPPHIRE_ID 0x415850 // AXP +#define FIRERED_ID 0x425052 // BPR +#define LEAFGREEN_ID 0x425047 // BPG +#define EMERALD_ID 0x425045 // BPE + +#define VERS_1_0 0 +#define VERS_1_1 1 +#define VERS_1_2 2 + +#define LANG_JPN 'J' +#define LANG_ENG 'E' +#define LANG_FRE 'F' +#define LANG_GER 'D' +#define LANG_ITA 'I' +#define LANG_SPA 'S' + +#define TEXT_KANTO 0 +#define TEXT_HOENN 1 + +#define NUM_ROMS 11 + +struct ROM_DATA +{ + bool is_valid; + + int gamecode; + int version; + int language; + + int loc_copyMonToPC; + int loc_gSpecialVar_0x8000; + int loc_gSaveBlock1; // Only used in R/S + int loc_gSaveBlock1PTR; // Only used in FR/LG/E + int loc_getSetPokedexFlag; + int loc_gSaveDataBuffer; // The location of the saveDataBuffer + int loc_readFlashSector; + int offset_ramscript; // Ramscript offset as found within the SaveBlock1 struct in global.h + int offset_flags; // Flag offset as found within the SaveBlock1 struct in global.h + int offset_wondercard; + int offset_script; + int text_region; + + // PKHeX's list of flags is useful for making sure the detection is accurate: https://github.com/kwsch/PKHeX/blob/78a557c3cdaa6f48b42cc96df8ccb4d20b897937/PKHeX.Core/Resources/text/other/flags_rs.txt + int e4_flag; // The flag that is set when you become champion. Often listed as "GAME_CLEAR" + int mg_flag; // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS + int unused_flag_start; // The start of the unused flags and must have 31 open flags in a row + + u8 map_bank; + u8 map_id; + u8 npc_id; + + u8 def_map_bank; + u8 def_map_id; + u8 def_npc_id; + + u8 test_map_bank; + u8 test_map_id; + u8 test_npc_id; +}; + +#endif \ No newline at end of file diff --git a/include/rom_values/rom_values_eng.h b/include/rom_values/rom_values_eng.h new file mode 100644 index 0000000..7d4a605 --- /dev/null +++ b/include/rom_values/rom_values_eng.h @@ -0,0 +1,311 @@ +#ifndef ROM_VALUES_ENG_H +#define ROM_VALUES_ENG_H + +#include "rom_values/base_rom_struct.h" + +const struct ROM_DATA ENG_RUBY_v0 = { + .is_valid = true, + + .gamecode = RUBY_ID, + .version = VERS_1_0, + .language = LANG_ENG, + + .loc_copyMonToPC = 0x0803D998, // Known as "SendMonToPC" + .loc_gSpecialVar_0x8000 = 0x0202E8C4, + .loc_gSaveBlock1 = 0x02025734, + .loc_getSetPokedexFlag = 0x08090D90, + .loc_gSaveDataBuffer = 0x02000000, // Known as "gSharedMem" in RS + .loc_readFlashSector = 0x08125BF8, // Known as "DoReadFlashWholeSection" in RS + + // The following should be consistant across languages and revisions. + .offset_ramscript = 0x3690, // Ramscript offset as found within the SaveBlock1 struct in global.h + .offset_flags = 0x1220, // Flag offset as found within the SaveBlock1 struct in global.h + .offset_script = 0x0810, + .text_region = TEXT_HOENN, + + // PKHeX's list of flags is useful for making sure the detection is accurate: https://github.com/kwsch/PKHeX/blob/78a557c3cdaa6f48b42cc96df8ccb4d20b897937/PKHeX.Core/Resources/text/other/flags_rs.txt + .e4_flag = 0x800 + 0x04, // The flag that is set when you become champion. Often listed as "GAME_CLEAR" + .mg_flag = 0x800 + 0x4C, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS + .unused_flag_start = 0x21, // The start of the unused flags and must have 31 open flags in a row + + .map_bank = 20, + .map_id = 2, + .npc_id = 1, + + .def_map_bank = 8, + .def_map_id = 1, + .def_npc_id = 1, + + .test_map_bank = 2, + .test_map_id = 2, + .test_npc_id = 3, +}; +const struct ROM_DATA ENG_SAPPHIRE_v0 = { + .is_valid = true, + + .gamecode = SAPPHIRE_ID, + .version = VERS_1_0, + .language = LANG_ENG, + + .loc_copyMonToPC = 0x0803D998, // Known as "SendMonToPC" + .loc_gSpecialVar_0x8000 = 0x0202E8C4, + .loc_gSaveBlock1 = 0x02025734, + .loc_getSetPokedexFlag = 0x08090D90, + .loc_gSaveDataBuffer = 0x02000000, // Known as "gSharedMem" in RS + .loc_readFlashSector = 0x08125BF8, // Known as "DoReadFlashWholeSection" in RS + + // The following should be consistant across languages and revisions. + .offset_ramscript = 0x3690, // Ramscript offset as found within the SaveBlock1 struct in global.h + .offset_flags = 0x1220, // Flag offset as found within the SaveBlock1 struct in global.h + .offset_script = 0x0810, + .text_region = TEXT_HOENN, + + // PKHeX's list of flags is useful for making sure the detection is accurate: https://github.com/kwsch/PKHeX/blob/78a557c3cdaa6f48b42cc96df8ccb4d20b897937/PKHeX.Core/Resources/text/other/flags_rs.txt + .e4_flag = 0x800 + 0x04, // The flag that is set when you become champion. Often listed as "GAME_CLEAR" + .mg_flag = 0x800 + 0x4C, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS + .unused_flag_start = 0x21, // The start of the unused flags and must have 31 open flags in a row + + .map_bank = 20, + .map_id = 2, + .npc_id = 1, + + .def_map_bank = 8, + .def_map_id = 1, + .def_npc_id = 1, + + .test_map_bank = 2, + .test_map_id = 2, + .test_npc_id = 3, +}; +const struct ROM_DATA ENG_RUBY_v1 = { + .is_valid = true, + + .gamecode = RUBY_ID, + .version = VERS_1_1, + .language = LANG_ENG, + + .loc_copyMonToPC = 0x0803D998, // Known as "SendMonToPC" + .loc_gSpecialVar_0x8000 = 0x0202E8C4, + .loc_gSaveBlock1 = 0x02025734, + .loc_getSetPokedexFlag = 0x08090D90, + .loc_gSaveDataBuffer = 0x02000000, // Known as "gSharedMem" in RS + .loc_readFlashSector = 0x08125BF8, // Known as "DoReadFlashWholeSection" in RS + + // The following should be consistant across languages and revisions. + .offset_ramscript = 0x3690, // Ramscript offset as found within the SaveBlock1 struct in global.h + .offset_flags = 0x1220, // Flag offset as found within the SaveBlock1 struct in global.h + .offset_script = 0x0810, + .text_region = TEXT_HOENN, + + // PKHeX's list of flags is useful for making sure the detection is accurate: https://github.com/kwsch/PKHeX/blob/78a557c3cdaa6f48b42cc96df8ccb4d20b897937/PKHeX.Core/Resources/text/other/flags_rs.txt + .e4_flag = 0x800 + 0x04, // The flag that is set when you become champion. Often listed as "GAME_CLEAR" + .mg_flag = 0x800 + 0x4C, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS + .unused_flag_start = 0x21, // The start of the unused flags and must have 31 open flags in a row + + .map_bank = 20, + .map_id = 2, + .npc_id = 1, + + .def_map_bank = 8, + .def_map_id = 1, + .def_npc_id = 1, + + .test_map_bank = 2, + .test_map_id = 2, + .test_npc_id = 3, +}; +const struct ROM_DATA ENG_SAPPHIRE_v1 = {0}; +const struct ROM_DATA ENG_RUBY_v2 = {0}; +const struct ROM_DATA ENG_SAPPHIRE_v2 = {0}; +const struct ROM_DATA ENG_FIRERED_v0 = { + .is_valid = true, + + .gamecode = FIRERED_ID, + .version = VERS_1_0, + .language = LANG_ENG, + + .loc_copyMonToPC = 0x08040B90, // Known as "SendMonToPC" + .loc_gSpecialVar_0x8000 = 0x020370B8, + .loc_gSaveBlock1PTR = 0x03005008, + .loc_getSetPokedexFlag = 0x08088E8C, + .loc_gSaveDataBuffer = 0x02039A38, // The location of the saveDataBuffer + .loc_readFlashSector = 0x080DA190, + + // The following should be consistant across languages and revisions. + .offset_ramscript = 0x361C, // Ramscript offset as found within the SaveBlock1 struct in global.h + .offset_flags = 0x0EE0, // Flag offset as found within the SaveBlock1 struct in global.h + .offset_wondercard = 0x0460, + .offset_script = 0x079C, + .text_region = TEXT_KANTO, + + // PKHeX's list of flags is useful for making sure the detection is accurate: https://github.com/kwsch/PKHeX/blob/78a557c3cdaa6f48b42cc96df8ccb4d20b897937/PKHeX.Core/Resources/text/other/flags_rs.txt + .e4_flag = 0x860 + 0x04, // The flag that is set when you become champion. Often listed as "GAME_CLEAR" + .mg_flag = 0x860 + 0x7B, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS + .unused_flag_start = 0x20, // The start of the unused flags and must have 31 open flags in a row + + .map_bank = 30, + .map_id = 0, + .npc_id = 1, + + .def_map_bank = 0xFF, + .def_map_id = 0xFF, + .def_npc_id = 0xFF, + + .test_map_bank = 7, + .test_map_id = 3, + .test_npc_id = 2, +}; +const struct ROM_DATA ENG_LEAFGREEN_v0 = { + .is_valid = true, + + .gamecode = LEAFGREEN_ID, + .version = VERS_1_0, + .language = LANG_ENG, + + .loc_copyMonToPC = 0x08040B90, + .loc_gSpecialVar_0x8000 = 0x020370B8, + .loc_gSaveBlock1PTR = 0x03005008, + .loc_getSetPokedexFlag = 0x08088E48, + .loc_gSaveDataBuffer = 0x02039A38, // The location of the saveDataBuffer + .loc_readFlashSector = 0x080DA164, + + // The following should be consistant across languages and revisions. + .offset_ramscript = 0x361C, // Ramscript offset as found within the SaveBlock1 struct in global.h + .offset_flags = 0x0EE0, // Flag offset as found within the SaveBlock1 struct in global.h + .offset_wondercard = 0x0460, + .offset_script = 0x079C, + .text_region = TEXT_KANTO, + + // PKHeX's list of flags is useful for making sure the detection is accurate: https://github.com/kwsch/PKHeX/blob/78a557c3cdaa6f48b42cc96df8ccb4d20b897937/PKHeX.Core/Resources/text/other/flags_rs.txt + .e4_flag = 0x860 + 0x04, // The flag that is set when you become champion. Often listed as "GAME_CLEAR" + .mg_flag = 0x860 + 0x7B, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS + .unused_flag_start = 0x20, // The start of the unused flags and must have 31 open flags in a row + + .map_bank = 30, + .map_id = 0, + .npc_id = 1, + + .def_map_bank = 0xFF, + .def_map_id = 0xFF, + .def_npc_id = 0xFF, + + .test_map_bank = 7, + .test_map_id = 3, + .test_npc_id = 2, +}; +const struct ROM_DATA ENG_FIRERED_v1 = { + .is_valid = true, + + .gamecode = FIRERED_ID, + .version = VERS_1_1, + .language = LANG_ENG, + + .loc_copyMonToPC = 0x08040BA4, + .loc_gSpecialVar_0x8000 = 0x020370B8, + .loc_gSaveBlock1PTR = 0x03005008, + .loc_getSetPokedexFlag = 0x08088E88, + .loc_gSaveDataBuffer = 0x02039A38, // The location of the saveDataBuffer + .loc_readFlashSector = 0x080DA1A4, + + // The following should be consistant across languages and revisions. + .offset_ramscript = 0x361C, // Ramscript offset as found within the SaveBlock1 struct in global.h + .offset_flags = 0x0EE0, // Flag offset as found within the SaveBlock1 struct in global.h + .offset_wondercard = 0x0460, + .offset_script = 0x079C, + .text_region = TEXT_KANTO, + + // PKHeX's list of flags is useful for making sure the detection is accurate: https://github.com/kwsch/PKHeX/blob/78a557c3cdaa6f48b42cc96df8ccb4d20b897937/PKHeX.Core/Resources/text/other/flags_rs.txt + .e4_flag = 0x860 + 0x04, // The flag that is set when you become champion. Often listed as "GAME_CLEAR" + .mg_flag = 0x860 + 0x7B, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS + .unused_flag_start = 0x20, // The start of the unused flags and must have 31 open flags in a row + + .map_bank = 30, + .map_id = 0, + .npc_id = 1, + + .def_map_bank = 0xFF, + .def_map_id = 0xFF, + .def_npc_id = 0xFF, + + .test_map_bank = 7, + .test_map_id = 3, + .test_npc_id = 2, +}; +const struct ROM_DATA ENG_LEAFGREEN_v1 = { + .is_valid = true, + + .gamecode = LEAFGREEN_ID, + .version = VERS_1_1, + .language = LANG_ENG, + + .loc_copyMonToPC = 0x08040BA4, + .loc_gSpecialVar_0x8000 = 0x020370B8, + .loc_gSaveBlock1PTR = 0x03005008, + .loc_getSetPokedexFlag = 0x08088E74, + .loc_gSaveDataBuffer = 0x02039A38, // The location of the saveDataBuffer + .loc_readFlashSector = 0x080DA178, + + // The following should be consistant across languages and revisions. + .offset_ramscript = 0x361C, // Ramscript offset as found within the SaveBlock1 struct in global.h + .offset_flags = 0x0EE0, // Flag offset as found within the SaveBlock1 struct in global.h + .offset_wondercard = 0x0460, + .offset_script = 0x079C, + .text_region = TEXT_KANTO, + + // PKHeX's list of flags is useful for making sure the detection is accurate: https://github.com/kwsch/PKHeX/blob/78a557c3cdaa6f48b42cc96df8ccb4d20b897937/PKHeX.Core/Resources/text/other/flags_rs.txt + .e4_flag = 0x860 + 0x04, // The flag that is set when you become champion. Often listed as "GAME_CLEAR" + .mg_flag = 0x860 + 0x7B, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS + .unused_flag_start = 0x20, // The start of the unused flags and must have 31 open flags in a row + + .map_bank = 30, + .map_id = 0, + .npc_id = 1, + + .def_map_bank = 0xFF, + .def_map_id = 0xFF, + .def_npc_id = 0xFF, + + .test_map_bank = 7, + .test_map_id = 3, + .test_npc_id = 2, +}; +const struct ROM_DATA ENG_EMERALD_v0 = { + .is_valid = true, + + .gamecode = EMERALD_ID, + .version = VERS_1_0, + .language = LANG_ENG, + + .loc_copyMonToPC = 0x0806B490, + .loc_gSpecialVar_0x8000 = 0x020375D8, + .loc_gSaveBlock1PTR = 0x03005D8C, + .loc_getSetPokedexFlag = 0x080C0664, + .loc_gSaveDataBuffer = 0x0203ABBC, // The location of the saveDataBuffer + .loc_readFlashSector = 0x0815314C, + + // The following should be consistant across languages and revisions. + .offset_ramscript = 0x3728, // Ramscript offset as found within the SaveBlock1 struct in global.h + .offset_flags = 0x1270, // Flag offset as found within the SaveBlock1 struct in global.h + .offset_wondercard = 0x056C, + .offset_script = 0x08A8, + .text_region = TEXT_HOENN, + + // PKHeX's list of flags is useful for making sure the detection is accurate: https://github.com/kwsch/PKHeX/blob/78a557c3cdaa6f48b42cc96df8ccb4d20b897937/PKHeX.Core/Resources/text/other/flags_rs.txt + .e4_flag = 0x860 + 0x04, // The flag that is set when you become champion. Often listed as "GAME_CLEAR" + .mg_flag = 0x860 + 0x7B, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS + .unused_flag_start = 0x20, // The start of the unused flags and must have 31 open flags in a row + + .map_bank = 20, + .map_id = 2, + .npc_id = 1, + + .def_map_bank = 0xFF, + .def_map_id = 0xFF, + .def_npc_id = 0xFF, + + .test_map_bank = 5, + .test_map_id = 4, + .test_npc_id = 2, +}; + +#endif \ No newline at end of file diff --git a/source/mystery_gift_builder.cpp b/source/mystery_gift_builder.cpp index b5aade6..d02859c 100644 --- a/source/mystery_gift_builder.cpp +++ b/source/mystery_gift_builder.cpp @@ -109,6 +109,7 @@ void mystery_gift_script::build_script(Pokemon_Party &incoming_box_data) textbox_var textReceived(asm_variable_list, &curr_index); textbox_var textPCFull(asm_variable_list, &curr_index); textbox_var textThank(asm_variable_list, &curr_index); + textbox_var textTest(asm_variable_list, &curr_index); // Ş = Wait for button and scroll text // ȼ = Wait for button and clear text @@ -123,6 +124,7 @@ void mystery_gift_script::build_script(Pokemon_Party &incoming_box_data) textThank.set_text(u"Thanks for helping out FENNEL!"); textPCFull.set_text(u"The PC is full…ȼGo make some more room!"); textReceived.set_text(u"ȆÀÁƲÀ’S POKÉMON were sent to theŇPC!"); + textTest.set_text(u"Testing..."); // Located at 0x?8A8 in the .sav init_npc_location(curr_rom.map_bank, curr_rom.map_id, curr_rom.npc_id); // Set the location of the NPC @@ -158,6 +160,7 @@ void mystery_gift_script::build_script(Pokemon_Party &incoming_box_data) jumpLoop.set_start(); // Set the jump destination for the JUMP_LOOP call(ptr_call_check_flag); // Call the check flag ASM virtualgotoif(COND_FLAGFALSE, jumpPkmnCollected.add_reference(2)); // If the "pokemon collected" flag is false, jump to the end of the loop + call(ptr_callASM); // Call readFlash ASM addvar(var_script_ptr_low, mainAsmStart.add_reference(3, &readFlashStart)); @@ -167,7 +170,7 @@ void mystery_gift_script::build_script(Pokemon_Party &incoming_box_data) addvar(var_script_ptr_low, dexAsmStart.add_reference(3, &mainAsmStart)); // add to the CallASM offset so that it points to PTR_DEX_START instead setvar(var_dex_seen_caught, 2); // set the seen caught variable to 2, so that the Pokemon is set to "seen" call(ptr_callASM); // call "PTR_DEX_START" - addvar(var_dex_seen_caught, 1); // add 1 to the seen caught variable so that the Pokemon will be "Caught" + addvar(var_dex_seen_caught, 1); // add 1 to the seen caught variable so that the Pokemon will be "Caught" call(ptr_callASM); // Call "PTR_DEX_START" again subvar(var_script_ptr_low, dexAsmStart.add_reference(3, &mainAsmStart)); // subtract from the CallASM offset so that it points to CALL_ASM again subvar(var_script_ptr_low, mainAsmStart.add_reference(3, &readFlashStart)); @@ -200,6 +203,7 @@ void mystery_gift_script::build_script(Pokemon_Party &incoming_box_data) textThank.insert_text(mg_script); textPCFull.insert_text(mg_script); textReceived.insert_text(mg_script); + textTest.insert_text(mg_script); four_align(); // Align the code so that it is byte aligned readFlashStart.set_start(); @@ -370,7 +374,7 @@ void mystery_gift_script::faceplayer() add_command(1); } -void mystery_gift_script::checkflag(u8 flag_id) +void mystery_gift_script::checkflag(u16 flag_id) { value_buffer[0] = 0x2B; value_buffer[1] = flag_id >> 0; diff --git a/source/rom_data.cpp b/source/rom_data.cpp index 534e0f3..1a257d8 100644 --- a/source/rom_data.cpp +++ b/source/rom_data.cpp @@ -2,10 +2,25 @@ #include "mystery_gift_builder.h" #include "pokemon_party.h" #include "pokemon_data.h" +#include "rom_values/rom_values_eng.h" rom_data::rom_data() {} bool rom_data::load_rom() { + const ROM_DATA *list_of_roms[NUM_ROMS] = { + &ENG_RUBY_v0, + &ENG_SAPPHIRE_v0, + &ENG_RUBY_v1, + &ENG_SAPPHIRE_v1, + &ENG_RUBY_v2, + &ENG_SAPPHIRE_v2, + &ENG_FIRERED_v0, + &ENG_LEAFGREEN_v0, + &ENG_FIRERED_v1, + &ENG_LEAFGREEN_v1, + &ENG_EMERALD_v0, + }; + if (IGNORE_GAME_PAK) { gamecode = DEBUG_GAME; @@ -21,132 +36,49 @@ bool rom_data::load_rom() version = (*(vu8 *)(0x80000BC)); } - // This section will need to be updated when more languages are added. It wil likely have to be a 3D array - if (language != LANG_ENG) + for (int i = 0; i < NUM_ROMS; i++) { - return false; - } - - switch (gamecode) - { - case (RUBY_ID): - case (SAPPHIRE_ID): - - map_bank = 0; // Testing girl is 0-10-1, lanette is 20-2-1 - map_id = 10; - npc_id = 1; - - def_map_bank = 8; - def_map_id = 1; - def_npc_id = 1; - - text_region = TEXT_HOENN; - offset_wondercard = 0; - offset_script = 0x0810; - - e4_flag = 0x800 + 0x04; - mg_flag = 0x800 + 0x4C; - - switch (version) + if (gamecode == list_of_roms[i]->gamecode && + language == list_of_roms[i]->language && + version == list_of_roms[i]->version) { - case (VERS_1_0): - loc_sendMonToPC = 0x0803D998; - loc_gSpecialVar_0x8000 = 0x0202E8C4; - loc_gSaveBlock1 = 0x02025734; - loc_setPokedexFlag = 0x08090D90; - offset_ramscript = 0x3690; - offset_flags = 0x1220; - return true; - case (VERS_1_1): - loc_sendMonToPC = 0x0803D998; - loc_gSpecialVar_0x8000 = 0x0202E8C4; - loc_gSaveBlock1 = 0x02025734; - loc_setPokedexFlag = 0x08090DB0; - offset_ramscript = 0x3690; - offset_flags = 0x1220; - return true; - case (VERS_1_2): - loc_sendMonToPC = 0x0803D998; - loc_gSpecialVar_0x8000 = 0x0202E8C4; - loc_gSaveBlock1 = 0x02025734; - loc_setPokedexFlag = 0x08090DB0; - offset_ramscript = 0x3690; - offset_flags = 0x1220; + fill_values(list_of_roms[i]); return true; } - break; - case (FIRERED_ID): - case (LEAFGREEN_ID): - - map_bank = 30; - map_id = 0; - npc_id = 1; - - def_map_bank = 0xFF; - def_map_id = 0xFF; - def_npc_id = 0xFF; - - text_region = TEXT_KANTO; - offset_wondercard = 0x0460; - offset_script = 0x079C; - - e4_flag = 0x800 + 0x2C; - mg_flag = 0x800 + 0x39; - - switch (version) - { - case (VERS_1_0): - loc_sendMonToPC = 0x08040B90; - loc_gSpecialVar_0x8000 = 0x020370B8; - loc_gSaveBlock1PTR = 0x03005008; - loc_setPokedexFlag = 0x08088E74; - offset_ramscript = 0x361C; - offset_flags = 0x0EE0; - return true; - case (VERS_1_1): - loc_sendMonToPC = 0x08040BA4; - loc_gSpecialVar_0x8000 = 0x020370B8; - loc_gSaveBlock1PTR = 0x03005008; - loc_setPokedexFlag = 0x08088E5C; - offset_ramscript = 0x361C; - offset_flags = 0x0EE0; - return true; - } - break; - case (EMERALD_ID): - - map_bank = 5; //20; - map_id = 4; //2; - npc_id = 2; //1; - - def_map_bank = 0xFF; - def_map_id = 0xFF; - def_npc_id = 0xFF; - - text_region = TEXT_HOENN; - offset_wondercard = 0x056C; - offset_script = 0x08A8; - - e4_flag = 0x860 + 0x04; - mg_flag = 0x860 + 0x7B; - unused_flag_start = 0x20; - all_collected_flag = 0x20; - pkmn_collected_flag_start = 0x21; - - loc_sendMonToPC = 0x0806B490; - loc_gSpecialVar_0x8000 = 0x020375D8; - loc_gSaveBlock1PTR = 0x03005D8C; - loc_setPokedexFlag = 0x080C0664; - loc_gSaveDataBuffer = 0x0203ABBC; - loc_readFlashSector = 0x0815314C; - - offset_ramscript = 0x3728; - offset_flags = 0x1270; - return true; } return false; } +void rom_data::fill_values(const ROM_DATA *rom_values) +{ + loc_sendMonToPC = rom_values->loc_copyMonToPC; + loc_gSpecialVar_0x8000 = rom_values->loc_gSpecialVar_0x8000; + loc_gSaveBlock1 = rom_values->loc_gSaveBlock1; + loc_gSaveBlock1PTR = rom_values->loc_gSaveBlock1PTR; + loc_setPokedexFlag = rom_values->loc_getSetPokedexFlag; + loc_gSaveDataBuffer = rom_values->loc_gSaveDataBuffer; + loc_readFlashSector = rom_values->loc_readFlashSector; + offset_ramscript = rom_values->offset_ramscript; + offset_flags = rom_values->offset_flags; + offset_wondercard = rom_values->offset_wondercard; + offset_script = rom_values->offset_script; + text_region = rom_values->text_region; + + e4_flag = rom_values->e4_flag; // The flag that is set when you become champion. Often listed as "GAME_CLEAR" + mg_flag = rom_values->mg_flag; // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS + unused_flag_start = rom_values->unused_flag_start; // The start of the unused flags and must have 31 open flags in a row + all_collected_flag = rom_values->unused_flag_start; // The flag for if everything has been collected + pkmn_collected_flag_start = rom_values->unused_flag_start + 1; // The beginning of the flags for each of the Pokemon + + map_bank = (DEBUG_MODE ? rom_values->test_map_bank : rom_values->map_bank); + map_id = (DEBUG_MODE ? rom_values->test_map_id : rom_values->map_id); + npc_id = (DEBUG_MODE ? rom_values->test_npc_id : rom_values->npc_id); + + def_map_bank = rom_values->def_map_bank; + def_map_id = rom_values->def_map_id; + def_npc_id = rom_values->def_npc_id; +} + bool rom_data::is_hoenn() { return (gamecode == RUBY_ID || gamecode == SAPPHIRE_ID || gamecode == EMERALD_ID);