annotate Plugins/Input/adplug/core/s3m.h @ 359:8df427a314a8 trunk

[svn] Adlib synthesizer (AdPlug) support.
author chainsaw
date Fri, 30 Dec 2005 16:31:39 -0800
parents
children f12d7e208b43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
359
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
1 /*
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
2 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
3 * Copyright (C) 1999 - 2003 Simon Peter, <dn.tlp@gmx.net>, et al.
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
4 *
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
8 * version 2.1 of the License, or (at your option) any later version.
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
9 *
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
13 * Lesser General Public License for more details.
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
14 *
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
18 *
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
19 * s3m.h - AdLib S3M Player by Simon Peter <dn.tlp@gmx.net>
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
20 */
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
21
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
22 #ifndef H_ADPLUG_S3M
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
23 #define H_ADPLUG_S3M
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
24
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
25 #include "player.h"
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
26
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
27 class Cs3mPlayer: public CPlayer
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
28 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
29 public:
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
30 static CPlayer *factory(Copl *newopl);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
31
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
32 Cs3mPlayer(Copl *newopl);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
33
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
34 bool load(const std::string &filename, const CFileProvider &fp);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
35 bool update();
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
36 void rewind(int subsong);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
37 float getrefresh();
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
38
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
39 std::string gettype();
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
40 std::string gettitle()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
41 { return std::string(header.name); };
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
42
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
43 unsigned int getpatterns()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
44 { return header.patnum; };
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
45 unsigned int getpattern()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
46 { return orders[ord]; };
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
47 unsigned int getorders()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
48 { return (header.ordnum-1); };
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
49 unsigned int getorder()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
50 { return ord; };
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
51 unsigned int getrow()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
52 { return crow; };
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
53 unsigned int getspeed()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
54 { return speed; };
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
55 unsigned int getinstruments()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
56 { return header.insnum; };
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
57 std::string getinstrument(unsigned int n)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
58 { return std::string(inst[n].name); };
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
59
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
60 protected:
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
61 struct s3mheader {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
62 char name[28]; // song name
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
63 unsigned char kennung,typ,dummy[2];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
64 unsigned short ordnum,insnum,patnum,flags,cwtv,ffi;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
65 char scrm[4];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
66 unsigned char gv,is,it,mv,uc,dp,dummy2[8];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
67 unsigned short special;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
68 unsigned char chanset[32];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
69 };
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
70
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
71 struct s3minst {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
72 unsigned char type;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
73 char filename[15];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
74 unsigned char d00,d01,d02,d03,d04,d05,d06,d07,d08,d09,d0a,d0b,volume,dsk,dummy[2];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
75 unsigned long c2spd;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
76 char dummy2[12], name[28],scri[4];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
77 } inst[99];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
78
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
79 struct {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
80 unsigned char note,oct,instrument,volume,command,info;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
81 } pattern[99][64][32];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
82
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
83 struct {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
84 unsigned short freq,nextfreq;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
85 unsigned char oct,vol,inst,fx,info,dualinfo,key,nextoct,trigger,note;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
86 } channel[9];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
87
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
88 s3mheader header;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
89 unsigned char orders[256];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
90 unsigned char crow,ord,speed,tempo,del,songend,loopstart,loopcnt;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
91
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
92 private:
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
93 static const char chnresolv[];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
94 static const unsigned short notetable[12];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
95 static const unsigned char vibratotab[32];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
96
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
97 void load_header(binistream *f, s3mheader *h);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
98 void setvolume(unsigned char chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
99 void setfreq(unsigned char chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
100 void playnote(unsigned char chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
101 void slide_down(unsigned char chan, unsigned char amount);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
102 void slide_up(unsigned char chan, unsigned char amount);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
103 void vibrato(unsigned char chan, unsigned char info);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
104 void tone_portamento(unsigned char chan, unsigned char info);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
105 };
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
106
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
107 #endif