Merge pull request #9 from Pickle/master

Changes needed to read Tengai Makyou Zero (SPC7110) based on skaman code
This commit is contained in:
sanni 2017-09-19 17:25:35 +02:00 committed by GitHub
commit 778c0adfbf
2 changed files with 119 additions and 35 deletions

View File

@ -47,7 +47,7 @@ char ver[5] = "V28E";
Define Input Define Input
******************************************/ ******************************************/
// If you are using the old version with only one button add // in front of the next line // If you are using the old version with only one button add // in front of the next line
#define enable_Button2 // #define enable_Button2
/****************************************** /******************************************
Define SD Speed Define SD Speed
@ -1338,4 +1338,4 @@ void loop() {
//****************************************** //******************************************
// End of File // End of File
//****************************************** //******************************************

View File

@ -344,6 +344,35 @@ byte readBank_SNES(byte myBank, word myAddress) {
return tempByte; return tempByte;
} }
void readLoRomBanks( unsigned int start, unsigned int total, SdFile *file)
{
byte buffer[512];
for (int currBank = start; currBank < total; currBank++) {
// Dump the bytes to SD 512B at a time
for (long currByte = 32768; currByte < 65536; currByte += 512) {
for (int c = 0; c < 512; c++) {
buffer[c] = readBank_SNES(currBank, currByte + c);
}
file->write(buffer, 512);
}
}
}
void readHiRomBanks( unsigned int start, unsigned int total, SdFile *file)
{
byte buffer[512];
for (int currBank = start; currBank < total; currBank++) {
for (long currByte = 0; currByte < 65536; currByte += 512) {
for (int c = 0; c < 512; c++) {
buffer[c] = readBank_SNES(currBank, currByte + c);
}
file->write(buffer, 512);
}
}
}
/****************************************** /******************************************
SNES ROM Functions SNES ROM Functions
******************************************/ ******************************************/
@ -425,6 +454,8 @@ 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 == 249)
println_Msg(F("SPC RAM BATT RTC"));
else else
println_Msg(F("")); println_Msg(F(""));
@ -433,7 +464,9 @@ void getCartInfo_SNES() {
println_Msg(F("Mbit")); println_Msg(F("Mbit"));
print_Msg(F("Banks: ")); print_Msg(F("Banks: "));
println_Msg(numBanks); print_Msg(numBanks);
print_Msg(F(" Chips: "));
println_Msg(romChips);
print_Msg(F("Sram Size: ")); print_Msg(F("Sram Size: "));
print_Msg(sramSize); print_Msg(sramSize);
@ -518,13 +551,15 @@ boolean checkcart_SNES() {
// Get Checksum as string // Get Checksum as string
sprintf(checksumStr, "%02X%02X", readBank_SNES(0, 65503), readBank_SNES(0, 65502)); sprintf(checksumStr, "%02X%02X", readBank_SNES(0, 65503), readBank_SNES(0, 65502));
// Check if ExHiROM romType = readBank_SNES(0, 0xFFD5);
if (readBank_SNES(0, 0xFFD5) == 0x35) { if (romType == 0x35) {
romType = EX; romType = EX; // Check if ExHiROM
}
else if (romType == 0x3A) {
romType = HI; // Check if SPC7110
} }
else { else {
// Check if LoROM or HiROM romType &= 1; // Must be LoROM or HiROM
romType = (readBank_SNES(0, 0xFFD5) & 1);
} }
// Check RomSpeed // Check RomSpeed
@ -539,6 +574,11 @@ boolean checkcart_SNES() {
numBanks = 96; numBanks = 96;
romType = HI; romType = HI;
} }
else if ((romChips == 249) && (romType == HI)) // SPC7110
{
romSize = 40;
numBanks = 80;
}
else else
{ {
// Check RomSize // Check RomSize
@ -864,32 +904,25 @@ void readROM_SNES() {
} }
} }
} }
//Dump Low-type ROM //Dump Low-type ROM
else if (romType == LO) { else if (romType == LO) {
// Read up to 96 banks starting at bank 0×00. // Read up to 96 banks starting at bank 0×00.
for (int currBank = 0; currBank < numBanks; currBank++) { readLoRomBanks( 0, numBanks, &myFile );
// Dump the bytes to SD 512B at a time
for (long currByte = 32768; currByte < 65536; currByte += 512) {
for (int c = 0; c < 512; c++) {
sdBuffer[c] = readBank_SNES(currBank, currByte + c);
}
myFile.write(sdBuffer, 512);
}
}
} }
// Dump High-type ROM // Dump High-type ROM
else if (((romType == HI) || (romType == SA) || (romType == EX)) && (romChips != 69)) { else if (((romType == HI) || (romType == SA) || (romType == EX)) && ((romChips != 69) && (romChips != 249))) {
for (int currBank = 192; currBank < (numBanks + 192); currBank++) { println_Msg(F("Dumping HiRom..."));
for (long currByte = 0; currByte < 65536; currByte += 512) { display_Update();
for (int c = 0; c < 512; c++) {
sdBuffer[c] = readBank_SNES(currBank, currByte + c); readHiRomBanks( 192, numBanks + 192, &myFile );
}
myFile.write(sdBuffer, 512);
}
}
} }
// 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"));
display_Update();
controlIn_SNES(); controlIn_SNES();
byte initialSOMap = readBank_SNES(0, 18439); byte initialSOMap = readBank_SNES(0, 18439);
@ -903,14 +936,7 @@ void readROM_SNES() {
dataIn(); dataIn();
controlIn_SNES(); controlIn_SNES();
for (int currBank = 240; currBank < 256; currBank++) { readHiRomBanks( 240, 256, &myFile );
for (long currByte = 0; currByte < 65536; currByte += 512) {
for (int c = 0; c < 512; c++) {
sdBuffer[c] = readBank_SNES(currBank, currByte + c);
}
myFile.write(sdBuffer, 512);
}
}
} }
dataOut(); dataOut();
@ -921,6 +947,64 @@ void readROM_SNES() {
dataIn(); dataIn();
controlIn_SNES(); controlIn_SNES();
} }
// Dump SPC7110 High-type ROM
else if ((romType == HI) && ((romChips == 245) || (romChips == 249))) {
println_Msg(F("Dumping SPC7110 HiRom"));
display_Update();
// 0xC00000-0xDFFFFF
print_Msg(F(" Part 1"));
display_Update();
readHiRomBanks( 192, 224, &myFile );
if (numBanks > 32) {
dataOut();
controlOut_SNES();
// Set 0x4834 to 0xFF
writeBank_SNES( 0, 0x4834, 0xFF );
dataIn();
controlIn_SNES();
// 0xE00000-0xEFFFFF
print_Msg(F(" 2"));
display_Update();
readHiRomBanks( 224, 240, &myFile );
if (numBanks > 48) {
// 0xF00000-0xFFFFFF
print_Msg(F(" 3"));
display_Update();
readHiRomBanks( 240, 256, &myFile );
dataOut();
controlOut_SNES();
// Set 0x4833 to 3
writeBank_SNES( 0, 0x4833, 3 );
dataIn();
controlIn_SNES();
// 0xF00000-0xFFFFFF
println_Msg(F(" 4"));
display_Update();
readHiRomBanks( 240, 256, &myFile );
}
// Return mapping registers to initial settings...
dataOut();
controlOut_SNES();
writeBank_SNES( 0, 0x4833, 2 );
writeBank_SNES( 0, 0x4834, 0 );
dataIn();
controlIn_SNES();
}
}
// Close the file: // Close the file:
myFile.close(); myFile.close();
} }
@ -1749,4 +1833,4 @@ boolean eraseSRAM (byte b) {
//****************************************** //******************************************
// End of File // End of File
//****************************************** //******************************************