diff options
Diffstat (limited to 'engines/tony/mpal/mpal.cpp')
-rw-r--r-- | engines/tony/mpal/mpal.cpp | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 8d83363c24..1a24c5a576 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -196,7 +196,6 @@ static int locGetOrderFromNum(uint32 nLoc) { return -1; } - /** * Find the index of a message within the messages array * @param nMsg Message number to search for @@ -233,7 +232,6 @@ static int itemGetOrderFromNum(uint32 nItem) { return -1; } - /** * Find the index of a script within the scripts array * @param nScript Script number to search for @@ -252,7 +250,6 @@ static int scriptGetOrderFromNum(uint32 nScript) { return -1; } - /** * Find the index of a dialog within the dialogs array * @param nDialog Dialog number to search for @@ -271,7 +268,6 @@ static int dialogGetOrderFromNum(uint32 nDialog) { return -1; } - /** * Duplicates a message * @param nMsgOrd Index of the message inside the messages array @@ -302,7 +298,6 @@ static char *DuplicateMessage(uint32 nMsgOrd) { return clonemsg; } - /** * Duplicate a sentence of a dialog * @param nDlgOrd Index of the dialog in the dialogs array @@ -340,7 +335,6 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { return NULL; } - /** * Load a resource from the MPR file * @@ -461,16 +455,16 @@ static LpItem getItemData(uint32 nOrdItem) { dat = (char *)globalLock(hDat); if (dat[0] == 'D' && dat[1] == 'A' && dat[2] == 'T') { - int i = dat[3]; // For version 1.0!! + int i = dat[3]; // For version 1.0!! dat += 4; - if (i >= 0x10) { // From 1.0, there's a destination point for each object + if (i >= 0x10) { // From 1.0, there's a destination point for each object ret->_destX = (int16)READ_LE_UINT16(dat); ret->_destY = (int16)READ_LE_UINT16(dat + 2); dat += 4; } - if (i >= 0x11) { // From 1.1, there's animation speed + if (i >= 0x11) { // From 1.1, there's animation speed ret->_speed = READ_LE_UINT16(dat); dat += 2; } else @@ -511,7 +505,7 @@ static LpItem getItemData(uint32 nOrdItem) { for (int i = 1; i < ret->_numpattern; i++) { for (int j = 0; j < patlength[i]; j++) ret->_pattern[i][j] = dat[j]; - ret->_pattern[i][(int)patlength[i]] = 255; // Terminate pattern + ret->_pattern[i][(int)patlength[i]] = 255; // Terminate pattern dat += patlength[i]; } @@ -538,7 +532,6 @@ static LpItem getItemData(uint32 nOrdItem) { return ret; } - /** * Thread that calls a custom function. It is used in scripts, so that each script * function is executed without delaying the others. @@ -562,7 +555,6 @@ void CustomThread(CORO_PARAM, const void *param) { CORO_END_CODE; } - /** * Main process for running a script. * @@ -587,7 +579,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->dwStartTime = g_vm->getTime(); _ctx->numHandles = 0; -// debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n", s->_nMoments); + //debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n", s->_nMoments); for (_ctx->i = 0; _ctx->i < s->_nMoments; _ctx->i++) { // Sleep for the required time if (s->_moment[_ctx->i]._dwTime == -1) { @@ -596,7 +588,7 @@ void ScriptThread(CORO_PARAM, const void *param) { } else { _ctx->dwCurTime = g_vm->getTime(); if (_ctx->dwCurTime < _ctx->dwStartTime + (s->_moment[_ctx->i]._dwTime * 100)) { - // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime + (s->_moment[_ctx->i]._dwTime*100) - _ctx->dwCurTime); + //debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime + (s->_moment[_ctx->i]._dwTime*100) - _ctx->dwCurTime); CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime + (s->_moment[_ctx->i]._dwTime * 100) - _ctx->dwCurTime); } } @@ -655,7 +647,6 @@ void ScriptThread(CORO_PARAM, const void *param) { CORO_END_CODE; } - /** * Thread that performs an action on an item. the thread always executes the action, * so it should create a new item in which the action is the one required. @@ -752,11 +743,9 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_INVOKE_1(g_vm->loadState, _ctx->slotNumber); } - CORO_END_CODE; } - /** * Polls one location (starting point of a process) * @@ -764,14 +753,14 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { */ void LocationPollThread(CORO_PARAM, const void *param) { typedef struct { - uint32 _nItem, _nAction; + uint32 _nItem, _nAction; - uint16 _wTime; - byte _perc; + uint16 _wTime; + byte _perc; MpalHandle _when; - byte _nCmds; - uint16 _cmdNum[MAX_COMMANDS_PER_ACTION]; - uint32 _dwLastTime; + byte _nCmds; + uint16 _cmdNum[MAX_COMMANDS_PER_ACTION]; + uint32 _dwLastTime; } MYACTION; typedef struct { @@ -862,7 +851,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { return; } - // We have established that there is at least one item that contains idle actions. // Now we created the mirrored copies of the idle actions. _ctx->myActions = (MYACTION *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); @@ -905,7 +893,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { // We don't need the item list anymore globalDestroy(_ctx->il); - // Here's the main loop while (1) { // Searching for idle actions requiring time to execute @@ -944,7 +931,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->curTime >= _ctx->myActions[_ctx->k]._dwLastTime + _ctx->myActions[_ctx->k]._wTime) { _ctx->myActions[_ctx->k]._dwLastTime += _ctx->myActions[_ctx->k]._wTime; - // It's time to check to see if fortune is on the side of the idle action + // It's time to check to see if fortune is on the side of the idle action byte randomVal = (byte)g_vm->_randomSource.getRandomNumber(99); if (randomVal < _ctx->myActions[_ctx->k]._perc) { // Check if there is an action running on the item @@ -1016,7 +1003,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { } } - // Set idle skip on CORO_INVOKE_4(GLOBALS._lplpFunctions[200], 0, 0, 0, 0); @@ -1038,7 +1024,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_END_CODE; } - /** * Wait for the end of the dialog execution thread, and then restore global * variables indicating that the dialogue has finished. @@ -1071,7 +1056,6 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { void doChoice(CORO_PARAM, uint32 nChoice); - /** * Executes a group of the current dialog. Can 'be the Starting point of a process. * @parm nGroup Number of the group to perform @@ -1149,7 +1133,6 @@ void GroupThread(CORO_PARAM, const void *param) { CORO_END_CODE; } - /** * Make a choice in the current dialog. * @@ -1247,7 +1230,6 @@ void doChoice(CORO_PARAM, uint32 nChoice) { CORO_END_CODE; } - /** * Perform an action on a certain item. * @@ -1353,7 +1335,6 @@ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { return h; } - /** * Takes note of the selection chosen by the user, and warns the process that was running * the box that it can continue. @@ -1379,7 +1360,6 @@ bool doSelection(uint32 i, uint32 dwData) { return true; } - /** * @defgroup Exported functions */ @@ -1502,6 +1482,8 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, lzo1x_decompress((const byte *)cmpbuf, dwSizeComp, (byte *)GLOBALS._lpResources, (uint32 *)&nBytesRead); if (nBytesRead != (uint32)GLOBALS._nResources * 8) return false; + for (int i = 0; i < 2*GLOBALS._nResources; ++i) + GLOBALS._lpResources[i] = FROM_LE_32(GLOBALS._lpResources[i]); globalDestroy(cmpbuf); @@ -1884,7 +1866,6 @@ MpalHandle mpalQueryHANDLE(uint16 wQueryType, ...) { return hRet; } - /** * This is a general function to communicate with the library, to request information * about what is in the .MPC file @@ -2005,7 +1986,6 @@ bool mpalStartIdlePoll(int nLoc) { return false; } - /** * Stop processing the idle actions of the items on one location. * @@ -2063,7 +2043,6 @@ void mpalSaveState(byte *buf) { unlockVar(); } - /** * Load a save state from a buffer. * |