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:");
61 XAutoRepeatOn(display);
63 /* needed if last screen was the playing screen, invoked from level editor */
64 if (level_editor_test_game)
66 game_status = LEVELED;
71 /* needed if last screen was the level editor */
72 UnmapLevelEditorGadgets();
80 DrawText(SX + 32, SY + 2*32, name_text, FS_BIG, FC_GREEN);
81 DrawText(SX + 6*32, SY + 2*32, setup.player_name, FS_BIG, FC_RED);
82 DrawText(SX + 32, SY + 3*32, "Level:", FS_BIG, FC_GREEN);
83 DrawText(SX + 11*32, SY + 3*32, int2str(level_nr,3), FS_BIG,
84 (leveldir[leveldir_nr].readonly ? FC_RED : FC_YELLOW));
85 DrawText(SX + 32, SY + 4*32, "Hall Of Fame", FS_BIG, FC_GREEN);
86 DrawText(SX + 32, SY + 5*32, "Level Creator", FS_BIG, FC_GREEN);
87 DrawText(SY + 32, SY + 6*32, "Info Screen", FS_BIG, FC_GREEN);
88 DrawText(SX + 32, SY + 7*32, "Start Game", FS_BIG, FC_GREEN);
89 DrawText(SX + 32, SY + 8*32, "Setup", FS_BIG, FC_GREEN);
90 DrawText(SX + 32, SY + 9*32, "Quit", FS_BIG, FC_GREEN);
92 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
94 DrawTextF(7*32 + 6, 3*32 + 9, FC_RED, "%d-%d",
95 leveldir[leveldir_nr].first_level,
96 leveldir[leveldir_nr].last_level);
98 if (leveldir[leveldir_nr].readonly)
100 DrawTextF(15*32 + 6, 3*32 + 9 - 7, FC_RED, "READ");
101 DrawTextF(15*32 + 6, 3*32 + 9 + 7, FC_RED, "ONLY");
105 DrawGraphic(0, i, GFX_KUGEL_BLAU);
106 DrawGraphic(10, 3, GFX_PFEIL_L);
107 DrawGraphic(14, 3, GFX_PFEIL_R);
109 DrawText(SX + 56, SY + 326, "A Game by Artsoft Entertainment",
112 if (leveldir[leveldir_nr].name)
114 int len = strlen(leveldir[leveldir_nr].name);
115 int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2;
116 int lypos = SY + 352;
118 DrawText(lxpos, lypos, leveldir[leveldir_nr].name, FS_SMALL, FC_SPECIAL2);
123 HandleMainMenu(0,0, 0,0, MB_MENU_INITIALIZE);
126 if (TAPE_IS_EMPTY(tape))
128 DrawCompleteVideoDisplay();
130 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
135 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
137 static int choice = 3;
138 static int redraw = TRUE;
139 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
141 if (redraw || button == MB_MENU_INITIALIZE)
143 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
147 if (button == MB_MENU_INITIALIZE)
152 if (dx && choice == 4)
154 x = (dx < 0 ? 11 : 15);
171 if (!mx && !my && !dx && !dy)
177 if (y == 4 && ((x == 11 && level_nr > leveldir[leveldir_nr].first_level) ||
178 (x == 15 && level_nr < leveldir[leveldir_nr].last_level)) &&
181 static unsigned long level_delay = 0;
182 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
183 int new_level_nr, old_level_nr = level_nr;
184 int font_color = (leveldir[leveldir_nr].readonly ? FC_RED : FC_YELLOW);
186 new_level_nr = level_nr + (x == 11 ? -step : +step);
187 if (new_level_nr < leveldir[leveldir_nr].first_level)
188 new_level_nr = leveldir[leveldir_nr].first_level;
189 if (new_level_nr > leveldir[leveldir_nr].last_level)
190 new_level_nr = leveldir[leveldir_nr].last_level;
192 if (old_level_nr == new_level_nr ||
193 !DelayReached(&level_delay, GADGET_FRAME_DELAY))
196 level_nr = new_level_nr;
198 DrawTextExt(drawto, gc, SX + 11 * 32, SY + 3 * 32,
199 int2str(level_nr, 3), FS_BIG, font_color);
200 DrawTextExt(window, gc, SX + 11 * 32, SY + 3 * 32,
201 int2str(level_nr, 3), FS_BIG, font_color);
204 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
208 DrawCompleteVideoDisplay();
210 /* needed because DrawMicroLevel() takes some time */
212 XSync(display, FALSE);
213 DelayReached(&level_delay, 0); /* reset delay counter */
215 else if (x == 1 && y >= 3 && y <= 10)
221 DrawGraphic(0, y-1, GFX_KUGEL_ROT);
222 DrawGraphic(0, choice - 1, GFX_KUGEL_BLAU);
230 game_status = TYPENAME;
231 HandleTypeName(strlen(setup.player_name), 0);
237 game_status = CHOOSELEVEL;
244 game_status = HALLOFFAME;
249 if (leveldir[leveldir_nr].readonly &&
250 strcmp(setup.player_name, "Artsoft") != 0)
251 Request("This level is read only !", REQ_CONFIRM);
252 game_status = LEVELED;
257 game_status = HELPSCREEN;
262 if (setup.autorecord)
263 TapeStartRecording();
267 SendToServer_StartPlaying();
271 game_status = PLAYING;
283 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
284 game_status = EXITGAME;
294 if (game_status == MAINMENU)
296 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE);
301 #define MAX_HELPSCREEN_ELS 10
305 static long helpscreen_state;
306 static int helpscreen_step[MAX_HELPSCREEN_ELS];
307 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
308 static int helpscreen_delay[MAX_HELPSCREEN_ELS];
309 static int helpscreen_action[] =
311 GFX_SPIELER1_DOWN,4,2,
313 GFX_SPIELER1_LEFT,4,2,
314 GFX_SPIELER1_RIGHT,4,2,
315 GFX_SPIELER1_PUSH_LEFT,4,2,
316 GFX_SPIELER1_PUSH_RIGHT,4,2, HA_NEXT,
317 GFX_ERDREICH,1,100, HA_NEXT,
318 GFX_LEERRAUM,1,100, HA_NEXT,
319 GFX_MORAST_LEER,1,100, HA_NEXT,
320 GFX_BETON,1,100, HA_NEXT,
321 GFX_MAUERWERK,1,100, HA_NEXT,
322 GFX_MAUER_L1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
323 GFX_MAUER_R1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
324 GFX_MAUER_UP, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
325 GFX_MAUER_DOWN,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
326 GFX_UNSICHTBAR,1,100, HA_NEXT,
327 GFX_FELSBODEN,1,100, HA_NEXT,
328 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
329 GFX_EDELSTEIN,2,5, HA_NEXT,
330 GFX_DIAMANT,2,5, HA_NEXT,
331 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
332 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
333 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
334 GFX_FELSBROCKEN,4,5, HA_NEXT,
335 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
336 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
337 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
338 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
339 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
340 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
341 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
342 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
343 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
344 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
345 GFX_GEBLUBBER,4,4, HA_NEXT,
346 GFX_SCHLUESSEL1,4,25, HA_NEXT,
347 GFX_PFORTE1,4,25, HA_NEXT,
348 GFX_PFORTE1X,4,25, HA_NEXT,
349 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
350 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
351 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
352 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
353 GFX_LEERRAUM,1,10, HA_NEXT,
354 GFX_DYNABOMB_NR,1,100, HA_NEXT,
355 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
356 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
357 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
358 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
359 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
360 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
361 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
362 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
363 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
364 GFX_BUTTERFLY,2,2, HA_NEXT,
365 GFX_FIREFLY,2,2, HA_NEXT,
366 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
367 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
368 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
369 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
370 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
371 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
372 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
373 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
374 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
375 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
376 GFX_MAULWURF_DOWN,4,2,
378 GFX_MAULWURF_LEFT,4,2,
379 GFX_MAULWURF_RIGHT,4,2, HA_NEXT,
380 GFX_PINGUIN_DOWN,4,2,
382 GFX_PINGUIN_LEFT,4,2,
383 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
384 GFX_SCHWEIN_DOWN,4,2,
386 GFX_SCHWEIN_LEFT,4,2,
387 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
391 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
392 GFX_SONDE_START,8,1, HA_NEXT,
393 GFX_ABLENK,4,1, HA_NEXT,
394 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
395 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
396 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
397 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
398 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
399 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
400 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
401 GFX_DIAMANT,1,10, HA_NEXT,
402 GFX_LIFE,1,100, HA_NEXT,
403 GFX_LIFE_ASYNC,1,100, HA_NEXT,
404 GFX_SIEB_INAKTIV,4,2, HA_NEXT,
405 GFX_SIEB2_INAKTIV,4,2, HA_NEXT,
406 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
407 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
408 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
409 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
410 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
411 GFX_SOKOBAN_OBJEKT,1,100, HA_NEXT,
412 GFX_SOKOBAN_FELD_LEER,1,100, HA_NEXT,
413 GFX_SOKOBAN_FELD_VOLL,1,100, HA_NEXT,
414 GFX_SPEED_PILL,1,100, HA_NEXT,
417 static char *helpscreen_eltext[][2] =
419 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
420 {"Normal sand:", "You can dig through it"},
421 {"Empty field:", "You can walk through it"},
422 {"Quicksand: You cannot pass it,", "but rocks can fall though it"},
423 {"Massive Wall:", "Nothing can go through it"},
424 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
425 {"Growing Wall: Grows in several di-", "rections if there is an empty field"},
426 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
427 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
428 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
429 {"Emerald: You must collect enough of","them to finish a level"},
430 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
431 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
432 {"Colorful Gems:", "Seem to behave like Emeralds"},
433 {"Rock: Smashes several things;", "Can be moved by the player"},
434 {"Bomb: You can move it, but be", "careful when dropping it"},
435 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
436 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
437 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
438 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
439 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
440 {"Acid: Things that fall in are gone", "forever (including our hero)"},
441 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
442 {"Door: Can be opened by the key", "with the same color"},
443 {"Door: You have to find out the", "right color of the key for it"},
444 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
445 {"Dynamite: This one explodes after", "a few seconds"},
446 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
447 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
448 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
449 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
450 {"Bug: Moves at the right side", "of walls; don't touch it!"},
451 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
452 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
453 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
454 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
455 {"Cruncher (BD style):", "Eats almost everything"},
456 {"Robot: Tries to kill the player", ""},
457 {"The mole: You must guide him savely","to the exit; he will follow you"},
458 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
459 {"The Pig: Harmless, but eats all", "gems it can get"},
460 {"The Dragon: Breathes fire,", "especially to some monsters"},
461 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
462 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
463 {"Light Bulb: All of them must be", "switched on to finish a level"},
464 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
465 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
466 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
467 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
468 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
469 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
470 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
471 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
472 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
473 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
474 {"Exit door: Opens if you have enough","emeralds to finish the level"},
475 {"Open exit door: Enter here to leave","the level and exit the actual game"},
476 {"Sokoban element: Object which must", "be pushed to an empty field"},
477 {"Sokoban element: Empty field where", "a Sokoban object can be placed on"},
478 {"Sokoban element: Field with object", "which can be pushed away"},
479 {"Speed pill: Lets the player run", "twice as fast as normally"},
481 static int num_helpscreen_els = sizeof(helpscreen_eltext)/(2*sizeof(char *));
483 static char *helpscreen_music[][3] =
485 { "Alchemy", "Ian Boddy", "Drive" },
486 { "The Chase", "Propaganda", "A Secret Wish" },
487 { "Network 23", "Tangerine Dream", "Exit" },
488 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
489 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
490 { "Voyager", "The Alan Parsons Project","Pyramid" },
491 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
493 static int helpscreen_musicpos;
495 void DrawHelpScreenElAction(int start)
499 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
501 while(helpscreen_action[j] != HA_END)
503 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
505 else if (i<start || helpscreen_delay[i-start])
507 if (i>=start && helpscreen_delay[i-start])
508 helpscreen_delay[i-start]--;
510 while(helpscreen_action[j] != HA_NEXT)
517 j += 3*helpscreen_step[i-start];
518 graphic = helpscreen_action[j++];
520 if (helpscreen_frame[i-start])
522 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
523 helpscreen_frame[i-start]--;
528 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
531 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
533 if (helpscreen_action[j] == HA_NEXT)
535 if (!helpscreen_frame[i-start])
536 helpscreen_step[i-start] = 0;
540 if (!helpscreen_frame[i-start])
541 helpscreen_step[i-start]++;
542 while(helpscreen_action[j] != HA_NEXT)
547 DrawGraphicExt(drawto, gc, xstart, ystart+(i-start)*ystep, graphic+frame);
558 void DrawHelpScreenElText(int start)
561 int xstart = SX + 56, ystart = SY + 65 + 2 * 32, ystep = TILEY + 4;
562 int ybottom = SYSIZE - 20;
567 DrawTextFCentered(100, FC_GREEN, "The game elements:");
569 for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++)
572 ystart + (i - start) * ystep + (*helpscreen_eltext[i][1] ? 0 : 8),
573 helpscreen_eltext[i][0], FS_SMALL, FC_YELLOW);
574 DrawText(xstart, ystart + (i - start) * ystep + 16,
575 helpscreen_eltext[i][1], FS_SMALL, FC_YELLOW);
578 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
581 void DrawHelpScreenMusicText(int num)
583 int ystart = 150, ystep = 30;
584 int ybottom = SYSIZE - 20;
590 DrawTextFCentered(100, FC_GREEN, "The game background music loops:");
592 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
594 DrawTextFCentered(ystart + 1 * ystep, FC_RED, "\"%s\"",
595 helpscreen_music[num][0]);
596 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
598 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
599 "%s", helpscreen_music[num][1]);
600 DrawTextFCentered(ystart + 4 * ystep, FC_YELLOW,
602 DrawTextFCentered(ystart + 5 * ystep, FC_RED, "\"%s\"",
603 helpscreen_music[num][2]);
605 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
607 PlaySoundLoop(background_loop[num]);
610 void DrawHelpScreenCreditsText()
612 int ystart = 150, ystep = 30;
613 int ybottom = SYSIZE - 20;
619 DrawTextFCentered(100, FC_GREEN,
621 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
622 "DOS/Windows port of the game:");
623 DrawTextFCentered(ystart + 1 * ystep, FC_RED,
625 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
626 "Additional toons:");
627 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
629 DrawTextFCentered(ystart + 5 * ystep, FC_YELLOW,
630 "...and many thanks to all contributors");
631 DrawTextFCentered(ystart + 6 * ystep, FC_YELLOW,
634 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
637 void DrawHelpScreenContactText()
639 int ystart = 150, ystep = 30;
640 int ybottom = SYSIZE - 20;
645 DrawTextFCentered(100, FC_GREEN, "Program information:");
647 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
648 "This game is Freeware!");
649 DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW,
650 "If you like it, send e-mail to:");
651 DrawTextFCentered(ystart + 2 * ystep, FC_RED,
652 "aeglos@valinor.owl.de");
653 DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW,
655 DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED,
657 DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED,
659 DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED,
661 DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED,
664 DrawTextFCentered(ystart + 7 * ystep, FC_YELLOW,
665 "If you have created new levels,");
666 DrawTextFCentered(ystart + 8 * ystep, FC_YELLOW,
667 "send them to me to include them!");
668 DrawTextFCentered(ystart + 9 * ystep, FC_YELLOW,
671 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for main menu");
674 void DrawHelpScreen()
678 CloseDoor(DOOR_CLOSE_2);
680 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
681 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
682 helpscreen_musicpos = 0;
683 helpscreen_state = 0;
684 DrawHelpScreenElText(0);
685 DrawHelpScreenElAction(0);
689 PlaySoundLoop(SND_RHYTHMLOOP);
692 void HandleHelpScreen(int button)
694 static unsigned long hs_delay = 0;
695 int num_helpscreen_els_pages =
696 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
697 int button_released = !button;
702 if (helpscreen_state < num_helpscreen_els_pages - 1)
704 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
705 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
707 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
708 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
710 else if (helpscreen_state < num_helpscreen_els_pages + num_bg_loops - 1)
713 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
715 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops - 1)
718 DrawHelpScreenCreditsText();
720 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops)
723 DrawHelpScreenContactText();
729 game_status = MAINMENU;
734 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
736 if (helpscreen_state<num_helpscreen_els_pages)
737 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
745 void HandleTypeName(int newxpos, KeySym key)
747 static int xpos = 0, ypos = 2;
752 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW);
753 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
757 if (((key >= XK_A && key <= XK_Z) || (key >= XK_a && key <= XK_z)) &&
758 xpos < MAX_NAMELEN - 1)
762 if (key >= XK_A && key <= XK_Z)
763 ascii = 'A' + (char)(key - XK_A);
765 ascii = 'a' + (char)(key - XK_a);
767 setup.player_name[xpos] = ascii;
768 setup.player_name[xpos + 1] = 0;
770 DrawTextExt(drawto, gc, SX + 6*32, SY + ypos*32,
771 setup.player_name, FS_BIG, FC_YELLOW);
772 DrawTextExt(window, gc, SX + 6*32, SY + ypos*32,
773 setup.player_name, FS_BIG, FC_YELLOW);
774 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
776 else if ((key == XK_Delete || key == XK_BackSpace) && xpos > 0)
779 setup.player_name[xpos] = 0;
780 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
781 DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM);
783 else if (key == XK_Return && xpos > 0)
785 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
786 DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM);
789 game_status = MAINMENU;
795 void DrawChooseLevel()
797 CloseDoor(DOOR_CLOSE_2);
801 HandleChooseLevel(0,0, 0,0, MB_MENU_INITIALIZE);
804 static void drawChooseLevelList(int first_entry, int num_page_entries)
807 char buffer[SCR_FIELDX];
810 DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN);
812 for(i=0; i<num_page_entries; i++)
814 strncpy(buffer, leveldir[first_entry + i].name , SCR_FIELDX - 1);
815 buffer[SCR_FIELDX - 1] = '\0';
816 DrawText(SX + 32, SY + (i + 2) * 32, buffer, FS_BIG, FC_YELLOW);
817 DrawGraphic(0, i + 2, GFX_KUGEL_BLAU);
821 DrawGraphic(0, 1, GFX_PFEIL_O);
823 if (first_entry + num_page_entries < num_leveldirs)
824 DrawGraphic(0, MAX_LEVEL_SERIES_ON_SCREEN + 1, GFX_PFEIL_U);
827 static void drawChooseLevelInfo(int leveldir_nr)
829 XFillRectangle(display, drawto, gc, SX + 32, SY + 32, SXSIZE - 32, 32);
830 DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
831 leveldir[leveldir_nr].levels,
832 leveldir[leveldir_nr].readonly ? "readonly" : "writable");
835 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
837 static int choice = 3;
838 static int first_entry = 0;
839 static unsigned long choose_delay = 0;
840 static int redraw = TRUE;
841 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
842 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
843 int num_page_entries;
845 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
846 num_page_entries = num_leveldirs;
848 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
850 if (button == MB_MENU_INITIALIZE)
853 choice = leveldir_nr + 3 - first_entry;
855 if (choice > num_page_entries + 2)
857 choice = num_page_entries + 2;
858 first_entry = num_leveldirs - num_page_entries;
861 drawChooseLevelList(first_entry, num_page_entries);
862 drawChooseLevelInfo(leveldir_nr);
867 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
871 if (button == MB_MENU_INITIALIZE)
885 if (x == 1 && y == 2)
887 if (first_entry > 0 &&
888 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
897 drawChooseLevelList(first_entry, num_page_entries);
898 drawChooseLevelInfo(first_entry);
899 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
903 else if (x == 1 && y > num_page_entries + 2)
905 if (first_entry + num_page_entries < num_leveldirs &&
906 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
912 if (first_entry + num_page_entries > num_leveldirs)
913 first_entry = num_leveldirs - num_page_entries;
915 drawChooseLevelList(first_entry, num_page_entries);
916 drawChooseLevelInfo(first_entry + num_page_entries - 1);
917 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
922 if (!mx && !my && !dx && !dy)
928 if (x == 1 && y >= 3 && y <= num_page_entries + 2)
934 DrawGraphic(0, y - 1, GFX_KUGEL_ROT);
935 DrawGraphic(0, choice - 1, GFX_KUGEL_BLAU);
936 drawChooseLevelInfo(first_entry + y - 3);
942 leveldir_nr = first_entry + y - 3;
944 getLastPlayedLevelOfLevelSeries(leveldir[leveldir_nr].filename);
949 game_status = MAINMENU;
957 if (game_status == CHOOSELEVEL)
961 void DrawHallOfFame(int highlight_position)
965 CloseDoor(DOOR_CLOSE_2);
967 if (highlight_position < 0)
972 DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
973 DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
975 for(i=0; i<MAX_LEVEL_SERIES_ON_SCREEN; i++)
977 DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG,
978 (i == highlight_position ? FC_RED : FC_GREEN));
979 DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG,
980 (i == highlight_position ? FC_RED : FC_GREEN));
981 DrawText(SX + 12 * 32, SY + 64 + i * 32,
982 int2str(highscore[i].Score, 5), FS_BIG,
983 (i == highlight_position ? FC_RED : FC_GREEN));
988 PlaySound(SND_HALLOFFAME);
991 void HandleHallOfFame(int button)
993 int button_released = !button;
997 FadeSound(SND_HALLOFFAME);
998 game_status = MAINMENU;
1006 void DrawSetupScreen()
1015 { &setup.sound, "Sound:", },
1016 { &setup.sound_loops, " Sound Loops:" },
1017 { &setup.sound_music, " Game Music:" },
1018 { &setup.toons, "Toons:" },
1019 { &setup.double_buffering, "Buffered gfx:" },
1020 { &setup.scroll_delay, "Scroll Delay:" },
1021 { &setup.soft_scrolling, "Soft Scroll.:" },
1022 { &setup.fading, "Fading:" },
1023 { &setup.quick_doors, "Quick Doors:" },
1024 { &setup.autorecord, "Auto-Record:" },
1025 { &setup.team_mode, "Team-Mode:" },
1026 { NULL, "Input Devices" },
1029 { NULL, "Save and exit" }
1032 CloseDoor(DOOR_CLOSE_2);
1034 DrawText(SX+16, SY+16, "SETUP",FS_BIG,FC_YELLOW);
1036 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
1038 int base = i - SETUP_SCREEN_POS_START;
1040 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
1042 DrawGraphic(0,i,GFX_KUGEL_BLAU);
1043 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
1046 if (setup_info[base].value)
1048 int setting_value = *setup_info[base].value;
1050 DrawText(SX+14*32, SY+i*32, (setting_value ? "on" : "off"),
1051 FS_BIG, (setting_value ? FC_YELLOW : FC_BLUE));
1057 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
1060 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
1062 static int choice = 3;
1063 static int redraw = TRUE;
1064 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1065 int pos_start = SETUP_SCREEN_POS_START + 1;
1066 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
1067 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
1068 int pos_end = SETUP_SCREEN_POS_END + 1;
1070 if (button == MB_MENU_INITIALIZE)
1075 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
1079 if (button == MB_MENU_INITIALIZE)
1092 if (y >= pos_empty1 && y <= pos_empty2)
1093 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1097 else if (y > pos_end)
1101 if (!mx && !my && !dx && !dy)
1107 if (x==1 && y >= pos_start && y <= pos_end &&
1108 !(y >= pos_empty1 && y <= pos_empty2))
1114 DrawGraphic(0,y-1,GFX_KUGEL_ROT);
1115 DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
1123 if (y==3 && sound_status==SOUND_AVAILABLE)
1127 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1128 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1129 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1130 setup.sound_loops = FALSE;
1131 setup.sound_music = FALSE;
1134 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1135 setup.sound = !setup.sound;
1137 else if (y==4 && sound_loops_allowed)
1139 if (setup.sound_loops)
1140 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1143 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1144 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1147 setup.sound_loops = !setup.sound_loops;
1149 else if (y==5 && sound_loops_allowed)
1151 if (setup.sound_music)
1152 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1155 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1156 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1159 setup.sound_music = !setup.sound_music;
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.toons = !setup.toons;
1172 if (setup.double_buffering)
1173 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1175 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1176 setup.double_buffering = !setup.double_buffering;
1177 setup.direct_draw = !setup.double_buffering;
1179 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1180 setup.double_buffering = TRUE;
1181 setup.direct_draw = !setup.double_buffering;
1186 if (setup.scroll_delay)
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.scroll_delay = !setup.scroll_delay;
1194 if (setup.soft_scrolling)
1195 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1197 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1198 setup.soft_scrolling = !setup.soft_scrolling;
1203 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1205 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1206 setup.fading = !setup.fading;
1210 if (setup.quick_doors)
1211 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1213 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1214 setup.quick_doors = !setup.quick_doors;
1218 if (setup.autorecord)
1219 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1221 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1222 setup.autorecord = !setup.autorecord;
1226 if (setup.team_mode)
1227 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1229 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1230 setup.team_mode = !setup.team_mode;
1234 game_status = SETUPINPUT;
1235 DrawSetupInputScreen();
1238 else if (y==pos_end-1 || y==pos_end)
1249 save_joystick_data(JOYSTICK_FILENAME);
1255 game_status = MAINMENU;
1263 if (game_status==SETUP)
1267 void DrawSetupInputScreen()
1270 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1272 DrawGraphic(0, 2, GFX_KUGEL_BLAU);
1273 DrawGraphic(0, 3, GFX_KUGEL_BLAU);
1274 DrawGraphic(0, 4, GFX_KUGEL_BLAU);
1275 DrawGraphic(0, 15, GFX_KUGEL_BLAU);
1276 DrawGraphic(10, 2, GFX_PFEIL_L);
1277 DrawGraphic(12, 2, GFX_PFEIL_R);
1279 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1280 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1281 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1283 DrawTextFCentered(SYSIZE - 20, FC_BLUE,
1284 "Joysticks deactivated on this screen");
1286 HandleSetupInputScreen(0,0, 0,0, MB_MENU_INITIALIZE);
1291 static void setJoystickDeviceToNr(char *device_name, int device_nr)
1293 if (device_name == NULL)
1296 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
1299 if (strlen(device_name) > 1)
1301 char c1 = device_name[strlen(device_name) - 1];
1302 char c2 = device_name[strlen(device_name) - 2];
1304 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
1305 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
1308 strncpy(device_name, joystick_device_name[device_nr], strlen(device_name));
1311 static void drawPlayerSetupInputInfo(int player_nr)
1314 static struct SetupKeyboardInfo custom_key;
1321 { &custom_key.left, "Joystick Left" },
1322 { &custom_key.right, "Joystick Right" },
1323 { &custom_key.up, "Joystick Up" },
1324 { &custom_key.down, "Joystick Down" },
1325 { &custom_key.snap, "Button 1" },
1326 { &custom_key.bomb, "Button 2" }
1328 static char *joystick_name[MAX_PLAYERS] =
1336 custom_key = setup.input[player_nr].key;
1338 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1339 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1341 if (setup.input[player_nr].use_joystick)
1343 char *device_name = setup.input[player_nr].joy.device_name;
1345 DrawText(SX+8*32, SY+3*32,
1346 joystick_name[getJoystickNrFromDeviceName(device_name)],
1348 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1352 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1353 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1356 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1357 DrawGraphic(1, 6, GFX_PFEIL_L);
1358 DrawGraphic(1, 7, GFX_PFEIL_R);
1359 DrawGraphic(1, 8, GFX_PFEIL_O);
1360 DrawGraphic(1, 9, GFX_PFEIL_U);
1361 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1362 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1363 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1364 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1365 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1366 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1370 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1372 DrawText(SX + 3*32, SY + ypos*32,
1373 " ", FS_BIG, FC_YELLOW);
1374 DrawText(SX + 3*32, SY + ypos*32,
1375 (setup.input[player_nr].use_joystick ?
1377 getKeyNameFromKeySym(*custom[i].keysym)),
1382 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1384 static int choice = 3;
1385 static int player_nr = 0;
1386 static int redraw = TRUE;
1387 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1388 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1389 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1390 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1391 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1393 if (button == MB_MENU_INITIALIZE)
1395 drawPlayerSetupInputInfo(player_nr);
1401 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
1405 if (button == MB_MENU_INITIALIZE)
1410 if (dx && choice == 3)
1412 x = (dx < 0 ? 11 : 13);
1415 else if (dx && choice == 4)
1417 button = MB_MENU_CHOICE;
1429 if (y >= pos_empty1 && y <= pos_empty2)
1430 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1434 else if (y > pos_end)
1438 if (!mx && !my && !dx && !dy)
1444 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1446 static unsigned long delay = 0;
1448 if (!DelayReached(&delay, GADGET_FRAME_DELAY))
1451 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1453 drawPlayerSetupInputInfo(player_nr);
1455 else if (x==1 && y >= pos_start && y <= pos_end &&
1456 !(y >= pos_empty1 && y <= pos_empty2))
1462 DrawGraphic(0, y-1, GFX_KUGEL_ROT);
1463 DrawGraphic(0, choice-1, GFX_KUGEL_BLAU);
1471 char *device_name = setup.input[player_nr].joy.device_name;
1473 if (!setup.input[player_nr].use_joystick)
1475 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
1477 setJoystickDeviceToNr(device_name, new_device_nr);
1478 setup.input[player_nr].use_joystick = TRUE;
1482 int device_nr = getJoystickNrFromDeviceName(device_name);
1483 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
1485 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
1486 setup.input[player_nr].use_joystick = FALSE;
1488 setJoystickDeviceToNr(device_name, new_device_nr);
1498 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1499 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1501 if (setup.input[player_nr].use_joystick)
1503 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1504 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1506 setup.input[player_nr].use_joystick = FALSE;
1510 setup.input[player_nr].use_joystick = TRUE;
1511 setup.input[player_nr].joystick_nr = one_joystick_nr;
1515 drawPlayerSetupInputInfo(player_nr);
1519 if (setup.input[player_nr].use_joystick)
1522 game_status = CALIBRATION;
1523 CalibrateJoystick(player_nr);
1524 game_status = SETUPINPUT;
1527 CustomizeKeyboard(player_nr);
1531 else if (y == pos_end)
1535 game_status = SETUP;
1545 if (game_status == SETUPINPUT)
1549 void CustomizeKeyboard(int player_nr)
1553 boolean finished = FALSE;
1554 static struct SetupKeyboardInfo custom_key;
1559 } customize_step[] =
1561 { &custom_key.left, "Move Left" },
1562 { &custom_key.right, "Move Right" },
1563 { &custom_key.up, "Move Up" },
1564 { &custom_key.down, "Move Down" },
1565 { &custom_key.snap, "Snap Field" },
1566 { &custom_key.bomb, "Place Bomb" }
1569 /* read existing key bindings from player setup */
1570 custom_key = setup.input[player_nr].key;
1573 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1579 DrawText(SX, SY + (2+2*step_nr)*32,
1580 customize_step[step_nr].text, FS_BIG, FC_RED);
1581 DrawText(SX, SY + (2+2*step_nr+1)*32,
1582 "Key:", FS_BIG, FC_RED);
1583 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1584 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1589 if (XPending(display)) /* got event from X server */
1593 XNextEvent(display, &event);
1599 KeySym key = XLookupKeysym((XKeyEvent *)&event,
1600 ((XKeyEvent *)&event)->state);
1602 if (key == XK_Escape || (key == XK_Return && step_nr == 6))
1608 /* press 'Enter' to keep the existing key binding */
1609 if (key == XK_Return || step_nr == 6)
1610 key = *customize_step[step_nr].keysym;
1612 /* check if key already used */
1613 for (i=0; i<step_nr; i++)
1614 if (*customize_step[i].keysym == key)
1619 /* got new key binding */
1620 *customize_step[step_nr].keysym = key;
1621 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1622 " ", FS_BIG, FC_YELLOW);
1623 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1624 getKeyNameFromKeySym(key), FS_BIG, FC_YELLOW);
1627 /* un-highlight last query */
1628 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1629 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1630 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1631 "Key:", FS_BIG, FC_GREEN);
1633 /* press 'Enter' to leave */
1636 DrawText(SX + 16, SY + 15*32+16,
1637 "Press Enter", FS_BIG, FC_YELLOW);
1641 /* query next key binding */
1642 DrawText(SX, SY+(2+2*step_nr)*32,
1643 customize_step[step_nr].text, FS_BIG, FC_RED);
1644 DrawText(SX, SY+(2+2*step_nr+1)*32,
1645 "Key:", FS_BIG, FC_RED);
1646 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1647 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1653 key_joystick_mapping = 0;
1657 HandleOtherEvents(&event);
1665 /* don't eat all CPU time */
1669 /* write new key bindings back to player setup */
1670 setup.input[player_nr].key = custom_key;
1673 DrawSetupInputScreen();
1676 void CalibrateJoystick(int player_nr)
1679 struct joystick joy_ctrl;
1681 struct joystick_control
1690 int new_joystick_xleft = 128, new_joystick_xright = 128;
1691 int new_joystick_yupper = 128, new_joystick_ylower = 128;
1692 int new_joystick_xmiddle, new_joystick_ymiddle;
1694 int calibration_step = 1;
1697 int joystick_fd = stored_player[player_nr].joystick_fd;
1698 int x, y, last_x, last_y, xpos = 8, ypos = 3;
1699 boolean check[3][3];
1700 int check_remaining;
1704 if (joystick_status == JOYSTICK_OFF ||
1706 !setup.input[player_nr].use_joystick)
1712 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW);
1713 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW);
1714 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ", FS_BIG, FC_YELLOW);
1715 DrawText(SX, SY + 10*32, " ARE YELLOW, ", FS_BIG, FC_YELLOW);
1716 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
1717 check_remaining = 3 * 3;
1719 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
1720 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
1721 DrawText(SX, SY + 9*32, " CENTER POSITION ", FS_BIG, FC_YELLOW);
1722 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
1723 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
1724 check_remaining = 0;
1731 check[x][y] = FALSE;
1732 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
1736 joy_value = Joystick(player_nr);
1737 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
1738 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
1739 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
1744 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1746 joy_ctrl.buttons = 0;
1749 while(Joystick(player_nr) & JOY_BUTTON);
1755 if (XPending(display)) /* got event from X server */
1759 XNextEvent(display, &event);
1764 switch(XLookupKeysym((XKeyEvent *)&event,
1765 ((XKeyEvent *)&event)->state))
1768 if (check_remaining == 0)
1782 key_joystick_mapping = 0;
1786 HandleOtherEvents(&event);
1792 if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1794 joystick_status = JOYSTICK_OFF;
1798 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
1799 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
1800 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
1801 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
1803 new_joystick_xmiddle =
1804 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
1805 new_joystick_ymiddle =
1806 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
1808 setup.input[player_nr].joy.xleft = new_joystick_xleft;
1809 setup.input[player_nr].joy.yupper = new_joystick_yupper;
1810 setup.input[player_nr].joy.xright = new_joystick_xright;
1811 setup.input[player_nr].joy.ylower = new_joystick_ylower;
1812 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
1813 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
1815 CheckJoystickData();
1818 joy_value = Joystick(player_nr);
1820 if (joy_value & JOY_BUTTON && check_remaining == 0)
1825 if (calibration_step == 1)
1830 else if (calibrate_joystick(joystick_fd) != 0)
1832 joystick_status = JOYSTICK_OFF;
1836 if (joy[joystick_fd].flags & JOYFLAG_CALIBRATE)
1841 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
1842 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
1844 if (calibration_step == 2)
1845 DrawText(SX + 16, SY + 9*32," THE UPPER LEFT ", FS_BIG, FC_YELLOW);
1847 DrawText(SX, SY + 9*32," THE LOWER RIGHT ", FS_BIG, FC_YELLOW);
1849 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
1850 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
1854 while(Joystick(player_nr) & JOY_BUTTON)
1860 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
1861 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
1863 if (x != last_x || y != last_y)
1866 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
1868 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_BLAU);
1870 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
1875 if (check_remaining > 0 && !check[x+1][y+1])
1877 check[x+1][y+1] = TRUE;
1882 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
1883 setup.input[player_nr].joy.xleft,
1884 setup.input[player_nr].joy.xmiddle,
1885 setup.input[player_nr].joy.xright);
1886 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
1887 setup.input[player_nr].joy.yupper,
1888 setup.input[player_nr].joy.ymiddle,
1889 setup.input[player_nr].joy.ylower);
1897 /* don't eat all CPU time */
1903 DrawSetupInputScreen();
1904 while(Joystick(player_nr) & JOY_BUTTON);
1910 DrawText(SX + 16, SY + 6*32, " JOYSTICK NOT ", FS_BIG, FC_YELLOW);
1911 DrawText(SX, SY + 7*32, " AVAILABLE ", FS_BIG, FC_YELLOW);
1914 DrawSetupInputScreen();
1921 void CalibrateJoystick_OLD()
1924 struct joystick joy_ctrl;
1926 struct joystick_control
1938 int joystick_nr = setup.input[0].joystick_nr;
1939 int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle;
1940 int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle;
1942 if (joystick_status == JOYSTICK_OFF)
1947 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1948 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
1949 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1953 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1955 joy_ctrl.buttons = 0;
1957 while(Joystick() & JOY_BUTTON);
1959 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1961 while(!joy_ctrl.buttons)
1964 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1966 joystick_status=JOYSTICK_OFF;
1972 new_joystick_xleft = joy_ctrl.x;
1973 new_joystick_yupper = joy_ctrl.y;
1976 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1977 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
1978 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1982 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1984 joy_ctrl.buttons = 0;
1986 while(Joystick() & JOY_BUTTON);
1988 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1990 while(!joy_ctrl.buttons)
1993 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1995 joystick_status=JOYSTICK_OFF;
2001 new_joystick_xright = joy_ctrl.x;
2002 new_joystick_ylower = joy_ctrl.y;
2005 DrawText(SX+32, SY+16+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
2006 DrawText(SX+16, SY+16+8*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
2010 joy_ctrl.b1 = joy_ctrl.b2 = 0;
2012 joy_ctrl.buttons = 0;
2014 while(Joystick() & JOY_BUTTON);
2016 while(!(joy_ctrl.b1 || joy_ctrl.b2))
2018 while(!joy_ctrl.buttons)
2021 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
2023 joystick_status=JOYSTICK_OFF;
2029 new_joystick_xmiddle = joy_ctrl.x;
2030 new_joystick_ymiddle = joy_ctrl.y;
2032 setup.input[player_nr].joy.xleft = new_joystick_xleft;
2033 setup.input[player_nr].joy.yupper = new_joystick_yupper;
2034 setup.input[player_nr].joy.xright = new_joystick_xright;
2035 setup.input[player_nr].joy.ylower = new_joystick_ylower;
2036 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
2037 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
2039 CheckJoystickData();
2042 while(Joystick() & JOY_BUTTON);
2050 joy_nr[1] = SETUP_2ND_JOYSTICK_ON(local_player->setup)+49;
2055 DrawText(SX+32, SY+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
2056 DrawText(SX+16+7*32, SY+8*32, joy_nr, FS_BIG,FC_YELLOW);
2057 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
2060 for(clear_keybuf();!keypressed(););
2061 install_joystick(JOY_TYPE_2PADS);
2064 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
2065 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
2066 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
2069 for(clear_keybuf();!keypressed(););
2070 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
2073 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
2074 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
2075 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
2078 for(clear_keybuf();!keypressed(););
2079 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
2086 DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
2087 DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
2097 void HandleGameActions()
2099 if (game_status != PLAYING)
2102 if (local_player->LevelSolved)
2105 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2113 void HandleVideoButtons(int mx, int my, int button)
2115 if (game_status != MAINMENU && game_status != PLAYING)
2118 switch(CheckVideoButtons(mx,my,button))
2120 case BUTTON_VIDEO_EJECT:
2122 if (TAPE_IS_EMPTY(tape))
2125 if (TAPE_IS_EMPTY(tape))
2126 Request("No tape for this level !",REQ_CONFIRM);
2131 SaveTape(tape.level_nr);
2134 DrawCompleteVideoDisplay();
2137 case BUTTON_VIDEO_STOP:
2141 case BUTTON_VIDEO_PAUSE:
2145 case BUTTON_VIDEO_REC:
2146 if (TAPE_IS_STOPPED(tape))
2148 TapeStartRecording();
2151 if (options.network)
2152 SendToServer_StartPlaying();
2156 game_status = PLAYING;
2160 else if (tape.pausing)
2162 if (tape.playing) /* PLAYING -> PAUSING -> RECORDING */
2164 tape.pos[tape.counter].delay = tape.delay_played;
2165 tape.playing = FALSE;
2166 tape.recording = TRUE;
2167 tape.changed = TRUE;
2169 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON,0);
2176 case BUTTON_VIDEO_PLAY:
2177 if (TAPE_IS_EMPTY(tape))
2180 if (TAPE_IS_STOPPED(tape))
2184 game_status = PLAYING;
2187 else if (tape.playing)
2189 if (tape.pausing) /* PAUSE -> PLAY */
2191 else if (!tape.fast_forward) /* PLAY -> FAST FORWARD PLAY */
2193 tape.fast_forward = TRUE;
2194 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
2196 else if (!tape.pause_before_death) /* FFWD PLAY -> + AUTO PAUSE */
2198 tape.pause_before_death = TRUE;
2199 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
2201 else /* -> NORMAL PLAY */
2203 tape.fast_forward = FALSE;
2204 tape.pause_before_death = FALSE;
2205 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PBEND_OFF, 0);
2217 void HandleSoundButtons(int mx, int my, int button)
2219 if (game_status != PLAYING)
2222 switch(CheckSoundButtons(mx,my,button))
2224 case BUTTON_SOUND_MUSIC:
2225 if (setup.sound_music)
2227 setup.sound_music = FALSE;
2228 FadeSound(background_loop[level_nr % num_bg_loops]);
2229 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
2231 else if (sound_loops_allowed)
2233 setup.sound = setup.sound_music = TRUE;
2234 PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
2235 DrawSoundDisplay(BUTTON_SOUND_MUSIC_ON);
2238 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
2241 case BUTTON_SOUND_LOOPS:
2242 if (setup.sound_loops)
2244 setup.sound_loops = FALSE;
2245 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
2247 else if (sound_loops_allowed)
2249 setup.sound = setup.sound_loops = TRUE;
2250 DrawSoundDisplay(BUTTON_SOUND_LOOPS_ON);
2253 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
2256 case BUTTON_SOUND_SIMPLE:
2257 if (setup.sound_simple)
2259 setup.sound_simple = FALSE;
2260 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
2262 else if (sound_status==SOUND_AVAILABLE)
2264 setup.sound = setup.sound_simple = TRUE;
2265 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_ON);
2268 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
2278 void HandleGameButtons(int mx, int my, int button)
2280 if (game_status != PLAYING)
2283 switch(CheckGameButtons(mx,my,button))
2285 case BUTTON_GAME_STOP:
2288 CloseDoor(DOOR_CLOSE_1);
2289 game_status = MAINMENU;
2294 if (Request("Do you really want to quit the game ?",
2295 REQ_ASK | REQ_STAY_CLOSED))
2298 if (options.network)
2299 SendToServer_StopPlaying();
2303 game_status = MAINMENU;
2308 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
2311 case BUTTON_GAME_PAUSE:
2312 if (options.network)
2316 SendToServer_ContinuePlaying();
2318 SendToServer_PausePlaying();
2325 case BUTTON_GAME_PLAY:
2329 if (options.network)
2330 SendToServer_ContinuePlaying();
2334 tape.pausing = FALSE;
2335 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);