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

View File

@ -833,13 +833,13 @@ void getCartInfo_GB() {
else if (sramSize > 1) {
lastByte = 0xBFFF;
}
// MBC6
if (romType == 32) {
sramBanks = 8;
lastByte = 0xAFFF;
}
// Get Checksum as string
eepbit[6] = sdBuffer[0x14E];
eepbit[7] = sdBuffer[0x14F];
@ -907,7 +907,7 @@ void getCartInfo_GB() {
(strncmp(romName, "MORTALKOMBAT DUO", 16) == 0) && (sdBuffer[0x14D] == 0xA7)) {
romType += 0x100;
}
// ROM revision
romVersion = sdBuffer[0x14C];
}
@ -986,11 +986,11 @@ void readROM_GB() {
// Set ROM bank for MBC1M
else if (romType == 0x101 || romType == 0x103) {
if (currBank < 10) {
writeByte_GB(0x4000, currBank >> 4);
writeByte_GB(0x2000, (currBank & 0x1f));
writeByte_GB(0x4000, currBank >> 4);
writeByte_GB(0x2000, (currBank & 0x1f));
} else {
writeByte_GB(0x4000, currBank >> 4);
writeByte_GB(0x2000, 0x10 | (currBank & 0x1f));
writeByte_GB(0x4000, currBank >> 4);
writeByte_GB(0x2000, 0x10 | (currBank & 0x1f));
}
}
@ -1321,7 +1321,7 @@ void readSRAMFLASH_MBC6_GB() {
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = 0x108000;
draw_progressbar(0, totalProgressBar);
// Enable Mapper and SRAM
writeByte_GB(0x0000, 0x0A);
@ -1354,7 +1354,7 @@ void readSRAMFLASH_MBC6_GB() {
// Switch FLASH banks
for (byte currBank = 0; currBank < 128; currBank++) {
word romAddress = 0x4000;
writeByte_GB(0x2000, currBank);
writeByte_GB(0x3000, currBank);
@ -1376,7 +1376,7 @@ void readSRAMFLASH_MBC6_GB() {
writeByte_GB(0x1000, 0x00);
writeByte_GB(0x2800, 0x00);
writeByte_GB(0x3800, 0x00);
// Close the file:
myFile.close();
@ -1395,7 +1395,7 @@ void writeSRAMFLASH_MBC6_GB() {
display_Clear();
println_Msg(F("Writing MBC6 save..."));
display_Update();
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = 0x108000;
@ -1403,7 +1403,7 @@ void writeSRAMFLASH_MBC6_GB() {
// Enable Mapper and SRAM
writeByte_GB(0x0000, 0x0A);
// Switch SRAM banks
for (byte currBank = 0; currBank < sramBanks; currBank++) {
writeByte_GB(0x0400, currBank);
@ -1417,20 +1417,20 @@ void writeSRAMFLASH_MBC6_GB() {
processedProgressBar += (lastByte + 1) - 0xA000;
draw_progressbar(processedProgressBar, totalProgressBar);
}
// Disable SRAM
writeByte_GB(0x0000, 0x00);
// Enable flash save memory (map to ROM)
writeByte_GB(0x1000, 0x01);
writeByte_GB(0x0C00, 0x01);
writeByte_GB(0x1000, 0x01);
writeByte_GB(0x2800, 0x08);
writeByte_GB(0x3800, 0x08);
for (byte currBank = 0; currBank < 128; currBank++) {
word romAddress = 0x4000;
// Erase FLASH sector
if (((processedProgressBar - 0x8000) % 0x20000) == 0) {
writeByte_GB(0x2800, 0x08);
@ -1471,7 +1471,7 @@ void writeSRAMFLASH_MBC6_GB() {
writeByte_GB(0x2000, currBank);
writeByte_GB(0x3000, currBank);
}
// Write to FLASH
while (romAddress <= 0x5FFF) {
writeByte_GB(0x2000, 0x01);

View File

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

View File

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

View File

@ -785,7 +785,7 @@ void getCartInfo_SNES() {
print_Msg(F(" ("));
print_Msg(numBanks);
println_Msg(F(" banks)"));
//print_Msg(F("Chips: "));
//println_Msg(romChips);
@ -1253,7 +1253,7 @@ boolean compare_checksum() {
char calcsumStr[5];
sprintf(calcsumStr, "%04X", calc_checksum(fileName, folder));
print_Msg(calcsumStr);
if (strcmp(calcsumStr, checksumStr) == 0) {
println_Msg(F(" -> OK"));
display_Update();