2003-12-16 02:10:15 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2004-01-06 12:45:34 +00:00
|
|
|
* Copyright (C) 2003-2004 The ScummVM project
|
2003-12-16 02:10:15 +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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
2004-10-21 12:43:49 +00:00
|
|
|
#include "sword1/sound.h"
|
2003-12-16 02:10:15 +00:00
|
|
|
#include "common/util.h"
|
2004-10-21 12:43:49 +00:00
|
|
|
#include "sword1/resman.h"
|
|
|
|
#include "sword1/logic.h"
|
|
|
|
#include "sword1/sword1.h"
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2004-11-27 15:58:18 +00:00
|
|
|
#include "sound/mp3.h"
|
|
|
|
#include "sound/vorbis.h"
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
namespace Sword1 {
|
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
#define SOUND_SPEECH_ID 1
|
|
|
|
#define SPEECH_FLAGS (SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_LITTLE_ENDIAN)
|
|
|
|
|
2004-10-12 15:50:00 +00:00
|
|
|
Sound::Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan) {
|
2003-12-16 02:10:15 +00:00
|
|
|
strcpy(_filePath, searchPath);
|
|
|
|
_mixer = mixer;
|
|
|
|
_resMan = pResMan;
|
|
|
|
_cowHeader = NULL;
|
|
|
|
_endOfQueue = 0;
|
2003-12-20 20:20:53 +00:00
|
|
|
_currentCowFile = 0;
|
2004-01-07 17:47:46 +00:00
|
|
|
_speechVolL = _speechVolR = _sfxVolL = _sfxVolR = 192;
|
2003-12-16 02:10:15 +00:00
|
|
|
}
|
|
|
|
|
2004-11-09 04:06:10 +00:00
|
|
|
Sound::~Sound(void) {
|
|
|
|
// clean up fx queue
|
|
|
|
_mixer->stopAll();
|
|
|
|
for (uint8 cnt = 0; cnt < _endOfQueue; cnt++)
|
|
|
|
if (_fxQueue[cnt].delay == 0)
|
|
|
|
_resMan->resClose(_fxList[_fxQueue[cnt].id].sampleId);
|
|
|
|
_endOfQueue = 0;
|
|
|
|
closeCowSystem();
|
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
int Sound::addToQueue(int32 fxNo) {
|
2003-12-16 02:10:15 +00:00
|
|
|
bool alreadyInQueue = false;
|
|
|
|
for (uint8 cnt = 0; (cnt < _endOfQueue) && (!alreadyInQueue); cnt++)
|
2003-12-16 09:43:08 +00:00
|
|
|
if (_fxQueue[cnt].id == (uint32)fxNo)
|
2003-12-16 02:10:15 +00:00
|
|
|
alreadyInQueue = true;
|
|
|
|
if (!alreadyInQueue) {
|
2003-12-17 05:16:37 +00:00
|
|
|
if (_endOfQueue == MAX_FXQ_LENGTH) {
|
|
|
|
warning("Sound queue overflow");
|
|
|
|
return 0;
|
|
|
|
}
|
2004-11-15 08:23:09 +00:00
|
|
|
if ((fxNo == 168) && (SwordEngine::_systemVars.isDemo)) {
|
|
|
|
// this sound doesn't exist in demo
|
|
|
|
return 0;
|
|
|
|
}
|
2003-12-16 02:10:15 +00:00
|
|
|
_resMan->resOpen(_fxList[fxNo].sampleId);
|
|
|
|
_fxQueue[_endOfQueue].id = fxNo;
|
|
|
|
if (_fxList[fxNo].type == FX_SPOT)
|
|
|
|
_fxQueue[_endOfQueue].delay = _fxList[fxNo].delay + 1;
|
|
|
|
else
|
|
|
|
_fxQueue[_endOfQueue].delay = 1;
|
|
|
|
_endOfQueue++;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
void Sound::engine(void) {
|
2003-12-16 02:10:15 +00:00
|
|
|
// first of all, add any random sfx to the queue...
|
|
|
|
for (uint16 cnt = 0; cnt < TOTAL_FX_PER_ROOM; cnt++) {
|
2004-01-11 15:47:41 +00:00
|
|
|
uint16 fxNo = _roomsFixedFx[Logic::_scriptVars[SCREEN]][cnt];
|
2003-12-16 05:02:34 +00:00
|
|
|
if (fxNo) {
|
2003-12-16 02:10:15 +00:00
|
|
|
if (_fxList[fxNo].type == FX_RANDOM) {
|
|
|
|
if (_rnd.getRandomNumber(_fxList[fxNo].delay) == 0)
|
|
|
|
addToQueue(fxNo);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// now process the queue
|
2003-12-23 00:59:18 +00:00
|
|
|
for (uint8 cnt2 = 0; cnt2 < _endOfQueue; cnt2++) {
|
|
|
|
if (_fxQueue[cnt2].delay > 0) {
|
|
|
|
_fxQueue[cnt2].delay--;
|
|
|
|
if (_fxQueue[cnt2].delay == 0)
|
|
|
|
playSample(&_fxQueue[cnt2]);
|
2003-12-16 02:10:15 +00:00
|
|
|
} else {
|
2003-12-24 00:25:18 +00:00
|
|
|
if (!_fxQueue[cnt2].handle.isActive()) { // sound finished
|
2003-12-23 00:59:18 +00:00
|
|
|
_resMan->resClose(_fxList[_fxQueue[cnt2].id].sampleId);
|
|
|
|
if (cnt2 != _endOfQueue-1)
|
|
|
|
_fxQueue[cnt2] = _fxQueue[_endOfQueue - 1];
|
2003-12-16 02:10:15 +00:00
|
|
|
_endOfQueue--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
void Sound::fnStopFx(int32 fxNo) {
|
2003-12-17 05:16:37 +00:00
|
|
|
_mixer->stopID(fxNo);
|
|
|
|
for (uint8 cnt = 0; cnt < _endOfQueue; cnt++)
|
|
|
|
if (_fxQueue[cnt].id == (uint32)fxNo) {
|
|
|
|
if (!_fxQueue[cnt].delay) // sound was started
|
|
|
|
_resMan->resClose(_fxList[_fxQueue[cnt].id].sampleId);
|
2003-12-19 14:07:12 +00:00
|
|
|
if (cnt != _endOfQueue-1)
|
2003-12-17 05:16:37 +00:00
|
|
|
_fxQueue[cnt] = _fxQueue[_endOfQueue-1];
|
|
|
|
_endOfQueue--;
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
debug(8, "fnStopFx: id not found in queue");
|
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
bool Sound::amISpeaking(void) {
|
2003-12-28 23:24:03 +00:00
|
|
|
_waveVolPos++;
|
2003-12-29 14:04:57 +00:00
|
|
|
return _waveVolume[_waveVolPos - 1];
|
2003-12-16 02:10:15 +00:00
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
bool Sound::speechFinished(void) {
|
2003-12-24 00:25:18 +00:00
|
|
|
return !_speechHandle.isActive();
|
2003-12-16 02:10:15 +00:00
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
void Sound::newScreen(uint32 screen) {
|
2003-12-20 20:20:53 +00:00
|
|
|
if (_currentCowFile != SwordEngine::_systemVars.currentCD) {
|
|
|
|
if (_currentCowFile)
|
|
|
|
closeCowSystem();
|
|
|
|
initCowSystem();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
void Sound::quitScreen(void) {
|
2003-12-17 05:16:37 +00:00
|
|
|
// stop all running SFX
|
|
|
|
while (_endOfQueue)
|
|
|
|
fnStopFx(_fxQueue[0].id);
|
2003-12-16 02:10:15 +00:00
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
void Sound::playSample(QueueElement *elem) {
|
2003-12-19 06:51:32 +00:00
|
|
|
uint8 *sampleData = (uint8*)_resMan->fetchRes(_fxList[elem->id].sampleId);
|
2003-12-16 02:10:15 +00:00
|
|
|
for (uint16 cnt = 0; cnt < MAX_ROOMS_PER_FX; cnt++) {
|
2003-12-19 06:51:32 +00:00
|
|
|
if (_fxList[elem->id].roomVolList[cnt].roomNo) {
|
2004-01-11 15:47:41 +00:00
|
|
|
if ((_fxList[elem->id].roomVolList[cnt].roomNo == (int)Logic::_scriptVars[SCREEN]) ||
|
2003-12-19 06:51:32 +00:00
|
|
|
(_fxList[elem->id].roomVolList[cnt].roomNo == -1)) {
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2004-01-07 17:47:46 +00:00
|
|
|
uint8 volL = (_fxList[elem->id].roomVolList[cnt].leftVol * 10 * _sfxVolL) / 255;
|
|
|
|
uint8 volR = (_fxList[elem->id].roomVolList[cnt].rightVol * 10 * _sfxVolR) / 255;
|
2003-12-16 02:10:15 +00:00
|
|
|
int8 pan = (volR - volL) / 2;
|
|
|
|
uint8 volume = (volR + volL) / 2;
|
|
|
|
uint32 size = READ_LE_UINT32(sampleData + 0x28);
|
|
|
|
uint8 flags;
|
|
|
|
if (READ_LE_UINT16(sampleData + 0x22) == 16)
|
|
|
|
flags = SoundMixer::FLAG_16BITS | SoundMixer::FLAG_LITTLE_ENDIAN;
|
|
|
|
else
|
|
|
|
flags = SoundMixer::FLAG_UNSIGNED;
|
2003-12-28 15:01:44 +00:00
|
|
|
if (READ_LE_UINT16(sampleData + 0x16) == 2)
|
|
|
|
flags |= SoundMixer::FLAG_STEREO;
|
2003-12-19 06:51:32 +00:00
|
|
|
_mixer->playRaw(&elem->handle, sampleData + 0x2C, size, 11025, flags, elem->id, volume, pan);
|
2003-12-16 02:10:15 +00:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
bool Sound::startSpeech(uint16 roomNo, uint16 localNo) {
|
2003-12-16 02:10:15 +00:00
|
|
|
if (_cowHeader == NULL) {
|
2004-01-11 15:47:41 +00:00
|
|
|
warning("Sound::startSpeech: COW file isn't open!");
|
2003-12-16 02:10:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 locIndex = _cowHeader[roomNo] >> 2;
|
|
|
|
uint32 sampleSize = _cowHeader[locIndex + (localNo * 2)];
|
|
|
|
uint32 index = _cowHeader[locIndex + (localNo * 2) - 1];
|
2003-12-21 15:55:55 +00:00
|
|
|
debug(6, "startSpeech(%d, %d): locIndex %d, sampleSize %d, index %d", roomNo, localNo, locIndex, sampleSize, index);
|
2003-12-16 02:10:15 +00:00
|
|
|
if (sampleSize) {
|
2004-01-07 17:47:46 +00:00
|
|
|
uint8 speechVol = (_speechVolR + _speechVolL) / 2;
|
|
|
|
int8 speechPan = (_speechVolR - _speechVolL) / 2;
|
2004-10-13 00:59:27 +00:00
|
|
|
if ((_cowMode == CowWave) || (_cowMode == CowDemo)) {
|
2004-10-12 15:50:00 +00:00
|
|
|
uint32 size;
|
|
|
|
int16 *data = uncompressSpeech(index + _cowHeaderSize, sampleSize, &size);
|
|
|
|
if (data)
|
|
|
|
_mixer->playRaw(&_speechHandle, data, size, 11025, SPEECH_FLAGS, SOUND_SPEECH_ID, speechVol, speechPan);
|
|
|
|
}
|
|
|
|
#ifdef USE_MAD
|
|
|
|
else if (_cowMode == CowMp3) {
|
|
|
|
_cowFile.seek(index);
|
2004-11-28 23:02:28 +00:00
|
|
|
_mixer->playInputStream(&_speechHandle, makeMP3Stream(&_cowFile, sampleSize), false, SOUND_SPEECH_ID, speechVol, speechPan);
|
2004-10-12 15:50:00 +00:00
|
|
|
// with compressed audio, we can't calculate the wave volume.
|
|
|
|
// so default to talking.
|
|
|
|
for (int cnt = 0; cnt < 480; cnt++)
|
|
|
|
_waveVolume[cnt] = true;
|
|
|
|
_waveVolPos = 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef USE_VORBIS
|
|
|
|
else if (_cowMode == CowVorbis) {
|
|
|
|
_cowFile.seek(index);
|
2004-11-28 23:02:28 +00:00
|
|
|
_mixer->playInputStream(&_speechHandle, makeVorbisStream(&_cowFile, sampleSize), false, SOUND_SPEECH_ID, speechVol, speechPan);
|
2004-10-12 15:50:00 +00:00
|
|
|
for (int cnt = 0; cnt < 480; cnt++)
|
|
|
|
_waveVolume[cnt] = true;
|
|
|
|
_waveVolPos = 0;
|
|
|
|
}
|
|
|
|
#endif
|
2003-12-16 02:10:15 +00:00
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
int16 *Sound::uncompressSpeech(uint32 index, uint32 cSize, uint32 *size) {
|
2003-12-21 15:55:55 +00:00
|
|
|
uint8 *fBuf = (uint8*)malloc(cSize);
|
|
|
|
_cowFile.seek(index);
|
|
|
|
_cowFile.read(fBuf, cSize);
|
|
|
|
uint32 headerPos = 0;
|
|
|
|
while ((READ_BE_UINT32(fBuf + headerPos) != 'data') && (headerPos < 100))
|
|
|
|
headerPos++;
|
|
|
|
if (headerPos < 100) {
|
2004-08-31 07:52:47 +00:00
|
|
|
int32 resSize;
|
2004-11-15 02:48:30 +00:00
|
|
|
headerPos += 4; // skip 'data' tag
|
|
|
|
if (_cowMode != CowDemo) {
|
|
|
|
resSize = READ_LE_UINT32(fBuf + headerPos) >> 1;
|
|
|
|
headerPos += 4;
|
|
|
|
} else {
|
|
|
|
// the demo speech files have the uncompressed size embedded
|
|
|
|
// in the compressed stream *sigh*
|
|
|
|
if (READ_LE_UINT16(fBuf + headerPos) == 1) {
|
|
|
|
resSize = READ_LE_UINT16(fBuf + headerPos + 2);
|
|
|
|
resSize |= READ_LE_UINT16(fBuf + headerPos + 6) << 16;
|
|
|
|
resSize >>= 1;
|
|
|
|
} else
|
|
|
|
resSize = READ_LE_UINT32(fBuf + headerPos + 2) >> 1;
|
2004-10-30 10:35:39 +00:00
|
|
|
}
|
2004-11-15 02:48:30 +00:00
|
|
|
assert(!(headerPos & 1));
|
|
|
|
int16 *srcData = (int16*)fBuf;
|
|
|
|
uint32 srcPos = headerPos >> 1;
|
|
|
|
cSize /= 2;
|
|
|
|
uint32 dstPos = 0;
|
|
|
|
/* alloc 200 additional bytes, as the demo sometimes has ASCII junk
|
|
|
|
at the end of the wave data */
|
|
|
|
int16 *dstData = (int16*)malloc(resSize * 2 + 200);
|
2003-12-21 15:55:55 +00:00
|
|
|
while (srcPos < cSize) {
|
|
|
|
int16 length = (int16)READ_LE_UINT16(srcData + srcPos);
|
|
|
|
srcPos++;
|
|
|
|
if (length < 0) {
|
|
|
|
length = -length;
|
|
|
|
for (uint16 cnt = 0; cnt < (uint16)length; cnt++)
|
2004-10-30 10:35:39 +00:00
|
|
|
dstData[dstPos++] = srcData[srcPos];
|
2003-12-21 15:55:55 +00:00
|
|
|
srcPos++;
|
|
|
|
} else {
|
2004-10-30 10:35:39 +00:00
|
|
|
memcpy(dstData + dstPos, srcData + srcPos, length * 2);
|
2003-12-21 15:55:55 +00:00
|
|
|
dstPos += length;
|
|
|
|
srcPos += length;
|
|
|
|
}
|
2003-12-16 02:10:15 +00:00
|
|
|
}
|
2004-11-15 02:48:30 +00:00
|
|
|
assert(dstPos < (uint32)resSize + 100);
|
|
|
|
if (_cowMode == CowDemo) // demo has wave output size embedded in the compressed data
|
|
|
|
*(uint32*)dstData = 0;
|
2003-12-21 15:55:55 +00:00
|
|
|
free(fBuf);
|
|
|
|
*size = resSize * 2;
|
2003-12-28 23:24:03 +00:00
|
|
|
calcWaveVolume(dstData, resSize);
|
2003-12-21 15:55:55 +00:00
|
|
|
return dstData;
|
|
|
|
} else {
|
|
|
|
free(fBuf);
|
2004-01-11 15:47:41 +00:00
|
|
|
warning("Sound::uncompressSpeech(): DATA tag not found in wave header");
|
2003-12-21 15:55:55 +00:00
|
|
|
*size = 0;
|
|
|
|
return NULL;
|
2003-12-16 02:10:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
void Sound::calcWaveVolume(int16 *data, uint32 length) {
|
2003-12-28 23:24:03 +00:00
|
|
|
int16 *blkPos = data + 918;
|
2004-01-17 11:16:38 +00:00
|
|
|
uint32 cnt;
|
|
|
|
for (cnt = 0; cnt < WAVE_VOL_TAB_LENGTH; cnt++)
|
2003-12-28 23:24:03 +00:00
|
|
|
_waveVolume[cnt] = false;
|
|
|
|
_waveVolPos = 0;
|
|
|
|
for (uint32 blkCnt = 1; blkCnt < length / 918; blkCnt++) {
|
|
|
|
if (blkCnt >= WAVE_VOL_TAB_LENGTH) {
|
|
|
|
warning("Wave vol tab too small.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int32 average = 0;
|
2004-01-17 11:16:38 +00:00
|
|
|
for (cnt = 0; cnt < 918; cnt++)
|
2003-12-28 23:24:03 +00:00
|
|
|
average += blkPos[cnt];
|
2003-12-29 14:04:57 +00:00
|
|
|
average /= 918;
|
2003-12-28 23:24:03 +00:00
|
|
|
uint32 diff = 0;
|
2004-01-17 11:16:38 +00:00
|
|
|
for (cnt = 0; cnt < 918; cnt++) {
|
2003-12-28 23:24:03 +00:00
|
|
|
int16 smpDiff = *blkPos - average;
|
|
|
|
diff += (uint32)ABS(smpDiff);
|
|
|
|
blkPos++;
|
|
|
|
}
|
|
|
|
if (diff > WAVE_VOL_THRESHOLD)
|
|
|
|
_waveVolume[blkCnt - 1] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
void Sound::stopSpeech(void) {
|
2003-12-16 02:10:15 +00:00
|
|
|
_mixer->stopID(SOUND_SPEECH_ID);
|
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
void Sound::initCowSystem(void) {
|
2003-12-20 20:20:53 +00:00
|
|
|
char cowName[25];
|
2003-12-26 03:07:01 +00:00
|
|
|
/* look for speech1/2.clu in the data dir
|
|
|
|
and speech/speech.clu (running from cd or using cd layout)
|
|
|
|
*/
|
2004-10-12 15:50:00 +00:00
|
|
|
#ifdef USE_MAD
|
|
|
|
sprintf(cowName, "SPEECH%d.CL3", SwordEngine::_systemVars.currentCD);
|
2003-12-20 20:20:53 +00:00
|
|
|
_cowFile.open(cowName);
|
2004-10-12 15:50:00 +00:00
|
|
|
if (_cowFile.isOpen()) {
|
|
|
|
debug(1, "Using MP3 compressed Speech Cluster");
|
|
|
|
_cowMode = CowMp3;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef USE_VORBIS
|
|
|
|
if (!_cowFile.isOpen()) {
|
|
|
|
sprintf(cowName, "SPEECH%d.CLV", SwordEngine::_systemVars.currentCD);
|
|
|
|
_cowFile.open(cowName);
|
|
|
|
if (_cowFile.isOpen()) {
|
|
|
|
debug(1, "Using Vorbis compressed Speech Cluster");
|
|
|
|
_cowMode = CowVorbis;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (!_cowFile.isOpen()) {
|
|
|
|
sprintf(cowName, "SPEECH%d.CLU", SwordEngine::_systemVars.currentCD);
|
|
|
|
_cowFile.open(cowName);
|
|
|
|
if (!_cowFile.isOpen()) {
|
|
|
|
_cowFile.open("speech.clu");
|
|
|
|
}
|
|
|
|
debug(1, "Using uncompressed Speech Cluster");
|
|
|
|
_cowMode = CowWave;
|
|
|
|
}
|
2004-07-27 03:47:56 +00:00
|
|
|
if (!_cowFile.isOpen())
|
2004-01-06 12:28:24 +00:00
|
|
|
_cowFile.open("speech.clu");
|
2004-10-12 15:50:00 +00:00
|
|
|
if (!_cowFile.isOpen()) {
|
|
|
|
_cowFile.open("cows.mad");
|
|
|
|
if (_cowFile.isOpen())
|
|
|
|
_cowMode = CowDemo;
|
|
|
|
}
|
2003-12-16 02:10:15 +00:00
|
|
|
if (_cowFile.isOpen()) {
|
|
|
|
_cowHeaderSize = _cowFile.readUint32LE();
|
|
|
|
_cowHeader = (uint32*)malloc(_cowHeaderSize);
|
|
|
|
if (_cowHeaderSize & 3)
|
|
|
|
error("Unexpected cow header size %d", _cowHeaderSize);
|
|
|
|
for (uint32 cnt = 0; cnt < (_cowHeaderSize / 4) - 1; cnt++)
|
|
|
|
_cowHeader[cnt] = _cowFile.readUint32LE();
|
2003-12-20 20:20:53 +00:00
|
|
|
_currentCowFile = SwordEngine::_systemVars.currentCD;
|
2003-12-16 02:10:15 +00:00
|
|
|
} else
|
2004-01-11 15:47:41 +00:00
|
|
|
warning("Sound::initCowSystem: Can't open SPEECH%d.CLU", SwordEngine::_systemVars.currentCD);
|
2003-12-20 20:20:53 +00:00
|
|
|
}
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
void Sound::closeCowSystem(void) {
|
2003-12-20 20:20:53 +00:00
|
|
|
if (_cowFile.isOpen())
|
|
|
|
_cowFile.close();
|
|
|
|
if (_cowHeader)
|
|
|
|
free(_cowHeader);
|
|
|
|
_cowHeader = NULL;
|
2003-12-21 17:16:07 +00:00
|
|
|
_currentCowFile = 0;
|
2003-12-16 02:10:15 +00:00
|
|
|
}
|
2003-12-20 20:20:53 +00:00
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
} // End of namespace Sword1
|