Custom 256 colour mode palettes

chat about arc/risc pc gaming & RISC OS software here (NOT the core OS!)Related forum: adventures


Post Reply
User avatar
Rich Talbot-Watkins
Posts: 1555
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Custom 256 colour mode palettes

Post by Rich Talbot-Watkins » Fri Jun 08, 2012 9:25 am

Following on from the Scorpius thread, I decided to have a quick experiment with redefining the palette in 256 colour modes, and realised that in fact it's not so irksome as I remembered.

In fact, I think there was many a wasted opportunity in not redefining the palette in 256 colour modes, as there are a couple of nice options. The palette can be filled with far more vivid colours, instead of the rather 'washed out' looking ones which come by default.

First of all, here's another visualisation of the colour set from the Scorpius thread. This is an '8 bit truecolor' palette, which uses 3 bits red, 3 bits green, and 2 bits blue:
Image
ArcTruecolor3.PNG
ArcTruecolor3.PNG (26.71 KiB) Viewed 2103 times
And now, my favourite one, a version which uses 2 bits red, 3 bits green, and 3 bits blue. There are loads of blues and greens, which would be great for any outdoorsy-type game:
Image
ArcTruecolor4.PNG
ArcTruecolor4.PNG (27.04 KiB) Viewed 2103 times

User avatar
tlsa
Posts: 35
Joined: Wed Oct 31, 2012 2:45 pm
Contact:

Re: Custom 256 colour mode palettes

Post by tlsa » Wed Dec 05, 2012 4:41 pm

So what exactly were the limitations or constraints in choosing a 256 colour palette?

User avatar
Rich Talbot-Watkins
Posts: 1555
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: Custom 256 colour mode palettes

Post by Rich Talbot-Watkins » Sat Dec 15, 2012 12:47 pm

The problem was that there were only 16 palette registers, but 256 colours, so each palette register had to control a block of 16 logical colours.

The hardware arranged this by splitting each 8-bit value in screen memory into two parts: the final colour was determined by using the bottom 4 bits as a palette index, whilst the meaning of the top 4 bits was fixed to contribute 50% red, 50% green, 50% blue and 25% green for each one that was set.

By carefully choosing palette colours which contributed different RGB amounts to those fixed in hardware, it was possible to achieve some reasonable palettes. Normally, RISC OS chose to define the palette where two bits represented 25% red and blue, and the other two bits contributed equal amounts of RGB, hence the 'tint'.

User avatar
tlsa
Posts: 35
Joined: Wed Oct 31, 2012 2:45 pm
Contact:

Re: Custom 256 colour mode palettes

Post by tlsa » Mon Dec 17, 2012 10:13 am

Ah, I see, thanks. Did later hardware like the RiscPC have the same limitations on the colours of 8bit screen modes?

User avatar
Rich Talbot-Watkins
Posts: 1555
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: Custom 256 colour mode palettes

Post by Rich Talbot-Watkins » Mon Dec 17, 2012 10:31 am

No, VIDC20 on the later models had a fully definable 256 colour palette. This limitation only applied to the original (VIDC10) models.

Zarchos
Posts: 2355
Joined: Sun May 19, 2013 8:19 am
Location: FRANCE

Re: Custom 256 colour mode palettes

Post by Zarchos » Wed Dec 25, 2013 5:12 pm

Hello.

What would it take to have these new 256 colour palettes existing as palette files usable under RISC OS ?

Zarchos
Posts: 2355
Joined: Sun May 19, 2013 8:19 am
Location: FRANCE

Re: Custom 256 colour mode palettes

Post by Zarchos » Tue Jan 07, 2014 7:22 pm

Hello again ...

Help ! Can you tell me how to turn the result of the BASIC program to generate palettes into ... palette files usable under RISC OS.
Just in case !Translator could use this new palette when it converts let's say a BMP or a GIF file.

So why do I need that (as I know some readers will be happy to tell me I can do without it... remember the Soviet era ;-) ?)
Explanations follow :
I've found the graphics package GrahicsGale very nice to work on the PC, with an Archimedes palette (from the palette3 program).
My issue is the following : OK on the PC I can work with the Archie (new) palette (I've got the exact same colours, in the exact same order ... ie byte values from 0 to 255 define the same colours on both computers).
So the issue : when I transfer the images from the PC to the Archie, I need a software to extract on the Archie the raw data describing the image, but I don't want [-X this Archie software to try to adapt the paletted file (from the PC) to the RISC OS default palette.
So, has anyone a solution ?
Yes I know the BMP format is not that difficult to decode so I could write my own decoder on the Archie to get what I want but if that existed already it would save the hassle...

User avatar
Rich Talbot-Watkins
Posts: 1555
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: Custom 256 colour mode palettes

Post by Rich Talbot-Watkins » Tue Jan 07, 2014 7:35 pm

To be honest, I have no idea if RISC OS / ColourTrans can deal with 256 colour modes with modified palettes. Bearing in mind that there's no full greyscale available with either of those new palettes, the Desktop might struggle too.

I don't know the format of a palette file but I expect it could be reverse engineered very trivially - I suspect it's a pure stream of VDU 19s, in which case you could generate it easily. Whether RISC OS will allow it to be used in a 256 colour mode is a different issue of course! Good luck!

Zarchos
Posts: 2355
Joined: Sun May 19, 2013 8:19 am
Location: FRANCE

Re: Custom 256 colour mode palettes

Post by Zarchos » Tue Jan 07, 2014 7:52 pm

#-o

poink
Posts: 963
Joined: Tue Mar 01, 2011 10:27 am
Contact:

Re: Custom 256 colour mode palettes

Post by poink » Wed Aug 19, 2015 11:15 pm

Rich Talbot-Watkins wrote:To be honest, I have no idea if RISC OS / ColourTrans can deal with 256 colour modes with modified palettes.
I believe it would work from RISC OS 3 onwards, which introduced much better colour handling. I'm pretty sure it must work by 3.5 to deal with 256 greyscale palettes.
Rich Talbot-Watkins wrote:Bearing in mind that there's no full greyscale available with either of those new palettes, the Desktop might struggle too.
I think the only thing that might get upset is the Font Manager; but as everything goes through ColourTrans, the more likely outcome is that it is forced to use slightly odd colours for anti-aliasing.

The palette manager creates a smooth blend between entries 0 and 7; but the PRMs suggest getting around that by setting 0 and 7 *first* and then customising the others.
Rich Talbot-Watkins wrote:I don't know the format of a palette file but I expect it could be reverse engineered very trivially - I suspect it's a pure stream of VDU 19s, in which case you could generate it easily.
Yes, that's correct - it's on page 3-284 in the PRMs (page 294 in the PDF copy of PRM3 on the Pi), in the documentation for *WimpPalette.

There's actually two forms, type 1, which is the RGB bytes for the 16 Palette colours, then the border colour, then the 3 pointer colours. And type 2, which is a stream of VDU19s. The type 1 is only read for backwards compatibility, the palette utility writes type 2.

*edit*: The PRM3 gets the format of a VDU19 wrong though- it's VDU 19,logical colour,mode,red,green,blue, See PRM 1-590 (PDF page 604 of PRM1 on the Pi).

So, the first entry in the standard palette is just the following bytes.

13 0 10 FF FF FF

Second entry follows immediately. There are no headers etc., to worry about.

Zarchos
Posts: 2355
Joined: Sun May 19, 2013 8:19 am
Location: FRANCE

Re: Custom 256 colour mode palettes

Post by Zarchos » Thu Apr 28, 2016 9:30 pm

Back to this thread because I think this addition could be interesting for people researching a way to create custom palettes easily :
InterGIF is able to create the best 256 colour palette for a given picture.
http://www.chaos.org.uk/~pdh/software/intergif.htm
and since it can work with ChangeFSI (as a preprocessor) it means it's going to be able to do that for virtually any format of pictures.



PS : Latest version of InterGIF is on Martin Wuertner website :
http://www.mw-software.com/software/freeware.html

User avatar
jgharston
Posts: 3723
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: Custom 256 colour mode palettes

Post by jgharston » Thu Apr 28, 2016 10:43 pm

Zarchos wrote:Hello again ...

Help ! Can you tell me how to turn the result of the BASIC program to generate palettes into ... palette files usable under RISC OS.
95 *SPOOL outfile
175 *SPOOL
176 *SetType outfile FED

A palette file is purely and simply a stream of VDU 19 sequences.

Whether you can use that palette file on the machine you read it with depends on you having suitable video hardware with a 256-entry palette and a version of RISC OS that understands it has a 256-entry palette.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

Zarchos
Posts: 2355
Joined: Sun May 19, 2013 8:19 am
Location: FRANCE

Re: Custom 256 colour mode palettes

Post by Zarchos » Fri Apr 29, 2016 5:36 am

jgharston wrote:
Zarchos wrote:Hello again ...

Help ! Can you tell me how to turn the result of the BASIC program to generate palettes into ... palette files usable under RISC OS.
95 *SPOOL outfile
175 *SPOOL
176 *SetType outfile FED

A palette file is purely and simply a stream of VDU 19 sequences.

Whether you can use that palette file on the machine you read it with depends on you having suitable video hardware with a 256-entry palette and a version of RISC OS that understands it has a 256-entry palette.
Hey thanks !
With RISC OS I expected sthing that simple and straightforward.

Post Reply