Topic : TOS - The Operating System Author : Version : tos.hyp (December 19, 2008) Subject : Programmieren/Atari Nodes : 3010 Index Size : 93790 HCP-Version : 5 Compiled on : Atari @charset : atarist @lang : @default : Title @help : @options : +g -i -s +x +zz -t4 @width : 70 View Ref-File7.13.2 COLOR_RGB TOS typedef struct { uint16 reserved; /* Set to 0 or the index of the entry */ uint16 red; /* Red: 0<->65535 */ uint16 green; /* Green: 0<->65535 */ uint16 blue; /* Blue: 0<->65535 */ } COLOR_RGB; If the colour data in a program is present in a sensible format (e.g. 8 bits per channel) already, one can save oneself a transformation with multiplication and division. The Shift and OR functions of the processor perform this faster and more elegantly. eleganter. Example: The colour value is described by the byte variables r, g, b. The correct conversion to the 16-bit format of the COLOR_RGB structure proceeds as follows: COLOR_RGB color; color.reserved = 0; color.red = r; color.red |= (color.red << 8); color.green = g; color.green |= (color.green << 8); color.blue = b; color.blue |= (color.blue << 8); The structure element reserved should be set to 0 or (for building up a colour table) contain the index of the entry. In each case, however, the upper 8 bits of reserved must be set to 0, as they may be used by the colour routines for some flags.