aboutsummaryrefslogtreecommitdiff
path: root/engines/director
diff options
context:
space:
mode:
Diffstat (limited to 'engines/director')
-rw-r--r--engines/director/lingo/lingo-bytecode.cpp442
-rw-r--r--engines/director/lingo/lingo-events.cpp12
-rw-r--r--engines/director/lingo/lingo.cpp12
-rw-r--r--engines/director/lingo/lingo.h30
4 files changed, 248 insertions, 248 deletions
diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index 87045e2738..3b800f8fd9 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -25,46 +25,46 @@
namespace Director {
static struct LingoV4Bytecode {
- const uint8 opcode;
- const inst func;
- const char *proto;
+ const uint8 opcode;
+ const inst func;
+ const char *proto;
} lingoV4[] = {
- { 0x03, Lingo::c_voidpush, "" },
- { 0x04, Lingo::c_mul, "" },
- { 0x05, Lingo::c_add, "" },
- { 0x06, Lingo::c_sub, "" },
- { 0x07, Lingo::c_div, "" },
- { 0x08, Lingo::c_mod, "" },
- { 0x09, Lingo::c_negate, "" },
- { 0x0a, Lingo::c_ampersand, "" },
- { 0x0b, Lingo::c_concat, "" },
- { 0x0c, Lingo::c_lt, "" },
- { 0x0d, Lingo::c_le, "" },
- { 0x0e, Lingo::c_neq, "" },
- { 0x0f, Lingo::c_eq, "" },
- { 0x10, Lingo::c_gt, "" },
- { 0x11, Lingo::c_ge, "" },
- { 0x12, Lingo::c_and, "" },
- { 0x13, Lingo::c_or, "" },
- { 0x14, Lingo::c_not, "" },
- { 0x15, Lingo::c_contains, "" },
- { 0x16, Lingo::c_starts, "" },
- { 0x17, Lingo::c_of, "" },
- { 0x18, Lingo::c_hilite, "" },
- { 0x19, Lingo::c_intersects, "" },
- { 0x1a, Lingo::c_within, "" },
- { 0x1b, Lingo::c_field, "" },
- { 0x1c, Lingo::c_tell, "" },
- { 0x1d, Lingo::c_telldone, "" },
-
- { 0x41, Lingo::c_intpush, "b" },
- { 0, 0, 0 }
+ { 0x03, Lingo::c_voidpush, "" },
+ { 0x04, Lingo::c_mul, "" },
+ { 0x05, Lingo::c_add, "" },
+ { 0x06, Lingo::c_sub, "" },
+ { 0x07, Lingo::c_div, "" },
+ { 0x08, Lingo::c_mod, "" },
+ { 0x09, Lingo::c_negate, "" },
+ { 0x0a, Lingo::c_ampersand, "" },
+ { 0x0b, Lingo::c_concat, "" },
+ { 0x0c, Lingo::c_lt, "" },
+ { 0x0d, Lingo::c_le, "" },
+ { 0x0e, Lingo::c_neq, "" },
+ { 0x0f, Lingo::c_eq, "" },
+ { 0x10, Lingo::c_gt, "" },
+ { 0x11, Lingo::c_ge, "" },
+ { 0x12, Lingo::c_and, "" },
+ { 0x13, Lingo::c_or, "" },
+ { 0x14, Lingo::c_not, "" },
+ { 0x15, Lingo::c_contains, "" },
+ { 0x16, Lingo::c_starts, "" },
+ { 0x17, Lingo::c_of, "" },
+ { 0x18, Lingo::c_hilite, "" },
+ { 0x19, Lingo::c_intersects, "" },
+ { 0x1a, Lingo::c_within, "" },
+ { 0x1b, Lingo::c_field, "" },
+ { 0x1c, Lingo::c_tell, "" },
+ { 0x1d, Lingo::c_telldone, "" },
+
+ { 0x41, Lingo::c_intpush, "b" },
+ { 0, 0, 0 }
};
void Lingo::initBytecode() {
- for (LingoV4Bytecode *op = lingoV4; op->opcode; op++) {
- _lingoV4[op->opcode] = new Opcode( op->func, op->proto );
- }
+ for (LingoV4Bytecode *op = lingoV4; op->opcode; op++) {
+ _lingoV4[op->opcode] = new Opcode( op->func, op->proto );
+ }
}
@@ -73,208 +73,208 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
if (_scriptContexts[type].contains(id)) {
for (size_t j = 0; j < _scriptContexts[type][id]->functions.size(); j++) {
- delete _scriptContexts[type][id]->functions[j];
- }
- delete _scriptContexts[type][id];
+ delete _scriptContexts[type][id]->functions[j];
+ }
+ delete _scriptContexts[type][id];
}
- _currentScriptContext = new ScriptContext;
- _currentScriptType = type;
- _currentEntityId = id;
- _scriptContexts[type][id] = _currentScriptContext;
+ _currentScriptContext = new ScriptContext;
+ _currentScriptType = type;
+ _currentEntityId = id;
+ _scriptContexts[type][id] = _currentScriptContext;
- // read the Lscr header!
- // unk1
- for (uint32 i = 0; i < 0x10; i++) {
- stream.readByte();
- }
- uint16 code_store_offset = stream.readUint16();
- // unk2
- for (uint32 i = 0; i < 0x2e; i++) {
- stream.readByte();
- }
- uint16 functions_offset = stream.readUint16();
- // unk3
- for (uint32 i = 0; i < 0x6; i++) {
- stream.readByte();
- }
- uint16 functions_count = stream.readUint16();
- stream.readUint16();
- stream.readUint16();
- uint16 consts_count = stream.readUint16();
- stream.readUint16();
- uint16 consts_offset = stream.readUint16();
- stream.readUint16();
- stream.readUint16();
- stream.readUint16();
- uint16 consts_base = stream.readUint16();
+ // read the Lscr header!
+ // unk1
+ for (uint32 i = 0; i < 0x10; i++) {
+ stream.readByte();
+ }
+ uint16 code_store_offset = stream.readUint16();
+ // unk2
+ for (uint32 i = 0; i < 0x2e; i++) {
+ stream.readByte();
+ }
+ uint16 functions_offset = stream.readUint16();
+ // unk3
+ for (uint32 i = 0; i < 0x6; i++) {
+ stream.readByte();
+ }
+ uint16 functions_count = stream.readUint16();
+ stream.readUint16();
+ stream.readUint16();
+ uint16 consts_count = stream.readUint16();
+ stream.readUint16();
+ uint16 consts_offset = stream.readUint16();
+ stream.readUint16();
+ stream.readUint16();
+ stream.readUint16();
+ uint16 consts_base = stream.readUint16();
- // preload all the constants!
- // these are stored as a reference table of 6 byte entries, followed by a storage area.
+ // preload all the constants!
+ // these are stored as a reference table of 6 byte entries, followed by a storage area.
- // copy the storage area first.
- uint32 consts_store_offset = consts_offset+6*consts_count;
- uint32 consts_store_size = stream.size()-consts_store_offset;
- stream.seek(consts_store_offset);
- byte *const_store = (byte *)malloc(consts_store_size);
- stream.read(const_store, consts_store_size);
+ // copy the storage area first.
+ uint32 consts_store_offset = consts_offset+6*consts_count;
+ uint32 consts_store_size = stream.size()-consts_store_offset;
+ stream.seek(consts_store_offset);
+ byte *const_store = (byte *)malloc(consts_store_size);
+ stream.read(const_store, consts_store_size);
- Common::Array<Datum> const_data;
+ Common::Array<Datum> const_data;
- // read each entry in the reference table.
- stream.seek(consts_offset);
- for (uint16 i=0; i<consts_count; i++) {
- Datum constant;
- uint16 const_type = stream.readUint16();
- uint32 value = stream.readUint32();
- switch (const_type) {
- case 1: { // String type
- constant.type = STRING;
- constant.u.s = new Common::String();
- uint32 pointer = value;
- while (pointer < consts_store_size) {
- if (const_store[pointer] == '\r') {
- constant.u.s += '\n';
- } else if (const_store[pointer] == '\0') {
- break;
- } else {
- constant.u.s += const_store[pointer];
- }
- pointer += 1;
- }
- if (pointer >= consts_store_size) {
- warning("Constant string has no null terminator");
- break;
- }
- }
- break;
- case 4: // Integer type
- constant.type = INT;
- constant.u.i = (int)value;
- break;
- case 9: { // Float type
- constant.type = FLOAT;
- if (value < consts_store_offset) {
- warning("Constant float start offset is out of bounds");
- break;
- } else if (value+4 > consts_store_size) {
- warning("Constant float end offset is out of bounds");
- break;
- }
- constant.u.f = *(float *)(const_store+value);
- }
- break;
- default:
- warning("Unknown constant type %d", type);
- break;
- }
+ // read each entry in the reference table.
+ stream.seek(consts_offset);
+ for (uint16 i=0; i<consts_count; i++) {
+ Datum constant;
+ uint16 const_type = stream.readUint16();
+ uint32 value = stream.readUint32();
+ switch (const_type) {
+ case 1: { // String type
+ constant.type = STRING;
+ constant.u.s = new Common::String();
+ uint32 pointer = value;
+ while (pointer < consts_store_size) {
+ if (const_store[pointer] == '\r') {
+ constant.u.s += '\n';
+ } else if (const_store[pointer] == '\0') {
+ break;
+ } else {
+ constant.u.s += const_store[pointer];
+ }
+ pointer += 1;
+ }
+ if (pointer >= consts_store_size) {
+ warning("Constant string has no null terminator");
+ break;
+ }
+ }
+ break;
+ case 4: // Integer type
+ constant.type = INT;
+ constant.u.i = (int)value;
+ break;
+ case 9: { // Float type
+ constant.type = FLOAT;
+ if (value < consts_store_offset) {
+ warning("Constant float start offset is out of bounds");
+ break;
+ } else if (value+4 > consts_store_size) {
+ warning("Constant float end offset is out of bounds");
+ break;
+ }
+ constant.u.f = *(float *)(const_store+value);
+ }
+ break;
+ default:
+ warning("Unknown constant type %d", type);
+ break;
+ }
- const_data.push_back(constant);
- }
- free(const_store);
+ const_data.push_back(constant);
+ }
+ free(const_store);
- // parse each function!
- // these are stored as a code storage area, followed by a reference table of 42 byte entries.
+ // parse each function!
+ // these are stored as a code storage area, followed by a reference table of 42 byte entries.
- // copy the storage area first.
- uint32 code_store_size = functions_offset - code_store_offset;
- stream.seek(code_store_offset);
- byte *code_store = (byte *)malloc(code_store_size);
- stream.read(code_store, code_store_size);
+ // copy the storage area first.
+ uint32 code_store_size = functions_offset - code_store_offset;
+ stream.seek(code_store_offset);
+ byte *code_store = (byte *)malloc(code_store_size);
+ stream.read(code_store, code_store_size);
- // read each entry in the function table.
- stream.seek(functions_offset);
- for (uint16 i=0; i<functions_count; i++) {
- _currentScriptFunction = i;
- _currentScriptContext->functions.push_back(new ScriptData);
- _currentScript = _currentScriptContext->functions[_currentScriptFunction];
+ // read each entry in the function table.
+ stream.seek(functions_offset);
+ for (uint16 i=0; i<functions_count; i++) {
+ _currentScriptFunction = i;
+ _currentScriptContext->functions.push_back(new ScriptData);
+ _currentScript = _currentScriptContext->functions[_currentScriptFunction];
- uint16 name_index = 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();
- stream.readUint16();
- stream.readUint16();
- stream.readUint16();
- stream.readUint16();
- stream.readUint16();
- stream.readUint16();
- stream.readUint16();
+ uint16 name_index = 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();
+ stream.readUint16();
+ stream.readUint16();
+ stream.readUint16();
+ stream.readUint16();
+ stream.readUint16();
+ stream.readUint16();
+ stream.readUint16();
- if (start_offset < code_store_offset) {
- warning("Function %d start offset is out of bounds!", i);
- continue;
- } else if (start_offset + length >= code_store_offset + code_store_size) {
- warning("Function %d end offset is out of bounds", i);
- continue;
- }
+ if (start_offset < code_store_offset) {
+ warning("Function %d start offset is out of bounds!", i);
+ continue;
+ } 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 < start_offset+length-code_store_offset) {
- uint8 opcode = code_store[pointer];
+ uint16 pointer = start_offset-code_store_offset;
+ Common::Array<uint32> offset_list;
+ while (pointer < start_offset+length-code_store_offset) {
+ uint8 opcode = code_store[pointer];
- pointer += 1;
- if (_lingoV4.contains(opcode)) {
- offset_list.push_back(_currentScript->size());
- g_lingo->code1(_lingoV4[opcode]->func);
- size_t argc = strlen(_lingoV4[opcode]->proto);
- for (uint c=0; c<argc; c++) {
- switch (_lingoV4[opcode]->proto[c]) {
- case 'b':
- offset_list.push_back(_currentScript->size());
- g_lingo->codeInt((int8)code_store[pointer]);
- pointer += 1;
- break;
- case 'w':
- offset_list.push_back(_currentScript->size());
- offset_list.push_back(_currentScript->size());
- g_lingo->codeInt((int16)READ_UINT16(&code_store[pointer]));
- pointer += 2;
- break;
- default:
- break;
- }
- }
+ pointer += 1;
+ if (_lingoV4.contains(opcode)) {
+ offset_list.push_back(_currentScript->size());
+ g_lingo->code1(_lingoV4[opcode]->func);
+ size_t argc = strlen(_lingoV4[opcode]->proto);
+ for (uint c=0; c<argc; c++) {
+ switch (_lingoV4[opcode]->proto[c]) {
+ case 'b':
+ offset_list.push_back(_currentScript->size());
+ g_lingo->codeInt((int8)code_store[pointer]);
+ pointer += 1;
+ break;
+ case 'w':
+ offset_list.push_back(_currentScript->size());
+ offset_list.push_back(_currentScript->size());
+ g_lingo->codeInt((int16)READ_UINT16(&code_store[pointer]));
+ pointer += 2;
+ break;
+ default:
+ break;
+ }
+ }
- } else {
- // exit condition
- if (opcode == 0x01) {
- offset_list.push_back(_currentScript->size());
- g_lingo->code1(STOP);
- // unimplemented instruction
- } else if (opcode < 0x40) { // 1 byte instruction
- offset_list.push_back(_currentScript->size());
- g_lingo->code1(Lingo::c_unk);
- g_lingo->codeInt(opcode);
- } else if (opcode < 0x80) { // 2 byte instruction
- offset_list.push_back(_currentScript->size());
- 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 { // 3 byte instruction
- offset_list.push_back(_currentScript->size());
- g_lingo->code1(Lingo::c_unk2);
- g_lingo->codeInt(opcode);
- offset_list.push_back(_currentScript->size());
- g_lingo->codeInt((uint)code_store[pointer]);
- offset_list.push_back(_currentScript->size());
- g_lingo->codeInt((uint)code_store[pointer+1]);
- pointer += 2;
- }
- }
- }
+ } else {
+ // exit condition
+ if (opcode == 0x01) {
+ offset_list.push_back(_currentScript->size());
+ g_lingo->code1(STOP);
+ // unimplemented instruction
+ } else if (opcode < 0x40) { // 1 byte instruction
+ offset_list.push_back(_currentScript->size());
+ g_lingo->code1(Lingo::c_unk);
+ g_lingo->codeInt(opcode);
+ } else if (opcode < 0x80) { // 2 byte instruction
+ offset_list.push_back(_currentScript->size());
+ 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 { // 3 byte instruction
+ offset_list.push_back(_currentScript->size());
+ g_lingo->code1(Lingo::c_unk2);
+ g_lingo->codeInt(opcode);
+ offset_list.push_back(_currentScript->size());
+ g_lingo->codeInt((uint)code_store[pointer]);
+ offset_list.push_back(_currentScript->size());
+ g_lingo->codeInt((uint)code_store[pointer+1]);
+ pointer += 2;
+ }
+ }
+ }
- }
- free(code_store);
+ }
+ free(code_store);
}
}
diff --git a/engines/director/lingo/lingo-events.cpp b/engines/director/lingo/lingo-events.cpp
index cc69cf4267..f1ed151823 100644
--- a/engines/director/lingo/lingo-events.cpp
+++ b/engines/director/lingo/lingo-events.cpp
@@ -39,11 +39,11 @@ struct EventHandlerType {
{ kEventBeginSprite, "beginSprite" },
{ kEventEndSprite, "endSprite" },
- { kEventEnterFrame, "enterFrame" }, // D4
- { kEventPrepareFrame, "prepareFrame" },
+ { kEventEnterFrame, "enterFrame" }, // D4
+ { kEventPrepareFrame, "prepareFrame" },
{ kEventIdle, "idle" },
{ kEventStepFrame, "stepFrame"},
- { kEventExitFrame, "exitFrame" }, // D4
+ { kEventExitFrame, "exitFrame" }, // D4
{ kEventActivateWindow, "activateWindow" },
{ kEventDeactivateWindow, "deactivateWindow" },
@@ -200,7 +200,7 @@ void Lingo::runMovieScript(LEvent event) {
void Lingo::processFrameEvent(LEvent event) {
/* [in D4] the enterFrame, exitFrame, idle and timeout messages
- * are sent to a frame script and then a movie script. If the
+ * are sent to a frame script and then a movie script. If the
* current frame has no frame script when the event occurs, the
* message goes to movie scripts.
* [p.81 of D4 docs]
@@ -224,8 +224,8 @@ void Lingo::processFrameEvent(LEvent event) {
entity = score->_frames[score->getCurrentFrame()]->_actionId;
}
processEvent(event,
- kFrameScript,
- entity);
+ kFrameScript,
+ entity);
runMovieScript(event);
}
}
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 25e3ca4061..b0af7945b6 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -73,7 +73,7 @@ Lingo::Lingo(DirectorEngine *vm) : _vm(vm) {
initBuiltIns();
initFuncs();
- initBytecode();
+ initBytecode();
initTheEntities();
warning("Lingo Inited");
@@ -221,7 +221,7 @@ void Lingo::executeScript(ScriptType type, uint16 id, uint16 function) {
debugC(1, kDebugLingoExec, "Executing script type: %s, id: %d, function: %d", scriptType2str(type), id, function);
_currentScriptContext = _scriptContexts[type][id];
- _currentScript = _currentScriptContext->functions[function];
+ _currentScript = _currentScriptContext->functions[function];
_pc = 0;
_returning = false;
@@ -237,11 +237,11 @@ void Lingo::restartLingo() {
for (int i = 0; i <= kMaxScriptType; i++) {
for (ScriptContextHash::iterator it = _scriptContexts[i].begin(); it != _scriptContexts[i].end(); ++it) {
- for (size_t j = 0; j < it->_value->functions.size(); j++) {
- delete it->_value->functions[j];
- }
+ for (size_t j = 0; j < it->_value->functions.size(); j++) {
+ delete it->_value->functions[j];
+ }
delete it->_value;
- }
+ }
_scriptContexts[i].clear();
}
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 72aea5e9d5..35507e111c 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -90,10 +90,10 @@ struct FuncDesc {
typedef Common::HashMap<void *, FuncDesc *> FuncHash;
struct Opcode {
- inst func;
- const char *proto;
+ inst func;
+ const char *proto;
- Opcode(inst f, const char *p) { func = f; proto = p; }
+ Opcode(inst f, const char *p) { func = f; proto = p; }
};
typedef Common::HashMap<int, Opcode *> OpcodeHash;
@@ -149,7 +149,7 @@ struct Builtin {
};
struct ScriptContext {
- Common::Array<ScriptData *> functions;
+ Common::Array<ScriptData *> functions;
};
typedef Common::HashMap<int32, ScriptContext *> ScriptContextHash;
@@ -182,7 +182,7 @@ public:
void initBuiltIns();
void initFuncs();
- void initBytecode();
+ void initBytecode();
void initTheEntities();
void runTests();
@@ -267,8 +267,8 @@ public:
static void c_intersects();
static void c_within();
- static void c_field();
- static void c_of();
+ static void c_field();
+ static void c_of();
static void c_charOf();
static void c_charToOf();
static void c_itemOf();
@@ -330,15 +330,15 @@ public:
static void c_playdone();
static void c_open();
- static void c_hilite();
+ static void c_hilite();
- static void c_jump();
- static void c_jumpif();
+ static void c_jump();
+ static void c_jumpif();
- // stubs for unknown instructions
- static void c_unk();
- static void c_unk1();
- static void c_unk2();
+ // 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);
@@ -588,7 +588,7 @@ private:
FuncHash _functions;
- OpcodeHash _lingoV4;
+ OpcodeHash _lingoV4;
uint _pc;