mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-09 12:22:51 +00:00
ILLUSIONS: Add SequenceOpcodes skeleton class
This commit is contained in:
parent
3fc592df49
commit
18540a5e38
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -17,6 +17,7 @@ MODULE_OBJS := \
|
||||
scriptopcodes.o \
|
||||
scriptresource.o \
|
||||
scriptthread.o \
|
||||
sequenceopcodes.o \
|
||||
spritedecompressqueue.o \
|
||||
spritedrawqueue.o \
|
||||
thread.o \
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
74
engines/illusions/sequenceopcodes.cpp
Normal file
74
engines/illusions/sequenceopcodes.cpp
Normal file
@ -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
|
53
engines/illusions/sequenceopcodes.h
Normal file
53
engines/illusions/sequenceopcodes.h
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user