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 crew_level;
|
||||||
COUNT hit_points;
|
COUNT hit_points;
|
||||||
COUNT facing; /* Planetside: lava-spot direction of travel */
|
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
|
union
|
||||||
{
|
{
|
||||||
|
|||||||
+90
-86
@@ -578,101 +578,101 @@ ship_death (ELEMENT *ShipPtr)
|
|||||||
|
|
||||||
#define START_ION_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A)
|
#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
|
void
|
||||||
spawn_ion_trail (ELEMENT *ElementPtr)
|
spawn_ion_trail (ELEMENT *ElementPtr)
|
||||||
{
|
{
|
||||||
|
HELEMENT hIonElement;
|
||||||
|
|
||||||
if (ElementPtr->state_flags & PLAYER_SHIP)
|
assert (ElementPtr->state_flags & PLAYER_SHIP);
|
||||||
|
|
||||||
|
hIonElement = AllocElement ();
|
||||||
|
if (hIonElement)
|
||||||
{
|
{
|
||||||
HELEMENT hIonElement;
|
|
||||||
|
|
||||||
hIonElement = AllocElement ();
|
|
||||||
if (hIonElement)
|
|
||||||
{
|
|
||||||
#define ION_LIFE 1
|
#define ION_LIFE 1
|
||||||
COUNT angle;
|
COUNT angle;
|
||||||
RECT r;
|
RECT r;
|
||||||
ELEMENT *IonElementPtr;
|
ELEMENT *IonElementPtr;
|
||||||
STARSHIP *StarShipPtr;
|
STARSHIP *StarShipPtr;
|
||||||
|
|
||||||
GetElementStarShip (ElementPtr, &StarShipPtr);
|
GetElementStarShip (ElementPtr, &StarShipPtr);
|
||||||
angle = FACING_TO_ANGLE (StarShipPtr->ShipFacing) + HALF_CIRCLE;
|
angle = FACING_TO_ANGLE (StarShipPtr->ShipFacing) + HALF_CIRCLE;
|
||||||
GetFrameRect (StarShipPtr->RaceDescPtr->ship_data.ship[0], &r);
|
GetFrameRect (StarShipPtr->RaceDescPtr->ship_data.ship[0], &r);
|
||||||
r.extent.height = DISPLAY_TO_WORLD (r.extent.height + r.corner.y);
|
r.extent.height = DISPLAY_TO_WORLD (r.extent.height + r.corner.y);
|
||||||
|
|
||||||
InsertElement (hIonElement, GetHeadElement ());
|
InsertElement (hIonElement, GetHeadElement ());
|
||||||
LockElement (hIonElement, &IonElementPtr);
|
LockElement (hIonElement, &IonElementPtr);
|
||||||
IonElementPtr->playerNr = NEUTRAL_PLAYER_NUM;
|
IonElementPtr->playerNr = NEUTRAL_PLAYER_NUM;
|
||||||
IonElementPtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID;
|
IonElementPtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID;
|
||||||
IonElementPtr->life_span = IonElementPtr->thrust_wait = ION_LIFE;
|
IonElementPtr->thrust_wait = ION_LIFE;
|
||||||
SetPrimType (&DisplayArray[IonElementPtr->PrimIndex], POINT_PRIM);
|
IonElementPtr->life_span = IonElementPtr->thrust_wait;
|
||||||
SetPrimColor (&DisplayArray[IonElementPtr->PrimIndex],
|
// When the element "dies", in the death_func
|
||||||
START_ION_COLOR);
|
// 'cycle_ion_trail', it is given new life a number of
|
||||||
IonElementPtr->current.image.frame =
|
// times, by setting life_span to thrust_wait.
|
||||||
DecFrameIndex (stars_in_space);
|
SetPrimType (&DisplayArray[IonElementPtr->PrimIndex], POINT_PRIM);
|
||||||
IonElementPtr->current.image.farray = &stars_in_space;
|
SetPrimColor (&DisplayArray[IonElementPtr->PrimIndex],
|
||||||
IonElementPtr->current.location = ElementPtr->current.location;
|
START_ION_COLOR);
|
||||||
IonElementPtr->current.location.x +=
|
IonElementPtr->cycle = 0;
|
||||||
(COORD)COSINE (angle, r.extent.height);
|
IonElementPtr->current.image.frame =
|
||||||
IonElementPtr->current.location.y +=
|
DecFrameIndex (stars_in_space);
|
||||||
(COORD)SINE (angle, r.extent.height);
|
IonElementPtr->current.image.farray = &stars_in_space;
|
||||||
IonElementPtr->death_func = spawn_ion_trail;
|
IonElementPtr->current.location = ElementPtr->current.location;
|
||||||
|
IonElementPtr->current.location.x +=
|
||||||
|
(COORD)COSINE (angle, r.extent.height);
|
||||||
|
IonElementPtr->current.location.y +=
|
||||||
|
(COORD)SINE (angle, r.extent.height);
|
||||||
|
IonElementPtr->death_func = cycle_ion_trail;
|
||||||
|
|
||||||
SetElementStarShip (IonElementPtr, StarShipPtr);
|
SetElementStarShip (IonElementPtr, StarShipPtr);
|
||||||
|
|
||||||
{
|
|
||||||
/* normally done during preprocess, but because
|
|
||||||
* object is being inserted at head rather than
|
|
||||||
* appended after tail it may never get preprocessed.
|
|
||||||
*/
|
|
||||||
IonElementPtr->next = IonElementPtr->current;
|
|
||||||
--IonElementPtr->life_span;
|
|
||||||
IonElementPtr->state_flags |= PRE_PROCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
UnlockElement (hIonElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
static const COLOR color_tab[] =
|
|
||||||
{
|
{
|
||||||
BUILD_COLOR (MAKE_RGB15 (0x1F, 0x00, 0x00), 0x2a),
|
/* normally done during preprocess, but because
|
||||||
BUILD_COLOR (MAKE_RGB15 (0x1B, 0x00, 0x00), 0x2b),
|
* object is being inserted at head rather than
|
||||||
BUILD_COLOR (MAKE_RGB15 (0x17, 0x00, 0x00), 0x2c),
|
* appended after tail it may never get preprocessed.
|
||||||
BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2d),
|
*/
|
||||||
BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2e),
|
IonElementPtr->next = IonElementPtr->current;
|
||||||
BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2f),
|
--IonElementPtr->life_span;
|
||||||
BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7a),
|
IonElementPtr->state_flags |= PRE_PROCESS;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnlockElement (hIonElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -743,12 +743,16 @@ ship_transition (ELEMENT *ElementPtr)
|
|||||||
LockElement (hShipImage, &ShipImagePtr);
|
LockElement (hShipImage, &ShipImagePtr);
|
||||||
ShipImagePtr->playerNr = NEUTRAL_PLAYER_NUM;
|
ShipImagePtr->playerNr = NEUTRAL_PLAYER_NUM;
|
||||||
ShipImagePtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID;
|
ShipImagePtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID;
|
||||||
ShipImagePtr->life_span = ShipImagePtr->thrust_wait =
|
ShipImagePtr->thrust_wait = TRANSITION_LIFE;
|
||||||
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],
|
SetPrimType (&DisplayArray[ShipImagePtr->PrimIndex],
|
||||||
STAMPFILL_PRIM);
|
STAMPFILL_PRIM);
|
||||||
SetPrimColor (&DisplayArray[ShipImagePtr->PrimIndex],
|
SetPrimColor (&DisplayArray[ShipImagePtr->PrimIndex],
|
||||||
START_ION_COLOR);
|
START_ION_COLOR);
|
||||||
|
ShipImagePtr->cycle = 0;
|
||||||
ShipImagePtr->current.image = ElementPtr->current.image;
|
ShipImagePtr->current.image = ElementPtr->current.image;
|
||||||
ShipImagePtr->current.location = ElementPtr->current.location;
|
ShipImagePtr->current.location = ElementPtr->current.location;
|
||||||
if (!(ElementPtr->state_flags & PLAYER_SHIP))
|
if (!(ElementPtr->state_flags & PLAYER_SHIP))
|
||||||
@@ -774,7 +778,7 @@ ship_transition (ELEMENT *ElementPtr)
|
|||||||
WRAP_Y (ShipImagePtr->current.location.y);
|
WRAP_Y (ShipImagePtr->current.location.y);
|
||||||
}
|
}
|
||||||
ShipImagePtr->preprocess_func = ship_transition;
|
ShipImagePtr->preprocess_func = ship_transition;
|
||||||
ShipImagePtr->death_func = spawn_ion_trail;
|
ShipImagePtr->death_func = cycle_ion_trail;
|
||||||
SetElementStarShip (ShipImagePtr, StarShipPtr);
|
SetElementStarShip (ShipImagePtr, StarShipPtr);
|
||||||
|
|
||||||
UnlockElement (hShipImage);
|
UnlockElement (hShipImage);
|
||||||
|
|||||||
Reference in New Issue
Block a user