From ec7ae35da1e6b5d02d8f99ad9bea5a90afad15a8 Mon Sep 17 00:00:00 2001 From: Duckbill Date: Fri, 12 Jan 2018 10:46:50 +0300 Subject: [PATCH] Fixes for masked 16-bit cheat opcodes, based on existing cheats. --- sysmodules/rosalina/source/menus/cheats.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/sysmodules/rosalina/source/menus/cheats.c b/sysmodules/rosalina/source/menus/cheats.c index 84708cc..aa77355 100644 --- a/sysmodules/rosalina/source/menus/cheats.c +++ b/sysmodules/rosalina/source/menus/cheats.c @@ -327,12 +327,9 @@ u32 Cheat_applyCheat(const CheatDescription* const cheat) { { u32 newSkip; u16 mask = (u16) ((arg1 >> 16) & 0xFFFF); - if (mask == 0) { - mask = 0xFFFF; - } u16 value = 0; if (!Cheat_read16(arg0 & 0x0FFFFFFF, &value)) return 0; - if ((value & mask) < (arg1 & 0xFFFF)) { + if ((value & (~mask)) < (arg1 & 0xFFFF)) { newSkip = 0; } else { newSkip = 1; @@ -352,12 +349,9 @@ u32 Cheat_applyCheat(const CheatDescription* const cheat) { { u32 newSkip; u16 mask = (u16) ((arg1 >> 16) & 0xFFFF); - if (mask == 0) { - mask = 0xFFFF; - } u16 value = 0; if (!Cheat_read16(arg0 & 0x0FFFFFFF, &value)) return 0; - if ((value & mask) > (arg1 & 0xFFFF)) { + if ((value & (~mask)) > (arg1 & 0xFFFF)) { newSkip = 0; } else { newSkip = 1; @@ -377,12 +371,9 @@ u32 Cheat_applyCheat(const CheatDescription* const cheat) { { u32 newSkip; u16 mask = (u16) ((arg1 >> 16) & 0xFFFF); - if (mask == 0) { - mask = 0xFFFF; - } u16 value = 0; if (!Cheat_read16(arg0 & 0x0FFFFFFF, &value)) return 0; - if ((value & mask) == (arg1 & 0xFFFF)) { + if ((value & (~mask)) == (arg1 & 0xFFFF)) { newSkip = 0; } else { newSkip = 1; @@ -402,12 +393,9 @@ u32 Cheat_applyCheat(const CheatDescription* const cheat) { { u32 newSkip; u16 mask = (u16) ((arg1 >> 16) & 0xFFFF); - if (mask == 0) { - mask = 0xFFFF; - } u16 value = 0; if (!Cheat_read16(arg0 & 0x0FFFFFFF, &value)) return 0; - if ((value & mask) != (arg1 & 0xFFFF)) { + if ((value & (~mask)) != (arg1 & 0xFFFF)) { newSkip = 0; } else { newSkip = 1;