aboutsummaryrefslogtreecommitdiff
path: root/blob2xex.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-05-16 05:46:44 -0400
committerB. Watson <urchlay@slackware.uk>2024-05-16 05:46:44 -0400
commit97142cb95b19c4b07a721a0b449c308b04d64e58 (patch)
tree1804885c6649ce110489875752b4b36d62cad70d /blob2xex.c
parent82538a0230ff580c1ba251e8756c881380585587 (diff)
downloadbw-atari8-tools-97142cb95b19c4b07a721a0b449c308b04d64e58.tar.gz
blob2xex: warn on address wraparound.
Diffstat (limited to 'blob2xex.c')
-rw-r--r--blob2xex.c9
1 files changed, 8 insertions, 1 deletions
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 <size> 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;
}