diff --git a/include/PSX/Auxiliary/complex_bitmap.hpp b/include/PSX/Auxiliary/complex_bitmap.hpp index ec4f6d1f..ce0bb742 100644 --- a/include/PSX/Auxiliary/complex_bitmap.hpp +++ b/include/PSX/Auxiliary/complex_bitmap.hpp @@ -195,6 +195,10 @@ namespace JabyEngine { this->clear_bit(value.bit); return *this; } + + constexpr __always_inline operator T() const { + return this->raw; + } }; } diff --git a/src/Library/src/CD/cd.cpp b/src/Library/src/CD/cd.cpp index 2027f2f6..7d2e8973 100644 --- a/src/Library/src/CD/cd.cpp +++ b/src/Library/src/CD/cd.cpp @@ -1,10 +1,49 @@ #include "../../include/CD/cd_internal.hpp" +#include namespace JabyEngine { namespace CD { - - namespace internal { + template + class IOPortX { + private: + volatile T value; + public: + constexpr T read_raw() const { + return this->value; + } + + constexpr S read() const { + return S{this->value}; + } + + constexpr void write_raw(T value) { + this->value = value; + } + + constexpr void write(const S& value) { + this->value = static_cast(value); + } + }; + + struct __no_align Wuff : public ComplexBitMap { + static constexpr auto Miau = Bit(0); + static constexpr auto Blubb = BitRange::from_to(0, 5); + }; + + static __always_inline auto& Wuff = *reinterpret_cast*>(0x1F80000); + + static uint32_t read(const IOPortX& port) { + return port.read().get_value(Wuff::Blubb); + } + + + namespace internal { + void setup() { + while(Wuff.read().is_bit_set(Wuff::Miau)); + + Wuff.write({Wuff::with(Wuff::Miau)}); + } } } } \ No newline at end of file