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 > Memory Adressing in C++

#57835 - thegamefreak0134 - Tue Oct 18, 2005 9:01 pm

OK, I understand every time someone tells me to change the first or second bit of a number. However, I don't understand how to do this in C. I noticed that in the header files I do have, some of the definitions point to memory locations in hex. Whats the deal here? Can someone fill me in on this issue? Normally I would use neither, but it's obviously required in GBA programming...
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]

#57843 - tepples - Tue Oct 18, 2005 9:33 pm

bit 0: 0x0001
bit 1: 0x0002
bit 2: 0x0004
bit 3: 0x0008
bit 4: 0x0010
bit 5: 0x0020
bit 6: 0x0040
(in general) bit N: (1 << N)

A with bit 0 set: A | 0x0001
A with bit 3 clear: A & ~0x0008
A with bit N flipped: A ^ (1 << N)
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.