Converted all pcx images to png, moved hotspot etc info to ani files, added colormap index for better palette support
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@114 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -493,7 +493,7 @@ XFormPLUT (COLORMAPPTR ColorMapPtr, SIZE TimeInterval)
|
||||
AssignTask (xform_PLUT_task, 1024,
|
||||
"transform palette")) == 0)
|
||||
{
|
||||
SetColorMap (ColorMapPtr, TFB_COLORMAP_COMM);
|
||||
SetColorMap (ColorMapPtr);
|
||||
ColorChange = TRUE;
|
||||
TimeOut = GetTimeCounter ();
|
||||
}
|
||||
@@ -1155,7 +1155,7 @@ AlienTalkSegue (COUNT wait_track)
|
||||
|
||||
if (!pCurInputState->Initialized)
|
||||
{
|
||||
SetColorMap (GetColorMapAddress (CommData.AlienColorMap), TFB_COLORMAP_COMM);
|
||||
SetColorMap (GetColorMapAddress (CommData.AlienColorMap));
|
||||
DrawAlienFrame (CommData.AlienFrame, NULL_PTR);
|
||||
UpdateSpeechGraphics (TRUE);
|
||||
|
||||
@@ -1542,7 +1542,6 @@ BatchGraphics ();
|
||||
|
||||
DestroyStringTable (ReleaseStringTable (CommData.ConversationPhrases));
|
||||
DestroyMusic ((MUSIC_REF)CommData.AlienSong);
|
||||
TFB_ReleaseColorMap ();
|
||||
DestroyColorMap (ReleaseColorMap (CommData.AlienColorMap));
|
||||
DestroyFont (ReleaseFont (CommData.AlienFont));
|
||||
DestroyDrawable (ReleaseDrawable (CommData.AlienFrame));
|
||||
|
||||
@@ -560,7 +560,6 @@ GiveRadios (RESPONSE_REF R)
|
||||
XFormPLUT (GetColorMapAddress (
|
||||
SetAbsColorMapIndex (CommData.AlienColorMap, 0)
|
||||
), 0);
|
||||
TFB_ReleaseColorMap ();
|
||||
ClearSemaphore (GraphicsSem);
|
||||
AlienTalkSegue ((COUNT)~0);
|
||||
|
||||
|
||||
@@ -1721,8 +1721,6 @@ SellMinerals (RESPONSE_REF R)
|
||||
BOOLEAN Sleepy;
|
||||
RESPONSE_REF pStr1, pStr2;
|
||||
|
||||
TFB_ReleaseColorMap();
|
||||
|
||||
total = 0;
|
||||
Sleepy = TRUE;
|
||||
for (i = 0; i < NUM_ELEMENT_CATEGORIES; ++i)
|
||||
|
||||
@@ -336,12 +336,12 @@ LoadHyperspace (void)
|
||||
if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1)
|
||||
{
|
||||
SetContextBackGroundColor (BUILD_COLOR (MAKE_RGB15 (0x7, 0x00, 0x00), 0x2F));
|
||||
SetColorMap (GetColorMapAddress (hypercmaps[0]), TFB_COLORMAP_HYPERSPACE);
|
||||
SetColorMap (GetColorMapAddress (hypercmaps[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetContextBackGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x1A, 0x00), 0x2F));
|
||||
SetColorMap (GetColorMapAddress (hypercmaps[1]), TFB_COLORMAP_QUASISPACE);
|
||||
SetColorMap (GetColorMapAddress (hypercmaps[1]));
|
||||
SET_GAME_STATE (USED_BROADCASTER, 0);
|
||||
SET_GAME_STATE (BROADCASTER_RESPONSE, 0);
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ extern BOOLEAN DestroyOverlayWindow (FRAME Display, DRAWABLE Drawable);
|
||||
extern void ScrollDisplay (FRAME Display, COORD x, COORD y);
|
||||
|
||||
extern BOOLEAN ReadColorMap (COLORMAPPTR ColorMapPtr);
|
||||
extern BOOLEAN SetColorMap (COLORMAPPTR ColorMapPtr, int type);
|
||||
extern BOOLEAN SetColorMap (COLORMAPPTR ColorMapPtr);
|
||||
extern BOOLEAN BatchColorMap (COLORMAPPTR ColorMapPtr);
|
||||
extern CYCLE_REF CycleColorMap (COLORMAPPTR ColorMapPtr, COUNT Cycles,
|
||||
SIZE TimeInterval);
|
||||
|
||||
@@ -37,31 +37,14 @@ static volatile int end, XForming;
|
||||
DWORD* _varPLUTs;
|
||||
static unsigned int varPLUTsize = VARPLUTS_SIZE;
|
||||
|
||||
static BOOLEAN has_colormap = FALSE;
|
||||
static TFB_Palette cmap_rgb[256];
|
||||
static int cmap_type = 0;
|
||||
|
||||
|
||||
BOOLEAN TFB_HasColorMap (void)
|
||||
{
|
||||
return has_colormap;
|
||||
}
|
||||
|
||||
int TFB_GetColorMapType (void)
|
||||
{
|
||||
return cmap_type;
|
||||
}
|
||||
|
||||
void TFB_ReleaseColorMap (void)
|
||||
{
|
||||
//fprintf (stderr, "TFB_ReleaseColorMap()\n");
|
||||
has_colormap = FALSE;
|
||||
}
|
||||
|
||||
void TFB_ColorMapToRGB (UBYTE *colors)
|
||||
void TFB_ColorMapToRGB (TFB_Palette *pal, int colormap_index)
|
||||
{
|
||||
DWORD i, k, cval;
|
||||
UBYTE j, r, g, b;
|
||||
UBYTE *colors;
|
||||
|
||||
colors = (UBYTE*)_varPLUTs + (colormap_index * PLUT_BYTE_SIZE);
|
||||
|
||||
for (i = 0; i < 32;)
|
||||
{
|
||||
@@ -76,9 +59,9 @@ void TFB_ColorMapToRGB (UBYTE *colors)
|
||||
{
|
||||
k = ((j << 5) + i);
|
||||
|
||||
cmap_rgb[k].r = r * (j + 1);
|
||||
cmap_rgb[k].g = g * (j + 1);
|
||||
cmap_rgb[k].b = b * (j + 1);
|
||||
pal[k].r = r * (j + 1);
|
||||
pal[k].g = g * (j + 1);
|
||||
pal[k].b = b * (j + 1);
|
||||
}
|
||||
|
||||
++i;
|
||||
@@ -90,51 +73,23 @@ void TFB_ColorMapToRGB (UBYTE *colors)
|
||||
for (j = 0; j < 8; ++j)
|
||||
{
|
||||
k = ((j << 5) + i);
|
||||
cmap_rgb[k].r = r * (j + 1);
|
||||
cmap_rgb[k].g = g * (j + 1);
|
||||
cmap_rgb[k].b = b * (j + 1);
|
||||
pal[k].r = r * (j + 1);
|
||||
pal[k].g = g * (j + 1);
|
||||
pal[k].b = b * (j + 1);
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN TFB_CopyRGBColorMap (TFB_Palette *dst)
|
||||
{
|
||||
if (cmap_type == TFB_COLORMAP_HYPERSPACE ||
|
||||
cmap_type == TFB_COLORMAP_QUASISPACE)
|
||||
{
|
||||
// TODO: some special colormaps still not implemented
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
else if (cmap_type == TFB_COLORMAP_PLANET)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 32; ++i)
|
||||
{
|
||||
dst[251-i].r = cmap_rgb[255-i].r;
|
||||
dst[251-i].g = cmap_rgb[255-i].g;
|
||||
dst[251-i].b = cmap_rgb[255-i].b;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(dst, cmap_rgb, sizeof(TFB_Palette) * 256);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
BatchColorMap (COLORMAPPTR ColorMapPtr)
|
||||
{
|
||||
return (SetColorMap (ColorMapPtr, TFB_COLORMAP_NONE));
|
||||
return (SetColorMap (ColorMapPtr));
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
SetColorMap (COLORMAPPTR map, int type)
|
||||
SetColorMap (COLORMAPPTR map)
|
||||
{
|
||||
int start, end, bytes;
|
||||
UBYTE *colors = (UBYTE*)map;
|
||||
@@ -157,14 +112,10 @@ SetColorMap (COLORMAPPTR map, int type)
|
||||
varPLUTsize = bytes;
|
||||
}
|
||||
|
||||
vp = (UBYTE*)_varPLUTs + (start * PLUT_BYTE_SIZE);
|
||||
|
||||
vp = (UBYTE*)_varPLUTs + (start * PLUT_BYTE_SIZE);
|
||||
memcpy (vp, colors, bytes);
|
||||
cmap_type = type;
|
||||
TFB_ColorMapToRGB (vp);
|
||||
has_colormap = TRUE;
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,21 +41,9 @@
|
||||
#define FADE_NORMAL_INTENSITY 255
|
||||
#define FADE_FULL_INTENSITY 510
|
||||
|
||||
enum
|
||||
{
|
||||
TFB_COLORMAP_NONE,
|
||||
TFB_COLORMAP_HYPERSPACE,
|
||||
TFB_COLORMAP_QUASISPACE,
|
||||
TFB_COLORMAP_PLANET,
|
||||
TFB_COLORMAP_COMM
|
||||
};
|
||||
|
||||
extern DWORD* _varPLUTs;
|
||||
extern volatile int FadeAmount;
|
||||
|
||||
BOOLEAN TFB_HasColorMap (void);
|
||||
int TFB_GetColorMapType (void);
|
||||
void TFB_ReleaseColorMap (void);
|
||||
BOOLEAN TFB_CopyRGBColorMap (TFB_Palette *dst);
|
||||
void TFB_ColorMapToRGB (TFB_Palette *pal, int colormap_index);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -143,22 +143,10 @@ blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TFB_HasColorMap() && img->NormalImg->format->BytesPerPixel == 1)
|
||||
if (img->NormalImg->format->palette && img->colormap_index != -1)
|
||||
{
|
||||
// TODO: this currently uses a hack to avoid corrupting sun colors..
|
||||
// why sun won't work properly with colormaps, should be traced later
|
||||
|
||||
int type = TFB_GetColorMapType();
|
||||
|
||||
if (type != TFB_COLORMAP_PLANET ||
|
||||
(type == TFB_COLORMAP_PLANET && (img->Palette[255].r != 248 ||
|
||||
img->Palette[255].g != 248 || img->Palette[255].b != 248)))
|
||||
{
|
||||
if (TFB_CopyRGBColorMap(DrawCommand.Palette))
|
||||
{
|
||||
DrawCommand.UsePalette = TRUE;
|
||||
}
|
||||
}
|
||||
TFB_ColorMapToRGB (DrawCommand.Palette, img->colormap_index);
|
||||
DrawCommand.UsePalette = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,15 +26,84 @@
|
||||
#include "sdl_common.h"
|
||||
#include "primitives.h"
|
||||
|
||||
// following stuff was in libs/graphics/getbody.c before modularization
|
||||
typedef struct anidata
|
||||
{
|
||||
int transparent_color;
|
||||
int colormap_index;
|
||||
int clip_x;
|
||||
int clip_y;
|
||||
int clip_w;
|
||||
int clip_h;
|
||||
int hotspot_x;
|
||||
int hotspot_y;
|
||||
} AniData;
|
||||
|
||||
|
||||
extern char *_cur_resfile_name;
|
||||
|
||||
static void
|
||||
process_image (FRAMEPTR FramePtr, SDL_Surface *img[], int cel_ct, BOOLEAN is_font)
|
||||
process_image (FRAMEPTR FramePtr, SDL_Surface *img[], AniData *ani, int cel_ct)
|
||||
{
|
||||
int hx, hy, h;
|
||||
TFB_Image *tfbimg;
|
||||
int hx = 0, hy = 0;
|
||||
|
||||
TYPE_SET (FramePtr->TypeIndexAndFlags, WANT_PIXMAP << FTYPE_SHIFT);
|
||||
INDEX_SET (FramePtr->TypeIndexAndFlags, cel_ct);
|
||||
|
||||
if (img[cel_ct]->format->palette)
|
||||
{
|
||||
if (ani[cel_ct].transparent_color != -1)
|
||||
SDL_SetColorKey(img[cel_ct], SDL_SRCCOLORKEY, ani[cel_ct].transparent_color);
|
||||
|
||||
if (ani[cel_ct].clip_x != -1)
|
||||
img[cel_ct]->clip_rect.x = ani[cel_ct].clip_x;
|
||||
if (ani[cel_ct].clip_y != -1)
|
||||
img[cel_ct]->clip_rect.y = ani[cel_ct].clip_y;
|
||||
if (ani[cel_ct].clip_w != -1)
|
||||
img[cel_ct]->clip_rect.w = ani[cel_ct].clip_w;
|
||||
if (ani[cel_ct].clip_h != -1)
|
||||
img[cel_ct]->clip_rect.h = ani[cel_ct].clip_h;
|
||||
|
||||
if (ani[cel_ct].hotspot_x != -1)
|
||||
hx = ani[cel_ct].hotspot_x;
|
||||
if (ani[cel_ct].hotspot_y != -1)
|
||||
hy = ani[cel_ct].hotspot_y;
|
||||
}
|
||||
|
||||
hx -= img[cel_ct]->clip_rect.x;
|
||||
hy -= img[cel_ct]->clip_rect.y;
|
||||
|
||||
FramePtr->DataOffs = (BYTE *)TFB_LoadImage (img[cel_ct]) - (BYTE *)FramePtr;
|
||||
|
||||
tfbimg = (TFB_Image *)((BYTE *)FramePtr + FramePtr->DataOffs);
|
||||
tfbimg->colormap_index = ani[cel_ct].colormap_index;
|
||||
img[cel_ct] = tfbimg->NormalImg;
|
||||
|
||||
hx += img[cel_ct]->clip_rect.x;
|
||||
hy += img[cel_ct]->clip_rect.y;
|
||||
|
||||
SetFrameHotSpot (FramePtr, MAKE_HOT_SPOT (hx, hy));
|
||||
SetFrameBounds (FramePtr, img[cel_ct]->clip_rect.w, img[cel_ct]->clip_rect.h);
|
||||
|
||||
#if 0
|
||||
fprintf (stderr, "\thot[%d, %d], rect[%d, %d, %d, %d]\n",
|
||||
hx, hy,
|
||||
img[cel_ct]->clip_rect.x, img[cel_ct]->clip_rect.y,
|
||||
img[cel_ct]->clip_rect.w, img[cel_ct]->clip_rect.h);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
process_font (FRAMEPTR FramePtr, SDL_Surface *img[], int cel_ct)
|
||||
{
|
||||
int hx, hy;
|
||||
int x,y;
|
||||
Uint8 r,g,b,a;
|
||||
Uint32 p;
|
||||
SDL_Color colors[256];
|
||||
SDL_Surface *new_surf;
|
||||
GetPixelFn getpix;
|
||||
PutPixelFn putpix;
|
||||
|
||||
TYPE_SET (FramePtr->TypeIndexAndFlags, WANT_PIXMAP << FTYPE_SHIFT);
|
||||
INDEX_SET (FramePtr->TypeIndexAndFlags, cel_ct);
|
||||
@@ -43,157 +112,43 @@ process_image (FRAMEPTR FramePtr, SDL_Surface *img[], int cel_ct, BOOLEAN is_fon
|
||||
|
||||
SDL_LockSurface (img[cel_ct]);
|
||||
|
||||
if (is_font)
|
||||
// convert 32-bit png font to indexed
|
||||
|
||||
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, img[cel_ct]->w, img[cel_ct]->h,
|
||||
8, 0, 0, 0, 0);
|
||||
|
||||
getpix = getpixel_for (img[cel_ct]);
|
||||
putpix = putpixel_for (new_surf);
|
||||
|
||||
for (y = 0; y < img[cel_ct]->h; ++y)
|
||||
{
|
||||
// convert 32-bit png font to indexed
|
||||
|
||||
int x,y;
|
||||
Uint8 r,g,b,a;
|
||||
Uint32 p;
|
||||
SDL_Color colors[256];
|
||||
|
||||
SDL_Surface *new_surf;
|
||||
GetPixelFn getpix;
|
||||
PutPixelFn putpix;
|
||||
|
||||
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, img[cel_ct]->w, img[cel_ct]->h,
|
||||
8, 0, 0, 0, 0);
|
||||
|
||||
getpix = getpixel_for (img[cel_ct]);
|
||||
putpix = putpixel_for (new_surf);
|
||||
|
||||
for (y = 0; y < img[cel_ct]->h; ++y)
|
||||
for (x = 0; x < img[cel_ct]->w; ++x)
|
||||
{
|
||||
for (x = 0; x < img[cel_ct]->w; ++x)
|
||||
{
|
||||
p = getpix (img[cel_ct], x, y);
|
||||
SDL_GetRGBA (p, img[cel_ct]->format, &r, &g, &b, &a);
|
||||
p = getpix (img[cel_ct], x, y);
|
||||
SDL_GetRGBA (p, img[cel_ct]->format, &r, &g, &b, &a);
|
||||
|
||||
if (a)
|
||||
putpix (new_surf, x, y, 1);
|
||||
else
|
||||
putpix (new_surf, x, y, 0);
|
||||
}
|
||||
}
|
||||
|
||||
colors[0].r = colors[0].g = colors[0].b = 0;
|
||||
for (x = 1; x < 256; ++x)
|
||||
{
|
||||
colors[x].r = 255;
|
||||
colors[x].g = 255;
|
||||
colors[x].b = 255;
|
||||
}
|
||||
|
||||
SDL_SetColors (new_surf, colors, 0, 256);
|
||||
SDL_SetColorKey (new_surf, SDL_SRCCOLORKEY, 0);
|
||||
|
||||
SDL_UnlockSurface (img[cel_ct]);
|
||||
SDL_FreeSurface (img[cel_ct]);
|
||||
|
||||
img[cel_ct] = new_surf;
|
||||
|
||||
SDL_LockSurface (img[cel_ct]);
|
||||
}
|
||||
else if (img[cel_ct]->w >= 3 && (h = img[cel_ct]->h))
|
||||
{
|
||||
if (img[cel_ct]->format->palette)
|
||||
{
|
||||
int w;
|
||||
BYTE *pixel, *p, Cknockout, Chotx, Choty;
|
||||
|
||||
img[cel_ct]->clip_rect.x = img[cel_ct]->w;
|
||||
img[cel_ct]->clip_rect.y = img[cel_ct]->h;
|
||||
img[cel_ct]->clip_rect.w = img[cel_ct]->clip_rect.h = 0;
|
||||
p = pixel = img[cel_ct]->pixels;
|
||||
Cknockout = *p++;
|
||||
Chotx = *p;
|
||||
*p++ = Cknockout;
|
||||
Choty = *p;
|
||||
*p++ = Cknockout;
|
||||
SDL_SetColorKey(img[cel_ct], SDL_SRCCOLORKEY, Cknockout);
|
||||
do
|
||||
{
|
||||
w = img[cel_ct]->w - (p - pixel);
|
||||
if (w)
|
||||
{
|
||||
int x, y;
|
||||
BYTE opval;
|
||||
|
||||
opval = Cknockout;
|
||||
do
|
||||
{
|
||||
BYTE pval;
|
||||
|
||||
pval = *p;
|
||||
if (pval == Chotx)
|
||||
{
|
||||
*p = Cknockout;
|
||||
hx = img[cel_ct]->w - w;
|
||||
}
|
||||
if (pval == Choty)
|
||||
{
|
||||
*p = Cknockout;
|
||||
hy = img[cel_ct]->h - h;
|
||||
}
|
||||
|
||||
pval = *p;
|
||||
if (pval == Cknockout)
|
||||
{
|
||||
if (opval != Cknockout)
|
||||
{
|
||||
x = img[cel_ct]->w - w;
|
||||
if (x > img[cel_ct]->clip_rect.x + img[cel_ct]->clip_rect.w)
|
||||
img[cel_ct]->clip_rect.w = x - img[cel_ct]->clip_rect.x;
|
||||
y = img[cel_ct]->h - h;
|
||||
if (y >= img[cel_ct]->clip_rect.y + img[cel_ct]->clip_rect.h)
|
||||
img[cel_ct]->clip_rect.h = y - img[cel_ct]->clip_rect.y + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (opval == Cknockout)
|
||||
{
|
||||
x = img[cel_ct]->w - w;
|
||||
if (x < img[cel_ct]->clip_rect.x)
|
||||
{
|
||||
if (img[cel_ct]->clip_rect.w == 0)
|
||||
img[cel_ct]->clip_rect.w = 1;
|
||||
else
|
||||
img[cel_ct]->clip_rect.w += img[cel_ct]->clip_rect.x - x;
|
||||
img[cel_ct]->clip_rect.x = x;
|
||||
}
|
||||
y = img[cel_ct]->h - h;
|
||||
if (y < img[cel_ct]->clip_rect.y)
|
||||
{
|
||||
if (img[cel_ct]->clip_rect.h == 0)
|
||||
img[cel_ct]->clip_rect.h = 1;
|
||||
else
|
||||
img[cel_ct]->clip_rect.h += img[cel_ct]->clip_rect.y - y;
|
||||
img[cel_ct]->clip_rect.y = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
opval = pval;
|
||||
} while (++p, --w);
|
||||
if (opval != Cknockout)
|
||||
{
|
||||
x = img[cel_ct]->w - w;
|
||||
if (x > img[cel_ct]->clip_rect.x + img[cel_ct]->clip_rect.w)
|
||||
img[cel_ct]->clip_rect.w = x - img[cel_ct]->clip_rect.x;
|
||||
y = img[cel_ct]->h - h;
|
||||
if (y >= img[cel_ct]->clip_rect.y + img[cel_ct]->clip_rect.h)
|
||||
img[cel_ct]->clip_rect.h = y - img[cel_ct]->clip_rect.y + 1;
|
||||
}
|
||||
}
|
||||
p = (pixel += img[cel_ct]->pitch);
|
||||
} while (--h);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (a)
|
||||
putpix (new_surf, x, y, 1);
|
||||
else
|
||||
putpix (new_surf, x, y, 0);
|
||||
}
|
||||
}
|
||||
|
||||
colors[0].r = colors[0].g = colors[0].b = 0;
|
||||
for (x = 1; x < 256; ++x)
|
||||
{
|
||||
colors[x].r = 255;
|
||||
colors[x].g = 255;
|
||||
colors[x].b = 255;
|
||||
}
|
||||
|
||||
SDL_SetColors (new_surf, colors, 0, 256);
|
||||
SDL_SetColorKey (new_surf, SDL_SRCCOLORKEY, 0);
|
||||
|
||||
SDL_UnlockSurface (img[cel_ct]);
|
||||
SDL_FreeSurface (img[cel_ct]);
|
||||
|
||||
img[cel_ct] = new_surf;
|
||||
|
||||
hx -= img[cel_ct]->clip_rect.x;
|
||||
hy -= img[cel_ct]->clip_rect.y;
|
||||
@@ -206,14 +161,6 @@ process_image (FRAMEPTR FramePtr, SDL_Surface *img[], int cel_ct, BOOLEAN is_fon
|
||||
|
||||
SetFrameHotSpot (FramePtr, MAKE_HOT_SPOT (hx, hy));
|
||||
SetFrameBounds (FramePtr, img[cel_ct]->clip_rect.w, img[cel_ct]->clip_rect.h);
|
||||
|
||||
#if 0
|
||||
fprintf (stderr, "\thot[%d, %d], rect[%d, %d, %d, %d]\n",
|
||||
hx, hy,
|
||||
img[cel_ct]->clip_rect.x, img[cel_ct]->clip_rect.y,
|
||||
img[cel_ct]->clip_rect.w, img[cel_ct]->clip_rect.h);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
MEM_HANDLE
|
||||
@@ -227,6 +174,7 @@ _GetCelData (FILE *fp, DWORD length)
|
||||
char CurrentLine[1024], filename[1024];
|
||||
#define MAX_CELS 256
|
||||
SDL_Surface *img[MAX_CELS];
|
||||
AniData ani[MAX_CELS];
|
||||
DRAWABLE Drawable;
|
||||
|
||||
opos = ftell (fp);
|
||||
@@ -256,21 +204,22 @@ _GetCelData (FILE *fp, DWORD length)
|
||||
/*char fnamestr[1000];
|
||||
sscanf(CurrentLine, "%s", fnamestr);
|
||||
fprintf (stderr, "imgload %s\n",fnamestr);*/
|
||||
|
||||
if
|
||||
(
|
||||
sscanf(CurrentLine, "%s", &filename[n]) == 1
|
||||
&& (img[cel_ct] = IMG_Load (filename))
|
||||
&& img[cel_ct]->w > 0
|
||||
&& img[cel_ct]->h > 0
|
||||
&& img[cel_ct]->format->BitsPerPixel >= 8
|
||||
)
|
||||
|
||||
sscanf (CurrentLine, "%s %d %d %d %d %d %d %d %d", &filename[n],
|
||||
&ani[cel_ct].transparent_color, &ani[cel_ct].colormap_index,
|
||||
&ani[cel_ct].clip_x, &ani[cel_ct].clip_y, &ani[cel_ct].clip_w,
|
||||
&ani[cel_ct].clip_h, &ani[cel_ct].hotspot_x, &ani[cel_ct].hotspot_y);
|
||||
|
||||
if ((img[cel_ct] = IMG_Load (filename)) && img[cel_ct]->w > 0 &&
|
||||
img[cel_ct]->h > 0 && img[cel_ct]->format->BitsPerPixel >= 8)
|
||||
{
|
||||
++cel_ct;
|
||||
else if (img[cel_ct])
|
||||
fprintf (stderr, "_GetCelData: Bad file!\n"),
|
||||
SDL_FreeSurface (img[cel_ct]);
|
||||
|
||||
|
||||
}
|
||||
else if (img[cel_ct])
|
||||
{
|
||||
fprintf (stderr, "_GetCelData: Bad file!\n");
|
||||
SDL_FreeSurface (img[cel_ct]);
|
||||
}
|
||||
|
||||
if ((int)ftell (fp) - (int)opos >= (int)length)
|
||||
break;
|
||||
@@ -303,7 +252,7 @@ _GetCelData (FILE *fp, DWORD length)
|
||||
|
||||
FramePtr = &DrawablePtr->Frame[cel_ct];
|
||||
while (--FramePtr, cel_ct--)
|
||||
process_image (FramePtr, img, cel_ct, FALSE);
|
||||
process_image (FramePtr, img, ani, cel_ct);
|
||||
|
||||
UnlockDrawable (Drawable);
|
||||
}
|
||||
@@ -422,7 +371,7 @@ _GetFontData (FILE *fp, DWORD length)
|
||||
{
|
||||
if (img[cel_ct])
|
||||
{
|
||||
process_image (FramePtr, img, cel_ct, TRUE);
|
||||
process_font (FramePtr, img, cel_ct);
|
||||
SetFrameBounds (FramePtr, GetFrameWidth (FramePtr) + 1, GetFrameHeight (FramePtr) + 1);
|
||||
|
||||
if (img[0])
|
||||
|
||||
@@ -148,6 +148,7 @@ TFB_LoadImage (SDL_Surface *img)
|
||||
myImage->mutex = CreateMutex();
|
||||
myImage->ScaledImg = NULL;
|
||||
myImage->Palette = NULL;
|
||||
myImage->colormap_index = -1;
|
||||
|
||||
if (img->format->BytesPerPixel == 1)
|
||||
{
|
||||
|
||||
@@ -48,10 +48,11 @@ typedef struct tfb_image
|
||||
SDL_Surface *NormalImg;
|
||||
SDL_Surface *ScaledImg;
|
||||
SDL_Color *Palette;
|
||||
int colormap_index;
|
||||
int scale;
|
||||
Mutex mutex;
|
||||
UBYTE pad[sizeof(TFB_ImageStruct)-sizeof(SDL_Surface*)-sizeof(SDL_Surface*)-
|
||||
sizeof(SDL_Color*)-sizeof(int)-sizeof(Mutex)];
|
||||
sizeof(SDL_Color*)-sizeof(int)-sizeof(int)-sizeof(Mutex)];
|
||||
} TFB_Image;
|
||||
|
||||
TFB_Image *TFB_LoadImage (SDL_Surface *img);
|
||||
|
||||
@@ -211,7 +211,6 @@ FreePlanet (void)
|
||||
pSolarSysState->hTopoData = 0;
|
||||
DestroyDrawable (ReleaseDrawable (pSolarSysState->TopoFrame));
|
||||
pSolarSysState->TopoFrame = 0;
|
||||
TFB_ReleaseColorMap ();
|
||||
DestroyColorMap (ReleaseColorMap (pSolarSysState->OrbitalCMap));
|
||||
pSolarSysState->OrbitalCMap = 0;
|
||||
|
||||
|
||||
@@ -115,7 +115,6 @@ FreeIPData (void)
|
||||
SISIPFrame = 0;
|
||||
DestroyDrawable (ReleaseDrawable (SunFrame));
|
||||
SunFrame = 0;
|
||||
TFB_ReleaseColorMap ();
|
||||
DestroyColorMap (ReleaseColorMap (OrbitalCMap));
|
||||
OrbitalCMap = 0;
|
||||
DestroyDrawable (ReleaseDrawable (OrbitalFrame));
|
||||
@@ -576,7 +575,7 @@ if (!(draw_sys_flags & DRAW_PLANETS))
|
||||
SetColorMap (GetColorMapAddress (
|
||||
SetAbsColorMapIndex (OrbitalCMap,
|
||||
PLANCOLOR (Type))
|
||||
), TFB_COLORMAP_PLANET);
|
||||
));
|
||||
|
||||
Size = PLANSIZE (Type);
|
||||
if (denom == 2 || xnumer > (COUNT)DISPLAY_FACTOR)
|
||||
@@ -626,13 +625,10 @@ if (!(draw_sys_flags & DRAW_PLANETS))
|
||||
if (index < NUMBER_OF_PLANET_TYPES
|
||||
&& (pPlanetDesc->data_index & PLANET_SHIELDED))
|
||||
{
|
||||
TFB_ReleaseColorMap();
|
||||
s.frame = SetAbsFrameIndex (SpaceJunkFrame, 17);
|
||||
DrawStamp (&s);
|
||||
}
|
||||
}
|
||||
|
||||
TFB_ReleaseColorMap();
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1699,11 +1695,9 @@ DrawSystem (SIZE radius, BOOLEAN IsInnerSystem)
|
||||
SetColorMap (GetColorMapAddress (
|
||||
SetAbsColorMapIndex (OrbitalCMap,
|
||||
PLANCOLOR (PlanData[pCurDesc->data_index].Type))
|
||||
), TFB_COLORMAP_PLANET);
|
||||
));
|
||||
DrawStamp (&pCurDesc->image);
|
||||
|
||||
TFB_ReleaseColorMap();
|
||||
|
||||
if (index == pSolarSysState->LastPlanetIndex)
|
||||
break;
|
||||
index = pCurDesc->NextIndex;
|
||||
|
||||
@@ -157,7 +157,7 @@ LoadKernel (int argc, char *argv[])
|
||||
COLORMAP ColorMapTab;
|
||||
|
||||
ColorMapTab = CaptureColorMap (LoadColorMap (STARCON_COLOR_MAP));
|
||||
SetColorMap (GetColorMapAddress (ColorMapTab), TFB_COLORMAP_NONE);
|
||||
SetColorMap (GetColorMapAddress (ColorMapTab));
|
||||
DestroyColorMap (ReleaseColorMap (ColorMapTab));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user