Compare commits

..

2 Commits

1 changed files with 11 additions and 24 deletions

View File

@ -107,8 +107,8 @@ pub fn DmaController(comptime id: u2) type {
} }
switch (sad_adj) { switch (sad_adj) {
.Increment => self._sad +%= offset, .Increment => self._sad += offset,
.Decrement => self._sad -%= offset, .Decrement => self._sad -= offset,
.Fixed => {}, .Fixed => {},
// TODO: Figure out correct behaviour on Illegal Source Addr Control Type // TODO: Figure out correct behaviour on Illegal Source Addr Control Type
@ -116,16 +116,14 @@ pub fn DmaController(comptime id: u2) type {
} }
switch (dad_adj) { switch (dad_adj) {
.Increment, .IncrementReload => self._dad +%= offset, .Increment, .IncrementReload => self._dad += offset,
.Decrement => self._dad -%= offset, .Decrement => self._dad -= offset,
.Fixed => {}, .Fixed => {},
} }
self._word_count -= 1; self._word_count -= 1;
if (self._word_count == 0) { if (self._word_count == 0) {
if (!self.cnt.repeat.read()) {
// If we're not repeating, Fire the IRQs and disable the DMA
if (self.cnt.irq.read()) { if (self.cnt.irq.read()) {
switch (id) { switch (id) {
0 => bus.io.irq.dma0.set(), 0 => bus.io.irq.dma0.set(),
@ -134,12 +132,8 @@ pub fn DmaController(comptime id: u2) type {
3 => bus.io.irq.dma0.set(), 3 => bus.io.irq.dma0.set(),
} }
} }
self.cnt.enabled.unset();
}
// We want to disable our internal enabled flag regardless of repeat self.cnt.enabled.unset();
// because we only want to step A DMA that repeats during it's specific
// timing window
self.enabled = false; self.enabled = false;
} }
@ -159,13 +153,6 @@ pub fn DmaController(comptime id: u2) type {
.VBlank => self.enabled = self.cnt.enabled.read() and self.cnt.start_timing.read() == 0b01, .VBlank => self.enabled = self.cnt.enabled.read() and self.cnt.start_timing.read() == 0b01,
.Immediate, .Special => {}, .Immediate, .Special => {},
} }
if (self.cnt.repeat.read() and self.enabled) {
self._word_count = if (self.word_count == 0) std.math.maxInt(@TypeOf(self._word_count)) else self.word_count;
const dad_adj = std.meta.intToEnum(Adjustment, self.cnt.dad_adj.read()) catch unreachable;
if (dad_adj == .IncrementReload) self._dad = self.dad;
}
} }
}; };
} }