Cleanups.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1833 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
meep-eep
2005-07-08 22:29:08 +00:00
parent e3998ad530
commit db2ec77dcf
+221 -243
View File
@@ -132,7 +132,8 @@ PrintCoarseScanPC (void)
if (CurStarDescPtr->Index == SOL_DEFINED) if (CurStarDescPtr->Index == SOL_DEFINED)
{ {
if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->SunDesc[0]) if (pSolarSysState->pOrbitalDesc->pPrevDesc ==
&pSolarSysState->SunDesc[0])
wstrcpy (buf, GLOBAL_SIS (PlanetName)); wstrcpy (buf, GLOBAL_SIS (PlanetName));
else else
{ {
@@ -880,8 +881,7 @@ DrawScannedStuff (COUNT y, BYTE CurState)
OldColor = SetContextForeGroundColor (0); OldColor = SetContextForeGroundColor (0);
for (hElement = GetHeadElement (); for (hElement = GetHeadElement (); hElement; hElement = hNextElement)
hElement; hElement = hNextElement)
{ {
ELEMENTPTR ElementPtr; ELEMENTPTR ElementPtr;
//COLOR OldColor; //COLOR OldColor;
@@ -1041,113 +1041,112 @@ DoScan (PMENU_STATE pMS)
#ifndef SPIN_ON_SCAN #ifndef SPIN_ON_SCAN
pSolarSysState->PauseRotate = 1; pSolarSysState->PauseRotate = 1;
#endif #endif
if ((min_scan = pMS->CurState) != AUTO_SCAN) min_scan = pMS->CurState;
if (min_scan != AUTO_SCAN)
max_scan = min_scan; max_scan = min_scan;
else else
min_scan = MINERAL_SCAN, max_scan = BIOLOGICAL_SCAN; {
min_scan = MINERAL_SCAN;
max_scan = BIOLOGICAL_SCAN;
}
do do
{ {
TEXT t; TEXT t;
SWORD i; SWORD i;
t.baseline.x = SIS_SCREEN_WIDTH >> 1; t.baseline.x = SIS_SCREEN_WIDTH >> 1;
t.baseline.y = SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7; t.baseline.y = SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7;
t.align = ALIGN_CENTER; t.align = ALIGN_CENTER;
t.CharCount = (COUNT)~0; t.CharCount = (COUNT)~0;
pSolarSysState->CurNode = (COUNT)~0; pSolarSysState->CurNode = (COUNT)~0;
(*pSolarSysState->GenFunc) ( (*pSolarSysState->GenFunc) ((BYTE)(min_scan + GENERATE_MINERAL));
(BYTE)(min_scan + GENERATE_MINERAL) pMS->delta_item = (SIZE)pSolarSysState->CurNode;
); t.pStr = GAME_STRING (SCAN_STRING_BASE + min_scan);
pMS->delta_item = (SIZE)pSolarSysState->CurNode;
t.pStr = GAME_STRING (SCAN_STRING_BASE + min_scan);
LockMutex (GraphicsLock);
SetContext (SpaceContext);
r.corner.x = 0;
r.corner.y = t.baseline.y - 10;
r.extent.width = SIS_SCREEN_WIDTH;
r.extent.height = t.baseline.y - r.corner.y + 1;
RepairBackRect (&r);
SetContextFont (MicroFont);
switch (min_scan)
{
case MINERAL_SCAN:
SetContextForeGroundColor (
BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C)
);
break;
case ENERGY_SCAN:
SetContextForeGroundColor (
BUILD_COLOR (MAKE_RGB15 (0xC, 0xC, 0xC), 0x1C)
);
break;
case BIOLOGICAL_SCAN:
SetContextForeGroundColor (
BUILD_COLOR (MAKE_RGB15 (0x00, 0xE, 0x00), 0x6C)
);
break;
}
font_DrawText (&t);
SetContext (ScanContext);
UnlockMutex (GraphicsLock);
{
DWORD rgb;
switch (min_scan)
{
case MINERAL_SCAN:
rgb = 0x1f << 10;
break;
case ENERGY_SCAN:
rgb = (0x1f << 10) | (0x1f << 5) | 0x1f;
break;
case BIOLOGICAL_SCAN:
rgb = 0x1f << 5;
break;
}
LockMutex (GraphicsLock);
BatchGraphics ();
DrawPlanet (0, 0, 0, 0);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
PressState = AnyButtonPress (TRUE);
WaitTime = (ONE_SECOND << 1) / MAP_HEIGHT;
// LockMutex (GraphicsLock);
TimeIn = GetTimeCounter ();
for (i = 0; i < MAP_HEIGHT + NUM_FLASH_COLORS + 1; i++)
{
ButtonState = AnyButtonPress (TRUE);
if (PressState)
{
PressState = ButtonState;
ButtonState = FALSE;
}
if (ButtonState)
i = -i;
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
BatchGraphics (); SetContext (SpaceContext);
DrawPlanet (0, 0, i, rgb); r.corner.x = 0;
if (i < 0) r.corner.y = t.baseline.y - 10;
i = MAP_HEIGHT + NUM_FLASH_COLORS; r.extent.width = SIS_SCREEN_WIDTH;
if (pMS->delta_item) r.extent.height = t.baseline.y - r.corner.y + 1;
DrawScannedStuff (i, min_scan); RepairBackRect (&r);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
// FlushGraphics ();
SleepThreadUntil (TimeIn + WaitTime);
TimeIn = GetTimeCounter ();
}
// UnlockMutex (GraphicsLock);
pSolarSysState->Tint_rgb = 0;
} SetContextFont (MicroFont);
switch (min_scan)
{
case MINERAL_SCAN:
SetContextForeGroundColor (
BUILD_COLOR (MAKE_RGB15 (0x13, 0x00, 0x00), 0x2C));
break;
case ENERGY_SCAN:
SetContextForeGroundColor (
BUILD_COLOR (MAKE_RGB15 (0xC, 0xC, 0xC), 0x1C));
break;
case BIOLOGICAL_SCAN:
SetContextForeGroundColor (
BUILD_COLOR (MAKE_RGB15 (0x00, 0xE, 0x00), 0x6C));
break;
}
font_DrawText (&t);
SetContext (ScanContext);
UnlockMutex (GraphicsLock);
{
DWORD rgb;
switch (min_scan)
{
case MINERAL_SCAN:
rgb = MAKE_RGB15 (0x1f, 0x00, 0x00);
break;
case ENERGY_SCAN:
rgb = MAKE_RGB15 (0x1f, 0x1f, 0x1f);
break;
case BIOLOGICAL_SCAN:
rgb = MAKE_RGB15 (0x00, 0x1f, 0x00);
break;
}
LockMutex (GraphicsLock);
BatchGraphics ();
DrawPlanet (0, 0, 0, 0);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
PressState = AnyButtonPress (TRUE);
WaitTime = (ONE_SECOND << 1) / MAP_HEIGHT;
// LockMutex (GraphicsLock);
TimeIn = GetTimeCounter ();
for (i = 0; i < MAP_HEIGHT + NUM_FLASH_COLORS + 1; i++)
{
ButtonState = AnyButtonPress (TRUE);
if (PressState)
{
PressState = ButtonState;
ButtonState = FALSE;
}
if (ButtonState)
i = -i;
LockMutex (GraphicsLock);
BatchGraphics ();
DrawPlanet (0, 0, i, rgb);
if (i < 0)
i = MAP_HEIGHT + NUM_FLASH_COLORS;
if (pMS->delta_item)
DrawScannedStuff (i, min_scan);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
// FlushGraphics ();
SleepThreadUntil (TimeIn + WaitTime);
TimeIn = GetTimeCounter ();
}
// UnlockMutex (GraphicsLock);
pSolarSysState->Tint_rgb = 0;
}
} while (++min_scan <= max_scan); } while (++min_scan <= max_scan);
@@ -1156,7 +1155,8 @@ DoScan (PMENU_STATE pMS)
r.corner.x = 0; r.corner.x = 0;
r.corner.y = (SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7) - 10; r.corner.y = (SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7) - 10;
r.extent.width = SIS_SCREEN_WIDTH; r.extent.width = SIS_SCREEN_WIDTH;
r.extent.height = (SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7) - r.corner.y + 1; r.extent.height = (SIS_SCREEN_HEIGHT - MAP_HEIGHT - 7)
- r.corner.y + 1;
RepairBackRect (&r); RepairBackRect (&r);
SetContext (ScanContext); SetContext (ScanContext);
@@ -1166,7 +1166,8 @@ DoScan (PMENU_STATE pMS)
DrawScannedObjects (FALSE); DrawScannedObjects (FALSE);
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_MIN_SCAN, pMS->CurState = DISPATCH_SHUTTLE); pMS->CurState = DISPATCH_SHUTTLE;
DrawMenuStateStrings (PM_MIN_SCAN, pMS->CurState);
} }
else else
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
@@ -1220,8 +1221,10 @@ ScanSystem (void)
else else
{ {
MenuState.CurState = AUTO_SCAN; MenuState.CurState = AUTO_SCAN;
pSolarSysState->MenuState.first_item.x = (MAP_WIDTH >> 1) << MAG_SHIFT; pSolarSysState->MenuState.first_item.x =
pSolarSysState->MenuState.first_item.y = (MAP_HEIGHT >> 1) << MAG_SHIFT; (MAP_WIDTH >> 1) << MAG_SHIFT;
pSolarSysState->MenuState.first_item.y =
(MAP_HEIGHT >> 1) << MAG_SHIFT;
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
ScanContext = CaptureContext (CreateContext ()); ScanContext = CaptureContext (CreateContext ());
@@ -1230,8 +1233,7 @@ ScanSystem (void)
MenuState.flash_rect0.extent.height = FLASH_HEIGHT; MenuState.flash_rect0.extent.height = FLASH_HEIGHT;
MenuState.flash_frame0 = CaptureDrawable ( MenuState.flash_frame0 = CaptureDrawable (
CreateDrawable (WANT_PIXMAP | MAPPED_TO_DISPLAY, CreateDrawable (WANT_PIXMAP | MAPPED_TO_DISPLAY,
FLASH_WIDTH, FLASH_HEIGHT, 1) FLASH_WIDTH, FLASH_HEIGHT, 1));
);
SetContextFGFrame (Screen); SetContextFGFrame (Screen);
r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH; r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH;
r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT; r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT;
@@ -1281,158 +1283,134 @@ GeneratePlanetSide (void)
COUNT num_nodes; COUNT num_nodes;
FRAME f; FRAME f;
f = SetAbsFrameIndex ( f = SetAbsFrameIndex (misc_data,
misc_data, NUM_SCANDOT_TRANSITIONS * (scan - ENERGY_SCAN));
NUM_SCANDOT_TRANSITIONS * (scan - ENERGY_SCAN)
);
pSolarSysState->CurNode = (COUNT)~0; pSolarSysState->CurNode = (COUNT)~0;
(*pSolarSysState->GenFunc) ( (*pSolarSysState->GenFunc) ((BYTE)(scan + GENERATE_MINERAL));
(BYTE)(scan + GENERATE_MINERAL)
);
num_nodes = pSolarSysState->CurNode; num_nodes = pSolarSysState->CurNode;
if (num_nodes) while (num_nodes--)
{ {
while (num_nodes--) HELEMENT hNodeElement;
ELEMENTPTR NodeElementPtr;
if (pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[scan]
& (1L << num_nodes))
continue;
hNodeElement = AllocElement ();
if (!hNodeElement)
continue;
LockElement (hNodeElement, &NodeElementPtr);
pSolarSysState->CurNode = num_nodes;
(*pSolarSysState->GenFunc) ((BYTE)(scan + GENERATE_MINERAL));
NodeElementPtr->life_span = MAKE_WORD (scan, num_nodes + 1);
NodeElementPtr->state_flags = BAD_GUY;
NodeElementPtr->current.location.x =
pSolarSysState->SysInfo.PlanetInfo.CurPt.x;
NodeElementPtr->current.location.y =
pSolarSysState->SysInfo.PlanetInfo.CurPt.y;
SetPrimType (&DisplayArray[NodeElementPtr->PrimIndex], STAMP_PRIM);
if (scan == MINERAL_SCAN)
{ {
HELEMENT hNodeElement; COUNT EType;
if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[scan] EType = pSolarSysState->SysInfo.PlanetInfo.CurType;
& (1L << num_nodes)) NodeElementPtr->turn_wait = (BYTE)EType;
&& (hNodeElement = AllocElement ())) NodeElementPtr->mass_points = HIBYTE (
pSolarSysState->SysInfo.PlanetInfo.CurDensity);
NodeElementPtr->current.image.frame = SetAbsFrameIndex (
misc_data, (NUM_SCANDOT_TRANSITIONS << 1)
+ ElementCategory (EType) * 5);
NodeElementPtr->next.image.frame = SetRelFrameIndex (
NodeElementPtr->current.image.frame, LOBYTE (
pSolarSysState->SysInfo.PlanetInfo.CurDensity) + 1);
DisplayArray[NodeElementPtr->PrimIndex].Object.Stamp.frame =
IncFrameIndex (NodeElementPtr->next.image.frame);
}
else
{
extern void object_animation (PELEMENT ElementPtr);
NodeElementPtr->current.image.frame = f;
NodeElementPtr->next.image.frame = SetRelFrameIndex (
f, NUM_SCANDOT_TRANSITIONS - 1);
NodeElementPtr->turn_wait = MAKE_BYTE (4, 4);
NodeElementPtr->preprocess_func = object_animation;
if (scan == ENERGY_SCAN)
{ {
ELEMENTPTR NodeElementPtr; if (pSolarSysState->SysInfo.PlanetInfo.CurType == 1)
NodeElementPtr->mass_points = 0;
LockElement (hNodeElement, &NodeElementPtr); else if (pSolarSysState->SysInfo.PlanetInfo.CurType == 2)
NodeElementPtr->mass_points = 1;
pSolarSysState->CurNode = num_nodes;
(*pSolarSysState->GenFunc) (
(BYTE)(scan + GENERATE_MINERAL)
);
NodeElementPtr->life_span = MAKE_WORD (scan, num_nodes + 1);
NodeElementPtr->state_flags = BAD_GUY;
NodeElementPtr->current.location.x =
pSolarSysState->SysInfo.PlanetInfo.CurPt.x;
NodeElementPtr->current.location.y =
pSolarSysState->SysInfo.PlanetInfo.CurPt.y;
SetPrimType (&DisplayArray[NodeElementPtr->PrimIndex], STAMP_PRIM);
if (scan == MINERAL_SCAN)
{
COUNT EType;
EType = pSolarSysState->SysInfo.PlanetInfo.CurType;
NodeElementPtr->turn_wait = (BYTE)EType;
NodeElementPtr->mass_points =
HIBYTE (
pSolarSysState->SysInfo.PlanetInfo.CurDensity
);
NodeElementPtr->current.image.frame =
SetAbsFrameIndex (
misc_data,
(NUM_SCANDOT_TRANSITIONS << 1)
+ ElementCategory (EType) * 5
);
NodeElementPtr->next.image.frame =
SetRelFrameIndex (
NodeElementPtr->current.image.frame,
LOBYTE (
pSolarSysState->SysInfo.PlanetInfo.CurDensity
) + 1
);
DisplayArray[NodeElementPtr->PrimIndex].Object.Stamp.frame =
IncFrameIndex (
NodeElementPtr->next.image.frame
);
}
else else
NodeElementPtr->mass_points = MAX_SCROUNGED;
DisplayArray[NodeElementPtr->PrimIndex].Object.Stamp.frame =
pSolarSysState->PlanetSideFrame[1];
}
else
{
COUNT i, which_node;
which_node = pSolarSysState->SysInfo.PlanetInfo.CurType;
if (CreatureData[which_node].Attributes & SPEED_MASK)
{ {
extern void i = (COUNT)TFB_Random ();
object_animation NodeElementPtr->current.location.x =
(PELEMENT (LOBYTE (i) % (MAP_WIDTH - (8 << 1))) + 8;
ElementPtr); NodeElementPtr->current.location.y =
(HIBYTE (i) % (MAP_HEIGHT - (8 << 1))) + 8;
NodeElementPtr->current.image.frame = f;
NodeElementPtr->next.image.frame =
SetRelFrameIndex (
f, NUM_SCANDOT_TRANSITIONS - 1
);
NodeElementPtr->turn_wait = MAKE_BYTE (4, 4);
NodeElementPtr->preprocess_func = object_animation;
if (scan == ENERGY_SCAN)
{
if (pSolarSysState->SysInfo.PlanetInfo.CurType == 1)
NodeElementPtr->mass_points = 0;
else if (pSolarSysState->SysInfo.PlanetInfo.CurType == 2)
NodeElementPtr->mass_points = 1;
else
NodeElementPtr->mass_points = MAX_SCROUNGED;
DisplayArray[NodeElementPtr->PrimIndex].Object.Stamp.frame =
pSolarSysState->PlanetSideFrame[1];
}
else
{
COUNT i, which_node;
which_node = pSolarSysState->SysInfo.PlanetInfo.CurType;
if (CreatureData[which_node].Attributes & SPEED_MASK)
{
i = (COUNT)TFB_Random ();
NodeElementPtr->current.location.x =
(LOBYTE (i) % (MAP_WIDTH - (8 << 1))) + 8;
NodeElementPtr->current.location.y =
(HIBYTE (i) % (MAP_HEIGHT - (8 << 1))) + 8;
}
if (pSolarSysState->PlanetSideFrame[0] == 0)
pSolarSysState->PlanetSideFrame[0] =
CaptureDrawable (LoadGraphic (
CANNISTER_MASK_PMAP_ANIM
));
for (i = 0; i < MAX_LIFE_VARIATION
&& life_init_tab[i] != (BYTE)(which_node + 1);
++i)
{
if (life_init_tab[i] == 0)
{
life_init_tab[i] = (BYTE)which_node + 1;
pSolarSysState->PlanetSideFrame[i + 3] =
CaptureDrawable (LoadGraphic (
MAKE_RESOURCE (
GET_PACKAGE (LIFE00_MASK_PMAP_ANIM)
+ which_node, GFXRES,
GET_INSTANCE (LIFE00_MASK_PMAP_ANIM)
+ which_node)));
break;
}
}
NodeElementPtr->mass_points = (BYTE)which_node;
NodeElementPtr->hit_points = HINIBBLE (
CreatureData[which_node].ValueAndHitPoints
);
DisplayArray[NodeElementPtr->PrimIndex].Object.Stamp.frame =
SetAbsFrameIndex (
pSolarSysState->PlanetSideFrame[i + 3],
(COUNT)TFB_Random ()
);
}
} }
NodeElementPtr->next.location.x = if (pSolarSysState->PlanetSideFrame[0] == 0)
NodeElementPtr->current.location.x << MAG_SHIFT; pSolarSysState->PlanetSideFrame[0] =
NodeElementPtr->next.location.y = CaptureDrawable (LoadGraphic (
NodeElementPtr->current.location.y << MAG_SHIFT; CANNISTER_MASK_PMAP_ANIM));
UnlockElement (hNodeElement); for (i = 0; i < MAX_LIFE_VARIATION
&& life_init_tab[i] != (BYTE)(which_node + 1);
++i)
{
if (life_init_tab[i] != 0)
continue;
PutElement (hNodeElement); life_init_tab[i] = (BYTE)which_node + 1;
pSolarSysState->PlanetSideFrame[i + 3] =
CaptureDrawable (LoadGraphic (
MAKE_RESOURCE (
GET_PACKAGE (LIFE00_MASK_PMAP_ANIM)
+ which_node, GFXRES,
GET_INSTANCE (LIFE00_MASK_PMAP_ANIM)
+ which_node)));
break;
}
NodeElementPtr->mass_points = (BYTE)which_node;
NodeElementPtr->hit_points = HINIBBLE (
CreatureData[which_node].ValueAndHitPoints);
DisplayArray[NodeElementPtr->PrimIndex].
Object.Stamp.frame = SetAbsFrameIndex (
pSolarSysState->PlanetSideFrame[i + 3],
(COUNT)TFB_Random ());
} }
} }
NodeElementPtr->next.location.x =
NodeElementPtr->current.location.x << MAG_SHIFT;
NodeElementPtr->next.location.y =
NodeElementPtr->current.location.y << MAG_SHIFT;
UnlockElement (hNodeElement);
PutElement (hNodeElement);
} }
} }
} }