Skip to content

Commit 1ac2fe0

Browse files
committed
Implement stats interrupt bug.
1 parent 377742d commit 1ac2fe0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

core/src/main/java/eu/rekawek/coffeegb/core/gpu/StatRegister.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ public boolean accepts(int address) {
160160
@Override
161161
public void setByte(int address, int value) {
162162
stat = (stat & 0b10000111) | (value & 0b01111000);
163+
164+
// Stats interrupt bug
165+
// see https://gbdev.io/pandocs/STAT.html#spurious-stat-interrupts
166+
if (!states.isEmpty() && !gpu.isGbc()) {
167+
var state = states.getLast();
168+
var mode = state.mode();
169+
if (mode == VBlank) {
170+
interruptManager.requestInterrupt(InterruptType.LCDC);
171+
}
172+
}
163173
}
164174

165175
@Override

0 commit comments

Comments
 (0)