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

sluicebox noreply at scummvm.org
Tue Aug 2 21:23:43 UTC 2022


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

Summary:
9d40b46f7e SCI: SciEngine was accessing itself through globals
e09010f7d8 SCI: Restrict kGetEvent throttling to fast cast mode
e672a7b5f6 SCI: Show all palette cycles on PQ1, PQ3 tile screen


Commit: 9d40b46f7e8c878954a36766bfb66098b83c06f8
    https://github.com/scummvm/scummvm/commit/9d40b46f7e8c878954a36766bfb66098b83c06f8
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2022-08-02T17:23:34-04:00

Commit Message:
SCI: SciEngine was accessing itself through globals

Changed paths:
    engines/sci/sci.cpp


diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index 82d222622a7..11e73f13d12 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -377,7 +377,7 @@ Common::Error SciEngine::run() {
 
 		// Jones only initializes its menus when restarting/restoring, thus set
 		// the gameIsRestarting flag here before initializing. Fixes bug #6536.
-		if (g_sci->getGameId() == GID_JONES)
+		if (getGameId() == GID_JONES)
 			_gamestate->gameIsRestarting = GAMEISRESTARTING_RESTORE;
 	}
 
@@ -603,7 +603,7 @@ void SciEngine::initGraphics() {
 #ifdef ENABLE_SCI32
 	if (getSciVersion() >= SCI_VERSION_2) {
 		// SCI32 graphic objects creation
-		if (g_sci->getPlatform() == Common::kPlatformMacintosh && _resMan->hasResourceType(kResourceTypeCursor)) {
+		if (getPlatform() == Common::kPlatformMacintosh && _resMan->hasResourceType(kResourceTypeCursor)) {
 			_gfxCursor32 = new GfxMacCursor32();
 		} else {
 			_gfxCursor32 = new GfxCursor32();
@@ -866,7 +866,7 @@ void SciEngine::sleep(uint32 msecs) {
 		_eventMan->getSciEvent(kSciEventPeek);
 
 		// There is no point in waiting any more if we are just waiting to quit
-		if (g_engine->shouldQuit()) {
+		if (shouldQuit()) {
 			return;
 		}
 
@@ -875,7 +875,7 @@ void SciEngine::sleep(uint32 msecs) {
 		// movement is still occurring and the screen needs to be updated to
 		// reflect it
 		if (getSciVersion() >= SCI_VERSION_2) {
-			g_sci->_gfxFrameout->updateScreen();
+			_gfxFrameout->updateScreen();
 		}
 #endif
 		time = g_system->getMillis();
@@ -903,7 +903,7 @@ void SciEngine::setLauncherLanguage() {
 		case Common::JA_JPN: {
 			// Set Japanese for FM-Towns games
 			// KQ5 on FM-Towns has no initial language set
-			if (g_sci->getPlatform() == Common::kPlatformFMTowns) {
+			if (getPlatform() == Common::kPlatformFMTowns) {
 				languageToSet = K_LANG_JAPANESE;
 			}
 		}
@@ -975,9 +975,9 @@ void SciEngine::loadMacExecutable() {
 }
 
 uint32 SciEngine::getTickCount() {
-	return g_engine->getTotalPlayTime() * 60 / 1000;
+	return getTotalPlayTime() * 60 / 1000;
 }
 void SciEngine::setTickCount(const uint32 ticks) {
-	return g_engine->setTotalPlayTime(ticks * 1000 / 60);
+	return setTotalPlayTime(ticks * 1000 / 60);
 }
 } // End of namespace Sci


Commit: e09010f7d8b7cc30ae3c8477d1a8b61b24d96306
    https://github.com/scummvm/scummvm/commit/e09010f7d8b7cc30ae3c8477d1a8b61b24d96306
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2022-08-02T17:23:34-04:00

Commit Message:
SCI: Restrict kGetEvent throttling to fast cast mode

In 2010 a 10 ms delay was added to every kGetEvent call to prevent
maxing out the CPU when some games display message boxes:
b0b4ddcc5232485100fd42dcd14d164a8d2eaeac

This rapid kGetEvent polling is called fast cast and it only exists in
SCI1.1 games and some SCI1 games. It occurs in an inner loop when the
fast cast global is set.

Now the workaround is only applied to fast cast games and only when the
kGetEvent polling occurs.

Removing this 10 ms delay from every SCI16 game cycle doesn't change
game speed by itself because the larger dynamic throttling in
kGameIsRestarting has been absorbing the 10 ms. But this does make the
other throttles easier to understand and work with, and solves minor
edge cases where delays from multiple kGetEvent calls add up.

Changed paths:
    engines/sci/engine/kevent.cpp
    engines/sci/engine/state.cpp
    engines/sci/engine/state.h
    engines/sci/graphics/animate.cpp


diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp
index 247a9733164..afe8082f0a0 100644
--- a/engines/sci/engine/kevent.cpp
+++ b/engines/sci/engine/kevent.cpp
@@ -31,6 +31,7 @@
 #include "sci/console.h"
 #include "sci/debug.h"	// for g_debug_simulated_key
 #include "sci/event.h"
+#include "sci/graphics/animate.h"
 #include "sci/graphics/coordadjuster.h"
 #include "sci/graphics/cursor.h"
 #include "sci/graphics/maciconbar.h"
@@ -264,14 +265,13 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
 		g_sci->_soundCmd->updateSci0Cues();
 	}
 
-	// Wait a bit here, so that the CPU isn't maxed out when the game
-	// is waiting for user input (e.g. when showing text boxes) - bug
-	// #5091. Make sure that we're not delaying while the game is
-	// benchmarking, as that will affect the final benchmarked result -
-	// check bugs #5326 and #5543
-	if (s->_gameIsBenchmarking) {
-		// Game is benchmarking, don't add a delay
-	} else if (getSciVersion() < SCI_VERSION_2) {
+	// Wait a bit if a "fast cast" game is polling kGetEvent while a message is
+	// being said or displayed. This prevents fast cast mode from maxing out
+	// CPU by polling from an inner loop when the fast cast global is set.
+	// Fixes bugs #5091, #5326
+	if (getSciVersion() <= SCI_VERSION_1_1 &&
+		g_sci->_gfxAnimate->isFastCastEnabled() &&
+		!s->variables[VAR_GLOBAL][kGlobalVarFastCast].isNull()) {
 		g_system->delayMillis(10);
 	}
 
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index e94337f2da7..ea0c1d54373 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -110,7 +110,6 @@ void EngineState::reset(bool isRestoring) {
 	_paletteSetIntensityCounter = 0;
 	_throttleLastTime = 0;
 	_throttleTrigger = false;
-	_gameIsBenchmarking = false;
 
 	_lastSaveVirtualId = SAVEGAMEID_OFFICIALRANGE_START;
 	_lastSaveNewId = 0;
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index 08b4446c3fb..733a1fbd0e0 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -122,7 +122,6 @@ public:
 	uint32 _paletteSetIntensityCounter; /**< total times kPaletteSetIntensity was invoked since the last call to kGameIsRestarting or kWait */
 	uint32 _throttleLastTime; /**< last time kAnimate was invoked */
 	bool _throttleTrigger;
-	bool _gameIsBenchmarking;
 
 	/* Kernel File IO stuff */
 
diff --git a/engines/sci/graphics/animate.cpp b/engines/sci/graphics/animate.cpp
index 0a13f126e59..63ce5761ef4 100644
--- a/engines/sci/graphics/animate.cpp
+++ b/engines/sci/graphics/animate.cpp
@@ -739,18 +739,15 @@ void GfxAnimate::throttleSpeed() {
 				// check further that there is only one cel in that view
 				GfxView *onlyView = _cache->getView(onlyCast->viewId);
 				if ((onlyView->getLoopCount() == 1) && (onlyView->getCelCount(0))) {
-					_s->_gameIsBenchmarking = true;
 					return;
 				}
 			}
 		}
-		_s->_gameIsBenchmarking = false;
 		_s->_throttleTrigger = true;
 		break;
 	}
 	default:
 		// More than 1 entry drawn -> time for speed throttling
-		_s->_gameIsBenchmarking = false;
 		_s->_throttleTrigger = true;
 		break;
 	}


Commit: e672a7b5f63740a34f1dab02526b27610311f2a2
    https://github.com/scummvm/scummvm/commit/e672a7b5f63740a34f1dab02526b27610311f2a2
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2022-08-02T17:23:34-04:00

Commit Message:
SCI: Show all palette cycles on PQ1, PQ3 tile screen

Fixes the police lights on the title screens of each game.
Only one of every eight frames in the palette cycle was appearing.

Thanks to @eriktorbjorn for reporting this

Changed paths:
    engines/sci/engine/kgraphics.cpp


diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index 8595d9248c0..cffec3b31e8 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -698,6 +698,19 @@ reg_t kPaletteAnimate(EngineState *s, int argc, reg_t *argv) {
 			g_sci->_gfxPalette16->kernelAnimateSet();
 	}
 
+	// WORKAROUNDS: kPaletteAnimate produces different results in ScummVM than
+	// the original when multiple calls occur in the same game cycle.
+	// SSCI updated the screen immediately so each call took a noticeable amount
+	// of time and the results of each call were visible.
+	// We generally update the screen on each game cycle; that makes all of the
+	// palette changes appear at once. No extra delay is produced since updating
+	// the palette data by itself takes an insignificant amount of time.
+	// Most scripts that call kPaletteAnimate only do so once per game cycle, so
+	// they are unaffected. Most that call it multiple times achieve practically
+	// the same effect in ScummVM. (Longbow title screen, EcoQuest ocean rooms,
+	// QFG1VGA room 10) But for scripts or effects that depend on the delay,
+	// or seeing each individual update, we currently work around them.
+
 	// WORKAROUND: The game scripts in SQ4 floppy count the number of elapsed
 	// cycles in the intro from the number of successive kAnimate calls during
 	// the palette cycling effect, while showing the SQ4 logo. This worked in
@@ -719,6 +732,25 @@ reg_t kPaletteAnimate(EngineState *s, int argc, reg_t *argv) {
 	if (g_sci->getGameId() == GID_SQ4 && !g_sci->isCD())
 		g_sci->sleep(10);
 
+	// WORKAROUND: PQ1 and PQ3 title screens call kPaletteAnimate eight times
+	// on each game cycle to animate police lights. The effect relies on every
+	// palette change being drawn to the screen instead of just the last one.
+	// We fix this by updating the screen on every call. Normally we would want
+	// to process events to keep the cursor smooth during these lengthy game
+	// cycles, but it doesn't matter here because the cursor is hidden.
+	// We call OSystem::updateScreen() directly to avoid the SCI throttler that
+	// discards multiple updates within 1/60th of a second, as that can lose
+	// some of the animation frames. This is only applied to the VGA version.
+	if ((g_sci->getGameId() == GID_PQ1 && s->currentRoomNumber() == 1) ||
+		(g_sci->getGameId() == GID_PQ3 && s->currentRoomNumber() == 2)) {
+		// PQ1 also cycles the Sierra logo in its room 1, so limit the
+		// workaround to just the police lights.
+		uint16 fromColor = argv[0].toUint16();
+		if (fromColor >= 208 && paletteChanged) {
+			g_system->updateScreen();
+		}
+	}
+
 	return s->r_acc;
 }
 




More information about the Scummvm-git-logs mailing list