mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-21 05:09:46 -06:00
proof-of-concept code for closing/opening lid.
This commit is contained in:
36
src/NDS.cpp
36
src/NDS.cpp
@ -764,6 +764,7 @@ u32 RunFrame()
|
|||||||
FrameSysClockCycles = 0;
|
FrameSysClockCycles = 0;
|
||||||
|
|
||||||
if (!Running) return 263; // dorp
|
if (!Running) return 263; // dorp
|
||||||
|
if (CPUStop & 0x40000000) return 263;
|
||||||
|
|
||||||
GPU::StartFrame();
|
GPU::StartFrame();
|
||||||
|
|
||||||
@ -852,6 +853,14 @@ u32 RunFrame()
|
|||||||
SysClockCycles += ndscyclestorun;
|
SysClockCycles += ndscyclestorun;
|
||||||
LastSysClockCycles += ndscyclestorun;
|
LastSysClockCycles += ndscyclestorun;
|
||||||
FrameSysClockCycles += ndscyclestorun;
|
FrameSysClockCycles += ndscyclestorun;
|
||||||
|
|
||||||
|
if (CPUStop & 0x40000000)
|
||||||
|
{
|
||||||
|
// checkme: when is sleep mode effective?
|
||||||
|
//CancelEvent(Event_LCD);
|
||||||
|
//GPU::TotalScanlines = 263;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_CHECK_DESYNC
|
#ifdef DEBUG_CHECK_DESYNC
|
||||||
@ -953,6 +962,20 @@ void SetKeyMask(u32 mask)
|
|||||||
KeyInput |= key_lo | (key_hi << 16);
|
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)
|
void MicInputFrame(s16* data, int samples)
|
||||||
{
|
{
|
||||||
return SPI_TSC::MicInputFrame(data, samples);
|
return SPI_TSC::MicInputFrame(data, samples);
|
||||||
@ -1111,6 +1134,14 @@ void GXFIFOUnstall()
|
|||||||
CPUStop &= ~0x80000000;
|
CPUStop &= ~0x80000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EnterSleepMode()
|
||||||
|
{
|
||||||
|
if (CPUStop & 0x40000000) return;
|
||||||
|
|
||||||
|
CPUStop |= 0x40000000;
|
||||||
|
ARM7->Halt(2);
|
||||||
|
}
|
||||||
|
|
||||||
u32 GetPC(u32 cpu)
|
u32 GetPC(u32 cpu)
|
||||||
{
|
{
|
||||||
return cpu ? ARM7->R[15] : ARM9->R[15];
|
return cpu ? ARM7->R[15] : ARM9->R[15];
|
||||||
@ -3224,7 +3255,10 @@ void ARM7IOWrite8(u32 addr, u8 val)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case 0x04000301:
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +152,8 @@ void ReleaseScreen();
|
|||||||
|
|
||||||
void SetKeyMask(u32 mask);
|
void SetKeyMask(u32 mask);
|
||||||
|
|
||||||
|
void SetLidClosed(bool closed);
|
||||||
|
|
||||||
void MicInputFrame(s16* data, int samples);
|
void MicInputFrame(s16* data, int samples);
|
||||||
|
|
||||||
void ScheduleEvent(u32 id, bool periodic, s32 delay, void (*func)(u32), u32 param);
|
void ScheduleEvent(u32 id, bool periodic, s32 delay, void (*func)(u32), u32 param);
|
||||||
|
@ -108,6 +108,7 @@ uiDrawMatrix BottomScreenTrans;
|
|||||||
bool Touching = false;
|
bool Touching = false;
|
||||||
|
|
||||||
u32 KeyInputMask;
|
u32 KeyInputMask;
|
||||||
|
bool LidCommand, LidStatus;
|
||||||
SDL_Joystick* Joystick;
|
SDL_Joystick* Joystick;
|
||||||
|
|
||||||
const u32 kMicBufferSize = 2048; // must be power of two
|
const u32 kMicBufferSize = 2048; // must be power of two
|
||||||
@ -290,6 +291,8 @@ int EmuThreadFunc(void* burp)
|
|||||||
ScreenDrawInited = false;
|
ScreenDrawInited = false;
|
||||||
Touching = false;
|
Touching = false;
|
||||||
KeyInputMask = 0xFFF;
|
KeyInputMask = 0xFFF;
|
||||||
|
LidCommand = false;
|
||||||
|
LidStatus = false;
|
||||||
|
|
||||||
u32 nframes = 0;
|
u32 nframes = 0;
|
||||||
u32 starttick = SDL_GetTicks();
|
u32 starttick = SDL_GetTicks();
|
||||||
@ -347,6 +350,12 @@ int EmuThreadFunc(void* burp)
|
|||||||
}
|
}
|
||||||
NDS::SetKeyMask(keymask & joymask);
|
NDS::SetKeyMask(keymask & joymask);
|
||||||
|
|
||||||
|
if (LidCommand)
|
||||||
|
{
|
||||||
|
NDS::SetLidClosed(LidStatus);
|
||||||
|
LidCommand = false;
|
||||||
|
}
|
||||||
|
|
||||||
// microphone input
|
// microphone input
|
||||||
if ((MicBufferReadPos + 735) > kMicBufferSize)
|
if ((MicBufferReadPos + 735) > kMicBufferSize)
|
||||||
{
|
{
|
||||||
@ -620,6 +629,12 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
|
|||||||
if (evt->Scancode == Config::KeyMapping[i])
|
if (evt->Scancode == Config::KeyMapping[i])
|
||||||
KeyInputMask &= ~(1<<i);
|
KeyInputMask &= ~(1<<i);
|
||||||
|
|
||||||
|
if (evt->Scancode == 0x44) // F10, test
|
||||||
|
{
|
||||||
|
LidStatus = !LidStatus;
|
||||||
|
LidCommand = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (evt->Scancode == 0x57) // F11
|
if (evt->Scancode == 0x57) // F11
|
||||||
NDS::debug(0);
|
NDS::debug(0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user