Skarsnik / QUsb2snes

A Qt based webserver for usb2snes. Users: go check usb2snes.com
https://skarsnik.github.io/QUsb2snes/
GNU General Public License v3.0
52 stars 33 forks source link

SRAM read/write to RetroArch for LoROM not mapped correctly #85

Closed JamesDunne closed 2 years ago

JamesDunne commented 3 years ago

It seems SRAM read/write to RetroArch for LoROM doesn't work as expected.

My app code works writing directly to the SD2SNES and also to the SD2SNES via qusb2snes, but fails for RetroArch (1.9.0).

I'm attempting to read/write bank $71 but it doesn't have the intended effect and silently fails.

Granted, most people wouldn't run into this because their SRAMs are reasonably sized (according to the $FFC0 header). ALTTP defaults to 03 header value for the bank size. For my case, I doubled it to 06 so I could get into the $71 bank and avoid overwriting any game save data.

I'm able to work around the issue by sticking to bank $70 and offsets between $0000-7FFF.

    if (addr >= 0xE00000 && addr < 0xF70000)
    {
        if (!hasRomAccess)
            return addr - 0xE00000 + 0x20000;
        if (romType == LoROM)
            return addr - 0xE00000 + 0x700000;
        return lorom_sram_pc_to_snes(addr2 - 0xE00000);
    }

That romType == LoROM calculation doesn't look right. LoROM SRAM banks use the lower half of the banks $70-$7D with offsets $0000-7FFFF (and $F0-$FF banks). The upper half of those banks $8000-FFFF is ROM access.

Skarsnik commented 2 years ago

This is probably kinda fixed now.