Refine new IO port concept
This commit is contained in:
@@ -6,17 +6,28 @@ namespace JabyEngine {
|
||||
template<typename T>
|
||||
struct NormalValue {
|
||||
typedef T Value;
|
||||
typedef T NakedValue;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct VolatileValue {
|
||||
typedef volatile T Value;
|
||||
typedef T NakedValue;
|
||||
};
|
||||
|
||||
|
||||
#define __declare_new_io_port(name, adr) \
|
||||
typedef name##_io_base<VolatileValue> name##_v; \
|
||||
typedef name##_io_base<NormalValue> name##_t; \
|
||||
static auto& name = *reinterpret_cast<name##_v*>(adr)
|
||||
|
||||
#define __declare_io_type(name, type, ...) \
|
||||
template<template<typename> typename T> \
|
||||
struct name##_io_base { \
|
||||
T<type>::Value value; \
|
||||
\
|
||||
__VA_ARGS__ \
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
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<typename T>
|
||||
struct VolatileBitMapPOD {
|
||||
struct __attribute__((deprecated)) VolatileBitMapPOD {
|
||||
typedef typename T::UnderlyingType Raw;
|
||||
|
||||
VolatilePOD<Raw> pod;
|
||||
|
@@ -4,27 +4,20 @@
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Memory_IO {
|
||||
template<template<typename> typename T>
|
||||
struct COM_DELAY_base {
|
||||
T<uint32_t>::Value value;
|
||||
|
||||
__declare_io_type(COM_DELAY, uint32_t,
|
||||
void setup() {
|
||||
this->value = 0x1325;
|
||||
}
|
||||
};
|
||||
typedef COM_DELAY_base<VolatileValue> COM_DELAY_v;
|
||||
typedef COM_DELAY_base<NormalValue> 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<COM_DELAY_v*>(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user