This module is not part of the ROM, but is in !system.modules.colours in the Welcome Suite. It provides generally useful functionality, and so it is documented as part of RISC OS.
Throughout, a mode of -1 means the current mode, and a palette pointer of
0 means the default palette (i.e. the palette set by the MOS on entry to
the specified mode).
-1 as a palette pointer refers to the current palette; this is generally only
sensible if -1 is specified for the mode.
"Palette pointer" (from here on just "palette") means a pointer to a list of words, containing BBGGRRxx. In 256 colour modes only the first 16 of these are be referenced, real colours being built from there.
When the destination is a 256 colour mode, "GCOL" means a byte with the real GCOL in bits 2-7, and the tint in bits 0 & 1.
"Colour number" is used to refer to the byte that's placed into screen memory; identical to the GCOL except for 256 colour modes.
"Most different" means "maximises the distance function"; "closest" means
"minimises the distance function". The distance function is a weighted
least squares, i.e.
where colours are (Rs, Gs, Bs) and (Rd, Gd, Bd)
distance = redweight*(Rs-Rd)^2 +
greenweight*(Gs-Gd)^2 + blueweight*(Bs-Bd)^2.
Currently, blueweight = 1, redweight = 2, greenweight = 3; this seems to give acceptable results on the limited problem we are tackling.
ColourTrans_SelectTable (&40740)
and ColourTrans_SelectGCOLTable (&40741)
For both the above:
Input: r0 = source mode
r1 = source palette
r2 = destination mode
r3 = destination palette
r4 = buffer (assumed to be long enough,
i.e. no_of_colours(source mode) bytes long)
ColourTrans_ReturnGCOL (&40742)
ColourTrans_SetGCOL (&40743)
ColourTrans_ReturnColourNumber (&40744)
ColourTrans_ReturnGCOLForMode (&40745)
ColourTrans_ReturnColourNumberForMode (&40746)
ColourTrans_ReturnOppGCOL (&40747)
ColourTrans_GCOLToColourNumber (&4074C)
ColourTrans_ColourNumberToGCOL (&4074D)
ColourTrans_ReturnFontColours (&4074E)
r3 = max offset
Output: r0-r3 as passed to Font_SetFontColour
This returns font colours to match the given colours; the closest approximation to the foreground and background will be set, and as many intermediate colours (up to the specified maximum) as can be done.
ColourTrans_SetFontColours also calls Font_SetFontColours.
Note: in 256 colour modes, only 16 font colours can be set up before
previously returned information becomes invalid. Therefore, if using
ReturnFontColours to obtain information to insert in a string to pass to the
font painter, do not allow more than 16 distinct colours in the string.
ColourTrans_InvalidateCache (&40750)