aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorjohndoe1232014-04-17 12:57:56 +0200
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commitd431d3521480d43fa646a5cd84c6a10d0d24843a (patch)
treeed559955060ebcfdeca99c837205933a1c163614 /engines
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')
-rw-r--r--engines/illusions/bbdou/bbdou_specialcode.cpp60
-rw-r--r--engines/illusions/bbdou/bbdou_specialcode.h21
-rw-r--r--engines/illusions/screen.cpp18
-rw-r--r--engines/illusions/scriptopcodes_bbdou.cpp10
-rw-r--r--engines/illusions/scriptopcodes_bbdou.h1
5 files changed, 100 insertions, 10 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);
diff --git a/engines/illusions/screen.cpp b/engines/illusions/screen.cpp
index cd5ca683df..076906e3a0 100644
--- a/engines/illusions/screen.cpp
+++ b/engines/illusions/screen.cpp
@@ -336,15 +336,17 @@ void Screen::drawSurface(Common::Rect &dstRect, Graphics::Surface *surface, Comm
}
void Screen::setPalette(byte *colors, uint start, uint count) {
- byte *dstPal = &_mainPalette[3 * (start - 1)];
- for (uint i = 0; i < count; ++i) {
- *dstPal++ = *colors++;
- *dstPal++ = *colors++;
- *dstPal++ = *colors++;
- ++colors;
+ if (_backSurface->format.bytesPerPixel == 1) {
+ byte *dstPal = &_mainPalette[3 * (start - 1)];
+ for (uint i = 0; i < count; ++i) {
+ *dstPal++ = *colors++;
+ *dstPal++ = *colors++;
+ *dstPal++ = *colors++;
+ ++colors;
+ }
+ buildColorTransTbl();
+ _needRefreshPalette = true;
}
- buildColorTransTbl();
- _needRefreshPalette = true;
}
void Screen::setPaletteEntry(int16 index, byte r, byte g, byte b) {
diff --git a/engines/illusions/scriptopcodes_bbdou.cpp b/engines/illusions/scriptopcodes_bbdou.cpp
index b566f521a3..ff5c98fa2b 100644
--- a/engines/illusions/scriptopcodes_bbdou.cpp
+++ b/engines/illusions/scriptopcodes_bbdou.cpp
@@ -63,6 +63,7 @@ void ScriptOpcodes_BBDOU::initOpcodes() {
OPCODE(6, opStartScriptThread);
OPCODE(8, opStartTempScriptThread);
OPCODE(9, opStartTimerThread);
+ OPCODE(12, opNotifyThreadId);
OPCODE(14, opSetThreadSceneId);
OPCODE(15, opEndTalkThreads);
OPCODE(16, opLoadResource);
@@ -191,6 +192,12 @@ duration = 1;//DEBUG Speeds up things
_vm->startTimerThread(duration, opCall._threadId);
}
+void ScriptOpcodes_BBDOU::opNotifyThreadId(ScriptThread *scriptThread, OpCall &opCall) {
+ Thread *thread = _vm->_threads->findThread(opCall._callerThreadId);
+ if (!(thread->_notifyFlags & 1))
+ _vm->notifyThreadId(thread->_callingThreadId);
+}
+
void ScriptOpcodes_BBDOU::opSetThreadSceneId(ScriptThread *scriptThread, OpCall &opCall) {
ARG_SKIP(2);
ARG_UINT32(sceneId);
@@ -240,7 +247,8 @@ void ScriptOpcodes_BBDOU::opEnterScene(ScriptThread *scriptThread, OpCall &opCal
//uint32 dsceneId = 0x0001000D, dthreadId = 0x00020012;//Food minigame
//uint32 dsceneId = 0x00010067, dthreadId = 0x0002022A;
//uint32 dsceneId = 0x0001000C, dthreadId = 0x00020011;//Cafeteria
-uint32 dsceneId = 0x0001000B, dthreadId = 0x00020010;
+//uint32 dsceneId = 0x0001000B, dthreadId = 0x00020010;
+uint32 dsceneId = 0x0001001A, dthreadId = 0x0002001F;
void ScriptOpcodes_BBDOU::opChangeScene(ScriptThread *scriptThread, OpCall &opCall) {
ARG_SKIP(2);
diff --git a/engines/illusions/scriptopcodes_bbdou.h b/engines/illusions/scriptopcodes_bbdou.h
index dbbc325a4d..b132011044 100644
--- a/engines/illusions/scriptopcodes_bbdou.h
+++ b/engines/illusions/scriptopcodes_bbdou.h
@@ -48,6 +48,7 @@ protected:
void opStartScriptThread(ScriptThread *scriptThread, OpCall &opCall);
void opStartTempScriptThread(ScriptThread *scriptThread, OpCall &opCall);
void opStartTimerThread(ScriptThread *scriptThread, OpCall &opCall);
+ void opNotifyThreadId(ScriptThread *scriptThread, OpCall &opCall);
void opSetThreadSceneId(ScriptThread *scriptThread, OpCall &opCall);
void opEndTalkThreads(ScriptThread *scriptThread, OpCall &opCall);
void opLoadResource(ScriptThread *scriptThread, OpCall &opCall);