+# other.txt - tile defintions for 'other' (walls, furniture, explosions)
+# Note: if the number of monster tiles, object tiles, or other tiles
+# changes, 'MAGICTILENO' in tile2bmp.c needs to be updated to match!
+# Note too: lines beginning with '# tile ' are not comments; other
+# lines beginning with '#' are.
. = (71, 108, 108)
A = (0, 0, 0)
B = (0, 182, 255)
/* The numbers in the following calculation are the
count of tiles present in:
monsters.txt objects.txt other.txt monsters.txt */
-#define MAGICTILENO (788 + 459 + 237 + 788)
+#define MAGICTILENO (789 + 477 + 240 + 789)
#if BITCOUNT == 4
#define MAX_X 320 /* 2 per byte, 4 bits per pixel */
exit(1);
}
while (pass < 4) {
- filenum = pass % (sizeof(tilefiles) / sizeof(char *));
+ filenum = pass % (sizeof tilefiles / sizeof (char *));
if (!fopen_text_file(tilefiles[filenum], RDTMODE)) {
Fprintf(stderr, "usage: tile2bmp (from the util directory)\n");
exit(EXIT_FAILURE);
set_grayscale(pass == 3);
/* printf("Colormap initialized\n"); */
while (read_text_tile(tilepixels)) {
+ if (tilecount >= MAGICTILENO) {
+ Fprintf(stderr, "tile2bmp: more than %d tiles!\n",
+ MAGICTILENO);
+ exit(EXIT_FAILURE);
+ }
build_bmptile(tilepixels);
tilecount++;
#if BITCOUNT == 4
(void) fclose_text_file();
++pass;
}
- fwrite(&bmp, sizeof(bmp), 1, fp);
+ fwrite(&bmp, sizeof bmp, 1, fp);
fclose(fp);
Fprintf(stderr, "Total of %d tiles written to %s.\n", tilecount, bmpname);
break;
}
if (cur_color >= num_colors)
- Fprintf(stderr, "color not in colormap!\n");
+ Fprintf(stderr, "color not in colormap! (tile #%d)\n",
+ tilecount);
y = (MAX_Y - 1) - (cur_y + yoffset);
apply_color = cur_color;
#if BITCOUNT == 4
x = (cur_x / 2) + xoffset;
- bmp.packtile[y][x] = cur_x % 2
- ? (uchar)(bmp.packtile[y][x] | cur_color)
- : (uchar)(cur_color << 4);
+ bmp.packtile[y][x] = (cur_x % 2 != 0)
+ ? (uchar) (bmp.packtile[y][x] | cur_color)
+ : (uchar) (cur_color << 4);
#else
x = cur_x + xoffset;
bmp.packtile[y][x] = (uchar) apply_color;
}
/*tile2bmp.c*/
-