Time to learn a bit about the SNES along with FE5. The next batch of these will probably all be about things that happen in FE5 on booting up.
Certain SNES games have “fast” ROM chips in them that can be accessed at 3.58MHz instead of 2.68MHz. To do so, these games have to set a bit in an I/O register while running, which is called
MEMSEL. This seems like something you’d only like to do once at startup unless you’re running some weird hardware with different access timings.
We’ll get back to that in a moment. We need to talk a bit about I/O registers. An I/O register is a way for the CPU to interact with other bits of hardware such as the picture processing unit (
PPU), audio processing unit (
APU), etc. These registers are implemented as places in RAM that the CPU can write to and read from.
It can be advantageous to keep a buffered copy of these I/O registers before they are actually written to. This buffer is copied to the I/O registers once per frame. The buffer is typically easier to write to/read from than the actual registers, thanks to quirks such as some I/O registers being read/write only or having sizes that are different from the data being fed to them, such as a 9-bit value being fed a byte at a time.
Some registers need to be written to immediately, so that typically happens at the same time as writing to the buffer. The buffer mostly serves as a way to keep track of what value the register holds, in the case of a write-only register.
It should be noted that not all I/O registers are buffered. Also, there are quite a lot of I/O registers that the SNES has, and they’re quite the pain.
Alright, back to
MEMSEL. FE5 keeps track of
MEMSEL in the I/O buffer as one of the registers that get a spot in the buffer because they’re read-only. If you’ve got a turbo button, you probably want it to activate immediately on being pressed, right?
There’s no reason for FE5 to ever change ROM access speed, however, and it never messes with it from what I can tell.
MEMSEL being buffered is probably the result of IntSys reusing code from other projects.