[Scummvm-git-logs] scummvm master -> 619aa0227321266352796b84b252196e263d5fbd

dreammaster paulfgilbert at gmail.com
Sat Mar 21 21:34:33 UTC 2020


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:
619aa02273 ULTIMA8: Add short fade in/out around menu items to match original game


Commit: 619aa0227321266352796b84b252196e263d5fbd
    https://github.com/scummvm/scummvm/commit/619aa0227321266352796b84b252196e263d5fbd
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-03-21T14:34:28-07:00

Commit Message:
ULTIMA8: Add short fade in/out around menu items to match original game

Changed paths:
  A engines/ultima/ultima8/graphics/fade_to_modal_process.cpp
  A engines/ultima/ultima8/graphics/fade_to_modal_process.h
    engines/ultima/module.mk
    engines/ultima/ultima8/audio/music_process.cpp
    engines/ultima/ultima8/games/game.cpp
    engines/ultima/ultima8/games/game.h
    engines/ultima/ultima8/games/remorse_game.cpp
    engines/ultima/ultima8/games/remorse_game.h
    engines/ultima/ultima8/games/start_u8_process.cpp
    engines/ultima/ultima8/games/u8_game.cpp
    engines/ultima/ultima8/games/u8_game.h
    engines/ultima/ultima8/graphics/palette_fader_process.cpp
    engines/ultima/ultima8/gumps/menu_gump.cpp
    engines/ultima/ultima8/gumps/movie_gump.cpp
    engines/ultima/ultima8/gumps/movie_gump.h
    engines/ultima/ultima8/kernel/process.cpp
    engines/ultima/ultima8/kernel/process.h
    engines/ultima/ultima8/misc/debugger.cpp


diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index c80c42e095..aace6bd4eb 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -361,6 +361,7 @@ MODULE_OBJS := \
 	ultima8/graphics/anim_dat.o \
 	ultima8/graphics/base_soft_render_surface.o \
 	ultima8/graphics/frame_id.o \
+	ultima8/graphics/fade_to_modal_process.o \
 	ultima8/graphics/gump_shape_archive.o \
 	ultima8/graphics/inverter_process.o \
 	ultima8/graphics/main_shape_archive.o \
diff --git a/engines/ultima/ultima8/audio/music_process.cpp b/engines/ultima/ultima8/audio/music_process.cpp
index a95a4c72fe..e74e2c0e51 100644
--- a/engines/ultima/ultima8/audio/music_process.cpp
+++ b/engines/ultima/ultima8/audio/music_process.cpp
@@ -47,8 +47,8 @@ MusicProcess::MusicProcess(MidiPlayer *player) : _midiPlayer(player),
 	Std::memset(_songBranches, (byte)-1, 128 * sizeof(int));
 
 	_theMusicProcess = this;
-	_flags |= PROC_RUNPAUSED;
 	_type = 1; // persistent
+	setRunPaused();
 }
 
 MusicProcess::~MusicProcess() {
diff --git a/engines/ultima/ultima8/games/game.cpp b/engines/ultima/ultima8/games/game.cpp
index d0ee69a994..0cc33ea631 100644
--- a/engines/ultima/ultima8/games/game.cpp
+++ b/engines/ultima/ultima8/games/game.cpp
@@ -69,7 +69,7 @@ uint32 Game::I_playEndgame(const uint8 *args, unsigned int /*argsize*/) {
 	Process *menuproc = new MainMenuProcess();
 	Kernel::get_instance()->addProcess(menuproc);
 
-	ProcId moviepid = Game::get_instance()->playEndgameMovie();
+	ProcId moviepid = Game::get_instance()->playEndgameMovie(false);
 	Process *movieproc = Kernel::get_instance()->getProcess(moviepid);
 	if (movieproc) {
 		menuproc->waitFor(movieproc);
diff --git a/engines/ultima/ultima8/games/game.h b/engines/ultima/ultima8/games/game.h
index f11cf0dec2..b8c619c8eb 100644
--- a/engines/ultima/ultima8/games/game.h
+++ b/engines/ultima/ultima8/games/game.h
@@ -52,8 +52,8 @@ public:
 	//! write game-specific savegame info (avatar stats, equipment, ...)
 	virtual void writeSaveInfo(ODataSource *ods) = 0;
 
-	virtual ProcId playIntroMovie() = 0;
-	virtual ProcId playEndgameMovie() = 0;
+	virtual ProcId playIntroMovie(bool fade) = 0;
+	virtual ProcId playEndgameMovie(bool fade) = 0;
 	virtual void playCredits() = 0;
 	virtual void playQuotes() = 0;
 
diff --git a/engines/ultima/ultima8/games/remorse_game.cpp b/engines/ultima/ultima8/games/remorse_game.cpp
index e21e602023..09eaaeff66 100644
--- a/engines/ultima/ultima8/games/remorse_game.cpp
+++ b/engines/ultima/ultima8/games/remorse_game.cpp
@@ -107,11 +107,11 @@ bool RemorseGame::startInitialUsecode(int saveSlot) {
 }
 
 
-ProcId RemorseGame::playIntroMovie() {
+ProcId RemorseGame::playIntroMovie(bool fade) {
 	return 0;
 }
 
-ProcId RemorseGame::playEndgameMovie() {
+ProcId RemorseGame::playEndgameMovie(bool fade) {
 	return 0;
 }
 
diff --git a/engines/ultima/ultima8/games/remorse_game.h b/engines/ultima/ultima8/games/remorse_game.h
index db6e1f3e6b..5dd054ab17 100644
--- a/engines/ultima/ultima8/games/remorse_game.h
+++ b/engines/ultima/ultima8/games/remorse_game.h
@@ -45,8 +45,8 @@ public:
 	//! write game-specific savegame info (avatar stats, equipment, ...)
 	void writeSaveInfo(ODataSource *ods) override;
 
-	ProcId playIntroMovie() override;
-	ProcId playEndgameMovie() override;
+	ProcId playIntroMovie(bool fade) override;
+	ProcId playEndgameMovie(bool fade) override;
 	void playCredits() override;
 	void playQuotes() override { };
 
diff --git a/engines/ultima/ultima8/games/start_u8_process.cpp b/engines/ultima/ultima8/games/start_u8_process.cpp
index 5971d93feb..57311fff74 100644
--- a/engines/ultima/ultima8/games/start_u8_process.cpp
+++ b/engines/ultima/ultima8/games/start_u8_process.cpp
@@ -53,7 +53,7 @@ StartU8Process::StartU8Process(int saveSlot) : Process(),
 void StartU8Process::run() {
 	if (!_skipStart && !_init) {
 		_init = true;
-		ProcId moviepid = Game::get_instance()->playIntroMovie();
+		ProcId moviepid = Game::get_instance()->playIntroMovie(false);
 		Process *movieproc = Kernel::get_instance()->getProcess(moviepid);
 		if (movieproc) {
 			waitFor(movieproc);
diff --git a/engines/ultima/ultima8/games/u8_game.cpp b/engines/ultima/ultima8/games/u8_game.cpp
index c89284d6d9..cae3f6c264 100644
--- a/engines/ultima/ultima8/games/u8_game.cpp
+++ b/engines/ultima/ultima8/games/u8_game.cpp
@@ -25,6 +25,7 @@
 #include "ultima/ultima8/games/u8_game.h"
 
 #include "ultima/ultima8/graphics/palette_manager.h"
+#include "ultima/ultima8/graphics/fade_to_modal_process.h"
 #include "ultima/ultima8/filesys/idata_source.h"
 #include "ultima/ultima8/filesys/file_system.h"
 #include "ultima/ultima8/games/game_data.h"
@@ -153,7 +154,7 @@ bool U8Game::startInitialUsecode(int saveSlot) {
 }
 
 
-ProcId U8Game::playIntroMovie() {
+ProcId U8Game::playIntroMovie(bool fade) {
 	GameInfo *gameinfo = CoreApp::get_instance()->getGameInfo();
 	char langletter = gameinfo->getLanguageFileLetter();
 	if (!langletter) {
@@ -173,10 +174,10 @@ ProcId U8Game::playIntroMovie() {
 	}
 
 	RawArchive *flex = new RawArchive(skf);
-	return MovieGump::U8MovieViewer(flex, true);
+	return MovieGump::U8MovieViewer(flex, fade, true);
 }
 
-ProcId U8Game::playEndgameMovie() {
+ProcId U8Game::playEndgameMovie(bool fade) {
 	Std::string filename = "@game/static/endgame.skf";
 	FileSystem *filesys = FileSystem::get_instance();
 	IDataSource *skf = filesys->ReadFile(filename);
@@ -186,7 +187,7 @@ ProcId U8Game::playEndgameMovie() {
 	}
 
 	RawArchive *flex = new RawArchive(skf);
-	return MovieGump::U8MovieViewer(flex);
+	return MovieGump::U8MovieViewer(flex, fade);
 }
 
 void U8Game::playCredits() {
@@ -213,9 +214,9 @@ void U8Game::playCredits() {
 	if (musicproc) musicproc->playMusic(51); // CONSTANT!
 
 	CreditsGump *gump = new CreditsGump(text);
-	gump->InitGump(0);
 	gump->SetFlagWhenFinished("quotes");
-	gump->setRelativePosition(Gump::CENTER);
+	FadeToModalProcess *p = new FadeToModalProcess(gump);
+	Kernel::get_instance()->addProcess(p);
 }
 
 void U8Game::playQuotes() {
@@ -233,9 +234,9 @@ void U8Game::playQuotes() {
 	MusicProcess *musicproc = MusicProcess::get_instance();
 	if (musicproc) musicproc->playMusic(113); // CONSTANT!
 
-	Gump *gump = new CreditsGump(text, 80);
-	gump->InitGump(0);
-	gump->setRelativePosition(Gump::CENTER);
+	CreditsGump *gump = new CreditsGump(text, 80);
+	FadeToModalProcess *p = new FadeToModalProcess(gump);
+	Kernel::get_instance()->addProcess(p);
 }
 
 
diff --git a/engines/ultima/ultima8/games/u8_game.h b/engines/ultima/ultima8/games/u8_game.h
index ac255e1dc0..594f7c802f 100644
--- a/engines/ultima/ultima8/games/u8_game.h
+++ b/engines/ultima/ultima8/games/u8_game.h
@@ -47,8 +47,8 @@ public:
 	//! write game-specific savegame info (avatar stats, equipment, ...)
 	void writeSaveInfo(ODataSource *ods) override;
 
-	ProcId playIntroMovie() override;
-	ProcId playEndgameMovie() override;
+	ProcId playIntroMovie(bool fade) override;
+	ProcId playEndgameMovie(bool fade) override;
 	void playCredits() override;
 	void playQuotes() override;
 
diff --git a/engines/ultima/ultima8/graphics/fade_to_modal_process.cpp b/engines/ultima/ultima8/graphics/fade_to_modal_process.cpp
new file mode 100644
index 0000000000..5025f769a1
--- /dev/null
+++ b/engines/ultima/ultima8/graphics/fade_to_modal_process.cpp
@@ -0,0 +1,100 @@
+/* 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 "ultima/ultima8/misc/pent_include.h"
+#include "ultima/ultima8/graphics/palette_fader_process.h"
+#include "ultima/ultima8/graphics/fade_to_modal_process.h"
+#include "ultima/ultima8/kernel/kernel.h"
+#include "ultima/ultima8/gumps/modal_gump.h"
+#include "ultima/ultima8/gumps/gump_notify_process.h"
+
+namespace Ultima {
+namespace Ultima8 {
+
+// p_dynamic_class stuff
+DEFINE_RUNTIME_CLASSTYPE_CODE(FadeToModalProcess, Process)
+
+
+FadeToModalProcess::FadeToModalProcess(ModalGump *modal)
+	: _modal(modal), _nextState(FS_OpenFadeOut), _fader(nullptr)
+{
+	setRunPaused();
+}
+
+FadeToModalProcess::~FadeToModalProcess(void) {
+}
+
+void FadeToModalProcess::onWakeUp() {
+	if (_nextState == FS_CloseFadeIn) {
+		// Jump in now and make sure the fade in is started (ie, we go to black)
+		// before the modal is closed, otherwise a single frame of the thing
+		// behind it will be shown first.
+		_fader = new PaletteFaderProcess(0x00000000, true, 0x7FFF, 30, false);
+		_fader->run();
+	}
+}
+
+void FadeToModalProcess::run() {
+	switch (_nextState) {
+		case FS_OpenFadeOut:
+		{
+			_fader = new PaletteFaderProcess(0x00000000, false, 0x7FFF, 30, true);
+			Kernel::get_instance()->addProcess(_fader);
+			_fader->setRunPaused();
+			_nextState = FS_ShowGump;
+			waitFor(_fader);
+			break;
+		}
+		case FS_ShowGump:
+		{
+			// kernel will delete the fader object for us
+			_fader = nullptr;
+			_modal->InitGump(0);
+			_modal->setRelativePosition(Gump::CENTER);
+			_modal->CreateNotifier();
+			// Reset the palette before showing the modal
+			PaletteManager::get_instance()->untransformPalette(PaletteManager::Pal_Game);
+			_nextState = FS_CloseFadeIn;
+			waitFor(_modal->GetNotifyProcess());
+			break;
+		}
+		case FS_CloseFadeIn:
+		{
+			// Already created a new fader in onWakeUp..
+			Kernel::get_instance()->addProcess(_fader);
+			_fader->setRunPaused();
+			_nextState = FS_Finshed;
+			waitFor(_fader);
+			break;
+		}
+		case FS_Finshed:
+		{
+			// kernel will delete the fader object for us
+			_fader = nullptr;
+			terminate();
+			break;
+		}
+	}
+}
+
+} // End of namespace Ultima8
+} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/graphics/fade_to_modal_process.h b/engines/ultima/ultima8/graphics/fade_to_modal_process.h
new file mode 100644
index 0000000000..d78dfc76d2
--- /dev/null
+++ b/engines/ultima/ultima8/graphics/fade_to_modal_process.h
@@ -0,0 +1,62 @@
+/* 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 ULTIMA8_GRAPHICS_FADETOMODALPROCESS_H
+#define ULTIMA8_GRAPHICS_FADETOMODALPROCESS_H
+
+#include "ultima/ultima8/kernel/process.h"
+#include "ultima/ultima8/gumps/modal_gump.h"
+#include "ultima/ultima8/misc/p_dynamic_cast.h"
+
+namespace Ultima {
+namespace Ultima8 {
+
+class PaletteFaderProcess;
+
+class FadeToModalProcess : public Process {
+
+	enum FadeToModalState {
+		FS_OpenFadeOut,
+		FS_ShowGump,
+		FS_CloseFadeIn,
+		FS_Finshed
+	} _nextState;
+
+	ModalGump * _modal;
+	PaletteFaderProcess * _fader;
+
+public:
+	// p_dynamic_class stuff
+	ENABLE_RUNTIME_CLASSTYPE()
+	FadeToModalProcess(ModalGump *modal);
+	~FadeToModalProcess(void) override;
+
+	void onWakeUp() override;
+
+	void run() override;
+
+};
+
+} // End of namespace Ultima8
+} // End of namespace Ultima
+
+#endif
diff --git a/engines/ultima/ultima8/graphics/palette_fader_process.cpp b/engines/ultima/ultima8/graphics/palette_fader_process.cpp
index ffe79d4dbf..1443d2c4ff 100644
--- a/engines/ultima/ultima8/graphics/palette_fader_process.cpp
+++ b/engines/ultima/ultima8/graphics/palette_fader_process.cpp
@@ -31,15 +31,12 @@
 namespace Ultima {
 namespace Ultima8 {
 
-#define PALETTEFADER_COUNTER    30
-
 PaletteFaderProcess *PaletteFaderProcess::_fader = nullptr;
 
 // p_dynamic_class stuff
 DEFINE_RUNTIME_CLASSTYPE_CODE(PaletteFaderProcess, Process)
 
 PaletteFaderProcess::PaletteFaderProcess() : Process() {
-
 }
 
 PaletteFaderProcess::PaletteFaderProcess(PalTransforms trans,
diff --git a/engines/ultima/ultima8/gumps/menu_gump.cpp b/engines/ultima/ultima8/gumps/menu_gump.cpp
index 7c3a009af1..a0cd836606 100644
--- a/engines/ultima/ultima8/gumps/menu_gump.cpp
+++ b/engines/ultima/ultima8/gumps/menu_gump.cpp
@@ -223,7 +223,7 @@ void MenuGump::selectEntry(int entry) {
 
 	switch (entry) {
 	case 1: // Intro
-		Game::get_instance()->playIntroMovie();
+		Game::get_instance()->playIntroMovie(true);
 		break;
 	case 2:
 	case 3: // Read/Write Diary
@@ -245,7 +245,7 @@ void MenuGump::selectEntry(int entry) {
 		if (quotes) Game::get_instance()->playQuotes();
 		break;
 	case 8: // End Game
-		if (endgame) Game::get_instance()->playEndgameMovie();
+		if (endgame) Game::get_instance()->playEndgameMovie(true);
 		break;
 	default:
 		break;
diff --git a/engines/ultima/ultima8/gumps/movie_gump.cpp b/engines/ultima/ultima8/gumps/movie_gump.cpp
index 2fc3700352..9989ebea15 100644
--- a/engines/ultima/ultima8/gumps/movie_gump.cpp
+++ b/engines/ultima/ultima8/gumps/movie_gump.cpp
@@ -25,7 +25,9 @@
 
 #include "ultima/ultima8/filesys/raw_archive.h"
 #include "ultima/ultima8/graphics/skf_player.h"
+#include "ultima/ultima8/graphics/fade_to_modal_process.h"
 #include "ultima/ultima8/ultima8.h"
+#include "ultima/ultima8/kernel/kernel.h"
 #include "ultima/ultima8/gumps/desktop_gump.h"
 #include "ultima/ultima8/gumps/gump_notify_process.h"
 
@@ -94,12 +96,20 @@ bool MovieGump::OnKeyDown(int key, int mod) {
 }
 
 //static
-ProcId MovieGump::U8MovieViewer(RawArchive *movie, bool introMusicHack) {
-	Gump *gump = new MovieGump(320, 200, movie, introMusicHack);
-	gump->InitGump(0);
-	gump->setRelativePosition(CENTER);
-	gump->CreateNotifier();
-	return gump->GetNotifyProcess()->getPid();
+ProcId MovieGump::U8MovieViewer(RawArchive *movie, bool fade, bool introMusicHack) {
+	ModalGump *gump = new MovieGump(320, 200, movie, introMusicHack);
+	if (fade) {
+		FadeToModalProcess *p = new FadeToModalProcess(gump);
+		Kernel::get_instance()->addProcess(p);
+		return p->getPid();
+	}
+	else
+	{
+		gump->InitGump(0);
+		gump->setRelativePosition(CENTER);
+		gump->CreateNotifier();
+		return gump->GetNotifyProcess()->getPid();
+	}
 }
 
 bool MovieGump::loadData(IDataSource *ids) {
diff --git a/engines/ultima/ultima8/gumps/movie_gump.h b/engines/ultima/ultima8/gumps/movie_gump.h
index fa4330583d..7674780da1 100644
--- a/engines/ultima/ultima8/gumps/movie_gump.h
+++ b/engines/ultima/ultima8/gumps/movie_gump.h
@@ -52,7 +52,7 @@ public:
 
 	bool OnKeyDown(int key, int mod) override;
 
-	static ProcId U8MovieViewer(RawArchive *skf, bool introMusicHack = false);
+	static ProcId U8MovieViewer(RawArchive *skf, bool fade, bool introMusicHack = false);
 
 	bool loadData(IDataSource *ids);
 protected:
diff --git a/engines/ultima/ultima8/kernel/process.cpp b/engines/ultima/ultima8/kernel/process.cpp
index 57f7a526c1..9ae109907d 100644
--- a/engines/ultima/ultima8/kernel/process.cpp
+++ b/engines/ultima/ultima8/kernel/process.cpp
@@ -69,6 +69,8 @@ void Process::wakeUp(uint32 result_) {
 	_flags &= ~PROC_SUSPENDED;
 
 	Kernel::get_instance()->setNextProcess(this);
+
+	onWakeUp();
 }
 
 void Process::waitFor(ProcId pid_) {
diff --git a/engines/ultima/ultima8/kernel/process.h b/engines/ultima/ultima8/kernel/process.h
index 80b88deea2..d3cdadd8f6 100644
--- a/engines/ultima/ultima8/kernel/process.h
+++ b/engines/ultima/ultima8/kernel/process.h
@@ -74,6 +74,11 @@ public:
 		_flags |= PROC_TERM_DEFERRED;
 	}
 
+	//! run even when paused
+	void setRunPaused() {
+		_flags |= PROC_RUNPAUSED;
+	};
+
 	//! suspend until process '_pid' returns. If _pid is 0, suspend indefinitely
 	void waitFor(ProcId _pid);
 
@@ -83,8 +88,12 @@ public:
 	//! suspend process
 	void suspend();
 
+	//! Wake up when the process we were waiting for has finished
 	void wakeUp(uint32 result);
 
+	//! A hook to add aditional behavior on wakeup, before anything else happens
+	virtual void onWakeUp() {};
+
 	void setItemNum(ObjId it) {
 		_itemNum = it;
 	}
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index 6a69c245e8..38d67edeb7 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -1438,7 +1438,7 @@ bool Debugger::cmdPlayMovie(int argc, const char **argv) {
 	}
 
 	RawArchive *flex = new RawArchive(skf);
-	MovieGump::U8MovieViewer(flex);
+	MovieGump::U8MovieViewer(flex, false);
 	return false;
 }
 




More information about the Scummvm-git-logs mailing list