mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-30 00:14: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
|
// Change working dir to root
|
||||||
sd.chdir("/");
|
sd.chdir("/");
|
||||||
readSRAM();
|
readSRAM();
|
||||||
eraseSRAM(0x00);
|
eraseSRAM(0x0F);
|
||||||
eraseSRAM(0xFF);
|
eraseSRAM(0xF0);
|
||||||
writeSRAM(0);
|
writeSRAM(0);
|
||||||
unsigned long wrErrors = verifySRAM();
|
unsigned long wrErrors = verifySRAM();
|
||||||
if (wrErrors == 0) {
|
if (wrErrors == 0) {
|
||||||
@ -1655,9 +1655,20 @@ void writeSRAM(boolean browseFile) {
|
|||||||
// Writing SRAM on HiRom needs CS(PH3) to be high
|
// Writing SRAM on HiRom needs CS(PH3) to be high
|
||||||
PORTH |= (1 << 3);
|
PORTH |= (1 << 3);
|
||||||
// Sram size
|
// Sram size
|
||||||
long lastByte = (long(sramSize) * 128) + 0x6000;
|
long lastByte = (long(sramSize) * 128);
|
||||||
for (long currByte = 0x6000; currByte < lastByte; currByte++) {
|
if (lastByte > 0x2000) { // Large EX SRAM Fix
|
||||||
writeBank_SNES(0xB0, currByte, myFile.read());
|
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
|
// SA1
|
||||||
@ -1809,9 +1820,19 @@ void readSRAM() {
|
|||||||
// Dumping SRAM on HiRom needs CS(PH3) to be high
|
// Dumping SRAM on HiRom needs CS(PH3) to be high
|
||||||
PORTH |= (1 << 3);
|
PORTH |= (1 << 3);
|
||||||
// Sram size
|
// Sram size
|
||||||
long lastByte = (long(sramSize) * 128) + 0x6000;
|
long lastByte = (long(sramSize) * 128);
|
||||||
for (long currByte = 0x6000; currByte < lastByte; currByte++) {
|
if (lastByte > 0x2000) { // Large EX SRAM Fix
|
||||||
myFile.write(readBank_SNES(0xB0, currByte));
|
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) {
|
} else if (romType == SA) {
|
||||||
// Dumping SRAM on HiRom needs CS(PH3) to be high
|
// 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
|
// Dumping SRAM on HiRom needs CS(PH3) to be high
|
||||||
PORTH |= (1 << 3);
|
PORTH |= (1 << 3);
|
||||||
// Sram size
|
// Sram size
|
||||||
long lastByte = (long(sramSize) * 128) + 0x6000;
|
long lastByte = (long(sramSize) * 128);
|
||||||
for (long currByte = 0x6000; currByte < lastByte; currByte += 512) {
|
if (lastByte > 0x2000) { // Large EX SRAM Fix
|
||||||
//fill sdBuffer
|
sramBanks = lastByte / 0x2000;
|
||||||
myFile.read(sdBuffer, 512);
|
for (int currBank = 0xB0; currBank < sramBanks + 0xB0; currBank++) {
|
||||||
for (int c = 0; c < 512; c++) {
|
for (long currByte = 0x6000; currByte < 0x8000; currByte += 512) {
|
||||||
if ((readBank_SNES(0xB0, currByte + c)) != sdBuffer[c]) {
|
//fill sdBuffer
|
||||||
writeErrors++;
|
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) {
|
else if (romType == EX) {
|
||||||
// Writing SRAM on HiRom needs CS(PH3) to be high
|
// Writing SRAM on HiRom needs CS(PH3) to be high
|
||||||
PORTH |= (1 << 3);
|
PORTH |= (1 << 3);
|
||||||
// Sram size
|
/// Sram size
|
||||||
long lastByte = (long(sramSize) * 128) + 0x6000;
|
long lastByte = (long(sramSize) * 128);
|
||||||
for (long currByte = 0x6000; currByte < lastByte; currByte++) {
|
if (lastByte > 0x2000) { // Large EX SRAM Fix
|
||||||
writeBank_SNES(0xB0, currByte, b);
|
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
|
// SA1
|
||||||
@ -2281,11 +2329,25 @@ boolean eraseSRAM(byte b) {
|
|||||||
// Dumping SRAM on HiRom needs CS(PH3) to be high
|
// Dumping SRAM on HiRom needs CS(PH3) to be high
|
||||||
PORTH |= (1 << 3);
|
PORTH |= (1 << 3);
|
||||||
// Sram size
|
// Sram size
|
||||||
long lastByte = (long(sramSize) * 128) + 0x6000;
|
long lastByte = (long(sramSize) * 128);
|
||||||
for (long currByte = 0x6000; currByte < lastByte; currByte += 512) {
|
if (lastByte > 0x2000) { // Large EX SRAM Fix
|
||||||
for (int c = 0; c < 512; c++) {
|
sramBanks = lastByte / 0x2000;
|
||||||
if ((readBank_SNES(0xB0, currByte + c)) != b) {
|
for (int currBank = 0xB0; currBank < sramBanks + 0xB0; currBank++) {
|
||||||
writeErrors++;
|
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