[Scummvm-cvs-logs] scummvm master -> 7d5f6fedda6044efba4e0f3eadd413f6cd59a56e

tramboi bertrand_augereau at yahoo.fr
Wed Aug 24 15:48:32 CEST 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:
7d5f6fedda DREAMWEB: 'checkcoords' ported to C++


Commit: 7d5f6fedda6044efba4e0f3eadd413f6cd59a56e
    https://github.com/scummvm/scummvm/commit/7d5f6fedda6044efba4e0f3eadd413f6cd59a56e
Author: Bertrand Augereau (bertrand_augereau at yahoo.fr)
Date: 2011-08-24T06:44:20-07:00

Commit Message:
DREAMWEB: 'checkcoords' ported to C++
(Still has __dispatch_call dependency)

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



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 134292c..fa246f5 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -151,6 +151,7 @@ generator = cpp(context, "DreamGen", blacklist = [
 	'delpointer',
 	'showblink',
 	'dumpblink',
+	'checkcoords',
 	], skip_output = [
 	# These functions are processed but not output
 	'dreamweb',
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 3a819a0..2b717e1 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -15156,43 +15156,6 @@ alreadyrun:
 	data.byte(kLastweapon) = 8;
 }
 
-void DreamGenContext::checkcoords() {
-	STACK_CHECK;
-	_cmp(data.byte(kNewlocation), 255);
-	if (flags.z())
-		goto loop048;
-	return;
-loop048:
-	ax = cs.word(bx);
-	_cmp(ax, 0x0ffff);
-	if (flags.z())
-		return /* (nonefound) */;
-	push(bx);
-	_cmp(data.word(kMousex), ax);
-	if (flags.l())
-		goto over045;
-	ax = cs.word(bx+2);
-	_cmp(data.word(kMousex), ax);
-	if (!flags.l())
-		goto over045;
-	ax = cs.word(bx+4);
-	_cmp(data.word(kMousey), ax);
-	if (flags.l())
-		goto over045;
-	ax = cs.word(bx+6);
-	_cmp(data.word(kMousey), ax);
-	if (!flags.l())
-		goto over045;
-	ax = cs.word(bx+8);
-	__dispatch_call(ax);
-	ax = pop();
-	return;
-over045:
-	bx = pop();
-	_add(bx, 10);
-	goto loop048;
-}
-
 void DreamGenContext::identifyob() {
 	STACK_CHECK;
 	_cmp(data.word(kWatchingtime), 0);
@@ -18257,7 +18220,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
 		case addr_convnum: convnum(); break;
 		case addr_mainscreen: mainscreen(); break;
 		case addr_madmanrun: madmanrun(); break;
-		case addr_checkcoords: checkcoords(); break;
 		case addr_identifyob: identifyob(); break;
 		case addr_checkifset: checkifset(); break;
 		case addr_checkifex: checkifex(); break;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index c770bbb..300bfdd 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -130,7 +130,6 @@ public:
 	static const uint16 addr_checkifex = 0xc9e0;
 	static const uint16 addr_checkifset = 0xc9dc;
 	static const uint16 addr_identifyob = 0xc9d4;
-	static const uint16 addr_checkcoords = 0xc9d0;
 	static const uint16 addr_madmanrun = 0xc9cc;
 	static const uint16 addr_mainscreen = 0xc9c8;
 	static const uint16 addr_convnum = 0xc9c4;
@@ -1598,7 +1597,7 @@ public:
 	void showouterpad();
 	void getkeyandlogo();
 	void selectob();
-	void checkcoords();
+	//void checkcoords();
 	void dumpmenu();
 	void chewy();
 	void accesslighton();
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h
index fe908f5..1cb52ec 100644
--- a/engines/dreamweb/structs.h
+++ b/engines/dreamweb/structs.h
@@ -54,6 +54,22 @@ struct Sprite {
 	uint8  hidden;
 };
 
+struct RectWithCallback {
+	uint16 _xMin, _xMax;
+	uint16 _yMin, _yMax;
+	uint16 _callback;
+
+	uint16 xMin() const { return READ_LE_UINT16(&_xMin); }
+	uint16 xMax() const { return READ_LE_UINT16(&_xMax); }
+	uint16 yMin() const { return READ_LE_UINT16(&_yMin); }
+	uint16 yMax() const { return READ_LE_UINT16(&_yMax); }
+	uint16 callback() const { return READ_LE_UINT16(&_callback); }
+
+	bool contains(uint16 x, uint16 y) const {
+		return (x >= xMin()) && (x < xMax()) && (y >= yMin()) && (y < yMax());
+	}
+};
+
 struct SetObject {
 	uint8 b0;
 	uint8 b1;
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index ba47f1a..5cbce89 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -1308,6 +1308,25 @@ void DreamGenContext::dumpblink() {
 	multidump(44, 32, 16, 12);
 }
 
+void DreamGenContext::checkcoords() {
+	checkcoords((const RectWithCallback *)cs.ptr(bx, 0));
+}
+
+void DreamGenContext::checkcoords(const RectWithCallback *rectWithCallbacks) {
+	if (data.byte(kNewlocation) != 0xff)
+		return;
+
+	const RectWithCallback *rectWithCallback = rectWithCallbacks;
+	while (rectWithCallback->xMin() != 0xffff) {
+		if (rectWithCallback->contains(data.word(kMousex), data.word(kMousey))) {
+			// TODO : Explicit dispatching
+			__dispatch_call(rectWithCallback->callback());
+			return;
+		}
+		++rectWithCallback;
+	}
+}
+
 bool DreamGenContext::isCD() {
 	// The original sources has two codepaths depending if the game is 'if cd' or not
 	// This is a hack to guess which version to use with the assumption that if we have a cd version
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 332e8a0..2cd22ce 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -181,4 +181,6 @@
 	void delpointer();
 	void showblink();
 	void dumpblink();
+	void checkcoords();
+	void checkcoords(const RectWithCallback *rectWithCallbacks);
 






More information about the Scummvm-git-logs mailing list