Skip to content

Commit

Permalink
SHERLOCK: RT: Miles AdLib: circular phys. assign
Browse files Browse the repository at this point in the history
implements circular physical assignment of FM-voices,
which was enabled for Rose Tattoo.

This is not really needed, but by implementing it assigned
physical FM-voices should exactly match the original driver.
  • Loading branch information
Martin Kiewitz committed Jun 26, 2015
1 parent 9bbeaa6 commit 258b5ad
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions engines/sherlock/tattoo/drivers/tattoo_adlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ class MidiDriver_Miles_AdLib : public MidiDriver_Emulated {
InstrumentEntry *_instrumentTablePtr;
uint16 _instrumentTableCount;

bool circularPhysicalAssignment;
byte circularPhysicalAssignmentFmVoice;

protected:
void onTimer();

Expand Down Expand Up @@ -249,6 +252,11 @@ MidiDriver_Miles_AdLib::MidiDriver_Miles_AdLib(Audio::Mixer *mixer, InstrumentEn
_instrumentTablePtr = instrumentTablePtr;
_instrumentTableCount = instrumentTableCount;

// Older Miles Audio drivers did not do a circular assign for physical FM-voices
// Sherlock Holmes 2 used the circular assign
circularPhysicalAssignment = true;
circularPhysicalAssignmentFmVoice = 255;

resetData();
}

Expand Down Expand Up @@ -394,9 +402,25 @@ int16 MidiDriver_Miles_AdLib::searchFreeVirtualFmVoiceChannel() {
}

int16 MidiDriver_Miles_AdLib::searchFreePhysicalFmVoiceChannel() {
for (byte physicalFmVoice = 0; physicalFmVoice < SHERLOCK_MILES_ADLIB_PHYSICAL_FMVOICES_COUNT; physicalFmVoice++) {
if (!_physicalFmVoices[physicalFmVoice].inUse)
return physicalFmVoice;
if (!circularPhysicalAssignment) {
// Older assign logic
for (byte physicalFmVoice = 0; physicalFmVoice < SHERLOCK_MILES_ADLIB_PHYSICAL_FMVOICES_COUNT; physicalFmVoice++) {
if (!_physicalFmVoices[physicalFmVoice].inUse)
return physicalFmVoice;
}
} else {
// Newer one
// Remembers last physical FM-voice and searches from that spot
byte physicalFmVoice = circularPhysicalAssignmentFmVoice;
for (byte physicalFmVoiceCount = 0; physicalFmVoiceCount < SHERLOCK_MILES_ADLIB_PHYSICAL_FMVOICES_COUNT; physicalFmVoiceCount++) {
physicalFmVoice++;
if (physicalFmVoice >= SHERLOCK_MILES_ADLIB_PHYSICAL_FMVOICES_COUNT)
physicalFmVoice = 0;
if (!_physicalFmVoices[physicalFmVoice].inUse) {
circularPhysicalAssignmentFmVoice = physicalFmVoice;
return physicalFmVoice;
}
}
}
return -1;
}
Expand Down

0 comments on commit 258b5ad

Please sign in to comment.