diff --git a/include/gameboy_colour.h b/include/gameboy_colour.h index 5017a60..652856b 100644 --- a/include/gameboy_colour.h +++ b/include/gameboy_colour.h @@ -30,9 +30,9 @@ #define FAST_SPEED 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, bool cancel_connection); -int loop(byte *box_data_storage, byte *curr_payload, GB_ROM *curr_rom, Simplified_Pokemon *curr_simple_array, bool cancel_connection); +void setup(const u16 *debug_charset); +byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ROM *curr_gb_rom, Simplified_Pokemon *curr_simple_array, const u16 *debug_charset, bool cancel_connection); +int loop(byte *box_data_storage, byte *curr_payload, GB_ROM *curr_rom, Simplified_Pokemon *curr_simple_array, const u16 *debug_charset, bool cancel_connection); byte exchange_parties(byte curr_in, byte *curr_payload); byte exchange_boxes(byte curr_in, byte *party_data, GB_ROM *curr_gb_rom); byte exchange_remove_array(byte curr_in, Simplified_Pokemon *curr_simple_array, bool cancel_connection); diff --git a/source/gameboy_colour.cpp b/source/gameboy_colour.cpp index 59991f2..cfc641a 100644 --- a/source/gameboy_colour.cpp +++ b/source/gameboy_colour.cpp @@ -112,7 +112,7 @@ void print(const char* format, ...) } } -void setup() +void setup(const u16 *debug_charset) { interrupt_init(); interrupt_set_handler(INTR_SERIAL, LINK_SPI_ISR_SERIAL); @@ -147,10 +147,10 @@ void setup() create_textbox(0, 0, 80, 80, true); //tte_erase_screen(); tte_set_pos(40, 24); - ptgb_write_debug("\n\n\n Connecting to\n GameBoy", true); + ptgb_write_debug(debug_charset, "\n\n\n Connecting to\n GameBoy", true); } -byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ROM *curr_gb_rom, Simplified_Pokemon *curr_simple_array, bool cancel_connection) +byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ROM *curr_gb_rom, Simplified_Pokemon *curr_simple_array, const u16 *debug_charset, bool cancel_connection) { // TODO: Change to a switch statement if (state == hs) @@ -200,7 +200,7 @@ byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ { tte_erase_rect(0, 0, H_MAX, V_MAX); tte_set_pos(40, 24); - ptgb_write_debug(curr_gb_rom->version != YELLOW_ID ? "\n\n\nLink was successful!\n\n Waiting for trade" : "\n\n\nLink was successful!\n\n Waiting for battle", true); + ptgb_write_debug(debug_charset, curr_gb_rom->version != YELLOW_ID ? "\n\n\nLink was successful!\n\n Waiting for trade" : "\n\n\nLink was successful!\n\n Waiting for battle", true); link_animation_state(STATE_NO_ANIM); state = pretrade; data_counter = 0; @@ -245,7 +245,7 @@ byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ { tte_erase_rect(0, 0, H_MAX, V_MAX); tte_set_pos(40, 24); - ptgb_write_debug("\n\n\nTransferring data...\n please wait!", true); + ptgb_write_debug(debug_charset, "\n\n\nTransferring data...\n please wait!", true); link_animation_state(STATE_TRANSFER); mosi_delay = 1; state = party_preamble; @@ -325,9 +325,10 @@ byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ return in; } -int loop(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_gb_rom, Simplified_Pokemon *curr_simple_array, const u16 *debug_charset, bool cancel_connection) { int counter = 0; + while (true) { // TODO: Restore Errors @@ -338,7 +339,7 @@ int loop(byte *box_data_storage, byte *curr_payload, GB_ROM *curr_gb_rom, Simpli tte_set_margins(0, 0, H_MAX, V_MAX); print("%d: [%d][%d][%" PRIu8 "][%" PRIu8 "]\n\n", counter, data_counter, state, in_data, out_data); } - out_data = handleIncomingByte(in_data, box_data_storage, curr_payload, curr_gb_rom, curr_simple_array, cancel_connection); + out_data = handleIncomingByte(in_data, box_data_storage, curr_payload, curr_gb_rom, curr_simple_array, debug_charset, cancel_connection); if (FF_count > (15 * 60)) { diff --git a/source/pokemon_party.cpp b/source/pokemon_party.cpp index 11fa2ad..20dce8d 100644 --- a/source/pokemon_party.cpp +++ b/source/pokemon_party.cpp @@ -182,12 +182,15 @@ void Pokemon_Party::start_link() } else { - setup(); + u16 debug_charset[256]; + + load_localized_charset(debug_charset, 3, ENG_ID); + setup(debug_charset); for (int i = 0; i < curr_gb_rom.box_data_size; i++) { box_data_array[i] = 0; } - last_error = loop(&box_data_array[0], generate_payload(curr_gb_rom, TRANSFER, false), &curr_gb_rom, simple_pkmn_array, false); + last_error = loop(&box_data_array[0], generate_payload(curr_gb_rom, TRANSFER, false), &curr_gb_rom, simple_pkmn_array, debug_charset, false); } } @@ -195,7 +198,10 @@ void Pokemon_Party::continue_link(bool cancel_connection) { if (!IGNORE_LINK_CABLE) { - last_error = loop(&box_data_array[0], generate_payload(curr_gb_rom, TRANSFER, false), &curr_gb_rom, simple_pkmn_array, cancel_connection); + u16 debug_charset[256]; + + load_localized_charset(debug_charset, 3, ENG_ID); + last_error = loop(&box_data_array[0], generate_payload(curr_gb_rom, TRANSFER, false), &curr_gb_rom, simple_pkmn_array, debug_charset, cancel_connection); } } diff --git a/source/script_array.cpp b/source/script_array.cpp index df6eebb..599e881 100644 --- a/source/script_array.cpp +++ b/source/script_array.cpp @@ -724,7 +724,7 @@ void populate_game_menu(int lang) } } -static bool load_simple_party_data() +static bool __attribute__((noinline)) load_simple_party_data() { PokemonTables data_tables; return party_data.fill_simple_pkmn_array(data_tables);