Save state
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user