log in | register | forums


User accounts
Register new account
Forgot password
Forum stats
List of members
Search the forums

Advanced search
Recent discussions
- RISC OS 'Advent' Calendar 2023 - FAST Xmas tree (News:)
- MUG Xmas Fair report 2023 (News:8)
- RISCOSbits takes to the ROADS (News:1)
- RISC OS 'Advent' Calendar 2023 - ROOL (News:)
- Rougol November 2023 talk is on RiscPC/Archimedes repairs (News:8)
- MUG RISC OS Xmas Market is on saturday (News:)
- RISC OS 'Advent' Calendar 2023 - Elesar (News:)
- RISC OS 'Advent' Calendar 2023 - PiHard Xmas tree (News:)
- November 2023 News Summary (News:1)
- RISC OS online Developer social meetup on saturday (News:)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
Site Search
Article archives
Acorn Arcade forums: Programming: Palette entry word deciphering
  Palette entry word deciphering
  (10:17 11/1/2001)
  Phlamethrower (15:32 11/1/2001)
    andrew (19:55 11/1/2001)
andrew Message #4709, posted at 10:17, 11/1/2001
Unregistered user Does there exist a SWI for converting GCOL numbers in palette entry words or does one have to manipulate the bits oneself?



  ^[ Log in to reply ]
Phlamethrower Message #4710, posted at 15:32, 11/1/2001, in reply to message #4709
Unregistered user Goes and consults PRM's....

Presuming what you're doing is getting an RGB value from the palette, then what you need is (unsurprisingly) OS_ReadPalette.

R0=logical colour
R1=type of colour (16=normal, 24=border, 25=pointer)

R2 and R3 will return the different flashing states of the colour, in this format:

Bits 0-6 value showing how colour was programmed
7 Supremacy bit
8-15 Red
16-23 Green
24-31 Blue

If you're after getting RGB from a GCOL value, then the format of GCOL is:

Bits 0-1 Tint bits 0-1
2-3 Red bits 2-3 (Other 2 in tint)
4-5 Green 2-3
6-7 Blue 2-3

If you want to convert a palette entry to GCOL, then use ColourTrans_ReturnGCOL:

R0=Palette entry (&BBGGRR00)
Returns GCOL in R0

To convert GCOL to palette though it looks like you'll have to do it manually. From BASIC (With g as the GCOL and c as the output)

c=((g AND 7)*17*256)+((g AND 3)*17*65536)+((g AND 48)*17*16384*4)+((g AND 3)*17*256*65536)+((g AND 192)*17*16*65536)

And from C:

c=((g & 7)*17*256)+((g & 3)*17*65536)+((g & 48)*17*16384*4)+((g & 3)*17*256*65536)+((g & 192)*17*16*65536)

I haven't tested these though so don't expect them to work.

[Edited by Phlamethrower at 15:33, 11/1/2001]

  ^[ Log in to reply ]
andrew Message #4711, posted at 19:55, 11/1/2001, in reply to message #4710
Unregistered user Yes, sorry what I mean is convering to a pallette entry word which is rather different than the GCOL format.
Manual it is, it seems!


  ^[ Log in to reply ]

Acorn Arcade forums: Programming: Palette entry word deciphering