SPU Controll Register
This commit is contained in:
parent
de7d0945a1
commit
a84b2c4f14
|
@ -15,13 +15,22 @@
|
|||
|
||||
#define io_class__2option_map_getter(type, option0, option1, name, bit_num) \
|
||||
io_class__2option_map(option0, option1, bit_num) \
|
||||
io_class__option_as(type, name, bit_num)
|
||||
io_class__option_get(type, name, bit_num)
|
||||
|
||||
#define io_class__option_as(type, name, bit_num) \
|
||||
#define io_class__2option_map_getter_is(type, option0, option1, bit_num) \
|
||||
io_class__2option_map(option0, option1, bit_num) \
|
||||
io_class__option_is(type, option1, bit_num)
|
||||
|
||||
#define io_class__option_get(type, name, bit_num) \
|
||||
constexpr type get_##name() const { \
|
||||
return static_cast<type>(bit::is_set(this->raw_value, bit_num)); \
|
||||
}
|
||||
|
||||
#define io_class__option_is(type, name, bit_num) \
|
||||
constexpr type is_##name() const { \
|
||||
return static_cast<type>(bit::is_set(this->raw_value, bit_num)); \
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static constexpr __always_inline void io_class__update_with(T& dst, const T& src) {
|
||||
typedef decltype(dst.raw_value) DST_VALUE;
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace SPU {
|
|||
};
|
||||
|
||||
struct __no_align ADSR {
|
||||
uint32_t raw_value = 0;
|
||||
ubus32_t raw_value;
|
||||
};
|
||||
|
||||
struct __no_align KeyW {
|
||||
|
@ -158,6 +158,60 @@ namespace SPU {
|
|||
static inline __always_inline auto& Left = *reinterpret_cast<SweepVolume*>(0x1F801D80);
|
||||
static inline __always_inline auto& Right = *reinterpret_cast<SweepVolume*>(0x1F801D82);
|
||||
};
|
||||
|
||||
struct __no_align Control {
|
||||
static inline __always_inline auto& Register = *reinterpret_cast<Control*>(0x1F801DAA);
|
||||
|
||||
enum TransferMode
|
||||
{
|
||||
Stop = 0,
|
||||
ManualWrite = (1 << 4),
|
||||
DMAWrite = (2 << 4),
|
||||
DMARead = (3 << 4),
|
||||
};
|
||||
|
||||
uint16_t raw_value = 0;
|
||||
|
||||
constexpr Control() = default;
|
||||
|
||||
io_class__2option_map(off, on, 15);
|
||||
io_class__2option_map_getter_is(bool, mute, unmute, 14);
|
||||
|
||||
constexpr Control& set_noise_shift(uint8_4b shift) {
|
||||
this->raw_value = bit::value::set_normalized(this->raw_value, static_cast<uint16_t>(shift), __start_end_bit2_start_length(10, 13));
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr uint8_4b get_noise_shift() const {
|
||||
return bit::value::get_normalized(this->raw_value, __start_end_bit2_start_length(10, 13));
|
||||
}
|
||||
|
||||
constexpr Control& set_noise_step(uint8_2b step) {
|
||||
this->raw_value = bit::value::set_normalized(this->raw_value, static_cast<uint16_t>(step), __start_end_bit2_start_length(8, 9));
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr uint8_2b get_noise_step() const {
|
||||
return bit::value::get_normalized(this->raw_value, __start_end_bit2_start_length(8, 9));
|
||||
}
|
||||
|
||||
io_class__2option_map_getter_is(bool, reverb_disabled, reverb_enabled, 7);
|
||||
io_class__2option_map(irq9_ack, irq9_enable, 6);
|
||||
|
||||
constexpr Control& set_transfer_mode(TransferMode mode) {
|
||||
this->raw_value = bit::value::set_normalized(this->raw_value, static_cast<uint16_t>(mode), __start_end_bit2_start_length(4, 5));
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr TransferMode get_transfer_mode() const {
|
||||
return static_cast<TransferMode>(bit::value::get_normalized(this->raw_value, __start_end_bit2_start_length(4, 5)));
|
||||
}
|
||||
|
||||
io_class__2option_map_getter_is(bool, external_reverb_off, external_reverb_on, 3);
|
||||
io_class__2option_map_getter_is(bool, cd_reverb_off, cd_reverb_on, 2);
|
||||
io_class__2option_map_getter_is(bool, external_audio_off, external_audio_on, 1);
|
||||
io_class__2option_map_getter_is(bool, cd_audio_disable, cd_audio_enable, 0);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //!__JABYENGINE_SPU_IO_HPP__
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
//uint<real bits>_<used bits>b;
|
||||
typedef uint8_t uint8_5b;
|
||||
typedef uint8_t uint8_4b;
|
||||
typedef uint8_t uint8_2b;
|
||||
|
||||
#endif //!__JABYENGINE_DEFINES__H
|
|
@ -24,12 +24,23 @@ namespace SPU {
|
|||
voice.repeatAdr = 0x200;
|
||||
}
|
||||
|
||||
static void enable_control() {
|
||||
io_class__update_with(Control::Register, Control().set_on().set_unmute().set_cd_audio_enable());
|
||||
}
|
||||
|
||||
static void disable_control() {
|
||||
io_class__update_with(Control::Register, Control());
|
||||
}
|
||||
|
||||
void setup() {
|
||||
clear_main_volume();
|
||||
clear_keys();
|
||||
disable_control();
|
||||
|
||||
for(auto& voice : Voice::Channel) {
|
||||
clear_voice(voice);
|
||||
}
|
||||
|
||||
enable_control();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue