Welcome! Log In Create A New Profile

Advanced

Crashing on hardware reset

Posted by Sinman 
Crashing on hardware reset
January 20, 2009 02:43AM
My game has a reset() function that (re-)initializes all global variables, returns to the title and starts playing a looping ogg (stopping the previously playing loop if there was one). A normal button press on the Wiimote can call this function and everything works as expected. The title screen appears, all in-game variables are reset to their default values and the loop starts over from the beginning. But if I press the Wii's hardware reset button, the game freezes. I've been able to narrow the problem down to the PlayOgg() function from the oggplayer library. Commenting out that one line allows the game to reset from the hardware reset button. Any ideas on why this might be happening?

Here's the relevant code. Inside the main function before the while loop I have:

SYS_SetResetCallback(WiiResetPressed);

WiiResetPressed() is defined as:

void WiiResetPressed()
{
	reset();
	HW_BUTTON = 0;
}

And the relevant parts of reset():

if (StatusOgg() == OGG_STATUS_RUNNING) StopOgg();
// the following line freezes the game on harware reset
PlayOgg(mem_open((char *) loop_ogg, loop_ogg_size), 0, OGG_INFINITE_TIME);
Re: Crashing on hardware reset
January 20, 2009 02:49AM
IIRC, you're supposed to just set a flag in your reset callback and check for it later, because you're in interrupt context and things don't work properly.
Re: Crashing on hardware reset
January 20, 2009 02:57AM
BAM! Changing WiiResetPressed() back to just:

void WiiResetPressed()
{
	HW_BUTTON = SYS_RETURNTOMENU;
}


and adding the following to my main loop:

if (HW_BUTTON == SYS_RETURNTOMENU) 
{
	reset();
	HW_BUTTON = 0;
}

solved it. Thanks for the quick response!
Re: Crashing on hardware reset
January 20, 2009 03:01AM
Correction. It only works the first time you hit the hardware reset. I seem to have to reapply:

SYS_SetResetCallback(WiiResetPressed);

after calling reset(). I can pretend that makes sense.



Edited 1 time(s). Last edit at 01/20/2009 03:06AM by Sinman.
Sorry, only registered users may post in this forum.

Click here to login