Continue setup SPU

This commit is contained in:
2022-08-31 21:17:14 +02:00
parent b070dc655a
commit 48ba6a4f8b
3 changed files with 77 additions and 13 deletions

View File

@@ -4,6 +4,29 @@
#include <limits.h>
namespace SPU {
struct __no_align ubus32_t
{
uint16_t low;
uint16_t high;
constexpr ubus32_t() : low(0), high(0) {
}
constexpr operator uint32_t() const {
return ((this->high << 16) | this->low);
}
constexpr void operator=(uint32_t value) {
this->low = (value & 0xFFFF);
this->high = (value >> 16);
}
constexpr void operator=(ubus32_t value) volatile {
this->low = value.low;
this->high = value.high;
}
};
enum Mode {
Linear = 0,
Exponential = 1,
@@ -86,9 +109,41 @@ namespace SPU {
uint32_t raw_value = 0;
};
struct __no_align KeyW {
ubus32_t raw_value;
constexpr KeyW() = default;
static constexpr KeyW All1() {
KeyW value;
value.raw_value = static_cast<uint32_t>(0xFFFFFFFF);
return value;
}
constexpr KeyW& set(size_t id) {
this->raw_value = bit::set<uint32_t>(this->raw_value, id);
return *this;
}
};
struct __no_align KeyR {
ubus32_t raw_value;
constexpr bool is_set(size_t id) const {
return bit::is_set<uint32_t>(this->raw_value, id);
}
};
struct __no_align Key {
static inline __always_inline auto& on = *reinterpret_cast<KeyW*>(0x1F801D88);
static inline __always_inline auto& off = *reinterpret_cast<KeyW*>(0x1F801D8C);
static inline __always_inline auto& state = *reinterpret_cast<KeyR*>(0x1F801D9C);
};
struct __no_align Voice {
static constexpr size_t Count = 24;
static inline __always_inline auto& Channel = reinterpret_cast<Voice(&)[Count]>(*reinterpret_cast<Voice*>(0x1f801c00));
static constexpr size_t Count = 24;
static inline __always_inline auto& Channel = reinterpret_cast<Voice(&)[Count]>(*reinterpret_cast<Voice*>(0x1f801c00));
SweepVolume volumeLeft;
SweepVolume volumeRight;