Remove another dependency on the VGA register field in a COLOR.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3359 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
Meep-Eep
2009-11-28 16:23:36 +00:00
parent e3862aefcd
commit c0481ea13c
3 changed files with 39 additions and 33 deletions
+5 -1
View File
@@ -88,7 +88,8 @@ DoRunAway (STARSHIP *StarShipPtr)
battle_counter[0]--;
ElementPtr->turn_wait = 3;
ElementPtr->thrust_wait = MAKE_BYTE (4, 0);
ElementPtr->thrust_wait = 4;
ElementPtr->colorCycleIndex = 0;
ElementPtr->preprocess_func = flee_preprocess;
ElementPtr->mass_points = MAX_SHIP_MASS * 10;
ZeroVelocityComponents (&ElementPtr->velocity);
@@ -97,6 +98,9 @@ DoRunAway (STARSHIP *StarShipPtr)
SetPrimColor (&DisplayArray[ElementPtr->PrimIndex],
BUILD_COLOR (MAKE_RGB15 (0x0B, 0x00, 0x00), 0x2E));
// XXX: I think this is supposed to be the same as the
// first entry of the color cycle table in flee_preeprocess,
// but it is slightly different (0x0A as red value). - SvdB.
SetPrimType (&DisplayArray[ElementPtr->PrimIndex], STAMPFILL_PRIM);
StarShipPtr->ship_input_state = 0;
+4 -3
View File
@@ -124,9 +124,7 @@ struct element
COUNT hit_points;
COUNT facing; /* Planetside: lava-spot direction of travel */
COUNT cycle;
/* Planetside: lightning cycle length
* Melee: color cycle index of ion trails and warp shadows
*/
/* Planetside: lightning cycle length */
};
union
{
@@ -145,6 +143,9 @@ struct element
BYTE blast_offset;
BYTE next_turn; /* Battle: animation interframe for some elements */
};
BYTE colorCycleIndex;
// Melee: used to cycle ion trails and warp shadows, and
// to cycle the ship color when fleeing.
VELOCITY_DESC velocity;
INTERSECT_CONTROL IntersectControl;
+30 -29
View File
@@ -583,7 +583,7 @@ ship_death (ELEMENT *ShipPtr)
void
cycle_ion_trail (ELEMENT *ElementPtr)
{
static const COLOR color_tab[] =
static const COLOR colorTab[] =
{
BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7a),
BUILD_COLOR (MAKE_RGB15 (0x1F, 0x11, 0x00), 0x7b),
@@ -598,18 +598,18 @@ cycle_ion_trail (ELEMENT *ElementPtr)
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])
const size_t colorTabCount = sizeof colorTab / sizeof colorTab[0];
assert (!(ElementPtr->state_flags & PLAYER_SHIP));
ElementPtr->cycle++;
if (ElementPtr->cycle != NUM_TAB_COLORS)
ElementPtr->colorCycleIndex++;
if (ElementPtr->colorCycleIndex != colorTabCount)
{
ElementPtr->life_span = ElementPtr->thrust_wait;
// Reset the life span.
SetPrimColor (&DisplayArray[ElementPtr->PrimIndex],
color_tab[ElementPtr->cycle]);
colorTab[ElementPtr->colorCycleIndex]);
ElementPtr->state_flags &= ~DISAPPEARING;
ElementPtr->state_flags |= CHANGING;
@@ -649,7 +649,7 @@ spawn_ion_trail (ELEMENT *ElementPtr)
SetPrimType (&DisplayArray[IonElementPtr->PrimIndex], POINT_PRIM);
SetPrimColor (&DisplayArray[IonElementPtr->PrimIndex],
START_ION_COLOR);
IonElementPtr->cycle = 0;
IonElementPtr->colorCycleIndex = 0;
IonElementPtr->current.image.frame =
DecFrameIndex (stars_in_space);
IonElementPtr->current.image.farray = &stars_in_space;
@@ -752,7 +752,7 @@ ship_transition (ELEMENT *ElementPtr)
STAMPFILL_PRIM);
SetPrimColor (&DisplayArray[ShipImagePtr->PrimIndex],
START_ION_COLOR);
ShipImagePtr->cycle = 0;
ShipImagePtr->colorCycleIndex = 0;
ShipImagePtr->current.image = ElementPtr->current.image;
ShipImagePtr->current.location = ElementPtr->current.location;
if (!(ElementPtr->state_flags & PLAYER_SHIP))
@@ -795,10 +795,18 @@ flee_preprocess (ELEMENT *ElementPtr)
if (--ElementPtr->turn_wait == 0)
{
SIZE dir;
COLOR c;
static const COLOR color_tab[] =
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),
@@ -809,34 +817,26 @@ flee_preprocess (ELEMENT *ElementPtr)
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 (0x0A, 0x00, 0x00), 0x2E),
};
const size_t colorTabCount = sizeof colorTab / sizeof colorTab[0];
dir = HINIBBLE (ElementPtr->thrust_wait) - 1;
ElementPtr->colorCycleIndex++;
if (ElementPtr->colorCycleIndex == colorTabCount)
ElementPtr->colorCycleIndex = 0;
c = COLOR_256 (GetPrimColor (&DisplayArray[ElementPtr->PrimIndex]));
if (c == 0x24)
dir = -dir;
c += dir;
c = color_tab[c - 0x24];
SetPrimColor (&DisplayArray[ElementPtr->PrimIndex], c);
SetPrimColor (&DisplayArray[ElementPtr->PrimIndex],
colorTab[ElementPtr->colorCycleIndex]);
if (COLOR_256 (c) == 0x2E)
{
dir = -dir;
if (ElementPtr->colorCycleIndex == 0)
--ElementPtr->thrust_wait;
}
dir += 1;
ElementPtr->turn_wait = LONIBBLE (ElementPtr->thrust_wait);
ElementPtr->turn_wait = ElementPtr->thrust_wait;
if (ElementPtr->turn_wait)
{
ElementPtr->thrust_wait = MAKE_BYTE (ElementPtr->turn_wait, dir);
ElementPtr->turn_wait = ((ElementPtr->turn_wait - 1) >> 1) + 1;
}
else if (COLOR_256 (c) != 0x24)
else if (ElementPtr->colorCycleIndex != (colorTabCount / 2))
{
ElementPtr->thrust_wait = MAKE_BYTE (0, dir);
ElementPtr->turn_wait = 1;
}
else
@@ -853,7 +853,8 @@ flee_preprocess (ELEMENT *ElementPtr)
}
GetElementStarShip (ElementPtr, &StarShipPtr);
StarShipPtr->cur_status_flags
&= ~(LEFT | RIGHT | THRUST | WEAPON | SPECIAL);
StarShipPtr->cur_status_flags &=
~(LEFT | RIGHT | THRUST | WEAPON | SPECIAL);
// Ignore control input when fleeing.
PreProcessStatus (ElementPtr);
}