aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/illusions/actor.cpp7
-rw-r--r--engines/illusions/actorresource.cpp26
-rw-r--r--engines/illusions/actorresource.h3
-rw-r--r--engines/illusions/dictionary.cpp54
-rw-r--r--engines/illusions/dictionary.h73
-rw-r--r--engines/illusions/illusions.cpp14
-rw-r--r--engines/illusions/illusions.h4
-rw-r--r--engines/illusions/module.mk1
8 files changed, 152 insertions, 30 deletions
diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp
index 04d7636e1c..2de6f483a0 100644
--- a/engines/illusions/actor.cpp
+++ b/engines/illusions/actor.cpp
@@ -23,6 +23,7 @@
#include "illusions/illusions.h"
#include "illusions/actor.h"
#include "illusions/camera.h"
+#include "illusions/dictionary.h"
#include "illusions/input.h"
#include "illusions/screen.h"
#include "illusions/scriptman.h"
@@ -198,7 +199,7 @@ void Control::unpause() {
if (_actor && !(_actor->_flags & 0x0200)) {
SurfInfo surfInfo;
- ActorType *actorType = _vm->findActorType(_actorTypeId);
+ ActorType *actorType = _vm->_dict->findActorType(_actorTypeId);
if (actorType)
surfInfo = actorType->_surfInfo;
else
@@ -483,7 +484,7 @@ void Control::startSequenceActorIntern(uint32 sequenceId, int value, int value2,
_actor->_notifyId3C = 0;
_actor->_path40 = 0;
- Sequence *sequence = _vm->findSequence(sequenceId);
+ Sequence *sequence = _vm->_dict->findSequence(sequenceId);
_actor->_seqCodeIp = sequence->_sequenceCode;
_actor->_frames = _vm->findSequenceFrames(sequence);
@@ -515,7 +516,7 @@ void Controls::placeActor(uint32 actorTypeId, Common::Point placePt, uint32 sequ
Control *control = newControl();
Actor *actor = newActor();
- ActorType *actorType = _vm->findActorType(actorTypeId);
+ ActorType *actorType = _vm->_dict->findActorType(actorTypeId);
control->_flags = actorType->_flags;
control->_priority = actorType->_priority;
control->_objectId = objectId;
diff --git a/engines/illusions/actorresource.cpp b/engines/illusions/actorresource.cpp
index fc4968ee61..b58a3382fb 100644
--- a/engines/illusions/actorresource.cpp
+++ b/engines/illusions/actorresource.cpp
@@ -22,6 +22,7 @@
#include "illusions/illusions.h"
#include "illusions/actorresource.h"
+#include "illusions/dictionary.h"
namespace Illusions {
@@ -41,7 +42,7 @@ void ActorResourceLoader::load(Resource *resource) {
for (uint i = 0; i < actorResource->_actorTypes.size(); ++i) {
ActorType *actorType = &actorResource->_actorTypes[i];
- ActorType *actorType2 = 0;// TODO _vm->getActorType(actorType->_actorTypeId);
+ ActorType *actorType2 = _vm->_dict->findActorType(actorType->_actorTypeId);
if (actorType2) {
actorType->_surfInfo._dimensions._width = MAX(actorType->_surfInfo._dimensions._width,
actorType2->_surfInfo._dimensions._width);
@@ -52,12 +53,12 @@ void ActorResourceLoader::load(Resource *resource) {
if (actorType->_value1E == 0)
actorType->_value1E = actorType2->_value1E;
}
- // TODO _vm->addActorType(actorType->_actorTypeId, actorType);
+ _vm->_dict->addActorType(actorType->_actorTypeId, actorType);
}
for (uint i = 0; i < actorResource->_sequences.size(); ++i) {
Sequence *sequence = &actorResource->_sequences[i];
- // TODO _vm->addSequence(sequence->_sequence, sequence);
+ _vm->_dict->addSequence(sequence->_sequenceId, sequence);
}
}
@@ -187,7 +188,8 @@ bool ActorResource::containsSequence(Sequence *sequence) {
// ActorItem
-ActorItem::ActorItem() {
+ActorItem::ActorItem(IllusionsEngine *vm)
+ : _vm(vm) {
}
ActorItem::~ActorItem() {
@@ -196,28 +198,24 @@ ActorItem::~ActorItem() {
void ActorItem::pause() {
++_pauseCtr;
if (_pauseCtr == 1) {
- /* TODO
for (uint i = 0; i < _actRes->_actorTypes.size(); ++i)
- // TODO _vm->removeActorType(_actRes->_actorTypes[i]._actorTypeId);
- for (uint i = 0; i < actorResource->_sequences.size(); ++i)
- // TODO _vm->removeSequence(_actRes->_sequences[i]._sequence);
- */
+ _vm->_dict->removeActorType(_actRes->_actorTypes[i]._actorTypeId);
+ for (uint i = 0; i < _actRes->_sequences.size(); ++i)
+ _vm->_dict->removeSequence(_actRes->_sequences[i]._sequenceId);
}
}
void ActorItem::unpause() {
--_pauseCtr;
if (_pauseCtr == 0) {
- /* TODO
for (uint i = 0; i < _actRes->_actorTypes.size(); ++i) {
ActorType *actorType = &_actRes->_actorTypes[i];
- // TODO _vm->addActorType(actorType->_actorTypeId, actorType);
+ _vm->_dict->addActorType(actorType->_actorTypeId, actorType);
}
for (uint i = 0; i < _actRes->_sequences.size(); ++i) {
Sequence *sequence = &_actRes->_sequences[i];
- // TODO _vm->addSequence(sequence->_sequence, sequence);
+ _vm->_dict->addSequence(sequence->_sequenceId, sequence);
}
- */
}
}
@@ -231,7 +229,7 @@ ActorItems::~ActorItems() {
}
ActorItem *ActorItems::allocActorItem() {
- ActorItem *actorItem = new ActorItem();
+ ActorItem *actorItem = new ActorItem(_vm);
_items.push_back(actorItem);
return actorItem;
}
diff --git a/engines/illusions/actorresource.h b/engines/illusions/actorresource.h
index c62f8a996a..af535d5692 100644
--- a/engines/illusions/actorresource.h
+++ b/engines/illusions/actorresource.h
@@ -95,11 +95,12 @@ public:
class ActorItem {
public:
- ActorItem();
+ ActorItem(IllusionsEngine *vm);
~ActorItem();
void pause();
void unpause();
public:
+ IllusionsEngine *_vm;
uint32 _tag;
int _pauseCtr;
ActorResource *_actRes;
diff --git a/engines/illusions/dictionary.cpp b/engines/illusions/dictionary.cpp
new file mode 100644
index 0000000000..bf0a4c82d6
--- /dev/null
+++ b/engines/illusions/dictionary.cpp
@@ -0,0 +1,54 @@
+/* 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/dictionary.h"
+#include "illusions/actorresource.h"
+#include "illusions/backgroundresource.h"
+
+namespace Illusions {
+
+void Dictionary::addActorType(uint32 id, ActorType *actorType) {
+ _actorTypes.add(id, actorType);
+}
+
+void Dictionary::removeActorType(uint32 id) {
+ _actorTypes.remove(id);
+}
+
+ActorType *Dictionary::findActorType(uint32 id) {
+ return _actorTypes.find(id);
+}
+
+void Dictionary::addSequence(uint32 id, Sequence *sequence) {
+ _sequences.add(id, sequence);
+}
+
+void Dictionary::removeSequence(uint32 id) {
+ _sequences.remove(id);
+}
+
+Sequence *Dictionary::findSequence(uint32 id) {
+ return _sequences.find(id);
+}
+
+} // End of namespace Illusions
diff --git a/engines/illusions/dictionary.h b/engines/illusions/dictionary.h
new file mode 100644
index 0000000000..9205fa69c6
--- /dev/null
+++ b/engines/illusions/dictionary.h
@@ -0,0 +1,73 @@
+/* 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_DICTIONARY_H
+#define ILLUSIONS_DICTIONARY_H
+
+#include "common/hashmap.h"
+
+namespace Illusions {
+
+class ActorType;
+
+template<class T>
+class DictionaryHashMap {
+public:
+
+ void add(uint32 id, T *value) {
+ _map[id] = value;
+ }
+
+ void remove(uint32 id) {
+ _map.erase(id);
+ }
+
+ T *find(uint32 id) {
+ typename Common::HashMap<uint32, T*>::iterator it = _map.find(id);
+ if (it != _map.end())
+ return it->_value;
+ return 0;
+ }
+
+protected:
+ Common::HashMap<uint32, T*> _map;
+};
+
+class Dictionary {
+public:
+
+ void addActorType(uint32 id, ActorType *actorType);
+ void removeActorType(uint32 id);
+ ActorType *findActorType(uint32 id);
+
+ void addSequence(uint32 id, Sequence *sequence);
+ void removeSequence(uint32 id);
+ Sequence *findSequence(uint32 id);
+
+protected:
+ DictionaryHashMap<ActorType> _actorTypes;
+ DictionaryHashMap<Sequence> _sequences;
+};
+
+} // End of namespace Illusions
+
+#endif // ILLUSIONS_DICTIONARY_H
diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp
index 3592ea9f15..e2ae4182b1 100644
--- a/engines/illusions/illusions.cpp
+++ b/engines/illusions/illusions.cpp
@@ -34,6 +34,7 @@
#include "illusions/scriptresource.h"
#include "illusions/scriptman.h"
#include "illusions/time.h"
+#include "illusions/dictionary.h"
#include "audio/audiostream.h"
#include "common/config-manager.h"
@@ -80,6 +81,8 @@ Common::Error IllusionsEngine::run() {
Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0);
initGraphics(640, 480, true, &pixelFormat16);
+ _dict = new Dictionary();
+
_resSys = new ResourceSystem();
_resSys->addResourceLoader(0x00060000, new ActorResourceLoader(this));
_resSys->addResourceLoader(0x000D0000, new ScriptResourceLoader(this));
@@ -139,6 +142,7 @@ Common::Error IllusionsEngine::run() {
delete _input;
delete _screen;
delete _resSys;
+ delete _dict;
return Common::kNoError;
}
@@ -191,16 +195,6 @@ Control *IllusionsEngine::findControl(uint32 objectId) {
return 0;
}
-ActorType *IllusionsEngine::findActorType(uint32 actorTypeId) {
- // TODO Dummy, to be replaced later
- return 0;
-}
-
-Sequence *IllusionsEngine::findSequence(uint32 sequenceId) {
- // TODO Dummy, to be replaced later
- return 0;
-}
-
void IllusionsEngine::notifyThreadId(uint32 &threadId) {
if (threadId) {
uint32 tempThreadId = threadId;
diff --git a/engines/illusions/illusions.h b/engines/illusions/illusions.h
index 3e19ecc75b..56bd7d9edf 100644
--- a/engines/illusions/illusions.h
+++ b/engines/illusions/illusions.h
@@ -56,6 +56,7 @@ class BackgroundItems;
class BackgroundResource;
class Camera;
class Control;
+class Dictionary;
class Input;
class Screen;
class ScriptResource;
@@ -77,6 +78,7 @@ private:
Graphics::PixelFormat _pixelFormat;
public:
Common::RandomSource *_random;
+ Dictionary *_dict;
ResourceSystem *_resSys;
void updateEvents();
@@ -90,8 +92,6 @@ public:
Common::Point *getObjectActorPositionPtr(uint32 objectId);
Control *findControl(uint32 objectId);
- ActorType *findActorType(uint32 actorTypeId);
- Sequence *findSequence(uint32 sequenceId);
FramesList *findSequenceFrames(Sequence *sequence);
void notifyThreadId(uint32 &threadId);
diff --git a/engines/illusions/module.mk b/engines/illusions/module.mk
index e40a676d18..149ed7d50f 100644
--- a/engines/illusions/module.mk
+++ b/engines/illusions/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
backgroundresource.o \
camera.o \
detection.o \
+ dictionary.o \
fixedpoint.o \
graphics.o \
illusions.o \