aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions/bbdou
diff options
context:
space:
mode:
authorjohndoe1232014-03-27 18:55:41 +0100
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit33d28deb690c79a6aca190c5b1bc998c39d95662 (patch)
treefaf3167dacc8c56a63e455af79cb8d7b2f16e2aa /engines/illusions/bbdou
parent22e898f7eb1bddc363900f4146696bf6e9d41e2f (diff)
downloadscummvm-rg350-33d28deb690c79a6aca190c5b1bc998c39d95662.tar.gz
scummvm-rg350-33d28deb690c79a6aca190c5b1bc998c39d95662.tar.bz2
scummvm-rg350-33d28deb690c79a6aca190c5b1bc998c39d95662.zip
ILLUSIONS: Additions in various places
- Add NamedPoint and related code - Remove some debug output - Fix right mouse button input - Add bubble code - Add BBDOU inventory skeleton
Diffstat (limited to 'engines/illusions/bbdou')
-rw-r--r--engines/illusions/bbdou/bbdou_bubble.cpp40
-rw-r--r--engines/illusions/bbdou/bbdou_bubble.h6
-rw-r--r--engines/illusions/bbdou/bbdou_inventory.cpp32
-rw-r--r--engines/illusions/bbdou/bbdou_inventory.h37
-rw-r--r--engines/illusions/bbdou/bbdou_specialcode.cpp79
-rw-r--r--engines/illusions/bbdou/bbdou_specialcode.h7
6 files changed, 189 insertions, 12 deletions
diff --git a/engines/illusions/bbdou/bbdou_bubble.cpp b/engines/illusions/bbdou/bbdou_bubble.cpp
index 3256bc404d..cc6019c835 100644
--- a/engines/illusions/bbdou/bbdou_bubble.cpp
+++ b/engines/illusions/bbdou/bbdou_bubble.cpp
@@ -60,8 +60,8 @@ void BbdouBubble::init() {
0x00040037, 0x00040038, 0x00040039, 0x0004003A
};
- _field1414 = 0x4005B;
- _field1418 = 0x4005C;
+ _objectId1414 = 0x4005B;
+ _objectId1418 = 0x4005C;
for (uint i = 0; i < 32; ++i)
_objectIds[i] = kObjectIds3[i];
@@ -147,4 +147,40 @@ void BbdouBubble::hide() {
}
}
+void BbdouBubble::setup(int16 minCount, Common::Point pt1, Common::Point pt2, uint32 progResKeywordId) {
+ for (uint i = 0; i < 32; ++i)
+ _items[i]._enabled = 0;
+ int16 maxCount = 32;
+ for (uint i = 0; i < _item0s.size(); ++i) {
+ Item0 *item0 = &_item0s[i];
+ if (item0->_count < maxCount && item0->_count >= minCount &&
+ (!progResKeywordId || item0->_progResKeywordId == progResKeywordId)) {
+ maxCount = item0->_count;
+ _currItem0 = item0;
+ }
+ }
+ _pt1 = pt1;
+ _pt2 = pt2;
+ _currItem0->_pt = pt2;
+ _currItem0->_objectId = _objectId1414;
+ if (_prevItem0 && _prevItem0->_objectId == _currItem0->_objectId)
+ _currItem0->_objectId = _objectId1418;
+}
+
+uint32 BbdouBubble::addItem(uint positionIndex, uint32 sequenceId) {
+ for (uint i = 0; i < 32; ++i) {
+ Item141C *item = &_items[i];
+ if (!item->_enabled) {
+ Common::Point itemPos = _vm->getNamedPointPosition(_currItem0->_namedPointIds[positionIndex]);
+ Common::Point basePos = _vm->getNamedPointPosition(_currItem0->_baseNamedPointId);
+ item->_enabled = 1;
+ item->_sequenceId = sequenceId;
+ item->_position.x = itemPos.x + _currItem0->_pt.x - basePos.x;
+ item->_position.y = itemPos.y + _currItem0->_pt.y - basePos.y;
+ return item->_objectId;
+ }
+ }
+ return 0;
+}
+
} // End of namespace Illusions
diff --git a/engines/illusions/bbdou/bbdou_bubble.h b/engines/illusions/bbdou/bbdou_bubble.h
index 9064acd08c..2426c9e1b8 100644
--- a/engines/illusions/bbdou/bbdou_bubble.h
+++ b/engines/illusions/bbdou/bbdou_bubble.h
@@ -61,6 +61,8 @@ public:
uint32 namedPointId, int16 count, uint32 *namedPointIds);
void show();
void hide();
+ void setup(int16 minCount, Common::Point pt1, Common::Point pt2, uint32 progResKeywordId);
+ uint32 addItem(uint positionIndex, uint32 sequenceId);
protected:
IllusionsEngine *_vm;
BbdouSpecialCode *_bbdou;
@@ -71,8 +73,8 @@ protected:
uint32 _objectIds[32];
Common::Point _pt1;
Common::Point _pt2;
- int _field1414;
- int _field1418;
+ int _objectId1414;
+ int _objectId1418;
Item141C _items[32];
};
diff --git a/engines/illusions/bbdou/bbdou_inventory.cpp b/engines/illusions/bbdou/bbdou_inventory.cpp
new file mode 100644
index 0000000000..b1d4f92381
--- /dev/null
+++ b/engines/illusions/bbdou/bbdou_inventory.cpp
@@ -0,0 +1,32 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "illusions/illusions.h"
+#include "illusions/bbdou/bbdou_inventory.h"
+#include "illusions/actor.h"
+#include "illusions/camera.h"
+#include "illusions/dictionary.h"
+#include "illusions/input.h"
+
+namespace Illusions {
+
+} // End of namespace Illusions
diff --git a/engines/illusions/bbdou/bbdou_inventory.h b/engines/illusions/bbdou/bbdou_inventory.h
new file mode 100644
index 0000000000..31023c063a
--- /dev/null
+++ b/engines/illusions/bbdou/bbdou_inventory.h
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ILLUSIONS_BBDOU_BBDOU_INVENTORY_H
+#define ILLUSIONS_BBDOU_BBDOU_INVENTORY_H
+
+#include "illusions/specialcode.h"
+#include "common/rect.h"
+
+namespace Illusions {
+
+class IllusionsEngine;
+class BbdouSpecialCode;
+class Control;
+
+} // End of namespace Illusions
+
+#endif // ILLUSIONS_BBDOU_BBDOU_INVENTORY_H
diff --git a/engines/illusions/bbdou/bbdou_specialcode.cpp b/engines/illusions/bbdou/bbdou_specialcode.cpp
index 62b0a7aca1..96e4cb0c11 100644
--- a/engines/illusions/bbdou/bbdou_specialcode.cpp
+++ b/engines/illusions/bbdou/bbdou_specialcode.cpp
@@ -33,6 +33,22 @@
namespace Illusions {
+static const Struct10 kStruct10s[] = {
+ {0x1B0000, 0, 0, 0},
+ {0x1B0001, 0x6001A, 0x6001B, 0x6001C},
+ {0x1B0002, 0x6001D, 0x6001E, 0x6001F},
+ {0x1B0003, 0x60020, 0x60021, 0x60022},
+ {0x1B0004, 0x60023, 0x60024, 0x60025},
+ {0x1B0005, 0x60026, 0x60027, 0x60028},
+ {0x1B0006, 0, 0, 0},
+ {0x1B0007, 0, 0, 0},
+ {0x1B0008, 0, 0, 0},
+ {0x1B0009, 0, 0, 0},
+ {0x1B000A, 0, 0, 0},
+ {0x1B000B, 0, 0, 0},
+ {0x1B000C, 0, 0, 0},
+};
+
CauseThread::CauseThread(IllusionsEngine *vm, uint32 threadId, uint32 callingThreadId,
BbdouSpecialCode *bbdou, uint32 cursorObjectId, uint32 sceneId, uint32 verbId,
uint32 objectId2, uint32 objectId)
@@ -92,8 +108,8 @@ void BbdouSpecialCode::run(uint32 specialCodeId, OpCall &opCall) {
// Convenience macros
#define ARG_SKIP(x) opCall.skip(x);
-#define ARG_INT16(name) int16 name = opCall.readSint16(); debug("ARG_INT16(" #name " = %d)", name);
-#define ARG_UINT32(name) uint32 name = opCall.readUint32(); debug("ARG_UINT32(" #name " = %08X)", name);
+#define ARG_INT16(name) int16 name = opCall.readSint16(); debug(1, "ARG_INT16(" #name " = %d)", name);
+#define ARG_UINT32(name) uint32 name = opCall.readUint32(); debug(1, "ARG_UINT32(" #name " = %08X)", name);
void BbdouSpecialCode::spcInitCursor(OpCall &opCall) {
ARG_UINT32(objectId);
@@ -196,7 +212,58 @@ Common::Point BbdouSpecialCode::getBackgroundCursorPos(Common::Point cursorPos)
void BbdouSpecialCode::showBubble(uint32 objectId, uint32 overlappedObjectId, uint32 holdingObjectId,
Item10 *item10, uint32 progResKeywordId) {
- // TODO
+
+ Common::Rect collisionRect;
+ Control *overlappedControl, *control2, *control3;
+ Common::Point pt1(320, 240), pt2, currPan;
+
+ overlappedControl = _vm->_dict->getObjectControl(overlappedObjectId);
+ overlappedControl->getCollisionRect(collisionRect);
+
+ currPan = _vm->_camera->getCurrentPan();
+ pt2.x = CLIP((collisionRect.right + collisionRect.left) / 2, currPan.x - 274, currPan.x + 274);
+ pt2.y = CLIP(collisionRect.top - (collisionRect.bottom - collisionRect.top) / 8, currPan.y - 204, currPan.y + 204);
+
+ control2 = _vm->_dict->getObjectControl(0x4000F);
+ if (!control2 || (control2->_actor && control2->_actor->_frameIndex == 0))
+ control2 = _vm->_dict->getObjectControl(0x4000E);
+
+ if (control2 && control2->_actor && control2->_actor->_frameIndex) {
+ pt1.x = control2->_actor->_surfInfo._dimensions._width / 2 + pt1.x - control2->_position.x;
+ pt1.y = control2->_actor->_position.y - control2->_position.y;
+ pt1.y = pt1.y >= 500 ? 500 : pt1.y + 32;
+ if (ABS(pt1.x - pt2.x) < ABS(pt1.y - pt2.y) / 2)
+ pt1.y += 80;
+ }
+
+ _bubble->setup(1, pt1, pt2, progResKeywordId);
+
+ item10->_objectIds[0] = _bubble->addItem(0, 0x6005A);
+ item10->_objectIds[1] = _bubble->addItem(0, 0x6005A);
+ item10->_index = 0;
+
+ int value = _cursor->findStruct8bsValue(overlappedControl->_objectId);
+ if (holdingObjectId) {
+ item10->_verbId = 0x1B0003;
+ } else if (value == 9) {
+ item10->_verbId = 0x1B0005;
+ } else if (value == 8) {
+ item10->_verbId = 0x1B0005;
+ } else {
+ item10->_verbId = 0x1B0002;
+ }
+
+ uint32 sequenceId = kStruct10s[item10->_verbId & 0xFFFF]._sequenceId2;
+ _bubble->show();
+
+ control3 = _vm->_dict->getObjectControl(item10->_objectIds[0]);
+ control3->startSequenceActor(sequenceId, 2, 0);
+ control3->appearActor();
+ control3->deactivateObject();
+
+ item10->_playSound48 = 1;
+ _vm->_input->discardButtons(0xFFFF);
+
}
bool BbdouSpecialCode::findVerbId(Item10 *item10, uint32 currOverlappedObjectId, int always0, uint32 &outVerbId) {
@@ -255,13 +322,11 @@ void BbdouSpecialCode::cursorInteractControlRoutine(Control *cursorControl, uint
}
if (foundOverlapped) {
- debug("overlappedControl: %p", (void*)overlappedControl);
if (overlappedControl->_objectId != cursorData._currOverlappedObjectId) {
if (cursorData._item10._playSound48)
playSoundEffect(4);
resetItem10(cursorControl->_objectId, &cursorData._item10);
int value = _cursor->findStruct8bsValue(overlappedControl->_objectId);
- debug("object value: %d", value);
if (!testValueRange(value)) {
if (cursorData._mode == 3)
_cursor->restoreInfo();
@@ -453,8 +518,6 @@ bool BbdouSpecialCode::runCause(Control *cursorControl, CursorData &cursorData,
success = true;
}
- debug("runCause() success: %d", success);
-
if (!success)
return false;
@@ -479,7 +542,7 @@ bool BbdouSpecialCode::runCause(Control *cursorControl, CursorData &cursorData,
uint32 BbdouSpecialCode::startCauseThread(uint32 cursorObjectId, uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId) {
uint32 tempThreadId = _vm->_scriptMan->newTempThreadId();
- debug("staring cause thread %08X...", tempThreadId);
+ debug(3, "Starting cause thread %08X...", tempThreadId);
CauseThread *causeThread = new CauseThread(_vm, tempThreadId, 0, this,
cursorObjectId, sceneId, verbId, objectId2, objectId);
_vm->_scriptMan->_threads->startThread(causeThread);
diff --git a/engines/illusions/bbdou/bbdou_specialcode.h b/engines/illusions/bbdou/bbdou_specialcode.h
index 61f6b703da..9781c6d15d 100644
--- a/engines/illusions/bbdou/bbdou_specialcode.h
+++ b/engines/illusions/bbdou/bbdou_specialcode.h
@@ -39,6 +39,13 @@ typedef Common::Functor1<OpCall&, void> SpecialCodeFunction;
class BbdouSpecialCode;
+struct Struct10 {
+ uint32 _verbId;
+ uint32 _sequenceId1;
+ uint32 _sequenceId2;
+ uint32 _sequenceId3;
+};
+
class CauseThread : public Thread {
public:
CauseThread(IllusionsEngine *vm, uint32 threadId, uint32 callingThreadId,