mGBA Forums
Accessing GB ROM Banks from Lua - Printable Version

+- mGBA Forums (https://forums.mgba.io)
+-- Forum: mGBA (https://forums.mgba.io/forumdisplay.php?fid=1)
+--- Forum: Development (https://forums.mgba.io/forumdisplay.php?fid=11)
+--- Thread: Accessing GB ROM Banks from Lua (/showthread.php?tid=5642)



Accessing GB ROM Banks from Lua - Zunawe - 11-23-2023

I'm writing a script meant to run with arbitrary games that can read data and send it over a socket. It doesn't look like there's a way to directly read ROM data for GB games. Only `memory.cart0`. So if the script is asked to return data in bank 4 or whatever it may not be addressable and the data is unknowable. Any chance I'm missing some obscure way to get at the ROM? I'm much less familiar with GB/GBC than GBA, so let me know if I'm mistaken about something.

I'm coming from the context of BizHawk which uses Gambatte and does allow access to the entire ROM from lua under the domain they label "ROM".


RE: Accessing GB ROM Banks from Lua - endrift - 11-23-2023

You can access further banks by indexing past 0x4000 in `memory.cart0`, e.g. bank 4 would start at 0x10000.


RE: Accessing GB ROM Banks from Lua - Zunawe - 11-24-2023

Ahh, I see. And it's `emu:read8` and similar which is reading off the bus. I had been using `emu:readRange` and using the base of the various memory domains as an offset.

Thanks for the response.