Skip to content
This repository was archived by the owner on Mar 16, 2026. It is now read-only.

Commit 78a3780

Browse files
committed
Fix writing SA1 SRAM
1 parent a28b450 commit 78a3780

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Cart_Reader/SNES.ino

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,7 @@ void writeSRAM(boolean browseFile) {
17601760
if (i2c_found) {
17611761
// Enable CPU Clock
17621762
clockgen.output_enable(SI5351_CLK1, 1);
1763+
clockgen.update_status();
17631764
}
17641765

17651766
// Direct writes to BW-RAM (SRAM) in banks 0x40-0x43 don't work
@@ -1781,26 +1782,26 @@ void writeSRAM(boolean browseFile) {
17811782

17821783
// Use $2224 (SNES) to map BW-RAM block to 0x6000-0x7FFF
17831784
// Use $2226 (SNES) to write enable the BW-RAM
1784-
byte firstByte = 0;
17851785
for (byte currBlock = 0; currBlock < lastBlock; currBlock++) {
17861786
// Set 0x2224 (SNES BMAPS) to map SRAM Block to 0x6000-0x7FFF
17871787
writeBank_SNES(0, 0x2224, currBlock);
17881788
// Set 0x2226 (SNES SBWE) to 0x80 Write Enable
17891789
writeBank_SNES(0, 0x2226, 0x80);
17901790
for (long currByte = 0x6000; currByte < 0x8000; currByte += 512) {
17911791
myFile.read(sdBuffer, 512);
1792-
if ((currBlock == 0) && (currByte == 0x6000)) {
1793-
firstByte = sdBuffer[0];
1794-
}
17951792
for (int c = 0; c < 512; c++) {
17961793
writeBank_SNES(0, currByte + c, sdBuffer[c]);
17971794
}
17981795
}
17991796
}
1800-
// Rewrite First Byte
1797+
// Rewrite first 16 bytes since they often get written incorrectly(fixes Super Bomberman Panic Bomber W), first byte needs to be written last(fixes PGA Tour 96)
1798+
myFile.seekSet(0);
1799+
myFile.read(sdBuffer, 16);
18011800
writeBank_SNES(0, 0x2224, 0);
18021801
writeBank_SNES(0, 0x2226, 0x80);
1803-
writeBank_SNES(0, 0x6000, firstByte);
1802+
for (int c = 15; c >= 0; c--) {
1803+
writeBank_SNES(0, 0x6000 + c, sdBuffer[c]);
1804+
}
18041805
if (i2c_found) {
18051806
// Disable CPU clock
18061807
clockgen.output_enable(SI5351_CLK1, 0);

0 commit comments

Comments
 (0)