[Scummvm-cvs-logs] SF.net SVN: scummvm: [22568] scummvm/trunk/engines/gob
wjpalenstijn at users.sourceforge.net
wjpalenstijn at users.sourceforge.net
Sun May 21 14:19:03 CEST 2006
Revision: 22568
Author: wjpalenstijn
Date: 2006-05-21 14:18:23 -0700 (Sun, 21 May 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=22568&view=rev
Log Message:
-----------
make printExpr, skipExpr accept both gob1 and gob2 expressions
Modified Paths:
--------------
scummvm/trunk/engines/gob/parse.cpp
scummvm/trunk/engines/gob/parse.h
Modified: scummvm/trunk/engines/gob/parse.cpp
===================================================================
--- scummvm/trunk/engines/gob/parse.cpp 2006-05-21 20:41:53 UTC (rev 22567)
+++ scummvm/trunk/engines/gob/parse.cpp 2006-05-21 21:18:23 UTC (rev 22568)
@@ -85,10 +85,13 @@
while (1) {
operation = *_vm->_global->_inter_execPtr++;
- if (operation >= 19 && operation <= 29) {
+ if (operation >= 16 && operation <= 29) {
switch (operation) {
+ case 17:
+ case 18:
case 20:
case 23:
+ case 24:
_vm->_global->_inter_execPtr += 2;
break;
@@ -96,6 +99,10 @@
_vm->_global->_inter_execPtr += 4;
break;
+ case 21:
+ _vm->_global->_inter_execPtr += 1;
+ break;
+
case 22:
_vm->_global->_inter_execPtr += strlen(_vm->_global->_inter_execPtr) + 1;
break;
@@ -108,10 +115,14 @@
}
break;
+ case 16:
case 26:
+ case 27:
case 28:
dimCount = _vm->_global->_inter_execPtr[2];
- _vm->_global->_inter_execPtr += 3 + dimCount; // ???
+ // skip header and dimensions
+ _vm->_global->_inter_execPtr += 3 + dimCount;
+ // skip indices
for (dim = 0; dim < dimCount; dim++)
skipExpr(12);
@@ -126,7 +137,7 @@
skipExpr(10);
}
continue;
- } // if (operation >= 19 && operation <= 29)
+ } // if (operation >= 16 && operation <= 29)
if (operation == 9) {
num++;
@@ -151,61 +162,77 @@
}
void Parse::printExpr(char stopToken) {
+ // Expression printing disabled by default
+ return;
+
+ char* savedPos = _vm->_global->_inter_execPtr;
+ printExpr_internal(stopToken);
+
+ // restore IP to start of expression
+ _vm->_global->_inter_execPtr = savedPos;
+}
+
+void Parse::printExpr_internal(char stopToken) {
int16 dimCount;
char operation;
int16 num;
int16 dim;
char *arrDesc;
char func;
- char saved = 0;
- static char *savedPos = 0;
- // TODO: There seems to be a problem here, GOB2 runs into an endless loop
- return;
-
- if (savedPos == 0) {
- savedPos = _vm->_global->_inter_execPtr;
- saved = 1;
- }
-
num = 0;
while (1) {
operation = *_vm->_global->_inter_execPtr++;
- if (operation >= 19 && operation <= 29) {
+ if (operation >= 16 && operation <= 29) {
+ // operands
+
switch (operation) {
- case 19:
+ case 17: // uint16 variable load
+ debugN(5, "var16_%d", _vm->_inter->load16());
+ break;
+
+ case 18: // uint8 variable load:
+ debugN(5, "var8_%d", _vm->_inter->load16());
+ break;
+
+ case 19: // uint32 immediate
debugN(5, "%d", READ_LE_UINT32(_vm->_global->_inter_execPtr));
_vm->_global->_inter_execPtr += 4;
break;
- case 20:
+ case 20: // uint16 immediate
debugN(5, "%d", _vm->_inter->load16());
break;
- case 22:
+ case 21: // uint8 immediate
+ debugN(5, "%d", *_vm->_global->_inter_execPtr++);
+ break;
+
+ case 22: // string immediate
debugN(5, "\42%s\42", _vm->_global->_inter_execPtr);
_vm->_global->_inter_execPtr += strlen(_vm->_global->_inter_execPtr) + 1;
break;
- case 23:
- {
- int16 varnum = _vm->_inter->load16();
- debugN(5, "var_%d (val=%d)", varnum, READ_LE_UINT32(_vm->_global->_inter_variables + varnum * 4) );
+ case 23: // uint32 variable load
+ case 24: // uint32 variable load as uint16
+ debugN(5, "var_%d", _vm->_inter->load16());
break;
- }
- case 25:
+
+ case 25: // string variable load
debugN(5, "(&var_%d)", _vm->_inter->load16());
if (*_vm->_global->_inter_execPtr == 13) {
_vm->_global->_inter_execPtr++;
debugN(5, "{");
- printExpr(12);
- debugN(5, "}");
+ printExpr_internal(12); // this also prints the closing }
}
break;
- case 26:
- case 28:
+ case 16: // uint8 array access
+ case 26: // uint32 array access
+ case 27: // uint16 array access
+ case 28: // string array access
+ debugN(5, "\n");
if (operation == 28)
debugN(5, "(&");
@@ -214,7 +241,7 @@
arrDesc = _vm->_global->_inter_execPtr;
_vm->_global->_inter_execPtr += dimCount;
for (dim = 0; dim < dimCount; dim++) {
- printExpr(12);
+ printExpr_internal(12);
debugN(5, " of %d", (int16)arrDesc[dim]);
if (dim != dimCount - 1)
debugN(5, ",");
@@ -226,12 +253,11 @@
if (operation == 28 && *_vm->_global->_inter_execPtr == 13) {
_vm->_global->_inter_execPtr++;
debugN(5, "{");
- printExpr(12);
-// debugN(5, "}");
+ printExpr_internal(12); // this also prints the closing }
}
break;
- case 29:
+ case 29: // function
func = *_vm->_global->_inter_execPtr++;
if (func == 5)
debugN(5, "sqr(");
@@ -243,15 +269,13 @@
debugN(5, "sqrt(");
else
debugN(5, "id(");
- printExpr(10);
+ printExpr_internal(10);
break;
-
- default:
- debugN(5, "<%d>", (int16)operation);
- break;
}
continue;
- } // if (operation >= 19 && operation <= 29)
+ } // if (operation >= 16 && operation <= 29)
+
+ // operators
switch (operation) {
case 9:
debugN(5, "(");
@@ -342,6 +366,7 @@
default:
debugN(5, "<%d>", (int16)operation);
+ error("printExpr: invalid operator in expression");
break;
}
@@ -361,17 +386,13 @@
if (operation == stopToken) {
if (stopToken != 10 || num < 0) {
-
- if (saved != 0) {
- _vm->_global->_inter_execPtr = savedPos;
- savedPos = 0;
- }
return;
}
}
}
}
+
void Parse::printVarIndex() {
char *arrDesc;
int16 dim;
Modified: scummvm/trunk/engines/gob/parse.h
===================================================================
--- scummvm/trunk/engines/gob/parse.h 2006-05-21 20:41:53 UTC (rev 22567)
+++ scummvm/trunk/engines/gob/parse.h 2006-05-21 21:18:23 UTC (rev 22568)
@@ -48,6 +48,8 @@
int32 encodePtr(char *ptr, int type);
char *decodePtr(int32 n);
+
+ void printExpr_internal(char stopToken);
};
class Parse_v1 : public Parse {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list