#ifndef __JABYENGINE_TIMER_IO_HPP__ #define __JABYENGINE_TIMER_IO_HPP__ #include "ioport.hpp" namespace JabyEngine { namespace Timer { enum struct SyncMode {}; struct __no_align CounterMode : public ComplexBitMap { __io_port_inherit_complex_bit_map(CounterMode); static constexpr auto SyncEnable = Bit(0); static constexpr auto SyncMode = BitRange::from_to(1, 2); static constexpr auto ResetAfterTarget = Bit(3); static constexpr auto IRQAtTarget = Bit(4); static constexpr auto IRQAtMax = Bit(5); static constexpr auto IRQOneShot = !Bit(6); static constexpr auto IRQEveryTime = Bit(6); static constexpr auto IRQPulse = !Bit(7); static constexpr auto IRQToggle = Bit(7); static constexpr auto ClockSource = BitRange::from_to(8, 9); static constexpr auto HasIRQRequest = Bit(10); static constexpr auto IsTargetReached = Bit(11); static constexpr auto IsMaxReached = Bit(12); }; struct __no_align CounterTarget : public ComplexBitMap { __io_port_inherit_complex_bit_map(CounterTarget); static constexpr auto CounterTargetValue = BitRange::from_to(0, 15); }; struct __no_align Timer { IOPort mode; IOPort target; private: uint32_t _unused[2]; }; namespace Counter0 { struct SyncMode { static constexpr auto Pause_During_Hblank = CounterMode::SyncMode.with(0); static constexpr auto Zero_At_Hblank = CounterMode::SyncMode.with(1); static constexpr auto Zero_At_Hblank_Pause_Outside_Hblank = CounterMode::SyncMode.with(2); static constexpr auto Pause_Until_Hblank_Then_Freerun = CounterMode::SyncMode.with(3); }; struct Source { static constexpr auto System_Clock = CounterMode::ClockSource.with(0); static constexpr auto Dot_Clock = CounterMode::ClockSource.with(1); static constexpr auto System_Clock_Too = CounterMode::ClockSource.with(2); static constexpr auto Dot_Clock_Too = CounterMode::ClockSource.with(3); }; } namespace Counter1 { struct SyncMode { static constexpr auto Pause_During_Vblank = CounterMode::SyncMode.with(0); static constexpr auto Zero_At_Vblank = CounterMode::SyncMode.with(1); static constexpr auto Zero_At_Vblank_Pause_Outside_Vblank = CounterMode::SyncMode.with(2); static constexpr auto Pause_Until_Vblank_Then_Freerun = CounterMode::SyncMode.with(3); }; struct Source { static constexpr auto System_Clock = CounterMode::ClockSource.with(0); static constexpr auto Hblank = CounterMode::ClockSource.with(1); static constexpr auto System_Clock_Too = CounterMode::ClockSource.with(2); static constexpr auto Hblank_Too = CounterMode::ClockSource.with(3); }; } namespace Counter2 { struct SyncMode { static constexpr auto Stop_Counter = CounterMode::SyncMode.with(0); static constexpr auto Freerun = CounterMode::SyncMode.with(1); static constexpr auto Freerun_Too = CounterMode::SyncMode.with(2); static constexpr auto Stop_Counter_Too = CounterMode::SyncMode.with(3); }; struct Source { static constexpr auto System_Clock = CounterMode::ClockSource.with(0); static constexpr auto System_Clock_Too = CounterMode::ClockSource.with(1); static constexpr auto System_Clock_Div_8 = CounterMode::ClockSource.with(2); static constexpr auto System_Clock_Div_8_Too = CounterMode::ClockSource.with(3); }; } __declare_io_port_global_array(Timer, Counter, 0x1F801104, 3); static_assert(sizeof(Timer) == 0x10); } } #endif //!__JABYENGINE_TIMER_IO_HPP__