ScummVM API documentation
fmopl.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 AUDIO_FMOPL_H
23 #define AUDIO_FMOPL_H
24 
25 #include "audio/chip.h"
26 
27 namespace Audio {
28 class SoundHandle;
29 }
30 
31 namespace Common {
32 class String;
33 }
34 
35 namespace OPL {
36 
37 class OPL;
38 
47 class Config {
48 public:
49  enum OplFlags {
50  kFlagOpl2 = (1 << 0),
51  kFlagDualOpl2 = (1 << 1),
52  kFlagOpl3 = (1 << 2)
53  };
54 
58  enum OplType {
59  kOpl2,
60  kDualOpl2,
61  kOpl3
62  };
63 
64  typedef int8 DriverId;
66  const char *name;
67  const char *description;
68 
69  DriverId id; // A unique ID for each driver
70  uint32 flags; // Capabilities of this driver
71  };
72 
77  static const EmulatorDescription *getAvailable() { return _drivers; }
78 
82  static DriverId parse(const Common::String &name);
83 
88  static const EmulatorDescription *findDriver(DriverId id);
89 
95  static DriverId detect(OplType type);
96 
100  static OPL *create(DriverId driver, OplType type);
101 
106  static OPL *create(OplType type = kOpl2);
107 
108 private:
109  static const EmulatorDescription _drivers[];
110 };
111 
115 class OPL : virtual public Audio::Chip {
116 private:
117  static bool _hasInstance;
118 public:
119  OPL();
120  virtual ~OPL() { _hasInstance = false; }
121 
127  virtual bool init() = 0;
128 
132  virtual void reset() = 0;
133 
140  virtual void write(int a, int v) = 0;
141 
151  virtual void writeReg(int r, int v) = 0;
152 
153  using Audio::Chip::start;
154  void start(TimerCallback *callback) { start(callback, kDefaultCallbackFrequency); }
155 
156  enum {
160  kDefaultCallbackFrequency = 250
161  };
162 
163 protected:
170  void initDualOpl2OnOpl3(Config::OplType oplType);
171 
184  bool emulateDualOpl2OnOpl3(int r, int v, Config::OplType oplType);
185 
186  bool _rhythmMode;
187  int _connectionFeedbackValues[3];
188 };
189 
191 } // End of namespace OPL
192 
193 #endif
Definition: str.h:59
void start(TimerCallback *callback, int timerFrequency)
static const EmulatorDescription * getAvailable()
Definition: fmopl.h:77
Definition: fmopl.h:47
Definition: chip.h:33
OplType
Definition: fmopl.h:58
Definition: algorithm.h:29
Definition: fmopl.h:35
Definition: fmopl.h:65
Definition: system.h:38