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

wjp wjp at usecode.org
Mon Dec 26 18:44:36 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:
c2a94132c8 DREAMWEB: Convert pickupConts


Commit: c2a94132c8adf8bec5914ca6fa2e312248e1c2bd
    https://github.com/scummvm/scummvm/commit/c2a94132c8adf8bec5914ca6fa2e312248e1c2bd
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-26T09:42:28-08:00

Commit Message:
DREAMWEB: Convert pickupConts

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/stubs.h



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index cd683d4..dc2874f 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -711,6 +711,7 @@ generator = cpp(context, "DreamGen", blacklist = [
 	'paneltomap',
 	'parseblaster',
 	'personnametext',
+	'pickupconts',
 	'pickupob',
 	'pitinterupt',
 	'pixelcheckset',
@@ -916,6 +917,7 @@ generator = cpp(context, "DreamGen", blacklist = [
 	'textformonk',
 	'titles',
 	'train',
+	'transfercontoex',
 	'transferinv',
 	'transfertext',
 	'transfertoex',
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 4b9919d..b134159 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -219,6 +219,8 @@ public:
 	void findAllOpen();
 	void fillOpen();
 	ObjectRef findInvPos();
+	void reExFromInv();
+	void swapWithInv();
 
 	// from pathfind.cpp
 	void turnPathOn(uint8 param);
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 424c4ab..356ebc8 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -73,75 +73,6 @@ void DreamGenContext::transferMap() {
 	_add(data.word(kExframepos), cx);
 }
 
-void DreamGenContext::pickupConts() {
-	STACK_CHECK;
-	al = ds.byte(si+7);
-	_cmp(al, 255);
-	if (flags.z())
-		return /* (notopenable) */;
-	al = data.byte(kItemframe);
-	ah = data.byte(kObjecttype);
-	dl = data.byte(kExpos);
-	es = data.word(kFreedat);
-	bx = 0;
-	cx = 0;
-pickupcontloop:
-	push(cx);
-	push(es);
-	push(bx);
-	push(dx);
-	push(ax);
-	_cmp(es.byte(bx+2), ah);
-	if (!flags.z())
-		goto notinsidethis;
-	_cmp(es.byte(bx+3), al);
-	if (!flags.z())
-		goto notinsidethis;
-	data.byte(kItemtotran) = cl;
-	transferConToEx();
-notinsidethis:
-	ax = pop();
-	dx = pop();
-	bx = pop();
-	es = pop();
-	cx = pop();
-	_add(bx, 16);
-	_inc(cx);
-	_cmp(cx, 80);
-	if (!flags.z())
-		goto pickupcontloop;
-}
-
-void DreamGenContext::transferConToEx() {
-	STACK_CHECK;
-	push(es);
-	push(bx);
-	push(dx);
-	push(es);
-	push(bx);
-	getExPos();
-	si = pop();
-	ds = pop();
-	push(di);
-	cx = 8;
-	_movsw(cx, true);
-	di = pop();
-	dx = pop();
-	al = data.byte(kReallocation);
-	es.byte(di) = al;
-	es.byte(di+11) = al;
-	al = data.byte(kItemtotran);
-	es.byte(di+1) = al;
-	es.byte(di+3) = dl;
-	es.byte(di+2) = 4;
-	transferMap();
-	transferInv();
-	transferText();
-	si = pop();
-	ds = pop();
-	ds.byte(si+2) = 255;
-}
-
 void DreamGenContext::read() {
 	STACK_CHECK;
 	cx = 40;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 41c252e..0c61a60 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -425,13 +425,11 @@ public:
 #include "stubs.h" // Allow hand-reversed functions to have a signature different than void f()
 
 	void dirFile();
-	void pickupConts();
 	void transferMap();
 	void dreamweb();
 	void read();
 	void searchForString();
 	void parser();
-	void transferConToEx();
 };
 
 } // End of namespace DreamGen
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index 5d0fbab..9799ca4 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -712,7 +712,7 @@ void DreamBase::dropObject() {
 	object->currentLocation = data.byte(kReallocation);
 }
 
-bool DreamGenContext::checkObjectSizeCPP() {
+bool DreamGenContext::checkObjectSize() {
 	byte containerSize = getOpenedSlotSize();
 	DynObject *object = getEitherAdCPP();
 	// If there is no size defined for the object in the editor, set its size
@@ -774,7 +774,7 @@ void DreamGenContext::selectOpenOb() {
 	delPointer();
 }
 
-void DreamGenContext::reExFromInv() {
+void DreamBase::reExFromInv() {
 	ObjectRef objectId = findInvPos();
 	data.byte(kCommandtype) = objectId._type;
 	data.byte(kCommand)     = objectId._index;
@@ -782,7 +782,7 @@ void DreamGenContext::reExFromInv() {
 	data.byte(kPointermode) = 0;
 }
 
-void DreamGenContext::swapWithInv() {
+void DreamBase::swapWithInv() {
 	ObjectRef subject;
 	subject._type = data.byte(kObjecttype);
 	subject._index = data.byte(kItemframe);
@@ -868,7 +868,7 @@ void DreamGenContext::useOpened() {
 		return;
 	}
 
-	if (!checkObjectSizeCPP())
+	if (!checkObjectSize())
 		return;
 
 	data.byte(kPickup) = 0;
@@ -964,7 +964,7 @@ void DreamGenContext::swapWithOpen() {
 		return;
 	}
 
-	if (!checkObjectSizeCPP())
+	if (!checkObjectSize())
 		return;
 
 	byte prevType = data.byte(kObjecttype);
@@ -1012,9 +1012,8 @@ ObjectRef DreamBase::findOpenPos() {
 
 byte DreamGenContext::transferToEx() {
 	emergencyPurge();
-	getExPos();
+	DynObject *exObject = getExPos(); // Also sets es:di
 	byte pos = data.byte(kExpos);
-	DynObject *exObject = getExAd(pos);
 	DynObject *freeObject = getFreeAd(data.byte(kItemframe));
 	memcpy(exObject, freeObject, sizeof(DynObject));
 	exObject->currentLocation = data.byte(kReallocation);
@@ -1029,8 +1028,6 @@ byte DreamGenContext::transferToEx() {
 	transferText();
 	freeObject = getFreeAd(data.byte(kItemframe));
 	freeObject->mapad[0] = 254;
-	ds = data.word(kFreedat);
-	si = data.byte(kItemframe) * sizeof(DynObject);
 	pickupConts();
 	return pos;
 }
@@ -1078,4 +1075,39 @@ void DreamBase::findAllOpen() {
 	}
 }
 
+void DreamGenContext::pickupConts() {
+	assert(data.byte(kObjecttype) == kFreeObjectType);
+	const DynObject *obj = getFreeAd(data.byte(kItemframe));
+
+	if (obj->slotCount == 255)
+		return; // not openable
+
+	uint8 expos = data.byte(kExpos);
+
+	for (uint16 index = 0; index < 80; ++index) {
+		DynObject *freeObj = getFreeAd(index);
+
+		if (freeObj->mapad[0] != data.byte(kObjecttype))
+			continue;
+		if (freeObj->mapad[1] != data.byte(kItemframe))
+			continue;
+		data.byte(kItemtotran) = index;
+
+		DynObject *exObj = getExPos(); // Also sets es:di to exObj
+
+		memcpy(exObj, freeObj, sizeof(DynObject));
+		exObj->currentLocation = data.byte(kReallocation);
+		exObj->initialLocation = data.byte(kReallocation);
+		exObj->index = index;
+		exObj->mapad[0] = 4; // kExObjectType?
+		exObj->mapad[1] = expos;
+
+		transferMap();
+		transferInv();
+		transferText();
+
+		freeObj->mapad[0] = 0xFF;
+	}
+}
+
 } // End of namespace DreamGen
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 87bca3d..9351a01 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -1364,18 +1364,19 @@ void DreamBase::deleteTaken() {
 	}
 }
 
-void DreamGenContext::getExPos() {
+DynObject *DreamGenContext::getExPos() {
 	es = data.word(kExtras);
-	const DynObject *objects = (const DynObject *)getSegment(data.word(kExtras)).ptr(kExdata, sizeof(DynObject));
+	DynObject *objects = (DynObject *)getSegment(data.word(kExtras)).ptr(kExdata, sizeof(DynObject));
 	for (size_t i = 0; i < kNumexobjects; ++i) {
 		if (objects[i].mapad[0] == 0xff) {
 			data.byte(kExpos) = i;
 			di = kExdata + i * sizeof(DynObject);
-			return;
+			return &objects[i];
 		}
 	}
 	data.byte(kExpos) = kNumexobjects;
 	di = kExdata + kNumexobjects * sizeof(DynObject);
+	return 0;
 }
 
 void DreamBase::placeSetObject(uint8 index) {
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 5577c77..8bdc0b1 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -66,7 +66,7 @@
 	void walkAndExamine();
 	void obName(uint8 command, uint8 commandType);
 
-	void getExPos();
+	DynObject *getExPos();
 	bool checkIfSet(uint8 x, uint8 y);
 	void obToInv();
 	void obToInv(uint8 index, uint8 flag, uint16 x, uint16 y) {
@@ -118,7 +118,7 @@
 	void triggerMessage(uint16 index);
 	void processTrigger();
 	bool execCommand();
-	bool checkObjectSizeCPP();
+	bool checkObjectSize();
 	void identifyOb();
 	void selectOb();
 	void setPickup();
@@ -127,13 +127,12 @@
 	void inToInv();
 	void outOfInv();
 	void selectOpenOb();
-	void reExFromInv();
 	void useOpened();
 	void outOfOpen();
 	void swapWithOpen();
-	void swapWithInv();
 	void searchForFiles(uint16 segment);
 	byte transferToEx();
 	void dirCom();
+	void pickupConts();
 
 #endif






More information about the Scummvm-git-logs mailing list