diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 7bb9015fe..aa825e7ad 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.7: +- All graphics operations use 24-bits colors at the game level too now, + instead of 16 bits colors. - SvdB - Cross-platform safemode (ignores uqm.cfg, bug #946) - Michael - Correct Chmmr response when asking about Sa-Matra (bug #1073) - Alex - Refactored universe generation - SvdB diff --git a/sc2/build/msvc6/UrQuanMasters.dsp b/sc2/build/msvc6/UrQuanMasters.dsp index 2232e3e8e..d2f77d285 100644 --- a/sc2/build/msvc6/UrQuanMasters.dsp +++ b/sc2/build/msvc6/UrQuanMasters.dsp @@ -481,10 +481,6 @@ SOURCE=..\..\src\libs\graphics\gfxintrn.h # End Source File # Begin Source File -SOURCE=..\..\src\libs\graphics\gfxother.h -# End Source File -# Begin Source File - SOURCE=..\..\src\libs\graphics\intersec.c # End Source File # Begin Source File diff --git a/sc2/src/libs/gfxlib.h b/sc2/src/libs/gfxlib.h index e8d06dbfb..759793482 100644 --- a/sc2/src/libs/gfxlib.h +++ b/sc2/src/libs/gfxlib.h @@ -38,12 +38,36 @@ typedef UWORD TIME_VALUE; #define MAX_TIME_VALUE ((1 << TIME_SHIFT) + 1) typedef SWORD COORD; -typedef DWORD COLOR; -#define BUILD_COLOR(c32k,c256) \ - (COLOR)(((DWORD)(c32k)<<8)|(BYTE)(c256)) - // BUILD_COLOR combines a 15-bit RGB color tripple with a +typedef struct Color { + BYTE r; + BYTE g; + BYTE b; + BYTE a; // Currently unused +} Color; + +static inline bool +sameColor(Color c1, Color c2) +{ + return c1.r == c2.r && + c1.g == c2.g && + c1.b == c2.b && + c1.a == c2.a; +} + +// Transform a 5-bits color component to an 8-bits color component. +// Form 1, calculates '(r5 / 31.0) * 255.0, highest value is 0xff: +#define CC5TO8(c) (((c) << 3) | ((c) >> 2)) +// Form 2, calculates '(r5 / 32.0) * 256.0, highest value is 0xf8: +//#define CC5TO8(c) ((c) << 3) + +#define BUILD_COLOR(col, c256) col + // BUILD_COLOR used to combine a 15-bit RGB color tripple with a // destination VGA palette index into a 32-bit value. + // Now, it is an empty wrapper which returns the first argument, + // which is of type Color, and ignores the second argument, + // the palette index. + // // It is a remnant of 8bpp hardware paletted display (VGA). // The palette index would be overwritten with the RGB value // and the drawing op would use this index on screen. @@ -54,10 +78,56 @@ typedef DWORD COLOR; // the standard ones (see colors.h; most likely unchanged from SC1) // The palette index is meaningless in UQM for the most part. // New code should just use index 0. -#define COLOR_32k(c) (UWORD)((COLOR)(c)>>8) -#define COLOR_256(c) LOBYTE((COLOR)c) -#define MAKE_RGB15(r,g,b) (UWORD)(((r)<<10)|((g)<<5)|(b)) -#define BUILD_COLOR_RGBA(r,g,b,a) (DWORD)(((r)<<24)|((g)<<16)|((b)<<8)|(a)) + +// Turn a 15 bits color into a 24-bits color. +// r, g, and b are each 5-bits color components. +static inline Color +colorFromRgb15 (BYTE r, BYTE g, BYTE b) +{ + Color c; + c.r = CC5TO8 (r); + c.g = CC5TO8 (g); + c.b = CC5TO8 (b); + c.a = 0; + + return c; +} +#define MAKE_RGB15(r, g, b) colorFromRgb15 ((r), (g), (b)) + +#ifdef NOTYET /* Need C'99 support */ +#define MAKE_RGB15(r, g, b) (Color) { \ + .r = CC5TO8 (r), \ + .g = CC5TO8 (g), \ + .b = CC5TO8 (b), \ + .a = 0 \ + } +#endif + +// Temporary, until we can use C'99 features. Then MAKE_RGB15 will be usable +// anywhere. +// This define is intended for global initialisations, where the +// expression must be constant. +#define MAKE_RGB15_INIT(r, g, b) { \ + CC5TO8 (r), \ + CC5TO8 (g), \ + CC5TO8 (b), \ + 0 \ + } + +static inline Color +buildColorRgba (BYTE r, BYTE g, BYTE b, BYTE a) +{ + Color c; + c.r = r; + c.g = g; + c.b = b; + c.a = a; + + return c; +} +#define BUILD_COLOR_RGBA(r, g, b, a) \ + buildColorRgba ((r), (g), (b), (a)) + typedef BYTE CREATE_FLAGS; #define WANT_MASK (CREATE_FLAGS)(1 << 0) @@ -168,10 +238,10 @@ extern BOOLEAN InitGraphics (int argc, char *argv[], COUNT extern void UninitGraphics (void); extern CONTEXT SetContext (CONTEXT Context); -extern COLOR SetContextForeGroundColor (COLOR Color); -extern COLOR GetContextForeGroundColor (void); -extern COLOR SetContextBackGroundColor (COLOR Color); -extern COLOR GetContextBackGroundColor (void); +extern Color SetContextForeGroundColor (Color Color); +extern Color GetContextForeGroundColor (void); +extern Color SetContextBackGroundColor (Color Color); +extern Color GetContextBackGroundColor (void); extern FRAME SetContextFGFrame (FRAME Frame); extern FRAME GetContextFGFrame (void); extern BOOLEAN SetContextClipping (BOOLEAN ClipStatus); @@ -186,7 +256,7 @@ extern void DrawRectangle (RECT *pRect); extern void DrawFilledRectangle (RECT *pRect); extern void DrawLine (LINE *pLine); extern void font_DrawText (TEXT *pText); -extern void font_DrawTracedText (TEXT *pText, COLOR text, COLOR trace); +extern void font_DrawTracedText (TEXT *pText, Color text, Color trace); extern void DrawBatch (PRIMITIVE *pBasePrim, PRIM_LINKS PrimLinks, BATCH_FLAGS BatchFlags); extern void BatchGraphics (void); @@ -236,7 +306,7 @@ extern FRAME SetEquFrameIndex (FRAME DstFrame, FRAME SrcFrame); extern FRAME IncFrameIndex (FRAME Frame); extern FRAME DecFrameIndex (FRAME Frame); extern DRAWABLE RotateFrame (FRAME Frame, int angle_deg); -extern void SetFrameTransparentColor (FRAME Frame, COLOR c32k); +extern void SetFrameTransparentColor (FRAME Frame, Color c32k); extern FRAME CaptureDrawable (DRAWABLE Drawable); extern DRAWABLE ReleaseDrawable (FRAME Frame); diff --git a/sc2/src/libs/graphics/cmap.c b/sc2/src/libs/graphics/cmap.c index 9ba94be11..1074c3f26 100644 --- a/sc2/src/libs/graphics/cmap.c +++ b/sc2/src/libs/graphics/cmap.c @@ -41,7 +41,7 @@ typedef struct xform_control SIZE Ticks; DWORD StartTime; DWORD EndTime; - TFB_Palette OldCMap[NUMBER_OF_PLUTVALS]; + Color OldCMap[NUMBER_OF_PLUTVALS]; } XFORM_CONTROL; #define MAX_XFORMS 16 @@ -225,7 +225,7 @@ TFB_GetColorMap (int index) } void -TFB_ColorMapToRGB (TFB_Palette *pal, int index) +TFB_ColorMapToRGB (Color *pal, int index) { TFB_ColorMap *map = NULL; @@ -239,7 +239,7 @@ TFB_ColorMapToRGB (TFB_Palette *pal, int index) return; } - memcpy (pal, map->colors, sizeof (map->colors)); + memcpy (pal, map->colors, sizeof map->colors); } BOOLEAN @@ -288,7 +288,7 @@ SetColorMap (COLORMAPPTR map) for (mpp = colormaps + start; start <= end; ++start, ++mpp) { int i; - TFB_Palette *pal; + Color *pal; TFB_ColorMap *newmap; TFB_ColorMap *oldmap; @@ -464,7 +464,7 @@ XFormColorMap_step (void) #define XFORM_SCALE 0x10000 TFB_ColorMap *newmap = NULL; UBYTE *pNewCMap; - TFB_Palette *pCurCMap, *pOldCMap; + Color *pCurCMap, *pOldCMap; int frac; int i; @@ -480,16 +480,16 @@ XFormColorMap_step (void) for (i = 0; i < NUMBER_OF_PLUTVALS; i++, ++pCurCMap, ++pOldCMap) { - pCurCMap->r = (UBYTE)(pOldCMap->r + ((int)*pNewCMap - pOldCMap->r) - * frac / XFORM_SCALE); + pCurCMap->r = (UBYTE)(pOldCMap->r + + ((int)*pNewCMap - pOldCMap->r) * frac / XFORM_SCALE); pNewCMap++; - pCurCMap->g = (UBYTE)(pOldCMap->g + ((int)*pNewCMap - pOldCMap->g) - * frac / XFORM_SCALE); + pCurCMap->g = (UBYTE)(pOldCMap->g + + ((int)*pNewCMap - pOldCMap->g) * frac / XFORM_SCALE); pNewCMap++; - pCurCMap->b = (UBYTE)(pOldCMap->b + ((int)*pNewCMap - pOldCMap->b) - * frac / XFORM_SCALE); + pCurCMap->b = (UBYTE)(pOldCMap->b + + ((int)*pNewCMap - pOldCMap->b) * frac / XFORM_SCALE); pNewCMap++; } diff --git a/sc2/src/libs/graphics/cmap.h b/sc2/src/libs/graphics/cmap.h index 6faabd3dd..93c1f77bb 100644 --- a/sc2/src/libs/graphics/cmap.h +++ b/sc2/src/libs/graphics/cmap.h @@ -40,7 +40,7 @@ typedef struct tfb_colormap { - TFB_Palette colors[NUMBER_OF_PLUTVALS]; + Color colors[NUMBER_OF_PLUTVALS]; int index; int version; int refcount; @@ -52,7 +52,7 @@ extern volatile int FadeAmount; extern void InitColorMaps (void); extern void UninitColorMaps (void); -extern void TFB_ColorMapToRGB (TFB_Palette *pal, int colormap_index); +extern void TFB_ColorMapToRGB (Color *pal, int colormap_index); extern TFB_ColorMap * TFB_GetColorMap (int index); extern void TFB_ReturnColorMap (TFB_ColorMap *map); diff --git a/sc2/src/libs/graphics/context.c b/sc2/src/libs/graphics/context.c index 20d55d89b..94177766c 100644 --- a/sc2/src/libs/graphics/context.c +++ b/sc2/src/libs/graphics/context.c @@ -17,7 +17,6 @@ */ #include "gfxintrn.h" -#include "gfxother.h" GRAPHICS_STATUS _GraphicsStatusFlags; CONTEXT _pCurContext; @@ -145,30 +144,30 @@ DestroyContext (CONTEXT ContextRef) return TRUE; } -COLOR -SetContextForeGroundColor (COLOR Color) +Color +SetContextForeGroundColor (Color color) { - COLOR oldColor; + Color oldColor; if (!ContextActive ()) return (BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); oldColor = _get_context_fg_color (); - if (oldColor != Color) + if (!sameColor(oldColor, color)) { - SwitchContextForeGroundColor (Color); + SwitchContextForeGroundColor (color); if (!(_get_context_fbk_flags () & FBK_IMAGE)) { SetContextFBkFlags (FBK_DIRTY); } } - SetPrimColor (&_locPrim, Color); + SetPrimColor (&_locPrim, color); return (oldColor); } -COLOR +Color GetContextForeGroundColor (void) { if (!ContextActive ()) @@ -177,22 +176,22 @@ GetContextForeGroundColor (void) return _get_context_fg_color (); } -COLOR -SetContextBackGroundColor (COLOR Color) +Color +SetContextBackGroundColor (Color color) { - COLOR oldColor; + Color oldColor; if (!ContextActive ()) return (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00)); oldColor = _get_context_bg_color (); - if (oldColor != Color) - SwitchContextBackGroundColor (Color); + if (!sameColor(oldColor, color)) + SwitchContextBackGroundColor (color); - return (oldColor); + return oldColor; } -COLOR +Color GetContextBackGroundColor (void) { if (!ContextActive ()) @@ -301,10 +300,9 @@ FixContextFontEffect (void) } else { // solid color backing - TFB_Palette color; RECT r = { {0, 0}, {w, h} }; + Color color = _get_context_fg_color (); - COLORtoPalette (_get_context_fg_color (), &color); TFB_DrawImage_Rect (&r, color.r, color.g, color.b, img); } diff --git a/sc2/src/libs/graphics/context.h b/sc2/src/libs/graphics/context.h index bbe058cca..8d3764c35 100644 --- a/sc2/src/libs/graphics/context.h +++ b/sc2/src/libs/graphics/context.h @@ -30,7 +30,7 @@ struct context_desc { UWORD Flags; - COLOR ForeGroundColor, BackGroundColor; + Color ForeGroundColor, BackGroundColor; FRAME ForeGroundFrame; FONT Font; diff --git a/sc2/src/libs/graphics/drawable.c b/sc2/src/libs/graphics/drawable.c index 753639f5f..94c4244b2 100644 --- a/sc2/src/libs/graphics/drawable.c +++ b/sc2/src/libs/graphics/drawable.c @@ -19,7 +19,6 @@ #include "gfxintrn.h" #include "libs/memlib.h" #include "tfb_draw.h" -#include "gfxother.h" #include #ifndef M_PI @@ -251,12 +250,10 @@ RotateFrame (FRAME Frame, int angle_deg) return Drawable; } +// color.a is ignored void -SetFrameTransparentColor (FRAME Frame, COLOR c32k) +SetFrameTransparentColor (FRAME Frame, Color color) { - TFB_Palette color; - - COLORtoPalette (c32k, &color); TFB_DrawCanvas_SetTransparentColor (Frame->image->NormalImg, color.r, color.g, color.b, FALSE); } diff --git a/sc2/src/libs/graphics/font.c b/sc2/src/libs/graphics/font.c index c45b5531a..0d1bc2c80 100644 --- a/sc2/src/libs/graphics/font.c +++ b/sc2/src/libs/graphics/font.c @@ -18,7 +18,6 @@ #include "gfxintrn.h" #include "tfb_prim.h" -#include "gfxother.h" #include "libs/log.h" extern void FixContextFontEffect (void); @@ -64,10 +63,10 @@ font_DrawText (TEXT *lpText) * background color one pixel shifted to all 4 directions. */ void -font_DrawTracedText (TEXT *pText, COLOR text, COLOR trace) +font_DrawTracedText (TEXT *pText, Color text, Color trace) { // Preserve current foreground color for full correctness - COLOR oldfg = SetContextForeGroundColor (trace); + Color oldfg = SetContextForeGroundColor (trace); pText->baseline.x--; font_DrawText (pText); pText->baseline.x += 2; @@ -235,7 +234,6 @@ _text_blt (RECT *pClipRect, PRIMITIVE *PrimPtr) const unsigned char *pStr; TEXT *TextPtr; POINT origin; - TFB_Palette color; TFB_Image *backing; FontPtr = _CurFontPtr; @@ -245,8 +243,6 @@ _text_blt (RECT *pClipRect, PRIMITIVE *PrimPtr) if (!backing) return; - COLORtoPalette (_get_context_fg_color (), &color); - TextPtr = &PrimPtr->Object.Text; origin.x = _save_stamp.origin.x; origin.y = TextPtr->baseline.y; diff --git a/sc2/src/libs/graphics/frame.c b/sc2/src/libs/graphics/frame.c index 7cd51b6e8..f701f593b 100644 --- a/sc2/src/libs/graphics/frame.c +++ b/sc2/src/libs/graphics/frame.c @@ -20,7 +20,6 @@ #include "gfx_common.h" #include "tfb_draw.h" #include "tfb_prim.h" -#include "gfxother.h" HOT_SPOT MAKE_HOT_SPOT (COORD x, COORD y) @@ -45,7 +44,7 @@ typedef struct { PRIM_LINKS Links; GRAPHICS_PRIM Type; - COLOR Color; + Color Color; INTERNAL_PRIM_DESC Object; } INTERNAL_PRIMITIVE; @@ -84,10 +83,8 @@ GetFrameValidRect (RECT *pValidRect, HOT_SPOT *pOldHot) void ClearBackGround (RECT *pClipRect) { - TFB_Palette color; - - COLORtoPalette (_get_context_bg_color (), &color); - TFB_Prim_FillRect (pClipRect, &color); + Color color = _get_context_bg_color (); + TFB_Prim_FillRect (pClipRect, color); } void @@ -103,9 +100,7 @@ DrawBatch (PRIMITIVE *lpBasePrim, PRIM_LINKS PrimLinks, PRIM_LINKS OldLinks; PRIMITIVE *lpPrim; - BatchFlags &= BATCH_SINGLE - | BATCH_BUILD_PAGE - | BATCH_XFORM; + BatchFlags &= BATCH_SINGLE | BATCH_BUILD_PAGE | BATCH_XFORM; BatchFlags |= _get_context_flags () & BATCH_CLIP_GRAPHICS; @@ -131,12 +126,13 @@ DrawBatch (PRIMITIVE *lpBasePrim, PRIM_LINKS PrimLinks, } } - for (; CurIndex != END_OF_LIST; CurIndex = GetSuccLink (GetPrimLinks (lpPrim))) + for (; CurIndex != END_OF_LIST; + CurIndex = GetSuccLink (GetPrimLinks (lpPrim))) { GRAPHICS_PRIM PrimType; PRIMITIVE *lpWorkPrim; RECT ClipRect; - TFB_Palette color; + Color color; lpPrim = &lpBasePrim[CurIndex]; PrimType = GetPrimType (lpPrim); @@ -148,19 +144,19 @@ DrawBatch (PRIMITIVE *lpBasePrim, PRIM_LINKS PrimLinks, switch (PrimType) { case POINT_PRIM: - COLORtoPalette (GetPrimColor (lpWorkPrim), &color); - TFB_Prim_Point (&lpWorkPrim->Object.Point, &color); + color = GetPrimColor (lpWorkPrim); + TFB_Prim_Point (&lpWorkPrim->Object.Point, color); break; case STAMP_PRIM: TFB_Prim_Stamp (&lpWorkPrim->Object.Stamp); break; case STAMPFILL_PRIM: - COLORtoPalette (GetPrimColor (lpWorkPrim), &color); - TFB_Prim_StampFill (&lpWorkPrim->Object.Stamp, &color); + color = GetPrimColor (lpWorkPrim); + TFB_Prim_StampFill (&lpWorkPrim->Object.Stamp, color); break; case LINE_PRIM: - COLORtoPalette (GetPrimColor (lpWorkPrim), &color); - TFB_Prim_Line (&lpWorkPrim->Object.Line, &color); + color = GetPrimColor (lpWorkPrim); + TFB_Prim_Line (&lpWorkPrim->Object.Line, color); break; case TEXT_PRIM: if (!TextRect (&lpWorkPrim->Object.Text, @@ -172,12 +168,12 @@ DrawBatch (PRIMITIVE *lpBasePrim, PRIM_LINKS PrimLinks, _text_blt (&ClipRect, lpWorkPrim); break; case RECT_PRIM: - COLORtoPalette (GetPrimColor (lpWorkPrim), &color); - TFB_Prim_Rect (&lpWorkPrim->Object.Rect, &color); + color = GetPrimColor (lpWorkPrim); + TFB_Prim_Rect (&lpWorkPrim->Object.Rect, color); break; case RECTFILL_PRIM: - COLORtoPalette (GetPrimColor (lpWorkPrim), &color); - TFB_Prim_FillRect (&lpWorkPrim->Object.Rect, &color); + color = GetPrimColor (lpWorkPrim); + TFB_Prim_FillRect (&lpWorkPrim->Object.Rect, color); break; } } @@ -188,9 +184,7 @@ DrawBatch (PRIMITIVE *lpBasePrim, PRIM_LINKS PrimLinks, if (BatchFlags & BATCH_SINGLE) SetPrimLinks (lpBasePrim, - GetPredLink (OldLinks), - GetSuccLink (OldLinks)); - + GetPredLink (OldLinks), GetSuccLink (OldLinks)); } } @@ -218,10 +212,8 @@ DrawPoint (POINT *lpPoint) if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot)) { - TFB_Palette color; - - COLORtoPalette (GetPrimColor (&_locPrim), &color); - TFB_Prim_Point (lpPoint, &color); + Color color = GetPrimColor (&_locPrim); + TFB_Prim_Point (lpPoint, color); _CurFramePtr->HotSpot = OldHot; } } @@ -234,10 +226,8 @@ DrawRectangle (RECT *lpRect) if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot)) { - TFB_Palette color; - - COLORtoPalette (GetPrimColor (&_locPrim), &color); - TFB_Prim_Rect (lpRect, &color); + Color color = GetPrimColor (&_locPrim); + TFB_Prim_Rect (lpRect, color); _CurFramePtr->HotSpot = OldHot; } } @@ -250,10 +240,8 @@ DrawFilledRectangle (RECT *lpRect) if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot)) { - TFB_Palette color; - - COLORtoPalette (GetPrimColor (&_locPrim), &color); - TFB_Prim_FillRect (lpRect, &color); + Color color = GetPrimColor (&_locPrim); + TFB_Prim_FillRect (lpRect, color); _CurFramePtr->HotSpot = OldHot; } } @@ -266,12 +254,10 @@ DrawLine (LINE *lpLine) if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot)) { - TFB_Palette color; - - COLORtoPalette (GetPrimColor (&_locPrim), &color); - TFB_Prim_Line (lpLine, &color); + Color color = GetPrimColor (&_locPrim); + TFB_Prim_Line (lpLine, color); _CurFramePtr->HotSpot = OldHot; - } + } } void @@ -295,10 +281,9 @@ DrawFilledStamp (STAMP *stmp) if (GraphicsSystemActive () && GetFrameValidRect (&ValidRect, &OldHot)) { - TFB_Palette color; - - COLORtoPalette (GetPrimColor (&_locPrim), &color); - TFB_Prim_StampFill (stmp, &color); + Color color = GetPrimColor (&_locPrim); + TFB_Prim_StampFill (stmp, color); _CurFramePtr->HotSpot = OldHot; } } + diff --git a/sc2/src/libs/graphics/gfxother.h b/sc2/src/libs/graphics/gfxother.h deleted file mode 100644 index 270d31378..000000000 --- a/sc2/src/libs/graphics/gfxother.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef GFXOTHER_H -#define GFXOTHER_H - -#include "gfxintrn.h" -#include "tfb_draw.h" - -static inline void -COLORtoPalette (DWORD c32k, TFB_Palette* color) -{ - c32k >>= 8; // shift out color index - color->r = (UBYTE)((c32k >> (10 - (8 - 5))) & 0xF8); - color->g = (UBYTE)((c32k >> (5 - (8 - 5))) & 0xF8); - color->b = (UBYTE)((c32k << (8 - 5)) & 0xF8); -} - -#endif /* GFXOTHER */ diff --git a/sc2/src/libs/graphics/prim.h b/sc2/src/libs/graphics/prim.h index ef932924c..db27b69c4 100644 --- a/sc2/src/libs/graphics/prim.h +++ b/sc2/src/libs/graphics/prim.h @@ -45,7 +45,7 @@ typedef struct { PRIM_LINKS Links; GRAPHICS_PRIM Type; - COLOR Color; + Color color; PRIM_DESC Object; } PRIMITIVE; @@ -58,8 +58,8 @@ typedef struct #define GetPrimLinks(pPrim) ((pPrim)->Links) #define SetPrimType(pPrim,t) ((pPrim)->Type = t) #define GetPrimType(pPrim) ((pPrim)->Type) -#define SetPrimColor(pPrim,c) ((pPrim)->Color = c) -#define GetPrimColor(pPrim) ((pPrim)->Color) +#define SetPrimColor(pPrim,c) ((pPrim)->color = c) +#define GetPrimColor(pPrim) ((pPrim)->color) static inline void SetPrimNextLink (PRIMITIVE *pPrim, COUNT Link) diff --git a/sc2/src/libs/graphics/sdl/canvas.c b/sc2/src/libs/graphics/sdl/canvas.c index 0260576d6..c2b22212f 100644 --- a/sc2/src/libs/graphics/sdl/canvas.c +++ b/sc2/src/libs/graphics/sdl/canvas.c @@ -84,7 +84,7 @@ TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, { SDL_Rect srcRect, targetRect, *pSrcRect; SDL_Surface *surf; - TFB_Palette* palette; + Color *palette; if (img == 0) { @@ -483,7 +483,8 @@ TFB_DrawCanvas_New_ForScreen (int w, int h, BOOLEAN withalpha) } TFB_Canvas -TFB_DrawCanvas_New_Paletted (int w, int h, TFB_Palette *palette, int transparent_index) +TFB_DrawCanvas_New_Paletted (int w, int h, Color *palette, + int transparent_index) { SDL_Surface *new_surf; new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h, 8, 0, 0, 0, 0); @@ -589,7 +590,7 @@ TFB_DrawCanvas_Delete (TFB_Canvas canvas) log_add (log_Warning, "INTERNAL PANIC: Attempted" " to delete a NULL canvas!"); /* Should we actually die here? */ - } + } else { SDL_FreeSurface ((SDL_Surface *) canvas); @@ -597,11 +598,11 @@ TFB_DrawCanvas_Delete (TFB_Canvas canvas) } -TFB_Palette * +Color * TFB_DrawCanvas_ExtractPalette (TFB_Canvas canvas) { int i; - TFB_Palette *result; + Color *result; SDL_Surface *surf = (SDL_Surface *)canvas; @@ -610,7 +611,7 @@ TFB_DrawCanvas_ExtractPalette (TFB_Canvas canvas) return NULL; } - result = (TFB_Palette*) HMalloc (sizeof (TFB_Palette) * 256); + result = (Color *) HMalloc (sizeof (Color) * 256); for (i = 0; i < 256; ++i) { result[i].r = surf->format->palette->colors[i].r; @@ -650,7 +651,7 @@ TFB_DrawCanvas_IsPaletted (TFB_Canvas canvas) } void -TFB_DrawCanvas_SetPalette (TFB_Canvas target, TFB_Palette *palette) +TFB_DrawCanvas_SetPalette (TFB_Canvas target, Color *palette) { SDL_SetColors ((SDL_Surface *)target, (SDL_Color *)palette, 0, 256); } @@ -722,7 +723,8 @@ TFB_DrawCanvas_GetTransparentColor (TFB_Canvas canvas, int *r, int *g, int *b) } void -TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas, int r, int g, int b, BOOLEAN rleaccel) +TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas, int r, int g, int b, + BOOLEAN rleaccel) { Uint32 color; int flags = SDL_SRCCOLORKEY; diff --git a/sc2/src/libs/graphics/tfb_draw.h b/sc2/src/libs/graphics/tfb_draw.h index e682016a8..546681c64 100644 --- a/sc2/src/libs/graphics/tfb_draw.h +++ b/sc2/src/libs/graphics/tfb_draw.h @@ -32,14 +32,6 @@ typedef enum { TFB_GFX_NUMSCREENS } SCREEN; -typedef struct tfb_palette -{ - UBYTE r; - UBYTE g; - UBYTE b; - UBYTE unused; -} TFB_Palette; - #include "libs/graphics/gfx_common.h" #include "cmap.h" @@ -49,7 +41,7 @@ typedef struct tfb_image TFB_Canvas ScaledImg; TFB_Canvas MipmapImg; TFB_Canvas FilledImg; - TFB_Palette *Palette; + Color *Palette; int colormap_index; int colormap_version; HOT_SPOT NormalHs; @@ -57,7 +49,7 @@ typedef struct tfb_image HOT_SPOT last_scale_hs; int last_scale; int last_scale_type; - TFB_Palette last_fill; + Color last_fill; EXTENT extent; Mutex mutex; BOOLEAN dirty; @@ -87,15 +79,20 @@ typedef struct tfb_pixelformat // Drawing commands -void TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, int r, int g, int b, SCREEN dest); +void TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, int r, int g, int b, + SCREEN dest); void TFB_DrawScreen_Rect (RECT *rect, int r, int g, int b, SCREEN dest); -void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, TFB_ColorMap *cmap, SCREEN dest); +void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, + TFB_ColorMap *cmap, SCREEN dest); void TFB_DrawScreen_Copy (RECT *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_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, RECT *lpRect, SCREEN src); -void TFB_DrawScreen_SetMipmap (TFB_Image *img, TFB_Image *mmimg, int hotx, int hoty); +void TFB_DrawScreen_SetMipmap (TFB_Image *img, TFB_Image *mmimg, int hotx, + int hoty); void TFB_DrawScreen_DeleteImage (TFB_Image *img); void TFB_DrawScreen_DeleteData (void *); void TFB_DrawScreen_WaitForSignal (void); @@ -105,20 +102,27 @@ void TFB_DrawScreen_Callback (void (*callback) (void *arg), void *arg); TFB_Image *TFB_DrawImage_New (TFB_Canvas canvas); TFB_Image *TFB_DrawImage_CreateForScreen (int w, int h, BOOLEAN withalpha); TFB_Image *TFB_DrawImage_New_Rotated (TFB_Image *img, int angle); -void TFB_DrawImage_SetMipmap (TFB_Image *img, TFB_Image *mmimg, int hotx, int hoty); +void TFB_DrawImage_SetMipmap (TFB_Image *img, TFB_Image *mmimg, int hotx, + int hoty); void TFB_DrawImage_Delete (TFB_Image *image); void TFB_DrawImage_FixScaling (TFB_Image *image, int target, int type); -void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, int r, int g, int b, TFB_Image *dest); +void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, int r, int g, int b, + TFB_Image *dest); void TFB_DrawImage_Rect (RECT *rect, int r, int g, int b, TFB_Image *image); -void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, TFB_ColorMap *cmap, 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); +void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, + TFB_ColorMap *cmap, 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); -TFB_Canvas TFB_DrawCanvas_New_Paletted (int w, int h, TFB_Palette *palette, int transparent_index); -TFB_Canvas TFB_DrawCanvas_New_ScaleTarget (TFB_Canvas canvas, TFB_Canvas oldcanvas, int type, int last_type); +TFB_Canvas TFB_DrawCanvas_New_Paletted (int w, int h, Color *palette, + int transparent_index); +TFB_Canvas TFB_DrawCanvas_New_ScaleTarget (TFB_Canvas canvas, + TFB_Canvas oldcanvas, int type, int last_type); TFB_Canvas TFB_DrawCanvas_New_RotationTarget (TFB_Canvas src, int angle); TFB_Canvas TFB_DrawCanvas_ToScreenFormat (TFB_Canvas canvas); BOOLEAN TFB_DrawCanvas_IsPaletted (TFB_Canvas canvas); @@ -132,24 +136,32 @@ void TFB_DrawCanvas_Rescale_Trilinear (TFB_Canvas src, TFB_Canvas mipmap, void TFB_DrawCanvas_GetScaledExtent (TFB_Canvas src_canvas, HOT_SPOT* src_hs, TFB_Canvas src_mipmap, HOT_SPOT* mm_hs, int scale, int type, EXTENT *size, HOT_SPOT *hs); -void TFB_DrawCanvas_Rotate (TFB_Canvas src, TFB_Canvas dst, int angle, EXTENT size); +void TFB_DrawCanvas_Rotate (TFB_Canvas src, TFB_Canvas dst, int angle, + EXTENT size); void TFB_DrawCanvas_GetRotatedExtent (TFB_Canvas src, int angle, EXTENT *size); void TFB_DrawCanvas_GetExtent (TFB_Canvas canvas, EXTENT *size); void TFB_DrawCanvas_Delete (TFB_Canvas canvas); -void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, int r, int g, int b, TFB_Canvas dest); +void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, int r, int g, int b, + TFB_Canvas dest); void TFB_DrawCanvas_Rect (RECT *rect, int r, int g, int b, TFB_Canvas image); -void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, TFB_ColorMap *cmap, 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); +void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, + TFB_ColorMap *cmap, 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); +Color *TFB_DrawCanvas_ExtractPalette (TFB_Canvas canvas); +void TFB_DrawCanvas_SetPalette (TFB_Canvas target, Color *palette); int TFB_DrawCanvas_GetTransparentIndex (TFB_Canvas canvas); -void TFB_DrawCanvas_SetTransparentIndex (TFB_Canvas canvas, int i, BOOLEAN rleaccel); -BOOLEAN TFB_DrawCanvas_GetTransparentColor (TFB_Canvas canvas, int *r, int *g, int *b); -void TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas, int r, int g, int b, BOOLEAN rleaccel); +void TFB_DrawCanvas_SetTransparentIndex (TFB_Canvas canvas, int i, + BOOLEAN rleaccel); +BOOLEAN TFB_DrawCanvas_GetTransparentColor (TFB_Canvas canvas, + int *r, int *g, int *b); +void TFB_DrawCanvas_SetTransparentColor (TFB_Canvas canvas, + int r, int g, int b, BOOLEAN rleaccel); void TFB_DrawCanvas_CopyTransparencyInfo (TFB_Canvas src, TFB_Canvas dst); void TFB_DrawCanvas_Initialize (void); void TFB_DrawCanvas_Lock (TFB_Canvas canvas); @@ -157,8 +169,10 @@ void TFB_DrawCanvas_Unlock (TFB_Canvas canvas); void TFB_DrawCanvas_GetScreenFormat (TFB_PixelFormat *fmt); int TFB_DrawCanvas_GetStride (TFB_Canvas canvas); void *TFB_DrawCanvas_GetLine (TFB_Canvas canvas, int line); -void TFB_DrawCanvas_GetPixel (TFB_Canvas canvas, int x, int y, int *r, int *g, int *b); +void TFB_DrawCanvas_GetPixel (TFB_Canvas canvas, int x, int y, + int *r, int *g, int *b); TFB_Canvas TFB_GetScreenCanvas (SCREEN screen); #endif + diff --git a/sc2/src/libs/graphics/tfb_prim.c b/sc2/src/libs/graphics/tfb_prim.c index 917b28972..eb4c66d25 100644 --- a/sc2/src/libs/graphics/tfb_prim.c +++ b/sc2/src/libs/graphics/tfb_prim.c @@ -29,7 +29,7 @@ #include "libs/log.h" void -TFB_Prim_Point (POINT *p, TFB_Palette *color) +TFB_Prim_Point (POINT *p, Color color) { RECT r; @@ -38,13 +38,14 @@ TFB_Prim_Point (POINT *p, TFB_Palette *color) r.extent.width = r.extent.height = 1; if (_CurFramePtr->Type == SCREEN_DRAWABLE) - TFB_DrawScreen_Rect (&r, color->r, color->g, color->b, TFB_SCREEN_MAIN); + TFB_DrawScreen_Rect (&r, color.r, color.g, color.b, TFB_SCREEN_MAIN); else - TFB_DrawImage_Rect (&r, color->r, color->g, color->b, _CurFramePtr->image); + TFB_DrawImage_Rect (&r, color.r, color.g, color.b, + _CurFramePtr->image); } void -TFB_Prim_Rect (RECT *r, TFB_Palette *color) +TFB_Prim_Rect (RECT *r, Color color) { RECT arm; int gscale; @@ -69,7 +70,7 @@ TFB_Prim_Rect (RECT *r, TFB_Palette *color) } void -TFB_Prim_FillRect (RECT *r, TFB_Palette *color) +TFB_Prim_FillRect (RECT *r, Color color) { RECT rect; int gscale; @@ -93,13 +94,15 @@ TFB_Prim_FillRect (RECT *r, TFB_Palette *color) } if (_CurFramePtr->Type == SCREEN_DRAWABLE) - TFB_DrawScreen_Rect (&rect, color->r, color->g, color->b, TFB_SCREEN_MAIN); + TFB_DrawScreen_Rect (&rect, color.r, color.g, color.b, + TFB_SCREEN_MAIN); else - TFB_DrawImage_Rect (&rect, color->r, color->g, color->b, _CurFramePtr->image); + TFB_DrawImage_Rect (&rect, color.r, color.g, color.b, + _CurFramePtr->image); } void -TFB_Prim_Line (LINE *line, TFB_Palette *color) +TFB_Prim_Line (LINE *line, Color color) { int x1, y1, x2, y2; @@ -109,9 +112,11 @@ TFB_Prim_Line (LINE *line, TFB_Palette *color) y2=line->second.y - _CurFramePtr->HotSpot.y; if (_CurFramePtr->Type == SCREEN_DRAWABLE) - TFB_DrawScreen_Line (x1, y1, x2, y2, color->r, color->g, color->b, TFB_SCREEN_MAIN); + TFB_DrawScreen_Line (x1, y1, x2, y2, color.r, color.g, color.b, + TFB_SCREEN_MAIN); else - TFB_DrawImage_Line (x1, y1, x2, y2, color->r, color->g, color->b, _CurFramePtr->image); + TFB_DrawImage_Line (x1, y1, x2, y2, color.r, color.g, color.b, + _CurFramePtr->image); } void @@ -164,7 +169,7 @@ TFB_Prim_Stamp (STAMP *stmp) } void -TFB_Prim_StampFill (STAMP *stmp, TFB_Palette *color) +TFB_Prim_StampFill (STAMP *stmp, Color color) { int x, y; FRAME SrcFramePtr; @@ -194,9 +199,9 @@ TFB_Prim_StampFill (STAMP *stmp, TFB_Palette *color) x = stmp->origin.x - _CurFramePtr->HotSpot.x; y = stmp->origin.y - _CurFramePtr->HotSpot.y; - r = color->r; - g = color->g; - b = color->b; + r = color.r; + g = color.g; + b = color.b; UnlockMutex (img->mutex); diff --git a/sc2/src/libs/graphics/tfb_prim.h b/sc2/src/libs/graphics/tfb_prim.h index d593b9cb8..1f2262d0e 100644 --- a/sc2/src/libs/graphics/tfb_prim.h +++ b/sc2/src/libs/graphics/tfb_prim.h @@ -20,10 +20,11 @@ #include "tfb_draw.h" -void TFB_Prim_Line (LINE *line, TFB_Palette *color); -void TFB_Prim_Point (POINT *p, TFB_Palette *color); -void TFB_Prim_Rect (RECT *r, TFB_Palette *color); -void TFB_Prim_FillRect (RECT *r, TFB_Palette *color); +void TFB_Prim_Line (LINE *line, Color color); +void TFB_Prim_Point (POINT *p, Color color); +void TFB_Prim_Rect (RECT *r, Color color); +void TFB_Prim_FillRect (RECT *r, Color color); void TFB_Prim_Stamp (STAMP *stamp); -void TFB_Prim_StampFill (STAMP *stamp, TFB_Palette *color); -void TFB_Prim_FontChar (POINT *origin, TFB_Char *, TFB_Image *backing); +void TFB_Prim_StampFill (STAMP *stamp, Color color); +void TFB_Prim_FontChar (POINT *origin, TFB_Char *fontChar, + TFB_Image *backing); diff --git a/sc2/src/libs/graphics/widgets.c b/sc2/src/libs/graphics/widgets.c index 23cbda817..0c444bc80 100644 --- a/sc2/src/libs/graphics/widgets.c +++ b/sc2/src/libs/graphics/widgets.c @@ -34,17 +34,20 @@ WIDGET *widget_focus = NULL; #define WIDGET_DIALOG_TEXT_COLOR \ BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) -static COLOR win_bg_clr = BUILD_COLOR (MAKE_RGB15 (0x18, 0x18, 0x1F), 0x00); -static COLOR win_medium_clr = BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x18), 0x00); -static COLOR win_dark_clr = BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x10), 0x00); +static Color win_bg_clr = + BUILD_COLOR (MAKE_RGB15_INIT (0x18, 0x18, 0x1F), 0x00); +static Color win_medium_clr = + BUILD_COLOR (MAKE_RGB15_INIT (0x10, 0x10, 0x18), 0x00); +static Color win_dark_clr = + BUILD_COLOR (MAKE_RGB15_INIT (0x08, 0x08, 0x10), 0x00); static FONT cur_font; void -DrawShadowedBox (RECT *r, COLOR bg, COLOR dark, COLOR medium) +DrawShadowedBox (RECT *r, Color bg, Color dark, Color medium) { RECT t; - COLOR oldcolor; + Color oldcolor; BatchGraphics (); @@ -84,7 +87,7 @@ DrawShadowedBox (RECT *r, COLOR bg, COLOR dark, COLOR medium) void DrawLabelAsWindow (WIDGET_LABEL *label, RECT *windowRect) { - COLOR oldfg = SetContextForeGroundColor (WIDGET_DIALOG_TEXT_COLOR); + Color oldfg = SetContextForeGroundColor (WIDGET_DIALOG_TEXT_COLOR); FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); RECT r; @@ -144,7 +147,7 @@ DrawLabelAsWindow (WIDGET_LABEL *label, RECT *windowRect) } void -Widget_SetWindowColors (COLOR bg, COLOR dark, COLOR medium) +Widget_SetWindowColors (Color bg, Color dark, Color medium) { win_bg_clr = bg; win_dark_clr = dark; @@ -165,7 +168,7 @@ Widget_DrawToolTips (int numlines, const char **tips) RECT r; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); - COLOR oldtext = SetContextForeGroundColor (WIDGET_INACTIVE_SELECTED_COLOR); + Color oldtext = SetContextForeGroundColor (WIDGET_INACTIVE_SELECTED_COLOR); TEXT t; int i; @@ -199,8 +202,8 @@ void Widget_DrawMenuScreen (WIDGET *_self, int x, int y) { RECT r; - COLOR title, oldtext; - COLOR inactive, default_color, selected; + Color title, oldtext; + Color inactive, default_color, selected; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -265,8 +268,8 @@ void Widget_DrawChoice (WIDGET *_self, int x, int y) { WIDGET_CHOICE *self = (WIDGET_CHOICE *)_self; - COLOR oldtext; - COLOR inactive, default_color, selected; + Color oldtext; + Color inactive, default_color, selected; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -299,7 +302,8 @@ Widget_DrawChoice (WIDGET *_self, int x, int y) t.align = ALIGN_CENTER; for (i = 0; i < self->numopts; i++) { - t.baseline.x = home_x + ((i % 3) * (ScreenWidth / (self->maxcolumns + 1))); + t.baseline.x = home_x + ((i % 3) * + (ScreenWidth / (self->maxcolumns + 1))); t.baseline.y = home_y + (8 * (i / 3)); t.pStr = self->options[i].optname; if ((widget_focus == _self) && @@ -307,7 +311,7 @@ Widget_DrawChoice (WIDGET *_self, int x, int y) { SetContextForeGroundColor (selected); Widget_DrawToolTips (3, self->options[i].tooltip); - } + } else if (i == self->selected) { SetContextForeGroundColor (default_color); @@ -328,8 +332,8 @@ void Widget_DrawButton (WIDGET *_self, int x, int y) { WIDGET_BUTTON *self = (WIDGET_BUTTON *)_self; - COLOR oldtext; - COLOR inactive, selected; + Color oldtext; + Color inactive, selected; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -366,7 +370,7 @@ void Widget_DrawLabel (WIDGET *_self, int x, int y) { WIDGET_LABEL *self = (WIDGET_LABEL *)_self; - COLOR oldtext = SetContextForeGroundColor (WIDGET_INACTIVE_SELECTED_COLOR); + Color oldtext = SetContextForeGroundColor (WIDGET_INACTIVE_SELECTED_COLOR); FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -397,8 +401,8 @@ void Widget_DrawSlider(WIDGET *_self, int x, int y) { WIDGET_SLIDER *self = (WIDGET_SLIDER *)_self; - COLOR oldtext; - COLOR inactive, default_color, selected; + Color oldtext; + Color inactive, default_color, selected; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -470,8 +474,8 @@ void Widget_DrawTextEntry (WIDGET *_self, int x, int y) { WIDGET_TEXTENTRY *self = (WIDGET_TEXTENTRY *)_self; - COLOR oldtext; - COLOR inactive, default_color, selected; + Color oldtext; + Color inactive, default_color, selected; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -607,8 +611,8 @@ void Widget_DrawControlEntry (WIDGET *_self, int x, int y) { WIDGET_CONTROLENTRY *self = (WIDGET_CONTROLENTRY *)_self; - COLOR oldtext; - COLOR inactive, default_color, selected; + Color oldtext; + Color inactive, default_color, selected; FONT oldfont = 0; FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; diff --git a/sc2/src/libs/graphics/widgets.h b/sc2/src/libs/graphics/widgets.h index 640bdd47d..40859d46d 100644 --- a/sc2/src/libs/graphics/widgets.h +++ b/sc2/src/libs/graphics/widgets.h @@ -175,9 +175,9 @@ typedef struct _widget_controlentry { char controlname[2][WIDGET_CONTROLENTRY_WIDTH]; } WIDGET_CONTROLENTRY; -void DrawShadowedBox (RECT *r, COLOR bg, COLOR dark, COLOR medium); +void DrawShadowedBox (RECT *r, Color bg, Color dark, Color medium); void DrawLabelAsWindow (WIDGET_LABEL *label, RECT *windowRect); -void Widget_SetWindowColors (COLOR bg, COLOR dark, COLOR medium); +void Widget_SetWindowColors (Color bg, Color dark, Color medium); FONT Widget_SetFont (FONT newFont); diff --git a/sc2/src/uqm/cnctdlg.c b/sc2/src/uqm/cnctdlg.c index 5b92019c1..1084ba6ea 100644 --- a/sc2/src/uqm/cnctdlg.c +++ b/sc2/src/uqm/cnctdlg.c @@ -94,8 +94,8 @@ static void MCD_DrawButton (WIDGET *_self, int x, int y) { WIDGET_BUTTON *self = (WIDGET_BUTTON *)_self; - COLOR oldtext; - COLOR inactive, selected; + Color oldtext; + Color inactive, selected; FONT oldfont = SetContextFont (StarConFont); FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -127,8 +127,8 @@ static void MCD_DrawSlider (WIDGET *_self, int x, int y) { WIDGET_SLIDER *self = (WIDGET_SLIDER *)_self; - COLOR oldtext; - COLOR default_color, selected; + Color oldtext; + Color default_color, selected; FONT oldfont = SetContextFont (PlayerFont); FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; @@ -177,8 +177,8 @@ void MCD_DrawTextEntry (WIDGET *_self, int x, int y) { WIDGET_TEXTENTRY *self = (WIDGET_TEXTENTRY *)_self; - COLOR oldtext; - COLOR inactive, default_color, selected; + Color oldtext; + Color inactive, default_color, selected; FONT oldfont = SetContextFont (PlayerFont); FRAME oldFontEffect = SetContextFontEffect (NULL); TEXT t; diff --git a/sc2/src/uqm/colors.h b/sc2/src/uqm/colors.h index 68051ae0e..eeb6dda16 100644 --- a/sc2/src/uqm/colors.h +++ b/sc2/src/uqm/colors.h @@ -16,6 +16,12 @@ #ifndef _COLORS_H #define _COLORS_H +// To be used as an indicator that the actual value of the color does not +// matter, for instance in structure initialisations for fields which +// are irrelevant in the context. +#define UNDEFINED_COLOR \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) + #if 0 #define DEFAULT_COLOR_00 \ BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00) @@ -230,46 +236,46 @@ // Pulsating color of the string "AUTO-PILOT" #define AUTOPILOT_COLOR_CYCLE_TABLE \ { \ - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x14, 0x18), 0x5B), \ - BUILD_COLOR (MAKE_RGB15 (0x06, 0x10, 0x16), 0x5C), \ - BUILD_COLOR (MAKE_RGB15 (0x03, 0x0E, 0x14), 0x5D), \ - BUILD_COLOR (MAKE_RGB15 (0x02, 0x0C, 0x11), 0x5E), \ - BUILD_COLOR (MAKE_RGB15 (0x01, 0x0B, 0x0F), 0x5F), \ - BUILD_COLOR (MAKE_RGB15 (0x01, 0x09, 0x0D), 0x60), \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x07, 0x0B), 0x61), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0A, 0x14, 0x18), 0x5B), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x06, 0x10, 0x16), 0x5C), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x03, 0x0E, 0x14), 0x5D), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x02, 0x0C, 0x11), 0x5E), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x01, 0x0B, 0x0F), 0x5F), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x01, 0x09, 0x0D), 0x60), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x07, 0x0B), 0x61), \ } // Colors for the fuel in the fuel tanks as they are filled up, // when viewed from the shipyard. #define FUEL_COLOR_TABLE \ { \ - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2D), \ - BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C), \ - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2B), \ - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2A), \ - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7F), \ - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7E), \ - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7D), \ - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7C), \ - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7B), \ - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A), \ - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x18, 0x00), 0x79), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x00), 0x2D), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x13, 0x00, 0x00), 0x2C), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x17, 0x00, 0x00), 0x2B), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x00, 0x00), 0x2A), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x03, 0x00), 0x7F), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x07, 0x00), 0x7E), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0A, 0x00), 0x7D), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0E, 0x00), 0x7C), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x11, 0x00), 0x7B), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x15, 0x00), 0x7A), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x18, 0x00), 0x79), \ } // Colors for the crew in the crew pods as they are filled up, // when viewed from the shipyard, when using PC fonts. #define PC_CREW_COLOR_TABLE \ { \ - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1E, 0x09), 0x65), \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x1E, 0x00), 0x65), \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x1B, 0x00), 0x65), \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x18, 0x00), 0x65), \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x15, 0x00), 0x65), \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x12, 0x00), 0x65), \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x10, 0x00), 0x65), \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x0D, 0x00), 0x65), \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x0A, 0x00), 0x65), \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x07, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0A, 0x1E, 0x09), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x1E, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x1B, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x18, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x15, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x12, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x10, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x0D, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x0A, 0x00), 0x65), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x07, 0x00), 0x65), \ } // Colors for the crew in the crew pods as they are filled up, @@ -281,16 +287,16 @@ // when viewed from the shipyard. #define STORAGE_BAY_COLOR_TABLE \ { \ - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F), \ - BUILD_COLOR (MAKE_RGB15 (0x1C, 0x1C, 0x1C), 0x11), \ - BUILD_COLOR (MAKE_RGB15 (0x18, 0x18, 0x18), 0x13), \ - BUILD_COLOR (MAKE_RGB15 (0x15, 0x15, 0x15), 0x15), \ - BUILD_COLOR (MAKE_RGB15 (0x12, 0x12, 0x12), 0x17), \ - BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19), \ - BUILD_COLOR (MAKE_RGB15 (0x0D, 0x0D, 0x0D), 0x1B), \ - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x1D), \ - BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F), \ - BUILD_COLOR (MAKE_RGB15 (0x05, 0x05, 0x05), 0x21), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1F, 0x1F), 0x0F), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1C, 0x1C, 0x1C), 0x11), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x18, 0x18, 0x18), 0x13), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x15, 0x15, 0x15), 0x15), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x12, 0x12, 0x12), 0x17), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x10, 0x10, 0x10), 0x19), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0D, 0x0D, 0x0D), 0x1B), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0A, 0x0A, 0x0A), 0x1D), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x08, 0x08, 0x08), 0x1F), \ + BUILD_COLOR (MAKE_RGB15_INIT (0x05, 0x05, 0x05), 0x21), \ } // Color of the storage bay indicator, as shown beneath the flagship, @@ -335,5 +341,14 @@ BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0x00) +// Temporary, until we can use C'99 features: +#define BLACK_COLOR_INIT \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x00), 0x00) +#define WHITE_COLOR_INIT \ + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1F, 0x1F), 0x0F) +#define UNDEFINED_COLOR_INIT \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x00), 0x00) + + #endif /* _COLORS_H */ diff --git a/sc2/src/uqm/comm.c b/sc2/src/uqm/comm.c index c6618824c..385880179 100644 --- a/sc2/src/uqm/comm.c +++ b/sc2/src/uqm/comm.c @@ -1214,7 +1214,7 @@ HailAlien (void) ENCOUNTER_STATE ES; FONT PlayerFont, OldFont; MUSIC_REF SongRef = 0; - COLOR TextBack; + Color TextBack; pCurInputState = &ES; memset (pCurInputState, 0, sizeof (*pCurInputState)); diff --git a/sc2/src/uqm/comm/arilou/arilouc.c b/sc2/src/uqm/comm/arilou/arilouc.c index 12e81a8b2..0bb043429 100644 --- a/sc2/src/uqm/comm/arilou/arilouc.c +++ b/sc2/src/uqm/comm/arilou/arilouc.c @@ -30,8 +30,8 @@ static LOCDATA arilou_desc = NULL, /* uninit_encounter_func */ ARILOU_PMAP_ANIM, /* AlienFrame */ ARILOU_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/blackur/blackurc.c b/sc2/src/uqm/comm/blackur/blackurc.c index 413551ebc..7070a9365 100644 --- a/sc2/src/uqm/comm/blackur/blackurc.c +++ b/sc2/src/uqm/comm/blackur/blackurc.c @@ -27,8 +27,8 @@ static LOCDATA blackurq_desc = NULL, /* uninit_encounter_func */ BLACKURQ_PMAP_ANIM, /* AlienFrame */ BLACKURQ_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/chmmr/chmmrc.c b/sc2/src/uqm/comm/chmmr/chmmrc.c index 4121d4108..80b5c61de 100644 --- a/sc2/src/uqm/comm/chmmr/chmmrc.c +++ b/sc2/src/uqm/comm/chmmr/chmmrc.c @@ -32,8 +32,8 @@ static LOCDATA chmmr_desc = NULL, /* uninit_encounter_func */ CHMMR_PMAP_ANIM, /* AlienFrame */ CHMMR_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/comandr/comandr.c b/sc2/src/uqm/comm/comandr/comandr.c index 3018edf64..39c14f95c 100644 --- a/sc2/src/uqm/comm/comandr/comandr.c +++ b/sc2/src/uqm/comm/comandr/comandr.c @@ -32,8 +32,8 @@ static LOCDATA commander_desc = NULL, /* uninit_encounter_func */ COMMANDER_PMAP_ANIM, /* AlienFrame */ COMMANDER_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/druuge/druugec.c b/sc2/src/uqm/comm/druuge/druugec.c index 0251f8671..4aa5959f6 100644 --- a/sc2/src/uqm/comm/druuge/druugec.c +++ b/sc2/src/uqm/comm/druuge/druugec.c @@ -33,8 +33,8 @@ static LOCDATA druuge_desc = NULL, /* uninit_encounter_func */ DRUUGE_PMAP_ANIM, /* AlienFrame */ DRUUGE_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/ilwrath/ilwrathc.c b/sc2/src/uqm/comm/ilwrath/ilwrathc.c index 3f07c3047..6e9f3909e 100644 --- a/sc2/src/uqm/comm/ilwrath/ilwrathc.c +++ b/sc2/src/uqm/comm/ilwrath/ilwrathc.c @@ -30,8 +30,8 @@ static LOCDATA ilwrath_desc = NULL, /* uninit_encounter_func */ ILWRATH_PMAP_ANIM, /* AlienFrame */ ILWRATH_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/melnorm/melnorm.c b/sc2/src/uqm/comm/melnorm/melnorm.c index b60bfa8d8..73dd23c8d 100644 --- a/sc2/src/uqm/comm/melnorm/melnorm.c +++ b/sc2/src/uqm/comm/melnorm/melnorm.c @@ -48,8 +48,8 @@ static LOCDATA melnorme_desc = NULL, /* uninit_encounter_func */ MELNORME_PMAP_ANIM, /* AlienFrame */ MELNORME_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/mycon/myconc.c b/sc2/src/uqm/comm/mycon/myconc.c index 640c96cb7..326bb1253 100644 --- a/sc2/src/uqm/comm/mycon/myconc.c +++ b/sc2/src/uqm/comm/mycon/myconc.c @@ -31,8 +31,8 @@ static LOCDATA mycon_desc = NULL, /* uninit_encounter_func */ MYCON_PMAP_ANIM, /* AlienFrame */ MYCON_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/orz/orzc.c b/sc2/src/uqm/comm/orz/orzc.c index 43a0526c4..9d1a313eb 100644 --- a/sc2/src/uqm/comm/orz/orzc.c +++ b/sc2/src/uqm/comm/orz/orzc.c @@ -30,8 +30,8 @@ static LOCDATA orz_desc = NULL, /* uninit_encounter_func */ ORZ_PMAP_ANIM, /* AlienFrame */ ORZ_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/pkunk/pkunkc.c b/sc2/src/uqm/comm/pkunk/pkunkc.c index be56c8662..55c5e9f2a 100644 --- a/sc2/src/uqm/comm/pkunk/pkunkc.c +++ b/sc2/src/uqm/comm/pkunk/pkunkc.c @@ -31,8 +31,8 @@ static LOCDATA pkunk_desc = NULL, /* uninit_encounter_func */ PKUNK_PMAP_ANIM, /* AlienFrame */ PKUNK_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/rebel/rebel.c b/sc2/src/uqm/comm/rebel/rebel.c index 448400e53..a26a03260 100644 --- a/sc2/src/uqm/comm/rebel/rebel.c +++ b/sc2/src/uqm/comm/rebel/rebel.c @@ -30,8 +30,8 @@ static LOCDATA yehat_desc = NULL, /* uninit_encounter_func */ YEHAT_PMAP_ANIM, /* AlienFrame */ YEHAT_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* (SIS_TEXT_WIDTH - 16) * 2 / 3, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/shofixt/shofixt.c b/sc2/src/uqm/comm/shofixt/shofixt.c index 8aa9651ff..7b286f34c 100644 --- a/sc2/src/uqm/comm/shofixt/shofixt.c +++ b/sc2/src/uqm/comm/shofixt/shofixt.c @@ -30,8 +30,8 @@ static LOCDATA shofixti_desc = NULL, /* uninit_encounter_func */ SHOFIXTI_PMAP_ANIM, /* AlienFrame */ SHOFIXTI_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/slyhome/slyhome.c b/sc2/src/uqm/comm/slyhome/slyhome.c index a6bf1949f..85954947b 100644 --- a/sc2/src/uqm/comm/slyhome/slyhome.c +++ b/sc2/src/uqm/comm/slyhome/slyhome.c @@ -30,8 +30,8 @@ static LOCDATA slylandro_desc = NULL, /* uninit_encounter_func */ SLYLANDRO_PMAP_ANIM, /* AlienFrame */ SLYLANDRO_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/slyland/slyland.c b/sc2/src/uqm/comm/slyland/slyland.c index 4d33b03fe..2fef97fbb 100644 --- a/sc2/src/uqm/comm/slyland/slyland.c +++ b/sc2/src/uqm/comm/slyland/slyland.c @@ -32,8 +32,8 @@ static LOCDATA slylandro_desc = NULL, /* uninit_encounter_func */ SLYLAND_PMAP_ANIM, /* AlienFrame */ SLYLAND_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/spahome/spahome.c b/sc2/src/uqm/comm/spahome/spahome.c index 8dce78e0f..e503104da 100644 --- a/sc2/src/uqm/comm/spahome/spahome.c +++ b/sc2/src/uqm/comm/spahome/spahome.c @@ -31,8 +31,8 @@ static LOCDATA spahome_desc = NULL, /* uninit_encounter_func */ SPATHI_HOME_PMAP_ANIM, /* AlienFrame */ SPATHI_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/spathi/spathic.c b/sc2/src/uqm/comm/spathi/spathic.c index f59559a38..c34605f2a 100644 --- a/sc2/src/uqm/comm/spathi/spathic.c +++ b/sc2/src/uqm/comm/spathi/spathic.c @@ -30,8 +30,8 @@ static LOCDATA spathi_desc = NULL, /* uninit_encounter_func */ SPATHI_PMAP_ANIM, /* AlienFrame */ SPATHI_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/starbas/starbas.c b/sc2/src/uqm/comm/starbas/starbas.c index 6d0bb1f42..a084516ad 100644 --- a/sc2/src/uqm/comm/starbas/starbas.c +++ b/sc2/src/uqm/comm/starbas/starbas.c @@ -42,8 +42,8 @@ static LOCDATA commander_desc = NULL, /* uninit_encounter_func */ COMMANDER_PMAP_ANIM, /* AlienFrame */ COMMANDER_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/supox/supoxc.c b/sc2/src/uqm/comm/supox/supoxc.c index 25e3b8b1a..abad51c30 100644 --- a/sc2/src/uqm/comm/supox/supoxc.c +++ b/sc2/src/uqm/comm/supox/supoxc.c @@ -30,8 +30,8 @@ static LOCDATA supox_desc = NULL, /* uninit_encounter_func */ SUPOX_PMAP_ANIM, /* AlienFrame */ SUPOX_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/syreen/syreenc.c b/sc2/src/uqm/comm/syreen/syreenc.c index 9518689eb..332732bd2 100644 --- a/sc2/src/uqm/comm/syreen/syreenc.c +++ b/sc2/src/uqm/comm/syreen/syreenc.c @@ -31,8 +31,8 @@ static LOCDATA syreen_desc = NULL, /* uninit_encounter_func */ SYREEN_PMAP_ANIM, /* AlienFrame */ SYREEN_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/talkpet/talkpet.c b/sc2/src/uqm/comm/talkpet/talkpet.c index 8145abb32..aa34eefb7 100644 --- a/sc2/src/uqm/comm/talkpet/talkpet.c +++ b/sc2/src/uqm/comm/talkpet/talkpet.c @@ -33,8 +33,8 @@ static LOCDATA talkpet_desc = NULL, /* uninit_encounter_func */ TALKING_PET_PMAP_ANIM, /* AlienFrame */ TALKING_PET_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/thradd/thraddc.c b/sc2/src/uqm/comm/thradd/thraddc.c index 920dd54ed..80900633d 100644 --- a/sc2/src/uqm/comm/thradd/thraddc.c +++ b/sc2/src/uqm/comm/thradd/thraddc.c @@ -31,8 +31,8 @@ static LOCDATA thradd_desc = NULL, /* uninit_encounter_func */ THRADD_PMAP_ANIM, /* AlienFrame */ THRADD_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/umgah/umgahc.c b/sc2/src/uqm/comm/umgah/umgahc.c index c357384a8..ea46459e6 100644 --- a/sc2/src/uqm/comm/umgah/umgahc.c +++ b/sc2/src/uqm/comm/umgah/umgahc.c @@ -30,8 +30,8 @@ static LOCDATA umgah_desc = NULL, /* uninit_encounter_func */ UMGAH_PMAP_ANIM, /* AlienFrame */ UMGAH_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/urquan/urquanc.c b/sc2/src/uqm/comm/urquan/urquanc.c index 5dc683228..7fa39c10d 100644 --- a/sc2/src/uqm/comm/urquan/urquanc.c +++ b/sc2/src/uqm/comm/urquan/urquanc.c @@ -27,8 +27,8 @@ static LOCDATA urquan_desc = NULL, /* uninit_encounter_func */ URQUAN_PMAP_ANIM, /* AlienFrame */ URQUAN_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/utwig/utwigc.c b/sc2/src/uqm/comm/utwig/utwigc.c index a167e8a36..6ce4065fc 100644 --- a/sc2/src/uqm/comm/utwig/utwigc.c +++ b/sc2/src/uqm/comm/utwig/utwigc.c @@ -31,8 +31,8 @@ static LOCDATA utwig_desc = NULL, /* uninit_encounter_func */ UTWIG_PMAP_ANIM, /* AlienFrame */ UTWIG_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* SIS_TEXT_WIDTH - 16, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/vux/vuxc.c b/sc2/src/uqm/comm/vux/vuxc.c index 559bd8e9d..ba660931f 100644 --- a/sc2/src/uqm/comm/vux/vuxc.c +++ b/sc2/src/uqm/comm/vux/vuxc.c @@ -27,8 +27,8 @@ static LOCDATA vux_desc = NULL, /* uninit_encounter_func */ VUX_PMAP_ANIM, /* AlienFrame */ VUX_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* (SIS_TEXT_WIDTH - 16) >> 1, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/yehat/yehatc.c b/sc2/src/uqm/comm/yehat/yehatc.c index 1ce341130..645326bdd 100644 --- a/sc2/src/uqm/comm/yehat/yehatc.c +++ b/sc2/src/uqm/comm/yehat/yehatc.c @@ -32,8 +32,8 @@ static LOCDATA yehat_desc = NULL, /* uninit_encounter_func */ YEHAT_PMAP_ANIM, /* AlienFrame */ YEHAT_FONT, /* AlienFont */ - WHITE_COLOR, /* AlienTextFColor */ - BLACK_COLOR, /* AlienTextBColor */ + WHITE_COLOR_INIT, /* AlienTextFColor */ + BLACK_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* (SIS_TEXT_WIDTH - 16) * 2 / 3, */ /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/comm/zoqfot/zoqfotc.c b/sc2/src/uqm/comm/zoqfot/zoqfotc.c index 999ac2f9f..123cd7977 100644 --- a/sc2/src/uqm/comm/zoqfot/zoqfotc.c +++ b/sc2/src/uqm/comm/zoqfot/zoqfotc.c @@ -47,8 +47,8 @@ static LOCDATA zoqfot_desc = NULL, /* uninit_encounter_func */ ZOQFOTPIK_PMAP_ANIM, /* AlienFrame */ ZOQFOTPIK_FONT, /* AlienFont */ - 0, /* AlienTextFColor */ - 0, /* AlienTextBColor */ + UNDEFINED_COLOR_INIT, /* AlienTextFColor */ + UNDEFINED_COLOR_INIT, /* AlienTextBColor */ {0, 0}, /* AlienTextBaseline */ 0, /* AlienTextWidth */ ALIGN_CENTER, /* AlienTextAlign */ diff --git a/sc2/src/uqm/confirm.c b/sc2/src/uqm/confirm.c index 48ec35966..c72e8337b 100644 --- a/sc2/src/uqm/confirm.c +++ b/sc2/src/uqm/confirm.c @@ -37,7 +37,7 @@ static void DrawConfirmationWindow (BOOLEAN answer) { - COLOR oldfg = SetContextForeGroundColor (MENU_TEXT_COLOR); + Color oldfg = SetContextForeGroundColor (MENU_TEXT_COLOR); FONT oldfont = SetContextFont (StarConFont); FRAME oldFontEffect = SetContextFontEffect (NULL); RECT r; diff --git a/sc2/src/uqm/credits.c b/sc2/src/uqm/credits.c index fd2cf6a6d..dfe2dac18 100644 --- a/sc2/src/uqm/credits.c +++ b/sc2/src/uqm/credits.c @@ -62,7 +62,7 @@ static FONT_SIZE_DEF CreditsFont[] = static FRAME -Credits_MakeTextFrame (int w, int h, COLOR TransColor) +Credits_MakeTextFrame (int w, int h, Color TransColor) { FRAME OldFrame; FRAME f; @@ -102,7 +102,7 @@ ParseTextLines (TEXT *Lines, int MaxLines, char *Buffer) static FRAME Credits_RenderTextFrame (CONTEXT TempContext, int *istr, int dir, - COLOR BackColor, COLOR ForeColor) + Color BackColor, Color ForeColor) { FRAME f; CONTEXT OldContext; @@ -294,7 +294,7 @@ credit_roll_task (void *data) CONTEXT DrawContext; CONTEXT LocalContext; FRAME Frame; - COLOR TransColor, TextFore, TextBack; + Color TransColor, TextFore, TextBack; STAMP TaskStamp; STAMP s; FRAME cf[CREDIT_FRAMES]; // preped text frames diff --git a/sc2/src/uqm/element.h b/sc2/src/uqm/element.h index eacd28174..54ba90577 100644 --- a/sc2/src/uqm/element.h +++ b/sc2/src/uqm/element.h @@ -191,7 +191,7 @@ extern PRIMITIVE DisplayArray[MAX_DISPLAY_PRIMS]; #define OBJECT_CLOAKED(eptr) \ (GetPrimType (&GLOBAL (DisplayArray[(eptr)->PrimIndex])) >= NUM_PRIMS \ || (GetPrimType (&GLOBAL (DisplayArray[(eptr)->PrimIndex])) == STAMPFILL_PRIM \ - && GetPrimColor (&GLOBAL (DisplayArray[(eptr)->PrimIndex])) == BLACK_COLOR)) + && sameColor (GetPrimColor (&GLOBAL (DisplayArray[(eptr)->PrimIndex])), BLACK_COLOR))) #define UNDEFINED_LEVEL 0 extern HELEMENT AllocElement (void); diff --git a/sc2/src/uqm/encount.c b/sc2/src/uqm/encount.c index 43011e0fc..95250abc6 100644 --- a/sc2/src/uqm/encount.c +++ b/sc2/src/uqm/encount.c @@ -352,15 +352,15 @@ DrawFadeText (const UNICODE *str1, const UNICODE *str2, BOOLEAN fade_in, SIZE i; DWORD TimeIn; TEXT t1, t2; - static const COLOR fade_cycle[] = + static const Color fade_cycle[] = { - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x1D), - BUILD_COLOR (MAKE_RGB15 (0x09, 0x09, 0x09), 0x1E), - BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F), - BUILD_COLOR (MAKE_RGB15 (0x06, 0x06, 0x06), 0x20), - BUILD_COLOR (MAKE_RGB15 (0x05, 0x05, 0x05), 0x21), - BUILD_COLOR (MAKE_RGB15 (0x04, 0x04, 0x04), 0x22), - BUILD_COLOR (MAKE_RGB15 (0x03, 0x03, 0x03), 0x23), + BUILD_COLOR (MAKE_RGB15_INIT (0x0A, 0x0A, 0x0A), 0x1D), + BUILD_COLOR (MAKE_RGB15_INIT (0x09, 0x09, 0x09), 0x1E), + BUILD_COLOR (MAKE_RGB15_INIT (0x08, 0x08, 0x08), 0x1F), + BUILD_COLOR (MAKE_RGB15_INIT (0x06, 0x06, 0x06), 0x20), + BUILD_COLOR (MAKE_RGB15_INIT (0x05, 0x05, 0x05), 0x21), + BUILD_COLOR (MAKE_RGB15_INIT (0x04, 0x04, 0x04), 0x22), + BUILD_COLOR (MAKE_RGB15_INIT (0x03, 0x03, 0x03), 0x23), }; #define NUM_FADES (sizeof (fade_cycle) / sizeof (fade_cycle[0])) @@ -449,18 +449,18 @@ UninitEncounter (void) UNICODE buf[80]; HSHIPFRAG hStarShip; SHIP_FRAGMENT *FragPtr; - static const COLOR fade_ship_cycle[] = + static const Color fade_ship_cycle[] = { - BUILD_COLOR (MAKE_RGB15 (0x07, 0x00, 0x00), 0x2F), - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2D), - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2B), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x27), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x14, 0x14), 0x25), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x14, 0x14), 0x25), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x27), - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2A), - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2B), + BUILD_COLOR (MAKE_RGB15_INIT (0x07, 0x00, 0x00), 0x2F), + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x00), 0x2D), + BUILD_COLOR (MAKE_RGB15_INIT (0x17, 0x00, 0x00), 0x2B), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0A, 0x0A), 0x27), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x14, 0x14), 0x25), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1F, 0x1F), 0x0F), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x14, 0x14), 0x25), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0A, 0x0A), 0x27), + BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x00, 0x00), 0x2A), + BUILD_COLOR (MAKE_RGB15_INIT (0x17, 0x00, 0x00), 0x2B), }; #define NUM_SHIP_FADES (sizeof (fade_ship_cycle) / \ sizeof (fade_ship_cycle[0])) diff --git a/sc2/src/uqm/gameopt.c b/sc2/src/uqm/gameopt.c index 188250aaf..f6d7a7ef9 100644 --- a/sc2/src/uqm/gameopt.c +++ b/sc2/src/uqm/gameopt.c @@ -196,7 +196,7 @@ DrawDescriptionString (MENU_STATE *pMS, UNICODE *Str, COUNT CursorPos, { RECT r; TEXT lf; - COLOR BackGround, ForeGround; + Color BackGround, ForeGround; FONT Font; LockMutex (GraphicsLock); @@ -535,17 +535,17 @@ DrawCargo (COUNT redraw_state) { TEXT t; UNICODE buf[40]; - static const COLOR cargo_color[] = + static const Color cargo_color[] = { - BUILD_COLOR (MAKE_RGB15 (0x02, 0x0E, 0x13), 0x00), - BUILD_COLOR (MAKE_RGB15 (0x19, 0x00, 0x00), 0x00), - BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x00), - BUILD_COLOR (MAKE_RGB15 (0x03, 0x05, 0x1E), 0x00), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x18, 0x00), 0x00), - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x1B, 0x00), 0x00), - BUILD_COLOR (MAKE_RGB15 (0x1E, 0x0D, 0x00), 0x00), - BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x14), 0x05), - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x19), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x02, 0x0E, 0x13), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x19, 0x00, 0x00), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x10, 0x10, 0x10), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x03, 0x05, 0x1E), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x18, 0x00), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x1B, 0x00), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x1E, 0x0D, 0x00), 0x00), + BUILD_COLOR (MAKE_RGB15_INIT (0x14, 0x00, 0x14), 0x05), + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x19), 0x00), }; r.extent.width = 23; diff --git a/sc2/src/uqm/globdata.h b/sc2/src/uqm/globdata.h index 8392a6ab7..521e9dc9e 100644 --- a/sc2/src/uqm/globdata.h +++ b/sc2/src/uqm/globdata.h @@ -99,7 +99,7 @@ typedef struct RESOURCE AlienFrameRes; RESOURCE AlienFontRes; - COLOR AlienTextFColor, AlienTextBColor; + Color AlienTextFColor, AlienTextBColor; POINT AlienTextBaseline; COUNT AlienTextWidth; TEXT_ALIGN AlienTextAlign; diff --git a/sc2/src/uqm/hyper.c b/sc2/src/uqm/hyper.c index 66617a368..c34fdcff5 100644 --- a/sc2/src/uqm/hyper.c +++ b/sc2/src/uqm/hyper.c @@ -1601,7 +1601,7 @@ SeedUniverse (void) void HyperspaceMenu (void) { - COLOR OldColor; + Color OldColor; CONTEXT OldContext; MENU_STATE MenuState; diff --git a/sc2/src/uqm/intro.c b/sc2/src/uqm/intro.c index 576ee2d58..19eee9e1a 100644 --- a/sc2/src/uqm/intro.c +++ b/sc2/src/uqm/intro.c @@ -58,9 +58,9 @@ typedef struct int LastDrawKind; int LastAngle; COUNT OperIndex; - COLOR TextFadeColor; - COLOR TextColor; - COLOR TextBackColor; + Color TextFadeColor; + Color TextColor; + Color TextBackColor; int TextVPos; int TextEffect; RECT clip_r; @@ -99,14 +99,14 @@ typedef struct static BOOLEAN DoPresentation (void *pIS); static BOOLEAN -ParseColorString (const char *Src, COLOR* pColor) +ParseColorString (const char *Src, Color* pColor) { unsigned clr; if (1 != sscanf (Src, "%x", &clr)) return FALSE; - *pColor = BUILD_COLOR (MAKE_RGB15 ( - (clr >> 19) & 0x1f, (clr >> 11) & 0x1f, (clr >> 3) & 0x1f), 0); + *pColor = BUILD_COLOR_RGBA ( + (clr >> 16) & 0xff, (clr >> 8) & 0xff, clr & 0xff, 0); return TRUE; } @@ -125,7 +125,7 @@ DoFadeScreen (PRESENTATION_INPUT_STATE* pPIS, const char *Src, BYTE FadeType) } static void -DrawTextEffect (TEXT *pText, COLOR Fore, COLOR Back, int Effect) +DrawTextEffect (TEXT *pText, Color Fore, Color Back, int Effect) { if (Effect == 'T') { @@ -197,7 +197,7 @@ Present_GenerateSIS (PRESENTATION_INPUT_STATE* pPIS) HOT_SPOT hs; int slot; COUNT piece; - COLOR SisBack; + Color SisBack; LockMutex (GraphicsLock); OldContext = SetContext (OffScreenContext); diff --git a/sc2/src/uqm/melee.c b/sc2/src/uqm/melee.c index 2992fb63e..30c94aa03 100644 --- a/sc2/src/uqm/melee.c +++ b/sc2/src/uqm/melee.c @@ -556,7 +556,7 @@ DrawPickIcon (COUNT iship, BYTE DrawErase) } else { // erase icon - COLOR OldColor; + Color OldColor; OldColor = SetContextForeGroundColor (BLACK_COLOR); DrawFilledStamp (&s); @@ -1836,7 +1836,7 @@ DoConnectingDialog (MELEE_STATE *pMS) { RECT r; FONT oldfont; - COLOR oldcolor; + Color oldcolor; TEXT t; // Build a network connection. diff --git a/sc2/src/uqm/misc.c b/sc2/src/uqm/misc.c index 91ab903b1..4bc728ff0 100644 --- a/sc2/src/uqm/misc.c +++ b/sc2/src/uqm/misc.c @@ -215,17 +215,25 @@ do_damage (ELEMENT *ElementPtr, SIZE damage) } } +#define CREW_COLOR_LOW_INTENSITY \ + BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x00), 0x02) +#define CREW_COLOR_HIGH_INTENSITY \ + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1E, 0x0A), 0x0A) void crew_preprocess (ELEMENT *ElementPtr) { HELEMENT hTarget; - SetPrimColor (&DisplayArray[ElementPtr->PrimIndex], - GetPrimColor (&DisplayArray[ElementPtr->PrimIndex]) - ^ BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08)); + // Switch from dark to light or vice versa: + Color oldColor = GetPrimColor (&DisplayArray[ElementPtr->PrimIndex]); + Color newColor = sameColor (oldColor, CREW_COLOR_LOW_INTENSITY) ? + CREW_COLOR_HIGH_INTENSITY : CREW_COLOR_LOW_INTENSITY; + SetPrimColor (&DisplayArray[ElementPtr->PrimIndex], newColor); + ElementPtr->state_flags |= CHANGING; - if ((hTarget = ElementPtr->hTarget) == 0) + hTarget = ElementPtr->hTarget; + if (hTarget == 0) { STARSHIP *StarShipPtr; diff --git a/sc2/src/uqm/planets/lander.c b/sc2/src/uqm/planets/lander.c index 670d80104..c21fdc3f9 100644 --- a/sc2/src/uqm/planets/lander.c +++ b/sc2/src/uqm/planets/lander.c @@ -176,38 +176,38 @@ static PLANETSIDE_DESC *planetSideDesc; #define ON_THE_GROUND 0 -static COLOR -DamageColorCycle (COLOR c, COUNT i) +static Color +DamageColorCycle (Color c, COUNT i) { - static const COLOR damage_tab[DAMAGE_CYCLE + 1] = + static const Color damage_tab[DAMAGE_CYCLE + 1] = { - WHITE_COLOR, - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2A), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7E), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7C), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1C, 0x00), 0x78), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E), + WHITE_COLOR_INIT, + BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x00, 0x00), 0x2A), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x07, 0x00), 0x7E), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0E, 0x00), 0x7C), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x15, 0x00), 0x7A), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1C, 0x00), 0x78), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1F, 0x0A), 0x0E), }; if (i) c = damage_tab[i]; - else if (c == WHITE_COLOR) + else if (sameColor(c, WHITE_COLOR)) c = damage_tab[6]; - else if (c == BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E)) + else if (sameColor(c, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E))) c = damage_tab[5]; - else if (c == BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1C, 0x00), 0x78)) + else if (sameColor(c, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1C, 0x00), 0x78))) c = damage_tab[4]; - else if (c == BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A)) + else if (sameColor(c, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A))) c = damage_tab[3]; - else if (c == BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7C)) + else if (sameColor(c, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7C))) c = damage_tab[2]; - else if (c == BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7E)) + else if (sameColor(c, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7E))) c = damage_tab[1]; else c = damage_tab[0]; - return (c); + return c; } static HELEMENT AddGroundDisaster (COUNT which_disaster); @@ -223,10 +223,10 @@ object_animation (ELEMENT *ElementPtr) && !((ElementPtr->state_flags & FINITE_LIFE) && ElementPtr->mass_points == EARTHQUAKE_DISASTER)) { - COLOR c; + Color c; c = DamageColorCycle (GetPrimColor (pPrim), 0); - if (c == WHITE_COLOR) + if (sameColor(c, WHITE_COLOR)) { SetPrimType (pPrim, STAMP_PRIM); if (ElementPtr->hit_points == 0) @@ -273,7 +273,8 @@ object_animation (ELEMENT *ElementPtr) else s = (14 - frame_index) >> 1; // XXX: Was 0x8000 the background flag on 3DO? - SetPrimColor (pPrim, BUILD_COLOR (0x8000 | MAKE_RGB15 (0x1F, 0x1F, 0x1F), s)); + //SetPrimColor (pPrim, BUILD_COLOR (0x8000 | MAKE_RGB15 (0x1F, 0x1F, 0x1F), s)); + SetPrimColor (pPrim, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), s)); if (frame_index == 13) PlaySound (SetAbsSoundIndex (LanderSounds, EARTHQUAKE_DISASTER), NotPositional (), NULL, GAME_SOUND_PRIORITY); @@ -923,7 +924,8 @@ lightning_process (ELEMENT *ElementPtr) if (s < 0) s = 0; // XXX: Was 0x8000 the background flag on 3DO? - SetPrimColor (pPrim, BUILD_COLOR (0x8000 | MAKE_RGB15 (0x1F, 0x1F, 0x1F), s)); + //SetPrimColor (pPrim, BUILD_COLOR (0x8000 | MAKE_RGB15 (0x1F, 0x1F, 0x1F), s)); + SetPrimColor (pPrim, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), s)); if (ElementPtr->mass_points == LIGHTNING_DISASTER) { @@ -1253,9 +1255,11 @@ ScrollPlanetSide (SIZE dx, SIZE dy, int landingOffset) // XXX: Shouldn't this color-cycle with damage_index? // damage_index is used, but only as a VGA index! - SetContextForeGroundColor (BUILD_COLOR ( + /*SetContextForeGroundColor (BUILD_COLOR ( MAKE_RGB15 (0x1F, 0x1F, 0x1F) | 0x8000, - damage_index)); + damage_index));*/ + SetContextForeGroundColor ( + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), damage_index)); DrawFilledStamp (&shield_s); } DrawStamp (&lander_s); @@ -1263,7 +1267,8 @@ ScrollPlanetSide (SIZE dx, SIZE dy, int landingOffset) else { // Direct hit, no shield --damage_index; - SetContextForeGroundColor (DamageColorCycle (0, damage_index)); + SetContextForeGroundColor ( + DamageColorCycle (BLACK_COLOR, damage_index)); DrawFilledStamp (&lander_s); } } diff --git a/sc2/src/uqm/planets/lander.h b/sc2/src/uqm/planets/lander.h index ce048bbb7..77e96bc10 100644 --- a/sc2/src/uqm/planets/lander.h +++ b/sc2/src/uqm/planets/lander.h @@ -49,7 +49,7 @@ typedef struct UNICODE AmountBuf[40]; TEXT MineralText[3]; - COLOR ColorCycle[NUM_TEXT_FRAMES >> 1]; + Color ColorCycle[NUM_TEXT_FRAMES >> 1]; BYTE TectonicsChance; BYTE WeatherChance; diff --git a/sc2/src/uqm/planets/pl_stuff.c b/sc2/src/uqm/planets/pl_stuff.c index 651af0b68..c3762981f 100644 --- a/sc2/src/uqm/planets/pl_stuff.c +++ b/sc2/src/uqm/planets/pl_stuff.c @@ -17,6 +17,7 @@ */ #include "planets.h" +#include "../colors.h" #include "../setup.h" #include "libs/graphics/gfx_common.h" #include "libs/graphics/drawable.h" @@ -123,8 +124,9 @@ RotatePlanet (int x, int dx, int dy, COUNT scale_amt, UBYTE zoom_from, (void)x; // unused param } +// rgb.a is ignored void -DrawPlanet (int x, int y, int dy, unsigned int rgb) +DrawPlanet (int x, int y, int dy, Color rgb) { STAMP s; UBYTE a = 128; @@ -134,7 +136,7 @@ DrawPlanet (int x, int y, int dy, unsigned int rgb) s.origin.y = y; s.frame = pSolarSysState->TopoFrame; BatchGraphics (); - if (! rgb) + if (sameColor (rgb, BLACK_COLOR)) { // no tint -- just draw the surface DrawStamp (&s); } @@ -151,14 +153,14 @@ DrawPlanet (int x, int y, int dy, unsigned int rgb) framew = GetFrameWidth (tintFrame[0]); frameh = GetFrameHeight (tintFrame[0]); - if (rgb != pSolarSysState->Tint_rgb) + if (!sameColor (rgb, pSolarSysState->Tint_rgb)) { pSolarSysState->Tint_rgb = rgb; // Buffer the topoMap to the tintFrame; arith_frame_blit (s.frame, NULL, tintFrame[0], NULL, 0, 0); - r = (rgb & (0x1f << 10)) >> 8; - g = (rgb & (0x1f << 5)) >> 3; - b = (rgb & 0x1f) << 2; + r = rgb.r / 2; + g = rgb.g / 2; + b = rgb.b / 2; #ifdef USE_ADDITIVE_SCAN_BLIT a = 255; #endif diff --git a/sc2/src/uqm/planets/planets.c b/sc2/src/uqm/planets/planets.c index 8ddc05bfb..f036377cd 100644 --- a/sc2/src/uqm/planets/planets.c +++ b/sc2/src/uqm/planets/planets.c @@ -20,6 +20,7 @@ #include "scan.h" #include "lander.h" +#include "../colors.h" #include "../element.h" #include "../settings.h" #include "../setup.h" @@ -102,7 +103,7 @@ DrawOrbitalDisplay (DRAW_ORBITAL_MODE Mode) else { DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH, - SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, 0); + SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, BLACK_COLOR); } if (Mode != DRAW_ORBITAL_UPDATE) @@ -247,7 +248,7 @@ FreePlanet (void) DestroyDrawable (ReleaseDrawable (Orbit->TintFrame)); Orbit->TintFrame = 0; - pSolarSysState->Tint_rgb = 0; + pSolarSysState->Tint_rgb = BLACK_COLOR; DestroyDrawable (ReleaseDrawable (Orbit->ObjectFrame)); Orbit->ObjectFrame = 0; diff --git a/sc2/src/uqm/planets/planets.h b/sc2/src/uqm/planets/planets.h index df27bf308..c53088ed3 100644 --- a/sc2/src/uqm/planets/planets.h +++ b/sc2/src/uqm/planets/planets.h @@ -114,7 +114,7 @@ struct planet_desc SIZE radius; POINT location; - COLOR temp_color; + Color temp_color; COUNT NextIndex; STAMP image; @@ -210,7 +210,7 @@ struct solarsys_state * [4] = bio 2 (world-specific) * [5] = bio 3 (world-specific) */ - UWORD Tint_rgb; + Color Tint_rgb; UBYTE PauseRotate; FRAME TopoFrame; PLANET_ORBIT Orbit; @@ -228,7 +228,7 @@ bool matchWorld (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world, BYTE planetI, BYTE moonI); extern void LoadPlanet (FRAME SurfDefFrame); -extern void DrawPlanet (int x, int y, int dy, unsigned int rgb); +extern void DrawPlanet (int x, int y, int dy, Color rgb); extern void FreePlanet (void); extern void LoadStdLanderFont (PLANET_INFO *info); extern void FreeLanderFont (PLANET_INFO *info); diff --git a/sc2/src/uqm/planets/pstarmap.c b/sc2/src/uqm/planets/pstarmap.c index c78a01c06..42364f3c5 100644 --- a/sc2/src/uqm/planets/pstarmap.c +++ b/sc2/src/uqm/planets/pstarmap.c @@ -118,7 +118,7 @@ flashCurrentLocation (POINT *where) if (GetTimeCounter () >= NextTime) { - COLOR OldColor; + Color OldColor; CONTEXT OldContext; STAMP s; @@ -130,7 +130,8 @@ flashCurrentLocation (POINT *where) if (c == 0x00 || c == 0x1A) val = -val; c += val; - OldColor = SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (c, c, c), c)); + OldColor = SetContextForeGroundColor ( + BUILD_COLOR (MAKE_RGB15 (c, c, c), c)); s.origin.x = UNIVERSE_TO_DISPX (universe.x); s.origin.y = UNIVERSE_TO_DISPY (universe.y); s.frame = IncFrameIndex (StarMapFrame); @@ -199,7 +200,8 @@ DrawAutoPilot (POINT *pDstPt) cycle = dy; delta = xerror = yerror = cycle >> 1; - SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x04, 0x04, 0x1F), 0x01)); + SetContextForeGroundColor ( + BUILD_COLOR (MAKE_RGB15 (0x04, 0x04, 0x1F), 0x01)); delta &= ~1; while (delta--) @@ -260,12 +262,16 @@ GetSphereRect (FLEET_INFO *FleetPtr, RECT *pRect, RECT *pRepairRect) if (pRepairRect->corner.x <= 0) pRepairRect->corner.x = 1; - else if (pRepairRect->corner.x + pRepairRect->extent.width >= SIS_SCREEN_WIDTH) - pRepairRect->corner.x = SIS_SCREEN_WIDTH - pRepairRect->extent.width - 1; + else if (pRepairRect->corner.x + pRepairRect->extent.width >= + SIS_SCREEN_WIDTH) + pRepairRect->corner.x = + SIS_SCREEN_WIDTH - pRepairRect->extent.width - 1; if (pRepairRect->corner.y <= 0) pRepairRect->corner.y = 1; - else if (pRepairRect->corner.y + pRepairRect->extent.height >= SIS_SCREEN_HEIGHT) - pRepairRect->corner.y = SIS_SCREEN_HEIGHT - pRepairRect->extent.height - 1; + else if (pRepairRect->corner.y + pRepairRect->extent.height >= + SIS_SCREEN_HEIGHT) + pRepairRect->corner.y = + SIS_SCREEN_HEIGHT - pRepairRect->extent.height - 1; BoxUnion (pRepairRect, pRect, pRepairRect); pRepairRect->extent.width++; @@ -339,7 +345,7 @@ DrawStarMap (COUNT race_update, RECT *pClipRect) && which_space < 2 && (diameter = (long)GLOBAL_SIS (FuelOnBoard) << 1)) { - COLOR OldColor; + Color OldColor; if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE) r.corner = CurStarDescPtr->star_pt; @@ -394,7 +400,7 @@ DrawStarMap (COUNT race_update, RECT *pClipRect) { COUNT index; HFLEETINFO hStarShip, hNextShip; - static const COLOR race_colors[] = + static const Color race_colors[] = { RACE_COLORS }; @@ -423,7 +429,7 @@ DrawStarMap (COUNT race_update, RECT *pClipRect) && repair_r.corner.x + repair_r.extent.width > pClipRect->corner.x && repair_r.corner.y + repair_r.extent.height > pClipRect->corner.y))) { - COLOR c; + Color c; TEXT t; STRING locString; @@ -456,22 +462,16 @@ DrawStarMap (COUNT race_update, RECT *pClipRect) t.baseline.y -= (r.corner.y + r.extent.height) - SIS_SCREEN_HEIGHT + 1; - { - BYTE r, g, b; - COLOR c32k; + // The text color is slightly lighter than the color of + // the SoI. + c.r = (c.r >= 0xff - CC5TO8 (0x03)) ? + 0xff : c.r + CC5TO8 (0x03); + c.g = (c.g >= 0xff - CC5TO8 (0x03)) ? + 0xff : c.g + CC5TO8 (0x03); + c.b = (c.b >= 0xff - CC5TO8 (0x03)) ? + 0xff : c.b + CC5TO8 (0x03); - c32k = COLOR_32k (c); - r = (BYTE)((c32k >> (5 * 2)) & 0x1F); - if ((r += 0x03) > 0x1F) r = 0x1F; - g = (BYTE)((c32k >> (5 * 1)) & 0x1F); - if ((g += 0x03) > 0x1F) g = 0x1F; - b = (BYTE)((c32k >> (5 * 0)) & 0x1F); - if ((b += 0x03) > 0x1F) b = 0x1F; - - SetContextForeGroundColor ( - BUILD_COLOR (MAKE_RGB15 (r, g, b), COLOR_256 (c) - 1) - ); - } + SetContextForeGroundColor (c); font_DrawText (&t); } } diff --git a/sc2/src/uqm/planets/roster.c b/sc2/src/uqm/planets/roster.c index 1190ae26e..625a4919c 100644 --- a/sc2/src/uqm/planets/roster.c +++ b/sc2/src/uqm/planets/roster.c @@ -79,17 +79,33 @@ getSupportShipIcon (MENU_STATE *pMS) static void flashSupportShip (MENU_STATE *pMS) { - static COLOR c = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x24); + static Color c = BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x00, 0x00), 0x24); static TimeCount NextTime = 0; if (GetTimeCounter () >= NextTime) { NextTime = GetTimeCounter () + (ONE_SECOND / 15); + /* The commented code out code is the old code before the switch + * to 24-bits colors. The current code produces very slightly + * different colors due to rounding errors, but the old code wasn't + * original anyhow, and you can't tell the difference visually. + * - SvdB if (c >= BUILD_COLOR (MAKE_RGB15 (0x1F, 0x19, 0x19), 0x24)) c = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x24); else c += BUILD_COLOR (MAKE_RGB15 (0x00, 0x02, 0x02), 0x00); + */ + + if (c.g >= CC5TO8 (0x19)) + { + c = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x24); + } + else + { + c.g += CC5TO8 (0x02); + c.b += CC5TO8 (0x02); + } SetContextForeGroundColor (c); drawSupportShip (pMS, TRUE); diff --git a/sc2/src/uqm/planets/scan.c b/sc2/src/uqm/planets/scan.c index 4b99b8c1c..93fb0b49f 100644 --- a/sc2/src/uqm/planets/scan.c +++ b/sc2/src/uqm/planets/scan.c @@ -20,6 +20,7 @@ #include "lifeform.h" #include "scan.h" #include "../build.h" +#include "../colors.h" #include "../cons_res.h" #include "../controls.h" #include "../menustat.h" @@ -625,7 +626,7 @@ RedrawSurfaceScan (const POINT *newLoc) OldContext = SetContext (ScanContext); BatchGraphics (); - DrawPlanet (0, 0, 0, 0); + DrawPlanet (0, 0, 0, BLACK_COLOR); DrawScannedObjects (TRUE); if (newLoc) { @@ -819,14 +820,14 @@ static void DrawScannedStuff (COUNT y, BYTE CurState) { HELEMENT hElement, hNextElement; - COLOR OldColor; + Color OldColor; - OldColor = SetContextForeGroundColor (0); + OldColor = SetContextForeGroundColor (BLACK_COLOR); for (hElement = GetHeadElement (); hElement; hElement = hNextElement) { ELEMENT *ElementPtr; - //COLOR OldColor; + //Color OldColor; SIZE dy; LockElement (hElement, &ElementPtr); @@ -860,7 +861,7 @@ DrawScannedStuff (COUNT y, BYTE CurState) else { BYTE r, g, b; - COLOR c; + Color c; // mineral -- white --> turquoise?? (contrasts with red) // energy -- white --> red (contrasts with white) @@ -949,7 +950,8 @@ DoScan (MENU_STATE *pMS) LockMutex (GraphicsLock); SetContext (SpaceContext); BatchGraphics (); - DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH, SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, 0); + DrawPlanet (SIS_SCREEN_WIDTH - MAP_WIDTH, + SIS_SCREEN_HEIGHT - MAP_HEIGHT, 0, BLACK_COLOR); UnbatchGraphics (); UnlockMutex (GraphicsLock); @@ -1001,7 +1003,7 @@ DoScan (MENU_STATE *pMS) LockMutex (GraphicsLock); SetContext (ScanContext); BatchGraphics (); - DrawPlanet (0, 0, 0, 0); + DrawPlanet (0, 0, 0, BLACK_COLOR); DrawScannedObjects (FALSE); UnbatchGraphics (); UnlockMutex (GraphicsLock); @@ -1079,26 +1081,27 @@ DoScan (MENU_STATE *pMS) UnlockMutex (GraphicsLock); { - DWORD rgb; + Color rgb; + // Alpha value will be ignored. TimeCount TimeOut; switch (min_scan) { case MINERAL_SCAN: - rgb = MAKE_RGB15 (0x1f, 0x00, 0x00); + rgb = BUILD_COLOR (MAKE_RGB15 (0x1f, 0x00, 0x00), 0x00); break; case ENERGY_SCAN: - rgb = MAKE_RGB15 (0x1f, 0x1f, 0x1f); + rgb = BUILD_COLOR (MAKE_RGB15 (0x1f, 0x1f, 0x1f), 0x00); break; case BIOLOGICAL_SCAN: - rgb = MAKE_RGB15 (0x00, 0x1f, 0x00); + rgb = BUILD_COLOR (MAKE_RGB15 (0x00, 0x1f, 0x00), 0x00); break; } // Draw a virgin surface LockMutex (GraphicsLock); BatchGraphics (); - DrawPlanet (0, 0, 0, 0); + DrawPlanet (0, 0, 0, BLACK_COLOR); UnbatchGraphics (); UnlockMutex (GraphicsLock); @@ -1129,7 +1132,7 @@ DoScan (MENU_STATE *pMS) UnlockMutex (GraphicsLock); } - pSolarSysState->Tint_rgb = 0; + pSolarSysState->Tint_rgb = BLACK_COLOR; } } @@ -1145,7 +1148,7 @@ DoScan (MENU_STATE *pMS) SetContext (ScanContext); if (pMS->CurState == AUTO_SCAN) { - DrawPlanet (0, 0, 0, 0); + DrawPlanet (0, 0, 0, BLACK_COLOR); DrawScannedObjects (FALSE); UnlockMutex (GraphicsLock); diff --git a/sc2/src/uqm/planets/solarsys.c b/sc2/src/uqm/planets/solarsys.c index 17c60ecd9..e2339ccc3 100644 --- a/sc2/src/uqm/planets/solarsys.c +++ b/sc2/src/uqm/planets/solarsys.c @@ -299,13 +299,13 @@ LoadSolarSys (void) PLANET_DESC *pCurDesc; DWORD old_seed; #define NUM_TEMP_RANGES 5 - static const COLOR temp_color_array[NUM_TEMP_RANGES] = + static const Color temp_color_array[NUM_TEMP_RANGES] = { - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x0E), 0x54), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x06, 0x08), 0x62), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x0B, 0x00), 0x6D), - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2D), - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x08, 0x00), 0x75), + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x0E), 0x54), + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x06, 0x08), 0x62), + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x0B, 0x00), 0x6D), + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x00), 0x2D), + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x08, 0x00), 0x75), }; pSolarSysState->MenuState.CurState = 0; diff --git a/sc2/src/uqm/races.h b/sc2/src/uqm/races.h index a0d6a2dbe..33033d9a1 100644 --- a/sc2/src/uqm/races.h +++ b/sc2/src/uqm/races.h @@ -640,29 +640,29 @@ enum MAKE_BYTE (1, 5), /* YEHAT_REBEL_SHIP */ #define RACE_COLORS \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x10), 0x53), /* ARILOU_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00), /* CHMMR_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x01, 0x1f), 0x4D), /* HUMAN_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x0E, 0x00, 0x0E), 0x36), /* ORZ_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x06, 0x08), 0x62), /* PKUNK_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00), /* SHOFIXTI_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x0C, 0x05, 0x00), 0x76), /* SPATHI_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x0C, 0x05, 0x00), 0x76), /* SUPOX_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x06, 0x08), 0x62), /* THRADDASH_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x06, 0x08), 0x62), /* UTWIG_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x10), 0x53), /* VUX_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x00, 0x11), 0x3D), /* YEHAT_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x06, 0x08), 0x62), /* MELNORME_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2D), /* DRUUGE_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x0E, 0x00, 0x0E), 0x36), /* ILWRATH_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x0E, 0x00, 0x0E), 0x36), /* MYCON_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x0C, 0x05, 0x00), 0x76), /* SLYLANDRO_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x00, 0x11), 0x3D), /* UMGAH_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x08, 0x00), 0x6E), /* URQUAN_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2D), /* ZOQFOTPIK_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00), /* SYREEN_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x06, 0x06, 0x06), 0x20), /* BLACK_URQUAN_SHIP */ \ - BUILD_COLOR (MAKE_RGB15 (0x14, 0x07, 0x1F), 0x39), /* YEHAT_REBEL_SHIP */ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x10), 0x53), /* ARILOU_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x00), 0x00), /* CHMMR_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x01, 0x1f), 0x4D), /* HUMAN_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0E, 0x00, 0x0E), 0x36), /* ORZ_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x06, 0x08), 0x62), /* PKUNK_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x00), 0x00), /* SHOFIXTI_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0C, 0x05, 0x00), 0x76), /* SPATHI_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0C, 0x05, 0x00), 0x76), /* SUPOX_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x06, 0x08), 0x62), /* THRADDASH_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x06, 0x08), 0x62), /* UTWIG_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x10), 0x53), /* VUX_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0A, 0x00, 0x11), 0x3D), /* YEHAT_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x06, 0x08), 0x62), /* MELNORME_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x00), 0x2D), /* DRUUGE_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0E, 0x00, 0x0E), 0x36), /* ILWRATH_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0E, 0x00, 0x0E), 0x36), /* MYCON_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0C, 0x05, 0x00), 0x76), /* SLYLANDRO_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0A, 0x00, 0x11), 0x3D), /* UMGAH_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x08, 0x00), 0x6E), /* URQUAN_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x00), 0x2D), /* ZOQFOTPIK_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x00), 0x00), /* SYREEN_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x06, 0x06, 0x06), 0x20), /* BLACK_URQUAN_SHIP */ \ + BUILD_COLOR (MAKE_RGB15_INIT (0x14, 0x07, 0x1F), 0x39), /* YEHAT_REBEL_SHIP */ #endif /* _RACES_H */ diff --git a/sc2/src/uqm/ships/chmmr/chmmr.c b/sc2/src/uqm/ships/chmmr/chmmr.c index b098fe50e..d6484b155 100644 --- a/sc2/src/uqm/ships/chmmr/chmmr.c +++ b/sc2/src/uqm/ships/chmmr/chmmr.c @@ -205,12 +205,12 @@ initialize_megawatt_laser (ELEMENT *ShipPtr, HELEMENT LaserArray[]) RECT r; STARSHIP *StarShipPtr; LASER_BLOCK LaserBlock; - static const COLOR cycle_array[] = + static const Color cycle_array[] = { - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2B), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7F), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7B), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7F), + BUILD_COLOR (MAKE_RGB15_INIT (0x17, 0x00, 0x00), 0x2B), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x03, 0x00), 0x7F), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x11, 0x00), 0x7B), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x03, 0x00), 0x7F), }; GetElementStarShip (ShipPtr, &StarShipPtr); @@ -354,13 +354,13 @@ chmmr_postprocess (ELEMENT *ElementPtr) DISPLAY_TO_WORLD (8 + 9 + 11 + 14), DISPLAY_TO_WORLD (8 + 9 + 11 + 14 + 18), }; - static const COLOR color_tab[] = + static const Color color_tab[] = { - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x10), 0x53), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x0E), 0x54), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x0C), 0x55), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x09), 0x56), - BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x07), 0x57), + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x10), 0x53), + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x0E), 0x54), + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x0C), 0x55), + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x09), 0x56), + BUILD_COLOR (MAKE_RGB15_INIT (0x00, 0x00, 0x07), 0x57), }; DWORD current_speed, max_speed; @@ -375,7 +375,8 @@ chmmr_postprocess (ELEMENT *ElementPtr) + DISPLAY_TO_WORLD (CHMMR_OFFSET))) - ShipElementPtr->next.location.y; angle = ARCTAN (dx, dy); - magnitude = WORLD_TO_VELOCITY (12) / ShipElementPtr->mass_points; + magnitude = WORLD_TO_VELOCITY (12) / + ShipElementPtr->mass_points; DeltaVelocityComponents (&ShipElementPtr->velocity, COSINE (angle, magnitude), SINE (angle, magnitude)); diff --git a/sc2/src/uqm/ships/ilwrath/ilwrath.c b/sc2/src/uqm/ships/ilwrath/ilwrath.c index 7fcec01da..9b0a30a64 100644 --- a/sc2/src/uqm/ships/ilwrath/ilwrath.c +++ b/sc2/src/uqm/ships/ilwrath/ilwrath.c @@ -233,26 +233,36 @@ ilwrath_preprocess (ELEMENT *ElementPtr) lpPrim = &(GLOBAL (DisplayArray))[ElementPtr->PrimIndex]; if (GetPrimType (lpPrim) == STAMPFILL_PRIM) { - COLOR Color; + Color color; BOOLEAN weapon_discharge; - Color = GetPrimColor (lpPrim); + color = GetPrimColor (lpPrim); weapon_discharge = ((status_flags & WEAPON) && StarShipPtr->RaceDescPtr->ship_info.energy_level >= WEAPON_ENERGY_COST); if (weapon_discharge || (StarShipPtr->special_counter == 0 - && ((status_flags & SPECIAL) || Color != BLACK_COLOR))) + && ((status_flags & SPECIAL) || + !sameColor (color, BLACK_COLOR)))) { - if (Color == BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)) + if (sameColor (color, + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F))) SetPrimType (lpPrim, STAMP_PRIM); - else if (Color == BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B)) - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); - else if (Color == BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03)) - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B)); - else if (Color == BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09)) - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03)); - else if (Color == BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)) - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09)); + else if (sameColor (color, + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B))) + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); + else if (sameColor (color, + BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03))) + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B)); + else if (sameColor (color, + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09))) + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03)); + else if (sameColor (color, + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01))) + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09)); else { ProcessSound (SetAbsSoundIndex ( @@ -329,21 +339,29 @@ ilwrath_preprocess (ELEMENT *ElementPtr) status_flags &= ~SPECIAL; StarShipPtr->special_counter = 0; } - else if (Color != BLACK_COLOR) + else if (!sameColor (color, BLACK_COLOR)) { - if (Color == BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)) + if (sameColor (color, + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01))) { SetPrimColor (lpPrim, BLACK_COLOR); Untarget (ElementPtr); } - else if (Color == BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09)) - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)); - else if (Color == BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03)) - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09)); - else if (Color == BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B)) - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03)); + else if (sameColor (color, + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09))) + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)); + else if (sameColor (color, + BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03))) + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09)); + else if (sameColor (color, + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B))) + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03)); else - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B)); + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B)); ElementPtr->state_flags |= CHANGING; } @@ -353,12 +371,14 @@ ilwrath_preprocess (ELEMENT *ElementPtr) && StarShipPtr->special_counter == 0 && DeltaEnergy (ElementPtr, -SPECIAL_ENERGY_COST)) { - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); SetPrimType (lpPrim, STAMPFILL_PRIM); ProcessSound (SetAbsSoundIndex ( /* CLOAKING_ON */ - StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 1), ElementPtr); + StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 1), + ElementPtr); StarShipPtr->special_counter = StarShipPtr->RaceDescPtr->characteristics.special_wait; diff --git a/sc2/src/uqm/ships/orz/orz.c b/sc2/src/uqm/ships/orz/orz.c index d6a0a4b7b..11a5c6875 100644 --- a/sc2/src/uqm/ships/orz/orz.c +++ b/sc2/src/uqm/ships/orz/orz.c @@ -318,21 +318,21 @@ ion_preprocess (ELEMENT *ElementPtr) * entries. It then used some if statements to skip over these. * The current behaviour is the same as the old behavior. */ - static const COLOR colorTable[] = + static const Color colorTable[] = { - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7a), - //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7b), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7c), - //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7d), - //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7e), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7f), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x15, 0x00), 0x7a), + //BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x11, 0x00), 0x7b), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0E, 0x00), 0x7c), + //BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0A, 0x00), 0x7d), + //BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x07, 0x00), 0x7e), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x03, 0x00), 0x7f), - //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x2a), - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2b), - //BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2c), - BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2d), - //BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2e), - //BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2f), + //BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x00, 0x00), 0x2a), + BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x00, 0x00), 0x2b), + //BUILD_COLOR (MAKE_RGB15_INIT (0x17, 0x00, 0x00), 0x2c), + BUILD_COLOR (MAKE_RGB15_INIT (0x13, 0x00, 0x00), 0x2d), + //BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x00), 0x2e), + //BUILD_COLOR (MAKE_RGB15_INIT (0x0B, 0x00, 0x00), 0x2f), }; const size_t colorTabCount = sizeof colorTable / sizeof colorTable[0]; diff --git a/sc2/src/uqm/ships/pkunk/pkunk.c b/sc2/src/uqm/ships/pkunk/pkunk.c index dbfad5a89..723dd2f7d 100644 --- a/sc2/src/uqm/ships/pkunk/pkunk.c +++ b/sc2/src/uqm/ships/pkunk/pkunk.c @@ -317,20 +317,20 @@ intercept_pkunk_death (ELEMENT *ElementPtr) void spawn_phoenix_trail (ELEMENT *ElementPtr) { - static const COLOR colorTable[] = + static const Color colorTable[] = { - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7a), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7b), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7c), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7d), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7e), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7f), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x2a), - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2b), - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2c), - BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2d), - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2e), - BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2f), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x15, 0x00), 0x7a), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x11, 0x00), 0x7b), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0E, 0x00), 0x7c), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0A, 0x00), 0x7d), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x07, 0x00), 0x7e), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x03, 0x00), 0x7f), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x00, 0x00), 0x2a), + BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x00, 0x00), 0x2b), + BUILD_COLOR (MAKE_RGB15_INIT (0x17, 0x00, 0x00), 0x2c), + BUILD_COLOR (MAKE_RGB15_INIT (0x13, 0x00, 0x00), 0x2d), + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x00), 0x2e), + BUILD_COLOR (MAKE_RGB15_INIT (0x0B, 0x00, 0x00), 0x2f), }; const size_t colorTableCount = sizeof colorTable / sizeof colorTable[0]; diff --git a/sc2/src/uqm/ships/shofixti/shofixti.c b/sc2/src/uqm/ships/shofixti/shofixti.c index 335e9b526..ed6c2eb24 100644 --- a/sc2/src/uqm/ships/shofixti/shofixti.c +++ b/sc2/src/uqm/ships/shofixti/shofixti.c @@ -152,22 +152,34 @@ destruct_preprocess (ELEMENT *ElementPtr) { SetPrimType (lpPrim, STAMPFILL_PRIM); if (ElementPtr->life_span == DESTRUCT_SWITCH + 2) - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E)); + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E)); else - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); } else if (ElementPtr->life_span < DESTRUCT_SWITCH) { + Color color = GetPrimColor (lpPrim); + ElementPtr->next.image.frame = IncFrameIndex (ElementPtr->current.image.frame); - if (GetPrimColor (lpPrim) == BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)) - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E)); - else if (GetPrimColor (lpPrim) == BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E)) - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C)); - else if (GetPrimColor (lpPrim) == BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C)) - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x14, 0x0A, 0x00), 0x06)); - else if (GetPrimColor (lpPrim) == BUILD_COLOR (MAKE_RGB15 (0x14, 0x0A, 0x00), 0x06)) - SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04)); + if (sameColor (color, + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F))) + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E)); + else if (sameColor (color, + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E))) + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C)); + else if (sameColor (color, + BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C))) + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x14, 0x0A, 0x00), 0x06)); + else if (sameColor (color, + BUILD_COLOR (MAKE_RGB15 (0x14, 0x0A, 0x00), 0x06))) + SetPrimColor (lpPrim, + BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04)); } else { diff --git a/sc2/src/uqm/ships/sis_ship/sis_ship.c b/sc2/src/uqm/ships/sis_ship/sis_ship.c index 94b54aad5..580abaeb5 100644 --- a/sc2/src/uqm/ships/sis_ship/sis_ship.c +++ b/sc2/src/uqm/ships/sis_ship/sis_ship.c @@ -342,17 +342,17 @@ spawn_point_defense (ELEMENT *ElementPtr) BOOLEAN PaidFor; HELEMENT hObject, hNextObject; ELEMENT *ShipPtr; - COLOR LaserColor; - static const COLOR ColorRange[] = + Color LaserColor; + static const Color ColorRange[] = { - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7F), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7E), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7D), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7C), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7B), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x18, 0x00), 0x79), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1C, 0x00), 0x78), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x03, 0x00), 0x7F), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x07, 0x00), 0x7E), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0A, 0x00), 0x7D), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0E, 0x00), 0x7C), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x11, 0x00), 0x7B), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x15, 0x00), 0x7A), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x18, 0x00), 0x79), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1C, 0x00), 0x78), }; PaidFor = FALSE; diff --git a/sc2/src/uqm/ships/utwig/utwig.c b/sc2/src/uqm/ships/utwig/utwig.c index d72dce780..11db06d82 100644 --- a/sc2/src/uqm/ships/utwig/utwig.c +++ b/sc2/src/uqm/ships/utwig/utwig.c @@ -325,20 +325,20 @@ utwig_preprocess (ELEMENT *ElementPtr) * The current behaviour is the same as the old behavior, * but I am not sure that the old behavior was intended. - SvdB */ - static const COLOR colorTable[] = + static const Color colorTable[] = { - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7a), - //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7b), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7c), - //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7d), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7e), - //BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7f), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x2a), - //BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2b), - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2c), - BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2d), - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2e), - //BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2f), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x15, 0x00), 0x7a), + //BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x11, 0x00), 0x7b), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0E, 0x00), 0x7c), + //BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0A, 0x00), 0x7d), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x07, 0x00), 0x7e), + //BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x03, 0x00), 0x7f), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x00, 0x00), 0x2a), + //BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x00, 0x00), 0x2b), + BUILD_COLOR (MAKE_RGB15_INIT (0x17, 0x00, 0x00), 0x2c), + BUILD_COLOR (MAKE_RGB15_INIT (0x13, 0x00, 0x00), 0x2d), + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x00), 0x2e), + //BUILD_COLOR (MAKE_RGB15_INIT (0x0B, 0x00, 0x00), 0x2f), }; const size_t colorTableCount = sizeof colorTable / sizeof colorTable[0]; diff --git a/sc2/src/uqm/sis.c b/sc2/src/uqm/sis.c index 14764d962..3d0fea3ca 100644 --- a/sc2/src/uqm/sis.c +++ b/sc2/src/uqm/sis.c @@ -81,7 +81,7 @@ void ClearSISRect (BYTE ClearFlags) { RECT r; - COLOR OldColor; + Color OldColor; CONTEXT OldContext; OldContext = SetContext (StatusContext); @@ -441,7 +441,7 @@ DrawCaptainsName (void) TEXT t; CONTEXT OldContext; FONT OldFont; - COLOR OldColor; + Color OldColor; OldContext = SetContext (StatusContext); OldFont = SetContextFont (TinyFont); @@ -472,7 +472,7 @@ DrawFlagshipName (BOOLEAN InStatusArea) RECT r; TEXT t; FONT OldFont; - COLOR OldColor; + Color OldColor; CONTEXT OldContext; FRAME OldFontEffect; UNICODE buf[250]; @@ -533,7 +533,7 @@ DrawFlagshipStats (void) RECT r; TEXT t; FONT OldFont; - COLOR OldColor; + Color OldColor; FRAME OldFontEffect; CONTEXT OldContext; UNICODE buf[128]; @@ -1198,7 +1198,7 @@ GetCPodCapacity (POINT *ppt) COUNT rowNr; COUNT colNr; - static const COLOR crewRows[] = PC_CREW_COLOR_TABLE; + static const Color crewRows[] = PC_CREW_COLOR_TABLE; crewCount = GetCrewCount (); if (!GetCrewPodForCrewMember (crewCount, &slotNr, &seatNr)) @@ -1300,7 +1300,7 @@ GetSBayCapacity (POINT *ppt) COUNT rowNr; COUNT colNr; - static const COLOR colorBars[] = STORAGE_BAY_COLOR_TABLE; + static const Color colorBars[] = STORAGE_BAY_COLOR_TABLE; massCount = GetElementMass (); if (!GetStorageCellForMineralUnit (massCount, &slotNr, &cellNr)) @@ -1408,7 +1408,7 @@ GetFTankCapacity (POINT *ppt) COUNT rowNr; - static const COLOR fuelColors[] = FUEL_COLOR_TABLE; + static const Color fuelColors[] = FUEL_COLOR_TABLE; fuelAmount = GetFuelTotal (); if (!GetFuelTankForFuelUnit (fuelAmount, &slotNr, &compartmentNr)) @@ -1479,7 +1479,7 @@ DrawAutoPilotMessage (BOOLEAN Reset) static DWORD cycle_index = 0; BOOLEAN OnAutoPilot; - static const COLOR cycle_tab[] = AUTOPILOT_COLOR_CYCLE_TABLE; + static const Color cycle_tab[] = AUTOPILOT_COLOR_CYCLE_TABLE; const size_t cycleCount = sizeof cycle_tab / sizeof cycle_tab[0]; #define BLINK_RATE (ONE_SECOND * 3 / 40) // 9 @ 120 ticks/second diff --git a/sc2/src/uqm/starbase.c b/sc2/src/uqm/starbase.c index 6f1ae00e8..05af8e150 100644 --- a/sc2/src/uqm/starbase.c +++ b/sc2/src/uqm/starbase.c @@ -82,7 +82,8 @@ void DrawShipPiece (FRAME ModuleFrame, COUNT which_piece, COUNT which_slot, BOOLEAN DrawBluePrint) { - COLOR OldColor = 0; // Initialisation is to keep the compiler silent. + Color OldColor = UNDEFINED_COLOR; + // Initialisation is just to keep the compiler silent. RECT r; STAMP Side, Top; SBYTE RepairSlot; diff --git a/sc2/src/uqm/status.c b/sc2/src/uqm/status.c index 830556c15..6a588a893 100644 --- a/sc2/src/uqm/status.c +++ b/sc2/src/uqm/status.c @@ -422,19 +422,19 @@ PostProcessStatus (ELEMENT *ShipPtr) if (StarShipPtr->RaceDescPtr->ship_info.crew_level == 0) { BYTE i; - COLOR c; + Color c; RECT r; i = (BYTE)(NUM_EXPLOSION_FRAMES * 3 - 1) - ShipPtr->life_span; if (i <= 4) { - static const COLOR flash_tab0[] = + static const Color flash_tab0[] = { - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2D), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x19, 0x19), 0x24), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7B), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1C, 0x00), 0x78), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F), + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x00), 0x2D), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x19, 0x19), 0x24), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x11, 0x00), 0x7B), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1C, 0x00), 0x78), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1F, 0x1F), 0x0F), }; c = flash_tab0[i]; @@ -449,23 +449,23 @@ PostProcessStatus (ELEMENT *ShipPtr) i -= 5; if (i <= 14) { - static const COLOR flash_tab1[] = + static const Color flash_tab1[] = { - BUILD_COLOR (MAKE_RGB15 (0x1E, 0x1F, 0x12), 0x70), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x00), 0x71), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1C, 0x00), 0x78), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x18, 0x00), 0x79), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7B), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7C), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7D), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7E), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7F), - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2A), - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2B), - BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C), - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2D), + BUILD_COLOR (MAKE_RGB15_INIT (0x1E, 0x1F, 0x12), 0x70), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1F, 0x0A), 0x0E), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1F, 0x00), 0x71), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x1C, 0x00), 0x78), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x18, 0x00), 0x79), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x15, 0x00), 0x7A), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x11, 0x00), 0x7B), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0E, 0x00), 0x7C), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0A, 0x00), 0x7D), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x07, 0x00), 0x7E), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x03, 0x00), 0x7F), + BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x00, 0x00), 0x2A), + BUILD_COLOR (MAKE_RGB15_INIT (0x17, 0x00, 0x00), 0x2B), + BUILD_COLOR (MAKE_RGB15_INIT (0x13, 0x00, 0x00), 0x2C), + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x00), 0x2D), }; c = flash_tab1[i]; @@ -516,7 +516,7 @@ PostProcessStatus (ELEMENT *ShipPtr) break; default: // Should not happen. - c = 0; // Keeping compiler quiet. + c = UNDEFINED_COLOR; // Keeping compiler quiet. break; } DrawFilledRectangle (&r); @@ -531,11 +531,11 @@ PostProcessStatus (ELEMENT *ShipPtr) c = BLACK_COLOR; else { - static const COLOR flash_tab2[] = + static const Color flash_tab2[] = { - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2B), - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2D), - BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2E), + BUILD_COLOR (MAKE_RGB15_INIT (0x17, 0x00, 0x00), 0x2B), + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x00), 0x2D), + BUILD_COLOR (MAKE_RGB15_INIT (0x0B, 0x00, 0x00), 0x2E), }; c = flash_tab2[i]; diff --git a/sc2/src/uqm/tactrans.c b/sc2/src/uqm/tactrans.c index 4a795f984..da1bc8b92 100644 --- a/sc2/src/uqm/tactrans.c +++ b/sc2/src/uqm/tactrans.c @@ -583,20 +583,20 @@ ship_death (ELEMENT *ShipPtr) void cycle_ion_trail (ELEMENT *ElementPtr) { - static const COLOR colorTab[] = + static const Color colorTab[] = { - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7a), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7b), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0E, 0x00), 0x7c), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7d), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x07, 0x00), 0x7e), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7f), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x2a), - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2b), - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2c), - BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2d), - BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2e), - BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2f), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x15, 0x00), 0x7a), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x11, 0x00), 0x7b), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0E, 0x00), 0x7c), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0A, 0x00), 0x7d), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x07, 0x00), 0x7e), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x03, 0x00), 0x7f), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x00, 0x00), 0x2a), + BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x00, 0x00), 0x2b), + BUILD_COLOR (MAKE_RGB15_INIT (0x17, 0x00, 0x00), 0x2c), + BUILD_COLOR (MAKE_RGB15_INIT (0x13, 0x00, 0x00), 0x2d), + BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x00, 0x00), 0x2e), + BUILD_COLOR (MAKE_RGB15_INIT (0x0B, 0x00, 0x00), 0x2f), }; const size_t colorTabCount = sizeof colorTab / sizeof colorTab[0]; @@ -795,28 +795,28 @@ flee_preprocess (ELEMENT *ElementPtr) if (--ElementPtr->turn_wait == 0) { - static const COLOR colorTab[] = + static const Color colorTab[] = { - BUILD_COLOR (MAKE_RGB15 (0x0A, 0x00, 0x00), 0x2E), - BUILD_COLOR (MAKE_RGB15 (0x0E, 0x00, 0x00), 0x2D), - BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C), - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2B), - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2A), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x29), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x04, 0x04), 0x28), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x27), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0F, 0x0F), 0x26), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x13, 0x13), 0x25), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x19, 0x19), 0x24), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x13, 0x13), 0x25), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0F, 0x0F), 0x26), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x27), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x04, 0x04), 0x28), - BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x29), - BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2A), - BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2B), - BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C), - BUILD_COLOR (MAKE_RGB15 (0x0E, 0x00, 0x00), 0x2D), + BUILD_COLOR (MAKE_RGB15_INIT (0x0A, 0x00, 0x00), 0x2E), + BUILD_COLOR (MAKE_RGB15_INIT (0x0E, 0x00, 0x00), 0x2D), + BUILD_COLOR (MAKE_RGB15_INIT (0x13, 0x00, 0x00), 0x2C), + BUILD_COLOR (MAKE_RGB15_INIT (0x17, 0x00, 0x00), 0x2B), + BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x00, 0x00), 0x2A), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x00, 0x00), 0x29), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x04, 0x04), 0x28), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0A, 0x0A), 0x27), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0F, 0x0F), 0x26), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x13, 0x13), 0x25), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x19, 0x19), 0x24), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x13, 0x13), 0x25), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0F, 0x0F), 0x26), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x0A, 0x0A), 0x27), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x04, 0x04), 0x28), + BUILD_COLOR (MAKE_RGB15_INIT (0x1F, 0x00, 0x00), 0x29), + BUILD_COLOR (MAKE_RGB15_INIT (0x1B, 0x00, 0x00), 0x2A), + BUILD_COLOR (MAKE_RGB15_INIT (0x17, 0x00, 0x00), 0x2B), + BUILD_COLOR (MAKE_RGB15_INIT (0x13, 0x00, 0x00), 0x2C), + BUILD_COLOR (MAKE_RGB15_INIT (0x0E, 0x00, 0x00), 0x2D), }; const size_t colorTabCount = sizeof colorTab / sizeof colorTab[0]; diff --git a/sc2/src/uqm/uqmdebug.c b/sc2/src/uqm/uqmdebug.c index 8508f200c..1b41ea92c 100644 --- a/sc2/src/uqm/uqmdebug.c +++ b/sc2/src/uqm/uqmdebug.c @@ -1630,7 +1630,7 @@ dumpStrings (FILE *out) //////////////////////////////////////////////////////////////////////////// -static COLOR +static Color hsvaToRgba (double hue, double sat, double val, BYTE alpha) { unsigned int hi = (int) (hue / 60.0); @@ -1665,31 +1665,6 @@ hsvaToRgba (double hue, double sat, double val, BYTE alpha) return BUILD_COLOR_RGBA (0, 0, 0, alpha); } -// Work-around: colors returned by BUILD_COLOR_RGBA are not usable to draw -// with. -static DWORD -fixColorRgba (FRAME frame, COLOR col) -{ -#if 0 - extern DWORD frame_mapRGBA (FRAME FramePtr, BYTE r, BYTE g, BYTE b, - BYTE a); - - BYTE r = (col & 0xff000000) >> 24; - BYTE g = (col & 0x00ff0000) >> 16; - BYTE b = (col & 0x0000ff00) >> 8; - BYTE a = (col & 0x000000ff) >> 0; - - return (DWORD) frame_mapRGBA (frame, r, g, b, a); -#endif - - BYTE r = (col & 0xff000000) >> 24; - BYTE g = (col & 0x00ff0000) >> 16; - BYTE b = (col & 0x0000ff00) >> 8; - - (void) frame; - return BUILD_COLOR (MAKE_RGB15 (r >> 3, g >> 3, b >> 3) ,0); -} - // Workaround. DrawFilledRectangle() doesn't handle transparency. // We use a temporary frame to achieve the same thing. static void @@ -1700,7 +1675,7 @@ DrawFilledRectangleTransparent (RECT *rect, BYTE alpha) RECT absRect; FRAME orgRectFrame; - COLOR fillColor; + Color fillColor; // Create a rectangle from 'rect', but with (0, 0) as origin. absRect.corner.x = 0; @@ -1718,23 +1693,13 @@ DrawFilledRectangleTransparent (RECT *rect, BYTE alpha) // Apply the transparency to the colour. fillColor = GetContextForeGroundColor (); -#if 0 /* 32 bits RGBA */ - fillColor = - (((((fillColor & 0xff000000) >> 24) * alpha + 127) / 255) << 24) | - (((((fillColor & 0x00ff0000) >> 16) * alpha + 127) / 255) << 16) | - (((((fillColor & 0x0000ff00) >> 8) * alpha + 127) / 255) << 8); - */ -#endif - /* 15 bits RGB + index: */ - fillColor = - (((((fillColor & 0x007c0000) >> 18) * alpha + 15) / 31) << 18) | - (((((fillColor & 0x0003e000) >> 13) * alpha + 15) / 31) << 13) | - (((((fillColor & 0x00001f00) >> 8) * alpha + 15) / 31) << 8) | - (fillColor & 0x000000ff); + fillColor.r = (fillColor.r * alpha + 127) / 255; + fillColor.g = (fillColor.g * alpha + 127) / 255; + fillColor.b = (fillColor.b * alpha + 127) / 255; // Fill the frame with fillColor { - COLOR oldFgColor = SetContextForeGroundColor (fillColor); + Color oldFgColor = SetContextForeGroundColor (fillColor); DrawFilledRectangle (rect); SetContextForeGroundColor (oldFgColor); FlushGraphics (); @@ -1796,10 +1761,10 @@ drawContext (CONTEXT context, double hue /* no pun intended */) FRAME drawFrame; CONTEXT oldContext; FONT oldFont; - COLOR oldFgCol; - COLOR rectCol; - COLOR lineCol; - COLOR textCol; + Color oldFgCol; + Color rectCol; + Color lineCol; + Color textCol; bool haveClippingRect; RECT rect; LINE line; @@ -1807,10 +1772,8 @@ drawContext (CONTEXT context, double hue /* no pun intended */) POINT p1, p2, p3, p4; drawFrame = GetContextFGFrame (); - rectCol = (COLOR) fixColorRgba (drawFrame, - hsvaToRgba (hue, 1.0, 0.5, 127)); - lineCol = (COLOR) fixColorRgba (drawFrame, - hsvaToRgba (hue, 1.0, 1.0, 0)); + rectCol = hsvaToRgba (hue, 1.0, 0.5, 127); + lineCol = hsvaToRgba (hue, 1.0, 1.0, 0); textCol = lineCol; // Save the original context. diff --git a/sc2/src/uqm/util.c b/sc2/src/uqm/util.c index 75d30a8e4..a093177d3 100644 --- a/sc2/src/uqm/util.c +++ b/sc2/src/uqm/util.c @@ -28,8 +28,8 @@ void -DrawStarConBox (RECT *pRect, SIZE BorderWidth, COLOR TopLeftColor, COLOR - BottomRightColor, BOOLEAN FillInterior, COLOR InteriorColor) +DrawStarConBox (RECT *pRect, SIZE BorderWidth, Color TopLeftColor, + Color BottomRightColor, BOOLEAN FillInterior, Color InteriorColor) { RECT locRect; diff --git a/sc2/src/uqm/util.h b/sc2/src/uqm/util.h index b01690d2a..0e52415de 100644 --- a/sc2/src/uqm/util.h +++ b/sc2/src/uqm/util.h @@ -21,8 +21,8 @@ #include "libs/gfxlib.h" extern void DrawStarConBox (RECT *pRect, SIZE BorderWidth, - COLOR TopLeftColor, COLOR BottomRightColor, BOOLEAN FillInterior, - COLOR InteriorColor); + Color TopLeftColor, Color BottomRightColor, BOOLEAN FillInterior, + Color InteriorColor); extern DWORD SeedRandomNumbers (void); // saveRect can be NULL to save the entire context frame diff --git a/sc2/src/uqm/weapon.h b/sc2/src/uqm/weapon.h index 52fd777d2..c039fbada 100644 --- a/sc2/src/uqm/weapon.h +++ b/sc2/src/uqm/weapon.h @@ -29,7 +29,7 @@ typedef struct SIZE sender; // player number SIZE pixoffs; COUNT face; - COLOR color; + Color color; } LASER_BLOCK; typedef struct