]> 4ch.mooo.com Git - 16.git/blob - 16/adplug/adplug/src/msc.h
wwww~
[16.git] / 16 / adplug / adplug / src / msc.h
1 /*
2  * Adplug - Replayer for many OPL2/OPL3 audio file formats.
3  * Copyright (C) 1999 - 2006 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  * msc.h - MSC Player by Lubomir Bulej (pallas@kadan.cz)
20  */
21
22 #include "player.h"
23
24 #define MSC_SIGN_LEN    16
25 #define MSC_DESC_LEN    64
26
27 class CmscPlayer: public CPlayer
28 {
29  public:
30   static CPlayer * factory(Copl * newopl);
31
32   CmscPlayer(Copl * newopl);
33   ~CmscPlayer();
34         
35   bool load(const std::string &filename, const CFileProvider &fp);
36   bool update();
37   void rewind(int subsong);
38   float getrefresh();
39
40   std::string gettype ();
41
42  protected:
43   typedef unsigned char         u8;
44   typedef unsigned short        u16;
45
46   struct msc_header {
47     u8  mh_sign [MSC_SIGN_LEN];
48     u16 mh_ver;
49     u8  mh_desc [MSC_DESC_LEN];
50     u16 mh_timer;
51     u16 mh_nr_blocks;
52     u16 mh_block_len;
53   };
54
55   struct msc_block {
56     u16         mb_length;
57     u8 *        mb_data;
58   };
59
60   // file data
61   char *                desc;           // song desctiption
62   unsigned short        version;        // file version
63   unsigned short        nr_blocks;      // number of music blocks
64   unsigned short        block_len;      // maximal block length
65   unsigned short        timer_div;      // timer divisor
66   msc_block *           msc_data;       // compressed music data
67
68   // decoder state
69   unsigned long block_num;      // active block
70   unsigned long block_pos;      // position in block
71   unsigned long raw_pos;        // position in data buffer
72   u8 *          raw_data;       // decompression buffer
73
74   u8            dec_prefix;     // prefix / state
75   int           dec_dist;       // prefix distance
76   unsigned int  dec_len;        // prefix length
77         
78   // player state
79   unsigned char delay;          // active delay
80   unsigned long play_pos;       // player position
81
82  private:
83   static const u8 msc_signature [MSC_SIGN_LEN];
84
85   bool load_header (binistream * bf, msc_header * hdr);
86   bool decode_octet (u8 * output);
87 };