mirror of
https://github.com/holub/mame
synced 2025-05-16 10:52:43 +03:00
Add basic LOAD function to the debugger to complement the existing SAVE function. It allows you to load a binary file straight into writeable memory. The format is the same as the SAVE function with the exception that the <length> can be handled differently. [Pugsy]
This commit is contained in:
parent
5ea7d4443f
commit
00a3403054
@ -130,6 +130,7 @@ static void execute_wpdisenable(running_machine *machine, int ref, int params, c
|
|||||||
static void execute_wplist(running_machine *machine, int ref, int params, const char **param);
|
static void execute_wplist(running_machine *machine, int ref, int params, const char **param);
|
||||||
static void execute_hotspot(running_machine *machine, int ref, int params, const char **param);
|
static void execute_hotspot(running_machine *machine, int ref, int params, const char **param);
|
||||||
static void execute_save(running_machine *machine, int ref, int params, const char **param);
|
static void execute_save(running_machine *machine, int ref, int params, const char **param);
|
||||||
|
static void execute_load(running_machine *machine, int ref, int params, const char **param);
|
||||||
static void execute_dump(running_machine *machine, int ref, int params, const char **param);
|
static void execute_dump(running_machine *machine, int ref, int params, const char **param);
|
||||||
static void execute_cheatinit(running_machine *machine, int ref, int params, const char **param);
|
static void execute_cheatinit(running_machine *machine, int ref, int params, const char **param);
|
||||||
static void execute_cheatnext(running_machine *machine, int ref, int params, const char **param);
|
static void execute_cheatnext(running_machine *machine, int ref, int params, const char **param);
|
||||||
@ -314,6 +315,10 @@ void debug_command_init(running_machine *machine)
|
|||||||
debug_console_register_command(machine, "saved", CMDFLAG_NONE, ADDRESS_SPACE_DATA, 3, 4, execute_save);
|
debug_console_register_command(machine, "saved", CMDFLAG_NONE, ADDRESS_SPACE_DATA, 3, 4, execute_save);
|
||||||
debug_console_register_command(machine, "savei", CMDFLAG_NONE, ADDRESS_SPACE_IO, 3, 4, execute_save);
|
debug_console_register_command(machine, "savei", CMDFLAG_NONE, ADDRESS_SPACE_IO, 3, 4, execute_save);
|
||||||
|
|
||||||
|
debug_console_register_command(machine, "load", CMDFLAG_NONE, ADDRESS_SPACE_PROGRAM, 3, 4, execute_load);
|
||||||
|
debug_console_register_command(machine, "loadd", CMDFLAG_NONE, ADDRESS_SPACE_DATA, 3, 4, execute_load);
|
||||||
|
debug_console_register_command(machine, "loadi", CMDFLAG_NONE, ADDRESS_SPACE_IO, 3, 4, execute_load);
|
||||||
|
|
||||||
debug_console_register_command(machine, "dump", CMDFLAG_NONE, ADDRESS_SPACE_PROGRAM, 3, 6, execute_dump);
|
debug_console_register_command(machine, "dump", CMDFLAG_NONE, ADDRESS_SPACE_PROGRAM, 3, 6, execute_dump);
|
||||||
debug_console_register_command(machine, "dumpd", CMDFLAG_NONE, ADDRESS_SPACE_DATA, 3, 6, execute_dump);
|
debug_console_register_command(machine, "dumpd", CMDFLAG_NONE, ADDRESS_SPACE_DATA, 3, 6, execute_dump);
|
||||||
debug_console_register_command(machine, "dumpi", CMDFLAG_NONE, ADDRESS_SPACE_IO, 3, 6, execute_dump);
|
debug_console_register_command(machine, "dumpi", CMDFLAG_NONE, ADDRESS_SPACE_IO, 3, 6, execute_dump);
|
||||||
@ -1547,6 +1552,56 @@ static void execute_save(running_machine *machine, int ref, int params, const ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------
|
||||||
|
execute_load - execute the load command
|
||||||
|
-------------------------------------------------*/
|
||||||
|
|
||||||
|
static void execute_load(running_machine *machine, int ref, int params, const char *param[])
|
||||||
|
{
|
||||||
|
UINT64 offset, endoffset, length;
|
||||||
|
address_space *space;
|
||||||
|
FILE *f;
|
||||||
|
UINT64 i;
|
||||||
|
|
||||||
|
/* validate parameters */
|
||||||
|
if (!debug_command_parameter_number(machine, param[1], &offset))
|
||||||
|
return;
|
||||||
|
if (!debug_command_parameter_number(machine, param[2], &length))
|
||||||
|
return;
|
||||||
|
if (!debug_command_parameter_cpu_space(machine, (params > 3) ? param[3] : NULL, ref, &space))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* determine the addresses to read */
|
||||||
|
endoffset = space->address_to_byte(offset + length - 1) & space->bytemask();
|
||||||
|
offset = space->address_to_byte(offset) & space->bytemask();
|
||||||
|
|
||||||
|
/* open the file */
|
||||||
|
f = fopen(param[0], "rb");
|
||||||
|
if (!f)
|
||||||
|
{
|
||||||
|
debug_console_printf(machine, "Error opening file '%s'\n", param[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* now read the data in, ignore endoffset and load entire file if length has been set to zero (offset-1) */
|
||||||
|
UINT8 byte;
|
||||||
|
for (i = offset; i <= endoffset || endoffset == offset - 1 ; i++)
|
||||||
|
{
|
||||||
|
fread(&byte, 1, 1, f);
|
||||||
|
/* check if end of file has been reached and stop loading if it has */
|
||||||
|
if (feof(f))
|
||||||
|
break;
|
||||||
|
debug_write_byte(space, i, byte, TRUE);
|
||||||
|
}
|
||||||
|
/* close the file */
|
||||||
|
fclose(f);
|
||||||
|
if ( i == offset)
|
||||||
|
debug_console_printf(machine, "Length specified too large, load failed\n");
|
||||||
|
else
|
||||||
|
debug_console_printf(machine, "Data loaded successfully to memory : 0x%s to 0x%s\n", core_i64_hex_format(offset,0), core_i64_hex_format(i-1,0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
execute_dump - execute the dump command
|
execute_dump - execute the dump command
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
@ -106,6 +106,9 @@ static const help_item static_help_list[] =
|
|||||||
" save <filename>,<address>,<length>[,<cpu>] -- save binary program memory to the given file\n"
|
" save <filename>,<address>,<length>[,<cpu>] -- save binary program memory to the given file\n"
|
||||||
" saved <filename>,<address>,<length>[,<cpu>] -- save binary data memory to the given file\n"
|
" saved <filename>,<address>,<length>[,<cpu>] -- save binary data memory to the given file\n"
|
||||||
" savei <filename>,<address>,<length>[,<cpu>] -- save binary I/O memory to the given file\n"
|
" savei <filename>,<address>,<length>[,<cpu>] -- save binary I/O memory to the given file\n"
|
||||||
|
" load <filename>,<address>,<length>[,<cpu>] -- load binary program memory from the given file\n"
|
||||||
|
" loadd <filename>,<address>,<length>[,<cpu>] -- load binary data memory from the given file\n"
|
||||||
|
" loadi <filename>,<address>,<length>[,<cpu>] -- load binary I/O memory from the given file\n"
|
||||||
" map <address> -- map logical program address to physical address and bank\n"
|
" map <address> -- map logical program address to physical address and bank\n"
|
||||||
" mapd <address> -- map logical data address to physical address and bank\n"
|
" mapd <address> -- map logical data address to physical address and bank\n"
|
||||||
" mapi <address> -- map logical I/O address to physical address and bank\n"
|
" mapi <address> -- map logical I/O address to physical address and bank\n"
|
||||||
@ -488,6 +491,28 @@ static const help_item static_help_list[] =
|
|||||||
"saved harddriv.bin,3000,1000,3\n"
|
"saved harddriv.bin,3000,1000,3\n"
|
||||||
" Saves data memory addresses 3000-3fff from CPU #3 to the binary file 'harddriv.bin'.\n"
|
" Saves data memory addresses 3000-3fff from CPU #3 to the binary file 'harddriv.bin'.\n"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"load",
|
||||||
|
"\n"
|
||||||
|
" load[{d|i}] <filename>,<address>,<length>[,<cpu>]\n"
|
||||||
|
"\n"
|
||||||
|
"The load/loadd/loadi commands load raw memory from the binary file specified in the <filename> "
|
||||||
|
"parameter. 'load' will load program space memory, while 'loadd' will load data space memory "
|
||||||
|
"and 'loadi' will load I/O space memory. <address> indicates the address of the start of saving, "
|
||||||
|
"and <length> indicates how much memory to load. The range <address> through <address>+<length>-1 "
|
||||||
|
"inclusive will be read in from the file. If you specify <length> = 0 or a length greater than the "
|
||||||
|
"total length of the file it will load the entire contents of the file and no more. You can also load "
|
||||||
|
"memory from another CPU by specifying the <cpu> parameter.\n"
|
||||||
|
"NOTE: This will only actually write memory that is possible to overwrite in the Memory Window\n"
|
||||||
|
"\n"
|
||||||
|
"Examples:\n"
|
||||||
|
"\n"
|
||||||
|
"load venture.bin,0,10000\n"
|
||||||
|
" Loads addresses 0-ffff in the current CPU from the binary file 'venture.bin'.\n"
|
||||||
|
"\n"
|
||||||
|
"loadd harddriv.bin,3000,1000,3\n"
|
||||||
|
" Loads data memory addresses 3000-3fff from CPU #3 from the binary file 'harddriv.bin'.\n"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"step",
|
"step",
|
||||||
"\n"
|
"\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user