When he was a kid, Sébastien Harelle was given a computer. It was Christmas 1988 and "ordinateurs" were finally starting to find their ways inside French homes.
It was not Sébastien's first contact with such a machine. As early as 1985, following Laurent Fabius's "Computers for Everybody" plan[1], all elementary schools introduced children to Logo programming via star-connected[2] Thomson MO5s.
This computer did not have network capability but it was full-fledged with a monitor and a floppy disc unit integrated in the keyboard. Turning it on brought up a blue background and yellow text home-screen displaying "BASIC 1.0 Ready" and a prompt.
Soon he was spending entire evenings at his desk. Besides programming, there was an immense catalog of games available. After inserting a floppy disk and typing "RUN DISC"[3], he was welcomed to the realms of Gryzor, Barbarian, and Renegade.
Sébastien did not know it at the time but like many other French kids he would end up developing an ever-lasting appreciation for that machine, the Amstrad CPC.
If you are not from France or the UK and if you were not born in the late 70s, chances are you have no idea what an Amstrad CPC is. To put it in one sentence, Amstrad took the 8-bit home computer market by storm in the mid-80s thanks to great advertising and low prices.
It is Christmas 1985 and you want to buy your kids a computer. On one side, you have a C64 with 64KiB RAM for $149. It can display 16 colors and also has features you don't understand like hardware sprites and soft-scrolling. You will also have to buy a floppy drive ($272) and a TV ($293). On the other side, you have an Amstrad CPC 464 with similar specs except it comes with a screen, has a higher resolution and only costs $472[4][5][6]. Which one do you buy?
My concept was simple: Mum and Dad don’t want little Johnny taking over the TV set, so our computer should come with its own monitor, have a full-sized keyboard and a built-in cassette mechanism for loading software and hit a target price of £199. This way, little Johnny could have it in his bedroom, freeing up the family TV.
- Alan Sugar (Amstrad founder)[7]
Based on a Z80 CPU running at 4Mhz with 64KiB RAM, the CPC was the finest machine to program. Besides built-in BASIC, its great asset was its video system which resolution far surpassed its competitors. The ZX-Spectrum could reach 256×192 and the C64 320x200. The CPC on the other end had three modes offering 160x200/16colors, 320x200/4colors, and 640x200/2colors.
What was even better about the CRTC system is that developer could pick the palette colors. It was a little bit weird with its three shade per channel but it results in 27 colors available.
The task of animation was considerably complicated by the convoluted video layout expected by the CRTC.
Regardless of the mode, the screen is always 200 pixels tall and always divided in 25 lines of characters (each 8 rows tall). The table on the right shows where a CRTC starting at 0xC000 would expect each row for each line of character.
Rows are not expected sequentially but 8-way interleaved. That means that a simple BASIC program to clear the screen by filling 16KiB linearly would first draw Line1, row1 (at 0xC000) then, 8 pixels below, Line2, row1 (at 0xC050), then Line3, row1 (at 0xC0A0), and so on.
FOR i=&C000 TO &FFFF:POKE i,255:NEXT[8]
This description does not even factor in when the CRTC start address has been changed or when the screen have been scrolled left or right.
You may have a hard time imagining how to move sprites with such a system. Working with only a raster interrupt, a character based (8 pixels) scroller, and a CPU did not deter game developers. Far from shying away, they deployed treasures of ingenuity resulting in a list of 1,776 games[9] of which many came from the world of arcades.
Ghosts and Goblins was released in arcades during Fall 1985 by Capcom. It was so well received that it became a franchise currently counting twelve titles[10].
To rescue an abducted lover, the hero had to face hordes of Zombies, Magicians, Skeletons, Red Arremers, and Flying Knights to name only a few. Bosses such as Unicorns, Dragons, Satan, and the chief Astaroth were gorgeous and well-animated. The PCB's Motorola 6809 1Mhz was rather weak but boosted by huge DMA "object" movers[11], it commanded a resolution of 256x224 with 256 colors[12] and hordes of huge sprites at 60fps. It was splendid.
It was also an unforgiving game. Enemies popped from everywhere with hard to predict patterns and privileged aiming directions. Dodging attacks was difficult since once triggered the trajectory of a jump could not be adjusted. Get hit once and your armor explodes, leaving you running around in your undies. Get hit another time and you have to start over.
Ghosts'n Goblins, arcade, 1985.
The game was ported to home computers the following year. Thanks to its Blitter co-processor, the 16-bit Amiga reached stellar quality[13] with the Atari ST not too far behind[14]. However when it came to PC[15], C64[16] and CPC[17], the quality of the ports dropped sharply.
On these three platforms, the story was butchered to the point it is unclear why the hero is running around and facing monsters. There is no introduction where Astaroth captures the princess and therefore no story. The game was also considerably shorter since out of the six levels from the arcade, only four made it home. The C64 version could be completed in 7mn.
The CPC version of Ghosts'n Goblins is interesting to study because it is both terrible and terrific.
It is terrible in terms of polish. The hero awkwardly jumps without bending his knees. Arthur cannot lose his armor and dies upon first hit. There is no start and no end. To be fair, it is likely the development team was given at best a few weeks to do it all without access to any of the original assets.
That being said, the game is terrific in terms of what the engine does in order to improve the framerate.
As alluded earlier, the CPC's Z80 could not refresh a whole screen without dropping to a single digit framerate. Yet, adamant to run in full screen with huge sprites, developer Nigel Alderton came up with a trick. He used Mode 0 (160x200 w/ 16 colors) but chose to split each nibble in two. Four colors are used for the background and 12 colors are aliased into three for the sprites.
00-00 | 00-01 | 00-10 | 00-11 | 01-XX | 10-XX | 11-XX |
Besides issues with the fillrate, CPC developers had to deal with what I call the "Atari ST curse" where despite having 128KiB of RAM, CPC 6128 games only used 64KiB out of the 128KiB available in order to be compatible with the 1 million CPC 464 already on the market.
To make things worse, despite some polished titles such as Gryzor and Renegade, the practice of Speccy ports[20] where ZX Spectrum games were shoved straight into CPCs gave ammunition to Amstrad haters. The platform developed a bad gaming rep.
As a remedy the British company released in September 1990 a "Plus" range made of the 464+, the 6128+, and the GX4000. If the technology was still based on a Z80 CPU, the video system was augmented to a 12-bit RGB (32 colors out of 4,096) and an ASIC chip which gifted developers with 16 hard sprites, soft scrolling, and DMA transfer to feed the audio chip automagically.
Amstrad GX4000. (Photo credit: wikipedia.com).
Unfortunately, by that time the industry had started to enter the 16-bit era. The 8-bit Z80 machines from Amstrad suffered when compared to Sega's Genesis and Nintendo's Super Famicom. Customers shunned the "+" line and developers dragged their feet by producing 27, mostly sub-par, games which were often "Direct Disk to Cartridge" ports[21].
Discounted within a few months after their introduction, without a real opportunity to show what they could produce, the "+" machines were an engineering success but a commercial failure from which Amstrad never recovered.
After the demise of the CPC, Sébastien and his generation moved onto other platforms. It would be years until Seb would become reacquainted with the world of Amstrad via cpcwiki.eu forum. In the Retrogaming movement, going under the nickname "Xifos", Seb found himself surrounded with people who shared his love for the CPCs but also occasionally read diverging opinions.
In the past fifteen years it has become trendy in the retro-gaming world to bad mouth the Amstrad CPC. The "+" range in particular is mocked and I thought it was not justified from a technical standing point. The only flaw really was to have been released a few years too late.
I came across some of these people bad mouthing the CPC around the same time I noticed that someone had done a port of Ghosts'n Goblins on Colecovision.
I thought it would be a good game to demonstrate what could really be done with the CPC+.
- Sébastien Harelle
And so it happened. Almost on a lark, Seb embarked in a project to make the best port of Ghosts'n Goblins he could for the platform he loved. If at first he was not sure in which direction to go, things clarified themselves quickly.
I started to tinker with the 6128+ to get myself used to the new capabilities and particularly the ASIC. Eventually another CPC enthusiast named TotO suggested to produce a cartridge targeting the GX4000. I especially liked the idea since the console is by far the most hated piece of hardware in the "Plus" range.
2016 is when Ghosts'n Goblins on GX4000 really got started. At first there was the question of what would be the RAM budget. The GX4000 and 464+ could receive a memory extension but I decided against it since it would not have been commercially viable back in the days. I elected to use the stock configuration which is 64KiB.
Then came the question of the cartridge storage capacity. I also wanted to use what game developers of the time had which was either 128KiB or 256KiB.
In terms of framerate, the goal was to max out the TV. The console was never released on NTSC so that meant running at the 50Hz of PAL.
- Sébastien Harelle
Besides setting the target hardware constraints, Seb's most important design decision was to establish the screen layout. He ended up reconfiguring the CRTC and using the raster interrupt to switch resolution mid-frame.
The CRTC is set to display 200 rows of 80 bytes which result in either 640, 320, or 160 horizontal pixels depending on the mode. Counting in characters this means the screen is 40x26 characters but you can reconfigure the CRTC to display more (overscan) or less. I chose to use 32x28 (so a bit more narrower and taller).
There is a top part which is 32x4 characters in Mode 1 (256x32) for the HUD and a bottom part which is 32x24 characters in Mode 0 (128x192 -8 horizontally for scrolling).
It is advantageous to have 64 bytes lines (instead of 80) since it simplify screen addressing, especially when scrolling. Using a narrower screen made of 64 bytes was common during the years 1985-1993.
- Sébastien Harelle
While manipulating the CRTC was something already doable with the CPC, what is more interesting is the new hardware in the CPC+.
From an engineering perspective, the GX4000 was a tour-de-force. It managed to preserve 100% backward capability while providing augmenting capabilities. The video system for example remains unchanged with Mode 0, 1, and 2. However thanks to the ASIC an extra layer of sprites with its own palette could be added on top of the background[22].
GX4000 architecture.
The powerhouse of the machine of course is the ASIC chip which allows 16 sprites of 16x16 pixels in 15 colors using a color palette separate for the rest of the video system. There is a little bit of inefficiency where the ASIC expects a sprite pixel to be encoded on a byte (8 bits) even though only a nibble (4 bits) is used. Instead of 16 sprites of 256 bytes each it would have been preferable to have 32 sprites of 128 bytes.
The sprites count limitation is important. You can't just use soft sprites (a.k.a drawn in the background layer) when you run out of hard sprites. For example the colors of the sprite may not be available in the background palette.
The soft scrolling capability solves many problems although there are a few subtle things to get everything right.
There is this common misconception that the GX4000 handles soft scrolling fully. In fact, it works a lot like the CPC hardware scroller except you can easily add a delay to the 8 pixels offset resulting in a smooth one pixel offset. But you still have to handle cycling and shifting yourself.
Also, the scroller does not allow increment to a resolution inferior to the current mode. Since the background is in mode 0 I make the background move only every other frame to get the desired visual scrolling speed.
The raster interrupt splits the screen in two vertically with the HUD in Mode 1 128*32 and the rest of the screen in Mode 0 128*192 so you have to be careful when scrolling to keep the upper part static.
In terms of audio, the DMA has three channels to automatically feed the three audio channels. These are taken care of by Arkos player which Targhan used for the music.
- Sébastien Harelle
To save on RAM and storage, I kept the sprites "compressed" (1 pixel/nibble) and only decompress them when they are transferred from RAM to the ASIC. I did not use multiplexing because it did not help much but I used compounding like when Satan appears in the intro which consumes six sprites.
To reduce sprite consumption, I made elements that spawn but don't move (plant enemies, bonuses, ...) be "soft sprites" backed into the background.
Another side effect of the hard sprite limitation is that I originally had Arthur limited to having on shot in-flight. Since the sheltering-in-place I have managed to add a second one but I have not released it.
- Sébastien Harelle
To program the game I started with a plain C file and hand-tuned some functions with inline ASM. Using SDCC compiler and WinApe emulator allowed to iterate fast. A build + deployment took 30 seconds.
For the gameplay and sprites, my starting point was the arcade version. I designed the maps with tilestudio and drew the sprites with PaintShop Pro 5. I did not have an artist to draw any of the assets so I did it all by myself.
I also received numerous mini contributions from the CPC community. TotO for example did the HUD but I also received help from Fano, Ast, ArnoldEmu, Vingazole, Templeton, Ced, and Kukulkan (I hope I did not forget anybody).
- Sébastien Harelle
The cartridge ended up at 256KiB with 16 blocks of 16KiB. All data pertaining to a level is grouped into blocks to ease loading/unloading.
block 0 : code.
block 1 : Add-on code, HUD assets, Dragon assets, Scoareboard assets.
block 2 : Mirrored hard-sprites data.
block 3 : Hard-sprites data.
block 4 : Title screen (splash).
block 5-11 : Level 1-7 (gfx, map, enemies).
block 12 : Mirrored Hard-sprite data (boss)
block 13 : Hard-sprites data (boss)
block 14 : Misc gfx data, Musics, SFX.
block 15 : Arkos audio player, More music.
- Sébastien Harelle
Even though it was not his specialty, Xifos produced music and sound effects. That was until he released a preview which Julien Névo, a.k.a Targhan, came across.
I came across Xifos preview when he posted it on the CPC Wiki. I was impressed with it but I pointed out that the music that he had came up with was not on par with the quality of the rest of his game.
I asked if I could contribute and Xifos accepted. We were very efficient in the sense that I completed all the music within two weeks in early May 2018.
I worked 100% with STarKos directly on a real CPC because I did not feel confident to use Arkos Tracker 2 yet. Since Xifos used Arkos Tracker 1 (AT1) player, I just had to export to this format and my music was in the game!
- Julien Névo
In May 2018, after two years of work, Sébastien and Julien shipped their project[23]. The high quality of the game was a testimony to a relentless effort fueled by passion and dedication.
Ghosts'n Goblins GX4000. Better 35 years later than never!
The community praised the professional quality. All six levels, all animations, all bosses, and all the weapons were there. The 32 colors were used wisely, the music was amazing, and the framerate high. I highly recommend to get WinAPE emulator and play it.
This is the Ghosts'n Goblins the Amstrad deserves.
- Xyphoe[24]
It's bloody fantastic! [...] This proves what the system could have done then.
- Novabug[25]
"Ghosts'n Goblins" receives a spectacular remake for the Amstrad GX4000!
- gx4000.co.uk[26]
"What is the moral of this story?" you may ask. I think it is pretty clear. Next time you are thinking about bad-mouthing the CPC, think twice. It may take two years but someone will make you eat your words!
In March 2004, John Carmack shared an uplifting opinion about people still developing for the Jaguar, long after the Atari console had been discontinued.
There is something noble about developing on a dead platform -- it is so completely for the joy of the development, without any commercial motivation.
- John Carmack
When does a platform truly "dies"? A "dead language" is defined as "a language which is no longer in everyday spoken use". By analogy, a platform would die not when it ceases to be profitable or when it is obsolete, but when people stop playing it and caring about it.
Now the question becomes "what draws people to retro-computing?". Is it nostalgia, the diversity, the creativity, the simplicity, or is it inexplicably fun?
I thought about it and I could not come up with a definitive answer. One thing, however is certain. For those who grew up with them, these machines will go on to live "forever".