diff options
| author | johndoe123 | 2014-03-13 19:55:25 +0100 |
|---|---|---|
| committer | Eugene Sandulenko | 2018-07-20 06:43:33 +0000 |
| commit | 9d35f807ecc0cbc7a98a987c02d58d795706ed1f (patch) | |
| tree | d92c9e062265b56d2c2797d39f950494b83530ac /engines/illusions/scriptopcodes.cpp | |
| parent | 9696eb9a546891bf7ff601d94f7a8a2ff6730349 (diff) | |
| download | scummvm-rg350-9d35f807ecc0cbc7a98a987c02d58d795706ed1f.tar.gz scummvm-rg350-9d35f807ecc0cbc7a98a987c02d58d795706ed1f.tar.bz2 scummvm-rg350-9d35f807ecc0cbc7a98a987c02d58d795706ed1f.zip | |
ILLUSIONS: More work on the script system
Diffstat (limited to 'engines/illusions/scriptopcodes.cpp')
| -rw-r--r-- | engines/illusions/scriptopcodes.cpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/engines/illusions/scriptopcodes.cpp b/engines/illusions/scriptopcodes.cpp new file mode 100644 index 0000000000..ac38548faa --- /dev/null +++ b/engines/illusions/scriptopcodes.cpp @@ -0,0 +1,86 @@ +/* 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/scriptopcodes.h" +#include "illusions/scriptman.h" +#include "illusions/scriptresource.h" +#include "illusions/scriptthread.h" + +namespace Illusions { + +// ScriptOpcodes + +ScriptOpcodes::ScriptOpcodes(IllusionsEngine *vm) + : _vm(vm) { + initOpcodes(); +} + +ScriptOpcodes::~ScriptOpcodes() { + freeOpcodes(); +} + +void ScriptOpcodes::execOpcode(ScriptThread *scriptThread, OpCall &opCall) { + if (!_opcodes[opCall._op]) + error("ScriptOpcodes::execOpcode() Unimplemented opcode %d", opCall._op); + debug("execOpcode(%d)", opCall._op); + (*_opcodes[opCall._op])(scriptThread, opCall); +} + +typedef Common::Functor2Mem<ScriptThread*, OpCall&, void, ScriptOpcodes> ScriptOpcodeI; +#define OPCODE(op, func) _opcodes[op] = new ScriptOpcodeI(this, &ScriptOpcodes::func); + +void ScriptOpcodes::initOpcodes() { + // First clear everything + for (uint i = 0; i < 256; ++i) + _opcodes[i] = 0; + // Register opcodes + OPCODE(42, opIncBlockCounter); + OPCODE(126, opDebug126); +} + +#undef OPCODE + +void ScriptOpcodes::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); + +void ScriptOpcodes::opIncBlockCounter(ScriptThread *scriptThread, OpCall &opCall) { + ARG_INT16(index) + byte value = _vm->_scriptMan->_scriptResource->_blockCounters.get(index + 1); + if (value <= 63) + _vm->_scriptMan->_scriptResource->_blockCounters.set(index + 1, value); +} + +void ScriptOpcodes::opDebug126(ScriptThread *scriptThread, OpCall &opCall) { + // NOTE Prints some debug text +} + +} // End of namespace Illusions |
