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