From d8f1b09f3b9d1a9039ab81549cc8414b46ed6828 Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 9 Jan 2023 16:44:23 +0000 Subject: Initial working version. Still dump to add. --- tapls.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tapls.c b/tapls.c index 3442c76..c00ec47 100644 --- a/tapls.c +++ b/tapls.c @@ -83,6 +83,7 @@ static void TAPLoad(const char *path, FILE **tapfile) { Z80Word blen; Z80Byte type,b,csum,tape_csum; + int warned = FALSE; b = 0; @@ -105,22 +106,24 @@ static void TAPLoad(const char *path, FILE **tapfile) while(blen) { - b=GetTAPByte(tapfile); - csum^=b; - blen--; - } + b = GetTAPByte(tapfile); + + if (!*tapfile && !warned) + { + fprintf(stderr,"%s: hit EOF during block (%u left)\n", path, + blen); + warned = TRUE; + } + + if (blen > 1) + { + csum ^= b; + } - /* Get the checksum - */ - if (blen) - { - tape_csum=GetTAPByte(tapfile); blen--; } - else - { - tape_csum=b; - } + + tape_csum = b; /* Check the checksum */ -- cgit v1.2.3