Skip to content

3.1.0

Latest

Choose a tag to compare

@bfirsh bfirsh released this 03 Dec 05:19
· 1 commit to main since this release
5ee394f

Highlights

JSNES 3.1 is a lot faster. It's about 5.5× faster than 3.0.0 on the bundled benchmark (about 6,300 fps on average, up from about 1,140), and roughly 2–3× faster on busier workloads with scrolling, sprites and sound. Accuracy is unchanged: frames and audio are bit-for-bit identical to 3.0.0, all 134 AccuracyCoin tests still pass, and save states from 3.0.0 still load.

The public API hasn't changed.

Performance

The cycle-accurate core from 3.0 is kept, but it skips work the CPU can't observe:

  • CPU: cycles that only touch RAM or PRG ROM, with no DMA, interrupt or PPU/APU event due, take a fast path that skips the per-cycle bookkeeping. Idle loops (including loops that poll $2002 waiting for VBlank or sprite 0) are fast-forwarded exactly to the next event.
  • PPU: whole visible lines are rendered in one step when nothing can disturb them. Background tiles are drawn a tile at a time from a lookup table, sprites are drawn in a separate pass over only the tiles that have sprites, and sprite evaluation uses a per-line cache. $2002 reads during rendering are answered from a prediction instead of catching up the PPU, when that's possible.
  • APU: silent square and noise channels and the idle DMC timer are advanced lazily, and audio output samples no longer force the APU to catch up.
  • Mappers: mappers without a scanline counter no longer schedule a PPU event every line, and MMC3 only runs the PPU in exact step for the scanline that raises its IRQ.
  • OAM DMA runs in one go when nothing else can happen during it.

Fixes

  • nes.reset() now power-cycles the console with the loaded ROM, the same as calling loadROM() again. Before, it rebuilt the hardware but didn't load the ROM into it, so the CPU ran from empty memory and crashed. Game Genie codes stay active across reset()/loadROM(), and loadROM() with an invalid file now leaves the current cartridge in place.
  • MMC1 (mapper 1): support for SUROM boards' 512 KB PRG bank selection, used by games such as Dragon Warrior III and IV (@SaveEditors).
  • Browser: fixed running too fast on high refresh rate monitors (@richwalm).