From 9de8a0cfa9953c40ca37a426cfcc2bfada2c4268 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 7 Sep 2003 07:23:20 +0000 Subject: [PATCH] Add music player for Amiga versions of indy3ega/loom from unused. Revert last change to common.rules for now, it broke compile. svn-id: r10061 --- scumm/module.mk | 1 + scumm/scumm.h | 2 ++ scumm/scummvm.cpp | 9 +++++++++ scumm/sound.cpp | 32 ++++++++++++++------------------ 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/scumm/module.mk b/scumm/module.mk index 52ea8437dae..755b8a5a431 100644 --- a/scumm/module.mk +++ b/scumm/module.mk @@ -23,6 +23,7 @@ SCUMM_OBJS = \ scumm/object.o \ scumm/player_v1.o\ scumm/player_v2.o\ + scumm/player_v3a.o\ scumm/resource.o \ scumm/resource_v2.o \ scumm/resource_v3.o \ diff --git a/scumm/scumm.h b/scumm/scumm.h index 15d56b92a14..04a8df3ae94 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -41,6 +41,7 @@ class IMuse; class IMuseDigital; class NewGui; class Player_V2; +class Player_V3A; class Scumm; class ScummDebugger; class Serializer; @@ -305,6 +306,7 @@ public: IMuse *_imuse; IMuseDigital *_imuseDigital; Player_V2 *_playerV2; + Player_V3A *_playerV3A; Sound *_sound; VerbSlot *_verbs; diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index edb708e29a6..56a99c024ac 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -31,6 +31,7 @@ #include "imuse_digi.h" #include "intern.h" #include "object.h" +#include "player_v3a.h" #include "player_v2.h" #include "player_v1.h" #include "resource.h" @@ -690,8 +691,11 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst) _imuse = NULL; _imuseDigital = NULL; _playerV2 = NULL; + _playerV3A = NULL; if (_features & GF_DIGI_IMUSE) { _imuseDigital = new IMuseDigital(this); + } else if ((_features & GF_AMIGA) && (_version == 3)) { + _playerV3A = new Player_V3A(this); } else if ((_features & GF_AMIGA) && (_version < 5)) { _playerV2 = NULL; } else if (((_midiDriver == MD_PCJR) || (_midiDriver == MD_PCSPK)) && ((_version > 2) && (_version < 5))) { @@ -783,6 +787,7 @@ Scumm::~Scumm () { delete _imuse; delete _imuseDigital; delete _playerV2; + delete _playerV3A; free(_languageBuffer); free(_audioNames); @@ -1272,6 +1277,10 @@ int Scumm::scummLoop(int delta) { // Covered automatically by the Sound class } else if (_playerV2) { VAR(VAR_MUSIC_TIMER) = _playerV2->getMusicTimer(); + } else if (_playerV3A) { + for (int i = 0; i < delta; i++) + _playerV3A->playMusic(); + VAR(VAR_MUSIC_TIMER) = _playerV3A->getMusicTimer(); } else if (_imuse) { VAR(VAR_MUSIC_TIMER) = _imuse->getMusicTimer(); } else if (_features & GF_SMALL_HEADER) { diff --git a/scumm/sound.cpp b/scumm/sound.cpp index d7a1ba5e915..e0d3323ab13 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -26,6 +26,7 @@ #include "imuse.h" #include "imuse_digi.h" #include "player_v2.h" +#include "player_v3a.h" #include "scumm.h" #include "sound.h" #include "sound/mididrv.h" @@ -430,26 +431,14 @@ void Sound::playSound(int soundID) { } - // Used in Amiga verisons of indy3ega and loom - // Used in Mac. version of indy3ega - if (((_scumm->_features & GF_MACINTOSH) && (_scumm->_gameId == GID_INDY3)) - || ((_scumm->_features & GF_AMIGA) && (_scumm->_version == 3))) { + if ((_scumm->_features & GF_MACINTOSH) && (_scumm->_gameId == GID_INDY3)) { if (ptr[26] == 00) { size = READ_BE_UINT16(ptr + 12); rate = 3579545 / READ_BE_UINT16(ptr + 20); sound = (char *)malloc(size); int vol = ptr[24] * 4; memcpy(sound,ptr + READ_BE_UINT16(ptr + 8), size); - if ((_scumm->_features & GF_AMIGA) && (READ_BE_UINT16(ptr + 16) || READ_BE_UINT16(ptr + 6))) { - // the first check is for pitch-bending looped sounds (i.e. "pouring liquid", "biplane dive", etc.) - // the second check is for simple looped sounds - int loopStart = READ_BE_UINT16(ptr + 10) - READ_BE_UINT16(ptr + 8); - int loopEnd = READ_BE_UINT16(ptr + 14); - _scumm->_mixer->playRaw(NULL, sound, size, rate, - SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_LOOP, soundID, vol, 0, loopStart, loopEnd); - } else { - _scumm->_mixer->playRaw(NULL, sound, size, rate, SoundMixer::FLAG_AUTOFREE, soundID, vol, 0); - } + _scumm->_mixer->playRaw(NULL, sound, size, rate, SoundMixer::FLAG_AUTOFREE, soundID, vol, 0); return; } } @@ -496,7 +485,10 @@ void Sound::playSound(int soundID) { if (_scumm->_playerV2) { _scumm->_playerV2->startSound(soundID, ptr); } - + + if (_scumm->_playerV3A) + _scumm->_playerV3A->startSound(soundID, ptr); + if (_scumm->_imuse) { _scumm->_imuse->startSound(soundID); } @@ -699,6 +691,9 @@ int Sound::isSoundRunning(int sound) const { if (_scumm->_playerV2) return _scumm->_playerV2->getSoundStatus(sound); + if (_scumm->_playerV3A) + return _scumm->_playerV3A->getSoundStatus(sound); + return 0; } @@ -769,9 +764,8 @@ void Sound::stopSound(int a) { _scumm->_imuse->stopSound(a); } else if (_scumm->_playerV2) { _scumm->_playerV2->stopSound (a); - } else if ((_scumm->_features & GF_AMIGA) && (_scumm->_version <= 3)) { - // this handles stopping looped sounds for now - _scumm->_mixer->stopID(a); + } else if (_scumm->_playerV3A) { + _scumm->_playerV3A->stopSound(a); } for (i = 0; i < 10; i++) @@ -790,6 +784,8 @@ void Sound::stopAllSounds() { _scumm->_imuse->clear_queue(); } else if (_scumm->_playerV2) { _scumm->_playerV2->stopAllSounds(); + } else if (_scumm->_playerV3A) { + _scumm->_playerV3A->stopAllSounds(); } clearSoundQue();