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

djsrv dservilla at gmail.com
Tue Jun 29 00:00:39 UTC 2021


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:
21988c77bf DIRECTOR: LINGO: Fix warnings
22f9d6e589 DIRECTOR: LINGO: Implement chunk ref properties
e072cd925f DIRECTOR: LINGO: Add v4 'the' mappings for chunk refs
eaf98c693f DIRECTOR: LINGO: Add test for compiling chunk ref property


Commit: 21988c77bfddd9be5ea38a670248e0a9a049171c
    https://github.com/scummvm/scummvm/commit/21988c77bfddd9be5ea38a670248e0a9a049171c
Author: djsrv (dservilla at gmail.com)
Date: 2021-06-28T19:59:53-04:00

Commit Message:
DIRECTOR: LINGO: Fix warnings

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 01e0dbd387..08b48b81fa 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -1588,7 +1588,7 @@ void LC::c_delete() {
 			field = field.u.cref->source;
 		}
 		if (!field.isVarRef() && !field.isCastRef()) {
-			warning("BUILDBOT: c_delete: bad chunk ref field type: %s", d.u.cref->source.type2str());
+			warning("BUILDBOT: c_delete: bad chunk ref field type: %s", field.type2str());
 			return;
 		}
 	} else if (d.isRef()) {
@@ -1644,7 +1644,7 @@ void LC::c_hilite() {
 		if (src.isCastRef()) {
 			fieldId = src.u.i;
 		} else {
-			warning("BUILDBOT: c_hilite: bad chunk ref field type: %s", d.u.cref->source.type2str());
+			warning("BUILDBOT: c_hilite: bad chunk ref field type: %s", src.type2str());
 			return;
 		}
 	} else if (d.isCastRef()) {


Commit: 22f9d6e589e2830f9901444b202203956ee746a5
    https://github.com/scummvm/scummvm/commit/22f9d6e589e2830f9901444b202203956ee746a5
Author: djsrv (dservilla at gmail.com)
Date: 2021-06-28T19:59:53-04:00

Commit Message:
DIRECTOR: LINGO: Implement chunk ref properties

Changed paths:
    engines/director/castmember.h
    engines/director/lingo/lingo-codegen.cpp
    engines/director/lingo/lingo-object.cpp
    engines/director/lingo/lingo-the.cpp
    engines/director/lingo/lingo-the.h
    engines/director/lingo/lingo.h


diff --git a/engines/director/castmember.h b/engines/director/castmember.h
index e29f72240e..6bbb3fa8da 100644
--- a/engines/director/castmember.h
+++ b/engines/director/castmember.h
@@ -233,6 +233,10 @@ public:
 	Datum getField(int field) override;
 	bool setField(int field, const Datum &value) override;
 
+	bool hasChunkField(int field);
+	Datum getChunkField(int field, int start, int end);
+	bool setChunkField(int field, int start, int end, const Datum &value);
+
 	SizeType _borderSize;
 	SizeType _gutterSize;
 	SizeType _boxShadow;
diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp
index b2a9284e59..e598b8ea07 100644
--- a/engines/director/lingo/lingo-codegen.cpp
+++ b/engines/director/lingo/lingo-codegen.cpp
@@ -616,6 +616,20 @@ bool LingoCompiler::visitSetNode(SetNode *node) {
 	if (node->var->type == kTheOfNode) {
 		TheOfNode *the = static_cast<TheOfNode *>(node->var);
 		switch (the->obj->type) {
+		case kChunkExprNode:
+			{
+				int fieldId = getTheFieldID(kTheChunk, *the->prop, true);
+				if (fieldId >= 0) {
+					COMPILE(node->val);
+					COMPILE_REF(the->obj);
+					code1(LC::c_theentityassign);
+					codeInt(kTheChunk);
+					codeInt(fieldId);
+					return true;
+				}
+				// fall back to generic object
+			}
+			break;
 		case kFuncNode:
 			{
 				FuncNode *func = static_cast<FuncNode *>(the->obj);
@@ -1206,6 +1220,19 @@ bool LingoCompiler::visitTheNode(TheNode *node) {
 
 bool LingoCompiler::visitTheOfNode(TheOfNode *node) {
 	switch (node->obj->type) {
+	case kChunkExprNode:
+		{
+			int fieldId = getTheFieldID(kTheChunk, *node->prop, true);
+			if (fieldId >= 0) {
+				COMPILE_REF(node->obj);
+				code1(LC::c_theentitypush);
+				codeInt(kTheChunk);
+				codeInt(fieldId);
+				return true;
+			}
+			// fall back to generic object
+		}
+		break;
 	case kFuncNode:
 		{
 			FuncNode *func = static_cast<FuncNode *>(node->obj);
diff --git a/engines/director/lingo/lingo-object.cpp b/engines/director/lingo/lingo-object.cpp
index 875f52816f..532b0a5883 100644
--- a/engines/director/lingo/lingo-object.cpp
+++ b/engines/director/lingo/lingo-object.cpp
@@ -979,4 +979,68 @@ bool TextCastMember::setField(int field, const Datum &d) {
 	return CastMember::setField(field, d);
 }
 
+bool TextCastMember::hasChunkField(int field) {
+	switch (field) {
+	case kTheForeColor:
+	case kTheTextFont:
+	case kTheTextHeight:
+	case kTheTextSize:
+	case kTheTextStyle:
+		return true;
+	default:
+		break;
+	}
+	return false;
+}
+
+Datum TextCastMember::getChunkField(int field, int start, int end) {
+	Datum d;
+
+	switch (field) {
+	case kTheForeColor:
+		warning("TextCastMember::getChunkField(): Unprocessed getting field \"%s\" of field %d", g_lingo->field2str(field), _castId);
+		break;
+	case kTheTextFont:
+		warning("TextCastMember::getChunkField(): Unprocessed getting field \"%s\" of field %d", g_lingo->field2str(field), _castId);
+		break;
+	case kTheTextHeight:
+		warning("TextCastMember::getChunkField(): Unprocessed getting field \"%s\" of field %d", g_lingo->field2str(field), _castId);
+		break;
+	case kTheTextSize:
+		warning("TextCastMember::getChunkField(): Unprocessed getting field \"%s\" of field %d", g_lingo->field2str(field), _castId);
+		break;
+	case kTheTextStyle:
+		warning("TextCastMember::getChunkField(): Unprocessed getting field \"%s\" of field %d", g_lingo->field2str(field), _castId);
+		break;
+	default:
+		break;
+	}
+
+	return d;
+}
+
+bool TextCastMember::setChunkField(int field, int start, int end, const Datum &d) {
+	switch (field) {
+	case kTheForeColor:
+		warning("TextCastMember::setChunkField(): Unprocessed setting field \"%s\" of field %d", g_lingo->field2str(field), _castId);
+		return false;
+	case kTheTextFont:
+		warning("TextCastMember::setChunkField(): Unprocessed setting field \"%s\" of field %d", g_lingo->field2str(field), _castId);
+		return false;
+	case kTheTextHeight:
+		warning("TextCastMember::setChunkField(): Unprocessed setting field \"%s\" of field %d", g_lingo->field2str(field), _castId);
+		return false;
+	case kTheTextSize:
+		warning("TextCastMember::setChunkField(): Unprocessed setting field \"%s\" of field %d", g_lingo->field2str(field), _castId);
+		return false;
+	case kTheTextStyle:
+		warning("TextCastMember::setChunkField(): Unprocessed setting field \"%s\" of field %d", g_lingo->field2str(field), _castId);
+		return false;
+	default:
+		break;
+	}
+
+	return false;
+}
+
 } // End of namespace Director
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index 839a4f658f..d0cb4af99a 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -50,6 +50,7 @@ TheEntity entities[] = {
 	{ kTheCenterStage,		"centerStage",		false, 200, false },	// D2 p
 	{ kTheCheckBoxAccess,	"checkBoxAccess",	false, 200, false },	// D2 p
 	{ kTheCheckBoxType,		"checkBoxType",		false, 200, false },	// D2 p
+	{ kTheChunk,			"chunk",			true,  300, false },	//		D3
 	{ kTheClickLoc,			"clickLoc",			false, 400, true },	// 			D4 function
 	{ kTheClickOn,			"clickOn",			false, 200, true },	// D2 f
 	{ kTheColorDepth,		"colorDepth",		false, 200, false },	// D2 p
@@ -248,6 +249,13 @@ TheEntityField fields[] = {
 	{ kTheField,	"textSize",		kTheTextSize,	300 },//		D3 p
 	{ kTheField,	"textStyle",	kTheTextStyle,	300 },//		D3 p
 
+	// Chunk fields
+	{ kTheChunk,	"foreColor",	kTheForeColor,	400 },//				D4 p
+	{ kTheChunk,	"textFont",		kTheTextFont,	300 },//		D3 p
+	{ kTheChunk,	"textHeight",	kTheTextHeight,	300 },//		D3 p
+	{ kTheChunk,	"textSize",		kTheTextSize,	300 },//		D3 p
+	{ kTheChunk,	"textStyle",	kTheTextStyle,	300 },//		D3 p
+
 	{ kTheWindow,	"drawRect",		kTheDrawRect,	400 },//				D4 p
 	{ kTheWindow,	"fileName",		kTheFileName,	400 },//				D4 p
 	{ kTheWindow,	"modal",		kTheModal,		400 },//				D4 p
@@ -391,6 +399,9 @@ Datum Lingo::getTheEntity(int entity, Datum &id, int field) {
 		d.type = INT;
 		d.u.i = g_director->getCurrentMovie()->_checkBoxType;
 		break;
+	case kTheChunk:
+		d = getTheChunk(id, field);
+		break;
 	case kTheClickLoc:
 		d.u.farr = new DatumArray;
 
@@ -887,6 +898,9 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
 	case kTheCheckBoxType:
 		g_director->getCurrentMovie()->_checkBoxType = d.asInt();
 		break;
+	case kTheChunk:
+		setTheChunk(id, field, d);
+		break;
 	case kTheColorDepth:
 		_vm->_colorDepth = d.asInt();
 
@@ -1597,6 +1611,98 @@ void Lingo::setTheField(Datum &id1, int field, Datum &d) {
 	member->setField(field, d);
 }
 
+Datum Lingo::getTheChunk(Datum &chunk, int field) {
+	Datum d;
+
+	Movie *movie = _vm->getCurrentMovie();
+	if (!movie) {
+		warning("Lingo::getTheChunk(): No movie loaded");
+		return d;
+	}
+
+	if (chunk.type != CHUNKREF) {
+		warning("BUILDBOT: Lingo::getTheChunk(): bad chunk ref type: %s", chunk.type2str());
+		return d;
+	}
+
+	int start, end;
+	start = chunk.u.cref->start;
+	end = chunk.u.cref->end;
+	Datum src = chunk.u.cref->source;
+	while (src.type == CHUNKREF) {
+		start += src.u.cref->start;
+		end += src.u.cref->start;
+		src = src.u.cref->source;
+	}
+	if (!src.isCastRef()) {
+		warning("BUILDBOT: Lingo::getTheChunk(): bad chunk ref field type: %s", src.type2str());
+		return d;
+	}
+
+	CastMember *member = movie->getCastMember(src.u.i);
+	if (!member) {
+		g_lingo->lingoError("Lingo::getTheChunk(): CastMember %d not found", src.u.i);
+		return d;
+	}
+	if (member->_type != kCastText) {
+		g_lingo->lingoError("Lingo::getTheChunk(): CastMember %d is not a field", src.u.i);
+		return d;
+	}
+
+	if (!((TextCastMember *)member)->hasChunkField(field)) {
+		warning("Lingo::getTheChunk(): CastMember %d has no chunk property '%s'", src.u.i, field2str(field));
+		return d;
+	}
+
+	d = ((TextCastMember *)member)->getChunkField(field, start, end);
+
+	return d;
+}
+
+void Lingo::setTheChunk(Datum &chunk, int field, Datum &d) {
+	Movie *movie = _vm->getCurrentMovie();
+	if (!movie) {
+		warning("Lingo::setTheChunk(): No movie loaded");
+		return;
+	}
+
+	if (chunk.type != CHUNKREF) {
+		warning("BUILDBOT: Lingo::setTheChunk(): bad chunk ref type: %s", chunk.type2str());
+		return;
+	}
+
+	int start, end;
+	start = chunk.u.cref->start;
+	end = chunk.u.cref->end;
+	Datum src = chunk.u.cref->source;
+	while (src.type == CHUNKREF) {
+		start += src.u.cref->start;
+		end += src.u.cref->start;
+		src = src.u.cref->source;
+	}
+	if (!src.isCastRef()) {
+		warning("BUILDBOT: Lingo::setTheChunk(): bad chunk ref field type: %s", src.type2str());
+		return;
+	}
+
+	CastMember *member = movie->getCastMember(src.u.i);
+	if (!member) {
+		g_lingo->lingoError("Lingo::setTheChunk(): CastMember %d not found", src.u.i);
+		return;
+	}
+	if (member->_type != kCastText) {
+		g_lingo->lingoError("Lingo::setTheChunk(): CastMember %d is not a field", src.u.i);
+		return;
+	}
+
+	if (!((TextCastMember *)member)->hasChunkField(field)) {
+		warning("Lingo::setTheChunk(): CastMember %d has no chunk property '%s'", src.u.i, field2str(field));
+		return;
+	}
+
+	((TextCastMember *)member)->setChunkField(field, start, end, d);
+}
+
 void Lingo::getObjectProp(Datum &obj, Common::String &propName) {
 	Datum d;
 	if (obj.type == OBJECT) {
diff --git a/engines/director/lingo/lingo-the.h b/engines/director/lingo/lingo-the.h
index 89b86e2819..f7127fab7a 100644
--- a/engines/director/lingo/lingo-the.h
+++ b/engines/director/lingo/lingo-the.h
@@ -37,6 +37,7 @@ enum TheEntityType {
 	kTheChars,
 	kTheCheckBoxAccess,
 	kTheCheckBoxType,
+	kTheChunk,
 	kTheClickLoc,
 	kTheClickOn,
 	kTheColorDepth,
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index c6fb17b885..01c1f203d8 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -336,6 +336,8 @@ public:
 	void setTheCast(Datum &id, int field, Datum &d);
 	Datum getTheField(Datum &id1, int field);
 	void setTheField(Datum &id1, int field, Datum &d);
+	Datum getTheChunk(Datum &chunk, int field);
+	void setTheChunk(Datum &chunk, int field, Datum &d);
 	void getObjectProp(Datum &obj, Common::String &propName);
 	void setObjectProp(Datum &obj, Common::String &propName, Datum &d);
 	Datum getTheDate(int field);


Commit: e072cd925f67ad77f8f6e5d6079daa7ffd8e6006
    https://github.com/scummvm/scummvm/commit/e072cd925f67ad77f8f6e5d6079daa7ffd8e6006
Author: djsrv (dservilla at gmail.com)
Date: 2021-06-28T19:59:53-04:00

Commit Message:
DIRECTOR: LINGO: Add v4 'the' mappings for chunk refs

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


diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index 0dc9a9c0c4..c94247df5c 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -257,6 +257,13 @@ static LingoV4TheEntity lingoV4TheEntity[] = {
 	{ 0x09, 0x11, kTheCast,				kTheForeColor,		true, kTEAItemId },
 	{ 0x09, 0x12, kTheCast,				kTheBackColor,		true, kTEAItemId },
 
+	// the chunk of cast
+	{ 0x0a, 0x03, kTheChunk,			kTheTextStyle,		true, kTEAChunk },
+	{ 0x0a, 0x04, kTheChunk,			kTheTextFont,		true, kTEAChunk },
+	{ 0x0a, 0x05, kTheChunk,			kTheTextHeight,		true, kTEAChunk },
+	{ 0x0a, 0x07, kTheChunk,			kTheTextSize,		true, kTEAChunk },
+	{ 0x0a, 0x11, kTheChunk,			kTheForeColor,		true, kTEAChunk },
+
 	{ 0x0b, 0x01, kTheField,			kTheName,			true, kTEAItemId },
 	{ 0x0b, 0x02, kTheField,			kTheText,			true, kTEAItemId },
 	{ 0x0b, 0x03, kTheField,			kTheTextStyle,		true, kTEAItemId },
@@ -267,6 +274,13 @@ static LingoV4TheEntity lingoV4TheEntity[] = {
 	{ 0x0b, 0x09, kTheField,			kTheHilite,			true, kTEAItemId },
 	{ 0x0b, 0x11, kTheField,			kTheForeColor,		true, kTEAItemId },
 
+	// the chunk of field
+	{ 0x0c, 0x03, kTheChunk,			kTheTextStyle,		true, kTEAChunk },
+	{ 0x0c, 0x04, kTheChunk,			kTheTextFont,		true, kTEAChunk },
+	{ 0x0c, 0x05, kTheChunk,			kTheTextHeight,		true, kTEAChunk },
+	{ 0x0c, 0x07, kTheChunk,			kTheTextSize,		true, kTEAChunk },
+	{ 0x0c, 0x11, kTheChunk,			kTheForeColor,		true, kTEAChunk },
+
 	{ 0x0d, 0x0c, kTheCast,				kTheLoop,			true, kTEAItemId },
 	{ 0x0d, 0x0d, kTheCast,				kTheDuration,		true, kTEAItemId },
 	{ 0x0d, 0x0e, kTheCast,				kTheController,		true, kTEAItemId },
@@ -740,6 +754,14 @@ void LC::cb_v4theentitypush() {
 				warning("cb_v4theentitypush: STUB: kTEAMenuIdItemId");
 			}
 			break;
+		case kTEAChunk:
+			{
+				Datum fieldRef = g_lingo->pop().asCastId();
+				fieldRef.type = FIELDREF;
+				Datum chunkRef = readChunkRef(fieldRef);
+				result = g_lingo->getTheEntity(entity, chunkRef, field);
+			}
+			break;
 		default:
 			warning("cb_v4theentitypush: unknown call type %d", g_lingo->_lingoV4TheEntity[key]->type);
 			break;
@@ -838,6 +860,14 @@ void LC::cb_v4theentityassign() {
 			warning("cb_v4theentityassign: STUB: kTEAMenuIdItemId");
 		}
 		break;
+	case kTEAChunk:
+		{
+			Datum fieldRef = g_lingo->pop().asCastId();
+			fieldRef.type = FIELDREF;
+			Datum chunkRef = readChunkRef(fieldRef);
+			g_lingo->setTheEntity(entity, chunkRef, field, value);
+		}
+		break;
 	default:
 		warning("cb_v4theentityassign: unknown call type %d", g_lingo->_lingoV4TheEntity[key]->type);
 		break;
diff --git a/engines/director/lingo/lingo-bytecode.h b/engines/director/lingo/lingo-bytecode.h
index 1f21f215d7..dafce2d69c 100644
--- a/engines/director/lingo/lingo-bytecode.h
+++ b/engines/director/lingo/lingo-bytecode.h
@@ -37,7 +37,8 @@ enum TheEntityArgsType {
 	kTEANOArgs = 0,
 	kTEAItemId = 1,
 	kTEAString,
-	kTEAMenuIdItemId
+	kTEAMenuIdItemId,
+	kTEAChunk
 };
 
 struct LingoV4TheEntity {


Commit: eaf98c693f4938cc3908a3313a5ddbcfa9b096b9
    https://github.com/scummvm/scummvm/commit/eaf98c693f4938cc3908a3313a5ddbcfa9b096b9
Author: djsrv (dservilla at gmail.com)
Date: 2021-06-28T19:59:53-04:00

Commit Message:
DIRECTOR: LINGO: Add test for compiling chunk ref property

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 e9a2f4101f..efcb46b4c8 100644
--- a/engines/director/lingo/tests/chunks.lingo
+++ b/engines/director/lingo/tests/chunks.lingo
@@ -39,3 +39,7 @@ scummvmAssertEqual(char 2 to 0 of field 1, "b")
 scummvmAssertEqual(char 2 to 4 of field 1, "bcd")
 scummvmAssertEqual(char 2 to 1000 of field 1, "bcdefghijklmnopqrstuvwxyz")
 scummvmAssertEqual(word 1000 of field 1, "")
+
+put "lorem ipsum dolor sit amet" into field 1
+set the foreColor of word 2 of field 1 to 10
+put the foreColor of word 2 of field 1




More information about the Scummvm-git-logs mailing list