aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorathrxx2012-11-11 03:01:39 +0100
committerathrxx2012-11-11 19:14:31 +0100
commit93e69aa4da0558b05fc235684355ed38eed9863d (patch)
treeb809c595a60ce23e2dcb27ae7d4a9f9fa68d7530 /engines
parent1bb8f22567e71796bba4f98a6ff4353ec84df197 (diff)
downloadscummvm-rg350-93e69aa4da0558b05fc235684355ed38eed9863d.tar.gz
scummvm-rg350-93e69aa4da0558b05fc235684355ed38eed9863d.tar.bz2
scummvm-rg350-93e69aa4da0558b05fc235684355ed38eed9863d.zip
KYRA: clean up audio resource handling
(this was really ugly, now it's somewhat less ugly)
Diffstat (limited to 'engines')
-rw-r--r--engines/kyra/kyra_hof.cpp2
-rw-r--r--engines/kyra/kyra_hof.h3
-rw-r--r--engines/kyra/kyra_lok.cpp8
-rw-r--r--engines/kyra/kyra_lok.h10
-rw-r--r--engines/kyra/kyra_v1.h12
-rw-r--r--engines/kyra/lol.cpp2
-rw-r--r--engines/kyra/lol.h4
-rw-r--r--engines/kyra/saveload_lok.cpp2
-rw-r--r--engines/kyra/sequences_hof.cpp22
-rw-r--r--engines/kyra/sequences_lol.cpp8
-rw-r--r--engines/kyra/sound.cpp23
-rw-r--r--engines/kyra/sound.h62
-rw-r--r--engines/kyra/sound_adlib.cpp27
-rw-r--r--engines/kyra/sound_adlib.h7
-rw-r--r--engines/kyra/sound_amiga.cpp16
-rw-r--r--engines/kyra/sound_intern.h39
-rw-r--r--engines/kyra/sound_midi.cpp28
-rw-r--r--engines/kyra/sound_towns.cpp106
-rw-r--r--engines/kyra/staticres.cpp102
-rw-r--r--engines/kyra/staticres_lol.cpp36
20 files changed, 314 insertions, 205 deletions
diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp
index d8d4f69d18..c53731ec35 100644
--- a/engines/kyra/kyra_hof.cpp
+++ b/engines/kyra/kyra_hof.cpp
@@ -274,7 +274,7 @@ Common::Error KyraEngine_HoF::go() {
}
void KyraEngine_HoF::startup() {
- _sound->setSoundList(&_soundData[kMusicIngame]);
+ _sound->selectAudioResourceSet(kMusicIngame);
// The track map is exactly the same
// for FM-TOWNS and DOS
_trackMap = _dosTrackMap;
diff --git a/engines/kyra/kyra_hof.h b/engines/kyra/kyra_hof.h
index 3ee6446436..a9831d0e6c 100644
--- a/engines/kyra/kyra_hof.h
+++ b/engines/kyra/kyra_hof.h
@@ -57,7 +57,6 @@ public:
GUI *gui() const { return _gui; }
virtual TextDisplayer *text() { return _text; }
int language() const { return _lang; }
- const AudioDataStruct *soundData(int index) { return &_soundData[index]; }
protected:
static const EngineDesc _hofEngineDesc;
@@ -87,8 +86,6 @@ protected:
static const int8 _pcSpkSfxMap[];
static const int _pcSpkSfxMapSize;
- AudioDataStruct _soundData[3];
-
protected:
// game initialization
void startup();
diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp
index 27bc2ad22a..7d4e35092f 100644
--- a/engines/kyra/kyra_lok.cpp
+++ b/engines/kyra/kyra_lok.cpp
@@ -98,8 +98,6 @@ KyraEngine_LoK::KyraEngine_LoK(OSystem *system, const GameFlags &flags)
_malcolmFrame = 0;
_malcolmTimer1 = _malcolmTimer2 = 0;
-
- _soundFiles = 0;
}
KyraEngine_LoK::~KyraEngine_LoK() {
@@ -123,8 +121,6 @@ KyraEngine_LoK::~KyraEngine_LoK() {
delete _animator;
delete _seq;
- delete[] _soundFiles;
-
delete[] _characterList;
delete[] _roomTable;
@@ -194,7 +190,7 @@ Common::Error KyraEngine_LoK::init() {
initStaticResource();
- _sound->setSoundList(&_soundData[kMusicIntro]);
+ _sound->selectAudioResourceSet(kMusicIntro);
if (_flags.platform == Common::kPlatformAmiga) {
_trackMap = _amigaTrackMap;
@@ -349,7 +345,7 @@ void KyraEngine_LoK::startup() {
static const uint8 colorMap[] = { 0, 0, 0, 0, 12, 12, 12, 0, 0, 0, 0, 0 };
_screen->setTextColorMap(colorMap);
- _sound->setSoundList(&_soundData[kMusicIngame]);
+ _sound->selectAudioResourceSet(kMusicIngame);
if (_flags.platform == Common::kPlatformPC98)
_sound->loadSoundFile("SE.DAT");
else
diff --git a/engines/kyra/kyra_lok.h b/engines/kyra/kyra_lok.h
index 71177f59e8..7470dd871b 100644
--- a/engines/kyra/kyra_lok.h
+++ b/engines/kyra/kyra_lok.h
@@ -134,8 +134,6 @@ public:
const uint8 * const *palTable1() { return &_specialPalettes[0]; }
const uint8 * const *palTable2() { return &_specialPalettes[29]; }
- const AudioDataStruct *soundData(int index) { return &_soundData[index]; }
-
protected:
virtual Common::Error go();
virtual Common::Error init();
@@ -645,14 +643,6 @@ protected:
const uint8 * const *_specialPalettes;
- const char * const *_soundFiles;
- int _soundFilesSize;
- const char * const *_soundFilesIntro;
- int _soundFilesIntroSize;
- const int32 *_cdaTrackTable;
- int _cdaTrackTableSize;
- AudioDataStruct _soundData[3];
-
// positions of the inventory
static const uint16 _itemPosX[];
static const uint8 _itemPosY[];
diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h
index d91255327f..79903e6f39 100644
--- a/engines/kyra/kyra_v1.h
+++ b/engines/kyra/kyra_v1.h
@@ -140,14 +140,6 @@ enum {
GI_EOB2 = 6
};
-struct AudioDataStruct {
- const char *const *fileList;
- int fileListLen;
- const void *cdaTracks;
- int cdaNumTracks;
- int extraOffset;
-};
-
// TODO: this is just the start of makeing the debug output of the kyra engine a bit more useable
// in the future we maybe merge some flags and/or create new ones
enum DebugLevels {
@@ -164,7 +156,7 @@ enum DebugLevels {
kDebugLevelTimer = 1 << 10 ///< debug level for "TimerManager" functions
};
-enum MusicDataID {
+enum AudioResourceSet {
kMusicIntro = 0,
kMusicIngame,
kMusicFinale
@@ -243,8 +235,6 @@ public:
virtual bool snd_voiceIsPlaying();
virtual void snd_stopVoice();
- virtual const AudioDataStruct *soundData(int index) { return 0; }
-
// delay functionallity
virtual void delayUntil(uint32 timestamp, bool updateGameTimers = false, bool update = false, bool isMainLoop = false);
virtual void delay(uint32 millis, bool update = false, bool isMainLoop = false);
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp
index ed7fe52446..dcfd2b7e10 100644
--- a/engines/kyra/lol.cpp
+++ b/engines/kyra/lol.cpp
@@ -534,7 +534,7 @@ Common::Error LoLEngine::go() {
if (_flags.platform == Common::kPlatformPC98)
_sound->loadSoundFile("sound.dat");
- _sound->setSoundList(&_soundData[kMusicIngame]);
+ _sound->selectAudioResourceSet(kMusicIngame);
if (_flags.platform != Common::kPlatformPC)
_sound->loadSoundFile(0);
diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h
index 06f9e32285..be2d83357d 100644
--- a/engines/kyra/lol.h
+++ b/engines/kyra/lol.h
@@ -275,8 +275,6 @@ public:
Screen *screen();
GUI *gui() const;
- const AudioDataStruct *soundData(int index) { return &_soundData[index]; }
-
private:
Screen_LoL *_screen;
GUI_LoL *_gui;
@@ -472,8 +470,6 @@ private:
const uint8 *_ingamePCSpeakerSoundIndex;
int _ingamePCSpeakerSoundIndexSize;
- AudioDataStruct _soundData[3];
-
// gui
void gui_drawPlayField();
void gui_drawScene(int pageNum);
diff --git a/engines/kyra/saveload_lok.cpp b/engines/kyra/saveload_lok.cpp
index b76d1da52a..f8cca1ab7b 100644
--- a/engines/kyra/saveload_lok.cpp
+++ b/engines/kyra/saveload_lok.cpp
@@ -150,7 +150,7 @@ Common::Error KyraEngine_LoK::loadGameState(int slot) {
// it wasn't made sure that _curSfxFile was initialized
// so if it's out of bounds we just set it to 0.
if (_flags.platform == Common::kPlatformFMTowns) {
- if (_curSfxFile >= _soundData->fileListLen || _curSfxFile < 0)
+ if (!_sound->hasSoundFile(_curSfxFile))
_curSfxFile = 0;
_sound->loadSoundFile(_curSfxFile);
}
diff --git a/engines/kyra/sequences_hof.cpp b/engines/kyra/sequences_hof.cpp
index 7f105bf25a..7b9e91db73 100644
--- a/engines/kyra/sequences_hof.cpp
+++ b/engines/kyra/sequences_hof.cpp
@@ -153,7 +153,7 @@ private:
void closeNestedAnimation(int animSlot);
void unloadNestedAnimation(int animSlot);
void doNestedFrameTransition(int transitionType, int animSlot);
- void updateAllNestedAnimations();
+ void updateAllNestedAnimations();
bool updateNestedAnimation(int animSlot);
struct AnimSlot {
@@ -478,7 +478,7 @@ SeqPlayer_HOF::~SeqPlayer_HOF() {
int SeqPlayer_HOF::play(SequenceID firstScene, SequenceID loopStartScene) {
bool incompatibleData = false;
- MusicDataID soundSet = kMusicIntro;
+ AudioResourceSet soundSet = kMusicIntro;
_firstScene = firstScene;
_loopStartScene = loopStartScene;
_preventLooping = false;
@@ -521,7 +521,7 @@ int SeqPlayer_HOF::play(SequenceID firstScene, SequenceID loopStartScene) {
if (incompatibleData)
error("SeqPlayer_HOF::play(): Specified sequences do not match the available sequence data for this target");
- _vm->sound()->setSoundList(_vm->soundData(soundSet));
+ _vm->sound()->selectAudioResourceSet(soundSet);
_vm->sound()->loadSoundFile(0);
setupCallbacks();
@@ -536,7 +536,7 @@ void SeqPlayer_HOF::pause(bool toggle) {
} else {
uint32 pausedTime = _system->getMillis() - _pauseStart;
_pauseStart = 0;
-
+
_countDownLastUpdate += pausedTime;
_fisherAnimCurTime += pausedTime;
_specialAnimTimeOutTotal += pausedTime;
@@ -702,7 +702,7 @@ void SeqPlayer_HOF::playScenes() {
while (!checkAbortPlayback() && !_vm->shouldQuit() && (countDownRunning() || _updateAnimations)) {
uint32 endFrame = (_system->getMillis() + _vm->tickLength()) & ~(_vm->tickLength() - 1);
updateAllNestedAnimations();
-
+
if (_config->seqProc[_curScene])
(this->*_config->seqProc[_curScene])(0, 0, 0, 0);
@@ -715,7 +715,7 @@ void SeqPlayer_HOF::playScenes() {
do {
if (checkAbortPlayback())
if (checkPlaybackStatus())
- break;
+ break;
} while (_system->getMillis() < endFrame);
}
}
@@ -968,7 +968,7 @@ void SeqPlayer_HOF::playAnimation(WSAMovie_v2 *wsaObj, int startFrame, int lastF
}
int8 frameStep = (startFrame > lastFrame) ? -1 : 1;
- _animCurrentFrame = startFrame;
+ _animCurrentFrame = startFrame;
while (!_vm->shouldQuit() && !finished) {
if (checkAbortPlayback())
@@ -1474,7 +1474,7 @@ void SeqPlayer_HOF::playHoFTalkieCredits() {
const uint8 *talkieCredits = _vm->staticres()->loadRawData(k2SeqplayCredits, talkieCreditsSize);
const char * const *talkieCreditsSpecial = _vm->staticres()->loadStrings(k2SeqplayCreditsSpecial, talkieCreditsSpecialSize);
- _vm->sound()->setSoundList(_vm->soundData(kMusicIngame));
+ _vm->sound()->selectAudioResourceSet(kMusicIngame);
_vm->sound()->loadSoundFile(3);
_vm->sound()->playTrack(3);
@@ -1493,7 +1493,7 @@ void SeqPlayer_HOF::playHoFTalkieCredits() {
delete[] dataPtr;
_vm->staticres()->unloadId(k2SeqplayCreditsSpecial);
- _vm->sound()->setSoundList(_vm->soundData(kMusicFinale));
+ _vm->sound()->selectAudioResourceSet(kMusicFinale);
_vm->sound()->loadSoundFile(0);
}
@@ -1735,7 +1735,7 @@ void SeqPlayer_HOF::setCountDown(uint32 ticks) {
_countDownRemainder = _countDownRemainder * 2 / 3;
_countDownLastUpdate = _system->getMillis() & ~(_vm->tickLength() - 1);
}
-
+
bool SeqPlayer_HOF::countDownRunning() {
uint32 cur = _system->getMillis();
uint32 step = cur - _countDownLastUpdate;
@@ -1770,7 +1770,7 @@ int SeqPlayer_HOF::cbHOF_title(WSAMovie_v2 *wsaObj, int x, int y, int frm) {
_system->updateScreen();
_result = _menu->handle(11) + 1;
_updateAnimations = false;
-
+
if (_result == 1) {
_curScene = _lastScene;
_preventLooping = true;
diff --git a/engines/kyra/sequences_lol.cpp b/engines/kyra/sequences_lol.cpp
index 44f97f381c..83005367d7 100644
--- a/engines/kyra/sequences_lol.cpp
+++ b/engines/kyra/sequences_lol.cpp
@@ -182,7 +182,7 @@ void LoLEngine::setupPrologueData(bool load) {
memset(_selectionAnimTimers, 0, sizeof(_selectionAnimTimers));
_screen->getPalette(1).clear();
- _sound->setSoundList(&_soundData[kMusicIntro]);
+ _sound->selectAudioResourceSet(kMusicIntro);
// We have three sound.dat files, one for the intro, one for the
// end sequence and one for ingame, each contained in a different
@@ -203,7 +203,7 @@ void LoLEngine::setupPrologueData(bool load) {
return;
_eventList.clear();
- _sound->setSoundList(0);
+ _sound->selectAudioResourceSet(kMusicIntro);
}
}
@@ -1041,7 +1041,7 @@ void LoLEngine::setupEpilogueData(bool load) {
_screen->clearPage(3);
if (load) {
- _sound->setSoundList(&_soundData[kMusicFinale]);
+ _sound->selectAudioResourceSet(kMusicFinale);
// We have three sound.dat files, one for the intro, one for the
// end sequence and one for ingame, each contained in a different
@@ -1057,7 +1057,7 @@ void LoLEngine::setupEpilogueData(bool load) {
return;
_eventList.clear();
- _sound->setSoundList(0);
+ _sound->selectAudioResourceSet(kMusicIntro);
}
}
diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp
index 9d3e5f67f5..7b1b4d82f4 100644
--- a/engines/kyra/sound.cpp
+++ b/engines/kyra/sound.cpp
@@ -37,7 +37,7 @@ namespace Kyra {
Sound::Sound(KyraEngine_v1 *vm, Audio::Mixer *mixer)
: _vm(vm), _mixer(mixer), _soundChannels(), _musicEnabled(1),
- _sfxEnabled(true), _soundDataList(0) {
+ _sfxEnabled(true) {
}
Sound::~Sound() {
@@ -47,14 +47,6 @@ Sound::kType Sound::getSfxType() const {
return getMusicType();
}
-void Sound::setSoundList(const AudioDataStruct *list) {
- _soundDataList = list;
-}
-
-bool Sound::hasSoundFile(uint file) const {
- return (fileListEntry(file) != 0);
-}
-
bool Sound::isPlaying() const {
return false;
}
@@ -203,12 +195,17 @@ void MixedSoundDriver::updateVolumeSettings() {
_sfx->updateVolumeSettings();
}
-void MixedSoundDriver::setSoundList(const AudioDataStruct *list) {
- _music->setSoundList(list);
- _sfx->setSoundList(list);
+void MixedSoundDriver::initAudioResourceInfo(int set, void *info) {
+ _music->initAudioResourceInfo(set, info);
+ _sfx->initAudioResourceInfo(set, info);
+}
+
+void MixedSoundDriver::selectAudioResourceSet(int set) {
+ _music->selectAudioResourceSet(set);
+ _sfx->selectAudioResourceSet(set);
}
-bool MixedSoundDriver::hasSoundFile(uint file) const {
+bool MixedSoundDriver::hasSoundFile(uint file) {
return _music->hasSoundFile(file) && _sfx->hasSoundFile(file);
}
diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h
index 384aeb4f35..48d9b60419 100644
--- a/engines/kyra/sound.h
+++ b/engines/kyra/sound.h
@@ -37,6 +37,35 @@ class SeekableAudioStream;
namespace Kyra {
+// Helper structs to format the data passed to the various initAudioResourceInfo() implementations
+struct SoundResourceInfo_PC {
+ SoundResourceInfo_PC(const char *const *files, int numFiles) : fileList(files), fileListSize(numFiles) {}
+ const char *const *fileList;
+ int fileListSize;
+};
+
+struct SoundResourceInfo_Towns {
+ SoundResourceInfo_Towns(const char *const *files, int numFiles, const int32 *cdaTbl, int cdaTblSize) : fileList(files), fileListSize(numFiles), cdaTable(cdaTbl), cdaTableSize(cdaTblSize) {}
+ const char *const *fileList;
+ int fileListSize;
+ const int32 *cdaTable;
+ int cdaTableSize;
+};
+
+struct SoundResourceInfo_PC98 {
+ SoundResourceInfo_PC98(const char *fileNamePattern) : pattern(fileNamePattern) {}
+ const char *pattern;
+};
+
+struct SoundResourceInfo_TownsPC98V2 {
+ SoundResourceInfo_TownsPC98V2(const char *const *files, int numFiles, const char *fileNamePattern, const uint16 *cdaTbl, int cdaTblSize) : fileList(files), fileListSize(numFiles), pattern(fileNamePattern), cdaTable(cdaTbl), cdaTableSize(cdaTblSize) {}
+ const char *const *fileList;
+ int fileListSize;
+ const char *pattern;
+ const uint16 *cdaTable;
+ int cdaTableSize;
+};
+
/**
* Analog audio output device API for Kyrandia games.
* It contains functionality to play music tracks,
@@ -78,12 +107,20 @@ public:
virtual void updateVolumeSettings() {}
/**
- * Sets the soundfiles the output device will use
- * when playing a track and/or sound effect.
+ * Assigns static resource data with information on how to load
+ * audio resources to
*
- * @param list soundfile list
+ * @param set value defined in AudioResourceSet enum
+ * info various types of resource info data (file list, file name pattern, struct, etc. - depending on the inheriting driver type)
*/
- virtual void setSoundList(const AudioDataStruct *list);
+ virtual void initAudioResourceInfo(int set, void *info) = 0;
+
+ /**
+ * Select audio resource set.
+ *
+ * @param set value defined in AudioResourceSet enum
+ */
+ virtual void selectAudioResourceSet(int set) = 0;
/**
* Checks if a given sound file is present.
@@ -91,7 +128,7 @@ public:
* @param track track number
* @return true if available, false otherwise
*/
- virtual bool hasSoundFile(uint file) const;
+ virtual bool hasSoundFile(uint file) = 0;
/**
* Load a specifc sound file for use of
@@ -228,12 +265,6 @@ public:
*/
virtual void resetTrigger() {}
protected:
- const char *fileListEntry(int file) const { return (_soundDataList != 0 && file >= 0 && file < _soundDataList->fileListLen) ? _soundDataList->fileList[file] : ""; }
- int fileListLen() const { return _soundDataList->fileListLen; }
- const void *cdaData() const { return _soundDataList != 0 ? _soundDataList->cdaTracks : 0; }
- int cdaTrackNum() const { return _soundDataList != 0 ? _soundDataList->cdaNumTracks : 0; }
- int extraOffset() const { return _soundDataList != 0 ? _soundDataList->extraOffset : 0; }
-
enum {
kNumChannelHandles = 4
};
@@ -243,7 +274,7 @@ protected:
Audio::SoundHandle handle;
int priority;
};
-
+
SoundChannel _soundChannels[kNumChannelHandles];
int _musicEnabled;
@@ -253,8 +284,6 @@ protected:
Audio::Mixer *_mixer;
private:
- const AudioDataStruct *_soundDataList;
-
struct SpeechCodecs {
const char *fileext;
Audio::SeekableAudioStream *(*streamFunc)(
@@ -278,8 +307,9 @@ public:
virtual void updateVolumeSettings();
- virtual void setSoundList(const AudioDataStruct *list);
- virtual bool hasSoundFile(uint file) const;
+ virtual void initAudioResourceInfo(int set, void *info);
+ virtual void selectAudioResourceSet(int set);
+ virtual bool hasSoundFile(uint file);
virtual void loadSoundFile(uint file);
virtual void loadSoundFile(Common::String file);
diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp
index 668e662413..3d4ad1f852 100644
--- a/engines/kyra/sound_adlib.cpp
+++ b/engines/kyra/sound_adlib.cpp
@@ -2292,6 +2292,8 @@ SoundAdLibPC::SoundAdLibPC(KyraEngine_v1 *vm, Audio::Mixer *mixer)
_numSoundTriggers = 0;
_sfxPlayingSound = -1;
_soundFileLoaded.clear();
+ _currentResourceSet = 0;
+ memset(&_resInfo, 0, sizeof(_resInfo));
switch (vm->game()) {
case GI_LOL:
@@ -2322,6 +2324,8 @@ SoundAdLibPC::SoundAdLibPC(KyraEngine_v1 *vm, Audio::Mixer *mixer)
SoundAdLibPC::~SoundAdLibPC() {
delete _driver;
delete[] _soundDataPtr;
+ for (int i = 0; i < 3; i++)
+ initAudioResourceInfo(i, 0);
}
bool SoundAdLibPC::init() {
@@ -2416,8 +2420,29 @@ void SoundAdLibPC::resetTrigger() {
_driver->resetSoundTrigger();
}
+void SoundAdLibPC::initAudioResourceInfo(int set, void *info) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ delete _resInfo[set];
+ _resInfo[set] = info ? new SoundResourceInfo_PC(*(SoundResourceInfo_PC*)info) : 0;
+ }
+}
+
+void SoundAdLibPC::selectAudioResourceSet(int set) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ if (_resInfo[set])
+ _currentResourceSet = set;
+ }
+}
+
+bool SoundAdLibPC::hasSoundFile(uint file) {
+ if (file < res()->fileListSize)
+ return (res()->fileList[file] != 0);
+ return false;
+}
+
void SoundAdLibPC::loadSoundFile(uint file) {
- internalLoadFile(fileListEntry(file));
+ if (file < res()->fileListSize)
+ internalLoadFile(res()->fileList[file]);
}
void SoundAdLibPC::loadSoundFile(Common::String file) {
diff --git a/engines/kyra/sound_adlib.h b/engines/kyra/sound_adlib.h
index 8492f3b99a..99e1f154c5 100644
--- a/engines/kyra/sound_adlib.h
+++ b/engines/kyra/sound_adlib.h
@@ -69,6 +69,9 @@ public:
virtual void updateVolumeSettings();
+ virtual void initAudioResourceInfo(int set, void *info);
+ virtual void selectAudioResourceSet(int set);
+ virtual bool hasSoundFile(uint file);
virtual void loadSoundFile(uint file);
virtual void loadSoundFile(Common::String file);
@@ -87,6 +90,10 @@ private:
void play(uint8 track, uint8 volume);
+ const SoundResourceInfo_PC *res() {return _resInfo[_currentResourceSet]; }
+ SoundResourceInfo_PC *_resInfo[3];
+ int _currentResourceSet;
+
AdLibDriver *_driver;
int _version;
diff --git a/engines/kyra/sound_amiga.cpp b/engines/kyra/sound_amiga.cpp
index ec2748dd38..5962d6f4fe 100644
--- a/engines/kyra/sound_amiga.cpp
+++ b/engines/kyra/sound_amiga.cpp
@@ -53,6 +53,22 @@ bool SoundAmiga::init() {
return _driver != 0 && _tableSfxIntro && _tableSfxGame;
}
+void SoundAmiga::initAudioResourceInfo(int set, void *info) {
+ // See comment below
+}
+
+void SoundAmiga::selectAudioResourceSet(int set) {
+ // It seems that loadSoundFile() is doing what would normally be done in here.
+ // As long as this driver is only required for one single target (Kyra 1 Amiga)
+ // this doesn't matter much.
+}
+
+bool SoundAmiga::hasSoundFile(uint file) {
+ if (file < 3)
+ return true;
+ return false;
+}
+
void SoundAmiga::loadSoundFile(uint file) {
debugC(5, kDebugLevelSound, "SoundAmiga::loadSoundFile(%d)", file);
diff --git a/engines/kyra/sound_intern.h b/engines/kyra/sound_intern.h
index e09fe7e360..94f596f402 100644
--- a/engines/kyra/sound_intern.h
+++ b/engines/kyra/sound_intern.h
@@ -23,6 +23,8 @@
#ifndef KYRA_SOUND_INTERN_H
#define KYRA_SOUND_INTERN_H
+
+
#include "kyra/sound.h"
#include "kyra/sound_adlib.h"
@@ -40,6 +42,7 @@ class MaxTrax;
} // End of namespace Audio
namespace Kyra {
+
class MidiOutput;
/**
@@ -59,6 +62,9 @@ public:
void updateVolumeSettings();
+ void initAudioResourceInfo(int set, void *info);
+ void selectAudioResourceSet(int set);
+ bool hasSoundFile(uint file);
void loadSoundFile(uint file);
void loadSoundFile(Common::String file);
void loadSfxFile(Common::String file);
@@ -89,6 +95,10 @@ private:
MidiParser *_music;
MidiParser *_sfx[3];
+ const SoundResourceInfo_PC *res() {return _resInfo[_currentResourceSet]; }
+ SoundResourceInfo_PC *_resInfo[3];
+ int _currentResourceSet;
+
// misc
kType _type;
Common::String getFileName(const Common::String &str);
@@ -110,6 +120,9 @@ public:
bool init();
void process();
+ void initAudioResourceInfo(int set, void *info);
+ void selectAudioResourceSet(int set);
+ bool hasSoundFile(uint file);
void loadSoundFile(uint file);
void loadSoundFile(Common::String) {}
@@ -142,6 +155,10 @@ private:
bool _cdaPlaying;
+ const SoundResourceInfo_Towns *res() {return _resInfo[_currentResourceSet]; }
+ SoundResourceInfo_Towns *_resInfo[3];
+ int _currentResourceSet;
+
const uint8 *_musicFadeTable;
const uint8 *_sfxBTTable;
const uint8 *_sfxWDTable;
@@ -157,6 +174,9 @@ public:
bool init();
void process() {}
+ void initAudioResourceInfo(int set, void *info);
+ void selectAudioResourceSet(int set);
+ bool hasSoundFile(uint file);
void loadSoundFile(uint file);
void loadSoundFile(Common::String file);
@@ -169,11 +189,15 @@ public:
void updateVolumeSettings();
-protected:
+private:
int _lastTrack;
uint8 *_musicTrackData;
uint8 *_sfxTrackData;
TownsPC98_AudioDriver *_driver;
+
+ const char *resPattern() {return _resInfo[_currentResourceSet]->c_str(); }
+ Common::String *_resInfo[3];
+ int _currentResourceSet;
};
class SoundTownsPC98_v2 : public Sound {
@@ -186,6 +210,9 @@ public:
bool init();
void process();
+ void initAudioResourceInfo(int set, void *info);
+ void selectAudioResourceSet(int set);
+ bool hasSoundFile(uint file);
void loadSoundFile(uint file) {}
void loadSoundFile(Common::String file);
@@ -198,7 +225,7 @@ public:
void updateVolumeSettings();
-protected:
+private:
Audio::AudioStream *_currentSFX;
int _lastTrack;
bool _useFmSfx;
@@ -206,6 +233,10 @@ protected:
uint8 *_musicTrackData;
uint8 *_sfxTrackData;
TownsPC98_AudioDriver *_driver;
+
+ const SoundResourceInfo_TownsPC98V2 *res() {return _resInfo[_currentResourceSet]; }
+ SoundResourceInfo_TownsPC98V2 *_resInfo[3];
+ int _currentResourceSet;
};
// PC Speaker MIDI driver
@@ -295,6 +326,10 @@ public:
bool init();
void process() {}
+
+ void initAudioResourceInfo(int set, void *info);
+ void selectAudioResourceSet(int set);
+ bool hasSoundFile(uint file);
void loadSoundFile(uint file);
void loadSoundFile(Common::String) {}
diff --git a/engines/kyra/sound_midi.cpp b/engines/kyra/sound_midi.cpp
index 70cc304192..fe40cb163a 100644
--- a/engines/kyra/sound_midi.cpp
+++ b/engines/kyra/sound_midi.cpp
@@ -442,6 +442,8 @@ SoundMidiPC::SoundMidiPC(KyraEngine_v1 *vm, Audio::Mixer *mixer, MidiDriver *dri
_output = 0;
_musicFile = _sfxFile = 0;
+ _currentResourceSet = 0;
+ memset(&_resInfo, 0, sizeof(_resInfo));
_music = MidiParser::createParser_XMIDI();
assert(_music);
@@ -495,6 +497,9 @@ SoundMidiPC::~SoundMidiPC() {
delete[] _sfxFile;
delete[] _musicFile;
+
+ for (int i = 0; i < 3; i++)
+ initAudioResourceInfo(i, 0);
}
bool SoundMidiPC::init() {
@@ -586,8 +591,29 @@ void SoundMidiPC::updateVolumeSettings() {
_output->setSourceVolume(i, _sfxVolume, false);
}
+void SoundMidiPC::initAudioResourceInfo(int set, void *info) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ delete _resInfo[set];
+ _resInfo[set] = info ? new SoundResourceInfo_PC(*(SoundResourceInfo_PC*)info) : 0;
+ }
+}
+
+void SoundMidiPC::selectAudioResourceSet(int set) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ if (_resInfo[set])
+ _currentResourceSet = set;
+ }
+}
+
+bool SoundMidiPC::hasSoundFile(uint file) {
+ if (file < res()->fileListSize)
+ return (res()->fileList[file] != 0);
+ return false;
+}
+
void SoundMidiPC::loadSoundFile(uint file) {
- loadSoundFile(fileListEntry(file));
+ if (file < res()->fileListSize)
+ loadSoundFile(res()->fileList[file]);
}
void SoundMidiPC::loadSoundFile(Common::String file) {
diff --git a/engines/kyra/sound_towns.cpp b/engines/kyra/sound_towns.cpp
index 01624d510b..c9a4e207f9 100644
--- a/engines/kyra/sound_towns.cpp
+++ b/engines/kyra/sound_towns.cpp
@@ -35,8 +35,8 @@ namespace Kyra {
SoundTowns::SoundTowns(KyraEngine_v1 *vm, Audio::Mixer *mixer)
: Sound(vm, mixer), _lastTrack(-1), _musicTrackData(0), _sfxFileData(0), _cdaPlaying(0),
- _sfxFileIndex((uint)-1), _musicFadeTable(0), _sfxWDTable(0), _sfxBTTable(0), _sfxChannel(0x46) {
-
+ _sfxFileIndex((uint)-1), _musicFadeTable(0), _sfxWDTable(0), _sfxBTTable(0), _sfxChannel(0x46), _currentResourceSet(0) {
+ memset(&_resInfo, 0, sizeof(_resInfo));
_driver = new TownsEuphonyDriver(_mixer);
}
@@ -46,6 +46,8 @@ SoundTowns::~SoundTowns() {
delete _driver;
delete[] _musicTrackData;
delete[] _sfxFileData;
+ for (int i = 0; i < 3; i++)
+ initAudioResourceInfo(i, 0);
}
bool SoundTowns::init() {
@@ -78,11 +80,12 @@ void SoundTowns::playTrack(uint8 track) {
return;
track -= 2;
- const int32 *const tTable = (const int32 *)cdaData();
int tTableIndex = 3 * track;
- int trackNum = (int)READ_LE_UINT32(&tTable[tTableIndex + 2]);
- int32 loop = (int32)READ_LE_UINT32(&tTable[tTableIndex + 1]);
+ assert(tTableIndex + 2 < res()->cdaTableSize);
+
+ int trackNum = (int)READ_LE_UINT32(&res()->cdaTable[tTableIndex + 2]);
+ int32 loop = (int32)READ_LE_UINT32(&res()->cdaTable[tTableIndex + 1]);
if (track == _lastTrack && _musicEnabled)
return;
@@ -95,7 +98,7 @@ void SoundTowns::playTrack(uint8 track) {
g_system->getAudioCDManager()->updateCD();
_cdaPlaying = true;
} else if (_musicEnabled) {
- playEuphonyTrack(READ_LE_UINT32(&tTable[tTableIndex]), loop);
+ playEuphonyTrack(READ_LE_UINT32(&res()->cdaTable[tTableIndex]), loop);
_cdaPlaying = false;
}
@@ -117,12 +120,31 @@ void SoundTowns::haltTrack() {
_driver->stopParser();
}
+void SoundTowns::initAudioResourceInfo(int set, void *info) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ delete _resInfo[set];
+ _resInfo[set] = info ? new SoundResourceInfo_Towns(*(SoundResourceInfo_Towns*)info) : 0;
+ }
+}
+
+void SoundTowns::selectAudioResourceSet(int set) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ if (_resInfo[set])
+ _currentResourceSet = set;
+ }
+}
+
+bool SoundTowns::hasSoundFile(uint file) {
+ if (file < res()->fileListSize)
+ return (res()->fileList[file] != 0);
+}
+
void SoundTowns::loadSoundFile(uint file) {
- if (_sfxFileIndex == file)
+ if (_sfxFileIndex == file || file >= res()->fileListSize)
return;
_sfxFileIndex = file;
delete[] _sfxFileData;
- _sfxFileData = _vm->resource()->fileData(fileListEntry(file), 0);
+ _sfxFileData = _vm->resource()->fileData(res()->fileList[file], 0);
}
void SoundTowns::playSoundEffect(uint8 track, uint8) {
@@ -367,13 +389,16 @@ void SoundTowns::fadeOutSoundEffects() {
}
SoundPC98::SoundPC98(KyraEngine_v1 *vm, Audio::Mixer *mixer) :
- Sound(vm, mixer), _musicTrackData(0), _sfxTrackData(0), _lastTrack(-1), _driver(0) {
+ Sound(vm, mixer), _musicTrackData(0), _sfxTrackData(0), _lastTrack(-1), _driver(0), _currentResourceSet(0) {
+ memset(&_resInfo, 0, sizeof(_resInfo));
}
SoundPC98::~SoundPC98() {
delete[] _musicTrackData;
delete[] _sfxTrackData;
delete _driver;
+ for (int i = 0; i < 3; i++)
+ initAudioResourceInfo(i, 0);
}
bool SoundPC98::init() {
@@ -383,8 +408,26 @@ bool SoundPC98::init() {
return reslt;
}
-void SoundPC98::loadSoundFile(uint file) {
- if (!scumm_strnicmp(fileListEntry(0), "INTRO", 5)) {
+void SoundPC98::initAudioResourceInfo(int set, void *info) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ delete _resInfo[set];
+ _resInfo[set] = info ? new Common::String(((SoundResourceInfo_PC98*)info)->pattern) : 0;
+ }
+}
+
+void SoundPC98::selectAudioResourceSet(int set) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ if (_resInfo[set])
+ _currentResourceSet = set;
+ }
+}
+
+bool SoundPC98::hasSoundFile(uint file) {
+ return true;
+}
+
+void SoundPC98::loadSoundFile(uint) {
+ if (_currentResourceSet == kMusicIntro) {
delete[] _sfxTrackData;
_sfxTrackData = 0;
@@ -407,14 +450,14 @@ void SoundPC98::loadSoundFile(Common::String file) {
}
void SoundPC98::playTrack(uint8 track) {
- track += extraOffset();
+ track -= 1;
if (track == _lastTrack && _musicEnabled)
return;
beginFadeOut();
- Common::String musicFile = fileListLen() == 1 ? Common::String::format(fileListEntry(0), track) : fileListEntry(track);
+ Common::String musicFile = Common::String::format(resPattern(), track);
delete[] _musicTrackData;
_musicTrackData = _vm->resource()->fileData(musicFile.c_str(), 0);
if (_musicEnabled)
@@ -464,13 +507,16 @@ void SoundPC98::updateVolumeSettings() {
// KYRA 2
SoundTownsPC98_v2::SoundTownsPC98_v2(KyraEngine_v1 *vm, Audio::Mixer *mixer) :
- Sound(vm, mixer), _currentSFX(0), _musicTrackData(0), _sfxTrackData(0), _lastTrack(-1), _driver(0), _useFmSfx(false) {
+ Sound(vm, mixer), _currentSFX(0), _musicTrackData(0), _sfxTrackData(0), _lastTrack(-1), _driver(0), _useFmSfx(false), _currentResourceSet(0) {
+ memset(&_resInfo, 0, sizeof(_resInfo));
}
SoundTownsPC98_v2::~SoundTownsPC98_v2() {
delete[] _musicTrackData;
delete[] _sfxTrackData;
delete _driver;
+ for (int i = 0; i < 3; i++)
+ initAudioResourceInfo(i, 0);
}
bool SoundTownsPC98_v2::init() {
@@ -503,6 +549,25 @@ bool SoundTownsPC98_v2::init() {
return reslt;
}
+void SoundTownsPC98_v2::initAudioResourceInfo(int set, void *info) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ delete _resInfo[set];
+ _resInfo[set] = info ? new SoundResourceInfo_TownsPC98V2(*(SoundResourceInfo_TownsPC98V2*)info) : 0;
+ }
+}
+
+void SoundTownsPC98_v2::selectAudioResourceSet(int set) {
+ if (set >= kMusicIntro && set <= kMusicFinale) {
+ if (_resInfo[set])
+ _currentResourceSet = set;
+ }
+}
+
+bool SoundTownsPC98_v2::hasSoundFile(uint file) {
+ if (file < res()->fileListSize)
+ return (res()->fileList[file] != 0);
+}
+
void SoundTownsPC98_v2::loadSoundFile(Common::String file) {
delete[] _sfxTrackData;
_sfxTrackData = _vm->resource()->fileData(file.c_str(), 0);
@@ -513,18 +578,14 @@ void SoundTownsPC98_v2::process() {
}
void SoundTownsPC98_v2::playTrack(uint8 track) {
- track += extraOffset();
-
if (track == _lastTrack && _musicEnabled)
return;
- const uint16 *const cdaTracks = (const uint16 *)cdaData();
-
int trackNum = -1;
if (_vm->gameFlags().platform == Common::kPlatformFMTowns) {
- for (int i = 0; i < cdaTrackNum(); i++) {
- if (track == (uint8) READ_LE_UINT16(&cdaTracks[i * 2])) {
- trackNum = (int) READ_LE_UINT16(&cdaTracks[i * 2 + 1]) - 1;
+ for (int i = 0; i < res()->cdaTableSize; i++) {
+ if (track == (uint8) READ_LE_UINT16(&res()->cdaTable[i * 2])) {
+ trackNum = (int) READ_LE_UINT16(&res()->cdaTable[i * 2 + 1]) - 1;
break;
}
}
@@ -532,9 +593,10 @@ void SoundTownsPC98_v2::playTrack(uint8 track) {
beginFadeOut();
- Common::String musicFile = fileListLen() == 1 ? Common::String::format(fileListEntry(0), track) : fileListEntry(track);
+ Common::String musicFile = res()->pattern ? Common::String::format(res()->pattern, track) : (res()->fileList ? res()->fileList[track] : 0);
if (musicFile.empty())
return;
+
delete[] _musicTrackData;
_musicTrackData = _vm->resource()->fileData(musicFile.c_str(), 0);
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index 04e111b51e..5909931f9f 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -778,22 +778,6 @@ void KyraEngine_LoK::initStaticResource() {
_storyStrings = _staticres->loadStrings(k1PC98StoryStrings, _storyStringsSize);
- int size1, size2;
- const char *const *soundfiles1 = _staticres->loadStrings(k1AudioTracks, size1);
- const char *const *soundfiles2 = _staticres->loadStrings(k1AudioTracks2, size2);
- _soundFilesSize = size1 + size2;
- if (_soundFilesSize) {
- delete[] _soundFiles;
- const char **soundfiles = new const char*[_soundFilesSize];
- for (int i = 0; i < _soundFilesSize; i++)
- soundfiles[i] = (i < size1) ? soundfiles1[i] : soundfiles2[i - size1];
- _soundFiles = soundfiles;
- }
- _soundFilesIntro = _staticres->loadStrings(k1AudioTracksIntro, _soundFilesIntroSize);
- _cdaTrackTable = (const int32 *)_staticres->loadRawData(k1TownsCDATable, _cdaTrackTableSize);
-
- // copied static res
-
// room list
const Room *tempRoomList = _staticres->loadRoomTable(k1RoomList, _roomTableSize);
@@ -820,34 +804,34 @@ void KyraEngine_LoK::initStaticResource() {
_staticres->unloadId(k1DefaultShapes);
}
- // audio data tables
- static const char *const tIntro98[] = { "INTRO%d.DAT" };
- static const char *const tIngame98[] = { "KYRAM%d.DAT" };
+ // audio resource assignment
+ int size1, size2;
+ const char *const *soundfiles1 = _staticres->loadStrings(k1AudioTracks, size1);
+ const char *const *soundfiles2 = _staticres->loadStrings(k1AudioTracks2, size2);
+ int soundFilesSize = size1 + size2;
+ int soundFilesIntroSize = 0;
+ int cdaTableSize = 0;
+ const char **soundFiles = 0;
+
+ if (soundFilesSize) {
+ soundFiles = new const char*[soundFilesSize];
+ for (int i = 0; i < soundFilesSize; i++)
+ soundFiles[i] = (i < size1) ? soundfiles1[i] : soundfiles2[i - size1];
+ }
+ const char *const *soundFilesIntro = _staticres->loadStrings(k1AudioTracksIntro, temp);
+ const int32 *cdaTable = (const int32 *)_staticres->loadRawData(k1TownsCDATable, cdaTableSize);
// FIXME: It seems Kyra1 MAC CD includes AdLib and MIDI music and sfx, thus we enable
// support for those for now. (Based on patch #2767489 "Support for Mac Kyrandia 1 CD" by satz).
- memset(_soundData, 0, sizeof(_soundData));
if (_flags.platform == Common::kPlatformPC || _flags.platform == Common::kPlatformMacintosh) {
- _soundData[0].fileList = _soundFilesIntro;
- _soundData[0].fileListLen = _soundFilesIntroSize;
- _soundData[1].fileList = _soundFiles;
- _soundData[1].fileListLen = _soundFilesSize;
+ _sound->initAudioResourceInfo(kMusicIntro, &SoundResourceInfo_PC(soundFilesIntro, soundFilesIntroSize));
+ _sound->initAudioResourceInfo(kMusicIngame, &SoundResourceInfo_PC(soundFiles, soundFilesSize));
} else if (_flags.platform == Common::kPlatformFMTowns) {
- _soundData[0].fileList = _soundFiles;
- _soundData[0].fileListLen = _soundFilesSize;
- _soundData[0].cdaTracks = _cdaTrackTable;
- _soundData[0].cdaNumTracks = _cdaTrackTableSize;
- _soundData[1].fileList = _soundFiles;
- _soundData[1].fileListLen = _soundFilesSize;
- _soundData[1].cdaTracks = _cdaTrackTable;
- _soundData[1].cdaNumTracks = _cdaTrackTableSize;
+ _sound->initAudioResourceInfo(kMusicIntro, &SoundResourceInfo_Towns(soundFiles, soundFilesSize, cdaTable, cdaTableSize));
+ _sound->initAudioResourceInfo(kMusicIngame, &SoundResourceInfo_Towns(soundFiles, soundFilesSize, cdaTable, cdaTableSize));
} else if (_flags.platform == Common::kPlatformPC98) {
- _soundData[0].fileList = tIntro98;
- _soundData[0].fileListLen = 1;
- _soundData[0].extraOffset = -1;
- _soundData[1].fileList = tIngame98;
- _soundData[1].fileListLen = 1;
- _soundData[1].extraOffset = -1;
+ _sound->initAudioResourceInfo(kMusicIntro, &SoundResourceInfo_PC98("INTRO%d.DAT"));
+ _sound->initAudioResourceInfo(kMusicIngame, &SoundResourceInfo_PC98("KYRAM%d.DAT"));
}
}
@@ -1009,42 +993,18 @@ void KyraEngine_HoF::initStaticResource() {
_itemAnimDefinition = _staticres->loadItemAnimDefinition(k2IngameShapeAnimData, _itemAnimDefinitionSize);
// assign music data
- static const char *const fmtMusicFileListIntro[] = { "intro%d.twn" };
- static const char *const fmtMusicFileListFinale[] = { "finale%d.twn" };
- static const char *const fmtMusicFileListIngame[] = { "km%02d.twn" };
-
- static const char *const pc98MusicFileListIntro[] = { "intro%d.86" };
- static const char *const pc98MusicFileListFinale[] = { "finale%d.86" };
- static const char *const pc98MusicFileListIngame[] = { "km%02d.86" };
-
- memset(_soundData, 0, sizeof(_soundData));
if (_flags.platform == Common::kPlatformPC) {
- _soundData[0].fileList = _musicFileListIntro;
- _soundData[0].fileListLen = _musicFileListIntroSize;
- _soundData[1].fileList = _musicFileListIngame;
- _soundData[1].fileListLen = _musicFileListIngameSize;
- _soundData[2].fileList = _musicFileListFinale;
- _soundData[2].fileListLen = _musicFileListIntroSize;
+ _sound->initAudioResourceInfo(kMusicIntro, &SoundResourceInfo_PC(_musicFileListIntro, _musicFileListIntroSize));
+ _sound->initAudioResourceInfo(kMusicIngame, &SoundResourceInfo_PC(_musicFileListIngame, _musicFileListIngameSize));
+ _sound->initAudioResourceInfo(kMusicFinale, &SoundResourceInfo_PC(_musicFileListFinale, _musicFileListFinaleSize));
} else if (_flags.platform == Common::kPlatformFMTowns) {
- _soundData[0].fileList = fmtMusicFileListIntro;
- _soundData[0].fileListLen = 1;
- _soundData[0].cdaTracks = _cdaTrackTableIntro;
- _soundData[0].cdaNumTracks = _cdaTrackTableIntroSize >> 1;
- _soundData[1].fileList = fmtMusicFileListIngame;
- _soundData[1].fileListLen = 1;
- _soundData[1].cdaTracks = _cdaTrackTableIngame;
- _soundData[1].cdaNumTracks = _cdaTrackTableIngameSize >> 1;
- _soundData[2].fileList = fmtMusicFileListFinale;
- _soundData[2].fileListLen = 1;
- _soundData[2].cdaTracks = _cdaTrackTableFinale;
- _soundData[2].cdaNumTracks = _cdaTrackTableFinaleSize >> 1;
+ _sound->initAudioResourceInfo(kMusicIntro, &SoundResourceInfo_TownsPC98V2(0, 0, "intro%d.twn", (const uint16*)_cdaTrackTableIntro, _cdaTrackTableIntroSize >> 1));
+ _sound->initAudioResourceInfo(kMusicIngame, &SoundResourceInfo_TownsPC98V2(0, 0, "km%02d.twn", (const uint16*)_cdaTrackTableIngame, _cdaTrackTableIngameSize >> 1));
+ _sound->initAudioResourceInfo(kMusicFinale, &SoundResourceInfo_TownsPC98V2(0, 0, "finale%d.twn", (const uint16*)_cdaTrackTableFinale, _cdaTrackTableFinaleSize >> 1));
} else if (_flags.platform == Common::kPlatformPC98) {
- _soundData[0].fileList = pc98MusicFileListIntro;
- _soundData[0].fileListLen = 1;
- _soundData[1].fileList = pc98MusicFileListIngame;
- _soundData[1].fileListLen = 1;
- _soundData[2].fileList = pc98MusicFileListFinale;
- _soundData[2].fileListLen = 1;
+ _sound->initAudioResourceInfo(kMusicIntro, &SoundResourceInfo_TownsPC98V2(0, 0, "intro%d.86", 0, 0));
+ _sound->initAudioResourceInfo(kMusicIngame, &SoundResourceInfo_TownsPC98V2(0, 0, "km%02d.86", 0, 0));
+ _sound->initAudioResourceInfo(kMusicFinale, &SoundResourceInfo_TownsPC98V2(0, 0, "finale%d.86", 0, 0));
}
}
diff --git a/engines/kyra/staticres_lol.cpp b/engines/kyra/staticres_lol.cpp
index 4934aeb421..af32fb9ad5 100644
--- a/engines/kyra/staticres_lol.cpp
+++ b/engines/kyra/staticres_lol.cpp
@@ -24,6 +24,7 @@
#include "kyra/lol.h"
#include "kyra/screen_lol.h"
#include "kyra/gui_lol.h"
+#include "kyra/sound_intern.h"
#ifdef ENABLE_LOL
@@ -213,35 +214,16 @@ void StaticResource::freeButtonDefs(void *&ptr, int &size) {
}
void LoLEngine::initStaticResource() {
- // assign music resource data
- static const char *const pcMusicFileListIntro[] = { "LOREINTR" };
- static const char *const pcMusicFileListFinale[] = { "LOREFINL" };
- static const char *const pcMusicFileListIngame[] = { "LORE%02d%c" };
- static const char *const pcMusicFileListDemo[] = { "LOREDEMO" };
-
- static const char *const pc98MusicFileListIntro[] = { 0, "lore84.86", "lore82.86", 0, 0, 0, "lore83.86", "lore81.86" };
- static const char *const pc98MusicFileListFinale[] = { 0, 0, "lore85.86", "lore86.86", "lore87.86" };
- static const char *const pc98MusicFileListIngame[] = { "lore%02d.86" };
-
- memset(_soundData, 0, sizeof(_soundData));
-
+ // assign music resource data (not required for the PC version, resource loading is implemented differently there)
if (_flags.isDemo) {
- _soundData[0].fileList = pcMusicFileListDemo;
- _soundData[0].fileListLen = ARRAYSIZE(pcMusicFileListDemo);
- } else if (_flags.platform == Common::kPlatformPC) {
- _soundData[0].fileList = pcMusicFileListIntro;
- _soundData[0].fileListLen = ARRAYSIZE(pcMusicFileListIntro);
- _soundData[1].fileList = pcMusicFileListIngame;
- _soundData[1].fileListLen = ARRAYSIZE(pcMusicFileListIngame);
- _soundData[2].fileList = pcMusicFileListFinale;
- _soundData[2].fileListLen = ARRAYSIZE(pcMusicFileListFinale);
+ static const char *const file[] = { "LOREDEMO" };
+ _sound->initAudioResourceInfo(kMusicIntro, &SoundResourceInfo_TownsPC98V2(file, ARRAYSIZE(file), 0, 0, 0));
} else if (_flags.platform == Common::kPlatformPC98) {
- _soundData[0].fileList = pc98MusicFileListIntro;
- _soundData[0].fileListLen = ARRAYSIZE(pc98MusicFileListIntro);
- _soundData[1].fileList = pc98MusicFileListIngame;
- _soundData[1].fileListLen = ARRAYSIZE(pc98MusicFileListIngame);
- _soundData[2].fileList = pc98MusicFileListFinale;
- _soundData[2].fileListLen = ARRAYSIZE(pc98MusicFileListFinale);
+ static const char *const fileListIntro[] = { 0, "lore84.86", "lore82.86", 0, 0, 0, "lore83.86", "lore81.86" };
+ static const char *const fileListFinale[] = { 0, 0, "lore85.86", "lore86.86", "lore87.86" };
+ _sound->initAudioResourceInfo(kMusicIntro, &SoundResourceInfo_TownsPC98V2(fileListIntro, ARRAYSIZE(fileListIntro), 0, 0, 0));
+ _sound->initAudioResourceInfo(kMusicIngame, &SoundResourceInfo_TownsPC98V2(0, 0, "lore%02d.86", 0, 0));
+ _sound->initAudioResourceInfo(kMusicFinale, &SoundResourceInfo_TownsPC98V2(fileListFinale, ARRAYSIZE(fileListFinale), 0, 0, 0));
}
if (_flags.isDemo)