Changes

1,133 bytes removed ,  04:01, 8 March 2009
←Redirected page to Developer tips
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>
 
2,375

edits