Skip to content

Commit

Permalink
DIRECTOR: Lingo: Added basic support for points
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 3, 2016
1 parent e56295d commit 7fd25e9
Show file tree
Hide file tree
Showing 8 changed files with 658 additions and 595 deletions.
23 changes: 23 additions & 0 deletions engines/director/lingo/lingo-builtins.cpp
Expand Up @@ -49,6 +49,8 @@ static struct BuiltinProto {
{ "string", Lingo::b_string, 1},
// Misc
{ "dontpassevent", Lingo::b_dontpassevent, -1 },
// point
{ "point", Lingo::b_point, 2},
{ 0, 0, 0 }
};

Expand Down Expand Up @@ -216,4 +218,25 @@ void Lingo::b_dontpassevent() {
warning("STUB: b_dontpassevent");
}

///////////////////
// Point
///////////////////
void Lingo::b_point() {
Datum y = g_lingo->pop();
Datum x = g_lingo->pop();
Datum d;

x.toFloat();
y.toFloat();

d.u.arr = new FloatArray;

d.u.arr->push_back(x.u.f);
d.u.arr->push_back(y.u.f);
d.type = POINT;

g_lingo->push(d);
}


} // End of namespace Director
13 changes: 12 additions & 1 deletion engines/director/lingo/lingo-code.cpp
Expand Up @@ -95,6 +95,9 @@ void Lingo::c_printtop(void) {
case STRING:
warning("%s", d.u.s->c_str());
break;
case POINT:
warning("point (%d, %d)", (int)((*d.u.arr)[0]), (int)((*d.u.arr)[1]));
break;
default:
warning("--unknown--");
}
Expand Down Expand Up @@ -175,14 +178,18 @@ void Lingo::c_assign() {
d1.u.sym->u.f = d2.u.f;
else if (d2.type == STRING)
d1.u.sym->u.s = new Common::String(*d2.u.s);
else if (d2.type == POINT)
d1.u.sym->u.arr = d2.u.arr;
else
error("c_assign: unhandled type: %s", d2.type2str());

d1.u.sym->type = d2.type;

g_lingo->push(d1);
}

bool Lingo::verify(Symbol *s) {
if (s->type != INT && s->type != VOID && s->type != FLOAT && s->type != STRING) {
if (s->type != INT && s->type != VOID && s->type != FLOAT && s->type != STRING && s->type != POINT) {
warning("attempt to evaluate non-variable '%s'", s->name);

return false;
Expand Down Expand Up @@ -214,6 +221,10 @@ void Lingo::c_eval() {
d.u.f = d.u.sym->u.f;
else if (d.u.sym->type == STRING)
d.u.s = new Common::String(*d.u.sym->u.s);
else if (d.u.sym->type == POINT)
d.u.arr = d.u.sym->u.arr;
else
error("c_eval: unhandled type: %s", d.type2str());

g_lingo->push(d);
}
Expand Down

0 comments on commit 7fd25e9

Please sign in to comment.