Skip to content

Commit

Permalink
unfuck the DSP code some
Browse files Browse the repository at this point in the history
(still doesn't work)
  • Loading branch information
Arisotura committed Oct 9, 2022
1 parent c177fae commit b76e5ad
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
38 changes: 28 additions & 10 deletions src/DSi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2241,8 +2241,11 @@ u8 ARM9IORead8(u32 addr)
return DSi_CamModule::Read8(addr);
}

if (addr >= 0x04004300 && addr <= 0x04004400)
return DSi_DSP::Read16(addr);
if ((addr & 0xFFFFFF00) == 0x04004300)
{
if (!(SCFG_EXT[0] & (1<<18))) return 0;
return DSi_DSP::Read8(addr);
}

return NDS::ARM9IORead8(addr);
}
Expand Down Expand Up @@ -2273,8 +2276,11 @@ u16 ARM9IORead16(u32 addr)
return DSi_CamModule::Read16(addr);
}

if (addr >= 0x04004300 && addr <= 0x04004400)
return DSi_DSP::Read32(addr);
if ((addr & 0xFFFFFF00) == 0x04004300)
{
if (!(SCFG_EXT[0] & (1<<18))) return 0;
return DSi_DSP::Read16(addr);
}

return NDS::ARM9IORead16(addr);
}
Expand Down Expand Up @@ -2335,6 +2341,12 @@ u32 ARM9IORead32(u32 addr)
return DSi_CamModule::Read32(addr);
}

if ((addr & 0xFFFFFF00) == 0x04004300)
{
if (!(SCFG_EXT[0] & (1<<18))) return 0;
return DSi_DSP::Read32(addr);
}

return NDS::ARM9IORead32(addr);
}

Expand Down Expand Up @@ -2399,10 +2411,10 @@ void ARM9IOWrite8(u32 addr, u8 val)
return DSi_CamModule::Write8(addr, val);
}

if (addr >= 0x04004300 && addr <= 0x04004400)
if ((addr & 0xFFFFFF00) == 0x04004300)
{
DSi_DSP::Write8(addr, val);
return;
if (!(SCFG_EXT[0] & (1<<18))) return;
return DSi_DSP::Write8(addr, val);
}

return NDS::ARM9IOWrite8(addr, val);
Expand Down Expand Up @@ -2459,10 +2471,10 @@ void ARM9IOWrite16(u32 addr, u16 val)
return DSi_CamModule::Write16(addr, val);
}

if (addr >= 0x04004300 && addr <= 0x04004400)
if ((addr & 0xFFFFFF00) == 0x04004300)
{
DSi_DSP::Write16(addr, val);
return;
if (!(SCFG_EXT[0] & (1<<18))) return;
return DSi_DSP::Write16(addr, val);
}

return NDS::ARM9IOWrite16(addr, val);
Expand Down Expand Up @@ -2609,6 +2621,12 @@ void ARM9IOWrite32(u32 addr, u32 val)
return DSi_CamModule::Write32(addr, val);
}

if ((addr & 0xFFFFFF00) == 0x04004300)
{
if (!(SCFG_EXT[0] & (1<<18))) return;
return DSi_DSP::Write32(addr, val);
}

return NDS::ARM9IOWrite32(addr, val);
}

Expand Down
14 changes: 0 additions & 14 deletions src/DSi_DSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,6 @@ u16 PDataDMAReadMMIO()

u8 Read8(u32 addr)
{
if (!(DSi::SCFG_EXT[0] & (1<<18)))
return 0;

if (!DSPCatchUp()) return 0;

addr &= 0x3F; // mirroring wheee
Expand All @@ -419,9 +416,6 @@ u8 Read8(u32 addr)
}
u16 Read16(u32 addr)
{
if (!(DSi::SCFG_EXT[0] & (1<<18)))
return 0;

if (!DSPCatchUp()) return 0;

addr &= 0x3E; // mirroring wheee
Expand Down Expand Up @@ -463,17 +457,13 @@ u16 Read16(u32 addr)
}
u32 Read32(u32 addr)
{
if (!(DSi::SCFG_EXT[0] & (1<<18))) return 0;

addr &= 0x3C;
return Read16(addr); // *shrug* (doesn't do anything unintended due to the
// 4byte spacing between regs while they're all 16bit)
}

void Write8(u32 addr, u8 val)
{
if (!(DSi::SCFG_EXT[0] & (1<<18))) return;

if (!DSPCatchUp()) return;

addr &= 0x3F;
Expand All @@ -494,8 +484,6 @@ void Write8(u32 addr, u8 val)
}
void Write16(u32 addr, u16 val)
{
if (!(DSi::SCFG_EXT[0] & (1<<18))) return;

if (!DSPCatchUp()) return;

addr &= 0x3E;
Expand Down Expand Up @@ -547,8 +535,6 @@ void Write16(u32 addr, u16 val)

void Write32(u32 addr, u32 val)
{
if (!(DSi::SCFG_EXT[0] & (1<<18))) return;

addr &= 0x3C;
Write16(addr, val & 0xFFFF);
}
Expand Down

0 comments on commit b76e5ad

Please sign in to comment.