diff options
author | Filippos Karapetis | 2009-05-30 17:53:12 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-05-30 17:53:12 +0000 |
commit | 15d5b8436e768674aeb2564d6f379e906fb0898c (patch) | |
tree | f382cdc13b652420c717aeb710c8da7534dedc47 | |
parent | 2f90c8f398bf41ee571d31ce08dbf46d524cc592 (diff) | |
download | scummvm-rg350-15d5b8436e768674aeb2564d6f379e906fb0898c.tar.gz scummvm-rg350-15d5b8436e768674aeb2564d6f379e906fb0898c.tar.bz2 scummvm-rg350-15d5b8436e768674aeb2564d6f379e906fb0898c.zip |
Removed the "sfx_debuglog" command. Sound debug messages are now shown if kDebugLevelSound is specified
svn-id: r41039
-rw-r--r-- | engines/sci/engine/savegame.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 98 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_widgets.cpp | 6 | ||||
-rw-r--r-- | engines/sci/sfx/core.cpp | 73 | ||||
-rw-r--r-- | engines/sci/sfx/core.h | 6 |
5 files changed, 36 insertions, 148 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index c710a70bd2..f2e4e703a5 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -853,7 +853,6 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { retval->_sound._flags = s->_sound._flags; retval->_sound._song = NULL; retval->_sound._suspended = s->_sound._suspended; - retval->_sound._debug = s->_sound._debug; reconstruct_sounds(retval); // Message state: diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 6eb882c35e..53bd6f3949 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -1708,87 +1708,9 @@ struct generic_config_flag_t { unsigned int flag; }; -static void handle_config_update(const generic_config_flag_t *flags_list, int flags_nr, const char *subsystem, - int *active_options_p, const char *changestring /* or NULL to display*/) { - if (!changestring) { - int j; - - sciprintf("Logging in %s:\n", subsystem); - if (!(*active_options_p)) - sciprintf(" (nothing)\n"); - - for (j = 0; j < flags_nr; j++) - if (*active_options_p & flags_list[j].flag) { - sciprintf(" - %s (%c)\n", flags_list[j].name, flags_list[j].option); - } - } else { - int mode; - int j = 0; - int flags = 0; - - if (changestring[0] == '-') - mode = 0; - else if (changestring[0] == '+') - mode = 1; - else { - sciprintf("Mode spec must start with '+' or '-' in '%s'\n", changestring); - return; - } - - while (changestring[++j]) { - int k; - int flag = 0; - - if (changestring[j] == '*') - flags = ~0; // Everything - else - for (k = 0; !flag && k < flags_nr; k++) - if (flags_list[k].option == changestring[j]) - flag = flags_list[k].flag; - - if (!flag) { - sciprintf("Invalid/unknown mode flag '%c'\n", changestring[j]); - return; - } - flags |= flag; - } - - if (mode) // + - *active_options_p |= flags; - else // - - *active_options_p &= ~flags; - } -} - -static int c_handle_config_update(const generic_config_flag_t *flags, int flags_nr, const char *subsystem, - int *active_options_p, const Common::Array<cmd_param_t> &cmdParams) { - - if (!_debugstate_valid) { - sciprintf("Not in debug state\n"); - return 1; - } - - if (cmdParams.size() == 0) - handle_config_update(flags, flags_nr, subsystem, active_options_p, 0); - - for (uint i = 0; i < cmdParams.size(); i++) - handle_config_update(flags, flags_nr, subsystem, active_options_p, cmdParams[i].str); - - return 0; -} - #define SFX_DEBUG_MODES 2 #define FROBNICATE_HANDLE(reg) ((reg).segment << 16 | (reg).offset) -static int c_sfx_debuglog(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) { - const generic_config_flag_t sfx_debug_modes[SFX_DEBUG_MODES] = { - {"Song activation/deactivation", 's', SFX_DEBUG_SONGS}, - {"Song cue polling and delivery", 'c', SFX_DEBUG_CUES} - }; - - return c_handle_config_update(sfx_debug_modes, SFX_DEBUG_MODES, "sound subsystem", (int *)&(s->_sound._debug), cmdParams); -} - static int c_sfx_remove(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) { reg_t id = cmdParams[0].reg; int handle = FROBNICATE_HANDLE(id); @@ -1810,20 +1732,20 @@ static int c_is_sample(EngineState *s, const Common::Array<cmd_param_t> &cmdPara Audio::AudioStream *data; if (!song) { - sciprintf("Not a sound resource.\n"); + warning("Not a sound resource"); return 1; } songit = songit_new(song->data, song->size, SCI_SONG_ITERATOR_TYPE_SCI0, 0xcaffe /* What do I care about the ID? */); if (!songit) { - sciprintf("Error-- Could not convert to song iterator\n"); + warning("Error-- Could not convert to song iterator"); return 1; } if ((data = songit->getAudioStream())) { /* - sciprintf("\nIs sample (encoding %dHz/%s/%04x).\n", data->conf.rate, (data->conf.stereo) ? + warning("\nIs sample (encoding %dHz/%s/%04x).", data->conf.rate, (data->conf.stereo) ? ((data->conf.stereo == SFX_PCM_STEREO_LR) ? "stereo-LR" : "stereo-RL") : "mono", data->conf.format); */ delete data; @@ -2360,20 +2282,6 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t * " The word sequence must be provided as a\n single string."); con_hook_command(c_set_parse_nodes, "set_parse_nodes", "s*", "Sets the contents of all parse nodes.\n" " Input token must be separated by\n blanks."); - con_hook_command(c_sfx_debuglog, "sfx_debuglog", "s*", - "Sets or prints the sound subsystem debug\n" - "settings\n\n" - "USAGE\n\n" - " sfx_debuglog {[+|-][p|u|x|b]+}*\n\n" - " sfx_debuglog\n\n" - " Prints current settings\n\n" - " sfx_debuglog +X\n\n" - " Activates all debug features listed in X\n\n" - " sfx_debuglog -X\n\n" - " Deactivates the debug features listed in X\n\n" - " Debug features:\n" - " s: Active song changes\n" - " c: Song cues\n"); #ifdef GFXW_DEBUG_WIDGETS con_hook_command(c_gfx_print_widget, "gfx_print_widget", "i*", "If called with no parameters, it\n shows which widgets are active.\n" diff --git a/engines/sci/gfx/gfx_widgets.cpp b/engines/sci/gfx/gfx_widgets.cpp index e0edf36788..25651fa7b5 100644 --- a/engines/sci/gfx/gfx_widgets.cpp +++ b/engines/sci/gfx/gfx_widgets.cpp @@ -154,9 +154,6 @@ GfxWidget::GfxWidget(gfxw_widget_type_t type_) { static int verify_widget(GfxWidget *widget) { if (!widget) { GFXERROR("Attempt to use NULL widget\n"); -#ifdef GFXW_DEBUG_WIDGETS - BREAKPOINT(); -#endif return 1; } else if (widget->_magic != GFXW_MAGIC_VALID) { if (widget->_magic == GFXW_MAGIC_INVALID) { @@ -164,9 +161,6 @@ static int verify_widget(GfxWidget *widget) { } else { GFXERROR("Attempt to use non-widget\n"); } -#ifdef GFXW_DEBUG_WIDGETS - BREAKPOINT(); -#endif return 1; } return 0; diff --git a/engines/sci/sfx/core.cpp b/engines/sci/sfx/core.cpp index 549a337a64..96ad6fa34a 100644 --- a/engines/sci/sfx/core.cpp +++ b/engines/sci/sfx/core.cpp @@ -26,6 +26,7 @@ /* Sound subsystem core: Event handler, sound player dispatching */ #include "sci/tools.h" +#include "sci/sci.h" #include "sci/sfx/core.h" #include "sci/sfx/iterator.h" #include "sci/sfx/misc.h" @@ -486,20 +487,25 @@ void SfxState::updateSingleSong() { setSongStatus(newsong, SOUND_STATUS_WAITING); } - if (_debug & SFX_DEBUG_SONGS) { - sciprintf("[SFX] Changing active song:"); - if (!_song) - sciprintf(" New song:"); - else - sciprintf(" pausing %08lx, now playing", _song->handle); - - if (newsong) - sciprintf(" %08lx\n", newsong->handle); - else - sciprintf(" none\n"); + Common::String debugMessage = "[SFX] Changing active song:"; + if (!_song) { + debugMessage += " New song:"; + } else { + char tmp[50]; + sprintf(tmp, " pausing %08lx, now playing ", _song->handle); + debugMessage += tmp; } + if (newsong) { + char tmp[20]; + sprintf(tmp, "%08lx\n", newsong->handle); + debugMessage += tmp; + } else { + debugMessage += " none\n"; + } + debugC(2, kDebugLevelSound, debugMessage.c_str()); + _song = newsong; thawTime(); /* Recover song delay time */ @@ -565,9 +571,8 @@ void SfxState::updateMultiSong() { oldseeker = oldseeker->next_stopping) if (oldseeker->next_playing == ¬_playing_anymore) { setSongStatus(oldseeker, SOUND_STATUS_SUSPENDED); - if (_debug & SFX_DEBUG_SONGS) { - sciprintf("[SFX] Stopping song %lx\n", oldseeker->handle); - } + debugC(2, kDebugLevelSound, "[SFX] Stopping song %lx\n", oldseeker->handle); + if (player && oldseeker->it) player->iterator_message(SongIterator::Message(oldseeker->it->ID, SIMSG_STOP)); oldseeker->next_playing = NULL; /* Clear this pointer; we don't need the tag anymore */ @@ -575,8 +580,7 @@ void SfxState::updateMultiSong() { for (newseeker = newsong; newseeker; newseeker = newseeker->next_playing) { if (newseeker->status != SOUND_STATUS_PLAYING && player) { - if (_debug & SFX_DEBUG_SONGS) - sciprintf("[SFX] Adding song %lx\n", newseeker->it->ID); + debugC(2, kDebugLevelSound, "[SFX] Adding song %lx\n", newseeker->it->ID); SongIterator *clonesong = newseeker->it->clone(newseeker->_delay); player->add_iterator(clonesong, g_system->getMillis()); @@ -617,7 +621,6 @@ void SfxState::sfx_init(ResourceManager *resmgr, int flags) { song_lib_init(&_songlib); _song = NULL; _flags = flags; - _debug = 0; /* Disable all debugging by default */ _soundSync = NULL; _audioResource = NULL; @@ -644,7 +647,7 @@ void SfxState::sfx_init(ResourceManager *resmgr, int flags) { player = new SfxPlayer(); if (!player) { - sciprintf("[SFX] No song player found\n"); + warning("[SFX] No song player found"); return; } @@ -721,9 +724,7 @@ int SfxState::sfx_poll_specific(song_handle_t handle, int *cue) { if (!song) return 0; /* Song not playing */ - if (_debug & SFX_DEBUG_CUES) { - fprintf(stderr, "[SFX:CUE] Polled song %08lx ", handle); - } + debugC(2, kDebugLevelSound, "[SFX:CUE] Polled song %08lx ", handle); while (1) { if (song->_wakeupTime.frameDiff(ctime) > 0) @@ -741,19 +742,14 @@ int SfxState::sfx_poll_specific(song_handle_t handle, int *cue) { case SI_LOOP: case SI_RELATIVE_CUE: case SI_ABSOLUTE_CUE: - if (_debug & SFX_DEBUG_CUES) { - sciprintf(" => "); - - if (result == SI_FINISHED) - sciprintf("finished\n"); - else { - if (result == SI_LOOP) - sciprintf("Loop: "); - else - sciprintf("Cue: "); - - sciprintf("%d (0x%x)", *cue, *cue); - } + if (result == SI_FINISHED) + debugC(2, kDebugLevelSound, " => finished"); + else { + if (result == SI_LOOP) + debugC(2, kDebugLevelSound, " => Loop: %d (0x%x)", *cue, *cue); + else + debugC(2, kDebugLevelSound, " => Cue: %d (0x%x)", *cue, *cue); + } return result; @@ -765,9 +761,7 @@ int SfxState::sfx_poll_specific(song_handle_t handle, int *cue) { break; } } - if (_debug & SFX_DEBUG_CUES) { - fprintf(stderr, "\n"); - } + } @@ -939,8 +933,7 @@ Common::Error SfxState::sfx_send_midi(song_handle_t handle, int channel, if (command == 0xb0 && arg1 == SCI_MIDI_CHANNEL_MUTE) { - sciprintf("TODO: channel mute (channel %d %s)!\n", channel, - channel_state[arg2]); + warning("TODO: channel mute (channel %d %s)!", channel, channel_state[arg2]); /* We need to have a GET_PLAYMASK interface to use here. SET_PLAYMASK we've got. */ @@ -964,7 +957,7 @@ Common::Error SfxState::sfx_send_midi(song_handle_t handle, int channel, buffer[2] = (arg1 & 0xff00) >> 7; break; default: - sciprintf("Unexpected explicit MIDI command %02x\n", command); + warning("Unexpected explicit MIDI command %02x", command); return Common::kUnknownError; } diff --git a/engines/sci/sfx/core.h b/engines/sci/sfx/core.h index 2c327e1f6d..dc557f2f8c 100644 --- a/engines/sci/sfx/core.h +++ b/engines/sci/sfx/core.h @@ -43,11 +43,6 @@ struct fade_params_t; ** simultaneously ? */ #define SFX_STATE_FLAG_NOSOUND (1 << 1) /* Completely disable sound playing */ - -#define SFX_DEBUG_SONGS (1 << 0) /* Debug song changes */ -#define SFX_DEBUG_CUES (1 << 1) /* Debug cues, loops, and -** song completions */ - class SfxState { public: // FIXME, make private SongIterator *_it; /**< The song iterator at the heart of things */ @@ -55,7 +50,6 @@ public: // FIXME, make private songlib_t _songlib; /**< Song library */ song_t *_song; /**< Active song, or start of active song chain */ bool _suspended; /**< Whether we are suspended */ - uint _debug; /**< Debug flags */ ResourceSync *_soundSync; /**< Used by kDoSync for speech syncing in CD talkie games */ AudioResource *_audioResource; /**< Used for audio resources in CD talkie games */ |