Add back option to dump headerless NES ROM

This commit is contained in:
sanni 2022-08-03 12:14:32 +02:00
parent 8e12c4ac3d
commit f002e40aa6
10 changed files with 179 additions and 49 deletions

View File

@ -220,7 +220,7 @@ void readROM_COL()
PORTH |= (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6); PORTH |= (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
// Compare CRC32 to database and rename ROM if found // Compare CRC32 to database and rename ROM if found
compareCRC("colv.txt", 0, 0); compareCRC("colv.txt", 0, 1, 0);
println_Msg(F("")); println_Msg(F(""));
println_Msg(F("Press Button...")); println_Msg(F("Press Button..."));

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: 26.07.2022 Date: 03.08.2022
Version: 9.2 Alpha Version: 9.2 Alpha
SD lib: https://github.com/greiman/SdFat SD lib: https://github.com/greiman/SdFat
@ -552,6 +552,9 @@ void skip_line(FsFile* readfile)
//Get line from file //Get line from file
void get_line(char* str_buf, FsFile* readfile, uint8_t maxi) void get_line(char* str_buf, FsFile* readfile, uint8_t maxi)
{ {
// Status LED on
statusLED(true);
int i = 0; int i = 0;
while (readfile->available()) while (readfile->available())
@ -577,7 +580,7 @@ void get_line(char* str_buf, FsFile* readfile, uint8_t maxi)
} }
// Calculate CRC32 if needed and compare it to CRC read from database // Calculate CRC32 if needed and compare it to CRC read from database
boolean compareCRC(char* database, char* crcString, int offset) { boolean compareCRC(char* database, char* crcString, boolean renamerom, int offset) {
#ifdef no-intro #ifdef no-intro
char crcStr[9]; char crcStr[9];
if (crcString == 0) { if (crcString == 0) {
@ -616,7 +619,7 @@ boolean compareCRC(char* database, char* crcString, int offset) {
if (strcmp(crc_search, crcStr) == 0) if (strcmp(crc_search, crcStr) == 0)
{ {
#ifdef enable_NES #ifdef enable_NES
if (mode == mode_NES) { if ((mode == mode_NES) && (offset != 0)) {
// Rewind to iNES Header // Rewind to iNES Header
myFile.seekSet(myFile.curPosition() - 36); myFile.seekSet(myFile.curPosition() - 36);
@ -640,7 +643,7 @@ boolean compareCRC(char* database, char* crcString, int offset) {
//Write iNES header //Write iNES header
#ifdef enable_NES #ifdef enable_NES
if (mode == mode_NES) { if ((mode == mode_NES) && (offset != 0)) {
// Write iNES header // Write iNES header
sd.chdir(folder); sd.chdir(folder);
if (!myFile.open(fileName, O_RDWR)) { if (!myFile.open(fileName, O_RDWR)) {
@ -653,14 +656,21 @@ boolean compareCRC(char* database, char* crcString, int offset) {
} }
#endif #endif
print_Msg(F(" -> ")); print_Msg(F(" -> "));
println_Msg(gamename); display_Update();
// Rename file to no-intro if (renamerom) {
sd.chdir(folder); println_Msg(gamename);
if (myFile.open(fileName, O_READ)) {
myFile.rename(gamename); // Rename file to no-intro
// Close the file: sd.chdir(folder);
myFile.close(); if (myFile.open(fileName, O_READ)) {
myFile.rename(gamename);
// Close the file:
myFile.close();
}
}
else {
println_Msg("OK");
} }
return 1; return 1;
break; break;
@ -1634,6 +1644,10 @@ void setup() {
SdFile::dateTimeCallback(dateTime); SdFile::dateTimeCallback(dateTime);
#endif #endif
// status LED ON
statusLED(true);
// Start menu system
startMenu(); startMenu();
} }
@ -1714,6 +1728,8 @@ void print_Error(const __FlashStringHelper * errorMessage, boolean forceReset) {
} }
void wait() { void wait() {
// Switch status LED off
statusLED(false);
#if defined(enable_LCD) #if defined(enable_LCD)
wait_btn(); wait_btn();
#elif defined (enable_OLED) #elif defined (enable_OLED)
@ -2229,6 +2245,38 @@ void blinkLED() {
#endif #endif
} }
void statusLED(boolean on) {
#if defined(HW5)
if (!on)
PORTD |= (1 << 7);
else
PORTD &= ~(1 << 7);
/*
#elif defined(enable_OLED)
if (!on)
PORTB |= (1 << 4);
else
PORTB &= ~(1 << 4);
#elif defined(enable_LCD)
if (!on)
PORTE |= (1 << 1);
else
PORTE &= ~(1 << 1);
#elif defined(enable_serial)
if (!on) {
PORTB |= (1 << 4);
PORTB |= (1 << 7);
}
else {
PORTB &= ~(1 << 4);
PORTB &= ~(1 << 7);
}
*/
#endif
}
/****************************************** /******************************************
LCD Menu Module LCD Menu Module
*****************************************/ *****************************************/

View File

@ -947,7 +947,7 @@ void compare_checksums_GB() {
println_Msg(calcsumStr); println_Msg(calcsumStr);
print_Error(F("Checksum Error"), false); print_Error(F("Checksum Error"), false);
} }
compareCRC("gb.txt", 0, 0); compareCRC("gb.txt", 0, 1, 0);
display_Update(); display_Update();
//go to root //go to root
sd.chdir(); sd.chdir();

View File

@ -128,7 +128,7 @@ void gbaMenu() {
// Internal Checksum // Internal Checksum
compare_checksum_GBA(); compare_checksum_GBA();
// CRC32 // CRC32
compareCRC("gba.txt", 0, 0); compareCRC("gba.txt", 0, 1, 0);
#ifdef global_log #ifdef global_log
save_log(); save_log();
#endif #endif
@ -350,7 +350,7 @@ void gbaMenu() {
// 512K FLASH // 512K FLASH
idFlash_GBA(); idFlash_GBA();
resetFLASH_GBA(); resetFLASH_GBA();
print_Msg(F("Flashrom ID: ")); print_Msg(F("Flashrom ID: "));
println_Msg(flashid); println_Msg(flashid);
println_Msg(F("")); println_Msg(F(""));
@ -377,7 +377,7 @@ void gbaMenu() {
wait(); wait();
display_Clear(); display_Clear();
display_Update(); display_Update();
if (strcmp(flashid, "1F3D") == 0) { // Atmel if (strcmp(flashid, "1F3D") == 0) { // Atmel
writeFLASH_GBA(1, 65536, 0, 1); writeFLASH_GBA(1, 65536, 0, 1);
verifyFLASH_GBA(65536, 0); verifyFLASH_GBA(65536, 0);
@ -400,7 +400,7 @@ void gbaMenu() {
// 1M FLASH // 1M FLASH
idFlash_GBA(); idFlash_GBA();
resetFLASH_GBA(); resetFLASH_GBA();
print_Msg(F("Flashrom ID: ")); print_Msg(F("Flashrom ID: "));
println_Msg(flashid); println_Msg(flashid);
println_Msg(F("")); println_Msg(F(""));
@ -1678,7 +1678,7 @@ void writeFLASH_GBA (boolean browseFile, unsigned long flashSize, uint32_t pos,
for (unsigned long currAddress = 0; currAddress < flashSize; currAddress += 512) { for (unsigned long currAddress = 0; currAddress < flashSize; currAddress += 512) {
//fill sdBuffer //fill sdBuffer
myFile.read(sdBuffer, 512); myFile.read(sdBuffer, 512);
for (int c = 0; c < 512; c++) { for (int c = 0; c < 512; c++) {
// Write command sequence // Write command sequence
writeByteFlash_GBA(0x5555, 0xaa); writeByteFlash_GBA(0x5555, 0xaa);
@ -1686,7 +1686,7 @@ void writeFLASH_GBA (boolean browseFile, unsigned long flashSize, uint32_t pos,
writeByteFlash_GBA(0x5555, 0xa0); writeByteFlash_GBA(0x5555, 0xa0);
// Write current byte // Write current byte
writeByteFlash_GBA(currAddress + c, sdBuffer[c]); writeByteFlash_GBA(currAddress + c, sdBuffer[c]);
// Wait // Wait
busyCheck_GBA(c); busyCheck_GBA(c);
} }
@ -1696,7 +1696,7 @@ void writeFLASH_GBA (boolean browseFile, unsigned long flashSize, uint32_t pos,
for (unsigned long currAddress = 0; currAddress < flashSize; currAddress += 128) { for (unsigned long currAddress = 0; currAddress < flashSize; currAddress += 128) {
//fill sdBuffer //fill sdBuffer
myFile.read(sdBuffer, 128); myFile.read(sdBuffer, 128);
// Write command sequence // Write command sequence
writeByteFlash_GBA(0x5555, 0xaa); writeByteFlash_GBA(0x5555, 0xaa);
writeByteFlash_GBA(0x2aaa, 0x55); writeByteFlash_GBA(0x2aaa, 0x55);

View File

@ -417,7 +417,7 @@ void readROM_INTV()
myFile.close(); myFile.close();
// Compare CRC32 to database and rename ROM if found // Compare CRC32 to database and rename ROM if found
compareCRC("intv.txt", 0, 0); compareCRC("intv.txt", 0, 1, 0);
println_Msg(F("")); println_Msg(F(""));
println_Msg(F("Press Button...")); println_Msg(F("Press Button..."));

View File

@ -1308,7 +1308,7 @@ void readROM_MD() {
} }
// Calculate and compare CRC32 with no-intro // Calculate and compare CRC32 with no-intro
compareCRC("md.txt", 0, 0); compareCRC("md.txt", 0, 1, 0);
// More checksums // More checksums
if (SnKmode >= 2) { if (SnKmode >= 2) {

View File

@ -3446,7 +3446,7 @@ redumpsamefolder:
// Close the file: // Close the file:
myFile.close(); myFile.close();
if (compareCRC("n64.txt", 0, 0)) { if (compareCRC("n64.txt", 0, 1, 0)) {
#else #else
// dumping rom fast // dumping rom fast
byte buffer[1024] = { 0 }; byte buffer[1024] = { 0 };
@ -3539,7 +3539,7 @@ redumpsamefolder:
sprintf(crcStr, "%08lX", ~oldcrc32); sprintf(crcStr, "%08lX", ~oldcrc32);
// Search n64.txt for crc // Search n64.txt for crc
if (compareCRC("n64.txt", crcStr, 0)) { if (compareCRC("n64.txt", crcStr, 1, 0)) {
#endif #endif
unsigned long timeElapsed = (millis() - startTime) / 1000; // seconds unsigned long timeElapsed = (millis() - startTime) / 1000; // seconds
print_Msg(F("Done (")); print_Msg(F("Done ("));

View File

@ -196,23 +196,28 @@ int b = 0;
*****************************************/ *****************************************/
// NES start menu // NES start menu
static const char nesMenuItem1[] PROGMEM = "Change Mapper"; static const char nesMenuItem1[] PROGMEM = "Change Mapper";
static const char nesMenuItem2[] PROGMEM = "Read Rom"; static const char nesMenuItem2[] PROGMEM = "Read iNES Rom";
static const char nesMenuItem3[] PROGMEM = "Read Sram"; static const char nesMenuItem3[] PROGMEM = "Read PRG/CHR";
static const char nesMenuItem4[] PROGMEM = "Write Sram"; static const char nesMenuItem4[] PROGMEM = "Read Sram";
static const char nesMenuItem5[] PROGMEM = "Read PRG/CHR"; static const char nesMenuItem5[] PROGMEM = "Write Sram";
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};
// NES chips menu // NES chips menu
static const char nesChipsMenuItem1[] PROGMEM = "Read PRG"; #ifndef no-intro
static const char nesChipsMenuItem2[] PROGMEM = "Read CHR"; static const char nesChipsMenuItem1[] PROGMEM = "Read PRG & CHR";
static const char nesChipsMenuItem3[] PROGMEM = "Back"; #else
static const char* const menuOptionsNESChips[] PROGMEM = {nesChipsMenuItem1, nesChipsMenuItem2, nesChipsMenuItem3}; static const char nesChipsMenuItem1[] PROGMEM = "Combined PRG+CHR";
#endif
static const char nesChipsMenuItem2[] PROGMEM = "Read only PRG";
static const char nesChipsMenuItem3[] PROGMEM = "Read only CHR";
static const char nesChipsMenuItem4[] PROGMEM = "Back";
static const char* const menuOptionsNESChips[] PROGMEM = {nesChipsMenuItem1, nesChipsMenuItem2, nesChipsMenuItem3, nesChipsMenuItem4};
// NES start menu // NES start menu
void nesMenu() { void nesMenu() {
// create menu with title "NES CART READER" and 5 options to choose from // create menu with title "NES CART READER" and 7 options to choose from
convertPgm(menuOptionsNES, 7); convertPgm(menuOptionsNES, 7);
unsigned char answer = question_box(F("NES CART READER"), menuOptions, 7, 0); unsigned char answer = question_box(F("NES CART READER"), menuOptions, 7, 0);
@ -257,8 +262,13 @@ void nesMenu() {
#endif #endif
break; break;
// Read RAM // Read single chip
case 2: case 2:
nesChipMenu();
break;
// Read RAM
case 3:
CreateROMFolderInSD(); CreateROMFolderInSD();
readRAM(); readRAM();
resetROM(); resetROM();
@ -269,7 +279,7 @@ void nesMenu() {
break; break;
// Write RAM // Write RAM
case 3: case 4:
writeRAM(); writeRAM();
resetROM(); resetROM();
println_Msg(F("")); println_Msg(F(""));
@ -278,11 +288,6 @@ void nesMenu() {
wait(); wait();
break; break;
// Read single chip
case 4:
nesChipMenu();
break;
// Write FLASH // Write FLASH
case 5: case 5:
if (mapper == 30) { if (mapper == 30) {
@ -309,13 +314,38 @@ void nesMenu() {
void nesChipMenu() { void nesChipMenu() {
// create menu with title "Select NES Chip" and 4 options to choose from // create menu with title "Select NES Chip" and 4 options to choose from
convertPgm(menuOptionsNESChips, 3); convertPgm(menuOptionsNESChips, 4);
unsigned char answer = question_box(F("Select NES Chip"), menuOptions, 3, 0); unsigned char answer = question_box(F("Select NES Chip"), menuOptions, 4, 0);
// 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) {
// Read PRG // Read combined PRG/CHR
case 0: case 0:
#ifndef no-intro
CreateROMFolderInSD();
readPRG(false);
resetROM();
CreateROMFolderInSD();
readCHR(false);
resetROM();
#else
display_Clear();
// Change working dir to root
sd.chdir("/");
readRaw_NES();
println_Msg(F(""));
println_Msg(F("Press Button..."));
#ifdef global_log
save_log();
#endif
#endif
display_Update();
wait();
break;
// Read PRG
case 1:
CreateROMFolderInSD(); CreateROMFolderInSD();
readPRG(false); readPRG(false);
resetROM(); resetROM();
@ -326,7 +356,7 @@ void nesChipMenu() {
break; break;
// Read CHR // Read CHR
case 1: case 2:
CreateROMFolderInSD(); CreateROMFolderInSD();
readCHR(false); readCHR(false);
resetROM(); resetROM();
@ -337,7 +367,7 @@ void nesChipMenu() {
break; break;
// Return to Main Menu // Return to Main Menu
case 2: case 3:
nesMenu(); nesMenu();
wait(); wait();
break; break;
@ -626,7 +656,59 @@ void readRom_NES() {
myFile.close(); myFile.close();
// Compare CRC32 with database // Compare CRC32 with database
compareCRC("nes.txt", 0, 16); compareCRC("nes.txt", 0, 1, 16);
}
void readRaw_NES() {
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName);
strcat(fileName, ".bin");
// create a new folder
EEPROM_readAnything(0, foldern);
sprintf(folder, "NES/ROM/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear();
print_Msg(F("Saving to "));
print_Msg(folder);
println_Msg(F("/..."));
display_Update();
// write new folder number back to eeprom
foldern = foldern + 1;
EEPROM_writeAnything(0, foldern);
// Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(F("SD Error"), true);
}
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)(prgsize * 16 * 1024 + chrsize * 4 * 1024);
draw_progressbar(0, totalProgressBar);
//Write PRG
readPRG(true);
// update progress bar
processedProgressBar += prgsize * 16 * 1024;
draw_progressbar(processedProgressBar, totalProgressBar);
//Write CHR
readCHR(true);
// update progress bar
processedProgressBar += chrsize * 4 * 1024;
draw_progressbar(processedProgressBar, totalProgressBar);
// Close the file:
myFile.close();
// Compare CRC32 with database
compareCRC("nes.txt", 0, 0, 0);
} }
#endif #endif

View File

@ -67,10 +67,10 @@ void _smsMenu() {
sd.chdir("/"); sd.chdir("/");
readROM_SMS(); readROM_SMS();
if (retrode_mode && !retrode_mode_sms) { if (retrode_mode && !retrode_mode_sms) {
compareCRC("gg.txt", 0, 0); compareCRC("gg.txt", 0, 1, 0);
} }
else { else {
compareCRC("sms.txt", 0, 0); compareCRC("sms.txt", 0, 1, 0);
} }
#ifdef global_log #ifdef global_log
save_log(); save_log();

View File

@ -214,7 +214,7 @@ void snesMenu() {
// Internal Checksum // Internal Checksum
compare_checksum(); compare_checksum();
// CRC32 // CRC32
compareCRC("snes.txt", 0, 0); compareCRC("snes.txt", 0, 1, 0);
#ifdef global_log #ifdef global_log
save_log(); save_log();
#endif #endif