]> 4ch.mooo.com Git - 16.git/blob - 16/adplug/adplug/src/a2m.h
renamed: 16/adplug/adplug-2.2.1/.DS_Store -> 16/adplug/adplug/.DS_Store
[16.git] / 16 / adplug / adplug / src / a2m.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  * a2m.h - A2M Loader by Simon Peter <dn.tlp@gmx.net>
20  */
21
22 #ifndef H_ADPLUG_A2MLOADER
23 #define H_ADPLUG_A2MLOADER
24
25 #include "protrack.h"
26
27 class Ca2mLoader: public CmodPlayer
28 {
29 public:
30   static CPlayer *factory(Copl *newopl);
31
32   Ca2mLoader(Copl *newopl): CmodPlayer(newopl)
33     { }
34
35   bool load(const std::string &filename, const CFileProvider &fp);
36   float getrefresh();
37
38   std::string gettype()
39     { return std::string("AdLib Tracker 2"); }
40   std::string gettitle()
41     { if(*songname) return std::string(songname,1,*songname); else return std::string(); }
42   std::string getauthor()
43     { if(*author) return std::string(author,1,*author); else return std::string(); }
44   unsigned int getinstruments()
45     { return 250; }
46   std::string getinstrument(unsigned int n)
47     { return std::string(instname[n],1,*instname[n]); }
48
49 private:
50
51 #define ADPLUG_A2M_COPYRANGES           6
52 #define ADPLUG_A2M_FIRSTCODE            257
53 #define ADPLUG_A2M_MINCOPY              3
54 #define ADPLUG_A2M_MAXCOPY              255
55 #define ADPLUG_A2M_CODESPERRANGE        (ADPLUG_A2M_MAXCOPY - ADPLUG_A2M_MINCOPY + 1)
56 #define ADPLUG_A2M_MAXCHAR              (ADPLUG_A2M_FIRSTCODE + ADPLUG_A2M_COPYRANGES * ADPLUG_A2M_CODESPERRANGE - 1)
57 #define ADPLUG_A2M_TWICEMAX             (2 * ADPLUG_A2M_MAXCHAR + 1)
58
59   static const unsigned int MAXFREQ, MINCOPY, MAXCOPY, COPYRANGES,
60     CODESPERRANGE, TERMINATE, FIRSTCODE, MAXCHAR, SUCCMAX, TWICEMAX, ROOT,
61     MAXBUF, MAXDISTANCE, MAXSIZE;
62
63   static const unsigned short bitvalue[14];
64   static const signed short copybits[ADPLUG_A2M_COPYRANGES],
65     copymin[ADPLUG_A2M_COPYRANGES];
66
67   void inittree();
68   void updatefreq(unsigned short a,unsigned short b);
69   void updatemodel(unsigned short code);
70   unsigned short inputcode(unsigned short bits);
71   unsigned short uncompress();
72   void decode();
73   unsigned short sixdepak(unsigned short *source,unsigned char *dest,unsigned short size);
74
75   char songname[43], author[43], instname[250][33];
76
77   unsigned short ibitcount, ibitbuffer, ibufcount, obufcount, input_size,
78     output_size, leftc[ADPLUG_A2M_MAXCHAR+1], rghtc[ADPLUG_A2M_MAXCHAR+1],
79     dad[ADPLUG_A2M_TWICEMAX+1], freq[ADPLUG_A2M_TWICEMAX+1], *wdbuf;
80   unsigned char *obuf, *buf;
81 };
82
83 #endif