New proposal

This commit is contained in:
jaby 2023-01-13 19:34:01 +01:00
parent c1f86c11c3
commit 509c25dfec
2 changed files with 45 additions and 2 deletions

View File

@ -195,6 +195,10 @@ namespace JabyEngine {
this->clear_bit(value.bit);
return *this;
}
constexpr __always_inline operator T() const {
return this->raw;
}
};
}

View File

@ -1,10 +1,49 @@
#include "../../include/CD/cd_internal.hpp"
#include <PSX/Auxiliary/complex_bitmap.hpp>
namespace JabyEngine {
namespace CD {
namespace internal {
template<typename T, typename S = T>
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<T>(value);
}
};
struct __no_align Wuff : public ComplexBitMap<uint32_t> {
static constexpr auto Miau = Bit<uint32_t>(0);
static constexpr auto Blubb = BitRange<uint32_t>::from_to(0, 5);
};
static __always_inline auto& Wuff = *reinterpret_cast<IOPortX<uint32_t, struct Wuff>*>(0x1F80000);
static uint32_t read(const IOPortX<uint32_t, struct Wuff>& 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)});
}
}
}
}