aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb/object.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2011-12-25 04:51:18 +0200
committerFilippos Karapetis2011-12-25 04:53:26 +0200
commit652403021d7dbcceb672dd21b468d1667479fc8b (patch)
tree81b14e0d0152df06ef84dabfcffe1d3f0e8ae9cc /engines/dreamweb/object.cpp
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.
Diffstat (limited to 'engines/dreamweb/object.cpp')
-rw-r--r--engines/dreamweb/object.cpp64
1 files changed, 61 insertions, 3 deletions
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