From e56ca6ac088cb84fe2af69acc33d263742ece373 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 24 Dec 2017 17:04:23 -0800 Subject: [PATCH] GBA DMA: Add misalign warnings --- src/gba/dma.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gba/dma.c b/src/gba/dma.c index 0e0abeefe..4516b5224 100644 --- a/src/gba/dma.c +++ b/src/gba/dma.c @@ -87,6 +87,15 @@ uint16_t GBADMAWriteCNT_HI(struct GBA* gba, int dma, uint16_t control) { currentDma->reg = GBADMARegisterClearSrcControl(currentDma->reg); } currentDma->nextDest = currentDma->dest; + + uint32_t width = 2 << GBADMARegisterGetWidth(currentDma->reg); + if (currentDma->nextSource & (width - 1)) { + mLOG(GBA_MEM, GAME_ERROR, "Misaligned DMA source address: 0x%08X", currentDma->nextSource); + } + if (currentDma->nextDest & (width - 1)) { + mLOG(GBA_MEM, GAME_ERROR, "Misaligned DMA destination address: 0x%08X", currentDma->nextDest); + } + GBADMASchedule(gba, dma, currentDma); } // If the DMA has already occurred, this value might have changed since the function started