Skip to content

Commit

Permalink
[Chores] Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasnoble committed Sep 20, 2024
1 parent 9e4b856 commit 5a683ee
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 114 deletions.
16 changes: 8 additions & 8 deletions src/core/gpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1137,10 +1137,10 @@ void PCSX::GPU::Poly<shading, shape, textured, blend, modulation>::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});
Expand Down Expand Up @@ -1234,10 +1234,10 @@ void PCSX::GPU::Rect<size, textured, blend, modulation>::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});
Expand Down
4 changes: 2 additions & 2 deletions src/core/psxmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
6 changes: 3 additions & 3 deletions src/core/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,21 @@ class System {

// Legacy printf stuff; needs to be replaced with loggers
template <typename... Args>
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 <typename... Args>
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 <typename... Args>
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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/mips/common/syscalls/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions src/mips/psyqo/fixed-point.hh
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ void printInt(uint32_t value, const eastl::function<void(char)>&, unsigned preci
* @tparam T The underlying integer type to use.
*/
template <unsigned precisionBits = 12, std::integral T = int32_t>
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<sizeof(T) == 4, int64_t, int32_t>::type;
using unsignedUpType = std::conditional<sizeof(T) == 4, uint64_t, uint32_t>::type;
using upType = std::conditional<std::is_signed<T>::value, signedUpType, unsignedUpType>::type;
Expand Down
14 changes: 8 additions & 6 deletions src/mips/psyqo/fragment-concept.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ struct has_explicit_copy_constructor<

template <typename Frag>
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<Frag>() } -> std::convertible_to<std::true_type>;
{ frag.getActualFragmentSize() } -> std::convertible_to<size_t>;
{(alignof(Frag) & 3) == 0};
{(sizeof(Frag) & 3) == 0};
{(sizeof(frag.head)) == 4};
{((offsetof(Frag, head)) & 3) == 0};
{ has_explicit_copy_constructor<Frag>() }
->std::convertible_to<std::true_type>;
{ frag.getActualFragmentSize() }
->std::convertible_to<size_t>;
};

} // namespace psyqo
126 changes: 63 additions & 63 deletions src/mips/psyqo/gte-registers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
};

/**
Expand All @@ -148,7 +148,7 @@ enum class Register {
*/
enum Safety {
Unsafe, /* avoid nops */
Safe, /* insert nops */
Safe, /* insert nops */
};

/**
Expand Down Expand Up @@ -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 */
};

Expand Down
39 changes: 10 additions & 29 deletions src/mips/psyqo/vector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ SOFTWARE.
namespace psyqo {

template <unsigned N, unsigned precisionBits = 12, std::integral T = int32_t>
requires((N >= 2) && (N <= 4))
struct Vector {
requires((N >= 2) && (N <= 4)) struct Vector {
typedef FixedPoint<precisionBits, T> FixedPointType;
FixedPoint<precisionBits, T> x, y;
struct EmptyZ {};
Expand All @@ -62,9 +61,7 @@ struct Vector {
}
}
constexpr FixedPointType& operator[](unsigned i) { return get(i); }
constexpr operator Vertex() const
requires((N == 2) && std::is_signed<T>::value)
{
constexpr operator Vertex() const requires((N == 2) && std::is_signed<T>::value) {
return {{.x = x.template integer<int16_t>(), .y = y.template integer<int16_t>()}};
}
constexpr Vector& operator+=(const Vector& rhs) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5a683ee

Please sign in to comment.