From f138ca9a9d4c370097be64a5ac06856ac1c6aa09 Mon Sep 17 00:00:00 2001 From: jaby Date: Sun, 22 Sep 2024 14:29:05 +0200 Subject: [PATCH] Fix EON --- .../System/IOPorts/IOValues/spu_io_values.hpp | 33 +++++++++++++++++-- include/PSX/System/IOPorts/spu_io.hpp | 26 ++++++++++----- src/Library/src/BootLoader/spu_boot.cpp | 2 +- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/include/PSX/System/IOPorts/IOValues/spu_io_values.hpp b/include/PSX/System/IOPorts/IOValues/spu_io_values.hpp index 36dd32e2..29abad4e 100644 --- a/include/PSX/System/IOPorts/IOValues/spu_io_values.hpp +++ b/include/PSX/System/IOPorts/IOValues/spu_io_values.hpp @@ -3,6 +3,23 @@ namespace JabyEngine { namespace SPU_IO_Values { + namespace internal { + template + struct AliasUbus32IOPort : public IOPort { + T read() const { + return T{IOPort::read()}; + } + + void write(T value) { + IOPort::write(value.raw); + } + }; + + #define alias_ioport_ubus32(type) \ + template<> \ + struct IOPort : public SPU_IO_Values::internal::AliasUbus32IOPort {} + } + __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); } \ No newline at end of file diff --git a/include/PSX/System/IOPorts/spu_io.hpp b/include/PSX/System/IOPorts/spu_io.hpp index 9d6197ee..3c08c64e 100644 --- a/include/PSX/System/IOPorts/spu_io.hpp +++ b/include/PSX/System/IOPorts/spu_io.hpp @@ -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(static_cast(I16_MAX)*fraction)}; } - struct SRAMTransferAddressIO : public IOPort {}; - +//--------------------------------------------------------------------------------------------------- struct ControlRegisterIO : public IOPort { using TransferMode = Value::RAMTransferMode; @@ -163,18 +160,29 @@ namespace JabyEngine { } }; - struct StatusRegisterIO : public IOPort {}; + struct EchoIO : public IOPort { + }; + + struct StatusRegisterIO : public IOPort { + }; + + struct SRAMTransferAddressIO : public IOPort { + }; + // TODO: The new way? v Parse with a Macro? + static auto& EON = *reinterpret_cast(0x1F801D98); + static auto& SRAMTransferAdr = *reinterpret_cast(0x1F801DA6); static auto& ControlRegister = *reinterpret_cast(0x1F801DAA); static auto& StatusRegister = *reinterpret_cast(0x1F801DAE); - static auto& SRAMTransferAdr = *reinterpret_cast(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); } diff --git a/src/Library/src/BootLoader/spu_boot.cpp b/src/Library/src/BootLoader/spu_boot.cpp index 2371f0f9..32d73491 100644 --- a/src/Library/src/BootLoader/spu_boot.cpp +++ b/src/Library/src/BootLoader/spu_boot.cpp @@ -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() {