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 34 forks source link

Fix RetroArch hirom hardware register mapping #52

Closed Raeven0 closed 3 years ago

Raeven0 commented 4 years ago

Accessing CGRAM or other non-WRAM, non-ROM addresses with a hirom ROM crashes the RetroArch device connection:

2020-06-11T22:19:28             WSServer - Debug: Device is  ADevice::READY
2020-06-11T22:19:28             WSServer - Debug: Executing request :  116 Created at QTime("22:19:28.379") - USB2SnesWS::GetAddress SD2Snes::SNES () ("F90000", "200") WSServer::RequestState::NEW for "MemoryViewer"
2020-06-11T22:19:28            RETROARCH - Debug: GetAddress  SD2Snes::SNES 16318464 512
2020-06-11T22:19:28             WSServer - Debug: Device Error "RetroArch 94dde6262e4f4fe4be027c47"

RetroArchDevice::addr_to_addr seems confused about how to handle this situation:

    if (addr >= 0xE00000)
    {
        if (!hasRomAccess)
            return addr - 0xE00000 + 0x20000;
        if (romType == LoROM)
            return addr - 0xE00000 + 0x700000;
        return lorom_sram_pc_to_snes(addr2 - 0xE00000);
    }
Skarsnik commented 4 years ago

I don't think we can access VRAM/CGRAM with RetroArch, the SRAM/ROM access is already kinda a hack. I will try to make it not crash thou.