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 ***********************************************************/
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 helpscreen_musicpos;
567 void DrawHelpScreenElAction(int start)
571 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
573 while(helpscreen_action[j] != HA_END)
575 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
577 else if (i<start || helpscreen_delay[i-start])
579 if (i>=start && helpscreen_delay[i-start])
580 helpscreen_delay[i-start]--;
582 while(helpscreen_action[j] != HA_NEXT)
589 j += 3*helpscreen_step[i-start];
590 graphic = helpscreen_action[j++];
592 if (helpscreen_frame[i-start])
594 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
595 helpscreen_frame[i-start]--;
600 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
603 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
605 if (helpscreen_action[j] == HA_NEXT)
607 if (!helpscreen_frame[i-start])
608 helpscreen_step[i-start] = 0;
612 if (!helpscreen_frame[i-start])
613 helpscreen_step[i-start]++;
614 while(helpscreen_action[j] != HA_NEXT)
619 DrawGraphicExt(drawto, xstart, ystart+(i-start)*ystep, graphic+frame);
630 void DrawHelpScreenElText(int start)
633 int xstart = SX + 56, ystart = SY + 65 + 2 * 32, ystep = TILEY + 4;
634 int ybottom = SYSIZE - 20;
639 DrawTextFCentered(100, FC_GREEN, "The game elements:");
641 for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++)
644 ystart + (i - start) * ystep + (*helpscreen_eltext[i][1] ? 0 : 8),
645 helpscreen_eltext[i][0], FS_SMALL, FC_YELLOW);
646 DrawText(xstart, ystart + (i - start) * ystep + 16,
647 helpscreen_eltext[i][1], FS_SMALL, FC_YELLOW);
650 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
653 void DrawHelpScreenMusicText(int num)
655 int ystart = 150, ystep = 30;
656 int ybottom = SYSIZE - 20;
662 DrawTextFCentered(100, FC_GREEN, "The game background music loops:");
664 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
666 DrawTextFCentered(ystart + 1 * ystep, FC_RED, "\"%s\"",
667 helpscreen_music[num][0]);
668 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
670 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
671 "%s", helpscreen_music[num][1]);
672 DrawTextFCentered(ystart + 4 * ystep, FC_YELLOW,
674 DrawTextFCentered(ystart + 5 * ystep, FC_RED, "\"%s\"",
675 helpscreen_music[num][2]);
677 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
679 PlaySoundLoop(background_loop[num]);
682 void DrawHelpScreenCreditsText()
684 int ystart = 150, ystep = 30;
685 int ybottom = SYSIZE - 20;
691 DrawTextFCentered(100, FC_GREEN,
693 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
694 "DOS port of the game:");
695 DrawTextFCentered(ystart + 1 * ystep, FC_RED,
697 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
698 "Additional toons:");
699 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
701 DrawTextFCentered(ystart + 5 * ystep, FC_YELLOW,
702 "...and many thanks to all contributors");
703 DrawTextFCentered(ystart + 6 * ystep, FC_YELLOW,
706 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
709 void DrawHelpScreenContactText()
711 int ystart = 150, ystep = 30;
712 int ybottom = SYSIZE - 20;
717 DrawTextFCentered(100, FC_GREEN, "Program information:");
719 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
720 "This game is Freeware!");
721 DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW,
722 "If you like it, send e-mail to:");
723 DrawTextFCentered(ystart + 2 * ystep, FC_RED,
725 DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW,
727 DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED,
729 DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED,
730 "Detmolder Strasse 189");
731 DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED,
733 DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED,
736 DrawTextFCentered(ystart + 7 * ystep, FC_YELLOW,
737 "If you have created new levels,");
738 DrawTextFCentered(ystart + 8 * ystep, FC_YELLOW,
739 "send them to me to include them!");
740 DrawTextFCentered(ystart + 9 * ystep, FC_YELLOW,
743 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for main menu");
746 void DrawHelpScreen()
751 CloseDoor(DOOR_CLOSE_2);
753 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
754 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
755 helpscreen_musicpos = 0;
756 helpscreen_state = 0;
757 DrawHelpScreenElText(0);
758 DrawHelpScreenElAction(0);
762 PlaySoundLoop(SND_RHYTHMLOOP);
765 void HandleHelpScreen(int button)
767 static unsigned long hs_delay = 0;
768 int num_helpscreen_els_pages =
769 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
770 int button_released = !button;
775 if (helpscreen_state < num_helpscreen_els_pages - 1)
777 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
778 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
780 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
781 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
783 else if (helpscreen_state < num_helpscreen_els_pages + num_bg_loops - 1)
786 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
788 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops - 1)
791 DrawHelpScreenCreditsText();
793 else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops)
796 DrawHelpScreenContactText();
802 game_status = MAINMENU;
807 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
809 if (helpscreen_state<num_helpscreen_els_pages)
810 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
818 void HandleTypeName(int newxpos, Key key)
820 static int xpos = 0, ypos = 2;
825 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW);
826 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
830 if (((key >= KSYM_A && key <= KSYM_Z) ||
831 (key >= KSYM_a && key <= KSYM_z)) &&
832 xpos < MAX_PLAYER_NAME_LEN)
836 if (key >= KSYM_A && key <= KSYM_Z)
837 ascii = 'A' + (char)(key - KSYM_A);
839 ascii = 'a' + (char)(key - KSYM_a);
841 setup.player_name[xpos] = ascii;
842 setup.player_name[xpos + 1] = 0;
844 DrawTextExt(drawto, SX + 6*32, SY + ypos*32,
845 setup.player_name, FS_BIG, FC_YELLOW);
846 DrawTextExt(window, SX + 6*32, SY + ypos*32,
847 setup.player_name, FS_BIG, FC_YELLOW);
848 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
850 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
853 setup.player_name[xpos] = 0;
854 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
855 DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM);
857 else if (key == KSYM_Return && xpos > 0)
859 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
860 DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM);
863 game_status = MAINMENU;
869 static void drawCursorExt(int ypos, int color, int graphic)
871 static int cursor_array[SCR_FIELDY];
874 cursor_array[ypos] = graphic;
876 graphic = cursor_array[ypos];
879 graphic = (graphic == GFX_ARROW_BLUE_LEFT ? GFX_ARROW_RED_LEFT :
880 graphic == GFX_ARROW_BLUE_RIGHT ? GFX_ARROW_RED_RIGHT :
883 DrawGraphic(0, ypos, graphic);
886 static void initCursor(int ypos, int graphic)
888 drawCursorExt(ypos, FC_BLUE, graphic);
891 static void drawCursor(int ypos, int color)
893 drawCursorExt(ypos, color, 0);
896 void DrawChooseLevel()
899 CloseDoor(DOOR_CLOSE_2);
902 HandleChooseLevel(0,0, 0,0, MB_MENU_INITIALIZE);
903 MapChooseLevelGadgets();
909 static void AdjustChooseLevelScrollbar(int id, int first_entry)
911 struct GadgetInfo *gi = screen_gadget[id];
912 int items_max, items_visible, item_position;
914 items_max = numLevelDirInfoInGroup(leveldir_current);
915 items_visible = MAX_LEVEL_SERIES_ON_SCREEN - 1;
916 item_position = first_entry;
918 if (item_position > items_max - items_visible)
919 item_position = items_max - items_visible;
921 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
922 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
925 static void drawChooseLevelList(int first_entry, int num_page_entries)
928 char buffer[SCR_FIELDX * 2];
929 int max_buffer_len = (SCR_FIELDX - 2) * 2;
930 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
932 ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE);
933 redraw_mask |= REDRAW_FIELD;
935 DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN);
937 for(i=0; i<num_page_entries; i++)
939 struct LevelDirInfo *node, *node_first;
940 int leveldir_pos = first_entry + i;
943 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
944 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
946 strncpy(buffer, node->name , max_buffer_len);
947 buffer[max_buffer_len] = '\0';
949 DrawText(SX + 32, SY + ypos * 32, buffer, FS_MEDIUM, node->color);
951 if (node->parent_link)
952 initCursor(ypos, GFX_ARROW_BLUE_LEFT);
953 else if (node->level_group)
954 initCursor(ypos, GFX_ARROW_BLUE_RIGHT);
956 initCursor(ypos, GFX_KUGEL_BLAU);
960 DrawGraphic(0, 1, GFX_ARROW_BLUE_UP);
962 if (first_entry + num_page_entries < num_leveldirs)
963 DrawGraphic(0, MAX_LEVEL_SERIES_ON_SCREEN + 1, GFX_ARROW_BLUE_DOWN);
966 static void drawChooseLevelInfo(int leveldir_pos)
968 struct LevelDirInfo *node, *node_first;
969 int x, last_redraw_mask = redraw_mask;
971 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
972 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
974 ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32);
976 if (node->parent_link)
977 DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc);
978 else if (node->level_group)
979 DrawTextFCentered(40, FC_RED, "enter group \"%s\"", node->class_desc);
981 DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
982 node->levels, node->class_desc);
984 /* let BackToFront() redraw only what is needed */
985 redraw_mask = last_redraw_mask | REDRAW_TILES;
986 for (x=0; x<SCR_FIELDX; x++)
990 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
992 static unsigned long choose_delay = 0;
993 static int redraw = TRUE;
994 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
995 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
996 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
997 int num_page_entries;
999 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
1000 num_page_entries = num_leveldirs;
1002 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
1004 if (button == MB_MENU_INITIALIZE)
1006 int leveldir_pos = posLevelDirInfo(leveldir_current);
1008 if (leveldir_current->cl_first == -1)
1010 leveldir_current->cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1011 leveldir_current->cl_cursor =
1012 leveldir_pos - leveldir_current->cl_first + 3;
1015 if (dx == 999) /* first entry is set by scrollbar position */
1016 leveldir_current->cl_first = dy;
1018 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1019 leveldir_current->cl_first);
1021 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1022 drawChooseLevelInfo(leveldir_pos);
1028 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1032 if (button == MB_MENU_INITIALIZE)
1040 y = leveldir_current->cl_cursor + dy;
1043 x = y = 0; /* no action */
1045 if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
1048 step = num_page_entries - 1;
1050 y = (dy < 0 ? 2 : num_page_entries + 3);
1054 if (x == 1 && y == 2)
1056 if (leveldir_current->cl_first > 0 &&
1057 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1059 leveldir_current->cl_first -= step;
1060 if (leveldir_current->cl_first < 0)
1061 leveldir_current->cl_first = 0;
1063 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1064 drawChooseLevelInfo(leveldir_current->cl_first +
1065 leveldir_current->cl_cursor - 3);
1066 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1067 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1068 leveldir_current->cl_first);
1072 else if (x == 1 && y > num_page_entries + 2)
1074 if (leveldir_current->cl_first + num_page_entries < num_leveldirs &&
1075 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1077 leveldir_current->cl_first += step;
1078 if (leveldir_current->cl_first + num_page_entries > num_leveldirs)
1079 leveldir_current->cl_first = MAX(0, num_leveldirs - num_page_entries);
1081 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1082 drawChooseLevelInfo(leveldir_current->cl_first +
1083 leveldir_current->cl_cursor - 3);
1084 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1085 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1086 leveldir_current->cl_first);
1091 if (!mx && !my && !dx && !dy)
1094 y = leveldir_current->cl_cursor;
1099 struct LevelDirInfo *node_first, *node_cursor;
1101 leveldir_current->cl_first + leveldir_current->cl_cursor - 3;
1103 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1104 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1106 if (node_cursor->node_group)
1108 node_cursor->cl_first = leveldir_current->cl_first;
1109 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1110 leveldir_current = node_cursor->node_group;
1114 else if (dx == -1 && leveldir_current->node_parent)
1116 leveldir_current = leveldir_current->node_parent;
1120 if (x == 1 && y >= 3 && y <= num_page_entries + 2)
1124 if (y != leveldir_current->cl_cursor)
1126 drawCursor(y - 1, FC_RED);
1127 drawCursor(leveldir_current->cl_cursor - 1, FC_BLUE);
1128 drawChooseLevelInfo(leveldir_current->cl_first + y - 3);
1129 leveldir_current->cl_cursor = y;
1134 struct LevelDirInfo *node_first, *node_cursor;
1135 int leveldir_pos = leveldir_current->cl_first + y - 3;
1137 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1138 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1140 if (node_cursor->node_group)
1142 node_cursor->cl_first = leveldir_current->cl_first;
1143 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1144 leveldir_current = node_cursor->node_group;
1147 else if (node_cursor->parent_link)
1149 leveldir_current = node_cursor->node_parent;
1154 leveldir_current = node_cursor;
1156 LoadLevelSetup_SeriesInfo();
1158 SaveLevelSetup_LastSeries();
1159 SaveLevelSetup_SeriesInfo();
1162 game_status = MAINMENU;
1170 if (game_status == CHOOSELEVEL)
1174 void DrawHallOfFame(int highlight_position)
1177 CloseDoor(DOOR_CLOSE_2);
1179 if (highlight_position < 0)
1180 LoadScore(level_nr);
1184 HandleHallOfFame(highlight_position,0, 0,0, MB_MENU_INITIALIZE);
1185 PlaySound(SND_HALLOFFAME);
1188 static void drawHallOfFameList(int first_entry, int highlight_position)
1193 DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
1194 DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
1196 for(i=0; i<MAX_LEVEL_SERIES_ON_SCREEN; i++)
1198 int entry = first_entry + i;
1199 int color = (entry == highlight_position ? FC_RED : FC_GREEN);
1202 DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG, color);
1203 DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG, color);
1204 DrawText(SX + 12 * 32, SY + 64 + i * 32,
1205 int2str(highscore[i].Score, 5), FS_BIG, color);
1207 DrawText(SX, SY + 64 + i * 32, "..................................",
1208 FS_MEDIUM, FC_YELLOW);
1209 DrawText(SX, SY + 64 + i * 32, int2str(entry + 1, 3),
1210 FS_MEDIUM, FC_YELLOW);
1211 DrawText(SX + 64, SY + 64 + i * 32, highscore[entry].Name, FS_BIG, color);
1212 DrawText(SX + 14 * 32 + 16, SY + 64 + i * 32,
1213 int2str(highscore[entry].Score, 5), FS_MEDIUM, color);
1218 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
1220 static int first_entry = 0;
1221 static int highlight_position = 0;
1222 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1223 int button_released = !button;
1225 if (button == MB_MENU_INITIALIZE)
1228 highlight_position = mx;
1229 drawHallOfFameList(first_entry, highlight_position);
1233 if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
1234 step = MAX_LEVEL_SERIES_ON_SCREEN - 1;
1238 if (first_entry > 0)
1240 first_entry -= step;
1241 if (first_entry < 0)
1244 drawHallOfFameList(first_entry, highlight_position);
1250 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN < MAX_SCORE_ENTRIES)
1252 first_entry += step;
1253 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN > MAX_SCORE_ENTRIES)
1254 first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_LEVEL_SERIES_ON_SCREEN);
1256 drawHallOfFameList(first_entry, highlight_position);
1261 if (button_released)
1263 FadeSound(SND_HALLOFFAME);
1264 game_status = MAINMENU;
1270 if (game_status == HALLOFFAME)
1274 void DrawSetupScreen()
1283 { &setup.sound, "Sound:", },
1284 { &setup.sound_loops, " Sound Loops:" },
1285 { &setup.sound_music, " Game Music:" },
1287 { &setup.toons, "Toons:" },
1288 { &setup.double_buffering, "Buffered gfx:" },
1290 { &setup.scroll_delay, "Scroll Delay:" },
1291 { &setup.soft_scrolling, "Soft Scroll.:" },
1293 { &setup.fading, "Fading:" },
1295 { &setup.fullscreen, "Fullscreen:" },
1296 { &setup.quick_doors, "Quick Doors:" },
1297 { &setup.autorecord, "Auto-Record:" },
1298 { &setup.team_mode, "Team-Mode:" },
1299 { &setup.handicap, "Handicap:" },
1300 { &setup.time_limit, "Timelimit:" },
1301 { NULL, "Input Devices" },
1304 { NULL, "Save and exit" }
1308 CloseDoor(DOOR_CLOSE_2);
1311 DrawText(SX + 16, SY + 16, "SETUP",FS_BIG,FC_YELLOW);
1313 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
1315 int base = i - SETUP_SCREEN_POS_START;
1317 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
1319 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
1321 if (strcmp(setup_info[base].text, "Input Devices") == 0)
1322 initCursor(i, GFX_ARROW_BLUE_RIGHT);
1324 initCursor(i, GFX_KUGEL_BLAU);
1327 if (setup_info[base].value)
1329 int setting_value = *setup_info[base].value;
1331 DrawText(SX+14*32, SY+i*32, (setting_value ? "on" : "off"),
1332 FS_BIG, (setting_value ? FC_YELLOW : FC_BLUE));
1338 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
1341 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
1343 static int choice = 3;
1344 static int redraw = TRUE;
1345 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1346 int pos_start = SETUP_SCREEN_POS_START + 1;
1347 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
1348 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
1349 int pos_end = SETUP_SCREEN_POS_END + 1;
1351 if (button == MB_MENU_INITIALIZE)
1356 drawCursor(choice - 1, FC_RED);
1360 if (button == MB_MENU_INITIALIZE)
1373 if (y >= pos_empty1 && y <= pos_empty2)
1374 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1378 else if (y > pos_end)
1382 if (!mx && !my && !dx && !dy)
1388 if (dx == 1 && choice == 14)
1390 game_status = SETUPINPUT;
1391 DrawSetupInputScreen();
1395 if (x==1 && y >= pos_start && y <= pos_end &&
1396 !(y >= pos_empty1 && y <= pos_empty2))
1402 drawCursor(y - 1, FC_RED);
1403 drawCursor(choice - 1, FC_BLUE);
1411 if (y == 3 && audio.sound_available)
1415 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1416 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1417 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1418 setup.sound_loops = FALSE;
1419 setup.sound_music = FALSE;
1422 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1423 setup.sound = !setup.sound;
1425 else if (y == 4 && audio.loops_available)
1427 if (setup.sound_loops)
1428 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1431 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1432 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1435 setup.sound_loops = !setup.sound_loops;
1437 else if (y == 5 && audio.loops_available)
1439 if (setup.sound_music)
1440 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1443 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1444 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1447 setup.sound_music = !setup.sound_music;
1454 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1456 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1457 setup.toons = !setup.toons;
1462 if (setup.double_buffering)
1463 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1465 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1466 setup.double_buffering = !setup.double_buffering;
1467 setup.direct_draw = !setup.double_buffering;
1469 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1470 setup.double_buffering = TRUE;
1471 setup.direct_draw = !setup.double_buffering;
1478 if (setup.scroll_delay)
1479 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1481 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1482 setup.scroll_delay = !setup.scroll_delay;
1486 if (setup.soft_scrolling)
1487 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1489 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1490 setup.soft_scrolling = !setup.soft_scrolling;
1496 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1498 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1499 setup.fading = !setup.fading;
1502 else if (y == 8 && video.fullscreen_available)
1504 if (setup.fullscreen)
1505 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1507 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1508 setup.fullscreen = !setup.fullscreen;
1512 if (setup.quick_doors)
1513 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1515 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1516 setup.quick_doors = !setup.quick_doors;
1520 if (setup.autorecord)
1521 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1523 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1524 setup.autorecord = !setup.autorecord;
1528 if (setup.team_mode)
1529 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1531 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1532 setup.team_mode = !setup.team_mode;
1537 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1539 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1540 setup.handicap = !setup.handicap;
1544 if (setup.time_limit)
1545 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1547 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1548 setup.time_limit = !setup.time_limit;
1552 game_status = SETUPINPUT;
1553 DrawSetupInputScreen();
1556 else if (y==pos_end-1 || y==pos_end)
1566 #if defined(PLATFORM_MSDOS)
1567 save_joystick_data(JOYSTICK_FILENAME);
1573 game_status = MAINMENU;
1581 if (game_status==SETUP)
1585 void DrawSetupInputScreen()
1588 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1590 initCursor(2, GFX_KUGEL_BLAU);
1591 initCursor(3, GFX_KUGEL_BLAU);
1592 initCursor(4, GFX_ARROW_BLUE_RIGHT);
1593 initCursor(15, GFX_KUGEL_BLAU);
1595 DrawGraphic(10, 2, GFX_ARROW_BLUE_LEFT);
1596 DrawGraphic(12, 2, GFX_ARROW_BLUE_RIGHT);
1598 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1599 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1600 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1602 DrawTextFCentered(SYSIZE - 20, FC_BLUE,
1603 "Joysticks deactivated on this screen");
1605 HandleSetupInputScreen(0,0, 0,0, MB_MENU_INITIALIZE);
1610 static void setJoystickDeviceToNr(char *device_name, int device_nr)
1612 if (device_name == NULL)
1615 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
1618 if (strlen(device_name) > 1)
1620 char c1 = device_name[strlen(device_name) - 1];
1621 char c2 = device_name[strlen(device_name) - 2];
1623 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
1624 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
1627 strncpy(device_name, joystick_device_name[device_nr], strlen(device_name));
1630 static void drawPlayerSetupInputInfo(int player_nr)
1633 static struct SetupKeyboardInfo custom_key;
1640 { &custom_key.left, "Joystick Left" },
1641 { &custom_key.right, "Joystick Right" },
1642 { &custom_key.up, "Joystick Up" },
1643 { &custom_key.down, "Joystick Down" },
1644 { &custom_key.snap, "Button 1" },
1645 { &custom_key.bomb, "Button 2" }
1647 static char *joystick_name[MAX_PLAYERS] =
1655 custom_key = setup.input[player_nr].key;
1657 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1658 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1660 if (setup.input[player_nr].use_joystick)
1662 char *device_name = setup.input[player_nr].joy.device_name;
1664 DrawText(SX+8*32, SY+3*32,
1665 joystick_name[getJoystickNrFromDeviceName(device_name)],
1667 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1671 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1672 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1675 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1676 DrawGraphic(1, 6, GFX_ARROW_BLUE_LEFT);
1677 DrawGraphic(1, 7, GFX_ARROW_BLUE_RIGHT);
1678 DrawGraphic(1, 8, GFX_ARROW_BLUE_UP);
1679 DrawGraphic(1, 9, GFX_ARROW_BLUE_DOWN);
1680 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1681 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1682 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1683 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1684 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1685 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1689 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1691 DrawText(SX + 3*32, SY + ypos*32,
1692 " ", FS_BIG, FC_YELLOW);
1693 DrawText(SX + 3*32, SY + ypos*32,
1694 (setup.input[player_nr].use_joystick ?
1696 getKeyNameFromKey(*custom[i].key)),
1701 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1703 static int choice = 3;
1704 static int player_nr = 0;
1705 static int redraw = TRUE;
1706 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1707 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1708 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1709 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1710 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1712 if (button == MB_MENU_INITIALIZE)
1714 drawPlayerSetupInputInfo(player_nr);
1720 drawCursor(choice - 1, FC_RED);
1724 if (button == MB_MENU_INITIALIZE)
1729 if (dx && choice == 3)
1731 x = (dx < 0 ? 11 : 13);
1734 else if (dx && choice == 4)
1736 button = MB_MENU_CHOICE;
1748 if (y >= pos_empty1 && y <= pos_empty2)
1749 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1753 else if (y > pos_end)
1757 if (!mx && !my && !dx && !dy)
1763 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1765 static unsigned long delay = 0;
1767 if (!DelayReached(&delay, GADGET_FRAME_DELAY))
1770 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1772 drawPlayerSetupInputInfo(player_nr);
1774 else if (x==1 && y >= pos_start && y <= pos_end &&
1775 !(y >= pos_empty1 && y <= pos_empty2))
1781 drawCursor(y - 1, FC_RED);
1782 drawCursor(choice - 1, FC_BLUE);
1790 char *device_name = setup.input[player_nr].joy.device_name;
1792 if (!setup.input[player_nr].use_joystick)
1794 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
1796 setJoystickDeviceToNr(device_name, new_device_nr);
1797 setup.input[player_nr].use_joystick = TRUE;
1801 int device_nr = getJoystickNrFromDeviceName(device_name);
1802 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
1804 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
1805 setup.input[player_nr].use_joystick = FALSE;
1807 setJoystickDeviceToNr(device_name, new_device_nr);
1817 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1818 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1820 if (setup.input[player_nr].use_joystick)
1822 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1823 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1825 setup.input[player_nr].use_joystick = FALSE;
1829 setup.input[player_nr].use_joystick = TRUE;
1830 setup.input[player_nr].joystick_nr = one_joystick_nr;
1834 drawPlayerSetupInputInfo(player_nr);
1838 if (setup.input[player_nr].use_joystick)
1841 game_status = CALIBRATION;
1842 CalibrateJoystick(player_nr);
1843 game_status = SETUPINPUT;
1846 CustomizeKeyboard(player_nr);
1850 else if (y == pos_end)
1854 game_status = SETUP;
1864 if (game_status == SETUPINPUT)
1868 void CustomizeKeyboard(int player_nr)
1872 boolean finished = FALSE;
1873 static struct SetupKeyboardInfo custom_key;
1878 } customize_step[] =
1880 { &custom_key.left, "Move Left" },
1881 { &custom_key.right, "Move Right" },
1882 { &custom_key.up, "Move Up" },
1883 { &custom_key.down, "Move Down" },
1884 { &custom_key.snap, "Snap Field" },
1885 { &custom_key.bomb, "Place Bomb" }
1888 /* read existing key bindings from player setup */
1889 custom_key = setup.input[player_nr].key;
1892 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1898 DrawText(SX, SY + (2+2*step_nr)*32,
1899 customize_step[step_nr].text, FS_BIG, FC_RED);
1900 DrawText(SX, SY + (2+2*step_nr+1)*32,
1901 "Key:", FS_BIG, FC_RED);
1902 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1903 getKeyNameFromKey(*customize_step[step_nr].key),
1908 if (PendingEvent()) /* got event */
1916 case EVENT_KEYPRESS:
1918 Key key = GetEventKey((KeyEvent *)&event, TRUE);
1920 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
1926 /* all keys configured -- wait for "Escape" or "Return" key */
1930 /* press 'Enter' to keep the existing key binding */
1931 if (key == KSYM_Return)
1932 key = *customize_step[step_nr].key;
1934 /* check if key already used */
1935 for (i=0; i<step_nr; i++)
1936 if (*customize_step[i].key == key)
1941 /* got new key binding */
1942 *customize_step[step_nr].key = key;
1943 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1944 " ", FS_BIG, FC_YELLOW);
1945 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1946 getKeyNameFromKey(key), FS_BIG, FC_YELLOW);
1949 /* un-highlight last query */
1950 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1951 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1952 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1953 "Key:", FS_BIG, FC_GREEN);
1955 /* press 'Enter' to leave */
1958 DrawText(SX + 16, SY + 15*32+16,
1959 "Press Enter", FS_BIG, FC_YELLOW);
1963 /* query next key binding */
1964 DrawText(SX, SY+(2+2*step_nr)*32,
1965 customize_step[step_nr].text, FS_BIG, FC_RED);
1966 DrawText(SX, SY+(2+2*step_nr+1)*32,
1967 "Key:", FS_BIG, FC_RED);
1968 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1969 getKeyNameFromKey(*customize_step[step_nr].key),
1974 case EVENT_KEYRELEASE:
1975 key_joystick_mapping = 0;
1979 HandleOtherEvents(&event);
1987 /* don't eat all CPU time */
1991 /* write new key bindings back to player setup */
1992 setup.input[player_nr].key = custom_key;
1995 DrawSetupInputScreen();
1998 void CalibrateJoystick(int player_nr)
2001 struct joystick joy_ctrl;
2003 struct joystick_control
2011 #if !defined(PLATFORM_MSDOS)
2012 int new_joystick_xleft = 128, new_joystick_xright = 128;
2013 int new_joystick_yupper = 128, new_joystick_ylower = 128;
2014 int new_joystick_xmiddle, new_joystick_ymiddle;
2016 int calibration_step = 1;
2019 int joystick_fd = stored_player[player_nr].joystick_fd;
2020 int x, y, last_x, last_y, xpos = 8, ypos = 3;
2021 boolean check[3][3];
2022 int check_remaining;
2026 if (joystick_status == JOYSTICK_OFF ||
2028 !setup.input[player_nr].use_joystick)
2033 #if !defined(PLATFORM_MSDOS)
2034 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW);
2035 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW);
2036 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ", FS_BIG, FC_YELLOW);
2037 DrawText(SX, SY + 10*32, " ARE YELLOW, ", FS_BIG, FC_YELLOW);
2038 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2039 check_remaining = 3 * 3;
2041 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2042 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2043 DrawText(SX, SY + 9*32, " CENTER POSITION ", FS_BIG, FC_YELLOW);
2044 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2045 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2046 check_remaining = 0;
2053 check[x][y] = FALSE;
2054 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
2058 joy_value = Joystick(player_nr);
2059 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2060 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2061 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
2066 joy_ctrl.b1 = joy_ctrl.b2 = 0;
2068 joy_ctrl.buttons = 0;
2071 while(Joystick(player_nr) & JOY_BUTTON);
2077 if (PendingEvent()) /* got event */
2085 case EVENT_KEYPRESS:
2086 switch(GetEventKey((KeyEvent *)&event, TRUE))
2089 if (check_remaining == 0)
2102 case EVENT_KEYRELEASE:
2103 key_joystick_mapping = 0;
2107 HandleOtherEvents(&event);
2112 #if !defined(PLATFORM_MSDOS)
2114 #if defined(TARGET_SDL)
2115 joy_ctrl.x = Get_SDL_Joystick_Axis(joystick_fd, 0);
2116 joy_ctrl.y = Get_SDL_Joystick_Axis(joystick_fd, 1);
2118 if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
2120 joystick_status = JOYSTICK_OFF;
2125 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
2126 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
2127 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
2128 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
2130 new_joystick_xmiddle =
2131 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
2132 new_joystick_ymiddle =
2133 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
2135 setup.input[player_nr].joy.xleft = new_joystick_xleft;
2136 setup.input[player_nr].joy.yupper = new_joystick_yupper;
2137 setup.input[player_nr].joy.xright = new_joystick_xright;
2138 setup.input[player_nr].joy.ylower = new_joystick_ylower;
2139 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
2140 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
2142 CheckJoystickData();
2145 joy_value = Joystick(player_nr);
2147 if (joy_value & JOY_BUTTON && check_remaining == 0)
2151 #if defined(PLATFORM_MSDOS)
2152 if (calibration_step == 1)
2157 else if (calibrate_joystick(joystick_fd) != 0)
2159 joystick_status = JOYSTICK_OFF;
2163 if (joy[joystick_fd].flags & JOYFLAG_CALIBRATE)
2168 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2169 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2171 if (calibration_step == 2)
2172 DrawText(SX + 16, SY + 9*32," THE UPPER LEFT ", FS_BIG, FC_YELLOW);
2174 DrawText(SX, SY + 9*32," THE LOWER RIGHT ", FS_BIG, FC_YELLOW);
2176 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2177 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2181 while(Joystick(player_nr) & JOY_BUTTON)
2187 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2188 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2190 if (x != last_x || y != last_y)
2192 #if !defined(PLATFORM_MSDOS)
2193 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
2195 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_BLAU);
2197 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
2202 if (check_remaining > 0 && !check[x+1][y+1])
2204 check[x+1][y+1] = TRUE;
2209 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
2210 setup.input[player_nr].joy.xleft,
2211 setup.input[player_nr].joy.xmiddle,
2212 setup.input[player_nr].joy.xright);
2213 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
2214 setup.input[player_nr].joy.yupper,
2215 setup.input[player_nr].joy.ymiddle,
2216 setup.input[player_nr].joy.ylower);
2224 /* don't eat all CPU time */
2230 DrawSetupInputScreen();
2232 /* wait until the last pressed button was released */
2233 while(Joystick(player_nr) & JOY_BUTTON)
2235 if (PendingEvent()) /* got event */
2240 HandleOtherEvents(&event);
2250 DrawText(SX + 16, SY + 6*32, " JOYSTICK NOT ", FS_BIG, FC_YELLOW);
2251 DrawText(SX, SY + 7*32, " AVAILABLE ", FS_BIG, FC_YELLOW);
2254 DrawSetupInputScreen();
2257 void HandleGameActions()
2259 if (game_status != PLAYING)
2262 if (local_player->LevelSolved)
2265 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2273 /* ---------- new screen button stuff -------------------------------------- */
2275 /* graphic position and size values for buttons and scrollbars */
2276 #define SC_SCROLLBUTTON_XPOS 64
2277 #define SC_SCROLLBUTTON_YPOS 0
2278 #define SC_SCROLLBAR_XPOS 0
2279 #define SC_SCROLLBAR_YPOS 64
2281 #define SC_SCROLLBUTTON_XSIZE 32
2282 #define SC_SCROLLBUTTON_YSIZE 32
2284 #define SC_SCROLL_UP_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
2285 #define SC_SCROLL_UP_YPOS SC_SCROLLBUTTON_YSIZE
2286 #define SC_SCROLL_DOWN_XPOS SC_SCROLL_UP_XPOS
2287 #define SC_SCROLL_DOWN_YPOS (SYSIZE - SC_SCROLLBUTTON_YSIZE)
2288 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLL_UP_XPOS
2289 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + SC_SCROLLBUTTON_YSIZE)
2290 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
2291 #define SC_SCROLL_VERTICAL_YSIZE (SYSIZE - 3 * SC_SCROLLBUTTON_YSIZE)
2293 #define SC_BORDER_SIZE 14
2301 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
2304 SC_SCROLLBUTTON_XPOS + 0 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2305 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
2306 SCREEN_CTRL_ID_SCROLL_UP,
2307 "scroll level series up"
2310 SC_SCROLLBUTTON_XPOS + 1 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2311 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
2312 SCREEN_CTRL_ID_SCROLL_DOWN,
2313 "scroll level series down"
2325 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
2328 SC_SCROLLBAR_XPOS, SC_SCROLLBAR_YPOS,
2329 SX + SC_SCROLL_VERTICAL_XPOS, SY + SC_SCROLL_VERTICAL_YPOS,
2330 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
2331 GD_TYPE_SCROLLBAR_VERTICAL,
2332 SCREEN_CTRL_ID_SCROLL_VERTICAL,
2333 "scroll level series vertically"
2337 static void CreateScreenScrollbuttons()
2339 Bitmap *gd_bitmap = pix[PIX_MORE];
2340 struct GadgetInfo *gi;
2341 unsigned long event_mask;
2344 for (i=0; i<NUM_SCREEN_SCROLLBUTTONS; i++)
2346 int id = scrollbutton_info[i].gadget_id;
2347 int x, y, width, height;
2348 int gd_x1, gd_x2, gd_y1, gd_y2;
2350 x = scrollbutton_info[i].x;
2351 y = scrollbutton_info[i].y;
2353 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
2357 width = SC_SCROLLBUTTON_XSIZE;
2358 height = SC_SCROLLBUTTON_YSIZE;
2359 gd_x1 = scrollbutton_info[i].xpos;
2360 gd_y1 = scrollbutton_info[i].ypos;
2362 gd_y2 = gd_y1 + SC_SCROLLBUTTON_YSIZE;
2364 gi = CreateGadget(GDI_CUSTOM_ID, id,
2365 GDI_CUSTOM_TYPE_ID, i,
2366 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
2371 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
2372 GDI_STATE, GD_BUTTON_UNPRESSED,
2373 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2374 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2375 GDI_EVENT_MASK, event_mask,
2376 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2380 Error(ERR_EXIT, "cannot create gadget");
2382 screen_gadget[id] = gi;
2386 static void CreateScreenScrollbars()
2390 for (i=0; i<NUM_SCREEN_SCROLLBARS; i++)
2392 int id = scrollbar_info[i].gadget_id;
2393 Bitmap *gd_bitmap = pix[PIX_MORE];
2394 int gd_x1, gd_x2, gd_y1, gd_y2;
2395 struct GadgetInfo *gi;
2396 int items_max, items_visible, item_position;
2397 unsigned long event_mask;
2398 int num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2401 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2402 num_page_entries = num_leveldirs;
2404 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2406 items_max = MAX(num_leveldirs, num_page_entries);
2407 items_visible = num_page_entries;
2410 items_max = num_page_entries;
2411 items_visible = num_page_entries;
2415 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
2417 gd_x1 = scrollbar_info[i].xpos;
2418 gd_x2 = gd_x1 + scrollbar_info[i].width;
2419 gd_y1 = scrollbar_info[i].ypos;
2420 gd_y2 = scrollbar_info[i].ypos;
2422 gi = CreateGadget(GDI_CUSTOM_ID, id,
2423 GDI_CUSTOM_TYPE_ID, i,
2424 GDI_INFO_TEXT, scrollbar_info[i].infotext,
2425 GDI_X, scrollbar_info[i].x,
2426 GDI_Y, scrollbar_info[i].y,
2427 GDI_WIDTH, scrollbar_info[i].width,
2428 GDI_HEIGHT, scrollbar_info[i].height,
2429 GDI_TYPE, scrollbar_info[i].type,
2430 GDI_SCROLLBAR_ITEMS_MAX, items_max,
2431 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
2432 GDI_SCROLLBAR_ITEM_POSITION, item_position,
2433 GDI_STATE, GD_BUTTON_UNPRESSED,
2434 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2435 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2436 GDI_BORDER_SIZE, SC_BORDER_SIZE,
2437 GDI_EVENT_MASK, event_mask,
2438 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2442 Error(ERR_EXIT, "cannot create gadget");
2444 screen_gadget[id] = gi;
2448 void CreateScreenGadgets()
2450 CreateScreenScrollbuttons();
2451 CreateScreenScrollbars();
2454 void MapChooseLevelGadgets()
2456 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
2459 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2462 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2463 MapGadget(screen_gadget[i]);
2466 void UnmapChooseLevelGadgets()
2470 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2471 UnmapGadget(screen_gadget[i]);
2474 static void HandleScreenGadgets(struct GadgetInfo *gi)
2476 int id = gi->custom_id;
2478 if (game_status != CHOOSELEVEL)
2483 case SCREEN_CTRL_ID_SCROLL_UP:
2484 HandleChooseLevel(SX,SY + 32, 0,0, MB_MENU_MARK);
2487 case SCREEN_CTRL_ID_SCROLL_DOWN:
2488 HandleChooseLevel(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK);
2491 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
2492 HandleChooseLevel(0,0, 999,gi->event.item_position, MB_MENU_INITIALIZE);