aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sherlock/objects.cpp38
-rw-r--r--engines/sherlock/objects.h19
-rw-r--r--engines/sherlock/scene.cpp95
-rw-r--r--engines/sherlock/scene.h5
4 files changed, 136 insertions, 21 deletions
diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp
index 2386c00686..73e6397b50 100644
--- a/engines/sherlock/objects.cpp
+++ b/engines/sherlock/objects.cpp
@@ -101,7 +101,10 @@ void Object::synchronize(Common::SeekableReadStream &s) {
_sequences = nullptr;
_images = nullptr;
_imageFrame = nullptr;
- s.seek(16, SEEK_CUR);
+
+ s.skip(4);
+ _sequenceOffset = s.readUint32LE();
+ s.seek(8, SEEK_CUR);
_walkCount = s.readByte();
_allow = s.readByte();
@@ -133,7 +136,7 @@ void Object::synchronize(Common::SeekableReadStream &s) {
_aOpen.synchronize(s);
_aType = s.readByte();
_lookFrames = s.readByte();
- _seqcounter = s.readByte();
+ _seqCounter = s.readByte();
_lookPosition.x = s.readUint16LE();
_lookPosition.y = s.readByte();
_lookFacing = s.readByte();
@@ -141,7 +144,7 @@ void Object::synchronize(Common::SeekableReadStream &s) {
_aClose.synchronize(s);
_seqStack = s.readByte();
_seqTo = s.readByte();
- _descOfs = s.readUint16LE();
+ _descOffset = s.readUint16LE();
_seqcounter2 = s.readByte();
_seqSize = s.readUint16LE();
s.skip(1);
@@ -152,4 +155,33 @@ void Object::synchronize(Common::SeekableReadStream &s) {
_use[idx].synchronize(s);
}
+/*----------------------------------------------------------------*/
+
+void CAnim::synchronize(Common::SeekableReadStream &s) {
+ char buffer[12];
+ s.read(buffer, 12);
+ _name = Common::String(buffer);
+
+ s.read(_sequences, 30);
+ _position.x = s.readSint16LE();
+ _position.y = s.readSint16LE();
+ _size = s.readUint32LE();
+ _type = (SpriteType)s.readUint16LE();
+ _flags = s.readByte();
+ _goto.x = s.readSint16LE();
+ _goto.y = s.readSint16LE();
+ _sequenceNumber = s.readSint16LE();
+ _teleportPos.x = s.readSint16LE();
+ _teleportPos.y = s.readSint16LE();
+ _teleportS = s.readSint16LE();
+}
+
+/*----------------------------------------------------------------*/
+
+InvGraphicType::InvGraphicType() {
+ _images = nullptr;
+ _maxFrames = 0;
+ _filesize = 0;
+}
+
} // End of namespace Sherlock
diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h
index f730240479..31d9520932 100644
--- a/engines/sherlock/objects.h
+++ b/engines/sherlock/objects.h
@@ -104,8 +104,9 @@ struct UseType {
struct Object {
Common::String _name; // Name
Common::String _description; // Description
- Common::StringArray _examine; // Examine in-depth description
- uint8 (*_sequences)[MAX_HOLMES_SEQUENCE][MAX_FRAME]; // Holds animation sequences
+ Common::String _examine; // Examine in-depth description
+ int _sequenceOffset;
+ uint8 *_sequences; // Holds animation sequences
ImageFile *_images; // Sprite images
ImageFrame *_imageFrame; // Pointer to shape in the images
int _walkCount; // Character walk counter
@@ -132,14 +133,14 @@ struct Object {
ActionType _aOpen; // Holds data for moving object
int _aType; // Tells if this is an object, person, talk, etc.
int _lookFrames; // How many frames to play of the look anim before pausing
- int _seqcounter; // How many times this sequence has been executed
+ int _seqCounter; // How many times this sequence has been executed
Common::Point _lookPosition; // Where to walk when examining object
int _lookFacing; // Direction to face when examining object
int _lookcAnim;
ActionType _aClose;
int _seqStack; // Allows gosubs to return to calling frame
int _seqTo; // Allows 1-5, 8-3 type sequences encoded in 2 bytes
- uint _descOfs; // Tells where description starts in DescText
+ uint _descOffset; // Tells where description starts in DescText
int _seqcounter2; // Counter of calling frame sequence
uint _seqSize; // Tells where description starts
ActionType _aMove;
@@ -159,8 +160,18 @@ struct CAnim {
int _sequenceNumber;
Common::Point _teleportPos; // Location Holmes shoul teleport to after
int _teleportS; // playing canim
+
+ void synchronize(Common::SeekableReadStream &s);
};
+struct InvGraphicType {
+ ImageFile *_images; // Object images
+ int _maxFrames; // How many frames in object
+ int _filesize; // File size
+
+ InvGraphicType();
+} ;
+
} // End of namespace Sherlock
#endif
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp
index 267b02b43c..ffae6f60c1 100644
--- a/engines/sherlock/scene.cpp
+++ b/engines/sherlock/scene.cpp
@@ -38,7 +38,7 @@ void BgFileHeader::synchronize(Common::SeekableReadStream &s) {
/*----------------------------------------------------------------*/
void BgfileheaderInfo::synchronize(Common::SeekableReadStream &s) {
- _fSize = s.readUint32LE();
+ _filesize = s.readUint32LE();
_maxFrames = s.readByte();
char buffer[9];
@@ -71,6 +71,15 @@ Scene::Scene(SherlockEngine *vm): _vm(vm) {
Scene::~Scene() {
delete _controls;
+ clear();
+}
+
+/**
+ * Takes care of clearing any scene data
+ */
+void Scene::clear() {
+ for (uint idx = 0; idx < _bgShapes.size(); ++idx)
+ delete _bgShapes[idx]._images;
}
void Scene::selectScene() {
@@ -108,6 +117,7 @@ void Scene::loadScene(const Common::String &filename) {
_roomBounds.clear();
_roomBounds.push_back(Common::Rect(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT));
+ clear();
_descText.clear();
_comments = "";
_bgShapes.clear();
@@ -131,8 +141,6 @@ void Scene::loadScene(const Common::String &filename) {
rrmStream->seek(rrmStream->readUint32LE());
BgFileHeader bgHeader;
bgHeader.synchronize(*rrmStream);
-
- _cAnim.resize(bgHeader._numcAnimations);
_invGraphicItems = bgHeader._numImages + 1;
// Read in the shapes header info
@@ -142,20 +150,13 @@ void Scene::loadScene(const Common::String &filename) {
for (uint idx = 0; idx < bgInfo.size(); ++idx)
bgInfo[idx].synchronize(*rrmStream);
- // Initialize the cAnim
- for (uint idx = 0; idx < _cAnim.size(); ++idx) {
- _cAnim[idx]._position.x = -1;
- _cAnim[idx]._goto.x = -1;
- _cAnim[idx]._teleportPos.x = -1;
- }
-
// Read information
Common::SeekableReadStream *infoStream = !_lzwMode ? rrmStream :
decompressLZ(*rrmStream, bgHeader._numImages * 569 +
bgHeader._descSize + bgHeader._seqSize);
- _bgShapes.resize(bgHeader._numStructs);
- for (uint idx = 0; idx < _bgShapes.size(); ++idx)
+ _bgShapes.resize(bgHeader._numStructs + 1);
+ for (int idx = 0; idx < bgHeader._numStructs; ++idx)
_bgShapes[idx].synchronize(*infoStream);
if (bgHeader._descSize) {
@@ -171,11 +172,79 @@ void Scene::loadScene(const Common::String &filename) {
if (_lzwMode)
delete infoStream;
- // Load shapes
+ // Set up inv list
+ _inv.resize(bgHeader._numImages + 1);
+ for (int idx = 0; idx < bgHeader._numImages; ++idx) {
+ _inv[idx + 1]._filesize = bgInfo[idx]._filesize;
+ _inv[idx + 1]._maxFrames = bgInfo[idx]._maxFrames;
+
+ // Read in the image data
+ Common::SeekableReadStream *imageStream = !_lzwMode ? rrmStream :
+ decompressLZ(*rrmStream, bgInfo[idx]._filesize);
+
+ _inv[idx + 1]._images = new ImageFile(*imageStream);
+
+ if (_lzwMode)
+ delete imageStream;
+ }
+
+ // Set up the bgShapes
+ for (int idx = 0; idx < bgHeader._numStructs; ++idx) {
+ _bgShapes[idx]._examine = Common::String(&_descText[_bgShapes[idx]._descOffset]);
+ _bgShapes[idx]._sequences = &_sequenceBuffer[_bgShapes[idx]._sequenceOffset];
+ _bgShapes[idx]._misc = 0;
+ _bgShapes[idx]._seqCounter = 0;
+ _bgShapes[idx]._seqcounter2 = 0;
+ _bgShapes[idx]._seqStack = 0;
+ _bgShapes[idx]._frameNumber = -1;
+ _bgShapes[idx]._position = Common::Point(0, 0);
+ _bgShapes[idx]._oldSize = Common::Point(1, 1);
+
+ _bgShapes[idx]._images = _inv[_bgShapes[idx]._misc]._images;
+ _bgShapes[idx]._imageFrame = !_bgShapes[idx]._images ? (ImageFrame *)nullptr :
+ &(*_bgShapes[idx]._images)[0];
+ }
+
+ // Set up end of list
+ _bgShapes[bgHeader._numStructs]._sequences = &_sequenceBuffer[0] + bgHeader._seqSize;
+ _bgShapes[bgHeader._numStructs]._examine = nullptr;
+
+ // Load in cAnim list
+ Common::SeekableReadStream *canimStream = !_lzwMode ? rrmStream :
+ decompressLZ(*rrmStream, 65 * bgHeader._numcAnimations);
+
+ _cAnim.resize(bgHeader._numcAnimations);
+ for (uint idx = 0; idx < _cAnim.size(); ++idx)
+ _cAnim[idx].synchronize(*canimStream);
+
+ if (_lzwMode)
+ delete canimStream;
+
+ // Read in the room bounding areas
+ int size = rrmStream->readUint16LE();
+ Common::SeekableReadStream *boundsStream = !_lzwMode ? rrmStream :
+ decompressLZ(*rrmStream, size);
+
+ _roomBounds.resize(size / 10);
+ for (uint idx = 0; idx < _roomBounds.size(); ++idx) {
+ _roomBounds[idx].left = boundsStream->readSint16LE();
+ _roomBounds[idx].top = boundsStream->readSint16LE();
+ _roomBounds[idx].setWidth(boundsStream->readSint16LE());
+ _roomBounds[idx].setHeight(boundsStream->readSint16LE());
+ boundsStream->skip(2); // Skip unused scene number field
+ }
+
+ if (_lzwMode)
+ delete boundsStream;
+
+ // Back at version byte, so skip over it
+ rrmStream->skip(1);
+
// TODO
delete rrmStream;
}
+
}
} // End of namespace Sherlock
diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h
index e216c2bd9d..2280e169b7 100644
--- a/engines/sherlock/scene.h
+++ b/engines/sherlock/scene.h
@@ -47,7 +47,7 @@ struct BgFileHeader {
};
struct BgfileheaderInfo {
- int _fSize; // How long images are
+ int _filesize; // How long images are
int _maxFrames; // How many unique frames in object
Common::String _filename; // Filename of object
@@ -85,10 +85,13 @@ public:
Common::Array<Object> _bgShapes;
Common::Array<CAnim> _cAnim;
Common::Array<byte> _sequenceBuffer;
+ Common::Array<InvGraphicType> _inv;
public:
Scene(SherlockEngine *vm);
~Scene();
+ void clear();
+
void selectScene();
};