Partial DMA rewrite using MAME code as a reference.