aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Fry2018-06-07 22:03:43 +1000
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit83994972de35193e10ad01acac3369f1b00c992b (patch)
treed16624bed76b6d3c312bd23dcdb922a72f26e6fd
parent88ef19056915b30d5e4b5d5e0e59ec6c17053d59 (diff)
downloadscummvm-rg350-83994972de35193e10ad01acac3369f1b00c992b.tar.gz
scummvm-rg350-83994972de35193e10ad01acac3369f1b00c992b.tar.bz2
scummvm-rg350-83994972de35193e10ad01acac3369f1b00c992b.zip
ILLUSIONS: Add debug cheat code support
Work on inventory add/remove debug menu.
-rw-r--r--engines/illusions/duckman/illusions_duckman.cpp4
-rw-r--r--engines/illusions/duckman/menusystem_duckman.cpp73
-rw-r--r--engines/illusions/duckman/menusystem_duckman.h13
-rw-r--r--engines/illusions/input.cpp14
-rw-r--r--engines/illusions/input.h2
-rw-r--r--engines/illusions/resources/actorresource.cpp7
-rw-r--r--engines/illusions/resources/actorresource.h4
7 files changed, 109 insertions, 8 deletions
diff --git a/engines/illusions/duckman/illusions_duckman.cpp b/engines/illusions/duckman/illusions_duckman.cpp
index 0b2bcca52f..c427293b59 100644
--- a/engines/illusions/duckman/illusions_duckman.cpp
+++ b/engines/illusions/duckman/illusions_duckman.cpp
@@ -261,10 +261,8 @@ void IllusionsEngine_Duckman::initInput() {
_input->setInputEvent(kEventDown, 0x80)
.addMouseButton(MOUSE_RIGHT_BUTTON)
.addKey(Common::KEYCODE_DOWN);
-#if 1 //TODO hide behind "gosanta" code
_input->setInputEvent(kEventF1, 0x100)
.addKey(Common::KEYCODE_F1);
-#endif
}
#define UPDATEFUNCTION(priority, sceneId, callback) \
@@ -288,7 +286,7 @@ int IllusionsEngine_Duckman::updateScript(uint flags) {
if (_screen->isDisplayOn() && !_screenPalette->isFaderActive() && _pauseCtr == 0) {
if (_input->pollEvent(kEventAbort)) {
startScriptThread(0x00020342, 0);
- } else if (_input->pollEvent(kEventF1)) {
+ } else if (_input->isCheatModeActive() && _input->pollEvent(kEventF1)) {
startScriptThread(0x0002033F, 0);
}
}
diff --git a/engines/illusions/duckman/menusystem_duckman.cpp b/engines/illusions/duckman/menusystem_duckman.cpp
index 263cda83ce..79734f1c53 100644
--- a/engines/illusions/duckman/menusystem_duckman.cpp
+++ b/engines/illusions/duckman/menusystem_duckman.cpp
@@ -24,6 +24,7 @@
#include "illusions/actor.h"
#include "illusions/duckman/illusions_duckman.h"
#include "illusions/duckman/menusystem_duckman.h"
+#include "illusions/resources/scriptresource.h"
namespace Illusions {
@@ -83,6 +84,10 @@ BaseMenu *DuckmanMenuSystem::createMenuById(int menuId) {
return createSaveCompleteMenu();
case kDuckmanOptionsMenu:
return createOptionsMenu();
+ case kDuckmanDebugMenu:
+ return createDebugMenu();
+ case kDuckmanAddRemoveInventoryMenu:
+ return createAddRemoveInventoryMenu();
default:
error("DuckmanMenuSystem::createMenuById() Invalid menu id %d", menuId);
}
@@ -148,12 +153,64 @@ BaseMenu *DuckmanMenuSystem::createSaveCompleteMenu() {
return menu;
}
+BaseMenu *DuckmanMenuSystem::createDebugMenu() {
+ BaseMenu *menu = new BaseMenu(this, 0x00120002, 0, 0, 0, 17, 1);
+ menu->addText("Debug Pause Menu");
+ menu->addText("-----------------");
+ menu->addMenuItem(new MenuItem("Return to Game", new MenuActionReturnChoice(this, 1)));
+ menu->addMenuItem(new MenuItem("Add/Remove Inventory", new MenuActionEnterMenu(this, kDuckmanAddRemoveInventoryMenu)));
+ return menu;
+}
+typedef struct InventoryMenuItem {
+ const char *name;
+ uint32 objectId;
+ uint32 sequenceId;
+ uint32 propertyId;
+} InventoryMenuItem;
+
+static const InventoryMenuItem kDebugInventoryItems[21] =
+{
+ { "Pick-up Book", 262212, 393231, 917519 },
+ { "Bucket and Squeegee", 262314, 393233, 917599 },
+ { "Cardboard Cut Out", 262219, 393264, 917573 },
+ { "Talking Doll", 262209, 393943, 917587 },
+ { "Cookie Fortunes", 262263, 393266, 917520 },
+ { "Garbage Can Lid", 262311, 393259, 917597 },
+ { "Chewing Gum", 262210, 393267, 917522 },
+ { "Ladder", 262155, 393258, 917598 },
+ { "Disco Light", 262342, 393260, 917594 },
+ { "Magazine Cover", 262185, 393261, 917517 },
+ { "Matches", 262159, 393232, 917516 },
+ { "Opera Lessons", 262293, 393731, 917600 },
+ { "Pizza Card", 262239, 393262, 917526 },
+ { "Toilet Plunger", 262282, 393257, 917555 },
+ { "Black Velvet Poster", 262258, 393269, 917527 },
+ { "Red Spray Paint", 262297, 393254, 917531 },
+ { "Remote Control", 262161, 393255, 917595 },
+ { "Sparkplug", 262294, 393256, 917532 },
+ { "Tape Recorder", 262328, 393827, 917584 },
+ { "Wacky Putty", 262228, 393559, 917537 },
+ { "Wrench", 262175, 393422, 917530 }
+};
+
+BaseMenu *DuckmanMenuSystem::createAddRemoveInventoryMenu() {
+ BaseMenu *menu = new BaseMenu(this, 0x00120002, 0, 0, 0, 17, 1);
+ menu->addText("Add/Remove Inventory");
+ menu->addText("-----------------");
+ for(int i=0;i < 21;i++) {
+ menu->addMenuItem(new MenuItem(kDebugInventoryItems[i].name, new MenuActionInventoryAddRemove(this, _vm, i)));
+ }
+ return menu;
+}
+
int DuckmanMenuSystem::convertRootMenuId(uint32 menuId) {
switch (menuId) {
case 0x180001:
return kDuckmanMainMenu;
case 0x180002:
return kDuckmanPauseMenu;
+ case 0x180004:
+ return kDuckmanDebugMenu;
case 0x180005:
return kDuckmanSaveCompleteMenu;
/*
@@ -198,4 +255,20 @@ void DuckmanMenuSystem::setGameState(int gameState) {
_vm->_cursor._gameState = gameState;
}
+MenuActionInventoryAddRemove::MenuActionInventoryAddRemove(BaseMenuSystem *menuSystem, IllusionsEngine_Duckman *vm, uint choiceIndex)
+ : BaseMenuAction(menuSystem), _choiceIndex(choiceIndex), _vm(vm) {
+}
+
+void MenuActionInventoryAddRemove::execute() {
+ if (_vm->_scriptResource->_properties.get(kDebugInventoryItems[_choiceIndex].propertyId)) {
+ //TODO stop holding object in cursor.
+ _vm->_scriptResource->_properties.set(kDebugInventoryItems[_choiceIndex].propertyId, false);
+ } else {
+ _vm->startCursorHoldingObject(kDebugInventoryItems[_choiceIndex].objectId,
+ kDebugInventoryItems[_choiceIndex].sequenceId);
+ _vm->_scriptResource->_properties.set(kDebugInventoryItems[_choiceIndex].propertyId, true);
+ }
+ _menuSystem->leaveMenu();
+}
+
} // End of namespace Illusions
diff --git a/engines/illusions/duckman/menusystem_duckman.h b/engines/illusions/duckman/menusystem_duckman.h
index 10a8a6eb0b..7bcf780c26 100644
--- a/engines/illusions/duckman/menusystem_duckman.h
+++ b/engines/illusions/duckman/menusystem_duckman.h
@@ -32,6 +32,8 @@ enum {
kDuckmanLoadGameMenu,
kDuckmanOptionsMenu,
kDuckmanPauseMenu,
+ kDuckmanDebugMenu,
+ kDuckmanAddRemoveInventoryMenu,
kDuckmanQueryQuitMenu,
kDuckmanQueryRestartMenu,
kDuckmanSaveCompleteMenu,
@@ -60,6 +62,8 @@ public://protected:
BaseMenu *createQueryRestartMenu();
BaseMenu *createQueryQuitMenu();
BaseMenu *createSaveCompleteMenu();
+ BaseMenu *createDebugMenu();
+ BaseMenu *createAddRemoveInventoryMenu();
int convertRootMenuId(uint32 menuId);
virtual bool initMenuCursor();
virtual int getGameState();
@@ -67,6 +71,15 @@ public://protected:
virtual void setMenuCursorNum(int cursorNum);
};
+class MenuActionInventoryAddRemove : public BaseMenuAction {
+public:
+ MenuActionInventoryAddRemove(BaseMenuSystem *menuSystem, IllusionsEngine_Duckman *vm, uint choiceIndex);
+ virtual void execute();
+protected:
+ IllusionsEngine_Duckman *_vm;
+ int _choiceIndex;
+};
+
} // End of namespace Illusions
#endif // ILLUSIONS_DUCKMAN_MENUSYSTEM_DUCKMAN_H
diff --git a/engines/illusions/input.cpp b/engines/illusions/input.cpp
index 56ce27a353..21042dcc1c 100644
--- a/engines/illusions/input.cpp
+++ b/engines/illusions/input.cpp
@@ -81,6 +81,7 @@ uint InputEvent::handle(Common::KeyCode key, int mouseButton, bool down) {
// Input
const uint kAllButtons = 0xFFFF;
+static const char kCheatCode[] = "gosanta";
Input::Input() {
_buttonStates = 0;
@@ -92,6 +93,7 @@ Input::Input() {
_cursorPos.y = 0;
_prevCursorPos.x = 0;
_prevCursorPos.y = 0;
+ _cheatCodeIndex = 0;
}
void Input::processEvent(Common::Event event) {
@@ -177,6 +179,14 @@ void Input::handleKey(Common::KeyCode key, int mouseButton, bool down) {
_buttonStates |= _newKeys;
_newKeys = 0;
_newButtons = ~prevButtonStates & _buttonStates;
+
+ if ( !down && !isCheatModeActive() ) {
+ if( _cheatCodeIndex < 7 && key == kCheatCode[_cheatCodeIndex] ) {
+ _cheatCodeIndex++;
+ } else {
+ _cheatCodeIndex = 0;
+ }
+ }
}
void Input::handleMouseButton(int mouseButton, bool down) {
@@ -211,4 +221,8 @@ void Input::discardButtons(uint bitMask) {
_buttonStates &= ~bitMask;
}
+bool Input::isCheatModeActive() {
+ return _cheatCodeIndex == 7;
+}
+
} // End of namespace Illusions
diff --git a/engines/illusions/input.h b/engines/illusions/input.h
index 99560399c3..77a1bda2fd 100644
--- a/engines/illusions/input.h
+++ b/engines/illusions/input.h
@@ -89,7 +89,9 @@ public:
void setCursorPosition(Common::Point mousePos);
Common::Point getCursorDelta();
InputEvent& setInputEvent(uint evt, uint bitMask);
+ bool isCheatModeActive();
protected:
+ uint _cheatCodeIndex;
uint _buttonStates, _newButtons, _buttonsDown;
uint _enabledButtons;
uint _newKeys;
diff --git a/engines/illusions/resources/actorresource.cpp b/engines/illusions/resources/actorresource.cpp
index c38a467ed9..42124573b8 100644
--- a/engines/illusions/resources/actorresource.cpp
+++ b/engines/illusions/resources/actorresource.cpp
@@ -183,7 +183,7 @@ void ActorInstance::load(Resource *resource) {
_actorResource->load(resource);
_sceneId = resource->_sceneId;
_pauseCtr = 0;
- initActorTypes();
+ initActorTypes(resource->_gameId);
}
void ActorInstance::unload() {
@@ -205,7 +205,7 @@ void ActorInstance::unpause() {
registerResources();
}
-void ActorInstance::initActorTypes() {
+void ActorInstance::initActorTypes(int gameId) {
for (uint i = 0; i < _actorResource->_actorTypes.size(); ++i) {
ActorType *actorType = &_actorResource->_actorTypes[i];
ActorType *actorType2 = _vm->_dict->findActorType(actorType->_actorTypeId);
@@ -224,7 +224,8 @@ void ActorInstance::initActorTypes() {
for (uint i = 0; i < _actorResource->_sequences.size(); ++i) {
Sequence *sequence = &_actorResource->_sequences[i];
_vm->_dict->addSequence(sequence->_sequenceId, sequence);
- if (sequence->_sequenceId == 0x60101) {
+ if (gameId == kGameIdDuckman && sequence->_sequenceId == 0x60101) {
+ // TODO check that this is the correct location for this logic.
_vm->_controls->placeActor(0x50023, Common::Point(0,0), sequence->_sequenceId, 0x400d7, 0);
}
}
diff --git a/engines/illusions/resources/actorresource.h b/engines/illusions/resources/actorresource.h
index c24213dba9..ea356a9504 100644
--- a/engines/illusions/resources/actorresource.h
+++ b/engines/illusions/resources/actorresource.h
@@ -105,8 +105,8 @@ public:
int _pauseCtr;
ActorResource *_actorResource;
protected:
- void initActorTypes();
- void registerResources();
+ void initActorTypes(int gameId);
+ void registerResources();
void unregisterResources();
};