2 #if defined(TARGET_X11)
4 /* 2000-04-19T13:26:05Z
6 * construct some tables to be included directly in emerald mine source.
7 * i made this because dynamically building the tables every time sucks and i
8 * need to be able to easily modify tile.h.
10 * this is key data which almost everything depends on.
12 * this is supposed to be fairly easy to read and modify. the tab values
13 * are still hard coded constants but that should be less of a problem to
20 /* ---------------------------------------------------------------------- */
59 int tile_android_move[] = {
67 /* ---------------------------------------------------------------------- */
69 /* explosions: special format */
70 /* everything is initially filled with Xboom_1 */
71 int tile_explode[] = {
122 TILE_MAX, /* up till here are indestructable */
132 Xbomb_pause, Xboom_bomb,
133 Xbomb_fall, Xboom_bomb,
134 TILE_MAX, /* up till here are special explosions */
135 Xandroid, Xboom_android,
136 Xandroid_1_n, Xboom_android,
137 Xandroid_2_n, Xboom_android,
138 Xandroid_1_e, Xboom_android,
139 Xandroid_2_e, Xboom_android,
140 Xandroid_1_s, Xboom_android,
141 Xandroid_2_s, Xboom_android,
142 Xandroid_1_w, Xboom_android,
143 Xandroid_2_w, Xboom_android,
144 TILE_MAX /* up until here are dynamite explosions */
147 /* ---------------------------------------------------------------------- */
149 /* map the graphics file to internal tiles and animations
151 * one graphics icon maps to many tiles and animations
1903 Xemerald_force_e,0 ,
1904 Xemerald_force_e,1 ,
1905 Xemerald_force_e,2 ,
1906 Xemerald_force_e,3 ,
1907 Xemerald_force_e,4 ,
1908 Xemerald_force_e,5 ,
1909 Xemerald_force_e,6 ,
1910 Xemerald_force_e,7 ,
1911 Xemerald_force_w,0 ,
1912 Xemerald_force_w,1 ,
1913 Xemerald_force_w,2 ,
1914 Xemerald_force_w,3 ,
1915 Xemerald_force_w,4 ,
1916 Xemerald_force_w,5 ,
1917 Xemerald_force_w,6 ,
1918 Xemerald_force_w,7 ,
2060 Xdiamond_force_e,0 ,
2061 Xdiamond_force_e,1 ,
2062 Xdiamond_force_e,2 ,
2063 Xdiamond_force_e,3 ,
2064 Xdiamond_force_e,4 ,
2065 Xdiamond_force_e,5 ,
2066 Xdiamond_force_e,6 ,
2067 Xdiamond_force_e,7 ,
2068 Xdiamond_force_w,0 ,
2069 Xdiamond_force_w,1 ,
2070 Xdiamond_force_w,2 ,
2071 Xdiamond_force_w,3 ,
2072 Xdiamond_force_w,4 ,
2073 Xdiamond_force_w,5 ,
2074 Xdiamond_force_w,6 ,
2075 Xdiamond_force_w,7 ,
3357 Xsand_stonesand_1,0 ,
3358 Xsand_stonesand_1,1 ,
3359 Xsand_stonesand_1,2 ,
3360 Xsand_stonesand_1,3 ,
3361 Xsand_stonesand_1,4 ,
3362 Xsand_stonesand_1,5 ,
3363 Xsand_stonesand_1,6 ,
3364 Xsand_stonesand_1,7 ,
3365 Xsand_stonesand_2,0 ,
3366 Xsand_stonesand_2,1 ,
3367 Xsand_stonesand_2,2 ,
3368 Xsand_stonesand_2,3 ,
3369 Xsand_stonesand_2,4 ,
3370 Xsand_stonesand_2,5 ,
3371 Xsand_stonesand_2,6 ,
3372 Xsand_stonesand_2,7 ,
3373 Xsand_stonesand_3,0 ,
3374 Xsand_stonesand_3,1 ,
3375 Xsand_stonesand_3,2 ,
3376 Xsand_stonesand_3,3 ,
3377 Xsand_stonesand_3,4 ,
3378 Xsand_stonesand_3,5 ,
3379 Xsand_stonesand_3,6 ,
3380 Xsand_stonesand_3,7 ,
3381 Xsand_stonesand_4,0 ,
3382 Xsand_stonesand_4,1 ,
3383 Xsand_stonesand_4,2 ,
3384 Xsand_stonesand_4,3 ,
3385 Xsand_stonesand_4,4 ,
3386 Xsand_stonesand_4,5 ,
3387 Xsand_stonesand_4,6 ,
3388 Xsand_stonesand_4,7 ,
3389 Xsand_sandstone_1,0 ,
3390 Xsand_sandstone_1,1 ,
3391 Xsand_sandstone_1,2 ,
3392 Xsand_sandstone_1,3 ,
3393 Xsand_sandstone_1,4 ,
3394 Xsand_sandstone_1,5 ,
3395 Xsand_sandstone_1,6 ,
3396 Xsand_sandstone_1,7 ,
3397 Xsand_sandstone_2,0 ,
3398 Xsand_sandstone_2,1 ,
3399 Xsand_sandstone_2,2 ,
3400 Xsand_sandstone_2,3 ,
3401 Xsand_sandstone_2,4 ,
3402 Xsand_sandstone_2,5 ,
3403 Xsand_sandstone_2,6 ,
3404 Xsand_sandstone_2,7 ,
3405 Xsand_sandstone_3,0 ,
3406 Xsand_sandstone_3,1 ,
3407 Xsand_sandstone_3,2 ,
3408 Xsand_sandstone_3,3 ,
3409 Xsand_sandstone_3,4 ,
3410 Xsand_sandstone_3,5 ,
3411 Xsand_sandstone_3,6 ,
3412 Xsand_sandstone_3,7 ,
3413 Xsand_sandstone_4,0 ,
3414 Xsand_sandstone_4,1 ,
3415 Xsand_sandstone_4,2 ,
3416 Xsand_sandstone_4,3 ,
3417 Xsand_sandstone_4,4 ,
3418 Xsand_sandstone_4,5 ,
3419 Xsand_sandstone_4,6 ,
3420 Xsand_sandstone_4,7 ,
4248 SPR_walk+0,0, 0,1,2,3,4,5,6,7,
4249 SPR_walk+1,0, 8,9,10,11,12,13,14,15,
4250 SPR_walk+2,0, 16,17,18,19,20,21,22,23,
4251 SPR_walk+3,0, 24,25,26,27,28,29,30,31,
4252 SPR_push+0,0, 32,33,34,35,36,35,34,33,
4253 SPR_push+1,0, 37,38,39,40,41,40,39,38,
4254 SPR_push+2,0, 42,43,44,45,46,45,44,43,
4255 SPR_push+3,0, 47,48,49,50,51,50,49,48,
4256 SPR_spray+0,0, 52,52,52,52,52,52,52,52,
4257 SPR_spray+1,0, 53,53,53,53,53,53,53,53,
4258 SPR_spray+2,0, 54,54,54,54,54,54,54,54,
4259 SPR_spray+3,0, 55,55,55,55,55,55,55,55,
4260 SPR_walk+0,1, 56,57,58,59,60,61,62,63,
4261 SPR_walk+1,1, 64,65,66,67,68,69,70,71,
4262 SPR_walk+2,1, 72,73,74,75,76,77,78,79,
4263 SPR_walk+3,1, 80,81,82,83,84,85,86,87,
4264 SPR_push+0,1, 88,89,90,91,92,91,90,89,
4265 SPR_push+1,1, 93,94,95,96,97,96,95,94,
4266 SPR_push+2,1, 98,99,100,101,102,101,100,99,
4267 SPR_push+3,1, 103,104,105,106,107,106,105,104,
4268 SPR_spray+0,1, 108,108,108,108,108,108,108,108,
4269 SPR_spray+1,1, 109,109,109,109,109,109,109,109,
4270 SPR_spray+2,1, 110,110,110,110,110,110,110,110,
4271 SPR_spray+3,1, 111,111,111,111,111,111,111,111,
4272 SPR_still,0, 112,112,112,112,112,112,112,112,
4273 SPR_still,1, 113,113,113,113,113,113,113,113,
4278 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
4279 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
4280 -1,0,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,2,3,4,-1, /* !',-. */
4281 5,6,7,8,9,10,11,12,13,14,15,-1,-1,-1,-1,16, /* 0123456789:? */
4282 -1,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, /* ABCDEFGHIJKLMNO */
4283 32,33,34,35,36,37,38,39,40,41,42,-1,-1,-1,-1,-1, /* PQRSTUVWXYZ */
4284 -1,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, /* abcdefghijklmno */
4285 32,33,34,35,36,37,38,39,40,41,42,-1,-1,-1,-1,-1 /* pqrstuvwxyz */
4288 /* ---------------------------------------------------------------------- */
4292 /* quick and dirty code to format the data semi nicely */
4294 void print_buffer(int *buffer, int count)
4298 for(i = 0; i < count;) {
4299 if(j > 80) { j=0; printf("\n"); }
4300 if(j == 0) printf("\t");
4301 j += printf("%d", buffer[i]);
4302 j += printf("%s", ++i == count ? "" : ",");
4306 void print_tab(int *invert, char *varname, char *comment)
4309 int buffer[TILE_MAX];
4311 for(i = 0; i < TILE_MAX; i++) buffer[i] = 0;
4312 for(;invert[0] < TILE_MAX; invert += 2) buffer[invert[0]] = invert[1];
4314 printf("/* %s */\n", comment);
4315 printf("const unsigned char %s[%d] = {\n", varname, TILE_MAX);
4316 print_buffer(buffer, TILE_MAX);
4319 void print_explode(void)
4322 int *tile = tile_explode;
4323 int buffer[TILE_MAX];
4325 for(i = 0; i < TILE_MAX; i++) buffer[i] = Xboom_1;
4326 while((i = *tile++) < TILE_MAX) buffer[i] = i; /* these tiles are indestructable */
4327 while((i = *tile++) < TILE_MAX) buffer[i] = *tile++; /* these tiles are special */
4329 printf("/* normal explosion */\n");
4330 printf("const unsigned short tab_explode_normal[%d] = {\n", TILE_MAX);
4331 print_buffer(buffer, TILE_MAX);
4334 while((i = *tile++) < TILE_MAX) buffer[i] = *tile++; /* these tiles for dynamite */
4336 printf("/* dynamite explosion */\n");
4337 printf("const unsigned short tab_explode_dynamite[%d] = {\n", TILE_MAX);
4338 print_buffer(buffer, TILE_MAX);
4341 void print_obj(void)
4345 int buffer[8][TILE_MAX];
4349 for(i = 0; i < 8; i++) for(j = 0; j < TILE_MAX; j++) buffer[i][j] = 0;
4350 for(i = 0; i < 64; i++) {
4351 for(;*map != -1; map += 2) {
4352 if(map[0] < 0 || map[0] >= TILE_MAX || map[1] < 0 || map[1] >= 8) { fprintf(stderr, "obj_map: bad tile (%d,%d) @ %d+%d\n", map[0], map[1], i / 16, i % 16); debug = 1; continue; }
4353 buffer[map[1]][map[0]]++;
4357 for(i = 0; i < 896; i++) {
4358 for(;*map != -1; map += 2) {
4359 if(map[0] < 0 || map[0] >= TILE_MAX || map[1] < 0 || map[1] >= 8) { fprintf(stderr, "obj_map: bad tile (%d,%d) @ %d\n", map[0], map[1], i); debug = 1; continue; }
4360 buffer[map[1]][map[0]]++;
4364 for(i = 0; i < TILE_MAX; i++) for(j = 0; j < 8; j++) {
4365 switch(buffer[j][i]) {
4366 case 0: fprintf(stderr, "obj_map: uninitialized (%d,%d)\n", i, j); debug = 1; break;
4367 case 1: break; /* good */
4368 default: fprintf(stderr, "obj_map: duplicate (%d,%d)\n", i, j); debug = 1; break;
4371 if(sizeof(obj_map) / sizeof(*obj_map) != map - obj_map) { fprintf(stderr, "obj_map: bad end (%d != %d)\n", sizeof(obj_map) / sizeof(*obj_map), map - obj_map); debug = 1; }
4372 if(debug == 0) fprintf(stderr, "obj_map: looks good, now disable debug code\n");
4376 for(i = 0; i < 8; i++) for(j = 0; j < TILE_MAX; j++) buffer[i][j] = Xblank;
4378 /* special case for first 64 entries */
4379 for(i = 0; i < 64; i++) {
4380 for(;*map != -1; map += 2) buffer[map[1]][map[0]] = i;
4384 /* now regular entries */
4385 for(i = 0; i < 896 * 16; i += 16) {
4386 for(;*map != -1; map += 2) buffer[map[1]][map[0]] = i;
4390 printf("/* map tiles to coords */\n");
4391 printf("const unsigned short map_obj[8][%d] = {\n", TILE_MAX);
4392 for(i = 0; i < 8;) {
4394 print_buffer(buffer[7 - i], TILE_MAX);
4395 printf("}%s", ++i == 8 ? "\n" : ",");
4400 void print_spr(void)
4404 int buffer[2][8][SPR_MAX];
4406 while(*map < SPR_MAX) {
4409 for(k = 0; k < 8; k++) buffer[j][k][i] = *map++;
4412 printf("/* map sprites to coords */\n");
4413 printf("const unsigned short map_spr[2][8][%d] = {\n", SPR_MAX);
4414 for(i = 0; i < 2;) {
4416 for(j = 0; j < 8;) {
4418 for(k = 0; k < SPR_MAX;) {
4419 printf("%d", buffer[i][7 - j][k]);
4420 printf("%s", ++k == SPR_MAX ? "" : ",");
4422 printf(" }%s\n", ++j == 8 ? "" : ",");
4424 printf("}%s", ++i == 2 ? "\n" : ",");
4428 void print_ttl(void)
4433 for(i = 0; i < 128; i++) {
4434 if(ttl_map[i] == -1) {
4437 j = (ttl_map[i] % 22) * 14;
4438 k = (ttl_map[i] / 22);
4439 buffer[i] = k * 320 + j;
4442 printf("/* map ascii to coords */\n");
4443 printf("const unsigned short map_ttl[128] = {\n");
4444 print_buffer(buffer, 128);
4449 printf("/* THIS FILE AUTOMATICALLY GENERATED */\n\n");
4450 print_tab(tile_blank, "tab_blank", "0=stop 1=blank");
4451 print_tab(tile_acid, "tab_acid", "0=stop 1=acid");
4452 print_tab(tile_ameuba, "tab_ameuba", "0=stop 1=ameuba");
4453 print_tab(tile_android_move, "tab_android_move", "0=stop 1=move");
4463 /* ------------------------------------------------------------------------- */
4465 /* 0=stop 1=blank */
4466 unsigned char tab_blank[TILE_MAX];
4469 unsigned char tab_acid[TILE_MAX];
4471 /* 0=stop 1=ameuba */
4472 unsigned char tab_ameuba[TILE_MAX];
4475 unsigned char tab_android_move[TILE_MAX];
4477 /* normal explosion */
4478 unsigned short tab_explode_normal[TILE_MAX];
4480 /* dynamite explosion */
4481 unsigned short tab_explode_dynamite[TILE_MAX];
4483 /* map tiles to coords */
4484 unsigned short map_obj[8][TILE_MAX];
4486 /* map sprites to coords */
4487 unsigned short map_spr[2][8][13];
4489 /* map ascii to coords */
4490 unsigned short map_ttl[128];
4492 void create_tab(int *invert, unsigned char *array)
4495 int buffer[TILE_MAX];
4497 for(i = 0; i < TILE_MAX; i++)
4500 for(;invert[0] < TILE_MAX; invert += 2)
4501 buffer[invert[0]] = invert[1];
4503 for(i = 0; i < TILE_MAX; i++)
4504 array[i] = buffer[i];
4507 void create_explode()
4510 int *tile = tile_explode;
4511 int buffer[TILE_MAX];
4513 for(i = 0; i < TILE_MAX; i++)
4514 buffer[i] = Xboom_1;
4515 while((i = *tile++) < TILE_MAX)
4516 buffer[i] = i; /* these tiles are indestructable */
4517 while((i = *tile++) < TILE_MAX)
4518 buffer[i] = *tile++; /* these tiles are special */
4520 for(i = 0; i < TILE_MAX; i++)
4521 tab_explode_normal[i] = buffer[i];
4523 while((i = *tile++) < TILE_MAX)
4524 buffer[i] = *tile++; /* these tiles for dynamite */
4526 for(i = 0; i < TILE_MAX; i++)
4527 tab_explode_dynamite[i] = buffer[i];
4534 int buffer[8][TILE_MAX];
4539 for(i = 0; i < 8; i++)
4540 for(j = 0; j < TILE_MAX; j++)
4542 for(i = 0; i < 64; i++)
4544 for(;*map != -1; map += 2)
4546 if (map[0] < 0 || map[0] >= TILE_MAX || map[1] < 0 || map[1] >= 8)
4548 fprintf(stderr, "obj_map: bad tile (%d,%d) @ %d+%d\n",
4549 map[0], map[1], i / 16, i % 16);
4553 buffer[map[1]][map[0]]++;
4557 for(i = 0; i < 896; i++)
4559 for(;*map != -1; map += 2)
4561 if (map[0] < 0 || map[0] >= TILE_MAX || map[1] < 0 || map[1] >= 8)
4563 fprintf(stderr, "obj_map: bad tile (%d,%d) @ %d\n", map[0], map[1], i);
4567 buffer[map[1]][map[0]]++;
4571 for(i = 0; i < TILE_MAX; i++)
4573 for(j = 0; j < 8; j++)
4575 switch(buffer[j][i])
4578 fprintf(stderr, "obj_map: uninitialized (%d,%d)\n", i, j);
4584 fprintf(stderr, "obj_map: duplicate (%d,%d)\n", i, j);
4591 if(sizeof(obj_map) / sizeof(*obj_map) != map - obj_map)
4593 fprintf(stderr, "obj_map: bad end (%d != %d)\n",
4594 sizeof(obj_map) / sizeof(*obj_map), map - obj_map);
4598 fprintf(stderr, "obj_map: looks good, now disable debug code\n");
4603 for(i = 0; i < 8; i++)
4604 for(j = 0; j < TILE_MAX; j++)
4605 buffer[i][j] = Xblank;
4607 /* special case for first 64 entries */
4608 for(i = 0; i < 64; i++)
4610 for(;*map != -1; map += 2)
4611 buffer[map[1]][map[0]] = i;
4615 /* now regular entries */
4616 for(i = 0; i < 896 * 16; i += 16)
4618 for(;*map != -1; map += 2)
4619 buffer[map[1]][map[0]] = i;
4623 for(i = 0; i < 8; i++)
4624 for(j = 0; j < TILE_MAX; j++)
4625 map_obj[i][j] = buffer[7 - i][j];
4634 int buffer[2][8][SPR_MAX];
4636 while(*map < SPR_MAX)
4640 for(k = 0; k < 8; k++)
4641 buffer[j][k][i] = *map++;
4644 for(i = 0; i < 2; i++)
4645 for(j = 0; j < 8; j++)
4646 for(k = 0; k < SPR_MAX; k++)
4647 map_spr[i][j][k] = buffer[i][7 - j][k];
4655 for(i = 0; i < 128; i++)
4657 if(ttl_map[i] == -1)
4663 j = (ttl_map[i] % 22) * 14;
4664 k = (ttl_map[i] / 22);
4665 buffer[i] = k * 320 + j;
4669 for (i = 0; i < 128; i++)
4670 map_ttl[i] = buffer[i];
4675 create_tab(tile_blank, tab_blank);
4676 create_tab(tile_acid, tab_acid);
4677 create_tab(tile_ameuba, tab_ameuba);
4678 create_tab(tile_android_move, tab_android_move);