chore: tick scheduler on memory access

This commit is contained in:
2022-04-09 19:15:12 -03:00
parent 5da84aff36
commit c100d64fcb
6 changed files with 34 additions and 34 deletions

View File

@@ -358,7 +358,7 @@ pub const Ppu = struct {
};
}
pub fn handleHDrawEnd(self: *Self, cpu: *Arm7tdmi) void {
pub fn handleHDrawEnd(self: *Self, cpu: *Arm7tdmi, late: u64) void {
// Transitioning to a Hblank
if (self.dispstat.hblank_irq.read()) {
cpu.bus.io.irq.hblank.set();
@@ -369,10 +369,10 @@ pub const Ppu = struct {
pollBlankingDma(cpu.bus, .HBlank);
self.dispstat.hblank.set();
self.sched.push(.HBlank, self.sched.now() + (68 * 4));
self.sched.push(.HBlank, self.sched.now() + (68 * 4) - late);
}
pub fn handleHBlankEnd(self: *Self, cpu: *Arm7tdmi) void {
pub fn handleHBlankEnd(self: *Self, cpu: *Arm7tdmi, late: u64) void {
// The End of a Hblank (During Draw or Vblank)
const old_scanline = self.vcount.scanline.read();
const scanline = (old_scanline + 1) % 228;
@@ -391,7 +391,7 @@ pub const Ppu = struct {
if (scanline < 160) {
// Transitioning to another Draw
self.sched.push(.Draw, self.sched.now() + (240 * 4));
self.sched.push(.Draw, self.sched.now() + (240 * 4) - late);
} else {
// Transitioning to a Vblank
if (scanline == 160) {
@@ -407,7 +407,7 @@ pub const Ppu = struct {
}
if (scanline == 227) self.dispstat.vblank.unset();
self.sched.push(.VBlank, self.sched.now() + (240 * 4));
self.sched.push(.VBlank, self.sched.now() + (240 * 4) - late);
}
}
};