Selecting [?] now forwards to manual mapper config for NES

This commit is contained in:
sanni 2022-10-07 10:15:18 +02:00
parent b7fa65a3de
commit 18b37c72d8
2 changed files with 304 additions and 274 deletions

View File

@ -4,7 +4,7 @@
This project represents a community-driven effort to provide This project represents a community-driven effort to provide
an easy to build and easy to modify cartridge dumper. an easy to build and easy to modify cartridge dumper.
Date: 06.10.2022 Date: 07.10.2022
Version: 10.0 Version: 10.0
SD lib: https://github.com/greiman/SdFat SD lib: https://github.com/greiman/SdFat
@ -737,18 +737,26 @@ byte starting_letter() {
line--; line--;
selection = 6; selection = 6;
} }
else if ((selection == 0) && (line == 0)) {
line = 3;
selection = 6;
}
else if (selection > 0) { else if (selection > 0) {
selection--; selection--;
} }
#if defined(enable_LCD) #if defined(enable_LCD)
display.setDrawColor(0); display.setDrawColor(0);
display.drawLine(0, 10 + (line + 1) * 16, 128, 10 + (line + 1) * 16); display.drawLine(0, 10 + 0 * 16, 128, 10 + 0 * 16);
display.drawLine(0, 10 + line * 16, 128, 10 + line * 16); display.drawLine(0, 10 + 1 * 16, 128, 10 + 1 * 16);
display.drawLine(0, 10 + 2 * 16, 128, 10 + 2 * 16);
display.drawLine(0, 10 + 3 * 16, 128, 10 + 3 * 16);
display.setDrawColor(1); display.setDrawColor(1);
display.drawLine(4 + selection * 16, 10 + line * 16, 9 + selection * 16, 10 + line * 16); display.drawLine(4 + selection * 16, 10 + line * 16, 9 + selection * 16, 10 + line * 16);
#elif defined(enable_OLED) #elif defined(enable_OLED)
display.drawLine(0, 10 + (line + 1) * 16, 128, 10 + (line + 1) * 16, BLACK); display.drawLine(0, 10 + 0 * 16, 128, 10 + 0 * 16, BLACK);
display.drawLine(0, 10 + line * 16, 128, 10 + line * 16, BLACK); display.drawLine(0, 10 + 1 * 16, 128, 10 + 1 * 16, BLACK);
display.drawLine(0, 10 + 2 * 16, 128, 10 + 2 * 16, BLACK);
display.drawLine(0, 10 + 3 * 16, 128, 10 + 3 * 16, BLACK);
display.drawLine(selection * 18, 10 + line * 16, 5 + selection * 18, 10 + line * 16, WHITE); display.drawLine(selection * 18, 10 + line * 16, 5 + selection * 18, 10 + line * 16, WHITE);
#endif #endif
display_Update(); display_Update();
@ -760,18 +768,26 @@ byte starting_letter() {
line++; line++;
selection = 0; selection = 0;
} }
else if ((selection == 6) && (line == 3)) {
line = 0;
selection = 0;
}
else if (selection < 6) { else if (selection < 6) {
selection++; selection++;
} }
#if defined(enable_LCD) #if defined(enable_LCD)
display.setDrawColor(0); display.setDrawColor(0);
display.drawLine(0, 10 + (line - 1) * 16, 128, 10 + (line - 1) * 16); display.drawLine(0, 10 + 0 * 16, 128, 10 + 0 * 16);
display.drawLine(0, 10 + line * 16, 128, 10 + line * 16); display.drawLine(0, 10 + 1 * 16, 128, 10 + 1 * 16);
display.drawLine(0, 10 + 2 * 16, 128, 10 + 2 * 16);
display.drawLine(0, 10 + 3 * 16, 128, 10 + 3 * 16);
display.setDrawColor(1); display.setDrawColor(1);
display.drawLine(4 + selection * 16, 10 + line * 16, 9 + selection * 16, 10 + line * 16); display.drawLine(4 + selection * 16, 10 + line * 16, 9 + selection * 16, 10 + line * 16);
#elif defined(enable_OLED) #elif defined(enable_OLED)
display.drawLine(0, 10 + (line - 1) * 16, 128, 10 + (line - 1) * 16, BLACK); display.drawLine(0, 10 + 0 * 16, 128, 10 + 0 * 16, BLACK);
display.drawLine(0, 10 + line * 16, 128, 10 + line * 16, BLACK); display.drawLine(0, 10 + 1 * 16, 128, 10 + 1 * 16, BLACK);
display.drawLine(0, 10 + 2 * 16, 128, 10 + 2 * 16, BLACK);
display.drawLine(0, 10 + 3 * 16, 128, 10 + 3 * 16, BLACK);
display.drawLine(selection * 18, 10 + line * 16, 5 + selection * 18, 10 + line * 16, WHITE); display.drawLine(selection * 18, 10 + line * 16, 5 + selection * 18, 10 + line * 16, WHITE);
#endif #endif
display_Update(); display_Update();

View File

@ -197,11 +197,11 @@ int b = 0;
Menus Menus
*****************************************/ *****************************************/
// NES start menu // NES start menu
static const char nesMenuItem1[] PROGMEM = "Change Mapper"; static const char nesMenuItem1[] PROGMEM = "Read iNES Rom";
static const char nesMenuItem2[] PROGMEM = "Read iNES Rom"; static const char nesMenuItem2[] PROGMEM = "Read PRG/CHR";
static const char nesMenuItem3[] PROGMEM = "Read PRG/CHR"; static const char nesMenuItem3[] PROGMEM = "Read Sram";
static const char nesMenuItem4[] PROGMEM = "Read Sram"; static const char nesMenuItem4[] PROGMEM = "Write Sram";
static const char nesMenuItem5[] PROGMEM = "Write Sram"; static const char nesMenuItem5[] PROGMEM = "Change Mapper";
static const char nesMenuItem6[] PROGMEM = "Flash NESMaker"; static const char nesMenuItem6[] PROGMEM = "Flash NESMaker";
static const char nesMenuItem7[] PROGMEM = "Reset"; static const char nesMenuItem7[] PROGMEM = "Reset";
static const char* const menuOptionsNES[] PROGMEM = {nesMenuItem1, nesMenuItem2, nesMenuItem3, nesMenuItem4, nesMenuItem5, nesMenuItem6, nesMenuItem7}; static const char* const menuOptionsNES[] PROGMEM = {nesMenuItem1, nesMenuItem2, nesMenuItem3, nesMenuItem4, nesMenuItem5, nesMenuItem6, nesMenuItem7};
@ -225,23 +225,8 @@ void nesMenu() {
// wait for user choice to come back from the question box menu // wait for user choice to come back from the question box menu
switch (answer) { switch (answer) {
// Change Mapper
case 0:
romName[0] = 'C';
romName[1] = 'A';
romName[2] = 'R';
romName[3] = 'T';
romName[4] = '\0';
setMapper();
checkMapperSize();
setPRGSize();
setCHRSize();
setRAMSize();
checkStatus_NES();
break;
// Read Rom // Read Rom
case 1: case 0:
#ifndef no-intro #ifndef no-intro
CartStart(); CartStart();
readPRG(false); readPRG(false);
@ -270,12 +255,12 @@ void nesMenu() {
break; break;
// Read single chip // Read single chip
case 2: case 1:
nesChipMenu(); nesChipMenu();
break; break;
// Read RAM // Read RAM
case 3: case 2:
CreateROMFolderInSD(); CreateROMFolderInSD();
readRAM(); readRAM();
resetROM(); resetROM();
@ -286,7 +271,7 @@ void nesMenu() {
break; break;
// Write RAM // Write RAM
case 4: case 3:
writeRAM(); writeRAM();
resetROM(); resetROM();
println_Msg(F("")); println_Msg(F(""));
@ -295,6 +280,21 @@ void nesMenu() {
wait(); wait();
break; break;
// Change Mapper
case 4:
romName[0] = 'C';
romName[1] = 'A';
romName[2] = 'R';
romName[3] = 'T';
romName[4] = '\0';
setMapper();
checkMapperSize();
setPRGSize();
setCHRSize();
setRAMSize();
checkStatus_NES();
break;
// Write FLASH // Write FLASH
case 5: case 5:
if (mapper == 30) { if (mapper == 30) {
@ -431,15 +431,16 @@ uint32_t uppow2(uint32_t n) {
return n; return n;
} }
void printPRG() { void printPRG(unsigned long myOffset) {
display_Clear(); display_Clear();
println_Msg(F("Printing PRG at 0x8000")); print_Msg(F("Printing PRG at "));
println_Msg(myOffset);
char myBuffer[3]; char myBuffer[3];
for (word currLine = 0; currLine < 512; currLine += 16) { for (word currLine = 0; currLine < 512; currLine += 16) {
for (byte currByte = 0; currByte < 16; currByte++) { for (byte currByte = 0; currByte < 16; currByte++) {
itoa (read_prg_byte(0x8000 + currLine + currByte), myBuffer, 16); itoa (read_prg_byte(myOffset + currLine + currByte), myBuffer, 16);
for (word i = 0; i < 2 - strlen(myBuffer); i++) { for (word i = 0; i < 2 - strlen(myBuffer); i++) {
print_Msg(F("0")); print_Msg(F("0"));
} }
@ -494,14 +495,14 @@ boolean getMapping() {
println_Msg(F("...")); println_Msg(F("..."));
display_Update(); display_Update();
// Filter out 0xFF checksum // Filter out all 0xFF checksums at 0x8000 and 0xE000
if (strcmp(crcStr, "BD7BC39F") == 0) { if ((strcmp(crcStr, "BD7BC39F") == 0) && (strcmp(crcStrMMC3, "BD7BC39F") == 0)) {
delay(500); delay(200);
println_Msg(F("")); println_Msg(F(""));
println_Msg(F("No data found at 0x8000")); println_Msg(F("No data found."));
println_Msg(F("Using manual selection")); println_Msg(F("Using manual selection"));
display_Update(); display_Update();
delay(1000); delay(500);
romName[0] = 'C'; romName[0] = 'C';
romName[1] = 'A'; romName[1] = 'A';
romName[2] = 'R'; romName[2] = 'R';
@ -548,8 +549,8 @@ boolean getMapping() {
//Skip every 3rd line //Skip every 3rd line
skip_line(&myFile); skip_line(&myFile);
//if checksum search successful set mapper and end search //if checksum search was successful set mapper and end search, also filter out 0xFF checksum
if ((strcmp(crc_search, crcStr) == 0) || (strcmp(crc_search, crcStrMMC3) == 0)) { if (((strcmp(crc_search, crcStr) == 0) || (strcmp(crc_search, crcStrMMC3) == 0)) && (strcmp(crc_search, "BD7BC39F") != 0)) {
// Rewind to start of entry // Rewind to start of entry
for (byte count_newline = 0; count_newline < 4; count_newline++) { for (byte count_newline = 0; count_newline < 4; count_newline++) {
@ -789,13 +790,16 @@ boolean getMapping() {
} }
} }
// File searched until end but nothing found // File searched until end but nothing found
if (strcmp(crc_search, crcStr) != 0) {
println_Msg(F("")); println_Msg(F(""));
println_Msg(F("CRC not found in database")); println_Msg(F("CRC not found in database"));
println_Msg(F("Using manual selection")); println_Msg(F("Using manual selection"));
display_Update(); display_Update();
delay(1000); delay(1000);
printPRG(); // Print debug
printPRG(0x8000);
printPRG(0xE000);
// Change ROM name to CART
romName[0] = 'C'; romName[0] = 'C';
romName[1] = 'A'; romName[1] = 'A';
romName[2] = 'R'; romName[2] = 'R';
@ -803,7 +807,6 @@ boolean getMapping() {
romName[4] = '\0'; romName[4] = '\0';
return 0; return 0;
} }
}
else { else {
println_Msg(F("Database file not found")); println_Msg(F("Database file not found"));
return 0; return 0;
@ -823,6 +826,16 @@ void selectMapping() {
// Select starting letter // Select starting letter
byte myLetter = starting_letter(); byte myLetter = starting_letter();
if (myLetter == 27) {
// Change Mapper
setMapper();
checkMapperSize();
setPRGSize();
setCHRSize();
setRAMSize();
checkStatus_NES();
}
else {
// Open database // Open database
if (myFile.open("nes.txt", O_READ)) { if (myFile.open("nes.txt", O_READ)) {
@ -1089,6 +1102,7 @@ void selectMapping() {
print_Error(F("Database file not found"), true); print_Error(F("Database file not found"), true);
} }
} }
}
void readRom_NES() { void readRom_NES() {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib