More corrections to the VAR_MUSIC_TIMER

computations, mostly to produce the
exptected output with AD resources.

svn-id: r9730
This commit is contained in:
Jamieson Christian 2003-08-16 17:08:22 +00:00
parent 61162bf359
commit d7fae3d1cb
6 changed files with 35 additions and 23 deletions

View file

@ -329,7 +329,7 @@ int IMuseInternal::getMusicTimer() {
best_time = timer; best_time = timer;
} }
} }
return best_time / 1000000; return best_time;
} }
void IMuseInternal::sequencer_timers(MidiDriver *midi) { void IMuseInternal::sequencer_timers(MidiDriver *midi) {

View file

@ -261,7 +261,7 @@ public:
int setTranspose(byte relative, int b); int setTranspose(byte relative, int b);
int setVolume(byte vol); int setVolume(byte vol);
bool startSound(int sound, MidiDriver *midi); bool startSound(int sound, MidiDriver *midi);
uint32 getMusicTimer(); int getMusicTimer();
public: public:
// MidiDriver interface // MidiDriver interface

View file

@ -128,8 +128,8 @@ bool Player::startSound(int sound, MidiDriver *midi) {
return true; return true;
} }
uint32 Player::getMusicTimer() { int Player::getMusicTimer() {
return _parser ? _parser->getTime() : 0; return _parser ? (_parser->getTick() * 2 / _parser->getPPQN()) : 0;
} }
bool Player::isFadingOut() { bool Player::isFadingOut() {

View file

@ -33,7 +33,8 @@
class MidiParser_RO : public MidiParser { class MidiParser_RO : public MidiParser {
protected: 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: protected:
void compressToType0(); void compressToType0();
@ -41,7 +42,7 @@ protected:
public: public:
bool loadMusic (byte *data, uint32 size); 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) { void MidiParser_RO::parseNextEvent (EventInfo &info) {
_markerCount += _lastMarkerCount;
_lastMarkerCount = 0;
info.delta = 0; info.delta = 0;
do { do {
info.start = _position._play_pos; info.start = _position._play_pos;
info.event = *(_position._play_pos++); info.event = *(_position._play_pos++);
if (info.command() == 0xA) { if (info.command() == 0xA) {
++_markerCount; ++_lastMarkerCount;
continue; info.event = 0xF0;
} // end if } else if (info.event == 0xF0) {
if (info.event == 0xF0) {
byte delay = *(_position._play_pos++); byte delay = *(_position._play_pos++);
info.delta += delay; info.delta += delay;
continue; continue;
@ -71,9 +73,15 @@ void MidiParser_RO::parseNextEvent (EventInfo &info) {
} while (true); } while (true);
// Seems to indicate EOT // Seems to indicate EOT
if (info.event == 0) if (info.event == 0) {
info.event = 0xF0; info.event = 0xFF;
else if (info.event < 0x80) info.ext.type = 0x2F;
info.length = 0;
info.ext.data = 0;
return;
}
if (info.event < 0x80)
return; return;
_position._running_status = info.event; _position._running_status = info.event;
@ -91,13 +99,16 @@ void MidiParser_RO::parseNextEvent (EventInfo &info) {
info.length = 0; info.length = 0;
break; break;
case 0xF: // End of Track messages case 0xF: // Marker and EOT messages
if (info.event == 0xFF)
_autoLoop = true;
info.event = 0xFF;
info.ext.type = 0x2F;
info.length = 0; info.length = 0;
info.ext.data = 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; break;
} }
} }
@ -114,7 +125,7 @@ bool MidiParser_RO::loadMusic (byte *data, uint32 size) {
_num_tracks = 1; _num_tracks = 1;
_ppqn = 120; _ppqn = 120;
_tracks[0] = pos + 2; _tracks[0] = pos + 2;
_markerCount = 0; _markerCount = _lastMarkerCount = 0;
// Note that we assume the original data passed in // Note that we assume the original data passed in
// will persist beyond this call, i.e. we do NOT // will persist beyond this call, i.e. we do NOT

View file

@ -1207,7 +1207,7 @@ int Scumm::scummLoop(int delta) {
// Covered automatically by the Sound class // Covered automatically by the Sound class
} else if (_playerV2) { } else if (_playerV2) {
VAR(VAR_MUSIC_TIMER) = _playerV2->getMusicTimer(); VAR(VAR_MUSIC_TIMER) = _playerV2->getMusicTimer();
} else if (_imuse && _midiDriver != MD_ADLIB) { } else if (_imuse) {
VAR(VAR_MUSIC_TIMER) = _imuse->getMusicTimer(); VAR(VAR_MUSIC_TIMER) = _imuse->getMusicTimer();
} else if (_features & GF_SMALL_HEADER) { } else if (_features & GF_SMALL_HEADER) {
// TODO: The music delay (given in milliseconds) might have to be tuned a little // TODO: The music delay (given in milliseconds) might have to be tuned a little

View file

@ -247,8 +247,9 @@ public:
bool setTrack (int track); bool setTrack (int track);
bool jumpToTick (uint32 tick, bool fireEvents = false); 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_SMF();
static MidiParser *createParser_XMIDI(); static MidiParser *createParser_XMIDI();