[Scummvm-git-logs] scummvm master -> ad3aba190857be6552d31c4d4b538f35a3c1eb6a
mgerhardy
noreply at scummvm.org
Tue Nov 30 14:40:52 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ad3aba1908 TWINE: added support for lbashow
Commit: ad3aba190857be6552d31c4d4b538f35a3c1eb6a
https://github.com/scummvm/scummvm/commit/ad3aba190857be6552d31c4d4b538f35a3c1eb6a
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-11-30T15:40:48+01:00
Commit Message:
TWINE: added support for lbashow
Changed paths:
A engines/twine/slideshow.cpp
A engines/twine/slideshow.h
engines/twine/detection.cpp
engines/twine/detection.h
engines/twine/menu/menu.cpp
engines/twine/metaengine.cpp
engines/twine/module.mk
engines/twine/twine.cpp
engines/twine/twine.h
image/pcx.h
diff --git a/engines/twine/detection.cpp b/engines/twine/detection.cpp
index 822ad60e77..0000fc6d0e 100644
--- a/engines/twine/detection.cpp
+++ b/engines/twine/detection.cpp
@@ -29,6 +29,7 @@
static const PlainGameDescriptor twineGames[] = {
{ "lba", "Little Big Adventure" },
+ { "lbashow", "Little Big Adventure Freeware Slide Show" },
{ "lba2", "Little Big Adventure 2" },
{ nullptr, nullptr }
};
@@ -596,6 +597,18 @@ static const ADGameDescription twineGameDescriptions[] = {
GUIO1(GUIO_NONE)
},
+ // LBA Freeware Slide Show
+ // 4 Apr 1994
+ {
+ "lbashow",
+ "LBA Freeware Slide Show",
+ AD_ENTRY1s("LBA_SHOW.EXE", "c1a887e38283d43f271249ad9f2a73ef", 85928),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NONE)
+ },
+
// Little Big Adventure 2
// Little Big Adventure 2 - Original European Version (EN, FR, DE, IT, ES)
diff --git a/engines/twine/detection.h b/engines/twine/detection.h
index e760defb9e..7c953a8053 100644
--- a/engines/twine/detection.h
+++ b/engines/twine/detection.h
@@ -27,7 +27,9 @@ namespace TwinE {
enum TwineGameType {
GType_LBA = 1,
- GType_LBA2 = 2
+ GType_LBA2 = 2,
+ // slideshow demo of lba1
+ GType_LBASHOW = 3
};
enum TwineFeatureFlags {
diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp
index efdaa29fde..41b01eef69 100644
--- a/engines/twine/menu/menu.cpp
+++ b/engines/twine/menu/menu.cpp
@@ -764,6 +764,8 @@ static const byte cursorPalette[] = {
0xff, 0xff, 0xff};
bool Menu::init() {
+ _engine->_input->enableKeyMap(uiKeyMapId);
+ _engine->_screens->loadMenuImage();
// load menu effect file only once
_plasmaEffectPtr = (uint8 *)malloc(kPlasmaEffectFilesize);
memset(_plasmaEffectPtr, 0, kPlasmaEffectFilesize);
diff --git a/engines/twine/metaengine.cpp b/engines/twine/metaengine.cpp
index 097b9116fe..9049a3c687 100644
--- a/engines/twine/metaengine.cpp
+++ b/engines/twine/metaengine.cpp
@@ -55,6 +55,8 @@ public:
gameType = TwineGameType::GType_LBA;
} else if (gameId == "lba2") {
gameType = TwineGameType::GType_LBA2;
+ } else if (gameId == "lbashow") {
+ gameType = TwineGameType::GType_LBASHOW;
}
*engine = new TwinE::TwinEEngine(syst, desc->language, desc->flags, gameType);
return Common::kNoError;
diff --git a/engines/twine/module.mk b/engines/twine/module.mk
index b7ea4919a4..3b909bffdc 100644
--- a/engines/twine/module.mk
+++ b/engines/twine/module.mk
@@ -47,6 +47,7 @@ MODULE_OBJS := \
input.o \
metaengine.o \
shared.o \
+ slideshow.o \
text.o \
twine.o
diff --git a/engines/twine/slideshow.cpp b/engines/twine/slideshow.cpp
new file mode 100644
index 0000000000..db09f19ab2
--- /dev/null
+++ b/engines/twine/slideshow.cpp
@@ -0,0 +1,248 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "twine/slideshow.h"
+#include "common/file.h"
+#include "common/tokenizer.h"
+#include "image/pcx.h"
+#include "twine/movies.h"
+#include "twine/renderer/screens.h"
+#include "twine/resources/resources.h"
+#include "twine/text.h"
+#include "twine/twine.h"
+
+namespace TwinE {
+
+class Slideshow {
+private:
+ TwinEEngine *_engine;
+ int _textY = 0;
+ bool _aborted = false;
+ int _lineHeight = 40;
+ uint32 _pal[NUMOFCOLORS]{};
+
+ void setPalette(const uint8 *in, int colors) {
+ uint8 *paletteOut = (uint8 *)_pal;
+ for (int i = 0; i < colors; i++) {
+ paletteOut[0] = in[0];
+ paletteOut[1] = in[1];
+ paletteOut[2] = in[2];
+ paletteOut[3] = 0xFF;
+ paletteOut += 4;
+ in += 3;
+ }
+ _engine->setPalette(_pal);
+ }
+
+ bool loadPCX(const Common::String &pcx, bool onlyPalette = false) {
+ Image::PCXDecoder decoder;
+ Common::File file;
+ if (!file.open(pcx)) {
+ return false;
+ }
+
+ if (!decoder.loadStream(file)) {
+ return false;
+ }
+ const Graphics::Surface *src = decoder.getSurface();
+ if (src == nullptr) {
+ return false;
+ }
+
+ Graphics::ManagedSurface &target = _engine->_frontVideoBuffer;
+ target.blitFrom(src);
+
+ if (decoder.hasPalette()) {
+ setPalette(decoder.getPalette(), decoder.getPaletteColorCount());
+ }
+ return true;
+ }
+
+ bool loadFont() {
+ Common::File font;
+ if (!font.open("LBA.FNT")) {
+ return false;
+ }
+ _engine->_resources->_fontBufSize = (int)font.size();
+ _engine->_resources->_fontPtr = (uint8 *)malloc(_engine->_resources->_fontBufSize);
+ font.read(_engine->_resources->_fontPtr, _engine->_resources->_fontBufSize);
+
+ _engine->_text->setFontParameters(4, 8);
+ return true;
+ }
+
+ void scriptCls() {
+ _textY = 0;
+ _engine->_screens->clearScreen();
+ }
+
+ void scriptPause(const Common::String ¶ms) {
+ _engine->_frontVideoBuffer.update();
+ const int seconds = atoi(params.c_str());
+ if (_engine->delaySkip(1000 * seconds)) {
+ _aborted = true;
+ }
+ }
+
+ void scriptColor(const Common::String ¶ms) {
+ const int color = atoi(params.c_str());
+ _engine->_text->setFontColor(color);
+ }
+
+ void scriptText(const Common::String ¶ms) {
+ if (!params.empty()) {
+ _pal[255] = _pal[15] = 0xffffffff;
+ _engine->setPalette(_pal);
+ const int32 length = _engine->_text->getTextSize(params.c_str());
+ const int x = 0;
+ _engine->_text->drawText(x, _textY, params.c_str());
+ _engine->_frontVideoBuffer.addDirtyRect(Common::Rect(x, _textY, x + length, _textY + _lineHeight));
+ }
+ _textY += _lineHeight;
+ }
+
+ void scriptRText(const Common::String ¶ms) {
+ if (!params.empty()) {
+ _pal[255] = _pal[15] = 0xffffffff;
+ _engine->setPalette(_pal);
+ const int32 length = _engine->_text->getTextSize(params.c_str());
+ const int x = _engine->width() - length;
+ _engine->_text->drawText(x, _textY, params.c_str());
+ _engine->_frontVideoBuffer.update();
+ _engine->_frontVideoBuffer.addDirtyRect(Common::Rect(x, _textY, x + length, _textY + _lineHeight));
+ }
+ _textY += _lineHeight;
+ }
+
+ void scriptTitle(const Common::String ¶ms) {
+ if (!params.empty()) {
+ _pal[255] = _pal[15] = 0xffffffff;
+ _engine->setPalette(_pal);
+ const int32 length = _engine->_text->getTextSize(params.c_str());
+ const int x = _engine->width() / 2 - length / 2;
+ _engine->_text->drawText(x, _textY, params.c_str());
+ _engine->_frontVideoBuffer.addDirtyRect(Common::Rect(x, _textY, x + length, _textY + _lineHeight));
+ }
+ _textY += _lineHeight;
+ }
+
+ void scriptFadeIn() {
+ _engine->_screens->fadeIn(_pal);
+ }
+
+ void scriptFadeOut() {
+ _engine->_screens->fadeOut(_pal);
+ }
+
+ void scriptPCX(const Common::String ¶ms) {
+ loadPCX(params + ".PCX");
+ }
+
+ void scriptShow() {
+ // TODO: _engine->setPalette(_pal);
+ // or updateScreen?
+ }
+
+ void scriptFLA(const Common::String ¶ms) {
+ if (!_engine->_movie->playMovie(params.c_str())) {
+ _aborted = true;
+ }
+ }
+
+ bool playScript() {
+ Common::File scriptFile;
+ if (!scriptFile.open("LBA_SHOW.SHO")) {
+ return false;
+ }
+ while (!scriptFile.eos() && !scriptFile.err()) {
+ if (_aborted) {
+ break;
+ }
+ const Common::String &line = scriptFile.readLine();
+ if (line.empty()) {
+ continue;
+ }
+ Common::String cmd;
+ Common::String params;
+ const size_t index = line.findFirstOf(' ');
+ if (index == Common::String::npos) {
+ cmd = line;
+ } else {
+ cmd = line.substr(0, index);
+ params = line.substr(index + 1);
+ }
+ debug("cmd: '%s %s'", cmd.c_str(), params.c_str());
+ if (cmd == "cls") {
+ scriptCls();
+ } else if (cmd == "text") {
+ scriptText(params);
+ } else if (cmd == "rtext") {
+ scriptRText(params);
+ } else if (cmd == "title") {
+ scriptTitle(params);
+ } else if (cmd == "color") {
+ scriptColor(params);
+ } else if (cmd == "pause") {
+ scriptPause(params);
+ } else if (cmd == "pcx") {
+ scriptPCX(params);
+ } else if (cmd == "fla") {
+ scriptFLA(params);
+ } else if (cmd == "fade_in") {
+ scriptFadeIn();
+ } else if (cmd == "fade_out") {
+ scriptFadeOut();
+ } else if (cmd == "show") {
+ scriptShow();
+ } else if (cmd == "restart") {
+ return true;
+ } else {
+ warning("Unknown command %s (%s)", cmd.c_str(), params.c_str());
+ }
+ }
+
+ return false;
+ }
+
+public:
+ Slideshow(TwinEEngine *engine) : _engine(engine) {
+ }
+
+ ~Slideshow() {
+ free(_engine->_resources->_fontPtr);
+ _engine->_resources->_fontPtr = nullptr;
+ }
+
+ void play() {
+ loadFont();
+ loadPCX("ADELINE.PCX", true);
+ while (playScript()) {
+ }
+ }
+};
+
+void playSlideShow(TwinEEngine *engine) {
+ Slideshow slideshow(engine);
+ slideshow.play();
+}
+
+} // namespace TwinE
diff --git a/engines/twine/slideshow.h b/engines/twine/slideshow.h
new file mode 100644
index 0000000000..ed1702ac68
--- /dev/null
+++ b/engines/twine/slideshow.h
@@ -0,0 +1,35 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TWINE_SLIDESHOW_H
+#define TWINE_SLIDESHOW_H
+
+#include "twine/input.h"
+namespace TwinE {
+
+class TwinEEngine;
+
+void playSlideShow(TwinEEngine *engine);
+
+} // namespace TwinE
+
+#endif
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index f514c2a99b..43f3fbe8c2 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -70,6 +70,7 @@
#include "twine/scene/scene.h"
#include "twine/script/script_life_v1.h"
#include "twine/script/script_move_v1.h"
+#include "twine/slideshow.h"
#include "twine/text.h"
namespace TwinE {
@@ -104,7 +105,7 @@ FrameMarker::~FrameMarker() {
const uint32 frameTime = end - _start;
const uint32 maxDelay = 1000 / _fps;
if (frameTime > maxDelay) {
- debug("Frame took longer than the max allowed time: %u (max is %u)", frameTime, maxDelay);
+ debug(5, "Frame took longer than the max allowed time: %u (max is %u)", frameTime, maxDelay);
return;
}
const uint32 waitMillis = maxDelay - frameTime;
@@ -255,8 +256,14 @@ Common::Error TwinEEngine::run() {
initGraphics(w, h);
allocVideoMemory(w, h);
+ if (isLBASlideShow()) {
+ playSlideShow(this);
+ return Common::kNoError;
+ }
+ _renderer->init(w, h);
+ _grid->init(w, h);
initAll();
- initEngine();
+ playIntro();
_sound->stopSamples();
saveFrontBuffer();
@@ -380,8 +387,6 @@ void TwinEEngine::allocVideoMemory(int32 w, int32 h) {
_workVideoBuffer.create(w, h, format);
_frontVideoBuffer.create(w, h, format);
- _renderer->init(w, h);
- _grid->init(w, h);
}
static int getLanguageTypeIndex(const char *languageName) {
@@ -476,12 +481,7 @@ void TwinEEngine::queueMovie(const char *filename) {
_queuedFlaMovie = filename;
}
-void TwinEEngine::initEngine() {
- _screens->clearScreen();
-
- // Check if LBA CD-Rom is on drive
- _music->initCdrom();
-
+void TwinEEngine::playIntro() {
_input->enableKeyMap(cutsceneKeyMapId);
// Display company logo
bool abort = false;
@@ -522,9 +522,6 @@ void TwinEEngine::initEngine() {
_movie->playMovie("INTRO");
}
}
- _input->enableKeyMap(uiKeyMapId);
-
- _screens->loadMenuImage();
}
void TwinEEngine::initSceneryView() {
@@ -547,6 +544,11 @@ void TwinEEngine::initAll() {
_resources->initResources();
exitSceneryView();
+
+ _screens->clearScreen();
+
+ // Check if LBA CD-Rom is on drive
+ _music->initCdrom();
}
int TwinEEngine::getRandomNumber(uint max) {
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index d7556a5c88..e3a9a96947 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -210,7 +210,7 @@ private:
void initConfigurations();
/** Initialize all needed stuffs at first time running engine */
void initAll();
- void initEngine();
+ void playIntro();
void processActorSamplePosition(int32 actorIdx);
/** Allocate video memory, both front and back buffers */
void allocVideoMemory(int32 w, int32 h);
@@ -242,6 +242,7 @@ public:
bool isLBA1() const { return _gameType == TwineGameType::GType_LBA; }
bool isLBA2() const { return _gameType == TwineGameType::GType_LBA2; }
+ bool isLBASlideShow() const { return _gameType == TwineGameType::GType_LBASHOW; }
bool isMod() const { return (_gameFlags & TwinE::TF_MOD) != 0; }
bool isDotEmuEnhanced() const { return (_gameFlags & TwinE::TF_DOTEMU_ENHANCED) != 0; }
bool isDemo() const { return (_gameFlags & ADGF_DEMO) != 0; };
@@ -334,6 +335,7 @@ public:
/**
* Deplay certain seconds till proceed - Can also Skip this delay
* @param time time in milliseconds to delay
+ * @return @c true if the delay was aborted, @c false otherwise
*/
bool delaySkip(uint32 time);
diff --git a/image/pcx.h b/image/pcx.h
index 7e9dbf6285..d144a26660 100644
--- a/image/pcx.h
+++ b/image/pcx.h
@@ -44,6 +44,7 @@ namespace Image {
* - Hugo
* - Queen
* - Tucker
+ * - TwinE
* @{
*/
More information about the Scummvm-git-logs
mailing list