Don't log manual mapper selection to file for NES/GBA

This commit is contained in:
sanni 2022-10-04 20:30:53 +02:00
parent 20898cf3d3
commit bef9d0f5f9
5 changed files with 73 additions and 34 deletions

View File

@ -183,6 +183,7 @@ FsFile myDir;
FsFile myFile; FsFile myFile;
#ifdef global_log #ifdef global_log
FsFile myLog; FsFile myLog;
boolean dont_log = false;
#endif #endif
// AVR Eeprom // AVR Eeprom
@ -690,6 +691,11 @@ boolean compareCRC(char* database, char* crcString, boolean renamerom, int offse
} }
byte starting_letter() { byte starting_letter() {
#ifdef global_log
// Disable log to prevent unnecessary logging
dont_log = true;
#endif
#if (defined(enable_LCD) || defined(enable_OLED)) #if (defined(enable_LCD) || defined(enable_OLED))
byte selection = 0; byte selection = 0;
byte line = 0; byte line = 0;
@ -786,6 +792,11 @@ byte starting_letter() {
byte incomingByte = Serial.read(); byte incomingByte = Serial.read();
return incomingByte; return incomingByte;
#endif #endif
#ifdef global_log
// Enable log again
dont_log = false;
#endif
} }
/****************************************** /******************************************
@ -1985,7 +1996,7 @@ void print_Msg(const __FlashStringHelper * string) {
Serial.print(string); Serial.print(string);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.print(string); if (!dont_log)myLog.print(string);
#endif #endif
} }
@ -2018,7 +2029,7 @@ void print_Msg(const char myString[]) {
Serial.print(myString); Serial.print(myString);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.print(myString); if (!dont_log)myLog.print(myString);
#endif #endif
} }
@ -2033,7 +2044,7 @@ void print_Msg(long unsigned int message) {
Serial.print(message); Serial.print(message);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.print(message); if (!dont_log)myLog.print(message);
#endif #endif
} }
@ -2048,7 +2059,7 @@ void print_Msg(byte message, int outputFormat) {
Serial.print(message, outputFormat); Serial.print(message, outputFormat);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.print(message, outputFormat); if (!dont_log)myLog.print(message, outputFormat);
#endif #endif
} }
@ -2063,7 +2074,7 @@ void print_Msg(word message, int outputFormat) {
Serial.print(message, outputFormat); Serial.print(message, outputFormat);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.print(message, outputFormat); if (!dont_log)myLog.print(message, outputFormat);
#endif #endif
} }
@ -2078,7 +2089,7 @@ void print_Msg(int message, int outputFormat) {
Serial.print(message, outputFormat); Serial.print(message, outputFormat);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.print(message, outputFormat); if (!dont_log)myLog.print(message, outputFormat);
#endif #endif
} }
@ -2093,7 +2104,7 @@ void print_Msg(long unsigned int message, int outputFormat) {
Serial.print(message, outputFormat); Serial.print(message, outputFormat);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.print(message, outputFormat); if (!dont_log)myLog.print(message, outputFormat);
#endif #endif
} }
@ -2108,7 +2119,7 @@ void print_Msg(String string) {
Serial.print(string); Serial.print(string);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.print(string); if (!dont_log)myLog.print(string);
#endif #endif
} }
@ -2140,7 +2151,7 @@ void println_Msg(String string) {
Serial.println(string); Serial.println(string);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.println(string); if (!dont_log)myLog.println(string);
#endif #endif
} }
@ -2156,7 +2167,7 @@ void println_Msg(byte message, int outputFormat) {
Serial.println(message, outputFormat); Serial.println(message, outputFormat);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.println(message, outputFormat); if (!dont_log)myLog.println(message, outputFormat);
#endif #endif
} }
@ -2190,7 +2201,7 @@ void println_Msg(const char myString[]) {
Serial.println(myString); Serial.println(myString);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.println(myString); if (!dont_log)myLog.println(myString);
#endif #endif
} }
@ -2209,7 +2220,7 @@ void println_Msg(const __FlashStringHelper * string) {
char myBuffer[15]; char myBuffer[15];
strlcpy_P(myBuffer, (char *)string, 15); strlcpy_P(myBuffer, (char *)string, 15);
if ((strncmp(myBuffer, "Press Button...", 14) != 0) && (strncmp(myBuffer, "Select file", 10) != 0)) { if ((strncmp(myBuffer, "Press Button...", 14) != 0) && (strncmp(myBuffer, "Select file", 10) != 0)) {
myLog.println(string); if (!dont_log)myLog.println(string);
} }
#endif #endif
} }
@ -2226,7 +2237,7 @@ void println_Msg(long unsigned int message) {
Serial.println(message); Serial.println(message);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.println(message); if (!dont_log)myLog.println(message);
#endif #endif
} }
@ -2241,7 +2252,7 @@ void display_Update() {
delay(100); delay(100);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.flush(); if (!dont_log)myLog.flush();
#endif #endif
} }
@ -2255,7 +2266,7 @@ void display_Clear() {
display.setCursor(0, 0); display.setCursor(0, 0);
#endif #endif
#ifdef global_log #ifdef global_log
myLog.println(""); if (!dont_log)myLog.println("");
#endif #endif
} }

View File

@ -841,6 +841,11 @@ void getCartInfo_GBA() {
if (myFile.open("gba.txt", O_READ)) { if (myFile.open("gba.txt", O_READ)) {
char gamename[100]; char gamename[100];
#ifdef global_log
// Disable log to prevent unnecessary logging
dont_log = true;
#endif
// Loop through file // Loop through file
while (myFile.available()) { while (myFile.available()) {
// Skip first line with name // Skip first line with name
@ -994,6 +999,11 @@ void getCartInfo_GBA() {
} }
// Close the file: // Close the file:
myFile.close(); myFile.close();
#ifdef global_log
// Enable log again
dont_log = false;
#endif
} }
else { else {
print_Error(F("GBA.txt missing"), true); print_Error(F("GBA.txt missing"), true);

View File

@ -650,6 +650,10 @@ boolean getMapping() {
ram = 1; // 1K ram = 1; // 1K
} }
#ifdef global_log
// Disable log to prevent unnecessary logging
dont_log = true;
#endif
println_Msg(gamename); println_Msg(gamename);
print_Msg(F("MAPPER: ")); print_Msg(F("MAPPER: "));
println_Msg(mapper); println_Msg(mapper);
@ -695,6 +699,10 @@ boolean getMapping() {
#endif #endif
display_Update(); display_Update();
#ifdef global_log
// Enable log again
dont_log = false;
#endif
int b = 0; int b = 0;
while (1) { while (1) {
// Check button input // Check button input
@ -800,6 +808,12 @@ void selectMapping() {
// Open database // Open database
if (myFile.open("nes.txt", O_READ)) { if (myFile.open("nes.txt", O_READ)) {
#ifdef global_log
// Disable log to prevent unnecessary logging
dont_log = true;
#endif
// Skip ahead to selected starting letter // Skip ahead to selected starting letter
if ((myLetter > 0) && (myLetter <= 26)) { if ((myLetter > 0) && (myLetter <= 26)) {
while (myFile.available()) { while (myFile.available()) {
@ -1049,6 +1063,10 @@ void selectMapping() {
} }
} }
} }
#ifdef global_log
// Enable log again
dont_log = false;
#endif
} }
else { else {
print_Error(F("Database file not found"), true); print_Error(F("Database file not found"), true);