diff --git a/include/PSX/System/IOPorts/IOValues/spu_io_values.hpp b/include/PSX/System/IOPorts/IOValues/spu_io_values.hpp index 91491b61..1416fe0f 100644 --- a/include/PSX/System/IOPorts/IOValues/spu_io_values.hpp +++ b/include/PSX/System/IOPorts/IOValues/spu_io_values.hpp @@ -23,7 +23,7 @@ namespace JabyEngine { static constexpr auto ExternalAudioEnable = Bit(1); static constexpr auto CDAudioEnable = Bit(0); }; - - using SRAM_Adr = uint16_t; + + __declare_io_value(SRAM_Adr, uint16_t) {}; } } \ No newline at end of file diff --git a/include/PSX/System/IOPorts/ioport.hpp b/include/PSX/System/IOPorts/ioport.hpp index c8bc09bd..7bec4c6d 100644 --- a/include/PSX/System/IOPorts/ioport.hpp +++ b/include/PSX/System/IOPorts/ioport.hpp @@ -74,41 +74,16 @@ namespace JabyEngine { } }; - template - struct IOPortX { - using Value = S; - - S read() const { - return S{*const_cast(reinterpret_cast(this))}; - } - - void write(S value) { - *const_cast(reinterpret_cast(this)) = value.raw; - } - }; - - template - struct IOPortX { - T read() const { - return *const_cast(reinterpret_cast(this)); - } - - void write(T value) { - *const_cast(reinterpret_cast(this)) = value; - } - }; - template struct IOPort { using Value = T; - T value; T read() const { - return {const_cast*>(this)->value.raw}; + return {const_cast(reinterpret_cast(this))->raw}; } void write(T value) { - const_cast*>(this)->value.raw = value.raw; + const_cast(reinterpret_cast(this))->raw = value.raw; } }; diff --git a/include/PSX/System/IOPorts/spu_io.hpp b/include/PSX/System/IOPorts/spu_io.hpp index 737c378c..f6eb9b07 100644 --- a/include/PSX/System/IOPorts/spu_io.hpp +++ b/include/PSX/System/IOPorts/spu_io.hpp @@ -42,8 +42,6 @@ namespace JabyEngine { return this->raw; } }; - __declare_io_value(Adr, uint16_t) { - }; __declare_io_value(SampleRate, uint16_t) { static constexpr SampleRate from_HZ(uint32_t freq) { @@ -94,13 +92,13 @@ namespace JabyEngine { IOPort volumeLeft; //Offset: 0x0 IOPort volumeRight; //Offset: 0x2 IOPort sampleRate; //Offset: 0x4; - IOPort adr; //Offset: 0x6 + IOPort adr; //Offset: 0x6 IOPort ad; //Offset: 0x8 IOPort sr; //Offset: 0xA IOPort currentVolume; //Offset: 0xC - IOPort repeatAdr; //Offset: 0xE + IOPort repeatAdr; //Offset: 0xE - static constexpr Adr start_adr() { + static constexpr SRAM_Adr start_adr() { return {0x200}; } }; @@ -147,16 +145,16 @@ namespace JabyEngine { __declare_io_port_w_type(inline, SimpleVolume, Left, 0x1F801D84); __declare_io_port_w_type(inline, SimpleVolume, Right, 0x1F801D86); }; - __declare_io_port_w_type(inline, Adr, WorkAreaAdr, 0x1F801DA2); + __declare_io_port_w_type(inline, SRAM_Adr, WorkAreaAdr, 0x1F801DA2); }; static constexpr SimpleVolume operator""_vol(long double fraction) { return {static_cast(static_cast(I16_MAX)*fraction)}; } - struct SRAMTransferAddressIO : public IOPortX {}; + struct SRAMTransferAddressIO : public IOPort {}; - struct ControlRegisterIO : public IOPortX { + struct ControlRegisterIO : public IOPort { using TransferMode = Value::RAMTransferMode; void set_transfer_mode(TransferMode mode) { diff --git a/src/Library/internal-include/SPU/spu_internal.hpp b/src/Library/internal-include/SPU/spu_internal.hpp index d47508fb..b1bbdec0 100644 --- a/src/Library/internal-include/SPU/spu_internal.hpp +++ b/src/Library/internal-include/SPU/spu_internal.hpp @@ -21,7 +21,7 @@ namespace JabyEngine { SPU_IO::ControlRegister.set_transfer_mode(SPU_IO::ControlRegister::DMAWrite); } - static void set_src(SPU::SRAM_Adr adr) { + static void set_src(uintptr_t adr) { DMA_IO::SPU.set_adr(adr); } diff --git a/src/Library/src/File/Processor/vag_processor.cpp b/src/Library/src/File/Processor/vag_processor.cpp index 66eaa616..9c0e77a2 100644 --- a/src/Library/src/File/Processor/vag_processor.cpp +++ b/src/Library/src/File/Processor/vag_processor.cpp @@ -41,7 +41,7 @@ namespace JabyEngine { static Progress parse_sample(State::Configuration& config, VAGState& state) { // Load balancer? - + return Progress::Error; } static Progress parse_header(State::Configuration& config, VAGState& state) { diff --git a/src/Library/src/SPU/spu.cpp b/src/Library/src/SPU/spu.cpp index d01cbf44..3b7a8c9b 100644 --- a/src/Library/src/SPU/spu.cpp +++ b/src/Library/src/SPU/spu.cpp @@ -11,9 +11,9 @@ namespace JabyEngine { SRAM_Adr Voice :: allocate(size_t size) const { Voice::stop(); const auto voice_id = Voice::get_id(); - const auto adr = static_cast(reinterpret_cast(SPU_MMU::allocate(voice_id, size))); + const auto adr = SRAM_Adr{static_cast(reinterpret_cast(SPU_MMU::allocate(voice_id, size)))}; - SPU_IO::Voice[voice_id].adr.write({adr}); + SPU_IO::Voice[voice_id].adr.write(adr); return adr; }