Tuesday 23 February 2016

Getting the colours right

Again, Real Life has been putting a serious dent into my spare time but at lunchtime today I finally managed to get the palette right on the Neo Geo for both ZX Spectrum and CPC graphics modes.

One of 4 room palettes of the CPC graphics mode (Neo Geo)

It's actually been quite tricky and I've gone back to the drawing board several times in several areas over the last week or so. In fact I've had to regenerate all the tiles (sprites) and FIX layer graphics, including the panel - some several times over - as I've juggled the palette.

The panel is now generated from the CPC graphics, which includes a larger mask around the frame so that the sun/moon don't show either end without further trickery.

The challenge has not been only supporting both ZX Spectrum and CPC colours, but supporting them both at the same time, since the main menu and end-of-game screens are all from the ZX version, with ZX palette - that's half the FIX layer palette gone!

And a fact that didn't click earlier when it should've - the CPC graphics support 4 colours plus transparency, in 2 bits. And here is where the mystery extra byte in the sprite data comes into play! The CPC sprite rendering routine is a mess of lookup tables and self-modifying code, but what I've managed to deduce is that the 3rd byte is a flag that denotes colour 1 should actually be rendered as colour 3, which is otherwise used as the mask colour and normally rendered black. So on the Neo Geo, I've had to duplicate and modify the palette for these sprites.

And as I sit here typing this up, I've just realised there could be a better way to do it on the Neo Geo... oh well, I'm not changing it now.

The idea was always to keep code that differentiated between ZX and CPC graphics to a minimum to keep the code tidy and easy to maintain; I've been fairly successful by keeping the palettes somewhat compatible.

And just because I think this blog needs more eye candy...

The CPC orange theme. Because of a bug I didn't get to see this for some time

And I think I will add the CPC title screen, as ordinary as it is, just as a visual indication of which version you're about to play!

UPDATE: And now I have...

The CPC title screen on the Neo Geo

That's it for the Neo Geo version; just need to go back and fix the game play issues related to having no .data segment (should be tedious but trivial) and of course the sprite Z-ordering.

UPDATE #2: Neo Geo now copies what would be in the .data segment into RAM - as a result it now has special objects that can be picked-up and dropped. I still need to add hardware sprite handling logic to this aspect of it, but game play is almost on par with the other ports now.

No comments:

Post a Comment