diff --git a/src/NDS.cpp b/src/NDS.cpp index 04a1a267..9b096b82 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -29,6 +29,7 @@ #include "SPI.h" #include "RTC.h" #include "Wifi.h" +#include "Platform.h" namespace NDS @@ -342,6 +343,13 @@ void Reset() Wifi::Reset(); } +void Stop() +{ + printf("Stopping: shutdown\n"); + Platform::StopEmu(); + SPU::Stop(); +} + void LoadROM(const char* path, bool direct) { Reset(); diff --git a/src/NDS.h b/src/NDS.h index a1eab993..0d772010 100644 --- a/src/NDS.h +++ b/src/NDS.h @@ -104,6 +104,7 @@ extern u8 MainRAM[0x400000]; bool Init(); void DeInit(); void Reset(); +void Stop(); void LoadROM(const char* path, bool direct); void LoadBIOS(); diff --git a/src/Platform.h b/src/Platform.h index 4fefd333..5196d0f1 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -24,6 +24,8 @@ namespace Platform { +void StopEmu(); + void* Thread_Create(void (*func)()); void Thread_Free(void* thread); void Thread_Wait(void* thread); diff --git a/src/SPI.cpp b/src/SPI.cpp index 21f9ccb7..534f6ca2 100644 --- a/src/SPI.cpp +++ b/src/SPI.cpp @@ -365,7 +365,7 @@ u8 Read() } void Write(u8 val, u32 hold) -{printf("SPI powerman %02X %d\n", val, hold?1:0); +{ if (!hold) { Hold = 0; @@ -395,11 +395,11 @@ void Write(u8 val, u32 hold) switch (regid) { case 0: - if (val & 0x40) printf("DS shutdown\n"); - printf("power %02X\n", val); + if (val & 0x40) NDS::Stop(); // shutdown + //printf("power %02X\n", val); break; case 4: - printf("brightness %02X\n", val); + //printf("brightness %02X\n", val); break; } } diff --git a/src/SPU.cpp b/src/SPU.cpp index 5c4a347f..a3f61b4e 100644 --- a/src/SPU.cpp +++ b/src/SPU.cpp @@ -114,6 +114,11 @@ void Reset() NDS::ScheduleEvent(NDS::Event_SPU, true, 1024*16, Mix, 16); } +void Stop() +{ + memset(OutputBuffer, 0, 2*OutputBufferSize*2); +} + void SetBias(u16 bias) { diff --git a/src/SPU.h b/src/SPU.h index e388be9b..0d59db78 100644 --- a/src/SPU.h +++ b/src/SPU.h @@ -25,6 +25,7 @@ namespace SPU bool Init(); void DeInit(); void Reset(); +void Stop(); void SetBias(u16 bias); diff --git a/src/libui_sdl/Platform.cpp b/src/libui_sdl/Platform.cpp index 7313ae44..67f136c7 100644 --- a/src/libui_sdl/Platform.cpp +++ b/src/libui_sdl/Platform.cpp @@ -44,6 +44,9 @@ #endif +void Stop(); + + namespace Platform { @@ -52,7 +55,7 @@ typedef struct { SDL_Thread* ID; void (*Func)(); - + } ThreadData; int ThreadEntry(void* data) @@ -70,6 +73,12 @@ u8 PacketBuffer[2048]; #define NIFI_VER 1*/ +void StopEmu() +{ + Stop(); +} + + void* Thread_Create(void (*func)()) { ThreadData* data = new ThreadData; diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 396bc29e..1068f922 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -272,6 +272,9 @@ void Stop() uiMenuItemDisable(MenuItem_Pause); uiMenuItemDisable(MenuItem_Reset); uiMenuItemSetChecked(MenuItem_Pause, 0); + + memset(ScreenBuffer, 256*384*4, 0); + uiAreaQueueRedrawAll(MainDrawArea); }