diff options
author | Paul Gilbert | 2014-11-08 19:16:14 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-12-12 22:25:25 -0500 |
commit | aea906f7d3c8959337c24ee4507bb245d9f5f744 (patch) | |
tree | bc75f4372906c2fa580c269faab26640049e1993 /engines | |
parent | e7818639afd72d861c3ed985bb8aeb4f685e5042 (diff) | |
download | scummvm-rg350-aea906f7d3c8959337c24ee4507bb245d9f5f744.tar.gz scummvm-rg350-aea906f7d3c8959337c24ee4507bb245d9f5f744.tar.bz2 scummvm-rg350-aea906f7d3c8959337c24ee4507bb245d9f5f744.zip |
ACCESS: Implemented chapter debug command
Diffstat (limited to 'engines')
-rw-r--r-- | engines/access/access.cpp | 2 | ||||
-rw-r--r-- | engines/access/debugger.cpp | 50 | ||||
-rw-r--r-- | engines/access/debugger.h | 17 | ||||
-rw-r--r-- | engines/access/files.cpp | 6 | ||||
-rw-r--r-- | engines/access/files.h | 1 | ||||
-rw-r--r-- | engines/access/room.cpp | 2 | ||||
-rw-r--r-- | engines/access/scripts.cpp | 2 | ||||
-rw-r--r-- | engines/access/scripts.h | 3 |
8 files changed, 72 insertions, 11 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp index f04a5dec88..a1f6430965 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -164,7 +164,7 @@ void AccessEngine::initialize() { _animation = new AnimationManager(this); _bubbleBox = new BubbleBox(this); _char = new CharManager(this); - _debugger = new Debugger(this); + _debugger = Debugger::init(this); _events = new EventsManager(this); _files = new FileManager(this); _inventory = new InventoryManager(this); diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp index d20b5d3e6b..d8f7cfe411 100644 --- a/engines/access/debugger.cpp +++ b/engines/access/debugger.cpp @@ -23,14 +23,10 @@ #include "common/file.h" #include "access/access.h" #include "access/debugger.h" +#include "access/amazon/amazon_game.h" namespace Access { -Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) { - registerCmd("continue", WRAP_METHOD(Debugger, cmdExit)); - registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene)); -} - static int strToInt(const char *s) { if (!*s) // No string at all @@ -47,6 +43,22 @@ static int strToInt(const char *s) { return (int)tmp; } +Debugger *Debugger::init(AccessEngine *vm) { + switch (vm->getGameID()) { + case GType_Amazon: + return new Amazon::AmazonDebugger(vm); + default: + return new Debugger(vm); + } +} + +/*------------------------------------------------------------------------*/ + +Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) { + registerCmd("continue", WRAP_METHOD(Debugger, cmdExit)); + registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene)); +} + bool Debugger::Cmd_LoadScene(int argc, const char **argv) { if (argc != 2) { debugPrintf("Current scene is: %d\n", _vm->_player->_roomNumber); @@ -66,4 +78,32 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) { } } +/*------------------------------------------------------------------------*/ + +namespace Amazon { + +AmazonDebugger::AmazonDebugger(AccessEngine *vm): Debugger(vm) { + registerCmd("chapter", WRAP_METHOD(AmazonDebugger, Cmd_StartChapter)); +} + +bool AmazonDebugger::Cmd_StartChapter(int argc, const char **argv) { + if (argc != 2) { + debugPrintf("Usage: %s <chapter number>\n", argv[0]); + return true; + } + + // Build up a simple one line script to start the given chapter + byte *chapterScript = (byte *)malloc(5); + chapterScript[0] = SCRIPT_START_BYTE; + chapterScript[1] = ROOM_SCRIPT % 256; + chapterScript[2] = ROOM_SCRIPT / 256; + chapterScript[3] = 0x80 + 75; // cmdChapter + chapterScript[4] = strToInt(argv[1]); // chapter number + _vm->_scripts->setScript(new Resource(chapterScript, 5)); + + return false; +} + +} // End of namespace Amazon + } // End of namespace Access diff --git a/engines/access/debugger.h b/engines/access/debugger.h index 6c8424dac4..67425430e2 100644 --- a/engines/access/debugger.h +++ b/engines/access/debugger.h @@ -31,16 +31,29 @@ namespace Access { class AccessEngine; class Debugger : public GUI::Debugger { -private: - AccessEngine *_vm; protected: + AccessEngine *_vm; + bool Cmd_LoadScene(int argc, const char **argv); public: + static Debugger *init(AccessEngine *vm); public: Debugger(AccessEngine *vm); virtual ~Debugger() {} }; +namespace Amazon { + +class AmazonDebugger : public Debugger { +protected: + bool Cmd_StartChapter(int argc, const char **argv); +public: + AmazonDebugger(AccessEngine *vm); + virtual ~AmazonDebugger() {} +}; + +} // End of namespace Amazon + } // End of namespace Access #endif /* ACCESS_DEBUGGER_H */ diff --git a/engines/access/files.cpp b/engines/access/files.cpp index a4ec16ad61..bb8dc57c2c 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -59,6 +59,12 @@ Resource::~Resource() { delete _stream; } +Resource::Resource(byte *data, int size) { + _data = data; + _size = size; + _stream = new Common::MemoryReadStream(data, size); +} + byte *Resource::data() { if (_data == nullptr) { _data = new byte[_size]; diff --git a/engines/access/files.h b/engines/access/files.h index 720d4fb2ba..24e2d88456 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -62,6 +62,7 @@ public: int _size; Resource(); + Resource::Resource(byte *data, int size); ~Resource(); byte *data(); }; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 76ad29e21a..c9f4a886a1 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -235,7 +235,7 @@ void Room::loadRoomData(const byte *roomData) { } void Room::roomLoop() { - _vm->_scripts->_sequence = 2000; + _vm->_scripts->_sequence = ROOM_SCRIPT; _vm->_scripts->searchForSequence(); _vm->_scripts->executeScript(); } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index e99af4b2f6..72fc35dc3f 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -25,8 +25,6 @@ #include "access/resources.h" #include "access/scripts.h" -#define SCRIPT_START_BYTE 0xE0 - namespace Access { Scripts::Scripts(AccessEngine *vm) : Manager(vm) { diff --git a/engines/access/scripts.h b/engines/access/scripts.h index ab80c1cd9f..9860c7cde9 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -32,6 +32,9 @@ namespace Access { class AccessEngine; class Scripts; +#define SCRIPT_START_BYTE 0xE0 +#define ROOM_SCRIPT 2000 + class Scripts: public Manager { private: Resource *_resource; |