summaryrefslogtreecommitdiff
path: root/plugins/adplug/adplug/d00.h
blob: 8c6339e1484925ff9ff246e91bf7712c4174bfc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * AdPlug - Replayer for many OPL2/OPL3 audio file formats.
 * Copyright (C) 1999 - 2007 Simon Peter, <dn.tlp@gmx.net>, et al.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * d00.h - D00 Player by Simon Peter <dn.tlp@gmx.net>
 */

#ifndef H_D00
#define H_D00

#include "player.h"

class Cd00Player: public CPlayer
{
 public:
  static CPlayer *factory(Copl *newopl);

  Cd00Player(Copl *newopl)
    : CPlayer(newopl), filedata(0)
    { };
  ~Cd00Player()
    { if(filedata) delete [] filedata; };

  bool load(const char *filename, const CFileProvider &fp);
  bool update();
  void rewind(int subsong);
  float getrefresh();

  const char * gettype();
  const char * gettitle()
    { if(version > 1) return header->songname; else return ""; };
  const char * getauthor()
    { if(version > 1) return header->author; else return ""; };
  const char * getdesc()
    { if(*datainfo) return datainfo; else return ""; };
  unsigned int getsubsongs();

 protected:
#pragma pack(1)
  struct d00header {
    char id[6];
    unsigned char type,version,speed,subsongs,soundcard;
    char songname[32],author[32],dummy[32];
    unsigned short tpoin,seqptr,instptr,infoptr,spfxptr,endmark;
  };

  struct d00header1 {
    unsigned char version,speed,subsongs;
    unsigned short tpoin,seqptr,instptr,infoptr,lpulptr,endmark;
  };
#pragma pack()

  struct {
    unsigned short	*order,ordpos,pattpos,del,speed,rhcnt,key,freq,inst,
      spfx,ispfx,irhcnt;
    signed short	transpose,slide,slideval,vibspeed;
    unsigned char	seqend,vol,vibdepth,fxdel,modvol,cvol,levpuls,
      frameskip,nextnote,note,ilevpuls,trigger,fxflag;
  } channel[9];

  struct Sinsts {
    unsigned char data[11],tunelev,timer,sr,dummy[2];
  } *inst;

  struct Sspfx {
    unsigned short instnr;
    signed char halfnote;
    unsigned char modlev;
    signed char modlevadd;
    unsigned char duration;
    unsigned short ptr;
  } *spfx;

  struct Slevpuls {
    unsigned char level;
    signed char voladd;
    unsigned char duration,ptr;
  } *levpuls;

  unsigned char songend,version,cursubsong;
  char *datainfo;
  unsigned short *seqptr;
  d00header *header;
  d00header1 *header1;
  char *filedata;
  char	tmpstr[40];

 private:
  void setvolume(unsigned char chan);
  void setfreq(unsigned char chan);
  void setinst(unsigned char chan);
  void playnote(unsigned char chan);
  void vibrato(unsigned char chan);
};

#endif