Skip to content

Commit 361fb49

Browse files
raskyLukeUsher
authored andcommitted
n64: fix VI bug causing spinloop
VI_H_TOTAL is defined as the number of cycles per scanline *minus 1*. We forgot to add that 1 back. Besides the minor inaccuracy in timing, we could hit a race condition during initial VI config: if the Ares VI thread ran when the display was turned on (VI_CTRL configured) but VI_H_TOTAL wasn't already configured (and thus defaulted to 0), the thread would spinloop forever because it would step by 0 cycles. While fixing this, I also noticed that I wasn't properly taking into account leap timings because of a typo; this means that PAL timings were very slightly off. Fixes #2293
1 parent 90139d0 commit 361fb49

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ares/n64/vi/vi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ auto VI::main() -> void {
113113
}
114114
}
115115

116-
u32 lineDuration = io.quarterLineDuration;
116+
u32 lineDuration = io.quarterLineDuration+1;
117117
if(io.vcounter == 1)
118118
lineDuration = io.hsyncLeap[io.leapPattern.bit(io.leapCounter)];
119-
step(io.quarterLineDuration);
119+
step(lineDuration);
120120
} else {
121121
// Arbitrarily call screen->frame() every once in a while to keep the UI responsive.
122122
// We do that every 200 simulated lines of 0x800 quarter-clocks. This is just arbitrary,

0 commit comments

Comments
 (0)