diff options
| author | 2009-09-03 08:54:11 +0000 | |
|---|---|---|
| committer | 2009-09-03 08:54:11 +0000 | |
| commit | 6b159dfd11f55124f818048cbf7603ff76b2a5bc (patch) | |
| tree | a59ad043ada4d7092e717f79ba284c45db90443c /src/emu/debug/debugcpu.c | |
| parent | 53907cc1826b364d8fa12845e0dd53e61c674902 (diff) | |
From: Sandro Ronco [mailto:sandro.ronco@alice.it]
Sent: Wednesday, August 26, 2009 5:57 AM
To: submit@mamedev.org
Subject: MAME cheat search engine
This is a diff of my cheat search engine with help of Pugsy.
This is only a first part, not has the same functions of the old search engine, but is better than nothing
I have update the search engine to support search of byte, word, dword
and qword signed and unsigned.
Diffstat (limited to 'src/emu/debug/debugcpu.c')
| -rw-r--r-- | src/emu/debug/debugcpu.c | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index 1d6c96cafa1..5137e6bac2c 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -1531,6 +1531,25 @@ UINT64 debug_read_qword(const address_space *space, offs_t address, int apply_tr /*------------------------------------------------- + debug_read_memory - return 1,2,4 or 8 bytes + from the specified memory space +-------------------------------------------------*/ + +UINT64 debug_read_memory(const address_space *space, offs_t address, int size, int apply_translation) +{ + UINT64 result = ~(UINT64)0 >> (64 - 8*size); + switch (size) + { + case 1: result = debug_read_byte(space, address, apply_translation); break; + case 2: result = debug_read_word(space, address, apply_translation); break; + case 4: result = debug_read_dword(space, address, apply_translation); break; + case 8: result = debug_read_qword(space, address, apply_translation); break; + } + return result; +} + + +/*------------------------------------------------- debug_write_byte - write a byte to the specified memory space -------------------------------------------------*/ @@ -1727,6 +1746,23 @@ void debug_write_qword(const address_space *space, offs_t address, UINT64 data, /*------------------------------------------------- + debug_write_memory - write 1,2,4 or 8 bytes + to the specified memory space +-------------------------------------------------*/ + +void debug_write_memory(const address_space *space, offs_t address, UINT64 data, int size, int apply_translation) +{ + switch (size) + { + case 1: debug_write_byte(space, address, data, apply_translation); break; + case 2: debug_write_word(space, address, data, apply_translation); break; + case 4: debug_write_dword(space, address, data, apply_translation); break; + case 8: debug_write_qword(space, address, data, apply_translation); break; + } +} + + +/*------------------------------------------------- debug_read_opcode - read 1,2,4 or 8 bytes at the given offset from opcode space -------------------------------------------------*/ @@ -2471,19 +2507,7 @@ static UINT64 expression_read_address_space(const address_space *space, offs_t a UINT64 result = ~(UINT64)0 >> (64 - 8*size); if (space != NULL) - { - /* adjust the address into a byte address */ - address = memory_address_to_byte(space, address); - - /* switch contexts and do the read */ - switch (size) - { - case 1: result = debug_read_byte(space, address, TRUE); break; - case 2: result = debug_read_word(space, address, TRUE); break; - case 4: result = debug_read_dword(space, address, TRUE); break; - case 8: result = debug_read_qword(space, address, TRUE); break; - } - } + result = debug_read_memory(space, memory_address_to_byte(space, address), size, TRUE); return result; } @@ -2677,19 +2701,7 @@ static void expression_write_memory(void *param, const char *name, int space, UI static void expression_write_address_space(const address_space *space, offs_t address, int size, UINT64 data) { if (space != NULL) - { - /* adjust the address into a byte address */ - address = memory_address_to_byte(space, address); - - /* switch contexts and do the write */ - switch (size) - { - case 1: debug_write_byte(space, address, data, TRUE); break; - case 2: debug_write_word(space, address, data, TRUE); break; - case 4: debug_write_dword(space, address, data, TRUE); break; - case 8: debug_write_qword(space, address, data, TRUE); break; - } - } + debug_write_memory(space, memory_address_to_byte(space, address), data, size, TRUE); } |
