From 57edaf00ffda88830f1a9efa1fa6521e835c2aee Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 9 Jan 2023 17:00:03 +0000 Subject: Added dump mode --- tapls.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/tapls.c b/tapls.c index c00ec47..0f7fe97 100644 --- a/tapls.c +++ b/tapls.c @@ -22,6 +22,7 @@ #include #include #include +#include /* ---------------------------------------- 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; -- cgit v1.2.3