mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-26 14:34:15 +01:00
Fix reading Bahamut Lagoon English Translation SRAM (thx to Cowboyjunkie)
https://github.com/sanni/cartreader/issues/917
This commit is contained in:
parent
fd2c332ea9
commit
d1b1c88af0
@ -384,8 +384,8 @@ void snesMenu() {
|
||||
// Change working dir to root
|
||||
sd.chdir("/");
|
||||
readSRAM();
|
||||
eraseSRAM(0x00);
|
||||
eraseSRAM(0xFF);
|
||||
eraseSRAM(0x0F);
|
||||
eraseSRAM(0xF0);
|
||||
writeSRAM(0);
|
||||
unsigned long wrErrors = verifySRAM();
|
||||
if (wrErrors == 0) {
|
||||
@ -1655,9 +1655,20 @@ void writeSRAM(boolean browseFile) {
|
||||
// Writing SRAM on HiRom needs CS(PH3) to be high
|
||||
PORTH |= (1 << 3);
|
||||
// Sram size
|
||||
long lastByte = (long(sramSize) * 128) + 0x6000;
|
||||
for (long currByte = 0x6000; currByte < lastByte; currByte++) {
|
||||
writeBank_SNES(0xB0, currByte, myFile.read());
|
||||
long lastByte = (long(sramSize) * 128);
|
||||
if (lastByte > 0x2000) { // Large EX SRAM Fix
|
||||
sramBanks = lastByte / 0x2000;
|
||||
for (int currBank = 0xB0; currBank < sramBanks + 0xB0; currBank++) {
|
||||
for (long currByte = 0x6000; currByte < 0x8000; currByte++) {
|
||||
writeBank_SNES(currBank, currByte, myFile.read());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lastByte += 0x6000;
|
||||
// Write to sram bank
|
||||
for (long currByte = 0x6000; currByte < lastByte; currByte++) {
|
||||
writeBank_SNES(0xB0, currByte, myFile.read());
|
||||
}
|
||||
}
|
||||
}
|
||||
// SA1
|
||||
@ -1809,9 +1820,19 @@ void readSRAM() {
|
||||
// Dumping SRAM on HiRom needs CS(PH3) to be high
|
||||
PORTH |= (1 << 3);
|
||||
// Sram size
|
||||
long lastByte = (long(sramSize) * 128) + 0x6000;
|
||||
for (long currByte = 0x6000; currByte < lastByte; currByte++) {
|
||||
myFile.write(readBank_SNES(0xB0, currByte));
|
||||
long lastByte = (long(sramSize) * 128);
|
||||
if (lastByte > 0x2000) { // Large EX SRAM Fix
|
||||
sramBanks = lastByte / 0x2000;
|
||||
for (int currBank = 0xB0; currBank < sramBanks + 0xB0; currBank++) {
|
||||
for (long currByte = 0x6000; currByte < 0x8000; currByte++) {
|
||||
myFile.write(readBank_SNES(currBank, currByte));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lastByte += 0x6000;
|
||||
for (long currByte = 0x6000; currByte < lastByte; currByte++) {
|
||||
myFile.write(readBank_SNES(0xB0, currByte));
|
||||
}
|
||||
}
|
||||
} else if (romType == SA) {
|
||||
// Dumping SRAM on HiRom needs CS(PH3) to be high
|
||||
@ -1964,13 +1985,29 @@ unsigned long verifySRAM() {
|
||||
// Dumping SRAM on HiRom needs CS(PH3) to be high
|
||||
PORTH |= (1 << 3);
|
||||
// Sram size
|
||||
long lastByte = (long(sramSize) * 128) + 0x6000;
|
||||
for (long currByte = 0x6000; currByte < lastByte; currByte += 512) {
|
||||
//fill sdBuffer
|
||||
myFile.read(sdBuffer, 512);
|
||||
for (int c = 0; c < 512; c++) {
|
||||
if ((readBank_SNES(0xB0, currByte + c)) != sdBuffer[c]) {
|
||||
writeErrors++;
|
||||
long lastByte = (long(sramSize) * 128);
|
||||
if (lastByte > 0x2000) { // Large EX SRAM Fix
|
||||
sramBanks = lastByte / 0x2000;
|
||||
for (int currBank = 0xB0; currBank < sramBanks + 0xB0; currBank++) {
|
||||
for (long currByte = 0x6000; currByte < 0x8000; currByte += 512) {
|
||||
//fill sdBuffer
|
||||
myFile.read(sdBuffer, 512);
|
||||
for (int c = 0; c < 512; c++) {
|
||||
if ((readBank_SNES(currBank, currByte + c)) != sdBuffer[c]) {
|
||||
writeErrors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lastByte += 0x6000;
|
||||
for (long currByte = 0x6000; currByte < lastByte; currByte += 512) {
|
||||
//fill sdBuffer
|
||||
myFile.read(sdBuffer, 512);
|
||||
for (int c = 0; c < 512; c++) {
|
||||
if ((readBank_SNES(0xB0, currByte + c)) != sdBuffer[c]) {
|
||||
writeErrors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2121,10 +2158,21 @@ boolean eraseSRAM(byte b) {
|
||||
else if (romType == EX) {
|
||||
// Writing SRAM on HiRom needs CS(PH3) to be high
|
||||
PORTH |= (1 << 3);
|
||||
// Sram size
|
||||
long lastByte = (long(sramSize) * 128) + 0x6000;
|
||||
for (long currByte = 0x6000; currByte < lastByte; currByte++) {
|
||||
writeBank_SNES(0xB0, currByte, b);
|
||||
/// Sram size
|
||||
long lastByte = (long(sramSize) * 128);
|
||||
if (lastByte > 0x2000) { // Large EX SRAM Fix
|
||||
sramBanks = lastByte / 0x2000;
|
||||
for (int currBank = 0xB0; currBank < sramBanks + 0xB0; currBank++) {
|
||||
for (long currByte = 0x6000; currByte < 0x8000; currByte++) {
|
||||
writeBank_SNES(currBank, currByte, b);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lastByte += 0x6000;
|
||||
// Write to sram bank
|
||||
for (long currByte = 0x6000; currByte < lastByte; currByte++) {
|
||||
writeBank_SNES(0xB0, currByte, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
// SA1
|
||||
@ -2281,11 +2329,25 @@ boolean eraseSRAM(byte b) {
|
||||
// Dumping SRAM on HiRom needs CS(PH3) to be high
|
||||
PORTH |= (1 << 3);
|
||||
// Sram size
|
||||
long lastByte = (long(sramSize) * 128) + 0x6000;
|
||||
for (long currByte = 0x6000; currByte < lastByte; currByte += 512) {
|
||||
for (int c = 0; c < 512; c++) {
|
||||
if ((readBank_SNES(0xB0, currByte + c)) != b) {
|
||||
writeErrors++;
|
||||
long lastByte = (long(sramSize) * 128);
|
||||
if (lastByte > 0x2000) { // Large EX SRAM Fix
|
||||
sramBanks = lastByte / 0x2000;
|
||||
for (int currBank = 0xB0; currBank < sramBanks + 0xB0; currBank++) {
|
||||
for (long currByte = 0x6000; currByte < 0x8000; currByte += 512) {
|
||||
for (int c = 0; c < 512; c++) {
|
||||
if ((readBank_SNES(currBank, currByte + c)) != b) {
|
||||
writeErrors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lastByte += 0x6000;
|
||||
for (long currByte = 0x6000; currByte < lastByte; currByte += 512) {
|
||||
for (int c = 0; c < 512; c++) {
|
||||
if ((readBank_SNES(0xB0, currByte + c)) != b) {
|
||||
writeErrors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user