mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-04 09:18:38 +00:00
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:
parent
61162bf359
commit
d7fae3d1cb
@ -329,7 +329,7 @@ int IMuseInternal::getMusicTimer() {
|
||||
best_time = timer;
|
||||
}
|
||||
}
|
||||
return best_time / 1000000;
|
||||
return best_time;
|
||||
}
|
||||
|
||||
void IMuseInternal::sequencer_timers(MidiDriver *midi) {
|
||||
|
@ -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
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user