Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pet2001web

The Commodore PET emulator behind PET Project's play page.

This is an adaptation of Thomas Skibo's JavaScript PET 2001 emulator (skibo/skibo.github.io, 6502/pet2001, vendored at commit 6759471ee31fb97ed8f75b9c7ed88f5f77226411), BSD-2-Clause. Skibo notes that Norbert Landsteiner maintains a much-extended version at masswerk.at/pet — if you want a full-featured in-browser PET, use that one. This repo stays minimal on purpose: it boots a ROM 4.0 / 32K / 40-column PET, loads a .prg from a URL, types RUN, and plays the CB2 sound. That's all the play page needs.

What was added

  • js/petloader.js — DOM-free .prg loading, READY-detection, RUN injection
  • js/cb2audio.js — VIA CB2 shift-register bit stream → Web Audio. The downsampler runs on the main thread and posts finished PCM to an AudioWorklet (js/cb2worklet.js, loaded at runtime via addModule); browsers without AudioWorklet fall back to the deprecated ScriptProcessorNode
  • js/petplayer.js — mounts canvas + keyboard, boots, drives the above. Keys are held on the PET matrix from keydown to keyup (reusing petkeys.js's mapping tables), so a held game key doesn't stutter on the OS repeat delay. The canvas is focusable and takes focus on boot; key handling is gated on it holding focus, so the host page keeps its own keyboard when it isn't playing
  • index.html — bare harness: ?prg=<url> boots a program
  • test/ — headless Node tests (node --test)
  • Seven patches to the vendored core, each marked // pet2001web:, across five files — bus accessors and an audio-sink setter (pet2001.js), an IO getter (pet2001hw.js), a per-cycle CB2 hook and its call site (pet2001io.js), the green-phosphor recolor (pet2001video.js, two sites) and a ROM 4 set regenerated from VICE's 4032 images (pet2001roms.js — see ROMs below)

ROMs

js/pet2001roms.js embeds Commodore PET ROM images (BASIC 1/2/4, editor, character generator). The ROM 1 and 2 images and both character generators are upstream's. The ROM 4 set is regenerated from VICE's PET 4032 images — basic-4.901465-23-20-21, edit-4-40-n-60Hz.901499-01 and kernal-4.901465-22 — by tools/make-petrom4.mjs, because upstream's ROM-4 editor stores a raw keyboard matrix index at $97 where the 4032 editor stores the decoded PETSCII that the demos read. That makes the emulated ROM-4 machine ROM-identical to the pet4032 the demos are built against. These are Commodore's historical firmware, not ours and not BSD-licensed — see LICENSE. The PET-Project repo itself contains no ROM images.

Running locally

python3 -m http.server 8080
# then open http://localhost:8080/?prg=<url-of-a-.prg>

Tests

node --test

About

JS Commodore PET emulator (adapted from Thomas Skibo's) behind PET Project's browser play page

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages