[Scummvm-git-logs] scummvm master -> 6db398a74d4deb9b0a8f81bdf2ae96bb79b628d3
djsrv
dservilla at gmail.com
Wed Aug 19 22:56:36 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
6fe741d2af DIRECTOR: LINGO: Implement findVarV4
6db398a74d DIRECTOR: LINGO: Use findVarV4 in cb_v4assign
Commit: 6fe741d2af8bf8b7d1dca1a49772242d3919cce0
https://github.com/scummvm/scummvm/commit/6fe741d2af8bf8b7d1dca1a49772242d3919cce0
Author: djsrv (dservilla at gmail.com)
Date: 2020-08-19T18:55:34-04:00
Commit Message:
DIRECTOR: LINGO: Implement findVarV4
Changed paths:
engines/director/lingo/lingo-bytecode.cpp
engines/director/lingo/lingo.h
diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index 97a09941ad..edb25f5408 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -306,6 +306,53 @@ void Lingo::initBytecode() {
}
}
+Datum Lingo::findVarV4(int varType, const Datum &id) {
+ Datum res;
+ switch (varType) {
+ case 1: // global
+ case 2: // global
+ case 3: // property/instance
+ if (id.type == VAR) {
+ res = id;
+ } else {
+ warning("BUILDBOT: findVarV4: expected ID for var type %d to be VAR, got %s", varType, id.type2str());
+ }
+ break;
+ case 4: // arg
+ case 5: // local
+ {
+ if (g_lingo->_callstack.empty()) {
+ warning("BUILDBOT: findVarV4: no call frame");
+ return res;
+ }
+ if (id.asInt() % 6 != 0) {
+ warning("BUILDBOT: findVarV4: invalid var ID %d for var type %d (not divisible by 6)", id.asInt(), varType);
+ return res;
+ }
+ int varIndex = id.asInt() / 6;
+ Common::Array<Common::String> *varNames = (varType == 4)
+ ? _callstack.back()->sp.argNames
+ : _callstack.back()->sp.varNames;
+
+ if (varIndex < (int)varNames->size()) {
+ res = (*varNames)[varIndex];
+ res.type = VAR;
+ } else {
+ warning("BUILDBOT: findVarV4: invalid var ID %d for var type %d (too high)", id.asInt(), varType);
+ }
+ }
+ break;
+ case 6: // field
+ res = id.asCastId();
+ res.type = FIELDREF;
+ break;
+ default:
+ warning("BUILDBOT: findVarV4: unhandled var type %d", varType);
+ break;
+ }
+ return res;
+}
+
void LC::cb_unk() {
uint opcode = g_lingo->readInt();
warning("STUB: opcode 0x%02x", opcode);
@@ -358,43 +405,12 @@ void LC::cb_localcall() {
void LC::cb_objectcall() {
int varType = g_lingo->readInt();
- Datum d = g_lingo->pop();
+ Datum varId = g_lingo->pop();
Datum nargs = g_lingo->pop();
- Common::String name;
- if (d.type == INT) {
- if (g_lingo->_callstack.empty()) {
- warning("cb_objectcall: no call frame");
- return;
- }
- if (d.asInt() % 6 != 0) {
- warning("BUILDBOT: cb_objectcall: invalid var ID %d for var type %d (not divisible by 6)", d.asInt(), varType);
- return;
- }
- int varIndex = d.asInt() / 6;
- Common::Array<Common::String> *varNames;
- switch (varType) {
- case 4: // arg
- varNames = g_lingo->_callstack.back()->sp.argNames;
- break;
- case 5: // local
- varNames = g_lingo->_callstack.back()->sp.varNames;
- break;
- default:
- // everything else should be passed as a VAR
- warning("BUILDBOT: cb_objectcall: received var index %d for unhandled var type %d", varIndex, varType);
- return;
- }
- if (varIndex < (int)varNames->size()) {
- name = (*varNames)[d.asInt() / 6];
- } else {
- warning("BUILDBOT: cb_objectcall: invalid var ID %d for var type %d (too high)", d.asInt(), varType);
- return;
- }
- } else if (d.type == VAR) {
- name = *d.u.s;
- } else {
- warning("cb_objectcall: first arg should be of type VAR or INT, not %s", d.type2str());
+ Datum var = g_lingo->findVarV4(varType, varId);
+ if (var.type != VAR) {
+ warning("cb_objectcall: first arg did not resolve to variable");
return;
}
@@ -412,7 +428,7 @@ void LC::cb_objectcall() {
}
}
- LC::call(name, nargs.u.i, nargs.type == ARGC);
+ LC::call(*var.u.s, nargs.u.i, nargs.type == ARGC);
}
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 8462a81585..d5c1289f53 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -288,6 +288,7 @@ public:
void cleanLocalVars();
void varAssign(Datum &var, Datum &value, bool global = false, DatumHash *localvars = nullptr);
Datum varFetch(Datum &var, bool global = false, DatumHash *localvars = nullptr, bool silent = false);
+ Datum findVarV4(int varType, const Datum &id);
int getAlignedType(const Datum &d1, const Datum &d2, bool numsOnly);
Commit: 6db398a74d4deb9b0a8f81bdf2ae96bb79b628d3
https://github.com/scummvm/scummvm/commit/6db398a74d4deb9b0a8f81bdf2ae96bb79b628d3
Author: djsrv (dservilla at gmail.com)
Date: 2020-08-19T18:55:34-04:00
Commit Message:
DIRECTOR: LINGO: Use findVarV4 in cb_v4assign
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 edb25f5408..d62df57a70 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -433,44 +433,30 @@ void LC::cb_objectcall() {
void LC::cb_v4assign() {
- int op = g_lingo->readInt();
+ int arg = g_lingo->readInt();
+ int op = (arg >> 4) & 0xF;
+ int varType = arg & 0xF;
+ Datum varId = g_lingo->pop();
+
+ Datum var = g_lingo->findVarV4(varType, varId);
+ g_lingo->push(var);
switch (op) {
- case 0x16:
- // put value into field textVar
- {
- LB::b_field(1);
- LC::c_assign();
- }
+ case 1:
+ // put value into var
+ LC::c_assign();
break;
- case 0x22:
- // put value after chunkExpression
- {
- Datum chunkExpr = g_lingo->pop();
- g_lingo->push(chunkExpr);
- LC::c_putafter();
- }
+ case 2:
+ // put value after var
+ LC::c_putafter();
break;
- case 0x26:
- // put value after field textVar
- {
- LB::b_field(1);
- Datum field = g_lingo->pop();
- g_lingo->push(field);
- LC::c_putafter();
- }
- break;
- case 0x36:
- // put value before field textVar
- {
- LB::b_field(1);
- Datum field = g_lingo->pop();
- g_lingo->push(field);
- LC::c_putbefore();
- }
+ case 3:
+ // put value before var
+ LC::c_putbefore();
break;
default:
warning("cb_v4assign: unknown operator %d", op);
+ g_lingo->pop();
break;
}
}
More information about the Scummvm-git-logs
mailing list