diff --git a/code/redalert/externs.h b/code/redalert/externs.h index 762635e..9d56160 100644 --- a/code/redalert/externs.h +++ b/code/redalert/externs.h @@ -323,7 +323,7 @@ extern HouseClass * PlayerPtr; extern PaletteClass CCPalette; extern void* CCGlobalOveridePalette; extern int CCPaletteHouseColor; -extern float HouseRGBColors[8][3]; +extern HSVClass HSVColors[8]; extern PaletteClass BlackPalette; extern PaletteClass WhitePalette; extern PaletteClass GamePalette; diff --git a/code/redalert/globals.cpp b/code/redalert/globals.cpp index c2931f8..de208a7 100644 --- a/code/redalert/globals.cpp +++ b/code/redalert/globals.cpp @@ -559,18 +559,17 @@ PaletteClass WhitePalette(RGBClass(RGBClass::MAX_VALUE, RGBClass::MAX_VALUE, RGB PaletteClass OriginalPalette; PaletteClass ScorePalette; -float HouseRGBColors[8][3] = { - { 255.0f, 223.0f, 94.0f }, - {160,164,200 }, // Allies Blue - {255.0f, 20.0f, 20.0f }, - {140, 244, 140 }, // Green - {255.0f, 155.0f, 0.0f}, - {92, 192, 164}, - {204, 184, 176}, - {170, 93, 71} +HSVClass HSVColors[8] = { + HSVClass(34, 128, 255), // Gold + HSVClass(164,140,255), // Light Blue + HSVClass(0,235,255), // Red + HSVClass(85,70,255), // light Green + HSVClass(25,230,255), // orange + HSVClass(85,235,150), // dark green + HSVClass(0, 0, 131), + HSVClass(0,180,150) }; - /*************************************************************************** ** These are the event queues. One is for holding events until they are ready to be ** sent to the remote computer for processing. The other list is for incoming events diff --git a/code/redalert/hsv.cpp b/code/redalert/hsv.cpp index e0862a4..edaccec 100644 --- a/code/redalert/hsv.cpp +++ b/code/redalert/hsv.cpp @@ -39,6 +39,7 @@ #include "watcom.h" #include "hsv.h" #include "rgb.h" +#include HSVClass const HSVClass::BlackColor(0, 0, 0); @@ -206,3 +207,27 @@ void HSVClass::Set(int color) const RGBClass rgb = *this; rgb.Set(color); } + +RGBClass GetHSVHouseColor(HSVClass& hsv, int index) +{ + int hue = hsv.Hue_Component(); + int sat = hsv.Saturation_Component(); + int val = hsv.Value_Component(); + + double satd = sat; + double vald = val; + + double cosval = index * 0.08144869842640204 + 0.3490658503988659;// 4.666666666 + 20 as deg + double sinval = index * 0.04654211338651545 + 0.8726646259971648;// 2.666666666 + 49.99999999 as deg + if (index == 0) { + cosval = 0.1963495408493621;// (PI/ 16) 11.25 as deg, or DEG2RAD(180 / 16) + } + + double satsin = sin(sinval); + double valcos = cos(cosval); + + HSVClass temp(hue, satsin * satd, valcos * vald); + RGBClass color = temp; + + return color; +} \ No newline at end of file diff --git a/code/redalert/hsv.h b/code/redalert/hsv.h index 17c4ccc..22e1f4c 100644 --- a/code/redalert/hsv.h +++ b/code/redalert/hsv.h @@ -75,4 +75,6 @@ class HSVClass unsigned char Value; }; +RGBClass GetHSVHouseColor(HSVClass& hsv, int index); + #endif diff --git a/code/redalert/winstub.cpp b/code/redalert/winstub.cpp index b608296..94661e9 100644 --- a/code/redalert/winstub.cpp +++ b/code/redalert/winstub.cpp @@ -520,9 +520,11 @@ Image_t* Image_CreateImageFrom8Bit(const char* name, int Width, int Height, unsi if (c >= 0x10 && c <= 0x1f) { float greyscale = r / 255.0f; - r = HouseRGBColors[CCPaletteHouseColor][0] * greyscale; - g = HouseRGBColors[CCPaletteHouseColor][1] * greyscale; - b = HouseRGBColors[CCPaletteHouseColor][2] * greyscale; + RGBClass remap = GetHSVHouseColor(HSVColors[CCPaletteHouseColor], c - 0x10); + + r = remap.GetRawRed() << 2; + g = remap.GetRawGreen() << 2; + b = remap.GetRawBlue() << 2; a = 0; } }