mirror of
https://github.com/holub/mame
synced 2025-05-21 05:08:54 +03:00
> From: Sandro Ronco [mailto:sandroronco@gmail.com]
> Sent: Wednesday, September 30, 2009 4:05 AM > To: submit@mamedev.org > Subject: Cheat > > I have added a simple system for auto-detect the ram region for make > more fast the cheatinit. But I have a problem on some address > translation, for example in seattle.c the ram region have a physical > address of 0x00000000 - 0x007fffff and the logical address is > 0x80000000 - 0x807fffff, I not have found a way for convert the > physical > address to the logical address. For now the only way for initialize the > cheat on seattle.c is force the address to the right range ("ci ub, > 0x80000000, 0x7fffff") but is not a good solution. > I hope can help me to fix this problem. > > Regards > > Sandro Ronco Fixed the logical/physical issue by having the cheat system always work at the physical layer and output cheats that explicitly point to the physical space.
This commit is contained in:
parent
cb51594344
commit
8d68eede38
@ -41,6 +41,7 @@ struct _global_entry
|
||||
UINT32 size;
|
||||
};
|
||||
|
||||
|
||||
typedef struct _cheat_map cheat_map;
|
||||
struct _cheat_map
|
||||
{
|
||||
@ -51,19 +52,31 @@ struct _cheat_map
|
||||
UINT8 undo:7;
|
||||
};
|
||||
|
||||
|
||||
typedef struct _cheat_system cheat_system;
|
||||
struct _cheat_system
|
||||
{
|
||||
char cpu;
|
||||
UINT64 length;
|
||||
UINT8 width;
|
||||
cheat_map * cheatmap;
|
||||
UINT8 undo;
|
||||
UINT8 signed_cheat;
|
||||
UINT8 swapped_cheat;
|
||||
char cpu;
|
||||
UINT64 length;
|
||||
UINT8 width;
|
||||
cheat_map * cheatmap;
|
||||
UINT8 undo;
|
||||
UINT8 signed_cheat;
|
||||
UINT8 swapped_cheat;
|
||||
};
|
||||
|
||||
|
||||
typedef struct _cheat_region_map cheat_region_map;
|
||||
struct _cheat_region_map
|
||||
{
|
||||
UINT64 offset;
|
||||
UINT64 endoffset;
|
||||
UINT8 share;
|
||||
UINT8 disabled;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
GLOBAL VARIABLES
|
||||
***************************************************************************/
|
||||
@ -1708,10 +1721,14 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch
|
||||
|
||||
static void execute_cheatinit(running_machine *machine, int ref, int params, const char *param[])
|
||||
{
|
||||
UINT64 offset, endoffset, length = 0, real_length = 0;
|
||||
UINT64 offset, length = 0, real_length = 0;
|
||||
const address_space *space;
|
||||
UINT32 active_cheat = 0;
|
||||
UINT64 curaddr;
|
||||
UINT8 i, region_count = 0;
|
||||
|
||||
address_map_entry *entry;
|
||||
cheat_region_map cheat_region[100];
|
||||
|
||||
/* validate parameters */
|
||||
if (!debug_command_parameter_cpu_space(machine, (params > 3) ? param[3] : NULL, ADDRESS_SPACE_PROGRAM, &space))
|
||||
@ -1719,6 +1736,9 @@ static void execute_cheatinit(running_machine *machine, int ref, int params, con
|
||||
|
||||
if (ref == 0)
|
||||
{
|
||||
cheat.width = 1;
|
||||
cheat.signed_cheat = FALSE;
|
||||
cheat.swapped_cheat = FALSE;
|
||||
if (params > 0)
|
||||
{
|
||||
char *srtpnt = (char*)param[0];
|
||||
@ -1752,35 +1772,51 @@ static void execute_cheatinit(running_machine *machine, int ref, int params, con
|
||||
else
|
||||
cheat.swapped_cheat = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cheat.width = 1;
|
||||
cheat.signed_cheat = FALSE;
|
||||
cheat.swapped_cheat = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (params > 1)
|
||||
/* initialize entire memory by default */
|
||||
if (params <= 1)
|
||||
{
|
||||
offset = 0;
|
||||
length = space->bytemask + 1;
|
||||
for (entry = space->map->entrylist; entry != NULL; entry = entry->next)
|
||||
{
|
||||
cheat_region[region_count].offset = memory_address_to_byte(space, entry->addrstart) & space->bytemask;
|
||||
cheat_region[region_count].endoffset = memory_address_to_byte(space, entry->addrend) & space->bytemask;
|
||||
cheat_region[region_count].share = entry->share;
|
||||
cheat_region[region_count].disabled = (entry->write.shandler8 == SMH_RAM) ? FALSE : TRUE;
|
||||
|
||||
/* disable double share regions */
|
||||
if (entry->share != 0)
|
||||
for (i = 0; i < region_count; i++)
|
||||
if (cheat_region[i].share == entry->share)
|
||||
cheat_region[region_count].disabled = TRUE;
|
||||
|
||||
region_count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* validate parameters */
|
||||
if (!debug_command_parameter_number(machine, param[(ref == 0) ? 1 : 0], &offset))
|
||||
return;
|
||||
if (!debug_command_parameter_number(machine, param[(ref == 0) ? 2 : 1], &length))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* initialize entire memory */
|
||||
offset = 0;
|
||||
length = space->bytemask + 1;
|
||||
|
||||
/* force region to the specified range */
|
||||
cheat_region[region_count].offset = memory_address_to_byte(space, offset) & space->bytemask;;
|
||||
cheat_region[region_count].endoffset = memory_address_to_byte(space, offset + length - 1) & space->bytemask;;
|
||||
cheat_region[region_count].share = 0;
|
||||
cheat_region[region_count].disabled = FALSE;
|
||||
region_count++;
|
||||
}
|
||||
|
||||
endoffset = memory_address_to_byte(space, offset + length - 1) & space->bytemask;
|
||||
offset = memory_address_to_byte(space, offset) & space->bytemask;
|
||||
|
||||
/* counts the writable bytes in the area */
|
||||
for (curaddr = offset; curaddr <= endoffset; curaddr += cheat.width)
|
||||
if (cheat_address_is_valid(space, curaddr))
|
||||
real_length++;
|
||||
/* determine the writable extent of each region in total */
|
||||
for (i = 0; i <= region_count; i++)
|
||||
if (!cheat_region[i].disabled)
|
||||
for (curaddr = cheat_region[i].offset; curaddr <= cheat_region[i].endoffset; curaddr += cheat.width)
|
||||
if (cheat_address_is_valid(space, curaddr))
|
||||
real_length++;
|
||||
|
||||
if (real_length == 0)
|
||||
{
|
||||
@ -1831,16 +1867,18 @@ static void execute_cheatinit(running_machine *machine, int ref, int params, con
|
||||
}
|
||||
|
||||
/* initialize cheatmap in the selected space */
|
||||
for (curaddr = offset; curaddr <= endoffset; curaddr += cheat.width)
|
||||
if (cheat_address_is_valid(space, curaddr))
|
||||
{
|
||||
cheat.cheatmap[active_cheat].previous_value = cheat_read_extended(&cheat, space, curaddr);
|
||||
cheat.cheatmap[active_cheat].first_value = cheat.cheatmap[active_cheat].previous_value;
|
||||
cheat.cheatmap[active_cheat].offset = curaddr;
|
||||
cheat.cheatmap[active_cheat].state = 1;
|
||||
cheat.cheatmap[active_cheat].undo = 0;
|
||||
active_cheat++;
|
||||
}
|
||||
for (i = 0; i < region_count; i++)
|
||||
if (!cheat_region[i].disabled)
|
||||
for (curaddr = cheat_region[i].offset; curaddr <= cheat_region[i].endoffset; curaddr += cheat.width)
|
||||
if (cheat_address_is_valid(space, curaddr))
|
||||
{
|
||||
cheat.cheatmap[active_cheat].previous_value = cheat_read_extended(&cheat, space, curaddr);
|
||||
cheat.cheatmap[active_cheat].first_value = cheat.cheatmap[active_cheat].previous_value;
|
||||
cheat.cheatmap[active_cheat].offset = curaddr;
|
||||
cheat.cheatmap[active_cheat].state = 1;
|
||||
cheat.cheatmap[active_cheat].undo = 0;
|
||||
active_cheat++;
|
||||
}
|
||||
|
||||
debug_console_printf(machine, "%u cheat initialized\n", active_cheat);
|
||||
}
|
||||
@ -2067,7 +2105,7 @@ static void execute_cheatlist(running_machine *machine, int ref, int params, con
|
||||
active_cheat++;
|
||||
fprintf(f, " <cheat desc=\"Possibility %d : %s (%s)\">\n", active_cheat, core_i64_hex_format(address, space->logaddrchars), core_i64_hex_format(value, cheat.width * 2));
|
||||
fprintf(f, " <script state=\"run\">\n");
|
||||
fprintf(f, " <action>%s.%c%c@%s=%s</action>\n", cpu->tag, spaceletter, sizeletter, core_i64_hex_format(address, space->logaddrchars), core_i64_hex_format(cheat_byte_swap(&cheat, cheat.cheatmap[cheatindex].first_value) & sizemask, cheat.width * 2));
|
||||
fprintf(f, " <action>%s.p%c%c@%s=%s</action>\n", cpu->tag, spaceletter, sizeletter, core_i64_hex_format(address, space->logaddrchars), core_i64_hex_format(cheat_byte_swap(&cheat, cheat.cheatmap[cheatindex].first_value) & sizemask, cheat.width * 2));
|
||||
fprintf(f, " </script>\n");
|
||||
fprintf(f, " </cheat>\n\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user