aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions/bbdou
diff options
context:
space:
mode:
authorjohndoe1232014-04-17 12:57:56 +0200
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commitd431d3521480d43fa646a5cd84c6a10d0d24843a (patch)
treeed559955060ebcfdeca99c837205933a1c163614 /engines/illusions/bbdou
parentb94b4c28ba33b9c5edbd9ba8143284786a8dfeac (diff)
downloadscummvm-rg350-d431d3521480d43fa646a5cd84c6a10d0d24843a.tar.gz
scummvm-rg350-d431d3521480d43fa646a5cd84c6a10d0d24843a.tar.bz2
scummvm-rg350-d431d3521480d43fa646a5cd84c6a10d0d24843a.zip
ILLUSIONS: BBDOU: Add microphone radar
Diffstat (limited to 'engines/illusions/bbdou')
-rw-r--r--engines/illusions/bbdou/bbdou_specialcode.cpp60
-rw-r--r--engines/illusions/bbdou/bbdou_specialcode.h21
2 files changed, 80 insertions, 1 deletions
diff --git a/engines/illusions/bbdou/bbdou_specialcode.cpp b/engines/illusions/bbdou/bbdou_specialcode.cpp
index 8011b3eb5d..cb4f32aeae 100644
--- a/engines/illusions/bbdou/bbdou_specialcode.cpp
+++ b/engines/illusions/bbdou/bbdou_specialcode.cpp
@@ -68,6 +68,41 @@ void CauseThread::onTerminated() {
_bbdou->_cursor->enable(_cursorObjectId);
}
+// RadarMicrophoneThread
+RadarMicrophoneThread::RadarMicrophoneThread(IllusionsEngine_BBDOU *vm, uint32 threadId,
+ uint32 callingThreadId, uint32 cursorObjectId)
+ : Thread(vm, threadId, callingThreadId, 0), _cursorObjectId(cursorObjectId), _zonesCount(0) {
+ _tag = _vm->getCurrentScene();
+}
+
+int RadarMicrophoneThread::onUpdate() {
+ Control *control = _vm->getObjectControl(_cursorObjectId);
+ int16 cursorX = control->getActorPosition().x;
+ if (_currZoneIndex == 0 ||
+ cursorX >= _zones[_currZoneIndex - 1]._x ||
+ (_currZoneIndex >= 2 && cursorX < _zones[_currZoneIndex - 2]._x)) {//CHECKME
+ for (uint i = 0; i < _zonesCount; ++i) {
+ if (cursorX < _zones[i]._x) {
+ _currZoneIndex = i + 1;
+ _vm->startScriptThreadSimple(_zones[i]._threadId, 0);
+ break;
+ }
+ }
+ }
+ return kTSYield;
+}
+
+void RadarMicrophoneThread::addZone(uint32 threadId) {
+ _zones[_zonesCount++]._threadId = threadId;
+}
+
+void RadarMicrophoneThread::initZones() {
+ for (uint i = 0; i < _zonesCount; ++i)
+ _zones[i]._x = (i + 1) * 640 / _zonesCount;
+ _zones[_zonesCount]._x = 640;
+ _currZoneIndex = 0;
+}
+
// BbdouSpecialCode
BbdouSpecialCode::BbdouSpecialCode(IllusionsEngine_BBDOU *vm)
@@ -105,7 +140,9 @@ void BbdouSpecialCode::init() {
SPECIAL(0x0016001E, spcRemoveInventoryItem);
SPECIAL(0x0016001F, spcHasInventoryItem);
SPECIAL(0x00160025, spcCloseInventory);
+ SPECIAL(0x00160032, spcSetCursorField90);
SPECIAL(0x00160037, spcIsCursorHoldingObjectId);
+ SPECIAL(0x00160038, spcInitRadarMicrophone);
SPECIAL(0x0016003A, spcSaladCtl);
}
@@ -229,6 +266,12 @@ void BbdouSpecialCode::spcCloseInventory(OpCall &opCall) {
_inventory->close();
}
+void BbdouSpecialCode::spcSetCursorField90(OpCall &opCall) {
+ ARG_SKIP(4); // objectId unused
+ _cursor->_data._field90 = 1;
+ _vm->notifyThreadId(opCall._threadId);
+}
+
void BbdouSpecialCode::spcIsCursorHoldingObjectId(OpCall &opCall) {
ARG_UINT32(cursorObjectId);
ARG_UINT32(objectId);
@@ -236,6 +279,21 @@ void BbdouSpecialCode::spcIsCursorHoldingObjectId(OpCall &opCall) {
_vm->notifyThreadId(opCall._threadId);
}
+void BbdouSpecialCode::spcInitRadarMicrophone(OpCall &opCall) {
+ ARG_UINT32(cursorObjectId);
+ uint32 tempThreadId = _vm->newTempThreadId();
+ RadarMicrophoneThread *radarMicrophoneThread = new RadarMicrophoneThread(_vm,
+ tempThreadId, opCall._callerThreadId, cursorObjectId);
+ for (uint i = 0; i < 7; ++i) {
+ ARG_UINT32(zoneThreadId);
+ if (zoneThreadId == 0)
+ break;
+ radarMicrophoneThread->addZone(zoneThreadId);
+ }
+ radarMicrophoneThread->initZones();
+ _vm->_threads->startThread(radarMicrophoneThread);
+}
+
void BbdouSpecialCode::spcSaladCtl(OpCall &opCall) {
ARG_UINT32(cmd);
ARG_UINT32(sequenceId);
@@ -280,7 +338,7 @@ bool BbdouSpecialCode::testValueRange(int value) {
}
void BbdouSpecialCode::setCursorControlRoutine(uint32 objectId, int num) {
- Control *control = _vm->_dict->getObjectControl(objectId);
+ Control *control = _vm->getObjectControl(objectId);
if (num == 0)
control->_actor->setControlRoutine(
new Common::Functor2Mem<Control*, uint32, void, BbdouSpecialCode>(this, &BbdouSpecialCode::cursorInteractControlRoutine));
diff --git a/engines/illusions/bbdou/bbdou_specialcode.h b/engines/illusions/bbdou/bbdou_specialcode.h
index b9080c9810..037d4750ce 100644
--- a/engines/illusions/bbdou/bbdou_specialcode.h
+++ b/engines/illusions/bbdou/bbdou_specialcode.h
@@ -63,6 +63,25 @@ public:
uint32 _objectId;
};
+struct RadarMicrophoneZone {
+ int16 _x;
+ uint32 _threadId;
+};
+
+class RadarMicrophoneThread : public Thread {
+public:
+ RadarMicrophoneThread(IllusionsEngine_BBDOU *vm, uint32 threadId,
+ uint32 callingThreadId, uint32 cursorObjectId);
+ virtual int onUpdate();
+ void addZone(uint32 threadId);
+ void initZones();
+public:
+ uint32 _cursorObjectId;
+ uint _zonesCount;
+ uint _currZoneIndex;
+ RadarMicrophoneZone _zones[8];
+};
+
class BbdouSpecialCode : public SpecialCode {
public:
BbdouSpecialCode(IllusionsEngine_BBDOU *vm);
@@ -100,7 +119,9 @@ public:
void spcRemoveInventoryItem(OpCall &opCall);
void spcHasInventoryItem(OpCall &opCall);
void spcCloseInventory(OpCall &opCall);
+ void spcSetCursorField90(OpCall &opCall);
void spcIsCursorHoldingObjectId(OpCall &opCall);
+ void spcInitRadarMicrophone(OpCall &opCall);
void spcSaladCtl(OpCall &opCall);
void playSoundEffect(int soundIndex);