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);
65 static void ToggleFullscreenIfNeeded()
67 if (setup.fullscreen != video.fullscreen_enabled)
69 /* save old door content */
70 BlitBitmap(backbuffer, pix[PIX_DB_DOOR],
71 DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
73 /* toggle fullscreen */
74 setup.fullscreen = ChangeVideoModeIfNeeded(setup.fullscreen);
76 /* redraw background to newly created backbuffer */
77 BlitBitmap(pix[PIX_BACK], backbuffer, 0,0, WIN_XSIZE,WIN_YSIZE, 0,0);
79 /* restore old door content */
80 BlitBitmap(pix[PIX_DB_DOOR], backbuffer,
81 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
83 redraw_mask = REDRAW_ALL;
89 static struct LevelDirInfo *leveldir_last_valid = NULL;
91 char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:");
95 KeyboardAutoRepeatOn();
97 /* needed if last screen was the playing screen, invoked from level editor */
98 if (level_editor_test_game)
100 game_status = LEVELED;
105 /* needed if last screen was the editor screen */
106 UndrawSpecialEditorDoor();
108 /* needed if last screen was the setup screen and fullscreen state changed */
109 ToggleFullscreenIfNeeded();
112 SetDrawtoField(DRAW_BACKBUFFER);
115 /* map gadgets for main menu screen */
118 /* leveldir_current may be invalid (level group, parent link) */
119 if (!validLevelSeries(leveldir_current))
120 leveldir_current = getFirstValidLevelSeries(leveldir_last_valid);
122 /* store valid level series information */
123 leveldir_last_valid = leveldir_current;
125 /* level_nr may have been set to value over handicap with level editor */
126 if (setup.handicap && level_nr > leveldir_current->handicap_level)
127 level_nr = leveldir_current->handicap_level;
134 DrawText(SX + 32, SY + 2*32, name_text, FS_BIG, FC_GREEN);
135 DrawText(SX + 6*32, SY + 2*32, setup.player_name, FS_BIG, FC_RED);
136 DrawText(SX + 32, SY + 3*32, "Level:", FS_BIG, FC_GREEN);
137 DrawText(SX + 11*32, SY + 3*32, int2str(level_nr,3), FS_BIG,
138 (leveldir_current->readonly ? FC_RED : FC_YELLOW));
139 DrawText(SX + 32, SY + 4*32, "Hall Of Fame", FS_BIG, FC_GREEN);
140 DrawText(SX + 32, SY + 5*32, "Level Creator", FS_BIG, FC_GREEN);
141 DrawText(SY + 32, SY + 6*32, "Info Screen", FS_BIG, FC_GREEN);
142 DrawText(SX + 32, SY + 7*32, "Start Game", FS_BIG, FC_GREEN);
143 DrawText(SX + 32, SY + 8*32, "Setup", FS_BIG, FC_GREEN);
144 DrawText(SX + 32, SY + 9*32, "Quit", FS_BIG, FC_GREEN);
146 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
148 DrawTextF(7*32 + 6, 3*32 + 9, FC_RED, "%d-%d",
149 leveldir_current->first_level,
150 leveldir_current->last_level);
152 if (leveldir_current->readonly)
154 DrawTextF(15*32 + 6, 3*32 + 9 - 7, FC_RED, "READ");
155 DrawTextF(15*32 + 6, 3*32 + 9 + 7, FC_RED, "ONLY");
159 DrawGraphic(0, i, GFX_KUGEL_BLAU);
160 DrawGraphic(10, 3, GFX_ARROW_BLUE_LEFT);
161 DrawGraphic(14, 3, GFX_ARROW_BLUE_RIGHT);
163 DrawText(SX + 56, SY + 326, "A Game by Artsoft Entertainment",
166 if (leveldir_current->name)
168 int len = strlen(leveldir_current->name);
169 int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2;
170 int lypos = SY + 352;
172 DrawText(lxpos, lypos, leveldir_current->name, FS_SMALL, FC_SPECIAL2);
177 HandleMainMenu(0,0, 0,0, MB_MENU_INITIALIZE);
180 if (TAPE_IS_EMPTY(tape))
182 DrawCompleteVideoDisplay();
184 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
192 static void gotoTopLevelDir()
194 /* move upwards to top level directory */
195 while (leveldir_current->node_parent)
197 /* write a "path" into level tree for easy navigation to last level */
198 if (leveldir_current->node_parent->node_group->cl_first == -1)
200 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
201 int leveldir_pos = posLevelDirInfo(leveldir_current);
202 int num_page_entries;
203 int cl_first, cl_cursor;
205 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
206 num_page_entries = num_leveldirs;
208 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
210 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
211 cl_cursor = leveldir_pos - cl_first + 3;
213 leveldir_current->node_parent->node_group->cl_first = cl_first;
214 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
217 leveldir_current = leveldir_current->node_parent;
221 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
223 static int choice = 3;
224 static int redraw = TRUE;
225 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
227 if (redraw || button == MB_MENU_INITIALIZE)
229 DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
233 if (button == MB_MENU_INITIALIZE)
238 if (dx && choice == 4)
240 x = (dx < 0 ? 11 : 15);
257 if (!mx && !my && !dx && !dy)
263 if (y == 4 && ((x == 11 && level_nr > leveldir_current->first_level) ||
264 (x == 15 && level_nr < leveldir_current->last_level)) &&
267 static unsigned long level_delay = 0;
268 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
269 int new_level_nr, old_level_nr = level_nr;
270 int font_color = (leveldir_current->readonly ? FC_RED : FC_YELLOW);
272 new_level_nr = level_nr + (x == 11 ? -step : +step);
273 if (new_level_nr < leveldir_current->first_level)
274 new_level_nr = leveldir_current->first_level;
275 if (new_level_nr > leveldir_current->last_level)
276 new_level_nr = leveldir_current->last_level;
278 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
279 new_level_nr = leveldir_current->handicap_level;
281 if (old_level_nr == new_level_nr ||
282 !DelayReached(&level_delay, GADGET_FRAME_DELAY))
285 level_nr = new_level_nr;
287 DrawTextExt(drawto, SX + 11 * 32, SY + 3 * 32,
288 int2str(level_nr, 3), FS_BIG, font_color);
289 DrawTextExt(window, SX + 11 * 32, SY + 3 * 32,
290 int2str(level_nr, 3), FS_BIG, font_color);
293 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
297 DrawCompleteVideoDisplay();
299 /* needed because DrawMicroLevel() takes some time */
302 DelayReached(&level_delay, 0); /* reset delay counter */
304 else if (x == 1 && y >= 3 && y <= 10)
310 DrawGraphic(0, y - 1, GFX_KUGEL_ROT);
311 DrawGraphic(0, choice - 1, GFX_KUGEL_BLAU);
319 game_status = TYPENAME;
320 HandleTypeName(strlen(setup.player_name), 0);
326 game_status = CHOOSELEVEL;
327 SaveLevelSetup_LastSeries();
328 SaveLevelSetup_SeriesInfo();
337 game_status = HALLOFFAME;
342 if (leveldir_current->readonly &&
343 strcmp(setup.player_name, "Artsoft") != 0)
344 Request("This level is read only !", REQ_CONFIRM);
345 game_status = LEVELED;
350 game_status = HELPSCREEN;
355 if (setup.autorecord)
356 TapeStartRecording();
358 #if defined(PLATFORM_UNIX)
360 SendToServer_StartPlaying();
364 game_status = PLAYING;
376 SaveLevelSetup_LastSeries();
377 SaveLevelSetup_SeriesInfo();
378 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
379 game_status = EXITGAME;
389 if (game_status == MAINMENU)
391 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE);
396 #define MAX_HELPSCREEN_ELS 10
400 static long helpscreen_state;
401 static int helpscreen_step[MAX_HELPSCREEN_ELS];
402 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
403 static int helpscreen_delay[MAX_HELPSCREEN_ELS];
404 static int helpscreen_action[] =
406 GFX_SPIELER1_DOWN,4,2,
408 GFX_SPIELER1_LEFT,4,2,
409 GFX_SPIELER1_RIGHT,4,2,
410 GFX_SPIELER1_PUSH_LEFT,4,2,
411 GFX_SPIELER1_PUSH_RIGHT,4,2, HA_NEXT,
412 GFX_ERDREICH,1,100, HA_NEXT,
413 GFX_LEERRAUM,1,100, HA_NEXT,
414 GFX_MORAST_LEER,1,100, HA_NEXT,
415 GFX_BETON,1,100, HA_NEXT,
416 GFX_MAUERWERK,1,100, HA_NEXT,
417 GFX_MAUER_L1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
418 GFX_MAUER_R1, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
419 GFX_MAUER_UP, 3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
420 GFX_MAUER_DOWN,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
421 GFX_UNSICHTBAR,1,100, HA_NEXT,
422 GFX_FELSBODEN,1,100, HA_NEXT,
423 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
424 GFX_EDELSTEIN,2,5, HA_NEXT,
425 GFX_DIAMANT,2,5, HA_NEXT,
426 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
427 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
428 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
429 GFX_FELSBROCKEN,4,5, HA_NEXT,
430 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
431 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
432 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
433 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
434 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
435 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
436 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
437 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
438 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
439 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
440 GFX_GEBLUBBER,4,4, HA_NEXT,
441 GFX_SCHLUESSEL1,4,25, HA_NEXT,
442 GFX_PFORTE1,4,25, HA_NEXT,
443 GFX_PFORTE1X,4,25, HA_NEXT,
444 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
445 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
446 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
447 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
448 GFX_LEERRAUM,1,10, HA_NEXT,
449 GFX_DYNABOMB_NR,1,100, HA_NEXT,
450 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
451 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
452 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
453 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
454 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
455 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
456 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
457 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
458 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
459 GFX_BUTTERFLY,2,2, HA_NEXT,
460 GFX_FIREFLY,2,2, HA_NEXT,
461 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
462 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
463 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
464 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
465 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
466 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
467 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
468 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
469 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
470 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
474 GFX_MOLE_RIGHT,4,2, HA_NEXT,
475 GFX_PINGUIN_DOWN,4,2,
477 GFX_PINGUIN_LEFT,4,2,
478 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
479 GFX_SCHWEIN_DOWN,4,2,
481 GFX_SCHWEIN_LEFT,4,2,
482 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
486 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
487 GFX_SONDE_START,8,1, HA_NEXT,
488 GFX_ABLENK,4,1, HA_NEXT,
489 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
490 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
491 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
492 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
493 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
494 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
495 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
496 GFX_DIAMANT,1,10, HA_NEXT,
497 GFX_LIFE,1,100, HA_NEXT,
498 GFX_LIFE_ASYNC,1,100, HA_NEXT,
499 GFX_MAGIC_WALL_OFF,4,2, HA_NEXT,
500 GFX_MAGIC_WALL_BD_OFF,4,2, HA_NEXT,
501 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
502 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
503 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
504 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
505 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
506 GFX_SOKOBAN_OBJEKT,1,100, HA_NEXT,
507 GFX_SOKOBAN_FELD_LEER,1,100, HA_NEXT,
508 GFX_SOKOBAN_FELD_VOLL,1,100, HA_NEXT,
509 GFX_SPEED_PILL,1,100, HA_NEXT,
512 static char *helpscreen_eltext[][2] =
514 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
515 {"Normal sand:", "You can dig through it"},
516 {"Empty field:", "You can walk through it"},
517 {"Quicksand: You cannot pass it,", "but rocks can fall though it"},
518 {"Massive Wall:", "Nothing can go through it"},
519 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
520 {"Growing Wall: Grows in several di-", "rections if there is an empty field"},
521 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
522 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
523 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
524 {"Emerald: You must collect enough of","them to finish a level"},
525 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
526 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
527 {"Colorful Gems:", "Seem to behave like Emeralds"},
528 {"Rock: Smashes several things;", "Can be moved by the player"},
529 {"Bomb: You can move it, but be", "careful when dropping it"},
530 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
531 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
532 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
533 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
534 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
535 {"Acid: Things that fall in are gone", "forever (including our hero)"},
536 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
537 {"Door: Can be opened by the key", "with the same color"},
538 {"Door: You have to find out the", "right color of the key for it"},
539 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
540 {"Dynamite: This one explodes after", "a few seconds"},
541 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
542 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
543 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
544 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
545 {"Bug: Moves at the right side", "of walls; don't touch it!"},
546 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
547 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
548 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
549 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
550 {"Cruncher (BD style):", "Eats almost everything"},
551 {"Robot: Tries to kill the player", ""},
552 {"The mole: Eats the amoeba and turns","empty space into normal sand"},
553 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
554 {"The Pig: Harmless, but eats all", "gems it can get"},
555 {"The Dragon: Breathes fire,", "especially to some monsters"},
556 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
557 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
558 {"Light Bulb: All of them must be", "switched on to finish a level"},
559 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
560 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
561 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
562 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
563 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
564 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
565 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
566 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
567 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
568 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
569 {"Exit door: Opens if you have enough","emeralds to finish the level"},
570 {"Open exit door: Enter here to leave","the level and exit the actual game"},
571 {"Sokoban element: Object which must", "be pushed to an empty field"},
572 {"Sokoban element: Empty field where", "a Sokoban object can be placed on"},
573 {"Sokoban element: Field with object", "which can be pushed away"},
574 {"Speed pill: Lets the player run", "twice as fast as normally"},
576 static int num_helpscreen_els = sizeof(helpscreen_eltext)/(2*sizeof(char *));
578 static char *helpscreen_music[][3] =
580 { "Alchemy", "Ian Boddy", "Drive" },
581 { "The Chase", "Propaganda", "A Secret Wish" },
582 { "Network 23", "Tangerine Dream", "Exit" },
583 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
584 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
585 { "Voyager", "The Alan Parsons Project","Pyramid" },
586 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
588 static int num_helpscreen_music = 7;
589 static int helpscreen_musicpos;
591 void DrawHelpScreenElAction(int start)
595 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
597 while(helpscreen_action[j] != HA_END)
599 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
601 else if (i<start || helpscreen_delay[i-start])
603 if (i>=start && helpscreen_delay[i-start])
604 helpscreen_delay[i-start]--;
606 while(helpscreen_action[j] != HA_NEXT)
613 j += 3*helpscreen_step[i-start];
614 graphic = helpscreen_action[j++];
616 if (helpscreen_frame[i-start])
618 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
619 helpscreen_frame[i-start]--;
624 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
627 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
629 if (helpscreen_action[j] == HA_NEXT)
631 if (!helpscreen_frame[i-start])
632 helpscreen_step[i-start] = 0;
636 if (!helpscreen_frame[i-start])
637 helpscreen_step[i-start]++;
638 while(helpscreen_action[j] != HA_NEXT)
643 DrawGraphicExt(drawto, xstart, ystart+(i-start)*ystep, graphic+frame);
654 void DrawHelpScreenElText(int start)
657 int xstart = SX + 56, ystart = SY + 65 + 2 * 32, ystep = TILEY + 4;
658 int ybottom = SYSIZE - 20;
663 DrawTextFCentered(100, FC_GREEN, "The game elements:");
665 for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++)
668 ystart + (i - start) * ystep + (*helpscreen_eltext[i][1] ? 0 : 8),
669 helpscreen_eltext[i][0], FS_SMALL, FC_YELLOW);
670 DrawText(xstart, ystart + (i - start) * ystep + 16,
671 helpscreen_eltext[i][1], FS_SMALL, FC_YELLOW);
674 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
677 void DrawHelpScreenMusicText(int num)
679 int ystart = 150, ystep = 30;
680 int ybottom = SYSIZE - 20;
686 DrawTextFCentered(100, FC_GREEN, "The game background music loops:");
688 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
690 DrawTextFCentered(ystart + 1 * ystep, FC_RED, "\"%s\"",
691 helpscreen_music[num][0]);
692 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
694 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
695 "%s", helpscreen_music[num][1]);
696 DrawTextFCentered(ystart + 4 * ystep, FC_YELLOW,
698 DrawTextFCentered(ystart + 5 * ystep, FC_RED, "\"%s\"",
699 helpscreen_music[num][2]);
701 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
703 PlaySoundLoop(background_loop[num]);
706 void DrawHelpScreenCreditsText()
708 int ystart = 150, ystep = 30;
709 int ybottom = SYSIZE - 20;
715 DrawTextFCentered(100, FC_GREEN,
717 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
718 "DOS port of the game:");
719 DrawTextFCentered(ystart + 1 * ystep, FC_RED,
721 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
722 "Additional toons:");
723 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
725 DrawTextFCentered(ystart + 5 * ystep, FC_YELLOW,
726 "...and many thanks to all contributors");
727 DrawTextFCentered(ystart + 6 * ystep, FC_YELLOW,
730 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
733 void DrawHelpScreenContactText()
735 int ystart = 150, ystep = 30;
736 int ybottom = SYSIZE - 20;
741 DrawTextFCentered(100, FC_GREEN, "Program information:");
743 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
744 "This game is Freeware!");
745 DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW,
746 "If you like it, send e-mail to:");
747 DrawTextFCentered(ystart + 2 * ystep, FC_RED,
749 DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW,
751 DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED,
753 DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED,
754 "Detmolder Strasse 189");
755 DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED,
757 DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED,
760 DrawTextFCentered(ystart + 7 * ystep, FC_YELLOW,
761 "If you have created new levels,");
762 DrawTextFCentered(ystart + 8 * ystep, FC_YELLOW,
763 "send them to me to include them!");
764 DrawTextFCentered(ystart + 9 * ystep, FC_YELLOW,
767 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for main menu");
770 void DrawHelpScreen()
775 CloseDoor(DOOR_CLOSE_2);
777 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
778 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
779 helpscreen_musicpos = 0;
780 helpscreen_state = 0;
781 DrawHelpScreenElText(0);
782 DrawHelpScreenElAction(0);
786 PlaySoundLoop(SND_RHYTHMLOOP);
789 void HandleHelpScreen(int button)
791 static unsigned long hs_delay = 0;
792 int num_helpscreen_els_pages =
793 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
794 int button_released = !button;
799 if (helpscreen_state < num_helpscreen_els_pages - 1)
801 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
802 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
804 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
805 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
807 else if (helpscreen_state <
808 num_helpscreen_els_pages + num_helpscreen_music - 1)
811 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
813 else if (helpscreen_state ==
814 num_helpscreen_els_pages + num_helpscreen_music - 1)
817 DrawHelpScreenCreditsText();
819 else if (helpscreen_state ==
820 num_helpscreen_els_pages + num_helpscreen_music)
823 DrawHelpScreenContactText();
829 game_status = MAINMENU;
834 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
836 if (helpscreen_state<num_helpscreen_els_pages)
837 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
845 void HandleTypeName(int newxpos, Key key)
847 static int xpos = 0, ypos = 2;
852 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW);
853 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
857 if (((key >= KSYM_A && key <= KSYM_Z) ||
858 (key >= KSYM_a && key <= KSYM_z)) &&
859 xpos < MAX_PLAYER_NAME_LEN)
863 if (key >= KSYM_A && key <= KSYM_Z)
864 ascii = 'A' + (char)(key - KSYM_A);
866 ascii = 'a' + (char)(key - KSYM_a);
868 setup.player_name[xpos] = ascii;
869 setup.player_name[xpos + 1] = 0;
871 DrawTextExt(drawto, SX + 6*32, SY + ypos*32,
872 setup.player_name, FS_BIG, FC_YELLOW);
873 DrawTextExt(window, SX + 6*32, SY + ypos*32,
874 setup.player_name, FS_BIG, FC_YELLOW);
875 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
877 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
880 setup.player_name[xpos] = 0;
881 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
882 DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM);
884 else if (key == KSYM_Return && xpos > 0)
886 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
887 DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM);
890 game_status = MAINMENU;
896 static void drawCursorExt(int ypos, int color, int graphic)
898 static int cursor_array[SCR_FIELDY];
901 cursor_array[ypos] = graphic;
903 graphic = cursor_array[ypos];
906 graphic = (graphic == GFX_ARROW_BLUE_LEFT ? GFX_ARROW_RED_LEFT :
907 graphic == GFX_ARROW_BLUE_RIGHT ? GFX_ARROW_RED_RIGHT :
910 DrawGraphic(0, ypos, graphic);
913 static void initCursor(int ypos, int graphic)
915 drawCursorExt(ypos, FC_BLUE, graphic);
918 static void drawCursor(int ypos, int color)
920 drawCursorExt(ypos, color, 0);
923 void DrawChooseLevel()
926 CloseDoor(DOOR_CLOSE_2);
929 HandleChooseLevel(0,0, 0,0, MB_MENU_INITIALIZE);
930 MapChooseLevelGadgets();
936 static void AdjustChooseLevelScrollbar(int id, int first_entry)
938 struct GadgetInfo *gi = screen_gadget[id];
939 int items_max, items_visible, item_position;
941 items_max = numLevelDirInfoInGroup(leveldir_current);
942 items_visible = MAX_LEVEL_SERIES_ON_SCREEN - 1;
943 item_position = first_entry;
945 if (item_position > items_max - items_visible)
946 item_position = items_max - items_visible;
948 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
949 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
952 static void drawChooseLevelList(int first_entry, int num_page_entries)
955 char buffer[SCR_FIELDX * 2];
956 int max_buffer_len = (SCR_FIELDX - 2) * 2;
957 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
959 ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE);
960 redraw_mask |= REDRAW_FIELD;
962 DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN);
964 for(i=0; i<num_page_entries; i++)
966 struct LevelDirInfo *node, *node_first;
967 int leveldir_pos = first_entry + i;
970 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
971 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
973 strncpy(buffer, node->name , max_buffer_len);
974 buffer[max_buffer_len] = '\0';
976 DrawText(SX + 32, SY + ypos * 32, buffer, FS_MEDIUM, node->color);
978 if (node->parent_link)
979 initCursor(ypos, GFX_ARROW_BLUE_LEFT);
980 else if (node->level_group)
981 initCursor(ypos, GFX_ARROW_BLUE_RIGHT);
983 initCursor(ypos, GFX_KUGEL_BLAU);
987 DrawGraphic(0, 1, GFX_ARROW_BLUE_UP);
989 if (first_entry + num_page_entries < num_leveldirs)
990 DrawGraphic(0, MAX_LEVEL_SERIES_ON_SCREEN + 1, GFX_ARROW_BLUE_DOWN);
993 static void drawChooseLevelInfo(int leveldir_pos)
995 struct LevelDirInfo *node, *node_first;
996 int x, last_redraw_mask = redraw_mask;
998 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
999 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
1001 ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32);
1003 if (node->parent_link)
1004 DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc);
1005 else if (node->level_group)
1006 DrawTextFCentered(40, FC_RED, "enter group \"%s\"", node->class_desc);
1008 DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
1009 node->levels, node->class_desc);
1011 /* let BackToFront() redraw only what is needed */
1012 redraw_mask = last_redraw_mask | REDRAW_TILES;
1013 for (x=0; x<SCR_FIELDX; x++)
1014 MarkTileDirty(x, 1);
1017 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
1019 static unsigned long choose_delay = 0;
1020 static int redraw = TRUE;
1021 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
1022 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1023 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
1024 int num_page_entries;
1026 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
1027 num_page_entries = num_leveldirs;
1029 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
1031 if (button == MB_MENU_INITIALIZE)
1033 int leveldir_pos = posLevelDirInfo(leveldir_current);
1035 if (leveldir_current->cl_first == -1)
1037 leveldir_current->cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1038 leveldir_current->cl_cursor =
1039 leveldir_pos - leveldir_current->cl_first + 3;
1042 if (dx == 999) /* first entry is set by scrollbar position */
1043 leveldir_current->cl_first = dy;
1045 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1046 leveldir_current->cl_first);
1048 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1049 drawChooseLevelInfo(leveldir_pos);
1055 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1059 if (button == MB_MENU_INITIALIZE)
1067 y = leveldir_current->cl_cursor + dy;
1070 x = y = 0; /* no action */
1072 if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
1075 step = num_page_entries - 1;
1077 y = (dy < 0 ? 2 : num_page_entries + 3);
1081 if (x == 1 && y == 2)
1083 if (leveldir_current->cl_first > 0 &&
1084 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1086 leveldir_current->cl_first -= step;
1087 if (leveldir_current->cl_first < 0)
1088 leveldir_current->cl_first = 0;
1090 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1091 drawChooseLevelInfo(leveldir_current->cl_first +
1092 leveldir_current->cl_cursor - 3);
1093 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1094 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1095 leveldir_current->cl_first);
1099 else if (x == 1 && y > num_page_entries + 2)
1101 if (leveldir_current->cl_first + num_page_entries < num_leveldirs &&
1102 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1104 leveldir_current->cl_first += step;
1105 if (leveldir_current->cl_first + num_page_entries > num_leveldirs)
1106 leveldir_current->cl_first = MAX(0, num_leveldirs - num_page_entries);
1108 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1109 drawChooseLevelInfo(leveldir_current->cl_first +
1110 leveldir_current->cl_cursor - 3);
1111 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1112 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1113 leveldir_current->cl_first);
1118 if (!mx && !my && !dx && !dy)
1121 y = leveldir_current->cl_cursor;
1126 struct LevelDirInfo *node_first, *node_cursor;
1128 leveldir_current->cl_first + leveldir_current->cl_cursor - 3;
1130 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1131 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1133 if (node_cursor->node_group)
1135 node_cursor->cl_first = leveldir_current->cl_first;
1136 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1137 leveldir_current = node_cursor->node_group;
1141 else if (dx == -1 && leveldir_current->node_parent)
1143 leveldir_current = leveldir_current->node_parent;
1147 if (x == 1 && y >= 3 && y <= num_page_entries + 2)
1151 if (y != leveldir_current->cl_cursor)
1153 drawCursor(y - 1, FC_RED);
1154 drawCursor(leveldir_current->cl_cursor - 1, FC_BLUE);
1155 drawChooseLevelInfo(leveldir_current->cl_first + y - 3);
1156 leveldir_current->cl_cursor = y;
1161 struct LevelDirInfo *node_first, *node_cursor;
1162 int leveldir_pos = leveldir_current->cl_first + y - 3;
1164 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1165 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1167 if (node_cursor->node_group)
1169 node_cursor->cl_first = leveldir_current->cl_first;
1170 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1171 leveldir_current = node_cursor->node_group;
1174 else if (node_cursor->parent_link)
1176 leveldir_current = node_cursor->node_parent;
1181 leveldir_current = node_cursor;
1183 LoadLevelSetup_SeriesInfo();
1185 SaveLevelSetup_LastSeries();
1186 SaveLevelSetup_SeriesInfo();
1189 game_status = MAINMENU;
1197 if (game_status == CHOOSELEVEL)
1201 void DrawHallOfFame(int highlight_position)
1204 CloseDoor(DOOR_CLOSE_2);
1206 if (highlight_position < 0)
1207 LoadScore(level_nr);
1211 HandleHallOfFame(highlight_position,0, 0,0, MB_MENU_INITIALIZE);
1212 PlaySound(SND_HALLOFFAME);
1215 static void drawHallOfFameList(int first_entry, int highlight_position)
1220 DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
1221 DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
1223 for(i=0; i<MAX_LEVEL_SERIES_ON_SCREEN; i++)
1225 int entry = first_entry + i;
1226 int color = (entry == highlight_position ? FC_RED : FC_GREEN);
1229 DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG, color);
1230 DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG, color);
1231 DrawText(SX + 12 * 32, SY + 64 + i * 32,
1232 int2str(highscore[i].Score, 5), FS_BIG, color);
1234 DrawText(SX, SY + 64 + i * 32, "..................................",
1235 FS_MEDIUM, FC_YELLOW);
1236 DrawText(SX, SY + 64 + i * 32, int2str(entry + 1, 3),
1237 FS_MEDIUM, FC_YELLOW);
1238 DrawText(SX + 64, SY + 64 + i * 32, highscore[entry].Name, FS_BIG, color);
1239 DrawText(SX + 14 * 32 + 16, SY + 64 + i * 32,
1240 int2str(highscore[entry].Score, 5), FS_MEDIUM, color);
1245 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
1247 static int first_entry = 0;
1248 static int highlight_position = 0;
1249 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1250 int button_released = !button;
1252 if (button == MB_MENU_INITIALIZE)
1255 highlight_position = mx;
1256 drawHallOfFameList(first_entry, highlight_position);
1260 if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
1261 step = MAX_LEVEL_SERIES_ON_SCREEN - 1;
1265 if (first_entry > 0)
1267 first_entry -= step;
1268 if (first_entry < 0)
1271 drawHallOfFameList(first_entry, highlight_position);
1277 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN < MAX_SCORE_ENTRIES)
1279 first_entry += step;
1280 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN > MAX_SCORE_ENTRIES)
1281 first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_LEVEL_SERIES_ON_SCREEN);
1283 drawHallOfFameList(first_entry, highlight_position);
1288 if (button_released)
1290 FadeSound(SND_HALLOFFAME);
1291 game_status = MAINMENU;
1297 if (game_status == HALLOFFAME)
1301 void DrawSetupScreen()
1310 { &setup.sound, "Sound:", },
1311 { &setup.sound_loops, " Sound Loops:" },
1312 { &setup.sound_music, " Game Music:" },
1314 { &setup.toons, "Toons:" },
1315 { &setup.double_buffering, "Buffered gfx:" },
1317 { &setup.scroll_delay, "Scroll Delay:" },
1318 { &setup.soft_scrolling, "Soft Scroll.:" },
1320 { &setup.fading, "Fading:" },
1322 { &setup.fullscreen, "Fullscreen:" },
1323 { &setup.quick_doors, "Quick Doors:" },
1324 { &setup.autorecord, "Auto-Record:" },
1325 { &setup.team_mode, "Team-Mode:" },
1326 { &setup.handicap, "Handicap:" },
1327 { &setup.time_limit, "Timelimit:" },
1328 { NULL, "Input Devices" },
1331 { NULL, "Save and exit" }
1335 CloseDoor(DOOR_CLOSE_2);
1338 DrawText(SX + 16, SY + 16, "SETUP",FS_BIG,FC_YELLOW);
1340 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
1342 int base = i - SETUP_SCREEN_POS_START;
1344 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
1346 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
1348 if (strcmp(setup_info[base].text, "Input Devices") == 0)
1349 initCursor(i, GFX_ARROW_BLUE_RIGHT);
1351 initCursor(i, GFX_KUGEL_BLAU);
1354 if (setup_info[base].value)
1356 int setting_value = *setup_info[base].value;
1358 DrawText(SX+14*32, SY+i*32, (setting_value ? "on" : "off"),
1359 FS_BIG, (setting_value ? FC_YELLOW : FC_BLUE));
1365 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
1368 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
1370 static int choice = 3;
1371 static int redraw = TRUE;
1372 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1373 int pos_start = SETUP_SCREEN_POS_START + 1;
1374 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
1375 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
1376 int pos_end = SETUP_SCREEN_POS_END + 1;
1378 if (button == MB_MENU_INITIALIZE)
1383 drawCursor(choice - 1, FC_RED);
1387 if (button == MB_MENU_INITIALIZE)
1400 if (y >= pos_empty1 && y <= pos_empty2)
1401 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1405 else if (y > pos_end)
1409 if (!mx && !my && !dx && !dy)
1415 if (dx == 1 && choice == 14)
1417 game_status = SETUPINPUT;
1418 DrawSetupInputScreen();
1422 if (x==1 && y >= pos_start && y <= pos_end &&
1423 !(y >= pos_empty1 && y <= pos_empty2))
1429 drawCursor(y - 1, FC_RED);
1430 drawCursor(choice - 1, FC_BLUE);
1438 if (y == 3 && audio.sound_available)
1442 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1443 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1444 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1445 setup.sound_loops = FALSE;
1446 setup.sound_music = FALSE;
1449 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1450 setup.sound = !setup.sound;
1452 else if (y == 4 && audio.loops_available)
1454 if (setup.sound_loops)
1455 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1458 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1459 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1462 setup.sound_loops = !setup.sound_loops;
1464 else if (y == 5 && audio.loops_available)
1466 if (setup.sound_music)
1467 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1470 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1471 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1474 setup.sound_music = !setup.sound_music;
1481 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1483 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1484 setup.toons = !setup.toons;
1489 if (setup.double_buffering)
1490 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1492 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1493 setup.double_buffering = !setup.double_buffering;
1494 setup.direct_draw = !setup.double_buffering;
1496 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1497 setup.double_buffering = TRUE;
1498 setup.direct_draw = !setup.double_buffering;
1505 if (setup.scroll_delay)
1506 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1508 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1509 setup.scroll_delay = !setup.scroll_delay;
1513 if (setup.soft_scrolling)
1514 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1516 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1517 setup.soft_scrolling = !setup.soft_scrolling;
1523 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1525 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1526 setup.fading = !setup.fading;
1529 else if (y == 8 && video.fullscreen_available)
1531 if (setup.fullscreen)
1532 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1534 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1535 setup.fullscreen = !setup.fullscreen;
1539 if (setup.quick_doors)
1540 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1542 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1543 setup.quick_doors = !setup.quick_doors;
1547 if (setup.autorecord)
1548 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1550 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1551 setup.autorecord = !setup.autorecord;
1555 if (setup.team_mode)
1556 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1558 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1559 setup.team_mode = !setup.team_mode;
1564 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1566 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1567 setup.handicap = !setup.handicap;
1571 if (setup.time_limit)
1572 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1574 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1575 setup.time_limit = !setup.time_limit;
1579 game_status = SETUPINPUT;
1580 DrawSetupInputScreen();
1583 else if (y==pos_end-1 || y==pos_end)
1593 #if defined(PLATFORM_MSDOS)
1594 save_joystick_data(JOYSTICK_FILENAME);
1600 game_status = MAINMENU;
1608 if (game_status==SETUP)
1612 void DrawSetupInputScreen()
1615 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1617 initCursor(2, GFX_KUGEL_BLAU);
1618 initCursor(3, GFX_KUGEL_BLAU);
1619 initCursor(4, GFX_ARROW_BLUE_RIGHT);
1620 initCursor(15, GFX_KUGEL_BLAU);
1622 DrawGraphic(10, 2, GFX_ARROW_BLUE_LEFT);
1623 DrawGraphic(12, 2, GFX_ARROW_BLUE_RIGHT);
1625 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1626 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1627 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1629 DrawTextFCentered(SYSIZE - 20, FC_BLUE,
1630 "Joysticks deactivated on this screen");
1632 HandleSetupInputScreen(0,0, 0,0, MB_MENU_INITIALIZE);
1637 static void setJoystickDeviceToNr(char *device_name, int device_nr)
1639 if (device_name == NULL)
1642 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
1645 if (strlen(device_name) > 1)
1647 char c1 = device_name[strlen(device_name) - 1];
1648 char c2 = device_name[strlen(device_name) - 2];
1650 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
1651 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
1654 strncpy(device_name, joystick_device_name[device_nr], strlen(device_name));
1657 static void drawPlayerSetupInputInfo(int player_nr)
1660 static struct SetupKeyboardInfo custom_key;
1667 { &custom_key.left, "Joystick Left" },
1668 { &custom_key.right, "Joystick Right" },
1669 { &custom_key.up, "Joystick Up" },
1670 { &custom_key.down, "Joystick Down" },
1671 { &custom_key.snap, "Button 1" },
1672 { &custom_key.bomb, "Button 2" }
1674 static char *joystick_name[MAX_PLAYERS] =
1682 custom_key = setup.input[player_nr].key;
1684 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1685 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1687 if (setup.input[player_nr].use_joystick)
1689 char *device_name = setup.input[player_nr].joy.device_name;
1691 DrawText(SX+8*32, SY+3*32,
1692 joystick_name[getJoystickNrFromDeviceName(device_name)],
1694 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1698 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1699 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1702 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1703 DrawGraphic(1, 6, GFX_ARROW_BLUE_LEFT);
1704 DrawGraphic(1, 7, GFX_ARROW_BLUE_RIGHT);
1705 DrawGraphic(1, 8, GFX_ARROW_BLUE_UP);
1706 DrawGraphic(1, 9, GFX_ARROW_BLUE_DOWN);
1707 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1708 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1709 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1710 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1711 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1712 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1716 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1718 DrawText(SX + 3*32, SY + ypos*32,
1719 " ", FS_BIG, FC_YELLOW);
1720 DrawText(SX + 3*32, SY + ypos*32,
1721 (setup.input[player_nr].use_joystick ?
1723 getKeyNameFromKey(*custom[i].key)),
1728 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1730 static int choice = 3;
1731 static int player_nr = 0;
1732 static int redraw = TRUE;
1733 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1734 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1735 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1736 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1737 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1739 if (button == MB_MENU_INITIALIZE)
1741 drawPlayerSetupInputInfo(player_nr);
1747 drawCursor(choice - 1, FC_RED);
1751 if (button == MB_MENU_INITIALIZE)
1756 if (dx && choice == 3)
1758 x = (dx < 0 ? 11 : 13);
1761 else if (dx && choice == 4)
1763 button = MB_MENU_CHOICE;
1775 if (y >= pos_empty1 && y <= pos_empty2)
1776 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1780 else if (y > pos_end)
1784 if (!mx && !my && !dx && !dy)
1790 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1792 static unsigned long delay = 0;
1794 if (!DelayReached(&delay, GADGET_FRAME_DELAY))
1797 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1799 drawPlayerSetupInputInfo(player_nr);
1801 else if (x==1 && y >= pos_start && y <= pos_end &&
1802 !(y >= pos_empty1 && y <= pos_empty2))
1808 drawCursor(y - 1, FC_RED);
1809 drawCursor(choice - 1, FC_BLUE);
1817 char *device_name = setup.input[player_nr].joy.device_name;
1819 if (!setup.input[player_nr].use_joystick)
1821 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
1823 setJoystickDeviceToNr(device_name, new_device_nr);
1824 setup.input[player_nr].use_joystick = TRUE;
1828 int device_nr = getJoystickNrFromDeviceName(device_name);
1829 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
1831 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
1832 setup.input[player_nr].use_joystick = FALSE;
1834 setJoystickDeviceToNr(device_name, new_device_nr);
1844 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1845 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1847 if (setup.input[player_nr].use_joystick)
1849 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1850 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1852 setup.input[player_nr].use_joystick = FALSE;
1856 setup.input[player_nr].use_joystick = TRUE;
1857 setup.input[player_nr].joystick_nr = one_joystick_nr;
1861 drawPlayerSetupInputInfo(player_nr);
1865 if (setup.input[player_nr].use_joystick)
1868 game_status = CALIBRATION;
1869 CalibrateJoystick(player_nr);
1870 game_status = SETUPINPUT;
1873 CustomizeKeyboard(player_nr);
1877 else if (y == pos_end)
1881 game_status = SETUP;
1891 if (game_status == SETUPINPUT)
1895 void CustomizeKeyboard(int player_nr)
1899 boolean finished = FALSE;
1900 static struct SetupKeyboardInfo custom_key;
1905 } customize_step[] =
1907 { &custom_key.left, "Move Left" },
1908 { &custom_key.right, "Move Right" },
1909 { &custom_key.up, "Move Up" },
1910 { &custom_key.down, "Move Down" },
1911 { &custom_key.snap, "Snap Field" },
1912 { &custom_key.bomb, "Place Bomb" }
1915 /* read existing key bindings from player setup */
1916 custom_key = setup.input[player_nr].key;
1919 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1925 DrawText(SX, SY + (2+2*step_nr)*32,
1926 customize_step[step_nr].text, FS_BIG, FC_RED);
1927 DrawText(SX, SY + (2+2*step_nr+1)*32,
1928 "Key:", FS_BIG, FC_RED);
1929 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1930 getKeyNameFromKey(*customize_step[step_nr].key),
1935 if (PendingEvent()) /* got event */
1943 case EVENT_KEYPRESS:
1945 Key key = GetEventKey((KeyEvent *)&event, TRUE);
1947 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
1953 /* all keys configured -- wait for "Escape" or "Return" key */
1957 /* press 'Enter' to keep the existing key binding */
1958 if (key == KSYM_Return)
1959 key = *customize_step[step_nr].key;
1961 /* check if key already used */
1962 for (i=0; i<step_nr; i++)
1963 if (*customize_step[i].key == key)
1968 /* got new key binding */
1969 *customize_step[step_nr].key = key;
1970 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1971 " ", FS_BIG, FC_YELLOW);
1972 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1973 getKeyNameFromKey(key), FS_BIG, FC_YELLOW);
1976 /* un-highlight last query */
1977 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1978 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1979 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1980 "Key:", FS_BIG, FC_GREEN);
1982 /* press 'Enter' to leave */
1985 DrawText(SX + 16, SY + 15*32+16,
1986 "Press Enter", FS_BIG, FC_YELLOW);
1990 /* query next key binding */
1991 DrawText(SX, SY+(2+2*step_nr)*32,
1992 customize_step[step_nr].text, FS_BIG, FC_RED);
1993 DrawText(SX, SY+(2+2*step_nr+1)*32,
1994 "Key:", FS_BIG, FC_RED);
1995 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1996 getKeyNameFromKey(*customize_step[step_nr].key),
2001 case EVENT_KEYRELEASE:
2002 key_joystick_mapping = 0;
2006 HandleOtherEvents(&event);
2014 /* don't eat all CPU time */
2018 /* write new key bindings back to player setup */
2019 setup.input[player_nr].key = custom_key;
2022 DrawSetupInputScreen();
2025 void CalibrateJoystick(int player_nr)
2028 struct joystick joy_ctrl;
2030 struct joystick_control
2038 #if !defined(PLATFORM_MSDOS)
2039 int new_joystick_xleft = 128, new_joystick_xright = 128;
2040 int new_joystick_yupper = 128, new_joystick_ylower = 128;
2041 int new_joystick_xmiddle, new_joystick_ymiddle;
2043 int calibration_step = 1;
2046 int joystick_fd = stored_player[player_nr].joystick_fd;
2047 int x, y, last_x, last_y, xpos = 8, ypos = 3;
2048 boolean check[3][3];
2049 int check_remaining;
2053 if (joystick_status == JOYSTICK_OFF ||
2055 !setup.input[player_nr].use_joystick)
2060 #if !defined(PLATFORM_MSDOS)
2061 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW);
2062 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW);
2063 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ", FS_BIG, FC_YELLOW);
2064 DrawText(SX, SY + 10*32, " ARE YELLOW, ", FS_BIG, FC_YELLOW);
2065 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2066 check_remaining = 3 * 3;
2068 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2069 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2070 DrawText(SX, SY + 9*32, " CENTER POSITION ", FS_BIG, FC_YELLOW);
2071 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2072 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2073 check_remaining = 0;
2080 check[x][y] = FALSE;
2081 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
2085 joy_value = Joystick(player_nr);
2086 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2087 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2088 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
2093 joy_ctrl.b1 = joy_ctrl.b2 = 0;
2095 joy_ctrl.buttons = 0;
2098 while(Joystick(player_nr) & JOY_BUTTON);
2104 if (PendingEvent()) /* got event */
2112 case EVENT_KEYPRESS:
2113 switch(GetEventKey((KeyEvent *)&event, TRUE))
2116 if (check_remaining == 0)
2129 case EVENT_KEYRELEASE:
2130 key_joystick_mapping = 0;
2134 HandleOtherEvents(&event);
2139 #if !defined(PLATFORM_MSDOS)
2141 #if defined(TARGET_SDL)
2142 joy_ctrl.x = Get_SDL_Joystick_Axis(joystick_fd, 0);
2143 joy_ctrl.y = Get_SDL_Joystick_Axis(joystick_fd, 1);
2145 if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
2147 joystick_status = JOYSTICK_OFF;
2152 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
2153 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
2154 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
2155 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
2157 new_joystick_xmiddle =
2158 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
2159 new_joystick_ymiddle =
2160 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
2162 setup.input[player_nr].joy.xleft = new_joystick_xleft;
2163 setup.input[player_nr].joy.yupper = new_joystick_yupper;
2164 setup.input[player_nr].joy.xright = new_joystick_xright;
2165 setup.input[player_nr].joy.ylower = new_joystick_ylower;
2166 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
2167 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
2169 CheckJoystickData();
2172 joy_value = Joystick(player_nr);
2174 if (joy_value & JOY_BUTTON && check_remaining == 0)
2178 #if defined(PLATFORM_MSDOS)
2179 if (calibration_step == 1)
2184 else if (calibrate_joystick(joystick_fd) != 0)
2186 joystick_status = JOYSTICK_OFF;
2190 if (joy[joystick_fd].flags & JOYFLAG_CALIBRATE)
2195 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2196 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2198 if (calibration_step == 2)
2199 DrawText(SX + 16, SY + 9*32," THE UPPER LEFT ", FS_BIG, FC_YELLOW);
2201 DrawText(SX, SY + 9*32," THE LOWER RIGHT ", FS_BIG, FC_YELLOW);
2203 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2204 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2208 while(Joystick(player_nr) & JOY_BUTTON)
2214 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2215 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2217 if (x != last_x || y != last_y)
2219 #if !defined(PLATFORM_MSDOS)
2220 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
2222 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_BLAU);
2224 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
2229 if (check_remaining > 0 && !check[x+1][y+1])
2231 check[x+1][y+1] = TRUE;
2236 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
2237 setup.input[player_nr].joy.xleft,
2238 setup.input[player_nr].joy.xmiddle,
2239 setup.input[player_nr].joy.xright);
2240 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
2241 setup.input[player_nr].joy.yupper,
2242 setup.input[player_nr].joy.ymiddle,
2243 setup.input[player_nr].joy.ylower);
2251 /* don't eat all CPU time */
2257 DrawSetupInputScreen();
2259 /* wait until the last pressed button was released */
2260 while(Joystick(player_nr) & JOY_BUTTON)
2262 if (PendingEvent()) /* got event */
2267 HandleOtherEvents(&event);
2277 DrawText(SX + 16, SY + 6*32, " JOYSTICK NOT ", FS_BIG, FC_YELLOW);
2278 DrawText(SX, SY + 7*32, " AVAILABLE ", FS_BIG, FC_YELLOW);
2281 DrawSetupInputScreen();
2284 void HandleGameActions()
2286 if (game_status != PLAYING)
2289 if (local_player->LevelSolved)
2292 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2300 /* ---------- new screen button stuff -------------------------------------- */
2302 /* graphic position and size values for buttons and scrollbars */
2303 #define SC_SCROLLBUTTON_XPOS 64
2304 #define SC_SCROLLBUTTON_YPOS 0
2305 #define SC_SCROLLBAR_XPOS 0
2306 #define SC_SCROLLBAR_YPOS 64
2308 #define SC_SCROLLBUTTON_XSIZE 32
2309 #define SC_SCROLLBUTTON_YSIZE 32
2311 #define SC_SCROLL_UP_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
2312 #define SC_SCROLL_UP_YPOS SC_SCROLLBUTTON_YSIZE
2313 #define SC_SCROLL_DOWN_XPOS SC_SCROLL_UP_XPOS
2314 #define SC_SCROLL_DOWN_YPOS (SYSIZE - SC_SCROLLBUTTON_YSIZE)
2315 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLL_UP_XPOS
2316 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + SC_SCROLLBUTTON_YSIZE)
2317 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
2318 #define SC_SCROLL_VERTICAL_YSIZE (SYSIZE - 3 * SC_SCROLLBUTTON_YSIZE)
2320 #define SC_BORDER_SIZE 14
2328 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
2331 SC_SCROLLBUTTON_XPOS + 0 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2332 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
2333 SCREEN_CTRL_ID_SCROLL_UP,
2334 "scroll level series up"
2337 SC_SCROLLBUTTON_XPOS + 1 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2338 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
2339 SCREEN_CTRL_ID_SCROLL_DOWN,
2340 "scroll level series down"
2352 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
2355 SC_SCROLLBAR_XPOS, SC_SCROLLBAR_YPOS,
2356 SX + SC_SCROLL_VERTICAL_XPOS, SY + SC_SCROLL_VERTICAL_YPOS,
2357 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
2358 GD_TYPE_SCROLLBAR_VERTICAL,
2359 SCREEN_CTRL_ID_SCROLL_VERTICAL,
2360 "scroll level series vertically"
2364 static void CreateScreenScrollbuttons()
2366 Bitmap *gd_bitmap = pix[PIX_MORE];
2367 struct GadgetInfo *gi;
2368 unsigned long event_mask;
2371 for (i=0; i<NUM_SCREEN_SCROLLBUTTONS; i++)
2373 int id = scrollbutton_info[i].gadget_id;
2374 int x, y, width, height;
2375 int gd_x1, gd_x2, gd_y1, gd_y2;
2377 x = scrollbutton_info[i].x;
2378 y = scrollbutton_info[i].y;
2380 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
2384 width = SC_SCROLLBUTTON_XSIZE;
2385 height = SC_SCROLLBUTTON_YSIZE;
2386 gd_x1 = scrollbutton_info[i].xpos;
2387 gd_y1 = scrollbutton_info[i].ypos;
2389 gd_y2 = gd_y1 + SC_SCROLLBUTTON_YSIZE;
2391 gi = CreateGadget(GDI_CUSTOM_ID, id,
2392 GDI_CUSTOM_TYPE_ID, i,
2393 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
2398 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
2399 GDI_STATE, GD_BUTTON_UNPRESSED,
2400 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2401 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2402 GDI_EVENT_MASK, event_mask,
2403 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2407 Error(ERR_EXIT, "cannot create gadget");
2409 screen_gadget[id] = gi;
2413 static void CreateScreenScrollbars()
2417 for (i=0; i<NUM_SCREEN_SCROLLBARS; i++)
2419 int id = scrollbar_info[i].gadget_id;
2420 Bitmap *gd_bitmap = pix[PIX_MORE];
2421 int gd_x1, gd_x2, gd_y1, gd_y2;
2422 struct GadgetInfo *gi;
2423 int items_max, items_visible, item_position;
2424 unsigned long event_mask;
2425 int num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2428 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2429 num_page_entries = num_leveldirs;
2431 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2433 items_max = MAX(num_leveldirs, num_page_entries);
2434 items_visible = num_page_entries;
2437 items_max = num_page_entries;
2438 items_visible = num_page_entries;
2442 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
2444 gd_x1 = scrollbar_info[i].xpos;
2445 gd_x2 = gd_x1 + scrollbar_info[i].width;
2446 gd_y1 = scrollbar_info[i].ypos;
2447 gd_y2 = scrollbar_info[i].ypos;
2449 gi = CreateGadget(GDI_CUSTOM_ID, id,
2450 GDI_CUSTOM_TYPE_ID, i,
2451 GDI_INFO_TEXT, scrollbar_info[i].infotext,
2452 GDI_X, scrollbar_info[i].x,
2453 GDI_Y, scrollbar_info[i].y,
2454 GDI_WIDTH, scrollbar_info[i].width,
2455 GDI_HEIGHT, scrollbar_info[i].height,
2456 GDI_TYPE, scrollbar_info[i].type,
2457 GDI_SCROLLBAR_ITEMS_MAX, items_max,
2458 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
2459 GDI_SCROLLBAR_ITEM_POSITION, item_position,
2460 GDI_STATE, GD_BUTTON_UNPRESSED,
2461 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2462 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2463 GDI_BORDER_SIZE, SC_BORDER_SIZE,
2464 GDI_EVENT_MASK, event_mask,
2465 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2469 Error(ERR_EXIT, "cannot create gadget");
2471 screen_gadget[id] = gi;
2475 void CreateScreenGadgets()
2477 CreateScreenScrollbuttons();
2478 CreateScreenScrollbars();
2481 void MapChooseLevelGadgets()
2483 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
2486 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2489 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2490 MapGadget(screen_gadget[i]);
2493 void UnmapChooseLevelGadgets()
2497 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2498 UnmapGadget(screen_gadget[i]);
2501 static void HandleScreenGadgets(struct GadgetInfo *gi)
2503 int id = gi->custom_id;
2505 if (game_status != CHOOSELEVEL)
2510 case SCREEN_CTRL_ID_SCROLL_UP:
2511 HandleChooseLevel(SX,SY + 32, 0,0, MB_MENU_MARK);
2514 case SCREEN_CTRL_ID_SCROLL_DOWN:
2515 HandleChooseLevel(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK);
2518 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
2519 HandleChooseLevel(0,0, 999,gi->event.item_position, MB_MENU_INITIALIZE);