VBA-M Forums

Full Version: Why are the IO registers stored redundantly?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In Globals.cpp, there is "u8 *ioMem = 0;", which should contain all the IO registers, but all the IO registers are declared again seperately in the same file.

I can see that whenever a register has to be changed, it looks like this:

DISPCNT = (value & 0xFFF7);
You can replace DISPCNT by any other register. Keep in mind 0x00 is the IO register's offset from 0x04000000 (the IO registers adress in GBA's memory map).

Here's the definition for UPDATE_REG:
#define UPDATE_REG(address, value)\
    WRITE16LE(((u16 *)&ioMem[address]),value);\
It writes the value to ioMem, certainly a redundancy.

Why is it done like that?
Couldn't we delete all the single registers and only use ioMem?

#define DISPCNT  ioMem[0x0000]
#define DISPSTAT ioMem[0x0004]
Reference URL's