Integrate all the progress into master #6

Merged
jaby merged 595 commits from ToolBox into main 2025-01-01 13:17:44 +00:00
3 changed files with 48 additions and 13 deletions
Showing only changes of commit 1b241184fc - Show all commits

View File

@ -3,6 +3,23 @@
namespace JabyEngine {
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) {
enum RAMTransferMode {
Stop = 0,
@ -24,6 +41,17 @@ namespace JabyEngine {
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) {
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)
@ -38,8 +66,7 @@ namespace JabyEngine {
static constexpr auto CDAudioReverb = Bit(2);
static constexpr auto ExternalAudioEnable = Bit(1);
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)
// TODO: This is ubus32_t
__declare_io_value(PMON, uint16_t) {
static constexpr auto EnableBits = BitRange::from_to(1, 23);
};
// TODO: This is ubus32_t
__declare_io_value(NON, uint16_t) {
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 ReverbCount = 1;
@ -152,8 +150,7 @@ namespace JabyEngine {
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> {
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?
static auto& EON = *reinterpret_cast<EchoIO*>(0x1F801D98);
static auto& SRAMTransferAdr = *reinterpret_cast<SRAMTransferAddressIO*>(0x1F801DA6);
static auto& ControlRegister = *reinterpret_cast<ControlRegisterIO*>(0x1F801DAA);
static auto& StatusRegister = *reinterpret_cast<StatusRegisterIO*>(0x1F801DAE);
static auto& SRAMTransferAdr = *reinterpret_cast<SRAMTransferAddressIO*>(0x1F801DA6);
//---------------------------------------------------------------------------------------------------
//__declare_io_port(, ControlRegister, 0x1F801DAA);
__declare_io_port(, DataTransferControl, 0x1F801DAC);
__declare_io_port(, PMON, 0x1F801D90);
__declare_io_port(, NON, 0x1F801D94);
__declare_io_port(, EON, 0x1F801D98);
//__declare_io_port(, EON, 0x1F801D98);
__declare_io_port_array(, Voice, VoiceCount, 0x1F801C00);
}

View File

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