proof-of-concept code for closing/opening lid.

This commit is contained in:
StapleButter
2018-12-14 02:36:57 +01:00
parent e829c2e4a1
commit cb1e6ce750
3 changed files with 52 additions and 1 deletions

View File

@ -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;
}