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");
704 PlaySoundLoop(background_loop[num]);
708 void DrawHelpScreenCreditsText()
710 int ystart = 150, ystep = 30;
711 int ybottom = SYSIZE - 20;
717 DrawTextFCentered(100, FC_GREEN,
719 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
720 "DOS port of the game:");
721 DrawTextFCentered(ystart + 1 * ystep, FC_RED,
723 DrawTextFCentered(ystart + 2 * ystep, FC_YELLOW,
724 "Additional toons:");
725 DrawTextFCentered(ystart + 3 * ystep, FC_RED,
727 DrawTextFCentered(ystart + 5 * ystep, FC_YELLOW,
728 "...and many thanks to all contributors");
729 DrawTextFCentered(ystart + 6 * ystep, FC_YELLOW,
732 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page");
735 void DrawHelpScreenContactText()
737 int ystart = 150, ystep = 30;
738 int ybottom = SYSIZE - 20;
743 DrawTextFCentered(100, FC_GREEN, "Program information:");
745 DrawTextFCentered(ystart + 0 * ystep, FC_YELLOW,
746 "This game is Freeware!");
747 DrawTextFCentered(ystart + 1 * ystep, FC_YELLOW,
748 "If you like it, send e-mail to:");
749 DrawTextFCentered(ystart + 2 * ystep, FC_RED,
751 DrawTextFCentered(ystart + 3 * ystep, FC_YELLOW,
753 DrawTextFCentered(ystart + 4 * ystep + 0, FC_RED,
755 DrawTextFCentered(ystart + 4 * ystep + 20, FC_RED,
756 "Detmolder Strasse 189");
757 DrawTextFCentered(ystart + 4 * ystep + 40, FC_RED,
759 DrawTextFCentered(ystart + 4 * ystep + 60, FC_RED,
762 DrawTextFCentered(ystart + 7 * ystep, FC_YELLOW,
763 "If you have created new levels,");
764 DrawTextFCentered(ystart + 8 * ystep, FC_YELLOW,
765 "send them to me to include them!");
766 DrawTextFCentered(ystart + 9 * ystep, FC_YELLOW,
769 DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for main menu");
772 void DrawHelpScreen()
777 CloseDoor(DOOR_CLOSE_2);
779 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
780 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
781 helpscreen_musicpos = 0;
782 helpscreen_state = 0;
783 DrawHelpScreenElText(0);
784 DrawHelpScreenElAction(0);
788 PlaySoundLoop(SND_RHYTHMLOOP);
791 void HandleHelpScreen(int button)
793 static unsigned long hs_delay = 0;
794 int num_helpscreen_els_pages =
795 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
796 int button_released = !button;
801 if (helpscreen_state < num_helpscreen_els_pages - 1)
803 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
804 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
806 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
807 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
809 else if (helpscreen_state <
810 num_helpscreen_els_pages + num_helpscreen_music - 1)
813 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
815 else if (helpscreen_state ==
816 num_helpscreen_els_pages + num_helpscreen_music - 1)
819 DrawHelpScreenCreditsText();
821 else if (helpscreen_state ==
822 num_helpscreen_els_pages + num_helpscreen_music)
825 DrawHelpScreenContactText();
831 game_status = MAINMENU;
836 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
838 if (helpscreen_state<num_helpscreen_els_pages)
839 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
847 void HandleTypeName(int newxpos, Key key)
849 static int xpos = 0, ypos = 2;
854 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_YELLOW);
855 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
859 if (((key >= KSYM_A && key <= KSYM_Z) ||
860 (key >= KSYM_a && key <= KSYM_z)) &&
861 xpos < MAX_PLAYER_NAME_LEN)
865 if (key >= KSYM_A && key <= KSYM_Z)
866 ascii = 'A' + (char)(key - KSYM_A);
868 ascii = 'a' + (char)(key - KSYM_a);
870 setup.player_name[xpos] = ascii;
871 setup.player_name[xpos + 1] = 0;
873 DrawTextExt(drawto, SX + 6*32, SY + ypos*32,
874 setup.player_name, FS_BIG, FC_YELLOW);
875 DrawTextExt(window, SX + 6*32, SY + ypos*32,
876 setup.player_name, FS_BIG, FC_YELLOW);
877 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
879 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
882 setup.player_name[xpos] = 0;
883 DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
884 DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM);
886 else if (key == KSYM_Return && xpos > 0)
888 DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
889 DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM);
892 game_status = MAINMENU;
898 static void drawCursorExt(int ypos, int color, int graphic)
900 static int cursor_array[SCR_FIELDY];
903 cursor_array[ypos] = graphic;
905 graphic = cursor_array[ypos];
908 graphic = (graphic == GFX_ARROW_BLUE_LEFT ? GFX_ARROW_RED_LEFT :
909 graphic == GFX_ARROW_BLUE_RIGHT ? GFX_ARROW_RED_RIGHT :
912 DrawGraphic(0, ypos, graphic);
915 static void initCursor(int ypos, int graphic)
917 drawCursorExt(ypos, FC_BLUE, graphic);
920 static void drawCursor(int ypos, int color)
922 drawCursorExt(ypos, color, 0);
925 void DrawChooseLevel()
928 CloseDoor(DOOR_CLOSE_2);
931 HandleChooseLevel(0,0, 0,0, MB_MENU_INITIALIZE);
932 MapChooseLevelGadgets();
938 static void AdjustChooseLevelScrollbar(int id, int first_entry)
940 struct GadgetInfo *gi = screen_gadget[id];
941 int items_max, items_visible, item_position;
943 items_max = numLevelDirInfoInGroup(leveldir_current);
944 items_visible = MAX_LEVEL_SERIES_ON_SCREEN - 1;
945 item_position = first_entry;
947 if (item_position > items_max - items_visible)
948 item_position = items_max - items_visible;
950 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
951 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
954 static void drawChooseLevelList(int first_entry, int num_page_entries)
957 char buffer[SCR_FIELDX * 2];
958 int max_buffer_len = (SCR_FIELDX - 2) * 2;
959 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
961 ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE);
962 redraw_mask |= REDRAW_FIELD;
964 DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN);
966 for(i=0; i<num_page_entries; i++)
968 struct LevelDirInfo *node, *node_first;
969 int leveldir_pos = first_entry + i;
972 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
973 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
975 strncpy(buffer, node->name , max_buffer_len);
976 buffer[max_buffer_len] = '\0';
978 DrawText(SX + 32, SY + ypos * 32, buffer, FS_MEDIUM, node->color);
980 if (node->parent_link)
981 initCursor(ypos, GFX_ARROW_BLUE_LEFT);
982 else if (node->level_group)
983 initCursor(ypos, GFX_ARROW_BLUE_RIGHT);
985 initCursor(ypos, GFX_KUGEL_BLAU);
989 DrawGraphic(0, 1, GFX_ARROW_BLUE_UP);
991 if (first_entry + num_page_entries < num_leveldirs)
992 DrawGraphic(0, MAX_LEVEL_SERIES_ON_SCREEN + 1, GFX_ARROW_BLUE_DOWN);
995 static void drawChooseLevelInfo(int leveldir_pos)
997 struct LevelDirInfo *node, *node_first;
998 int x, last_redraw_mask = redraw_mask;
1000 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1001 node = getLevelDirInfoFromPos(node_first, leveldir_pos);
1003 ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32);
1005 if (node->parent_link)
1006 DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc);
1007 else if (node->level_group)
1008 DrawTextFCentered(40, FC_RED, "enter group \"%s\"", node->class_desc);
1010 DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
1011 node->levels, node->class_desc);
1013 /* let BackToFront() redraw only what is needed */
1014 redraw_mask = last_redraw_mask | REDRAW_TILES;
1015 for (x=0; x<SCR_FIELDX; x++)
1016 MarkTileDirty(x, 1);
1019 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
1021 static unsigned long choose_delay = 0;
1022 static int redraw = TRUE;
1023 int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
1024 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1025 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
1026 int num_page_entries;
1028 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
1029 num_page_entries = num_leveldirs;
1031 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
1033 if (button == MB_MENU_INITIALIZE)
1035 int leveldir_pos = posLevelDirInfo(leveldir_current);
1037 if (leveldir_current->cl_first == -1)
1039 leveldir_current->cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
1040 leveldir_current->cl_cursor =
1041 leveldir_pos - leveldir_current->cl_first + 3;
1044 if (dx == 999) /* first entry is set by scrollbar position */
1045 leveldir_current->cl_first = dy;
1047 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1048 leveldir_current->cl_first);
1050 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1051 drawChooseLevelInfo(leveldir_pos);
1057 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1061 if (button == MB_MENU_INITIALIZE)
1069 y = leveldir_current->cl_cursor + dy;
1072 x = y = 0; /* no action */
1074 if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
1077 step = num_page_entries - 1;
1079 y = (dy < 0 ? 2 : num_page_entries + 3);
1083 if (x == 1 && y == 2)
1085 if (leveldir_current->cl_first > 0 &&
1086 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1088 leveldir_current->cl_first -= step;
1089 if (leveldir_current->cl_first < 0)
1090 leveldir_current->cl_first = 0;
1092 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1093 drawChooseLevelInfo(leveldir_current->cl_first +
1094 leveldir_current->cl_cursor - 3);
1095 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1096 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1097 leveldir_current->cl_first);
1101 else if (x == 1 && y > num_page_entries + 2)
1103 if (leveldir_current->cl_first + num_page_entries < num_leveldirs &&
1104 (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
1106 leveldir_current->cl_first += step;
1107 if (leveldir_current->cl_first + num_page_entries > num_leveldirs)
1108 leveldir_current->cl_first = MAX(0, num_leveldirs - num_page_entries);
1110 drawChooseLevelList(leveldir_current->cl_first, num_page_entries);
1111 drawChooseLevelInfo(leveldir_current->cl_first +
1112 leveldir_current->cl_cursor - 3);
1113 drawCursor(leveldir_current->cl_cursor - 1, FC_RED);
1114 AdjustChooseLevelScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1115 leveldir_current->cl_first);
1120 if (!mx && !my && !dx && !dy)
1123 y = leveldir_current->cl_cursor;
1128 struct LevelDirInfo *node_first, *node_cursor;
1130 leveldir_current->cl_first + leveldir_current->cl_cursor - 3;
1132 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1133 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1135 if (node_cursor->node_group)
1137 node_cursor->cl_first = leveldir_current->cl_first;
1138 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1139 leveldir_current = node_cursor->node_group;
1143 else if (dx == -1 && leveldir_current->node_parent)
1145 leveldir_current = leveldir_current->node_parent;
1149 if (x == 1 && y >= 3 && y <= num_page_entries + 2)
1153 if (y != leveldir_current->cl_cursor)
1155 drawCursor(y - 1, FC_RED);
1156 drawCursor(leveldir_current->cl_cursor - 1, FC_BLUE);
1157 drawChooseLevelInfo(leveldir_current->cl_first + y - 3);
1158 leveldir_current->cl_cursor = y;
1163 struct LevelDirInfo *node_first, *node_cursor;
1164 int leveldir_pos = leveldir_current->cl_first + y - 3;
1166 node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
1167 node_cursor = getLevelDirInfoFromPos(node_first, leveldir_pos);
1169 if (node_cursor->node_group)
1171 node_cursor->cl_first = leveldir_current->cl_first;
1172 node_cursor->cl_cursor = leveldir_current->cl_cursor;
1173 leveldir_current = node_cursor->node_group;
1176 else if (node_cursor->parent_link)
1178 leveldir_current = node_cursor->node_parent;
1183 leveldir_current = node_cursor;
1185 LoadLevelSetup_SeriesInfo();
1187 SaveLevelSetup_LastSeries();
1188 SaveLevelSetup_SeriesInfo();
1191 game_status = MAINMENU;
1199 if (game_status == CHOOSELEVEL)
1203 void DrawHallOfFame(int highlight_position)
1206 CloseDoor(DOOR_CLOSE_2);
1208 if (highlight_position < 0)
1209 LoadScore(level_nr);
1213 HandleHallOfFame(highlight_position,0, 0,0, MB_MENU_INITIALIZE);
1214 PlaySound(SND_HALLOFFAME);
1217 static void drawHallOfFameList(int first_entry, int highlight_position)
1222 DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
1223 DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
1225 for(i=0; i<MAX_LEVEL_SERIES_ON_SCREEN; i++)
1227 int entry = first_entry + i;
1228 int color = (entry == highlight_position ? FC_RED : FC_GREEN);
1231 DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG, color);
1232 DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG, color);
1233 DrawText(SX + 12 * 32, SY + 64 + i * 32,
1234 int2str(highscore[i].Score, 5), FS_BIG, color);
1236 DrawText(SX, SY + 64 + i * 32, "..................................",
1237 FS_MEDIUM, FC_YELLOW);
1238 DrawText(SX, SY + 64 + i * 32, int2str(entry + 1, 3),
1239 FS_MEDIUM, FC_YELLOW);
1240 DrawText(SX + 64, SY + 64 + i * 32, highscore[entry].Name, FS_BIG, color);
1241 DrawText(SX + 14 * 32 + 16, SY + 64 + i * 32,
1242 int2str(highscore[entry].Score, 5), FS_MEDIUM, color);
1247 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
1249 static int first_entry = 0;
1250 static int highlight_position = 0;
1251 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1252 int button_released = !button;
1254 if (button == MB_MENU_INITIALIZE)
1257 highlight_position = mx;
1258 drawHallOfFameList(first_entry, highlight_position);
1262 if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
1263 step = MAX_LEVEL_SERIES_ON_SCREEN - 1;
1267 if (first_entry > 0)
1269 first_entry -= step;
1270 if (first_entry < 0)
1273 drawHallOfFameList(first_entry, highlight_position);
1279 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN < MAX_SCORE_ENTRIES)
1281 first_entry += step;
1282 if (first_entry + MAX_LEVEL_SERIES_ON_SCREEN > MAX_SCORE_ENTRIES)
1283 first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_LEVEL_SERIES_ON_SCREEN);
1285 drawHallOfFameList(first_entry, highlight_position);
1290 if (button_released)
1292 FadeSound(SND_HALLOFFAME);
1293 game_status = MAINMENU;
1299 if (game_status == HALLOFFAME)
1303 void DrawSetupScreen()
1312 { &setup.sound, "Sound:", },
1313 { &setup.sound_loops, " Sound Loops:" },
1314 { &setup.sound_music, " Game Music:" },
1316 { &setup.toons, "Toons:" },
1317 { &setup.double_buffering, "Buffered gfx:" },
1319 { &setup.scroll_delay, "Scroll Delay:" },
1320 { &setup.soft_scrolling, "Soft Scroll.:" },
1322 { &setup.fading, "Fading:" },
1324 { &setup.fullscreen, "Fullscreen:" },
1325 { &setup.quick_doors, "Quick Doors:" },
1326 { &setup.autorecord, "Auto-Record:" },
1327 { &setup.team_mode, "Team-Mode:" },
1328 { &setup.handicap, "Handicap:" },
1329 { &setup.time_limit, "Timelimit:" },
1330 { NULL, "Input Devices" },
1333 { NULL, "Save and exit" }
1337 CloseDoor(DOOR_CLOSE_2);
1340 DrawText(SX + 16, SY + 16, "SETUP",FS_BIG,FC_YELLOW);
1342 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
1344 int base = i - SETUP_SCREEN_POS_START;
1346 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
1348 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
1350 if (strcmp(setup_info[base].text, "Input Devices") == 0)
1351 initCursor(i, GFX_ARROW_BLUE_RIGHT);
1353 initCursor(i, GFX_KUGEL_BLAU);
1356 if (setup_info[base].value)
1358 int setting_value = *setup_info[base].value;
1360 DrawText(SX+14*32, SY+i*32, (setting_value ? "on" : "off"),
1361 FS_BIG, (setting_value ? FC_YELLOW : FC_BLUE));
1367 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
1370 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
1372 static int choice = 3;
1373 static int redraw = TRUE;
1374 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1375 int pos_start = SETUP_SCREEN_POS_START + 1;
1376 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
1377 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
1378 int pos_end = SETUP_SCREEN_POS_END + 1;
1380 if (button == MB_MENU_INITIALIZE)
1385 drawCursor(choice - 1, FC_RED);
1389 if (button == MB_MENU_INITIALIZE)
1402 if (y >= pos_empty1 && y <= pos_empty2)
1403 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1407 else if (y > pos_end)
1411 if (!mx && !my && !dx && !dy)
1417 if (dx == 1 && choice == 14)
1419 game_status = SETUPINPUT;
1420 DrawSetupInputScreen();
1424 if (x==1 && y >= pos_start && y <= pos_end &&
1425 !(y >= pos_empty1 && y <= pos_empty2))
1431 drawCursor(y - 1, FC_RED);
1432 drawCursor(choice - 1, FC_BLUE);
1440 if (y == 3 && audio.sound_available)
1444 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1445 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1446 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1447 setup.sound_loops = FALSE;
1448 setup.sound_music = FALSE;
1451 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1452 setup.sound = !setup.sound;
1454 else if (y == 4 && audio.loops_available)
1456 if (setup.sound_loops)
1457 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1460 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1461 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1464 setup.sound_loops = !setup.sound_loops;
1466 else if (y == 5 && audio.loops_available)
1468 if (setup.sound_music)
1469 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1472 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1473 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1476 setup.sound_music = !setup.sound_music;
1483 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1485 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1486 setup.toons = !setup.toons;
1491 if (setup.double_buffering)
1492 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1494 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1495 setup.double_buffering = !setup.double_buffering;
1496 setup.direct_draw = !setup.double_buffering;
1498 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1499 setup.double_buffering = TRUE;
1500 setup.direct_draw = !setup.double_buffering;
1507 if (setup.scroll_delay)
1508 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1510 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1511 setup.scroll_delay = !setup.scroll_delay;
1515 if (setup.soft_scrolling)
1516 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1518 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1519 setup.soft_scrolling = !setup.soft_scrolling;
1525 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1527 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1528 setup.fading = !setup.fading;
1531 else if (y == 8 && video.fullscreen_available)
1533 if (setup.fullscreen)
1534 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1536 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1537 setup.fullscreen = !setup.fullscreen;
1541 if (setup.quick_doors)
1542 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1544 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1545 setup.quick_doors = !setup.quick_doors;
1549 if (setup.autorecord)
1550 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1552 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1553 setup.autorecord = !setup.autorecord;
1557 if (setup.team_mode)
1558 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1560 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1561 setup.team_mode = !setup.team_mode;
1566 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1568 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1569 setup.handicap = !setup.handicap;
1573 if (setup.time_limit)
1574 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1576 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1577 setup.time_limit = !setup.time_limit;
1581 game_status = SETUPINPUT;
1582 DrawSetupInputScreen();
1585 else if (y==pos_end-1 || y==pos_end)
1595 #if defined(PLATFORM_MSDOS)
1596 save_joystick_data(JOYSTICK_FILENAME);
1602 game_status = MAINMENU;
1610 if (game_status==SETUP)
1614 void DrawSetupInputScreen()
1617 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1619 initCursor(2, GFX_KUGEL_BLAU);
1620 initCursor(3, GFX_KUGEL_BLAU);
1621 initCursor(4, GFX_ARROW_BLUE_RIGHT);
1622 initCursor(15, GFX_KUGEL_BLAU);
1624 DrawGraphic(10, 2, GFX_ARROW_BLUE_LEFT);
1625 DrawGraphic(12, 2, GFX_ARROW_BLUE_RIGHT);
1627 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1628 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1629 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1631 DrawTextFCentered(SYSIZE - 20, FC_BLUE,
1632 "Joysticks deactivated on this screen");
1634 HandleSetupInputScreen(0,0, 0,0, MB_MENU_INITIALIZE);
1639 static void setJoystickDeviceToNr(char *device_name, int device_nr)
1641 if (device_name == NULL)
1644 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
1647 if (strlen(device_name) > 1)
1649 char c1 = device_name[strlen(device_name) - 1];
1650 char c2 = device_name[strlen(device_name) - 2];
1652 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
1653 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
1656 strncpy(device_name, joystick_device_name[device_nr], strlen(device_name));
1659 static void drawPlayerSetupInputInfo(int player_nr)
1662 static struct SetupKeyboardInfo custom_key;
1669 { &custom_key.left, "Joystick Left" },
1670 { &custom_key.right, "Joystick Right" },
1671 { &custom_key.up, "Joystick Up" },
1672 { &custom_key.down, "Joystick Down" },
1673 { &custom_key.snap, "Button 1" },
1674 { &custom_key.bomb, "Button 2" }
1676 static char *joystick_name[MAX_PLAYERS] =
1684 custom_key = setup.input[player_nr].key;
1686 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1687 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1689 if (setup.input[player_nr].use_joystick)
1691 char *device_name = setup.input[player_nr].joy.device_name;
1693 DrawText(SX+8*32, SY+3*32,
1694 joystick_name[getJoystickNrFromDeviceName(device_name)],
1696 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1700 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1701 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1704 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1705 DrawGraphic(1, 6, GFX_ARROW_BLUE_LEFT);
1706 DrawGraphic(1, 7, GFX_ARROW_BLUE_RIGHT);
1707 DrawGraphic(1, 8, GFX_ARROW_BLUE_UP);
1708 DrawGraphic(1, 9, GFX_ARROW_BLUE_DOWN);
1709 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1710 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1711 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1712 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1713 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1714 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1718 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1720 DrawText(SX + 3*32, SY + ypos*32,
1721 " ", FS_BIG, FC_YELLOW);
1722 DrawText(SX + 3*32, SY + ypos*32,
1723 (setup.input[player_nr].use_joystick ?
1725 getKeyNameFromKey(*custom[i].key)),
1730 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1732 static int choice = 3;
1733 static int player_nr = 0;
1734 static int redraw = TRUE;
1735 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1736 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1737 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1738 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1739 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1741 if (button == MB_MENU_INITIALIZE)
1743 drawPlayerSetupInputInfo(player_nr);
1749 drawCursor(choice - 1, FC_RED);
1753 if (button == MB_MENU_INITIALIZE)
1758 if (dx && choice == 3)
1760 x = (dx < 0 ? 11 : 13);
1763 else if (dx && choice == 4)
1765 button = MB_MENU_CHOICE;
1777 if (y >= pos_empty1 && y <= pos_empty2)
1778 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1782 else if (y > pos_end)
1786 if (!mx && !my && !dx && !dy)
1792 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1794 static unsigned long delay = 0;
1796 if (!DelayReached(&delay, GADGET_FRAME_DELAY))
1799 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1801 drawPlayerSetupInputInfo(player_nr);
1803 else if (x==1 && y >= pos_start && y <= pos_end &&
1804 !(y >= pos_empty1 && y <= pos_empty2))
1810 drawCursor(y - 1, FC_RED);
1811 drawCursor(choice - 1, FC_BLUE);
1819 char *device_name = setup.input[player_nr].joy.device_name;
1821 if (!setup.input[player_nr].use_joystick)
1823 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
1825 setJoystickDeviceToNr(device_name, new_device_nr);
1826 setup.input[player_nr].use_joystick = TRUE;
1830 int device_nr = getJoystickNrFromDeviceName(device_name);
1831 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
1833 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
1834 setup.input[player_nr].use_joystick = FALSE;
1836 setJoystickDeviceToNr(device_name, new_device_nr);
1846 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1847 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1849 if (setup.input[player_nr].use_joystick)
1851 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1852 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1854 setup.input[player_nr].use_joystick = FALSE;
1858 setup.input[player_nr].use_joystick = TRUE;
1859 setup.input[player_nr].joystick_nr = one_joystick_nr;
1863 drawPlayerSetupInputInfo(player_nr);
1867 if (setup.input[player_nr].use_joystick)
1870 game_status = CALIBRATION;
1871 CalibrateJoystick(player_nr);
1872 game_status = SETUPINPUT;
1875 CustomizeKeyboard(player_nr);
1879 else if (y == pos_end)
1883 game_status = SETUP;
1893 if (game_status == SETUPINPUT)
1897 void CustomizeKeyboard(int player_nr)
1901 boolean finished = FALSE;
1902 static struct SetupKeyboardInfo custom_key;
1907 } customize_step[] =
1909 { &custom_key.left, "Move Left" },
1910 { &custom_key.right, "Move Right" },
1911 { &custom_key.up, "Move Up" },
1912 { &custom_key.down, "Move Down" },
1913 { &custom_key.snap, "Snap Field" },
1914 { &custom_key.bomb, "Place Bomb" }
1917 /* read existing key bindings from player setup */
1918 custom_key = setup.input[player_nr].key;
1921 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1927 DrawText(SX, SY + (2+2*step_nr)*32,
1928 customize_step[step_nr].text, FS_BIG, FC_RED);
1929 DrawText(SX, SY + (2+2*step_nr+1)*32,
1930 "Key:", FS_BIG, FC_RED);
1931 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1932 getKeyNameFromKey(*customize_step[step_nr].key),
1937 if (PendingEvent()) /* got event */
1945 case EVENT_KEYPRESS:
1947 Key key = GetEventKey((KeyEvent *)&event, TRUE);
1949 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
1955 /* all keys configured -- wait for "Escape" or "Return" key */
1959 /* press 'Enter' to keep the existing key binding */
1960 if (key == KSYM_Return)
1961 key = *customize_step[step_nr].key;
1963 /* check if key already used */
1964 for (i=0; i<step_nr; i++)
1965 if (*customize_step[i].key == key)
1970 /* got new key binding */
1971 *customize_step[step_nr].key = key;
1972 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1973 " ", FS_BIG, FC_YELLOW);
1974 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1975 getKeyNameFromKey(key), FS_BIG, FC_YELLOW);
1978 /* un-highlight last query */
1979 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1980 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1981 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1982 "Key:", FS_BIG, FC_GREEN);
1984 /* press 'Enter' to leave */
1987 DrawText(SX + 16, SY + 15*32+16,
1988 "Press Enter", FS_BIG, FC_YELLOW);
1992 /* query next key binding */
1993 DrawText(SX, SY+(2+2*step_nr)*32,
1994 customize_step[step_nr].text, FS_BIG, FC_RED);
1995 DrawText(SX, SY+(2+2*step_nr+1)*32,
1996 "Key:", FS_BIG, FC_RED);
1997 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1998 getKeyNameFromKey(*customize_step[step_nr].key),
2003 case EVENT_KEYRELEASE:
2004 key_joystick_mapping = 0;
2008 HandleOtherEvents(&event);
2016 /* don't eat all CPU time */
2020 /* write new key bindings back to player setup */
2021 setup.input[player_nr].key = custom_key;
2024 DrawSetupInputScreen();
2027 void CalibrateJoystick(int player_nr)
2030 struct joystick joy_ctrl;
2032 struct joystick_control
2040 #if !defined(PLATFORM_MSDOS)
2041 int new_joystick_xleft = 128, new_joystick_xright = 128;
2042 int new_joystick_yupper = 128, new_joystick_ylower = 128;
2043 int new_joystick_xmiddle, new_joystick_ymiddle;
2045 int calibration_step = 1;
2048 int joystick_fd = stored_player[player_nr].joystick_fd;
2049 int x, y, last_x, last_y, xpos = 8, ypos = 3;
2050 boolean check[3][3];
2051 int check_remaining;
2055 if (joystick_status == JOYSTICK_OFF ||
2057 !setup.input[player_nr].use_joystick)
2062 #if !defined(PLATFORM_MSDOS)
2063 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ", FS_BIG, FC_YELLOW);
2064 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS", FS_BIG, FC_YELLOW);
2065 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ", FS_BIG, FC_YELLOW);
2066 DrawText(SX, SY + 10*32, " ARE YELLOW, ", FS_BIG, FC_YELLOW);
2067 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2068 check_remaining = 3 * 3;
2070 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2071 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2072 DrawText(SX, SY + 9*32, " CENTER POSITION ", FS_BIG, FC_YELLOW);
2073 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2074 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2075 check_remaining = 0;
2082 check[x][y] = FALSE;
2083 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
2087 joy_value = Joystick(player_nr);
2088 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2089 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2090 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
2095 joy_ctrl.b1 = joy_ctrl.b2 = 0;
2097 joy_ctrl.buttons = 0;
2100 while(Joystick(player_nr) & JOY_BUTTON);
2106 if (PendingEvent()) /* got event */
2114 case EVENT_KEYPRESS:
2115 switch(GetEventKey((KeyEvent *)&event, TRUE))
2118 if (check_remaining == 0)
2131 case EVENT_KEYRELEASE:
2132 key_joystick_mapping = 0;
2136 HandleOtherEvents(&event);
2141 #if !defined(PLATFORM_MSDOS)
2143 #if defined(TARGET_SDL)
2144 joy_ctrl.x = Get_SDL_Joystick_Axis(joystick_fd, 0);
2145 joy_ctrl.y = Get_SDL_Joystick_Axis(joystick_fd, 1);
2147 if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
2149 joystick_status = JOYSTICK_OFF;
2154 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
2155 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
2156 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
2157 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
2159 new_joystick_xmiddle =
2160 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
2161 new_joystick_ymiddle =
2162 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
2164 setup.input[player_nr].joy.xleft = new_joystick_xleft;
2165 setup.input[player_nr].joy.yupper = new_joystick_yupper;
2166 setup.input[player_nr].joy.xright = new_joystick_xright;
2167 setup.input[player_nr].joy.ylower = new_joystick_ylower;
2168 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
2169 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
2171 CheckJoystickData();
2174 joy_value = Joystick(player_nr);
2176 if (joy_value & JOY_BUTTON && check_remaining == 0)
2180 #if defined(PLATFORM_MSDOS)
2181 if (calibration_step == 1)
2186 else if (calibrate_joystick(joystick_fd) != 0)
2188 joystick_status = JOYSTICK_OFF;
2192 if (joy[joystick_fd].flags & JOYFLAG_CALIBRATE)
2197 DrawText(SX, SY + 7*32, " MOVE JOYSTICK ", FS_BIG, FC_YELLOW);
2198 DrawText(SX + 16, SY + 8*32, " TO ", FS_BIG, FC_YELLOW);
2200 if (calibration_step == 2)
2201 DrawText(SX + 16, SY + 9*32," THE UPPER LEFT ", FS_BIG, FC_YELLOW);
2203 DrawText(SX, SY + 9*32," THE LOWER RIGHT ", FS_BIG, FC_YELLOW);
2205 DrawText(SX, SY + 10*32, " AND ", FS_BIG, FC_YELLOW);
2206 DrawText(SX, SY + 11*32, "PRESS ANY BUTTON!", FS_BIG, FC_YELLOW);
2210 while(Joystick(player_nr) & JOY_BUTTON)
2216 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2217 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2219 if (x != last_x || y != last_y)
2221 #if !defined(PLATFORM_MSDOS)
2222 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
2224 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_BLAU);
2226 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
2231 if (check_remaining > 0 && !check[x+1][y+1])
2233 check[x+1][y+1] = TRUE;
2238 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
2239 setup.input[player_nr].joy.xleft,
2240 setup.input[player_nr].joy.xmiddle,
2241 setup.input[player_nr].joy.xright);
2242 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
2243 setup.input[player_nr].joy.yupper,
2244 setup.input[player_nr].joy.ymiddle,
2245 setup.input[player_nr].joy.ylower);
2253 /* don't eat all CPU time */
2259 DrawSetupInputScreen();
2261 /* wait until the last pressed button was released */
2262 while(Joystick(player_nr) & JOY_BUTTON)
2264 if (PendingEvent()) /* got event */
2269 HandleOtherEvents(&event);
2279 DrawText(SX + 16, SY + 6*32, " JOYSTICK NOT ", FS_BIG, FC_YELLOW);
2280 DrawText(SX, SY + 7*32, " AVAILABLE ", FS_BIG, FC_YELLOW);
2283 DrawSetupInputScreen();
2286 void HandleGameActions()
2288 if (game_status != PLAYING)
2291 if (local_player->LevelSolved)
2294 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2302 /* ---------- new screen button stuff -------------------------------------- */
2304 /* graphic position and size values for buttons and scrollbars */
2305 #define SC_SCROLLBUTTON_XPOS 64
2306 #define SC_SCROLLBUTTON_YPOS 0
2307 #define SC_SCROLLBAR_XPOS 0
2308 #define SC_SCROLLBAR_YPOS 64
2310 #define SC_SCROLLBUTTON_XSIZE 32
2311 #define SC_SCROLLBUTTON_YSIZE 32
2313 #define SC_SCROLL_UP_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
2314 #define SC_SCROLL_UP_YPOS SC_SCROLLBUTTON_YSIZE
2315 #define SC_SCROLL_DOWN_XPOS SC_SCROLL_UP_XPOS
2316 #define SC_SCROLL_DOWN_YPOS (SYSIZE - SC_SCROLLBUTTON_YSIZE)
2317 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLL_UP_XPOS
2318 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + SC_SCROLLBUTTON_YSIZE)
2319 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
2320 #define SC_SCROLL_VERTICAL_YSIZE (SYSIZE - 3 * SC_SCROLLBUTTON_YSIZE)
2322 #define SC_BORDER_SIZE 14
2330 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
2333 SC_SCROLLBUTTON_XPOS + 0 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2334 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
2335 SCREEN_CTRL_ID_SCROLL_UP,
2336 "scroll level series up"
2339 SC_SCROLLBUTTON_XPOS + 1 * SC_SCROLLBUTTON_XSIZE, SC_SCROLLBUTTON_YPOS,
2340 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
2341 SCREEN_CTRL_ID_SCROLL_DOWN,
2342 "scroll level series down"
2354 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
2357 SC_SCROLLBAR_XPOS, SC_SCROLLBAR_YPOS,
2358 SX + SC_SCROLL_VERTICAL_XPOS, SY + SC_SCROLL_VERTICAL_YPOS,
2359 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
2360 GD_TYPE_SCROLLBAR_VERTICAL,
2361 SCREEN_CTRL_ID_SCROLL_VERTICAL,
2362 "scroll level series vertically"
2366 static void CreateScreenScrollbuttons()
2368 Bitmap *gd_bitmap = pix[PIX_MORE];
2369 struct GadgetInfo *gi;
2370 unsigned long event_mask;
2373 for (i=0; i<NUM_SCREEN_SCROLLBUTTONS; i++)
2375 int id = scrollbutton_info[i].gadget_id;
2376 int x, y, width, height;
2377 int gd_x1, gd_x2, gd_y1, gd_y2;
2379 x = scrollbutton_info[i].x;
2380 y = scrollbutton_info[i].y;
2382 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
2386 width = SC_SCROLLBUTTON_XSIZE;
2387 height = SC_SCROLLBUTTON_YSIZE;
2388 gd_x1 = scrollbutton_info[i].xpos;
2389 gd_y1 = scrollbutton_info[i].ypos;
2391 gd_y2 = gd_y1 + SC_SCROLLBUTTON_YSIZE;
2393 gi = CreateGadget(GDI_CUSTOM_ID, id,
2394 GDI_CUSTOM_TYPE_ID, i,
2395 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
2400 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
2401 GDI_STATE, GD_BUTTON_UNPRESSED,
2402 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2403 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2404 GDI_EVENT_MASK, event_mask,
2405 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2409 Error(ERR_EXIT, "cannot create gadget");
2411 screen_gadget[id] = gi;
2415 static void CreateScreenScrollbars()
2419 for (i=0; i<NUM_SCREEN_SCROLLBARS; i++)
2421 int id = scrollbar_info[i].gadget_id;
2422 Bitmap *gd_bitmap = pix[PIX_MORE];
2423 int gd_x1, gd_x2, gd_y1, gd_y2;
2424 struct GadgetInfo *gi;
2425 int items_max, items_visible, item_position;
2426 unsigned long event_mask;
2427 int num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2430 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2431 num_page_entries = num_leveldirs;
2433 num_page_entries = MAX_LEVEL_SERIES_ON_SCREEN - 1;
2435 items_max = MAX(num_leveldirs, num_page_entries);
2436 items_visible = num_page_entries;
2439 items_max = num_page_entries;
2440 items_visible = num_page_entries;
2444 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
2446 gd_x1 = scrollbar_info[i].xpos;
2447 gd_x2 = gd_x1 + scrollbar_info[i].width;
2448 gd_y1 = scrollbar_info[i].ypos;
2449 gd_y2 = scrollbar_info[i].ypos;
2451 gi = CreateGadget(GDI_CUSTOM_ID, id,
2452 GDI_CUSTOM_TYPE_ID, i,
2453 GDI_INFO_TEXT, scrollbar_info[i].infotext,
2454 GDI_X, scrollbar_info[i].x,
2455 GDI_Y, scrollbar_info[i].y,
2456 GDI_WIDTH, scrollbar_info[i].width,
2457 GDI_HEIGHT, scrollbar_info[i].height,
2458 GDI_TYPE, scrollbar_info[i].type,
2459 GDI_SCROLLBAR_ITEMS_MAX, items_max,
2460 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
2461 GDI_SCROLLBAR_ITEM_POSITION, item_position,
2462 GDI_STATE, GD_BUTTON_UNPRESSED,
2463 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
2464 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
2465 GDI_BORDER_SIZE, SC_BORDER_SIZE,
2466 GDI_EVENT_MASK, event_mask,
2467 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2471 Error(ERR_EXIT, "cannot create gadget");
2473 screen_gadget[id] = gi;
2477 void CreateScreenGadgets()
2479 CreateScreenScrollbuttons();
2480 CreateScreenScrollbars();
2483 void MapChooseLevelGadgets()
2485 int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
2488 if (num_leveldirs <= MAX_LEVEL_SERIES_ON_SCREEN)
2491 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2492 MapGadget(screen_gadget[i]);
2495 void UnmapChooseLevelGadgets()
2499 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2500 UnmapGadget(screen_gadget[i]);
2503 static void HandleScreenGadgets(struct GadgetInfo *gi)
2505 int id = gi->custom_id;
2507 if (game_status != CHOOSELEVEL)
2512 case SCREEN_CTRL_ID_SCROLL_UP:
2513 HandleChooseLevel(SX,SY + 32, 0,0, MB_MENU_MARK);
2516 case SCREEN_CTRL_ID_SCROLL_DOWN:
2517 HandleChooseLevel(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK);
2520 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
2521 HandleChooseLevel(0,0, 999,gi->event.item_position, MB_MENU_INITIALIZE);