Changed colormap format to 256 x 24bit RGB to allow for richer gfx; first step towards fulfilling bug #314

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1509 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2005-02-03 07:20:45 +00:00
parent 1beccebf1e
commit 17955f993f
17 changed files with 51 additions and 95 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+18 -54
View File
@@ -488,7 +488,7 @@ typedef struct xform_control
{ {
COLORMAPPTR CMapPtr; COLORMAPPTR CMapPtr;
SIZE Ticks, TTotal, TOrig; SIZE Ticks, TTotal, TOrig;
DWORD OldCMap[NUMBER_OF_PLUT_UINT32s]; UBYTE OldCMap[PLUT_BYTE_SIZE];
} XFORM_CONTROL; } XFORM_CONTROL;
#define MAX_XFORMS 32 #define MAX_XFORMS 32
@@ -565,7 +565,6 @@ xform_PLUT_step (SIZE TDelta)
{ {
XFORM_CONTROL *control; XFORM_CONTROL *control;
COLORMAPPTR ColorMapPtr; COLORMAPPTR ColorMapPtr;
DWORD *pCurCMap, *pOldCMap;
int i; int i;
if (!XFormControl.XFormsPending) if (!XFormControl.XFormsPending)
@@ -578,56 +577,26 @@ xform_PLUT_step (SIZE TDelta)
if (TDelta > control->TTotal) if (TDelta > control->TTotal)
TDelta = control->TTotal; TDelta = control->TTotal;
pCurCMap = (DWORD *)((BYTE *)_varPLUTs + (*ColorMapPtr * PLUT_BYTE_SIZE)); if (_varPLUTs && control->TOrig != 0)
{
#define XFORM_SCALE 0x10000
UBYTE *pCurCMap, *pOldCMap, *pNewCMap;
int frac;
pCurCMap = GET_VAR_PLUT (*ColorMapPtr);
pOldCMap = control->OldCMap; pOldCMap = control->OldCMap;
pNewCMap = (UBYTE*)ColorMapPtr + 2;
ColorMapPtr += 2; frac = (int)(control->TOrig - control->TTotal) * XFORM_SCALE
if (_varPLUTs) / control->TOrig;
for (i = 0; i < PLUT_BYTE_SIZE; i++)
{ {
for (i = 0; i < NUMBER_OF_PLUT_UINT32s; i++) *pCurCMap = (UBYTE)(*pOldCMap + ((int)*pNewCMap - *pOldCMap)
{ * frac / XFORM_SCALE);
SIZE c0, c1;
DWORD v0, v1, val;
float f = (control->TOrig - control->TTotal) / (float)control->TOrig;
COLORMAPPTR oldmap = (COLORMAPPTR) pOldCMap;
v0 = UQM_SwapBE32 (*(DWORD *)oldmap);
v1 = UQM_SwapBE32 (*(DWORD *)ColorMapPtr);
ColorMapPtr += sizeof (DWORD);
c0 = (SIZE)((v0 >> (10 + 16)) & 0x1F);
c1 = (SIZE)((v1 >> (10 + 16)) & 0x1F);
c0 += (SIZE)((c1 - c0) * f);
val = (c0 & 0x1F) | (1 << 5);
c0 = (SIZE)((v0 >> (5 + 16)) & 0x1F);
c1 = (SIZE)((v1 >> (5 + 16)) & 0x1F);
c0 += (SIZE)((c1 - c0) * f);
val = (val << 5) | (c0 & 0x1F);
c0 = (SIZE)((v0 >> (0 + 16)) & 0x1F);
c1 = (SIZE)((v1 >> (0 + 16)) & 0x1F);
c0 += (SIZE)((c1 - c0) * f);
val = (val << 5) | (c0 & 0x1F);
c0 = (SIZE)((v0 >> 10) & 0x1F);
c1 = (SIZE)((v1 >> 10) & 0x1F);
c0 += (SIZE)((c1 - c0) * f);
val = (val << (5 + 1)) | (c0 & 0x1F) | (1 << 5);
c0 = (SIZE)((v0 >> 5) & 0x1F);
c1 = (SIZE)((v1 >> 5) & 0x1F);
c0 += (SIZE)((c1 - c0) * f);
val = (val << 5) | (c0 & 0x1F);
c0 = (SIZE)((v0 >> 0) & 0x1F);
c1 = (SIZE)((v1 >> 0) & 0x1F);
c0 += (SIZE)((c1 - c0) * f);
val = (val << 5) | (c0 & 0x1F);
pOldCMap++; pOldCMap++;
*pCurCMap++ = UQM_SwapBE32 (val); pCurCMap++;
pNewCMap++;
} }
ColorChange = TRUE; ColorChange = TRUE;
} }
@@ -657,9 +626,7 @@ XFormPLUT (COLORMAPPTR ColorMapPtr, SIZE TimeInterval)
{ {
if (ColorMapPtr) if (ColorMapPtr)
{ {
DWORD *pOldCMap, *pCurCMap;
XFORM_CONTROL *control; XFORM_CONTROL *control;
int i;
// FlushPLUTXForms (); // FlushPLUTXForms ();
@@ -674,10 +641,7 @@ XFormPLUT (COLORMAPPTR ColorMapPtr, SIZE TimeInterval)
control = &XFormControl.TaskControl[XFormControl.XFormInsertPoint]; control = &XFormControl.TaskControl[XFormControl.XFormInsertPoint];
pCurCMap = (DWORD *)((BYTE *)_varPLUTs + (*ColorMapPtr * PLUT_BYTE_SIZE)); memcpy (control->OldCMap, GET_VAR_PLUT (*ColorMapPtr), PLUT_BYTE_SIZE);
pOldCMap = control->OldCMap;
for (i = 0; i < NUMBER_OF_PLUT_UINT32s; ++i)
*pOldCMap++ = *pCurCMap++;
control->CMapPtr = ColorMapPtr; control->CMapPtr = ColorMapPtr;
if ((control->Ticks = TimeInterval) <= 0) if ((control->Ticks = TimeInterval) <= 0)
+25 -30
View File
@@ -35,45 +35,30 @@ static struct
volatile int FadeAmount = FADE_NORMAL_INTENSITY; volatile int FadeAmount = FADE_NORMAL_INTENSITY;
static volatile int end, XForming; static volatile int end, XForming;
DWORD* _varPLUTs; UBYTE* _varPLUTs;
static unsigned int varPLUTsize = VARPLUTS_SIZE; static unsigned int varPLUTsize = 0;
void TFB_ColorMapToRGB (TFB_Palette *pal, int colormap_index) void TFB_ColorMapToRGB (TFB_Palette *pal, int colormap_index)
{ {
DWORD i, k; int i;
UWORD cval;
UBYTE j, r, g, b, rtot, gtot, btot;
UBYTE *colors; UBYTE *colors;
colors = (UBYTE*)_varPLUTs + (colormap_index * PLUT_BYTE_SIZE); colors = GET_VAR_PLUT (colormap_index);
for (i = 0; i < 32; i++) for (i = 0; i < NUMBER_OF_PLUTVALS; i++)
{ {
cval = MAKE_WORD (colors[1], colors[0]); pal[i].r = *colors++;
colors += 2; pal[i].g = *colors++;
pal[i].b = *colors++;
rtot = r = (UBYTE)((cval >> 10) & 0x1f); // bits 10-14
gtot = g = (UBYTE)((cval >> 5) & 0x1f); // bits 5-9
btot = b = (UBYTE)(cval & 0x1f); // bits 0-4
for (j = 0; j < 8; ++j)
{
k = ((j << 5) + i);
pal[k].r = rtot;
rtot += r;
pal[k].g = gtot;
gtot += g;
pal[k].b = btot;
btot += b;
}
} }
} }
BOOLEAN BOOLEAN
SetColorMap (COLORMAPPTR map) SetColorMap (COLORMAPPTR map)
{ {
int start, end, bytes; int start, end;
DWORD size, total_size;
UBYTE *colors = (UBYTE*)map; UBYTE *colors = (UBYTE*)map;
UBYTE *vp; UBYTE *vp;
@@ -85,17 +70,27 @@ SetColorMap (COLORMAPPTR map)
if (start > end) if (start > end)
return TRUE; return TRUE;
bytes = (end - start + 1) * PLUT_BYTE_SIZE; size = (end - start + 1) * PLUT_BYTE_SIZE;
total_size = (end + 1) * PLUT_BYTE_SIZE;
if (!_varPLUTs) if (!_varPLUTs)
{ {
if (!(_varPLUTs = (DWORD *) HMalloc (bytes))) _varPLUTs = (UBYTE *) HMalloc (total_size);
varPLUTsize = total_size;
}
else if (total_size > varPLUTsize)
{
_varPLUTs = (UBYTE *) HRealloc (_varPLUTs, total_size);
varPLUTsize = total_size;
}
if (!_varPLUTs)
{
varPLUTsize = 0;
return TRUE; return TRUE;
varPLUTsize = bytes;
} }
vp = (UBYTE*)_varPLUTs + (start * PLUT_BYTE_SIZE); vp = GET_VAR_PLUT (start);
memcpy (vp, colors, bytes); memcpy (vp, colors, size);
//fprintf (stderr, "SetColorMap(): vp %x map %x bytes %d, start %d end %d\n", vp, map, bytes, start, end); //fprintf (stderr, "SetColorMap(): vp %x map %x bytes %d, start %d end %d\n", vp, map, bytes, start, end);
return TRUE; return TRUE;
+6 -9
View File
@@ -22,14 +22,11 @@
#define CMAP_H #define CMAP_H
#define NUMBER_OF_VARPLUTS 256 #define NUMBER_OF_VARPLUTS 256
#define NUMBER_OF_PLUTVALS 32 #define PLUTVAL_BYTE_SIZE 3
#define NUMBER_OF_PLUT_UINT32s (NUMBER_OF_PLUTVALS >> 1) #define NUMBER_OF_PLUTVALS 256
#define PLUT_BYTE_SIZE (sizeof (unsigned int) * \ #define PLUT_BYTE_SIZE (PLUTVAL_BYTE_SIZE * NUMBER_OF_PLUTVALS)
NUMBER_OF_PLUT_UINT32s) #define VARPLUTS_SIZE (NUMBER_OF_VARPLUTS * PLUT_BYTE_SIZE)
#define NUMBER_OF_CLUTVALS 32 #define GET_VAR_PLUT(i) (_varPLUTs + (i) * PLUT_BYTE_SIZE)
#define VARPLUTS_SIZE (NUMBER_OF_VARPLUTS * \
NUMBER_OF_PLUT_UINT32s * sizeof (unsigned int))
#define GET_VAR_PLUT(i) (_varPLUTs + (i) * NUMBER_OF_PLUT_UINT32s)
#define BUILD_FRAME (1 << 0) #define BUILD_FRAME (1 << 0)
#define FIND_PAGE (1 << 1) #define FIND_PAGE (1 << 1)
@@ -43,7 +40,7 @@
#define FADE_NORMAL_INTENSITY 255 #define FADE_NORMAL_INTENSITY 255
#define FADE_FULL_INTENSITY 510 #define FADE_FULL_INTENSITY 510
extern DWORD* _varPLUTs; extern UBYTE* _varPLUTs;
extern volatile int FadeAmount; extern volatile int FadeAmount;
void TFB_ColorMapToRGB (TFB_Palette *pal, int colormap_index); void TFB_ColorMapToRGB (TFB_Palette *pal, int colormap_index);