aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb
diff options
context:
space:
mode:
authorFilippos Karapetis2011-12-26 16:10:28 +0200
committerFilippos Karapetis2011-12-26 16:10:28 +0200
commit63ba3988fff08911d2fecbf4808f5514e2fd420f (patch)
tree6808fe72bff97b202ba9bc44ffff00d9c472c460 /engines/dreamweb
parente311f678b989c2cf3eee03bb98c7c8deed46bddc (diff)
downloadscummvm-rg350-63ba3988fff08911d2fecbf4808f5514e2fd420f.tar.gz
scummvm-rg350-63ba3988fff08911d2fecbf4808f5514e2fd420f.tar.bz2
scummvm-rg350-63ba3988fff08911d2fecbf4808f5514e2fd420f.zip
DREAMWEB: Port 'transfertoex' to C++
Diffstat (limited to 'engines/dreamweb')
-rw-r--r--engines/dreamweb/dreamgen.cpp41
-rw-r--r--engines/dreamweb/dreamgen.h1
-rw-r--r--engines/dreamweb/object.cpp34
-rw-r--r--engines/dreamweb/stubs.h1
4 files changed, 29 insertions, 48 deletions
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 66438cfd04..9582ebe5a5 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -241,47 +241,6 @@ void DreamGenContext::getSetAd() {
es = data.word(kSetdat);
}
-void DreamGenContext::transferToEx() {
- STACK_CHECK;
- emergencyPurge();
- getExPos();
- al = data.byte(kExpos);
- push(ax);
- push(di);
- al = data.byte(kItemframe);
- ah = 0;
- bx = 16;
- _mul(bx);
- ds = data.word(kFreedat);
- si = ax;
- cx = 8;
- _movsw(cx, true);
- di = pop();
- al = data.byte(kReallocation);
- es.byte(di) = al;
- es.byte(di+11) = al;
- al = data.byte(kItemframe);
- es.byte(di+1) = al;
- es.byte(di+2) = 4;
- es.byte(di+3) = 255;
- al = data.byte(kLastinvpos);
- es.byte(di+4) = al;
- al = data.byte(kItemframe);
- data.byte(kItemtotran) = al;
- transferMap();
- transferInv();
- transferText();
- al = data.byte(kItemframe);
- ah = 0;
- bx = 16;
- _mul(bx);
- ds = data.word(kFreedat);
- si = ax;
- ds.byte(si+2) = 254;
- pickupConts();
- ax = pop();
-}
-
void DreamGenContext::pickupConts() {
STACK_CHECK;
al = ds.byte(si+7);
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index a292384826..0ecdf7210b 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -440,7 +440,6 @@ public:
void read();
void searchForString();
void getExAd();
- void transferToEx();
void parser();
void transferConToEx();
};
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index 10138acb78..daa45e67eb 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -446,8 +446,7 @@ void DreamGenContext::setPickup() {
if (data.byte(kObjecttype) != kExObjectType) {
data.byte(kItemframe) = data.byte(kCommand);
data.byte(kOpenedob) = 255;
- transferToEx();
- data.byte(kItemframe) = al;
+ data.byte(kItemframe) = transferToEx();
data.byte(kObjecttype) = kExObjectType;
DynObject *object = getExAd(data.byte(kItemframe));
object->mapad[0] = 20;
@@ -964,8 +963,7 @@ void DreamGenContext::outOfOpen() {
data.byte(kItemframe) = objectId & 0xFF;
if (data.byte(kObjecttype) != 4) {
- transferToEx();
- data.byte(kItemframe) = al;
+ data.byte(kItemframe) = transferToEx();
data.byte(kObjecttype) = 4;
}
@@ -1021,8 +1019,7 @@ void DreamGenContext::swapWithOpen() {
data.byte(kItemframe) = objectId & 0xFF;
if (data.byte(kObjecttype) != 4) {
- transferToEx();
- data.byte(kItemframe) = al;
+ data.byte(kItemframe) = transferToEx();
data.byte(kObjecttype) = 4;
}
@@ -1059,4 +1056,29 @@ uint16 DreamBase::findOpenPos() {
return pos * 2 + kOpeninvlist; // return the object position in the inventory data
}
+byte DreamGenContext::transferToEx() {
+ emergencyPurge();
+ getExPos();
+ 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);
+ exObject->initialLocation = data.byte(kReallocation);
+ exObject->index = data.byte(kItemframe);
+ exObject->mapad[0] = 4;
+ exObject->mapad[1] = 255;
+ exObject->mapad[2] = data.byte(kLastinvpos);
+ data.byte(kItemtotran) = data.byte(kItemframe);
+ transferMap();
+ transferInv();
+ transferText();
+ freeObject = getFreeAd(data.byte(kItemframe));
+ freeObject->mapad[0] = 254;
+ ds = data.word(kFreedat);
+ si = data.byte(kItemframe);
+ pickupConts();
+ return pos;
+}
+
} // End of namespace DreamGen
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index a03dbc2fb6..9bbf3b3c40 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -139,5 +139,6 @@
void swapWithOpen();
void swapWithInv();
void searchForFiles();
+ byte transferToEx();
#endif