diff options
author | Travis Howell | 2005-04-25 05:44:12 +0000 |
---|---|---|
committer | Travis Howell | 2005-04-25 05:44:12 +0000 |
commit | 93803048327377ed3a4f3966e7cf7719253a56ed (patch) | |
tree | bff7487f11f554aaca99739ee2335e1a3a70c593 | |
parent | 8776150321abb1d7d5f6ceb512713583e53d605e (diff) | |
download | scummvm-rg350-93803048327377ed3a4f3966e7cf7719253a56ed.tar.gz scummvm-rg350-93803048327377ed3a4f3966e7cf7719253a56ed.tar.bz2 scummvm-rg350-93803048327377ed3a4f3966e7cf7719253a56ed.zip |
Read index of music file in HE games at startup.
Only reliable way to always get correct music tracks.
svn-id: r17798
-rw-r--r-- | scumm/sound.cpp | 69 | ||||
-rw-r--r-- | scumm/sound.h | 10 | ||||
-rw-r--r-- | scumm/wiz_he.cpp | 6 |
3 files changed, 51 insertions, 34 deletions
diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 63a573f990..20be3a512e 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -76,7 +76,8 @@ Sound::Sound(ScummEngine *parent) _currentCDSound(0), _currentMusic(0), _soundsPaused(false), - _sfxMode(0) { + _sfxMode(0), + _heMusicTracks(0) { memset(_soundQue, 0, sizeof(_soundQue)); memset(_soundQue2, 0, sizeof(_soundQue2)); @@ -161,8 +162,8 @@ void Sound::setOverrideFreq(int freq) { _overrideFreq = freq; } -void Sound::getHEMusicDetails(int id, int &musicOffs, int &musicSize) { - int musicID, offs, tracks, total_size; +void Sound::setupHEMusicFile() { + int i, total_size; char buf[32], buf1[128]; File musicFile; @@ -179,42 +180,43 @@ void Sound::getHEMusicDetails(int id, int &musicOffs, int &musicSize) { musicFile.seek(4, SEEK_SET); total_size = musicFile.readUint32BE(); musicFile.seek(16, SEEK_SET); - tracks = musicFile.readUint32LE(); + _heMusicTracks = musicFile.readUint32LE(); + debug(0, "Total music tracks %d", _heMusicTracks); int musicStart = (_vm->_heversion >= 80) ? 56 : 20; - musicFile.seek(musicStart, SEEK_SET); - int musicStartID = musicFile.readUint32LE(); - - // Music is off by one in freddi2/puttzoo - offs = id - musicStartID - 1; - if (offs < 0 || offs > tracks) - offs = 0; - - offs *= (_vm->_heversion >= 80) ? 21 : 25; - musicFile.seek(musicStart + offs, SEEK_SET); - - // Adjust all other games. - musicID = musicFile.readUint32LE(); - if (id == musicID + 1) { - offs += (_vm->_heversion >= 80) ? 21 : 25; - musicFile.seek(musicStart + offs, SEEK_SET); - musicID = musicFile.readUint32LE(); - } - musicOffs = musicFile.readUint32LE(); - musicSize = musicFile.readUint32LE(); + _heMusic = (HEMusic *)malloc((_heMusicTracks + 1) * sizeof(HEMusic)); + for (i = 0; i < _heMusicTracks; i++) { + _heMusic[i].id = musicFile.readUint32LE(); + _heMusic[i].offset = musicFile.readUint32LE(); + _heMusic[i].size = musicFile.readUint32LE(); - if (id != musicID) { - debug(0, "getHEMusicDetails: Music track doesn't match (%d, %d)", id, musicID); - } - if (musicOffs > total_size || (musicSize + musicOffs > total_size) || musicSize < 0) { - error("getHEMusicDetails: Invalid music offset (%d) in music %d", id); - } + if (_vm->_heversion >= 80) { + musicFile.seek(+9, SEEK_CUR); + } else { + musicFile.seek(+13, SEEK_CUR); + } + } musicFile.close(); } +void Sound::getHEMusicDetails(int id, int &musicOffs, int &musicSize) { + int i; + + for (i = 0; i < _heMusicTracks; i++) { + if (_heMusic[i].id == id) { + musicOffs = _heMusic[i].offset; + musicSize = _heMusic[i].size; + return; + } + } + + error("getHEMusicDetails: musicID %d not found", id); + +} + void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) { debug(5,"playSound: soundID %d heOffset %d heChannel %d heFlags %d\n", soundID, heOffset, heChannel, heFlags); byte *mallocedPtr = NULL; @@ -1060,8 +1062,13 @@ void Sound::setupSound() { delete _sfxFile; _sfxFile = openSfxFile(); - if (_vm->_gameId == GID_FT) + if (_vm->_heversion >= 70) { + setupHEMusicFile(); + } + + if (_vm->_gameId == GID_FT) { _vm->VAR(_vm->VAR_VOICE_BUNDLE_LOADED) = _sfxFile->isOpen(); + } } void Sound::pauseSounds(bool pause) { diff --git a/scumm/sound.h b/scumm/sound.h index 900250525f..89c4335c6d 100644 --- a/scumm/sound.h +++ b/scumm/sound.h @@ -83,6 +83,15 @@ protected: int16 _currentCDSound; int16 _currentMusic; + + struct HEMusic{ + int32 id; + int32 offset; + int32 size; + }; + HEMusic *_heMusic; + int16 _heMusicTracks; + public: SoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on SoundHandle _heSoundChannels[8]; @@ -120,6 +129,7 @@ public: void updateCD(); int getCurrentCDSound() const { return _currentCDSound; } + void setupHEMusicFile(); void getHEMusicDetails(int id, int &musicOffs, int &musicSize); // Used by the save/load system: diff --git a/scumm/wiz_he.cpp b/scumm/wiz_he.cpp index 7e5e2da530..5177747cc9 100644 --- a/scumm/wiz_he.cpp +++ b/scumm/wiz_he.cpp @@ -912,7 +912,7 @@ void ScummEngine_v72he::displayWizImage(WizImage *pwi) { } uint8 *ScummEngine_v72he::drawWizImage(int resNum, int state, int x1, int y1, int xmapNum, const Common::Rect *clipBox, int flags, int dstResNum, int paletteNum) { - debug(1, "drawWizImage(resNum %d, x1 %d, y1 %d, flags 0x%X, xmapNum %d dstResNum %d paletteNum %d)", resNum, x1, y1, flags, xmapNum, dstResNum, paletteNum); + debug(2, "drawWizImage(resNum %d, x1 %d, y1 %d, flags 0x%X, xmapNum %d dstResNum %d paletteNum %d)", resNum, x1, y1, flags, xmapNum, dstResNum, paletteNum); uint8 *dst = NULL; const uint8 *palPtr = NULL; if (_heversion >= 99) { @@ -932,7 +932,7 @@ uint8 *ScummEngine_v72he::drawWizImage(int resNum, int state, int x1, int y1, in uint32 comp = READ_LE_UINT32(wizh + 0x0); uint32 width = READ_LE_UINT32(wizh + 0x4); uint32 height = READ_LE_UINT32(wizh + 0x8); - debug(1, "wiz_header.comp = %d wiz_header.w = %d wiz_header.h = %d", comp, width, height); + debug(2, "wiz_header.comp = %d wiz_header.w = %d wiz_header.h = %d", comp, width, height); uint8 *wizd = findWrappedBlock(MKID('WIZD'), dataPtr, state, 0); assert(wizd); @@ -1620,7 +1620,7 @@ void ScummEngine_v90he::fillWizParallelogram(const WizParameters *params) { } void ScummEngine_v90he::processWizImage(const WizParameters *params) { - debug(0, "processWizImage: processMode %d", params->processMode); + debug(2, "processWizImage: processMode %d", params->processMode); switch (params->processMode) { case 0: // Used in racedemo |