From 0602882b1819fc35bf071ac0418a0609400f71bd Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 18 Mar 2003 16:13:52 +0000 Subject: cleanup svn-id: r6832 --- scumm/imuse.cpp | 52 +++++++++++++++++------------------ scumm/imuse.h | 8 +++--- scumm/saveload.cpp | 2 +- scumm/script_v6.cpp | 3 +-- scumm/scummvm.cpp | 1 + scumm/smush/smush_player.cpp | 1 + scumm/sound.cpp | 64 +++++++++++++++++--------------------------- 7 files changed, 57 insertions(+), 74 deletions(-) (limited to 'scumm') diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp index bff8a5b5ff..cec93be063 100644 --- a/scumm/imuse.cpp +++ b/scumm/imuse.cpp @@ -106,7 +106,7 @@ struct Player { // Player part void hook_clear(); void clear(); - bool start_sound(int sound); + bool startSound(int sound); void uninit_parts(); byte *parse_midi(byte *s); void key_off(uint8 chan, byte data); @@ -455,12 +455,12 @@ public: int set_master_volume(uint vol); int get_master_volume(); byte get_channel_program (byte channel) { return _driver->get_channel_program (channel); } - bool start_sound(int sound); - int stop_sound(int sound); + bool startSound(int sound); + int stopSound(int sound); int stop_all_sounds(); int get_sound_status(int sound); bool get_sound_active(int sound); - int32 do_command(int a, int b, int c, int d, int e, int f, int g, int h); + int32 doCommand(int a, int b, int c, int d, int e, int f, int g, int h); int clear_queue(); void setBase(byte **base); @@ -676,7 +676,7 @@ bool IMuseInternal::isGM(int sound) { return false; } -bool IMuseInternal::start_sound(int sound) { +bool IMuseInternal::startSound(int sound) { Player *player; void *mdhd; @@ -697,7 +697,7 @@ bool IMuseInternal::start_sound(int sound) { if (!mdhd) { mdhd = findTag(sound, MDPG_TAG, 0); if (!mdhd) { - warning("SE::start_sound failed: Couldn't find sound %d", sound); + warning("SE::startSound failed: Couldn't find sound %d", sound); return false; } } @@ -720,7 +720,7 @@ bool IMuseInternal::start_sound(int sound) { return false; player->clear(); - return player->start_sound(sound); + return player->startSound(sound); } @@ -789,7 +789,7 @@ void IMuseInternal::init_parts() { } } -int IMuseInternal::stop_sound(int sound) { +int IMuseInternal::stopSound(int sound) { Player *player = _players; int i; int r = -1; @@ -865,7 +865,7 @@ void IMuseInternal::handle_marker(uint id, byte data) { break; _queue_end = pos; - do_command(p[0], p[1], p[2], p[3], p[4], p[5], p[6], 0); + doCommand(p[0], p[1], p[2], p[3], p[4], p[5], p[6], 0); if (_queue_cleared) return; @@ -1242,7 +1242,7 @@ int IMuseInternal::enqueue_trigger(int sound, int marker) { return 0; } -int32 IMuseInternal::do_command(int a, int b, int c, int d, int e, int f, int g, int h) { +int32 IMuseInternal::doCommand(int a, int b, int c, int d, int e, int f, int g, int h) { int i; byte cmd = a & 0xFF; byte param = a >> 8; @@ -1261,9 +1261,9 @@ int32 IMuseInternal::do_command(int a, int b, int c, int d, int e, int f, int g, case 7: return _master_volume >> 1; // Convert from 0-255 to 0-127 case 8: - return start_sound(b) ? 0 : -1; + return startSound(b) ? 0 : -1; case 9: - return stop_sound(b); + return stopSound(b); case 10: // FIXME: Sam and Max - Not sure if this is correct return stop_all_sounds(); case 11: @@ -1282,7 +1282,7 @@ int32 IMuseInternal::do_command(int a, int b, int c, int d, int e, int f, int g, // Set player volume. return player->set_vol (e); default: - warning("IMuseInternal::do_command (6) unsupported sub-command %d", d); + warning("IMuseInternal::doCommand (6) unsupported sub-command %d", d); } return -1; case 13: @@ -1348,13 +1348,13 @@ int32 IMuseInternal::do_command(int a, int b, int c, int d, int e, int f, int g, // Sam & Max: Deferred Command // FIXME: Right now this acts as an immediate command. // The significance of parameter b is unknown. - warning ("Incomplete support for iMuse::do_command(20)"); - return do_command (c, d, e, f, g, h, 0, 0); + warning ("Incomplete support for iMuse::doCommand(20)"); + return doCommand (c, d, e, f, g, h, 0, 0); case 2: case 3: return 0; default: - warning("do_command (%d [%d/%d], %d, %d, %d, %d, %d, %d, %d) unsupported", a, param, cmd, b, c, d, e, f, g, h); + warning("doCommand (%d [%d/%d], %d, %d, %d, %d, %d, %d, %d) unsupported", a, param, cmd, b, c, d, e, f, g, h); } } else if (param == 1) { if ((1 << cmd) & (0x783FFF)) { @@ -1435,7 +1435,7 @@ int32 IMuseInternal::do_command(int a, int b, int c, int d, int e, int f, int g, case 24: return 0; default: - warning("do_command (%d [%d/%d], %d, %d, %d, %d, %d, %d, %d) unsupported", a, param, cmd, b, c, d, e, f, g, h); + warning("doCommand (%d [%d/%d], %d, %d, %d, %d, %d, %d, %d) unsupported", a, param, cmd, b, c, d, e, f, g, h); return -1; } } @@ -1446,7 +1446,7 @@ int32 IMuseInternal::do_command(int a, int b, int c, int d, int e, int f, int g, int32 IMuseInternal::ImSetTrigger (int sound, int id, int a, int b, int c, int d) { // Sam & Max: ImSetTrigger. // Sets a trigger for a particular player and - // marker ID, along with do_command parameters + // marker ID, along with doCommand parameters // to invoke at the marker. The marker is // represented by MIDI SysEx block 00 xx (F7) // where "xx" is the marker ID. @@ -1491,7 +1491,7 @@ int32 IMuseInternal::ImSetTrigger (int sound, int id, int a, int b, int c, int d // If the command is to start a sound, stop that sound if it's already playing. // This fixes some carnival music problems. if (trig->command [0] == 8 && get_sound_status (trig->command [1])) - stop_sound (trig->command [1]); + stopSound (trig->command [1]); return 0; } @@ -1754,14 +1754,14 @@ void Player::clear() { _ticks_per_beat = TICKS_PER_BEAT; } -bool Player::start_sound(int sound) { +bool Player::startSound(int sound) { void *mdhd; mdhd = _se->findTag(sound, MDHD_TAG, 0); if (mdhd == NULL) { mdhd = _se->findTag(sound, MDPG_TAG, 0); if (mdhd == NULL) { - warning("P::start_sound failed: Couldn't find %s", MDHD_TAG); + warning("P::startSound failed: Couldn't find %s", MDHD_TAG); return false; } } @@ -2062,7 +2062,7 @@ void Player::parse_sysex(byte *p, uint len) { } } else { // Sam & Max: Trigger Event - // Triggers are set by do_command (ImSetTrigger). + // Triggers are set by doCommand (ImSetTrigger). // When a SysEx marker is encountered whose sound // ID and marker ID match what was set by ImSetTrigger, // something magical is supposed to happen.... @@ -2071,7 +2071,7 @@ void Player::parse_sysex(byte *p, uint len) { _se->_snm_triggers [a].id == *p) { _se->_snm_triggers [a].sound = _se->_snm_triggers [a].id = 0; - _se->do_command (_se->_snm_triggers [a].command [0], + _se->doCommand (_se->_snm_triggers [a].command [0], _se->_snm_triggers [a].command [1], _se->_snm_triggers [a].command [2], _se->_snm_triggers [a].command [3], @@ -3551,12 +3551,12 @@ int IMuse::set_music_volume(uint vol) { in(); int ret = _target->set_music_volum int IMuse::get_music_volume() { in(); int ret = _target->get_music_volume(); out(); return ret; } int IMuse::set_master_volume(uint vol) { in(); int ret = _target->set_master_volume (vol); out(); return ret; } int IMuse::get_master_volume() { in(); int ret = _target->get_master_volume(); out(); return ret; } -bool IMuse::start_sound(int sound) { in(); bool ret = _target->start_sound (sound); out(); return ret; } -int IMuse::stop_sound(int sound) { in(); int ret = _target->stop_sound (sound); out(); return ret; } +bool IMuse::startSound(int sound) { in(); bool ret = _target->startSound (sound); out(); return ret; } +int IMuse::stopSound(int sound) { in(); int ret = _target->stopSound (sound); out(); return ret; } int IMuse::stop_all_sounds() { in(); int ret = _target->stop_all_sounds(); out(); return ret; } int IMuse::get_sound_status(int sound) { in(); int ret = _target->get_sound_status (sound); out(); return ret; } bool IMuse::get_sound_active(int sound) { in(); bool ret = _target->get_sound_active (sound); out(); return ret; } -int32 IMuse::do_command(int a, int b, int c, int d, int e, int f, int g, int h) { in(); int32 ret = _target->do_command (a,b,c,d,e,f,g,h); out(); return ret; } +int32 IMuse::doCommand(int a, int b, int c, int d, int e, int f, int g, int h) { in(); int32 ret = _target->doCommand (a,b,c,d,e,f,g,h); out(); return ret; } int IMuse::clear_queue() { in(); int ret = _target->clear_queue(); out(); return ret; } void IMuse::setBase(byte **base) { in(); _target->setBase (base); out(); } uint32 IMuse::property(int prop, uint32 value) { in(); uint32 ret = _target->property (prop, value); out(); return ret; } diff --git a/scumm/imuse.h b/scumm/imuse.h index 007c740ac3..4923f408c3 100644 --- a/scumm/imuse.h +++ b/scumm/imuse.h @@ -23,8 +23,6 @@ #ifndef IMUSE_H #define IMUSE_H -#include "imuse_digi.h" - class IMuseInternal; class MidiDriver; class OSystem; @@ -56,12 +54,12 @@ public: int get_music_volume(); int set_master_volume(uint vol); int get_master_volume(); - bool start_sound(int sound); - int stop_sound(int sound); + bool startSound(int sound); + int stopSound(int sound); int stop_all_sounds(); int get_sound_status(int sound); bool get_sound_active(int sound); - int32 do_command(int a, int b, int c, int d, int e, int f, int g, int h); + int32 doCommand(int a, int b, int c, int d, int e, int f, int g, int h); int clear_queue(); void setBase(byte **base); uint32 property(int prop, uint32 value); diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index 035658c149..11b9a2e2a1 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -24,13 +24,13 @@ #include "actor.h" #include "charset.h" #include "imuse.h" +#include "imuse_digi.h" #include "resource.h" #include "saveload.h" #include "scumm.h" #include "sound.h" #include "verbs.h" #include "common/config-file.h" -#include "sound/mididrv.h" struct SaveGameHeader { uint32 type; diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 5d9d5524b2..066e135525 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -2604,8 +2604,7 @@ void Scumm_v6::o6_kernelSetFunctions() { case 122: _vars[VAR_SOUNDRESULT] = - (short)_imuse->do_command(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8] - ); + (short)_imuse->doCommand(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]); break; case 123: diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 4f857bdf68..92538a9d94 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -28,6 +28,7 @@ #include "debugger.h" #include "dialogs.h" #include "imuse.h" +#include "imuse_digi.h" #include "intern.h" #include "object.h" #include "resource.h" diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp index a4da856c27..4406bb8afa 100644 --- a/scumm/smush/smush_player.cpp +++ b/scumm/smush/smush_player.cpp @@ -26,6 +26,7 @@ #include "scumm/scumm.h" #include "scumm/sound.h" #include "scumm/imuse.h" +#include "scumm/imuse_digi.h" #include "sound/mixer.h" #include "smush_player.h" #include "smush_mixer.h" diff --git a/scumm/sound.cpp b/scumm/sound.cpp index c0bb0aecce..c3d25fb276 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -25,6 +25,7 @@ #include "sound.h" #include "sound/mididrv.h" #include "imuse.h" +#include "imuse_digi.h" #include "actor.h" #include "bundle.h" #include "common/config-file.h" @@ -71,10 +72,8 @@ void Sound::addSoundToQueue2(int sound) { void Sound::processSoundQues() { int d; - int i, j; int num; int16 data[16]; - IMuse *se; processSfxQueues(); @@ -84,21 +83,18 @@ void Sound::processSoundQues() { playSound(d); } - for (i = 0; i < _soundQuePos;) { + for (int i = 0; i < _soundQuePos;) { num = _soundQue[i++]; if (i + num > _soundQuePos) { warning("processSoundQues: invalid num value"); break; } - for (j = 0; j < 16; j++) - data[j] = 0; + memset(data, 0, sizeof(data)); if (num > 0) { - for (j = 0; j < num; j++) + for (int j = 0; j < num; j++) data[j] = _soundQue[i + j]; i += num; - se = _scumm->_imuse; - #if 0 debug(1, "processSoundQues(%d,%d,%d,%d,%d,%d,%d,%d,%d)", data[0] >> 8, @@ -108,15 +104,15 @@ void Sound::processSoundQues() { #endif if (!(_scumm->_features & GF_AFTER_V7)) { - if (se) + if (_scumm->_imuse) _scumm->_vars[_scumm->VAR_SOUNDRESULT] = - (short)se->do_command(data[0], data[1], data[2], data[3], data[4], + (short)_scumm->_imuse->doCommand(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); } else { if (_scumm->_imuseDigital) _scumm->_vars[_scumm->VAR_SOUNDRESULT] = (short)_scumm->_imuseDigital->doCommand(data[0], data[1], data[2], data[3], data[4], - data[5], data[6], data[7]); + data[5], data[6], data[7]); } } } @@ -180,8 +176,7 @@ void Sound::playSound(int soundID) { int size; int rate; - debug(3,"playSound #%d (room %d)", - soundID, _scumm->getResourceRoomNr(rtSound, soundID)); + debug(3,"playSound #%d (room %d)", soundID, _scumm->getResourceRoomNr(rtSound, soundID)); ptr = _scumm->getResourceAddress(rtSound, soundID); if (ptr) { if (READ_UINT32_UNALIGNED(ptr) == MKID('iMUS')){ @@ -396,10 +391,9 @@ void Sound::playSound(int soundID) { } - IMuse *se = _scumm->_imuse; - if (se) { + if (_scumm->_imuse) { _scumm->getResourceAddress(rtSound, soundID); - se->start_sound(soundID); + _scumm->_imuse->startSound(soundID); } } @@ -457,7 +451,7 @@ void Sound::processSfxQueues() { } } -static int compar(const void *a, const void *b) { +static int compareMP3OffsetTable(const void *a, const void *b) { return ((MP3OffsetTable *)a)->org_offset - ((MP3OffsetTable *)b)->org_offset; } @@ -510,7 +504,7 @@ int Sound::startTalkSound(uint32 offset, uint32 b, int mode) { key.org_offset = offset; result = (MP3OffsetTable *)bsearch(&key, offset_table, num_sound_effects, - sizeof(MP3OffsetTable), compar); + sizeof(MP3OffsetTable), compareMP3OffsetTable); if (result == NULL) { warning("startTalkSound: did not find sound at offset %d !", offset); @@ -573,7 +567,6 @@ bool Sound::isMouthSyncOff(uint pos) { int Sound::isSoundRunning(int sound) { - IMuse *se; int i; if (sound == _scumm->current_cd_sound) @@ -595,10 +588,9 @@ int Sound::isSoundRunning(int sound) { return _scumm->_imuseDigital->getSoundStatus(sound); } - se = _scumm->_imuse; - if (!se) + if (!_scumm->_imuse) return 0; - return se->get_sound_status(sound); + return _scumm->_imuse->get_sound_status(sound); } // This is exactly the same as isSoundRunning except that it @@ -606,7 +598,6 @@ int Sound::isSoundRunning(int sound) { // This is necessary when determining what resources to // expire from memory. bool Sound::isSoundActive(int sound) { - IMuse *se; int i; if (sound == _scumm->current_cd_sound) @@ -628,10 +619,9 @@ bool Sound::isSoundActive(int sound) { return _scumm->_imuseDigital->getSoundStatus(sound) != 0; } - se = _scumm->_imuse; - if (!se) + if (!_scumm->_imuse) return false; - return se->get_sound_active(sound); + return _scumm->_imuse->get_sound_active(sound); } bool Sound::isSoundInQueue(int sound) { @@ -655,7 +645,6 @@ bool Sound::isSoundInQueue(int sound) { } void Sound::stopSound(int a) { - IMuse *se; int i; if (a != 0 && a == _scumm->current_cd_sound) { @@ -665,10 +654,8 @@ void Sound::stopSound(int a) { if (_scumm->_imuseDigital) { _scumm->_imuseDigital->stopSound(a); - } else { - se = _scumm->_imuse; - if (se) - se->stop_sound(a); + } else if (_scumm->_imuse) { + _scumm->_imuse->stopSound(a); } for (i = 0; i < 10; i++) @@ -677,16 +664,14 @@ void Sound::stopSound(int a) { } void Sound::stopAllSounds() { - IMuse *se = _scumm->_imuse; - if (_scumm->current_cd_sound != 0) { _scumm->current_cd_sound = 0; stopCD(); } - if (se) { - se->stop_all_sounds(); - se->clear_queue(); + if (_scumm->_imuse) { + _scumm->_imuse->stop_all_sounds(); + _scumm->_imuse->clear_queue(); } clearSoundQue(); stopSfxSound(); @@ -706,7 +691,7 @@ void Sound::soundKludge(int *list, int num) { } if ((_soundQuePos + num) > 0x100) { - warning("Sound que buffer overflow"); + warning("Sound que buffer overflow (%d + %d = %d)", _soundQuePos, num, _soundQuePos+num); return; } @@ -754,9 +739,8 @@ void Sound::setupSound() { } void Sound::pauseSounds(bool pause) { - IMuse *se = _scumm->_imuse; - if (se) - se->pause(pause); + if (_scumm->_imuse) + _scumm->_imuse->pause(pause); // Don't pause sounds if the game isn't active // FIXME - this is quite a nasty hack, replace with something cleaner, and w/o -- cgit v1.2.3