1 /***********************************************************
2 * K O U L E S *
3 *----------------------------------------------------------*
4 * C1995 JAHUSOFT *
5 * Jan Hubicka *
6 * Dukelskych Bojovniku 1944 *
7 * 390 03 Tabor *
8 * Czech Republic *
9 * Phone: 0041-361-32613 *
10 * eMail: hubicka@limax.paru.cas.cz *
11 *----------------------------------------------------------*
12 * Copyright(c)1995,1996 by Jan Hubicka.See README for *
13 * licence details. *
14 *----------------------------------------------------------*
15 * intro.c intro outro code *
16 ***********************************************************/
17 /* Changes for OS/2 Warp with Dive. *
18 * Copyright(c)1996 by Thomas A. K. Kjaer *
19 ***********************************************************/
20
21 #include "koules.h"
22 #include "font.h"
23 #include "text.h"
24 #include <sys/time.h>
25 #include <unistd.h>
26 extern void fadein1 ();
27 extern void points ();
28 extern void points1 ();
29
30
31 /*
32
33 * intro code
34 *
35 */
36 void
draw_koules(CONST int c,CONST int s,CONST int r)37 draw_koules (CONST int c, CONST int s, CONST int r)
38 {
39 int i;
40 for (i = 0; i < 360; i += 60)
41 switch (c)
42 {
43 case 0:
44 PutBitmap ((int) (MAPWIDTH / 2 - BALL_RADIUS / DIV + sin (RAD (i + s)) * r),
45 (int) (MAPHEIGHT / 2 - BALL_RADIUS / DIV + cos (RAD (i + s)) * r),
46 BALL_RADIUS * 2 / DIV, BALL_RADIUS * 2 / DIV, ball_bitmap);
47 break;
48 case 1:
49 PutBitmap ((int) (MAPWIDTH / 2 - BALL_RADIUS / DIV + sin (RAD (i + s)) * r),
50 (int) (MAPHEIGHT / 2 - BALL_RADIUS / DIV + cos (RAD (i + s)) * r),
51 BALL_RADIUS * 2 / DIV, BALL_RADIUS * 2 / DIV, lball_bitmap[0]);
52 break;
53 default:
54 PutBitmap ((int) (MAPWIDTH / 2 - BALL_RADIUS / DIV + sin (RAD (i + s)) * r),
55 (int) (MAPHEIGHT / 2 - BALL_RADIUS / DIV + cos (RAD (i + s)) * r),
56 BALL_RADIUS * 2 / DIV, BALL_RADIUS * 2 / DIV, lball_bitmap[1]);
57 break;
58 }
59
60 }
61 void
koulescreator(CONST int r)62 koulescreator (CONST int r)
63 {
64 int time = 100;
65 int z1;
66 int x, y;
67 int x1, y1, i;
68 Effect (S_CREATOR1, next);
69 for (i = 0; i < 360; i += 60)
70 {
71 x1 = (MAPWIDTH / 2 - +sin (RAD (i)) * r);
72 y1 = (MAPHEIGHT / 2 - +cos (RAD (i)) * r);
73 for (z1 = 0; z1 < BALL_RADIUS * BALL_RADIUS * M_PI / DIV / DIV; z1++)
74 {
75 x = rand () % GAMEWIDTH;
76 y = rand () % GAMEHEIGHT;
77 addpoint (x * 256 * DIV, y * 256 * DIV,
78 (x1 - x) * 256 / (time) * DIV,
79 (y1 - y) * 256 / (time) * DIV,
80 ball (rand () % 32),
81 time);
82 }
83 }
84 }
85 void
starcreator()86 starcreator ()
87 {
88 int time = 100;
89 int z;
90 int x, y;
91 Effect (S_CREATOR1, next);
92 for (z = 0; z < ROCKET_RADIUS * ROCKET_RADIUS * M_PI / DIV / DIV; z++)
93 {
94 x = rand () % GAMEWIDTH;
95 y = rand () % GAMEHEIGHT;
96 addpoint (x * 256 * DIV, y * 256 * DIV,
97 (MAPWIDTH / 2 - x) * 256 / (time) * DIV,
98 (MAPHEIGHT / 2 - y) * 256 / (time) * DIV,
99 (rand () % 32),
100 time);
101 }
102 }
103 void
draw_player(CONST int x,CONST int y,CONST float r,CONST int z,CONST int r1)104 draw_player (CONST int x, CONST int y, CONST float r, CONST int z, CONST int r1)
105 {
106 int x1, y1;
107 PutBitmap ((int) x - ROCKET_RADIUS / DIV, (int) y - ROCKET_RADIUS / DIV,
108 ROCKET_RADIUS * 2 / DIV, ROCKET_RADIUS * 2 / DIV, rocket_bitmap[z]);
109 x1 = x * DIV + sin (r - RAD (30)) * r1 - EYE_RADIUS;
110 y1 = y * DIV + cos (r - RAD (30)) * r1 - EYE_RADIUS;
111 PutBitmap (x1 / DIV, y1 / DIV,
112 EYE_RADIUS * 2 / DIV, EYE_RADIUS * 2 / DIV, eye_bitmap[z]);
113 x1 = x * DIV + sin (r + RAD (30)) * r1 - EYE_RADIUS;
114 y1 = y * DIV + cos (r + RAD (30)) * r1 - EYE_RADIUS;
115 PutBitmap (x1 / DIV, y1 / DIV,
116 EYE_RADIUS * 2 / DIV, EYE_RADIUS * 2 / DIV, eye_bitmap[z]);
117
118 }
119
120 #define TEXTW 200
121 #define TEXTH 25
122 void
starwars()123 starwars ()
124 {
125 int y, i, z;
126 float r[3];
127 float angle = 0;
128
129 int actu = 0;
130 int time = 0;
131 int time1 = 0;
132
133 int playx = 0, playy = 0;
134 int bballx = 0, bbally = 0;
135 float playr = RAD (0), playp = 0.03;
136 long VfTime = 0;
137 long VendSleep = 0;
138 int sizes[300];
139 struct timeval VlastClk;
140 struct timeval VnewClk;
141 int wait = 0;
142
143 float r1;
144 float rp[3];
145
146 fadeout ();
147 for (y = 0; y < TEXTSIZE; y++)
148 sizes[y] = -vgatextsize (TEXTH, text[y]) / 2;
149 gettimeofday (&VlastClk, NULL);
150 gettimeofday (&VnewClk, NULL);
151 VendSleep = VlastClk.tv_usec;
152 #ifdef DEBUG
153 VfTime = 1000000 / 200;
154 #else
155 VfTime = 1000000 / 65;
156 #endif
157
158 r[1] = r[2] = r[0] = sqrt ((MAPWIDTH / 2) * (MAPWIDTH / 2) +
159 (MAPHEIGHT / 2) * (MAPHEIGHT / 2));
160 rp[0] = 0.0 / DIV;
161 rp[1] = 0.6 / DIV;
162 rp[2] = 0.6 / DIV;
163 r1 = r[0];
164
165 Effect (S_START, 0);
166 for (i = -660; i < (TEXTSIZE + 10) * TEXTW; i += 1)
167 {
168 gettimeofday (&VnewClk, NULL);
169 if (VnewClk.tv_usec < VendSleep)
170 VendSleep -= 1000000;
171 wait = (VfTime - VnewClk.tv_usec + VendSleep);
172 if (wait >= 0 || tbreak)
173 {
174 CopyVSToVS (starbackground, backscreen);
175 SetScreen (backscreen);
176 EnableClipping ();
177 for (z = 0; z < 3; z++)
178 {
179 if (r[z] <= ROCKET_RADIUS / DIV + BALL_RADIUS / DIV)
180 {
181 rp[z] = -6 / DIV;
182 Effect (S_COLIZE, next);
183 }
184 if (r[z] < r1)
185 draw_koules (rp[z] > 0 ? z : 0, (int) angle, r[z]);
186 }
187 if (bbally > -20 && bballx)
188 PutBitmap ((int) bballx - (BBALL_RADIUS) / DIV, bbally,
189 BBALL_RADIUS * 2 / DIV, BBALL_RADIUS * 2 / DIV, bball_bitmap);
190
191 points ();
192 for (y = 0; y < TEXTSIZE; y++)
193 {
194 if (y * TEXTW - i + 2 * TEXTW < 1000 && y * TEXTW - i + TEXTW > -1500)
195 {
196 textcolor = (1200 + (y * TEXTW - i)) * 32 / 2500;
197 if (textcolor <= 0)
198 continue;
199 actu = y;
200 vgadrawtext (sizes[y], y * TEXTW - i, TEXTH, text[y]);
201 #ifdef OS2DIVE
202 DosSleep (WAIT);
203 #endif
204 }
205 }
206 if (playx)
207 draw_player (playx, playy, playr, 0, EYE_RADIUS1);
208 if (actu == PLAYERLINE && !time)
209 starcreator (), time = 1;
210 CopyToScreen (backscreen);
211 fadein1 ();
212 }
213 else
214 points1 ();
215
216
217 if (actu >= KOULESLINE && !time1)
218 koulescreator (MAPHEIGHT / 2 - 20), time1 = 1;
219 if (time1)
220 time1++;
221 if (time1 == 100)
222 r[0] = MAPHEIGHT / 2 - 20;
223 if (time1 > 100)
224 r[0] -= rp[0], angle += 0.3;
225
226
227 playr += playp;
228 if (playr < RAD (-45))
229 playp = 0.015, playr = RAD (-45);
230 if (playr > RAD (45))
231 playp = -0.03, playr = RAD (45);
232 if (actu >= D1LINE)
233 r[1] -= rp[1];
234 if (actu >= D2LINE)
235 r[2] -= rp[2];
236 if (actu >= BLINE && !bballx)
237 bballx = MAPWIDTH / 2,
238 bbally = MAPHEIGHT + 30;
239 if (bballx)
240 bbally--;
241 if (bbally > 0 && bbally < MAPHEIGHT / 2 + ROCKET_RADIUS / 2)
242 {
243 if (playy == MAPHEIGHT / 2)
244 {
245 Effect (S_END, next);
246 }
247 playy -= 10;
248 }
249 if (time)
250 time++;
251 if (time == 100)
252 {
253 playx = MAPWIDTH / 2, playy = MAPHEIGHT / 2, playr = RAD (180), rp[0] = 1.5 / DIV;
254 Effect (S_CREATOR2, next);
255 }
256 gettimeofday (&VnewClk, NULL);
257 if (VnewClk.tv_usec < VendSleep)
258 VendSleep -= 1000000;
259 wait = (VfTime - VnewClk.tv_usec + VendSleep);
260 if (tbreak)
261 wait = VfTime, tbreak = 0;
262 usleep (wait < 0 ? 0 : wait);
263 VendSleep = VnewClk.tv_usec + wait;
264 gettimeofday (&VlastClk, NULL);
265 UpdateInput ();
266 if (Pressed ())
267 {
268 fadeout ();
269 while (Pressed ())
270 {
271 UpdateInput ();
272 }
273 return;
274 }
275 }
276 fadeout ();
277 }
278 void
clearpoints()279 clearpoints ()
280 {
281 int i;
282 for (i = 0; i < MAXPOINT; i++)
283 point[i].time = 0;
284 }
285 void
outro(CONST int size,char * text[])286 outro (CONST int size, char *text[])
287 {
288 int y, i;
289
290 int actu = -1;
291 int lkey = 1;
292 int skey = 0;
293 int key = 1;
294
295 long VfTime = 0;
296 long VendSleep = 0;
297 #ifdef __GNUC__
298 int sizes[size];
299 #else
300 int sizes[300];
301 #endif
302 struct timeval VlastClk;
303 struct timeval VnewClk;
304 int wait = 0;
305
306 fadeout ();
307 clearpoints ();
308 for (y = 0; y < size; y++)
309 sizes[y] = -vgatextsize (TEXTH, text[y]) / 2;
310 gettimeofday (&VlastClk, NULL);
311 gettimeofday (&VnewClk, NULL);
312 VendSleep = VlastClk.tv_usec;
313 #ifdef DEBUG
314 VfTime = 1000000 / 200;
315 #else
316 VfTime = 1000000 / 65;
317 #endif
318
319 for (i = -660; i < (size + 4) * TEXTW; i += 1)
320 {
321 gettimeofday (&VnewClk, NULL);
322 if (VnewClk.tv_usec < VendSleep)
323 VendSleep -= 1000000;
324 wait = (VfTime - VnewClk.tv_usec + VendSleep);
325 if (wait >= 0 || tbreak)
326 {
327 CopyVSToVS (starbackground, backscreen);
328 SetScreen (backscreen);
329 EnableClipping ();
330 points ();
331 for (y = 0; y < size; y++)
332 {
333 if (y * TEXTW - i + 2 * TEXTW < 1000 && y * TEXTW - i + TEXTW > -1500)
334 {
335 textcolor = (1200 + (y * TEXTW - i)) * 32 / 2500;
336 if (textcolor <= 0)
337 continue;
338 actu = y;
339 vgadrawtext (sizes[y], y * TEXTW - i, TEXTH, text[y]);
340 #ifdef OS2DIVE
341 DosSleep (WAIT);
342 #endif
343 }
344 }
345 CopyToScreen (backscreen);
346 fadein1 ();
347 }
348 else
349 points1 ();
350
351
352 gettimeofday (&VnewClk, NULL);
353 if (VnewClk.tv_usec < VendSleep)
354 VendSleep -= 1000000;
355 wait = (VfTime - VnewClk.tv_usec + VendSleep);
356 if (tbreak)
357 wait = VfTime, tbreak = 0;
358 usleep (wait < 0 ? 0 : wait);
359 VendSleep = VnewClk.tv_usec + wait;
360 gettimeofday (&VlastClk, NULL);
361 UpdateInput ();
362 if (actu >= 0)
363 {
364 lkey = key;
365 key = Pressed ();
366 if (skey && !key && lkey)
367 {
368 fadeout ();
369 return;
370 }
371 if (!key && lkey)
372 skey = 1;
373 }
374 }
375 fadeout ();
376 }
377 void
staraccel(CONST float x1,CONST float y1,CONST float r)378 staraccel (CONST float x1, CONST float y1, CONST float r)
379 {
380 int y;
381 for (y = 0; y < 5 / DIV / DIV; y++)
382 {
383 float p;
384 p = RAD (rand () % 45 - 22);
385 addpoint (x1 * 256,
386 y1 * 256,
387 (-sin (r + p) * 0.08 * 10) * (rand () % 512),
388 (-cos (r + p) * 0.08 * 10) * (rand () % 512),
389 rocket (rand () % 16), 30);
390 }
391 }
392 void
outro2()393 outro2 ()
394 {
395 int y, i, z;
396 int lkey = 1;
397 int skey = 0;
398 int key = 1;
399
400 int actu = 0;
401 float width = 0;
402
403 long VfTime = 0;
404 long VendSleep = 0;
405 int size = TEXTSIZE2;
406 #ifdef __GNUC__
407 int sizes[size], nrockets1;
408 #else
409 int sizes[300], nrockets1;
410 #endif
411 struct timeval VlastClk;
412 struct timeval VnewClk;
413 int wait = 0;
414 int first=1;
415 float playy = MAPHEIGHT + 20;
416 float playr = RAD (180);
417 float playp = 0;
418 float er = EYE_RADIUS1;
419 float erp = 2;
420
421
422 fadeout ();
423 clearpoints ();
424 nrockets1 = nrockets - 1;
425 if (nrockets1 == 0)
426 nrockets1 = 1;
427 for (y = 0; y < size; y++)
428 sizes[y] = -vgatextsize (TEXTH, text2[y]) / 2;
429 gettimeofday (&VlastClk, NULL);
430 gettimeofday (&VnewClk, NULL);
431 VendSleep = VlastClk.tv_usec;
432 #ifdef DEBUG
433 VfTime = 1000000 / 200;
434 #else
435 VfTime = 1000000 / 65;
436 #endif
437 Effect (S_START, next);
438 for (i = -660; i < (size + 5) * TEXTW; i += 1)
439 {
440 gettimeofday (&VnewClk, NULL);
441 if (VnewClk.tv_usec < VendSleep)
442 VendSleep -= 1000000;
443 wait = (VfTime - VnewClk.tv_usec + VendSleep);
444 if (wait >= 0 || tbreak)
445 {
446 CopyVSToVS (starbackground, backscreen);
447 SetScreen (backscreen);
448 EnableClipping ();
449 points ();
450 for (y = 0; y < size; y++)
451 {
452 if (y * TEXTW - i + 2 * TEXTW < 1000 && y * TEXTW - i + TEXTW > -1500)
453 {
454 textcolor = (1200 + (y * TEXTW - i)) * 32 / 2500;
455 if (textcolor <= 0)
456 continue;
457 actu = y;
458 vgadrawtext (sizes[y], y * TEXTW - i, TEXTH, text2[y]);
459 #ifdef OS2DIVE
460 DosSleep (WAIT);
461 #endif
462 }
463 }
464 for (z = 0; z < nrockets; z++)
465 {
466 if(!first) draw_player (MAPWIDTH / 2 - width / 2 + z * width / (nrockets1), playy, playr, z, (int) er);
467 }
468 first=0;
469 CopyToScreen (backscreen);
470 fadein1 ();
471 }
472 else
473 points1 ();
474 width = (200 * (nrockets - 1) * playy / MAPHEIGHT + 20 * (nrockets - 1)) / DIV;
475 if (playy > MAPHEIGHT / 2 || actu > CONTLINE)
476 {
477 playy -= 0.6 / DIV;
478 playr = RAD (180);
479 for (z = 0; z < nrockets; z++)
480 {
481 staraccel ((MAPWIDTH / 2 - width / 2 + z * width / (nrockets1)) * DIV, (playy) * DIV, playr);
482 }
483 er = EYE_RADIUS1;
484 }
485 else
486 {
487 playr += playp;
488 if (playr < RAD (-45))
489 playp = 0.015, playr = RAD (-45);
490 if (playr > RAD (45))
491 playp = -0.03, playr = RAD (45);
492 if (actu > UDIVLINE)
493 {
494 /*if (er < 2 * EYE_RADIUS1)
495 erp += 0.1;
496 if (er > 2 * EYE_RADIUS1)
497 erp -= 0.1; */
498 erp += (2 * EYE_RADIUS1 - er) / 10;
499 erp *= 0.98;
500 er += erp;
501 }
502 }
503 gettimeofday (&VnewClk, NULL);
504 if (VnewClk.tv_usec < VendSleep)
505 VendSleep -= 1000000;
506 wait = (VfTime - VnewClk.tv_usec + VendSleep);
507 if (tbreak)
508 wait = VfTime, tbreak = 0;
509 usleep (wait < 0 ? 0 : wait);
510 VendSleep = VnewClk.tv_usec + wait;
511 gettimeofday (&VlastClk, NULL);
512 UpdateInput ();
513 if (actu > 0)
514 {
515 lkey = key;
516 key = 0;
517 key = Pressed ();
518 if (skey && !key && lkey)
519 {
520 fadeout ();
521 return;
522 }
523 if (!key && lkey)
524 skey = 1;
525 }
526 }
527 fadeout ();
528 }
529
530
531 void
outro1()532 outro1 ()
533 {
534 outro (TEXTSIZE1, text1);
535 }
536
537 void
intro_intro()538 intro_intro ()
539 {
540 outro (INTROSIZE, introtext);
541 }
542
543 void
hole_intro()544 hole_intro ()
545 {
546 outro (HOLESIZE, holetext);
547 }
548
549 void
inspector_intro()550 inspector_intro ()
551 {
552 outro (INSPECTORSIZE, inspectortext);
553 }
554
555 void
bball_intro()556 bball_intro ()
557 {
558 outro (BBALLSIZE, bballtext);
559 }
560
561 void
bbball_intro()562 bbball_intro ()
563 {
564 outro (BBBALLSIZE, bbballtext);
565 }
566
567 void
maghole_intro()568 maghole_intro ()
569 {
570 outro (MAGSIZE, magholetext);
571 }
572 void
spring_intro()573 spring_intro ()
574 {
575 outro (SPRINGTSIZE, springtext);
576 }
577 void
thief_intro()578 thief_intro ()
579 {
580 outro (THIEFSIZE, thieftext);
581 }
582 void
ttool_intro()583 ttool_intro ()
584 {
585 outro (TTOOLSIZE, ttooltext);
586 }
587 void
finder_intro()588 finder_intro ()
589 {
590 outro (FINDERSIZE, findertext);
591 }
592 void
lunatic_intro()593 lunatic_intro ()
594 {
595 outro (LUNATICSIZE, lunatictext);
596 }
597