diff --git a/include/link_handler.h b/include/link_handler.h index 36d6f88..32b04a1 100644 --- a/include/link_handler.h +++ b/include/link_handler.h @@ -363,7 +363,7 @@ public: // These are all the Link Commands bool LinkCommand_InitalizeConnection(bool waitForCompletion = true); bool LinkCommand_ReloadCurrentBox(bool waitForCompletion = true); - bool LinkCommand_TransferPokemon(byte payload[], int payloadLength, bool waitForCompletion = true); + bool LinkCommand_TransferPokemon(int boxNumber, byte removalArray[], int removalArrayLength, bool waitForCompletion); bool LinkCommand_SoftReset(bool waitForCompletion = true); bool LinkCommand_ModifySRAMAccess(bool enableSRAM, byte SRAMbank, bool waitForCompletion = true); bool LinkCommand_RunSecondaryPayload(byte payload[], int payloadLength, bool waitForCompletion = true); diff --git a/source/dbg/debug_mode.cpp b/source/dbg/debug_mode.cpp index ee7a5bf..364e75f 100644 --- a/source/dbg/debug_mode.cpp +++ b/source/dbg/debug_mode.cpp @@ -14,7 +14,7 @@ debug_options g_debug_options = .dont_hide_invalid_pkmn = (false && DEBUG_MODE), .ignore_dex_completion = (false && DEBUG_MODE), .force_all_caught = (false && DEBUG_MODE), - .write_cable_data_to_save = (u8)WRITE_CABLE_DATA_MODE_OFF, + .write_cable_data_to_save = (u8)WRITE_CABLE_DATA_MODE_CART, .load_cable_data_from_save = (u8)WRITE_CABLE_DATA_MODE_OFF, .display_control_char = (false && DEBUG_MODE) }; \ No newline at end of file diff --git a/source/link_handler.cpp b/source/link_handler.cpp index 12c9b86..19f7ca6 100644 --- a/source/link_handler.cpp +++ b/source/link_handler.cpp @@ -610,6 +610,11 @@ void LinkConnection::handleStateLogic() // Add the checksum and we're done with the packet. nextOutData = currOutgoingPacket->secondaryPayloadSizeChecksum; } + else if (inData != currOutgoingPacket->packetID) + { + // We need to wait until the packet is ready to be recieved. + nextOutData = 0xFF; + } else { // Now it's time to process the packet. Use a dummy packet to flush it out @@ -681,6 +686,11 @@ void LinkConnection::prepareForNextCycle() subStateChanged = false; } + if (key_held(KEY_L) && key_held(KEY_R)) + { + exitState = END; + } + globalStateCounter++; enterState = exitState; outData = nextOutData; @@ -825,6 +835,7 @@ bool LinkConnection::processPacket() if (currIncomingPacket->command != CMD_ReadDataRequest) { // These command types will echo the first 8 bytes of the packet back to verify they were recieved correctly. Make sure that's the case. + // This will also fail if a secondary packet fails if ( currIncomingPacket->recievedData[0] != currIncomingPacket->packetID || currIncomingPacket->recievedData[1] != currIncomingPacket->command || @@ -983,15 +994,41 @@ bool LinkConnection::LinkCommand_ReloadCurrentBox(bool waitForCompletion) return true; }; -bool LinkConnection::LinkCommand_TransferPokemon(byte payload[], int payloadLength, bool waitForCompletion) +bool LinkConnection::LinkCommand_TransferPokemon(int boxNumber, byte removalArray[], int removalArrayLength, bool waitForCompletion) { - // Check that box number is correct + int maxBoxes = 0; + if (gen == 1) + { + if (lang == JAPANESE) + { + maxBoxes = 8; + } + else + { + maxBoxes = 12; + } + } + else + { + if (lang == JAPANESE) + { + maxBoxes = 9; + } + else + { + maxBoxes = 14; + } + } + + if (boxNumber >= maxBoxes) + { + return false; + } + resetLinkPackets(); - - // TODO: THIS SHOULD NOT BE HARDCODED TO A BOX - linkPacketArr[0] = LinkPacket(CMD_RunSecondaryPayload, payloadLength + SECONDARY_PAYLOAD_HEADER_SIZE, 0x03, 0xC6DC); - linkPacketArr[0].loadSecondaryPayload(payload, payloadLength); + linkPacketArr[0] = LinkPacket(CMD_TransferPokemon, removalArrayLength + SECONDARY_PAYLOAD_HEADER_SIZE, boxNumber, 0xC6DC); + linkPacketArr[0].loadSecondaryPayload(removalArray, removalArrayLength); globalLinkCable.startConnection(PACKET_EXCHANGE); if (waitForCompletion) @@ -1044,11 +1081,8 @@ bool LinkConnection::LinkCommand_RunSecondaryPayload(byte payload[], int payload { resetLinkPackets(); - byte tempPayload[] = {0x21, 0xA0, 0xC3, 0x75, 0xC9}; - byte size = 5; - - linkPacketArr[0] = LinkPacket(CMD_RunSecondaryPayload, size + SECONDARY_PAYLOAD_HEADER_SIZE, 0x00, 0xC6DC); - linkPacketArr[0].loadSecondaryPayload(tempPayload, size); + linkPacketArr[0] = LinkPacket(CMD_RunSecondaryPayload, payloadLength + SECONDARY_PAYLOAD_HEADER_SIZE, 0x00, 0xC6DC); + linkPacketArr[0].loadSecondaryPayload(payload, payloadLength); globalLinkCable.startConnection(PACKET_EXCHANGE); if (waitForCompletion) diff --git a/source/script_array.cpp b/source/script_array.cpp index c274f5b..0782926 100644 --- a/source/script_array.cpp +++ b/source/script_array.cpp @@ -1,20 +1,20 @@ #include "script_array.h" -#include "button_menu.h" -#include "text_engine.h" -#include "mystery_gift_injector.h" -#include "sprite_data.h" -#include "flash_mem.h" -#include "pokemon_data.h" -#include "mystery_gift_builder.h" -#include "global_frame_controller.h" -#include "box_menu.h" -#include #include "background_engine.h" -#include "select_menu.h" -#include "translated_text.h" -#include "link_handler.h" -#include "text_tables.h" +#include "box_menu.h" +#include "button_menu.h" +#include "flash_mem.h" #include "gb_rom_values/gb_rom_values.h" +#include "global_frame_controller.h" +#include "link_handler.h" +#include "mystery_gift_builder.h" +#include "mystery_gift_injector.h" +#include "pokemon_data.h" +#include "select_menu.h" +#include "sprite_data.h" +#include "text_engine.h" +#include "text_tables.h" +#include "translated_text.h" +#include int last_error; PokeBox box; @@ -23,7 +23,8 @@ Select_Menu langs(false, LANG_MENU, 18, 0); Select_Menu games(false, CART_MENU, 18, 0); Box_Menu box_viewer; -// For documentation purposes, here's an overview of the categories of the transfer script: +// For documentation purposes, here's an overview of the categories of the +// transfer script: // -------- TRANSFER SCRIPT -------- // // Check that the conditions are set for the transfer @@ -103,333 +104,245 @@ Box_Menu box_viewer; // CMD_END_SCRIPT // CMD_BACK_TO_MENU -// The array below is exactly in order of the DIA, commands and condition int values -// So if adding a new dia, command or condition, make sure to add it in the right position/index. -// defining it this way does not generate an expensive function. It's all stored as read-only data in EWRAM. +// The array below is exactly in order of the DIA, commands and condition int +// values So if adding a new dia, command or condition, make sure to add it in +// the right position/index. defining it this way does not generate an expensive +// function. It's all stored as read-only data in EWRAM. const script_obj_params transfer_script_params[SCRIPT_SIZE] = { // PTGB_DIA_OPEN - { - .text_entry_index = PTGB_DIA_OPEN, - .next_if_true = CMD_SET_TUTOR_TRUE}, + {.text_entry_index = PTGB_DIA_OPEN, .next_if_true = CMD_SET_TUTOR_TRUE}, // PTGB_DIA_E4 - { - .text_entry_index = PTGB_DIA_E4, - .next_if_true = CMD_END_SCRIPT}, + {.text_entry_index = PTGB_DIA_E4, .next_if_true = CMD_END_SCRIPT}, // PTGB_DIA_MG_FRLGE - { - .text_entry_index = PTGB_DIA_MG_FRLGE, - .next_if_true = CMD_END_SCRIPT}, + {.text_entry_index = PTGB_DIA_MG_FRLGE, .next_if_true = CMD_END_SCRIPT}, // PTGB_DIA_MG_RS - { - .text_entry_index = PTGB_DIA_MG_RS, - .next_if_true = CMD_END_SCRIPT}, + {.text_entry_index = PTGB_DIA_MG_RS, .next_if_true = CMD_END_SCRIPT}, // PTGB_DIA_LETS_START - { - .text_entry_index = PTGB_DIA_LETS_START, - .next_if_true = PTGB_DIA_START}, + {.text_entry_index = PTGB_DIA_LETS_START, .next_if_true = PTGB_DIA_START}, // PTGB_DIA_START - { - .text_entry_index = PTGB_DIA_START, - .next_if_true = CMD_START_LINK}, + {.text_entry_index = PTGB_DIA_START, .next_if_true = CMD_START_LINK}, // PTGB_DIA_TRANS_GOOD - { - .text_entry_index = PTGB_DIA_TRANS_GOOD, - .next_if_true = COND_NEW_POKEMON}, + {.text_entry_index = PTGB_DIA_TRANS_GOOD, .next_if_true = COND_NEW_POKEMON}, // PTGB_DIA_NEW_DEX - { - .text_entry_index = PTGB_DIA_NEW_DEX, - .next_if_true = COND_IS_HOENN_RS}, + {.text_entry_index = PTGB_DIA_NEW_DEX, .next_if_true = COND_IS_HOENN_RS}, // PTGB_DIA_NO_NEW_DEX - { - .text_entry_index = PTGB_DIA_NO_NEW_DEX, - .next_if_true = COND_IS_HOENN_RS}, + {.text_entry_index = PTGB_DIA_NO_NEW_DEX, .next_if_true = COND_IS_HOENN_RS}, // PTGB_DIA_SEND_FRIEND_KANTO - { - .text_entry_index = PTGB_DIA_SEND_FRIEND_KANTO, + {.text_entry_index = PTGB_DIA_SEND_FRIEND_KANTO, .next_if_true = PTGB_DIA_THANK}, // PTGB_DIA_SEND_FRIEND_HOENN_RS - { - .text_entry_index = PTGB_DIA_SEND_FRIEND_HOENN_RS, + {.text_entry_index = PTGB_DIA_SEND_FRIEND_HOENN_RS, .next_if_true = PTGB_DIA_THANK}, // PTGB_DIA_SEND_FRIEND_HOENN_E - { - .text_entry_index = PTGB_DIA_SEND_FRIEND_HOENN_E, + {.text_entry_index = PTGB_DIA_SEND_FRIEND_HOENN_E, .next_if_true = PTGB_DIA_THANK}, // PTGB_DIA_THANK - { - .text_entry_index = PTGB_DIA_THANK, - .next_if_true = CMD_END_SCRIPT}, + {.text_entry_index = PTGB_DIA_THANK, .next_if_true = CMD_END_SCRIPT}, // PTGB_DIA_GET_MON (unused) - { - .text_entry_index = PTGB_DIA_GET_MON, - .next_if_true = CMD_END_SCRIPT}, + {.text_entry_index = PTGB_DIA_GET_MON, .next_if_true = CMD_END_SCRIPT}, // PTGB_DIA_MG_OTHER_EVENT - { - .text_entry_index = PTGB_DIA_MG_OTHER_EVENT, + {.text_entry_index = PTGB_DIA_MG_OTHER_EVENT, .next_if_true = PTGB_DIA_LETS_START}, // PTGB_DIA_PKMN_TO_COLLECT - { - .text_entry_index = PTGB_DIA_PKMN_TO_COLLECT, + {.text_entry_index = PTGB_DIA_PKMN_TO_COLLECT, .next_if_true = CMD_END_SCRIPT}, // PTGB_DIA_NO_VALID_PKMN - { - .text_entry_index = PTGB_DIA_NO_VALID_PKMN, + {.text_entry_index = PTGB_DIA_NO_VALID_PKMN, .next_if_true = CMD_CANCEL_LINK}, // PTGB_DIA_ASK_QUEST - { - .text_entry_index = PTGB_DIA_ASK_QUEST, + {.text_entry_index = PTGB_DIA_ASK_QUEST, .next_if_true = CMD_SLIDE_PROF_LEFT}, // PTGB_DIA_WHAT_GAME_TRANS - { - .text_entry_index = PTGB_DIA_WHAT_GAME_TRANS, + {.text_entry_index = PTGB_DIA_WHAT_GAME_TRANS, .next_if_true = CMD_GAME_MENU}, // PTGB_DIA_WHAT_LANG_TRANS - { - .text_entry_index = PTGB_DIA_WHAT_LANG_TRANS, + {.text_entry_index = PTGB_DIA_WHAT_LANG_TRANS, .next_if_true = CMD_LANG_MENU}, // PTGB_DIA_NO_GB_ROM - { - .text_entry_index = PTGB_DIA_NO_GB_ROM, + {.text_entry_index = PTGB_DIA_NO_GB_ROM, .next_if_true = PTGB_DIA_WHAT_LANG_TRANS}, // PTGB_DIA_IN_BOX - { - .text_entry_index = PTGB_DIA_IN_BOX, - .next_if_true = CMD_BOX_MENU}, + {.text_entry_index = PTGB_DIA_IN_BOX, .next_if_true = CMD_BOX_MENU}, // PTGB_DIA_MYTHIC_CONVERT - { - .text_entry_index = PTGB_DIA_MYTHIC_CONVERT, + {.text_entry_index = PTGB_DIA_MYTHIC_CONVERT, .next_if_true = CMD_MYTHIC_MENU}, // PTGB_DIA_CANCEL - { - .text_entry_index = PTGB_DIA_CANCEL, - .next_if_true = CMD_CANCEL_LINK}, + {.text_entry_index = PTGB_DIA_CANCEL, .next_if_true = CMD_CANCEL_LINK}, // PTGB_DIA_SOME_INVALID_PKMN - { - .text_entry_index = PTGB_DIA_SOME_INVALID_PKMN, + {.text_entry_index = PTGB_DIA_SOME_INVALID_PKMN, .next_if_true = COND_CHECK_MYTHIC}, // PTGB_DIA_MENU_BACK - { - .text_entry_index = PTGB_DIA_MENU_BACK, - .next_if_true = CMD_END_SCRIPT}, + {.text_entry_index = PTGB_DIA_MENU_BACK, .next_if_true = CMD_END_SCRIPT}, // PTGB_DIA_IS_MISSINGNO - { - .text_entry_index = PTGB_DIA_IS_MISSINGNO, + {.text_entry_index = PTGB_DIA_IS_MISSINGNO, .next_if_true = PTGB_DIA_IN_BOX}, // PTGB_DIA_ERROR_COLOSSEUM - { - .text_entry_index = PTGB_DIA_ERROR_COLOSSEUM, + {.text_entry_index = PTGB_DIA_ERROR_COLOSSEUM, .next_if_true = PTGB_DIA_START}, // PTGB_DIA_ERROR_COM_ENDED - { - .text_entry_index = PTGB_DIA_ERROR_COM_ENDED, + {.text_entry_index = PTGB_DIA_ERROR_COM_ENDED, .next_if_true = PTGB_DIA_START}, // PTGB_DIA_ERROR_DISCONNECT - { - .text_entry_index = PTGB_DIA_ERROR_DISCONNECT, + {.text_entry_index = PTGB_DIA_ERROR_DISCONNECT, .next_if_true = PTGB_DIA_START}, // PTGB_DIA_ERROR_TIME_ONE - { - .text_entry_index = PTGB_DIA_ERROR_TIME_ONE, + {.text_entry_index = PTGB_DIA_ERROR_TIME_ONE, .next_if_true = PTGB_DIA_START}, // PTGB_DIA_ERROR_TIME_TWO - { - .text_entry_index = PTGB_DIA_ERROR_TIME_TWO, + {.text_entry_index = PTGB_DIA_ERROR_TIME_TWO, .next_if_true = PTGB_DIA_START}, // PTGB_DIA_WHAT_LANG_EVENT - { - .text_entry_index = PTGB_DIA_WHAT_LANG_EVENT, + {.text_entry_index = PTGB_DIA_WHAT_LANG_EVENT, .next_if_true = CMD_LANG_MENU}, // PTGB_DIA_WHAT_GAME_EVENT - { - .text_entry_index = PTGB_DIA_WHAT_GAME_EVENT, + {.text_entry_index = PTGB_DIA_WHAT_GAME_EVENT, .next_if_true = CMD_GAME_MENU}, // PTGB_DIA_K_DEX_NOT_FULL - { - .text_entry_index = PTGB_DIA_K_DEX_NOT_FULL, + {.text_entry_index = PTGB_DIA_K_DEX_NOT_FULL, .next_if_true = CMD_END_SCRIPT}, // PTGB_DIA_J_DEX_NOT_FULL - { - .text_entry_index = PTGB_DIA_J_DEX_NOT_FULL, + {.text_entry_index = PTGB_DIA_J_DEX_NOT_FULL, .next_if_true = CMD_END_SCRIPT}, // T_SCRIPT_START - { - .conditional_index = CMD_SHOW_PROF, + {.conditional_index = CMD_SHOW_PROF, .next_if_true = COND_TUTORIAL_COMPLETE}, // E_SCRIPT_START - { - .conditional_index = CMD_SHOW_PROF, - .next_if_true = PTGB_DIA_LETS_START}, + {.conditional_index = CMD_SHOW_PROF, .next_if_true = PTGB_DIA_LETS_START}, // CMD_START_LINK - { - .conditional_index = CMD_START_LINK, + {.conditional_index = CMD_START_LINK, .next_if_true = COND_ERROR_TIMEOUT_ONE}, // CMD_IMPORT_POKEMON - { - .conditional_index = CMD_IMPORT_POKEMON, + {.conditional_index = CMD_IMPORT_POKEMON, .next_if_true = CMD_CONTINUE_LINK}, // CMD_BACK_TO_MENU - { - .conditional_index = CMD_BACK_TO_MENU, - .next_if_true = T_SCRIPT_START}, - // CMD_SHOW_PROF (unused in this manner (not used in a next_if_true). Therefore this is a dummy entry) - // we even need to define such unused values to keep the array element positions in order + {.conditional_index = CMD_BACK_TO_MENU, .next_if_true = T_SCRIPT_START}, + // CMD_SHOW_PROF (unused in this manner (not used in a next_if_true). + // Therefore this is a dummy entry) + // we even need to define such unused values to keep the array element + // positions in order {}, - // CMD_HIDE_PROF (unused in this manner (not used in a next_if_true). Therefore this is a dummy entry) + // CMD_HIDE_PROF (unused in this manner (not used in a next_if_true). + // Therefore this is a dummy entry) {}, // CMD_SET_TUTOR_TRUE - { - .conditional_index = CMD_SET_TUTOR_TRUE, - .next_if_true = CMD_END_SCRIPT}, + {.conditional_index = CMD_SET_TUTOR_TRUE, .next_if_true = CMD_END_SCRIPT}, // CMD_END_SCRIPT - { - .conditional_index = CMD_END_SCRIPT, - .next_if_true = CMD_BACK_TO_MENU}, + {.conditional_index = CMD_END_SCRIPT, .next_if_true = CMD_BACK_TO_MENU}, // CMD_GAME_MENU - { - .conditional_index = CMD_GAME_MENU, + {.conditional_index = CMD_GAME_MENU, .next_if_true = COND_GB_ROM_EXISTS, .next_if_false = PTGB_DIA_WHAT_LANG_TRANS}, // CMD_LANG_MENU - { - .conditional_index = CMD_LANG_MENU, + {.conditional_index = CMD_LANG_MENU, .next_if_true = PTGB_DIA_WHAT_GAME_TRANS, .next_if_false = PTGB_DIA_CANCEL}, // CMD_SLIDE_PROF_LEFT - { - .conditional_index = CMD_SLIDE_PROF_LEFT, + {.conditional_index = CMD_SLIDE_PROF_LEFT, .next_if_true = PTGB_DIA_WHAT_LANG_TRANS}, // CMD_SLIDE_PROF_RIGHT - { - .conditional_index = CMD_SLIDE_PROF_RIGHT, + {.conditional_index = CMD_SLIDE_PROF_RIGHT, .next_if_true = PTGB_DIA_LETS_START}, // CMD_CONTINUE_LINK - { - .conditional_index = CMD_CONTINUE_LINK, - .next_if_true = CMD_END_MISSINGNO}, + {.conditional_index = CMD_CONTINUE_LINK, .next_if_true = CMD_END_MISSINGNO}, // CMD_BOX_MENU - { - .conditional_index = CMD_BOX_MENU, + {.conditional_index = CMD_BOX_MENU, .next_if_true = CMD_IMPORT_POKEMON, .next_if_false = PTGB_DIA_CANCEL}, // CMD_MYTHIC_MENU - { - .conditional_index = CMD_MYTHIC_MENU, + {.conditional_index = CMD_MYTHIC_MENU, .next_if_true = COND_CHECK_MISSINGNO}, // CMD_IS_A_VALID_PKMN - { - .conditional_index = CMD_IS_A_VALID_PKMN, + {.conditional_index = CMD_IS_A_VALID_PKMN, .next_if_true = COND_SOME_INVALID_PKMN, .next_if_false = PTGB_DIA_NO_VALID_PKMN}, // CMD_CANCEL_LINK - { - .conditional_index = CMD_CANCEL_LINK, - .next_if_true = CMD_END_SCRIPT}, + {.conditional_index = CMD_CANCEL_LINK, .next_if_true = CMD_END_SCRIPT}, // CMD_END_MISSINGNO - { - .conditional_index = CMD_END_MISSINGNO, + {.conditional_index = CMD_END_MISSINGNO, .next_if_true = PTGB_DIA_TRANS_GOOD}, // COND_ERROR_TIMEOUT_ONE - { - .conditional_index = COND_ERROR_TIMEOUT_ONE, + {.conditional_index = COND_ERROR_TIMEOUT_ONE, .next_if_true = COND_ERROR_TIMEOUT_TWO, .next_if_false = PTGB_DIA_ERROR_TIME_ONE}, // COND_ERROR_DISCONNECT - { - .conditional_index = COND_ERROR_DISCONNECT, + {.conditional_index = COND_ERROR_DISCONNECT, .next_if_true = CMD_IS_A_VALID_PKMN, .next_if_false = PTGB_DIA_ERROR_DISCONNECT}, // COND_ERROR_COM_ENDED - { - .conditional_index = COND_ERROR_COM_ENDED, + {.conditional_index = COND_ERROR_COM_ENDED, .next_if_true = COND_ERROR_COLOSSEUM, .next_if_false = PTGB_DIA_ERROR_COM_ENDED}, // COND_ERROR_TIMEOUT_TWO - { - .conditional_index = COND_ERROR_TIMEOUT_TWO, + {.conditional_index = COND_ERROR_TIMEOUT_TWO, .next_if_true = COND_ERROR_COM_ENDED, .next_if_false = PTGB_DIA_ERROR_TIME_TWO}, // COND_ERROR_COLOSSEUM - { - .conditional_index = COND_ERROR_COLOSSEUM, + {.conditional_index = COND_ERROR_COLOSSEUM, .next_if_true = COND_ERROR_DISCONNECT, .next_if_false = PTGB_DIA_ERROR_COLOSSEUM}, // COND_BEAT_E4 - { - .conditional_index = COND_BEAT_E4, + {.conditional_index = COND_BEAT_E4, .next_if_true = COND_MG_ENABLED, .next_if_false = PTGB_DIA_E4}, // COND_MG_ENABLED - { - .conditional_index = COND_MG_ENABLED, + {.conditional_index = COND_MG_ENABLED, .next_if_true = COND_MG_OTHER_EVENT, .next_if_false = COND_IS_FRLGE}, // COND_TUTORIAL_COMPLETE - { - .conditional_index = COND_TUTORIAL_COMPLETE, + {.conditional_index = COND_TUTORIAL_COMPLETE, .next_if_true = COND_BEAT_E4, .next_if_false = PTGB_DIA_OPEN}, // COND_NEW_POKEMON - { - .conditional_index = COND_NEW_POKEMON, + {.conditional_index = COND_NEW_POKEMON, .next_if_true = PTGB_DIA_NEW_DEX, .next_if_false = PTGB_DIA_NO_NEW_DEX}, // COND_IS_HOENN_RS - { - .conditional_index = COND_IS_HOENN_RS, + {.conditional_index = COND_IS_HOENN_RS, .next_if_true = PTGB_DIA_SEND_FRIEND_HOENN_RS, .next_if_false = COND_IS_HOENN_E}, // COND_IS_FRLGE - { - .conditional_index = COND_IS_FRLGE, + {.conditional_index = COND_IS_FRLGE, .next_if_true = PTGB_DIA_MG_FRLGE, .next_if_false = PTGB_DIA_MG_RS}, // COND_MG_OTHER_EVENT - { - .conditional_index = COND_MG_OTHER_EVENT, + {.conditional_index = COND_MG_OTHER_EVENT, .next_if_true = PTGB_DIA_MG_OTHER_EVENT, .next_if_false = COND_PKMN_TO_COLLECT}, // COND_PKMN_TO_COLLECT - { - .conditional_index = COND_PKMN_TO_COLLECT, + {.conditional_index = COND_PKMN_TO_COLLECT, .next_if_true = PTGB_DIA_PKMN_TO_COLLECT, .next_if_false = PTGB_DIA_LETS_START}, // COND_GB_ROM_EXISTS - { - .conditional_index = COND_GB_ROM_EXISTS, + {.conditional_index = COND_GB_ROM_EXISTS, .next_if_true = CMD_SLIDE_PROF_RIGHT, .next_if_false = PTGB_DIA_NO_GB_ROM}, // COND_CHECK_MYTHIC - { - .conditional_index = COND_CHECK_MYTHIC, + {.conditional_index = COND_CHECK_MYTHIC, .next_if_true = PTGB_DIA_MYTHIC_CONVERT, .next_if_false = COND_CHECK_MISSINGNO}, // COND_CHECK_DEX - { - .conditional_index = COND_CHECK_DEX, + {.conditional_index = COND_CHECK_DEX, .next_if_true = 0, .next_if_false = COND_CHECK_KANTO}, // COND_CHECK_KANTO - { - .conditional_index = COND_CHECK_KANTO, + {.conditional_index = COND_CHECK_KANTO, .next_if_true = PTGB_DIA_K_DEX_NOT_FULL, .next_if_false = PTGB_DIA_J_DEX_NOT_FULL}, // COND_SOME_INVALID_PKMN - { - .conditional_index = COND_SOME_INVALID_PKMN, + {.conditional_index = COND_SOME_INVALID_PKMN, .next_if_true = PTGB_DIA_SOME_INVALID_PKMN, .next_if_false = COND_CHECK_MYTHIC}, // COND_IS_HOENN_E - { - .conditional_index = COND_IS_HOENN_E, + {.conditional_index = COND_IS_HOENN_E, .next_if_true = PTGB_DIA_SEND_FRIEND_HOENN_E, .next_if_false = PTGB_DIA_SEND_FRIEND_KANTO}, // COND_CHECK_MISSINGNO - { - .conditional_index = COND_CHECK_MISSINGNO, + {.conditional_index = COND_CHECK_MISSINGNO, .next_if_true = PTGB_DIA_IS_MISSINGNO, .next_if_false = PTGB_DIA_IN_BOX}}; -// For documentation purposes, here's an overview of the categories of the events script: +// For documentation purposes, here's an overview of the categories of the +// events script: // -------- EVENTS SCRIPT -------- // Start the dialogue and show the menu // E_SCRIPT_START @@ -456,11 +369,13 @@ const script_obj_params transfer_script_params[SCRIPT_SIZE] = { // CMD_END_SCRIPT // CMD_BACK_TO_MENU -// The array below is exactly in order of the DIA, commands and condition int values -// So if adding a new dia, command or condition, make sure to add it in the right position/index. -// because things are in order, it also means we have to define every possible entry even if we don't use it. -// defining it this way does not generate an expensive function. It's all stored as read-only data in EWRAM. -// Although frankly given the small amount of defined entries, we ARE wasting a lot of space with this one. (probably around 500 bytes) +// The array below is exactly in order of the DIA, commands and condition int +// values So if adding a new dia, command or condition, make sure to add it in +// the right position/index. because things are in order, it also means we have +// to define every possible entry even if we don't use it. defining it this way +// does not generate an expensive function. It's all stored as read-only data in +// EWRAM. Although frankly given the small amount of defined entries, we ARE +// wasting a lot of space with this one. (probably around 500 bytes) const script_obj_params event_script_params[SCRIPT_SIZE] = { {}, // PTGB_DIA_OPEN {}, // PTGB_DIA_E4 @@ -480,14 +395,12 @@ const script_obj_params event_script_params[SCRIPT_SIZE] = { {}, // PTGB_DIA_PKMN_TO_COLLECT {}, // PTGB_DIA_NO_VALID_PKMN // PTGB_DIA_ASK_QUEST - { - .text_entry_index = PTGB_DIA_ASK_QUEST, + {.text_entry_index = PTGB_DIA_ASK_QUEST, .next_if_true = CMD_SLIDE_PROF_LEFT}, {}, // PTGB_DIA_WHAT_GAME_TRANS {}, // PTGB_DIA_WHAT_LANG_TRANS // PTGB_DIA_NO_GB_ROM - { - .text_entry_index = PTGB_DIA_NO_GB_ROM, + {.text_entry_index = PTGB_DIA_NO_GB_ROM, .next_if_true = PTGB_DIA_WHAT_LANG_EVENT}, {}, // PTGB_DIA_IN_BOX {}, // PTGB_DIA_MYTHIC_CONVERT @@ -501,56 +414,41 @@ const script_obj_params event_script_params[SCRIPT_SIZE] = { {}, // PTGB_DIA_ERROR_TIME_ONE {}, // PTGB_DIA_ERROR_TIME_TWO // PTGB_DIA_WHAT_LANG_EVENT - { - .text_entry_index = PTGB_DIA_WHAT_LANG_EVENT, + {.text_entry_index = PTGB_DIA_WHAT_LANG_EVENT, .next_if_true = CMD_LANG_MENU}, // PTGB_DIA_WHAT_GAME_EVENT - { - .text_entry_index = PTGB_DIA_WHAT_GAME_EVENT, + {.text_entry_index = PTGB_DIA_WHAT_GAME_EVENT, .next_if_true = CMD_GAME_MENU}, // PTGB_DIA_K_DEX_NOT_FULL - { - .text_entry_index = PTGB_DIA_K_DEX_NOT_FULL, + {.text_entry_index = PTGB_DIA_K_DEX_NOT_FULL, .next_if_true = CMD_END_SCRIPT}, // PTGB_DIA_J_DEX_NOT_FULL - { - .text_entry_index = PTGB_DIA_J_DEX_NOT_FULL, + {.text_entry_index = PTGB_DIA_J_DEX_NOT_FULL, .next_if_true = CMD_END_SCRIPT}, {}, // T_SCRIPT_START // E_SCRIPT_START - { - .conditional_index = CMD_SHOW_PROF, - .next_if_true = PTGB_DIA_ASK_QUEST}, + {.conditional_index = CMD_SHOW_PROF, .next_if_true = PTGB_DIA_ASK_QUEST}, {}, // CMD_START_LINK {}, // CMD_IMPORT_POKEMON // CMD_BACK_TO_MENU - { - .conditional_index = CMD_BACK_TO_MENU, - .next_if_true = T_SCRIPT_START}, + {.conditional_index = CMD_BACK_TO_MENU, .next_if_true = T_SCRIPT_START}, {}, // CMD_SHOW_PROF {}, // CMD_HIDE_PROF {}, // CMD_SET_TUTOR_TRUE // CMD_END_SCRIPT - { - .conditional_index = CMD_END_SCRIPT, - .next_if_true = CMD_BACK_TO_MENU}, + {.conditional_index = CMD_END_SCRIPT, .next_if_true = CMD_BACK_TO_MENU}, // CMD_GAME_MENU - { - .conditional_index = CMD_GAME_MENU, + {.conditional_index = CMD_GAME_MENU, .next_if_true = COND_GB_ROM_EXISTS, .next_if_false = PTGB_DIA_WHAT_LANG_EVENT}, // CMD_LANG_MENU - { - .conditional_index = CMD_LANG_MENU, + {.conditional_index = CMD_LANG_MENU, .next_if_true = PTGB_DIA_WHAT_GAME_EVENT}, // CMD_SLIDE_PROF_LEFT - { - .conditional_index = CMD_SLIDE_PROF_LEFT, + {.conditional_index = CMD_SLIDE_PROF_LEFT, .next_if_true = PTGB_DIA_WHAT_LANG_EVENT}, // CMD_SLIDE_PROF_RIGHT - { - .conditional_index = CMD_SLIDE_PROF_RIGHT, - .next_if_true = COND_CHECK_DEX}, + {.conditional_index = CMD_SLIDE_PROF_RIGHT, .next_if_true = COND_CHECK_DEX}, {}, // CMD_CONTINUE_LINK {}, // CMD_BOX_MENU {}, // CMD_MYTHIC_MENU @@ -571,19 +469,16 @@ const script_obj_params event_script_params[SCRIPT_SIZE] = { {}, // COND_MG_OTHER_EVENT {}, // COND_PKMN_TO_COLLECT // COND_GB_ROM_EXISTS - { - .conditional_index = COND_GB_ROM_EXISTS, + {.conditional_index = COND_GB_ROM_EXISTS, .next_if_true = CMD_SLIDE_PROF_RIGHT, .next_if_false = PTGB_DIA_NO_GB_ROM}, {}, // COND_CHECK_MYTHIC // COND_CHECK_DEX - { - .conditional_index = COND_CHECK_DEX, + {.conditional_index = COND_CHECK_DEX, .next_if_true = 0, .next_if_false = COND_CHECK_KANTO}, // COND_CHECK_KANTO - { - .conditional_index = COND_CHECK_KANTO, + {.conditional_index = COND_CHECK_KANTO, .next_if_true = PTGB_DIA_K_DEX_NOT_FULL, .next_if_false = PTGB_DIA_J_DEX_NOT_FULL}, {}, // COND_SOME_INVALID_PKMN @@ -644,7 +539,8 @@ void populate_game_menu(int lang) bool run_conditional(int index) { - // Here is most of the logic that drives what lines show up where. It's probably not the best way to code it, but it works + // Here is most of the logic that drives what lines show up where. It's + // probably not the best way to code it, but it works bool ret; switch (index) { @@ -665,10 +561,12 @@ bool run_conditional(int index) return globalLinkCable.lastError != COND_ERROR_COLOSSEUM; case COND_BEAT_E4: - return read_flag(curr_GBA_rom.e4_flag) || g_debug_options.ignore_mg_e4_flags; + return read_flag(curr_GBA_rom.e4_flag) || + g_debug_options.ignore_mg_e4_flags; case COND_MG_ENABLED: - return read_flag(curr_GBA_rom.mg_flag) || g_debug_options.ignore_mg_e4_flags; + return read_flag(curr_GBA_rom.mg_flag) || + g_debug_options.ignore_mg_e4_flags; case COND_TUTORIAL_COMPLETE: return get_tutorial_flag() && !g_debug_options.force_tutorial; @@ -683,10 +581,15 @@ bool run_conditional(int index) return !curr_GBA_rom.is_ruby_sapphire(); case COND_MG_OTHER_EVENT: - return compare_map_and_npc_data(curr_GBA_rom.def_map_bank, curr_GBA_rom.def_map_id, curr_GBA_rom.def_npc_id) && !g_debug_options.ignore_mg_e4_flags; + return compare_map_and_npc_data(curr_GBA_rom.def_map_bank, + curr_GBA_rom.def_map_id, curr_GBA_rom.def_npc_id) && + !g_debug_options.ignore_mg_e4_flags; case COND_PKMN_TO_COLLECT: - return compare_map_and_npc_data(curr_GBA_rom.map_bank, curr_GBA_rom.map_id, curr_GBA_rom.npc_id) && !read_flag(curr_GBA_rom.all_collected_flag) && !g_debug_options.ignore_unreceived_pkmn; + return compare_map_and_npc_data(curr_GBA_rom.map_bank, + curr_GBA_rom.map_id, curr_GBA_rom.npc_id) && + !read_flag(curr_GBA_rom.all_collected_flag) && + !g_debug_options.ignore_unreceived_pkmn; case COND_GB_ROM_EXISTS: return true; @@ -697,11 +600,13 @@ bool run_conditional(int index) case COND_CHECK_DEX: if (globalLinkCable.gen == 1) { - return (get_dex_completion(1, false) == 150) || g_debug_options.ignore_dex_completion; + return (get_dex_completion(1, false) == 150) || + g_debug_options.ignore_dex_completion; } else { - return (get_dex_completion(1, false) == 99) || g_debug_options.ignore_dex_completion; + return (get_dex_completion(1, false) == 99) || + g_debug_options.ignore_dex_completion; } case COND_CHECK_KANTO: @@ -727,24 +632,29 @@ bool run_conditional(int index) if (g_debug_options.ignore_link_cable) { // TODO - Make this less hardcoded - //box.loadData(1, ENGLISH, gen1_rb_debug_box_data); + // box.loadData(1, ENGLISH, gen1_rb_debug_box_data); } else { u8 general_text_table_buffer[2048]; - u8 lineBuffer[1024]; // text_helper/main.py restricts the lines to 1024 bytes. + u8 lineBuffer[1024]; // text_helper/main.py restricts the lines to + // 1024 bytes. const u8 **chunkList; u32 numChunks; u32 chunkSize; - get_text_table_chunks(GENERAL_INDEX, &chunkList, &numChunks, &chunkSize); + get_text_table_chunks( + GENERAL_INDEX, &chunkList, &numChunks, &chunkSize); - FileContainerReader general_text_reader(chunkList, numChunks, chunkSize); - general_text_reader.init(general_text_table_buffer, sizeof(general_text_table_buffer)); + FileContainerReader general_text_reader( + chunkList, numChunks, chunkSize); + general_text_reader.init( + general_text_table_buffer, sizeof(general_text_table_buffer)); general_text_reader.readFile(GENERAL_connecting, lineBuffer); - ptgb_write_textbox(lineBuffer, true, false, GENERAL_INDEX, GENERAL_connecting, false); + ptgb_write_textbox(lineBuffer, true, false, GENERAL_INDEX, + GENERAL_connecting, false); load_select_sprites(NO_GB_ROM); obj_unhide(gba_cart, 0); @@ -766,17 +676,22 @@ bool run_conditional(int index) globalLinkCable.LinkCommand_InitalizeConnection(false); while (globalLinkCable.exitState != END) { - if (globalLinkCable.subStateChanged && !g_debug_options.print_link_data) + if (globalLinkCable.subStateChanged && + !g_debug_options.print_link_data) { switch (globalLinkCable.exitState) { case SAVE_SUCCESS: - general_text_reader.readFile(GENERAL_link_success, lineBuffer); - ptgb_write_textbox(lineBuffer, true, false, GENERAL_INDEX, GENERAL_link_success, false); + general_text_reader.readFile( + GENERAL_link_success, lineBuffer); + ptgb_write_textbox(lineBuffer, true, false, + GENERAL_INDEX, GENERAL_link_success, false); break; case TRADE_PREAMBLE: - general_text_reader.readFile(GENERAL_transferring, lineBuffer); - ptgb_write_textbox(lineBuffer, true, false, GENERAL_INDEX, GENERAL_transferring, false); + general_text_reader.readFile( + GENERAL_transferring, lineBuffer); + ptgb_write_textbox(lineBuffer, true, false, + GENERAL_INDEX, GENERAL_transferring, false); break; default: break; @@ -796,10 +711,12 @@ bool run_conditional(int index) globalLinkCable.pauseOnPacket = true; byte boxDataArray[1122]; - - globalLinkCable.LinkCommand_ReadMemorySection(0xDA80, boxDataArray, 1122); - box.loadData(globalLinkCable.gen, globalLinkCable.lang, boxDataArray); + globalLinkCable.LinkCommand_ReadMemorySection(0xDA80, + boxDataArray, 1122); + + box.loadData(globalLinkCable.gen, globalLinkCable.lang, + boxDataArray); } reload_textbox_background(); load_flex_background(FLEXBG_FENNEL, 2); @@ -875,7 +792,8 @@ bool run_conditional(int index) if (box.getGen3Pokemon(i)->isValid) { box.removePokemon(i); - if (!(DONT_TRANSFER_POKEMON_AT_INDEX_X && i == POKEMON_INDEX_TO_SKIP)) + if (!(DONT_TRANSFER_POKEMON_AT_INDEX_X && + i == POKEMON_INDEX_TO_SKIP)) { boxRemovalPayload[arrayIndex] = i; arrayIndex++; @@ -885,7 +803,8 @@ bool run_conditional(int index) boxRemovalPayload[arrayIndex] = 0xFF; arrayIndex++; - globalLinkCable.LinkCommand_TransferPokemon(boxRemovalPayload, arrayIndex); + globalLinkCable.LinkCommand_TransferPokemon( + boxRemovalPayload, arrayIndex); } return true; diff --git a/tools/text_helper/text.xlsx b/tools/text_helper/text.xlsx index 6730c5a..c65690a 100644 Binary files a/tools/text_helper/text.xlsx and b/tools/text_helper/text.xlsx differ