[Scummvm-git-logs] scummvm master -> 9cb6a98c700b4f114ec34ffd91bb9ac1d5469953

sev- noreply at scummvm.org
Wed Mar 29 21:51:08 UTC 2023


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

Summary:
8ff8dd1ac2 DIRECTOR: Set value of 'the result' from call returns
2cecf4da96 DIRECTOR: Normalize xlibname to remove mac path delimiters :, @:
e8b593eefe DIRECTOR: Fix directory seperator while splitting path into dir, filename
9cb6a98c70 DIRECTOR: Add xlib DialogS and support for games saves in totaldistortion-win


Commit: 8ff8dd1ac24593bb66a48052505f6b78404e24d4
    https://github.com/scummvm/scummvm/commit/8ff8dd1ac24593bb66a48052505f6b78404e24d4
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-03-29T23:50:51+02:00

Commit Message:
DIRECTOR: Set value of 'the result' from call returns

Used when determining save/load success in the totaldistortion-win

Changed paths:
    engines/director/lingo/lingo-code.cpp
    engines/director/lingo/lingo.h


diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index fe0c19e0384..7fdaf18e965 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -191,10 +191,15 @@ void Lingo::push(Datum d) {
 	_stack.push_back(d);
 }
 
-void Lingo::pushVoid() {
+Datum Lingo::getVoid() {
 	Datum d;
 	d.u.s = nullptr;
 	d.type = VOID;
+	return d;
+}
+
+void Lingo::pushVoid() {
+	Datum d = getVoid();
 	push(d);
 }
 
@@ -1650,11 +1655,20 @@ void LC::call(const Symbol &funcSym, int nargs, bool allowRetVal) {
 
 		if (funcSym.u.bltin != LB::b_return && funcSym.u.bltin != LB::b_value) {
 			if (stackSize == stackSizeBefore + 1) {
+				// Set "the result" to return value!, when a method
+				// this is for handling result after execution!
+				Datum top = g_lingo->peek(0);
+				if (top.type == INT)
+					g_lingo->_theResult = top;
+
 				if (!allowRetVal) {
 					Datum extra = g_lingo->pop();
 					warning("Builtin '%s' dropping return value: %s", funcSym.name->c_str(), extra.asString(true).c_str());
 				}
 			} else if (stackSize == stackSizeBefore) {
+				// No value, hence "the result" is VOID
+				g_lingo->_theResult = g_lingo->getVoid();
+
 				if (allowRetVal)
 					error("Builtin '%s' did not return value", funcSym.name->c_str());
 			} else if (stackSize > stackSizeBefore) {
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 34aced959e7..2edebbc7578 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -403,6 +403,7 @@ public:
 	char *readString() { char *s = getString(_state->pc); _state->pc += calcStringAlignment(s); return s; }
 	char *getString(uint pc) { return (char *)(&((*_state->script)[_state->pc])); }
 
+	Datum getVoid();
 	void pushVoid();
 
 	void printSTUBWithArglist(const char *funcname, int nargs, const char *prefix = "STUB:");


Commit: 2cecf4da96eb721d5af42a56d9c6af00cae4ca1d
    https://github.com/scummvm/scummvm/commit/2cecf4da96eb721d5af42a56d9c6af00cae4ca1d
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-03-29T23:50:51+02:00

Commit Message:
DIRECTOR: Normalize xlibname to remove mac path delimiters :, @:

totaldistortion-win calls many libraries with @:xlibName format

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


diff --git a/engines/director/lingo/lingo-object.cpp b/engines/director/lingo/lingo-object.cpp
index 1ffd5cf06d3..199508ca6a7 100644
--- a/engines/director/lingo/lingo-object.cpp
+++ b/engines/director/lingo/lingo-object.cpp
@@ -244,6 +244,9 @@ Common::String Lingo::normalizeXLibName(Common::String name) {
 
 	name.trim();
 
+	// Normalize to remove machintosh path delimiters (':', '@:')
+	name = convertPath(name);
+
 	return name;
 }
 


Commit: e8b593eefec44bd56c2d1746041da9000c8cc292
    https://github.com/scummvm/scummvm/commit/e8b593eefec44bd56c2d1746041da9000c8cc292
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-03-29T23:50:51+02:00

Commit Message:
DIRECTOR: Fix directory seperator while splitting path into dir, filename

Used in formatting paths(C:\totaldistortion-win-savename.TDG) while loading/saving in totaldistortion-win

Changed paths:
    engines/director/lingo/xlibs/fileio.cpp


diff --git a/engines/director/lingo/xlibs/fileio.cpp b/engines/director/lingo/xlibs/fileio.cpp
index 1f9f28ca7dd..882b7975fea 100644
--- a/engines/director/lingo/xlibs/fileio.cpp
+++ b/engines/director/lingo/xlibs/fileio.cpp
@@ -204,12 +204,14 @@ void FileIO::m_new(int nargs) {
 	Common::String option = d1.asString();
 	Common::String path = d2.asString();
 	Common::String origpath = path;
+	char dirSeparator = g_director->_dirSeparator;
 
 	Common::String prefix = g_director->getTargetName() + '-';
 
 	if (option.hasPrefix("?")) {
 		option = option.substr(1);
 		Common::String mask = prefix + "*.txt";
+		dirSeparator = '/';
 
 		GUI::FileBrowserDialog browser(nullptr, "txt", option.equalsIgnoreCase("write") ? GUI::kFBModeSave : GUI::kFBModeLoad, mask.c_str());
 		if (browser.runModal() <= 0) {
@@ -222,8 +224,8 @@ void FileIO::m_new(int nargs) {
 	}
 
 	// Enforce target to the created files so they do not mix up
-	Common::String filename = lastPathComponent(path, '/');
-	Common::String dir = firstPathComponents(path, '/');
+	Common::String filename = lastPathComponent(path, dirSeparator);
+	Common::String dir = firstPathComponents(path, dirSeparator);
 
 	if (!filename.hasPrefixIgnoreCase(prefix))
 		filename = dir + prefix + filename;


Commit: 9cb6a98c700b4f114ec34ffd91bb9ac1d5469953
    https://github.com/scummvm/scummvm/commit/9cb6a98c700b4f114ec34ffd91bb9ac1d5469953
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-03-29T23:50:51+02:00

Commit Message:
DIRECTOR: Add xlib DialogS and support for games saves in totaldistortion-win

Changed paths:
  A engines/director/lingo/xlibs/dialogs.cpp
  A engines/director/lingo/xlibs/dialogs.h
    engines/director/lingo/lingo-object.cpp
    engines/director/lingo/xlibs/fileio.cpp
    engines/director/module.mk


diff --git a/engines/director/lingo/lingo-object.cpp b/engines/director/lingo/lingo-object.cpp
index 199508ca6a7..2759e2c9359 100644
--- a/engines/director/lingo/lingo-object.cpp
+++ b/engines/director/lingo/lingo-object.cpp
@@ -45,6 +45,7 @@
 #include "director/lingo/xlibs/cdromxobj.h"
 #include "director/lingo/xlibs/darkenscreen.h"
 #include "director/lingo/xlibs/developerStack.h"
+#include "director/lingo/xlibs/dialogs.h"
 #include "director/lingo/xlibs/dpwavi.h"
 #include "director/lingo/xlibs/dpwqtw.h"
 #include "director/lingo/xlibs/draw.h"
@@ -165,6 +166,7 @@ static struct XLibProto {
 	{ CDROMXObj::fileNames,				CDROMXObj::open,			CDROMXObj::close,			kXObj,					200 },	// D2
 	{ DarkenScreen::fileNames,			DarkenScreen::open,			DarkenScreen::close,		kXObj,					300 },	// D3
 	{ DeveloperStack::fileNames,		DeveloperStack::open,		DeveloperStack::close,		kXObj,					300 },	// D3
+	{ DialogsXObj::fileNames,			DialogsXObj::open,			DialogsXObj::close,			kXObj,					400 },	// D4
 	{ DPwAVI::fileNames,				DPwAVI::open,				DPwAVI::close,				kXObj,					400 },	// D4
 	{ DPwQTw::fileNames,				DPwQTw::open,				DPwQTw::close,				kXObj,					400 },	// D4
 	{ DrawXObj::fileNames,				DrawXObj::open,				DrawXObj::close,			kXObj,					400 },	// D4
diff --git a/engines/director/lingo/xlibs/dialogs.cpp b/engines/director/lingo/xlibs/dialogs.cpp
new file mode 100644
index 00000000000..cd61c2bfc9b
--- /dev/null
+++ b/engines/director/lingo/xlibs/dialogs.cpp
@@ -0,0 +1,141 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/*************************************
+*
+* USED IN:
+* Total Distortion
+*
+*************************************/
+/*
+ * -- Dialogs XObject. Written by Scott Kildall. Copyright (c) Red Eye  Software, December 11th, 1994.
+ * Compuserve:72703,451 AOL:KILDALL  APPLELINK:S.KILDALL
+ * Internet:72703.451 at compuserve.com
+ * Licensed for the MediaBook CD for Director
+ * Published by gray matter design (415) 243-0394
+ *
+ * Dialogs
+ * X        mNew          --Creates a new instance of the XObject
+ * SSSS     mPutFile, Dialog Title, Default Name, Default Extension       --Displays a save dialog box
+ * SSSS     mGetFile, Dialog Title, Default Name, Default Extension       --Displays an open dialog box
+ *
+ * -- How it is called:
+ * set GameFileFULLPATH to gDialogsObj(mPutFile, "Save your Total Distortion Game File!", "TDGame", "TDG")
+ * set GameFileFULLPATH to gDialogsObj(mGetFile, "Find your Total Distortion Game File!", "*.TDG", "TDG")
+*/
+
+#include "gui/filebrowser-dialog.h"
+
+#include "director/director.h"
+#include "director/lingo/lingo.h"
+#include "director/lingo/lingo-object.h"
+#include "director/lingo/xlibs/dialogs.h"
+
+namespace Director {
+
+const char *DialogsXObj::xlibNames[] = {
+	"DialogS",
+	nullptr
+};
+
+const char *DialogsXObj::fileNames[] = {
+	"DialogS",
+	"shaREQUE", // TD loads this up using openXLib("@:shaREQUE.DLL")
+	nullptr
+};
+
+static MethodProto xlibMethods[] = {
+	{ "new",               DialogsXObj::m_new,              0, 0,  400 },  // D4
+	{ "GetFile",           DialogsXObj::m_getFile,          3, 3,  400 },  // D4
+	{ "PutFile",           DialogsXObj::m_putFile,          3, 3,  400 },  // D4
+	{ nullptr, nullptr, 0, 0, 0 }
+};
+
+void DialogsXObj::open(int type) {
+	if (type == kXObj) {
+		DialogsXObject::initMethods(xlibMethods);
+		DialogsXObject *xobj = new DialogsXObject(kXObj);
+		for (uint i = 0; xlibNames[i]; i++) {
+			g_lingo->exposeXObject(xlibNames[i], xobj);
+		}
+	}
+}
+
+void DialogsXObj::close(int type) {
+	if (type == kXObj) {
+		DialogsXObject::cleanupMethods();
+		for (uint i = 0; xlibNames[i]; i++) {
+			g_lingo->_globalvars[xlibNames[i]] = Datum();
+		}
+	}
+}
+
+DialogsXObject::DialogsXObject(ObjectType ObjectType) : Object<DialogsXObject>("DialogS") {
+	_objType = ObjectType;
+}
+
+void DialogsXObj::m_new(int nargs) {
+	g_lingo->push(g_lingo->_state->me);
+}
+
+void DialogsXObj::m_putFile(int nargs) {
+	Common::String title = g_lingo->pop().asString();
+	Common::String name = g_lingo->pop().asString();
+	Common::String extn = g_lingo->pop().asString();
+
+	Common::String prefix = g_director->getTargetName() + '-';
+	Common::String mask = prefix + "*." + extn + ".txt";
+	Common::String filename = name;
+
+	GUI::FileBrowserDialog browser(title.c_str(), "txt", GUI::kFBModeSave, mask.c_str());
+	if (browser.runModal() > 0) {
+		filename = browser.getResult();
+		if (!filename.matchString(mask)) // If user choose to create new file (rather than overwriting existing one)
+			filename = Common::String::format("C:\\%s%s", prefix.c_str(), filename.c_str());
+		else {
+			// Here user chose existing save file to be overwritten, so format it before sending! (To prevent duplicate extensions)
+			const Common::String suffx = "." + extn;
+			Common::replace(filename, suffx, "");
+		}
+	}
+	warning("DialogsXObj::m_putFile return filename: %s", filename.c_str());
+	g_lingo->push(Datum(filename));
+}
+
+void DialogsXObj::m_getFile(int nargs) {
+	Common::String title = g_lingo->pop().asString();
+	Common::String name = g_lingo->pop().asString();
+	Common::String extn = g_lingo->pop().asString();
+
+	Common::String prefix = g_director->getTargetName() + '-';
+	Common::String mask = prefix + "*." + extn + ".txt";
+	Common::String fileName = name;
+
+	GUI::FileBrowserDialog browser(title.c_str(), "txt", GUI::kFBModeLoad, mask.c_str());
+	if (browser.runModal() > 0) {
+		Common::String path = browser.getResult();
+		fileName = Common::String::format("C:\\%s", path.c_str()); // Create fullpath from this name, as: C:\filename.TDG.txt!
+	}
+	warning("DialogsXObj::m_getFile return filename: %s", fileName.c_str());
+	g_lingo->push(Datum(fileName));
+}
+
+} // End of namespace Director
diff --git a/engines/director/lingo/xlibs/dialogs.h b/engines/director/lingo/xlibs/dialogs.h
new file mode 100644
index 00000000000..4db6722ff00
--- /dev/null
+++ b/engines/director/lingo/xlibs/dialogs.h
@@ -0,0 +1,47 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef DIRECTOR_LINGO_XLIBS_DIALOGSXOBJ_H
+#define DIRECTOR_LINGO_XLIBS_DIALOGSXOBJ_H
+
+namespace Director {
+class DialogsXObject : public Object<DialogsXObject> {
+public:
+	DialogsXObject(ObjectType objType);
+};
+
+namespace DialogsXObj {
+
+extern const char *xlibNames[];
+extern const char *fileNames[];
+
+void open(int type);
+void close(int type);
+
+void m_new(int nargs);
+void m_putFile(int nargs);
+void m_getFile(int nargs);
+
+} // End of namespace DialogsXObj
+
+} // End of namespace Director
+
+#endif
diff --git a/engines/director/lingo/xlibs/fileio.cpp b/engines/director/lingo/xlibs/fileio.cpp
index 882b7975fea..a0bf15b109e 100644
--- a/engines/director/lingo/xlibs/fileio.cpp
+++ b/engines/director/lingo/xlibs/fileio.cpp
@@ -95,6 +95,7 @@ namespace Director {
 const char *FileIO::xlibName = "FileIO";
 const char *FileIO::fileNames[] = {
 	"FileIO",
+	"shFILEIO", // TD loads this up using openXLib("@:shFILEIO.DLL")
 	nullptr
 };
 
diff --git a/engines/director/module.mk b/engines/director/module.mk
index fb0d095fb49..176375ee82b 100644
--- a/engines/director/module.mk
+++ b/engines/director/module.mk
@@ -51,6 +51,7 @@ MODULE_OBJS = \
 	lingo/xlibs/cdromxobj.o \
 	lingo/xlibs/darkenscreen.o \
 	lingo/xlibs/developerStack.o \
+	lingo/xlibs/dialogs.o \
 	lingo/xlibs/dpwavi.o \
 	lingo/xlibs/dpwqtw.o \
 	lingo/xlibs/draw.o \




More information about the Scummvm-git-logs mailing list