Skip to content

Commit

Permalink
SHERLOCK: adlib: in-use timer, thx LordHoto
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Kiewitz committed May 30, 2015
1 parent 4989aff commit 66d0a90
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions engines/sherlock/scalpel/drivers/adlib.cpp
Expand Up @@ -269,8 +269,10 @@ class MidiDriver_AdLib : public MidiDriver_Emulated {
// stores information about all FM voice channels
adlib_ChannelEntry _channels[SHERLOCK_ADLIB_VOICES_COUNT];

void updateChannelInUseTimers();
protected:
void onTimer();

private:
void resetAdLib();
void resetAdLib_OperatorRegisters(byte baseRegister, byte value);
void resetAdLib_FMVoiceChannelRegisters(byte baseRegister, byte value);
Expand Down Expand Up @@ -337,10 +339,10 @@ void MidiDriver_AdLib::setVolume(byte volume) {
//renewNotes(-1, true);
}

// this should normally get called per tick
// but calling it per send() shouldn't be a problem
// TODO: maybe change inUseTimer to a 32-bit integer to make sure there are no overruns?!?!
void MidiDriver_AdLib::updateChannelInUseTimers() {
// this should/must get called per tick
// original driver did this before MIDI data processing on each tick
// we do it atm after MIDI data processing
void MidiDriver_AdLib::onTimer() {
for (byte FMvoiceChannel = 0; FMvoiceChannel < SHERLOCK_ADLIB_VOICES_COUNT; FMvoiceChannel++) {
if (_channels[FMvoiceChannel].inUse) {
_channels[FMvoiceChannel].inUseTimer++;
Expand Down Expand Up @@ -411,8 +413,6 @@ void MidiDriver_AdLib::send(uint32 b) {
byte op1 = (b >> 8) & 0xff;
byte op2 = (b >> 16) & 0xff;

updateChannelInUseTimers();

switch (command) {
case 0x80:
noteOff(channel, op1);
Expand Down

0 comments on commit 66d0a90

Please sign in to comment.