[Scummvm-git-logs] scummvm master -> 0a2688268bd74783a12502aeff14f6b4e02705ca

djsrv dservilla at gmail.com
Wed Jun 23 20:31:57 UTC 2021


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

Summary:
cce64b815b DIRECTOR: LINGO: Make chunk -30000 return last chunk
a433004914 DIRECTOR: LINGO: Fix chunkRef bounds check
b423f6e563 DIRECTOR: LINGO: Add chunk ref instructions
2fabaedac8 DIRECTOR: LINGO: Improve tests for "the last"
7a32cb300f DIRECTOR: LINGO: Add "delete the last" tests
c13088a829 DIRECTOR: LINGO: Load intpush's arg as signed
0a2688268b DIRECTOR: LINGO: Fix negative bytecode chunk refs


Commit: cce64b815ba6d545e0a9d0b2e3f0ffe0d74587c9
    https://github.com/scummvm/scummvm/commit/cce64b815ba6d545e0a9d0b2e3f0ffe0d74587c9
Author: djsrv (dservilla at gmail.com)
Date: 2021-06-23T16:29:10-04:00

Commit Message:
DIRECTOR: LINGO: Make chunk -30000 return last chunk

This is what the original does.

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


diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index e8c7dd2d2d..d3de9539e5 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -869,7 +869,7 @@ void LC::c_within() {
 	}
 }
 
-Datum LC::chunkRef(ChunkType type, int startChunk, int endChunk, const Datum &src, bool returnLast) {
+Datum LC::chunkRef(ChunkType type, int startChunk, int endChunk, const Datum &src) {
 	// A chunk expression is made up of 0 or more chunks within a source text.
 	// This function returns a reference to the source text, the start index of the first chunk,
 	// and the end index of the last chunk in the chunk expression.
@@ -877,9 +877,8 @@ Datum LC::chunkRef(ChunkType type, int startChunk, int endChunk, const Datum &sr
 	if (0 > endChunk && endChunk < startChunk)
 		return src;
 
-	// If startChunk < 1 && returnLast, we'll return the last chunk.
-	// Otherwise, the default is to return the full string.
-	if (startChunk < 1 && !returnLast)
+	// startChunk == -30000 means return the last chunk
+	if (startChunk < 1 && startChunk != -30000)
 		return src;
 
 	if (endChunk < 1)
@@ -978,7 +977,7 @@ Datum LC::chunkRef(ChunkType type, int startChunk, int endChunk, const Datum &sr
 		break;
 	}
 
-	if (startChunk < 1) {
+	if (startChunk == -30000) {
 		// return the last chunk we found
 		startChunk = chunkNum;
 		endChunk = chunkNum;
@@ -1002,7 +1001,7 @@ Datum LC::chunkRef(ChunkType type, int startChunk, int endChunk, const Datum &sr
 }
 
 Datum LC::lastChunk(ChunkType type, const Datum &src) {
-	return chunkRef(type, 0, 0, src, true);
+	return chunkRef(type, -30000, 0, src);
 }
 
 Datum LC::readChunkRef(const Datum &src) {
diff --git a/engines/director/lingo/lingo-code.h b/engines/director/lingo/lingo-code.h
index bcedfda681..fc4db978f2 100644
--- a/engines/director/lingo/lingo-code.h
+++ b/engines/director/lingo/lingo-code.h
@@ -56,7 +56,7 @@ void c_starts();
 
 void c_intersects();
 void c_within();
-Datum chunkRef(ChunkType type, int startChunk, int endChunk, const Datum &src, bool returnLast = false);
+Datum chunkRef(ChunkType type, int startChunk, int endChunk, const Datum &src);
 Datum lastChunk(ChunkType type, const Datum &src);
 Datum readChunkRef(const Datum &src);
 void c_of();


Commit: a4330049147f1072175d693faf8cd8f2cd998a28
    https://github.com/scummvm/scummvm/commit/a4330049147f1072175d693faf8cd8f2cd998a28
Author: djsrv (dservilla at gmail.com)
Date: 2021-06-23T16:29:10-04:00

Commit Message:
DIRECTOR: LINGO: Fix chunkRef bounds check

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


diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index d3de9539e5..4b45e2f4c9 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -874,14 +874,11 @@ Datum LC::chunkRef(ChunkType type, int startChunk, int endChunk, const Datum &sr
 	// This function returns a reference to the source text, the start index of the first chunk,
 	// and the end index of the last chunk in the chunk expression.
 
-	if (0 > endChunk && endChunk < startChunk)
-		return src;
-
 	// startChunk == -30000 means return the last chunk
 	if (startChunk < 1 && startChunk != -30000)
 		return src;
 
-	if (endChunk < 1)
+	if (endChunk < 1 || startChunk == -30000)
 		endChunk = startChunk;
 
 	Common::String str = src.eval().asString();


Commit: b423f6e563b364c42a8b703430084e10f3e11f4e
    https://github.com/scummvm/scummvm/commit/b423f6e563b364c42a8b703430084e10f3e11f4e
Author: djsrv (dservilla at gmail.com)
Date: 2021-06-23T16:29:10-04:00

Commit Message:
DIRECTOR: LINGO: Add chunk ref instructions

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


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 078f1c42b8..8656023362 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -262,10 +262,6 @@ static struct BuiltinProto {
 	{ "numberOfItems",	LB::b_numberofitems,1, 1, false, 300, FBLTIN },	//			D3 f
 	{ "numberOfLines",	LB::b_numberoflines,1, 1, false, 300, FBLTIN },	//			D3 f
 	{ "numberOfWords",	LB::b_numberofwords,1, 1, false, 300, FBLTIN },	//			D3 f
-	{ "lastCharOf",		LB::b_lastcharof,	1, 1, false, 400, FBLTIN },	//			D4 f
-	{ "lastItemOf",		LB::b_lastitemof,	1, 1, false, 400, FBLTIN },	//			D4 f
-	{ "lastLineOf",		LB::b_lastlineof,	1, 1, false, 400, FBLTIN },	//			D4 f
-	{ "lastWordOf",		LB::b_lastwordof,	1, 1, false, 400, FBLTIN },	//			D4 f
 
 	// ScummVM Asserts: Used for testing ScummVM's Lingo implementation
 	{ "scummvmAssert",	LB::b_scummvmassert,1, 2, true,  200, HBLTIN },
@@ -2551,30 +2547,6 @@ void LB::b_numberofwords(int nargs) {
 	g_lingo->push(chunkRef.u.cref->startChunk);
 }
 
-void LB::b_lastcharof(int nargs) {
-	Datum d = g_lingo->pop();
-	Datum chunkRef = LC::lastChunk(kChunkChar, d);
-	g_lingo->push(chunkRef.eval());
-}
-
-void LB::b_lastitemof(int nargs) {
-	Datum d = g_lingo->pop();
-	Datum chunkRef = LC::lastChunk(kChunkItem, d);
-	g_lingo->push(chunkRef.eval());
-}
-
-void LB::b_lastlineof(int nargs) {
-	Datum d = g_lingo->pop();
-	Datum chunkRef = LC::lastChunk(kChunkLine, d);
-	g_lingo->push(chunkRef.eval());
-}
-
-void LB::b_lastwordof(int nargs) {
-	Datum d = g_lingo->pop();
-	Datum chunkRef = LC::lastChunk(kChunkWord, d);
-	g_lingo->push(chunkRef.eval());
-}
-
 void LB::b_scummvmassert(int nargs) {
 	Datum line = g_lingo->pop();
 	Datum d = g_lingo->pop();
diff --git a/engines/director/lingo/lingo-builtins.h b/engines/director/lingo/lingo-builtins.h
index 5656e7eaa2..bca1b193d1 100644
--- a/engines/director/lingo/lingo-builtins.h
+++ b/engines/director/lingo/lingo-builtins.h
@@ -194,10 +194,6 @@ void b_numberofchars(int nargs);
 void b_numberofitems(int nargs);
 void b_numberoflines(int nargs);
 void b_numberofwords(int nargs);
-void b_lastcharof(int nargs);
-void b_lastitemof(int nargs);
-void b_lastlineof(int nargs);
-void b_lastwordof(int nargs);
 
 void b_scummvmassert(int nargs);
 void b_scummvmassertequal(int nargs);
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 4b45e2f4c9..557ba3c29e 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -76,7 +76,6 @@ static struct FuncDescr {
 	{ LC::c_assign,			"c_assign",			""  },
 	{ LC::c_callcmd,		"c_callcmd",		"si" },
 	{ LC::c_callfunc,		"c_callfunc",		"si" },
-	{ LC::c_charOf,			"c_charOf",			"" },	// D3
 	{ LC::c_charToOf,		"c_charToOf",		"" },	// D3
 	{ LC::c_concat,			"c_concat",			"" },
 	{ LC::c_constpush,		"c_constpush",		"s" },
@@ -91,12 +90,10 @@ static struct FuncDescr {
 	{ LC::c_hilite,			"c_hilite",			"" },
 	{ LC::c_intersects,		"c_intersects",		"" },
 	{ LC::c_intpush,		"c_intpush",		"i" },
-	{ LC::c_itemOf,			"c_itemOf",			"" },	// D3
 	{ LC::c_itemToOf,		"c_itemToOf",		"" },	// D3
 	{ LC::c_jump,			"c_jump",			"o" },
 	{ LC::c_jumpifz,		"c_jumpifz",		"o" },
 	{ LC::c_le,				"c_le",				"" },
-	{ LC::c_lineOf,			"c_lineOf",			"" },	// D3
 	{ LC::c_lineToOf,		"c_lineToOf",		"" },	// D3
 	{ LC::c_localpush,		"c_localpush",		"s" },
 	{ LC::c_localrefpush,	"c_localrefpush",	"s" },
@@ -133,7 +130,6 @@ static struct FuncDescr {
 	{ LC::c_voidpush,		"c_voidpush",		""  },
 	{ LC::c_whencode,		"c_whencode",		"s" },
 	{ LC::c_within,			"c_within",			"" },
-	{ LC::c_wordOf,			"c_wordOf",			"" },	// D3
 	{ LC::c_wordToOf,		"c_wordToOf",		"" },	// D3
 	{ LC::c_xpop,			"c_xpop",			""  },
 	{ LC::cb_call,			"cb_call",			"N" },
@@ -1029,27 +1025,14 @@ void LC::c_of() {
 	g_lingo->push(ref.eval());
 }
 
-void LC::c_charOf() {
-	Datum src = g_lingo->pop(false);
-	Datum index = g_lingo->pop();
-
-	if ((index.type != INT && index.type != FLOAT) || (src.type != STRING && !src.isRef())) {
-		g_lingo->lingoError("LC::c_charOf(): Called with wrong data types: %s and %s", index.type2str(), src.type2str());
-		g_lingo->push(Datum(""));
-		return;
-	}
-
-	g_lingo->push(LC::chunkRef(kChunkChar, index.asInt(), 0, src));
-}
-
-void LC::c_charToOf() {
+void LC::c_charToOfRef() {
 	Datum src = g_lingo->pop(false);
 	Datum indexTo = g_lingo->pop();
 	Datum indexFrom = g_lingo->pop();
 
 	if ((indexTo.type != INT && indexTo.type != FLOAT) || (indexFrom.type != INT && indexFrom.type != FLOAT)
 			|| (src.type != STRING && !src.isRef())) {
-		warning("LC::c_charToOf(): Called with wrong data types: %s, %s and %s", indexTo.type2str(), indexFrom.type2str(), src.type2str());
+		warning("LC::c_charToOfRef(): Called with wrong data types: %s, %s and %s", indexTo.type2str(), indexFrom.type2str(), src.type2str());
 		g_lingo->push(Datum(""));
 		return;
 	}
@@ -1057,27 +1040,20 @@ void LC::c_charToOf() {
 	g_lingo->push(LC::chunkRef(kChunkChar, indexFrom.asInt(), indexTo.asInt(), src));
 }
 
-void LC::c_itemOf() {
-	Datum src = g_lingo->pop(false);
-	Datum index = g_lingo->pop();
-
-	if ((index.type != INT && index.type != FLOAT) || (src.type != STRING && !src.isRef())) {
-		warning("LC::c_itemOf(): Called with wrong data types: %s and %s", index.type2str(), src.type2str());
-		g_lingo->push(Datum(""));
-		return;
-	}
-
-	g_lingo->push(LC::chunkRef(kChunkItem, index.asInt(), 0, src));
+void LC::c_charToOf() {
+	LC::c_charToOfRef();
+	Datum ref = g_lingo->pop(false);
+	g_lingo->push(ref.eval());
 }
 
-void LC::c_itemToOf() {
+void LC::c_itemToOfRef() {
 	Datum src = g_lingo->pop(false);
 	Datum indexTo = g_lingo->pop();
 	Datum indexFrom = g_lingo->pop();
 
 	if ((indexTo.type != INT && indexTo.type != FLOAT) || (indexFrom.type != INT && indexFrom.type != FLOAT)
 			|| (src.type != STRING && !src.isRef())) {
-		warning("LC::c_itemToOf(): Called with wrong data types: %s, %s and %s", indexTo.type2str(), indexFrom.type2str(), src.type2str());
+		warning("LC::c_itemToOfRef(): Called with wrong data types: %s, %s and %s", indexTo.type2str(), indexFrom.type2str(), src.type2str());
 		g_lingo->push(Datum(""));
 		return;
 	}
@@ -1085,27 +1061,20 @@ void LC::c_itemToOf() {
 	g_lingo->push(LC::chunkRef(kChunkItem, indexFrom.asInt(), indexTo.asInt(), src));
 }
 
-void LC::c_lineOf() {
-	Datum src = g_lingo->pop(false);
-	Datum index = g_lingo->pop();
-
-	if ((index.type != INT && index.type != FLOAT) || (src.type != STRING && !src.isRef())) {
-		warning("LC::c_lineOf(): Called with wrong data types: %s and %s", index.type2str(), src.type2str());
-		g_lingo->push(Datum(""));
-		return;
-	}
-
-	g_lingo->push(LC::chunkRef(kChunkLine, index.asInt(), 0, src));
+void LC::c_itemToOf() {
+	LC::c_itemToOfRef();
+	Datum ref = g_lingo->pop(false);
+	g_lingo->push(ref.eval());
 }
 
-void LC::c_lineToOf() {
+void LC::c_lineToOfRef() {
 	Datum src = g_lingo->pop(false);
 	Datum indexTo = g_lingo->pop();
 	Datum indexFrom = g_lingo->pop();
 
 	if ((indexTo.type != INT && indexTo.type != FLOAT) || (indexFrom.type != INT && indexFrom.type != FLOAT)
 			|| (src.type != STRING && !src.isRef())) {
-		warning("LC::c_lineToOf(): Called with wrong data types: %s, %s and %s", indexTo.type2str(), indexFrom.type2str(), src.type2str());
+		warning("LC::c_lineToOfRef(): Called with wrong data types: %s, %s and %s", indexTo.type2str(), indexFrom.type2str(), src.type2str());
 		g_lingo->push(Datum(""));
 		return;
 	}
@@ -1113,27 +1082,20 @@ void LC::c_lineToOf() {
 	g_lingo->push(LC::chunkRef(kChunkLine, indexFrom.asInt(), indexTo.asInt(), src));
 }
 
-void LC::c_wordOf() {
-	Datum src = g_lingo->pop(false);
-	Datum index = g_lingo->pop();
-
-	if ((index.type != INT && index.type != FLOAT) || (src.type != STRING && !src.isRef())) {
-		warning("LC::c_wordOf(): Called with wrong data types: %s and %s", index.type2str(), src.type2str());
-		g_lingo->push(Datum(""));
-		return;
-	}
-
-	g_lingo->push(LC::chunkRef(kChunkWord, index.asInt(), 0, src));
+void LC::c_lineToOf() {
+	LC::c_lineToOfRef();
+	Datum ref = g_lingo->pop(false);
+	g_lingo->push(ref.eval());
 }
 
-void LC::c_wordToOf() {
+void LC::c_wordToOfRef() {
 	Datum src = g_lingo->pop(false);
 	Datum indexTo = g_lingo->pop();
 	Datum indexFrom = g_lingo->pop();
 
 	if ((indexTo.type != INT && indexTo.type != FLOAT) || (indexFrom.type != INT && indexFrom.type != FLOAT)
 			|| (src.type != STRING && !src.isRef())) {
-		warning("LC::c_wordToOf(): Called with wrong data types: %s, %s and %s", indexTo.type2str(), indexFrom.type2str(), src.type2str());
+		warning("LC::c_wordToOfRef(): Called with wrong data types: %s, %s and %s", indexTo.type2str(), indexFrom.type2str(), src.type2str());
 		g_lingo->push(Datum(""));
 		return;
 	}
@@ -1141,6 +1103,12 @@ void LC::c_wordToOf() {
 	g_lingo->push(LC::chunkRef(kChunkWord, indexFrom.asInt(), indexTo.asInt(), src));
 }
 
+void LC::c_wordToOf() {
+	LC::c_wordToOfRef();
+	Datum ref = g_lingo->pop(false);
+	g_lingo->push(ref.eval());
+}
+
 void LC::c_and() {
 	Datum d2 = g_lingo->pop();
 	Datum d1 = g_lingo->pop();
diff --git a/engines/director/lingo/lingo-code.h b/engines/director/lingo/lingo-code.h
index fc4db978f2..b2b7ce49b8 100644
--- a/engines/director/lingo/lingo-code.h
+++ b/engines/director/lingo/lingo-code.h
@@ -60,13 +60,13 @@ Datum chunkRef(ChunkType type, int startChunk, int endChunk, const Datum &src);
 Datum lastChunk(ChunkType type, const Datum &src);
 Datum readChunkRef(const Datum &src);
 void c_of();
-void c_charOf();
+void c_charToOfRef();
 void c_charToOf();
-void c_itemOf();
+void c_itemToOfRef();
 void c_itemToOf();
-void c_lineOf();
+void c_lineToOfRef();
 void c_lineToOf();
-void c_wordOf();
+void c_wordToOfRef();
 void c_wordToOf();
 
 void c_constpush();
diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp
index 76cacfd767..fc203582f6 100644
--- a/engines/director/lingo/lingo-codegen.cpp
+++ b/engines/director/lingo/lingo-codegen.cpp
@@ -1283,19 +1283,39 @@ bool LingoCompiler::visitTheNumberOfNode(TheNumberOfNode *node) {
 /* TheLastNode */
 
 bool LingoCompiler::visitTheLastNode(TheLastNode *node) {
+	code1(LC::c_intpush);
+	codeInt(-30000);
+	code1(LC::c_intpush);
+	codeInt(0);
 	COMPILE(node->arg);
 	switch (node->type) {
 	case kChunkChar:
-		codeFunc("lastCharOf", 1);
+		if (_refMode) {
+			code1(LC::c_charToOfRef);
+		} else {
+			code1(LC::c_charToOf);
+		}
 		break;
 	case kChunkWord:
-		codeFunc("lastWordOf", 1);
+		if (_refMode) {
+			code1(LC::c_wordToOfRef);
+		} else {
+			code1(LC::c_wordToOf);
+		}
 		break;
 	case kChunkItem:
-		codeFunc("lastItemOf", 1);
+		if (_refMode) {
+			code1(LC::c_itemToOfRef);
+		} else {
+			code1(LC::c_itemToOf);
+		}
 		break;
 	case kChunkLine:
-		codeFunc("lastLineOf", 1);
+		if (_refMode) {
+			code1(LC::c_lineToOfRef);
+		} else {
+			code1(LC::c_lineToOf);
+		}
 		break;
 	}
 	return true;
@@ -1342,35 +1362,38 @@ bool LingoCompiler::visitChunkExprNode(ChunkExprNode *node) {
 	COMPILE(node->start);
 	if (node->end) {
 		COMPILE(node->end);
+	} else {
+		code1(LC::c_intpush);
+		codeInt(0);
 	}
 	COMPILE(node->src);
 	switch (node->type) {
 	case kChunkChar:
-		if (node->end) {
-			code1(LC::c_charToOf);
+		if (_refMode) {
+			code1(LC::c_charToOfRef);
 		} else {
-			code1(LC::c_charOf);
+			code1(LC::c_charToOf);
 		}
 		break;
 	case kChunkWord:
-		if (node->end) {
-			code1(LC::c_wordToOf);
+		if (_refMode) {
+			code1(LC::c_wordToOfRef);
 		} else {
-			code1(LC::c_wordOf);
+			code1(LC::c_wordToOf);
 		}
 		break;
 	case kChunkItem:
-		if (node->end) {
-			code1(LC::c_itemToOf);
+		if (_refMode) {
+			code1(LC::c_itemToOfRef);
 		} else {
-			code1(LC::c_itemOf);
+			code1(LC::c_itemToOf);
 		}
 		break;
 	case kChunkLine:
-		if (node->end) {
-			code1(LC::c_lineToOf);
+		if (_refMode) {
+			code1(LC::c_lineToOfRef);
 		} else {
-			code1(LC::c_lineOf);
+			code1(LC::c_lineToOf);
 		}
 		break;
 	}


Commit: 2fabaedac8fa917c71a1573ce127b406720300b7
    https://github.com/scummvm/scummvm/commit/2fabaedac8fa917c71a1573ce127b406720300b7
Author: djsrv (dservilla at gmail.com)
Date: 2021-06-23T16:29:10-04:00

Commit Message:
DIRECTOR: LINGO: Improve tests for "the last"

Changed paths:
    engines/director/lingo/tests/chunks.lingo


diff --git a/engines/director/lingo/tests/chunks.lingo b/engines/director/lingo/tests/chunks.lingo
index 8f51ad70ec..e9a2f4101f 100644
--- a/engines/director/lingo/tests/chunks.lingo
+++ b/engines/director/lingo/tests/chunks.lingo
@@ -2,9 +2,11 @@
 
 -- put the last word of field 1 into field 3
 
-put the last char of "Macromedia, the multimedia company"
-put the last word of "Macromedia, the multimedia company"
-put the last word of "Macromedia, the multimedia company" && "man"
+scummvmAssertEqual(the last char of "Macromedia, the multimedia company", "y")
+scummvmAssertEqual(the last word of "Macromedia, the multimedia company", "company")
+scummvmAssertEqual(the last word of "Macromedia, the multimedia company" && "man", "company man")
+scummvmAssertEqual(word -30000 of "Macromedia, the multimedia company", "company")
+scummvmAssertEqual(word -30000 of "Macromedia, the multimedia company" && "man", "company man")
 
 set src = "abcdefghijklmnopqrstuvwxyz"
 scummvmAssertEqual(char 2 of src, "b")


Commit: 7a32cb300f0c112974792754343e6d089887a2a7
    https://github.com/scummvm/scummvm/commit/7a32cb300f0c112974792754343e6d089887a2a7
Author: djsrv (dservilla at gmail.com)
Date: 2021-06-23T16:29:10-04:00

Commit Message:
DIRECTOR: LINGO: Add "delete the last" tests

Changed paths:
    engines/director/lingo/tests/delete.lingo


diff --git a/engines/director/lingo/tests/delete.lingo b/engines/director/lingo/tests/delete.lingo
index 62689daf9d..c400a0ed4d 100644
--- a/engines/director/lingo/tests/delete.lingo
+++ b/engines/director/lingo/tests/delete.lingo
@@ -14,6 +14,10 @@ put "qwertyuiop" into test
 delete char 0 of test
 scummvmAssertEqual(test, "")
 
+put "qwertyuiop" into test
+delete the last char of test
+scummvmAssertEqual(test, "qwertyuio")
+
 put "lorem  ipsum    dolor" into test
 delete word 2 of test
 scummvmAssertEqual(test, "lorem  dolor")
@@ -26,6 +30,10 @@ put "lorem  ipsum    dolor" into test
 delete word 2 to 1000 of test
 scummvmAssertEqual(test, "lorem  ")
 
+put "lorem  ipsum    dolor" into test
+delete the last word of test
+scummvmAssertEqual(test, "lorem  ipsum    ")
+
 put "lorem,ipsum,dolor,sit,amet" into test
 delete item 3 of test
 scummvmAssertEqual(test, "lorem,ipsum,sit,amet")
@@ -34,6 +42,10 @@ put "lorem,ipsum,dolor,sit,amet" into test
 delete item 2 to 5 of test
 scummvmAssertEqual(test, "lorem")
 
+put "lorem,ipsum,dolor,sit,amet" into test
+delete the last item of test
+scummvmAssertEqual(test, "lorem,ipsum,dolor,sit")
+
 put "lorem" & RETURN & "ipsum" & RETURN & "dolor" & RETURN & "sit" & RETURN & "amet" into test
 delete line 3 of test
 scummvmAssertEqual(test, "lorem" & RETURN & "ipsum" & RETURN & "sit" & RETURN & "amet")
@@ -41,3 +53,7 @@ scummvmAssertEqual(test, "lorem" & RETURN & "ipsum" & RETURN & "sit" & RETURN &
 put "lorem" & RETURN & "ipsum" & RETURN & "dolor" & RETURN & "sit" & RETURN & "amet" into test
 delete line 2 to 5 of test
 scummvmAssertEqual(test, "lorem")
+
+put "lorem" & RETURN & "ipsum" & RETURN & "dolor" & RETURN & "sit" & RETURN & "amet" into test
+delete the last line of test
+scummvmAssertEqual(test, "lorem" & RETURN & "ipsum" & RETURN & "dolor" & RETURN & "sit")


Commit: c13088a829574d02888248648f52082ce09598f5
    https://github.com/scummvm/scummvm/commit/c13088a829574d02888248648f52082ce09598f5
Author: djsrv (dservilla at gmail.com)
Date: 2021-06-23T16:29:10-04:00

Commit Message:
DIRECTOR: LINGO: Load intpush's arg as signed

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


diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index e28c72fded..3bf74841c5 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -71,7 +71,7 @@ static LingoV4Bytecode lingoV4[] = {
 	{ 0x1d, LC::c_telldone,		"" },
 	{ 0x1e, LC::cb_list,		"" },
 	{ 0x1f, LC::cb_proplist,	"" },
-	{ 0x41, LC::c_intpush,		"b" },
+	{ 0x41, LC::c_intpush,		"B" },
 	{ 0x42, LC::c_argcnoretpush,"b" },
 	{ 0x43, LC::c_argcpush,		"b" },
 	// 0x44, push a constant
@@ -106,7 +106,7 @@ static LingoV4Bytecode lingoV4[] = {
 	{ 0x64, LC::c_stackpeek, 	"b" },
 	{ 0x65, LC::c_stackdrop, 	"b" },
 	{ 0x66, LC::cb_v4theentitynamepush, "b" },
-	{ 0x81, LC::c_intpush,		"w" },
+	{ 0x81, LC::c_intpush,		"W" },
 	{ 0x82, LC::c_argcnoretpush,"w" },
 	{ 0x83, LC::c_argcpush,		"w" },
 	// 0x84, push a constant
@@ -1320,6 +1320,12 @@ ScriptContext *LingoCompiler::compileLingoV4(Common::SeekableReadStreamEndian &s
 							arg = (uint8)codeStore[pointer];
 							pointer += 1;
 							break;
+						case 'B':
+							// read one int8 as an argument
+							offsetList.push_back(_currentAssembly->size());
+							arg = (int8)codeStore[pointer];
+							pointer += 1;
+							break;
 						case 'w':
 							// read one uint16 as an argument
 							offsetList.push_back(_currentAssembly->size());
@@ -1327,6 +1333,13 @@ ScriptContext *LingoCompiler::compileLingoV4(Common::SeekableReadStreamEndian &s
 							arg = (uint16)READ_BE_UINT16(&codeStore[pointer]);
 							pointer += 2;
 							break;
+						case 'W':
+							// read one int16 as an argument
+							offsetList.push_back(_currentAssembly->size());
+							offsetList.push_back(_currentAssembly->size());
+							arg = (int16)READ_BE_INT16(&codeStore[pointer]);
+							pointer += 2;
+							break;
 						case 'n':
 							// argument is negative
 							arg *= -1;


Commit: 0a2688268bd74783a12502aeff14f6b4e02705ca
    https://github.com/scummvm/scummvm/commit/0a2688268bd74783a12502aeff14f6b4e02705ca
Author: djsrv (dservilla at gmail.com)
Date: 2021-06-23T16:29:10-04:00

Commit Message:
DIRECTOR: LINGO: Fix negative bytecode chunk refs

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


diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 557ba3c29e..711a007c5a 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -1007,13 +1007,13 @@ Datum LC::readChunkRef(const Datum &src) {
 	Datum lastChar = g_lingo->pop();
 	Datum firstChar = g_lingo->pop();
 
-	if (firstChar.asInt() > 0)
+	if (firstChar.asInt() != 0)
 		return LC::chunkRef(kChunkChar, firstChar.asInt(), lastChar.asInt(), src);
-	if (firstWord.asInt() > 0)
+	if (firstWord.asInt() != 0)
 		return LC::chunkRef(kChunkWord, firstWord.asInt(), lastWord.asInt(), src);
-	if (firstItem.asInt() > 0)
+	if (firstItem.asInt() != 0)
 		return LC::chunkRef(kChunkItem, firstItem.asInt(), lastItem.asInt(), src);
-	if (lastLine.asInt() > 0)
+	if (firstLine.asInt() != 0)
 		return LC::chunkRef(kChunkLine, firstLine.asInt(), lastLine.asInt(), src);
 
 	return src;




More information about the Scummvm-git-logs mailing list