rocks_n_diamonds-0.9b
[rocksndiamonds.git] / src / screens.c
1 /***********************************************************
2 *  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
3 *----------------------------------------------------------*
4 *  ©1995 Artsoft Development                               *
5 *        Holger Schemel                                    *
6 *        33659 Bielefeld-Senne                             *
7 *        Telefon: (0521) 493245                            *
8 *        eMail: aeglos@valinor.owl.de                      *
9 *               aeglos@uni-paderborn.de                    *
10 *               q99492@pbhrzx.uni-paderborn.de             *
11 *----------------------------------------------------------*
12 *  screens.c                                               *
13 ***********************************************************/
14
15 #include "screens.h"
16 #include "events.h"
17 #include "sound.h"
18 #include "game.h"
19 #include "tools.h"
20 #include "editor.h"
21 #include "misc.h"
22 #include "files.h"
23 #include "buttons.h"
24
25 void DrawMainMenu()
26 {
27   int i;
28
29   FadeSounds();
30   GetPlayerConfig();
31   LoadLevel(level_nr);
32
33   ClearWindow();
34   DrawText(SX+16, SY+8,  "ROCKS'N'DIAMONDS",FS_BIG,FC_YELLOW);
35   DrawText(SX+25+16, SY+46, "Copyright ^1995 by Holger Schemel",
36            FS_SMALL,FC_RED);
37   DrawText(SX+32, SY+64, "Name:",FS_BIG,FC_GREEN);
38   DrawText(SX+192,SY+64, player.alias_name,FS_BIG,FC_RED);
39   DrawText(SX+32, SY+96, "Level:",FS_BIG,FC_GREEN);
40   DrawText(SX+352,SY+96, int2str(level_nr,3),FS_BIG,
41            (level_nr<leveldir[leveldir_nr].num_ready ? FC_RED : FC_YELLOW));
42   DrawText(SX+32, SY+128,"Hall Of Fame",FS_BIG,FC_GREEN);
43   DrawText(SX+32, SY+160,"Level Creator",FS_BIG,FC_GREEN);
44   DrawText(SY+32, SY+192,"Info Screen",FS_BIG,FC_GREEN);
45   DrawText(SX+32, SY+224,"Start Game",FS_BIG,FC_GREEN);
46   DrawText(SX+32, SY+256,"Setup",FS_BIG,FC_GREEN);
47   DrawText(SX+32, SY+288,"Quit",FS_BIG,FC_GREEN);
48
49   DrawMicroLevel(MICROLEV_XPOS,MICROLEV_YPOS);
50
51   for(i=2;i<10;i++)
52     DrawGraphic(0,i,GFX_KUGEL_BLAU);
53   DrawGraphic(10,3,GFX_KUGEL_BLAU);
54   DrawGraphic(14,3,GFX_KUGEL_BLAU);
55
56   DrawText(SX+54+16,SY+326,"A Game by Artsoft Development",FS_SMALL,FC_BLUE);
57   DrawText(SX+40+16,SY+344,"Graphics: Deluxe Paint IV Amiga",
58            FS_SMALL,FC_BLUE);
59   DrawText(SX+60+16,SY+362,"Sounds: AudioMaster IV Amiga",
60            FS_SMALL,FC_BLUE);
61
62   FadeToFront();
63   InitAnimation();
64   HandleMainMenu(0,0,0,0,MB_MENU_MARK);
65
66   TapeStop();
67   if (TAPE_IS_EMPTY(tape))
68     LoadLevelTape(level_nr);
69   DrawCompleteVideoDisplay();
70
71   OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
72
73   XAutoRepeatOn(display);
74 }
75
76 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
77 {
78   static int choice = 3;
79   static int redraw = TRUE;
80   int x = (mx+32-SX)/32, y = (my+32-SY)/32;
81
82   if (redraw)
83   {
84     DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
85     redraw = FALSE;
86   }
87
88   if (dx || dy)
89   {
90     if (dx && choice==4)
91     {
92       x = (dx<0 ? 11 : 15);
93       y = 4;
94     }
95     else if (dy)
96     {
97       x = 1;
98       y = choice+dy;
99     }
100     else
101       x = y = 0;
102
103     if (y<3)
104       y = 3;
105     else if (y>10)
106       y = 10;
107   }
108
109   if (!mx && !my && !dx && !dy)
110   {
111     x = 1;
112     y = choice;
113   }
114
115   if (y==4 && ((x==11 && level_nr>0) ||
116                (x==15 && level_nr<LEVELDIR_SIZE(leveldir[leveldir_nr]))) &&
117       button)
118   {
119     static long level_delay = 0;
120     int step = (button==1 ? 1 : button==2 ? 5 : 10);
121
122     if (!DelayReached(&level_delay,20))
123       goto out;
124
125     level_nr += (x==11 ? -step : +step);
126     if (level_nr<0)
127       level_nr = 0;
128     if (level_nr>LEVELDIR_SIZE(leveldir[leveldir_nr])-1)
129       level_nr = LEVELDIR_SIZE(leveldir[leveldir_nr])-1;
130
131     if (level_nr>player.handicap && level_nr<leveldir[leveldir_nr].num_ready)
132     {
133       if (x==11 || leveldir[leveldir_nr].num_free==0)
134         level_nr = player.handicap;
135       else
136         level_nr = leveldir[leveldir_nr].num_ready;
137     }
138
139     DrawTextExt(drawto,gc,SX+352,SY+96, int2str(level_nr,3),FS_BIG,
140                 (level_nr<leveldir[leveldir_nr].num_ready ?FC_RED :FC_YELLOW));
141     DrawTextExt(window,gc,SX+352,SY+96, int2str(level_nr,3),FS_BIG,
142                 (level_nr<leveldir[leveldir_nr].num_ready ?FC_RED :FC_YELLOW));
143
144     LoadLevel(level_nr);
145     DrawMicroLevel(MICROLEV_XPOS,MICROLEV_YPOS);
146
147     TapeErase();
148     LoadLevelTape(level_nr);
149     DrawCompleteVideoDisplay();
150   }
151   else if (x==1 && y>=3 && y<=10)
152   {
153     if (button)
154     {
155       if (y!=choice)
156       {
157         DrawGraphic(0,y-1,GFX_KUGEL_ROT);
158         DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
159       }
160       choice = y;
161     }
162     else
163     {
164       if (y==3)
165       {
166         game_status = TYPENAME;
167         HandleTypeName(strlen(player.alias_name),0);
168       }
169       else if (y==4)
170       {
171         if (num_leveldirs)
172         {
173           game_status = CHOOSELEVEL;
174           DrawChooseLevel();
175           redraw = TRUE;
176         }
177       }
178       else if (y==5)
179       {
180         game_status = HALLOFFAME;
181         DrawHallOfFame(-1);
182         redraw = TRUE;
183       }
184       else if (y==6)
185       {
186         game_status = LEVELED;
187         DrawLevelEd();
188         redraw = TRUE;
189       }
190       else if (y==7)
191       {
192         game_status = HELPSCREEN;
193         DrawHelpScreen();
194         redraw = TRUE;
195       }
196       else if (y==8)
197       {
198         if (autorecord_on && !tape.playing)
199           TapeInitRecording();
200
201         game_status = PLAYING;
202         InitGame();
203         redraw = TRUE;
204       }
205       else if (y==9)
206       {
207         game_status = SETUP;
208         DrawSetupScreen();
209         redraw = TRUE;
210       }
211       else if (y==10)
212       {
213         if (AreYouSure("Do you really want to quit ?",AYS_ASK|AYS_STAY_CLOSED))
214           game_status = EXITGAME;
215       }
216     }
217   }
218   BackToFront();
219
220   out:
221
222   if (game_status==MAINMENU)
223     DoAnimation();
224 }
225
226 #define MAX_HELPSCREEN_ELS      10
227 #define HA_NEXT                 -999
228 #define HA_END                  -1000
229
230 static long helpscreen_state;
231 static int helpscreen_step[MAX_HELPSCREEN_ELS];
232 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
233 static int helpscreen_delay[MAX_HELPSCREEN_ELS];
234 static int helpscreen_action[] =
235 {
236   GFX_ERDREICH,1,100,                                           HA_NEXT,
237   GFX_LEERRAUM,1,100,                                           HA_NEXT,
238   GFX_MORAST_LEER,1,100,                                        HA_NEXT,
239   GFX_BETON,1,100,                                              HA_NEXT,
240   GFX_MAUERWERK,1,100,                                          HA_NEXT,
241   GFX_FELSBODEN,1,100,                                          HA_NEXT,
242   GFX_EDELSTEIN,2,5,                                            HA_NEXT,
243   GFX_DIAMANT,2,5,                                              HA_NEXT,
244   GFX_FELSBROCKEN,4,5,                                          HA_NEXT,
245   GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10,         HA_NEXT,
246   GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10,  HA_NEXT,
247   GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10,     HA_NEXT,
248   GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10,       HA_NEXT,
249   GFX_GEBLUBBER,4,4,                                            HA_NEXT,
250   GFX_SCHLUESSEL1,4,33,                                         HA_NEXT,
251   GFX_PFORTE1,4,33,                                             HA_NEXT,
252   GFX_PFORTE1X,4,33,                                            HA_NEXT,
253   GFX_DYNAMIT_AUS,1,100,                                        HA_NEXT,
254   GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10,        HA_NEXT,
255   GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
256   GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
257   GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
258   GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3,      HA_NEXT,
259   GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
260   GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
261   GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
262   GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1,         HA_NEXT,
263   GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
264   GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
265   GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
266   GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3,         HA_NEXT,
267   GFX_MAMPFER+0,4,0, GFX_MAMPFER+3,1,0, GFX_MAMPFER+2,1,0,
268   GFX_MAMPFER+1,1,0,                                            HA_NEXT,
269   GFX_ZOMBIE+0,4,0, GFX_ZOMBIE+3,1,0, GFX_ZOMBIE+2,1,0,
270   GFX_ZOMBIE+1,1,0,                                             HA_NEXT,
271   GFX_ABLENK,4,1,                                               HA_NEXT,
272   GFX_AMOEBE_LEBT,4,40,                                         HA_NEXT,
273   GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50,                   HA_NEXT,
274   GFX_SIEB_LEER,4,2,                                            HA_NEXT,
275   HA_END
276 };
277 static char *helpscreen_eltext[][2] =
278 {
279   "Normal sand:", "You can dig through it",
280   "Empty field:", "You can walk through it",
281   "Quicksand: You cannot pass it,", "but rocks can fall though it",
282   "Massive Wall:", "Nothing can go through it",
283   "Normal Wall: You can't go through", "it, but you can bomb it away",
284   "Old Wall: Like normal wall, but", "some things can fall down from it",
285   "Emerald: You must collect enough of", "them to finish a level",
286   "Diamond: Counts as 3 emeralds;", "Can be destroyed by rocks",
287   "Rock: Smashes several things;", "Can be moved by the player",
288   "Bomb: You can move it, but be", "careful when dropping it",
289   "Nut: Throw a rock on it to open it;", "Each nut contains an emerald",
290   "Wall with an Emerald inside:", "Bomb the wall away to get it",
291   "Wall with a Diamond inside:", "Bomb the wall away to get it",
292   "Acid: Destroys everything that", "falls or walks into it",
293   "Key: Opens the door that has the", "same color (red/yellow/green/blue)",
294   "Door: Can be opened by the key", "with the same color",
295   "Door: You have to find out the", "right color of the key for it",
296   "Dynamite: Collect it and use it to", "destroy walls or kill enemies",
297   "Dynamite: This one explodes after", "a few seconds",
298   "Spaceship: Moves at the left side", "of walls; don't touch it!",
299   "Bug: Moves at the right side of", "walls; don't touch it!",
300   "Pacman: Eats the amoeba and you,", "if you're not careful",
301   "Cruncher: Eats diamonds and you,", "if you're not careful",
302   "Robot: Tries to kill the player", "",
303   "Magic Wheel: Touch it to get rid of", "the robots for some seconds",
304   "Living Amoeba: Grows through empty", "fields, sand and quicksand",
305   "Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships",
306   "Magic Wall: Changes rocks, emeralds", "and diamonds when they pass it",
307 };
308 static int num_helpscreen_els = sizeof(helpscreen_eltext)/(2*sizeof(char *));
309
310 static char *helpscreen_music[][3] =
311 {
312   "Alchemy",                    "Ian Boddy",            "Drive",
313   "The Chase",                  "Propaganda",           "A Secret Wish",
314   "Network 23",                 "Tangerine Dream",      "Exit",
315   "Czardasz",                   "Robert Pieculewicz",   "Czardasz",
316   "21st Century Common Man",    "Tangerine Dream",      "Tyger",
317   "Voyager",                    "The Alan Parsons Project","Pyramid",
318   "Twilight Painter",           "Tangerine Dream",      "Heartbreakers"
319 };
320 static int helpscreen_musicpos;
321
322 void DrawHelpScreenElAction(int start)
323 {
324   int i = 0, j = 0;
325   int frame, delay, graphic;
326   int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
327
328   while(helpscreen_action[j] != HA_END)
329   {
330     if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
331       break;
332     else if (i<start || helpscreen_delay[i-start])
333     {
334       if (i>=start && helpscreen_delay[i-start])
335         helpscreen_delay[i-start]--;
336
337       while(helpscreen_action[j] != HA_NEXT)
338         j++;
339       j++;
340       i++;
341       continue;
342     }
343
344     j += 3*helpscreen_step[i-start];
345     graphic = helpscreen_action[j++];
346
347     if (helpscreen_frame[i-start])
348     {
349       frame = helpscreen_action[j++] - helpscreen_frame[i-start];
350       helpscreen_frame[i-start]--;
351     }
352     else
353     {
354       frame = 0;
355       helpscreen_frame[i-start] = helpscreen_action[j++]-1;
356     }
357
358     delay = helpscreen_action[j++];
359     helpscreen_delay[i-start] = delay;
360
361     if (helpscreen_action[j] == HA_NEXT)
362     {
363       if (!helpscreen_frame[i-start])
364         helpscreen_step[i-start] = 0;
365     }
366     else
367     {
368       if (!helpscreen_frame[i-start])
369         helpscreen_step[i-start]++;
370       while(helpscreen_action[j] != HA_NEXT)
371         j++;
372     }
373     j++;
374
375     DrawGraphicExtHiRes(drawto,gc,xstart,ystart+(i-start)*ystep,
376                         graphic+frame);
377     i++;
378   }
379
380   redraw_tiles += 28;
381   for(i=2;i<16;i++)
382     redraw[0][i] = redraw[1][i] = TRUE;
383   redraw_mask |= REDRAW_TILES;
384 }
385
386 void DrawHelpScreenElText(int start)
387 {
388   int i;
389   int xstart = SX+56, ystart = SY+65+2*32, ystep = TILEY+4;
390   char text[FULL_SXSIZE/FONT2_XSIZE+10];
391
392   ClearWindow();
393   DrawText(SX+16, SY+8,  "ROCKS'N'DIAMONDS",FS_BIG,FC_YELLOW);
394   DrawText(SX+25+16, SY+46, "Copyright ^1995 by Holger Schemel",
395            FS_SMALL,FC_RED);
396
397   sprintf(text,"The game elements:");
398   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100,
399            text,FS_SMALL,FC_GREEN);
400
401   for(i=start;i<start+MAX_HELPSCREEN_ELS && i<num_helpscreen_els;i++)
402   {
403     DrawText(xstart,ystart+(i-start)*ystep+(*helpscreen_eltext[i][1] ? 0 : 8),
404              helpscreen_eltext[i][0],FS_SMALL,FC_YELLOW);
405     DrawText(xstart,ystart+(i-start)*ystep+16,
406              helpscreen_eltext[i][1],FS_SMALL,FC_YELLOW);
407   }
408
409   sprintf(text,"Press any key or button for next page");
410   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20,
411            text,FS_SMALL,FC_BLUE);
412 }
413
414 void DrawHelpScreenMusicText(int num)
415 {
416   int ystart = 150, ystep = 30;
417   char text[FULL_SXSIZE/FONT2_XSIZE+10];
418
419   FadeSounds();
420   ClearWindow();
421   DrawText(SX+16, SY+8,  "ROCKS'N'DIAMONDS",FS_BIG,FC_YELLOW);
422   DrawText(SX+25+16, SY+46, "Copyright ^1995 by Holger Schemel",
423            FS_SMALL,FC_RED);
424
425   sprintf(text,"The game background music loops:");
426   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100,
427            text,FS_SMALL,FC_GREEN);
428
429   sprintf(text,"Excerpt from");
430   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+0*ystep,
431            text,FS_SMALL,FC_YELLOW);
432   sprintf(text,"%c%s%c",'\"',helpscreen_music[num][0],'\"');
433   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+1*ystep,
434            text,FS_SMALL,FC_RED);
435   sprintf(text,"by");
436   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+2*ystep,
437            text,FS_SMALL,FC_YELLOW);
438   sprintf(text,"%s",helpscreen_music[num][1]);
439   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+3*ystep,
440            text,FS_SMALL,FC_RED);
441   sprintf(text,"from the album");
442   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep,
443            text,FS_SMALL,FC_YELLOW);
444   sprintf(text,"%c%s%c",'\"',helpscreen_music[num][2],'\"');
445   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+5*ystep,
446            text,FS_SMALL,FC_RED);
447
448   sprintf(text,"Press any key or button for next page");
449   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20,
450            text,FS_SMALL,FC_BLUE);
451
452   PlaySoundLoop(background_loop[num]);
453 }
454
455 void DrawHelpScreenCreditsText()
456 {
457   int ystart = 150, ystep = 30;
458   char text[FULL_SXSIZE/FONT2_XSIZE+10];
459
460   FadeSounds();
461   ClearWindow();
462   DrawText(SX+16, SY+8,  "ROCKS'N'DIAMONDS",FS_BIG,FC_YELLOW);
463   DrawText(SX+25+16, SY+46, "Copyright ^1995 by Holger Schemel",
464            FS_SMALL,FC_RED);
465
466   sprintf(text,"Program information:");
467   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100,
468            text,FS_SMALL,FC_GREEN);
469
470   sprintf(text,"This game is Freeware!");
471   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+0*ystep,
472            text,FS_SMALL,FC_YELLOW);
473   sprintf(text,"If you like it, send e-mail to:");
474   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+1*ystep,
475            text,FS_SMALL,FC_YELLOW);
476   sprintf(text,"aeglos@valinor.owl.de");
477   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+2*ystep,
478            text,FS_SMALL,FC_RED);
479   sprintf(text,"or SnailMail to:");
480   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+3*ystep,
481            text,FS_SMALL,FC_YELLOW);
482   sprintf(text,"Holger Schemel");
483   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep,
484            text,FS_SMALL,FC_RED);
485   sprintf(text,"Sennehof 28");
486   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+20,
487            text,FS_SMALL,FC_RED);
488   sprintf(text,"33659 Bielefeld");
489   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+40,
490            text,FS_SMALL,FC_RED);
491   sprintf(text,"Germany");
492   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+60,
493            text,FS_SMALL,FC_RED);
494
495   sprintf(text,"Press any key or button for main menu");
496   DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20,
497            text,FS_SMALL,FC_BLUE);
498 }
499
500 void DrawHelpScreen()
501 {
502   int i;
503
504   CloseDoor(DOOR_CLOSE_2);
505
506   for(i=0;i<MAX_HELPSCREEN_ELS;i++)
507     helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
508   helpscreen_musicpos = 0;
509   helpscreen_state = 0;
510   DrawHelpScreenElText(0);
511   DrawHelpScreenElAction(0);
512
513   FadeToFront();
514   InitAnimation();
515   PlaySoundLoop(SND_RHYTHMLOOP);
516 }
517
518 void HandleHelpScreen(int button)
519 {
520   static long hs_delay = 0;
521   int num_helpscreen_els_pages =
522     (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
523   int button_released = !button;
524   int i;
525
526   if (button_released)
527   {
528     if (helpscreen_state<num_helpscreen_els_pages-1)
529     {
530       for(i=0;i<MAX_HELPSCREEN_ELS;i++)
531         helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
532       helpscreen_state++;
533       DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
534       DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
535     }
536     else if (helpscreen_state<num_helpscreen_els_pages+num_bg_loops-1)
537     {
538       helpscreen_state++;
539       DrawHelpScreenMusicText(helpscreen_state-num_helpscreen_els_pages);
540     }
541     else if (helpscreen_state==num_helpscreen_els_pages+num_bg_loops-1)
542     {
543       helpscreen_state++;
544       DrawHelpScreenCreditsText();
545     }
546     else
547     {
548       FadeSounds();
549       DrawMainMenu();
550       game_status = MAINMENU;
551     }
552   }
553   else
554   {
555     if (DelayReached(&hs_delay,3))
556     {
557       if (helpscreen_state<num_helpscreen_els_pages)
558         DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
559     }
560     DoAnimation();
561   }
562
563   BackToFront();
564 }
565
566 void CheckCheat()
567 {
568   int old_handicap = player.handicap;
569
570   if (!strcmp(player.alias_name,"Artsoft"))
571     player.handicap = MAX(0,leveldir[leveldir_nr].num_ready-1);
572
573   if (player.handicap != old_handicap)
574   {
575     SavePlayerInfo(PLAYER_LEVEL);
576     level_nr = player.handicap;
577   }
578 }
579
580 void HandleTypeName(int newxpos, KeySym key)
581 {
582   static int xpos = 0, ypos = 2;
583   unsigned char ascii;
584
585   if (newxpos)
586   {
587     xpos = newxpos;
588     DrawText(SX+6*32,SY+ypos*32,player.alias_name,FS_BIG,FC_YELLOW);
589     DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
590     return;
591   }
592
593   if ((key>=XK_A && key<=XK_Z) || (key>=XK_a && key<=XK_z && 
594       xpos<MAX_NAMELEN-1))
595   {
596     if (key>=XK_A && key<=XK_Z)
597       ascii = 'A'+(char)(key-XK_A);
598     if (key>=XK_a && key<=XK_z)
599       ascii = 'a'+(char)(key-XK_a);
600     player.alias_name[xpos] = ascii;
601     player.alias_name[xpos+1] = 0;
602     xpos++;
603     DrawTextExt(drawto,gc,SX+6*32,SY+ypos*32,
604                 player.alias_name,FS_BIG,FC_YELLOW);
605     DrawTextExt(window,gc,SX+6*32,SY+ypos*32,
606                 player.alias_name,FS_BIG,FC_YELLOW);
607     DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
608   }
609   else if (key==XK_Delete && xpos>0)
610   {
611     player.alias_name[xpos] = 0;
612     xpos--;
613     DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
614     DrawGraphic(xpos+7,ypos,GFX_LEERRAUM);
615   }
616   else if (key==XK_Return && xpos>0)
617   {
618     DrawText(SX+6*32,SY+ypos*32,player.alias_name,FS_BIG,FC_RED);
619     DrawGraphic(xpos+6,ypos,GFX_LEERRAUM);
620     SavePlayerInfo(PLAYER_SETUP);
621     CheckCheat();
622
623     game_status = MAINMENU;
624     DrawMainMenu();
625   }
626   BackToFront();
627 }
628
629 void DrawChooseLevel()
630 {
631   int i;
632
633   CloseDoor(DOOR_CLOSE_2);
634
635   ClearWindow();
636   DrawText(SX,SY,"Level Directories",FS_BIG,FC_GREEN);
637   for(i=0;i<num_leveldirs;i++)
638   {
639     DrawText(SX+32,SY+(i+2)*32,leveldir[i].name,FS_BIG,FC_YELLOW);
640     DrawGraphic(0,i+2,GFX_KUGEL_BLAU);
641   }
642
643   FadeToFront();
644   InitAnimation();
645   HandleChooseLevel(0,0,0,0,MB_MENU_MARK);
646 }
647
648 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
649 {
650   static int choice = 3;
651   static int redraw = TRUE;
652   int x = (mx+32-SX)/32, y = (my+32-SY)/32;
653
654   if (redraw)
655   {
656     DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
657     redraw = FALSE;
658   }
659
660   if (dx || dy)
661   {
662     if (dy)
663     {
664       x = 1;
665       y = choice+dy;
666     }
667     else
668       x = y = 0;
669
670     if (y<3)
671       y = 3;
672     else if (y>num_leveldirs+2)
673       y = num_leveldirs+2;
674   }
675
676   if (!mx && !my && !dx && !dy)
677   {
678     x = 1;
679     y = choice;
680   }
681
682   if (x==1 && y>=3 && y<=num_leveldirs+2)
683   {
684     if (button)
685     {
686       if (y!=choice)
687       {
688         DrawGraphic(0,y-1,GFX_KUGEL_ROT);
689         DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
690       }
691       choice = y;
692     }
693     else
694     {
695       player.leveldir_nr = leveldir_nr = y-3;
696       LoadPlayerInfo(PLAYER_LEVEL);
697       SavePlayerInfo(PLAYER_SETUP);
698       CheckCheat();
699
700       game_status = MAINMENU;
701       DrawMainMenu();
702       redraw = TRUE;
703     }
704   }
705   BackToFront();
706
707   if (game_status==CHOOSELEVEL)
708     DoAnimation();
709 }
710
711 void DrawHallOfFame(int pos)
712 {
713   int y;
714   char txt[40];
715
716   CloseDoor(DOOR_CLOSE_2);
717
718   if (pos<0) 
719     LoadScore(level_nr);
720   ClearWindow();
721   DrawText(SX+64,SY+10,"Hall Of Fame",FS_BIG,FC_YELLOW);
722   sprintf(txt,"HighScores of Level %d",level_nr);
723   DrawText(SX+256-strlen(txt)*7,SY+48,txt,FS_SMALL,FC_RED);
724   for(y=0;y<MAX_SCORE_ENTRIES;y++)
725   {
726     DrawText(SX,SY+64+y*32,".................",FS_BIG,
727              (y==pos ? FC_RED : FC_GREEN));
728     DrawText(SX,SY+64+y*32,highscore[y].Name,FS_BIG,
729              (y==pos ? FC_RED : FC_GREEN));
730     DrawText(SX+12*32,SY+64+y*32,
731              int2str(highscore[y].Score,5),FS_BIG,
732              (y==pos ? FC_RED : FC_GREEN));
733   }
734
735   FadeToFront();
736   InitAnimation();
737   PlaySound(SND_HALLOFFAME);
738 }
739
740 void HandleHallOfFame(int button)
741 {
742   int button_released = !button;
743
744   if (button_released)
745   {
746     FadeSound(SND_HALLOFFAME);
747     game_status = MAINMENU;
748     DrawMainMenu();
749     BackToFront();
750   }
751   else
752     DoAnimation();
753 }
754
755 void DrawSetupScreen()
756 {
757   int i;
758
759   CloseDoor(DOOR_CLOSE_2);
760
761   ClearWindow();
762   DrawText(SX+16, SY+16,  "SETUP",FS_BIG,FC_YELLOW);
763   DrawText(SX+32, SY+2*32,"Sound:",FS_BIG,FC_GREEN);
764   DrawText(SX+32, SY+3*32,"Sound loops:",FS_BIG,FC_GREEN);
765   DrawText(SX+32, SY+4*32,"Game music:",FS_BIG,FC_GREEN);
766   DrawText(SX+32, SY+5*32,"Toons:",FS_BIG,FC_GREEN);
767   DrawText(SX+32, SY+6*32,"Buffered gfx:",FS_BIG,FC_GREEN);
768   DrawText(SX+32, SY+7*32,"Fading:",FS_BIG,FC_GREEN);
769   DrawText(SX+32, SY+8*32,"Quick Doors:",FS_BIG,FC_GREEN);
770   DrawText(SX+32, SY+9*32,"Auto-Record:",FS_BIG,FC_GREEN);
771   DrawText(SX+32, SY+10*32,"Joystick:",FS_BIG,FC_GREEN);
772   DrawText(SX+32, SY+11*32,"Cal. Joystick",FS_BIG,FC_GREEN);
773
774   DrawText(SX+32, SY+13*32,"Exit",FS_BIG,FC_GREEN);
775   DrawText(SX+32, SY+14*32,"Save and exit",FS_BIG,FC_GREEN);
776
777   if (SETUP_SOUND_ON(player.setup))
778     DrawText(SX+14*32, SY+2*32,"on",FS_BIG,FC_YELLOW);
779   else
780     DrawText(SX+14*32, SY+2*32,"off",FS_BIG,FC_BLUE);
781
782   if (SETUP_SOUND_LOOPS_ON(player.setup))
783     DrawText(SX+14*32, SY+3*32,"on",FS_BIG,FC_YELLOW);
784   else
785     DrawText(SX+14*32, SY+3*32,"off",FS_BIG,FC_BLUE);
786
787   if (SETUP_SOUND_MUSIC_ON(player.setup))
788     DrawText(SX+14*32, SY+4*32,"on",FS_BIG,FC_YELLOW);
789   else
790     DrawText(SX+14*32, SY+4*32,"off",FS_BIG,FC_BLUE);
791
792   if (SETUP_TOONS_ON(player.setup))
793     DrawText(SX+14*32, SY+5*32,"on",FS_BIG,FC_YELLOW);
794   else
795     DrawText(SX+14*32, SY+5*32,"off",FS_BIG,FC_BLUE);
796
797   if (!SETUP_DIRECT_DRAW_ON(player.setup))
798     DrawText(SX+14*32, SY+6*32,"on",FS_BIG,FC_YELLOW);
799   else
800     DrawText(SX+14*32, SY+6*32,"off",FS_BIG,FC_BLUE);
801
802   if (SETUP_FADING_ON(player.setup))
803     DrawText(SX+14*32, SY+7*32,"on",FS_BIG,FC_YELLOW);
804   else
805     DrawText(SX+14*32, SY+7*32,"off",FS_BIG,FC_BLUE);
806
807   if (SETUP_QUICK_DOORS_ON(player.setup))
808     DrawText(SX+14*32, SY+8*32,"on",FS_BIG,FC_YELLOW);
809   else
810     DrawText(SX+14*32, SY+8*32,"off",FS_BIG,FC_BLUE);
811
812   if (SETUP_RECORD_EACH_GAME_ON(player.setup))
813     DrawText(SX+14*32, SY+9*32,"on",FS_BIG,FC_YELLOW);
814   else
815     DrawText(SX+14*32, SY+9*32,"off",FS_BIG,FC_BLUE);
816
817   if (SETUP_2ND_JOYSTICK_ON(player.setup))
818     DrawText(SX+14*32, SY+10*32,"2nd",FS_BIG,FC_YELLOW);
819   else
820     DrawText(SX+14*32, SY+10*32,"1st",FS_BIG,FC_YELLOW);
821
822   for(i=2;i<15;i++)
823     if (i!=12)
824       DrawGraphic(0,i,GFX_KUGEL_BLAU);
825
826   FadeToFront();
827   InitAnimation();
828   HandleSetupScreen(0,0,0,0,MB_MENU_MARK);
829 }
830
831 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
832 {
833   static int choice = 3;
834   static int redraw = TRUE;
835   int x = (mx+32-SX)/32, y = (my+32-SY)/32;
836
837   if (redraw)
838   {
839     DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
840     redraw = FALSE;
841   }
842
843   if (dx || dy)
844   {
845     if (dy)
846     {
847       x = 1;
848       y = choice+dy;
849     }
850     else
851       x = y = 0;
852
853     if (y==13)
854       y = (dy>0 ? 14 : 12);
855
856     if (y<3)
857       y = 3;
858     else if (y>15)
859       y = 15;
860   }
861
862   if (!mx && !my && !dx && !dy)
863   {
864     x = 1;
865     y = choice;
866   }
867
868   if (x==1 && y>=3 && y<=15 && y!=13)
869   {
870     if (button)
871     {
872       if (y!=choice)
873       {
874         DrawGraphic(0,y-1,GFX_KUGEL_ROT);
875         DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
876       }
877       choice = y;
878     }
879     else
880     {
881       int yy = y-1;
882
883       if (y==3 && sound_status==SOUND_AVAILABLE)
884       {
885         if (SETUP_SOUND_ON(player.setup))
886           DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
887         else
888           DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
889         player.setup ^= SETUP_SOUND;
890       }
891       else if (y==4 && sound_loops_allowed)
892       {
893         if (SETUP_SOUND_LOOPS_ON(player.setup))
894           DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
895         else
896           DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
897         player.setup ^= SETUP_SOUND_LOOPS;
898       }
899       else if (y==5 && sound_loops_allowed)
900       {
901         if (SETUP_SOUND_MUSIC_ON(player.setup))
902           DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
903         else
904           DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
905         player.setup ^= SETUP_SOUND_MUSIC;
906       }
907       else if (y==6)
908       {
909         if (SETUP_TOONS_ON(player.setup))
910           DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
911         else
912           DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
913         player.setup ^= SETUP_TOONS;
914       }
915       else if (y==7)
916       {
917         if (!SETUP_DIRECT_DRAW_ON(player.setup))
918           DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
919         else
920           DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
921         player.setup ^= SETUP_DIRECT_DRAW;
922       }
923       else if (y==8)
924       {
925         if (SETUP_FADING_ON(player.setup))
926           DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
927         else
928           DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
929         player.setup ^= SETUP_FADING;
930       }
931       else if (y==9)
932       {
933         if (SETUP_QUICK_DOORS_ON(player.setup))
934           DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
935         else
936           DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
937         player.setup ^= SETUP_QUICK_DOORS;
938       }
939       else if (y==10)
940       {
941         if (SETUP_RECORD_EACH_GAME_ON(player.setup))
942           DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
943         else
944           DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
945         player.setup ^= SETUP_RECORD_EACH_GAME;
946       }
947       else if (y==11)
948       {
949         if (SETUP_2ND_JOYSTICK_ON(player.setup))
950           DrawText(SX+14*32, SY+yy*32,"1st",FS_BIG,FC_YELLOW);
951         else
952           DrawText(SX+14*32, SY+yy*32,"2nd",FS_BIG,FC_YELLOW);
953         player.setup ^= SETUP_2ND_JOYSTICK;
954       }
955       else if (y==12)
956       {
957         CalibrateJoystick();
958         redraw = TRUE;
959       }
960       else if (y==14 || y==15)
961       {
962         if (y==15)
963         {
964           SavePlayerInfo(PLAYER_SETUP);
965           SaveJoystickData();
966         }
967
968         game_status = MAINMENU;
969         DrawMainMenu();
970         redraw = TRUE;
971       }
972     }
973   }
974   BackToFront();
975
976   if (game_status==SETUP)
977     DoAnimation();
978 }
979
980 void CalibrateJoystick()
981 {
982 #ifdef __FreeBSD__
983   struct joystick joy_ctrl;
984 #else
985   struct joystick_control
986   {
987     int buttons;
988     int x;
989     int y;
990   } joy_ctrl;
991 #endif
992
993   int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle;
994   int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle;
995
996   if (joystick_status==JOYSTICK_OFF)
997     goto error_out;
998
999   ClearWindow();
1000   DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1001   DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
1002   DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1003   BackToFront();
1004
1005 #ifdef __FreeBSD__
1006   joy_ctrl.b1 = joy_ctrl.b2 = 0;
1007 #else
1008   joy_ctrl.buttons = 0;
1009 #endif
1010   while(Joystick() & JOY_BUTTON);
1011 #ifdef __FreeBSD__
1012   while(!(joy_ctrl.b1||joy_ctrl.b2))
1013 #else
1014   while(!joy_ctrl.buttons)
1015 #endif
1016   {
1017     if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1018     {
1019       joystick_status=JOYSTICK_OFF;
1020       goto error_out;
1021     }
1022     Delay(10000);
1023   }
1024
1025   new_joystick_xleft = joy_ctrl.x;
1026   new_joystick_yupper = joy_ctrl.y;
1027
1028   ClearWindow();
1029   DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1030   DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
1031   DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1032   BackToFront();
1033
1034 #ifdef __FreeBSD__
1035   joy_ctrl.b1 = joy_ctrl.b2 = 0;
1036 #else
1037   joy_ctrl.buttons = 0;
1038 #endif
1039   while(Joystick() & JOY_BUTTON);
1040 #ifdef __FreeBSD__
1041   while(!(joy_ctrl.b1||joy_ctrl.b2))
1042 #else
1043   while(!joy_ctrl.buttons)
1044 #endif
1045   {
1046     if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1047     {
1048       joystick_status=JOYSTICK_OFF;
1049       goto error_out;
1050     }
1051     Delay(10000);
1052   }
1053
1054   new_joystick_xright = joy_ctrl.x;
1055   new_joystick_ylower = joy_ctrl.y;
1056
1057   ClearWindow();
1058   DrawText(SX+32, SY+16+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
1059   DrawText(SX+16, SY+16+8*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1060   BackToFront();
1061
1062 #ifdef __FreeBSD__
1063   joy_ctrl.b1 = joy_ctrl.b2 = 0;
1064 #else
1065   joy_ctrl.buttons = 0;
1066 #endif
1067   while(Joystick() & JOY_BUTTON);
1068 #ifdef __FreeBSD__
1069   while(!(joy_ctrl.b1||joy_ctrl.b2))
1070 #else
1071   while(!joy_ctrl.buttons)
1072 #endif
1073   {
1074     if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1075     {
1076       joystick_status=JOYSTICK_OFF;
1077       goto error_out;
1078     }
1079     Delay(10000);
1080   }
1081
1082   new_joystick_xmiddle = joy_ctrl.x;
1083   new_joystick_ymiddle = joy_ctrl.y;
1084
1085   joystick[joystick_nr].xleft = new_joystick_xleft;
1086   joystick[joystick_nr].yupper = new_joystick_yupper;
1087   joystick[joystick_nr].xright = new_joystick_xright;
1088   joystick[joystick_nr].ylower = new_joystick_ylower;
1089   joystick[joystick_nr].xmiddle = new_joystick_xmiddle;
1090   joystick[joystick_nr].ymiddle = new_joystick_ymiddle;
1091
1092   CheckJoystickData();
1093
1094   DrawSetupScreen();
1095   while(Joystick() & JOY_BUTTON);
1096   return;
1097
1098   error_out:
1099
1100   ClearWindow();
1101   DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
1102   DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
1103   Delay(3000000);
1104   DrawSetupScreen();
1105 }
1106
1107 void HandleVideoButtons(int mx, int my, int button)
1108 {
1109   if (game_status!=MAINMENU && game_status!=PLAYING)
1110     return;
1111
1112   switch(CheckVideoButtons(mx,my,button))
1113   {
1114     case BUTTON_VIDEO_EJECT:
1115       TapeStop();
1116       if (!TAPE_IS_EMPTY(tape))
1117         SaveLevelTape(tape.level_nr);
1118       else
1119         AreYouSure("Tape is empty !",AYS_CONFIRM);
1120       DrawCompleteVideoDisplay();
1121       break;
1122     case BUTTON_VIDEO_STOP:
1123       TapeStop();
1124       break;
1125     case BUTTON_VIDEO_PAUSE:
1126       TapeTogglePause();
1127       break;
1128     case BUTTON_VIDEO_REC:
1129       if (tape.pausing)
1130         TapeTogglePause();
1131       else if (game_status==MAINMENU)
1132         TapeInitRecording();
1133       break;
1134     case BUTTON_VIDEO_PLAY:
1135       if (tape.pausing)
1136         TapeTogglePause();
1137       else if (game_status==MAINMENU)
1138         TapeInitPlaying();
1139       break;
1140     default:
1141       break;
1142   }
1143 }
1144
1145 void HandleSoundButtons(int mx, int my, int button)
1146 {
1147   if (game_status!=PLAYING)
1148     return;
1149
1150   switch(CheckSoundButtons(mx,my,button))
1151   {
1152     case BUTTON_SOUND_MUSIC:
1153       if (sound_music_on)
1154       { 
1155         sound_music_on = FALSE;
1156         player.setup &= ~SETUP_SOUND_MUSIC;
1157         FadeSound(background_loop[level_nr % num_bg_loops]);
1158         DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
1159       }
1160       else if (sound_loops_allowed)
1161       { 
1162         sound_music_on = TRUE;
1163         player.setup |= SETUP_SOUND_MUSIC;
1164         PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
1165         DrawSoundDisplay(BUTTON_SOUND_MUSIC_ON);
1166       }
1167       else
1168         DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
1169       break;
1170     case BUTTON_SOUND_LOOPS:
1171       if (sound_loops_on)
1172       { 
1173         sound_loops_on = FALSE;
1174         player.setup &= ~SETUP_SOUND_LOOPS;
1175         DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
1176       }
1177       else if (sound_loops_allowed)
1178       { 
1179         sound_loops_on = TRUE;
1180         player.setup |= SETUP_SOUND_LOOPS;
1181         DrawSoundDisplay(BUTTON_SOUND_LOOPS_ON);
1182       }
1183       else
1184         DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
1185       break;
1186     case BUTTON_SOUND_SOUND:
1187       if (sound_on)
1188       { 
1189         sound_on = FALSE;
1190         player.setup &= ~SETUP_SOUND;
1191         DrawSoundDisplay(BUTTON_SOUND_SOUND_OFF);
1192       }
1193       else if (sound_status==SOUND_AVAILABLE)
1194       { 
1195         sound_on = TRUE;
1196         player.setup |= SETUP_SOUND;
1197         DrawSoundDisplay(BUTTON_SOUND_SOUND_ON);
1198       }
1199       else
1200         DrawSoundDisplay(BUTTON_SOUND_SOUND_OFF);
1201       break;
1202     default:
1203       break;
1204   }
1205 }
1206
1207 void HandleGameButtons(int mx, int my, int button)
1208 {
1209   if (game_status!=PLAYING)
1210     return;
1211
1212   switch(CheckGameButtons(mx,my,button))
1213   {
1214     case BUTTON_GAME_STOP:
1215       if (AreYouSure("Do you really want to quit the game ?",
1216                       AYS_ASK | AYS_STAY_CLOSED))
1217       { 
1218         game_status = MAINMENU;
1219         DrawMainMenu();
1220       }
1221       else
1222         OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
1223       break;
1224     case BUTTON_GAME_PAUSE:
1225       if (tape.pausing)
1226       {
1227         tape.pausing = FALSE;
1228         DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
1229       }
1230       else
1231       {
1232         tape.pausing = TRUE;
1233         DrawVideoDisplay(VIDEO_STATE_PAUSE_ON,0);
1234       }
1235       break;
1236     case BUTTON_GAME_PLAY:
1237       if (tape.pausing)
1238       {
1239         tape.pausing = FALSE;
1240         DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
1241       }
1242       break;
1243     default:
1244       break;
1245   }
1246 }