From 88564c21da9da2c91252be350db5c08775cea17c Mon Sep 17 00:00:00 2001 From: Roger Braunstein Date: Fri, 28 Jun 2024 18:09:51 -0700 Subject: [PATCH 1/8] Initial work on PCE flash repro, erase working --- Cart_Reader/PCE.ino | 85 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 11 deletions(-) diff --git a/Cart_Reader/PCE.ino b/Cart_Reader/PCE.ino index 7e9aaff..503ba63 100644 --- a/Cart_Reader/PCE.ino +++ b/Cart_Reader/PCE.ino @@ -18,6 +18,7 @@ #define HUCARD 0 #define TURBOCHIP 1 #define HUCARD_NOSWAP 2 +#define PCE_FLASH 3 #define DETECTION_SIZE 64 #define FORCED_SIZE 1024 #define CHKSUM_SKIP 0 @@ -53,7 +54,8 @@ uint8_t tennokoe_bank_index = 0; static const char pceMenuItem1[] PROGMEM = "HuCARD (swapped)"; static const char pceMenuItem2[] PROGMEM = "HuCARD(not swapped)"; static const char pceMenuItem3[] PROGMEM = "Turbochip"; -static const char *const menuOptionspce[] PROGMEM = { pceMenuItem1, pceMenuItem2, pceMenuItem3, FSTRING_RESET }; +static const char pceMenuItem4[] PROGMEM = "Flash Repro (SST)"; +static const char *const menuOptionspce[] PROGMEM = { pceMenuItem1, pceMenuItem2, pceMenuItem3, pceMenuItem4, FSTRING_RESET }; // PCE card menu items static const char menuOptionspceCart_1[] PROGMEM = "Read RAM Bank %d"; @@ -66,15 +68,18 @@ static const char menuOptionspceCart_5_fmt[] PROGMEM = "ROM size now %dK"; // Turbochip menu items static const char *const menuOptionspceTC[] PROGMEM = { FSTRING_READ_ROM, FSTRING_RESET }; -// PCE start menu -void pcsMenu(void) { - // create menu with title and 3 options to choose from - unsigned char pceDev; - // Copy menuOptions out of progmem - convertPgm(menuOptionspce, 3); - pceDev = question_box(F("Select device"), menuOptions, 3, 0); +#ifdef ENABLE_FLASH +// Flash repro menu items +static const char menuOptionspceFlash1[] PROGMEM = "Erase"; +static const char *const menuOptionspceFlash[] PROGMEM = { menuOptionspceFlash1, FSTRING_RESET }; +#endif + +// PCE start menu, first a device type is selected and set in pce_internal_mode +void pcsMenu(void) { + unsigned char pceDev; + convertPgm(menuOptionspce, 4); + pceDev = question_box(F("Select device"), menuOptions, 4, 0); - // wait for user choice to come back from the question box menu switch (pceDev) { case 0: //Hucard @@ -103,9 +108,23 @@ void pcsMenu(void) { mode = CORE_PCE; break; +#ifdef ENABLE_FLASH case 3: + //Flash Repro + display_Clear(); + display_Update(); + pce_internal_mode = PCE_FLASH; + setup_cart_PCE(); + mode = CORE_PCE; + break; +#endif + + case 4: resetArduino(); break; + + default: + print_MissingModule(); // does not return } } @@ -273,7 +292,7 @@ void write_byte_PCE(uint32_t address, uint8_t data) { "nop\n\t"); //Swap bit order for PC Engine HuCARD - if (pce_internal_mode == HUCARD) { + if (pce_internal_mode == HUCARD || pce_internal_mode == PCE_FLASH) { data = ((data & 0x01) << 7) | ((data & 0x02) << 5) | ((data & 0x04) << 3) | ((data & 0x08) << 1) | ((data & 0x10) >> 1) | ((data & 0x20) >> 3) | ((data & 0x40) >> 5) | ((data & 0x80) >> 7); } @@ -808,6 +827,28 @@ void read_rom_PCE(void) { wait(); } +void flash_erase_PCE() { + display_Clear(); + pin_read_write_PCE(); + data_output_PCE(); + PORTH |= (1 << 3); // RD HIGH + write_byte_PCE(0x5555, 0xAA); + write_byte_PCE(0x2AAA, 0x55); + write_byte_PCE(0x5555, 0x80); + write_byte_PCE(0x5555, 0xAA); + write_byte_PCE(0x2AAA, 0x55); + write_byte_PCE(0x5555, 0x10); + // TSCE = 100ms + delay(100); + + pin_init_PCE(); + + println_Msg(FS(FSTRING_OK)); + print_STR(press_button_STR, 1); + display_Update(); + wait(); +} + // PC Engine Menu void pceMenu() { // create menu with title and 7 options to choose from @@ -861,7 +902,8 @@ void pceMenu() { resetArduino(); break; } - } else { + } + else if (pce_internal_mode == TURBOCHIP) { // Copy menuOptions out of progmem convertPgm(menuOptionspceTC, 2); mainMenu = question_box(F("TG TurboChip menu"), menuOptions, 2, 0); @@ -877,6 +919,27 @@ void pceMenu() { break; } } +#ifdef ENABLE_FLASH + else if (pce_internal_mode == PCE_FLASH) { + const int max = 2; + convertPgm(menuOptionspceFlash, max); + mainMenu = question_box(F("Flash Repro menu"), menuOptions, max, 0); + + switch (mainMenu) { + case 0: + // Format/erase + flash_erase_PCE(); + break; + + case 1: + resetArduino(); + break; + } + } +#endif + else { + print_MissingModule(); // does not return + } } #endif From 6fc56b5ed65b443c00731adfc11e92befcda12c5 Mon Sep 17 00:00:00 2001 From: Roger Braunstein Date: Fri, 28 Jun 2024 19:31:14 -0700 Subject: [PATCH 2/8] Working with 4mbit hardcoded --- Cart_Reader/PCE.ino | 82 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 65 insertions(+), 17 deletions(-) diff --git a/Cart_Reader/PCE.ino b/Cart_Reader/PCE.ino index 503ba63..909294c 100644 --- a/Cart_Reader/PCE.ino +++ b/Cart_Reader/PCE.ino @@ -70,7 +70,7 @@ static const char *const menuOptionspceTC[] PROGMEM = { FSTRING_READ_ROM, FSTRIN #ifdef ENABLE_FLASH // Flash repro menu items -static const char menuOptionspceFlash1[] PROGMEM = "Erase"; +static const char menuOptionspceFlash1[] PROGMEM = "Flash (PCE)"; static const char *const menuOptionspceFlash[] PROGMEM = { menuOptionspceFlash1, FSTRING_RESET }; #endif @@ -827,27 +827,75 @@ void read_rom_PCE(void) { wait(); } -void flash_erase_PCE() { +#ifdef ENABLE_FLASH +// Write flashrom +void flash_PCE() { + // TODO identify size by ID? + flashSize = 524288; //4Mbit SST39SF040 + filePath[0] = '\0'; + sd.chdir("/"); + fileBrowser(FS(FSTRING_SELECT_FILE)); display_Clear(); - pin_read_write_PCE(); - data_output_PCE(); - PORTH |= (1 << 3); // RD HIGH - write_byte_PCE(0x5555, 0xAA); - write_byte_PCE(0x2AAA, 0x55); - write_byte_PCE(0x5555, 0x80); - write_byte_PCE(0x5555, 0xAA); - write_byte_PCE(0x2AAA, 0x55); - write_byte_PCE(0x5555, 0x10); - // TSCE = 100ms - delay(100); - pin_init_PCE(); + if (openFlashFile()) { - println_Msg(FS(FSTRING_OK)); - print_STR(press_button_STR, 1); + println_Msg(F("Erasing...")); + display_Update(); + + pin_read_write_PCE(); + data_output_PCE(); + PORTH |= (1 << 3); // RD HIGH + write_byte_PCE(0x5555, 0xAA); + write_byte_PCE(0x2AAA, 0x55); + write_byte_PCE(0x5555, 0x80); + write_byte_PCE(0x5555, 0xAA); + write_byte_PCE(0x2AAA, 0x55); + write_byte_PCE(0x5555, 0x10); + // TSCE = 100ms + delay(100); + pin_init_PCE(); + + println_Msg(F("Writing flash")); + display_Update(); + + pin_read_write_PCE(); + data_output_PCE(); + PORTH |= (1 << 3); // RD HIGH + + uint32_t processedProgressBar = 0; + uint32_t totalProgressBar = (uint32_t)fileSize; + draw_progressbar(0, totalProgressBar); + + for (unsigned long currAddr = 0; currAddr < fileSize; currAddr += 512) { + myFile.read(sdBuffer, 512); + + if (currAddr % 4096 == 0) { + blinkLED(); + } + + for (int currByte = 0; currByte < 512; currByte++) { + write_byte_PCE(0x5555, 0xAA); + write_byte_PCE(0x2AAA, 0x55); + write_byte_PCE(0x5555, 0xA0); + write_byte_PCE(currAddr + currByte, sdBuffer[currByte]); + + // TODO could use toggle bit or data complement + // TBP = 20us + delayMicroseconds(20); + } + + // update progress bar + processedProgressBar += 512; + draw_progressbar(processedProgressBar, totalProgressBar); + } + myFile.close(); + pin_init_PCE(); + println_Msg(FS(FSTRING_OK)); + } display_Update(); wait(); } +#endif // PC Engine Menu void pceMenu() { @@ -928,7 +976,7 @@ void pceMenu() { switch (mainMenu) { case 0: // Format/erase - flash_erase_PCE(); + flash_PCE(); break; case 1: From 2abde7f2fc3d5301f4e26176e4b503287d3f523a Mon Sep 17 00:00:00 2001 From: Roger Braunstein Date: Sat, 29 Jun 2024 17:05:05 -0700 Subject: [PATCH 3/8] Detect flash chip --- Cart_Reader/PCE.ino | 120 ++++++++++++++++++++++++++++++-------------- 1 file changed, 83 insertions(+), 37 deletions(-) diff --git a/Cart_Reader/PCE.ino b/Cart_Reader/PCE.ino index 909294c..e3e5f66 100644 --- a/Cart_Reader/PCE.ino +++ b/Cart_Reader/PCE.ino @@ -2,12 +2,14 @@ // PC Engine & TurboGrafx dump code by tamanegi_taro // April 18th 2018 Revision 1.0.1 Initial version // August 12th 2019 Revision 1.0.2 Added Tennokoe Bank support +// June 29th 2024 Revision 1.0.3 Added ichigobankai repro HuCard writing // // Special thanks // sanni - Arduino cart reader // skaman - ROM size detection // NO-INTRO - CRC list for game name detection // Chris Covell - Tennokoe bank support +// partlyhuman - repro HuCard support // //****************************************** #ifdef ENABLE_PCE @@ -15,15 +17,15 @@ /****************************************** Defines *****************************************/ -#define HUCARD 0 -#define TURBOCHIP 1 -#define HUCARD_NOSWAP 2 -#define PCE_FLASH 3 #define DETECTION_SIZE 64 #define FORCED_SIZE 1024 #define CHKSUM_SKIP 0 #define CHKSUM_OK 1 #define CHKSUM_ERROR 2 +enum PCE_MODE_T : uint8_t { HUCARD, + TURBOCHIP, + HUCARD_NOSWAP, + PCE_FLASH }; /****************************************** Prototype Declarations @@ -54,7 +56,7 @@ uint8_t tennokoe_bank_index = 0; static const char pceMenuItem1[] PROGMEM = "HuCARD (swapped)"; static const char pceMenuItem2[] PROGMEM = "HuCARD(not swapped)"; static const char pceMenuItem3[] PROGMEM = "Turbochip"; -static const char pceMenuItem4[] PROGMEM = "Flash Repro (SST)"; +static const char pceMenuItem4[] PROGMEM = "HuCARD Flash Repro"; static const char *const menuOptionspce[] PROGMEM = { pceMenuItem1, pceMenuItem2, pceMenuItem3, pceMenuItem4, FSTRING_RESET }; // PCE card menu items @@ -70,8 +72,8 @@ static const char *const menuOptionspceTC[] PROGMEM = { FSTRING_READ_ROM, FSTRIN #ifdef ENABLE_FLASH // Flash repro menu items -static const char menuOptionspceFlash1[] PROGMEM = "Flash (PCE)"; -static const char *const menuOptionspceFlash[] PROGMEM = { menuOptionspceFlash1, FSTRING_RESET }; +// static const char menuOptionspceFlash1[] PROGMEM = "Program"; +static const char *const menuOptionspceFlash[] PROGMEM = { flashMenuItemWrite, FSTRING_RESET }; #endif // PCE start menu, first a device type is selected and set in pce_internal_mode @@ -247,7 +249,7 @@ uint8_t read_byte_PCE(uint32_t address) { ret = PINC; //Swap bit order for PC Engine HuCARD - if (pce_internal_mode == HUCARD) { + if (pce_internal_mode == HUCARD || pce_internal_mode == PCE_FLASH) { ret = ((ret & 0x01) << 7) | ((ret & 0x02) << 5) | ((ret & 0x04) << 3) | ((ret & 0x08) << 1) | ((ret & 0x10) >> 1) | ((ret & 0x20) >> 3) | ((ret & 0x40) >> 5) | ((ret & 0x80) >> 7); } @@ -822,16 +824,67 @@ void read_rom_PCE(void) { crc_search(fileName, folder, rom_size, crc); println_Msg(FS(FSTRING_EMPTY)); - print_STR(press_button_STR, 1); + print_STR(press_button_STR, true); display_Update(); wait(); } -#ifdef ENABLE_FLASH -// Write flashrom +#ifdef ENABLE_FLASH +void flash_mode_PCE() { + pin_read_write_PCE(); + data_output_PCE(); + PORTH |= (1 << 3); // RD HIGH + // write_byte_PCE sets WR +} + void flash_PCE() { - // TODO identify size by ID? - flashSize = 524288; //4Mbit SST39SF040 + // SOFTWARE ID PROGRAM + flash_mode_PCE(); + write_byte_PCE(0x5555, 0xAA); + write_byte_PCE(0x2AAA, 0x55); + write_byte_PCE(0x5555, 0x90); + data_input_PCE(); + // tIDA = 150ns + delayMicroseconds(1); + // MFG,DEVICE + uint16_t deviceId = (read_byte_PCE(0x0) << 8) | read_byte_PCE(0x1); + + // EXIT SOFTWARE ID PROGRAM + flash_mode_PCE(); + write_byte_PCE(0x5555, 0xAA); + write_byte_PCE(0x2AAA, 0x55); + write_byte_PCE(0x5555, 0xF0); + + flashSize = 0; + switch (deviceId) { + case 0xBFB5: + // SST39SF010A = 1Mbit + flashSize = 131072UL; + break; + case 0xBFB6: + // SST39SF020A = 2Mbit + flashSize = 262144UL; + break; + case 0xBFB7: + // SST39SF040 = 4Mbit + flashSize = 524288UL; + break; + } + + if (flashSize <= 0) { + println_Msg(F("FLASH NOT DETECTED")); + display_Update(); + wait(); + resetArduino(); + return; + } else { + print_Msg(FS(FSTRING_SIZE)); + print_Msg(flashSize / 131072UL); + println_Msg(F("Mbit")); + display_Update(); + wait(); + } + filePath[0] = '\0'; sd.chdir("/"); fileBrowser(FS(FSTRING_SELECT_FILE)); @@ -839,58 +892,53 @@ void flash_PCE() { if (openFlashFile()) { - println_Msg(F("Erasing...")); + print_STR(flashing_file_STR, true); display_Update(); - pin_read_write_PCE(); - data_output_PCE(); - PORTH |= (1 << 3); // RD HIGH + // CHIP ERASE PROGRAM + flash_mode_PCE(); write_byte_PCE(0x5555, 0xAA); write_byte_PCE(0x2AAA, 0x55); write_byte_PCE(0x5555, 0x80); write_byte_PCE(0x5555, 0xAA); write_byte_PCE(0x2AAA, 0x55); write_byte_PCE(0x5555, 0x10); - // TSCE = 100ms + // tSCE = 100ms delay(100); pin_init_PCE(); - println_Msg(F("Writing flash")); - display_Update(); - - pin_read_write_PCE(); - data_output_PCE(); - PORTH |= (1 << 3); // RD HIGH - uint32_t processedProgressBar = 0; uint32_t totalProgressBar = (uint32_t)fileSize; draw_progressbar(0, totalProgressBar); - for (unsigned long currAddr = 0; currAddr < fileSize; currAddr += 512) { - myFile.read(sdBuffer, 512); + flash_mode_PCE(); + const size_t BUFSIZE = 512; + for (unsigned long currAddr = 0; currAddr < fileSize; currAddr += BUFSIZE) { + myFile.read(sdBuffer, BUFSIZE); if (currAddr % 4096 == 0) { blinkLED(); } - for (int currByte = 0; currByte < 512; currByte++) { + for (int currByte = 0; currByte < BUFSIZE; currByte++) { + // BYTE PROGRAM write_byte_PCE(0x5555, 0xAA); write_byte_PCE(0x2AAA, 0x55); write_byte_PCE(0x5555, 0xA0); write_byte_PCE(currAddr + currByte, sdBuffer[currByte]); - // TODO could use toggle bit or data complement - // TBP = 20us + // Could detect status with toggle bit or data complement, but already quite fast + // tBP = 20us delayMicroseconds(20); } // update progress bar - processedProgressBar += 512; + processedProgressBar += BUFSIZE; draw_progressbar(processedProgressBar, totalProgressBar); } myFile.close(); pin_init_PCE(); - println_Msg(FS(FSTRING_OK)); + print_STR(done_STR, true); } display_Update(); wait(); @@ -950,8 +998,7 @@ void pceMenu() { resetArduino(); break; } - } - else if (pce_internal_mode == TURBOCHIP) { + } else if (pce_internal_mode == TURBOCHIP) { // Copy menuOptions out of progmem convertPgm(menuOptionspceTC, 2); mainMenu = question_box(F("TG TurboChip menu"), menuOptions, 2, 0); @@ -967,7 +1014,7 @@ void pceMenu() { break; } } -#ifdef ENABLE_FLASH +#ifdef ENABLE_FLASH else if (pce_internal_mode == PCE_FLASH) { const int max = 2; convertPgm(menuOptionspceFlash, max); @@ -975,10 +1022,9 @@ void pceMenu() { switch (mainMenu) { case 0: - // Format/erase flash_PCE(); break; - + case 1: resetArduino(); break; From efe0dcf47d3a230eda2120066c98b1d53d303f4c Mon Sep 17 00:00:00 2001 From: Roger Braunstein Date: Sat, 29 Jun 2024 18:17:26 -0700 Subject: [PATCH 4/8] Implements data complement status checking and MX29F0x0 flash --- Cart_Reader/PCE.ino | 60 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/Cart_Reader/PCE.ino b/Cart_Reader/PCE.ino index e3e5f66..e514f18 100644 --- a/Cart_Reader/PCE.ino +++ b/Cart_Reader/PCE.ino @@ -837,7 +837,32 @@ void flash_mode_PCE() { // write_byte_PCE sets WR } +// Implements data complement status checking +void flash_wait_status_PCE(uint8_t expected) { + set_cs_rd_low_PCE(); + data_input_PCE(); + + // We only look at D7, or the highest bit of expected + expected >>= 7; + uint8_t status; + do { + PORTH &= ~(1 << 3); // RD low + // one nop = 62.5ns + // tOE = 30-50ns depending on flash + NOP; + status = PINC; + PORTH |= (1 << 3); // RD high + // reversed, bit 0 is the MSB + } while ((status & 0x1) != expected); + + data_output_PCE(); + // leave RD high on exit +} + void flash_PCE() { + println_Msg(F("Detecting...")); + display_Update(); + // SOFTWARE ID PROGRAM flash_mode_PCE(); write_byte_PCE(0x5555, 0xAA); @@ -845,7 +870,7 @@ void flash_PCE() { write_byte_PCE(0x5555, 0x90); data_input_PCE(); // tIDA = 150ns - delayMicroseconds(1); + NOP;NOP;NOP; // MFG,DEVICE uint16_t deviceId = (read_byte_PCE(0x0) << 8) | read_byte_PCE(0x1); @@ -869,10 +894,19 @@ void flash_PCE() { // SST39SF040 = 4Mbit flashSize = 524288UL; break; + case 0xC2A4: + // MX29F040 = 4Mbit + flashSize = 524288UL; + break; + case 0xC2D5: + // MX29F080 = 8Mbit + flashSize = 1048576UL; + break; } if (flashSize <= 0) { - println_Msg(F("FLASH NOT DETECTED")); + print_Msg(F("UNKNOWN ")); + println_Msg(deviceId); display_Update(); wait(); resetArduino(); @@ -892,7 +926,7 @@ void flash_PCE() { if (openFlashFile()) { - print_STR(flashing_file_STR, true); + println_Msg(F("Erasing...")); display_Update(); // CHIP ERASE PROGRAM @@ -903,14 +937,16 @@ void flash_PCE() { write_byte_PCE(0x5555, 0xAA); write_byte_PCE(0x2AAA, 0x55); write_byte_PCE(0x5555, 0x10); - // tSCE = 100ms - delay(100); - pin_init_PCE(); + // Data complement polling, wait until highest bit is 1 + flash_wait_status_PCE(0xFF); + print_STR(flashing_file_STR, true); + display_Update(); uint32_t processedProgressBar = 0; uint32_t totalProgressBar = (uint32_t)fileSize; draw_progressbar(0, totalProgressBar); + unsigned long startMs = millis(); flash_mode_PCE(); const size_t BUFSIZE = 512; for (unsigned long currAddr = 0; currAddr < fileSize; currAddr += BUFSIZE) { @@ -922,14 +958,17 @@ void flash_PCE() { for (int currByte = 0; currByte < BUFSIZE; currByte++) { // BYTE PROGRAM + byte b = sdBuffer[currByte]; write_byte_PCE(0x5555, 0xAA); write_byte_PCE(0x2AAA, 0x55); write_byte_PCE(0x5555, 0xA0); - write_byte_PCE(currAddr + currByte, sdBuffer[currByte]); - - // Could detect status with toggle bit or data complement, but already quite fast + write_byte_PCE(currAddr + currByte, b); + flash_wait_status_PCE(b); + // tBP = 20us - delayMicroseconds(20); + // delayMicroseconds(20); + + // status polling = 38s } // update progress bar @@ -938,6 +977,7 @@ void flash_PCE() { } myFile.close(); pin_init_PCE(); + println_Msg((millis() - startMs) / 1000); print_STR(done_STR, true); } display_Update(); From 3ebfc53a18b9ee937fd5a5063ff380b3a7aa20e0 Mon Sep 17 00:00:00 2001 From: Roger Braunstein Date: Sat, 29 Jun 2024 18:20:04 -0700 Subject: [PATCH 5/8] Cleaning up debug stuff --- Cart_Reader/PCE.ino | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Cart_Reader/PCE.ino b/Cart_Reader/PCE.ino index e514f18..e16a6e0 100644 --- a/Cart_Reader/PCE.ino +++ b/Cart_Reader/PCE.ino @@ -838,12 +838,11 @@ void flash_mode_PCE() { } // Implements data complement status checking +// We only look at D7, or the highest bit of expected void flash_wait_status_PCE(uint8_t expected) { set_cs_rd_low_PCE(); data_input_PCE(); - // We only look at D7, or the highest bit of expected - expected >>= 7; uint8_t status; do { PORTH &= ~(1 << 3); // RD low @@ -853,7 +852,7 @@ void flash_wait_status_PCE(uint8_t expected) { status = PINC; PORTH |= (1 << 3); // RD high // reversed, bit 0 is the MSB - } while ((status & 0x1) != expected); + } while ((status & 0x1) != (expected >> 7)); data_output_PCE(); // leave RD high on exit @@ -946,7 +945,6 @@ void flash_PCE() { uint32_t totalProgressBar = (uint32_t)fileSize; draw_progressbar(0, totalProgressBar); - unsigned long startMs = millis(); flash_mode_PCE(); const size_t BUFSIZE = 512; for (unsigned long currAddr = 0; currAddr < fileSize; currAddr += BUFSIZE) { @@ -964,11 +962,6 @@ void flash_PCE() { write_byte_PCE(0x5555, 0xA0); write_byte_PCE(currAddr + currByte, b); flash_wait_status_PCE(b); - - // tBP = 20us - // delayMicroseconds(20); - - // status polling = 38s } // update progress bar @@ -977,7 +970,6 @@ void flash_PCE() { } myFile.close(); pin_init_PCE(); - println_Msg((millis() - startMs) / 1000); print_STR(done_STR, true); } display_Update(); From 99433cc769f65f0424016bf9195c140517b970e6 Mon Sep 17 00:00:00 2001 From: Roger Braunstein Date: Sat, 29 Jun 2024 18:25:34 -0700 Subject: [PATCH 6/8] Update comments --- Cart_Reader/PCE.ino | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Cart_Reader/PCE.ino b/Cart_Reader/PCE.ino index e16a6e0..a14f3dc 100644 --- a/Cart_Reader/PCE.ino +++ b/Cart_Reader/PCE.ino @@ -2,7 +2,7 @@ // PC Engine & TurboGrafx dump code by tamanegi_taro // April 18th 2018 Revision 1.0.1 Initial version // August 12th 2019 Revision 1.0.2 Added Tennokoe Bank support -// June 29th 2024 Revision 1.0.3 Added ichigobankai repro HuCard writing +// June 29th 2024 Revision 1.0.3 Added repro HuCard flashing // // Special thanks // sanni - Arduino cart reader @@ -858,6 +858,9 @@ void flash_wait_status_PCE(uint8_t expected) { // leave RD high on exit } +// Flashes a reproduction HuCard that's directly wired to a flash chip +// Supported flash: SST39SF0x0, MX29F0x0 1Mbit-8Mbit +// Developed against Ichigobankai's design https://github.com/partlyhuman/HuCARD-repro void flash_PCE() { println_Msg(F("Detecting...")); display_Update(); @@ -882,11 +885,11 @@ void flash_PCE() { flashSize = 0; switch (deviceId) { case 0xBFB5: - // SST39SF010A = 1Mbit + // SST39SF010 = 1Mbit flashSize = 131072UL; break; case 0xBFB6: - // SST39SF020A = 2Mbit + // SST39SF020 = 2Mbit flashSize = 262144UL; break; case 0xBFB7: From 75d547db22248cd677a07ac8355b96ac4e72e8ce Mon Sep 17 00:00:00 2001 From: Roger Braunstein Date: Sun, 30 Jun 2024 12:29:11 -0700 Subject: [PATCH 7/8] Fixes compilation of SNES w/o FLASH option, update comment --- Cart_Reader/Config.h | 2 +- Cart_Reader/OSCR.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Cart_Reader/Config.h b/Cart_Reader/Config.h index 474c10b..c18d960 100644 --- a/Cart_Reader/Config.h +++ b/Cart_Reader/Config.h @@ -124,7 +124,7 @@ /****/ -/* [ Flashrom Programmer for SNES repros -------------------------- ] +/* [ Flashrom Programmer for repro carts -------------------------- ] */ #define ENABLE_FLASH diff --git a/Cart_Reader/OSCR.h b/Cart_Reader/OSCR.h index 6381d86..943a6d8 100644 --- a/Cart_Reader/OSCR.h +++ b/Cart_Reader/OSCR.h @@ -124,9 +124,7 @@ enum CORES: uint8_t { # endif # ifdef ENABLE_SFM CORE_SFM, -# ifdef ENABLE_FLASH CORE_SFM_FLASH, -# endif CORE_SFM_GAME, # endif # ifdef ENABLE_GBX From ae52422502da26e53766d450be3608c4d9bf7ebd Mon Sep 17 00:00:00 2001 From: Roger Braunstein Date: Sun, 30 Jun 2024 12:31:54 -0700 Subject: [PATCH 8/8] Alternate fix --- Cart_Reader/OSCR.h | 2 ++ Cart_Reader/SFM.ino | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/Cart_Reader/OSCR.h b/Cart_Reader/OSCR.h index 943a6d8..6381d86 100644 --- a/Cart_Reader/OSCR.h +++ b/Cart_Reader/OSCR.h @@ -124,7 +124,9 @@ enum CORES: uint8_t { # endif # ifdef ENABLE_SFM CORE_SFM, +# ifdef ENABLE_FLASH CORE_SFM_FLASH, +# endif CORE_SFM_GAME, # endif # ifdef ENABLE_GBX diff --git a/Cart_Reader/SFM.ino b/Cart_Reader/SFM.ino index 276c51a..ab144fd 100644 --- a/Cart_Reader/SFM.ino +++ b/Cart_Reader/SFM.ino @@ -58,14 +58,19 @@ void sfmMenu() { case 0: sfmGameMenu(); break; +#ifdef CORE_SFM_FLASH // Flash menu case 1: mode = CORE_SFM_FLASH; break; +#endif // Reset case 2: resetArduino(); break; + default: + print_MissingModule(); + break; } }