finally fixed the bottom scanline LMAO
This commit is contained in:
parent
09e0d83e97
commit
a487264f40
1 changed files with 13 additions and 9 deletions
|
@ -117,10 +117,11 @@ where
|
||||||
match self.stat.mode {
|
match self.stat.mode {
|
||||||
DrawMode::HBlank => {
|
DrawMode::HBlank => {
|
||||||
// mode 0: hblank
|
// mode 0: hblank
|
||||||
if self.mode_clock >= 204 {
|
const HBLANK_MODE_CLOCK: usize = 204;
|
||||||
self.mode_clock = 0;
|
if self.mode_clock >= HBLANK_MODE_CLOCK {
|
||||||
|
self.mode_clock -= HBLANK_MODE_CLOCK;
|
||||||
self.scanline += 1;
|
self.scanline += 1;
|
||||||
if self.scanline == 143 {
|
if self.scanline == 144 {
|
||||||
self.enter_vblank(output);
|
self.enter_vblank(output);
|
||||||
interrupts.vblank = true;
|
interrupts.vblank = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -130,8 +131,9 @@ where
|
||||||
}
|
}
|
||||||
DrawMode::VBlank => {
|
DrawMode::VBlank => {
|
||||||
// mode 1: vblank
|
// mode 1: vblank
|
||||||
if self.mode_clock >= 456 {
|
const VBLANK_MODE_CLOCK: usize = 456;
|
||||||
self.mode_clock = 0;
|
if self.mode_clock >= VBLANK_MODE_CLOCK {
|
||||||
|
self.mode_clock -= VBLANK_MODE_CLOCK;
|
||||||
self.scanline += 1;
|
self.scanline += 1;
|
||||||
if self.scanline == 153 {
|
if self.scanline == 153 {
|
||||||
self.exit_vblank(output);
|
self.exit_vblank(output);
|
||||||
|
@ -139,17 +141,19 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawMode::Mode2 => {
|
DrawMode::Mode2 => {
|
||||||
|
const MODE2_MODE_CLOCK: usize = 80;
|
||||||
// search oam for sprites on this line
|
// search oam for sprites on this line
|
||||||
// we dont really have to emulate this
|
// we dont really have to emulate this
|
||||||
if self.mode_clock >= 80 {
|
if self.mode_clock >= MODE2_MODE_CLOCK {
|
||||||
self.mode_clock = 0;
|
self.mode_clock -= MODE2_MODE_CLOCK;
|
||||||
self.stat.mode = DrawMode::Mode3;
|
self.stat.mode = DrawMode::Mode3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawMode::Mode3 => {
|
DrawMode::Mode3 => {
|
||||||
|
const MODE3_MODE_CLOCK: usize = 172;
|
||||||
// generate scanline
|
// generate scanline
|
||||||
if self.mode_clock >= 172 {
|
if self.mode_clock >= MODE3_MODE_CLOCK {
|
||||||
self.mode_clock = 0;
|
self.mode_clock -= MODE3_MODE_CLOCK;
|
||||||
self.enter_hblank(output);
|
self.enter_hblank(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue