From eff9ba31d277d7ace410001437cbbe7c8f6d40f1 Mon Sep 17 00:00:00 2001 From: gibbed Date: Sat, 13 May 2017 23:44:02 -0500 Subject: [PATCH] Fixed PPCContext::cr() returning incorrectly shifted state. --- src/xenia/cpu/ppc/ppc_context.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/xenia/cpu/ppc/ppc_context.cc b/src/xenia/cpu/ppc/ppc_context.cc index 4143d21a6..cca51098d 100644 --- a/src/xenia/cpu/ppc/ppc_context.cc +++ b/src/xenia/cpu/ppc/ppc_context.cc @@ -22,12 +22,19 @@ namespace ppc { uint64_t PPCContext::cr() const { uint64_t final_bits = 0; for (int i = 0; i < 8; ++i) { - uint32_t crf = *(&cr0.value + i); - uint64_t bits = (crf & 0x1) << (4 * (7 - i) + 3) | - ((crf >> 8) & 0x1) << (4 * (7 - i) + 2) | - ((crf >> 16) & 0x1) << (4 * (7 - i) + 1) | - ((crf >> 24) & 0x1) << (4 * (7 - i) + 0); - final_bits |= bits << (i * 4); + union { + uint32_t value; + struct { + uint8_t lt; + uint8_t gt; + uint8_t eq; + uint8_t so; + }; + } crf; + crf.value = *(&cr0.value + i); + uint64_t bits = (crf.lt & 0x1) << 3 | (crf.gt & 0x1) << 2 | + (crf.eq & 0x1) << 1 | (crf.so & 0x1) << 0; + final_bits |= bits << ((7 - i) * 4); } return final_bits; }