mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-10 23:15:08 +01:00
Add back option to dump headerless NES ROM
This commit is contained in:
parent
8e12c4ac3d
commit
f002e40aa6
@ -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..."));
|
||||
|
@ -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
|
||||
*****************************************/
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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..."));
|
||||
|
@ -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) {
|
||||
|
@ -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 ("));
|
||||
|
@ -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
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user