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