[Scummvm-cvs-logs] scummvm master -> 2cd0b29de182be4f01caddaa4e66582ab780bcd4

wjp wjp at usecode.org
Mon Dec 26 21:58:45 CET 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
2cd0b29de1 DREAMWEB: Convert searchForString


Commit: 2cd0b29de182be4f01caddaa4e66582ab780bcd4
    https://github.com/scummvm/scummvm/commit/2cd0b29de182be4f01caddaa4e66582ab780bcd4
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-26T12:58:17-08:00

Commit Message:
DREAMWEB: Convert searchForString

Changed paths:
    devtools/tasmrecover/tasm-recover
    engines/dreamweb/dreambase.h
    engines/dreamweb/dreamgen.cpp
    engines/dreamweb/dreamgen.h
    engines/dreamweb/monitor.cpp
    engines/dreamweb/stubs.h



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 57674d2..f82b6a0 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -817,6 +817,7 @@ generator = cpp(context, "DreamGen", blacklist = [
 	'scrollmonitor',
 	'searchforfiles',
 	'searchforsame',
+	'searchforstring',
 	'security',
 	'seecommandtail',
 	'selectlocation',
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 1502e39..d9b77c1 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 a4eeeac..4a0611d 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 48b4138..d477869 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 db3401e..f1b870d 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 24a7c08..9cbb286 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






More information about the Scummvm-git-logs mailing list