Skip to content

Commit

Permalink
TONY: Remove unnecessary mainloop mutex.
Browse files Browse the repository at this point in the history
Also, all the related freeze functions/members.
  • Loading branch information
fuzzie committed Aug 28, 2012
1 parent 9ebbeda commit 3c986af
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 141 deletions.
2 changes: 0 additions & 2 deletions engines/tony/adv.h
Expand Up @@ -67,8 +67,6 @@ enum RMTonyAction {
uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start);
void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result);
void mainLinkGraphicTask(RMGfxTask *task);
void mainFreeze();
void mainUnfreeze();
void mainWaitFrame(CORO_PARAM);
void mainShowMouse();
void mainHideMouse();
Expand Down
56 changes: 2 additions & 54 deletions engines/tony/custom.cpp
Expand Up @@ -374,15 +374,12 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui

CORO_BEGIN_CODE(_ctx);

GLOBALS.Freeze();

GLOBALS._curChangedHotspot = 0;
if (bUseStartPos != 0)
GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]);
else
GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1));

GLOBALS.Unfreeze();
_ctx->h = mpalQueryDoAction(0, nLoc, 0);

// On Enter?
Expand Down Expand Up @@ -413,7 +410,6 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32

CORO_INVOKE_2(GLOBALS.UnloadLocation, false, NULL);
GLOBALS._tony->hide();
GLOBALS.Unfreeze();

for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS._bSkipIdle; _ctx->i++) {
_ctx->text.setInput(GLOBALS._input);
Expand Down Expand Up @@ -474,11 +470,9 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32)
}

DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) {
GLOBALS.Freeze();
GLOBALS.LoadLocation(GLOBALS._fullScreenMessageLoc, RMPoint(GLOBALS._fullScreenMessagePt._x, GLOBALS._fullScreenMessagePt._y), RMPoint(-1, -1));
if (!bNotEnableTony)
GLOBALS._tony->show();
GLOBALS.Unfreeze();

MCharResetCodes();
ReapplyChangedHotspot();
Expand Down Expand Up @@ -514,9 +508,8 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3

g_vm->stopMusic(4);

// On exit, unload and unfreeze
// On exit, unload
CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL);
GLOBALS.Unfreeze();

CORO_END_CODE;
}
Expand Down Expand Up @@ -557,9 +550,6 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint
GLOBALS.InitWipe(2);
}

GLOBALS.Unfreeze();


_ctx->h = mpalQueryDoAction(0, nLoc, 0);

if (!GLOBALS._bNoBullsEye) {
Expand Down Expand Up @@ -626,9 +616,7 @@ void TonyGenericTake1(CORO_PARAM, uint32 nDirection) {

CORO_BEGIN_CODE(_ctx);

GLOBALS.Freeze();
GLOBALS._tony->take(nDirection, 0);
GLOBALS.Unfreeze();

if (!GLOBALS._bSkipIdle)
CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern);
Expand All @@ -642,16 +630,12 @@ void TonyGenericTake2(CORO_PARAM, uint32 nDirection) {

CORO_BEGIN_CODE(_ctx);

GLOBALS.Freeze();
GLOBALS._tony->take(nDirection, 1);
GLOBALS.Unfreeze();

if (!GLOBALS._bSkipIdle)
CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern);

GLOBALS.Freeze();
GLOBALS._tony->take(nDirection, 2);
GLOBALS.Unfreeze();

CORO_END_CODE;
}
Expand All @@ -662,9 +646,7 @@ void TonyGenericPut1(CORO_PARAM, uint32 nDirection) {

CORO_BEGIN_CODE(_ctx);

GLOBALS.Freeze();
GLOBALS._tony->put(nDirection, 0);
GLOBALS.Unfreeze();

if (!GLOBALS._bSkipIdle)
CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern);
Expand All @@ -678,16 +660,12 @@ void TonyGenericPut2(CORO_PARAM, uint32 nDirection) {

CORO_BEGIN_CODE(_ctx);

GLOBALS.Freeze();
GLOBALS._tony->put(nDirection, 1);
GLOBALS.Unfreeze();

if (!GLOBALS._bSkipIdle)
CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern);

GLOBALS.Freeze();
GLOBALS._tony->put(nDirection, 2);
GLOBALS.Unfreeze();

CORO_END_CODE;
}
Expand Down Expand Up @@ -1250,10 +1228,8 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32

CORO_INVOKE_0(GLOBALS.WaitFrame);

GLOBALS.Freeze();
GLOBALS._loc->setScrollPosition(_ctx->pt);
GLOBALS._tony->setScrollPosition(_ctx->pt);
GLOBALS.Unfreeze();
}

CORO_END_CODE;
Expand Down Expand Up @@ -1315,10 +1291,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui

CORO_INVOKE_0(GLOBALS.WaitFrame);

GLOBALS.Freeze();
GLOBALS._loc->setScrollPosition(_ctx->pt);
GLOBALS._tony->setScrollPosition(_ctx->pt);
GLOBALS.Unfreeze();

}

Expand All @@ -1336,10 +1310,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui
_ctx->pt._y = _ctx->startpt._y - _ctx->dimy;
}

GLOBALS.Freeze();
GLOBALS._loc->setScrollPosition(_ctx->pt);
GLOBALS._tony->setScrollPosition(_ctx->pt);
GLOBALS.Unfreeze();

CORO_END_CODE;
}
Expand Down Expand Up @@ -1392,10 +1364,8 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32,
while (g_vm->getTime() < _ctx->curTime + nScosse) {
CORO_INVOKE_0(GLOBALS.WaitFrame);

GLOBALS.Freeze();
GLOBALS._loc->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry));
GLOBALS._tony->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry));
GLOBALS.Unfreeze();

_ctx->i = g_vm->_randomSource.getRandomNumber(2);

Expand All @@ -1405,10 +1375,8 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32,
_ctx->diry = -_ctx->diry;
}

GLOBALS.Freeze();
GLOBALS._loc->setFixedScroll(RMPoint(0, 0));
GLOBALS._tony->setFixedScroll(RMPoint(0, 0));
GLOBALS.Unfreeze();

CORO_END_CODE;
}
Expand Down Expand Up @@ -1471,16 +1439,12 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess
_ctx->pt = GLOBALS._character[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition();

if (GLOBALS._character[nChar]._startTalkPattern != 0) {
GLOBALS.Freeze();
GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._startTalkPattern);
GLOBALS.Unfreeze();

CORO_INVOKE_0(GLOBALS._character[nChar]._item->waitForEndPattern);
}

GLOBALS.Freeze();
GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._talkPattern);
GLOBALS.Unfreeze();

_ctx->curVoc = SearchVoiceHeader(0, dwMessage);
_ctx->voice = NULL;
Expand Down Expand Up @@ -1551,15 +1515,11 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess
}

if (GLOBALS._character[nChar]._endTalkPattern != 0) {
GLOBALS.Freeze();
GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._endTalkPattern);
GLOBALS.Unfreeze();
CORO_INVOKE_0(GLOBALS._character[nChar]._item->waitForEndPattern);
}

GLOBALS.Freeze();
GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._standPattern);
GLOBALS.Unfreeze();
delete _ctx->msg;

CORO_END_CODE;
Expand Down Expand Up @@ -1845,9 +1805,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg
_ctx->pt = GLOBALS._character[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition();

if (GLOBALS._character[nPers]._startTalkPattern != 0) {
GLOBALS.Freeze();
GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._startTalkPattern);
GLOBALS.Unfreeze();
CORO_INVOKE_0(GLOBALS._character[nPers]._item->waitForEndPattern);
}

Expand Down Expand Up @@ -1925,9 +1883,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg
if (nPers != 0) {
if (!GLOBALS._isMChar[nPers]) {
if (GLOBALS._character[nPers]._endTalkPattern != 0) {
GLOBALS.Freeze();
GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._endTalkPattern);
GLOBALS.Unfreeze();
CORO_INVOKE_0(GLOBALS._character[nPers]._item->waitForEndPattern);
}

Expand Down Expand Up @@ -2023,9 +1979,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr

while (!(GLOBALS._input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.getSelection()) != -1))) {
CORO_INVOKE_0(GLOBALS.WaitFrame);
GLOBALS.Freeze();
CORO_INVOKE_1(_ctx->dc.doFrame, GLOBALS._input->mousePos());
GLOBALS.Unfreeze();
}

// Hide the pointer
Expand Down Expand Up @@ -2298,7 +2252,7 @@ DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uin
}

DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) {
GLOBALS._bPatIrqFreeze = bStatus;
// Unused in ScummVM.
}

DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, uint32) {
Expand All @@ -2307,9 +2261,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, ui

CORO_BEGIN_CODE(_ctx);

GLOBALS.Freeze();
CORO_INVOKE_0(g_vm->openInitLoadMenu);
GLOBALS.Unfreeze();

CORO_END_CODE;
}
Expand All @@ -2320,9 +2272,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uin

CORO_BEGIN_CODE(_ctx);

GLOBALS.Freeze();
CORO_INVOKE_0(g_vm->openInitOptions);
GLOBALS.Unfreeze();

CORO_END_CODE;
}
Expand Down Expand Up @@ -2575,8 +2525,6 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation
GLOBALS.LoadLocation = mainLoadLocation;
GLOBALS.UnloadLocation = mainUnloadLocation;
GLOBALS.LinkGraphicTask = mainLinkGraphicTask;
GLOBALS.Freeze = mainFreeze;
GLOBALS.Unfreeze = mainUnfreeze;
GLOBALS.WaitFrame = mainWaitFrame;
GLOBALS.PlayMusic = mainPlayMusic;
GLOBALS.InitWipe = mainInitWipe;
Expand Down
4 changes: 0 additions & 4 deletions engines/tony/font.cpp
Expand Up @@ -1072,10 +1072,8 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) {
_ctx->elaps = 0;
while (_ctx->elaps < 700) {
CORO_INVOKE_0(mainWaitFrame);
mainFreeze();
_ctx->elaps = g_vm->getTime() - _ctx->starttime;
_ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100;
mainUnfreeze();
}

_ptDrawPos._y = _ctx->destpt._y;
Expand Down Expand Up @@ -1116,10 +1114,8 @@ void RMDialogChoice::hide(CORO_PARAM) {
_ctx->elaps = 0;
while (_ctx->elaps < 700) {
CORO_INVOKE_0(mainWaitFrame);
mainFreeze();
_ctx->elaps = g_vm->getTime() - _ctx->starttime;
_ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100;
mainUnfreeze();
}
}

Expand Down
8 changes: 0 additions & 8 deletions engines/tony/game.cpp
Expand Up @@ -59,14 +59,6 @@ void mainLinkGraphicTask(RMGfxTask *task) {
g_vm->getEngine()->linkGraphicTask(task);
}

void mainFreeze() {
g_vm->getEngine()->freeze();
}

void mainUnfreeze() {
g_vm->getEngine()->unfreeze();
}

void mainWaitFrame(CORO_PARAM) {
CoroScheduler.waitForSingleObject(coroParam, g_vm->_hEndOfFrame, CORO_INFINITE);
}
Expand Down

0 comments on commit 3c986af

Please sign in to comment.