Skip to content

Commit

Permalink
Fixes compatibility on creation of 256 bytes/sector images.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsc committed Feb 11, 2019
1 parent 0feb769 commit aee6a4d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/mkatr.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

static void write_atr(const char *out, const char *data, int ssec, int nsec)
{
int size = ssec * nsec;
int size = (nsec > 3) ? ssec * (nsec - 3) + 128 * 3 : 128 * nsec;
show_msg("writing image with %d sectors of %d bytes, total %d bytes.\n",
nsec, ssec, size);
FILE *f = fopen(out, "wb");
Expand All @@ -49,8 +49,17 @@ static void write_atr(const char *out, const char *data, int ssec, int nsec)
putc(0, f);
putc(0, f);
putc(0, f);
fwrite(data, ssec, nsec, f);
fclose(f);

for(int i=0; i<nsec; i++)
{
// First three sectors are 128 bytes
if( i < 3 )
fwrite(data + ssec * i, 128, 1, f);
else
fwrite(data + ssec * i, ssec, 1, f);
}
if( 0 != fclose(f) )
show_error("can't write output fil '%s': %s\n", out, strerror(errno));
}

int main(int argc, char **argv)
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once
const char *prog_version = "1.2-20190210";
const char *prog_version = "1.3-20190211";

0 comments on commit aee6a4d

Please sign in to comment.