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 > wait for keyypress not working, how do i do it?

#90778 - spinal_cord - Sun Jul 02, 2006 10:58 am

I have what I assume is a simple, rather silly problem. I'm trying to add a title screen to my (hardly started) game, but for some reason I cant get it wo wait for start to be pressed before continuing. Can someone tell me what im doing wrong?

Code:

void title(void)
{
   PA_LoadTiledBg(0, 3, title);   
   PA_LoadTiledBg(1, 3, title1);   
int st=0;
      while(st==0)
   {
      if(Pad.Newpress.Start){st=1;}
   }   
}


Is this a good way to do this? (appart from it not working).
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage

#90779 - Dark Knight ez - Sun Jul 02, 2006 11:13 am

I haven't worked with PALib, but I'll try to give a meaningful reply nevertheless.

Is there no function to refresh what keys are pressed?
In libnds there is a function called scanKeys() which needs to be called before you can check what new keypresses were done.
If something like that exists, your code should look like this:
Code:
int st=0;
while (st==0)
{
    scanKeys();
    if (Pad.Newpress.Start){st=1;}
}


I say this, because the only thing I can think of which goes "wrong" is that Pad.Newpress.Start is true from the start. It might need an update before using it.

#90781 - spinal_cord - Sun Jul 02, 2006 11:42 am

Thankyou very much, You were indeed correct, there is a PA_UpdatePad(); , weird how i don't need it in the rest of the game.

It all seems to be working fine now.
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage

#90782 - Dark Knight ez - Sun Jul 02, 2006 12:22 pm

As I understood it, some keypresses are not accessable from the main CPU (ARM9), but only from ARM7.
To get/update these keypresses, some communication is needed between ARM9 and ARM7.
The function PA_UpdatePad() takes care of that communication for you.

Apparently, the Start button is amongst the keypresses detected by ARM7. The other buttons you are using can probably be accessed by ARM9 - no need for such communication.

#90787 - spinal_cord - Sun Jul 02, 2006 1:21 pm

I also tried with up and select, they didnt work either. doesn't matter though, it works now, thats the main thing.
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage

#90839 - Mr Snowflake - Sun Jul 02, 2006 10:18 pm

Dark Knight ez wrote:

Apparently, the Start button is amongst the keypresses detected by ARM7. The other buttons you are using can probably be accessed by ARM9 - no need for such communication.
Only X Y and the touch screen are under ARM7's control
_________________
http://www.mrsnowflake.be

#90864 - Diffuse - Mon Jul 03, 2006 1:32 am

I might as well answer this one since im familiar with PALib.

The reason you don't need it anywhere else is because PA_WaitForVBL(); calls PA_UpdatePad();. Here's how I would do it:

While(!Pad.Newpress.Start) PA_WaitForVBL();

Alot simpler :) Good luck.
_________________
http://www.ndscene.net
Diffuse is Tepples #1 fan! w00t!