diff options
author | Nicola Mettifogo | 2007-05-06 08:52:27 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-05-06 08:52:27 +0000 |
commit | a4cc51b8c572895e794cf03b056689d5a5f63d1d (patch) | |
tree | 5f33817f51bfa0e4dcbc69a331109aec84e64111 /engines/parallaction | |
parent | 0ab860d60dbbc4658e2030f9a3642d4b915046b6 (diff) | |
download | scummvm-rg350-a4cc51b8c572895e794cf03b056689d5a5f63d1d.tar.gz scummvm-rg350-a4cc51b8c572895e794cf03b056689d5a5f63d1d.tar.bz2 scummvm-rg350-a4cc51b8c572895e794cf03b056689d5a5f63d1d.zip |
Added embryonic debugger, and some adjustments to make basic commands work.
svn-id: r26755
Diffstat (limited to 'engines/parallaction')
-rw-r--r-- | engines/parallaction/debug.cpp | 60 | ||||
-rw-r--r-- | engines/parallaction/debug.h | 29 | ||||
-rw-r--r-- | engines/parallaction/inventory.cpp | 26 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 10 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 5 | ||||
-rw-r--r-- | engines/parallaction/zone.cpp | 11 |
6 files changed, 110 insertions, 31 deletions
diff --git a/engines/parallaction/debug.cpp b/engines/parallaction/debug.cpp index 9b4b0e8932..61ab924c15 100644 --- a/engines/parallaction/debug.cpp +++ b/engines/parallaction/debug.cpp @@ -26,6 +26,8 @@ #include "parallaction/parallaction.h" #include "parallaction/graphics.h" +#include "parallaction/debug.h" + namespace Parallaction { @@ -54,14 +56,62 @@ const char *_jobDescriptions[] = { "21 - erase mouse" }; -void beep() { -// sound(1500); -// delay(100); -// nosound(); - return; +Debugger::Debugger(Parallaction *vm) + : GUI::Debugger() { + _vm = vm; + + DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); + DCmd_Register("location", WRAP_METHOD(Debugger, Cmd_Location)); + DCmd_Register("give", WRAP_METHOD(Debugger, Cmd_Give)); +} + + +void Debugger::preEnter() { +} + + +void Debugger::postEnter() { +} + +bool Debugger::Cmd_Location(int argc, const char **argv) { + + char *character = _vm->_characterName; + char *location = _vm->_location._name; + + switch (argc) { + case 3: + character = const_cast<char*>(argv[2]); + // fallthru is intentional here + + case 2: + location = const_cast<char*>(argv[1]); + sprintf(_vm->_location._name, "%s.%s", location, character); + // TODO: check if location exists + _engineFlags |= kEngineChangeLocation; + break; + + case 1: + DebugPrintf("location <location name> [character name]\n"); + + } + + return true; } +bool Debugger::Cmd_Give(int argc, const char **argv) { + if (argc == 1) { + DebugPrintf("give <item name>\n"); + } else { + int index = _vm->_objectsNames->lookup(argv[1]); + if (index != -1) + _vm->addInventoryItem(index + 4); + else + DebugPrintf("invalid item name '%s'\n", argv[1]); + } + + return true; +} } // namespace Parallaction diff --git a/engines/parallaction/debug.h b/engines/parallaction/debug.h new file mode 100644 index 0000000000..371ed70b1e --- /dev/null +++ b/engines/parallaction/debug.h @@ -0,0 +1,29 @@ + +#ifndef PARALLACTION_DEBUGGER_H +#define PARALLACTION_DEBUGGER_H + +#include "gui/debugger.h" + +namespace Parallaction { + +class Parallaction; + +class Debugger : public GUI::Debugger { +public: + Debugger(Parallaction *vm); + virtual ~Debugger() {} // we need this for __SYMBIAN32__ archaic gcc/UIQ + +protected: + Parallaction *_vm; + + virtual void preEnter(); + virtual void postEnter(); + + bool Cmd_DebugLevel(int argc, const char **argv); + bool Cmd_Location(int argc, const char **argv); + bool Cmd_Give(int argc, const char **argv); +}; + +} // End of namespace Parallaction + +#endif diff --git a/engines/parallaction/inventory.cpp b/engines/parallaction/inventory.cpp index 0e6a003b23..48d2ebdfcd 100644 --- a/engines/parallaction/inventory.cpp +++ b/engines/parallaction/inventory.cpp @@ -116,37 +116,19 @@ int16 Parallaction::getHoverInventoryItem(int16 x, int16 y) { } -int16 Parallaction::pickupItem(Zone *z) { - - uint16 _si; - for (_si = 0; _inventory[_si]._id != 0; _si++) ; - if (_si == INVENTORY_MAX_ITEMS) - return -1; - - _inventory[_si]._id = MAKE_INVENTORY_ID(z->u.get->_icon); - _inventory[_si]._index = z->u.get->_icon; - - addJob(&jobRemovePickedItem, z, kPriority17 ); - - if (_inventory[_si]._id == 0) return 0; - - refreshInventoryItem(_characterName, _si); - - return 0; -} - - -void Parallaction::addInventoryItem(uint16 item) { +int Parallaction::addInventoryItem(uint16 item) { uint16 _si = 0; while (_inventory[_si]._id != 0) _si++; + if (_si == INVENTORY_MAX_ITEMS) + return -1; _inventory[_si]._id = MAKE_INVENTORY_ID(item); _inventory[_si]._index = item; refreshInventoryItem(_characterName, _si); - return; + return 0; } diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 3dfabd0c35..ac76ca49ca 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -31,6 +31,7 @@ #include "sound/mixer.h" #include "parallaction/parallaction.h" +#include "parallaction/debug.h" #include "parallaction/menu.h" #include "parallaction/parser.h" #include "parallaction/disk.h" @@ -124,6 +125,8 @@ Parallaction::Parallaction(OSystem *syst) : Parallaction::~Parallaction() { + delete _debugger; + delete _soundMan; delete _disk; delete _globalTable; @@ -214,6 +217,8 @@ int Parallaction::init() { _soundMan = new AmigaSoundMan(this); } + _debugger = new Debugger(this); + return 0; } @@ -283,6 +288,8 @@ uint16 Parallaction::updateInput() { case Common::EVENT_KEYDOWN: if (e.kbd.ascii == 'l') KeyDown = kEvLoadGame; if (e.kbd.ascii == 's') KeyDown = kEvSaveGame; + if (e.kbd.flags == Common::KBD_CTRL && e.kbd.keycode == 'd') + _debugger->attach(); break; case Common::EVENT_LBUTTONDOWN: @@ -316,6 +323,9 @@ uint16 Parallaction::updateInput() { } + if (_debugger->isAttached()) + _debugger->onFrame(); + return KeyDown; } diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index e317226e63..8b69b68e9b 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -281,6 +281,7 @@ public: class Parallaction : public Engine { + friend class Debugger; public: @@ -368,6 +369,8 @@ public: protected: // data + Debugger *_debugger; + struct InputData { uint16 _event; Common::Point _mousePos; @@ -449,7 +452,7 @@ protected: // members void enterDialogue(); void exitDialogue(); - void addInventoryItem(uint16 item); + int addInventoryItem(uint16 item); void dropItem(uint16 item); int16 pickupItem(Zone *z); int16 isItemInInventory(int32 v); diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp index 11efa8f6ca..e4215eae02 100644 --- a/engines/parallaction/zone.cpp +++ b/engines/parallaction/zone.cpp @@ -457,13 +457,18 @@ void jobToggleDoor(void *parm, Job *j) { - - - // // ZONE TYPE: GET // +int16 Parallaction::pickupItem(Zone *z) { + int r = addInventoryItem(z->u.get->_icon); + if (r == 0) + addJob(&jobRemovePickedItem, z, kPriority17 ); + + return r; +} + void jobRemovePickedItem(void *parm, Job *j) { Zone *z = (Zone*)parm; |