aboutsummaryrefslogtreecommitdiff
path: root/engines/director/lingo
diff options
context:
space:
mode:
authorEugene Sandulenko2016-08-13 12:40:54 +0200
committerEugene Sandulenko2016-08-13 12:41:22 +0200
commit963826ca6f350783e2fd0a2ca6bdb9f3a5222d52 (patch)
tree977e26503001eac3e7148e10269006a7b571acea /engines/director/lingo
parentfb5c38c9edd004d32b8ef6da1bfa444777283f05 (diff)
downloadscummvm-rg350-963826ca6f350783e2fd0a2ca6bdb9f3a5222d52.tar.gz
scummvm-rg350-963826ca6f350783e2fd0a2ca6bdb9f3a5222d52.tar.bz2
scummvm-rg350-963826ca6f350783e2fd0a2ca6bdb9f3a5222d52.zip
DIRECTOR: Lingo: Simplified Datum constants pushing
Diffstat (limited to 'engines/director/lingo')
-rw-r--r--engines/director/lingo/lingo-builtins.cpp60
-rw-r--r--engines/director/lingo/lingo-code.cpp5
-rw-r--r--engines/director/lingo/lingo.h3
3 files changed, 16 insertions, 52 deletions
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 9f80de6f7f..05553fe806 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -521,6 +521,8 @@ void Lingo::b_constrainH(int nargs) {
sprite.toInt();
warning("STUB: b_constrainH(%d, %d)", sprite.u.i, num.u.i);
+
+ g_lingo->push(Datum(0));
}
void Lingo::b_constrainV(int nargs) {
@@ -531,6 +533,8 @@ void Lingo::b_constrainV(int nargs) {
sprite.toInt();
warning("STUB: b_constrainV(%d, %d)", sprite.u.i, num.u.i);
+
+ g_lingo->push(Datum(0));
}
void Lingo::b_editableText(int nargs) {
@@ -647,75 +651,35 @@ void Lingo::b_mciwait(int nargs) {
// Constants
///////////////////
void Lingo::b_backspace(int nargs) {
- Datum d;
-
- d.type = STRING;
- d.u.s = new Common::String("\b");
-
- g_lingo->push(d);
+ g_lingo->push(Datum(new Common::String("\b")));
}
void Lingo::b_empty(int nargs) {
- Datum d;
-
- d.type = STRING;
- d.u.s = new Common::String("");
-
- g_lingo->push(d);
+ g_lingo->push(Datum(new Common::String("")));
}
void Lingo::b_enter(int nargs) {
- Datum d;
-
- d.type = STRING;
- d.u.s = new Common::String("\n");
-
- g_lingo->push(d);
+ g_lingo->push(Datum(new Common::String("\n")));
}
void Lingo::b_false(int nargs) {
- Datum d;
-
- d.type = INT;
- d.u.i = 0;
-
- g_lingo->push(d);
+ g_lingo->push(Datum(0));
}
void Lingo::b_quote(int nargs) {
- Datum d;
-
- d.type = STRING;
- d.u.s = new Common::String("\"");
-
- g_lingo->push(d);
+ g_lingo->push(Datum(new Common::String("\"")));
}
void Lingo::b_return(int nargs) {
- Datum d;
-
- d.type = STRING;
- d.u.s = new Common::String("\r");
-
- g_lingo->push(d);
+ g_lingo->push(Datum(new Common::String("\r")));
}
void Lingo::b_tab(int nargs) {
- Datum d;
-
- d.type = STRING;
- d.u.s = new Common::String("\t");
-
- g_lingo->push(d);
+ g_lingo->push(Datum(new Common::String("\t")));
}
void Lingo::b_true(int nargs) {
- Datum d;
-
- d.type = INT;
- d.u.i = 1;
-
- g_lingo->push(d);
+ g_lingo->push(Datum(1));
}
///////////////////
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 646a9316c3..6072977d07 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -140,13 +140,10 @@ void Lingo::c_fconstpush() {
}
void Lingo::c_stringpush() {
- Datum d;
char *s = (char *)&(*g_lingo->_currentScript)[g_lingo->_pc];
g_lingo->_pc += g_lingo->calcStringAlignment(s);
- d.u.s = new Common::String(s);
- d.type = STRING;
- g_lingo->push(d);
+ g_lingo->push(Datum(new Common::String(s)));
}
void Lingo::c_varpush() {
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index b4244e8bee..a8b8c04355 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -111,6 +111,9 @@ struct Datum { /* interpreter stack type */
} u;
Datum() { u.sym = NULL; type = VOID; }
+ Datum(int val) { u.i = val; type = INT; }
+ Datum(double val) { u.f = val; type = FLOAT; }
+ Datum(Common::String *val) { u.s = val; type = STRING; }
double toFloat();
int toInt();