aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb/object.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2011-12-17 13:47:42 +0200
committerFilippos Karapetis2011-12-17 13:48:12 +0200
commit05c5e224b45f910d9db50e6c9ce451ede31452f2 (patch)
tree5953e7be76ba1052bef43abeb9bee55879e5f718 /engines/dreamweb/object.cpp
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()
Diffstat (limited to 'engines/dreamweb/object.cpp')
-rw-r--r--engines/dreamweb/object.cpp41
1 files changed, 41 insertions, 0 deletions
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