npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nes-emu

v1.0.20

Published

A NES emulator

Downloads

49

Readme

NesCore

A NES Emulator made in JavaScript for educational purposes. Try it!

It's main objective is to reflect the NES internals as simply as possible by using clean, object-oriented code. It doesn't have any complex bitwise operations, huge switch-case statements or files with lots of magic numbers.

⚠️ This is not a cycle-accurate emulator and performance is not the main concern ⚠️

Features

  • 👾 It emulates the NES
  • 👨‍🔧 It plays Super Mario Bros. 3!
  • 💻 CPU
    • All official instructions are implemented
    • nestest passes ✔️
  • Fully functional 🖥️ PPU and 🔊 APU
  • 🔌 Supported mappers
  • 🐏 SRAM support
  • 💾 Save states support
  • 🌎 Web frontend using Web Workers and Gamepad API

Usage

npm install --save nes-emu

// configure video and audio:
const onFrame = (frameBuffer) => {
  // write `frameBuffer` (an Uint32Array) to screen...
};
const onSample = (sample) => {
  // write `sample` (a number) to audio buffer...
};

// create an instance:
const nes = new NES(onFrame, onSample);

// load a game:
nes.load(rom); // rom = Uint8Array

// run at 60 fps, or as fast as you can:
{
  nes.setButton(1, "BUTTON_A", true); // player = 1, button = A, pressed = true
  nes.setButton(2, "BUTTON_DOWN", false); // player = 2, button = DOWN, pressed = false
  // ...set the rest of the buttons
  nes.frame();
}

// save / restore states:
const saveState = nes.getSaveState();
nes.setSaveState(saveState);

👀 Have a look at the demo implementation for more details. When running the demo (npm start) you can add ?debug to the URL to enable a global window.debug object.

Full API

| Method | Parameters | Description | | --------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | constructor | onFrame, onSample, logger | Creates an emulator's instance. All properties can be set at any time. | | load | rom, saveFileBytes | Loads a ROM. If a saveFileBytes array is provided, it sets the SRAM content. | | frame | | Runs the emulation for a whole video frame. | | samples | requestedSamples | Runs the emulation until the audio system generates requestedSamples. | | scanline | | Runs the emulation until the next scanline. | | setButton | player, button, isPressed | Sets the button state of player to isPressed. The button can be one of: ["BUTTON_A", "BUTTON_B", "BUTTON_SELECT", "BUTTON_START", "BUTTON_UP", "BUTTON_DOWN", "BUTTON_LEFT", "BUTTON_RIGHT"] | | clearButtons | player | Sets all buttons of player to a non-pressed state. | | getSaveFile | | Returns an array with the SRAM bytes, or null. | | getSaveState | | Returns an object with a snapshot of the current state. | | setSaveState | saveState | Restores a saveState. |

Screenshots

nestest screenshot

Useful links