gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Reading "Write-Only" IO registers

#29054 - bertsnks - Wed Nov 10, 2004 10:12 pm

In short, is there some trick to read write-only IO registers such as the BG0_HOFS ?

#29056 - poslundc - Wed Nov 10, 2004 10:17 pm

Don't know if there is, but I can't think of a practical reason you'd want to that couldn't be duplicated just by keeping a copy of it in memory whenever you write the value to it.

Dan.

#29075 - tepples - Thu Nov 11, 2004 12:54 am

poslundc wrote:
I can't think of a practical reason you'd want to that couldn't be duplicated just by keeping a copy of it in memory whenever you write the value to it.

I can: going to a debugging screen and then restoring the state of the graphics subsystem. The only other option is to write a wrapper function around each register so that the debugger knows what to restore when hiding it.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#29080 - poslundc - Thu Nov 11, 2004 1:12 am

You win this round, tepples.

*shakes fist*

Dan.

#29090 - ampz - Thu Nov 11, 2004 7:22 am

Most of the write-only registers are updated frequently by the game... In many cases it would probably work even if you do not restore them to their original value.

#29091 - sgeos - Thu Nov 11, 2004 7:34 am

tepples wrote:
I can: going to a debugging screen and then restoring the state of the graphics subsystem. The only other option is to write a wrapper function around each register so that the debugger knows what to restore when hiding it.

There are other options:

Use an API. set_bgx_ofs(), get_bgx_ofs(). get_bgx_ofs() keeps a copy of the bg offset at the module level.

Pass in the offsets.
void debug(int p_x_ofs, int p_y_ofs, ...)

Give each display mode a unique display struct.

I'm sure that there are many other ways to deal with this "problem".

-Brendan

#29109 - tepples - Thu Nov 11, 2004 6:32 pm

sgeos wrote:
There are other options:

Use an API. set_bgx_ofs(), get_bgx_ofs(). get_bgx_ofs() keeps a copy of the bg offset at the module level.

That's exactly what I meant by a "wrapper function around each register".

Quote:
Pass in the offsets.
void debug(int p_x_ofs, int p_y_ofs, ...)

That can get hairy, especially given the number of write-only registers in the GBA.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.