STARK: Add a debug console with a command allowing to extract archives
This commit is contained in:
parent
6272a2a7ee
commit
73b58aaa4d
5 changed files with 146 additions and 1 deletions
82
engines/stark/console.cpp
Normal file
82
engines/stark/console.cpp
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/* ResidualVM - A 3D game interpreter
|
||||||
|
*
|
||||||
|
* ResidualVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the AUTHORS
|
||||||
|
* file distributed with this source distribution.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "engines/stark/console.h"
|
||||||
|
#include "engines/stark/archive.h"
|
||||||
|
|
||||||
|
#include "common/file.h"
|
||||||
|
|
||||||
|
namespace Stark {
|
||||||
|
|
||||||
|
Console::Console(StarkEngine *vm) : GUI::Debugger(), _vm(vm) {
|
||||||
|
registerCmd("dumpArchive", WRAP_METHOD(Console, Cmd_DumpArchive));
|
||||||
|
}
|
||||||
|
|
||||||
|
Console::~Console() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Console::Cmd_DumpArchive(int argc, const char **argv) {
|
||||||
|
if (argc != 2) {
|
||||||
|
debugPrintf("Extract all the files from a game archive.\n");
|
||||||
|
debugPrintf("The destination folder, named 'dump', must exist.\n");
|
||||||
|
debugPrintf("Usage :\n");
|
||||||
|
debugPrintf("dumpArchive [file name]\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
XARCArchive xarc;
|
||||||
|
if (!xarc.open(argv[1])) {
|
||||||
|
debugPrintf("Can't open archive with name '%s'\n", argv[1]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Common::ArchiveMemberList members;
|
||||||
|
xarc.listMembers(members);
|
||||||
|
|
||||||
|
for (Common::ArchiveMemberList::const_iterator it = members.begin(); it != members.end(); it++) {
|
||||||
|
Common::String fileName = Common::String::format("dump/%s", it->get()->getName().c_str());
|
||||||
|
|
||||||
|
// Open the output file
|
||||||
|
Common::DumpFile outFile;
|
||||||
|
if (!outFile.open(fileName)) {
|
||||||
|
debugPrintf("Unable to open file '%s' for writing", fileName.c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy the archive content to the output file using a temporary buffer
|
||||||
|
Common::SeekableReadStream *inStream = it->get()->createReadStream();
|
||||||
|
uint8 *buf = new uint8[inStream->size()];
|
||||||
|
|
||||||
|
inStream->read(buf, inStream->size());
|
||||||
|
outFile.write(buf, inStream->size());
|
||||||
|
|
||||||
|
delete[] buf;
|
||||||
|
delete inStream;
|
||||||
|
outFile.close();
|
||||||
|
|
||||||
|
debugPrintf("Extracted '%s'", it->get()->getName().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // End of namespace Stark
|
47
engines/stark/console.h
Normal file
47
engines/stark/console.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/* ResidualVM - A 3D game interpreter
|
||||||
|
*
|
||||||
|
* ResidualVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the AUTHORS
|
||||||
|
* file distributed with this source distribution.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONSOLE_H_
|
||||||
|
#define CONSOLE_H_
|
||||||
|
|
||||||
|
#include "common/debug.h"
|
||||||
|
|
||||||
|
#include "gui/debugger.h"
|
||||||
|
|
||||||
|
#include "engines/stark/stark.h"
|
||||||
|
|
||||||
|
namespace Stark {
|
||||||
|
|
||||||
|
class Console : public GUI::Debugger {
|
||||||
|
public:
|
||||||
|
Console(StarkEngine *vm);
|
||||||
|
virtual ~Console();
|
||||||
|
|
||||||
|
private:
|
||||||
|
StarkEngine *_vm;
|
||||||
|
|
||||||
|
bool Cmd_DumpArchive(int argc, const char **argv);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // End of namespace Stark
|
||||||
|
|
||||||
|
#endif // CONSOLE_H_
|
|
@ -4,6 +4,7 @@ MODULE_OBJS := \
|
||||||
actor.o \
|
actor.o \
|
||||||
adpcm.o \
|
adpcm.o \
|
||||||
archive.o \
|
archive.o \
|
||||||
|
console.o \
|
||||||
detection.o \
|
detection.o \
|
||||||
gfx/coordinate.o \
|
gfx/coordinate.o \
|
||||||
gfx/driver.o \
|
gfx/driver.o \
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "engines/stark/stark.h"
|
#include "engines/stark/stark.h"
|
||||||
|
#include "engines/stark/console.h"
|
||||||
#include "engines/stark/debug.h"
|
#include "engines/stark/debug.h"
|
||||||
|
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
|
@ -33,7 +34,9 @@
|
||||||
|
|
||||||
namespace Stark {
|
namespace Stark {
|
||||||
|
|
||||||
StarkEngine::StarkEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _gfx(NULL), _scene(NULL) {
|
StarkEngine::StarkEngine(OSystem *syst, const ADGameDescription *gameDesc) :
|
||||||
|
Engine(syst), _gameDescription(gameDesc), _gfx(NULL), _scene(NULL),
|
||||||
|
_console(NULL) {
|
||||||
_mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, 127);
|
_mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, 127);
|
||||||
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
|
||||||
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
|
||||||
|
@ -48,9 +51,11 @@ StarkEngine::StarkEngine(OSystem *syst, const ADGameDescription *gameDesc) : Eng
|
||||||
|
|
||||||
StarkEngine::~StarkEngine() {
|
StarkEngine::~StarkEngine() {
|
||||||
delete _scene;
|
delete _scene;
|
||||||
|
delete _console;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Error StarkEngine::run() {
|
Common::Error StarkEngine::run() {
|
||||||
|
_console = new Console(this);
|
||||||
_gfx = GfxDriver::create();
|
_gfx = GfxDriver::create();
|
||||||
|
|
||||||
// Get the screen prepared
|
// Get the screen prepared
|
||||||
|
@ -75,9 +80,15 @@ void StarkEngine::mainLoop() {
|
||||||
if (e.kbd.ascii == 'q') {
|
if (e.kbd.ascii == 'q') {
|
||||||
quitGame();
|
quitGame();
|
||||||
break;
|
break;
|
||||||
|
} else if (e.kbd.keycode == Common::KEYCODE_d) {
|
||||||
|
if (e.kbd.flags & Common::KBD_CTRL) {
|
||||||
|
_console->attach();
|
||||||
|
_console->onFrame();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//handleChars(event.type, event.kbd.keycode, event.kbd.flags, event.kbd.ascii);
|
//handleChars(event.type, event.kbd.keycode, event.kbd.flags, event.kbd.ascii);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/*if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_KEYUP) {
|
/*if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_KEYUP) {
|
||||||
handleControls(event.type, event.kbd.keycode, event.kbd.flags, event.kbd.ascii);
|
handleControls(event.type, event.kbd.keycode, event.kbd.flags, event.kbd.ascii);
|
||||||
|
|
|
@ -44,6 +44,8 @@ enum StarkGameFeatures {
|
||||||
GF_DVD = (1 << 31)
|
GF_DVD = (1 << 31)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Console;
|
||||||
|
|
||||||
class StarkEngine : public Engine {
|
class StarkEngine : public Engine {
|
||||||
public:
|
public:
|
||||||
StarkEngine(OSystem *syst, const ADGameDescription *gameDesc);
|
StarkEngine(OSystem *syst, const ADGameDescription *gameDesc);
|
||||||
|
@ -52,12 +54,14 @@ public:
|
||||||
protected:
|
protected:
|
||||||
// Engine APIs
|
// Engine APIs
|
||||||
virtual Common::Error run();
|
virtual Common::Error run();
|
||||||
|
virtual GUI::Debugger *getDebugger() { return (GUI::Debugger *)_console; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void mainLoop();
|
void mainLoop();
|
||||||
void updateDisplayScene();
|
void updateDisplayScene();
|
||||||
|
|
||||||
GfxDriver *_gfx;
|
GfxDriver *_gfx;
|
||||||
|
Console *_console;
|
||||||
|
|
||||||
const ADGameDescription *_gameDescription;
|
const ADGameDescription *_gameDescription;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue