This commit is contained in:
jaby 2024-09-22 14:29:05 +02:00
parent efd887268b
commit f138ca9a9d
3 changed files with 48 additions and 13 deletions

View File

@ -3,6 +3,23 @@
namespace JabyEngine { namespace JabyEngine {
namespace SPU_IO_Values { namespace SPU_IO_Values {
namespace internal {
template<typename T>
struct AliasUbus32IOPort : public IOPort<ubus32_t> {
T read() const {
return T{IOPort<ubus32_t>::read()};
}
void write(T value) {
IOPort<ubus32_t>::write(value.raw);
}
};
#define alias_ioport_ubus32(type) \
template<> \
struct IOPort<type> : public SPU_IO_Values::internal::AliasUbus32IOPort<type> {}
}
__declare_io_value(ControlRegister, uint16_t) { __declare_io_value(ControlRegister, uint16_t) {
enum RAMTransferMode { enum RAMTransferMode {
Stop = 0, Stop = 0,
@ -24,6 +41,17 @@ namespace JabyEngine {
static constexpr auto CDAudioEnable = Bit(0); static constexpr auto CDAudioEnable = Bit(0);
}; };
__declare_io_value(Echo, ubus32_t) {
static constexpr auto EchoBits = BitRange::from_to(0, 23);
static constexpr Echo AllOff() {
return Echo{0};
}
};
__declare_io_value(SRAM_Adr, uint16_t) {
};
__declare_io_value(StatusRegister, uint16_t) { __declare_io_value(StatusRegister, uint16_t) {
static constexpr auto Unused = BitRange::from_to(12, 15); static constexpr auto Unused = BitRange::from_to(12, 15);
static constexpr auto CaputreBufferHalf = Bit(11); // TODO: Turn into enum?; Writing to First/Second half of Capture Buffers (0=First, 1=Second) static constexpr auto CaputreBufferHalf = Bit(11); // TODO: Turn into enum?; Writing to First/Second half of Capture Buffers (0=First, 1=Second)
@ -38,8 +66,7 @@ namespace JabyEngine {
static constexpr auto CDAudioReverb = Bit(2); static constexpr auto CDAudioReverb = Bit(2);
static constexpr auto ExternalAudioEnable = Bit(1); static constexpr auto ExternalAudioEnable = Bit(1);
static constexpr auto CDAudioEnable = Bit(0); static constexpr auto CDAudioEnable = Bit(0);
}; };
__declare_io_value(SRAM_Adr, uint16_t) {};
} }
alias_ioport_ubus32(SPU_IO_Values::Echo);
} }

View File

@ -104,18 +104,16 @@ namespace JabyEngine {
}; };
#pragma pack(pop) #pragma pack(pop)
// TODO: This is ubus32_t
__declare_io_value(PMON, uint16_t) { __declare_io_value(PMON, uint16_t) {
static constexpr auto EnableBits = BitRange::from_to(1, 23); static constexpr auto EnableBits = BitRange::from_to(1, 23);
}; };
// TODO: This is ubus32_t
__declare_io_value(NON, uint16_t) { __declare_io_value(NON, uint16_t) {
static constexpr auto NoiseBits = BitRange::from_to(0, 23); static constexpr auto NoiseBits = BitRange::from_to(0, 23);
}; };
__declare_io_value(EON, uint16_t) {
static constexpr auto EchoBits = BitRange::from_to(0, 23);
};
static constexpr size_t VoiceCount = 24; static constexpr size_t VoiceCount = 24;
static constexpr size_t ReverbCount = 1; static constexpr size_t ReverbCount = 1;
@ -152,8 +150,7 @@ namespace JabyEngine {
return {static_cast<int16_t>(static_cast<long double>(I16_MAX)*fraction)}; return {static_cast<int16_t>(static_cast<long double>(I16_MAX)*fraction)};
} }
struct SRAMTransferAddressIO : public IOPort<SRAM_Adr> {}; //---------------------------------------------------------------------------------------------------
struct ControlRegisterIO : public IOPort<SPU_IO_Values::ControlRegister> { struct ControlRegisterIO : public IOPort<SPU_IO_Values::ControlRegister> {
using TransferMode = Value::RAMTransferMode; using TransferMode = Value::RAMTransferMode;
@ -163,18 +160,29 @@ namespace JabyEngine {
} }
}; };
struct StatusRegisterIO : public IOPort<SPU_IO_Values::StatusRegister> {}; struct EchoIO : public IOPort<SPU_IO_Values::Echo> {
};
struct StatusRegisterIO : public IOPort<SPU_IO_Values::StatusRegister> {
};
struct SRAMTransferAddressIO : public IOPort<SPU_IO_Values::SRAM_Adr> {
};
// TODO: The new way? v Parse with a Macro? // TODO: The new way? v Parse with a Macro?
static auto& EON = *reinterpret_cast<EchoIO*>(0x1F801D98);
static auto& SRAMTransferAdr = *reinterpret_cast<SRAMTransferAddressIO*>(0x1F801DA6);
static auto& ControlRegister = *reinterpret_cast<ControlRegisterIO*>(0x1F801DAA); static auto& ControlRegister = *reinterpret_cast<ControlRegisterIO*>(0x1F801DAA);
static auto& StatusRegister = *reinterpret_cast<StatusRegisterIO*>(0x1F801DAE); static auto& StatusRegister = *reinterpret_cast<StatusRegisterIO*>(0x1F801DAE);
static auto& SRAMTransferAdr = *reinterpret_cast<SRAMTransferAddressIO*>(0x1F801DA6);
//---------------------------------------------------------------------------------------------------
//__declare_io_port(, ControlRegister, 0x1F801DAA); //__declare_io_port(, ControlRegister, 0x1F801DAA);
__declare_io_port(, DataTransferControl, 0x1F801DAC); __declare_io_port(, DataTransferControl, 0x1F801DAC);
__declare_io_port(, PMON, 0x1F801D90); __declare_io_port(, PMON, 0x1F801D90);
__declare_io_port(, NON, 0x1F801D94); __declare_io_port(, NON, 0x1F801D94);
__declare_io_port(, EON, 0x1F801D98); //__declare_io_port(, EON, 0x1F801D98);
__declare_io_port_array(, Voice, VoiceCount, 0x1F801C00); __declare_io_port_array(, Voice, VoiceCount, 0x1F801C00);
} }

View File

@ -42,7 +42,7 @@ namespace JabyEngine {
static void clear_noise_and_echo() { static void clear_noise_and_echo() {
SPU_IO::NON.write({0}); SPU_IO::NON.write({0});
SPU_IO::EON.write({0}); SPU_IO::EON.write(Echo::AllOff());
} }
static void clear_reverb() { static void clear_reverb() {