aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Percival2020-01-09 19:23:43 +0800
committerScott Percival2020-01-09 19:23:43 +0800
commitf26aff27088c0100cb61b906e808e3b9aa0d8210 (patch)
tree8f759cb71410ab6a3cc0a91a1eb6bc9e80f3c21c
parentfe9b3fea556ad03941049f61c6c2232cb09a420b (diff)
downloadscummvm-rg350-f26aff27088c0100cb61b906e808e3b9aa0d8210.tar.gz
scummvm-rg350-f26aff27088c0100cb61b906e808e3b9aa0d8210.tar.bz2
scummvm-rg350-f26aff27088c0100cb61b906e808e3b9aa0d8210.zip
DIRECTOR: LINGO: Allow cb_v4theentitypush and cb_v4theentityassign to cast to INT
-rw-r--r--engines/director/lingo/lingo-bytecode.cpp170
-rw-r--r--engines/director/lingo/lingo.cpp6
2 files changed, 87 insertions, 89 deletions
diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index da5da4481d..5a71233c01 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -85,7 +85,7 @@ static LingoV4Bytecode lingoV4[] = {
};
static LingoV4TheEntity lingoV4TheEntity[] = {
- { 0x00, 0x00, kTheFloatPrecision, kTheNOField, false, kTEANOArgs },
+ { 0x00, 0x00, kTheFloatPrecision, kTheNOField, true, kTEANOArgs },
{ 0x00, 0x01, kTheMouseDownScript, kTheNOField, true, kTEANOArgs },
{ 0x00, 0x02, kTheMouseUpScript, kTheNOField, true, kTEANOArgs },
{ 0x00, 0x03, kTheKeyDownScript, kTheNOField, true, kTEANOArgs },
@@ -252,56 +252,52 @@ void LC::cb_v4theentitypush() {
int bank = g_lingo->readInt();
Datum firstArg = g_lingo->pop();
+ firstArg.toInt();
Datum result;
result.u.s = NULL;
result.type = VOID;
- if (firstArg.type == INT) {
- int key = (bank << 8) + firstArg.u.i;
- if (g_lingo->_lingoV4TheEntity.contains(key)) {
- debugC(3, kDebugLingoExec, "cb_v4theentitypush: mapping 0x%02x, 0x%02x", bank, firstArg.u.i);
- int entity = g_lingo->_lingoV4TheEntity[key]->entity;
- int field = g_lingo->_lingoV4TheEntity[key]->field;
- switch (g_lingo->_lingoV4TheEntity[key]->type) {
- case kTEANOArgs:
- {
- Datum id;
- id.u.s = NULL;
- id.type = VOID;
- debugC(3, kDebugLingoExec, "cb_v4theentitypush: calling getTheEntity(0x%02x, NULL, 0x%02x)", entity, field);
- result = g_lingo->getTheEntity(entity, id, field);
- }
- break;
- case kTEAItemId:
- {
- Datum id = g_lingo->pop();
- debugC(3, kDebugLingoExec, "cb_v4theentitypush: calling getTheEntity(0x%02x, id, 0x%02x)", entity, field);
- result = g_lingo->getTheEntity(entity, id, field);
- }
- break;
- case kTEAString:
- {
- /*Datum stringArg = */g_lingo->pop();
- warning("cb_v4theentitypush: STUB: kTEAString");
- }
- break;
- case kTEAMenuIdItemId:
- {
- /*Datum menuId = */g_lingo->pop();
- /*Datum itemId = */g_lingo->pop();
- warning("cb_v4theentitypush: STUB: kTEAMenuIdItemId");
- }
- break;
- default:
- warning("cb_v4theentitypush: unknown call type %d", g_lingo->_lingoV4TheEntity[key]->type);
- break;
+ int key = (bank << 8) + firstArg.u.i;
+ if (g_lingo->_lingoV4TheEntity.contains(key)) {
+ debugC(3, kDebugLingoExec, "cb_v4theentitypush: mapping 0x%02x, 0x%02x", bank, firstArg.u.i);
+ int entity = g_lingo->_lingoV4TheEntity[key]->entity;
+ int field = g_lingo->_lingoV4TheEntity[key]->field;
+ switch (g_lingo->_lingoV4TheEntity[key]->type) {
+ case kTEANOArgs:
+ {
+ Datum id;
+ id.u.s = NULL;
+ id.type = VOID;
+ debugC(3, kDebugLingoExec, "cb_v4theentitypush: calling getTheEntity(0x%02x, NULL, 0x%02x)", entity, field);
+ result = g_lingo->getTheEntity(entity, id, field);
}
- } else {
- warning("cb_v4theentitypush: unhandled mapping 0x%02x 0x%02x", bank, firstArg.u.i);
+ break;
+ case kTEAItemId:
+ {
+ Datum id = g_lingo->pop();
+ debugC(3, kDebugLingoExec, "cb_v4theentitypush: calling getTheEntity(0x%02x, id, 0x%02x)", entity, field);
+ result = g_lingo->getTheEntity(entity, id, field);
+ }
+ break;
+ case kTEAString:
+ {
+ /*Datum stringArg = */g_lingo->pop();
+ warning("cb_v4theentitypush: STUB: kTEAString");
+ }
+ break;
+ case kTEAMenuIdItemId:
+ {
+ /*Datum menuId = */g_lingo->pop();
+ /*Datum itemId = */g_lingo->pop();
+ warning("cb_v4theentitypush: STUB: kTEAMenuIdItemId");
+ }
+ break;
+ default:
+ warning("cb_v4theentitypush: unknown call type %d", g_lingo->_lingoV4TheEntity[key]->type);
+ break;
}
-
} else {
- warning("cb_v4theentitypush: first arg should be of type INT, not %s", firstArg.type2str());
+ warning("cb_v4theentitypush: unhandled mapping 0x%02x 0x%02x", bank, firstArg.u.i);
}
g_lingo->push(result);
@@ -342,61 +338,57 @@ void LC::cb_v4theentityassign() {
int bank = g_lingo->readInt();
Datum firstArg = g_lingo->pop();
+ firstArg.toInt();
Datum value = g_lingo->pop();
Datum result;
result.u.s = NULL;
result.type = VOID;
- if (firstArg.type == INT) {
- int key = (bank << 8) + firstArg.u.i;
- if (g_lingo->_lingoV4TheEntity.contains(key)) {
- debugC(3, kDebugLingoExec, "cb_v4theentityassign: mapping 0x%02x, 0x%02x", bank, firstArg.u.i);
- if (g_lingo->_lingoV4TheEntity[key]->writable) {
- int entity = g_lingo->_lingoV4TheEntity[key]->entity;
- int field = g_lingo->_lingoV4TheEntity[key]->field;
- switch (g_lingo->_lingoV4TheEntity[key]->type) {
- case kTEANOArgs:
- {
- Datum id;
- id.u.s = NULL;
- id.type = VOID;
- debugC(3, kDebugLingoExec, "cb_v4theentityassign: calling setTheEntity(0x%02x, NULL, 0x%02x, value)", entity, field);
- g_lingo->setTheEntity(entity, id, field, value);
- }
- break;
- case kTEAItemId:
- {
- Datum id = g_lingo->pop();
- debugC(3, kDebugLingoExec, "cb_v4theentityassign: calling setTheEntity(0x%02x, id, 0x%02x, value)", entity, field);
- g_lingo->setTheEntity(entity, id, field, value);
- }
- break;
- case kTEAString:
- {
- /*Datum stringArg = */g_lingo->pop();
- warning("cb_v4theentityassign: STUB: kTEAString");
- }
- break;
- case kTEAMenuIdItemId:
- {
- /*Datum menuId = */g_lingo->pop();
- /*Datum itemId = */g_lingo->pop();
- warning("cb_v4theentityassign: STUB: kTEAMenuIdItemId");
- }
- break;
- default:
- warning("cb_v4theentityassign: unknown call type %d", g_lingo->_lingoV4TheEntity[key]->type);
- break;
+ int key = (bank << 8) + firstArg.u.i;
+ if (g_lingo->_lingoV4TheEntity.contains(key)) {
+ debugC(3, kDebugLingoExec, "cb_v4theentityassign: mapping 0x%02x, 0x%02x", bank, firstArg.u.i);
+ if (g_lingo->_lingoV4TheEntity[key]->writable) {
+ int entity = g_lingo->_lingoV4TheEntity[key]->entity;
+ int field = g_lingo->_lingoV4TheEntity[key]->field;
+ switch (g_lingo->_lingoV4TheEntity[key]->type) {
+ case kTEANOArgs:
+ {
+ Datum id;
+ id.u.s = NULL;
+ id.type = VOID;
+ debugC(3, kDebugLingoExec, "cb_v4theentityassign: calling setTheEntity(0x%02x, NULL, 0x%02x, value)", entity, field);
+ g_lingo->setTheEntity(entity, id, field, value);
}
- } else {
- warning("cb_v4theentityassign: non-writable mapping 0x%02x 0x%02x", bank, firstArg.u.i);
+ break;
+ case kTEAItemId:
+ {
+ Datum id = g_lingo->pop();
+ debugC(3, kDebugLingoExec, "cb_v4theentityassign: calling setTheEntity(0x%02x, id, 0x%02x, value)", entity, field);
+ g_lingo->setTheEntity(entity, id, field, value);
+ }
+ break;
+ case kTEAString:
+ {
+ /*Datum stringArg = */g_lingo->pop();
+ warning("cb_v4theentityassign: STUB: kTEAString");
+ }
+ break;
+ case kTEAMenuIdItemId:
+ {
+ /*Datum menuId = */g_lingo->pop();
+ /*Datum itemId = */g_lingo->pop();
+ warning("cb_v4theentityassign: STUB: kTEAMenuIdItemId");
+ }
+ break;
+ default:
+ warning("cb_v4theentityassign: unknown call type %d", g_lingo->_lingoV4TheEntity[key]->type);
+ break;
}
} else {
- warning("cb_v4theentityassign: unhandled mapping 0x%02x 0x%02x", bank, firstArg.u.i);
+ warning("cb_v4theentityassign: non-writable mapping 0x%02x 0x%02x", bank, firstArg.u.i);
}
-
} else {
- warning("cb_v4theentityassign: first arg should be of type INT, not %s", firstArg.type2str());
+ warning("cb_v4theentityassign: unhandled mapping 0x%02x 0x%02x", bank, firstArg.u.i);
}
}
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 36a0c6368d..8935614242 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -305,6 +305,9 @@ int Datum::toInt() {
case STRING:
u.i = atoi(u.s->c_str());
break;
+ case VOID:
+ u.i = 0;
+ break;
case INT:
// no-op
break;
@@ -328,6 +331,9 @@ double Datum::toFloat() {
case STRING:
u.f = atof(u.s->c_str());
break;
+ case VOID:
+ u.f = 0.0;
+ break;
case INT:
u.f = (double)u.i;
break;