aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2011-12-17 13:47:42 +0200
committerFilippos Karapetis2011-12-17 13:48:12 +0200
commit05c5e224b45f910d9db50e6c9ce451ede31452f2 (patch)
tree5953e7be76ba1052bef43abeb9bee55879e5f718
parent8dec805d852cff58d3ff52c4d8051ac0a33f93be (diff)
downloadscummvm-rg350-05c5e224b45f910d9db50e6c9ce451ede31452f2.tar.gz
scummvm-rg350-05c5e224b45f910d9db50e6c9ce451ede31452f2.tar.bz2
scummvm-rg350-05c5e224b45f910d9db50e6c9ce451ede31452f2.zip
DREAMWEB: Port 'findinvpos', 'selectob' to C++ and fix a regression in identifyOb()
-rwxr-xr-xdevtools/tasmrecover/tasm-recover2
-rw-r--r--engines/dreamweb/dreamgen.cpp69
-rw-r--r--engines/dreamweb/dreamgen.h2
-rw-r--r--engines/dreamweb/object.cpp41
-rw-r--r--engines/dreamweb/stubs.h3
5 files changed, 46 insertions, 71 deletions
diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 2b0e08632f..8d5eb11b63 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -412,6 +412,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'finalframe',
'findallryan',
'findexobject',
+ 'findinvpos',
'findlen',
'findnextcolon',
'findobname',
@@ -710,6 +711,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'security',
'seecommandtail',
'selectlocation',
+ 'selectob',
'selectslot',
'selectslot2',
'set16colpalette',
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 939e8c0127..ff91eb678f 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -1091,36 +1091,6 @@ void DreamGenContext::getSetAd() {
es = data.word(kSetdat);
}
-void DreamGenContext::findInvPos() {
- STACK_CHECK;
- cx = data.word(kMousex);
- _sub(cx, (80));
- bx = -1;
-findinv1:
- _inc(bx);
- _sub(cx, (44));
- if (!flags.c())
- goto findinv1;
- cx = data.word(kMousey);
- _sub(cx, (58));
- _sub(bx, 5);
-findinv2:
- _add(bx, 5);
- _sub(cx, (44));
- if (!flags.c())
- goto findinv2;
- al = data.byte(kRyanpage);
- ah = 0;
- cx = 10;
- _mul(cx);
- _add(bx, ax);
- al = bl;
- data.byte(kLastinvpos) = al;
- _add(bx, bx);
- es = data.word(kBuffers);
- _add(bx, (0+(228*13)+32));
-}
-
void DreamGenContext::findOpenPos() {
STACK_CHECK;
cx = data.word(kMousex);
@@ -2736,45 +2706,6 @@ lookcolon:
goto lookcolon;
}
-void DreamGenContext::selectOb() {
- STACK_CHECK;
- findInvPos();
- ax = es.word(bx);
- _cmp(al, 255);
- if (!flags.z())
- goto canselectob;
- blank();
- return;
-canselectob:
- data.byte(kWithobject) = al;
- data.byte(kWithtype) = ah;
- _cmp(ax, data.word(kOldsubject));
- if (!flags.z())
- goto diffsub3;
- _cmp(data.byte(kCommandtype), 221);
- if (flags.z())
- goto alreadyselob;
- data.byte(kCommandtype) = 221;
-diffsub3:
- data.word(kOldsubject) = ax;
- bx = ax;
- al = 0;
- commandWithOb();
-alreadyselob:
- ax = data.word(kMousebutton);
- _cmp(ax, data.word(kOldbutton));
- if (flags.z())
- return /* (notselob) */;
- _and(ax, 1);
- if (!flags.z())
- goto doselob;
- return;
-doselob:
- delPointer();
- data.byte(kInvopen) = 0;
- useRoutine();
-}
-
void DreamGenContext::showDiaryKeys() {
STACK_CHECK;
_cmp(data.byte(kPresscount), 0);
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 28711bb1ba..139253cdb8 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -496,9 +496,7 @@ public:
void removeObFromInv();
void dirFile();
void pickupConts();
- void findInvPos();
void getKeyAndLogo();
- void selectOb();
void fadeUpMon();
void reExFromInv();
void outOfInv();
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index 747b7934b4..283e44b583 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -331,6 +331,8 @@ void DreamGenContext::identifyOb() {
push(ax);
findPathOfPoint();
data.byte(kPointerspath) = dl;
+ ax = pop();
+ push(ax);
findFirstPath();
data.byte(kPointerfirstpath) = al;
ax = pop();
@@ -354,4 +356,43 @@ void DreamGenContext::identifyOb() {
blank();
}
+uint16 DreamGenContext::findInvPosCPP() {
+ uint16 x = data.word(kMousex) - kInventx;
+ uint16 y = data.word(kMousey) - kInventy;
+ uint16 pos = (x / kItempicsize) + (y / kItempicsize) * 5;
+ uint16 invPos = data.byte(kRyanpage) * 10 + pos;
+ data.byte(kLastinvpos) = invPos & 0xFF;
+ return invPos * 2 + kRyaninvlist;
+}
+
+void DreamGenContext::findInvPos() {
+ bx = findInvPosCPP();
+ es = data.word(kBuffers);
+}
+
+void DreamGenContext::selectOb() {
+ es = data.word(kBuffers);
+
+ uint16 objectId = es.word(findInvPosCPP());
+ if ((objectId & 0xFF) == 255) {
+ blank();
+ return;
+ }
+
+ data.byte(kWithobject) = objectId & 0x00FF;
+ data.byte(kWithtype) = objectId & 0xFF00;
+
+ if (objectId == data.word(kOldsubject) && data.byte(kCommandtype) != 221)
+ data.byte(kCommandtype) = 221;
+
+ data.word(kOldsubject) = objectId;
+ commandWithOb(0, data.byte(kWithtype), data.byte(kWithobject));
+
+ if (data.word(kMousebutton) != data.word(kOldbutton) && (data.word(kMousebutton) & 1)) {
+ delPointer();
+ data.byte(kInvopen) = 0;
+ useRoutine();
+ }
+}
+
} // End of namespace DreamGen
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index b2417e767b..d9823fb2c0 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -398,5 +398,8 @@
void useStereo();
void checkInside();
uint16 checkInside(uint16 command, uint16 type);
+ void selectOb();
+ void findInvPos();
+ uint16 findInvPosCPP();
#endif