diff options
author | Scott Percival | 2019-10-30 00:12:21 +0800 |
---|---|---|
committer | Eugene Sandulenko | 2019-11-17 22:31:54 +0100 |
commit | 3891161b4c61c46a4454ab3d2f8e8230ef8d221c (patch) | |
tree | 10224341d08eded7fb0ed2906d8eee6d53be3a62 /engines/director | |
parent | e0ae924f45a43dab6fc9842d9469afb9d46f5c72 (diff) | |
download | scummvm-rg350-3891161b4c61c46a4454ab3d2f8e8230ef8d221c.tar.gz scummvm-rg350-3891161b4c61c46a4454ab3d2f8e8230ef8d221c.tar.bz2 scummvm-rg350-3891161b4c61c46a4454ab3d2f8e8230ef8d221c.zip |
DIRECTOR: Fix script function model, rename c_nop to c_unk.
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/lingo/lingo-bytecode.cpp | 52 | ||||
-rw-r--r-- | engines/director/lingo/lingo-code.cpp | 18 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 7 |
3 files changed, 35 insertions, 42 deletions
diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp index 41dce3dad8..832566c44a 100644 --- a/engines/director/lingo/lingo-bytecode.cpp +++ b/engines/director/lingo/lingo-bytecode.cpp @@ -128,11 +128,7 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty case 1: { // String type constant.type = STRING; constant.u.s = new Common::String(); - if (value < consts_store_offset) { - warning("Constant string start offset is out of bounds!"); - break; - } - uint32 pointer = value - consts_store_offset; + uint32 pointer = value; while (pointer < consts_store_size) { if (const_store[pointer] == '\r') { constant.u.s += '\n'; @@ -143,8 +139,8 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty } pointer += 1; } - if (pointer == consts_store_size) { - warning("Constant string has no null terminator!"); + if (pointer >= consts_store_size) { + warning("Constant string has no null terminator"); break; } } @@ -156,13 +152,13 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty case 9: { // Float type constant.type = FLOAT; if (value < consts_store_offset) { - warning("Constant float start offset is out of bounds!"); + warning("Constant float start offset is out of bounds"); break; - } else if (value+4 > consts_store_offset + consts_store_size) { - warning("Constant float end offset is out of bounds!"); + } else if (value+4 > consts_store_size) { + warning("Constant float end offset is out of bounds"); break; } - constant.u.f = *(float *)(const_store+value-consts_store_offset); + constant.u.f = *(float *)(const_store+value); } break; default: @@ -186,39 +182,35 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty // read each entry in the function table. stream.seek(functions_offset); for (uint16 i=0; i<functions_count; i++) { + uint16 name_index = stream.readUint16(); stream.readUint16(); - stream.readUint16(); - stream.readUint16(); - stream.readUint16(); - stream.readUint16(); - stream.readUint16(); + uint32 length = stream.readUint32(); + uint32 start_offset = stream.readUint32(); uint16 arg_count = stream.readUint16(); + uint32 arg_offset = stream.readUint32(); + uint16 var_count = stream.readUint16(); + uint32 var_names_offset = stream.readUint32(); stream.readUint16(); stream.readUint16(); - uint16 var_count = stream.readUint16(); stream.readUint16(); stream.readUint16(); - uint16 name_index = stream.readUint16(); stream.readUint16(); stream.readUint16(); - uint16 length = stream.readUint16(); stream.readUint16(); - uint16 start_offset = stream.readUint16(); stream.readUint16(); stream.readUint16(); - uint16 end_offset = stream.readUint16(); if (start_offset < code_store_offset) { warning("Function %d start offset is out of bounds!", i); continue; - } else if (end_offset >= code_store_offset+code_store_size) { - warning("Function %d end offset is out of bounds!", i); + } else if (start_offset + length >= code_store_offset + code_store_size) { + warning("Function %d end offset is out of bounds", i); continue; } uint16 pointer = start_offset-code_store_offset; Common::Array<uint32> offset_list; - while (pointer < end_offset-code_store_offset) { + while (pointer < start_offset+length-code_store_offset) { uint8 opcode = code_store[pointer]; pointer += 1; @@ -247,20 +239,20 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty } else { // unimplemented instruction - if (opcode < 0x40) { + if (opcode < 0x40) { // 1 byte instruction offset_list.push_back(_currentScript->size()); - g_lingo->code1(Lingo::c_nop); + g_lingo->code1(Lingo::c_unk); g_lingo->codeInt(opcode); - } else if (opcode < 0x80) { + } else if (opcode < 0x80) { // 2 byte instruction offset_list.push_back(_currentScript->size()); - g_lingo->code1(Lingo::c_nop1); + g_lingo->code1(Lingo::c_unk1); g_lingo->codeInt(opcode); offset_list.push_back(_currentScript->size()); g_lingo->codeInt((uint)code_store[pointer]); pointer += 1; - } else { + } else { // 3 byte instruction offset_list.push_back(_currentScript->size()); - g_lingo->code1(Lingo::c_nop2); + g_lingo->code1(Lingo::c_unk2); g_lingo->codeInt(opcode); offset_list.push_back(_currentScript->size()); g_lingo->codeInt((uint)code_store[pointer]); diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index 14f08719a9..819053f89b 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -128,9 +128,9 @@ static struct FuncDescr { { Lingo::c_hilite, "c_hilite", "" }, { Lingo::c_jump, "c_jump", "" }, { Lingo::c_jumpif, "c_jumpif", "" }, - { Lingo::c_nop, "c_nop", "i" }, - { Lingo::c_nop1, "c_nop1", "ii" }, - { Lingo::c_nop2, "c_nop2", "iii" }, + { Lingo::c_unk, "c_unk", "i" }, + { Lingo::c_unk1, "c_unk1", "ii" }, + { Lingo::c_unk2, "c_unk2", "iii" }, { 0, 0, 0 } }; @@ -1275,27 +1275,27 @@ void Lingo::c_jumpif() { } -void Lingo::c_nop() { +void Lingo::c_unk() { int savepc = g_lingo->_pc; uint opcode = READ_UINT32(&(*g_lingo->_currentScript)[savepc]); - warning("STUB: c_nop: %d", opcode); + warning("STUB: opcode 0x%02x", opcode); g_lingo->_pc += 1; } -void Lingo::c_nop1() { +void Lingo::c_unk1() { int savepc = g_lingo->_pc; uint opcode = READ_UINT32(&(*g_lingo->_currentScript)[savepc]); uint arg1 = READ_UINT32(&(*g_lingo->_currentScript)[savepc+1]); - warning("STUB: c_nop1: %d %d", opcode, arg1); + warning("STUB: opcode 0x%02x (%d)", opcode, arg1); g_lingo->_pc += 2; } -void Lingo::c_nop2() { +void Lingo::c_unk2() { int savepc = g_lingo->_pc; uint opcode = READ_UINT32(&(*g_lingo->_currentScript)[savepc]); uint arg1 = READ_UINT32(&(*g_lingo->_currentScript)[savepc+1]); uint arg2 = READ_UINT32(&(*g_lingo->_currentScript)[savepc+2]); - warning("STUB: c_nop2: %d %d %d", opcode, arg1, arg2); + warning("STUB: opcode 0x%02x (%d, %d)", opcode, arg1, arg2); g_lingo->_pc += 3; } diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 3227786666..4e8e711cd4 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -331,9 +331,10 @@ public: static void c_jump(); static void c_jumpif(); - static void c_nop(); - static void c_nop1(); - static void c_nop2(); + // stubs for unknown instructions + static void c_unk(); + static void c_unk1(); + static void c_unk2(); void printSTUBWithArglist(const char *funcname, int nargs, const char *prefix = "STUB:"); void convertVOIDtoString(int arg, int nargs); |