mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 21:59:17 +00:00
- Committed slightly modified patch #1951735 "kyra3: debugger and "give" command"
- Added some more commands to new kyra3 debugger - Cleaned up some debugger code svn-id: r31723
This commit is contained in:
parent
671e475567
commit
3150313377
@ -29,6 +29,7 @@
|
||||
#include "kyra/debugger.h"
|
||||
#include "kyra/kyra_v1.h"
|
||||
#include "kyra/kyra_v2.h"
|
||||
#include "kyra/kyra_v3.h"
|
||||
#include "kyra/screen.h"
|
||||
#include "kyra/timer.h"
|
||||
#include "kyra/resource.h"
|
||||
@ -39,6 +40,7 @@ Debugger::Debugger(KyraEngine *vm)
|
||||
: ::GUI::Debugger() {
|
||||
_vm = vm;
|
||||
|
||||
DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit));
|
||||
DCmd_Register("screen_debug_mode", WRAP_METHOD(Debugger, cmd_setScreenDebug));
|
||||
DCmd_Register("load_palette", WRAP_METHOD(Debugger, cmd_loadPalette));
|
||||
DCmd_Register("facings", WRAP_METHOD(Debugger, cmd_showFacings));
|
||||
@ -189,11 +191,7 @@ bool Debugger::cmd_setTimerCountdown(int argc, const char **argv) {
|
||||
#pragma mark -
|
||||
|
||||
Debugger_v1::Debugger_v1(KyraEngine_v1 *vm)
|
||||
: Debugger(vm) {
|
||||
_vm = vm;
|
||||
|
||||
DCmd_Register("continue", WRAP_METHOD(Debugger_v1, Cmd_Exit));
|
||||
DCmd_Register("enter", WRAP_METHOD(Debugger_v1, cmd_enterRoom));
|
||||
: Debugger(vm), _vm(vm) {
|
||||
DCmd_Register("rooms", WRAP_METHOD(Debugger_v1, cmd_listRooms));
|
||||
DCmd_Register("give", WRAP_METHOD(Debugger_v1, cmd_giveItem));
|
||||
DCmd_Register("birthstones", WRAP_METHOD(Debugger_v1, cmd_listBirthstones));
|
||||
@ -235,7 +233,8 @@ bool Debugger_v1::cmd_enterRoom(int argc, const char **argv) {
|
||||
_vm->_currentCharacter->facing = direction;
|
||||
|
||||
_vm->enterNewScene(room, _vm->_currentCharacter->facing, 0, 0, 1);
|
||||
_vm->_screen->_mouseLockCount = 0;
|
||||
while (!_vm->_screen->isMouseVisible())
|
||||
_vm->_screen->showMouse();
|
||||
|
||||
_detach_now = true;
|
||||
return false;
|
||||
@ -285,7 +284,6 @@ bool Debugger_v1::cmd_listBirthstones(int argc, const char **argv) {
|
||||
#pragma mark -
|
||||
|
||||
Debugger_v2::Debugger_v2(KyraEngine_v2 *vm) : Debugger(vm), _vm(vm) {
|
||||
DCmd_Register("continue", WRAP_METHOD(Debugger_v2, Cmd_Exit));
|
||||
DCmd_Register("character_info", WRAP_METHOD(Debugger_v2, cmd_characterInfo));
|
||||
DCmd_Register("enter", WRAP_METHOD(Debugger_v2, cmd_enterScene));
|
||||
DCmd_Register("rooms", WRAP_METHOD(Debugger_v2, cmd_listScenes)); // for consistency with kyra_v1
|
||||
@ -454,5 +452,109 @@ bool Debugger_v2::cmd_passcodes(int argc, const char **argv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Debugger_v3::Debugger_v3(KyraEngine_v3 *vm) : Debugger(vm), _vm(vm) {
|
||||
DCmd_Register("give", WRAP_METHOD(Debugger_v3, cmd_giveItem));
|
||||
DCmd_Register("enter", WRAP_METHOD(Debugger_v3, cmd_enterScene));
|
||||
DCmd_Register("rooms", WRAP_METHOD(Debugger_v3, cmd_listScenes)); // for consistency with kyra_v1
|
||||
DCmd_Register("scenes", WRAP_METHOD(Debugger_v3, cmd_listScenes));
|
||||
DCmd_Register("scene_info", WRAP_METHOD(Debugger_v3, cmd_sceneInfo));
|
||||
DCmd_Register("scene_to_facing", WRAP_METHOD(Debugger_v3, cmd_sceneToFacing));
|
||||
}
|
||||
|
||||
bool Debugger_v3::cmd_giveItem(int argc, const char **argv) {
|
||||
if (argc == 2) {
|
||||
int item = atoi(argv[1]);
|
||||
|
||||
// Kyrandia 3 has only 73 items (-1 to 71), otherwise it will crash
|
||||
if (item < -1 || item > 71) {
|
||||
DebugPrintf("itemid must be any value between (including) -1 and 71\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
_vm->setHandItem(item);
|
||||
} else {
|
||||
DebugPrintf("Syntax: give <itemid>\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Debugger_v3::cmd_enterScene(int argc, const char **argv) {
|
||||
uint direction = 0;
|
||||
if (argc > 1) {
|
||||
int scene = atoi(argv[1]);
|
||||
|
||||
// game will crash if entering a non-existent scene
|
||||
if (scene >= _vm->_sceneListSize) {
|
||||
DebugPrintf("scene number must be any value between (including) 0 and %d\n", _vm->_sceneListSize-1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
direction = atoi(argv[2]);
|
||||
} else {
|
||||
if (_vm->_sceneList[scene].exit1 != 0xFFFF)
|
||||
direction = 4;
|
||||
else if (_vm->_sceneList[scene].exit2 != 0xFFFF)
|
||||
direction = 6;
|
||||
else if (_vm->_sceneList[scene].exit3 != 0xFFFF)
|
||||
direction = 0;
|
||||
else if (_vm->_sceneList[scene].exit4 != 0xFFFF)
|
||||
direction = 2;
|
||||
}
|
||||
|
||||
_vm->_system->hideOverlay();
|
||||
_vm->_mainCharacter.facing = direction;
|
||||
|
||||
_vm->enterNewScene(scene, _vm->_mainCharacter.facing, 0, 0, 1);
|
||||
while (!_vm->_screen->isMouseVisible())
|
||||
_vm->_screen->showMouse();
|
||||
|
||||
_detach_now = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
DebugPrintf("Syntax: %d <scenenum> <direction>\n", argv[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Debugger_v3::cmd_listScenes(int argc, const char **argv) {
|
||||
int shown = 1;
|
||||
for (int i = 0; i < _vm->_sceneListSize; ++i) {
|
||||
if (_vm->_sceneList[i].filename1[0]) {
|
||||
DebugPrintf("%-2i: %-10s", i, _vm->_sceneList[i].filename1);
|
||||
if (!(shown % 5))
|
||||
DebugPrintf("\n");
|
||||
++shown;
|
||||
}
|
||||
}
|
||||
DebugPrintf("\n");
|
||||
DebugPrintf("Current scene: %i\n", _vm->_mainCharacter.sceneId);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Debugger_v3::cmd_sceneInfo(int argc, const char **argv) {
|
||||
DebugPrintf("Current scene: %d '%s'\n", _vm->_mainCharacter.sceneId, _vm->_sceneList[_vm->_mainCharacter.sceneId].filename1);
|
||||
DebugPrintf("\n");
|
||||
DebugPrintf("Exit information:\n");
|
||||
DebugPrintf("Exit1: leads to %d, position %dx%d\n", int16(_vm->_sceneExit1), _vm->_sceneEnterX1, _vm->_sceneEnterY1);
|
||||
DebugPrintf("Exit2: leads to %d, position %dx%d\n", int16(_vm->_sceneExit2), _vm->_sceneEnterX2, _vm->_sceneEnterY2);
|
||||
DebugPrintf("Exit3: leads to %d, position %dx%d\n", int16(_vm->_sceneExit3), _vm->_sceneEnterX3, _vm->_sceneEnterY3);
|
||||
DebugPrintf("Exit4: leads to %d, position %dx%d\n", int16(_vm->_sceneExit4), _vm->_sceneEnterX4, _vm->_sceneEnterY4);
|
||||
DebugPrintf("Special exit information:\n");
|
||||
if (!_vm->_specialExitCount) {
|
||||
DebugPrintf("No special exits.\n");
|
||||
} else {
|
||||
DebugPrintf("This scene has %d special exits.\n", _vm->_specialExitCount);
|
||||
for (int i = 0; i < _vm->_specialExitCount; ++i) {
|
||||
DebugPrintf("SpecialExit%d: facing %d, position (x1/y1/x2/y2): %d/%d/%d/%d\n", i,
|
||||
_vm->_specialExitTable[20+i], _vm->_specialExitTable[0+i], _vm->_specialExitTable[5+i],
|
||||
_vm->_specialExitTable[10+i], _vm->_specialExitTable[15+i]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Kyra
|
||||
|
||||
|
@ -33,6 +33,7 @@ namespace Kyra {
|
||||
class KyraEngine;
|
||||
class KyraEngine_v1;
|
||||
class KyraEngine_v2;
|
||||
class KyraEngine_v3;
|
||||
|
||||
class Debugger : public ::GUI::Debugger {
|
||||
public:
|
||||
@ -87,6 +88,22 @@ protected:
|
||||
bool cmd_passcodes(int argc, const char **argv);
|
||||
};
|
||||
|
||||
class Debugger_v3 : public Debugger {
|
||||
public:
|
||||
Debugger_v3(KyraEngine_v3 *vm);
|
||||
virtual ~Debugger_v3() {}
|
||||
|
||||
protected:
|
||||
KyraEngine_v3 *_vm;
|
||||
|
||||
bool cmd_giveItem(int argc, const char **argv);
|
||||
bool cmd_enterScene(int argc, const char **argv);
|
||||
bool cmd_listScenes(int argc, const char **argv);
|
||||
bool cmd_sceneInfo(int argc, const char **argv);
|
||||
bool cmd_sceneToFacing(int argc, const char **argv);
|
||||
};
|
||||
|
||||
|
||||
} // End of namespace Kyra
|
||||
|
||||
#endif
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "kyra/vqa.h"
|
||||
#include "kyra/gui.h"
|
||||
#include "kyra/timer.h"
|
||||
#include "kyra/debugger.h"
|
||||
|
||||
#include "common/system.h"
|
||||
#include "common/config-manager.h"
|
||||
@ -130,6 +131,7 @@ KyraEngine_v3::KyraEngine_v3(OSystem *system, const GameFlags &flags) : KyraEngi
|
||||
_invWsaFrame = -1;
|
||||
_score = 0;
|
||||
memset(_scoreFlagTable, 0, sizeof(_scoreFlagTable));
|
||||
_debugger = 0;
|
||||
}
|
||||
|
||||
KyraEngine_v3::~KyraEngine_v3() {
|
||||
@ -188,6 +190,7 @@ KyraEngine_v3::~KyraEngine_v3() {
|
||||
delete [] _stringBuffer;
|
||||
delete [] _newShapeFiledata;
|
||||
delete _invWsa;
|
||||
delete _debugger;
|
||||
}
|
||||
|
||||
int KyraEngine_v3::init() {
|
||||
@ -198,6 +201,9 @@ int KyraEngine_v3::init() {
|
||||
|
||||
KyraEngine::init();
|
||||
|
||||
_debugger = new Debugger_v3(this);
|
||||
assert(_debugger);
|
||||
|
||||
_soundDigital = new SoundDigital(this, _mixer);
|
||||
assert(_soundDigital);
|
||||
if (!_soundDigital->init())
|
||||
@ -622,6 +628,8 @@ void KyraEngine_v3::startup() {
|
||||
memset(_conversationState, -1, sizeof(_conversationState));
|
||||
|
||||
_sceneList = new SceneDesc[98];
|
||||
_sceneListSize = 98;
|
||||
|
||||
musicUpdate(0);
|
||||
runStartupScript(1, 0);
|
||||
_res->exists("MOODOMTR.WSA", true);
|
||||
@ -1359,9 +1367,9 @@ int KyraEngine_v3::checkInput(Button *buttonList, bool mainLoop) {
|
||||
|
||||
switch (event.type) {
|
||||
case Common::EVENT_KEYDOWN:
|
||||
/*if (event.kbd.keycode >= '1' && event.kbd.keycode <= '9' &&
|
||||
if (event.kbd.keycode >= '1' && event.kbd.keycode <= '9' &&
|
||||
(event.kbd.flags == Common::KBD_CTRL || event.kbd.flags == Common::KBD_ALT) && mainLoop) {
|
||||
const char *saveLoadSlot = getSavegameFilename(9 - (event.kbd.keycode - '0') + 990);
|
||||
/*const char *saveLoadSlot = getSavegameFilename(9 - (event.kbd.keycode - '0') + 990);
|
||||
|
||||
if (event.kbd.flags == Common::KBD_CTRL) {
|
||||
loadGame(saveLoadSlot);
|
||||
@ -1371,11 +1379,11 @@ int KyraEngine_v3::checkInput(Button *buttonList, bool mainLoop) {
|
||||
char savegameName[14];
|
||||
sprintf(savegameName, "Quicksave %d", event.kbd.keycode - '0');
|
||||
saveGame(saveLoadSlot, savegameName);
|
||||
}
|
||||
}*/
|
||||
} else if (event.kbd.flags == Common::KBD_CTRL) {
|
||||
if (event.kbd.keycode == 'd')
|
||||
_debugger->attach();
|
||||
}*/
|
||||
}
|
||||
break;
|
||||
|
||||
case Common::EVENT_MOUSEMOVE: {
|
||||
@ -1398,8 +1406,8 @@ int KyraEngine_v3::checkInput(Button *buttonList, bool mainLoop) {
|
||||
break;
|
||||
}
|
||||
|
||||
//if (_debugger->isAttached())
|
||||
// _debugger->onFrame();
|
||||
if (_debugger->isAttached())
|
||||
_debugger->onFrame();
|
||||
|
||||
if (breakLoop)
|
||||
break;
|
||||
|
@ -40,9 +40,11 @@ class Screen_v3;
|
||||
class MainMenu;
|
||||
class WSAMovieV2;
|
||||
class TextDisplayer_v3;
|
||||
class Debugger_v3;
|
||||
struct Button;
|
||||
|
||||
class KyraEngine_v3 : public KyraEngine {
|
||||
friend class Debugger_v3;
|
||||
friend class TextDisplayer_v3;
|
||||
public:
|
||||
KyraEngine_v3(OSystem *system, const GameFlags &flags);
|
||||
@ -407,6 +409,7 @@ private:
|
||||
};
|
||||
|
||||
SceneDesc *_sceneList;
|
||||
int _sceneListSize;
|
||||
uint16 _sceneExit1, _sceneExit2, _sceneExit3, _sceneExit4;
|
||||
int _sceneEnterX1, _sceneEnterY1;
|
||||
int _sceneEnterX2, _sceneEnterY2;
|
||||
@ -746,6 +749,7 @@ private:
|
||||
|
||||
// misc
|
||||
TextDisplayer_v3 *_text;
|
||||
Debugger_v3 *_debugger;
|
||||
bool _wsaPlayingVQA;
|
||||
|
||||
// resource specific
|
||||
|
Loading…
Reference in New Issue
Block a user