diff --git a/include/debug_mode.h b/include/debug_mode.h index eb70bad..434989e 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 true +#define IGNORE_LINK_CABLE false #define DEBUG_GAME LEAFGREEN_ID #define DEBUG_VERS VERS_1_1 #define DEBUG_LANG LANG_ENG diff --git a/include/script_array.h b/include/script_array.h index 47d4181..1bed0af 100644 --- a/include/script_array.h +++ b/include/script_array.h @@ -4,63 +4,51 @@ #include "script_obj.h" #include "pokemon_party.h" - -// Start! -#define SCRIPT_START 0 -#define START_SIZE 1 - // Dialouge -#define DIA_INDEX_OPEN 0 -#define DIA_INDEX_E4_1 1 -#define DIA_INDEX_E4_2 2 -#define DIA_INDEX_MG 3 -#define DIA_INDEX_START 4 -#define DIA_INDEX_ERROR_1 5 -#define DIA_INDEX_CONN_GOOD 6 -#define DIA_INDEX_LINK_GOOD 7 -#define DIA_INDEX_TRANS_GOOD 8 -#define DIA_INDEX_NEW_DEX 9 -#define DIA_INDEX_NO_NEW_DEX 10 -#define DIA_INDEX_SEND_FRIEND 11 -#define DIA_INDEX_THANK 12 +#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_F_OPEN START_SIZE + DIA_INDEX_OPEN -#define DIA_F_E4_1 START_SIZE + DIA_INDEX_E4_1 -#define DIA_F_E4_2 START_SIZE + DIA_INDEX_E4_2 -#define DIA_F_MG START_SIZE + DIA_INDEX_MG -#define DIA_F_START START_SIZE + DIA_INDEX_START -#define DIA_F_ERROR_1 START_SIZE + DIA_INDEX_START -#define DIA_F_CONN_GOOD START_SIZE + DIA_INDEX_CONN_GOOD -#define DIA_F_LINK_GOOD START_SIZE + DIA_INDEX_LINK_GOOD -#define DIA_F_TRANS_GOOD START_SIZE + DIA_INDEX_TRANS_GOOD -#define DIA_F_NEW_DEX START_SIZE + DIA_INDEX_NEW_DEX -#define DIA_F_NO_NEW_DEX START_SIZE + DIA_INDEX_NO_NEW_DEX -#define DIA_F_SEND_FRIEND START_SIZE + DIA_INDEX_SEND_FRIEND -#define DIA_F_THANK START_SIZE + DIA_INDEX_THANK - -#define DIA_SIZE 27 -#define DIA_END DIA_SIZE + START_SIZE +#define DIA_SIZE 18 +#define DIA_END DIA_SIZE // Commands -#define CMD_START_LINK DIA_END + 0 -#define CMD_IMPORT_POKEMON DIA_END + 1 -#define CMD_BACK_TO_MENU DIA_END + 2 -#define CMD_SHOW_PROF DIA_END + 3 -#define CMD_HIDE_PROF DIA_END + 4 +#define SCRIPT_START DIA_END + 0 +#define CMD_START_LINK DIA_END + 1 +#define CMD_IMPORT_POKEMON DIA_END + 2 +#define CMD_BACK_TO_MENU DIA_END + 3 +#define CMD_SHOW_PROF DIA_END + 4 +#define CMD_HIDE_PROF DIA_END + 5 -#define CMD_SIZE 5 +#define CMD_SIZE 6 #define CMDS_END DIA_END + CMD_SIZE // Conditionals -#define COND_ERROR_TIMEOUT_ONE CMDS_END + 0 -#define COND_ERROR_DISCONNECT CMDS_END + 1 -#define COND_ERROR_COM_ENDED CMDS_END + 2 -#define COND_ERROR_TIMEOUT_TWO CMDS_END + 3 -#define COND_ERROR_COLOSSEUM CMDS_END + 4 -#define COND_BEAT_E4 CMDS_END + 5 -#define COND_MG_ENABLED CMDS_END + 6 +#define COND_ERROR_TIMEOUT_ONE CMDS_END + 0 // Didn't talk to the Cable Club attendant fast enough or cable not connected +#define COND_ERROR_DISCONNECT CMDS_END + 1 // If you unplug the cable after starting SPI +#define COND_ERROR_COM_ENDED CMDS_END + 2 // If you don't save the game +#define COND_ERROR_TIMEOUT_TWO CMDS_END + 3 // ??? +#define COND_ERROR_COLOSSEUM CMDS_END + 4 // If the player selects the battle colosseum (shouldn't be possible) +#define COND_BEAT_E4 CMDS_END + 5 +#define COND_MG_ENABLED CMDS_END + 6 +#define COND_TUTORIAL_COMPLETE CMDS_END + 7 -#define COND_SIZE 7 +#define COND_SIZE 8 #define COND_END CMDS_END + COND_SIZE // Ends diff --git a/include/script_obj.h b/include/script_obj.h index bd18249..b075cb2 100644 --- a/include/script_obj.h +++ b/include/script_obj.h @@ -8,11 +8,9 @@ class script_obj { public: script_obj(); - script_obj(std::string_view nText, int nNext); - script_obj(std::string_view nText, int nRun, int nNext); - script_obj(int nRun, int nNext); - script_obj(std::string_view nText, int nRun, int nNext_if_true, int nNext_if_false); - script_obj(int nRun, int nNext_if_true, int nNext_if_false); + script_obj(std::string_view nText, int nNext); // For dialogue + script_obj(int nRun, int nNext); // For commands + script_obj(int nRun, int nNext_if_true, int nNext_if_false); // for conditionals std::string get_text(); int get_true_index(); diff --git a/source/main.cpp b/source/main.cpp index 516a3e3..00fb0aa 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -121,12 +121,12 @@ void initalization_script(void) flash_init(FLASH_SIZE_128KB); rand_set_seed(0x1216); - init_text_engine(); add_script_party_var(party); // Prepare dialouge populate_dialogue(); populate_script(); + init_text_engine(); // Sound bank init irq_init(NULL); diff --git a/source/pokemon_party.cpp b/source/pokemon_party.cpp index f1e22a8..23ee1a8 100644 --- a/source/pokemon_party.cpp +++ b/source/pokemon_party.cpp @@ -3,7 +3,7 @@ #include "pokemon.h" #include "flash_mem.h" #include "debug_mode.h" -#include "script.h" +#include "mystery_gift_injector.h" /* byte debug_party_data[GEN2_INT_SIZE + 4] = { // Japanese Gen 1 diff --git a/source/script_array.cpp b/source/script_array.cpp index 999269b..5fe3cc6 100644 --- a/source/script_array.cpp +++ b/source/script_array.cpp @@ -13,35 +13,59 @@ std::string_view dialogue[DIA_SIZE]; void populate_dialogue() { - dialogue[DIA_INDEX_OPEN] = "Hey there! I'm Professor Fennel. As you can see, I'm a scientist. In fact, the subject I'm researching is Trainers! My dream is to collect save files of various trainers, but I haven't had any breakthroughs yet. In the center of the region where I'm from, there's a location that can make a Pokemon's dreams into reality! This means that any other Pokemon they meet in their dreams become real! That's fantastic, but my goal is to do the same- but for a trainer! I've successfully been able send a Pokemon in and out of a trainer's dream, but I've been unsuccessful in pulling out a Pokemon without... catastrophic results. That's when I had a breakthrough- I realized if I sent in a DITTO, it could transform into the Pokemon found within that trainer's dream! That's why you're here today- I want to bring as many Pokemon out of your dreams as possible! There's just over 250 different Pokemon I want to catalogue in my Dream Pokedex- or Dream Dex for short. But I'll let you keep any Pokemon- they're from your dreams after all! I think that's everything... whenever you're ready, just let me know!"; - dialogue[DIA_INDEX_E4_1] = "Hi trainer! I'm thrilled\nyou've decided to help with our research, but we need\nthe best of the best!"; - dialogue[DIA_INDEX_E4_2] = "Come back once you've taken down the Elite Four!"; + 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] = "Alright then, let's get started! Please connect your Game Boy Advance to a Game Boy family system, using a Game Boy Color link cable. 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 something isn't right. Let'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 Link Trade, and then press A."; - dialogue[DIA_INDEX_LINK_GOOD] = "We're almost set! Once you're ready, talk to the trainer across the table from you to start the process!"; - dialogue[DIA_INDEX_TRANS_GOOD] = "Amazing! Fantastic!! Everything went perfectly!"; - dialogue[DIA_INDEX_NEW_DEX] = "It looks like there's at least one new Pokemon here that isn't in the Dream Dex! I'll give it something extra sweet as a reward for you both."; - dialogue[DIA_INDEX_NO_NEW_DEX] = "It doesn't look like there's anything new for your Dream Dex, but that's okay! Any research is good research!"; + 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_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 assisting with my research! Whenever you want to transfer more Pokemon, just let me know!"; + 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_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"; } void populate_script() { - + // Check that the conditions are set for the transfer script[SCRIPT_START] = script_obj(CMD_SHOW_PROF, COND_BEAT_E4); - script[COND_BEAT_E4] = script_obj(COND_BEAT_E4, COND_MG_ENABLED, DIA_F_E4_1); - script[COND_MG_ENABLED] = script_obj(COND_MG_ENABLED, DIA_F_START, DIA_F_MG); + 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[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[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[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[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[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); + + // 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); + + // 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[DIA_F_START] = script_obj("welcome", CMD_START_LINK, DIA_F_CONN_GOOD); - script[DIA_F_CONN_GOOD] = script_obj("good", CMD_IMPORT_POKEMON, CMD_BACK_TO_MENU); - script[DIA_F_E4_1] = script_obj(dialogue[DIA_INDEX_E4_1], DIA_F_E4_2); - script[DIA_F_E4_2] = script_obj(dialogue[DIA_INDEX_E4_2], CMD_HIDE_PROF, CMD_BACK_TO_MENU); - script[DIA_F_MG] = script_obj(dialogue[DIA_INDEX_MG], CMD_HIDE_PROF, CMD_BACK_TO_MENU); /* 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 @@ -66,7 +90,6 @@ void populate_script() script[20] = script_obj("", 21, CMD_HIDE_PROF); // 20 script[21] = script_obj("", 0, CMD_BACK_TO_MENU); */ - // 21 }; void add_script_party_var(Pokemon_Party var) @@ -123,6 +146,9 @@ bool run_conditional(int index) case COND_MG_ENABLED: return true; + case COND_TUTORIAL_COMPLETE: + return true; + default: tte_set_pos(0, 0); tte_write("ERROR! No conditional found."); diff --git a/source/script_obj.cpp b/source/script_obj.cpp index b84e3fd..e4ab128 100644 --- a/source/script_obj.cpp +++ b/source/script_obj.cpp @@ -4,14 +4,10 @@ #include "gba_flash.h" #include "pokemon.h" #include "pokemon_party.h" +#include "script_array.h" -script_obj::script_obj() -{ - text = ""; - next_index = 0; - conditional_index = 0; - next_false_index = 0; -} +script_obj::script_obj(){ +}; script_obj::script_obj(std::string_view nText, int nNext) { @@ -21,14 +17,6 @@ script_obj::script_obj(std::string_view nText, int nNext) next_false_index = 0; } -script_obj::script_obj(std::string_view nText, int nRun, int nNext) -{ - text = nText; - next_index = nNext; - conditional_index = nRun; - next_false_index = nNext; -} - script_obj::script_obj(int nRun, int nNext) { text = ""; @@ -37,14 +25,6 @@ script_obj::script_obj(int nRun, int nNext) next_false_index = nNext; } -script_obj::script_obj(std::string_view nText, int nRun, int nNext_if_true, int nNext_if_false) -{ - text = nText; - next_index = nNext_if_true; - conditional_index = nRun; - next_false_index = nNext_if_false; -} - script_obj::script_obj(int nRun, int nNext_if_true, int nNext_if_false) { text = ""; diff --git a/source/text_engine.cpp b/source/text_engine.cpp index 2dfcf26..f6aeaed 100644 --- a/source/text_engine.cpp +++ b/source/text_engine.cpp @@ -5,12 +5,15 @@ #include "text_engine.h" #include "global_frame_counter.h" #include "pkmn_font.h" +#include "script_array.h" #define TEXT_CBB 3 #define TEXT_SBB 28 script_obj curr_line; -uint char_count; +uint char_index; +uint line_char_index; +std::string curr_text; bool disabled; void init_text_engine() @@ -21,9 +24,11 @@ void init_text_engine() tte_set_pos(LEFT, TOP); // Set default variables - curr_line = script[0]; - char_count = 0; + curr_line = script[SCRIPT_START]; + char_index = 0; + line_char_index = 0; disabled = false; + curr_text = curr_line.get_text(); } void text_next_frame() @@ -31,22 +36,34 @@ void text_next_frame() if (!disabled) { tte_set_pos(LEFT, TOP); - if (char_count < curr_line.get_text().length()) + if (char_index < curr_text.length() && curr_text.substr(char_index, 1) != "|") { if (get_frame_count() % 2 == 0 || key_held(KEY_B)) { - char_count++; + char_index++; tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM); tte_set_ink(CLR_RED); - tte_write(curr_line.get_text().substr(0, char_count).c_str()); + tte_write(curr_text.substr(0, char_index).c_str()); } } else { - if (key_hit(KEY_A) || char_count == 0) + if (key_hit(KEY_A) || curr_text.length() == 0) { - curr_line = script[text_next_obj_id(curr_line)]; - char_count = 0; + if (curr_text.substr(char_index, 1) == "|") + { + line_char_index += char_index; + line_char_index++; + curr_text = curr_line.get_text().substr(line_char_index); + char_index = 0; + } + else + { + line_char_index = 0; + curr_line = script[text_next_obj_id(curr_line)]; + curr_text = curr_line.get_text(); + char_index = 0; + } } } } @@ -81,10 +98,12 @@ void text_disable() hide_text_box(); } -void show_text_box(){ +void show_text_box() +{ REG_BG2CNT = (REG_BG2CNT & ~BG_PRIO_MASK) | BG_PRIO(1); } -void hide_text_box(){ +void hide_text_box() +{ REG_BG2CNT = (REG_BG2CNT & ~BG_PRIO_MASK) | BG_PRIO(3); }