Clear voices
This commit is contained in:
parent
595b6e0ec5
commit
e3a53bfd42
|
@ -138,6 +138,10 @@ public:
|
||||||
const_cast<volatile IOPort<T>*>(this)->value = value;
|
const_cast<volatile IOPort<T>*>(this)->value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr volatile T& ref() {
|
||||||
|
return const_cast<volatile IOPort<T>*>(this)->value;
|
||||||
|
}
|
||||||
|
|
||||||
//For raw access
|
//For raw access
|
||||||
constexpr operator T() const {
|
constexpr operator T() const {
|
||||||
return this->value;
|
return this->value;
|
||||||
|
@ -205,6 +209,7 @@ static constexpr uintptr_t IO_Base_Mask = 0xF0000000;
|
||||||
static constexpr uintptr_t IO_Base_Adr = 0x10000000;
|
static constexpr uintptr_t IO_Base_Adr = 0x10000000;
|
||||||
|
|
||||||
#define __declare_io_port_global(type, name, adr) static __always_inline auto& name = *reinterpret_cast<IOPort<type>*>((IO_Base_Adr + (adr & ~IO_Base_Mask)))
|
#define __declare_io_port_global(type, name, adr) static __always_inline auto& name = *reinterpret_cast<IOPort<type>*>((IO_Base_Adr + (adr & ~IO_Base_Mask)))
|
||||||
|
#define __declare_io_port_global_array(type, name, adr, size) static __always_inline auto& name = reinterpret_cast<type(&)[size]>(*reinterpret_cast<type*>((IO_Base_Adr + (adr & ~IO_Base_Mask))));
|
||||||
#define __io_port_inherit(name) \
|
#define __io_port_inherit(name) \
|
||||||
using IOPort::operator=; \
|
using IOPort::operator=; \
|
||||||
constexpr name() = default; \
|
constexpr name() = default; \
|
||||||
|
|
|
@ -53,6 +53,8 @@ namespace SPU {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct __no_align SR : public IOPort<uint16_t> {
|
struct __no_align SR : public IOPort<uint16_t> {
|
||||||
|
__io_port_inherit(SR);
|
||||||
|
|
||||||
static constexpr Bit<Mode> SustainMode = (31 - 16);
|
static constexpr Bit<Mode> SustainMode = (31 - 16);
|
||||||
static constexpr Bit<Direction> SustainDirection = (30 - 16);
|
static constexpr Bit<Direction> SustainDirection = (30 - 16);
|
||||||
static constexpr BitRange<Shift> SustainShift = BitRange<Shift>::from_to((24 - 16), (28 - 16));
|
static constexpr BitRange<Shift> SustainShift = BitRange<Shift>::from_to((24 - 16), (28 - 16));
|
||||||
|
@ -62,6 +64,8 @@ namespace SPU {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct __no_align AD : public IOPort<uint16_t> {
|
struct __no_align AD : public IOPort<uint16_t> {
|
||||||
|
__io_port_inherit(AD);
|
||||||
|
|
||||||
static constexpr Bit<Mode> AttackMode = 15;
|
static constexpr Bit<Mode> AttackMode = 15;
|
||||||
static constexpr BitRange<Shift> AttackShift = BitRange<Shift>::from_to(10, 14);
|
static constexpr BitRange<Shift> AttackShift = BitRange<Shift>::from_to(10, 14);
|
||||||
static constexpr BitRange<Step> AttackStep = BitRange<Step>::from_to(8, 9);
|
static constexpr BitRange<Step> AttackStep = BitRange<Step>::from_to(8, 9);
|
||||||
|
@ -103,6 +107,8 @@ namespace SPU {
|
||||||
static constexpr Bit<uint16_t> CDAudioEnable = 0;
|
static constexpr Bit<uint16_t> CDAudioEnable = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static constexpr size_t VoiceCount = 24;
|
||||||
|
|
||||||
namespace Key {
|
namespace Key {
|
||||||
__declare_io_port_global(ubus32_t, on, 0x1F801D88);
|
__declare_io_port_global(ubus32_t, on, 0x1F801D88);
|
||||||
__declare_io_port_global(ubus32_t, off, 0x1F801D8C);
|
__declare_io_port_global(ubus32_t, off, 0x1F801D8C);
|
||||||
|
@ -115,6 +121,7 @@ namespace SPU {
|
||||||
}
|
}
|
||||||
|
|
||||||
__declare_io_port_global(ControlRegister, Control, 0x1F801DAA);
|
__declare_io_port_global(ControlRegister, Control, 0x1F801DAA);
|
||||||
|
__declare_io_port_global_array(Voice, Voices, 0x1F801C00, VoiceCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,20 @@ namespace SPU {
|
||||||
Control.write(ControlRegister());
|
Control.write(ControlRegister());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void clear_voice() {
|
||||||
|
for(auto& voice : Voices) {
|
||||||
|
voice.volumeLeft.write(SweepVolume());
|
||||||
|
voice.volumeRight.write(SweepVolume());
|
||||||
|
voice.sampleRate.write(SampleRate());
|
||||||
|
voice.ad.write(AD());
|
||||||
|
voice.sr.write(SR());
|
||||||
|
voice.currentVolume.write(SweepVolume());
|
||||||
|
|
||||||
|
voice.adr.write(0x200);
|
||||||
|
voice.repeatAdr.write(0x200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void setup_control_register() {
|
static void setup_control_register() {
|
||||||
static constexpr auto SetupValue = ControlRegister() | ControlRegister::Enable | ControlRegister::Unmute | ControlRegister::CDAudioEnable;
|
static constexpr auto SetupValue = ControlRegister() | ControlRegister::Enable | ControlRegister::Unmute | ControlRegister::CDAudioEnable;
|
||||||
|
|
||||||
|
@ -29,6 +43,7 @@ namespace SPU {
|
||||||
clear_key();
|
clear_key();
|
||||||
clear_main_volume();
|
clear_main_volume();
|
||||||
clear_control_register();
|
clear_control_register();
|
||||||
|
clear_voice();
|
||||||
|
|
||||||
setup_control_register();
|
setup_control_register();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue