ScummVM API documentation
infogrames.h
Go to the documentation of this file.
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
28 #ifndef AUDIO_MODS_INFOGRAMES_H
29 #define AUDIO_MODS_INFOGRAMES_H
30 
31 #include "audio/mods/paula.h"
32 
33 namespace Common {
34 class SeekableReadStream;
35 }
36 
37 namespace Audio {
38 
40 class Infogrames : public Paula {
41 public:
42  class Instruments {
43  public:
44  Instruments();
45  template<typename T> Instruments(T ins) {
46  init();
47  bool result = load(ins);
48  assert(result);
49  }
50  ~Instruments();
51 
52  bool load(Common::SeekableReadStream &ins);
53  bool load(const char *ins);
54  void unload();
55 
56  uint8 getCount() const { return _count; }
57 
58  protected:
59  struct Sample {
60  int8 *data;
61  int8 *dataRepeat;
62  uint32 length;
63  uint32 lengthRepeat;
64  } _samples[32];
65 
66  uint8 _count;
67  int8 *_sampleData;
68 
69  void init();
70 
71  friend class Infogrames;
72  };
73 
74  Infogrames(Instruments &ins, bool stereo = false, int rate = 44100,
75  int interruptFreq = 0);
76  ~Infogrames();
77 
78  Instruments *getInstruments() const { return _instruments; }
79  bool getRepeating() const { return _repCount != 0; }
80  void setRepeating (int32 repCount) { _repCount = repCount; }
81 
82  bool load(Common::SeekableReadStream &dum);
83  bool load(const char *dum);
84  void unload();
85  void restart() {
86  if (_data) {
87  // Use the mutex here to ensure we do not call init()
88  // while data is being read by the mixer thread.
89  _mutex.lock();
90  init();
91  startPlay();
92  _mutex.unlock();
93  }
94  }
95 
96 protected:
97  Instruments *_instruments;
98 
99  static const uint8 tickCount[];
100  static const uint16 periods[];
101  byte *_data;
102  int32 _repCount;
103 
104  byte *_subSong;
105  byte *_cmdBlocks;
106  byte *_volSlideBlocks;
107  byte *_periodSlideBlocks;
108  uint8 _speedCounter;
109  uint8 _speed;
110 
111  uint16 _volume;
112  int16 _period;
113  uint8 _sample;
114 
115  struct Slide {
116  byte *data;
117  int8 amount;
118  uint8 dataOffset;
119  int16 finetuneNeg;
120  int16 finetunePos;
121  uint8 curDelay1;
122  uint8 curDelay2;
123  uint8 flags; // 0: Apply finetune modifier, 2: Don't slide, 7: Continuous
124  };
125  struct Channel {
126  byte *cmdBlockIndices;
127  byte *cmdBlocks;
128  byte *cmds;
129  uint8 ticks;
130  uint8 tickCount;
131  Slide volSlide;
132  Slide periodSlide;
133  int16 period;
134  int8 periodMod;
135  uint8 flags; // 0: Need init, 5: Loop cmdBlocks, 6: Ignore channel
136  } _chn[4];
137 
138  void init();
139  void reset();
140  void getNextSample(Channel &chn);
141  int16 tune(Slide &slide, int16 start) const;
142  virtual void interrupt();
143 };
144 
145 } // End of namespace Audio
146 
147 #endif
Definition: infogrames.h:115
Definition: stream.h:745
Definition: infogrames.h:40
Definition: infogrames.h:59
Definition: infogrames.h:125
Definition: algorithm.h:29
Definition: infogrames.h:42
Definition: paula.h:36
Definition: system.h:38