mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-27 16:17:31 -04:00
Formatted code (#1007)
* Updated style * Updated files * fixed new line * Updated spacing * File fix WIP * Updated to clang 13 * updated comment style * Removed old comment code
This commit is contained in:
parent
7aca7ce74d
commit
033c4e9a5b
599 changed files with 70746 additions and 66896 deletions
|
@ -32,49 +32,49 @@
|
|||
#define LOCATE_IN_RAM __attribute__((section(".ramtext")))
|
||||
|
||||
inline uint16_t fb_to_uint16(const std::string& fb) {
|
||||
return (fb[1] << 8) + fb[0];
|
||||
return (fb[1] << 8) + fb[0];
|
||||
}
|
||||
|
||||
inline uint32_t fb_to_uint32(const std::string& fb) {
|
||||
return (fb[3] << 24) + (fb[2] << 16) + (fb[1] << 8) + fb[0];
|
||||
return (fb[3] << 24) + (fb[2] << 16) + (fb[1] << 8) + fb[0];
|
||||
}
|
||||
|
||||
constexpr size_t operator "" _KiB(unsigned long long v) {
|
||||
return v * 1024;
|
||||
constexpr size_t operator"" _KiB(unsigned long long v) {
|
||||
return v * 1024;
|
||||
}
|
||||
|
||||
constexpr size_t operator "" _MiB(unsigned long long v) {
|
||||
return v * 1024 * 1024;
|
||||
constexpr size_t operator"" _MiB(unsigned long long v) {
|
||||
return v * 1024 * 1024;
|
||||
}
|
||||
|
||||
template<typename E>
|
||||
template <typename E>
|
||||
constexpr typename std::underlying_type<E>::type toUType(E enumerator) noexcept {
|
||||
/* Thanks, Scott Meyers! */
|
||||
return static_cast<typename std::underlying_type<E>::type>(enumerator);
|
||||
/* Thanks, Scott Meyers! */
|
||||
return static_cast<typename std::underlying_type<E>::type>(enumerator);
|
||||
}
|
||||
|
||||
inline uint32_t flp2(uint32_t v) {
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
return v - (v >> 1);
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
return v - (v >> 1);
|
||||
}
|
||||
|
||||
uint32_t gcd(const uint32_t u, const uint32_t v);
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
inline constexpr T pow(const T base, unsigned const exponent) {
|
||||
return (exponent == 0) ? 1 : (base * pow(base, exponent - 1));
|
||||
return (exponent == 0) ? 1 : (base * pow(base, exponent - 1));
|
||||
}
|
||||
|
||||
constexpr bool power_of_two(const size_t n) {
|
||||
return (n & (n - 1)) == 0;
|
||||
return (n & (n - 1)) == 0;
|
||||
}
|
||||
|
||||
constexpr size_t log_2(const size_t n, const size_t p = 0) {
|
||||
return (n <= 1) ? p : log_2(n / 2, p + 1);
|
||||
return (n <= 1) ? p : log_2(n / 2, p + 1);
|
||||
}
|
||||
|
||||
float fast_log2(const float val);
|
||||
|
@ -83,46 +83,46 @@ float fast_pow2(const float val);
|
|||
float mag2_to_dbv_norm(const float mag2);
|
||||
|
||||
inline float magnitude_squared(const std::complex<float> c) {
|
||||
const auto r = c.real();
|
||||
const auto r2 = r * r;
|
||||
const auto i = c.imag();
|
||||
const auto i2 = i * i;
|
||||
return r2 + i2;
|
||||
const auto r = c.real();
|
||||
const auto r2 = r * r;
|
||||
const auto i = c.imag();
|
||||
const auto i2 = i * i;
|
||||
return r2 + i2;
|
||||
}
|
||||
|
||||
int fast_int_magnitude(int y, int x);
|
||||
int int_atan2(int y, int x);
|
||||
int32_t int16_sin_s4(int32_t x);
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
struct range_t {
|
||||
const T minimum;
|
||||
const T maximum;
|
||||
const T minimum;
|
||||
const T maximum;
|
||||
|
||||
constexpr const T& clip(const T& value) const {
|
||||
return std::max(std::min(value, maximum), minimum);
|
||||
}
|
||||
constexpr const T& clip(const T& value) const {
|
||||
return std::max(std::min(value, maximum), minimum);
|
||||
}
|
||||
|
||||
constexpr void reset_if_outside(T& value, const T& reset_value) const {
|
||||
if( (value < minimum ) ||
|
||||
(value > maximum ) ) {
|
||||
value = reset_value;
|
||||
}
|
||||
}
|
||||
constexpr void reset_if_outside(T& value, const T& reset_value) const {
|
||||
if ((value < minimum) ||
|
||||
(value > maximum)) {
|
||||
value = reset_value;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr bool below_range(const T& value) const {
|
||||
return value < minimum;
|
||||
}
|
||||
constexpr bool below_range(const T& value) const {
|
||||
return value < minimum;
|
||||
}
|
||||
|
||||
constexpr bool contains(const T& value) const {
|
||||
// TODO: Subtle gotcha here! Range test doesn't include maximum!
|
||||
return (value >= minimum) && (value < maximum);
|
||||
}
|
||||
constexpr bool contains(const T& value) const {
|
||||
// TODO: Subtle gotcha here! Range test doesn't include maximum!
|
||||
return (value >= minimum) && (value < maximum);
|
||||
}
|
||||
|
||||
constexpr bool out_of_range(const T& value) const {
|
||||
// TODO: Subtle gotcha here! Range test in contains() doesn't include maximum!
|
||||
return !contains(value);
|
||||
}
|
||||
constexpr bool out_of_range(const T& value) const {
|
||||
// TODO: Subtle gotcha here! Range test in contains() doesn't include maximum!
|
||||
return !contains(value);
|
||||
}
|
||||
};
|
||||
|
||||
#endif/*__UTILITY_H__*/
|
||||
#endif /*__UTILITY_H__*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue