aboutsummaryrefslogtreecommitdiff
path: root/engines/agos
diff options
context:
space:
mode:
authorMatthew Hoops2015-06-22 01:48:03 -0400
committerMatthew Hoops2015-07-07 20:19:45 -0400
commit0c5d40e94c6f10d63763a72c70d06fe2fa15de29 (patch)
tree877190f44e43527f59986dab225ff30129067e8f /engines/agos
parentdcb75fcaf12ebf194e0b68e841c3eee9739e4d1e (diff)
downloadscummvm-rg350-0c5d40e94c6f10d63763a72c70d06fe2fa15de29.tar.gz
scummvm-rg350-0c5d40e94c6f10d63763a72c70d06fe2fa15de29.tar.bz2
scummvm-rg350-0c5d40e94c6f10d63763a72c70d06fe2fa15de29.zip
AGOS: Use the built-in OPL timer
Diffstat (limited to 'engines/agos')
-rw-r--r--engines/agos/drivers/accolade/adlib.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/engines/agos/drivers/accolade/adlib.cpp b/engines/agos/drivers/accolade/adlib.cpp
index 61f209b063..33a7595a89 100644
--- a/engines/agos/drivers/accolade/adlib.cpp
+++ b/engines/agos/drivers/accolade/adlib.cpp
@@ -125,6 +125,7 @@ public:
MidiChannel *getPercussionChannel() { return NULL; }
// AudioStream
+ int readBuffer(int16 *data, const int numSamples);
bool isStereo() const { return false; }
int getRate() const { return _mixer->getOutputRate(); }
int getPolyphony() const { return AGOS_ADLIB_VOICES_COUNT; }
@@ -138,6 +139,8 @@ public:
bool setupInstruments(byte *instrumentData, uint16 instrumentDataSize, bool useMusicDrvFile);
+ void setTimerCallback(void *timerParam, Common::TimerManager::TimerProc timerProc);
+
private:
bool _musicDrvMode;
@@ -170,16 +173,17 @@ private:
OPL::OPL *_opl;
int _masterVolume;
+ Common::TimerManager::TimerProc _adlibTimerProc;
+ void *_adlibTimerParam;
+
// points to a MIDI channel for each of the new voice channels
byte _voiceChannelMapping[AGOS_ADLIB_VOICES_COUNT];
// stores information about all FM voice channels
ChannelEntry _channels[AGOS_ADLIB_VOICES_COUNT];
-protected:
void onTimer();
-private:
void resetAdLib();
void resetAdLibOperatorRegisters(byte baseRegister, byte value);
void resetAdLibFMVoiceChannelRegisters(byte baseRegister, byte value);
@@ -193,7 +197,8 @@ private:
};
MidiDriver_Accolade_AdLib::MidiDriver_Accolade_AdLib(Audio::Mixer *mixer)
- : MidiDriver_Emulated(mixer), _masterVolume(15), _opl(0) {
+ : MidiDriver_Emulated(mixer), _masterVolume(15), _opl(0),
+ _adlibTimerProc(0), _adlibTimerParam(0) {
memset(_channelMapping, 0, sizeof(_channelMapping));
memset(_instrumentMapping, 0, sizeof(_instrumentMapping));
memset(_instrumentVolumeAdjust, 0, sizeof(_instrumentVolumeAdjust));
@@ -224,6 +229,7 @@ int MidiDriver_Accolade_AdLib::open() {
MidiDriver_Emulated::open();
+ _opl->start(new Common::Functor0Mem<void, MidiDriver_Accolade_AdLib>(this, &MidiDriver_Accolade_AdLib::onTimer));
_mixer->playStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO);
resetAdLib();
@@ -269,6 +275,8 @@ void MidiDriver_Accolade_AdLib::setVolume(byte volume) {
}
void MidiDriver_Accolade_AdLib::onTimer() {
+ if (_adlibTimerProc)
+ (*_adlibTimerProc)(_adlibTimerParam);
}
void MidiDriver_Accolade_AdLib::resetAdLib() {
@@ -367,7 +375,16 @@ void MidiDriver_Accolade_AdLib::send(uint32 b) {
}
void MidiDriver_Accolade_AdLib::generateSamples(int16 *data, int len) {
- _opl->readBuffer(data, len);
+ // Dummy implementation until we no longer inherit from MidiDriver_Emulated
+}
+
+int MidiDriver_Accolade_AdLib::readBuffer(int16 *data, const int numSamples) {
+ return _opl->readBuffer(data, numSamples);
+}
+
+void MidiDriver_Accolade_AdLib::setTimerCallback(void *timerParam, Common::TimerManager::TimerProc timerProc) {
+ _adlibTimerProc = timerProc;
+ _adlibTimerParam = timerParam;
}
void MidiDriver_Accolade_AdLib::noteOn(byte FMvoiceChannel, byte note, byte velocity) {