added getMusicTimer() to class MusicEngine; this allows some nice code cleanup; also added an error() invocation to find out if certain code is still needed

svn-id: r10556
This commit is contained in:
Max Horn 2003-10-03 01:07:35 +00:00
parent 2ed4677ede
commit e6819e42cf
4 changed files with 19 additions and 25 deletions

View File

@ -36,7 +36,9 @@ public:
virtual void stopSound(int sound) = 0;
virtual void stopAllSounds() = 0;
virtual int getSoundStatus(int sound) const = 0;
// virtual int getMusicTimer() const = 0;
virtual int getMusicTimer() const { return 0; }
virtual void terminate() {}
};

View File

@ -32,7 +32,7 @@ void ScummEngine_v2::readClassicIndexFile() {
if (_gameId == GID_MANIAC) {
if (!(_features & GF_AMIGA) && !(_features & GF_NES))
_musicEngine = _playerV2 = new Player_V1(this);
_musicEngine = new Player_V1(this);
_numGlobalObjects = 800;
_numRooms = 55;
@ -41,7 +41,7 @@ void ScummEngine_v2::readClassicIndexFile() {
_numSounds = 100;
} else if (_gameId == GID_ZAK) {
if (!(_features & GF_AMIGA))
_musicEngine = _playerV2 = new Player_V2(this);
_musicEngine = new Player_V2(this);
_numGlobalObjects = 775;
_numRooms = 61;
@ -107,7 +107,7 @@ void ScummEngine_v2::readClassicIndexFile() {
void ScummEngine_v2::readEnhancedIndexFile() {
if (!(_features & GF_AMIGA))
_musicEngine = _playerV2 = new Player_V2(this);
_musicEngine = new Player_V2(this);
_numGlobalObjects = _fileHandle.readUint16LE();
_fileHandle.seek(_numGlobalObjects, SEEK_CUR); // Skip object flags

View File

@ -42,9 +42,6 @@ class IMuse;
class IMuseDigital;
class MusicEngine;
class NewGui;
class Player_V2;
class Player_V2A;
class Player_V3A;
class ScummEngine;
class ScummDebugger;
class Serializer;
@ -260,9 +257,6 @@ public:
* on some architectures. */
IMuse *_imuse;
IMuseDigital *_imuseDigital;
Player_V2 *_playerV2;
Player_V2A *_playerV2A;
Player_V3A *_playerV3A;
MusicEngine *_musicEngine;
Sound *_sound;

View File

@ -732,22 +732,19 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst)
// Init iMuse
_imuse = NULL;
_imuseDigital = NULL;
_playerV2 = NULL;
_playerV2A = NULL;
_playerV3A = NULL;
_musicEngine = NULL;
if (_features & GF_DIGI_IMUSE) {
_musicEngine = _imuseDigital = new IMuseDigital(this);
#ifndef __PALM_OS__
} else if ((_features & GF_AMIGA) && (_version == 2)) {
_musicEngine = _playerV2A = new Player_V2A(this);
_musicEngine = new Player_V2A(this);
#endif
} else if ((_features & GF_AMIGA) && (_version == 3)) {
_musicEngine = _playerV3A = new Player_V3A(this);
_musicEngine = new Player_V3A(this);
} else if ((_features & GF_AMIGA) && (_version < 5)) {
_musicEngine = NULL;
} else if (((_midiDriver == MD_PCJR) || (_midiDriver == MD_PCSPK)) && ((_version > 2) && (_version < 5))) {
_musicEngine = _playerV2 = new Player_V2(this);
_musicEngine = new Player_V2(this);
} else if (_version > 2) {
MidiDriver *driver = detector->createMidi();
if (driver && detector->_native_mt32)
@ -1352,22 +1349,23 @@ int ScummEngine::scummLoop(int delta) {
if (_features & GF_AUDIOTRACKS) {
// Covered automatically by the Sound class
} else if (_playerV2) {
VAR(VAR_MUSIC_TIMER) = _playerV2->getMusicTimer();
} else if (_playerV2A) {
VAR(VAR_MUSIC_TIMER) = _playerV2A->getMusicTimer();
} else if (_playerV3A) {
VAR(VAR_MUSIC_TIMER) = _playerV3A->getMusicTimer();
} else if (_imuse) {
VAR(VAR_MUSIC_TIMER) = _imuse->getMusicTimer();
} else if (_musicEngine && VAR_MUSIC_TIMER != 0xFF) {
// The music engine generates the timer data for us.
VAR(VAR_MUSIC_TIMER) = _musicEngine->getMusicTimer();
} else if (_features & GF_SMALL_HEADER) {
// FIXME: Is this code here really still necessary? It used to be there to sync
// MonkeyVGA, back before we used iMuse for it, too. Right now, I can't find
// anything which would need this... so I put an aggressive error in here,
// if there is something needing this, I am guranteed a report :-)
error("Fingolfin asks: when is this ever triggered anyway? %s:%d", __FILE__, __LINE__);
// TODO: The music delay (given in milliseconds) might have to be tuned a little
// to get it correct for all games. Without the ability to watch/listen to the
// original games, I can't do that myself.
const int MUSIC_DELAY = 480;
tempMusic += delta * 15; // Convert delta to milliseconds
if (tempMusic >= MUSIC_DELAY) {
tempMusic %= MUSIC_DELAY;
tempMusic -= MUSIC_DELAY;
VAR(VAR_MUSIC_TIMER) += 1;
}
}