all repos — mgba @ 1de5238e8f2992af1a4b8961477cf6e9ce78943c

mGBA Game Boy Advance Emulator

GBA DMA: Add misalign warnings
Vicki Pfau vi@endrift.com
Sun, 24 Dec 2017 17:04:23 -0800
commit

1de5238e8f2992af1a4b8961477cf6e9ce78943c

parent

5d21116aea5211c3c92925c2a751bb5ce5e575e8

1 files changed, 9 insertions(+), 0 deletions(-)

jump to
M src/gba/dma.csrc/gba/dma.c

@@ -85,6 +85,15 @@ if (currentDma->nextSource >= BASE_CART0 && currentDma->nextSource < BASE_CART_SRAM && GBADMARegisterGetSrcControl(currentDma->reg) < 3) {

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