aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock/animation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sherlock/animation.cpp')
-rw-r--r--engines/sherlock/animation.cpp104
1 files changed, 104 insertions, 0 deletions
diff --git a/engines/sherlock/animation.cpp b/engines/sherlock/animation.cpp
index 21d63633d3..bc0e337039 100644
--- a/engines/sherlock/animation.cpp
+++ b/engines/sherlock/animation.cpp
@@ -133,6 +133,110 @@ bool Animation::play(const Common::String &filename, int minDelay, int fade,
return !skipped && !_vm->shouldQuit();
}
+bool Animation::play3DO(const Common::String &filename, int minDelay, int fade,
+ int speed) {
+ Events &events = *_vm->_events;
+ Screen &screen = *_vm->_screen;
+ Sound &sound = *_vm->_sound;
+ //int soundNumber = 0;
+
+ // Check for any any sound frames for the given animation
+ //const int *soundFrames = checkForSoundFrames(filename);
+
+ // Add on the VDX extension
+ Common::String indexName = "prologue/" + filename + ".3dx";
+
+ // Load the animation
+ Common::File *indexStream = new Common::File();
+
+ if (!indexStream->open(indexName)) {
+ warning("unable to open %s\n", indexName);
+ return false;
+ }
+
+ // Load initial image
+ Common::String graphicsName = "prologue/" + filename + ".3da";
+ ImageFile3DO images(graphicsName, true);
+
+ events.wait(minDelay);
+// if (fade != 0 && fade != 255)
+// screen.fadeToBlack();
+
+// if (setPalette) {
+// if (fade != 255)
+// screen.setPalette(images._palette);
+// }
+
+ //int frameNumber = 0;
+ Common::Point pt;
+ bool skipped = false;
+ while (!_vm->shouldQuit()) {
+ // Get the next sprite to display
+ int imageFrame = indexStream->readSint16BE();
+
+ if (imageFrame == -2) {
+ // End of animation reached
+ break;
+ } else if (imageFrame != -1) {
+ // Read position from either animation stream or the sprite frame itself
+ if (imageFrame < 0) {
+ imageFrame += 32768;
+ pt.x = indexStream->readUint16BE();
+ pt.y = indexStream->readUint16BE();
+ } else {
+ pt = images[imageFrame]._offset;
+ }
+
+ // Draw the sprite. Note that we explicitly use the raw frame below, rather than the ImageFrame,
+ // since we don't want the offsets in the image file to be used, just the explicit position we specify
+ screen.transBlitFromUnscaled3DO(images[imageFrame]._frame, pt);
+ //events.wait(1000);
+ } else {
+#if 0
+ // At this point, either the sprites for the frame has been complete, or there weren't any sprites
+ // at all to draw for the frame
+ //if (fade == 255) {
+ // // Gradual fade in
+ // if (screen.equalizePalette(images._palette) == 0)
+ // fade = 0;
+ //}
+
+ // Check if we've reached a frame with sound
+ if (frameNumber++ == *soundFrames) {
+ ++soundNumber;
+ ++soundFrames;
+ Common::String fname = _soundLibraryFilename.empty() ?
+ Common::String::format("%s%01d", filename.c_str(), soundNumber) :
+ Common::String::format("%s%02d", filename.c_str(), soundNumber);
+
+ if (sound._voices)
+ sound.playSound(fname, WAIT_RETURN_IMMEDIATELY, 100, _soundLibraryFilename.c_str());
+ }
+#endif
+
+ events.wait(speed * 3);
+ }
+
+ if (events.kbHit()) {
+ Common::KeyState keyState = events.getKey();
+ if (keyState.keycode == Common::KEYCODE_ESCAPE ||
+ keyState.keycode == Common::KEYCODE_SPACE) {
+ skipped = true;
+ break;
+ }
+ } else if (events._pressed) {
+ skipped = true;
+ break;
+ }
+ }
+
+ events.clearEvents();
+ sound.stopSound();
+ delete indexStream;
+
+ return !skipped && !_vm->shouldQuit();
+}
+
void Animation::setPrologueNames(const char *const *names, int count) {
for (int idx = 0; idx < count; ++idx, ++names) {
_prologueNames.push_back(*names);