ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
player_pce.h
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 
22 #ifndef SCUMM_PLAYERS_PLAYER_PCE_H
23 #define SCUMM_PLAYERS_PLAYER_PCE_H
24 
25 #include "common/scummsys.h"
26 #include "common/mutex.h"
27 #include "scumm/music.h"
28 #include "audio/audiostream.h"
29 #include "audio/mixer.h"
30 
31 // PCE sound engine is only used by Loom, which requires 16bit color support
32 #ifdef USE_RGB_COLOR
33 
34 namespace Scumm {
35 
36 class ScummEngine;
37 class PSG_HuC6280;
38 
39 class Player_PCE : public Audio::AudioStream, public MusicEngine {
40 private:
41  struct channel_t {
42  int id;
43 
44  byte controlVec0;
45  byte controlVec1;
46  byte controlVec2;
47  byte controlVec5;
48  byte balance;
49  byte balance2;
50  byte controlVec8;
51  byte controlVec9;
52  byte controlVec10;
53  byte controlVec11;
54  int16 soundUpdateCounter;
55  byte controlVec18;
56  byte controlVec19;
57  byte waveformCtrl;
58  byte controlVec21;
59  bool controlVec23;
60  bool controlVec24;
61 
62  uint16 controlVecShort02;
63  uint16 controlVecShort03;
64  int16 controlVecShort06;
65  uint16 freq;
66  uint16 controlVecShort09;
67  uint16 controlVecShort10;
68 
69  const byte* soundDataPtr;
70  const byte* controlBufferPos;
71  };
72 
73 public:
74  Player_PCE(ScummEngine *scumm, Audio::Mixer *mixer);
75  ~Player_PCE() override;
76 
77  void setMusicVolume(int vol) override { _maxvol = vol; }
78  void startSound(int sound) override;
79  void stopSound(int sound) override;
80  void stopAllSounds() override;
81  int getSoundStatus(int sound) const override;
82  int getMusicTimer() override;
83 
84  // AudioStream API
85  int readBuffer(int16 *buffer, const int numSamples) override;
86  bool isStereo() const override { return true; }
87  bool endOfData() const override { return false; }
88  int getRate() const override { return _sampleRate; }
89 
90 private:
91  ScummEngine *_vm;
92  Audio::Mixer *_mixer;
93  Audio::SoundHandle _soundHandle;
94  int _sampleRate;
95  int _maxvol;
96 
97 private:
98  PSG_HuC6280 *_psg;
99  channel_t channels[12];
100  Common::Mutex _mutex;
101 
102  // number of samples per timer period
103  int _samplesPerPeriod;
104  int16* _sampleBuffer;
105  int _sampleBufferCnt;
106 
107  void PSG_Write(int reg, byte data);
108 
109  void setupWaveform(byte bank);
110  void procA541(channel_t *channel);
111  void updateSound();
112  void procA731(channel_t *channel);
113  void processSoundData(channel_t *channel);
114  void procAA62(channel_t *channel, int a);
115  void procAB7F(channel_t *channel);
116  void procAC24(channel_t *channel);
117  void procACEA(channel_t *channel, int a);
118 };
119 
120 } // End of namespace Scumm
121 
122 #endif // USE_RGB_COLOR
123 
124 #endif
Definition: mixer.h:49
Definition: mixer.h:59
Definition: mutex.h:67
Definition: audiostream.h:50
Definition: actor.h:30