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

mduggan noreply at scummvm.org
Sat Nov 23 00:15:04 UTC 2024


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:
b673c07115 DGDS: Fix swapped buffers in TTM 0xB606 operation
4894210917 DGDS: Avoid potential use of deallocated memory
aa0b9b7d66 DGDS: Support more mouse cursors for Willy Beamish


Commit: b673c071159d08739352d173f437e40d3e16db76
    https://github.com/scummvm/scummvm/commit/b673c071159d08739352d173f437e40d3e16db76
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-11-23T11:12:02+11:00

Commit Message:
DGDS: Fix swapped buffers in TTM 0xB606 operation

The background and composition buffers were the wrong way around.  This fixes
various black backgrounds that were seen during the intro and start of Willy
Beamish.

Changed paths:
    engines/dgds/ads.cpp
    engines/dgds/ttm.cpp


diff --git a/engines/dgds/ads.cpp b/engines/dgds/ads.cpp
index 6c27d8e9e77..a10fadfeb5f 100644
--- a/engines/dgds/ads.cpp
+++ b/engines/dgds/ads.cpp
@@ -81,6 +81,7 @@ bool ADSInterpreter::load(const Common::String &filename) {
 	debug(1, "ADSInterpreter: load %s", detailfile.c_str());
 
 	// Reset the state
+	_vm->setFlipMode(false);
 	_adsTexts.setVal(detailfile, ADSData());
 	_adsData = &(_adsTexts.getVal(detailfile));
 
diff --git a/engines/dgds/ttm.cpp b/engines/dgds/ttm.cpp
index 7f6402eb254..6740bd33d17 100644
--- a/engines/dgds/ttm.cpp
+++ b/engines/dgds/ttm.cpp
@@ -210,7 +210,7 @@ static const char *ttmOpName(uint16 op) {
 	case 0xa520: return "DRAW SPRITE FLIPH";
 	case 0xa530: return "DRAW SPRITE FLIPHV";
 	case 0xa600: return "DRAW GETPUT";
-	case 0xa700: return "DRAW A700??";
+	case 0xa700: return "DRAW SCROLL";
 	case 0xaf00: return "DRAW FLOOD FILL";
 	case 0xaf10: return "DRAW EMPTY POLY";
 	case 0xaf20: return "DRAW FILLED POLY";
@@ -978,7 +978,7 @@ void TTMInterpreter::handleOperation(TTMEnviro &env, TTMSeq &seq, uint16 op, byt
 						Common::Point(r.left, r.top));
 		break;
 	}
-	case 0xa700: { // DRAW scrollshape? x,y,w,h??
+	case 0xa700: { // DRAW SCROLL x,y,w,h??
 		if (!env._scrollShape) {
 			warning("Trying to draw scroll with no scrollshape loaded");
 		} else {
@@ -1034,21 +1034,21 @@ void TTMInterpreter::handleOperation(TTMEnviro &env, TTMSeq &seq, uint16 op, byt
 		}
 		break;
 	}
-	case 0xb600: { // COPY BUFFER: x, y, w, h, buf1, buf2
-		// buf1 and buf2 are buffer numbers.
-		// 	0 - composition
+	case 0xb600: { // COPY BUFFER: x, y, w, h, srcbuf, dstbuf
+		// srcbuf and dstbuf are buffer numbers.
+		// 	0 - background
 		// 	1 - stored area
-		// 	2 - background
+		// 	2 - composition
 		if (seq._executed) // this is a one-shot op
 			break;
 		const Common::Rect r(Common::Point(ivals[0], ivals[1]), ivals[2], ivals[3]);
 		int16 b1 = ivals[4];
 		int16 b2 = ivals[5];
-		Graphics::ManagedSurface &s1 = ((b1 == 0) ? _vm->_compositionBuffer :
-				(b1 == 2 ? _vm->getBackgroundBuffer() : _vm->getStoredAreaBuffer()));
-		Graphics::ManagedSurface &s2 = ((b2 == 0) ? _vm->_compositionBuffer :
-				(b2 == 2 ? _vm->getBackgroundBuffer() : _vm->getStoredAreaBuffer()));
-		s2.blitFrom(s1, r, r);
+		Graphics::ManagedSurface &src = ((b1 == 2) ? _vm->_compositionBuffer :
+				(b1 == 0 ? _vm->getBackgroundBuffer() : _vm->getStoredAreaBuffer()));
+		Graphics::ManagedSurface &dst = ((b2 == 2) ? _vm->_compositionBuffer :
+				(b2 == 0 ? _vm->getBackgroundBuffer() : _vm->getStoredAreaBuffer()));
+		dst.blitFrom(src, r, r);
 		break;
 	}
 	case 0xc020: {	// LOAD SAMPLE: filename:str


Commit: 48942109179181dbd06eee3d0e222242ee3b9b16
    https://github.com/scummvm/scummvm/commit/48942109179181dbd06eee3d0e222242ee3b9b16
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-11-23T11:12:09+11:00

Commit Message:
DGDS: Avoid potential use of deallocated memory

Changed paths:
    engines/dgds/scene.cpp


diff --git a/engines/dgds/scene.cpp b/engines/dgds/scene.cpp
index 75e34a8ba92..45a4505e48b 100644
--- a/engines/dgds/scene.cpp
+++ b/engines/dgds/scene.cpp
@@ -1658,6 +1658,8 @@ bool SDSScene::checkDialogActive() {
 
 					// Take a copy of the dialog because the actions might change the scene
 					Dialog dlgCopy = dlg;
+					if (dlgCopy._state)
+						dlgCopy._state->_selectedAction = nullptr;
 					debug(1, "Dialog %d closing: run action (%d ops)", dlg._num, action->sceneOpList.size());
 					if (!runOps(action->sceneOpList)) {
 						// HACK: the scene changed, but we haven't yet drawn the foreground for the


Commit: aa0b9b7d66a6ed9b452bdd58e9f4b811fbda51ac
    https://github.com/scummvm/scummvm/commit/aa0b9b7d66a6ed9b452bdd58e9f4b811fbda51ac
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-11-23T11:12:21+11:00

Commit Message:
DGDS: Support more mouse cursors for Willy Beamish

Still a bit incomplete but should fix some of the issues.

Changed paths:
    engines/dgds/dgds.cpp
    engines/dgds/dgds.h
    engines/dgds/scene.cpp
    engines/dgds/scene.h


diff --git a/engines/dgds/dgds.cpp b/engines/dgds/dgds.cpp
index f6d4db2eb21..064bc36de8e 100644
--- a/engines/dgds/dgds.cpp
+++ b/engines/dgds/dgds.cpp
@@ -213,8 +213,10 @@ bool DgdsEngine::changeScene(int sceneNum) {
 
 	_gdsScene->runChangeSceneOps();
 
-	if (!_scene->getDragItem())
-		setMouseCursor(_gdsScene->getDefaultMouseCursor());
+	if (!_scene->getDragItem()) {
+		int16 cursorNum = (getGameId() == GID_WILLY) ? -2 : -1;
+		setMouseCursor(cursorNum);
+	}
 
 	_storedAreaBuffer.fillRect(Common::Rect(SCREEN_WIDTH, SCREEN_HEIGHT), 0);
 
@@ -249,8 +251,13 @@ bool DgdsEngine::changeScene(int sceneNum) {
 	return true;
 }
 
-void DgdsEngine::setMouseCursor(uint num) {
-	if (!_icons || (int)num >= _icons->loadedFrameCount())
+void DgdsEngine::setMouseCursor(int num) {
+	if (num == -1)
+		num = _gdsScene->getDefaultMouseCursor();
+	else if (num == -2)
+		num = _gdsScene->getDefaultMouseCursor2();
+
+	if (!_icons || num >= _icons->loadedFrameCount())
 		return;
 
 	if ((int)num == _currentCursor)
@@ -258,7 +265,7 @@ void DgdsEngine::setMouseCursor(uint num) {
 
 	const Common::Array<MouseCursor> &cursors = _gdsScene->getCursorList();
 
-	if (num >= cursors.size())
+	if (num >= (int)cursors.size())
 		error("Not enough cursor info, need %d have %d", num, cursors.size());
 
 	_currentCursorHot = cursors[num].getHot();
@@ -712,6 +719,7 @@ Common::Error DgdsEngine::run() {
 			if (getGameId() == GID_WILLY) {
 				_scene->drawVisibleHeads(&_compositionBuffer);
 				_scene->drawAndUpdateDialogs(&_compositionBuffer);
+				_scene->updateHotAreasFromDynamicRects();
 			} else {
 				_scene->drawAndUpdateDialogs(&_compositionBuffer);
 				_scene->drawVisibleHeads(&_compositionBuffer);
@@ -723,6 +731,7 @@ Common::Error DgdsEngine::run() {
 			_clock.update(gameRunning);
 
 			g_system->copyRectToScreen(_compositionBuffer.getPixels(), SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+
 			_justChangedScene1 = false;
 			_justChangedScene2 = false;
 		}
diff --git a/engines/dgds/dgds.h b/engines/dgds/dgds.h
index ca9849d8803..1813b7562cd 100644
--- a/engines/dgds/dgds.h
+++ b/engines/dgds/dgds.h
@@ -215,7 +215,7 @@ public:
 	Common::RandomSource &getRandom() { return _random; }
 
 	bool changeScene(int sceneNum);
-	void setMouseCursor(uint num);
+	void setMouseCursor(int num);
 
 	int getTextSpeed() const { return _textSpeed; }
 	void setTextSpeed(int16 speed) { _textSpeed = speed; }
diff --git a/engines/dgds/scene.cpp b/engines/dgds/scene.cpp
index 45a4505e48b..0671b64876b 100644
--- a/engines/dgds/scene.cpp
+++ b/engines/dgds/scene.cpp
@@ -102,7 +102,7 @@ Common::String SceneConditions::dump(const Common::String &indent) const {
 
 Common::String HotArea::dump(const Common::String &indent) const {
 	Common::String str = Common::String::format("%sHotArea<%s num %d cursor %d cursor2 %d interactionRectNum %d",
-			indent.c_str(), _rect.dump("").c_str(), _num, _cursorNum, _otherCursorNum, _objInteractionRectNum);
+			indent.c_str(), _rect.dump("").c_str(), _num, _cursorNum, _cursorNum2, _objInteractionRectNum);
 	str += _dumpStructList(indent, "enableConditions", enableConditions);
 	str += _dumpStructList(indent, "onRClickOps", onRClickOps);
 	str += _dumpStructList(indent, "onLDownOps", onLDownOps);
@@ -305,9 +305,9 @@ bool Scene::readHotArea(Common::SeekableReadStream *s, HotArea &dst) const {
 	dst._num = s->readUint16LE();
 	dst._cursorNum = s->readUint16LE();
 	if (isVersionOver(" 1.217"))
-		dst._otherCursorNum = s->readUint16LE();
+		dst._cursorNum2 = s->readUint16LE();
 	else
-		dst._otherCursorNum = 0;
+		dst._cursorNum2 = 0;
 
 	if (isVersionOver(" 1.218")) {
 		dst._objInteractionRectNum = s->readUint16LE();
@@ -1798,6 +1798,12 @@ void SDSScene::mouseMoved(const Common::Point &pt) {
 
 	int16 cursorNum = (!dlg && area) ? area->_cursorNum : 0;
 	if (_dragItem) {
+		if (area && area->_objInteractionRectNum == 1) {
+			// drag over Willy Beamish
+			engine->getInventory()->open();
+			return;
+		}
+
 		cursorNum = _dragItem->_iconNum;
 	} else if (_rbuttonDown) {
 		GameItem *activeItem = engine->getGDSScene()->getActiveItem();
@@ -1821,9 +1827,9 @@ void SDSScene::mouseLDown(const Common::Point &pt) {
 	if (!area)
 		return;
 
-	debug(9, "Mouse LDown on area %d (%d,%d,%d,%d) cursor %d. Run %d ops", area->_num,
+	debug(9, "Mouse LDown on area %d (%d,%d,%d,%d) cursor %d cursor2 %d. Run %d ops", area->_num,
 			area->_rect.x, area->_rect.y, area->_rect.width, area->_rect.height,
-			area->_cursorNum, area->onLDownOps.size());
+			area->_cursorNum, area->_cursorNum2, area->onLDownOps.size());
 
 	DgdsEngine *engine = DgdsEngine::getInstance();
 	int16 addmins = engine->getGameGlobals()->getGameMinsToAddOnStartDrag();
@@ -1867,8 +1873,8 @@ void SDSScene::mouseLUp(const Common::Point &pt) {
 	if (!area)
 		return;
 
-	debug(9, "Mouse LUp on area %d (%d,%d,%d,%d) cursor %d", area->_num, area->_rect.x, area->_rect.y,
-			area->_rect.width, area->_rect.height, area->_cursorNum);
+	debug(9, "Mouse LUp on area %d (%d,%d,%d,%d) cursor %d cursor2 %d", area->_num, area->_rect.x, area->_rect.y,
+		  area->_rect.width, area->_rect.height, area->_cursorNum, area->_cursorNum2);
 
 	DgdsEngine *engine = DgdsEngine::getInstance();
 	if (!_rbuttonDown)
@@ -2127,7 +2133,7 @@ void SDSScene::addInvButtonToHotAreaList() {
 	area._rect.height = icons->height(invButtonIcon);
 	area._rect.x = SCREEN_WIDTH - area._rect.width;
 	area._rect.y = SCREEN_HEIGHT - area._rect.height;
-	area._otherCursorNum = 0;
+	area._cursorNum2 = 0;
 	area._objInteractionRectNum = 0;
 
 	// Add swap character button for HoC
@@ -2141,7 +2147,7 @@ void SDSScene::addInvButtonToHotAreaList() {
 		area2._rect.height = icons->height(iconNum);
 		area2._rect.x = 5;
 		area2._rect.y = SCREEN_HEIGHT - area2._rect.height - 5;
-		area2._otherCursorNum = 0;
+		area2._cursorNum2 = 0;
 		area2._objInteractionRectNum = 0;
 
 		_hotAreaList.push_front(area2);
@@ -2214,7 +2220,7 @@ void SDSScene::activateChoice() {
 }
 
 
-GDSScene::GDSScene() : _defaultMouseCursor(0), _field3a(0), _invIconNum(0), _invIconMouseCursor(0), _field40(0) {
+GDSScene::GDSScene() : _defaultMouseCursor(0), _defaultMouseCursor2(0), _invIconNum(0), _invIconMouseCursor(0), _defaultOtherMouseCursor(0) {
 }
 
 bool GDSScene::load(const Common::String &filename, ResourceManager *resourceManager, Decompressor *decompressor) {
@@ -2388,17 +2394,17 @@ bool GDSScene::parse(Common::SeekableReadStream *stream) {
 		readObjInteractionList(stream, _objInteractions2);
 
 	if (isVersionOver(" 1.218")) {
-		_defaultMouseCursor = stream->readUint16LE();
-		_field3a = stream->readUint16LE();
+		_defaultMouseCursor = stream->readSint16LE();
+		_defaultMouseCursor2 = stream->readUint16LE();
 		_invIconNum = stream->readUint16LE();
-		_invIconMouseCursor = stream->readUint16LE();
-		_field40 = stream->readUint16LE();
+		_invIconMouseCursor = stream->readSint16LE();
+		_defaultOtherMouseCursor = stream->readSint16LE();
 	} else {
 		_defaultMouseCursor = 0;
-		_field3a = 1;
+		_defaultMouseCursor2 = 1;
 		_invIconNum = 2;
 		_invIconMouseCursor = 0;
-		_field40 = 6;
+		_defaultOtherMouseCursor = 6;
 	}
 
 	return !stream->err();
diff --git a/engines/dgds/scene.h b/engines/dgds/scene.h
index 0c915798e95..12ff2aeac24 100644
--- a/engines/dgds/scene.h
+++ b/engines/dgds/scene.h
@@ -71,7 +71,7 @@ public:
 	uint16 _cursorNum;
 
 	// Used in Willy Beamish
-	uint16 _otherCursorNum;
+	uint16 _cursorNum2;
 	uint16 _objInteractionRectNum;
 
 	Common::Array<SceneConditions> enableConditions;
@@ -402,9 +402,11 @@ public:
 	void initIconSizes();
 	GameItem *getActiveItem();
 
-	uint16 getDefaultMouseCursor() const { return _defaultMouseCursor; }
+	int16 getDefaultMouseCursor() const { return _defaultMouseCursor; }
+	int16 getDefaultMouseCursor2() const { return _defaultMouseCursor2; }
+	int16 getOtherDefaultMouseCursor() const { return _defaultOtherMouseCursor; }
 	uint16 getInvIconNum() const { return _invIconNum; }
-	uint16 getInvIconMouseCursor() const { return _invIconMouseCursor; }
+	int16 getInvIconMouseCursor() const { return _invIconMouseCursor; }
 
 private:
 	Common::String _iconFile;
@@ -418,11 +420,11 @@ private:
 	Common::Array<ObjectInteraction> _objInteractions1;
 
 	// Additional fields that appear in Willy Beamish (unused in others)
-	uint16 _defaultMouseCursor;
-	uint16 _field3a;
+	int16 _defaultMouseCursor;
+	int16 _defaultMouseCursor2;
 	uint16 _invIconNum;
-	uint16 _invIconMouseCursor;
-	uint16 _field40;
+	int16 _invIconMouseCursor;
+	int16 _defaultOtherMouseCursor;
 };
 
 class SDSScene : public Scene {




More information about the Scummvm-git-logs mailing list