mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 14:19:55 -06:00
fix bug that happened when HDMA got interrupted (or any repeating DMA, for that matter)
This commit is contained in:
25
src/DMA.cpp
25
src/DMA.cpp
@ -115,6 +115,7 @@ void DMA::Reset()
|
|||||||
DstAddrInc = 0;
|
DstAddrInc = 0;
|
||||||
|
|
||||||
Running = false;
|
Running = false;
|
||||||
|
InProgress = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMA::WriteCnt(u32 val)
|
void DMA::WriteCnt(u32 val)
|
||||||
@ -162,15 +163,18 @@ void DMA::Start()
|
|||||||
{
|
{
|
||||||
if (Running) return;
|
if (Running) return;
|
||||||
|
|
||||||
u32 countmask;
|
if (!InProgress)
|
||||||
if (CPU == 0)
|
{
|
||||||
countmask = 0x001FFFFF;
|
u32 countmask;
|
||||||
else
|
if (CPU == 0)
|
||||||
countmask = (Num==3 ? 0x0000FFFF : 0x00003FFF);
|
countmask = 0x001FFFFF;
|
||||||
|
else
|
||||||
|
countmask = (Num==3 ? 0x0000FFFF : 0x00003FFF);
|
||||||
|
|
||||||
RemCount = Cnt & countmask;
|
RemCount = Cnt & countmask;
|
||||||
if (!RemCount)
|
if (!RemCount)
|
||||||
RemCount = countmask+1;
|
RemCount = countmask+1;
|
||||||
|
}
|
||||||
|
|
||||||
if (StartMode == 0x07 && RemCount > 112)
|
if (StartMode == 0x07 && RemCount > 112)
|
||||||
IterCount = 112;
|
IterCount = 112;
|
||||||
@ -211,6 +215,7 @@ void DMA::Start()
|
|||||||
// TODO eventually: not stop if we're running code in ITCM
|
// TODO eventually: not stop if we're running code in ITCM
|
||||||
|
|
||||||
Running = true;
|
Running = true;
|
||||||
|
InProgress = true;
|
||||||
NDS::StopCPU(CPU, 1<<Num);
|
NDS::StopCPU(CPU, 1<<Num);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,9 +265,6 @@ s32 DMA::Run(s32 cycles)
|
|||||||
|
|
||||||
if (RemCount)
|
if (RemCount)
|
||||||
{
|
{
|
||||||
Cnt &= ~CountMask;
|
|
||||||
Cnt |= RemCount;
|
|
||||||
|
|
||||||
if (IterCount == 0)
|
if (IterCount == 0)
|
||||||
{
|
{
|
||||||
Running = false;
|
Running = false;
|
||||||
@ -282,6 +284,7 @@ s32 DMA::Run(s32 cycles)
|
|||||||
NDS::SetIRQ(CPU, NDS::IRQ_DMA0 + Num);
|
NDS::SetIRQ(CPU, NDS::IRQ_DMA0 + Num);
|
||||||
|
|
||||||
Running = false;
|
Running = false;
|
||||||
|
InProgress = false;
|
||||||
NDS::ResumeCPU(CPU, 1<<Num);
|
NDS::ResumeCPU(CPU, 1<<Num);
|
||||||
|
|
||||||
return cycles - 2;
|
return cycles - 2;
|
||||||
|
Reference in New Issue
Block a user