aboutsummaryrefslogtreecommitdiff
path: root/src/NDS.cpp
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2018-12-14 02:36:57 +0100
committerStapleButter <thetotalworm@gmail.com>2018-12-14 02:36:57 +0100
commitcb1e6ce750410aa6d56f57454366d009e832a3df (patch)
tree5339fce57af9fcfbfc59d1571746d264460823cf /src/NDS.cpp
parente829c2e4a1c106d0d3a4a81edc5b76ec3ddfd4ef (diff)
proof-of-concept code for closing/opening lid.
Diffstat (limited to 'src/NDS.cpp')
-rw-r--r--src/NDS.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/NDS.cpp b/src/NDS.cpp
index c750bc6..98c2924 100644
--- a/src/NDS.cpp
+++ b/src/NDS.cpp
@@ -764,6 +764,7 @@ u32 RunFrame()
FrameSysClockCycles = 0;
if (!Running) return 263; // dorp
+ if (CPUStop & 0x40000000) return 263;
GPU::StartFrame();
@@ -852,6 +853,14 @@ u32 RunFrame()
SysClockCycles += ndscyclestorun;
LastSysClockCycles += ndscyclestorun;
FrameSysClockCycles += ndscyclestorun;
+
+ if (CPUStop & 0x40000000)
+ {
+ // checkme: when is sleep mode effective?
+ //CancelEvent(Event_LCD);
+ //GPU::TotalScanlines = 263;
+ break;
+ }
}
#ifdef DEBUG_CHECK_DESYNC
@@ -953,6 +962,20 @@ void SetKeyMask(u32 mask)
KeyInput |= key_lo | (key_hi << 16);
}
+void SetLidClosed(bool closed)
+{
+ if (closed)
+ {
+ KeyInput |= (1<<23);
+ }
+ else
+ {
+ KeyInput &= ~(1<<23);
+ SetIRQ(1, IRQ_LidOpen);
+ CPUStop &= ~0x40000000;
+ }
+}
+
void MicInputFrame(s16* data, int samples)
{
return SPI_TSC::MicInputFrame(data, samples);
@@ -1111,6 +1134,14 @@ void GXFIFOUnstall()
CPUStop &= ~0x80000000;
}
+void EnterSleepMode()
+{
+ if (CPUStop & 0x40000000) return;
+
+ CPUStop |= 0x40000000;
+ ARM7->Halt(2);
+}
+
u32 GetPC(u32 cpu)
{
return cpu ? ARM7->R[15] : ARM9->R[15];
@@ -3224,7 +3255,10 @@ void ARM7IOWrite8(u32 addr, u8 val)
return;
case 0x04000301:
- if (val == 0x80) ARM7->Halt(1);
+ val & 0xC0;
+ if (val == 0x40) printf("!! GBA MODE NOT SUPPORTED\n");
+ else if (val == 0x80) ARM7->Halt(1);
+ else if (val == 0xC0) EnterSleepMode();
return;
}