[Scummvm-git-logs] scummvm master -> 4d1b38fc8d3972988397881027f8991051ca63dc

digitall noreply at scummvm.org
Wed Aug 2 01:49:31 UTC 2023


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:
4d1b38fc8d MOHAWK: MYST: Skip fade steps on slower machines


Commit: 4d1b38fc8d3972988397881027f8991051ca63dc
    https://github.com/scummvm/scummvm/commit/4d1b38fc8d3972988397881027f8991051ca63dc
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-08-02T02:49:26+01:00

Commit Message:
MOHAWK: MYST: Skip fade steps on slower machines

Changed paths:
    engines/mohawk/myst_graphics.cpp


diff --git a/engines/mohawk/myst_graphics.cpp b/engines/mohawk/myst_graphics.cpp
index 4f7ee71c5b6..47e2195605b 100644
--- a/engines/mohawk/myst_graphics.cpp
+++ b/engines/mohawk/myst_graphics.cpp
@@ -706,18 +706,29 @@ void MystGraphics::fadeToBlack() {
 	// This is only for the demo
 	assert(!_vm->isGameVariant(GF_ME));
 
-	// Linear fade in 64 steps
-	for (int i = 63; i >= 0; i--) {
+	// Linear fade in 64 steps or less
+	uint32 startTime = _vm->_system->getMillis();
+	uint32 endTime = startTime + 640;
+	uint32 time, i;
+
+	do {
 		byte palette[256 * 3];
 		byte *src = _palette;
 		byte *dst = palette;
 
-		for (uint j = 0; j < sizeof(palette); j++)
-			*dst++ = *src++ * i / 64;
+		time = _vm->_system->getMillis();
+		i = (endTime - time) / 10;
+
+		if (time < endTime) {
+			for (uint j = 0; j < sizeof(palette); j++)
+				*dst++ = *src++ * i / 64;
+		} else {
+			memset(palette, 0, sizeof(palette));
+		}
 
 		_vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
 		_vm->doFrame();
-	}
+	} while (time < endTime);
 }
 
 void MystGraphics::fadeFromBlack() {
@@ -726,18 +737,28 @@ void MystGraphics::fadeFromBlack() {
 
 	copyBackBufferToScreen(_viewport);
 
-	// Linear fade in 64 steps
-	for (int i = 0; i < 64; i++) {
+	// Linear fade in 64 steps or less
+	uint32 startTime = _vm->_system->getMillis();
+	uint32 endTime = startTime + 640;
+	uint32 time, i;
+
+	do {
 		byte palette[256 * 3];
 		byte *src = _palette;
 		byte *dst = palette;
+		time = _vm->_system->getMillis();
+		i = (time - startTime) / 10;
 
-		for (uint j = 0; j < sizeof(palette); j++)
-			*dst++ = *src++ * i / 64;
+		if (time < endTime) {
+			for (uint j = 0; j < sizeof(palette); j++)
+				*dst++ = *src++ * i / 64;
+		} else {
+			memcpy(palette, _palette, sizeof(palette));
+		}
 
 		_vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
 		_vm->doFrame();
-	}
+	} while (time < endTime);
 
 	// Set the full palette
 	_vm->_system->getPaletteManager()->setPalette(_palette, 0, 256);




More information about the Scummvm-git-logs mailing list