From 08b1b97a45200af02cb7d76e6134d5e0f759a9d7 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Sun, 9 Feb 2014 02:58:00 -0700 Subject: [PATCH] Preserve the ability to set pad_value in rgbfix. --- src/fix/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/fix/main.c b/src/fix/main.c index 32ed3db5..f13bc14e 100644 --- a/src/fix/main.c +++ b/src/fix/main.c @@ -380,6 +380,7 @@ main(int argc, char *argv[]) /* We will pad the ROM to match the size given in the header. */ int romsize, newsize, headbyte; + uint8_t *buf; fseek(rom, 0, SEEK_END); romsize = ftell(rom); newsize = 0x8000; @@ -393,10 +394,14 @@ main(int argc, char *argv[]) if (newsize > 0x800000) /* ROM is bigger than 8MiB */ fprintf(stderr, "ROM size is bigger than 8MiB\n"); - ftruncate(fileno(rom), newsize); + buf = malloc(newsize - romsize); + memset(buf, padvalue, newsize - romsize); + fwrite(buf, 1, newsize - romsize, rom); fseek(rom, 0x148, SEEK_SET); fputc(headbyte, rom); + + free(buf); } if (setramsize) {