vram dma increments
This commit is contained in:
parent
d3c67622eb
commit
2eae8875ca
1 changed files with 12 additions and 7 deletions
|
@ -86,22 +86,27 @@ where
|
||||||
let returning = if let Some(cgb_peripherals) = &mut self.cgb_peripherals {
|
let returning = if let Some(cgb_peripherals) = &mut self.cgb_peripherals {
|
||||||
match cgb_peripherals.vram_dma.mode {
|
match cgb_peripherals.vram_dma.mode {
|
||||||
DmaMode::Halt(l) => {
|
DmaMode::Halt(l) => {
|
||||||
|
let length = 16 * ((l as u16) + 1);
|
||||||
copy = Some((
|
copy = Some((
|
||||||
cgb_peripherals.vram_dma.destination,
|
|
||||||
cgb_peripherals.vram_dma.source,
|
cgb_peripherals.vram_dma.source,
|
||||||
16 * ((l as u16) + 1),
|
cgb_peripherals.vram_dma.destination,
|
||||||
|
length,
|
||||||
));
|
));
|
||||||
|
cgb_peripherals.vram_dma.source += length;
|
||||||
|
cgb_peripherals.vram_dma.destination += length;
|
||||||
cgb_peripherals.vram_dma.mode = DmaMode::Waiting;
|
cgb_peripherals.vram_dma.mode = DmaMode::Waiting;
|
||||||
((l as usize) + 1) * 8
|
((l as usize) + 1) * 8
|
||||||
}
|
}
|
||||||
DmaMode::Hblank(l, ref mut progress) => {
|
DmaMode::Hblank(l, ref mut progress) => {
|
||||||
if self.gpu.get_mode() == DrawMode::HBlank {
|
if self.gpu.get_mode() == DrawMode::HBlank {
|
||||||
let offset = *progress * 16;
|
let length = 16;
|
||||||
copy = Some((
|
copy = Some((
|
||||||
cgb_peripherals.vram_dma.destination + offset,
|
cgb_peripherals.vram_dma.source,
|
||||||
cgb_peripherals.vram_dma.source + offset,
|
cgb_peripherals.vram_dma.destination,
|
||||||
16,
|
length,
|
||||||
));
|
));
|
||||||
|
cgb_peripherals.vram_dma.source += length;
|
||||||
|
cgb_peripherals.vram_dma.destination += length;
|
||||||
*progress += 1;
|
*progress += 1;
|
||||||
if *progress > (l as u16) {
|
if *progress > (l as u16) {
|
||||||
cgb_peripherals.vram_dma.mode = DmaMode::Waiting
|
cgb_peripherals.vram_dma.mode = DmaMode::Waiting
|
||||||
|
@ -118,7 +123,7 @@ where
|
||||||
};
|
};
|
||||||
if let Some((source, dest, length)) = copy {
|
if let Some((source, dest, length)) = copy {
|
||||||
for i in 0..length {
|
for i in 0..length {
|
||||||
self.set(dest + i, self.get(source + i));
|
self.set(source + i, self.get(dest + i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if self.is_double_speed() {
|
if self.is_double_speed() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue