From 7ac555ecea930fb8d258f92bf9693f512e27bc7b Mon Sep 17 00:00:00 2001 From: Martin Gerhardy Date: Sat, 9 Jan 2021 22:10:27 +0100 Subject: [PATCH] TWINE: parse fla movie frame information --- engines/twine/flamovies.cpp | 35 +++------------------------ engines/twine/resources/resources.cpp | 34 ++++++++++++++++++++++++++ engines/twine/resources/resources.h | 7 ++++++ 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/engines/twine/flamovies.cpp b/engines/twine/flamovies.cpp index 9444c45a629..9f6d2a50251 100644 --- a/engines/twine/flamovies.cpp +++ b/engines/twine/flamovies.cpp @@ -264,38 +264,9 @@ void FlaMovies::playGIFMovie(const char *flaName) { } debug("Play gif %s", flaName); - // TODO: use the HQR 23th entry (movies informations) - if (!strcmp(flaName, FLA_INTROD)) { - prepareGIF(3); - prepareGIF(4); - prepareGIF(5); - } else if (!strcmp(flaName, "BAFFE") || !strcmp(flaName, "BAFFE2") || !strcmp(flaName, "BAFFE3") || !strcmp(flaName, "BAFFE4")) { - prepareGIF(6); - } else if (!strcmp(flaName, "bateau") || !strcmp(flaName, "bateau2")) { - prepareGIF(7); - } else if (!strcmp(flaName, "navette")) { - prepareGIF(15); - } else if (!strcmp(flaName, "templebu")) { - prepareGIF(12); - } else if (!strcmp(flaName, "flute2")) { - prepareGIF(8); // TODO: same as glass2? - } else if (!strcmp(flaName, "glass2")) { - prepareGIF(8); // TODO: same as flute2? - } else if (!strcmp(flaName, "surf")) { - prepareGIF(9); - } else if (!strcmp(flaName, "verser") || !strcmp(flaName, "verser2")) { - prepareGIF(10); - } else if (!strcmp(flaName, "neige2")) { - prepareGIF(11); - } else if (!strcmp(flaName, "capture")) { - prepareGIF(14); // TODO: same as sendel? - } else if (!strcmp(flaName, "sendel")) { - prepareGIF(14); // TODO: same as capture? - } else if (!strcmp(flaName, "sendel2")) { - prepareGIF(17); - } else if (!strcmp(flaName, FLA_DRAGON3)) { - prepareGIF(1); - prepareGIF(2); + const Common::Array& frames = _engine->_resources->getFlaMovieInfo(flaName); + for (int32 frame : frames) { + prepareGIF(frame); } } diff --git a/engines/twine/resources/resources.cpp b/engines/twine/resources/resources.cpp index e24dac791c8..31e21261e41 100644 --- a/engines/twine/resources/resources.cpp +++ b/engines/twine/resources/resources.cpp @@ -21,6 +21,7 @@ */ #include "twine/resources/resources.h" +#include "common/tokenizer.h" #include "common/util.h" #include "twine/audio/sound.h" #include "twine/renderer/screens.h" @@ -172,6 +173,39 @@ void Resources::initResources() { preloadAnimations(); preloadSamples(); preloadInventoryItems(); + + loadFlaInfo(); +} + +void Resources::loadFlaInfo() { + uint8 *content = nullptr; + const int32 size = HQR::getAllocEntry(&content, Resources::HQR_RESS_FILE, RESSHQR_FLAINFO); + if (size == 0) { + return; + } + const Common::String str((const char*)content, size); + free(content); + + Common::StringTokenizer tok(str, "\r\n"); + while (!tok.empty()) { + const Common::String &line = tok.nextToken(); + Common::StringTokenizer lineTok(line); + if (lineTok.empty()) { + continue; + } + const Common::String &name = lineTok.nextToken(); + Common::Array frames; + while (!lineTok.empty()) { + const Common::String &frame = lineTok.nextToken(); + const int32 frameIdx = atoi(frame.c_str()); + frames.push_back(frameIdx); + } + _flaMovieFrames.setVal(name, frames); + } +} + +const Common::Array& Resources::getFlaMovieInfo(const Common::String &name) const { + return _flaMovieFrames.getVal(name); } } // namespace TwinE diff --git a/engines/twine/resources/resources.h b/engines/twine/resources/resources.h index e9e6a9baa06..b0b1ca175ab 100644 --- a/engines/twine/resources/resources.h +++ b/engines/twine/resources/resources.h @@ -23,6 +23,7 @@ #ifndef TWINE_RESOURCES_H #define TWINE_RESOURCES_H +#include "common/hashmap.h" #include "common/scummsys.h" #include "twine/parser/sprite.h" #include "twine/scene/gamestate.h" @@ -142,11 +143,17 @@ private: /** Preload all animations */ void preloadAnimations(); void preloadSamples(); + void loadFlaInfo(); + + using MovieInfoMap = Common::HashMap>; + MovieInfoMap _flaMovieFrames; public: Resources(TwinEEngine *engine) : _engine(engine) {} ~Resources(); + const Common::Array& getFlaMovieInfo(const Common::String &name) const; + /** Table with all loaded samples */ uint8 *inventoryTable[NUM_INVENTORY_ITEMS] {nullptr}; /** Table with all loaded samples sizes */