aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-03-02 17:49:52 -0500
committerPaul Gilbert2014-03-02 17:49:52 -0500
commitd5b5cbbb686596f50cdb9ea072c9178775ada720 (patch)
tree2021c018d16ab9129a973f0e296c5fe4f1a7ec31 /engines
parentcc810add7479b024138f31fc559f5a9cf7f7a459 (diff)
downloadscummvm-rg350-d5b5cbbb686596f50cdb9ea072c9178775ada720.tar.gz
scummvm-rg350-d5b5cbbb686596f50cdb9ea072c9178775ada720.tar.bz2
scummvm-rg350-d5b5cbbb686596f50cdb9ea072c9178775ada720.zip
MADS: Implemented rest of animation loading
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/animation.cpp88
-rw-r--r--engines/mads/animation.h12
-rw-r--r--engines/mads/scene.h2
-rw-r--r--engines/mads/scene_data.cpp13
-rw-r--r--engines/mads/scene_data.h8
-rw-r--r--engines/mads/sound.cpp4
-rw-r--r--engines/mads/sound.h5
7 files changed, 89 insertions, 43 deletions
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index dd62e7b0f0..339ee72d46 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -39,7 +39,7 @@ AAHeader::AAHeader(Common::SeekableReadStream *f) {
_animMode = f->readUint16LE();
_roomNumber = f->readUint16LE();
f->skip(2);
- _field12 = f->readUint16LE() != 0;
+ _manualFlag = f->readUint16LE() != 0;
_spriteListIndex = f->readUint16LE();
_scrollPosition.x = f->readSint16LE();
_scrollPosition.y = f->readSint16LE();
@@ -137,9 +137,19 @@ Animation *Animation::init(MADSEngine *vm, Scene *scene) {
return new Animation(vm, scene);
}
+Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {
+ _font = nullptr;
+}
+
+Animation::~Animation() {
+ delete _font;
+ for (uint i = 0; i < _spriteSets.size(); ++i)
+ delete _spriteSets[i];
+}
+
void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
- const Common::String &resName, int flags, Common::Array<RGB4> *palAnimData,
- SceneInfo *sceneInfo) {
+ const Common::String &resName, int flags, Common::Array<RGB4> *palAnimData,
+ SceneInfo *sceneInfo) {
Common::String resourceName = resName;
if (!resourceName.contains("."))
resourceName += ".AA";
@@ -165,9 +175,11 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
}
// Initialize the reference list
+ _spriteListIndexes.clear();
for (int i = 0; i < aaHeader._spriteListCount; ++i)
_spriteListIndexes.push_back(-1);
+ _messages.clear();
if (aaHeader._messagesCount > 0) {
// Chunk 2: Following is a list of any messages for the animation
Common::SeekableReadStream *msgStream = madsPack.getItemStream(1);
@@ -181,6 +193,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
delete msgStream;
}
+ _frameEntries.clear();
if (aaHeader._frameEntriesCount > 0) {
// Chunk 3: animation frame info
Common::SeekableReadStream *frameStream = madsPack.getItemStream(2);
@@ -194,6 +207,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
delete frameStream;
}
+ _miscEntries.clear();
if (aaHeader._miscEntriesCount > 0) {
// Chunk 4: Misc Data
Common::SeekableReadStream *miscStream = madsPack.getItemStream(3);
@@ -206,43 +220,55 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
delete miscStream;
}
- /*
+
// If the animation specifies a font, then load it for access
- if (_flags & ANIM_CUSTOM_FONT) {
- Common::String fontName;
- if (madsRes)
- fontName += "*";
- fontName += fontResource;
-
- if (fontName != "")
- _font = _vm->_font->getFont(fontName.c_str());
- else
- warning("Attempted to set a font with an empty name");
+ delete _font;
+ if (aaHeader._flags & ANIM_CUSTOM_FONT) {
+ Common::String fontName = "*" + aaHeader._fontResource;
+ _font = _vm->_font->getFont(fontName.c_str());
+ } else {
+ _font = nullptr;
}
-
- // If a speech file is specified, then load it
- if (!_dsrName.empty())
- _vm->_sound->loadDSRFile(_dsrName.c_str());
-
+
// Load all the sprite sets for the animation
- for (int i = 0; i < spriteListCount; ++i) {
- if (_field12 && (i == _spriteListIndex))
- // Skip over field, since it's manually loaded
- continue;
+ for (uint i = 0; i < _spriteSets.size(); ++i)
+ delete _spriteSets[i];
+ _spriteSets.clear();
+ _spriteSets.resize(aaHeader._spriteListCount);
- _spriteListIndexes[i] = _view->_spriteSlots.addSprites(_spriteSetNames[i].c_str());
+ for (int i = 0; i < aaHeader._spriteListCount; ++i) {
+ if (aaHeader._manualFlag && (i == aaHeader._spriteListIndex)) {
+ // Skip over field, since it's manually loaded
+ _spriteSets[i] = nullptr;
+ } else {
+ _spriteSets[i] = new SpriteAsset(_vm, aaHeader._spriteSetNames[i], flags);
+ }
}
+ if (aaHeader._manualFlag) {
+ Common::String resName = "*" + aaHeader._spriteSetNames[aaHeader._spriteListIndex];
+ SpriteAsset *sprites = new SpriteAsset(_vm, resName, flags);
+ _spriteSets[aaHeader._spriteListIndex] = sprites;
+
+ _spriteListIndexes[aaHeader._spriteListIndex] = _scene->_sprites.add(sprites);
+ }
- if (_field12) {
- Common::String resName;
- if (madsRes)
- resName += "*";
- resName += _spriteSetNames[_spriteListIndex];
+ // TODO: List var_420/var_422 population that seems to overwrite other structures?
- _spriteListIndexes[_spriteListIndex] = _view->_spriteSlots.addSprites(resName.c_str());
+ if (aaHeader._animMode == 4) {
+ // Remaps the sprite list indexes for frames to the loaded sprite list indexes
+ for (uint i = 0; i < _frameEntries.size(); ++i) {
+ int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex;
+ _frameEntries[i]._spriteSlot._spritesIndex = _spriteListIndexes[spriteListIndex];
+ }
+ } else {
+ // Remaps the sprite list indexes for frames to the loaded sprite list indexes
+ for (uint i = 0; i < _frameEntries.size(); ++i) {
+ int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex;
+ _frameEntries[i]._spriteSlot._spritesIndex = _spriteListIndexes[spriteListIndex];
+ }
}
- */
+
f.close();
}
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 1e542da590..d96e89b1b9 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -28,6 +28,7 @@
#include "common/rect.h"
#include "mads/msurface.h"
#include "mads/scene_data.h"
+#include "mads/font.h"
namespace MADS {
@@ -87,7 +88,7 @@ public:
byte _flags;
int _animMode;
int _roomNumber;
- int _field12;
+ bool _manualFlag;
int _spriteListIndex;
Common::Point _scrollPosition;
uint32 _scrollTicks;
@@ -113,7 +114,7 @@ private:
void loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface,
AAHeader &header, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo);
protected:
- Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {}
+ Animation(MADSEngine *vm, Scene *scene);
public:
static Animation *init(MADSEngine *vm, Scene *scene);
public:
@@ -121,7 +122,14 @@ public:
Common::Array<AnimMessage> _messages;
Common::Array<AnimFrameEntry> _frameEntries;
Common::Array<AnimMiscEntry> _miscEntries;
+ Common::Array<SpriteAsset *> _spriteSets;
+ Font *_font;
public:
+ /*
+ * Destructor
+ */
+ ~Animation();
+
/**
* Loads animation data
*/
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 2c5880a405..03980f7043 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -64,7 +64,7 @@ public:
Common::Array<VerbInit> _verbList;
Common::Array<TextDisplay> _textDisplay;
SpriteSlots _spriteSlots;
- Common::Array<SpriteAsset *> _sprites;
+ SpriteSets _sprites;
int _spritesIndex;
Common::Array<DynamicHotspot> _dynamicHotspots;
bool _dynamicHotspotsChanged;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index cec3e457a0..db2237557b 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -78,6 +78,19 @@ void SpriteSlots::deleteEntry(int index) {
remove_at(index);
}
+/*------------------------------------------------------------------------*/
+
+int SpriteSets::add(SpriteAsset *asset, int idx) {
+ if (!idx)
+ idx = size();
+
+ if (idx >= (size() + 1))
+ resize(idx + 1);
+ delete (*this)[idx];
+ (*this)[idx] = asset;
+
+ return idx;
+}
/*------------------------------------------------------------------------*/
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 23eee3403f..87fddfedd7 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -130,6 +130,14 @@ public:
void deleteEntry(int index);
};
+class SpriteSets: public Common::Array<SpriteAsset *> {
+public:
+ /**
+ * Add a sprite asset to the list
+ */
+ int add(SpriteAsset *asset, int idx = 0);
+};
+
class TextDisplay {
public:
bool _active;
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index ae338461ec..ea0239076b 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -90,10 +90,6 @@ void SoundManager::startQueuedCommands() {
}
}
-void SoundManager::loadDSRFile(const Common::String &filename) {
- error("TODO: SoundManager::loadDSRFile");
-}
-
void SoundManager::command(int commandId, int param) {
if (_newSoundsPaused) {
if (_queuedCommands.size() < 8)
diff --git a/engines/mads/sound.h b/engines/mads/sound.h
index 1fe322d6fb..0fd9ac1095 100644
--- a/engines/mads/sound.h
+++ b/engines/mads/sound.h
@@ -77,11 +77,6 @@ public:
*/
void startQueuedCommands();
- /**
- * Loads a DSR resource
- */
- void loadDSRFile(const Common::String &filename);
-
//@{
/**
* Executes a command on the sound driver