-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_mapdata.c
45 lines (38 loc) · 946 Bytes
/
build_mapdata.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
43
44
#include "wl_def.h"
FILE *f;
static void writeplane(int map, int plane)
{
int n;
int len;
char buf[16384];
len = mapheaderseg[map].planelength[plane];
fseek(f, mapheaderseg[map].planestart[plane], SEEK_SET);
fread(buf, mapheaderseg[map].planelength[plane], 1, f);
printf("static const byte MapData%02d_%d[%d] = {", map, plane, len);
for (n = 0; n < len; n++) {
if ((n & 15) == 0)
printf("\n");
printf (" %d,", buf[n]);
}
printf("\n};\n");
}
int main()
{
int i;
printf("#include \"wl_def.h\"\n");
f = fopen("gamemaps." GAMEEXT, "rb");
if (!f)
return 1;
for (i = 0; i < NUMMAPS; i++) {
writeplane(i, 0);
writeplane(i, 1);
}
fclose(f);
printf("const byte *const ROMAREA MapPlane[NUMMAPS * 2] = {\n");
for (i = 0; i < NUMMAPS; i++) {
printf(" MapData%02d_%d,\n", i, 0);
printf(" MapData%02d_%d,\n", i, 1);
}
printf("};\n");
return 0;
}