1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-19 06:31:31 +00:00
cc65/util/gamate/gamate-fixcart.c

26 lines
506 B
C
Raw Normal View History

2015-11-29 00:14:59 +00:00
#include <stdlib.h>
#include <stdio.h>
unsigned char buffer[512 * 1024];
unsigned len;
FILE *in, *out;
int n, i;
int main(int argc, char *argv[]) {
if (argc < 3) {
exit(-1);
}
in = fopen(argv[1], "rb");
out = fopen(argv[2], "wb");
len = fread(buffer, 1, 512 * 1024, in);
n = 0; for (i = 0x1000; i < 0x2000; i++) {
n += buffer[i];
}
buffer[0] = n & 0xff;
buffer[1] = (n >> 8) & 0xff;
fwrite(buffer, 1, len, out);
fclose(in);
fclose(out);
}