summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2020-09-08 18:51:03 -0500
committer cracyc <cracyc@users.noreply.github.com>2020-09-08 18:51:03 -0500
commita03b22c555b509bf4dad5d38cb1f8dfd41aee9b1 (patch)
treed9312643254f0041a985038bfec7d4a13afd6a8a
parent6ebfb737a8cbad6fa54ad744dee27ffb72755c70 (diff)
cheat_simple: with game genie codes try 32k nes banks then fall back to 8k and warn with 6 char codes and banked prg
-rw-r--r--plugins/cheat/cheat_simple.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/cheat/cheat_simple.lua b/plugins/cheat/cheat_simple.lua
index 11c63e6e642..9640cf22bc6 100644
--- a/plugins/cheat/cheat_simple.lua
+++ b/plugins/cheat/cheat_simple.lua
@@ -92,13 +92,20 @@ function codefuncs.nes_gg(desc, code)
if #code == 6 then
addr = ((value >> 4) & 7) | ((value >> 8) & 0x78) | ((value >> 12) & 0x80) | ((value << 8) & 0x700) | ((value << 4) & 0x7800)
newval = ((value >> 20) & 7) | (value & 8) | ((value >> 12) & 0x70) | ((value >> 16) & 0x80)
+ if manager:machine():memory().regions[":nes_slot:cart:prg_rom"].size > 32768 then
+ emu.print_verbose("warning: gamegenie 6 char code with banked rom " .. desc)
+ end
return prepare_rom_cheat(desc, ":nes_slot:cart:prg_rom", addr, newval, 8)
elseif #code == 8 then
addr = ((value >> 12) & 7) | ((value >> 16) & 0x78) | ((value >> 20) & 0x80) | (value & 0x700) | ((value >> 4) & 0x7800)
newval = ((value >> 28) & 7) | (value & 8) | ((value >> 20) & 0x70) | ((value >> 24) & 0x80)
comp = ((value >> 4) & 7) | ((value >> 8) & 8) | ((value << 4) & 0x70) | (value & 0x80)
- -- assume 8K banks, 32K also common but is an easy multiple of 8K
- return prepare_rom_cheat(desc, ":nes_slot:cart:prg_rom", addr, newval, 8, 8192, comp)
+ -- try 32K banks then 8K
+ local status, cheat = pcall(prepare_rom_cheat, desc, ":nes_slot:cart:prg_rom", addr, newval, 8, 32768, comp)
+ if not status then
+ cheat = prepare_rom_cheat(desc, ":nes_slot:cart:prg_rom", addr, newval, 8, 8192, comp)
+ end
+ return cheat
else
error("error game genie cheat incorrect length " .. desc)
end