aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/tony/mpal/expr.cpp92
-rw-r--r--engines/tony/mpal/expr.h61
-rw-r--r--engines/tony/mpal/loadmpc.cpp6
-rw-r--r--engines/tony/mpal/memory.cpp2
-rw-r--r--engines/tony/mpal/memory.h2
-rw-r--r--engines/tony/mpal/mpal.cpp27
-rw-r--r--engines/tony/mpal/mpal.h2
-rw-r--r--engines/tony/utils.cpp2
8 files changed, 85 insertions, 109 deletions
diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp
index 7923d263c0..824cd91651 100644
--- a/engines/tony/mpal/expr.cpp
+++ b/engines/tony/mpal/expr.cpp
@@ -35,68 +35,6 @@ namespace Tony {
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)
-
-
-/**
- * Object types that can be contained in an EXPRESSION structure
- */
-enum ExprListTypes {
- ELT_NUMBER = 1,
- ELT_VAR = 2,
- ELT_PARENTH = 3,
- ELT_PARENTH2 = 4
-};
-
-//@}
-
-/**
- * @defgroup Structures
- */
-//@{
-
-/**
- * Mathamatical framework to manage operations
- */
-typedef struct {
- byte _type; // Tipo di oggetto (vedi enum ExprListTypes)
- byte _unary; // Unary operatore (NON SUPPORTATO)
-
- union {
- int _num; // Numero (se type==ELT_NUMBER)
- char *_name; // Nome variabile (se type==ELT_VAR)
- MpalHandle _son; // Handle a espressione (type==ELT_PARENTH)
- byte *_pson; // Handle lockato (type==ELT_PARENTH2)
- } _val;
-
- byte _symbol; // Simbolo matematico (vedi #define OP_*)
-
-} Expression;
-typedef Expression *LpExpression;
-
-//@}
/**
* Duplicate a mathematical expression.
@@ -106,15 +44,14 @@ typedef Expression *LpExpression;
*/
static byte *duplicateExpression(MpalHandle h) {
byte *orig, *clone;
- LpExpression one, two;
orig = (byte *)globalLock(h);
int num = *(byte *)orig;
- one = (LpExpression)(orig+1);
+ LpExpression one = (LpExpression)(orig+1);
clone = (byte *)globalAlloc(GMEM_FIXED, sizeof(Expression) * num + 1);
- two = (LpExpression)(clone + 1);
+ LpExpression two = (LpExpression)(clone + 1);
memcpy(clone, orig, sizeof(Expression) * num + 1);
@@ -180,7 +117,6 @@ static int Compute(int a, int b, byte symbol) {
static void solve(LpExpression one, int num) {
LpExpression two, three;
- int j;
while (num > 1) {
two = one + 1;
@@ -189,7 +125,7 @@ static void solve(LpExpression one, int num) {
memmove(one, two, (num - 1) * sizeof(Expression));
--num;
} else {
- j = 1;
+ int j = 1;
three = two + 1;
while ((three->_symbol != 0) && (two->_symbol & 0xF0) > (three->_symbol & 0xF0)) {
++two;
@@ -213,13 +149,11 @@ static void solve(LpExpression one, int num) {
* @returns Value
*/
static int evaluateAndFreeExpression(byte *expr) {
- LpExpression one, cur;
-
int num = *expr;
- one = (LpExpression)(expr + 1);
+ LpExpression one = (LpExpression)(expr + 1);
// 1) Substitutions of variables
- cur = one;
+ LpExpression cur = one;
for (int i = 0; i < num; i++, cur++) {
if (cur->_type == ELT_VAR) {
cur->_type = ELT_NUMBER;
@@ -254,7 +188,6 @@ static int evaluateAndFreeExpression(byte *expr) {
* @returns Pointer to the buffer immediately after the expression, or NULL if error.
*/
const byte *parseExpression(const byte *lpBuf, MpalHandle *h) {
- LpExpression cur;
byte *start;
uint32 num = *lpBuf;
@@ -270,12 +203,14 @@ const byte *parseExpression(const byte *lpBuf, MpalHandle *h) {
start = (byte *)globalLock(*h);
*start = (byte)num;
- cur = (LpExpression)(start + 1);
+ LpExpression cur = (LpExpression)(start + 1);
for (uint32 i = 0;i < num; i++) {
cur->_type = *(lpBuf);
- cur->_unary = *(lpBuf + 1);
+
+ // *(lpBuf + 1) contains the unary operator, unused => skipped
lpBuf += 2;
+
switch (cur->_type) {
case ELT_NUMBER:
cur->_val._num = (int32)READ_LE_UINT32(lpBuf);
@@ -322,10 +257,8 @@ const byte *parseExpression(const byte *lpBuf, MpalHandle *h) {
* @returns Numeric value
*/
int evaluateExpression(MpalHandle h) {
- int ret;
-
lockVar();
- ret = evaluateAndFreeExpression(duplicateExpression(h));
+ int ret = evaluateAndFreeExpression(duplicateExpression(h));
unlockVar();
return ret;
@@ -339,7 +272,6 @@ int evaluateExpression(MpalHandle h) {
*/
bool compareExpressions(MpalHandle h1, MpalHandle h2) {
byte *e1, *e2;
- LpExpression one, two;
e1 = (byte *)globalLock(h1);
e2 = (byte *)globalLock(h2);
@@ -353,8 +285,8 @@ bool compareExpressions(MpalHandle h1, MpalHandle h2) {
return false;
}
- one = (LpExpression)(e1 + 1);
- two = (LpExpression)(e2 + 1);
+ LpExpression one = (LpExpression)(e1 + 1);
+ LpExpression two = (LpExpression)(e2 + 1);
for (int 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 9036099993..405624b4fe 100644
--- a/engines/tony/mpal/expr.h
+++ b/engines/tony/mpal/expr.h
@@ -35,6 +35,67 @@ namespace Tony {
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)
+
+//@}
+
+/**
+ * @defgroup Structures
+ */
+
+//@{
+/**
+ * Mathamatical framework to manage operations
+ */
+typedef struct {
+ byte _type; // Object Type (see enum ExprListTypes)
+
+ union {
+ int _num; // Identifier (if type == ELT_NUMBER)
+ char *_name; // Variable name (if type == ELT_VAR)
+ MpalHandle _son; // Handle expressions (if type == ELT_PARENTH)
+ byte *_pson; // Handle lockato (if type == ELT_PARENTH2)
+ } _val;
+
+ byte _symbol; // Mathematic symbols (see #define OP_*)
+
+} Expression;
+typedef Expression *LpExpression;
+
+//@}
+
+/**
+ * Object types that can be contained in an EXPRESSION structure
+ */
+enum ExprListTypes {
+ ELT_NUMBER = 1,
+ ELT_VAR = 2,
+ ELT_PARENTH = 3,
+ ELT_PARENTH2 = 4
+};
+
/****************************************************************************\
* Function Prototypes
\****************************************************************************/
diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp
index 953820be74..9c45cdf982 100644
--- a/engines/tony/mpal/loadmpc.cpp
+++ b/engines/tony/mpal/loadmpc.cpp
@@ -139,7 +139,6 @@ static void FreeScript(LpMpalScript lpmsScript) {
* @returns Pointer to the buffer after the item, or NULL on failure.
*/
static const byte *parseDialog(const byte *lpBuf, LpMpalDialog lpmdDialog) {
- uint32 num2, num3;
byte *lpLock;
lpmdDialog->_nObj = READ_LE_UINT32(lpBuf);
@@ -266,7 +265,7 @@ static const byte *parseDialog(const byte *lpBuf, LpMpalDialog lpmdDialog) {
lpmdDialog->_choice[i]._nChoice = READ_LE_UINT16(lpBuf);
lpBuf += 2;
- num2 = *lpBuf++;
+ uint32 num2 = *lpBuf++;
if (num2 >= MAX_SELECTS_PER_CHOICE)
error("Too much selects in choice #%d in dialog #%d", lpmdDialog->_choice[i]._nChoice, lpmdDialog->_nObj);
@@ -296,7 +295,7 @@ static const byte *parseDialog(const byte *lpBuf, LpMpalDialog lpmdDialog) {
lpBuf += 4;
// PlayGroup
- num3 = *lpBuf++;
+ uint32 num3 = *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);
@@ -365,7 +364,6 @@ static const byte *parseItem(const byte *lpBuf, LpMpalItem lpmiItem) {
lpBuf++;
}
-
if (*lpBuf == 0) {
lpBuf++;
lpmiItem->_action[i]._when = NULL;
diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp
index 78b036e657..dfbf16e789 100644
--- a/engines/tony/mpal/memory.cpp
+++ b/engines/tony/mpal/memory.cpp
@@ -33,8 +33,6 @@ namespace MPAL {
* MemoryManager methods
\****************************************************************************/
-const uint32 BLOCK_ID = 0x12345678;
-
/**
* Allocates a new memory block
* @return Returns a MemoryItem instance for the new block
diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h
index ba7865938f..9c21cc20e6 100644
--- a/engines/tony/mpal/memory.h
+++ b/engines/tony/mpal/memory.h
@@ -69,6 +69,8 @@ public:
#define GMEM_MOVEABLE 2
#define GMEM_ZEROINIT 4
+const uint32 BLOCK_ID = 0x12345678;
+
} // end of namespace MPAL
} // end of namespace Tony
diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp
index 10f5753540..da18b538d5 100644
--- a/engines/tony/mpal/mpal.cpp
+++ b/engines/tony/mpal/mpal.cpp
@@ -39,19 +39,6 @@ namespace Tony {
namespace MPAL {
-#define GETARG(type) va_arg(v, type)
-
-/****************************************************************************\
-* Copyright
-\****************************************************************************/
-
-const char *mpalCopyright =
- "\n\nMPAL - MultiPurpose Adventure Language for Windows 95\n"
- "Copyright 1997-98 Giovanni Bajo and Luca Giusti\n"
- "ALL RIGHTS RESERVED\n"
- "\n"
- "\n";
-
/****************************************************************************\
* Internal functions
\****************************************************************************/
@@ -363,24 +350,22 @@ static char *duplicateDialogPeriod(uint32 nPeriod) {
MpalHandle resLoad(uint32 dwId) {
MpalHandle h;
char head[4];
- uint32 nBytesRead;
- uint32 nSizeComp, nSizeDecomp;
byte *temp, *buf;
for (int i = 0; i < GLOBALS._nResources; i++)
if (GLOBALS._lpResources[i * 2] == dwId) {
GLOBALS._hMpr.seek(GLOBALS._lpResources[i * 2 + 1]);
- nBytesRead = GLOBALS._hMpr.read(head, 4);
+ uint32 nBytesRead = GLOBALS._hMpr.read(head, 4);
if (nBytesRead != 4)
return NULL;
if (head[0] != 'R' || head[1] != 'E' || head[2] != 'S' || head[3] != 'D')
return NULL;
- nSizeDecomp = GLOBALS._hMpr.readUint32LE();
+ uint32 nSizeDecomp = GLOBALS._hMpr.readUint32LE();
if (GLOBALS._hMpr.err())
return NULL;
- nSizeComp = GLOBALS._hMpr.readUint32LE();
+ uint32 nSizeComp = GLOBALS._hMpr.readUint32LE();
if (GLOBALS._hMpr.err())
return NULL;
@@ -463,18 +448,16 @@ static uint32 *GetItemList(uint32 nLoc) {
static LpItem getItemData(uint32 nOrdItem) {
LpMpalItem curitem = GLOBALS._lpmiItems + nOrdItem;
- LpItem ret;
- MpalHandle hDat;
char *dat;
char *patlength;
// Zeroing out the allocated memory is required!!!
- ret = (LpItem)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(Item));
+ LpItem ret = (LpItem)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(Item));
if (ret == NULL)
return NULL;
ret->_speed = 150;
- hDat = resLoad(curitem->_dwRes);
+ MpalHandle hDat = resLoad(curitem->_dwRes);
dat = (char *)globalLock(hDat);
if (dat[0] == 'D' && dat[1] == 'A' && dat[2] == 'T') {
diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h
index c5f505063f..5e1b02b3fc 100644
--- a/engines/tony/mpal/mpal.h
+++ b/engines/tony/mpal/mpal.h
@@ -102,6 +102,8 @@ namespace MPAL {
#define MAXPATTERN 40 // pattern of animation of an object
#define MAXPOLLINGLOCATIONS 64
+#define GETARG(type) va_arg(v, type)
+
/**
* Macro for use with queries that may refer to X and Y co-ordinates
*/
diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp
index 3cc09a1454..81060146b7 100644
--- a/engines/tony/utils.cpp
+++ b/engines/tony/utils.cpp
@@ -383,7 +383,7 @@ void RMResUpdate::init(const Common::String &fileName) {
// It doesn't exist, so exit immediately
return;
- uint8 version = _hFile.readByte();
+ _hFile.readByte(); // Version, unused
_numUpd = _hFile.readUint32LE();