aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions/bbdou
diff options
context:
space:
mode:
Diffstat (limited to 'engines/illusions/bbdou')
-rw-r--r--engines/illusions/bbdou/bbdou_cursor.cpp32
-rw-r--r--engines/illusions/bbdou/bbdou_cursor.h9
-rw-r--r--engines/illusions/bbdou/bbdou_specialcode.cpp45
-rw-r--r--engines/illusions/bbdou/bbdou_specialcode.h17
4 files changed, 59 insertions, 44 deletions
diff --git a/engines/illusions/bbdou/bbdou_cursor.cpp b/engines/illusions/bbdou/bbdou_cursor.cpp
index a6bc4a90ba..605919a29f 100644
--- a/engines/illusions/bbdou/bbdou_cursor.cpp
+++ b/engines/illusions/bbdou/bbdou_cursor.cpp
@@ -33,6 +33,8 @@ namespace Illusions {
// NOTE It's assumed there's only one game cursor object
// The original stores the _data inside the actor, here it's inside the Cursor class.
+// BbdouCursor
+
BbdouCursor::BbdouCursor(IllusionsEngine_BBDOU *vm, BbdouSpecialCode *bbdou)
: _vm(vm), _bbdou(bbdou) {
}
@@ -145,36 +147,6 @@ uint32 BbdouCursor::findCursorSequenceId(uint32 objectId) {
return 0;
}
-void BbdouCursor::setObjectInteractMode(uint32 objectId, int value) {
- ObjectInteractMode *objectInteractMode = 0;
- for (uint i = 0; i < ARRAYSIZE(_objectVerbs); ++i)
- if (_objectVerbs[i]._objectId == objectId) {
- objectInteractMode = &_objectVerbs[i];
- break;
- }
- if (!objectInteractMode) {
- for (uint i = 0; i < ARRAYSIZE(_objectVerbs); ++i)
- if (_objectVerbs[i]._objectId == 0) {
- objectInteractMode = &_objectVerbs[i];
- break;
- }
- }
- if (value != 11) {
- objectInteractMode->_objectId = objectId;
- objectInteractMode->_interactMode = value;
- } else if (objectInteractMode->_objectId == objectId) {
- objectInteractMode->_objectId = 0;
- objectInteractMode->_interactMode = 0;
- }
-}
-
-int BbdouCursor::getObjectInteractMode(uint32 objectId) {
- for (uint i = 0; i < ARRAYSIZE(_objectVerbs); ++i)
- if (_objectVerbs[i]._objectId == objectId)
- return _objectVerbs[i]._interactMode;
- return 11;
-}
-
bool BbdouCursor::updateTrackingCursor(Control *control) {
uint32 sequenceId;
if (getTrackingCursorSequenceId(control, sequenceId)) {
diff --git a/engines/illusions/bbdou/bbdou_cursor.h b/engines/illusions/bbdou/bbdou_cursor.h
index c3f023a5e9..49082a02d6 100644
--- a/engines/illusions/bbdou/bbdou_cursor.h
+++ b/engines/illusions/bbdou/bbdou_cursor.h
@@ -69,12 +69,6 @@ struct CursorSequence {
CursorSequence() : _objectId(0), _sequenceId(0) {}
};
-struct ObjectInteractMode {
- uint32 _objectId;
- int _interactMode;
- ObjectInteractMode() : _objectId(0), _interactMode(0) {}
-};
-
const uint kMaxCursorSequences = 100;
class BbdouCursor {
@@ -87,8 +81,6 @@ public:
void reset(uint32 objectId);
void addCursorSequenceId(uint32 objectId, uint32 sequenceId);
uint32 findCursorSequenceId(uint32 objectId);
- void setObjectInteractMode(uint32 objectId, int value);
- int getObjectInteractMode(uint32 objectId);
bool updateTrackingCursor(Control *control);
void saveInfo();
void restoreInfo();
@@ -104,7 +96,6 @@ public:
Control *_control;
CursorData _data;
CursorSequence _cursorSequences[kMaxCursorSequences];
- ObjectInteractMode _objectVerbs[512];
void resetActiveVerbs();
void show(Control *control);
void hide(uint32 objectId);
diff --git a/engines/illusions/bbdou/bbdou_specialcode.cpp b/engines/illusions/bbdou/bbdou_specialcode.cpp
index 540a31e1a0..ed1ce5cb95 100644
--- a/engines/illusions/bbdou/bbdou_specialcode.cpp
+++ b/engines/illusions/bbdou/bbdou_specialcode.cpp
@@ -107,6 +107,41 @@ void RadarMicrophoneThread::initZones() {
_currZoneIndex = 0;
}
+// ObjectInteractModeMap
+
+ObjectInteractModeMap::ObjectInteractModeMap() {
+}
+
+void ObjectInteractModeMap::setObjectInteractMode(uint32 objectId, int value) {
+ ObjectInteractMode *objectInteractMode = 0;
+ for (uint i = 0; i < ARRAYSIZE(_objectVerbs); ++i)
+ if (_objectVerbs[i]._objectId == objectId) {
+ objectInteractMode = &_objectVerbs[i];
+ break;
+ }
+ if (!objectInteractMode) {
+ for (uint i = 0; i < ARRAYSIZE(_objectVerbs); ++i)
+ if (_objectVerbs[i]._objectId == 0) {
+ objectInteractMode = &_objectVerbs[i];
+ break;
+ }
+ }
+ if (value != 11) {
+ objectInteractMode->_objectId = objectId;
+ objectInteractMode->_interactMode = value;
+ } else if (objectInteractMode->_objectId == objectId) {
+ objectInteractMode->_objectId = 0;
+ objectInteractMode->_interactMode = 0;
+ }
+}
+
+int ObjectInteractModeMap::getObjectInteractMode(uint32 objectId) {
+ for (uint i = 0; i < ARRAYSIZE(_objectVerbs); ++i)
+ if (_objectVerbs[i]._objectId == objectId)
+ return _objectVerbs[i]._interactMode;
+ return 11;
+}
+
// BbdouSpecialCode
BbdouSpecialCode::BbdouSpecialCode(IllusionsEngine_BBDOU *vm)
@@ -252,7 +287,7 @@ void BbdouSpecialCode::spcSetObjectInteractMode(OpCall &opCall) {
ARG_SKIP(4);
ARG_UINT32(objectId);
ARG_INT16(value);
- _cursor->setObjectInteractMode(objectId, value);
+ _objectInteractModeMap.setObjectInteractMode(objectId, value);
_vm->notifyThreadId(opCall._threadId);
}
@@ -530,7 +565,7 @@ void BbdouSpecialCode::showBubble(uint32 objectId, uint32 overlappedObjectId, ui
verbState->_objectIds[1] = _bubble->addItem(0, 0x6005A);
verbState->_index = 0;
- int value = _cursor->getObjectInteractMode(overlappedControl->_objectId);
+ int value = _objectInteractModeMap.getObjectInteractMode(overlappedControl->_objectId);
if (holdingObjectId) {
verbState->_verbId = 0x1B0003;
} else if (value == 9) {
@@ -614,7 +649,7 @@ void BbdouSpecialCode::cursorInteractControlRoutine(Control *cursorControl, uint
if (cursorData._verbState._isBubbleVisible)
playSoundEffect(4);
hideVerbBubble(cursorControl->_objectId, &cursorData._verbState);
- int value = _cursor->getObjectInteractMode(overlappedControl->_objectId);
+ int value = _objectInteractModeMap.getObjectInteractMode(overlappedControl->_objectId);
if (!testValueRange(value)) {
if (cursorData._mode == 3)
_cursor->restoreInfo();
@@ -785,7 +820,7 @@ void BbdouSpecialCode::cursorCrosshairControlRoutine(Control *cursorControl, uin
if (foundOverlapped) {
if (overlappedControl->_objectId != cursorData._currOverlappedObjectId) {
hideVerbBubble(cursorControl->_objectId, &cursorData._verbState);
- int value = _cursor->getObjectInteractMode(overlappedControl->_objectId);
+ int value = _objectInteractModeMap.getObjectInteractMode(overlappedControl->_objectId);
if (value == 2 || value == 3 || value == 4 || value == 5 || value == 6 || value == 7) {
if (cursorData._mode != 3) {
_cursor->saveInfo();
@@ -921,7 +956,7 @@ bool BbdouSpecialCode::testVerbId(uint32 verbId, uint32 holdingObjectId, uint32
static const uint32 kVerbIdsH8[] = {0x001B0003, 0x001B0001, 0};
const uint32 *verbIds;
- int value = _cursor->getObjectInteractMode(overlappedObjectId);
+ int value = _objectInteractModeMap.getObjectInteractMode(overlappedObjectId);
if (holdingObjectId) {
if (value == 9)
diff --git a/engines/illusions/bbdou/bbdou_specialcode.h b/engines/illusions/bbdou/bbdou_specialcode.h
index 567c9562ee..ad9d3b7a1d 100644
--- a/engines/illusions/bbdou/bbdou_specialcode.h
+++ b/engines/illusions/bbdou/bbdou_specialcode.h
@@ -89,6 +89,21 @@ struct ShooterStatus {
bool flag;
};
+struct ObjectInteractMode {
+ uint32 _objectId;
+ int _interactMode;
+ ObjectInteractMode() : _objectId(0), _interactMode(0) {}
+};
+
+class ObjectInteractModeMap {
+public:
+ ObjectInteractModeMap();
+ void setObjectInteractMode(uint32 objectId, int value);
+ int getObjectInteractMode(uint32 objectId);
+protected:
+ ObjectInteractMode _objectVerbs[512];
+};
+
class BbdouSpecialCode : public SpecialCode {
public:
BbdouSpecialCode(IllusionsEngine_BBDOU *vm);
@@ -115,6 +130,8 @@ public:
uint _shooterObjectIdIndex;
BbdouFoodCtl *_foodCtl;
+
+ ObjectInteractModeMap _objectInteractModeMap;
// Special code interface functions
void spcInitCursor(OpCall &opCall);