SAM Coupé emulator and Z80 IDE
A SAM Coupé in your browser — the 6 MHz Z80 with memory contention, all four screen modes, the 128-colour palette, line interrupts, LMPR/HMPR/VMPR paging, SAA1099 stereo sound, the keyboard and mouse, and MGT/SAD/DSK disks through a VL1772 — booting SAM ROM 3.0 to SAM BASIC, with a Z80 assembler, examples (mode 4 palette cycling, raster bars, SAA1099 music) and a debugger.
Added
How to use it
Press Power on, or just Assemble & run in the Code & debug tab. The SAM boots SAM ROM 3.0 to its colour bars and "© 1990 SAM Coupé"; a key clears them and SAM BASIC is waiting. Click the screen to give it the keyboard.
How to use it
-
Code & debug — pick an example and press Assemble & run (Ctrl/⌘+Enter): printing through the ROM, mode 4 with palette cycling, raster bars from line interrupts, Ode to Joy on the SAA1099, mode 3’s 512 pixels, and the keyboard matrix. Programs start at
ORG $8000: the page loads them at 32768 (RAM page 1) and calls them the wayCALL 32768does from BASIC — page 1 in section C, ROM 1 in section D — so the same code runs on a real SAM.RETreturns to BASIC with every register put back. The graphics examples show how to page the screen into sections A and B and give it back. -
BASIC examples in the same list (circles and
PALETTE,SOUND) are typed into SAM BASIC, and so is anything in the Type text tab. -
Breakpoints and stepping — click a line number to set a breakpoint, right-click it to run to it; Run/Continue (F5), Pause (F6), Step (F11), Step over (F10), Step out (Shift+F11), Run to cursor (Ctrl+F10). The panel beside the editor shows the registers (type to change one), the flags, the code at PC with ROM routines named, the stack and watches; the Debugger tab has the frame line and T-state, both interrupt lines, a longer disassembly and memory.
-
Disks — drop an
.MGT,.SADor.DSKimage on the screen: it goes in drive 1 and the page typesBOOT. The ROM loads the DOS from track 4 of the disk, which then runs the disk’sautofile. The Disks tab lists the SAMDOS directory and can load a CODE or SCREEN$ file straight into memory (and call it) for disks without a DOS. Save to disk adds your program as a CODE file; Download .MGT saves the disk, changes included. -
Screen & paging shows the mode, LMPR, HMPR, VMPR, the CLUT and the 128 colours; SAA1099 the sound chip’s registers as frequencies and envelopes.
The assembler is this site’s Z80 assembler. Predefined: the ROM’s
jump table from the Technical Manual (JSETSTRM, JMODE, JPALET, JCLSBL, JREADKEY,
JWAITKEY, JBEEP…), PRINTA (RST $10), and the ports CLUT, STATUS, LINE, LMPR,
HMPR, VMPR, BORDER, KEYBOARD, ATTR, SAAADDR, SAADATA, HPEN, LPEN.
The machine
-
CPU and timing — 6 MHz; 384 T-states a line, 312 lines, 119 808 T a frame (50.08 Hz). The frame interrupt starts each frame and lasts 128 T; the 192 screen lines are frame lines 68–259. Memory contention as on the real ASIC: internal RAM waits for every eighth T-state inside the screen in modes 2–4 (every fourth outside it, and in mode 1 every eighth in alternate bands of the border too); ROM never waits; the ASIC’s ports wait for an 8-T slot. These timings follow SimCoupé’s measurements.
-
Screen — mode 1 (the Spectrum’s layout), mode 2 (linear with an attribute for every 8 × 1 pixels), mode 3 (512 × 192, four colours plus two palette bits from HMPR) and mode 4 (256 × 192, sixteen colours), drawn line by line so CLUT, border and mode changes land on the line where they happen. BORDER bit 7 switches the screen off in modes 3 and 4 (and the contention with it).
-
Colour — 16 CLUT entries (ports 248 + 256 × n), each one of 128 colours (G1 R1 B1 BRIGHT G0 R0 B0).
-
Interrupts — frame and line, read on STATUS (port 249); the LINE register fires at the start of the right border of the line before.
-
Memory — 256 or 512 KB in 16 KB pages; LMPR (250) pages sections A and B, ROM 0 off and ROM 1 on and write protection; HMPR (251) sections C and D; VMPR (252) the screen page and mode.
-
SAA1099 — six tone channels, two noise generators, two envelope generators on channels 2 and 5, stereo amplitudes; registers through ports 511 and 255.
-
Keyboard — the nine-row matrix (ports 254 and 249); the page makes the SAM’s own Shift and Symbol combinations for the character you type. Mouse (toolbar) adds a SAM mouse on port
$FFFE: click the screen to capture the pointer. -
Disk — a VL1772 controller on ports 224–231 (drive 2: 240–247), with MGT (800 KB), SAD and EDSK images; the index hole turns at 300 rpm, commands finish at once.
ROM and DOS
SAM ROM 3.0, the last official ROM, was written by Dr Andy Wright for Miles Gordon Technology. In April 2008 Andy Wright allowed all his SAM Coupé titles, ROMs included, to be freely distributed; World of SAM and the SimCoupé emulator distribute the ROM images on that basis, and the ROM’s source has been published (Simon Owen’s samrom). The image here is ROM30 from World of SAM’s archive, unchanged; see NOTICE.txt. The ROM tab can boot another 32 KB SAM ROM of your own instead.
SAMDOS (Bruce Gordon, MGT) is not included: World of SAM records no distribution permission
from MGT. Nearly every SAM disk carries its DOS as its first file, and BOOT loads it from
there.
Keys
Letters, digits and punctuation type the character you press. Enter is RETURN, Backspace DELETE, Esc ESC, Tab TAB, Caps Lock CAPS, Ctrl CNTRL, Alt SYMBOL, the arrows the cursor keys, Home EDIT, Insert INV and the numeric keypad F0–F9 (F9 boots a disk). The debugger keeps F5, F6, F7, F8, F10 and F11. The on-screen keyboard is for phones. Works in current Chrome, Edge, Firefox and Safari; sound starts after you click the page.
Limits
-
No tape: the SAM’s cassette loading isn’t emulated.
-
Disk commands complete instantly and copy-protected disks with unusual formats may not load; writing a track (formatting) is understood but simplified.
-
Contention follows the SAM’s rules per memory access; video is drawn per line, not per cell, so mid-line palette changes land on the next line.
-
No MIDI, external memory, printer, clock, or Kempston joystick.
-
The SAA1099’s envelope changes take effect at once instead of at the end of the current envelope period.
Privacy
Everything runs in your browser. The ROM is loaded from this site; disk images and ROM files you open stay in the page (a ROM of your own is kept in this browser’s IndexedDB) and are never uploaded. The page loads no third-party scripts.
Linking to an example
Share link copies a URL with the example (or your source) and the tab — never disks.
| Parameter | Values |
|---|---|
|
|
|
the tab: |
|
|
Other Z80 machines here: the ZX Spectrum (mode 1 is its screen), the TRS-80, the MSX and the Amstrad CPC.
Feedback is a gift. Something to improve, a feature to add, or a bug? Tell me.
Runs entirely in your browser; nothing you type leaves this page.