| 231 | } |
| 232 | |
| 233 | static void |
| 234 | build_tibtile(pixel (*pixels)[TILE_X], boolean statues) |
| 235 | { |
| 236 | static int graymappings[] = { |
| 237 | /* . A B C D E F G H I J K L M N O P */ |
| 238 | 0, 1, 17, 18, 19, 20, 27, 22, 23, 24, 25, 26, 21, 15, 13, 14, 14 |
| 239 | }; |
| 240 | int i, j, k, co_off; |
| 241 | unsigned char co_mask, tmp; |
| 242 | |
| 243 | #ifdef PLANAR_FILE |
| 244 | #ifndef OVERVIEW_FILE |
| 245 | memset((void *) &planetile, 0, sizeof(struct planar_cell_struct)); |
| 246 | #else |
| 247 | memset((void *) &planetile, 0, |
| 248 | sizeof(struct overview_planar_cell_struct)); |
| 249 | #endif |
| 250 | #endif |
| 251 | for (j = 0; j < TILE_Y; j++) { |
| 252 | for (i = 0; i < TILE_X; i++) { |
| 253 | for (k = 0; k < num_colors; k++) { |
| 254 | if (ColorMap[CM_RED][k] == pixels[j][i].r |
| 255 | && ColorMap[CM_GREEN][k] == pixels[j][i].g |
| 256 | && ColorMap[CM_BLUE][k] == pixels[j][i].b) |
| 257 | break; |
| 258 | } |
| 259 | if (k >= num_colors) |
| 260 | Fprintf(stderr, "color not in colormap!\n"); |
| 261 | if (statues) { |
| 262 | k = graymappings[k]; |
| 263 | } else { |
| 264 | if (k == 16) { |
| 265 | k = 13; |
| 266 | } else if (k == 13) { |
| 267 | k = 16; |
| 268 | } |
| 269 | } |
| 270 | #ifdef PACKED_FILE |
| 271 | packtile[j][i] = k; |
| 272 | #endif |
| 273 | |
| 274 | #ifdef PLANAR_FILE |
| 275 | if (i > 7) { |
| 276 | co_off = 1; |
| 277 | co_mask = masktable[i - 8]; |
| 278 | } else { |
| 279 | co_off = 0; |
| 280 | co_mask = masktable[i]; |
| 281 | } |
| 282 | |
| 283 | if (!statues) { |
| 284 | if (k == 28) { |
| 285 | k = 0; |
| 286 | } |
| 287 | if (k >= 16) { |
| 288 | fprintf(stderr, "Warning: pixel value %d in 16 color bitmap\n", k); |
| 289 | } |
| 290 | } |