ppeccin / javatari.js

Javatari - Online Atari 2600 Emulator
https://javatari.org
GNU Affero General Public License v3.0
215 stars 54 forks source link

bug in E7 cartridge handling #37

Open deater opened 1 year ago

deater commented 1 year ago

I found a bug while working on my "Myst" demake. It looks like the E7 cartridge handling code enables RAM when the proper memory location is accessed, but it never disables the RAM when ROM is swapped back in. This caused my game to crash after a few steps.

I have a patch that fixes things for me. I tried to attach it but github was giving me issues so I've included it inline here too. Thanks!

diff --git a/src/main/atari/cartridge/formats/Cartridge16K_E7.js b/src/main/atari/cartridge/formats/Cartridge16K_E7.js
index 2478deb..32faa19 100644
--- a/src/main/atari/cartridge/formats/Cartridge16K_E7.js
+++ b/src/main/atari/cartridge/formats/Cartridge16K_E7.js
@@ -41,8 +41,10 @@ jt.Cartridge16K_E7 = function(rom, format) {
         var maskedAddress = address & ADDRESS_MASK;
         // Check if address is within range of bank selection
         if (maskedAddress >= 0x0fe0 && maskedAddress <= 0x0feb) {
-            if (/* maskedAddress >= 0x0fe0 && */ maskedAddress <= 0x0fe6)          // Selectable ROM Slice
+            if (/* maskedAddress >= 0x0fe0 && */ maskedAddress <= 0x0fe6) {        // Selectable ROM Slice
                 bankAddressOffset = BANK_SIZE * (maskedAddress - 0x0fe0);
+                extraRAMSlice0Active = false;
+            }
             else if (maskedAddress == 0x0fe7)                                                              // Extra RAM Slice0
                 extraRAMSlice0Active = true;
             else if (/* maskedAddress >= 0x0fe8 && */ maskedAddress <= 0x0feb) // Extra RAM Slice1
ppeccin commented 1 year ago

Thanks for reporting the issue!