diff --git a/include/PSX/System/IOPorts/ioport.hpp b/include/PSX/System/IOPorts/ioport.hpp index cd1e7a37..97f1fbdd 100644 --- a/include/PSX/System/IOPorts/ioport.hpp +++ b/include/PSX/System/IOPorts/ioport.hpp @@ -3,6 +3,24 @@ #include "../../Auxiliary/complex_bitmap.hpp" namespace JabyEngine { + struct IOBitUnset { + size_t pos; + + constexpr IOBitUnset(size_t bit_pos) : pos(bit_pos) { + } + }; + + struct IOBitSet { + size_t pos; + + constexpr IOBitSet(size_t bit_pos) : pos(bit_pos) { + } + + constexpr IOBitUnset operator!() const { + return IOBitUnset(this->pos); + } + }; + template struct NormalValue { typedef T Value; @@ -26,6 +44,24 @@ namespace JabyEngine { name##_io_base(type value) : raw_value(value) {} \ __VA_ARGS__ \ \ + void set(IOBitSet bit) { \ + this->raw_value = bit::set(this->raw_value, bit.pos); \ + } \ + void set(IOBitUnset bit) { \ + this->raw_value = bit::clear(this->raw_value, bit.pos); \ + } \ + \ + \ + void clear(IOBitSet bit) { \ + this->raw_value = bit::clear(this->raw_value, bit.pos); \ + } \ + \ + \ + bool is_set(IOBitSet bit) const { \ + return bit::is_set(this->raw_value, bit.pos);\ + } \ + \ + \ void operator=(type value) { \ this->raw_value = value; \ } \