Refactored font engine: fonts are loaded and treated as alpha-channel-only images; rendered through a per-context backing surface which unifies solid color and effects processing; new TFB_Prim_FontChar and underlying methods

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2047 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2005-12-08 15:48:31 +00:00
parent ccf43eb5f9
commit 982f40ba32
43 changed files with 482 additions and 425 deletions
+2 -2
View File
@@ -39,7 +39,7 @@ DrawConfirmationWindow (BOOLEAN answer)
COLOR oldfg = SetContextForeGroundColor (MENU_TEXT_COLOR);
COLOR dark, medium;
FONT oldfont = SetContextFont (StarConFont);
FONTEFFECT oldFontEffect = SetContextFontEffect (0, 0, 0);
FRAME oldFontEffect = SetContextFontEffect (NULL);
RECT r;
TEXT t;
@@ -72,7 +72,7 @@ DrawConfirmationWindow (BOOLEAN answer)
UnbatchGraphics ();
SetContextFontEffect (oldFontEffect.type, oldFontEffect.from, oldFontEffect.to);
SetContextFontEffect (oldFontEffect);
SetContextFont (oldfont);
SetContextForeGroundColor (oldfg);
}
+5
View File
@@ -117,6 +117,9 @@ LoadSC2Data (void)
if (MiscDataFrame == NULL)
return FALSE;
FontGradFrame = CaptureDrawable (
LoadGraphic (FONTGRAD_PMAP_ANIM));
SetResourceIndex (hOldIndex);
}
@@ -311,6 +314,8 @@ FreeSC2Data (void)
{
DestroyContext (ReleaseContext (RadarContext));
RadarContext = 0;
DestroyDrawable (ReleaseDrawable (FontGradFrame));
FontGradFrame = 0;
DestroyDrawable (ReleaseDrawable (MiscDataFrame));
MiscDataFrame = 0;
DestroyDrawable (ReleaseDrawable (FlagStatFrame));
+2
View File
@@ -286,4 +286,6 @@
#define SISSKEL_MASK_PMAP_ANIM 0x23611c02L
#define ORBENTER_PMAP_ANIM 0x23811d02L
#define MENUBKG_PMAP_ANIM 0x23a11e02L
#define FONTGRAD_PMAP_ANIM 0x03e11f02L
#define LANDER_FONTEFF_PMAP_ANIM 0x11412002L
+2 -9
View File
@@ -162,14 +162,6 @@ extern INTERSECT_CODE BoxIntersect (PRECT pr1, PRECT pr2, PRECT
printer);
extern void BoxUnion (PRECT pr1, PRECT pr2, PRECT punion);
typedef struct
{
BOOLEAN Use;
DWORD from;
DWORD to;
BYTE type;
} FONTEFFECT;
enum
{
FadeAllToWhite = 250,
@@ -232,13 +224,14 @@ extern DWORD LoadFontFile (PVOID pStr);
extern DWORD LoadGraphicInstance (DWORD res);
extern DWORD LoadGraphic (DWORD res);
extern DRAWABLE LoadDisplayPixmap (PRECT area, FRAME frame);
extern FONTEFFECT SetContextFontEffect (BYTE type, DWORD from, DWORD to);
extern FRAME SetContextFontEffect (FRAME EffectFrame);
extern FONT SetContextFont (FONT Font);
extern BOOLEAN DestroyFont (FONT_REF FontRef);
extern FONT CaptureFont (FONT_REF FontRef);
extern FONT_REF ReleaseFont (FONT Font);
extern BOOLEAN TextRect (PTEXT pText, PRECT pRect, PBYTE pdelta);
extern BOOLEAN GetContextFontLeading (PSIZE pheight);
extern BOOLEAN GetContextFontLeadingWidth (PSIZE pwidth);
extern COUNT GetFrameCount (FRAME Frame);
extern COUNT GetFrameIndex (FRAME Frame);
extern FRAME SetAbsFrameIndex (FRAME Frame, COUNT FrameIndex);
+70
View File
@@ -17,6 +17,7 @@
*/
#include "gfxintrn.h"
#include "gfxother.h"
GRAPHICS_STATUS _GraphicsStatusFlags;
CONTEXTPTR _pCurContext;
@@ -142,6 +143,11 @@ SetContextForeGroundColor (COLOR Color)
if ((oldColor = _get_context_fg_color ()) != Color)
{
SwitchContextForeGroundColor (Color);
if (!(_get_context_fbk_flags () & FBK_IMAGE))
{
SetContextFBkFlags (FBK_DIRTY);
}
}
SetPrimColor (&_locPrim, Color);
@@ -210,3 +216,67 @@ GetContextClipRect (PRECT lpRect)
}
FRAME
SetContextFontEffect (FRAME EffectFrame)
{
FRAME LastEffect;
if (!ContextActive ())
return (NULL);
LastEffect = _get_context_fonteff ();
if (EffectFrame != LastEffect)
{
SwitchContextFontEffect (EffectFrame);
if (EffectFrame != 0)
{
SetContextFBkFlags (FBK_IMAGE);
}
else
{
UnsetContextFBkFlags (FBK_IMAGE);
}
}
return LastEffect;
}
void
FixContextFontEffect (void)
{
SIZE w, h;
TFB_Image* img;
if (!ContextActive () || (_get_context_font_backing () != 0
&& !(_get_context_fbk_flags () & FBK_DIRTY)))
return;
if (!GetContextFontLeading (&h) || !GetContextFontLeadingWidth (&w))
return;
img = _pCurContext->FontBacking;
if (img)
TFB_DrawScreen_DeleteImage (img);
img = TFB_DrawImage_CreateForScreen (w, h, TRUE);
if (_get_context_fbk_flags () & FBK_IMAGE)
{ // image pattern backing
FRAMEPTR EffectFrame = (FRAMEPTR)_get_context_fonteff ();
TFB_DrawImage_Image (EffectFrame->image,
-EffectFrame->HotSpot.x, -EffectFrame->HotSpot.y,
0, NULL, img);
}
else
{ // solid color backing
TFB_Palette color;
RECT r = { {0, 0}, {w, h} };
COLORtoPalette (_get_context_fg_color (), &color);
TFB_DrawImage_Rect (&r, color.r, color.g, color.b, img);
}
_pCurContext->FontBacking = img;
UnsetContextFBkFlags (FBK_DIRTY);
}
+28
View File
@@ -19,6 +19,12 @@
#ifndef _CONTEXT_H
#define _CONTEXT_H
#include "tfb_draw.h"
typedef UWORD FBK_FLAGS;
#define FBK_DIRTY (1 << 0)
#define FBK_IMAGE (1 << 1)
typedef struct
{
CONTEXT_REF ContextRef;
@@ -29,6 +35,11 @@ typedef struct
FONT Font;
RECT ClipRect;
FRAME FontEffect;
TFB_Image *FontBacking;
FBK_FLAGS BackingFlags;
} CONTEXT_DESC;
typedef CONTEXT_DESC *PCONTEXT_DESC;
@@ -51,6 +62,9 @@ extern PRIMITIVE _locPrim;
#define _get_context_flags() (_pCurContext->Flags)
#define _get_context_fg_frame() (_pCurContext->ForeGroundFrame)
#define _get_context_font() (_pCurContext->Font)
#define _get_context_fbk_flags() (_pCurContext->BackingFlags)
#define _get_context_fonteff() (_pCurContext->FontEffect)
#define _get_context_font_backing() (_pCurContext->FontBacking)
#define SwitchContextDrawState(s) \
{ \
@@ -79,11 +93,25 @@ extern PRIMITIVE _locPrim;
#define SwitchContextFont(f) \
{ \
_pCurContext->Font = (f); \
SetContextFBkFlags (FBK_DIRTY); \
}
#define SwitchContextBGFunc(f) \
{ \
_pCurContext->BackGroundFunc = (f); \
}
#define SetContextFBkFlags(f) \
{ \
_pCurContext->BackingFlags |= (f); \
}
#define UnsetContextFBkFlags(f) \
{ \
_pCurContext->BackingFlags &= ~(f); \
}
#define SwitchContextFontEffect(f) \
{ \
_pCurContext->FontEffect = (f); \
SetContextFBkFlags (FBK_DIRTY); \
}
/*
These seem to have been moved to gfxlib.h, but not in their
+18
View File
@@ -27,6 +27,7 @@ enum
TFB_DRAWCOMMANDTYPE_RECTANGLE,
TFB_DRAWCOMMANDTYPE_IMAGE,
TFB_DRAWCOMMANDTYPE_FILLEDIMAGE,
TFB_DRAWCOMMANDTYPE_FONTCHAR,
TFB_DRAWCOMMANDTYPE_COPY,
TFB_DRAWCOMMANDTYPE_COPYTOIMAGE,
@@ -37,6 +38,7 @@ enum
TFB_DRAWCOMMANDTYPE_SETPALETTE,
TFB_DRAWCOMMANDTYPE_SETMIPMAP,
TFB_DRAWCOMMANDTYPE_DELETEIMAGE,
TFB_DRAWCOMMANDTYPE_DELETEDATA,
TFB_DRAWCOMMANDTYPE_SENDSIGNAL,
TFB_DRAWCOMMANDTYPE_REINITVIDEO,
};
@@ -73,6 +75,14 @@ typedef struct tfb_dc_filledimg
int scale;
} TFB_DrawCommand_FilledImage;
typedef struct tfb_dc_fontchar
{
TFB_Char *fontchar;
TFB_Image *backing;
int x, y;
SCREEN destBuffer;
} TFB_DrawCommand_FontChar;
typedef struct tfb_dc_copy
{
int x, y, w, h;
@@ -109,6 +119,12 @@ typedef struct tfb_dc_delimg
TFB_Image *image;
} TFB_DrawCommand_DeleteImage;
typedef struct tfb_dc_deldata
{
void *data;
// data must be a result of HXalloc() call
} TFB_DrawCommand_DeleteData;
typedef struct tfb_dc_signal
{
Semaphore sem;
@@ -127,12 +143,14 @@ typedef struct tfb_drawcommand
TFB_DrawCommand_Rect rect;
TFB_DrawCommand_Image image;
TFB_DrawCommand_FilledImage filledimage;
TFB_DrawCommand_FontChar fontchar;
TFB_DrawCommand_Copy copy;
TFB_DrawCommand_CopyToImage copytoimage;
TFB_DrawCommand_Scissor scissor;
TFB_DrawCommand_SetPalette setpalette;
TFB_DrawCommand_SetMipmap setmipmap;
TFB_DrawCommand_DeleteImage deleteimage;
TFB_DrawCommand_DeleteData deletedata;
TFB_DrawCommand_SendSignal sendsignal;
TFB_DrawCommand_ReinitVideo reinitvideo;
} data;
+39 -57
View File
@@ -21,38 +21,12 @@
#include "gfxother.h"
extern FRAME Build_Font_Effect (FRAME FramePtr, DWORD from, DWORD to,
BYTE type);
static inline FRAME_DESC *getCharFrame (FONT_DESC *fontPtr, wchar_t ch);
extern void FixContextFontEffect (void);
static inline TFB_Char *getCharFrame (FONT_DESC *fontPtr, wchar_t ch);
static BYTE char_delta_array[MAX_DELTAS];
// XXX: This does not seem to be used.
static FONTEFFECT FontEffect = {0,0,0,0};
FONTEFFECT
SetContextFontEffect (BYTE type, DWORD from, DWORD to)
{
FONTEFFECT oldFontEffect = FontEffect;
if (from == to)
FontEffect.Use = 0;
else
{
FontEffect.Use = 1;
FontEffect.from = from;
FontEffect.to = to;
FontEffect.type = type;
}
if (!oldFontEffect.Use)
// reset fields so that when struct passed back
// the logic works correctly
oldFontEffect.to = oldFontEffect.from = 0;
return oldFontEffect;
}
FONT
SetContextFont (FONT Font)
@@ -113,6 +87,7 @@ ReleaseFont (FONT Font)
void
font_DrawText (PTEXT lpText)
{
FixContextFontEffect ();
SetPrimType (&_locPrim, TEXT_PRIM);
_locPrim.Object.Text = *lpText;
DrawBatch (&_locPrim, 0, BATCH_SINGLE);
@@ -131,6 +106,19 @@ GetContextFontLeading (PSIZE pheight)
return (FALSE);
}
BOOLEAN
GetContextFontLeadingWidth (PSIZE pwidth)
{
if (_CurFontPtr != 0)
{
*pwidth = (SIZE)_CurFontPtr->LeadingWidth;
return (TRUE);
}
*pwidth = 0;
return (FALSE);
}
BOOLEAN
TextRect (PTEXT lpText, PRECT pRect, PBYTE pdelta)
{
@@ -174,7 +162,7 @@ TextRect (PTEXT lpText, PRECT pRect, PBYTE pdelta)
{
wchar_t ch;
SIZE last_width;
FRAME_DESC *charFrame;
TFB_Char *charFrame;
last_width = width;
@@ -190,18 +178,18 @@ TextRect (PTEXT lpText, PRECT pRect, PBYTE pdelta)
}
charFrame = getCharFrame (FontPtr, ch);
if (charFrame != NULL && GetFrameWidth (charFrame))
if (charFrame != NULL && charFrame->disp.width)
{
COORD y;
y = -charFrame->HotSpot.y;
if (y < top_y)
top_y = y;
y += GetFrameHeight (charFrame);
y += charFrame->disp.height;
if (y > bot_y)
bot_y = y;
width += GetFrameWidth (charFrame);
width += charFrame->disp.width;
#if 0
if (num_chars && next_ch < (UNICODE) MAX_CHARS
&& !(FontPtr->KernTab[ch]
@@ -252,18 +240,22 @@ _text_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
wchar_t next_ch;
const unsigned char *pStr;
TEXTPTR TextPtr;
STAMP s;
POINT origin;
TFB_Palette color;
TFB_Image *backing;
FontPtr = _CurFontPtr;
if (FontPtr == NULL)
return;
backing = _get_context_font_backing ();
if (!backing)
return;
COLORtoPalette (_get_context_fg_color (), &color);
TextPtr = &PrimPtr->Object.Text;
s.origin.x = _save_stamp.origin.x;
s.origin.y = TextPtr->baseline.y;
origin.x = _save_stamp.origin.x;
origin.y = TextPtr->baseline.y;
num_chars = TextPtr->CharCount;
if (num_chars == 0)
return;
@@ -276,6 +268,7 @@ _text_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
while (num_chars--)
{
wchar_t ch;
TFB_Char* fontChar;
ch = next_ch;
if (num_chars > 0)
@@ -285,44 +278,33 @@ _text_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
num_chars = 0;
}
s.frame = getCharFrame (FontPtr, ch);
if (s.frame != NULL && GetFrameWidth (s.frame))
fontChar = getCharFrame (FontPtr, ch);
if (fontChar != NULL && fontChar->disp.width)
{
RECT r;
r.corner.x = s.origin.x - ((FRAMEPTR)s.frame)->HotSpot.x;
r.corner.y = s.origin.y - ((FRAMEPTR)s.frame)->HotSpot.y;
r.extent.width = GetFrameWidth (s.frame);
r.extent.height = GetFrameHeight (s.frame);
r.corner.x = origin.x - fontChar->HotSpot.x;
r.corner.y = origin.y - fontChar->HotSpot.y;
r.extent.width = fontChar->disp.width;
r.extent.height = fontChar->disp.height;
_save_stamp.origin = r.corner;
if (BoxIntersect (&r, pClipRect, &r))
{
if (FontEffect.Use)
{
FRAME origFrame = s.frame;
s.frame = Build_Font_Effect(
s.frame, FontEffect.from,
FontEffect.to, FontEffect.type);
TFB_Prim_Stamp (&s);
DestroyDrawable (ReleaseDrawable (s.frame));
s.frame = origFrame;
}
else
TFB_Prim_StampFill (&s, &color);
TFB_Prim_FontChar (&origin, fontChar, backing);
}
s.origin.x += GetFrameWidth (s.frame);
origin.x += fontChar->disp.width;
#if 0
if (num_chars && next_ch < (UNICODE) MAX_CHARS
&& !(FontPtr->KernTab[ch]
& (FontPtr->KernTab[next_ch] >> 2)))
s.origin.x -= FontPtr->KernAmount;
origin.x -= FontPtr->KernAmount;
#endif
}
}
}
static inline FRAME_DESC *
static inline TFB_Char *
getCharFrame (FONT_DESC *fontPtr, wchar_t ch)
{
wchar_t pageStart = ch & CHARACTER_PAGE_MASK;
@@ -342,7 +324,7 @@ getCharFrame (FONT_DESC *fontPtr, wchar_t ch)
charIndex = ch - page->firstChar;
if (ch >= page->firstChar && charIndex < page->numChars
&& page->charDesc[charIndex].image)
&& page->charDesc[charIndex].data)
{
return &page->charDesc[charIndex];
}
+3 -2
View File
@@ -28,7 +28,7 @@ typedef struct FontPage
#define CHARACTER_PAGE_MASK 0xff800
wchar_t firstChar;
size_t numChars;
FRAME_DESC *charDesc;
TFB_Char *charDesc;
} FONT_PAGE;
typedef FONT_PAGE *PFONT_PAGE;
@@ -51,7 +51,8 @@ typedef struct
{
FONT_REF FontRef;
BYTE Leading;
UWORD Leading;
UWORD LeadingWidth;
FONT_PAGE *fontPages;
} FONT_DESC;
typedef FONT_DESC *PFONT_DESC;
+39 -190
View File
@@ -106,102 +106,55 @@ process_image (FRAMEPTR FramePtr, SDL_Surface *img[], AniData *ani, int cel_ct)
}
static void
processFontChar (FRAMEPTR FramePtr, SDL_Surface *surf, int charInd)
processFontChar (TFB_Char* CharPtr, SDL_Surface *surf, int charInd)
{
int x,y;
Uint8 r,g,b,a;
Uint32 p;
Uint32 clear, opaque;
SDL_Color colors[256];
SDL_Surface *new_surf;
SDL_PixelFormat* srcfmt = surf->format;
SDL_PixelFormat* dstfmt;
GetPixelFn getpix;
PutPixelFn putpix;
BYTE* newdata;
Uint32 dpitch;
TYPE_SET (FramePtr->TypeIndexAndFlags, ROM_DRAWABLE);
INDEX_SET (FramePtr->TypeIndexAndFlags, charInd);
// XXX: Is this still relevant?
//#define ALPHA_FONTS
//#define RGB_FONTS
// Currently, each font char has its own separate data
// but that can change to common mem area
newdata = HMalloc (surf->w * surf->h * sizeof(BYTE));
dpitch = surf->w;
SDL_LockSurface (surf);
clear = 0;
opaque = 1;
#if defined(ALPHA_FONTS)
// convert png font to truecolor + alpha
new_surf = TFB_DrawCanvas_New_TrueColor (surf->w, surf->h, TRUE);
#elif defined(RGB_FONTS)
// convert png font to truecolor w/ colorkey
new_surf = TFB_DrawCanvas_New_TrueColor (surf->w, surf->h, FALSE);
opaque = SDL_MapRGB (new_surf->format, 255, 255, 255);
#else // indexed fonts
// convert 32-bit png font to indexed
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, surf->w, surf->h,
8, 0, 0, 0, 0);
#endif
dstfmt = new_surf->format;
getpix = getpixel_for (surf);
putpix = putpixel_for (new_surf);
// produce an alpha-only image in internal BYTE[] format
// from the SDL surface
for (y = 0; y < surf->h; ++y)
{
for (x = 0; x < surf->w; ++x)
BYTE* dst = newdata + dpitch * y;
for (x = 0; x < surf->w; ++x, ++dst)
{
p = getpix (surf, x, y);
SDL_GetRGBA (p, srcfmt, &r, &g, &b, &a);
#if defined(ALPHA_FONTS)
if (!srcfmt->Amask)
{ // produce alpha from intensity (Y component)
// using a fast approximation
// contributions to Y are: R=2, G=4, B=1
a = (((int)r << 1) + ((int)g << 2) + b) / 7;
}
// normalize font pixel
putpix (new_surf, x, y, SDL_MapRGBA (dstfmt,
255, 255, 255, a));
#else // indexed/rgb colorkey fonts
// normalize font pixel
if (r == 0 && g == 0 && b == 0)
putpix (new_surf, x, y, clear);
else
putpix (new_surf, x, y, opaque);
#endif
*dst = a;
}
}
#if !defined(ALPHA_FONTS)
#if !defined(RGB_FONTS)
colors[0].r = 0;
colors[0].g = 0;
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);
#endif /* !RGB_FONTS */
SDL_SetColorKey (new_surf, SDL_SRCCOLORKEY, clear);
#endif /* !ALPHA_FONTS */
SDL_UnlockSurface (surf);
SDL_FreeSurface (surf);
FramePtr->image = TFB_DrawImage_New (new_surf);
surf = FramePtr->image->NormalImg;
SetFrameBounds (FramePtr, surf->w + 1, surf->h + 1);
CharPtr->data = newdata;
CharPtr->pitch = dpitch;
CharPtr->extent.width = surf->w;
CharPtr->extent.height = surf->h;
CharPtr->disp.width = surf->w + 1;
CharPtr->disp.height = surf->h + 1;
// XXX: why the +1?
// I brought it into this function from the only calling
// function, but I don't know why it was there in the first
@@ -215,14 +168,15 @@ processFontChar (FRAMEPTR FramePtr, SDL_Surface *surf, int charInd)
int tune_amount = 0;
if (surf->h == 8)
if (CharPtr->extent.height == 8)
tune_amount = -1;
else if (surf->h == 9)
else if (CharPtr->extent.height == 9)
tune_amount = -2;
else if (surf->h > 9)
else if (CharPtr->extent.height > 9)
tune_amount = -3;
FramePtr->HotSpot = MAKE_HOT_SPOT (0, surf->h + tune_amount);
CharPtr->HotSpot = MAKE_HOT_SPOT (0,
CharPtr->extent.height + tune_amount);
}
}
@@ -385,114 +339,6 @@ void getpixelarray(Uint32 *map, FRAMEPTR FramePtr, int width, int height)
UnlockMutex (tfbImg->mutex);
}
FRAMEPTR Build_Font_Effect (FRAMEPTR FramePtr, Uint32 from, Uint32 to, BYTE type)
{
FRAMEPTR NewFrame;
int x, y;
int width, height;
Uint32 color, clear;
Uint32 srcmask, threshold;
BYTE from_r, from_g, from_b, from_a;
BYTE to_r, to_g, to_b, to_a;
TFB_Image *tfbImg, *tfbOrigImg;
SDL_Surface *img, *OrigImg;
PutPixelFn putpix;
GetPixelFn getpix;
tfbOrigImg = FramePtr->image;
OrigImg = (SDL_Surface *)tfbOrigImg->NormalImg;
SDL_LockSurface (OrigImg);
width = OrigImg->w;
height = OrigImg->h;
NewFrame = CaptureDrawable (CreateDrawable ((CREATE_FLAGS)RAM_DRAWABLE,
(SIZE)width, (SIZE)height, 1));
NewFrame->Bounds = FramePtr->Bounds;
NewFrame->HotSpot = FramePtr->HotSpot;
tfbImg = NewFrame->image;
img = (SDL_Surface *)tfbImg->NormalImg;
SDL_LockSurface (img);
putpix = putpixel_for (img);
getpix = getpixel_for (OrigImg);
from_r = (from >> 24);
from_g = (from >> 16) & 0xFF;
from_b = (from >> 8) & 0xFF;
from_a = from & 0xFF;
to_r = (to >> 24);
to_g = (to >> 16) & 0xFF;
to_b = (to >> 8) & 0xFF;
to_a = to & 0xFF;
clear = SDL_MapRGBA (img->format, 0, 0, 0, 0);
TFB_DrawCanvas_SetTransparentColor (img, 0, 0, 0, FALSE);
#if defined(ALPHA_FONTS)
srcmask = OrigImg->format->Amask;
threshold = (srcmask >> 1) & srcmask;
#else // indexed fonts
srcmask = 255;
threshold = 0; // any index != 0
#endif
if (type == GRADIENT_EFFECT)
{
int clrstep_r, clrstep_g, clrstep_b, clrstep_a;
clrstep_r = (to_r - from_r) / (height - 1);
clrstep_g = (to_g - from_g) / (height - 1);
clrstep_b = (to_b - from_b) / (height - 1);
clrstep_a = (to_a - from_a) / (height - 1);
for (y = 0; y < height; y++)
{
color = SDL_MapRGBA (img->format, from_r, from_g, from_b, from_a);
from_r += clrstep_r;
from_g += clrstep_g;
from_b += clrstep_b;
from_a += clrstep_a;
for (x = 0; x < width; x++)
{
Uint32 p = getpix (OrigImg, x, y);
if ((p & srcmask) > threshold)
putpix (img, x, y, color);
else
putpix (img, x, y, clear);
}
}
}
else if (type == ALTERNATE_EFFECT)
{
Uint32 color1, color2;
color1 = SDL_MapRGBA (img->format, from_r, from_g, from_b, from_a);
color2 = SDL_MapRGBA (img->format, to_r, to_g, to_b, to_a);
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
Uint32 p = getpix (OrigImg, x, y);
if ((p & srcmask) > threshold)
{
color = ((y & 0x01) ^ (x & 0x01)) ? color2 : color1;
putpix (img, x, y, color);
}
else
putpix (img, x, y, clear);
}
}
}
SDL_UnlockSurface (img);
SDL_UnlockSurface (OrigImg);
return (NewFrame);
}
// Generate a pixel (in the correct format to be applied to FramePtr) from the
// r,g,b,a values supplied
@@ -729,6 +575,7 @@ _GetFontData (uio_Stream *fp, DWORD length)
fontPtr->FontRef = fontRef;
fontPtr->Leading = 0;
fontPtr->LeadingWidth = 0;
{
size_t startBCD = 0;
@@ -760,10 +607,10 @@ _GetFontData (uio_Stream *fp, DWORD length)
{
// Process one character.
BuildCharDesc *bcd = &bcds[bcdI];
FRAME_DESC *destFrame =
TFB_Char *destChar =
&page->charDesc[bcd->index - page->firstChar];
if (destFrame->image != NULL)
if (destChar->data != NULL)
{
// There's already an image for this character.
#ifdef DEBUG
@@ -775,14 +622,14 @@ _GetFontData (uio_Stream *fp, DWORD length)
continue;
}
processFontChar (destFrame, bcd->surface,
processFontChar (destChar, bcd->surface,
bcd->index - page->firstChar);
// bcd->surface is handed over to destFrame.
// Don't access it through bcd->surface any more.
// It may be freed from within ProcessFontChar().
SDL_FreeSurface (bcd->surface);
if (GetFrameHeight (destFrame) > fontPtr->Leading)
fontPtr->Leading = GetFrameHeight (destFrame);
if (destChar->disp.height > fontPtr->Leading)
fontPtr->Leading = destChar->disp.height;
if (destChar->disp.width > fontPtr->LeadingWidth)
fontPtr->LeadingWidth = destChar->disp.width;
}
}
@@ -836,12 +683,14 @@ _ReleaseFontData (MEM_HANDLE handle)
size_t charI;
for (charI = 0; charI < page->numChars; charI++)
{
FRAME_DESC *frame = &page->charDesc[charI];
TFB_Char *c = &page->charDesc[charI];
if (frame->image == NULL)
if (c->data == NULL)
continue;
TFB_DrawScreen_DeleteImage (frame->image);
// XXX: fix this if fonts get per-page data
// rather than per-char
TFB_DrawScreen_DeleteData (c->data);
}
nextPage = page->next;
@@ -300,6 +300,77 @@ TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int
UnlockMutex (img->mutex);
}
void
TFB_DrawCanvas_FontChar (TFB_Char *fontChar, TFB_Image *backing,
int x, int y, TFB_Canvas target)
{
SDL_Rect srcRect, targetRect;
SDL_Surface *surf;
int w, h;
if (fontChar == 0)
{
fprintf (stderr, "ERROR: "
"TFB_DrawCanvas_FontChar passed null char ptr\n");
return;
}
if (backing == 0)
{
fprintf (stderr, "ERROR: "
"TFB_DrawCanvas_FontChar passed null backing ptr\n");
return;
}
w = fontChar->extent.width;
h = fontChar->extent.height;
LockMutex (backing->mutex);
surf = backing->NormalImg;
if (surf->format->BytesPerPixel != 4
|| surf->w < w || surf->h < h)
{
fprintf (stderr, "ERROR: "
"TFB_DrawCanvas_FontChar bad backing surface: %dx%dx%d; "
"char: %dx%d\n",
surf->w, surf->h, (int)surf->format->BytesPerPixel, w, h);
UnlockMutex (backing->mutex);
return;
}
srcRect.x = 0;
srcRect.y = 0;
srcRect.w = fontChar->extent.width;
srcRect.h = fontChar->extent.height;
targetRect.x = x - fontChar->HotSpot.x;
targetRect.y = y - fontChar->HotSpot.y;
// transfer the alpha channel to the backing surface
SDL_LockSurface (surf);
{
int x, y;
const int sskip = fontChar->pitch - w;
const int dskip = (surf->pitch / 4) - w;
const Uint32 dmask = ~surf->format->Amask;
const int ashift = surf->format->Ashift;
Uint8 *src_p = fontChar->data;
Uint32 *dst_p = (Uint32 *)surf->pixels;
for (y = 0; y < h; ++y, src_p += sskip, dst_p += dskip)
{
for (x = 0; x < w; ++x, ++src_p, ++dst_p)
{
*dst_p = (*dst_p & dmask) | (((Uint32)*src_p) << ashift);
}
}
}
SDL_UnlockSurface (surf);
SDL_BlitSurface (surf, &srcRect, (NativeCanvas) target, &targetRect);
UnlockMutex (backing->mutex);
}
TFB_Canvas
TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha)
{
@@ -669,6 +669,31 @@ TFB_FlushGraphics () // Only call from main thread!!
UnlockMutex (DC_image->mutex);
}
break;
}
case TFB_DRAWCOMMANDTYPE_FONTCHAR:
{
TFB_Char *DC_char = DC.data.fontchar.fontchar;
int x = DC.data.fontchar.x;
int y = DC.data.fontchar.y;
TFB_DrawCanvas_FontChar (DC.data.fontchar.fontchar,
DC.data.fontchar.backing,
DC.data.fontchar.x, DC.data.fontchar.y,
SDL_Screens[DC.data.fontchar.destBuffer]);
if (DC.data.fontchar.destBuffer == 0)
{
RECT r;
r.corner.x = x - DC_char->HotSpot.x;
r.corner.y = y - DC_char->HotSpot.y;
r.extent.width = DC_char->extent.width;
r.extent.height = DC_char->extent.height;
TFB_BBox_RegisterRect (&r);
}
break;
}
case TFB_DRAWCOMMANDTYPE_LINE:
@@ -760,6 +785,12 @@ TFB_FlushGraphics () // Only call from main thread!!
TFB_DrawImage_Delete(DC_image);
break;
}
case TFB_DRAWCOMMANDTYPE_DELETEDATA:
{
void *data = DC.data.deletedata.data;
HFree (data);
break;
}
case TFB_DRAWCOMMANDTYPE_SENDSIGNAL:
ClearSemaphore (DC.data.sendsignal.sem);
break;
+42
View File
@@ -160,6 +160,22 @@ TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale,
TFB_EnqueueDrawCommand (&DC);
}
void
TFB_DrawScreen_FontChar (TFB_Char *fontChar, TFB_Image *backing,
int x, int y, SCREEN dest)
{
TFB_DrawCommand DC;
DC.Type = TFB_DRAWCOMMANDTYPE_FONTCHAR;
DC.data.fontchar.fontchar = fontChar;
DC.data.fontchar.backing = backing;
DC.data.fontchar.x = x;
DC.data.fontchar.y = y;
DC.data.fontchar.destBuffer = dest;
TFB_EnqueueDrawCommand (&DC);
}
void
TFB_DrawScreen_CopyToImage (TFB_Image *img, PRECT lpRect, SCREEN src)
{
@@ -215,6 +231,21 @@ TFB_DrawScreen_DeleteImage (TFB_Image *img)
}
}
void
TFB_DrawScreen_DeleteData (void *data)
// data must be a result of HXalloc() call
{
if (data)
{
TFB_DrawCommand DC;
DC.Type = TFB_DRAWCOMMANDTYPE_DELETEDATA;
DC.data.deletedata.data = data;
TFB_EnqueueDrawCommand (&DC);
}
}
void
TFB_DrawScreen_WaitForSignal (void)
{
@@ -283,6 +314,17 @@ TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale,
UnlockMutex (target->mutex);
}
void
TFB_DrawImage_FontChar (TFB_Char *fontChar, TFB_Image *backing,
int x, int y, TFB_Image *target)
{
LockMutex (target->mutex);
TFB_DrawCanvas_FontChar (fontChar, backing, x, y, target->NormalImg);
target->dirty = TRUE;
UnlockMutex (target->mutex);
}
TFB_Image *
TFB_DrawImage_New (TFB_Canvas canvas)
{
+17
View File
@@ -66,6 +66,18 @@ typedef struct tfb_image
BOOLEAN dirty;
} TFB_Image;
typedef struct tfb_char
{
EXTENT extent;
EXTENT disp;
// Display extent
HOT_SPOT HotSpot;
BYTE* data;
DWORD pitch;
// Pitch is for storing all chars of a page
// in one rectangular pixel matrix
} TFB_Char;
// we do not support paletted format for now
typedef struct tfb_pixelformat
{
@@ -83,8 +95,11 @@ void TFB_DrawScreen_Rect (PRECT rect, int r, int g, int b, SCREEN dest);
void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *palette, SCREEN dest);
void TFB_DrawScreen_Copy (PRECT r, SCREEN src, SCREEN dest);
void TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, SCREEN dest);
void TFB_DrawScreen_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, SCREEN dest);
void TFB_DrawScreen_CopyToImage (TFB_Image *img, PRECT lpRect, SCREEN src);
void TFB_DrawScreen_DeleteImage (TFB_Image *img);
void TFB_DrawScreen_DeleteData (void *);
void TFB_DrawScreen_WaitForSignal (void);
void TFB_DrawScreen_ReinitVideo (int driver, int flags, int width, int height, int bpp);
void TFB_DrawScreen_SetPalette (int paletteIndex, int r, int g, int b);
@@ -100,6 +115,7 @@ void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, int r, int g, int b, TF
void TFB_DrawImage_Rect (PRECT rect, int r, int g, int b, TFB_Image *image);
void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *palette, TFB_Image *target);
void TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, TFB_Image *target);
void TFB_DrawImage_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, TFB_Image *target);
TFB_Canvas TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha);
TFB_Canvas TFB_DrawCanvas_New_ForScreen (int w, int h, BOOLEAN withalpha);
@@ -123,6 +139,7 @@ void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, int r, int g, int b, T
void TFB_DrawCanvas_Rect (PRECT rect, int r, int g, int b, TFB_Canvas image);
void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *palette, TFB_Canvas target);
void TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, int r, int g, int b, TFB_Canvas target);
void TFB_DrawCanvas_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, TFB_Canvas target);
TFB_Palette *TFB_DrawCanvas_ExtractPalette (TFB_Canvas canvas);
void TFB_DrawCanvas_SetPalette (TFB_Canvas target, TFB_Palette *palette);
+20
View File
@@ -213,4 +213,24 @@ TFB_Prim_StampFill (PSTAMP stmp, TFB_Palette *color)
}
}
void
TFB_Prim_FontChar (PPOINT origin, TFB_Char *fontChar, TFB_Image *backing)
{
int x, y;
x = origin->x - _CurFramePtr->HotSpot.x;
y = origin->y - _CurFramePtr->HotSpot.y;
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
{
TFB_DrawScreen_FontChar (fontChar, backing, x, y,
TFB_SCREEN_MAIN);
}
else
{
TFB_DrawImage_FontChar (fontChar, backing, x, y,
_CurFramePtr->image);
}
}
// Text rendering is in font.c, under the name _text_blt
+1
View File
@@ -26,3 +26,4 @@ void TFB_Prim_Rect (PRECT r, TFB_Palette *color);
void TFB_Prim_FillRect (PRECT r, TFB_Palette *color);
void TFB_Prim_Stamp (PSTAMP stamp);
void TFB_Prim_StampFill (PSTAMP stamp, TFB_Palette *color);
void TFB_Prim_FontChar (PPOINT origin, TFB_Char *, TFB_Image *backing);
+10 -10
View File
@@ -49,7 +49,7 @@ Widget_DrawToolTips (int numlines, const char **tips)
{
RECT r;
FONT oldfont = SetContextFont (StarConFont);
FONTEFFECT oldFontEffect = SetContextFontEffect (0, 0, 0);
FRAME oldFontEffect = SetContextFontEffect (NULL);
COLOR oldtext = SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
TEXT t;
int i;
@@ -72,7 +72,7 @@ Widget_DrawToolTips (int numlines, const char **tips)
t.baseline.y += 8;
}
SetContextFontEffect (oldFontEffect.type, oldFontEffect.from, oldFontEffect.to);
SetContextFontEffect (oldFontEffect);
SetContextFont (oldfont);
SetContextForeGroundColor (oldtext);
}
@@ -84,7 +84,7 @@ Widget_DrawMenuScreen (WIDGET *_self, int x, int y)
COLOR title, oldtext;
COLOR inactive, default_color, selected;
FONT oldfont = SetContextFont (StarConFont);
FONTEFFECT oldFontEffect = SetContextFontEffect (0, 0, 0);
FRAME oldFontEffect = SetContextFontEffect (NULL);
TEXT t;
int widget_index, height, widget_y;
@@ -132,7 +132,7 @@ Widget_DrawMenuScreen (WIDGET *_self, int x, int y)
widget_y += (*c->height)(c) + 8;
}
SetContextFontEffect (oldFontEffect.type, oldFontEffect.from, oldFontEffect.to);
SetContextFontEffect (oldFontEffect);
SetContextFont (oldfont);
SetContextForeGroundColor (oldtext);
@@ -147,7 +147,7 @@ Widget_DrawChoice (WIDGET *_self, int x, int y)
COLOR oldtext;
COLOR inactive, default_color, selected;
FONT oldfont = SetContextFont (StarConFont);
FONTEFFECT oldFontEffect = SetContextFontEffect (0, 0, 0);
FRAME oldFontEffect = SetContextFontEffect (NULL);
TEXT t;
int i, home_x, home_y;
@@ -195,7 +195,7 @@ Widget_DrawChoice (WIDGET *_self, int x, int y)
}
font_DrawText (&t);
}
SetContextFontEffect (oldFontEffect.type, oldFontEffect.from, oldFontEffect.to);
SetContextFontEffect (oldFontEffect);
SetContextFont (oldfont);
SetContextForeGroundColor (oldtext);
}
@@ -207,7 +207,7 @@ Widget_DrawButton (WIDGET *_self, int x, int y)
COLOR oldtext;
COLOR inactive, selected;
FONT oldfont = SetContextFont (StarConFont);
FONTEFFECT oldFontEffect = SetContextFontEffect (0, 0, 0);
FRAME oldFontEffect = SetContextFontEffect (NULL);
TEXT t;
selected = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x00), 0x0E);
@@ -229,7 +229,7 @@ Widget_DrawButton (WIDGET *_self, int x, int y)
oldtext = SetContextForeGroundColor (inactive);
}
font_DrawText (&t);
SetContextFontEffect (oldFontEffect.type, oldFontEffect.from, oldFontEffect.to);
SetContextFontEffect (oldFontEffect);
SetContextFont (oldfont);
SetContextForeGroundColor (oldtext);
(void) x;
@@ -242,7 +242,7 @@ Widget_DrawLabel (WIDGET *_self, int x, int y)
COLOR oldtext = SetContextForeGroundColor (
BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
FONT oldfont = SetContextFont (StarConFont);
FONTEFFECT oldFontEffect = SetContextFontEffect (0, 0, 0);
FRAME oldFontEffect = SetContextFontEffect (NULL);
TEXT t;
int i;
@@ -258,7 +258,7 @@ Widget_DrawLabel (WIDGET *_self, int x, int y)
font_DrawText (&t);
t.baseline.y += 8;
}
SetContextFontEffect (oldFontEffect.type, oldFontEffect.from, oldFontEffect.to);
SetContextFontEffect (oldFontEffect);
SetContextFont (oldfont);
SetContextForeGroundColor (oldtext);
(void) x;
+2 -3
View File
@@ -72,7 +72,7 @@ DoMouseError (PMOUSE_ERROR_STATE pInputState)
RECT r;
COLOR bg, dark, medium, text, oldtext;
FONT oldfont = SetContextFont (StarConFont);
FONTEFFECT oldFontEffect = SetContextFontEffect (0, 0, 0);
FRAME oldFontEffect = SetContextFontEffect (NULL);
TEXT t;
r.corner.x = 2;
@@ -104,8 +104,7 @@ DoMouseError (PMOUSE_ERROR_STATE pInputState)
t.baseline.y += 16;
font_DrawText (&t);
SetContextFontEffect (oldFontEffect.type, oldFontEffect.from,
oldFontEffect.to);
SetContextFontEffect (oldFontEffect);
SetContextFont (oldfont);
SetContextForeGroundColor (oldtext);
}
+2 -4
View File
@@ -153,8 +153,7 @@ GenerateBurvixes (BYTE control)
pSolarSysState->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val;
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (LoadGraphic (LANDER_FONT));
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM));
@@ -168,8 +167,7 @@ GenerateBurvixes (BYTE control)
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0]
&& !GET_GAME_STATE (BURVIXESE_BROADCASTERS))
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (LoadGraphic (LANDER_FONT));
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (BURV_BCS_MASK_PMAP_ANIM));
+2 -7
View File
@@ -107,10 +107,7 @@ GenerateChmmr (BYTE control)
LockMutex (GraphicsLock);
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
LoadStringTable (CHMMR_BASE_STRTAB));
@@ -134,9 +131,7 @@ GenerateChmmr (BYTE control)
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString
));
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0;
DestroyFont (ReleaseFont (
pSolarSysState->SysInfo.PlanetInfo.LanderFont));
pSolarSysState->SysInfo.PlanetInfo.LanderFont = 0;
FreeLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
UnlockMutex (GraphicsLock);
break;
+1 -4
View File
@@ -135,10 +135,7 @@ GenerateDruuge (BYTE control)
}
else
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
+1 -4
View File
@@ -109,10 +109,7 @@ GenerateIlwrath (BYTE control)
}
else
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
+2 -8
View File
@@ -193,10 +193,7 @@ GenerateMycon (BYTE control)
case SUN_DEVICE_DEFINED:
if (!GET_GAME_STATE (SUN_DEVICE))
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (SUN_DEVICE_MASK_PMAP_ANIM)
@@ -217,10 +214,7 @@ GenerateMycon (BYTE control)
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
& (1L << 0)))
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (EGG_CASE_MASK_PMAP_ANIM)
+3 -12
View File
@@ -133,10 +133,7 @@ GenerateAndrosynth (BYTE control)
{
UWORD retval;
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
@@ -352,10 +349,7 @@ GenerateOrz (BYTE control)
SET_GAME_STATE (TAALO_UNPROTECTED, 1);
if (CurStarDescPtr->Index == TAALO_PROTECTOR_DEFINED)
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (TAALO_DEVICE_MASK_PMAP_ANIM)
@@ -367,10 +361,7 @@ GenerateOrz (BYTE control)
}
else
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
+1 -4
View File
@@ -230,10 +230,7 @@ GenerateTalkingPet (BYTE control)
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[0])
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
+1 -4
View File
@@ -128,10 +128,7 @@ GeneratePkunk (BYTE control)
}
else
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
+2 -8
View File
@@ -297,10 +297,7 @@ generate_orbital (void)
case 8: /* PLUTO */
if (!GET_GAME_STATE (FOUND_PLUTO_SPATHI))
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (SPAPLUTO_MASK_PMAP_ANIM)
@@ -342,10 +339,7 @@ generate_orbital (void)
if (!GET_GAME_STATE (MOONBASE_DESTROYED))
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (MOONBASE_MASK_PMAP_ANIM)
+1 -4
View File
@@ -196,10 +196,7 @@ GenerateSpathi (BYTE control)
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature = 28;
if (!GET_GAME_STATE (UMGAH_BROADCASTERS))
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (UMGAH_BCS_MASK_PMAP_ANIM)
+1 -4
View File
@@ -126,10 +126,7 @@ GenerateSupox (BYTE control)
}
else
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
+2 -8
View File
@@ -183,10 +183,7 @@ GenerateThradd (BYTE control)
if (CurStarDescPtr->Index == AQUA_HELIX_DEFINED
&& !GET_GAME_STATE (AQUA_HELIX))
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (AQUA_MASK_PMAP_ANIM)
@@ -198,10 +195,7 @@ GenerateThradd (BYTE control)
}
else if (CurStarDescPtr->Index == THRADD_DEFINED)
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
+2 -8
View File
@@ -217,10 +217,7 @@ GenerateUtwig (BYTE control)
if (CurStarDescPtr->Index == BOMB_DEFINED)
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (BOMB_MASK_PMAP_ANIM)
@@ -232,10 +229,7 @@ GenerateUtwig (BYTE control)
}
else
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
+1 -4
View File
@@ -81,10 +81,7 @@ GenerateShipVault (BYTE control)
if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->PlanetDesc[0]
&& pSolarSysState->pOrbitalDesc == &pSolarSysState->MoonDesc[0])
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (VAULT_MASK_PMAP_ANIM)
+3 -12
View File
@@ -202,10 +202,7 @@ GenerateVUX (BYTE control)
{
if (!GET_GAME_STATE (SHOFIXTI_MAIDENS))
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (MAIDENS_MASK_PMAP_ANIM)
@@ -220,10 +217,7 @@ GenerateVUX (BYTE control)
{
if (!GET_GAME_STATE (VUX_BEAST))
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] = 0;
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (
@@ -233,10 +227,7 @@ GenerateVUX (BYTE control)
}
else
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
+1 -4
View File
@@ -72,10 +72,7 @@ GenerateUrquanWreck (BYTE control)
case GENERATE_ORBITAL:
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[6])
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (WRECK_MASK_PMAP_ANIM)
+1 -4
View File
@@ -110,10 +110,7 @@ GenerateYehat (BYTE control)
}
else
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
+1 -4
View File
@@ -218,10 +218,7 @@ GenerateZoqFotPik (BYTE control)
}
else
{
pSolarSysState->SysInfo.PlanetInfo.LanderFont =
CaptureFont (
LoadGraphic (LANDER_FONT)
);
LoadStdLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PlanetSideFrame[1] =
CaptureDrawable (
LoadGraphic (RUINS_MASK_PMAP_ANIM)
+1
View File
@@ -298,6 +298,7 @@ typedef struct
STRING DiscoveryString;
FONT LanderFont;
FRAME LanderFontEff;
} PLANET_INFO;
typedef PLANET_INFO *PPLANET_INFO;
+18 -5
View File
@@ -262,17 +262,30 @@ FreePlanet (void)
DestroyContext (ReleaseContext (TaskContext));
TaskContext = 0;
DestroyStringTable (ReleaseStringTable (
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString
));
pSolarSysState->SysInfo.PlanetInfo.DiscoveryString = 0;
DestroyFont (ReleaseFont (
pSolarSysState->SysInfo.PlanetInfo.LanderFont
));
pSolarSysState->SysInfo.PlanetInfo.LanderFont = 0;
FreeLanderFont (&pSolarSysState->SysInfo.PlanetInfo);
pSolarSysState->PauseRotate = 0;
UnlockMutex (GraphicsLock);
}
void
LoadStdLanderFont (PLANET_INFO *info)
{
info->LanderFont = CaptureFont (LoadGraphic (LANDER_FONT));
info->LanderFontEff = CaptureDrawable (
LoadGraphic (LANDER_FONTEFF_PMAP_ANIM));
}
void
FreeLanderFont (PLANET_INFO *info)
{
DestroyFont (ReleaseFont (info->LanderFont));
info->LanderFont = 0;
DestroyDrawable (ReleaseDrawable (info->LanderFontEff));
info->LanderFontEff = 0;
}
+3 -1
View File
@@ -205,8 +205,10 @@ typedef SOLARSYS_STATE *PSOLARSYS_STATE;
extern PSOLARSYS_STATE pSolarSysState;
extern void LoadPlanet (BOOLEAN IsDefined);
void DrawPlanet(int x, int y, int dy, unsigned int rgb);
extern void DrawPlanet(int x, int y, int dy, unsigned int rgb);
extern void FreePlanet (void);
extern void LoadStdLanderFont (PLANET_INFO *info);
extern void FreeLanderFont (PLANET_INFO *info);
extern void ExploreSolarSys (void);
extern void DrawStarBackGround (BOOLEAN ForPlanet);
+12 -13
View File
@@ -256,22 +256,21 @@ DoDiscoveryReport (SOUND ReadOutSounds)
OldContext = SetContext (ScanContext);
{
FONT OldFont;
FRAME OldFontEffect;
OldFont = SetContextFont (pSolarSysState->SysInfo.PlanetInfo.LanderFont);
OldFont = SetContextFont (
pSolarSysState->SysInfo.PlanetInfo.LanderFont);
if (optWhichFonts == OPT_PC)
{
SetContextFontEffect (ALTERNATE_EFFECT,
BUILD_COLOR_RGBA (0x00, 0x00, 0xD6, 0xFF),
BUILD_COLOR_RGBA (0x00, 0x04, 0xFF, 0xFF));
MakeReport (ReadOutSounds,
(UNICODE *)GetStringAddress (pSolarSysState->SysInfo.PlanetInfo.DiscoveryString),
GetStringLength (pSolarSysState->SysInfo.PlanetInfo.DiscoveryString));
SetContextFontEffect (0, 0, 0);
}
OldFontEffect = SetContextFontEffect (
pSolarSysState->SysInfo.PlanetInfo.LanderFontEff);
else
MakeReport (ReadOutSounds,
(UNICODE *)GetStringAddress (pSolarSysState->SysInfo.PlanetInfo.DiscoveryString),
GetStringLength (pSolarSysState->SysInfo.PlanetInfo.DiscoveryString));
OldFontEffect = SetContextFontEffect (NULL);
MakeReport (ReadOutSounds,
(UNICODE *)GetStringAddress (pSolarSysState->SysInfo.PlanetInfo.DiscoveryString),
GetStringLength (pSolarSysState->SysInfo.PlanetInfo.DiscoveryString));
SetContextFontEffect (OldFontEffect);
SetContextFont (OldFont);
}
#ifdef OLD
+1
View File
@@ -63,6 +63,7 @@ FRAME ActivityFrame;
FRAME StatusFrame;
FRAME FlagStatFrame;
FRAME MiscDataFrame;
FRAME FontGradFrame;
Mutex GraphicsLock;
STRING GameStrings;
+1
View File
@@ -31,6 +31,7 @@ extern FRAME ActivityFrame;
extern FRAME StatusFrame;
extern FRAME FlagStatFrame;
extern FRAME MiscDataFrame;
extern FRAME FontGradFrame;
extern CONTEXT OffScreenContext;
extern CONTEXT ScreenContext;
+16 -26
View File
@@ -339,6 +339,7 @@ DrawFlagshipName (BOOLEAN InStatusArea)
FONT OldFont;
COLOR OldColor;
CONTEXT OldContext;
FRAME OldFontEffect;
UNICODE buf[60];
if (InStatusArea)
@@ -367,6 +368,7 @@ DrawFlagshipName (BOOLEAN InStatusArea)
wsprintf (buf, "%s %s", GAME_STRING (NAMING_STRING_BASE + 1), GLOBAL_SIS (ShipName));
wstrupr (buf);
}
OldFontEffect = SetContextFontEffect (NULL);
OldColor = SetContextForeGroundColor (BLACK_COLOR);
DrawFilledRectangle (&r);
@@ -374,22 +376,15 @@ DrawFlagshipName (BOOLEAN InStatusArea)
t.baseline.y = r.corner.y + (SHIP_NAME_HEIGHT - InStatusArea);
t.align = ALIGN_CENTER;
t.CharCount = (COUNT)~0;
if (optWhichFonts == OPT_PC) {
if (InStatusArea)
SetContextFontEffect (GRADIENT_EFFECT,
BUILD_COLOR_RGBA (0xF7, 0x08, 0x00, 0xFF),
BUILD_COLOR_RGBA (0xF7, 0xCD, 0x00, 0xFF));
else
SetContextFontEffect (GRADIENT_EFFECT,
BUILD_COLOR_RGBA (0x00, 0x00, 0x80, 0xFF),
BUILD_COLOR_RGBA (0x0C, 0x18, 0xFF, 0xFF));
}
if (optWhichFonts == OPT_PC)
SetContextFontEffect (SetAbsFrameIndex (FontGradFrame,
InStatusArea ? 0 : 3));
else
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x14, 0x0A, 0x00), 0x0C));
font_DrawText (&t);
if (optWhichFonts == OPT_PC)
SetContextFontEffect (0, 0, 0);
SetContextFontEffect (OldFontEffect);
SetContextForeGroundColor (OldColor);
SetContextFont (OldFont);
SetContext (OldContext);
@@ -402,6 +397,7 @@ DrawFlagshipStats (void)
TEXT t;
FONT OldFont;
COLOR OldColor;
FRAME OldFontEffect;
CONTEXT OldContext;
UNICODE buf[60];
SIZE leading;
@@ -452,6 +448,7 @@ DrawFlagshipStats (void)
OldContext = SetContext (SpaceContext);
OldFont = SetContextFont (StarConFont);
OldFontEffect = SetContextFontEffect (NULL);
GetContextFontLeading (&leading);
/* we need room to play. full screen width, 4 lines tall */
@@ -474,9 +471,7 @@ DrawFlagshipStats (void)
t.align = ALIGN_RIGHT;
t.CharCount = (COUNT)~0;
SetContextFontEffect (GRADIENT_EFFECT,
BUILD_COLOR_RGBA (0x00, 0x00, 0xA0, 0xFF),
BUILD_COLOR_RGBA (0x70, 0x7C, 0xFF, 0xFF));
SetContextFontEffect (SetAbsFrameIndex (FontGradFrame, 4));
wsprintf (buf, "nose:");
font_DrawText (&t);
@@ -510,9 +505,7 @@ DrawFlagshipStats (void)
t.baseline.y = r.corner.y + leading + 3;
t.align = ALIGN_RIGHT;
SetContextFontEffect (GRADIENT_EFFECT,
BUILD_COLOR_RGBA (0x00, 0x30, 0x48, 0xFF),
BUILD_COLOR_RGBA (0x68, 0xAC, 0xCC, 0xFF));
SetContextFontEffect (SetAbsFrameIndex (FontGradFrame, 5));
wsprintf (buf, "maximum velocity:");
font_DrawText (&t);
@@ -548,7 +541,7 @@ DrawFlagshipStats (void)
wsprintf (buf, "%4lu", (fuel / FUEL_TANK_SCALE));
font_DrawText (&t);
SetContextFontEffect (0, 0, 0);
SetContextFontEffect (OldFontEffect);
SetContextForeGroundColor (OldColor);
SetContextFont (OldFont);
SetContext (OldContext);
@@ -695,6 +688,7 @@ DrawPC_SIS (void)
TEXT t;
RECT r;
UNICODE buf[10];
GetGaugeRect (&r, FALSE);
t.baseline.x = STATUS_WIDTH >> 1;
t.baseline.y = r.corner.y - 1;
@@ -709,9 +703,7 @@ DrawPC_SIS (void)
r.extent.width += 2;
DrawFilledRectangle (&r);
SetContextFontEffect (GRADIENT_EFFECT,
BUILD_COLOR_RGBA (0x40, 0x00, 0x00, 0xFF),
BUILD_COLOR_RGBA (0xFF, 0x00, 0x00, 0xFF));
SetContextFontEffect (SetAbsFrameIndex (FontGradFrame, 1));
wsprintf (buf, "FUEL");
font_DrawText (&t);
@@ -719,12 +711,10 @@ DrawPC_SIS (void)
t.baseline.y += 79;
DrawFilledRectangle (&r);
SetContextFontEffect (GRADIENT_EFFECT,
BUILD_COLOR_RGBA (0x00, 0x28, 0x00, 0xFF),
BUILD_COLOR_RGBA (0x00, 0xC0, 0x00, 0xFF));
SetContextFontEffect (SetAbsFrameIndex (FontGradFrame, 2));
wsprintf (buf, "CREW");
font_DrawText (&t);
SetContextFontEffect (0, 0, 0);
SetContextFontEffect (NULL);
r.corner.x = 2 + 1;
r.corner.y = 3;