AGOS: Add option for Simon 1 DOS tempos to parsers

The DOS version of Simon 1 has different music tempos compared to the Windows
version. This commit adds the option to both the DOS and Windows MIDI parsers
to use either the DOS or Windows tempos.
This commit is contained in:
Coen Rampen 2022-04-23 20:18:08 +02:00
parent a0ffa1e005
commit 97745050c2
4 changed files with 22 additions and 13 deletions

View File

@ -25,7 +25,7 @@
namespace AGOS {
MidiParser_GMF::MidiParser_GMF(int8 source) : MidiParser_SMF(source) {
MidiParser_GMF::MidiParser_GMF(int8 source, bool useDosTempos) : MidiParser_SMF(source), _useDosTempos(useDosTempos) {
memset(_tracksEndPos, 0, 120);
}
@ -164,14 +164,19 @@ bool MidiParser_GMF::loadMusic(byte *data, uint32 size) {
_autoLoop = headerLoop;
_ppqn = 192;
// These translations from the GMF header tempo (2-8) to the SMF tempo have
// been determined by measuring the tempos generated by the DOS version of
// Simon 1 in DOSBox.
uint32 tempo;
if (headerTempo < 6) {
tempo = 330000 + ((headerTempo - 2) * 105000);
if (_useDosTempos) {
// These translations from the GMF header tempo (2-8) to the SMF tempo have
// been determined by measuring the tempos generated by the DOS version of
// Simon 1 in DOSBox.
if (headerTempo < 6) {
tempo = 330000 + ((headerTempo - 2) * 105000);
} else {
tempo = 750000 + ((headerTempo - 6) * 125000);
}
} else {
tempo = 750000 + ((headerTempo - 6) * 125000);
// These are the tempos as specified in the Windows version SMF data.
tempo = headerTempo * 125000;
}
setTempo(tempo);

View File

@ -36,7 +36,7 @@ namespace AGOS {
*/
class MidiParser_GMF : public MidiParser_SMF {
public:
MidiParser_GMF(int8 source = -1);
MidiParser_GMF(int8 source = -1, bool useDosTempos = false);
bool loadMusic(byte *data, uint32 size) override;
@ -46,6 +46,10 @@ protected:
// The end position of each track, exclusive
// (i.e. 1 byte past the end of the data).
byte *_tracksEndPos[MAXIMUM_TRACKS];
// True if the music tempos from the DOS version should be used; false if
// the tempos from the Windows version should be used.
bool _useDosTempos;
};
} // End of namespace AGOS

View File

@ -25,8 +25,8 @@
namespace AGOS {
MidiParser_SimonWin::MidiParser_SimonWin(int8 source, bool correctSimon1Tempo) :
MidiParser_SMF(source), _trackData(), _correctSimon1Tempo(correctSimon1Tempo) { }
MidiParser_SimonWin::MidiParser_SimonWin(int8 source, bool useDosTempos) :
MidiParser_SMF(source), _trackData(), _useDosTempos(useDosTempos) { }
MidiParser_SimonWin::~MidiParser_SimonWin() {
// Call unloadMusic to make sure any _trackData contents are deallocated.
@ -61,7 +61,7 @@ void MidiParser_SimonWin::parseNextEvent(EventInfo &info) {
void MidiParser_SimonWin::setTempo(uint32 tempo) {
uint32 newTempo = tempo;
if (_correctSimon1Tempo && tempo < 750000) {
if (_useDosTempos && tempo < 750000) {
// WORKAROUND The tempos set in the SMF data of Simon 1 Windows are
// faster than the DOS version for the faster tempos. These are
// corrected here to match the DOS version. The correct tempos have

View File

@ -42,7 +42,7 @@ protected:
public:
int32 determineDataSize(Common::SeekableReadStream *stream) override;
MidiParser_SimonWin(int8 source = -1, bool correctSimon1Tempo = false);
MidiParser_SimonWin(int8 source = -1, bool useDosTempos = false);
~MidiParser_SimonWin();
void setTempo(uint32 tempo) override;
@ -55,7 +55,7 @@ protected:
byte *_trackData[MAXIMUM_TRACKS];
bool _correctSimon1Tempo;
bool _useDosTempos;
};
} // End of namespace AGOS