What differences in programming Spectrum and CPC

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
zack4mac
Berk
Posts: 17
Joined: Sat Apr 13, 2019 12:20 pm

What differences in programming Spectrum and CPC

Post by zack4mac » Sun Apr 14, 2019 9:12 pm

I know they have the same Z80 and later the same sound chips but how different are they when programming and can programs be ported from one to the other easily? do the differences stop between the basic programming languages? what advantages for one over the other? :mrgreen:
0 x

User avatar
Ast A. Moore
Dynamite Dan
Posts: 1134
Joined: Mon Nov 13, 2017 3:16 pm

Re: What differences in programming Spectrum and CPC

Post by Ast A. Moore » Sun Apr 14, 2019 10:39 pm

zack4mac wrote:
Sun Apr 14, 2019 9:12 pm
can programs be ported from one to the other easily?
Disclaimer: I’m no expert on the CPC.

Define “easily.” Obviously, any game logic will remain virtually, if not completely, identical. Any graphics/display, sound, and keyboard polling routines will have to be rewritten. Of them, the display routines will be the ones that would be using drastically different approaches. Not only is the display handling implemented differently on the two machines, but sprites and other graphical data may also have to be stored and retrieved differently for optimal performance. (And if a game relies on any ROM routines, obviously, they’d have to be rewritten.)

Having said that, porting simpler, less demanding games, could be a fairly straightforward task. However, most, if not all, software written for eight-bit micros benefits from extensive optimizations tailored specifically to account for the peculiarities and quirks of individual hardware. Universality usually leads to mediocre results.
0 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

User avatar
djnzx48
Manic Miner
Posts: 479
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: What differences in programming Spectrum and CPC

Post by djnzx48 » Sun Apr 14, 2019 10:47 pm

Ast A. Moore wrote:
Sun Apr 14, 2019 10:39 pm
Any graphics/display, sound, and keyboard polling routines will have to be rewritten. Of them, the display routines will be the ones that would be using drastically different approaches.
Not necessarily. According to this page, games that were converted from the Spectrum to the CPC often left all the display routines unchanged, including the 8x8 attribute system. They seemingly used some technique to emulate the Spectrum screen in software, slowing the game down.
0 x

User avatar
Ast A. Moore
Dynamite Dan
Posts: 1134
Joined: Mon Nov 13, 2017 3:16 pm

Re: What differences in programming Spectrum and CPC

Post by Ast A. Moore » Sun Apr 14, 2019 10:52 pm

djnzx48 wrote:
Sun Apr 14, 2019 10:47 pm
Ast A. Moore wrote:
Sun Apr 14, 2019 10:39 pm
Any graphics/display, sound, and keyboard polling routines will have to be rewritten. Of them, the display routines will be the ones that would be using drastically different approaches.
games that were converted from the Spectrum to the CPC often left all the display routines unchanged, including the 8x8 attribute system. They seemingly used some technique to emulate the Spectrum screen in software, slowing the game down.
Fair enough, but that’s a really lazy approach.
0 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

Bizzley
Microbot
Posts: 124
Joined: Thu Nov 16, 2017 10:47 am

Re: What differences in programming Spectrum and CPC

Post by Bizzley » Mon Apr 15, 2019 12:09 am

Ast A. Moore wrote:
Sun Apr 14, 2019 10:52 pm
Fair enough, but that’s a really lazy approach.
But it was cheap, quick, pretty easy to do and meant that the CPC got some games that it wouldn't ordinarily have had.

CPC owners may not have like the quality of what they were getting but it was better then getting nothing at all.
0 x
"He made eloquent speeches to an audience consisting of a few depressed daffodil roots, and sometimes the cat from next door."

User avatar
zack4mac
Berk
Posts: 17
Joined: Sat Apr 13, 2019 12:20 pm

Re: What differences in programming Spectrum and CPC

Post by zack4mac » Mon Apr 15, 2019 4:26 am

Some brilliant points and very clearly stated. I am starting to grasp that it is not necessarily the machine but the community that surrounds it, a community that has not shown any aggression or disrespect. This is exactly the reason I have shied away from the C64, which like the spectrum is a great machine but sadly I have noticed there seems to be a lot of infighting discrediting others and their machines extending to pointless aggression this is also true of certain Amiga communities and lets their chosen architecture down.

I cant wait until my spectrum arrives and is up and running.

Thanks again for your insightful thoughts. :D and sorry for going off topic.
0 x

User avatar
reidrac
Berk
Posts: 11
Joined: Sun Dec 09, 2018 4:27 pm
Location: Bristol, UK
Contact:

Re: What differences in programming Spectrum and CPC

Post by reidrac » Mon Apr 15, 2019 5:57 am

I've made few CPC games (and speccy too), as someone has said already there are differences you would expect; but for me the most relevant ones are: 4 bits per pixel (16 colours) and 2 bits per pixel (4 colours) graphical modes (colours to choose from a palette of 27) with no attibutes, there's an int at 300Hz instead of 50Hz, there are 64K of RAM and the ROM's can be disabled to access to all it, and the video memory can be configured to use any memory address (including in 64K models).

The biggest problems with a port is that the graphics need to be converted, otherwise the CPC fans won't like it. If you don't do it and go with the 2 bits per pixel model, you'll end with mostly monochrome graphics, or the 8x8 attribute limitation of the speccy that doesn't exist in the CPC. Ideally people prefer 4 bits per pixel and 16 colours, because that's one of the great features of the system, but the pixels are 2:1, so you can't reuse the speccy graphics.
0 x

User avatar
1024MAK
Manic Miner
Posts: 476
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: What differences in programming Spectrum and CPC

Post by 1024MAK » Mon Apr 15, 2019 6:45 am

zack4mac wrote:
Sun Apr 14, 2019 9:12 pm
I know they have the same Z80 and later the same sound chips but how different are they when programming and can programs be ported from one to the other easily? do the differences stop between the basic programming languages? what advantages for one over the other? :mrgreen:
The only thing that is exactly the same is the Z80 CPU.
The later 128K ZX Spectrum machine’s do use the same sound chip, but the interface arrangements are different.
The bank memory switching is different.
The ROM code, OS and BASIC are all completely different.
The video display hardware is completely different.
The keyboard is different.

Mark
0 x

AndyC
Manic Miner
Posts: 251
Joined: Mon Nov 13, 2017 5:12 am

Re: What differences in programming Spectrum and CPC

Post by AndyC » Mon Apr 15, 2019 7:13 am

djnzx48 wrote:
Sun Apr 14, 2019 10:47 pm
Ast A. Moore wrote:
Sun Apr 14, 2019 10:39 pm
Any graphics/display, sound, and keyboard polling routines will have to be rewritten. Of them, the display routines will be the ones that would be using drastically different approaches.
Not necessarily. According to this page, games that were converted from the Spectrum to the CPC often left all the display routines unchanged, including the 8x8 attribute system. They seemingly used some technique to emulate the Spectrum screen in software, slowing the game down.
Well yes, there are some that mimic the Spectrum display - either by using the same backbuffer technique as the Speccy code, but changing the actual render pass to write a CPC format screen from the backbuffer, or by altering the drawing routines to read speccy format data but write it out differently. The Dizzy games, for example, have all the background items coloured from 2 to 7 - numbered for the Speecy colour they're drawn in, but that three bit value gets mapped onto the CPC 4 colours using the two most significant bits (this is why there aren't any blue objects in the Speccy version, it would map onto black!)

Depending on the type of game, this can work ok (see Dizzy, though the egg himself is a special case re-coloured sprite) or cause significant performance hits a graphical quirks (see R-Type). It looks really bad if your game seems to have colour clash on a machine with no such limits.

A slightly less lazy approach is to keep the background mono using inks 0 & 1, but then XORing mono sprites onto the screen in ink 2 and ink 3 the same colour as 2. This "colour plane" approach means you get no graphical distortion from the XOR effect (except when sprites overlap) and your mono sprites can stand out more from the scenery (Uridium is doing something similar to this, but not quite) because they are a totally different colour.

Using modified, coloured in graphics, whether in the four colour Mode 1 or 16 colour Mode 0 is a much nicer approach. Head over Heels shows how much nicer even re-coloured 4 graphics can be. It's still possible to retain most of the core game logic, so porting between machines is still fairly easy. Going full out and taking advantage of hardware tricks with the CRTC and such will give you the best results, as will re-optimizing core routines around the CPC's different contention model, but obviously anything like that makes porting more complicated.
0 x

User avatar
Pegaz
Manic Miner
Posts: 241
Joined: Mon Nov 13, 2017 1:44 pm

Re: What differences in programming Spectrum and CPC

Post by Pegaz » Mon Apr 15, 2019 8:19 am

If I remember correctly, Dynamite Dan II cpc port, was converted from Spectrum original for just week or two.
It wasnt an easy task, but it showed how much the two machines are actually related.

@zack4mac
Well, in the last couple of years, c64 scene has become much better in many ways.
Amiga community is quite another story and situation is even worse, than what you have just described.
0 x

Post Reply