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

mgerhardy noreply at scummvm.org
Sat Jul 4 13:42:02 UTC 2026


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

Summary:
b9b75e720f MACS2: pass by ref for renderString
ddb9646d8c MACS2: fixed center of mouse cursor sprite


Commit: b9b75e720fb27cfe219da5376fa62909f7ee7b08
    https://github.com/scummvm/scummvm/commit/b9b75e720fb27cfe219da5376fa62909f7ee7b08
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-07-04T15:41:49+02:00

Commit Message:
MACS2: pass by ref for renderString

Changed paths:
    engines/macs2/view1.cpp
    engines/macs2/view1.h


diff --git a/engines/macs2/view1.cpp b/engines/macs2/view1.cpp
index eb5a2cf9a51..dba5ac3a27b 100644
--- a/engines/macs2/view1.cpp
+++ b/engines/macs2/view1.cpp
@@ -476,7 +476,7 @@ void View1::drawCurrentSpeaker(Graphics::ManagedSurface &s) {
 	delete rightPortrait;
 }
 
-void View1::renderString(uint16 x, uint16 y, Common::String s) {
+void View1::renderString(uint16 x, uint16 y, const Common::String &s) {
 	Graphics::ManagedSurface surf = getSurface();
 	uint16 currentX = x;
 	uint16 currentY = y;
diff --git a/engines/macs2/view1.h b/engines/macs2/view1.h
index 697abc98571..f3b83dd3fc4 100644
--- a/engines/macs2/view1.h
+++ b/engines/macs2/view1.h
@@ -304,7 +304,7 @@ private:
 
 	void showStringBox(const Common::StringArray &sa);
 
-	void renderString(uint16 x, uint16 y, Common::String s);
+	void renderString(uint16 x, uint16 y, const Common::String &s);
 	void renderString(const Common::Point pos, const Common::String &s);
 	void renderStringWithFont(uint16 x, uint16 y, const Common::String &s, const GlyphData *glyphs, uint16 numGlyphs);
 	int measureStringWithFont(const Common::String &s, const GlyphData *glyphs, uint16 numGlyphs);


Commit: ddb9646d8c505331034ed627688e8e39f1cc8e0d
    https://github.com/scummvm/scummvm/commit/ddb9646d8c505331034ed627688e8e39f1cc8e0d
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-07-04T15:41:49+02:00

Commit Message:
MACS2: fixed center of mouse cursor sprite

handling scale and aspect ratio

Changed paths:
    engines/macs2/macs2.cpp
    engines/macs2/view1.cpp


diff --git a/engines/macs2/macs2.cpp b/engines/macs2/macs2.cpp
index 1904014ce66..56cf79321f5 100644
--- a/engines/macs2/macs2.cpp
+++ b/engines/macs2/macs2.cpp
@@ -1120,38 +1120,10 @@ int Macs2Engine::computeMinCostToReachable(int nodeIndex, int prevNode, uint16 a
 }
 
 void Macs2Engine::setCursorMode(Script::MouseMode newMode) {
-	// setCursorMode (1008:3ea5): when the cursor image changes, keep the hotspot
-	// fixed on screen by compensating for the old/new image half-extents, clamp,
-	// refresh the cursor graphic, and flag the clip rect dirty.
-	const Script::MouseMode oldMode = _scriptExecutor->_cursorMode;
+	// setCursorMode (1008:3ea5): binary adjusts top-left by old/new half-extents.
 	const bool cursorVisible = CursorMan.isVisible();
 
-	auto cursorHalfSize = [this](Script::MouseMode mode, uint16 &halfW, uint16 &halfH) {
-		halfW = halfH = 0;
-		const int index = (int)mode - 1;
-		if (index < 0 || index >= (int)_imageResources.size())
-			return;
-		halfW = _imageResources[index]._width / 2;
-		halfH = _imageResources[index]._height / 2;
-	};
-
-	uint16 oldHalfW = 0, oldHalfH = 0, newHalfW = 0, newHalfH = 0;
-	cursorHalfSize(oldMode, oldHalfW, oldHalfH);
-
-	Common::Point mouse = g_system->getEventManager()->getMousePos();
-	mouse.x += oldHalfW;
-	mouse.y += oldHalfH;
-
 	_scriptExecutor->_cursorMode = newMode;
-
-	cursorHalfSize(newMode, newHalfW, newHalfH);
-	mouse.x -= newHalfW;
-	mouse.y -= newHalfH;
-
-	mouse.x = CLIP<int>(mouse.x, (int)newHalfW, 319 - (int)newHalfW);
-	mouse.y = CLIP<int>(mouse.y, (int)newHalfH, 199 - (int)newHalfH);
-	g_system->warpMouse(mouse.x, mouse.y);
-
 	_clipRectDirty = true;
 
 	if (View1 *view = (View1 *)findView("View1"))
diff --git a/engines/macs2/view1.cpp b/engines/macs2/view1.cpp
index dba5ac3a27b..5abf0a7c2b3 100644
--- a/engines/macs2/view1.cpp
+++ b/engines/macs2/view1.cpp
@@ -28,6 +28,7 @@
 #include "engines/enhancements.h"
 #include "graphics/cursorman.h"
 #include "graphics/paletteman.h"
+#include "graphics/scaler/aspect.h"
 #include "macs2/debugtools.h"
 #include "macs2/detection.h"
 #include "macs2/gameobjects.h"
@@ -117,6 +118,28 @@ void buildFadedPalette(byte *colors, const byte *sourcePalette, int fadeValue) {
 	}
 }
 
+static Common::Point cursorReplaceHotspot(uint16 width, uint16 height) {
+	const uint scale = MAX(1u, g_system->getScaleFactor());
+	const int hotX = (int)width / (2 * (int)scale);
+	int hotY = (int)height / (2 * (int)scale);
+
+	if (g_system->getFeatureState(OSystem::kFeatureAspectRatioCorrection)) {
+		const int target = (int)height / 2;
+		int bestHotY = hotY;
+		int bestErr = ABS(real2Aspect(bestHotY * (int)scale) - target);
+		for (int candidate = 0; candidate <= (int)height; candidate++) {
+			const int err = ABS(real2Aspect(candidate * (int)scale) - target);
+			if (err < bestErr) {
+				bestErr = err;
+				bestHotY = candidate;
+			}
+		}
+		hotY = bestHotY;
+	}
+
+	return Common::Point(hotX, hotY);
+}
+
 } // namespace
 
 const View1::BorderStyle View1::kBorderRaised = {0x1010, 0x1012, 0x1011};
@@ -362,7 +385,10 @@ void View1::updateCursor(const byte *palette) {
 		rgbaCursor[i] = rgbaCursorFormat.RGBToColor(paletteEntry[0], paletteEntry[1], paletteEntry[2]);
 	}
 
-	CursorMan.replaceCursor(rgbaCursor.data(), width, height, width >> 1, height >> 1, 0, &rgbaCursorFormat);
+	// adjustViewportToMouse (1008:3de3): interaction center = mouse; draw at center - half.
+	// getMousePos() is the center; compensate hotspot for SurfaceSdl rHot scaling (see above).
+	const Common::Point hotspot = cursorReplaceHotspot(width, height);
+	CursorMan.replaceCursor(rgbaCursor.data(), width, height, hotspot.x, hotspot.y, 0, &rgbaCursorFormat);
 	// Enable a cursor palette so the backend won't re-blit the cursor on
 	// every screen palette change. The macs2 engine uses RGBA cursors with
 	// baked-in palette colors, so the cursor palette content is irrelevant -




More information about the Scummvm-git-logs mailing list