Line 1:
Line 1:
−
Following a comment on the contribute talk page there is now a Standard Code page for pieces of code that could be useful to anyone
+
#REDIRECT [[Developer tips]]
−
<br>
−
such as return to launcher, rebooting e.t.c
−
−
If you are adding to this page please add your code in a source box then put a description of how it works.
−
Do note that at least some of this code is going to be deprecated once that the normal APIs is done.
−
−
=Code=
−
−
==Return to Loader==
−
−
<source lang="c">
−
−
typedef void (*Loader_Entry)(void);
−
Loader_Entry loader = (Loader_Entry)0x80001800;
−
−
</source>
−
−
Whenever you want to return to loader just call
−
−
<source lang="c">
−
−
loader();
−
−
</source>
−
−
==Reboot==
−
−
<source lang="c">
−
−
void shutdown(void) {
−
__STM_Init();
−
STM_RebootSystem();
−
__STM_Close();
−
}
−
−
</source>
−
−
When you want to reboot just call
−
−
<source lang="c">
−
−
shutdown();
−
−
</source>
−
−
You will need to include the following
−
−
<source lang="c">
−
−
#include <ogc/ios.h>
−
#include <ogc/stm.h>
−
#include <ogc/ipc.h>
−
−
</source>
−
−
More reboot code only requiring ogc/ipc.h
−
−
<source lang="c">
−
−
void Reboot()
−
{
−
int fd = IOS_Open("/dev/stm/immediate", 0);
−
IOS_Ioctl(fd, 0x2001, NULL, 0, NULL, 0);
−
IOS_Close(fd);
−
}
−
−
</source>