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

athrxx athrxx at scummvm.org
Mon May 17 18:02:49 UTC 2021


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:
fb8f108402 SCUMM: (FM-Towns) - improve smooth scroling


Commit: fb8f10840292ca2f678d4414815ff9578205656c
    https://github.com/scummvm/scummvm/commit/fb8f10840292ca2f678d4414815ff9578205656c
Author: athrxx (athrxx at scummvm.org)
Date: 2021-05-17T20:02:24+02:00

Commit Message:
SCUMM: (FM-Towns) - improve smooth scroling

I have made the scrolling more smooth and still hopefully managed not to break the sync with the engine (which really is a bit tricky).
I've tested playing the ZAK and LOOM intros and also walking around in ZAK and MI2, since there are some good test cases there. I've also compared all these side by side with the UNZ emulator.

Changed paths:
    engines/scumm/gfx_towns.cpp
    engines/scumm/scumm.cpp


diff --git a/engines/scumm/gfx_towns.cpp b/engines/scumm/gfx_towns.cpp
index 56a43beacb..b28d77d34e 100644
--- a/engines/scumm/gfx_towns.cpp
+++ b/engines/scumm/gfx_towns.cpp
@@ -186,13 +186,13 @@ void ScummEngine::towns_updateGfx() {
 		return;
 
 	uint32 cur = _system->getMillis();
-	while (_scrollTimer <= cur) {
+	if (_scrollTimer <= cur) {
 		if (!_scrollTimer)
 			_scrollTimer = cur;
 		_scrollTimer += 1000 / 60;
 		_townsScreen->scrollLayers(1, _scrollRequest);
 		if (_townsScreen->isScrolling(0))
-			_scrollDeltaAdjust = 1;
+			_scrollDeltaAdjust++;
 		_scrollRequest = 0;
 	}
 
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 3ea4107a47..cf264c0425 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2275,9 +2275,16 @@ Common::Error ScummEngine::go() {
 		// Determine how long to wait before the next loop iteration should start
 		int delta = (VAR_TIMER_NEXT != 0xFF) ? VAR(VAR_TIMER_NEXT) : 4;
 #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
-		// FM-Towns only. The original does this to make the engine wait for the scrolling to catch up.
-		if (_scrollDeltaAdjust)
-			delta = delta * 4 / (4 - _scrollDeltaAdjust);
+		// FM-Towns only. The original has a mechanism to let the scrolling catch up to the engine. This avoids glitches, e. g.
+		// when the engine draws actors or objects to the far left/right of the screen while the scrolling hasn't caught up yet.
+		// MI2 FM-Towns normally adds an amount of 4 to a counter on each 60 Hz tick from inside an interrupt handler, but only
+		// an amount of 3 while the smooth scrolling is in progress. The counter divided by 4 has to reach the VAR_TIMER_NEXT
+		// before the main loop continues. We try to imitate that behaviour here to avoid glitches, but without making it
+		// overly complicated...
+		if (_scrollDeltaAdjust) {
+			int adj = MIN<int>(_scrollDeltaAdjust * 4 / 3 - _scrollDeltaAdjust, delta * 4 / 3 - delta);
+			delta += adj;
+		}
 		_scrollDeltaAdjust = 0;
 #endif
 		if (delta < 1)	// Ensure we don't get into an endless loop




More information about the Scummvm-git-logs mailing list