|
From: <av...@us...> - 2012-02-11 23:41:16
|
Revision: 3761
http://sc2.svn.sourceforge.net/sc2/?rev=3761&view=rev
Author: avolkov
Date: 2012-02-11 23:41:06 +0000 (Sat, 11 Feb 2012)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/sc2/ChangeLog
trunk/sc2/build/msvc6/UrQuanMasters.dsp
trunk/sc2/doc/devel/threads
trunk/sc2/src/libs/callback/callback.c
trunk/sc2/src/libs/callback/callback.h
trunk/sc2/src/libs/graphics/dcqueue.c
trunk/sc2/src/libs/sound/trackint.h
trunk/sc2/src/libs/sound/trackplayer.c
trunk/sc2/src/libs/sound/trackplayer.h
trunk/sc2/src/libs/video/video.c
trunk/sc2/src/libs/video/vidintrn.h
trunk/sc2/src/libs/video/vidplayer.c
trunk/sc2/src/uqm/battle.c
trunk/sc2/src/uqm/battle.h
trunk/sc2/src/uqm/build.c
trunk/sc2/src/uqm/clock.c
trunk/sc2/src/uqm/cnctdlg.c
trunk/sc2/src/uqm/comm/comandr/comandr.c
trunk/sc2/src/uqm/comm/druuge/druugec.c
trunk/sc2/src/uqm/comm/melnorm/melnorm.c
trunk/sc2/src/uqm/comm/starbas/starbas.c
trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c
trunk/sc2/src/uqm/comm.c
trunk/sc2/src/uqm/commglue.c
trunk/sc2/src/uqm/commglue.h
trunk/sc2/src/uqm/confirm.c
trunk/sc2/src/uqm/controls.h
trunk/sc2/src/uqm/credits.c
trunk/sc2/src/uqm/encount.c
trunk/sc2/src/uqm/flash.c
trunk/sc2/src/uqm/fmv.c
trunk/sc2/src/uqm/gameopt.c
trunk/sc2/src/uqm/hyper.c
trunk/sc2/src/uqm/intro.c
trunk/sc2/src/uqm/menu.c
trunk/sc2/src/uqm/outfit.c
trunk/sc2/src/uqm/pickship.c
trunk/sc2/src/uqm/planets/cargo.c
trunk/sc2/src/uqm/planets/devices.c
trunk/sc2/src/uqm/planets/generate/genchmmr.c
trunk/sc2/src/uqm/planets/generate/genmyc.c
trunk/sc2/src/uqm/planets/generate/genorz.c
trunk/sc2/src/uqm/planets/generate/genpet.c
trunk/sc2/src/uqm/planets/generate/genthrad.c
trunk/sc2/src/uqm/planets/generate/genutw.c
trunk/sc2/src/uqm/planets/generate/genvux.c
trunk/sc2/src/uqm/planets/lander.c
trunk/sc2/src/uqm/planets/pl_stuff.c
trunk/sc2/src/uqm/planets/planets.c
trunk/sc2/src/uqm/planets/plangen.c
trunk/sc2/src/uqm/planets/pstarmap.c
trunk/sc2/src/uqm/planets/report.c
trunk/sc2/src/uqm/planets/roster.c
trunk/sc2/src/uqm/planets/scan.c
trunk/sc2/src/uqm/planets/solarsys.c
trunk/sc2/src/uqm/restart.c
trunk/sc2/src/uqm/save.c
trunk/sc2/src/uqm/setup.c
trunk/sc2/src/uqm/setup.h
trunk/sc2/src/uqm/shipyard.c
trunk/sc2/src/uqm/sis.c
trunk/sc2/src/uqm/sis.h
trunk/sc2/src/uqm/starbase.c
trunk/sc2/src/uqm/starcon.c
trunk/sc2/src/uqm/supermelee/buildpick.c
trunk/sc2/src/uqm/supermelee/loadmele.c
trunk/sc2/src/uqm/supermelee/melee.c
trunk/sc2/src/uqm/supermelee/pickmele.c
trunk/sc2/src/uqm/uqmdebug.c
trunk/sc2/src/uqm/util.c
trunk/sc2/src/uqm.c
Removed Paths:
-------------
trunk/sc2/doc/devel/graphicslock
Modified: trunk/sc2/ChangeLog
===================================================================
--- trunk/sc2/ChangeLog 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/ChangeLog 2012-02-11 23:41:06 UTC (rev 3761)
@@ -1,4 +1,5 @@
Changes towards version 0.8:
+- Removed GraphicsLock and made comm callbacks queued - Alex
- Split debug key function into sync and async parts, paving the way
for GraphicsLock removal - Alex
- PageUp/PageDown now add/remove 10 fuel in the shipyard, from
Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp
===================================================================
--- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2012-02-11 23:41:06 UTC (rev 3761)
@@ -3654,10 +3654,6 @@
# End Source File
# Begin Source File
-SOURCE=..\..\doc\devel\graphicslock
-# End Source File
-# Begin Source File
-
SOURCE=..\..\doc\devel\input
# End Source File
# Begin Source File
Deleted: trunk/sc2/doc/devel/graphicslock
===================================================================
--- trunk/sc2/doc/devel/graphicslock 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/doc/devel/graphicslock 2012-02-11 23:41:06 UTC (rev 3761)
@@ -1,104 +0,0 @@
-HOW TO NOT GET HOSED BY DOUBLE-LOCK/UNLOCKS WITH GraphicsLock
-
-For the kinds of modifications you're likely to be doing, there only a
-few functions that you must take care to ensure that you hold
-GraphicsLock before calling. There are also some general guidelines.
-
-GENERAL GUIDELINES
-
-- Don't hold the GraphicsLock in Generate* functions.
-
-- Always hold it while doing ship operations - they're all only called
- by RedrawQueue. (preprocess, postprocess, etc.)
-
-- On ConcludeTask, you must not be holding *anything* or you could
- cause a deadlock if the thread you're waiting to conclude needs
- whatever lock you hold before it can safely exit. It is
- acceptable to hold the GraphicsLock when merely calling
- Task_SetState.
-
-Specific Guidelines:
-
-Always hold the GraphicsLock when calling...
-
-- SetFlashRect in sis.c; this changes which part of the screen is
- flashing. Very common.
-
-- RedrawQueue in process.c; this is for updating all the the graphics
- for ship animations.
-
-- GetMeleeStarShip in pickmele.c. That this is extern at all is
- probably a sign of lousy code organization.
-
-- DoMenuOptions in hyper.c; this is a consequence of being called from
- a ship operation when in hyperspace, which means that it must assume
- that it's called with the GraphicsLock held.
-
-- DoDiscoveryReport in planets/report.c; this is called by the
- Generate* functions, which always start out not holding the Lock.
-
-- ClearSISRect and DeltaSISGauges in sis.c; you might call these if
- working on code that modifies fuel or crew somehow.
-
-THE GORY DETAILS
-
-[functionname] means that the function is static and demands lockedness.
-<functionname> means that the function is static and demands unlockedness.
-*functionname* means that the function is extern and demands lockedness
-(functionname) means that the function is extern and demands unlockedness.
-
-This information is incomplete, and the result of a fairly informal
-hand-analysis of the code. In the case of extern-requires-lock,
-context and calling sites have been tracked so that all such functions
-are reached.
-
-battle.c: (Battle)
-border.c: (DrawSISFrame)
-build.c: (ActivateStarShip)
-clock.c: (clock_task_func)
-comm.c: (ambient_anim_task) [SpewPhrases] (AlienTalkSegue)
- <DoCommunication> [HailAlien] (InitCommunication)
-confirm.c: (DoConfirmExit)
-credits.c: (Credits) (OutTakes)
-encount.c: <DoSelectAction> (InitEncounter) [DrawFadeText]
- (UninitEncounter) (EncounterBattle)
-fmv.c: (Introduction)
-gameopt.c: <FeedbackSetting> <FeedbackQuit> <DrawDescriptionString>
- <DoNaming> <DoSettings> <DoQuitMenu> [ShowSummary]
- <DoPickGame> <PickGame>
-hyper.c: *LoadHyperspace* *FreeHyperspace* *DoMenuOptions*
-init.c: *InitShips* *UninitShips*
-melee.c: [DrawPickFrame] (flash_selection_func) <DrawMeleeShipStrings>
- <DoLoadTeam> <DoSaveTeam> <DoEdit> <DoPickShip>
- <FreeMeleeInfo> <DoMelee>
-menu.c: (DrawMenuStateStrings)
-outfit.c: <DoInstallModule> (ChangeFuelQuantity) (DoOutfit)
-pickmele.c: *GetMeleeStarShip*
-pickship.c: <DoPickBattleShip> [GetArmadaStarShip]
-process.c: *RedrawQueue*
-restart.c: <DrawRestartMenu> <DoRestart> (StartGame)
-save.c: (SaveProblem)
-ship.c: *ship_preprocess*
-shipyard.c: (hangar_anim_func) <DrawRaceStrings> <ShowCombatShip>
- [CrewTransaction] <DoModifyShips> <DrawBluePrint>
- (DoShipyard)
-sis.c: *ClearSISRect* *DeltaSISGauges* (flash_rect_func)
- *SetFlashRect*
-starbase.c: (rotate_starbase) (DoStarBase)
-starcon.c: (arilou_gate_task) (Starcon2Main)
-utils.c: (PauseGame)
-cargo.c: (DrawCargoStrings) <DoDiscardCargo> (Cargo)
-devices.c: <DrawDevices> <DoManipulateDevices> (Devices)
-lander.c: <ScrollPlanetSide> [AnimateLaunch] <InitPlanetSide>
- <ReturnToOrbit> (PlanetSide) (InitLander)
-planets.c: (LoadPlanet) (FreePlanet)
-plangen.c: (rotate_planet_task)
-pstarmap.c: (flash_cursor_func) (DrawStarMap) [EraseCursor]
- <DoMoveCursor> [DoStarMap] (DoFlagshipCommands)
-report.c: [MakeReport] *DoDiscoveryReport*
-roster.c: (flash_ship_task) <DoModifyRoster>
-scan.c: <EraseCoarseScan> <PrintCoarseScanPC> <PrintCoarseScan3DO>
- <SetPlanetLoc> (flash_planet_loc_func) <PickPlanetSide>
- <DoScan> (ScanSystem)
-solarsys.c: <FreeSolarSys> (IPtask_func) <DrawInnerSystem>
- (ChangeSolarSys) <InitSolarSys>
Modified: trunk/sc2/doc/devel/threads
===================================================================
--- trunk/sc2/doc/devel/threads 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/doc/devel/threads 2012-02-11 23:41:06 UTC (rev 3761)
@@ -97,10 +97,7 @@
sleep if the mutex is already locked, and awaken once the mutex
becomes available. A Mutex must be unlocked by the same thread that
locked it, and a thread must never lock a mutex it has already locked
-(without unlocking it first). The most important Mutex in the program
-the GraphicsLock. Code in UQM that does things like change the
-screen's clipping rectangle always grabs the GraphicsLock first, to
-ensure that the screen doesn't go crazy.
+(without unlocking it first).
API:
Mutex CreateMutex (const char *name, DWORD syncClass);
Modified: trunk/sc2/src/libs/callback/callback.c
===================================================================
--- trunk/sc2/src/libs/callback/callback.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/libs/callback/callback.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -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 **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,8 +64,16 @@
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.
CallbackID
Callback_add(CallbackFunction callback, CallbackArg arg) {
Modified: trunk/sc2/src/libs/callback/callback.h
===================================================================
--- trunk/sc2/src/libs/callback/callback.h 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/libs/callback/callback.h 2012-02-11 23:41:06 UTC (rev 3761)
@@ -33,6 +33,7 @@
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);
Modified: trunk/sc2/src/libs/graphics/dcqueue.c
===================================================================
--- trunk/sc2/src/libs/graphics/dcqueue.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/libs/graphics/dcqueue.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -216,6 +216,22 @@
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 @@
return;
}
+ checkExclusiveThread ();
+
if (DrawCommand->Type <= TFB_DRAWCOMMANDTYPE_COPYTOIMAGE
&& _CurFramePtr->Type == SCREEN_DRAWABLE)
{
Modified: trunk/sc2/src/libs/sound/trackint.h
===================================================================
--- trunk/sc2/src/libs/sound/trackint.h 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/libs/sound/trackint.h 2012-02-11 23:41:06 UTC (rev 3761)
@@ -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 @@
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;
};
Modified: trunk/sc2/src/libs/sound/trackplayer.c
===================================================================
--- trunk/sc2/src/libs/sound/trackplayer.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/libs/sound/trackplayer.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -199,7 +199,8 @@
DoTrackTag (TFB_SoundChunk *chunk)
{
if (chunk->callback)
- chunk->callback ();
+ Callback_add(chunk->callback, 0);
+
cur_sub_chunk = chunk;
}
@@ -421,7 +422,7 @@
// 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;
Modified: trunk/sc2/src/libs/sound/trackplayer.h
===================================================================
--- trunk/sc2/src/libs/sound/trackplayer.h 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/libs/sound/trackplayer.h 2012-02-11 23:41:06 UTC (rev 3761)
@@ -20,9 +20,8 @@
#define TRACKPLAYER_H
#include "libs/compiler.h"
+#include "libs/callback.h"
-typedef void (*TFB_TrackCB) (void);
-
#define ACCEL_SCROLL_SPEED 300
extern void PlayTrack (void);
@@ -37,7 +36,7 @@
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);
Modified: trunk/sc2/src/libs/video/video.c
===================================================================
--- trunk/sc2/src/libs/video/video.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/libs/video/video.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -127,7 +127,6 @@
_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 @@
{
ret = NO_FMV;
}
- UnlockMutex (GraphicsLock);
return ret;
}
Modified: trunk/sc2/src/libs/video/vidintrn.h
===================================================================
--- trunk/sc2/src/libs/video/vidintrn.h 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/libs/video/vidintrn.h 2012-02-11 23:41:06 UTC (rev 3761)
@@ -38,10 +38,4 @@
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
Modified: trunk/sc2/src/libs/video/vidplayer.c
===================================================================
--- trunk/sc2/src/libs/video/vidplayer.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/libs/video/vidplayer.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -143,14 +143,12 @@
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 @@
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)
Modified: trunk/sc2/src/uqm/battle.c
===================================================================
--- trunk/sc2/src/uqm/battle.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/battle.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -302,7 +302,6 @@
}
#endif
- LockMutex (GraphicsLock);
if (bs->first_time)
{
r.corner.x = SIS_ORG_X;
@@ -325,7 +324,6 @@
ScreenTransition (3, &r);
}
UnbatchGraphics ();
- UnlockMutex (GraphicsLock);
if ((!(GLOBAL (CurrentActivity) & IN_BATTLE)) ||
(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
@@ -399,7 +397,6 @@
{
SIZE num_ships;
- LockMutex (GraphicsLock);
#if !(DEMO_MODE || CREATE_JOURNAL)
if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE) {
@@ -469,9 +466,7 @@
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 @@
// 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 @@
UninitShips ();
FreeBattleSong ();
- UnlockMutex (GraphicsLock);
return (BOOLEAN) (num_ships < 0);
}
Modified: trunk/sc2/src/uqm/battle.h
===================================================================
--- trunk/sc2/src/uqm/battle.h 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/battle.h 2012-02-11 23:41:06 UTC (rev 3761)
@@ -31,8 +31,7 @@
#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 {
Modified: trunk/sc2/src/uqm/build.c
===================================================================
--- trunk/sc2/src/uqm/build.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/build.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -144,9 +144,7 @@
InsertQueue (&GLOBAL (built_ship_q), hStarShip, hOldShip);
}
- LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
- UnlockMutex (GraphicsLock);
return i;
}
@@ -389,9 +387,7 @@
if (count > 0)
{
// Update the display.
- LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
- UnlockMutex (GraphicsLock);
}
return count;
Modified: trunk/sc2/src/uqm/clock.c
===================================================================
--- trunk/sc2/src/uqm/clock.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/clock.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -276,7 +276,6 @@
return (0);
}
-// This function must be called with GraphicsLock held.
void
GameClockTick (void)
{
@@ -299,7 +298,6 @@
UnlockMutex (clock_mutex);
}
-// This function must be called with GraphicsLock held.
void
MoveGameClockDays (COUNT days)
{
Modified: trunk/sc2/src/uqm/cnctdlg.c
===================================================================
--- trunk/sc2/src/uqm/cnctdlg.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/cnctdlg.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -531,14 +531,12 @@
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
Modified: trunk/sc2/src/uqm/comm/comandr/comandr.c
===================================================================
--- trunk/sc2/src/uqm/comm/comandr/comandr.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/comm/comandr/comandr.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -227,10 +227,8 @@
{
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 @@
{
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 @@
{
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 @@
{
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 @@
{
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 @@
{
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 @@
NPCPhrase (FUEL_UP1);
AlienTalkSegue (1);
- LockMutex (GraphicsLock);
CommData.AlienAmbientArray[2].AnimFlags |= ANIM_DISABLED;
- UnlockMutex (GraphicsLock);
XFormColorMap (GetColorMapAddress (
SetAbsColorMapIndex (CommData.AlienColorMap, 0)
Modified: trunk/sc2/src/uqm/comm/druuge/druugec.c
===================================================================
--- trunk/sc2/src/uqm/comm/druuge/druugec.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/comm/druuge/druugec.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -244,9 +244,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);
Modified: trunk/sc2/src/uqm/comm/melnorm/melnorm.c
===================================================================
--- trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/comm/melnorm/melnorm.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -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 @@
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 @@
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 @@
if (total == 0)
{
NPCPhrase (CHARITY);
- LockMutex (GraphicsLock);
DeltaSISGauges (0, fuel_required, 0);
- UnlockMutex (GraphicsLock);
return (FALSE);
}
else
@@ -891,9 +883,7 @@
{
Credit += delta_credit;
SetAvailableCredits (Credit);
- LockMutex (GraphicsLock);
DrawStatusMessage (NULL);
- UnlockMutex (GraphicsLock);
return true;
}
@@ -1045,14 +1035,12 @@
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 @@
} 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 @@
static void
post_melnorme_enc (void)
{
- LockMutex (GraphicsLock);
if (prevMsgMode != SMM_UNDEFINED)
SetStatusMessageMode (prevMsgMode);
DrawStatusMessage (NULL);
- UnlockMutex (GraphicsLock);
}
LOCDATA*
Modified: trunk/sc2/src/uqm/comm/starbas/starbas.c
===================================================================
--- trunk/sc2/src/uqm/comm/starbas/starbas.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/comm/starbas/starbas.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -1656,9 +1656,7 @@
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 @@
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 @@
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 @@
}
SleepThread (ONE_SECOND / 2);
- LockMutex (GraphicsLock);
ClearSISRect (DRAW_SIS_DISPLAY);
- UnlockMutex (GraphicsLock);
// DrawStorageBays (FALSE);
if (total < 1000)
Modified: trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c
===================================================================
--- trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -118,15 +118,12 @@
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 @@
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 @@
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);
}
Modified: trunk/sc2/src/uqm/comm.c
===================================================================
--- trunk/sc2/src/uqm/comm.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/comm.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -632,13 +632,11 @@
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 @@
static void
runCommAnimFrame (void)
{
- LockMutex (GraphicsLock);
UpdateCommGraphics ();
- UnlockMutex (GraphicsLock);
SleepThread (COMM_ANIM_RATE);
}
@@ -764,13 +760,11 @@
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 @@
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 @@
font_DrawText (&mt);
}
- UnlockMutex (GraphicsLock);
pSS->PrintNext = FALSE;
}
@@ -934,9 +926,7 @@
&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 @@
{
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 @@
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 @@
if (!(GLOBAL (CurrentActivity) & CHECK_ABORT))
{
- LockMutex (GraphicsLock);
RefreshResponses (pES);
- UnlockMutex (GraphicsLock);
FadeMusic (FOREGROUND_VOL, ONE_SECOND);
}
}
@@ -1029,7 +1009,6 @@
{
COORD y;
- LockMutex (GraphicsLock);
BatchGraphics ();
add_text (-2,
&pES->response_list[pES->cur_response].response_text);
@@ -1049,12 +1028,9 @@
RefreshResponses (pES);
}
UnbatchGraphics ();
- UnlockMutex (GraphicsLock);
}
- LockMutex (GraphicsLock);
UpdateCommGraphics ();
- UnlockMutex (GraphicsLock);
SleepThreadUntil (pES->NextTime);
pES->NextTime = GetTimeCounter () + COMM_ANIM_RATE;
@@ -1094,9 +1070,7 @@
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 @@
return TRUE;
}
- LockMutex (GraphicsLock);
SetContext (SpaceContext);
DestroyContext (AnimContext);
AnimContext = NULL;
- UnlockMutex (GraphicsLock);
FlushColorXForms ();
ClearSubtitles ();
@@ -1228,7 +1200,6 @@
SubtitleText.baseline = CommData.AlienTextBaseline;
SubtitleText.align = CommData.AlienTextAlign;
- LockMutex (GraphicsLock);
// init subtitle cache context
TextCacheContext = CreateContext ("TextCacheContext");
@@ -1293,7 +1264,6 @@
DrawSISComWindow ();
}
- UnlockMutex (GraphicsLock);
LastActivity |= CHECK_LOAD; /* prevent spurious input */
(*CommData.init_encounter_func) ();
@@ -1302,10 +1272,8 @@
(*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 @@
return 0;
#endif
- LockMutex (GraphicsLock);
if (LastActivity & CHECK_LOAD)
{
@@ -1369,7 +1336,6 @@
}
}
- UnlockMutex (GraphicsLock);
if (which_comm == URQUAN_DRONE_CONVERSATION)
{
Modified: trunk/sc2/src/uqm/commglue.c
===================================================================
--- trunk/sc2/src/uqm/commglue.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/commglue.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -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;
Modified: trunk/sc2/src/uqm/commglue.h
===================================================================
--- trunk/sc2/src/uqm/commglue.h 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/commglue.h 2012-02-11 23:41:06 UTC (rev 3761)
@@ -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 @@
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);
Modified: trunk/sc2/src/uqm/confirm.c
===================================================================
--- trunk/sc2/src/uqm/confirm.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/confirm.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -85,7 +85,6 @@
PauseFlash ();
- LockMutex (GraphicsLock);
{
RECT r;
STAMP s;
@@ -160,7 +159,6 @@
SetContextClipRect (&oldRect);
SetContext (oldContext);
}
- UnlockMutex (GraphicsLock);
ContinueFlash ();
@@ -217,7 +215,6 @@
label.lines = lines;
PauseFlash ();
- LockMutex (GraphicsLock);
oldContext = SetContext (ScreenContext);
GetContextClipRect (&oldRect);
@@ -246,7 +243,6 @@
DestroyDrawable (ReleaseDrawable (s.frame));
SetContextClipRect (&oldRect);
SetContext (oldContext);
- UnlockMutex (GraphicsLock);
ContinueFlash ();
SetMenuSounds (s0, s1);
StringBank_Free (bank);
Modified: trunk/sc2/src/uqm/controls.h
===================================================================
--- trunk/sc2/src/uqm/controls.h 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/controls.h 2012-02-11 23:41:06 UTC (rev 3761)
@@ -119,9 +119,6 @@
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);
Modified: trunk/sc2/src/uqm/credits.c
===================================================================
--- trunk/sc2/src/uqm/credits.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/credits.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -240,7 +240,6 @@
t.pStr = " ";
t.CharCount = 1;
- LockMutex (GraphicsLock);
OldContext = SetContext (TempContext);
// get font dimensions
@@ -312,7 +311,6 @@
SetContextFGFrame (OldFrame);
SetContext (OldContext);
- UnlockMutex (GraphicsLock);
return f;
}
@@ -331,7 +329,6 @@
STAMP s;
int i;
- LockMutex (GraphicsLock);
oldContext = SetContext (targetContext);
// draw background
s.origin.x = 0;
@@ -358,7 +355,6 @@
}
SetContext (oldContext);
- UnlockMutex (GraphicsLock);
}
static void
@@ -373,7 +369,6 @@
LocalContext = CreateContext ("Credits.LocalContext");
DrawContext = CreateContext ("Credits.DrawContext");
- LockMutex (GraphicsLock);
targetFrame = GetContextFGFrame ();
GetContextClipRect (&ctxRect);
CreditsExtent = ctxRect.extent;
@@ -402,7 +397,6 @@
SetContextFGFrame (targetFrame);
SetContext (oldContext);
- UnlockMutex (GraphicsLock);
// Prepare the first screen frame
RenderCreditsScreen (LocalContext);
@@ -493,12 +487,10 @@
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 @@
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 @@
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 @@
FadeMusic (0, ONE_SECOND / 2);
UninitCredits ();
- LockMutex (GraphicsLock);
SetContext (ScreenContext);
SleepThreadUntil (FadeScreen (FadeAllToBlack, ONE_SECOND / 2));
FlushColorXForms ();
- UnlockMutex (GraphicsLock);
if (hMusic)
{
Modified: trunk/sc2/src/uqm/encount.c
===================================================================
--- trunk/sc2/src/uqm/encount.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/encount.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -78,9 +78,7 @@
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 @@
extern FRAME planet[];
MUSIC_REF MR;
- LockMutex (GraphicsLock);
SetContext (SpaceContext);
SetContextFont (TinyFont);
@@ -278,11 +275,9 @@
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 @@
DestroyDrawable (ReleaseDrawable (SegueFrame));
ScreenTransition (3, NULL);
- UnlockMutex (GraphicsLock);
{
MENU_STATE MenuState;
@@ -403,15 +397,11 @@
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 @@
{
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 @@
{
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 @@
ships_killed = 0;
- LockMutex (GraphicsLock);
free_gravity_well ();
if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
@@ -702,10 +687,8 @@
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 @@
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 @@
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 @@
}
}
ExitUninitEncounter:
- UnlockMutex (GraphicsLock);
return (ships_killed);
}
@@ -799,7 +777,6 @@
extern UWORD nth_frame;
InputContext *savedPlayerInput = NULL;
- LockMutex (GraphicsLock);
SET_GAME_STATE (BATTLE_SEGUE, 1);
@@ -838,9 +815,7 @@
GameSounds = CaptureSound (LoadSound (GAME_SOUNDS));
- UnlockMutex (GraphicsLock);
Battle (NULL);
- LockMutex (GraphicsLock);
DestroySound (ReleaseSound (GameSounds));
GameSounds = 0;
@@ -864,6 +839,5 @@
GLOBAL (CurrentActivity) = OldActivity;
- UnlockMutex (GraphicsLock);
}
Modified: trunk/sc2/src/uqm/flash.c
===================================================================
--- trunk/sc2/src/uqm/flash.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/flash.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -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 @@
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 @@
// 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_blendFraction (context, numer, denom, &blendedNumer, &blendedDenom);
- LockMutex (GraphicsLock);
oldGfxContext = SetContext (workGfxContext);
SetContextFGFrame (dest);
@@ -650,7 +645,6 @@
}
SetContext (oldGfxContext);
- UnlockMutex (GraphicsLock);
}
// Prepare an entry in the cache.
@@ -686,7 +680,6 @@
CONTEXT oldGfxContext;
STAMP stamp;
- LockMutex (GraphicsLock);
oldGfxContext = SetContext (context->gfxContext);
stamp.origin = context->rect.corner;
@@ -694,7 +687,6 @@
DrawStamp(&stamp);
SetContext (oldGfxContext);
- UnlockMutex (GraphicsLock);
}
static void
Modified: trunk/sc2/src/uqm/fmv.c
===================================================================
--- trunk/sc2/src/uqm/fmv.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/fmv.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -79,13 +79,11 @@
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);
Modified: trunk/sc2/src/uqm/gameopt.c
===================================================================
--- trunk/sc2/src/uqm/gameopt.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/gameopt.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -167,9 +167,7 @@
break;
}
- LockMutex (GraphicsLock);
DrawStatusMessage (buf);
- UnlockMutex (GraphicsLock);
}
#define DDSHS_NORMAL 0
@@ -229,7 +227,6 @@
lf.align = ALIGN_CENTER;
}
- LockMutex (GraphicsLock);
SetContext (StatusContext);
SetContextFont (Font);
lf.pStr = Str;
@@ -253,14 +250,11 @@
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 @@
SetContextForeGroundColor (ForeGround);
font_DrawText (&lf);
- PostUpdateFlashRectLocked ();
+ PostUpdateFlashRect ();
}
- UnlockMutex (GraphicsLock);
return (TRUE);
}
@@ -325,15 +318,11 @@
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 @@
else
utf8StringCopy (buf, sizeof (buf), Setting);
- LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
- UnlockMutex (GraphicsLock);
DrawNameString (nameCaptain, buf, 0, DDSHS_NORMAL);
@@ -450,9 +437,7 @@
MenuState.InputFunc = DoSettings;
DoInput (&MenuState, FALSE);
- LockMutex (GraphicsLock);
DrawStatusMessage (NULL);
- UnlockMutex (GraphicsLock);
}
typedef struct
@@ -677,10 +662,8 @@
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 @@
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 @@
// 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 @@
// 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 @@
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 @@
FadeMusic (NORMAL_VOLUME, 0);
// draw the current savegame and fade in
- LockMutex (GraphicsLock);
SetTransitionSource (NULL);
BatchGraphics ();
@@ -1050,7 +1024,6 @@
ScreenTransition (3, &ctxRect);
UnbatchGraphics ();
}
- UnlockMutex (GraphicsLock);
SetMenuSounds (MENU_SOUND_ARROWS | MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN,
0);
@@ -1076,9 +1049,7 @@
// 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 @@
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 @@
{
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 @@
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));
}
Modified: trunk/sc2/src/uqm/hyper.c
===================================================================
--- trunk/sc2/src/uqm/hyper.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/hyper.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -1633,9 +1633,7 @@
if (!select)
return TRUE;
- LockMutex (GraphicsLock);
SetFlashRect (NULL);
- UnlockMutex (GraphicsLock);
switch (pMS->CurState)
{
@@ -1675,9 +1673,7 @@
pMS->CurState = NAVIGATION;
DrawMenuStateStrings (PM_STARMAP, pMS->CurState);
}
- LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
- UnlockMutex (GraphicsLock);
}
return TRUE;
@@ -1695,7 +1691,6 @@
OldContext = SetContext (SpaceContext);
OldColor = SetContextBackGroundColor (BLACK_COLOR);
- UnlockMutex (GraphicsLock);
memset (&MenuState, 0, sizeof (MenuState));
MenuState.InputFunc = DoHyperspaceMenu;
@@ -1703,14 +1698,11 @@
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 @@
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
ClearSISRect (CLEAR_SIS_RADAR);
- UnlockMutex (GraphicsLock);
WaitForNoInput (ONE_SECOND / 2, FALSE);
- LockMutex (GraphicsLock);
}
SetContextBackGroundColor (OldColor);
Modified: trunk/sc2/src/uqm/intro.c
===================================================================
--- trunk/sc2/src/uqm/intro.c 2012-02-06 17:43:46 UTC (rev 3760)
+++ trunk/sc2/src/uqm/intro.c 2012-02-11 23:41:06 UTC (rev 3761)
@@ -160,7 +160,6 @@
if (!pPIS->Batched)
{
pPIS->Batched = TRUE;
- LockMutex (GraphicsLock);
BatchGraphics ();
}
}
@@ -171,7 +170,6 @@
if (pPIS->Batched)
{
UnbatchGraphics ();
- UnlockMutex (GraphicsLock);
pPIS->Batched = FALSE;
if (bYield)
TaskSwitch ();
@@ -196,7 +194,6 @@
COUNT piece;
Color SisBack;
- LockMutex (GraphicsLock);
OldContext = SetContext (OffScreenContext);
SkelFrame = CaptureDrawable (LoadGraphic (SISSKEL_MASK_PMAP_ANIM));
@@ -264,7 +261,6 @@
SetContext (OldContext);
FlushGraphics ();
- UnlockMutex (GraphicsLock);
pPIS->SisFrame = SisFrame;
}
@@ -277,9 +273,7 @@
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 @@
/* 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 @@
*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 @@
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 @@
Present_UnbatchGraphics (pPIS, TRUE);
- LockMutex (GraphicsLock);
GetContextFontLeading (&leading);
- UnlockMutex (GraphicsLock);
switch (pPIS->TextVPos)
{
@@ -536,7 +518,6 @@
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 @@
ScreenTransition (3, &pPIS->tfade_r);
UnbatchGraphics ();
- UnlockMutex (GraphicsLock);
}
else if (strcmp (Opcode, "TFO") == 0)
{ /* text fade-out */
@@ -558,7 +538,6 @@
Present_UnbatchGraphics (pPIS, TRUE);
- LockMutex (GraphicsLock);
/* do transition */
SetTransitionSource (&pPIS->tfade_r);
BatchGraphics ();
@@ -567,7 +546,6 @@
pPIS->TextFadeColor, pPIS->TextEffect);
ScreenTransition (3, &pPIS->tfade_r);
UnbatchGraphics ();
- UnlockMutex (GraphicsLock);
}
else if (strcmp (Opcode, "SAVEBG") == 0)
{ /* save background */
@@ -652,15 +630,11 @@
}
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 @@
{ /* clear screen */
Present_UnbatchGraphics (pPIS, TRUE);
- LockMutex (GraphicsLock);
ClearDrawable ();
- UnlockMutex (GraphicsLock);
}
else if (strcmp (Opcode, "CALL") == 0)
{ /* call another script */
@@ -712,12 +684,8 @@
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 @@
pis.SlideShow = SetAbsStringTableIndex (pis.SlideShow, 0);
pis.OperIndex = 0;
- LockMutex ...
[truncated message content] |