diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/tony/custom.cpp | 10 | ||||
-rw-r--r-- | engines/tony/font.cpp | 56 | ||||
-rw-r--r-- | engines/tony/mpal/expr.cpp | 64 | ||||
-rw-r--r-- | engines/tony/mpal/expr.h | 2 | ||||
-rw-r--r-- | engines/tony/mpal/loadmpc.cpp | 124 | ||||
-rw-r--r-- | engines/tony/mpal/mpal.cpp | 44 | ||||
-rw-r--r-- | engines/tony/mpal/mpaldll.h | 4 |
7 files changed, 166 insertions, 138 deletions
diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 0127494007..a6381e0937 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2073,16 +2073,6 @@ DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32 warning("TODO: Validate that the use of events in TakeOwnership/ReleaseOwnership match original"); } - - - - - - - - - - /* * Music * ----- diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 66f1ccdcd9..6b6778044d 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1430,8 +1430,8 @@ void RMFontCredits::Init(void) { * Metodi di RMFontObj \****************************************************************************/ -#define TOUPPER(a) ((a) >='a'&&(a)<='z'?(a)+'A'-'a':(a)) -#define TOLOWER(a) ((a) >='A'&&(a)<='Z'?(a)+'a'-'A':(a)) +#define TOUPPER(a) ((a) >= 'a' && (a) <= 'z' ? (a) + 'A' - 'a' : (a)) +#define TOLOWER(a) ((a) >= 'A' && (a) <= 'Z' ? (a) + 'a' - 'A' : (a)) void RMFontObj::SetBothCase(int nChar, int nNext, signed char spiazz) { l2Table[TOUPPER(nChar)][TOUPPER(nNext)] = spiazz; @@ -1849,7 +1849,8 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { j += font->StringLen(*p); if (j > (((aHorType == HLEFTPAR) && (i > 0)) ? maxLineLength - 25 : maxLineLength)) { j -= font->StringLen(*p, p[1]); - if (j > x) x = j; + if (j > x) + x = j; // Back to the first usable space // @@ -1858,13 +1859,15 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { // This workaround has the partial word broken up so it will still display // old_p = p; - while (*p != ' ' && *p != '-' && p > string) p--; + while (*p != ' ' && *p != '-' && p > string) + p--; if (p == string) p = old_p; // Check if there are any blanks to end - while (*p == ' ' && *p != '\0') p++; + while (*p == ' ' && *p != '\0') + p++; if (*p == '\0') break; p--; @@ -1875,7 +1878,8 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { p++; } - if (j > x) x = j; + if (j > x) + x = j; i++; numlines = i; @@ -1948,10 +1952,14 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { void RMText::ClipOnScreen(RMGfxPrimitive *prim) { // Don't let it go outside the screen - if (prim->Dst().x1 < 5) prim->Dst().x1 = 5; - if (prim->Dst().y1 < 5) prim->Dst().y1 = 5; - if (prim->Dst().x1 + m_dimx > 635) prim->Dst().x1 = 635 - m_dimx; - if (prim->Dst().y1 + m_dimy > 475) prim->Dst().y1 = 475 - m_dimy; + if (prim->Dst().x1 < 5) + prim->Dst().x1 = 5; + if (prim->Dst().y1 < 5) + prim->Dst().y1 = 5; + if (prim->Dst().x1 + m_dimx > 635) + prim->Dst().x1 = 635 - m_dimx; + if (prim->Dst().y1 + m_dimy > 475) + prim->Dst().y1 = 475 - m_dimy; } void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -2068,34 +2076,40 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { // Don't erase the background if (m_bSkipStatus) { - if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) + if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (GLOBALS.bCfgTimerizedText) { - if (!m_bForceNoTime) + if (!m_bForceNoTime) { if (_vm->GetTime() > (uint32)m_time + m_startTime) return; + } } + } - if (!m_bNoTab) + if (!m_bNoTab) { if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) return; + } - if (!m_bNoTab) - if (m_input) + if (!m_bNoTab) { + if (m_input) { if (m_input->MouseLeftClicked() || m_input->MouseRightClicked()) return; + } + } } // Erase the background - else { - if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) - if (!m_bForceNoTime) - if (_vm->GetTime() > (uint32)m_time + m_startTime) - return; + else if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { + if (!m_bForceNoTime) { + if (_vm->GetTime() > (uint32)m_time + m_startTime) + return; + } } // If time is forced - if (m_bForceTime) + if (m_bForceTime) { if (_vm->GetTime() > (uint32)m_time + m_startTime) return; + } if (hCustomSkip != CORO_INVALID_PID_VALUE) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip, 0, &_ctx->expired); diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index aaec74fb4c..ae6dfac482 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -43,37 +43,36 @@ namespace MPAL { * @defgroup Mathamatical operations */ -#define OP_MUL ((1<<4)|0) -#define OP_DIV ((1<<4)|1) -#define OP_MODULE ((1<<4)|2) -#define OP_ADD ((2<<4)|0) -#define OP_SUB ((2<<4)|1) -#define OP_SHL ((3<<4)|0) -#define OP_SHR ((3<<4)|1) -#define OP_MINOR ((4<<4)|0) -#define OP_MAJOR ((4<<4)|1) -#define OP_MINEQ ((4<<4)|2) -#define OP_MAJEQ ((4<<4)|3) -#define OP_EQUAL ((5<<4)|0) -#define OP_NOEQUAL ((5<<4)|1) -#define OP_BITAND ((6<<4)|0) -#define OP_BITXOR ((7<<4)|0) -#define OP_BITOR ((8<<4)|0) -#define OP_AND ((9<<4)|0) -#define OP_OR ((10<<4)|0) +#define OP_MUL ((1 << 4) | 0) +#define OP_DIV ((1 << 4) | 1) +#define OP_MODULE ((1 << 4) | 2) +#define OP_ADD ((2 << 4) | 0) +#define OP_SUB ((2 << 4) | 1) +#define OP_SHL ((3 << 4) | 0) +#define OP_SHR ((3 << 4) | 1) +#define OP_MINOR ((4 << 4) | 0) +#define OP_MAJOR ((4 << 4) | 1) +#define OP_MINEQ ((4 << 4) | 2) +#define OP_MAJEQ ((4 << 4) | 3) +#define OP_EQUAL ((5 << 4) | 0) +#define OP_NOEQUAL ((5 << 4) | 1) +#define OP_BITAND ((6 << 4) | 0) +#define OP_BITXOR ((7 << 4) | 0) +#define OP_BITOR ((8 << 4) | 0) +#define OP_AND ((9 << 4) | 0) +#define OP_OR ((10 << 4) | 0) /** * Object types that can be contained in an EXPRESSION structure */ enum ExprListTypes { - ELT_NUMBER = 1, - ELT_VAR = 2, - ELT_PARENTH = 3, + ELT_NUMBER = 1, + ELT_VAR = 2, + ELT_PARENTH = 3, ELT_PARENTH2 = 4 }; - /** * @defgroup Structures */ @@ -95,7 +94,7 @@ typedef struct { byte symbol; // Simbolo matematico (vedi #define OP_*) } EXPRESSION; -typedef EXPRESSION* LPEXPRESSION; +typedef EXPRESSION *LPEXPRESSION; /** @@ -186,13 +185,13 @@ static void Solve(LPEXPRESSION one, int num) { while (num > 1) { two=one + 1; if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { - two->val.num=Compute(one->val.num, two->val.num,one->symbol); + two->val.num = Compute(one->val.num, two->val.num,one->symbol); CopyMemory(one, two, (num - 1) * sizeof(EXPRESSION)); num--; } else { j = 1; three = two + 1; - while ((three->symbol != 0) && (two->symbol & 0xF0)>(three->symbol & 0xF0)) { + while ((three->symbol != 0) && (two->symbol & 0xF0) > (three->symbol & 0xF0)) { two++; three++; j++; @@ -221,10 +220,10 @@ static int EvaluateAndFreeExpression(byte *expr) { one = (LPEXPRESSION)(expr + 1); // 1) Sostituzioni delle variabili - for (i=0, cur=one; i < num; i++, cur++) { - if (cur->type==ELT_VAR) { - cur->type=ELT_NUMBER; - cur->val.num=varGetValue(cur->val.name); + for (i = 0, cur = one; i < num; i++, cur++) { + if (cur->type == ELT_VAR) { + cur->type = ELT_NUMBER; + cur->val.num = varGetValue(cur->val.name); } } @@ -265,7 +264,7 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { return NULL; *h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); - if (*h==NULL) + if (*h == NULL) return NULL; start = (byte *)GlobalLock(*h); @@ -332,7 +331,6 @@ int EvaluateExpression(HGLOBAL h) { return ret; } - /** * Compare two mathematical expressions together * @@ -356,8 +354,8 @@ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { return false; } - one = (LPEXPRESSION)(e1+1); - two = (LPEXPRESSION)(e2+1); + one = (LPEXPRESSION)(e1 + 1); + two = (LPEXPRESSION)(e2 + 1); for (i = 0; i < num1; i++) { if (one->type != two->type || (i != num1 - 1 && one->symbol != two->symbol)) { diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 7d7ca09c41..17e9c1264b 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -47,7 +47,6 @@ namespace MPAL { */ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); - /** * Calculate the value of a mathamatical expression * @@ -56,7 +55,6 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); */ int EvaluateExpression(HGLOBAL h); - /** * Compare two mathematical expressions together * diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index a60c9f5f16..a80c85eb75 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -38,7 +38,6 @@ namespace Tony { namespace MPAL { - /****************************************************************************\ * Funzioni statiche \****************************************************************************/ @@ -54,7 +53,6 @@ static bool CompareCommands(struct command *cmd1, struct command *cmd2) { return (memcmp(cmd1, cmd2, sizeof(struct command)) == 0); } - /** * Parses a script from the MPC file, and inserts its data into a structure * @@ -64,7 +62,7 @@ static bool CompareCommands(struct command *cmd1, struct command *cmd2) { * @returns Pointer to the buffer after the item, or NULL on failure. */ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { - int curCmd,j,len; + int curCmd, j, len; uint i; lpmsScript->nObj = (int32)READ_LE_UINT32(lpBuf); @@ -76,31 +74,40 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { curCmd = 0; for (i = 0; i < lpmsScript->nMoments; i++) { - lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Moment[i].nCmds = *lpBuf; lpBuf++; + lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmsScript->Moment[i].nCmds = *lpBuf; + lpBuf++; for (j = 0; j < lpmsScript->Moment[i].nCmds; j++) { - lpmsScript->Command[curCmd].type = *lpBuf; lpBuf++; + lpmsScript->Command[curCmd].type = *lpBuf; + lpBuf++; switch (lpmsScript->Command[curCmd].type) { case 1: - lpmsScript->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmsScript->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmsScript->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpBuf += 2; + lpmsScript->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmsScript->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmsScript->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmsScript->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; break; case 2: // Variable assign - len=*lpBuf; lpBuf++; - lpmsScript->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); + len = *lpBuf; + lpBuf++; + lpmsScript->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); if (lpmsScript->Command[curCmd].lpszVarName == NULL) return NULL; CopyMemory(lpmsScript->Command[curCmd].lpszVarName, lpBuf, len); - lpBuf+=len; + lpBuf += len; lpBuf = ParseExpression(lpBuf, &lpmsScript->Command[curCmd].expr); if (lpBuf == NULL) - return NULL; + return NULL; break; default: @@ -111,11 +118,9 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { curCmd++; } } - return lpBuf; } - /** * Parses a dialog from the MPC file, and inserts its data into a structure * @@ -131,16 +136,19 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 curCmd; uint32 len; - lpmdDialog->nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->nObj = READ_LE_UINT32(lpBuf); + lpBuf += 4; /* Periodi */ - num = READ_LE_UINT16(lpBuf); lpBuf += 2; + num = READ_LE_UINT16(lpBuf); + lpBuf += 2; if (num >= MAX_PERIODS_PER_DIALOG - 1) error("Too much periods in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->PeriodNums[i] = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->PeriodNums[i] = READ_LE_UINT16(lpBuf); + lpBuf += 2; lpmdDialog->Periods[i] = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); lpLock = (byte *)GlobalLock(lpmdDialog->Periods[i]); Common::copy(lpBuf + 1, lpBuf + 1 + *lpBuf, lpLock); @@ -152,14 +160,16 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->Periods[i] = NULL; /* Gruppi */ - num = READ_LE_UINT16(lpBuf); lpBuf += 2; + num = READ_LE_UINT16(lpBuf); + lpBuf += 2; curCmd = 0; if (num >= MAX_GROUPS_PER_DIALOG) error("Too much groups in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->Group[i].num = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Group[i].num = READ_LE_UINT16(lpBuf); + lpBuf += 2; lpmdDialog->Group[i].nCmds = *lpBuf; lpBuf++; if (lpmdDialog->Group[i].nCmds >= MAX_COMMANDS_PER_GROUP) @@ -172,11 +182,16 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { switch (lpmdDialog->Command[curCmd].type) { // Call custom function case 1: - lpmdDialog->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->Command[curCmd].arg1 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg2 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg3 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg4 = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpBuf += 2; + lpmdDialog->Command[curCmd].arg1 = READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmdDialog->Command[curCmd].arg2 = READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmdDialog->Command[curCmd].arg3 = READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmdDialog->Command[curCmd].arg4 = READ_LE_UINT32(lpBuf); + lpBuf += 4; break; // Variable assign @@ -197,7 +212,8 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { // Do Choice case 3: - lpmdDialog->Command[curCmd].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Command[curCmd].nChoice = READ_LE_UINT16(lpBuf); + lpBuf += 2; break; default: @@ -222,13 +238,15 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { error("Too much commands in dialog #%d",lpmdDialog->nObj); /* Choices */ - num = READ_LE_UINT16(lpBuf); lpBuf += 2; + num = READ_LE_UINT16(lpBuf); + lpBuf += 2; if (num >= MAX_CHOICES_PER_DIALOG) error("Too much choices in dialog #%d",lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->Choice[i].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Choice[i].nChoice = READ_LE_UINT16(lpBuf); + lpBuf += 2; num2 = *lpBuf++; @@ -256,16 +274,19 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->Choice[i].Select[j].attr = *lpBuf++; // Data - lpmdDialog->Choice[i].Select[j].dwData = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->Choice[i].Select[j].dwData = READ_LE_UINT32(lpBuf); + lpBuf += 4; // PlayGroup - num3 = *lpBuf; *lpBuf++; + num3 = *lpBuf; + *lpBuf++; if (num3 >= MAX_PLAYGROUPS_PER_SELECT) error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->Choice[i].nChoice, lpmdDialog->nObj); for (z = 0; z < num3; z++) { - lpmdDialog->Choice[i].Select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Choice[i].Select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); + lpBuf += 2; } lpmdDialog->Choice[i].Select[j].wPlayGroup[num3] = 0; @@ -353,11 +374,16 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpBuf++; switch (lpmiItem->Command[curCmd].type) { case 1: // Call custom function - lpmiItem->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmiItem->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmiItem->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpBuf += 2; + lpmiItem->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmiItem->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmiItem->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmiItem->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; break; case 2: // Variable assign @@ -385,7 +411,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } } - if (kk==curCmd) { + if (kk == curCmd) { lpmiItem->Action[i].CmdNum[j] = curCmd; curCmd++; @@ -397,7 +423,8 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } } - lpmiItem->dwRes = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmiItem->dwRes = READ_LE_UINT32(lpBuf); + lpBuf += 4; return lpBuf; } @@ -418,7 +445,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) lpBuf += 2; lpmlLocation->dwYlen = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmlLocation->dwPicRes = READ_LE_UINT32(lpBuf); + lpmlLocation->dwPicRes = READ_LE_UINT32(lpBuf); lpBuf += 4; return lpBuf; @@ -551,14 +578,15 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.nItems = 0; GLOBALS.hItems = GLOBALS.lpmiItems = NULL; if (*(lpBuf + 2) == 4 && strncmp((const char *)lpBuf + 3, "Item", 4)==0) { - GLOBALS.nItems = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nItems = READ_LE_UINT16(lpBuf); + lpBuf += 2; // Allocate memory and read them in GLOBALS.hItems = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); if (GLOBALS.hItems == NULL) return false; - GLOBALS.lpmiItems=(LPMPALITEM)GlobalLock(GLOBALS.hItems); + GLOBALS.lpmiItems = (LPMPALITEM)GlobalLock(GLOBALS.hItems); for (i = 0; i < GLOBALS.nItems; i++) if ((lpBuf = ParseItem(lpBuf + 5, &GLOBALS.lpmiItems[i])) == NULL) @@ -570,8 +598,9 @@ bool ParseMpc(const byte *lpBuf) { // Check the locations GLOBALS.nLocations = 0; GLOBALS.hLocations = GLOBALS.lpmlLocations = NULL; - if (*(lpBuf + 2) == 8 && strncmp((const char *)lpBuf + 3, "Location", 8)==0) { - GLOBALS.nLocations = READ_LE_UINT16(lpBuf); lpBuf += 2; + if (*(lpBuf + 2) == 8 && strncmp((const char *)lpBuf + 3, "Location", 8) == 0) { + GLOBALS.nLocations = READ_LE_UINT16(lpBuf); + lpBuf += 2; // Allocate memory and read them in GLOBALS.hLocations=GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); @@ -591,7 +620,8 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.nScripts = 0; GLOBALS.hScripts = GLOBALS.lpmsScripts = NULL; if (*(lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Script", 6) == 0) { - GLOBALS.nScripts = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nScripts = READ_LE_UINT16(lpBuf); + lpBuf += 2; // Allocate memory GLOBALS.hScripts = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); @@ -611,7 +641,6 @@ bool ParseMpc(const byte *lpBuf) { //sizeof(GLOBALS.lpmsScripts[i].Moment[0]), //(int (*)(const void *, const void *))CompareMoments //); - } GlobalUnlock(GLOBALS.hScripts); @@ -623,7 +652,6 @@ bool ParseMpc(const byte *lpBuf) { return true; } - } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index a5b7593e68..12fc78c60c 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -345,7 +345,7 @@ static char *DuplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; LPMPALDIALOG dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; - int i,j; + int i, j; for (j = 0; dialog->Periods[j] != NULL; j++) if (dialog->PeriodNums[j] == nPeriod) { @@ -457,7 +457,7 @@ static uint32 *GetItemList(uint32 nLoc) { LPMPALVAR v = GLOBALS.lpmvVars; num = 0; - for (i = 0; i < GLOBALS.nVars; i++,v++) { + for (i = 0; i < GLOBALS.nVars; i++, v++) { if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) num++; } @@ -468,8 +468,8 @@ static uint32 *GetItemList(uint32 nLoc) { v = GLOBALS.lpmvVars; j = 0; - for (i = 0; i < GLOBALS.nVars; i++,v++) { - if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) { + for (i = 0; i < GLOBALS.nVars; i++, v++) { + if (strncmp(v->lpszVarName, "Location", 8) == 0 && v->dwVal == nLoc) { sscanf(v->lpszVarName, "Location.%u", &il[j]); j++; } @@ -504,7 +504,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { 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; + dat += 4; } if (i >= 0x11) { // From 1.1, there's animation speed @@ -514,9 +514,9 @@ static LPITEM GetItemData(uint32 nOrdItem) { ret->speed = 150; } - ret->numframe=*dat++; - ret->numpattern=*dat++; - ret->Zvalue=*dat++; + ret->numframe = *dat++; + ret->numpattern = *dat++; + ret->Zvalue = *dat++; // Upload the left & top co-ordinates of each frame for (i = 0; i < ret->numframe; i++) { @@ -529,7 +529,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { for (i = 0; i < ret->numframe; i++) { ret->frameslocations[i].right = (int16)READ_LE_UINT16(dat) + ret->frameslocations[i].left; ret->frameslocations[i].bottom = (int16)READ_LE_UINT16(dat + 2) + ret->frameslocations[i].top; - dat+=4; + dat += 4; } // Upload the bounding boxes of each frame @@ -538,12 +538,12 @@ static LPITEM GetItemData(uint32 nOrdItem) { ret->bbox[i].top = (int16)READ_LE_UINT16(dat + 2); ret->bbox[i].right = (int16)READ_LE_UINT16(dat + 4); ret->bbox[i].bottom = (int16)READ_LE_UINT16(dat + 6); - dat+=8; + dat += 8; } // Load the animation pattern patlength = dat; - dat+=ret->numpattern; + dat += ret->numpattern; for (i = 1; i < ret->numpattern; i++) { for (j = 0; j < patlength[i]; j++) @@ -639,7 +639,7 @@ void ScriptThread(CORO_PARAM, const void *param) { } _ctx->numHandles = 0; - for (_ctx->j = 0; _ctx->j<s->Moment[_ctx->i].nCmds; _ctx->j++) { + for (_ctx->j = 0; _ctx->j < s->Moment[_ctx->i].nCmds; _ctx->j++) { _ctx->k = s->Moment[_ctx->i].CmdNum[_ctx->j]; if (s->Command[_ctx->k].type == 1) { @@ -1048,9 +1048,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { } - - - /** * Wait for the end of the dialog execution thread, and then restore global * variables indicating that the dialogue has finished. @@ -1847,7 +1844,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { n = GETARG(char *); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) - n[0]='\0'; + n[0] = '\0'; else { LockItems(); y = itemGetOrderFromNum(x); @@ -2288,7 +2285,7 @@ void mpalDumpMessages(void) { } // Now make a loop over all the periods - for (j = 0;j<nPeriods; j++) { + for (j = 0; j < nPeriods; j++) { if (nPeriods == 1) sprintf(fname, "000-%05d.WAV", GLOBALS.lpmmMsgs[i].wNum); else @@ -2300,7 +2297,8 @@ void mpalDumpMessages(void) { *p = '\"'; p = frase; - while (*p == ' ') p++; + while (*p == ' ') + p++; if (*p == '\0') continue; @@ -2361,7 +2359,7 @@ void mpalDumpOthers(void) { if (OutputStartOther(GLOBALS.lpmmMsgs[i].wNum, f)) { while (1) { // Find the end of the current period - while (*p!='\0') + while (*p != '\0') p++; // If there is another '0' at the end, then the message is finished @@ -2382,11 +2380,12 @@ void mpalDumpOthers(void) { strcpy(frase,lpPeriods[j]); - while ((p = strchr(frase,'^')) != NULL) + while ((p = strchr(frase, '^')) != NULL) *p = '\"'; p = frase; - while (*p == ' ') p++; + while (*p == ' ') + p++; if (*p == '\0') continue; @@ -2861,7 +2860,8 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { *p = '\"'; p = frase; - while (*p == ' ') p++; + while (*p == ' ') + p++; if (*p == '\0') continue; diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index 90fa31ef1d..44d817d748 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -234,8 +234,8 @@ struct MPALSCRIPT { } Moment[MAX_MOMENTS_PER_SCRIPT]; } PACKED_STRUCT; -typedef MPALSCRIPT* LPMPALSCRIPT; -typedef LPMPALSCRIPT* LPLPMPALSCRIPT; +typedef MPALSCRIPT *LPMPALSCRIPT; +typedef LPMPALSCRIPT *LPLPMPALSCRIPT; #include "common/pack-end.h" |