Skip to content

Commit

Permalink
Improve frame loop performance
Browse files Browse the repository at this point in the history
  • Loading branch information
lrusso committed Aug 22, 2024
1 parent e6edb06 commit 1667b31
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/nes.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ NES.prototype = {
}
}

var finalCurX = ppu.curX + cycles;
if (
!ppu.requestEndFrame &&
finalCurX < 341 &&
(ppu.spr0HitX < ppu.curX || ppu.spr0HitX >= finalCurX)
) {
ppu.curX = finalCurX;
continue FRAMELOOP;
}

for (; cycles > 0; cycles--) {
if (
ppu.curX === ppu.spr0HitX &&
Expand Down

0 comments on commit 1667b31

Please sign in to comment.