Browser Emulators for ZENBASIC Console Integration
This document catalogs available browser-based emulators for potential integration with the ZENPOWER Console's machine profiles.
Overview
The ZENBASIC Console currently has 20 machine profiles defined in VMSettings.ts. These profiles define CPU, memory, display, audio, and BASIC dialect specifications. To enable full system emulation (boot ROMs, OS loading, disk access), we can integrate existing browser emulators.
Integration Strategy Options
Option 1: EmulatorJS (Unified Solution)
Recommendation: Best for consistency and maintenance
EmulatorJS is a web-based frontend for RetroArch compiled to WebAssembly. It supports 30+ systems with a unified interface.
Supported relevant systems:
- Commodore 64, VIC-20 (vice_x64, vice_xvic cores)
- Atari 2600, 5200, 7800, Lynx, Jaguar
- MSX, MSX2
- Amstrad CPC
- Sega systems (SMS, Genesis/MD, Game Gear, Saturn, 32X)
- Nintendo systems (NES, SNES, N64, GB, GBA, NDS)
Pros:
- Single codebase, consistent API
- Active maintenance (updated Dec 2025)
- Self-hostable
- Unified save state/control mapping
Cons:
- Large download size (~5-50MB per core)
- Some systems have better standalone emulators
Option 2: Best-of-Breed (Per-System)
Recommendation: Best for accuracy and features
Use specialized emulators for each platform:
Commodore Systems
C64/C128: vc64web
- URL: https://vc64web.github.io/
- Source: Based on VirtualC64 (GPLv3)
- Features: Cycle-accurate, SID emulation, disk/tape support
- ROM Required: Yes (Kernal, BASIC, Character ROMs)
- Integration: iframe or WebAssembly module
C64/C128: VICE.js
- URL: https://rjanicek.github.io/vice.js/
- Source: VICE emulator compiled with Emscripten
- Features: Full VICE functionality, multiple machines (C64, C128, VIC-20, PET, Plus/4)
- ROM Required: Yes (included in some builds)
VIC-20: JS VIC-20
- URL: https://www.mdawson.net/vic20chrome/vic20.php
- Author: Matt Dawson
- Features: Pure JavaScript, no plugins
- Best For: Quick integration, lightweight
Amiga Systems
SAE - Scripted Amiga Emulator
- URL: https://scriptedamigaemulator.net/
- Source: Pure JavaScript
- Features: A500, A1200 emulation, ADF disk support
- ROM Required: Yes (Kickstart ROMs)
- Status: Most mature browser Amiga emulator
vAmigaWeb
- URL: https://vamigaweb.github.io/
- Source: vAmiga compiled to WebAssembly
- Features: Cycle-exact emulation, modern codebase
- ROM Required: Yes (Kickstart 1.3/3.1)
Atari Systems
Atari 800/XL: jsA8E
- URL: https://eahumada.github.io/AtariOnline/
- Source: A8E ported via Emscripten
- Features: Full Atari 800 XL emulation, joystick support
- ROM Required: Yes (OS ROMs)
- Controls: F1=HELP, F2=OPTION, F3=SELECT, F4=START, F5=RESET
Atari ST: pce.js / EstyJS
- URL (pce.js): http://jamesfriend.com.au/pce-js/atari-st/
- URL (EstyJS): https://estyjs.azurewebsites.net/
- Features: TOS boot, GEM desktop
- ROM Required: Yes (TOS ROMs)
British Systems
BBC Micro/Acorn: jsbeeb
- URL: https://bbc.xania.org/
- Source: https://github.com/mattgodbolt/jsbeeb
- Author: Matt Godbolt
- Features: BBC B, BBC Master 128, Acorn Atom
- ROM Required: Included (legal OS ROMs)
- Quality: Excellent - cycle-accurate, USB gamepad support
ZX Spectrum: JSSpeccy 3
- URL: https://jsspeccy.zxdemo.org/
- Source: WebAssembly core
- Features: 48K, 128K, Pentagon, fast loading
- ROM Required: Yes (Spectrum ROM)
- Quality: Excellent - modern WASM implementation
Amstrad CPC: CPCBox
- URL: https://retroshowcase.gr/cpcbox-master/
- Features: CPC 464, 6128 emulation
- ROM Required: Distributed with permission from Amstrad
Other Systems
MSX/MSX2: WebMSX
- URL: https://webmsx.org/
- Source: Pure JavaScript
- Features: MSX, MSX2, MSX2+ with NetPlay, extensive peripheral support
- ROM Required: Uses open-source CBIOS by default
- Quality: Best-in-class MSX emulator for browser
Apple II: apple2js
- URL: https://www.scullinsteel.com/apple2/
- Source: TypeScript
- Features: Apple II, II+, IIe, disk support
- ROM Required: Yes
TRS-80: trs80-emulator
- URL: https://lkesteloot.github.io/trs80/
- Source: https://github.com/lkesteloot/trs80
- Features: Model I, Model III, TypeScript
- ROM Required: Yes
ROM Legality Note
Most emulators require original ROM files to function. Options:
- User-provided ROMs - User uploads their own legally obtained ROMs
- Open-source alternatives - CBIOS for MSX, OpenROM for some systems
- Licensed distribution - Amstrad has given blanket permission for CPC ROMs
- Abandonware - Some ROMs are effectively abandoned (legal gray area)
Recommended approach: Provide emulator shell, let users supply ROMs via drag-and-drop.
Integration Architecture
┌─────────────────────────────────────────────────────────────┐
│ ZENBASIC Console │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Machine Selector │ │
│ │ MACHINE C64 | MACHINE AMIGA500 | MACHINE SPECTRUM │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ │
│ ┌───────────────┼───────────────┐ │
│ ▼ ▼ ▼ │
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │ ZENBASIC │ │ Full Emu │ │ Hybrid │ │
│ │ Mode │ │ Mode │ │ Mode │ │
│ │(current) │ │(external) │ │ (bridge) │ │
│ └───────────┘ └───────────┘ └───────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ZenCPU.ts iframe/WASM PEEK/POKE │
│ (6502-like) (real 6502) Interceptor │
└─────────────────────────────────────────────────────────────┘
Mode 1: ZENBASIC Mode (Current)
- Uses ZenCPU.ts (6502-compatible emulator)
- Runs BASIC programs with ZEN extensions
- Fast startup, integrated with Zenpower API
Mode 2: Full Emulation Mode (New)
- Loads external emulator (EmulatorJS or standalone)
- Boots actual ROM, runs real software
- User provides ROM files
- Command:
BOOT C64orEMU AMIGA500
Mode 3: Hybrid Mode (Future)
- ZENBASIC interpreter with pass-through to real hardware emulation
- PEEK/POKE operations route to actual emulated memory
- Best of both worlds
Implementation Plan
Phase 1: EmulatorJS Integration
- Add EmulatorJS as optional dependency
- Create
EmulatorBridge.tswrapper class - Add
BOOT <machine>command to launch full emulation - Store user-provided ROMs in IndexedDB
Phase 2: Premium Standalone Emulators
- Integrate jsbeeb for BBC Micro (excellent quality, included ROMs)
- Integrate WebMSX for MSX (open CBIOS, best features)
- Integrate JSSpeccy for Spectrum (WASM performance)
Phase 3: Hybrid Mode
- Create memory bridge between ZENBASIC and emulator
- Allow ZENBASIC programs to interact with emulated hardware
- Enable "turbo" mode for BASIC programs
File Size Estimates
| Emulator | Core Size | With ROMs |
|---|---|---|
| EmulatorJS (per core) | 2-10 MB | +0.5-2 MB |
| jsbeeb | ~500 KB | Included |
| WebMSX | ~800 KB | CBIOS included |
| JSSpeccy | ~300 KB | +16 KB ROM |
| SAE | ~2 MB | +512 KB ROM |