From 97142cb95b19c4b07a721a0b449c308b04d64e58 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Thu, 16 May 2024 05:46:44 -0400 Subject: blob2xex: warn on address wraparound. --- blob2xex.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'blob2xex.c') diff --git a/blob2xex.c b/blob2xex.c index 0f17371..413fb52 100644 --- a/blob2xex.c +++ b/blob2xex.c @@ -99,8 +99,12 @@ int write_segment( } /* make sure we don't wrap the Atari's address space. */ - if(size + loadaddr > 0xffff) + if(size + loadaddr > 0xffff) { + int oldsize = size; size = (size - loadaddr) + 1; + fprintf(stderr, SELF ": " + "warning: %s: address would exceed $FFFF! truncated %d bytes to %d.\n", infile, oldsize, size); + } /* read bytes, or until EOF (which is not an error) */ while(size) { @@ -209,6 +213,7 @@ int main(int argc, char **argv) { if( (bytes = write_segment(infile, outfile, loadaddr, initaddr, offset, size)) ) { segcount++; loadaddr += bytes; + loadaddr %= 0xffff; } else { segcount = 0; break; @@ -245,6 +250,8 @@ int main(int argc, char **argv) { fprintf(stderr, SELF ": read %d input files, wrote %d segments to %s.\n", incount, segcount, outfile); } else { + if(xex_verbose) + fprintf(stderr, SELF ": no output file created, due to fatal error.\n"); unlink(outfile); return 1; } -- cgit v1.2.3