Get rid of one abuse of the vga palette index of a COLOR to store state.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3358 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -123,7 +123,10 @@ struct element
|
||||
COUNT crew_level;
|
||||
COUNT hit_points;
|
||||
COUNT facing; /* Planetside: lava-spot direction of travel */
|
||||
COUNT cycle; /* Planetside: lightning cycle length */
|
||||
COUNT cycle;
|
||||
/* Planetside: lightning cycle length
|
||||
* Melee: color cycle index of ion trails and warp shadows
|
||||
*/
|
||||
};
|
||||
union
|
||||
{
|
||||
|
||||
+54
-50
@@ -578,14 +578,51 @@ ship_death (ELEMENT *ShipPtr)
|
||||
|
||||
#define START_ION_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A)
|
||||
|
||||
// Called from the death_func of an element for an ion trail pixel, or a
|
||||
// ship shadow (when warping in/out).
|
||||
void
|
||||
cycle_ion_trail (ELEMENT *ElementPtr)
|
||||
{
|
||||
static const COLOR color_tab[] =
|
||||
{
|
||||
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),
|
||||
};
|
||||
#define NUM_TAB_COLORS (sizeof color_tab / sizeof color_tab[0])
|
||||
|
||||
assert (!(ElementPtr->state_flags & PLAYER_SHIP));
|
||||
|
||||
ElementPtr->cycle++;
|
||||
if (ElementPtr->cycle != NUM_TAB_COLORS)
|
||||
{
|
||||
ElementPtr->life_span = ElementPtr->thrust_wait;
|
||||
// Reset the life span.
|
||||
|
||||
SetPrimColor (&DisplayArray[ElementPtr->PrimIndex],
|
||||
color_tab[ElementPtr->cycle]);
|
||||
|
||||
ElementPtr->state_flags &= ~DISAPPEARING;
|
||||
ElementPtr->state_flags |= CHANGING;
|
||||
} // else, the element disappears.
|
||||
}
|
||||
|
||||
void
|
||||
spawn_ion_trail (ELEMENT *ElementPtr)
|
||||
{
|
||||
|
||||
if (ElementPtr->state_flags & PLAYER_SHIP)
|
||||
{
|
||||
HELEMENT hIonElement;
|
||||
|
||||
assert (ElementPtr->state_flags & PLAYER_SHIP);
|
||||
|
||||
hIonElement = AllocElement ();
|
||||
if (hIonElement)
|
||||
{
|
||||
@@ -604,10 +641,15 @@ spawn_ion_trail (ELEMENT *ElementPtr)
|
||||
LockElement (hIonElement, &IonElementPtr);
|
||||
IonElementPtr->playerNr = NEUTRAL_PLAYER_NUM;
|
||||
IonElementPtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID;
|
||||
IonElementPtr->life_span = IonElementPtr->thrust_wait = ION_LIFE;
|
||||
IonElementPtr->thrust_wait = ION_LIFE;
|
||||
IonElementPtr->life_span = IonElementPtr->thrust_wait;
|
||||
// When the element "dies", in the death_func
|
||||
// 'cycle_ion_trail', it is given new life a number of
|
||||
// times, by setting life_span to thrust_wait.
|
||||
SetPrimType (&DisplayArray[IonElementPtr->PrimIndex], POINT_PRIM);
|
||||
SetPrimColor (&DisplayArray[IonElementPtr->PrimIndex],
|
||||
START_ION_COLOR);
|
||||
IonElementPtr->cycle = 0;
|
||||
IonElementPtr->current.image.frame =
|
||||
DecFrameIndex (stars_in_space);
|
||||
IonElementPtr->current.image.farray = &stars_in_space;
|
||||
@@ -616,7 +658,7 @@ spawn_ion_trail (ELEMENT *ElementPtr)
|
||||
(COORD)COSINE (angle, r.extent.height);
|
||||
IonElementPtr->current.location.y +=
|
||||
(COORD)SINE (angle, r.extent.height);
|
||||
IonElementPtr->death_func = spawn_ion_trail;
|
||||
IonElementPtr->death_func = cycle_ion_trail;
|
||||
|
||||
SetElementStarShip (IonElementPtr, StarShipPtr);
|
||||
|
||||
@@ -632,48 +674,6 @@ spawn_ion_trail (ELEMENT *ElementPtr)
|
||||
|
||||
UnlockElement (hIonElement);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static const COLOR color_tab[] =
|
||||
{
|
||||
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 (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),
|
||||
};
|
||||
#define NUM_TAB_COLORS (sizeof (color_tab) / sizeof (color_tab[0]))
|
||||
|
||||
COUNT color_index = 0;
|
||||
COLOR Color;
|
||||
|
||||
Color = COLOR_256 (GetPrimColor (&DisplayArray[ElementPtr->PrimIndex]));
|
||||
if (Color != 0x2F)
|
||||
{
|
||||
ElementPtr->life_span = ElementPtr->thrust_wait;
|
||||
|
||||
++Color;
|
||||
if (Color > 0x7F)
|
||||
Color = 0x2A;
|
||||
if (Color <= 0x2f && Color >= 0x2a)
|
||||
color_index = (COUNT)Color - 0x2a;
|
||||
else /* color is between 0x7a and 0x7f */
|
||||
color_index = (COUNT)(Color - 0x7a) + (NUM_TAB_COLORS >> 1);
|
||||
SetPrimColor (&DisplayArray[ElementPtr->PrimIndex],
|
||||
color_tab[color_index]);
|
||||
|
||||
ElementPtr->state_flags &= ~DISAPPEARING;
|
||||
ElementPtr->state_flags |= CHANGING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Preprocess function for spawning a ship into or out of battle.
|
||||
@@ -743,12 +743,16 @@ ship_transition (ELEMENT *ElementPtr)
|
||||
LockElement (hShipImage, &ShipImagePtr);
|
||||
ShipImagePtr->playerNr = NEUTRAL_PLAYER_NUM;
|
||||
ShipImagePtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID;
|
||||
ShipImagePtr->life_span = ShipImagePtr->thrust_wait =
|
||||
TRANSITION_LIFE;
|
||||
ShipImagePtr->thrust_wait = TRANSITION_LIFE;
|
||||
ShipImagePtr->life_span = ShipImagePtr->thrust_wait;
|
||||
// When the element "dies", in the death_func
|
||||
// 'cycle_ion_trail', it is given new life a number of
|
||||
// times, by setting life_span to thrust_wait.
|
||||
SetPrimType (&DisplayArray[ShipImagePtr->PrimIndex],
|
||||
STAMPFILL_PRIM);
|
||||
SetPrimColor (&DisplayArray[ShipImagePtr->PrimIndex],
|
||||
START_ION_COLOR);
|
||||
ShipImagePtr->cycle = 0;
|
||||
ShipImagePtr->current.image = ElementPtr->current.image;
|
||||
ShipImagePtr->current.location = ElementPtr->current.location;
|
||||
if (!(ElementPtr->state_flags & PLAYER_SHIP))
|
||||
@@ -774,7 +778,7 @@ ship_transition (ELEMENT *ElementPtr)
|
||||
WRAP_Y (ShipImagePtr->current.location.y);
|
||||
}
|
||||
ShipImagePtr->preprocess_func = ship_transition;
|
||||
ShipImagePtr->death_func = spawn_ion_trail;
|
||||
ShipImagePtr->death_func = cycle_ion_trail;
|
||||
SetElementStarShip (ShipImagePtr, StarShipPtr);
|
||||
|
||||
UnlockElement (hShipImage);
|
||||
|
||||
Reference in New Issue
Block a user