summaryrefslogtreecommitdiff
path: root/tapls.c
diff options
context:
space:
mode:
Diffstat (limited to 'tapls.c')
-rw-r--r--tapls.c42
1 files 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 <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;