ColorMap
ColorMap
This structure is the primary storage for palette data.
Color data itself is stored in two tables: ColorTable and LowColorBits. These fields are actually pointer to arrays of UWORDs. Each UWORD corresponds to one color. Number of UWORDs in these array is equal to Count value in this structure. ColorTable stores upper nibbles of RGB values, LowColorBits stores low nibbles.
Example:
color number 4, value: 0x00ABCDEF
ColorTable [4] = 0x0ACE,
LowColorBits[4] = 0x0BDF
When setting a ColorTable entry upper nibble is kept unchanged instead of just zeroing it out. This means that this nibble is used for something by Amiga chipset (perhaps alpha value for genlock?)
SpriteBase fields keep bank number, not a color number. On m68k Amiga colors are divided into banks, 16 per each. So bank number is color number divided by 16. Base color is a number which is added to all colors of the sprite in order to look up the actual palette entry.
struct ColorMap { UBYTE Flags; /* see below */ UBYTE Type; /* Colormap type (reflects version), see below */ UWORD Count; /* Number of palette entries */ APTR ColorTable; /* Table of high nibbles of color values */ /* The following fields are present only if Type >= COLORMAP_TYPE_V36 */ struct ViewPortExtra * cm_vpe; /* ViewPortExtra, for faster access */ APTR LowColorBits; /* Table of low nibbles of color values */ UBYTE TransparencyPlane; UBYTE SpriteResolution; /* see below */ UBYTE SpriteResDefault; UBYTE AuxFlags; struct ViewPort * cm_vp; /* Points back to a ViewPort this colormap belongs to */ APTR NormalDisplayInfo; APTR CoerceDisplayInfo; /* The following fields are present only if Type >= COLORMAP_TYPE_V39 */ struct TagItem * cm_batch_items; ULONG VPModeID; struct PaletteExtra * PalExtra; /* Structure controlling palette sharing */ UWORD SpriteBase_Even; /* Color bank for even sprites (see above) */ UWORD SpriteBase_Odd; /* The same for odd sprites */ UWORD Bp_0_base; UWORD Bp_1_base; }; /* Flags */ #define CMF_CMTRANS 0 #define COLORMAP_TRANSPARENCY (1<<0) #define CMF_CPTRANS 1 #define COLORPLANE_TRANSPARENCY (1<<1) #define CMF_BRDRBLNK 2 #define BORDER_BLANKING (1<<2) #define CMF_BRDNTRAN 3 #define BORDER_NOTRANSPARENCY (1<<3) #define VIDEOCONTROL_BATCH (1<<4) #define USER_COPPER_CLIP (1<<5) #define CMF_BRDRSPRT 6 #define BORDERSPRITES (1<<6) /* Type */ #define COLORMAP_TYPE_V1_2 0 #define COLORMAP_TYPE_V36 1 #define COLORMAP_TYPE_V39 2 /* SpriteResolution */ #define SPRITERESN_ECS 0x00 #define SPRITERESN_140NS 0x01 #define SPRITERESN_70NS 0x02 #define SPRITERESN_35NS 0x03 #define SPRITERESN_DEFAULT 0xFF