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 ***********************************************************/
29 /* for DrawSetupScreen(), HandleSetupScreen() */
30 #define SETUP_SCREEN_POS_START 2
31 #define SETUP_SCREEN_POS_END 16
32 #define SETUP_SCREEN_POS_EMPTY1 (SETUP_SCREEN_POS_END - 2)
33 #define SETUP_SCREEN_POS_EMPTY2 (SETUP_SCREEN_POS_END - 2)
35 /* for HandleSetupInputScreen() */
36 #define SETUPINPUT_SCREEN_POS_START 2
37 #define SETUPINPUT_SCREEN_POS_END 15
38 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
39 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
41 /* for HandleChooseLevel() */
42 #define MAX_LEVEL_SERIES_ON_SCREEN 15
45 extern unsigned char get_ascii(KeySym);
50 int x = SX + (SXSIZE - strlen(GAMETITLE_STRING) * FONT1_XSIZE) / 2;
52 DrawText(x, SY + 8, GAMETITLE_STRING, FS_BIG, FC_YELLOW);
53 DrawTextFCentered(46, FC_RED, COPYRIGHT_STRING);
59 char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:");
67 DrawText(SX + 32, SY + 2*32, name_text, FS_BIG, FC_GREEN);
68 DrawText(SX + 6*32, SY + 2*32, setup.player_name, FS_BIG, FC_RED);
69 DrawText(SX + 32, SY + 3*32, "Level:", FS_BIG, FC_GREEN);
70 DrawText(SX + 11*32, SY + 3*32, int2str(level_nr,3), FS_BIG,
71 (leveldir[leveldir_nr].readonly ? FC_RED : FC_YELLOW));
72 DrawText(SX + 32, SY + 4*32, "Hall Of Fame", FS_BIG, FC_GREEN);
73 DrawText(SX + 32, SY + 5*32, "Level Creator", FS_BIG, FC_GREEN);
74 DrawText(SY + 32, SY + 6*32, "Info Screen", FS_BIG, FC_GREEN);
75 DrawText(SX + 32, SY + 7*32, "Start Game", FS_BIG, FC_GREEN);
76 DrawText(SX + 32, SY + 8*32, "Setup", FS_BIG, FC_GREEN);
77 DrawText(SX + 32, SY + 9*32, "Quit", FS_BIG, FC_GREEN);
79 DrawMicroLevel(MICROLEV_XPOS,MICROLEV_YPOS);
82 DrawGraphic(0, i, GFX_KUGEL_BLAU);
83 DrawGraphic(10, 3, GFX_PFEIL_L);
84 DrawGraphic(14, 3, GFX_PFEIL_R);
86 DrawTextF(15*32 + 6, 3*32 + 9, FC_RED, "%d", leveldir[leveldir_nr].levels);
88 DrawText(SX + 56, SY + 326, "A Game by Artsoft Entertainment",
91 if (leveldir[leveldir_nr].name)
93 int len = strlen(leveldir[leveldir_nr].name);
94 int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2;
97 DrawText(lxpos, lypos, leveldir[leveldir_nr].name, FS_SMALL, FC_SPECIAL2);
102 HandleMainMenu(0,0, 0,0, MB_MENU_INITIALIZE);
105 if (TAPE_IS_EMPTY(tape))
107 DrawCompleteVideoDisplay();
109 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
112 XAutoRepeatOn(display);
115 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
117 static int choice = 3;
118 static int redraw = TRUE;
119 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
121 if (redraw || button == MB_MENU_INITIALIZE)
123 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
127 if (button == MB_MENU_INITIALIZE)
132 if (dx && choice == 4)
134 x = (dx < 0 ? 11 : 15);
151 if (!mx && !my && !dx && !dy)
157 if (y == 4 && ((x == 11 && level_nr > 0) ||
158 (x == 15 && level_nr < leveldir[leveldir_nr].levels - 1)) &&
161 static long level_delay = 0;
162 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
163 int new_level_nr, old_level_nr = level_nr;
164 int font_color = (leveldir[leveldir_nr].readonly ? FC_RED : FC_YELLOW);
166 new_level_nr = level_nr + (x == 11 ? -step : +step);
167 if (new_level_nr < 0)
169 if (new_level_nr > leveldir[leveldir_nr].levels - 1)
170 new_level_nr = leveldir[leveldir_nr].levels - 1;
172 if (old_level_nr == new_level_nr || !DelayReached(&level_delay, 150))
175 level_nr = new_level_nr;
177 DrawTextExt(drawto, gc, SX + 11 * 32, SY + 3 * 32,
178 int2str(level_nr, 3), FS_BIG, font_color);
179 DrawTextExt(window, gc, SX + 11 * 32, SY + 3 * 32,
180 int2str(level_nr, 3), FS_BIG, font_color);
183 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS);
187 DrawCompleteVideoDisplay();
189 /* needed because DrawMicroLevel() takes some time */
191 XSync(display, FALSE);
192 DelayReached(&level_delay, 0); /* reset delay counter */
194 else if (x == 1 && y >= 3 && y <= 10)
200 DrawGraphic(0, y-1, GFX_KUGEL_ROT);
201 DrawGraphic(0, choice - 1, GFX_KUGEL_BLAU);
209 game_status = TYPENAME;
210 HandleTypeName(strlen(setup.player_name), 0);
216 game_status = CHOOSELEVEL;
223 game_status = HALLOFFAME;
228 if (leveldir[leveldir_nr].readonly)
229 Request("This level is read only !", REQ_CONFIRM);
230 game_status = LEVELED;
235 game_status = HELPSCREEN;
240 if (setup.autorecord)
241 TapeStartRecording();
245 SendToServer_StartPlaying();
249 game_status = PLAYING;
261 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
262 game_status = EXITGAME;
272 if (game_status == MAINMENU)
276 #define MAX_HELPSCREEN_ELS 10
280 static long helpscreen_state;
281 static int helpscreen_step[MAX_HELPSCREEN_ELS];
282 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
283 static int helpscreen_delay[MAX_HELPSCREEN_ELS];
284 static int helpscreen_action[] =
286 GFX_SPIELER1_DOWN,4,2,
288 GFX_SPIELER1_LEFT,4,2,
289 GFX_SPIELER1_RIGHT,4,2,
290 GFX_SPIELER1_PUSH_LEFT,4,2,
291 GFX_SPIELER1_PUSH_RIGHT,4,2, HA_NEXT,
292 GFX_ERDREICH,1,100, HA_NEXT,
293 GFX_LEERRAUM,1,100, HA_NEXT,
294 GFX_MORAST_LEER,1,100, HA_NEXT,
295 GFX_BETON,1,100, HA_NEXT,
296 GFX_MAUERWERK,1,100, HA_NEXT,
297 GFX_MAUER_R1,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
298 GFX_MAUER_L1,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
299 GFX_UNSICHTBAR,1,100, HA_NEXT,
300 GFX_FELSBODEN,1,100, HA_NEXT,
301 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
302 GFX_EDELSTEIN,2,5, HA_NEXT,
303 GFX_DIAMANT,2,5, HA_NEXT,
304 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
305 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
306 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
307 GFX_FELSBROCKEN,4,5, HA_NEXT,
308 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
309 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
310 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
311 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
312 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
313 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
314 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
315 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
316 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
317 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
318 GFX_GEBLUBBER,4,4, HA_NEXT,
319 GFX_SCHLUESSEL1,4,25, HA_NEXT,
320 GFX_PFORTE1,4,25, HA_NEXT,
321 GFX_PFORTE1X,4,25, HA_NEXT,
322 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
323 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
324 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
325 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
326 GFX_LEERRAUM,1,10, HA_NEXT,
327 GFX_DYNABOMB_NR,1,100, HA_NEXT,
328 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
329 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
330 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
331 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
332 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
333 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
334 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
335 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
336 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
337 GFX_BUTTERFLY,2,2, HA_NEXT,
338 GFX_FIREFLY,2,2, HA_NEXT,
339 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
340 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
341 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
342 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
343 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
344 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
345 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
346 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
347 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
348 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
349 GFX_MAULWURF_DOWN,4,2,
351 GFX_MAULWURF_LEFT,4,2,
352 GFX_MAULWURF_RIGHT,4,2, HA_NEXT,
353 GFX_PINGUIN_DOWN,4,2,
355 GFX_PINGUIN_LEFT,4,2,
356 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
357 GFX_SCHWEIN_DOWN,4,2,
359 GFX_SCHWEIN_LEFT,4,2,
360 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
364 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
365 GFX_SONDE_START,8,1, HA_NEXT,
366 GFX_ABLENK,4,1, HA_NEXT,
367 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
368 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
369 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
370 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
371 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
372 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
373 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
374 GFX_DIAMANT,1,10, HA_NEXT,
375 GFX_LIFE,1,100, HA_NEXT,
376 GFX_LIFE_ASYNC,1,100, HA_NEXT,
377 GFX_SIEB_LEER,4,2, HA_NEXT,
378 GFX_SIEB2_LEER,4,2, HA_NEXT,
379 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
380 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
381 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
382 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
383 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
386 static char *helpscreen_eltext[][2] =
388 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
389 {"Normal sand:", "You can dig through it"},
390 {"Empty field:", "You can walk through it"},
391 {"Quicksand: You cannot pass it,", "but rocks can fall though it"},
392 {"Massive Wall:", "Nothing can go through it"},
393 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
394 {"Growing Wall: Grows to the left or", "right if there is an empty field"},
395 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
396 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
397 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
398 {"Emerald: You must collect enough of","them to finish a level"},
399 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
400 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
401 {"Colorful Gems:", "Seem to behave like Emeralds"},
402 {"Rock: Smashes several things;", "Can be moved by the player"},
403 {"Bomb: You can move it, but be", "careful when dropping it"},
404 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
405 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
406 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
407 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
408 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
409 {"Acid: Things that fall in are gone", "forever (including our hero)"},
410 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
411 {"Door: Can be opened by the key", "with the same color"},
412 {"Door: You have to find out the", "right color of the key for it"},
413 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
414 {"Dynamite: This one explodes after", "a few seconds"},
415 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
416 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
417 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
418 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
419 {"Bug: Moves at the right side", "of walls; don't touch it!"},
420 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
421 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
422 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
423 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
424 {"Cruncher (BD style):", "Eats almost everything"},
425 {"Robot: Tries to kill the player", ""},
426 {"The mole: You must guide him savely","to the exit; he will follow you"},
427 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
428 {"The Pig: Harmless, but eats all", "gems it can get"},
429 {"The Dragon: Breathes fire,", "especially to some monsters"},
430 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
431 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
432 {"Light Bulb: All of them must be", "switched on to finish a level"},
433 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
434 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
435 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
436 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
437 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
438 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
439 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
440 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
441 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
442 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
443 {"Exit door: Opens if you have enough","emeralds to finish the level"},
444 {"Open exit door: Enter here to leave","the level and exit the actual game"},
446 static int num_helpscreen_els = sizeof(helpscreen_eltext)/(2*sizeof(char *));
448 static char *helpscreen_music[][3] =
450 { "Alchemy", "Ian Boddy", "Drive" },
451 { "The Chase", "Propaganda", "A Secret Wish" },
452 { "Network 23", "Tangerine Dream", "Exit" },
453 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
454 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
455 { "Voyager", "The Alan Parsons Project","Pyramid" },
456 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
458 static int helpscreen_musicpos;
460 void DrawHelpScreenElAction(int start)
464 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
466 while(helpscreen_action[j] != HA_END)
468 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
470 else if (i<start || helpscreen_delay[i-start])
472 if (i>=start && helpscreen_delay[i-start])
473 helpscreen_delay[i-start]--;
475 while(helpscreen_action[j] != HA_NEXT)
482 j += 3*helpscreen_step[i-start];
483 graphic = helpscreen_action[j++];
485 if (helpscreen_frame[i-start])
487 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
488 helpscreen_frame[i-start]--;
493 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
496 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
498 if (helpscreen_action[j] == HA_NEXT)
500 if (!helpscreen_frame[i-start])
501 helpscreen_step[i-start] = 0;
505 if (!helpscreen_frame[i-start])
506 helpscreen_step[i-start]++;
507 while(helpscreen_action[j] != HA_NEXT)
512 DrawGraphicExt(drawto, gc, xstart, ystart+(i-start)*ystep, graphic+frame);
523 void DrawHelpScreenElText(int start)
526 int xstart = SX + 56, ystart = SY + 65 + 2 * 32, ystep = TILEY + 4;
527 int ybottom = SYSIZE - 20;
532 DrawTextFCentered(100, FC_GREEN, "The game elements:");
534 for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++)
537 ystart + (i - start) * ystep + (*helpscreen_eltext[i][1] ? 0 : 8),
538 helpscreen_eltext[i][0], FS_SMALL, FC_YELLOW);
539 DrawText(xstart, ystart + (i - start) * ystep + 16,
540 helpscreen_eltext[i][1], FS_SMALL, FC_YELLOW);
543 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
546 void DrawHelpScreenMusicText(int num)
548 int ystart = 150, ystep = 30;
549 int ybottom = SYSIZE - 20;
555 DrawTextFCentered(100, FC_GREEN, "The game background music loops:");
557 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
559 DrawTextFCentered(ystart + 1 * ystep, FC_RED, "\"%s\"",
560 helpscreen_music[num][0]);
561 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
563 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
564 "%s", helpscreen_music[num][1]);
565 DrawTextFCentered(ystart + 4 * ystep, FC_YELLOW,
567 DrawTextFCentered(ystart + 5 * ystep, FC_RED, "\"%s\"",
568 helpscreen_music[num][2]);
570 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
572 PlaySoundLoop(background_loop[num]);
575 void DrawHelpScreenCreditsText()
577 int ystart = 150, ystep = 30;
578 int ybottom = SYSIZE - 20;
584 DrawTextFCentered(100, FC_GREEN,
586 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
587 "DOS/Windows port of the game:");
588 DrawTextFCentered(ystart + 1 * ystep, FC_RED,
590 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
591 "Additional toons:");
592 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
594 DrawTextFCentered(ystart + 5 * ystep, FC_YELLOW,
595 "...and many thanks to all contributors");
596 DrawTextFCentered(ystart + 6 * ystep, FC_YELLOW,
599 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
602 void DrawHelpScreenContactText()
604 int ystart = 150, ystep = 30;
605 int ybottom = SYSIZE - 20;
610 DrawTextFCentered(100, FC_GREEN, "Program information:");
612 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
613 "This game is Freeware!");
614 DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW,
615 "If you like it, send e-mail to:");
616 DrawTextFCentered(ystart + 2 * ystep, FC_RED,
617 "aeglos@valinor.owl.de");
618 DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW,
620 DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED,
622 DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED,
624 DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED,
626 DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED,
629 DrawTextFCentered(ystart + 7 * ystep, FC_YELLOW,
630 "If you have created new levels,");
631 DrawTextFCentered(ystart + 8 * ystep, FC_YELLOW,
632 "send them to me to include them!");
633 DrawTextFCentered(ystart + 9 * ystep, FC_YELLOW,
636 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for main menu");
639 void DrawHelpScreen()
643 CloseDoor(DOOR_CLOSE_2);
645 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
646 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
647 helpscreen_musicpos = 0;
648 helpscreen_state = 0;
649 DrawHelpScreenElText(0);
650 DrawHelpScreenElAction(0);
654 PlaySoundLoop(SND_RHYTHMLOOP);
657 void HandleHelpScreen(int button)
659 static long hs_delay = 0;
660 int num_helpscreen_els_pages =
661 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
662 int button_released = !button;
667 if (helpscreen_state < num_helpscreen_els_pages - 1)
669 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
670 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
672 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
673 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
675 else if (helpscreen_state < num_helpscreen_els_pages + num_bg_loops - 1)
678 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
680 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops - 1)
683 DrawHelpScreenCreditsText();
685 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops)
688 DrawHelpScreenContactText();
694 game_status = MAINMENU;
699 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
701 if (helpscreen_state<num_helpscreen_els_pages)
702 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
710 void HandleTypeName(int newxpos, KeySym key)
712 static int xpos = 0, ypos = 2;
718 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW);
719 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
723 if (((key >= XK_A && key <= XK_Z) || (key >= XK_a && key <= XK_z)) &&
724 xpos < MAX_NAMELEN - 1)
726 if (key >= XK_A && key <= XK_Z)
727 ascii = 'A' + (char)(key - XK_A);
728 if (key >= XK_a && key <= XK_z)
729 ascii = 'a' + (char)(key - XK_a);
731 setup.player_name[xpos] = ascii;
732 setup.player_name[xpos + 1] = 0;
734 DrawTextExt(drawto, gc, SX + 6*32, SY + ypos*32,
735 setup.player_name, FS_BIG, FC_YELLOW);
736 DrawTextExt(window, gc, SX + 6*32, SY + ypos*32,
737 setup.player_name, FS_BIG, FC_YELLOW);
738 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
740 else if ((key == XK_Delete || key == XK_BackSpace) && xpos > 0)
743 setup.player_name[xpos] = 0;
744 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
745 DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM);
747 else if (key == XK_Return && xpos > 0)
749 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
750 DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM);
753 game_status = MAINMENU;
759 void DrawChooseLevel()
761 CloseDoor(DOOR_CLOSE_2);
765 HandleChooseLevel(0,0, 0,0, MB_MENU_INITIALIZE);
768 static void drawChooseLevelList(int first_entry, int num_page_entries)
771 char buffer[SCR_FIELDX];
774 DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN);
776 for(i=0; i<num_page_entries; i++)
778 strncpy(buffer, leveldir[first_entry + i].name , SCR_FIELDX - 1);
779 buffer[SCR_FIELDX - 1] = '\0';
780 DrawText(SX + 32, SY + (i + 2) * 32, buffer, FS_BIG, FC_YELLOW);
781 DrawGraphic(0, i + 2, GFX_KUGEL_BLAU);
785 DrawGraphic(0, 1, GFX_PFEIL_O);
787 if (first_entry + num_page_entries < num_leveldirs)
788 DrawGraphic(0, MAX_LEVEL_SERIES_ON_SCREEN + 1, GFX_PFEIL_U);
791 static void drawChooseLevelInfo(int leveldir_nr)
793 XFillRectangle(display, drawto, gc, SX + 32, SY + 32, SXSIZE - 32, 32);
794 DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
795 leveldir[leveldir_nr].levels,
796 leveldir[leveldir_nr].readonly ? "readonly" : "writable");
799 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
801 static int choice = 3;
802 static int first_entry = 0;
803 static long choose_delay = 0;
804 static int redraw = TRUE;
805 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
806 int num_page_entries;
808 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
809 num_page_entries = num_leveldirs;
811 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
813 if (button == MB_MENU_INITIALIZE)
816 choice = leveldir_nr + 3 - first_entry;
818 if (choice > num_page_entries + 2)
820 choice = num_page_entries + 2;
821 first_entry = num_leveldirs - num_page_entries;
824 drawChooseLevelList(first_entry, num_page_entries);
825 drawChooseLevelInfo(leveldir_nr);
830 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
834 if (button == MB_MENU_INITIALIZE)
848 if (x == 1 && y == 2)
850 if (first_entry > 0 &&
851 (dy || DelayReached(&choose_delay, 150)))
854 drawChooseLevelList(first_entry, num_page_entries);
855 drawChooseLevelInfo(first_entry);
856 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
860 else if (x == 1 && y > num_page_entries + 2)
862 if (first_entry + num_page_entries < num_leveldirs &&
863 (dy || DelayReached(&choose_delay, 150)))
866 drawChooseLevelList(first_entry, num_page_entries);
867 drawChooseLevelInfo(first_entry + num_page_entries - 1);
868 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
873 if (!mx && !my && !dx && !dy)
879 if (x == 1 && y >= 3 && y <= num_page_entries + 2)
885 DrawGraphic(0, y - 1, GFX_KUGEL_ROT);
886 DrawGraphic(0, choice - 1, GFX_KUGEL_BLAU);
887 drawChooseLevelInfo(first_entry + y - 3);
893 leveldir_nr = first_entry + y - 3;
895 getLastPlayedLevelOfLevelSeries(leveldir[leveldir_nr].filename);
900 game_status = MAINMENU;
908 if (game_status == CHOOSELEVEL)
912 void DrawHallOfFame(int highlight_position)
916 CloseDoor(DOOR_CLOSE_2);
918 if (highlight_position < 0)
923 DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
924 DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
926 for(i=0; i<MAX_LEVEL_SERIES_ON_SCREEN; i++)
928 DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG,
929 (i == highlight_position ? FC_RED : FC_GREEN));
930 DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG,
931 (i == highlight_position ? FC_RED : FC_GREEN));
932 DrawText(SX + 12 * 32, SY + 64 + i * 32,
933 int2str(highscore[i].Score, 5), FS_BIG,
934 (i == highlight_position ? FC_RED : FC_GREEN));
939 PlaySound(SND_HALLOFFAME);
942 void HandleHallOfFame(int button)
944 int button_released = !button;
948 FadeSound(SND_HALLOFFAME);
949 game_status = MAINMENU;
957 void DrawSetupScreen()
966 { &setup.sound, "Sound:", },
967 { &setup.sound_loops, " Sound Loops:" },
968 { &setup.sound_music, " Game Music:" },
969 { &setup.toons, "Toons:" },
970 { &setup.double_buffering, "Buffered gfx:" },
971 { &setup.scroll_delay, "Scroll Delay:" },
972 { &setup.soft_scrolling, "Soft Scroll.:" },
973 { &setup.fading, "Fading:" },
974 { &setup.quick_doors, "Quick Doors:" },
975 { &setup.autorecord, "Auto-Record:" },
976 { &setup.team_mode, "Team-Mode:" },
977 { NULL, "Input Devices" },
980 { NULL, "Save and exit" }
983 CloseDoor(DOOR_CLOSE_2);
985 DrawText(SX+16, SY+16, "SETUP",FS_BIG,FC_YELLOW);
987 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
989 int base = i - SETUP_SCREEN_POS_START;
991 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
993 DrawGraphic(0,i,GFX_KUGEL_BLAU);
994 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
997 if (setup_info[base].value)
999 int setting_value = *setup_info[base].value;
1001 DrawText(SX+14*32, SY+i*32, (setting_value ? "on" : "off"),
1002 FS_BIG, (setting_value ? FC_YELLOW : FC_BLUE));
1008 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
1011 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
1013 static int choice = 3;
1014 static int redraw = TRUE;
1015 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1016 int pos_start = SETUP_SCREEN_POS_START + 1;
1017 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
1018 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
1019 int pos_end = SETUP_SCREEN_POS_END + 1;
1021 if (button == MB_MENU_INITIALIZE)
1026 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
1030 if (button == MB_MENU_INITIALIZE)
1043 if (y >= pos_empty1 && y <= pos_empty2)
1044 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1048 else if (y > pos_end)
1052 if (!mx && !my && !dx && !dy)
1058 if (x==1 && y >= pos_start && y <= pos_end &&
1059 !(y >= pos_empty1 && y <= pos_empty2))
1065 DrawGraphic(0,y-1,GFX_KUGEL_ROT);
1066 DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
1074 if (y==3 && sound_status==SOUND_AVAILABLE)
1078 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1079 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1080 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1081 setup.sound_loops = FALSE;
1082 setup.sound_music = FALSE;
1085 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1086 setup.sound = !setup.sound;
1088 else if (y==4 && sound_loops_allowed)
1090 if (setup.sound_loops)
1091 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1094 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1095 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1098 setup.sound_loops = !setup.sound_loops;
1100 else if (y==5 && sound_loops_allowed)
1102 if (setup.sound_music)
1103 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 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1110 setup.sound_music = !setup.sound_music;
1115 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1117 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1118 setup.toons = !setup.toons;
1122 if (setup.double_buffering)
1123 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1125 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1126 setup.double_buffering = !setup.double_buffering;
1127 setup.direct_draw = !setup.double_buffering;
1131 if (setup.scroll_delay)
1132 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1134 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1135 setup.scroll_delay = !setup.scroll_delay;
1139 if (setup.soft_scrolling)
1140 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1142 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1143 setup.soft_scrolling = !setup.soft_scrolling;
1148 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1150 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1151 setup.fading = !setup.fading;
1155 if (setup.quick_doors)
1156 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1158 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1159 setup.quick_doors = !setup.quick_doors;
1163 if (setup.autorecord)
1164 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1166 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1167 setup.autorecord = !setup.autorecord;
1171 if (setup.team_mode)
1172 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1174 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1175 setup.team_mode = !setup.team_mode;
1179 game_status = SETUPINPUT;
1180 DrawSetupInputScreen();
1183 else if (y==pos_end-1 || y==pos_end)
1194 save_joystick_data(JOYSTICK_FILENAME);
1200 game_status = MAINMENU;
1208 if (game_status==SETUP)
1212 void DrawSetupInputScreen()
1215 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1217 DrawGraphic(0, 2, GFX_KUGEL_BLAU);
1218 DrawGraphic(0, 3, GFX_KUGEL_BLAU);
1219 DrawGraphic(0, 4, GFX_KUGEL_BLAU);
1220 DrawGraphic(0, 15, GFX_KUGEL_BLAU);
1221 DrawGraphic(10, 2, GFX_PFEIL_L);
1222 DrawGraphic(12, 2, GFX_PFEIL_R);
1224 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1225 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1226 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1228 DrawTextFCentered(SYSIZE - 20, FC_BLUE,
1229 "Joysticks deactivated on this screen");
1231 HandleSetupInputScreen(0,0, 0,0, MB_MENU_INITIALIZE);
1236 static void setJoystickDeviceToNr(char *device_name, int device_nr)
1238 if (device_name == NULL)
1241 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
1244 if (strlen(device_name) > 1)
1246 char c1 = device_name[strlen(device_name) - 1];
1247 char c2 = device_name[strlen(device_name) - 2];
1249 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
1250 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
1253 strncpy(device_name, joystick_device_name[device_nr], strlen(device_name));
1256 static void drawPlayerSetupInputInfo(int player_nr)
1259 static struct SetupKeyboardInfo custom_key;
1266 { &custom_key.left, "Joystick Left" },
1267 { &custom_key.right, "Joystick Right" },
1268 { &custom_key.up, "Joystick Up" },
1269 { &custom_key.down, "Joystick Down" },
1270 { &custom_key.snap, "Button 1" },
1271 { &custom_key.bomb, "Button 2" }
1273 static char *joystick_name[MAX_PLAYERS] =
1281 custom_key = setup.input[player_nr].key;
1283 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1284 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1286 if (setup.input[player_nr].use_joystick)
1288 char *device_name = setup.input[player_nr].joy.device_name;
1290 DrawText(SX+8*32, SY+3*32,
1291 joystick_name[getJoystickNrFromDeviceName(device_name)],
1293 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1297 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1298 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1301 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1302 DrawGraphic(1, 6, GFX_PFEIL_L);
1303 DrawGraphic(1, 7, GFX_PFEIL_R);
1304 DrawGraphic(1, 8, GFX_PFEIL_O);
1305 DrawGraphic(1, 9, GFX_PFEIL_U);
1306 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1307 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1308 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1309 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1310 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1311 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1315 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1317 DrawText(SX + 3*32, SY + ypos*32,
1318 " ", FS_BIG, FC_YELLOW);
1319 DrawText(SX + 3*32, SY + ypos*32,
1320 (setup.input[player_nr].use_joystick ?
1322 getKeyNameFromKeySym(*custom[i].keysym)),
1327 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1329 static int choice = 3;
1330 static int player_nr = 0;
1331 static int redraw = TRUE;
1332 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1333 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1334 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1335 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1336 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1338 if (button == MB_MENU_INITIALIZE)
1340 drawPlayerSetupInputInfo(player_nr);
1346 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
1350 if (button == MB_MENU_INITIALIZE)
1355 if (dx && choice == 3)
1357 x = (dx < 0 ? 11 : 13);
1360 else if (dx && choice == 4)
1362 button = MB_MENU_CHOICE;
1374 if (y >= pos_empty1 && y <= pos_empty2)
1375 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1379 else if (y > pos_end)
1383 if (!mx && !my && !dx && !dy)
1389 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1391 static long delay = 0;
1393 if (!DelayReached(&delay, 150))
1396 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1398 drawPlayerSetupInputInfo(player_nr);
1400 else if (x==1 && y >= pos_start && y <= pos_end &&
1401 !(y >= pos_empty1 && y <= pos_empty2))
1407 DrawGraphic(0, y-1, GFX_KUGEL_ROT);
1408 DrawGraphic(0, choice-1, GFX_KUGEL_BLAU);
1416 char *device_name = setup.input[player_nr].joy.device_name;
1418 if (!setup.input[player_nr].use_joystick)
1420 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
1422 setJoystickDeviceToNr(device_name, new_device_nr);
1423 setup.input[player_nr].use_joystick = TRUE;
1427 int device_nr = getJoystickNrFromDeviceName(device_name);
1428 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
1430 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
1431 setup.input[player_nr].use_joystick = FALSE;
1433 setJoystickDeviceToNr(device_name, new_device_nr);
1443 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1444 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1446 if (setup.input[player_nr].use_joystick)
1448 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1449 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1451 setup.input[player_nr].use_joystick = FALSE;
1455 setup.input[player_nr].use_joystick = TRUE;
1456 setup.input[player_nr].joystick_nr = one_joystick_nr;
1460 drawPlayerSetupInputInfo(player_nr);
1464 if (setup.input[player_nr].use_joystick)
1467 game_status = CALIBRATION;
1468 CalibrateJoystick(player_nr);
1469 game_status = SETUPINPUT;
1472 CustomizeKeyboard(player_nr);
1476 else if (y == pos_end)
1480 game_status = SETUP;
1490 if (game_status == SETUPINPUT)
1494 void CustomizeKeyboard(int player_nr)
1498 boolean finished = FALSE;
1499 static struct SetupKeyboardInfo custom_key;
1504 } customize_step[] =
1506 { &custom_key.left, "Move Left" },
1507 { &custom_key.right, "Move Right" },
1508 { &custom_key.up, "Move Up" },
1509 { &custom_key.down, "Move Down" },
1510 { &custom_key.snap, "Snap Field" },
1511 { &custom_key.bomb, "Place Bomb" }
1514 /* read existing key bindings from player setup */
1515 custom_key = setup.input[player_nr].key;
1518 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1524 DrawText(SX, SY + (2+2*step_nr)*32,
1525 customize_step[step_nr].text, FS_BIG, FC_RED);
1526 DrawText(SX, SY + (2+2*step_nr+1)*32,
1527 "Key:", FS_BIG, FC_RED);
1528 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1529 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1534 if (XPending(display)) /* got event from X server */
1538 XNextEvent(display, &event);
1544 KeySym key = XLookupKeysym((XKeyEvent *)&event,
1545 ((XKeyEvent *)&event)->state);
1547 if (key == XK_Escape || (key == XK_Return && step_nr == 6))
1553 /* press 'Enter' to keep the existing key binding */
1554 if (key == XK_Return || step_nr == 6)
1555 key = *customize_step[step_nr].keysym;
1557 /* check if key already used */
1558 for (i=0; i<step_nr; i++)
1559 if (*customize_step[i].keysym == key)
1564 /* got new key binding */
1565 *customize_step[step_nr].keysym = key;
1566 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1567 " ", FS_BIG, FC_YELLOW);
1568 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1569 getKeyNameFromKeySym(key), FS_BIG, FC_YELLOW);
1572 /* un-highlight last query */
1573 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1574 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1575 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1576 "Key:", FS_BIG, FC_GREEN);
1578 /* press 'Enter' to leave */
1581 DrawText(SX + 16, SY + 15*32+16,
1582 "Press Enter", FS_BIG, FC_YELLOW);
1586 /* query next key binding */
1587 DrawText(SX, SY+(2+2*step_nr)*32,
1588 customize_step[step_nr].text, FS_BIG, FC_RED);
1589 DrawText(SX, SY+(2+2*step_nr+1)*32,
1590 "Key:", FS_BIG, FC_RED);
1591 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1592 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1598 key_joystick_mapping = 0;
1602 HandleOtherEvents(&event);
1610 /* don't eat all CPU time */
1614 /* write new key bindings back to player setup */
1615 setup.input[player_nr].key = custom_key;
1618 DrawSetupInputScreen();
1621 void CalibrateJoystick(int player_nr)
1624 struct joystick joy_ctrl;
1626 struct joystick_control
1635 int new_joystick_xleft = 128, new_joystick_xright = 128;
1636 int new_joystick_yupper = 128, new_joystick_ylower = 128;
1637 int new_joystick_xmiddle, new_joystick_ymiddle;
1639 int calibration_step = 1;
1642 int joystick_fd = stored_player[player_nr].joystick_fd;
1643 int x, y, last_x, last_y, xpos = 8, ypos = 3;
1644 boolean check[3][3];
1645 int check_remaining;
1649 if (joystick_status == JOYSTICK_OFF ||
1651 !setup.input[player_nr].use_joystick)
1657 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW);
1658 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW);
1659 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ", FS_BIG, FC_YELLOW);
1660 DrawText(SX, SY + 10*32, " ARE YELLOW, ", FS_BIG, FC_YELLOW);
1661 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
1662 check_remaining = 3 * 3;
1664 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
1665 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
1666 DrawText(SX, SY + 9*32, " CENTER POSITION ", FS_BIG, FC_YELLOW);
1667 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
1668 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
1669 check_remaining = 0;
1676 check[x][y] = FALSE;
1677 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
1681 joy_value = Joystick(player_nr);
1682 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
1683 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
1684 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
1689 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1691 joy_ctrl.buttons = 0;
1694 while(Joystick(player_nr) & JOY_BUTTON);
1700 if (XPending(display)) /* got event from X server */
1704 XNextEvent(display, &event);
1709 switch(XLookupKeysym((XKeyEvent *)&event,
1710 ((XKeyEvent *)&event)->state))
1713 if (check_remaining == 0)
1727 key_joystick_mapping = 0;
1731 HandleOtherEvents(&event);
1737 if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1739 joystick_status = JOYSTICK_OFF;
1743 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
1744 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
1745 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
1746 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
1748 new_joystick_xmiddle =
1749 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
1750 new_joystick_ymiddle =
1751 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
1753 setup.input[player_nr].joy.xleft = new_joystick_xleft;
1754 setup.input[player_nr].joy.yupper = new_joystick_yupper;
1755 setup.input[player_nr].joy.xright = new_joystick_xright;
1756 setup.input[player_nr].joy.ylower = new_joystick_ylower;
1757 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
1758 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
1760 CheckJoystickData();
1763 joy_value = Joystick(player_nr);
1765 if (joy_value & JOY_BUTTON && check_remaining == 0)
1770 if (calibration_step == 1)
1775 else if (calibrate_joystick(joystick_fd) != 0)
1777 joystick_status = JOYSTICK_OFF;
1781 if (joy[joystick_fd].flags & JOYFLAG_CALIBRATE)
1786 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
1787 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
1789 if (calibration_step == 2)
1790 DrawText(SX + 16, SY + 9*32," THE UPPER LEFT ", FS_BIG, FC_YELLOW);
1792 DrawText(SX, SY + 9*32," THE LOWER RIGHT ", FS_BIG, FC_YELLOW);
1794 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
1795 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
1799 while(Joystick(player_nr) & JOY_BUTTON)
1805 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
1806 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
1808 if (x != last_x || y != last_y)
1811 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
1813 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_BLAU);
1815 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
1820 if (check_remaining > 0 && !check[x+1][y+1])
1822 check[x+1][y+1] = TRUE;
1827 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
1828 setup.input[player_nr].joy.xleft,
1829 setup.input[player_nr].joy.xmiddle,
1830 setup.input[player_nr].joy.xright);
1831 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
1832 setup.input[player_nr].joy.yupper,
1833 setup.input[player_nr].joy.ymiddle,
1834 setup.input[player_nr].joy.ylower);
1842 /* don't eat all CPU time */
1848 DrawSetupInputScreen();
1849 while(Joystick(player_nr) & JOY_BUTTON);
1855 DrawText(SX + 16, SY + 6*32, " JOYSTICK NOT ", FS_BIG, FC_YELLOW);
1856 DrawText(SX, SY + 7*32, " AVAILABLE ", FS_BIG, FC_YELLOW);
1859 DrawSetupInputScreen();
1866 void CalibrateJoystick_OLD()
1869 struct joystick joy_ctrl;
1871 struct joystick_control
1883 int joystick_nr = setup.input[0].joystick_nr;
1884 int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle;
1885 int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle;
1887 if (joystick_status == JOYSTICK_OFF)
1892 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1893 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
1894 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1898 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1900 joy_ctrl.buttons = 0;
1902 while(Joystick() & JOY_BUTTON);
1904 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1906 while(!joy_ctrl.buttons)
1909 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1911 joystick_status=JOYSTICK_OFF;
1917 new_joystick_xleft = joy_ctrl.x;
1918 new_joystick_yupper = joy_ctrl.y;
1921 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1922 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
1923 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1927 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1929 joy_ctrl.buttons = 0;
1931 while(Joystick() & JOY_BUTTON);
1933 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1935 while(!joy_ctrl.buttons)
1938 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1940 joystick_status=JOYSTICK_OFF;
1946 new_joystick_xright = joy_ctrl.x;
1947 new_joystick_ylower = joy_ctrl.y;
1950 DrawText(SX+32, SY+16+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
1951 DrawText(SX+16, SY+16+8*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1955 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1957 joy_ctrl.buttons = 0;
1959 while(Joystick() & JOY_BUTTON);
1961 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1963 while(!joy_ctrl.buttons)
1966 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1968 joystick_status=JOYSTICK_OFF;
1974 new_joystick_xmiddle = joy_ctrl.x;
1975 new_joystick_ymiddle = joy_ctrl.y;
1977 setup.input[player_nr].joy.xleft = new_joystick_xleft;
1978 setup.input[player_nr].joy.yupper = new_joystick_yupper;
1979 setup.input[player_nr].joy.xright = new_joystick_xright;
1980 setup.input[player_nr].joy.ylower = new_joystick_ylower;
1981 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
1982 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
1984 CheckJoystickData();
1987 while(Joystick() & JOY_BUTTON);
1995 joy_nr[1] = SETUP_2ND_JOYSTICK_ON(local_player->setup)+49;
2000 DrawText(SX+32, SY+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
2001 DrawText(SX+16+7*32, SY+8*32, joy_nr, FS_BIG,FC_YELLOW);
2002 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
2005 for(clear_keybuf();!keypressed(););
2006 install_joystick(JOY_TYPE_2PADS);
2009 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
2010 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
2011 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
2014 for(clear_keybuf();!keypressed(););
2015 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
2018 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
2019 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
2020 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
2023 for(clear_keybuf();!keypressed(););
2024 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
2031 DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
2032 DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
2042 void HandleGameActions()
2044 if (game_status != PLAYING)
2047 if (local_player->LevelSolved)
2050 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2058 void HandleVideoButtons(int mx, int my, int button)
2060 if (game_status != MAINMENU && game_status != PLAYING)
2063 switch(CheckVideoButtons(mx,my,button))
2065 case BUTTON_VIDEO_EJECT:
2067 if (TAPE_IS_EMPTY(tape))
2070 if (TAPE_IS_EMPTY(tape))
2071 Request("No tape for this level !",REQ_CONFIRM);
2076 SaveTape(tape.level_nr);
2079 DrawCompleteVideoDisplay();
2082 case BUTTON_VIDEO_STOP:
2086 case BUTTON_VIDEO_PAUSE:
2090 case BUTTON_VIDEO_REC:
2091 if (TAPE_IS_STOPPED(tape))
2093 TapeStartRecording();
2096 if (options.network)
2097 SendToServer_StartPlaying();
2101 game_status = PLAYING;
2105 else if (tape.pausing)
2107 if (tape.playing) /* PLAYING -> PAUSING -> RECORDING */
2109 tape.pos[tape.counter].delay = tape.delay_played;
2110 tape.playing = FALSE;
2111 tape.recording = TRUE;
2112 tape.changed = TRUE;
2114 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON,0);
2121 case BUTTON_VIDEO_PLAY:
2122 if (TAPE_IS_EMPTY(tape))
2125 if (TAPE_IS_STOPPED(tape))
2129 game_status = PLAYING;
2132 else if (tape.playing)
2134 if (tape.pausing) /* PAUSE -> PLAY */
2136 else if (!tape.fast_forward) /* PLAY -> FAST FORWARD PLAY */
2138 tape.fast_forward = TRUE;
2139 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
2141 else if (!tape.pause_before_death) /* FFWD PLAY -> + AUTO PAUSE */
2143 tape.pause_before_death = TRUE;
2144 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
2146 else /* -> NORMAL PLAY */
2148 tape.fast_forward = FALSE;
2149 tape.pause_before_death = FALSE;
2150 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PBEND_OFF, 0);
2162 void HandleSoundButtons(int mx, int my, int button)
2164 if (game_status != PLAYING)
2167 switch(CheckSoundButtons(mx,my,button))
2169 case BUTTON_SOUND_MUSIC:
2170 if (setup.sound_music)
2172 setup.sound_music = FALSE;
2173 FadeSound(background_loop[level_nr % num_bg_loops]);
2174 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
2176 else if (sound_loops_allowed)
2178 setup.sound = setup.sound_music = TRUE;
2179 PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
2180 DrawSoundDisplay(BUTTON_SOUND_MUSIC_ON);
2183 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
2186 case BUTTON_SOUND_LOOPS:
2187 if (setup.sound_loops)
2189 setup.sound_loops = FALSE;
2190 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
2192 else if (sound_loops_allowed)
2194 setup.sound = setup.sound_loops = TRUE;
2195 DrawSoundDisplay(BUTTON_SOUND_LOOPS_ON);
2198 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
2201 case BUTTON_SOUND_SIMPLE:
2202 if (setup.sound_simple)
2204 setup.sound_simple = FALSE;
2205 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
2207 else if (sound_status==SOUND_AVAILABLE)
2209 setup.sound = setup.sound_simple = TRUE;
2210 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_ON);
2213 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
2223 void HandleGameButtons(int mx, int my, int button)
2225 if (game_status != PLAYING)
2228 switch(CheckGameButtons(mx,my,button))
2230 case BUTTON_GAME_STOP:
2233 CloseDoor(DOOR_CLOSE_1);
2234 game_status = MAINMENU;
2239 if (Request("Do you really want to quit the game ?",
2240 REQ_ASK | REQ_STAY_CLOSED))
2243 if (options.network)
2244 SendToServer_StopPlaying();
2248 game_status = MAINMENU;
2253 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
2256 case BUTTON_GAME_PAUSE:
2257 if (options.network)
2261 SendToServer_ContinuePlaying();
2263 SendToServer_PausePlaying();
2270 case BUTTON_GAME_PLAY:
2274 if (options.network)
2275 SendToServer_ContinuePlaying();
2279 tape.pausing = FALSE;
2280 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);