diff --git a/Pokemon_Mirror_mb-0.png b/Pokemon_Mirror_mb-0.png deleted file mode 100644 index 8cf3d41..0000000 Binary files a/Pokemon_Mirror_mb-0.png and /dev/null differ diff --git a/include/debug_mode.h b/include/debug_mode.h index 2da2c02..ab0871c 100644 --- a/include/debug_mode.h +++ b/include/debug_mode.h @@ -1,12 +1,12 @@ #ifndef DEBUG_MODE_H #define DEBUG_MODE_H -#define DEBUG_MODE false -#define IGNORE_GAME_PAK false +#define DEBUG_MODE true +#define IGNORE_GAME_PAK true #define IGNORE_LINK_CABLE false -#define IGNORE_MG_E4_FLAGS false +#define IGNORE_MG_E4_FLAGS true -#define DEBUG_GAME SAPPHIRE_ID +#define DEBUG_GAME EMERALD_ID #define DEBUG_VERS VERS_1_0 #define DEBUG_LANG LANG_ENG diff --git a/include/gameboy_colour.h b/include/gameboy_colour.h index 2f9a962..77cb372 100644 --- a/include/gameboy_colour.h +++ b/include/gameboy_colour.h @@ -26,6 +26,10 @@ */ +// The number of frames(?) between changing the clock signals +#define FAST_SPEED 10 +#define SLOW_SPEED 1000 + void setup(); byte handleIncomingByte(byte in); int transferBit(byte *party_data); diff --git a/include/output.h b/include/output.h index 7ff8dea..e039747 100644 --- a/include/output.h +++ b/include/output.h @@ -2,11 +2,15 @@ #include -#define PLAYER_LENGTH 418 //11+8+(44*6)+(11*6)+(11*6)+3 +#define PLAYER_LENGTH_GEN_I 418 //11+8+(44*6)+(11*6)+(11*6) #define PLAYER_LENGTH_GEN_II 444 //11+8+2+(48*6)+(11*6)+(11*6)+3 -uint8_t INPUT_BLOCK[PLAYER_LENGTH]; -uint8_t INPUT_BLOCK_GEN_II[PLAYER_LENGTH_GEN_II]; + +#define PATCH_LIST_LEN_GEN_I 196 + + +//uint8_t INPUT_BLOCK_GEN_I[PLAYER_LENGTH_GEN_I]; +//uint8_t INPUT_BLOCK_GEN_II[PLAYER_LENGTH_GEN_II]; /* const uint8_t DATA_BLOCK[PLAYER_LENGTH] PROGMEM = { 0x80, 0x91, 0x83, 0x94, 0x88, 0x8D, 0x8E, 0x50, 0x00, 0x00, 0x00, // name @@ -36,6 +40,7 @@ uint8_t INPUT_BLOCK_GEN_II[PLAYER_LENGTH_GEN_II]; // 2 useless bytes?? 0x00, 0x00, 0x00}; */ +/* const uint8_t DATA_BLOCK_GEN_II[PLAYER_LENGTH_GEN_II] = { 0x80, 0x91, 0x83, 0x94, 0x88, 0x8D, 0x8E, 0x50, 0x00, 0x00, 0x00, // name 0x1, 0x5C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // number of pokemon in party (0x00), pokemon ID (0x01 - 0x06), stop byte (0x07) @@ -64,3 +69,4 @@ const uint8_t DATA_BLOCK_GEN_II[PLAYER_LENGTH_GEN_II] = { 0x8C, 0x80, 0x86, 0x88, 0x8A, 0x80, 0x91, 0x8F, 0x50, 0x50, 0x50, // 2 useless bytes?? 0x00, 0x00, 0x00}; +*/ \ No newline at end of file diff --git a/include/payload.h b/include/payload.h new file mode 100644 index 0000000..910346b --- /dev/null +++ b/include/payload.h @@ -0,0 +1,10 @@ +#ifndef PAYLOAD_H +#define PAYLOAD_H + +#include +#include "output.h" + +extern byte gen1_party_bootstrap[PLAYER_LENGTH_GEN_I]; +extern byte gen1_omnipayload[PATCH_LIST_LEN_GEN_I]; + +#endif \ No newline at end of file diff --git a/source/gameboy_colour.cpp b/source/gameboy_colour.cpp index daa47a4..3260eb3 100644 --- a/source/gameboy_colour.cpp +++ b/source/gameboy_colour.cpp @@ -8,6 +8,7 @@ #include "LinkGPIO.h" #include "script_array.h" #include "debug_mode.h" +#include "payload.h" #define BYTE_INCOMPLETE 0 #define BYTE_COMPLETE 1 @@ -15,7 +16,7 @@ #define TIMEOUT_ONE_LENGTH 1000000 // Maybe keep a 10:1 ratio between ONE and TWO? #define TIMEOUT_TWO_LENGTH 100000 -const int MODE = 1; // mode=0 will transfer pokemon data from pokemon.h +const int MODE = 0; // mode=0 will transfer pokemon data from pokemon.h // mode=1 will copy pokemon party data being received LinkGPIO *linkGPIO = new LinkGPIO(); @@ -73,7 +74,7 @@ void print(std::string str) void updateFrames() { - if (((connection_state > 1) && (frame - last_bit >= ((trade_centre_state_gen_II >= WAITING_TO_SEND_DATA) ? 10 : 1000))) /*|| connection_state == PRE_CONNECTED*/) + if (((connection_state > 1) && (frame - last_bit >= ((trade_centre_state_gen_II >= WAITING_TO_SEND_DATA) ? FAST_SPEED : SLOW_SPEED))) /*|| connection_state == PRE_CONNECTED*/) { SC_state = !SC_state; linkGPIO->writePin(LinkGPIO::Pin::SC, SC_state); @@ -270,8 +271,8 @@ byte handleIncomingByte(byte in) switch (MODE) { case 0: - send = DATA_BLOCK_GEN_II[counter]; - INPUT_BLOCK_GEN_II[counter] = in; + send = gen1_party_bootstrap[counter]; + //INPUT_BLOCK_GEN_II[counter] = in; break; case 1: send = in; @@ -288,8 +289,8 @@ byte handleIncomingByte(byte in) switch (MODE) { case 0: - send = DATA_BLOCK_GEN_II[counter]; - INPUT_BLOCK_GEN_II[counter] = in; + send = gen1_party_bootstrap[counter]; + //INPUT_BLOCK_GEN_II[counter] = in; break; case 1: send = in; @@ -299,7 +300,7 @@ byte handleIncomingByte(byte in) break; } counter++; - if (counter == PLAYER_LENGTH_GEN_II) + if (counter == PLAYER_LENGTH_GEN_I) { trade_centre_state_gen_II = SENDING_PATCH_DATA; } @@ -311,8 +312,24 @@ byte handleIncomingByte(byte in) } else if (trade_centre_state_gen_II == SENDING_PATCH_DATA && in != 0xFD) { - send = in; - trade_centre_state_gen_II = MIMIC; + switch (MODE) + { + case 0: + send = gen1_omnipayload[counter]; + //INPUT_BLOCK_GEN_II[counter] = in; + break; + case 1: + send = in; + break; + default: + send = in; + break; + } + counter++; + if (counter == PATCH_LIST_LEN_GEN_I) + { + trade_centre_state_gen_II = MIMIC; + } } else if (trade_centre_state_gen_II == MIMIC) { @@ -383,7 +400,8 @@ int transferBit(byte *party_data) std::to_string(trade_centre_state_gen_II) + " " + std::to_string(connection_state) + " " + std::to_string(in_data) + " " + - std::to_string(out_data) + "\n"); + std::to_string(out_data) + " " + + std::to_string(counter) + "\n"); } if (trade_centre_state_gen_II == SENDING_DATA) { @@ -459,7 +477,7 @@ int loop(byte *party_data) return COND_ERROR_COLOSSEUM; } - if (trade_centre_state_gen_II == SENDING_PATCH_DATA) + if (trade_centre_state_gen_II == MIMIC) { return 0; } diff --git a/source/main.cpp b/source/main.cpp index 3cf18ea..7056857 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -31,6 +31,12 @@ #include "save.h" /* + +TODO: +- Implement patch list (as described here: https://web.archive.org/web/20180508011842/https://vaguilar.js.org/posts/1/) + But this isn't going to be relevant after the ACE is implemented, since we will be pulling directly from the box... right? + is 0xFE being a terminator part of the SPI function or is it implemented specifically in the trade/battle code? + Post Beta TODO: - Better custom sprites (Progress, Fennel, Title) - Add a % or x/250 for the Dream Dex @@ -44,6 +50,8 @@ Post Beta TODO: - MissingNo/Enigma Berry - Text translations - Add support for other languages +- Champion ribbons (u/NinjaKnight92) +- Doxygen generation -------- */ diff --git a/source/payload.cpp b/source/payload.cpp new file mode 100644 index 0000000..e776d28 --- /dev/null +++ b/source/payload.cpp @@ -0,0 +1,36 @@ +#include + +#include "payload.h" + +byte gen1_party_bootstrap[PLAYER_LENGTH_GEN_I] = { + 248, 0, 54, 253, 1, 62, 88, 197, 195, 0xd6, 0xc5, + 6, 21, 22, 22, 21, 21, 21, 22, 22, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 206, 227, 227, 255, 33, 160, 195, 1, 136, 1, 62, 0, 205, 224, 54, 17, 24, 218, 33, 89, 196, 205, 85, 25, 195, 21, 218, 139, 142, 128, 131, 136, 141, 134, 232, 232, 232, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 64, 0, 0}; + +byte gen1_omnipayload[PATCH_LIST_LEN_GEN_I] = { + 0x3E, 0x63, 0xF5, 0x21, 0xA0, 0xC3, 0x01, 0x88, + 0x01, 0xCD, 0xE0, 0x36, 0x11, 0xFF, 0xC5, 0x21, + 0x57, 0xC4, 0xCD, 0x55, 0x19, 0x76, 0x76, 0x76, + 0x76, 0x76, 0x76, 0x76, 0xF1, 0x3C, 0x0E, 0x6C, + 0xB9, 0xC2, 0xD8, 0xC5, 0x3E, 0x63, 0xC3, 0xD8, + 0xC5, 0x7F, 0x87, 0x84, 0x8B, 0x8B, 0x8E, 0x7F, + 0x96, 0x8E, 0x91, 0x8B, 0x83, 0xE7, 0x7F, 0x50, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; \ No newline at end of file diff --git a/source/script_obj.cpp b/source/script_obj.cpp index e4ab128..e97bcab 100644 --- a/source/script_obj.cpp +++ b/source/script_obj.cpp @@ -1,7 +1,6 @@ #include #include #include "script_obj.h" -#include "gba_flash.h" #include "pokemon.h" #include "pokemon_party.h" #include "script_array.h"