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

sev- noreply at scummvm.org
Sun Mar 10 22:12:28 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:
1bf0dbad75 GRAPHICS: MACGUI: Eliminate timer use
d46e4e1aa0 SCUMM: Don't update the Mac GUI during graphical transitions


Commit: 1bf0dbad75db5e538026f58c16b3c33a3a613f9c
    https://github.com/scummvm/scummvm/commit/1bf0dbad75db5e538026f58c16b3c33a3a613f9c
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2024-03-10T23:12:25+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/macgui/macgui_impl.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/macgui/macgui_impl.cpp b/engines/scumm/macgui/macgui_impl.cpp
index bef2520f1f7..a22084d3142 100644
--- a/engines/scumm/macgui/macgui_impl.cpp
+++ b/engines/scumm/macgui/macgui_impl.cpp
@@ -156,7 +156,7 @@ void MacGuiImpl::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 3d333839b6b..bfdb959b7c5 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;
@@ -258,8 +255,6 @@ MacWindowManager::~MacWindowManager() {
 
 	cleanupDesktopBmp();
 	cleanupDataBundle();
-
-	g_system->getTimerManager()->removeTimerProc(&menuTimerHandler);
 }
 
 void MacWindowManager::setDesktopMode(uint32 mode) {
@@ -999,6 +994,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)
@@ -1019,18 +1022,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:
@@ -1049,10 +1040,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 22a128c77a0..902b3c485fb 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: d46e4e1aa02ec94b9801edf60b0e9b6441c714c3
    https://github.com/scummvm/scummvm/commit/d46e4e1aa02ec94b9801edf60b0e9b6441c714c3
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2024-03-10T23:12:25+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 d61d975d95a..aaca0b136dd 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2497,7 +2497,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));
 
@@ -2522,7 +2522,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 3821e6cbbc3..becd5071229 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