aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2011-12-25 17:32:56 +0200
committerFilippos Karapetis2011-12-25 17:32:56 +0200
commitc531c4c1eafbf66a3724df0f3cb7b9ad8da97a8d (patch)
treee1df3445a59cde4e88126f5e671364d6f63e874c /engines
parent0fff97b4b023895256cb8cce9b30684d433bfae4 (diff)
downloadscummvm-rg350-c531c4c1eafbf66a3724df0f3cb7b9ad8da97a8d.tar.gz
scummvm-rg350-c531c4c1eafbf66a3724df0f3cb7b9ad8da97a8d.tar.bz2
scummvm-rg350-c531c4c1eafbf66a3724df0f3cb7b9ad8da97a8d.zip
DREAMWEB: Port 'swapwithinv' to C++
Diffstat (limited to 'engines')
-rw-r--r--engines/dreamweb/dreamgen.cpp60
-rw-r--r--engines/dreamweb/dreamgen.h1
-rw-r--r--engines/dreamweb/object.cpp43
-rw-r--r--engines/dreamweb/stubs.h1
4 files changed, 44 insertions, 61 deletions
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 4d89322a77..1afca17560 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -284,66 +284,6 @@ findopen2a:
goto findopen1a;
}
-void DreamGenContext::swapWithInv() {
- STACK_CHECK;
- al = data.byte(kItemframe);
- ah = data.byte(kObjecttype);
- _cmp(ax, data.word(kOldsubject));
- if (!flags.z())
- goto difsub7;
- _cmp(data.byte(kCommandtype), 243);
- if (flags.z())
- goto alreadyswap1;
- data.byte(kCommandtype) = 243;
-difsub7:
- data.word(kOldsubject) = ax;
- bx = ax;
- al = 34;
- commandWithOb();
-alreadyswap1:
- ax = data.word(kMousebutton);
- _cmp(ax, data.word(kOldbutton));
- if (flags.z())
- return /* (cantswap1) */;
- _and(ax, 1);
- if (!flags.z())
- goto doswap1;
- return;
-doswap1:
- ah = data.byte(kObjecttype);
- al = data.byte(kItemframe);
- push(ax);
- findInvPos();
- ax = es.word(bx);
- data.byte(kItemframe) = al;
- data.byte(kObjecttype) = ah;
- getEitherAd();
- es.byte(bx+2) = 20;
- es.byte(bx+3) = 255;
- bl = data.byte(kItemframe);
- bh = data.byte(kObjecttype);
- ax = pop();
- data.byte(kObjecttype) = ah;
- data.byte(kItemframe) = al;
- push(bx);
- findInvPos();
- delPointer();
- al = data.byte(kItemframe);
- getEitherAd();
- es.byte(bx+2) = 4;
- es.byte(bx+3) = 255;
- al = data.byte(kLastinvpos);
- es.byte(bx+4) = al;
- ax = pop();
- data.byte(kObjecttype) = ah;
- data.byte(kItemframe) = al;
- fillRyan();
- readMouse();
- showPointer();
- workToScreen();
- delPointer();
-}
-
void DreamGenContext::swapWithOpen() {
STACK_CHECK;
al = data.byte(kItemframe);
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 3ddf858053..25901250b6 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -477,7 +477,6 @@ public:
void searchForString();
void searchForFiles();
void getExAd();
- void swapWithInv();
void transferToEx();
void parser();
void emergencyPurge();
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index 8399c6f26a..9eb31f438f 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -902,4 +902,47 @@ void DreamGenContext::useOpened() {
delPointer();
}
+void DreamGenContext::swapWithInv() {
+ uint16 subject = (data.byte(kObjecttype) << 8) | data.byte(kItemframe);
+ if (subject == data.word(kOldsubject)) {
+ if (data.byte(kCommandtype) != 243) {
+ data.byte(kCommandtype) = 243;
+ data.word(kOldsubject) = subject;
+ commandWithOb(34, data.byte(kObjecttype), data.byte(kItemframe));
+ }
+ } else {
+ data.word(kOldsubject) = subject;
+ commandWithOb(34, data.byte(kObjecttype), data.byte(kItemframe));
+ }
+
+ if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1))
+ return;
+
+ byte prevType = data.byte(kObjecttype);
+ byte prevFrame = data.byte(kItemframe);
+ uint16 objectId = getSegment(data.word(kBuffers)).word(findInvPosCPP());
+ data.byte(kItemframe) = objectId & 0x00FF;
+ data.byte(kObjecttype) = objectId >> 8;
+ DynObject *object = getEitherAdCPP();
+ object->mapad[0] = 20;
+ object->mapad[1] = 255;
+ byte prevType2 = data.byte(kObjecttype);
+ byte prevFrame2 = data.byte(kItemframe);
+ data.byte(kObjecttype) = prevType;
+ data.byte(kItemframe) = prevFrame;
+ //findInvPosCPP(); // found in the original source, but it seems to be useless
+ delPointer();
+ object = getEitherAdCPP();
+ object->mapad[0] = 4;
+ object->mapad[1] = 255;
+ object->mapad[2] = data.byte(kLastinvpos);
+ data.byte(kObjecttype) = prevType2;
+ data.byte(kItemframe) = prevFrame2;
+ fillRyan();
+ readMouse();
+ showPointer();
+ workToScreenCPP();
+ delPointer();
+}
+
} // End of namespace DreamGen
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 4ba8cd6dd9..2ac944b06a 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -196,5 +196,6 @@
void reExFromInv();
void locationPic();
void useOpened();
+ void swapWithInv();
#endif