From: <Mee...@us...> - 2009-11-28 20:43:15
|
Revision: 3365 http://sc2.svn.sourceforge.net/sc2/?rev=3365&view=rev Author: Meep-Eep Date: 2009-11-28 20:43:08 +0000 (Sat, 28 Nov 2009) Log Message: ----------- Remove another dependency on the VGA palette index in COLOR. Modified Paths: -------------- trunk/sc2/src/uqm/ships/orz/orz.c trunk/sc2/src/uqm/tactrans.c Modified: trunk/sc2/src/uqm/ships/orz/orz.c =================================================================== --- trunk/sc2/src/uqm/ships/orz/orz.c 2009-11-28 20:03:05 UTC (rev 3364) +++ trunk/sc2/src/uqm/ships/orz/orz.c 2009-11-28 20:43:08 UTC (rev 3365) @@ -311,46 +311,38 @@ #define START_ION_COLOR BUILD_COLOR (MAKE_RGB15 (0x1F, 0x15, 0x00), 0x7A) -void +static void ion_preprocess (ELEMENT *ElementPtr) { - static const COLOR color_tab[] = + /* Originally, this table also contained the now commented out + * 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[] = { - 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, 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, 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])) - - COUNT color_index = 0; - COLOR Color; + const size_t colorTabCount = sizeof colorTable / sizeof colorTable[0]; - Color = COLOR_256 (GetPrimColor (&(GLOBAL (DisplayArray))[ - ElementPtr->PrimIndex])); - if (Color != 0x2D) + ElementPtr->colorCycleIndex++; + if (ElementPtr->colorCycleIndex != colorTabCount) { ElementPtr->life_span = ElementPtr->thrust_wait; - Color += 2; - if (Color > 0x7F) - Color = 0x2B; - else if (Color == 0x7E) - Color = 0x7F; - 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 (&(GLOBAL (DisplayArray))[ - ElementPtr->PrimIndex], color_tab[color_index]); + SetPrimColor (&(GLOBAL (DisplayArray))[ElementPtr->PrimIndex], + colorTable[ElementPtr->colorCycleIndex]); ElementPtr->state_flags &= ~DISAPPEARING; ElementPtr->state_flags |= CHANGING; @@ -472,7 +464,60 @@ } } +// XXX: merge this with spawn_ion_trail from tactrans.c? static void +spawn_marine_ion_trail (ELEMENT *ElementPtr, STARSHIP *StarShipPtr, + COUNT facing) +{ + HELEMENT hIonElement; + + hIonElement = AllocElement (); + if (hIonElement) + { +#define ION_LIFE 1 + COUNT angle; + ELEMENT *IonElementPtr; + + angle = FACING_TO_ANGLE (facing) + HALF_CIRCLE; + + InsertElement (hIonElement, GetHeadElement ()); + LockElement (hIonElement, &IonElementPtr); + IonElementPtr->playerNr = NEUTRAL_PLAYER_NUM; + IonElementPtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID; + 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 (&(GLOBAL (DisplayArray))[IonElementPtr->PrimIndex], + POINT_PRIM); + SetPrimColor (&(GLOBAL (DisplayArray))[IonElementPtr->PrimIndex], + START_ION_COLOR); + IonElementPtr->colorCycleIndex = 0; + IonElementPtr->current.location = ElementPtr->current.location; + IonElementPtr->current.location.x += + (COORD)COSINE (angle, DISPLAY_TO_WORLD (2)); + IonElementPtr->current.location.y += + (COORD)SINE (angle, DISPLAY_TO_WORLD (2)); + IonElementPtr->death_func = ion_preprocess; + + 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); + } +} + +static void marine_preprocess (ELEMENT *ElementPtr) { ELEMENT *ShipPtr; @@ -668,50 +713,7 @@ || !(thrust_status & (SHIP_AT_MAX_SPEED | SHIP_BEYOND_MAX_SPEED))) { - HELEMENT hIonElement; - - hIonElement = AllocElement (); - if (hIonElement) - { -#define ION_LIFE 1 - COUNT angle; - ELEMENT *IonElementPtr; - - angle = FACING_TO_ANGLE (facing) + HALF_CIRCLE; - - InsertElement (hIonElement, GetHeadElement ()); - LockElement (hIonElement, &IonElementPtr); - IonElementPtr->playerNr = NEUTRAL_PLAYER_NUM; - IonElementPtr->state_flags = - APPEARING | FINITE_LIFE | NONSOLID; - IonElementPtr->life_span = - IonElementPtr->thrust_wait = ION_LIFE; - SetPrimType (&(GLOBAL (DisplayArray))[ - IonElementPtr->PrimIndex], POINT_PRIM); - SetPrimColor (&(GLOBAL (DisplayArray))[ - IonElementPtr->PrimIndex], START_ION_COLOR); - IonElementPtr->current.location = - ElementPtr->current.location; - IonElementPtr->current.location.x += - (COORD)COSINE (angle, DISPLAY_TO_WORLD (2)); - IonElementPtr->current.location.y += - (COORD)SINE (angle, DISPLAY_TO_WORLD (2)); - IonElementPtr->death_func = ion_preprocess; - - 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); - } + spawn_marine_ion_trail (ElementPtr, StarShipPtr, facing); } // XXX: thrust_wait is abused to store marine speed and @@ -1041,9 +1043,10 @@ TurretPtr->playerNr = ElementPtr->playerNr; TurretPtr->state_flags = FINITE_LIFE | NONSOLID | IGNORE_SIMILAR; TurretPtr->life_span = 1; - TurretPtr->current.image.farray = StarShipPtr->RaceDescPtr->ship_data.special; - TurretPtr->current.image.frame = - SetAbsFrameIndex (StarShipPtr->RaceDescPtr->ship_data.special[0], + TurretPtr->current.image.farray = + StarShipPtr->RaceDescPtr->ship_data.special; + TurretPtr->current.image.frame = SetAbsFrameIndex ( + StarShipPtr->RaceDescPtr->ship_data.special[0], StarShipPtr->ShipFacing); TurretPtr->postprocess_func = turret_postprocess; Modified: trunk/sc2/src/uqm/tactrans.c =================================================================== --- trunk/sc2/src/uqm/tactrans.c 2009-11-28 20:03:05 UTC (rev 3364) +++ trunk/sc2/src/uqm/tactrans.c 2009-11-28 20:43:08 UTC (rev 3365) @@ -663,10 +663,10 @@ 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. - */ + /* 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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |