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

np2-wasm

v0.1.1

Published

PC-98x1 emulator for the Web.

Downloads

1

Readme

np2-wasm

This is a PC-9801 / PC-9821 emulator based on Neko Project II that runs in a web browser.

Demo

https://irori.github.io/np2-wasm/

How to Use

example.html:

<!DOCTYPE html>
<html>
 <body>
  <canvas id="canvas"></canvas> <!-- The screen will be drawn on this canvas -->
  <script type="module" src="example.js"></script>
 </body>
</html>

example.js:

import { NP2, NP21 } from "https://unpkg.com/np2-wasm/dist/np2-wasm.js";

// Create an NP2 instance specifying a canvas
const canvas = document.getElementById('canvas');
// Change this to NP21.create() if i386 emulation is needed
const np2 = await NP2.create({ canvas });

// Load a floppy disk image
const resp = await fetch('image.d88');
const data = new Uint8Array(await resp.arrayBuffer());
np2.addDiskImage('image.d88', data);

// Set the disk image to FD drive 0
np2.setFdd(0, 'image.d88');

// Run the emulator
np2.run();

API

NP2.create(config: NP2Config): Promise<NP2>

Creates a new instance of NP2. config is an object that has the following attributes:

canvas: HTMLCanvasElement

The <canvas> element that displays the screen of the emulator.

onDiskChange: (name: string) => void

A callback function that is called when a write operation is performed to the disk image. The modified image can be retrieved with the getDiskImage() method.

onExit: () => void

A callback called when the emulator is powered off. After exit, you can restart the emulator with reset().

clk_base: number (default=2457600)

Specifies the base clock (Hz) of the CPU. Either 1996800 or 2457600 can be specified.

clk_mult: number (default=4)

Specifies the multiplication factor for the CPU. The actual CPU speed will be the product of this value and the base clock.

Latencys: number (default=250)

Specifies the output buffer size for the sound emulator in milliseconds. Please specify a number between 20 and 1000 ms. A smaller value will shorten the delay of the sound, but it will require more CPU power.

use_menu: boolean (default=true)

Show the Neko Project II menu on middle-click or F11.

NP21.create(config: NP2Config): Promise<NP21>

Same as NP2.create(), but this will create an instance of the PC-9821 emulator NP21.

state: 'ready' | 'running' | 'paused' | 'exited'

Returns the current state of the emulator.

run(): void

Starts the emulator.

reset(): void

Resets the emulator.

addDiskImage(name: string, bytes: Uint8Array): void

Adds a disk image to the emulator.

getDiskImage(name: string): Uint8Array

Returns the current content of the disk image.

setFdd(drive: number, name: string | null): void

Sets a disk image to the floppy disk drive of the emulator. drive is the drive number (0 or 1), name is the disk name specified in addDiskImage.

setHdd(drive: number, name: string | null): void

Sets a disk image to the hard disk drive of the emulator. drive is the drive number (0 or 1), name is the disk name specified in addDiskImage. If this method is called after running run(), the effect is not reflected until reset() is called.