SearchA-ZS › Sharp MZ-700

Sharp MZ-700

2016 MIT Online

This is mz700-js by Koji Takami, a full JavaScript emulator of the Sharp MZ-700, the Japanese Z80A home computer SHARP released in November 1982. It emulates the Z80A CPU, the banked memory, the 8253 timer, the 8255 keyboard/cassette interface and the character-cell colour display, and boots to the MZ-NEW MONITOR. This build wires it into the shared debugger, so you can single-step the Z80, set breakpoints and inspect memory, and type on a keyboard coloured like the real machine.

Visit the official site ↗

Runs on: Web browser

Sharp MZ-700 Online Emulator

Play Sharp MZ-700 using JavaScript directly in your browser.

Configurations

ConfigurationEmulatorMachineOSLegal
MZ-NEW MONITORSharp MZ-700Sharp MZ-700greyOpen ⛶

Machines emulated

Chips

Notes

Embedding

The emulator core is takamin/mz700-js (MIT), written in TypeScript. Upstream it runs inside a Web Worker and talks to a jQuery UI through transworker; that hides the Z80 from the debugger. So we bundle only the core classes into one browser global - MZ700 (the machine) and MZ700CanvasRenderer / MZ700CG (its character-cell screen) - and drive them ourselves on the main thread.

Boot. Build the character-generator screen, create the machine with a VRAM-update callback that paints cells, load the bundled MZ-NEW MONITOR ROM, reset, then run your own loop over z80.exec() (one Z80 instruction) plus mz.clock() (which ticks the 8253 timer chain that raises the vertical-blank interrupt):

var renderer = new MZ700CanvasRenderer();
renderer.create({ canvas: canvas, CG: new MZ700CG(MZ700CG.ROM, 8, 8) });
renderer.setupRendering();
var mz = new MZ700();
mz.create({ onVramUpdate: (i, code, attr) => renderer.writeVram(i, attr, code) });
mz.setMonitorRom(newmonBytes);           // 4K MZ-NEW MONITOR at $0000
mz.reset();
(function frame(){
  var t0 = mz.z80.consumedTCycle;
  while (mz.z80.consumedTCycle - t0 < PER_FRAME) { mz.z80.exec(); mz.clock(); }
  requestAnimationFrame(frame);
})();

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

MemberKindWhat it does
mz.z80.exec()methodExecute exactly one Z80 instruction. The single-step primitive; mz.clock() after it advances the timers.
mz.z80.regfieldThe live Z80 register file: .PC .SP .IX .IY .I .R and pair accessors getAF/getBC/getDE/getHL + setAF/… and getF/setF.
mz.z80.consumedTCyclefieldRunning T-state count, used to pace one video frame's worth of instructions.
mz.memory.peek(a) / .poke(a,v)methodThe 64 KB banked address space (monitor ROM, DRAM, text/attribute VRAM, MMIO). peek is used for a side-effect-free hex view.
mz.setKeyState(strobe, bit, down)methodSet one cell of the MZ-700 key matrix; the monitor scans it through the 8255 at $E000.
mz.reset()methodRe-bank the monitor, clear the screen and reset the Z80 (PC ← $0000).

Because the CPU, memory and key matrix are ordinary JavaScript, the debugger single-steps with z80.exec(), reads and writes registers straight off z80.reg, and implements breakpoints and watchpoints as host-side checks around the loop, no changes to the emulator core.

Debugger integration

The plug-in (mz700-debug.js) describes the machine to the shared debugger and nothing more:

  • Registers are read live from the Z80 core each refresh; the 16-bit pairs AF BC DE HL IX IY SP PC, the I/R bytes and the S Z H V N C flags - and written back through the same accessors.
  • Disassembly uses the shared z80 decoder over the full 64 KB, so the monitor ROM and any code you load read back as Z80 mnemonics.
  • Memory is mz.memory.peek, read side-effect-free; the $E000-$E7FF I/O window (8255 / 8253 / keyboard) is blanked so the auto-polling hex view never disturbs the timers.
  • Single step is one z80.exec(); breakpoints (on PC) and watchpoints (on a memory write) are host-side checks in the boot loop.
  • Keyboard. The physical keyboard is mapped character-accurately to the MZ-700 key matrix; an on-screen keyboard coloured like the real machine drives the same matrix for touch.

Architecture

The MZ-700 (SHARP, November 1982) is a cassette-based Z80A home computer with a character-cell display in eight colours and a single-voice beeper, with no bitmap graphics. This build keeps each part visible:

  • Z80A CPU at 3.58 MHz - the Sharp LH0080. The core interprets one instruction per exec(); the shared z80 decoder disassembles it.
  • Banked memory - 64 KB DRAM with the monitor ROM paged in over $0000-$0FFF and text VRAM ($D000) + attribute VRAM ($D800) + MMIO ($E000) paged over the top block, switched by OUT to ports $E0-$E6.
  • Intel 8253 programmable timer + an 8255 PIO - the 8253 divides the clock down to the 50 Hz vertical-blank interrupt and the sound tone; the 8255 at $E000 reads the key-matrix strobe and the cassette / cursor-blink status bits.
  • MZ-NEW MONITOR - a freely-redistributed compatible monitor ROM (Musashino Micro-computer Club) bundled by mz700-js; it prints the * prompt the machine boots to.

The character-cell screen is drawn from the MZ-700 character-generator font: every VRAM write repaints one 8×8 cell into the canvas, exactly as the video hardware scanned it.