mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-26 04:35:16 +00:00
Read index of music file in HE games at startup.
Only reliable way to always get correct music tracks. svn-id: r17798
This commit is contained in:
parent
8776150321
commit
9380304832
@ -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;
|
||||
_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();
|
||||
|
||||
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();
|
||||
|
||||
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) {
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user