From 2cfec76b3cff8bd2d03f107e6ae41bcb48cdc63a Mon Sep 17 00:00:00 2001 From: The Gears of Progress Date: Fri, 7 Jun 2024 13:55:01 -0400 Subject: [PATCH] Adding support for Yellow and fixing other bugs --- include/background_engine.h | 5 +- include/debug_mode.h | 1 + include/gameboy_colour.h | 6 +- include/gb_rom_values/base_gb_rom_struct.h | 2 +- include/pokemon_party.h | 2 +- include/rom_data.h | 3 + include/script_array.h | 3 +- source/background_engine.cpp | 27 +++++++++ source/gameboy_colour.cpp | 69 +++++++++++++--------- source/global_frame_controller.cpp | 21 ++++++- source/main.cpp | 20 +++---- source/pokemon.cpp | 4 +- source/pokemon_party.cpp | 8 +-- source/rom_data.cpp | 10 ++++ source/script_array.cpp | 23 +++++--- 15 files changed, 143 insertions(+), 61 deletions(-) diff --git a/include/background_engine.h b/include/background_engine.h index 330e4f9..fa57323 100644 --- a/include/background_engine.h +++ b/include/background_engine.h @@ -2,5 +2,8 @@ #define BACKGROUND_ENGINE_H void background_frame(); - +void set_textbox_large(); +void set_textbox_small(); +void show_textbox(); +void hide_textbox(); #endif \ No newline at end of file diff --git a/include/debug_mode.h b/include/debug_mode.h index ada5c05..ca1f1a3 100644 --- a/include/debug_mode.h +++ b/include/debug_mode.h @@ -5,6 +5,7 @@ #define IGNORE_GAME_PAK false #define IGNORE_LINK_CABLE false #define IGNORE_MG_E4_FLAGS false +#define IGNORE_UNRECEIVED_PKMN false #define FORCE_TUTORIAL false #define DONT_REMOVE_PKMN false #define SHOW_INVALID_PKMN false diff --git a/include/gameboy_colour.h b/include/gameboy_colour.h index 67ed7ed..bc71229 100644 --- a/include/gameboy_colour.h +++ b/include/gameboy_colour.h @@ -32,10 +32,10 @@ #define SLOW_SPEED 1000 void setup(); -byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ROM *curr_gb_rom, Simplified_Pokemon *curr_simple_array); -int loop(byte *box_data_storage, byte *curr_payload, GB_ROM *curr_rom, Simplified_Pokemon *curr_simple_array); +byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ROM *curr_gb_rom, Simplified_Pokemon *curr_simple_array, bool cancel_connection); +int loop(byte *box_data_storage, byte *curr_payload, GB_ROM *curr_rom, Simplified_Pokemon *curr_simple_array, bool cancel_connection); byte exchange_parties(byte curr_in, byte *curr_payload); byte exchange_boxes(byte curr_in, byte *party_data); -byte exchange_remove_array(byte curr_in, Simplified_Pokemon *curr_simple_array); +byte exchange_remove_array(byte curr_in, Simplified_Pokemon *curr_simple_array, bool cancel_connection); #endif /* GAMEBOY_COLOUR_H_ */ diff --git a/include/gb_rom_values/base_gb_rom_struct.h b/include/gb_rom_values/base_gb_rom_struct.h index 451d315..935572f 100644 --- a/include/gb_rom_values/base_gb_rom_struct.h +++ b/include/gb_rom_values/base_gb_rom_struct.h @@ -8,7 +8,7 @@ typedef unsigned int u32, word, uint, eint; typedef unsigned long long u64; #define PAYLOAD_SIZE 672 -#define NUM_PAYLOADS 1 +#define NUM_PAYLOADS 2 #define GB_TILE_WIDTH 20 diff --git a/include/pokemon_party.h b/include/pokemon_party.h index 6da821d..66a56e1 100644 --- a/include/pokemon_party.h +++ b/include/pokemon_party.h @@ -10,7 +10,7 @@ class Pokemon_Party public: Pokemon_Party(); void start_link(); - void continue_link(); + void continue_link(bool cancel_connection); int get_last_error(); Pokemon get_converted_pkmn(int index); bool get_has_new_pkmn(); diff --git a/include/rom_data.h b/include/rom_data.h index 59e412f..e2ed24d 100644 --- a/include/rom_data.h +++ b/include/rom_data.h @@ -29,6 +29,9 @@ public: bool is_hoenn(); bool is_ruby_sapphire(); void print_rom_info(); + bool verify_rom(); + + bool rom_loaded = false; int gamecode; int version; diff --git a/include/script_array.h b/include/script_array.h index 1930509..8853a67 100644 --- a/include/script_array.h +++ b/include/script_array.h @@ -58,8 +58,9 @@ #define CMD_BOX_MENU DIA_END + 13 #define CMD_MYTHIC_MENU DIA_END + 14 #define CMD_LOAD_SIMP DIA_END + 15 +#define CMD_CANCEL_LINK DIA_END + 16 -#define CMD_SIZE 16 +#define CMD_SIZE 17 #define CMDS_END DIA_END + CMD_SIZE // Conditionals diff --git a/source/background_engine.cpp b/source/background_engine.cpp index 825d8ea..848b3cd 100644 --- a/source/background_engine.cpp +++ b/source/background_engine.cpp @@ -2,6 +2,7 @@ #include #include "sprite_data.h" +#include "text_engine.h" #define CBB 0 #define SBB 24 @@ -14,4 +15,30 @@ void background_frame() REG_BG0HOFS = x; REG_BG0VOFS = y; +} + +void set_textbox_large() +{ + tte_set_pos(40, 24); + tte_set_margins(40, 24, 206, 104); + tte_erase_rect(0, 0, H_MAX, V_MAX); + REG_BG2VOFS = 0; +} +void set_textbox_small() +{ + tte_set_margins(LEFT, TOP, RIGHT, BOTTOM); + tte_erase_rect(0, 0, H_MAX, V_MAX); + REG_BG2VOFS = 96; +} + +void show_textbox() +{ + REG_BG0CNT = (REG_BG0CNT & ~BG_PRIO_MASK) | BG_PRIO(3); + REG_BG2CNT = (REG_BG2CNT & ~BG_PRIO_MASK) | BG_PRIO(2); +} + +void hide_textbox() +{ + REG_BG0CNT = (REG_BG0CNT & ~BG_PRIO_MASK) | BG_PRIO(2); + REG_BG2CNT = (REG_BG2CNT & ~BG_PRIO_MASK) | BG_PRIO(3); } \ No newline at end of file diff --git a/source/gameboy_colour.cpp b/source/gameboy_colour.cpp index 050d69d..89c640d 100644 --- a/source/gameboy_colour.cpp +++ b/source/gameboy_colour.cpp @@ -11,6 +11,8 @@ #include "text_engine.h" #include "global_frame_controller.h" #include "gb_rom_values/eng_gb_rom_values.h" +#include "background_engine.h" +#include "sprite_data.h" #define TIMEOUT 2 #define TIMEOUT_ONE_LENGTH 1000000 // Maybe keep a 10:1 ratio between ONE and TWO? @@ -108,17 +110,21 @@ void setup() tte_set_pos(0, 0); tte_write("FEED ME POKEMON, I HUNGER!\n"); } + set_textbox_large(); + tte_erase_screen(); + tte_set_pos(40, 24); + tte_write("\n\n\n Connecting to\n GameBoy"); } -byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ROM *curr_gb_rom, Simplified_Pokemon *curr_simple_array) +byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ROM *curr_gb_rom, Simplified_Pokemon *curr_simple_array, bool cancel_connection) { // TODO: Change to a switch statement if (state == hs) { + mosi_delay = 4; if (curr_gb_rom->generation == 2) { state = ack; - // mosi_delay = 1; return 0x00; } if (in == 0x00) @@ -159,8 +165,10 @@ byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ if (in == 0x60 || in == 0x61) { tte_erase_screen(); - tte_write("Connected to Game Boy."); + tte_set_pos(40, 24); + tte_write("\n\n\nLink was successful!\n\n Waiting for trade"); state = pretrade; + data_counter = 0; return in; } else if (in == 0x02) @@ -176,23 +184,22 @@ byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ else if (state == pretrade) { - if (in == 0xD0) + if (data_counter == 16) { + data_counter = 0; state = trade; - return 0xD4; } - else if (in == 0xD1) - { - state = trade; - return 0xD1; - } - return in; + data_counter++; + return 0xD4; } else if (state == trade) { if (in == 0xfd) { + tte_erase_screen(); + tte_set_pos(40, 24); + tte_write("\n\n\nTransferring data...\n please wait!"); mosi_delay = 1; state = party_preamble; } @@ -219,6 +226,10 @@ byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ } else if ((curr_gb_rom->method == METHOD_MEW) && (in == 0xFE)) { + tte_erase_screen(); + tte_set_pos(40, 24); + tte_write("\n\nPlease press A or B\n twice on the other\n GameBoy system"); + mosi_delay = 3; state = wait_to_resend; } else @@ -253,6 +264,9 @@ byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ { if (in != 0xFE) { + tte_erase_screen(); + tte_set_pos(40, 24); + tte_write("\n\n\nTransferring data...\n please wait!"); state = resend_payload; data_counter = 0x1B4; } @@ -273,7 +287,6 @@ byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ else if (state == reboot) { data_counter = 0; - mosi_delay = 16; state = remove_array_preamble; return 0xFD; } @@ -283,7 +296,7 @@ byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ if (in != 0xFD) { state = send_remove_array; - return exchange_remove_array(in, curr_simple_array); + return exchange_remove_array(in, curr_simple_array, cancel_connection); } return in; } @@ -295,13 +308,13 @@ byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ state = end2; } data_counter++; - return exchange_remove_array(in, curr_simple_array); + return exchange_remove_array(in, curr_simple_array, cancel_connection); } return in; } -int loop(byte *box_data_storage, byte *curr_payload, GB_ROM *curr_gb_rom, Simplified_Pokemon *curr_simple_array) +int loop(byte *box_data_storage, byte *curr_payload, GB_ROM *curr_gb_rom, Simplified_Pokemon *curr_simple_array, bool cancel_connection) { int counter = 0; while (true) @@ -311,6 +324,7 @@ int loop(byte *box_data_storage, byte *curr_payload, GB_ROM *curr_gb_rom, Simpli if (DEBUG_MODE) { + tte_set_margins(0, 0, H_MAX, V_MAX); print( std::to_string(counter) + ": [" + std::to_string(data_counter) + "][" + @@ -318,15 +332,15 @@ int loop(byte *box_data_storage, byte *curr_payload, GB_ROM *curr_gb_rom, Simpli std::to_string(in_data) + "][" + std::to_string(out_data) + "]\n"); } - out_data = handleIncomingByte(in_data, box_data_storage, curr_payload, curr_gb_rom, curr_simple_array); + out_data = handleIncomingByte(in_data, box_data_storage, curr_payload, curr_gb_rom, curr_simple_array, cancel_connection); - if (FF_count > 25) + if (FF_count > (5 * 60)) { - // return COND_ERROR_DISCONNECT; + return COND_ERROR_DISCONNECT; } - if (zero_count > 25) + if (zero_count > (5 * 60)) { - // return COND_ERROR_COM_ENDED; + return COND_ERROR_COM_ENDED; } if (connection_state == COLOSSEUM) { @@ -349,16 +363,17 @@ int loop(byte *box_data_storage, byte *curr_payload, GB_ROM *curr_gb_rom, Simpli return COND_ERROR_DISCONNECT; } + if (state != box_data) + { + FF_count = (in_data == 0xFF ? FF_count + mosi_delay : 0); + zero_count = (in_data == 0x00 ? zero_count + mosi_delay : 0); + } + counter++; for (int i = 0; i < mosi_delay; i++) { global_next_frame(); } - - if (counter > (60 * 10)) - { - // return COND_ERROR_TIMEOUT_ONE; - } } }; @@ -376,11 +391,11 @@ byte exchange_boxes(byte curr_in, byte *box_data_storage) return curr_in; }; -byte exchange_remove_array(byte curr_in, Simplified_Pokemon *curr_simple_array) +byte exchange_remove_array(byte curr_in, Simplified_Pokemon *curr_simple_array, bool cancel_connection) { for (int i = 29; i >= 0; i--) { - if (curr_simple_array[i].is_valid && !curr_simple_array[i].is_transferred) + if (curr_simple_array[i].is_valid && !curr_simple_array[i].is_transferred && !cancel_connection) { curr_simple_array[i].is_transferred = true; return i; diff --git a/source/global_frame_controller.cpp b/source/global_frame_controller.cpp index f8ed072..c90957f 100644 --- a/source/global_frame_controller.cpp +++ b/source/global_frame_controller.cpp @@ -23,6 +23,21 @@ void global_next_frame() if (global_frame_count % 60 == 0) { memcpy(pal_obj_mem + (MENU_SPRITE_PAL * 16), frame_one_pal, 32); + + if (!curr_rom.verify_rom()) + { + REG_BG0CNT = (REG_BG0CNT & ~BG_PRIO_MASK) | BG_PRIO(3); + REG_BG1CNT = (REG_BG1CNT & ~BG_PRIO_MASK) | BG_PRIO(2); + REG_BG2CNT = (REG_BG2CNT & ~BG_PRIO_MASK) | BG_PRIO(1); + REG_BG2VOFS = 0; + tte_set_pos(40, 24); + tte_set_margins(40, 24, 206, 104); + set_textbox_large(); + tte_write("\n\n#{cx:0xF000}The Pok@mon game was\nremoved. Please turn\noff the system and\nrestart the program."); + obj_hide_multi(testroid, 128); + oam_copy(oam_mem, obj_buffer, num_sprites); + while(true){}; + } } else if (global_frame_count % 60 == 30) { @@ -36,10 +51,12 @@ int get_frame_count() return global_frame_count; } -void enable_auto_random(){ +void enable_auto_random() +{ rand_enabled = true; } -void disable_auto_random(){ +void disable_auto_random() +{ rand_enabled = false; } \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index 340dfe5..90f0e90 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -151,6 +151,7 @@ void game_load_error(void) REG_BG2VOFS = 0; tte_set_pos(40, 24); tte_set_margins(40, 24, 206, 104); + set_textbox_large(); tte_write("#{cx:0xF000}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(); @@ -172,7 +173,7 @@ void first_load_message(void) { tte_set_pos(8, 0); tte_set_ink(10); - tte_write("#{cx:0xE000}\n\nHello! Thank you for using\nPok@ Transporter GB!\n\nJust as a word of caution- \nPok@ Transporter GB WILL\nmodify both the GameBoy and GameBoy Advance save files.\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"); + tte_write("#{cx:0xE000}\n\nHello! Thank you for using\nPok@ Transporter GB!\n\nJust as a word of caution- \nPok@ Transporter GB WILL\nmodify both the GameBoy and GameBoy Advance save files.\n\nPlease note that Pok@\nTransporter GB is still in\nbeta, so save file backups\nare HIGHLY recommended\nbefore using. With that all\nbeing said, please enjoy!\n\n -The Gears of Progress"); while (!key_hit(KEY_A)) { global_next_frame(); @@ -204,19 +205,12 @@ int credits() while (true) { - tte_set_pos(40, 24); - tte_set_margins(40, 24, 206, 104); - tte_erase_screen(); + set_textbox_large(); tte_write(credits_array[curr_credits_num].c_str()); - REG_BG0CNT = (REG_BG0CNT & ~BG_PRIO_MASK) | BG_PRIO(3); - REG_BG2CNT = (REG_BG2CNT & ~BG_PRIO_MASK) | BG_PRIO(2); - REG_BG2VOFS = 0; if (key_hit(KEY_B)) - { - tte_erase_rect(0, 0, H_MAX, V_MAX); - REG_BG0CNT = (REG_BG0CNT & ~BG_PRIO_MASK) | BG_PRIO(2); - REG_BG2CNT = (REG_BG2CNT & ~BG_PRIO_MASK) | BG_PRIO(3); - REG_BG2VOFS = 96; + { + hide_text_box(); + set_textbox_small(); return 0; } if (key_hit(KEY_LEFT) && curr_credits_num > 0) @@ -306,6 +300,8 @@ int main(void) pokedex_loop(); break; case (BTN_CREDITS): + set_textbox_large(); + show_text_box(); obj_set_pos(ptgb_logo_l, 56, 108); obj_set_pos(ptgb_logo_r, 56 + 64, 108); credits(); diff --git a/source/pokemon.cpp b/source/pokemon.cpp index 271c4fa..b690ab6 100644 --- a/source/pokemon.cpp +++ b/source/pokemon.cpp @@ -142,8 +142,8 @@ void Pokemon::convert_to_gen_three(bool simplified, bool stabilize_mythical) } is_valid = true; - // Update dex - if (!is_caught(species_index_struct)) + // Update dex if not simple + if (!simplified && !is_caught(species_index_struct)) { is_new = true; set_caught(species_index_struct); diff --git a/source/pokemon_party.cpp b/source/pokemon_party.cpp index 19ea06a..0e35f37 100644 --- a/source/pokemon_party.cpp +++ b/source/pokemon_party.cpp @@ -11,7 +11,7 @@ const GB_ROM *list_of_gb_roms[NUM_PAYLOADS] = { &ENG_RED_BLUE, - //&ENG_YELLOW, + &ENG_YELLOW, //&ENG_GOLD, //&ENG_SILVER, //&ENG_CRYSTAL, @@ -171,13 +171,13 @@ void Pokemon_Party::start_link() else { setup(); - last_error = loop(&box_data_array[0], generate_payload(curr_gb_rom, false), &curr_gb_rom, simple_pkmn_array); + last_error = loop(&box_data_array[0], generate_payload(curr_gb_rom, false), &curr_gb_rom, simple_pkmn_array, false); } } -void Pokemon_Party::continue_link(){ +void Pokemon_Party::continue_link(bool cancel_connection){ if (!IGNORE_LINK_CABLE){ - last_error = loop(&box_data_array[0], generate_payload(curr_gb_rom, false), &curr_gb_rom, simple_pkmn_array); + last_error = loop(&box_data_array[0], generate_payload(curr_gb_rom, false), &curr_gb_rom, simple_pkmn_array, cancel_connection); } } diff --git a/source/rom_data.cpp b/source/rom_data.cpp index f19a4fe..8b79de7 100644 --- a/source/rom_data.cpp +++ b/source/rom_data.cpp @@ -43,6 +43,7 @@ bool rom_data::load_rom() version == list_of_roms[i]->version) { fill_values(list_of_roms[i]); + rom_loaded = true; return true; } } @@ -116,4 +117,13 @@ void rom_data::print_rom_info() out += char(language); tte_set_pos(0, 8); tte_write(out.c_str()); +} + +bool rom_data::verify_rom() +{ + return !rom_loaded || + IGNORE_GAME_PAK || + ((gamecode == ((*(vu8 *)(0x80000AC)) << 0x10 | (*(vu8 *)(0x80000AD)) << 0x08 | (*(vu8 *)(0x80000AE)) << 0x00)) && + (language == (*(vu8 *)(0x80000AF))) && + (version == (*(vu8 *)(0x80000BC)))); } \ No newline at end of file diff --git a/source/script_array.cpp b/source/script_array.cpp index a5f7ba1..64148bd 100644 --- a/source/script_array.cpp +++ b/source/script_array.cpp @@ -9,6 +9,7 @@ #include "global_frame_controller.h" #include "box_menu.h" #include +#include "background_engine.h" int last_error; Pokemon_Party party_data = Pokemon_Party(); @@ -29,7 +30,7 @@ void populate_dialogue() dialogue[DIA_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_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_LETS_START] = "Perfect, that's all the\ninformation I need! Let's\nget started!"; - dialogue[DIA_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 Pok@mon 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_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, make your current box\nthe one you want to transfer\nfrom.|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_TRANS_GOOD] = "Amazing! Fantastic!\nEverything went perfectly!|You may now turn off your\nother Game Boy family\nsystem."; dialogue[DIA_NEW_DEX] = "It looks like there's at\nleast one new Pok@mon here\nthat isn't in the Dream Dex!|I'll give them something\nextra sweet as a reward for you both."; dialogue[DIA_NO_NEW_DEX] = "It doesn't look like there's\nanything new for your Dream\nDex, but that's okay!|It's important to confirm\nresearch results with\nmultiple tests!"; @@ -38,7 +39,7 @@ void populate_dialogue() dialogue[DIA_THANK] = "Thank you so much for your\nhelp! Whenever you want to\ntransfer more Pok@mon, just\nlet me know!|See you around!"; dialogue[DIA_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_MG_OTHER_EVENT] = "Hi Trainer! It looks like\nyou have a different event\ncurrently loaded.|That's no problem, but it\nwill be overwritten if you\ncontinue.|Turn off the system now if\nyou want to experience your\ncurrent event,\nbut otherwise-"; - dialogue[DIA_PKMN_TO_COLLECT] = "Hi Trainer! It looks like\nyou still have Pok@mon to\npick up...|I can send in new ones, but do know that the Pok@mon you\nhaven't picked up yet will\nbe replaced.|Turn off the system now if\nyou want to recieve those\nPok@mon, but otherwise-"; + dialogue[DIA_PKMN_TO_COLLECT] = "Hi Trainer! It looks like\nyou still have Pok@mon to\npick up...|I can't send over new\nPok@mon until you pick those\nup.|Come back after you've\nreceived them!"; dialogue[DIA_NO_VALID_PKMN] = "Sorry Trainer, it doesn't\nlook like you have any valid\nPok@mon in your party right\nnow.|Double check your party and we'll give it another shot!"; dialogue[DIA_ASK_QUEST] = "Hi trainer! Before we begin,\nI need to ask you a few\nquestions."; dialogue[DIA_WHAT_GAME] = "And which Game Boy Pok@mon\ngame are you transferring\nfrom?"; @@ -50,7 +51,7 @@ void populate_dialogue() 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_DISCONNECT] = "It looks like the Game Boy\nColor link cable was\ndisconnected...|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!"; } @@ -71,7 +72,7 @@ void populate_script() script[COND_MG_OTHER_EVENT] = script_obj(COND_MG_OTHER_EVENT, DIA_MG_OTHER_EVENT, COND_PKMN_TO_COLLECT); script[COND_PKMN_TO_COLLECT] = script_obj(COND_PKMN_TO_COLLECT, DIA_PKMN_TO_COLLECT, DIA_ASK_QUEST); script[DIA_MG_OTHER_EVENT] = script_obj(dialogue[DIA_MG_OTHER_EVENT], DIA_ASK_QUEST); - script[DIA_PKMN_TO_COLLECT] = script_obj(dialogue[DIA_PKMN_TO_COLLECT], DIA_ASK_QUEST); + script[DIA_PKMN_TO_COLLECT] = script_obj(dialogue[DIA_PKMN_TO_COLLECT], CMD_END_SCRIPT); // Ask the user what game and language they're using script[DIA_WHAT_GAME] = script_obj(dialogue[DIA_WHAT_GAME], CMD_GAME_MENU); @@ -106,8 +107,9 @@ void populate_script() script[CMD_MYTHIC_MENU] = script_obj(CMD_MYTHIC_MENU, DIA_IN_BOX); script[DIA_IN_BOX] = script_obj(dialogue[DIA_IN_BOX], CMD_BOX_MENU); script[CMD_BOX_MENU] = script_obj(CMD_BOX_MENU, CMD_CONTINUE_LINK, DIA_CANCEL); - script[DIA_CANCEL] = script_obj(dialogue[DIA_CANCEL], CMD_END_SCRIPT); + script[DIA_CANCEL] = script_obj(dialogue[DIA_CANCEL], CMD_CANCEL_LINK); script[CMD_CONTINUE_LINK] = script_obj(CMD_CONTINUE_LINK, CMD_IMPORT_POKEMON); + script[CMD_CANCEL_LINK] = script_obj(CMD_CANCEL_LINK, CMD_END_SCRIPT); // Complete the transfer and give messages based on the transfered Pokemon script[CMD_IMPORT_POKEMON] = script_obj(CMD_IMPORT_POKEMON, DIA_TRANS_GOOD, DIA_NO_VALID_PKMN); @@ -213,7 +215,7 @@ bool run_conditional(int index) return compare_map_and_npc_data(curr_rom.def_map_bank, curr_rom.def_map_id, curr_rom.def_npc_id) && !IGNORE_MG_E4_FLAGS; case COND_PKMN_TO_COLLECT: - return compare_map_and_npc_data(curr_rom.map_bank, curr_rom.map_id, curr_rom.npc_id) && !read_flag(curr_rom.all_collected_flag) && !IGNORE_MG_E4_FLAGS; + return compare_map_and_npc_data(curr_rom.map_bank, curr_rom.map_id, curr_rom.npc_id) && !read_flag(curr_rom.all_collected_flag) && !IGNORE_UNRECEIVED_PKMN; case COND_PAYLOAD_EXISTS: return party_data.load_payload(); @@ -222,7 +224,10 @@ bool run_conditional(int index) return party_data.get_contains_mythical(); case CMD_START_LINK: + obj_hide(prof); party_data.start_link(); + set_textbox_small(); + obj_unhide(prof, 0); return true; case CMD_IMPORT_POKEMON: @@ -300,7 +305,7 @@ bool run_conditional(int index) return true; case CMD_CONTINUE_LINK: - party_data.continue_link(); + party_data.continue_link(false); return true; case CMD_BOX_MENU: @@ -314,6 +319,10 @@ bool run_conditional(int index) party_data.fill_simple_pkmn_array(); return true; + case CMD_CANCEL_LINK: + party_data.continue_link(true); + return true; + default: tte_set_pos(0, 0); tte_write("ERROR! No conditional found.");