Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libgambatte/src/sound/envelope_unit.h
2 views
1
/***************************************************************************
2
* Copyright (C) 2007 by Sindre Aamås *
3
* [email protected] *
4
* *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License version 2 as *
7
* published by the Free Software Foundation. *
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 version 2 for more details. *
13
* *
14
* You should have received a copy of the GNU General Public License *
15
* version 2 along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18
***************************************************************************/
19
#ifndef ENVELOPE_UNIT_H
20
#define ENVELOPE_UNIT_H
21
22
#include "sound_unit.h"
23
#include "../savestate.h"
24
#include "newstate.h"
25
26
namespace gambatte {
27
28
class EnvelopeUnit : public SoundUnit {
29
public:
30
struct VolOnOffEvent {
31
virtual ~VolOnOffEvent() {}
32
virtual void operator()(unsigned long /*cc*/) {}
33
};
34
35
private:
36
static VolOnOffEvent nullEvent;
37
VolOnOffEvent &volOnOffEvent;
38
unsigned char nr2;
39
unsigned char volume;
40
41
public:
42
explicit EnvelopeUnit(VolOnOffEvent &volOnOffEvent = nullEvent);
43
void event();
44
bool dacIsOn() const { return nr2 & 0xF8; }
45
unsigned getVolume() const { return volume; }
46
bool nr2Change(unsigned newNr2);
47
bool nr4Init(unsigned long cycleCounter);
48
void reset();
49
void loadState(const SaveState::SPU::Env &estate, unsigned nr2, unsigned long cc);
50
51
template<bool isReader>void SyncState(NewState *ns);
52
};
53
54
}
55
56
#endif
57
58