diff options
author | Scott Percival | 2020-01-01 17:21:50 +0800 |
---|---|---|
committer | Scott Percival | 2020-01-01 17:27:25 +0800 |
commit | f263ed4bb63dca26a73790eb12ec908e75e5818a (patch) | |
tree | e58ae43dba2f62e2e4a976978b4997600e0468f1 /engines/director | |
parent | 94543467822401b407f4b061268e42d59d6a905b (diff) | |
download | scummvm-rg350-f263ed4bb63dca26a73790eb12ec908e75e5818a.tar.gz scummvm-rg350-f263ed4bb63dca26a73790eb12ec908e75e5818a.tar.bz2 scummvm-rg350-f263ed4bb63dca26a73790eb12ec908e75e5818a.zip |
DIRECTOR: LINGO: Add cb_v4putvalue, casting support for REFERENCE
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/lingo/lingo-builtins.cpp | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo-bytecode.cpp | 34 | ||||
-rw-r--r-- | engines/director/lingo/lingo-code.cpp | 11 | ||||
-rw-r--r-- | engines/director/lingo/lingo-code.h | 3 | ||||
-rw-r--r-- | engines/director/lingo/lingo.cpp | 16 |
5 files changed, 51 insertions, 15 deletions
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp index 3ba361e824..40ac67206c 100644 --- a/engines/director/lingo/lingo-builtins.cpp +++ b/engines/director/lingo/lingo-builtins.cpp @@ -1724,7 +1724,7 @@ void LB::b_field(int nargs) { if (g_director->getCurrentScore()->_castsNames.contains(*d.u.s)) id = g_director->getCurrentScore()->_castsNames[*d.u.s]; else - error("b_filed: Reference to non-existent field: %s", d.u.s->c_str()); + error("b_field: Reference to non-existent field: %s", d.u.s->c_str()); } else if (d.type == INT || d.type == FLOAT) { d.toInt(); id = d.u.i; diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp index c980d51082..da5da4481d 100644 --- a/engines/director/lingo/lingo-bytecode.cpp +++ b/engines/director/lingo/lingo-bytecode.cpp @@ -25,13 +25,14 @@ #include "director/director.h" #include "director/lingo/lingo.h" #include "director/lingo/lingo-code.h" +#include "director/lingo/lingo-builtins.h" #include "director/lingo/lingo-bytecode.h" #include "director/lingo/lingo-the.h" namespace Director { static LingoV4Bytecode lingoV4[] = { - { 0x01, STOP, "" }, + { 0x01, LC::c_procret, "" }, { 0x03, LC::c_voidpush, "" }, { 0x04, LC::c_mul, "" }, { 0x05, LC::c_add, "" }, @@ -56,7 +57,7 @@ static LingoV4Bytecode lingoV4[] = { { 0x18, LC::c_hilite, "" }, { 0x19, LC::c_intersects, "" }, { 0x1a, LC::c_within, "" }, - { 0x1b, LC::c_field, "" }, + { 0x1b, LC::cb_field, "" }, { 0x1c, LC::c_tell, "" }, { 0x1d, LC::c_telldone, "" }, { 0x41, LC::c_intpush, "b" }, @@ -69,6 +70,7 @@ static LingoV4Bytecode lingoV4[] = { { 0x55, LC::c_jumpifz, "jb" }, { 0x56, LC::cb_localcall, "b" }, { 0x57, LC::cb_call, "b" }, + { 0x59, LC::cb_v4putvalue, "b" }, { 0x5c, LC::cb_v4theentitypush, "b" }, { 0x5d, LC::cb_v4theentityassign, "b" }, { 0x66, LC::cb_v4theentitynamepush, "b" }, @@ -190,6 +192,11 @@ void Lingo::initBytecode() { } +void LC::cb_field() { + LB::b_field(1); +} + + void LC::cb_localcall() { int nameId = g_lingo->readInt(); Common::String name = g_lingo->_namelist[nameId]; @@ -208,6 +215,24 @@ void LC::cb_localcall() { } +void LC::cb_v4putvalue() { + int op = g_lingo->readInt(); + + switch (op) { + case 0x16: + // put value into field textVar + { + LC::cb_field(); + LC::c_assign(); + } + break; + default: + warning("cb_v4putvalue: unknown operator %d", op); + break; + } +} + + void LC::cb_call() { int nameId = g_lingo->readInt(); Common::String name = g_lingo->_namelist[nameId]; @@ -683,6 +708,9 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty } } + // Add backstop + g_lingo->code1(STOP); + // Rewrite every offset flagged as a jump based on the new code alignment. // This converts the relative offset from the bytecode to an absolute one. for (uint j = 0; j < jumpList.size(); j++) { @@ -707,6 +735,7 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty warning("Function has unknown name id %d, skipping define", nameIndex); } } + free(codeStore); } @@ -743,6 +772,7 @@ void Lingo::addNamesV4(Common::SeekableSubReadStreamEndian &stream) { name += stream.readByte(); } _namelist.push_back(name); + debugC(5, kDebugLoading, "%d: \"%s\"", i, name.c_str()); } } diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index ed307fb1dc..6cf10f861e 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -93,7 +93,6 @@ static struct FuncDescr { { LC::c_starts, "c_starts", "" }, { LC::c_intersects, "c_intersects", "" }, { LC::c_within, "c_within", "" }, - { LC::c_field, "c_field", "" }, { LC::c_of, "c_of", "" }, { LC::c_charOf, "c_charOf", "" }, // D3 { LC::c_charToOf, "c_charToOf", "" }, // D3 @@ -139,7 +138,9 @@ static struct FuncDescr { { LC::c_unk1, "c_unk1", "ii" }, { LC::c_unk2, "c_unk2", "iii" }, { LC::cb_call, "cb_call", "i" }, + { LC::cb_field, "cb_field", "" }, { LC::cb_localcall, "cb_localcall", "i" }, + { LC::cb_v4putvalue, "cb_putvalue", "i" }, { LC::cb_v4theentitypush,"c_v4theentitypush","i" }, { LC::cb_v4theentitynamepush,"c_v4theentitynamepush","i" }, { LC::cb_v4theentityassign,"c_v4theentityassign","i" }, @@ -690,14 +691,6 @@ void LC::c_within() { g_lingo->push(d1); } -void LC::c_field() { - Datum d1 = g_lingo->pop(); - - warning("STUB: c_field: %d", d1.u.i); - - g_lingo->push(d1); -} - void LC::c_of() { Datum first_char = g_lingo->pop(); Datum last_char = g_lingo->pop(); diff --git a/engines/director/lingo/lingo-code.h b/engines/director/lingo/lingo-code.h index 87051a8cca..05bfbfb82c 100644 --- a/engines/director/lingo/lingo-code.h +++ b/engines/director/lingo/lingo-code.h @@ -49,7 +49,6 @@ namespace LC { void c_intersects(); void c_within(); - void c_field(); void c_of(); void c_charOf(); void c_charToOf(); @@ -129,6 +128,8 @@ namespace LC { // bytecode-related instructions void cb_localcall(); void cb_call(); + void cb_field(); + void cb_v4putvalue(); void cb_v4theentitypush(); void cb_v4theentitynamepush(); void cb_v4theentityassign(); diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index f5a0d73ac2..03533babe6 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -299,25 +299,35 @@ int Lingo::alignTypes(Datum &d1, Datum &d2) { int Datum::toInt() { switch (type) { + case REFERENCE: + toString(); + case STRING: + u.i = atoi(u.s->c_str()); + break; case INT: // no-op break; case FLOAT: u.i = (int)u.f; - type = INT; break; default: warning("Incorrect operation toInt() for type: %s", type2str()); } + type = INT; + return u.i; } double Datum::toFloat() { switch (type) { + case REFERENCE: + toString(); + case STRING: + u.f = atof(u.s->c_str()); + break; case INT: u.f = (double)u.i; - type = FLOAT; break; case FLOAT: // no-op @@ -326,6 +336,8 @@ double Datum::toFloat() { warning("Incorrect operation toFloat() for type: %s", type2str()); } + type = FLOAT; + return u.f; } |