diff options
author | Travis Howell | 2004-06-01 08:37:57 +0000 |
---|---|---|
committer | Travis Howell | 2004-06-01 08:37:57 +0000 |
commit | 6c0f223440354fa0aa0df7b5378ccb4e2dd037f7 (patch) | |
tree | 94d3c6fa1e460a79ec621d5a473138bbb1f5ab60 | |
parent | 654099e7d658973b399b17b34a48eb805dcd5979 (diff) | |
download | scummvm-rg350-6c0f223440354fa0aa0df7b5378ccb4e2dd037f7.tar.gz scummvm-rg350-6c0f223440354fa0aa0df7b5378ccb4e2dd037f7.tar.bz2 scummvm-rg350-6c0f223440354fa0aa0df7b5378ccb4e2dd037f7.zip |
HE games use slightly different E1 opcode
Move HE7 specific opcodes to he7, as requested.
svn-id: r13915
-rw-r--r-- | scumm/intern.h | 16 | ||||
-rw-r--r-- | scumm/script_v6he.cpp | 221 | ||||
-rw-r--r-- | scumm/script_v7he.cpp | 176 |
3 files changed, 223 insertions, 190 deletions
diff --git a/scumm/intern.h b/scumm/intern.h index 5638d40600..6436219fa0 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -576,7 +576,6 @@ protected: void virtScreenLoad(int resIdx, int x1, int y1, int x2, int y2); uint8 virtScreenLoadUnpack(vsUnpackCtx *ctx, byte *data); void seekFilePos(int slot, int offset, int mode); - byte stringLen(byte *); virtual void decodeParseString(int a, int b); /* Version 6 script opcodes */ @@ -601,14 +600,9 @@ protected: void o6_writeFile(); void o6_setVolume(); void o6_seekFilePos(); + void o6_unknownE1(); void o6_localizeArray(); - void o6_unknownFA(); void o6_redimArray(); - void o6_stringLen(); - void o6_readINI(); - void o6_unknownF4(); - void o6_unknownF9(); - void o6_unknownFB(); void o6_readFilePos(); void o6_quitPauseRestart(); }; @@ -633,9 +627,17 @@ 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_readINI(); + void o7_unknownF4(); + void o7_unknownF9(); + void o7_unknownFA(); + void o7_unknownFB(); }; class ScummEngine_v7 : public ScummEngine_v6 { diff --git a/scumm/script_v6he.cpp b/scumm/script_v6he.cpp index 3aabe6a9f6..cd2e8892ec 100644 --- a/scumm/script_v6he.cpp +++ b/scumm/script_v6he.cpp @@ -342,23 +342,23 @@ void ScummEngine_v6he::setupOpcodes() { /* EC */ OPCODE(o6_invalid), OPCODE(o6_invalid), - OPCODE(o6_stringLen), + OPCODE(o6_invalid), OPCODE(o6_invalid), /* F0 */ OPCODE(o6_invalid), OPCODE(o6_invalid), OPCODE(o6_invalid), - OPCODE(o6_readINI), + OPCODE(o6_invalid), /* F4 */ - OPCODE(o6_unknownF4), + OPCODE(o6_invalid), OPCODE(o6_invalid), OPCODE(o6_invalid), OPCODE(o6_invalid), /* F8 */ OPCODE(o6_invalid), - OPCODE(o6_unknownF9), - OPCODE(o6_unknownFA), - OPCODE(o6_unknownFB), + OPCODE(o6_invalid), + OPCODE(o6_invalid), + OPCODE(o6_invalid), /* FC */ OPCODE(o6_invalid), OPCODE(o6_invalid), @@ -1272,12 +1272,45 @@ void ScummEngine_v6he::o6_setVolume() { } } -void ScummEngine_v6he::o6_unknownFA() { - int len, a = fetchScriptByte(); +void ScummEngine_v6he::o6_unknownE1() { + int x = pop(); + int y = pop(); + + if (x > _screenWidth - 1) { + push(-1); + return; + } + if (x < 0) { + push(-1); + return; + } + + if (y < 0) { + push(-1); + return; + } - len = resStrLen(_scriptPointer); - warning("stub o6_unknownFA(%d, \"%s\")", a, _scriptPointer); - _scriptPointer += len + 1; + VirtScreen *vs = findVirtScreen(y); + + if (vs == NULL) { + push(-1); + return; + } + + int offset = (y - vs->topline) * vs->width + x + _screenLeft; + + byte area = *(vs->screenPtr + offset); + push(area); +} + +void ScummEngine_v6he::o6_localizeArray() { + int stringID = pop(); + + if (stringID < _numArray) { + _baseArrays[stringID][0] = (byte)_currentScript; + } else { + warning("o6_localizeArray(%d): too big scriptID", stringID); + } } void ScummEngine_v6he::o6_seekFilePos() { @@ -1387,172 +1420,6 @@ void ScummEngine_v6he::redimArray(int arrayId, int newX, int newY, int type) { ah->dim2 = TO_LE_16(newX + 1); } -void ScummEngine_v6he::o6_stringLen() { - int a, len; - byte *addr; - - a = pop(); - - addr = getStringAddress(a); - if (!addr) { - // FIXME: should be error here - warning("o6_stringLen: Reference to zeroed array pointer (%d)", a); - push(0); - return; - } - - if (_heversion >= 60) { - len = strlen((char *)getStringAddress(a)); - } else { // FREDDI, PUTTMOON - len = stringLen(addr); - } - push(len); -} - -byte ScummEngine_v6he::stringLen(byte *ptr) { - byte len; - byte c; - if (!ptr) { - //ptr = _someGlobalPtr; - error("ScummEngine_v6he::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_v6he::o6_readINI() { - int len; - - len = resStrLen(_scriptPointer); - debug(1, "stub o6_readINI(\"%s\")", _scriptPointer); - _scriptPointer += len + 1; - pop(); - push(0); - -} - -void ScummEngine_v6he::o6_localizeArray() { - int stringID = pop(); - - if (stringID < _numArray) { - _baseArrays[stringID][0] = (byte)_currentScript; - } else { - warning("o6_localizeArray(%d): too big scriptID", stringID); - } -} - -void ScummEngine_v6he::o6_unknownF4() { - if (_heversion >= 60) { - 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: - addMessageToStack(_scriptPointer, filename1, sizeof(filename1)); - - len = resStrLen(_scriptPointer); - _scriptPointer += len + 1; - debug(1, "o6_unknownF4(%d, %d, \"%s\")", a, b, filename1); - break; - case 2: - addMessageToStack(_scriptPointer, filename1, sizeof(filename1)); - - len = resStrLen(_scriptPointer); - _scriptPointer += len + 1; - - addMessageToStack(_scriptPointer, filename2, sizeof(filename2)); - - 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; - byte filename[100]; - - addMessageToStack(_scriptPointer, filename, sizeof(filename)); - - len = resStrLen(_scriptPointer); - _scriptPointer += len + 1; - - for (r = strlen((char*)filename); r != 0; r--) { - if (filename[r - 1] == '\\') - break; - } - - warning("stub o6_unknownF9(\"%s\")", filename + r); -} - -void ScummEngine_v6he::o6_unknownFB() { - byte b; - b = fetchScriptByte(); - - switch (b) { - case 246: - case 248: - pop(); - pop(); - pop(); - pop(); - pop(); - pop(); - pop(); - pop(); - pop(); - break; - case 247: - pop(); - pop(); - break; - } - warning("o6_unknownFB stub"); -} - void ScummEngine_v6he::decodeParseString(int m, int n) { byte b; int c; diff --git a/scumm/script_v7he.cpp b/scumm/script_v7he.cpp index 8241ff36fb..8fedba9744 100644 --- a/scumm/script_v7he.cpp +++ b/scumm/script_v7he.cpp @@ -342,23 +342,23 @@ void ScummEngine_v7he::setupOpcodes() { /* EC */ OPCODE(o6_invalid), OPCODE(o6_invalid), - OPCODE(o6_stringLen), + OPCODE(o7_stringLen), OPCODE(o6_invalid), /* F0 */ OPCODE(o6_invalid), OPCODE(o6_invalid), OPCODE(o6_invalid), - OPCODE(o6_readINI), + OPCODE(o7_readINI), /* F4 */ - OPCODE(o6_unknownF4), + OPCODE(o7_unknownF4), OPCODE(o6_invalid), OPCODE(o6_invalid), OPCODE(o6_invalid), /* F8 */ OPCODE(o6_invalid), - OPCODE(o6_unknownF9), - OPCODE(o6_unknownFA), - OPCODE(o6_unknownFB), + OPCODE(o7_unknownF9), + OPCODE(o7_unknownFA), + OPCODE(o7_unknownFB), /* FC */ OPCODE(o6_invalid), OPCODE(o6_invalid), @@ -404,4 +404,168 @@ void ScummEngine_v7he::o7_objectY() { push(_objs[objnum].y_pos); } +void ScummEngine_v7he::o7_unknownFA() { + int len, a = fetchScriptByte(); + + len = resStrLen(_scriptPointer); + warning("stub o7_unknownFA(%d, \"%s\")", a, _scriptPointer); + _scriptPointer += len + 1; +} + +void ScummEngine_v7he::o7_stringLen() { + int a, len; + byte *addr; + + a = pop(); + + addr = getStringAddress(a); + if (!addr) { + // FIXME: should be error here + warning("o7_stringLen: Reference to zeroed array pointer (%d)", a); + push(0); + return; + } + + if (_heversion >= 60) { + len = strlen((char *)getStringAddress(a)); + } else { // FREDDI, PUTTMOON + len = stringLen(addr); + } + 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_readINI() { + int len; + + len = resStrLen(_scriptPointer); + debug(1, "stub o7_readINI(\"%s\")", _scriptPointer); + _scriptPointer += len + 1; + pop(); + push(0); + +} + +void ScummEngine_v7he::o7_unknownF4() { + if (_heversion >= 60) { + 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: + addMessageToStack(_scriptPointer, filename1, sizeof(filename1)); + + len = resStrLen(_scriptPointer); + _scriptPointer += len + 1; + debug(1, "o7_unknownF4(%d, %d, \"%s\")", a, b, filename1); + break; + case 2: + addMessageToStack(_scriptPointer, filename1, sizeof(filename1)); + + len = resStrLen(_scriptPointer); + _scriptPointer += len + 1; + + addMessageToStack(_scriptPointer, filename2, sizeof(filename2)); + + len = resStrLen(_scriptPointer); + _scriptPointer += len + 1; + debug(1, "o7_unknownF4(%d, %d, \"%s\", \"%s\")", a, b, filename1, filename2); + break; + } + } + warning("o7_unknownF4 stub"); +} + +void ScummEngine_v7he::o7_unknownF9() { + // File related + int len, r; + byte filename[100]; + + addMessageToStack(_scriptPointer, filename, sizeof(filename)); + + len = resStrLen(_scriptPointer); + _scriptPointer += len + 1; + + for (r = strlen((char*)filename); r != 0; r--) { + if (filename[r - 1] == '\\') + break; + } + + warning("stub o7_unknownF9(\"%s\")", filename + r); +} + +void ScummEngine_v7he::o7_unknownFB() { + byte b; + b = fetchScriptByte(); + + switch (b) { + case 246: + case 248: + pop(); + pop(); + pop(); + pop(); + pop(); + pop(); + pop(); + pop(); + pop(); + break; + case 247: + pop(); + pop(); + break; + } + warning("o7_unknownFB stub"); +} + } // End of namespace Scumm |