diff options
author | Walter van Niftrik | 2015-06-28 15:58:46 -0400 |
---|---|---|
committer | Matthew Hoops | 2015-07-07 20:19:46 -0400 |
commit | b367ea548d7c129e14fec6164ebe5610d3edeb46 (patch) | |
tree | 91a73382f2ee624299005892fe65ee57bf34b873 /engines/queen/midiadlib.h | |
parent | e31da911c98824b746d8804a63df9695216bc08e (diff) | |
download | scummvm-rg350-b367ea548d7c129e14fec6164ebe5610d3edeb46.tar.gz scummvm-rg350-b367ea548d7c129e14fec6164ebe5610d3edeb46.tar.bz2 scummvm-rg350-b367ea548d7c129e14fec6164ebe5610d3edeb46.zip |
QUEEN: Implement original music volume handling
Diffstat (limited to 'engines/queen/midiadlib.h')
-rw-r--r-- | engines/queen/midiadlib.h | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/engines/queen/midiadlib.h b/engines/queen/midiadlib.h new file mode 100644 index 0000000000..d5590253cb --- /dev/null +++ b/engines/queen/midiadlib.h @@ -0,0 +1,130 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "audio/fmopl.h" +#include "audio/mididrv.h" +#include "audio/softsynth/emumidi.h" + +namespace Queen { + +class AdLibMidiDriver : public MidiDriver_Emulated { +public: + + AdLibMidiDriver(Audio::Mixer *mixer) : MidiDriver_Emulated(mixer) { _adlibWaveformSelect = 0; } + ~AdLibMidiDriver() {} + + // MidiDriver + int open(); + void close(); + void send(uint32 b); + void metaEvent(byte type, byte *data, uint16 length); + MidiChannel *allocateChannel() { return 0; } + MidiChannel *getPercussionChannel() { return 0; } + void setTimerCallback(void *timerParam, Common::TimerManager::TimerProc timerProc); + + // AudioStream + int readBuffer(int16 *data, const int numSamples); + bool isStereo() const { return false; } + int getRate() const { return _mixer->getOutputRate(); } + + // MidiDriver_Emulated + void generateSamples(int16 *buf, int len); + + void setVolume(uint32 volume); + +private: + + void handleMidiEvent0x90_NoteOn(int channel, int param1, int param2); + void handleSequencerSpecificMetaEvent1(int channel, const uint8 *data); + void handleSequencerSpecificMetaEvent2(uint8 value); + void handleSequencerSpecificMetaEvent3(uint8 value); + + void adlibWrite(uint8 port, uint8 value); + void adlibSetupCard(); + void adlibSetupChannels(int fl); + void adlibResetAmpVibratoRhythm(int am, int vib, int kso); + void adlibResetChannels(); + void adlibSetAmpVibratoRhythm(); + void adlibSetCSMKeyboardSplit(); + void adlibSetNoteMul(int mul); + void adlibSetWaveformSelect(int fl); + void adlibSetPitchBend(int channel, int range); + void adlibPlayNote(int channel); + uint8 adlibPlayNoteHelper(int channel, int note1, int note2, int oct); + void adlibTurnNoteOff(int channel); + void adlibTurnNoteOn(int channel, int note); + void adlibSetupChannelFromSequence(int channel, const uint8 *src, int fl); + void adlibSetupChannel(int channel, const uint16 *src, int fl); + void adlibSetChannelVolume(int channel, uint8 volume); + void adlibSetNoteVolume(int channel, int volume); + void adlibSetupChannelHelper(int channel); + void adlibSetChannel0x40(int channel); + void adlibSetChannel0xC0(int channel); + void adlibSetChannel0x60(int channel); + void adlibSetChannel0x80(int channel); + void adlibSetChannel0x20(int channel); + void adlibSetChannel0xE0(int channel); + + void onTimer(); + + OPL::OPL *_opl; + int _midiNumberOfChannels; + int _adlibNoteMul; + int _adlibWaveformSelect; + int _adlibAMDepthEq48; + int _adlibVibratoDepthEq14; + int _adlibRhythmEnabled; + int _adlibKeyboardSplitOn; + int _adlibVibratoRhythm; + uint8 _midiChannelsFreqTable[9]; + uint8 _adlibChannelsLevelKeyScalingTable[11]; + uint8 _adlibSetupChannelSequence1[14 * 18]; + uint16 _adlibSetupChannelSequence2[14]; + int16 _midiChannelsNote2Table[9]; + uint8 _midiChannelsNote1Table[9]; + uint8 _midiChannelsOctTable[9]; + uint16 _adlibChannelsVolume[11]; + uint16 _adlibMetaSequenceData[28]; + uint8 _adlibChannelsVolumeTable[11]; + + Common::TimerManager::TimerProc _adlibTimerProc; + void *_adlibTimerParam; + + static const uint8 _adlibChannelsMappingTable1[]; + static const uint8 _adlibChannelsNoFeedback[]; + static const uint8 _adlibChannelsMappingTable2[]; + static const uint8 _adlibChannelsMappingTable3[]; + static const uint8 _adlibChannelsKeyScalingTable1[]; + static const uint8 _adlibChannelsKeyScalingTable2[]; + static const uint8 _adlibInitSequenceData1[]; + static const uint8 _adlibInitSequenceData2[]; + static const uint8 _adlibInitSequenceData3[]; + static const uint8 _adlibInitSequenceData4[]; + static const uint8 _adlibInitSequenceData5[]; + static const uint8 _adlibInitSequenceData6[]; + static const uint8 _adlibInitSequenceData7[]; + static const uint8 _adlibInitSequenceData8[]; + static const int16 _midiChannelsNoteTable[]; + static const int16 _midiNoteFreqTable[]; +}; + +} // End of namespace Queen |