gbadev
Game Boy Advance homebrew development forum
Member
Joined:
Posts: 1

I was following Tonc and noticed it defines the display register like this:
#define REG_DISPCNT *((volatile u32*)(MEM_IO+0x0000))

But the documentation I've seen online describes it as a 16-bit register.
Can anyone explain the discrepancy and recommend how I should handle it in my own projects?

Administrator
avatar
Joined:
Posts: 54

I'd probably recommend to treat DISPCNT as 16-bit in your own projects.

As far as I know, Tonc treats DISPCNT as 32-bit under the belief that the space next to it is unused. This isn't correct, those 16-bits are actually the green-swap register. However, green-swap isn't all that useful and writing zeroes to it is harmless, so there's nothing really wrong with what Tonc's doing. If you did want to toggle green-swap for any reason you could just treat it as an extra field of DISPCNT.

I did once wonder if having DISPCNT as 32-bit could be performance-related but my current understanding is that it wouldn't be any faster... So I don't really know why Tonc does this. Maybe cearn thought it would throw people off if there was an unexplained gap?