aboutsummaryrefslogtreecommitdiff
path: root/engines/director/lingo
diff options
context:
space:
mode:
authorScott Percival2019-12-18 01:46:45 +0800
committerScott Percival2019-12-18 02:12:53 +0800
commit7c919f70d441961d8335cdadb10fc4f0e14ee915 (patch)
tree4bc3e612ba12595f942c5930beb1ecc2b0f6f4af /engines/director/lingo
parente86c71ae20f7aa1f0f7b11c11779e3419acb0d99 (diff)
downloadscummvm-rg350-7c919f70d441961d8335cdadb10fc4f0e14ee915.tar.gz
scummvm-rg350-7c919f70d441961d8335cdadb10fc4f0e14ee915.tar.bz2
scummvm-rg350-7c919f70d441961d8335cdadb10fc4f0e14ee915.zip
DIRECTOR: Fix calling convention for b_go
Diffstat (limited to 'engines/director/lingo')
-rw-r--r--engines/director/lingo/lingo-builtins.cpp62
1 files changed, 43 insertions, 19 deletions
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index f0e384d92c..8a465c585e 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -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);