svp compiler, early stage, works
[picodrive.git] / tools / mkbgxx.c
CommitLineData
8ab3e3c1 1#include <stdio.h>
2#include <zlib.h>
3
4static unsigned char buff[0x10140];
5static unsigned char buff2[0x10140];
6
7static void do_file(const char *ifn, const char *ofn)
8{
9 FILE *fi, *fo;
10 int ret;
11 unsigned long dlen = sizeof(buff2);
12
13 fi = fopen(ifn, "rb");
14 if (!fi) return;
15 fseek(fi, 0x10020, SEEK_SET);
16 fread(buff, 1, 0x10000, fi);
17 fseek(fi, 0x2000, SEEK_CUR);
18 fread(buff + 0x10000, 1, 0x80*2, fi);
19 fseek(fi, 0x221a0, SEEK_SET);
20 fread(buff + 0x10100, 1, 0x40, fi);
21 fclose(fi);
22
23 ret = compress2(buff2, &dlen, buff, sizeof(buff), Z_BEST_COMPRESSION);
24 if (ret) { printf("compress2 failed with %i\n", ret); return; }
25
26 fo = fopen(ofn, "wb");
27 if (!fo) return;
28 fwrite(buff2, 1, dlen, fo);
29 fclose(fo);
30
31 printf("%s: %6i -> %6li\n", ofn, sizeof(buff), dlen);
32}
33
34int main(int argc, char *argv[])
35{
36 if (argc != 3) return 1;
37
38 do_file(argv[1], "bg40.bin");
39 do_file(argv[2], "bg32.bin");
40
41 return 0;
42}
43