Debian Codegraph @

gba/apu/registers.hpp

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