CPCEC Amstrad CPC emulator and its ZX Spectrum sibling ZXSEC
16231 hits
Foreword
CPCEC is an emulator of the family of home microcomputers Amstrad CPC
(models 464, 664, 6128 and Plus) whose goal is to be loyal to the original
hardware and efficient in standard modern systems. Thus it brings a
faithful emulation of the Z80 microprocessor and it replicates the
behavior of the CRTC 6845 and Gate Array video chips, the PSG AY-3-8912
sound chip, the remaining circuits found in the original hardware, and
the tape deck and floppy disc drive that made possible loading and
running software.
ZXSEC is an emulator of the Sinclair Spectrum family (48k, 128k,
+2/Plus2 and +3/Plus3) based on the components it shared with the
Amstrad CPC family: the Z80 microprocessor, the PSG AY-3-8192 sound
chip, the tape system and the NEC765 disc drive controller.
The default build of CPCEC requires a Microsoft Windows 2000 operating system
or later, while the SDL2 build requires any operating system supported by the
SDL2 library. The minimal hardware requirements are those fitting the operating
system, and it's advised that the main microprocessor runs at 400 MHz at least.
Screen resolution in pixels must be 800x600 at least. A sound card is
optional. Using a joystick is optional, too.
The source code of CPCEC and its binaries follow the GNU General Public
License v3, described in the file GPL.TXT within the package.
Gallery
Arkanoid 2 (1988 Imagine) CPC 464
Skweek (1989 Loriciels) CPC 6128
Cobra (1986 Ocean) Spectrum 48k
Zub (1987 Mastertronic) Spectrum 128k
Mega Phoenix (1991 Dinamic) CPC 464
Beast Preview (1992 Overflow) CPC 6128
Dark Star (1984 Design Design) Spectrum 48k
Deliverance (1990 Hewson) Spectrum 128k
Mission Genocide (1987 Firebird) CPC 464
Logon's Run (2017 Logon System) CPC 6128
Starion (1985 Melbourne House) Spectrum 48k
Mot (1989 Opera Soft) Spectrum Plus3
Samurai Trilogy (1987 Gremlin) CPC 464
PhX (2018 Condense) CPC 6128
Vectron (1988 Firebird) Spectrum 48k
Cray 5 (2011 Retroworks) Spectrum Plus3
Acknowledgements
This emulator owes its existence to a series of people and societies
that are listed as follows:
The firmware files included in the package are Amstrad's
properties, who allows the emulation of their old computer
systems and supports the distribution of their firmwares as long
as their authorship and contents are respected, and whom I
wholeheartedly thank the creation of those magnificent computers
and the good will towards their emulation.
This emulator was my final project for the Computer
Engineering postdegree at the Distance-Learning National
University (Universidad Nacional de Enseñanza a Distancia,
UNED), a project directed by professor José Manuel Díaz Martínez
and ultimately awarded a 100% and the right to a honorable
mention.
The documentation about the system comes from cpcwiki.eu,
cpc-power.com, cpcrulez.fr and quasar.cpcscene.net.
The alpha tests were handled by the faithful and loyal Denis
Lechevalier.
Version log
20210115 -- minor patch fixing a bug in the CPC PIO: "Inertie" sends a value to port A, then reads the same value back instead of receiving a PSG register or keyboard bits.
20210114 -- minor patch improving Playcity stereo autodetection ("Alcon 2020" uses the left chip only), adding ROM simulation to Dandanator cartridges ("CPC Soccer") and fixing a bug in Z80 instruction CPI introduced in version 20210105 (RAXOFT tests) and another one in the CRTC1 VSYNC length ("Pheelone").
20210107 -- minor patch fixing a bug in the ASIC's screen split trigger (SSSL must be checked when HSYNC rises, rather than when HDISP rises) and a glitch in the Win32 joystick support, and making the Playcity CTC more responsive.
20210105 -- minor patch fixing a bug in video recording (it turned 44KHz stereo into 88KHz mono) and tape playback (16 and 24 bit WAVE files were improperly supported), extending the joystick support to handle directional controls (thanks to Pelrun for the Win32 and SDL2 code) and letting the Dandanator emulation modify the cartridge (configuration, savestates...) if the user requests it.
20201215 -- minor patch fixing snapshot loading on Spectrum Plus3 and extending the ULA's "snow" behavior ("Vectron") and scope ("Narco Police", "Robocop 3"). The SDL2 UI appends an ellipsis to filenames that are too long to fit within the dialogs.
20201212 -- nineteenth public release. The Windows version can use DirectDraw instead of GDI, and the SDL2 version uses Textures instead of Surfaces: performance rises when hardware acceleration is available. Just in case, however, command line parameter `-!` and the menu option "Video: Software render" can be used to disable the hardware acceleration in systems where it's missing or performs worse than pure software. CPC bugfix: PSG handles register 14 separately, as expected by "Gremlins (v1)". Spectrum bugfix: 128K ghost ports are properly emulated, the demo "Tiratok" plays music at last. XRF lists the available codecs on Windows when launched without parameters.
20201130 -- minor patch further extending ROM profile loading with four new fields: "type", "bank", "crtc" and "fddc".
20201122 -- minor patch fixing a crash when using the SDL2 interface to save a file in the root path, and enabling automatic SDL2 detection on compile time.
20201111 -- minor patch adding mouse tracking to the SDL2 interface and making XRF file recording less memory-consuming.
20201028 -- minor patch improving Issue-2 emulation on Spectrum 48K: "Abu Simbel Profanation" and "Rasputin 48K" work on 48K Issue 2 and fail on the other models, as expected.
20201024 -- minor patch solving a problem with the SDL_WINDOWEVENT_EXPOSED event and inverting the black/white bits in ZXSEC's graphics viewer.
20201022 -- minor patch adding mouse wheel support to the SDL2 user interface and an option to set whether disc write conflicts in CPCEC and ZXSEC are strict (they raise errors) or relaxed (they do nothing).
20201020 -- minor patch fixing a bug in the Dandanator support (the "LD (IY+n),A/B/C" operations must work with any "n" value, instead of just 0: thanks to Spirax for the report) and another one in the CRTC (counter HCC is 8 bits long: "Camembert Meeting 4 Demo" stops showing a line of garbage between the top and the middle panels), adding SDL2_DOUBLE_QUEUE as an optional SDL2 compilation flag (some systems need an audio buffer longer than the default 8 frames) and using a different pixel pattern when both X-Masking and Y-Masking are enabled.
20201012 -- minor patch adding mouse support to the user interface for SDL2.
20201010 -- eighteenth public release. Fully rewritten CRTC logic, with an internal event system that extends demo compatibility (for example "Chapelle Sixteen", "Madness Demo" and "S&KOH" for CRTC1) and a fully multiplexed Plus sprite renderer. More disc protections (ERE, UBI) are supported, WRITE DELETED DATA updates the corresponding flag in the sector table. New Dandanator support, read-only ("Sword of Ianna"). Preliminary Playcity support, limited to the two extra PSG and the NMI trigger. New video recording based on an intermediary format XRF, and including a tool allowing to convert it into AVI files. Improvements in the SDL2 interface, with a bigger font (12px rather than 8px) and vertical alignment in menu keyboard shortcuts. Added new debugging functions (looking at graphics in memory with key "W", trapping the opcode $EDFF as a breakpoint, etc.) and moved breakpoints from "T" to "." . Removed CPCEC.ELF and ZXSEC.ELF as they're bound to a single OS (Linux Mint 18 32bit) and the user must compile the binaries anyway. Moved the configuration files in non-Windows systems from CPCEC.INI and ZXSEC.INI to .cpcecrc and .zxsecrc as customary on Unix.
20200622 -- minor patch reducing memory footprint (extra ROM memory is only allocated if the user loads a "profile"), rendering SYNC signals as black rather than as the current border, and fixing the 3D cylinders part of "PhX" on CRTC1; the "ball worms" and the final scroller stay bad on CRTC3 and CRTC4, though.
20200616 -- minor patch adding several tape analyses and removing the patch that shortened the initial delays (it caused problems). Several changes in SDL2 (fewer warnings, disc drive cache in Win32) and in the Z80 debugger (more content: 256 bytes of memory dump and 32 bytes of stack).
20200606 -- minor patch with surround sound: the user can set the channel separation to 0% (mono), 50% (surround) or 100% (stereo).
20200603 -- seventeenth public release. Added stereo sound. Fixed a bug in the CPC PIO (the read-only mode of port A allowed writing), another bug in the tape analysis (CPCEC: the algorithm for TITUS caused trouble in "The Blues Brothers"; ZXSEC: Speedlock5 didn't recognize the heading noise; both systems add patches to shorten the initial delays), another one in the loading of CPC snapshots (a snapshot saved on PLUS hardware without the "CPC+" block showed a completely black palette), another one in the Z80 debugger (the command 'P0 could generate an infinite disassembly), another one on tape handling (reading a WAV file must use >128 as reference instead of >=128) and some problems in Win32 (the screen stopped updating after pausing, switching windows in and out) and SDL2 (boot message errors weren't shown; the filename sorting algorithm was slow).
20200509 -- minor patch improving the synchrony between Z80 and video on ZXSEC: the ULA48 test already worked before, but ULA128 had problems; now both work well. Added the option -W (use the full screen rather than a window) and improved the SDL2 handling of bigger windows.
20200504 -- minor patch focused on the SDL2 toolkit: fixed a bug when confirming overwriting files, and improved file browsing across directories by pointing by default to the previous directory.
20200503 -- 20200503 -- minor patch improving the behavior of the Z80 operations INI, IND, INIR, INDR, OUTI, OUTD, OTIR and OTIR: the 2012 RAXOFT tests (Z80CCF, Z80FULL and Z80MEMPTR) score zero errors. Slightly more precise automatic frameskip.
20200430 -- sixteenth public release. Now you can compile CPCEC and ZXSEC with SDL2 (featuring its own graphical user interface) for multiple operating systems thru the option -DSDL_MAIN_HANDLED; the precompiled files CPCEC.ELF and ZXSEC.ELF for 32bit GNU/Linux are included, too. New support for extended ROM profiles through INI files enumerating up to 257 16K ROM blocks. Further Z80 tweaks: the new error rates of ZXSEC in the 2012 RAXOFT tests are 8/152 Z80FULL, 5/152 Z80CCF and 0/152 Z80MEMPTR.
20200420 -- minor patch fixing the HSYNC signals' black stripes from "Chany Dream End Megademo" on CRTC 1, "Onescreen Colonies" on CRTC 0, etc., as well as the value of MEMPTR in JR cc,$RR and DJNZ $RR and the logic of BIT n,r,(IX+$XX): the error rates of ZXSEC in the 2012 RAXOFT tests are Z80FULL 10/152, Z80CCF 70/152 and Z80MEMPTR 4/152.
20200406 -- minor patch adding partially multiplexed PLUS sprite rendering: "Synergy 4" recovers its top left sprites.
20200404 -- minor patch fixing the DMA handler (all commands but LOAD can be combined together) and removing several "kludges" for PLUS but the one for "Black Sabbath": thanks to Norecess464 for locating the bug. Also, -C now becomes -C0..4.
20200331 -- minor patch providing further fixes for Plus demos "CRTC3" and "Synergy 4" (top left sprites disappear after few seconds, though) and adding the command Shift+Space (skip scanline) to the debugger.
20200314 -- first anniversary! minor patch fixing issues in the demos "CRTC3" and "Eerie Forest" for Amstrad Plus.
20200307 -- minor patch avoiding a hang in globbing(), improving snapshot compatibility (WinAPE and ACE employ slightly different CPC+ blocks) and removing several useless details. The optional firmware packages now include the corresponding cartridges.
20200229 -- fifteenth public release. Added support for Amstrad Plus hardware: extended colours, soft scrolling, hardware sprites, programmable raster interruptions, DMA channels, ROM cartridges, etc. Added fifty more tape schemes to speed up the reading of bytes and even whole blocks. Improvements in the disc drive emulation: new discs (by default the DATA format shared by CPC and Spectrum +3) can be created on the fly, emulation of protected games from Design Design ("2112 AD"), The Edge ("Palitron"), Titus ("Prehistorik" and "Moktar/Titus the Fox"), bugfixes (READ ID: "5KB Demo 3", "Daley Thompson's Olympic Challenge" and "Turbo Copy III"; FORMAT TRACK converts old-style MV - CPC discs into new-style EXTENDED ones, and cleans up useless data at the end of the disc). CPCEC honours the RAM size (up to 576k) and CRTC type stated by a snapshot ("Postscript" demo) and so does ZXSEC, that can read Z80 snapshots now and allows 48K SNA files to be either strict (the original format) or relaxed: 128K headers on 48K data. Control-F2 avoids accidental recording of snapshots after a reset. Fixed a bug that happened when combining Y-Masking and Half Scanlines. Extended ZIP archive support to handle pipeline-generated (i.e. the final headers are the right ones) archives. Sources are distributed together with the binaries instead of being delivered upon demand.
20200101 -- minor patch fixing a regression in CRTC0 caused by the previous patch ("Scroll Factory", intro of "Pinball Dreams", "Overflow Preview: Part 1") and improving its heuristics ("Overflow Preview: Part 3").
20191231 -- minor patch fixing a bug in the FDC (bit 6 of SENSE DRIVE STATUS must react when the user changes discs: "Fugitif") and a regression in CRTC0 (detect REG6<REG4 rather than REG6<=REG4: "5KB Megademo 3: Nayad"). Happy new year 2020!
20191227 -- fourteenth public release. Visual improvements: the green screen palette is closer to the original, the vertical filters ("Y-Masking") are compatible with the interlaced modes, mixing X-Masking and Y-Masking together shows a checkered pattern. Internal improvements: the new traits of the CRTC registers 3 and 9 and the delays between the Gate Array, the Z80 and the CRTC finally can emulate "Pinball Dreams" as a whole for all the CRTC types and solve the problems in several demos ("Scroll Factory", "Still Rising", parts of "The Demo"...) and games ("Action Fighter", "Storm Warrior", "Usagi Yojimbo"), although some titles still need particular CRTCs ("PhX" CRTC0, "Onescreen Colonies" CRTC1, etc.) to work correctly.
20191130 -- minor patch fixing a bug when running CPCEC and ZXSEC on a screen shorter than 600 px, another one when recording a WAV file, and another one in the port logic of CPCEC ("Knight Rider", OUT &0088,&88 must not reach the Gate Array, but "Hero Quest", OUT &00C0,&C0 must reach it). The CRTC types 0 and 2 have improved ("Face Hugger Ultimate Megademo": "Tantrum", "5KB Megademo 3", "Power System Megademo": "Glooms"...) but cannot handle "Pinball Dreams" yet, unlike CRTC 3 and 4, that together with CRTC 1 support this game now.
20191117 -- thirteenth public release. More precise emulation of type 1 CRTC (by default instead of 0) in CPCEC ("From Scratch", "Pinball Dreams"...) and 48K memory contention in ZXSEC ("Starion", "Black Lamp"...). CPCEC also allows choosing the length of the V-hold signal (for example "Thunder Blade" needs a short signal) and whether horizontal sync must be flexible ("Batman Returns", "Pinball Dreams"...) or not ("CPC 30th Anniversary Megademo", "PhX"). Unfortunately, some demos that worked well in past versions now suffer problems that cannot be solved by selecting another CRTC. Removed third joystick button in CPCEC, no real joystick ever included it. The ZXSEC joystick is Sinclair 2 by default.
20191004 -- minor patch making the debugger options set with V and M stick between sessions.
20191003 -- twelfth public release. Precise (albeit not perfect yet) memory contention and ULA noise ("snow") on Spectrum: "48K Timing Tests" passes all tests but 36 and 37, and "128K Timing Tests" fails on just six tests. "Mask 3: Venom Strikes Back" draws the attribute and border effects on their precise locations on all platforms (48K, 128K/Plus2, Plus3) and Software Creations' "Black Lamp", "LED Storm" and "Sly Spy" behave well on 128K machines. Improvements in the debugger: fixed disassembly panel invalid cursor locations, added optional tall characters, avoided debug+pause clashing, new key M toggles memory dump ROM+RAM and RAM-only modes. Improved ZIP handling (ZIP archives are no longer locked, files within archives are filtered by extension), user interface fixes.
20190831 -- minor patch fixing several bugs (booting two-sided discs with FLIP SIDE option on, recording snapshots or tapes after loading a snapshot or tape from a ZIP archive), improving several details (loading snapshots with memory compression, emulating up to 576 kB RAM) and redefining the menus (Edit is divided into Edit and Settings, Image and Sound become Video and Audio, new video filter functions...) and the command line: "-+" now limits the zoom to integer values; "-!" inherits the option of hiding the menu.
20190817 -- minor patch fixing a crash when booting tapes right when the automatic frameskip kicks in.
20190809 -- minor patch restoring the "silent" discarding (i.e. without error codes) of write operations in read-only discs and allowing the automatic booting of IBM-formatted discs.
20190731 -- eleventh public release. Added a new UI-based debugger (typing commands is no longer needed) and support for ZIP archive reading based on PUFF.C from the ZLIB project, upgraded GCC to 5.1.0 and removed all `inline` tags (they did more harm than good), and generally reworked all internals to make them OS-independent. Several details improved as well: the file selector fixes a bug in Win10 (and in some cases in Win7), "browse tape" dialog shows the file name, Spectrum +3 automatically becomes +2A to load tapes, `auto rewind` shows up in Edit menu and fixes bugs in CSW files, and sound emulation has improved, for example "Terminus" on CPC plays sound and "Agent X II" on Spectrum is no longer noisy.
20190526 -- minor patch fixing a bug in autorun mode: opening menus and switching windows cancelled the automatic keyboard.
20190524 -- tenth public release. Added support for CDT/TZX file blocks 0x24 and 0x25 (loop start and ending) (cfr. BATMAN.TZX), fixed bugs in the handling of weak sectors in DSK files (cfr. "Titus Classiques"), YM file recording is reentrant, fixed a bug in INI files with empty fields and added the option `autorewind <0|1>` to rewind (or remove) a tape when playback reaches the end.
20190430 -- ninth public release. Softer B/W Spectrum palette; fixed bug in FDC sector size calculation if GAP datas are stored (Loriciels' discs); added simple memory contention to ZXSEC ("Amaurote", "Black Lamp", "Puzznic", "Sly Spy", "Zub"...).
20190419 -- eighth public release. Added options for image and sound interpolation; tape automatically rewinds itself when it reaches the end (à la FUSE); fixed a bug in TZX files that store 0 instead of 8 in the "used bits" field, another bug in CUSTOM INFO blocks in TZX files, and another one when ZXSEC loads a 48K SNA file in Plus3 mode (users should manually switch to a safe model beforehand anyway). INI files now remember the names of the last used files.
20190408 -- seventh public release. Fixed a bug in the YM3 file recording, another one in the ZXSEC internal timings, and one more in the debugger commands with optional parameters.
20190404 -- sixth public release. Fixed a Z80 emulation bug in IRQ logic. Configuration (computer model and file paths) is kept across sessions in a INI file.
20190331 -- fifth public release. Tapes can be browsed, either by file position (WAV and CSW) or by block (CDT, TZX and TAP).
20190325 -- fourth public release. Onscreen indicators (hide them with -O); fixed bugs in ZXSEC that slowed emulation down when the frameskip wasn't zero, and another bug in audio recording on WAV files.
20190318 -- third public release. By default the window shows a menu; new option -+ hides it.
20190317 -- second public release. Fixed Win32 joystick bugs: JoyGetPos returns ZERO on OK, not on ERROR.
20190314 -- first public release.