-
Notifications
You must be signed in to change notification settings - Fork 38
/
registers.hpp
158 lines (132 loc) · 2.61 KB
/
registers.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
struct Registers {
struct SoundBias {
uint10 level;
uint2 amplitude;
operator uint16() const;
uint16 operator=(uint16 source);
SoundBias& operator=(const SoundBias&) = delete;
} bias;
unsigned clock;
} regs;
struct Sweep {
uint3 shift;
uint1 direction;
uint3 frequency;
uint1 enable;
uint1 negate;
uint3 period;
};
struct Envelope {
uint3 frequency;
uint1 direction;
uint4 volume;
uint3 period;
inline bool dacenable() const { return volume || direction; }
};
struct Square {
Envelope envelope;
uint1 enable;
uint6 length;
uint2 duty;
uint11 frequency;
uint1 counter;
uint1 initialize;
signed shadowfrequency;
uint1 signal;
uint4 output;
unsigned period;
uint3 phase;
uint4 volume;
void run();
void clocklength();
void clockenvelope();
};
struct Square1 : Square {
Sweep sweep;
void runsweep(bool update);
void clocksweep();
uint8 read(unsigned addr) const;
void write(unsigned addr, uint8 byte);
void power();
} square1;
struct Square2 : Square {
uint8 read(unsigned addr) const;
void write(unsigned addr, uint8 byte);
void power();
} square2;
struct Wave {
uint1 mode;
uint1 bank;
uint1 dacenable;
uint8 length;
uint3 volume;
uint11 frequency;
uint1 counter;
uint1 initialize;
uint4 pattern[32];
uint1 enable;
uint4 output;
uint4 patternaddr;
uint1 patternbank;
uint4 patternsample;
unsigned period;
void run();
void clocklength();
uint8 read(unsigned addr) const;
void write(unsigned addr, uint8 byte);
uint8 readram(unsigned addr) const;
void writeram(unsigned addr, uint8 byte);
void power();
} wave;
struct Noise {
Envelope envelope;
uint6 length;
uint3 divisor;
uint1 narrowlfsr;
uint4 frequency;
uint1 counter;
uint1 initialize;
uint1 enable;
uint15 lfsr;
uint4 output;
unsigned period;
uint4 volume;
unsigned divider() const;
void run();
void clocklength();
void clockenvelope();
uint8 read(unsigned addr) const;
void write(unsigned addr, uint8 byte);
void power();
} noise;
struct Sequencer {
uint2 volume;
uint3 lvolume;
uint3 rvolume;
uint1 lenable[4];
uint1 renable[4];
uint1 enable[4];
uint1 masterenable;
uint12 base;
uint3 step;
int16 lsample;
int16 rsample;
uint8 read(unsigned addr) const;
void write(unsigned addr, uint8 byte);
void power();
} sequencer;
struct FIFO {
int8 sample[32];
int8 output;
uint5 rdoffset;
uint5 wroffset;
uint6 size;
uint1 volume; //0 = 50%, 1 = 100%
uint1 lenable;
uint1 renable;
uint1 timer;
void read();
void write(int8 byte);
void reset();
void power();
} fifo[2];