diff --git a/include/PSX/System/IOPorts/ioport.hpp b/include/PSX/System/IOPorts/ioport.hpp index 7253482d..d6d95578 100644 --- a/include/PSX/System/IOPorts/ioport.hpp +++ b/include/PSX/System/IOPorts/ioport.hpp @@ -60,25 +60,31 @@ namespace JabyEngine { #define __declare_io_type(name, type, ...) \ template typename T> \ struct name##_io_base { \ - T::Value raw_value; \ + T::Value raw_value = 0; \ \ - name##_io_base(type value) : raw_value(value) {} \ + constexpr name##_io_base() = default; \ + \ + constexpr name##_io_base(type value) : raw_value(value) {} \ __VA_ARGS__ \ \ - void set(IOBitSet bit) { \ + constexpr name##_io_base& set(IOBitSet bit) { \ this->raw_value = bit::set(this->raw_value, bit.pos); \ + return *this; \ } \ \ - void set(IOBitUnset bit) { \ + constexpr name##_io_base& set(IOBitUnset bit) { \ this->raw_value = bit::clear(this->raw_value, bit.pos); \ + return *this; \ } \ \ - void set(IOValueSet bits, type value) { \ + constexpr name##_io_base& set(IOValueSet bits, type value) { \ this->raw_value = bit::value::set_normalized(this->raw_value, value, bits.pos, bits.length); \ + return *this; \ } \ \ - void set(const IOValueSet::IOValueSetPair& value) { \ + constexpr name##_io_base& set(const IOValueSet::IOValueSetPair& value) { \ this->set(value.first, value.second); \ + return *this; \ } \ \ type get(IOValueSet bits) const { \ @@ -86,8 +92,9 @@ namespace JabyEngine { } \ \ \ - void clear(IOBitSet bit) { \ + constexpr name##_io_base& clear(IOBitSet bit) { \ this->raw_value = bit::clear(this->raw_value, bit.pos); \ + return *this; \ } \ \ \