aboutsummaryrefslogtreecommitdiff
path: root/src/DSi_DSP.cpp
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2022-10-11 00:26:42 +0200
committerArisotura <thetotalworm@gmail.com>2022-10-11 00:26:42 +0200
commitb33f0434a6b4ca9b64ce7856ed12633ebf879cf7 (patch)
tree77db55eb3e3f68063e2c1bf3c137af503990e414 /src/DSi_DSP.cpp
parent9a85bc745314f672a8a3ce0659cc25794a923398 (diff)
unfuck the DSP enough that it will actually run code
(don't get your hopes up, it's still pretty much a trainwreck)
Diffstat (limited to 'src/DSi_DSP.cpp')
-rw-r--r--src/DSi_DSP.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/DSi_DSP.cpp b/src/DSi_DSP.cpp
index 711166c..74170b7 100644
--- a/src/DSi_DSP.cpp
+++ b/src/DSi_DSP.cpp
@@ -214,6 +214,11 @@ inline bool IsDSPCoreEnabled()
return (DSi::SCFG_Clock9 & (1<<1)) && SCFG_RST && (!(DSP_PCFG & (1<<0)));
}
+inline bool IsDSPIOEnabled()
+{
+ return (DSi::SCFG_Clock9 & (1<<1)) && SCFG_RST;
+}
+
bool DSPCatchUp()
{
//asm volatile("int3");
@@ -390,7 +395,8 @@ u16 PDataDMAReadMMIO()
u8 Read8(u32 addr)
{
- if (!DSPCatchUp()) return 0;
+ if (!IsDSPIOEnabled()) return 0;
+ DSPCatchUp();
addr &= 0x3F; // mirroring wheee
@@ -416,7 +422,9 @@ u8 Read8(u32 addr)
}
u16 Read16(u32 addr)
{
- if (!DSPCatchUp()) return 0;
+ //printf("DSP READ16 %d %08X %08X\n", IsDSPCoreEnabled(), addr, NDS::GetPC(0));
+ if (!IsDSPIOEnabled()) return 0;
+ DSPCatchUp();
addr &= 0x3E; // mirroring wheee
@@ -464,7 +472,8 @@ u32 Read32(u32 addr)
void Write8(u32 addr, u8 val)
{
- if (!DSPCatchUp()) return;
+ if (!IsDSPIOEnabled()) return;
+ DSPCatchUp();
addr &= 0x3F;
switch (addr)
@@ -484,7 +493,9 @@ void Write8(u32 addr, u8 val)
}
void Write16(u32 addr, u16 val)
{
- if (!DSPCatchUp()) return;
+ //printf("DSP WRITE16 %d %08X %08X %08X\n", IsDSPCoreEnabled(), addr, val, NDS::GetPC(0));
+ if (!IsDSPIOEnabled()) return;
+ DSPCatchUp();
addr &= 0x3E;
switch (addr)
@@ -494,6 +505,8 @@ void Write16(u32 addr, u16 val)
case 0x08:
DSP_PCFG = val;
+ if (DSP_PCFG & (1<<0))
+ TeakraCore->Reset();
if (DSP_PCFG & (1<<4))
PDataDMAStart();
else