Skip to content

Commit

Permalink
[md] accurate duration of Z80 IRQ signaled by VDP
Browse files Browse the repository at this point in the history
  • Loading branch information
TascoDLX authored and Screwtapello committed Mar 19, 2021
1 parent acafe5c commit 3416d74
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions higan/md/vdp/vdp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,13 @@ auto VDP::main() -> void {
scanline();

cpu.lower(CPU::Interrupt::HorizontalBlank);
apu.setINT(false);

if(state.vcounter == 0) {
latch.horizontalInterruptCounter = io.horizontalInterruptCounter;
io.vblankIRQ = false;
cpu.lower(CPU::Interrupt::VerticalBlank);
}

if(state.vcounter == screenHeight()) {
if(io.verticalBlankInterruptEnable) {
io.vblankIRQ = true;
cpu.raise(CPU::Interrupt::VerticalBlank);
}
//todo: should only stay high for ~2573/2 clocks
apu.setINT(true);
}

if(state.vcounter < screenHeight()) {
while(state.hcounter < 1280) {
run();
Expand All @@ -74,6 +64,19 @@ auto VDP::main() -> void {
}

step(430);

} else if(state.vcounter == screenHeight()) {
if(io.verticalBlankInterruptEnable) {
io.vblankIRQ = true;
cpu.raise(CPU::Interrupt::VerticalBlank);
}

// only stay high for ~2573/2 clocks
apu.setINT(true);
step(2573/2);
apu.setINT(false);
step(1710-(2573/2));

} else {
step(1710);
}
Expand Down

0 comments on commit 3416d74

Please sign in to comment.