[Scummvm-git-logs] scummvm master -> 5e426860f6d20e1ce2eac3df30b80799ee763bd9

neuromancer noreply at scummvm.org
Sun Oct 6 14:42:05 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:
bc1e1b80eb FREESCAPE: better responsiveness when scripts introduce a delay and some font fixes
6f053f7297 FREESCAPE: improved castle zx sounds
5e426860f6 FREESCAPE: improved handling on yaw conversion when traversing an entrance


Commit: bc1e1b80eb924bafaa712cd1038783f6551a3361
    https://github.com/scummvm/scummvm/commit/bc1e1b80eb924bafaa712cd1038783f6551a3361
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-10-06T16:43:29+02:00

Commit Message:
FREESCAPE: better responsiveness when scripts introduce a delay and some font fixes

Changed paths:
    engines/freescape/font.cpp
    engines/freescape/freescape.h
    engines/freescape/games/castle/castle.cpp
    engines/freescape/language/instruction.cpp
    engines/freescape/sound.cpp
    engines/freescape/ui.cpp


diff --git a/engines/freescape/font.cpp b/engines/freescape/font.cpp
index d60a46abece..dc937446aab 100644
--- a/engines/freescape/font.cpp
+++ b/engines/freescape/font.cpp
@@ -92,9 +92,9 @@ void Font::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 col
 		surface.convertToInPlace(dst->format, (byte *)palette, 3);
 
 	if (_backgroundColor == dst->format.ARGBToColor(0x00, 0x00, 0x00, 0x00))
-		dst->copyRectToSurfaceWithKey(surface, x, y, Common::Rect(0, 0, _charWidth, surface.h), dst->format.ARGBToColor(0xFF, 0x00, 0x00, 0x00));
+		dst->copyRectToSurfaceWithKey(surface, x, y, Common::Rect(0, 0, MIN(int(surface.w), _charWidth), surface.h), dst->format.ARGBToColor(0xFF, 0x00, 0x00, 0x00));
 	else
-		dst->copyRectToSurface(surface, x, y, Common::Rect(0, 0, _charWidth, surface.h));
+		dst->copyRectToSurface(surface, x, y, Common::Rect(0, 0, MIN(int(surface.w), _charWidth), surface.h));
 
 	surface.free();
 }
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index fdc3cb652a3..6fe681bf4c4 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -185,6 +185,7 @@ public:
 	void drawFullscreenSurface(Graphics::Surface *surface);
 	virtual void loadBorder();
 	virtual void processBorder();
+	void waitInLoop(int maxWait);
 	void drawBorder();
 	void drawTitle();
 	virtual void drawBackground();
diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index 92ab375d4d5..d84ddfbc8b8 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -313,7 +313,7 @@ void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
 		_pitch = 0;
 		playSound(_soundIndexStart, false);
 	} else {
-		playSound(_soundIndexAreaChange, false);
+		playSound(_soundIndexAreaChange, true);
 	}
 
 	debugC(1, kFreescapeDebugMove, "starting player position: %f, %f, %f", _position.x(), _position.y(), _position.z());
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 6cb4788bd73..dd533f987e7 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -291,16 +291,7 @@ bool FreescapeEngine::executeCode(FCLInstructionVector &code, bool shot, bool co
 
 void FreescapeEngine::executeRedraw(FCLInstruction &instruction) {
 	debugC(1, kFreescapeDebugCode, "Redrawing screen");
-	drawFrame();
-	_gfx->flipBuffer();
-	g_system->updateScreen();
-	g_system->delayMillis(10);
-
-	drawFrame();
-	_gfx->flipBuffer();
-	g_system->updateScreen();
-	g_system->delayMillis(isCPC() ? 100 : 10);
-
+	waitInLoop((100 / 15) + 1);
 	if (_syncSound) {
 		waitForSounds();
 	}
@@ -335,7 +326,7 @@ void FreescapeEngine::executeSound(FCLInstruction &instruction) {
 void FreescapeEngine::executeDelay(FCLInstruction &instruction) {
 	uint16 delay = instruction._source;
 	debugC(1, kFreescapeDebugCode, "Delaying %d * 1/50 seconds", delay);
-	g_system->delayMillis(20 * delay);
+	waitInLoop(((20 * delay) / 15) + 1);
 }
 
 void FreescapeEngine::executePrint(FCLInstruction &instruction) {
diff --git a/engines/freescape/sound.cpp b/engines/freescape/sound.cpp
index 09872fb517a..9bd83bf7418 100644
--- a/engines/freescape/sound.cpp
+++ b/engines/freescape/sound.cpp
@@ -303,14 +303,16 @@ void FreescapeEngine::playSound(int index, bool sync) {
 		return;
 	}
 
+	if (_syncSound)
+		waitForSounds();
+
+	_syncSound = sync;
+
 	debugC(1, kFreescapeDebugMedia, "Playing sound %d with sync: %d", index, sync);
 	if (isAmiga() || isAtariST()) {
 		playSoundFx(index, sync);
-		_syncSound = sync;
 		return;
 	}
-	if (_syncSound)
-		waitForSounds();
 
 	if (isDOS()) {
 		soundSpeakerFx *speakerFxInfo = _soundsSpeakerFx[index];
diff --git a/engines/freescape/ui.cpp b/engines/freescape/ui.cpp
index 32009c5a4fa..7c93ab131da 100644
--- a/engines/freescape/ui.cpp
+++ b/engines/freescape/ui.cpp
@@ -23,6 +23,60 @@
 
 namespace Freescape {
 
+void FreescapeEngine::waitInLoop(int maxWait) {
+	for (int i = 0; i < maxWait; i++ ) {
+		Common::Event event;
+		while (_eventManager->pollEvent(event)) {
+			Common::Point mousePos;
+			switch (event.type) {
+			case Common::EVENT_QUIT:
+			case Common::EVENT_RETURN_TO_LAUNCHER:
+				quitGame();
+				return;
+
+			case Common::EVENT_MOUSEMOVE:
+				if (_hasFallen)
+					break;
+				mousePos = event.mouse;
+
+				if (_demoMode)
+					break;
+
+				if (_shootMode) {;
+					break;
+				} else {
+					// Mouse pointer is locked into the the middle of the screen
+					// since we only need the relative movements. This will not affect any touchscreen device
+					// so on-screen controls are still accesible
+					mousePos.x = g_system->getWidth() * ( _viewArea.left + _viewArea.width() / 2) / _screenW;
+					mousePos.y = g_system->getHeight() * (_viewArea.top + _viewArea.height() / 2) / _screenW;
+					if (_invertY)
+						event.relMouse.y = -event.relMouse.y;
+
+					g_system->warpMouse(mousePos.x, mousePos.y);
+					_eventManager->purgeMouseEvents();
+				}
+
+				rotate(event.relMouse.x * _mouseSensitivity, event.relMouse.y * _mouseSensitivity);
+				break;
+
+			case Common::EVENT_SCREEN_CHANGED:
+				_gfx->computeScreenViewport();
+				_gfx->clear(0, 0, 0, true);
+				break;
+			default:
+				break;
+			}
+		}
+		_gfx->clear(0, 0, 0, true);
+		drawFrame();
+		_gfx->flipBuffer();
+		g_system->updateScreen();
+		g_system->delayMillis(15); // try to target ~60 FPS
+	}
+	_gfx->clear(0, 0, 0, true);
+}
+
 void FreescapeEngine::titleScreen() {
 	if (!_title)
 		return;


Commit: 6f053f7297d915f41811502aafae08ee1733eb72
    https://github.com/scummvm/scummvm/commit/6f053f7297d915f41811502aafae08ee1733eb72
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-10-06T16:43:29+02:00

Commit Message:
FREESCAPE: improved castle zx sounds

Changed paths:
    engines/freescape/games/castle/castle.cpp
    engines/freescape/games/castle/zx.cpp


diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index d84ddfbc8b8..77d2b41db37 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -36,10 +36,12 @@
 namespace Freescape {
 
 CastleEngine::CastleEngine(OSystem *syst, const ADGameDescription *gd) : FreescapeEngine(syst, gd) {
-
 	if (!Common::parseBool(ConfMan.get("rock_travel"), _useRockTravel))
 		error("Failed to parse bool from rock_travel option");
 
+	_soundIndexStart = 9;
+	_soundIndexAreaChange = 5;
+
 	if (isSpectrum())
 		initZX();
 
@@ -86,10 +88,6 @@ CastleEngine::CastleEngine(OSystem *syst, const ADGameDescription *gd) : Freesca
 	_spiritsDestroyed = 0;
 	_spiritsMeter = 32;
 	_spiritsToKill = 26;
-
-	_soundIndexStart = 9;
-	_soundIndexAreaChange = 5;
-
 }
 
 CastleEngine::~CastleEngine() {
@@ -311,9 +309,16 @@ void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
 	if (areaID == _startArea && entranceID == _startEntrance) {
 		_yaw = 310;
 		_pitch = 0;
-		playSound(_soundIndexStart, false);
+		if (getGameBit(31))
+			playSound(13, true);
+		else
+			playSound(_soundIndexStart, false);
 	} else {
-		playSound(_soundIndexAreaChange, true);
+		// If escaped, play a different sound
+		if (getGameBit(31))
+			playSound(13, true);
+		else
+			playSound(_soundIndexAreaChange, true);
 	}
 
 	debugC(1, kFreescapeDebugMove, "starting player position: %f, %f, %f", _position.x(), _position.y(), _position.z());
diff --git a/engines/freescape/games/castle/zx.cpp b/engines/freescape/games/castle/zx.cpp
index 8dd48a0c0c5..f4079e25c96 100644
--- a/engines/freescape/games/castle/zx.cpp
+++ b/engines/freescape/games/castle/zx.cpp
@@ -38,7 +38,7 @@ void CastleEngine::initZX() {
 	_soundIndexClimb = -1;
 	_soundIndexMenu = -1;
 	_soundIndexStart = 6;
-	_soundIndexAreaChange = 5;
+	_soundIndexAreaChange = 7;
 }
 
 Graphics::ManagedSurface *CastleEngine::loadFrameWithHeader(Common::SeekableReadStream *file, int pos, uint32 front, uint32 back) {


Commit: 5e426860f6d20e1ce2eac3df30b80799ee763bd9
    https://github.com/scummvm/scummvm/commit/5e426860f6d20e1ce2eac3df30b80799ee763bd9
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-10-06T16:43:29+02:00

Commit Message:
FREESCAPE: improved handling on yaw conversion when traversing an entrance

Changed paths:
    engines/freescape/games/castle/castle.cpp
    engines/freescape/games/dark/dark.cpp
    engines/freescape/games/driller/driller.cpp
    engines/freescape/games/eclipse/eclipse.cpp
    engines/freescape/movement.cpp


diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index 77d2b41db37..b1c00d63db5 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -307,8 +307,6 @@ void CastleEngine::gotoArea(uint16 areaID, int entranceID) {
 	_gameStateVars[0x1f] = 0;
 
 	if (areaID == _startArea && entranceID == _startEntrance) {
-		_yaw = 310;
-		_pitch = 0;
 		if (getGameBit(31))
 			playSound(13, true);
 		else
diff --git a/engines/freescape/games/dark/dark.cpp b/engines/freescape/games/dark/dark.cpp
index 99dd4c8ff42..1685070ef9c 100644
--- a/engines/freescape/games/dark/dark.cpp
+++ b/engines/freescape/games/dark/dark.cpp
@@ -613,8 +613,6 @@ void DarkEngine::gotoArea(uint16 areaID, int entranceID) {
 	_gameStateVars[0x1f] = 0;
 
 	if (areaID == _startArea && entranceID == _startEntrance) {
-		_yaw = 90;
-		_pitch = 0;
 		playSound(_soundIndexStart, true);
 	} else if (areaID == _endArea && entranceID == _endEntrance) {
 		_pitch = 10;
diff --git a/engines/freescape/games/driller/driller.cpp b/engines/freescape/games/driller/driller.cpp
index 0ba23e9106d..9928eac2e37 100644
--- a/engines/freescape/games/driller/driller.cpp
+++ b/engines/freescape/games/driller/driller.cpp
@@ -242,12 +242,9 @@ void DrillerEngine::gotoArea(uint16 areaID, int entranceID) {
 	_gameStateVars[0x1f] = 0;
 
 	if (areaID == _startArea && entranceID == _startEntrance) {
-		_yaw = 280;
-		_pitch = 0;
 		playSound(_soundIndexStart, true);
 	} else if (areaID == 127) {
 		assert(entranceID == 0);
-		_yaw = 90;
 		_pitch = 335;
 		_flyMode = true; // Avoid falling
 		// Show the number of completed areas
diff --git a/engines/freescape/games/eclipse/eclipse.cpp b/engines/freescape/games/eclipse/eclipse.cpp
index 75118d57cc8..cfb5b80cb98 100644
--- a/engines/freescape/games/eclipse/eclipse.cpp
+++ b/engines/freescape/games/eclipse/eclipse.cpp
@@ -220,7 +220,7 @@ void EclipseEngine::initKeymaps(Common::Keymap *engineKeyMap, Common::Keymap *in
 	act->addDefaultInputMapping("w");
 	engineKeyMap->addAction(act);
 
-	// I18N: Illustrates the angle at which you turn left or right. 
+	// I18N: Illustrates the angle at which you turn left or right.
 	act = new Common::Action("CHNGANGLE", _("Change Angle"));
 	act->setCustomEngineActionEvent(kActionChangeAngle);
 	act->addDefaultInputMapping("a");
@@ -268,12 +268,8 @@ void EclipseEngine::gotoArea(uint16 areaID, int entranceID) {
 	_lastPosition = _position;
 
 	if (areaID == _startArea && entranceID == _startEntrance) {
-		_yaw = 180;
-		_pitch = 0;
-
 		playSound(_soundIndexStart, true);
 		if (isEclipse2()) {
-			_yaw = 120;
 			_gameStateControl = kFreescapeGameStateStart;
 		}
 
diff --git a/engines/freescape/movement.cpp b/engines/freescape/movement.cpp
index c9046bb8114..16d724314ac 100644
--- a/engines/freescape/movement.cpp
+++ b/engines/freescape/movement.cpp
@@ -139,15 +139,21 @@ void FreescapeEngine::traverseEntrance(uint16 entranceID) {
 	}
 
 	_pitch = rotation.x();
-	if (rotation.y() > 0 && rotation.y() <= 45)
-		_yaw = rotation.y();
-	else if (rotation.y() <= 0 || (rotation.y() >= 180 && rotation.y() < 270))
-		_yaw = rotation.y() + 90;
+	float y = rotation.y();
+
+	// Adjust _yaw based on normalized angle
+	if (y >= 0 && y < 90)
+		_yaw = 90 - y;			// 0 to 90 maps to 90 to 0 (yaw should be 90 to 0)
+	else if (y >= 90 && y <= 180)
+		_yaw = 450 - y;			// 90 to 180 maps to 360 to 270 (yaw should be 360 to 270)
+	else if (y > 180 && y <= 225)
+		_yaw = y;				// 180 to 225 maps to 180 to 225 (yaw should be 180 to 225)
+	else if (y > 225 && y < 270)
+		_yaw = y - 90;			// 180 to 270 maps to 90 to 0 (yaw should be 90 to 0)
 	else
-		_yaw = rotation.y() - 90;
+		_yaw = 360 + 90 - y;	// 270 to 360 maps to 90 to 180 (yaw should be 90 to 180)
 
 	debugC(1, kFreescapeDebugMove, "entrace position: %f %f %f", _position.x(), _position.y(), _position.z());
-
 	// Set the player height
 	_playerHeight = 0;
 	changePlayerHeight(_playerHeightNumber);




More information about the Scummvm-git-logs mailing list