Save state

This commit is contained in:
2024-09-06 18:32:09 +01:00
parent 0dcd2b71a6
commit a4426ad5d2
8 changed files with 143 additions and 32 deletions

View File

@@ -74,8 +74,33 @@ namespace JabyEngine {
}
};
template<typename S, typename T = S::UnderlyingType>
struct IOPortX {
using Value = S;
S read() const {
return S{*const_cast<const volatile T*>(reinterpret_cast<const T*>(this))};
}
void write(S value) {
*const_cast<volatile T*>(reinterpret_cast<T*>(this)) = value.raw;
}
};
template<typename T>
struct IOPortX<T, T> {
T read() const {
return *const_cast<const volatile T*>(reinterpret_cast<const T*>(this));
}
void write(T value) {
*const_cast<volatile T*>(reinterpret_cast<T*>(this)) = value;
}
};
template<typename T>
struct IOPort {
using Value = T;
T value;
T read() const {
@@ -89,6 +114,7 @@ namespace JabyEngine {
template<>
struct IOPort<ubus32_t> {
using Value = ubus32_t;
ubus32_t value;
ubus32_t read() const {