Skip to content
Permalink
Browse files

DIRECTOR: Add c_v4theentitypush and c_v4theentityassign

  • Loading branch information
moralrecordings committed Nov 29, 2019
1 parent f2bb493 commit 993fbf5a4f0ea93f7e4d5b387a188298ac05f2b5
Showing with 134 additions and 4 deletions.
  1. +130 −4 engines/director/lingo/lingo-bytecode.cpp
  2. +2 −0 engines/director/lingo/lingo-code.cpp
  3. +2 −0 engines/director/lingo/lingo.h
@@ -54,10 +54,18 @@ static LingoV4Bytecode lingoV4[] = {
{ 0x1c, Lingo::c_tell, "" },
{ 0x1d, Lingo::c_telldone, "" },
{ 0x41, Lingo::c_intpush, "b" },
{ 0x42, Lingo::c_argspush, "b" },
{ 0x43, Lingo::c_arraypush, "b" },
{ 0x45, Lingo::c_symbolpush, "b" },
{ 0x5c, Lingo::c_v4theentitypush, "b" },
{ 0x5d, Lingo::c_v4theentityassign, "b" },
{ 0x81, Lingo::c_intpush, "w" },
{ 0x82, Lingo::c_argspush, "w" },
{ 0x83, Lingo::c_arraypush, "w" },
{ 0, 0, 0 }
};

static LingoV4TheEntity lingoV4TheEntity[] {
static LingoV4TheEntity lingoV4TheEntity[] = {
{ 0x00, 0x00, kTheFloatPrecision, kTheNOField, false, kTEANOArgs },
{ 0x00, 0x01, kTheMouseDownScript, kTheNOField, true, kTEANOArgs },
{ 0x00, 0x02, kTheMouseUpScript, kTheNOField, true, kTEANOArgs },
@@ -150,7 +158,7 @@ static LingoV4TheEntity lingoV4TheEntity[] {
{ 0x0c, 0x07, kTheField, kTheTextSize, true, kTEAItemId },
{ 0x0d, 0x0f, kTheCast, kTheDirectToStage, true, kTEAItemId },
{ 0x0d, 0x10, kTheCast, kTheSound, true, kTEAItemId },
{ -1, 0, 0, 0, false, kTEANOArgs },
{ -1, 0, 0, 0, false, kTEANOArgs }
};


@@ -160,7 +168,126 @@ void Lingo::initBytecode() {
}

for (LingoV4TheEntity *ent = lingoV4TheEntity; ent->bank != -1; ent++) {
_lingoV4TheEntity[(ent->bank << 16) + ent->firstArg] = ent;
_lingoV4TheEntity[(ent->bank << 8) + ent->firstArg] = ent;
}
}


void Lingo::c_v4theentitypush() {
inst b = (*g_lingo->_currentScript)[g_lingo->_pc++];
int bank = (int)READ_UINT32(&b);

Datum firstArg = 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)) {
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;
result = g_lingo->getTheEntity(entity, id, field);
}
break;
case kTEAItemId:
{
Datum id = g_lingo->pop();
result = g_lingo->getTheEntity(entity, id, field);
}
break;
case kTEAString:
{
/*Datum stringArg = */g_lingo->pop();
warning("c_v4theentitypush: STUB: mapping 0x%02x 0x%02x kTEAString", bank, firstArg.u.i);
}
break;
case kTEAMenuIdItemId:
{
/*Datum menuId = */g_lingo->pop();
/*Datum itemId = */g_lingo->pop();
warning("c_v4theentitypush: STUB: mapping 0x%02x 0x%02x kTEAMenuIdItemId", bank, firstArg.u.i);
}
break;
default:
warning("c_v4theentitypush: unknown call type %d", g_lingo->_lingoV4TheEntity[key]->type);
break;
}
} else {
warning("c_v4theentitypush: unhandled mapping 0x%02x 0x%02x", bank, firstArg.u.i);
}

} else {
warning("c_v4theentitypush: first arg should be of type INT, not %s", firstArg.type2str());
}

g_lingo->push(result);
}


void Lingo::c_v4theentityassign() {
inst b = (*g_lingo->_currentScript)[g_lingo->_pc++];
int bank = (int)READ_UINT32(&b);

Datum firstArg = g_lingo->pop();
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)) {
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;
g_lingo->setTheEntity(entity, id, field, value);
}
break;
case kTEAItemId:
{
Datum id = g_lingo->pop();
g_lingo->setTheEntity(entity, id, field, value);
}
break;
case kTEAString:
{
/*Datum stringArg = */g_lingo->pop();
warning("c_v4theentityassign: STUB: mapping 0x%02x 0x%02x kTEAString", bank, firstArg.u.i);
}
break;
case kTEAMenuIdItemId:
{
/*Datum menuId = */g_lingo->pop();
/*Datum itemId = */g_lingo->pop();
warning("c_v4theentityassign: STUB: mapping 0x%02x 0x%02x kTEAMenuIdItemId", bank, firstArg.u.i);
}
break;
default:
warning("c_v4theentityassign: unknown call type %d", g_lingo->_lingoV4TheEntity[key]->type);
break;
}
} else {
warning("c_v4theentityassign: non-writable mapping 0x%02x 0x%02x", bank, firstArg.u.i);
}
} else {
warning("c_v4theentityassign: unhandled mapping 0x%02x 0x%02x", bank, firstArg.u.i);
}

} else {
warning("c_v4theentityassign: first arg should be of type INT, not %s", firstArg.type2str());
}
}

@@ -368,7 +495,6 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
break;
}
}

} else {
// unimplemented instruction
if (opcode < 0x40) { // 1 byte instruction
@@ -71,6 +71,8 @@ static struct FuncDescr {
{ Lingo::c_eval, "c_eval", "s" },
{ Lingo::c_theentitypush,"c_theentitypush","ii" }, // entity, field
{ Lingo::c_theentityassign,"c_theentityassign","ii" },
{ Lingo::c_v4theentitypush,"c_v4theentitypush","i" },
{ Lingo::c_v4theentityassign,"c_v4theentityassign","i" },
{ Lingo::c_swap, "c_swap", "" },
{ Lingo::c_add, "c_add", "" },
{ Lingo::c_sub, "c_sub", "" },
@@ -290,6 +290,8 @@ class Lingo {

static void c_theentitypush();
static void c_theentityassign();
static void c_v4theentitypush();
static void c_v4theentityassign();

static void c_repeatwhilecode();
static void c_repeatwithcode();

0 comments on commit 993fbf5

Please sign in to comment.
You can’t perform that action at this time.