CPCSyntaxError

Amstrad CPC emulation continues to advance, and CPCSyntaxError arrives with a focus on accurately reproducing the original hardware’s behavior.

It is a Windows emulator compatible with the CPC 464, CPC 6128, CPC Plus, and GX4000, built around a cycle-accurate model of the computer’s video chips. A standout feature of the project is its implementation of all five CRTC types, including the models used in classic CPCs and the ASICs found in the Plus range.

The emulator also replicates various versions of the Gate Array—along with their specific pixel-timing characteristics—and models monitor types such as the CTM 640/644, CM14, GT 64/65, and MM12.

For the CPC Plus and GX4000, CPCSyntaxError incorporates ASIC-specific features such as hardware sprites, DMA sound, a 4096-color palette, raster interrupts, split-screen effects, and smooth scrolling.

An emulator also designed for programmers

CPCSyntaxError goes beyond simply running games and programs. The project integrates a debugger featuring breakpoints and conditions, memory watchpoints, step-by-step execution, a disassembler with labels, and a hex editor.

It also offers real-time visualization windows for various CPC components, including the CRTC, Gate Array, monitor, ASIC Plus, PSG, PPI, keyboard matrix, disk controller, and tape system.

Another interesting feature is the inclusion of the RASM assembler, which allows for assembling code directly into the emulated machine’s memory and executing it within the environment itself.

The interface is built using SDL2, OpenGL, and Dear ImGui, featuring dockable and resizable windows that allow users to organize their workspace according to their needs.

There are also various expansions yet to be completed, including the M4, Symbiface II/III, DigiBlaster, AmDrum DAC, light gun, printer, and V9990/GFX9000.

4 Likes

Only for Windows?

1 Like

I was tinkering a bit with the source code and there’s not much that is really windows-specific.

It would be nice to be able to compile it on MacOS and Linux!

Thanks @XeNoMoRPH for sharing.

…with source code provided on the link you posted… GitHub - WacKEDmaN/CPCSyntaxError: Emulator for Amstrad CPC and Plus/GX4000 · GitHub

Looks like this is close to working on Linux then?

1 Like

I will consult the author about it.

1 Like

i havent tested building it on linux… but it was designed to be cross compatible…

i still have a lot of work to do on it so expect updates

3 Likes

ive updated the code to be fully compatible with linux… build instructions included

please dont ask me for a Mac version! i dont have access to one!..but the linux version “should” work!

3 Likes

I could not see it in screenshots, but does it come with api based debugging (external debugging) and external code load features, so that you can run it in a development session with vscode or other tools?

Also can it load roms?

there is a headless mode via CLI that can be used for debugging…probably not exactly what you want tho!..

Command line

cpcse.exe --roms <folder> starts with another ROM folder. A headless screenshot mode is also available for scripting:

cpcse.exe --shot out.bmp --model cpc6128 --frames 200 [--disk game.dsk] [--type "RUN\"GAME\n"]
          [--cart file.cpr] [--tape file.cdt] [--sna file.sna] [--crtc 0-4]
          [--gate-array 40007|40008|40010] [--beam] [--ram 64-4160]
          [--m4 <folder>] [--gfx9000] [--v9990-shot gfx.bmp] [--video9000-shot mixed.bmp]
          [--opl4] [--playcity] [--speech ssa1|dktronics|lambdaspeak3] [--mp3card <folder>]
          [--dac digiblaster|amdrum] [--wav out.wav] [--sf2]
          [--mouse "w120;j5,60;j16,2;tDIR;kEnter;s<file.bmp>"]

--mouse is a small script run after everything else: wait frames, move the mouse, click, double-click, hold the joystick (j<bits>,<frames>), type text, tap a key, save a screenshot – enough to drive a desktop such as SymbOS with no window.

Models: cpc464, cpc6128, cpc464plus, cpc6128plus, gx4000.

The headless modes print to the Command Prompt they were started from. cpcse.exe is a windowed program, so the prompt does not wait for it: use start /wait cpcse.exe ... in a batch file that needs the result.

i can add GDB and API + CLI for commands

updated

New: external debugging and code loading

Work in VS Code (or any editor) and let the emulator follow your build. Everything is off until you turn it on in Settings → External debugging or on the command line. The servers listen on 127.0.0.1 only.

  • GDB server (--gdb, port 12000) for DeZog’s mame remote: source-level debugging with breakpoints (conditional ones too), step into/over/out, pause and continue, watchpoints, and memory and register views and edits. DeZog’s breakpoints also show in the emulator’s Debugger window. Plain gdb clients work too, along with MAME’s monitor commands.
  • Command API (--api, port 6128) and the new cpcse-ctl program beside cpcse.exe, for build scripts. It can load a .bin, .dsk, .sna, .cpr or tape and run it, type on the keyboard, press keys, read and write memory and registers, set breakpoints and watchpoints, disassemble, step, wait for a stop, and take PNG or BMP screenshots. Requests are one line each, as JSON or a short form (cpcse-ctl load build/game.bin 0x4000 entry).
  • Auto-reload (--watch): your build’s output is loaded again and restarted every time it changes. That works for a .bin, or a .dsk with a command typed after it.
  • New command-line options: --gdb[=port], --api[=port], --load file[@addr], --watch file[@addr], --run entry|addr, --reset, --command "RUN\"GAME\n" and --symbols file. Symbols can come from RASM, sjasmplus, pasmo or WinAPE files, or EQU lists, and addresses can be given as labels.
  • Documentation: docs/external-debugging.md has a DeZog launch.json, a VS Code build task, and every option and command.

New: tape deck

In the Media window, Media → Tape and Debug → Chips → Tape:

  • a tape counter with a reset button
  • the tape’s time position, and which block it is in out of how many
  • rewind to the start, back a block, play, pause, stop, fast forward, eject
  • a list of the tape’s blocks to jump to
  • a MOTOR light

New: assembler syntax colours

The assembler’s editor colours each part of the code in its own colour: instructions, registers and conditions, directives, numbers, strings, comments, label definitions and the labels they use. Colours… lets you change each colour or switch the colouring off, and your choice is saved.

New: Eject for cartridges and snapshots

Cartridges and snapshots now have an Eject button in the Media window and the Media menu, like discs and tapes. Ejecting restarts the same machine without it. The Snapshot section shows which snapshot is loaded.

New: windows that fit when they’re narrow

Rows of buttons, toolbars and text now wrap to the window’s width in every window, so a narrow or docked window shows everything instead of cutting it off. This covers the Machine, Media, Settings, debugger, Chips, Memory, GFX9000, DSK editor, assembler, CSL and printer windows.

New: GFX9000 VRAM image as the display shows it

Debug → GFX9000 → VRAM image now colours VRAM the way the picture does: each layer uses its own palette offset, sprite patterns use their sprite’s palette, and transparent dots show the backdrop colour. In P1, layers A and B are shown side by side, and hovering over a dot shows which layer it belongs to.

2 Likes

gdb server

:heart_eyes:

I’ve mentioned that in the old forum. Allows existing debugging clients to debug CPC programs.

Rhaa no time to test now. :sleepy_face:

1 Like

I feel your pain, my other big project is also SDL2/Imgui/OpenGL and whilst I develop on Linux, and cross-compile in a VM for Windows for releases, I ended up accepting a PR for MacOS support. imgui is the Dog’s Bollocks though, it’s a lovely piece of software.

2 Likes

I usually find myself not having to add any extra effort to make Mac and Linux happen at the same time.

It’s Windows the one that usually breaks my balls because Microsoft cannot follow a single standard and has to do things their way…

That said, I managed to compile CPCSyntaxError on my M1 but crashes on start with this error:

Failed to initialize OpenGL loader!
Assertion failed: (bd != nullptr && “Context or backend not initialized! Did you call ImGui_ImplOpenGL3_Init()?”), function ImGui_ImplOpenGL3_NewFrame, file imgui_impl_opengl3.cpp, line 333.

I’ll keep trying to make it work.

2 Likes

On macOS you only get a modern OpenGL context if you explicitly ask for a 3.2+ Core Profile, forward-compatible one. The code asks for plain 3.0 with GLSL #version 130, so macOS hands back a legacy 2.1 context, ImGui’s OpenGL loader refuses it, and the assert follows.

updating the code now..found a few other issues that would cause problems on macos too..so fixing them..next version “should” allow it to run on mac.. and will be the last update till next weekend!

2 Likes

v0.3.1: runs on macOS (Apple silicon and Intel)

New: macOS

CPCSyntaxError now builds and runs on Macs, both Apple silicon (M1 and later) and Intel. A user’s build compiled, but then stopped at start-up with “Failed to initialize OpenGL loader!”. macOS only gives a modern OpenGL to a program that asks for a 3.2 Core Profile context, and the emulator now asks for one. The README has a new Building from source → macOS section:

xcode-select --install
brew install cmake ninja sdl2
cmake -S . -B build -G Ninja
cmake --build build
./build/cpcse

Other things that work on a Mac now:

  • CSL scripts window: it runs scripts (it finds its own program file without Linux’s /proc).
  • “Open screenshot folder”: it uses open.
  • GDB server and command API: a debugger that disconnects mid-reply no longer ends the program.

If a computer’s graphics driver can’t provide OpenGL 3 at all, the program now explains this in a message box instead of stopping with an assert.

Windows and Linux are unchanged.

3 Likes

Now it works!

Thanks a lot!

1 Like

Ah, that would explain why on my own similar Imgui project, the MacOS support PR I had received upgraded the required OpenGL to 4 on that platform.

(I was also using 3/#130 by default)