1 /*
2 ########################################
3 #### WILL MOVE IN THE GFX DLL/SO
4 ########################################
5 */
6
7 #include "trans_fx.h"
8
9 const char nb_fadein = 5;
10 const char nb_fadeout = 5;
11 // used to know how many functions do we have
12
13
14 #ifdef ALLEGRO
15
16 void special_fadein1 (BITMAP * to, unsigned xto, unsigned yto, unsigned xmax,
17 unsigned ymax);
18 void special_fadein2 (BITMAP * to, unsigned xto, unsigned yto, unsigned xmax,
19 unsigned ymax);
20 void special_fadein3 (BITMAP * to, unsigned xto, unsigned yto, unsigned xmax,
21 unsigned ymax);
22 void special_fadein4 (BITMAP * to, unsigned xto, unsigned yto, unsigned xmax,
23 unsigned ymax);
24 void special_fadein5 (BITMAP * to, unsigned xto, unsigned yto, unsigned xmax,
25 unsigned ymax);
26 // forward declaration for initialising the following tab
27
28 void (*fade_in_proc[5]) (BITMAP *, unsigned, unsigned, unsigned, unsigned) =
29 {
30 special_fadein1,
31 special_fadein2, special_fadein3, special_fadein4, special_fadein5};
32
33 #else
34
35 void (*fade_in_proc[5]) (UChar *, unsigned, unsigned, unsigned, unsigned) =
36 {};
37
38 #endif
39
40 // Array of function for random calls
41
42 #if defined(ALLEGRO)
43
44 void special_fadeout1 (unsigned xto, unsigned yto, unsigned xmax,
45 unsigned ymax);
46 void special_fadeout2 (unsigned xto, unsigned yto, unsigned xmax,
47 unsigned ymax);
48 void special_fadeout3 (unsigned xto, unsigned yto, unsigned xmax,
49 unsigned ymax);
50 void special_fadeout4 (unsigned xto, unsigned yto, unsigned xmax,
51 unsigned ymax);
52 void special_fadeout5 (unsigned xto, unsigned yto, unsigned xmax,
53 unsigned ymax);
54 // forward declaration for initialising the following tab
55
56 void (*fade_out_proc[5]) (unsigned, unsigned, unsigned, unsigned) =
57 {
58 special_fadeout1,
59 special_fadeout2, special_fadeout3, special_fadeout4, special_fadeout5};
60
61 // Array of function for random calls
62
63 #else
64
65 void (*fade_out_proc[5]) (unsigned, unsigned, unsigned, unsigned) =
66 {};
67
68
69 #endif
70
71
72 #ifdef ALLEGRO
73
74
75 /*****************************************************************************
76
77 Function: special_fadein1
78
79 Description: fade in with spiral effect
80 Parameters: the BITMAP to fade to,
81 xto,yto,xmax,ymax used like in blit
82 used like "blit(to,screen,0,0,xto,yto,xmax,ymax)"
83 Return:nothing
84
85 *****************************************************************************/
86 void
special_fadein1(BITMAP * to,unsigned xto,unsigned yto,unsigned xmax,unsigned ymax)87 special_fadein1 (BITMAP * to, unsigned xto, unsigned yto, unsigned xmax,
88 unsigned ymax)
89 {
90 static char xinit[] = { 0, 1, 2, 3, 3, 3, 3, 2, 1, 0, 0, 0, 1, 2, 2, 1 };
91 static char yinit[] = { 0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2 };
92 unsigned x = 0, y = 0;
93 unsigned char index;
94 UChar tmp_sync = 0;
95 for (index = 0; index < 16; index++)
96 {
97 for (y = yinit[index]; y < ymax; y += 4)
98 for (x = xinit[index]; x < xmax; x += 4)
99 putpixel (screen, xto + x, yto + y, getpixel (to, x, y));
100
101 if (!use_eagle)
102 vsync ();
103 else if (tmp_sync = !tmp_sync)
104 vsync ();
105
106 }
107 blit (to, screen, 0, 0, xto, yto, xmax, ymax);
108 return;
109 }
110
111 /*****************************************************************************
112
113 Function: special_fadeout1
114
115 Description: fade out with spiral effect
116 Parameters: xto,yto,xmax,ymax used like in blit
117 used like "rectfill(screen,xto,yto,xto+xmax,yto+ymax)"
118 Return:nothing
119
120 *****************************************************************************/
121
122
123 void
special_fadeout1(unsigned xto,unsigned yto,unsigned xmax,unsigned ymax)124 special_fadeout1 (unsigned xto, unsigned yto, unsigned xmax, unsigned ymax)
125 {
126 static char xinit[] = { 0, 1, 2, 3, 3, 3, 3, 2, 1, 0, 0, 0, 1, 2, 2, 1 };
127 static char yinit[] = { 0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2 };
128 unsigned x = 0, y = 0;
129 unsigned char index;
130 UChar tmp_sync = 0;
131 for (index = 0; index < 16; index++)
132 {
133 for (y = yto + yinit[index]; y < yto + ymax; y += 4)
134 for (x = xto + xinit[index]; x < xto + xmax; x += 4)
135 putpixel (screen, x, y, 0);
136
137 if (!use_eagle)
138 vsync ();
139 else if (tmp_sync = !tmp_sync)
140 vsync ();
141
142 }
143 rectfill (screen, xto, yto, xto + xmax, yto + ymax, 0);
144 return;
145 }
146
147
148 /*****************************************************************************
149
150 Function: special_fadeout2
151
152 Description: fade out with slide effect
153 Parameters: xto,yto,xmax,ymax used like in blit
154 used like "rectfill(screen,xto,yto,xto+xmax,yto+ymax,0)"
155 Return:nothing
156
157 *****************************************************************************/
158
159
160 void
special_fadeout2(unsigned xto,unsigned yto,unsigned xmax,unsigned ymax)161 special_fadeout2 (unsigned xto, unsigned yto, unsigned xmax, unsigned ymax)
162 {
163 int y = 0;
164 int *diff, *act;
165 int index, max_iter = (xmax - xto) / 8, iter = 0;
166 UChar tmp_sync = 0;
167
168 diff = (int *) alloca (sizeof (int) * ymax);
169 act = (int *) alloca (sizeof (int) * ymax);
170 memset (diff, 0, (ymax) * sizeof (int));
171 memset (act, 0, ymax * sizeof (int));
172
173
174 while (iter < max_iter)
175 {
176 for (index = 0; index < ymax; index++)
177 {
178 act[index] += diff[index] = rand () % 4 + 6;
179 if (act[index] > xmax)
180 act[index] = xmax;
181 }
182 for (y = yto, index = 0; index < ymax; y++, index++)
183 hline (screen, xto, y, xto + act[index], 0);
184
185 iter++;
186 if (!use_eagle)
187 vsync ();
188 else if (tmp_sync = !tmp_sync)
189 vsync ();
190
191 }
192 rectfill (screen, xto, yto, xto + xmax, yto + ymax, 0);
193 return;
194 }
195
196 /*****************************************************************************
197
198 Function: special_fadein2
199
200 Description: fade in with slide effect
201 Parameters: xto,yto,xmax,ymax used like in blit
202 used like "blit(screen,to,0,0,xto,yto,xmax,ymax)"
203 Return:nothing
204
205 *****************************************************************************/
206
207
208 void
special_fadein2(BITMAP * to,unsigned xto,unsigned yto,unsigned xmax,unsigned ymax)209 special_fadein2 (BITMAP * to, unsigned xto, unsigned yto, unsigned xmax,
210 unsigned ymax)
211 {
212 int y = 0;
213 int *diff, *act;
214 int index, max_iter = (xmax - xto) / 8, iter = 0;
215 UChar tmp_sync = 0;
216
217 diff = (int *) alloca (sizeof (int) * ymax);
218 act = (int *) alloca (sizeof (int) * ymax);
219 memset (diff, 0, (ymax) * sizeof (int));
220 memset (act, 0, (ymax) * sizeof (int));
221
222
223 while (iter < max_iter)
224 {
225 for (index = 0; index < ymax; index++)
226 {
227 act[index] += diff[index] = rand () % 4 + 6;
228 if (act[index] >= xmax)
229 act[index] = xmax;
230
231 }
232
233 for (y = yto, index = 0; index < ymax; y++, index++)
234 blit (to, screen, xmax - act[index], index, xto, y, act[index], 1);
235
236 iter++;
237 if (!use_eagle)
238 vsync ();
239 else if (tmp_sync = !tmp_sync)
240 vsync ();
241
242 }
243 blit (to, screen, 0, 0, xto, yto, xmax, ymax);
244 return;
245 }
246
247
248 /*****************************************************************************
249
250 Function: special_fadein3
251
252 Description: fade in with double slide effect
253 Parameters: xto,yto,xmax,ymax used like in blit
254 used like "blit(screen,to,0,0,xto,yto,xmax,ymax)"
255 Return:nothing
256
257 *****************************************************************************/
258
259
260 void
special_fadein3(BITMAP * to,unsigned xto,unsigned yto,unsigned xmax,unsigned ymax)261 special_fadein3 (BITMAP * to, unsigned xto, unsigned yto, unsigned xmax,
262 unsigned ymax)
263 {
264 int y = 0;
265 int *diff, *act;
266 int index, max_iter = (xmax - xto) / 10, iter = 0;
267 UChar tmp_sync = 0;
268
269 diff = (int *) alloca (sizeof (int) * ymax);
270 act = (int *) alloca (sizeof (int) * ymax);
271 memset (diff, 0, (ymax) * sizeof (int));
272 memset (act, 0, (ymax) * sizeof (int));
273
274 while (iter < max_iter)
275 {
276
277 for (index = 0; index < ymax; index++)
278 act[index] += 10;
279
280 for (y = yto, index = 0; index < ymax; y += 2, index += 2)
281 blit (to, screen, xmax - act[index], index, xto, y, act[index], 1);
282
283 for (y = yto + 1, index = 1; index < ymax; y += 2, index += 2)
284 blit (to, screen, 0, index, xto + xmax - act[index], y, act[index],
285 1);
286
287 iter++;
288 if (!use_eagle)
289 vsync ();
290 else if (tmp_sync = !tmp_sync)
291 vsync ();
292 }
293 blit (to, screen, 0, 0, xto, yto, xmax, ymax);
294 return;
295 }
296
297
298 /*****************************************************************************
299
300 Function: special_fadeout3
301
302 Description: fade in with double slide effect
303 Parameters: xto,yto,xmax,ymax used like in blit
304 used like "rectfill(screen,xto,yto,xto+xmax,yto+ymax)"
305 Return:nothing
306
307 *****************************************************************************/
308
309
310 void
special_fadeout3(unsigned xto,unsigned yto,unsigned xmax,unsigned ymax)311 special_fadeout3 (unsigned xto, unsigned yto, unsigned xmax, unsigned ymax)
312 {
313 int y = 0;
314 int *diff, *act;
315 int index, max_iter = (xmax - xto) / 10, iter = 0;
316 UChar tmp_sync = 0;
317
318 diff = (int *) alloca (sizeof (int) * ymax);
319 act = (int *) alloca (sizeof (int) * ymax);
320 memset (diff, 0, (ymax) * sizeof (int));
321 memset (act, 0, (ymax) * sizeof (int));
322
323 while (iter < max_iter)
324 {
325
326 for (index = 0; index < ymax; index++)
327 act[index] += 10;
328
329 for (y = yto, index = 0; index < ymax; y += 2, index += 2)
330 hline (screen, act[index] - 10, y, act[index], 0);
331
332 for (y = yto + 1, index = 1; index < ymax; y += 2, index += 2)
333 hline (screen, xto + xmax - act[index] + 10, y,
334 xto + xmax - act[index], 0);
335
336 iter++;
337
338 if (!use_eagle)
339 vsync ();
340 else if (tmp_sync = !tmp_sync)
341 vsync ();
342
343 }
344 rectfill (screen, xto, yto, xto + xmax, yto + ymax, 0);
345 return;
346 }
347
348 /*****************************************************************************
349
350 Function: special_fadein4
351
352 Description: fade in with diagonal effect
353 Parameters: the BITMAP to fade to,
354 xto,yto,xmax,ymax used like in blit
355 used like "blit(to,screen,0,0,xto,yto,xmax,ymax)"
356 Return:nothing
357
358 *****************************************************************************/
359 void
special_fadein4(BITMAP * to,unsigned xto,unsigned yto,unsigned xmax,unsigned ymax)360 special_fadein4 (BITMAP * to, unsigned xto, unsigned yto, unsigned xmax,
361 unsigned ymax)
362 {
363 static char xinit[] = { 0, 2, 0, 2, 1, 3, 1, 3, 1, 3, 1, 3, 2, 0, 2, 0 };
364 static char yinit[] = { 0, 0, 1, 1, 2, 2, 3, 3, 0, 0, 1, 1, 2, 2, 3, 3 };
365 unsigned x = 0, y = 0;
366 unsigned char index;
367 UChar tmp_sync = 0;
368 for (index = 0; index < 16; index++)
369 {
370 for (y = yinit[index]; y < ymax; y += 4)
371 for (x = xinit[index]; x < xmax; x += 4)
372 putpixel (screen, xto + x, yto + y, getpixel (to, x, y));
373
374 if (!use_eagle)
375 vsync ();
376 else if (tmp_sync = !tmp_sync)
377 vsync ();
378
379 }
380 blit (to, screen, 0, 0, xto, yto, xmax, ymax);
381 return;
382 }
383
384 /*****************************************************************************
385
386 Function: special_fadeout4
387
388 Description: fade out with diagonal effect
389 Parameters: xto,yto,xmax,ymax used like in blit
390 used like "rectfill(screen,xto,yto,xto+xmax,yto+ymax)"
391 Return:nothing
392
393 *****************************************************************************/
394
395
396 void
special_fadeout4(unsigned xto,unsigned yto,unsigned xmax,unsigned ymax)397 special_fadeout4 (unsigned xto, unsigned yto, unsigned xmax, unsigned ymax)
398 {
399 static char xinit[] = { 0, 2, 0, 2, 1, 3, 1, 3, 1, 3, 1, 3, 2, 0, 2, 0 };
400 static char yinit[] = { 0, 0, 1, 1, 2, 2, 3, 3, 0, 0, 1, 1, 2, 2, 3, 3 };
401 unsigned x = 0, y = 0;
402 unsigned char index;
403 UChar tmp_sync = 0;
404 for (index = 0; index < 16; index++)
405 {
406 for (y = yto + yinit[index]; y < yto + ymax; y += 4)
407 for (x = xto + xinit[index]; x < xto + xmax; x += 4)
408 putpixel (screen, x, y, 0);
409
410 if (!use_eagle)
411 vsync ();
412 else if (tmp_sync = !tmp_sync)
413 vsync ();
414
415 }
416 rectfill (screen, xto, yto, xto + xmax, yto + ymax, 0);
417 return;
418 }
419
420
421 /*****************************************************************************
422
423 Function: special_fadein5
424
425 Description: fade in with spiral effect
426 Parameters: the BITMAP to fade to,
427 xto,yto,xmax,ymax used like in blit
428 used like "blit(to,screen,0,0,xto,yto,xmax,ymax)"
429 Return:nothing
430
431 *****************************************************************************/
432 void
special_fadein5(BITMAP * to,unsigned xto,unsigned yto,unsigned xmax,unsigned ymax)433 special_fadein5 (BITMAP * to, unsigned xto, unsigned yto, unsigned xmax,
434 unsigned ymax)
435 {
436 static char xinit[] = { 3, 2, 2, 1, 1, 0, 0, 0, 1, 0, 1, 2, 2, 3, 3, 3 };
437 static char yinit[] = { 0, 1, 0, 0, 1, 0, 1, 2, 2, 3, 3, 3, 2, 3, 2, 1 };
438 unsigned x = 0, y = 0;
439 unsigned char index;
440 UChar tmp_sync = 0;
441 for (index = 0; index < 16; index++)
442 {
443 for (y = yinit[index]; y < ymax; y += 4)
444 for (x = xinit[index]; x < xmax; x += 4)
445 putpixel (screen, xto + x, yto + y, getpixel (to, x, y));
446
447 if (!use_eagle)
448 vsync ();
449 else if (tmp_sync = !tmp_sync)
450 vsync ();
451
452 }
453 blit (to, screen, 0, 0, xto, yto, xmax, ymax);
454 return;
455 }
456
457
458 /*****************************************************************************
459
460 Function: special_fadeout5
461
462 Description: fade out with spiral effect
463 Parameters: xto,yto,xmax,ymax used like in blit
464 used like "rectfill(screen,xto,yto,xto+xmax,yto+ymax)"
465 Return:nothing
466
467 *****************************************************************************/
468
469
470 void
special_fadeout5(unsigned xto,unsigned yto,unsigned xmax,unsigned ymax)471 special_fadeout5 (unsigned xto, unsigned yto, unsigned xmax, unsigned ymax)
472 {
473 static char xinit[] = { 3, 2, 2, 1, 1, 0, 0, 0, 1, 0, 1, 2, 2, 3, 3, 3 };
474 static char yinit[] = { 0, 1, 0, 0, 1, 0, 1, 2, 2, 3, 3, 3, 2, 3, 2, 1 };
475 unsigned x = 0, y = 0;
476 unsigned char index;
477 UChar tmp_sync = 0;
478 for (index = 0; index < 16; index++)
479 {
480 for (y = yto + yinit[index]; y < yto + ymax; y += 4)
481 for (x = xto + xinit[index]; x < xto + xmax; x += 4)
482 putpixel (screen, x, y, 0);
483
484 if (!use_eagle)
485 vsync ();
486 else if (tmp_sync = !tmp_sync)
487 vsync ();
488
489 }
490 rectfill (screen, xto, yto, xto + xmax, yto + ymax, 0);
491 return;
492 }
493
494 #endif
495