aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/dreamweb/dreambase.h5
-rw-r--r--engines/dreamweb/dreamgen.cpp143
-rw-r--r--engines/dreamweb/dreamgen.h4
-rw-r--r--engines/dreamweb/object.cpp86
-rw-r--r--engines/dreamweb/people.cpp2
-rw-r--r--engines/dreamweb/stubs.cpp2
-rw-r--r--engines/dreamweb/stubs.h16
7 files changed, 108 insertions, 150 deletions
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 6f78bcad07..eae1d05902 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -137,6 +137,10 @@ public:
void findAllRyan(uint8 *inv);
void obToInv(uint8 index, uint8 flag, uint16 x, uint16 y);
void obPicture();
+ void removeObFromInv();
+ void deleteExObject(uint8 index);
+ void deleteExFrame(uint8 frameNum);
+ void deleteExText(uint8 textNum);
// from pathfind.cpp
void turnPathOn(uint8 param);
@@ -417,6 +421,7 @@ public:
void hangOnCurs(uint16 frameCount);
const uint8 *findObName(uint8 type, uint8 index);
void copyName(uint8 type, uint8 index, uint8 *dst);
+ uint16 findExObject(const char *id);
// from use.cpp
void placeFreeObject(uint8 index);
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 6034e0ea69..6d303e62bf 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -985,18 +985,6 @@ notinlift:
es.byte(bx) = al;
}
-void DreamGenContext::removeObFromInv() {
- STACK_CHECK;
- _cmp(data.byte(kCommand), 100);
- if (flags.z())
- return /* (obnotexist) */;
- getAnyAd();
- di = bx;
- cl = data.byte(kCommand);
- ch = 0;
- deleteExObject();
-}
-
void DreamGenContext::selectOpenOb() {
STACK_CHECK;
al = data.byte(kCommand);
@@ -1466,137 +1454,6 @@ cantpurge2:
goto lookforpurge2;
}
-void DreamGenContext::deleteExObject() {
- STACK_CHECK;
- push(cx);
- push(cx);
- push(cx);
- push(cx);
- al = 255;
- cx = 16;
- _stosb(cx, true);
- ax = pop();
- cl = al;
- _add(al, al);
- _add(al, cl);
- deleteExFrame();
- ax = pop();
- cl = al;
- _add(al, al);
- _add(al, cl);
- _inc(al);
- deleteExFrame();
- ax = pop();
- deleteExText();
- bx = pop();
- bh = bl;
- bl = 4;
- di = (0+2080+30000);
- cx = 0;
-deleteconts:
- _cmp(es.word(di+2), bx);
- if (!flags.z())
- goto notinsideex;
- push(bx);
- push(cx);
- push(di);
- deleteExObject();
- di = pop();
- cx = pop();
- bx = pop();
-notinsideex:
- _add(di, 16);
- _inc(cx);
- _cmp(cx, (114));
- if (!flags.z())
- goto deleteconts;
-}
-
-void DreamGenContext::deleteExFrame() {
- STACK_CHECK;
- di = (0);
- ah = 0;
- _add(ax, ax);
- _add(di, ax);
- _add(ax, ax);
- _add(di, ax);
- al = es.byte(di);
- ah = 0;
- cl = es.byte(di+1);
- ch = 0;
- _mul(cx);
- si = es.word(di+2);
- push(si);
- _add(si, (0+2080));
- cx = (30000);
- _sub(cx, es.word(di+2));
- di = si;
- _add(si, ax);
- push(ax);
- ds = es;
- _movsb(cx, true);
- bx = pop();
- _sub(data.word(kExframepos), bx);
- si = pop();
- cx = (114)*3;
- di = (0);
-shuffleadsdown:
- ax = es.word(di+2);
- _cmp(ax, si);
- if (flags.c())
- goto beforethisone;
- _sub(ax, bx);
-beforethisone:
- es.word(di+2) = ax;
- _add(di, 6);
- if (--cx)
- goto shuffleadsdown;
-}
-
-void DreamGenContext::deleteExText() {
- STACK_CHECK;
- di = (0+2080+30000+(16*114));
- ah = 0;
- _add(ax, ax);
- _add(di, ax);
- ax = es.word(di);
- si = ax;
- di = ax;
- _add(si, (0+2080+30000+(16*114)+((114+2)*2)));
- _add(di, (0+2080+30000+(16*114)+((114+2)*2)));
- ax = 0;
-findlenextext:
- cl = es.byte(si);
- _inc(ax);
- _inc(si);
- _cmp(cl, 0);
- if (!flags.z())
- goto findlenextext;
- cx = (18000);
- bx = si;
- _sub(bx, (0+2080+30000+(16*114)+((114+2)*2)));
- push(bx);
- push(ax);
- _sub(cx, bx);
- _movsb(cx, true);
- bx = pop();
- _sub(data.word(kExtextpos), bx);
- si = pop();
- cx = (114);
- di = (0+2080+30000+(16*114));
-shuffletextads:
- ax = es.word(di);
- _cmp(ax, si);
- if (flags.c())
- goto beforethistext;
- _sub(ax, bx);
-beforethistext:
- es.word(di) = ax;
- _add(di, 2);
- if (--cx)
- goto shuffletextads;
-}
-
void DreamGenContext::startTalk() {
STACK_CHECK;
data.byte(kTalkmode) = 0;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 7f1601e5f6..b7a644fe1f 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -482,9 +482,7 @@ public:
void getAnyAd();
void reminders();
void inToInv();
- void deleteExText();
void getFreeAd();
- void removeObFromInv();
void dirFile();
void pickupConts();
void fadeUpMon();
@@ -496,13 +494,11 @@ public:
void getSetAd();
void nextColon();
void findOpenPos();
- void deleteExFrame();
void searchForSame();
void rollEm();
void lookAtPlace();
void findAllOpen();
void fillOpen();
- void deleteExObject();
void getEitherAd();
void dropObject();
void useOpened();
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index 53ecc0c362..384e001b5e 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -477,4 +477,90 @@ void DreamGenContext::setPickup() {
workToScreenM();
}
+void DreamGenContext::deleteExFrame() {
+ deleteExFrame(al);
+}
+
+void DreamBase::deleteExFrame(uint8 frameNum) {
+ Frame *frame = (Frame *)getSegment(data.word(kExtras)).ptr(kExframedata + sizeof(Frame)*frameNum, sizeof(Frame));
+
+ uint16 frameSize = frame->width * frame->height;
+ // Note: the original asm didn't subtract frameSize from remainder
+ uint16 remainder = kExframeslen - frame->ptr() - frameSize;
+ uint16 startOff = kExframes + frame->ptr();
+ uint16 endOff = startOff + frameSize;
+
+ // Shift frame data after this one down
+ memmove(getSegment(data.word(kExtras)).ptr(startOff, remainder), getSegment(data.word(kExtras)).ptr(endOff, remainder), remainder);
+
+ // Combined frame data is now frameSize smaller
+ data.word(kExframepos) -= frameSize;
+
+ // Adjust all frame pointers pointing into the shifted data
+ for (unsigned int i = 0; i < 3*kNumexobjects; ++i) {
+ frame = (Frame *)getSegment(data.word(kExtras)).ptr(kExframedata + sizeof(Frame)*i, sizeof(Frame));
+ if (frame->ptr() >= startOff)
+ frame->setPtr(frame->ptr() - frameSize);
+ }
+}
+
+void DreamGenContext::deleteExText() {
+ deleteExText(al);
+}
+
+void DreamBase::deleteExText(uint8 textNum) {
+ uint16 offset = getSegment(data.word(kExtras)).word(kExtextdat + 2*textNum);
+
+ uint16 startOff = kExtext + offset;
+ uint16 textSize = strlen((char *)getSegment(data.word(kExtras)).ptr(startOff, 0)) + 1;
+ uint16 endOff = startOff + textSize;
+ uint16 remainder = kExtextlen - offset - textSize;
+
+ // Shift text data after this one down
+ memmove(getSegment(data.word(kExtras)).ptr(startOff, remainder), getSegment(data.word(kExtras)).ptr(endOff, remainder), remainder);
+
+ // Combined text data is now frameSize smaller
+ data.word(kExtextpos) -= textSize;
+
+ // Adjust all text pointers pointing into the shifted data
+ for (unsigned int i = 0; i < kNumexobjects; ++i) {
+ uint16 t = getSegment(data.word(kExtras)).word(kExtextdat + 2*i);
+ if (t >= offset + textSize)
+ getSegment(data.word(kExtras)).word(kExtextdat + 2*i) = t - textSize;
+ }
+}
+
+// This takes es:di and cl as input, but es:di always points to getExAd(cl)
+void DreamGenContext::deleteExObject() {
+ deleteExObject(cl);
+}
+
+void DreamBase::deleteExObject(uint8 index) {
+ DynObject *obj = getExAd(index);
+
+ memset(obj, 0xFF, sizeof(DynObject));
+
+ deleteExFrame(3*index);
+ deleteExFrame(3*index + 1);
+
+ deleteExText(index);
+
+ for (uint8 i = 0; i < kNumexobjects; ++i) {
+ DynObject *t = getExAd(index);
+ // Is this object contained in the one we've just deleted?
+ if (t->mapad[0] == 4 && t->mapad[1] == index)
+ deleteExObject(i);
+ }
+}
+
+void DreamBase::removeObFromInv() {
+ if (data.byte(kCommand) == 100)
+ return; // object doesn't exit
+
+ assert(data.byte(kObjecttype) == kExObjectType);
+
+ deleteExObject(data.byte(kCommand));
+}
+
+
} // End of namespace DreamGen
diff --git a/engines/dreamweb/people.cpp b/engines/dreamweb/people.cpp
index 81de17cbac..20d67763ad 100644
--- a/engines/dreamweb/people.cpp
+++ b/engines/dreamweb/people.cpp
@@ -48,7 +48,7 @@ static void (DreamGenContext::*reelCallbacks[57])(ReelRoutine &) = {
&DreamBase::gates, &DreamBase::introMagic3,
&DreamBase::introMonks1, &DreamBase::candles,
&DreamBase::introMonks2, &DreamBase::handClap,
- &DreamBase::monkAndRyan, &DreamGenContext::endGameSeq,
+ &DreamBase::monkAndRyan, &DreamBase::endGameSeq,
&DreamBase::priest, &DreamBase::madman,
&DreamBase::madmansTelly, &DreamBase::alleyBarkSound,
&DreamBase::foghornSound, &DreamBase::carParkDrip,
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 51587f1bde..6b7e9a7784 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -1734,7 +1734,7 @@ void DreamGenContext::findExObject() {
bx = kExdata + al * 16;
}
-uint16 DreamGenContext::findExObject(const char *id) {
+uint16 DreamBase::findExObject(const char *id) {
for (uint16 index = 0; index < kNumexobjects; index++) {
if (objectMatches(getExAd(index), id))
return index;
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 3e61367e2d..aeda662283 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -349,7 +349,9 @@
void lookAtCard();
bool execCommand();
void findExObject();
- uint16 findExObject(const char *id);
+ uint16 findExObject(const char *id) {
+ return DreamBase::findExObject(id);
+ }
void isRyanHolding();
bool isRyanHolding(const char *id) {
return DreamBase::isRyanHolding(id);
@@ -371,5 +373,17 @@
void showDiaryKeys();
void showKeys();
void getKeyAndLogo();
+ void deleteExObject();
+ void deleteExObject(uint8 index) {
+ DreamBase::deleteExObject(index);
+ }
+ void deleteExFrame();
+ void deleteExFrame(uint8 frameNum) {
+ DreamBase::deleteExFrame(frameNum);
+ }
+ void deleteExText();
+ void deleteExText(uint8 textNum) {
+ DreamBase::deleteExText(textNum);
+ }
#endif