From ac0691e154d2e7329c75b9636bb815ab93ceb36a Mon Sep 17 00:00:00 2001 From: b4rtaz Date: Wed, 19 Oct 2022 23:53:08 +0200 Subject: [PATCH] improve frame loop performance. --- src/nes.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/nes.js b/src/nes.js index 1cdd30c..fc5e07b 100644 --- a/src/nes.js +++ b/src/nes.js @@ -109,6 +109,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 &&