]> 4ch.mooo.com Git - 16.git/blob - 16/adplug/adplug/src/jbm.h
wwww~
[16.git] / 16 / adplug / adplug / src / jbm.h
1 /*
2  * Adplug - Replayer for many OPL2/OPL3 audio file formats.
3  * Copyright (C) 1999 - 2007 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  * jbm.h - JBM Player by Dennis Lindroos <lindroos@nls.fi>
20  */
21
22 #ifndef H_ADPLUG_JBMPLAYER
23 #define H_ADPLUG_JBMPLAYER
24
25 #include "player.h"
26
27 class CjbmPlayer: public CPlayer
28 {
29  public:
30   static CPlayer *factory(Copl *newopl);
31
32   CjbmPlayer(Copl *newopl) : CPlayer(newopl), m(0)
33     { }
34   ~CjbmPlayer()
35     { if(m != NULL) delete [] m; }
36
37   bool load(const std::string &filename, const CFileProvider &fp);
38   bool update();
39   void rewind(int subsong);
40
41   float getrefresh()
42     { return timer; }
43
44   std::string gettype()
45     {
46       return std::string(flags&1 ? "JBM Adlib Music [rhythm mode]" :
47                          "JBM Adlib Music");
48     }
49   std::string getauthor()
50     { return std::string("Johannes Bjerregaard"); }
51
52  protected:
53
54   unsigned char *m;
55   float timer;
56   unsigned short flags, voicemask;
57   unsigned short seqtable, seqcount;
58   unsigned short instable, inscount;
59   unsigned short *sequences;
60   unsigned char bdreg; 
61
62   typedef struct {
63     unsigned short trkpos, trkstart, seqpos;
64     unsigned char seqno, note;
65     short vol;
66     short delay;
67     short instr;
68     unsigned char frq[2];
69     unsigned char ivol, dummy;
70   } JBMVoice;
71
72   JBMVoice voice[11];
73
74  private:
75   //void calc_opl_frequency(JBMVoice *);
76   void set_opl_instrument(int, JBMVoice *); 
77   void opl_noteonoff(int, JBMVoice *, bool);
78 };
79
80 #endif