diff options
author | 2020-08-06 20:53:02 +1000 | |
---|---|---|
committer | 2020-08-06 20:53:02 +1000 | |
commit | 746438653a8e0c30218aa9590bbad1e8fbab7f87 (patch) | |
tree | d446b4eb4a5f0aadd932f908700d43e9b1b5d4ab /src/emu/debug/debugcmd.cpp | |
parent | 2c799e11604986b2845d60b69fd5cac46e8e7b87 (diff) | |
parent | c55a261d26d225c5c847c046f729290139b6546e (diff) |
Merge tag 'mame0223' into mainline-master
MAME 0.223
Diffstat (limited to 'src/emu/debug/debugcmd.cpp')
-rw-r--r-- | src/emu/debug/debugcmd.cpp | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index b431bb88732..c6dda192e59 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -1982,7 +1982,6 @@ void debugger_commands::execute_saveregion(int ref, const std::vector<std::strin { u64 offset, length; memory_region *region; - FILE *f; /* validate parameters */ if (!validate_number_parameter(params[1], offset)) @@ -1992,21 +1991,21 @@ void debugger_commands::execute_saveregion(int ref, const std::vector<std::strin if (!validate_memory_region_parameter(params[3], region)) return; - /* open the file */ - f = fopen(params[0].c_str(), "wb"); - if (!f) { - m_console.printf("Error opening file '%s'\n", params[0].c_str()); + if (offset >= region->bytes()) + { + m_console.printf("Invalid offset\n"); return; } + if ((length <= 0) || ((length + offset) >= region->bytes())) + length = region->bytes() - offset; - if(offset >= region->bytes()) { - m_console.printf("Invalide offset\n"); + /* open the file */ + FILE *f = fopen(params[0].c_str(), "wb"); + if (!f) + { + m_console.printf("Error opening file '%s'\n", params[0].c_str()); return; } - // get full length - if(length <= 0 || length + offset >= region->bytes()) { - length = region->bytes() - offset; - } fwrite(region->base() + offset, 1, length, f); fclose(f); @@ -2123,14 +2122,13 @@ void debugger_commands::execute_load(int ref, const std::vector<std::string> &pa /*------------------------------------------------- - execute_saveregion - execute the save command on region memory + execute_loadregion - execute the load command on region memory -------------------------------------------------*/ void debugger_commands::execute_loadregion(int ref, const std::vector<std::string> ¶ms) { u64 offset, length; memory_region *region; - FILE *f; /* validate parameters */ if (!validate_number_parameter(params[1], offset)) @@ -2140,9 +2138,18 @@ void debugger_commands::execute_loadregion(int ref, const std::vector<std::strin if (!validate_memory_region_parameter(params[3], region)) return; + if (offset >= region->bytes()) + { + m_console.printf("Invalid offset\n"); + return; + } + if ((length <= 0) || ((length + offset) >= region->bytes())) + length = region->bytes() - offset; + /* open the file */ - f = fopen(params[0].c_str(), "rb"); - if (!f) { + FILE *f = fopen(params[0].c_str(), "rb"); + if (!f) + { m_console.printf("Error opening file '%s'\n", params[0].c_str()); return; } @@ -2151,18 +2158,9 @@ void debugger_commands::execute_loadregion(int ref, const std::vector<std::strin u64 size = ftell(f); rewind(f); - if(offset >= region->bytes()) { - m_console.printf("Invalide offset\n"); - return; - } - // get full length - if(length <= 0 || length + offset >= region->bytes()) { - length = region->bytes() - offset; - } // check file size - if(length >= size) { + if (length >= size) length = size; - } fread(region->base() + offset, 1, length, f); |