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:
Â
Code: Select all
DISPCNT = (value & 0xFFF7);
UPDATE_REG(0x00, DISPCNT);
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:
Code: Select all
#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?
Â
Â
Proposal:
Code: Select all
#define DISPCNT ioMem[0x0000]
#define DISPSTAT ioMem[0x0004]
...