Compare commits
2 Commits
0ceba17139
...
2e4854c2ff
Author | SHA1 | Date |
---|---|---|
Rekai Nyangadzayi Musuka | 2e4854c2ff | |
Rekai Nyangadzayi Musuka | 85f0b13f4a |
|
@ -107,8 +107,8 @@ pub fn DmaController(comptime id: u2) type {
|
|||
}
|
||||
|
||||
switch (sad_adj) {
|
||||
.Increment => self._sad += offset,
|
||||
.Decrement => self._sad -= offset,
|
||||
.Increment => self._sad +%= offset,
|
||||
.Decrement => self._sad -%= offset,
|
||||
.Fixed => {},
|
||||
|
||||
// TODO: Figure out correct behaviour on Illegal Source Addr Control Type
|
||||
|
@ -116,24 +116,30 @@ pub fn DmaController(comptime id: u2) type {
|
|||
}
|
||||
|
||||
switch (dad_adj) {
|
||||
.Increment, .IncrementReload => self._dad += offset,
|
||||
.Decrement => self._dad -= offset,
|
||||
.Increment, .IncrementReload => self._dad +%= offset,
|
||||
.Decrement => self._dad -%= offset,
|
||||
.Fixed => {},
|
||||
}
|
||||
|
||||
self._word_count -= 1;
|
||||
|
||||
if (self._word_count == 0) {
|
||||
if (self.cnt.irq.read()) {
|
||||
switch (id) {
|
||||
0 => bus.io.irq.dma0.set(),
|
||||
1 => bus.io.irq.dma0.set(),
|
||||
2 => bus.io.irq.dma0.set(),
|
||||
3 => bus.io.irq.dma0.set(),
|
||||
if (!self.cnt.repeat.read()) {
|
||||
// If we're not repeating, Fire the IRQs and disable the DMA
|
||||
if (self.cnt.irq.read()) {
|
||||
switch (id) {
|
||||
0 => bus.io.irq.dma0.set(),
|
||||
1 => bus.io.irq.dma0.set(),
|
||||
2 => bus.io.irq.dma0.set(),
|
||||
3 => bus.io.irq.dma0.set(),
|
||||
}
|
||||
}
|
||||
self.cnt.enabled.unset();
|
||||
}
|
||||
|
||||
self.cnt.enabled.unset();
|
||||
// We want to disable our internal enabled flag regardless of repeat
|
||||
// because we only want to step A DMA that repeats during it's specific
|
||||
// timing window
|
||||
self.enabled = false;
|
||||
}
|
||||
|
||||
|
@ -153,6 +159,13 @@ pub fn DmaController(comptime id: u2) type {
|
|||
.VBlank => self.enabled = self.cnt.enabled.read() and self.cnt.start_timing.read() == 0b01,
|
||||
.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;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue