]> 4ch.mooo.com Git - 16.git/blob - 16/adplug/adplug/src/protrack.h
wwww~
[16.git] / 16 / adplug / adplug / src / protrack.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  * protrack.h - Generic Protracker Player by Simon Peter <dn.tlp@gmx.net>
20  */
21
22 #ifndef H_PROTRACK
23 #define H_PROTRACK
24
25 #include "player.h"
26
27 class CmodPlayer: public CPlayer
28 {
29 public:
30   CmodPlayer(Copl *newopl);
31   virtual ~CmodPlayer();
32
33   bool update();
34   void rewind(int subsong);
35   float getrefresh();
36
37   unsigned int getpatterns()
38     { return nop; }
39   unsigned int getpattern()
40     { return order[ord]; }
41   unsigned int getorders()
42     { return length; }
43   unsigned int getorder()
44     { return ord; }
45   unsigned int getrow()
46     { return rw; }
47   unsigned int getspeed()
48     { return speed; }
49
50  protected:
51   enum Flags {
52     Standard = 0,
53     Decimal = 1 << 0,
54     Faust = 1 << 1,
55     NoKeyOn = 1 << 2,
56     Opl3 = 1 << 3,
57     Tremolo = 1 << 4,
58     Vibrato = 1 << 5,
59     Percussion = 1 << 6
60   };
61
62   struct Instrument {
63     unsigned char data[11],arpstart,arpspeed,arppos,arpspdcnt,misc;
64     signed char slide;
65   } *inst;
66
67   struct Tracks {
68     unsigned char note,command,inst,param2,param1;
69   } **tracks;
70
71   unsigned char *order, *arplist, *arpcmd, initspeed;
72   unsigned short tempo, **trackord, bpm, nop;
73   unsigned long length, restartpos, activechan;
74   int flags, curchip;
75
76   struct Channel {
77     unsigned short freq,nextfreq;
78     unsigned char oct,vol1,vol2,inst,fx,info1,info2,key,nextoct,
79       note,portainfo,vibinfo1,vibinfo2,arppos,arpspdcnt;
80     signed char trigger;
81   } *channel;
82
83   void init_trackord();
84   bool init_specialarp();
85   void init_notetable(const unsigned short *newnotetable);
86   bool realloc_order(unsigned long len);
87   bool realloc_patterns(unsigned long pats, unsigned long rows, unsigned long chans);
88   bool realloc_instruments(unsigned long len);
89
90   void dealloc();
91
92  private:
93   static const unsigned short sa2_notetable[12];
94   static const unsigned char vibratotab[32];
95
96   unsigned char speed, del, songend, regbd;
97   unsigned short rows, notetable[12];
98   unsigned long rw, ord, nrows, npats, nchans;
99
100   void setvolume(unsigned char chan);
101   void setvolume_alt(unsigned char chan);
102   void setfreq(unsigned char chan);
103   void playnote(unsigned char chan);
104   void setnote(unsigned char chan, int note);
105   void slide_down(unsigned char chan, int amount);
106   void slide_up(unsigned char chan, int amount);
107   void tone_portamento(unsigned char chan, unsigned char info);
108   void vibrato(unsigned char chan, unsigned char speed, unsigned char depth);
109   void vol_up(unsigned char chan, int amount);
110   void vol_down(unsigned char chan, int amount);
111   void vol_up_alt(unsigned char chan, int amount);
112   void vol_down_alt(unsigned char chan, int amount);
113
114   void dealloc_patterns();
115   bool resolve_order();
116   unsigned char set_opl_chip(unsigned char chan);
117 };
118
119 #endif