aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2011-12-25 04:51:18 +0200
committerFilippos Karapetis2011-12-25 04:53:26 +0200
commit652403021d7dbcceb672dd21b468d1667479fc8b (patch)
tree81b14e0d0152df06ef84dabfcffe1d3f0e8ae9cc
parenta1ffa11620fcd0ba48b5cc2c1ca505ca4baab436 (diff)
downloadscummvm-rg350-652403021d7dbcceb672dd21b468d1667479fc8b.tar.gz
scummvm-rg350-652403021d7dbcceb672dd21b468d1667479fc8b.tar.bz2
scummvm-rg350-652403021d7dbcceb672dd21b468d1667479fc8b.zip
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.
-rwxr-xr-xdevtools/tasmrecover/tasm-recover1
-rw-r--r--engines/dreamweb/dreamgen.cpp48
-rw-r--r--engines/dreamweb/dreamgen.h1
-rw-r--r--engines/dreamweb/object.cpp64
-rw-r--r--engines/dreamweb/structs.h6
-rw-r--r--engines/dreamweb/stubs.h5
6 files changed, 69 insertions, 56 deletions
diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 9cacf01ea3..eb10c886fc 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 e321c50993..7416e1bafb 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 7717c7fb1c..d8270efdc3 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 ac5f3132b6..7e1ba1c2a3 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 4d1b1420f9..5d93d1d99f 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 921b8ed2eb..09a68682a7 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();