Jump to content
Visual Boy Advance-M
Sign in to follow this  
spacy51

Why are the IO registers stored redundantly?

Recommended Posts

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);
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:

#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:

#define DISPCNT  ioMem[0x0000]
#define DISPSTAT ioMem[0x0004]
...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×