summaryrefslogtreecommitdiff
path: root/plugins/adplug/adplug/lds.h
blob: 2642a6a938536d9cbf2a6103fbaed96d6b74d3d8 (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
/*
 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
 * Copyright (C) 1999 - 2004 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
 *
 * lds.h - LOUDNESS Player by Simon Peter <dn.tlp@gmx.net>
 */

#include "player.h"

class CldsPlayer: public CPlayer
{
 public:
  static CPlayer *factory(Copl *newopl) { return new CldsPlayer(newopl); }

  CldsPlayer(Copl *newopl);
  virtual ~CldsPlayer();

  bool load(const char *filename, const CFileProvider &fp);
  virtual bool update();
  virtual void rewind(int subsong = -1);
  float getrefresh() { return 70.0f; }

  const char * gettype() { return "LOUDNESS Sound System"; }
  unsigned int getorders() { return numposi; }
  unsigned int getorder() { return posplay; }
  unsigned int getrow() { return pattplay; }
  unsigned int getspeed() { return speed; }
  unsigned int getinstruments() { return numpatch; }

 private:
  typedef struct {
    unsigned char	mod_misc, mod_vol, mod_ad, mod_sr, mod_wave,
      car_misc, car_vol, car_ad, car_sr, car_wave, feedback, keyoff,
      portamento, glide, finetune, vibrato, vibdelay, mod_trem, car_trem,
      tremwait, arpeggio, arp_tab[12];
    unsigned short	start, size;
    unsigned char	fms;
    unsigned short	transp;
    unsigned char	midinst, midvelo, midkey, midtrans, middum1, middum2;
  } SoundBank;

  typedef struct {
    unsigned short	gototune, lasttune, packpos;
    unsigned char	finetune, glideto, portspeed, nextvol, volmod, volcar,
      vibwait, vibspeed, vibrate, trmstay, trmwait, trmspeed, trmrate, trmcount,
      trcwait, trcspeed, trcrate, trccount, arp_size, arp_speed, keycount,
      vibcount, arp_pos, arp_count, packwait, arp_tab[12];

    struct {
      unsigned char	chandelay, sound;
      unsigned short	high;
    } chancheat;
  } Channel;

  typedef struct {
    unsigned short	patnum;
    unsigned char	transpose;
  } Position;

  static const unsigned short	frequency[];
  static const unsigned char	vibtab[], tremtab[];
  static const unsigned short	maxsound, maxpos;

  SoundBank		*soundbank;
  Channel		channel[9];
  Position		*positions;
  unsigned char		fmchip[0xff], jumping, fadeonoff, allvolume, hardfade,
    tempo_now, pattplay, tempo, regbd, chandelay[9], mode, pattlen;
  unsigned short	posplay, jumppos, *patterns, speed;
  bool			playing, songlooped;
  unsigned int		numpatch, numposi, patterns_size, mainvolume;

  void		playsound(int inst_number, int channel_number, int tunehigh);
  inline void	setregs(unsigned char reg, unsigned char val);
  inline void	setregs_adv(unsigned char reg, unsigned char mask,
			    unsigned char val);
};