Mercurial > hg > index.fcgi > lj > lj046
view src/dssleep.c @ 3:17286938e22a
change DS alt. rotate key to rotate twice
author | paulo@localhost |
---|---|
date | Wed, 08 Apr 2009 21:50:13 -0700 |
parents | |
children |
line source
1 #include <nds.h>
3 /*
4 by Mighty Max and melw,
5 after http://forum.gbadev.org/viewtopic.php?t=12011
6 */
8 int needLidSleep(void) {
9 // when reading keys
10 if (IPC->buttons & 0x0080) {
11 /* hinge is closed */
13 /* Step 1: Turn off all interrupts but vblank for waking up */
14 unsigned long oldIE = REG_IE;
15 REG_IE = IRQ_VBLANK;
17 /* Step 2: Power off most of the system */
18 powerOFF(POWER_LCD);
20 /* Step 3: Wait one vblank at a time until the ARM7 tells us
21 that the lid is no longer closed */
22 while (IPC->buttons & 0x0080) {
23 swiWaitForVBlank();
24 }
26 /* Step 4: Wait a bit more (necessary?) */
27 swiWaitForVBlank();
29 /* Step 5: Restore old machine state */
30 powerON(POWER_LCD);
31 REG_IE = oldIE;
32 return 1;
33 }
34 return 0;
35 }