Added embryonic debugger, and some adjustments to make basic commands work.

svn-id: r26755
This commit is contained in:
Nicola Mettifogo 2007-05-06 08:52:27 +00:00
parent 0ab860d60d
commit a4cc51b8c5
6 changed files with 110 additions and 31 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;