Skip to content

Commit

Permalink
Fixed mac0 value casting in psyqo cube example and implemented Nicola…
Browse files Browse the repository at this point in the history
…s' inline assembly fix
  • Loading branch information
CloudMracek committed Oct 22, 2024
1 parent 95bf165 commit a06067d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/mips/psyqo/examples/cube/cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ void CubeScene::frame() {
psyqo::GTE::Kernels::nclip();

// Read the result of nclip and skip rendering this face if it's not facing us
uint32_t mac0 = 0;
psyqo::GTE::read<psyqo::GTE::Register::MAC0>(&mac0);
int32_t mac0 = 0;
psyqo::GTE::read<psyqo::GTE::Register::MAC0>(reinterpret_cast<uint32_t *>(&mac0));
if (mac0 <= 0) continue;

// Since the GTE can only handle 3 vertices at a time, we need to store our first vertex
Expand All @@ -190,8 +190,8 @@ void CubeScene::frame() {

// Calculate the average Z for the z-Index to be put in the ordering table
psyqo::GTE::Kernels::avsz4();
uint32_t zIndex = 0;
psyqo::GTE::read<psyqo::GTE::Register::OTZ>(&zIndex);
int32_t zIndex = 0;
psyqo::GTE::read<psyqo::GTE::Register::OTZ>(reinterpret_cast<uint32_t *>(&zIndex));

// If the Z-index is out of bounds for our ordering table, we skip rendering this face.
if (zIndex < 0 || zIndex >= ORDERING_TABLE_SIZE) continue;
Expand Down
2 changes: 1 addition & 1 deletion src/mips/psyqo/gte-registers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ template <Register reg>
static inline void read(uint32_t* ptr) {
static_assert(reg < Register::R11R12, "Unable to read from register to memory directly");
if constexpr (reg < Register::R11R12) {
asm volatile("swc2 $%1, 0(%0)" ::"r"(ptr), "i"(static_cast<uint32_t>(reg)));
asm volatile("swc2 $%2, 0(%1)" : "=m"(*ptr) : "r"(ptr), "i"(static_cast<uint32_t>(reg)));
}
}

Expand Down

0 comments on commit a06067d

Please sign in to comment.