mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-23 21:19:16 +01:00
Remove auto selecting NES mapper config
This commit is contained in:
parent
38bc8a59e5
commit
49fdb0131e
@ -4,8 +4,8 @@
|
||||
This project represents a community-driven effort to provide
|
||||
an easy to build and easy to modify cartridge dumper.
|
||||
|
||||
Date: 10.09.2022
|
||||
Version: 9.7
|
||||
Date: 18.09.2022
|
||||
Version: 9.8
|
||||
|
||||
SD lib: https://github.com/greiman/SdFat
|
||||
OLED lib: https://github.com/adafruit/Adafruit_SSD1306
|
||||
@ -59,7 +59,7 @@
|
||||
|
||||
**********************************************************************************/
|
||||
|
||||
char ver[5] = "9.7";
|
||||
char ver[5] = "9.8";
|
||||
|
||||
//******************************************
|
||||
// !!! CHOOSE HARDWARE VERSION !!!
|
||||
@ -862,14 +862,9 @@ void mainMenu() {
|
||||
#ifdef no-intro
|
||||
if (getMapping() == 0) {
|
||||
selectMapping();
|
||||
checkStatus_NES(0);
|
||||
}
|
||||
else {
|
||||
checkStatus_NES(1);
|
||||
}
|
||||
#else
|
||||
checkStatus_NES(0);
|
||||
#endif
|
||||
checkStatus_NES();
|
||||
nesMenu();
|
||||
break;
|
||||
#endif
|
||||
|
@ -230,7 +230,7 @@ void nesMenu() {
|
||||
setPRGSize();
|
||||
setCHRSize();
|
||||
setRAMSize();
|
||||
checkStatus_NES(0);
|
||||
checkStatus_NES();
|
||||
break;
|
||||
|
||||
// Read Rom
|
||||
@ -493,8 +493,62 @@ boolean getMapping() {
|
||||
|
||||
//if checksum search successful set mapper and end search
|
||||
if (strcmp(crc_search, crcStr) == 0) {
|
||||
// Close the file:
|
||||
myFile.close();
|
||||
|
||||
// Rewind to start of entry
|
||||
for (byte count_newline = 0; count_newline < 4; count_newline++) {
|
||||
while (1) {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
}
|
||||
else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
|
||||
|
||||
// Display database
|
||||
while (myFile.available()) {
|
||||
display_Clear();
|
||||
|
||||
// Read game name
|
||||
#if defined(enable_OLED)
|
||||
get_line(gamename, &myFile, 42);
|
||||
#else
|
||||
get_line(gamename, &myFile, 96);
|
||||
#endif
|
||||
|
||||
// Read CRC32 checksum
|
||||
sprintf(checksumStr, "%c", myFile.read());
|
||||
for (byte i = 0; i < 7; i++) {
|
||||
sprintf(tempStr2, "%c", myFile.read());
|
||||
strcat(checksumStr, tempStr2);
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
|
||||
// Read CRC32 of first 512 bytes
|
||||
sprintf(crc_search, "%c", myFile.read());
|
||||
for (byte i = 0; i < 7; i++) {
|
||||
sprintf(tempStr2, "%c", myFile.read());
|
||||
strcat(crc_search, tempStr2);
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
|
||||
// Read iNES header
|
||||
get_line(iNES_STR, &myFile, 33);
|
||||
|
||||
// Skip every 3rd line
|
||||
skip_line(&myFile);
|
||||
|
||||
// Convert "4E4553" to (0x4E, 0x45, 0x53)
|
||||
byte iNES_BUF[2];
|
||||
@ -508,23 +562,6 @@ boolean getMapping() {
|
||||
mapper |= (iNES_HEADER[7] & 0xF0);
|
||||
mapper |= ((iNES_HEADER[8] & 0x0F) << 8);
|
||||
|
||||
// Check if it's a supported mapper
|
||||
boolean validMapper = 0;
|
||||
byte mapcount = (sizeof(mapsize) / sizeof(mapsize[0])) / 7;
|
||||
for (byte currMaplist = 0; currMaplist < mapcount; currMaplist++) {
|
||||
if (pgm_read_byte(mapsize + currMaplist * 7) == mapper)
|
||||
validMapper = 1;
|
||||
}
|
||||
|
||||
if (!validMapper) {
|
||||
println_Msg(F("Mapper not supported"));
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// Save Mapper
|
||||
EEPROM_writeAnything(7, mapper);
|
||||
|
||||
// PRG size
|
||||
if ((iNES_HEADER[9] & 0x0F) != 0x0F) {
|
||||
// simple notation
|
||||
@ -536,7 +573,6 @@ boolean getMapping() {
|
||||
}
|
||||
if (prgsize != 0)
|
||||
prgsize = (int(log(prgsize) / log(2)));
|
||||
EEPROM_writeAnything(8, prgsize);
|
||||
|
||||
// CHR size
|
||||
if ((iNES_HEADER[9] & 0xF0) != 0xF0) {
|
||||
@ -548,15 +584,110 @@ boolean getMapping() {
|
||||
}
|
||||
if (chrsize != 0)
|
||||
chrsize = (int(log(chrsize) / log(2)));
|
||||
EEPROM_writeAnything(9, chrsize);
|
||||
|
||||
// RAM size
|
||||
ramsize = ((iNES_HEADER[10] & 0xF0) ? (64 << ((iNES_HEADER[10] & 0xF0) >> 4)) : 0) / 4096; //*4
|
||||
if (ramsize != 0)
|
||||
ramsize = (int(log(ramsize) / log(2)));
|
||||
EEPROM_writeAnything(10, ramsize);
|
||||
|
||||
prg = (int_pow(2, prgsize)) * 16;
|
||||
if (chrsize == 0)
|
||||
chr = 0; // 0K
|
||||
else
|
||||
chr = (int_pow(2, chrsize)) * 4;
|
||||
if (ramsize == 0)
|
||||
ram = 0; // 0K
|
||||
else if (mapper == 82)
|
||||
ram = 5; // 5K
|
||||
else
|
||||
ram = (int_pow(2, ramsize)) * 4;
|
||||
|
||||
// Mapper Variants
|
||||
// Identify variant for use across multiple functions
|
||||
if (mapper == 4) { // Check for MMC6/MMC3
|
||||
checkMMC6();
|
||||
if (mmc6)
|
||||
ram = 1; // 1K
|
||||
}
|
||||
|
||||
println_Msg(gamename);
|
||||
print_Msg(F("MAPPER: "));
|
||||
println_Msg(mapper);
|
||||
print_Msg(F("PRG SIZE: "));
|
||||
print_Msg(prg);
|
||||
println_Msg(F("K"));
|
||||
print_Msg(F("CHR SIZE: "));
|
||||
print_Msg(chr);
|
||||
println_Msg(F("K"));
|
||||
print_Msg(F("RAM SIZE: "));
|
||||
if (mapper == 0) {
|
||||
print_Msg(ram / 4);
|
||||
println_Msg(F("K"));
|
||||
}
|
||||
else if ((mapper == 16) || (mapper == 80) || (mapper == 159)) {
|
||||
if (mapper == 16)
|
||||
print_Msg(ram * 32);
|
||||
else
|
||||
print_Msg(ram * 16);
|
||||
println_Msg(F("B"));
|
||||
}
|
||||
else if (mapper == 19) {
|
||||
if (ramsize == 2)
|
||||
println_Msg(F("128B"));
|
||||
else {
|
||||
print_Msg(ram);
|
||||
println_Msg(F("K"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
print_Msg(ram);
|
||||
println_Msg(F("K"));
|
||||
}
|
||||
#if defined(enable_OLED)
|
||||
println_Msg(F("Press left to Change"));
|
||||
println_Msg(F("and right to Select"));
|
||||
#elif defined(enable_LCD)
|
||||
println_Msg(F("Rotate to Change"));
|
||||
println_Msg(F("Press to Select"));
|
||||
#elif defined(SERIAL_MONITOR)
|
||||
println_Msg(F("U/D to Change"));
|
||||
println_Msg(F("Space to Select"));
|
||||
#endif
|
||||
display_Update();
|
||||
|
||||
int b = 0;
|
||||
while (1) {
|
||||
// Check button input
|
||||
b = checkButton();
|
||||
|
||||
// Next
|
||||
if (b == 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Previous
|
||||
else if (b == 2) {
|
||||
for (byte count_newline = 0; count_newline < 7; count_newline++) {
|
||||
while (1) {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
}
|
||||
else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
break;
|
||||
}
|
||||
|
||||
// Selection
|
||||
else if (b == 3) {
|
||||
// Get name
|
||||
byte myLength = 0;
|
||||
for (unsigned int i = 0; i < 20; i++) {
|
||||
@ -578,14 +709,19 @@ boolean getMapping() {
|
||||
romName[3] = 'T';
|
||||
}
|
||||
|
||||
// Print name
|
||||
display_Clear();
|
||||
println_Msg(romName);
|
||||
display_Update();
|
||||
// Save Mapper
|
||||
EEPROM_writeAnything(7, mapper);
|
||||
EEPROM_writeAnything(8, prgsize);
|
||||
EEPROM_writeAnything(9, chrsize);
|
||||
EEPROM_writeAnything(10, ramsize);
|
||||
myFile.close();
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// File searched until end but nothing found
|
||||
if (strcmp(crc_search, crcStr) != 0) {
|
||||
println_Msg(F("Not found"));
|
||||
@ -2548,7 +2684,7 @@ void checkMMC6() { // Detect MMC6 Carts - read PRG 0x3E00A ("STARTROPICS")
|
||||
mmc6 = true; // MMC6 Cart
|
||||
}
|
||||
|
||||
void checkStatus_NES(boolean clrscn) {
|
||||
void checkStatus_NES() {
|
||||
EEPROM_readAnything(7, mapper);
|
||||
EEPROM_readAnything(8, prgsize);
|
||||
EEPROM_readAnything(9, chrsize);
|
||||
@ -2575,12 +2711,10 @@ void checkStatus_NES(boolean clrscn) {
|
||||
else if (mapper == 30) // Check for Flashable/Non-Flashable
|
||||
NESmaker_ID(); // Flash ID
|
||||
|
||||
if (!clrscn) {
|
||||
display_Clear();
|
||||
println_Msg(F("NES CART READER"));
|
||||
println_Msg(F(""));
|
||||
println_Msg(F("CURRENT SETTINGS"));
|
||||
}
|
||||
println_Msg(F(""));
|
||||
print_Msg(F("MAPPER: "));
|
||||
println_Msg(mapper);
|
||||
|
Loading…
Reference in New Issue
Block a user