Fix inconsistent EOL

This commit is contained in:
2025-01-08 22:27:37 +01:00
parent 57671ac79d
commit 1f7141c517
184 changed files with 13686 additions and 13685 deletions

View File

@@ -1,74 +1,74 @@
#ifndef __JABYENGINE_FRAME_TIMER_HPP__
#define __JABYENGINE_FRAME_TIMER_HPP__
#include "frame_time_helper.hpp"
#include <stdint.hpp>
namespace JabyEngine {
class MasterTime {
__friends:
static uint32_t value;
public:
static uint32_t read() {
return reinterpret_cast<volatile uint32_t&>(MasterTime::value);
}
template<typename T>
static T read_as() {
return static_cast<T>(MasterTime::read());
}
};
template<typename T>
class SimpleTimer {
protected:
T value = 0;
public:
constexpr SimpleTimer() = default;
static SimpleTimer create() {
SimpleTimer timer;
timer.reset();
return timer;
}
bool is_expired_for(T time) const {
return static_cast<T>((MasterTime::read_as<T>() - this->value)) >= time;
}
void reset() {
this->value = MasterTime::read_as<T>();
}
};
template<typename T>
class IntervalTimer : public SimpleTimer<T> {
private:
T interval = 0;
public:
constexpr IntervalTimer() = default;
constexpr IntervalTimer(T interval) : SimpleTimer<T>(), interval(interval) {
}
static constexpr IntervalTimer create(T interval) {
IntervalTimer timer;
static_cast<SimpleTimer<T>&>(timer) = SimpleTimer<T>::create();
timer.interval = interval;
return timer;
}
void set_interval(T interval) {
this->interval = interval;
}
bool is_expired() const {
return SimpleTimer<T>::is_expired_for(this->interval);
}
};
}
#ifndef __JABYENGINE_FRAME_TIMER_HPP__
#define __JABYENGINE_FRAME_TIMER_HPP__
#include "frame_time_helper.hpp"
#include <stdint.hpp>
namespace JabyEngine {
class MasterTime {
__friends:
static uint32_t value;
public:
static uint32_t read() {
return reinterpret_cast<volatile uint32_t&>(MasterTime::value);
}
template<typename T>
static T read_as() {
return static_cast<T>(MasterTime::read());
}
};
template<typename T>
class SimpleTimer {
protected:
T value = 0;
public:
constexpr SimpleTimer() = default;
static SimpleTimer create() {
SimpleTimer timer;
timer.reset();
return timer;
}
bool is_expired_for(T time) const {
return static_cast<T>((MasterTime::read_as<T>() - this->value)) >= time;
}
void reset() {
this->value = MasterTime::read_as<T>();
}
};
template<typename T>
class IntervalTimer : public SimpleTimer<T> {
private:
T interval = 0;
public:
constexpr IntervalTimer() = default;
constexpr IntervalTimer(T interval) : SimpleTimer<T>(), interval(interval) {
}
static constexpr IntervalTimer create(T interval) {
IntervalTimer timer;
static_cast<SimpleTimer<T>&>(timer) = SimpleTimer<T>::create();
timer.interval = interval;
return timer;
}
void set_interval(T interval) {
this->interval = interval;
}
bool is_expired() const {
return SimpleTimer<T>::is_expired_for(this->interval);
}
};
}
#endif //!__JABYENGINE_FRAME_TIMER_HPP__

View File

@@ -1,81 +1,81 @@
#ifndef __JABYENGINE_HIGH_RES_TIMER_HPP__
#define __JABYENGINE_HIGH_RES_TIMER_HPP__
#include "../jabyengine_defines.hpp"
#include <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/IOPorts/timer_io.hpp>
namespace JabyEngine {
struct CPUTicks {
static constexpr double Frequency_Hz = 33868800.0;
static constexpr double Frequency_Hz_Div8 = (Frequency_Hz/8.0);
template<typename T>
static constexpr T ticks_per_ns(double CPU_Frequency_Hz, double time = 1.0) {
return static_cast<T>((time/CPU_Frequency_Hz)*1000.0*1000.0*1000.0);
}
template<typename T>
static constexpr T ticks_per_us(double CPU_Frequency_Hz, double time = 1.0) {
return static_cast<T>(((time*1000.0)/ticks_per_ns<double>(CPU_Frequency_Hz)));
}
template<typename T>
static constexpr T ticks_per_ms(double CPU_Frequency_Hz, double time = 1.0) {
return static_cast<T>(((time*1000.0*1000.0)/ticks_per_ns<double>(CPU_Frequency_Hz)));
}
};
class HighResTime {
public:
class TimeStamp {
private:
uint16_t counter_10ms_value;
uint16_t fraction;
constexpr TimeStamp(uint16_t counter_10ms_value, uint16_t fraction) : counter_10ms_value(counter_10ms_value), fraction(fraction) {
}
constexpr static size_t to_us(uint16_t counter_10ms_value, uint16_t fraction) {
return counter_10ms_value*(10*1000) + ((fraction/HighResTime::TicksFor100us)*100);
}
constexpr static size_t to_ms(uint16_t counter_10ms_value, uint16_t fraction) {
return counter_10ms_value*10 + (fraction/HighResTime::TicksFor1ms);
}
public:
constexpr size_t microseconds_to(const TimeStamp& end) const {
return TimeStamp::to_us((end.counter_10ms_value - this->counter_10ms_value), (end.fraction - this->fraction));
}
constexpr size_t milliseconds_to(const TimeStamp& end) const {
return TimeStamp::to_ms((end.counter_10ms_value - this->counter_10ms_value), (end.fraction - this->fraction));
}
friend class HighResTime;
};
__friends:
static constexpr uint16_t TicksFor100us = CPUTicks::ticks_per_us<uint16_t>(CPUTicks::Frequency_Hz_Div8, 100.0);
static constexpr uint16_t TicksFor1ms = CPUTicks::ticks_per_ms<uint16_t>(CPUTicks::Frequency_Hz_Div8, 1.0);
static constexpr uint16_t TicksFor10ms = CPUTicks::ticks_per_ms<uint16_t>(CPUTicks::Frequency_Hz_Div8, 10.0);
static volatile uint16_t global_counter_10ms;
public:
HighResTime() = delete;
~HighResTime() = delete;
static void enable() {
Interrupt::enable_irq(Interrupt::Timer2);
}
static void disable() {
Interrupt::disable_irq(Interrupt::Timer2);
}
static TimeStamp get_time_stamp() {
return TimeStamp(HighResTime::global_counter_10ms, Timer_IO::Counter2.get_current_value());
}
};
}
#ifndef __JABYENGINE_HIGH_RES_TIMER_HPP__
#define __JABYENGINE_HIGH_RES_TIMER_HPP__
#include "../jabyengine_defines.hpp"
#include <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/IOPorts/timer_io.hpp>
namespace JabyEngine {
struct CPUTicks {
static constexpr double Frequency_Hz = 33868800.0;
static constexpr double Frequency_Hz_Div8 = (Frequency_Hz/8.0);
template<typename T>
static constexpr T ticks_per_ns(double CPU_Frequency_Hz, double time = 1.0) {
return static_cast<T>((time/CPU_Frequency_Hz)*1000.0*1000.0*1000.0);
}
template<typename T>
static constexpr T ticks_per_us(double CPU_Frequency_Hz, double time = 1.0) {
return static_cast<T>(((time*1000.0)/ticks_per_ns<double>(CPU_Frequency_Hz)));
}
template<typename T>
static constexpr T ticks_per_ms(double CPU_Frequency_Hz, double time = 1.0) {
return static_cast<T>(((time*1000.0*1000.0)/ticks_per_ns<double>(CPU_Frequency_Hz)));
}
};
class HighResTime {
public:
class TimeStamp {
private:
uint16_t counter_10ms_value;
uint16_t fraction;
constexpr TimeStamp(uint16_t counter_10ms_value, uint16_t fraction) : counter_10ms_value(counter_10ms_value), fraction(fraction) {
}
constexpr static size_t to_us(uint16_t counter_10ms_value, uint16_t fraction) {
return counter_10ms_value*(10*1000) + ((fraction/HighResTime::TicksFor100us)*100);
}
constexpr static size_t to_ms(uint16_t counter_10ms_value, uint16_t fraction) {
return counter_10ms_value*10 + (fraction/HighResTime::TicksFor1ms);
}
public:
constexpr size_t microseconds_to(const TimeStamp& end) const {
return TimeStamp::to_us((end.counter_10ms_value - this->counter_10ms_value), (end.fraction - this->fraction));
}
constexpr size_t milliseconds_to(const TimeStamp& end) const {
return TimeStamp::to_ms((end.counter_10ms_value - this->counter_10ms_value), (end.fraction - this->fraction));
}
friend class HighResTime;
};
__friends:
static constexpr uint16_t TicksFor100us = CPUTicks::ticks_per_us<uint16_t>(CPUTicks::Frequency_Hz_Div8, 100.0);
static constexpr uint16_t TicksFor1ms = CPUTicks::ticks_per_ms<uint16_t>(CPUTicks::Frequency_Hz_Div8, 1.0);
static constexpr uint16_t TicksFor10ms = CPUTicks::ticks_per_ms<uint16_t>(CPUTicks::Frequency_Hz_Div8, 10.0);
static volatile uint16_t global_counter_10ms;
public:
HighResTime() = delete;
~HighResTime() = delete;
static void enable() {
Interrupt::enable_irq(Interrupt::Timer2);
}
static void disable() {
Interrupt::disable_irq(Interrupt::Timer2);
}
static TimeStamp get_time_stamp() {
return TimeStamp(HighResTime::global_counter_10ms, Timer_IO::Counter2.get_current_value());
}
};
}
#endif //!__JABYENGINE_HIGH_RES_TIMER_HPP__