359
|
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 * s3m.h - AdLib S3M Player by Simon Peter <dn.tlp@gmx.net>
|
|
20 */
|
|
21
|
|
22 #ifndef H_ADPLUG_S3M
|
|
23 #define H_ADPLUG_S3M
|
|
24
|
|
25 #include "player.h"
|
|
26
|
|
27 class Cs3mPlayer: public CPlayer
|
|
28 {
|
|
29 public:
|
|
30 static CPlayer *factory(Copl *newopl);
|
|
31
|
|
32 Cs3mPlayer(Copl *newopl);
|
|
33
|
|
34 bool load(const std::string &filename, const CFileProvider &fp);
|
|
35 bool update();
|
|
36 void rewind(int subsong);
|
|
37 float getrefresh();
|
|
38
|
|
39 std::string gettype();
|
|
40 std::string gettitle()
|
|
41 { return std::string(header.name); };
|
|
42
|
|
43 unsigned int getpatterns()
|
|
44 { return header.patnum; };
|
|
45 unsigned int getpattern()
|
|
46 { return orders[ord]; };
|
|
47 unsigned int getorders()
|
|
48 { return (header.ordnum-1); };
|
|
49 unsigned int getorder()
|
|
50 { return ord; };
|
|
51 unsigned int getrow()
|
|
52 { return crow; };
|
|
53 unsigned int getspeed()
|
|
54 { return speed; };
|
|
55 unsigned int getinstruments()
|
|
56 { return header.insnum; };
|
|
57 std::string getinstrument(unsigned int n)
|
|
58 { return std::string(inst[n].name); };
|
|
59
|
|
60 protected:
|
|
61 struct s3mheader {
|
|
62 char name[28]; // song name
|
|
63 unsigned char kennung,typ,dummy[2];
|
|
64 unsigned short ordnum,insnum,patnum,flags,cwtv,ffi;
|
|
65 char scrm[4];
|
|
66 unsigned char gv,is,it,mv,uc,dp,dummy2[8];
|
|
67 unsigned short special;
|
|
68 unsigned char chanset[32];
|
|
69 };
|
|
70
|
|
71 struct s3minst {
|
|
72 unsigned char type;
|
|
73 char filename[15];
|
|
74 unsigned char d00,d01,d02,d03,d04,d05,d06,d07,d08,d09,d0a,d0b,volume,dsk,dummy[2];
|
|
75 unsigned long c2spd;
|
|
76 char dummy2[12], name[28],scri[4];
|
|
77 } inst[99];
|
|
78
|
|
79 struct {
|
|
80 unsigned char note,oct,instrument,volume,command,info;
|
|
81 } pattern[99][64][32];
|
|
82
|
|
83 struct {
|
|
84 unsigned short freq,nextfreq;
|
|
85 unsigned char oct,vol,inst,fx,info,dualinfo,key,nextoct,trigger,note;
|
|
86 } channel[9];
|
|
87
|
|
88 s3mheader header;
|
|
89 unsigned char orders[256];
|
|
90 unsigned char crow,ord,speed,tempo,del,songend,loopstart,loopcnt;
|
|
91
|
|
92 private:
|
|
93 static const char chnresolv[];
|
|
94 static const unsigned short notetable[12];
|
|
95 static const unsigned char vibratotab[32];
|
|
96
|
|
97 void load_header(binistream *f, s3mheader *h);
|
|
98 void setvolume(unsigned char chan);
|
|
99 void setfreq(unsigned char chan);
|
|
100 void playnote(unsigned char chan);
|
|
101 void slide_down(unsigned char chan, unsigned char amount);
|
|
102 void slide_up(unsigned char chan, unsigned char amount);
|
|
103 void vibrato(unsigned char chan, unsigned char info);
|
|
104 void tone_portamento(unsigned char chan, unsigned char info);
|
|
105 };
|
|
106
|
|
107 #endif
|