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 > Need Help: Game crashes after level has loaded. [Solved]

#84144 - Linkiboy - Sat May 20, 2006 7:03 pm

Hi.

I have a problem. I have made a menu for my WIP game. However once I choose from the menu what level to play it just stops. The emulator doesn't crash and still performs normally. I have yet to test it on hardware.

Code:

while(1)
   {
   if(objective == 0)
   {   
   menuRun();
   }
   if(objective == 0)
   {
   if(Pad.Newpress.Start) {
   objective = 1;
   if(objective == 1)
   {
   objective = 2;
   dirtLoad();
   }
   }
   
   if (objective == 2)
   {
   dirtRun();
   }
   }
   }


That's part of the menu code that when altered caused the game to malfunction.

If you need more of my game source just ask.

Download my game here...

http://dslink.itsfun.be/lieroproject.nds - .nds
http://dslink.itsfun.be/lieroproject.ds.gba - ds.gba


Last edited by Linkiboy on Sun May 21, 2006 12:23 am; edited 1 time in total

#84153 - Valmond - Sat May 20, 2006 8:17 pm

Its a bit confusing, you could replace it with (I think) :

Code:

while(1)
{
 if(objective == 0)
 {
  menuRun();
  if(Pad.Newpress.Start)
  {
   objective = 2;
   dirtLoad();
   dirtRun();
  }
 }
}


so what happens is that menuRun is called constantly until Start is pressed,
Then dirtLoad is called once, and dirtRun once,, objective goes 2
and no more keypresses will be detected and the while
loop will just run forever...

Is this what you want ?
Or do you want dirtRun() to be called constantly after the keypress ?

\Valmond

#84165 - Linkiboy - Sat May 20, 2006 9:00 pm

dirtRun() needs to be constantly called, but dirtLoad() only needs to be called once.

So would this code work then?
Code:

while(1)
{
 if(objective == 0)
 {
  menuRun();
  if(Pad.Newpress.Start)
  {
   objective = 2;
   dirtLoad();
  }
 }
}

while(objective == 2)
{
   dirtRun();
}


Bah it doesn't... I'll try something else.

#84185 - Daniel[Nordigic] - Sat May 20, 2006 11:33 pm

This should work then...

Code:

while(1)
{
 if(objective == 0)
 {
  menuRun();
  if(Pad.Newpress.Start)
  {
   objective = 2;
   dirtLoad();
  }
 }

 if(objective == 2)
 {
    dirtRun();
 }
}

#84187 - Linkiboy - Sun May 21, 2006 12:23 am

Ok, apperently it wasn't only that piece of code, it was something with menuRun() as well.

But...

SOLVED!

#84220 - Daniel[Nordigic] - Sun May 21, 2006 10:31 am

Good to hear... Good luck! ^^