From 4f55b334eb94f129e7b23019c188f4e0dd4fc6df Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Mon, 23 Aug 2004 11:20:25 +0000 Subject: Re-order opcodes svn-id: r14714 --- scumm/intern.h | 24 ++-- scumm/script_v72he.cpp | 322 ++++++++++++++++++++++-------------------- scumm/script_v7he.cpp | 374 ++++++++++++++++++++++++------------------------- 3 files changed, 365 insertions(+), 355 deletions(-) diff --git a/scumm/intern.h b/scumm/intern.h index f8a4b87d4b..492a8a0215 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -620,18 +620,17 @@ protected: byte stringLen(byte *); /* Version 7 script opcodes */ - void o7_getString(); + void o7_cursorCommand(); + void o7_startSound(); + void o7_pickupObject(); + void o7_getActorRoom(); + void o7_quitPauseRestart(); void o7_stringLen(); void o7_readINI(); void o7_unknownF4(); void o7_unknownF9(); void o7_unknownFA(); void o7_unknownFB(); - void o7_quitPauseRestart(); - void o7_getActorRoom(); - void o7_pickupObject(); - void o7_startSound(); - void o7_cursorCommand(); }; class ScummEngine_v72he : public ScummEngine_v7he { @@ -659,17 +658,18 @@ protected: void o7_getString(); void o7_objectX(); void o7_objectY(); + void o7_startScript(); + void o7_startObject(); + void o7_unknown63(); + void o7_arrayOps(); + void o7_dimArray(); + void o7_dim2dimArray(); + void o7_jumpToScript(); void o7_stringLen(); void o7_readINI(); void o7_unknownF4(); void o7_unknownFA(); void o7_unknownFB(); - void o7_arrayOps(); - void o7_dimArray(); - void o7_jumpToScript(); - void o7_startScript(); - void o7_unknown63(); - void o7_dim2dimArray(); }; class ScummEngine_v7 : public ScummEngine_v6 { diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp index d270b27aa6..26cf28487c 100644 --- a/scumm/script_v72he.cpp +++ b/scumm/script_v72he.cpp @@ -166,7 +166,7 @@ void ScummEngine_v72he::setupOpcodes() { OPCODE(o7_startScript), OPCODE(o6_startScriptQuick), /* 60 */ - OPCODE(o6_startObject), + OPCODE(o7_startObject), OPCODE(o6_drawObject), OPCODE(o6_drawObjectAt), OPCODE(o7_unknown63), @@ -380,6 +380,16 @@ const char *ScummEngine_v72he::getOpcodeDesc(byte i) { } +void ScummEngine_v72he::o7_getString() { + int len; + + len = resStrLen(_scriptPointer); + warning("stub o7_getString(\"%s\")", _scriptPointer); + _scriptPointer += len; + fetchScriptWord(); + fetchScriptWord(); +} + void ScummEngine_v72he::o7_objectX() { int object = pop(); int objnum = getObjectIndex(object); @@ -405,14 +415,31 @@ void ScummEngine_v72he::o7_objectY() { push(_objs[objnum].y_pos); } -void ScummEngine_v72he::o7_getString() { - int len; +void ScummEngine_v72he::o7_startScript() { + if (_heversion <= 71) { + ScummEngine_v6::o6_startScript(); + return; + } + + int args[16]; + int script, flags; + + getStackList(args, ARRAYSIZE(args)); + script = pop(); + flags = fetchScriptByte(); - len = resStrLen(_scriptPointer); - warning("stub o7_getString(\"%s\")", _scriptPointer); - _scriptPointer += len; - fetchScriptWord(); - fetchScriptWord(); + runScript(script, (flags == 199 || flags == 200), (flags == 195 || flags == 200), args); +} + +void ScummEngine_v72he::o7_startObject() { + int args[16]; + int script, entryp; + int flags; + getStackList(args, ARRAYSIZE(args)); + entryp = pop(); + script = pop(); + flags = fetchScriptByte(); + runObjectScript(script, entryp, (flags == 199 || flags == 200), (flags == 195 || flags == 200), args); } void ScummEngine_v72he::o7_unknown63() { @@ -421,8 +448,134 @@ void ScummEngine_v72he::o7_unknown63() { push(1); } -void ScummEngine_v72he::o7_unknownFA() { - warning("stub o7_unknownFA(%d)", fetchScriptByte()); +void ScummEngine_v72he::o7_arrayOps() { + byte subOp = fetchScriptByte(); + int array = fetchScriptWord(); + int b, c, d, len; + ArrayHeader *ah; + int list[128]; + + switch (subOp) { + case 7: // SO_ASSIGN_STRING + len = resStrLen(_scriptPointer); + ah = defineArray(array, kStringArray, 0, len + 1); + copyScriptString(ah->data); + break; + case 205: // SO_ASSIGN_STRING + b = pop(); + len = resStrLen(_scriptPointer); + ah = defineArray(array, kStringArray, 0, len + 1); + copyScriptString(ah->data + b); + break; + case 208: // SO_ASSIGN_INT_LIST + b = pop(); + c = pop(); + d = readVar(array); + if (d == 0) { + defineArray(array, kIntArray, 0, b + c); + } + while (c--) { + writeArray(array, 0, b + c, pop()); + } + break; + case 212: // SO_ASSIGN_2DIM_LIST + b = pop(); + len = getStackList(list, ARRAYSIZE(list)); + d = readVar(array); + if (d == 0) + error("Must DIM a two dimensional array before assigning"); + c = pop(); + while (--len >= 0) { + writeArray(array, c, b + len, list[len]); + } + break; + default: + error("o7_arrayOps: default case %d (array %d)", subOp, array); + } +} + +void ScummEngine_v72he::o7_dimArray() { + if (_heversion <= 71) { + ScummEngine_v6::o6_dimArray(); + return; + } + + int data; + int type = fetchScriptByte(); + + switch (type) { + case 5: // SO_INT_ARRAY + data = kIntArray; + break; + case 2: // SO_BIT_ARRAY + data = kBitArray; + break; + case 3: // SO_NIBBLE_ARRAY + data = kNibbleArray; + break; + case 4: // SO_BYTE_ARRAY + data = kByteArray; + break; + case 7: // SO_STRING_ARRAY + data = kStringArray; + break; + case 204: // SO_UNDIM_ARRAY + nukeArray(fetchScriptWord()); + return; + default: + error("o7_dimArray: default case %d", type); + } + + defineArray(fetchScriptWord(), data, 0, pop()); +} + + +void ScummEngine_v72he::o7_dim2dimArray() { + if (_heversion <= 71) { + ScummEngine_v6::o6_dim2dimArray(); + return; + } + + int a, b, data; + int type = fetchScriptByte(); + switch (type - 2) { + case 0: // SO_INT_ARRAY + data = kIntArray; + break; + case 1: // SO_BIT_ARRAY + data = kBitArray; + break; + case 2: // SO_NIBBLE_ARRAY + data = kNibbleArray; + break; + case 3: // SO_BYTE_ARRAY + data = kByteArray; + break; + case 4: // SO_STRING_ARRAY + data = kStringArray; + break; + default: + error("o7_dim2dimArray: default case %d", type); + } + + b = pop(); + a = pop(); + defineArray(fetchScriptWord(), data, a, b); +} + +void ScummEngine_v72he::o7_jumpToScript() { + if (_heversion <= 71) { + ScummEngine_v6::o6_jumpToScript(); + return; + } + int args[16]; + int script, flags; + + getStackList(args, ARRAYSIZE(args)); + script = pop(); + flags = fetchScriptByte(); + stopObjectCode(); + runScript(script, (flags == 199 || flags == 200), (flags == 195 || flags == 200), args); } void ScummEngine_v72he::o7_stringLen() { @@ -485,6 +638,10 @@ void ScummEngine_v72he::o7_unknownF4() { warning("o7_unknownF4 stub"); } +void ScummEngine_v72he::o7_unknownFA() { + warning("stub o7_unknownFA(%d)", fetchScriptByte()); +} + void ScummEngine_v72he::o7_unknownFB() { byte b; b = fetchScriptByte(); @@ -510,149 +667,4 @@ void ScummEngine_v72he::o7_unknownFB() { warning("o7_unknownFB stub"); } -void ScummEngine_v72he::o7_dim2dimArray() { - if (_heversion <= 71) { - ScummEngine_v6::o6_dim2dimArray(); - return; - } - - int a, b, data; - int type = fetchScriptByte(); - switch (type - 2) { - case 0: // SO_INT_ARRAY - data = kIntArray; - break; - case 1: // SO_BIT_ARRAY - data = kBitArray; - break; - case 2: // SO_NIBBLE_ARRAY - data = kNibbleArray; - break; - case 3: // SO_BYTE_ARRAY - data = kByteArray; - break; - case 4: // SO_STRING_ARRAY - data = kStringArray; - break; - default: - error("o7_dim2dimArray: default case %d", type); - } - - b = pop(); - a = pop(); - defineArray(fetchScriptWord(), data, a, b); -} - -void ScummEngine_v72he::o7_dimArray() { - if (_heversion <= 71) { - ScummEngine_v6::o6_dimArray(); - return; - } - - int data; - int type = fetchScriptByte(); - - switch (type) { - case 5: // SO_INT_ARRAY - data = kIntArray; - break; - case 2: // SO_BIT_ARRAY - data = kBitArray; - break; - case 3: // SO_NIBBLE_ARRAY - data = kNibbleArray; - break; - case 4: // SO_BYTE_ARRAY - data = kByteArray; - break; - case 7: // SO_STRING_ARRAY - data = kStringArray; - break; - case 204: // SO_UNDIM_ARRAY - nukeArray(fetchScriptWord()); - return; - default: - error("o7_dimArray: default case %d", type); - } - - defineArray(fetchScriptWord(), data, 0, pop()); -} - -void ScummEngine_v72he::o7_arrayOps() { - byte subOp = fetchScriptByte(); - int array = fetchScriptWord(); - int b, c, d, len; - ArrayHeader *ah; - int list[128]; - - switch (subOp) { - case 7: // SO_ASSIGN_STRING - len = resStrLen(_scriptPointer); - ah = defineArray(array, kStringArray, 0, len + 1); - copyScriptString(ah->data); - break; - case 205: // SO_ASSIGN_STRING - b = pop(); - len = resStrLen(_scriptPointer); - ah = defineArray(array, kStringArray, 0, len + 1); - copyScriptString(ah->data + b); - break; - case 208: // SO_ASSIGN_INT_LIST - b = pop(); - c = pop(); - d = readVar(array); - if (d == 0) { - defineArray(array, kIntArray, 0, b + c); - } - while (c--) { - writeArray(array, 0, b + c, pop()); - } - break; - case 212: // SO_ASSIGN_2DIM_LIST - b = pop(); - len = getStackList(list, ARRAYSIZE(list)); - d = readVar(array); - if (d == 0) - error("Must DIM a two dimensional array before assigning"); - c = pop(); - while (--len >= 0) { - writeArray(array, c, b + len, list[len]); - } - break; - default: - error("o7_arrayOps: default case %d (array %d)", subOp, array); - } -} - -void ScummEngine_v72he::o7_jumpToScript() { - if (_heversion <= 71) { - ScummEngine_v6::o6_jumpToScript(); - return; - } - int args[16]; - int script, flags; - - getStackList(args, ARRAYSIZE(args)); - script = pop(); - flags = fetchScriptByte(); - stopObjectCode(); - runScript(script, (flags == 199 || flags == 200), (flags == 195 || flags == 200), args); -} - -void ScummEngine_v72he::o7_startScript() { - if (_heversion <= 71) { - ScummEngine_v6::o6_startScript(); - return; - } - - int args[16]; - int script, flags; - - getStackList(args, ARRAYSIZE(args)); - script = pop(); - flags = fetchScriptByte(); - - runScript(script, (flags == 199 || flags == 200), (flags == 195 || flags == 200), args); -} - } // End of namespace Scumm diff --git a/scumm/script_v7he.cpp b/scumm/script_v7he.cpp index a5863b0d7f..94b0d051a6 100644 --- a/scumm/script_v7he.cpp +++ b/scumm/script_v7he.cpp @@ -386,31 +386,6 @@ const char *ScummEngine_v7he::getOpcodeDesc(byte i) { } -void ScummEngine_v7he::o7_unknownFA() { - int num = fetchScriptByte(); - int len = resStrLen(_scriptPointer); - warning("stub o7_unknownFA(%d, \"%s\")", num, _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; - } - - len = stringLen(addr); - push(len); -} - byte ScummEngine_v7he::stringLen(byte *ptr) { byte len; byte c; @@ -438,6 +413,185 @@ byte ScummEngine_v7he::stringLen(byte *ptr) { return len; } +void ScummEngine_v7he::o7_cursorCommand() { + int a, i; + int args[16]; + int subOp = fetchScriptByte(); + + switch (subOp) { + case 0x90: // SO_CURSOR_ON Turn cursor on + _cursor.state = 1; + verbMouseOver(0); + break; + case 0x91: // SO_CURSOR_OFF Turn cursor off + _cursor.state = 0; + verbMouseOver(0); + break; + case 0x92: // SO_USERPUT_ON + _userPut = 1; + break; + case 0x93: // SO_USERPUT_OFF + _userPut = 0; + break; + case 0x94: // SO_CURSOR_SOFT_ON Turn soft cursor on + _cursor.state++; + if (_cursor.state > 1) + error("Cursor state greater than 1 in script"); + verbMouseOver(0); + break; + case 0x95: // SO_CURSOR_SOFT_OFF Turn soft cursor off + _cursor.state--; + verbMouseOver(0); + break; + case 0x96: // SO_USERPUT_SOFT_ON + _userPut++; + break; + case 0x97: // SO_USERPUT_SOFT_OFF + _userPut--; + break; + case 0x99: // SO_CURSOR_IMAGE Set cursor image + _Win32ResExtractor->setCursor(pop()); /* Difference */ + break; + case 0x9A: // SO_CURSOR_HOTSPOT Set cursor hotspot + a = pop(); + setCursorHotspot(pop(), a); + break; + case 0x9C: // SO_CHARSET_SET + initCharset(pop()); + break; + case 0x9D: // SO_CHARSET_COLOR + getStackList(args, ARRAYSIZE(args)); + for (i = 0; i < 16; i++) + _charsetColorMap[i] = _charsetData[_string[1]._default.charset][i] = (unsigned char)args[i]; + break; + case 0xD6: // SO_CURSOR_TRANSPARENT Set cursor transparent color + setCursorTransparency(pop()); + break; + default: + error("o7_cursorCommand: default case %x", subOp); + } + + VAR(VAR_CURSORSTATE) = _cursor.state; + VAR(VAR_USERPUT) = _userPut; +} + +void ScummEngine_v7he::o7_startSound() { + byte op; + op = fetchScriptByte(); + + switch (op) { + case 224: + _heSndSoundFreq = pop(); + break; + + case 230: + _heSndTimer = pop(); + break; + + case 231: + _heSndOffset = pop(); + break; + + case 232: + _heSndSoundId = pop(); + _heSndOffset = 0; + _heSndSoundFreq = 11025; + _heSndTimer = VAR(VAR_MUSIC_TIMER); + break; + + case 245: + _heSndLoop |= 1; + break; + + case 255: + // _sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndTimer, _heSndLoop); + _sound->addSoundToQueue(_heSndSoundId, _heSndOffset); + debug(2, "o7_startSound stub (%d, %d, %d, %d)", _heSndSoundId, _heSndOffset, _heSndTimer, _heSndLoop); + _heSndLoop = 0; + break; + + default: + break; + } +} + +void ScummEngine_v7he::o7_pickupObject() { + int obj, room; + + room = pop(); + obj = pop(); + if (room == 0) + room = getObjectRoom(obj); + + addObjectToInventory(obj, room); + putOwner(obj, VAR(VAR_EGO)); + putClass(obj, kObjectClassUntouchable, 1); + putState(obj, 1); + markObjectRectAsDirty(obj); + clearDrawObjectQueue(); + runInventoryScript(obj); /* Difference */ +} + + +void ScummEngine_v7he::o7_getActorRoom() { + int act = pop(); + + if (act < _numActors) { + Actor *a = derefActor(act, "o7_getActorRoom"); + push(a->room); + } else + push(getObjectRoom(act)); +} + +void ScummEngine_v7he::o7_quitPauseRestart() { + byte subOp = fetchScriptByte(); + int par1; + + switch (subOp & 0xff) { + case 158: // SO_RESTART + restart(); + break; + case 160: + // FIXME: check + shutDown(); + break; + case 250: + par1 = pop(); + warning("stub: o7_quitPauseRestart subOpcode %d", subOp); + break; + case 253: + par1 = pop(); + warning("stub: o7_quitPauseRestart subOpcode %d", subOp); + case 244: // SO_QUIT + shutDown(); + break; + case 251: + case 252: + warning("stub: o7_quitPauseRestart subOpcode %d", subOp); + break; + default: + error("o7_quitPauseRestart invalid case %d", subOp); + } +} + +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; + } + + len = stringLen(addr); + push(len); +} + void ScummEngine_v7he::o7_readINI() { int len; int type; @@ -513,6 +667,13 @@ void ScummEngine_v7he::o7_unknownF9() { warning("stub o7_unknownF9(\"%s\")", filename + r); } +void ScummEngine_v7he::o7_unknownFA() { + int num = fetchScriptByte(); + int len = resStrLen(_scriptPointer); + warning("stub o7_unknownFA(%d, \"%s\")", num, _scriptPointer); + _scriptPointer += len + 1; +} + void ScummEngine_v7he::o7_unknownFB() { byte b; b = fetchScriptByte(); @@ -538,167 +699,4 @@ void ScummEngine_v7he::o7_unknownFB() { warning("o7_unknownFB stub"); } -void ScummEngine_v7he::o7_quitPauseRestart() { - byte subOp = fetchScriptByte(); - int par1; - - switch (subOp & 0xff) { - case 158: // SO_RESTART - restart(); - break; - case 160: - // FIXME: check - shutDown(); - break; - case 250: - par1 = pop(); - warning("stub: o7_quitPauseRestart subOpcode %d", subOp); - break; - case 253: - par1 = pop(); - warning("stub: o7_quitPauseRestart subOpcode %d", subOp); - case 244: // SO_QUIT - shutDown(); - break; - case 251: - case 252: - warning("stub: o7_quitPauseRestart subOpcode %d", subOp); - break; - default: - error("o7_quitPauseRestart invalid case %d", subOp); - } -} - -void ScummEngine_v7he::o7_pickupObject() { - int obj, room; - - room = pop(); - obj = pop(); - if (room == 0) - room = getObjectRoom(obj); - - addObjectToInventory(obj, room); - putOwner(obj, VAR(VAR_EGO)); - putClass(obj, kObjectClassUntouchable, 1); - putState(obj, 1); - markObjectRectAsDirty(obj); - clearDrawObjectQueue(); - runInventoryScript(obj); /* Difference */ -} - - -void ScummEngine_v7he::o7_getActorRoom() { - int act = pop(); - - if (act < _numActors) { - Actor *a = derefActor(act, "o7_getActorRoom"); - push(a->room); - } else - push(getObjectRoom(act)); -} - -void ScummEngine_v7he::o7_startSound() { - byte op; - op = fetchScriptByte(); - - switch (op) { - case 224: - _heSndSoundFreq = pop(); - break; - - case 230: - _heSndTimer = pop(); - break; - - case 231: - _heSndOffset = pop(); - break; - - case 232: - _heSndSoundId = pop(); - _heSndOffset = 0; - _heSndSoundFreq = 11025; - _heSndTimer = VAR(VAR_MUSIC_TIMER); - break; - - case 245: - _heSndLoop |= 1; - break; - - case 255: - // _sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndTimer, _heSndLoop); - _sound->addSoundToQueue(_heSndSoundId, _heSndOffset); - debug(2, "o7_startSound stub (%d, %d, %d, %d)", _heSndSoundId, _heSndOffset, _heSndTimer, _heSndLoop); - _heSndLoop = 0; - break; - - default: - break; - } -} - - -void ScummEngine_v7he::o7_cursorCommand() { - int a, i; - int args[16]; - int subOp = fetchScriptByte(); - - switch (subOp) { - case 0x90: // SO_CURSOR_ON Turn cursor on - _cursor.state = 1; - verbMouseOver(0); - break; - case 0x91: // SO_CURSOR_OFF Turn cursor off - _cursor.state = 0; - verbMouseOver(0); - break; - case 0x92: // SO_USERPUT_ON - _userPut = 1; - break; - case 0x93: // SO_USERPUT_OFF - _userPut = 0; - break; - case 0x94: // SO_CURSOR_SOFT_ON Turn soft cursor on - _cursor.state++; - if (_cursor.state > 1) - error("Cursor state greater than 1 in script"); - verbMouseOver(0); - break; - case 0x95: // SO_CURSOR_SOFT_OFF Turn soft cursor off - _cursor.state--; - verbMouseOver(0); - break; - case 0x96: // SO_USERPUT_SOFT_ON - _userPut++; - break; - case 0x97: // SO_USERPUT_SOFT_OFF - _userPut--; - break; - case 0x99: // SO_CURSOR_IMAGE Set cursor image - _Win32ResExtractor->setCursor(pop()); /* Difference */ - break; - case 0x9A: // SO_CURSOR_HOTSPOT Set cursor hotspot - a = pop(); - setCursorHotspot(pop(), a); - break; - case 0x9C: // SO_CHARSET_SET - initCharset(pop()); - break; - case 0x9D: // SO_CHARSET_COLOR - getStackList(args, ARRAYSIZE(args)); - for (i = 0; i < 16; i++) - _charsetColorMap[i] = _charsetData[_string[1]._default.charset][i] = (unsigned char)args[i]; - break; - case 0xD6: // SO_CURSOR_TRANSPARENT Set cursor transparent color - setCursorTransparency(pop()); - break; - default: - error("o7_cursorCommand: default case %x", subOp); - } - - VAR(VAR_CURSORSTATE) = _cursor.state; - VAR(VAR_USERPUT) = _userPut; -} - - } // End of namespace Scumm -- cgit v1.2.3