Removed some unnecessary / commented out code, and initialized the debug

console a bit earlier so that error messages about missing files will be
more obvious to the user. (If an error happens that early, some of the
debugger commands will cause ScummVM to crash. I might look into that
later.)

svn-id: r11443
This commit is contained in:
Torbjörn Andersson 2003-12-01 07:47:54 +00:00
parent a008022b30
commit 7c9d46765b
4 changed files with 37 additions and 91 deletions

View File

@ -123,19 +123,25 @@ void Debugger::varSet(int var, int val) {
void Debugger::preEnter() {
// Pause sound output
_vm->_sound->pauseFx();
_vm->_sound->pauseSpeech();
_vm->_sound->pauseMusic();
if (_vm->_sound) {
_vm->_sound->pauseFx();
_vm->_sound->pauseSpeech();
_vm->_sound->pauseMusic();
}
}
void Debugger::postEnter() {
// Resume previous sound state
_vm->_sound->unpauseFx();
_vm->_sound->unpauseSpeech();
_vm->_sound->unpauseMusic();
if (_vm->_sound) {
// Resume previous sound state
_vm->_sound->unpauseFx();
_vm->_sound->unpauseSpeech();
_vm->_sound->unpauseMusic();
}
// Restore old mouse cursor
_vm->_graphics->drawMouse();
if (_vm->_graphics) {
// Restore old mouse cursor
_vm->_graphics->drawMouse();
}
}
///////////////////////////////////////////////////

View File

@ -141,11 +141,6 @@ private:
void formText(int32 *params);
bool wantSpeechForLine(uint32 wavId);
#ifdef _SWORD2_DEBUG
// for testing speech & text
void getCorrectCdForSpeech(int32 wavId);
#endif
uint32 _totalStartups;
uint32 _totalScreenManagers;
uint32 _startRes;
@ -156,7 +151,7 @@ private:
// id of screen manager object
uint32 start_res_id;
//tell the manager which startup you want (if there are more
// tell the manager which startup you want (if there are more
// than 1) (i.e more than 1 entrance to a screen and/or
// separate game boots)
uint32 key;

View File

@ -871,8 +871,6 @@ int32 Logic::fnISpeak(int32 *params) {
// for text/speech testing & checking for correct file type
_standardHeader *head;
// for text/speech testing - keeping track of text resource currently being tested
static uint32 currentTextResource = 0;
// set up the pointers which we know we'll always need
@ -1081,21 +1079,6 @@ int32 Logic::fnISpeak(int32 *params) {
else if (speech_pan > 16)
speech_pan = 16;
// if we're testing text & speech
if (SYSTEM_TESTING_TEXT) {
// if we've moved onto a new text resource,
// we will want to check if the CD needs
// changing again - can only know which CD to
// get if the wavID is non-zero
if (text_res != currentTextResource && params[S_WAV]) {
// ensure correct CD is in for this
// wavId
// getCorrectCdForSpeech(params[S_WAV]);
currentTextResource = text_res;
}
}
// set up path to speech cluster
// first checking if we have speech1.clu or
// speech2.clu in current directory (for translators
@ -1468,28 +1451,6 @@ void Logic::formText(int32 *params) {
}
}
#ifdef _SWORD2_DEBUG
void Logic::getCorrectCdForSpeech(int32 wavId) {
File fp;
// 1, 2 or 0 (if speech on both cd's, ie. no need to change)
uint8 cd;
if (!fp.open("cd.bin"))
error("Need cd.bin file for testing speech!");
fp.seek(wavId, SEEK_SET);
fp.read(&cd, 1);
fp.close();
// if we specifically need CD1 or CD2 (ie. it's not on both)
// then check it's there (& ask for it if it's not there)
if (cd == 1 || cd == 2)
_vm->_resman->getCd(cd);
}
#endif
// For preventing sfx subtitles from trying to load speech samples
// - since the sfx are implemented as normal sfx, so we don't want them as
// speech samples too

View File

@ -51,9 +51,9 @@ GameList Engine_SWORD2_detectGames(const FSList &fslist) {
GameList detectedGames;
const GameSettings *g;
// TODO: It would be nice if we had code here which distinguishes between
// the 'sword2' and 'sword2demo' targets. The current code can't do that
// since they use the same detectname.
// TODO: It would be nice if we had code here which distinguishes
// between the 'sword2' and 'sword2demo' targets. The current code
// can't do that since they use the same detectname.
for (g = sword2_settings; g->gameName; ++g) {
// Iterate over all files in the given directory
@ -85,6 +85,8 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
g_sword2 = this;
_debugger = NULL;
_sound = NULL;
_graphics = NULL;
_features = detector->_game.features;
_targetName = strdup(detector->_targetName.c_str());
_bootParam = ConfMan.getInt("boot_param");
@ -104,6 +106,15 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
// get some falling RAM and put it in your pocket, never let it slip
// away
_graphics = new Graphics(this, 640, 480);
// Create the debugger as early as possible (but not before the
// graphics object!) so that errors can be displayed in it. In
// particular, we want errors about missing files to be clearly
// visible to the user.
_debugger = new Debugger(this);
_memory = new MemoryManager(this);
_resman = new ResourceManager(this);
_logic = new Logic(this);
@ -111,8 +122,6 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
_gui = new Gui(this);
_input = new Input(this);
_sound = new Sound(this);
_graphics = new Graphics(this, 640, 480);
_debugger = new Debugger(this);
_lastPaletteRes = 0;
@ -185,10 +194,11 @@ void Sword2Engine::errorString(const char *buf1, char *buf2) {
return;
#endif
// Unless an error -originated- within the debugger, spawn the debugger. Otherwise
// exit out normally.
// Unless an error -originated- within the debugger, spawn the
// debugger. Otherwise exit out normally.
if (_debugger && !_debugger->isAttached()) {
printf("%s\n", buf2); // (Print it again in case debugger segfaults)
// (Print it again in case debugger segfaults)
printf("%s\n", buf2);
_debugger->attach(buf2);
_debugger->onFrame();
}
@ -243,7 +253,7 @@ void Sword2Engine::gameCycle(void) {
// got a screen to run?
if (_logic->getRunList()) {
//run the logic session UNTIL a full loop has been performed
// run the logic session UNTIL a full loop has been performed
do {
// reset the graphic 'buildit' list before a new
// logic list (see fnRegisterFrame)
@ -275,14 +285,6 @@ void Sword2Engine::gameCycle(void) {
void Sword2Engine::go() {
_keyboardEvent ke;
// Call the application "Revolution" until the resource manager is
// ready to dig the name out of a text file. See initialiseGame()
// which calls InitialiseFontResourceFlags() in maketext.cpp
//
// Have to do it like this since we cannot really fire up the resource
// manager until a window has been created as any errors are displayed
// via a window, thus time becomes a loop.
debug(5, "CALLING: readOptionSettings");
_gui->readOptionSettings();
@ -342,14 +344,9 @@ void Sword2Engine::go() {
char c = toupper(ke.ascii);
if (ke.modifiers == OSystem::KBD_CTRL) {
if (ke.keycode == 'd') {
_debugger->attach();
}
}
if (c == '~' || c == '#')
if ((ke.modifiers == OSystem::KBD_CTRL && ke.keycode == 'd') || c == '~' || c == '#') {
_debugger->attach();
}
if (_gamePaused) { // if currently paused
if (c == 'P') {
@ -466,14 +463,6 @@ void Sword2Engine::sleepUntil(uint32 time) {
}
void Sword2Engine::pauseGame(void) {
// uint8 *text;
// open text file & get the line "PAUSED"
// text = fetchTextLine(_resman->openResource(3258), 449);
// pause_text_bloc_no = _fontRenderer->buildNewBloc(text + 2, 320, 210, 640, 184, RDSPR_TRANS | RDSPR_DISPLAYALIGN, SPEECH_FONT_ID, POSITION_AT_CENTRE_OF_BASE);
// now ok to close the text file
// _resman->closeResource(3258);
// don't allow Pause while screen fading or while black
if (_graphics->getFadeStatus() != RDFADE_NONE)
return;
@ -483,8 +472,6 @@ void Sword2Engine::pauseGame(void) {
// make a normal mouse
clearPointerText();
// mouse_mode=MOUSE_normal;
// this is the only place allowed to do it this way
_graphics->setLuggageAnim(NULL, 0);
@ -512,9 +499,6 @@ void Sword2Engine::pauseGame(void) {
}
void Sword2Engine::unpauseGame(void) {
// removed "PAUSED" from screen
// _fontRenderer->killTextBloc(pause_text_bloc_no);
if (OBJECT_HELD && _realLuggageItem)
setLuggage(_realLuggageItem);