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

AndywinXp noreply at scummvm.org
Sun Oct 12 22:47:06 UTC 2025


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:
ec0a6a26d6 SCUMM: HE60-62 (DOS): Set proper PIT divisors constants


Commit: ec0a6a26d6a040534a854c510bb1d38baeee7142
    https://github.com/scummvm/scummvm/commit/ec0a6a26d6a040534a854c510bb1d38baeee7142
Author: AndywinXp (andywinxp at gmail.com)
Date: 2025-10-13T00:46:33+02:00

Commit Message:
SCUMM: HE60-62 (DOS): Set proper PIT divisors constants

This makes timing accurate for early HE DOS games.

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


diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index cb33188e265..230a25e9d93 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2818,43 +2818,76 @@ uint32 ScummEngine::getIntegralTime(double fMsecs) {
 void ScummEngine::setTimerAndShakeFrequency() {
 	_shakeTimerRate = _timerFrequency = 240.0;
 
-	if (_game.platform == Common::kPlatformDOS || _game.platform == Common::kPlatformWindows || _game.platform == Common::kPlatformUnknown) {
-		switch (_game.version) {
-		case 1:
-			if (_game.id == GID_MANIAC) {
-				// In MANIAC V1, one tick represents three frames,
-				// i.e., 12 quarter-frames.
-				_shakeTimerRate = _timerFrequency = PIT_BASE_FREQUENCY / PIT_V1_DIVISOR * 12;
-			} else {
+	if (_game.heversion == 0) {
+		if (_game.platform == Common::kPlatformDOS || _game.platform == Common::kPlatformWindows || _game.platform == Common::kPlatformUnknown) {
+			switch (_game.version) {
+			case 1:
+				if (_game.id == GID_MANIAC) {
+					// In MANIAC V1, one tick represents three frames,
+					// i.e., 12 quarter-frames.
+					_shakeTimerRate = _timerFrequency = PIT_BASE_FREQUENCY / PIT_V1_DIVISOR * 12;
+				} else {
+					_shakeTimerRate = _timerFrequency = PIT_BASE_FREQUENCY / PIT_V2_4_DIVISOR;
+				}
+				break;
+			case 2:
+			case 3:
+			case 4:
 				_shakeTimerRate = _timerFrequency = PIT_BASE_FREQUENCY / PIT_V2_4_DIVISOR;
+				break;
+			case 5:
+				_shakeTimerRate = _timerFrequency = PIT_BASE_FREQUENCY / PIT_V5_6_ORCHESTRATOR_DIVISOR;
+				_timerFrequency *= PIT_V5_6_SUBTIMER_INC / PIT_V5_SUBTIMER_THRESH;
+				break;
+			case 6:
+				_shakeTimerRate = _timerFrequency = PIT_BASE_FREQUENCY / PIT_V5_6_ORCHESTRATOR_DIVISOR;
+				if (_game.id == GID_TENTACLE) {
+					_timerFrequency *= PIT_V5_6_SUBTIMER_INC / PIT_V6_DOTT_SUBTIMER_THRESH;
+				} else {
+					_timerFrequency *= PIT_V5_6_SUBTIMER_INC / PIT_V6_SAMNMAX_SUBTIMER_THRESH;
+				}
+				break;
+			case 7:
+				_shakeTimerRate = _timerFrequency = PIT_BASE_FREQUENCY / PIT_V7_ORCHESTRATOR_DIVISOR;
+				_timerFrequency *= PIT_V7_SUBTIMER_INC / PIT_V7_SUBTIMER_THRESH;
+				break;
+			default:
+				_shakeTimerRate = _timerFrequency = 240.0;
 			}
-			break;
-		case 2:
-		case 3:
-		case 4:
-			_shakeTimerRate = _timerFrequency = PIT_BASE_FREQUENCY / PIT_V2_4_DIVISOR;
-			break;
-		case 5:
-			_shakeTimerRate = _timerFrequency = PIT_BASE_FREQUENCY / PIT_V5_6_ORCHESTRATOR_DIVISOR;
-			_timerFrequency *= PIT_V5_6_SUBTIMER_INC / PIT_V5_SUBTIMER_THRESH;
-			break;
-		case 6:
-			_shakeTimerRate = _timerFrequency = PIT_BASE_FREQUENCY / PIT_V5_6_ORCHESTRATOR_DIVISOR;
-			if (_game.id == GID_TENTACLE) {
-				_timerFrequency *= PIT_V5_6_SUBTIMER_INC / PIT_V6_DOTT_SUBTIMER_THRESH;
+		} else if (_game.platform == Common::kPlatformAmiga && _game.id != GID_MONKEY_VGA) {
+			_shakeTimerRate = _timerFrequency = _isAmigaPALSystem ? AMIGA_PAL_VBLANK_RATE : AMIGA_NTSC_VBLANK_RATE;
+		}
+	} else {
+		if (_game.heversion < 70 && _game.platform == Common::kPlatformDOS) {
+			// HE6x DOS games use a slightly different (but not really...)
+			// mechanism to increment "piffies" (a quarter of a jiffy).
+			// 
+			// Fatty Bear, Putt-Putt's Fun Pack:
+			//   - PIT divisor: 0x5555 (21845) -> ~54.6 Hz timer interrupt
+			//   - The piffy value is directly incremented by 4 on every interrupt
+			//   - Effective jiffy rate: 54.6 Hz
+			// 
+			// Putt-Putt (1&2), Fatty Bear's Fun Pack, Putt-Putt & Fatty Bear's Activity Pack:
+			//   - PIT divisor: 0x2492 (9362) -> ~127.5 Hz timer interrupt
+			//   - The piffy value is directly incremented by 4 on every *other* interrupt
+			//   - Effective jiffy rate: 63.75 Hz
+			// 
+			// The multiplication by 4 below re-adapts these jiffy rates to our quarter-frame system.
+
+			if (_game.id == GID_FBEAR || _game.id == GID_FUNPACK) {
+				_shakeTimerRate = _timerFrequency = PIT_BASE_FREQUENCY / PIT_HE_FATTY_BEAR_DIVISOR * 4.0;
+			} else if (_game.id == GID_PUTTDEMO ||
+					   _game.id == GID_PUTTMOON ||
+					   Common::String(_game.gameid).equals("puttputt") ||
+					   Common::String(_game.gameid).equals("activity") ||
+					   Common::String(_game.gameid).equals("fbpack")) {
+				_shakeTimerRate = _timerFrequency = PIT_BASE_FREQUENCY / PIT_HE_PUTT_PUTT_DIVISOR / 2.0 * 4.0;
 			} else {
-				_timerFrequency *= PIT_V5_6_SUBTIMER_INC / PIT_V6_SAMNMAX_SUBTIMER_THRESH;
+				_shakeTimerRate = _timerFrequency = 240.0;
 			}
-			break;
-		case 7:
-			_shakeTimerRate = _timerFrequency = PIT_BASE_FREQUENCY / PIT_V7_ORCHESTRATOR_DIVISOR;
-			_timerFrequency *= PIT_V7_SUBTIMER_INC / PIT_V7_SUBTIMER_THRESH;
-			break;
-		default:
+		} else {
 			_shakeTimerRate = _timerFrequency = 240.0;
 		}
-	} else if (_game.platform == Common::kPlatformAmiga && _game.id != GID_MONKEY_VGA) {
-		_shakeTimerRate = _timerFrequency = _isAmigaPALSystem ? AMIGA_PAL_VBLANK_RATE : AMIGA_NTSC_VBLANK_RATE;
 	}
 }
 
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index b6388013525..a869f33ba13 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -323,6 +323,9 @@ class ResourceManager;
 #define PIT_V7_SUBTIMER_INC            3977.0
 #define PIT_V7_SUBTIMER_THRESH         4971.0
 
+#define PIT_HE_PUTT_PUTT_DIVISOR       9362.0
+#define PIT_HE_FATTY_BEAR_DIVISOR      21845.0
+
 #define LOOM_STEAM_CDDA_RATE           240.0
 
 /**




More information about the Scummvm-git-logs mailing list