aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions
diff options
context:
space:
mode:
authorjohndoe1232015-12-05 00:27:30 +0100
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit823ba2f462ff75370d1091b5c59dc950b815eed9 (patch)
treec0390e91b5034869de304423b906d8633e5f5945 /engines/illusions
parent2de38e3469e85e56b6401a9c3cd97ead2249f67e (diff)
downloadscummvm-rg350-823ba2f462ff75370d1091b5c59dc950b815eed9.tar.gz
scummvm-rg350-823ba2f462ff75370d1091b5c59dc950b815eed9.tar.bz2
scummvm-rg350-823ba2f462ff75370d1091b5c59dc950b815eed9.zip
ILLUSIONS: DUCKMAN: Implement load game from the game's menu system
- Fix pause/unpause opcodes - Reduce debug output
Diffstat (limited to 'engines/illusions')
-rw-r--r--engines/illusions/actor.cpp14
-rw-r--r--engines/illusions/duckman/illusions_duckman.cpp3
-rw-r--r--engines/illusions/duckman/menusystem_duckman.cpp16
-rw-r--r--engines/illusions/duckman/scriptopcodes_duckman.cpp20
-rw-r--r--engines/illusions/illusions.h1
-rw-r--r--engines/illusions/menusystem.cpp41
-rw-r--r--engines/illusions/menusystem.h9
-rw-r--r--engines/illusions/scriptopcodes.cpp2
-rw-r--r--engines/illusions/scriptopcodes.h6
-rw-r--r--engines/illusions/sequenceopcodes.cpp2
10 files changed, 74 insertions, 40 deletions
diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp
index 29a1e6883c..33610ca6af 100644
--- a/engines/illusions/actor.cpp
+++ b/engines/illusions/actor.cpp
@@ -623,7 +623,7 @@ void Control::sequenceActor() {
while (_actor->_seqCodeValue3 <= 0 && !sequenceFinished) {
bool breakInner = false;
while (!breakInner) {
- debug(1, "[%08X] SEQ[%08X] op: %08X", _objectId, _actor->_sequenceId, _actor->_seqCodeIp[0]);
+ //debug(1, "[%08X] SEQ[%08X] op: %08X", _objectId, _actor->_sequenceId, _actor->_seqCodeIp[0]);
opCall._op = _actor->_seqCodeIp[0] & 0x7F;
opCall._opSize = _actor->_seqCodeIp[1];
opCall._code = _actor->_seqCodeIp + 2;
@@ -643,18 +643,18 @@ void Control::sequenceActor() {
}
if (_actor->_newFrameIndex != 0) {
- debug(1, "New frame %d", _actor->_newFrameIndex);
+ //debug(1, "New frame %d", _actor->_newFrameIndex);
setActorFrameIndex(_actor->_newFrameIndex);
if (_vm->getGameId() == kGameIdBBDOU &&
!(_actor->_flags & 1) && (_actor->_flags & 0x1000) && (_objectId != 0x40004)) {
appearActor();
_actor->_flags &= ~0x1000;
}
- debug(1, "New frame OK");
+ //debug(1, "New frame OK");
}
if (sequenceFinished) {
- debug(1, "Sequence has finished");
+ //debug(1, "Sequence has finished");
_actor->_seqCodeIp = 0;
}
@@ -772,7 +772,7 @@ PointArray *Control::createPath(Common::Point destPt) {
WidthHeight bgDimensions = _vm->_backgroundInstances->getMasterBgDimensions();
PointArray *path = pathFinder.findPath(_actor->_position, destPt, walkPoints, walkRects, bgDimensions);
for (uint i = 0; i < path->size(); ++i) {
- debug(0, "Path(%d) (%d, %d)", i, (*path)[i].x, (*path)[i].y);
+ //debug(0, "Path(%d) (%d, %d)", i, (*path)[i].x, (*path)[i].y);
}
return path;
}
@@ -963,7 +963,7 @@ void Control::startSequenceActorIntern(uint32 sequenceId, int value, byte *entry
Sequence *sequence = _vm->_dict->findSequence(sequenceId);
if (!sequence && _vm->getGameId() == kGameIdDuckman) {
- debug(1, "Load external sequence...");
+ //debug(1, "Load external sequence...");
_vm->_resSys->loadResource(0x00060000 | (sequenceId & 0xFFFF), _vm->getCurrentScene(), 0);
sequence = _vm->_dict->findSequence(sequenceId);
_actor->_flags |= 0x800;
@@ -1394,7 +1394,7 @@ void Controls::actorControlRoutine(Control *control, uint32 deltaTime) {
int savedSeqCodeValue1 = actor->_seqCodeValue1;
int savedSeqCodeValue3 = actor->_seqCodeValue3;
uint32 regionSequenceId = actor->_regionLayer->getRegionSequenceId(regionIndex);
- debug(1, "Running transition sequence %08X", regionSequenceId);
+ //debug(1, "Running transition sequence %08X", regionSequenceId);
Sequence *sequence = _vm->_dict->findSequence(regionSequenceId);
actor->_sequenceId = regionSequenceId;
actor->_seqCodeIp = sequence->_sequenceCode;
diff --git a/engines/illusions/duckman/illusions_duckman.cpp b/engines/illusions/duckman/illusions_duckman.cpp
index 289a3d80b4..8f28a99c56 100644
--- a/engines/illusions/duckman/illusions_duckman.cpp
+++ b/engines/illusions/duckman/illusions_duckman.cpp
@@ -1080,7 +1080,6 @@ bool IllusionsEngine_Duckman::getTriggerCause(uint32 verbId, uint32 objectId2, u
}
uint32 IllusionsEngine_Duckman::runTriggerCause(uint32 verbId, uint32 objectId2, uint32 objectId) {
- // TODO
debug(1, "runTriggerCause(%08X, %08X, %08X)", verbId, objectId2, objectId);
uint32 triggerThreadId;
@@ -1136,7 +1135,7 @@ void IllusionsEngine_Duckman::playTriggerCauseSound(uint32 verbId, uint32 object
}
bool IllusionsEngine_Duckman::loadSavegameFromScript(int16 slotNum, uint32 callingThreadId) {
- const char *fileName = getSavegameFilename(slotNum);
+ const char *fileName = getSavegameFilename(_savegameSlotNum);
bool success = loadgame(fileName);
if (success)
activateSavegame(callingThreadId);
diff --git a/engines/illusions/duckman/menusystem_duckman.cpp b/engines/illusions/duckman/menusystem_duckman.cpp
index 666005d952..7b1191612f 100644
--- a/engines/illusions/duckman/menusystem_duckman.cpp
+++ b/engines/illusions/duckman/menusystem_duckman.cpp
@@ -41,7 +41,7 @@ DuckmanMenuSystem::~DuckmanMenuSystem() {
void DuckmanMenuSystem::runMenu(MenuChoiceOffsets menuChoiceOffsets, int16 *menuChoiceOffset,
uint32 menuId, uint32 duration, uint timeOutMenuChoiceIndex, uint32 menuCallerThreadId) {
- debug("DuckmanMenuSystem::runMenu(%08X)", menuId);
+ debug(0, "DuckmanMenuSystem::runMenu(%08X)", menuId);
setTimeOutDuration(duration, timeOutMenuChoiceIndex);
setMenuCallerThreadId(menuCallerThreadId);
@@ -87,11 +87,7 @@ BaseMenu *DuckmanMenuSystem::createMenuById(int menuId) {
BaseMenu *DuckmanMenuSystem::createMainMenu() {
BaseMenu *menu = new BaseMenu(this, 0x00120003, 12, 17, 11, 27, 0);
menu->addMenuItem(new MenuItem("Start New Game", new MenuActionReturnChoice(this, 11)));
-
- menu->addMenuItem(new MenuItem("Load Saved Game", new MenuActionReturnChoice(this, 0)));
- menu->addMenuItem(new MenuItem("Options", new MenuActionReturnChoice(this, 0)));
-
- // TODO menu->addMenuItem(new MenuItem("Load Saved Game", new MenuActionEnterMenu(this, kDuckmanLoadGameMenu)));
+ menu->addMenuItem(new MenuItem("Load Saved Game", new MenuActionLoadGame(this, 1)));
// TODO menu->addMenuItem(new MenuItem("Options", new MenuActionEnterMenu(this, kDuckmanOptionsMenu)));
menu->addMenuItem(new MenuItem("Quit Game", new MenuActionEnterQueryMenu(this, kDuckmanQueryQuitMenu, 12)));
return menu;
@@ -109,10 +105,12 @@ BaseMenu *DuckmanMenuSystem::createPauseMenu() {
BaseMenu *menu = new BaseMenu(this, 0x00120003, 12, 17, 11, 27, 1);
menu->addText(" Game Paused");
menu->addText("-------------------");
- menu->addMenuItem(new MenuItem("Resume", new MenuActionReturnChoice(this, 1)));
- //menu->addMenuItem(new MenuItem("Restart Game", new MenuActionEnterQueryMenu(this, kDuckmanQueryRestartMenu, 2)));
+ menu->addMenuItem(new MenuItem("Resume", new MenuActionReturnChoice(this, 21)));
+ menu->addMenuItem(new MenuItem("Load Game", new MenuActionLoadGame(this, 1)));
+ // TODO menu->addMenuItem(new MenuItem("Save Game", new MenuActionSaveGame(this, 11)));
+ // TODO menu->addMenuItem(new MenuItem("Restart Game", new MenuActionEnterQueryMenu(this, kDuckmanQueryRestartMenu, 2)));
// TODO menu->addMenuItem(new MenuItem("Options", new MenuActionEnterMenu(this, kDuckmanOptionsMenu)));
- menu->addMenuItem(new MenuItem("Quit Game", new MenuActionEnterQueryMenu(this, kDuckmanQueryQuitMenu, 3)));
+ menu->addMenuItem(new MenuItem("Quit Game", new MenuActionEnterQueryMenu(this, kDuckmanQueryQuitMenu, 23)));
return menu;
}
diff --git a/engines/illusions/duckman/scriptopcodes_duckman.cpp b/engines/illusions/duckman/scriptopcodes_duckman.cpp
index 1456cfc0ee..759b4bc606 100644
--- a/engines/illusions/duckman/scriptopcodes_duckman.cpp
+++ b/engines/illusions/duckman/scriptopcodes_duckman.cpp
@@ -203,14 +203,14 @@ void ScriptOpcodes_Duckman::opStartTimerThread(ScriptThread *scriptThread, OpCal
if (maxDuration)
duration += _vm->getRandom(maxDuration);
-//duration = 1;//DEBUG Speeds up things
-//duration = 5;
-//debug("duration: %d", duration);
+ //duration = 1;//DEBUG Speeds up things
+ //duration = 5;
+ //debug("duration: %d", duration);
if (isAbortable)
- _vm->startAbortableTimerThread(duration, opCall._threadId);
+ _vm->startAbortableTimerThread(duration, opCall._callerThreadId);
else
- _vm->startTimerThread(duration, opCall._threadId);
+ _vm->startTimerThread(duration, opCall._callerThreadId);
}
void ScriptOpcodes_Duckman::opRerunThreads(ScriptThread *scriptThread, OpCall &opCall) {
@@ -592,11 +592,11 @@ void ScriptOpcodes_Duckman::opRunSpecialCode(ScriptThread *scriptThread, OpCall
}
void ScriptOpcodes_Duckman::opPause(ScriptThread *scriptThread, OpCall &opCall) {
- _vm->pause(opCall._threadId);
+ _vm->pause(opCall._callerThreadId);
}
void ScriptOpcodes_Duckman::opUnpause(ScriptThread *scriptThread, OpCall &opCall) {
- _vm->unpause(opCall._threadId);
+ _vm->unpause(opCall._callerThreadId);
}
void ScriptOpcodes_Duckman::opStartSound(ScriptThread *scriptThread, OpCall &opCall) {
@@ -649,21 +649,17 @@ void ScriptOpcodes_Duckman::opDisplayMenu(ScriptThread *scriptThread, OpCall &op
ARG_UINT32(menuId);
ARG_UINT32(timeOutMenuChoiceIndex);
- debug("menuId: %08X", menuId);
- debug("timeOutMenuChoiceIndex: %d", timeOutMenuChoiceIndex);
-
MenuChoiceOffsets menuChoiceOffsets;
// Load menu choices from the stack
do {
int16 choiceOffs = _vm->_stack->pop();
- debug("choiceOffs: %04X", choiceOffs);
menuChoiceOffsets.push_back(choiceOffs);
} while (_vm->_stack->pop() == 0);
_vm->_menuSystem->runMenu(menuChoiceOffsets, &_vm->_menuChoiceOfs,
menuId, timeOutDuration, timeOutMenuChoiceIndex,
- opCall._threadId);
+ opCall._callerThreadId);
//DEBUG Resume calling thread, later done by the video player
//_vm->notifyThreadId(opCall._callerThreadId);
diff --git a/engines/illusions/illusions.h b/engines/illusions/illusions.h
index 784277f872..836282d8e3 100644
--- a/engines/illusions/illusions.h
+++ b/engines/illusions/illusions.h
@@ -136,6 +136,7 @@ public:
uint32 _lastUpdateTime;
int _resumeFromSavegameRequested;
+ int _savegameSlotNum;
uint32 _savegameSceneId;
uint32 _savegameThreadId;
diff --git a/engines/illusions/menusystem.cpp b/engines/illusions/menusystem.cpp
index 01b92208d8..cb82e3343d 100644
--- a/engines/illusions/menusystem.cpp
+++ b/engines/illusions/menusystem.cpp
@@ -28,6 +28,9 @@
#include "illusions/screentext.h"
#include "illusions/thread.h"
#include "illusions/time.h"
+#include "common/config-manager.h"
+#include "common/translation.h"
+#include "gui/saveload.h"
namespace Illusions {
@@ -105,11 +108,11 @@ void BaseMenuSystem::playSoundEffect14() {
}
void BaseMenuSystem::selectMenuChoiceIndex(uint choiceIndex) {
- debug("choiceIndex: %d", choiceIndex);
- debug("_menuChoiceOffset: %p", (void*)_menuChoiceOffset);
+ debug(0, "choiceIndex: %d", choiceIndex);
+ debug(0, "_menuChoiceOffset: %p", (void*)_menuChoiceOffset);
if (choiceIndex > 0 && _menuChoiceOffset) {
*_menuChoiceOffset = _menuChoiceOffsets[choiceIndex - 1];
- debug(0, "*_menuChoiceOffset: %04X", *_menuChoiceOffset);
+ debug(0, "*_menuChoiceOffset: %04X", *_menuChoiceOffset);
}
_vm->_threads->notifyId(_menuCallerThreadId);
_menuCallerThreadId = 0;
@@ -374,7 +377,7 @@ void BaseMenuSystem::closeMenu() {
}
void BaseMenuSystem::handleClick(uint menuItemIndex, const Common::Point &mousePos) {
- debug("BaseMenuSystem::handleClick() menuItemIndex: %d", menuItemIndex);
+ debug(0, "BaseMenuSystem::handleClick() menuItemIndex: %d", menuItemIndex);
if (menuItemIndex == 0) {
playSoundEffect14();
@@ -497,6 +500,10 @@ void BaseMenuSystem::setMenuChoiceOffsets(MenuChoiceOffsets menuChoiceOffsets, i
_menuChoiceOffset = menuChoiceOffset;
}
+void BaseMenuSystem::setSavegameSlotNum(int slotNum) {
+ _vm->_savegameSlotNum = slotNum;
+}
+
void BaseMenuSystem::updateTimeOut(bool resetTimeOut) {
if (!_isTimeOutEnabled)
@@ -516,7 +523,6 @@ void BaseMenuSystem::updateTimeOut(bool resetTimeOut) {
_timeOutStartTime = getCurrentTime();
_timeOutEndTime = _timeOutDuration + _timeOutStartTime;
} else if (isTimerExpired(_timeOutStartTime, _timeOutEndTime)) {
- debug("timeout reached");
_isTimeOutEnabled = false;
selectMenuChoiceIndex(_timeOutMenuChoiceIndex);
}
@@ -590,4 +596,29 @@ void MenuActionEnterQueryMenu::execute() {
_menuSystem->enterSubMenuById(_menuId);
}
+// MenuActionLoadGame
+
+MenuActionLoadGame::MenuActionLoadGame(BaseMenuSystem *menuSystem, uint choiceIndex)
+ : BaseMenuAction(menuSystem), _choiceIndex(choiceIndex) {
+}
+
+void MenuActionLoadGame::execute() {
+ const EnginePlugin *plugin = NULL;
+ EngineMan.findGame(ConfMan.get("gameid"), &plugin);
+ GUI::SaveLoadChooser *dialog;
+ Common::String desc;
+ int slot;
+
+ dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
+ slot = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
+
+ delete dialog;
+
+ if (slot >= 0) {
+ _menuSystem->setSavegameSlotNum(slot);
+ _menuSystem->selectMenuChoiceIndex(_choiceIndex);
+ }
+
+}
+
} // End of namespace Illusions
diff --git a/engines/illusions/menusystem.h b/engines/illusions/menusystem.h
index 98ef924300..26a5931d18 100644
--- a/engines/illusions/menusystem.h
+++ b/engines/illusions/menusystem.h
@@ -102,6 +102,7 @@ public:
void setTimeOutDuration(uint32 duration, uint timeOutMenuChoiceIndex);
void setMenuCallerThreadId(uint32 menuCallerThreadId);
void setMenuChoiceOffsets(MenuChoiceOffsets menuChoiceOffsets, int16 *menuChoiceOffset);
+ void setSavegameSlotNum(int slotNum);
virtual bool initMenuCursor() = 0;
virtual int getGameState() = 0;
virtual void setGameState(int gameState) = 0;
@@ -230,6 +231,14 @@ protected:
uint _confirmationChoiceIndex;
};
+class MenuActionLoadGame : public BaseMenuAction {
+public:
+ MenuActionLoadGame(BaseMenuSystem *menuSystem, uint choiceIndex);
+ virtual void execute();
+protected:
+ uint _choiceIndex;
+};
+
} // End of namespace Illusions
#endif // ILLUSIONS_MENUSYSTEM_H
diff --git a/engines/illusions/scriptopcodes.cpp b/engines/illusions/scriptopcodes.cpp
index 7d515a8109..38fdbec3ce 100644
--- a/engines/illusions/scriptopcodes.cpp
+++ b/engines/illusions/scriptopcodes.cpp
@@ -62,7 +62,7 @@ ScriptOpcodes::~ScriptOpcodes() {
void ScriptOpcodes::execOpcode(ScriptThread *scriptThread, OpCall &opCall) {
if (!_opcodes[opCall._op])
error("ScriptOpcodes::execOpcode() Unimplemented opcode %d", opCall._op);
- debug(0, "\nexecOpcode([%08X] %d) %s", opCall._callerThreadId, opCall._op, _opcodeNames[opCall._op].c_str());
+ debug("\nexecOpcode([%08X] %d) %s", opCall._callerThreadId, opCall._op, _opcodeNames[opCall._op].c_str());
(*_opcodes[opCall._op])(scriptThread, opCall);
}
diff --git a/engines/illusions/scriptopcodes.h b/engines/illusions/scriptopcodes.h
index cf20380008..8ba2586946 100644
--- a/engines/illusions/scriptopcodes.h
+++ b/engines/illusions/scriptopcodes.h
@@ -61,9 +61,9 @@ protected:
// Convenience macros
#define ARG_SKIP(x) opCall.skip(x);
-#define ARG_BYTE(name) byte name = opCall.readByte(); debug(0, "ARG_BYTE(" #name " = %d)", name);
-#define ARG_INT16(name) int16 name = opCall.readSint16(); debug(0, "ARG_INT16(" #name " = %d)", name);
-#define ARG_UINT32(name) uint32 name = opCall.readUint32(); debug(0, "ARG_UINT32(" #name " = %08X)", name);
+#define ARG_BYTE(name) byte name = opCall.readByte(); debug(5, "ARG_BYTE(" #name " = %d)", name);
+#define ARG_INT16(name) int16 name = opCall.readSint16(); debug(5, "ARG_INT16(" #name " = %d)", name);
+#define ARG_UINT32(name) uint32 name = opCall.readUint32(); debug(5, "ARG_UINT32(" #name " = %08X)", name);
} // End of namespace Illusions
diff --git a/engines/illusions/sequenceopcodes.cpp b/engines/illusions/sequenceopcodes.cpp
index 8d678ebc52..5ce25ca1fb 100644
--- a/engines/illusions/sequenceopcodes.cpp
+++ b/engines/illusions/sequenceopcodes.cpp
@@ -45,7 +45,7 @@ SequenceOpcodes::~SequenceOpcodes() {
void SequenceOpcodes::execOpcode(Control *control, OpCall &opCall) {
if (!_opcodes[opCall._op])
error("SequenceOpcodes::execOpcode() Unimplemented opcode %d", opCall._op);
- debug(1, "execOpcode(%d)", opCall._op);
+ debug(3, "execOpcode(%d)", opCall._op);
(*_opcodes[opCall._op])(control, opCall);
}