aboutsummaryrefslogtreecommitdiff
path: root/engines/director/lingo
diff options
context:
space:
mode:
authorEugene Sandulenko2017-02-25 21:40:29 +0100
committerEugene Sandulenko2017-02-25 21:44:01 +0100
commit27a0f433338726dd486c5c8be0ad60ba587aeaa1 (patch)
tree17ebef213b16b1f15f71c7a195be15e59e8c2f43 /engines/director/lingo
parent16d21cd0ff7fa200664fb75b915da015cccc8a48 (diff)
downloadscummvm-rg350-27a0f433338726dd486c5c8be0ad60ba587aeaa1.tar.gz
scummvm-rg350-27a0f433338726dd486c5c8be0ad60ba587aeaa1.tar.bz2
scummvm-rg350-27a0f433338726dd486c5c8be0ad60ba587aeaa1.zip
DIRECTOR: Move utility functions to util.cpp
Diffstat (limited to 'engines/director/lingo')
-rw-r--r--engines/director/lingo/lingo-code.cpp9
-rw-r--r--engines/director/lingo/lingo-codegen.cpp21
-rw-r--r--engines/director/lingo/lingo.cpp42
-rw-r--r--engines/director/lingo/lingo.h2
4 files changed, 14 insertions, 60 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index b7fc484d91..96f2b72158 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -44,6 +44,7 @@
// THIS SOFTWARE.
#include "director/cast.h"
+#include "director/util.h"
#include "director/lingo/lingo.h"
#include "director/lingo/lingo-gr.h"
@@ -578,8 +579,8 @@ void Lingo::c_contains() {
d1.toString();
d2.toString();
- Common::String *s1 = g_lingo->toLowercaseMac(d1.u.s);
- Common::String *s2 = g_lingo->toLowercaseMac(d2.u.s);
+ Common::String *s1 = toLowercaseMac(d1.u.s);
+ Common::String *s2 = toLowercaseMac(d2.u.s);
int res = s1->contains(*s2) ? 1 : 0;
@@ -601,8 +602,8 @@ void Lingo::c_starts() {
d1.toString();
d2.toString();
- Common::String *s1 = g_lingo->toLowercaseMac(d1.u.s);
- Common::String *s2 = g_lingo->toLowercaseMac(d2.u.s);
+ Common::String *s1 = toLowercaseMac(d1.u.s);
+ Common::String *s2 = toLowercaseMac(d2.u.s);
int res = s1->hasPrefix(*s2) ? 1 : 0;
diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp
index d69de85e9a..b16e6b6131 100644
--- a/engines/director/lingo/lingo-codegen.cpp
+++ b/engines/director/lingo/lingo-codegen.cpp
@@ -48,6 +48,7 @@
#include "audio/decoders/wave.h"
#include "director/lingo/lingo-gr.h"
+#include "director/util.h"
namespace Director {
@@ -146,22 +147,18 @@ Symbol *Lingo::lookupVar(const char *name, bool create, bool putInGlobalList) {
// Looking for the cast member constants
if (_vm->getVersion() < 4) { // TODO: There could be a flag 'Allow Outdated Lingo' in Movie Info in D4
- if (strlen(name) == 3) {
- if (tolower(name[0]) >= 'a' && tolower(name[0]) <= 'h' &&
- name[1] >= '1' && name[1] <= '8' &&
- name[2] >= '1' && name[2] <= '8') {
+ int val = castNumToNum(name);
- if (!create)
- error("Cast reference used in wrong context: %s", name);
+ if (val != -1) {
+ if (!create)
+ error("Cast reference used in wrong context: %s", name);
- int val = (tolower(name[0]) - 'a') * 64 + (name[1] - '1') * 8 + (name[2] - '1') + 1;
- sym = new Symbol;
+ sym = new Symbol;
- sym->type = CASTREF;
- sym->u.i = val;
+ sym->type = CASTREF;
+ sym->u.i = val;
- return sym;
- }
+ return sym;
}
}
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index ffbbdab933..5775eb13bc 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -438,48 +438,6 @@ const char *Datum::type2str(bool isk) {
}
}
-// This is table for built-in Macintosh font lowercasing.
-// '.' means that the symbol should be not changed, rest
-// of the symbols are stripping the diacritics
-// The table starts from 0x80
-//
-// TODO: Check it for correctness.
-static char lowerCaseConvert[] =
-"aacenoua" // 80
-"aaaaacee" // 88
-"eeiiiino" // 90
-"oooouuuu" // 98
-"........" // a0
-".......o" // a8
-"........" // b0
-".......o" // b8
-"........" // c0
-".. aao.." // c8
-"--.....y";// d0-d8
-
-Common::String *Lingo::toLowercaseMac(Common::String *s) {
- Common::String *res = new Common::String;
- const unsigned char *p = (const unsigned char *)s->c_str();
-
- while (*p) {
- if (*p >= 0x80 && *p <= 0xd8) {
- if (lowerCaseConvert[*p - 0x80] != '.')
- *res += lowerCaseConvert[*p - 0x80];
- else
- *res += *p;
- } else if (*p < 0x80) {
- *res += tolower(*p);
- } else {
- warning("Unacceptable symbol in toLowercaseMac: %c", *p);
-
- *res += *p;
- }
- p++;
- }
-
- return res;
-}
-
void Lingo::parseMenu(const char *code) {
warning("STUB: parseMenu");
}
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 516e91c6ed..1e84344cdb 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -190,8 +190,6 @@ public:
void initFuncs();
void initTheEntities();
- Common::String *toLowercaseMac(Common::String *s);
-
void runTests();
private: