diff options
author | Willem Jan Palenstijn | 2015-07-22 22:37:40 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-07-22 22:43:42 +0200 |
commit | 6ec9c81b575f13b2c4b30aeac592ebf2557b5890 (patch) | |
tree | 503d50902bad2d800165593039d08d5ccf0c98ab /engines/parallaction/adlib.cpp | |
parent | 5ec05f6b647c5ea41418be7ed19ad381f97cabd8 (diff) | |
parent | 4e5c8d35f7e133e2e72a846fdbd54900c91eeb73 (diff) | |
download | scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.gz scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.bz2 scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.zip |
Merge branch 'master' into mm
Conflicts:
engines/access/access.cpp
engines/access/asurface.h
engines/access/bubble_box.cpp
engines/access/bubble_box.h
engines/access/martian/martian_game.cpp
engines/access/player.cpp
engines/access/player.h
engines/access/resources.cpp
engines/access/screen.cpp
engines/access/screen.h
engines/access/sound.cpp
engines/access/sound.h
Diffstat (limited to 'engines/parallaction/adlib.cpp')
-rw-r--r-- | engines/parallaction/adlib.cpp | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/engines/parallaction/adlib.cpp b/engines/parallaction/adlib.cpp index 7c1dd1681f..568ad190aa 100644 --- a/engines/parallaction/adlib.cpp +++ b/engines/parallaction/adlib.cpp @@ -25,7 +25,7 @@ #include "audio/fmopl.h" #include "audio/mpu401.h" -#include "audio/softsynth/emumidi.h" +#include "audio/mididrv.h" namespace Parallaction { @@ -270,11 +270,13 @@ struct MelodicVoice { int8 _octave; }; -class AdLibDriver : public MidiDriver_Emulated { +class AdLibDriver : public MidiDriver { public: - AdLibDriver(Audio::Mixer *mixer) : MidiDriver_Emulated(mixer) { + AdLibDriver(Audio::Mixer *mixer) { for (uint i = 0; i < 16; ++i) _channels[i].init(this, i); + + _isOpen = false; } int open(); @@ -282,11 +284,13 @@ public: void send(uint32 b); MidiChannel *allocateChannel(); MidiChannel *getPercussionChannel() { return &_channels[9]; } + bool isOpen() const { return _isOpen; } + uint32 getBaseTempo() { return 1000000 / OPL::OPL::kDefaultCallbackFrequency; } - bool isStereo() const { return false; } - int getRate() const { return _mixer->getOutputRate(); } - - void generateSamples(int16 *buf, int len); + virtual void setTimerCallback(void *timerParam, Common::TimerManager::TimerProc timerProc) { + _adlibTimerProc = timerProc; + _adlibTimerParam = timerParam; + } protected: OPL::OPL *_opl; @@ -320,6 +324,13 @@ protected: void muteMelodicVoice(uint8 voice); void initVoices(); + +private: + void onTimer(); + + Common::TimerManager::TimerProc _adlibTimerProc; + void *_adlibTimerParam; + bool _isOpen; }; MidiDriver *createAdLibDriver() { @@ -348,10 +359,10 @@ int AdLibDriver::open() { if (_isOpen) return MERR_ALREADY_OPEN; - MidiDriver_Emulated::open(); + _isOpen = true; _opl = OPL::Config::create(); - _opl->init(getRate()); + _opl->init(); _opl->writeReg(0x1, 0x20); // set bit 5 (enable all waveforms) // Reset the OPL registers. @@ -364,7 +375,7 @@ int AdLibDriver::open() { initVoices(); - _mixer->playStream(Audio::Mixer::kMusicSoundType, &_mixerSoundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); + _opl->start(new Common::Functor0Mem<void, AdLibDriver>(this, &AdLibDriver::onTimer)); return 0; } @@ -373,7 +384,6 @@ void AdLibDriver::close() { return; _isOpen = false; - _mixer->stopHandle(_mixerSoundHandle); delete _opl; } @@ -777,9 +787,9 @@ MidiChannel *AdLibDriver::allocateChannel() { return NULL; } -void AdLibDriver::generateSamples(int16 *buf, int len) { - memset(buf, 0, sizeof(int16) * len); - _opl->readBuffer(buf, len); +void AdLibDriver::onTimer() { + if (_adlibTimerProc) + (*_adlibTimerProc)(_adlibTimerParam); } void AdLibDriver::initVoices() { |