Clear voices

This commit is contained in:
2022-09-02 13:04:24 +02:00
parent 181ff65c9c
commit cf663aee73
3 changed files with 29 additions and 2 deletions

View File

@@ -138,6 +138,10 @@ public:
const_cast<volatile IOPort<T>*>(this)->value = value;
}
constexpr volatile T& ref() {
return const_cast<volatile IOPort<T>*>(this)->value;
}
//For raw access
constexpr operator T() const {
return this->value;
@@ -204,7 +208,8 @@ struct __no_align ubus32_t {
static constexpr uintptr_t IO_Base_Mask = 0xF0000000;
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) \
using IOPort::operator=; \
constexpr name() = default; \

View File

@@ -53,6 +53,8 @@ namespace SPU {
};
struct __no_align SR : public IOPort<uint16_t> {
__io_port_inherit(SR);
static constexpr Bit<Mode> SustainMode = (31 - 16);
static constexpr Bit<Direction> SustainDirection = (30 - 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> {
__io_port_inherit(AD);
static constexpr Bit<Mode> AttackMode = 15;
static constexpr BitRange<Shift> AttackShift = BitRange<Shift>::from_to(10, 14);
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 size_t VoiceCount = 24;
namespace Key {
__declare_io_port_global(ubus32_t, on, 0x1F801D88);
__declare_io_port_global(ubus32_t, off, 0x1F801D8C);
@@ -114,7 +120,8 @@ namespace SPU {
__declare_io_port_global(SweepVolume, right, 0x1F801D82);
}
__declare_io_port_global(ControlRegister, Control, 0x1F801DAA);
__declare_io_port_global(ControlRegister, Control, 0x1F801DAA);
__declare_io_port_global_array(Voice, Voices, 0x1F801C00, VoiceCount);
}
}