finally fixed the bottom scanline LMAO

This commit is contained in:
Alex Janka 2023-10-03 16:16:39 +11:00
parent 09e0d83e97
commit a487264f40

View file

@ -117,10 +117,11 @@ where
match self.stat.mode {
DrawMode::HBlank => {
// mode 0: hblank
if self.mode_clock >= 204 {
self.mode_clock = 0;
const HBLANK_MODE_CLOCK: usize = 204;
if self.mode_clock >= HBLANK_MODE_CLOCK {
self.mode_clock -= HBLANK_MODE_CLOCK;
self.scanline += 1;
if self.scanline == 143 {
if self.scanline == 144 {
self.enter_vblank(output);
interrupts.vblank = true;
} else {
@ -130,8 +131,9 @@ where
}
DrawMode::VBlank => {
// mode 1: vblank
if self.mode_clock >= 456 {
self.mode_clock = 0;
const VBLANK_MODE_CLOCK: usize = 456;
if self.mode_clock >= VBLANK_MODE_CLOCK {
self.mode_clock -= VBLANK_MODE_CLOCK;
self.scanline += 1;
if self.scanline == 153 {
self.exit_vblank(output);
@ -139,17 +141,19 @@ where
}
}
DrawMode::Mode2 => {
const MODE2_MODE_CLOCK: usize = 80;
// search oam for sprites on this line
// we dont really have to emulate this
if self.mode_clock >= 80 {
self.mode_clock = 0;
if self.mode_clock >= MODE2_MODE_CLOCK {
self.mode_clock -= MODE2_MODE_CLOCK;
self.stat.mode = DrawMode::Mode3;
}
}
DrawMode::Mode3 => {
const MODE3_MODE_CLOCK: usize = 172;
// generate scanline
if self.mode_clock >= 172 {
self.mode_clock = 0;
if self.mode_clock >= MODE3_MODE_CLOCK {
self.mode_clock -= MODE3_MODE_CLOCK;
self.enter_hblank(output);
}
}