aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions
diff options
context:
space:
mode:
authorjohndoe1232015-11-19 17:40:13 +0100
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit09bbb482a8ccdfb8e36128d40364900b99aa2a13 (patch)
tree45aba751e4c2fc6826c3e9db26ee4bee28e0da9d /engines/illusions
parent601c6f408210344c73dcf4f3bab34b493132387a (diff)
downloadscummvm-rg350-09bbb482a8ccdfb8e36128d40364900b99aa2a13.tar.gz
scummvm-rg350-09bbb482a8ccdfb8e36128d40364900b99aa2a13.tar.bz2
scummvm-rg350-09bbb482a8ccdfb8e36128d40364900b99aa2a13.zip
ILLUSIONS: DUCKMAN: Implement opcodes 70/71 for pausing/unpausing during the menu
Also change some input functions to return uint istead of byte to allow bigger bitmasks.
Diffstat (limited to 'engines/illusions')
-rw-r--r--engines/illusions/duckman/illusions_duckman.cpp30
-rw-r--r--engines/illusions/duckman/illusions_duckman.h3
-rw-r--r--engines/illusions/duckman/scriptopcodes_duckman.cpp20
-rw-r--r--engines/illusions/duckman/scriptopcodes_duckman.h4
-rw-r--r--engines/illusions/illusions.cpp10
-rw-r--r--engines/illusions/illusions.h2
-rw-r--r--engines/illusions/input.cpp4
-rw-r--r--engines/illusions/input.h2
-rw-r--r--engines/illusions/screen.h1
-rw-r--r--engines/illusions/thread.cpp19
-rw-r--r--engines/illusions/thread.h3
-rw-r--r--engines/illusions/threads/talkthread_duckman.cpp27
-rw-r--r--engines/illusions/threads/talkthread_duckman.h1
-rw-r--r--engines/illusions/threads/timerthread.cpp14
-rw-r--r--engines/illusions/threads/timerthread.h1
15 files changed, 133 insertions, 8 deletions
diff --git a/engines/illusions/duckman/illusions_duckman.cpp b/engines/illusions/duckman/illusions_duckman.cpp
index ed165f0c16..7255327eaa 100644
--- a/engines/illusions/duckman/illusions_duckman.cpp
+++ b/engines/illusions/duckman/illusions_duckman.cpp
@@ -231,6 +231,8 @@ void IllusionsEngine_Duckman::initInput() {
_input->setInputEvent(kEventDown, 0x80)
.addMouseButton(MOUSE_RIGHT_BUTTON)
.addKey(Common::KEYCODE_DOWN);
+ _input->setInputEvent(kEventF1, 0x100)
+ .addKey(Common::KEYCODE_F1);
}
#define UPDATEFUNCTION(priority, sceneId, callback) \
@@ -250,6 +252,16 @@ void IllusionsEngine_Duckman::initUpdateFunctions() {
int IllusionsEngine_Duckman::updateScript(uint flags) {
// TODO Some more stuff
+
+ if (_screen->isDisplayOn() && !_screen->isFaderActive() && _pauseCtr == 0) {
+ if (_input->pollEvent(kEventAbort)) {
+ startScriptThread(0x00020342, 0);
+ } else if (_input->pollEvent(kEventF1)) {
+ debug("F1");
+ startScriptThread(0x0002033F, 0);
+ }
+ }
+
_threads->updateThreads();
return kUFNext;
}
@@ -783,6 +795,24 @@ void IllusionsEngine_Duckman::dumpCurrSceneFiles(uint32 sceneId, uint32 threadId
_resSys->unloadResourcesBySceneId(sceneId);
}
+void IllusionsEngine_Duckman::pause(uint32 callerThreadId) {
+ if (++_pauseCtr == 1) {
+ _threads->pauseThreads(callerThreadId);
+ _camera->pause();
+ pauseFader();
+ // TODO largeObj_pauseControlActor(0x40004);
+ }
+}
+
+void IllusionsEngine_Duckman::unpause(uint32 callerThreadId) {
+ if (--_pauseCtr == 0) {
+ // TODO largeObj_unpauseControlActor(0x40004);
+ unpauseFader();
+ _camera->unpause();
+ _threads->unpauseThreads(callerThreadId);
+ }
+}
+
void IllusionsEngine_Duckman::setSceneIdThreadId(uint32 theSceneId, uint32 theThreadId) {
_theSceneId = theSceneId;
_theThreadId = theThreadId;
diff --git a/engines/illusions/duckman/illusions_duckman.h b/engines/illusions/duckman/illusions_duckman.h
index 5fda0d6d68..39c421dae9 100644
--- a/engines/illusions/duckman/illusions_duckman.h
+++ b/engines/illusions/duckman/illusions_duckman.h
@@ -165,6 +165,9 @@ public:
void dumpActiveScenes(uint32 sceneId, uint32 threadId);
void dumpCurrSceneFiles(uint32 sceneId, uint32 threadId);
+ void pause(uint32 callerThreadId);
+ void unpause(uint32 callerThreadId);
+
void setSceneIdThreadId(uint32 theSceneId, uint32 theThreadId);
bool findTriggerCause(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, uint32 &codeOffs);
void reset();
diff --git a/engines/illusions/duckman/scriptopcodes_duckman.cpp b/engines/illusions/duckman/scriptopcodes_duckman.cpp
index 09bf8c6716..401f2e3eed 100644
--- a/engines/illusions/duckman/scriptopcodes_duckman.cpp
+++ b/engines/illusions/duckman/scriptopcodes_duckman.cpp
@@ -74,6 +74,8 @@ void ScriptOpcodes_Duckman::initOpcodes() {
OPCODE(23, opExitModalScene);
OPCODE(24, opEnterScene24);
OPCODE(25, opLeaveScene24);
+ OPCODE(26, opEnterScene26);
+ OPCODE(27, opLeaveScene26);
OPCODE(32, opPanCenterObject);
OPCODE(33, opPanTrackObject);
OPCODE(34, opPanToObject);
@@ -101,6 +103,8 @@ void ScriptOpcodes_Duckman::initOpcodes() {
OPCODE(65, opStartCursorHoldingObject);
OPCODE(66, opPlayVideo);
OPCODE(69, opRunSpecialCode);
+ OPCODE(70, opPause);
+ OPCODE(71, opUnpause);
OPCODE(72, opStartSound);
OPCODE(75, opStopSound);
OPCODE(76, opStartMidiMusic);
@@ -327,6 +331,14 @@ void ScriptOpcodes_Duckman::opLeaveScene24(ScriptThread *scriptThread, OpCall &o
_vm->leavePause(_vm->getCurrentScene(), opCall._callerThreadId);
}
+void ScriptOpcodes_Duckman::opEnterScene26(ScriptThread *scriptThread, OpCall &opCall) {
+ // TODO
+}
+
+void ScriptOpcodes_Duckman::opLeaveScene26(ScriptThread *scriptThread, OpCall &opCall) {
+ // TODO
+}
+
void ScriptOpcodes_Duckman::opPanCenterObject(ScriptThread *scriptThread, OpCall &opCall) {
ARG_INT16(speed);
ARG_UINT32(objectId);
@@ -558,6 +570,14 @@ void ScriptOpcodes_Duckman::opRunSpecialCode(ScriptThread *scriptThread, OpCall
_vm->_specialCode->run(specialCodeId, opCall);
}
+void ScriptOpcodes_Duckman::opPause(ScriptThread *scriptThread, OpCall &opCall) {
+ _vm->pause(opCall._threadId);
+}
+
+void ScriptOpcodes_Duckman::opUnpause(ScriptThread *scriptThread, OpCall &opCall) {
+ _vm->unpause(opCall._threadId);
+}
+
void ScriptOpcodes_Duckman::opStartSound(ScriptThread *scriptThread, OpCall &opCall) {
ARG_INT16(volume);
ARG_UINT32(soundEffectId);
diff --git a/engines/illusions/duckman/scriptopcodes_duckman.h b/engines/illusions/duckman/scriptopcodes_duckman.h
index abb9982e85..5b2f089460 100644
--- a/engines/illusions/duckman/scriptopcodes_duckman.h
+++ b/engines/illusions/duckman/scriptopcodes_duckman.h
@@ -59,6 +59,8 @@ protected:
void opExitModalScene(ScriptThread *scriptThread, OpCall &opCall);
void opEnterScene24(ScriptThread *scriptThread, OpCall &opCall);
void opLeaveScene24(ScriptThread *scriptThread, OpCall &opCall);
+ void opEnterScene26(ScriptThread *scriptThread, OpCall &opCall);
+ void opLeaveScene26(ScriptThread *scriptThread, OpCall &opCall);
void opPanCenterObject(ScriptThread *scriptThread, OpCall &opCall);
void opPanTrackObject(ScriptThread *scriptThread, OpCall &opCall);
void opPanToObject(ScriptThread *scriptThread, OpCall &opCall);
@@ -86,6 +88,8 @@ protected:
void opStartCursorHoldingObject(ScriptThread *scriptThread, OpCall &opCall);
void opPlayVideo(ScriptThread *scriptThread, OpCall &opCall);
void opRunSpecialCode(ScriptThread *scriptThread, OpCall &opCall);
+ void opPause(ScriptThread *scriptThread, OpCall &opCall);
+ void opUnpause(ScriptThread *scriptThread, OpCall &opCall);
void opStartSound(ScriptThread *scriptThread, OpCall &opCall);
void opStopSound(ScriptThread *scriptThread, OpCall &opCall);
void opStartMidiMusic(ScriptThread *scriptThread, OpCall &opCall);
diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp
index d3eb50fe71..28c678c2b6 100644
--- a/engines/illusions/illusions.cpp
+++ b/engines/illusions/illusions.cpp
@@ -283,6 +283,16 @@ void IllusionsEngine::updateFader() {
}
}
+void IllusionsEngine::pauseFader() {
+ _fader->_paused = true;
+ _fader->_startTime = getCurrentTime() - _fader->_startTime;
+}
+
+void IllusionsEngine::unpauseFader() {
+ _fader->_startTime = getCurrentTime() - _fader->_startTime;
+ _fader->_paused = false;
+}
+
void IllusionsEngine::setCurrFontId(uint32 fontId) {
_fontId = fontId;
}
diff --git a/engines/illusions/illusions.h b/engines/illusions/illusions.h
index 023a45f565..b3e8141a8b 100644
--- a/engines/illusions/illusions.h
+++ b/engines/illusions/illusions.h
@@ -161,6 +161,8 @@ public:
bool isSoundActive();
void updateFader();
+ void pauseFader();
+ void unpauseFader();
void setCurrFontId(uint32 fontId);
bool checkActiveTalkThreads();
diff --git a/engines/illusions/input.cpp b/engines/illusions/input.cpp
index 1251aabc5d..3956691ef6 100644
--- a/engines/illusions/input.cpp
+++ b/engines/illusions/input.cpp
@@ -59,8 +59,8 @@ InputEvent& InputEvent::addMouseButton(int mouseButton) {
return *this;
}
-byte InputEvent::handle(Common::KeyCode key, int mouseButton, bool down) {
- byte newKeys = 0;
+uint InputEvent::handle(Common::KeyCode key, int mouseButton, bool down) {
+ uint newKeys = 0;
for (KeyMap::iterator it = _keyMap.begin(); it != _keyMap.end(); ++it) {
KeyMapping &keyMapping = *it;
if ((keyMapping._key != Common::KEYCODE_INVALID && keyMapping._key == key) ||
diff --git a/engines/illusions/input.h b/engines/illusions/input.h
index f203a64046..093adad222 100644
--- a/engines/illusions/input.h
+++ b/engines/illusions/input.h
@@ -67,7 +67,7 @@ public:
InputEvent& setBitMask(uint bitMask);
InputEvent& addKey(Common::KeyCode key);
InputEvent& addMouseButton(int mouseButton);
- byte handle(Common::KeyCode key, int mouseButton, bool down);
+ uint handle(Common::KeyCode key, int mouseButton, bool down);
uint getBitMask() const { return _bitMask; }
protected:
uint _bitMask;
diff --git a/engines/illusions/screen.h b/engines/illusions/screen.h
index bdb7ea0258..6c3e83b8ee 100644
--- a/engines/illusions/screen.h
+++ b/engines/illusions/screen.h
@@ -139,6 +139,7 @@ public:
uint16 getColorKey2() const { return _colorKey2; }
int16 getScreenWidth() const { return _backSurface->w; }
int16 getScreenHeight() const { return _backSurface->h; }
+ bool isFaderActive() const { return _isFaderActive; }
public:
IllusionsEngine *_vm;
bool _displayOn;
diff --git a/engines/illusions/thread.cpp b/engines/illusions/thread.cpp
index d12d11a81c..cea0b9728e 100644
--- a/engines/illusions/thread.cpp
+++ b/engines/illusions/thread.cpp
@@ -49,6 +49,9 @@ void Thread::onNotify() {
void Thread::onPause() {
}
+void Thread::onUnpause() {
+}
+
void Thread::onResume() {
}
@@ -72,6 +75,14 @@ void Thread::pause() {
}
}
+void Thread::unpause() {
+ if (!_terminated) {
+ --_pauseCtr;
+ if (_pauseCtr == 0)
+ onUnpause();
+ }
+}
+
void Thread::resume() {
if (!_terminated) {
--_pauseCtr;
@@ -246,6 +257,14 @@ void ThreadList::pauseThreads(uint32 threadId) {
}
}
+void ThreadList::unpauseThreads(uint32 threadId) {
+ for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
+ Thread *thread = *it;
+ if (thread->_threadId != threadId)
+ thread->unpause();
+ }
+}
+
void ThreadList::suspendThreads(uint32 threadId) {
for (Iterator it = _threads.begin(); it != _threads.end(); ++it) {
Thread *thread = *it;
diff --git a/engines/illusions/thread.h b/engines/illusions/thread.h
index cde2a41907..20edac07af 100644
--- a/engines/illusions/thread.h
+++ b/engines/illusions/thread.h
@@ -53,11 +53,13 @@ public:
virtual void onSuspend();
virtual void onNotify();
virtual void onPause();
+ virtual void onUnpause();
virtual void onResume();
virtual void onTerminated();
virtual void onKill();
virtual uint32 sendMessage(int msgNum, uint32 msgValue);
void pause();
+ void unpause();
void resume();
void suspend();
void notify();
@@ -93,6 +95,7 @@ public:
void notifyThreads(uint32 threadId);
void notifyThreadsBySceneId(uint32 sceneId, uint32 threadId);
void pauseThreads(uint32 threadId);
+ void unpauseThreads(uint32 threadId);
void suspendThreads(uint32 threadId);
void resumeThreads(uint32 threadId);
void endTalkThreads();
diff --git a/engines/illusions/threads/talkthread_duckman.cpp b/engines/illusions/threads/talkthread_duckman.cpp
index 9b7ca4eefd..5511fc523e 100644
--- a/engines/illusions/threads/talkthread_duckman.cpp
+++ b/engines/illusions/threads/talkthread_duckman.cpp
@@ -210,6 +210,33 @@ void TalkThread_Duckman::onNotify() {
}
void TalkThread_Duckman::onPause() {
+ if (_status == 5) {
+ if (!(_flags & 4)) {
+ // TODO audvocPauseVoice();
+ }
+ if (!(_flags & 8))
+ _textDurationElapsed = getDurationElapsed(_textStartTime, _textEndTime);
+ }
+}
+
+void TalkThread_Duckman::onUnpause() {
+ if (_status == 3) {
+ TalkEntry *talkEntry = getTalkResourceEntry(_talkId);
+ if (!_vm->isSoundActive())
+ _vm->_soundMan->cueVoice((char*)talkEntry->_voiceName);
+ } else if (_status == 5) {
+ if (!(_flags & 4)) {
+ // TODO audvocUnpauseVoice();
+ }
+ if (!(_flags & 8)) {
+ _textStartTime = getCurrentTime();
+ if (_textDuration <= _textDurationElapsed)
+ _textEndTime = _textStartTime;
+ else
+ _textEndTime = _textStartTime + _textDuration - _textDurationElapsed;
+ _textDurationElapsed = 0;
+ }
+ }
}
void TalkThread_Duckman::onResume() {
diff --git a/engines/illusions/threads/talkthread_duckman.h b/engines/illusions/threads/talkthread_duckman.h
index b729ad2d8f..6f4758dc33 100644
--- a/engines/illusions/threads/talkthread_duckman.h
+++ b/engines/illusions/threads/talkthread_duckman.h
@@ -44,6 +44,7 @@ public:
virtual void onSuspend();
virtual void onNotify();
virtual void onPause();
+ virtual void onUnpause();
virtual void onResume();
virtual void onTerminated();
virtual void onKill();
diff --git a/engines/illusions/threads/timerthread.cpp b/engines/illusions/threads/timerthread.cpp
index 417d113210..de1502d9f2 100644
--- a/engines/illusions/threads/timerthread.cpp
+++ b/engines/illusions/threads/timerthread.cpp
@@ -52,10 +52,18 @@ int TimerThread::onUpdate() {
}
void TimerThread::onSuspend() {
- _durationElapsed = getDurationElapsed(_startTime, _endTime);
+ onPause();
}
void TimerThread::onNotify() {
+ onUnpause();
+}
+
+void TimerThread::onPause() {
+ _durationElapsed = getDurationElapsed(_startTime, _endTime);
+}
+
+void TimerThread::onUnpause() {
uint32 currTime = getCurrentTime();
_startTime = currTime;
if (_duration <= _durationElapsed)
@@ -65,10 +73,6 @@ void TimerThread::onNotify() {
_durationElapsed = 0;
}
-void TimerThread::onPause() {
- onSuspend();
-}
-
void TimerThread::onResume() {
onNotify();
}
diff --git a/engines/illusions/threads/timerthread.h b/engines/illusions/threads/timerthread.h
index d283dc40ba..7e1b61319b 100644
--- a/engines/illusions/threads/timerthread.h
+++ b/engines/illusions/threads/timerthread.h
@@ -37,6 +37,7 @@ public:
virtual void onSuspend();
virtual void onNotify();
virtual void onPause();
+ virtual void onUnpause();
virtual void onResume();
virtual void onTerminated();
public: