The Amstrad CPC6128

The Amstrad CPC6128 128K Colour Personal Computer changed the world. It wasn't the first computer that I programmed (that would be a Sinclair ZX80), but it was the first one that I owned - sort of - and is a source of great nostalgia. As a kid, sitting up all night in my bedroom during school holidays, I taught myself BASIC, which I used to write my own Assembler, then used that to write an Assembler in Assembly Language, then used that to write games.

After many years as a professional Software Developer I decided to take out some old 3 inch floppies from back in the day, and revive my projects. I was interested to know whether I would now hire my 15-year-old self 😊 My mother had kindly thrown the original machine in the bin some years previously, so I had to buy another, but amazingly after nearly 30 years the disks were still readable!

I was delighted to find that there is an active online community surrounding this and other 1980s retro machines. Furthermore, there are a wealth of free tools and information available, and developing software for these machines is now a thousand times easier than it was when literally ALL I had was the machine, a book on Assembly Language programming, a copy of Soft968, and my wits. There was no WorldWide Web in those days, in fact no home Internet at all, and PCs ran MS-DOS and cost about 50 years worth of pocket money.

Soft 968

Soft 968 is the Firmware manual for the Amstrad CPC range of machines. The Firmware contains a wealth of routines for interacting with the machine hardware, i.e. the screen, keyboard and so on, and is an invaluable resource for the Machine Code programmer. If you want to try and outsmart the original Amstrad engineers then you could do all these things directly, but leveraging the Firmware will save you a bucket of time and a world of pain ! Back in the day it was expensive to buy, nowadays the full text is reproduced online.

Assembly Language Programming for the Amstrad CPC 464, 664 & 6128

This book was my Bible, and really my only resource for actually learning how to program in Assembly Language. I consider it to be very well-written, and pitched exactly at the level I was back then. It is now out of print and the publisher Argus Books has been sold and resold, but once again the text is available online. If you did want to to seek out a hard copy second hand, I did a brief search and couldn't find this actual title, but I saw a similar book of theirs for the BBC Micro on Amazon for £115. No, my copy is not for sale !

Tools Ancient and Modern

Nowadays we all have powerful PCs and the Internet to help us, and there are many different ways you can approach developing Machine Code programs for the Amstrad CPC6128

WinAPE

Even if you are lucky enough to own an actual Amstrad CPC6128, there are many advantages to doing your development or at least your debugging on an emulator running on your PC. There are others, but the most popular and the one I have been using is WinAPE. This has a built-in Assembler and debugging tools one could only dream of when working on the actual machine. Alternatively, you could go old-school and use the HiSoft DevPac assembler/disassembler/editor/monitor package, either on your emulator or an actual machine.

HiSoft DevPac

HiSoft DevPac is a complete assembler, disassembler, editor and monitor from Amsoft/Hisoft, and was definitely on my wishlist when I was programming in my childhood bedroom. At the time, for a kid from a not particularly wealthy family, it was something I could not afford, which prompted me to write my own.

Nowadays, like much for the Amstrad, it can be found on the Internet to download for free. Or you could use my home grown version if you like...

SDCC

Another interesting approach, which if you are familiar with the C programming language can enable you to get quite a long way quite quickly, is to develop in C and then use SDCC (Small Device C Compiler) to compile down to Z80 machine code.

SDCC is not specifically for the Amstrad, or even the Z80, in fact it was developed primarily for people to program microcontrollers in their own hardware projects. However, it supports Z80, and there are some excellent resources online explaining exactly how to use it for the Amstrad.

CPCDiskXP

Given that WinAPE utilises special "Amstrad Disk Image" files, and real Amstrad CPC6128s require 3 inch floppies that were pretty non-standard even back then, how do you transfer files back and forth between your PC and the Amstrad realm ?

This is something that I spent quite a bit of time exploring. More on transferring to a real Amstrad, and indeed transferring from those original vintage floppies back to the PC later on. For the emulator at least, the answer is an excellent utility called CPCDiskXP, which will transfer files between PC and virtual disk images.

ConvImgCPC

Oh, the time I spent with graph paper, felt tip pens and a Hex/Binary/Decimal calculator, designing and encoding sprites for my games. OK, so actually I wrote a sprite designer utility, but what I would have given for a near-infinite source of images like the Internet and a tool to convert those to Amstrad-friendly object bytes. That tool is ConvImgCPC. Let's say you want to animate a running horse. Find some video online and use online tools to convert individual frames to JPG files, then run them through ConvImgCPC, which will crunch them down to the best representation the lowly Amstrad hardware can manage. There's your set of sprites ready to animate.







Zeus Z80 Assembler

DevPac is a Z80 Assembler designed to run on the Amstrad, or an emulator. However, there are advantages to constructing your Assembly Language project and compiling your code on the PC, before transferring the object to the Amstrad realm.

You get more flexibility and control over the memory map than you do using SDCC, and it allows you to write more efficient code as SDCC, although excellent, inevitably makes generalisations which can waste precious bytes and clock cycles. For example, it makes heavy use of the stack for both passing parameters and variable storage within routines. If your code is not re-entrant, and doesn't need to be relocatable, it's much more efficient to do this using defined RAM locations.

Having searched the Net and tried several Windows-based Z80 compilers, I have found Zeus to be the best.

GIMP

GIMP (GNU Image Manipulation Program) is powerful and free open-source cross-platform image manipulation software, with capabilities that you might otherwise expect to pay serious money for. It takes a little time and effort to learn how to use it to its full potential, but is an incredibly useful tool for anyone doing anything graphical for any computer retro or modern. The icon adorning this panel was created in seconds from a downloaded base image using GIMP.

Original Software

This section contains original software that I have written. More content is on the way in the coming weeks.

Having used ConvImgCPC to generate sprites for a game that I am working on, I found the basic functionality outstanding, but that it was difficult to edit and manipulate the sprites once converted. I did search for existing tools, and many are available, but none seemed to do exactly what I wanted. Therefore, I have quickly knocked together the bare bones of a tool to plug this gap. As yet functionality is relatively basic, for example it currently only supports Mode 0, and I need to improve the general performance. However it does allow you to load up output in the form of Linear bytes generated by ConvImgCPC, and manipulate it with the following functions: Edit individual pixels, Add rows/columns to the edges, Flip, Rotate, and Substitute one pen for another. A representation of the output roughly as it will appear when rendered on the CPC6128 is displayed in real time. You can then save back to the same Linear bytes format. You can also Load, Modify and Save the palette using the same OCP Art Studio .PAL file format as used by ConvImgCPC. A sample .ASM file (the tiger sprite) is included. The tool is written in C# using WPF and is based on a DynamicGridView project created by Illya Reznykov. I am very receptive to comments, suggestions, bug reports and feature requests. The source code can be downloaded from my GitHub repository.

CPC Sprite Manipulation Tool 1.0.0 for Windows

This is a beta version of a Windows tool I have written for manipulating Amstrad sprites. Essentially it is designed to complement the functionality of ConvImgCPC.