A cycle-accurate MC6800/MC6808 emulator running on the Raspberry Pi RP2350 microcontroller. Designed to replace the MC6800/MC6808 processor and EPROMs in early 1980s Williams, Stern and Bally pinball machines, providing hardware-level compatibility with vintage MC6800-based systems.
Much of the documentation in this repository was created with the assistance of an LLM (Claude Code). While this has accelerated the development process, it also means that the content may contain subtle errors, inaccuracies, or may not be fully up-to-date. We encourage you to cross-reference with official documentation or source code where possible and report any issues you find.
- Cycle-Accurate Emulation: Every MC6800 instruction executes in exactly the correct number of E clock cycles
- Hardware Bus Interface: Physical GPIO connections allow interfacing with real MC6800 peripheral chips (PIAs, etc.)
- Auto-Configuration: Memory fingerprinting automatically detects and configures system architecture
- Custom Hardware: Designed for Ned's System 7 Board (RP2350B with 48 GPIO)
- Full Address Bus: Complete 16-bit address bus (A0-A15) for full 64KB address space
- External Clock Support: Auto-detect and synchronize to external E clock source
- USB CDC Interface: Command-line control, Intel HEX file loading, and comprehensive diagnostics
- Web Interface: Browser-based GUI for easy ROM loading and monitoring
- Debug Features: SPI debug output, UART console, LED indicators (ROM/RAM/unmapped access)
- Flash-Based Storage: Persistent flash-based storage for ROM (up to 48KB).
- Microcontroller: Raspberry Pi RP2350B (dual Cortex-M33 cores, 48 GPIO package)
- Board: Ned's System 7 Board (BOARD_NED_SYS7)
- Memory: 520KiB SRAM, 16MiB Flash, 8MiB PSRAM
- System Clock: Configurable 150-300MHz (default: 266MHz for 133MHz QSPI flash)
- Bus Interface: 8-bit data bus, full 16-bit address bus, complete control signals
- Clock Generation: PIO-based E clock at 894.886 kHz (3.579545 MHz / 4) or external clock input
The emulator automatically detects and configures memory regions for the following architectures:
- Early Bally (AS-2518-17/35): ROM down to $D000, CMOS write-through to bus
- Stern MPU-100/200: Similar to Early Bally architecture
- Williams System 3/6: Compatible memory mapping
- Williams System 7: 5KB RAM ($0000-$13FF) with mirroring at $1000-$10FF
- Williams System 9: Extended memory configuration
- Williams System 11: Up to 48KB ROM support
- RAM: Up to 8KB shadow RAM with configurable base address and aliasing support
- ROM: Up to 48KB flash-backed storage (minimum address $4000)
- Bus Access: Unmapped addresses route to physical GPIO bus for peripheral chips (PIAs, etc.)
- CMOS: Handled as unmapped, with write-through to target hardware
The emulator consists of several key components:
- CPU Core (
src/cpu_state.c,src/instructions.c): MC6800 instruction execution with accurate cycle counting - Memory System (
src/memory.c,src/memory_map.c): Flexible address translation with aliasing support - Memory Fingerprinting (
src/memory_fingerprint.c): Auto-detection of system architecture and memory layout - Bus Interface (
src/bus.c,src/bus_cycle.pio): PIO-accelerated GPIO operations for cycle-accurate timing - Clock Management (
src/clock.c,src/clock.pio): E clock generation and external clock synchronization - USB Interface (
src/usb_cdc.c): Dual-core design with dedicated USB CDC processing - Debug System (
src/debug_spi.c): SPI output, LED indicators, and comprehensive diagnostics - Interrupts (
src/interrupts.c): /IRQ, /NMI, and /RESET handling with proper vector support
✅ Implemented Features:
- Full MC6800 instruction set with cycle-accurate timing
- Physical bus interface with PIO acceleration
- Auto-detection of external E clock input (MC6800 systems)
- Automatic memory fingerprinting and architecture detection
- Support for Early Bally, Stern MPU-100/200, Williams System 3/6/7/9/11
- USB CDC command interface with Intel HEX loading
- Optional Web-based control interface
- Flexible memory configuration with address aliasing
- Flash-backed ROM (up to 48KB) storage
- LED indicators for memory access visualization (NED_SYS7 board)
- Optional SPI debug output for logic analyzer
- Breakpoint system with up to 16 breakpoints
- Comprehensive diagnostics and memory dump commands
🔄 In Development:
- Support for banked memory systems
- Support for faster (2MHz) E clocks
- MC6809 processor emulation
- PSRAM utilization for extended storage
For detailed setup and usage instructions, see the documentation:
- Getting Started Guide - Complete setup, building, and first program
- Web Interface Guide - Browser-based control panel (easiest method)
- Hardware Connection - Pin assignments and wiring
- USB Commands Reference - Command-line interface
- Download Memory Guide - Backup and extract ROM/RAM contents
- Memory Configuration - Memory layout and configuration
- Architecture Overview - System design and implementation
git clone https://github.com/bikeNomad/6800_emulator.git
cd 6800_emulator
make
# Flash images/BOARD_NED_SYS7.uf2 to device in BOOTSEL modeBuild options: SYS_CLOCK_MHZ=266 QSPI_CLOCK_DIVISOR=2 DEBUG_INTERRUPTS=0
-
Registers:
- 16-bit PC (program counter)
- 8-bit A and B accumulators
- 16-bit SP (stack pointer)
- 16-bit X (index register)
- 8-bit CCR (condition codes: H I N Z V C, top 2 bits always 1)
-
Instruction Set: Complete MC6800 instruction set with cycle-accurate timing
-
Cycle Accuracy: Each instruction executes in exactly the correct number of E clock cycles
- Data Bus: 8 lines (bidirectional)
- Address Bus: 16-bit (A0-A15 on GPIO 8-23)
- Control Signals:
VMA(Valid Memory Address) outputR/W(Read/Write) output- E clock output (PIO-generated) or input (external clock)
- Interrupt Inputs:
/IRQ,/NMI,/RESET(active low)
Data Bus (GPIO 0-7):
- D0-D7: Bidirectional 8-bit data bus
Address Bus (GPIO 8-23):
- A0-A15: Full 16-bit address bus
Control Signals:
- GPIO 24: E clock (output or input for external clock)
- GPIO 25: VMA (Valid Memory Address)
- GPIO 26: R/W (Read/Write)
Interrupts:
- GPIO 27: /IRQ (active low)
- GPIO 28: /NMI (active low)
- GPIO 29: /RESET (active low)
LED Indicators:
- GPIO 37: ROM access (green, active low)
- GPIO 38: RAM access (red, active low)
- GPIO 39: Unmapped/bus access (yellow, active low)
- E Clock Frequency: 894.886 kHz (3.579545 MHz ÷ 4) or external input
- Internal Mode: PIO-based generation for jitter-free timing
- External Mode: Auto-detect external E clock input
- Synchronization: PIO-based cycle counting ensures cycle-accurate execution
- ROM Storage: Up to 48KB in flash (minimum address $4000)
- RAM Storage: Up to 8KB shadow RAM with configurable base address
- CMOS Storage: 256 bytes persistent flash with write-through to bus
- Address Aliasing: Supports incomplete address decoding (e.g., System 7 RAM mirroring)
- Memory Types: ROM, RAM, Unmapped (routed to GPIO bus)
- Device Class: CDC (Communications Device Class) serial port
- Baud Rate: Virtual (USB full-speed)
- Features:
- Intel HEX file loading
- Interactive command shell
- Memory read/write/dump commands
- Breakpoint control
- System configuration and status
- UART: Hardware serial output for diagnostics (115200 baud, GPIO 40/41)
- SPI: Optional clocked debug stream with PC, R/W, and data bus values (GPIO 33-36)
- LED Indicators: Visual feedback for memory access patterns (GPIO 37-39)
A browser-based control panel is available in web-interface/emulator-control.html:
- WebSerial Connection: Direct USB CDC access from Chrome/Edge browsers
- Real-Time Monitoring: Live CPU status and cycle counters
- ROM Loading: Drag-and-drop support for Intel HEX and binary files
- IC Detection: Automatic IC number detection for Williams System 7
- Built-in Terminal: Full command-line access in the browser
- Status Display: Memory map, breakpoints, and system configuration
See Web-Interface.md for detailed documentation.
The firmware is organized into functional modules:
src/main.c: System initialization and dual-core coordinationsrc/emulator.c: Main emulation loop and state machinesrc/cpu_state.c: CPU register state and managementsrc/instructions.c: MC6800 instruction decode and executionsrc/interrupts.c: Interrupt handling (/IRQ, /NMI, /RESET)src/memory.c: Memory subsystem with ROM/RAM shadow copiessrc/memory_map.c: Memory region mapping and address translationsrc/memory_fingerprint.c: Architecture auto-detectionsrc/bus.c: GPIO bus interface and PIO coordinationsrc/clock.c: E clock generation and cycle managementsrc/usb_cdc.c: USB CDC device and command shellsrc/debug_spi.c: SPI debug output for logic analyzers
src/clock.pio: E clock generation and cycle countingsrc/bus_cycle.pio: Cycle-accurate bus read/write operations
The emulator uses several techniques to achieve cycle-accurate timing:
- Shadow Memory: ROM and RAM are cached in fast SRAM for zero-wait-state access
- PIO Acceleration: Bus cycles use PIO state machines for precise timing
- Cycle Accounting: Every instruction tracks and synchronizes E clock cycles
- Fast Path: Internal memory accesses bypass GPIO bus for speed
- Address Aliasing: Incomplete decoding handled via memory map entries
Each MC6800 instruction must complete within the exact number of E clock cycles:
- Memory reads/writes to ROM/RAM: No bus delay (shadow copy access)
- Memory access to unmapped regions: Full bus cycle with PIO synchronization
- Instruction execution: Precise cycle counting with periodic synchronization
The emulator auto-detects and supports:
- Early Bally (AS-2518-17, AS-2518-35): ROM from $D000, CMOS write-through
- Stern MPU-100/200: Early Bally-compatible configuration
- Williams System 3/6: Classic Williams architecture
- Williams System 7: 5KB RAM with mirroring, 16KB ROM
- Williams System 9: Extended ROM support
- Williams System 11: Up to 48KB ROM
- Raspberry Pi Pico SDK (1.5.0 or later)
- CMake 3.13 or later
- GCC ARM cross-compiler
- TinyUSB (included with Pico SDK)
Key build options:
SYS_CLOCK_MHZ: System clock frequency (150-300 MHz, default: 266)QSPI_CLOCK_DIVISOR: Flash access speed divisor (1-4, default: 2)DEBUG_INTERRUPTS: Enable interrupt debug output (0 or 1, default: 0)
The repository includes test programs in tests/:
test_program_2.asm: Basic instruction testtest_program_2.hex: Assembled Intel HEX format
Contributions are welcome! Key areas for development:
- Additional processor support (MC6809, 6502)
- Banked memory systems
- Faster E clock modes (2 MHz+)
- Enhanced debugging features
See LICENSE file for details.
Developed by Ned Konz for the vintage pinball community.
Uses the Raspberry Pi Pico SDK and TinyUSB library.