cfxnes (another browser-based emulator)

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
cfxnes (another browser-based emulator)
by on (#140169)
Hi, CFxNES is emulator I've been working on for some time. It's written in JavaScript (ES6).

For more info see project page or changelog.
Live demo is running at http://cfxnes.herokuapp.com

Any comments are welcome. Thanks.
Re: cfxnes (another browser-based emulator)
by on (#140192)
Running my usual list of test games:
-Battletoads freezes after the intro. (That game is extremely timing sensitive.)
-Break Time doesn't work at all (probably this is due to a mistimed APU Frame IRQ or not waiting a frame before starting to set the PPU VBlank interrupt)
-Driar (homebrew game) doesn't work probably due to lack of support for undocumented CPU opcodes
-Slalom has lines that are displaced suggesting that you're using a PPU design that draws a whole line at a time. Sadly there's no way to deal with all the raster effects that the NES can do using a line at a time renderer.
-Shadow of the Ninja doesn't work

Turning off the triangle wave should leave it outputting its current value instead of resetting it to zero (this is the cause of a lot of popping sounds)
Similarly, changing the fine period or duty cycle on the square waves should not reset them. Changing the coarse period should reset the counters though.
Higher pitches are increasingly flat. Is there an off by one error on the counters for the square waves?
Resizing the window causes the audio pitch to change too. I know you're probably trying to compensate for framerate drops but it sounds terrible and takes a while to recover. You should run the APU for more cycles to fill the buffer instead.
Re: cfxnes (another browser-based emulator)
by on (#140229)
Grapeshot wrote:
-Driar (homebrew game) doesn't work probably due to lack of support for undocumented CPU opcodes

I implemented some of them, but not all.

Grapeshot wrote:
-Slalom has lines that are displaced suggesting that you're using a PPU design that draws a whole line at a time. Sadly there's no way to deal with all the raster effects that the NES can do using a line at a time renderer.

I'm actually using per-pixel rendering. I suspect there's a bug in my PPU scrolling implementation.

Grapeshot wrote:
Turning off the triangle wave should leave it outputting its current value instead of resetting it to zero (this is the cause of a lot of popping sounds)

You're right, that reduced the popping. However, I can still hear it. There must be something else I'm missing.

Grapeshot wrote:
Similarly, changing the fine period or duty cycle on the square waves should not reset them. Changing the coarse period should reset the counters though.

I'm only reseting the duty cycle and envelope during write to $4003/$4007.

Grapeshot wrote:
Higher pitches are increasingly flat. Is there an off by one error on the counters for the square waves?

I checked it and it seems to me it's right:
Code:
if --timerCycle <= 0
    # Duty period is 2 * 8 * (timerPeriod + 1) APU cycles
    timerCycle = (timerPeriod + 1) << 1
    dutyPosition = (dutyPosition + 1) & 0x7


Grapeshot wrote:
Resizing the window causes the audio pitch to change too. I know you're probably trying to compensate for framerate drops but it sounds terrible and takes a while to recover. You should run the APU for more cycles to fill the buffer instead.

You're right. I'm adjusting sampling rate to prevent audio buffer underflow/overflow and it's causing these transitions when framerate changes.
Re: cfxnes (another browser-based emulator)
by on (#140259)
Grapeshot wrote:
-Driar (homebrew game) doesn't work probably due to lack of support for undocumented CPU opcodes
Driar (both original SGROM and my NROM) use $8F (SAX), $B3 (LAX), and $CB (AXS). The NROM build additionally requires that RAM exist from $800-$895 (although it doesn't require that RAM be mirrored)
Re: cfxnes (another browser-based emulator)
by on (#140295)
lidnariq wrote:
Grapeshot wrote:
-Driar (homebrew game) doesn't work probably due to lack of support for undocumented CPU opcodes
Driar (both original SGROM and my NROM) use $8F (SAX), $B3 (LAX), and $CB (AXS). The NROM build additionally requires that RAM exist from $800-$895 (although it doesn't require that RAM be mirrored)


I've implemented AXS and Driar is now finally working. Thanks.
Re: cfxnes (another browser-based emulator)
by on (#141276)
Minor update:
- all CPU opcodes are implemented (emulator passes Blargg's instr_test and instr_timing tests)
- better PPU timing - the first level of Battletoads is now playable (the game freezes in the second level, though)
Re: cfxnes (another browser-based emulator)
by on (#141773)
Another update:
- fixed PPU scrolling implementation (games like Slalom or F-1 Race are now properly rendered)
- fixed VBlank/NMI timing (emulator passes ppu_vbl_nmi test)
- popping sounds should be now reduced (the cause was audio buffer overflow)
Re: cfxnes (another browser-based emulator)
by on (#146263)
Due to performance reasons, I rewrote the whole emulator from CoffeScript to JavaScript (ES6).
There should be noticable performance improvement in Firefox (emulation speed should be as fast as in Chrome).