V30K: Add Momotaro Dentetsu Happy detection

and also the updated checksum calculation out of skaman's enhanced snes sketch
This commit is contained in:
sanni 2018-03-19 12:24:13 +01:00 committed by GitHub
parent 742e96151a
commit 2c2eb0e8bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 63 deletions

View File

@ -2,8 +2,8 @@
Cartridge Reader for Arduino Mega2560 Cartridge Reader for Arduino Mega2560
Author: sanni Author: sanni
Date: 2018-03-12 Date: 2018-03-19
Version: V30J Version: V30K
SD lib: https://github.com/greiman/SdFat SD lib: https://github.com/greiman/SdFat
LCD lib: https://github.com/adafruit/Adafruit_SSD1306 LCD lib: https://github.com/adafruit/Adafruit_SSD1306
@ -35,7 +35,7 @@
infinest - help with GB Memory cart infinest - help with GB Memory cart
**********************************************************************************/ **********************************************************************************/
char ver[5] = "V30J"; char ver[5] = "V30K";
/****************************************** /******************************************
Define Starting Point Define Starting Point

View File

@ -122,7 +122,7 @@ void setup_MD() {
DDRL = 0xFF; DDRL = 0xFF;
// Set Control Pins to Output RST(PH0) CS(PH3) WRH(PH4) WRL(PH5) OE(PH6) // Set Control Pins to Output RST(PH0) CS(PH3) WRH(PH4) WRL(PH5) OE(PH6)
DDRH |= (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6); DDRH |= (1 << 0) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
// Set TIME(PJ0) to Output // Set TIME(PJ0) to Output
DDRJ |= (1 << 0); DDRJ |= (1 << 0);

View File

@ -486,8 +486,10 @@ void getCartInfo_SNES() {
println_Msg(F("RAM GBoy")); println_Msg(F("RAM GBoy"));
else if (romChips == 246) else if (romChips == 246)
println_Msg(F("DSP2")); println_Msg(F("DSP2"));
else if (romChips == 245)
println_Msg(F("SPC RAM BATT"));
else if (romChips == 249) else if (romChips == 249)
println_Msg(F("SPC RAM BATT RTC")); println_Msg(F("SPC RAM RTC"));
else else
println_Msg(F("")); println_Msg(F(""));
@ -600,19 +602,20 @@ boolean checkcart_SNES() {
// Check RomChips // Check RomChips
romChips = readBank_SNES(0, 65494); romChips = readBank_SNES(0, 65494);
if (romChips == 69) if (romChips == 69) {
{
romSize = 48; romSize = 48;
numBanks = 96; numBanks = 96;
romType = HI; romType = HI;
} }
else if ((romChips == 249) && (romType == HI)) // SPC7110 else if ((romChips == 245) && (romType == HI)) {
{ romSize = 24;
numBanks = 48;
}
else if ((romChips == 249) && (romType == HI)) {
romSize = 40; romSize = 40;
numBanks = 80; numBanks = 80;
} }
else else {
{
// Check RomSize // Check RomSize
byte romSizeExp = readBank_SNES(0, 65495) - 7; byte romSizeExp = readBank_SNES(0, 65495) - 7;
romSize = 1; romSize = 1;
@ -747,31 +750,19 @@ unsigned int calc_checksum (char* fileName, char* folder) {
} }
calcChecksum += 0xF47C; // FFs from 0x60000-0x80000 calcChecksum += 0xF47C; // FFs from 0x60000-0x80000
} }
else if (calcFilesize == 12 || calcFilesize == 20) { else if ((calcFilesize == 10) || (calcFilesize == 12) || (calcFilesize == 20) || (calcFilesize == 24)) {
// Divide filesize by 8 to get number of 8Mbit chunks unsigned long calcBase = 0;
for (i = 0; i < (calcFilesize / 8); i++ ) { unsigned long calcMirror = 0;
// Add all the bits in the 8Mbit chunks byte calcMirrorCount = 0;
for (j = 0; j < (1048576 / 512); j++) { if (calcFilesize > 16)
myFile.read(sdBuffer, 512); calcBase = 2097152;
for (c = 0; c < 512; c++) { else
calcChecksumChunk += sdBuffer[c]; calcBase = 1048576;
} calcMirror = myFile.fileSize() - calcBase;
} calcMirrorCount = calcBase / calcMirror;
calcChecksum = calcChecksumChunk;
} // Momotarou Dentetsu Happy Fix 3MB (24Mbit)
calcChecksumChunk = 0; if ((calcFilesize == 24) && (romChips == 245)) {
// Add the 4Mbit rest
for (j = 0; j < (524288 / 512); j++) {
myFile.read(sdBuffer, 512);
for (c = 0; c < 512; c++) {
calcChecksumChunk += sdBuffer[c];
}
}
calcChecksum += 2 * calcChecksumChunk;
}
else if (calcFilesize == 24 || calcFilesize == 28) {
/* Momotarou Dentestu Happy Fix 3MB (24Mbit)
if ((calcFilesize == 24) && (romSizeExp = 0x0C)) {
for (i = 0; i < (myFile.fileSize() / 512); i++) { for (i = 0; i < (myFile.fileSize() / 512); i++) {
myFile.read(sdBuffer, 512); myFile.read(sdBuffer, 512);
for (c = 0; c < 512; c++) { for (c = 0; c < 512; c++) {
@ -780,28 +771,25 @@ unsigned int calc_checksum (char* fileName, char* folder) {
} }
calcChecksum = 2 * calcChecksumChunk; calcChecksum = 2 * calcChecksumChunk;
} }
else {*/ else {
for (i = 0; i < (calcFilesize / 16); i++ ) { // Base 8/16 Mbit chunk
// Add all the bits in the 16Mbit chunks for (j = 0; j < (calcBase / 512); j++) {
for (j = 0; j < (2097152 / 512); j++) {
myFile.read(sdBuffer, 512); myFile.read(sdBuffer, 512);
for (c = 0; c < 512; c++) { for (c = 0; c < 512; c++) {
calcChecksumChunk += sdBuffer[c]; calcChecksumChunk += sdBuffer[c];
} }
} }
calcChecksum = calcChecksumChunk; calcChecksum = calcChecksumChunk;
}
calcChecksumChunk = 0; calcChecksumChunk = 0;
// Add the mirrored chunk
// Add the 8Mbit rest for (j = 0; j < (calcMirror / 512); j++) {
for (j = 0; j < (1048576 / 512); j++) {
myFile.read(sdBuffer, 512); myFile.read(sdBuffer, 512);
for (c = 0; c < 512; c++) { for (c = 0; c < 512; c++) {
calcChecksumChunk += sdBuffer[c]; calcChecksumChunk += sdBuffer[c];
} }
} }
calcChecksum += 2 * calcChecksumChunk; calcChecksum += calcMirrorCount * calcChecksumChunk;
//} }
} }
else if ((calcFilesize == 40) && (romChips == 85)) { else if ((calcFilesize == 40) && (romChips == 85)) {
// Daikaijuu Monogatari 2 Fix 5MB (40Mbit) // Daikaijuu Monogatari 2 Fix 5MB (40Mbit)
@ -857,9 +845,11 @@ unsigned int calc_checksum (char* fileName, char* folder) {
sd.chdir(); sd.chdir();
return (calcChecksum); return (calcChecksum);
} }
// Else show error
else { else {
print_Error(F("DUMP ROM 1ST"), false); // Else show error
display.println(F("ERROR"));
display.println(F("DUMP ROM 1ST"));
display.display();
return 0; return 0;
} }
} }
@ -962,14 +952,6 @@ void readROM_SNES() {
} }
} }
// Dump High-type ROM
else if (((romType == HI) || (romType == SA) || (romType == EX)) && ((romChips != 69) && (romChips != 249))) {
println_Msg(F("Dumping HiRom..."));
display_Update();
readHiRomBanks( 192, numBanks + 192, &myFile );
}
// Dump SDD1 High-type ROM // Dump SDD1 High-type ROM
else if ((romType == HI) && (romChips == 69)) { else if ((romType == HI) && (romChips == 69)) {
println_Msg(F("Dumping SDD1 HiRom")); println_Msg(F("Dumping SDD1 HiRom"));
@ -1039,10 +1021,11 @@ void readROM_SNES() {
controlIn_SNES(); controlIn_SNES();
// 0xF00000-0xFFFFFF // 0xF00000-0xFFFFFF
println_Msg(F(" 4")); print_Msg(F(" 4"));
display_Update(); display_Update();
readHiRomBanks( 240, 256, &myFile ); readHiRomBanks( 240, 256, &myFile );
} }
println_Msg(F(""));
// Return mapping registers to initial settings... // Return mapping registers to initial settings...
dataOut(); dataOut();
@ -1056,6 +1039,14 @@ void readROM_SNES() {
} }
} }
// Dump standard High-type ROM
else if ((romType == HI) || (romType == SA) || (romType == EX)) {
println_Msg(F("Dumping HiRom..."));
display_Update();
readHiRomBanks( 192, numBanks + 192, &myFile );
}
// Close the file: // Close the file:
myFile.close(); myFile.close();
} }