Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0x4000-0xffff (48 KB) ROMs do not work #99

Open
qiqitori opened this issue May 17, 2023 · 6 comments
Open

0x4000-0xffff (48 KB) ROMs do not work #99

qiqitori opened this issue May 17, 2023 · 6 comments

Comments

@qiqitori
Copy link

Hi, there are two reasonable ways to organize a normal (mapper-less) 48 KB ROM, 0x0000-0xbfff (this seems to work), and 0x4000-0xffff (this doesn't work). The current code assumes the former whenever it encounters a ROM larger than 32 KB.

The following patch seems to fix the issue with the particular ROM file I was trying to load, which works in openMSX and on a real MSX1; you can download it from https://blog.qiqitori.com/wp-content/uploads/2023/05/msx1_popsa_2.rom. This ROM loads in WebMSX, but it sees the ROM contents at 0xc000-0xffff as 0xff bytes. These 0xff bytes cause playback to appear to freeze, though it actually is just executing very long breaks. After a while playback may start from the beginning again because the counter loops to 0000 and eventually may get to the correct song start address.

It also doesn't break the only other normal mapper-less 48 KB ROM (Uchusen Gamma, which has the header at 0x4000) that I have on hand, but before applying it the patch should be tested for regressions with other 48 KB and 64 KB ROMs (e.g., 48 KB with header at 0x8000, 64 KB with headers at 0x4000, 0x8000).

diff --git a/src/main/msx/slots/SlotFormats.js b/src/main/msx/slots/SlotFormats.js
index c87d2d97..7cb4516f 100644
--- a/src/main/msx/slots/SlotFormats.js
+++ b/src/main/msx/slots/SlotFormats.js
@@ -389,7 +389,8 @@ wmsx.SlotFormats = {
                 || (rom.content[0x4000] === 65 && rom.content[0x4001] === 66))) return this.priority;
             // Any > 32K and <= 64K content, with the Cartridge identifier "AB" at 0x4000 or 0x8000
             if ((rom.content.length > 32768 && rom.content.length <= 65536)
-                && ((rom.content[0x4000] === 65 && rom.content[0x4001] === 66)
+                && ((rom.content[0] === 65 && rom.content[1] === 66)
+                || (rom.content[0x4000] === 65 && rom.content[0x4001] === 66)
                 || (rom.content[0x8000] === 65 && rom.content[0x8001] === 66))) return this.priority;
             return null;
         },
diff --git a/src/main/msx/slots/SlotNormal.js b/src/main/msx/slots/SlotNormal.js
index a2401bdb..4ce35d31 100644
--- a/src/main/msx/slots/SlotNormal.js
+++ b/src/main/msx/slots/SlotNormal.js
@@ -19,8 +19,8 @@ wmsx.SlotNormal = function(rom, format) {
         var startingPage = 0;
         mirrored = format === wmsx.SlotFormats.Mirrored ? true : format === wmsx.SlotFormats.NotMirrored ? false : null;       // Force mirroring?
 
-        // If > 32K (64K, 48K), force startingPage to 0
-        if (size > 0x8000)
+        // If > 48K (64K), force startingPage to 0
+        if (size > 0xc000)
             startingPage = 0;
         else {
             // <= 32K. Use position from info if present and mirror by default
@ppeccin
Copy link
Owner

ppeccin commented May 17, 2023 via email

@qiqitori
Copy link
Author

In order to use the stack, my program first copies 0xc000 to 0xefff from the ROM to RAM at init time. (It inefficiently switches pages for every byte.) It doesn't use the 0xc000-0xffff page of the ROM anymore after copying is finished.

@ppeccin
Copy link
Owner

ppeccin commented May 17, 2023 via email

@qiqitori
Copy link
Author

I must admit that I wasn't aware that it's more common practice to make 48 KB ROMs start at 0x0000. I'll consider adjusting my 48 KB programs to start at 0x0000.

Thank you for considering the patch! Feel free to close this issue when you no longer need it.

@NullPointerReference
Copy link

Shall we close the issue ?

@ppeccin
Copy link
Owner

ppeccin commented Dec 16, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants