DIRECTOR: Fix calling convention for b_go

This commit is contained in:
Scott Percival 2019-12-18 01:46:45 +08:00
parent e86c71ae20
commit 7c919f70d4

View File

@ -893,36 +893,60 @@ void Lingo::b_do(int nargs) {
}
void Lingo::b_go(int nargs) {
// Builtin function for go as used by the Director bytecode engine.
//
// Accepted arguments:
// "loop"
// "next"
// "previous"
// (STRING|INT) frame
// STRING movie, (STRING|INT) frame
if (nargs >= 1 && nargs <= 2) {
Datum frame = g_lingo->pop();
Datum firstArg = g_lingo->pop();
nargs -= 1;
if (frame.type == STRING) {
if (*frame.u.s == "loop") {
bool callSpecial = false;
if (firstArg.type == STRING) {
if (*firstArg.u.s == "loop") {
g_lingo->func_gotoloop();
} else if (*frame.u.s == "next") {
callSpecial = true;
} else if (*firstArg.u.s == "next") {
g_lingo->func_gotonext();
} else if (*frame.u.s == "previous") {
callSpecial = true;
} else if (*firstArg.u.s == "previous") {
g_lingo->func_gotoprevious();
} else {
Datum movie;
if (nargs > 0) {
movie = g_lingo->pop();
nargs -= 1;
if (movie.type != STRING) {
warning("b_go: movie arg should be of type STRING, not %s", movie.type2str());
}
}
g_lingo->func_goto(frame, movie);
callSpecial = true;
}
}
if (!callSpecial) {
Datum movie;
Datum frame;
if (nargs > 0) {
warning("b_go: ignoring %d extra args", nargs);
g_lingo->dropStack(nargs);
movie = firstArg;
if (movie.type != STRING) {
warning("b_go: movie arg should be of type STRING, not %s", movie.type2str());
}
frame = g_lingo->pop();
nargs -= 1;
} else {
frame = firstArg;
}
} else {
warning("b_go: frame arg should be of type STRING, not %s", frame.type2str());
if (frame.type != STRING && frame.type != INT) {
warning("b_go: frame arg should be of type STRING or INT, not %s", frame.type2str());
}
g_lingo->func_goto(frame, movie);
}
if (nargs > 0) {
warning("b_go: ignoring %d extra args", nargs);
g_lingo->dropStack(nargs);
}
} else {
warning("b_go: expected 1 or 2 args, not %d", nargs);
g_lingo->dropStack(nargs);