From e2ac4c41b051b0ef08d1790ffb41f5ca5213a210 Mon Sep 17 00:00:00 2001 From: Remnants of Forgotten Disney Date: Wed, 15 Nov 2023 09:48:57 -0600 Subject: [PATCH] Shrinking the save data array size --- include/debug_mode.h | 2 +- include/flash_mem.h | 3 +- include/save_data_manager.h | 4 +- include/script_array.h | 49 +++++++----- source/flash_mem.cpp | 73 ++++++++++++------ source/main.cpp | 48 ++++++------ source/main_menu.cpp | 35 ++++++--- source/save_data_manager.cpp | 28 ++++++- source/script_array.cpp | 145 ++++++++++++++++++++--------------- 9 files changed, 241 insertions(+), 146 deletions(-) diff --git a/include/debug_mode.h b/include/debug_mode.h index 434989e..eb70bad 100644 --- a/include/debug_mode.h +++ b/include/debug_mode.h @@ -2,7 +2,7 @@ #define DEBUG_MODE_H #define DEBUG_MODE true -#define IGNORE_LINK_CABLE false +#define IGNORE_LINK_CABLE true #define DEBUG_GAME LEAFGREEN_ID #define DEBUG_VERS VERS_1_1 #define DEBUG_LANG LANG_ENG diff --git a/include/flash_mem.h b/include/flash_mem.h index dfb8d67..8c970a1 100644 --- a/include/flash_mem.h +++ b/include/flash_mem.h @@ -13,7 +13,7 @@ #define SAVE_INDEX_OFFSET 0x00000FFC extern vu32 newest_save_offset; -extern vu32 memory_section_array[14]; +extern vu32 memory_section_array[]; extern char mem_name; extern u8 global_memory_buffer[0x1000]; @@ -21,6 +21,7 @@ void initalize_memory_locations(); bool insert_pokemon(Pokemon party_array[], int num); void reverse_endian(u8 *data, size_t size); void update_memory_buffer_checksum(); +bool get_flag(u16 flag_id); #endif \ No newline at end of file diff --git a/include/save_data_manager.h b/include/save_data_manager.h index f3d031e..950bdc6 100644 --- a/include/save_data_manager.h +++ b/include/save_data_manager.h @@ -47,5 +47,7 @@ int get_def_lang_num(); int get_gamecode(); int get_version(); int get_language(); - +bool get_tutorial_flag(); +void set_tutorial_flag(bool value); +void initalize_save_data(); #endif diff --git a/include/script_array.h b/include/script_array.h index 1bed0af..ceb7007 100644 --- a/include/script_array.h +++ b/include/script_array.h @@ -5,26 +5,29 @@ #include "pokemon_party.h" // Dialouge -#define DIA_INDEX_OPEN 0 -#define DIA_INDEX_E4 1 -#define DIA_INDEX_MG 2 -#define DIA_INDEX_START 3 -#define DIA_INDEX_ERROR_1 4 -#define DIA_INDEX_CONN_GOOD 5 -#define DIA_INDEX_LINK_GOOD 6 -#define DIA_INDEX_TRANS_GOOD 7 -#define DIA_INDEX_NEW_DEX 8 -#define DIA_INDEX_NO_NEW_DEX 9 -#define DIA_INDEX_SEND_FRIEND 10 -#define DIA_INDEX_THANK 11 -#define DIA_INDEX_GET_MON 12 -#define DIA_ERROR_TIME_ONE 13 -#define DIA_ERROR_TIME_TWO 14 -#define DIA_ERROR_DISCONNECT 15 -#define DIA_ERROR_COM_ENDED 16 -#define DIA_ERROR_COLOSSEUM 17 +#define DIA_INDEX_OPEN 0 +#define DIA_INDEX_E4 1 +#define DIA_INDEX_MG_RS 2 +#define DIA_INDEX_MG_FRLGE 3 +#define DIA_INDEX_START 4 +#define DIA_INDEX_LETS_START 5 +#define DIA_INDEX_ERROR_1 6 +#define DIA_INDEX_CONN_GOOD 7 +#define DIA_INDEX_LINK_GOOD 8 +#define DIA_INDEX_TRANS_GOOD 9 +#define DIA_INDEX_NEW_DEX 10 +#define DIA_INDEX_NO_NEW_DEX 11 +#define DIA_INDEX_SEND_FRIEND_HOENN 12 +#define DIA_INDEX_SEND_FRIEND_KANTO 13 +#define DIA_INDEX_THANK 14 +#define DIA_INDEX_GET_MON 15 +#define DIA_ERROR_TIME_ONE 16 +#define DIA_ERROR_TIME_TWO 17 +#define DIA_ERROR_DISCONNECT 18 +#define DIA_ERROR_COM_ENDED 19 +#define DIA_ERROR_COLOSSEUM 20 -#define DIA_SIZE 18 +#define DIA_SIZE 21 #define DIA_END DIA_SIZE // Commands @@ -34,8 +37,9 @@ #define CMD_BACK_TO_MENU DIA_END + 3 #define CMD_SHOW_PROF DIA_END + 4 #define CMD_HIDE_PROF DIA_END + 5 +#define CMD_SET_TUTOR_TRUE DIA_END + 6 -#define CMD_SIZE 6 +#define CMD_SIZE 7 #define CMDS_END DIA_END + CMD_SIZE // Conditionals @@ -47,8 +51,11 @@ #define COND_BEAT_E4 CMDS_END + 5 #define COND_MG_ENABLED CMDS_END + 6 #define COND_TUTORIAL_COMPLETE CMDS_END + 7 +#define COND_NEW_POKEMON CMDS_END + 8 +#define COND_IS_HOENN CMDS_END + 9 +#define COND_IS_FRLGE CMDS_END + 10 -#define COND_SIZE 8 +#define COND_SIZE 11 #define COND_END CMDS_END + COND_SIZE // Ends diff --git a/source/flash_mem.cpp b/source/flash_mem.cpp index c59ea59..9de7208 100644 --- a/source/flash_mem.cpp +++ b/source/flash_mem.cpp @@ -4,41 +4,50 @@ #include "pokemon.h" #define pkmn_length 80 +#define READ_SAVE_SECTIONS 5 +#define TOTAL_SAVE_SECTIONS 14 vu32 newest_save_offset = MEM_CRAM + SAVE_A_OFFSET; -vu32 memory_section_array[14] = {}; +vu32 memory_section_array[READ_SAVE_SECTIONS] = {}; u8 global_memory_buffer[0x1000]; char mem_name = 'A'; - // Fills the variables with the current offset information -void initalize_memory_locations(){ +void initalize_memory_locations() +{ u8 save_A_index[4]; u8 save_B_index[4]; flash_read(MEM_CRAM + SAVE_A_OFFSET + SAVE_INDEX_OFFSET, &save_A_index[0], 0x04); flash_read(MEM_CRAM + SAVE_B_OFFSET + SAVE_INDEX_OFFSET, &save_B_index[0], 0x04); reverse_endian(&save_A_index[0], 0x04); reverse_endian(&save_B_index[0], 0x04); - + // Determines if save A or B is more recent - if(*(vu32*)save_B_index > *(vu32*)save_A_index){ + if (*(vu32 *)save_B_index > *(vu32 *)save_A_index) + { newest_save_offset = MEM_CRAM + SAVE_B_OFFSET; mem_name = 'B'; } // Populates the memory_section_array with the correct pointer locations - vu8 mem_id = *(vu8*)(newest_save_offset + SECTION_ID_OFFSET); - for (int i = 0; i < 14; i++){ - memory_section_array[mem_id] = newest_save_offset + (i * 0x1000); - mem_id = (mem_id + 1) % 14; + vu8 mem_id = *(vu8 *)(newest_save_offset + SECTION_ID_OFFSET); + for (int i = 0; i < TOTAL_SAVE_SECTIONS; i++) + { + if (mem_id < READ_SAVE_SECTIONS) + { + memory_section_array[mem_id] = newest_save_offset + (i * 0x1000); + } + mem_id = (mem_id + 1) % TOTAL_SAVE_SECTIONS; } } // Reverses the endian of the given array -void reverse_endian(u8 *data, size_t size){ +void reverse_endian(u8 *data, size_t size) +{ u8 temp; - for (unsigned int i = 0; i < (size/2); i++){ + for (unsigned int i = 0; i < (size / 2); i++) + { temp = data[i]; data[i] = data[(size - 1) - i]; data[(size - 1) - i] = temp; @@ -46,7 +55,9 @@ void reverse_endian(u8 *data, size_t size){ } // Inserts "total_num" Pokemon from the party array -bool insert_pokemon(Pokemon party[], int total_num){ +/* +bool insert_pokemon(Pokemon party[], int total_num) +{ int pkmn_num = 0; int mem_section = 5; int byte_location = 4; @@ -55,9 +66,11 @@ bool insert_pokemon(Pokemon party[], int total_num){ flash_read(memory_section_array[mem_section], &global_memory_buffer[0], 0x1000); - while(pkmn_num < total_num){ + while (pkmn_num < total_num) + { // Checks if we are currently beyond PC box information bounds. If so, return false - if ((mem_section == 13) && (byte_location >= 1860)){ + if ((mem_section == 13) && (byte_location >= 1860)) + { update_memory_buffer_checksum(); flash_write(memory_section_array[mem_section], &global_memory_buffer[0], 0x1000); return false; @@ -65,24 +78,29 @@ bool insert_pokemon(Pokemon party[], int total_num){ // Determines if there is space to write a Pokemon, or if a Pokemon is currently being written write_pkmn = (write_pkmn | (global_memory_buffer[byte_location] == 0x00)); - + // Writes a byte of the current Pokemon to the current spot - if (write_pkmn){ + if (write_pkmn) + { global_memory_buffer[byte_location] = party[pkmn_num].get_full_gen_3_array()[pkmn_byte]; byte_location++; pkmn_byte++; // Determines if the whole Pokemon has been written - if (pkmn_byte == pkmn_length){ + if (pkmn_byte == pkmn_length) + { pkmn_byte = 0x00; write_pkmn = false; pkmn_num++; } - } else { + } + else + { byte_location += pkmn_length; } // If at any point we are beyond the bounds of the current memory section, // we move to the next memory buffer and save the current one - if (byte_location >= 3968){ + if (byte_location >= 3968) + { update_memory_buffer_checksum(); flash_write(memory_section_array[mem_section], &global_memory_buffer[0], 0x1000); mem_section++; @@ -94,21 +112,30 @@ bool insert_pokemon(Pokemon party[], int total_num){ flash_write(memory_section_array[mem_section], &global_memory_buffer[0], 0x1000); return true; } +*/ // Updates the checksum in the current memory buffer to match what is expected -void update_memory_buffer_checksum(){ +void update_memory_buffer_checksum() +{ vu32 checksum = 0x00; vu32 num_of_bytes = 3968; - if (global_memory_buffer[0x0FF4] == 13){ + if (global_memory_buffer[0x0FF4] == 13) + { num_of_bytes = 2000; } - for (unsigned int i = 0; i < num_of_bytes / 4; i++){ - checksum += (global_memory_buffer[(4*i) + 3] << 24) | (global_memory_buffer[(4*i) + 2] << 16) | (global_memory_buffer[(4*i) + 1] << 8) | (global_memory_buffer[(4*i) + 0] << 0); + for (unsigned int i = 0; i < num_of_bytes / 4; i++) + { + checksum += (global_memory_buffer[(4 * i) + 3] << 24) | (global_memory_buffer[(4 * i) + 2] << 16) | (global_memory_buffer[(4 * i) + 1] << 8) | (global_memory_buffer[(4 * i) + 0] << 0); } vu16 small_checksum = ((checksum & 0xFFFF0000) >> 16) + (checksum & 0x0000FFFF); global_memory_buffer[0x0FF6] = small_checksum & 0x00FF; global_memory_buffer[0x0FF7] = (small_checksum & 0xFF00) >> 8; +} + +bool get_flag(u16 flag_id) +{ + return true; } \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index 00fb0aa..f235468 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -34,36 +34,23 @@ -------- RESEARCH: - See if shiny Pokemon from gen 2 can be square shinies or if they're all normal -- Determine how tossing wonder cards works, and if we need to trash the script after it is finished LINK CABLE: -- Figure out JP Gen 2 +- Confirm JP Gen 2 INJECTION: -- Hall of Fame / Mystery Gift confirmation -- 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 - -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 +- Combine the gen 3 data pointers into one class GENERAL: -- Music -- Finalize Graphics -- Fade in and out - - 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 +- Finish conditionals - Restart the program after a transfer? Transfering twice without restarting corrupts the data (level included?) +- Finalize Graphics +- Simplify the sprite initalization +- Fade in and out +- Add in sound effects for pressing buttons +- Music +- Credits (List all programs, people, and code- plus TPCI) FUTURE: - Minigame @@ -209,6 +196,18 @@ void game_load_error(void) } } +void first_load_message(void) +{ + tte_set_pos(8, 0); + tte_write("Hello! Thank you for using\nPok@mon Mirror!\n\nJust as a word of caution- \nPok@mon Mirror WILL modify\nyour generation 3 save file.\nThe program is designed to\nnot corrupt anything, but if\nyou do not wish to modify\nyour save file, please turn\noff your Game Boy Advance.\n\nPlease note that Pok@mon\nMirror is still in beta, so\nsave file backups are HIGHLY\nrecommended before using.\nWith that all out of the\nway, please enjoy!\n\n -The Gears of Progress"); + while (!key_hit(KEY_A)) + { + key_poll(); + VBlankIntrWait(); + } + tte_erase_rect(0, 0, H_MAX, V_MAX); +} + int main(void) { do @@ -235,6 +234,11 @@ int main(void) initalize_memory_locations(); load_custom_save_data(); + if (get_tutorial_flag() == false){ + first_load_message(); + initalize_save_data(); + } + // Legal mumbo jumbo tte_set_pos(8, 0); tte_write("\n\nPokemon Mirror was created\nout of love and appreciation\nfor the Pokemon franchise\nwith no profit in mind.\nIt will ALWAYS be free.\n\nPlease support the original developers-\nNintendo and GAME FREAK.\n\nAll Pokemon names, sprites, and music are owned by \nNintendo, Creatures Inc, and\nGAME FREAK Inc."); diff --git a/source/main_menu.cpp b/source/main_menu.cpp index 8fe5510..ae23c68 100644 --- a/source/main_menu.cpp +++ b/source/main_menu.cpp @@ -1,6 +1,7 @@ #include #include "main_menu.h" #include "button_handler.h" +#include "save_data_manager.h" int menu_slot = 1; int old_menu_slot = 0; @@ -79,7 +80,14 @@ int main_menu_loop() if (key_hit(KEY_A)) { - ani_mode = ENTERING; + if ((get_tutorial_flag() == true || menu_slot == BTN_TRANSFER)) + { + ani_mode = ENTERING; + } + else + { + // "Bad" noise here + } } if (menu_slot != old_menu_slot) @@ -108,23 +116,28 @@ void main_menu_exit() ani_mode = EXITING; } -void show_lang_btns(){ - for (int i = 0; i < LANG_BUTTON_ARRAY_SIZE; i++){ - lang_button_array[i].show(); +void show_lang_btns() +{ + for (int i = 0; i < LANG_BUTTON_ARRAY_SIZE; i++) + { + lang_button_array[i].show(); } } -void hide_lang_btns(){ - for (int i = 0; i < LANG_BUTTON_ARRAY_SIZE; i++){ - lang_button_array[i].hide(); +void hide_lang_btns() +{ + for (int i = 0; i < LANG_BUTTON_ARRAY_SIZE; i++) + { + lang_button_array[i].hide(); } } -void highlight_lang_btn(int index, bool highlight){ +void highlight_lang_btn(int index, bool highlight) +{ lang_button_array[index].set_highlight(highlight); } - -void set_arrow_point(int index){ +void set_arrow_point(int index) +{ lang_button_array[LANG_ARROW].set_location(lang_button_array[index].x + 16, lang_button_array[index].y - 8); -} +} \ No newline at end of file diff --git a/source/save_data_manager.cpp b/source/save_data_manager.cpp index f21e162..9fd0ce9 100644 --- a/source/save_data_manager.cpp +++ b/source/save_data_manager.cpp @@ -40,7 +40,7 @@ void load_custom_save_data() void write_custom_save_data() { - flash_read(HALL_OF_FAME + 0x1000, &global_memory_buffer[0], 0x1000); + flash_read(HALL_OF_FAME + 0x1000, &global_memory_buffer[0], 0x1000); for (int i = 0; i < SAVE_DATA_SIZE; i++) { global_memory_buffer[HOF_SECTION + i] = save_data_array[i]; @@ -79,7 +79,8 @@ int get_def_lang() } } -int get_def_lang_num(){ +int get_def_lang_num() +{ return save_data_array[DEFAULT_LANGUAGE]; } @@ -98,6 +99,27 @@ int get_version() return version; } -int get_language(){ +int get_language() +{ return language; +} + +void set_tutorial_flag(bool value) +{ + save_data_array[TUTORIAL_FLAG] = value; + write_custom_save_data(); +} + +bool get_tutorial_flag() +{ + return save_data_array[TUTORIAL_FLAG]; +} + +void initalize_save_data() +{ + for (int i = 0; i < SAVE_DATA_SIZE; i++) + { + save_data_array[i] = 0; + } + write_custom_save_data(); } \ No newline at end of file diff --git a/source/script_array.cpp b/source/script_array.cpp index 5fe3cc6..433f8e0 100644 --- a/source/script_array.cpp +++ b/source/script_array.cpp @@ -14,24 +14,24 @@ std::string_view dialogue[DIA_SIZE]; void populate_dialogue() { dialogue[DIA_INDEX_OPEN] = "Hey there! I'm Professor\nFennel. As you can see, I'm\na scientist.|In fact, the subject I'm \nresearching is Trainers!|My dream is to collect save files of various trainers, \nbut I haven't had any \nbreakthroughs yet...|So in the meantime, I have a\ndifferent project!|In my home region, there's a\nlocation that can make a\nPokemon's dreams into\nreality.|This means that any other\nPokemon they meet in their\ndreams become real!|That's fantastic, but my\ngoal is to do the same-\njust with a trainer's dream\ninstead!|I've successfully been able\nto send a Pokemon into\nand out of a trainer's\ndream...|but I've been unsuccessful\nin pulling out a new Pokemon\nwithout...\ncatastrophic results.|That's when I had a\nbreakthrough- I realized if \nI sent in a DITTO,|it could transform into the\nPokemon found within that\ntrainer's dream!|That's why I need your help!\nI want to bring as many\nPokemon out of your dreams\nas possible!|There's just over 250\nPokemon I want to catalogue\nin my Dream Pokedex-\nor Dream Dex for short.|But I'll let you keep any\nPokemon- they're from your\ndreams after all!|I think that's everything...\nwhenever you're ready to\nstart, just let me know!"; - dialogue[DIA_INDEX_E4] = "Hi trainer! I'm thrilled\nyou've decided to help with our research, but we need\nthe best of the best!"; - dialogue[DIA_INDEX_MG] = "Looks like Mystery gift isn't enabled..."; - dialogue[DIA_INDEX_START] = "Please connect your Game Boy\nAdvance to a Game Boy family\nsystem|using a Game Boy Color link\ncable.|Load the Game Boy Pokemon game you want to transfer Pokemon from.|Once both devices have been connected and the Game Boy Pokemon game has been loaded, press A."; - dialogue[DIA_INDEX_ERROR_1] = "Hmm, it looks like\nsomething isn't right.\nLet's try that again!"; - dialogue[DIA_INDEX_CONN_GOOD] = "Great! Now head to the\nearest Pokemon Center.|Put any Pokemon you wish\to bring out of your dreams into your party, and go to\the Cable Club attendant.|Ask them to perform a\nLink Trade, and then\npress A.|"; - dialogue[DIA_INDEX_LINK_GOOD] = "We're almost set!\nOnce you're ready,\ntalk to the trainer across the table from you\to start the process!"; - dialogue[DIA_INDEX_TRANS_GOOD] = "Amazing! Fantastic!!\nEverything went perfectly!"; - dialogue[DIA_INDEX_NEW_DEX] = "It looks like there's at\nleast one new Pokemon\nhere that isn't in the\nDream Dex!|I'll give it something extra\nsweet as a reward\nfor you both."; + dialogue[DIA_INDEX_E4] = "Hi trainer! I'm thrilled\nyou've decided to help with our research, but we need\nthe best of the best!|Come back after you've\nbeaten the Elite Four and\nbecome the Champion!"; + dialogue[DIA_INDEX_MG_FRLGE] = "Sorry trainer, one more\nthing to take care of before\nwe can begin- you need to\nenable MYSTERY GIFT!|Head to the nearest Pok@\nMart and fill out the\nquestionnaire as follows:\nLINK TOGETHER WITH ALL|After that, you should be\nall set to go!|See you soon!"; + dialogue[DIA_INDEX_MG_RS] = "Sorry trainer, one more\nthing to take care of before\nwe can begin- you need to\nenable MYSTERY EVENT!|Head to the PETALBURG\nPok@mon Center and tell the\nman next to the PC:\nMYSTERY EVENT IS EXCITING|After that, you should be\nall set to go!|See you soon!"; + dialogue[DIA_INDEX_LETS_START] = "Let's get started!"; + dialogue[DIA_INDEX_START] = "On a second Game Boy family\nsystem, please load the Game\nBoy Pok@mon game you wish to\ntransfer from.|In your Game Boy Pok@mon\ngame, put any Pokemon you\nwant to bring out of\nyour dreams into your party.|Then connect this Game Boy\nAdvance to the other Game\nBoy family system using a\nGame Boy Color link cable.|Once you're ready, press A\non this device, talk to the Cable Club attendant, and\nthen initiate a trade."; + dialogue[DIA_INDEX_TRANS_GOOD] = "Amazing! Fantastic!\nEverything went perfectly!"; + dialogue[DIA_INDEX_NEW_DEX] = "It looks like there's at\nleast one new Pokemon here\nthat isn't in the Dream Dex!|I'll give them something\nextra sweet as a reward for you both."; dialogue[DIA_INDEX_NO_NEW_DEX] = "It doesn't look like there's\nanything new for your Dream\nDex, but that's okay!|Any research is good\research!"; - dialogue[DIA_INDEX_SEND_FRIEND] = "I'll send these Pokemon to my friend Bill/Lannette so that you can pick them up. Did you know they developed the Storage System for the Kanto/Hoenn region? My younger sister developed the Storage System where I'm from, so Bill/Lannette is a good friend of ours!"; - dialogue[DIA_INDEX_THANK] = "Thank you so much for\nassisting with my research! Whenever you want to\ntransfer more Pokemon, just\nlet me know!"; - dialogue[DIA_INDEX_GET_MON] = "Get your Pokemon, press A, then talk to the link cable club person"; + dialogue[DIA_INDEX_SEND_FRIEND_KANTO] = "I'm going to send these\nPokemon to my friend BILL so\nthat you can pick them up.\nThey live on Route 25!|Did you know they developed the Storage System for the\nKanto region?|My younger sister developed a version of the Storage\nSystem too, so BILL is a\ngood friend of ours!"; + dialogue[DIA_INDEX_SEND_FRIEND_HOENN] = "I'm going to send these\nPokemon to my friend LANNETE so\nthat you can pick them up.\nThey live on route 114!|Did you know they developed the Storage System for the\nHoenn region?|My younger sister developed a version of the Storage\nSystem too, so LANNETE is a\ngood friend of ours!"; + dialogue[DIA_INDEX_THANK] = "Thank you so much for your\nhelp! Whenever you want to\ntransfer more Pokemon, just\nlet me know!|See you around!"; + dialogue[DIA_INDEX_GET_MON] = "Let's get started! Please connect Load the Game Boy Pok@mon game you want to transfer from, and put the Pok@mon you want to transfer into your party. "; - dialogue[DIA_ERROR_COLOSSEUM] = "Went to colo"; - dialogue[DIA_ERROR_COM_ENDED] = "com ended"; - dialogue[DIA_ERROR_DISCONNECT] = "no cable"; - dialogue[DIA_ERROR_TIME_ONE] = "timeout 1"; - dialogue[DIA_ERROR_TIME_TWO] = "timeout 2"; + dialogue[DIA_ERROR_COLOSSEUM] = "It looks like you went to\nthe colosseum instead of the\ntrading room!|Let's try that again!"; + dialogue[DIA_ERROR_COM_ENDED] = "Communication with the other\ndevice was terminated.|Let's try that again!"; + dialogue[DIA_ERROR_DISCONNECT] = "It doesn't look like the\nGame Boy Color link cable is\nconnected correctly.|Let's try that again!"; + dialogue[DIA_ERROR_TIME_ONE] = "It looks like the connection\ntimed out...|Let's try that again!"; + dialogue[DIA_ERROR_TIME_TWO] = "It seems like the connection\ntimed out...|Let's try that again!"; } void populate_script() @@ -40,56 +40,43 @@ void populate_script() script[SCRIPT_START] = script_obj(CMD_SHOW_PROF, COND_BEAT_E4); script[COND_BEAT_E4] = script_obj(COND_BEAT_E4, COND_MG_ENABLED, DIA_INDEX_E4); script[DIA_INDEX_E4] = script_obj(dialogue[DIA_INDEX_E4], CMD_HIDE_PROF); - script[COND_MG_ENABLED] = script_obj(COND_MG_ENABLED, COND_TUTORIAL_COMPLETE, DIA_INDEX_MG); - script[DIA_INDEX_MG] = script_obj(dialogue[DIA_INDEX_E4], CMD_HIDE_PROF); - script[COND_TUTORIAL_COMPLETE] = script_obj(COND_TUTORIAL_COMPLETE, DIA_INDEX_START, DIA_INDEX_OPEN); - script[DIA_INDEX_OPEN] = script_obj(dialogue[DIA_INDEX_OPEN], CMD_HIDE_PROF); - script[DIA_INDEX_START] = script_obj(dialogue[DIA_INDEX_GET_MON], CMD_START_LINK); + script[COND_MG_ENABLED] = script_obj(COND_MG_ENABLED, COND_TUTORIAL_COMPLETE, COND_IS_FRLGE); + script[COND_IS_FRLGE] = script_obj(COND_IS_FRLGE, DIA_INDEX_MG_FRLGE, DIA_INDEX_MG_RS); + script[DIA_INDEX_MG_FRLGE] = script_obj(dialogue[DIA_INDEX_MG_FRLGE], CMD_HIDE_PROF); + script[DIA_INDEX_MG_RS] = script_obj(dialogue[DIA_INDEX_MG_RS], CMD_HIDE_PROF); + script[COND_TUTORIAL_COMPLETE] = script_obj(COND_TUTORIAL_COMPLETE, DIA_INDEX_LETS_START, DIA_INDEX_OPEN); + script[DIA_INDEX_OPEN] = script_obj(dialogue[DIA_INDEX_OPEN], CMD_SET_TUTOR_TRUE); + script[CMD_SET_TUTOR_TRUE] = script_obj(CMD_SET_TUTOR_TRUE, CMD_HIDE_PROF); + script[DIA_INDEX_LETS_START] = script_obj(dialogue[DIA_INDEX_LETS_START], DIA_INDEX_START); + script[DIA_INDEX_START] = script_obj(dialogue[DIA_INDEX_START], CMD_START_LINK); script[CMD_START_LINK] = script_obj(CMD_START_LINK, COND_ERROR_TIMEOUT_ONE); // Initiate the transfer and check for errors script[COND_ERROR_TIMEOUT_ONE] = script_obj(COND_ERROR_TIMEOUT_ONE, COND_ERROR_TIMEOUT_TWO, DIA_ERROR_TIME_ONE); - script[DIA_ERROR_TIME_ONE] = script_obj(dialogue[DIA_ERROR_TIME_ONE], DIA_INDEX_START); + script[DIA_ERROR_TIME_ONE] = script_obj(dialogue[DIA_ERROR_TIME_ONE], DIA_INDEX_LETS_START); script[COND_ERROR_TIMEOUT_TWO] = script_obj(COND_ERROR_TIMEOUT_TWO, COND_ERROR_COM_ENDED, DIA_ERROR_TIME_TWO); - script[DIA_ERROR_TIME_TWO] = script_obj(dialogue[DIA_ERROR_TIME_TWO], DIA_INDEX_START); + script[DIA_ERROR_TIME_TWO] = script_obj(dialogue[DIA_ERROR_TIME_TWO], DIA_INDEX_LETS_START); script[COND_ERROR_COM_ENDED] = script_obj(COND_ERROR_COM_ENDED, COND_ERROR_COLOSSEUM, DIA_ERROR_COM_ENDED); - script[DIA_ERROR_COM_ENDED] = script_obj(dialogue[DIA_ERROR_COM_ENDED], DIA_INDEX_START); + script[DIA_ERROR_COM_ENDED] = script_obj(dialogue[DIA_ERROR_COM_ENDED], DIA_INDEX_LETS_START); script[COND_ERROR_COLOSSEUM] = script_obj(COND_ERROR_COLOSSEUM, COND_ERROR_DISCONNECT, DIA_ERROR_COLOSSEUM); - script[DIA_ERROR_COLOSSEUM] = script_obj(dialogue[DIA_ERROR_COLOSSEUM], DIA_INDEX_START); + script[DIA_ERROR_COLOSSEUM] = script_obj(dialogue[DIA_ERROR_COLOSSEUM], DIA_INDEX_LETS_START); script[COND_ERROR_DISCONNECT] = script_obj(COND_ERROR_DISCONNECT, DIA_INDEX_TRANS_GOOD, DIA_ERROR_DISCONNECT); - script[DIA_ERROR_DISCONNECT] = script_obj(dialogue[DIA_ERROR_DISCONNECT], DIA_INDEX_START); + script[DIA_ERROR_DISCONNECT] = script_obj(dialogue[DIA_ERROR_DISCONNECT], DIA_INDEX_LETS_START); // Complete the transfer and give messages based on the transfered Pokemon - script[DIA_INDEX_TRANS_GOOD] = script_obj(dialogue[DIA_INDEX_TRANS_GOOD], CMD_HIDE_PROF); + script[DIA_INDEX_TRANS_GOOD] = script_obj(dialogue[DIA_INDEX_TRANS_GOOD], CMD_IMPORT_POKEMON); + script[CMD_IMPORT_POKEMON] = script_obj(CMD_IMPORT_POKEMON, COND_NEW_POKEMON); + script[COND_NEW_POKEMON] = script_obj(COND_NEW_POKEMON, DIA_INDEX_NEW_DEX, DIA_INDEX_NO_NEW_DEX); + script[DIA_INDEX_NEW_DEX] = script_obj(dialogue[DIA_INDEX_NEW_DEX], COND_IS_HOENN); + script[DIA_INDEX_NO_NEW_DEX] = script_obj(dialogue[DIA_INDEX_NO_NEW_DEX], COND_IS_HOENN); + script[COND_IS_HOENN] = script_obj(COND_IS_HOENN, DIA_INDEX_SEND_FRIEND_HOENN, DIA_INDEX_SEND_FRIEND_KANTO); + script[DIA_INDEX_SEND_FRIEND_HOENN] = script_obj(dialogue[DIA_INDEX_SEND_FRIEND_HOENN], DIA_INDEX_THANK); + script[DIA_INDEX_SEND_FRIEND_KANTO] = script_obj(dialogue[DIA_INDEX_SEND_FRIEND_KANTO], DIA_INDEX_THANK); + script[DIA_INDEX_THANK] = script_obj(dialogue[DIA_INDEX_THANK], CMD_HIDE_PROF); // Hide the dialouge and professor script[CMD_HIDE_PROF] = script_obj(CMD_HIDE_PROF, CMD_BACK_TO_MENU); script[CMD_BACK_TO_MENU] = script_obj(CMD_BACK_TO_MENU, SCRIPT_START); - - /* - script[0] = script_obj("", 17, CMD_SHOW_PROF); // 0 - script[1] = script_obj("Game not detected. Please turn off your system and upload the program again.", 2); // 1 - script[2] = script_obj("Welcome to Pokemon Mirror!", 3); // 2 - script[3] = script_obj("Please connect your GBA to a GB in the trading room, and press A", 4, CMD_START_LINK); // 3 - script[4] = script_obj("", 6, COND_ERROR_COM_ENDED, 5); // 4 - script[5] = script_obj("Error: Communication ended.", 3); // 5 - script[6] = script_obj("", 8, COND_ERROR_DISCONNECT, 7); // 6 - script[7] = script_obj("Error: Cable disconnected.", 3); // 7 - script[8] = script_obj("", 10, COND_ERROR_TIMEOUT_ONE, 9); // 8 - script[9] = script_obj("Error: Timed out (1).", 3); // 9 - script[10] = script_obj("", 12, COND_ERROR_TIMEOUT_TWO, 11); // 10 - script[11] = script_obj("Error: Timed out (2)", 3); // 11 - script[12] = script_obj("", 14, COND_ERROR_COLOSSEUM, 13); // 12 - script[13] = script_obj("Error: Went into Colosseum", 3); // 13 - script[14] = script_obj("Connection successful! Transfering in Pokemon now", 15); // 14 - script[15] = script_obj("", 16, CMD_IMPORT_POKEMON); // 15 - script[16] = script_obj("Bye!", 21); // 16 - script[17] = script_obj("", 2, COND_BEAT_E4, 18); // 17 - script[18] = script_obj("Hi trainer! I'm thrilled\nyou've decided to help with our research, but we need\nthe best of the best!", 19); // 18 // 17 - script[19] = script_obj("Come back once you've taken down the Elite Four!", 20); // 19 - script[20] = script_obj("", 21, CMD_HIDE_PROF); // 20 - script[21] = script_obj("", 0, CMD_BACK_TO_MENU); - */ }; void add_script_party_var(Pokemon_Party var) @@ -103,10 +90,6 @@ bool run_conditional(int index) switch (index) { - case CMD_START_LINK: - party_data.start_link(); - return true; - case COND_ERROR_COM_ENDED: return party_data.get_last_error() != COND_ERROR_COM_ENDED; @@ -122,6 +105,47 @@ bool run_conditional(int index) case COND_ERROR_COLOSSEUM: return party_data.get_last_error() != COND_ERROR_COLOSSEUM; + case COND_BEAT_E4: + // Emerald Flag ID 0x860 + 0x1F + + return true; + + case COND_MG_ENABLED: + // Emerald flag ID (SYSTEM_FLAGS + 0x7B) + return true; + + case COND_TUTORIAL_COMPLETE: + return get_tutorial_flag(); + + case COND_NEW_POKEMON: + return true; + + case COND_IS_HOENN: + switch (get_gamecode()) + { + case (RUBY_ID): + case (SAPPHIRE_ID): + case (EMERALD_ID): + return true; + default: + return false; + } + + case COND_IS_FRLGE: + switch (get_gamecode()) + { + case (FIRERED_ID): + case (LEAFGREEN_ID): + case (EMERALD_ID): + return true; + default: + return false; + } + + case CMD_START_LINK: + party_data.start_link(); + return true; + case CMD_IMPORT_POKEMON: party_data.load_pokemon(); inject_mystery(party_data.get_full_pokemon_array()); @@ -132,9 +156,6 @@ bool run_conditional(int index) main_menu_exit(); return true; - case COND_BEAT_E4: - return true; - case CMD_SHOW_PROF: obj_unhide(prof, 0); return true; @@ -143,10 +164,8 @@ bool run_conditional(int index) obj_hide(prof); return true; - case COND_MG_ENABLED: - return true; - - case COND_TUTORIAL_COMPLETE: + case CMD_SET_TUTOR_TRUE: + set_tutorial_flag(true); return true; default: