1 /* 2000-04-19T13:26:05Z
3 * construct some tables to be included directly in emerald mine source.
4 * i made this because dynamically building the tables every time sucks and i
5 * need to be able to easily modify tile.h.
7 * this is key data which almost everything depends on.
9 * this is supposed to be fairly easy to read and modify. the tab values
10 * are still hard coded constants but that should be less of a problem to
17 /* ------------------------------------------------------------------------- */
62 int tile_android_move[] =
72 /* ------------------------------------------------------------------------- */
74 /* explosions: special format */
75 /* everything is initially filled with Xboom_1 */
128 TILE_MAX, /* up till here are indestructable */
139 Xbomb_pause, Xboom_bomb,
140 Xbomb_fall, Xboom_bomb,
141 TILE_MAX, /* up till here are special explosions */
143 Xandroid, Xboom_android,
144 Xandroid_1_n, Xboom_android,
145 Xandroid_2_n, Xboom_android,
146 Xandroid_1_e, Xboom_android,
147 Xandroid_2_e, Xboom_android,
148 Xandroid_1_s, Xboom_android,
149 Xandroid_2_s, Xboom_android,
150 Xandroid_1_w, Xboom_android,
151 Xandroid_2_w, Xboom_android,
152 TILE_MAX /* up until here are dynamite explosions */
156 /* ------------------------------------------------------------------------- */
158 /* map the graphics file to internal tiles and animations
160 * one graphics icon maps to many tiles and animations
312 /* use normal "Xblank" instead of explicit x==0, y==2 empty space graphic */
1924 Xemerald_force_e, 0,
1925 Xemerald_force_e, 1,
1926 Xemerald_force_e, 2,
1927 Xemerald_force_e, 3,
1928 Xemerald_force_e, 4,
1929 Xemerald_force_e, 5,
1930 Xemerald_force_e, 6,
1931 Xemerald_force_e, 7,
1932 Xemerald_force_w, 0,
1933 Xemerald_force_w, 1,
1934 Xemerald_force_w, 2,
1935 Xemerald_force_w, 3,
1936 Xemerald_force_w, 4,
1937 Xemerald_force_w, 5,
1938 Xemerald_force_w, 6,
1939 Xemerald_force_w, 7,
2083 Xdiamond_force_e, 0,
2084 Xdiamond_force_e, 1,
2085 Xdiamond_force_e, 2,
2086 Xdiamond_force_e, 3,
2087 Xdiamond_force_e, 4,
2088 Xdiamond_force_e, 5,
2089 Xdiamond_force_e, 6,
2090 Xdiamond_force_e, 7,
2091 Xdiamond_force_w, 0,
2092 Xdiamond_force_w, 1,
2093 Xdiamond_force_w, 2,
2094 Xdiamond_force_w, 3,
2095 Xdiamond_force_w, 4,
2096 Xdiamond_force_w, 5,
2097 Xdiamond_force_w, 6,
2098 Xdiamond_force_w, 7,
3383 Xsand_stonesand_1, 0,
3384 Xsand_stonesand_1, 1,
3385 Xsand_stonesand_1, 2,
3386 Xsand_stonesand_1, 3,
3387 Xsand_stonesand_1, 4,
3388 Xsand_stonesand_1, 5,
3389 Xsand_stonesand_1, 6,
3390 Xsand_stonesand_1, 7,
3391 Xsand_stonesand_2, 0,
3392 Xsand_stonesand_2, 1,
3393 Xsand_stonesand_2, 2,
3394 Xsand_stonesand_2, 3,
3395 Xsand_stonesand_2, 4,
3396 Xsand_stonesand_2, 5,
3397 Xsand_stonesand_2, 6,
3398 Xsand_stonesand_2, 7,
3399 Xsand_stonesand_3, 0,
3400 Xsand_stonesand_3, 1,
3401 Xsand_stonesand_3, 2,
3402 Xsand_stonesand_3, 3,
3403 Xsand_stonesand_3, 4,
3404 Xsand_stonesand_3, 5,
3405 Xsand_stonesand_3, 6,
3406 Xsand_stonesand_3, 7,
3407 Xsand_stonesand_4, 0,
3408 Xsand_stonesand_4, 1,
3409 Xsand_stonesand_4, 2,
3410 Xsand_stonesand_4, 3,
3411 Xsand_stonesand_4, 4,
3412 Xsand_stonesand_4, 5,
3413 Xsand_stonesand_4, 6,
3414 Xsand_stonesand_4, 7,
3415 Xsand_sandstone_1, 0,
3416 Xsand_sandstone_1, 1,
3417 Xsand_sandstone_1, 2,
3418 Xsand_sandstone_1, 3,
3419 Xsand_sandstone_1, 4,
3420 Xsand_sandstone_1, 5,
3421 Xsand_sandstone_1, 6,
3422 Xsand_sandstone_1, 7,
3423 Xsand_sandstone_2, 0,
3424 Xsand_sandstone_2, 1,
3425 Xsand_sandstone_2, 2,
3426 Xsand_sandstone_2, 3,
3427 Xsand_sandstone_2, 4,
3428 Xsand_sandstone_2, 5,
3429 Xsand_sandstone_2, 6,
3430 Xsand_sandstone_2, 7,
3431 Xsand_sandstone_3, 0,
3432 Xsand_sandstone_3, 1,
3433 Xsand_sandstone_3, 2,
3434 Xsand_sandstone_3, 3,
3435 Xsand_sandstone_3, 4,
3436 Xsand_sandstone_3, 5,
3437 Xsand_sandstone_3, 6,
3438 Xsand_sandstone_3, 7,
3439 Xsand_sandstone_4, 0,
3440 Xsand_sandstone_4, 1,
3441 Xsand_sandstone_4, 2,
3442 Xsand_sandstone_4, 3,
3443 Xsand_sandstone_4, 4,
3444 Xsand_sandstone_4, 5,
3445 Xsand_sandstone_4, 6,
3446 Xsand_sandstone_4, 7,
4371 SPR_walk + 0, 0, 0, 1, 2, 3, 4, 5, 6, 7,
4372 SPR_walk + 1, 0, 8, 9, 10, 11, 12, 13, 14, 15,
4373 SPR_walk + 2, 0, 16, 17, 18, 19, 20, 21, 22, 23,
4374 SPR_walk + 3, 0, 24, 25, 26, 27, 28, 29, 30, 31,
4376 SPR_push + 0, 0, 32, 33, 34, 35, 36, 35, 34, 33,
4377 SPR_push + 1, 0, 37, 38, 39, 40, 41, 40, 39, 38,
4378 SPR_push + 2, 0, 42, 43, 44, 45, 46, 45, 44, 43,
4379 SPR_push + 3, 0, 47, 48, 49, 50, 51, 50, 49, 48,
4381 SPR_spray + 0, 0, 52, 52, 52, 52, 52, 52, 52, 52,
4382 SPR_spray + 1, 0, 53, 53, 53, 53, 53, 53, 53, 53,
4383 SPR_spray + 2, 0, 54, 54, 54, 54, 54, 54, 54, 54,
4384 SPR_spray + 3, 0, 55, 55, 55, 55, 55, 55, 55, 55,
4386 SPR_walk + 0, 1, 56, 57, 58, 59, 60, 61, 62, 63,
4387 SPR_walk + 1, 1, 64, 65, 66, 67, 68, 69, 70, 71,
4388 SPR_walk + 2, 1, 72, 73, 74, 75, 76, 77, 78, 79,
4389 SPR_walk + 3, 1, 80, 81, 82, 83, 84, 85, 86, 87,
4391 SPR_push + 0, 1, 88, 89, 90, 91, 92, 91, 90, 89,
4392 SPR_push + 1, 1, 93, 94, 95, 96, 97, 96, 95, 94,
4393 SPR_push + 2, 1, 98, 99, 100, 101, 102, 101, 100, 99,
4394 SPR_push + 3, 1, 103, 104, 105, 106, 107, 106, 105, 104,
4396 SPR_spray + 0, 1, 108, 108, 108, 108, 108, 108, 108, 108,
4397 SPR_spray + 1, 1, 109, 109, 109, 109, 109, 109, 109, 109,
4398 SPR_spray + 2, 1, 110, 110, 110, 110, 110, 110, 110, 110,
4399 SPR_spray + 3, 1, 111, 111, 111, 111, 111, 111, 111, 111,
4401 SPR_still, 0, 112,112, 112, 112, 112, 112, 112, 112,
4402 SPR_still, 1, 113,113, 113, 113, 113, 113, 113, 113,
4408 /* 0=stop 1=blank */
4409 unsigned char tab_blank[TILE_MAX];
4412 unsigned char tab_acid[TILE_MAX];
4414 /* 0=stop 1=amoeba */
4415 unsigned char tab_amoeba[TILE_MAX];
4418 unsigned char tab_android_move[TILE_MAX];
4420 /* normal explosion */
4421 unsigned short tab_explode_normal[TILE_MAX];
4423 /* dynamite explosion */
4424 unsigned short tab_explode_dynamite[TILE_MAX];
4426 /* map tiles to coords */
4427 unsigned short map_obj[8][TILE_MAX];
4429 /* map sprites to coords */
4430 unsigned short map_spr[2][8][13];
4432 /* map ascii to coords */
4433 unsigned short map_ttl[128];
4435 /* map tiles and frames to graphic info */
4436 struct GraphicInfo_EM graphic_info_em_object[TILE_MAX][8];
4438 /* map player number, frames and action to graphic info */
4439 struct GraphicInfo_EM graphic_info_em_player[MAX_PLAYERS][SPR_MAX][8];
4441 void create_tab(int *invert, unsigned char *array)
4444 int buffer[TILE_MAX];
4446 for (i = 0; i < TILE_MAX; i++)
4449 for (;invert[0] < TILE_MAX; invert += 2)
4450 buffer[invert[0]] = invert[1];
4452 for (i = 0; i < TILE_MAX; i++)
4453 array[i] = buffer[i];
4456 void create_explode()
4459 int *tile = tile_explode;
4460 int buffer[TILE_MAX];
4462 for (i = 0; i < TILE_MAX; i++)
4463 buffer[i] = Xboom_1;
4464 while ((i = *tile++) < TILE_MAX)
4465 buffer[i] = i; /* these tiles are indestructable */
4466 while ((i = *tile++) < TILE_MAX)
4467 buffer[i] = *tile++; /* these tiles are special */
4469 for (i = 0; i < TILE_MAX; i++)
4470 tab_explode_normal[i] = buffer[i];
4472 while ((i = *tile++) < TILE_MAX)
4473 buffer[i] = *tile++; /* these tiles for dynamite */
4475 for (i = 0; i < TILE_MAX; i++)
4476 tab_explode_dynamite[i] = buffer[i];
4483 int buffer[8][TILE_MAX];
4489 for (i = 0; i < 8; i++)
4490 for (j = 0; j < TILE_MAX; j++)
4493 for (i = 0; i < 64; i++)
4495 for (;*map != -1; map += 2)
4497 if (map[0] < 0 || map[0] >= TILE_MAX || map[1] < 0 || map[1] >= 8)
4499 fprintf(stderr, "obj_map: bad tile (%d, %d) @ %d+%d\n",
4500 map[0], map[1], i / 16, i % 16);
4504 buffer[map[1]][map[0]]++;
4509 for (i = 0; i < 896; i++)
4511 for (;*map != -1; map += 2)
4513 if (map[0] < 0 || map[0] >= TILE_MAX || map[1] < 0 || map[1] >= 8)
4515 fprintf(stderr, "obj_map: bad tile (%d, %d) @ %d\n", map[0], map[1], i);
4519 buffer[map[1]][map[0]]++;
4524 for (i = 0; i < TILE_MAX; i++)
4526 for (j = 0; j < 8; j++)
4528 switch(buffer[j][i])
4531 fprintf(stderr, "obj_map: uninitialized (%d, %d)\n", i, j);
4537 fprintf(stderr, "obj_map: duplicate (%d, %d)\n", i, j);
4544 if (sizeof(obj_map) / sizeof(*obj_map) != map - obj_map)
4546 fprintf(stderr, "obj_map: bad end (%d != %d)\n",
4547 sizeof(obj_map) / sizeof(*obj_map), map - obj_map);
4552 fprintf(stderr, "obj_map: looks good, now disable debug code\n");
4558 for (i = 0; i < 8; i++)
4559 for (j = 0; j < TILE_MAX; j++)
4560 buffer[i][j] = Xblank;
4562 /* special case for first 64 entries */
4563 for (i = 0; i < 64; i++)
4565 for (;*map != -1; map += 2)
4566 buffer[map[1]][map[0]] = i;
4570 /* now regular entries */
4571 for (i = 0; i < 896 * 16; i += 16)
4573 for (;*map != -1; map += 2)
4574 buffer[map[1]][map[0]] = i;
4578 for (i = 0; i < 8; i++)
4579 for (j = 0; j < TILE_MAX; j++)
4580 map_obj[i][j] = buffer[7 - i][j];
4585 void create_obj_graphics_info_em()
4589 for (i = 0; i < TILE_MAX; i++)
4591 for (j = 0; j < 8; j++)
4593 struct GraphicInfo_EM *g = &graphic_info_em_object[i][j];
4594 int obj = map_obj[j][i];
4596 g->bitmap = objBitmap;
4597 g->src_x = (obj / 512) * TILEX;
4598 g->src_y = (obj % 512) * TILEY / 16;
4599 g->src_offset_x = 0;
4600 g->src_offset_y = 0;
4601 g->dst_offset_x = 0;
4602 g->dst_offset_y = 0;
4606 g->crumbled_bitmap = NULL;
4607 g->crumbled_src_x = 0;
4608 g->crumbled_src_y = 0;
4609 g->crumbled_border_size = 0;
4611 g->has_crumbled_graphics = FALSE;
4612 g->preserve_background = FALSE;
4614 /* create unique graphic identifier to decide if tile must be redrawn */
4615 g->unique_identifier = obj;
4624 int buffer[2][8][SPR_MAX];
4626 while (*map < SPR_MAX)
4631 for (k = 0; k < 8; k++)
4632 buffer[j][k][i] = *map++;
4635 for (i = 0; i < 2; i++)
4636 for (j = 0; j < 8; j++)
4637 for (k = 0; k < SPR_MAX; k++)
4638 map_spr[i][j][k] = buffer[i][7 - j][k];
4641 void create_spr_graphics_info_em()
4645 for (i = 0; i < MAX_PLAYERS; i++)
4647 for (j = 0; j < SPR_MAX; j++)
4649 for (k = 0; k < 8; k++)
4651 struct GraphicInfo_EM *g = &graphic_info_em_player[i][j][k];
4652 int spr = map_spr[i % 2][k][j];
4654 g->bitmap = sprBitmap;
4655 g->src_x = (spr / 8) * TILEX;
4656 g->src_y = (spr % 8) * TILEY;
4657 g->src_offset_x = 0;
4658 g->src_offset_y = 0;
4659 g->dst_offset_x = 0;
4660 g->dst_offset_y = 0;
4664 g->has_crumbled_graphics = FALSE;
4665 g->crumbled_bitmap = NULL;
4666 g->crumbled_src_x = 0;
4667 g->crumbled_src_y = 0;
4668 g->crumbled_border_size = 0;
4670 g->unique_identifier = 0;
4678 create_tab(tile_blank, tab_blank);
4679 create_tab(tile_acid, tab_acid);
4680 create_tab(tile_amoeba, tab_amoeba);
4681 create_tab(tile_android_move, tab_android_move);
4687 void tab_generate_graphics_info_em()
4689 create_obj_graphics_info_em();
4690 create_spr_graphics_info_em();
4692 InitGraphicInfo_EM();