diff --git a/src/mmu.rs b/src/mmu.rs index a2f92b7a5ac03b20104cae1af2160619586fa404..9b02f33f6fa4d288b2df5852b116701ec162f9dd 100644 --- a/src/mmu.rs +++ b/src/mmu.rs @@ -244,8 +244,14 @@ impl Mmu { } // @TODO: Implement DMA transfer in a better way - let data = self.read_many(self.dma.source(), self.dma.length()); - self.write_many(self.dma.destination(), &data); + + // only runs the DMA transfer if the system is in CGB mode + // this avoid issues when writing to DMG unmapped registers + // that would otherwise cause the system to crash + if self.mode == GameBoyMode::Cgb { + let data = self.read_many(self.dma.source(), self.dma.length()); + self.write_many(self.dma.destination(), &data); + } self.dma.set_active(false); }