mirror of
https://github.com/italicsjenga/gba.git
synced 2024-12-24 03:11:29 +11:00
Added sound master control registers to mmio_addresses. (#144)
* Added sound master control registers to mmio_addresses. * Merge FifioEnable into SoundStatus, reduce struct sizes. * Rename SOUND_CHANNEL_CTL to something a bit simpler.
This commit is contained in:
parent
ec0ca7d804
commit
144dada16b
|
@ -161,6 +161,22 @@ pub const NOISE_LEN_ENV: VolAddress<NoiseLenEnv, Safe, Safe> =
|
||||||
pub const NOISE_FREQ_CNT: VolAddress<NoiseFrequencyControl, Safe, Safe> =
|
pub const NOISE_FREQ_CNT: VolAddress<NoiseFrequencyControl, Safe, Safe> =
|
||||||
unsafe { VolAddress::new(0x0400_007C) };
|
unsafe { VolAddress::new(0x0400_007C) };
|
||||||
|
|
||||||
|
/// [SOUNDCNT_L](https://problemkaputt.de/gbatek.htm#gbasoundcontrolregisters)
|
||||||
|
pub const SOUND_CONTROL: VolAddress<SoundControl, Safe, Safe> =
|
||||||
|
unsafe { VolAddress::new(0x0400_0080) };
|
||||||
|
/// [SOUNDCNT_X](https://problemkaputt.de/gbatek.htm#gbasoundcontrolregisters)
|
||||||
|
pub const SOUND_STATUS: VolAddress<SoundStatus, Safe, Safe> =
|
||||||
|
unsafe { VolAddress::new(0x0400_0084) };
|
||||||
|
/// [SOUNDBIAS](https://problemkaputt.de/gbatek.htm#gbasoundcontrolregisters)
|
||||||
|
pub const SOUND_BIAS: VolAddress<SoundBias, Safe, Safe> =
|
||||||
|
unsafe { VolAddress::new(0x0400_0088) };
|
||||||
|
|
||||||
|
/// [SOUNDCNT_H](https://problemkaputt.de/gbatek.htm#gbasoundcontrolregisters) (R/W fields)
|
||||||
|
pub const FIFO_CONTROL: VolAddress<FifoControl, Safe, Safe> =
|
||||||
|
unsafe { VolAddress::new(0x0400_0082) };
|
||||||
|
/// [SOUNDCNT_H](https://problemkaputt.de/gbatek.htm#gbasoundcontrolregisters) (write-only fields)
|
||||||
|
pub const FIFO_RESET: VolAddress<FifoReset, (), Safe> =
|
||||||
|
unsafe { VolAddress::new(0x0400_0082) };
|
||||||
/// [FIFO_A](https://problemkaputt.de/gbatek.htm#gbasoundchannelaandbdmasound)
|
/// [FIFO_A](https://problemkaputt.de/gbatek.htm#gbasoundchannelaandbdmasound)
|
||||||
pub const FIFO_A: VolAddress<u32, (), Safe> = unsafe { VolAddress::new(0x0400_00A0) };
|
pub const FIFO_A: VolAddress<u32, (), Safe> = unsafe { VolAddress::new(0x0400_00A0) };
|
||||||
/// [FIFO_B](https://problemkaputt.de/gbatek.htm#gbasoundchannelaandbdmasound)
|
/// [FIFO_B](https://problemkaputt.de/gbatek.htm#gbasoundchannelaandbdmasound)
|
||||||
|
|
|
@ -183,6 +183,21 @@ pub use register_ram_reset_control::*;
|
||||||
mod interrupt_flags;
|
mod interrupt_flags;
|
||||||
pub use interrupt_flags::*;
|
pub use interrupt_flags::*;
|
||||||
|
|
||||||
|
mod fifo_control;
|
||||||
|
pub use fifo_control::*;
|
||||||
|
|
||||||
|
mod fifo_reset;
|
||||||
|
pub use fifo_reset::*;
|
||||||
|
|
||||||
|
mod sound_control;
|
||||||
|
pub use sound_control::*;
|
||||||
|
|
||||||
|
mod sound_status;
|
||||||
|
pub use sound_status::*;
|
||||||
|
|
||||||
|
mod sound_bias;
|
||||||
|
pub use sound_bias::*;
|
||||||
|
|
||||||
mod timer_control;
|
mod timer_control;
|
||||||
pub use timer_control::*;
|
pub use timer_control::*;
|
||||||
|
|
||||||
|
|
25
src/mmio_types/fifo_control.rs
Normal file
25
src/mmio_types/fifo_control.rs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||||
|
#[repr(transparent)]
|
||||||
|
pub struct FifoControl(u16);
|
||||||
|
impl FifoControl {
|
||||||
|
const_new!();
|
||||||
|
bitfield_enum!(u16; 0..=1: MixVolume, mix_volume, with_mix_volume, set_mix_volume);
|
||||||
|
bitfield_bool!(u16; 2, full_volume_a, with_full_volume_a, set_full_volume_a);
|
||||||
|
bitfield_bool!(u16; 3, full_volume_b, with_full_volume_b, set_full_volume_b);
|
||||||
|
bitfield_bool!(u16; 8, enable_right_a, with_enable_right_a, set_enable_right_a);
|
||||||
|
bitfield_bool!(u16; 9, enable_left_a, with_enable_left_a, set_enable_left_a);
|
||||||
|
bitfield_bool!(u16; 10, use_timer1_a, with_use_timer1_a, set_use_timer1_a);
|
||||||
|
bitfield_bool!(u16; 12, enable_right_b, with_enable_right_b, set_enable_right_b);
|
||||||
|
bitfield_bool!(u16; 13, enable_left_b, with_enable_left_b, set_enable_left_b);
|
||||||
|
bitfield_bool!(u16; 14, use_timer1_b, with_use_timer1_b, set_use_timer1_b);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
#[repr(u16)]
|
||||||
|
pub enum MixVolume {
|
||||||
|
_25 = 0,
|
||||||
|
_50 = 1,
|
||||||
|
_100 = 2,
|
||||||
|
}
|
10
src/mmio_types/fifo_reset.rs
Normal file
10
src/mmio_types/fifo_reset.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||||
|
#[repr(transparent)]
|
||||||
|
pub struct FifoReset(u16);
|
||||||
|
impl FifoReset {
|
||||||
|
const_new!();
|
||||||
|
bitfield_bool!(u16; 11, reset_a, with_reset_fifo_a, set_reset_fifo_a);
|
||||||
|
bitfield_bool!(u16; 15, reset_b, with_reset_fifo_b, set_reset_fifo_b);
|
||||||
|
}
|
19
src/mmio_types/sound_bias.rs
Normal file
19
src/mmio_types/sound_bias.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||||
|
#[repr(transparent)]
|
||||||
|
pub struct SoundBias(u16);
|
||||||
|
impl SoundBias {
|
||||||
|
const_new!();
|
||||||
|
bitfield_int!(u16; 1..=9: u16, bias, with_bias, set_bias);
|
||||||
|
bitfield_enum!(u16; 14..=15: SampleBits, sample_bits, with_sample_bits, set_sample_bits);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
#[repr(u16)]
|
||||||
|
pub enum SampleBits {
|
||||||
|
_9 = 0 << 14,
|
||||||
|
_8 = 1 << 14,
|
||||||
|
_7 = 2 << 14,
|
||||||
|
_6 = 3 << 14,
|
||||||
|
}
|
18
src/mmio_types/sound_control.rs
Normal file
18
src/mmio_types/sound_control.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||||
|
#[repr(transparent)]
|
||||||
|
pub struct SoundControl(u16);
|
||||||
|
impl SoundControl {
|
||||||
|
const_new!();
|
||||||
|
bitfield_int!(u16; 0..=2: u16, right_volume, with_right_volume, set_right_volume);
|
||||||
|
bitfield_int!(u16; 4..=6: u16, left_volume, with_left_volume, set_left_volume);
|
||||||
|
bitfield_bool!(u16; 8, tone1_right, with_tone1_right, set_tone1_right);
|
||||||
|
bitfield_bool!(u16; 9, tone2_right, with_tone2_right, set_tone2_right);
|
||||||
|
bitfield_bool!(u16; 10, wave_right, with_wave_right, set_wave_right);
|
||||||
|
bitfield_bool!(u16; 11, noise_right, with_noise_right, set_noise_right);
|
||||||
|
bitfield_bool!(u16; 12, tone1_left, with_tone1_left, set_tone1_left);
|
||||||
|
bitfield_bool!(u16; 13, tone2_left, with_tone2_left, set_tone2_left);
|
||||||
|
bitfield_bool!(u16; 14, wave_left, with_wave_left, set_wave_left);
|
||||||
|
bitfield_bool!(u16; 15, noise_left, with_noise_left, set_noise_left);
|
||||||
|
}
|
13
src/mmio_types/sound_status.rs
Normal file
13
src/mmio_types/sound_status.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||||
|
#[repr(transparent)]
|
||||||
|
pub struct SoundStatus(u8);
|
||||||
|
impl SoundStatus {
|
||||||
|
const_new!();
|
||||||
|
bitfield_bool!(u8; 0, tone1_playing, with_tone1_playing, set_tone1_playing);
|
||||||
|
bitfield_bool!(u8; 1, tone2_playing, with_tone2_playing, set_tone2_playing);
|
||||||
|
bitfield_bool!(u8; 2, wave_playing, with_wave_playing, set_wave_playing);
|
||||||
|
bitfield_bool!(u8; 3, noise_playing, with_noise_playing, set_noise_playing);
|
||||||
|
bitfield_bool!(u8; 7, enabled, with_enabled, set_enabled);
|
||||||
|
}
|
Loading…
Reference in a new issue