Skip to content

Commit aa6e8ae

Browse files
committed
2026-05-14 19:54:20
1 parent cb5d0a1 commit aa6e8ae

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

src/gpu.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,6 @@ pub struct Gpu {
295295
// Extra dots to add to the mode3 threshold due to sprites on the current scanline.
296296
// Computed when mode2 fires; represents floor(T_penalty/4)*4 extra dots before mode0.
297297
sprite_penalty: u32,
298-
// Set when LCDC bit 7 transitions 0->1. Line 0 after LCD enable starts in Mode 0
299-
// (not Mode 2) and jumps directly to Mode 3 at dot 80.
300-
lcdon_first_line: bool,
301298
}
302299

303300
impl Gpu {
@@ -329,7 +326,6 @@ impl Gpu {
329326
prio: [(true, 0); SCREEN_W],
330327
dots: 0,
331328
sprite_penalty: 0,
332-
lcdon_first_line: false,
333329
}
334330
}
335331

@@ -868,7 +864,6 @@ impl Memory for Gpu {
868864
} else if !was_on {
869865
// LCD just enabled: line 0 starts in Mode 0, not Mode 2.
870866
// Evaluate LYC=LY coincidence for the initial display state.
871-
self.lcdon_first_line = true;
872867
self.stat.lyeq(self.ly == self.lc);
873868
self.sigq_update();
874869
}
@@ -993,8 +988,9 @@ impl Ticker for Gpu {
993988
}
994989
// Mode 2: OAM search (dots 0-79).
995990
if self.dots < 80 {
996-
if self.lcdon_first_line {
997-
// Line 0 after LCD enable: stay in Mode 0, skip Mode 2 entirely.
991+
// Line 0 after LCD enable: ly=0 and mode=0 (cleared at LCD-off) uniquely identify this case. Stay in
992+
// Mode 0, skip Mode 2 entirely.
993+
if self.stat.mode() == 0 && self.ly == 0 {
998994
continue;
999995
}
1000996
if self.stat.mode() == 2 {
@@ -1010,7 +1006,6 @@ impl Ticker for Gpu {
10101006
}
10111007
// Mode 3: Pixel transfer (dots 80-455, but may end early due to sprite penalty).
10121008
if self.dots <= (80 + 172 + ((self.sx as u32 % 8 + 3) / 4) * 4) - 4 + self.sprite_penalty {
1013-
self.lcdon_first_line = false;
10141009
self.stat.data = (self.stat.data & !0x03) | 3;
10151010
// Mode 3 has no STAT interrupt source; the signal may fall to LOW here
10161011
// unless LYC=LY keeps it high. Update to track any falling edge.

0 commit comments

Comments
 (0)