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

djsrv dservilla at gmail.com
Tue Jul 27 00:00:28 UTC 2021


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

Summary:
eded70bc8a DIRECTOR: Start _currentFrame at 1, not 0
f5c3e65ec0 DIRECTOR: LINGO: Implement framesToHMS and HMStoFrames
3b1dc4ada7 DIRECTOR: LINGO: Add HMS tests
44dc5ed55d DIRECTOR: LINGO: Fix string input to b_integer
d7c3444991 DIRECTOR: LINGO: Cap framesToHMS hours output to 99


Commit: eded70bc8ab551adca581e0d6e3ab9f552fe3a3a
    https://github.com/scummvm/scummvm/commit/eded70bc8ab551adca581e0d6e3ab9f552fe3a3a
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-26T19:57:12-04:00

Commit Message:
DIRECTOR: Start _currentFrame at 1, not 0

If a startMovie handler gets 'the frame', it should return 1, not 0.

Changed paths:
    engines/director/score.cpp


diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index fd17bd6836..530bfdfbbb 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -257,7 +257,7 @@ int Score::getPreviousLabelNumber(int referenceFrame) {
 }
 
 void Score::startPlay() {
-	_currentFrame = 0;
+	_currentFrame = 1;
 	_playState = kPlayStarted;
 	_nextFrameTime = 0;
 
@@ -344,7 +344,7 @@ void Score::update() {
 	}
 
 	// For previous frame
-	if (_currentFrame > 0 && !_vm->_playbackPaused) {
+	if (!_window->_newMovieStarted && !_vm->_playbackPaused) {
 		// When Lingo::func_goto* is called, _nextFrame is set
 		// and _skipFrameAdvance is set to true.
 		// exitFrame is not called in this case.
@@ -359,12 +359,10 @@ void Score::update() {
 		}
 	}
 
-	if (!_vm->_playbackPaused) {
-		if (_nextFrame)
-			_currentFrame = _nextFrame;
-		else
-			_currentFrame++;
-	}
+	if (_nextFrame)
+		_currentFrame = _nextFrame;
+	else if (!_window->_newMovieStarted)
+		_currentFrame++;
 
 	_nextFrame = 0;
 


Commit: f5c3e65ec00442ecf1babd5d9712a645bcd000c6
    https://github.com/scummvm/scummvm/commit/f5c3e65ec00442ecf1babd5d9712a645bcd000c6
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-26T19:57:12-04:00

Commit Message:
DIRECTOR: LINGO: Implement framesToHMS and HMStoFrames

Changed paths:
    engines/director/lingo/lingo-builtins.cpp


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 809b054e70..45aa576df8 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1257,19 +1257,125 @@ void LB::b_preLoadCast(int nargs) {
 }
 
 void LB::b_framesToHMS(int nargs) {
-	g_lingo->printSTUBWithArglist("b_framesToHMS", nargs);
+	int fractionalSeconds = g_lingo->pop().asInt();
+	int dropFrame = g_lingo->pop().asInt();
+	int fps = g_lingo->pop().asInt();
+	int frames = g_lingo->pop().asInt();
 
-	g_lingo->dropStack(nargs);
+	if (fps <= 0)
+		fps = -fps;
 
-	g_lingo->push(Datum(0));
+	bool negative = frames < 0;
+	if (negative)
+		frames = -frames;
+
+	int framesPerMin = 60 * fps;
+	int framesPerHour = 60 * framesPerMin;
+
+	if (dropFrame)
+		warning("STUB: b_framesToHMS: Unhandled dropFrame option");
+
+	int h = frames / framesPerHour;
+	int m = (frames % framesPerHour) / framesPerMin;
+	int s = (frames % framesPerMin) / fps;
+
+	int residual;
+	if (fractionalSeconds) {
+		int ms = (1000 * (frames % fps)) / fps;
+		residual = (ms + 5) / 10; // round to nearest centisecond
+	} else {
+		residual = frames % fps;
+	}
+
+	Common::String hms = Common::String::format(
+		"%c%02d:%02d:%02d.%02d%c",
+		negative ? '-' : ' ',
+		h, m, s, residual,
+		dropFrame ? 'd' : ' '
+	);
+
+	g_lingo->push(hms);
 }
 
 void LB::b_HMStoFrames(int nargs) {
-	g_lingo->printSTUBWithArglist("b_HMStoFrames", nargs);
+	// The original implementation of this accepts some really weird,
+	// seemingly malformed input strings.
+	// (Try, for example, "12345678901234567890")
+	// It's probably not worth supporting them all unless we need to,
+	// so only well-formed input is handled right now.
+
+	int fractionalSeconds = g_lingo->pop().asInt();
+	int dropFrame = g_lingo->pop().asInt();
+	int fps = g_lingo->pop().asInt();
+	Common::String hms = g_lingo->pop().asString();
+
+	if (fps <= 0)
+		fps = 1;
+
+	const char *ptr = hms.c_str();
+	while (Common::isSpace(*ptr))
+		ptr++;
+
+	// read sign
+	bool negative = false;
+	if (*ptr == '-') {
+		negative = true;
+		ptr++;
+	}
+
+	// read HH, MM, and SS
+	int secs = 0;
+	for (int i = 0; i < 3; i++) {
+		if (*ptr == ':' || Common::isSpace(*ptr))
+			ptr ++;
+
+		if (!Common::isDigit(*ptr))
+			break;
 
-	g_lingo->dropStack(nargs);
+		int part = 0;
+		for (int j = 0; j < 2 && Common::isDigit(*ptr); j++) {
+			part = (10 * part) + (*ptr - '0');
+			ptr++;
+		}
+		secs = (60 * secs) + part;
+	}
+	int frames = secs * fps;
 
-	g_lingo->push(Datum(0));
+	// read FF
+	if (*ptr == '.') {
+		ptr++;
+
+		int part = 0;
+		for (int i = 0; i < 2 && Common::isDigit(*ptr); i++) {
+			part = (10 * part) + (*ptr - '0');
+			ptr++;
+		}
+		if (fractionalSeconds) {
+			frames += (part * fps + 50) / 100; // round to nearest frame
+		} else {
+			frames += part;
+		}
+	}
+
+	// read D
+	if (*ptr == 'd' || *ptr == 'D') {
+		ptr++;
+		dropFrame = 1;
+	}
+
+	while (Common::isSpace(*ptr))
+		ptr++;
+
+	if (*ptr != '\0')
+		warning("b_HMStoFrames: Unexpected character '%c'", *ptr);
+
+	if (dropFrame)
+		warning("STUB: b_HMStoFrames: Unhandled dropFrame option");
+
+	if (negative)
+		frames = -frames;
+
+	g_lingo->push(frames);
 }
 
 void LB::b_param(int nargs) {


Commit: 3b1dc4ada7ce67885471313c07bf59e543b5154b
    https://github.com/scummvm/scummvm/commit/3b1dc4ada7ce67885471313c07bf59e543b5154b
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-26T19:57:12-04:00

Commit Message:
DIRECTOR: LINGO: Add HMS tests

Changed paths:
  A engines/director/lingo/tests/hms.lingo


diff --git a/engines/director/lingo/tests/hms.lingo b/engines/director/lingo/tests/hms.lingo
new file mode 100644
index 0000000000..df6cb466e7
--- /dev/null
+++ b/engines/director/lingo/tests/hms.lingo
@@ -0,0 +1,13 @@
+scummvmAssertEqual framesToHMS(123456, 30, FALSE, FALSE), " 01:08:35.06 "
+scummvmAssertEqual framesToHMS(-123456, 30, FALSE, FALSE), "-01:08:35.06 "
+
+scummvmAssertEqual framesToHMS(123456, 30, FALSE, TRUE), " 01:08:35.20 "
+
+scummvmAssertEqual HMSToFrames(" 01:08:35.06 ", 30, FALSE, FALSE), 123456
+scummvmAssertEqual HMSToFrames("-01:08:35.06 ", 30, FALSE, FALSE), -123456
+scummvmAssertEqual HMSToFrames("01:08:35.06", 30, FALSE, FALSE), 123456
+scummvmAssertEqual HMSToFrames("08:35.06", 30, FALSE, FALSE), 15456
+scummvmAssertEqual HMSToFrames("35.06", 30, FALSE, FALSE), 1056
+scummvmAssertEqual HMSToFrames("35", 30, FALSE, FALSE), 1050
+
+scummvmAssertEqual HMSToFrames(" 01:08:35.20 ", 30, FALSE, TRUE), 123456


Commit: 44dc5ed55d67513ef2a6c10c671315aeb16a016d
    https://github.com/scummvm/scummvm/commit/44dc5ed55d67513ef2a6c10c671315aeb16a016d
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-26T19:57:12-04:00

Commit Message:
DIRECTOR: LINGO: Fix string input to b_integer

Changed paths:
    engines/director/lingo/lingo-builtins.cpp


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 45aa576df8..4e84979331 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -360,10 +360,14 @@ void LB::b_integer(int nargs) {
 	Datum d = g_lingo->pop();
 	Datum res;
 
-	if (g_director->getVersion() < 500) {	// Note that D4 behaves differently from asInt()
-		res = (int)(d.u.f + 0.5);		// Yes, +0.5 even for negative numbers
+	if (d.type == FLOAT) {
+		if (g_director->getVersion() < 500) {	// Note that D4 behaves differently from asInt()
+			res = (int)(d.u.f + 0.5);		// Yes, +0.5 even for negative numbers
+		} else {
+			res = (int)round(d.u.f);
+		}
 	} else {
-		res = (int)round(d.u.f);
+		res = d.asInt();
 	}
 
 	g_lingo->push(res);


Commit: d7c344499196b93500b25d01942d34d1e6601ad1
    https://github.com/scummvm/scummvm/commit/d7c344499196b93500b25d01942d34d1e6601ad1
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-26T19:57:12-04:00

Commit Message:
DIRECTOR: LINGO: Cap framesToHMS hours output to 99

Changed paths:
    engines/director/lingo/lingo-builtins.cpp


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 4e84979331..a12cb971e2 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1279,7 +1279,7 @@ void LB::b_framesToHMS(int nargs) {
 	if (dropFrame)
 		warning("STUB: b_framesToHMS: Unhandled dropFrame option");
 
-	int h = frames / framesPerHour;
+	int h = MIN(frames / framesPerHour, 99);
 	int m = (frames % framesPerHour) / framesPerMin;
 	int s = (frames % framesPerMin) / fps;
 




More information about the Scummvm-git-logs mailing list