From 996b909b0e880298d3e7bb3b7682968ab1e6199b Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 9 Jul 2016 23:17:10 +0200 Subject: DIRECTOR: Lingo: FLOAT actually has to have double precision. Switching. --- engines/director/lingo/lingo-builtins.cpp | 10 +++++----- engines/director/lingo/lingo-code.cpp | 4 ++-- engines/director/lingo/lingo-codegen.cpp | 6 +++--- engines/director/lingo/lingo-gr.cpp | 2 +- engines/director/lingo/lingo-gr.h | 2 +- engines/director/lingo/lingo-gr.y | 2 +- engines/director/lingo/lingo.cpp | 6 +++--- engines/director/lingo/lingo.h | 8 ++++---- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp index 873e844228..0555a13df7 100644 --- a/engines/director/lingo/lingo-builtins.cpp +++ b/engines/director/lingo/lingo-builtins.cpp @@ -73,7 +73,7 @@ void Lingo::b_abs() { void Lingo::b_atan() { Datum d = g_lingo->pop(); d.toFloat(); - d.u.f = atanf(d.u.f); + d.u.f = atan(d.u.f); g_lingo->push(d); } @@ -88,7 +88,7 @@ void Lingo::b_exp() { Datum d = g_lingo->pop(); d.toInt(); // Lingo uses int, so we're enforcing it d.toFloat(); - d.u.f = expf(d.u.f); + d.u.f = exp(d.u.f); g_lingo->push(d); } @@ -107,14 +107,14 @@ void Lingo::b_integer() { void Lingo::b_log() { Datum d = g_lingo->pop(); d.toFloat(); - d.u.f = logf(d.u.f); + d.u.f = log(d.u.f); g_lingo->push(d); } void Lingo::b_pi() { Datum d; d.toFloat(); - d.u.f = 3.14159265358; + d.u.f = 3.14159265358979; g_lingo->push(d); } @@ -123,7 +123,7 @@ void Lingo::b_power() { Datum d2 = g_lingo->pop(); d1.toFloat(); d2.toFloat(); - d1.u.f = powf(d2.u.f, d1.u.f); + d1.u.f = pow(d2.u.f, d1.u.f); g_lingo->push(d1); } diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index f7dc403d3f..24325be9f5 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -111,10 +111,10 @@ void Lingo::c_constpush() { void Lingo::c_fconstpush() { Datum d; inst i = (*g_lingo->_currentScript)[g_lingo->_pc]; - d.u.f = *((float *)&i); + d.u.f = *((double *)&i); d.type = FLOAT; - g_lingo->_pc += g_lingo->calcCodeAlignment(sizeof(float)); + g_lingo->_pc += g_lingo->calcCodeAlignment(sizeof(double)); g_lingo->push(d); } diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp index 771cfc5320..a7a004e7d9 100644 --- a/engines/director/lingo/lingo-codegen.cpp +++ b/engines/director/lingo/lingo-codegen.cpp @@ -164,8 +164,8 @@ int Lingo::codeString(const char *str) { return _currentScript->size(); } -int Lingo::codeFloat(float f) { - int numInsts = calcCodeAlignment(sizeof(float)); +int Lingo::codeFloat(double f) { + int numInsts = calcCodeAlignment(sizeof(double)); // Where we copy the string over int pos = _currentScript->size(); @@ -174,7 +174,7 @@ int Lingo::codeFloat(float f) { for (int i = 0; i < numInsts; i++) _currentScript->push_back(0); - float *dst = (float *)((byte *)&_currentScript->front() + pos * sizeof(inst)); + double *dst = (double *)((byte *)&_currentScript->front() + pos * sizeof(inst)); *dst = f; diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp index f5c4e3da1d..50d34d9992 100644 --- a/engines/director/lingo/lingo-gr.cpp +++ b/engines/director/lingo/lingo-gr.cpp @@ -211,7 +211,7 @@ typedef union YYSTYPE { Common::String *s; int i; - float f; + double f; int code; int narg; /* number of arguments */ } diff --git a/engines/director/lingo/lingo-gr.h b/engines/director/lingo/lingo-gr.h index 3c349b7e98..b809af7775 100644 --- a/engines/director/lingo/lingo-gr.h +++ b/engines/director/lingo/lingo-gr.h @@ -148,7 +148,7 @@ typedef union YYSTYPE { Common::String *s; int i; - float f; + double f; int code; int narg; /* number of arguments */ } diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y index d0618af9f8..6af9ca145f 100644 --- a/engines/director/lingo/lingo-gr.y +++ b/engines/director/lingo/lingo-gr.y @@ -65,7 +65,7 @@ using namespace Director; %union { Common::String *s; int i; - float f; + double f; int code; int narg; /* number of arguments */ } diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index a73820dff6..b05c62c5b6 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -197,10 +197,10 @@ int Datum::toInt() { return u.i; } -float Datum::toFloat() { +double Datum::toFloat() { switch (type) { case INT: - u.f = (float)u.i; + u.f = (double)u.i; type = FLOAT; break; case FLOAT: @@ -220,7 +220,7 @@ Common::String *Datum::toString() { s->format("%d", u.i); break; case FLOAT: - s->format("%f", u.f); + s->format(g_lingo->_floatPrecisionFormat.c_str(), u.f); break; case STRING: delete s; diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index ea41762f11..d8cd64df0f 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -82,7 +82,7 @@ struct Symbol { /* symbol table entry */ int type; union { int i; /* VAR */ - float f; /* FLOAT */ + double f; /* FLOAT */ ScriptData *defn; /* FUNCTION, PROCEDURE */ Common::String *s; /* STRING */ } u; @@ -97,14 +97,14 @@ struct Datum { /* interpreter stack type */ union { int i; - float f; + double f; Common::String *s; Symbol *sym; } u; Datum() { u.sym = NULL; type = VOID; } - float toFloat(); + double toFloat(); int toInt(); Common::String *toString(); @@ -173,7 +173,7 @@ public: void codeArgStore(); int codeId(Common::String &s); int codeId_(Common::String &s); - int codeFloat(float f); + int codeFloat(double f); static void c_xpop(); static void c_printtop(); -- cgit v1.2.3