Changed file_talk files to open in binary mode

This commit is contained in:
Andrew Alderwick 2021-08-31 19:30:46 +01:00
parent 174ab66ddb
commit a6b99078de
2 changed files with 2 additions and 2 deletions

View File

@ -81,7 +81,7 @@ file_talk(Device *d, Uint8 b0, Uint8 w)
Uint16 result = 0, length = peek16(d->dat, 0xa); Uint16 result = 0, length = peek16(d->dat, 0xa);
long offset = (peek16(d->dat, 0x4) << 16) + peek16(d->dat, 0x6); long offset = (peek16(d->dat, 0x4) << 16) + peek16(d->dat, 0x6);
Uint16 addr = peek16(d->dat, b0 - 1); Uint16 addr = peek16(d->dat, b0 - 1);
FILE *f = fopen(name, read ? "r" : (offset ? "a" : "w")); FILE *f = fopen(name, read ? "rb" : (offset ? "ab" : "wb"));
if(f) { if(f) {
fprintf(stderr, "%s %s %s #%04x, ", read ? "Loading" : "Saving", name, read ? "to" : "from", addr); fprintf(stderr, "%s %s %s #%04x, ", read ? "Loading" : "Saving", name, read ? "to" : "from", addr);
if(fseek(f, offset, SEEK_SET) != -1) if(fseek(f, offset, SEEK_SET) != -1)

View File

@ -346,7 +346,7 @@ file_talk(Device *d, Uint8 b0, Uint8 w)
Uint16 result = 0, length = peek16(d->dat, 0xa); Uint16 result = 0, length = peek16(d->dat, 0xa);
long offset = (peek16(d->dat, 0x4) << 16) + peek16(d->dat, 0x6); long offset = (peek16(d->dat, 0x4) << 16) + peek16(d->dat, 0x6);
Uint16 addr = peek16(d->dat, b0 - 1); Uint16 addr = peek16(d->dat, b0 - 1);
FILE *f = fopen(name, read ? "r" : (offset ? "a" : "w")); FILE *f = fopen(name, read ? "rb" : (offset ? "ab" : "wb"));
if(f) { if(f) {
fprintf(stderr, "%s %s %s #%04x, ", read ? "Loading" : "Saving", name, read ? "to" : "from", addr); fprintf(stderr, "%s %s %s #%04x, ", read ? "Loading" : "Saving", name, read ? "to" : "from", addr);
if(fseek(f, offset, SEEK_SET) != -1) if(fseek(f, offset, SEEK_SET) != -1)