Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libgambatte/src/sound/channel1.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 SOUND_CHANNEL1_H
20
#define SOUND_CHANNEL1_H
21
22
#include "gbint.h"
23
#include "master_disabler.h"
24
#include "length_counter.h"
25
#include "duty_unit.h"
26
#include "envelope_unit.h"
27
#include "static_output_tester.h"
28
#include "newstate.h"
29
30
namespace gambatte {
31
32
struct SaveState;
33
34
class Channel1 {
35
class SweepUnit : public SoundUnit {
36
MasterDisabler &disableMaster;
37
DutyUnit &dutyUnit;
38
unsigned short shadow;
39
unsigned char nr0;
40
bool negging;
41
42
unsigned calcFreq();
43
44
public:
45
SweepUnit(MasterDisabler &disabler, DutyUnit &dutyUnit);
46
void event();
47
void nr0Change(unsigned newNr0);
48
void nr4Init(unsigned long cycleCounter);
49
void reset();
50
void loadState(const SaveState &state);
51
52
template<bool isReader>void SyncState(NewState *ns);
53
};
54
55
friend class StaticOutputTester<Channel1,DutyUnit>;
56
57
StaticOutputTester<Channel1,DutyUnit> staticOutputTest;
58
DutyMasterDisabler disableMaster;
59
LengthCounter lengthCounter;
60
DutyUnit dutyUnit;
61
EnvelopeUnit envelopeUnit;
62
SweepUnit sweepUnit;
63
64
SoundUnit *nextEventUnit;
65
66
unsigned long cycleCounter;
67
unsigned long soMask;
68
unsigned long prevOut;
69
70
unsigned char nr4;
71
bool master;
72
73
void setEvent();
74
75
public:
76
Channel1();
77
void setNr0(unsigned data);
78
void setNr1(unsigned data);
79
void setNr2(unsigned data);
80
void setNr3(unsigned data);
81
void setNr4(unsigned data);
82
83
void setSo(unsigned long soMask);
84
bool isActive() const { return master; }
85
86
void update(uint_least32_t *buf, unsigned long soBaseVol, unsigned long cycles);
87
88
void reset();
89
void init(bool cgb);
90
void loadState(const SaveState &state);
91
92
template<bool isReader>void SyncState(NewState *ns);
93
};
94
95
}
96
97
#endif
98
99