diff --git a/include/PSX/System/IOPorts/ioport.hpp b/include/PSX/System/IOPorts/ioport.hpp index f877828b..1d1afa3c 100644 --- a/include/PSX/System/IOPorts/ioport.hpp +++ b/include/PSX/System/IOPorts/ioport.hpp @@ -6,17 +6,28 @@ namespace JabyEngine { template struct NormalValue { typedef T Value; - typedef T NakedValue; }; template struct VolatileValue { typedef volatile T Value; - typedef T NakedValue; }; - + + #define __declare_new_io_port(name, adr) \ + typedef name##_io_base name##_v; \ + typedef name##_io_base name##_t; \ + static auto& name = *reinterpret_cast(adr) + + #define __declare_io_type(name, type, ...) \ + template typename T> \ + struct name##_io_base { \ + T::Value value; \ + \ + __VA_ARGS__ \ + } + template - struct VolatilePOD { + struct __attribute__((deprecated)) VolatilePOD { volatile T raw; constexpr T read() const { @@ -30,7 +41,7 @@ namespace JabyEngine { // For use with ComplexBitMaps or what else satisfies this API template - struct VolatileBitMapPOD { + struct __attribute__((deprecated)) VolatileBitMapPOD { typedef typename T::UnderlyingType Raw; VolatilePOD pod; diff --git a/include/PSX/System/IOPorts/memory_io.hpp b/include/PSX/System/IOPorts/memory_io.hpp index 1a701858..162c1d75 100644 --- a/include/PSX/System/IOPorts/memory_io.hpp +++ b/include/PSX/System/IOPorts/memory_io.hpp @@ -4,27 +4,20 @@ namespace JabyEngine { namespace Memory_IO { - template typename T> - struct COM_DELAY_base { - T::Value value; - + __declare_io_type(COM_DELAY, uint32_t, void setup() { this->value = 0x1325; - } - }; - typedef COM_DELAY_base COM_DELAY_v; - typedef COM_DELAY_base COM_DELAY_t; + } + ); - struct CD_DELAY { - typedef uint32_t Type; + __declare_io_type(CD_DELAY, uint32_t, + void setup() { + this->value = 0x20943; + } + ); - static constexpr uint32_t SetupValue = 0x20943; - }; - - static auto& COM_DELAY = *reinterpret_cast(0x1F801020); - - //__declare_io_port_global_simple(COM_DELAY::Type, COM_DELAY, 0x1F801020); - __declare_io_port_global_simple(CD_DELAY::Type, CD_DELAY, 0x1F801018); + __declare_new_io_port(COM_DELAY, 0x1F801020); + __declare_new_io_port(CD_DELAY, 0x1F801018); } } diff --git a/src/Library/src/BootLoader/cd_boot.cpp b/src/Library/src/BootLoader/cd_boot.cpp index 9f6e7aa6..c7507534 100644 --- a/src/Library/src/BootLoader/cd_boot.cpp +++ b/src/Library/src/BootLoader/cd_boot.cpp @@ -17,17 +17,7 @@ namespace JabyEngine { void setup() { __syscall_EnterCriticalSection(); Memory_IO::COM_DELAY.setup(); - Memory_IO::COM_DELAY.setup(); - Memory_IO::COM_DELAY.setup(); - - Memory_IO::COM_DELAY_t b{Memory_IO::COM_DELAY.value}; - - b.setup(); - b.setup(); - b.setup(); - - //Memory_IO::COM_DELAY.write(Memory_IO::COM_DELAY::SetupValue); - Memory_IO::CD_DELAY.write(Memory_IO::CD_DELAY::SetupValue); + Memory_IO::CD_DELAY.setup(); __syscall_SysEnqIntRP(CdromIoIrq, &::JabyEngine::CD::internal::callback);