aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorjohndoe1232014-03-20 14:16:48 +0100
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit43cd806f17377d5244e575b863519f013e5f033c (patch)
tree089f4367800ac59a51d23cbaeea9958e554b6a23 /engines
parentf47575ca906682bab942d19a36cc33ea7465a4b2 (diff)
downloadscummvm-rg350-43cd806f17377d5244e575b863519f013e5f033c.tar.gz
scummvm-rg350-43cd806f17377d5244e575b863519f013e5f033c.tar.bz2
scummvm-rg350-43cd806f17377d5244e575b863519f013e5f033c.zip
ILLUSIONS: Add more script opcodes
Diffstat (limited to 'engines')
-rw-r--r--engines/illusions/actor.cpp40
-rw-r--r--engines/illusions/actor.h1
-rw-r--r--engines/illusions/cursor.cpp93
-rw-r--r--engines/illusions/cursor.h53
-rw-r--r--engines/illusions/illusions.cpp25
-rw-r--r--engines/illusions/illusions.h6
-rw-r--r--engines/illusions/module.mk1
-rw-r--r--engines/illusions/scriptman.cpp22
-rw-r--r--engines/illusions/scriptman.h5
-rw-r--r--engines/illusions/scriptopcodes.cpp132
-rw-r--r--engines/illusions/scriptopcodes.h9
-rw-r--r--engines/illusions/sequenceopcodes.cpp1
12 files changed, 330 insertions, 58 deletions
diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp
index ad91b0200f..5ba576b546 100644
--- a/engines/illusions/actor.cpp
+++ b/engines/illusions/actor.cpp
@@ -23,6 +23,7 @@
#include "illusions/illusions.h"
#include "illusions/actor.h"
#include "illusions/camera.h"
+#include "illusions/cursor.h"
#include "illusions/dictionary.h"
#include "illusions/input.h"
#include "illusions/screen.h"
@@ -210,7 +211,7 @@ void Control::pause() {
_vm->_dict->setObjectControl(_objectId, 0);
if (_objectId == 0x40004)
- _vm->setCursorControl(0);
+ _vm->_cursor->setControl(0);
if (_actor && !(_actor->_flags & 0x0200))
_actor->destroySurface();
@@ -222,7 +223,7 @@ void Control::unpause() {
_vm->_dict->setObjectControl(_objectId, this);
if (_objectId == 0x40004)
- _vm->setCursorControl(this);
+ _vm->_cursor->setControl(this);
if (_actor && !(_actor->_flags & 0x0200)) {
SurfInfo surfInfo;
@@ -238,15 +239,7 @@ void Control::unpause() {
void Control::appearActor() {
if (_objectId == 0x40004) {
- if (_vm->showCursor()) {
- _flags |= 1;
- _actor->_flags |= 1;
- if (_actor->_frameIndex) {
- _actor->_flags |= 0x2000;
- _actor->_flags |= 0x4000;
- }
- _vm->_input->discardButtons(0xFFFF);
- }
+ _vm->_cursor->show();
} else {
if (_actor->_frameIndex || _actorTypeId == 0x50004)
_actor->_flags |= 1;
@@ -262,10 +255,7 @@ void Control::appearActor() {
void Control::disappearActor() {
if (_objectId == 0x40004) {
- if (_vm->hideCursor()) {
- _flags &= ~1;
- _actor->_flags &= ~1;
- }
+ _vm->_cursor->hide();
} else {
_actor->_flags &= ~1;
_actor->_flags &= ~0x1000;
@@ -653,10 +643,8 @@ void Controls::placeActor(uint32 actorTypeId, Common::Point placePt, uint32 sequ
control->readPointsConfig(actorType->_pointsConfig);
control->_actorTypeId = actorTypeId;
control->_actor = actor;
- /* TODO
if (actorTypeId == 0x50001 && objectId == 0x40004)
- actor->setControlRoutine(Cursor_controlRoutine);
- */
+ actor->setControlRoutine(new Common::Functor2Mem<Control*, uint32, void, Cursor>(_vm->_cursor, &Cursor::cursorControlRoutine));
if (actorType->_surfInfo._dimensions._width > 0 || actorType->_surfInfo._dimensions._height > 0) {
actor->createSurface(actorType->_surfInfo);
} else {
@@ -703,7 +691,7 @@ void Controls::placeActor(uint32 actorTypeId, Common::Point placePt, uint32 sequ
_vm->_dict->setObjectControl(objectId, control);
if (actorTypeId == 0x50001 && objectId == 0x40004)
- _vm->placeCursor(control, sequenceId);
+ _vm->_cursor->place(control, sequenceId);
control->_flags |= 0x01;
actor->_flags |= 0x1000;
@@ -760,6 +748,17 @@ void Controls::placeActorLessObject(uint32 objectId, Common::Point feetPt, Commo
_vm->_dict->setObjectControl(objectId, control);
}
+void Controls::destroyControlsByTag(uint32 tag) {
+ ItemsIterator it = _controls.begin();
+ while (it != _controls.end()) {
+ if ((*it)->_tag == tag) {
+ destroyControl(*it);
+ it = _controls.erase(it);
+ } else
+ ++it;
+ }
+}
+
Actor *Controls::newActor() {
return new Actor(_vm);
}
@@ -769,13 +768,12 @@ Control *Controls::newControl() {
}
void Controls::destroyControl(Control *control) {
- _controls.remove(control);
if (control->_pauseCtr <= 0)
_vm->_dict->setObjectControl(control->_objectId, 0);
if (control->_objectId == 0x40004 && control->_pauseCtr <= 0)
- _vm->setCursorControl(0);
+ _vm->_cursor->setControl(0);
if (control->_actor) {
/* TODO
diff --git a/engines/illusions/actor.h b/engines/illusions/actor.h
index b37e1317eb..59660532c3 100644
--- a/engines/illusions/actor.h
+++ b/engines/illusions/actor.h
@@ -196,6 +196,7 @@ public:
void placeActor(uint32 actorTypeId, Common::Point placePt, uint32 sequenceId, uint32 objectId, uint32 notifyThreadId);
void placeSequenceLessActor(uint32 objectId, Common::Point placePt, WidthHeight dimensions, int16 priority);
void placeActorLessObject(uint32 objectId, Common::Point feetPt, Common::Point pt, int16 priority, uint flags);
+ void destroyControlsByTag(uint32 tag);
void actorControlRouine(Control *control, uint32 deltaTime);
public:
typedef Common::List<Control*> Items;
diff --git a/engines/illusions/cursor.cpp b/engines/illusions/cursor.cpp
new file mode 100644
index 0000000000..36ab97a633
--- /dev/null
+++ b/engines/illusions/cursor.cpp
@@ -0,0 +1,93 @@
+/* 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/actor.h"
+#include "illusions/cursor.h"
+#include "illusions/input.h"
+
+namespace Illusions {
+
+Cursor::Cursor(IllusionsEngine *vm)
+ : _vm(vm) {
+ _status = 1;
+ _control = 0;
+ _x = 320;
+ _y = 240;
+ _cursorNum = 1;
+ _field_10 = 0;
+ _sequenceId = 0;
+}
+
+void Cursor::place(Control *control, uint32 sequenceId) {
+ _status = 2;
+ _control = control;
+ _cursorNum = 1;
+ _field_10 = 0;
+ _sequenceId = sequenceId;
+ _visibleCtr = 0;
+ _control->_flags |= 8;
+ setActorIndex(_cursorNum, 1, 0);
+ _vm->_input->setCursorPosition(_control->_actor->_position);
+}
+
+void Cursor::setActorIndex(int a2, int a3, int a4) {
+ _control->_actor->_actorIndex = 1;// TODO?!? *((_BYTE *)&stru_42C040[30].y + 2 * ((always0 != 0) + 2 * a2) + a3 + 1);
+}
+
+void Cursor::setControl(Control *control) {
+ _control = control;
+}
+
+void Cursor::show() {
+ ++_visibleCtr;
+ if (_visibleCtr > 0) {
+ _control->_flags |= 1;
+ _control->_actor->_flags |= 1;
+ if (_control->_actor->_frameIndex) {
+ _control->_actor->_flags |= 0x2000;
+ _control->_actor->_flags |= 0x4000;
+ }
+ _vm->_input->discardButtons(0xFFFF);
+ }
+}
+
+void Cursor::hide() {
+ --_visibleCtr;
+ if (_visibleCtr < 0) {
+ _control->_flags &= ~1;
+ _control->_actor->_flags &= ~1;
+ }
+}
+
+void Cursor::cursorControlRoutine(Control *control, uint32 deltaTime) {
+ _control->_actor->_seqCodeValue1 = 100 * deltaTime;
+ if (_control->_actor->_flags & 1) {
+ if (_status == 2) {
+ // Unused nullsub_1(control);
+ } else if (_status == 3) {
+ // TODO _vm->_shellMgr->handleMouse(_control);
+ }
+ }
+}
+
+} // End of namespace Illusions
diff --git a/engines/illusions/cursor.h b/engines/illusions/cursor.h
new file mode 100644
index 0000000000..3179b71917
--- /dev/null
+++ b/engines/illusions/cursor.h
@@ -0,0 +1,53 @@
+/* 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_CURSOR_H
+#define ILLUSIONS_CURSOR_H
+
+namespace Illusions {
+
+class Control;
+class IllusionsEngine;
+
+class Cursor {
+public:
+ Cursor(IllusionsEngine *vm);
+ void place(Control *control, uint32 sequenceId);
+ void setActorIndex(int a2, int a3, int a4);
+ void setControl(Control *control);
+ void show();
+ void hide();
+ void cursorControlRoutine(Control *control, uint32 deltaTime);
+protected:
+ IllusionsEngine *_vm;
+ Control *_control;
+ uint32 _sequenceId;
+ int _status;
+ int _cursorNum;
+ int _field_10;
+ int _visibleCtr;
+ int16 _x, _y;
+};
+
+} // End of namespace Illusions
+
+#endif // ILLUSIONS_CURSOR_H
diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp
index 1d591c76f6..89668140cb 100644
--- a/engines/illusions/illusions.cpp
+++ b/engines/illusions/illusions.cpp
@@ -25,6 +25,7 @@
#include "illusions/actorresource.h"
#include "illusions/backgroundresource.h"
#include "illusions/camera.h"
+#include "illusions/cursor.h"
#include "illusions/dictionary.h"
#include "illusions/fontresource.h"
#include "illusions/graphics.h"
@@ -102,6 +103,7 @@ Common::Error IllusionsEngine::run() {
_backgroundItems = new BackgroundItems(this);
_camera = new Camera(this);
_controls = new Controls(this);
+ _cursor = new Cursor(this);
// TODO Move to own class
_resGetCtr = 0;
@@ -176,6 +178,7 @@ Common::Error IllusionsEngine::run() {
}
#endif
+ delete _cursor;
delete _controls;
delete _camera;
delete _backgroundItems;
@@ -242,28 +245,6 @@ void IllusionsEngine::notifyThreadId(uint32 &threadId) {
}
}
-void IllusionsEngine::setCursorControl(Control *control) {
- // TODO Dummy, to be replaced later
-}
-
-void IllusionsEngine::placeCursor(Control *control, uint32 sequenceId) {
- // TODO Dummy, to be replaced later
-}
-
-bool IllusionsEngine::showCursor() {
- // TODO Dummy, to be replaced later
- // TODO ++cursor._visibleCtr;
- // TODO if (cursor._visibleCtr > 0)
- return false;
-}
-
-bool IllusionsEngine::hideCursor() {
- // TODO Dummy, to be replaced later
- // TODO --cursor._visibleCtr;
- // TODO if (cursor.visibleCtr <= 0)
- return false;
-}
-
uint32 IllusionsEngine::getElapsedUpdateTime() {
uint32 result = 0;
uint32 currTime = getCurrentTime();
diff --git a/engines/illusions/illusions.h b/engines/illusions/illusions.h
index 797d8a31ea..c82f2c1576 100644
--- a/engines/illusions/illusions.h
+++ b/engines/illusions/illusions.h
@@ -57,6 +57,7 @@ class BackgroundResource;
class Camera;
class Control;
class Controls;
+class Cursor;
class Dictionary;
class Input;
class Screen;
@@ -91,6 +92,7 @@ public:
BackgroundItems *_backgroundItems;
Camera *_camera;
Controls *_controls;
+ Cursor *_cursor;
int _resGetCtr;
uint32 _resGetTime;
@@ -101,10 +103,6 @@ public:
void notifyThreadId(uint32 &threadId);
- void setCursorControl(Control *control);
- void placeCursor(Control *control, uint32 sequenceId);
- bool showCursor();
- bool hideCursor();
uint32 getElapsedUpdateTime();
int updateActors();
int updateSequences();
diff --git a/engines/illusions/module.mk b/engines/illusions/module.mk
index 9121343b3b..edaa94f32a 100644
--- a/engines/illusions/module.mk
+++ b/engines/illusions/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS := \
actorresource.o \
backgroundresource.o \
camera.o \
+ cursor.o \
detection.o \
dictionary.o \
fixedpoint.o \
diff --git a/engines/illusions/scriptman.cpp b/engines/illusions/scriptman.cpp
index d94a32316a..527c0a5f3e 100644
--- a/engines/illusions/scriptman.cpp
+++ b/engines/illusions/scriptman.cpp
@@ -21,6 +21,7 @@
*/
#include "illusions/illusions.h"
+#include "illusions/actor.h"
#include "illusions/scriptman.h"
#include "illusions/scriptthread.h"
#include "illusions/scriptopcodes.h"
@@ -116,6 +117,10 @@ int16 ScriptStack::peek() {
return value;
}
+int16 *ScriptStack::topPtr() {
+ return &_stack[_stackPos];
+}
+
// ScriptMan
ScriptMan::ScriptMan(IllusionsEngine *vm)
@@ -170,6 +175,12 @@ void ScriptMan::setCurrFontId(uint32 fontId) {
_fontId = fontId;
}
+void ScriptMan::reset() {
+ // TODO _scriptResource->_blockCounters.clear();
+ // TODO _scriptResource->_properties.clear();
+ // TODO script_sub_417FF0(1, 0);
+}
+
bool ScriptMan::enterScene(uint32 sceneId, uint32 threadId) {
ProgInfo *progInfo = _scriptResource->getProgInfo(sceneId & 0xFFFF);
if (!progInfo) {
@@ -180,6 +191,17 @@ bool ScriptMan::enterScene(uint32 sceneId, uint32 threadId) {
return progInfo != 0;
}
+void ScriptMan::exitScene(uint32 threadId) {
+ uint32 sceneId = _activeScenes.getCurrentScene();
+ // TODO krnfileDump(sceneId);
+ // TODO UpdateFunctions_disableByTag__TODO_maybe(sceneId);
+ _threads->terminateThreadsByTag(sceneId, threadId);
+ _vm->_controls->destroyControlsByTag(sceneId);
+ // TODO causeFunc_removeBySceneId(sceneId);
+ // TODO _vm->_resSys->unloadResourceByTag(sceneId);
+ _activeScenes.pop();
+}
+
void ScriptMan::newScriptThread(uint32 threadId, uint32 callingThreadId, uint notifyFlags,
byte *scriptCodeIp, uint32 value8, uint32 valueC, uint32 value10) {
ScriptThread *scriptThread = new ScriptThread(_vm, threadId, callingThreadId, notifyFlags,
diff --git a/engines/illusions/scriptman.h b/engines/illusions/scriptman.h
index da0f6b6e04..4bbd669928 100644
--- a/engines/illusions/scriptman.h
+++ b/engines/illusions/scriptman.h
@@ -61,6 +61,7 @@ public:
void push(int16 value);
int16 pop();
int16 peek();
+ int16 *topPtr();
protected:
int _stackPos;
int16 _stack[256];
@@ -80,7 +81,9 @@ public:
uint32 startAbortableTimerThread(uint32 duration, uint32 threadId);
uint32 startTimerThread(uint32 duration, uint32 threadId);
void setCurrFontId(uint32 fontId);
+ void reset();
bool enterScene(uint32 sceneId, uint32 threadId);
+ void exitScene(uint32 threadId);
public:
IllusionsEngine *_vm;
@@ -97,11 +100,13 @@ public:
uint32 _nextTempThreadId;
uint32 _fontId;
+ uint32 _prevSceneId;
ThreadList *_threads;
ScriptOpcodes *_scriptOpcodes;
uint32 _callerThreadId;
+ int16 _menuChoiceOfs;
void newScriptThread(uint32 threadId, uint32 callingThreadId, uint notifyFlags,
byte *scriptCodeIp, uint32 value8, uint32 valueC, uint32 value10);
diff --git a/engines/illusions/scriptopcodes.cpp b/engines/illusions/scriptopcodes.cpp
index 72c455ad08..a40429b5b0 100644
--- a/engines/illusions/scriptopcodes.cpp
+++ b/engines/illusions/scriptopcodes.cpp
@@ -66,9 +66,9 @@ ScriptOpcodes::~ScriptOpcodes() {
}
void ScriptOpcodes::execOpcode(ScriptThread *scriptThread, OpCall &opCall) {
+ debug("\nexecOpcode([%08X] %d)", opCall._callerThreadId, opCall._op);
if (!_opcodes[opCall._op])
error("ScriptOpcodes::execOpcode() Unimplemented opcode %d", opCall._op);
- debug("\nexecOpcode(%d)", opCall._op);
(*_opcodes[opCall._op])(scriptThread, opCall);
}
@@ -90,6 +90,7 @@ void ScriptOpcodes::initOpcodes() {
OPCODE(14, opSetThreadSceneId);
OPCODE(16, opLoadResource);
OPCODE(20, opEnterScene);
+ OPCODE(25, opChangeScene);
OPCODE(39, opSetDisplay);
OPCODE(42, opIncBlockCounter);
OPCODE(45, opSetProperty);
@@ -97,19 +98,27 @@ void ScriptOpcodes::initOpcodes() {
OPCODE(49, opStartSequenceActor);
OPCODE(57, opAppearActor);
OPCODE(58, opDisappearActor);
+ OPCODE(61, opDeactivateObject);
OPCODE(63, opSetSelectSfx);
OPCODE(64, opSetMoveSfx);
OPCODE(65, opSetDenySfx);
OPCODE(66, opSetAdjustUpSfx);
OPCODE(67, opSetAdjustDnSfx);
OPCODE(75, opStartMusic);
+ OPCODE(80, opAddMenuChoice);
+ OPCODE(81, opDisplayMenu);
+ OPCODE(82, opSwitchMenuChoice);
+ OPCODE(84, opResetGame);
OPCODE(87, opDeactivateButton);
OPCODE(88, opActivateButton);
OPCODE(103, opJumpIf);
+ OPCODE(110, opGetProperty);
+ OPCODE(111, opCompareBlockCounter);
OPCODE(126, opDebug126);
OPCODE(144, opPlayVideo);
OPCODE(148, opLoadSpecialCodeModule);
OPCODE(150, opRunSpecialCode);
+ OPCODE(161, opSetActorUsePan);
OPCODE(175, opSetSceneIdThreadId);
OPCODE(176, opStackPush0);
OPCODE(177, opSetFontId);
@@ -198,25 +207,39 @@ void ScriptOpcodes::opEnterScene(ScriptThread *scriptThread, OpCall &opCall) {
_vm->_scriptMan->_activeScenes.getActiveSceneInfo(scenesCount - 1, &currSceneId, 0);
// TODO krnfileDump(currSceneId);
}
- if (!_vm->_scriptMan->enterScene(sceneId, opCall._threadId))
+ if (!_vm->_scriptMan->enterScene(sceneId, opCall._callerThreadId))
opCall._result = kTSTerminate;
}
+void ScriptOpcodes::opChangeScene(ScriptThread *scriptThread, OpCall &opCall) {
+ ARG_SKIP(2);
+ ARG_UINT32(sceneId);
+ ARG_UINT32(threadId);
+ // NOTE Skipped checking for stalled resources
+ _vm->_input->discardButtons(0xFFFF);
+ _vm->_scriptMan->_prevSceneId = _vm->_scriptMan->_activeScenes.getCurrentScene();
+ _vm->_scriptMan->exitScene(opCall._callerThreadId);
+ _vm->_scriptMan->enterScene(sceneId, opCall._callerThreadId);
+ // TODO _vm->_gameStates->writeStates(_vm->_scriptMan->_prevSceneId, sceneId, threadId);
+ _vm->_scriptMan->startAnonScriptThread(threadId, 0,
+ scriptThread->_value8, scriptThread->_valueC, scriptThread->_value10);
+}
+
void ScriptOpcodes::opSetDisplay(ScriptThread *scriptThread, OpCall &opCall) {
ARG_INT16(flag);
_vm->_screen->setDisplayOn(flag != 0);
}
void ScriptOpcodes::opIncBlockCounter(ScriptThread *scriptThread, OpCall &opCall) {
- ARG_INT16(index)
- byte value = _vm->_scriptMan->_scriptResource->_blockCounters.get(index + 1);
+ ARG_INT16(index);
+ byte value = _vm->_scriptMan->_scriptResource->_blockCounters.get(index) + 1;
if (value <= 63)
- _vm->_scriptMan->_scriptResource->_blockCounters.set(index + 1, value);
+ _vm->_scriptMan->_scriptResource->_blockCounters.set(index, value);
}
void ScriptOpcodes::opSetProperty(ScriptThread *scriptThread, OpCall &opCall) {
- ARG_INT16(value)
- ARG_INT16(propertyId)
+ ARG_INT16(value);
+ ARG_UINT32(propertyId);
// TODO _vm->_scriptMan->_scriptResource->_properties.set(propertyId, value);
}
@@ -259,6 +282,14 @@ void ScriptOpcodes::opDisappearActor(ScriptThread *scriptThread, OpCall &opCall)
control->disappearActor();
}
+void ScriptOpcodes::opDeactivateObject(ScriptThread *scriptThread, OpCall &opCall) {
+ ARG_SKIP(2);
+ ARG_UINT32(objectId);
+ Control *control = _vm->_dict->getObjectControl(objectId);
+ if (control)
+ control->deactivateObject();
+}
+
void ScriptOpcodes::opSetSelectSfx(ScriptThread *scriptThread, OpCall &opCall) {
ARG_SKIP(2);
ARG_UINT32(soundEffectId);
@@ -290,13 +321,51 @@ void ScriptOpcodes::opSetAdjustDnSfx(ScriptThread *scriptThread, OpCall &opCall)
}
void ScriptOpcodes::opStartMusic(ScriptThread *scriptThread, OpCall &opCall) {
ARG_SKIP(2);
- ARG_INT16(volume)
- ARG_INT16(pan)
+ ARG_INT16(volume);
+ ARG_INT16(pan);
ARG_UINT32(musicId);
ARG_UINT32(type);
// TODO _vm->playMusic(musicId, type, volume, pan);
}
+void ScriptOpcodes::opAddMenuChoice(ScriptThread *scriptThread, OpCall &opCall) {
+ ARG_SKIP(2);
+ ARG_INT16(jumpOffs);
+ ARG_INT16(endMarker);
+ _vm->_scriptMan->_stack.push(endMarker);
+ _vm->_scriptMan->_stack.push(jumpOffs);
+}
+
+void ScriptOpcodes::opDisplayMenu(ScriptThread *scriptThread, OpCall &opCall) {
+ ARG_INT16(unk1);
+ ARG_UINT32(menuId);
+ ARG_UINT32(unk2);
+ // TODO _vm->_shellMgr->displayMenu(_vm->_scriptMan->_stack.topPtr(), &_vm->_scriptMan->_menuChoiceOfs, menuId, unk1, unk2, opCall._callerThreadId);
+ // Remove menu choices from the stack
+ do {
+ _vm->_scriptMan->_stack.pop();
+ } while (_vm->_scriptMan->_stack.pop() == 0);
+
+ //DEBUG Resume calling thread, later done by the video player
+ _vm->notifyThreadId(opCall._callerThreadId);
+
+}
+
+void ScriptOpcodes::opSwitchMenuChoice(ScriptThread *scriptThread, OpCall &opCall) {
+_vm->_scriptMan->_menuChoiceOfs = 88; // DEBUG Chose "Start game"
+
+ opCall._deltaOfs += _vm->_scriptMan->_menuChoiceOfs;
+debug("deltaOfs = %08X", opCall._deltaOfs);
+}
+
+void ScriptOpcodes::opResetGame(ScriptThread *scriptThread, OpCall &opCall) {
+ _vm->_scriptMan->_threads->terminateThreads(opCall._callerThreadId);
+ _vm->_scriptMan->reset();
+ _vm->_input->activateButton(0xFFFF);
+ // TODO _vm->stopMusic();
+ // TODO _vm->_gameStates->clear();
+}
+
void ScriptOpcodes::opDeactivateButton(ScriptThread *scriptThread, OpCall &opCall) {
ARG_INT16(button)
_vm->_input->deactivateButton(button);
@@ -314,6 +383,42 @@ void ScriptOpcodes::opJumpIf(ScriptThread *scriptThread, OpCall &opCall) {
opCall._deltaOfs += jumpOffs;
}
+void ScriptOpcodes::opGetProperty(ScriptThread *scriptThread, OpCall &opCall) {
+ ARG_SKIP(2);
+ ARG_UINT32(propertyId)
+ int16 value = 0;// TODO _vm->_scriptMan->_scriptResource->_properties.get(propertyId);
+ _vm->_scriptMan->_stack.push(value);
+}
+
+void ScriptOpcodes::opCompareBlockCounter(ScriptThread *scriptThread, OpCall &opCall) {
+ ARG_INT16(index);
+ ARG_INT16(compareOp);
+ ARG_INT16(rvalue);
+ int16 lvalue = _vm->_scriptMan->_scriptResource->_blockCounters.get(index);
+ bool compareResult = false;
+ switch (compareOp) {
+ case 1:
+ compareResult = lvalue == rvalue;
+ break;
+ case 2:
+ compareResult = lvalue != rvalue;
+ break;
+ case 3:
+ compareResult = lvalue < rvalue;
+ break;
+ case 4:
+ compareResult = lvalue > rvalue;
+ break;
+ case 5:
+ compareResult = lvalue >= rvalue;
+ break;
+ case 6:
+ compareResult = lvalue <= rvalue;
+ break;
+ }
+ _vm->_scriptMan->_stack.push(compareResult ? 1 : 0);
+}
+
void ScriptOpcodes::opDebug126(ScriptThread *scriptThread, OpCall &opCall) {
// NOTE Prints some debug text
debug("[DBG] %s", (char*)opCall._code);
@@ -345,10 +450,17 @@ void ScriptOpcodes::opRunSpecialCode(ScriptThread *scriptThread, OpCall &opCall)
_vm->_scriptMan->_callerThreadId = 0;
//DEBUG Resume calling thread, later done by the special code
- _vm->notifyThreadId(opCall._threadId);
+ _vm->notifyThreadId(opCall._callerThreadId);
}
+void ScriptOpcodes::opSetActorUsePan(ScriptThread *scriptThread, OpCall &opCall) {
+ ARG_INT16(usePan)
+ ARG_UINT32(objectId);
+ Control *control = _vm->_dict->getObjectControl(objectId);
+ control->setActorUsePan(usePan);
+}
+
void ScriptOpcodes::opSetSceneIdThreadId(ScriptThread *scriptThread, OpCall &opCall) {
ARG_SKIP(2);
ARG_UINT32(sceneId);
diff --git a/engines/illusions/scriptopcodes.h b/engines/illusions/scriptopcodes.h
index 4d14010f2f..5187c9e057 100644
--- a/engines/illusions/scriptopcodes.h
+++ b/engines/illusions/scriptopcodes.h
@@ -68,6 +68,7 @@ protected:
void opSetThreadSceneId(ScriptThread *scriptThread, OpCall &opCall);
void opLoadResource(ScriptThread *scriptThread, OpCall &opCall);
void opEnterScene(ScriptThread *scriptThread, OpCall &opCall);
+ void opChangeScene(ScriptThread *scriptThread, OpCall &opCall);
void opSetDisplay(ScriptThread *scriptThread, OpCall &opCall);
void opIncBlockCounter(ScriptThread *scriptThread, OpCall &opCall);
void opSetProperty(ScriptThread *scriptThread, OpCall &opCall);
@@ -75,19 +76,27 @@ protected:
void opStartSequenceActor(ScriptThread *scriptThread, OpCall &opCall);
void opAppearActor(ScriptThread *scriptThread, OpCall &opCall);
void opDisappearActor(ScriptThread *scriptThread, OpCall &opCall);
+ void opDeactivateObject(ScriptThread *scriptThread, OpCall &opCall);
void opSetSelectSfx(ScriptThread *scriptThread, OpCall &opCall);
void opSetMoveSfx(ScriptThread *scriptThread, OpCall &opCall);
void opSetDenySfx(ScriptThread *scriptThread, OpCall &opCall);
void opSetAdjustUpSfx(ScriptThread *scriptThread, OpCall &opCall);
void opSetAdjustDnSfx(ScriptThread *scriptThread, OpCall &opCall);
void opStartMusic(ScriptThread *scriptThread, OpCall &opCall);
+ void opAddMenuChoice(ScriptThread *scriptThread, OpCall &opCall);
+ void opDisplayMenu(ScriptThread *scriptThread, OpCall &opCall);
+ void opSwitchMenuChoice(ScriptThread *scriptThread, OpCall &opCall);
+ void opResetGame(ScriptThread *scriptThread, OpCall &opCall);
void opDeactivateButton(ScriptThread *scriptThread, OpCall &opCall);
void opActivateButton(ScriptThread *scriptThread, OpCall &opCall);
void opJumpIf(ScriptThread *scriptThread, OpCall &opCall);
+ void opGetProperty(ScriptThread *scriptThread, OpCall &opCall);
+ void opCompareBlockCounter(ScriptThread *scriptThread, OpCall &opCall);
void opDebug126(ScriptThread *scriptThread, OpCall &opCall);
void opPlayVideo(ScriptThread *scriptThread, OpCall &opCall);
void opLoadSpecialCodeModule(ScriptThread *scriptThread, OpCall &opCall);
void opRunSpecialCode(ScriptThread *scriptThread, OpCall &opCall);
+ void opSetActorUsePan(ScriptThread *scriptThread, OpCall &opCall);
void opSetSceneIdThreadId(ScriptThread *scriptThread, OpCall &opCall);
void opStackPush0(ScriptThread *scriptThread, OpCall &opCall);
void opSetFontId(ScriptThread *scriptThread, OpCall &opCall);
diff --git a/engines/illusions/sequenceopcodes.cpp b/engines/illusions/sequenceopcodes.cpp
index 4eaa7a9c38..4dc3b29a9c 100644
--- a/engines/illusions/sequenceopcodes.cpp
+++ b/engines/illusions/sequenceopcodes.cpp
@@ -180,7 +180,6 @@ void SequenceOpcodes::opNextLoop(Control *control, OpCall &opCall) {
void SequenceOpcodes::opSwitchActorIndex(Control *control, OpCall &opCall) {
ARG_INT16(actorIndex);
ARG_INT16(jumpOffs);
- debug("control->_objectId = %08X", control->_objectId);
if (control->_actor->_actorIndex != actorIndex)
opCall._deltaOfs += jumpOffs;
}