diff options
author | 2016-03-03 02:48:20 +1100 | |
---|---|---|
committer | 2016-03-03 03:53:43 +1100 | |
commit | 42ea68285296b7838fe9a3ce7e5d66061c8f7e21 (patch) | |
tree | e469b8575dcda181066d6cd0f60d5ba2c8e9ae33 /src | |
parent | d50614c8bd734b2b995c470a96336967be401206 (diff) |
core_i64_hex_format is now a static function in memory.cpp
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/memory.cpp | 29 | ||||
-rw-r--r-- | src/lib/util/corestr.cpp | 67 | ||||
-rw-r--r-- | src/lib/util/corestr.h | 4 |
3 files changed, 29 insertions, 71 deletions
diff --git a/src/emu/memory.cpp b/src/emu/memory.cpp index f5ebf5e3361..4401cc0d05e 100644 --- a/src/emu/memory.cpp +++ b/src/emu/memory.cpp @@ -187,6 +187,35 @@ #define VPRINTF(x) do { if (VERBOSE) printf x; } while (0) +/*------------------------------------------------- + core_i64_hex_format - i64 format printf helper +-------------------------------------------------*/ + +static char *core_i64_hex_format(UINT64 value, UINT8 mindigits) +{ + static char buffer[16][64]; + // TODO: this can overflow - e.g. when a lot of unmapped writes are logged + static int index; + char *bufbase = &buffer[index++ % 16][0]; + char *bufptr = bufbase; + INT8 curdigit; + + for (curdigit = 15; curdigit >= 0; curdigit--) + { + int nibble = (value >> (curdigit * 4)) & 0xf; + if (nibble != 0 || curdigit < mindigits) + { + mindigits = curdigit; + *bufptr++ = "0123456789ABCDEF"[nibble]; + } + } + if (bufptr == bufbase) + *bufptr++ = '0'; + *bufptr = 0; + + return bufbase; +} + //************************************************************************** diff --git a/src/lib/util/corestr.cpp b/src/lib/util/corestr.cpp index 2f39bc06ad9..7daad5cc0cb 100644 --- a/src/lib/util/corestr.cpp +++ b/src/lib/util/corestr.cpp @@ -126,73 +126,6 @@ char *core_strdup(const char *str) /*------------------------------------------------- - core_i64_hex_format - i64 format printf helper --------------------------------------------------*/ - -char *core_i64_hex_format(UINT64 value, UINT8 mindigits) -{ - static char buffer[16][64]; - // TODO: this can overflow - e.g. when a lot of unmapped writes are logged - static int index; - char *bufbase = &buffer[index++ % 16][0]; - char *bufptr = bufbase; - INT8 curdigit; - - for (curdigit = 15; curdigit >= 0; curdigit--) - { - int nibble = (value >> (curdigit * 4)) & 0xf; - if (nibble != 0 || curdigit < mindigits) - { - mindigits = curdigit; - *bufptr++ = "0123456789ABCDEF"[nibble]; - } - } - if (bufptr == bufbase) - *bufptr++ = '0'; - *bufptr = 0; - - return bufbase; -} - -/*------------------------------------------------- - core_i64_oct_format - i64 format printf helper --------------------------------------------------*/ - -char *core_i64_oct_format(UINT64 value, UINT8 mindigits) -{ - static char buffer[22][64]; - // TODO: this can overflow - static int index; - char *bufbase = &buffer[index++ % 22][0]; - char *bufptr = bufbase; - INT8 curdigit; - - for (curdigit = 21; curdigit >= 0; curdigit--) - { - int octdigit = (value >> (curdigit * 3)) & 0x7; - if (octdigit != 0 || curdigit < mindigits) - { - mindigits = curdigit; - *bufptr++ = "01234567"[octdigit]; - } - } - if (bufptr == bufbase) - *bufptr++ = '0'; - *bufptr = 0; - - return bufbase; -} - -/*------------------------------------------------- - core_i64_format - i64 format printf helper --------------------------------------------------*/ - -char *core_i64_format(UINT64 value, UINT8 mindigits, bool is_octal) -{ - return is_octal ? core_i64_oct_format(value,mindigits) : core_i64_hex_format(value,mindigits); -} - -/*------------------------------------------------- std::string helpers -------------------------------------------------*/ diff --git a/src/lib/util/corestr.h b/src/lib/util/corestr.h index bd08da1483c..29f98d06dc6 100644 --- a/src/lib/util/corestr.h +++ b/src/lib/util/corestr.h @@ -61,10 +61,6 @@ char *core_strdup(const char *str); int core_strwildcmp(const char *sp1, const char *sp2); -/* I64 printf helper */ -char *core_i64_format(UINT64 value, UINT8 mindigits, bool is_octal); -char *core_i64_hex_format(UINT64 value, UINT8 mindigits); - int strcatvprintf(std::string &str, const char *format, va_list args); void strdelchr(std::string& str, char chr); |