1 /* aNetHack 0.0.1 thintile.c $ANH-Date: 1457207049 2016/03/05 19:44:09 $ $ANH-Branch: chasonr $:$ANH-Revision: 1.10 $ */
2 /* Copyright (c) aNetHack Development Team 1995 */
3 /* aNetHack may be freely redistributed. See license for details. */
5 /* Create a set of overview tiles by eliminating even pixels in original */
14 static char pixels
[TILE_Y
][TILE_X
];
16 static char *tilefiles
[] = { "../win/share/monsters.txt",
17 "../win/share/objects.txt",
18 "../win/share/other.txt" };
20 static char *thinfiles
[] = { "../win/share/monthin.txt",
21 "../win/share/objthin.txt",
22 "../win/share/oththin.txt" };
23 static FILE *infile
, *outfile
;
25 static int tilecount_per_file
;
27 static char comment
[BUFSZ
];
35 while (fscanf(infile
, "%[A-Za-z0-9.] = (%d, %d, %d) ", c
, &r
, &g
, &b
)
37 Fprintf(outfile
, "%c = (%d, %d, %d)\n", c
[0], r
, g
, b
);
50 if (fscanf(infile
, "# %s %d (%[^)])", buf2
, &i
, buf
) <= 0)
53 Sprintf(comment
, "# tile %d (%s)", i
, buf
);
55 /* look for non-whitespace at each stage */
56 if (fscanf(infile
, "%1s", c
) < 0) {
57 Fprintf(stderr
, "unexpected EOF\n");
61 Fprintf(stderr
, "didn't find expected '{'\n");
64 for (j
= 0; j
< TILE_Y
; j
++) {
65 for (i
= 0; i
< TILE_X
; i
++) {
66 if (fscanf(infile
, "%1s", c
) < 0) {
67 Fprintf(stderr
, "unexpected EOF\n");
73 if (fscanf(infile
, "%1s ", c
) < 0) {
74 Fprintf(stderr
, "unexpected EOF\n");
78 Fprintf(stderr
, "didn't find expected '}'\n");
89 Fprintf(outfile
, "%s\n", comment
);
90 Fprintf(outfile
, "{\n");
91 for (j
= 0; j
< TILE_Y
; j
++) {
92 Fprintf(outfile
, " ");
93 for (i
= 0; i
< TILE_X
; i
+= 2) {
94 (void) fputc(pixels
[j
][i
], outfile
);
96 Fprintf(outfile
, "\n");
98 Fprintf(outfile
, "}\n");
105 while (filenum
< 3) {
106 tilecount_per_file
= 0;
107 infile
= fopen(tilefiles
[filenum
], RDTMODE
);
108 outfile
= fopen(thinfiles
[filenum
], WRTMODE
);
110 while (read_txttile()) {
112 tilecount_per_file
++;
117 printf("%d tiles processed from %s\n", tilecount_per_file
,
121 printf("Grand total of %d tiles processed.\n", tilecount
);