1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2000 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
14 #include "libgame/libgame.h"
28 /* for DrawSetupScreen(), HandleSetupScreen() */
29 #define SETUP_SCREEN_POS_START 2
30 #define SETUP_SCREEN_POS_END (SCR_FIELDY - 1)
31 #define SETUP_SCREEN_POS_EMPTY1 (SETUP_SCREEN_POS_END - 2)
32 #define SETUP_SCREEN_POS_EMPTY2 (SETUP_SCREEN_POS_END - 2)
34 /* for HandleSetupInputScreen() */
35 #define SETUPINPUT_SCREEN_POS_START 2
36 #define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 2)
37 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
38 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
40 /* for HandleChooseLevel() */
41 #define MAX_LEVEL_SERIES_ON_SCREEN (SCR_FIELDY - 2)
43 /* buttons and scrollbars identifiers */
44 #define SCREEN_CTRL_ID_SCROLL_UP 0
45 #define SCREEN_CTRL_ID_SCROLL_DOWN 1
46 #define SCREEN_CTRL_ID_SCROLL_VERTICAL 2
48 #define NUM_SCREEN_SCROLLBUTTONS 2
49 #define NUM_SCREEN_SCROLLBARS 1
50 #define NUM_SCREEN_GADGETS 3
52 /* forward declaration for internal use */
53 static void HandleScreenGadgets(struct GadgetInfo *);
55 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
59 int x = SX + (SXSIZE - strlen(PROGRAM_TITLE_STRING) * FONT1_XSIZE) / 2;
61 DrawText(x, SY + 8, PROGRAM_TITLE_STRING, FS_BIG, FC_YELLOW);
62 DrawTextFCentered(46, FC_RED, WINDOW_SUBTITLE_STRING);
67 static struct LevelDirInfo *leveldir_last_valid = NULL;
69 char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:");
73 KeyboardAutoRepeatOn();
75 /* needed if last screen was the playing screen, invoked from level editor */
76 if (level_editor_test_game)
78 game_status = LEVELED;
83 /* needed if last screen was the editor screen */
84 UndrawSpecialEditorDoor();
86 /* needed if last screen was the setup screen and fullscreen state changed */
87 setup.fullscreen = ChangeVideoModeIfNeeded(setup.fullscreen);
89 SetDrawtoField(DRAW_BACKBUFFER);
92 /* map gadgets for main menu screen */
95 /* leveldir_current may be invalid (level group, parent link) */
96 if (!validLevelSeries(leveldir_current))
97 leveldir_current = getFirstValidLevelSeries(leveldir_last_valid);
99 /* store valid level series information */
100 leveldir_last_valid = leveldir_current;
102 /* level_nr may have been set to value over handicap with level editor */
103 if (setup.handicap && level_nr > leveldir_current->handicap_level)
104 level_nr = leveldir_current->handicap_level;
111 DrawText(SX + 32, SY + 2*32, name_text, FS_BIG, FC_GREEN);
112 DrawText(SX + 6*32, SY + 2*32, setup.player_name, FS_BIG, FC_RED);
113 DrawText(SX + 32, SY + 3*32, "Level:", FS_BIG, FC_GREEN);
114 DrawText(SX + 11*32, SY + 3*32, int2str(level_nr,3), FS_BIG,
115 (leveldir_current->readonly ? FC_RED : FC_YELLOW));
116 DrawText(SX + 32, SY + 4*32, "Hall Of Fame", FS_BIG, FC_GREEN);
117 DrawText(SX + 32, SY + 5*32, "Level Creator", FS_BIG, FC_GREEN);
118 DrawText(SY + 32, SY + 6*32, "Info Screen", FS_BIG, FC_GREEN);
119 DrawText(SX + 32, SY + 7*32, "Start Game", FS_BIG, FC_GREEN);
120 DrawText(SX + 32, SY + 8*32, "Setup", FS_BIG, FC_GREEN);
121 DrawText(SX + 32, SY + 9*32, "Quit", FS_BIG, FC_GREEN);
123 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
125 DrawTextF(7*32 + 6, 3*32 + 9, FC_RED, "%d-%d",
126 leveldir_current->first_level,
127 leveldir_current->last_level);
129 if (leveldir_current->readonly)
131 DrawTextF(15*32 + 6, 3*32 + 9 - 7, FC_RED, "READ");
132 DrawTextF(15*32 + 6, 3*32 + 9 + 7, FC_RED, "ONLY");
136 DrawGraphic(0, i, GFX_KUGEL_BLAU);
137 DrawGraphic(10, 3, GFX_ARROW_BLUE_LEFT);
138 DrawGraphic(14, 3, GFX_ARROW_BLUE_RIGHT);
140 DrawText(SX + 56, SY + 326, "A Game by Artsoft Entertainment",
143 if (leveldir_current->name)
145 int len = strlen(leveldir_current->name);
146 int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2;
147 int lypos = SY + 352;
149 DrawText(lxpos, lypos, leveldir_current->name, FS_SMALL, FC_SPECIAL2);
154 HandleMainMenu(0,0, 0,0, MB_MENU_INITIALIZE);
157 if (TAPE_IS_EMPTY(tape))
159 DrawCompleteVideoDisplay();
161 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
169 static void gotoTopLevelDir()
171 /* move upwards to top level directory */
172 while (leveldir_current->node_parent)
174 /* write a "path" into level tree for easy navigation to last level */
175 if (leveldir_current->node_parent->node_group->cl_first == -1)
177 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
178 int leveldir_pos = posLevelDirInfo(leveldir_current);
179 int num_page_entries;
180 int cl_first, cl_cursor;
182 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
183 num_page_entries = num_leveldirs;
185 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
187 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
188 cl_cursor = leveldir_pos - cl_first + 3;
190 leveldir_current->node_parent->node_group->cl_first = cl_first;
191 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
194 leveldir_current = leveldir_current->node_parent;
198 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
200 static int choice = 3;
201 static int redraw = TRUE;
202 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
204 if (redraw || button == MB_MENU_INITIALIZE)
206 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
210 if (button == MB_MENU_INITIALIZE)
215 if (dx && choice == 4)
217 x = (dx < 0 ? 11 : 15);
234 if (!mx && !my && !dx && !dy)
240 if (y == 4 && ((x == 11 && level_nr > leveldir_current->first_level) ||
241 (x == 15 && level_nr < leveldir_current->last_level)) &&
244 static unsigned long level_delay = 0;
245 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
246 int new_level_nr, old_level_nr = level_nr;
247 int font_color = (leveldir_current->readonly ? FC_RED : FC_YELLOW);
249 new_level_nr = level_nr + (x == 11 ? -step : +step);
250 if (new_level_nr < leveldir_current->first_level)
251 new_level_nr = leveldir_current->first_level;
252 if (new_level_nr > leveldir_current->last_level)
253 new_level_nr = leveldir_current->last_level;
255 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
256 new_level_nr = leveldir_current->handicap_level;
258 if (old_level_nr == new_level_nr ||
259 !DelayReached(&level_delay, GADGET_FRAME_DELAY))
262 level_nr = new_level_nr;
264 DrawTextExt(drawto, SX + 11 * 32, SY + 3 * 32,
265 int2str(level_nr, 3), FS_BIG, font_color);
266 DrawTextExt(window, SX + 11 * 32, SY + 3 * 32,
267 int2str(level_nr, 3), FS_BIG, font_color);
270 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
274 DrawCompleteVideoDisplay();
276 /* needed because DrawMicroLevel() takes some time */
279 DelayReached(&level_delay, 0); /* reset delay counter */
281 else if (x == 1 && y >= 3 && y <= 10)
287 DrawGraphic(0, y - 1, GFX_KUGEL_ROT);
288 DrawGraphic(0, choice - 1, GFX_KUGEL_BLAU);
296 game_status = TYPENAME;
297 HandleTypeName(strlen(setup.player_name), 0);
303 game_status = CHOOSELEVEL;
304 SaveLevelSetup_LastSeries();
305 SaveLevelSetup_SeriesInfo();
314 game_status = HALLOFFAME;
319 if (leveldir_current->readonly &&
320 strcmp(setup.player_name, "Artsoft") != 0)
321 Request("This level is read only !", REQ_CONFIRM);
322 game_status = LEVELED;
327 game_status = HELPSCREEN;
332 if (setup.autorecord)
333 TapeStartRecording();
335 #if defined(PLATFORM_UNIX)
337 SendToServer_StartPlaying();
341 game_status = PLAYING;
353 SaveLevelSetup_LastSeries();
354 SaveLevelSetup_SeriesInfo();
355 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
356 game_status = EXITGAME;
366 if (game_status == MAINMENU)
368 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE);
373 #define MAX_HELPSCREEN_ELS 10
377 static long helpscreen_state;
378 static int helpscreen_step[MAX_HELPSCREEN_ELS];
379 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
380 static int helpscreen_delay[MAX_HELPSCREEN_ELS];
381 static int helpscreen_action[] =
383 GFX_SPIELER1_DOWN,4,2,
385 GFX_SPIELER1_LEFT,4,2,
386 GFX_SPIELER1_RIGHT,4,2,
387 GFX_SPIELER1_PUSH_LEFT,4,2,
388 GFX_SPIELER1_PUSH_RIGHT,4,2, HA_NEXT,
389 GFX_ERDREICH,1,100, HA_NEXT,
390 GFX_LEERRAUM,1,100, HA_NEXT,
391 GFX_MORAST_LEER,1,100, HA_NEXT,
392 GFX_BETON,1,100, HA_NEXT,
393 GFX_MAUERWERK,1,100, HA_NEXT,
394 GFX_MAUER_L1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
395 GFX_MAUER_R1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
396 GFX_MAUER_UP, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
397 GFX_MAUER_DOWN,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
398 GFX_UNSICHTBAR,1,100, HA_NEXT,
399 GFX_FELSBODEN,1,100, HA_NEXT,
400 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
401 GFX_EDELSTEIN,2,5, HA_NEXT,
402 GFX_DIAMANT,2,5, HA_NEXT,
403 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
404 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
405 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
406 GFX_FELSBROCKEN,4,5, HA_NEXT,
407 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
408 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
409 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
410 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
411 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
412 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
413 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
414 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
415 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
416 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
417 GFX_GEBLUBBER,4,4, HA_NEXT,
418 GFX_SCHLUESSEL1,4,25, HA_NEXT,
419 GFX_PFORTE1,4,25, HA_NEXT,
420 GFX_PFORTE1X,4,25, HA_NEXT,
421 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
422 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
423 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
424 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
425 GFX_LEERRAUM,1,10, HA_NEXT,
426 GFX_DYNABOMB_NR,1,100, HA_NEXT,
427 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
428 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
429 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
430 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
431 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
432 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
433 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
434 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
435 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
436 GFX_BUTTERFLY,2,2, HA_NEXT,
437 GFX_FIREFLY,2,2, HA_NEXT,
438 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
439 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
440 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
441 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
442 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
443 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
444 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
445 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
446 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
447 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
451 GFX_MOLE_RIGHT,4,2, HA_NEXT,
452 GFX_PINGUIN_DOWN,4,2,
454 GFX_PINGUIN_LEFT,4,2,
455 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
456 GFX_SCHWEIN_DOWN,4,2,
458 GFX_SCHWEIN_LEFT,4,2,
459 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
463 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
464 GFX_SONDE_START,8,1, HA_NEXT,
465 GFX_ABLENK,4,1, HA_NEXT,
466 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
467 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
468 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
469 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
470 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
471 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
472 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
473 GFX_DIAMANT,1,10, HA_NEXT,
474 GFX_LIFE,1,100, HA_NEXT,
475 GFX_LIFE_ASYNC,1,100, HA_NEXT,
476 GFX_MAGIC_WALL_OFF,4,2, HA_NEXT,
477 GFX_MAGIC_WALL_BD_OFF,4,2, HA_NEXT,
478 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
479 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
480 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
481 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
482 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
483 GFX_SOKOBAN_OBJEKT,1,100, HA_NEXT,
484 GFX_SOKOBAN_FELD_LEER,1,100, HA_NEXT,
485 GFX_SOKOBAN_FELD_VOLL,1,100, HA_NEXT,
486 GFX_SPEED_PILL,1,100, HA_NEXT,
489 static char *helpscreen_eltext[][2] =
491 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
492 {"Normal sand:", "You can dig through it"},
493 {"Empty field:", "You can walk through it"},
494 {"Quicksand: You cannot pass it,", "but rocks can fall though it"},
495 {"Massive Wall:", "Nothing can go through it"},
496 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
497 {"Growing Wall: Grows in several di-", "rections if there is an empty field"},
498 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
499 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
500 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
501 {"Emerald: You must collect enough of","them to finish a level"},
502 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
503 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
504 {"Colorful Gems:", "Seem to behave like Emeralds"},
505 {"Rock: Smashes several things;", "Can be moved by the player"},
506 {"Bomb: You can move it, but be", "careful when dropping it"},
507 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
508 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
509 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
510 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
511 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
512 {"Acid: Things that fall in are gone", "forever (including our hero)"},
513 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
514 {"Door: Can be opened by the key", "with the same color"},
515 {"Door: You have to find out the", "right color of the key for it"},
516 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
517 {"Dynamite: This one explodes after", "a few seconds"},
518 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
519 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
520 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
521 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
522 {"Bug: Moves at the right side", "of walls; don't touch it!"},
523 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
524 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
525 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
526 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
527 {"Cruncher (BD style):", "Eats almost everything"},
528 {"Robot: Tries to kill the player", ""},
529 {"The mole: Eats the amoeba and turns","empty space into normal sand"},
530 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
531 {"The Pig: Harmless, but eats all", "gems it can get"},
532 {"The Dragon: Breathes fire,", "especially to some monsters"},
533 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
534 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
535 {"Light Bulb: All of them must be", "switched on to finish a level"},
536 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
537 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
538 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
539 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
540 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
541 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
542 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
543 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
544 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
545 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
546 {"Exit door: Opens if you have enough","emeralds to finish the level"},
547 {"Open exit door: Enter here to leave","the level and exit the actual game"},
548 {"Sokoban element: Object which must", "be pushed to an empty field"},
549 {"Sokoban element: Empty field where", "a Sokoban object can be placed on"},
550 {"Sokoban element: Field with object", "which can be pushed away"},
551 {"Speed pill: Lets the player run", "twice as fast as normally"},
553 static int num_helpscreen_els = sizeof(helpscreen_eltext)/(2*sizeof(char *));
555 static char *helpscreen_music[][3] =
557 { "Alchemy", "Ian Boddy", "Drive" },
558 { "The Chase", "Propaganda", "A Secret Wish" },
559 { "Network 23", "Tangerine Dream", "Exit" },
560 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
561 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
562 { "Voyager", "The Alan Parsons Project","Pyramid" },
563 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
565 static int num_helpscreen_music = 7;
566 static int helpscreen_musicpos;
568 void DrawHelpScreenElAction(int start)
572 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
574 while(helpscreen_action[j] != HA_END)
576 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
578 else if (i<start || helpscreen_delay[i-start])
580 if (i>=start && helpscreen_delay[i-start])
581 helpscreen_delay[i-start]--;
583 while(helpscreen_action[j] != HA_NEXT)
590 j += 3*helpscreen_step[i-start];
591 graphic = helpscreen_action[j++];
593 if (helpscreen_frame[i-start])
595 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
596 helpscreen_frame[i-start]--;
601 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
604 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
606 if (helpscreen_action[j] == HA_NEXT)
608 if (!helpscreen_frame[i-start])
609 helpscreen_step[i-start] = 0;
613 if (!helpscreen_frame[i-start])
614 helpscreen_step[i-start]++;
615 while(helpscreen_action[j] != HA_NEXT)
620 DrawGraphicExt(drawto, xstart, ystart+(i-start)*ystep, graphic+frame);
631 void DrawHelpScreenElText(int start)
634 int xstart = SX + 56, ystart = SY + 65 + 2 * 32, ystep = TILEY + 4;
635 int ybottom = SYSIZE - 20;
640 DrawTextFCentered(100, FC_GREEN, "The game elements:");
642 for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++)
645 ystart + (i - start) * ystep + (*helpscreen_eltext[i][1] ? 0 : 8),
646 helpscreen_eltext[i][0], FS_SMALL, FC_YELLOW);
647 DrawText(xstart, ystart + (i - start) * ystep + 16,
648 helpscreen_eltext[i][1], FS_SMALL, FC_YELLOW);
651 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
654 void DrawHelpScreenMusicText(int num)
656 int ystart = 150, ystep = 30;
657 int ybottom = SYSIZE - 20;
663 DrawTextFCentered(100, FC_GREEN, "The game background music loops:");
665 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
667 DrawTextFCentered(ystart + 1 * ystep, FC_RED, "\"%s\"",
668 helpscreen_music[num][0]);
669 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
671 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
672 "%s", helpscreen_music[num][1]);
673 DrawTextFCentered(ystart + 4 * ystep, FC_YELLOW,
675 DrawTextFCentered(ystart + 5 * ystep, FC_RED, "\"%s\"",
676 helpscreen_music[num][2]);
678 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
680 PlaySoundLoop(background_loop[num]);
683 void DrawHelpScreenCreditsText()
685 int ystart = 150, ystep = 30;
686 int ybottom = SYSIZE - 20;
692 DrawTextFCentered(100, FC_GREEN,
694 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
695 "DOS port of the game:");
696 DrawTextFCentered(ystart + 1 * ystep, FC_RED,
698 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
699 "Additional toons:");
700 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
702 DrawTextFCentered(ystart + 5 * ystep, FC_YELLOW,
703 "...and many thanks to all contributors");
704 DrawTextFCentered(ystart + 6 * ystep, FC_YELLOW,
707 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
710 void DrawHelpScreenContactText()
712 int ystart = 150, ystep = 30;
713 int ybottom = SYSIZE - 20;
718 DrawTextFCentered(100, FC_GREEN, "Program information:");
720 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
721 "This game is Freeware!");
722 DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW,
723 "If you like it, send e-mail to:");
724 DrawTextFCentered(ystart + 2 * ystep, FC_RED,
726 DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW,
728 DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED,
730 DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED,
731 "Detmolder Strasse 189");
732 DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED,
734 DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED,
737 DrawTextFCentered(ystart + 7 * ystep, FC_YELLOW,
738 "If you have created new levels,");
739 DrawTextFCentered(ystart + 8 * ystep, FC_YELLOW,
740 "send them to me to include them!");
741 DrawTextFCentered(ystart + 9 * ystep, FC_YELLOW,
744 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for main menu");
747 void DrawHelpScreen()
752 CloseDoor(DOOR_CLOSE_2);
754 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
755 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
756 helpscreen_musicpos = 0;
757 helpscreen_state = 0;
758 DrawHelpScreenElText(0);
759 DrawHelpScreenElAction(0);
763 PlaySoundLoop(SND_RHYTHMLOOP);
766 void HandleHelpScreen(int button)
768 static unsigned long hs_delay = 0;
769 int num_helpscreen_els_pages =
770 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
771 int button_released = !button;
776 if (helpscreen_state < num_helpscreen_els_pages - 1)
778 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
779 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
781 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
782 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
784 else if (helpscreen_state <
785 num_helpscreen_els_pages + num_helpscreen_music - 1)
788 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
790 else if (helpscreen_state ==
791 num_helpscreen_els_pages + num_helpscreen_music - 1)
794 DrawHelpScreenCreditsText();
796 else if (helpscreen_state ==
797 num_helpscreen_els_pages + num_helpscreen_music)
800 DrawHelpScreenContactText();
806 game_status = MAINMENU;
811 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
813 if (helpscreen_state<num_helpscreen_els_pages)
814 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
822 void HandleTypeName(int newxpos, Key key)
824 static int xpos = 0, ypos = 2;
829 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW);
830 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
834 if (((key >= KSYM_A && key <= KSYM_Z) ||
835 (key >= KSYM_a && key <= KSYM_z)) &&
836 xpos < MAX_PLAYER_NAME_LEN)
840 if (key >= KSYM_A && key <= KSYM_Z)
841 ascii = 'A' + (char)(key - KSYM_A);
843 ascii = 'a' + (char)(key - KSYM_a);
845 setup.player_name[xpos] = ascii;
846 setup.player_name[xpos + 1] = 0;
848 DrawTextExt(drawto, SX + 6*32, SY + ypos*32,
849 setup.player_name, FS_BIG, FC_YELLOW);
850 DrawTextExt(window, SX + 6*32, SY + ypos*32,
851 setup.player_name, FS_BIG, FC_YELLOW);
852 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
854 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
857 setup.player_name[xpos] = 0;
858 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
859 DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM);
861 else if (key == KSYM_Return && xpos > 0)
863 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
864 DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM);
867 game_status = MAINMENU;
873 static void drawCursorExt(int ypos, int color, int graphic)
875 static int cursor_array[SCR_FIELDY];
878 cursor_array[ypos] = graphic;
880 graphic = cursor_array[ypos];
883 graphic = (graphic == GFX_ARROW_BLUE_LEFT ? GFX_ARROW_RED_LEFT :
884 graphic == GFX_ARROW_BLUE_RIGHT ? GFX_ARROW_RED_RIGHT :
887 DrawGraphic(0, ypos, graphic);
890 static void initCursor(int ypos, int graphic)
892 drawCursorExt(ypos, FC_BLUE, graphic);
895 static void drawCursor(int ypos, int color)
897 drawCursorExt(ypos, color, 0);
900 void DrawChooseLevel()
903 CloseDoor(DOOR_CLOSE_2);
906 HandleChooseLevel(0,0, 0,0, MB_MENU_INITIALIZE);
907 MapChooseLevelGadgets();
913 static void AdjustChooseLevelScrollbar(int id, int first_entry)
915 struct GadgetInfo *gi = screen_gadget[id];
916 int items_max, items_visible, item_position;
918 items_max = numLevelDirInfoInGroup(leveldir_current);
919 items_visible = MAX_LEVEL_SERIES_ON_SCREEN - 1;
920 item_position = first_entry;
922 if (item_position > items_max - items_visible)
923 item_position = items_max - items_visible;
925 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
926 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
929 static void drawChooseLevelList(int first_entry, int num_page_entries)
932 char buffer[SCR_FIELDX * 2];
933 int max_buffer_len = (SCR_FIELDX - 2) * 2;
934 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
936 ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE);
937 redraw_mask |= REDRAW_FIELD;
939 DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN);
941 for(i=0; i<num_page_entries; i++)
943 struct LevelDirInfo *node, *node_first;
944 int leveldir_pos = first_entry + i;
947 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
948 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
950 strncpy(buffer, node->name , max_buffer_len);
951 buffer[max_buffer_len] = '\0';
953 DrawText(SX + 32, SY + ypos * 32, buffer, FS_MEDIUM, node->color);
955 if (node->parent_link)
956 initCursor(ypos, GFX_ARROW_BLUE_LEFT);
957 else if (node->level_group)
958 initCursor(ypos, GFX_ARROW_BLUE_RIGHT);
960 initCursor(ypos, GFX_KUGEL_BLAU);
964 DrawGraphic(0, 1, GFX_ARROW_BLUE_UP);
966 if (first_entry + num_page_entries < num_leveldirs)
967 DrawGraphic(0, MAX_LEVEL_SERIES_ON_SCREEN + 1, GFX_ARROW_BLUE_DOWN);
970 static void drawChooseLevelInfo(int leveldir_pos)
972 struct LevelDirInfo *node, *node_first;
973 int x, last_redraw_mask = redraw_mask;
975 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
976 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
978 ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32);
980 if (node->parent_link)
981 DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc);
982 else if (node->level_group)
983 DrawTextFCentered(40, FC_RED, "enter group \"%s\"", node->class_desc);
985 DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
986 node->levels, node->class_desc);
988 /* let BackToFront() redraw only what is needed */
989 redraw_mask = last_redraw_mask | REDRAW_TILES;
990 for (x=0; x<SCR_FIELDX; x++)
994 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
996 static unsigned long choose_delay = 0;
997 static int redraw = TRUE;
998 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
999 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1000 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
1001 int num_page_entries;
1003 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
1004 num_page_entries = num_leveldirs;
1006 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
1008 if (button == MB_MENU_INITIALIZE)
1010 int leveldir_pos = posLevelDirInfo(leveldir_current);
1012 if (leveldir_current->cl_first == -1)
1014 leveldir_current->cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1015 leveldir_current->cl_cursor =
1016 leveldir_pos - leveldir_current->cl_first + 3;
1019 if (dx == 999) /* first entry is set by scrollbar position */
1020 leveldir_current->cl_first = dy;
1022 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1023 leveldir_current->cl_first);
1025 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1026 drawChooseLevelInfo(leveldir_pos);
1032 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1036 if (button == MB_MENU_INITIALIZE)
1044 y = leveldir_current->cl_cursor + dy;
1047 x = y = 0; /* no action */
1049 if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
1052 step = num_page_entries - 1;
1054 y = (dy < 0 ? 2 : num_page_entries + 3);
1058 if (x == 1 && y == 2)
1060 if (leveldir_current->cl_first > 0 &&
1061 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1063 leveldir_current->cl_first -= step;
1064 if (leveldir_current->cl_first < 0)
1065 leveldir_current->cl_first = 0;
1067 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1068 drawChooseLevelInfo(leveldir_current->cl_first +
1069 leveldir_current->cl_cursor - 3);
1070 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1071 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1072 leveldir_current->cl_first);
1076 else if (x == 1 && y > num_page_entries + 2)
1078 if (leveldir_current->cl_first + num_page_entries < num_leveldirs &&
1079 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1081 leveldir_current->cl_first += step;
1082 if (leveldir_current->cl_first + num_page_entries > num_leveldirs)
1083 leveldir_current->cl_first = MAX(0, num_leveldirs - num_page_entries);
1085 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1086 drawChooseLevelInfo(leveldir_current->cl_first +
1087 leveldir_current->cl_cursor - 3);
1088 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1089 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1090 leveldir_current->cl_first);
1095 if (!mx && !my && !dx && !dy)
1098 y = leveldir_current->cl_cursor;
1103 struct LevelDirInfo *node_first, *node_cursor;
1105 leveldir_current->cl_first + leveldir_current->cl_cursor - 3;
1107 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1108 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1110 if (node_cursor->node_group)
1112 node_cursor->cl_first = leveldir_current->cl_first;
1113 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1114 leveldir_current = node_cursor->node_group;
1118 else if (dx == -1 && leveldir_current->node_parent)
1120 leveldir_current = leveldir_current->node_parent;
1124 if (x == 1 && y >= 3 && y <= num_page_entries + 2)
1128 if (y != leveldir_current->cl_cursor)
1130 drawCursor(y - 1, FC_RED);
1131 drawCursor(leveldir_current->cl_cursor - 1, FC_BLUE);
1132 drawChooseLevelInfo(leveldir_current->cl_first + y - 3);
1133 leveldir_current->cl_cursor = y;
1138 struct LevelDirInfo *node_first, *node_cursor;
1139 int leveldir_pos = leveldir_current->cl_first + y - 3;
1141 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1142 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1144 if (node_cursor->node_group)
1146 node_cursor->cl_first = leveldir_current->cl_first;
1147 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1148 leveldir_current = node_cursor->node_group;
1151 else if (node_cursor->parent_link)
1153 leveldir_current = node_cursor->node_parent;
1158 leveldir_current = node_cursor;
1160 LoadLevelSetup_SeriesInfo();
1162 SaveLevelSetup_LastSeries();
1163 SaveLevelSetup_SeriesInfo();
1166 game_status = MAINMENU;
1174 if (game_status == CHOOSELEVEL)
1178 void DrawHallOfFame(int highlight_position)
1181 CloseDoor(DOOR_CLOSE_2);
1183 if (highlight_position < 0)
1184 LoadScore(level_nr);
1188 HandleHallOfFame(highlight_position,0, 0,0, MB_MENU_INITIALIZE);
1189 PlaySound(SND_HALLOFFAME);
1192 static void drawHallOfFameList(int first_entry, int highlight_position)
1197 DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
1198 DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
1200 for(i=0; i<MAX_LEVEL_SERIES_ON_SCREEN; i++)
1202 int entry = first_entry + i;
1203 int color = (entry == highlight_position ? FC_RED : FC_GREEN);
1206 DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG, color);
1207 DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG, color);
1208 DrawText(SX + 12 * 32, SY + 64 + i * 32,
1209 int2str(highscore[i].Score, 5), FS_BIG, color);
1211 DrawText(SX, SY + 64 + i * 32, "..................................",
1212 FS_MEDIUM, FC_YELLOW);
1213 DrawText(SX, SY + 64 + i * 32, int2str(entry + 1, 3),
1214 FS_MEDIUM, FC_YELLOW);
1215 DrawText(SX + 64, SY + 64 + i * 32, highscore[entry].Name, FS_BIG, color);
1216 DrawText(SX + 14 * 32 + 16, SY + 64 + i * 32,
1217 int2str(highscore[entry].Score, 5), FS_MEDIUM, color);
1222 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
1224 static int first_entry = 0;
1225 static int highlight_position = 0;
1226 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1227 int button_released = !button;
1229 if (button == MB_MENU_INITIALIZE)
1232 highlight_position = mx;
1233 drawHallOfFameList(first_entry, highlight_position);
1237 if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
1238 step = MAX_LEVEL_SERIES_ON_SCREEN - 1;
1242 if (first_entry > 0)
1244 first_entry -= step;
1245 if (first_entry < 0)
1248 drawHallOfFameList(first_entry, highlight_position);
1254 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN < MAX_SCORE_ENTRIES)
1256 first_entry += step;
1257 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN > MAX_SCORE_ENTRIES)
1258 first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_LEVEL_SERIES_ON_SCREEN);
1260 drawHallOfFameList(first_entry, highlight_position);
1265 if (button_released)
1267 FadeSound(SND_HALLOFFAME);
1268 game_status = MAINMENU;
1274 if (game_status == HALLOFFAME)
1278 void DrawSetupScreen()
1287 { &setup.sound, "Sound:", },
1288 { &setup.sound_loops, " Sound Loops:" },
1289 { &setup.sound_music, " Game Music:" },
1291 { &setup.toons, "Toons:" },
1292 { &setup.double_buffering, "Buffered gfx:" },
1294 { &setup.scroll_delay, "Scroll Delay:" },
1295 { &setup.soft_scrolling, "Soft Scroll.:" },
1297 { &setup.fading, "Fading:" },
1299 { &setup.fullscreen, "Fullscreen:" },
1300 { &setup.quick_doors, "Quick Doors:" },
1301 { &setup.autorecord, "Auto-Record:" },
1302 { &setup.team_mode, "Team-Mode:" },
1303 { &setup.handicap, "Handicap:" },
1304 { &setup.time_limit, "Timelimit:" },
1305 { NULL, "Input Devices" },
1308 { NULL, "Save and exit" }
1312 CloseDoor(DOOR_CLOSE_2);
1315 DrawText(SX + 16, SY + 16, "SETUP",FS_BIG,FC_YELLOW);
1317 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
1319 int base = i - SETUP_SCREEN_POS_START;
1321 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
1323 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
1325 if (strcmp(setup_info[base].text, "Input Devices") == 0)
1326 initCursor(i, GFX_ARROW_BLUE_RIGHT);
1328 initCursor(i, GFX_KUGEL_BLAU);
1331 if (setup_info[base].value)
1333 int setting_value = *setup_info[base].value;
1335 DrawText(SX+14*32, SY+i*32, (setting_value ? "on" : "off"),
1336 FS_BIG, (setting_value ? FC_YELLOW : FC_BLUE));
1342 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
1345 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
1347 static int choice = 3;
1348 static int redraw = TRUE;
1349 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1350 int pos_start = SETUP_SCREEN_POS_START + 1;
1351 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
1352 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
1353 int pos_end = SETUP_SCREEN_POS_END + 1;
1355 if (button == MB_MENU_INITIALIZE)
1360 drawCursor(choice - 1, FC_RED);
1364 if (button == MB_MENU_INITIALIZE)
1377 if (y >= pos_empty1 && y <= pos_empty2)
1378 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1382 else if (y > pos_end)
1386 if (!mx && !my && !dx && !dy)
1392 if (dx == 1 && choice == 14)
1394 game_status = SETUPINPUT;
1395 DrawSetupInputScreen();
1399 if (x==1 && y >= pos_start && y <= pos_end &&
1400 !(y >= pos_empty1 && y <= pos_empty2))
1406 drawCursor(y - 1, FC_RED);
1407 drawCursor(choice - 1, FC_BLUE);
1415 if (y == 3 && audio.sound_available)
1419 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1420 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1421 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1422 setup.sound_loops = FALSE;
1423 setup.sound_music = FALSE;
1426 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1427 setup.sound = !setup.sound;
1429 else if (y == 4 && audio.loops_available)
1431 if (setup.sound_loops)
1432 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1435 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1436 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1439 setup.sound_loops = !setup.sound_loops;
1441 else if (y == 5 && audio.loops_available)
1443 if (setup.sound_music)
1444 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1447 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1448 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1451 setup.sound_music = !setup.sound_music;
1458 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1460 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1461 setup.toons = !setup.toons;
1466 if (setup.double_buffering)
1467 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1469 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1470 setup.double_buffering = !setup.double_buffering;
1471 setup.direct_draw = !setup.double_buffering;
1473 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1474 setup.double_buffering = TRUE;
1475 setup.direct_draw = !setup.double_buffering;
1482 if (setup.scroll_delay)
1483 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1485 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1486 setup.scroll_delay = !setup.scroll_delay;
1490 if (setup.soft_scrolling)
1491 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1493 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1494 setup.soft_scrolling = !setup.soft_scrolling;
1500 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1502 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1503 setup.fading = !setup.fading;
1506 else if (y == 8 && video.fullscreen_available)
1508 if (setup.fullscreen)
1509 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1511 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1512 setup.fullscreen = !setup.fullscreen;
1516 if (setup.quick_doors)
1517 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1519 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1520 setup.quick_doors = !setup.quick_doors;
1524 if (setup.autorecord)
1525 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1527 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1528 setup.autorecord = !setup.autorecord;
1532 if (setup.team_mode)
1533 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1535 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1536 setup.team_mode = !setup.team_mode;
1541 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1543 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1544 setup.handicap = !setup.handicap;
1548 if (setup.time_limit)
1549 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1551 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1552 setup.time_limit = !setup.time_limit;
1556 game_status = SETUPINPUT;
1557 DrawSetupInputScreen();
1560 else if (y==pos_end-1 || y==pos_end)
1570 #if defined(PLATFORM_MSDOS)
1571 save_joystick_data(JOYSTICK_FILENAME);
1577 game_status = MAINMENU;
1585 if (game_status==SETUP)
1589 void DrawSetupInputScreen()
1592 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1594 initCursor(2, GFX_KUGEL_BLAU);
1595 initCursor(3, GFX_KUGEL_BLAU);
1596 initCursor(4, GFX_ARROW_BLUE_RIGHT);
1597 initCursor(15, GFX_KUGEL_BLAU);
1599 DrawGraphic(10, 2, GFX_ARROW_BLUE_LEFT);
1600 DrawGraphic(12, 2, GFX_ARROW_BLUE_RIGHT);
1602 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1603 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1604 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1606 DrawTextFCentered(SYSIZE - 20, FC_BLUE,
1607 "Joysticks deactivated on this screen");
1609 HandleSetupInputScreen(0,0, 0,0, MB_MENU_INITIALIZE);
1614 static void setJoystickDeviceToNr(char *device_name, int device_nr)
1616 if (device_name == NULL)
1619 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
1622 if (strlen(device_name) > 1)
1624 char c1 = device_name[strlen(device_name) - 1];
1625 char c2 = device_name[strlen(device_name) - 2];
1627 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
1628 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
1631 strncpy(device_name, joystick_device_name[device_nr], strlen(device_name));
1634 static void drawPlayerSetupInputInfo(int player_nr)
1637 static struct SetupKeyboardInfo custom_key;
1644 { &custom_key.left, "Joystick Left" },
1645 { &custom_key.right, "Joystick Right" },
1646 { &custom_key.up, "Joystick Up" },
1647 { &custom_key.down, "Joystick Down" },
1648 { &custom_key.snap, "Button 1" },
1649 { &custom_key.bomb, "Button 2" }
1651 static char *joystick_name[MAX_PLAYERS] =
1659 custom_key = setup.input[player_nr].key;
1661 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1662 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1664 if (setup.input[player_nr].use_joystick)
1666 char *device_name = setup.input[player_nr].joy.device_name;
1668 DrawText(SX+8*32, SY+3*32,
1669 joystick_name[getJoystickNrFromDeviceName(device_name)],
1671 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1675 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1676 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1679 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1680 DrawGraphic(1, 6, GFX_ARROW_BLUE_LEFT);
1681 DrawGraphic(1, 7, GFX_ARROW_BLUE_RIGHT);
1682 DrawGraphic(1, 8, GFX_ARROW_BLUE_UP);
1683 DrawGraphic(1, 9, GFX_ARROW_BLUE_DOWN);
1684 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1685 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1686 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1687 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1688 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1689 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1693 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1695 DrawText(SX + 3*32, SY + ypos*32,
1696 " ", FS_BIG, FC_YELLOW);
1697 DrawText(SX + 3*32, SY + ypos*32,
1698 (setup.input[player_nr].use_joystick ?
1700 getKeyNameFromKey(*custom[i].key)),
1705 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1707 static int choice = 3;
1708 static int player_nr = 0;
1709 static int redraw = TRUE;
1710 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1711 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1712 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1713 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1714 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1716 if (button == MB_MENU_INITIALIZE)
1718 drawPlayerSetupInputInfo(player_nr);
1724 drawCursor(choice - 1, FC_RED);
1728 if (button == MB_MENU_INITIALIZE)
1733 if (dx && choice == 3)
1735 x = (dx < 0 ? 11 : 13);
1738 else if (dx && choice == 4)
1740 button = MB_MENU_CHOICE;
1752 if (y >= pos_empty1 && y <= pos_empty2)
1753 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1757 else if (y > pos_end)
1761 if (!mx && !my && !dx && !dy)
1767 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1769 static unsigned long delay = 0;
1771 if (!DelayReached(&delay, GADGET_FRAME_DELAY))
1774 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1776 drawPlayerSetupInputInfo(player_nr);
1778 else if (x==1 && y >= pos_start && y <= pos_end &&
1779 !(y >= pos_empty1 && y <= pos_empty2))
1785 drawCursor(y - 1, FC_RED);
1786 drawCursor(choice - 1, FC_BLUE);
1794 char *device_name = setup.input[player_nr].joy.device_name;
1796 if (!setup.input[player_nr].use_joystick)
1798 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
1800 setJoystickDeviceToNr(device_name, new_device_nr);
1801 setup.input[player_nr].use_joystick = TRUE;
1805 int device_nr = getJoystickNrFromDeviceName(device_name);
1806 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
1808 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
1809 setup.input[player_nr].use_joystick = FALSE;
1811 setJoystickDeviceToNr(device_name, new_device_nr);
1821 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1822 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1824 if (setup.input[player_nr].use_joystick)
1826 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1827 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1829 setup.input[player_nr].use_joystick = FALSE;
1833 setup.input[player_nr].use_joystick = TRUE;
1834 setup.input[player_nr].joystick_nr = one_joystick_nr;
1838 drawPlayerSetupInputInfo(player_nr);
1842 if (setup.input[player_nr].use_joystick)
1845 game_status = CALIBRATION;
1846 CalibrateJoystick(player_nr);
1847 game_status = SETUPINPUT;
1850 CustomizeKeyboard(player_nr);
1854 else if (y == pos_end)
1858 game_status = SETUP;
1868 if (game_status == SETUPINPUT)
1872 void CustomizeKeyboard(int player_nr)
1876 boolean finished = FALSE;
1877 static struct SetupKeyboardInfo custom_key;
1882 } customize_step[] =
1884 { &custom_key.left, "Move Left" },
1885 { &custom_key.right, "Move Right" },
1886 { &custom_key.up, "Move Up" },
1887 { &custom_key.down, "Move Down" },
1888 { &custom_key.snap, "Snap Field" },
1889 { &custom_key.bomb, "Place Bomb" }
1892 /* read existing key bindings from player setup */
1893 custom_key = setup.input[player_nr].key;
1896 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1902 DrawText(SX, SY + (2+2*step_nr)*32,
1903 customize_step[step_nr].text, FS_BIG, FC_RED);
1904 DrawText(SX, SY + (2+2*step_nr+1)*32,
1905 "Key:", FS_BIG, FC_RED);
1906 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1907 getKeyNameFromKey(*customize_step[step_nr].key),
1912 if (PendingEvent()) /* got event */
1920 case EVENT_KEYPRESS:
1922 Key key = GetEventKey((KeyEvent *)&event, TRUE);
1924 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
1930 /* all keys configured -- wait for "Escape" or "Return" key */
1934 /* press 'Enter' to keep the existing key binding */
1935 if (key == KSYM_Return)
1936 key = *customize_step[step_nr].key;
1938 /* check if key already used */
1939 for (i=0; i<step_nr; i++)
1940 if (*customize_step[i].key == key)
1945 /* got new key binding */
1946 *customize_step[step_nr].key = key;
1947 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1948 " ", FS_BIG, FC_YELLOW);
1949 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1950 getKeyNameFromKey(key), FS_BIG, FC_YELLOW);
1953 /* un-highlight last query */
1954 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1955 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1956 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1957 "Key:", FS_BIG, FC_GREEN);
1959 /* press 'Enter' to leave */
1962 DrawText(SX + 16, SY + 15*32+16,
1963 "Press Enter", FS_BIG, FC_YELLOW);
1967 /* query next key binding */
1968 DrawText(SX, SY+(2+2*step_nr)*32,
1969 customize_step[step_nr].text, FS_BIG, FC_RED);
1970 DrawText(SX, SY+(2+2*step_nr+1)*32,
1971 "Key:", FS_BIG, FC_RED);
1972 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1973 getKeyNameFromKey(*customize_step[step_nr].key),
1978 case EVENT_KEYRELEASE:
1979 key_joystick_mapping = 0;
1983 HandleOtherEvents(&event);
1991 /* don't eat all CPU time */
1995 /* write new key bindings back to player setup */
1996 setup.input[player_nr].key = custom_key;
1999 DrawSetupInputScreen();
2002 void CalibrateJoystick(int player_nr)
2005 struct joystick joy_ctrl;
2007 struct joystick_control
2015 #if !defined(PLATFORM_MSDOS)
2016 int new_joystick_xleft = 128, new_joystick_xright = 128;
2017 int new_joystick_yupper = 128, new_joystick_ylower = 128;
2018 int new_joystick_xmiddle, new_joystick_ymiddle;
2020 int calibration_step = 1;
2023 int joystick_fd = stored_player[player_nr].joystick_fd;
2024 int x, y, last_x, last_y, xpos = 8, ypos = 3;
2025 boolean check[3][3];
2026 int check_remaining;
2030 if (joystick_status == JOYSTICK_OFF ||
2032 !setup.input[player_nr].use_joystick)
2037 #if !defined(PLATFORM_MSDOS)
2038 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW);
2039 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW);
2040 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ", FS_BIG, FC_YELLOW);
2041 DrawText(SX, SY + 10*32, " ARE YELLOW, ", FS_BIG, FC_YELLOW);
2042 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2043 check_remaining = 3 * 3;
2045 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2046 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2047 DrawText(SX, SY + 9*32, " CENTER POSITION ", FS_BIG, FC_YELLOW);
2048 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2049 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2050 check_remaining = 0;
2057 check[x][y] = FALSE;
2058 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
2062 joy_value = Joystick(player_nr);
2063 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2064 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2065 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
2070 joy_ctrl.b1 = joy_ctrl.b2 = 0;
2072 joy_ctrl.buttons = 0;
2075 while(Joystick(player_nr) & JOY_BUTTON);
2081 if (PendingEvent()) /* got event */
2089 case EVENT_KEYPRESS:
2090 switch(GetEventKey((KeyEvent *)&event, TRUE))
2093 if (check_remaining == 0)
2106 case EVENT_KEYRELEASE:
2107 key_joystick_mapping = 0;
2111 HandleOtherEvents(&event);
2116 #if !defined(PLATFORM_MSDOS)
2118 #if defined(TARGET_SDL)
2119 joy_ctrl.x = Get_SDL_Joystick_Axis(joystick_fd, 0);
2120 joy_ctrl.y = Get_SDL_Joystick_Axis(joystick_fd, 1);
2122 if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
2124 joystick_status = JOYSTICK_OFF;
2129 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
2130 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
2131 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
2132 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
2134 new_joystick_xmiddle =
2135 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
2136 new_joystick_ymiddle =
2137 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
2139 setup.input[player_nr].joy.xleft = new_joystick_xleft;
2140 setup.input[player_nr].joy.yupper = new_joystick_yupper;
2141 setup.input[player_nr].joy.xright = new_joystick_xright;
2142 setup.input[player_nr].joy.ylower = new_joystick_ylower;
2143 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
2144 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
2146 CheckJoystickData();
2149 joy_value = Joystick(player_nr);
2151 if (joy_value & JOY_BUTTON && check_remaining == 0)
2155 #if defined(PLATFORM_MSDOS)
2156 if (calibration_step == 1)
2161 else if (calibrate_joystick(joystick_fd) != 0)
2163 joystick_status = JOYSTICK_OFF;
2167 if (joy[joystick_fd].flags & JOYFLAG_CALIBRATE)
2172 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2173 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2175 if (calibration_step == 2)
2176 DrawText(SX + 16, SY + 9*32," THE UPPER LEFT ", FS_BIG, FC_YELLOW);
2178 DrawText(SX, SY + 9*32," THE LOWER RIGHT ", FS_BIG, FC_YELLOW);
2180 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2181 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2185 while(Joystick(player_nr) & JOY_BUTTON)
2191 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2192 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2194 if (x != last_x || y != last_y)
2196 #if !defined(PLATFORM_MSDOS)
2197 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
2199 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_BLAU);
2201 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
2206 if (check_remaining > 0 && !check[x+1][y+1])
2208 check[x+1][y+1] = TRUE;
2213 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
2214 setup.input[player_nr].joy.xleft,
2215 setup.input[player_nr].joy.xmiddle,
2216 setup.input[player_nr].joy.xright);
2217 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
2218 setup.input[player_nr].joy.yupper,
2219 setup.input[player_nr].joy.ymiddle,
2220 setup.input[player_nr].joy.ylower);
2228 /* don't eat all CPU time */
2234 DrawSetupInputScreen();
2236 /* wait until the last pressed button was released */
2237 while(Joystick(player_nr) & JOY_BUTTON)
2239 if (PendingEvent()) /* got event */
2244 HandleOtherEvents(&event);
2254 DrawText(SX + 16, SY + 6*32, " JOYSTICK NOT ", FS_BIG, FC_YELLOW);
2255 DrawText(SX, SY + 7*32, " AVAILABLE ", FS_BIG, FC_YELLOW);
2258 DrawSetupInputScreen();
2261 void HandleGameActions()
2263 if (game_status != PLAYING)
2266 if (local_player->LevelSolved)
2269 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2277 /* ---------- new screen button stuff -------------------------------------- */
2279 /* graphic position and size values for buttons and scrollbars */
2280 #define SC_SCROLLBUTTON_XPOS 64
2281 #define SC_SCROLLBUTTON_YPOS 0
2282 #define SC_SCROLLBAR_XPOS 0
2283 #define SC_SCROLLBAR_YPOS 64
2285 #define SC_SCROLLBUTTON_XSIZE 32
2286 #define SC_SCROLLBUTTON_YSIZE 32
2288 #define SC_SCROLL_UP_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
2289 #define SC_SCROLL_UP_YPOS SC_SCROLLBUTTON_YSIZE
2290 #define SC_SCROLL_DOWN_XPOS SC_SCROLL_UP_XPOS
2291 #define SC_SCROLL_DOWN_YPOS (SYSIZE - SC_SCROLLBUTTON_YSIZE)
2292 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLL_UP_XPOS
2293 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + SC_SCROLLBUTTON_YSIZE)
2294 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
2295 #define SC_SCROLL_VERTICAL_YSIZE (SYSIZE - 3 * SC_SCROLLBUTTON_YSIZE)
2297 #define SC_BORDER_SIZE 14
2305 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
2308 SC_SCROLLBUTTON_XPOS + 0 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2309 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
2310 SCREEN_CTRL_ID_SCROLL_UP,
2311 "scroll level series up"
2314 SC_SCROLLBUTTON_XPOS + 1 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2315 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
2316 SCREEN_CTRL_ID_SCROLL_DOWN,
2317 "scroll level series down"
2329 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
2332 SC_SCROLLBAR_XPOS, SC_SCROLLBAR_YPOS,
2333 SX + SC_SCROLL_VERTICAL_XPOS, SY + SC_SCROLL_VERTICAL_YPOS,
2334 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
2335 GD_TYPE_SCROLLBAR_VERTICAL,
2336 SCREEN_CTRL_ID_SCROLL_VERTICAL,
2337 "scroll level series vertically"
2341 static void CreateScreenScrollbuttons()
2343 Bitmap *gd_bitmap = pix[PIX_MORE];
2344 struct GadgetInfo *gi;
2345 unsigned long event_mask;
2348 for (i=0; i<NUM_SCREEN_SCROLLBUTTONS; i++)
2350 int id = scrollbutton_info[i].gadget_id;
2351 int x, y, width, height;
2352 int gd_x1, gd_x2, gd_y1, gd_y2;
2354 x = scrollbutton_info[i].x;
2355 y = scrollbutton_info[i].y;
2357 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
2361 width = SC_SCROLLBUTTON_XSIZE;
2362 height = SC_SCROLLBUTTON_YSIZE;
2363 gd_x1 = scrollbutton_info[i].xpos;
2364 gd_y1 = scrollbutton_info[i].ypos;
2366 gd_y2 = gd_y1 + SC_SCROLLBUTTON_YSIZE;
2368 gi = CreateGadget(GDI_CUSTOM_ID, id,
2369 GDI_CUSTOM_TYPE_ID, i,
2370 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
2375 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
2376 GDI_STATE, GD_BUTTON_UNPRESSED,
2377 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2378 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2379 GDI_EVENT_MASK, event_mask,
2380 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2384 Error(ERR_EXIT, "cannot create gadget");
2386 screen_gadget[id] = gi;
2390 static void CreateScreenScrollbars()
2394 for (i=0; i<NUM_SCREEN_SCROLLBARS; i++)
2396 int id = scrollbar_info[i].gadget_id;
2397 Bitmap *gd_bitmap = pix[PIX_MORE];
2398 int gd_x1, gd_x2, gd_y1, gd_y2;
2399 struct GadgetInfo *gi;
2400 int items_max, items_visible, item_position;
2401 unsigned long event_mask;
2402 int num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2405 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2406 num_page_entries = num_leveldirs;
2408 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2410 items_max = MAX(num_leveldirs, num_page_entries);
2411 items_visible = num_page_entries;
2414 items_max = num_page_entries;
2415 items_visible = num_page_entries;
2419 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
2421 gd_x1 = scrollbar_info[i].xpos;
2422 gd_x2 = gd_x1 + scrollbar_info[i].width;
2423 gd_y1 = scrollbar_info[i].ypos;
2424 gd_y2 = scrollbar_info[i].ypos;
2426 gi = CreateGadget(GDI_CUSTOM_ID, id,
2427 GDI_CUSTOM_TYPE_ID, i,
2428 GDI_INFO_TEXT, scrollbar_info[i].infotext,
2429 GDI_X, scrollbar_info[i].x,
2430 GDI_Y, scrollbar_info[i].y,
2431 GDI_WIDTH, scrollbar_info[i].width,
2432 GDI_HEIGHT, scrollbar_info[i].height,
2433 GDI_TYPE, scrollbar_info[i].type,
2434 GDI_SCROLLBAR_ITEMS_MAX, items_max,
2435 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
2436 GDI_SCROLLBAR_ITEM_POSITION, item_position,
2437 GDI_STATE, GD_BUTTON_UNPRESSED,
2438 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2439 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2440 GDI_BORDER_SIZE, SC_BORDER_SIZE,
2441 GDI_EVENT_MASK, event_mask,
2442 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2446 Error(ERR_EXIT, "cannot create gadget");
2448 screen_gadget[id] = gi;
2452 void CreateScreenGadgets()
2454 CreateScreenScrollbuttons();
2455 CreateScreenScrollbars();
2458 void MapChooseLevelGadgets()
2460 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
2463 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2466 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2467 MapGadget(screen_gadget[i]);
2470 void UnmapChooseLevelGadgets()
2474 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2475 UnmapGadget(screen_gadget[i]);
2478 static void HandleScreenGadgets(struct GadgetInfo *gi)
2480 int id = gi->custom_id;
2482 if (game_status != CHOOSELEVEL)
2487 case SCREEN_CTRL_ID_SCROLL_UP:
2488 HandleChooseLevel(SX,SY + 32, 0,0, MB_MENU_MARK);
2491 case SCREEN_CTRL_ID_SCROLL_DOWN:
2492 HandleChooseLevel(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK);
2495 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
2496 HandleChooseLevel(0,0, 999,gi->event.item_position, MB_MENU_INITIALIZE);