add support for SPI shutdown, btw

This commit is contained in:
StapleButter 2017-09-21 03:59:12 +02:00
parent 0aa3434ec7
commit 495d0ba12d
8 changed files with 34 additions and 5 deletions

View File

@ -29,6 +29,7 @@
#include "SPI.h" #include "SPI.h"
#include "RTC.h" #include "RTC.h"
#include "Wifi.h" #include "Wifi.h"
#include "Platform.h"
namespace NDS namespace NDS
@ -342,6 +343,13 @@ void Reset()
Wifi::Reset(); Wifi::Reset();
} }
void Stop()
{
printf("Stopping: shutdown\n");
Platform::StopEmu();
SPU::Stop();
}
void LoadROM(const char* path, bool direct) void LoadROM(const char* path, bool direct)
{ {
Reset(); Reset();

View File

@ -104,6 +104,7 @@ extern u8 MainRAM[0x400000];
bool Init(); bool Init();
void DeInit(); void DeInit();
void Reset(); void Reset();
void Stop();
void LoadROM(const char* path, bool direct); void LoadROM(const char* path, bool direct);
void LoadBIOS(); void LoadBIOS();

View File

@ -24,6 +24,8 @@
namespace Platform namespace Platform
{ {
void StopEmu();
void* Thread_Create(void (*func)()); void* Thread_Create(void (*func)());
void Thread_Free(void* thread); void Thread_Free(void* thread);
void Thread_Wait(void* thread); void Thread_Wait(void* thread);

View File

@ -365,7 +365,7 @@ u8 Read()
} }
void Write(u8 val, u32 hold) void Write(u8 val, u32 hold)
{printf("SPI powerman %02X %d\n", val, hold?1:0); {
if (!hold) if (!hold)
{ {
Hold = 0; Hold = 0;
@ -395,11 +395,11 @@ void Write(u8 val, u32 hold)
switch (regid) switch (regid)
{ {
case 0: case 0:
if (val & 0x40) printf("DS shutdown\n"); if (val & 0x40) NDS::Stop(); // shutdown
printf("power %02X\n", val); //printf("power %02X\n", val);
break; break;
case 4: case 4:
printf("brightness %02X\n", val); //printf("brightness %02X\n", val);
break; break;
} }
} }

View File

@ -114,6 +114,11 @@ void Reset()
NDS::ScheduleEvent(NDS::Event_SPU, true, 1024*16, Mix, 16); NDS::ScheduleEvent(NDS::Event_SPU, true, 1024*16, Mix, 16);
} }
void Stop()
{
memset(OutputBuffer, 0, 2*OutputBufferSize*2);
}
void SetBias(u16 bias) void SetBias(u16 bias)
{ {

View File

@ -25,6 +25,7 @@ namespace SPU
bool Init(); bool Init();
void DeInit(); void DeInit();
void Reset(); void Reset();
void Stop();
void SetBias(u16 bias); void SetBias(u16 bias);

View File

@ -44,6 +44,9 @@
#endif #endif
void Stop();
namespace Platform namespace Platform
{ {
@ -70,6 +73,12 @@ u8 PacketBuffer[2048];
#define NIFI_VER 1*/ #define NIFI_VER 1*/
void StopEmu()
{
Stop();
}
void* Thread_Create(void (*func)()) void* Thread_Create(void (*func)())
{ {
ThreadData* data = new ThreadData; ThreadData* data = new ThreadData;

View File

@ -272,6 +272,9 @@ void Stop()
uiMenuItemDisable(MenuItem_Pause); uiMenuItemDisable(MenuItem_Pause);
uiMenuItemDisable(MenuItem_Reset); uiMenuItemDisable(MenuItem_Reset);
uiMenuItemSetChecked(MenuItem_Pause, 0); uiMenuItemSetChecked(MenuItem_Pause, 0);
memset(ScreenBuffer, 256*384*4, 0);
uiAreaQueueRedrawAll(MainDrawArea);
} }