[Scummvm-git-logs] scummvm branch-2-8 -> 81c175b767115b79a7068a6e0e8911d2ed009ada

eriktorbjorn noreply at scummvm.org
Mon Mar 11 07:01:50 UTC 2024


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

Summary:
5154b1e7a8 GRAPHICS: MACGUI: Eliminate timer use
81c175b767 SCUMM: Don't update the Mac GUI during graphical transitions


Commit: 5154b1e7a86528dac43b0ae0f41e243ebd3719fa
    https://github.com/scummvm/scummvm/commit/5154b1e7a86528dac43b0ae0f41e243ebd3719fa
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2024-03-11T06:28:44+01:00

Commit Message:
GRAPHICS: MACGUI: Eliminate timer use

As part of fixing a graphical glitch in Mac Indiana Jones and the Last
Crusade, eliminate the menu timer from the Mac window manager. It's just
too unpredictable and error prone for my taste.

Changed paths:
    engines/pink/screen.cpp
    engines/scumm/gfx_mac.cpp
    graphics/macgui/macwindowmanager.cpp
    graphics/macgui/macwindowmanager.h


diff --git a/engines/pink/screen.cpp b/engines/pink/screen.cpp
index 583afccc1a3..b28c1fb7de3 100644
--- a/engines/pink/screen.cpp
+++ b/engines/pink/screen.cpp
@@ -102,7 +102,7 @@ Screen::Screen(PinkEngine *vm)
 
 	_wm->setScreen(&_surface);
 	_wm->setMenuHotzone(Common::Rect(0, 0, 640, 23));
-	_wm->setMenuDelay(250000);
+	_wm->setMenuDelay(250);
 	_wm->setEngineRedrawCallback(this, redrawCallback);
 
 	_textFont = nullptr;
diff --git a/engines/scumm/gfx_mac.cpp b/engines/scumm/gfx_mac.cpp
index 4897ea1b84c..de011e0994a 100644
--- a/engines/scumm/gfx_mac.cpp
+++ b/engines/scumm/gfx_mac.cpp
@@ -2584,7 +2584,7 @@ void MacGui::initialize() {
 
 	if (_vm->isUsingOriginalGUI()) {
 		_windowManager->setMenuHotzone(Common::Rect(640, 23));
-		_windowManager->setMenuDelay(250000);
+		_windowManager->setMenuDelay(250);
 
 		Common::MacResManager resource;
 		Graphics::MacMenu *menu = _windowManager->addMenu();
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 4f4c3a3efe5..07ee0600081 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -21,7 +21,6 @@
 #include "common/array.h"
 #include "common/list.h"
 #include "common/system.h"
-#include "common/timer.h"
 
 #include "graphics/cursorman.h"
 #include "graphics/managed_surface.h"
@@ -152,8 +151,6 @@ static const byte macCursorCrossBar[] = {
 	3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
 };
 
-static void menuTimerHandler(void *refCon);
-
 MacWindowManager::MacWindowManager(uint32 mode, MacPatterns *patterns, Common::Language language) {
 	_screen = nullptr;
 	_screenCopy = nullptr;
@@ -175,7 +172,7 @@ MacWindowManager::MacWindowManager(uint32 mode, MacPatterns *patterns, Common::L
 
 	_menu = 0;
 	_menuDelay = 0;
-	_menuTimerActive = false;
+	_menuTimer = 0;
 
 	_engineP = nullptr;
 	_engineR = nullptr;
@@ -257,8 +254,6 @@ MacWindowManager::~MacWindowManager() {
 
 	cleanupDesktopBmp();
 	cleanupDataBundle();
-
-	g_system->getTimerManager()->removeTimerProc(&menuTimerHandler);
 }
 
 void MacWindowManager::setDesktopMode(uint32 mode) {
@@ -998,6 +993,14 @@ void MacWindowManager::draw() {
 		}
 	}
 
+	if (_menuTimer && g_system->getMillis() >= _menuTimer) {
+		if (_menuHotzone.contains(_lastMousePos)) {
+			activateMenu();
+		}
+
+		_menuTimer = 0;
+	}
+
 	// Menu is drawn on top of everything and always
 	if (_menu && !(_mode & kWMModeFullscreen)) {
 		if (_fullRefresh)
@@ -1018,18 +1021,6 @@ void MacWindowManager::draw() {
 	_fullRefresh = false;
 }
 
-static void menuTimerHandler(void *refCon) {
-	MacWindowManager *wm = (MacWindowManager *)refCon;
-
-	if (wm->_menuHotzone.contains(wm->_lastMousePos)) {
-		wm->activateMenu();
-	}
-
-	wm->_menuTimerActive = false;
-
-	g_system->getTimerManager()->removeTimerProc(&menuTimerHandler);
-}
-
 bool MacWindowManager::processEvent(Common::Event &event) {
 	switch (event.type) {
 	case Common::EVENT_MOUSEMOVE:
@@ -1048,10 +1039,8 @@ bool MacWindowManager::processEvent(Common::Event &event) {
 
 	if (_menu && !_menu->isVisible()) {
 		if ((_mode & kWMModeAutohideMenu) && event.type == Common::EVENT_MOUSEMOVE) {
-			if (!_menuTimerActive && _menuHotzone.contains(event.mouse)) {
-				_menuTimerActive = true;
-
-				g_system->getTimerManager()->installTimerProc(&menuTimerHandler, _menuDelay, this, "menuWindowCursor");
+			if (!_menuTimer && _menuHotzone.contains(event.mouse)) {
+				_menuTimer = g_system->getMillis() + _menuDelay;
 			}
 		}
 	}
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 6dbc3f56f12..205bdac25ef 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -402,7 +402,7 @@ public:
 	Common::Point _lastMousePos;
 	Common::Rect _menuHotzone;
 
-	bool _menuTimerActive;
+	uint32 _menuTimer;
 	bool _mouseDown;
 
 	uint32 _colorBlack, _colorGray80, _colorGray88, _colorGrayEE, _colorWhite, _colorGreen, _colorGreen2;


Commit: 81c175b767115b79a7068a6e0e8911d2ed009ada
    https://github.com/scummvm/scummvm/commit/81c175b767115b79a7068a6e0e8911d2ed009ada
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2024-03-11T06:29:50+01:00

Commit Message:
SCUMM: Don't update the Mac GUI during graphical transitions

Perhaps this will finally fix the screen corruption bug I've been seeing
occasionally in Mac Indy 3? That seemed to happen because the screen was
changing while the game was paused, after the Window manager had made a
copy of the current screen.

Changed paths:
    engines/scumm/gfx.cpp
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h


diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index d469ab3d5fb..5dd7286a25c 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -4297,7 +4297,7 @@ void ScummEngine::transitionEffect(int a) {
 		// Draw the current state to the screen and wait
 		// for the appropriate number of quarter frames
 		if (!_fastMode) {
-			waitForTimer(delay);
+			waitForTimer(delay, true);
 		}
 	}
 }
@@ -4455,9 +4455,9 @@ void ScummEngine::dissolveEffect(int width, int height) {
 		if (canHalt) {
 			canHalt = false;
 			if (_game.platform == Common::kPlatformAmiga) {
-				waitForTimer(4);
+				waitForTimer(4, true);
 			} else {
-				waitForTimer(1);
+				waitForTimer(1, true);
 			}
 		}
 	}
@@ -4518,7 +4518,7 @@ void ScummEngine::scrollEffect(int dir) {
 					vs->w * m, step * m);
 			}
 
-			waitForTimer(delay);
+			waitForTimer(delay, true);
 			y += step;
 		}
 		break;
@@ -4540,7 +4540,7 @@ void ScummEngine::scrollEffect(int dir) {
 					vs->w * m, step * m);
 			}
 
-			waitForTimer(delay);
+			waitForTimer(delay, true);
 			y += step;
 		}
 		break;
@@ -4556,7 +4556,7 @@ void ScummEngine::scrollEffect(int dir) {
 				(vs->w - step) * m, 0,
 				step * m, vs->h * m);
 
-			waitForTimer(delay);
+			waitForTimer(delay, true);
 			x += step;
 		}
 		break;
@@ -4572,7 +4572,7 @@ void ScummEngine::scrollEffect(int dir) {
 				0, 0,
 				step, vs->h);
 
-			waitForTimer(delay);
+			waitForTimer(delay, true);
 			x += step;
 		}
 		break;
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 767e7b201cf..1ca32ac709d 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2487,7 +2487,7 @@ Common::Error ScummEngine::go() {
 	return Common::kNoError;
 }
 
-void ScummEngine::waitForTimer(int quarterFrames) {
+void ScummEngine::waitForTimer(int quarterFrames, bool freezeMacGui) {
 	uint32 endTime, cur;
 	uint32 msecDelay = getIntegralTime(quarterFrames * (1000 / _timerFrequency));
 
@@ -2512,7 +2512,7 @@ void ScummEngine::waitForTimer(int quarterFrames) {
 		towns_updateGfx();
 #endif
 
-		if (_macGui)
+		if (_macGui && !freezeMacGui)
 			_macGui->updateWindowManager();
 
 		_system->updateScreen();
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index d3a712637d6..6e890ca352e 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -632,7 +632,7 @@ public:
 protected:
 	virtual void parseEvent(Common::Event event);
 
-	void waitForTimer(int quarterFrames);
+	void waitForTimer(int quarterFrames, bool freezeMacGui = false);
 	uint32 _lastWaitTime;
 
 	void setTimerAndShakeFrequency();




More information about the Scummvm-git-logs mailing list