aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions
diff options
context:
space:
mode:
authorjohndoe1232014-03-18 16:17:38 +0100
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit18540a5e385997815f5a7c237328d7bc0b10c174 (patch)
tree2f34b07441f48e94175e8602beec912719ecf0b8 /engines/illusions
parent3fc592df497b957b42aa4eec27f8f77f899e0700 (diff)
downloadscummvm-rg350-18540a5e385997815f5a7c237328d7bc0b10c174.tar.gz
scummvm-rg350-18540a5e385997815f5a7c237328d7bc0b10c174.tar.bz2
scummvm-rg350-18540a5e385997815f5a7c237328d7bc0b10c174.zip
ILLUSIONS: Add SequenceOpcodes skeleton class
Diffstat (limited to 'engines/illusions')
-rw-r--r--engines/illusions/actor.cpp11
-rw-r--r--engines/illusions/actor.h5
-rw-r--r--engines/illusions/module.mk1
-rw-r--r--engines/illusions/scriptopcodes.cpp22
-rw-r--r--engines/illusions/scriptopcodes.h14
-rw-r--r--engines/illusions/scriptthread.cpp24
-rw-r--r--engines/illusions/scriptthread.h14
-rw-r--r--engines/illusions/sequenceopcodes.cpp74
-rw-r--r--engines/illusions/sequenceopcodes.h53
9 files changed, 181 insertions, 37 deletions
diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp
index c0a42a1432..74443c3aac 100644
--- a/engines/illusions/actor.cpp
+++ b/engines/illusions/actor.cpp
@@ -27,6 +27,7 @@
#include "illusions/input.h"
#include "illusions/screen.h"
#include "illusions/scriptman.h"
+#include "illusions/sequenceopcodes.h"
namespace Illusions {
@@ -570,10 +571,20 @@ void Control::startSequenceActorIntern(uint32 sequenceId, int value, int value2,
}
+void Control::execSequenceOpcode(OpCall &opCall) {
+ // TODO Clean this up
+ _vm->_controls->_sequenceOpcodes->execOpcode(this, opCall);
+}
+
// Controls
Controls::Controls(IllusionsEngine *vm)
: _vm(vm) {
+ _sequenceOpcodes = new SequenceOpcodes(_vm);
+}
+
+Controls::~Controls() {
+ delete _sequenceOpcodes;
}
void Controls::placeActor(uint32 actorTypeId, Common::Point placePt, uint32 sequenceId, uint32 objectId, uint32 notifyThreadId) {
diff --git a/engines/illusions/actor.h b/engines/illusions/actor.h
index d913710c14..0684ce1834 100644
--- a/engines/illusions/actor.h
+++ b/engines/illusions/actor.h
@@ -33,6 +33,8 @@
namespace Illusions {
class IllusionsEngine;
+class SequenceOpcodes;
+struct OpCall;
const uint kSubObjectsCount = 15;
@@ -176,11 +178,13 @@ public:
Common::Point _subobjectsPos[kSubObjectsCount];
// TODO 0000001C - 00000054 unknown
void startSequenceActorIntern(uint32 sequenceId, int value, int value2, uint32 notifyThreadId);
+ void execSequenceOpcode(OpCall &opCall);
};
class Controls {
public:
Controls(IllusionsEngine *vm);
+ ~Controls();
void placeActor(uint32 actorTypeId, Common::Point placePt, uint32 sequenceId, uint32 objectId, uint32 notifyThreadId);
void placeSequenceLessActor(uint32 objectId, Common::Point placePt, WidthHeight dimensions, int16 priority);
void placeActorLessObject(uint32 objectId, Common::Point feetPt, Common::Point pt, int16 priority, uint flags);
@@ -189,6 +193,7 @@ public:
typedef Items::iterator ItemsIterator;
IllusionsEngine *_vm;
Items _controls;
+ SequenceOpcodes *_sequenceOpcodes;
Actor *newActor();
Control *newControl();
void destroyControl(Control *control);
diff --git a/engines/illusions/module.mk b/engines/illusions/module.mk
index 149ed7d50f..eab667ee1b 100644
--- a/engines/illusions/module.mk
+++ b/engines/illusions/module.mk
@@ -17,6 +17,7 @@ MODULE_OBJS := \
scriptopcodes.o \
scriptresource.o \
scriptthread.o \
+ sequenceopcodes.o \
spritedecompressqueue.o \
spritedrawqueue.o \
thread.o \
diff --git a/engines/illusions/scriptopcodes.cpp b/engines/illusions/scriptopcodes.cpp
index ac38548faa..392170db57 100644
--- a/engines/illusions/scriptopcodes.cpp
+++ b/engines/illusions/scriptopcodes.cpp
@@ -28,6 +28,28 @@
namespace Illusions {
+// OpCall
+
+void OpCall::skip(uint size) {
+ _code += size;
+}
+
+byte OpCall::readByte() {
+ return *_code++;
+}
+
+int16 OpCall::readSint16() {
+ int16 value = READ_LE_UINT16(_code);
+ _code += 2;
+ return value;
+}
+
+uint32 OpCall::readUint32() {
+ uint32 value = READ_LE_UINT32(_code);
+ _code += 4;
+ return value;
+}
+
// ScriptOpcodes
ScriptOpcodes::ScriptOpcodes(IllusionsEngine *vm)
diff --git a/engines/illusions/scriptopcodes.h b/engines/illusions/scriptopcodes.h
index 78b68e5b59..3f79ea5eea 100644
--- a/engines/illusions/scriptopcodes.h
+++ b/engines/illusions/scriptopcodes.h
@@ -29,7 +29,19 @@ namespace Illusions {
class IllusionsEngine;
class ScriptThread;
-struct OpCall;
+
+struct OpCall {
+ byte _op;
+ byte _opSize;
+ uint32 _threadId;
+ int16 _deltaOfs;
+ byte *_code;
+ int _result;
+ void skip(uint size);
+ byte readByte();
+ int16 readSint16();
+ uint32 readUint32();
+};
typedef Common::Functor2<ScriptThread*, OpCall&, void> ScriptOpcode;
diff --git a/engines/illusions/scriptthread.cpp b/engines/illusions/scriptthread.cpp
index a594101107..6455cfb756 100644
--- a/engines/illusions/scriptthread.cpp
+++ b/engines/illusions/scriptthread.cpp
@@ -27,28 +27,6 @@
namespace Illusions {
-// OpCall
-
-void OpCall::skip(uint size) {
- _scriptCode += size;
-}
-
-byte OpCall::readByte() {
- return *_scriptCode++;
-}
-
-int16 OpCall::readSint16() {
- int16 value = READ_LE_UINT16(_scriptCode);
- _scriptCode += 2;
- return value;
-}
-
-uint32 OpCall::readUint32() {
- uint32 value = READ_LE_UINT32(_scriptCode);
- _scriptCode += 4;
- return value;
-}
-
// ScriptThread
ScriptThread::ScriptThread(IllusionsEngine *vm, uint32 threadId, uint32 callingThreadId, uint notifyFlags,
@@ -65,7 +43,7 @@ int ScriptThread::onUpdate() {
opCall._op = _scriptCodeIp[0];
opCall._opSize = _scriptCodeIp[1] >> 1;
opCall._threadId = _scriptCodeIp[1] & 1 ? _threadId : 0;
- opCall._scriptCode = _scriptCodeIp + 2;
+ opCall._code = _scriptCodeIp + 2;
opCall._deltaOfs = 0;
execOpcode(opCall);
_scriptCodeIp += opCall._opSize + opCall._deltaOfs;
diff --git a/engines/illusions/scriptthread.h b/engines/illusions/scriptthread.h
index 201e598756..f0d122bc70 100644
--- a/engines/illusions/scriptthread.h
+++ b/engines/illusions/scriptthread.h
@@ -28,19 +28,7 @@
namespace Illusions {
class IllusionsEngine;
-
-struct OpCall {
- byte _op;
- byte _opSize;
- uint32 _threadId;
- int16 _deltaOfs;
- byte *_scriptCode;
- int _result;
- void skip(uint size);
- byte readByte();
- int16 readSint16();
- uint32 readUint32();
-};
+struct OpCall;
class ScriptThread : public Thread {
public:
diff --git a/engines/illusions/sequenceopcodes.cpp b/engines/illusions/sequenceopcodes.cpp
new file mode 100644
index 0000000000..22845f0944
--- /dev/null
+++ b/engines/illusions/sequenceopcodes.cpp
@@ -0,0 +1,74 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "illusions/illusions.h"
+#include "illusions/sequenceopcodes.h"
+#include "illusions/actor.h"
+#include "illusions/actorresource.h"
+#include "illusions/scriptopcodes.h"
+
+namespace Illusions {
+
+// SequenceOpcodes
+
+SequenceOpcodes::SequenceOpcodes(IllusionsEngine *vm)
+ : _vm(vm) {
+ initOpcodes();
+}
+
+SequenceOpcodes::~SequenceOpcodes() {
+ freeOpcodes();
+}
+
+void SequenceOpcodes::execOpcode(Control *control, OpCall &opCall) {
+ if (!_opcodes[opCall._op])
+ error("SequenceOpcodes::execOpcode() Unimplemented opcode %d", opCall._op);
+ debug("execOpcode(%d)", opCall._op);
+ (*_opcodes[opCall._op])(control, opCall);
+}
+
+typedef Common::Functor2Mem<ScriptThread*, OpCall&, void, SequenceOpcodes> SequenceOpcodeI;
+#define OPCODE(op, func) _opcodes[op] = new SequenceOpcodeI(this, &SequenceOpcodes::func);
+
+void SequenceOpcodes::initOpcodes() {
+ // First clear everything
+ for (uint i = 0; i < 256; ++i)
+ _opcodes[i] = 0;
+ // Register opcodes
+ //OPCODE(42, opIncBlockCounter);
+}
+
+#undef OPCODE
+
+void SequenceOpcodes::freeOpcodes() {
+ for (uint i = 0; i < 256; ++i)
+ delete _opcodes[i];
+}
+
+// Opcodes
+
+// Convenience macros
+#define ARG_SKIP(x) opCall.skip(x);
+#define ARG_INT16(name) int16 name = opCall.readSint16(); debug("ARG_INT16(" #name " = %d)", name);
+#define ARG_UINT32(name) uint32 name = opCall.readUint32(); debug("ARG_UINT32(" #name " = %d)", name);
+
+} // End of namespace Illusions
diff --git a/engines/illusions/sequenceopcodes.h b/engines/illusions/sequenceopcodes.h
new file mode 100644
index 0000000000..aa31a76176
--- /dev/null
+++ b/engines/illusions/sequenceopcodes.h
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ILLUSIONS_SEQUENCEOPCODES_H
+#define ILLUSIONS_SEQUENCEOPCODES_H
+
+#include "common/func.h"
+
+namespace Illusions {
+
+class IllusionsEngine;
+class Control;
+struct OpCall;
+
+typedef Common::Functor2<Control*, OpCall&, void> SequenceOpcode;
+
+class SequenceOpcodes {
+public:
+ SequenceOpcodes(IllusionsEngine *vm);
+ ~SequenceOpcodes();
+ void execOpcode(Control *control, OpCall &opCall);
+protected:
+ IllusionsEngine *_vm;
+ SequenceOpcode *_opcodes[256];
+ void initOpcodes();
+ void freeOpcodes();
+
+ // Opcodes
+
+};
+
+} // End of namespace Illusions
+
+#endif // ILLUSIONS_SEQUENCEOPCODES_H