From 5a683ee84d35c319f432d0ac991188b9fd15f5c1 Mon Sep 17 00:00:00 2001 From: nicolasnoble Date: Fri, 20 Sep 2024 15:37:49 +0000 Subject: [PATCH] [Chores] Format code --- src/core/gpu.cc | 16 ++-- src/core/psxmem.h | 4 +- src/core/system.h | 6 +- src/mips/common/syscalls/syscalls.h | 2 +- src/mips/psyqo/fixed-point.hh | 3 +- src/mips/psyqo/fragment-concept.hh | 14 ++-- src/mips/psyqo/gte-registers.hh | 126 ++++++++++++++-------------- src/mips/psyqo/vector.hh | 39 +++------ 8 files changed, 96 insertions(+), 114 deletions(-) diff --git a/src/core/gpu.cc b/src/core/gpu.cc index 2dcc1432a..f4fbd26f6 100644 --- a/src/core/gpu.cc +++ b/src/core/gpu.cc @@ -1137,10 +1137,10 @@ void PCSX::GPU::Poly::drawLogNode(u ImGui::SameLine(); std::string label = fmt::format(f_("Go to texture##{}"), n); if (ImGui::Button(label.c_str())) { - const auto mode = tpage.texDepth == TexDepth::Tex16Bits - ? Events::GUI::VRAM_16BITS - : tpage.texDepth == TexDepth::Tex8Bits ? Events::GUI::VRAM_8BITS - : Events::GUI::VRAM_4BITS; + const auto mode = + tpage.texDepth == TexDepth::Tex16Bits + ? Events::GUI::VRAM_16BITS + : tpage.texDepth == TexDepth::Tex8Bits ? Events::GUI::VRAM_8BITS : Events::GUI::VRAM_4BITS; g_system->m_eventBus->signal(Events::GUI::SelectClut{clutX(), clutY()}); g_system->m_eventBus->signal( Events::GUI::VRAMFocus{int(minU + tx), int(minV + ty), int(maxU + tx), int(maxV + ty), mode}); @@ -1234,10 +1234,10 @@ void PCSX::GPU::Rect::drawLogNode(unsigned n) ImGui::SameLine(); std::string label = fmt::format(f_("Go to texture##{}"), n); if (ImGui::Button(label.c_str())) { - const auto mode = tpage.texDepth == TexDepth::Tex16Bits - ? Events::GUI::VRAM_16BITS - : tpage.texDepth == TexDepth::Tex8Bits ? Events::GUI::VRAM_8BITS - : Events::GUI::VRAM_4BITS; + const auto mode = + tpage.texDepth == TexDepth::Tex16Bits + ? Events::GUI::VRAM_16BITS + : tpage.texDepth == TexDepth::Tex8Bits ? Events::GUI::VRAM_8BITS : Events::GUI::VRAM_4BITS; g_system->m_eventBus->signal(Events::GUI::SelectClut{clutX(), clutY()}); g_system->m_eventBus->signal(Events::GUI::VRAMFocus{int((u >> shift) + tx), int(v + ty), int(((u + w) >> shift) + tx), int(v + h + ty), mode}); diff --git a/src/core/psxmem.h b/src/core/psxmem.h index 7b731524f..88c36db84 100644 --- a/src/core/psxmem.h +++ b/src/core/psxmem.h @@ -28,9 +28,9 @@ #if defined(__BIGENDIAN__) -#define SWAP_LE16(v) ((((v) & 0xff00) >> 8) | (((v) & 0xff) << 8)) +#define SWAP_LE16(v) ((((v)&0xff00) >> 8) | (((v)&0xff) << 8)) #define SWAP_LE32(v) \ - ((((v) & 0xff000000ul) >> 24) | (((v) & 0xff0000ul) >> 8) | (((v) & 0xff00ul) << 8) | (((v) & 0xfful) << 24)) + ((((v)&0xff000000ul) >> 24) | (((v)&0xff0000ul) >> 8) | (((v)&0xff00ul) << 8) | (((v)&0xfful) << 24)) #define SWAP_LEu16(v) SWAP_LE16((uint16_t)(v)) #define SWAP_LEu32(v) SWAP_LE32((uint32_t)(v)) diff --git a/src/core/system.h b/src/core/system.h index ac4fa05cb..aae819c05 100644 --- a/src/core/system.h +++ b/src/core/system.h @@ -137,21 +137,21 @@ class System { // Legacy printf stuff; needs to be replaced with loggers template - void printf(const char *format, const Args &...args) { + void printf(const char *format, const Args &... args) { std::string s = fmt::sprintf(format, args...); printf(std::move(s)); } virtual void printf(std::string &&) = 0; // Add a log line template - void log(LogClass logClass, const char *format, const Args &...args) { + void log(LogClass logClass, const char *format, const Args &... args) { std::string s = fmt::sprintf(format, args...); log(logClass, std::move(s)); } virtual void log(LogClass, std::string &&) = 0; // Display a popup message to the user template - void message(const char *format, const Args &...args) { + void message(const char *format, const Args &... args) { std::string s = fmt::sprintf(format, args...); message(std::move(s)); } diff --git a/src/mips/common/syscalls/syscalls.h b/src/mips/common/syscalls/syscalls.h index 344e81aba..2350264d3 100644 --- a/src/mips/common/syscalls/syscalls.h +++ b/src/mips/common/syscalls/syscalls.h @@ -60,7 +60,7 @@ static __attribute__((always_inline)) int changeThreadSubFunction(uint32_t addre static __attribute__((always_inline)) size_t syscall_write(int fd, const void *buf, size_t size) { register int n asm("t1") = 0x03; __asm__ volatile("" : "=r"(n) : "r"(n)); - return ((size_t (*)(int, const void *, size_t))0xa0)(fd, buf, size); + return ((size_t(*)(int, const void *, size_t))0xa0)(fd, buf, size); } static __attribute__((always_inline)) int syscall_setjmp(struct JmpBuf *buf) { diff --git a/src/mips/psyqo/fixed-point.hh b/src/mips/psyqo/fixed-point.hh index fca1a9a5d..881bf6aab 100644 --- a/src/mips/psyqo/fixed-point.hh +++ b/src/mips/psyqo/fixed-point.hh @@ -62,8 +62,7 @@ void printInt(uint32_t value, const eastl::function&, unsigned preci * @tparam T The underlying integer type to use. */ template -requires((precisionBits > 0) && (precisionBits < 32) && ((sizeof(T) == 4) || (sizeof(T) == 2))) -class FixedPoint { +requires((precisionBits > 0) && (precisionBits < 32) && ((sizeof(T) == 4) || (sizeof(T) == 2))) class FixedPoint { using signedUpType = std::conditional::type; using unsignedUpType = std::conditional::type; using upType = std::conditional::value, signedUpType, unsignedUpType>::type; diff --git a/src/mips/psyqo/fragment-concept.hh b/src/mips/psyqo/fragment-concept.hh index 9c125baca..790b92e03 100644 --- a/src/mips/psyqo/fragment-concept.hh +++ b/src/mips/psyqo/fragment-concept.hh @@ -48,12 +48,14 @@ struct has_explicit_copy_constructor< template concept Fragment = requires(Frag frag) { - { (alignof(Frag) & 3) == 0 }; - { (sizeof(Frag) & 3) == 0 }; - { (sizeof(frag.head)) == 4 }; - { ((offsetof(Frag, head)) & 3) == 0 }; - { has_explicit_copy_constructor() } -> std::convertible_to; - { frag.getActualFragmentSize() } -> std::convertible_to; + {(alignof(Frag) & 3) == 0}; + {(sizeof(Frag) & 3) == 0}; + {(sizeof(frag.head)) == 4}; + {((offsetof(Frag, head)) & 3) == 0}; + { has_explicit_copy_constructor() } + ->std::convertible_to; + { frag.getActualFragmentSize() } + ->std::convertible_to; }; } // namespace psyqo diff --git a/src/mips/psyqo/gte-registers.hh b/src/mips/psyqo/gte-registers.hh index ef4e3da41..e5436353d 100644 --- a/src/mips/psyqo/gte-registers.hh +++ b/src/mips/psyqo/gte-registers.hh @@ -67,72 +67,72 @@ struct PackedVec3 { /** * @brief The list of available GTE registers. - */ + */ enum class Register { - VXY0, /* Vector 0 (X,Y) */ - VZ0, /* Vector 0 (Z) */ - VXY1, /* Vector 1 (X,Y) */ - VZ1, /* Vector 1 (Z) */ - VXY2, /* Vector 2 (X,Y) */ - VZ2, /* Vector 2 (Z) */ - RGB, /* Color/code value */ - OTZ, /* Average Z value (for Ordering Table) */ - IR0, /* 16bit Accumulator 0 (Interpolate) */ - IR1, /* 16bit Accumulator 1 (Vector) */ - IR2, /* 16bit Accumulator 2 (Vector) */ - IR3, /* 16bit Accumulator 3 (Vector) */ - SXY0, /* Screen XY-coordinate 0 FIFO */ - SXY1, /* Screen XY-coordinate 1 FIFO */ - SXY2, /* Screen XY-coordinate 2 FIFO */ - SXYP, /* Screen XY-coordinate P FIFO */ - SZ0, /* Screen Z-coordinate 0 FIFO */ - SZ1, /* Screen Z-coordinate 1 FIFO */ - SZ2, /* Screen Z-coordinate 2 FIFO */ - SZ3, /* Screen Z-coordinate 3 FIFO */ - RGB0, /* Color CRGB-code/color 0 FIFO */ - RGB1, /* Color CRGB-code/color 1 FIFO */ - RGB2, /* Color CRGB-code/color 2 FIFO */ - RES1, /* Prohibited */ - MAC0, /* 32bit Maths Accumulators 0 (Value) */ - MAC1, /* 32bit Maths Accumulators 1 (Vector) */ - MAC2, /* 32bit Maths Accumulators 2 (Vector) */ - MAC3, /* 32bit Maths Accumulators 3 (Vector) */ - IRGB, /* Convert RGB Color (48bit vs 15bit) */ - ORGB, /* Convert RGB Color (48bit vs 15bit) */ - LZCS, /* Count Leading-Zeroes/Ones (sign bits) */ - LZCR, /* Count Leading-Zeroes/Ones (sign bits) */ + VXY0, /* Vector 0 (X,Y) */ + VZ0, /* Vector 0 (Z) */ + VXY1, /* Vector 1 (X,Y) */ + VZ1, /* Vector 1 (Z) */ + VXY2, /* Vector 2 (X,Y) */ + VZ2, /* Vector 2 (Z) */ + RGB, /* Color/code value */ + OTZ, /* Average Z value (for Ordering Table) */ + IR0, /* 16bit Accumulator 0 (Interpolate) */ + IR1, /* 16bit Accumulator 1 (Vector) */ + IR2, /* 16bit Accumulator 2 (Vector) */ + IR3, /* 16bit Accumulator 3 (Vector) */ + SXY0, /* Screen XY-coordinate 0 FIFO */ + SXY1, /* Screen XY-coordinate 1 FIFO */ + SXY2, /* Screen XY-coordinate 2 FIFO */ + SXYP, /* Screen XY-coordinate P FIFO */ + SZ0, /* Screen Z-coordinate 0 FIFO */ + SZ1, /* Screen Z-coordinate 1 FIFO */ + SZ2, /* Screen Z-coordinate 2 FIFO */ + SZ3, /* Screen Z-coordinate 3 FIFO */ + RGB0, /* Color CRGB-code/color 0 FIFO */ + RGB1, /* Color CRGB-code/color 1 FIFO */ + RGB2, /* Color CRGB-code/color 2 FIFO */ + RES1, /* Prohibited */ + MAC0, /* 32bit Maths Accumulators 0 (Value) */ + MAC1, /* 32bit Maths Accumulators 1 (Vector) */ + MAC2, /* 32bit Maths Accumulators 2 (Vector) */ + MAC3, /* 32bit Maths Accumulators 3 (Vector) */ + IRGB, /* Convert RGB Color (48bit vs 15bit) */ + ORGB, /* Convert RGB Color (48bit vs 15bit) */ + LZCS, /* Count Leading-Zeroes/Ones (sign bits) */ + LZCR, /* Count Leading-Zeroes/Ones (sign bits) */ R11R12, /* Rotation matrix (3x3) */ R13R21, /* Rotation matrix (3x3) */ R22R23, /* Rotation matrix (3x3) */ R31R32, /* Rotation matrix (3x3) */ - R33, /* Rotation matrix (3x3) */ - TRX, /* Translation vector (X) */ - TRY, /* Translation vector (Y) */ - TRZ, /* Translation vector (Z) */ + R33, /* Rotation matrix (3x3) */ + TRX, /* Translation vector (X) */ + TRY, /* Translation vector (Y) */ + TRZ, /* Translation vector (Z) */ L11L12, /* Light source matrix (3x3) */ L13L21, /* Light source matrix (3x3) */ L22L23, /* Light source matrix (3x3) */ L31L32, /* Light source matrix (3x3) */ - L33, /* Light source matrix (3x3) */ - RBK, /* Background color(R) */ - GBK, /* Background color(G) */ - BBK, /* Background color(B) */ + L33, /* Light source matrix (3x3) */ + RBK, /* Background color(R) */ + GBK, /* Background color(G) */ + BBK, /* Background color(B) */ LR1LR2, /* Light color matrix source (3x3) */ LR3LG1, /* Light color matrix source (3x3) */ LG2LG3, /* Light color matrix source (3x3) */ LB1LB2, /* Light color matrix source (3x3) */ - LB3, /* Light color matrix source (3x3) */ - RFC, /* Far color (R) */ - GFC, /* Far color (G) */ - BFC, /* Far color (B) */ - OFX, /* Screen offset (X) */ - OFY, /* Screen offset (Y) */ - H, /* Projection plane distance. */ - DQA, /* Depth queing parameter A (coeff) */ - DQB, /* Depth queing parameter B (offset) */ - ZSF3, /* Average Z scale factors */ - ZSF4, /* Average Z scale factors */ - FLAG, /* Returns any calculation errors */ + LB3, /* Light color matrix source (3x3) */ + RFC, /* Far color (R) */ + GFC, /* Far color (G) */ + BFC, /* Far color (B) */ + OFX, /* Screen offset (X) */ + OFY, /* Screen offset (Y) */ + H, /* Projection plane distance. */ + DQA, /* Depth queing parameter A (coeff) */ + DQB, /* Depth queing parameter B (offset) */ + ZSF3, /* Average Z scale factors */ + ZSF4, /* Average Z scale factors */ + FLAG, /* Returns any calculation errors */ }; /** @@ -148,7 +148,7 @@ enum class Register { */ enum Safety { Unsafe, /* avoid nops */ - Safe, /* insert nops */ + Safe, /* insert nops */ }; /** @@ -245,15 +245,15 @@ static inline void writeUnsafe(Short low, Short hi) { * @brief The list of available GTE pseudo registers. */ enum class PseudoRegister { - Rotation, /* pseudo register for full rotation matrix, mapped to registers R11R12-R33 */ - Light, /* pseudo register for full light matrix, mapped to registers L11L12-L33 */ - Color, /* pseudo register for full light color matrix, mapped to registers LR1LR2-LB3 */ - V0, /* pseudo register for full Vector 0, mapped to registers VXY0 and VZ0 */ - V1, /* pseudo register for full Vector 1, mapped to registers VXY1 and VZ1 */ - V2, /* pseudo register for full Vector 2, mapped to registers VXY2 and VZ2 */ - SV, /* pseudo register for full 16bit Accumulator Vector, mapped to registers IR1-IR3 */ - LV, /* pseudo register for full 32bit Maths Accumulator Vector, mapped to registers MAC1-MAC3 */ - Translation, /* pseudo register for full Translation vector, mapped to registers TRX-TRZ */ + Rotation, /* pseudo register for full rotation matrix, mapped to registers R11R12-R33 */ + Light, /* pseudo register for full light matrix, mapped to registers L11L12-L33 */ + Color, /* pseudo register for full light color matrix, mapped to registers LR1LR2-LB3 */ + V0, /* pseudo register for full Vector 0, mapped to registers VXY0 and VZ0 */ + V1, /* pseudo register for full Vector 1, mapped to registers VXY1 and VZ1 */ + V2, /* pseudo register for full Vector 2, mapped to registers VXY2 and VZ2 */ + SV, /* pseudo register for full 16bit Accumulator Vector, mapped to registers IR1-IR3 */ + LV, /* pseudo register for full 32bit Maths Accumulator Vector, mapped to registers MAC1-MAC3 */ + Translation, /* pseudo register for full Translation vector, mapped to registers TRX-TRZ */ ScreenOffset, /* pseudo register for full Screen offset, mapped to registers OFX and OFY */ }; diff --git a/src/mips/psyqo/vector.hh b/src/mips/psyqo/vector.hh index 60e667323..50a340da0 100644 --- a/src/mips/psyqo/vector.hh +++ b/src/mips/psyqo/vector.hh @@ -35,8 +35,7 @@ SOFTWARE. namespace psyqo { template - requires((N >= 2) && (N <= 4)) -struct Vector { +requires((N >= 2) && (N <= 4)) struct Vector { typedef FixedPoint FixedPointType; FixedPoint x, y; struct EmptyZ {}; @@ -62,9 +61,7 @@ struct Vector { } } constexpr FixedPointType& operator[](unsigned i) { return get(i); } - constexpr operator Vertex() const - requires((N == 2) && std::is_signed::value) - { + constexpr operator Vertex() const requires((N == 2) && std::is_signed::value) { return {{.x = x.template integer(), .y = y.template integer()}}; } constexpr Vector& operator+=(const Vector& rhs) { @@ -156,72 +153,56 @@ struct Vector { } return result; } - static constexpr Vector ZERO() - requires(N <= 3) - { + static constexpr Vector ZERO() requires(N <= 3) { Vector result; for (unsigned i = 0; i < N; i++) { result.get(i) = FixedPointType(0.0); } return result; } - static constexpr Vector ONE() - requires(N <= 3) - { + static constexpr Vector ONE() requires(N <= 3) { Vector result; for (unsigned i = 0; i < N; i++) { result.get(i) = FixedPointType(1.0); } return result; } - static constexpr Vector UP() - requires(N <= 3) - { + static constexpr Vector UP() requires(N <= 3) { Vector result; for (unsigned i = 0; i < N; i++) { result.get(i) = (i == 1) ? FixedPointType(1.0) : FixedPointType(0.0); } return result; } - static constexpr Vector DOWN() - requires(N <= 3) - { + static constexpr Vector DOWN() requires(N <= 3) { Vector result; for (unsigned i = 0; i < N; i++) { result.get(i) = (i == 1) ? -FixedPointType(1.0) : FixedPointType(0.0); } return result; } - static constexpr Vector LEFT() - requires(N <= 3) - { + static constexpr Vector LEFT() requires(N <= 3) { Vector result; for (unsigned i = 0; i < N; i++) { result.get(i) = (i == 0) ? -FixedPointType(1.0) : FixedPointType(0.0); } return result; } - static constexpr Vector RIGHT() - requires(N <= 3) - { + static constexpr Vector RIGHT() requires(N <= 3) { Vector result; for (unsigned i = 0; i < N; i++) { result.get(i) = (i == 0) ? FixedPointType(1.0) : FixedPointType(0.0); } return result; } - static constexpr Vector FORWARD() - requires(N == 3) - { + static constexpr Vector FORWARD() requires(N == 3) { Vector result; for (unsigned i = 0; i < N; i++) { result.get(i) = (i == 2) ? FixedPointType(1.0) : FixedPointType(0.0); } return result; } - static constexpr Vector BACKWARD() - requires(N == 3) - { + static constexpr Vector BACKWARD() requires(N == 3) { Vector result; for (unsigned i = 0; i < N; i++) { result.get(i) = (i == 2) ? -FixedPointType(1.0) : FixedPointType(0.0);