1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
30 extern unsigned char get_ascii(KeySym);
35 int x1 = SX+(SXSIZE - strlen(GAMETITLE_STRING) * FONT1_XSIZE) / 2;
37 int x2 = SX+(SXSIZE - strlen(COPYRIGHT_STRING) * FONT2_XSIZE) / 2;
40 DrawText(x1,y1, GAMETITLE_STRING, FS_BIG, FC_YELLOW);
41 DrawText(x2,y2, COPYRIGHT_STRING, FS_SMALL, FC_RED);
54 DrawText(SX + 32, SY + 2*32, "Name:", FS_BIG, FC_GREEN);
55 DrawText(SX + 6*32, SY + 2*32, setup.alias_name, FS_BIG, FC_RED);
56 DrawText(SX + 32, SY + 3*32, "Level:", FS_BIG, FC_GREEN);
57 DrawText(SX + 11*32, SY + 3*32, int2str(level_nr,3), FS_BIG,
58 (level_nr<leveldir[leveldir_nr].levels ? FC_RED : FC_YELLOW));
59 DrawText(SX + 32, SY + 4*32, "Hall Of Fame", FS_BIG, FC_GREEN);
60 DrawText(SX + 32, SY + 5*32, "Level Creator", FS_BIG, FC_GREEN);
61 DrawText(SY + 32, SY + 6*32, "Info Screen", FS_BIG, FC_GREEN);
62 DrawText(SX + 32, SY + 7*32, "Start Game", FS_BIG, FC_GREEN);
63 DrawText(SX + 32, SY + 8*32, "Setup", FS_BIG, FC_GREEN);
64 DrawText(SX + 32, SY + 9*32, "Quit", FS_BIG, FC_GREEN);
66 DrawMicroLevel(MICROLEV_XPOS,MICROLEV_YPOS);
69 DrawGraphic(0,i,GFX_KUGEL_BLAU);
70 DrawGraphic(10,3,GFX_PFEIL_L);
71 DrawGraphic(14,3,GFX_PFEIL_R);
73 DrawText(SX+40+16,SY+326,"A Game by Artsoft Entertainment",FS_SMALL,FC_BLUE);
76 DrawText(SX+40+16,SY+344,"Graphics: Deluxe Paint IV Amiga",
78 DrawText(SX+60+16,SY+362,"Sounds: AudioMaster IV Amiga",
82 if (leveldir[leveldir_nr].name)
84 int len = strlen(leveldir[leveldir_nr].name);
85 int lxpos = SX+(SXSIZE-len*FONT4_XSIZE)/2;
88 DrawText(lxpos,lypos,leveldir[leveldir_nr].name,FS_SMALL,FC_SPECIAL2);
93 HandleMainMenu(0,0,0,0,MB_MENU_INITIALIZE);
96 if (TAPE_IS_EMPTY(tape))
97 LoadLevelTape(level_nr);
98 DrawCompleteVideoDisplay();
100 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
103 XAutoRepeatOn(display);
106 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
108 static int choice = 3;
109 static int redraw = TRUE;
110 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
112 if (redraw || button == MB_MENU_INITIALIZE)
114 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
118 if (button == MB_MENU_INITIALIZE)
125 x = (dx<0 ? 11 : 15);
142 if (!mx && !my && !dx && !dy)
148 if (y==4 && ((x==11 && level_nr>0) ||
149 (x==15 && level_nr<leveldir[leveldir_nr].levels-1)) &&
152 static long level_delay = 0;
153 int step = (button==1 ? 1 : button==2 ? 5 : 10);
154 int new_level_nr, old_level_nr = level_nr;
156 new_level_nr = level_nr + (x==11 ? -step : +step);
159 if (new_level_nr>leveldir[leveldir_nr].levels-1)
160 new_level_nr = leveldir[leveldir_nr].levels-1;
162 if (old_level_nr==new_level_nr || !DelayReached(&level_delay,150))
165 level_nr = new_level_nr;
167 DrawTextExt(drawto,gc,SX+11*32,SY+3*32,
168 int2str(level_nr,3), FS_BIG,FC_RED);
169 DrawTextExt(window,gc,SX+11*32,SY+3*32,
170 int2str(level_nr,3), FS_BIG,FC_RED);
173 DrawMicroLevel(MICROLEV_XPOS,MICROLEV_YPOS);
176 LoadLevelTape(level_nr);
177 DrawCompleteVideoDisplay();
179 /* needed because DrawMicroLevel() takes some time */
181 XSync(display,FALSE);
182 DelayReached(&level_delay,0); /* reset delay counter */
184 else if (x==1 && y>=3 && y<=10)
190 DrawGraphic(0,y-1,GFX_KUGEL_ROT);
191 DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
199 game_status = TYPENAME;
200 HandleTypeName(strlen(setup.alias_name),0);
206 game_status = CHOOSELEVEL;
213 game_status = HALLOFFAME;
218 game_status = LEVELED;
219 if (leveldir[leveldir_nr].readonly)
220 Request("This level is read only !",REQ_CONFIRM);
225 game_status = HELPSCREEN;
230 if (setup.autorecord)
231 TapeStartRecording();
234 SendToServer_StartPlaying();
237 game_status = PLAYING;
249 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
250 game_status = EXITGAME;
261 if (game_status==MAINMENU)
265 #define MAX_HELPSCREEN_ELS 10
269 static long helpscreen_state;
270 static int helpscreen_step[MAX_HELPSCREEN_ELS];
271 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
272 static int helpscreen_delay[MAX_HELPSCREEN_ELS];
273 static int helpscreen_action[] =
275 GFX_SPIELER1_DOWN,4,2,
277 GFX_SPIELER1_LEFT,4,2,
278 GFX_SPIELER1_RIGHT,4,2,
279 GFX_SPIELER1_PUSH_LEFT,4,2,
280 GFX_SPIELER1_PUSH_RIGHT,4,2, HA_NEXT,
281 GFX_ERDREICH,1,100, HA_NEXT,
282 GFX_LEERRAUM,1,100, HA_NEXT,
283 GFX_MORAST_LEER,1,100, HA_NEXT,
284 GFX_BETON,1,100, HA_NEXT,
285 GFX_MAUERWERK,1,100, HA_NEXT,
286 GFX_MAUER_R1,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
287 GFX_MAUER_L1,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
288 GFX_UNSICHTBAR,1,100, HA_NEXT,
289 GFX_FELSBODEN,1,100, HA_NEXT,
290 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
291 GFX_EDELSTEIN,2,5, HA_NEXT,
292 GFX_DIAMANT,2,5, HA_NEXT,
293 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
294 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
295 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
296 GFX_FELSBROCKEN,4,5, HA_NEXT,
297 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
298 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
299 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
300 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
301 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
302 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
303 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
304 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
305 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
306 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
307 GFX_GEBLUBBER,4,4, HA_NEXT,
308 GFX_SCHLUESSEL1,4,25, HA_NEXT,
309 GFX_PFORTE1,4,25, HA_NEXT,
310 GFX_PFORTE1X,4,25, HA_NEXT,
311 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
312 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
313 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
314 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
315 GFX_LEERRAUM,1,10, HA_NEXT,
316 GFX_DYNABOMB_NR,1,100, HA_NEXT,
317 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
318 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
319 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
320 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
321 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
322 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
323 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
324 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
325 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
326 GFX_BUTTERFLY,2,2, HA_NEXT,
327 GFX_FIREFLY,2,2, HA_NEXT,
328 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
329 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
330 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
331 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
332 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
333 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
334 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
335 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
336 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
337 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
338 GFX_MAULWURF_DOWN,4,2,
340 GFX_MAULWURF_LEFT,4,2,
341 GFX_MAULWURF_RIGHT,4,2, HA_NEXT,
342 GFX_PINGUIN_DOWN,4,2,
344 GFX_PINGUIN_LEFT,4,2,
345 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
346 GFX_SCHWEIN_DOWN,4,2,
348 GFX_SCHWEIN_LEFT,4,2,
349 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
353 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
354 GFX_SONDE_START,8,1, HA_NEXT,
355 GFX_ABLENK,4,1, HA_NEXT,
356 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
357 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
358 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
359 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
360 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
361 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
362 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
363 GFX_DIAMANT,1,10, HA_NEXT,
364 GFX_LIFE,1,100, HA_NEXT,
365 GFX_LIFE_ASYNC,1,100, HA_NEXT,
366 GFX_SIEB_LEER,4,2, HA_NEXT,
367 GFX_SIEB2_LEER,4,2, HA_NEXT,
368 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
369 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
370 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
371 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
372 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
375 static char *helpscreen_eltext[][2] =
377 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
378 {"Normal sand:", "You can dig through it"},
379 {"Empty field:", "You can walk through it"},
380 {"Quicksand: You cannot pass it,", "but rocks can fall though it"},
381 {"Massive Wall:", "Nothing can go through it"},
382 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
383 {"Growing Wall: Grows to the left or", "right if there is an empty field"},
384 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
385 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
386 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
387 {"Emerald: You must collect enough of","them to finish a level"},
388 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
389 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
390 {"Colorful Gems:", "Seem to behave like Emeralds"},
391 {"Rock: Smashes several things;", "Can be moved by the player"},
392 {"Bomb: You can move it, but be", "careful when dropping it"},
393 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
394 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
395 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
396 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
397 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
398 {"Acid: Things that fall in are gone", "forever (including our hero)"},
399 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
400 {"Door: Can be opened by the key", "with the same color"},
401 {"Door: You have to find out the", "right color of the key for it"},
402 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
403 {"Dynamite: This one explodes after", "a few seconds"},
404 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
405 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
406 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
407 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
408 {"Bug: Moves at the right side", "of walls; don't touch it!"},
409 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
410 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
411 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
412 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
413 {"Cruncher (BD style):", "Eats almost everything"},
414 {"Robot: Tries to kill the player", ""},
415 {"The mole: You must guide him savely","to the exit; he will follow you"},
416 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
417 {"The Pig: Harmless, but eats all", "gems it can get"},
418 {"The Dragon: Breathes fire,", "especially to some monsters"},
419 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
420 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
421 {"Light Bulb: All of them must be", "switched on to finish a level"},
422 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
423 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
424 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
425 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
426 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
427 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
428 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
429 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
430 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
431 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
432 {"Exit door: Opens if you have enough","emeralds to finish the level"},
433 {"Open exit door: Enter here to leave","the level and exit the actual game"},
435 static int num_helpscreen_els = sizeof(helpscreen_eltext)/(2*sizeof(char *));
437 static char *helpscreen_music[][3] =
439 { "Alchemy", "Ian Boddy", "Drive" },
440 { "The Chase", "Propaganda", "A Secret Wish" },
441 { "Network 23", "Tangerine Dream", "Exit" },
442 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
443 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
444 { "Voyager", "The Alan Parsons Project","Pyramid" },
445 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
447 static int helpscreen_musicpos;
449 void DrawHelpScreenElAction(int start)
453 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
455 while(helpscreen_action[j] != HA_END)
457 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
459 else if (i<start || helpscreen_delay[i-start])
461 if (i>=start && helpscreen_delay[i-start])
462 helpscreen_delay[i-start]--;
464 while(helpscreen_action[j] != HA_NEXT)
471 j += 3*helpscreen_step[i-start];
472 graphic = helpscreen_action[j++];
474 if (helpscreen_frame[i-start])
476 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
477 helpscreen_frame[i-start]--;
482 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
485 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
487 if (helpscreen_action[j] == HA_NEXT)
489 if (!helpscreen_frame[i-start])
490 helpscreen_step[i-start] = 0;
494 if (!helpscreen_frame[i-start])
495 helpscreen_step[i-start]++;
496 while(helpscreen_action[j] != HA_NEXT)
501 DrawGraphicExt(drawto, gc, xstart, ystart+(i-start)*ystep, graphic+frame);
512 void DrawHelpScreenElText(int start)
515 int xstart = SX+56, ystart = SY+65+2*32, ystep = TILEY+4;
516 char text[FULL_SXSIZE/FONT2_XSIZE+10];
521 sprintf(text,"The game elements:");
522 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100,
523 text,FS_SMALL,FC_GREEN);
525 for(i=start;i<start+MAX_HELPSCREEN_ELS && i<num_helpscreen_els;i++)
527 DrawText(xstart,ystart+(i-start)*ystep+(*helpscreen_eltext[i][1] ? 0 : 8),
528 helpscreen_eltext[i][0],FS_SMALL,FC_YELLOW);
529 DrawText(xstart,ystart+(i-start)*ystep+16,
530 helpscreen_eltext[i][1],FS_SMALL,FC_YELLOW);
533 sprintf(text,"Press any key or button for next page");
534 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20,
535 text,FS_SMALL,FC_BLUE);
538 void DrawHelpScreenMusicText(int num)
540 int ystart = 150, ystep = 30;
541 char text[FULL_SXSIZE/FONT2_XSIZE+10];
547 sprintf(text,"The game background music loops:");
548 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100,
549 text,FS_SMALL,FC_GREEN);
551 sprintf(text,"Excerpt from");
552 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+0*ystep,
553 text,FS_SMALL,FC_YELLOW);
554 sprintf(text,"%c%s%c",'\"',helpscreen_music[num][0],'\"');
555 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+1*ystep,
556 text,FS_SMALL,FC_RED);
558 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+2*ystep,
559 text,FS_SMALL,FC_YELLOW);
560 sprintf(text,"%s",helpscreen_music[num][1]);
561 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+3*ystep,
562 text,FS_SMALL,FC_RED);
563 sprintf(text,"from the album");
564 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep,
565 text,FS_SMALL,FC_YELLOW);
566 sprintf(text,"%c%s%c",'\"',helpscreen_music[num][2],'\"');
567 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+5*ystep,
568 text,FS_SMALL,FC_RED);
570 sprintf(text,"Press any key or button for next page");
571 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20,
572 text,FS_SMALL,FC_BLUE);
574 PlaySoundLoop(background_loop[num]);
577 void DrawHelpScreenCreditsText()
579 int ystart = 150, ystep = 30;
580 char text[FULL_SXSIZE/FONT2_XSIZE+10];
586 sprintf(text,"Program information:");
587 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100,
588 text,FS_SMALL,FC_GREEN);
590 sprintf(text,"This game is Freeware!");
591 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+0*ystep,
592 text,FS_SMALL,FC_YELLOW);
593 sprintf(text,"If you like it, send e-mail to:");
594 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+1*ystep,
595 text,FS_SMALL,FC_YELLOW);
596 sprintf(text,"aeglos@valinor.owl.de");
597 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+2*ystep,
598 text,FS_SMALL,FC_RED);
599 sprintf(text,"or SnailMail to:");
600 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+3*ystep,
601 text,FS_SMALL,FC_YELLOW);
602 sprintf(text,"Holger Schemel");
603 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep,
604 text,FS_SMALL,FC_RED);
605 sprintf(text,"Sennehof 28");
606 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+20,
607 text,FS_SMALL,FC_RED);
608 sprintf(text,"33659 Bielefeld");
609 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+40,
610 text,FS_SMALL,FC_RED);
611 sprintf(text,"Germany");
612 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+60,
613 text,FS_SMALL,FC_RED);
615 sprintf(text,"If you have created new levels,");
616 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+7*ystep,
617 text,FS_SMALL,FC_YELLOW);
618 sprintf(text,"send them to me to include them!");
619 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+8*ystep,
620 text,FS_SMALL,FC_YELLOW);
622 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+9*ystep,
623 text,FS_SMALL,FC_YELLOW);
625 sprintf(text,"Press any key or button for main menu");
626 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20,
627 text,FS_SMALL,FC_BLUE);
630 void DrawHelpScreen()
634 CloseDoor(DOOR_CLOSE_2);
636 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
637 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
638 helpscreen_musicpos = 0;
639 helpscreen_state = 0;
640 DrawHelpScreenElText(0);
641 DrawHelpScreenElAction(0);
645 PlaySoundLoop(SND_RHYTHMLOOP);
648 void HandleHelpScreen(int button)
650 static long hs_delay = 0;
651 int num_helpscreen_els_pages =
652 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
653 int button_released = !button;
658 if (helpscreen_state<num_helpscreen_els_pages-1)
660 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
661 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
663 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
664 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
666 else if (helpscreen_state<num_helpscreen_els_pages+num_bg_loops-1)
669 DrawHelpScreenMusicText(helpscreen_state-num_helpscreen_els_pages);
671 else if (helpscreen_state==num_helpscreen_els_pages+num_bg_loops-1)
674 DrawHelpScreenCreditsText();
680 game_status = MAINMENU;
685 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
687 if (helpscreen_state<num_helpscreen_els_pages)
688 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
696 void HandleTypeName(int newxpos, KeySym key)
698 static int xpos = 0, ypos = 2;
704 DrawText(SX+6*32, SY+ypos*32, setup.alias_name, FS_BIG, FC_YELLOW);
705 DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
710 if ((key>=XK_A && key<=XK_Z) || (key>=XK_a && key<=XK_z &&
713 if (key>=XK_A && key<=XK_Z)
714 ascii = 'A'+(char)(key-XK_A);
715 if (key>=XK_a && key<=XK_z)
716 ascii = 'a'+(char)(key-XK_a);
718 if((ascii = get_ascii(key)) && xpos<MAX_NAMELEN-1)
721 setup.alias_name[xpos] = ascii;
722 setup.alias_name[xpos+1] = 0;
724 DrawTextExt(drawto,gc,SX+6*32,SY+ypos*32,
725 setup.alias_name,FS_BIG,FC_YELLOW);
726 DrawTextExt(window,gc,SX+6*32,SY+ypos*32,
727 setup.alias_name,FS_BIG,FC_YELLOW);
728 DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
730 else if ((key==XK_Delete || key==XK_BackSpace) && xpos>0)
733 setup.alias_name[xpos] = 0;
734 DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
735 DrawGraphic(xpos+7,ypos,GFX_LEERRAUM);
737 else if (key==XK_Return && xpos>0)
739 DrawText(SX+6*32,SY+ypos*32,setup.alias_name,FS_BIG,FC_RED);
740 DrawGraphic(xpos+6,ypos,GFX_LEERRAUM);
743 game_status = MAINMENU;
749 void DrawChooseLevel()
753 CloseDoor(DOOR_CLOSE_2);
756 DrawText(SX,SY,"Level Directories",FS_BIG,FC_GREEN);
757 for(i=0;i<num_leveldirs;i++)
759 DrawText(SX+32,SY+(i+2)*32,leveldir[i].name,FS_BIG,FC_YELLOW);
760 DrawGraphic(0,i+2,GFX_KUGEL_BLAU);
765 HandleChooseLevel(0,0,0,0,MB_MENU_INITIALIZE);
768 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
770 static int choice = 3;
771 static int redraw = TRUE;
772 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
774 if (button == MB_MENU_INITIALIZE)
777 choice = leveldir_nr + 3;
782 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
786 if (button == MB_MENU_INITIALIZE)
801 else if (y>num_leveldirs+2)
805 if (!mx && !my && !dx && !dy)
811 if (x==1 && y>=3 && y<=num_leveldirs+2)
817 DrawGraphic(0,y-1,GFX_KUGEL_ROT);
818 DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
826 getLastPlayedLevelOfLevelSeries(leveldir[leveldir_nr].filename);
831 LoadLevelTape(level_nr);
833 game_status = MAINMENU;
841 if (game_status==CHOOSELEVEL)
845 void DrawHallOfFame(int pos)
850 CloseDoor(DOOR_CLOSE_2);
855 DrawText(SX+64,SY+10,"Hall Of Fame",FS_BIG,FC_YELLOW);
856 sprintf(txt,"HighScores of Level %d",level_nr);
857 DrawText(SX+256-strlen(txt)*7,SY+48,txt,FS_SMALL,FC_RED);
858 for(y=0;y<MAX_SCORE_ENTRIES;y++)
860 DrawText(SX,SY+64+y*32,".................",FS_BIG,
861 (y==pos ? FC_RED : FC_GREEN));
862 DrawText(SX,SY+64+y*32,highscore[y].Name,FS_BIG,
863 (y==pos ? FC_RED : FC_GREEN));
864 DrawText(SX+12*32,SY+64+y*32,
865 int2str(highscore[y].Score,5),FS_BIG,
866 (y==pos ? FC_RED : FC_GREEN));
871 PlaySound(SND_HALLOFFAME);
874 void HandleHallOfFame(int button)
876 int button_released = !button;
880 FadeSound(SND_HALLOFFAME);
881 game_status = MAINMENU;
889 void DrawSetupScreen()
898 { &setup.sound, "Sound:", },
899 { &setup.sound_loops, " Sound Loops:" },
900 { &setup.sound_music, " Game Music:" },
901 { &setup.toons, "Toons:" },
902 { &setup.double_buffering, "Buffered gfx:" },
903 { &setup.scroll_delay, "Scroll Delay:" },
904 { &setup.soft_scrolling, "Soft Scroll.:" },
905 { &setup.fading, "Fading:" },
906 { &setup.quick_doors, "Quick Doors:" },
907 { &setup.autorecord, "Auto-Record:" },
908 { &setup.team_mode, "Team-Mode:" },
909 { NULL, "Input Devices" },
912 { NULL, "Save and exit" }
915 CloseDoor(DOOR_CLOSE_2);
917 DrawText(SX+16, SY+16, "SETUP",FS_BIG,FC_YELLOW);
919 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
921 int base = i - SETUP_SCREEN_POS_START;
923 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
925 DrawGraphic(0,i,GFX_KUGEL_BLAU);
926 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
929 if (setup_info[base].value)
931 int setting_value = *setup_info[base].value;
933 DrawText(SX+14*32, SY+i*32, (setting_value ? "on" : "off"),
934 FS_BIG, (setting_value ? FC_YELLOW : FC_BLUE));
940 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
943 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
945 static int choice = 3;
946 static int redraw = TRUE;
947 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
948 int pos_start = SETUP_SCREEN_POS_START + 1;
949 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
950 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
951 int pos_end = SETUP_SCREEN_POS_END + 1;
953 if (button == MB_MENU_INITIALIZE)
958 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
962 if (button == MB_MENU_INITIALIZE)
975 if (y >= pos_empty1 && y <= pos_empty2)
976 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
980 else if (y > pos_end)
984 if (!mx && !my && !dx && !dy)
990 if (x==1 && y >= pos_start && y <= pos_end &&
991 !(y >= pos_empty1 && y <= pos_empty2))
997 DrawGraphic(0,y-1,GFX_KUGEL_ROT);
998 DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
1006 if (y==3 && sound_status==SOUND_AVAILABLE)
1010 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1011 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1012 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1013 setup.sound_loops = FALSE;
1014 setup.sound_music = FALSE;
1017 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1018 setup.sound = !setup.sound;
1020 else if (y==4 && sound_loops_allowed)
1022 if (setup.sound_loops)
1023 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1026 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1027 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1030 setup.sound_loops = !setup.sound_loops;
1032 else if (y==5 && sound_loops_allowed)
1034 if (setup.sound_music)
1035 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1038 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1039 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1042 setup.sound_music = !setup.sound_music;
1047 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1049 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1050 setup.toons = !setup.toons;
1054 if (setup.double_buffering)
1055 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1057 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1058 setup.double_buffering = !setup.double_buffering;
1059 setup.direct_draw = !setup.double_buffering;
1063 if (setup.scroll_delay)
1064 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1066 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1067 setup.scroll_delay = !setup.scroll_delay;
1071 if (setup.soft_scrolling)
1072 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1074 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1075 setup.soft_scrolling = !setup.soft_scrolling;
1080 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1082 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1083 setup.fading = !setup.fading;
1087 if (setup.quick_doors)
1088 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1090 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1091 setup.quick_doors = !setup.quick_doors;
1095 if (setup.autorecord)
1096 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1098 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1099 setup.autorecord = !setup.autorecord;
1103 if (setup.team_mode)
1104 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1106 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1107 setup.team_mode = !setup.team_mode;
1111 game_status = SETUPINPUT;
1112 DrawSetupInputScreen();
1115 else if (y==pos_end-1 || y==pos_end)
1127 game_status = MAINMENU;
1135 if (game_status==SETUP)
1139 void DrawSetupInputScreen()
1142 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1144 DrawGraphic(0, 2, GFX_KUGEL_BLAU);
1145 DrawGraphic(0, 3, GFX_KUGEL_BLAU);
1146 DrawGraphic(0, 4, GFX_KUGEL_BLAU);
1147 DrawGraphic(0, 15, GFX_KUGEL_BLAU);
1148 DrawGraphic(10, 2, GFX_PFEIL_L);
1149 DrawGraphic(12, 2, GFX_PFEIL_R);
1151 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1152 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1153 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1157 HandleSetupInputScreen(0,0,0,0,MB_MENU_INITIALIZE);
1160 static int getJoystickNrFromDeviceName(char *device_name)
1163 int joystick_nr = 0;
1165 if (device_name == NULL || device_name[0] == '\0')
1168 c = device_name[strlen(device_name) - 1];
1170 if (c >= '0' && c <= '9')
1171 joystick_nr = (int)(c - '0');
1173 if (joystick_nr < 0 || joystick_nr >= MAX_PLAYERS)
1179 static void setJoystickDeviceToNr(char *device_name, int device_nr)
1181 if (device_name == NULL)
1184 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
1187 if (strlen(device_name) > 1)
1189 char c1 = device_name[strlen(device_name) - 1];
1190 char c2 = device_name[strlen(device_name) - 2];
1192 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
1193 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
1196 strcpy(device_name, joystick_device_name[device_nr]);
1199 static void drawPlayerSetupInputInfo(int player_nr)
1202 static struct SetupKeyboardInfo custom_key;
1209 { &custom_key.left, "Joystick Left" },
1210 { &custom_key.right, "Joystick Right" },
1211 { &custom_key.up, "Joystick Up" },
1212 { &custom_key.down, "Joystick Down" },
1213 { &custom_key.snap, "Button 1" },
1214 { &custom_key.bomb, "Button 2" }
1216 static char *joystick_name[MAX_PLAYERS] =
1224 custom_key = setup.input[player_nr].key;
1226 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1227 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1229 if (setup.input[player_nr].use_joystick)
1231 char *device_name = setup.input[player_nr].joy.device_name;
1233 DrawText(SX+8*32, SY+3*32,
1234 joystick_name[getJoystickNrFromDeviceName(device_name)],
1236 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1240 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1241 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1244 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1245 DrawGraphic(1, 6, GFX_PFEIL_L);
1246 DrawGraphic(1, 7, GFX_PFEIL_R);
1247 DrawGraphic(1, 8, GFX_PFEIL_O);
1248 DrawGraphic(1, 9, GFX_PFEIL_U);
1249 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1250 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1251 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1252 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1253 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1254 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1258 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1260 DrawText(SX + 3*32, SY + ypos*32,
1261 " ", FS_BIG, FC_YELLOW);
1262 DrawText(SX + 3*32, SY + ypos*32,
1263 (setup.input[player_nr].use_joystick ?
1265 getKeyNameFromKeySym(*custom[i].keysym)),
1270 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1272 static int choice = 3;
1273 static int player_nr = 0;
1274 static int redraw = TRUE;
1275 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1276 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1277 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1278 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1279 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1281 if (button == MB_MENU_INITIALIZE)
1283 drawPlayerSetupInputInfo(player_nr);
1289 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
1293 if (button == MB_MENU_INITIALIZE)
1298 if (dx && choice == 3)
1300 x = (dx < 0 ? 11 : 13);
1303 else if (dx && choice == 4)
1305 button = MB_MENU_CHOICE;
1317 if (y >= pos_empty1 && y <= pos_empty2)
1318 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1322 else if (y > pos_end)
1326 if (!mx && !my && !dx && !dy)
1332 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1334 static long delay = 0;
1336 if (!DelayReached(&delay, 150))
1339 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1341 drawPlayerSetupInputInfo(player_nr);
1343 else if (x==1 && y >= pos_start && y <= pos_end &&
1344 !(y >= pos_empty1 && y <= pos_empty2))
1350 DrawGraphic(0, y-1, GFX_KUGEL_ROT);
1351 DrawGraphic(0, choice-1, GFX_KUGEL_BLAU);
1359 char *device_name = setup.input[player_nr].joy.device_name;
1361 if (!setup.input[player_nr].use_joystick)
1363 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
1365 setJoystickDeviceToNr(device_name, new_device_nr);
1366 setup.input[player_nr].use_joystick = TRUE;
1370 int device_nr = getJoystickNrFromDeviceName(device_name);
1371 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
1373 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
1374 setup.input[player_nr].use_joystick = FALSE;
1376 setJoystickDeviceToNr(device_name, new_device_nr);
1386 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1387 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1389 if (setup.input[player_nr].use_joystick)
1391 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1392 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1394 setup.input[player_nr].use_joystick = FALSE;
1398 setup.input[player_nr].use_joystick = TRUE;
1399 setup.input[player_nr].joystick_nr = one_joystick_nr;
1403 drawPlayerSetupInputInfo(player_nr);
1407 if (setup.input[player_nr].use_joystick)
1410 CalibrateJoystick(player_nr);
1413 CustomizeKeyboard(player_nr);
1417 else if (y == pos_end)
1421 game_status = SETUP;
1431 if (game_status == SETUPINPUT)
1435 void CustomizeKeyboard(int player_nr)
1439 boolean finished = FALSE;
1440 static struct SetupKeyboardInfo custom_key;
1445 } customize_step[] =
1447 { &custom_key.left, "Move Left" },
1448 { &custom_key.right, "Move Right" },
1449 { &custom_key.up, "Move Up" },
1450 { &custom_key.down, "Move Down" },
1451 { &custom_key.snap, "Snap Field" },
1452 { &custom_key.bomb, "Place Bomb" }
1455 /* read existing key bindings from player setup */
1456 custom_key = setup.input[player_nr].key;
1459 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1465 DrawText(SX, SY + (2+2*step_nr)*32,
1466 customize_step[step_nr].text, FS_BIG, FC_RED);
1467 DrawText(SX, SY + (2+2*step_nr+1)*32,
1468 "Key:", FS_BIG, FC_RED);
1469 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1470 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1475 if (XPending(display)) /* got event from X server */
1479 XNextEvent(display, &event);
1485 KeySym key = XLookupKeysym((XKeyEvent *)&event,
1486 ((XKeyEvent *)&event)->state);
1488 if (key == XK_Escape || (key == XK_Return && step_nr == 6))
1494 /* press 'Enter' to keep the existing key binding */
1495 if (key == XK_Return || step_nr == 6)
1496 key = *customize_step[step_nr].keysym;
1498 /* check if key already used */
1499 for (i=0; i<step_nr; i++)
1500 if (*customize_step[i].keysym == key)
1505 /* got new key binding */
1506 *customize_step[step_nr].keysym = key;
1507 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1508 " ", FS_BIG, FC_YELLOW);
1509 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1510 getKeyNameFromKeySym(key), FS_BIG, FC_YELLOW);
1513 /* un-highlight last query */
1514 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1515 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1516 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1517 "Key:", FS_BIG, FC_GREEN);
1519 /* press 'Enter' to leave */
1522 DrawText(SX + 16, SY + 15*32+16,
1523 "Press Enter", FS_BIG, FC_YELLOW);
1527 /* query next key binding */
1528 DrawText(SX, SY+(2+2*step_nr)*32,
1529 customize_step[step_nr].text, FS_BIG, FC_RED);
1530 DrawText(SX, SY+(2+2*step_nr+1)*32,
1531 "Key:", FS_BIG, FC_RED);
1532 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1533 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1539 key_joystick_mapping = 0;
1543 HandleOtherEvents(&event);
1551 /* don't eat all CPU time */
1555 /* write new key bindings back to player setup */
1556 setup.input[player_nr].key = custom_key;
1559 DrawSetupInputScreen();
1562 void CalibrateJoystick(int player_nr)
1565 struct joystick joy_ctrl;
1567 struct joystick_control
1579 int joystick_fd = stored_player[player_nr].joystick_fd;
1580 int new_joystick_xleft = 128, new_joystick_xright = 128;
1581 int new_joystick_yupper = 128, new_joystick_ylower = 128;
1582 int new_joystick_xmiddle, new_joystick_ymiddle;
1583 int x, y, last_x, last_y, xpos = 8, ypos = 3;
1584 boolean check[3][3];
1585 int check_remaining = 3 * 3;
1589 if (joystick_status == JOYSTICK_OFF)
1592 if (!setup.input[player_nr].use_joystick || joystick_fd < 0)
1596 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ",FS_BIG,FC_YELLOW);
1597 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS",FS_BIG,FC_YELLOW);
1598 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ",FS_BIG,FC_YELLOW);
1599 DrawText(SX, SY + 10*32, " ARE YELLOW, ",FS_BIG,FC_YELLOW);
1600 DrawText(SX, SY + 11*32, " PRESS BUTTON! ",FS_BIG,FC_YELLOW);
1606 check[x][y] = FALSE;
1607 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
1611 joy = Joystick(player_nr);
1612 last_x = (joy & JOY_LEFT ? -1 : joy & JOY_RIGHT ? +1 : 0);
1613 last_y = (joy & JOY_UP ? -1 : joy & JOY_DOWN ? +1 : 0);
1614 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
1619 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1621 joy_ctrl.buttons = 0;
1624 while(Joystick(player_nr) & JOY_BUTTON);
1630 if (XPending(display)) /* got event from X server */
1634 XNextEvent(display, &event);
1639 switch(XLookupKeysym((XKeyEvent *)&event,
1640 ((XKeyEvent *)&event)->state))
1643 if (check_remaining == 0)
1657 key_joystick_mapping = 0;
1661 HandleOtherEvents(&event);
1666 if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1668 joystick_status = JOYSTICK_OFF;
1672 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
1673 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
1674 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
1675 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
1677 new_joystick_xmiddle =
1678 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
1679 new_joystick_ymiddle =
1680 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
1682 setup.input[player_nr].joy.xleft = new_joystick_xleft;
1683 setup.input[player_nr].joy.yupper = new_joystick_yupper;
1684 setup.input[player_nr].joy.xright = new_joystick_xright;
1685 setup.input[player_nr].joy.ylower = new_joystick_ylower;
1686 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
1687 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
1689 CheckJoystickData();
1691 joy = Joystick(player_nr);
1693 if (joy & JOY_BUTTON && check_remaining == 0)
1696 x = (joy & JOY_LEFT ? -1 : joy & JOY_RIGHT ? +1 : 0);
1697 y = (joy & JOY_UP ? -1 : joy & JOY_DOWN ? +1 : 0);
1699 if (x != last_x || y != last_y)
1701 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
1702 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
1707 if (check_remaining > 0 && !check[x+1][y+1])
1709 check[x+1][y+1] = TRUE;
1714 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
1715 setup.input[player_nr].joy.xleft,
1716 setup.input[player_nr].joy.xmiddle,
1717 setup.input[player_nr].joy.xright);
1718 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
1719 setup.input[player_nr].joy.yupper,
1720 setup.input[player_nr].joy.ymiddle,
1721 setup.input[player_nr].joy.ylower);
1728 /* don't eat all CPU time */
1734 DrawSetupInputScreen();
1735 while(Joystick(player_nr) & JOY_BUTTON);
1741 DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
1742 DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
1745 DrawSetupInputScreen();
1752 void CalibrateJoystick_OLD()
1755 struct joystick joy_ctrl;
1757 struct joystick_control
1769 int joystick_nr = setup.input[0].joystick_nr;
1770 int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle;
1771 int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle;
1773 if (joystick_status == JOYSTICK_OFF)
1778 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1779 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
1780 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1784 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1786 joy_ctrl.buttons = 0;
1788 while(Joystick() & JOY_BUTTON);
1790 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1792 while(!joy_ctrl.buttons)
1795 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1797 joystick_status=JOYSTICK_OFF;
1803 new_joystick_xleft = joy_ctrl.x;
1804 new_joystick_yupper = joy_ctrl.y;
1807 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1808 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
1809 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1813 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1815 joy_ctrl.buttons = 0;
1817 while(Joystick() & JOY_BUTTON);
1819 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1821 while(!joy_ctrl.buttons)
1824 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1826 joystick_status=JOYSTICK_OFF;
1832 new_joystick_xright = joy_ctrl.x;
1833 new_joystick_ylower = joy_ctrl.y;
1836 DrawText(SX+32, SY+16+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
1837 DrawText(SX+16, SY+16+8*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1841 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1843 joy_ctrl.buttons = 0;
1845 while(Joystick() & JOY_BUTTON);
1847 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1849 while(!joy_ctrl.buttons)
1852 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1854 joystick_status=JOYSTICK_OFF;
1860 new_joystick_xmiddle = joy_ctrl.x;
1861 new_joystick_ymiddle = joy_ctrl.y;
1863 setup.input[player_nr].joy.xleft = new_joystick_xleft;
1864 setup.input[player_nr].joy.yupper = new_joystick_yupper;
1865 setup.input[player_nr].joy.xright = new_joystick_xright;
1866 setup.input[player_nr].joy.ylower = new_joystick_ylower;
1867 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
1868 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
1870 CheckJoystickData();
1873 while(Joystick() & JOY_BUTTON);
1881 joy_nr[1] = SETUP_2ND_JOYSTICK_ON(local_player->setup)+49;
1886 DrawText(SX+32, SY+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
1887 DrawText(SX+16+7*32, SY+8*32, joy_nr, FS_BIG,FC_YELLOW);
1888 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
1891 for(clear_keybuf();!keypressed(););
1892 install_joystick(JOY_TYPE_2PADS);
1895 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1896 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
1897 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
1900 for(clear_keybuf();!keypressed(););
1901 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
1904 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1905 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
1906 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
1909 for(clear_keybuf();!keypressed(););
1910 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
1917 DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
1918 DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
1928 void HandleGameActions()
1930 if (game_status != PLAYING)
1933 if (local_player->LevelSolved)
1936 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
1944 void HandleVideoButtons(int mx, int my, int button)
1946 if (game_status != MAINMENU && game_status != PLAYING)
1949 switch(CheckVideoButtons(mx,my,button))
1951 case BUTTON_VIDEO_EJECT:
1953 if (TAPE_IS_EMPTY(tape))
1955 LoadLevelTape(level_nr);
1956 if (TAPE_IS_EMPTY(tape))
1957 Request("No tape for this level !",REQ_CONFIRM);
1962 SaveLevelTape(tape.level_nr);
1965 DrawCompleteVideoDisplay();
1968 case BUTTON_VIDEO_STOP:
1972 case BUTTON_VIDEO_PAUSE:
1976 case BUTTON_VIDEO_REC:
1977 if (TAPE_IS_STOPPED(tape))
1979 TapeStartRecording();
1981 if (options.network)
1982 SendToServer_StartPlaying();
1985 game_status = PLAYING;
1989 else if (tape.pausing)
1991 if (tape.playing) /* PLAYING -> PAUSING -> RECORDING */
1993 tape.pos[tape.counter].delay = tape.delay_played;
1994 tape.playing = FALSE;
1995 tape.recording = TRUE;
1996 tape.changed = TRUE;
1998 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON,0);
2005 case BUTTON_VIDEO_PLAY:
2006 if (TAPE_IS_EMPTY(tape))
2009 if (TAPE_IS_STOPPED(tape))
2013 game_status = PLAYING;
2016 else if (tape.playing)
2018 if (tape.pausing) /* PAUSE -> PLAY */
2020 else if (!tape.fast_forward) /* PLAY -> FAST FORWARD PLAY */
2022 tape.fast_forward = TRUE;
2023 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
2025 else if (!tape.pause_before_death) /* FFWD PLAY -> + AUTO PAUSE */
2027 tape.pause_before_death = TRUE;
2028 DrawVideoDisplay(VIDEO_STATE_PAUSE_ON, VIDEO_DISPLAY_LABEL_ONLY);
2030 else /* -> NORMAL PLAY */
2032 tape.fast_forward = FALSE;
2033 tape.pause_before_death = FALSE;
2034 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PAUSE_OFF, 0);
2046 void HandleSoundButtons(int mx, int my, int button)
2048 if (game_status != PLAYING)
2051 switch(CheckSoundButtons(mx,my,button))
2053 case BUTTON_SOUND_MUSIC:
2054 if (setup.sound_music)
2056 setup.sound_music = FALSE;
2057 FadeSound(background_loop[level_nr % num_bg_loops]);
2058 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
2060 else if (sound_loops_allowed)
2062 setup.sound = setup.sound_music = TRUE;
2063 PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
2064 DrawSoundDisplay(BUTTON_SOUND_MUSIC_ON);
2067 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
2070 case BUTTON_SOUND_LOOPS:
2071 if (setup.sound_loops)
2073 setup.sound_loops = FALSE;
2074 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
2076 else if (sound_loops_allowed)
2078 setup.sound = setup.sound_loops = TRUE;
2079 DrawSoundDisplay(BUTTON_SOUND_LOOPS_ON);
2082 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
2085 case BUTTON_SOUND_SIMPLE:
2086 if (setup.sound_simple)
2088 setup.sound_simple = FALSE;
2089 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
2091 else if (sound_status==SOUND_AVAILABLE)
2093 setup.sound = setup.sound_simple = TRUE;
2094 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_ON);
2097 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
2107 void HandleGameButtons(int mx, int my, int button)
2109 if (game_status != PLAYING)
2112 switch(CheckGameButtons(mx,my,button))
2114 case BUTTON_GAME_STOP:
2117 CloseDoor(DOOR_CLOSE_1);
2118 game_status = MAINMENU;
2123 if (Request("Do you really want to quit the game ?",
2124 REQ_ASK | REQ_STAY_CLOSED))
2126 if (options.network)
2127 SendToServer_StopPlaying();
2130 game_status = MAINMENU;
2135 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
2138 case BUTTON_GAME_PAUSE:
2139 if (options.network)
2142 SendToServer_ContinuePlaying();
2144 SendToServer_PausePlaying();
2150 case BUTTON_GAME_PLAY:
2153 if (options.network)
2154 SendToServer_ContinuePlaying();
2157 tape.pausing = FALSE;
2158 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);