aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorjohndoe1232014-03-21 19:58:53 +0100
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit812c7fc3a83f57b9ba181c47d3699155c16ab379 (patch)
tree02dc7789f53b9fb5163f0e17d37f073555773c7b /engines
parent762be35a364fe66359d29b85b650c6e7add80e47 (diff)
downloadscummvm-rg350-812c7fc3a83f57b9ba181c47d3699155c16ab379.tar.gz
scummvm-rg350-812c7fc3a83f57b9ba181c47d3699155c16ab379.tar.bz2
scummvm-rg350-812c7fc3a83f57b9ba181c47d3699155c16ab379.zip
ILLUSIONS: Add TalkResource and related
Diffstat (limited to 'engines')
-rw-r--r--engines/illusions/backgroundresource.cpp3
-rw-r--r--engines/illusions/dictionary.cpp13
-rw-r--r--engines/illusions/dictionary.h8
-rw-r--r--engines/illusions/illusions.cpp2
-rw-r--r--engines/illusions/illusions.h2
-rw-r--r--engines/illusions/talkresource.cpp98
-rw-r--r--engines/illusions/talkresource.h44
7 files changed, 168 insertions, 2 deletions
diff --git a/engines/illusions/backgroundresource.cpp b/engines/illusions/backgroundresource.cpp
index fd8ae4f7dc..d80a9e2dd9 100644
--- a/engines/illusions/backgroundresource.cpp
+++ b/engines/illusions/backgroundresource.cpp
@@ -62,8 +62,9 @@ void BackgroundResourceLoader::unload(Resource *resource) {
// TODO Move to BackgroundItems
BackgroundItem *backgroundItem = _vm->_backgroundItems->findBackgroundByResource((BackgroundResource*)resource->_refId);
backgroundItem->freeSurface();
- _vm->_backgroundItems->freeBackgroundItem(backgroundItem);
// TODO Remove IDs from item48s
+ delete backgroundItem->_bgRes;
+ _vm->_backgroundItems->freeBackgroundItem(backgroundItem);
// TODO _vm->setDefPointDimensions1();
}
diff --git a/engines/illusions/dictionary.cpp b/engines/illusions/dictionary.cpp
index 2d3de2a29c..2d9d4b4812 100644
--- a/engines/illusions/dictionary.cpp
+++ b/engines/illusions/dictionary.cpp
@@ -24,6 +24,7 @@
#include "illusions/dictionary.h"
#include "illusions/actorresource.h"
#include "illusions/backgroundresource.h"
+#include "illusions/talkresource.h"
namespace Illusions {
@@ -51,6 +52,18 @@ Sequence *Dictionary::findSequence(uint32 id) {
return _sequences.find(id);
}
+void Dictionary::addTalkEntry(uint32 id, TalkEntry *talkEntry) {
+ _talkEntries.add(id, talkEntry);
+}
+
+void Dictionary::removeTalkEntry(uint32 id) {
+ _talkEntries.remove(id);
+}
+
+TalkEntry *Dictionary::findTalkEntry(uint32 id) {
+ return _talkEntries.find(id);
+}
+
void Dictionary::setObjectControl(uint32 objectId, Control *control) {
if (control)
_controls.add(objectId, control);
diff --git a/engines/illusions/dictionary.h b/engines/illusions/dictionary.h
index e8863f4c53..6bdc539725 100644
--- a/engines/illusions/dictionary.h
+++ b/engines/illusions/dictionary.h
@@ -28,6 +28,9 @@
namespace Illusions {
class ActorType;
+class Control;
+class Sequence;
+class TalkEntry;
template<class T>
class DictionaryHashMap {
@@ -63,12 +66,17 @@ public:
void removeSequence(uint32 id);
Sequence *findSequence(uint32 id);
+ void addTalkEntry(uint32 id, TalkEntry *talkEntry);
+ void removeTalkEntry(uint32 id);
+ TalkEntry *findTalkEntry(uint32 id);
+
void setObjectControl(uint32 objectId, Control *control);
Control *getObjectControl(uint32 objectId);
protected:
DictionaryHashMap<ActorType> _actorTypes;
DictionaryHashMap<Sequence> _sequences;
+ DictionaryHashMap<TalkEntry> _talkEntries;
DictionaryHashMap<Control> _controls;
};
diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp
index 265833a58e..d758c1fd0f 100644
--- a/engines/illusions/illusions.cpp
+++ b/engines/illusions/illusions.cpp
@@ -104,6 +104,7 @@ Common::Error IllusionsEngine::run() {
_camera = new Camera(this);
_controls = new Controls(this);
_cursor = new Cursor(this);
+ _talkItems = new TalkItems(this);
// TODO Move to own class
_resGetCtr = 0;
@@ -181,6 +182,7 @@ Common::Error IllusionsEngine::run() {
}
#endif
+ delete _talkItems;
delete _cursor;
delete _controls;
delete _camera;
diff --git a/engines/illusions/illusions.h b/engines/illusions/illusions.h
index c82f2c1576..2fa76319df 100644
--- a/engines/illusions/illusions.h
+++ b/engines/illusions/illusions.h
@@ -64,6 +64,7 @@ class Screen;
class ScriptResource;
class ScriptMan;
class Sequence;
+class TalkItems;
class FramesList;
class IllusionsEngine : public Engine {
@@ -93,6 +94,7 @@ public:
Camera *_camera;
Controls *_controls;
Cursor *_cursor;
+ TalkItems *_talkItems;
int _resGetCtr;
uint32 _resGetTime;
diff --git a/engines/illusions/talkresource.cpp b/engines/illusions/talkresource.cpp
index d0fa607518..fe14effd39 100644
--- a/engines/illusions/talkresource.cpp
+++ b/engines/illusions/talkresource.cpp
@@ -22,6 +22,7 @@
#include "illusions/illusions.h"
#include "illusions/talkresource.h"
+#include "illusions/dictionary.h"
namespace Illusions {
@@ -30,11 +31,30 @@ namespace Illusions {
void TalkResourceLoader::load(Resource *resource) {
debug("TalkResourceLoader::load() Loading font %08X from %s...", resource->_resId, resource->_filename.c_str());
- // TODO
+ TalkResource *talkResource = new TalkResource();
+ talkResource->load(resource->_data, resource->_dataSize);
+ resource->_refId = talkResource;
+
+ _vm->_talkItems->newTalkItem(resource->_resId, talkResource);
+
+ for (uint i = 0; i < talkResource->_talkEntriesCount; ++i) {
+ TalkEntry *talkEntry = &talkResource->_talkEntries[i];
+ _vm->_dict->addTalkEntry(talkEntry->_talkId, talkEntry);
+ }
}
void TalkResourceLoader::unload(Resource *resource) {
+ TalkItem *talkItem = _vm->_talkItems->findTalkItem(resource->_resId);
+ TalkResource *talkResource = talkItem->_talkRes;
+
+ for (uint i = 0; i < talkResource->_talkEntriesCount; ++i) {
+ TalkEntry *talkEntry = &talkResource->_talkEntries[i];
+ _vm->_dict->removeTalkEntry(talkEntry->_talkId);
+ }
+
+ _vm->_talkItems->freeTalkItem(talkItem);
+
}
void TalkResourceLoader::buildFilename(Resource *resource) {
@@ -46,4 +66,80 @@ bool TalkResourceLoader::isFlag(int flag) {
flag == kRlfLoadFile;
}
+// TalkEntry
+
+void TalkEntry::load(byte *dataStart, Common::SeekableReadStream &stream) {
+ _talkId = stream.readUint32LE();
+ stream.readUint32LE(); // Skip unknown
+ uint32 textOffs = stream.readUint32LE();
+ uint32 tblOffs = stream.readUint32LE();
+ uint32 voiceNameOffs = stream.readUint32LE();
+ _text = dataStart + textOffs;
+ _tblPtr = dataStart + tblOffs;
+ _voiceName = dataStart + voiceNameOffs;
+
+ debug("TalkEntry::load() _talkId: %08X; textOffs: %08X; tblOffs: %08X; voiceNameOffs: %08X",
+ _talkId, textOffs, tblOffs, voiceNameOffs);
+}
+
+// TalkResource
+
+TalkResource::TalkResource()
+ : _talkEntriesCount(0), _talkEntries(0) {
+}
+
+TalkResource::~TalkResource() {
+ delete[] _talkEntries;
+}
+
+void TalkResource::load(byte *data, uint32 dataSize) {
+ Common::MemoryReadStream stream(data, dataSize, DisposeAfterUse::NO);
+
+ stream.skip(4); // Skip size
+ _talkEntriesCount = stream.readUint16LE();
+ stream.skip(2); // Skip padding
+
+ _talkEntries = new TalkEntry[_talkEntriesCount];
+ for (uint i = 0; i < _talkEntriesCount; ++i) {
+ stream.seek(8 + i * 0x14);
+ _talkEntries[i].load(data, stream);
+ }
+
+}
+
+// TalkItem
+
+TalkItem::TalkItem(uint32 talkId, TalkResource *talkResource)
+ : _talkId(talkId), _talkRes(talkResource), _pauseCtr(0) {
+}
+
+TalkItem::~TalkItem() {
+}
+
+// TalkItems
+
+TalkItems::TalkItems(IllusionsEngine *vm) {
+}
+
+TalkItems::~TalkItems() {
+}
+
+TalkItem *TalkItems::newTalkItem(uint32 talkId, TalkResource *talkResource) {
+ TalkItem *talkItem = new TalkItem(talkId, talkResource);
+ _items.push_back(talkItem);
+ return talkItem;
+}
+
+void TalkItems::freeTalkItem(TalkItem *talkItem) {
+ _items.remove(talkItem);
+ delete talkItem;
+}
+
+TalkItem *TalkItems::findTalkItem(uint32 talkId) {
+ for (ItemsIterator it = _items.begin(); it != _items.end(); ++it)
+ if ((*it)->_talkId == talkId)
+ return (*it);
+ return 0;
+}
+
} // End of namespace Illusions
diff --git a/engines/illusions/talkresource.h b/engines/illusions/talkresource.h
index 982d5fdf75..beb859c108 100644
--- a/engines/illusions/talkresource.h
+++ b/engines/illusions/talkresource.h
@@ -42,6 +42,50 @@ protected:
IllusionsEngine *_vm;
};
+struct TalkEntry {
+ uint32 _talkId;
+ //field_4 dd
+ byte *_text;
+ byte *_tblPtr;
+ byte *_voiceName;
+ void load(byte *dataStart, Common::SeekableReadStream &stream);
+};
+
+class TalkResource {
+public:
+ TalkResource();
+ ~TalkResource();
+ void load(byte *data, uint32 dataSize);
+public:
+ uint _talkEntriesCount;
+ TalkEntry *_talkEntries;
+};
+
+class TalkItem {
+public:
+ TalkItem(uint32 talkId, TalkResource *talkResource);
+ ~TalkItem();
+public:
+ uint32 _talkId;
+ TalkResource *_talkRes;
+ int _pauseCtr;
+};
+
+class TalkItems {
+public:
+ TalkItems(IllusionsEngine *vm);
+ ~TalkItems();
+ TalkItem *newTalkItem(uint32 talkId, TalkResource *talkResource);
+ void freeTalkItem(TalkItem *talkItem);
+ TalkItem *findTalkItem(uint32 talkId);
+//protected:
+public:
+ typedef Common::List<TalkItem*> Items;
+ typedef Items::iterator ItemsIterator;
+ IllusionsEngine *_vm;
+ Items _items;
+};
+
} // End of namespace Illusions
#endif // ILLUSIONS_TALKRESOURCE_H