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_R1,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
323 GFX_MAUER_L1,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
324 GFX_UNSICHTBAR,1,100, HA_NEXT,
325 GFX_FELSBODEN,1,100, HA_NEXT,
326 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
327 GFX_EDELSTEIN,2,5, HA_NEXT,
328 GFX_DIAMANT,2,5, HA_NEXT,
329 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
330 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
331 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
332 GFX_FELSBROCKEN,4,5, HA_NEXT,
333 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
334 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
335 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
336 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
337 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
338 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
339 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
340 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
341 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
342 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
343 GFX_GEBLUBBER,4,4, HA_NEXT,
344 GFX_SCHLUESSEL1,4,25, HA_NEXT,
345 GFX_PFORTE1,4,25, HA_NEXT,
346 GFX_PFORTE1X,4,25, HA_NEXT,
347 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
348 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
349 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
350 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
351 GFX_LEERRAUM,1,10, HA_NEXT,
352 GFX_DYNABOMB_NR,1,100, HA_NEXT,
353 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
354 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
355 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
356 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
357 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
358 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
359 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
360 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
361 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
362 GFX_BUTTERFLY,2,2, HA_NEXT,
363 GFX_FIREFLY,2,2, HA_NEXT,
364 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
365 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
366 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
367 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
368 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
369 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
370 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
371 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
372 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
373 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
374 GFX_MAULWURF_DOWN,4,2,
376 GFX_MAULWURF_LEFT,4,2,
377 GFX_MAULWURF_RIGHT,4,2, HA_NEXT,
378 GFX_PINGUIN_DOWN,4,2,
380 GFX_PINGUIN_LEFT,4,2,
381 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
382 GFX_SCHWEIN_DOWN,4,2,
384 GFX_SCHWEIN_LEFT,4,2,
385 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
389 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
390 GFX_SONDE_START,8,1, HA_NEXT,
391 GFX_ABLENK,4,1, HA_NEXT,
392 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
393 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
394 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
395 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
396 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
397 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
398 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
399 GFX_DIAMANT,1,10, HA_NEXT,
400 GFX_LIFE,1,100, HA_NEXT,
401 GFX_LIFE_ASYNC,1,100, HA_NEXT,
402 GFX_SIEB_INAKTIV,4,2, HA_NEXT,
403 GFX_SIEB2_INAKTIV,4,2, HA_NEXT,
404 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
405 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
406 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
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,
411 static char *helpscreen_eltext[][2] =
413 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
414 {"Normal sand:", "You can dig through it"},
415 {"Empty field:", "You can walk through it"},
416 {"Quicksand: You cannot pass it,", "but rocks can fall though it"},
417 {"Massive Wall:", "Nothing can go through it"},
418 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
419 {"Growing Wall: Grows to the left or", "right if there is an empty field"},
420 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
421 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
422 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
423 {"Emerald: You must collect enough of","them to finish a level"},
424 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
425 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
426 {"Colorful Gems:", "Seem to behave like Emeralds"},
427 {"Rock: Smashes several things;", "Can be moved by the player"},
428 {"Bomb: You can move it, but be", "careful when dropping it"},
429 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
430 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
431 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
432 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
433 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
434 {"Acid: Things that fall in are gone", "forever (including our hero)"},
435 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
436 {"Door: Can be opened by the key", "with the same color"},
437 {"Door: You have to find out the", "right color of the key for it"},
438 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
439 {"Dynamite: This one explodes after", "a few seconds"},
440 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
441 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
442 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
443 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
444 {"Bug: Moves at the right side", "of walls; don't touch it!"},
445 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
446 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
447 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
448 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
449 {"Cruncher (BD style):", "Eats almost everything"},
450 {"Robot: Tries to kill the player", ""},
451 {"The mole: You must guide him savely","to the exit; he will follow you"},
452 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
453 {"The Pig: Harmless, but eats all", "gems it can get"},
454 {"The Dragon: Breathes fire,", "especially to some monsters"},
455 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
456 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
457 {"Light Bulb: All of them must be", "switched on to finish a level"},
458 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
459 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
460 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
461 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
462 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
463 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
464 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
465 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
466 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
467 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
468 {"Exit door: Opens if you have enough","emeralds to finish the level"},
469 {"Open exit door: Enter here to leave","the level and exit the actual game"},
471 static int num_helpscreen_els = sizeof(helpscreen_eltext)/(2*sizeof(char *));
473 static char *helpscreen_music[][3] =
475 { "Alchemy", "Ian Boddy", "Drive" },
476 { "The Chase", "Propaganda", "A Secret Wish" },
477 { "Network 23", "Tangerine Dream", "Exit" },
478 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
479 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
480 { "Voyager", "The Alan Parsons Project","Pyramid" },
481 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
483 static int helpscreen_musicpos;
485 void DrawHelpScreenElAction(int start)
489 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
491 while(helpscreen_action[j] != HA_END)
493 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
495 else if (i<start || helpscreen_delay[i-start])
497 if (i>=start && helpscreen_delay[i-start])
498 helpscreen_delay[i-start]--;
500 while(helpscreen_action[j] != HA_NEXT)
507 j += 3*helpscreen_step[i-start];
508 graphic = helpscreen_action[j++];
510 if (helpscreen_frame[i-start])
512 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
513 helpscreen_frame[i-start]--;
518 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
521 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
523 if (helpscreen_action[j] == HA_NEXT)
525 if (!helpscreen_frame[i-start])
526 helpscreen_step[i-start] = 0;
530 if (!helpscreen_frame[i-start])
531 helpscreen_step[i-start]++;
532 while(helpscreen_action[j] != HA_NEXT)
537 DrawGraphicExt(drawto, gc, xstart, ystart+(i-start)*ystep, graphic+frame);
548 void DrawHelpScreenElText(int start)
551 int xstart = SX + 56, ystart = SY + 65 + 2 * 32, ystep = TILEY + 4;
552 int ybottom = SYSIZE - 20;
557 DrawTextFCentered(100, FC_GREEN, "The game elements:");
559 for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++)
562 ystart + (i - start) * ystep + (*helpscreen_eltext[i][1] ? 0 : 8),
563 helpscreen_eltext[i][0], FS_SMALL, FC_YELLOW);
564 DrawText(xstart, ystart + (i - start) * ystep + 16,
565 helpscreen_eltext[i][1], FS_SMALL, FC_YELLOW);
568 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
571 void DrawHelpScreenMusicText(int num)
573 int ystart = 150, ystep = 30;
574 int ybottom = SYSIZE - 20;
580 DrawTextFCentered(100, FC_GREEN, "The game background music loops:");
582 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
584 DrawTextFCentered(ystart + 1 * ystep, FC_RED, "\"%s\"",
585 helpscreen_music[num][0]);
586 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
588 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
589 "%s", helpscreen_music[num][1]);
590 DrawTextFCentered(ystart + 4 * ystep, FC_YELLOW,
592 DrawTextFCentered(ystart + 5 * ystep, FC_RED, "\"%s\"",
593 helpscreen_music[num][2]);
595 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
597 PlaySoundLoop(background_loop[num]);
600 void DrawHelpScreenCreditsText()
602 int ystart = 150, ystep = 30;
603 int ybottom = SYSIZE - 20;
609 DrawTextFCentered(100, FC_GREEN,
611 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
612 "DOS/Windows port of the game:");
613 DrawTextFCentered(ystart + 1 * ystep, FC_RED,
615 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
616 "Additional toons:");
617 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
619 DrawTextFCentered(ystart + 5 * ystep, FC_YELLOW,
620 "...and many thanks to all contributors");
621 DrawTextFCentered(ystart + 6 * ystep, FC_YELLOW,
624 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
627 void DrawHelpScreenContactText()
629 int ystart = 150, ystep = 30;
630 int ybottom = SYSIZE - 20;
635 DrawTextFCentered(100, FC_GREEN, "Program information:");
637 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
638 "This game is Freeware!");
639 DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW,
640 "If you like it, send e-mail to:");
641 DrawTextFCentered(ystart + 2 * ystep, FC_RED,
642 "aeglos@valinor.owl.de");
643 DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW,
645 DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED,
647 DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED,
649 DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED,
651 DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED,
654 DrawTextFCentered(ystart + 7 * ystep, FC_YELLOW,
655 "If you have created new levels,");
656 DrawTextFCentered(ystart + 8 * ystep, FC_YELLOW,
657 "send them to me to include them!");
658 DrawTextFCentered(ystart + 9 * ystep, FC_YELLOW,
661 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for main menu");
664 void DrawHelpScreen()
668 CloseDoor(DOOR_CLOSE_2);
670 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
671 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
672 helpscreen_musicpos = 0;
673 helpscreen_state = 0;
674 DrawHelpScreenElText(0);
675 DrawHelpScreenElAction(0);
679 PlaySoundLoop(SND_RHYTHMLOOP);
682 void HandleHelpScreen(int button)
684 static unsigned long hs_delay = 0;
685 int num_helpscreen_els_pages =
686 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
687 int button_released = !button;
692 if (helpscreen_state < num_helpscreen_els_pages - 1)
694 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
695 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
697 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
698 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
700 else if (helpscreen_state < num_helpscreen_els_pages + num_bg_loops - 1)
703 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
705 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops - 1)
708 DrawHelpScreenCreditsText();
710 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops)
713 DrawHelpScreenContactText();
719 game_status = MAINMENU;
724 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
726 if (helpscreen_state<num_helpscreen_els_pages)
727 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
735 void HandleTypeName(int newxpos, KeySym key)
737 static int xpos = 0, ypos = 2;
742 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW);
743 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
747 if (((key >= XK_A && key <= XK_Z) || (key >= XK_a && key <= XK_z)) &&
748 xpos < MAX_NAMELEN - 1)
752 if (key >= XK_A && key <= XK_Z)
753 ascii = 'A' + (char)(key - XK_A);
755 ascii = 'a' + (char)(key - XK_a);
757 setup.player_name[xpos] = ascii;
758 setup.player_name[xpos + 1] = 0;
760 DrawTextExt(drawto, gc, SX + 6*32, SY + ypos*32,
761 setup.player_name, FS_BIG, FC_YELLOW);
762 DrawTextExt(window, gc, SX + 6*32, SY + ypos*32,
763 setup.player_name, FS_BIG, FC_YELLOW);
764 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
766 else if ((key == XK_Delete || key == XK_BackSpace) && xpos > 0)
769 setup.player_name[xpos] = 0;
770 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
771 DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM);
773 else if (key == XK_Return && xpos > 0)
775 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
776 DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM);
779 game_status = MAINMENU;
785 void DrawChooseLevel()
787 CloseDoor(DOOR_CLOSE_2);
791 HandleChooseLevel(0,0, 0,0, MB_MENU_INITIALIZE);
794 static void drawChooseLevelList(int first_entry, int num_page_entries)
797 char buffer[SCR_FIELDX];
800 DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN);
802 for(i=0; i<num_page_entries; i++)
804 strncpy(buffer, leveldir[first_entry + i].name , SCR_FIELDX - 1);
805 buffer[SCR_FIELDX - 1] = '\0';
806 DrawText(SX + 32, SY + (i + 2) * 32, buffer, FS_BIG, FC_YELLOW);
807 DrawGraphic(0, i + 2, GFX_KUGEL_BLAU);
811 DrawGraphic(0, 1, GFX_PFEIL_O);
813 if (first_entry + num_page_entries < num_leveldirs)
814 DrawGraphic(0, MAX_LEVEL_SERIES_ON_SCREEN + 1, GFX_PFEIL_U);
817 static void drawChooseLevelInfo(int leveldir_nr)
819 XFillRectangle(display, drawto, gc, SX + 32, SY + 32, SXSIZE - 32, 32);
820 DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
821 leveldir[leveldir_nr].levels,
822 leveldir[leveldir_nr].readonly ? "readonly" : "writable");
825 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
827 static int choice = 3;
828 static int first_entry = 0;
829 static unsigned long choose_delay = 0;
830 static int redraw = TRUE;
831 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
832 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
833 int num_page_entries;
835 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
836 num_page_entries = num_leveldirs;
838 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
840 if (button == MB_MENU_INITIALIZE)
843 choice = leveldir_nr + 3 - first_entry;
845 if (choice > num_page_entries + 2)
847 choice = num_page_entries + 2;
848 first_entry = num_leveldirs - num_page_entries;
851 drawChooseLevelList(first_entry, num_page_entries);
852 drawChooseLevelInfo(leveldir_nr);
857 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
861 if (button == MB_MENU_INITIALIZE)
875 if (x == 1 && y == 2)
877 if (first_entry > 0 &&
878 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
887 drawChooseLevelList(first_entry, num_page_entries);
888 drawChooseLevelInfo(first_entry);
889 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
893 else if (x == 1 && y > num_page_entries + 2)
895 if (first_entry + num_page_entries < num_leveldirs &&
896 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
902 if (first_entry + num_page_entries > num_leveldirs)
903 first_entry = num_leveldirs - num_page_entries;
905 drawChooseLevelList(first_entry, num_page_entries);
906 drawChooseLevelInfo(first_entry + num_page_entries - 1);
907 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
912 if (!mx && !my && !dx && !dy)
918 if (x == 1 && y >= 3 && y <= num_page_entries + 2)
924 DrawGraphic(0, y - 1, GFX_KUGEL_ROT);
925 DrawGraphic(0, choice - 1, GFX_KUGEL_BLAU);
926 drawChooseLevelInfo(first_entry + y - 3);
932 leveldir_nr = first_entry + y - 3;
934 getLastPlayedLevelOfLevelSeries(leveldir[leveldir_nr].filename);
939 game_status = MAINMENU;
947 if (game_status == CHOOSELEVEL)
951 void DrawHallOfFame(int highlight_position)
955 CloseDoor(DOOR_CLOSE_2);
957 if (highlight_position < 0)
962 DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
963 DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
965 for(i=0; i<MAX_LEVEL_SERIES_ON_SCREEN; i++)
967 DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG,
968 (i == highlight_position ? FC_RED : FC_GREEN));
969 DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG,
970 (i == highlight_position ? FC_RED : FC_GREEN));
971 DrawText(SX + 12 * 32, SY + 64 + i * 32,
972 int2str(highscore[i].Score, 5), FS_BIG,
973 (i == highlight_position ? FC_RED : FC_GREEN));
978 PlaySound(SND_HALLOFFAME);
981 void HandleHallOfFame(int button)
983 int button_released = !button;
987 FadeSound(SND_HALLOFFAME);
988 game_status = MAINMENU;
996 void DrawSetupScreen()
1005 { &setup.sound, "Sound:", },
1006 { &setup.sound_loops, " Sound Loops:" },
1007 { &setup.sound_music, " Game Music:" },
1008 { &setup.toons, "Toons:" },
1009 { &setup.double_buffering, "Buffered gfx:" },
1010 { &setup.scroll_delay, "Scroll Delay:" },
1011 { &setup.soft_scrolling, "Soft Scroll.:" },
1012 { &setup.fading, "Fading:" },
1013 { &setup.quick_doors, "Quick Doors:" },
1014 { &setup.autorecord, "Auto-Record:" },
1015 { &setup.team_mode, "Team-Mode:" },
1016 { NULL, "Input Devices" },
1019 { NULL, "Save and exit" }
1022 CloseDoor(DOOR_CLOSE_2);
1024 DrawText(SX+16, SY+16, "SETUP",FS_BIG,FC_YELLOW);
1026 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
1028 int base = i - SETUP_SCREEN_POS_START;
1030 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
1032 DrawGraphic(0,i,GFX_KUGEL_BLAU);
1033 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
1036 if (setup_info[base].value)
1038 int setting_value = *setup_info[base].value;
1040 DrawText(SX+14*32, SY+i*32, (setting_value ? "on" : "off"),
1041 FS_BIG, (setting_value ? FC_YELLOW : FC_BLUE));
1047 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
1050 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
1052 static int choice = 3;
1053 static int redraw = TRUE;
1054 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1055 int pos_start = SETUP_SCREEN_POS_START + 1;
1056 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
1057 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
1058 int pos_end = SETUP_SCREEN_POS_END + 1;
1060 if (button == MB_MENU_INITIALIZE)
1065 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
1069 if (button == MB_MENU_INITIALIZE)
1082 if (y >= pos_empty1 && y <= pos_empty2)
1083 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1087 else if (y > pos_end)
1091 if (!mx && !my && !dx && !dy)
1097 if (x==1 && y >= pos_start && y <= pos_end &&
1098 !(y >= pos_empty1 && y <= pos_empty2))
1104 DrawGraphic(0,y-1,GFX_KUGEL_ROT);
1105 DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
1113 if (y==3 && sound_status==SOUND_AVAILABLE)
1117 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1118 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1119 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1120 setup.sound_loops = FALSE;
1121 setup.sound_music = FALSE;
1124 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1125 setup.sound = !setup.sound;
1127 else if (y==4 && sound_loops_allowed)
1129 if (setup.sound_loops)
1130 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1133 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1134 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1137 setup.sound_loops = !setup.sound_loops;
1139 else if (y==5 && sound_loops_allowed)
1141 if (setup.sound_music)
1142 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1145 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1146 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1149 setup.sound_music = !setup.sound_music;
1154 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1156 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1157 setup.toons = !setup.toons;
1162 if (setup.double_buffering)
1163 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1165 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1166 setup.double_buffering = !setup.double_buffering;
1167 setup.direct_draw = !setup.double_buffering;
1169 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1170 setup.double_buffering = TRUE;
1171 setup.direct_draw = !setup.double_buffering;
1176 if (setup.scroll_delay)
1177 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1179 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1180 setup.scroll_delay = !setup.scroll_delay;
1184 if (setup.soft_scrolling)
1185 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1187 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1188 setup.soft_scrolling = !setup.soft_scrolling;
1193 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1195 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1196 setup.fading = !setup.fading;
1200 if (setup.quick_doors)
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.quick_doors = !setup.quick_doors;
1208 if (setup.autorecord)
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.autorecord = !setup.autorecord;
1216 if (setup.team_mode)
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.team_mode = !setup.team_mode;
1224 game_status = SETUPINPUT;
1225 DrawSetupInputScreen();
1228 else if (y==pos_end-1 || y==pos_end)
1239 save_joystick_data(JOYSTICK_FILENAME);
1245 game_status = MAINMENU;
1253 if (game_status==SETUP)
1257 void DrawSetupInputScreen()
1260 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1262 DrawGraphic(0, 2, GFX_KUGEL_BLAU);
1263 DrawGraphic(0, 3, GFX_KUGEL_BLAU);
1264 DrawGraphic(0, 4, GFX_KUGEL_BLAU);
1265 DrawGraphic(0, 15, GFX_KUGEL_BLAU);
1266 DrawGraphic(10, 2, GFX_PFEIL_L);
1267 DrawGraphic(12, 2, GFX_PFEIL_R);
1269 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1270 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1271 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1273 DrawTextFCentered(SYSIZE - 20, FC_BLUE,
1274 "Joysticks deactivated on this screen");
1276 HandleSetupInputScreen(0,0, 0,0, MB_MENU_INITIALIZE);
1281 static void setJoystickDeviceToNr(char *device_name, int device_nr)
1283 if (device_name == NULL)
1286 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
1289 if (strlen(device_name) > 1)
1291 char c1 = device_name[strlen(device_name) - 1];
1292 char c2 = device_name[strlen(device_name) - 2];
1294 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
1295 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
1298 strncpy(device_name, joystick_device_name[device_nr], strlen(device_name));
1301 static void drawPlayerSetupInputInfo(int player_nr)
1304 static struct SetupKeyboardInfo custom_key;
1311 { &custom_key.left, "Joystick Left" },
1312 { &custom_key.right, "Joystick Right" },
1313 { &custom_key.up, "Joystick Up" },
1314 { &custom_key.down, "Joystick Down" },
1315 { &custom_key.snap, "Button 1" },
1316 { &custom_key.bomb, "Button 2" }
1318 static char *joystick_name[MAX_PLAYERS] =
1326 custom_key = setup.input[player_nr].key;
1328 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1329 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1331 if (setup.input[player_nr].use_joystick)
1333 char *device_name = setup.input[player_nr].joy.device_name;
1335 DrawText(SX+8*32, SY+3*32,
1336 joystick_name[getJoystickNrFromDeviceName(device_name)],
1338 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1342 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1343 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1346 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1347 DrawGraphic(1, 6, GFX_PFEIL_L);
1348 DrawGraphic(1, 7, GFX_PFEIL_R);
1349 DrawGraphic(1, 8, GFX_PFEIL_O);
1350 DrawGraphic(1, 9, GFX_PFEIL_U);
1351 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1352 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1353 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1354 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1355 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1356 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1360 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1362 DrawText(SX + 3*32, SY + ypos*32,
1363 " ", FS_BIG, FC_YELLOW);
1364 DrawText(SX + 3*32, SY + ypos*32,
1365 (setup.input[player_nr].use_joystick ?
1367 getKeyNameFromKeySym(*custom[i].keysym)),
1372 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1374 static int choice = 3;
1375 static int player_nr = 0;
1376 static int redraw = TRUE;
1377 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1378 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1379 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1380 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1381 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1383 if (button == MB_MENU_INITIALIZE)
1385 drawPlayerSetupInputInfo(player_nr);
1391 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
1395 if (button == MB_MENU_INITIALIZE)
1400 if (dx && choice == 3)
1402 x = (dx < 0 ? 11 : 13);
1405 else if (dx && choice == 4)
1407 button = MB_MENU_CHOICE;
1419 if (y >= pos_empty1 && y <= pos_empty2)
1420 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1424 else if (y > pos_end)
1428 if (!mx && !my && !dx && !dy)
1434 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1436 static unsigned long delay = 0;
1438 if (!DelayReached(&delay, GADGET_FRAME_DELAY))
1441 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1443 drawPlayerSetupInputInfo(player_nr);
1445 else if (x==1 && y >= pos_start && y <= pos_end &&
1446 !(y >= pos_empty1 && y <= pos_empty2))
1452 DrawGraphic(0, y-1, GFX_KUGEL_ROT);
1453 DrawGraphic(0, choice-1, GFX_KUGEL_BLAU);
1461 char *device_name = setup.input[player_nr].joy.device_name;
1463 if (!setup.input[player_nr].use_joystick)
1465 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
1467 setJoystickDeviceToNr(device_name, new_device_nr);
1468 setup.input[player_nr].use_joystick = TRUE;
1472 int device_nr = getJoystickNrFromDeviceName(device_name);
1473 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
1475 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
1476 setup.input[player_nr].use_joystick = FALSE;
1478 setJoystickDeviceToNr(device_name, new_device_nr);
1488 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1489 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1491 if (setup.input[player_nr].use_joystick)
1493 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1494 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1496 setup.input[player_nr].use_joystick = FALSE;
1500 setup.input[player_nr].use_joystick = TRUE;
1501 setup.input[player_nr].joystick_nr = one_joystick_nr;
1505 drawPlayerSetupInputInfo(player_nr);
1509 if (setup.input[player_nr].use_joystick)
1512 game_status = CALIBRATION;
1513 CalibrateJoystick(player_nr);
1514 game_status = SETUPINPUT;
1517 CustomizeKeyboard(player_nr);
1521 else if (y == pos_end)
1525 game_status = SETUP;
1535 if (game_status == SETUPINPUT)
1539 void CustomizeKeyboard(int player_nr)
1543 boolean finished = FALSE;
1544 static struct SetupKeyboardInfo custom_key;
1549 } customize_step[] =
1551 { &custom_key.left, "Move Left" },
1552 { &custom_key.right, "Move Right" },
1553 { &custom_key.up, "Move Up" },
1554 { &custom_key.down, "Move Down" },
1555 { &custom_key.snap, "Snap Field" },
1556 { &custom_key.bomb, "Place Bomb" }
1559 /* read existing key bindings from player setup */
1560 custom_key = setup.input[player_nr].key;
1563 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1569 DrawText(SX, SY + (2+2*step_nr)*32,
1570 customize_step[step_nr].text, FS_BIG, FC_RED);
1571 DrawText(SX, SY + (2+2*step_nr+1)*32,
1572 "Key:", FS_BIG, FC_RED);
1573 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1574 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1579 if (XPending(display)) /* got event from X server */
1583 XNextEvent(display, &event);
1589 KeySym key = XLookupKeysym((XKeyEvent *)&event,
1590 ((XKeyEvent *)&event)->state);
1592 if (key == XK_Escape || (key == XK_Return && step_nr == 6))
1598 /* press 'Enter' to keep the existing key binding */
1599 if (key == XK_Return || step_nr == 6)
1600 key = *customize_step[step_nr].keysym;
1602 /* check if key already used */
1603 for (i=0; i<step_nr; i++)
1604 if (*customize_step[i].keysym == key)
1609 /* got new key binding */
1610 *customize_step[step_nr].keysym = key;
1611 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1612 " ", FS_BIG, FC_YELLOW);
1613 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1614 getKeyNameFromKeySym(key), FS_BIG, FC_YELLOW);
1617 /* un-highlight last query */
1618 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1619 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1620 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1621 "Key:", FS_BIG, FC_GREEN);
1623 /* press 'Enter' to leave */
1626 DrawText(SX + 16, SY + 15*32+16,
1627 "Press Enter", FS_BIG, FC_YELLOW);
1631 /* query next key binding */
1632 DrawText(SX, SY+(2+2*step_nr)*32,
1633 customize_step[step_nr].text, FS_BIG, FC_RED);
1634 DrawText(SX, SY+(2+2*step_nr+1)*32,
1635 "Key:", FS_BIG, FC_RED);
1636 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1637 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1643 key_joystick_mapping = 0;
1647 HandleOtherEvents(&event);
1655 /* don't eat all CPU time */
1659 /* write new key bindings back to player setup */
1660 setup.input[player_nr].key = custom_key;
1663 DrawSetupInputScreen();
1666 void CalibrateJoystick(int player_nr)
1669 struct joystick joy_ctrl;
1671 struct joystick_control
1680 int new_joystick_xleft = 128, new_joystick_xright = 128;
1681 int new_joystick_yupper = 128, new_joystick_ylower = 128;
1682 int new_joystick_xmiddle, new_joystick_ymiddle;
1684 int calibration_step = 1;
1687 int joystick_fd = stored_player[player_nr].joystick_fd;
1688 int x, y, last_x, last_y, xpos = 8, ypos = 3;
1689 boolean check[3][3];
1690 int check_remaining;
1694 if (joystick_status == JOYSTICK_OFF ||
1696 !setup.input[player_nr].use_joystick)
1702 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW);
1703 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW);
1704 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ", FS_BIG, FC_YELLOW);
1705 DrawText(SX, SY + 10*32, " ARE YELLOW, ", FS_BIG, FC_YELLOW);
1706 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
1707 check_remaining = 3 * 3;
1709 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
1710 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
1711 DrawText(SX, SY + 9*32, " CENTER POSITION ", FS_BIG, FC_YELLOW);
1712 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
1713 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
1714 check_remaining = 0;
1721 check[x][y] = FALSE;
1722 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
1726 joy_value = Joystick(player_nr);
1727 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
1728 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
1729 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
1734 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1736 joy_ctrl.buttons = 0;
1739 while(Joystick(player_nr) & JOY_BUTTON);
1745 if (XPending(display)) /* got event from X server */
1749 XNextEvent(display, &event);
1754 switch(XLookupKeysym((XKeyEvent *)&event,
1755 ((XKeyEvent *)&event)->state))
1758 if (check_remaining == 0)
1772 key_joystick_mapping = 0;
1776 HandleOtherEvents(&event);
1782 if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1784 joystick_status = JOYSTICK_OFF;
1788 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
1789 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
1790 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
1791 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
1793 new_joystick_xmiddle =
1794 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
1795 new_joystick_ymiddle =
1796 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
1798 setup.input[player_nr].joy.xleft = new_joystick_xleft;
1799 setup.input[player_nr].joy.yupper = new_joystick_yupper;
1800 setup.input[player_nr].joy.xright = new_joystick_xright;
1801 setup.input[player_nr].joy.ylower = new_joystick_ylower;
1802 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
1803 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
1805 CheckJoystickData();
1808 joy_value = Joystick(player_nr);
1810 if (joy_value & JOY_BUTTON && check_remaining == 0)
1815 if (calibration_step == 1)
1820 else if (calibrate_joystick(joystick_fd) != 0)
1822 joystick_status = JOYSTICK_OFF;
1826 if (joy[joystick_fd].flags & JOYFLAG_CALIBRATE)
1831 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
1832 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
1834 if (calibration_step == 2)
1835 DrawText(SX + 16, SY + 9*32," THE UPPER LEFT ", FS_BIG, FC_YELLOW);
1837 DrawText(SX, SY + 9*32," THE LOWER RIGHT ", FS_BIG, FC_YELLOW);
1839 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
1840 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
1844 while(Joystick(player_nr) & JOY_BUTTON)
1850 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
1851 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
1853 if (x != last_x || y != last_y)
1856 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
1858 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_BLAU);
1860 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
1865 if (check_remaining > 0 && !check[x+1][y+1])
1867 check[x+1][y+1] = TRUE;
1872 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
1873 setup.input[player_nr].joy.xleft,
1874 setup.input[player_nr].joy.xmiddle,
1875 setup.input[player_nr].joy.xright);
1876 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
1877 setup.input[player_nr].joy.yupper,
1878 setup.input[player_nr].joy.ymiddle,
1879 setup.input[player_nr].joy.ylower);
1887 /* don't eat all CPU time */
1893 DrawSetupInputScreen();
1894 while(Joystick(player_nr) & JOY_BUTTON);
1900 DrawText(SX + 16, SY + 6*32, " JOYSTICK NOT ", FS_BIG, FC_YELLOW);
1901 DrawText(SX, SY + 7*32, " AVAILABLE ", FS_BIG, FC_YELLOW);
1904 DrawSetupInputScreen();
1911 void CalibrateJoystick_OLD()
1914 struct joystick joy_ctrl;
1916 struct joystick_control
1928 int joystick_nr = setup.input[0].joystick_nr;
1929 int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle;
1930 int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle;
1932 if (joystick_status == JOYSTICK_OFF)
1937 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1938 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
1939 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1943 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1945 joy_ctrl.buttons = 0;
1947 while(Joystick() & JOY_BUTTON);
1949 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1951 while(!joy_ctrl.buttons)
1954 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1956 joystick_status=JOYSTICK_OFF;
1962 new_joystick_xleft = joy_ctrl.x;
1963 new_joystick_yupper = joy_ctrl.y;
1966 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1967 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
1968 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1972 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1974 joy_ctrl.buttons = 0;
1976 while(Joystick() & JOY_BUTTON);
1978 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1980 while(!joy_ctrl.buttons)
1983 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1985 joystick_status=JOYSTICK_OFF;
1991 new_joystick_xright = joy_ctrl.x;
1992 new_joystick_ylower = joy_ctrl.y;
1995 DrawText(SX+32, SY+16+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
1996 DrawText(SX+16, SY+16+8*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
2000 joy_ctrl.b1 = joy_ctrl.b2 = 0;
2002 joy_ctrl.buttons = 0;
2004 while(Joystick() & JOY_BUTTON);
2006 while(!(joy_ctrl.b1 || joy_ctrl.b2))
2008 while(!joy_ctrl.buttons)
2011 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
2013 joystick_status=JOYSTICK_OFF;
2019 new_joystick_xmiddle = joy_ctrl.x;
2020 new_joystick_ymiddle = joy_ctrl.y;
2022 setup.input[player_nr].joy.xleft = new_joystick_xleft;
2023 setup.input[player_nr].joy.yupper = new_joystick_yupper;
2024 setup.input[player_nr].joy.xright = new_joystick_xright;
2025 setup.input[player_nr].joy.ylower = new_joystick_ylower;
2026 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
2027 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
2029 CheckJoystickData();
2032 while(Joystick() & JOY_BUTTON);
2040 joy_nr[1] = SETUP_2ND_JOYSTICK_ON(local_player->setup)+49;
2045 DrawText(SX+32, SY+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
2046 DrawText(SX+16+7*32, SY+8*32, joy_nr, FS_BIG,FC_YELLOW);
2047 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
2050 for(clear_keybuf();!keypressed(););
2051 install_joystick(JOY_TYPE_2PADS);
2054 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
2055 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
2056 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
2059 for(clear_keybuf();!keypressed(););
2060 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
2063 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
2064 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
2065 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
2068 for(clear_keybuf();!keypressed(););
2069 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
2076 DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
2077 DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
2087 void HandleGameActions()
2089 if (game_status != PLAYING)
2092 if (local_player->LevelSolved)
2095 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2103 void HandleVideoButtons(int mx, int my, int button)
2105 if (game_status != MAINMENU && game_status != PLAYING)
2108 switch(CheckVideoButtons(mx,my,button))
2110 case BUTTON_VIDEO_EJECT:
2112 if (TAPE_IS_EMPTY(tape))
2115 if (TAPE_IS_EMPTY(tape))
2116 Request("No tape for this level !",REQ_CONFIRM);
2121 SaveTape(tape.level_nr);
2124 DrawCompleteVideoDisplay();
2127 case BUTTON_VIDEO_STOP:
2131 case BUTTON_VIDEO_PAUSE:
2135 case BUTTON_VIDEO_REC:
2136 if (TAPE_IS_STOPPED(tape))
2138 TapeStartRecording();
2141 if (options.network)
2142 SendToServer_StartPlaying();
2146 game_status = PLAYING;
2150 else if (tape.pausing)
2152 if (tape.playing) /* PLAYING -> PAUSING -> RECORDING */
2154 tape.pos[tape.counter].delay = tape.delay_played;
2155 tape.playing = FALSE;
2156 tape.recording = TRUE;
2157 tape.changed = TRUE;
2159 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON,0);
2166 case BUTTON_VIDEO_PLAY:
2167 if (TAPE_IS_EMPTY(tape))
2170 if (TAPE_IS_STOPPED(tape))
2174 game_status = PLAYING;
2177 else if (tape.playing)
2179 if (tape.pausing) /* PAUSE -> PLAY */
2181 else if (!tape.fast_forward) /* PLAY -> FAST FORWARD PLAY */
2183 tape.fast_forward = TRUE;
2184 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
2186 else if (!tape.pause_before_death) /* FFWD PLAY -> + AUTO PAUSE */
2188 tape.pause_before_death = TRUE;
2189 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
2191 else /* -> NORMAL PLAY */
2193 tape.fast_forward = FALSE;
2194 tape.pause_before_death = FALSE;
2195 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PBEND_OFF, 0);
2207 void HandleSoundButtons(int mx, int my, int button)
2209 if (game_status != PLAYING)
2212 switch(CheckSoundButtons(mx,my,button))
2214 case BUTTON_SOUND_MUSIC:
2215 if (setup.sound_music)
2217 setup.sound_music = FALSE;
2218 FadeSound(background_loop[level_nr % num_bg_loops]);
2219 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
2221 else if (sound_loops_allowed)
2223 setup.sound = setup.sound_music = TRUE;
2224 PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
2225 DrawSoundDisplay(BUTTON_SOUND_MUSIC_ON);
2228 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
2231 case BUTTON_SOUND_LOOPS:
2232 if (setup.sound_loops)
2234 setup.sound_loops = FALSE;
2235 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
2237 else if (sound_loops_allowed)
2239 setup.sound = setup.sound_loops = TRUE;
2240 DrawSoundDisplay(BUTTON_SOUND_LOOPS_ON);
2243 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
2246 case BUTTON_SOUND_SIMPLE:
2247 if (setup.sound_simple)
2249 setup.sound_simple = FALSE;
2250 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
2252 else if (sound_status==SOUND_AVAILABLE)
2254 setup.sound = setup.sound_simple = TRUE;
2255 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_ON);
2258 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
2268 void HandleGameButtons(int mx, int my, int button)
2270 if (game_status != PLAYING)
2273 switch(CheckGameButtons(mx,my,button))
2275 case BUTTON_GAME_STOP:
2278 CloseDoor(DOOR_CLOSE_1);
2279 game_status = MAINMENU;
2284 if (Request("Do you really want to quit the game ?",
2285 REQ_ASK | REQ_STAY_CLOSED))
2288 if (options.network)
2289 SendToServer_StopPlaying();
2293 game_status = MAINMENU;
2298 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
2301 case BUTTON_GAME_PAUSE:
2302 if (options.network)
2306 SendToServer_ContinuePlaying();
2308 SendToServer_PausePlaying();
2315 case BUTTON_GAME_PLAY:
2319 if (options.network)
2320 SendToServer_ContinuePlaying();
2324 tape.pausing = FALSE;
2325 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);