log in | register | forums


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

Advanced search
Recent discussions
- June 2022 News Summary (News:1)
- teh website (PP:43)
- Updated RiscFF GUI front end for FFmpeg (News:1)
- Midlands User group Online...ow is on Saturday 2nd July (News:2)
- Rougol RISC OS 35th birthday celebrations (News:1)
- Rougol June talk is a 35th birthday celebration for RISC OS (News:)
- RISC OS interview with Andrew Oyston (News:)
- FOURtify your Pi with RISCOSbits (News:)
- Drag'n'Drop 11i3 edition reviewed (News:)
- RISCOSbits teams up with P...er payments by instalments (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