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(PROGRAM_TITLE_STRING) * FONT1_XSIZE) / 2;
52 DrawText(x, SY + 8, PROGRAM_TITLE_STRING, FS_BIG, FC_YELLOW);
53 DrawTextFCentered(46, FC_RED, COPYRIGHT_STRING);
59 char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:");
63 XAutoRepeatOn(display);
65 /* needed if last screen was the playing screen, invoked from level editor */
66 if (level_editor_test_game)
68 game_status = LEVELED;
73 /* map gadgets for main menu screen */
81 DrawText(SX + 32, SY + 2*32, name_text, FS_BIG, FC_GREEN);
82 DrawText(SX + 6*32, SY + 2*32, setup.player_name, FS_BIG, FC_RED);
83 DrawText(SX + 32, SY + 3*32, "Level:", FS_BIG, FC_GREEN);
84 DrawText(SX + 11*32, SY + 3*32, int2str(level_nr,3), FS_BIG,
85 (leveldir[leveldir_nr].readonly ? FC_RED : FC_YELLOW));
86 DrawText(SX + 32, SY + 4*32, "Hall Of Fame", FS_BIG, FC_GREEN);
87 DrawText(SX + 32, SY + 5*32, "Level Creator", FS_BIG, FC_GREEN);
88 DrawText(SY + 32, SY + 6*32, "Info Screen", FS_BIG, FC_GREEN);
89 DrawText(SX + 32, SY + 7*32, "Start Game", FS_BIG, FC_GREEN);
90 DrawText(SX + 32, SY + 8*32, "Setup", FS_BIG, FC_GREEN);
91 DrawText(SX + 32, SY + 9*32, "Quit", FS_BIG, FC_GREEN);
93 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
95 DrawTextF(7*32 + 6, 3*32 + 9, FC_RED, "%d-%d",
96 leveldir[leveldir_nr].first_level,
97 leveldir[leveldir_nr].last_level);
99 if (leveldir[leveldir_nr].readonly)
101 DrawTextF(15*32 + 6, 3*32 + 9 - 7, FC_RED, "READ");
102 DrawTextF(15*32 + 6, 3*32 + 9 + 7, FC_RED, "ONLY");
106 DrawGraphic(0, i, GFX_KUGEL_BLAU);
107 DrawGraphic(10, 3, GFX_PFEIL_L);
108 DrawGraphic(14, 3, GFX_PFEIL_R);
110 DrawText(SX + 56, SY + 326, "A Game by Artsoft Entertainment",
113 if (leveldir[leveldir_nr].name)
115 int len = strlen(leveldir[leveldir_nr].name);
116 int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2;
117 int lypos = SY + 352;
119 DrawText(lxpos, lypos, leveldir[leveldir_nr].name, FS_SMALL, FC_SPECIAL2);
124 HandleMainMenu(0,0, 0,0, MB_MENU_INITIALIZE);
127 if (TAPE_IS_EMPTY(tape))
129 DrawCompleteVideoDisplay();
131 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
136 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
138 static int choice = 3;
139 static int redraw = TRUE;
140 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
142 if (redraw || button == MB_MENU_INITIALIZE)
144 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
148 if (button == MB_MENU_INITIALIZE)
153 if (dx && choice == 4)
155 x = (dx < 0 ? 11 : 15);
172 if (!mx && !my && !dx && !dy)
178 if (y == 4 && ((x == 11 && level_nr > leveldir[leveldir_nr].first_level) ||
179 (x == 15 && level_nr < leveldir[leveldir_nr].last_level)) &&
182 static unsigned long level_delay = 0;
183 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
184 int new_level_nr, old_level_nr = level_nr;
185 int font_color = (leveldir[leveldir_nr].readonly ? FC_RED : FC_YELLOW);
187 new_level_nr = level_nr + (x == 11 ? -step : +step);
188 if (new_level_nr < leveldir[leveldir_nr].first_level)
189 new_level_nr = leveldir[leveldir_nr].first_level;
190 if (new_level_nr > leveldir[leveldir_nr].last_level)
191 new_level_nr = leveldir[leveldir_nr].last_level;
193 if (old_level_nr == new_level_nr ||
194 !DelayReached(&level_delay, GADGET_FRAME_DELAY))
197 level_nr = new_level_nr;
199 DrawTextExt(drawto, gc, SX + 11 * 32, SY + 3 * 32,
200 int2str(level_nr, 3), FS_BIG, font_color);
201 DrawTextExt(window, gc, SX + 11 * 32, SY + 3 * 32,
202 int2str(level_nr, 3), FS_BIG, font_color);
205 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
209 DrawCompleteVideoDisplay();
211 /* needed because DrawMicroLevel() takes some time */
213 XSync(display, FALSE);
214 DelayReached(&level_delay, 0); /* reset delay counter */
216 else if (x == 1 && y >= 3 && y <= 10)
222 DrawGraphic(0, y-1, GFX_KUGEL_ROT);
223 DrawGraphic(0, choice - 1, GFX_KUGEL_BLAU);
231 game_status = TYPENAME;
232 HandleTypeName(strlen(setup.player_name), 0);
238 game_status = CHOOSELEVEL;
245 game_status = HALLOFFAME;
250 if (leveldir[leveldir_nr].readonly &&
251 strcmp(setup.player_name, "Artsoft") != 0)
252 Request("This level is read only !", REQ_CONFIRM);
253 game_status = LEVELED;
258 game_status = HELPSCREEN;
263 if (setup.autorecord)
264 TapeStartRecording();
268 SendToServer_StartPlaying();
272 game_status = PLAYING;
284 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
285 game_status = EXITGAME;
295 if (game_status == MAINMENU)
297 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE);
302 #define MAX_HELPSCREEN_ELS 10
306 static long helpscreen_state;
307 static int helpscreen_step[MAX_HELPSCREEN_ELS];
308 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
309 static int helpscreen_delay[MAX_HELPSCREEN_ELS];
310 static int helpscreen_action[] =
312 GFX_SPIELER1_DOWN,4,2,
314 GFX_SPIELER1_LEFT,4,2,
315 GFX_SPIELER1_RIGHT,4,2,
316 GFX_SPIELER1_PUSH_LEFT,4,2,
317 GFX_SPIELER1_PUSH_RIGHT,4,2, HA_NEXT,
318 GFX_ERDREICH,1,100, HA_NEXT,
319 GFX_LEERRAUM,1,100, HA_NEXT,
320 GFX_MORAST_LEER,1,100, HA_NEXT,
321 GFX_BETON,1,100, HA_NEXT,
322 GFX_MAUERWERK,1,100, HA_NEXT,
323 GFX_MAUER_L1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
324 GFX_MAUER_R1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
325 GFX_MAUER_UP, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
326 GFX_MAUER_DOWN,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
327 GFX_UNSICHTBAR,1,100, HA_NEXT,
328 GFX_FELSBODEN,1,100, HA_NEXT,
329 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
330 GFX_EDELSTEIN,2,5, HA_NEXT,
331 GFX_DIAMANT,2,5, HA_NEXT,
332 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
333 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
334 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
335 GFX_FELSBROCKEN,4,5, HA_NEXT,
336 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
337 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
338 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
339 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
340 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
341 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
342 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
343 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
344 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
345 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
346 GFX_GEBLUBBER,4,4, HA_NEXT,
347 GFX_SCHLUESSEL1,4,25, HA_NEXT,
348 GFX_PFORTE1,4,25, HA_NEXT,
349 GFX_PFORTE1X,4,25, HA_NEXT,
350 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
351 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
352 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
353 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
354 GFX_LEERRAUM,1,10, HA_NEXT,
355 GFX_DYNABOMB_NR,1,100, HA_NEXT,
356 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
357 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
358 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
359 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
360 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
361 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
362 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
363 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
364 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
365 GFX_BUTTERFLY,2,2, HA_NEXT,
366 GFX_FIREFLY,2,2, HA_NEXT,
367 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
368 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
369 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
370 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
371 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
372 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
373 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
374 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
375 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
376 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
377 GFX_MAULWURF_DOWN,4,2,
379 GFX_MAULWURF_LEFT,4,2,
380 GFX_MAULWURF_RIGHT,4,2, HA_NEXT,
381 GFX_PINGUIN_DOWN,4,2,
383 GFX_PINGUIN_LEFT,4,2,
384 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
385 GFX_SCHWEIN_DOWN,4,2,
387 GFX_SCHWEIN_LEFT,4,2,
388 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
392 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
393 GFX_SONDE_START,8,1, HA_NEXT,
394 GFX_ABLENK,4,1, HA_NEXT,
395 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
396 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
397 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
398 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
399 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
400 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
401 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
402 GFX_DIAMANT,1,10, HA_NEXT,
403 GFX_LIFE,1,100, HA_NEXT,
404 GFX_LIFE_ASYNC,1,100, HA_NEXT,
405 GFX_SIEB_INAKTIV,4,2, HA_NEXT,
406 GFX_SIEB2_INAKTIV,4,2, HA_NEXT,
407 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
408 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
409 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
410 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
411 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
412 GFX_SOKOBAN_OBJEKT,1,100, HA_NEXT,
413 GFX_SOKOBAN_FELD_LEER,1,100, HA_NEXT,
414 GFX_SOKOBAN_FELD_VOLL,1,100, HA_NEXT,
415 GFX_SPEED_PILL,1,100, HA_NEXT,
418 static char *helpscreen_eltext[][2] =
420 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
421 {"Normal sand:", "You can dig through it"},
422 {"Empty field:", "You can walk through it"},
423 {"Quicksand: You cannot pass it,", "but rocks can fall though it"},
424 {"Massive Wall:", "Nothing can go through it"},
425 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
426 {"Growing Wall: Grows in several di-", "rections if there is an empty field"},
427 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
428 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
429 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
430 {"Emerald: You must collect enough of","them to finish a level"},
431 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
432 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
433 {"Colorful Gems:", "Seem to behave like Emeralds"},
434 {"Rock: Smashes several things;", "Can be moved by the player"},
435 {"Bomb: You can move it, but be", "careful when dropping it"},
436 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
437 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
438 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
439 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
440 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
441 {"Acid: Things that fall in are gone", "forever (including our hero)"},
442 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
443 {"Door: Can be opened by the key", "with the same color"},
444 {"Door: You have to find out the", "right color of the key for it"},
445 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
446 {"Dynamite: This one explodes after", "a few seconds"},
447 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
448 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
449 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
450 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
451 {"Bug: Moves at the right side", "of walls; don't touch it!"},
452 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
453 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
454 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
455 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
456 {"Cruncher (BD style):", "Eats almost everything"},
457 {"Robot: Tries to kill the player", ""},
458 {"The mole: You must guide him savely","to the exit; he will follow you"},
459 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
460 {"The Pig: Harmless, but eats all", "gems it can get"},
461 {"The Dragon: Breathes fire,", "especially to some monsters"},
462 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
463 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
464 {"Light Bulb: All of them must be", "switched on to finish a level"},
465 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
466 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
467 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
468 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
469 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
470 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
471 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
472 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
473 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
474 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
475 {"Exit door: Opens if you have enough","emeralds to finish the level"},
476 {"Open exit door: Enter here to leave","the level and exit the actual game"},
477 {"Sokoban element: Object which must", "be pushed to an empty field"},
478 {"Sokoban element: Empty field where", "a Sokoban object can be placed on"},
479 {"Sokoban element: Field with object", "which can be pushed away"},
480 {"Speed pill: Lets the player run", "twice as fast as normally"},
482 static int num_helpscreen_els = sizeof(helpscreen_eltext)/(2*sizeof(char *));
484 static char *helpscreen_music[][3] =
486 { "Alchemy", "Ian Boddy", "Drive" },
487 { "The Chase", "Propaganda", "A Secret Wish" },
488 { "Network 23", "Tangerine Dream", "Exit" },
489 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
490 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
491 { "Voyager", "The Alan Parsons Project","Pyramid" },
492 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
494 static int helpscreen_musicpos;
496 void DrawHelpScreenElAction(int start)
500 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
502 while(helpscreen_action[j] != HA_END)
504 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
506 else if (i<start || helpscreen_delay[i-start])
508 if (i>=start && helpscreen_delay[i-start])
509 helpscreen_delay[i-start]--;
511 while(helpscreen_action[j] != HA_NEXT)
518 j += 3*helpscreen_step[i-start];
519 graphic = helpscreen_action[j++];
521 if (helpscreen_frame[i-start])
523 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
524 helpscreen_frame[i-start]--;
529 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
532 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
534 if (helpscreen_action[j] == HA_NEXT)
536 if (!helpscreen_frame[i-start])
537 helpscreen_step[i-start] = 0;
541 if (!helpscreen_frame[i-start])
542 helpscreen_step[i-start]++;
543 while(helpscreen_action[j] != HA_NEXT)
548 DrawGraphicExt(drawto, gc, xstart, ystart+(i-start)*ystep, graphic+frame);
559 void DrawHelpScreenElText(int start)
562 int xstart = SX + 56, ystart = SY + 65 + 2 * 32, ystep = TILEY + 4;
563 int ybottom = SYSIZE - 20;
568 DrawTextFCentered(100, FC_GREEN, "The game elements:");
570 for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++)
573 ystart + (i - start) * ystep + (*helpscreen_eltext[i][1] ? 0 : 8),
574 helpscreen_eltext[i][0], FS_SMALL, FC_YELLOW);
575 DrawText(xstart, ystart + (i - start) * ystep + 16,
576 helpscreen_eltext[i][1], FS_SMALL, FC_YELLOW);
579 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
582 void DrawHelpScreenMusicText(int num)
584 int ystart = 150, ystep = 30;
585 int ybottom = SYSIZE - 20;
591 DrawTextFCentered(100, FC_GREEN, "The game background music loops:");
593 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
595 DrawTextFCentered(ystart + 1 * ystep, FC_RED, "\"%s\"",
596 helpscreen_music[num][0]);
597 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
599 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
600 "%s", helpscreen_music[num][1]);
601 DrawTextFCentered(ystart + 4 * ystep, FC_YELLOW,
603 DrawTextFCentered(ystart + 5 * ystep, FC_RED, "\"%s\"",
604 helpscreen_music[num][2]);
606 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
608 PlaySoundLoop(background_loop[num]);
611 void DrawHelpScreenCreditsText()
613 int ystart = 150, ystep = 30;
614 int ybottom = SYSIZE - 20;
620 DrawTextFCentered(100, FC_GREEN,
622 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
623 "DOS/Windows port of the game:");
624 DrawTextFCentered(ystart + 1 * ystep, FC_RED,
626 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
627 "Additional toons:");
628 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
630 DrawTextFCentered(ystart + 5 * ystep, FC_YELLOW,
631 "...and many thanks to all contributors");
632 DrawTextFCentered(ystart + 6 * ystep, FC_YELLOW,
635 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
638 void DrawHelpScreenContactText()
640 int ystart = 150, ystep = 30;
641 int ybottom = SYSIZE - 20;
646 DrawTextFCentered(100, FC_GREEN, "Program information:");
648 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
649 "This game is Freeware!");
650 DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW,
651 "If you like it, send e-mail to:");
652 DrawTextFCentered(ystart + 2 * ystep, FC_RED,
653 "aeglos@valinor.owl.de");
654 DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW,
656 DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED,
658 DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED,
660 DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED,
662 DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED,
665 DrawTextFCentered(ystart + 7 * ystep, FC_YELLOW,
666 "If you have created new levels,");
667 DrawTextFCentered(ystart + 8 * ystep, FC_YELLOW,
668 "send them to me to include them!");
669 DrawTextFCentered(ystart + 9 * ystep, FC_YELLOW,
672 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for main menu");
675 void DrawHelpScreen()
680 CloseDoor(DOOR_CLOSE_2);
682 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
683 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
684 helpscreen_musicpos = 0;
685 helpscreen_state = 0;
686 DrawHelpScreenElText(0);
687 DrawHelpScreenElAction(0);
691 PlaySoundLoop(SND_RHYTHMLOOP);
694 void HandleHelpScreen(int button)
696 static unsigned long hs_delay = 0;
697 int num_helpscreen_els_pages =
698 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
699 int button_released = !button;
704 if (helpscreen_state < num_helpscreen_els_pages - 1)
706 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
707 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
709 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
710 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
712 else if (helpscreen_state < num_helpscreen_els_pages + num_bg_loops - 1)
715 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
717 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops - 1)
720 DrawHelpScreenCreditsText();
722 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops)
725 DrawHelpScreenContactText();
731 game_status = MAINMENU;
736 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
738 if (helpscreen_state<num_helpscreen_els_pages)
739 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
747 void HandleTypeName(int newxpos, KeySym key)
749 static int xpos = 0, ypos = 2;
754 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW);
755 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
759 if (((key >= XK_A && key <= XK_Z) || (key >= XK_a && key <= XK_z)) &&
760 xpos < MAX_NAMELEN - 1)
764 if (key >= XK_A && key <= XK_Z)
765 ascii = 'A' + (char)(key - XK_A);
767 ascii = 'a' + (char)(key - XK_a);
769 setup.player_name[xpos] = ascii;
770 setup.player_name[xpos + 1] = 0;
772 DrawTextExt(drawto, gc, SX + 6*32, SY + ypos*32,
773 setup.player_name, FS_BIG, FC_YELLOW);
774 DrawTextExt(window, gc, SX + 6*32, SY + ypos*32,
775 setup.player_name, FS_BIG, FC_YELLOW);
776 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
778 else if ((key == XK_Delete || key == XK_BackSpace) && xpos > 0)
781 setup.player_name[xpos] = 0;
782 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
783 DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM);
785 else if (key == XK_Return && xpos > 0)
787 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
788 DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM);
791 game_status = MAINMENU;
797 void DrawChooseLevel()
800 CloseDoor(DOOR_CLOSE_2);
804 HandleChooseLevel(0,0, 0,0, MB_MENU_INITIALIZE);
807 static void drawChooseLevelList(int first_entry, int num_page_entries)
810 char buffer[SCR_FIELDX];
813 DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN);
815 for(i=0; i<num_page_entries; i++)
817 strncpy(buffer, leveldir[first_entry + i].name , SCR_FIELDX - 1);
818 buffer[SCR_FIELDX - 1] = '\0';
819 DrawText(SX + 32, SY + (i + 2) * 32, buffer,
820 FS_BIG, leveldir[first_entry + i].color);
821 DrawGraphic(0, i + 2, GFX_KUGEL_BLAU);
825 DrawGraphic(0, 1, GFX_PFEIL_O);
827 if (first_entry + num_page_entries < num_leveldirs)
828 DrawGraphic(0, MAX_LEVEL_SERIES_ON_SCREEN + 1, GFX_PFEIL_U);
831 static void drawChooseLevelInfo(int leveldir_nr)
833 int x, last_redraw_mask = redraw_mask;
835 XFillRectangle(display, drawto, gc, SX + 32, SY + 32, SXSIZE - 32, 32);
836 DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
837 leveldir[leveldir_nr].levels,
838 leveldir[leveldir_nr].readonly ? "readonly" : "writable");
840 /* let BackToFront() redraw only what is needed */
841 redraw_mask = last_redraw_mask | REDRAW_TILES;
842 for (x=0; x<SCR_FIELDX; x++)
846 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
848 static int choice = 3;
849 static int first_entry = 0;
850 static unsigned long choose_delay = 0;
851 static int redraw = TRUE;
852 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
853 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
854 int num_page_entries;
856 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
857 num_page_entries = num_leveldirs;
859 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
861 if (button == MB_MENU_INITIALIZE)
864 choice = leveldir_nr + 3 - first_entry;
866 if (choice > num_page_entries + 2)
868 choice = num_page_entries + 2;
869 first_entry = num_leveldirs - num_page_entries;
872 drawChooseLevelList(first_entry, num_page_entries);
873 drawChooseLevelInfo(leveldir_nr);
878 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
882 if (button == MB_MENU_INITIALIZE)
896 if (x == 1 && y == 2)
898 if (first_entry > 0 &&
899 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
908 drawChooseLevelList(first_entry, num_page_entries);
909 drawChooseLevelInfo(first_entry);
910 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
914 else if (x == 1 && y > num_page_entries + 2)
916 if (first_entry + num_page_entries < num_leveldirs &&
917 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
923 if (first_entry + num_page_entries > num_leveldirs)
924 first_entry = num_leveldirs - num_page_entries;
926 drawChooseLevelList(first_entry, num_page_entries);
927 drawChooseLevelInfo(first_entry + num_page_entries - 1);
928 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
933 if (!mx && !my && !dx && !dy)
939 if (x == 1 && y >= 3 && y <= num_page_entries + 2)
945 DrawGraphic(0, y - 1, GFX_KUGEL_ROT);
946 DrawGraphic(0, choice - 1, GFX_KUGEL_BLAU);
947 drawChooseLevelInfo(first_entry + y - 3);
953 leveldir_nr = first_entry + y - 3;
955 getLastPlayedLevelOfLevelSeries(leveldir[leveldir_nr].filename);
960 game_status = MAINMENU;
968 if (game_status == CHOOSELEVEL)
972 void DrawHallOfFame(int highlight_position)
977 CloseDoor(DOOR_CLOSE_2);
979 if (highlight_position < 0)
984 DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
985 DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
987 for(i=0; i<MAX_LEVEL_SERIES_ON_SCREEN; i++)
989 DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG,
990 (i == highlight_position ? FC_RED : FC_GREEN));
991 DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG,
992 (i == highlight_position ? FC_RED : FC_GREEN));
993 DrawText(SX + 12 * 32, SY + 64 + i * 32,
994 int2str(highscore[i].Score, 5), FS_BIG,
995 (i == highlight_position ? FC_RED : FC_GREEN));
1000 PlaySound(SND_HALLOFFAME);
1003 void HandleHallOfFame(int button)
1005 int button_released = !button;
1007 if (button_released)
1009 FadeSound(SND_HALLOFFAME);
1010 game_status = MAINMENU;
1018 void DrawSetupScreen()
1027 { &setup.sound, "Sound:", },
1028 { &setup.sound_loops, " Sound Loops:" },
1029 { &setup.sound_music, " Game Music:" },
1030 { &setup.toons, "Toons:" },
1031 { &setup.double_buffering, "Buffered gfx:" },
1032 { &setup.scroll_delay, "Scroll Delay:" },
1033 { &setup.soft_scrolling, "Soft Scroll.:" },
1034 { &setup.fading, "Fading:" },
1035 { &setup.quick_doors, "Quick Doors:" },
1036 { &setup.autorecord, "Auto-Record:" },
1037 { &setup.team_mode, "Team-Mode:" },
1038 { NULL, "Input Devices" },
1041 { NULL, "Save and exit" }
1045 CloseDoor(DOOR_CLOSE_2);
1048 DrawText(SX + 16, SY + 16, "SETUP",FS_BIG,FC_YELLOW);
1050 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
1052 int base = i - SETUP_SCREEN_POS_START;
1054 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
1056 DrawGraphic(0,i,GFX_KUGEL_BLAU);
1057 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
1060 if (setup_info[base].value)
1062 int setting_value = *setup_info[base].value;
1064 DrawText(SX+14*32, SY+i*32, (setting_value ? "on" : "off"),
1065 FS_BIG, (setting_value ? FC_YELLOW : FC_BLUE));
1071 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
1074 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
1076 static int choice = 3;
1077 static int redraw = TRUE;
1078 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1079 int pos_start = SETUP_SCREEN_POS_START + 1;
1080 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
1081 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
1082 int pos_end = SETUP_SCREEN_POS_END + 1;
1084 if (button == MB_MENU_INITIALIZE)
1089 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
1093 if (button == MB_MENU_INITIALIZE)
1106 if (y >= pos_empty1 && y <= pos_empty2)
1107 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1111 else if (y > pos_end)
1115 if (!mx && !my && !dx && !dy)
1121 if (x==1 && y >= pos_start && y <= pos_end &&
1122 !(y >= pos_empty1 && y <= pos_empty2))
1128 DrawGraphic(0,y-1,GFX_KUGEL_ROT);
1129 DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
1137 if (y==3 && sound_status==SOUND_AVAILABLE)
1141 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1142 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1143 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1144 setup.sound_loops = FALSE;
1145 setup.sound_music = FALSE;
1148 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1149 setup.sound = !setup.sound;
1151 else if (y==4 && sound_loops_allowed)
1153 if (setup.sound_loops)
1154 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1157 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1158 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1161 setup.sound_loops = !setup.sound_loops;
1163 else if (y==5 && sound_loops_allowed)
1165 if (setup.sound_music)
1166 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1169 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1170 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1173 setup.sound_music = !setup.sound_music;
1178 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1180 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1181 setup.toons = !setup.toons;
1186 if (setup.double_buffering)
1187 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1189 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1190 setup.double_buffering = !setup.double_buffering;
1191 setup.direct_draw = !setup.double_buffering;
1193 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1194 setup.double_buffering = TRUE;
1195 setup.direct_draw = !setup.double_buffering;
1200 if (setup.scroll_delay)
1201 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1203 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1204 setup.scroll_delay = !setup.scroll_delay;
1208 if (setup.soft_scrolling)
1209 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1211 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1212 setup.soft_scrolling = !setup.soft_scrolling;
1217 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1219 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1220 setup.fading = !setup.fading;
1224 if (setup.quick_doors)
1225 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1227 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1228 setup.quick_doors = !setup.quick_doors;
1232 if (setup.autorecord)
1233 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1235 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1236 setup.autorecord = !setup.autorecord;
1240 if (setup.team_mode)
1241 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1243 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1244 setup.team_mode = !setup.team_mode;
1248 game_status = SETUPINPUT;
1249 DrawSetupInputScreen();
1252 else if (y==pos_end-1 || y==pos_end)
1263 save_joystick_data(JOYSTICK_FILENAME);
1269 game_status = MAINMENU;
1277 if (game_status==SETUP)
1281 void DrawSetupInputScreen()
1284 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1286 DrawGraphic(0, 2, GFX_KUGEL_BLAU);
1287 DrawGraphic(0, 3, GFX_KUGEL_BLAU);
1288 DrawGraphic(0, 4, GFX_KUGEL_BLAU);
1289 DrawGraphic(0, 15, GFX_KUGEL_BLAU);
1290 DrawGraphic(10, 2, GFX_PFEIL_L);
1291 DrawGraphic(12, 2, GFX_PFEIL_R);
1293 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1294 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1295 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1297 DrawTextFCentered(SYSIZE - 20, FC_BLUE,
1298 "Joysticks deactivated on this screen");
1300 HandleSetupInputScreen(0,0, 0,0, MB_MENU_INITIALIZE);
1305 static void setJoystickDeviceToNr(char *device_name, int device_nr)
1307 if (device_name == NULL)
1310 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
1313 if (strlen(device_name) > 1)
1315 char c1 = device_name[strlen(device_name) - 1];
1316 char c2 = device_name[strlen(device_name) - 2];
1318 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
1319 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
1322 strncpy(device_name, joystick_device_name[device_nr], strlen(device_name));
1325 static void drawPlayerSetupInputInfo(int player_nr)
1328 static struct SetupKeyboardInfo custom_key;
1335 { &custom_key.left, "Joystick Left" },
1336 { &custom_key.right, "Joystick Right" },
1337 { &custom_key.up, "Joystick Up" },
1338 { &custom_key.down, "Joystick Down" },
1339 { &custom_key.snap, "Button 1" },
1340 { &custom_key.bomb, "Button 2" }
1342 static char *joystick_name[MAX_PLAYERS] =
1350 custom_key = setup.input[player_nr].key;
1352 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1353 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1355 if (setup.input[player_nr].use_joystick)
1357 char *device_name = setup.input[player_nr].joy.device_name;
1359 DrawText(SX+8*32, SY+3*32,
1360 joystick_name[getJoystickNrFromDeviceName(device_name)],
1362 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1366 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1367 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1370 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1371 DrawGraphic(1, 6, GFX_PFEIL_L);
1372 DrawGraphic(1, 7, GFX_PFEIL_R);
1373 DrawGraphic(1, 8, GFX_PFEIL_O);
1374 DrawGraphic(1, 9, GFX_PFEIL_U);
1375 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1376 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1377 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1378 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1379 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1380 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1384 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1386 DrawText(SX + 3*32, SY + ypos*32,
1387 " ", FS_BIG, FC_YELLOW);
1388 DrawText(SX + 3*32, SY + ypos*32,
1389 (setup.input[player_nr].use_joystick ?
1391 getKeyNameFromKeySym(*custom[i].keysym)),
1396 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1398 static int choice = 3;
1399 static int player_nr = 0;
1400 static int redraw = TRUE;
1401 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1402 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1403 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1404 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1405 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1407 if (button == MB_MENU_INITIALIZE)
1409 drawPlayerSetupInputInfo(player_nr);
1415 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
1419 if (button == MB_MENU_INITIALIZE)
1424 if (dx && choice == 3)
1426 x = (dx < 0 ? 11 : 13);
1429 else if (dx && choice == 4)
1431 button = MB_MENU_CHOICE;
1443 if (y >= pos_empty1 && y <= pos_empty2)
1444 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1448 else if (y > pos_end)
1452 if (!mx && !my && !dx && !dy)
1458 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1460 static unsigned long delay = 0;
1462 if (!DelayReached(&delay, GADGET_FRAME_DELAY))
1465 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1467 drawPlayerSetupInputInfo(player_nr);
1469 else if (x==1 && y >= pos_start && y <= pos_end &&
1470 !(y >= pos_empty1 && y <= pos_empty2))
1476 DrawGraphic(0, y-1, GFX_KUGEL_ROT);
1477 DrawGraphic(0, choice-1, GFX_KUGEL_BLAU);
1485 char *device_name = setup.input[player_nr].joy.device_name;
1487 if (!setup.input[player_nr].use_joystick)
1489 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
1491 setJoystickDeviceToNr(device_name, new_device_nr);
1492 setup.input[player_nr].use_joystick = TRUE;
1496 int device_nr = getJoystickNrFromDeviceName(device_name);
1497 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
1499 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
1500 setup.input[player_nr].use_joystick = FALSE;
1502 setJoystickDeviceToNr(device_name, new_device_nr);
1512 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1513 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1515 if (setup.input[player_nr].use_joystick)
1517 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1518 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1520 setup.input[player_nr].use_joystick = FALSE;
1524 setup.input[player_nr].use_joystick = TRUE;
1525 setup.input[player_nr].joystick_nr = one_joystick_nr;
1529 drawPlayerSetupInputInfo(player_nr);
1533 if (setup.input[player_nr].use_joystick)
1536 game_status = CALIBRATION;
1537 CalibrateJoystick(player_nr);
1538 game_status = SETUPINPUT;
1541 CustomizeKeyboard(player_nr);
1545 else if (y == pos_end)
1549 game_status = SETUP;
1559 if (game_status == SETUPINPUT)
1563 void CustomizeKeyboard(int player_nr)
1567 boolean finished = FALSE;
1568 static struct SetupKeyboardInfo custom_key;
1573 } customize_step[] =
1575 { &custom_key.left, "Move Left" },
1576 { &custom_key.right, "Move Right" },
1577 { &custom_key.up, "Move Up" },
1578 { &custom_key.down, "Move Down" },
1579 { &custom_key.snap, "Snap Field" },
1580 { &custom_key.bomb, "Place Bomb" }
1583 /* read existing key bindings from player setup */
1584 custom_key = setup.input[player_nr].key;
1587 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1593 DrawText(SX, SY + (2+2*step_nr)*32,
1594 customize_step[step_nr].text, FS_BIG, FC_RED);
1595 DrawText(SX, SY + (2+2*step_nr+1)*32,
1596 "Key:", FS_BIG, FC_RED);
1597 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1598 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1603 if (XPending(display)) /* got event from X server */
1607 XNextEvent(display, &event);
1613 KeySym key = XLookupKeysym((XKeyEvent *)&event,
1614 ((XKeyEvent *)&event)->state);
1616 if (key == XK_Escape || (key == XK_Return && step_nr == 6))
1622 /* press 'Enter' to keep the existing key binding */
1623 if (key == XK_Return || step_nr == 6)
1624 key = *customize_step[step_nr].keysym;
1626 /* check if key already used */
1627 for (i=0; i<step_nr; i++)
1628 if (*customize_step[i].keysym == key)
1633 /* got new key binding */
1634 *customize_step[step_nr].keysym = key;
1635 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1636 " ", FS_BIG, FC_YELLOW);
1637 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1638 getKeyNameFromKeySym(key), FS_BIG, FC_YELLOW);
1641 /* un-highlight last query */
1642 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1643 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1644 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1645 "Key:", FS_BIG, FC_GREEN);
1647 /* press 'Enter' to leave */
1650 DrawText(SX + 16, SY + 15*32+16,
1651 "Press Enter", FS_BIG, FC_YELLOW);
1655 /* query next key binding */
1656 DrawText(SX, SY+(2+2*step_nr)*32,
1657 customize_step[step_nr].text, FS_BIG, FC_RED);
1658 DrawText(SX, SY+(2+2*step_nr+1)*32,
1659 "Key:", FS_BIG, FC_RED);
1660 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1661 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1667 key_joystick_mapping = 0;
1671 HandleOtherEvents(&event);
1679 /* don't eat all CPU time */
1683 /* write new key bindings back to player setup */
1684 setup.input[player_nr].key = custom_key;
1687 DrawSetupInputScreen();
1690 void CalibrateJoystick(int player_nr)
1693 struct joystick joy_ctrl;
1695 struct joystick_control
1704 int new_joystick_xleft = 128, new_joystick_xright = 128;
1705 int new_joystick_yupper = 128, new_joystick_ylower = 128;
1706 int new_joystick_xmiddle, new_joystick_ymiddle;
1708 int calibration_step = 1;
1711 int joystick_fd = stored_player[player_nr].joystick_fd;
1712 int x, y, last_x, last_y, xpos = 8, ypos = 3;
1713 boolean check[3][3];
1714 int check_remaining;
1718 if (joystick_status == JOYSTICK_OFF ||
1720 !setup.input[player_nr].use_joystick)
1726 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW);
1727 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW);
1728 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ", FS_BIG, FC_YELLOW);
1729 DrawText(SX, SY + 10*32, " ARE YELLOW, ", FS_BIG, FC_YELLOW);
1730 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
1731 check_remaining = 3 * 3;
1733 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
1734 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
1735 DrawText(SX, SY + 9*32, " CENTER POSITION ", FS_BIG, FC_YELLOW);
1736 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
1737 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
1738 check_remaining = 0;
1745 check[x][y] = FALSE;
1746 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
1750 joy_value = Joystick(player_nr);
1751 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
1752 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
1753 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
1758 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1760 joy_ctrl.buttons = 0;
1763 while(Joystick(player_nr) & JOY_BUTTON);
1769 if (XPending(display)) /* got event from X server */
1773 XNextEvent(display, &event);
1778 switch(XLookupKeysym((XKeyEvent *)&event,
1779 ((XKeyEvent *)&event)->state))
1782 if (check_remaining == 0)
1796 key_joystick_mapping = 0;
1800 HandleOtherEvents(&event);
1806 if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1808 joystick_status = JOYSTICK_OFF;
1812 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
1813 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
1814 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
1815 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
1817 new_joystick_xmiddle =
1818 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
1819 new_joystick_ymiddle =
1820 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
1822 setup.input[player_nr].joy.xleft = new_joystick_xleft;
1823 setup.input[player_nr].joy.yupper = new_joystick_yupper;
1824 setup.input[player_nr].joy.xright = new_joystick_xright;
1825 setup.input[player_nr].joy.ylower = new_joystick_ylower;
1826 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
1827 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
1829 CheckJoystickData();
1832 joy_value = Joystick(player_nr);
1834 if (joy_value & JOY_BUTTON && check_remaining == 0)
1839 if (calibration_step == 1)
1844 else if (calibrate_joystick(joystick_fd) != 0)
1846 joystick_status = JOYSTICK_OFF;
1850 if (joy[joystick_fd].flags & JOYFLAG_CALIBRATE)
1855 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
1856 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
1858 if (calibration_step == 2)
1859 DrawText(SX + 16, SY + 9*32," THE UPPER LEFT ", FS_BIG, FC_YELLOW);
1861 DrawText(SX, SY + 9*32," THE LOWER RIGHT ", FS_BIG, FC_YELLOW);
1863 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
1864 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
1868 while(Joystick(player_nr) & JOY_BUTTON)
1874 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
1875 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
1877 if (x != last_x || y != last_y)
1880 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
1882 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_BLAU);
1884 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
1889 if (check_remaining > 0 && !check[x+1][y+1])
1891 check[x+1][y+1] = TRUE;
1896 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
1897 setup.input[player_nr].joy.xleft,
1898 setup.input[player_nr].joy.xmiddle,
1899 setup.input[player_nr].joy.xright);
1900 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
1901 setup.input[player_nr].joy.yupper,
1902 setup.input[player_nr].joy.ymiddle,
1903 setup.input[player_nr].joy.ylower);
1911 /* don't eat all CPU time */
1917 DrawSetupInputScreen();
1918 while(Joystick(player_nr) & JOY_BUTTON);
1924 DrawText(SX + 16, SY + 6*32, " JOYSTICK NOT ", FS_BIG, FC_YELLOW);
1925 DrawText(SX, SY + 7*32, " AVAILABLE ", FS_BIG, FC_YELLOW);
1928 DrawSetupInputScreen();
1935 void CalibrateJoystick_OLD()
1938 struct joystick joy_ctrl;
1940 struct joystick_control
1952 int joystick_nr = setup.input[0].joystick_nr;
1953 int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle;
1954 int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle;
1956 if (joystick_status == JOYSTICK_OFF)
1961 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1962 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
1963 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1967 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1969 joy_ctrl.buttons = 0;
1971 while(Joystick() & JOY_BUTTON);
1973 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1975 while(!joy_ctrl.buttons)
1978 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1980 joystick_status=JOYSTICK_OFF;
1986 new_joystick_xleft = joy_ctrl.x;
1987 new_joystick_yupper = joy_ctrl.y;
1990 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1991 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
1992 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1996 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1998 joy_ctrl.buttons = 0;
2000 while(Joystick() & JOY_BUTTON);
2002 while(!(joy_ctrl.b1 || joy_ctrl.b2))
2004 while(!joy_ctrl.buttons)
2007 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
2009 joystick_status=JOYSTICK_OFF;
2015 new_joystick_xright = joy_ctrl.x;
2016 new_joystick_ylower = joy_ctrl.y;
2019 DrawText(SX+32, SY+16+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
2020 DrawText(SX+16, SY+16+8*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
2024 joy_ctrl.b1 = joy_ctrl.b2 = 0;
2026 joy_ctrl.buttons = 0;
2028 while(Joystick() & JOY_BUTTON);
2030 while(!(joy_ctrl.b1 || joy_ctrl.b2))
2032 while(!joy_ctrl.buttons)
2035 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
2037 joystick_status=JOYSTICK_OFF;
2043 new_joystick_xmiddle = joy_ctrl.x;
2044 new_joystick_ymiddle = joy_ctrl.y;
2046 setup.input[player_nr].joy.xleft = new_joystick_xleft;
2047 setup.input[player_nr].joy.yupper = new_joystick_yupper;
2048 setup.input[player_nr].joy.xright = new_joystick_xright;
2049 setup.input[player_nr].joy.ylower = new_joystick_ylower;
2050 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
2051 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
2053 CheckJoystickData();
2056 while(Joystick() & JOY_BUTTON);
2064 joy_nr[1] = SETUP_2ND_JOYSTICK_ON(local_player->setup)+49;
2069 DrawText(SX+32, SY+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
2070 DrawText(SX+16+7*32, SY+8*32, joy_nr, FS_BIG,FC_YELLOW);
2071 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
2074 for(clear_keybuf();!keypressed(););
2075 install_joystick(JOY_TYPE_2PADS);
2078 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
2079 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
2080 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
2083 for(clear_keybuf();!keypressed(););
2084 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
2087 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
2088 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
2089 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
2092 for(clear_keybuf();!keypressed(););
2093 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
2100 DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
2101 DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
2111 void HandleGameActions()
2113 if (game_status != PLAYING)
2116 if (local_player->LevelSolved)
2119 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2127 void HandleVideoButtons(int mx, int my, int button)
2134 if (game_status != MAINMENU && game_status != PLAYING)
2137 switch(CheckVideoButtons(mx,my,button))
2139 case BUTTON_VIDEO_EJECT:
2141 if (TAPE_IS_EMPTY(tape))
2144 if (TAPE_IS_EMPTY(tape))
2145 Request("No tape for this level !",REQ_CONFIRM);
2150 SaveTape(tape.level_nr);
2153 DrawCompleteVideoDisplay();
2156 case BUTTON_VIDEO_STOP:
2160 case BUTTON_VIDEO_PAUSE:
2164 case BUTTON_VIDEO_REC:
2165 if (TAPE_IS_STOPPED(tape))
2167 TapeStartRecording();
2170 if (options.network)
2171 SendToServer_StartPlaying();
2175 game_status = PLAYING;
2179 else if (tape.pausing)
2181 if (tape.playing) /* PLAYING -> PAUSING -> RECORDING */
2183 tape.pos[tape.counter].delay = tape.delay_played;
2184 tape.playing = FALSE;
2185 tape.recording = TRUE;
2186 tape.changed = TRUE;
2188 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON,0);
2195 case BUTTON_VIDEO_PLAY:
2196 if (TAPE_IS_EMPTY(tape))
2199 if (TAPE_IS_STOPPED(tape))
2203 game_status = PLAYING;
2206 else if (tape.playing)
2208 if (tape.pausing) /* PAUSE -> PLAY */
2210 else if (!tape.fast_forward) /* PLAY -> FAST FORWARD PLAY */
2212 tape.fast_forward = TRUE;
2213 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
2215 else if (!tape.pause_before_death) /* FFWD PLAY -> + AUTO PAUSE */
2217 tape.pause_before_death = TRUE;
2218 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
2220 else /* -> NORMAL PLAY */
2222 tape.fast_forward = FALSE;
2223 tape.pause_before_death = FALSE;
2224 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PBEND_OFF, 0);
2236 void HandleSoundButtons(int mx, int my, int button)
2245 if (game_status != PLAYING)
2248 switch(CheckSoundButtons(mx,my,button))
2250 case BUTTON_SOUND_MUSIC:
2251 if (setup.sound_music)
2253 setup.sound_music = FALSE;
2254 FadeSound(background_loop[level_nr % num_bg_loops]);
2255 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
2257 else if (sound_loops_allowed)
2259 setup.sound = setup.sound_music = TRUE;
2260 PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
2261 DrawSoundDisplay(BUTTON_SOUND_MUSIC_ON);
2264 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
2267 case BUTTON_SOUND_LOOPS:
2268 if (setup.sound_loops)
2270 setup.sound_loops = FALSE;
2271 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
2273 else if (sound_loops_allowed)
2275 setup.sound = setup.sound_loops = TRUE;
2276 DrawSoundDisplay(BUTTON_SOUND_LOOPS_ON);
2279 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
2282 case BUTTON_SOUND_SIMPLE:
2283 if (setup.sound_simple)
2285 setup.sound_simple = FALSE;
2286 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
2288 else if (sound_status==SOUND_AVAILABLE)
2290 setup.sound = setup.sound_simple = TRUE;
2291 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_ON);
2294 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
2304 void HandleGameButtons(int mx, int my, int button)
2313 if (game_status != PLAYING)
2316 switch(CheckGameButtons(mx,my,button))
2318 case BUTTON_GAME_STOP:
2321 CloseDoor(DOOR_CLOSE_1);
2322 game_status = MAINMENU;
2327 if (Request("Do you really want to quit the game ?",
2328 REQ_ASK | REQ_STAY_CLOSED))
2331 if (options.network)
2332 SendToServer_StopPlaying();
2336 game_status = MAINMENU;
2341 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
2344 case BUTTON_GAME_PAUSE:
2345 if (options.network)
2349 SendToServer_ContinuePlaying();
2351 SendToServer_PausePlaying();
2358 case BUTTON_GAME_PLAY:
2362 if (options.network)
2363 SendToServer_ContinuePlaying();
2367 tape.pausing = FALSE;
2368 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);