Quantum-erase GraphicsLock; Some changes needed to accomplish this:

* comm/trackplayer Callbacks are now queued instead of asynchronously called on the stream decoder thread
* libs/callback now guards the list with a mutex (called from different threads)
* only one thread (Starcon2Main) is allowed to queue draw commands right now; a sanity check is in place (define DEBUG_DCQ_THREADS)
Fixes: Alarms and Callbacks are used for more than just Netplay, reflect this.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3761 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2012-02-11 23:41:06 +00:00
parent 8e8b812cb7
commit 6be6491c05
72 changed files with 76 additions and 905 deletions
+14 -4
View File
@@ -23,6 +23,8 @@
#include <stdlib.h>
#include <sys/types.h>
#include "libs/threadlib.h"
typedef struct CallbackLink CallbackLink;
#define CALLBACK_INTERNAL
@@ -38,16 +40,16 @@ static CallbackLink *callbacks;
static CallbackLink **callbacksEnd;
static CallbackLink *const *callbacksProcessEnd;
static Mutex callbackListLock;
static inline void
CallbackList_lock(void) {
// TODO
// Necessary for reentrant operation
LockMutex(callbackListLock);
}
static inline void
CallbackList_unlock(void) {
// TODO
// Necessary for reentrant operation
UnlockMutex(callbackListLock);
}
#if 0
@@ -62,6 +64,14 @@ Callback_init(void) {
callbacks = NULL;
callbacksEnd = &callbacks;
callbacksProcessEnd = &callbacks;
callbackListLock = CreateMutex("Callback List Lock", SYNC_CLASS_TOPLEVEL);
}
void
Callback_uninit(void) {
// TODO: cleanup the queue?
DestroyMutex (callbackListLock);
callbackListLock = 0;
}
// Callbacks are guaranteed to be called in the order that they are queued.
+1
View File
@@ -33,6 +33,7 @@ typedef void *CallbackArg;
typedef void (*CallbackFunction)(CallbackArg arg);
void Callback_init(void);
void Callback_uninit(void);
CallbackID Callback_add(CallbackFunction callback, CallbackArg arg);
bool Callback_remove(CallbackID id);
void Callback_process(void);
+18
View File
@@ -216,6 +216,22 @@ TFB_DrawCommandQueue_Clear ()
UnlockRecursiveMutex (DCQ_Mutex);
}
static void
checkExclusiveThread (void)
{
#ifdef DEBUG_DCQ_THREADS
static uint32 exclusiveThreadId;
extern uint32 SDL_ThreadID(void);
// Only one thread is currently allowed to enqueue commands
// This is not a technical limitation but rather a semantical one atm.
if (!exclusiveThreadId)
exclusiveThreadId = SDL_ThreadID();
else
assert (SDL_ThreadID() == exclusiveThreadId);
#endif
}
void
TFB_EnqueueDrawCommand (TFB_DrawCommand* DrawCommand)
{
@@ -224,6 +240,8 @@ TFB_EnqueueDrawCommand (TFB_DrawCommand* DrawCommand)
return;
}
checkExclusiveThread ();
if (DrawCommand->Type <= TFB_DRAWCOMMANDTYPE_COPYTOIMAGE
&& _CurFramePtr->Type == SCREEN_DRAWABLE)
{
+3 -1
View File
@@ -17,6 +17,8 @@
#ifndef TRACKINT_H
#define TRACKINT_H
#include "libs/callback.h"
struct tfb_soundchunk
{
TFB_SoundDecoder *decoder; // decoder for this chunk
@@ -24,7 +26,7 @@ struct tfb_soundchunk
int tag_me; // set for chunks with subtitles
uint32 track_num; // logical track #, comm code needs this
UNICODE *text; // subtitle text
TFB_TrackCB callback; // comm callback, executed on chunk start
CallbackFunction callback; // comm callback, executed on chunk start
struct tfb_soundchunk *next;
};
+3 -2
View File
@@ -199,7 +199,8 @@ static void
DoTrackTag (TFB_SoundChunk *chunk)
{
if (chunk->callback)
chunk->callback ();
Callback_add(chunk->callback, 0);
cur_sub_chunk = chunk;
}
@@ -421,7 +422,7 @@ SpliceMultiTrack (UNICODE *TrackNames[], UNICODE *TrackText)
// XXX: This code and the entire trackplayer are begging to be overhauled
void
SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, TFB_TrackCB cb)
SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp, CallbackFunction cb)
{
static UNICODE last_track_name[128] = "";
static unsigned long dec_offset = 0;
+2 -3
View File
@@ -20,8 +20,7 @@
#define TRACKPLAYER_H
#include "libs/compiler.h"
typedef void (*TFB_TrackCB) (void);
#include "libs/callback.h"
#define ACCEL_SCROLL_SPEED 300
@@ -37,7 +36,7 @@ extern void FastForward_Smooth (void);
extern void FastReverse_Page (void);
extern void FastForward_Page (void);
extern void SpliceTrack (UNICODE *filespec, UNICODE *textspec, UNICODE *TimeStamp, TFB_TrackCB cb);
extern void SpliceTrack (UNICODE *filespec, UNICODE *textspec, UNICODE *TimeStamp, CallbackFunction cb);
extern void SpliceMultiTrack (UNICODE *TrackNames[], UNICODE *TrackText);
extern int GetTrackPosition (int in_units);
-2
View File
@@ -127,7 +127,6 @@ VidPlayEx (VIDEO_REF vid, MUSIC_REF AudRef, MUSIC_REF SpeechRef,
_cur_speech = 0;
_cur_video = NULL_VIDEO_REF;
LockMutex (GraphicsLock);
// play video in the center of the screen
if (TFB_PlayVideo (vid, (ScreenWidth - vid->w) / 2,
(ScreenHeight - vid->h) / 2))
@@ -144,7 +143,6 @@ VidPlayEx (VIDEO_REF vid, MUSIC_REF AudRef, MUSIC_REF SpeechRef,
{
ret = NO_FMV;
}
UnlockMutex (GraphicsLock);
return ret;
}
-6
View File
@@ -38,10 +38,4 @@ struct legacy_video_ref
MUSIC_REF speechref;
};
// XXX: There has to be a better way to synchronize gfx calls with the rest
// of the game. The only thing we need to sync is the current context, and
// even there only the cliprect. Perhaps a DCQ command that takes an
// explicit cliprect would be better.
extern Mutex GraphicsLock;
#endif
-4
View File
@@ -143,14 +143,12 @@ processAudioSyncedFrame (VIDEO_REF vid)
vid->cur_frame = vid->decoder->cur_frame;
// draw the frame
LockMutex (GraphicsLock);
// We have the cliprect precalculated and don't need the rest
oldContext = SetContext (NULL);
TFB_DrawScreen_Image (vid->frame,
vid->dst_rect.corner.x, vid->dst_rect.corner.y, 0, 0,
NULL, DRAW_REPLACE_MODE, TFB_SCREEN_MAIN);
SetContext (oldContext);
UnlockMutex (GraphicsLock);
FlushGraphics (); // needed to prevent half-frame updates
// increase interframe with positive lag-count to allow audio to catch up
@@ -195,14 +193,12 @@ processMuteFrame (VIDEO_REF vid)
vid->cur_frame = vid->decoder->cur_frame;
LockMutex (GraphicsLock);
// We have the cliprect precalculated and don't need the rest
oldContext = SetContext (NULL);
TFB_DrawScreen_Image (vid->frame,
vid->dst_rect.corner.x, vid->dst_rect.corner.y, 0, 0,
NULL, DRAW_REPLACE_MODE, TFB_SCREEN_MAIN);
SetContext (oldContext);
UnlockMutex (GraphicsLock);
FlushGraphics (); // needed to prevent half-frame updates
if (vid->cur_frame == vid->loop_frame)
+6 -6
View File
@@ -402,16 +402,14 @@ main (int argc, char *argv[])
InitTimeSystem ();
InitTaskSystem ();
#ifdef NETPLAY
Network_init ();
Alarm_init ();
Callback_init ();
#ifdef NETPLAY
Network_init ();
NetManager_init ();
#endif
GraphicsLock = CreateMutex ("Graphics",
SYNC_CLASS_TOPLEVEL | SYNC_CLASS_VIDEO);
gfxDriver = options.opengl.value ?
TFB_GFXDRIVER_SDL_OPENGL : TFB_GFXDRIVER_SDL_PURE;
gfxFlags = options.scaler.value;
@@ -476,10 +474,12 @@ main (int argc, char *argv[])
#ifdef NETPLAY
NetManager_uninit ();
Alarm_uninit ();
Network_uninit ();
#endif
Callback_uninit ();
Alarm_uninit ();
// Not yet: CleanupTaskSystem ();
UnInitTimeSystem ();
#if 0
-8
View File
@@ -302,7 +302,6 @@ DoBattle (BATTLE_STATE *bs)
}
#endif
LockMutex (GraphicsLock);
if (bs->first_time)
{
r.corner.x = SIS_ORG_X;
@@ -325,7 +324,6 @@ DoBattle (BATTLE_STATE *bs)
ScreenTransition (3, &r);
}
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
if ((!(GLOBAL (CurrentActivity) & IN_BATTLE)) ||
(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
@@ -399,7 +397,6 @@ Battle (BattleFrameCallback *callback)
{
SIZE num_ships;
LockMutex (GraphicsLock);
#if !(DEMO_MODE || CREATE_JOURNAL)
if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE) {
@@ -469,9 +466,7 @@ Battle (BattleFrameCallback *callback)
bs.first_time = (BOOLEAN)(LOBYTE (GLOBAL (CurrentActivity)) ==
IN_HYPERSPACE);
UnlockMutex (GraphicsLock);
DoInput (&bs, FALSE);
LockMutex (GraphicsLock);
AbortBattle:
if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE)
@@ -481,12 +476,10 @@ AbortBattle:
// Do not return to the main menu when a game is aborted,
// (just to the supermelee menu).
#ifdef NETPLAY
UnlockMutex (GraphicsLock);
waitResetConnections(NetState_inSetup);
// A connection may already be in inSetup (set from
// GetMeleeStarship). This is not a problem, although
// it will generate a warning in debug mode.
LockMutex (GraphicsLock);
#endif
GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
@@ -514,7 +507,6 @@ AbortBattle:
UninitShips ();
FreeBattleSong ();
UnlockMutex (GraphicsLock);
return (BOOLEAN) (num_ships < 0);
}
+1 -2
View File
@@ -31,8 +31,7 @@ extern "C" {
#endif
// The callback function is called on every battle frame
// with GraphicsLock held, just before the display queue
// is drawn
// just before the display queue is drawn
typedef void (BattleFrameCallback) (void);
typedef struct battlestate_struct {
-4
View File
@@ -144,9 +144,7 @@ AddEscortShips (COUNT race, SIZE count)
InsertQueue (&GLOBAL (built_ship_q), hStarShip, hOldShip);
}
LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
UnlockMutex (GraphicsLock);
return i;
}
@@ -389,9 +387,7 @@ RemoveSomeEscortShips (COUNT race, COUNT count)
if (count > 0)
{
// Update the display.
LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
UnlockMutex (GraphicsLock);
}
return count;
-2
View File
@@ -276,7 +276,6 @@ AddEvent (EVENT_TYPE type, COUNT month_index, COUNT day_index, COUNT
return (0);
}
// This function must be called with GraphicsLock held.
void
GameClockTick (void)
{
@@ -299,7 +298,6 @@ GameClockTick (void)
UnlockMutex (clock_mutex);
}
// This function must be called with GraphicsLock held.
void
MoveGameClockDays (COUNT days)
{
-2
View File
@@ -531,14 +531,12 @@ DrawConnectDialog (void)
r.corner.x = (SCREEN_WIDTH - r.extent.width) >> 1;
r.corner.y = (SCREEN_HEIGHT - r.extent.height) >> 1;
LockMutex (GraphicsLock);
DrawShadowedBox (&r, SHADOWBOX_BACKGROUND_COLOR,
SHADOWBOX_DARK_COLOR, SHADOWBOX_MEDIUM_COLOR);
menu.draw ((WIDGET *)&menu, r.corner.x + 10, r.corner.y + 10);
UnlockMutex (GraphicsLock);
}
static BOOLEAN
-34
View File
@@ -632,13 +632,11 @@ DoTalkSegue (TALKING_STATE *pTS)
CheckSubtitles ();
}
LockMutex (GraphicsLock);
// XXX: When seeking, all animations (talking and ambient) stop
// progressing. This is an original 3DO behavior, and I see no
// reason why the animations cannot continue while seeking.
UpdateAnimations (pTS->seeking);
UpdateSpeechGraphics ();
UnlockMutex (GraphicsLock);
curTrack = PlayingTrack ();
pTS->ended = !pTS->seeking && !curTrack;
@@ -653,9 +651,7 @@ DoTalkSegue (TALKING_STATE *pTS)
static void
runCommAnimFrame (void)
{
LockMutex (GraphicsLock);
UpdateCommGraphics ();
UnlockMutex (GraphicsLock);
SleepThread (COMM_ANIM_RATE);
}
@@ -764,13 +760,11 @@ AlienTalkSegue (COUNT wait_track)
if (!pCurInputState->Initialized)
{
InitSpeechGraphics ();
LockMutex (GraphicsLock);
SetColorMap (GetColorMapAddress (CommData.AlienColorMap));
SetContext (AnimContext);
DrawAlienFrame (NULL, 0, TRUE);
UpdateSpeechGraphics ();
CommIntroTransition ();
UnlockMutex (GraphicsLock);
pCurInputState->Initialized = TRUE;
@@ -845,7 +839,6 @@ DoConvSummary (SUMMARY_STATE *pSS)
r.extent.width = SIS_SCREEN_WIDTH;
r.extent.height = SIS_SCREEN_HEIGHT - SLIDER_Y - SLIDER_HEIGHT + 2;
LockMutex (GraphicsLock);
SetContext (AnimContext);
SetContextForeGroundColor (COMM_HISTORY_BACKGROUND_COLOR);
DrawFilledRectangle (&r);
@@ -914,7 +907,6 @@ DoConvSummary (SUMMARY_STATE *pSS)
font_DrawText (&mt);
}
UnlockMutex (GraphicsLock);
pSS->PrintNext = FALSE;
}
@@ -934,9 +926,7 @@ SelectResponse (ENCOUNTER_STATE *pES)
&pES->response_list[pES->cur_response].response_text;
utf8StringCopy (pES->phrase_buf, sizeof pES->phrase_buf,
response_text->pStr);
LockMutex (GraphicsLock);
FeedbackPlayerPhrase (pES->phrase_buf);
UnlockMutex (GraphicsLock);
StopTrack ();
ClearSubtitles ();
SetSliderImage (SetAbsFrameIndex (ActivityFrame, 2));
@@ -955,29 +945,23 @@ SelectConversationSummary (ENCOUNTER_STATE *pES)
{
SUMMARY_STATE SummaryState;
LockMutex (GraphicsLock);
if (pES)
FeedbackPlayerPhrase (pES->phrase_buf);
UnlockMutex (GraphicsLock);
SummaryState.Initialized = FALSE;
DoConvSummary (&SummaryState);
LockMutex (GraphicsLock);
if (pES)
RefreshResponses (pES);
clear_subtitles = TRUE;
UnlockMutex (GraphicsLock);
}
static void
SelectReplay (ENCOUNTER_STATE *pES)
{
FadeMusic (BACKGROUND_VOL, ONE_SECOND);
LockMutex (GraphicsLock);
if (pES)
FeedbackPlayerPhrase (pES->phrase_buf);
UnlockMutex (GraphicsLock);
TalkSegue (0);
}
@@ -990,9 +974,7 @@ PlayerResponseInput (ENCOUNTER_STATE *pES)
if (pES->top_response == (BYTE)~0)
{
pES->top_response = 0;
LockMutex (GraphicsLock);
RefreshResponses (pES);
UnlockMutex (GraphicsLock);
}
if (PulsedInputState.menu[KEY_MENU_SELECT])
@@ -1013,9 +995,7 @@ PlayerResponseInput (ENCOUNTER_STATE *pES)
if (!(GLOBAL (CurrentActivity) & CHECK_ABORT))
{
LockMutex (GraphicsLock);
RefreshResponses (pES);
UnlockMutex (GraphicsLock);
FadeMusic (FOREGROUND_VOL, ONE_SECOND);
}
}
@@ -1029,7 +1009,6 @@ PlayerResponseInput (ENCOUNTER_STATE *pES)
{
COORD y;
LockMutex (GraphicsLock);
BatchGraphics ();
add_text (-2,
&pES->response_list[pES->cur_response].response_text);
@@ -1049,12 +1028,9 @@ PlayerResponseInput (ENCOUNTER_STATE *pES)
RefreshResponses (pES);
}
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
}
LockMutex (GraphicsLock);
UpdateCommGraphics ();
UnlockMutex (GraphicsLock);
SleepThreadUntil (pES->NextTime);
pES->NextTime = GetTimeCounter () + COMM_ANIM_RATE;
@@ -1094,9 +1070,7 @@ DoLastReplay (LAST_REPLAY_STATE *pLRS)
pLRS->TimeOut = FadeMusic (0, ONE_SECOND * 2) + ONE_SECOND / 60;
}
LockMutex (GraphicsLock);
UpdateCommGraphics ();
UnlockMutex (GraphicsLock);
SleepThreadUntil (pLRS->NextTime);
pLRS->NextTime = GetTimeCounter () + COMM_ANIM_RATE;
@@ -1135,11 +1109,9 @@ DoCommunication (ENCOUNTER_STATE *pES)
return TRUE;
}
LockMutex (GraphicsLock);
SetContext (SpaceContext);
DestroyContext (AnimContext);
AnimContext = NULL;
UnlockMutex (GraphicsLock);
FlushColorXForms ();
ClearSubtitles ();
@@ -1228,7 +1200,6 @@ HailAlien (void)
SubtitleText.baseline = CommData.AlienTextBaseline;
SubtitleText.align = CommData.AlienTextAlign;
LockMutex (GraphicsLock);
// init subtitle cache context
TextCacheContext = CreateContext ("TextCacheContext");
@@ -1293,7 +1264,6 @@ HailAlien (void)
DrawSISComWindow ();
}
UnlockMutex (GraphicsLock);
LastActivity |= CHECK_LOAD; /* prevent spurious input */
(*CommData.init_encounter_func) ();
@@ -1302,10 +1272,8 @@ HailAlien (void)
(*CommData.post_encounter_func) ();
(*CommData.uninit_encounter_func) ();
LockMutex (GraphicsLock);
SetContext (SpaceContext);
SetContextFont (OldFont);
UnlockMutex (GraphicsLock);
DestroyStringTable (ReleaseStringTable (CommData.ConversationPhrases));
DestroyMusic (CommData.AlienSong);
@@ -1343,7 +1311,6 @@ InitCommunication (CONVERSATION which_comm)
return 0;
#endif
LockMutex (GraphicsLock);
if (LastActivity & CHECK_LOAD)
{
@@ -1369,7 +1336,6 @@ InitCommunication (CONVERSATION which_comm)
}
}
UnlockMutex (GraphicsLock);
if (which_comm == URQUAN_DRONE_CONVERSATION)
{
-26
View File
@@ -227,10 +227,8 @@ NoRadioactives (RESPONSE_REF R)
{
NPCPhrase (HERE_IS_A_NEW_LANDER);
++GLOBAL_SIS (NumLanders);
LockMutex (GraphicsLock);
DrawLanders ();
DeltaSISGauges (4, 0, 0);
UnlockMutex (GraphicsLock);
SET_GAME_STATE (LANDERS_LOST, 1);
}
@@ -238,27 +236,21 @@ NoRadioactives (RESPONSE_REF R)
{
NPCPhrase (HERE_IS_ANOTHER_LANDER);
++GLOBAL_SIS (NumLanders);
LockMutex (GraphicsLock);
DrawLanders ();
DeltaSISGauges (4, 0, 0);
UnlockMutex (GraphicsLock);
}
else if (PLAYER_SAID (R, need_fuel_mercury) ||
PLAYER_SAID (R, need_fuel_luna))
{
NPCPhrase (GIVE_FUEL);
LockMutex (GraphicsLock);
DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0);
UnlockMutex (GraphicsLock);
SET_GAME_STATE (GIVEN_FUEL_BEFORE, 1);
}
else if (PLAYER_SAID (R, need_fuel_again))
{
NPCPhrase (GIVE_FUEL_AGAIN);
LockMutex (GraphicsLock);
DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0);
UnlockMutex (GraphicsLock);
}
if (GLOBAL_SIS (ElementAmounts[RADIOACTIVE]))
@@ -297,10 +289,8 @@ AskAfterRadios (RESPONSE_REF R)
{
NPCPhrase (HERE_IS_A_NEW_LANDER);
++GLOBAL_SIS (NumLanders);
LockMutex (GraphicsLock);
DrawLanders ();
DeltaSISGauges (4, 0, 0);
UnlockMutex (GraphicsLock);
SET_GAME_STATE (LANDERS_LOST, 1);
}
@@ -308,27 +298,21 @@ AskAfterRadios (RESPONSE_REF R)
{
NPCPhrase (HERE_IS_ANOTHER_LANDER);
++GLOBAL_SIS (NumLanders);
LockMutex (GraphicsLock);
DrawLanders ();
DeltaSISGauges (4, 0, 0);
UnlockMutex (GraphicsLock);
}
else if (PLAYER_SAID (R, need_fuel_mercury) ||
PLAYER_SAID (R, need_fuel_luna))
{
NPCPhrase (GIVE_FUEL);
LockMutex (GraphicsLock);
DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0);
UnlockMutex (GraphicsLock);
SET_GAME_STATE (GIVEN_FUEL_BEFORE, 1);
}
else if (PLAYER_SAID (R, need_fuel_again))
{
NPCPhrase (GIVE_FUEL_AGAIN);
LockMutex (GraphicsLock);
DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0);
UnlockMutex (GraphicsLock);
}
else if (PLAYER_SAID (R, where_get_radios))
{
@@ -399,10 +383,8 @@ TellMoonBase (RESPONSE_REF R)
{
NPCPhrase (HERE_IS_A_NEW_LANDER);
++GLOBAL_SIS (NumLanders);
LockMutex (GraphicsLock);
DrawLanders ();
DeltaSISGauges (4, 0, 0);
UnlockMutex (GraphicsLock);
SET_GAME_STATE (LANDERS_LOST, 1);
}
@@ -410,27 +392,21 @@ TellMoonBase (RESPONSE_REF R)
{
NPCPhrase (HERE_IS_ANOTHER_LANDER);
++GLOBAL_SIS (NumLanders);
LockMutex (GraphicsLock);
DrawLanders ();
DeltaSISGauges (4, 0, 0);
UnlockMutex (GraphicsLock);
}
else if (PLAYER_SAID (R, need_fuel_mercury) ||
PLAYER_SAID (R, need_fuel_luna))
{
NPCPhrase (GIVE_FUEL);
LockMutex (GraphicsLock);
DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0);
UnlockMutex (GraphicsLock);
SET_GAME_STATE (GIVEN_FUEL_BEFORE, 1);
}
else if (PLAYER_SAID (R, need_fuel_again))
{
NPCPhrase (GIVE_FUEL_AGAIN);
LockMutex (GraphicsLock);
DeltaSISGauges (0, 5 * FUEL_TANK_SCALE, 0);
UnlockMutex (GraphicsLock);
}
else if (PLAYER_SAID (R, we_are_here_to_help))
{
@@ -593,9 +569,7 @@ GiveRadios (RESPONSE_REF R)
NPCPhrase (FUEL_UP1);
AlienTalkSegue (1);
LockMutex (GraphicsLock);
CommData.AlienAmbientArray[2].AnimFlags |= ANIM_DISABLED;
UnlockMutex (GraphicsLock);
XFormColorMap (GetColorMapAddress (
SetAbsColorMapIndex (CommData.AlienColorMap, 0)
-12
View File
@@ -244,9 +244,7 @@ Buy (RESPONSE_REF R)
NPCPhrase (NOT_ENOUGH_ROOM);
else
{
LockMutex (GraphicsLock);
DeltaSISGauges (-SHIP_CREW_COST, 0, 0);
UnlockMutex (GraphicsLock);
SlaveryCount += SHIP_CREW_COST;
AddEscortShips (DRUUGE_SHIP, 1);
@@ -260,9 +258,7 @@ Buy (RESPONSE_REF R)
NPCPhrase (NOT_ENOUGH_CREW);
else
{
LockMutex (GraphicsLock);
DeltaSISGauges (-ARTIFACT_CREW_COST, 0, 0);
UnlockMutex (GraphicsLock);
SlaveryCount += ARTIFACT_CREW_COST;
SET_GAME_STATE (ROSY_SPHERE_ON_SHIP, 1);
SET_GAME_STATE (ROSY_SPHERE, 1);
@@ -276,9 +272,7 @@ Buy (RESPONSE_REF R)
NPCPhrase (NOT_ENOUGH_CREW);
else
{
LockMutex (GraphicsLock);
DeltaSISGauges (-ARTIFACT_CREW_COST, 0, 0);
UnlockMutex (GraphicsLock);
SlaveryCount += ARTIFACT_CREW_COST;
SET_GAME_STATE (ARTIFACT_2_ON_SHIP, 1);
@@ -291,9 +285,7 @@ Buy (RESPONSE_REF R)
NPCPhrase (NOT_ENOUGH_CREW);
else
{
LockMutex (GraphicsLock);
DeltaSISGauges (-ARTIFACT_CREW_COST, 0, 0);
UnlockMutex (GraphicsLock);
SlaveryCount += ARTIFACT_CREW_COST;
SET_GAME_STATE (ARTIFACT_3_ON_SHIP, 1);
@@ -307,10 +299,8 @@ Buy (RESPONSE_REF R)
NPCPhrase (NOT_ENOUGH_CREW);
else
{
LockMutex (GraphicsLock);
DeltaSISGauges (-FUEL_CREW_COST,
FUEL_CREW_COST * FUEL_TANK_SCALE, 0);
UnlockMutex (GraphicsLock);
SlaveryCount += FUEL_CREW_COST;
NPCPhrase (BOUGHT_FUEL);
@@ -466,14 +456,12 @@ DoTransaction (RESPONSE_REF R)
capacity -= GLOBAL_SIS (FuelOnBoard);
f = (COUNT)((capacity + (FUEL_TANK_SCALE >> 1)) / FUEL_TANK_SCALE);
LockMutex (GraphicsLock);
while (capacity > 0x3FFFL)
{
DeltaSISGauges (0, 0x3FFF, 0);
capacity -= 0x3FFF;
}
DeltaSISGauges (0, (SIZE)capacity, 0);
UnlockMutex (GraphicsLock);
NPCPhrase (FUEL0);
NPCNumber (f, NULL);
-16
View File
@@ -21,8 +21,6 @@
#include "strings.h"
#include "uqm/gameev.h"
#include "uqm/setup.h"
// for GraphicsLock
#include "uqm/shipcont.h"
#include "libs/inplib.h"
#include "libs/mathlib.h"
@@ -590,9 +588,7 @@ StripShip (COUNT fuel_required)
if (fuel_required == 0)
{
GlobData.SIS_state = SIS_copy;
LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, rescue_fuel, UNDEFINED_DELTA);
UnlockMutex (GraphicsLock);
}
else if (fuel_required == (COUNT)~0)
{
@@ -616,9 +612,7 @@ StripShip (COUNT fuel_required)
GLOBAL_SIS (ModuleSlots[i]) = EMPTY_SLOT + 2;
}
LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
UnlockMutex (GraphicsLock);
}
else if (fuel_required)
{
@@ -735,9 +729,7 @@ StripShip (COUNT fuel_required)
if (total == 0)
{
NPCPhrase (CHARITY);
LockMutex (GraphicsLock);
DeltaSISGauges (0, fuel_required, 0);
UnlockMutex (GraphicsLock);
return (FALSE);
}
else
@@ -891,9 +883,7 @@ DeltaCredit (SIZE delta_credit)
{
Credit += delta_credit;
SetAvailableCredits (Credit);
LockMutex (GraphicsLock);
DrawStatusMessage (NULL);
UnlockMutex (GraphicsLock);
return true;
}
@@ -1045,14 +1035,12 @@ DoBuy (RESPONSE_REF R)
NPCPhrase (GOT_FUEL);
f = (DWORD)needed_credit * FUEL_TANK_SCALE;
LockMutex (GraphicsLock);
while (f > 0x3FFFL)
{
DeltaSISGauges (0, 0x3FFF, 0);
f -= 0x3FFF;
}
DeltaSISGauges (0, (SIZE)f, 0);
UnlockMutex (GraphicsLock);
}
needed_credit *= (BIO_CREDIT_VALUE / 2);
}
@@ -1251,9 +1239,7 @@ DoSell (RESPONSE_REF R)
} while (GLOBAL_SIS (TotalBioMass));
SleepThread (ONE_SECOND / 2);
LockMutex (GraphicsLock);
ClearSISRect (DRAW_SIS_DISPLAY);
UnlockMutex (GraphicsLock);
}
else /* if (R == sell_rainbow_locations) */
{
@@ -1838,11 +1824,9 @@ uninit_melnorme (void)
static void
post_melnorme_enc (void)
{
LockMutex (GraphicsLock);
if (prevMsgMode != SMM_UNDEFINED)
SetStatusMessageMode (prevMsgMode);
DrawStatusMessage (NULL);
UnlockMutex (GraphicsLock);
}
LOCDATA*
-8
View File
@@ -1656,9 +1656,7 @@ NormalStarbase (RESPONSE_REF R)
else
NPCPhrase (GLOBAL_SHIP_NAME);
NPCPhrase (STARBASE_IS_READY_C);
LockMutex (GraphicsLock);
DeltaSISGauges (0, 0, 2500);
UnlockMutex (GraphicsLock);
SET_GAME_STATE (STARBASE_MONTH,
GLOBAL (GameClock.month_index));
SET_GAME_STATE (STARBASE_DAY,
@@ -1770,9 +1768,7 @@ SellMinerals (RESPONSE_REF R)
Sleepy = FALSE;
GLOBAL_SIS (ElementAmounts[i]) = 0;
GLOBAL_SIS (TotalElementMass) -= amount;
LockMutex (GraphicsLock);
DeltaSISGauges (0, 0, amount * GLOBAL (ElementWorth[i]));
UnlockMutex (GraphicsLock);
break;
}
@@ -1781,10 +1777,8 @@ SellMinerals (RESPONSE_REF R)
TaskSwitch ();
TimeIn = GetTimeCounter ();
DrawCargoStrings ((BYTE)i, (BYTE)i);
LockMutex (GraphicsLock);
ShowRemainingCapacity ();
DeltaSISGauges (0, 0, GLOBAL (ElementWorth[i]));
UnlockMutex (GraphicsLock);
} while (--amount);
}
if (Sleepy) {
@@ -1794,9 +1788,7 @@ SellMinerals (RESPONSE_REF R)
}
SleepThread (ONE_SECOND / 2);
LockMutex (GraphicsLock);
ClearSISRect (DRAW_SIS_DISPLAY);
UnlockMutex (GraphicsLock);
// DrawStorageBays (FALSE);
if (total < 1000)
+9 -11
View File
@@ -118,15 +118,12 @@ enum
static int LastAlien;
// Queued and executes synchronously on the Starcon2Main thread
static void
SelectAlienZOQ (void)
SelectAlienZOQ (CallbackArg arg)
{
if (LastAlien != ZOQ_ALIEN)
{
// XXX: This should hold the GraphicsLock to block comm anims and
// prevent CommData half-updates, but if we do so, the stream
// decoder will deadlock with the drawing thread.
// Transition to neutral state first if Pik was talking
if (LastAlien != FOT_ALIEN)
CommData.AlienTransitionDesc.AnimFlags |= TALK_DONE;
@@ -142,17 +139,16 @@ SelectAlienZOQ (void)
CommData.AlienTextFColor = ZOQ_FG_COLOR;
CommData.AlienTextBColor = ZOQ_BG_COLOR;
}
(void)arg; // ignored
}
// Queued and executes synchronously on the Starcon2Main thread
static void
SelectAlienPIK (void)
SelectAlienPIK (CallbackArg arg)
{
if (LastAlien != PIK_ALIEN)
{
// XXX: This should hold the GraphicsLock to block comm anims and
// prevent CommData half-updates, but if we do so, the stream
// decoder will deadlock with the drawing thread.
// Transition to neutral state first if Zoq was talking
if (LastAlien != FOT_ALIEN)
CommData.AlienTransitionDesc.AnimFlags |= TALK_DONE;
@@ -168,13 +164,15 @@ SelectAlienPIK (void)
CommData.AlienTextFColor = PIK_FG_COLOR;
CommData.AlienTextBColor = PIK_BG_COLOR;
}
(void)arg; // ignored
}
static void
ZFPTalkSegue (COUNT wait_track)
{
LastAlien = FOT_ALIEN;
SelectAlienZOQ ();
SelectAlienZOQ (0);
AlienTalkSegue (wait_track);
}
+3 -1
View File
@@ -28,8 +28,10 @@
static int NPCNumberPhrase (int number, const char *fmt, UNICODE **ptrack);
// The CallbackFunction is queued and executes synchronously
// on the Starcon2Main thread
void
NPCPhrase_cb (int index, TFB_TrackCB cb)
NPCPhrase_cb (int index, CallbackFunction cb)
{
UNICODE *pStr, buf[400];
void *pClip, *pTimeStamp;
+4 -1
View File
@@ -22,6 +22,7 @@
#include "globdata.h"
#include "resinst.h"
#include "libs/sound/trackplayer.h"
#include "libs/callback.h"
#if defined(__cplusplus)
extern "C" {
@@ -88,7 +89,9 @@ extern void DoResponsePhrase (RESPONSE_REF R, RESPONSE_FUNC
response_func, UNICODE *ContstructStr);
extern void DoNPCPhrase (UNICODE *pStr);
extern void NPCPhrase_cb (int index, TFB_TrackCB cb);
// The CallbackFunction is queued and executes synchronously
// on the Starcon2Main thread
extern void NPCPhrase_cb (int index, CallbackFunction cb);
#define NPCPhrase(index) NPCPhrase_cb ((index), NULL)
extern void NPCPhrase_splice (int index);
extern void NPCNumber (int number, const char *fmt);
-4
View File
@@ -85,7 +85,6 @@ DoConfirmExit (void)
PauseFlash ();
LockMutex (GraphicsLock);
{
RECT r;
STAMP s;
@@ -160,7 +159,6 @@ DoConfirmExit (void)
SetContextClipRect (&oldRect);
SetContext (oldContext);
}
UnlockMutex (GraphicsLock);
ContinueFlash ();
@@ -217,7 +215,6 @@ DoPopupWindow (const char *msg)
label.lines = lines;
PauseFlash ();
LockMutex (GraphicsLock);
oldContext = SetContext (ScreenContext);
GetContextClipRect (&oldRect);
@@ -246,7 +243,6 @@ DoPopupWindow (const char *msg)
DestroyDrawable (ReleaseDrawable (s.frame));
SetContextClipRect (&oldRect);
SetContext (oldContext);
UnlockMutex (GraphicsLock);
ContinueFlash ();
SetMenuSounds (s0, s1);
StringBank_Free (bank);
-3
View File
@@ -119,9 +119,6 @@ BOOLEAN WaitForNoInputUntil (TimeCount timeOut, BOOLEAN resetInput);
void DoPopupWindow(const char *msg);
typedef void (InputFrameCallback) (void);
// Anything using input callbacks MUST NOT keep GraphicsLock across
// InputFunc executions. This also means NOT holding GraphicsLock
// when calling DoInput().
InputFrameCallback* SetInputCallback (InputFrameCallback *);
// pInputState must point to a struct derived from INPUT_STATE_DESC
void DoInput (void *pInputState, BOOLEAN resetInput);
-14
View File
@@ -240,7 +240,6 @@ Credits_RenderTextFrame (CONTEXT TempContext, int *istr, int dir,
t.pStr = " ";
t.CharCount = 1;
LockMutex (GraphicsLock);
OldContext = SetContext (TempContext);
// get font dimensions
@@ -312,7 +311,6 @@ Credits_RenderTextFrame (CONTEXT TempContext, int *istr, int dir,
SetContextFGFrame (OldFrame);
SetContext (OldContext);
UnlockMutex (GraphicsLock);
return f;
}
@@ -331,7 +329,6 @@ RenderCreditsScreen (CONTEXT targetContext)
STAMP s;
int i;
LockMutex (GraphicsLock);
oldContext = SetContext (targetContext);
// draw background
s.origin.x = 0;
@@ -358,7 +355,6 @@ RenderCreditsScreen (CONTEXT targetContext)
}
SetContext (oldContext);
UnlockMutex (GraphicsLock);
}
static void
@@ -373,7 +369,6 @@ InitCredits (void)
LocalContext = CreateContext ("Credits.LocalContext");
DrawContext = CreateContext ("Credits.DrawContext");
LockMutex (GraphicsLock);
targetFrame = GetContextFGFrame ();
GetContextClipRect (&ctxRect);
CreditsExtent = ctxRect.extent;
@@ -402,7 +397,6 @@ InitCredits (void)
SetContextFGFrame (targetFrame);
SetContext (oldContext);
UnlockMutex (GraphicsLock);
// Prepare the first screen frame
RenderCreditsScreen (LocalContext);
@@ -493,12 +487,10 @@ processCreditsFrame (void)
s.origin.y = 0;
s.frame = CreditsFrame;
LockMutex (GraphicsLock);
OldContext = SetContext (DrawContext);
DrawStamp (&s);
SetContext (OldContext);
FlushGraphics ();
UnlockMutex (GraphicsLock);
// prepare next screen frame
deficitHeight = calcDeficitHeight ();
@@ -782,13 +774,11 @@ Credits (BOOLEAN WithOuttakes)
hMusic = LoadMusic (CREDITS_MUSIC);
LockMutex (GraphicsLock);
SetContext (ScreenContext);
SetContextClipRect (NULL);
GetContextClipRect (&screenRect);
SetContextBackGroundColor (BLACK_COLOR);
ClearDrawable ();
UnlockMutex (GraphicsLock);
if (!LoadCredits ())
return;
@@ -797,10 +787,8 @@ Credits (BOOLEAN WithOuttakes)
s.origin.x = 0;
s.origin.y = 0;
s.frame = CreditsBack;
LockMutex (GraphicsLock);
DrawStamp (&s);
FadeScreen (FadeAllToColor, ONE_SECOND / 2);
UnlockMutex (GraphicsLock);
// set the position of outtakes comm
CommWndRect.corner.x = (screenRect.extent.width - CommWndRect.extent.width)
@@ -836,11 +824,9 @@ Credits (BOOLEAN WithOuttakes)
FadeMusic (0, ONE_SECOND / 2);
UninitCredits ();
LockMutex (GraphicsLock);
SetContext (ScreenContext);
SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2));
FlushColorXForms ();
UnlockMutex (GraphicsLock);
if (hMusic)
{
-26
View File
@@ -78,9 +78,7 @@ DoSelectAction (MENU_STATE *pMS)
if (!GameOptions ())
return FALSE;
DrawMenuStateStrings (PM_CONVERSE, pMS->CurState);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
break;
default:
printf ("Unknown option: %d\n", pMS->CurState);
@@ -270,7 +268,6 @@ InitEncounter (void)
extern FRAME planet[];
MUSIC_REF MR;
LockMutex (GraphicsLock);
SetContext (SpaceContext);
SetContextFont (TinyFont);
@@ -278,11 +275,9 @@ InitEncounter (void)
MR = LoadMusic (REDALERT_MUSIC);
PlayMusic (MR, FALSE, 1);
SegueFrame = CaptureDrawable (LoadGraphic (SEGUE_PMAP_ANIM));
UnlockMutex (GraphicsLock);
WaitForSoundEnd (TFBSOUND_WAIT_ALL);
StopMusic ();
DestroyMusic (MR);
LockMutex (GraphicsLock);
s.origin.x = s.origin.y = 0;
SetTransitionSource (NULL);
@@ -394,7 +389,6 @@ InitEncounter (void)
DestroyDrawable (ReleaseDrawable (SegueFrame));
ScreenTransition (3, NULL);
UnlockMutex (GraphicsLock);
{
MENU_STATE MenuState;
@@ -403,15 +397,11 @@ InitEncounter (void)
MenuState.Initialized = FALSE;
DrawMenuStateStrings (PM_CONVERSE, MenuState.CurState = HAIL);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
DoInput (&MenuState, TRUE);
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
return (MenuState.CurState);
}
@@ -451,10 +441,8 @@ DrawFadeText (const UNICODE *str1, const UNICODE *str2, BOOLEAN fade_in,
{
for (i = 0; i < (SIZE) NUM_FADES; ++i)
{
UnlockMutex (GraphicsLock);
if (AnyButtonPress (TRUE))
i = NUM_FADES - 1;
LockMutex (GraphicsLock);
SetContextForeGroundColor (fade_cycle[i]);
font_DrawText (&t1);
@@ -467,10 +455,8 @@ DrawFadeText (const UNICODE *str1, const UNICODE *str2, BOOLEAN fade_in,
{
for (i = NUM_FADES - 1; i >= 0; --i)
{
UnlockMutex (GraphicsLock);
if (AnyButtonPress (TRUE))
i = 0;
LockMutex (GraphicsLock);
SetContextForeGroundColor (fade_cycle[i]);
font_DrawText (&t1);
@@ -492,7 +478,6 @@ UninitEncounter (void)
ships_killed = 0;
LockMutex (GraphicsLock);
free_gravity_well ();
if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
@@ -702,10 +687,8 @@ UninitEncounter (void)
TimeCount Time = GetTimeCounter ();
for (j = 0; j < NUM_SHIP_FADES; ++j)
{
UnlockMutex (GraphicsLock);
Sleepy = (BOOLEAN)!AnyButtonPress (TRUE) &&
!(GLOBAL (CurrentActivity) & CHECK_ABORT);
LockMutex (GraphicsLock);
if (!Sleepy)
break;
@@ -738,9 +721,7 @@ UninitEncounter (void)
DestroyDrawable (ReleaseDrawable (s.frame));
#endif /* NEVER */
UnlockMutex (GraphicsLock);
WaitForAnyButton (TRUE, ONE_SECOND * 3, FALSE);
LockMutex (GraphicsLock);
if (!CurrentInputState.key[PlayerControls[0]][KEY_ESCAPE])
{
DrawFadeText (str1, str2, FALSE, &scavenge_r);
@@ -766,9 +747,7 @@ UninitEncounter (void)
str2 = GAME_STRING (ENCOUNTER_STRING_BASE + 7);
// "Scavenged"
DrawFadeText (str1, str2, TRUE, &scavenge_r);
UnlockMutex (GraphicsLock);
WaitForAnyButton (TRUE, ONE_SECOND * 2, FALSE);
LockMutex (GraphicsLock);
if (!CurrentInputState.key[PlayerControls[0]][KEY_ESCAPE])
DrawFadeText (str1, str2, FALSE, &scavenge_r);
}
@@ -787,7 +766,6 @@ UninitEncounter (void)
}
}
ExitUninitEncounter:
UnlockMutex (GraphicsLock);
return (ships_killed);
}
@@ -799,7 +777,6 @@ EncounterBattle (void)
extern UWORD nth_frame;
InputContext *savedPlayerInput = NULL;
LockMutex (GraphicsLock);
SET_GAME_STATE (BATTLE_SEGUE, 1);
@@ -838,9 +815,7 @@ EncounterBattle (void)
GameSounds = CaptureSound (LoadSound (GAME_SOUNDS));
UnlockMutex (GraphicsLock);
Battle (NULL);
LockMutex (GraphicsLock);
DestroySound (ReleaseSound (GameSounds));
GameSounds = 0;
@@ -864,6 +839,5 @@ EncounterBattle (void)
GLOBAL (CurrentActivity) = OldActivity;
UnlockMutex (GraphicsLock);
}
-8
View File
@@ -36,8 +36,6 @@
#define FLASH_INTERNAL
#include "flash.h"
#include "setup.h"
// For GraphicsLock.
#include "libs/log.h"
#include "libs/memlib.h"
#include "libs/threadlib.h"
@@ -545,7 +543,6 @@ Flash_grabOriginal (FlashContext *context)
if (context->original != (FRAME) 0)
DestroyDrawable (ReleaseDrawable (context->original));
LockMutex (GraphicsLock);
oldGfxContext = SetContext (context->gfxContext);
context->original = CaptureDrawable (CopyContextRect (&context->rect));
SetContext (oldGfxContext);
@@ -553,7 +550,6 @@ Flash_grabOriginal (FlashContext *context)
// CopyContextRect() may have queued the command to read
// a rectangle from the screen; a FlushGraphics()
// is necessary to ensure that it can actually be used.
UnlockMutex (GraphicsLock);
}
static inline void
@@ -589,7 +585,6 @@ Flash_makeFrame (FlashContext *context, FRAME dest, int numer, int denom)
Flash_blendFraction (context, numer, denom, &blendedNumer, &blendedDenom);
LockMutex (GraphicsLock);
oldGfxContext = SetContext (workGfxContext);
SetContextFGFrame (dest);
@@ -650,7 +645,6 @@ Flash_makeFrame (FlashContext *context, FRAME dest, int numer, int denom)
}
SetContext (oldGfxContext);
UnlockMutex (GraphicsLock);
}
// Prepare an entry in the cache.
@@ -686,7 +680,6 @@ Flash_drawFrame (FlashContext *context, FRAME frame)
CONTEXT oldGfxContext;
STAMP stamp;
LockMutex (GraphicsLock);
oldGfxContext = SetContext (context->gfxContext);
stamp.origin = context->rect.corner;
@@ -694,7 +687,6 @@ Flash_drawFrame (FlashContext *context, FRAME frame)
DrawStamp(&stamp);
SetContext (oldGfxContext);
UnlockMutex (GraphicsLock);
}
static void
-2
View File
@@ -79,13 +79,11 @@ SplashScreen (void (* DoProcessing)(DWORD TimeOut))
DWORD TimeOut;
SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 120));
LockMutex (GraphicsLock);
SetContext (ScreenContext);
s.origin.x = s.origin.y = 0;
s.frame = CaptureDrawable (LoadGraphic (TITLE_ANIM));
DrawStamp (&s);
DestroyDrawable (ReleaseDrawable (s.frame));
UnlockMutex (GraphicsLock);
TimeOut = FadeScreen (FadeAllToColor, ONE_SECOND / 2);
+1 -42
View File
@@ -167,9 +167,7 @@ FeedbackSetting (BYTE which_setting)
break;
}
LockMutex (GraphicsLock);
DrawStatusMessage (buf);
UnlockMutex (GraphicsLock);
}
#define DDSHS_NORMAL 0
@@ -229,7 +227,6 @@ DrawNameString (bool nameCaptain, UNICODE *Str, COUNT CursorPos,
lf.align = ALIGN_CENTER;
}
LockMutex (GraphicsLock);
SetContext (StatusContext);
SetContextFont (Font);
lf.pStr = Str;
@@ -253,14 +250,11 @@ DrawNameString (bool nameCaptain, UNICODE *Str, COUNT CursorPos,
if ((text_r.extent.width + 2) >= r.extent.width)
{ // the text does not fit the input box size and so
// will not fit when displayed later
UnlockMutex (GraphicsLock);
// disallow the change
return (FALSE);
}
UnlockMutex (GraphicsLock);
PreUpdateFlashRect ();
LockMutex (GraphicsLock);
SetContextForeGroundColor (BackGround);
DrawFilledRectangle (&r);
@@ -299,10 +293,9 @@ DrawNameString (bool nameCaptain, UNICODE *Str, COUNT CursorPos,
SetContextForeGroundColor (ForeGround);
font_DrawText (&lf);
PostUpdateFlashRectLocked ();
PostUpdateFlashRect ();
}
UnlockMutex (GraphicsLock);
return (TRUE);
}
@@ -325,15 +318,11 @@ NameCaptainOrShip (bool nameCaptain)
TEXTENTRY_STATE tes;
UNICODE *Setting;
LockMutex (GraphicsLock);
SetFlashRect (nameCaptain ? &captainNameRect : &shipNameRect);
UnlockMutex (GraphicsLock);
DrawNameString (nameCaptain, buf, 0, DDSHS_EDIT);
LockMutex (GraphicsLock);
DrawStatusMessage (GAME_STRING (NAMING_STRING_BASE + 0));
UnlockMutex (GraphicsLock);
if (nameCaptain)
{
@@ -359,9 +348,7 @@ NameCaptainOrShip (bool nameCaptain)
else
utf8StringCopy (buf, sizeof (buf), Setting);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
DrawNameString (nameCaptain, buf, 0, DDSHS_NORMAL);
@@ -450,9 +437,7 @@ SettingsMenu (void)
MenuState.InputFunc = DoSettings;
DoInput (&MenuState, FALSE);
LockMutex (GraphicsLock);
DrawStatusMessage (NULL);
UnlockMutex (GraphicsLock);
}
typedef struct
@@ -677,10 +662,8 @@ DrawSavegameSummary (PICK_GAME_STATE *pickState, COUNT gameIndex)
r.corner.y = SIS_ORG_Y + 84;
r.extent = OldRect.extent;
SetContextClipRect (&r);
UnlockMutex (GraphicsLock);
// draw the lander with upgrades
InitLander (pSD->Flags | OVERRIDE_LANDER_FLAGS);
LockMutex (GraphicsLock);
SetContextClipRect (&OldRect);
SetContext (SpaceContext);
@@ -941,11 +924,9 @@ DoPickGame (MENU_STATE *pMS)
if (NewState != pMS->CurState)
{
LockMutex (GraphicsLock);
pMS->CurState = NewState;
SetContext (SpaceContext);
RedrawPickDisplay (pickState, pMS->CurState);
UnlockMutex (GraphicsLock);
}
SleepThreadUntil (TimeIn + ONE_SECOND / 30);
@@ -965,9 +946,7 @@ SaveLoadGame (PICK_GAME_STATE *pickState, COUNT gameIndex)
// TODO: fix ConfirmSaveLoad() interface so it does not rely on
// MsgStamp != NULL parameter.
LockMutex (GraphicsLock);
ConfirmSaveLoad (pickState->saving ? &saveStamp : NULL);
UnlockMutex (GraphicsLock);
if (pickState->saving)
success = SaveGame (gameIndex, desc);
@@ -978,9 +957,7 @@ SaveLoadGame (PICK_GAME_STATE *pickState, COUNT gameIndex)
// display a load problem message
if (pickState->saving)
{ // restore the screen under "SAVING..." message
LockMutex (GraphicsLock);
DrawStamp (&saveStamp);
UnlockMutex (GraphicsLock);
}
DestroyDrawable (ReleaseDrawable (saveStamp.frame));
@@ -1015,12 +992,10 @@ PickGame (BOOLEAN saving, BOOLEAN fromMainMenu)
LoadGameDescriptions (pickState.summary);
LockMutex (GraphicsLock);
OldContext = SetContext (SpaceContext);
// Save the current state of the screen for later restoration
DlgStamp = SaveContextFrame (NULL);
GetContextClipRect (&DlgRect);
UnlockMutex (GraphicsLock);
SleepThreadUntil (TimeOut);
PauseMusic ();
@@ -1028,7 +1003,6 @@ PickGame (BOOLEAN saving, BOOLEAN fromMainMenu)
FadeMusic (NORMAL_VOLUME, 0);
// draw the current savegame and fade in
LockMutex (GraphicsLock);
SetTransitionSource (NULL);
BatchGraphics ();
@@ -1050,7 +1024,6 @@ PickGame (BOOLEAN saving, BOOLEAN fromMainMenu)
ScreenTransition (3, &ctxRect);
UnbatchGraphics ();
}
UnlockMutex (GraphicsLock);
SetMenuSounds (MENU_SOUND_ARROWS | MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN,
0);
@@ -1076,9 +1049,7 @@ PickGame (BOOLEAN saving, BOOLEAN fromMainMenu)
// reload and redraw everything
LoadGameDescriptions (pickState.summary);
LockMutex (GraphicsLock);
RedrawPickDisplay (&pickState, MenuState.CurState);
UnlockMutex (GraphicsLock);
}
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
@@ -1091,20 +1062,16 @@ PickGame (BOOLEAN saving, BOOLEAN fromMainMenu)
if (!(GLOBAL (CurrentActivity) & CHECK_ABORT) &&
(saving || (!pickState.success && !fromMainMenu)))
{ // Restore previous screen
LockMutex (GraphicsLock);
SetTransitionSource (&DlgRect);
BatchGraphics ();
DrawStamp (&DlgStamp);
ScreenTransition (3, &DlgRect);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
}
DestroyDrawable (ReleaseDrawable (DlgStamp.frame));
LockMutex (GraphicsLock);
SetContext (OldContext);
UnlockMutex (GraphicsLock);
ResumeMusic ();
@@ -1132,14 +1099,10 @@ DoGameOptions (MENU_STATE *pMS)
{
case SAVE_GAME:
case LOAD_GAME:
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
if (PickGame (pMS->CurState == SAVE_GAME, FALSE))
return FALSE;
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
break;
case QUIT_GAME:
if (ConfirmExit ())
@@ -1181,17 +1144,13 @@ GameOptions (void)
MenuState.CurState = SAVE_GAME;
DrawMenuStateStrings (PM_SAVE_GAME, MenuState.CurState);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
MenuState.InputFunc = DoGameOptions;
DoInput (&MenuState, TRUE);
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
return !(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD));
}
-10
View File
@@ -1633,9 +1633,7 @@ DoHyperspaceMenu (MENU_STATE *pMS)
if (!select)
return TRUE;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
switch (pMS->CurState)
{
@@ -1675,9 +1673,7 @@ DoHyperspaceMenu (MENU_STATE *pMS)
pMS->CurState = NAVIGATION;
DrawMenuStateStrings (PM_STARMAP, pMS->CurState);
}
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
}
return TRUE;
@@ -1695,7 +1691,6 @@ UnbatchGraphics ();
OldContext = SetContext (SpaceContext);
OldColor = SetContextBackGroundColor (BLACK_COLOR);
UnlockMutex (GraphicsLock);
memset (&MenuState, 0, sizeof (MenuState));
MenuState.InputFunc = DoHyperspaceMenu;
@@ -1703,14 +1698,11 @@ UnbatchGraphics ();
MenuState.CurState = STARMAP;
DrawMenuStateStrings (PM_STARMAP, STARMAP);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
DoInput (&MenuState, TRUE);
LockMutex (GraphicsLock);
SetFlashRect (NULL);
SetContext (SpaceContext);
@@ -1718,9 +1710,7 @@ UnbatchGraphics ();
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
ClearSISRect (CLEAR_SIS_RADAR);
UnlockMutex (GraphicsLock);
WaitForNoInput (ONE_SECOND / 2, FALSE);
LockMutex (GraphicsLock);
}
SetContextBackGroundColor (OldColor);
-38
View File
@@ -160,7 +160,6 @@ Present_BatchGraphics (PRESENTATION_INPUT_STATE* pPIS)
if (!pPIS->Batched)
{
pPIS->Batched = TRUE;
LockMutex (GraphicsLock);
BatchGraphics ();
}
}
@@ -171,7 +170,6 @@ Present_UnbatchGraphics (PRESENTATION_INPUT_STATE* pPIS, BOOLEAN bYield)
if (pPIS->Batched)
{
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
pPIS->Batched = FALSE;
if (bYield)
TaskSwitch ();
@@ -196,7 +194,6 @@ Present_GenerateSIS (PRESENTATION_INPUT_STATE* pPIS)
COUNT piece;
Color SisBack;
LockMutex (GraphicsLock);
OldContext = SetContext (OffScreenContext);
SkelFrame = CaptureDrawable (LoadGraphic (SISSKEL_MASK_PMAP_ANIM));
@@ -264,7 +261,6 @@ Present_GenerateSIS (PRESENTATION_INPUT_STATE* pPIS)
SetContext (OldContext);
FlushGraphics ();
UnlockMutex (GraphicsLock);
pPIS->SisFrame = SisFrame;
}
@@ -277,9 +273,7 @@ Present_DrawMovieFrame (PRESENTATION_INPUT_STATE* pPIS)
s.origin.x = 0;
s.origin.y = 0;
s.frame = SetAbsFrameIndex (pPIS->Frame, pPIS->MovieFrame);
LockMutex (GraphicsLock);
DrawStamp (&s);
UnlockMutex (GraphicsLock);
}
static BOOLEAN
@@ -362,9 +356,7 @@ DoPresentation (void *pIS)
/* center on screen */
pPIS->clip_r.corner.x = (SCREEN_WIDTH - w) / 2;
pPIS->clip_r.corner.y = (SCREEN_HEIGHT - h) / 2;
LockMutex (GraphicsLock);
SetContextClipRect (&pPIS->clip_r);
UnlockMutex (GraphicsLock);
}
}
else if (strcmp (Opcode, "FONT") == 0)
@@ -390,11 +382,7 @@ DoPresentation (void *pIS)
*pFont = LoadFontFile (pPIS->Buffer);
}
if (!pPIS->Batched)
LockMutex (GraphicsLock);
SetContextFont (*pFont);
if (!pPIS->Batched)
UnlockMutex (GraphicsLock);
}
else if (strcmp (Opcode, "ANI") == 0)
{ /* set ani */
@@ -490,12 +478,8 @@ DoPresentation (void *pIS)
t.CharCount = (COUNT)~0;
t.baseline.x = x;
t.baseline.y = y;
if (!pPIS->Batched)
LockMutex (GraphicsLock);
DrawTextEffect (&t, pPIS->TextColor, pPIS->TextBackColor,
pPIS->TextEffect);
if (!pPIS->Batched)
UnlockMutex (GraphicsLock);
}
}
else if (strcmp (Opcode, "TFI") == 0)
@@ -510,9 +494,7 @@ DoPresentation (void *pIS)
Present_UnbatchGraphics (pPIS, TRUE);
LockMutex (GraphicsLock);
GetContextFontLeading (&leading);
UnlockMutex (GraphicsLock);
switch (pPIS->TextVPos)
{
@@ -536,7 +518,6 @@ DoPresentation (void *pIS)
pPIS->TextLines[i].baseline.y = y;
}
LockMutex (GraphicsLock);
for (i = 0; i < pPIS->LinesCount; ++i)
DrawTextEffect (pPIS->TextLines + i, pPIS->TextFadeColor,
pPIS->TextFadeColor, pPIS->TextEffect);
@@ -550,7 +531,6 @@ DoPresentation (void *pIS)
ScreenTransition (3, &pPIS->tfade_r);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
}
else if (strcmp (Opcode, "TFO") == 0)
{ /* text fade-out */
@@ -558,7 +538,6 @@ DoPresentation (void *pIS)
Present_UnbatchGraphics (pPIS, TRUE);
LockMutex (GraphicsLock);
/* do transition */
SetTransitionSource (&pPIS->tfade_r);
BatchGraphics ();
@@ -567,7 +546,6 @@ DoPresentation (void *pIS)
pPIS->TextFadeColor, pPIS->TextEffect);
ScreenTransition (3, &pPIS->tfade_r);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
}
else if (strcmp (Opcode, "SAVEBG") == 0)
{ /* save background */
@@ -652,15 +630,11 @@ DoPresentation (void *pIS)
}
s.origin.x = x;
s.origin.y = y;
if (!pPIS->Batched)
LockMutex (GraphicsLock);
old_mode = SetGraphicScaleMode (scale_mode);
old_scale = SetGraphicScale (scale);
DrawStamp (&s);
SetGraphicScale (old_scale);
SetGraphicScaleMode (old_mode);
if (!pPIS->Batched)
UnlockMutex (GraphicsLock);
}
else if (strcmp (Opcode, "BATCH") == 0)
{ /* batch graphics */
@@ -689,9 +663,7 @@ DoPresentation (void *pIS)
{ /* clear screen */
Present_UnbatchGraphics (pPIS, TRUE);
LockMutex (GraphicsLock);
ClearDrawable ();
UnlockMutex (GraphicsLock);
}
else if (strcmp (Opcode, "CALL") == 0)
{ /* call another script */
@@ -712,12 +684,8 @@ DoPresentation (void *pIS)
l.second.x = x2;
l.second.y = y2;
if (!pPIS->Batched)
LockMutex (GraphicsLock);
SetContextForeGroundColor (pPIS->TextColor);
DrawLine (&l);
if (!pPIS->Batched)
UnlockMutex (GraphicsLock);
}
else
{
@@ -771,12 +739,10 @@ ShowSlidePresentation (STRING PresStr)
pis.SlideShow = SetAbsStringTableIndex (pis.SlideShow, 0);
pis.OperIndex = 0;
LockMutex (GraphicsLock);
OldContext = SetContext (ScreenContext);
GetContextClipRect (&OldRect);
OldFont = SetContextFont (NULL);
SetContextBackGroundColor (BLACK_COLOR);
UnlockMutex (GraphicsLock);
SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE);
pis.InputFunc = DoPresentation;
@@ -797,11 +763,9 @@ ShowSlidePresentation (STRING PresStr)
for (i = 0; i < MAX_FONTS; ++i)
DestroyFont (pis.Fonts[i]);
LockMutex (GraphicsLock);
SetContextFont (OldFont);
SetContextClipRect (&OldRect);
SetContext (OldContext);
UnlockMutex (GraphicsLock);
return TRUE;
}
@@ -853,11 +817,9 @@ FadeClearScreen (void)
SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2));
// clear the screen with black
LockMutex (GraphicsLock);
SetContext (ScreenContext);
SetContextBackGroundColor (BLACK_COLOR);
ClearDrawable ();
UnlockMutex (GraphicsLock);
FadeScreen (FadeAllToColor, 0);
}
-2
View File
@@ -498,7 +498,6 @@ DrawMenuStateStrings (BYTE beg_index, SWORD NewState)
s.frame = SetAbsFrameIndex (PlayFrame, beg_index + NewState);
PreUpdateFlashRect ();
LockMutex (GraphicsLock);
OldContext = SetContext (StatusContext);
GetContextClipRect (&r);
s.origin.x = RADAR_X - r.corner.x;
@@ -599,7 +598,6 @@ DrawMenuStateStrings (BYTE beg_index, SWORD NewState)
}
UnbatchGraphics ();
SetContext (OldContext);
UnlockMutex (GraphicsLock);
PostUpdateFlashRect ();
}
-25
View File
@@ -234,7 +234,6 @@ DoInstallModule (MENU_STATE *pMS)
pMS->InputFunc = DoInstallModule;
LockMutex (GraphicsLock);
SetContext (SpaceContext);
ClearSISRect (CLEAR_SIS_RADAR);
@@ -296,7 +295,6 @@ DoInstallModule (MENU_STATE *pMS)
}
}
LockMutex (GraphicsLock);
SetContext (SpaceContext);
SetFlashRect (NULL);
@@ -382,15 +380,12 @@ DoInstallModule (MENU_STATE *pMS)
else
{
SetContext (StatusContext);
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_FUEL, pMS->CurState = OUTFIT_MODULES);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
pMS->InputFunc = DoOutfit;
ClearSISRect (DRAW_SIS_DISPLAY);
}
UnlockMutex (GraphicsLock);
}
else if (motion)
{
@@ -440,7 +435,6 @@ DoInstallModule (MENU_STATE *pMS)
|| (NewItem >= GUN_WEAPON && NewItem <= CANNON_WEAPON
&& pMS->delta_item > 0 && pMS->delta_item < 13)));
LockMutex (GraphicsLock);
if (NewState < EMPTY_SLOT)
{
if (NewItem != pMS->CurState)
@@ -540,7 +534,6 @@ InitFlash:
else
SetFlashRect (&pMS->flash_rect0);
}
UnlockMutex (GraphicsLock);
}
return (TRUE);
@@ -578,7 +571,6 @@ ChangeFuelQuantity (void)
incr = minFit; // All we have.
}
LockMutex (GraphicsLock);
if (!incr)
{
// No more room, not enough RUs, or no fuel left to drain.
@@ -600,16 +592,13 @@ ChangeFuelQuantity (void)
SetFlashRect (&r);
SetContext (oldContext);
}
UnlockMutex (GraphicsLock);
}
static void
onNamingDone (void)
{
// In case player just named a ship, redraw it
LockMutex (GraphicsLock);
DrawFlagshipName (FALSE);
UnlockMutex (GraphicsLock);
}
BOOLEAN
@@ -639,7 +628,6 @@ DoOutfit (MENU_STATE *pMS)
s.frame = CaptureDrawable (
LoadGraphic (OUTFIT_PMAP_ANIM));
LockMutex (GraphicsLock);
SetTransitionSource (NULL);
BatchGraphics ();
DrawSISFrame ();
@@ -701,21 +689,16 @@ DoOutfit (MENU_STATE *pMS)
DrawStamp (&s);
}
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_FUEL, pMS->CurState);
LockMutex (GraphicsLock);
DrawFlagshipName (FALSE);
if (optWhichFonts == OPT_PC)
DrawFlagshipStats ();
UnlockMutex (GraphicsLock);
ScreenTransition (3, NULL);
PlayMusic (pMS->hMusic, TRUE, 1);
UnbatchGraphics ();
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
GLOBAL_SIS (FuelOnBoard) =
(GLOBAL_SIS (FuelOnBoard)
@@ -732,9 +715,7 @@ DoOutfit (MENU_STATE *pMS)
if (pMS->CurState == OUTFIT_DOFUEL)
{
pMS->CurState = OUTFIT_FUEL;
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
}
else
{
@@ -758,18 +739,14 @@ ExitOutfit:
RECT r;
pMS->CurState = OUTFIT_DOFUEL;
LockMutex (GraphicsLock);
SetContext (StatusContext);
GetGaugeRect (&r, FALSE);
SetFlashRect (&r);
UnlockMutex (GraphicsLock);
break;
}
case OUTFIT_DOFUEL:
pMS->CurState = OUTFIT_FUEL;
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
break;
case OUTFIT_MODULES:
pMS->CurState = EMPTY_SLOT + 2;
@@ -786,9 +763,7 @@ ExitOutfit:
if (!GameOptions ())
goto ExitOutfit;
DrawMenuStateStrings (PM_FUEL, pMS->CurState);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
break;
}
}
-5
View File
@@ -61,7 +61,6 @@ DoPickBattleShip (MENU_STATE *pMS)
pMS->Initialized = TRUE;
pMS->InputFunc = DoPickBattleShip;
LockMutex (GraphicsLock);
goto ChangeSelection;
}
@@ -106,7 +105,6 @@ DoPickBattleShip (MENU_STATE *pMS)
PlayMenuSound (MENU_SOUND_MOVE);
LockMutex (GraphicsLock);
#ifdef NEVER
SetContextForeGroundColor (
@@ -240,7 +238,6 @@ ChangeSelection:
SetFlashRect (NULL);
SetFlashRect (&pMS->flash_rect0);
UnlockMutex (GraphicsLock);
}
}
@@ -278,10 +275,8 @@ OldContext = SetContext (SpaceContext);
MenuState.flash_rect1.corner = pick_r.corner;
MenuState.flash_rect1.extent.width = 0;
UnlockMutex (GraphicsLock);
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
DoInput (&MenuState, FALSE);
LockMutex (GraphicsLock);
SetFlashRect (NULL);
-9
View File
@@ -239,8 +239,6 @@ DrawCargoStrings (BYTE OldElement, BYTE NewElement)
{
CONTEXT OldContext;
LockMutex (GraphicsLock);
OldContext = SetContext (StatusContext);
SetContextFont (TinyFont);
@@ -266,15 +264,12 @@ DrawCargoStrings (BYTE OldElement, BYTE NewElement)
UnbatchGraphics ();
SetContext (OldContext);
UnlockMutex (GraphicsLock);
}
static void
DrawElementDescription (COUNT element)
{
LockMutex (GraphicsLock);
DrawStatusMessage (GAME_STRING (element + (CARGO_STRING_BASE + 2)));
UnlockMutex (GraphicsLock);
}
static BOOLEAN
@@ -302,10 +297,8 @@ DoDiscardCargo (MENU_STATE *pMS)
--GLOBAL_SIS (ElementAmounts[pMS->CurState]);
DrawCargoStrings (pMS->CurState, pMS->CurState);
LockMutex (GraphicsLock);
--GLOBAL_SIS (TotalElementMass);
ShowRemainingCapacity ();
UnlockMutex (GraphicsLock);
}
else
{ // no element left in cargo hold
@@ -358,8 +351,6 @@ CargoMenu (void)
DoInput (&MenuState, TRUE);
// erase the cargo display
LockMutex (GraphicsLock);
ClearSISRect (DRAW_SIS_DISPLAY);
UnlockMutex (GraphicsLock);
}
-6
View File
@@ -185,7 +185,6 @@ DrawDevicesDisplay (DEVICES_STATE *devState)
static void
DrawDevices (DEVICES_STATE *devState, COUNT OldDevice, COUNT NewDevice)
{
LockMutex (GraphicsLock);
BatchGraphics ();
SetContext (StatusContext);
@@ -211,7 +210,6 @@ DrawDevices (DEVICES_STATE *devState, COUNT OldDevice, COUNT NewDevice)
}
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
}
// Returns TRUE if the broadcaster has been successfully activated,
@@ -493,13 +491,11 @@ DoManipulateDevices (MENU_STATE *pMS)
{
DeviceStatus status;
LockMutex (GraphicsLock);
status = InvokeDevice (devState->list[pMS->CurState]);
if (status == DEVICE_FAILURE)
PlayMenuSound (MENU_SOUND_FAILURE);
else if (status == DEVICE_SUCCESS)
PlayMenuSound (MENU_SOUND_INVOKED);
UnlockMutex (GraphicsLock);
return (status == DEVICE_FAILURE);
}
@@ -682,9 +678,7 @@ DevicesMenu (void)
if (GLOBAL_SIS (CrewEnlisted) != (COUNT)~0
&& !(GLOBAL (CurrentActivity) & CHECK_ABORT))
{
LockMutex (GraphicsLock);
ClearSISRect (DRAW_SIS_DISPLAY);
UnlockMutex (GraphicsLock);
if (!GET_GAME_STATE (PORTAL_COUNTER)
&& !(GLOBAL (CurrentActivity) & START_ENCOUNTER)
-4
View File
@@ -133,8 +133,6 @@ GenerateChmmr_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
else if (matchWorld (solarSys, world, 1, 0))
{
/* Starbase */
LockMutex (GraphicsLock);
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
solarSys->SysInfo.PlanetInfo.DiscoveryString =
CaptureStringTable (LoadStringTable (CHMMR_BASE_STRTAB));
@@ -146,8 +144,6 @@ GenerateChmmr_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
solarSys->SysInfo.PlanetInfo.DiscoveryString = 0;
FreeLanderFont (&solarSys->SysInfo.PlanetInfo);
UnlockMutex (GraphicsLock);
return true;
}
-2
View File
@@ -142,9 +142,7 @@ GenerateMycon_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
return true;
SET_GAME_STATE (SUN_DEVICE_UNGUARDED, 1);
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
}
}
}
-2
View File
@@ -135,9 +135,7 @@ GenerateOrz_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
if (OrzSurvivors)
return true;
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
}
}
-4
View File
@@ -231,9 +231,7 @@ ZapToUrquanEncounter (void)
{
#define LOST_DAYS 15
SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND * 2));
LockMutex (GraphicsLock);
MoveGameClockDays (LOST_DAYS);
UnlockMutex (GraphicsLock);
}
GLOBAL (CurrentActivity) = MAKE_WORD (IN_HYPERSPACE, 0) | START_ENCOUNTER;
@@ -243,7 +241,6 @@ ZapToUrquanEncounter (void)
dx = (SIZE)square_root ((long)dx * dx + (long)dy * dy)
+ (FUEL_TANK_SCALE >> 1);
LockMutex (GraphicsLock);
DeltaSISGauges (0, -dx, 0);
if (GLOBAL_SIS (FuelOnBoard) < 5 * FUEL_TANK_SCALE)
{
@@ -253,7 +250,6 @@ ZapToUrquanEncounter (void)
}
DrawSISMessage (NULL);
DrawHyperCoords (EncounterPtr->loc_pt);
UnlockMutex (GraphicsLock);
UnlockEncounter (hEncounter);
}
-2
View File
@@ -132,9 +132,7 @@ GenerateThraddash_generateOrbital (SOLARSYS_STATE *solarSys,
&& (BYTE)(GET_GAME_STATE (THRADD_MISSION) - 1) >= 3))
return true;
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
}
if (CurStarDescPtr->Index == AQUA_HELIX_DEFINED
-2
View File
@@ -174,9 +174,7 @@ GenerateUtwig_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
if (DruugeSurvivors)
return true;
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
SET_GAME_STATE (BOMB_UNPROTECTED, 1);
}
}
-2
View File
@@ -158,9 +158,7 @@ GenerateVux_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|| !GET_GAME_STATE (ZEX_IS_DEAD))
return true;
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
}
}
-36
View File
@@ -1142,7 +1142,6 @@ ScrollPlanetSide (SIZE dx, SIZE dy, int landingOffset)
curLanderLoc = new_pt;
LockMutex (GraphicsLock);
OldContext = SetContext (PlanetContext);
BatchGraphics ();
@@ -1252,7 +1251,6 @@ ScrollPlanetSide (SIZE dx, SIZE dy, int landingOffset)
UnbatchGraphics ();
SetContext (OldContext);
UnlockMutex (GraphicsLock);
}
static void
@@ -1262,9 +1260,7 @@ animationInterframe (TimeCount *TimeIn, COUNT periods)
for ( ; periods; --periods)
{
LockMutex (GraphicsLock);
RotatePlanetSphere (TRUE);
UnlockMutex (GraphicsLock);
SleepThreadUntil (*TimeIn + ANIM_FRAME_RATE);
*TimeIn = GetTimeCounter ();
@@ -1279,7 +1275,6 @@ AnimateLaunch (FRAME farray)
COUNT num_frames;
TimeCount NextTime;
LockMutex (GraphicsLock);
SetContext (PlanetContext);
r.corner.x = 0;
@@ -1303,18 +1298,14 @@ AnimateLaunch (FRAME farray)
#endif
DrawStamp (&s);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
GetFrameRect (s.frame, &r);
s.frame = IncFrameIndex (s.frame);
SleepThreadUntil (NextTime);
LockMutex (GraphicsLock);
}
RepairBackRect (&r);
UnlockMutex (GraphicsLock);
}
static void
@@ -1325,18 +1316,14 @@ AnimateLanderWarmup (void)
CONTEXT OldContext;
TimeCount TimeIn = GetTimeCounter ();
LockMutex (GraphicsLock);
OldContext = SetContext (RadarContext);
UnlockMutex (GraphicsLock);
s.origin.x = 0;
s.origin.y = 0;
s.frame = SetAbsFrameIndex (LanderFrame[0],
(ANGLE_TO_FACING (FULL_CIRCLE) << 1) + 1);
LockMutex (GraphicsLock);
DrawStamp (&s);
UnlockMutex (GraphicsLock);
animationInterframe (&TimeIn, 2);
@@ -1345,10 +1332,8 @@ AnimateLanderWarmup (void)
{
animationInterframe (&TimeIn, 1);
LockMutex (GraphicsLock);
DeltaSISGauges (-1, 0, 0);
DeltaLanderCrew (1, 0);
UnlockMutex (GraphicsLock);
}
animationInterframe (&TimeIn, 2);
@@ -1358,9 +1343,7 @@ AnimateLanderWarmup (void)
else
s.frame = SetAbsFrameIndex (s.frame,
(ANGLE_TO_FACING (FULL_CIRCLE) << 1) + 2);
LockMutex (GraphicsLock);
DrawStamp (&s);
UnlockMutex (GraphicsLock);
animationInterframe (&TimeIn, 2);
@@ -1370,26 +1353,20 @@ AnimateLanderWarmup (void)
{
s.frame = SetAbsFrameIndex (s.frame,
(ANGLE_TO_FACING (FULL_CIRCLE) << 1) + 3);
LockMutex (GraphicsLock);
DrawStamp (&s);
UnlockMutex (GraphicsLock);
animationInterframe (&TimeIn, 2);
s.frame = IncFrameIndex (s.frame);
}
LockMutex (GraphicsLock);
DrawStamp (&s);
UnlockMutex (GraphicsLock);
if (GET_GAME_STATE (IMPROVED_LANDER_CARGO))
{
animationInterframe (&TimeIn, 2);
s.frame = SetAbsFrameIndex (s.frame, 59);
LockMutex (GraphicsLock);
DrawStamp (&s);
UnlockMutex (GraphicsLock);
}
animationInterframe (&TimeIn, 2);
@@ -1419,7 +1396,6 @@ InitPlanetSide (POINT pt)
curLanderLoc = pt;
LockMutex (GraphicsLock);
SetContext (PlanetContext);
SetContextFont (TinyFont);
@@ -1452,7 +1428,6 @@ InitPlanetSide (POINT pt)
UnbatchGraphics ();
}
UnlockMutex (GraphicsLock);
SET_GAME_STATE (PLANETARY_LANDING, 1);
}
@@ -1749,7 +1724,6 @@ ReturnToOrbit (void)
CONTEXT OldContext;
RECT r;
LockMutex (GraphicsLock);
OldContext = SetContext (PlanetContext);
GetContextClipRect (&r);
@@ -1762,7 +1736,6 @@ ReturnToOrbit (void)
UnbatchGraphics ();
SetContext (OldContext);
UnlockMutex (GraphicsLock);
}
static void
@@ -1972,9 +1945,7 @@ PlanetSide (POINT planetLoc)
if (crew_left == 0)
{
--GLOBAL_SIS (NumLanders);
LockMutex (GraphicsLock);
DrawLanders ();
UnlockMutex (GraphicsLock);
ReturnToOrbit ();
}
@@ -1988,7 +1959,6 @@ PlanetSide (POINT planetLoc)
ReturnToOrbit ();
AnimateLaunch (LanderFrame[6]);
LockMutex (GraphicsLock);
DeltaSISGauges (crew_left, 0, 0);
if (PSD.ElementLevel)
@@ -2002,7 +1972,6 @@ PlanetSide (POINT planetLoc)
}
DrawStorageBays (FALSE);
}
UnlockMutex (GraphicsLock);
GLOBAL_SIS (TotalBioMass) += PSD.BiologicalLevel;
}
@@ -2042,10 +2011,7 @@ InitLander (BYTE LanderFlags)
{
RECT r;
LockMutex (GraphicsLock);
SetContext (RadarContext);
BatchGraphics ();
r.corner.x = 0;
@@ -2132,6 +2098,4 @@ InitLander (BYTE LanderFlags)
}
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
}
-2
View File
@@ -192,7 +192,6 @@ ZoomInPlanetSphere (void)
pt.y = PLANET_ORG_Y + (int) (dy * (1.0 - scale)
* (SCAN_SCREEN_HEIGHT * 6 / 10) + 0.5);
LockMutex (GraphicsLock);
SetContext (PlanetContext);
BatchGraphics ();
@@ -206,7 +205,6 @@ ZoomInPlanetSphere (void)
SetGraphicScaleMode (oldMode);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
repairRect.corner.x = pt.x + frameRect.corner.x;
repairRect.corner.y = pt.y + frameRect.corner.y;
-25
View File
@@ -59,8 +59,6 @@ CreatePlanetContext (void)
assert (PlanetContext == NULL);
LockMutex (GraphicsLock);
// PlanetContext rect is relative to SpaceContext
oldContext = SetContext (SpaceContext);
GetContextClipRect (&r);
@@ -72,7 +70,6 @@ CreatePlanetContext (void)
SetContextClipRect (&r);
SetContext (oldContext);
UnlockMutex (GraphicsLock);
}
static void
@@ -263,9 +260,7 @@ LoadPlanet (FRAME SurfDefFrame)
if (WaitMode)
{
LockMutex (GraphicsLock);
DrawOrbitalDisplay (DRAW_ORBITAL_WAIT);
UnlockMutex (GraphicsLock);
}
StopMusic ();
@@ -281,15 +276,11 @@ LoadPlanet (FRAME SurfDefFrame)
if (WaitMode)
{
ZoomInPlanetSphere ();
LockMutex (GraphicsLock);
DrawOrbitalDisplay (DRAW_ORBITAL_UPDATE);
UnlockMutex (GraphicsLock);
}
else
{
LockMutex (GraphicsLock);
DrawOrbitalDisplay (DRAW_ORBITAL_FULL);
UnlockMutex (GraphicsLock);
}
}
@@ -302,7 +293,6 @@ FreePlanet (void)
UninitSphereRotation ();
StopMusic ();
LockMutex (GraphicsLock);
for (i = 0; i < sizeof (pSolarSysState->PlanetSideFrame)
/ sizeof (pSolarSysState->PlanetSideFrame[0]); ++i)
@@ -353,7 +343,6 @@ FreePlanet (void)
DestroyPlanetContext ();
DestroyScanContext ();
UnlockMutex (GraphicsLock);
}
void
@@ -391,9 +380,7 @@ DoPlanetOrbit (MENU_STATE *pMS)
if (!select)
return TRUE;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
switch (pMS->CurState)
{
@@ -431,9 +418,7 @@ DoPlanetOrbit (MENU_STATE *pMS)
// Deactivate planet rotation
oldCallback = SetInputCallback (NULL);
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
AutoPilotSet = StarMap ();
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
@@ -444,9 +429,7 @@ DoPlanetOrbit (MENU_STATE *pMS)
if (!AutoPilotSet)
{ // Redraw the orbital display
LockMutex (GraphicsLock);
DrawOrbitalDisplay (DRAW_ORBITAL_FULL);
UnlockMutex (GraphicsLock);
break;
}
// Fall through !!!
@@ -463,9 +446,7 @@ DoPlanetOrbit (MENU_STATE *pMS)
pMS->CurState = NAVIGATION;
DrawMenuStateStrings (PM_SCAN, pMS->CurState);
}
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
}
return TRUE;
@@ -474,9 +455,7 @@ DoPlanetOrbit (MENU_STATE *pMS)
static void
on_input_frame (void)
{
LockMutex (GraphicsLock);
RotatePlanetSphere (TRUE);
UnlockMutex (GraphicsLock);
}
void
@@ -488,9 +467,7 @@ PlanetOrbitMenu (void)
memset (&MenuState, 0, sizeof MenuState);
DrawMenuStateStrings (PM_SCAN, SCAN);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
MenuState.CurState = SCAN;
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
@@ -501,8 +478,6 @@ PlanetOrbitMenu (void)
SetInputCallback (oldCallback);
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_STARMAP, -NAVIGATION);
}
-2
View File
@@ -1735,7 +1735,6 @@ GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame)
RandomContext_SeedRandom (SysGenRNG, pPlanetDesc->rand_seed);
TopoContext = CreateContext ("Plangen.TopoContext");
LockMutex (GraphicsLock);
OldContext = SetContext (TopoContext);
planet_orbit_init ();
@@ -1950,7 +1949,6 @@ GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame)
}
SetContext (OldContext);
UnlockMutex (GraphicsLock);
DestroyContext (TopoContext);
}
-27
View File
@@ -123,7 +123,6 @@ flashCurrentLocation (POINT *where)
NextTime = GetTimeCounter () + (ONE_SECOND / 16);
LockMutex (GraphicsLock);
OldContext = SetContext (SpaceContext);
if (c == 0x00 || c == 0x1A)
@@ -138,7 +137,6 @@ flashCurrentLocation (POINT *where)
SetContextForeGroundColor (OldColor);
SetContext (OldContext);
UnlockMutex (GraphicsLock);
}
}
@@ -299,7 +297,6 @@ DrawStarMap (COUNT race_update, RECT *pClipRect)
}
else
{
LockMutex (GraphicsLock);
draw_cursor = TRUE;
}
@@ -559,9 +556,6 @@ DrawStarMap (COUNT race_update, RECT *pClipRect)
UNIVERSE_TO_DISPY (cursorLoc.y));
}
}
if (draw_cursor)
UnlockMutex (GraphicsLock);
}
static void
@@ -591,9 +585,7 @@ EraseCursor (COORD curs_x, COORD curs_y)
#else /* NEW */
r.extent.height += r.corner.y & 1;
r.corner.y &= ~1;
UnlockMutex (GraphicsLock);
DrawStarMap (0, &r);
LockMutex (GraphicsLock);
#endif /* OLD */
}
@@ -693,11 +685,9 @@ UpdateCursorLocation (int sx, int sy, const POINT *newpt)
}
else
{
LockMutex (GraphicsLock);
EraseCursor (pt.x, pt.y);
// ClearDrawable ();
DrawCursor (s.origin.x, s.origin.y);
UnlockMutex (GraphicsLock);
}
}
@@ -767,14 +757,12 @@ UpdateCursorInfo (UNICODE *prevbuf)
}
}
LockMutex (GraphicsLock);
DrawHyperCoords (cursorLoc);
if (strcmp (buf, prevbuf) != 0)
{
strcpy (prevbuf, buf);
DrawSISMessage (buf);
}
UnlockMutex (GraphicsLock);
}
static void
@@ -806,9 +794,7 @@ UpdateFuelRequirement (void)
fuel_required / FUEL_TANK_SCALE,
(fuel_required % FUEL_TANK_SCALE) / 10);
LockMutex (GraphicsLock);
DrawStatusMessage (buf);
UnlockMutex (GraphicsLock);
}
#define STAR_SEARCH_BUFSIZE 256
@@ -1059,10 +1045,8 @@ DrawMatchedStarName (TEXTENTRY_STATE *pTES)
flags |= DSME_BLOCKCUR;
}
LockMutex (GraphicsLock);
DrawSISMessageEx (buf, CurPos, ExPos, flags);
DrawHyperCoords (cursorLoc);
UnlockMutex (GraphicsLock);
}
static void
@@ -1133,9 +1117,7 @@ OnStarNameChange (TEXTENTRY_STATE *pTES)
if (pTES->JoystickMode)
flags |= DSME_BLOCKCUR;
LockMutex (GraphicsLock);
ret = DrawSISMessageEx (pSS->Text, pTES->CursorPos, -1, flags);
UnlockMutex (GraphicsLock);
}
else
{
@@ -1196,9 +1178,7 @@ DoStarSearch (MENU_STATE *pMS)
if (!pss)
return FALSE;
LockMutex (GraphicsLock);
DrawSISMessageEx ("", 0, 0, DSME_SETFR);
UnlockMutex (GraphicsLock);
pss->pMS = pMS;
pss->LastChangeTime = 0;
@@ -1220,9 +1200,7 @@ DoStarSearch (MENU_STATE *pMS)
SetDefaultMenuRepeatDelay ();
success = DoTextEntry (&tes);
LockMutex (GraphicsLock);
DrawSISMessageEx (pss->Text, -1, -1, DSME_CLEARFR);
UnlockMutex (GraphicsLock);
HFree (pss);
@@ -1620,8 +1598,6 @@ StarMap (void)
if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1)
UpdateMap ();
LockMutex (GraphicsLock);
DrawStarMap (0, (RECT*)-1);
transition_pending = FALSE;
@@ -1633,7 +1609,6 @@ StarMap (void)
DrawCursor (UNIVERSE_TO_DISPX (cursorLoc.x),
UNIVERSE_TO_DISPY (cursorLoc.y));
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE);
SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY, STEP_ACCEL_DELAY,
@@ -1642,11 +1617,9 @@ StarMap (void)
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
SetDefaultMenuRepeatDelay ();
LockMutex (GraphicsLock);
DrawHyperCoords (universe);
DrawSISMessage (NULL);
DrawStatusMessage (NULL);
UnlockMutex (GraphicsLock);
if (GLOBAL (autopilot.x) == universe.x
&& GLOBAL (autopilot.y) == universe.y)
-11
View File
@@ -102,7 +102,6 @@ MakeReport (SOUND ReadOutSounds, UNICODE *pStr, COUNT StrLen)
t.pStr = pStr;
Sleepy = TRUE;
UnlockMutex (GraphicsLock);
FlushInput ();
// XXX: this is a pretty ugly goto
@@ -163,9 +162,7 @@ MakeReport (SOUND ReadOutSounds, UNICODE *pStr, COUNT StrLen)
font_DrawText (&t);
else
{
LockMutex (GraphicsLock);
font_DrawText (&t);
UnlockMutex (GraphicsLock);
PlaySound (ReadOutSounds, NotPositional (), NULL,
GAME_SOUND_PRIORITY);
@@ -183,7 +180,6 @@ MakeReport (SOUND ReadOutSounds, UNICODE *pStr, COUNT StrLen)
{
Sleepy = FALSE;
// We draw the whole thing at once after this
LockMutex (GraphicsLock);
BatchGraphics ();
}
}
@@ -204,7 +200,6 @@ MakeReport (SOUND ReadOutSounds, UNICODE *pStr, COUNT StrLen)
if (!Sleepy)
{
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
}
if (!WaitForAnyButton (TRUE, WAIT_INFINITE, FALSE))
@@ -216,18 +211,14 @@ InitPageCell:
row_cells = 0;
if (StrLen)
{
LockMutex (GraphicsLock);
if (!Sleepy)
BatchGraphics ();
ClearReportArea();
SetContextForeGroundColor (
BUILD_COLOR (MAKE_RGB15 (0x00, 0x1F, 0x00), 0xFF));
if (Sleepy)
UnlockMutex (GraphicsLock);
}
}
}
LockMutex (GraphicsLock);
}
void
@@ -274,9 +265,7 @@ DoDiscoveryReport (SOUND ReadOutSounds)
DestroyDrawable (ReleaseDrawable (saveStamp.frame));
UnlockMutex (GraphicsLock);
WaitForNoInput (WAIT_INFINITE, TRUE);
LockMutex (GraphicsLock);
}
-10
View File
@@ -254,7 +254,6 @@ DoModifyRoster (MENU_STATE *pMS)
}
else if (select || cancel)
{
LockMutex (GraphicsLock);
rosterState->modifyingCrew ^= true;
if (!rosterState->modifyingCrew)
{
@@ -268,7 +267,6 @@ DoModifyRoster (MENU_STATE *pMS)
SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN,
MENU_SOUND_SELECT | MENU_SOUND_CANCEL);
}
UnlockMutex (GraphicsLock);
}
else if (rosterState->modifyingCrew)
{
@@ -292,9 +290,7 @@ DoModifyRoster (MENU_STATE *pMS)
if (delta != 0)
{
LockMutex (GraphicsLock);
failed = !DeltaSupportCrew (rosterState, delta);
UnlockMutex (GraphicsLock);
}
if (failed)
@@ -350,7 +346,6 @@ DoModifyRoster (MENU_STATE *pMS)
--NewState;
}
LockMutex (GraphicsLock);
BatchGraphics ();
SetContext (StatusContext);
@@ -366,7 +361,6 @@ DoModifyRoster (MENU_STATE *pMS)
flashSupportShip (rosterState);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
}
SleepThread (ONE_SECOND / 30);
@@ -416,22 +410,18 @@ RosterMenu (void)
qsort (RosterState.shipPos, RosterState.count,
sizeof (RosterState.shipPos[0]), compShipPos);
LockMutex (GraphicsLock);
SetContext (StatusContext);
selectSupportShip (&RosterState, MenuState.CurState);
UnlockMutex (GraphicsLock);
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
MenuState.InputFunc = DoModifyRoster;
DoInput (&MenuState, TRUE);
LockMutex (GraphicsLock);
SetContext (StatusContext);
// unselect the last ship
drawSupportShip (&RosterState, FALSE);
DrawStatusMessage (NULL);
UnlockMutex (GraphicsLock);
return TRUE;
}
-82
View File
@@ -85,15 +85,12 @@ RepairBackRect (RECT *pRect)
static void
EraseCoarseScan (void)
{
LockMutex (GraphicsLock);
SetContext (PlanetContext);
BatchGraphics ();
DrawStarBackGround ();
DrawDefaultPlanetSphere ();
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
}
static void
@@ -160,7 +157,6 @@ PrintCoarseScanPC (void)
GetPlanetTitle (buf, sizeof (buf));
LockMutex (GraphicsLock);
SetContext (PlanetContext);
t.align = ALIGN_CENTER;
@@ -174,7 +170,6 @@ PrintCoarseScanPC (void)
font_DrawText (&t);
SetContextFont (TinyFont);
UnlockMutex (GraphicsLock);
#define LEFT_SIDE_BASELINE_X_PC 5
#define RIGHT_SIDE_BASELINE_X_PC (SIS_SCREEN_WIDTH - 75)
@@ -183,7 +178,6 @@ PrintCoarseScanPC (void)
t.baseline.y = SCAN_BASELINE_Y_PC;
t.align = ALIGN_LEFT;
LockMutex (GraphicsLock);
PrintScanTitlePC (&t, &r, GAME_STRING (ORBITSCAN_STRING_BASE),
LEFT_SIDE_BASELINE_X_PC); // "Orbit: "
val = ((pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist * 100L
@@ -194,9 +188,7 @@ PrintCoarseScanPC (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING_PC;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
PrintScanTitlePC (&t, &r, GAME_STRING (ORBITSCAN_STRING_BASE + 2),
LEFT_SIDE_BASELINE_X_PC); // "Atmo: "
if (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == GAS_GIANT_ATMOSPHERE)
@@ -216,9 +208,7 @@ PrintCoarseScanPC (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING_PC;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
PrintScanTitlePC (&t, &r, GAME_STRING (ORBITSCAN_STRING_BASE + 6),
LEFT_SIDE_BASELINE_X_PC); // "Temp: "
sprintf (buf, "%d" STR_DEGREE_SIGN " c",
@@ -227,9 +217,7 @@ PrintCoarseScanPC (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING_PC;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
PrintScanTitlePC (&t, &r, GAME_STRING (ORBITSCAN_STRING_BASE + 7),
LEFT_SIDE_BASELINE_X_PC); // "Weather: "
if (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == 0)
@@ -244,9 +232,7 @@ PrintCoarseScanPC (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING_PC;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
PrintScanTitlePC (&t, &r, GAME_STRING (ORBITSCAN_STRING_BASE + 10),
LEFT_SIDE_BASELINE_X_PC); // "Tectonics: "
if (PLANSIZE (pSolarSysState->SysInfo.PlanetInfo.PlanDataPtr->Type) ==
@@ -261,11 +247,9 @@ PrintCoarseScanPC (void)
}
t.CharCount = (COUNT)~0;
font_DrawText (&t);
UnlockMutex (GraphicsLock);
t.baseline.y = SCAN_BASELINE_Y_PC;
LockMutex (GraphicsLock);
PrintScanTitlePC (&t, &r, GAME_STRING (ORBITSCAN_STRING_BASE + 11),
RIGHT_SIDE_BASELINE_X_PC); // "Mass: "
val = pSolarSysState->SysInfo.PlanetInfo.PlanetRadius;
@@ -280,9 +264,7 @@ PrintCoarseScanPC (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING_PC;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
PrintScanTitlePC (&t, &r, GAME_STRING (ORBITSCAN_STRING_BASE + 13),
RIGHT_SIDE_BASELINE_X_PC); // "Radius: "
val = pSolarSysState->SysInfo.PlanetInfo.PlanetRadius;
@@ -292,9 +274,7 @@ PrintCoarseScanPC (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING_PC;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
PrintScanTitlePC (&t, &r, GAME_STRING (ORBITSCAN_STRING_BASE + 14),
RIGHT_SIDE_BASELINE_X_PC); // "Gravity: "
val = pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity;
@@ -306,9 +286,7 @@ PrintCoarseScanPC (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING_PC;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
PrintScanTitlePC (&t, &r, GAME_STRING (ORBITSCAN_STRING_BASE + 16),
RIGHT_SIDE_BASELINE_X_PC); // "Day: "
val = (SDWORD)pSolarSysState->SysInfo.PlanetInfo.RotationPeriod
@@ -319,9 +297,7 @@ PrintCoarseScanPC (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING_PC;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
PrintScanTitlePC (&t, &r, GAME_STRING (ORBITSCAN_STRING_BASE + 18),
RIGHT_SIDE_BASELINE_X_PC); // "Tilt: "
val = pSolarSysState->SysInfo.PlanetInfo.AxialTilt;
@@ -331,7 +307,6 @@ PrintCoarseScanPC (void)
sprintf (buf, "%d" STR_DEGREE_SIGN, val);
t.CharCount = (COUNT)~0;
font_DrawText (&t);
UnlockMutex (GraphicsLock);
}
static void
@@ -345,7 +320,6 @@ PrintCoarseScan3DO (void)
GetPlanetTitle (buf, sizeof (buf));
LockMutex (GraphicsLock);
SetContext (PlanetContext);
t.align = ALIGN_CENTER;
@@ -363,8 +337,6 @@ PrintCoarseScan3DO (void)
s.frame = SetAbsFrameIndex (SpaceJunkFrame, 20);
DrawStamp (&s);
UnlockMutex (GraphicsLock);
#define LEFT_SIDE_BASELINE_X (27 + (16 - SAFE_X))
#define RIGHT_SIDE_BASELINE_X (SIS_SCREEN_WIDTH - LEFT_SIDE_BASELINE_X)
#define SCAN_BASELINE_Y 25
@@ -373,7 +345,6 @@ PrintCoarseScan3DO (void)
t.baseline.y = SCAN_BASELINE_Y;
t.align = ALIGN_LEFT;
LockMutex (GraphicsLock);
t.pStr = buf;
val = ((pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist * 100L
+ (EARTH_RADIUS >> 1)) / EARTH_RADIUS);
@@ -381,9 +352,7 @@ PrintCoarseScan3DO (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
t.pStr = buf;
if (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == GAS_GIANT_ATMOSPHERE)
strcpy (buf, STR_INFINITY_SIGN);
@@ -396,27 +365,21 @@ PrintCoarseScan3DO (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
t.pStr = buf;
sprintf (buf, "%d" STR_DEGREE_SIGN,
pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature);
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
t.pStr = buf;
sprintf (buf, "<%u>", pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == 0
? 0 : (pSolarSysState->SysInfo.PlanetInfo.Weather + 1));
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
t.pStr = buf;
sprintf (buf, "<%u>",
PLANSIZE (
@@ -425,13 +388,11 @@ PrintCoarseScan3DO (void)
? 0 : (pSolarSysState->SysInfo.PlanetInfo.Tectonics + 1));
t.CharCount = (COUNT)~0;
font_DrawText (&t);
UnlockMutex (GraphicsLock);
t.baseline.x = RIGHT_SIDE_BASELINE_X;
t.baseline.y = SCAN_BASELINE_Y;
t.align = ALIGN_RIGHT;
LockMutex (GraphicsLock);
t.pStr = buf;
val = pSolarSysState->SysInfo.PlanetInfo.PlanetRadius;
val = ((DWORD) val * (DWORD) val * (DWORD) val / 100L
@@ -443,9 +404,7 @@ PrintCoarseScan3DO (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
t.pStr = buf;
val = pSolarSysState->SysInfo.PlanetInfo.PlanetRadius;
MakeScanValue (buf, val, STR_EARTH_SIGN);
@@ -453,9 +412,7 @@ PrintCoarseScan3DO (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
t.pStr = buf;
val = pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity;
if (val == 0)
@@ -464,9 +421,7 @@ PrintCoarseScan3DO (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
t.pStr = buf;
val = pSolarSysState->SysInfo.PlanetInfo.AxialTilt;
if (val < 0)
@@ -475,16 +430,13 @@ PrintCoarseScan3DO (void)
t.CharCount = (COUNT)~0;
font_DrawText (&t);
t.baseline.y += SCAN_LEADING;
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
t.pStr = buf;
val = (SDWORD)pSolarSysState->SysInfo.PlanetInfo.RotationPeriod
* 10 / 24;
MakeScanValue (buf, val, STR_EARTH_SIGN);
t.CharCount = (COUNT)~0;
font_DrawText (&t);
UnlockMutex (GraphicsLock);
}
static void
@@ -667,11 +619,9 @@ DispatchLander (void)
// Deactivate planet rotation callback
oldCallback = SetInputCallback (NULL);
LockMutex (GraphicsLock);
DeltaSISGauges (0, -landingFuel, 0);
SetContext (ScanContext);
drawPlanetCursor (FALSE);
UnlockMutex (GraphicsLock);
PlanetSide (planetLoc);
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
@@ -749,7 +699,6 @@ DoPickPlanetSide (MENU_STATE *pMS)
if (CurrentInputState.menu[KEY_MENU_DOWN])
dy = 1;
LockMutex (GraphicsLock);
BatchGraphics ();
dx = dx << MAG_SHIFT;
@@ -777,7 +726,6 @@ DoPickPlanetSide (MENU_STATE *pMS)
flashPlanetLocation ();
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
SleepThreadUntil (TimeIn + ONE_SECOND / 40);
}
@@ -799,9 +747,7 @@ drawLandingFuelUsage (COUNT fuel)
static void
eraseLandingFuelUsage (void)
{
LockMutex (GraphicsLock);
DrawStatusMessage (NULL);
UnlockMutex (GraphicsLock);
}
static BOOLEAN
@@ -815,7 +761,6 @@ PickPlanetSide (void)
memset (&MenuState, 0, sizeof MenuState);
MenuState.privData = &PickState;
LockMutex (GraphicsLock);
ClearSISRect (CLEAR_SIS_RADAR);
SetContext (ScanContext);
BatchGraphics ();
@@ -827,7 +772,6 @@ PickPlanetSide (void)
// Set the current flash location
setPlanetCursorLoc (planetLoc);
savePlanetLocationImage ();
UnlockMutex (GraphicsLock);
InitLander (0);
@@ -844,9 +788,7 @@ PickPlanetSide (void)
}
else
{ // player bailed out
LockMutex (GraphicsLock);
restorePlanetLocationImage ();
UnlockMutex (GraphicsLock);
}
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
@@ -1026,7 +968,6 @@ ScanPlanet (COUNT scanType)
t.pStr = GAME_STRING (SCAN_STRING_BASE + scan);
LockMutex (GraphicsLock);
SetContext (PlanetContext);
r.corner.x = 0;
r.corner.y = t.baseline.y - 10;
@@ -1041,14 +982,11 @@ ScanPlanet (COUNT scanType)
font_DrawText (&t);
SetContext (ScanContext);
UnlockMutex (GraphicsLock);
// Draw a virgin surface
LockMutex (GraphicsLock);
BatchGraphics ();
DrawPlanet (0, BLACK_COLOR);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
tintColor = tintColors[scan];
@@ -1060,7 +998,6 @@ ScanPlanet (COUNT scanType)
if (WaitForAnyButtonUntil (TRUE, TimeOut, FALSE))
break;
LockMutex (GraphicsLock);
BatchGraphics ();
DrawPlanet (i, tintColor);
DrawScannedStuff (i, scan);
@@ -1068,21 +1005,17 @@ ScanPlanet (COUNT scanType)
#ifdef SPIN_ON_SCAN
RotatePlanetSphere (TRUE);
#endif
UnlockMutex (GraphicsLock);
}
if (i < SCAN_LINES)
{ // Aborted by a keypress; draw in finished state
LockMutex (GraphicsLock);
BatchGraphics ();
DrawPlanet (SCAN_LINES - 1, tintColor);
DrawScannedStuff (SCAN_LINES - 1, scan);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
}
}
LockMutex (GraphicsLock);
SetContext (PlanetContext);
RepairBackRect (&r);
@@ -1093,7 +1026,6 @@ ScanPlanet (COUNT scanType)
DrawScannedObjects (FALSE);
}
UnlockMutex (GraphicsLock);
FlushInput ();
}
@@ -1135,17 +1067,13 @@ DoScan (MENU_STATE *pMS)
return TRUE;
}
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
if (!PickPlanetSide ())
return FALSE;
DrawMenuStateStrings (PM_MIN_SCAN, pMS->CurState);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
return TRUE;
}
@@ -1235,9 +1163,7 @@ ScanSystem (void)
memset (&MenuState, 0, sizeof MenuState);
LockMutex (GraphicsLock);
GetScanContext (NULL);
UnlockMutex (GraphicsLock);
if (optWhichMenu == OPT_3DO &&
((pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED)
@@ -1252,17 +1178,13 @@ ScanSystem (void)
planetLoc.x = (MAP_WIDTH >> 1) << MAG_SHIFT;
planetLoc.y = (MAP_HEIGHT >> 1) << MAG_SHIFT;
LockMutex (GraphicsLock);
initPlanetLocationImage ();
SetContext (ScanContext);
DrawScannedObjects (FALSE);
UnlockMutex (GraphicsLock);
}
DrawMenuStateStrings (PM_MIN_SCAN, MenuState.CurState);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
if (optWhichCoarseScan == OPT_PC)
PrintCoarseScanPC ();
@@ -1274,18 +1196,14 @@ ScanSystem (void)
MenuState.InputFunc = DoScan;
DoInput (&MenuState, FALSE);
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
// cleanup scan graphics
LockMutex (GraphicsLock);
BatchGraphics ();
SetContext (ScanContext);
DrawPlanet (0, BLACK_COLOR);
EraseCoarseScan ();
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
DestroyDrawable (ReleaseDrawable (eraseFrame));
eraseFrame = NULL;
-19
View File
@@ -1030,10 +1030,8 @@ DrawSystemTransition (BOOLEAN inner)
static void
TransitionSystemIn (void)
{
LockMutex (GraphicsLock);
SetContext (SpaceContext);
DrawSystemTransition (playerInInnerSystem ());
UnlockMutex (GraphicsLock);
}
static void
@@ -1117,7 +1115,6 @@ IP_frame (void)
BOOLEAN locChange;
SIZE newRadius;
LockMutex (GraphicsLock);
SetContext (SpaceContext);
GameClockTick ();
@@ -1148,7 +1145,6 @@ IP_frame (void)
UnbatchGraphics ();
}
UnlockMutex (GraphicsLock);
}
static BOOLEAN
@@ -1311,9 +1307,7 @@ EnterPlanetOrbit (void)
ValidateInnerOrbits ();
ResetSolarSys ();
LockMutex (GraphicsLock);
RepairSISBorder ();
UnlockMutex (GraphicsLock);
TransitionSystemIn ();
}
}
@@ -1325,11 +1319,9 @@ InitSolarSys (void)
BOOLEAN Reentry;
PLANET_DESC *orbital;
LockMutex (GraphicsLock);
LoadIPData ();
LoadLanderData ();
UnlockMutex (GraphicsLock);
Reentry = (GLOBAL (ShipFacing) != 0);
if (!Reentry)
@@ -1344,7 +1336,6 @@ InitSolarSys (void)
MAX_ZOOM_RADIUS);
}
LockMutex (GraphicsLock);
StarsFrame = CreateStarBackGround ();
@@ -1352,7 +1343,6 @@ InitSolarSys (void)
SetContextFGFrame (Screen);
SetContextBackGroundColor (BLACK_COLOR);
UnlockMutex (GraphicsLock);
orbital = LoadSolarSys ();
InnerSystem = CheckZoomLevel ();
@@ -1380,7 +1370,6 @@ InitSolarSys (void)
}
else
{ // Draw the borders, the system (inner or outer) and fade/transition
LockMutex (GraphicsLock);
SetContext (SpaceContext);
SetTransitionSource (NULL);
@@ -1418,8 +1407,6 @@ InitSolarSys (void)
LastActivity &= ~CHECK_LOAD;
}
UnlockMutex (GraphicsLock);
}
}
@@ -1928,9 +1915,7 @@ DoSolarSysMenu (MENU_STATE *pMS)
if (!select)
return TRUE;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
switch (pMS->CurState)
{
@@ -1971,9 +1956,7 @@ DoSolarSysMenu (MENU_STATE *pMS)
pMS->CurState = NAVIGATION;
DrawMenuStateStrings (PM_STARMAP, pMS->CurState);
}
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
}
return TRUE;
@@ -1996,10 +1979,8 @@ SolarSysMenu (void)
MenuState.CurState = STARMAP;
}
LockMutex (GraphicsLock);
DrawStatusMessage (NULL);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
MenuState.InputFunc = DoSolarSysMenu;
-6
View File
@@ -42,10 +42,6 @@
#include "libs/inplib.h"
// TODO: This entire module fails to uphold the GraphicsLock semantics
// This either has to be fixed, or GraphicsLock completely ignored,
// or will become irrelevant if GraphicsLock completely removed.
enum
{
START_NEW_GAME = 0,
@@ -74,7 +70,6 @@ DrawRestartMenuGraphic (MENU_STATE *pMS)
BatchGraphics ();
ClearDrawable ();
FlushColorXForms ();
LockMutex (GraphicsLock);
DrawStamp (&s);
// Put the version number in the bottom right corner.
@@ -89,7 +84,6 @@ DrawRestartMenuGraphic (MENU_STATE *pMS)
SetContextForeGroundColor (WHITE_COLOR);
font_DrawText (&t);
UnlockMutex (GraphicsLock);
UnbatchGraphics ();
}
-4
View File
@@ -606,20 +606,16 @@ SaveProblem (void)
STAMP s;
CONTEXT OldContext;
LockMutex (GraphicsLock);
OldContext = SetContext (SpaceContext);
SaveProblemMessage (&s);
FlushGraphics ();
UnlockMutex (GraphicsLock);
WaitForAnyButton (TRUE, WAIT_INFINITE, FALSE);
LockMutex (GraphicsLock);
// Restore the screen under the message
DrawStamp (&s);
SetContext (OldContext);
DestroyDrawable (ReleaseDrawable (s.frame));
UnlockMutex (GraphicsLock);
}
static void
-1
View File
@@ -65,7 +65,6 @@ FRAME StatusFrame;
FRAME FlagStatFrame;
FRAME MiscDataFrame;
FRAME FontGradFrame;
Mutex GraphicsLock;
STRING GameStrings;
QUEUE disp_q;
-1
View File
@@ -51,7 +51,6 @@ extern FONT StarConFont;
extern FONT MicroFont;
extern FONT TinyFont;
extern Mutex GraphicsLock;
extern CondVar RenderingCond;
extern QUEUE race_q[];
+8 -60
View File
@@ -119,11 +119,9 @@ on_input_frame (void)
{
CONTEXT oldContext;
LockMutex (GraphicsLock);
oldContext = SetContext (SpaceContext);
animatePowerLines (NULL);
SetContext (oldContext);
UnlockMutex (GraphicsLock);
}
#ifdef WANT_SHIP_SPINS
@@ -139,9 +137,7 @@ SpinStarShip (MENU_STATE *pMS, HFLEETINFO hStarShip)
if (Index >= 0 && Index < NUM_MELEE_SHIPS)
{
UnlockMutex (GraphicsLock);
DoShipSpin (Index, pMS->hMusic);
LockMutex (GraphicsLock);
}
}
#endif
@@ -201,7 +197,6 @@ DrawRaceStrings (MENU_STATE *pMS, BYTE NewRaceItem)
STAMP s;
CONTEXT OldContext;
LockMutex (GraphicsLock);
OldContext = SetContext (StatusContext);
GetContextClipRect (&r);
@@ -259,7 +254,6 @@ DrawRaceStrings (MENU_STATE *pMS, BYTE NewRaceItem)
UnbatchGraphics ();
SetContext (OldContext);
UnlockMutex (GraphicsLock);
}
#define SHIP_WIN_WIDTH 34
@@ -455,7 +449,6 @@ ShowCombatShip (MENU_STATE *pMS, COUNT which_window,
AllDoorsFinished = TRUE;
}
LockMutex (GraphicsLock);
OldContext = SetContext (SpaceContext);
GetContextClipRect (&OldClipRect);
SetContextBackGroundColor (BLACK_COLOR);
@@ -503,12 +496,10 @@ ShowCombatShip (MENU_STATE *pMS, COUNT which_window,
#endif
UnbatchGraphics ();
SetContext (OldContext);
UnlockMutex (GraphicsLock);
}
}
}
// Pre: GraphicsLock is unlocked.
static void
CrewTransaction (SIZE crew_delta)
{
@@ -552,7 +543,6 @@ CrewTransaction (SIZE crew_delta)
}
}
// Pre: GraphicsLock is locked.
static void
DMS_FlashFlagShip (void)
{
@@ -576,7 +566,6 @@ DMS_GetEscortShipRect (RECT *rOut, BYTE slotNr)
rOut->extent.height = SHIP_WIN_HEIGHT;
}
// Pre: GraphicsLock is locked.
static void
DMS_FlashEscortShip (BYTE slotNr)
{
@@ -585,7 +574,6 @@ DMS_FlashEscortShip (BYTE slotNr)
SetFlashRect (&r);
}
// Pre: GraphicsLock is locked.
static void
DMS_FlashFlagShipCrewCount (void)
{
@@ -596,7 +584,6 @@ DMS_FlashFlagShipCrewCount (void)
SetContext (SpaceContext);
}
// Pre: GraphicsLock is locked.
static void
DMS_FlashEscortShipCrewCount (BYTE slotNr)
{
@@ -615,7 +602,6 @@ DMS_FlashEscortShipCrewCount (BYTE slotNr)
// Helper function for DoModifyShips(). Called to change the flash
// rectangle to the currently selected ship (flagship or escort ship).
// The caller must hold the graphicsLock.
static void
DMS_FlashActiveShip (MENU_STATE *pMS)
{
@@ -636,7 +622,6 @@ DMS_FlashActiveShip (MENU_STATE *pMS)
// XXX: right now, this only switches the sound and flash rectangle.
// Perhaps we should move more of the code to modify other aspects
// here too.
// The caller must hold the graphicsLock.
static void
DMS_SetMode (MENU_STATE *pMS, DMS_Mode mode)
{
@@ -677,7 +662,6 @@ DMS_SetMode (MENU_STATE *pMS, DMS_Mode mode)
// It works both when the cursor is over an escort ship, while not editing
// the crew, and when a new ship is added.
// hStarShip is the ship in the slot under the cursor (or 0 if no such ship).
// Pre: GraphicsLock is locked.
static BOOLEAN
DMS_SpinShip (MENU_STATE *pMS, HSHIPFRAG hStarShip)
{
@@ -751,9 +735,9 @@ DMS_HireFlagShipCrew (void)
// Update the crew counter and RU. Note that the crew counter is
// flashing.
PreUpdateFlashRectLocked ();
PreUpdateFlashRect ();
DeltaSISGauges (1, 0, -GLOBAL (CrewCost));
PostUpdateFlashRectLocked ();
PostUpdateFlashRect ();
return 1;
}
@@ -780,10 +764,10 @@ DMS_DismissFlagShipCrew (void)
// Update the crew counter and RU. Note that the crew counter is
// flashing.
PreUpdateFlashRectLocked ();
PreUpdateFlashRect ();
DeltaSISGauges (-1, 0, GLOBAL (CrewCost) -
(crew_bought == CREW_EXPENSE_THRESHOLD ? 2 : 0));
PostUpdateFlashRectLocked ();
PostUpdateFlashRect ();
// Remove the pixel representing the crew member.
GetCPodCapacity (&r.corner);
@@ -843,10 +827,10 @@ DMS_HireEscortShipCrew (SHIP_FRAGMENT *StarShipPtr)
++StarShipPtr->crew_level;
PreUpdateFlashRectLocked ();
PreUpdateFlashRect ();
DMS_GetEscortShipRect (&r, StarShipPtr->index);
ShowShipCrew (StarShipPtr, &r);
PostUpdateFlashRectLocked ();
PostUpdateFlashRect ();
return 1;
}
@@ -888,10 +872,10 @@ DMS_DismissEscortShipCrew (SHIP_FRAGMENT *StarShipPtr)
PlayMenuSound (MENU_SOUND_FAILURE);
}
PreUpdateFlashRectLocked ();
PreUpdateFlashRect ();
DMS_GetEscortShipRect (&r, StarShipPtr->index);
ShowShipCrew (StarShipPtr, &r);
PostUpdateFlashRectLocked ();
PostUpdateFlashRect ();
return crew_delta;
}
@@ -903,7 +887,6 @@ DMS_DismissEscortShipCrew (SHIP_FRAGMENT *StarShipPtr)
// selected.
// 'dy' is -1 if the 'up' button was pressed, or '1' if the down button was
// pressed.
// Pre: caller holds the GraphicsLock
static void
DMS_ModifyCrew (MENU_STATE *pMS, HSHIPFRAG hStarShip, SBYTE dy)
{
@@ -960,15 +943,12 @@ DMS_ModifyCrew (MENU_STATE *pMS, HSHIPFRAG hStarShip, SBYTE dy)
pMS->delta_item &= MODIFY_CREW_FLAG;
}
UnlockMutex (GraphicsLock);
CrewTransaction (crew_delta);
LockMutex (GraphicsLock);
}
// Helper function for DoModifyShips(), called when the player presses the
// select button when the cursor is over an empty escort ship slot.
// Try to add the currently selected ship as an escort ship.
// Pre: caller does not hold the GraphicsLock
static void
DMS_TryAddEscortShip (MENU_STATE *pMS)
{
@@ -983,11 +963,9 @@ DMS_TryAddEscortShip (MENU_STATE *pMS)
// Reset flash rectangle
DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW);
LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA,
-((int)ShipCost[Index]));
DMS_SetMode (pMS, DMS_Mode_editCrew);
UnlockMutex (GraphicsLock);
}
else
{
@@ -1011,28 +989,21 @@ DMS_AddEscortShip (MENU_STATE *pMS, BOOLEAN special, BOOLEAN select,
if (special)
{
HSHIPFRAG hStarShip = GetEscortByStarShipIndex (pMS->delta_item);
LockMutex (GraphicsLock);
if (DMS_SpinShip (pMS, hStarShip))
DMS_SetMode (pMS, DMS_Mode_addEscort);
UnlockMutex (GraphicsLock);
return;
}
#else
(void) special; // Satisfying compiler.
#endif /* WANT_SHIP_SPINS */
UnlockMutex (GraphicsLock);
if (cancel)
{
// Cancel selecting an escort ship.
pMS->delta_item &= ~MODIFY_CREW_FLAG;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW);
LockMutex (GraphicsLock);
DMS_SetMode (pMS, DMS_Mode_navigate);
UnlockMutex (GraphicsLock);
}
else if (select)
{
@@ -1065,12 +1036,10 @@ DMS_AddEscortShip (MENU_STATE *pMS, BOOLEAN special, BOOLEAN select,
pMS->delta_item = currentShip | MODIFY_CREW_FLAG;
}
}
LockMutex (GraphicsLock);
}
// Helper function for DoModifyShips(), called when the player presses
// 'select' or 'cancel' after selling all the crew.
// Pre: caller holds the GraphicsLock
static void
DMS_ScrapEscortShip (MENU_STATE *pMS, HSHIPFRAG hStarShip)
{
@@ -1079,9 +1048,7 @@ DMS_ScrapEscortShip (MENU_STATE *pMS, HSHIPFRAG hStarShip)
BYTE slotNr;
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
ShowCombatShip (pMS, pMS->CurState, StarShipPtr);
LockMutex (GraphicsLock);
slotNr = StarShipPtr->index;
UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip);
@@ -1138,7 +1105,6 @@ DMS_MoveCursor (BYTE curState, SBYTE dx, SBYTE dy)
// Helper function for DoModifyShips(), called every time DoModifyShip() is
// called when we are in crew editing mode.
// Pre: Caller holds the GraphicsLock
static void
DMS_EditCrewMode (MENU_STATE *pMS, HSHIPFRAG hStarShip,
BOOLEAN select, BOOLEAN cancel, SBYTE dy)
@@ -1209,9 +1175,7 @@ DMS_NavigateShipSlots (MENU_STATE *pMS, BOOLEAN special, BOOLEAN select,
// Select button was pressed over an empty escort
// ship slot. Switch to 'add escort ship' mode.
pMS->delta_item = MODIFY_CREW_FLAG;
UnlockMutex (GraphicsLock);
DrawRaceStrings (pMS, 0);
LockMutex (GraphicsLock);
DMS_SetMode (pMS, DMS_Mode_addEscort);
}
else
@@ -1227,9 +1191,7 @@ DMS_NavigateShipSlots (MENU_STATE *pMS, BOOLEAN special, BOOLEAN select,
// Leave escort ship editor.
pMS->InputFunc = DoShipyard;
pMS->CurState = SHIPYARD_CREW;
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_CREW, pMS->CurState);
LockMutex (GraphicsLock);
DMS_SetMode (pMS, DMS_Mode_exit);
}
}
@@ -1257,10 +1219,8 @@ DoModifyShips (MENU_STATE *pMS)
pMS->CurState = MAKE_BYTE (0, 0xF);
pMS->delta_item = 0;
LockMutex (GraphicsLock);
SetContext (SpaceContext);
DMS_SetMode (pMS, DMS_Mode_navigate);
UnlockMutex (GraphicsLock);
}
else
{
@@ -1279,7 +1239,6 @@ DoModifyShips (MENU_STATE *pMS)
if (PulsedInputState.menu[KEY_MENU_DOWN])
dy = 1;
LockMutex (GraphicsLock);
if (!(pMS->delta_item & MODIFY_CREW_FLAG))
{
@@ -1304,7 +1263,6 @@ DoModifyShips (MENU_STATE *pMS)
}
}
UnlockMutex (GraphicsLock);
}
SleepThread (ONE_SECOND / 30);
@@ -1452,7 +1410,6 @@ DoShipyard (MENU_STATE *pMS)
pMS->hMusic = LoadMusic (SHIPYARD_MUSIC);
LockMutex (GraphicsLock);
SetTransitionSource (NULL);
BatchGraphics ();
DrawSISFrame ();
@@ -1460,12 +1417,10 @@ DoShipyard (MENU_STATE *pMS)
DrawSISTitle (GAME_STRING (STARBASE_STRING_BASE));
SetContext (SpaceContext);
DrawBluePrint (pMS);
UnlockMutex (GraphicsLock);
pMS->CurState = SHIPYARD_CREW;
DrawMenuStateStrings (PM_CREW, pMS->CurState);
LockMutex (GraphicsLock);
SetContext (SpaceContext);
s.origin.x = 0;
s.origin.y = 0;
@@ -1490,7 +1445,6 @@ DoShipyard (MENU_STATE *pMS)
ScreenTransition (3, NULL);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
PlayMusic (pMS->hMusic, TRUE, 1);
@@ -1498,9 +1452,7 @@ DoShipyard (MENU_STATE *pMS)
SetInputCallback (on_input_frame);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
}
pMS->Initialized = TRUE;
@@ -1510,12 +1462,10 @@ DoShipyard (MENU_STATE *pMS)
ExitShipyard:
SetInputCallback (NULL);
LockMutex (GraphicsLock);
DestroyDrawable (ReleaseDrawable (pMS->ModuleFrame));
pMS->ModuleFrame = 0;
DestroyColorMap (ReleaseColorMap (pMS->CurString));
pMS->CurString = 0;
UnlockMutex (GraphicsLock);
return FALSE;
}
@@ -1532,9 +1482,7 @@ ExitShipyard:
if (!GameOptions ())
goto ExitShipyard;
DrawMenuStateStrings (PM_CREW, pMS->CurState);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
}
}
else
-32
View File
@@ -100,9 +100,7 @@ ClearSISRect (BYTE ClearFlags)
if (ClearFlags & CLEAR_SIS_RADAR)
{
UnlockMutex (GraphicsLock);
DrawMenuStateStrings ((BYTE)~0, 1);
LockMutex (GraphicsLock);
#ifdef NEVER
r.corner.x = RADAR_X - 1;
r.corner.y = RADAR_Y - 1;
@@ -951,7 +949,6 @@ DrawModules (void)
}
}
// Pre: GraphicsLock is unlocked
static void
DrawSupportShips (void)
{
@@ -975,9 +972,7 @@ DrawSupportShips (void)
s.origin = *pship_pos;
s.frame = StarShipPtr->icons;
LockMutex (GraphicsLock);
DrawStamp (&s);
UnlockMutex (GraphicsLock);
UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip);
}
@@ -1142,9 +1137,7 @@ DeltaSISGauges (SIZE crew_delta, SIZE fuel_delta, int resunit_delta)
DrawTurningJets ();
DrawModules ();
UnlockMutex (GraphicsLock);
DrawSupportShips ();
LockMutex (GraphicsLock);
}
SetContextFont (TinyFont);
@@ -1619,7 +1612,6 @@ scheduleFlashAlarm (void)
flashAlarm = Alarm_addAbsoluteMs (nextTimeMs, updateFlashRect, NULL);
}
// Pre: the caller holds the GraphicsLock
void
SetFlashRect (const RECT *pRect)
{
@@ -1683,9 +1675,7 @@ SetFlashRect (const RECT *pRect)
// Flash rectangle is empty. Stop flashing.
if (flashContext != NULL)
{
UnlockMutex (GraphicsLock);
Alarm_remove(flashAlarm);
LockMutex (GraphicsLock);
flashAlarm = 0;
Flash_terminate (flashContext);
@@ -1700,7 +1690,6 @@ COUNT updateFlashRectRecursion = 0;
// ClearSISRect(), which calls DrawMenuStateStrings(), which starts its own
// UpdateFlashRect block. This should probably be cleaned up.
// GraphicsLock must be unlocked.
void
PreUpdateFlashRect (void)
{
@@ -1713,7 +1702,6 @@ PreUpdateFlashRect (void)
}
}
// GraphicsLock must be unlocked.
void
PostUpdateFlashRect (void)
{
@@ -1727,26 +1715,6 @@ PostUpdateFlashRect (void)
}
}
// Because the situation occurs a lot where the GraphicsLock is already
// locked, we add this function.
void
PreUpdateFlashRectLocked (void)
{
UnlockMutex (GraphicsLock);
PreUpdateFlashRect ();
LockMutex (GraphicsLock);
}
// Because the situation occurs a lot where the GraphicsLock is already
// locked, we add this function.
void
PostUpdateFlashRectLocked (void)
{
UnlockMutex (GraphicsLock);
PostUpdateFlashRect ();
LockMutex (GraphicsLock);
}
// Stop flashing if flashing is active.
void
PauseFlash (void)
-2
View File
@@ -184,8 +184,6 @@ extern void ClearSISRect (BYTE ClearFlags);
extern void SetFlashRect (const RECT *pRect);
extern void PreUpdateFlashRect (void);
extern void PostUpdateFlashRect (void);
extern void PreUpdateFlashRectLocked (void);
extern void PostUpdateFlashRectLocked (void);
extern void PauseFlash (void);
extern void ContinueFlash (void);
-10
View File
@@ -307,7 +307,6 @@ DoStarBase (MENU_STATE *pMS)
LastActivity &= ~CHECK_LOAD;
pMS->InputFunc = DoStarBase;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
if (pMS->hMusic)
@@ -318,12 +317,10 @@ DoStarBase (MENU_STATE *pMS)
}
pMS->Initialized = TRUE;
UnlockMutex (GraphicsLock);
pMS->CurFrame = CaptureDrawable (LoadGraphic (STARBASE_ANIM));
pMS->hMusic = LoadMusic (STARBASE_MUSIC);
LockMutex (GraphicsLock);
SetContext (ScreenContext);
SetTransitionSource (NULL);
BatchGraphics ();
@@ -334,7 +331,6 @@ DoStarBase (MENU_STATE *pMS)
ScreenTransition (3, NULL);
PlayMusic (pMS->hMusic, TRUE, 1);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
}
else if (PulsedInputState.menu[KEY_MENU_SELECT])
{
@@ -404,7 +400,6 @@ ExitStarBase:
NewState = TALK_COMMANDER;
}
LockMutex (GraphicsLock);
BatchGraphics ();
SetContext (ScreenContext);
@@ -417,7 +412,6 @@ ExitStarBase:
rotateStarbase (pMS, NULL);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
SleepThread (ONE_SECOND / 30);
}
@@ -430,9 +424,7 @@ DoTimePassage (void)
{
#define LOST_DAYS 14
SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND * 2));
LockMutex (GraphicsLock);
MoveGameClockDays (LOST_DAYS);
UnlockMutex (GraphicsLock);
}
void
@@ -541,12 +533,10 @@ InstallBombAtEarth (void)
{
DoTimePassage ();
LockMutex (GraphicsLock);
SetContext (ScreenContext);
SetTransitionSource (NULL);
SetContextBackGroundColor (BLACK_COLOR);
ClearDrawable ();
UnlockMutex (GraphicsLock);
SleepThreadUntil (FadeScreen (FadeAllToColor, 0));
-3
View File
@@ -77,7 +77,6 @@ checkArilouGate (void)
}
// Battle frame callback function.
// Called with GraphicsLock held
static void
on_battle_frame (void)
{
@@ -286,9 +285,7 @@ while (--ac > 0)
Battle (&on_battle_frame);
}
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
LastActivity = GLOBAL (CurrentActivity);
-5
View File
@@ -86,7 +86,6 @@ DrawPickIcon (MeleeShip ship, bool DrawErase)
}
}
// Pre: the called holds the GraphicsLock
void
DrawPickFrame (MELEE_STATE *pMS)
{
@@ -187,11 +186,9 @@ DoPickShip (MELEE_STATE *pMS)
if (newSelectedShip != pMS->currentShip)
{
// A new ship has been selected.
LockMutex (GraphicsLock);
DrawPickIcon (pMS->currentShip, true);
pMS->currentShip = newSelectedShip;
DrawMeleeShipStrings (pMS, newSelectedShip);
UnlockMutex (GraphicsLock);
}
}
@@ -214,9 +211,7 @@ BuildPickShip (MELEE_STATE *pMS)
if (pMS->currentShip == MELEE_NONE)
pMS->currentShip = 0;
LockMutex (GraphicsLock);
DrawPickFrame (pMS);
UnlockMutex (GraphicsLock);
pMS->InputFunc = DoPickShip;
DoInput (pMS, FALSE);
-12
View File
@@ -311,11 +311,9 @@ flashSelectedTeam (MELEE_STATE *pMS)
NextTime = Now + FLASH_RATE;
hilite ^= 1;
LockMutex (GraphicsLock);
OldContext = SetContext (SpaceContext);
SelectFileString (pMS, hilite);
SetContext (OldContext);
UnlockMutex (GraphicsLock);
}
}
@@ -335,12 +333,10 @@ DoLoadTeam (MELEE_STATE *pMS)
if (!pMS->Initialized)
{
LockMutex (GraphicsLock);
DrawFileStrings (pMS);
SelectFileString (pMS, true);
pMS->Initialized = TRUE;
pMS->InputFunc = DoLoadTeam;
UnlockMutex (GraphicsLock);
return TRUE;
}
@@ -360,9 +356,7 @@ DoLoadTeam (MELEE_STATE *pMS)
RECT r;
GetFrameRect (SetAbsFrameIndex (MeleeFrame, 28), &r);
LockMutex (GraphicsLock);
RepairMeleeFrame (&r);
UnlockMutex (GraphicsLock);
}
return TRUE;
}
@@ -418,7 +412,6 @@ DoLoadTeam (MELEE_STATE *pMS)
if (newIndex != pMS->load.cur)
{
// The cursor has been moved.
LockMutex (GraphicsLock);
if (newTop == pMS->load.top)
{
// The view itself hasn't changed.
@@ -431,7 +424,6 @@ DoLoadTeam (MELEE_STATE *pMS)
DrawFileStrings (pMS);
}
pMS->load.cur = newIndex;
UnlockMutex (GraphicsLock);
}
}
@@ -482,11 +474,9 @@ DoSaveTeam (MELEE_STATE *pMS)
snprintf (file, sizeof file, "%s.mle",
MeleeSetup_getTeamName (pMS->meleeSetup, pMS->side));
LockMutex (GraphicsLock);
OldContext = SetContext (ScreenContext);
ConfirmSaveLoad (&MsgStamp);
// Show the "Saving . . ." message.
UnlockMutex (GraphicsLock);
stream = uio_fopen (meleeDir, file, "wb");
if (stream != NULL)
@@ -503,11 +493,9 @@ DoSaveTeam (MELEE_STATE *pMS)
pMS->load.cur = 0;
// Undo the screen damage done by the "Saving . . ." message.
LockMutex (GraphicsLock);
DrawStamp (&MsgStamp);
DestroyDrawable (ReleaseDrawable (MsgStamp.frame));
SetContext (OldContext);
UnlockMutex (GraphicsLock);
if (!saveOk)
SaveProblem ();
-46
View File
@@ -250,7 +250,6 @@ GetShipBox (RECT *pRect, COUNT side, COUNT row, COUNT col)
pRect->extent.height = MELEE_BOX_HEIGHT;
}
// The caller must hold the GraphicsLock.
static void
DrawShipBox (COUNT side, FleetShipIndex index, MeleeShip ship, BOOLEAN HiLite)
{
@@ -286,7 +285,6 @@ DrawShipBox (COUNT side, FleetShipIndex index, MeleeShip ship, BOOLEAN HiLite)
UnbatchGraphics ();
}
// The caller must hold the GraphicsLock.
static void
ClearShipBox (COUNT side, FleetShipIndex index)
{
@@ -570,7 +568,6 @@ DrawTeamString (MELEE_STATE *pMS, COUNT side, COUNT HiLiteState,
#ifdef NETPLAY
// This function is generic. It should probably be moved to elsewhere.
// The caller should hold the GraphicsLock.
static void
multiLineDrawText (TEXT *textIn, RECT *clipRect) {
RECT oldRect;
@@ -617,7 +614,6 @@ DrawMeleeStatusMessage (const char *message)
CONTEXT oldContext;
RECT r;
LockMutex (GraphicsLock);
oldContext = SetContext (SpaceContext);
r.corner.x = MELEE_STATUS_X_OFFS;
@@ -643,7 +639,6 @@ DrawMeleeStatusMessage (const char *message)
}
SetContext (oldContext);
UnlockMutex (GraphicsLock);
}
static void
@@ -697,7 +692,6 @@ UpdateMeleeStatusMessage (ssize_t player)
#endif /* NETPLAY */
// XXX: this function is called when the current selection is blinking off.
// The caller should hold the GraphicsLock.
static void
Deselect (BYTE opt)
{
@@ -760,7 +754,6 @@ Deselect (BYTE opt)
}
// XXX: this function is called when the current selection is blinking off.
// The caller should hold the GraphicsLock.
static void
Select (BYTE opt)
{
@@ -837,14 +830,12 @@ Melee_flashSelection (MELEE_STATE *pMS)
NextTime = Now + FLASH_RATE;
select = !select;
LockMutex (GraphicsLock);
OldContext = SetContext (SpaceContext);
if (select)
Select (pMS->MeleeOption);
else
Deselect (pMS->MeleeOption);
SetContext (OldContext);
UnlockMutex (GraphicsLock);
}
}
@@ -870,7 +861,6 @@ InitMelee (MELEE_STATE *pMS)
(void) pMS;
}
// Pre: The caller holds the GraphicsLock.
void
DrawMeleeShipStrings (MELEE_STATE *pMS, MeleeShip NewStarShip)
{
@@ -957,9 +947,7 @@ UpdateCurrentShip (MELEE_STATE *pMS)
MeleeSetup_getShip (pMS->meleeSetup, pMS->side, slotNr);
}
LockMutex (GraphicsLock);
DrawMeleeShipStrings (pMS, pMS->currentShip);
UnlockMutex (GraphicsLock);
}
// returns (COUNT) ~0 for an invalid ship.
@@ -1025,9 +1013,7 @@ OnTeamNameChange (TEXTENTRY_STATE *pTES)
if (pTES->JoystickMode)
hl |= DTSHS_BLOCKCUR;
LockMutex (GraphicsLock);
ret = DrawTeamString (pMS, pMS->side, hl, pTES->BaseStr);
UnlockMutex (GraphicsLock);
return ret;
}
@@ -1074,9 +1060,7 @@ BuildPickShipPopup (MELEE_STATE *pMS)
RECT r;
GetBuildPickFrameRect (&r);
LockMutex (GraphicsLock);
RepairMeleeFrame (&r);
UnlockMutex (GraphicsLock);
}
UpdateCurrentShip (pMS);
@@ -1113,12 +1097,10 @@ DoEdit (MELEE_STATE *pMS)
|| pMS->row == NUM_MELEE_ROWS))))
{
// Done editing the teams.
LockMutex (GraphicsLock);
Deselect (EDIT_MELEE);
pMS->currentShip = MELEE_NONE;
pMS->MeleeOption = START_MELEE;
pMS->InputFunc = DoMelee;
UnlockMutex (GraphicsLock);
pMS->LastInputTime = GetTimeCounter ();
}
else if (pMS->row < NUM_MELEE_ROWS
@@ -1132,13 +1114,11 @@ DoEdit (MELEE_STATE *pMS)
&& PulsedInputState.menu[KEY_MENU_SPECIAL])
{
// TODO: this is a stub; Should we display a ship spin?
LockMutex (GraphicsLock);
Deselect (EDIT_MELEE);
if (pMS->currentShip != MELEE_NONE)
{
// Do something with pMS->currentShip here
}
UnlockMutex (GraphicsLock);
}
else if (pMS->row < NUM_MELEE_ROWS &&
PulsedInputState.menu[KEY_MENU_DELETE])
@@ -1165,9 +1145,7 @@ DoEdit (MELEE_STATE *pMS)
// going to enter text
pMS->CurIndex = 0;
LockMutex (GraphicsLock);
DrawTeamString (pMS, pMS->side, DTSHS_EDIT, NULL);
UnlockMutex (GraphicsLock);
strncpy (buf, MeleeSetup_getTeamName (
pMS->meleeSetup, pMS->side), MAX_TEAM_CHARS);
@@ -1238,12 +1216,10 @@ DoEdit (MELEE_STATE *pMS)
if (col != pMS->col || row != pMS->row || side != pMS->side)
{
LockMutex (GraphicsLock);
Deselect (EDIT_MELEE);
pMS->side = side;
pMS->row = row;
pMS->col = col;
UnlockMutex (GraphicsLock);
UpdateCurrentShip (pMS);
}
@@ -1488,9 +1464,7 @@ StartMelee (MELEE_STATE *pMS)
{
if (!SetPlayerInputAll ())
break;
LockMutex (GraphicsLock);
BuildAndDrawShipList (pMS);
UnlockMutex (GraphicsLock);
WaitForSoundEnd (TFBSOUND_WAIT_ALL);
@@ -1638,7 +1612,6 @@ DoConnectingDialog (MELEE_STATE *pMS)
pMS->InputFunc = DoConnectingDialog;
/* Draw the dialog box here */
LockMutex (GraphicsLock);
oldfont = SetContextFont (StarConFont);
oldcolor = SetContextForeGroundColor (BLACK_COLOR);
BatchGraphics ();
@@ -1674,7 +1647,6 @@ DoConnectingDialog (MELEE_STATE *pMS)
SetContextFont (oldfont);
SetContextForeGroundColor (oldcolor);
UnbatchGraphics ();
UnlockMutex (GraphicsLock);
}
netInput ();
@@ -1882,9 +1854,7 @@ DoMelee (MELEE_STATE *pMS)
pMS->MeleeOption = START_MELEE;
PlayMusic (pMS->hMusic, TRUE, 1);
LockMutex (GraphicsLock);
InitMelee (pMS);
UnlockMutex (GraphicsLock);
FadeScreen (FadeAllToColor, ONE_SECOND / 2);
pMS->LastInputTime = GetTimeCounter ();
@@ -1899,10 +1869,8 @@ DoMelee (MELEE_STATE *pMS)
PulsedInputState.menu[KEY_MENU_LEFT])
{
// Start editing the teams.
LockMutex (GraphicsLock);
pMS->LastInputTime = GetTimeCounter ();
Deselect (pMS->MeleeOption);
UnlockMutex (GraphicsLock);
pMS->MeleeOption = EDIT_MELEE;
pMS->Initialized = FALSE;
if (PulsedInputState.menu[KEY_MENU_CANCEL])
@@ -1949,11 +1917,9 @@ DoMelee (MELEE_STATE *pMS)
pMS->MeleeOption == CONTROLS_BOT)
UpdateMeleeStatusMessage (-1);
#endif
LockMutex (GraphicsLock);
Deselect (pMS->MeleeOption);
pMS->MeleeOption = NewMeleeOption;
Select (pMS->MeleeOption);
UnlockMutex (GraphicsLock);
#ifdef NETPLAY
if (NewMeleeOption == CONTROLS_TOP ||
NewMeleeOption == CONTROLS_BOT)
@@ -2148,14 +2114,12 @@ updateRandomSeed (MELEE_STATE *pMS, COUNT side, DWORD seed)
void
confirmationCancelled (MELEE_STATE *pMS, COUNT side)
{
LockMutex (GraphicsLock);
if (side == 0)
DrawMeleeStatusMessage (GAME_STRING (NETMELEE_STRING_BASE + 16));
// "Bottom player changed something -- need to reconfirm."
else
DrawMeleeStatusMessage (GAME_STRING (NETMELEE_STRING_BASE + 17));
// "Top player changed something -- need to reconfirm."
UnlockMutex (GraphicsLock);
if (pMS->InputFunc == DoConfirmSettings)
pMS->InputFunc = DoMelee;
@@ -2168,9 +2132,7 @@ connectionFeedback (NetConnection *conn, const char *str, bool forcePopup) {
if (bs == NULL && !forcePopup)
{
// bs == NULL means the game has not started yet.
LockMutex (GraphicsLock);
DrawMeleeStatusMessage (str);
UnlockMutex (GraphicsLock);
}
else
{
@@ -2314,10 +2276,8 @@ Melee_UpdateView_fleetValue (MELEE_STATE *pMS, COUNT side)
if (pMS->meleeStarted)
return;
LockMutex (GraphicsLock);
DrawFleetValue (pMS, side, DTSHS_REPAIR);
// BUG: The fleet value is always drawn as deselected.
UnlockMutex (GraphicsLock);
}
static void
@@ -2330,7 +2290,6 @@ Melee_UpdateView_ship (MELEE_STATE *pMS, COUNT side, FleetShipIndex index)
ship = MeleeSetup_getShip (pMS->meleeSetup, side, index);
LockMutex (GraphicsLock);
if (ship == MELEE_NONE)
{
ClearShipBox (side, index);
@@ -2339,7 +2298,6 @@ Melee_UpdateView_ship (MELEE_STATE *pMS, COUNT side, FleetShipIndex index)
{
DrawShipBox (side, index, ship, FALSE);
}
UnlockMutex (GraphicsLock);
}
static void
@@ -2348,9 +2306,7 @@ Melee_UpdateView_teamName (MELEE_STATE *pMS, COUNT side)
if (pMS->meleeStarted)
return;
LockMutex (GraphicsLock);
DrawTeamString (pMS, side, DTSHS_REPAIR, NULL);
UnlockMutex (GraphicsLock);
}
///////////////////////////////////////////////////////////////////////////
@@ -2378,9 +2334,7 @@ Melee_Change_ship (MELEE_STATE *pMS, COUNT side, FleetShipIndex index,
if (isShipSlotSelected (pMS, side, index))
{
pMS->currentShip = ship;
LockMutex (GraphicsLock);
DrawMeleeShipStrings (pMS, ship);
UnlockMutex (GraphicsLock);
}
return true;
-4
View File
@@ -656,7 +656,6 @@ MeleeGameOver (void)
for (playerI = 0; playerI < NUM_PLAYERS; playerI++)
DrawPickMeleeFrame (playerI);
UnlockMutex (GraphicsLock);
#ifdef NETPLAY
negotiateReadyConnections(true, NetState_inSetup);
@@ -683,7 +682,6 @@ MeleeGameOver (void)
&& (!(PlayerControl[0] & PlayerControl[1] & PSYTRON_CONTROL)
|| GetTimeCounter () < TimeOut)));
LockMutex (GraphicsLock);
}
void
@@ -796,12 +794,10 @@ GetMeleeStarShips (COUNT playerMask, HSTARSHIP *ships)
SetContext (OffScreenContext);
UnlockMutex (GraphicsLock);
DoInput (&gmstate, FALSE);
WaitForSoundEnd (0);
LockMutex (GraphicsLock);
for (playerI = 0; playerI < NUM_PLAYERS; playerI++)
{
+1 -18
View File
@@ -147,7 +147,7 @@ debugKeyPressed (void)
// Fast forwards to the next event.
// If skipHEE is set, HYPERSPACE_ENCOUNTER_EVENTs are skipped.
// Must be called from the Starcon2Main thread.
// TODO: GraphicsLock and LockGameClock may be removed since it is only
// TODO: LockGameClock may be removed since it is only
// supposed to be called synchronously wrt the game logic thread.
void
forwardToNextEvent (BOOLEAN skipHEE)
@@ -161,9 +161,6 @@ forwardToNextEvent (BOOLEAN skipHEE)
if (!GameClockRunning ())
return;
// Must hold GraphicsLock for MoveGameClockDays()
// Must acquire GraphicsLock *before* the game clock lock
LockMutex (GraphicsLock);
LockGameClock ();
done = !skipHEE;
@@ -192,7 +189,6 @@ forwardToNextEvent (BOOLEAN skipHEE)
} while (!done);
UnlockGameClock ();
UnlockMutex (GraphicsLock);
}
const char *
@@ -376,9 +372,7 @@ equipShip (void)
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE ||
LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY)
{
LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
UnlockMutex (GraphicsLock);
}
}
@@ -435,9 +429,7 @@ clearEscorts (void)
FreeShipFrag (&GLOBAL (built_ship_q), hStarShip);
}
LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
UnlockMutex (GraphicsLock);
}
////////////////////////////////////////////////////////////////////////////
@@ -1865,16 +1857,13 @@ debugContexts (void)
return;
inDebugContexts = true;
LockMutex (GraphicsLock);
contextCount = countVisibleContexts ();
if (contextCount == 0)
{
UnlockMutex (GraphicsLock);
goto out;
}
savedScreen = getScreen ();
//UnlockMutex (GraphicsLock);
FlushGraphics ();
// Make sure that the screen has actually been captured,
// before we use the frame.
@@ -1888,7 +1877,6 @@ debugContexts (void)
hueIncrement = 360.0 / contextCount;
//LockMutex (GraphicsLock);
visibleContextI = 0;
for (context = GetFirstContext (); context != NULL;
context = GetNextContext (context))
@@ -1910,7 +1898,6 @@ debugContexts (void)
// Blit the final debugging frame to the screen.
putScreen (debugDrawFrame);
UnlockMutex (GraphicsLock);
// Wait for a key:
{
@@ -1919,9 +1906,7 @@ debugContexts (void)
DoInput(&state, TRUE);
}
LockMutex (GraphicsLock);
SetContext (orgContext);
UnlockMutex (GraphicsLock);
// Destroy the debugging frame and context.
DestroyContext (debugDrawContext);
@@ -1929,9 +1914,7 @@ debugContexts (void)
// SetContextFGFrame().
DestroyDrawable (ReleaseDrawable (debugDrawFrame));
LockMutex (GraphicsLock);
putScreen (savedScreen);
UnlockMutex (GraphicsLock);
DestroyDrawable (ReleaseDrawable (savedScreen));
-8
View File
@@ -152,7 +152,6 @@ PauseGame (void)
if (PlayingTrack ())
PauseTrack ();
LockMutex (GraphicsLock);
OldContext = SetContext (ScreenContext);
oldOrigin = SetContextOrigin (MAKE_POINT (0, 0));
GetContextClipRect (&OldRect);
@@ -170,11 +169,7 @@ PauseGame (void)
SetSystemRect (&r);
DrawStamp (&s);
// It is safer to just not release the lock so any graphics tasks
// would be blocked
//UnlockMutex (GraphicsLock);
FlushGraphics ();
//LockMutex (GraphicsLock);
while (ImmediateInputState.menu[KEY_PAUSE] && GamePaused)
{
@@ -209,7 +204,6 @@ PauseGame (void)
if (PlayingTrack ())
ResumeTrack ();
UnlockMutex (GraphicsLock);
TaskSwitch ();
GLOBAL (CurrentActivity) &= ~CHECK_PAUSE;
@@ -300,7 +294,6 @@ SleepGame (void)
PauseTrack ();
PauseMusic ();
LockMutex (GraphicsLock);
while (!GameActive && !QuitPosted)
SleepThread (ONE_SECOND / 2);
@@ -314,7 +307,6 @@ SleepGame (void)
if (PlayingTrack ())
ResumeTrack ();
UnlockMutex (GraphicsLock);
TaskSwitch ();
}