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>