summaryrefslogtreecommitdiffstats
path: root/src/core/arm
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2014-12-20 21:21:25 +0100
committerbunnei <bunneidev@gmail.com>2014-12-20 21:21:25 +0100
commit7095c4959b5dac8091a461881cb53b136ae4b8d0 (patch)
tree22e2cee1a4d0a94ddfe4aca8e15341518a3ff7fa /src/core/arm
parentMerge pull request #313 from lioncash/smlsd (diff)
parentarmemu: Implement USAD8 and USADA8 (diff)
downloadyuzu-7095c4959b5dac8091a461881cb53b136ae4b8d0.tar
yuzu-7095c4959b5dac8091a461881cb53b136ae4b8d0.tar.gz
yuzu-7095c4959b5dac8091a461881cb53b136ae4b8d0.tar.bz2
yuzu-7095c4959b5dac8091a461881cb53b136ae4b8d0.tar.lz
yuzu-7095c4959b5dac8091a461881cb53b136ae4b8d0.tar.xz
yuzu-7095c4959b5dac8091a461881cb53b136ae4b8d0.tar.zst
yuzu-7095c4959b5dac8091a461881cb53b136ae4b8d0.zip
Diffstat (limited to 'src/core/arm')
-rw-r--r--src/core/arm/interpreter/armemu.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/core/arm/interpreter/armemu.cpp b/src/core/arm/interpreter/armemu.cpp
index b21d97e12..7408b6f08 100644
--- a/src/core/arm/interpreter/armemu.cpp
+++ b/src/core/arm/interpreter/armemu.cpp
@@ -6374,7 +6374,30 @@ L_stm_s_takeabort:
printf ("Unhandled v6 insn: smmla/smmls/smmul\n");
break;
case 0x78:
- printf ("Unhandled v6 insn: usad/usada8\n");
+ if (BITS(20, 24) == 0x18)
+ {
+ const u8 rm_idx = BITS(8, 11);
+ const u8 rn_idx = BITS(0, 3);
+ const u8 rd_idx = BITS(16, 19);
+
+ const u32 rm_val = state->Reg[rm_idx];
+ const u32 rn_val = state->Reg[rn_idx];
+
+ const u8 diff1 = (u8)::abs((rn_val & 0xFF) - (rm_val & 0xFF));
+ const u8 diff2 = (u8)::abs(((rn_val >> 8) & 0xFF) - ((rm_val >> 8) & 0xFF));
+ const u8 diff3 = (u8)::abs(((rn_val >> 16) & 0xFF) - ((rm_val >> 16) & 0xFF));
+ const u8 diff4 = (u8)::abs(((rn_val >> 24) & 0xFF) - ((rm_val >> 24) & 0xFF));
+
+ u32 finalDif = (diff1 + diff2 + diff3 + diff4);
+
+ // Op is USADA8 if true.
+ const u8 ra_idx = BITS(12, 15);
+ if (ra_idx != 15)
+ finalDif += state->Reg[ra_idx];
+
+ state->Reg[rd_idx] = finalDif;
+ return 1;
+ }
break;
case 0x7a:
printf ("Unhandled v6 insn: usbfx\n");