Merge pull request #603 from vpelletier/trim

More resource usage reduction efforts: factorise N64 JoyBus code, print_Error split
This commit is contained in:
sanni 2022-10-31 10:08:00 +01:00 committed by GitHub
commit 20c5fdb6bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 827 additions and 1412 deletions

View File

@ -182,7 +182,7 @@ void readROM_COL() {
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
// write new folder number back to EEPROM // write new folder number back to EEPROM
foldern++; foldern++;
@ -515,7 +515,7 @@ void setCart_COL() {
} }
} }
} else { } else {
print_Error(F("Database file not found"), true); print_FatalError(F("Database file not found"));
} }
} }
#endif #endif

View File

@ -298,6 +298,10 @@ bool i2c_found;
#include "FreqCount.h" #include "FreqCount.h"
#endif #endif
void _print_FatalError(void) __attribute__ ((noreturn));
void print_FatalError(const __FlashStringHelper* errorMessage) __attribute__ ((noreturn));
void print_FatalError(byte errorMessage) __attribute__ ((noreturn));
/****************************************** /******************************************
Common Strings Common Strings
*****************************************/ *****************************************/
@ -616,7 +620,7 @@ uint32_t calculateCRC(char* fileName, char* folder, int offset) {
//print_Msg(folder); //print_Msg(folder);
//print_Msg(F("/")); //print_Msg(F("/"));
//print_Msg(fileName); //print_Msg(fileName);
print_Error(F(" not found"), true); print_FatalError(F(" not found"));
return 0; return 0;
} }
} }
@ -748,7 +752,7 @@ boolean compareCRC(const char* database, char* crcString, boolean renamerom, int
// Write iNES header // Write iNES header
sd.chdir(folder); sd.chdir(folder);
if (!myFile.open(fileName, O_RDWR)) { if (!myFile.open(fileName, O_RDWR)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
for (byte z = 0; z < 16; z++) { for (byte z = 0; z < 16; z++) {
myFile.write(iNES_HEADER[z]); myFile.write(iNES_HEADER[z]);
@ -886,6 +890,12 @@ byte starting_letter() {
#endif #endif
} }
void print_MissingModule(void) {
display_Clear();
println_Msg(F("Please enable module"));
print_FatalError(F("in Cart_Reader.ino."));
}
/****************************************** /******************************************
Main menu optimized for rotary encoder Main menu optimized for rotary encoder
*****************************************/ *****************************************/
@ -913,6 +923,8 @@ static const char* const modeOptions[] PROGMEM = { modeItem1, modeItem2, modeIte
void mainMenu() { void mainMenu() {
// create menu with title and 15 options to choose from // create menu with title and 15 options to choose from
unsigned char modeMenu; unsigned char modeMenu;
byte num_answers;
byte option_offset;
// Main menu spans across two pages // Main menu spans across two pages
currPage = 1; currPage = 1;
@ -921,23 +933,23 @@ void mainMenu() {
while (1) { while (1) {
if (currPage == 1) { if (currPage == 1) {
// Copy menuOptions out of progmem option_offset = 0;
convertPgm(modeOptions + 0, 7); num_answers = 7;
modeMenu = question_box(F("OPEN SOURCE CART READER"), menuOptions, 7, 0);
} }
if (currPage == 2) { if (currPage == 2) {
// Copy menuOptions out of progmem option_offset = 7;
convertPgm(modeOptions + 7, 7); num_answers = 7;
modeMenu = question_box(F("OPEN SOURCE CART READER"), menuOptions, 7, 0);
} }
if (currPage == 3) { if (currPage == 3) {
// Copy menuOptions out of progmem option_offset = 14;
convertPgm(modeOptions + 14, 2); num_answers = 2;
modeMenu = question_box(F("OPEN SOURCE CART READER"), menuOptions, 2, 0);
} }
// Copy menuOptions out of progmem
convertPgm(modeOptions + option_offset, num_answers);
modeMenu = question_box(F("OPEN SOURCE CART READER"), menuOptions, num_answers, 0);
if (numPages == 0) { if (numPages == 0) {
// Execute choice // Execute choice
modeMenu = (currPage - 1) * 7 + modeMenu; modeMenu += option_offset;
break; break;
} }
} }
@ -1062,10 +1074,7 @@ void mainMenu() {
break; break;
default: default:
display_Clear(); print_MissingModule(); // does not return
println_Msg(F("Please enable module"));
print_Error(F("in Cart_Reader.ino."), true);
break;
} }
} }
@ -1081,11 +1090,7 @@ static const char modeItem2[] PROGMEM = "SNES/SFC (CLK0+1)";
static const char modeItem2[] PROGMEM = "Super Nintendo/SFC"; static const char modeItem2[] PROGMEM = "Super Nintendo/SFC";
#endif #endif
static const char modeItem3[] PROGMEM = "Mega Drive/Genesis"; static const char modeItem3[] PROGMEM = "Mega Drive/Genesis";
#if defined(clockgen_installed)
static const char modeItem4[] PROGMEM = "N64 (3V EEP CLK1)"; static const char modeItem4[] PROGMEM = "N64 (3V EEP CLK1)";
#else
static const char modeItem4[] PROGMEM = "Nintendo 64(3V EEP)";
#endif
static const char modeItem5[] PROGMEM = "Game Boy"; static const char modeItem5[] PROGMEM = "Game Boy";
static const char modeItem6[] PROGMEM = "About"; static const char modeItem6[] PROGMEM = "About";
// static const char modeItem7[] PROGMEM = "Reset"; (stored in common strings array) // static const char modeItem7[] PROGMEM = "Reset"; (stored in common strings array)
@ -1161,6 +1166,9 @@ void mainMenu() {
case 6: case 6:
resetArduino(); resetArduino();
break; break;
default:
print_MissingModule(); // does not return
} }
} }
@ -1199,10 +1207,7 @@ void addonMenu() {
break; break;
default: default:
display_Clear(); print_MissingModule(); // does not return
println_Msg(F("Please enable module"));
print_Error(F("in Cart_Reader.ino."), true);
break;
} }
} }
@ -1258,10 +1263,7 @@ void consoleMenu() {
break; break;
default: default:
display_Clear(); print_MissingModule(); // does not return
println_Msg(F("Please enable module"));
print_Error(F("in Cart_Reader.ino."), true);
break;
} }
} }
@ -1319,10 +1321,7 @@ void handheldMenu() {
break; break;
default: default:
display_Clear(); print_MissingModule(); // does not return
println_Msg(F("Please enable module"));
print_Error(F("in Cart_Reader.ino."), true);
break;
} }
} }
#endif #endif
@ -1498,7 +1497,7 @@ void clkcal() {
if (!i2c_found) { if (!i2c_found) {
display_Clear(); display_Clear();
print_Error(F("Clock Generator not found"), true); print_FatalError(F("Clock Generator not found"));
} }
//clockgen.set_correction(cal_factor, SI5351_PLL_INPUT_XO); //clockgen.set_correction(cal_factor, SI5351_PLL_INPUT_XO);
@ -1654,7 +1653,7 @@ void savetofile() {
delay(2000); delay(2000);
if (!myFile.open("/snes_clk.txt", O_WRITE | O_CREAT | O_TRUNC)) { if (!myFile.open("/snes_clk.txt", O_WRITE | O_CREAT | O_TRUNC)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
// Write calibration factor to file // Write calibration factor to file
myFile.print(cal_factor); myFile.print(cal_factor);
@ -1841,12 +1840,12 @@ void setup() {
// Init SD card // Init SD card
if (!sd.begin(SS)) { if (!sd.begin(SS)) {
display_Clear(); display_Clear();
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
#ifdef global_log #ifdef global_log
if (!myLog.open("OSCR_LOG.txt", O_RDWR | O_CREAT | O_APPEND)) { if (!myLog.open("OSCR_LOG.txt", O_RDWR | O_CREAT | O_APPEND)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
println_Msg(F("")); println_Msg(F(""));
#if defined(HW1) #if defined(HW1)
@ -1955,71 +1954,38 @@ void convertPgm(const char* const pgmOptions[], byte numArrays) {
} }
} }
void print_Error(const __FlashStringHelper* errorMessage, boolean forceReset) { void _print_Error(void) {
errorLvl = 1; errorLvl = 1;
setColor_RGB(255, 0, 0); setColor_RGB(255, 0, 0);
display_Update();
}
void print_Error(const __FlashStringHelper* errorMessage) {
println_Msg(errorMessage); println_Msg(errorMessage);
display_Update(); _print_Error();
if (forceReset) {
println_Msg(F(""));
print_STR(press_button_STR, 1);
display_Update();
wait();
if (ignoreError == 0) {
resetArduino();
} else {
ignoreError = 0;
display_Clear();
println_Msg(F(""));
println_Msg(F("Error Overwrite"));
println_Msg(F(""));
display_Update();
delay(2000);
}
}
} }
void print_Error(byte errorMessage, boolean forceReset) { void print_Error(byte errorMessage) {
errorLvl = 1;
setColor_RGB(255, 0, 0);
print_STR(errorMessage, 1); print_STR(errorMessage, 1);
_print_Error();
}
void _print_FatalError(void) {
println_Msg(F(""));
print_STR(press_button_STR, 1);
display_Update(); display_Update();
wait();
if (forceReset) { resetArduino();
println_Msg(F(""));
// Prints string out of the common strings array either with or without newline
print_STR(press_button_STR, 1);
display_Update();
wait();
if (ignoreError == 0) {
resetArduino();
} else {
ignoreError = 0;
display_Clear();
println_Msg(F(""));
println_Msg(F("Error Overwrite"));
println_Msg(F(""));
display_Update();
delay(2000);
}
}
} }
void print_FatalError(const __FlashStringHelper* errorMessage) __attribute__ ((noreturn));
void print_FatalError(const __FlashStringHelper* errorMessage) { void print_FatalError(const __FlashStringHelper* errorMessage) {
print_Error(errorMessage, true); print_Error(errorMessage);
// Redundant as print_Error already calls it, but makes gcc understand that _print_FatalError();
// this in fact does not return.
resetArduino();
} }
void print_FatalError(byte errorMessage) __attribute__ ((noreturn));
void print_FatalError(byte errorMessage){ void print_FatalError(byte errorMessage){
print_Error(errorMessage, true); print_Error(errorMessage);
// Redundant as print_Error already calls it, but makes gcc understand that _print_FatalError();
// this in fact does not return.
resetArduino();
} }
void wait() { void wait() {
@ -2089,7 +2055,7 @@ void save_log() {
strcpy(fileName, romName); strcpy(fileName, romName);
strcat(fileName, ".txt"); strcat(fileName, ".txt");
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
while (myLog.available()) { while (myLog.available()) {
@ -2486,7 +2452,7 @@ byte questionBox_Serial(const __FlashStringHelper* question, char answers[7][20]
EEPROM_readAnything(0, foldern); EEPROM_readAnything(0, foldern);
sprintf(fileName, "IMPORT/%d.bin", foldern); sprintf(fileName, "IMPORT/%d.bin", foldern);
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
} }
// Read file from serial // Read file from serial
@ -2753,7 +2719,7 @@ void wait_serial() {
myFile.close(); myFile.close();
} }
else { else {
print_Error(open_file_STR, true); print_FatalError(open_file_STR);
} }
}*/ }*/
} }
@ -2903,15 +2869,6 @@ void wait_btn() {
// get input button // get input button
int b = checkButton(); int b = checkButton();
#ifdef enable_N64
#ifndef clockgen_installed
// Send some clock pulses to the Eeprom in case it locked up
if ((mode == mode_N64_Cart) && ((saveType == 5) || (saveType == 6))) {
pulseClock_N64(1);
}
#endif
#endif
// if the cart readers input button is pressed shortly // if the cart readers input button is pressed shortly
if (b == 1) { if (b == 1) {
errorLvl = 0; errorLvl = 0;
@ -3005,15 +2962,6 @@ void wait_btn() {
// get input button // get input button
int b = checkButton(); int b = checkButton();
#ifdef enable_N64
#ifndef clockgen_installed
// Send some clock pulses to the Eeprom in case it locked up
if ((mode == mode_N64_Cart) && ((saveType == 5) || (saveType == 6))) {
pulseClock_N64(1);
}
#endif
#endif
// if the cart readers input button is pressed shortly // if the cart readers input button is pressed shortly
if (b == 1) { if (b == 1) {
errorLvl = 0; errorLvl = 0;
@ -3045,15 +2993,6 @@ void wait_encoder() {
encoder.tick(); encoder.tick();
int newPos = encoder.getPosition(); int newPos = encoder.getPosition();
#ifdef enable_N64
#ifndef clockgen_installed
// Send some clock pulses to the Eeprom in case it locked up
if ((mode == mode_N64_Cart) && ((saveType == 5) || (saveType == 6))) {
pulseClock_N64(1);
}
#endif
#endif
if (rotaryPos != newPos) { if (rotaryPos != newPos) {
rotaryPos = newPos; rotaryPos = newPos;
errorLvl = 0; errorLvl = 0;
@ -3094,7 +3033,7 @@ browserstart:
// Open filepath directory // Open filepath directory
if (!myDir.open(filePath)) { if (!myDir.open(filePath)) {
display_Clear(); display_Clear();
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
// Count files in directory // Count files in directory
@ -3120,7 +3059,7 @@ page:
// Open filepath directory // Open filepath directory
if (!myDir.open(filePath)) { if (!myDir.open(filePath)) {
display_Clear(); display_Clear();
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
int countFile = 0; int countFile = 0;

View File

@ -569,7 +569,7 @@ idtheflash:
println_Msg(F("")); println_Msg(F(""));
display_Update(); display_Update();
resetFlash8(); resetFlash8();
print_Error(F("Press Button to reset"), true); print_FatalError(F("Press Button to reset"));
} }
println_Msg(""); println_Msg("");
// Prints string out of the common strings array either with or without newline // Prints string out of the common strings array either with or without newline
@ -624,7 +624,7 @@ void id_Flash16() {
flashSize = 8388608; flashSize = 8388608;
flashromType = 2; flashromType = 2;
} else { } else {
print_Error(F("Unknown flashrom"), true); print_FatalError(F("Unknown flashrom"));
println_Msg(""); println_Msg("");
} }
println_Msg(""); println_Msg("");
@ -1054,7 +1054,7 @@ void writeFlash29F032() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) if (fileSize > flashSize)
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
// Set data pins to output // Set data pins to output
dataOut(); dataOut();
@ -1194,7 +1194,7 @@ void writeFlash29F1610() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) if (fileSize > flashSize)
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
// Set data pins to output // Set data pins to output
dataOut(); dataOut();
@ -1248,7 +1248,7 @@ void writeFlash29F1601() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) if (fileSize > flashSize)
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
// Set data pins to output // Set data pins to output
dataOut(); dataOut();
@ -1393,7 +1393,7 @@ void writeFlash29LV640() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) if (fileSize > flashSize)
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
// Set data pins to output // Set data pins to output
dataOut(); dataOut();
@ -1440,7 +1440,7 @@ void writeFlash29GL(unsigned long sectorSize, byte bufferSize) {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) if (fileSize > flashSize)
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
// Set data pins to output // Set data pins to output
dataOut(); dataOut();
@ -1507,7 +1507,7 @@ void writeFlash29F800() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) if (fileSize > flashSize)
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
// Set data pins to output // Set data pins to output
dataOut(); dataOut();
@ -1612,7 +1612,7 @@ void writeFlash28FXXX() {
void writeFlashE28FXXXJ3A() { void writeFlashE28FXXXJ3A() {
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) { if (fileSize > flashSize) {
print_Error(file_too_big_STR, false); print_Error(file_too_big_STR);
return; return;
} }
@ -1663,7 +1663,7 @@ void writeFlashE28FXXXJ3A() {
void writeFlashLH28F0XX() { void writeFlashLH28F0XX() {
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) { if (fileSize > flashSize) {
print_Error(file_too_big_STR, false); print_Error(file_too_big_STR);
return; return;
} }
@ -1718,7 +1718,7 @@ void blankcheck_Flash() {
println_Msg(F("Flashrom is empty")); println_Msg(F("Flashrom is empty"));
display_Update(); display_Update();
} else { } else {
print_Error(F("Error: Not blank"), false); print_Error(F("Error: Not blank"));
} }
} }
@ -1731,7 +1731,7 @@ void verifyFlash() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) if (fileSize > flashSize)
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
blank = 0; blank = 0;
for (unsigned long currByte = 0; currByte < fileSize; currByte += 512) { for (unsigned long currByte = 0; currByte < fileSize; currByte += 512) {
@ -1750,7 +1750,7 @@ void verifyFlash() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(blank); print_Msg(blank);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
// Close the file: // Close the file:
myFile.close(); myFile.close();
@ -1782,7 +1782,7 @@ void readFlash() {
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
} }
for (unsigned long currByte = 0; currByte < flashSize; currByte += 512) { for (unsigned long currByte = 0; currByte < flashSize; currByte += 512) {
for (int c = 0; c < 512; c++) { for (int c = 0; c < 512; c++) {
@ -1853,7 +1853,7 @@ void writeFlash16() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) if (fileSize > flashSize)
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
// Set data pins to output // Set data pins to output
dataOut16(); dataOut16();
@ -1911,7 +1911,7 @@ void writeFlash16_29F1601() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) if (fileSize > flashSize)
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
// Set data pins to output // Set data pins to output
dataOut16(); dataOut16();
@ -2031,7 +2031,7 @@ void blankcheck16() {
println_Msg(F("Flashrom is empty.")); println_Msg(F("Flashrom is empty."));
display_Update(); display_Update();
} else { } else {
print_Error(F("Error: Not blank"), false); print_Error(F("Error: Not blank"));
} }
} }
@ -2044,7 +2044,7 @@ void verifyFlash16() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) { if (fileSize > flashSize) {
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
} }
blank = 0; blank = 0;
@ -2068,7 +2068,7 @@ void verifyFlash16() {
} else { } else {
println_Msg(F("Verification ERROR!")); println_Msg(F("Verification ERROR!"));
print_Msg(blank); print_Msg(blank);
print_Error(F("B did not verify."), false); print_Error(F("B did not verify."));
display_Update(); display_Update();
} }
// Close the file: // Close the file:
@ -2211,7 +2211,7 @@ void writeFlash16_29LV640() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) if (fileSize > flashSize)
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
// Set data pins to output // Set data pins to output
dataOut16(); dataOut16();
@ -2374,7 +2374,7 @@ void blankcheck_Eprom() {
println_Msg(F("Flashrom is empty.")); println_Msg(F("Flashrom is empty."));
display_Update(); display_Update();
} else { } else {
print_Error(F("Error: Not blank"), false); print_Error(F("Error: Not blank"));
} }
} }
@ -2438,7 +2438,7 @@ void write_Eprom() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) if (fileSize > flashSize)
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
// Switch VPP/OE(PH5) to HIGH // Switch VPP/OE(PH5) to HIGH
PORTH |= (1 << 5); PORTH |= (1 << 5);
@ -2473,7 +2473,7 @@ void write_Eprom() {
print_Msg(readWord_Eprom(currWord + c), HEX); print_Msg(readWord_Eprom(currWord + c), HEX);
print_Msg(F(" != 0x")); print_Msg(F(" != 0x"));
println_Msg(myWord, HEX); println_Msg(myWord, HEX);
print_Error(F("Press button to reset"), true); print_FatalError(F("Press button to reset"));
} }
n++; n++;
} while (checkWord != myWord); } while (checkWord != myWord);
@ -2497,7 +2497,7 @@ void verify_Eprom() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) { if (fileSize > flashSize) {
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
} }
blank = 0; blank = 0;
@ -2521,7 +2521,7 @@ void verify_Eprom() {
} else { } else {
println_Msg(F("Verification ERROR!")); println_Msg(F("Verification ERROR!"));
print_Msg(blank); print_Msg(blank);
print_Error(F(" words did not verify."), false); print_Error(F(" words did not verify."));
display_Update(); display_Update();
} }
// Close the file: // Close the file:

View File

@ -240,7 +240,7 @@ void gbxMenu() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(wrErrors); print_Msg(wrErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
break; break;
} }
@ -250,7 +250,7 @@ void gbxMenu() {
println_Msg(F("Error: No save found.")); println_Msg(F("Error: No save found."));
} }
} else { } else {
print_Error(F("Cart has no Sram"), false); print_Error(F("Cart has no Sram"));
} }
// Reset // Reset
wait(); wait();
@ -316,7 +316,7 @@ void gbMenu() {
else else
readSRAM_GB(); readSRAM_GB();
} else { } else {
print_Error(F("No save or unsupported type"), false); print_Error(F("No save or unsupported type"));
} }
println_Msg(F("")); println_Msg(F(""));
break; break;
@ -343,11 +343,11 @@ void gbMenu() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(wrErrors); print_Msg(wrErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
} }
} else { } else {
print_Error(F("No save or unsupported type"), false); print_Error(F("No save or unsupported type"));
} }
println_Msg(F("")); println_Msg(F(""));
break; break;
@ -547,7 +547,7 @@ void showCartInfo_GB() {
display_Update(); display_Update();
wait(); wait();
} else { } else {
print_Error(F("GAMEPAK ERROR"), true); print_FatalError(F("GAMEPAK ERROR"));
} }
} }
@ -750,7 +750,7 @@ void getCartInfo_GB() {
} }
if (logoChecksum != 0x1546) { if (logoChecksum != 0x1546) {
print_Error(F("STARTUP LOGO ERROR"), false); print_Error(F("STARTUP LOGO ERROR"));
println_Msg(F("")); println_Msg(F(""));
println_Msg(F("")); println_Msg(F(""));
println_Msg(F("")); println_Msg(F(""));
@ -781,7 +781,7 @@ void getCartInfo_GB() {
} }
if (headerChecksum != sdBuffer[0x14D]) { if (headerChecksum != sdBuffer[0x14D]) {
print_Error(F("HEADER CHECKSUM ERROR"), false); print_Error(F("HEADER CHECKSUM ERROR"));
println_Msg(F("")); println_Msg(F(""));
println_Msg(F("")); println_Msg(F(""));
println_Msg(F("")); println_Msg(F(""));
@ -960,7 +960,7 @@ void readROM_GB() {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
} }
word endAddress = 0x7FFF; word endAddress = 0x7FFF;
@ -1109,7 +1109,7 @@ unsigned int calc_checksum_GB(char* fileName) {
} }
// Else show error // Else show error
else { else {
print_Error(F("DUMP ROM 1ST"), false); print_Error(F("DUMP ROM 1ST"));
return 0; return 0;
} }
} }
@ -1137,7 +1137,7 @@ void compare_checksums_GB() {
} else { } else {
print_Msg(F(" != ")); print_Msg(F(" != "));
println_Msg(checksumStr); println_Msg(checksumStr);
print_Error(F("Invalid Checksum"), false); print_Error(F("Invalid Checksum"));
} }
compareCRC("gb.txt", 0, 1, 0); compareCRC("gb.txt", 0, 1, 0);
display_Update(); display_Update();
@ -1169,7 +1169,7 @@ void readSRAM_GB() {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
// MBC2 Fix // MBC2 Fix
@ -1207,7 +1207,7 @@ void readSRAM_GB() {
println_Msg(F("/")); println_Msg(F("/"));
display_Update(); display_Update();
} else { } else {
print_Error(F("Cart has no SRAM"), false); print_Error(F("Cart has no SRAM"));
} }
} }
@ -1250,10 +1250,10 @@ void writeSRAM_GB() {
display_Update(); display_Update();
} else { } else {
print_Error(F("File doesnt exist"), false); print_Error(F("File doesnt exist"));
} }
} else { } else {
print_Error(F("Cart has no SRAM"), false); print_Error(F("Cart has no SRAM"));
} }
} }
@ -1300,7 +1300,7 @@ unsigned long verifySRAM_GB() {
myFile.close(); myFile.close();
return writeErrors; return writeErrors;
} else { } else {
print_Error(open_file_STR, true); print_FatalError(open_file_STR);
return 1; return 1;
} }
} }
@ -1329,7 +1329,7 @@ void readSRAMFLASH_MBC6_GB() {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
//Initialize progress bar //Initialize progress bar
@ -1476,7 +1476,7 @@ void writeSRAMFLASH_MBC6_GB() {
writeByte_GB(0x3800, 0x00); writeByte_GB(0x3800, 0x00);
myFile.close(); myFile.close();
display_Clear(); display_Clear();
print_Error(F("Error erasing FLASH sector."), true); print_FatalError(F("Error erasing FLASH sector."));
} }
} }
} else { } else {
@ -1515,7 +1515,7 @@ void writeSRAMFLASH_MBC6_GB() {
writeByte_GB(0x3800, 0x00); writeByte_GB(0x3800, 0x00);
myFile.close(); myFile.close();
display_Clear(); display_Clear();
print_Error(F("Error writing to FLASH."), true); print_FatalError(F("Error writing to FLASH."));
} }
} }
writeByte_GB(romAddress - 1, 0xF0); writeByte_GB(romAddress - 1, 0xF0);
@ -1536,7 +1536,7 @@ void writeSRAMFLASH_MBC6_GB() {
println_Msg(F("Save writing finished")); println_Msg(F("Save writing finished"));
display_Update(); display_Update();
} else { } else {
print_Error(F("File doesnt exist"), false); print_Error(F("File doesnt exist"));
} }
} }
@ -1649,7 +1649,7 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
sprintf(flashid_str, "%04X", flashid); sprintf(flashid_str, "%04X", flashid);
println_Msg(flashid_str); println_Msg(flashid_str);
display_Update(); display_Update();
print_Error(F("Unknown flashrom"), true); print_FatalError(F("Unknown flashrom"));
} }
// Reset flash // Reset flash
@ -1696,7 +1696,7 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
for (int j = 0; j < 512; j++) { for (int j = 0; j < 512; j++) {
if (sdBuffer[j] != 0xFF) { if (sdBuffer[j] != 0xFF) {
println_Msg(F("Not empty")); println_Msg(F("Not empty"));
print_Error(F("Erase failed"), true); print_FatalError(F("Erase failed"));
} }
} }
} }
@ -1852,7 +1852,7 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
println_Msg(F("Error")); println_Msg(F("Error"));
print_Msg(writeErrors); print_Msg(writeErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, true); print_FatalError(did_not_verify_STR);
} }
} else { } else {
print_STR(open_file_STR, 1); print_STR(open_file_STR, 1);
@ -2095,7 +2095,7 @@ bool writeCFI_GB() {
for (int j = 0; j < 512; j++) { for (int j = 0; j < 512; j++) {
if (sdBuffer[j] != 0xFF) { if (sdBuffer[j] != 0xFF) {
println_Msg(F("Not empty")); println_Msg(F("Not empty"));
print_Error(F("Erase failed"), true); print_FatalError(F("Erase failed"));
} }
} }
} }
@ -2212,7 +2212,7 @@ bool writeCFI_GB() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(writeErrors); print_Msg(writeErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
} else { } else {
print_STR(open_file_STR, 1); print_STR(open_file_STR, 1);

View File

@ -161,7 +161,7 @@ void gbaMenu() {
printFlashTypeAndWait(F("Panasonic MN63F805MNP")); printFlashTypeAndWait(F("Panasonic MN63F805MNP"));
} else { } else {
printFlashTypeAndWait(F("Unknown")); printFlashTypeAndWait(F("Unknown"));
//print_Error(F(""), true); //print_FatalError(F(""));
} }
if (flashid == 0x1F3D) { // Atmel if (flashid == 0x1F3D) { // Atmel
@ -187,7 +187,7 @@ void gbaMenu() {
printFlashTypeAndWait(F("SANYO LE26FV10N1TS")); printFlashTypeAndWait(F("SANYO LE26FV10N1TS"));
} else { } else {
printFlashTypeAndWait(F("Unknown")); printFlashTypeAndWait(F("Unknown"));
//print_Error(F(""), true); //print_FatalError(F(""));
} }
eraseFLASH_GBA(); eraseFLASH_GBA();
@ -593,7 +593,7 @@ void getCartInfo_GBA() {
if (logoChecksum != 0x4B1B) { if (logoChecksum != 0x4B1B) {
display_Clear(); display_Clear();
print_Error(F("CARTRIDGE ERROR"), false); print_Error(F("CARTRIDGE ERROR"));
strcpy(romName, "ERROR"); strcpy(romName, "ERROR");
println_Msg(F("")); println_Msg(F(""));
println_Msg(F("")); println_Msg(F(""));
@ -755,7 +755,7 @@ void getCartInfo_GBA() {
dont_log = false; dont_log = false;
#endif #endif
} else { } else {
print_Error(F("GBA.txt missing"), true); print_FatalError(F("GBA.txt missing"));
} }
// Get name // Get name
@ -780,7 +780,7 @@ void getCartInfo_GBA() {
// Turn into string // Turn into string
sprintf(calcChecksumStr, "%02X", calcChecksum); sprintf(calcChecksumStr, "%02X", calcChecksum);
println_Msg(calcChecksumStr); println_Msg(calcChecksumStr);
print_Error(F("Checksum Error"), false); print_Error(F("Checksum Error"));
println_Msg(F("")); println_Msg(F(""));
// Prints string out of the common strings array either with or without newline // Prints string out of the common strings array either with or without newline
print_STR(press_button_STR, 1); print_STR(press_button_STR, 1);
@ -865,7 +865,7 @@ void readROM_GBA() {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
} }
//Initialize progress bar //Initialize progress bar
@ -927,13 +927,13 @@ boolean compare_checksum_GBA() {
} else { } else {
print_Msg(F(" != ")); print_Msg(F(" != "));
println_Msg(checksumStr); println_Msg(checksumStr);
print_Error(F("Invalid Checksum"), false); print_Error(F("Invalid Checksum"));
return 0; return 0;
} }
} }
// Else show error // Else show error
else { else {
print_Error(F("Failed to open rom"), false); print_Error(F("Failed to open rom"));
return 0; return 0;
} }
} }
@ -966,7 +966,7 @@ void readSRAM_GBA(boolean browseFile, unsigned long sramSize, uint32_t pos) {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
// Seek to a new position in the file // Seek to a new position in the file
@ -1022,7 +1022,7 @@ void writeSRAM_GBA(boolean browseFile, unsigned long sramSize, uint32_t pos) {
display_Update(); display_Update();
} else { } else {
print_Error(F("File doesnt exist"), false); print_Error(F("File doesnt exist"));
} }
} }
@ -1057,12 +1057,12 @@ unsigned long verifySRAM_GBA(unsigned long sramSize, uint32_t pos) {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(writeErrors); print_Msg(writeErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
return writeErrors; return writeErrors;
} else { } else {
print_Error(F("Can't open file"), false); print_Error(F("Can't open file"));
return 1; return 1;
} }
} }
@ -1106,7 +1106,7 @@ void readFRAM_GBA(unsigned long framSize) {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
for (unsigned long currAddress = 0; currAddress < framSize; currAddress += 512) { for (unsigned long currAddress = 0; currAddress < framSize; currAddress += 512) {
for (int c = 0; c < 512; c++) { for (int c = 0; c < 512; c++) {
@ -1209,7 +1209,7 @@ void writeFRAM_GBA(boolean browseFile, unsigned long framSize) {
display_Update(); display_Update();
} else { } else {
print_Error(F("File doesnt exist"), false); print_Error(F("File doesnt exist"));
} }
} }
@ -1270,7 +1270,7 @@ unsigned long verifyFRAM_GBA(unsigned long framSize) {
myFile.close(); myFile.close();
return writeErrors; return writeErrors;
} else { } else {
print_Error(F("Can't open file"), false); print_Error(F("Can't open file"));
return 1; return 1;
} }
} }
@ -1461,7 +1461,7 @@ boolean blankcheckFLASH_GBA(unsigned long flashSize) {
// Check buffer // Check buffer
for (unsigned long currByte = 0; currByte < 512; currByte++) { for (unsigned long currByte = 0; currByte < 512; currByte++) {
if (sdBuffer[currByte] != 0xFF) { if (sdBuffer[currByte] != 0xFF) {
print_Error(F("Erase failed"), false); print_Error(F("Erase failed"));
currByte = 512; currByte = 512;
currAddress = flashSize; currAddress = flashSize;
blank = 0; blank = 0;
@ -1539,7 +1539,7 @@ void readFLASH_GBA(boolean browseFile, unsigned long flashSize, uint32_t pos) {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
// Seek to a new position in the file // Seek to a new position in the file
@ -1657,7 +1657,7 @@ void writeFLASH_GBA(boolean browseFile, unsigned long flashSize, uint32_t pos, b
} else { } else {
println_Msg(F("Error")); println_Msg(F("Error"));
print_Error(F("File doesnt exist"), false); print_Error(F("File doesnt exist"));
} }
} }
@ -1684,7 +1684,7 @@ unsigned long verifyFLASH_GBA(unsigned long flashSize, uint32_t pos) {
//open file on sd card //open file on sd card
if (!myFile.open(filePath, O_READ)) { if (!myFile.open(filePath, O_READ)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
// Seek to a new position in the file // Seek to a new position in the file
@ -1710,7 +1710,7 @@ unsigned long verifyFLASH_GBA(unsigned long flashSize, uint32_t pos) {
println_Msg(F("OK")); println_Msg(F("OK"));
} else { } else {
print_Msg(wrError); print_Msg(wrError);
print_Error(F(" Errors"), false); print_Error(F(" Errors"));
} }
return wrError; return wrError;
@ -1753,7 +1753,7 @@ void writeEeprom_GBA(word eepSize) {
display_Update(); display_Update();
} else { } else {
println_Msg(F("Error")); println_Msg(F("Error"));
print_Error(F("File doesnt exist"), false); print_Error(F("File doesnt exist"));
} }
} }
@ -1782,7 +1782,7 @@ void readEeprom_GBA(word eepSize) {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
// Each block contains 8 Bytes, so for a 8KB eeprom 1024 blocks need to be read // Each block contains 8 Bytes, so for a 8KB eeprom 1024 blocks need to be read
@ -2024,7 +2024,7 @@ unsigned long verifyEEP_GBA(word eepSize) {
//open file on sd card //open file on sd card
if (!myFile.open(filePath, O_READ)) { if (!myFile.open(filePath, O_READ)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
// Fill sd Buffer // Fill sd Buffer
@ -2050,7 +2050,7 @@ unsigned long verifyEEP_GBA(word eepSize) {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(wrError); print_Msg(wrError);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
return wrError; return wrError;
@ -2134,7 +2134,7 @@ void idFlashrom_GBA() {
print_Msg(F("Flash ID: ")); print_Msg(F("Flash ID: "));
println_Msg(flashid_str); println_Msg(flashid_str);
println_Msg(F("")); println_Msg(F(""));
print_Error(F("Check voltage"), true); print_FatalError(F("Check voltage"));
} }
} }
} }
@ -2532,7 +2532,7 @@ boolean verifyFlashrom_GBA() {
return 0; return 0;
} }
} else { } else {
print_Error(open_file_STR, true); print_FatalError(open_file_STR);
return 9999; return 9999;
} }
} }
@ -2561,7 +2561,7 @@ void flashRepro_GBA() {
} else { } else {
print_Msg(F("romType: 0x")); print_Msg(F("romType: 0x"));
println_Msg(romType, HEX); println_Msg(romType, HEX);
print_Error(F("Unknown manufacturer"), true); print_FatalError(F("Unknown manufacturer"));
} }
} }
// Intel 4000L0YBQ0 // Intel 4000L0YBQ0
@ -2614,7 +2614,7 @@ void flashRepro_GBA() {
resetIntel_GBA(0x200000); resetIntel_GBA(0x200000);
} else if (flashid == 0x227E) { } else if (flashid == 0x227E) {
//if (sectorCheckMX29GL128E_GBA()) { //if (sectorCheckMX29GL128E_GBA()) {
//print_Error(F("Sector Protected"), true); //print_FatalError(F("Sector Protected"));
//} //}
//else { //else {
println_Msg(F("Erasing...")); println_Msg(F("Erasing..."));
@ -2680,16 +2680,16 @@ void flashRepro_GBA() {
println_Msg(F("OK")); println_Msg(F("OK"));
display_Update(); display_Update();
} else { } else {
print_Error(F("ERROR"), true); print_FatalError(F("ERROR"));
} }
/* Skipped blankcheck /* Skipped blankcheck
} }
else { else {
print_Error(F("failed"), true); print_FatalError(F("failed"));
} }
*/ */
} else { } else {
print_Error(open_file_STR, true); print_FatalError(open_file_STR);
} }
} else { } else {
println_Msg(F("Error")); println_Msg(F("Error"));
@ -2698,7 +2698,7 @@ void flashRepro_GBA() {
print_Msg(F("Flash ID: ")); print_Msg(F("Flash ID: "));
println_Msg(flashid_str); println_Msg(flashid_str);
println_Msg(F("")); println_Msg(F(""));
print_Error(F("Check voltage"), true); print_FatalError(F("Check voltage"));
} }
} }

View File

@ -165,7 +165,7 @@ void gbmMenu() {
println_Msg(F("OK")); println_Msg(F("OK"));
display_Update(); display_Update();
} else { } else {
print_Error(F("Erasing failed"), false); print_Error(F("Erasing failed"));
break; break;
} }
@ -235,7 +235,7 @@ void setup_GBM() {
timeout++; timeout++;
if (timeout > 10) { if (timeout > 10) {
println_Msg(F("Error: Time Out")); println_Msg(F("Error: Time Out"));
print_Error(F("Please power cycle"), true); print_FatalError(F("Please power cycle"));
} }
} }
} }
@ -337,7 +337,7 @@ void readROM_GBM(word numBanks) {
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
} else { } else {
// Read rom // Read rom
word currAddress = 0; word currAddress = 0;
@ -439,7 +439,7 @@ void send_GBM(byte myCommand) {
break; break;
default: default:
print_Error(F("Unknown Command"), true); print_FatalError(F("Unknown Command"));
break; break;
} }
} }
@ -459,7 +459,7 @@ void send_GBM(byte myCommand, word myAddress, byte myData) {
break; break;
default: default:
print_Error(F("Unknown Command"), true); print_FatalError(F("Unknown Command"));
break; break;
} }
} }
@ -508,7 +508,7 @@ boolean readFlashID_GBM() {
} else { } else {
print_Msg(F("Flash ID: ")); print_Msg(F("Flash ID: "));
println_Msg(flashid_str); println_Msg(flashid_str);
print_Error(F("Unknown Flash ID"), true); print_FatalError(F("Unknown Flash ID"));
resetFlash_GBM(); resetFlash_GBM();
return 0; return 0;
} }
@ -592,7 +592,7 @@ void writeFlash_GBM() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if ((fileSize / 0x4000) > 64) { if ((fileSize / 0x4000) > 64) {
print_Error(F("File is too big."), true); print_FatalError(F("File is too big."));
} }
// Enable access to ports 0120h // Enable access to ports 0120h
@ -685,7 +685,7 @@ void writeFlash_GBM() {
myFile.close(); myFile.close();
print_STR(done_STR, 1); print_STR(done_STR, 1);
} else { } else {
print_Error(F("Can't open file"), false); print_Error(F("Can't open file"));
} }
} }
@ -722,7 +722,7 @@ void readMapping_GBM() {
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
} else { } else {
for (byte currByte = 0; currByte < 128; currByte++) { for (byte currByte = 0; currByte < 128; currByte++) {
sdBuffer[currByte] = readByte_GBM(currByte); sdBuffer[currByte] = readByte_GBM(currByte);
@ -821,7 +821,7 @@ void writeMapping_GBM() {
if (myFile.open(filePath, O_READ)) { if (myFile.open(filePath, O_READ)) {
// Get map file size and check if it exceeds 128KByte // Get map file size and check if it exceeds 128KByte
if (myFile.fileSize() > 0x80) { if (myFile.fileSize() > 0x80) {
print_Error(F("File is too big."), true); print_FatalError(F("File is too big."));
} }
// Enable access to ports 0120h // Enable access to ports 0120h
@ -899,7 +899,7 @@ void writeMapping_GBM() {
myFile.close(); myFile.close();
print_STR(done_STR, 1); print_STR(done_STR, 1);
} else { } else {
print_Error(F("Can't open file"), false); print_Error(F("Can't open file"));
} }
} }

View File

@ -72,7 +72,7 @@ boolean compare_checksum_GBS() {
} else { } else {
print_Msg(F("Result: ")); print_Msg(F("Result: "));
println_Msg(calcsumStr); println_Msg(calcsumStr);
print_Error(F("Checksum Error"), false); print_Error(F("Checksum Error"));
return 0; return 0;
} }
} }
@ -206,7 +206,7 @@ void gbSmartGameOptions() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(wrErrors); print_Msg(wrErrors);
println_Msg(F(" bytes")); println_Msg(F(" bytes"));
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
break; break;
} }
@ -400,7 +400,7 @@ void gbSmartReadFlash() {
display_Update(); display_Update();
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
// reset flash to read array state // reset flash to read array state
for (uint16_t i = 0x00; i < gbSmartBanks; i += gbSmartBanksPerFlashChip) for (uint16_t i = 0x00; i < gbSmartBanks; i += gbSmartBanksPerFlashChip)
@ -456,7 +456,7 @@ void gbSmartWriteFlash() {
display_Update(); display_Update();
if (!gbSmartBlankCheckingFlash(bank)) if (!gbSmartBlankCheckingFlash(bank))
print_Error(F("Could not erase flash"), true); print_FatalError(F("Could not erase flash"));
println_Msg(F("Passed")); println_Msg(F("Passed"));
display_Update(); display_Update();
@ -479,13 +479,13 @@ void gbSmartWriteFlash() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(writeErrors); print_Msg(writeErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, true); print_FatalError(did_not_verify_STR);
} }
} }
void gbSmartWriteFlash(uint32_t start_bank) { void gbSmartWriteFlash(uint32_t start_bank) {
if (!myFile.open(filePath, O_READ)) if (!myFile.open(filePath, O_READ))
print_Error(open_file_STR, true); print_FatalError(open_file_STR);
// switch to flash base bank // switch to flash base bank
gbSmartRemapStartBank(start_bank, gbSmartFlashSizeGB, gbSmartSramSizeGB); gbSmartRemapStartBank(start_bank, gbSmartFlashSizeGB, gbSmartSramSizeGB);
@ -546,7 +546,7 @@ uint32_t gbSmartVerifyFlash() {
if (!myFile.open(filePath, O_READ)) { if (!myFile.open(filePath, O_READ)) {
verified = 0xffffffff; verified = 0xffffffff;
print_Error(F("Can't open file on SD"), false); print_Error(F("Can't open file on SD"));
} else { } else {
// remaps mmc to full access // remaps mmc to full access
gbSmartRemapStartBank(0x00, gbSmartRomSizeGB, gbSmartSramSizeGB); gbSmartRemapStartBank(0x00, gbSmartRomSizeGB, gbSmartSramSizeGB);

View File

@ -323,7 +323,7 @@ void readROM_INTV() {
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
// write new folder number back to EEPROM // write new folder number back to EEPROM
foldern++; foldern++;
@ -938,7 +938,7 @@ void setCart_INTV() {
} }
} }
} else { } else {
print_Error(F("Database file not found"), true); print_FatalError(F("Database file not found"));
} }
} }
#endif #endif

View File

@ -255,7 +255,7 @@ void mdMenu() {
println_Msg(F("MX29F1610 detected")); println_Msg(F("MX29F1610 detected"));
flashSize = 2097152; flashSize = 2097152;
} else { } else {
print_Error(F("Error: Unknown flashrom"), true); print_FatalError(F("Error: Unknown flashrom"));
} }
display_Update(); display_Update();
@ -307,7 +307,7 @@ void mdCartMenu() {
readROM_MD(); readROM_MD();
} }
} else { } else {
print_Error(F("Cart has no ROM"), false); print_Error(F("Cart has no ROM"));
} }
#ifdef global_log #ifdef global_log
save_log(); save_log();
@ -326,7 +326,7 @@ void mdCartMenu() {
readSram_MD(); readSram_MD();
enableSram_MD(0); enableSram_MD(0);
} else { } else {
print_Error(F("Cart has no Sram"), false); print_Error(F("Cart has no Sram"));
} }
break; break;
@ -350,10 +350,10 @@ void mdCartMenu() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(writeErrors); print_Msg(writeErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
} else { } else {
print_Error(F("Cart has no Sram"), false); print_Error(F("Cart has no Sram"));
} }
break; break;
@ -362,7 +362,7 @@ void mdCartMenu() {
if (saveType == 4) if (saveType == 4)
readEEP_MD(); readEEP_MD();
else { else {
print_Error(F("Cart has no EEPROM"), false); print_Error(F("Cart has no EEPROM"));
} }
break; break;
@ -374,7 +374,7 @@ void mdCartMenu() {
display_Clear(); display_Clear();
writeEEP_MD(); writeEEP_MD();
} else { } else {
print_Error(F("Cart has no EEPROM"), false); print_Error(F("Cart has no EEPROM"));
} }
break; break;
@ -417,7 +417,7 @@ void segaCDMenu() {
if (bramSize > 0) if (bramSize > 0)
readBram_MD(); readBram_MD();
else { else {
print_Error(F("Not CD Backup RAM Cart"), false); print_Error(F("Not CD Backup RAM Cart"));
} }
break; break;
@ -429,7 +429,7 @@ void segaCDMenu() {
display_Clear(); display_Clear();
writeBram_MD(); writeBram_MD();
} else { } else {
print_Error(F("Not CD Backup RAM Cart"), false); print_Error(F("Not CD Backup RAM Cart"));
} }
break; break;
@ -882,7 +882,7 @@ void getCartInfo_MD() {
print_Msg(("sramEnd: ")); print_Msg(("sramEnd: "));
print_Msg_PaddedHex32(sramEnd); print_Msg_PaddedHex32(sramEnd);
println_Msg(F("")); println_Msg(F(""));
print_Error(F("Unknown Sram Base"), true); print_FatalError(F("Unknown Sram Base"));
} }
} else if (sramType == 0xE020) { // SRAM BOTH BYTES } else if (sramType == 0xE020) { // SRAM BOTH BYTES
// Get sram start and end // Get sram start and end
@ -907,7 +907,7 @@ void getCartInfo_MD() {
print_Msg(("sramEnd: ")); print_Msg(("sramEnd: "));
print_Msg_PaddedHex32(sramEnd); print_Msg_PaddedHex32(sramEnd);
println_Msg(F("")); println_Msg(F(""));
print_Error(F("Unknown Sram Base"), true); print_FatalError(F("Unknown Sram Base"));
} }
} }
} else { } else {
@ -1164,7 +1164,7 @@ void readROM_MD() {
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
byte buffer[1024] = { 0 }; byte buffer[1024] = { 0 };
@ -1371,7 +1371,7 @@ void readROM_MD() {
char calcsumStr[5]; char calcsumStr[5];
sprintf(calcsumStr, "%04X", calcCKS); sprintf(calcsumStr, "%04X", calcCKS);
println_Msg(calcsumStr); println_Msg(calcsumStr);
print_Error(F(""), false); print_Error(F(""));
display_Update(); display_Update();
} }
@ -1392,7 +1392,7 @@ void readROM_MD() {
char calcsumStr[5]; char calcsumStr[5];
sprintf(calcsumStr, "%04X", calcCKSLockon); sprintf(calcsumStr, "%04X", calcCKSLockon);
println_Msg(calcsumStr); println_Msg(calcsumStr);
print_Error(F(""), false); print_Error(F(""));
display_Update(); display_Update();
} }
} }
@ -1405,7 +1405,7 @@ void readROM_MD() {
char calcsumStr[5]; char calcsumStr[5];
sprintf(calcsumStr, "%04X", calcCKSSonic2); sprintf(calcsumStr, "%04X", calcCKSSonic2);
println_Msg(calcsumStr); println_Msg(calcsumStr);
print_Error(F(""), false); print_Error(F(""));
display_Update(); display_Update();
} }
} }
@ -1483,14 +1483,14 @@ void writeSram_MD() {
writeWord_MD(currByte, data); writeWord_MD(currByte, data);
} }
} else } else
print_Error(F("Unknown save type"), false); print_Error(F("Unknown save type"));
// Close the file: // Close the file:
myFile.close(); myFile.close();
print_STR(done_STR, 1); print_STR(done_STR, 1);
display_Update(); display_Update();
} else { } else {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
dataIn_MD(); dataIn_MD();
} }
@ -1515,7 +1515,7 @@ void readSram_MD() {
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
for (unsigned long currBuffer = sramBase; currBuffer < sramBase + sramSize; currBuffer += 256) { for (unsigned long currBuffer = sramBase; currBuffer < sramBase + sramSize; currBuffer += 256) {
@ -1609,7 +1609,7 @@ unsigned long verifySram_MD() {
// Close the file: // Close the file:
myFile.close(); myFile.close();
} else { } else {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
// Return 0 if verified ok, or number of errors // Return 0 if verified ok, or number of errors
return writeErrors; return writeErrors;
@ -1645,7 +1645,7 @@ void write29F1610_MD() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) { if (fileSize > flashSize) {
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
} }
// Set data pins to output // Set data pins to output
dataOut_MD(); dataOut_MD();
@ -1754,7 +1754,7 @@ void blankcheck_MD() {
} }
} }
if (!blank) { if (!blank) {
print_Error(F("Error: Not blank"), false); print_Error(F("Error: Not blank"));
} }
} }
@ -1764,7 +1764,7 @@ void verifyFlash_MD() {
// Get rom size from file // Get rom size from file
fileSize = myFile.fileSize(); fileSize = myFile.fileSize();
if (fileSize > flashSize) { if (fileSize > flashSize) {
print_Error(file_too_big_STR, true); print_FatalError(file_too_big_STR);
} }
blank = 0; blank = 0;
@ -1792,7 +1792,7 @@ void verifyFlash_MD() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(blank); print_Msg(blank);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
// Close the file: // Close the file:
myFile.close(); myFile.close();
@ -2382,7 +2382,7 @@ void readEEP_MD() {
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
if (eepSize > 0x100) { // 24C04+ if (eepSize > 0x100) { // 24C04+
for (word currByte = 0; currByte < eepSize; currByte += 256) { for (word currByte = 0; currByte < eepSize; currByte += 256) {
@ -2451,7 +2451,7 @@ void writeEEP_MD() {
print_STR(done_STR, 1); print_STR(done_STR, 1);
display_Update(); display_Update();
} else { } else {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
dataIn_MD(); dataIn_MD();
} }
@ -2481,7 +2481,7 @@ void readBram_MD() {
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
for (unsigned long currByte = 0; currByte < bramSize; currByte += 512) { for (unsigned long currByte = 0; currByte < bramSize; currByte += 512) {
@ -2530,7 +2530,7 @@ void writeBram_MD() {
print_STR(done_STR, 1); print_STR(done_STR, 1);
display_Update(); display_Update();
} else { } else {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
dataIn_MD(); dataIn_MD();
} }
@ -2579,7 +2579,7 @@ void readRealtec_MD() {
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
// Realtec Registers // Realtec Registers

File diff suppressed because it is too large Load Diff

View File

@ -514,7 +514,7 @@ void getMapping() {
sd.chdir(); sd.chdir();
if (!database.open("nes.txt", O_READ)) { if (!database.open("nes.txt", O_READ)) {
print_Error(F("Database file not found"), true); print_FatalError(F("Database file not found"));
// never reached // never reached
} }
@ -766,7 +766,7 @@ void readRom_NES() {
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
//Initialize progress bar //Initialize progress bar
@ -825,7 +825,7 @@ void readRaw_NES() {
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
//Initialize progress bar //Initialize progress bar
@ -1203,7 +1203,7 @@ void outputNES() {
display_Clear(); display_Clear();
println_Msg(F("PRG FILE FAILED!")); println_Msg(F("PRG FILE FAILED!"));
display_Update(); display_Update();
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
if (has_header) { if (has_header) {
@ -1223,7 +1223,7 @@ void outputNES() {
display_Clear(); display_Clear();
println_Msg(F("NES FILE FAILED!")); println_Msg(F("NES FILE FAILED!"));
display_Update(); display_Update();
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
if (has_header) { if (has_header) {
@ -4163,7 +4163,7 @@ void writeRAM() {
display_Clear(); display_Clear();
if (ramsize == 0) { if (ramsize == 0) {
print_Error(F("RAM SIZE 0K"), false); print_Error(F("RAM SIZE 0K"));
} else { } else {
fileBrowser(F("Select RAM File")); fileBrowser(F("Select RAM File"));
word base = 0x6000; word base = 0x6000;
@ -4379,7 +4379,7 @@ void writeRAM() {
display_Update(); display_Update();
} else { } else {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
} }

View File

@ -47,7 +47,7 @@ void setup_NGP() {
if (getCartInfo_NGP()) if (getCartInfo_NGP())
printCartInfo_NGP(); printCartInfo_NGP();
else else
print_Error(F("Cartridge read error"), true); print_FatalError(F("Cartridge read error"));
} }
void ngpMenu() { void ngpMenu() {
@ -215,7 +215,7 @@ void readROM_NGP(char* outPathBuf, size_t bufferSize) {
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
// write new folder number back to EEPROM // write new folder number back to EEPROM
foldern++; foldern++;
@ -265,7 +265,7 @@ void scanChip_NGP() {
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
// write new folder number back to EEPROM // write new folder number back to EEPROM
foldern++; foldern++;

View File

@ -543,7 +543,7 @@ void read_tennokoe_bank_PCE(int bank_index) {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
} }
pin_read_write_PCE(); pin_read_write_PCE();
@ -683,7 +683,7 @@ void write_tennokoe_bank_PCE(int bank_index) {
println_Msg(F("Verify failed...")); println_Msg(F("Verify failed..."));
print_Msg(diffcnt); print_Msg(diffcnt);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
pin_init_PCE(); pin_init_PCE();
@ -694,7 +694,7 @@ void write_tennokoe_bank_PCE(int bank_index) {
display_Update(); display_Update();
wait(); wait();
} else { } else {
print_Error(F("File doesn't exist"), false); print_Error(F("File doesn't exist"));
} }
} }
@ -737,7 +737,7 @@ void read_rom_PCE(void) {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
} }
pin_read_write_PCE(); pin_read_write_PCE();

View File

@ -185,7 +185,7 @@ void pcwMenu() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(writeErrors); print_Msg(writeErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
break; break;
@ -478,7 +478,7 @@ void readROM_PCW() {
EEPROM_writeAnything(0, foldern); EEPROM_writeAnything(0, foldern);
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
read_setup_PCW(); read_setup_PCW();
for (unsigned long address = 0; address < 0x400000; address += 512) { // 4MB for (unsigned long address = 0; address < 0x400000; address += 512) { // 4MB
@ -521,7 +521,7 @@ void readMultiROM_PCW() {
EEPROM_writeAnything(0, foldern); EEPROM_writeAnything(0, foldern);
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
display_Clear(); display_Clear();
println_Msg(F("READING MULTI-PACK")); println_Msg(F("READING MULTI-PACK"));
@ -579,7 +579,7 @@ void readSRAM_PCW() { // readSRAM_1A()
EEPROM_writeAnything(0, foldern); EEPROM_writeAnything(0, foldern);
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
display_Clear(); display_Clear();
read_setup_PCW(); read_setup_PCW();
@ -626,10 +626,10 @@ void writeSRAM_PCW() {
print_STR(done_STR, 1); print_STR(done_STR, 1);
display_Update(); display_Update();
} else { } else {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
} else { } else {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
display_Clear(); display_Clear();
} }
@ -652,7 +652,7 @@ unsigned long verifySRAM_PCW() {
} }
myFile.close(); myFile.close();
} else { } else {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
return writeErrors; return writeErrors;

View File

@ -109,7 +109,7 @@ void sfmGameMenu() {
println_Msg(F(" Timeout")); println_Msg(F(" Timeout"));
println_Msg(readBank_SFM(0, 0x2400), HEX); println_Msg(readBank_SFM(0, 0x2400), HEX);
println_Msg(F("")); println_Msg(F(""));
print_Error(F("Powercycle SFM cart"), true); print_FatalError(F("Powercycle SFM cart"));
} }
} }
// Copy gameCode to romName in case of japanese chars in romName // Copy gameCode to romName in case of japanese chars in romName
@ -132,7 +132,7 @@ void sfmGameMenu() {
mode = mode_SFM_Game; mode = mode_SFM_Game;
} }
} else { } else {
print_Error(F("Switch to HiRom failed"), false); print_Error(F("Switch to HiRom failed"));
} }
} }
@ -177,7 +177,7 @@ void sfmGameOptions() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(wrErrors); print_Msg(wrErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
break; break;
@ -246,7 +246,7 @@ void sfmFlashMenu() {
// Read flash // Read flash
readFlash_SFM(); readFlash_SFM();
} else { } else {
print_Error(F("Switch to HiRom failed"), false); print_Error(F("Switch to HiRom failed"));
} }
break; break;
@ -316,13 +316,13 @@ void sfmFlashMenu() {
resetFlash_SFM(0xC0); resetFlash_SFM(0xC0);
resetFlash_SFM(0xE0); resetFlash_SFM(0xE0);
} else { } else {
print_Error(F("Error: Wrong Flash ID"), true); print_FatalError(F("Error: Wrong Flash ID"));
} }
} else { } else {
print_Error(F("Error: Wrong Flash ID"), true); print_FatalError(F("Error: Wrong Flash ID"));
} }
} else { } else {
print_Error(F("failed"), false); print_Error(F("failed"));
} }
break; break;
@ -353,13 +353,13 @@ void sfmFlashMenu() {
resetFlash_SFM(0xC0); resetFlash_SFM(0xC0);
resetFlash_SFM(0xE0); resetFlash_SFM(0xE0);
} else { } else {
print_Error(F("Error: Wrong Flash ID"), true); print_FatalError(F("Error: Wrong Flash ID"));
} }
} else { } else {
print_Error(F("Error: Wrong Flash ID"), true); print_FatalError(F("Error: Wrong Flash ID"));
} }
} else { } else {
print_Error(F("failed"), false); print_Error(F("failed"));
} }
break; break;
@ -576,7 +576,7 @@ void setup_SFM() {
#ifdef clockgen_installed #ifdef clockgen_installed
else { else {
display_Clear(); display_Clear();
print_Error(F("Clock Generator not found"), true); print_FatalError(F("Clock Generator not found"));
} }
#endif #endif
@ -598,7 +598,7 @@ void setup_SFM() {
println_Msg(F("Hirom All Timeout")); println_Msg(F("Hirom All Timeout"));
println_Msg(F("")); println_Msg(F(""));
println_Msg(F("")); println_Msg(F(""));
print_Error(F("Powercycle SFM cart"), true); print_FatalError(F("Powercycle SFM cart"));
} }
} }
} }
@ -903,7 +903,7 @@ void readROM_SFM() {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
} }
// Check if LoROM or HiROM... // Check if LoROM or HiROM...
@ -1078,7 +1078,7 @@ void writeFlash_SFM(int startBank, uint32_t pos) {
myFile.close(); myFile.close();
println_Msg(""); println_Msg("");
} else { } else {
print_Error(open_file_STR, true); print_FatalError(open_file_STR);
} }
} }
@ -1221,7 +1221,7 @@ unsigned long verifyFlash_SFM(int startBank, uint32_t pos) {
} else { } else {
// SD Error // SD Error
verified = 999999; verified = 999999;
print_Error(F("Can't open file on SD"), false); print_Error(F("Can't open file on SD"));
} }
// Return 0 if verified ok, or number of errors // Return 0 if verified ok, or number of errors
return verified; return verified;
@ -1241,7 +1241,7 @@ void readFlash_SFM() {
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
} }
if (romType) { if (romType) {
for (byte currBank = 0xC0; currBank < 0xC0 + numBanks; currBank++) { for (byte currBank = 0xC0; currBank < 0xC0 + numBanks; currBank++) {
@ -1385,7 +1385,7 @@ void readMapping() {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
// Read the mapping info out of the 1st chip // Read the mapping info out of the 1st chip
@ -1471,10 +1471,10 @@ void eraseMapping(byte startBank) {
dataIn(); dataIn();
controlIn_SFM(); controlIn_SFM();
} else { } else {
print_Error(F("Error: Wrong Flash ID"), true); print_FatalError(F("Error: Wrong Flash ID"));
} }
} else { } else {
print_Error(F("Unlock failed"), true); print_FatalError(F("Unlock failed"));
} }
} }
@ -1599,17 +1599,17 @@ void writeMapping_SFM(byte startBank, uint32_t pos) {
myFile.close(); myFile.close();
println_Msg(""); println_Msg("");
} else { } else {
print_Error(F("Can't open file on SD"), false); print_Error(F("Can't open file on SD"));
} }
// Switch to read // Switch to read
dataIn(); dataIn();
controlIn_SFM(); controlIn_SFM();
} else { } else {
print_Error(F("Error: Wrong Flash ID"), true); print_FatalError(F("Error: Wrong Flash ID"));
} }
} else { } else {
print_Error(F("Unlock failed"), true); print_FatalError(F("Unlock failed"));
} }
} }
@ -1717,7 +1717,7 @@ void write_SFM(int startBank, uint32_t pos) {
println_Msg(F("OK")); println_Msg(F("OK"));
display_Update(); display_Update();
} else { } else {
print_Error(F("Could not erase flash"), true); print_FatalError(F("Could not erase flash"));
} }
} }
// Write flash // Write flash
@ -1737,13 +1737,13 @@ void write_SFM(int startBank, uint32_t pos) {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(writeErrors); print_Msg(writeErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, true); print_FatalError(did_not_verify_STR);
} }
} else { } else {
print_Error(F("Error: Wrong Flash ID"), true); print_FatalError(F("Error: Wrong Flash ID"));
} }
} else { } else {
print_Error(F("Unlock failed"), true); print_FatalError(F("Unlock failed"));
} }
} }

View File

@ -593,7 +593,7 @@ void readROM_SMS() {
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
// set default bank size to 16KB // set default bank size to 16KB
@ -678,7 +678,7 @@ void readSRAM_SMS() {
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
// Write the whole 32KB // Write the whole 32KB
// When there is only 8KB of SRAM, the contents should be duplicated // When there is only 8KB of SRAM, the contents should be duplicated
@ -705,7 +705,7 @@ void writeSRAM_SMS() {
display_Clear(); display_Clear();
if (false) { if (false) {
print_Error(F("DISABLED"), false); print_Error(F("DISABLED"));
} else { } else {
fileBrowser(F("Select file")); fileBrowser(F("Select file"));
@ -748,7 +748,7 @@ void writeSRAM_SMS() {
print_STR(done_STR, 1); print_STR(done_STR, 1);
display_Update(); display_Update();
} else { } else {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
} }

View File

@ -216,7 +216,7 @@ void snesMenu() {
display_Update(); display_Update();
} else { } else {
display_Clear(); display_Clear();
print_Error(F("Does not have ROM"), false); print_Error(F("Does not have ROM"));
} }
} }
break; break;
@ -229,7 +229,7 @@ void snesMenu() {
readSRAM(); readSRAM();
} else { } else {
display_Clear(); display_Clear();
print_Error(F("Does not have SRAM"), false); print_Error(F("Does not have SRAM"));
} }
break; break;
@ -248,11 +248,11 @@ void snesMenu() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(wrErrors); print_Msg(wrErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
} else { } else {
display_Clear(); display_Clear();
print_Error(F("Does not have SRAM"), false); print_Error(F("Does not have SRAM"));
} }
break; break;
@ -283,11 +283,11 @@ void snesMenu() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(wrErrors); print_Msg(wrErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
} else { } else {
display_Clear(); display_Clear();
print_Error(F("Does not have SRAM"), false); print_Error(F("Does not have SRAM"));
} }
break; break;
@ -465,7 +465,7 @@ void setup_Snes() {
#ifdef clockgen_installed #ifdef clockgen_installed
else { else {
display_Clear(); display_Clear();
print_Error(F("Clock Generator not found"), true); print_FatalError(F("Clock Generator not found"));
} }
#endif #endif
@ -1213,7 +1213,7 @@ unsigned int calc_checksum(char* fileName, char* folder) {
return (calcChecksum); return (calcChecksum);
} else { } else {
// Else show error // Else show error
print_Error(F("DUMP ROM 1ST"), false); print_Error(F("DUMP ROM 1ST"));
return 0; return 0;
} }
} }
@ -1240,7 +1240,7 @@ boolean compare_checksum() {
} else { } else {
print_Msg(F(" != ")); print_Msg(F(" != "));
println_Msg(checksumStr); println_Msg(checksumStr);
print_Error(F("Invalid Checksum"), false); print_Error(F("Invalid Checksum"));
display_Update(); display_Update();
return 0; return 0;
} }
@ -1275,7 +1275,7 @@ void readROM_SNES() {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
} }
//Dump Derby Stallion '96 (Japan) Actual Size is 24Mb //Dump Derby Stallion '96 (Japan) Actual Size is 24Mb
@ -1604,7 +1604,7 @@ void writeSRAM(boolean browseFile) {
display_Update(); display_Update();
} else { } else {
print_Error(F("File doesnt exist"), false); print_Error(F("File doesnt exist"));
} }
} }
@ -1628,7 +1628,7 @@ void readSRAM() {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
int sramBanks = 0; int sramBanks = 0;
if (romType == LO) { if (romType == LO) {
@ -1904,7 +1904,7 @@ unsigned long verifySRAM() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(writeErrors); print_Msg(writeErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
display_Update(); display_Update();
wait(); wait();
@ -1921,7 +1921,7 @@ unsigned long verifySRAM() {
myFile.close(); myFile.close();
return writeErrors; return writeErrors;
} else { } else {
print_Error(F("Can't open file"), false); print_Error(F("Can't open file"));
return 1; return 1;
} }
} }

View File

@ -85,7 +85,7 @@ void svMenu() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(wrErrors); print_Msg(wrErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
wait(); wait();
break; break;
@ -122,7 +122,7 @@ void setup_SV() {
#ifdef clockgen_installed #ifdef clockgen_installed
else { else {
display_Clear(); display_Clear();
print_Error(F("Clock Generator not found"), true); print_FatalError(F("Clock Generator not found"));
} }
#endif #endif
@ -300,7 +300,7 @@ void readSRAM_SV() {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
readBank_SV(0x10, 0); // Preconfigure to fix corrupt 1st byte readBank_SV(0x10, 0); // Preconfigure to fix corrupt 1st byte
@ -371,7 +371,7 @@ void writeSRAM_SV() {
println_Msg(F("SRAM writing finished")); println_Msg(F("SRAM writing finished"));
display_Update(); display_Update();
} else { } else {
print_Error(F("File doesnt exist"), false); print_Error(F("File doesnt exist"));
} }
} }
@ -402,7 +402,7 @@ unsigned long verifySRAM_SV() {
myFile.close(); myFile.close();
return writeErrors; return writeErrors;
} else { } else {
print_Error(F("Can't open file"), false); print_Error(F("Can't open file"));
return 1; return 1;
} }
} }
@ -438,7 +438,7 @@ void readROM_SV() {
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
} }
// Read Banks // Read Banks
@ -470,7 +470,7 @@ void writeROM_SV(void) {
//if CRC is not 8B86, BS-X cart is not inserted. Display error and reset //if CRC is not 8B86, BS-X cart is not inserted. Display error and reset
if (strcmp("8B86", checksumStr) != 0) { if (strcmp("8B86", checksumStr) != 0) {
display_Clear(); display_Clear();
print_Error(F("Error: Must use BS-X cart"), true); print_FatalError(F("Error: Must use BS-X cart"));
} }
//Display file Browser and wait user to select a file. Size must be 1MB. //Display file Browser and wait user to select a file. Size must be 1MB.
@ -575,7 +575,7 @@ void writeROM_SV(void) {
wait(); wait();
} else { } else {
print_Error(F("File doesn't exist"), false); print_Error(F("File doesn't exist"));
} }
} }

View File

@ -122,7 +122,7 @@ void vboyMenu() {
readSRAM_VB(); readSRAM_VB();
sd.chdir("/"); sd.chdir("/");
} else { } else {
print_Error(F("Cart has no SRAM"), false); print_Error(F("Cart has no SRAM"));
} }
#if (defined(enable_OLED) || defined(enable_LCD)) #if (defined(enable_OLED) || defined(enable_LCD))
// Wait for user input // Wait for user input
@ -149,10 +149,10 @@ void vboyMenu() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(writeErrors); print_Msg(writeErrors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
} else { } else {
print_Error(F("Cart has no SRAM"), false); print_Error(F("Cart has no SRAM"));
} }
#if (defined(enable_OLED) || defined(enable_LCD)) #if (defined(enable_OLED) || defined(enable_LCD))
// Wait for user input // Wait for user input
@ -429,7 +429,7 @@ void readROM_VB() {
EEPROM_writeAnything(0, foldern); EEPROM_writeAnything(0, foldern);
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
word d = 0; word d = 0;
@ -500,7 +500,7 @@ void writeSRAM_VB() {
print_STR(done_STR, 1); print_STR(done_STR, 1);
display_Update(); display_Update();
} else { } else {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
dataIn_VB(); dataIn_VB();
} }
@ -520,7 +520,7 @@ void readSRAM_VB() {
EEPROM_writeAnything(0, foldern); EEPROM_writeAnything(0, foldern);
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
for (unsigned long currBuffer = 0; currBuffer < sramSize; currBuffer += 512) { for (unsigned long currBuffer = 0; currBuffer < sramSize; currBuffer += 512) {
for (int currByte = 0; currByte < 512; currByte++) { for (int currByte = 0; currByte < 512; currByte++) {
@ -554,7 +554,7 @@ unsigned long verifySRAM_VB() {
} }
myFile.close(); myFile.close();
} else { } else {
print_Error(sd_error_STR, true); print_FatalError(sd_error_STR);
} }
return writeErrors; return writeErrors;

View File

@ -77,10 +77,10 @@ void setup_WS() {
// unlock MMC // unlock MMC
// if (!unlockMMC2003_WS()) // if (!unlockMMC2003_WS())
// print_Error(F("Can't initial MMC"), true); // print_FatalError(F("Can't initial MMC"));
// if (getCartInfo_WS() != 0xea) // if (getCartInfo_WS() != 0xea)
// print_Error(F("Rom header read error"), true); // print_FatalError(F("Rom header read error"));
println_Msg(F("Initializing...")); println_Msg(F("Initializing..."));
display_Update(); display_Update();
@ -496,7 +496,7 @@ void readROM_WS(char *outPathBuf, size_t bufferSize) {
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
// write new folder number back to EEPROM // write new folder number back to EEPROM
foldern++; foldern++;
@ -563,7 +563,7 @@ void readSRAM_WS() {
EEPROM_writeAnything(0, foldern); EEPROM_writeAnything(0, foldern);
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
uint32_t bank_size = (sramSize << 7); uint32_t bank_size = (sramSize << 7);
uint16_t end_bank = (bank_size >> 16); // 64KB per bank uint16_t end_bank = (bank_size >> 16); // 64KB per bank
@ -635,10 +635,10 @@ void verifySRAM_WS() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(write_errors); print_Msg(write_errors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
} else { } else {
print_Error(F("File doesn't exist"), false); print_Error(F("File doesn't exist"));
} }
} }
@ -684,7 +684,7 @@ void writeSRAM_WS() {
println_Msg(F("Writing finished")); println_Msg(F("Writing finished"));
display_Update(); display_Update();
} else { } else {
print_Error(F("File doesn't exist"), false); print_Error(F("File doesn't exist"));
} }
} }
@ -708,7 +708,7 @@ void readEEPROM_WS() {
EEPROM_writeAnything(0, foldern); EEPROM_writeAnything(0, foldern);
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
uint32_t eepromSize = (sramSize << 7); uint32_t eepromSize = (sramSize << 7);
uint32_t bufSize = (eepromSize < 512 ? eepromSize : 512); uint32_t bufSize = (eepromSize < 512 ? eepromSize : 512);
@ -789,10 +789,10 @@ void verifyEEPROM_WS() {
print_STR(error_STR, 0); print_STR(error_STR, 0);
print_Msg(write_errors); print_Msg(write_errors);
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR, false); print_Error(did_not_verify_STR);
} }
} else { } else {
print_Error(F("File doesn't exist"), false); print_Error(F("File doesn't exist"));
} }
} }
@ -843,7 +843,7 @@ void writeEEPROM_WS() {
print_STR(done_STR, 1); print_STR(done_STR, 1);
} else { } else {
print_Error(F("File doesn't exist"), false); print_Error(F("File doesn't exist"));
} }
} }
@ -857,7 +857,7 @@ void writeWitchOS_WS() {
dataIn_WS(); dataIn_WS();
if (readWord_WS(0xe0004) || readWord_WS(0xe4004) || readWord_WS(0xec004) || readWord_WS(0xee004)) { if (readWord_WS(0xe0004) || readWord_WS(0xe4004) || readWord_WS(0xec004) || readWord_WS(0xee004)) {
display_Clear(); display_Clear();
print_Error(F("OS sectors are protected!"), false); print_Error(F("OS sectors are protected!"));
} else { } else {
filePath[0] = 0; filePath[0] = 0;
sd.chdir("/"); sd.chdir("/");
@ -932,7 +932,7 @@ void writeWitchOS_WS() {
print_STR(done_STR, 1); print_STR(done_STR, 1);
} else { } else {
print_Error(F("File doesn't exist"), false); print_Error(F("File doesn't exist"));
} }
} }
@ -976,7 +976,7 @@ boolean compareChecksum_WS(const char *wsFilePath) {
display_Update(); display_Update();
if (!myFile.open(wsFilePath, O_READ)) { if (!myFile.open(wsFilePath, O_READ)) {
print_Error(F("Failed to open file"), false); print_Error(F("Failed to open file"));
return 0; return 0;
} }
@ -1013,7 +1013,7 @@ boolean compareChecksum_WS(const char *wsFilePath) {
display_Update(); display_Update();
return 1; return 1;
} else { } else {
print_Error(F("Checksum Error"), false); print_Error(F("Checksum Error"));
return 0; return 0;
} }
} }

View File

@ -205,7 +205,7 @@ void readROM_WSV() {
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_Error(create_file_STR, true); print_FatalError(create_file_STR);
// write new folder number back to EEPROM // write new folder number back to EEPROM
foldern++; foldern++;
@ -516,7 +516,7 @@ void setCart_WSV() {
} }
} }
} else { } else {
print_Error(F("Database file not found"), true); print_FatalError(F("Database file not found"));
} }
} }
#endif #endif