IanSB / RGBtoHDMI

Bare-metal Raspberry Pi project that provides pixel-perfect sampling of BBC Micro video and conversion to HDMI
GNU General Public License v3.0
129 stars 6 forks source link

Palattes #27

Open wthorch42 opened 7 months ago

wthorch42 commented 7 months ago

Hi, Ian,

I have a question. How would I go about creating a new palette or adjusting an existing one? I think the VIC20 Lumacode palette needs just a touch of tweaking, but I don't know how to do it. I looked through the documentation, but didn't see anything. I also tried looking through the file system on the SD card and didn't see any obvious place where the palettes were defined. Is this something you have to do before compiling a new release or is it something an amateur like myself can do?

Thanks Todd

IanSB commented 7 months ago

@wthorch42 The palettes are generated programmatically on first boot and then stored in /palettes on the SD card. You can then edit those files or create additional custom palette files that you could manually select from the palette menu:

Each palette file contains 257 32 bit words with the first 256 being the palette colours and the last one being the number of entries that are used by the current palette.

Each palette colour word contains the following 4 bytes in order: Red value 0-255 Green value 0-255 Blue value 0-255 Mono value 0-255 (used in mono mode)

Generally when less than 256 colours are defined the values should repeat to fill the 256 entries (this is not actually necessary but ensures there is something valid in those entries.

So for a VIC20 custom palette file you would put the RGBM values in the first 16 words, repeat that 15 more times and put 0x10, 0x00, 0x00, 0x00 at the end.

Note the colour order is not the standard VIC20 order but you can use this table to work out the order: {0, 6, 2, 4, 9, 11, 12, 3, 8, 14, 15, 7, 5, 10, 13, 1} i.e. palette entry 0 is VIC colour 0 palette entry 1 is VIC colour 6 palette entry 2 is VIC colour 4 ... palette entry 15 is VIC colour 1

If you get something that looks better, please post the values.

wthorch42 commented 7 months ago

I haven’t had a chance to do a side-by-side comparison, but give this a try.

(https://github.com/IanSB/RGBtoHDMI/files/14210059/VIC-20_LumaCode.zip)

Sent from Mail for Windows

From: IanSB Sent: Monday, February 5, 2024 1:55 PM To: IanSB/RGBtoHDMI Cc: Todd Horch; Mention Subject: Re: [IanSB/RGBtoHDMI] Palattes (Issue #27)

@wthorch42 The palettes are generated programmatically on first boot and then stored in /palettes on the SD card. You can then edit those files or create additional custom palette files that you could manually select from the palette menu: Each palette file contains 257 32 bit words with the first 256 being the palette colours and the last one being the number of entries that are used by the current palette. Each palette colour word contains the following 4 bytes in order: Red value 0-255 Green value 0-255 Blue value 0-255 Mono value 0-255 (used in mono mode) Generally when less than 256 colours are defined the values should repeat to fill the 256 entries (this is not actually necessary but ensures there is something valid in those entries. So for a VIC20 custom palette file you would put the RGBM values in the first 16 words, repeat that 15 more times and put 0x10, 0x00, 0x00, 0x00 at the end. Note the colour order is not the standard VIC20 order but you can use this table to work out the order: {0, 6, 2, 4, 9, 11, 12, 3, 8, 14, 15, 7, 5, 10, 13, 1} i.e. palette entry 0 is VIC colour 0 palette entry 1 is VIC colour 6 [VIC-20_LumaCode.zip]

palette entry 2 is VIC colour 4 ... palette entry 15 is VIC colour 1 If you get something that looks better, please post the values. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

IanSB commented 7 months ago

@wthorch42

I haven’t had a chance to do a side-by-side comparison, but give this a try.

If you attached a file to your email reply it was not included in the github thread so you will have to view the thread and post it directly.