summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author PugsyMAME <pugsy@gmx.net>2017-03-26 12:10:16 +0100
committer Olivier Galibert <galibert@pobox.com>2017-03-26 13:10:16 +0200
commita97c0fbe87a189f49cf82dedce433393b33d342d (patch)
treee3000cb47738dc998336707d24873c1d548f2909
parentcc07ecc00e58d349c76ed185b15205de756a49cf (diff)
Fixed writes to decrypted opcode memory [v3] (#2190)
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 This is the simplest way of updating this, EXPSPACE_OPCODE is now a copy of EXPSPACE_RAMWRITE except it uses AS_DECRYPTED_OPCODES instead of AS_PROGRAM. This method means I've got a lot of work updating a lot of cheat file warnings ...but this is the correct way of doing this.
-rw-r--r--src/emu/debug/debugcpu.cpp51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp
index 3b765d79cc2..962a8e025cd 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;
@@ -1008,6 +1007,26 @@ u64 debugger_cpu::expression_read_memory(void *param, const char *name, expressi
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_DECRYPTED_OPCODES), (spacenum == EXPSPACE_OPCODE), address, size);
+ } else
+ return expression_read_program_direct(memory->space(AS_DECRYPTED_OPCODES), (spacenum == EXPSPACE_OPCODE), address, size);
+ break;
+ }
+
case EXPSPACE_REGION:
if (name == nullptr)
break;
@@ -1179,7 +1198,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);
@@ -1195,6 +1213,21 @@ void debugger_cpu::expression_write_memory(void *param, const char *name, expres
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();
+ expression_write_program_direct(memory->space(AS_DECRYPTED_OPCODES), (spacenum == EXPSPACE_OPCODE), address, size, data);
+ } else
+ expression_write_program_direct(memory->space(AS_DECRYPTED_OPCODES), (spacenum == EXPSPACE_OPCODE), address, size, data);
+ break;
+
case EXPSPACE_REGION:
if (name == nullptr)
break;
@@ -1367,7 +1400,6 @@ expression_error::error_code debugger_cpu::expression_validate(void *param, cons
return expression_error::NO_SUCH_MEMORY_SPACE;
break;
- case EXPSPACE_OPCODE:
case EXPSPACE_RAMWRITE:
if (name)
{
@@ -1381,6 +1413,19 @@ expression_error::error_code debugger_cpu::expression_validate(void *param, cons
return expression_error::NO_SUCH_MEMORY_SPACE;
break;
+ case EXPSPACE_OPCODE:
+ if (name)
+ {
+ device = expression_get_device(name);
+ if (device == nullptr || !device->interface(memory))
+ return expression_error::INVALID_MEMORY_NAME;
+ }
+ if (!device)
+ device = get_visible_cpu();
+ if (!device->interface(memory) || !memory->has_space(AS_DECRYPTED_OPCODES))
+ return expression_error::NO_SUCH_MEMORY_SPACE;
+ break;
+
case EXPSPACE_REGION:
if (!name)
return expression_error::MISSING_MEMORY_NAME;