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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
use super::*;
pub const SOUND1CNT_L: VolAddress<SweepRegisterSetting> = unsafe { VolAddress::new_unchecked(0x400_0060) };
newtype! {
SweepRegisterSetting, u16
}
impl SweepRegisterSetting {
phantom_fields! {
self.0: u16,
sweep_shift: 0-2,
sweep_decreasing: 3,
sweep_time: 4-6,
}
}
pub const SOUND1CNT_H: VolAddress<DutyLenEnvelopeSetting> = unsafe { VolAddress::new_unchecked(0x400_0062) };
newtype! {
DutyLenEnvelopeSetting, u16
}
impl DutyLenEnvelopeSetting {
phantom_fields! {
self.0: u16,
sound_length: 0-5,
wave_pattern_duty: 6-7,
envelope_step_time: 8-10,
envelope_increasing: 11,
initial_envelope_volume: 12-15,
}
}
pub const SOUND1CNT_X: VolAddress<FrequencyControlSetting> = unsafe { VolAddress::new_unchecked(0x400_0064) };
newtype! {
FrequencyControlSetting, u32
}
impl FrequencyControlSetting {
phantom_fields! {
self.0: u32,
frequency: 0-10,
length_flag: 14,
is_initial: 15,
}
}
pub const SOUND2CNT_L: VolAddress<DutyLenEnvelopeSetting> = unsafe { VolAddress::new_unchecked(0x400_0068) };
pub const SOUND2CNT_H: VolAddress<FrequencyControlSetting> = unsafe { VolAddress::new_unchecked(0x400_006C) };
pub const SOUND3CNT_L: VolAddress<StopWaveRAMSelectSetting> = unsafe { VolAddress::new_unchecked(0x400_0070) };
newtype! {
StopWaveRAMSelectSetting, u16
}
impl StopWaveRAMSelectSetting {
phantom_fields! {
self.0: u16,
wave_ram_dimension_2d: 5,
wave_ram_bank_number: 6,
sound_channel_3_playing: 7,
}
}
pub const SOUND3CNT_H: VolAddress<LengthVolumeSetting> = unsafe { VolAddress::new_unchecked(0x400_0072) };
newtype! {
LengthVolumeSetting, u16
}
impl LengthVolumeSetting {
phantom_fields! {
self.0: u16,
sound_length: 0-7,
sound_volume: 13-14,
force_75percent: 15,
}
}
pub const SOUND3CNT_X: VolAddress<FrequencyControlSetting> = unsafe { VolAddress::new_unchecked(0x400_0074) };
pub const WAVE_RAM0_L: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_0090) };
pub const WAVE_RAM0_H: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_0092) };
pub const WAVE_RAM1_L: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_0094) };
pub const WAVE_RAM1_H: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_0096) };
pub const WAVE_RAM2_L: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_0098) };
pub const WAVE_RAM2_H: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_009A) };
pub const WAVE_RAM3_L: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_009C) };
pub const WAVE_RAM3_H: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_009E) };
pub const SOUND4CNT_L: VolAddress<LengthEnvelopeSetting> = unsafe { VolAddress::new_unchecked(0x400_0078) };
newtype! {
LengthEnvelopeSetting, u32
}
impl LengthEnvelopeSetting {
phantom_fields! {
self.0: u32,
sound_length: 0-5,
envelope_step_time: 8-10,
envelope_increasing: 11,
initial_envelope_volume: 12-15,
}
}
pub const SOUND4CNT_H: VolAddress<NoiseFrequencySetting> = unsafe { VolAddress::new_unchecked(0x400_007C) };
newtype! {
NoiseFrequencySetting, u32
}
impl NoiseFrequencySetting {
phantom_fields! {
self.0: u32,
frequency_divide_ratio: 0-2,
counter_step_width_7bit: 3,
shift_clock_frequency: 4-7,
length_flag_stop: 14,
initial_restart: 15,
}
}
pub const FIFO_A_L: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_00A0) };
pub const FIFO_A_H: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_00A2) };
pub const FIFO_B_L: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_00A4) };
pub const FIFO_B_H: VolAddress<u16> = unsafe { VolAddress::new_unchecked(0x400_00A6) };
pub const SOUNDCNT_L: VolAddress<NonWaveVolumeEnableSetting> = unsafe { VolAddress::new_unchecked(0x400_0080) };
newtype! {
NonWaveVolumeEnableSetting, u16
}
impl NonWaveVolumeEnableSetting {
phantom_fields! {
self.0: u16,
right_master_volume: 0-2,
left_master_volume: 4-6,
right_enable_flags: 8-11,
left_enable_flags: 12-15,
}
}
pub const SOUNDCNT_H: VolAddress<WaveVolumeEnableSetting> = unsafe { VolAddress::new_unchecked(0x400_0082) };
newtype! {
WaveVolumeEnableSetting, u16
}
impl WaveVolumeEnableSetting {
phantom_fields! {
self.0: u16,
sound_number_volume: 0-1=NumberSoundVolume<Quarter, Half, Full>,
dma_sound_a_full_volume: 2,
dma_sound_b_full_volume: 3,
dma_sound_a_enable_right: 8,
dma_sound_a_enable_left: 9,
dma_sound_a_timer_select: 10,
dma_sound_a_reset_fifo: 11,
dma_sound_b_enable_right: 12,
dma_sound_b_enable_left: 13,
dma_sound_b_timer_select: 14,
dma_sound_b_reset_fifo: 15,
}
}
newtype_enum! {
NumberSoundVolume = u16,
Quarter = 0,
Half = 1,
Full = 2,
}
pub const SOUNDCNT_X: VolAddress<SoundMasterSetting> = unsafe { VolAddress::new_unchecked(0x400_0084) };
newtype! {
SoundMasterSetting, u16
}
impl SoundMasterSetting {
phantom_fields! {
self.0: u16,
sound1_on: 0,
sound2_on: 1,
sound3_on: 2,
sound4_on: 3,
psg_fifo_master_enabled: 7,
}
}
pub const SOUNDBIAS: VolAddress<SoundPWMSetting> = unsafe { VolAddress::new_unchecked(0x400_0088) };
newtype! {
SoundPWMSetting, u16
}
impl SoundMasterSetting {
phantom_fields! {
self.0: u16,
bias_level: 1-9,
amplitude_resolution: 14-15,
}
}