2 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
3 * Copyright (C) 1999 - 2007 Simon Peter, <dn.tlp@gmx.net>, et al.
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.
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.
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
19 * a2m.h - A2M Loader by Simon Peter <dn.tlp@gmx.net>
22 #ifndef H_ADPLUG_A2MLOADER
23 #define H_ADPLUG_A2MLOADER
27 class Ca2mLoader: public CmodPlayer
30 static CPlayer *factory(Copl *newopl);
32 Ca2mLoader(Copl *newopl): CmodPlayer(newopl)
35 bool load(const std::string &filename, const CFileProvider &fp);
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()
46 std::string getinstrument(unsigned int n)
47 { return std::string(instname[n],1,*instname[n]); }
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)
59 static const unsigned int MAXFREQ, MINCOPY, MAXCOPY, COPYRANGES,
60 CODESPERRANGE, TERMINATE, FIRSTCODE, MAXCHAR, SUCCMAX, TWICEMAX, ROOT,
61 MAXBUF, MAXDISTANCE, MAXSIZE;
63 static const unsigned short bitvalue[14];
64 static const signed short copybits[ADPLUG_A2M_COPYRANGES],
65 copymin[ADPLUG_A2M_COPYRANGES];
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();
73 unsigned short sixdepak(unsigned short *source,unsigned char *dest,unsigned short size);
75 char songname[43], author[43], instname[250][33];
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;