aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-03-02 10:49:20 -0500
committerPaul Gilbert2014-03-02 10:49:20 -0500
commit4bd1217dafbc2c28b731bd58d4ebd7b0b16a712e (patch)
tree34fd4b016fef6d6c2a28fbb3cd243688497030cb /engines
parent411a4054006be03c0c465b2707c5ef7c50eb87a1 (diff)
downloadscummvm-rg350-4bd1217dafbc2c28b731bd58d4ebd7b0b16a712e.tar.gz
scummvm-rg350-4bd1217dafbc2c28b731bd58d4ebd7b0b16a712e.tar.bz2
scummvm-rg350-4bd1217dafbc2c28b731bd58d4ebd7b0b16a712e.zip
MADS: Added loading for scene nodes and hotspost
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/events.h5
-rw-r--r--engines/mads/mads.h7
-rw-r--r--engines/mads/palette.cpp6
-rw-r--r--engines/mads/palette.h3
-rw-r--r--engines/mads/scene.cpp76
-rw-r--r--engines/mads/scene.h12
-rw-r--r--engines/mads/scene_data.cpp35
-rw-r--r--engines/mads/scene_data.h30
8 files changed, 145 insertions, 29 deletions
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 01f48170d4..0e990c5258 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -116,6 +116,11 @@ public:
* Delay for a given number of frames
*/
void delay(int amount);
+
+ /**
+ * Gets the current frame counter
+ */
+ uint32 getFrameCounter() const { return _gameCounter; }
};
} // End of namespace MADS
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 44630ca135..92758b72a5 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -75,10 +75,6 @@ private:
const MADSGameDescription *_gameDescription;
Common::RandomSource _randomSource;
- bool _easyMouse;
- bool _invObjectStill;
- bool _textWindowStill;
-
/**
* Handles basic initialisation
*/
@@ -98,6 +94,9 @@ public:
MSurface *_screen;
SoundManager *_sound;
UserInterface *_userInterface;
+ bool _easyMouse;
+ bool _invObjectStill;
+ bool _textWindowStill;
public:
MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc);
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index aca1298a23..b26329a65c 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -68,9 +68,11 @@ void PaletteUsage::load(int count, ...) {
va_list va;
va_start(va, count);
- _data.clear();
+ if (count > (int)_data.size())
+ _data.resize(count);
+
for (int i = 0; i < count; ++i)
- _data.push_back(va_arg(va, int));
+ _data[i] = va_arg(va, int);
va_end(va);
}
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 820e50fb21..18b058cccc 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -30,6 +30,8 @@ namespace MADS {
class MADSEngine;
+#define PALETTE_USAGE_COUNT 4
+
struct RGB4 {
byte r;
byte g;
@@ -143,6 +145,7 @@ protected:
void reset();
public:
byte _mainPalette[PALETTE_SIZE];
+ byte _savedPalette[PALETTE_SIZE];
RGB4 _gamePalette[PALETTE_COUNT];
PaletteUsage _paletteUsage;
public:
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index c640ff8da1..af53710c34 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -22,6 +22,7 @@
#include "common/scummsys.h"
#include "mads/scene.h"
+#include "mads/compression.h"
#include "mads/mads.h"
#include "mads/nebular/nebular_scenes.h"
@@ -34,6 +35,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) {
_vocabBuffer = nullptr;
_sceneLogic = nullptr;
_sceneInfo = nullptr;
+ _animFlag = false;
+ _animVal1 = 0;
_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
@@ -123,15 +126,46 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
_sceneInfo = SceneInfo::init(_vm);
_sceneInfo->load(_currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16,
_depthSurface, _backgroundSurface);
+
+ // Initialise palette animation for the scene
+ initPaletteAnimation(_sceneInfo->_palAnimData, false);
+
+ // Copy over nodes
+ _nodes.clear();
+ for (uint i = 0; i < _sceneInfo->_nodes.size(); ++i)
+ _nodes.push_back(_sceneInfo->_nodes[i]);
+
+ // Load hotspots
+ loadHotspots();
+
+ // Load vocab
+ loadVocab();
+
+ // Load palette usage
+ _vm->_palette->_paletteUsage.load(1, 0xF);
+
+ // Load interface
+ int flags = _vm->_game->_v2 ? 0x4101 : 0x4100;
+ if (!_vm->_textWindowStill)
+ flags |= 0x200;
+ // TODO
}
void Scene::loadHotspots() {
File f(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH"));
- int count = f.readUint16LE();
+ MadsPack madsPack(&f);
+
+ Common::SeekableReadStream *stream = madsPack.getItemStream(0);
+ int count = stream->readUint16LE();
+ delete stream;
+ stream = madsPack.getItemStream(1);
_hotspots.clear();
for (int i = 0; i < count; ++i)
- _hotspots.push_back(Hotspot(f));
+ _hotspots.push_back(Hotspot(*stream));
+
+ delete stream;
+ f.close();
}
void Scene::loadVocab() {
@@ -163,14 +197,42 @@ void Scene::loadVocabStrings() {
freeVocab();
File f("*VOCAB.DAT");
- byte *d = new byte[ f.size()];
- f.read(d, f.size());
-
+ char *textStrings = new char[f.size()];
+ f.read(textStrings, f.size());
-// int vocabId = 1;
for (uint strIndex = 0; strIndex < _activeVocabs.size(); ++strIndex) {
- // TODO: Rest of this method
+ const char *s = textStrings;
+ for (int vocabIndex = 0; vocabIndex < _activeVocabs[strIndex]; ++vocabIndex)
+ s += strlen(s) + 1;
+
+ _vocabStrings.push_back(s);
}
+
+ delete[] textStrings;
+ f.close();
+}
+
+void Scene::initPaletteAnimation(Common::Array<RGB4> &animData, bool animFlag) {
+ // Initialise the animation palette and ticks list
+ _animTicksList.clear();
+ _animPalData.clear();
+
+ for (uint i = 0; i < animData.size(); ++i) {
+ _animTicksList.push_back(_vm->_events->getFrameCounter());
+ _animPalData.push_back(animData[i]);
+ }
+
+ // Save the initial starting palette
+ Common::copy(&_vm->_palette->_mainPalette[0], &_vm->_palette->_mainPalette[PALETTE_SIZE],
+ &_vm->_palette->_savedPalette[0]);
+
+ // Calculate total
+ _animCount = 0;
+ for (uint i = 0; i < _animPalData.size(); ++i)
+ _animCount += _animPalData[i].r;
+
+ _animVal1 = (_animCount > 16) ? 3 : 0;
+ _animFlag = animFlag;
}
void Scene::free() {
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index a1edff5bdf..6bbab0fbbd 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -48,6 +48,11 @@ private:
* Secondary loading vocab list
*/
void loadVocabStrings();
+
+ /*
+ * Initialises the data for palette animation within the scene
+ */
+ void initPaletteAnimation(Common::Array<RGB4> &animData, bool animFlag);
protected:
MADSEngine *_vm;
public:
@@ -74,6 +79,13 @@ public:
SceneInfo *_sceneInfo;
MSurface _backgroundSurface;
MSurface _depthSurface;
+ bool _animFlag;
+ int _animVal1;
+ int _animCount;
+ Common::Array<uint32> _animTicksList;
+ Common::Array<RGB4> _animPalData;
+ SceneNodeList _nodes;
+ Common::StringArray _vocabStrings;
/**
* Constructor
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 0204699165..07a2ae856d 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -187,12 +187,21 @@ void ARTHeader::load(Common::SeekableReadStream *f) {
rgb.b = f->readByte();
rgb.u = f->readByte();
- _palData.push_back(rgb);
+ _palAnimData.push_back(rgb);
}
}
/*------------------------------------------------------------------------*/
+void SceneNode::load(Common::SeekableReadStream *f) {
+ _walkPos.x = f->readSint16LE();
+ _walkPos.y = f->readSint16LE();
+ for (int i = 0; i < MAX_ROUTE_NODES; ++i)
+ _indexes[i] = f->readUint16LE();
+}
+
+/*------------------------------------------------------------------------*/
+
void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
f->skip(3);
_spriteSetIndex = f->readByte();
@@ -237,21 +246,25 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
_depthStyle = infoStream->readUint16LE();
_width = infoStream->readUint16LE();
_height = infoStream->readUint16LE();
+
infoStream->skip(24);
- _nodeCount = infoStream->readUint16LE();
+
+ int nodeCount = infoStream->readUint16LE();
_yBandsEnd = infoStream->readUint16LE();
_yBandsStart = infoStream->readUint16LE();
_maxScale = infoStream->readUint16LE();
_minScale = infoStream->readUint16LE();
- for (int i = 0; i < 15; ++i)
+ for (int i = 0; i < DEPTH_BANDS_SIZE; ++i)
_depthList[i] = infoStream->readUint16LE();
_field4A = infoStream->readUint16LE();
// Load the set of objects that are associated with the scene
for (int i = 0; i < 20; ++i) {
- InventoryObject obj;
- obj.load(*infoStream);
- _objects.push_back(obj);
+ SceneNode node;
+ node.load(infoStream);
+
+ if (i < nodeCount)
+ _nodes.push_back(node);
}
int spriteSetsCount = infoStream->readUint16LE();
@@ -313,8 +326,8 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
delete stream;
// Copy out the palette data
- for (uint i = 0; i < artHeader._palData.size(); ++i)
- _palette.push_back(artHeader._palData[i]);
+ for (uint i = 0; i < artHeader._palAnimData.size(); ++i)
+ _palAnimData.push_back(artHeader._palAnimData[i]);
if (!(flags & 1)) {
if (!_vm->_palette->_paletteUsage.empty()) {
@@ -326,9 +339,9 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
if (_field4C > 0) {
_vm->_palette->_paletteUsage.transform(artHeader._palette);
- for (uint i = 0; i < _palette.size(); ++i) {
- byte g = _palette[i].g;
- _palette[g].b = artHeader._palette[g].palIndex;
+ for (uint i = 0; i < _palAnimData.size(); ++i) {
+ byte g = _palAnimData[i].g;
+ _palAnimData[g].b = artHeader._palAnimData[g].u;
}
}
}
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 1b98b9d165..2fe5c849c1 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -50,6 +50,9 @@ enum {
VERB_WALKTO = 13
};
+#define DEPTH_BANDS_SIZE 15
+#define MAX_ROUTE_NODES 22
+
class VerbInit {
public:
int _id;
@@ -254,10 +257,28 @@ struct ARTHeader {
int _width;
int _height;
Common::Array<RGB6> _palette;
- Common::Array<RGB4> _palData;
+ Common::Array<RGB4> _palAnimData;
+
+ void load(Common::SeekableReadStream *f);
+};
+
+class SceneNode {
+public:
+ Common::Point _walkPos;
+ int _indexes[MAX_ROUTE_NODES];
+ bool _active;
+ /**
+ * Constructor
+ */
+ SceneNode() : _active(false) {}
+
+ /**
+ * Loads the scene node
+ */
void load(Common::SeekableReadStream *f);
};
+typedef Common::Array<SceneNode> SceneNodeList;
/**
* Handles general data for a given scene
@@ -291,17 +312,16 @@ public:
int _width;
int _height;
- int _nodeCount;
int _yBandsEnd;
int _yBandsStart;
int _maxScale;
int _minScale;
- int _depthList[15];
+ int _depthList[DEPTH_BANDS_SIZE];
int _field4A;
int _field4C;
- Common::Array<InventoryObject> _objects;
- Common::Array<RGB4> _palette;
+ Common::Array<RGB4> _palAnimData;
+ SceneNodeList _nodes;
public:
/**
* Destructor