bsnes-emu / bsnes

bsnes is a Super Nintendo (SNES) emulator focused on performance, features, and ease of use.
Other
1.67k stars 154 forks source link

SuperFX 8MB ROM not working with manifest #190

Open Yoshimaster96 opened 3 years ago

Yoshimaster96 commented 3 years ago

For some reason extending a SuperFX ROM (Yoshi's Island in my case) to 8MB and extending SRAM to 128KB (by setting $FFBD to $07 and $FFD7 to $0D, then adding 6MB of extra bytes to the end), then using the following manifest file, causes bsnes to not load the game:

game
  region: NTSC
  board: GSU8MB-RAM
    memory
      type: ROM
      size: 0x800000
      content: Program
    memory
      type: RAM
      size: 0x20000
      content: Save

board: GSU8MB-RAM
  processor architecture=GSU
    map address=00-3f,80-bf:3000-34ff
    memory type=ROM size=0x800000 content=Program
      map address=00-3f:8000-ffff mask=0x8000
      map address=40-5f:0000-ffff
      map address=80-bf:8000-ffff mask=0x8000 base=0x200000
      map address=c0-ff:0000-ffff base=0x400000
    memory type=RAM size=0x20000 content=Save
      map address=00-3f,80-bf:6000-7fff size=0x2000
      map address=70-71:0000-ffff

Strangely, extending the ROM to 4MB (by setting $FFD7 to $0C instead and only adding 2MB of bytes at the end), then using this other manifest, works just fine:

game
  region: NTSC
  board: GSU4MB-RAM
    memory
      type: ROM
      size: 0x400000
      content: Program
    memory
      type: RAM
      size: 0x20000
      content: Save

board: GSU4MB-RAM
  processor architecture=GSU
    map address=00-3f,80-bf:3000-34ff
    memory type=ROM size=0x400000 content=Program
      map address=00-3f:8000-ffff mask=0x8000
      map address=40-5f:0000-ffff
      map address=80-bf:8000-ffff mask=0x8000 base=0x200000
      map address=c0-df:0000-ffff base=0x200000
    memory type=RAM size=0x20000 content=Save
      map address=00-3f,80-bf:6000-7fff size=0x2000
      map address=70-71,f0-f1:0000-ffff

I'm not sure what the issue is, whether it's a bug with bsnes or if my manifests are malformed in some way. Any help would be appreciated, thanks!

Screwtapello commented 3 years ago

If you're using a manifest, all the $FFB0-$FFDF values are ignored.

I'm not sure what the actual physical limits of the SuperFX are, though.

Yoshimaster96 commented 3 years ago

Hm, okay. Though I do explicitly state the size in the manifest, so it should work nonetheless.

The SuperFX can only address the low half of memory (it doesn't have an A23 line). However, additional ROM data can be supplied for the CPU's exclusive use in the upper half, allowing for up to 8MB of ROM data (only the first 2MB of which can the SuperFX actually address).

[EDIT]

Does bsnes hardcode a limit of some kind? Or maybe the address decoding is bugged somehow?

Strangely enough, bsnes-plus actually does manage to run the 8MB game as well as the 4MB game properly (though the manifest has to be in a different format). Here are the manifests for those if you wanna take a look at them:

8MB version:

<?xml version='1.0' encoding='UTF-8'?>
<cartridge region='NTSC'>
    <superfx revision='2'>
        <rom size='800000'>
            <map mode='linear' address='00-3f:8000-ffff'/>
            <map mode='linear' address='40-5f:0000-ffff'/>
            <map mode='linear' address='80-bf:8000-ffff' offset='200000'/>
            <map mode='linear' address='c0-ff:0000-ffff' offset='400000'/>
        </rom>
        <ram size='20000'>
            <map mode='linear' address='00-3f:6000-7fff' size='2000'/>
            <map mode='linear' address='80-bf:6000-7fff' size='2000'/>
            <map mode='linear' address='70-71:0000-ffff'/>
        </ram>
        <mmio>
            <map address='00-3f:3000-34ff'/>
            <map address='80-bf:3000-34ff'/>
        </mmio>
    </superfx>
</cartridge>

4MB version:

<?xml version='1.0' encoding='UTF-8'?>
<cartridge region='NTSC'>
    <superfx revision='2'>
        <rom size='400000'>
            <map mode='linear' address='00-3f:8000-ffff'/>
            <map mode='linear' address='40-5f:0000-ffff'/>
            <map mode='linear' address='80-bf:8000-ffff' offset='200000'/>
            <map mode='linear' address='c0-df:0000-ffff' offset='200000'/>
        </rom>
        <ram size='20000'>
            <map mode='linear' address='00-3f:6000-7fff' size='2000'/>
            <map mode='linear' address='80-bf:6000-7fff' size='2000'/>
            <map mode='linear' address='70-71:0000-ffff'/>
            <map mode='linear' address='f0-f1:0000-ffff'/>
        </ram>
        <mmio>
            <map address='00-3f:3000-34ff'/>
            <map address='80-bf:3000-34ff'/>
        </mmio>
    </superfx>
</cartridge>

You may have noticed that the way I'm implementing 4MB mode is to basically mirror what is done for 2MB mode but for the upper half of memory as well. While 8MB more or less follows the specifications which say that 80-bf:8000-ffff and c0-ff:0000-ffff should be used.

So IDK if I should instead have c0-ff:0000-ffff be the full 4MB ROM for 4MB mode instead, or do it using mirroring like I'm doing now. There were never any SuperFX games which used more than 2MB, so I could do whatever, but I'm just curious which one makes the most sense to you guys. Dunno if this would be the best place to ask though.