#define ENABLE_FLASH now enables/disables all repro flash code

This cuts down memory usage from 90%/66% to 68%/63%. Useful for people that don't flash repros and would like to enable more systems instead.
This commit is contained in:
sanni 2024-08-16 11:43:08 +02:00
parent 9400330fca
commit 34e2ef2bae
12 changed files with 631 additions and 569 deletions

View File

@ -4,8 +4,8 @@
This project represents a community-driven effort to provide
an easy to build and easy to modify cartridge dumper.
Date: 2024-08-11
Version: 14.2
Date: 2024-08-16
Version: 14.3
SD lib: https://github.com/greiman/SdFat
LCD lib: https://github.com/olikraus/u8g2
@ -2332,6 +2332,21 @@ void setup() {
if (!myLog.open("OSCR_LOG.txt", O_RDWR | O_CREAT | O_APPEND)) {
print_FatalError(sd_error_STR);
}
// Start new log if file is too big
if (myLog.fileSize() > 262144) {
EEPROM_readAnything(0, foldern);
sprintf(folder, "%s%d%s", "OSCR_LOG_", foldern, ".txt");
foldern = foldern + 1;
EEPROM_writeAnything(0, foldern);
myLog.rename(folder);
// Close the file:
myLog.close();
if (!myLog.open("OSCR_LOG.txt", O_RDWR | O_CREAT | O_APPEND)) {
print_FatalError(sd_error_STR);
}
}
println_Msg(FS(FSTRING_EMPTY));
#if defined(HW1)
print_Msg(F("OSCR HW1"));
@ -3686,10 +3701,12 @@ void loop() {
case CORE_GB: return gbMenu();
case CORE_GBA: return gbaMenu();
case CORE_GBM: return gbmMenu();
#if defined(ENABLE_FLASH)
case CORE_GB_GBSMART: return gbSmartMenu();
case CORE_GB_GBSMART_FLASH: return gbSmartFlashMenu();
case CORE_GB_GBSMART_GAME: return gbSmartGameOptions();
#endif
#endif
#ifdef ENABLE_FLASH
case CORE_FLASH8: return flashromMenu8();
#ifdef ENABLE_FLASH16

View File

@ -182,7 +182,7 @@
/* [ Flashrom Programmer for repro carts -------------------------- ]
*/
#define ENABLE_FLASH
//#define ENABLE_FLASH
//#define ENABLE_FLASH16
/****/

View File

@ -27,6 +27,7 @@ static const char* const menuOptionsGBx[] PROGMEM = { gbxMenuItem1, gbxMenuItem2
// GB menu items
static const char* const menuOptionsGB[] PROGMEM = { FSTRING_READ_ROM, FSTRING_READ_SAVE, FSTRING_WRITE_SAVE, FSTRING_RESET };
#if defined(ENABLE_FLASH)
// GB Flash items
static const char GBFlashItem1[] PROGMEM = "GB 29F Repro";
static const char GBFlashItem2[] PROGMEM = "GB CFI Repro";
@ -42,6 +43,7 @@ static const char GBFlash29Item2[] PROGMEM = "DIY MBC5 (WR)";
static const char GBFlash29Item3[] PROGMEM = "HDR MBC30 (Audio)";
static const char GBFlash29Item4[] PROGMEM = "HDR GameBoy Cam";
static const char* const menuOptionsGBFlash29[] PROGMEM = { GBFlash29Item1, GBFlash29Item2, GBFlash29Item3, GBFlash29Item4, FSTRING_RESET };
#endif
// Pelican Codebreaker, Brainboy, and Monster Brain Operation Menu
static const char PelicanRead[] PROGMEM = "Read Device";
@ -55,6 +57,7 @@ static const char GameSharkRead[] PROGMEM = "Read GBC GameShark";
static const char GameSharkWrite[] PROGMEM = "Write GBC GameShark";
static const char* const menuOptionsGBDatel[] PROGMEM = { MegaMemRead, MegaMemWrite, GameSharkRead, GameSharkWrite };
#if defined(ENABLE_FLASH)
bool gbxFlashCFI() {
// Flash CFI
display_Clear();
@ -80,6 +83,7 @@ bool gbxFlashCFI() {
}
return true;
}
#endif
void feedbackPressAndReset() {
// Prints string out of the common strings array either with or without newline
@ -113,6 +117,7 @@ void gbxMenu() {
mode = CORE_GBA;
break;
#if defined(ENABLE_FLASH)
case 2:
// create submenu with title and 7 options to choose from
unsigned char gbFlash;
@ -314,6 +319,7 @@ void gbxMenu() {
break;
}
break;
#endif
case 3:
// Flash GB Memory
@ -430,6 +436,9 @@ void gbxMenu() {
case 6:
resetArduino();
break;
default:
print_MissingModule(); // does not return
}
}
@ -1806,6 +1815,7 @@ void sendMBC7EEPROM_Inst_GB(uint8_t op, uint8_t addr, uint16_t data) {
}
}
#if defined(ENABLE_FLASH)
/******************************************
29F016/29F032/29F033 flashrom functions
*****************************************/
@ -2452,6 +2462,7 @@ bool writeCFI_GB() {
}
return true;
}
#endif
/**************************************************
Pelican Gameboy Device Read Function

View File

@ -10,12 +10,14 @@
static const char GBAMenuItem4[] PROGMEM = "Force Savetype";
static const char* const menuOptionsGBA[] PROGMEM = { FSTRING_READ_ROM, FSTRING_READ_SAVE, FSTRING_WRITE_SAVE, GBAMenuItem4, FSTRING_RESET };
#if defined(ENABLE_FLASH)
// 369-in-1 menu items
static const char Menu369Item1[] PROGMEM = "Read 256MB";
static const char Menu369Item2[] PROGMEM = "Write 256MB";
static const char Menu369Item3[] PROGMEM = "Read Offset";
static const char Menu369Item4[] PROGMEM = "Write Offset";
static const char* const Options369GBA[] PROGMEM = { Menu369Item1, Menu369Item2, Menu369Item3, Menu369Item4, FSTRING_RESET };
#endif
// Rom menu
static const char GBARomItem1[] PROGMEM = "1 MB";
@ -233,6 +235,7 @@ void gbaMenu() {
}
}
#if defined(ENABLE_FLASH)
// Flash GBA Repro
void GBAReproMenu() {
setup_GBA_Repro();
@ -302,6 +305,7 @@ void repro369in1Menu() {
wait();
resetArduino();
}
#endif
/******************************************
Setup
@ -367,12 +371,14 @@ void setup_GBA() {
wait();
}
#if defined(ENABLE_FLASH)
void setup_GBA_Repro() {
// Request 3.3V
setVoltage(VOLTS_SET_3V3);
setROM_GBA();
display_Clear();
}
#endif
/******************************************
Low level functions
@ -2002,6 +2008,7 @@ unsigned long verifyEEP_GBA(word eepSize) {
return wrError;
}
#if defined(ENABLE_FLASH)
/******************************************
GBA REPRO Functions (32MB Intel 4000L0YBQ0 and 16MB MX29GL128E)
*****************************************/
@ -2920,9 +2927,8 @@ void flashRepro_GBA(boolean option) {
print_FatalError(F("Check voltage"));
}
}
#endif
#endif
//******************************************
// End of File
//******************************************

View File

@ -25,12 +25,14 @@ void gbmMenu() {
// wait for user choice to come back from the question box menu
switch (mainMenu) {
#if defined(ENABLE_FLASH)
// Read Flash ID
case 0:
// Clear screen
display_Clear();
readFlashID_GBM();
break;
#endif
// Read Flash
case 1:
@ -62,6 +64,7 @@ void gbmMenu() {
readROM_GBM(64);
break;
#if defined(ENABLE_FLASH)
// Erase Flash
case 2:
// Clear screen
@ -172,6 +175,10 @@ void gbmMenu() {
// Write mapping
writeMapping_GBM();
break;
#endif
default:
print_MissingModule(); // does not return
}
println_Msg(FS(FSTRING_EMPTY));
// Prints string out of the common strings array either with or without newline
@ -447,6 +454,7 @@ void send_GBM(byte myCommand) {
}
}
#if defined(ENABLE_FLASH)
void send_GBM(byte myCommand, word myAddress, byte myData) {
byte myAddrLow = myAddress & 0xFF;
byte myAddrHigh = (myAddress >> 8) & 0xFF;
@ -905,7 +913,7 @@ void writeMapping_GBM() {
print_Error(open_file_STR);
}
}
#endif
#endif
//******************************************

View File

@ -3,6 +3,7 @@
// Supports 32M cart with LH28F016SUT flash
//******************************************
#ifdef ENABLE_GBX
#if defined(ENABLE_FLASH)
#define GB_SMART_GAMES_PER_PAGE 6
/******************************************
@ -728,6 +729,7 @@ uint8_t gbSmartGetResizeParam(uint8_t rom_size, uint8_t sram_size) {
return (sram_size | rom_size);
}
#endif
#endif
//******************************************
// End of File

View File

@ -296,6 +296,9 @@ void mdMenu() {
case 3:
resetArduino();
break;
default:
print_MissingModule(); // does not return
}
}
@ -2120,7 +2123,6 @@ void verifyFlash_MD() {
display_Update();
}
}
#endif
// Delay between write operations based on status register
void busyCheck_MD() {
@ -2137,6 +2139,7 @@ void busyCheck_MD() {
// Set data pins to output
dataOut_MD();
}
#endif
//******************************************
// EEPROM Functions
@ -2899,9 +2902,9 @@ void printRomSize_MD(int index) {
void force_cartSize_MD() {
cartSize = navigateMenu(0, 9, &printRomSize_MD);
cartSize = pgm_read_byte(&(MDSize[cartSize])) * 131072;
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
display.setCursor(0, 56); // Display selection at bottom
#endif
#endif
print_Msg(FS(FSTRING_ROM_SIZE));
print_Msg(cartSize / 131072);
println_Msg(F(" Mbit"));
@ -2913,4 +2916,4 @@ void force_cartSize_MD() {
//******************************************
// End of File
//******************************************
//******************************************

View File

@ -69,12 +69,6 @@ static const char* const menuOptionsN64Controller[] PROGMEM = { N64ContMenuItem1
static const char N64CartMenuItem4[] PROGMEM = "Force Savetype";
static const char* const menuOptionsN64Cart[] PROGMEM = { FSTRING_READ_ROM, FSTRING_READ_SAVE, FSTRING_WRITE_SAVE, N64CartMenuItem4, FSTRING_RESET };
// N64 CRC32 error menu items
static const char N64CRCMenuItem1[] PROGMEM = "No";
static const char N64CRCMenuItem2[] PROGMEM = "Yes and keep old";
static const char N64CRCMenuItem3[] PROGMEM = "Yes and delete old";
static const char* const menuOptionsN64CRC[] PROGMEM = { N64CRCMenuItem1, N64CRCMenuItem2, N64CRCMenuItem3, FSTRING_RESET };
// Rom menu
static const char N64RomItem1[] PROGMEM = "4 MB";
static const char N64RomItem2[] PROGMEM = "8 MB";
@ -93,6 +87,7 @@ static const char N64SaveItem4[] PROGMEM = "SRAM";
static const char N64SaveItem5[] PROGMEM = "FLASH";
static const char* const saveOptionsN64[] PROGMEM = { N64SaveItem1, N64SaveItem2, N64SaveItem3, N64SaveItem4, N64SaveItem5 };
#if defined(ENABLE_FLASH)
// Repro write buffer menu
static const char N64BufferItem1[] PROGMEM = "No buffer";
static const char N64BufferItem2[] PROGMEM = "32 Byte";
@ -106,6 +101,7 @@ static const char N64SectorItem2[] PROGMEM = "32 KB";
static const char N64SectorItem3[] PROGMEM = "64 KB";
static const char N64SectorItem4[] PROGMEM = "128 KB";
static const char* const sectorOptionsN64[] PROGMEM = { N64SectorItem1, N64SectorItem2, N64SectorItem3, N64SectorItem4 };
#endif
// N64 start menu
void n64Menu() {
@ -132,6 +128,7 @@ void n64Menu() {
mode = CORE_N64_CONTROLLER;
break;
#if defined(ENABLE_FLASH)
case 2:
display_Clear();
display_Update();
@ -140,6 +137,7 @@ void n64Menu() {
printCartInfo_N64();
mode = CORE_N64_CART;
break;
#endif
case 3:
display_Clear();
@ -165,6 +163,9 @@ void n64Menu() {
case 5:
resetArduino();
break;
default:
print_MissingModule(); // does not return
}
}
@ -3039,6 +3040,7 @@ void savesummary_N64(boolean checkfound, char crcStr[9], unsigned long timeElaps
}
#endif
#if defined(ENABLE_FLASH)
/******************************************
N64 Repro Flashrom Functions
*****************************************/
@ -3997,6 +3999,7 @@ unsigned long verifyFlashrom_N64() {
return 9999;
}
}
#endif
/******************************************
N64 Gameshark Flash Functions
@ -4687,4 +4690,4 @@ unsigned long verifyXplorer_N64() {
//******************************************
// End of File
//******************************************
//******************************************

File diff suppressed because it is too large Load Diff

View File

@ -49,7 +49,7 @@
* String Constants
**/
// Firmware Version
constexpr char PROGMEM FSTRING_VERSION[] = "V14.2";
constexpr char PROGMEM FSTRING_VERSION[] = "V14.3";
// Universal
constexpr char PROGMEM FSTRING_RESET[] = "Reset";

View File

@ -135,10 +135,12 @@ enum CORES: uint8_t {
CORE_GB,
CORE_GBA,
CORE_GBM,
# ifdef ENABLE_FLASH
CORE_GB_GBSMART,
CORE_GB_GBSMART_FLASH,
CORE_GB_GBSMART_GAME,
# endif
# endif
# ifdef ENABLE_FLASH
CORE_FLASH8,
# ifdef ENABLE_FLASH16

View File

@ -53,6 +53,7 @@ static const char confMenuItem3[] PROGMEM = "4MB HiROM 64K SRAM";
static const char confMenuItem4[] PROGMEM = "6MB ExROM 256K SRAM";
static const char* const menuOptionsConfManual[] PROGMEM = { confMenuItem1, confMenuItem2, confMenuItem3, confMenuItem4, FSTRING_RESET };
#if defined(ENABLE_FLASH)
// Repro menu items
static const char reproMenuItem1[] PROGMEM = "CFI LoROM";
static const char reproMenuItem2[] PROGMEM = "CFI HiROM";
@ -78,7 +79,6 @@ static const char* const menuOptionsReproEX[] PROGMEM = { reproEXItem1, reproEXI
*/
void setupCFI() {
#ifdef ENABLE_FLASH
display_Clear();
display_Update();
filePath[0] = '\0';
@ -89,12 +89,10 @@ void setupCFI() {
identifyCFI_Flash();
sprintf(filePath, "%s/%s", filePath, fileName);
display_Clear();
#endif
}
/*boolean reproEXMenu() {
boolean fileOrder = 0;
#ifdef ENABLE_FLASH
// create menu with title and 3 options to choose from
unsigned char snsReproEX;
// Copy menuOptions out of progmem
@ -113,7 +111,6 @@ void setupCFI() {
resetArduino();
break;
}
#endif
return fileOrder;
}*/
@ -128,7 +125,6 @@ void reproCFIMenu() {
// wait for user choice to come back from the question box menu
switch (snsReproCFI) {
#ifdef ENABLE_FLASH
case 0:
setupCFI();
flashSize = 2097152;
@ -244,20 +240,17 @@ void reproCFIMenu() {
writeCFI_Flash(1, 1, reversed);
verifyFlash(1, 1, reversed);
break;
#endif
case 6:
resetArduino();
break;
}
#ifdef ENABLE_FLASH
// Prints string out of the common strings array either with or without newline
print_STR(press_button_STR, 0);
display_Update();
wait();
resetArduino();
#endif
}
// SNES repro menu
@ -270,7 +263,6 @@ void reproMenu() {
// wait for user choice to come back from the question box menu
switch (snsRepro) {
#ifdef ENABLE_FLASH
case 0:
// CFI LoROM
mapping = 1;
@ -326,13 +318,13 @@ void reproMenu() {
wait();
mode = CORE_FLASH8;
break;
#endif
case 6:
resetArduino();
break;
}
}
#endif
// SNES start menu
void snsMenu() {