New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / graphics / getcolormap.c
blobe97b3e321a5218ab6f1bde56391f92e2a2e6642c
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function GetColorMap()
6 Lang: english
7 */
8 #include "exec/memory.h"
9 #include "exec/types.h"
10 #include "proto/exec.h"
11 #include "graphics/view.h"
12 #include "graphics_intern.h"
14 /*****************************************************************************
16 NAME */
17 #include <proto/graphics.h>
19 AROS_LH1(struct ColorMap *, GetColorMap,
21 /* SYNOPSIS */
22 AROS_LHA(ULONG, entries, D0),
24 /* LOCATION */
25 struct GfxBase *, GfxBase, 95, Graphics)
27 /* FUNCTION
28 Allocates, initilizes a ColorMap structure and passes back the
29 pointer. This enables you to do calls to SetRGB4() and LoadRGB4()
30 to load colors for a view port.
31 The ColorTable pointer in the ColorMap structure points to a hardware
32 specific colormap data structure which you should not interpret.
34 INPUTS
35 entries - the number of entries for the colormap
37 RESULT
38 NULL - not enough memory could be allocated for the necessary
39 data structures
40 other - pointer to a initilized ColorMap structure that may be
41 stored into the ViewPort.ColorMap pointer.
43 NOTES
45 EXAMPLE
47 BUGS
49 SEE ALSO
50 FreeColorMap SetRGB4() graphics/view.h
52 INTERNALS
53 RGB Colortable with preference values is incomplete.
55 HISTORY
57 *****************************************************************************/
59 AROS_LIBFUNC_INIT
60 AROS_LIBBASE_EXT_DECL(struct GfxBase *,GfxBase)
62 struct ColorMap * NewCM = (struct ColorMap *)AllocMem(sizeof(struct ColorMap),
63 MEMF_PUBLIC|MEMF_CLEAR);
64 LONG * ptr1, * ptr2;
66 #if 0
67 /* ColorTable with some preference values; !!! incomplete */
68 const WORD RGBColorTable[] = {0x0000,0x0f00,0x00f0,0x0ff0,
69 0x000f,0x0f0f,0x00ff,0x0fff}; /* !!!etc. */
70 #endif
73 /* go on if we got the memory for the ColorMap */
74 if (NULL != NewCM)
76 /* get memory for the ColorTable */
77 NewCM -> ColorTable = AllocMem(entries * sizeof(UWORD), MEMF_CLEAR|MEMF_PUBLIC);
79 /* get memory for LowColorbits !!!how much memory we need for that?? */
80 NewCM -> LowColorBits = AllocMem(entries * sizeof(UWORD), MEMF_CLEAR|MEMF_PUBLIC);
82 ptr1 = NewCM -> ColorTable;
83 ptr2 = NewCM -> LowColorBits;
85 /* did we get all the memory we wanted? */
86 if ( (NULL != ptr1) && (NULL != ptr2) )
88 #if 0
89 ULONG i;
90 LONG * L_RGBColorTable = (LONG *)&RGBColorTable[0];
91 #endif
93 /* further init the GetColorMap structure */
94 NewCM->Type = COLORMAP_TYPE_V39;
95 NewCM->Count = entries;
96 NewCM->SpriteResolution = SPRITERESN_DEFAULT;
97 NewCM->SpriteResDefault = SPRITERESN_ECS;
98 NewCM->AuxFlags = CMAF_FULLPALETTE;
99 NewCM->VPModeID = -1;
100 NewCM->SpriteBase_Even = 0x0010;
101 NewCM->SpriteBase_Odd = 0x0010;
102 NewCM->Bp_1_base = 0x0008;
104 #if 0
105 /* Fill the ColorTable and the LowColorBits with the appropriate Data */
107 /* as we`re clever we`re doing some 32 bit copying with the 16 bit data */
108 for (i = 0; i < (entries >> 1); i++)
110 LONG ColorValue = L_RGBColorTable[i];
111 *ptr1++ = ColorValue;
112 *ptr2++ = ColorValue;
114 /* is there one WORD left to copy? */
115 if (1 == (entries & 1) )
117 WORD ColorValue = RGBColorTable[entries-1];
118 *(WORD *)ptr1 = ColorValue;
119 *(WORD *)ptr2 = ColorValue;
121 #endif
124 else /* not enough memory for the tables */
126 if (NULL != NewCM -> ColorTable)
127 FreeMem(NewCM -> ColorTable, entries * sizeof(UWORD));
128 if (NULL != NewCM -> LowColorBits)
129 FreeMem(NewCM -> LowColorBits, entries * sizeof(UWORD));
131 FreeMem(NewCM, sizeof(struct ColorMap));
132 /* make return value invalid */
133 NewCM = NULL;
136 } /* if (NULL != NewCM) */
138 return NewCM;
140 AROS_LIBFUNC_EXIT
142 } /* GetColorMap */