Post Reply 
Thread Rating:
  • 38 Vote(s) - 3.34 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why are the IO registers stored redundantly?
Author Message
spacy51 Offline
VBA-M Developer

Posts: 451
Joined: Mar 2008
Post: #1
Why are the IO registers stored redundantly?

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]
(This post was last modified: 08-18-2009 06:22 AM by spacy51.)
08-18-2009 06:20 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 

Forum Jump:

User(s) browsing this thread: 1 Guest(s)

 Quick Theme: