From df1df7ea7f65832e82bbc1f42dcd1aaef7dffd6f Mon Sep 17 00:00:00 2001 From: Remnants of Forgotten Disney Date: Sun, 4 Feb 2024 12:35:54 -0600 Subject: [PATCH] Pre-link rewrite --- Pokemon_Mirror_mb-0.png | Bin 1590 -> 0 bytes include/debug_mode.h | 8 ++++---- include/gameboy_colour.h | 4 ++++ include/output.h | 12 +++++++++--- include/payload.h | 10 ++++++++++ source/gameboy_colour.cpp | 40 +++++++++++++++++++++++++++----------- source/main.cpp | 8 ++++++++ source/payload.cpp | 36 ++++++++++++++++++++++++++++++++++ source/script_obj.cpp | 1 - 9 files changed, 100 insertions(+), 19 deletions(-) delete mode 100644 Pokemon_Mirror_mb-0.png create mode 100644 include/payload.h create mode 100644 source/payload.cpp diff --git a/Pokemon_Mirror_mb-0.png b/Pokemon_Mirror_mb-0.png deleted file mode 100644 index 8cf3d414096ac6bc348e2e5def1473335ddfa64c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1590 zcmbW1dpOez9L7~{EtiyQ)1){RjhGUrQ6~4KBrLX5A}2O6Hk-MmM!L+kmPq|fDcV%X zoyUYCY-cWy+dR^2rE!|A#f;;eKl}51pXdF)&-*;@`|l^q&(~cOv;(B1q@?NT;d*A> z|6bP<^^NPlr2%iNq@<$obUl7Hu~;TK;HSL1=J%cxdd|B0pexliB;7+M}WF!;% zv(4+#Lr(jyUd$cvyJ+zG`j_+L)?uM=C&=Vj`k}T|#XQ%qJdHP7mFh^{o(j=H43Ger%qTMz*mPxyx5?0ti z=ro!7INN?aJTlg*dCgjeY3M&VoQQMaCYUT4!^Y=d2BT(e7cJJnNix% zlhEPJGTeciJDM>MfBi|ivgBj(nE^8{2x!y7-RbRCldS4|NjWgqj1s;4K?d8{Wmqji z@|_|QG9U03g0O{>?b|`UOJBsE#sNG>Iz;ZKD&bQmSX^Ze$rd7n&Ym=g@UeL|h+9EM zvC#Ee6?V`4vK866xf>?q`EH%0E8$R8FO7+BV!YvwxB|9np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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"