(cd ../util ; $(MAKE) tile2bmp)
x11tiles: ../util/tile2x11 ../win/share/monsters.txt ../win/share/objects.txt \
- ../win/share/other.txt
+ ../win/share/other.txt \
+ ../win/share/monsters.txt
../util/tile2x11 ../win/share/monsters.txt ../win/share/objects.txt \
- ../win/share/other.txt
+ ../win/share/other.txt \
+ -grayscale ../win/share/monsters.txt
beostiles: ../util/tile2beos ../win/share/monsters.txt \
../win/share/objects.txt \
header.per_row = TILES_PER_ROW;
if (argc == 1) {
- Fprintf(stderr, "usage: %s txt_file1 [txt_file2 ...]\n", argv[0]);
+ Fprintf(stderr, "usage: %s txt_file1 [txt_file2 ...] [-grayscale txt_fileN]\n", argv[0]);
exit(1);
}
/* don't leave garbage at end of partial row */
(void) memset((genericptr_t) tile_bytes, 0, sizeof(tile_bytes));
- for (i = 1; i < argc; i++)
+ for (i = 1; i < argc; i++) {
+ if (!strncmp(argv[i], "-grayscale", 10)) {
+ set_grayscale(TRUE);
+ if (i < (argc - 1)) i++;
+ } else {
+ set_grayscale(FALSE);
+ }
process_file(argv[i]);
+ }
Fprintf(stderr, "Total tiles: %ld\n", header.ntiles);
/* round size up to the end of the row */
boolean write_text_tile(pixel[TILE_Y][TILE_X]);
writes tile
-There are two additional shared routines provided for writers:
+There are some additional shared routines provided for writers:
+void set_grayscale(boolean g);
+ do grayscale color substitutions when reading the tile text file
void init_colormap();
initialize the output colormap from the input one
must be called before opening output file as colormap is part of header
extern boolean FDECL(write_text_tile, (pixel(*) [TILE_X]));
extern int NDECL(fclose_text_file);
+extern void FDECL(set_grayscale, (boolean));
extern void NDECL(init_colormap);
extern void NDECL(merge_colormap);
#endif
#endif
-#if defined(MSDOS) || defined(WIN32)
+#if defined(MSDOS) || defined(WIN32) || defined(X11_GRAPHICS)
#define STATUES_LOOK_LIKE_MONSTERS
#endif
"%[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.] = " \
"(%d, %d, %d) "
+static boolean grayscale = FALSE;
+/* grayscale color mapping */
+static const int graymappings[] = {
+ /* . A B C D E F G H I J K L M N O P */
+ 0, 1, 17, 18, 19, 20, 27, 22, 23, 24, 25, 26, 21, 15, 13, 14, 14
+};
+
+void
+set_grayscale(g)
+boolean g;
+{
+ grayscale = g;
+}
+
static void
read_text_colormap(txtfile)
FILE *txtfile;
return FALSE;
}
k = color_index[(int) c[0]];
+ if (grayscale) {
+ if (k > (SIZE(graymappings) - 1))
+ Fprintf(stderr, "Gray mapping issue %d > %d.\n", k,
+ SIZE(graymappings) - 1);
+ else
+ k = graymappings[k];
+ }
if (k == -1)
Fprintf(stderr, "color %c not in colormap!\n", c[0]);
else {