[Scummvm-git-logs] scummvm master -> 83a3a8abb9446644f9128d90b54e48a3d413f18d

neuromancer noreply at scummvm.org
Wed Feb 25 19:00:29 UTC 2026


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

Summary:
83a3a8abb9 FREESCAPE: Fix DOS Castle Master lightning effect


Commit: 83a3a8abb9446644f9128d90b54e48a3d413f18d
    https://github.com/scummvm/scummvm/commit/83a3a8abb9446644f9128d90b54e48a3d413f18d
Author: Andrei Radulescu (andrei.radulescu2703 at gmail.com)
Date: 2026-02-25T20:00:24+01:00

Commit Message:
FREESCAPE: Fix DOS Castle Master lightning effect

Fix lightning effect for the DOS version of Castle Master not showing up because of incorrect loading of the texture. Fix lightning showing in the same region and not in view of camera.
Add sound and flash effect.

Signed-off-by: Andrei Radulescu <andrei.radulescu2703 at gmail.com>

Changed paths:
    engines/freescape/games/castle/castle.cpp
    engines/freescape/games/castle/castle.h
    engines/freescape/games/castle/dos.cpp


diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index 501f2c07434..bbd1baf0518 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -106,6 +106,7 @@ CastleEngine::CastleEngine(OSystem *syst, const ADGameDescription *gd) : Freesca
 	_spiritsMeterMax = 64;
 	_thunderTicks = 0;
 	_thunderFrameDuration = 0;
+	_thunderFrameIndex = 0;
 }
 
 CastleEngine::~CastleEngine() {
@@ -1848,10 +1849,14 @@ void CastleEngine::updateThunder() {
 		//debug("Thunder frame duration: %d", _thunderFrameDuration);
 		//debug("Size: %f", 2 * _thunderOffset.length());
 		//debug("Offset: %.1f, %.1f, %.1f", _thunderOffset.x(), _thunderOffset.y(), _thunderOffset.z());
-		_gfx->drawThunder(_thunderTextures[0], _position + _thunderOffset, 100);
+		_gfx->drawThunder(_thunderTextures[_thunderFrameIndex], _position + _thunderOffset, 100);
 		_thunderFrameDuration--;
+
+		if (_thunderFrameDuration == 5)
+			_gfx->clear(255, 255, 255);
+
 		if (_thunderFrameDuration == 0)
-			if (isSpectrum() || isCPC())
+			if (isSpectrum() || isCPC() || isDOS())
 				playSound(8, false, _soundFxHandle);
 		return;
 	}
@@ -1860,15 +1865,31 @@ void CastleEngine::updateThunder() {
 		//debug("Thunder ticks: %d", _thunderTicks);
 		_thunderTicks--;
 		if (_thunderTicks <= 0) {
+			if (isDOS())
+				_thunderFrameIndex = int(_rnd->getRandomNumber(_thunderTextures.size() - 1));
 			_thunderFrameDuration = 10;
+			_thunderOffset = Math::Vector3d();
+
+			// Project to floor plane
+			Math::Vector3d forward = _cameraFront; 
+			forward.y() = 0;
+			forward.normalize();
+
+			Math::Angle yaw = Math::Angle(30.0f - (float)_rnd->getRandomNumber(60));
+			Math::Angle pitch = Math::Angle(5.0f + (float)_rnd->getRandomNumber(20));
+
+			// Rotate on floor plane
+			float x = forward.x();
+			forward.x() = forward.x() * yaw.getCosine() - forward.z() * yaw.getSine();
+			forward.z() = x * yaw.getSine() + forward.z() * yaw.getCosine();
+
+			// Rotate upwards
+			Math::Vector3d tiltedForward = (forward * pitch.getCosine()) + (_upVector * pitch.getSine());
+			_thunderOffset = tiltedForward * (400.0f + (float)_rnd->getRandomNumber(200));
 		}
 	} else {
 		// Schedule next thunder, between 10 and 10 + 10 seconds
 		_thunderTicks = 50 * (10 + _rnd->getRandomNumber(10));
-		_thunderOffset = Math::Vector3d();
-		_thunderOffset.x() += (int(_rnd->getRandomNumber(100)) + 300);
-		_thunderOffset.y() += int(_rnd->getRandomNumber(100)) + 50.0f;
-		_thunderOffset.z() += (int(_rnd->getRandomNumber(100)) + 300);
 	}
 }
 
diff --git a/engines/freescape/games/castle/castle.h b/engines/freescape/games/castle/castle.h
index 2f54595a9f3..97261220129 100644
--- a/engines/freescape/games/castle/castle.h
+++ b/engines/freescape/games/castle/castle.h
@@ -166,6 +166,7 @@ private:
 	int _droppingGateStartTicks;
 	int _thunderTicks;
 	int _thunderFrameDuration;
+	int _thunderFrameIndex;
 	Math::Vector3d _thunderOffset;
 	Common::Array<Texture *>_thunderTextures;
 };
diff --git a/engines/freescape/games/castle/dos.cpp b/engines/freescape/games/castle/dos.cpp
index 69f441e8e1d..c7cb608783d 100644
--- a/engines/freescape/games/castle/dos.cpp
+++ b/engines/freescape/games/castle/dos.cpp
@@ -368,7 +368,14 @@ void CastleEngine::loadAssetsDOSDemo() {
 			_riddleBottomFrame = loadFrameWithHeaderDOS(stream);
 			_endGameThroneFrame = loadFrameWithHeaderDOS(stream);
 			// No header
-			Graphics::ManagedSurface *thunderFrame = loadFrameFromPlanes(stream, 32, 128);
+			Graphics::ManagedSurface *thunderFrame;
+
+			thunderFrame = loadFrameFromPlanes(stream, 16, 112);
+			thunderFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+			_thunderFrames.push_back(thunderFrame);
+
+			stream->seek(-0x160,SEEK_CUR);
+			thunderFrame = loadFrameFromPlanes(stream, 16, 112);
 			thunderFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
 			_thunderFrames.push_back(thunderFrame);
 




More information about the Scummvm-git-logs mailing list