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 > warning problems

#66845 - radicalrandy - Fri Jan 13, 2006 9:13 pm

Hi I'm getting these warnings that say intov16 or floatof32 is deprecated. Anybody know what that means? I think that this is making it so that my input keys aren't calculating correctly.

Does anybody know how I can fix it so that these warnings don't appear no more, I have no clue as to what they mean.

#66848 - Joat - Fri Jan 13, 2006 9:24 pm

Dovoto mis-spelled the original type conversion macros, int o v16 instead int to v16, etc...

The warning has nothing to do with key presses not working, it just means that someone (me) has flagged those names as old (rather than removing them completly). To make the warnings go away, just add an extra t to the names, inttov16, floattof32, etc...

For your key problem (without actually knowing what the problem is):
1) Emulators are unreliable, if at all possible test on hardware instead (first rule of any DS related problem)
2) keysHeld and keysDown do two fairly different things.

keysHeld returns the buttons that are down as of right now (or for X,Y,and PENIRQ, down as of the last v-blank).

keysDown returns the keys that have been pushed down ****since the last time you called keysDown*** (updates some internal state), and should only ever be called once a frame (and stored into a variable, if you want to check for more than one newly pressed button).

i.e. for an effect that should only depend on the state, use keysHeld
amRunning = (keysHeld() & KEY_A) != 0;

but for an effect that requires a press, use keysDown:

uint16 keys = keysDown();
if ((keys & KEY_START)) gamePaused = !gamePaused;
if ((!gamePaused) && (keys & KEY_A != 0) && (playerNearDoor()))
openDoor();

if you had instead written:
if ((keysDown() & KEY_START)) gamePaused = !gamePaused;
if ((!gamePaused) && (keysDown() & KEY_A != 0) && (playerNearDoor()))
openDoor();

You could never open a door, ever, as you already reset the 'was key A *just* pressed' flag (so to speak), when you checked for the start button.


Hope that helps.
_________________
Joat
http://www.bottledlight.com

#66851 - radicalrandy - Fri Jan 13, 2006 9:32 pm

hell yes that does, thanks a bunch.