From 7b562f71b301e5475d35bf95f06c6fd14b09559c Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 25 Jun 2025 21:52:23 +0200 Subject: [PATCH] NDMA: fix IRQ in infinite repeat mode --- src/DSi_NDMA.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/DSi_NDMA.cpp b/src/DSi_NDMA.cpp index 1cd1bc67..0121b388 100644 --- a/src/DSi_NDMA.cpp +++ b/src/DSi_NDMA.cpp @@ -269,11 +269,18 @@ void DSi_NDMA::Run9() if ((StartMode & 0x1F) == 0x10) // CHECKME { + // no repeat Cnt &= ~(1<<31); if (Cnt & (1<<30)) DSi.SetIRQ(0, IRQ_DSi_NDMA0 + Num); } - else if (!(Cnt & (1<<29))) + else if (Cnt & (1<<29)) { + // repeat infinitely + if (Cnt & (1<<30)) DSi.SetIRQ(0, IRQ_DSi_NDMA0 + Num); + } + else + { + // repeat until total count is reached if (TotalRemCount == 0) { Cnt &= ~(1<<31); @@ -358,11 +365,18 @@ void DSi_NDMA::Run7() if ((StartMode & 0x1F) == 0x10) // CHECKME { + // no repeat Cnt &= ~(1<<31); if (Cnt & (1<<30)) DSi.SetIRQ(1, IRQ_DSi_NDMA0 + Num); } - else if (!(Cnt & (1<<29))) + else if (Cnt & (1<<29)) { + // repeat infinitely + if (Cnt & (1<<30)) DSi.SetIRQ(1, IRQ_DSi_NDMA0 + Num); + } + else + { + // repeat until total count is reached if (TotalRemCount == 0) { Cnt &= ~(1<<31);