From: <Mee...@us...> - 2009-11-28 16:23:45
|
Revision: 3359 http://sc2.svn.sourceforge.net/sc2/?rev=3359&view=rev Author: Meep-Eep Date: 2009-11-28 16:23:36 +0000 (Sat, 28 Nov 2009) Log Message: ----------- Remove another dependency on the VGA register field in a COLOR. Modified Paths: -------------- trunk/sc2/src/uqm/battle.c trunk/sc2/src/uqm/element.h trunk/sc2/src/uqm/tactrans.c Modified: trunk/sc2/src/uqm/battle.c =================================================================== --- trunk/sc2/src/uqm/battle.c 2009-11-28 15:07:38 UTC (rev 3358) +++ trunk/sc2/src/uqm/battle.c 2009-11-28 16:23:36 UTC (rev 3359) @@ -88,7 +88,8 @@ 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 @@ 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; Modified: trunk/sc2/src/uqm/element.h =================================================================== --- trunk/sc2/src/uqm/element.h 2009-11-28 15:07:38 UTC (rev 3358) +++ trunk/sc2/src/uqm/element.h 2009-11-28 16:23:36 UTC (rev 3359) @@ -124,9 +124,7 @@ 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 @@ 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; Modified: trunk/sc2/src/uqm/tactrans.c =================================================================== --- trunk/sc2/src/uqm/tactrans.c 2009-11-28 15:07:38 UTC (rev 3358) +++ trunk/sc2/src/uqm/tactrans.c 2009-11-28 16:23:36 UTC (rev 3359) @@ -583,7 +583,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |