]> 4ch.mooo.com Git - 16.git/blob - 16/adplug/adplug/src/realopl.h
wwww~
[16.git] / 16 / adplug / adplug / src / realopl.h
1 /*
2  * AdPlug - Replayer for many OPL2/OPL3 audio file formats.
3  * Copyright (C) 1999 - 2005 Simon Peter <dn.tlp@gmx.net>, et al.
4  * 
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * 
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  * 
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  * realopl.h - Real hardware OPL, by Simon Peter <dn.tlp@gmx.net>
20  */
21
22 #ifndef H_ADPLUG_REALOPL
23 #define H_ADPLUG_REALOPL
24
25 #include "opl.h"
26
27 #define DFL_ADLIBPORT   0x388           // default adlib baseport
28
29 class CRealopl: public Copl
30 {
31  public:        
32   CRealopl(unsigned short initport = DFL_ADLIBPORT);    // initport = OPL2 hardware baseport
33
34   bool detect();                        // returns true if adlib compatible board is found, else false
35   void setvolume(int volume);           // set adlib master volume (0 - 63) 0 = loudest, 63 = softest
36   void setquiet(bool quiet = true);     // sets the OPL2 quiet, while still writing to the registers
37   void setport(unsigned short port)     // set new OPL2 hardware baseport
38     {
39       adlport = port;
40     }
41   void setnowrite(bool nw = true)       // set hardware write status
42     {
43       nowrite = nw;
44     }
45
46   int getvolume()                       // get adlib master volume
47     {
48       return hardvol;
49     }
50
51   // template methods
52   void write(int reg, int val);
53   void init();
54   void settype(ChipType type)
55     {
56       currType = type;
57     }
58
59  protected:
60   void hardwrite(int reg, int val);             // write to OPL2 hardware registers
61   bool harddetect();                            // do real hardware detection
62
63   static const unsigned char op_table[9];       // the 9 operators as expected by the OPL2
64
65   unsigned short        adlport;                // adlib hardware baseport
66   int                   hardvol, oldvol;        // hardware master volume
67   bool                  bequiet;                // quiet status cache
68   char                  hardvols[2][22][2];     // volume cache
69   bool                  nowrite;                // don't write to hardware, if true
70 };
71
72 #endif