diff options
author | Jamieson Christian | 2003-08-16 17:08:22 +0000 |
---|---|---|
committer | Jamieson Christian | 2003-08-16 17:08:22 +0000 |
commit | d7fae3d1cb5921e1256c9313d0ea0bf74db3523d (patch) | |
tree | 60fc1ba9dd9c782ae43251b631a60d7883bcde6b | |
parent | 61162bf359b251ea46f2ea4944383a92f528555a (diff) | |
download | scummvm-rg350-d7fae3d1cb5921e1256c9313d0ea0bf74db3523d.tar.gz scummvm-rg350-d7fae3d1cb5921e1256c9313d0ea0bf74db3523d.tar.bz2 scummvm-rg350-d7fae3d1cb5921e1256c9313d0ea0bf74db3523d.zip |
More corrections to the VAR_MUSIC_TIMER
computations, mostly to produce the
exptected output with AD resources.
svn-id: r9730
-rw-r--r-- | scumm/imuse.cpp | 2 | ||||
-rw-r--r-- | scumm/imuse_internal.h | 2 | ||||
-rw-r--r-- | scumm/imuse_player.cpp | 4 | ||||
-rw-r--r-- | scumm/midiparser_ro.cpp | 43 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 2 | ||||
-rw-r--r-- | sound/midiparser.h | 5 |
6 files changed, 35 insertions, 23 deletions
diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp index ceed012148..986b32c6f5 100644 --- a/scumm/imuse.cpp +++ b/scumm/imuse.cpp @@ -329,7 +329,7 @@ int IMuseInternal::getMusicTimer() { best_time = timer; } } - return best_time / 1000000; + return best_time; } void IMuseInternal::sequencer_timers(MidiDriver *midi) { diff --git a/scumm/imuse_internal.h b/scumm/imuse_internal.h index 8ab454d87f..81819465ed 100644 --- a/scumm/imuse_internal.h +++ b/scumm/imuse_internal.h @@ -261,7 +261,7 @@ public: int setTranspose(byte relative, int b); int setVolume(byte vol); bool startSound(int sound, MidiDriver *midi); - uint32 getMusicTimer(); + int getMusicTimer(); public: // MidiDriver interface diff --git a/scumm/imuse_player.cpp b/scumm/imuse_player.cpp index a754700b37..597544823c 100644 --- a/scumm/imuse_player.cpp +++ b/scumm/imuse_player.cpp @@ -128,8 +128,8 @@ bool Player::startSound(int sound, MidiDriver *midi) { return true; } -uint32 Player::getMusicTimer() { - return _parser ? _parser->getTime() : 0; +int Player::getMusicTimer() { + return _parser ? (_parser->getTick() * 2 / _parser->getPPQN()) : 0; } bool Player::isFadingOut() { diff --git a/scumm/midiparser_ro.cpp b/scumm/midiparser_ro.cpp index 4f01a3e5fe..afe0f49131 100644 --- a/scumm/midiparser_ro.cpp +++ b/scumm/midiparser_ro.cpp @@ -33,7 +33,8 @@ class MidiParser_RO : public MidiParser { protected: - int _markerCount; // Number of markers encountered in stream so far + int _markerCount; // Number of markers encountered in stream so far + int _lastMarkerCount; // Cache markers until parsed event is actually consumed protected: void compressToType0(); @@ -41,7 +42,7 @@ protected: public: bool loadMusic (byte *data, uint32 size); - uint32 getTime() { return (uint32) _markerCount * 1000000; } + uint32 getTick() { return (uint32) _markerCount * _ppqn / 2; } }; @@ -53,16 +54,17 @@ public: ////////////////////////////////////////////////// void MidiParser_RO::parseNextEvent (EventInfo &info) { + _markerCount += _lastMarkerCount; + _lastMarkerCount = 0; + info.delta = 0; do { info.start = _position._play_pos; info.event = *(_position._play_pos++); if (info.command() == 0xA) { - ++_markerCount; - continue; - } // end if - - if (info.event == 0xF0) { + ++_lastMarkerCount; + info.event = 0xF0; + } else if (info.event == 0xF0) { byte delay = *(_position._play_pos++); info.delta += delay; continue; @@ -71,9 +73,15 @@ void MidiParser_RO::parseNextEvent (EventInfo &info) { } while (true); // Seems to indicate EOT - if (info.event == 0) - info.event = 0xF0; - else if (info.event < 0x80) + if (info.event == 0) { + info.event = 0xFF; + info.ext.type = 0x2F; + info.length = 0; + info.ext.data = 0; + return; + } + + if (info.event < 0x80) return; _position._running_status = info.event; @@ -91,13 +99,16 @@ void MidiParser_RO::parseNextEvent (EventInfo &info) { info.length = 0; break; - case 0xF: // End of Track messages - if (info.event == 0xFF) - _autoLoop = true; - info.event = 0xFF; - info.ext.type = 0x2F; + case 0xF: // Marker and EOT messages info.length = 0; info.ext.data = 0; + if (info.event == 0xFF) { + _autoLoop = true; + info.ext.type = 0x2F; + } else { + info.ext.type = 0x7F; // Bogus META + } + info.event = 0xFF; break; } } @@ -114,7 +125,7 @@ bool MidiParser_RO::loadMusic (byte *data, uint32 size) { _num_tracks = 1; _ppqn = 120; _tracks[0] = pos + 2; - _markerCount = 0; + _markerCount = _lastMarkerCount = 0; // Note that we assume the original data passed in // will persist beyond this call, i.e. we do NOT diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 342a17f89a..8ed884612c 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -1207,7 +1207,7 @@ int Scumm::scummLoop(int delta) { // Covered automatically by the Sound class } else if (_playerV2) { VAR(VAR_MUSIC_TIMER) = _playerV2->getMusicTimer(); - } else if (_imuse && _midiDriver != MD_ADLIB) { + } else if (_imuse) { VAR(VAR_MUSIC_TIMER) = _imuse->getMusicTimer(); } else if (_features & GF_SMALL_HEADER) { // TODO: The music delay (given in milliseconds) might have to be tuned a little diff --git a/sound/midiparser.h b/sound/midiparser.h index e419535df0..d44b477015 100644 --- a/sound/midiparser.h +++ b/sound/midiparser.h @@ -247,8 +247,9 @@ public: bool setTrack (int track); bool jumpToTick (uint32 tick, bool fireEvents = false); - uint32 getTick() { return _position._play_tick; } - virtual uint32 getTime() { return _position._play_time; } + + uint32 getPPQN() { return _ppqn; } + virtual uint32 getTick() { return _position._play_tick; } static MidiParser *createParser_SMF(); static MidiParser *createParser_XMIDI(); |