[Scummvm-git-logs] scummvm master -> a0ea8dc7f33006008385bd98a1b266579a5b99b9

mgerhardy martin.gerhardy at gmail.com
Fri Sep 10 17:21:08 UTC 2021


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
0a33eb7496 TWINE: some scene change logic is lba1 specific
1fb91752e1 TWINE: fixed lba2 array sizes for body models
4b512d64b8 TWINE: added lba2 intro support
a0ea8dc7f3 TWINE: renamed class to Movies


Commit: 0a33eb74966983dc641b143b48971d7512f93757
    https://github.com/scummvm/scummvm/commit/0a33eb74966983dc641b143b48971d7512f93757
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-10T19:20:56+02:00

Commit Message:
TWINE: some scene change logic is lba1 specific

Changed paths:
    engines/twine/scene/scene.cpp


diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index 6d6d846b8e..ab777ff874 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -468,22 +468,24 @@ void Scene::reloadCurrentScene() {
 }
 
 void Scene::changeScene() {
-	if (_useScenePatches) {
-		if (_currentSceneIdx == LBA1SceneId::Citadel_Island_Harbor && _needChangeScene == LBA1SceneId::Principal_Island_Harbor && _sceneNumZones > 14) {
-			const ZoneStruct *zone = &_sceneZones[15];
-			const IVec3 &track = _sceneTracks[8];
-			IVec3 &pos = _zoneHeroPos;
-			pos.x = zone->infoData.ChangeScene.x - zone->mins.x + track.x;
-			pos.y = zone->infoData.ChangeScene.y - zone->mins.y + track.y;
-			pos.z = zone->infoData.ChangeScene.z - zone->mins.z + track.z;
-			_engine->_scene->_heroPositionType = ScenePositionType::kZone;
-			debug(3, "Using zone position %i:%i:%i", pos.x, pos.y, pos.z);
+	if (_engine->isLBA1()) {
+		if (_useScenePatches) {
+			if (_currentSceneIdx == LBA1SceneId::Citadel_Island_Harbor && _needChangeScene == LBA1SceneId::Principal_Island_Harbor && _sceneNumZones > 14) {
+				const ZoneStruct *zone = &_sceneZones[15];
+				const IVec3 &track = _sceneTracks[8];
+				IVec3 &pos = _zoneHeroPos;
+				pos.x = zone->infoData.ChangeScene.x - zone->mins.x + track.x;
+				pos.y = zone->infoData.ChangeScene.y - zone->mins.y + track.y;
+				pos.z = zone->infoData.ChangeScene.z - zone->mins.z + track.z;
+				_engine->_scene->_heroPositionType = ScenePositionType::kZone;
+				debug(3, "Using zone position %i:%i:%i", pos.x, pos.y, pos.z);
+			}
 		}
-	}
 
-	// change twinsen house destroyed hard-coded
-	if (_needChangeScene == LBA1SceneId::Citadel_Island_near_twinsens_house && _engine->_gameState->hasOpenedFunfrocksSafe()) {
-		_needChangeScene = LBA1SceneId::Citadel_Island_Twinsens_house_destroyed;
+		// change twinsen house destroyed hard-coded
+		if (_needChangeScene == LBA1SceneId::Citadel_Island_near_twinsens_house && _engine->_gameState->hasOpenedFunfrocksSafe()) {
+			_needChangeScene = LBA1SceneId::Citadel_Island_Twinsens_house_destroyed;
+		}
 	}
 
 	// local backup previous scene
@@ -497,14 +499,16 @@ void Scene::changeScene() {
 	}
 	debug(2, "Entering scene %s (came from %i)", _engine->_gameState->_sceneName, _previousSceneIdx);
 
-	if (_needChangeScene == LBA1SceneId::Polar_Island_end_scene) {
-		_engine->unlockAchievement("LBA_ACH_001");
-		// if you finish the game in less than 4 hours
-		if (_engine->getTotalPlayTime() <= 1000 * 60 * 60 * 4) {
-			_engine->unlockAchievement("LBA_ACH_005");
+	if (_engine->isLBA1()) {
+		if (_needChangeScene == LBA1SceneId::Polar_Island_end_scene) {
+			_engine->unlockAchievement("LBA_ACH_001");
+			// if you finish the game in less than 4 hours
+			if (_engine->getTotalPlayTime() <= 1000 * 60 * 60 * 4) {
+				_engine->unlockAchievement("LBA_ACH_005");
+			}
+		} else if (_needChangeScene == LBA1SceneId::Brundle_Island_Secret_room) {
+			_engine->unlockAchievement("LBA_ACH_006");
 		}
-	} else if (_needChangeScene == LBA1SceneId::Brundle_Island_Secret_room) {
-		_engine->unlockAchievement("LBA_ACH_006");
 	}
 
 	_engine->_sound->stopSamples();
@@ -534,9 +538,7 @@ void Scene::changeScene() {
 
 	if (_heroPositionType == ScenePositionType::kZone) {
 		_newHeroPos = _zoneHeroPos;
-	}
-
-	if (_heroPositionType == ScenePositionType::kScene || _heroPositionType == ScenePositionType::kNoPosition) {
+	} else if (_heroPositionType == ScenePositionType::kScene || _heroPositionType == ScenePositionType::kNoPosition) {
 		_newHeroPos = _sceneHeroPos;
 	}
 


Commit: 1fb91752e152a88d7ff2b7eb0384de6aa289550d
    https://github.com/scummvm/scummvm/commit/1fb91752e152a88d7ff2b7eb0384de6aa289550d
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-10T19:20:56+02:00

Commit Message:
TWINE: fixed lba2 array sizes for body models

Changed paths:
    engines/twine/resources/resources.cpp
    engines/twine/scene/actor.h


diff --git a/engines/twine/resources/resources.cpp b/engines/twine/resources/resources.cpp
index e40196d6cd..326393ab7d 100644
--- a/engines/twine/resources/resources.cpp
+++ b/engines/twine/resources/resources.cpp
@@ -147,46 +147,46 @@ void Resources::initResources() {
 	_engine->_text->setFontColor(COLOR_14);
 	_engine->_text->setTextCrossColor(136, 143, 2);
 
-	if (!_spriteShadowPtr.loadFromHQR(Resources::HQR_RESS_FILE, RESSHQR_SPRITESHADOW, _engine->isLBA1())) {
-		error("Failed to load shadow sprites");
-	}
-
 	if (_engine->isLBA1()) {
+		if (!_spriteShadowPtr.loadFromHQR(Resources::HQR_RESS_FILE, RESSHQR_SPRITESHADOW, _engine->isLBA1())) {
+			error("Failed to load shadow sprites");
+		}
+
 		if (!_spriteBoundingBox.loadFromHQR(Resources::HQR_RESS_FILE, RESSHQR_SPRITEBOXDATA, _engine->isLBA1())) {
 			error("Failed to load sprite bounding box data");
 		}
-	}
 
-	_holomapSurfaceSize = HQR::getAllocEntry(&_holomapSurfacePtr, Resources::HQR_RESS_FILE, RESSHQR_HOLOSURFACE);
-	if (_holomapSurfaceSize == 0) {
-		error("Failed to load holomap surface");
-	}
+		_holomapSurfaceSize = HQR::getAllocEntry(&_holomapSurfacePtr, Resources::HQR_RESS_FILE, RESSHQR_HOLOSURFACE);
+		if (_holomapSurfaceSize == 0) {
+			error("Failed to load holomap surface");
+		}
 
-	_holomapImageSize = HQR::getAllocEntry(&_holomapImagePtr, Resources::HQR_RESS_FILE, RESSHQR_HOLOIMG);
-	if (_holomapImageSize == 0) {
-		error("Failed to load holomap image");
-	}
+		_holomapImageSize = HQR::getAllocEntry(&_holomapImagePtr, Resources::HQR_RESS_FILE, RESSHQR_HOLOIMG);
+		if (_holomapImageSize == 0) {
+			error("Failed to load holomap image");
+		}
 
-	if (!_holomapTwinsenModelPtr.loadFromHQR(Resources::HQR_RESS_FILE, RESSHQR_HOLOTWINMDL, _engine->isLBA1())) {
-		error("Failed to load holomap twinsen model");
-	}
+		if (!_holomapTwinsenModelPtr.loadFromHQR(Resources::HQR_RESS_FILE, RESSHQR_HOLOTWINMDL, _engine->isLBA1())) {
+			error("Failed to load holomap twinsen model");
+		}
 
-	if (!_holomapPointModelPtr.loadFromHQR(Resources::HQR_RESS_FILE, RESSHQR_HOLOPOINTMDL, _engine->isLBA1())) {
-		error("Failed to load holomap point model");
-	}
+		if (!_holomapPointModelPtr.loadFromHQR(Resources::HQR_RESS_FILE, RESSHQR_HOLOPOINTMDL, _engine->isLBA1())) {
+			error("Failed to load holomap point model");
+		}
 
-	if (!_holomapArrowPtr.loadFromHQR(Resources::HQR_RESS_FILE, RESSHQR_HOLOARROWMDL, _engine->isLBA1())) {
-		error("Failed to load holomap arrow model");
-	}
+		if (!_holomapArrowPtr.loadFromHQR(Resources::HQR_RESS_FILE, RESSHQR_HOLOARROWMDL, _engine->isLBA1())) {
+			error("Failed to load holomap arrow model");
+		}
 
-	if (!_holomapTwinsenArrowPtr.loadFromHQR(Resources::HQR_RESS_FILE, RESSHQR_HOLOTWINARROWMDL, _engine->isLBA1())) {
-		error("Failed to load holomap twinsen arrow model");
-	}
+		if (!_holomapTwinsenArrowPtr.loadFromHQR(Resources::HQR_RESS_FILE, RESSHQR_HOLOTWINARROWMDL, _engine->isLBA1())) {
+			error("Failed to load holomap twinsen arrow model");
+		}
 
-	if (!_trajectories.loadFromHQR(Resources::HQR_RESS_FILE, RESSHQR_HOLOPOINTANIM, _engine->isLBA1())) {
-		error("Failed to parse trajectory data");
+		if (!_trajectories.loadFromHQR(Resources::HQR_RESS_FILE, RESSHQR_HOLOPOINTANIM, _engine->isLBA1())) {
+			error("Failed to parse trajectory data");
+		}
+		debug("preload %i trajectories", (int)_trajectories.getTrajectories().size());
 	}
-	debug("preload %i trajectories", (int)_trajectories.getTrajectories().size());
 
 	preloadSprites();
 	preloadAnimations();
@@ -194,6 +194,10 @@ void Resources::initResources() {
 	preloadInventoryItems();
 
 	const int32 bodyCount = HQR::numEntries(Resources::HQR_BODY_FILE);
+	const int32 maxBodies = _engine->isLBA1() ? 200 : NUM_BODIES;
+	if (bodyCount > maxBodies) {
+		error("Max body count exceeded: %i", bodyCount);
+	}
 	for (int32 i = 0; i < bodyCount; ++i) {
 		if (!_bodyData[i].loadFromHQR(Resources::HQR_BODY_FILE, i, _engine->isLBA1())) {
 			error("HQR ERROR: Parsing body entity for model %i failed", i);
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index feacdf5c8c..a8edb49e78 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -34,7 +34,7 @@ namespace TwinE {
 #define NUM_SPRITES 425 // 200 for lba1
 
 /** Total number of bodies allowed in the game */
-#define NUM_BODIES 200
+#define NUM_BODIES 469 // 131 for lba1
 
 /** Actors move structure */
 struct ActorMoveStruct {


Commit: 4b512d64b8f7e20687db10a8945d2e1b9f9caf2d
    https://github.com/scummvm/scummvm/commit/4b512d64b8f7e20687db10a8945d2e1b9f9caf2d
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-10T19:20:56+02:00

Commit Message:
TWINE: added lba2 intro support

Changed paths:
    engines/twine/flamovies.cpp
    engines/twine/flamovies.h
    engines/twine/holomap.cpp
    engines/twine/menu/menuoptions.cpp
    engines/twine/parser/text.cpp
    engines/twine/renderer/screens.cpp
    engines/twine/renderer/screens.h
    engines/twine/resources/hqr.h
    engines/twine/resources/resources.h
    engines/twine/script/script_life_v1.cpp
    engines/twine/shared.h
    engines/twine/twine.cpp
    video/smk_decoder.h


diff --git a/engines/twine/flamovies.cpp b/engines/twine/flamovies.cpp
index f9cc6eb858..8b647bbaef 100644
--- a/engines/twine/flamovies.cpp
+++ b/engines/twine/flamovies.cpp
@@ -34,7 +34,9 @@
 #include "twine/resources/hqr.h"
 #include "twine/resources/resources.h"
 #include "twine/scene/grid.h"
+#include "twine/shared.h"
 #include "twine/twine.h"
+#include "video/smk_decoder.h"
 
 namespace TwinE {
 
@@ -342,6 +344,7 @@ void FlaMovies::playGIFMovie(const char *flaName) {
 }
 
 void FlaMovies::playFlaMovie(const char *flaName) {
+	assert(_engine->isLBA1());
 	_engine->_sound->stopSamples();
 
 	Common::String fileNamePath = Common::String::format("%s", flaName);
@@ -435,4 +438,46 @@ void FlaMovies::playFlaMovie(const char *flaName) {
 	_engine->_sound->stopSamples();
 }
 
+void FlaMovies::playSmkMovie(int index) {
+	assert(_engine->isLBA2());
+	Video::SmackerDecoder decoder;
+	Common::SeekableReadStream *stream = HQR::makeReadStream(TwineResource(Resources::HQR_VIDEO_FILE, index));
+	if (stream == nullptr) {
+		warning("Failed to find smacker video %i", index);
+		return;
+	}
+	if (!decoder.loadStream(stream)) {
+		warning("Failed to load smacker video %i", index);
+		return;
+	}
+	decoder.start();
+
+	for (;;) {
+		if (decoder.endOfVideo()) {
+			break;
+		}
+		FrameMarker frame(_engine);
+		_engine->_input->readKeys();
+		if (_engine->shouldQuit() || _engine->_input->toggleAbortAction()) {
+			break;
+		}
+
+		if (decoder.needsUpdate()) {
+			const Graphics::Surface *frameSurf = decoder.decodeNextFrame();
+			if (!frameSurf) {
+				continue;
+			}
+			if (decoder.hasDirtyPalette()) {
+				_engine->setPalette(0, 256, decoder.getPalette());
+			}
+
+			Graphics::ManagedSurface& target = _engine->_frontVideoBuffer;
+			const Common::Rect frameBounds(0, 0, frameSurf->w, frameSurf->h);
+			target.transBlitFrom(*frameSurf, frameBounds, target.getBounds(), 0, false, 0, 0xff, nullptr, true);
+		}
+	}
+
+	decoder.close();
+}
+
 } // namespace TwinE
diff --git a/engines/twine/flamovies.h b/engines/twine/flamovies.h
index a761076c49..c2171be4d7 100644
--- a/engines/twine/flamovies.h
+++ b/engines/twine/flamovies.h
@@ -103,6 +103,8 @@ public:
 	 * @param flaName FLA movie name
 	 */
 	void playFlaMovie(const char *flaName);
+
+	void playSmkMovie(int index);
 };
 
 } // namespace TwinE
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index c2a3ef8e03..ce65a52c77 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -121,7 +121,8 @@ void Holomap::clearHolomapPosition(int32 locationIdx) {
 }
 
 void Holomap::loadHolomapGFX() {
-	_engine->_screens->loadCustomPalette(RESSHQR_HOLOPAL);
+	constexpr TwineResource resource(Resources::HQR_RESS_FILE, RESSHQR_HOLOPAL);
+	_engine->_screens->loadCustomPalette(resource);
 
 	int32 j = 576;
 	for (int32 i = 0; i < 96; i += 3, j += 3) {
diff --git a/engines/twine/menu/menuoptions.cpp b/engines/twine/menu/menuoptions.cpp
index 62b108c083..33bc9de98d 100644
--- a/engines/twine/menu/menuoptions.cpp
+++ b/engines/twine/menu/menuoptions.cpp
@@ -53,7 +53,7 @@ void MenuOptions::newGame() {
 	_engine->_cfgfile.FlagDisplayText = true;
 
 	// intro screen 1 - twinsun
-	_engine->_screens->loadImage(RESSHQR_INTROSCREEN1IMG, RESSHQR_INTROSCREEN1PAL);
+	_engine->_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 15, 16));
 
 	_engine->_text->_drawTextBoxBackground = false;
 	_engine->_text->_renderTextTriangle = true;
@@ -66,11 +66,11 @@ void MenuOptions::newGame() {
 
 	// intro screen 2
 	if (!aborted) {
-		_engine->_screens->loadImage(RESSHQR_INTROSCREEN2IMG, RESSHQR_INTROSCREEN2PAL);
+		_engine->_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 17, 18));
 		aborted |= _engine->_text->drawTextProgressive(TextId::kIntroText2);
 
 		if (!aborted) {
-			_engine->_screens->loadImage(RESSHQR_INTROSCREEN3IMG, RESSHQR_INTROSCREEN3PAL);
+			_engine->_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 19, 20));
 			aborted |= _engine->_text->drawTextProgressive(TextId::kIntroText3);
 		}
 	}
diff --git a/engines/twine/parser/text.cpp b/engines/twine/parser/text.cpp
index 3a56ab93a1..8592c60ecb 100644
--- a/engines/twine/parser/text.cpp
+++ b/engines/twine/parser/text.cpp
@@ -57,13 +57,20 @@ bool TextData::loadFromHQR(const char *name, TextBankId textBankId, int language
 
 	for (int entry = 0; entry < numIdxEntries; ++entry) {
 		const TextId textIdx = (TextId)indexStream->readUint16LE();
-		const uint16 start = offsetStream->readUint16LE();
+		uint16 start = offsetStream->readUint16LE();
 		const int32 offsetPos = offsetStream->pos();
 		const uint16 end = offsetStream->readUint16LE();
+
+		if (!lba1) {
+			++start;
+		}
 		offsetStream->seek(start);
 		Common::String result;
 		for (int16 i = start; i < end - 1; ++i) {
 			const char c = (char)offsetStream->readByte();
+			if (c == '\0') {
+				break;
+			}
 			result += c;
 		}
 		add(textBankId, TextEntry{result, entry, textIdx});
diff --git a/engines/twine/renderer/screens.cpp b/engines/twine/renderer/screens.cpp
index 329ab15034..98d4e6733d 100644
--- a/engines/twine/renderer/screens.cpp
+++ b/engines/twine/renderer/screens.cpp
@@ -34,17 +34,17 @@ namespace TwinE {
 bool Screens::adelineLogo() {
 	_engine->_music->playMidiMusic(31);
 
-	return loadImageDelay(RESSHQR_ADELINEIMG, RESSHQR_ADELINEPAL, 7);
+	return loadImageDelay(_engine->_resources->adelineLogo(), 7);
 }
 
 void Screens::loadMenuImage(bool fadeIn) {
-	loadImage(RESSHQR_MENUIMG, -1, fadeIn);
+	loadImage(_engine->_resources->menuBackground(), fadeIn);
 	_engine->_workVideoBuffer.blitFrom(_engine->_frontVideoBuffer);
 }
 
-void Screens::loadCustomPalette(int32 index) {
-	if (HQR::getEntry(_palette, Resources::HQR_RESS_FILE, index) == 0) {
-		warning("Failed to load custom palette %i", index);
+void Screens::loadCustomPalette(const TwineResource &resource) {
+	if (HQR::getEntry(_palette, resource.hqr, resource.index) == 0) {
+		warning("Failed to load custom palette %i", resource.index);
 		return;
 	}
 	convertPalToRGBA(_palette, _paletteRGBACustom);
@@ -62,18 +62,18 @@ void Screens::convertPalToRGBA(const uint8 *in, uint32 *out) {
 	}
 }
 
-void Screens::loadImage(int32 index, int32 paletteIndex, bool fadeIn) {
+void Screens::loadImage(TwineImage image, bool fadeIn) {
 	Graphics::ManagedSurface& src = _engine->_imageBuffer;
-	if (HQR::getEntry((uint8 *)src.getPixels(), Resources::HQR_RESS_FILE, index) == 0) {
-		warning("Failed to load image with index %i", index);
+	if (HQR::getEntry((uint8 *)src.getPixels(), image.image) == 0) {
+		warning("Failed to load image with index %i", image.image.index);
 		return;
 	}
-	debug(0, "Load image: %i", index);
+	debug(0, "Load image: %i", image.image.index);
 	Graphics::ManagedSurface& target = _engine->_frontVideoBuffer;
 	target.transBlitFrom(src, src.getBounds(), target.getBounds(), 0, false, 0, 0xff, nullptr, true);
 	const uint32 *pal = _paletteRGBA;
-	if (paletteIndex != -1) {
-		loadCustomPalette(paletteIndex);
+	if (image.palette.index != -1) {
+		loadCustomPalette(image.palette);
 		pal = _paletteRGBACustom;
 	}
 	if (fadeIn) {
@@ -83,8 +83,8 @@ void Screens::loadImage(int32 index, int32 paletteIndex, bool fadeIn) {
 	}
 }
 
-bool Screens::loadImageDelay(int32 index, int32 paletteIndex, int32 seconds) {
-	loadImage(index, paletteIndex);
+bool Screens::loadImageDelay(TwineImage image, int32 seconds) {
+	loadImage(image);
 	if (_engine->delaySkip(1000 * seconds)) {
 		adjustPalette(0, 0, 0, _paletteRGBACustom, 100);
 		return true;
diff --git a/engines/twine/renderer/screens.h b/engines/twine/renderer/screens.h
index e97b228249..5430908073 100644
--- a/engines/twine/renderer/screens.h
+++ b/engines/twine/renderer/screens.h
@@ -78,7 +78,7 @@ public:
 	 * Load a custom palette
 	 * @param index \a RESS.HQR entry index (starting from 0)
 	 */
-	void loadCustomPalette(int32 index);
+	void loadCustomPalette(const TwineResource &resource);
 
 	/** Load and display Main Menu image */
 	void loadMenuImage(bool fadeIn = true);
@@ -89,7 +89,7 @@ public:
 	 * @param paletteIndex \a RESS.HQR entry index of the palette for the given image. This is often the @c index + 1
 	 * @param fadeIn if we fade in before using the palette
 	 */
-	void loadImage(int32 index, int32 paletteIndex, bool fadeIn = true);
+	void loadImage(TwineImage image, bool fadeIn = true);
 
 	/**
 	 * Load and display a particulary image on \a RESS.HQR file with cross fade effect and delay
@@ -97,7 +97,7 @@ public:
 	 * @param paletteIndex \a RESS.HQR entry index of the palette for the given image. This is often the @c index + 1
 	 * @param seconds number of seconds to delay
 	 */
-	bool loadImageDelay(int32 index, int32 paletteIndex, int32 seconds);
+	bool loadImageDelay(TwineImage image, int32 seconds);
 
 	/**
 	 * Fade image in
diff --git a/engines/twine/resources/hqr.h b/engines/twine/resources/hqr.h
index bf75fa894c..1cddb9cfb4 100644
--- a/engines/twine/resources/hqr.h
+++ b/engines/twine/resources/hqr.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "common/stream.h"
+#include "twine/shared.h"
 
 namespace TwinE {
 
@@ -37,6 +38,7 @@ class TwinEEngine;
  */
 namespace HQR {
 
+
 /**
  * Get a HQR entry pointer
  * @param ptr pointer to save the entry
@@ -45,6 +47,9 @@ namespace HQR {
  * @return entry real size
  */
 int32 getEntry(uint8 *ptr, const char *filename, int32 index);
+inline int32 getEntry(uint8 *ptr, TwineResource resource) {
+	return getEntry(ptr, resource.hqr, resource.index);
+}
 
 /**
  * Get a HQR entry pointer
@@ -53,6 +58,9 @@ int32 getEntry(uint8 *ptr, const char *filename, int32 index);
  * @return entry real size
  */
 int32 entrySize(const char *filename, int32 index);
+inline int32 entrySize(TwineResource resource) {
+	return entrySize(resource.hqr, resource.index);
+}
 
 /**
  * Get a HQR total number of entries
@@ -70,11 +78,17 @@ int32 numEntries(const char *filename);
  * @return entry real size
  */
 int32 getAllocEntry(uint8 **ptr, const char *filename, int32 index);
+inline int32 getAllocEntry(uint8 **ptr, TwineResource resource) {
+	return getAllocEntry(ptr, resource.hqr, resource.index);
+}
 
 /**
  * @brief Helper method to dump the content of the given hqr index to a file
  */
 bool dumpEntry(const char *filename, int32 index, const char *targetFileName);
+inline bool dumpEntry(TwineResource resource, const char *targetFileName) {
+	return dumpEntry(resource.hqr, resource.index, targetFileName);
+}
 
 /**
  * Get a HQR entry pointer
@@ -95,7 +109,9 @@ int32 getVoxEntry(uint8 *ptr, const char *filename, int32 index, int32 hiddenInd
 int32 getAllocVoxEntry(uint8 **ptr, const char *filename, int32 index, int32 hiddenIndex);
 
 Common::SeekableReadStream *makeReadStream(const char *filename, int index);
-
+inline Common::SeekableReadStream *makeReadStream(TwineResource resource) {
+	return makeReadStream(resource.hqr, resource.index);
+}
 } // namespace HQR
 
 } // namespace TwinE
diff --git a/engines/twine/resources/resources.h b/engines/twine/resources/resources.h
index bec9bf9717..abd55337b5 100644
--- a/engines/twine/resources/resources.h
+++ b/engines/twine/resources/resources.h
@@ -48,33 +48,17 @@ namespace TwinE {
 #define RESSHQR_HOLOTWINMDL 9
 #define RESSHQR_HOLOARROWMDL 10
 #define RESSHQR_HOLOTWINARROWMDL 11
-#define RESSHQR_RELLENTIMG 12
-#define RESSHQR_RELLENTPAL 13
-#define RESSHQR_MENUIMG 14
-#define RESSHQR_INTROSCREEN1IMG 15
-#define RESSHQR_INTROSCREEN1PAL 16
-#define RESSHQR_INTROSCREEN2IMG 17
-#define RESSHQR_INTROSCREEN2PAL 18
-#define RESSHQR_INTROSCREEN3IMG 19
-#define RESSHQR_INTROSCREEN3PAL 20
+
 #define RESSHQR_GAMEOVERMDL 21
 
 #define RESSHQR_ALARMREDPAL 22
 #define RESSHQR_FLAINFO 23
 #define RESSHQR_DARKPAL 24
-#define RESSHQR_TWINSEN_ZOE_SENDELLIMG 25
-#define RESSHQR_TWINSEN_ZOE_SENDELLPAL 26
-#define RESSHQR_ADELINEIMG 27
-#define RESSHQR_ADELINEPAL 28
 
 #define RESSHQR_HOLOPOINTMDL 29
 #define RESSHQR_HOLOPOINTANIM 30
 
-#define RESSHQR_LBAIMG 49
-#define RESSHQR_LBAPAL 50
 #define RESSHQR_PLASMAEFFECT 51
-#define RESSHQR_EAIMG 52
-#define RESSHQR_EAPAL 53
 
 #define FLA_DRAGON3 "dragon3"
 #define FLA_INTROD "introd"
@@ -229,6 +213,8 @@ public:
 	static constexpr const char *HQR_LBA_BRK_FILE = "lba_brk.hqr";
 	// scenes (active area content (actors, scripts, etc.))
 	static constexpr const char *HQR_SCENE_FILE = "scene.hqr";
+	// full screen images (lba2)
+	static constexpr const char *HQR_SCREEN_FILE = "screen.hqr";
 	// sprites
 	static constexpr const char *HQR_SPRITES_FILE = "sprites.hqr";
 	/**
@@ -250,6 +236,51 @@ public:
 	static constexpr const char *HQR_FLASAMP_FILE = "flasamp.hqr";
 	static constexpr const char *HQR_MIDI_MI_DOS_FILE = "midi_mi.hqr";
 	static constexpr const char *HQR_MIDI_MI_WIN_FILE = "midi_mi_win.hqr";
+
+	static constexpr const char *HQR_VIDEO_FILE = "video.hqr"; // lba2 - smk files
+
+	TwineImage adelineLogo() const {
+		if (_engine->isLBA1()) {
+			return TwineImage(Resources::HQR_RESS_FILE, 27, 28);
+		}
+		return TwineImage(Resources::HQR_SCREEN_FILE, 0, 1);
+	}
+
+	TwineImage lbaLogo() const {
+		if (_engine->isLBA1()) {
+			return TwineImage(Resources::HQR_RESS_FILE, 49, 50);
+		}
+		return TwineImage(Resources::HQR_SCREEN_FILE, 60, 61);
+	}
+
+	TwineImage eaLogo() const {
+		if (_engine->isLBA1()) {
+			return TwineImage(Resources::HQR_RESS_FILE, 52, 53);
+		}
+		return TwineImage(Resources::HQR_SCREEN_FILE, 74, 75);
+	}
+
+	TwineImage activisionLogo() const {
+		assert(_engine->isLBA2());
+		return TwineImage(Resources::HQR_SCREEN_FILE, 72, 73);
+	}
+
+	TwineImage virginLogo() const {
+		assert(_engine->isLBA2());
+		return TwineImage(Resources::HQR_SCREEN_FILE, 76, 77);
+	}
+
+	TwineImage relentLogo() const {
+		assert(_engine->isLBA1());
+		return TwineImage(Resources::HQR_RESS_FILE, 12, 13);
+	}
+
+	TwineImage menuBackground() const {
+		if (_engine->isLBA1()) {
+			return TwineImage(Resources::HQR_RESS_FILE, 14, -1);
+		}
+		return TwineImage(Resources::HQR_SCREEN_FILE, 4, 5);
+	}
 };
 
 } // namespace TwinE
diff --git a/engines/twine/script/script_life_v1.cpp b/engines/twine/script/script_life_v1.cpp
index de778d7fb4..e753158fba 100644
--- a/engines/twine/script/script_life_v1.cpp
+++ b/engines/twine/script/script_life_v1.cpp
@@ -1578,7 +1578,7 @@ static int32 lSET_NORMAL_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
 static int32 lMESSAGE_SENDELL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ScopedEngineFreeze scoped(engine);
 	engine->_screens->fadeToBlack(engine->_screens->_paletteRGBA);
-	engine->_screens->loadImage(RESSHQR_TWINSEN_ZOE_SENDELLIMG, RESSHQR_TWINSEN_ZOE_SENDELLPAL);
+	engine->_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 25, 26));
 	engine->_text->textClipFull();
 	engine->_text->setFontCrossColor(COLOR_WHITE);
 	engine->_text->_drawTextBoxBackground = false;
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index 0413874398..4fb34c434f 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -568,6 +568,22 @@ enum InventoryItems {
 	MaxInventoryItems = 28
 };
 
+struct TwineResource {
+	const char *hqr;
+	const int32 index;
+
+	constexpr TwineResource(const char *_hqr, int32 _index) : hqr(_hqr), index(_index) {
+	}
+};
+
+struct TwineImage {
+	TwineResource image;
+	TwineResource palette;
+
+	constexpr TwineImage(const char *hqr, int32 index, int32 paletteIndex = -1) : image(hqr, index), palette(hqr, paletteIndex) {
+	}
+};
+
 // lba2 does from 0 to 0x1000
 // lba1 angles
 // TODO: wrap in a class to be able to handle lba1 and lba2
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index b6beeac15b..370bed5463 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -129,6 +129,9 @@ TwinEEngine::TwinEEngine(OSystem *system, Common::Language language, uint32 flag
 	const Common::FSNode gameDataDir(ConfMan.get("path"));
 	SearchMan.addSubDirectoryMatching(gameDataDir, "fla");
 	SearchMan.addSubDirectoryMatching(gameDataDir, "vox");
+	if (isLBA2()) {
+		SearchMan.addSubDirectoryMatching(gameDataDir, "video");
+	}
 	if (flags & TF_DOTEMU_ENHANCED) {
 		SearchMan.addSubDirectoryMatching(gameDataDir, "resources/lba_files/hqr");
 		SearchMan.addSubDirectoryMatching(gameDataDir, "resources/lba_files/fla");
@@ -483,30 +486,42 @@ void TwinEEngine::initEngine() {
 	_input->enableKeyMap(cutsceneKeyMapId);
 	// Display company logo
 	bool abort = false;
+
+	if (isLBA2()) {
+		//abort |= _screens->loadImageDelay(_resources->activisionLogo(), 7);
+		abort |= _screens->loadImageDelay(_resources->eaLogo(), 7);
+	}
+
 	abort |= _screens->adelineLogo();
 
-	// verify game version screens
-	if (!abort && _cfgfile.Version == EUROPE_VERSION) {
-		// Little Big Adventure screen
-		abort |= _screens->loadImageDelay(RESSHQR_LBAIMG, RESSHQR_LBAPAL, 3);
-		if (!abort) {
-			// Electronic Arts Logo
-			abort |= _screens->loadImageDelay(RESSHQR_EAIMG, RESSHQR_EAPAL, 2);
-		}
-	} else if (!abort && _cfgfile.Version == USA_VERSION) {
-		// Relentless screen
-		abort |= _screens->loadImageDelay(RESSHQR_RELLENTIMG, RESSHQR_RELLENTPAL, 3);
-		if (!abort) {
-			// Electronic Arts Logo
-			abort |= _screens->loadImageDelay(RESSHQR_EAIMG, RESSHQR_EAPAL, 2);
+	if (isLBA1()) {
+		// verify game version screens
+		if (!abort && _cfgfile.Version == EUROPE_VERSION) {
+			// Little Big Adventure screen
+			abort |= _screens->loadImageDelay(_resources->lbaLogo(), 3);
+			if (!abort) {
+				// Electronic Arts Logo
+				abort |= _screens->loadImageDelay(_resources->eaLogo(), 2);
+			}
+		} else if (!abort && _cfgfile.Version == USA_VERSION) {
+			// Relentless screen
+			abort |= _screens->loadImageDelay(_resources->relentLogo(), 3);
+			if (!abort) {
+				// Electronic Arts Logo
+				abort |= _screens->loadImageDelay(_resources->eaLogo(), 2);
+			}
+		} else if (!abort && _cfgfile.Version == MODIFICATION_VERSION) {
+			// Modification screen
+			abort |= _screens->loadImageDelay(_resources->relentLogo(), 2);
 		}
-	} else if (!abort && _cfgfile.Version == MODIFICATION_VERSION) {
-		// Modification screen
-		abort |= _screens->loadImageDelay(RESSHQR_RELLENTIMG, RESSHQR_RELLENTPAL, 2);
 	}
 
 	if (!abort) {
-		_flaMovies->playFlaMovie(FLA_DRAGON3);
+		if (isLBA1()) {
+			_flaMovies->playFlaMovie(FLA_DRAGON3);
+		} else {
+			_flaMovies->playSmkMovie(16);
+		}
 	}
 	_input->enableKeyMap(uiKeyMapId);
 
@@ -566,7 +581,7 @@ void TwinEEngine::processActorSamplePosition(int32 actorIdx) {
 
 void TwinEEngine::processBookOfBu() {
 	_screens->fadeToBlack(_screens->_paletteRGBA);
-	_screens->loadImage(RESSHQR_INTROSCREEN1IMG, RESSHQR_INTROSCREEN1PAL);
+	_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 15, 16));
 	_text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
 	_text->_drawTextBoxBackground = false;
 	_text->textClipFull();
diff --git a/video/smk_decoder.h b/video/smk_decoder.h
index bf3887efac..86862f5b4a 100644
--- a/video/smk_decoder.h
+++ b/video/smk_decoder.h
@@ -59,6 +59,7 @@ class BigHuffmanTree;
  *  - sword2
  *  - toon
  *  - trecision
+ *  - twine
  */
 class SmackerDecoder : public VideoDecoder {
 public:


Commit: a0ea8dc7f33006008385bd98a1b266579a5b99b9
    https://github.com/scummvm/scummvm/commit/a0ea8dc7f33006008385bd98a1b266579a5b99b9
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-10T19:20:56+02:00

Commit Message:
TWINE: renamed class to Movies

as it now also playing smacker videos for lba2

Changed paths:
  A engines/twine/movies.cpp
  A engines/twine/movies.h
  R engines/twine/flamovies.cpp
  R engines/twine/flamovies.h
    engines/twine/audio/sound.cpp
    engines/twine/menu/menuoptions.cpp
    engines/twine/module.mk
    engines/twine/script/script_life_v1.cpp
    engines/twine/script/script_move_v1.cpp
    engines/twine/twine.cpp
    engines/twine/twine.h


diff --git a/engines/twine/audio/sound.cpp b/engines/twine/audio/sound.cpp
index 87af4466d5..61b294dece 100644
--- a/engines/twine/audio/sound.cpp
+++ b/engines/twine/audio/sound.cpp
@@ -30,7 +30,7 @@
 #include "common/util.h"
 #include "twine/parser/text.h"
 #include "twine/scene/collision.h"
-#include "twine/flamovies.h"
+#include "twine/movies.h"
 #include "twine/scene/grid.h"
 #include "twine/resources/hqr.h"
 #include "twine/scene/movements.h"
diff --git a/engines/twine/menu/menuoptions.cpp b/engines/twine/menu/menuoptions.cpp
index 33bc9de98d..0b39a6ffd9 100644
--- a/engines/twine/menu/menuoptions.cpp
+++ b/engines/twine/menu/menuoptions.cpp
@@ -29,7 +29,7 @@
 #include "savestate.h"
 #include "twine/audio/music.h"
 #include "twine/audio/sound.h"
-#include "twine/flamovies.h"
+#include "twine/movies.h"
 #include "twine/scene/gamestate.h"
 #include "twine/input.h"
 #include "twine/menu/interface.h"
diff --git a/engines/twine/module.mk b/engines/twine/module.mk
index c2f59a66d0..b7ea4919a4 100644
--- a/engines/twine/module.mk
+++ b/engines/twine/module.mk
@@ -42,7 +42,7 @@ MODULE_OBJS := \
 	resources/lzss.o \
 	resources/resources.o \
 	\
-	flamovies.o \
+	movies.o \
 	holomap.o \
 	input.o \
 	metaengine.o \
diff --git a/engines/twine/flamovies.cpp b/engines/twine/movies.cpp
similarity index 96%
rename from engines/twine/flamovies.cpp
rename to engines/twine/movies.cpp
index 8b647bbaef..a357a9b04a 100644
--- a/engines/twine/flamovies.cpp
+++ b/engines/twine/movies.cpp
@@ -20,7 +20,7 @@
  *
  */
 
-#include "twine/flamovies.h"
+#include "twine/movies.h"
 #include "common/endian.h"
 #include "common/file.h"
 #include "common/system.h"
@@ -73,7 +73,7 @@ struct FLASampleStruct {
 /** FLA movie extension */
 #define FLA_EXT ".fla"
 
-void FlaMovies::drawKeyFrame(Common::MemoryReadStream &stream, int32 width, int32 height) {
+void Movies::drawKeyFrame(Common::MemoryReadStream &stream, int32 width, int32 height) {
 	uint8 *destPtr = (uint8 *)_flaBuffer;
 	uint8 *startOfLine = destPtr;
 
@@ -99,7 +99,7 @@ void FlaMovies::drawKeyFrame(Common::MemoryReadStream &stream, int32 width, int3
 	}
 }
 
-void FlaMovies::drawDeltaFrame(Common::MemoryReadStream &stream, int32 width) {
+void Movies::drawDeltaFrame(Common::MemoryReadStream &stream, int32 width) {
 	const uint16 skip = stream.readUint16LE() * width;
 	const int32 height = stream.readSint16LE();
 
@@ -128,7 +128,7 @@ void FlaMovies::drawDeltaFrame(Common::MemoryReadStream &stream, int32 width) {
 	}
 }
 
-void FlaMovies::scaleFla2x() {
+void Movies::scaleFla2x() {
 	uint8 *source = (uint8 *)_flaBuffer;
 	uint8 *dest = (uint8 *)_engine->_imageBuffer.getPixels();
 
@@ -162,7 +162,7 @@ void FlaMovies::scaleFla2x() {
 	}
 }
 
-void FlaMovies::processFrame() {
+void Movies::processFrame() {
 	FLASampleStruct sample;
 
 	_frameData.videoSize = _file.readSint16LE();
@@ -270,9 +270,9 @@ void FlaMovies::processFrame() {
 	}
 }
 
-FlaMovies::FlaMovies(TwinEEngine *engine) : _engine(engine) {}
+Movies::Movies(TwinEEngine *engine) : _engine(engine) {}
 
-void FlaMovies::prepareGIF(int index) {
+void Movies::prepareGIF(int index) {
 	Image::GIFDecoder decoder;
 	Common::SeekableReadStream *stream = HQR::makeReadStream(Resources::HQR_FLAGIF_FILE, index);
 	if (stream == nullptr) {
@@ -295,7 +295,7 @@ void FlaMovies::prepareGIF(int index) {
 	_engine->setPalette(_engine->_screens->_paletteRGBA);
 }
 
-void FlaMovies::playGIFMovie(const char *flaName) {
+void Movies::playGIFMovie(const char *flaName) {
 	if (!Common::File::exists(Resources::HQR_FLAGIF_FILE)) {
 		warning("%s file doesn't exist", Resources::HQR_FLAGIF_FILE);
 		return;
@@ -343,7 +343,7 @@ void FlaMovies::playGIFMovie(const char *flaName) {
 	}
 }
 
-void FlaMovies::playFlaMovie(const char *flaName) {
+void Movies::playFlaMovie(const char *flaName) {
 	assert(_engine->isLBA1());
 	_engine->_sound->stopSamples();
 
@@ -438,7 +438,7 @@ void FlaMovies::playFlaMovie(const char *flaName) {
 	_engine->_sound->stopSamples();
 }
 
-void FlaMovies::playSmkMovie(int index) {
+void Movies::playSmkMovie(int index) {
 	assert(_engine->isLBA2());
 	Video::SmackerDecoder decoder;
 	Common::SeekableReadStream *stream = HQR::makeReadStream(TwineResource(Resources::HQR_VIDEO_FILE, index));
diff --git a/engines/twine/flamovies.h b/engines/twine/movies.h
similarity index 98%
rename from engines/twine/flamovies.h
rename to engines/twine/movies.h
index c2171be4d7..eb409e584d 100644
--- a/engines/twine/flamovies.h
+++ b/engines/twine/movies.h
@@ -60,7 +60,7 @@ struct FLAFrameDataStruct {
 
 class TwinEEngine;
 
-class FlaMovies {
+class Movies {
 private:
 	TwinEEngine *_engine;
 
@@ -96,7 +96,7 @@ private:
 	void playGIFMovie(const char *flaName);
 
 public:
-	FlaMovies(TwinEEngine *engine);
+	Movies(TwinEEngine *engine);
 
 	/**
 	 * Play FLA movies
diff --git a/engines/twine/script/script_life_v1.cpp b/engines/twine/script/script_life_v1.cpp
index e753158fba..6e82d1920c 100644
--- a/engines/twine/script/script_life_v1.cpp
+++ b/engines/twine/script/script_life_v1.cpp
@@ -29,7 +29,7 @@
 #include "twine/audio/music.h"
 #include "twine/audio/sound.h"
 #include "twine/scene/collision.h"
-#include "twine/flamovies.h"
+#include "twine/movies.h"
 #include "twine/scene/gamestate.h"
 #include "twine/scene/grid.h"
 #include "twine/holomap.h"
diff --git a/engines/twine/script/script_move_v1.cpp b/engines/twine/script/script_move_v1.cpp
index 7f187490fb..88b90014d5 100644
--- a/engines/twine/script/script_move_v1.cpp
+++ b/engines/twine/script/script_move_v1.cpp
@@ -26,7 +26,7 @@
 #include "common/util.h"
 #include "twine/scene/animations.h"
 #include "twine/audio/sound.h"
-#include "twine/flamovies.h"
+#include "twine/movies.h"
 #include "twine/scene/movements.h"
 #include "twine/renderer/redraw.h"
 #include "twine/renderer/renderer.h"
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 370bed5463..aa2d46acc8 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -49,7 +49,7 @@
 #include "twine/debugger/debug_grid.h"
 #include "twine/debugger/debug_scene.h"
 #include "twine/detection.h"
-#include "twine/flamovies.h"
+#include "twine/movies.h"
 #include "twine/holomap.h"
 #include "twine/input.h"
 #include "twine/menu/interface.h"
@@ -163,7 +163,7 @@ TwinEEngine::TwinEEngine(OSystem *system, Common::Language language, uint32 flag
 	_movements = new Movements(this);
 	_interface = new Interface(this);
 	_menu = new Menu(this);
-	_flaMovies = new FlaMovies(this);
+	_flaMovies = new Movies(this);
 	_menuOptions = new MenuOptions(this);
 	_music = new Music(this);
 	_redraw = new Redraw(this);
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 643acc1992..2a7e5a35a5 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -130,7 +130,7 @@ class Grid;
 class Movements;
 class Interface;
 class Menu;
-class FlaMovies;
+class Movies;
 class MenuOptions;
 class Music;
 class Redraw;
@@ -260,7 +260,7 @@ public:
 	Movements *_movements;
 	Interface *_interface;
 	Menu *_menu;
-	FlaMovies *_flaMovies;
+	Movies *_flaMovies;
 	MenuOptions *_menuOptions;
 	Music *_music;
 	Redraw *_redraw;




More information about the Scummvm-git-logs mailing list