Sharp X1
The Sharp X1 (1982) is a Japanese Z80A home computer, built around a Zilog Z80A with a Hitachi 6845 CRTC driving a 40 or 80 column text screen over a separate bitmap layer, an AY-3-8910 sound chip, and an 80C49 sub-processor handling the keyboard, cassette and clock. It is a "clean computer": there is no ROM BASIC, so the small IPL ROM only bootstraps a program from tape or disk.
This is a purpose-built pure-JavaScript machine — the MIT-licensed DrGoldfire Z80 interpreter paired with a from-scratch X1 board (IPL/RAM overlay, the text and attribute VRAM, the 6845 CRTC, the 8255 PPI and the keyboard sub-CPU) written for emulators.org — so the whole Z80 is single-steppable, register-editable and breakpointable in the shared in-page debugger. With no media the IPL comes up on a driver-select menu and offers a built-in machine-language monitor with a "*" prompt.
Runs on: Web browser
Sharp X1 Online Emulator
Play Sharp X1 using JavaScript directly in your browser.
Controls
Configurations
| Configuration | Emulator | Machine | OS | Legal | |
|---|---|---|---|---|---|
| Sharp X1 (IPL) | Sharp X1 | Sharp X1 | grey | Open ⛶ |
Chips
Notes
Embedding
The Sharp X1 is a "clean computer": it has no ROM BASIC, only a small IPL ROM that bootstraps a program from tape or disk. This build drives a from-scratch X1 board (sharp-x1.js) around Molly Howell's MIT Z80.js — the same vendored Zilog Z80 core this site reuses for its other Z80 machines. The board is modelled on MAME's src/mame/sharp/x1.cpp; the whole machine runs from a host-owned loop, so the debugger can pause and single-step it.
Boot. Constructing the machine fetches the IPL ROM and the 8×8 character-generator font, resets the Z80 with the IPL overlaid over 0x0000-0x7FFF, and starts the loop. The IPL programs the 6845 CRTC (WIDTH40), clears the text and attribute VRAM, finds no drive ready, and paints its menu:
var m = new SharpX1({ canvas, romBase, iplFile, fontFile });
m.boot(); // fetch IPL + font, reset the Z80, run
// each animation frame runs one 60Hz field of Z80 time, then draws the text screen
The machine object. Everything the host and debugger need is a field or method on the machine:
| Member | Kind | What it does |
|---|---|---|
m.cpu | field | The Zilog Z80 core. Registers are read with getReg(name) / written with setReg(name,v) for A F B C D E H L, the AF/BC/DE/HL pairs, IX IY SP PC, and I R. |
m.dbgRead(a) / m.dbgWrite(a,v) | method | Side-effect-free read of the 64K bus and the CPU write path — what the debugger's memory views read and poke. |
m.keyDown(ascii) / m.keyUp() | method | Set or clear the currently-held key; the 80C49 sub-CPU returns it to the IPL keyboard routine. |
EMU_BOOT.transport | field | The pause / resume / step / breakpoint / watchpoint surface the shared debugger drives. |
Video. The X1's text screen is two parallel 2 KB planes in the Z80 I/O space: character codes at 0x3000 and per-cell attributes at 0x2000 (written a byte at a time with OUT (C),A, since the X1 addresses I/O with the full 16-bit BC). The renderer draws a 40×25 grid of 8×8 cells through the character-generator ROM; the attribute's low three bits pick one of eight digital colours, and the software cursor toggles the highlight bit.
Debugger integration
Because the whole board is ordinary JavaScript and the host owns the run loop, the debugger's controls need no changes to the CPU core: the loop can pause, single-step and check breakpoints between any two instructions. window.EMU_BOOT.transport maps the shared debugger onto the Z80:
- pause / resume / isPaused — stop or restart the
requestAnimationFrameloop. - stepInsn(n) — run exactly n Z80 instructions through the core's
run_instruction()entry. - step(n) — advance n whole 60 Hz fields of Z80 time.
- breakpoints — a
Setof PC values checked before each instruction; a match pauses before the instruction runs. - watchpoints — the Z80's memory-write path flags a hit when a watched address is written, and the loop pauses on it.
The stock Z80.js keeps its registers in a closure and only exposes a whole-core getState()/setState(). The vendored core carries two extra hooks — get_pc() and set_pc() — so the run loop can read PC before every instruction (for breakpoints) without allocating a state object, and the machine wraps getState/setState in focused getReg/setReg/getFlag/setFlag helpers that the plug-in binds to. Memory reads use the machine's side-effect-free dbgRead, which returns the IPL ROM under the reset overlay and the work RAM without touching the I/O side, so inspecting memory never disturbs the video or keyboard hardware. Two extra memory views expose the text-code (0x3000) and attribute (0x2000) VRAM planes, which live in the I/O space rather than on the CPU bus. The Z80 disassembler is the shared decoder at /debugger/src/cpus/z80.js, reused unchanged.
Architecture
The Sharp X1 (SHARP, 1982) is a Z80A home computer whose CPU, video and PSG were kept as separate, cleanly-addressed hardware. This build models the parts the IPL needs to reach its prompt:
- Z80A CPU at 4 MHz. The core interprets one instruction per
run_instruction(); the sharedz80decoder disassembles it. The X1 addresses I/O with the full 16-bitBC, so every device sits at a 16-bit port. - Memory overlay — 64 KB of work RAM with the IPL ROM overlaid over
0x0000-0x7FFFat reset; writes always land in RAM, and a write to port0x1E00pages the ROM out so loaded code runs from RAM. - 6845 CRTC at
0x1800/0x1801— the IPL loads its register set for a 40-column, 25-row text display. - Text hardware — a character-code plane at I/O
0x3000and an attribute plane at0x2000, rendered through the 8×8 ANK character-generator ROM into eight digital colours. - 8255 PPI at
0x1A00-0x1A03and the 80C49 sub-CPU at0x1900— the keyboard is read by writing command0xE6to the sub-CPU and reading the key code back through the PPI handshake; the sub-CPU also handled the cassette and clock. - IPL ROM — a clean-room, CC0 compatible loader that, finding no drive ready, shows a driver-select menu and offers a small machine-language monitor with a
*prompt (dump, edit, jump, go). The 8×8 font is a free Misaki-derived character generator.
A real X1 reaches Hu-BASIC or CP/M only by loading it from a cassette or floppy; with no media the IPL's own menu and monitor are what the machine presents.