SHERLOCK: Split up Debugger class for both games

This commit is contained in:
Paul Gilbert 2015-07-12 22:30:32 -04:00
parent 918f6c06a6
commit 6c03654980
9 changed files with 246 additions and 77 deletions

View File

@ -23,21 +23,25 @@
#include "sherlock/debugger.h"
#include "sherlock/sherlock.h"
#include "sherlock/music.h"
#include "sherlock/scalpel/3do/movie_decoder.h"
#include "sherlock/scalpel/scalpel_debugger.h"
#include "sherlock/tattoo/tattoo_debugger.h"
#include "audio/mixer.h"
#include "audio/decoders/aiff.h"
#include "audio/decoders/wave.h"
#include "audio/decoders/3do.h"
namespace Sherlock {
Debugger *Debugger::init(SherlockEngine *vm) {
if (vm->getGameID() == GType_RoseTattoo)
return new Tattoo::TattooDebugger(vm);
else
return new Scalpel::ScalpelDebugger(vm);
}
Debugger::Debugger(SherlockEngine *vm) : GUI::Debugger(), _vm(vm) {
registerCmd("continue", WRAP_METHOD(Debugger, cmdExit));
registerCmd("scene", WRAP_METHOD(Debugger, cmdScene));
registerCmd("3do_playmovie", WRAP_METHOD(Debugger, cmd3DO_PlayMovie));
registerCmd("3do_playaudio", WRAP_METHOD(Debugger, cmd3DO_PlayAudio));
registerCmd("song", WRAP_METHOD(Debugger, cmdSong));
registerCmd("dumpfile", WRAP_METHOD(Debugger, cmdDumpFile));
}
@ -78,56 +82,6 @@ bool Debugger::cmdScene(int argc, const char **argv) {
}
}
bool Debugger::cmd3DO_PlayMovie(int argc, const char **argv) {
if (argc != 2) {
debugPrintf("Format: 3do_playmovie <3do-movie-file>\n");
return true;
}
// play gets postboned until debugger is closed
Common::String filename = argv[1];
_3doPlayMovieFile = filename;
return cmdExit(0, 0);
}
bool Debugger::cmd3DO_PlayAudio(int argc, const char **argv) {
if (argc != 2) {
debugPrintf("Format: 3do_playaudio <3do-audio-file>\n");
return true;
}
Common::File *file = new Common::File();
if (!file->open(argv[1])) {
debugPrintf("can not open specified audio file\n");
return true;
}
Audio::AudioStream *testStream;
Audio::SoundHandle testHandle;
// Try to load the given file as AIFF/AIFC
testStream = Audio::makeAIFFStream(file, DisposeAfterUse::YES);
if (testStream) {
g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &testHandle, testStream);
_vm->_events->clearEvents();
while ((!_vm->shouldQuit()) && g_system->getMixer()->isSoundHandleActive(testHandle)) {
_vm->_events->pollEvents();
g_system->delayMillis(10);
if (_vm->_events->kbHit()) {
break;
}
}
debugPrintf("playing completed\n");
g_system->getMixer()->stopHandle(testHandle);
}
return true;
}
bool Debugger::cmdSong(int argc, const char **argv) {
if (argc != 2) {
debugPrintf("Format: song <room>\n");

View File

@ -31,15 +31,7 @@ namespace Sherlock {
class SherlockEngine;
class Debugger : public GUI::Debugger {
public:
Debugger(SherlockEngine *vm);
virtual ~Debugger() {}
void postEnter();
private:
SherlockEngine *_vm;
/**
* Converts a decimal or hexadecimal string into a number
*/
@ -50,16 +42,6 @@ private:
*/
bool cmdScene(int argc, const char **argv);
/**
* Plays a 3DO movie
*/
bool cmd3DO_PlayMovie(int argc, const char **argv);
/**
* Plays a 3DO audio
*/
bool cmd3DO_PlayAudio(int argc, const char **argv);
/**
* Plays a song
*/
@ -69,9 +51,15 @@ private:
* Dumps a file to disk
*/
bool cmdDumpFile(int argc, const char **argv);
private:
protected:
SherlockEngine *_vm;
Common::String _3doPlayMovieFile;
public:
Debugger(SherlockEngine *vm);
virtual ~Debugger() {}
static Debugger *init(SherlockEngine *vm);
void postEnter();
};
} // End of namespace Sherlock

View File

@ -8,6 +8,7 @@ MODULE_OBJS = \
scalpel/drivers/mt32.o \
scalpel/tsage/logo.o \
scalpel/tsage/resources.o \
scalpel/scalpel_debugger.o \
scalpel/scalpel_fixed_text.o \
scalpel/scalpel_inventory.o \
scalpel/scalpel_journal.o \
@ -21,6 +22,7 @@ MODULE_OBJS = \
scalpel/settings.o \
tattoo/tattoo.o \
tattoo/tattoo_darts.o \
tattoo/tattoo_debugger.o \
tattoo/tattoo_fixed_text.o \
tattoo/tattoo_inventory.o \
tattoo/tattoo_journal.o \

View File

@ -0,0 +1,91 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* 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 "sherlock/scalpel/scalpel_debugger.h"
#include "sherlock/sherlock.h"
#include "audio/mixer.h"
#include "audio/decoders/3do.h"
#include "audio/decoders/aiff.h"
#include "audio/decoders/wave.h"
namespace Sherlock {
namespace Scalpel {
ScalpelDebugger::ScalpelDebugger(SherlockEngine *vm) : Debugger(vm) {
registerCmd("3do_playmovie", WRAP_METHOD(ScalpelDebugger, cmd3DO_PlayMovie));
registerCmd("3do_playaudio", WRAP_METHOD(ScalpelDebugger, cmd3DO_PlayAudio));
}
bool ScalpelDebugger::cmd3DO_PlayMovie(int argc, const char **argv) {
if (argc != 2) {
debugPrintf("Format: 3do_playmovie <3do-movie-file>\n");
return true;
}
// play gets postboned until debugger is closed
Common::String filename = argv[1];
_3doPlayMovieFile = filename;
return cmdExit(0, 0);
}
bool ScalpelDebugger::cmd3DO_PlayAudio(int argc, const char **argv) {
if (argc != 2) {
debugPrintf("Format: 3do_playaudio <3do-audio-file>\n");
return true;
}
Common::File *file = new Common::File();
if (!file->open(argv[1])) {
debugPrintf("can not open specified audio file\n");
return true;
}
Audio::AudioStream *testStream;
Audio::SoundHandle testHandle;
// Try to load the given file as AIFF/AIFC
testStream = Audio::makeAIFFStream(file, DisposeAfterUse::YES);
if (testStream) {
g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &testHandle, testStream);
_vm->_events->clearEvents();
while ((!_vm->shouldQuit()) && g_system->getMixer()->isSoundHandleActive(testHandle)) {
_vm->_events->pollEvents();
g_system->delayMillis(10);
if (_vm->_events->kbHit()) {
break;
}
}
debugPrintf("playing completed\n");
g_system->getMixer()->stopHandle(testHandle);
}
return true;
}
} // End of namespace Scalpel
} // End of namespace Sherlock

View File

@ -0,0 +1,54 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* 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 SHERLOCK_SCALPEL_DEBUGGER_H
#define SHERLOCK_SCALPEL_DEBUGGER_H
#include "sherlock/debugger.h"
namespace Sherlock {
class SherlockEngine;
namespace Scalpel {
class ScalpelDebugger : public Debugger {
private:
/**
* Plays a 3DO movie
*/
bool cmd3DO_PlayMovie(int argc, const char **argv);
/**
* Plays a 3DO audio
*/
bool cmd3DO_PlayAudio(int argc, const char **argv);
public:
ScalpelDebugger(SherlockEngine *vm);
virtual ~ScalpelDebugger() {}
};
} // End of namespace Scalpel
} // End of namespace Sherlock
#endif /* SHERLOCK_DEBUGGER_H */

View File

@ -93,7 +93,7 @@ void SherlockEngine::initialize() {
_res = new Resources(this);
_animation = new Animation(this);
_debugger = new Debugger(this);
_debugger = Debugger::init(this);
_events = new Events(this);
_fixedText = FixedText::init(this);
_inventory = Inventory::init(this);

View File

@ -0,0 +1,35 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* 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 "sherlock/tattoo/tattoo_debugger.h"
#include "sherlock/sherlock.h"
namespace Sherlock {
namespace Tattoo {
TattooDebugger::TattooDebugger(SherlockEngine *vm) : Debugger(vm) {
}
} // End of namespace Tattoo
} // End of namespace Sherlock

View File

@ -0,0 +1,44 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* 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 SHERLOCK_TATTOO_DEBUGGER_H
#define SHERLOCK_TATTOO_DEBUGGER_H
#include "sherlock/debugger.h"
namespace Sherlock {
class SherlockEngine;
namespace Tattoo {
class TattooDebugger : public Debugger {
public:
TattooDebugger(SherlockEngine *vm);
virtual ~TattooDebugger() {}
};
} // End of namespace Tattoo
} // End of namespace Sherlock
#endif /* SHERLOCK_TATTOO_DEBUGGER_H */

View File

@ -293,7 +293,8 @@ void TattooMap::drawMapIcons() {
Screen &screen = *_vm->_screen;
for (uint idx = 0; idx < _data.size(); ++idx) {
_vm->setFlagsDirect(idx + 1); //***DEBUG***
_vm->setFlagsDirect(idx + 1);
if (_data[idx]._iconNum != -1 && _vm->readFlags(idx + 1)) {
MapEntry &mapEntry = _data[idx];
ImageFrame &img = (*_iconImages)[mapEntry._iconNum];