1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2002 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
14 #include "libgame/libgame.h"
27 /* screens in the setup menu */
28 #define SETUP_MODE_MAIN 0
29 #define SETUP_MODE_GAME 1
30 #define SETUP_MODE_EDITOR 2
31 #define SETUP_MODE_INPUT 3
32 #define SETUP_MODE_SHORTCUT 4
33 #define SETUP_MODE_GRAPHICS 5
34 #define SETUP_MODE_SOUND 6
35 #define SETUP_MODE_ARTWORK 7
36 #define SETUP_MODE_CHOOSE_GRAPHICS 8
37 #define SETUP_MODE_CHOOSE_SOUNDS 9
38 #define SETUP_MODE_CHOOSE_MUSIC 10
40 #define MAX_SETUP_MODES 11
42 /* for input setup functions */
43 #define SETUPINPUT_SCREEN_POS_START 0
44 #define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 4)
45 #define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
46 #define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
48 /* for various menu stuff */
49 #define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - 2)
50 #define MENU_SCREEN_START_YPOS 2
51 #define MENU_SCREEN_VALUE_XPOS 14
53 /* buttons and scrollbars identifiers */
54 #define SCREEN_CTRL_ID_SCROLL_UP 0
55 #define SCREEN_CTRL_ID_SCROLL_DOWN 1
56 #define SCREEN_CTRL_ID_SCROLL_VERTICAL 2
58 #define NUM_SCREEN_SCROLLBUTTONS 2
59 #define NUM_SCREEN_SCROLLBARS 1
60 #define NUM_SCREEN_GADGETS 3
62 /* forward declarations of internal functions */
63 static void HandleScreenGadgets(struct GadgetInfo *);
64 static void HandleSetupScreen_Generic(int, int, int, int, int);
65 static void HandleSetupScreen_Input(int, int, int, int, int);
66 static void CustomizeKeyboard(int);
67 static void CalibrateJoystick(int);
68 static void execSetupArtwork(void);
69 static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
71 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
72 static int setup_mode = SETUP_MODE_MAIN;
74 #define mSX (SX + (game_status >= GAME_MODE_MAIN && \
75 game_status <= GAME_MODE_SETUP ? \
76 menu.draw_xoffset[game_status] : menu.draw_xoffset_default))
77 #define mSY (SY + (game_status >= GAME_MODE_MAIN && \
78 game_status <= GAME_MODE_SETUP ? \
79 menu.draw_yoffset[game_status] : menu.draw_yoffset_default))
81 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
82 #define NUM_SCROLLBAR_BITMAPS 2
83 static Bitmap *scrollbar_bitmap[NUM_SCROLLBAR_BITMAPS];
87 static void drawCursorExt(int xpos, int ypos, int color, int graphic)
89 static int cursor_array[SCR_FIELDY];
94 cursor_array[ypos] = graphic;
96 graphic = cursor_array[ypos];
100 graphic = (graphic == IMG_MENU_BUTTON_LEFT ? IMG_MENU_BUTTON_LEFT_ACTIVE :
101 graphic == IMG_MENU_BUTTON_RIGHT ? IMG_MENU_BUTTON_RIGHT_ACTIVE:
102 IMG_MENU_BUTTON_ACTIVE);
104 ypos += MENU_SCREEN_START_YPOS;
106 DrawBackground(mSX + xpos * TILEX, mSY + ypos * TILEY, TILEX, TILEY);
107 DrawGraphicThruMaskExt(drawto, mSX + xpos * TILEX, mSY + ypos * TILEY,
111 static void initCursor(int ypos, int graphic)
113 drawCursorExt(0, ypos, FC_BLUE, graphic);
116 static void drawCursor(int ypos, int color)
118 drawCursorExt(0, ypos, color, 0);
121 static void drawCursorXY(int xpos, int ypos, int graphic)
123 drawCursorExt(xpos, ypos, -1, graphic);
126 static void PlaySound_Menu_Start(int sound)
128 if (sound_info[sound].loop)
129 PlaySoundLoop(sound);
134 static void PlaySound_Menu_Continue(int sound)
136 if (sound_info[sound].loop)
137 PlaySoundLoop(sound);
142 int font1_width = getFontWidth(FONT_TITLE_1);
143 int font2_width = getFontWidth(FONT_TITLE_2);
144 int x1 = SX + (SXSIZE - strlen(PROGRAM_TITLE_STRING) * font1_width) / 2;
145 int x2 = SX + (SXSIZE - strlen(WINDOW_SUBTITLE_STRING) * font2_width) / 2;
147 DrawText(x1, SY + 8, PROGRAM_TITLE_STRING, FONT_TITLE_1);
148 DrawText(x2, SY + 46, WINDOW_SUBTITLE_STRING, FONT_TITLE_2);
151 static void ToggleFullscreenIfNeeded()
153 if (setup.fullscreen != video.fullscreen_enabled)
155 /* save old door content */
156 BlitBitmap(backbuffer, bitmap_db_door,
157 DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
159 /* toggle fullscreen */
160 ChangeVideoModeIfNeeded(setup.fullscreen);
161 setup.fullscreen = video.fullscreen_enabled;
163 /* redraw background to newly created backbuffer */
164 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
165 0,0, WIN_XSIZE,WIN_YSIZE, 0,0);
167 /* restore old door content */
168 BlitBitmap(bitmap_db_door, backbuffer,
169 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
171 redraw_mask = REDRAW_ALL;
177 static LevelDirTree *leveldir_last_valid = NULL;
178 char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:");
179 int font_width = getFontWidth(FONT_MENU_1);
180 int name_width = font_width * strlen("Name:");
181 int level_width = font_width * strlen("Level:");
187 KeyboardAutoRepeatOn();
190 SetDrawDeactivationMask(REDRAW_NONE);
191 SetDrawBackgroundMask(REDRAW_FIELD);
193 audio.sound_deactivated = FALSE;
195 /* needed if last screen was the playing screen, invoked from level editor */
196 if (level_editor_test_game)
198 game_status = GAME_MODE_EDITOR;
203 /* needed if last screen was the editor screen */
204 UndrawSpecialEditorDoor();
206 /* needed if last screen was the setup screen and fullscreen state changed */
207 ToggleFullscreenIfNeeded();
209 /* needed if last screen (level choice) changed graphics, sounds or music */
210 ReloadCustomArtwork();
213 SetDrawtoField(DRAW_BACKBUFFER);
216 /* map gadgets for main menu screen */
219 /* leveldir_current may be invalid (level group, parent link) */
220 if (!validLevelSeries(leveldir_current))
221 leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
223 /* store valid level series information */
224 leveldir_last_valid = leveldir_current;
226 /* level_nr may have been set to value over handicap with level editor */
227 if (setup.handicap && level_nr > leveldir_current->handicap_level)
228 level_nr = leveldir_current->handicap_level;
233 SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
238 DrawText(mSX + 32, mSY + 2*32, name_text, FONT_MENU_1);
239 DrawText(mSX + 32, mSY + 3*32, "Level:", FONT_MENU_1);
240 DrawText(mSX + 32, mSY + 4*32, "Hall Of Fame", FONT_MENU_1);
241 DrawText(mSX + 32, mSY + 5*32, "Level Creator", FONT_MENU_1);
242 DrawText(mSX + 32, mSY + 6*32, "Info Screen", FONT_MENU_1);
243 DrawText(mSX + 32, mSY + 7*32, "Start Game", FONT_MENU_1);
244 DrawText(mSX + 32, mSY + 8*32, "Setup", FONT_MENU_1);
245 DrawText(mSX + 32, mSY + 9*32, "Quit", FONT_MENU_1);
247 DrawText(mSX + 32 + name_width, mSY + 2*32, setup.player_name, FONT_INPUT_1);
248 DrawText(mSX + level_width + 5 * 32, mSY + 3*32, int2str(level_nr,3),
251 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
253 DrawTextF(mSX + 32 + level_width - 2, mSY + 3*32 + 1, FONT_TEXT_3, "%d-%d",
254 leveldir_current->first_level, leveldir_current->last_level);
256 if (leveldir_current->readonly)
258 DrawTextF(mSX + level_width + 9 * 32 - 2,
259 mSY + 3 * 32 + 1 - 7, FONT_TEXT_3, "READ");
260 DrawTextF(mSX + level_width + 9 * 32 - 2,
261 mSY + 3 * 32 + 1 + 7, FONT_TEXT_3, "ONLY");
265 initCursor(i, (i == 1 || i == 6 ? IMG_MENU_BUTTON_RIGHT :IMG_MENU_BUTTON));
267 drawCursorXY(level_width/32 + 4, 1, IMG_MENU_BUTTON_LEFT);
268 drawCursorXY(level_width/32 + 8, 1, IMG_MENU_BUTTON_RIGHT);
270 DrawText(SX + 56, SY + 326, "A Game by Artsoft Entertainment", FONT_TITLE_2);
274 HandleMainMenu(0,0, 0,0, MB_MENU_INITIALIZE);
277 if (TAPE_IS_EMPTY(tape))
279 DrawCompleteVideoDisplay();
281 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
288 static void gotoTopLevelDir()
290 /* move upwards to top level directory */
291 while (leveldir_current->node_parent)
293 /* write a "path" into level tree for easy navigation to last level */
294 if (leveldir_current->node_parent->node_group->cl_first == -1)
296 int num_leveldirs = numTreeInfoInGroup(leveldir_current);
297 int leveldir_pos = posTreeInfo(leveldir_current);
298 int num_page_entries;
299 int cl_first, cl_cursor;
301 if (num_leveldirs <= MAX_MENU_ENTRIES_ON_SCREEN)
302 num_page_entries = num_leveldirs;
304 num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN;
306 cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
307 cl_cursor = leveldir_pos - cl_first;
309 leveldir_current->node_parent->node_group->cl_first = cl_first;
310 leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
313 leveldir_current = leveldir_current->node_parent;
317 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
319 static int choice = 0;
323 if (button == MB_MENU_INITIALIZE)
325 drawCursor(choice, FC_RED);
329 if (mx || my) /* mouse input */
332 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
334 else if (dx || dy) /* keyboard input */
336 if (dx && choice == 1)
337 x = (dx < 0 ? 10 : 14);
342 if (y == 1 && ((x == 10 && level_nr > leveldir_current->first_level) ||
343 (x == 14 && level_nr < leveldir_current->last_level)) &&
346 static unsigned long level_delay = 0;
347 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
348 int new_level_nr, old_level_nr = level_nr;
350 new_level_nr = level_nr + (x == 10 ? -step : +step);
351 if (new_level_nr < leveldir_current->first_level)
352 new_level_nr = leveldir_current->first_level;
353 if (new_level_nr > leveldir_current->last_level)
354 new_level_nr = leveldir_current->last_level;
356 if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
357 new_level_nr = leveldir_current->handicap_level;
359 if (old_level_nr == new_level_nr ||
360 !DelayReached(&level_delay, GADGET_FRAME_DELAY))
363 level_nr = new_level_nr;
365 DrawText(mSX + 11 * 32, mSY + 3 * 32, int2str(level_nr, 3), FONT_VALUE_1);
368 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
372 DrawCompleteVideoDisplay();
374 /* needed because DrawMicroLevel() takes some time */
377 DelayReached(&level_delay, 0); /* reset delay counter */
379 else if (x == 0 && y >= 0 && y <= 7)
385 drawCursor(y, FC_RED);
386 drawCursor(choice, FC_BLUE);
394 game_status = GAME_MODE_PSEUDO_TYPENAME;
395 HandleTypeName(strlen(setup.player_name), 0);
401 game_status = GAME_MODE_LEVELS;
402 SaveLevelSetup_LastSeries();
403 SaveLevelSetup_SeriesInfo();
412 game_status = GAME_MODE_SCORES;
417 if (leveldir_current->readonly &&
418 strcmp(setup.player_name, "Artsoft") != 0)
419 Request("This level is read only !", REQ_CONFIRM);
420 game_status = GAME_MODE_EDITOR;
425 game_status = GAME_MODE_INFO;
430 if (setup.autorecord)
431 TapeStartRecording();
433 #if defined(PLATFORM_UNIX)
435 SendToServer_StartPlaying();
439 game_status = GAME_MODE_PLAYING;
446 game_status = GAME_MODE_SETUP;
447 setup_mode = SETUP_MODE_MAIN;
452 SaveLevelSetup_LastSeries();
453 SaveLevelSetup_SeriesInfo();
454 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
455 game_status = GAME_MODE_QUIT;
464 if (game_status == GAME_MODE_MAIN)
466 DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE);
472 #define MAX_HELPSCREEN_ELS 10
476 static long helpscreen_state;
477 static int helpscreen_step[MAX_HELPSCREEN_ELS];
478 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
480 static int helpscreen_action[] =
482 IMG_PLAYER_1_MOVING_DOWN, 16,
483 IMG_PLAYER_1_MOVING_UP, 16,
484 IMG_PLAYER_1_MOVING_LEFT, 16,
485 IMG_PLAYER_1_MOVING_RIGHT, 16,
486 IMG_PLAYER_1_PUSHING_LEFT, 16,
487 IMG_PLAYER_1_PUSHING_RIGHT, 16, HA_NEXT,
489 IMG_SAND, -1, HA_NEXT,
491 IMG_EMPTY_SPACE, -1, HA_NEXT,
493 IMG_QUICKSAND_EMPTY, -1, HA_NEXT,
495 IMG_STEELWALL, -1, HA_NEXT,
497 IMG_WALL, -1, HA_NEXT,
499 IMG_EXPANDABLE_WALL_GROWING_LEFT, 20,
502 IMG_EXPANDABLE_WALL_GROWING_RIGHT, 20,
505 IMG_EXPANDABLE_WALL_GROWING_UP, 20,
508 IMG_EXPANDABLE_WALL_GROWING_DOWN, 20,
510 IMG_EMPTY_SPACE, 20, HA_NEXT,
512 IMG_INVISIBLE_WALL, -1, HA_NEXT,
514 IMG_WALL_CRUMBLED, -1, HA_NEXT,
516 IMG_FONT_GAME_INFO, -1, HA_NEXT,
518 IMG_EMERALD, -1, HA_NEXT,
520 IMG_DIAMOND, -1, HA_NEXT,
522 IMG_BD_DIAMOND, -1, HA_NEXT,
524 IMG_EMERALD_YELLOW, 50,
526 IMG_EMERALD_PURPLE, 50, HA_NEXT,
528 IMG_BD_ROCK, -1, HA_NEXT,
532 IMG_EMPTY_SPACE, 10, HA_NEXT,
536 IMG_EMERALD, 20, HA_NEXT,
538 IMG_WALL_EMERALD, 100,
540 IMG_EMERALD, 20, HA_NEXT,
542 IMG_WALL_DIAMOND, 100,
544 IMG_DIAMOND, 20, HA_NEXT,
546 IMG_WALL_BD_DIAMOND, 100,
548 IMG_BD_DIAMOND, 20, HA_NEXT,
550 IMG_WALL_EMERALD_YELLOW, 100,
552 IMG_EMERALD_YELLOW, 20,
553 IMG_WALL_EMERALD_RED, 100,
556 IMG_WALL_EMERALD_PURPLE, 100,
558 IMG_EMERALD_PURPLE, 20, HA_NEXT,
560 IMG_ACID, -1, HA_NEXT,
565 IMG_KEY_4, 50, HA_NEXT,
570 IMG_GATE_4, 50, HA_NEXT,
575 IMG_GATE_4_GRAY, 50, HA_NEXT,
577 IMG_DYNAMITE, -1, HA_NEXT,
579 IMG_DYNAMITE_ACTIVE, 96,
581 IMG_EMPTY_SPACE, 20, HA_NEXT,
583 IMG_DYNABOMB_ACTIVE, 100,
585 IMG_EMPTY_SPACE, 20, HA_NEXT,
587 IMG_DYNABOMB_INCREASE_NUMBER, -1, HA_NEXT,
589 IMG_DYNABOMB_INCREASE_SIZE, -1, HA_NEXT,
591 IMG_DYNABOMB_INCREASE_POWER, -1, HA_NEXT,
593 IMG_SPACESHIP_RIGHT, 16,
594 IMG_SPACESHIP_UP, 16,
595 IMG_SPACESHIP_LEFT, 16,
596 IMG_SPACESHIP_DOWN, 16, HA_NEXT,
601 IMG_BUG_DOWN, 16, HA_NEXT,
603 IMG_BD_BUTTERFLY, -1, HA_NEXT,
605 IMG_BD_FIREFLY, -1, HA_NEXT,
607 IMG_PACMAN_RIGHT, 16,
610 IMG_PACMAN_DOWN, 16, HA_NEXT,
612 IMG_YAMYAM, -1, HA_NEXT,
614 IMG_DARK_YAMYAM, -1, HA_NEXT,
616 IMG_ROBOT, -1, HA_NEXT,
618 IMG_MOLE_MOVING_RIGHT, 16,
619 IMG_MOLE_MOVING_UP, 16,
620 IMG_MOLE_MOVING_LEFT, 16,
621 IMG_MOLE_MOVING_DOWN, 16, HA_NEXT,
623 IMG_PENGUIN_MOVING_RIGHT, 16,
624 IMG_PENGUIN_MOVING_UP, 16,
625 IMG_PENGUIN_MOVING_LEFT, 16,
626 IMG_PENGUIN_MOVING_DOWN, 16, HA_NEXT,
628 IMG_PIG_MOVING_RIGHT, 16,
629 IMG_PIG_MOVING_UP, 16,
630 IMG_PIG_MOVING_LEFT, 16,
631 IMG_PIG_MOVING_DOWN, 16, HA_NEXT,
633 IMG_DRAGON_MOVING_RIGHT, 16,
634 IMG_DRAGON_MOVING_UP, 16,
635 IMG_DRAGON_MOVING_LEFT, 16,
636 IMG_DRAGON_MOVING_DOWN, 16, HA_NEXT,
638 IMG_SATELLITE, -1, HA_NEXT,
641 IMG_ROBOT_WHEEL_ACTIVE, 100, HA_NEXT,
644 IMG_LAMP_ACTIVE, 50, HA_NEXT,
646 IMG_TIME_ORB_FULL, 50,
647 IMG_TIME_ORB_EMPTY, 50, HA_NEXT,
650 IMG_AMOEBA_GROWING, 6,
651 IMG_AMOEBA_WET, 20, HA_NEXT,
653 IMG_AMOEBA_DEAD, -1, HA_NEXT,
655 IMG_AMOEBA_WET, -1, HA_NEXT,
658 IMG_AMOEBA_GROWING, 6, HA_NEXT,
663 IMG_DIAMOND, 20, HA_NEXT,
665 IMG_GAME_OF_LIFE, -1, HA_NEXT,
667 IMG_BIOMAZE, -1, HA_NEXT,
669 IMG_MAGIC_WALL_ACTIVE, -1, HA_NEXT,
671 IMG_BD_MAGIC_WALL_ACTIVE, -1, HA_NEXT,
673 IMG_EXIT_CLOSED, 200,
674 IMG_EXIT_OPENING, 16,
675 IMG_EXIT_OPEN, 100, HA_NEXT,
677 IMG_EXIT_OPEN, -1, HA_NEXT,
679 IMG_SOKOBAN_OBJECT, -1, HA_NEXT,
681 IMG_SOKOBAN_FIELD_EMPTY, -1, HA_NEXT,
683 IMG_SOKOBAN_FIELD_FULL, -1, HA_NEXT,
685 IMG_SPEED_PILL, -1, HA_NEXT,
689 static char *helpscreen_eltext[][2] =
691 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
692 {"Normal sand:", "You can dig through it"},
693 {"Empty field:", "You can walk through it"},
694 {"Quicksand: You cannot pass it,", "but rocks can fall through it"},
695 {"Massive Wall:", "Nothing can go through it"},
696 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
697 {"Growing Wall: Grows in several di-", "rections if there is an empty field"},
698 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
699 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
700 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
701 {"Emerald: You must collect enough of","them to finish a level"},
702 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
703 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
704 {"Colorful Gems:", "Seem to behave like Emeralds"},
705 {"Rock: Smashes several things;", "Can be moved by the player"},
706 {"Bomb: You can move it, but be", "careful when dropping it"},
707 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
708 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
709 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
710 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
711 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
712 {"Acid: Things that fall in are gone", "forever (including our hero)"},
713 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
714 {"Door: Can be opened by the key", "with the same color"},
715 {"Door: You have to find out the", "right color of the key for it"},
716 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
717 {"Dynamite: This one explodes after", "a few seconds"},
718 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
719 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
720 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
721 {"Dyna Bomb: Increases the power of", "explosion of dyna bombs"},
722 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
723 {"Bug: Moves at the right side", "of walls; don't touch it!"},
724 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
725 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
726 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
727 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
728 {"Cruncher (BD style):", "Eats almost everything"},
729 {"Robot: Tries to kill the player", ""},
730 {"The mole: Eats the amoeba and turns","empty space into normal sand"},
731 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
732 {"The Pig: Harmless, but eats all", "gems it can get"},
733 {"The Dragon: Breathes fire,", "especially to some monsters"},
734 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
735 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
736 {"Light Bulb: All of them must be", "switched on to finish a level"},
737 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
738 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
739 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
740 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
741 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
742 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
743 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
744 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
745 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
746 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
747 {"Exit door: Opens if you have enough","emeralds to finish the level"},
748 {"Open exit door: Enter here to leave","the level and exit the actual game"},
749 {"Sokoban element: Object which must", "be pushed to an empty field"},
750 {"Sokoban element: Empty field where", "a Sokoban object can be placed on"},
751 {"Sokoban element: Field with object", "which can be pushed away"},
752 {"Speed pill: Lets the player run", "twice as fast as normally"},
754 static int num_helpscreen_els = sizeof(helpscreen_eltext) / (2*sizeof(char *));
756 static char *helpscreen_music[][3] =
758 { "Alchemy", "Ian Boddy", "Drive" },
759 { "The Chase", "Propaganda", "A Secret Wish" },
760 { "Network 23", "Tangerine Dream", "Exit" },
761 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
762 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
763 { "Voyager", "The Alan Parsons Project","Pyramid" },
764 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
766 static int num_helpscreen_music = 7;
767 static int helpscreen_musicpos;
770 void OLD_DrawHelpScreenElAction(int start)
774 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
776 while(helpscreen_action[j] != HA_END)
778 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
780 else if (i<start || helpscreen_delay[i-start])
782 if (i>=start && helpscreen_delay[i-start])
783 helpscreen_delay[i-start]--;
785 while(helpscreen_action[j] != HA_NEXT)
792 j += 3*helpscreen_step[i-start];
793 graphic = helpscreen_action[j++];
795 if (helpscreen_frame[i-start])
797 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
798 helpscreen_frame[i-start]--;
803 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
806 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
808 if (helpscreen_action[j] == HA_NEXT)
810 if (!helpscreen_frame[i-start])
811 helpscreen_step[i-start] = 0;
815 if (!helpscreen_frame[i-start])
816 helpscreen_step[i-start]++;
817 while(helpscreen_action[j] != HA_NEXT)
822 DrawOldGraphicExt(drawto, xstart, ystart+(i-start)*ystep, graphic+frame);
834 void DrawHelpScreenElAction(int start)
837 int xstart = mSX + 16;
838 int ystart = mSY + 64 + 2 * 32;
839 int ystep = TILEY + 4;
845 while (helpscreen_action[j] != HA_END)
847 if (i >= start + MAX_HELPSCREEN_ELS || i >= num_helpscreen_els)
851 while (helpscreen_action[j] != HA_NEXT)
860 j += 2 * helpscreen_step[i-start];
861 graphic = helpscreen_action[j++];
862 frame_count = helpscreen_action[j++];
863 if (frame_count == -1)
864 frame_count = 1000000;
866 if (helpscreen_frame[i-start] == 0)
869 helpscreen_frame[i-start] = frame_count - 1;
873 sync_frame = frame_count - helpscreen_frame[i-start];
874 helpscreen_frame[i-start]--;
877 if (helpscreen_action[j] == HA_NEXT)
879 if (!helpscreen_frame[i-start])
880 helpscreen_step[i-start] = 0;
884 if (!helpscreen_frame[i-start])
885 helpscreen_step[i-start]++;
886 while(helpscreen_action[j] != HA_NEXT)
892 ClearRectangleOnBackground(drawto, xstart, ystart + (i - start) * ystep,
894 DrawGraphicAnimationExt(drawto, xstart, ystart + (i - start) * ystep,
895 graphic, sync_frame, USE_MASKING);
897 frame = getGraphicAnimationFrame(graphic, sync_frame);
899 DrawGraphicExt(drawto, xstart, ystart + (i-start) * ystep,
915 void DrawHelpScreenElText(int start)
918 int xstart = mSX + 56, ystart = mSY + 65 + 2 * 32, ystep = TILEY + 4;
919 int ybottom = SYSIZE - 20;
921 SetMainBackgroundImage(IMG_BACKGROUND_INFO);
925 DrawTextFCentered(100, FONT_TEXT_1, "The game elements:");
927 for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++)
930 ystart + (i - start) * ystep + (*helpscreen_eltext[i][1] ? 0 : 8),
931 helpscreen_eltext[i][0], FONT_TEXT_2);
932 DrawText(xstart, ystart + (i - start) * ystep + 16,
933 helpscreen_eltext[i][1], FONT_TEXT_2);
936 DrawTextFCentered(ybottom, FONT_TEXT_4,
937 "Press any key or button for next page");
940 void DrawHelpScreenMusicText(int num)
942 int ystart = 150, ystep = 30;
943 int ybottom = SYSIZE - 20;
949 DrawTextFCentered(100, FONT_TEXT_1, "The game background music loops:");
951 DrawTextFCentered(ystart + 0 * ystep, FONT_TEXT_2, "Excerpt from");
952 DrawTextFCentered(ystart + 1 * ystep, FONT_TEXT_3,
953 "\"%s\"", helpscreen_music[num][0]);
954 DrawTextFCentered(ystart + 2 * ystep, FONT_TEXT_2, "by");
955 DrawTextFCentered(ystart + 3 * ystep, FONT_TEXT_3,
956 "%s", helpscreen_music[num][1]);
957 DrawTextFCentered(ystart + 4 * ystep, FONT_TEXT_2, "from the album");
958 DrawTextFCentered(ystart + 5 * ystep, FONT_TEXT_3,
959 "\"%s\"", helpscreen_music[num][2]);
961 DrawTextFCentered(ybottom, FONT_TEXT_4,
962 "Press any key or button for next page");
965 PlaySoundLoop(background_loop[num]);
969 void DrawHelpScreenCreditsText()
971 int ystart = 150, ystep = 30;
972 int ybottom = SYSIZE - 20;
978 DrawTextFCentered(100, FONT_TEXT_1, "Credits:");
979 DrawTextFCentered(ystart + 0 * ystep, FONT_TEXT_2, "DOS port of the game:");
980 DrawTextFCentered(ystart + 1 * ystep, FONT_TEXT_3, "Guido Schulz");
981 DrawTextFCentered(ystart + 2 * ystep, FONT_TEXT_2, "Additional toons:");
982 DrawTextFCentered(ystart + 3 * ystep, FONT_TEXT_3, "Karl Hörnell");
983 DrawTextFCentered(ystart + 5 * ystep, FONT_TEXT_2,
984 "...and many thanks to all contributors");
985 DrawTextFCentered(ystart + 6 * ystep, FONT_TEXT_2, "of new levels!");
987 DrawTextFCentered(ybottom, FONT_TEXT_4,
988 "Press any key or button for next page");
991 void DrawHelpScreenContactText()
993 int ystart = 150, ystep = 30;
994 int ybottom = SYSIZE - 20;
999 DrawTextFCentered(100, FONT_TEXT_1, "Program information:");
1001 DrawTextFCentered(ystart + 0 * ystep, FONT_TEXT_2,
1002 "This game is Freeware!");
1003 DrawTextFCentered(ystart + 1 * ystep, FONT_TEXT_2,
1004 "If you like it, send e-mail to:");
1005 DrawTextFCentered(ystart + 2 * ystep, FONT_TEXT_3,
1006 "info@artsoft.org");
1007 DrawTextFCentered(ystart + 3 * ystep, FONT_TEXT_2,
1008 "or SnailMail to:");
1009 DrawTextFCentered(ystart + 4 * ystep + 0, FONT_TEXT_3,
1011 DrawTextFCentered(ystart + 4 * ystep + 20, FONT_TEXT_3,
1012 "Detmolder Strasse 189");
1013 DrawTextFCentered(ystart + 4 * ystep + 40, FONT_TEXT_3,
1015 DrawTextFCentered(ystart + 4 * ystep + 60, FONT_TEXT_3,
1018 DrawTextFCentered(ystart + 7 * ystep, FONT_TEXT_2,
1019 "If you have created new levels,");
1020 DrawTextFCentered(ystart + 8 * ystep, FONT_TEXT_2,
1021 "send them to me to include them!");
1022 DrawTextFCentered(ystart + 9 * ystep, FONT_TEXT_2,
1025 DrawTextFCentered(ybottom, FONT_TEXT_4,
1026 "Press any key or button for main menu");
1029 void DrawHelpScreen()
1034 CloseDoor(DOOR_CLOSE_2);
1036 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
1037 helpscreen_step[i] = helpscreen_frame[i] = 0;
1038 helpscreen_musicpos = 0;
1039 helpscreen_state = 0;
1041 DrawHelpScreenElText(0);
1042 DrawHelpScreenElAction(0);
1048 PlaySoundLoop(SND_BACKGROUND_INFO);
1050 PlaySound_Menu_Start(SND_BACKGROUND_INFO);
1054 void HandleHelpScreen(int button)
1056 static unsigned long hs_delay = 0;
1057 int num_helpscreen_els_pages =
1058 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
1059 int button_released = !button;
1062 if (button_released)
1064 if (helpscreen_state < num_helpscreen_els_pages - 1)
1066 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
1067 helpscreen_step[i] = helpscreen_frame[i] = 0;
1071 DrawHelpScreenElText(helpscreen_state * MAX_HELPSCREEN_ELS);
1072 DrawHelpScreenElAction(helpscreen_state * MAX_HELPSCREEN_ELS);
1074 else if (helpscreen_state <
1075 num_helpscreen_els_pages + num_helpscreen_music - 1)
1078 DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
1080 else if (helpscreen_state ==
1081 num_helpscreen_els_pages + num_helpscreen_music - 1)
1084 DrawHelpScreenCreditsText();
1086 else if (helpscreen_state ==
1087 num_helpscreen_els_pages + num_helpscreen_music)
1090 DrawHelpScreenContactText();
1096 game_status = GAME_MODE_MAIN;
1102 if (DelayReached(&hs_delay, GAME_FRAME_DELAY))
1104 if (helpscreen_state < num_helpscreen_els_pages)
1105 DrawHelpScreenElAction(helpscreen_state * MAX_HELPSCREEN_ELS);
1108 /* !!! workaround for playing "music" that is really a sound loop (and
1109 must therefore periodically be reactivated with the current sound
1112 PlaySoundLoop(SND_BACKGROUND_INFO);
1114 PlaySound_Menu_Continue(SND_BACKGROUND_INFO);
1123 void HandleTypeName(int newxpos, Key key)
1125 static int xpos = 0, ypos = 2;
1126 int font_width = getFontWidth(FONT_INPUT_1_ACTIVE);
1127 int name_width = getFontWidth(FONT_MENU_1) * strlen("Name:");
1128 int startx = mSX + 32 + name_width;
1129 int starty = mSY + ypos * 32;
1135 DrawText(startx, starty, setup.player_name, FONT_INPUT_1_ACTIVE);
1136 DrawText(startx + xpos * font_width, starty, "_", FONT_INPUT_1_ACTIVE);
1141 if (((key >= KSYM_A && key <= KSYM_Z) ||
1142 (key >= KSYM_a && key <= KSYM_z)) &&
1143 xpos < MAX_PLAYER_NAME_LEN)
1147 if (key >= KSYM_A && key <= KSYM_Z)
1148 ascii = 'A' + (char)(key - KSYM_A);
1150 ascii = 'a' + (char)(key - KSYM_a);
1152 setup.player_name[xpos] = ascii;
1153 setup.player_name[xpos + 1] = 0;
1156 DrawText(startx, starty, setup.player_name, FONT_INPUT_1_ACTIVE);
1157 DrawText(startx + xpos * font_width, starty, "_", FONT_INPUT_1_ACTIVE);
1159 else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
1162 setup.player_name[xpos] = 0;
1164 DrawText(startx + xpos * font_width, starty, "_ ", FONT_INPUT_1_ACTIVE);
1166 else if (key == KSYM_Return && xpos > 0)
1168 DrawText(startx, starty, setup.player_name, FONT_INPUT_1);
1169 DrawText(startx + xpos * font_width, starty, " ", FONT_INPUT_1_ACTIVE);
1172 game_status = GAME_MODE_MAIN;
1178 static void DrawChooseTree(TreeInfo **ti_ptr)
1181 CloseDoor(DOOR_CLOSE_2);
1185 HandleChooseTree(0,0, 0,0, MB_MENU_INITIALIZE, ti_ptr);
1186 MapChooseTreeGadgets(*ti_ptr);
1192 static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
1194 struct GadgetInfo *gi = screen_gadget[id];
1195 int items_max, items_visible, item_position;
1197 items_max = numTreeInfoInGroup(ti);
1198 items_visible = MAX_MENU_ENTRIES_ON_SCREEN;
1199 item_position = first_entry;
1201 if (item_position > items_max - items_visible)
1202 item_position = items_max - items_visible;
1204 ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
1205 GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
1208 static void drawChooseTreeList(int first_entry, int num_page_entries,
1212 char buffer[SCR_FIELDX * 2];
1213 int max_buffer_len = (SCR_FIELDX - 2) * 2;
1214 char *title_string = NULL;
1215 int xoffset_setup = 16;
1216 int yoffset_setup = 16;
1217 int xoffset = (ti->type == TREE_TYPE_LEVEL_DIR ? 0 : xoffset_setup);
1218 int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ? 0 : yoffset_setup);
1219 int last_game_status = game_status; /* save current game status */
1221 DrawBackground(SX, SY, SXSIZE - 32, SYSIZE);
1222 redraw_mask |= REDRAW_FIELD;
1225 (ti->type == TREE_TYPE_LEVEL_DIR ? "Level Directories" :
1226 ti->type == TREE_TYPE_GRAPHICS_DIR ? "Custom Graphics" :
1227 ti->type == TREE_TYPE_SOUNDS_DIR ? "Custom Sounds" :
1228 ti->type == TREE_TYPE_MUSIC_DIR ? "Custom Music" : "");
1230 DrawText(SX + xoffset, SY + yoffset, title_string, FONT_TITLE_1);
1232 /* force LEVELS font on artwork setup screen */
1233 game_status = GAME_MODE_LEVELS;
1235 for(i=0; i<num_page_entries; i++)
1237 TreeInfo *node, *node_first;
1238 int entry_pos = first_entry + i;
1239 int ypos = MENU_SCREEN_START_YPOS + i;
1241 node_first = getTreeInfoFirstGroupEntry(ti);
1242 node = getTreeInfoFromPos(node_first, entry_pos);
1244 strncpy(buffer, node->name , max_buffer_len);
1245 buffer[max_buffer_len] = '\0';
1247 DrawText(mSX + 32, mSY + ypos * 32, buffer, FONT_TEXT_1 + node->color);
1249 if (node->parent_link)
1250 initCursor(i, IMG_MENU_BUTTON_LEFT);
1251 else if (node->level_group)
1252 initCursor(i, IMG_MENU_BUTTON_RIGHT);
1254 initCursor(i, IMG_MENU_BUTTON);
1257 game_status = last_game_status; /* restore current game status */
1260 static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
1262 TreeInfo *node, *node_first;
1263 int x, last_redraw_mask = redraw_mask;
1265 if (ti->type != TREE_TYPE_LEVEL_DIR)
1268 node_first = getTreeInfoFirstGroupEntry(ti);
1269 node = getTreeInfoFromPos(node_first, entry_pos);
1271 DrawBackground(SX + 32, SY + 32, SXSIZE - 64, 32);
1273 if (node->parent_link)
1274 DrawTextFCentered(40, FONT_TITLE_2, "leave group \"%s\"",
1276 else if (node->level_group)
1277 DrawTextFCentered(40, FONT_TITLE_2, "enter group \"%s\"",
1279 else if (ti->type == TREE_TYPE_LEVEL_DIR)
1280 DrawTextFCentered(40, FONT_TITLE_2, "%3d levels (%s)",
1281 node->levels, node->class_desc);
1283 /* let BackToFront() redraw only what is needed */
1284 redraw_mask = last_redraw_mask | REDRAW_TILES;
1285 for (x=0; x<SCR_FIELDX; x++)
1286 MarkTileDirty(x, 1);
1289 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
1292 TreeInfo *ti = *ti_ptr;
1294 int y = ti->cl_cursor;
1295 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1296 int num_entries = numTreeInfoInGroup(ti);
1297 int num_page_entries;
1299 if (num_entries <= MAX_MENU_ENTRIES_ON_SCREEN)
1300 num_page_entries = num_entries;
1302 num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN;
1304 if (button == MB_MENU_INITIALIZE)
1306 int entry_pos = posTreeInfo(ti);
1308 if (ti->cl_first == -1)
1310 ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
1312 entry_pos - ti->cl_first;
1315 if (dx == 999) /* first entry is set by scrollbar position */
1318 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1321 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
1322 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
1323 drawCursor(ti->cl_cursor, FC_RED);
1326 else if (button == MB_MENU_LEAVE)
1328 if (ti->node_parent)
1330 *ti_ptr = ti->node_parent;
1331 DrawChooseTree(ti_ptr);
1333 else if (game_status == GAME_MODE_SETUP)
1339 game_status = GAME_MODE_MAIN;
1346 if (mx || my) /* mouse input */
1348 x = (mx - mSX) / 32;
1349 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
1351 else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
1353 /* move cursor instead of scrolling when already at start/end of list */
1354 if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
1356 else if (dy == +1 * SCROLL_LINE &&
1357 ti->cl_first + num_page_entries == num_entries)
1360 /* handle scrolling screen one line or page */
1361 if (ti->cl_cursor + dy < 0 ||
1362 ti->cl_cursor + dy > num_page_entries - 1)
1364 if (ABS(dy) == SCROLL_PAGE)
1365 step = num_page_entries - 1;
1367 if (dy < 0 && ti->cl_first > 0)
1369 /* scroll page/line up */
1371 ti->cl_first -= step;
1372 if (ti->cl_first < 0)
1375 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
1376 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
1377 drawCursor(ti->cl_cursor, FC_RED);
1378 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1381 else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
1383 /* scroll page/line down */
1385 ti->cl_first += step;
1386 if (ti->cl_first + num_page_entries > num_entries)
1387 ti->cl_first = MAX(0, num_entries - num_page_entries);
1389 drawChooseTreeList(ti->cl_first, num_page_entries, ti);
1390 drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
1391 drawCursor(ti->cl_cursor, FC_RED);
1392 AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
1399 /* handle moving cursor one line */
1400 y = ti->cl_cursor + dy;
1405 TreeInfo *node_first, *node_cursor;
1406 int entry_pos = ti->cl_first + y;
1408 node_first = getTreeInfoFirstGroupEntry(ti);
1409 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
1411 if (node_cursor->node_group)
1413 node_cursor->cl_first = ti->cl_first;
1414 node_cursor->cl_cursor = ti->cl_cursor;
1415 *ti_ptr = node_cursor->node_group;
1416 DrawChooseTree(ti_ptr);
1420 else if (dx == -1 && ti->node_parent)
1422 *ti_ptr = ti->node_parent;
1423 DrawChooseTree(ti_ptr);
1427 if (x == 0 && y >= 0 && y < num_page_entries)
1431 if (y != ti->cl_cursor)
1433 drawCursor(y, FC_RED);
1434 drawCursor(ti->cl_cursor, FC_BLUE);
1435 drawChooseTreeInfo(ti->cl_first + y, ti);
1441 TreeInfo *node_first, *node_cursor;
1442 int entry_pos = ti->cl_first + y;
1444 node_first = getTreeInfoFirstGroupEntry(ti);
1445 node_cursor = getTreeInfoFromPos(node_first, entry_pos);
1447 if (node_cursor->node_group)
1449 node_cursor->cl_first = ti->cl_first;
1450 node_cursor->cl_cursor = ti->cl_cursor;
1451 *ti_ptr = node_cursor->node_group;
1452 DrawChooseTree(ti_ptr);
1454 else if (node_cursor->parent_link)
1456 *ti_ptr = node_cursor->node_parent;
1457 DrawChooseTree(ti_ptr);
1461 node_cursor->cl_first = ti->cl_first;
1462 node_cursor->cl_cursor = ti->cl_cursor;
1463 *ti_ptr = node_cursor;
1465 if (ti->type == TREE_TYPE_LEVEL_DIR)
1467 LoadLevelSetup_SeriesInfo();
1469 SaveLevelSetup_LastSeries();
1470 SaveLevelSetup_SeriesInfo();
1474 if (game_status == GAME_MODE_SETUP)
1480 game_status = GAME_MODE_MAIN;
1489 if (game_status == GAME_MODE_LEVELS || game_status == GAME_MODE_SETUP)
1493 void DrawChooseLevel()
1495 SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
1497 DrawChooseTree(&leveldir_current);
1500 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
1502 HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
1505 void DrawHallOfFame(int highlight_position)
1509 CloseDoor(DOOR_CLOSE_2);
1511 if (highlight_position < 0)
1512 LoadScore(level_nr);
1517 HandleHallOfFame(highlight_position,0, 0,0, MB_MENU_INITIALIZE);
1520 PlaySound(SND_BACKGROUND_SCORES);
1522 PlaySound_Menu_Start(SND_BACKGROUND_SCORES);
1526 static void drawHallOfFameList(int first_entry, int highlight_position)
1530 SetMainBackgroundImage(IMG_BACKGROUND_SCORES);
1533 DrawText(mSX + 80, mSY + 8, "Hall Of Fame", FONT_TITLE_1);
1534 DrawTextFCentered(46, FONT_TITLE_2, "HighScores of Level %d", level_nr);
1536 for(i=0; i<MAX_MENU_ENTRIES_ON_SCREEN; i++)
1538 int entry = first_entry + i;
1539 boolean active = (entry == highlight_position);
1540 int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1);
1541 int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
1542 int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
1543 int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
1544 int dx1 = 3 * getFontWidth(font_nr1);
1545 int dx2 = dx1 + getFontWidth(font_nr1);
1546 int dx3 = dx2 + 25 * getFontWidth(font_nr3);
1547 int sy = mSY + 64 + i * 32;
1549 DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1);
1550 DrawText(mSX + dx1, sy, ".", font_nr1);
1551 DrawText(mSX + dx2, sy, ".........................", font_nr3);
1552 if (strcmp(highscore[entry].Name, EMPTY_PLAYER_NAME) != 0)
1553 DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
1554 DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
1558 void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
1560 static int first_entry = 0;
1561 static int highlight_position = 0;
1562 int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
1563 int button_released = !button;
1565 if (button == MB_MENU_INITIALIZE)
1568 highlight_position = mx;
1569 drawHallOfFameList(first_entry, highlight_position);
1573 if (ABS(dy) == SCROLL_PAGE) /* handle scrolling one page */
1574 step = MAX_MENU_ENTRIES_ON_SCREEN - 1;
1578 if (first_entry > 0)
1580 first_entry -= step;
1581 if (first_entry < 0)
1584 drawHallOfFameList(first_entry, highlight_position);
1590 if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
1592 first_entry += step;
1593 if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
1594 first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_MENU_ENTRIES_ON_SCREEN);
1596 drawHallOfFameList(first_entry, highlight_position);
1601 if (button_released)
1603 FadeSound(SND_BACKGROUND_SCORES);
1604 game_status = GAME_MODE_MAIN;
1610 if (game_status == GAME_MODE_SCORES)
1614 PlaySound_Menu_Continue(SND_BACKGROUND_SCORES);
1620 /* ========================================================================= */
1621 /* setup screen functions */
1622 /* ========================================================================= */
1624 static struct TokenInfo *setup_info;
1625 static int num_setup_info;
1627 static char *graphics_set_name;
1628 static char *sounds_set_name;
1629 static char *music_set_name;
1631 static void execSetupMain()
1633 setup_mode = SETUP_MODE_MAIN;
1637 static void execSetupGame()
1639 setup_mode = SETUP_MODE_GAME;
1643 static void execSetupEditor()
1645 setup_mode = SETUP_MODE_EDITOR;
1649 static void execSetupGraphics()
1651 setup_mode = SETUP_MODE_GRAPHICS;
1655 static void execSetupSound()
1657 setup_mode = SETUP_MODE_SOUND;
1661 static void execSetupArtwork()
1663 /* needed if last screen (setup choice) changed graphics, sounds or music */
1664 ReloadCustomArtwork();
1666 setup.graphics_set = artwork.gfx_current->identifier;
1667 setup.sounds_set = artwork.snd_current->identifier;
1668 setup.music_set = artwork.mus_current->identifier;
1670 /* needed for displaying artwork name instead of artwork identifier */
1671 graphics_set_name = artwork.gfx_current->name;
1672 sounds_set_name = artwork.snd_current->name;
1673 music_set_name = artwork.mus_current->name;
1675 setup_mode = SETUP_MODE_ARTWORK;
1679 static void execSetupChooseGraphics()
1681 setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
1685 static void execSetupChooseSounds()
1687 setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
1691 static void execSetupChooseMusic()
1693 setup_mode = SETUP_MODE_CHOOSE_MUSIC;
1697 static void execSetupInput()
1699 setup_mode = SETUP_MODE_INPUT;
1703 static void execSetupShortcut()
1705 setup_mode = SETUP_MODE_SHORTCUT;
1709 static void execExitSetup()
1711 game_status = GAME_MODE_MAIN;
1715 static void execSaveAndExitSetup()
1721 static struct TokenInfo setup_info_main[] =
1723 { TYPE_ENTER_MENU, execSetupGame, "Game Settings" },
1724 { TYPE_ENTER_MENU, execSetupEditor, "Editor Settings" },
1725 { TYPE_ENTER_MENU, execSetupGraphics, "Graphics" },
1726 { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" },
1727 { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" },
1728 { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
1729 { TYPE_ENTER_MENU, execSetupShortcut, "Key Shortcuts" },
1730 { TYPE_EMPTY, NULL, "" },
1731 { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
1732 { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" },
1736 static struct TokenInfo setup_info_game[] =
1738 { TYPE_SWITCH, &setup.team_mode, "Team-Mode:" },
1739 { TYPE_SWITCH, &setup.handicap, "Handicap:" },
1740 { TYPE_SWITCH, &setup.time_limit, "Timelimit:" },
1741 { TYPE_SWITCH, &setup.autorecord, "Auto-Record:" },
1742 { TYPE_EMPTY, NULL, "" },
1743 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
1747 static struct TokenInfo setup_info_editor[] =
1749 { TYPE_STRING, NULL, "Offer Special Elements:"},
1750 { TYPE_SWITCH, &setup.editor.el_boulderdash, "BoulderDash:" },
1751 { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
1752 { TYPE_SWITCH, &setup.editor.el_more, "More:" },
1753 { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
1754 { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
1755 { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamd. Caves:" },
1756 { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX Boulderd.:" },
1757 { TYPE_SWITCH, &setup.editor.el_chars, "Characters:" },
1758 { TYPE_SWITCH, &setup.editor.el_custom, "Custom:" },
1759 { TYPE_EMPTY, NULL, "" },
1760 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
1764 static struct TokenInfo setup_info_graphics[] =
1766 { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
1767 { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" },
1768 { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scroll.:" },
1770 { TYPE_SWITCH, &setup.double_buffering,"Buffered gfx:" },
1771 { TYPE_SWITCH, &setup.fading, "Fading:" },
1773 { TYPE_SWITCH, &setup.quick_doors, "Quick Doors:" },
1774 { TYPE_SWITCH, &setup.toons, "Toons:" },
1775 { TYPE_EMPTY, NULL, "" },
1776 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
1780 static struct TokenInfo setup_info_sound[] =
1782 { TYPE_SWITCH, &setup.sound, "Sound:", },
1783 { TYPE_EMPTY, NULL, "" },
1784 { TYPE_SWITCH, &setup.sound_simple, "Simple Sound:" },
1785 { TYPE_SWITCH, &setup.sound_loops, "Sound Loops:" },
1786 { TYPE_SWITCH, &setup.sound_music, "Game Music:" },
1787 { TYPE_EMPTY, NULL, "" },
1788 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
1792 static struct TokenInfo setup_info_artwork[] =
1794 { TYPE_ENTER_MENU, execSetupChooseGraphics,"Custom Graphics" },
1795 { TYPE_STRING, &graphics_set_name, "" },
1796 { TYPE_ENTER_MENU, execSetupChooseSounds, "Custom Sounds" },
1797 { TYPE_STRING, &sounds_set_name, "" },
1798 { TYPE_ENTER_MENU, execSetupChooseMusic, "Custom Music" },
1799 { TYPE_STRING, &music_set_name, "" },
1800 { TYPE_EMPTY, NULL, "" },
1801 { TYPE_STRING, NULL, "Override Level Artwork:"},
1802 { TYPE_YES_NO, &setup.override_level_graphics, "Graphics:" },
1803 { TYPE_YES_NO, &setup.override_level_sounds, "Sounds:" },
1804 { TYPE_YES_NO, &setup.override_level_music, "Music:" },
1805 { TYPE_EMPTY, NULL, "" },
1806 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
1810 static struct TokenInfo setup_info_shortcut[] =
1812 { TYPE_KEYTEXT, NULL, "Quick Save Game:", },
1813 { TYPE_KEY, &setup.shortcut.save_game, "" },
1814 { TYPE_KEYTEXT, NULL, "Quick Load Game:", },
1815 { TYPE_KEY, &setup.shortcut.load_game, "" },
1816 { TYPE_KEYTEXT, NULL, "Toggle Pause:", },
1817 { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
1818 { TYPE_EMPTY, NULL, "" },
1819 { TYPE_YES_NO, &setup.ask_on_escape, "Ask on Esc:" },
1820 { TYPE_EMPTY, NULL, "" },
1821 { TYPE_LEAVE_MENU, execSetupMain, "Back" },
1825 static Key getSetupKey()
1827 Key key = KSYM_UNDEFINED;
1828 boolean got_key_event = FALSE;
1830 while (!got_key_event)
1832 if (PendingEvent()) /* got event */
1840 case EVENT_KEYPRESS:
1842 key = GetEventKey((KeyEvent *)&event, TRUE);
1844 /* press 'Escape' or 'Enter' to keep the existing key binding */
1845 if (key == KSYM_Escape || key == KSYM_Return)
1846 key = KSYM_UNDEFINED; /* keep old value */
1848 got_key_event = TRUE;
1852 case EVENT_KEYRELEASE:
1853 key_joystick_mapping = 0;
1857 HandleOtherEvents(&event);
1865 /* don't eat all CPU time */
1872 static void drawSetupValue(int pos)
1874 int xpos = MENU_SCREEN_VALUE_XPOS;
1875 int ypos = MENU_SCREEN_START_YPOS + pos;
1876 int font_nr = FONT_VALUE_1;
1877 char *value_string = getSetupValue(setup_info[pos].type & ~TYPE_GHOSTED,
1878 setup_info[pos].value);
1880 if (value_string == NULL)
1883 if (setup_info[pos].type & TYPE_KEY)
1887 if (setup_info[pos].type & TYPE_QUERY)
1889 value_string = "<press key>";
1890 font_nr = FONT_INPUT_1_ACTIVE;
1893 else if (setup_info[pos].type & TYPE_STRING)
1895 int max_value_len = (SCR_FIELDX - 2) * 2;
1898 font_nr = FONT_VALUE_2;
1900 if (strlen(value_string) > max_value_len)
1901 value_string[max_value_len] = '\0';
1903 else if (setup_info[pos].type & TYPE_BOOLEAN_STYLE)
1905 font_nr = (*(boolean *)(setup_info[pos].value) ? FONT_OPTION_ON :
1909 DrawText(mSX + xpos * 32, mSY + ypos * 32,
1910 (xpos == 3 ? " " : " "), font_nr);
1911 DrawText(mSX + xpos * 32, mSY + ypos * 32, value_string, font_nr);
1914 static void changeSetupValue(int pos)
1916 if (setup_info[pos].type & TYPE_BOOLEAN_STYLE)
1918 *(boolean *)setup_info[pos].value ^= TRUE;
1920 else if (setup_info[pos].type & TYPE_KEY)
1924 setup_info[pos].type |= TYPE_QUERY;
1925 drawSetupValue(pos);
1926 setup_info[pos].type &= ~TYPE_QUERY;
1928 key = getSetupKey();
1929 if (key != KSYM_UNDEFINED)
1930 *(Key *)setup_info[pos].value = key;
1933 drawSetupValue(pos);
1936 static void DrawSetupScreen_Generic()
1938 char *title_string = NULL;
1942 CloseDoor(DOOR_CLOSE_2);
1946 if (setup_mode == SETUP_MODE_MAIN)
1948 setup_info = setup_info_main;
1949 title_string = "Setup";
1951 else if (setup_mode == SETUP_MODE_GAME)
1953 setup_info = setup_info_game;
1954 title_string = "Setup Game";
1956 else if (setup_mode == SETUP_MODE_EDITOR)
1958 setup_info = setup_info_editor;
1959 title_string = "Setup Editor";
1961 else if (setup_mode == SETUP_MODE_GRAPHICS)
1963 setup_info = setup_info_graphics;
1964 title_string = "Setup Graphics";
1966 else if (setup_mode == SETUP_MODE_SOUND)
1968 setup_info = setup_info_sound;
1969 title_string = "Setup Sound";
1971 else if (setup_mode == SETUP_MODE_ARTWORK)
1973 setup_info = setup_info_artwork;
1974 title_string = "Custom Artwork";
1976 else if (setup_mode == SETUP_MODE_SHORTCUT)
1978 setup_info = setup_info_shortcut;
1979 title_string = "Setup Shortcuts";
1982 DrawText(mSX + 16, mSY + 16, title_string, FONT_TITLE_1);
1985 for(i=0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++)
1987 void *value_ptr = setup_info[i].value;
1988 int ypos = MENU_SCREEN_START_YPOS + i;
1989 int font_nr = FONT_MENU_1;
1991 /* set some entries to "unchangeable" according to other variables */
1992 if ((value_ptr == &setup.sound && !audio.sound_available) ||
1993 (value_ptr == &setup.sound_loops && !audio.loops_available) ||
1994 (value_ptr == &setup.sound_music && !audio.music_available) ||
1995 (value_ptr == &setup.fullscreen && !video.fullscreen_available))
1996 setup_info[i].type |= TYPE_GHOSTED;
1998 if (setup_info[i].type & TYPE_STRING)
1999 font_nr = FONT_MENU_2;
2001 DrawText(mSX + 32, mSY + ypos * 32, setup_info[i].text, font_nr);
2003 if (setup_info[i].type & TYPE_ENTER_MENU)
2004 initCursor(i, IMG_MENU_BUTTON_RIGHT);
2005 else if (setup_info[i].type & TYPE_LEAVE_MENU)
2006 initCursor(i, IMG_MENU_BUTTON_LEFT);
2007 else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
2008 initCursor(i, IMG_MENU_BUTTON);
2010 if (setup_info[i].type & TYPE_VALUE)
2018 HandleSetupScreen_Generic(0,0,0,0,MB_MENU_INITIALIZE);
2021 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
2023 static int choice_store[MAX_SETUP_MODES];
2024 int choice = choice_store[setup_mode]; /* always starts with 0 */
2028 if (button == MB_MENU_INITIALIZE)
2030 /* advance to first valid menu entry */
2031 while (choice < num_setup_info &&
2032 (setup_info[choice].type & TYPE_SKIP_ENTRY))
2034 choice_store[setup_mode] = choice;
2036 drawCursor(choice, FC_RED);
2039 else if (button == MB_MENU_LEAVE)
2041 for (y=0; y<num_setup_info; y++)
2043 if (setup_info[y].type & TYPE_LEAVE_MENU)
2045 void (*menu_callback_function)(void) = setup_info[y].value;
2047 menu_callback_function();
2048 break; /* absolutely needed because function changes 'setup_info'! */
2055 if (mx || my) /* mouse input */
2057 x = (mx - mSX) / 32;
2058 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2060 else if (dx || dy) /* keyboard input */
2064 int menu_navigation_type = (dx < 0 ? TYPE_LEAVE_MENU : TYPE_ENTER_MENU);
2066 if ((setup_info[choice].type & menu_navigation_type) ||
2067 (setup_info[choice].type & TYPE_BOOLEAN_STYLE))
2068 button = MB_MENU_CHOICE;
2073 /* jump to next non-empty menu entry (up or down) */
2074 while (y > 0 && y < num_setup_info - 1 &&
2075 (setup_info[y].type & TYPE_SKIP_ENTRY))
2079 if (x == 0 && y >= 0 && y < num_setup_info &&
2080 (setup_info[y].type & ~TYPE_SKIP_ENTRY))
2086 drawCursor(y, FC_RED);
2087 drawCursor(choice, FC_BLUE);
2088 choice = choice_store[setup_mode] = y;
2091 else if (!(setup_info[y].type & TYPE_GHOSTED))
2093 if (setup_info[y].type & TYPE_ENTER_OR_LEAVE_MENU)
2095 void (*menu_callback_function)(void) = setup_info[choice].value;
2097 menu_callback_function();
2101 if ((setup_info[y].type & TYPE_KEYTEXT) &&
2102 (setup_info[y + 1].type & TYPE_KEY))
2105 if (setup_info[y].type & TYPE_VALUE)
2106 changeSetupValue(y);
2113 if (game_status == GAME_MODE_SETUP)
2117 void DrawSetupScreen_Input()
2121 DrawText(mSX+16, mSY+16, "Setup Input", FONT_TITLE_1);
2123 initCursor(0, IMG_MENU_BUTTON);
2124 initCursor(1, IMG_MENU_BUTTON);
2125 initCursor(2, IMG_MENU_BUTTON_RIGHT);
2126 initCursor(13, IMG_MENU_BUTTON_LEFT);
2128 drawCursorXY(10, 0, IMG_MENU_BUTTON_LEFT);
2129 drawCursorXY(12, 0, IMG_MENU_BUTTON_RIGHT);
2131 DrawText(mSX+32, mSY+2*32, "Player:", FONT_MENU_1);
2132 DrawText(mSX+32, mSY+3*32, "Device:", FONT_MENU_1);
2133 DrawText(mSX+32, mSY+15*32, "Back", FONT_MENU_1);
2136 DeactivateJoystickForCalibration();
2137 DrawTextFCentered(SYSIZE - 20, FONT_TEXT_4,
2138 "Joysticks deactivated on this screen");
2141 HandleSetupScreen_Input(0,0, 0,0, MB_MENU_INITIALIZE);
2146 static void setJoystickDeviceToNr(char *device_name, int device_nr)
2148 if (device_name == NULL)
2151 if (device_nr < 0 || device_nr >= MAX_PLAYERS)
2154 if (strlen(device_name) > 1)
2156 char c1 = device_name[strlen(device_name) - 1];
2157 char c2 = device_name[strlen(device_name) - 2];
2159 if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
2160 device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
2163 strncpy(device_name, getDeviceNameFromJoystickNr(device_nr),
2164 strlen(device_name));
2167 static void drawPlayerSetupInputInfo(int player_nr)
2170 static struct SetupKeyboardInfo custom_key;
2177 { &custom_key.left, "Joystick Left" },
2178 { &custom_key.right, "Joystick Right" },
2179 { &custom_key.up, "Joystick Up" },
2180 { &custom_key.down, "Joystick Down" },
2181 { &custom_key.snap, "Button 1" },
2182 { &custom_key.bomb, "Button 2" }
2184 static char *joystick_name[MAX_PLAYERS] =
2192 custom_key = setup.input[player_nr].key;
2194 DrawText(mSX+11*32, mSY+2*32, int2str(player_nr +1, 1), FONT_INPUT_1_ACTIVE);
2196 DrawGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
2197 PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
2199 DrawGraphicThruMask(8, 2, PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
2202 if (setup.input[player_nr].use_joystick)
2204 char *device_name = setup.input[player_nr].joy.device_name;
2206 DrawText(mSX+8*32, mSY+3*32,
2207 joystick_name[getJoystickNrFromDeviceName(device_name)],
2209 DrawText(mSX+32, mSY+4*32, "Calibrate", FONT_MENU_1);
2213 DrawText(mSX+8*32, mSY+3*32, "Keyboard ", FONT_VALUE_1);
2214 DrawText(mSX+32, mSY+4*32, "Customize", FONT_MENU_1);
2217 DrawText(mSX+32, mSY+5*32, "Actual Settings:", FONT_MENU_1);
2218 drawCursorXY(1, 4, IMG_MENU_BUTTON_LEFT);
2219 drawCursorXY(1, 5, IMG_MENU_BUTTON_RIGHT);
2220 drawCursorXY(1, 6, IMG_MENU_BUTTON_UP);
2221 drawCursorXY(1, 7, IMG_MENU_BUTTON_DOWN);
2222 DrawText(mSX+2*32, mSY+6*32, ":", FONT_VALUE_OLD);
2223 DrawText(mSX+2*32, mSY+7*32, ":", FONT_VALUE_OLD);
2224 DrawText(mSX+2*32, mSY+8*32, ":", FONT_VALUE_OLD);
2225 DrawText(mSX+2*32, mSY+9*32, ":", FONT_VALUE_OLD);
2226 DrawText(mSX+32, mSY+10*32, "Snap Field:", FONT_VALUE_OLD);
2227 DrawText(mSX+32, mSY+12*32, "Place Bomb:", FONT_VALUE_OLD);
2231 int ypos = 6 + i + (i > 3 ? i-3 : 0);
2233 DrawText(mSX + 3*32, mSY + ypos*32,
2235 DrawText(mSX + 3*32, mSY + ypos*32,
2236 (setup.input[player_nr].use_joystick ?
2238 getKeyNameFromKey(*custom[i].key)), FONT_VALUE_1);
2242 void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
2244 static int choice = 0;
2245 static int player_nr = 0;
2248 int pos_start = SETUPINPUT_SCREEN_POS_START;
2249 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1;
2250 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2;
2251 int pos_end = SETUPINPUT_SCREEN_POS_END;
2253 if (button == MB_MENU_INITIALIZE)
2255 drawPlayerSetupInputInfo(player_nr);
2256 drawCursor(choice, FC_RED);
2259 else if (button == MB_MENU_LEAVE)
2261 setup_mode = SETUP_MODE_MAIN;
2266 if (mx || my) /* mouse input */
2268 x = (mx - mSX) / 32;
2269 y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
2271 else if (dx || dy) /* keyboard input */
2273 if (dx && choice == 0)
2274 x = (dx < 0 ? 10 : 12);
2275 else if ((dx && choice == 1) ||
2276 (dx == +1 && choice == 2) ||
2277 (dx == -1 && choice == pos_end))
2278 button = MB_MENU_CHOICE;
2282 if (y >= pos_empty1 && y <= pos_empty2)
2283 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
2286 if (y == 0 && ((x == 0 && !button) || ((x == 10 || x == 12) && button)))
2288 static unsigned long delay = 0;
2290 if (!DelayReached(&delay, GADGET_FRAME_DELAY))
2293 player_nr = (player_nr + (x == 10 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
2295 drawPlayerSetupInputInfo(player_nr);
2297 else if (x == 0 && y >= pos_start && y <= pos_end &&
2298 !(y >= pos_empty1 && y <= pos_empty2))
2304 drawCursor(y, FC_RED);
2305 drawCursor(choice, FC_BLUE);
2313 char *device_name = setup.input[player_nr].joy.device_name;
2315 if (!setup.input[player_nr].use_joystick)
2317 int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
2319 setJoystickDeviceToNr(device_name, new_device_nr);
2320 setup.input[player_nr].use_joystick = TRUE;
2324 int device_nr = getJoystickNrFromDeviceName(device_name);
2325 int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
2327 if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
2328 setup.input[player_nr].use_joystick = FALSE;
2330 setJoystickDeviceToNr(device_name, new_device_nr);
2333 drawPlayerSetupInputInfo(player_nr);
2337 if (setup.input[player_nr].use_joystick)
2340 CalibrateJoystick(player_nr);
2343 CustomizeKeyboard(player_nr);
2345 else if (y == pos_end)
2349 setup_mode = SETUP_MODE_MAIN;
2359 if (game_status == GAME_MODE_SETUP)
2363 void CustomizeKeyboard(int player_nr)
2367 boolean finished = FALSE;
2368 static struct SetupKeyboardInfo custom_key;
2373 } customize_step[] =
2375 { &custom_key.left, "Move Left" },
2376 { &custom_key.right, "Move Right" },
2377 { &custom_key.up, "Move Up" },
2378 { &custom_key.down, "Move Down" },
2379 { &custom_key.snap, "Snap Field" },
2380 { &custom_key.bomb, "Place Bomb" }
2383 /* read existing key bindings from player setup */
2384 custom_key = setup.input[player_nr].key;
2387 DrawText(mSX + 16, mSY + 16, "Keyboard Input", FONT_TITLE_1);
2393 DrawText(mSX, mSY + (2+2*step_nr)*32,
2394 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
2395 DrawText(mSX, mSY + (2+2*step_nr+1)*32,
2396 "Key:", FONT_INPUT_1_ACTIVE);
2397 DrawText(mSX + 4*32, mSY + (2+2*step_nr+1)*32,
2398 getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
2402 if (PendingEvent()) /* got event */
2410 case EVENT_KEYPRESS:
2412 Key key = GetEventKey((KeyEvent *)&event, FALSE);
2414 if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6))
2420 /* all keys configured -- wait for "Escape" or "Return" key */
2424 /* press 'Enter' to keep the existing key binding */
2425 if (key == KSYM_Return)
2426 key = *customize_step[step_nr].key;
2428 /* check if key already used */
2429 for (i=0; i<step_nr; i++)
2430 if (*customize_step[i].key == key)
2435 /* got new key binding */
2436 *customize_step[step_nr].key = key;
2437 DrawText(mSX + 4*32, mSY + (2+2*step_nr+1)*32,
2439 DrawText(mSX + 4*32, mSY + (2+2*step_nr+1)*32,
2440 getKeyNameFromKey(key), FONT_VALUE_1);
2443 /* un-highlight last query */
2444 DrawText(mSX, mSY+(2+2*(step_nr-1))*32,
2445 customize_step[step_nr-1].text, FONT_MENU_1);
2446 DrawText(mSX, mSY+(2+2*(step_nr-1)+1)*32,
2447 "Key:", FONT_MENU_1);
2449 /* press 'Enter' to leave */
2452 DrawText(mSX + 16, mSY + 15*32+16,
2453 "Press Enter", FONT_TITLE_1);
2457 /* query next key binding */
2458 DrawText(mSX, mSY+(2+2*step_nr)*32,
2459 customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
2460 DrawText(mSX, mSY+(2+2*step_nr+1)*32,
2461 "Key:", FONT_INPUT_1_ACTIVE);
2462 DrawText(mSX + 4*32, mSY+(2+2*step_nr+1)*32,
2463 getKeyNameFromKey(*customize_step[step_nr].key),
2468 case EVENT_KEYRELEASE:
2469 key_joystick_mapping = 0;
2473 HandleOtherEvents(&event);
2481 /* don't eat all CPU time */
2485 /* write new key bindings back to player setup */
2486 setup.input[player_nr].key = custom_key;
2489 DrawSetupScreen_Input();
2492 static boolean CalibrateJoystickMain(int player_nr)
2494 int new_joystick_xleft = JOYSTICK_XMIDDLE;
2495 int new_joystick_xright = JOYSTICK_XMIDDLE;
2496 int new_joystick_yupper = JOYSTICK_YMIDDLE;
2497 int new_joystick_ylower = JOYSTICK_YMIDDLE;
2498 int new_joystick_xmiddle, new_joystick_ymiddle;
2500 int joystick_fd = joystick.fd[player_nr];
2501 int x, y, last_x, last_y, xpos = 8, ypos = 3;
2502 boolean check[3][3];
2503 int check_remaining = 3 * 3;
2508 if (joystick.status == JOYSTICK_NOT_AVAILABLE)
2511 if (joystick_fd < 0 || !setup.input[player_nr].use_joystick)
2516 for(y=0; y < 3; y++)
2518 for(x=0; x < 3; x++)
2520 DrawGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0);
2521 check[x][y] = FALSE;
2525 DrawText(mSX, mSY + 6 * 32, " ROTATE JOYSTICK ", FONT_TITLE_1);
2526 DrawText(mSX, mSY + 7 * 32, "IN ALL DIRECTIONS", FONT_TITLE_1);
2527 DrawText(mSX + 16, mSY + 9 * 32, " IF ALL BALLS ", FONT_TITLE_1);
2528 DrawText(mSX, mSY + 10 * 32, " ARE YELLOW, ", FONT_TITLE_1);
2529 DrawText(mSX, mSY + 11 * 32, " CENTER JOYSTICK ", FONT_TITLE_1);
2530 DrawText(mSX, mSY + 12 * 32, " AND ", FONT_TITLE_1);
2531 DrawText(mSX, mSY + 13 * 32, "PRESS ANY BUTTON!", FONT_TITLE_1);
2533 joy_value = Joystick(player_nr);
2534 last_x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2535 last_y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2537 /* eventually uncalibrated center position (joystick could be uncentered) */
2538 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
2541 new_joystick_xmiddle = joy_x;
2542 new_joystick_ymiddle = joy_y;
2544 DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0);
2547 while(Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
2552 if (PendingEvent()) /* got event */
2560 case EVENT_KEYPRESS:
2561 switch(GetEventKey((KeyEvent *)&event, TRUE))
2564 if (check_remaining == 0)
2577 case EVENT_KEYRELEASE:
2578 key_joystick_mapping = 0;
2582 HandleOtherEvents(&event);
2587 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
2590 new_joystick_xleft = MIN(new_joystick_xleft, joy_x);
2591 new_joystick_xright = MAX(new_joystick_xright, joy_x);
2592 new_joystick_yupper = MIN(new_joystick_yupper, joy_y);
2593 new_joystick_ylower = MAX(new_joystick_ylower, joy_y);
2595 setup.input[player_nr].joy.xleft = new_joystick_xleft;
2596 setup.input[player_nr].joy.yupper = new_joystick_yupper;
2597 setup.input[player_nr].joy.xright = new_joystick_xright;
2598 setup.input[player_nr].joy.ylower = new_joystick_ylower;
2599 setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
2600 setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
2602 CheckJoystickData();
2604 joy_value = Joystick(player_nr);
2606 if (joy_value & JOY_BUTTON && check_remaining == 0)
2609 x = (joy_value & JOY_LEFT ? -1 : joy_value & JOY_RIGHT ? +1 : 0);
2610 y = (joy_value & JOY_UP ? -1 : joy_value & JOY_DOWN ? +1 : 0);
2612 if (x != last_x || y != last_y)
2614 DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_YELLOW, 0);
2615 DrawGraphic(xpos + x, ypos + y, IMG_MENU_CALIBRATE_RED, 0);
2620 if (check_remaining > 0 && !check[x+1][y+1])
2622 check[x+1][y+1] = TRUE;
2628 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
2629 setup.input[player_nr].joy.xleft,
2630 setup.input[player_nr].joy.xmiddle,
2631 setup.input[player_nr].joy.xright);
2632 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
2633 setup.input[player_nr].joy.yupper,
2634 setup.input[player_nr].joy.ymiddle,
2635 setup.input[player_nr].joy.ylower);
2644 /* don't eat all CPU time */
2648 /* calibrated center position (joystick should now be centered) */
2649 if (!ReadJoystick(joystick_fd, &joy_x, &joy_y, NULL, NULL))
2652 new_joystick_xmiddle = joy_x;
2653 new_joystick_ymiddle = joy_y;
2657 DrawSetupScreen_Input();
2659 /* wait until the last pressed button was released */
2660 while (Joystick(player_nr) & JOY_BUTTON)
2662 if (PendingEvent()) /* got event */
2667 HandleOtherEvents(&event);
2676 void CalibrateJoystick(int player_nr)
2678 if (!CalibrateJoystickMain(player_nr))
2682 DrawText(mSX + 16, mSY + 6*32, " JOYSTICK NOT ", FONT_TITLE_1);
2683 DrawText(mSX, mSY + 7*32, " AVAILABLE ", FONT_TITLE_1);
2685 Delay(2000); /* show error message for two seconds */
2689 void DrawSetupScreen()
2691 DeactivateJoystick();
2693 SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
2695 if (setup_mode == SETUP_MODE_INPUT)
2696 DrawSetupScreen_Input();
2697 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
2698 DrawChooseTree(&artwork.gfx_current);
2699 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
2700 DrawChooseTree(&artwork.snd_current);
2701 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
2702 DrawChooseTree(&artwork.mus_current);
2704 DrawSetupScreen_Generic();
2707 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
2709 if (setup_mode == SETUP_MODE_INPUT)
2710 HandleSetupScreen_Input(mx, my, dx, dy, button);
2711 else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
2712 HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
2713 else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
2714 HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current);
2715 else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC)
2716 HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current);
2718 HandleSetupScreen_Generic(mx, my, dx, dy, button);
2721 void HandleGameActions()
2723 if (game_status != GAME_MODE_PLAYING)
2726 if (local_player->LevelSolved)
2729 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
2737 if (tape.auto_play && !tape.playing)
2738 AutoPlayTape(); /* continue automatically playing next tape */
2742 /* ---------- new screen button stuff -------------------------------------- */
2744 /* graphic position and size values for buttons and scrollbars */
2745 #define SC_SCROLLBUTTON_XSIZE TILEX
2746 #define SC_SCROLLBUTTON_YSIZE TILEY
2748 #define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE
2749 #define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \
2750 SC_SCROLLBUTTON_YSIZE)
2751 #define SC_SCROLL_UP_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE)
2752 #define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE)
2753 #define SC_SCROLL_VERTICAL_XPOS SC_SCROLL_UP_XPOS
2754 #define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \
2755 SC_SCROLLBUTTON_YSIZE)
2756 #define SC_SCROLL_DOWN_XPOS SC_SCROLL_UP_XPOS
2757 #define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \
2758 SC_SCROLL_VERTICAL_YSIZE)
2760 #define SC_BORDER_SIZE 14
2764 int gfx_unpressed, gfx_pressed;
2768 } scrollbutton_info[NUM_SCREEN_SCROLLBUTTONS] =
2771 IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
2772 SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
2773 SCREEN_CTRL_ID_SCROLL_UP,
2777 IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
2778 SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
2779 SCREEN_CTRL_ID_SCROLL_DOWN,
2786 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
2787 Bitmap **gfx_unpressed, **gfx_pressed;
2789 int gfx_unpressed, gfx_pressed;
2796 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
2799 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
2800 &scrollbar_bitmap[0], &scrollbar_bitmap[1],
2802 IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
2804 SX + SC_SCROLL_VERTICAL_XPOS, SY + SC_SCROLL_VERTICAL_YPOS,
2805 SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
2806 GD_TYPE_SCROLLBAR_VERTICAL,
2807 SCREEN_CTRL_ID_SCROLL_VERTICAL,
2808 "scroll level series vertically"
2812 static void CreateScreenScrollbuttons()
2814 struct GadgetInfo *gi;
2815 unsigned long event_mask;
2818 for (i=0; i<NUM_SCREEN_SCROLLBUTTONS; i++)
2820 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
2821 int gfx_unpressed, gfx_pressed;
2822 int x, y, width, height;
2823 int gd_x1, gd_x2, gd_y1, gd_y2;
2824 int id = scrollbutton_info[i].gadget_id;
2826 x = scrollbutton_info[i].x;
2827 y = scrollbutton_info[i].y;
2829 event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
2833 width = SC_SCROLLBUTTON_XSIZE;
2834 height = SC_SCROLLBUTTON_YSIZE;
2836 gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
2837 gfx_pressed = scrollbutton_info[i].gfx_pressed;
2838 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
2839 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
2840 gd_x1 = graphic_info[gfx_unpressed].src_x;
2841 gd_y1 = graphic_info[gfx_unpressed].src_y;
2842 gd_x2 = graphic_info[gfx_pressed].src_x;
2843 gd_y2 = graphic_info[gfx_pressed].src_y;
2845 gi = CreateGadget(GDI_CUSTOM_ID, id,
2846 GDI_CUSTOM_TYPE_ID, i,
2847 GDI_INFO_TEXT, scrollbutton_info[i].infotext,
2852 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
2853 GDI_STATE, GD_BUTTON_UNPRESSED,
2854 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
2855 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
2856 GDI_EVENT_MASK, event_mask,
2857 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2861 Error(ERR_EXIT, "cannot create gadget");
2863 screen_gadget[id] = gi;
2867 static void CreateScreenScrollbars()
2871 for (i=0; i<NUM_SCREEN_SCROLLBARS; i++)
2873 Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
2874 #if !defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
2875 int gfx_unpressed, gfx_pressed;
2877 int gd_x1, gd_x2, gd_y1, gd_y2;
2878 struct GadgetInfo *gi;
2879 int items_max, items_visible, item_position;
2880 unsigned long event_mask;
2881 int num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN;
2882 int id = scrollbar_info[i].gadget_id;
2884 items_max = num_page_entries;
2885 items_visible = num_page_entries;
2888 event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
2890 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
2891 gd_bitmap_unpressed = *scrollbar_info[i].gfx_unpressed;
2892 gd_bitmap_pressed = *scrollbar_info[i].gfx_pressed;
2898 gfx_unpressed = scrollbar_info[i].gfx_unpressed;
2899 gfx_pressed = scrollbar_info[i].gfx_pressed;
2900 gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
2901 gd_bitmap_pressed = graphic_info[gfx_pressed].bitmap;
2902 gd_x1 = graphic_info[gfx_unpressed].src_x;
2903 gd_y1 = graphic_info[gfx_unpressed].src_y;
2904 gd_x2 = graphic_info[gfx_pressed].src_x;
2905 gd_y2 = graphic_info[gfx_pressed].src_y;
2908 gi = CreateGadget(GDI_CUSTOM_ID, id,
2909 GDI_CUSTOM_TYPE_ID, i,
2910 GDI_INFO_TEXT, scrollbar_info[i].infotext,
2911 GDI_X, scrollbar_info[i].x,
2912 GDI_Y, scrollbar_info[i].y,
2913 GDI_WIDTH, scrollbar_info[i].width,
2914 GDI_HEIGHT, scrollbar_info[i].height,
2915 GDI_TYPE, scrollbar_info[i].type,
2916 GDI_SCROLLBAR_ITEMS_MAX, items_max,
2917 GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible,
2918 GDI_SCROLLBAR_ITEM_POSITION, item_position,
2919 GDI_STATE, GD_BUTTON_UNPRESSED,
2920 GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1,
2921 GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2,
2922 GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE,
2923 GDI_EVENT_MASK, event_mask,
2924 GDI_CALLBACK_ACTION, HandleScreenGadgets,
2928 Error(ERR_EXIT, "cannot create gadget");
2930 screen_gadget[id] = gi;
2934 void CreateScreenGadgets()
2936 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
2939 for (i=0; i < NUM_SCROLLBAR_BITMAPS; i++)
2941 scrollbar_bitmap[i] = CreateBitmap(TILEX, TILEY, DEFAULT_DEPTH);
2943 /* copy pointers to clip mask and GC */
2944 scrollbar_bitmap[i]->clip_mask =
2945 graphic_info[IMG_MENU_SCROLLBAR + i].clip_mask;
2946 scrollbar_bitmap[i]->stored_clip_gc =
2947 graphic_info[IMG_MENU_SCROLLBAR + i].clip_gc;
2949 BlitBitmap(graphic_info[IMG_MENU_SCROLLBAR + i].bitmap,
2950 scrollbar_bitmap[i],
2951 graphic_info[IMG_MENU_SCROLLBAR + i].src_x,
2952 graphic_info[IMG_MENU_SCROLLBAR + i].src_y,
2953 TILEX, TILEY, 0, 0);
2957 CreateScreenScrollbuttons();
2958 CreateScreenScrollbars();
2961 void FreeScreenGadgets()
2965 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
2966 for (i=0; i < NUM_SCROLLBAR_BITMAPS; i++)
2968 /* prevent freeing clip mask and GC twice */
2969 scrollbar_bitmap[i]->clip_mask = None;
2970 scrollbar_bitmap[i]->stored_clip_gc = None;
2972 FreeBitmap(scrollbar_bitmap[i]);
2976 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2977 FreeGadget(screen_gadget[i]);
2980 void MapChooseTreeGadgets(TreeInfo *ti)
2982 int num_entries = numTreeInfoInGroup(ti);
2985 if (num_entries <= MAX_MENU_ENTRIES_ON_SCREEN)
2988 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2989 MapGadget(screen_gadget[i]);
2992 void UnmapChooseTreeGadgets()
2996 for (i=0; i<NUM_SCREEN_GADGETS; i++)
2997 UnmapGadget(screen_gadget[i]);
3000 static void HandleScreenGadgets(struct GadgetInfo *gi)
3002 int id = gi->custom_id;
3004 if (game_status != GAME_MODE_LEVELS && game_status != GAME_MODE_SETUP)
3009 case SCREEN_CTRL_ID_SCROLL_UP:
3010 if (game_status == GAME_MODE_LEVELS)
3011 HandleChooseLevel(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
3012 else if (game_status == GAME_MODE_SETUP)
3013 HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
3016 case SCREEN_CTRL_ID_SCROLL_DOWN:
3017 if (game_status == GAME_MODE_LEVELS)
3018 HandleChooseLevel(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
3019 else if (game_status == GAME_MODE_SETUP)
3020 HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
3023 case SCREEN_CTRL_ID_SCROLL_VERTICAL:
3024 if (game_status == GAME_MODE_LEVELS)
3025 HandleChooseLevel(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);
3026 else if (game_status == GAME_MODE_SETUP)
3027 HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);