]> 4ch.mooo.com Git - 16.git/blob - 16/adplug/adplug/src/rat.h
wwww~
[16.git] / 16 / adplug / adplug / src / rat.h
1 /*
2  * Adplug - Replayer for many OPL2/OPL3 audio file formats.
3  * Copyright (C) 1999 - 2003 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  * [xad] RAT player, by Riven the Mage <riven@ok.ru>
20  */
21
22 #include "xad.h"
23
24 class CxadratPlayer: public CxadPlayer
25 {
26 public:
27   static CPlayer *factory(Copl *newopl);
28
29   CxadratPlayer(Copl *newopl): CxadPlayer(newopl)
30     { }
31
32 protected:
33   struct rat_header
34   {
35     char            id[3];
36     unsigned char   version;
37     char            title[32];
38     unsigned char   numchan;
39     unsigned char   reserved_25;
40     unsigned char   order_end;
41     unsigned char   reserved_27;
42     unsigned char   numinst;              // ?: Number of Instruments
43     unsigned char   reserved_29;
44     unsigned char   numpat;               // ?: Number of Patterns
45     unsigned char   reserved_2B;
46     unsigned char   order_start;
47     unsigned char   reserved_2D;
48     unsigned char   order_loop;
49     unsigned char   reserved_2F;
50     unsigned char   volume;
51     unsigned char   speed;
52     unsigned char   reserved_32[12];
53     unsigned char   patseg[2];
54   };
55
56   struct rat_event
57   {
58     unsigned char   note;
59     unsigned char   instrument;
60     unsigned char   volume;
61     unsigned char   fx;
62     unsigned char   fxp;
63   };
64
65   struct rat_instrument
66   {
67     unsigned char   freq[2];
68     unsigned char   reserved_2[2];
69     unsigned char   mod_ctrl;
70     unsigned char   car_ctrl;
71     unsigned char   mod_volume;   
72     unsigned char   car_volume;   
73     unsigned char   mod_AD;       
74     unsigned char   car_AD;       
75     unsigned char   mod_SR;       
76     unsigned char   car_SR;       
77     unsigned char   mod_wave;
78     unsigned char   car_wave;
79     unsigned char   connect;
80     unsigned char   reserved_F;
81     unsigned char   volume;
82     unsigned char   reserved_11[3];
83   };
84
85   struct
86   {
87     rat_header      hdr;
88
89     unsigned char   volume;
90     unsigned char   order_pos;
91     unsigned char   pattern_pos;
92
93     unsigned char   *order;
94
95     rat_instrument  *inst;
96
97     rat_event       tracks[256][64][9];
98
99     struct
100     {
101       unsigned char   instrument;
102       unsigned char   volume;
103       unsigned char   fx;
104       unsigned char   fxp;
105     } channel[9];
106   } rat;
107   //
108   bool            xadplayer_load();
109   void            xadplayer_rewind(int subsong);
110   void            xadplayer_update();
111   float           xadplayer_getrefresh();
112   std::string       xadplayer_gettype();
113   std::string     xadplayer_gettitle();
114   unsigned int    xadplayer_getinstruments();
115   //
116 private:
117   static const unsigned char rat_adlib_bases[18];
118   static const unsigned short rat_notes[16];
119
120   unsigned char   __rat_calc_volume(unsigned char ivol, unsigned char cvol, unsigned char gvol);
121 };