[Scummvm-cvs-logs] scummvm master -> b9839635eab502b640c29e23bdbb20240b2bf440

wjp wjp at usecode.org
Sat Dec 24 12:24:19 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:
b9839635ea DREAMWEB: Convert getObTextStart


Commit: b9839635eab502b640c29e23bdbb20240b2bf440
    https://github.com/scummvm/scummvm/commit/b9839635eab502b640c29e23bdbb20240b2bf440
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-24T03:23:24-08:00

Commit Message:
DREAMWEB: Convert getObTextStart

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



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index b75b0d3..e519aeb 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -479,6 +479,7 @@ generator = cpp(context, "DreamGen", blacklist = [
 	'getnamepos',
 	'getnextword',
 	'getnumber',
+	'getobtextstart',
 	'getopenedsize',
 	'getpersframe',
 	'getreelframeax',
@@ -748,6 +749,7 @@ generator = cpp(context, "DreamGen", blacklist = [
 	'saveposition',
 	'saveseg',
 	'scanfornames',
+	'scanforsame',
 	'screenupdate',
 	'scrollmonitor',
 	'security',
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 7ba8a93..4dc537c 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -188,6 +188,7 @@ public:
 	void deleteExFrame(uint8 frameNum);
 	void deleteExText(uint8 textNum);
 	void purgeALocation(uint8 index);
+	const uint8 *getObTextStart();
 
 	// from pathfind.cpp
 	void turnPathOn(uint8 param);
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 17f862c..bcb45f5 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -284,53 +284,6 @@ findopen2a:
 		goto findopen1a;
 }
 
-void DreamGenContext::getObTextStart() {
-	STACK_CHECK;
-	es = data.word(kFreedesc);
-	si = (0);
-	cx = (0+(82*2));
-	_cmp(data.byte(kObjecttype), 2);
-	if (flags.z())
-		goto describe;
-	es = data.word(kSetdesc);
-	si = (0);
-	cx = (0+(130*2));
-	_cmp(data.byte(kObjecttype), 1);
-	if (flags.z())
-		goto describe;
-	es = data.word(kExtras);
-	si = (0+2080+30000+(16*114));
-	cx = (0+2080+30000+(16*114)+((114+2)*2));
-describe:
-	al = data.byte(kCommand);
-	ah = 0;
-	_add(ax, ax);
-	_add(si, ax);
-	ax = es.word(si);
-	_add(ax, cx);
-	si = ax;
-	bx = ax;
-tryagain:
-	push(si);
-	findNextColon();
-	al = es.byte(si);
-	cx = si;
-	si = pop();
-	_cmp(data.byte(kObjecttype), 1);
-	if (!flags.z())
-		return /* (cantmakeoneup) */;
-	_cmp(al, 0);
-	if (flags.z())
-		goto findsometext;
-	_cmp(al, ':');
-	if (flags.z())
-		goto findsometext;
-	return;
-findsometext:
-	searchForSame();
-	goto tryagain;
-}
-
 void DreamGenContext::searchForSame() {
 	STACK_CHECK;
 	si = cx;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index b620b21..2df23e4 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -455,7 +455,6 @@ public:
 #include "stubs.h" // Allow hand-reversed functions to have a signature different than void f()
 
 	void getPersonText();
-	void getObTextStart();
 	void checkObjectSize();
 	void doSomeTalk();
 	void outOfOpen();
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index cdd6120..8e7ade4 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -636,4 +636,73 @@ void DreamBase::purgeALocation(uint8 index) {
 	}
 }
 
+const uint8 *DreamBase::getObTextStart() {
+	uint16 textSeg, textDatOff, textOff;
+	if (data.byte(kObjecttype) == kFreeObjectType) {
+		textSeg = data.word(kFreedesc);
+		textDatOff = kFreetextdat;
+		textOff = kFreetext;
+	} else if (data.byte(kObjecttype) == kSetObjectType1) {
+		textSeg = data.word(kSetdesc);
+		textDatOff = kSettextdat;
+		textOff = kSettext;
+	} else {
+		textSeg = data.word(kExtras);
+		textDatOff = kExtextdat;
+		textOff = kExtext;
+	}
+	const uint8 *textBase = getSegment(textSeg).ptr(textOff, 0);
+	const uint8 *text = textBase + getSegment(textSeg).word(textDatOff + 2*data.byte(kCommand));
+
+	if (data.byte(kObjecttype) != kSetObjectType1)
+		return text;
+
+	const uint8 *obname = text;
+	while (true) {
+		const uint8 *start = text;
+		findNextColon(&text);
+
+		// Not an empty description string?
+		if (*text != 0 && *text != ':')
+			return start;
+
+		// If the description string (of a SetObjectType1 object) is empty,
+		// look for an object with the same name.
+		// Example: Eden's garage door outside has two parts. The right part
+		// has no description of its own but uses that of the left part.
+
+		bool found = false;
+		do {
+			text++;
+			uint8 c = *obname;
+
+			// scan for matching first character
+			while (*text != c) {
+				text++;
+
+				// arbitrary give-up counter
+				if (text - (textBase - textOff) >= 8000) {
+					warning("Object description for %d/%d not found", data.byte(kObjecttype), data.byte(kCommand));
+					return obname;
+				}
+			}
+
+			// found matching first character, so match the rest
+			const uint8 *s1 = obname;
+			const uint8 *s2 = text;
+			do {
+				s1++;
+				s2++;
+			} while (*s1 != ':' && *s1 != 0 && *s1 == *s2);
+
+			if (*s1 == ':' || *s1 == 0)
+				found = true; // (prefix) matched the entire object name
+		} while (!found);
+
+		// We found an object with the same name. The next loop iteration
+		// will check if this one again has an empty description.
+	}
+}
+
+
 } // End of namespace DreamGen
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 09c8b36..f15325e 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -1875,16 +1875,6 @@ uint8 DreamBase::findNextColon(const uint8 **string) {
 	return c;
 }
 
-const uint8 *DreamGenContext::getObTextStartCPP() {
-	push(es);
-	push(si);
-	getObTextStart();
-	const uint8 *result = es.ptr(si, 0);
-	si = pop();
-	es = pop();
-	return result;
-}
-
 void DreamGenContext::enterSymbol() {
 	data.byte(kManisoffscreen) = 1;
 	getRidOfReels();
@@ -2906,7 +2896,7 @@ void DreamGenContext::obsThatDoThings() {
 }
 
 void DreamGenContext::describeOb() {
-	const uint8 *obText = getObTextStartCPP();
+	const uint8 *obText = getObTextStart();
 	uint16 y = 92;
 	if (data.byte(kForeignrelease) && data.byte(kObjecttype) == kSetObjectType1)
 		y = 82;
@@ -3673,7 +3663,7 @@ void DreamGenContext::lookAtCard() {
 	loadKeypad();
 	createPanel2();
 	showFrame(tempGraphics(), 160, 80, 42, 128);
-	const uint8 *obText = getObTextStartCPP();
+	const uint8 *obText = getObTextStart();
 	findNextColon(&obText);
 	findNextColon(&obText);
 	findNextColon(&obText);
diff --git a/engines/dreamweb/use.cpp b/engines/dreamweb/use.cpp
index aa7c2bd..e891298 100644
--- a/engines/dreamweb/use.cpp
+++ b/engines/dreamweb/use.cpp
@@ -140,7 +140,7 @@ void DreamGenContext::useRoutine() {
 	}
 
 	delPointer();
-	const uint8 *obText = getObTextStartCPP();
+	const uint8 *obText = getObTextStart();
 	if (findNextColon(&obText) != 0) {
 		if (findNextColon(&obText) != 0) {
 			if (*obText != 0) {
@@ -175,7 +175,7 @@ void DreamGenContext::useText(const uint8 *string) {
 }
 
 void DreamGenContext::showFirstUse() {
-	const uint8 *obText = getObTextStartCPP();
+	const uint8 *obText = getObTextStart();
 	findNextColon(&obText);
 	findNextColon(&obText);
 	useText(obText);
@@ -183,7 +183,7 @@ void DreamGenContext::showFirstUse() {
 }
 
 void DreamGenContext::showSecondUse() {
-	const uint8 *obText = getObTextStartCPP();
+	const uint8 *obText = getObTextStart();
 	findNextColon(&obText);
 	findNextColon(&obText);
 	findNextColon(&obText);
@@ -1611,7 +1611,7 @@ void DreamGenContext::useCashCard() {
 	showMan();
 	uint16 y = (!data.byte(kForeignrelease)) ? 120 : 120 - 3;
 	showFrame(tempGraphics(), 114, y, 39, 0);
-	const uint8 *obText = getObTextStartCPP();
+	const uint8 *obText = getObTextStart();
 	findNextColon(&obText);
 	findNextColon(&obText);
 	y = 98;






More information about the Scummvm-git-logs mailing list