diff options
Diffstat (limited to 'engines/gob')
-rw-r--r-- | engines/gob/parse.cpp | 30 | ||||
-rw-r--r-- | engines/gob/parse.h | 2 | ||||
-rw-r--r-- | engines/gob/parse_v1.cpp | 26 | ||||
-rw-r--r-- | engines/gob/parse_v2.cpp | 30 |
4 files changed, 45 insertions, 43 deletions
diff --git a/engines/gob/parse.cpp b/engines/gob/parse.cpp index 7bcdfb4f79..50eec0f406 100644 --- a/engines/gob/parse.cpp +++ b/engines/gob/parse.cpp @@ -118,7 +118,7 @@ void Parse::skipExpr(char stopToken) { _vm->_global->_inter_execPtr += 2; if (*_vm->_global->_inter_execPtr == 13) { _vm->_global->_inter_execPtr++; - skipExpr(12); + skipExpr(OP_END_MARKER); } break; @@ -134,17 +134,17 @@ void Parse::skipExpr(char stopToken) { _vm->_global->_inter_execPtr += 3 + dimCount; // skip indices for (dim = 0; dim < dimCount; dim++) - skipExpr(12); + skipExpr(OP_END_MARKER); if ((operation == OP_ARRAY_STR) && (*_vm->_global->_inter_execPtr == 13)) { _vm->_global->_inter_execPtr++; - skipExpr(12); + skipExpr(OP_END_MARKER); } break; case OP_FUNC: _vm->_global->_inter_execPtr++; - skipExpr(10); + skipExpr(OP_END_EXPR); } continue; } // if ((operation >= OP_ARRAY_UINT8) && (operation <= OP_FUNC)) @@ -166,7 +166,7 @@ void Parse::skipExpr(char stopToken) { if (operation != stopToken) continue; - if ((stopToken != 10) || (num < 0)) + if ((stopToken != OP_END_EXPR) || (num < 0)) return; } } @@ -235,7 +235,7 @@ void Parse::printExpr_internal(char stopToken) { if (*_vm->_global->_inter_execPtr == 13) { _vm->_global->_inter_execPtr++; debugN(5, "{"); - printExpr_internal(12); // this also prints the closing } + printExpr_internal(OP_END_MARKER); // this also prints the closing } } break; @@ -252,7 +252,7 @@ void Parse::printExpr_internal(char stopToken) { arrDesc = _vm->_global->_inter_execPtr; _vm->_global->_inter_execPtr += dimCount; for (dim = 0; dim < dimCount; dim++) { - printExpr_internal(12); + printExpr_internal(OP_END_MARKER); debugN(5, " of %d", (int16) arrDesc[dim]); if (dim != dimCount - 1) debugN(5, ","); @@ -264,7 +264,7 @@ void Parse::printExpr_internal(char stopToken) { if ((operation == OP_ARRAY_STR) && (*_vm->_global->_inter_execPtr == 13)) { _vm->_global->_inter_execPtr++; debugN(5, "{"); - printExpr_internal(12); // this also prints the closing } + printExpr_internal(OP_END_MARKER); // this also prints the closing } } break; @@ -280,7 +280,7 @@ void Parse::printExpr_internal(char stopToken) { debugN(5, "sqrt("); else debugN(5, "id("); - printExpr_internal(10); + printExpr_internal(OP_END_EXPR); break; } continue; @@ -368,9 +368,9 @@ void Parse::printExpr_internal(char stopToken) { debugN(5, "\n"); break; - case 12: + case OP_END_MARKER: debugN(5, "}"); - if (stopToken != 12) { + if (stopToken != OP_END_MARKER) { debugN(5, "Closing paren without opening?"); } break; @@ -396,7 +396,7 @@ void Parse::printExpr_internal(char stopToken) { num--; if (operation == stopToken) { - if ((stopToken != 10) || (num < 0)) { + if ((stopToken != OP_END_EXPR) || (num < 0)) { return; } } @@ -422,7 +422,7 @@ void Parse::printVarIndex() { if ((operation == OP_LOAD_VAR_STR) && (*_vm->_global->_inter_execPtr == 13)) { _vm->_global->_inter_execPtr++; debugN(5, "+"); - printExpr(12); + printExpr(OP_END_MARKER); } break; @@ -433,7 +433,7 @@ void Parse::printVarIndex() { arrDesc = _vm->_global->_inter_execPtr; _vm->_global->_inter_execPtr += dimCount; for (dim = 0; dim < dimCount; dim++) { - printExpr(12); + printExpr(OP_END_MARKER); debugN(5, " of %d", (int16) arrDesc[dim]); if (dim != dimCount - 1) debugN(5, ","); @@ -443,7 +443,7 @@ void Parse::printVarIndex() { if ((operation == OP_ARRAY_STR) && (*_vm->_global->_inter_execPtr == 13)) { _vm->_global->_inter_execPtr++; debugN(5, "+"); - printExpr(12); + printExpr(OP_END_MARKER); } break; diff --git a/engines/gob/parse.h b/engines/gob/parse.h index e0696fa0bb..689ef06eae 100644 --- a/engines/gob/parse.h +++ b/engines/gob/parse.h @@ -41,6 +41,8 @@ enum { OP_END_EXPR = 10, OP_NOT = 11, + OP_END_MARKER = 12, // Marks end of an array or string + OP_ARRAY_UINT8 = 16, diff --git a/engines/gob/parse_v1.cpp b/engines/gob/parse_v1.cpp index 5352e9a611..427a2b5184 100644 --- a/engines/gob/parse_v1.cpp +++ b/engines/gob/parse_v1.cpp @@ -56,7 +56,7 @@ int16 Parse_v1::parseVarIndex(uint16 *arg_0, uint16 *arg_4) { if ((operation == OP_LOAD_VAR_STR) && (*_vm->_global->_inter_execPtr == 13)) { _vm->_global->_inter_execPtr++; - val = parseValExpr(12); + val = parseValExpr(OP_END_MARKER); temp += val; debugC(5, kDebugParser, "parse subscript = %d", val); } @@ -70,7 +70,7 @@ int16 Parse_v1::parseVarIndex(uint16 *arg_0, uint16 *arg_4) { _vm->_global->_inter_execPtr += dimCount; offset = 0; for (dim = 0; dim < dimCount; dim++) { - temp2 = parseValExpr(12); + temp2 = parseValExpr(OP_END_MARKER); offset = arrDesc[dim] * offset + temp2; } offset *= 4; @@ -79,7 +79,7 @@ int16 Parse_v1::parseVarIndex(uint16 *arg_0, uint16 *arg_4) { if (*_vm->_global->_inter_execPtr == 13) { _vm->_global->_inter_execPtr++; - temp += parseValExpr(12); + temp += parseValExpr(OP_END_MARKER); } return offset * _vm->_global->_inter_animDataSize + temp; @@ -140,7 +140,7 @@ int16 Parse_v1::parseValExpr(byte stopToken) { case OP_LOAD_VAR_STR: temp = _vm->_inter->load16() * 4; _vm->_global->_inter_execPtr++; - temp += parseValExpr(12); + temp += parseValExpr(OP_END_MARKER); *valPtr = READ_VARO_UINT8(temp); break; @@ -152,14 +152,14 @@ int16 Parse_v1::parseValExpr(byte stopToken) { _vm->_global->_inter_execPtr += dimCount; offset = 0; for (dim = 0; dim < dimCount; dim++) { - temp2 = parseValExpr(12); + temp2 = parseValExpr(OP_END_MARKER); offset = arrDesc[dim] * offset + temp2; } if (operation == OP_ARRAY_UINT32) { *valPtr = (uint16) VAR(temp + offset); } else { _vm->_global->_inter_execPtr++; - temp2 = parseValExpr(12); + temp2 = parseValExpr(OP_END_MARKER); *valPtr = READ_VARO_UINT8(temp * 4 + offset * 4 * _vm->_global->_inter_animDataSize + temp2); } @@ -167,7 +167,7 @@ int16 Parse_v1::parseValExpr(byte stopToken) { case OP_FUNC: operation = *_vm->_global->_inter_execPtr++; - parseExpr(10, 0); + parseExpr(OP_END_EXPR, 0); if (operation == FUNC_SQR) { _vm->_global->_inter_resVal = @@ -379,7 +379,7 @@ int16 Parse_v1::parseExpr(byte stopToken, byte *arg_2) { kInterVar); if (*_vm->_global->_inter_execPtr == 13) { _vm->_global->_inter_execPtr++; - temp += parseValExpr(12); + temp += parseValExpr(OP_END_MARKER); *operPtr = OP_LOAD_IMM_INT16; *valPtr = READ_VARO_UINT8(temp); } @@ -395,7 +395,7 @@ int16 Parse_v1::parseExpr(byte stopToken, byte *arg_2) { offset = 0; dim = 0; for (dim = 0; dim < dimCount; dim++) { - temp2 = parseValExpr(12); + temp2 = parseValExpr(OP_END_MARKER); offset = offset * arrDescPtr[dim] + temp2; } @@ -408,7 +408,7 @@ int16 Parse_v1::parseExpr(byte stopToken, byte *arg_2) { kInterVar); if (*_vm->_global->_inter_execPtr == 13) { _vm->_global->_inter_execPtr++; - temp2 = parseValExpr(12); + temp2 = parseValExpr(OP_END_MARKER); *operPtr = OP_LOAD_IMM_INT16; *valPtr = READ_VARO_UINT8(temp * 4 + offset * 4 * _vm->_global->_inter_animDataSize + temp2); @@ -417,7 +417,7 @@ int16 Parse_v1::parseExpr(byte stopToken, byte *arg_2) { case OP_FUNC: operation = *_vm->_global->_inter_execPtr++; - parseExpr(10, 0); + parseExpr(OP_END_EXPR, 0); switch (operation) { case FUNC_SQR: @@ -473,7 +473,7 @@ int16 Parse_v1::parseExpr(byte stopToken, byte *arg_2) { continue; switch (operPtr[-1]) { - case 2: + case OP_ADD: if (operPtr[-2] == OP_LOAD_IMM_STR) { if ((char *) decodePtr(valPtr[-2]) != _vm->_global->_inter_resStr) { strcpy(_vm->_global->_inter_resStr, (char *) decodePtr(valPtr[-2])); @@ -734,7 +734,7 @@ int16 Parse_v1::parseExpr(byte stopToken, byte *arg_2) { if (((operation == OP_OR) && (operPtr[-1] == GOB_TRUE)) || ((operation == OP_AND) && (operPtr[-1] == GOB_FALSE))) { if ((stkPos > 1) && (operPtr[-2] == OP_BEGIN_EXPR)) { - skipExpr(10); + skipExpr(OP_END_EXPR); operPtr[-2] = operPtr[-1]; stkPos -= 2; operPtr -= 2; diff --git a/engines/gob/parse_v2.cpp b/engines/gob/parse_v2.cpp index 296e135fa1..87ad486c93 100644 --- a/engines/gob/parse_v2.cpp +++ b/engines/gob/parse_v2.cpp @@ -85,7 +85,7 @@ int16 Parse_v2::parseVarIndex(uint16 *arg_0, uint16 *arg_4) { uint16 var_6 = 0; for (int i = 0; i < var_A; i++) { - temp2 = parseValExpr(12); + temp2 = parseValExpr(OP_END_MARKER); int16 ax = sub_12063(temp2, var_12[i], varPos, 0, 0); @@ -122,7 +122,7 @@ int16 Parse_v2::parseVarIndex(uint16 *arg_0, uint16 *arg_4) { _vm->_global->_inter_execPtr += dimCount; offset = 0; for (dim = 0; dim < dimCount; dim++) { - temp2 = parseValExpr(12); + temp2 = parseValExpr(OP_END_MARKER); offset = arrDesc[dim] * offset + temp2; } if (operation == OP_ARRAY_UINT8) @@ -135,7 +135,7 @@ int16 Parse_v2::parseVarIndex(uint16 *arg_0, uint16 *arg_4) { offset *= 4; if (*_vm->_global->_inter_execPtr == 13) { _vm->_global->_inter_execPtr++; - temp += parseValExpr(12); + temp += parseValExpr(OP_END_MARKER); } return varPos + offset * _vm->_global->_inter_animDataSize + temp; @@ -153,7 +153,7 @@ int16 Parse_v2::parseVarIndex(uint16 *arg_0, uint16 *arg_4) { (int16) *_vm->_global->_inter_execPtr); if ((operation == OP_LOAD_VAR_STR) && (*_vm->_global->_inter_execPtr == 13)) { _vm->_global->_inter_execPtr++; - val = parseValExpr(12); + val = parseValExpr(OP_END_MARKER); temp += val; debugC(5, kDebugParser, "parse subscript = %d", val); } @@ -216,7 +216,7 @@ int16 Parse_v2::parseValExpr(byte stopToken) { uint16 var_6 = 0; for (int i = 0; i < var_A; i++) { - temp2 = parseValExpr(12); + temp2 = parseValExpr(OP_END_MARKER); int16 ax = sub_12063(temp2, var_12[i], varPos, 0, 0); @@ -250,7 +250,7 @@ int16 Parse_v2::parseValExpr(byte stopToken) { _vm->_global->_inter_execPtr += dimCount; offset = 0; for (dim = 0; dim < dimCount; dim++) { - temp2 = parseValExpr(12); + temp2 = parseValExpr(OP_END_MARKER); offset = arrDesc[dim] * offset + temp2; } if (operation == OP_ARRAY_UINT8) @@ -261,7 +261,7 @@ int16 Parse_v2::parseValExpr(byte stopToken) { *valPtr = READ_VARO_UINT16(varPos + temp * 2 + offset * 2); else if (operation == OP_ARRAY_STR) { _vm->_global->_inter_execPtr++; - temp2 = parseValExpr(12); + temp2 = parseValExpr(OP_END_MARKER); *valPtr = READ_VARO_UINT8(varPos + temp * 4 + offset * 4 * _vm->_global->_inter_animDataSize + temp2); } @@ -299,13 +299,13 @@ int16 Parse_v2::parseValExpr(byte stopToken) { case OP_LOAD_VAR_STR: temp = _vm->_inter->load16() * 4; _vm->_global->_inter_execPtr++; - temp += parseValExpr(12); + temp += parseValExpr(OP_END_MARKER); *valPtr = READ_VARO_UINT8(varPos + temp); break; case OP_FUNC: operation = *_vm->_global->_inter_execPtr++; - parseExpr(10, 0); + parseExpr(OP_END_EXPR, 0); if (operation == FUNC_SQR) { _vm->_global->_inter_resVal = @@ -508,7 +508,7 @@ int16 Parse_v2::parseExpr(byte stopToken, byte *arg_2) { uint16 var_6 = 0; for (int i = 0; i < var_A; i++) { - temp2 = parseValExpr(12); + temp2 = parseValExpr(OP_END_MARKER); int16 ax = sub_12063(temp2, var_12[i], varPos, 0, 0); @@ -543,7 +543,7 @@ int16 Parse_v2::parseExpr(byte stopToken, byte *arg_2) { _vm->_global->_inter_execPtr += dimCount; offset = 0; for (dim = 0; dim < dimCount; dim++) { - temp2 = parseValExpr(12); + temp2 = parseValExpr(OP_END_MARKER); offset = offset * arrDescPtr[dim] + temp2; } if (operation == OP_ARRAY_UINT8) @@ -558,7 +558,7 @@ int16 Parse_v2::parseExpr(byte stopToken, byte *arg_2) { kInterVar); if (*_vm->_global->_inter_execPtr == 13) { _vm->_global->_inter_execPtr++; - temp2 = parseValExpr(12); + temp2 = parseValExpr(OP_END_MARKER); *operPtr = OP_LOAD_IMM_INT16; *valPtr = READ_VARO_UINT8(varPos + temp * 4 + offset * 4 * _vm->_global->_inter_animDataSize + temp2); @@ -615,7 +615,7 @@ int16 Parse_v2::parseExpr(byte stopToken, byte *arg_2) { *valPtr = encodePtr(_vm->_inter->_variables->getAddressOff8(varPos + temp, 0), kInterVar); if (*_vm->_global->_inter_execPtr == 13) { _vm->_global->_inter_execPtr++; - temp += parseValExpr(12); + temp += parseValExpr(OP_END_MARKER); *operPtr = OP_LOAD_IMM_INT16; *valPtr = READ_VARO_UINT8(varPos + temp); } @@ -623,7 +623,7 @@ int16 Parse_v2::parseExpr(byte stopToken, byte *arg_2) { case OP_FUNC: operation = *_vm->_global->_inter_execPtr++; - parseExpr(10, 0); + parseExpr(OP_END_EXPR, 0); switch (operation) { case FUNC_SQRT1: @@ -951,7 +951,7 @@ int16 Parse_v2::parseExpr(byte stopToken, byte *arg_2) { if (((operation == OP_OR) && (operPtr[-1] == GOB_TRUE)) || ((operation == OP_AND) && (operPtr[-1] == GOB_FALSE))) { if ((stkPos > 1) && (operPtr[-2] == OP_BEGIN_EXPR)) { - skipExpr(10); + skipExpr(OP_END_EXPR); operPtr[-2] = operPtr[-1]; stkPos -= 2; operPtr -= 2; |