removed unused graphics initializations from EM engine
[rocksndiamonds.git] / src / game_em / tab_generate.c
1 /* 2000-04-19T13:26:05Z
2  *
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 definitions.
6  *
7  * this is key data which almost everything depends on.
8  *
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
11  * modify.
12  */
13
14 #include "main_em.h"
15
16
17 /* ------------------------------------------------------------------------- */
18
19 /* 0=stop 1=blank */
20 int tile_blank[] =
21 {
22   Xblank, 1,
23   Xsplash_e, 1,
24   Xsplash_w, 1,
25   Xfake_acid_1, 1,
26   Xfake_acid_2, 1,
27   Xfake_acid_3, 1,
28   Xfake_acid_4, 1,
29   Xfake_acid_5, 1,
30   Xfake_acid_6, 1,
31   Xfake_acid_7, 1,
32   Xfake_acid_8, 1,
33   TILE_MAX
34 };
35
36 /* 0=stop 1=acid */
37 int tile_acid[] =
38 {
39   Xblank, 1,
40   Xsplash_e, 1,
41   Xsplash_w, 1,
42   Xfake_acid_1, 1,
43   Xfake_acid_2, 1,
44   Xfake_acid_3, 1,
45   Xfake_acid_4, 1,
46   Xfake_acid_5, 1,
47   Xfake_acid_6, 1,
48   Xfake_acid_7, 1,
49   Xfake_acid_8, 1,
50   Xacid_1, 1,
51   Xacid_2, 1,
52   Xacid_3, 1,
53   Xacid_4, 1,
54   Xacid_5, 1,
55   Xacid_6, 1,
56   Xacid_7, 1,
57   Xacid_8, 1,
58   TILE_MAX
59 };
60
61 /* 0=stop 1=fake_acid */
62 int tile_fake_acid[] =
63 {
64   Xfake_acid_1, 1,
65   Xfake_acid_2, 1,
66   Xfake_acid_3, 1,
67   Xfake_acid_4, 1,
68   Xfake_acid_5, 1,
69   Xfake_acid_6, 1,
70   Xfake_acid_7, 1,
71   Xfake_acid_8, 1,
72   TILE_MAX
73 };
74
75 /* 0=stop 1=amoeba */
76 int tile_amoeba[] =
77 {
78   Xfake_amoeba, 1,
79   Xfake_amoebaB, 1,
80   Xamoeba_1, 1,
81   Xamoeba_2, 1,
82   Xamoeba_3, 1,
83   Xamoeba_4, 1,
84   Xamoeba_5, 1,
85   Xamoeba_6, 1,
86   Xamoeba_7, 1,
87   Xamoeba_8, 1,
88   TILE_MAX
89 };
90
91 /* 0=stop 1=move */
92 int tile_android_move[] =
93 {
94   Xblank, 1,
95   Xsplash_e, 1,
96   Xsplash_w, 1,
97   Xfake_acid_1, 1,
98   Xfake_acid_2, 1,
99   Xfake_acid_3, 1,
100   Xfake_acid_4, 1,
101   Xfake_acid_5, 1,
102   Xfake_acid_6, 1,
103   Xfake_acid_7, 1,
104   Xfake_acid_8, 1,
105   Xplant, 1,
106   TILE_MAX
107 };
108
109
110 /* ------------------------------------------------------------------------- */
111
112 /* explosions: special format */
113 /* everything is initially filled with Xboom_1 */
114 int tile_explode[] =
115 {
116   Zborder,
117   Znormal,
118   Zdynamite,
119   Xboom_bug,
120   Xboom_bomb,
121   Xboom_android,
122   Xandroid,
123   Xandroid_1_n,
124   Xandroid_2_n,
125   Xandroid_1_e,
126   Xandroid_2_e,
127   Xandroid_1_s,
128   Xandroid_2_s,
129   Xandroid_1_w,
130   Xandroid_2_w,
131   Xacid_ne,
132   Xacid_nw,
133   Xacid_s,
134   Xacid_se,
135   Xacid_sw,
136   Xacid_1,
137   Xacid_2,
138   Xacid_3,
139   Xacid_4,
140   Xacid_5,
141   Xacid_6,
142   Xacid_7,
143   Xacid_8,
144   Xdoor_1,
145   Xdoor_2,
146   Xdoor_3,
147   Xdoor_4,
148   Xdoor_5,
149   Xdoor_6,
150   Xdoor_7,
151   Xdoor_8,
152   Xplant,
153   Yplant,
154   Xfake_door_1,
155   Xfake_door_2,
156   Xfake_door_3,
157   Xfake_door_4,
158   Xfake_door_5,
159   Xfake_door_6,
160   Xfake_door_7,
161   Xfake_door_8,
162   Xsteel_1,
163   Xsteel_2,
164   Xsteel_3,
165   Xsteel_4,
166   TILE_MAX,                     /* up till here are indestructable */
167
168   Xbug_1_n, Xboom_bug,
169   Xbug_1_e, Xboom_bug,
170   Xbug_1_s, Xboom_bug,
171   Xbug_1_w, Xboom_bug,
172   Xbug_2_n, Xboom_bug,
173   Xbug_2_e, Xboom_bug,
174   Xbug_2_s, Xboom_bug,
175   Xbug_2_w, Xboom_bug,
176   Xbomb, Xboom_bomb,
177   Xbomb_pause, Xboom_bomb,
178   Xbomb_fall, Xboom_bomb,
179   TILE_MAX,                     /* up till here are special explosions */
180
181   Xandroid, Xboom_android,
182   Xandroid_1_n, Xboom_android,
183   Xandroid_2_n, Xboom_android,
184   Xandroid_1_e, Xboom_android,
185   Xandroid_2_e, Xboom_android,
186   Xandroid_1_s, Xboom_android,
187   Xandroid_2_s, Xboom_android,
188   Xandroid_1_w, Xboom_android,
189   Xandroid_2_w, Xboom_android,
190   TILE_MAX                      /* up until here are dynamite explosions */
191 };
192
193
194 /* ------------------------------------------------------------------------- */
195
196
197 /* 0=stop 1=blank */
198 unsigned char tab_blank[TILE_MAX];
199
200 /* 0=stop 1=acid */
201 unsigned char tab_acid[TILE_MAX];
202
203 /* 0=stop 1=fake_acid */
204 unsigned char tab_fake_acid[TILE_MAX];
205
206 /* 0=stop 1=amoeba */
207 unsigned char tab_amoeba[TILE_MAX];
208
209 /* 0=stop 1=move */
210 unsigned char tab_android_move[TILE_MAX];
211
212 /* normal explosion */
213 unsigned short tab_explode_normal[TILE_MAX];
214
215 /* dynamite explosion */
216 unsigned short tab_explode_dynamite[TILE_MAX];
217
218 /* map tiles and frames to graphic info */
219 struct GraphicInfo_EM graphic_info_em_object[TILE_MAX][8];
220
221 /* map player number, frames and action to graphic info */
222 struct GraphicInfo_EM graphic_info_em_player[MAX_PLAYERS][PLY_MAX][8];
223
224 static void create_tab(int *invert, unsigned char *array)
225 {
226   int i;
227   int buffer[TILE_MAX];
228
229   for (i = 0; i < TILE_MAX; i++)
230     buffer[i] = 0;
231
232   for (;invert[0] < TILE_MAX; invert += 2)
233     buffer[invert[0]] = invert[1];
234
235   for (i = 0; i < TILE_MAX; i++)
236     array[i] = buffer[i];
237 }
238
239 static void create_explode(void)
240 {
241   int i;
242   int *tile = tile_explode;
243   int buffer[TILE_MAX];
244
245   for (i = 0; i < TILE_MAX; i++)
246     buffer[i] = Xboom_1;
247   while ((i = *tile++) < TILE_MAX)
248     buffer[i] = i;                      /* these tiles are indestructable */
249   while ((i = *tile++) < TILE_MAX)
250     buffer[i] = *tile++;                /* these tiles are special */
251
252   for (i = 0; i < TILE_MAX; i++)
253     tab_explode_normal[i] = buffer[i];
254
255   while ((i = *tile++) < TILE_MAX)
256     buffer[i] = *tile++;                /* these tiles for dynamite */
257
258   for (i = 0; i < TILE_MAX; i++)
259     tab_explode_dynamite[i] = buffer[i];
260 }
261
262 void tab_generate(void)
263 {
264   create_tab(tile_blank, tab_blank);
265   create_tab(tile_acid, tab_acid);
266   create_tab(tile_fake_acid, tab_fake_acid);
267   create_tab(tile_amoeba, tab_amoeba);
268   create_tab(tile_android_move, tab_android_move);
269   create_explode();
270 }
271
272 void tab_generate_graphics_info_em(void)
273 {
274   InitGraphicInfo_EM();
275 }