diff options
author | Ian C <ianc@noddybox.co.uk> | 2023-01-09 17:00:03 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2023-01-09 17:00:03 +0000 |
commit | 57edaf00ffda88830f1a9efa1fa6521e835c2aee (patch) | |
tree | d5bbc911f986c5d6a610de4686f2568bb959c89c | |
parent | d8f1b09f3b9d1a9039ab81549cc8414b46ed6828 (diff) |
Added dump mode
-rw-r--r-- | tapls.c | 42 |
1 files changed, 38 insertions, 4 deletions
@@ -22,6 +22,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <ctype.h> /* ---------------------------------------- MACROS */ @@ -77,13 +78,16 @@ static Z80Word GetTAPLSBWord(FILE **tapfile) } -static void TAPLoad(const char *path, FILE **tapfile) +static void TAPLoad(const char *path, FILE **tapfile, int dump) { while(TRUE) { Z80Word blen; Z80Byte type,b,csum,tape_csum; int warned = FALSE; + int col = 0; + char asc[17] = {0}; + unsigned off = 0; b = 0; @@ -120,9 +124,39 @@ static void TAPLoad(const char *path, FILE **tapfile) csum ^= b; } + if (dump) + { + if (col == 0) + { + printf("%4.4x:", off); + off += 16; + } + + printf(" %2.2x", (unsigned)b); + + asc[col++] = isprint(b) ? b : '.'; + + if (col == 16) + { + printf(" %s\n", asc); + memset(asc, 0, sizeof asc); + col = 0; + } + } + blen--; } + if (dump && col > 0) + { + while(col++ < 16) + { + printf(" **"); + } + + printf(" %s\n", asc); + } + tape_csum = b; /* Check the checksum @@ -133,7 +167,7 @@ static void TAPLoad(const char *path, FILE **tapfile) } -static void TapLS(const char *path) +static void TapLS(const char *path, int dump) { FILE *fp; @@ -141,7 +175,7 @@ static void TapLS(const char *path) if (fp) { - TAPLoad(path, &fp); + TAPLoad(path, &fp, dump); } else { @@ -202,7 +236,7 @@ int main(int argc, char *argv[]) for(f = file_i; f < argc; f++) { - TapLS(argv[f]); + TapLS(argv[f], dump); } return EXIT_SUCCESS; |