Closed ids1024 closed 1 year ago
Hm, I guess writing IO_PORT_CONTROL
is unsafe since the linker might put something in this part of the ROM. But the other two should be safe, and reading is safe (but may get whatever data the ROM has at that location if IO_PORT_CONTROL
is 0).
Those addresses would be within the header region of the ROM, right? Right now we reserve 0xE0
bytes for the header, so all three of these locations should end up within there. Then I think it's safe to try a write, since there's definitely no code there.
Ah, I didn't check that. https://problemkaputt.de/gbatek.htm#gbacartridgeheader indicates the header is at 8000000h-80000BFh. So this is just after the header, but if the link script is reserving enough bytes then it isn't an issue.
https://github.com/rust-console/gba/blob/main/src/asm_runtime.rs#L34
Yeah right now this reserves the entire multi-boot header region as well. Some older versions of mGBA were getting confused when code showed up in that area and trying to run the rom as a multiboot rom. I can't imagine ever trying to reclaim that space because with 32mb of allowed rom it's not really important to squeeze every last byte out.
Can you add some docs in the source linking to where this IO port stuff is described? I'm not familiar with it myself. I'm assuming GBATEK has a section about it so just a link to that would suffice.
Testing in mGBA I'm having trouble getting rumble to work (with a controller and setting it in "game overrides"). But changing
IO_PORT_CONTROL
does change how readingIO_PORT_DATA
behaves, so it seems to work as expected.