ScummVM API documentation
player_nes.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_NES_H
23 #define SCUMM_PLAYERS_PLAYER_NES_H
24 
25 #include "common/scummsys.h"
26 #include "scumm/music.h"
27 #include "audio/audiostream.h"
28 #include "audio/mixer.h"
29 
30 namespace Scumm {
31 
32 class ScummEngine;
33 namespace APUe {
34 class APU;
35 }
36 
37 static const int MAXVOLUME = 0x7F;
38 static const int NUMSLOTS = 3;
39 static const int NUMCHANS = 4;
40 
44 class Player_NES : public Audio::AudioStream, public MusicEngine {
45 public:
46  Player_NES(ScummEngine *scumm, Audio::Mixer *mixer);
47  ~Player_NES() override;
48 
49  void setMusicVolume(int vol) override;
50  void startSound(int sound) override;
51  void stopSound(int sound) override;
52  void stopAllSounds() override;
53  int getSoundStatus(int sound) const override;
54 
55  // AudioStream API
56  int readBuffer(int16 *buffer, const int numSamples) override;
57  bool isStereo() const override { return false; }
58  bool endOfData() const override { return false; }
59  int getRate() const override { return _sampleRate; }
60 
61 private:
62 
63  void sound_play();
64  void playSFX(int nr);
65  void playMusic();
66  void chainCommand(int chan);
67  void checkSilenceChannels(int chan);
68 
69  void APU_writeChannel(int chan, int offset, byte value);
70  void APU_writeControl(byte value);
71  byte APU_readStatus();
72 
73  ScummEngine *_vm;
74  Audio::Mixer *_mixer;
75  Audio::SoundHandle _soundHandle;
76  APUe::APU *_apu;
77  int _sampleRate;
78  int _samples_per_frame;
79  int _current_sample;
80  int _maxvol;
81 
82  struct slot {
83  int framesleft;
84  int id;
85  int type;
86  byte *data;
87  int offset;
88  } _slot[NUMSLOTS];
89 
90  struct mchan {
91  int command;
92  int framedelay;
93  int pitch;
94  int volume;
95  int voldelta;
96  int envflags;
97  int cmdlock;
98  } _mchan[NUMCHANS];
99 
100  bool isSFXplaying, wasSFXplaying;
101 
102  byte *dataStart;
103  int numNotes;
104  byte *auxData1;
105  byte *auxData2;
106 
107  byte *soundptr;
108 };
109 
110 } // End of namespace Scumm
111 
112 #endif
Definition: music.h:40
bool isStereo() const override
Definition: player_nes.h:57
Definition: scumm.h:519
Definition: mixer.h:49
Definition: mixer.h:59
Definition: player_nes.h:44
Definition: audiostream.h:50
int getRate() const override
Definition: player_nes.h:59
Definition: actor.h:30
bool endOfData() const override
Definition: player_nes.h:58