cfxnes (another browser-based emulator)

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
jonyzz
Posts: 6
Joined: Fri Jan 30, 2015 12:44 pm

cfxnes (another browser-based emulator)

Post by jonyzz » Fri Jan 30, 2015 1:43 pm

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.
Last edited by jonyzz on Wed Oct 28, 2015 12:49 pm, edited 5 times in total.

Grapeshot
Posts: 85
Joined: Thu Apr 14, 2011 9:27 pm
Contact:

Re: cfxnes (another browser-based emulator)

Post by Grapeshot » Fri Jan 30, 2015 7:25 pm

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.

jonyzz
Posts: 6
Joined: Fri Jan 30, 2015 12:44 pm

Re: cfxnes (another browser-based emulator)

Post by jonyzz » Sat Jan 31, 2015 8:19 am

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: Select all

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.

lidnariq
Posts: 10239
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: cfxnes (another browser-based emulator)

Post by lidnariq » Sat Jan 31, 2015 2:24 pm

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)

jonyzz
Posts: 6
Joined: Fri Jan 30, 2015 12:44 pm

Re: cfxnes (another browser-based emulator)

Post by jonyzz » Sat Jan 31, 2015 6:20 pm

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.

jonyzz
Posts: 6
Joined: Fri Jan 30, 2015 12:44 pm

Re: cfxnes (another browser-based emulator)

Post by jonyzz » Sun Feb 15, 2015 4:40 pm

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)

jonyzz
Posts: 6
Joined: Fri Jan 30, 2015 12:44 pm

Re: cfxnes (another browser-based emulator)

Post by jonyzz » Sun Feb 22, 2015 3:48 pm

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)

jonyzz
Posts: 6
Joined: Fri Jan 30, 2015 12:44 pm

Re: cfxnes (another browser-based emulator)

Post by jonyzz » Sun Apr 26, 2015 2:43 pm

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).

Post Reply