aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2015-12-23 00:57:15 +0100
committerEugene Sandulenko2015-12-27 15:41:00 +0100
commit60ce5fa557a82f120065d18d135e282352688c51 (patch)
tree96604ea6bb2d73ff9b6b3949d41c80a333280dfe /engines
parente11aef1a7d6f2d3aeb6f509800143f0aac8d3e20 (diff)
downloadscummvm-rg350-60ce5fa557a82f120065d18d135e282352688c51.tar.gz
scummvm-rg350-60ce5fa557a82f120065d18d135e282352688c51.tar.bz2
scummvm-rg350-60ce5fa557a82f120065d18d135e282352688c51.zip
WAGE: Unstub processIf()
Diffstat (limited to 'engines')
-rw-r--r--engines/wage/script.cpp78
-rw-r--r--engines/wage/script.h3
2 files changed, 80 insertions, 1 deletions
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 432b226996..355c5da0f8 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -411,7 +411,83 @@ const char *Script::readOperator() {
}
void Script::processIf() {
- warning("STUB: processIf");
+ int logicalOp = 0; // 0 => initial, 1 => and, 2 => or
+ bool result = true;
+ bool done = false;
+
+ do {
+ Operand *lhs = readOperand();
+ const char *op = readOperator();
+ Operand *rhs = readOperand();
+
+ bool condResult = eval(lhs, op, rhs);
+
+ if (logicalOp == 1) {
+ result = (result && condResult);
+ } else if (logicalOp == 2) {
+ result = (result || condResult);
+ } else { // logicalOp == 0
+ result = condResult;
+ }
+
+ byte logical = _data->readByte();
+
+ if (logical == 0x84) {
+ logicalOp = 1; // and
+ } else if (logical == 0x85) {
+ logicalOp = 2; // or
+ } else if (logical == 0xFE) {
+ done = true; // then
+ }
+ } while (!done);
+
+ if (result == false) {
+ skipBlock();
+ }
+}
+
+void Script::skipIf() {
+ do {
+ readOperand();
+ readOperator();
+ readOperand();
+ } while (_data->readByte() != 0xFE);
+}
+
+void Script::skipBlock() {
+ int nesting = 1;
+
+ while (true) {
+ byte op = _data->readByte();
+
+ if (_data->eos())
+ return;
+
+ if (op == 0x80) { // IF
+ nesting++;
+ skipIf();
+ } else if (op == 0x88 || op == 0x87) { // END or EXIT
+ _data->seek(-1, SEEK_CUR); // We need to reread it higher
+ nesting--;
+ if (nesting == 0) {
+ _data->readByte(); // skiping
+ return;
+ }
+ } else switch (op) {
+ case 0x8B: // PRINT
+ case 0x8C: // SOUND
+ case 0x8E: // LET
+ case 0x95: // MENU
+ while (_data->readByte() != 0xFD)
+ ;
+ }
+ }
+}
+
+bool Script::eval(Operand *lhs, const char *op, Operand *rhs) {
+ warning("STUB: eval");
+
+ return false;
}
void Script::processMove() {
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 97d52f07b4..7ac8356b18 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -134,6 +134,9 @@ private:
Operand *readStringOperand();
const char *readOperator();
void processIf();
+ void skipBlock();
+ void skipIf();
+ bool eval(Operand *lhs, const char *op, Operand *rhs);
void processMove();
void processLet();