diff options
author | sanni <[email protected]> | 2022-08-03 12:14:32 +0200 |
---|---|---|
committer | sanni <[email protected]> | 2022-08-03 12:14:32 +0200 |
commit | f002e40aa694405897ca1ded1e416b21c03d2f06 (patch) | |
tree | 4787d2d43385c1aeb4e1ed9af1b0ed5f4e2d1bab /Cart_Reader | |
parent | 8e12c4ac3dc700487f573fdc149da888cabd8ed0 (diff) | |
download | cartreader-f002e40aa694405897ca1ded1e416b21c03d2f06.tar.gz cartreader-f002e40aa694405897ca1ded1e416b21c03d2f06.zip |
Add back option to dump headerless NES ROM
Diffstat (limited to 'Cart_Reader')
-rw-r--r-- | Cart_Reader/COLV.ino | 2 | ||||
-rw-r--r-- | Cart_Reader/Cart_Reader.ino | 70 | ||||
-rw-r--r-- | Cart_Reader/GB.ino | 2 | ||||
-rw-r--r-- | Cart_Reader/GBA.ino | 14 | ||||
-rw-r--r-- | Cart_Reader/INTV.ino | 2 | ||||
-rw-r--r-- | Cart_Reader/MD.ino | 2 | ||||
-rw-r--r-- | Cart_Reader/N64.ino | 4 | ||||
-rw-r--r-- | Cart_Reader/NES.ino | 126 | ||||
-rw-r--r-- | Cart_Reader/SMS.ino | 4 | ||||
-rw-r--r-- | Cart_Reader/SNES.ino | 2 |
10 files changed, 179 insertions, 49 deletions
diff --git a/Cart_Reader/COLV.ino b/Cart_Reader/COLV.ino index b8e9d85..25a6164 100644 --- a/Cart_Reader/COLV.ino +++ b/Cart_Reader/COLV.ino @@ -220,7 +220,7 @@ void readROM_COL() PORTH |= (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6); // 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("Press Button...")); diff --git a/Cart_Reader/Cart_Reader.ino b/Cart_Reader/Cart_Reader.ino index 6a4bc35..975a2b6 100644 --- a/Cart_Reader/Cart_Reader.ino +++ b/Cart_Reader/Cart_Reader.ino @@ -4,7 +4,7 @@ This project represents a community-driven effort to provide
an easy to build and easy to modify cartridge dumper.
- Date: 26.07.2022
+ Date: 03.08.2022
Version: 9.2 Alpha
SD lib: https://github.com/greiman/SdFat
@@ -552,6 +552,9 @@ void skip_line(FsFile* readfile) //Get line from file
void get_line(char* str_buf, FsFile* readfile, uint8_t maxi)
{
+ // Status LED on
+ statusLED(true);
+
int i = 0;
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
-boolean compareCRC(char* database, char* crcString, int offset) {
+boolean compareCRC(char* database, char* crcString, boolean renamerom, int offset) {
#ifdef no-intro
char crcStr[9];
if (crcString == 0) {
@@ -616,7 +619,7 @@ boolean compareCRC(char* database, char* crcString, int offset) { if (strcmp(crc_search, crcStr) == 0)
{
#ifdef enable_NES
- if (mode == mode_NES) {
+ if ((mode == mode_NES) && (offset != 0)) {
// Rewind to iNES Header
myFile.seekSet(myFile.curPosition() - 36);
@@ -640,7 +643,7 @@ boolean compareCRC(char* database, char* crcString, int offset) { //Write iNES header
#ifdef enable_NES
- if (mode == mode_NES) {
+ if ((mode == mode_NES) && (offset != 0)) {
// Write iNES header
sd.chdir(folder);
if (!myFile.open(fileName, O_RDWR)) {
@@ -653,14 +656,21 @@ boolean compareCRC(char* database, char* crcString, int offset) { }
#endif
print_Msg(F(" -> "));
- println_Msg(gamename);
+ display_Update();
- // Rename file to no-intro
- sd.chdir(folder);
- if (myFile.open(fileName, O_READ)) {
- myFile.rename(gamename);
- // Close the file:
- myFile.close();
+ if (renamerom) {
+ println_Msg(gamename);
+
+ // Rename file to no-intro
+ sd.chdir(folder);
+ if (myFile.open(fileName, O_READ)) {
+ myFile.rename(gamename);
+ // Close the file:
+ myFile.close();
+ }
+ }
+ else {
+ println_Msg("OK");
}
return 1;
break;
@@ -1634,6 +1644,10 @@ void setup() { SdFile::dateTimeCallback(dateTime);
#endif
+ // status LED ON
+ statusLED(true);
+
+ // Start menu system
startMenu();
}
@@ -1714,6 +1728,8 @@ void print_Error(const __FlashStringHelper * errorMessage, boolean forceReset) { }
void wait() {
+ // Switch status LED off
+ statusLED(false);
#if defined(enable_LCD)
wait_btn();
#elif defined (enable_OLED)
@@ -2229,6 +2245,38 @@ void blinkLED() { #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
*****************************************/
diff --git a/Cart_Reader/GB.ino b/Cart_Reader/GB.ino index a2a60a6..cc080c0 100644 --- a/Cart_Reader/GB.ino +++ b/Cart_Reader/GB.ino @@ -947,7 +947,7 @@ void compare_checksums_GB() { println_Msg(calcsumStr); print_Error(F("Checksum Error"), false); } - compareCRC("gb.txt", 0, 0); + compareCRC("gb.txt", 0, 1, 0); display_Update(); //go to root sd.chdir(); diff --git a/Cart_Reader/GBA.ino b/Cart_Reader/GBA.ino index e2ad9b6..6c00faa 100644 --- a/Cart_Reader/GBA.ino +++ b/Cart_Reader/GBA.ino @@ -128,7 +128,7 @@ void gbaMenu() { // Internal Checksum
compare_checksum_GBA();
// CRC32
- compareCRC("gba.txt", 0, 0);
+ compareCRC("gba.txt", 0, 1, 0);
#ifdef global_log
save_log();
#endif
@@ -350,7 +350,7 @@ void gbaMenu() { // 512K FLASH
idFlash_GBA();
resetFLASH_GBA();
-
+
print_Msg(F("Flashrom ID: "));
println_Msg(flashid);
println_Msg(F(""));
@@ -377,7 +377,7 @@ void gbaMenu() { wait();
display_Clear();
display_Update();
-
+
if (strcmp(flashid, "1F3D") == 0) { // Atmel
writeFLASH_GBA(1, 65536, 0, 1);
verifyFLASH_GBA(65536, 0);
@@ -400,7 +400,7 @@ void gbaMenu() { // 1M FLASH
idFlash_GBA();
resetFLASH_GBA();
-
+
print_Msg(F("Flashrom ID: "));
println_Msg(flashid);
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) {
//fill sdBuffer
myFile.read(sdBuffer, 512);
-
+
for (int c = 0; c < 512; c++) {
// Write command sequence
writeByteFlash_GBA(0x5555, 0xaa);
@@ -1686,7 +1686,7 @@ void writeFLASH_GBA (boolean browseFile, unsigned long flashSize, uint32_t pos, writeByteFlash_GBA(0x5555, 0xa0);
// Write current byte
writeByteFlash_GBA(currAddress + c, sdBuffer[c]);
-
+
// Wait
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) {
//fill sdBuffer
myFile.read(sdBuffer, 128);
-
+
// Write command sequence
writeByteFlash_GBA(0x5555, 0xaa);
writeByteFlash_GBA(0x2aaa, 0x55);
diff --git a/Cart_Reader/INTV.ino b/Cart_Reader/INTV.ino index 3a31eb3..322611e 100644 --- a/Cart_Reader/INTV.ino +++ b/Cart_Reader/INTV.ino @@ -417,7 +417,7 @@ void readROM_INTV() myFile.close(); // 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("Press Button...")); diff --git a/Cart_Reader/MD.ino b/Cart_Reader/MD.ino index 1ca9964..d770792 100644 --- a/Cart_Reader/MD.ino +++ b/Cart_Reader/MD.ino @@ -1308,7 +1308,7 @@ void readROM_MD() { }
// Calculate and compare CRC32 with no-intro
- compareCRC("md.txt", 0, 0);
+ compareCRC("md.txt", 0, 1, 0);
// More checksums
if (SnKmode >= 2) {
diff --git a/Cart_Reader/N64.ino b/Cart_Reader/N64.ino index 25864cd..f4c3a2f 100644 --- a/Cart_Reader/N64.ino +++ b/Cart_Reader/N64.ino @@ -3446,7 +3446,7 @@ redumpsamefolder: // Close the file: myFile.close(); - if (compareCRC("n64.txt", 0, 0)) { + if (compareCRC("n64.txt", 0, 1, 0)) { #else // dumping rom fast byte buffer[1024] = { 0 }; @@ -3539,7 +3539,7 @@ redumpsamefolder: sprintf(crcStr, "%08lX", ~oldcrc32); // Search n64.txt for crc - if (compareCRC("n64.txt", crcStr, 0)) { + if (compareCRC("n64.txt", crcStr, 1, 0)) { #endif unsigned long timeElapsed = (millis() - startTime) / 1000; // seconds print_Msg(F("Done (")); diff --git a/Cart_Reader/NES.ino b/Cart_Reader/NES.ino index cd6e373..5409857 100644 --- a/Cart_Reader/NES.ino +++ b/Cart_Reader/NES.ino @@ -196,23 +196,28 @@ int b = 0; *****************************************/ // NES start menu static const char nesMenuItem1[] PROGMEM = "Change Mapper"; -static const char nesMenuItem2[] PROGMEM = "Read Rom"; -static const char nesMenuItem3[] PROGMEM = "Read Sram"; -static const char nesMenuItem4[] PROGMEM = "Write Sram"; -static const char nesMenuItem5[] PROGMEM = "Read PRG/CHR"; +static const char nesMenuItem2[] PROGMEM = "Read iNES Rom"; +static const char nesMenuItem3[] PROGMEM = "Read PRG/CHR"; +static const char nesMenuItem4[] PROGMEM = "Read Sram"; +static const char nesMenuItem5[] PROGMEM = "Write Sram"; static const char nesMenuItem6[] PROGMEM = "Flash NESMaker"; static const char nesMenuItem7[] PROGMEM = "Reset"; static const char* const menuOptionsNES[] PROGMEM = {nesMenuItem1, nesMenuItem2, nesMenuItem3, nesMenuItem4, nesMenuItem5, nesMenuItem6, nesMenuItem7}; // NES chips menu -static const char nesChipsMenuItem1[] PROGMEM = "Read PRG"; -static const char nesChipsMenuItem2[] PROGMEM = "Read CHR"; -static const char nesChipsMenuItem3[] PROGMEM = "Back"; -static const char* const menuOptionsNESChips[] PROGMEM = {nesChipsMenuItem1, nesChipsMenuItem2, nesChipsMenuItem3}; +#ifndef no-intro +static const char nesChipsMenuItem1[] PROGMEM = "Read PRG & CHR"; +#else +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 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); unsigned char answer = question_box(F("NES CART READER"), menuOptions, 7, 0); @@ -257,8 +262,13 @@ void nesMenu() { #endif break; - // Read RAM + // Read single chip case 2: + nesChipMenu(); + break; + + // Read RAM + case 3: CreateROMFolderInSD(); readRAM(); resetROM(); @@ -269,7 +279,7 @@ void nesMenu() { break; // Write RAM - case 3: + case 4: writeRAM(); resetROM(); println_Msg(F("")); @@ -278,11 +288,6 @@ void nesMenu() { wait(); break; - // Read single chip - case 4: - nesChipMenu(); - break; - // Write FLASH case 5: if (mapper == 30) { @@ -309,13 +314,38 @@ void nesMenu() { void nesChipMenu() { // create menu with title "Select NES Chip" and 4 options to choose from - convertPgm(menuOptionsNESChips, 3); - unsigned char answer = question_box(F("Select NES Chip"), menuOptions, 3, 0); + convertPgm(menuOptionsNESChips, 4); + unsigned char answer = question_box(F("Select NES Chip"), menuOptions, 4, 0); // wait for user choice to come back from the question box menu switch (answer) { - // Read PRG + // Read combined PRG/CHR 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(); readPRG(false); resetROM(); @@ -326,7 +356,7 @@ void nesChipMenu() { break; // Read CHR - case 1: + case 2: CreateROMFolderInSD(); readCHR(false); resetROM(); @@ -337,7 +367,7 @@ void nesChipMenu() { break; // Return to Main Menu - case 2: + case 3: nesMenu(); wait(); break; @@ -626,7 +656,59 @@ void readRom_NES() { myFile.close(); // 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 diff --git a/Cart_Reader/SMS.ino b/Cart_Reader/SMS.ino index f74c5ae..29de181 100644 --- a/Cart_Reader/SMS.ino +++ b/Cart_Reader/SMS.ino @@ -67,10 +67,10 @@ void _smsMenu() { sd.chdir("/");
readROM_SMS();
if (retrode_mode && !retrode_mode_sms) {
- compareCRC("gg.txt", 0, 0);
+ compareCRC("gg.txt", 0, 1, 0);
}
else {
- compareCRC("sms.txt", 0, 0);
+ compareCRC("sms.txt", 0, 1, 0);
}
#ifdef global_log
save_log();
diff --git a/Cart_Reader/SNES.ino b/Cart_Reader/SNES.ino index 0a591fa..e63a76f 100644 --- a/Cart_Reader/SNES.ino +++ b/Cart_Reader/SNES.ino @@ -214,7 +214,7 @@ void snesMenu() { // Internal Checksum compare_checksum(); // CRC32 - compareCRC("snes.txt", 0, 0); + compareCRC("snes.txt", 0, 1, 0); #ifdef global_log save_log(); #endif |