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

digitall digitall at scummvm.org
Sun Dec 25 23:29:10 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:
c7b1ec2198 DREAMWEB: Ported 'findfirstpath' to C++.


Commit: c7b1ec21980d622c138fa2dcac5a03f80aa415e1
    https://github.com/scummvm/scummvm/commit/c7b1ec21980d622c138fa2dcac5a03f80aa415e1
Author: D G Turner (digitall at scummvm.org)
Date: 2011-12-25T15:33:11-08:00

Commit Message:
DREAMWEB: Ported 'findfirstpath' to C++.

This conversion could do with a bit more work to remove the es/ax/cx
temp usage and clean up the code.

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



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index d3929af..daab0fa 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -447,6 +447,7 @@ generator = cpp(context, "DreamGen", blacklist = [
 	'finalframe',
 	'findallryan',
 	'findexobject',
+	'findfirstpath',
 	'findinvpos',
 	'findlen',
 	'findnextcolon',
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 32bb520..e922911 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -790,49 +790,6 @@ flunkedit:
 	dl = 255;
 }
 
-void DreamGenContext::findFirstPath() {
-	STACK_CHECK;
-	push(ax);
-	bx = (0);
-	es = data.word(kReels);
-	al = data.byte(kRoomnum);
-	ah = 0;
-	cx = 144;
-	_mul(cx);
-	_add(bx, ax);
-	cx = pop();
-	dl = 0;
-fpathloop:
-	ax = es.word(bx+2);
-	_cmp(ax, 0x0ffff);
-	if (flags.z())
-		goto nofirst;
-	_cmp(cl, al);
-	if (flags.c())
-		goto nofirst;
-	_cmp(ch, ah);
-	if (flags.c())
-		goto nofirst;
-	ax = es.word(bx+4);
-	_cmp(cl, al);
-	if (!flags.c())
-		goto nofirst;
-	_cmp(ch, ah);
-	if (!flags.c())
-		goto nofirst;
-	goto gotfirst;
-nofirst:
-	_add(bx, 8);
-	_inc(dl);
-	_cmp(dl, 12);
-	if (!flags.z())
-		goto fpathloop;
-	al = 0;
-	return;
-gotfirst:
-	al = es.byte(bx+6);
-}
-
 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 45589ca..4d6946e 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -454,7 +454,6 @@ public:
 #include "stubs.h" // Allow hand-reversed functions to have a signature different than void f()
 
 	void dirCom();
-	void findFirstPath();
 	void getAnyAd();
 	void getFreeAd();
 	void dirFile();
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index c202ac7..84829bf 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -341,6 +341,32 @@ void DreamGenContext::openOb() {
 	_openChangeSize = getOpenedSlotCount() * kItempicsize + kInventx;
 }
 
+uint8 DreamGenContext::findFirstPath(uint16 param) {
+	es = data.word(kReels);
+	uint16 ptr = 144 * data.byte(kRoomnum);
+	// TODO: Replace ax, cx usage with temporary uint8/16 variables...
+	cx = param;
+
+	for (uint8 pathLoop = 0; pathLoop < 12; pathLoop++, ptr += 8) {
+		ax = es.word(ptr+2);
+
+		if (ax == 0x0ffff)
+			continue; // "nofirst"
+
+		if (cl < al || ch < ah)
+			continue; // "nofirst"
+
+		ax = es.word(ptr+4);
+
+		if (cl > al || ch > ah)
+			continue; // "nofirst"
+
+		return es.byte(ptr+6); // "gotfirst"
+	}
+
+	return 0;
+}
+
 void DreamGenContext::identifyOb() {
 	if (data.word(kWatchingtime) != 0) {
 		blank();
@@ -362,8 +388,7 @@ void DreamGenContext::identifyOb() {
 	data.byte(kPointerspath) = dl;
 	ax = pop();
 	push(ax);
-	findFirstPath();
-	data.byte(kPointerfirstpath) = al;
+	data.byte(kPointerfirstpath) = findFirstPath(ax);
 	ax = pop();
 
 	byte x = al;
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 148436e..62259a1 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -172,6 +172,7 @@
 	void checkObjectSize();
 	bool checkObjectSizeCPP();
 	void openOb();
+	uint8 findFirstPath(uint16 param);
 	void identifyOb();
 	void selectOb();
 	void findInvPos();






More information about the Scummvm-git-logs mailing list