[Scummvm-cvs-logs] CVS: scummvm/scumm script_v7he.cpp,2.28,2.29 sound.cpp,1.340,1.341 sound.h,1.66,1.67
Travis Howell
kirben at users.sourceforge.net
Mon Jul 12 02:03:01 CEST 2004
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6512/scumm
Modified Files:
script_v7he.cpp sound.cpp sound.h
Log Message:
Add support for music in HE 7.0 games.
Check music status correctly in 3DO versions.
Index: script_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v7he.cpp,v
retrieving revision 2.28
retrieving revision 2.29
diff -u -d -r2.28 -r2.29
--- script_v7he.cpp 3 Jul 2004 10:03:21 -0000 2.28
+++ script_v7he.cpp 12 Jul 2004 09:02:18 -0000 2.29
@@ -686,11 +686,8 @@
case 255:
// _sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndTimer, _heSndLoop);
- // FIXME: Music resources (Id 4000+?) are currently unsupported,
- // so don't attempt to play them.
- if (_heSndSoundId < 4000)
- _sound->addSoundToQueue(_heSndSoundId);
- debug(1, "o7_startSound stub (%d, %d, %d, %d)", _heSndSoundId, _heSndOffset, _heSndTimer, _heSndLoop);
+ _sound->addSoundToQueue(_heSndSoundId);
+ debug(2, "o7_startSound stub (%d, %d, %d, %d)", _heSndSoundId, _heSndOffset, _heSndTimer, _heSndLoop);
_heSndLoop = 0;
break;
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.340
retrieving revision 1.341
diff -u -d -r1.340 -r1.341
--- sound.cpp 2 Jul 2004 07:38:40 -0000 1.340
+++ sound.cpp 12 Jul 2004 09:02:18 -0000 1.341
@@ -70,6 +70,7 @@
_curSoundPos(0),
_overrideFreq(0),
_currentCDSound(0),
+ _currentMusic(0),
_soundsPaused(false),
_sfxMode(0) {
@@ -85,7 +86,9 @@
void Sound::addSoundToQueue(int sound) {
_vm->VAR(_vm->VAR_LAST_SOUND) = sound;
- _vm->ensureResourceLoaded(rtSound, sound);
+ // Music resources are in separate file
+ if (!((_vm->_heversion == 70 || _vm->_heversion == 71) && sound >= 4000))
+ _vm->ensureResourceLoaded(rtSound, sound);
addSoundToQueue2(sound);
}
@@ -155,6 +158,52 @@
debugC(DEBUG_SOUND, "playSound #%d (room %d)", soundID,
_vm->getResourceRoomNr(rtSound, soundID));
+ if ((_vm->_heversion == 70 || _vm->_heversion == 71) && soundID >= 4000) {
+ int music_offs, total_size;
+ char buf[32];
+ File musicFile;
+ sprintf(buf, "%s.he4", _vm->getGameName());
+ if (musicFile.open(buf) == false) {
+ return;
+ }
+ musicFile.seek(4, SEEK_SET);
+ total_size = musicFile.readUint32BE();
+ debug(1, "Total Music file size %d", total_size);
+
+ // Skip header junk
+ musicFile.seek(+20, SEEK_CUR);
+
+ // Skip to correct music header
+ uint skip = (soundID - 4001) * 25;
+ musicFile.seek(+skip, SEEK_CUR);
+
+ // Skip to offsets
+ musicFile.seek(+21, SEEK_CUR);
+
+ music_offs = musicFile.readUint32LE();
+ size = musicFile.readUint32LE();
+
+ musicFile.seek(music_offs, SEEK_SET);
+
+
+ if (music_offs > total_size || (size + music_offs) > total_size)
+ error("Bad music offsets");
+
+ byte *src_ptr = (byte *) calloc(size, 1);
+ musicFile.read(src_ptr, size);
+ musicFile.close();
+
+ rate = 11025;
+
+ // Allocate a sound buffer, copy the data into it, and play
+ sound = (char *)malloc(size);
+ memcpy(sound, src_ptr, size);
+ _currentMusic = soundID;
+ _vm->_mixer->stopHandle(_musicChannelHandle);
+ _vm->_mixer->playRaw(&_musicChannelHandle, sound, size, rate, flags, soundID);
+ return;
+ }
+
ptr = _vm->getResourceAddress(rtSound, soundID);
if (!ptr) {
return;
@@ -213,7 +262,9 @@
// Allocate a sound buffer, copy the data into it, and play
sound = (char *)malloc(size);
memcpy(sound, ptr + 8, size);
- _vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
+ _currentMusic = soundID;
+ _vm->_mixer->stopHandle(_musicChannelHandle);
+ _vm->_mixer->playRaw(&_musicChannelHandle, sound, size, rate, flags, soundID);
}
// Support for sampled sound effects in Monkey Island 1 and 2
else if (READ_UINT32(ptr) == MKID('SBL ')) {
@@ -658,16 +709,17 @@
if (_vm->_features & GF_HUMONGOUS) {
if (sound == 10000)
- // FIXME: Music resources in HE7 games are currently unsupported,
- // so prevent music restart attempt
- return 1;
+ return (_musicChannelHandle.isActive()) ? _currentMusic : 0;
else if (sound == -2) {
return isSfxFinished();
} else if (sound == -1) {
// getSoundStatus(), with a -1, will return the
// ID number of the first active music it finds.
// TODO handle MRAW (pcm music) in humongous games
- return _vm->_imuse->getSoundStatus(sound);
+ if (_currentMusic)
+ return _currentMusic;
+ else
+ return _vm->_imuse->getSoundStatus(sound);
}
}
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- sound.h 22 Jun 2004 10:39:46 -0000 1.66
+++ sound.h 12 Jul 2004 09:02:18 -0000 1.67
@@ -73,8 +73,11 @@
int _overrideFreq;
int _currentCDSound;
+ int _currentMusic;
public:
PlayingSoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on
+ PlayingSoundHandle _musicChannelHandle; // Handle of mixer channel music is on
+
bool _soundsPaused;
byte _sfxMode;
More information about the Scummvm-git-logs
mailing list