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
18 /* ---------------------------------------------------------------------- */
63 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 */
155 /* ---------------------------------------------------------------------- */
157 /* map the graphics file to internal tiles and animations
159 * one graphics icon maps to many tiles and animations
1918 Xemerald_force_e, 0,
1919 Xemerald_force_e, 1,
1920 Xemerald_force_e, 2,
1921 Xemerald_force_e, 3,
1922 Xemerald_force_e, 4,
1923 Xemerald_force_e, 5,
1924 Xemerald_force_e, 6,
1925 Xemerald_force_e, 7,
1926 Xemerald_force_w, 0,
1927 Xemerald_force_w, 1,
1928 Xemerald_force_w, 2,
1929 Xemerald_force_w, 3,
1930 Xemerald_force_w, 4,
1931 Xemerald_force_w, 5,
1932 Xemerald_force_w, 6,
1933 Xemerald_force_w, 7,
2077 Xdiamond_force_e, 0,
2078 Xdiamond_force_e, 1,
2079 Xdiamond_force_e, 2,
2080 Xdiamond_force_e, 3,
2081 Xdiamond_force_e, 4,
2082 Xdiamond_force_e, 5,
2083 Xdiamond_force_e, 6,
2084 Xdiamond_force_e, 7,
2085 Xdiamond_force_w, 0,
2086 Xdiamond_force_w, 1,
2087 Xdiamond_force_w, 2,
2088 Xdiamond_force_w, 3,
2089 Xdiamond_force_w, 4,
2090 Xdiamond_force_w, 5,
2091 Xdiamond_force_w, 6,
2092 Xdiamond_force_w, 7,
3377 Xsand_stonesand_1, 0,
3378 Xsand_stonesand_1, 1,
3379 Xsand_stonesand_1, 2,
3380 Xsand_stonesand_1, 3,
3381 Xsand_stonesand_1, 4,
3382 Xsand_stonesand_1, 5,
3383 Xsand_stonesand_1, 6,
3384 Xsand_stonesand_1, 7,
3385 Xsand_stonesand_2, 0,
3386 Xsand_stonesand_2, 1,
3387 Xsand_stonesand_2, 2,
3388 Xsand_stonesand_2, 3,
3389 Xsand_stonesand_2, 4,
3390 Xsand_stonesand_2, 5,
3391 Xsand_stonesand_2, 6,
3392 Xsand_stonesand_2, 7,
3393 Xsand_stonesand_3, 0,
3394 Xsand_stonesand_3, 1,
3395 Xsand_stonesand_3, 2,
3396 Xsand_stonesand_3, 3,
3397 Xsand_stonesand_3, 4,
3398 Xsand_stonesand_3, 5,
3399 Xsand_stonesand_3, 6,
3400 Xsand_stonesand_3, 7,
3401 Xsand_stonesand_4, 0,
3402 Xsand_stonesand_4, 1,
3403 Xsand_stonesand_4, 2,
3404 Xsand_stonesand_4, 3,
3405 Xsand_stonesand_4, 4,
3406 Xsand_stonesand_4, 5,
3407 Xsand_stonesand_4, 6,
3408 Xsand_stonesand_4, 7,
3409 Xsand_sandstone_1, 0,
3410 Xsand_sandstone_1, 1,
3411 Xsand_sandstone_1, 2,
3412 Xsand_sandstone_1, 3,
3413 Xsand_sandstone_1, 4,
3414 Xsand_sandstone_1, 5,
3415 Xsand_sandstone_1, 6,
3416 Xsand_sandstone_1, 7,
3417 Xsand_sandstone_2, 0,
3418 Xsand_sandstone_2, 1,
3419 Xsand_sandstone_2, 2,
3420 Xsand_sandstone_2, 3,
3421 Xsand_sandstone_2, 4,
3422 Xsand_sandstone_2, 5,
3423 Xsand_sandstone_2, 6,
3424 Xsand_sandstone_2, 7,
3425 Xsand_sandstone_3, 0,
3426 Xsand_sandstone_3, 1,
3427 Xsand_sandstone_3, 2,
3428 Xsand_sandstone_3, 3,
3429 Xsand_sandstone_3, 4,
3430 Xsand_sandstone_3, 5,
3431 Xsand_sandstone_3, 6,
3432 Xsand_sandstone_3, 7,
3433 Xsand_sandstone_4, 0,
3434 Xsand_sandstone_4, 1,
3435 Xsand_sandstone_4, 2,
3436 Xsand_sandstone_4, 3,
3437 Xsand_sandstone_4, 4,
3438 Xsand_sandstone_4, 5,
3439 Xsand_sandstone_4, 6,
3440 Xsand_sandstone_4, 7,
4269 SPR_walk + 0, 0, 0, 1, 2, 3, 4, 5, 6, 7,
4270 SPR_walk + 1, 0, 8, 9, 10, 11, 12, 13, 14, 15,
4271 SPR_walk + 2, 0, 16, 17, 18, 19, 20, 21, 22, 23,
4272 SPR_walk + 3, 0, 24, 25, 26, 27, 28, 29, 30, 31,
4273 SPR_push+0, 0, 32, 33, 34, 35, 36, 35, 34, 33,
4274 SPR_push+1, 0, 37, 38, 39, 40, 41, 40, 39, 38,
4275 SPR_push+2, 0, 42, 43, 44, 45, 46, 45, 44, 43,
4276 SPR_push+3, 0, 47, 48, 49, 50, 51, 50, 49, 48,
4277 SPR_spray+0, 0, 52, 52, 52, 52, 52, 52, 52, 52,
4278 SPR_spray+1, 0, 53, 53, 53, 53, 53, 53, 53, 53,
4279 SPR_spray+2, 0, 54, 54, 54, 54, 54, 54, 54, 54,
4280 SPR_spray+3, 0, 55, 55, 55, 55, 55, 55, 55, 55,
4281 SPR_walk + 0, 1, 56, 57, 58, 59, 60, 61, 62, 63,
4282 SPR_walk + 1, 1, 64, 65, 66, 67, 68, 69, 70, 71,
4283 SPR_walk + 2, 1, 72, 73, 74, 75, 76, 77, 78, 79,
4284 SPR_walk + 3, 1, 80, 81, 82, 83, 84, 85, 86, 87,
4285 SPR_push + 0, 1, 88, 89, 90, 91, 92, 91, 90, 89,
4286 SPR_push + 1, 1, 93, 94, 95, 96, 97, 96, 95, 94,
4287 SPR_push + 2, 1, 98, 99, 100, 101, 102, 101, 100, 99,
4288 SPR_push + 3, 1, 103, 104, 105, 106, 107, 106, 105, 104,
4289 SPR_spray + 0, 1, 108, 108, 108, 108, 108, 108, 108, 108,
4290 SPR_spray + 1, 1, 109, 109, 109, 109, 109, 109, 109, 109,
4291 SPR_spray + 2, 1, 110, 110, 110, 110, 110, 110, 110, 110,
4292 SPR_spray + 3, 1, 111, 111, 111, 111, 111, 111, 111, 111,
4293 SPR_still, 0, 112, 112, 112, 112, 112, 112, 112, 112,
4294 SPR_still, 1, 113, 113, 113, 113, 113, 113, 113, 113,
4299 /* 0=stop 1=blank */
4300 unsigned char tab_blank[TILE_MAX];
4303 unsigned char tab_acid[TILE_MAX];
4305 /* 0=stop 1=amoeba */
4306 unsigned char tab_amoeba[TILE_MAX];
4309 unsigned char tab_android_move[TILE_MAX];
4311 /* normal explosion */
4312 unsigned short tab_explode_normal[TILE_MAX];
4314 /* dynamite explosion */
4315 unsigned short tab_explode_dynamite[TILE_MAX];
4317 /* map tiles to coords */
4318 unsigned short map_obj[8][TILE_MAX];
4320 /* map sprites to coords */
4321 unsigned short map_spr[2][8][13];
4323 /* map ascii to coords */
4324 unsigned short map_ttl[128];
4326 /* map tiles and frames to graphics info */
4327 struct GraphicInfo_EM graphic_info_em[TILE_MAX][8];
4329 void create_tab(int *invert, unsigned char *array)
4332 int buffer[TILE_MAX];
4334 for (i = 0; i < TILE_MAX; i++)
4337 for (;invert[0] < TILE_MAX; invert += 2)
4338 buffer[invert[0]] = invert[1];
4340 for (i = 0; i < TILE_MAX; i++)
4341 array[i] = buffer[i];
4344 void create_explode()
4347 int *tile = tile_explode;
4348 int buffer[TILE_MAX];
4350 for (i = 0; i < TILE_MAX; i++)
4351 buffer[i] = Xboom_1;
4352 while ((i = *tile++) < TILE_MAX)
4353 buffer[i] = i; /* these tiles are indestructable */
4354 while ((i = *tile++) < TILE_MAX)
4355 buffer[i] = *tile++; /* these tiles are special */
4357 for (i = 0; i < TILE_MAX; i++)
4358 tab_explode_normal[i] = buffer[i];
4360 while ((i = *tile++) < TILE_MAX)
4361 buffer[i] = *tile++; /* these tiles for dynamite */
4363 for (i = 0; i < TILE_MAX; i++)
4364 tab_explode_dynamite[i] = buffer[i];
4371 int buffer[8][TILE_MAX];
4377 for (i = 0; i < 8; i++)
4378 for (j = 0; j < TILE_MAX; j++)
4381 for (i = 0; i < 64; i++)
4383 for (;*map != -1; map += 2)
4385 if (map[0] < 0 || map[0] >= TILE_MAX || map[1] < 0 || map[1] >= 8)
4387 fprintf(stderr, "obj_map: bad tile (%d, %d) @ %d+%d\n",
4388 map[0], map[1], i / 16, i % 16);
4392 buffer[map[1]][map[0]]++;
4397 for (i = 0; i < 896; i++)
4399 for (;*map != -1; map += 2)
4401 if (map[0] < 0 || map[0] >= TILE_MAX || map[1] < 0 || map[1] >= 8)
4403 fprintf(stderr, "obj_map: bad tile (%d, %d) @ %d\n", map[0], map[1], i);
4407 buffer[map[1]][map[0]]++;
4412 for (i = 0; i < TILE_MAX; i++)
4414 for (j = 0; j < 8; j++)
4416 switch(buffer[j][i])
4419 fprintf(stderr, "obj_map: uninitialized (%d, %d)\n", i, j);
4425 fprintf(stderr, "obj_map: duplicate (%d, %d)\n", i, j);
4432 if (sizeof(obj_map) / sizeof(*obj_map) != map - obj_map)
4434 fprintf(stderr, "obj_map: bad end (%d != %d)\n",
4435 sizeof(obj_map) / sizeof(*obj_map), map - obj_map);
4440 fprintf(stderr, "obj_map: looks good, now disable debug code\n");
4446 for (i = 0; i < 8; i++)
4447 for (j = 0; j < TILE_MAX; j++)
4448 buffer[i][j] = Xblank;
4450 /* special case for first 64 entries */
4451 for (i = 0; i < 64; i++)
4453 for (;*map != -1; map += 2)
4454 buffer[map[1]][map[0]] = i;
4458 /* now regular entries */
4459 for (i = 0; i < 896 * 16; i += 16)
4461 for (;*map != -1; map += 2)
4462 buffer[map[1]][map[0]] = i;
4466 for (i = 0; i < 8; i++)
4467 for (j = 0; j < TILE_MAX; j++)
4468 map_obj[i][j] = buffer[7 - i][j];
4473 void create_obj_graphics_info_em()
4477 for (i = 0; i < TILE_MAX; i++)
4479 for (j = 0; j < 8; j++)
4481 struct GraphicInfo_EM *g = &graphic_info_em[i][j];
4482 int obj = map_obj[j][i];
4484 g->bitmap = objBitmap;
4485 g->src_x = (obj / 512) * TILEX;
4486 g->src_y = (obj % 512) * TILEY / 16;
4487 g->src_offset_x = 0;
4488 g->src_offset_y = 0;
4489 g->dst_offset_x = 0;
4490 g->dst_offset_y = 0;
4496 InitGraphicInfo_EM();
4503 int buffer[2][8][SPR_MAX];
4505 while (*map < SPR_MAX)
4509 for (k = 0; k < 8; k++)
4510 buffer[j][k][i] = *map++;
4513 for (i = 0; i < 2; i++)
4514 for (j = 0; j < 8; j++)
4515 for (k = 0; k < SPR_MAX; k++)
4516 map_spr[i][j][k] = buffer[i][7 - j][k];
4521 create_tab(tile_blank, tab_blank);
4522 create_tab(tile_acid, tab_acid);
4523 create_tab(tile_amoeba, tab_amoeba);
4524 create_tab(tile_android_move, tab_android_move);
4530 void tab_generate_graphics_info_em()
4532 create_obj_graphics_info_em();