Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmeteor/include/ameteor/sound.hpp
2 views
1
// Meteor - A Nintendo Gameboy Advance emulator
2
// Copyright (C) 2009-2011 Philippe Daouadi
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
#ifndef __SOUND_H__
18
#define __SOUND_H__
19
20
#include "audio/speaker.hpp"
21
#include "clock.hpp"
22
#include <stdint.h>
23
#include <istream>
24
#include <ostream>
25
26
namespace AMeteor
27
{
28
class Sound
29
{
30
public :
31
Sound ();
32
33
void Reset ();
34
35
inline Audio::Speaker& GetSpeaker();
36
37
void UpdateCntH1 (uint8_t val);
38
39
inline void ResetSound1 ();
40
inline void ResetSound2 ();
41
inline void ResetSound4 ();
42
43
inline void ResetSound1Envelope ();
44
inline void ResetSound2Envelope ();
45
inline void ResetSound4Envelope ();
46
47
void TimerOverflow (uint8_t timernum);
48
49
inline void SendDigitalA (uint8_t* buffer);
50
inline void SendDigitalB (uint8_t* buffer);
51
52
bool SaveState (std::ostream& stream);
53
bool LoadState (std::istream& stream);
54
55
private :
56
Audio::Speaker m_speaker;
57
58
uint8_t m_fATimer, m_fBTimer;
59
60
inline void TimerOverflowA ();
61
inline void TimerOverflowB ();
62
63
void TimeEvent ()
64
{
65
m_speaker.SoundTick();
66
}
67
68
friend void Clock::Commit ();
69
};
70
71
inline Audio::Speaker& Sound::GetSpeaker()
72
{
73
return m_speaker;
74
}
75
76
inline void Sound::ResetSound1 ()
77
{
78
m_speaker.ResetSound1();
79
}
80
81
inline void Sound::ResetSound2 ()
82
{
83
m_speaker.ResetSound2();
84
}
85
86
inline void Sound::ResetSound4 ()
87
{
88
m_speaker.ResetSound4();
89
}
90
91
inline void Sound::ResetSound1Envelope ()
92
{
93
m_speaker.ResetSound1Envelope();
94
}
95
96
inline void Sound::ResetSound2Envelope ()
97
{
98
m_speaker.ResetSound2Envelope();
99
}
100
101
inline void Sound::ResetSound4Envelope ()
102
{
103
m_speaker.ResetSound4Envelope();
104
}
105
106
inline void Sound::SendDigitalA (uint8_t* buffer)
107
{
108
m_speaker.FillFifoA((int8_t*)buffer);
109
}
110
111
inline void Sound::SendDigitalB (uint8_t* buffer)
112
{
113
m_speaker.FillFifoB((int8_t*)buffer);
114
}
115
}
116
117
#endif
118
119