Welcome! Log In Create A New Profile

Advanced

Restarting an application

Posted by Plombo 
Restarting an application
January 26, 2010 05:57AM
I'm implementing POWER/RESET button support into my app right now. I've gotten the callbacks to behave nicely enough, but when I do the actual shutdown, it returns to the Homebrew Channel instead of restarting my application. Here is the line of code that does the reset:
SYS_ResetSystem(SYS_HOTRESET, 0, 0);
Is there any way to restart my application instead of returning to the Homebrew Channel?
Re: Restarting an application
January 26, 2010 06:55AM
If it's your app you should restart it yourself, not sure if there's any other way. If I'm understanding your question?

i.e.

int main()
{
appstart:
.....
....
while( apprunning )
{
.... do your stuff

}

if (bRestart) goto appstart;

}

Re: Restarting an application
January 26, 2010 10:03PM
Ugh, why goto? :p

You could attempt to load the file again (it is probably stored in argv[0], the filename, though I'm not sure)...
Re: Restarting an application
January 26, 2010 10:04PM
**headdesk**

Leave it to me to ask such an incredibly stupid question. Thank you for answering it.

EDIT: I just saw the latest reply. That sounds like a much better solution; I'll try that! Then I'll only have to revert to goto if I can't get the file loading to work.



Edited 1 time(s). Last edit at 01/26/2010 10:19PM by Plombo.
Re: Restarting an application
January 26, 2010 11:48PM
I tried system() and execl() with no luck (system just returns to the HBC and execl gives me a linking error for some reason), so...how do I reload an application file on a Wii? Sorry for the noobish question.
Re: Restarting an application
January 27, 2010 12:52AM
scanff already answered your question. Restart it yourself.

For example, in Wii Shooting Gallery, I restart the application by setting all of the variables back to zero and sending the player back to the main menu. Thus, you are given the illusion of restarting the application even though it was not actually restarted. This is an allegory of sorts for what scanff is telling you to do.



Edited 1 time(s). Last edit at 01/27/2010 12:53AM by Arikado.
Re: Restarting an application
May 24, 2010 04:09AM
I think the question he is posing is in relation to how to get the application to reload back to it's selection menu without having it go back to the HBC, and manually restart it all over again. For an example I'll use Tantrics emulators. In those you would start the app like all others from the HBC, and the app will load up with their rom selection menus, and other menu options. Selecting a rom begins gameplay, and when you quit out of a game in the emulator it merely goes back to the selection menu instead of going straight back to HBC. I think this is what his aim is, is to have his app not go back to the HBC every time upon quitting what he has running on it, and have it go back to the selection menu instead.

And yeah I realize this is an old post, but if it helps him then so be it. Better than a copy topic sprouting up asking the same thing when the answer will be available in one topic that exists already.



Edited 1 time(s). Last edit at 05/24/2010 04:11AM by nightwishfan1.
Re: Restarting an application
May 25, 2010 03:52AM
Nightwishfan1 is right.

Quote
Arikado
scanff already answered your question. Restart it yourself.

For example, in Wii Shooting Gallery, I restart the application by setting all of the variables back to zero and sending the player back to the main menu. Thus, you are given the illusion of restarting the application even though it was not actually restarted. This is an allegory of sorts for what scanff is telling you to do.

OpenBOR has several hundred variables. Setting them all to zero is beyond impractical.
Re: Restarting an application
May 25, 2010 04:16PM
yes but the only way to do that with a clean start (ie all settings back to their "factory default") is to set those variables back to their defaults manually.

There is no 'working' reset app line.

According to the wiki... your options are:

SYS_RESTART  /*!< Reboot the gamecube, force, if necessary, to boot the IPL menu. Cold reset is issued */
SYS_HOTRESET  /*!< Restart the application. Kind of softreset */
SYS_SHUTDOWN  /*!< Shutdown the thread system, card management system etc. Leave current thread running and return to caller */
SYS_RETURNTOMENU  /*!< Directly load the Wii Channels menu, without actually cold-resetting the system */
SYS_POWEROFF  /*!< Powers off the Wii, automatically choosing Standby or Idle mode depending on the user's configuration */
SYS_POWEROFF_STANDBY  /*!< Powers off the Wii to standby (red LED, WC24 off) mode. */
SYS_POWEROFF_IDLE  /*!< Powers off the Wii to idle (yellow LED, WC24 on) mode. */


which would lead you to believe that SYS_HOTRESET is what you would want... it didn't work for me either and i've found no one that it has worked for. My guess is it works great for GameCube stuff, but the translation over to the wii HB didn't work for that command.

several hundred variables isn't that much if you want this feature that bad ;D



Edited 2 time(s). Last edit at 05/25/2010 04:20PM by mdbrim.
Re: Restarting an application
May 25, 2010 05:57PM
I think you could just 'jump' to the real entry point of the executable.

I think:
_start();
Might work (_start is an label in the startup assembly code) This wil reset the stack and all variables to initial values, as the startup code handles all this.
Re: Restarting an application
May 26, 2010 12:24AM
Quote
Daid
I think you could just 'jump' to the real entry point of the executable.

I think:
_start();
Might work (_start is an label in the startup assembly code) This wil reset the stack and all variables to initial values, as the startup code handles all this.

I tried that, but it causes a code dump immediately after I press the Reset button on the Wii. Maybe I'm doing something wrong; here's my control code.

#include <ogc/lwp_watchdog.h>
#include <wiiuse/wpad.h>
#include <ogc/pad.h>
#include <ogc/system.h>
#include <stdio.h>
#include "wiiport.h"
#include "version.h"
#include "control.h"

#define	PAD_START			1
#define	MAX_PADS			4
#define	PAD_END				(MAX_BUTTONS*MAX_PADS)

void _start();

static int usejoy;
static int initialized;
static int hwbutton = 0;
static int using_gc[MAX_PADS];
static int lastkey[MAX_PADS];
static int rumbling[MAX_PADS];
static long long unsigned rumble_msec[MAX_PADS];
static long long unsigned time2rumble[MAX_PADS];

void poweroff()
{
	hwbutton = WII_SHUTDOWN;
}

void reset()
{
	hwbutton = WII_RESET;
}

void wiimote_poweroff(int playernum)
{
	poweroff();
}

// Resets or powers off the Wii if the corresponding buttons are pressed. 
// Resetting currently returns to the Homebrew Channel.
void respondToPowerReset()
{	
	printf(
		"OpenBoR %s, Compile Date: " __DATE__ "\n"
		"Presented by Team Senile.\n"
		"This Version is unofficial and based on the Senile Source Code.\n"
		"\n"
		"Special thanks to SEGA and SNK.\n\n",
		VERSION
	);
	
	if (hwbutton == WII_SHUTDOWN)     SYS_ResetSystem(SYS_POWEROFF, 0, 0);
	else if (hwbutton == WII_RESET)   _start(); // borExit(0);
}

static int flag_to_index(unsigned long flag)
{
	int index = 0;
	unsigned long bit = 1;
	while(!((bit<<index)&flag) && index<31) ++index;
	return index;
}

void control_exit()
{
	int i;
	for(i=0; i<MAX_PADS; i++)
	{
		rumbling = 0;
		rumble_msec = 0;
	}
	usejoy = 0;
}

void control_init(int joy_enable)
{
	int i;
	if(initialized) return;
	for(i=0; i<MAX_PADS; i++)
	{
		rumbling = 0;
		rumble_msec = 0;
	}
	usejoy = joy_enable;
	hwbutton = 0;
	PAD_Init();
	WPAD_Init();
	
	// set callbacks for power/reset buttons
	SYS_SetResetCallback(reset);
	SYS_SetPowerCallback(poweroff);
	WPAD_SetPowerButtonCallback(wiimote_poweroff);
	
	initialized = 1;
}



Edited 2 time(s). Last edit at 05/26/2010 12:32AM by Plombo.
Sorry, only registered users may post in this forum.

Click here to login