git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1834 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
meep-eep
2005-07-10 00:17:12 +00:00
parent db2ec77dcf
commit ca84db6414
+157 -160
View File
@@ -59,11 +59,59 @@ MUSIC_REF SpaceMusic;
#define GRAB_BKGND (1 << 7) #define GRAB_BKGND (1 << 7)
static SIZE old_radius; static SIZE old_radius;
BYTE draw_sys_flags = DRAW_STARS BYTE draw_sys_flags = DRAW_STARS | DRAW_PLANETS | DRAW_ORBITS
| DRAW_PLANETS | DRAW_HYPER_COORDS | GRAB_BKGND;
| DRAW_ORBITS
| DRAW_HYPER_COORDS static void
| GRAB_BKGND; GeneratePlanets (void)
{
COUNT i;
PPLANET_DESC pCurDesc;
for (i = pSolarSysState->SunDesc[0].NumPlanets,
pCurDesc = &pSolarSysState->PlanetDesc[0]; i;
--i, ++pCurDesc)
{
DWORD rand_val;
BYTE byte_val;
BYTE num_moons;
BYTE type;
rand_val = TFB_Random ();
byte_val = LOBYTE (rand_val);
num_moons = 0;
type = PlanData[pCurDesc->data_index & ~PLANET_SHIELDED].Type;
switch (PLANSIZE (type))
{
case LARGE_ROCKY_WORLD:
if (byte_val < 0x00FF * 25 / 100)
{
if (byte_val < 0x00FF * 5 / 100)
++num_moons;
++num_moons;
}
break;
case GAS_GIANT:
if (byte_val < 0x00FF * 90 / 100)
{
if (byte_val < 0x00FF * 75 / 100)
{
if (byte_val < 0x00FF * 50 / 100)
{
if (byte_val < 0x00FF * 25 / 100)
++num_moons;
++num_moons;
}
++num_moons;
}
++num_moons;
}
break;
}
pCurDesc->NumPlanets = num_moons;
}
}
static void static void
GenerateMoons (void) GenerateMoons (void)
@@ -103,17 +151,17 @@ GenerateMoons (void)
pMoonDesc->temp_color = pCurDesc->temp_color; pMoonDesc->temp_color = pCurDesc->temp_color;
data_index = pMoonDesc->data_index; data_index = pMoonDesc->data_index;
/* Starbase */
if (data_index == (BYTE)~0) if (data_index == (BYTE)~0)
{ {
pMoonDesc->image.frame = SetAbsFrameIndex ( /* Starbase */
SpaceJunkFrame, 16); pMoonDesc->image.frame =
SetAbsFrameIndex (SpaceJunkFrame, 16);
} }
/* Samatra */
else if (data_index == (BYTE)(~0 - 1)) else if (data_index == (BYTE)(~0 - 1))
{ {
pMoonDesc->image.frame = SetAbsFrameIndex ( /* Sa-Matra */
SpaceJunkFrame, 19); pMoonDesc->image.frame =
SetAbsFrameIndex (SpaceJunkFrame, 19);
} }
} }
} }
@@ -166,11 +214,11 @@ LoadSolarSys (void)
#define NUM_TEMP_RANGES 5 #define NUM_TEMP_RANGES 5
COLOR temp_color_array[NUM_TEMP_RANGES] = COLOR temp_color_array[NUM_TEMP_RANGES] =
{ {
BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0xE), 0x54), BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x0E), 0x54),
BUILD_COLOR (MAKE_RGB15 (0x00, 0x6, 0x8), 0x62), BUILD_COLOR (MAKE_RGB15 (0x00, 0x06, 0x08), 0x62),
BUILD_COLOR (MAKE_RGB15 (0x00, 0xB, 0x00), 0x6D), BUILD_COLOR (MAKE_RGB15 (0x00, 0x0B, 0x00), 0x6D),
BUILD_COLOR (MAKE_RGB15 (0xF, 0x00, 0x00), 0x2D), BUILD_COLOR (MAKE_RGB15 (0x0F, 0x00, 0x00), 0x2D),
BUILD_COLOR (MAKE_RGB15 (0xF, 0x8, 0x00), 0x75), BUILD_COLOR (MAKE_RGB15 (0x0F, 0x08, 0x00), 0x75),
}; };
pSolarSysState->MenuState.CurState = 0; pSolarSysState->MenuState.CurState = 0;
@@ -385,8 +433,7 @@ CheckIntersect (BOOLEAN just_checking)
PlanetIntersect.EndPoint = PlanetIntersect.IntersectStamp.origin; PlanetIntersect.EndPoint = PlanetIntersect.IntersectStamp.origin;
if (pSolarSysState->WaitIntersect != (COUNT)~0 if (pSolarSysState->WaitIntersect != (COUNT)~0
&& pSolarSysState->WaitIntersect != MAKE_WORD ( && pSolarSysState->WaitIntersect != MAKE_WORD (
pCurDesc - pSolarSysState->PlanetDesc + 1, 1 pCurDesc - pSolarSysState->PlanetDesc + 1, 1))
))
PlanetIntersect.IntersectStamp.frame = DecFrameIndex (stars_in_space); PlanetIntersect.IntersectStamp.frame = DecFrameIndex (stars_in_space);
else else
PlanetIntersect.IntersectStamp.frame = pCurDesc->image.frame; PlanetIntersect.IntersectStamp.frame = pCurDesc->image.frame;
@@ -425,91 +472,89 @@ ShowPlanet:
} }
} }
for (i = pCurDesc->NumPlanets,
pCurDesc = pSolarSysState->pBaseDesc; i; --i, ++pCurDesc)
{ {
for (i = pCurDesc->NumPlanets, PlanetIntersect.IntersectStamp.origin = pCurDesc->image.origin;
pCurDesc = pSolarSysState->pBaseDesc; i; --i, ++pCurDesc) PlanetIntersect.EndPoint = PlanetIntersect.IntersectStamp.origin;
if (pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc)
{ {
PlanetIntersect.IntersectStamp.origin = pCurDesc->image.origin; PlanetOffset = pCurDesc->pPrevDesc -
PlanetIntersect.EndPoint = PlanetIntersect.IntersectStamp.origin; pSolarSysState->PlanetDesc;
if (pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc) MoonOffset = pCurDesc - pSolarSysState->MoonDesc + 2;
{ }
PlanetOffset = pCurDesc->pPrevDesc - else
pSolarSysState->PlanetDesc; {
MoonOffset = pCurDesc - pSolarSysState->MoonDesc + 2; PlanetOffset = pCurDesc - pSolarSysState->PlanetDesc;
} MoonOffset = 0;
else }
{ ++PlanetOffset;
PlanetOffset = pCurDesc - pSolarSysState->PlanetDesc; if (pSolarSysState->WaitIntersect != (COUNT)~0
MoonOffset = 0; && pSolarSysState->WaitIntersect != MAKE_WORD (
} PlanetOffset, MoonOffset))
++PlanetOffset; PlanetIntersect.IntersectStamp.frame =
if (pSolarSysState->WaitIntersect != (COUNT)~0 DecFrameIndex (stars_in_space);
&& pSolarSysState->WaitIntersect != MAKE_WORD ( else
PlanetOffset, MoonOffset)) PlanetIntersect.IntersectStamp.frame = pCurDesc->image.frame;
PlanetIntersect.IntersectStamp.frame =
DecFrameIndex (stars_in_space);
else
PlanetIntersect.IntersectStamp.frame = pCurDesc->image.frame;
if (DrawablesIntersect (&ShipIntersect, if (DrawablesIntersect (&ShipIntersect,
&PlanetIntersect, MAX_TIME_VALUE)) &PlanetIntersect, MAX_TIME_VALUE))
{ {
// fprintf (stderr, "1: Planet %d, Moon %d\n", PlanetOffset, MoonOffset); // fprintf (stderr, "1: Planet %d, Moon %d\n", PlanetOffset, MoonOffset);
NewWaitPlanet = MAKE_WORD (PlanetOffset, MoonOffset); NewWaitPlanet = MAKE_WORD (PlanetOffset, MoonOffset);
if (pSolarSysState->WaitIntersect == (COUNT)~0) if (pSolarSysState->WaitIntersect == (COUNT)~0)
return; return;
else if (pSolarSysState->WaitIntersect == NewWaitPlanet) else if (pSolarSysState->WaitIntersect == NewWaitPlanet)
continue; continue;
else if (pSolarSysState->pBaseDesc == else if (pSolarSysState->pBaseDesc ==
pSolarSysState->MoonDesc) pSolarSysState->MoonDesc)
goto ShowPlanet; goto ShowPlanet;
else if (!just_checking) /* pBaseDesc == PlanetDesc */ else if (!just_checking) /* pBaseDesc == PlanetDesc */
{ {
COUNT angle; COUNT angle;
RECT r; RECT r;
angle = FACING_TO_ANGLE ( angle = FACING_TO_ANGLE (
GetFrameIndex (GLOBAL (ShipStamp.frame)) GetFrameIndex (GLOBAL (ShipStamp.frame))
) + HALF_CIRCLE; ) + HALF_CIRCLE;
GLOBAL (ShipStamp.origin.x) = GLOBAL (ShipStamp.origin.x) =
(SIS_SCREEN_WIDTH >> 1) + COSINE ( (SIS_SCREEN_WIDTH >> 1) + COSINE (
angle, MIN_MOON_RADIUS angle, MIN_MOON_RADIUS
+ ((MAX_MOONS - 1) * MOON_DELTA) + ((MAX_MOONS - 1) * MOON_DELTA)
+ (MOON_DELTA >> 2)); + (MOON_DELTA >> 2));
GLOBAL (ShipStamp.origin.y) =
(SIS_SCREEN_HEIGHT >> 1) + SINE (
angle, MIN_MOON_RADIUS
+ ((MAX_MOONS - 1) * MOON_DELTA)
+ (MOON_DELTA >> 2));
if (GLOBAL (ShipStamp.origin.y) < 0)
GLOBAL (ShipStamp.origin.y) = 1;
else if (GLOBAL (ShipStamp.origin.y) >= SIS_SCREEN_HEIGHT)
GLOBAL (ShipStamp.origin.y) = GLOBAL (ShipStamp.origin.y) =
(SIS_SCREEN_HEIGHT >> 1) + SINE ( (SIS_SCREEN_HEIGHT - 1) - 1;
angle, MIN_MOON_RADIUS pSolarSysState->pBaseDesc = pCurDesc;
+ ((MAX_MOONS - 1) * MOON_DELTA) XFormIPLoc (&pCurDesc->image.origin,
+ (MOON_DELTA >> 2)); &pSolarSysState->SunDesc[0].location, FALSE);
if (GLOBAL (ShipStamp.origin.y) < 0) ZeroVelocityComponents (&GLOBAL (velocity));
GLOBAL (ShipStamp.origin.y) = 1; GenerateMoons ();
else if (GLOBAL (ShipStamp.origin.y) >= SIS_SCREEN_HEIGHT)
GLOBAL (ShipStamp.origin.y) =
(SIS_SCREEN_HEIGHT - 1) - 1;
pSolarSysState->pBaseDesc = pCurDesc;
XFormIPLoc (&pCurDesc->image.origin,
&pSolarSysState->SunDesc[0].location, FALSE);
ZeroVelocityComponents (&GLOBAL (velocity));
GenerateMoons ();
NewWaitPlanet = 0; NewWaitPlanet = 0;
SetTransitionSource (NULL); SetTransitionSource (NULL);
BatchGraphics (); BatchGraphics ();
SetGraphicGrabOther (1); SetGraphicGrabOther (1);
DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius, DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius,
TRUE); TRUE);
SetGraphicGrabOther (0); SetGraphicGrabOther (0);
r.corner.x = SIS_ORG_X; r.corner.x = SIS_ORG_X;
r.corner.y = SIS_ORG_Y; r.corner.y = SIS_ORG_Y;
r.extent.width = SIS_SCREEN_WIDTH; r.extent.width = SIS_SCREEN_WIDTH;
r.extent.height = SIS_SCREEN_HEIGHT; r.extent.height = SIS_SCREEN_HEIGHT;
ScreenTransition (3, &r); ScreenTransition (3, &r);
UnbatchGraphics (); UnbatchGraphics ();
LoadIntoExtraScreen (&r); LoadIntoExtraScreen (&r);
}
break;
} }
break;
} }
} }
@@ -781,11 +826,10 @@ ProcessShipControls (void)
if (delta_x || delta_y < 0) if (delta_x || delta_y < 0)
{ {
GLOBAL (autopilot.x) = GLOBAL (autopilot.x) = ~0;
GLOBAL (autopilot.y) = ~0; GLOBAL (autopilot.y) = ~0;
} }
else if (GLOBAL (autopilot.x) != ~0 else if (GLOBAL (autopilot.x) != ~0 && GLOBAL (autopilot.y) != ~0)
&& GLOBAL (autopilot.y) != ~0)
delta_y = -1; delta_y = -1;
else else
delta_y = 0; delta_y = 0;
@@ -801,8 +845,7 @@ ProcessShipControls (void)
index = NORMALIZE_FACING (index + 1); index = NORMALIZE_FACING (index + 1);
GLOBAL (ShipStamp.frame) = GLOBAL (ShipStamp.frame) =
SetAbsFrameIndex (GLOBAL (ShipStamp.frame), SetAbsFrameIndex (GLOBAL (ShipStamp.frame), index);
index);
pSolarSysState->turn_counter = pSolarSysState->turn_wait; pSolarSysState->turn_counter = pSolarSysState->turn_wait;
} }
@@ -851,10 +894,8 @@ UndrawShip (void)
pSolarSysState->pBaseDesc = pSolarSysState->PlanetDesc; pSolarSysState->pBaseDesc = pSolarSysState->PlanetDesc;
pSolarSysState->WaitIntersect = MAKE_WORD ( pSolarSysState->WaitIntersect = MAKE_WORD (
pPlanetDesc - pSolarSysState->PlanetDesc + 1, 0 pPlanetDesc - pSolarSysState->PlanetDesc + 1, 0);
); GLOBAL (ip_location) = pSolarSysState->SunDesc[0].location;
GLOBAL (ip_location) =
pSolarSysState->SunDesc[0].location;
ZeroVelocityComponents (&GLOBAL (velocity)); ZeroVelocityComponents (&GLOBAL (velocity));
} }
@@ -996,7 +1037,7 @@ ScaleSystem (void)
} }
/* Constants and routines for handling interplanetary play. TODO: /* Constants and routines for handling interplanetary play. TODO:
this is NOT INSTANTIABLE; only one IP task may be active at any this is NOT THREAD-SAFE; only one IP task may be active at any
given time. --Michael */ given time. --Michael */
#define IP_FRAME_RATE (ONE_SECOND / 30) #define IP_FRAME_RATE (ONE_SECOND / 30)
@@ -1331,10 +1372,8 @@ StartGroups:
pSolarSysState->pOrbitalDesc->image.origin; pSolarSysState->pOrbitalDesc->image.origin;
else else
{ {
GLOBAL (ShipStamp.origin.x) = GLOBAL (ShipStamp.origin.x) = SIS_SCREEN_WIDTH >> 1;
SIS_SCREEN_WIDTH >> 1; GLOBAL (ShipStamp.origin.y) = SIS_SCREEN_HEIGHT >> 1;
GLOBAL (ShipStamp.origin.y) =
SIS_SCREEN_HEIGHT >> 1;
} }
} }
@@ -1528,7 +1567,6 @@ GenerateRandomIP (BYTE control)
{ {
COUNT i; COUNT i;
DWORD rand_val; DWORD rand_val;
PPLANET_DESC pCurDesc;
switch (control) switch (control)
{ {
@@ -1606,47 +1644,7 @@ GenerateRandomIP (BYTE control)
case GENERATE_PLANETS: case GENERATE_PLANETS:
{ {
FillOrbits ((BYTE)~0, &pSolarSysState->PlanetDesc[0], FALSE); FillOrbits ((BYTE)~0, &pSolarSysState->PlanetDesc[0], FALSE);
for (i = pSolarSysState->SunDesc[0].NumPlanets, GeneratePlanets();
pCurDesc = &pSolarSysState->PlanetDesc[0]; i;
--i, ++pCurDesc)
{
BYTE byte_val;
BYTE num_moons;
rand_val = TFB_Random ();
byte_val = LOBYTE (rand_val);
num_moons = 0;
switch (PLANSIZE (PlanData[
pCurDesc->data_index & ~PLANET_SHIELDED].Type))
{
case LARGE_ROCKY_WORLD:
if (byte_val < 0x00FF * 25 / 100)
{
if (byte_val < 0x00FF * 5 / 100)
++num_moons;
++num_moons;
}
break;
case GAS_GIANT:
if (byte_val < 0x00FF * 90 / 100)
{
if (byte_val < 0x00FF * 75 / 100)
{
if (byte_val < 0x00FF * 50 / 100)
{
if (byte_val < 0x00FF * 25 / 100)
++num_moons;
++num_moons;
}
++num_moons;
}
++num_moons;
}
break;
}
pCurDesc->NumPlanets = num_moons;
}
break; break;
} }
} }
@@ -1774,8 +1772,7 @@ DrawStarBackGround (BOOLEAN ForPlanet)
old_seed = TFB_SeedRandom ( old_seed = TFB_SeedRandom (
MAKE_DWORD (CurStarDescPtr->star_pt.x, MAKE_DWORD (CurStarDescPtr->star_pt.x,
CurStarDescPtr->star_pt.y) CurStarDescPtr->star_pt.y));
);
#define NUM_DIM_PIECES 8 #define NUM_DIM_PIECES 8
s.frame = SpaceJunkFrame; s.frame = SpaceJunkFrame;
@@ -1821,16 +1818,16 @@ DrawStarBackGround (BOOLEAN ForPlanet)
SetContext (ScreenContext); SetContext (ScreenContext);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0xA), SetContextForeGroundColor (
0x08)); BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0xA), 0x08));
r.corner.x = SIS_ORG_X - 1; r.corner.x = SIS_ORG_X - 1;
r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT - 4; r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT - 4;
r.extent.width = SIS_SCREEN_WIDTH + 2; r.extent.width = SIS_SCREEN_WIDTH + 2;
r.extent.height = 3; r.extent.height = 3;
DrawFilledRectangle (&r); DrawFilledRectangle (&r);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x8, 0x8, 0x8), SetContextForeGroundColor (
0x1F)); BUILD_COLOR (MAKE_RGB15 (0x8, 0x8, 0x8), 0x1F));
r.extent.width = 1; r.extent.width = 1;
r.extent.height = MAP_HEIGHT + 1; r.extent.height = MAP_HEIGHT + 1;
r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT; r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT;
@@ -1844,8 +1841,8 @@ DrawStarBackGround (BOOLEAN ForPlanet)
r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT - 5; r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT - 5;
DrawFilledRectangle (&r); DrawFilledRectangle (&r);
SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 ( SetContextForeGroundColor (
0x10, 0x10, 0x10), 0x19)); BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19));
r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT - 1; r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT - 1;
r.extent.width = MAP_WIDTH + 2; r.extent.width = MAP_WIDTH + 2;
r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH - 1; r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH - 1;