SearchA-ZJ › JSVecX

JSVecX

2010 Open source · GPL-3.0 Online

JSVecX is a JavaScript port of the VecX Vectrex emulator by raz0red, running the GCE Vectrex vector console entirely in-browser. It emulates the Motorola 6809, the 6522 VIA and the AY-3-8910 sound chip, and rasterises the machine's analog vector generator to an HTML5 canvas. With no cartridge inserted it boots the Vectrex system BIOS straight into the built-in Mine Storm game.

Visit the official site ↗

Runs on: Web browser

JSVecX Online Emulator

Play JSVecX using JavaScript directly in your browser.

Configurations

ConfigurationEmulatorMachineOSLegal
Mine StormJSVecXVectrexgreyOpen ⛶

Machines emulated

Chips

Notes

Embedding

jsvecx is a set of plain JavaScript files (no modules). Vendor them and load them in dependency order - utils, globals, the BIOS fastromdata, the e6809 CPU, the e8910 sound chip, the osint vector renderer, vector_t and vecx - but skip upstream's jQuery page driver. That driver owns a setTimeout loop and status UI that can't be paused or single-stepped, which the debugger needs. Instead replicate its main(): build the machine, point its renderer at a <canvas id="screen">, reset it, and drive it from a loop you control.

var vecx = new VecX();
vecx.osint.init(vecx);          // analog vector generator -> canvas#screen
vecx.e6809.init(vecx);          // 6809 core bound to the machine bus
vecx.vecx_reset();             // loads the BIOS; with no cart it boots Mine Storm
var CPF = (Globals.VECTREX_MHZ / 50) | 0;    // ~30000 cycles = one 50 Hz frame
(function loop(){ vecx.vecx_emu(CPF); requestAnimationFrame(loop); })();

The machine is plain objects. Everything the debugger needs is a method or field on the machine or its CPU:

MemberKindWhat it does
vecx.vecx_emu(cycles)methodRun the machine for cycles 6809 clocks, steps the CPU, the VIA timers and the vector generator, rendering when the phosphor budget expires. vecx_emu(1) runs exactly one instruction: the single-step primitive.
vecx.vecx_reset()methodReset the machine and reload the BIOS (and cartridge, if any).
vecx.read8(a) / vecx.write8(a,v)methodCPU bus read/write across cart, RAM, the VIA and the BIOS.
vecx.e6809fieldThe 6809: reg_pc, reg_a, reg_b, reg_dp, reg_cc (numbers) and reg_x/y/u/s (each an fptr whose .value is the 16-bit register).
vecx.e6809.e6809_sstep(irq,firq)methodExecute one 6809 instruction and return the cycles it took - what vecx_emu calls in its inner loop.
vecx.ram / vecx.rom / vecx.cartfieldThe 1K RAM, the 8K system BIOS and the 32K cartridge, as plain byte arrays, readable and pokeable live.
vecx.alg_jch0/1, vecx.snd_regs[14]fieldThe analog joystick axes and the button port, how input reaches the machine each frame.

Because the CPU and memory are ordinary JavaScript, the debugger single-steps with vecx_emu(1), reads and writes the registers directly on e6809, and implements breakpoints and watchpoints as host-side checks around the loop, no changes to the emulator.

Debugger integration

The debugger plug-in reads the live machine from window.EMU_BOOT and hands the shared framework a description of the Vectrex. Nothing is patched into the emulator; the whole surface is ordinary field access.

  • Registers are read straight off vecx.e6809 each refresh - A B D X Y U S DP PC CC plus the E F H I N Z V C condition flags decoded from reg_cc - and written back the same way.
  • Memory is exposed as four chips: a side-effect-free 64K CPU bus (the $C000–$DFFF VIA I/O window is skipped so auto-polling never trips a timer), plus the raw RAM, BIOS and cartridge. Disassembly uses the shared m6809 decoder.
  • Single step is vecx_emu(1) - one 6809 instruction with its VIA and video cycles.
  • Breakpoints are host-side: with any set, the loop steps one instruction at a time and compares e6809.reg_pc before each. Watchpoints wrap vecx.write8 and pause on a write to a watched address.
  • Input is a 4-button keypad plus the analog stick shown as a D-pad; press/release set the held-direction flags and the button port the run loop feeds to the machine each frame.

Architecture

The Vectrex is unusual: it has no framebuffer. A Motorola 6809 drives a 6522 VIA whose ports feed a set of integrators and a digital-to-analog converter that steer the electron beam directly, drawing crisp vectors on a tall built-in CRT. jsvecx keeps each block as its own object hanging off VecX:

  • e6809 - the Motorola 6809 core, single-stepped by e6809_sstep.
  • vecx - the machine: the 6522 VIA, its timers and shift register, the DAC/integrator maths that turn port writes into beam movement, and the read8/write8 bus.
  • osint - the "analog" vector generator: it accumulates drawn line segments and rasterises them to the 2D canvas, fading like phosphor.
  • e8910 - the General Instrument AY-3-8910 sound chip, played through Web Audio.
  • fastromdata - the 8K system BIOS, which contains the built-in Mine Storm game the console runs with no cartridge inserted.

Each vecx_emu chunk runs the 6809 while ticking the VIA and integrating beam motion, then hands the accumulated vectors to osint to draw - a complete, inspectable machine that boots straight to Mine Storm.