ScummVM API documentation
sound_driver_adlib.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef MM_SHARED_XEEN_SOUND_DRIVER_ADLIB_H
23 #define MM_SHARED_XEEN_SOUND_DRIVER_ADLIB_H
24 
25 #include "audio/mididrv.h"
26 #include "mm/shared/xeen/sound_driver.h"
27 
28 namespace OPL {
29  class OPL;
30 }
31 
32 namespace MM {
33 namespace Shared {
34 namespace Xeen {
35 
36 class SoundDriverAdlib : public SoundDriver {
37  struct RegisterValue {
38  uint8 _regNum;
39  uint8 _value;
40 
41  RegisterValue(int regNum, int value) {
42  _regNum = regNum; _value = value;
43  }
44  };
45 private:
46  static const byte OPERATOR1_INDEXES[CHANNEL_COUNT];
47  static const byte OPERATOR2_INDEXES[CHANNEL_COUNT];
48  static const uint WAVEFORMS[24];
49 private:
50  OPL::OPL *_opl;
52  Common::Mutex _driverMutex;
53  const byte *_musInstrumentPtrs[16];
54  const byte *_fxInstrumentPtrs[16];
55  int _field180;
56  int _field181;
57  int _field182;
58  int _musicVolume, _sfxVolume;
59 private:
63  void initialize();
64 
69  void write(int reg, int val);
70 
74  void onTimer();
75 
79  void flush();
80 
84  void resetFrequencies();
85 
89  void setFrequency(byte operatorNum, uint frequency);
90 
94  uint calcFrequency(byte note);
95 
99  void setOutputLevel(byte channelNum, uint level);
100 
104  void playInstrument(byte channelNum, const byte *data, bool isFx);
105 
109  byte calculateLevel(byte level, bool isFx);
110 
111 protected:
112  bool musSetInstrument(const byte *&srcP, byte param) override;
113  bool musSetPitchWheel(const byte *&srcP, byte param) override;
114  bool musSetPanning(const byte *&srcP, byte param) override;
115  bool musFade(const byte *&srcP, byte param) override;
116  bool musStartNote(const byte *&srcP, byte param) override;
117  bool musSetVolume(const byte *&srcP, byte param) override;
118  bool musInjectMidi(const byte *&srcP, byte param) override;
119  bool musPlayInstrument(const byte *&srcP, byte param) override;
120  bool cmdFreezeFrequency(const byte *&srcP, byte param) override;
121  bool cmdChangeFrequency(const byte *&srcP, byte param) override;
122 
123  bool fxSetInstrument(const byte *&srcP, byte param) override;
124  bool fxSetVolume(const byte *&srcP, byte param) override;
125  bool fxMidiReset(const byte *&srcP, byte param) override;
126  bool fxMidiDword(const byte *&srcP, byte param) override;
127  bool fxSetPanning(const byte *&srcP, byte param) override;
128  bool fxChannelOff(const byte *&srcP, byte param) override;
129  bool fxFade(const byte *&srcP, byte param) override;
130  bool fxStartNote(const byte *&srcP, byte param) override;
131  bool fxInjectMidi(const byte *&srcP, byte param) override;
132  bool fxPlayInstrument(const byte *&srcP, byte param) override;
133 
137  void pausePostProcess() override;
138 
142  void resetFX() override;
143 
147  void sysExMessage(const byte *&data) override;
148 public:
153 
157  ~SoundDriverAdlib() override;
158 
162  void playFX(uint effectId, const byte *data) override;
163 
167  void playSong(const byte *data) override;
168 
172  int songCommand(uint commandId, byte musicVolume = 0, byte sfxVolume = 0) override;
173 };
174 
175 } // namespace Xeen
176 } // namespace Shared
177 } // namespace MM
178 
179 #endif
Definition: detection.h:27
Definition: mutex.h:67
Definition: sound_driver_adlib.h:36
Definition: fmopl.h:35
Definition: sound_driver.h:56
Definition: fmopl.h:115