From b070dc655a41a1b6128387b692c19aab9a73e09c Mon Sep 17 00:00:00 2001 From: jaby Date: Wed, 31 Aug 2022 20:01:39 +0200 Subject: [PATCH] Re-arranged files --- include/PSX/Auxiliary/io_class_helper.hpp | 6 ++-- .../IOPorts/SPU_IO.hpp} | 22 +++++------- lib/pcsx-redux/ps-exe.ld | 18 +++++----- src/Library/Library.code-workspace | 1 + src/Library/Makefile | 2 +- .../include/BootLoader/boot_loader.hpp | 8 +++++ src/Library/src/BootLoader/boot_spu.cpp | 26 ++++++++++++++ src/Library/src/BootLoader/boot_start.cpp | 11 ++++++ src/Library/src/BootLoader/start.cpp | 36 ------------------- 9 files changed, 69 insertions(+), 61 deletions(-) rename include/PSX/{SPU/SPU_Ports.hpp => System/IOPorts/SPU_IO.hpp} (85%) create mode 100644 src/Library/include/BootLoader/boot_loader.hpp create mode 100644 src/Library/src/BootLoader/boot_spu.cpp create mode 100644 src/Library/src/BootLoader/boot_start.cpp delete mode 100644 src/Library/src/BootLoader/start.cpp diff --git a/include/PSX/Auxiliary/io_class_helper.hpp b/include/PSX/Auxiliary/io_class_helper.hpp index 49139694..e99e236f 100644 --- a/include/PSX/Auxiliary/io_class_helper.hpp +++ b/include/PSX/Auxiliary/io_class_helper.hpp @@ -23,8 +23,10 @@ } template -static constexpr void io_class__volatile_assign(volatile T& dst, const T& src) { - dst.raw_value = src.raw_value; +static constexpr __always_inline void io_class__volatile_assign(T& dst, const T& src) { + typedef decltype(dst.raw_value) DST_VALUE; + + const_cast(dst.raw_value) = src.raw_value; } #endif //!__JABYENGINE_IO_CLASS_HELPER_HPP__ \ No newline at end of file diff --git a/include/PSX/SPU/SPU_Ports.hpp b/include/PSX/System/IOPorts/SPU_IO.hpp similarity index 85% rename from include/PSX/SPU/SPU_Ports.hpp rename to include/PSX/System/IOPorts/SPU_IO.hpp index 471adfbc..65ca28a0 100644 --- a/include/PSX/SPU/SPU_Ports.hpp +++ b/include/PSX/System/IOPorts/SPU_IO.hpp @@ -1,7 +1,7 @@ -#ifndef __JABYENGINE_SPU_PORTS_HPP__ -#define __JABYENGINE_SPU_PORTS_HPP__ -#include "../Auxiliary/io_class_helper.hpp" -#include "../../limits.h" +#ifndef __JABYENGINE_SPU_IO_HPP__ +#define __JABYENGINE_SPU_IO_HPP__ +#include "../../Auxiliary/io_class_helper.hpp" +#include namespace SPU { enum Mode { @@ -46,17 +46,13 @@ namespace SPU { return *this; } - //A value between 0 and 1000 - constexpr auto& set_volume_step(VolumeStep volume_step) { - volume_step *= SingleVolumeStep; - - this->raw_value = bit::value::set_normalized(this->raw_value, volume_step, __start_end_bit2_start_length(0, 14)); + constexpr auto& set_volume(int16_t volume) { + this->raw_value = bit::value::set_normalized(this->raw_value, static_cast((volume >> 1)), __start_end_bit2_start_length(0, 14)); return *this; } - //A value between 0 and 1000 - constexpr VolumeStep get_volume_step() const { - return (bit::value::get_normalized(this->raw_value, __start_end_bit2_start_length(0, 14))/SingleVolumeStep); + constexpr int16_t get_volume_step() const { + return bit::value::get_normalized(this->raw_value, __start_end_bit2_start_length(0, 14)); } io_class__2option_map(volume_mode, sweep_mode, 15); @@ -109,4 +105,4 @@ namespace SPU { }; } -#endif //!__JABYENGINE_SPU_PORTS_HPP__ \ No newline at end of file +#endif //!__JABYENGINE_SPU_IO_HPP__ \ No newline at end of file diff --git a/lib/pcsx-redux/ps-exe.ld b/lib/pcsx-redux/ps-exe.ld index 9d93b5b2..a91afff1 100644 --- a/lib/pcsx-redux/ps-exe.ld +++ b/lib/pcsx-redux/ps-exe.ld @@ -68,16 +68,16 @@ SECTIONS { { .planschi { - *libJabyEngine.a:start.o(.text.startup._GLOBAL__*) - *libJabyEngine.a:start.o(.ctors) + *libJabyEngine.a:boot_*.o(.text.startup._GLOBAL__*) + *libJabyEngine.a:boot_*.o(.ctors) - *libJabyEngine.a:start.o(.text.*) - *libJabyEngine.a:start.o(.rodata*) - *libJabyEngine.a:start.o(.sdata*) - *libJabyEngine.a:start.o(.data*) - *libJabyEngine.a:start.o(.sbss*) - *libJabyEngine.a:start.o(.bss*) - *libJabyEngine.a:start.o(*) + *libJabyEngine.a:boot_*.o(.text.*) + *libJabyEngine.a:boot_*.o(.rodata*) + *libJabyEngine.a:boot_*.o(.sdata*) + *libJabyEngine.a::boot_*.o(.data*) + *libJabyEngine.a::boot_*.o(.sbss*) + *libJabyEngine.a::boot_*.o(.bss*) + *libJabyEngine.a::boot_*.o(*) } } __boot_loader_end = .; diff --git a/src/Library/Library.code-workspace b/src/Library/Library.code-workspace index 44697c10..94b6f8e3 100644 --- a/src/Library/Library.code-workspace +++ b/src/Library/Library.code-workspace @@ -55,6 +55,7 @@ }, "settings": { "C_Cpp.default.includePath": [ + "include", "../../include" ], "C_Cpp.default.compilerPath": "", diff --git a/src/Library/Makefile b/src/Library/Makefile index 4965ce0b..91056301 100644 --- a/src/Library/Makefile +++ b/src/Library/Makefile @@ -1,7 +1,7 @@ ARTIFACT = libJabyEngine BUILD_DIR = bin -CCFLAGS += -I../../include +CCFLAGS += -Iinclude -I../../include CCFLAGS += -save-temps=obj include ../../lib/Wildcard.mk diff --git a/src/Library/include/BootLoader/boot_loader.hpp b/src/Library/include/BootLoader/boot_loader.hpp new file mode 100644 index 00000000..5870a36b --- /dev/null +++ b/src/Library/include/BootLoader/boot_loader.hpp @@ -0,0 +1,8 @@ +#ifndef BOOT_LOADER_HPP +#define BOOT_LOADER_HPP + +namespace SPU { + void setup(); +} + +#endif //!BOOT_LOADER_HPP \ No newline at end of file diff --git a/src/Library/src/BootLoader/boot_spu.cpp b/src/Library/src/BootLoader/boot_spu.cpp new file mode 100644 index 00000000..14721fcd --- /dev/null +++ b/src/Library/src/BootLoader/boot_spu.cpp @@ -0,0 +1,26 @@ +#include + +namespace SPU { + static void clear_voice(Voice& voice) { + io_class__volatile_assign(voice.volumeLeft, SweepVolume()); + io_class__volatile_assign(voice.volumeRight, SweepVolume()); + + io_class__volatile_assign(voice.sampleRate, SampleRate::from_HZ(0.0)); + io_class__volatile_assign(voice.adsr, ADSR()); + io_class__volatile_assign(voice.currentVolume, SweepVolume()); + + voice.adr = 0x200; + voice.repeatAdr = 0x200; + } + + void setup() { + static constexpr auto StartVol = SweepVolume().set_volume_mode().set_volume_percent(50.0); + + io_class__volatile_assign(MainVolume::Left, StartVol); + io_class__volatile_assign(MainVolume::Right, StartVol); + + for(auto& voice : Voice::Channel) { + clear_voice(voice); + } + } +} \ No newline at end of file diff --git a/src/Library/src/BootLoader/boot_start.cpp b/src/Library/src/BootLoader/boot_start.cpp new file mode 100644 index 00000000..c3c5f3c4 --- /dev/null +++ b/src/Library/src/BootLoader/boot_start.cpp @@ -0,0 +1,11 @@ +#include "BootLoader/boot_loader.hpp" +#include + +namespace JabyEngine { + void start() { + printf("Hello Planschbecken\n"); + + SPU::setup(); + printf("Setup done!\n"); + } +} \ No newline at end of file diff --git a/src/Library/src/BootLoader/start.cpp b/src/Library/src/BootLoader/start.cpp deleted file mode 100644 index 0198b4fb..00000000 --- a/src/Library/src/BootLoader/start.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -namespace JabyEngine { - namespace SPU { - static void clear_voice(::SPU::Voice& voice) { - io_class__volatile_assign(voice.volumeLeft, ::SPU::SweepVolume()); - io_class__volatile_assign(voice.volumeRight, ::SPU::SweepVolume()); - - io_class__volatile_assign(voice.sampleRate, ::SPU::SampleRate::from_HZ(0.0)); - io_class__volatile_assign(voice.adsr, ::SPU::ADSR()); - io_class__volatile_assign(voice.currentVolume, ::SPU::SweepVolume()); - - voice.adr = 0x200; - voice.repeatAdr = 0x200; - } - - static void setup() { - static constexpr auto StartVol = ::SPU::SweepVolume().set_volume_mode().set_volume_percent(50.0); - - io_class__volatile_assign(::SPU::MainVolume::Left, StartVol); - io_class__volatile_assign(::SPU::MainVolume::Right, StartVol); - - for(auto& voice : ::SPU::Voice::Channel) { - clear_voice(voice); - } - } - } - - void start() { - printf("Hello Planschbecken\n"); - - SPU::setup(); - printf("Setup done!\n"); - } -} \ No newline at end of file