aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2017-09-21 03:59:12 +0200
committerStapleButter <thetotalworm@gmail.com>2017-09-21 03:59:12 +0200
commit495d0ba12d140fc205fbfbe491b6ddd8d6dbe891 (patch)
tree27692236dd7fd042a75fb828d89365686616cdd0 /src
parent0aa3434ec7c7416fb267ebff76535949e91bf050 (diff)
add support for SPI shutdown, btw
Diffstat (limited to 'src')
-rw-r--r--src/NDS.cpp8
-rw-r--r--src/NDS.h1
-rw-r--r--src/Platform.h2
-rw-r--r--src/SPI.cpp8
-rw-r--r--src/SPU.cpp5
-rw-r--r--src/SPU.h1
-rw-r--r--src/libui_sdl/Platform.cpp11
-rw-r--r--src/libui_sdl/main.cpp3
8 files changed, 34 insertions, 5 deletions
diff --git a/src/NDS.cpp b/src/NDS.cpp
index 04a1a26..9b096b8 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 a1eab99..0d77201 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 4fefd33..5196d0f 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 21f9ccb..534f6ca 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 5c4a347..a3f61b4 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 e388be9..0d59db7 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 7313ae4..67f136c 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 396bc29..1068f92 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);
}