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.

DS development > Switching register bits

#108338 - Rajveer - Tue Nov 07, 2006 9:27 pm

Hi guys. I've been learning the "theory" behind switching/manipulating bits in bytes and registers. I'm trying to change bit 16 and bit 17 of the register GFX_TEX_FORMAT but I dont seem to be doing it correctly. This is what I'm trying:

Code:
u32 texFormat = GL_TEXTURE_WRAP_S | GL_TEXTURE_WRAP_T;
GFX_TEX_FORMAT = texFormat;


I'm trying this before I use a glBindTexture command so that the texture I use after this command will repeat on the polygon. Can you show me what I'm doing wrong?

Cheers

#108341 - thegamefreak0134 - Tue Nov 07, 2006 10:18 pm

You\'re going to need to include the original register in there somewhere. You need to do something like:

Code:
 
GFX_TEX_FORMAT = (GFX_TEX_FORMAT | texFormat);


If you just set the value, you set those two bits, but then zero out all the bits around them, which is never too good. Or (|) is your friend. If you notice, this is the same method used when setting up your video modes. You simply or the bits that need to be done, and the names are defines telling the compiler which bits those are.

-gamefreak
_________________
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]

#108345 - Rajveer - Tue Nov 07, 2006 10:34 pm

Cheers for the replying. This register in particular cannot be read, only written to, so I have to set everyting that I want to set in one go without calling it. Thing is, my method wont work, is it correct?

#108346 - Sausage Boy - Tue Nov 07, 2006 10:43 pm

What you want to do is add "| GL_TEXTURE_WRAP_S | GL_TEXTURE_WRAP_T " to the 7th argument of glTexImage2D (second last one).
_________________
"no offense, but this is the gayest game ever"

#108347 - sajiimori - Tue Nov 07, 2006 11:06 pm

I don't understand Sausage Boy's suggestion, but my suggestion is to arrange your code so you can write whole values to the register. If nothing else, you could save the last value that was written in a separate variable for later use.

#108397 - Sausage Boy - Wed Nov 08, 2006 2:22 pm

glTexImage2D is a libnds function that stores a value to write to GFX_TEX_FORMAT.
_________________
"no offense, but this is the gayest game ever"

#108421 - thegamefreak0134 - Wed Nov 08, 2006 5:43 pm

So either use that function, or keep a local copy of the register, twiddle your bits, and send it out.
_________________
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]

#108425 - Sausage Boy - Wed Nov 08, 2006 6:23 pm

You did realize that that is exactly what glTexImage2D does, right?
_________________
"no offense, but this is the gayest game ever"