aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
Diffstat (limited to 'scumm')
-rw-r--r--scumm/intern.h5
-rw-r--r--scumm/script_v6he.cpp74
-rw-r--r--scumm/script_v7he.cpp118
3 files changed, 69 insertions, 128 deletions
diff --git a/scumm/intern.h b/scumm/intern.h
index cf152a706d..0d18e0530b 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -593,6 +593,7 @@ protected:
void o6_redimArray();
void o6_stringLen();
void o6_readINI();
+ void o6_unknownF4();
void o6_unknownF9();
void o6_readFilePos();
};
@@ -617,13 +618,9 @@ protected:
virtual void executeOpcode(byte i);
virtual const char *getOpcodeDesc(byte i);
- byte stringLen(byte *);
-
/* Version 7 script opcodes */
void o7_objectX();
void o7_objectY();
- void o7_stringLen();
- void o7_unknownF4();
void o7_unknownFB();
};
diff --git a/scumm/script_v6he.cpp b/scumm/script_v6he.cpp
index ec7d68055e..ce53e47f80 100644
--- a/scumm/script_v6he.cpp
+++ b/scumm/script_v6he.cpp
@@ -352,7 +352,7 @@ void ScummEngine_v6he::setupOpcodes() {
OPCODE(o6_invalid),
OPCODE(o6_readINI),
/* F4 */
- OPCODE(o6_invalid),
+ OPCODE(o6_unknownF4),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
@@ -1248,22 +1248,21 @@ void ScummEngine_v6he::o6_stringLen() {
int a, len;
byte *addr;
- if (!(_features & GF_WINDOWS)) {
- o6_invalid();
- return;
- }
-
a = pop();
addr = getStringAddress(a);
if (!addr) {
// FIXME: should be error here
- warning("ScummEngine_v6he::o7_stringLen: Reference to zeroed array pointer (%d)", a);
+ warning("o6_stringLen: Reference to zeroed array pointer (%d)", a);
push(0);
return;
}
- len = stringLen(addr);
+ if (_gameId == GID_FREDDEMO) {
+ len = strlen((char *)getStringAddress(a));
+ } else { // FREDDI, PUTTMOON
+ len = stringLen(addr);
+ }
push(len);
}
@@ -1315,6 +1314,65 @@ void ScummEngine_v6he::o6_localizeArray() {
}
}
+void ScummEngine_v6he::o6_unknownF4() {
+ if (_gameId == GID_FREDDEMO) {
+ byte b;
+ int len;
+ b = fetchScriptByte();
+
+ switch (b) {
+ case 6:
+ pop();
+ len = resStrLen(_scriptPointer);
+ _scriptPointer += len + 1;
+ break;
+ case 7:
+ len = resStrLen(_scriptPointer);
+ _scriptPointer += len + 1;
+ len = resStrLen(_scriptPointer);
+ _scriptPointer += len + 1;
+ break;
+ }
+ } else { // FREDDI, PUTTMOON
+ int a, b;
+ byte filename1[256], filename2[256];
+ int len;
+
+
+ b = pop();
+ a = pop();
+
+ switch (b) {
+ case 1:
+ _msgPtrToAdd = filename1;
+ _messagePtr = _scriptPointer;
+ addMessageToStack(_messagePtr);
+
+ len = resStrLen(_scriptPointer);
+ _scriptPointer += len + 1;
+ debug(1, "o6_unknownF4(%d, %d, \"%s\")", a, b, _messagePtr);
+ break;
+ case 2:
+ _msgPtrToAdd = filename1;
+ _messagePtr = _scriptPointer;
+ addMessageToStack(_messagePtr);
+
+ len = resStrLen(_scriptPointer);
+ _scriptPointer += len + 1;
+
+ _msgPtrToAdd = filename2;
+ _messagePtr = _scriptPointer;
+ addMessageToStack(_messagePtr);
+
+ len = resStrLen(_scriptPointer);
+ _scriptPointer += len + 1;
+ debug(1, "o6_unknownF4(%d, %d, \"%s\", \"%s\")", a, b, filename1, filename2);
+ break;
+ }
+ }
+ warning("o6_unknownF4 stub");
+}
+
void ScummEngine_v6he::o6_unknownF9() {
// File related
int len, r;
diff --git a/scumm/script_v7he.cpp b/scumm/script_v7he.cpp
index cda0d14749..f1f07ca4d1 100644
--- a/scumm/script_v7he.cpp
+++ b/scumm/script_v7he.cpp
@@ -344,7 +344,7 @@ void ScummEngine_v7he::setupOpcodes() {
/* EC */
OPCODE(o6_invalid),
OPCODE(o6_invalid),
- OPCODE(o7_stringLen),
+ OPCODE(o6_stringLen),
OPCODE(o6_invalid),
/* F0 */
OPCODE(o6_invalid),
@@ -352,7 +352,7 @@ void ScummEngine_v7he::setupOpcodes() {
OPCODE(o6_invalid),
OPCODE(o6_readINI),
/* F4 */
- OPCODE(o7_unknownF4),
+ OPCODE(o6_unknownF4),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
@@ -406,120 +406,6 @@ void ScummEngine_v7he::o7_objectY() {
push(_objs[objnum].y_pos);
}
-void ScummEngine_v7he::o7_stringLen() {
- int a, len;
- byte *addr;
-
- if (!(_features & GF_WINDOWS)) {
- o6_invalid();
- return;
- }
-
- a = pop();
-
- addr = getStringAddress(a);
- if (!addr) {
- // FIXME: should be error here
- warning("ScummEngine_v7he::o7_stringLen: Reference to zeroed array pointer (%d)", a);
- push(0);
- return;
- }
-
- len = strlen((char *)getStringAddress(a));
- push(len);
-}
-
-byte ScummEngine_v7he::stringLen(byte *ptr) {
- byte len;
- byte c;
- if (!ptr) {
- //ptr = _someGlobalPtr;
- error("ScummEngine_v7he::stringLen(): zero ptr. Undimplemented behaviour");
- return 1;
- }
-
- len = 0;
- c = *ptr++;
-
- if (len == c)
- return 1;
-
- do {
- len++;
- if (c == 0xff) {
- ptr += 3;
- len += 3;
- }
- c = *ptr++;
- } while (c);
-
- return len+1;
-}
-
-void ScummEngine_v7he::o7_unknownF4() {
- if (!(_features & GF_WINDOWS)) {
- o6_invalid();
- return;
- }
-
- if (_gameId == GID_FREDDEMO) {
- byte b;
- int len;
- b = fetchScriptByte();
-
- switch (b) {
- case 6:
- pop();
- len = resStrLen(_scriptPointer);
- _scriptPointer += len + 1;
- break;
- case 7:
- len = resStrLen(_scriptPointer);
- _scriptPointer += len + 1;
- len = resStrLen(_scriptPointer);
- _scriptPointer += len + 1;
- break;
- }
- } else { // FREDDI.w32, PUTTMOON.w32
- int a, b;
- byte filename1[256], filename2[256];
- int len;
-
-
- b = pop();
- a = pop();
-
- switch (b) {
- case 1:
- _msgPtrToAdd = filename1;
- _messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr);
-
- len = resStrLen(_scriptPointer);
- _scriptPointer += len + 1;
- debug(0, "unknownF4(%d, %d, \"%s\")", a, b, _messagePtr);
- break;
- case 2:
- _msgPtrToAdd = filename1;
- _messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr);
-
- len = resStrLen(_scriptPointer);
- _scriptPointer += len + 1;
-
- _msgPtrToAdd = filename2;
- _messagePtr = _scriptPointer;
- addMessageToStack(_messagePtr);
-
- len = resStrLen(_scriptPointer);
- _scriptPointer += len + 1;
- debug(0, "unknownF4(%d, %d, \"%s\", \"%s\")", a, b, filename1, filename2);
- break;
- }
- }
- warning("o7_unknownF4 stub");
-}
-
void ScummEngine_v7he::o7_unknownFB() {
byte b;
b = fetchScriptByte();