From 3589a77cae310757deefe6fff95b61a638823750 Mon Sep 17 00:00:00 2001 From: PugsyMAME Date: Fri, 24 Mar 2017 19:09:53 +0000 Subject: Fixed writes to decrypted opcode memory Fixes problem in the debugger and the cheat engine as currently the writes to opcode memory are not handled correctly, so separated EXPSPACE_RAMWRITE and EXPSPACE_OPCODE case statements to allow opcode writes to access the correct memory. Example: In flicky this will now disable cat collisions with the main sprite: maincpu.ob@3ac6=c3 --- src/emu/debug/debugcpu.cpp | 51 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index ecd4996b320..342bf9d9461 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -987,7 +987,6 @@ u64 debugger_cpu::expression_read_memory(void *param, const char *name, expressi break; } - case EXPSPACE_OPCODE: case EXPSPACE_RAMWRITE: { device_t *device = nullptr; @@ -1000,13 +999,32 @@ u64 debugger_cpu::expression_read_memory(void *param, const char *name, expressi device = get_visible_cpu(); memory = &device->memory(); } - if (!with_se) { + if (!with_se) + auto dis = m_machine.disable_side_effect(); + return expression_read_program_direct(memory->space(AS_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size); + break; + } + + case EXPSPACE_OPCODE: + { + device_t *device = nullptr; + device_memory_interface *memory; + + if (name != nullptr) + device = expression_get_device(name); + if (device == nullptr || !device->interface(memory)) + { + device = get_visible_cpu(); + memory = &device->memory(); + } + if (!with_se) auto dis = m_machine.disable_side_effect(); - return expression_read_program_direct(memory->space(AS_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size); - } else + if (memory->has_space(AS_DECRYPTED_OPCODES + (spacenum - EXPSPACE_OPCODE))) + return expression_read_program_direct(memory->space(AS_DECRYPTED_OPCODES), (spacenum == EXPSPACE_OPCODE), address, size); + else return expression_read_program_direct(memory->space(AS_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size); break; - } + } case EXPSPACE_REGION: if (name == nullptr) @@ -1179,7 +1197,6 @@ void debugger_cpu::expression_write_memory(void *param, const char *name, expres } break; - case EXPSPACE_OPCODE: case EXPSPACE_RAMWRITE: if (name != nullptr) device = expression_get_device(name); @@ -1188,12 +1205,26 @@ void debugger_cpu::expression_write_memory(void *param, const char *name, expres device = get_visible_cpu(); memory = &device->memory(); } - if (!with_se) { + if (!with_se) auto dis = m_machine.disable_side_effect(); - expression_write_program_direct(memory->space(AS_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size, data); - } else - expression_write_program_direct(memory->space(AS_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size, data); + expression_write_program_direct(memory->space(AS_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size, data); break; + + case EXPSPACE_OPCODE: + if (name != nullptr) + device = expression_get_device(name); + if (device == nullptr || !device->interface(memory)) + { + device = get_visible_cpu(); + memory = &device->memory(); + } + if (!with_se) + auto dis = m_machine.disable_side_effect(); + if (memory->has_space(AS_DECRYPTED_OPCODES + (spacenum - EXPSPACE_OPCODE))) + expression_write_program_direct(memory->space(AS_DECRYPTED_OPCODES), (spacenum == EXPSPACE_OPCODE), address, size, data); + else + expression_write_program_direct(memory->space(AS_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size, data); + break; case EXPSPACE_REGION: if (name == nullptr) -- cgit v1.2.3