diff options
author | Max Horn | 2003-05-02 21:29:05 +0000 |
---|---|---|
committer | Max Horn | 2003-05-02 21:29:05 +0000 |
commit | c1b38d64ed706bac4097e56a5c04914e4d2b1b39 (patch) | |
tree | c154b5bcc937f88d85018c9fb4867e8dc7079883 /common | |
parent | 3a83153fb509dd26fe1068ca3e3d3021355cd8ee (diff) | |
download | scummvm-rg350-c1b38d64ed706bac4097e56a5c04914e4d2b1b39.tar.gz scummvm-rg350-c1b38d64ed706bac4097e56a5c04914e4d2b1b39.tar.bz2 scummvm-rg350-c1b38d64ed706bac4097e56a5c04914e4d2b1b39.zip |
make hexdump width variable
svn-id: r7269
Diffstat (limited to 'common')
-rw-r--r-- | common/util.cpp | 19 | ||||
-rw-r--r-- | common/util.h | 4 |
2 files changed, 12 insertions, 11 deletions
diff --git a/common/util.cpp b/common/util.cpp index 791b7e7b6d..a1ccbc6d70 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -96,24 +96,25 @@ void ClearBlendCache(byte *palette, int weight) { } // -// Print hexdump of the data passed in, 8 bytes a row +// Print hexdump of the data passed in // -void hexdump(const byte * data, int len) { +void hexdump(const byte * data, int len, int bytes_per_line) { + assert(1 <= bytes_per_line && bytes_per_line <= 32); int i; byte c; - while (len >= 8) { - for (i = 0; i < 8; i++) + while (len >= bytes_per_line) { + for (i = 0; i < bytes_per_line; i++) printf("%02x ", data[i]); printf(" |"); - for (i = 0; i < 8; i++) { + for (i = 0; i < bytes_per_line; i++) { c = data[i]; if (c < 32 || c >= 127) c = '.'; printf("%c", c); } printf("|\n"); - data += 8; - len -= 8; + data += bytes_per_line; + len -= bytes_per_line; } if (len <= 0) @@ -121,7 +122,7 @@ void hexdump(const byte * data, int len) { for (i = 0; i < len; i++) printf("%02x ", data[i]); - for (; i < 8; i++) + for (; i < bytes_per_line; i++) printf(" "); printf(" |"); for (i = 0; i < len; i++) { @@ -130,7 +131,7 @@ void hexdump(const byte * data, int len) { c = '.'; printf("%c", c); } - for (; i < 8; i++) + for (; i < bytes_per_line; i++) printf(" "); printf("|\n"); } diff --git a/common/util.h b/common/util.h index eb7534dd32..9fc73acdcb 100644 --- a/common/util.h +++ b/common/util.h @@ -43,9 +43,9 @@ int Blend(int src, int dst, byte *palette); void ClearBlendCache(byte *palette, int weight); /* - * Print hexdump of the data passed in, 8 bytes a row + * Print hexdump of the data passed in */ -void hexdump(const byte * data, int len); +void hexdump(const byte * data, int len, int bytes_per_line = 8); class RandomSource { private: |