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

mduggan noreply at scummvm.org
Sun Jan 5 06:56:49 UTC 2025


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

Summary:
f990c8e67f DGDS: Various fixes for Willy Beamish CD version


Commit: f990c8e67fd8591071dff202aefd53d215b472a6
    https://github.com/scummvm/scummvm/commit/f990c8e67fd8591071dff202aefd53d215b472a6
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2025-01-05T17:56:36+11:00

Commit Message:
DGDS: Various fixes for Willy Beamish CD version

Voice acting is still really broken, but doesn't crash as much.

Changed paths:
    engines/dgds/drawing.cpp
    engines/dgds/game_palettes.cpp
    engines/dgds/head.cpp
    engines/dgds/head.h
    engines/dgds/ttm.cpp


diff --git a/engines/dgds/drawing.cpp b/engines/dgds/drawing.cpp
index 4db4328bbb4..17760764d7f 100644
--- a/engines/dgds/drawing.cpp
+++ b/engines/dgds/drawing.cpp
@@ -44,6 +44,11 @@ void emptyCircle(int x, int y, int xr, int yr, Graphics::ManagedSurface *dst, by
 }
 
 void rectClipped(const Common::Rect &r, const Common::Rect &clip, Graphics::ManagedSurface *dst, byte color) {
+	Common::Rect clippedR(r);
+	clippedR.clip(clip);
+	if (clippedR.isEmpty())
+		return;
+
 	if (r.top >= clip.top && r.top < clip.bottom)
 		dst->hLine(MAX(r.left, clip.left), r.top, MIN(r.right - 1, clip.right - 1), color);
 
diff --git a/engines/dgds/game_palettes.cpp b/engines/dgds/game_palettes.cpp
index 9a1c12a32a2..c6998c2a5eb 100644
--- a/engines/dgds/game_palettes.cpp
+++ b/engines/dgds/game_palettes.cpp
@@ -62,9 +62,9 @@ void GamePalettes::reset() {
 int GamePalettes::loadPalette(const Common::String &filename) {
 	Common::SeekableReadStream *fileStream = _resourceMan->getResource(filename);
 	if (!fileStream) {
-		// Happens in the Amiga version of Dragon
+		// Happens in the Amiga version of Dragon and CDS scripts
 		warning("Couldn't load palette resource %s", filename.c_str());
-		return 0;
+		return _curPalNum;
 	}
 
 	_palettes.resize(_palettes.size() + 1);
diff --git a/engines/dgds/head.cpp b/engines/dgds/head.cpp
index a3ed8df778c..fd09f809047 100644
--- a/engines/dgds/head.cpp
+++ b/engines/dgds/head.cpp
@@ -164,6 +164,10 @@ bool TalkData::hasVisibleHead() const {
 
 //////
 
+Conversation::~Conversation() {
+	unload();
+}
+
 void Conversation::unload() {
 	if (_sound) {
 		_sound->stop();
@@ -171,6 +175,8 @@ void Conversation::unload() {
 	}
 	_img.reset();
 	_ttmScript.reset();
+	if (_ttmEnv._soundRaw)
+		_ttmEnv._soundRaw->stop();
 	_ttmEnv = TTMEnviro();
 }
 
@@ -197,6 +203,8 @@ void Conversation::loadData(uint16 dlgFileNum, uint16 dlgNum, int16 sub) {
 	if (!resourceManager->hasResource(fname))
 		return;
 
+	debug(10, "CDS: Load CDS resource %s", fname.c_str());
+
 	_sound.reset(new SoundRaw(resourceManager, decompressor));
 	_sound->load(fname);
 	_img.reset(new Image(resourceManager, decompressor));
@@ -228,7 +236,7 @@ void Conversation::runScript() {
 	_ttmEnv._yOff = _drawRect.y;
 
 	for (auto seq : _ttmSeqs) {
-		if (seq->_seqNum == _ttmEnv._cdsSeqNum) {
+		if (seq->_seqNum == _ttmEnv._cdsSeqNum && seq->_currentFrame < (int)_ttmEnv._frameOffsets.size()) {
 			debug(10, "CDS: Running TTM sequence %d frame %d", seq->_seqNum, seq->_currentFrame);
 			_ttmEnv.scr->seek(_ttmEnv._frameOffsets[seq->_currentFrame]);
 
diff --git a/engines/dgds/head.h b/engines/dgds/head.h
index b2c7558f5a5..916db07923e 100644
--- a/engines/dgds/head.h
+++ b/engines/dgds/head.h
@@ -109,6 +109,7 @@ public:
 class Conversation {
 public:
 	Conversation() : _nextExec(0) {}
+	~Conversation();
 
 	void unload();
 	void runScript();
diff --git a/engines/dgds/ttm.cpp b/engines/dgds/ttm.cpp
index 16e560b1cf3..09209b77737 100644
--- a/engines/dgds/ttm.cpp
+++ b/engines/dgds/ttm.cpp
@@ -680,6 +680,8 @@ void TTMInterpreter::handleOperation(TTMEnviro &env, TTMSeq &seq, uint16 op, byt
 		seq._currentPalId = ivals[0];
 		if (seq._executed) // this is a mostly on-shot op.
 			break;
+		if (env._cdsSeqNum >= 0) // don't change global pal for CDS scripts.
+			break;
 		_vm->getGamePals()->selectPalNum(env._scriptPals[ivals[0]]);
 		break;
 	case 0x1070: // SELECT FONT  i:int
@@ -792,15 +794,19 @@ void TTMInterpreter::handleOperation(TTMEnviro &env, TTMSeq &seq, uint16 op, byt
 		_vm->_compositionBuffer.blitFrom(_vm->getBackgroundBuffer());
 		break;
 	}
-	case 0x3200:
+	case 0x3200: // CDS FIND GOTO TARGET frameno
 		env._cdsSeqNum = findGOTOTarget(env, seq, ivals[0]);
 		break;
-	case 0x3300:
+	case 0x3300: // CDS GOSUB
 		if (!env._cdsJumped && env._frameOffsets[env._cdsSeqNum] != seq._currentFrame) {
 			env._cdsJumped = true;
 			int64 prevPos = env.scr->pos();
+			env._xOff += ivals[0];
+			env._yOff += ivals[1];
 			env.scr->seek(env._frameOffsets[env._cdsSeqNum]);
 			run(env, seq);
+			env._xOff -= ivals[0];
+			env._yOff -= ivals[1];
 			env.scr->seek(prevPos);
 			env._cdsJumped = false;
 		}
@@ -1125,6 +1131,9 @@ void TTMInterpreter::handleOperation(TTMEnviro &env, TTMSeq &seq, uint16 op, byt
 	case 0xc210: {  // LOAD RAW SFX filename:str
 		if (seq._executed) // this is a one-shot op
 			break;
+		// Stop existing raw sound before we deallocate it.
+		if (env._soundRaw)
+			env._soundRaw->stop();
 		if (_vm->getResourceManager()->hasResource(sval)) {
 			SoundRaw *snd = new SoundRaw(_vm->getResourceManager(), _vm->getDecompressor());
 			snd->load(sval);




More information about the Scummvm-git-logs mailing list