aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2011-12-26 21:56:40 +0100
committerWillem Jan Palenstijn2011-12-26 21:58:17 +0100
commit2cd0b29de182be4f01caddaa4e66582ab780bcd4 (patch)
tree92c49c84149e9522946497f291745e237a47a567 /engines/dreamweb
parent2ec65882e885730e05b074063ce71caaba7cd2fc (diff)
downloadscummvm-rg350-2cd0b29de182be4f01caddaa4e66582ab780bcd4.tar.gz
scummvm-rg350-2cd0b29de182be4f01caddaa4e66582ab780bcd4.tar.bz2
scummvm-rg350-2cd0b29de182be4f01caddaa4e66582ab780bcd4.zip
DREAMWEB: Convert searchForString
Diffstat (limited to 'engines/dreamweb')
-rw-r--r--engines/dreamweb/dreambase.h1
-rw-r--r--engines/dreamweb/dreamgen.cpp44
-rw-r--r--engines/dreamweb/dreamgen.h1
-rw-r--r--engines/dreamweb/monitor.cpp40
-rw-r--r--engines/dreamweb/stubs.h4
5 files changed, 45 insertions, 45 deletions
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 1502e391fa..d9b77c1ec0 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -181,6 +181,7 @@ public:
void loadCart();
void showKeys();
const char *parser();
+ const char *searchForString(const char *topic, const char *text);
// from newplace.cpp
void getUnderCentre();
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index a4eeeacd2f..4a0611d594 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -104,50 +104,6 @@ endofdir2:
scrollMonitor();
}
-void DreamGenContext::searchForString() {
- STACK_CHECK;
- dl = es.byte(di);
- cx = di;
-restartlook:
- di = cx;
- bx = si;
- dh = 0;
-keeplooking:
- _lodsb();
- makeCaps();
- _cmp(al, '*');
- if (flags.z())
- goto notfound;
- _cmp(dl, '=');
- if (!flags.z())
- goto nofindingtopic;
- _cmp(al, 34);
- if (flags.z())
- goto notfound;
-nofindingtopic:
- ah = es.byte(di);
- _cmp(al, dl);
- if (!flags.z())
- goto notbracket;
- _inc(dh);
- _cmp(dh, 2);
- if (flags.z())
- goto complete;
-notbracket:
- _cmp(al, ah);
- if (!flags.z())
- goto restartlook;
- _inc(di);
- goto keeplooking;
-complete:
- es = ds;
- al = 0;
- bx = si;
- return;
-notfound:
- al = 1;
-}
-
void DreamGenContext::__start() {
static const uint8 src[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x13, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 48b413807c..d4778693b1 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -417,7 +417,6 @@ public:
void dirFile();
void dreamweb();
- void searchForString();
};
} // End of namespace DreamGen
diff --git a/engines/dreamweb/monitor.cpp b/engines/dreamweb/monitor.cpp
index db3401e078..f1b870d9c0 100644
--- a/engines/dreamweb/monitor.cpp
+++ b/engines/dreamweb/monitor.cpp
@@ -662,5 +662,45 @@ const char *DreamBase::parser() {
return output;
}
+void DreamGenContext::searchForString() {
+ const char *topic = (const char*)es.ptr(di, 0);
+ const char *text = (const char*)ds.ptr(si, 0);
+ const char *found = searchForString(topic, text);
+ if (!found) {
+ al = 1;
+ } else {
+ es = ds;
+ bx = si + (found - text);
+ si = bx;
+ al = 0;
+ }
+}
+
+// input: es:di : topic
+// ds:si : monitor text
+const char *DreamBase::searchForString(const char *topic, const char *text) {
+ char delim = *topic;
+
+ while (true) {
+ const char *s = topic;
+ int delimCount = 0;
+
+ char c;
+ do {
+ c = makeCaps(*text++);
+
+ if (c == '*' || (delim == '=' && c == 34))
+ return 0;
+
+ if (c == delim) {
+ delimCount++;
+ if (delimCount == 2)
+ return text;
+ }
+
+ } while (c == *s++);
+ }
+}
+
} // End of namespace DreamGen
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 24a7c081b5..9cbb286022 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -93,5 +93,9 @@
void getKeyAndLogo();
void read();
void dirCom();
+ void searchForString();
+ const char *searchForString(const char *topic, const char *text) {
+ return DreamBase::searchForString(topic, text);
+ }
#endif