SearchA-ZD › Dragon 32

Dragon 32

2026 Open source Online

Dragon 32 is a compact emulator built here in JavaScript around a genuine Motorola 6809 core, running the machine's own 16 KB Microsoft/Dragon Data BASIC ROM in the browser so it boots straight to the Dragon's signature green "OK" prompt with no downloads. The Dragon 32 and the Tandy Colour Computer share the same 6809, SAM, MC6847 VDG and MC6821 hardware, so the same core also runs Tandy Extended Color BASIC. Every register, chip and byte of memory is a plain JavaScript object, so the whole machine can be paused, single-stepped and inspected live in the shared debugger.

Runs on: Web browser

Dragon 32 Online Emulator

Play Dragon 32 using JavaScript directly in your browser.

Configurations

ConfigurationEmulatorMachineOSLegal
Dragon BASICDragon 32greyOpen ⛶
Color BASICDragon 32TRS-80 CoCo 1greyOpen ⛶

Machines emulated

Also emulates the Dragon 32 (the default configuration), which shares the same 6809 hardware as the Color Computer.

Chips

Notes

Embedding

There is no ready-made pure-JavaScript Dragon, so this build reuses the proven JavaScript Motorola 6809 core from JSVecX (e6809.js, itself a port of Valavan Manohararajah's e6809.c) and wraps a small Dragon 32 around it. The Dragon 32 and the Tandy Colour Computer are the same design, a 6809E, a SN74LS783 "SAM" address multiplexer, an MC6847 video display generator and two MC6821 PIAs, so the same machine serves both.

Boot. Give the 6809 a bus object with read8 / write8, point it at the 16 KB BASIC ROM at $8000, reset it (the reset vector at $FFFE reads $B3B4 from the top of the ROM) and drive it from a loop you own - one field is ~17,895 CPU clocks at 0.895 MHz / 50 Hz:

var cpu = new e6809();
cpu.init(machine);              // machine.read8 / machine.write8 = the bus
cpu.e6809_reset();             // PC <- read16($FFFE) = $B3B4 (ROM)
(function field(){
  pia0.crb |= 0x80;             // 50 Hz field-sync sets PIA0 CB1 (the BASIC timer IRQ)
  for (var c = 0; c < 17895; )
    c += cpu.e6809_sstep(irqLine(), firqLine());  // one instruction, returns its cycles
  render(); requestAnimationFrame(field);
})();

The machine is plain objects. Everything the debugger needs is a field or method. There is no wasm heap to reach into:

MemberKindWhat it does
cpu.e6809_sstep(irq, firq)methodExecute exactly one 6809 instruction with the current IRQ / FIRQ lines; returns its cycle count. The single-step primitive.
cpu.e6809_reset()methodReset the CPU - reloads PC from the $FFFE vector.
cpu.reg_a / reg_b / reg_dp / reg_cc / reg_pcfieldThe 8- and 16-bit registers as numbers; reg_x/y/u/s are boxed (.value holds the 16-bit register).
machine.read8(a) / write8(a,v)methodThe CPU bus: 32K RAM, the BASIC ROM, the two PIAs, the SAM registers and the interrupt vectors.
ram (32K) / rom (16K)fieldRaw byte arrays, readable and pokeable live.
pia0 / pia1fieldThe MC6821s: pia0 scans the keyboard and raises the 50 Hz IRQ; pia1 holds the VDG mode and the 6-bit sound DAC.

Because the CPU, bus and RAM are ordinary JavaScript, the debugger single-steps with e6809_sstep, reads and writes registers straight off cpu, and implements breakpoints and watchpoints as host-side checks around the loop, no changes to the reused core.

Debugger integration

The plug-in (dragon-debug.js) reads the live machine from window.EMU_BOOT and hands the shared framework a description of the Dragon. Nothing is patched into the emulator; the whole surface is ordinary field access.

  • Registers are read straight off cpu 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. Single-step and watch them change.
  • Memory is three chips: a side-effect-free 64K CPU bus (the $FF00–$FFDF I/O window is skipped so an auto-refreshing hex view never clears a PIA interrupt flag), the raw 32K RAM and the 16K BASIC ROM. Disassembly uses the shared m6809 decoder.
  • Single step is e6809_sstep - one 6809 instruction with its correct IRQ handling.
  • Breakpoints are host-side: with any set, the loop steps one instruction at a time and compares cpu.reg_pc before each. Watchpoints wrap the bus write path and pause on a write to a watched address.
  • Input is the real Dragon key matrix: the physical keyboard maps each character to a matrix cell, and an on-screen Dragon keyboard drives the same cells for touch.

Architecture

The Dragon 32 is a clean 6809 machine, and this build keeps each block as its own object:

  • e6809 - the Motorola 6809 core (reused from JSVecX), single-stepped by e6809_sstep.
  • Bus - 32K RAM at $0000, the 16K Microsoft/Dragon Data BASIC ROM at $8000, an empty cartridge slot at $C000, the PIAs and SAM in the $FF00 page, and the interrupt vectors mapped from the top of the ROM.
  • MC6821 PIAs - pia0 reads the 8×7 keyboard matrix (columns out on port B, rows in on port A) and turns the MC6847 field-sync into the 50 Hz IRQ that drives the BASIC timer; pia1 carries the VDG mode bits and the single-/six-bit sound port.
  • SN74LS783 SAM - its display-offset (F) and mode (V) register pairs set where and how the screen is fetched; the text screen sits at $0400.
  • MC6847 VDG - the built-in alphanumeric mode is rendered to the canvas as 32×16 green-on-black (in fact black-on-green: BASIC stores every character in inverse video, which is the Dragon's signature green screen). Each byte is a 6-bit character code with an inverse bit and a semigraphics bit.

With no cartridge and no disk, the reset routine sizes the 32K, prints its copyright banner and drops to OK - a complete, inspectable machine that boots straight to BASIC.