Uncouple Starmap from pMenuState and remove MENU_STATE abuse

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3311 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-11-17 09:56:02 +00:00
parent 581d28c45e
commit ec89d2688e
+98 -97
View File
@@ -37,6 +37,12 @@
#include "libs/memlib.h" #include "libs/memlib.h"
static POINT cursorLoc;
static POINT mapOrigin;
static int zoomLevel;
static FRAME StarMapFrame;
static inline long static inline long
signedDivWithError (long val, long divisor) signedDivWithError (long val, long divisor)
{ {
@@ -55,8 +61,7 @@ signedDivWithError (long val, long divisor)
static inline COORD static inline COORD
universeToDispx (COORD ux) universeToDispx (COORD ux)
{ {
return signedDivWithError ((((long)ux - pMenuState->flash_rect1.corner.x) return signedDivWithError ((((long)ux - mapOrigin.x) << zoomLevel)
<< LOBYTE (pMenuState->delta_item))
* SIS_SCREEN_WIDTH, MAX_X_UNIVERSE + MAP_FIT_X) * SIS_SCREEN_WIDTH, MAX_X_UNIVERSE + MAP_FIT_X)
+ ((SIS_SCREEN_WIDTH - 1) >> 1); + ((SIS_SCREEN_WIDTH - 1) >> 1);
} }
@@ -65,8 +70,7 @@ universeToDispx (COORD ux)
static inline COORD static inline COORD
universeToDispy (COORD uy) universeToDispy (COORD uy)
{ {
return signedDivWithError ((((long)pMenuState->flash_rect1.corner.y - uy) return signedDivWithError ((((long)mapOrigin.y - uy) << zoomLevel)
<< LOBYTE (pMenuState->delta_item))
* SIS_SCREEN_HEIGHT, MAX_Y_UNIVERSE + 2) * SIS_SCREEN_HEIGHT, MAX_Y_UNIVERSE + 2)
+ ((SIS_SCREEN_HEIGHT - 1) >> 1); + ((SIS_SCREEN_HEIGHT - 1) >> 1);
} }
@@ -76,8 +80,8 @@ static inline COORD
dispxToUniverse (COORD dx) dispxToUniverse (COORD dx)
{ {
return (((long)(dx - ((SIS_SCREEN_WIDTH - 1) >> 1)) return (((long)(dx - ((SIS_SCREEN_WIDTH - 1) >> 1))
* (MAX_X_UNIVERSE + MAP_FIT_X)) >> LOBYTE (pMenuState->delta_item)) * (MAX_X_UNIVERSE + MAP_FIT_X)) >> zoomLevel)
/ SIS_SCREEN_WIDTH + pMenuState->flash_rect1.corner.x; / SIS_SCREEN_WIDTH + mapOrigin.x;
} }
#define DISP_TO_UNIVERSEX(dx) dispxToUniverse(dx) #define DISP_TO_UNIVERSEX(dx) dispxToUniverse(dx)
@@ -85,8 +89,8 @@ static inline COORD
dispyToUniverse (COORD dy) dispyToUniverse (COORD dy)
{ {
return (((long)(((SIS_SCREEN_HEIGHT - 1) >> 1) - dy) return (((long)(((SIS_SCREEN_HEIGHT - 1) >> 1) - dy)
* (MAX_Y_UNIVERSE + 2)) >> LOBYTE (pMenuState->delta_item)) * (MAX_Y_UNIVERSE + 2)) >> zoomLevel)
/ SIS_SCREEN_HEIGHT + pMenuState->flash_rect1.corner.y; / SIS_SCREEN_HEIGHT + mapOrigin.y;
} }
#define DISP_TO_UNIVERSEY(dy) dispyToUniverse(dy) #define DISP_TO_UNIVERSEY(dy) dispyToUniverse(dy)
@@ -120,7 +124,7 @@ flashCurrentLocation (POINT *where)
OldColor = SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (c, c, c), c)); OldColor = SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (c, c, c), c));
s.origin.x = UNIVERSE_TO_DISPX (universe.x); s.origin.x = UNIVERSE_TO_DISPX (universe.x);
s.origin.y = UNIVERSE_TO_DISPY (universe.y); s.origin.y = UNIVERSE_TO_DISPY (universe.y);
s.frame = IncFrameIndex (pMenuState->CurFrame); s.frame = IncFrameIndex (StarMapFrame);
DrawFilledStamp (&s); DrawFilledStamp (&s);
SetContextForeGroundColor (OldColor); SetContextForeGroundColor (OldColor);
@@ -136,7 +140,7 @@ DrawCursor (COORD curs_x, COORD curs_y)
s.origin.x = curs_x; s.origin.x = curs_x;
s.origin.y = curs_y; s.origin.y = curs_y;
s.frame = pMenuState->CurFrame; s.frame = StarMapFrame;
DrawStamp (&s); DrawStamp (&s);
} }
@@ -362,13 +366,13 @@ DrawStarMap (COUNT race_update, RECT *pClipRect)
r.corner.x = UNIVERSE_TO_DISPX (0); r.corner.x = UNIVERSE_TO_DISPX (0);
r.corner.y = UNIVERSE_TO_DISPY (i); r.corner.y = UNIVERSE_TO_DISPY (i);
r.extent.width = SIS_SCREEN_WIDTH << LOBYTE (pMenuState->delta_item); r.extent.width = SIS_SCREEN_WIDTH << zoomLevel;
r.extent.height = 1; r.extent.height = 1;
DrawFilledRectangle (&r); DrawFilledRectangle (&r);
r.corner.y = UNIVERSE_TO_DISPY (MAX_Y_UNIVERSE + 1); r.corner.y = UNIVERSE_TO_DISPY (MAX_Y_UNIVERSE + 1);
r.extent.width = 1; r.extent.width = 1;
r.extent.height = SIS_SCREEN_HEIGHT << LOBYTE (pMenuState->delta_item); r.extent.height = SIS_SCREEN_HEIGHT << zoomLevel;
for (j = MAX_X_UNIVERSE + 1; j >= 0; j -= GRID_DELTA) for (j = MAX_X_UNIVERSE + 1; j >= 0; j -= GRID_DELTA)
{ {
r.corner.x = UNIVERSE_TO_DISPX (j); r.corner.x = UNIVERSE_TO_DISPX (j);
@@ -376,7 +380,7 @@ DrawStarMap (COUNT race_update, RECT *pClipRect)
} }
} }
star_frame = SetRelFrameIndex (pMenuState->CurFrame, 2); star_frame = SetRelFrameIndex (StarMapFrame, 2);
if (which_space <= 1) if (which_space <= 1)
{ {
COUNT index; COUNT index;
@@ -544,10 +548,8 @@ printf ("%s\n", buf);
{ {
GetContextClipRect (&r); GetContextClipRect (&r);
LoadIntoExtraScreen (&r); LoadIntoExtraScreen (&r);
DrawCursor ( DrawCursor (UNIVERSE_TO_DISPX (cursorLoc.x),
UNIVERSE_TO_DISPX (pMenuState->first_item.x), UNIVERSE_TO_DISPY (cursorLoc.y));
UNIVERSE_TO_DISPY (pMenuState->first_item.y)
);
} }
} }
@@ -560,7 +562,7 @@ EraseCursor (COORD curs_x, COORD curs_y)
{ {
RECT r; RECT r;
GetFrameRect (pMenuState->CurFrame, &r); GetFrameRect (StarMapFrame, &r);
if ((r.corner.x += curs_x) < 0) if ((r.corner.x += curs_x) < 0)
{ {
@@ -594,10 +596,10 @@ ZoomStarMap (SIZE dir)
#define MAX_ZOOM_SHIFT 4 #define MAX_ZOOM_SHIFT 4
if (dir > 0) if (dir > 0)
{ {
if (LOBYTE (pMenuState->delta_item) < MAX_ZOOM_SHIFT) if (zoomLevel < MAX_ZOOM_SHIFT)
{ {
++pMenuState->delta_item; ++zoomLevel;
pMenuState->flash_rect1.corner = pMenuState->first_item; mapOrigin = cursorLoc;
DrawStarMap (0, NULL); DrawStarMap (0, NULL);
SleepThread (ONE_SECOND / 8); SleepThread (ONE_SECOND / 8);
@@ -605,16 +607,16 @@ ZoomStarMap (SIZE dir)
} }
else if (dir < 0) else if (dir < 0)
{ {
if (LOBYTE (pMenuState->delta_item)) if (zoomLevel > 0)
{ {
if (LOBYTE (pMenuState->delta_item) > 1) if (zoomLevel > 1)
pMenuState->flash_rect1.corner = pMenuState->first_item; mapOrigin = cursorLoc;
else else
{ {
pMenuState->flash_rect1.corner.x = MAX_X_UNIVERSE >> 1; mapOrigin.x = MAX_X_UNIVERSE >> 1;
pMenuState->flash_rect1.corner.y = MAX_Y_UNIVERSE >> 1; mapOrigin.y = MAX_Y_UNIVERSE >> 1;
} }
--pMenuState->delta_item; --zoomLevel;
DrawStarMap (0, NULL); DrawStarMap (0, NULL);
SleepThread (ONE_SECOND / 8); SleepThread (ONE_SECOND / 8);
@@ -623,20 +625,20 @@ ZoomStarMap (SIZE dir)
} }
static void static void
UpdateCursorLocation (MENU_STATE *pMS, int sx, int sy, const POINT *newpt) UpdateCursorLocation (int sx, int sy, const POINT *newpt)
{ {
STAMP s; STAMP s;
POINT pt; POINT pt;
pt.x = UNIVERSE_TO_DISPX (pMS->first_item.x); pt.x = UNIVERSE_TO_DISPX (cursorLoc.x);
pt.y = UNIVERSE_TO_DISPY (pMS->first_item.y); pt.y = UNIVERSE_TO_DISPY (cursorLoc.y);
if (newpt) if (newpt)
{ // absolute move { // absolute move
sx = sy = 0; sx = sy = 0;
s.origin.x = UNIVERSE_TO_DISPX (newpt->x); s.origin.x = UNIVERSE_TO_DISPX (newpt->x);
s.origin.y = UNIVERSE_TO_DISPY (newpt->y); s.origin.y = UNIVERSE_TO_DISPY (newpt->y);
pMS->first_item = *newpt; cursorLoc = *newpt;
} }
else else
{ // incremental move { // incremental move
@@ -646,41 +648,41 @@ UpdateCursorLocation (MENU_STATE *pMS, int sx, int sy, const POINT *newpt)
if (sx) if (sx)
{ {
pMS->first_item.x = DISP_TO_UNIVERSEX (s.origin.x) - sx; cursorLoc.x = DISP_TO_UNIVERSEX (s.origin.x) - sx;
while (UNIVERSE_TO_DISPX (pMS->first_item.x) == pt.x) while (UNIVERSE_TO_DISPX (cursorLoc.x) == pt.x)
pMS->first_item.x += sx; cursorLoc.x += sx;
if (pMS->first_item.x < 0) if (cursorLoc.x < 0)
pMS->first_item.x = 0; cursorLoc.x = 0;
else if (pMS->first_item.x > MAX_X_UNIVERSE) else if (cursorLoc.x > MAX_X_UNIVERSE)
pMS->first_item.x = MAX_X_UNIVERSE; cursorLoc.x = MAX_X_UNIVERSE;
s.origin.x = UNIVERSE_TO_DISPX (pMS->first_item.x); s.origin.x = UNIVERSE_TO_DISPX (cursorLoc.x);
} }
if (sy) if (sy)
{ {
pMS->first_item.y = DISP_TO_UNIVERSEY (s.origin.y) + sy; cursorLoc.y = DISP_TO_UNIVERSEY (s.origin.y) + sy;
while (UNIVERSE_TO_DISPY (pMS->first_item.y) == pt.y) while (UNIVERSE_TO_DISPY (cursorLoc.y) == pt.y)
pMS->first_item.y -= sy; cursorLoc.y -= sy;
if (pMS->first_item.y < 0) if (cursorLoc.y < 0)
pMS->first_item.y = 0; cursorLoc.y = 0;
else if (pMS->first_item.y > MAX_Y_UNIVERSE) else if (cursorLoc.y > MAX_Y_UNIVERSE)
pMS->first_item.y = MAX_Y_UNIVERSE; cursorLoc.y = MAX_Y_UNIVERSE;
s.origin.y = UNIVERSE_TO_DISPY (pMS->first_item.y); s.origin.y = UNIVERSE_TO_DISPY (cursorLoc.y);
} }
if (s.origin.x < 0 || s.origin.y < 0 if (s.origin.x < 0 || s.origin.y < 0
|| s.origin.x >= SIS_SCREEN_WIDTH || s.origin.x >= SIS_SCREEN_WIDTH
|| s.origin.y >= SIS_SCREEN_HEIGHT) || s.origin.y >= SIS_SCREEN_HEIGHT)
{ {
pMS->flash_rect1.corner = pMS->first_item; mapOrigin = cursorLoc;
DrawStarMap (0, NULL); DrawStarMap (0, NULL);
s.origin.x = UNIVERSE_TO_DISPX (pMS->first_item.x); s.origin.x = UNIVERSE_TO_DISPX (cursorLoc.x);
s.origin.y = UNIVERSE_TO_DISPY (pMS->first_item.y); s.origin.y = UNIVERSE_TO_DISPY (cursorLoc.y);
} }
else else
{ {
@@ -695,18 +697,18 @@ UpdateCursorLocation (MENU_STATE *pMS, int sx, int sy, const POINT *newpt)
#define CURSOR_INFO_BUFSIZE 256 #define CURSOR_INFO_BUFSIZE 256
static void static void
UpdateCursorInfo (MENU_STATE *pMS, UNICODE *prevbuf) UpdateCursorInfo (UNICODE *prevbuf)
{ {
UNICODE buf[CURSOR_INFO_BUFSIZE] = ""; UNICODE buf[CURSOR_INFO_BUFSIZE] = "";
POINT pt; POINT pt;
STAR_DESC *SDPtr; STAR_DESC *SDPtr;
STAR_DESC *BestSDPtr; STAR_DESC *BestSDPtr;
pt.x = UNIVERSE_TO_DISPX (pMS->first_item.x); pt.x = UNIVERSE_TO_DISPX (cursorLoc.x);
pt.y = UNIVERSE_TO_DISPY (pMS->first_item.y); pt.y = UNIVERSE_TO_DISPY (cursorLoc.y);
SDPtr = BestSDPtr = 0; SDPtr = BestSDPtr = 0;
while ((SDPtr = FindStar (SDPtr, &pMS->first_item, 75, 75))) while ((SDPtr = FindStar (SDPtr, &cursorLoc, 75, 75)))
{ {
if (UNIVERSE_TO_DISPX (SDPtr->star_pt.x) == pt.x if (UNIVERSE_TO_DISPX (SDPtr->star_pt.x) == pt.x
&& UNIVERSE_TO_DISPY (SDPtr->star_pt.y) == pt.y && UNIVERSE_TO_DISPY (SDPtr->star_pt.y) == pt.y
@@ -717,21 +719,21 @@ UpdateCursorInfo (MENU_STATE *pMS, UNICODE *prevbuf)
if (BestSDPtr) if (BestSDPtr)
{ {
pMS->first_item = BestSDPtr->star_pt; cursorLoc = BestSDPtr->star_pt;
GetClusterName (BestSDPtr, buf); GetClusterName (BestSDPtr, buf);
} }
else else
{ // No star found. Reset the coordinates to the cursor's location { // No star found. Reset the coordinates to the cursor's location
pMS->first_item.x = DISP_TO_UNIVERSEX (pt.x); cursorLoc.x = DISP_TO_UNIVERSEX (pt.x);
if (pMS->first_item.x < 0) if (cursorLoc.x < 0)
pMS->first_item.x = 0; cursorLoc.x = 0;
else if (pMS->first_item.x > MAX_X_UNIVERSE) else if (cursorLoc.x > MAX_X_UNIVERSE)
pMS->first_item.x = MAX_X_UNIVERSE; cursorLoc.x = MAX_X_UNIVERSE;
pMS->first_item.y = DISP_TO_UNIVERSEY (pt.y); cursorLoc.y = DISP_TO_UNIVERSEY (pt.y);
if (pMS->first_item.y < 0) if (cursorLoc.y < 0)
pMS->first_item.y = 0; cursorLoc.y = 0;
else if (pMS->first_item.y > MAX_Y_UNIVERSE) else if (cursorLoc.y > MAX_Y_UNIVERSE)
pMS->first_item.y = MAX_Y_UNIVERSE; cursorLoc.y = MAX_Y_UNIVERSE;
} }
if (GET_GAME_STATE (ARILOU_SPACE)) if (GET_GAME_STATE (ARILOU_SPACE))
@@ -752,14 +754,14 @@ UpdateCursorInfo (MENU_STATE *pMS, UNICODE *prevbuf)
if (UNIVERSE_TO_DISPX (ari_pt.x) == pt.x if (UNIVERSE_TO_DISPX (ari_pt.x) == pt.x
&& UNIVERSE_TO_DISPY (ari_pt.y) == pt.y) && UNIVERSE_TO_DISPY (ari_pt.y) == pt.y)
{ {
pMS->first_item = ari_pt; cursorLoc = ari_pt;
utf8StringCopy (buf, sizeof (buf), utf8StringCopy (buf, sizeof (buf),
GAME_STRING (STAR_STRING_BASE + 132)); GAME_STRING (STAR_STRING_BASE + 132));
} }
} }
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
DrawHyperCoords (pMS->first_item); DrawHyperCoords (cursorLoc);
if (strcmp (buf, prevbuf) != 0) if (strcmp (buf, prevbuf) != 0)
{ {
strcpy (prevbuf, buf); strcpy (prevbuf, buf);
@@ -769,7 +771,7 @@ UpdateCursorInfo (MENU_STATE *pMS, UNICODE *prevbuf)
} }
static void static void
UpdateFuelRequirement (MENU_STATE *pMS) UpdateFuelRequirement (void)
{ {
UNICODE buf[80]; UNICODE buf[80];
COUNT fuel_required; COUNT fuel_required;
@@ -783,8 +785,8 @@ UpdateFuelRequirement (MENU_STATE *pMS)
pt.x = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x)); pt.x = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x));
pt.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y)); pt.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y));
} }
pt.x -= pMS->first_item.x; pt.x -= cursorLoc.x;
pt.y -= pMS->first_item.y; pt.y -= cursorLoc.y;
f = (DWORD)((long)pt.x * pt.x + (long)pt.y * pt.y); f = (DWORD)((long)pt.x * pt.x + (long)pt.y * pt.y);
if (f == 0 || GET_GAME_STATE (ARILOU_SPACE_SIDE) > 1) if (f == 0 || GET_GAME_STATE (ARILOU_SPACE_SIDE) > 1)
@@ -806,6 +808,7 @@ UpdateFuelRequirement (MENU_STATE *pMS)
typedef struct starsearch_state typedef struct starsearch_state
{ {
// TODO: pMS field is probably not needed anymore
MENU_STATE *pMS; MENU_STATE *pMS;
UNICODE Text[STAR_SEARCH_BUFSIZE]; UNICODE Text[STAR_SEARCH_BUFSIZE];
UNICODE LastText[STAR_SEARCH_BUFSIZE]; UNICODE LastText[STAR_SEARCH_BUFSIZE];
@@ -1048,7 +1051,7 @@ DrawMatchedStarName (TEXTENTRY_STATE *pTES)
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
DrawSISMessageEx (buf, CurPos, ExPos, flags); DrawSISMessageEx (buf, CurPos, ExPos, flags);
DrawHyperCoords (pMS->first_item); DrawHyperCoords (cursorLoc);
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
} }
@@ -1131,10 +1134,10 @@ OnStarNameChange (TEXTENTRY_STATE *pTES)
// move the cursor to the found star // move the cursor to the found star
SDPtr = &star_array[pSS->SortedStars[pSS->CurIndex]]; SDPtr = &star_array[pSS->SortedStars[pSS->CurIndex]];
UpdateCursorLocation (pMS, 0, 0, &SDPtr->star_pt); UpdateCursorLocation (0, 0, &SDPtr->star_pt);
DrawMatchedStarName (pTES); DrawMatchedStarName (pTES);
UpdateFuelRequirement (pMS); UpdateFuelRequirement ();
} }
return ret; return ret;
@@ -1161,10 +1164,10 @@ OnStarNameFrame (TEXTENTRY_STATE *pTES)
// move the cursor to the found star // move the cursor to the found star
SDPtr = &star_array[pSS->SortedStars[pSS->CurIndex]]; SDPtr = &star_array[pSS->SortedStars[pSS->CurIndex]];
UpdateCursorLocation (pMS, 0, 0, &SDPtr->star_pt); UpdateCursorLocation (0, 0, &SDPtr->star_pt);
DrawMatchedStarName (pTES); DrawMatchedStarName (pTES);
UpdateFuelRequirement (pMS); UpdateFuelRequirement ();
} }
flashCurrentLocation (NULL); flashCurrentLocation (NULL);
@@ -1247,8 +1250,8 @@ DoMoveCursor (MENU_STATE *pMS)
flashCurrentLocation (&universe); flashCurrentLocation (&universe);
last_buf[0] = '\0'; last_buf[0] = '\0';
UpdateCursorInfo (pMS, last_buf); UpdateCursorInfo (last_buf);
UpdateFuelRequirement (pMS); UpdateFuelRequirement ();
return TRUE; return TRUE;
} }
@@ -1258,7 +1261,7 @@ DoMoveCursor (MENU_STATE *pMS)
} }
else if (PulsedInputState.menu[KEY_MENU_SELECT]) else if (PulsedInputState.menu[KEY_MENU_SELECT])
{ {
GLOBAL (autopilot) = pMS->first_item; GLOBAL (autopilot) = cursorLoc;
#ifdef DEBUG #ifdef DEBUG
if (instantMove) if (instantMove)
{ {
@@ -1287,16 +1290,16 @@ DoMoveCursor (MENU_STATE *pMS)
{ {
if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1) if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1)
{ // HyperSpace search { // HyperSpace search
POINT oldpt = pMS->first_item; POINT oldpt = cursorLoc;
if (!DoStarSearch (pMS)) if (!DoStarSearch (pMS))
{ // search failed or canceled - return cursor { // search failed or canceled - return cursor
UpdateCursorLocation (pMS, 0, 0, &oldpt); UpdateCursorLocation (0, 0, &oldpt);
} }
// make sure cmp fails // make sure cmp fails
strcpy (last_buf, " <random garbage> "); strcpy (last_buf, " <random garbage> ");
UpdateCursorInfo (pMS, last_buf); UpdateCursorInfo (last_buf);
UpdateFuelRequirement (pMS); UpdateFuelRequirement ();
SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY, SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY,
STEP_ACCEL_DELAY, TRUE); STEP_ACCEL_DELAY, TRUE);
@@ -1328,9 +1331,9 @@ DoMoveCursor (MENU_STATE *pMS)
if (sx != 0 || sy != 0) if (sx != 0 || sy != 0)
{ {
UpdateCursorLocation (pMS, sx, sy, NULL); UpdateCursorLocation (sx, sy, NULL);
UpdateCursorInfo (pMS, last_buf); UpdateCursorInfo (last_buf);
UpdateFuelRequirement (pMS); UpdateFuelRequirement ();
} }
SleepThreadUntil (TimeIn + MIN_ACCEL_DELAY); SleepThreadUntil (TimeIn + MIN_ACCEL_DELAY);
@@ -1587,12 +1590,12 @@ DoStarMap (void)
CONTEXT OldContext; CONTEXT OldContext;
pMenuState = &MenuState; pMenuState = &MenuState;
memset (pMenuState, 0, sizeof (*pMenuState)); memset (&MenuState, 0, sizeof (MenuState));
MenuState.flash_rect1.corner.x = MAX_X_UNIVERSE >> 1; zoomLevel = 0;
MenuState.flash_rect1.corner.y = MAX_Y_UNIVERSE >> 1; mapOrigin.x = MAX_X_UNIVERSE >> 1;
MenuState.CurFrame = SetAbsFrameIndex (MiscDataFrame, 48); mapOrigin.y = MAX_Y_UNIVERSE >> 1;
MenuState.delta_item = 0; StarMapFrame = SetAbsFrameIndex (MiscDataFrame, 48);
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE) if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
universe = CurStarDescPtr->star_pt; universe = CurStarDescPtr->star_pt;
@@ -1602,9 +1605,9 @@ DoStarMap (void)
universe.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y)); universe.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y));
} }
MenuState.first_item = GLOBAL (autopilot); cursorLoc = GLOBAL (autopilot);
if (MenuState.first_item.x == ~0 && MenuState.first_item.y == ~0) if (cursorLoc.x == ~0 && cursorLoc.y == ~0)
MenuState.first_item = universe; cursorLoc = universe;
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
TaskSwitch (); TaskSwitch ();
@@ -1626,10 +1629,8 @@ DoStarMap (void)
GetContextClipRect (&clip_r); GetContextClipRect (&clip_r);
SetContext (OldContext); SetContext (OldContext);
LoadIntoExtraScreen (&clip_r); LoadIntoExtraScreen (&clip_r);
DrawCursor ( DrawCursor (UNIVERSE_TO_DISPX (cursorLoc.x),
UNIVERSE_TO_DISPX (MenuState.first_item.x), UNIVERSE_TO_DISPY (cursorLoc.y));
UNIVERSE_TO_DISPY (MenuState.first_item.y)
);
UnbatchGraphics (); UnbatchGraphics ();
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);