commit 6a10f2f0461b89ad522d3e5bcf1479f5270c8ab3
parent 760855c5654538a5eeef7d8adf062cf65a5f50ea
Author: Quentin Rameau <quinq@fifth.space>
Date: Tue, 10 Nov 2015 16:59:40 +0100
Regroup game count inscription
That is only needed once everything has been processed.
Always rewrite file header.
Diffstat:
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/addrom.c b/addrom.c
@@ -70,12 +70,6 @@ getbingamecount(uint64_t n)
}
static void
-setgamecount(char *buf, const uint32_t hexcount)
-{
- *(uint32_t *)(buf) = hexcount;
-}
-
-static void
ereadinfile(char *datbuf, const ssize_t size, FILE *infile)
{
if (fread(datbuf, 1, size, infile) != size)
@@ -180,9 +174,6 @@ main(int argc, char *argv[])
ereadinfile(outbuf, offset, infile);
- setgamecount(outbuf + HEADERSZSZ,
- getbingamecount((infilesize - HEADERSZ) / ENTRYSZ + 1));
-
addrom(outbuf + offset, &rom);
ereadinfile(outbuf + offset + ENTRYSZ, infilesize - offset,
@@ -192,15 +183,15 @@ main(int argc, char *argv[])
outbuf = ecalloc(outbufsize);
- *(uint32_t *)(outbuf) = HEADERSZ;
-
- setgamecount(outbuf + HEADERSZSZ, getbingamecount(1));
-
offset = HEADERSZ;
addrom(outbuf + offset, &rom);
}
+ *(uint32_t *)(outbuf) = HEADERSZ;
+ *(uint32_t *)(outbuf + HEADERSZSZ) =
+ getbingamecount((outbufsize - HEADERSZ) / ENTRYSZ);
+
/* write out buffer */
if (out && !(outfile = fopen(out, "w")))
die("Can't open output file %s\n", out);