2003-10-21 12:29:37 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2003-2006 The ScummVM project
|
2003-10-21 12:29:37 +00:00
|
|
|
*
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-10-21 12:29:37 +00:00
|
|
|
*
|
2006-02-11 10:07:12 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2003-10-21 12:29:37 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-06-24 15:23:51 +00:00
|
|
|
#include "common/stdafx.h"
|
2007-02-21 20:27:48 +00:00
|
|
|
#include "common/config-manager.h"
|
2006-03-29 15:59:37 +00:00
|
|
|
#include "common/endian.h"
|
2007-02-21 20:27:48 +00:00
|
|
|
#include "common/stream.h"
|
2006-03-29 15:59:37 +00:00
|
|
|
|
2003-12-01 20:48:41 +00:00
|
|
|
#include "queen/sound.h"
|
2003-10-23 06:44:35 +00:00
|
|
|
#include "queen/input.h"
|
2007-02-21 20:27:48 +00:00
|
|
|
#include "queen/logic.h"
|
2003-12-14 00:33:21 +00:00
|
|
|
#include "queen/music.h"
|
2003-12-11 22:16:35 +00:00
|
|
|
#include "queen/queen.h"
|
2003-10-21 12:29:37 +00:00
|
|
|
#include "queen/resource.h"
|
|
|
|
|
2004-11-27 15:58:18 +00:00
|
|
|
#include "sound/flac.h"
|
2007-02-21 20:27:48 +00:00
|
|
|
#include "sound/mididrv.h"
|
2004-11-27 15:58:18 +00:00
|
|
|
#include "sound/mp3.h"
|
|
|
|
#include "sound/vorbis.h"
|
|
|
|
|
2006-11-23 22:10:25 +00:00
|
|
|
#define SB_HEADER_SIZE_V104 110
|
|
|
|
#define SB_HEADER_SIZE_V110 122
|
2003-10-21 12:29:37 +00:00
|
|
|
|
|
|
|
namespace Queen {
|
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
class SilentSound : public PCSound {
|
2007-02-20 19:23:07 +00:00
|
|
|
public:
|
2007-02-21 20:27:48 +00:00
|
|
|
SilentSound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {}
|
2007-02-20 19:23:07 +00:00
|
|
|
protected:
|
|
|
|
void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
|
|
|
|
// Do nothing
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
class SBSound : public PCSound {
|
2007-02-20 19:23:07 +00:00
|
|
|
public:
|
2007-02-21 20:27:48 +00:00
|
|
|
SBSound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {}
|
2007-02-20 19:23:07 +00:00
|
|
|
protected:
|
|
|
|
void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle);
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef USE_MAD
|
2007-02-21 20:27:48 +00:00
|
|
|
class MP3Sound : public PCSound {
|
2007-02-20 19:23:07 +00:00
|
|
|
public:
|
2007-02-21 20:27:48 +00:00
|
|
|
MP3Sound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {}
|
2007-02-20 19:23:07 +00:00
|
|
|
protected:
|
|
|
|
void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
|
|
|
|
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeMP3Stream(f, size));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_VORBIS
|
2007-02-21 20:27:48 +00:00
|
|
|
class OGGSound : public PCSound {
|
2007-02-20 19:23:07 +00:00
|
|
|
public:
|
2007-02-21 20:27:48 +00:00
|
|
|
OGGSound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {}
|
2007-02-20 19:23:07 +00:00
|
|
|
protected:
|
|
|
|
void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
|
|
|
|
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeVorbisStream(f, size));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_FLAC
|
2007-02-21 20:27:48 +00:00
|
|
|
class FLACSound : public PCSound {
|
2007-02-20 19:23:07 +00:00
|
|
|
public:
|
2007-02-21 20:27:48 +00:00
|
|
|
FLACSound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {};
|
2007-02-20 19:23:07 +00:00
|
|
|
protected:
|
|
|
|
void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
|
|
|
|
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeFlacStream(f, size));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif // #ifdef USE_FLAC
|
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
Sound::Sound(Audio::Mixer *mixer, QueenEngine *vm) :
|
2007-02-21 20:27:48 +00:00
|
|
|
_mixer(mixer), _vm(vm), _sfxToggle(true), _speechToggle(true), _musicToggle(true),
|
|
|
|
_speechSfxExists(false), _lastOverride(0), _masterVolume(0) {
|
2003-10-21 12:29:37 +00:00
|
|
|
}
|
|
|
|
|
2007-02-20 19:23:07 +00:00
|
|
|
Sound *Sound::makeSoundInstance(Audio::Mixer *mixer, QueenEngine *vm, uint8 compression) {
|
2007-02-21 20:27:48 +00:00
|
|
|
if (vm->resource()->getPlatform() == Common::kPlatformAmiga)
|
|
|
|
return new AmigaSound(mixer, vm);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-04-07 08:57:40 +00:00
|
|
|
switch (compression) {
|
|
|
|
case COMPRESSION_NONE:
|
|
|
|
return new SBSound(mixer, vm);
|
|
|
|
case COMPRESSION_MP3:
|
|
|
|
#ifndef USE_MAD
|
|
|
|
warning("Using MP3 compressed datafile, but MP3 support not compiled in");
|
|
|
|
return new SilentSound(mixer, vm);
|
|
|
|
#else
|
|
|
|
return new MP3Sound(mixer, vm);
|
|
|
|
#endif
|
|
|
|
case COMPRESSION_OGG:
|
2005-08-10 12:42:56 +00:00
|
|
|
#ifndef USE_VORBIS
|
2005-04-07 08:57:40 +00:00
|
|
|
warning("Using OGG compressed datafile, but OGG support not compiled in");
|
|
|
|
return new SilentSound(mixer, vm);
|
|
|
|
#else
|
|
|
|
return new OGGSound(mixer, vm);
|
|
|
|
#endif
|
|
|
|
case COMPRESSION_FLAC:
|
|
|
|
#ifndef USE_FLAC
|
|
|
|
warning("Using FLAC compressed datafile, but FLAC support not compiled in");
|
|
|
|
return new SilentSound(mixer, vm);
|
|
|
|
#else
|
|
|
|
return new FLACSound(mixer, vm);
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
warning("Unknown compression type");
|
|
|
|
return new SilentSound(mixer, vm);
|
2003-10-21 12:29:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
void Sound::saveState(byte *&ptr) {
|
|
|
|
WRITE_BE_UINT16(ptr, _lastOverride); ptr += 2;
|
2006-11-24 18:37:43 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
void Sound::loadState(uint32 ver, byte *&ptr) {
|
|
|
|
_lastOverride = (int16)READ_BE_INT16(ptr); ptr += 2;
|
2003-12-20 16:54:46 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
PCSound::PCSound(Audio::Mixer *mixer, QueenEngine *vm)
|
|
|
|
: Sound(mixer, vm) {
|
2007-02-18 21:46:40 +00:00
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
|
|
|
|
bool native_mt32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32"));
|
2007-02-18 21:46:40 +00:00
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
MidiDriver *driver = MidiDriver::createMidi(midiDriver);
|
|
|
|
if (native_mt32)
|
|
|
|
driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
|
2007-02-18 21:46:40 +00:00
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
_music = new Music(driver, vm);
|
|
|
|
_music->hasNativeMT32(native_mt32);
|
|
|
|
}
|
2007-02-18 21:46:40 +00:00
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
PCSound::~PCSound() {
|
|
|
|
delete _music;
|
2007-02-18 21:46:40 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
void PCSound::playSfx(uint16 sfx) {
|
|
|
|
if (sfxOn() && sfx != 0) {
|
|
|
|
#ifndef PALMOS_68K
|
|
|
|
playSound(_sfxName[sfx - 1], false);
|
2007-02-18 21:46:40 +00:00
|
|
|
#else
|
2007-02-21 20:27:48 +00:00
|
|
|
playSound(_sfxName + 10 * (sfx - 1), false); // saved as 8char + /0/0
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2007-02-18 21:46:40 +00:00
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
void PCSound::playSong(int16 songNum) {
|
2003-12-28 01:47:37 +00:00
|
|
|
if (songNum <= 0) {
|
2007-02-21 20:27:48 +00:00
|
|
|
_music->stopSong();
|
2003-12-14 00:33:21 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-01-25 05:03:35 +00:00
|
|
|
int16 newTune;
|
|
|
|
if (_vm->resource()->isDemo()) {
|
2004-01-25 16:57:05 +00:00
|
|
|
if (songNum == 17) {
|
2007-02-21 20:27:48 +00:00
|
|
|
_music->stopSong();
|
2004-01-25 16:57:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2004-01-25 05:03:35 +00:00
|
|
|
newTune = _songDemo[songNum - 1].tuneList[0] - 1;
|
|
|
|
} else {
|
|
|
|
newTune = _song[songNum - 1].tuneList[0] - 1;
|
|
|
|
}
|
2003-11-07 02:33:20 +00:00
|
|
|
|
2004-01-04 03:37:12 +00:00
|
|
|
if (_tune[newTune].sfx[0]) {
|
2006-11-24 18:37:43 +00:00
|
|
|
playSfx(_tune[newTune].sfx[0]);
|
2003-12-14 00:33:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-01-25 05:03:35 +00:00
|
|
|
if (!musicOn())
|
2003-12-14 04:07:22 +00:00
|
|
|
return;
|
|
|
|
|
2004-01-25 05:03:35 +00:00
|
|
|
int override = (_vm->resource()->isDemo()) ? _songDemo[songNum - 1].override : _song[songNum - 1].override;
|
|
|
|
switch (override) {
|
2005-04-07 08:57:40 +00:00
|
|
|
// Override all songs
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
// Alter song settings (such as volume) and exit
|
|
|
|
case 2:
|
2007-02-21 20:27:48 +00:00
|
|
|
_music->toggleVChange();
|
2005-04-07 08:57:40 +00:00
|
|
|
default:
|
|
|
|
return;
|
2004-01-04 03:37:12 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-12-28 01:17:29 +00:00
|
|
|
_lastOverride = songNum;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
_music->queueTuneList(newTune);
|
|
|
|
_music->playMusic();
|
2003-11-07 02:33:20 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
void PCSound::stopSong() {
|
|
|
|
_music->stopSong();
|
|
|
|
}
|
2007-02-18 21:46:40 +00:00
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
void PCSound::playSpeech(const char *base) {
|
|
|
|
if (speechOn()) {
|
|
|
|
playSound(base, true);
|
|
|
|
}
|
2004-01-12 13:40:02 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
void PCSound::setVolume(int vol) {
|
|
|
|
_music->setVolume(vol);
|
|
|
|
}
|
|
|
|
|
|
|
|
int PCSound::volume() {
|
|
|
|
return _music->volume();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCSound::waitFinished(bool isSpeech) {
|
|
|
|
while (_mixer->isSoundHandleActive(isSpeech ? _speechHandle : _sfxHandle))
|
|
|
|
_vm->input()->delay(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCSound::playSound(const char *base, bool isSpeech) {
|
|
|
|
char name[13];
|
|
|
|
strcpy(name, base);
|
|
|
|
// alter filename to add zeros and append ".SB"
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
if (name[i] == ' ')
|
|
|
|
name[i] = '0';
|
|
|
|
}
|
|
|
|
strcat(name, ".SB");
|
|
|
|
waitFinished(isSpeech);
|
|
|
|
uint32 size;
|
|
|
|
Common::File *f = _vm->resource()->findSound(name, &size);
|
|
|
|
if (f) {
|
|
|
|
playSoundData(f, size, isSpeech ? &_speechHandle : &_sfxHandle);
|
|
|
|
_speechSfxExists = isSpeech;
|
|
|
|
} else {
|
|
|
|
_speechSfxExists = false;
|
|
|
|
}
|
2004-01-12 13:40:02 +00:00
|
|
|
}
|
|
|
|
|
2006-11-24 18:37:43 +00:00
|
|
|
void SBSound::playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
|
|
|
|
int headerSize;
|
|
|
|
f->seek(2, SEEK_CUR);
|
|
|
|
uint16 version = f->readUint16LE();
|
|
|
|
switch (version) {
|
|
|
|
case 104:
|
|
|
|
headerSize = SB_HEADER_SIZE_V104;
|
|
|
|
break;
|
|
|
|
case 110:
|
|
|
|
headerSize = SB_HEADER_SIZE_V110;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
warning("Unhandled SB file version %d, defaulting to 104\n", version);
|
|
|
|
headerSize = SB_HEADER_SIZE_V104;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
f->seek(headerSize - 4, SEEK_CUR);
|
|
|
|
size -= headerSize;
|
|
|
|
uint8 *sound = (uint8 *)malloc(size);
|
|
|
|
if (sound) {
|
|
|
|
f->read(sound, size);
|
|
|
|
byte flags = Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE;
|
2007-02-03 19:05:53 +00:00
|
|
|
_mixer->playRaw(Audio::Mixer::kSFXSoundType, soundHandle, sound, size, 11025, flags);
|
2005-11-07 18:34:55 +00:00
|
|
|
}
|
2003-10-21 12:29:37 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
AmigaSound::AmigaSound(Audio::Mixer *mixer, QueenEngine *vm)
|
|
|
|
: Sound(mixer, vm), _fanfareRestore(0), _fanfareCount(0), _fluteCount(0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void AmigaSound::playSfx(uint16 sfx) {
|
|
|
|
if (_vm->logic()->currentRoom() == 111) {
|
|
|
|
// lightning sound
|
|
|
|
playSound("88SSSSSS");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AmigaSound::playSong(int16 song) {
|
|
|
|
debug(2, "Sound::playSong %d override %d", song, _lastOverride);
|
|
|
|
|
2007-02-25 19:01:59 +00:00
|
|
|
if (song < 0) {
|
|
|
|
stopSong();
|
|
|
|
return;
|
|
|
|
}
|
2007-02-22 12:25:30 +00:00
|
|
|
|
2007-02-25 19:01:59 +00:00
|
|
|
// remap song numbers for the Amiga
|
2007-02-22 12:25:30 +00:00
|
|
|
switch (song) {
|
2007-02-21 20:27:48 +00:00
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
song = 39;
|
|
|
|
break;
|
|
|
|
case 37:
|
|
|
|
case 52:
|
|
|
|
case 196:
|
|
|
|
song = 90;
|
|
|
|
break;
|
|
|
|
case 38:
|
|
|
|
case 89:
|
|
|
|
song = 3;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
case 158:
|
|
|
|
song = 117;
|
|
|
|
break;
|
|
|
|
case 71:
|
|
|
|
case 72:
|
|
|
|
case 73:
|
|
|
|
case 75:
|
|
|
|
song = 133;
|
|
|
|
break;
|
|
|
|
case 203:
|
|
|
|
song = 67;
|
|
|
|
break;
|
|
|
|
case 145:
|
|
|
|
song = 140;
|
|
|
|
break;
|
2007-02-22 12:25:30 +00:00
|
|
|
case 53:
|
|
|
|
case 204:
|
|
|
|
song = 44;
|
|
|
|
break;
|
|
|
|
case 136:
|
|
|
|
case 142:
|
|
|
|
case 179:
|
|
|
|
song = 86;
|
|
|
|
break;
|
|
|
|
case 101:
|
|
|
|
case 102:
|
|
|
|
case 143:
|
|
|
|
song = 188;
|
|
|
|
break;
|
|
|
|
case 65:
|
|
|
|
case 62:
|
|
|
|
song = 69;
|
|
|
|
break;
|
|
|
|
case 118:
|
|
|
|
case 119:
|
|
|
|
song = 137;
|
|
|
|
break;
|
|
|
|
case 130:
|
|
|
|
case 131:
|
|
|
|
song = 59;
|
|
|
|
break;
|
|
|
|
case 174:
|
|
|
|
case 175:
|
|
|
|
song = 57;
|
|
|
|
break;
|
|
|
|
case 171:
|
|
|
|
case 121:
|
|
|
|
song = 137;
|
|
|
|
break;
|
|
|
|
case 138:
|
|
|
|
case 170:
|
|
|
|
case 149:
|
|
|
|
song = 28;
|
|
|
|
break;
|
|
|
|
case 122:
|
|
|
|
case 180:
|
|
|
|
case 83:
|
|
|
|
case 98:
|
|
|
|
song = 83;
|
|
|
|
break;
|
|
|
|
case 20:
|
|
|
|
case 33:
|
|
|
|
song = 34;
|
|
|
|
break;
|
|
|
|
case 29:
|
|
|
|
case 35:
|
|
|
|
song = 36;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
case 9:
|
|
|
|
case 10:
|
|
|
|
song = 11;
|
|
|
|
break;
|
|
|
|
case 110:
|
|
|
|
song = 94;
|
|
|
|
break;
|
|
|
|
case 111:
|
|
|
|
song = 95;
|
|
|
|
break;
|
|
|
|
case 30:
|
|
|
|
song = 43;
|
|
|
|
break;
|
|
|
|
case 76:
|
|
|
|
song = 27;
|
|
|
|
break;
|
|
|
|
case 194:
|
|
|
|
case 195:
|
|
|
|
song = 32;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_lastOverride != 32 && _lastOverride != 44) {
|
|
|
|
if (playSpecialSfx(song)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_lastOverride == song && _mixer->isSoundHandleActive(_modHandle)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (song) {
|
|
|
|
// hotel
|
2007-02-21 20:27:48 +00:00
|
|
|
case 39:
|
2007-02-22 12:25:30 +00:00
|
|
|
playModule("HOTEL", 1);
|
|
|
|
break;
|
|
|
|
case 19:
|
|
|
|
playModule("HOTEL", 3);
|
|
|
|
break;
|
|
|
|
case 34:
|
|
|
|
playModule("HOTEL", 2);
|
|
|
|
break;
|
|
|
|
case 36:
|
|
|
|
playModule("HOTEL", 4);
|
2007-02-21 20:27:48 +00:00
|
|
|
_fanfareRestore = _lastOverride;
|
2007-02-22 12:25:30 +00:00
|
|
|
_fanfareCount = 60;
|
|
|
|
break;
|
2007-02-21 20:27:48 +00:00
|
|
|
// jungle
|
|
|
|
case 40:
|
|
|
|
playModule("JUNG", 1);
|
|
|
|
_fanfareRestore = _lastOverride;
|
|
|
|
_fanfareCount = 80;
|
|
|
|
_fluteCount = 100;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
playModule("JUNG", 2);
|
|
|
|
_fluteCount = 100;
|
|
|
|
break;
|
|
|
|
// temple
|
|
|
|
case 54:
|
2007-02-22 12:25:30 +00:00
|
|
|
playModule("TEMPLE", 1);
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
playModule("TEMPLE", 2);
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
playModule("TEMPLE", 3);
|
|
|
|
break;
|
|
|
|
case 31:
|
|
|
|
playModule("TEMPLE", 4);
|
|
|
|
_fanfareRestore = _lastOverride;
|
|
|
|
_fanfareCount = 80;
|
|
|
|
break;
|
2007-02-21 20:27:48 +00:00
|
|
|
// floda
|
2007-02-22 12:25:30 +00:00
|
|
|
case 41:
|
|
|
|
playModule("FLODA", 4);
|
2007-02-21 20:27:48 +00:00
|
|
|
_fanfareRestore = _lastOverride;
|
2007-02-22 12:25:30 +00:00
|
|
|
_fanfareCount = 60;
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
playModule("FLODA", 3);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
playModule("FLODA", 1);
|
|
|
|
break;
|
|
|
|
case 17:
|
|
|
|
playModule("FLODA", 2);
|
|
|
|
break;
|
|
|
|
case 43:
|
|
|
|
playModule("FLODA", 5);
|
|
|
|
break;
|
2007-02-21 20:27:48 +00:00
|
|
|
// end credits
|
2007-02-22 12:25:30 +00:00
|
|
|
case 67:
|
|
|
|
playModule("TITLE", 1);
|
|
|
|
break;
|
|
|
|
// intro credits
|
|
|
|
case 88:
|
|
|
|
playModule("TITLE", 1);
|
|
|
|
break;
|
|
|
|
// valley
|
|
|
|
case 90:
|
|
|
|
playModule("AWESTRUK", 1);
|
|
|
|
break;
|
|
|
|
// confrontation
|
|
|
|
case 91:
|
|
|
|
playModule("'JUNGLE'", 1);
|
|
|
|
break;
|
|
|
|
// Frank
|
|
|
|
case 46:
|
|
|
|
playModule("FRANK", 1);
|
|
|
|
break;
|
|
|
|
// trader bob
|
|
|
|
case 6:
|
|
|
|
playModule("BOB", 1);
|
|
|
|
break;
|
|
|
|
// azura
|
|
|
|
case 44:
|
|
|
|
playModule("AZURA", 1);
|
|
|
|
break;
|
|
|
|
// amazon fortress
|
|
|
|
case 21:
|
|
|
|
playModule("FORT", 1);
|
|
|
|
break;
|
|
|
|
// rocket
|
|
|
|
case 32:
|
|
|
|
playModule("ROCKET", 1);
|
|
|
|
break;
|
|
|
|
// robot
|
|
|
|
case 92:
|
|
|
|
playModule("ROBOT", 1);
|
|
|
|
break;
|
2007-02-21 20:27:48 +00:00
|
|
|
default:
|
|
|
|
// song not available in the amiga version
|
|
|
|
return;
|
2007-02-22 12:25:30 +00:00
|
|
|
}
|
2007-02-21 20:27:48 +00:00
|
|
|
_lastOverride = song;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AmigaSound::stopSfx() {
|
|
|
|
_mixer->stopHandle(_sfxHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AmigaSound::stopSong() {
|
|
|
|
_mixer->stopHandle(_modHandle);
|
|
|
|
_fanfareCount = _fluteCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AmigaSound::updateMusic() {
|
|
|
|
if (_fanfareCount > 0) {
|
|
|
|
--_fanfareCount;
|
|
|
|
if (_fanfareCount == 0) {
|
|
|
|
playSong(_fanfareRestore);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_fluteCount > 0 && (_lastOverride == 40 || _lastOverride == 3)) {
|
|
|
|
--_fluteCount;
|
|
|
|
if (_fluteCount == 0) {
|
2007-02-25 19:01:59 +00:00
|
|
|
playRandomPatternJungle();
|
2007-02-21 20:27:48 +00:00
|
|
|
_fluteCount = 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AmigaSound::playSound(const char *base) {
|
2007-02-22 12:12:45 +00:00
|
|
|
debug(7, "AmigaSound::playSound(%s)", base);
|
2007-02-21 20:27:48 +00:00
|
|
|
char soundName[20];
|
|
|
|
sprintf(soundName, "%s.AMR", base);
|
|
|
|
|
|
|
|
uint32 soundSize;
|
|
|
|
Common::File *f = _vm->resource()->findSound(soundName, &soundSize);
|
|
|
|
if (f) {
|
|
|
|
uint8 *soundData = (uint8 *)malloc(soundSize);
|
|
|
|
if (soundData) {
|
|
|
|
f->read(soundData, soundSize);
|
|
|
|
byte flags = Audio::Mixer::FLAG_AUTOFREE;
|
|
|
|
_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_sfxHandle, soundData, soundSize, 11025, flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AmigaSound::playModule(const char *base, int song) {
|
2007-02-22 12:12:45 +00:00
|
|
|
debug(7, "AmigaSound::playModule(%s, %d)", base, song);
|
2007-02-21 20:27:48 +00:00
|
|
|
char name[20];
|
|
|
|
|
|
|
|
// load song/pattern data
|
|
|
|
uint32 sngDataSize;
|
|
|
|
sprintf(name, "%s.SNG", base);
|
|
|
|
uint8 *sngData = _vm->resource()->loadFile(name, 0, &sngDataSize);
|
|
|
|
Common::MemoryReadStream sngStr(sngData, sngDataSize);
|
|
|
|
|
|
|
|
// load instruments/wave data
|
|
|
|
uint32 insDataSize;
|
|
|
|
sprintf(name, "%s.INS", base);
|
|
|
|
uint8 *insData = _vm->resource()->loadFile(name, 0, &insDataSize);
|
|
|
|
Common::MemoryReadStream insStr(insData, insDataSize);
|
|
|
|
|
|
|
|
_mixer->stopHandle(_modHandle);
|
|
|
|
Audio::AudioStream *stream = Audio::makeRjp1Stream(&sngStr, &insStr, song, _mixer->getOutputRate());
|
|
|
|
if (stream) {
|
|
|
|
_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_modHandle, stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] sngData;
|
|
|
|
delete[] insData;
|
|
|
|
|
|
|
|
_fanfareCount = 0;
|
|
|
|
}
|
|
|
|
|
2007-02-25 19:01:59 +00:00
|
|
|
void AmigaSound::playRandomPatternJungle() {
|
|
|
|
static const uint16 patOffset[] = { 2, 1416, 2722, 2242, 11046, 11046 };
|
|
|
|
static const uint16 patSize[] = { 1056, 826, 8100, 8580, 15808, 15808 };
|
|
|
|
uint32 soundSize;
|
|
|
|
Common::File *f = _vm->resource()->findSound("JUNG.INS", &soundSize);
|
|
|
|
if (f) {
|
|
|
|
const int i = _rnd.getRandomNumber(5);
|
|
|
|
uint8 *soundData = (uint8 *)malloc(patSize[i]);
|
|
|
|
if (soundData) {
|
|
|
|
f->seek(patOffset[i], SEEK_CUR);
|
|
|
|
f->read(soundData, patSize[i]);
|
|
|
|
byte flags = Audio::Mixer::FLAG_AUTOFREE;
|
|
|
|
_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, soundData, patSize[i], 9000, flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-21 20:27:48 +00:00
|
|
|
bool AmigaSound::playSpecialSfx(int16 sfx) {
|
|
|
|
switch (sfx) {
|
|
|
|
case 5: // normal volume
|
|
|
|
break;
|
|
|
|
case 15: // soft volume
|
|
|
|
break;
|
|
|
|
case 14: // medium volume
|
|
|
|
break;
|
|
|
|
case 25: // open door
|
|
|
|
playSound("116BSSSS");
|
|
|
|
break;
|
|
|
|
case 26: // close door
|
|
|
|
playSound("105ASSSS");
|
|
|
|
break;
|
|
|
|
case 56: // light switch
|
|
|
|
playSound("27SSSSSS");
|
|
|
|
break;
|
|
|
|
case 57: // hydraulic doors open
|
|
|
|
playSound("96SSSSSS");
|
|
|
|
break;
|
|
|
|
case 58: // hydraulic doors close
|
|
|
|
playSound("97SSSSSS");
|
|
|
|
break;
|
|
|
|
case 59: // metallic door slams
|
|
|
|
playSound("105SSSSS");
|
|
|
|
break;
|
|
|
|
case 63: // oracle rezzes in
|
|
|
|
playSound("132SSSSS");
|
|
|
|
break;
|
|
|
|
case 27: // cloth slide 1
|
|
|
|
playSound("135SSSSS");
|
|
|
|
break;
|
|
|
|
case 83: // splash
|
|
|
|
playSound("18SSSSSS");
|
|
|
|
break;
|
|
|
|
case 85: // agression enhancer
|
|
|
|
playSound("138BSSSS");
|
|
|
|
break;
|
|
|
|
case 68: // dino ray
|
|
|
|
playSound("138SSSSS");
|
|
|
|
break;
|
|
|
|
case 140: // dino transformation
|
|
|
|
playSound("55BSSSSS");
|
|
|
|
break;
|
|
|
|
case 141: // experimental laser
|
|
|
|
playSound("55SSSSSS");
|
|
|
|
break;
|
|
|
|
case 94: // plane hatch open
|
|
|
|
playSound("3SSSSSSS");
|
|
|
|
break;
|
|
|
|
case 95: // plane hatch close
|
|
|
|
playSound("4SSSSSSS");
|
|
|
|
break;
|
|
|
|
case 117: // oracle rezzes out
|
|
|
|
playSound("70SSSSSS");
|
|
|
|
break;
|
|
|
|
case 124: // dino horn
|
|
|
|
playSound("103SSSSS");
|
|
|
|
break;
|
|
|
|
case 127: // punch
|
|
|
|
playSound("128SSSSS");
|
|
|
|
break;
|
|
|
|
case 128: // body hits ground
|
|
|
|
playSound("129SSSSS");
|
|
|
|
break;
|
|
|
|
case 137: // explosion
|
|
|
|
playSound("88SSSSSS");
|
|
|
|
break;
|
|
|
|
case 86: // stone door grind 1
|
|
|
|
playSound("1001SSSS");
|
|
|
|
break;
|
|
|
|
case 188: // stone door grind 2
|
|
|
|
playSound("1002SSSS");
|
|
|
|
break;
|
|
|
|
case 28: // cloth slide 2
|
|
|
|
playSound("1005SSSS");
|
|
|
|
break;
|
|
|
|
case 151: // rattle bars
|
|
|
|
playSound("115SSSSS");
|
|
|
|
break;
|
|
|
|
case 152: // door dissolves
|
|
|
|
playSound("56SSSSSS");
|
|
|
|
break;
|
|
|
|
case 153: // altar slides
|
|
|
|
playSound("85SSSSSS");
|
|
|
|
break;
|
|
|
|
case 166 : // pull lever
|
|
|
|
playSound("1008SSSS");
|
|
|
|
break;
|
|
|
|
case 182: // zap Frank
|
|
|
|
playSound("1023SSSS");
|
|
|
|
break;
|
|
|
|
case 69: // splorch
|
|
|
|
playSound("137ASSSS");
|
|
|
|
break;
|
|
|
|
case 70: // robot laser
|
|
|
|
playSound("61SSSSSS");
|
|
|
|
break;
|
|
|
|
case 133: // pick hits stone
|
|
|
|
playSound("71SSSSSS");
|
|
|
|
break;
|
|
|
|
case 165: // press button
|
|
|
|
playSound("1007SSSS");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-10-21 12:29:37 +00:00
|
|
|
} //End of namespace Queen
|