[Scummvm-cvs-logs] scummvm master -> 652403021d7dbcceb672dd21b468d1667479fc8b

bluegr md5 at scummvm.org
Sun Dec 25 03:53:56 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:
652403021d DREAMWEB: Convert 'checkobjectsize' to C++


Commit: 652403021d7dbcceb672dd21b468d1667479fc8b
    https://github.com/scummvm/scummvm/commit/652403021d7dbcceb672dd21b468d1667479fc8b
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2011-12-24T18:53:26-08:00

Commit Message:
DREAMWEB: Convert 'checkobjectsize' to C++

Also, renamed getOpenedSizeCPP() to getSlotCount(). Special thanks to
wjp for his help and for examining the behavior of a fallback case.

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



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 9cacf01..eb10c88 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -315,6 +315,7 @@ generator = cpp(context, "DreamGen", blacklist = [
 	'checkifset',
 	'checkinput',
 	'checkinside',
+	'checkobjectsize',
 	'checkone',
 	'checksoundint',
 	'checkspeed',
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index e321c50..7416e1b 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -677,54 +677,6 @@ sizeok1:
 	delPointer();
 }
 
-void DreamGenContext::checkObjectSize() {
-	STACK_CHECK;
-	getOpenedSize();
-	push(ax);
-	al = data.byte(kItemframe);
-	getEitherAd();
-	al = es.byte(bx+9);
-	cx = pop();
-	_cmp(al, 255);
-	if (!flags.z())
-		goto notunsized;
-	al = 6;
-notunsized:
-	_cmp(al, 100);
-	if (!flags.c())
-		goto specialcase;
-	_cmp(cl, 100);
-	if (flags.c())
-		goto isntspecial;
-	errorMessage3();
-	goto sizewrong;
-isntspecial:
-	_cmp(cl, al);
-	if (!flags.c())
-		goto sizeok;
-specialcase:
-	_sub(al, 100);
-	_cmp(cl, 100);
-	if (!flags.c())
-		goto bothspecial;
-	_cmp(cl, al);
-	if (!flags.c())
-		goto sizeok;
-	errorMessage2();
-	goto sizewrong;
-bothspecial:
-	_sub(cl, 100);
-	_cmp(al, cl);
-	if (flags.z())
-		goto sizeok;
-	errorMessage3();
-sizewrong:
-	al = 1;
-	return;
-sizeok:
-	al = 0;
-}
-
 void DreamGenContext::outOfOpen() {
 	STACK_CHECK;
 	_cmp(data.byte(kOpenedob), 255);
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 7717c7f..d8270ef 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -454,7 +454,6 @@ public:
 	void __start();
 #include "stubs.h" // Allow hand-reversed functions to have a signature different than void f()
 
-	void checkObjectSize();
 	void doSomeTalk();
 	void outOfOpen();
 	void dirCom();
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index ac5f313..7e1ba1c 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -281,7 +281,7 @@ void DreamBase::getBackFromOb() {
 }
 
 void DreamGenContext::getOpenedSize() {
-	//ax = getOpenedSizeCPP();
+	//ax = getOpenedSlotCount();
 
 	// We need to call the ASM-style versions of get*Ad, as these also set
 	// bx and es
@@ -304,7 +304,7 @@ void DreamGenContext::getOpenedSize() {
 	}
 }
 
-byte DreamGenContext::getOpenedSizeCPP() {
+byte DreamGenContext::getOpenedSlotCount() {
 	byte obj = data.byte(kOpenedob);
 	switch (data.byte(kOpenedtype)) {
 	case 4:
@@ -316,6 +316,18 @@ byte DreamGenContext::getOpenedSizeCPP() {
 	}
 }
 
+byte DreamGenContext::getOpenedSlotSize() {
+	byte obj = data.byte(kOpenedob);
+	switch (data.byte(kOpenedtype)) {
+	case 4:
+		return getExAd(obj)->slotSize;
+	case 2:
+		return getFreeAd(obj)->slotSize;
+	default:
+		return getSetAd(obj)->slotSize;
+	}
+}
+
 void DreamGenContext::openOb() {
 	uint8 commandLine[64] = "OBJECT NAME ONE                         ";
 
@@ -326,7 +338,7 @@ void DreamGenContext::openOb() {
 	al = printDirect(commandLine, data.word(kLastxpos) + 5, kInventy+86, 220, false);
 
 	fillOpen();
-	_openChangeSize = getOpenedSizeCPP() * kItempicsize + kInventx;
+	_openChangeSize = getOpenedSlotCount() * kItempicsize + kInventx;
 }
 
 void DreamGenContext::identifyOb() {
@@ -748,4 +760,50 @@ void DreamBase::dropObject() {
 	object->currentLocation = data.byte(kReallocation);
 }
 
+void DreamGenContext::checkObjectSize() {
+	al = checkObjectSizeCPP() ? 0 : 1;
+}
+
+bool DreamGenContext::checkObjectSizeCPP() {
+	byte containerSize = getOpenedSlotSize();
+	DynObject *object = getEitherAdCPP();
+	// If there is no size defined for the object in the editor, set its size
+	// to 6. This could be a bad idea, according to the original source.
+	byte objectSize = (object->objectSize != 255) ? object->objectSize : 6;
+
+	if (objectSize >= 100) {
+		// Special case
+		if (containerSize >= 100) {
+			// Both objects are special
+			if (containerSize == objectSize) {
+				return true;
+			} else {
+				errorMessage3();
+				return false;
+			}
+		} else {
+			if (containerSize >= (byte)(objectSize - 100)) {
+				return true;
+			} else {
+				errorMessage2();
+				return false;
+			}
+		}
+	} else if (containerSize >= 100) {	// The current object isn't special, but the container object is
+		errorMessage3();
+		return false;
+	} else if (containerSize >= objectSize) {
+		return true;
+	} else {
+		// The original continues here to the special case above. It checks if
+		// cl (containerSize) < al (objectSize) and continues if this is so.
+		// However, in this case, the code subtracts 100 from objectSize, which
+		// was between 0 - 99, so it now is between 156 and 255. containerSize is
+		// smaller than 100, so comparing it with objectSize will always be true,
+		// thus this bit of code always falls through to the errorMessage2() case.
+		errorMessage2();
+		return false;
+	}
+}
+
 } // End of namespace DreamGen
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h
index 4d1b142..5d93d1d 100644
--- a/engines/dreamweb/structs.h
+++ b/engines/dreamweb/structs.h
@@ -120,9 +120,9 @@ struct DynObject {
 	uint8 currentLocation;
 	uint8 index;
 	uint8 mapad[5];
-	uint8 slotSize;
-	uint8 slotCount;
-	uint8 b9;
+	uint8 slotSize;		// the size of an object's slots
+	uint8 slotCount;	// the number of slots of an object
+	uint8 objectSize;	// the size of an object
 	uint8 b10;
 	uint8 initialLocation;
 	uint8 id[4];
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 921b8ed..09a6868 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -185,7 +185,10 @@
 	void runEndSeq();
 	bool execCommand();
 	void getOpenedSize();
-	byte getOpenedSizeCPP();
+	byte getOpenedSlotSize();
+	byte getOpenedSlotCount();
+	void checkObjectSize();
+	bool checkObjectSizeCPP();
 	void openOb();
 	void identifyOb();
 	void useStereo();






More information about the Scummvm-git-logs mailing list