shithub: rgbds

Download patch

ref: 08b1b97a45200af02cb7d76e6134d5e0f759a9d7
parent: 17192ea6f07c2697bd87bc28df015a66f6e97fc3
author: Anthony J. Bentley <[email protected]>
date: Sat Feb 8 21:58:00 EST 2014

Preserve the ability to set pad_value in rgbfix.

--- a/src/fix/main.c
+++ b/src/fix/main.c
@@ -380,6 +380,7 @@
 
 		/* 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 @@
 		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) {