[Scummvm-git-logs] scummvm master -> 07b1314ff4828b3f8f8ec4f967f8e5a72c21b810
rvanlaar
roland at rolandvanlaar.nl
Mon Aug 3 10:07:30 UTC 2020
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:
644704a5ba DIRECTOR: Allow Director Version change during runtime
1906ebcea0 DIRECTOR: LINGO: D3 float to int as round
07b1314ff4 DIRECTOR: LINGO: Implement D3ism with chars
Commit: 644704a5ba9b0b3db70f2d66942262b319aa9b7c
https://github.com/scummvm/scummvm/commit/644704a5ba9b0b3db70f2d66942262b319aa9b7c
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2020-08-03T12:01:15+02:00
Commit Message:
DIRECTOR: Allow Director Version change during runtime
There are subtle versions between director versions.
Changing the version during runtime allows for testing these
changes from the lingo tests.
Includes a new kThe keyword: kTheScummvmVersion.
The Director Version can be set and queried with it.
Changed paths:
engines/director/detection.cpp
engines/director/director.cpp
engines/director/director.h
engines/director/lingo/lingo-the.cpp
engines/director/lingo/lingo-the.h
diff --git a/engines/director/detection.cpp b/engines/director/detection.cpp
index 1b3d20c45b..dcb3bdcaf2 100644
--- a/engines/director/detection.cpp
+++ b/engines/director/detection.cpp
@@ -50,7 +50,7 @@ Common::Platform DirectorEngine::getPlatform() const {
return _gameDescription->desc.platform;
}
-uint16 DirectorEngine::getVersion() const {
+uint16 DirectorEngine::getDescriptionVersion() const {
return _gameDescription->version;
}
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index f606dd5b8b..2c7f7885dc 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -86,6 +86,7 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
_windowList->u.farr = new DatumArray;
_currentStage = nullptr;
_lingo = nullptr;
+ _version = getDescriptionVersion();
_wm = nullptr;
_surface = nullptr;
diff --git a/engines/director/director.h b/engines/director/director.h
index 1bb44a4de4..647ec3cf91 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -170,7 +170,9 @@ public:
DirectorGameGID getGameGID() const;
const char *getGameId() const;
- uint16 getVersion() const;
+ uint16 getDescriptionVersion() const;
+ uint16 getVersion() const { return _version; }
+ void setVersion(uint16 version) { _version = version; }
Common::Platform getPlatform() const;
Common::Language getLanguage() const;
const char *getExtra();
@@ -240,6 +242,7 @@ private:
byte *_currentPalette;
uint16 _currentPaletteLength;
Lingo *_lingo;
+ uint16 _version;
Stage *_mainStage;
Datum *_windowList; // Lingo list
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index 1e8e077329..d689e76859 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -120,6 +120,7 @@ TheEntity entities[] = {
{ kTheRightMouseDown, "rightMouseDown", false, 5 }, // D5 f
{ kTheRightMouseUp, "rightMouseUp", false, 5 }, // D5 f
{ kTheRomanLingo, "romanLingo", false, 3 }, // D3.1 p
+ { kTheScummvmVersion, "scummvmVersion", false, 2 }, // ScummVM only
{ kTheSearchCurrentFolder,"searchCurrentFolder",false,4 },// D4 f
{ kTheSearchPath, "searchPath", false, 4 }, // D4 f
{ kTheSelection, "selection", false, 2 }, // D2 f
@@ -677,6 +678,10 @@ Datum Lingo::getTheEntity(int entity, Datum &id, int field) {
case kTheRomanLingo:
getTheEntitySTUB(kTheRomanLingo);
break;
+ case kTheScummvmVersion:
+ d.type = INT;
+ d.u.i = _vm->getVersion();
+ break;
case kTheSearchCurrentFolder:
getTheEntitySTUB(kTheSearchCurrentFolder);
break;
@@ -938,6 +943,10 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
case kTheRomanLingo:
setTheEntitySTUB(kTheRomanLingo);
break;
+ case kTheScummvmVersion:
+ // Allow director version change: used for testing version differences via the lingo tests.
+ _vm->setVersion(d.asInt());
+ break;
case kTheSelEnd:
if (_vm->getCurrentMovie()->_currentEditableTextChannel != 0) {
Channel *channel = _vm->getCurrentMovie()->getScore()->getChannelById(_vm->getCurrentMovie()->_currentEditableTextChannel);
diff --git a/engines/director/lingo/lingo-the.h b/engines/director/lingo/lingo-the.h
index 9e8eb5a297..2dfe832953 100644
--- a/engines/director/lingo/lingo-the.h
+++ b/engines/director/lingo/lingo-the.h
@@ -109,6 +109,7 @@ enum TheEntityType {
kTheRightMouseDown,
kTheRightMouseUp,
kTheRomanLingo,
+ kTheScummvmVersion, // set the Director version via lingo in tests
kTheSearchCurrentFolder,
kTheSearchPath,
kTheSelection,
Commit: 1906ebcea07cad3b1e4d484c953b838201180e83
https://github.com/scummvm/scummvm/commit/1906ebcea07cad3b1e4d484c953b838201180e83
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2020-08-03T12:01:15+02:00
Commit Message:
DIRECTOR: LINGO: D3 float to int as round
D3 does a round, D4 a floor. Now when converting a Datum to an int
with D3 it's done with round. With D4 the default behavior is kept,
i.e. a floor.
Includes a test for charOf which tests this.
Changed paths:
engines/director/lingo/lingo.cpp
engines/director/lingo/tests/strings.lingo
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 9c1b2a9215..197dd89a82 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -20,6 +20,8 @@
*
*/
+#include <math.h>
+
#include "common/file.h"
#include "common/config-manager.h"
@@ -852,7 +854,10 @@ int Datum::asInt() const {
res = u.i;
break;
case FLOAT:
- res = (int)u.f;
+ if (g_director->getVersion() < 4)
+ res = round(u.f);
+ else
+ res = (int)u.f;
break;
default:
warning("Incorrect operation asInt() for type: %s", type2str());
diff --git a/engines/director/lingo/tests/strings.lingo b/engines/director/lingo/tests/strings.lingo
index ef2a223366..7212ae7eea 100644
--- a/engines/director/lingo/tests/strings.lingo
+++ b/engines/director/lingo/tests/strings.lingo
@@ -45,8 +45,19 @@ set res to char 60 of string
scummvmAssertEqual(res, EMPTY)
set res to char 0 of string
scummvmAssertEqual(res, string)
-set res to char 5.4 of string
+-- Test D4, it does a floor
+set res to char 5.49 of string
scummvmAssertEqual(res, "o")
+set res to char 5.5 of string
+scummvmAssertEqual(res, "o")
+-- Test D3, it does a round
+set save to the scummvmVersion
+set the scummvmVersion to 3
+set res to char 5.49 of string
+scummvmAssertEqual(res, "o")
+set res to char 5.5 of string
+scummvmAssertEqual(res, "m")
+set the scummvmVersion to save
-- LC::charToOf
set string to "Macromedia"
Commit: 07b1314ff4828b3f8f8ec4f967f8e5a72c21b810
https://github.com/scummvm/scummvm/commit/07b1314ff4828b3f8f8ec4f967f8e5a72c21b810
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2020-08-03T12:01:15+02:00
Commit Message:
DIRECTOR: LINGO: Implement D3ism with chars
In D3 the builtin chars throws an error when called with a float.
Mimick this behavior by returning a Datum(0).
The choice was made to recreate this behavior to serve
as living documentation on how Director behaves.
Changed paths:
engines/director/lingo/lingo-builtins.cpp
engines/director/lingo/tests/strings.lingo
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index a37d7d64ab..be2e1b710b 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -438,11 +438,20 @@ void LB::b_tan(int nargs) {
// String
///////////////////
void LB::b_chars(int nargs) {
- int to = g_lingo->pop().asInt();
- int from = g_lingo->pop().asInt();
+ Datum d3 = g_lingo->pop();
+ Datum d2 = g_lingo->pop();
Datum s = g_lingo->pop();
TYPECHECK2(s, STRING, FIELDREF);
+ if (g_director->getVersion() < 4 && (d2.type == FLOAT || d3.type == FLOAT)) {
+ // D3 throws an error when called with a float.
+ g_lingo->push(Datum(0));
+ return;
+ }
+
+ int to = d3.asInt();
+ int from = d2.asInt();
+
Common::String src = s.asString();
int len = strlen(src.c_str());
diff --git a/engines/director/lingo/tests/strings.lingo b/engines/director/lingo/tests/strings.lingo
index 7212ae7eea..3af97b5aa8 100644
--- a/engines/director/lingo/tests/strings.lingo
+++ b/engines/director/lingo/tests/strings.lingo
@@ -10,6 +10,11 @@ set c = chars("Macromedia", 6, 10)
scummvmAssertEqual(c, "media")
set c = chars("Macromedia", -1, 15)
scummvmAssertEqual(c, "Macromedia")
+set save to the scummvmVersion
+set the scummvmVersion to 3
+set c = chars("Macromedia", 1, 1.1)
+scummvmAssertEqual(c, 0)
+set the scummvmVersion to save
scummvmAssert("meow" = "MeÍW")
More information about the Scummvm-git-logs
mailing list