Skip to content

Commit

Permalink
Merge pull request #1057 from Clownacy/master
Browse files Browse the repository at this point in the history
Fix Big-Endian Incompatibilities
  • Loading branch information
richard42 authored Jan 13, 2024
2 parents 93ddc88 + 469d4eb commit 20615a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/device/cart/is_viewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void read_is_viewer(void* opaque, uint32_t address, uint32_t* value)
struct is_viewer* is_viewer = (struct is_viewer*)opaque;
address &= IS_ADDR_MASK;
memcpy(value, &is_viewer->data[address], 4);
*value = m64p_swap32(*value);
*value = big32(*value);
}

void write_is_viewer(void* opaque, uint32_t address, uint32_t value, uint32_t mask)
Expand Down Expand Up @@ -83,7 +83,7 @@ void write_is_viewer(void* opaque, uint32_t address, uint32_t value, uint32_t ma
}
else
{
word = m64p_swap32(word);
word = big32(word);
memcpy(&is_viewer->data[address], &word, sizeof(word));
}
}
10 changes: 8 additions & 2 deletions src/device/r4300/cp1.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

#define FCR31_FS_BIT UINT32_C(0x1000000)

#ifdef M64P_BIG_ENDIAN
#define DOUBLE_HALF_XOR 1
#else
#define DOUBLE_HALF_XOR 0
#endif

void init_cp1(struct cp1* cp1, struct new_dynarec_hot_state* new_dynarec_hot_state)
{
#ifdef NEW_DYNAREC
Expand Down Expand Up @@ -104,15 +110,15 @@ void set_fpr_pointers(struct cp1* cp1, uint32_t newStatus)
{
for (i = 0; i < 32; i++)
{
(r4300_cp1_regs_simple(cp1))[i] = &cp1->regs[i & ~1].float32[i & 1];
(r4300_cp1_regs_simple(cp1))[i] = &cp1->regs[i & ~1].float32[i & 1 ^ DOUBLE_HALF_XOR];
(r4300_cp1_regs_double(cp1))[i] = &cp1->regs[i & ~1].float64;
}
}
else
{
for (i = 0; i < 32; i++)
{
(r4300_cp1_regs_simple(cp1))[i] = &cp1->regs[i].float32[0];
(r4300_cp1_regs_simple(cp1))[i] = &cp1->regs[i].float32[DOUBLE_HALF_XOR];
(r4300_cp1_regs_double(cp1))[i] = &cp1->regs[i].float64;
}
}
Expand Down

0 comments on commit 20615a1

Please sign in to comment.