static boolean pressed = FALSE;
int sound_state[3];
- sound_state[0] = BUTTON_SOUND_MUSIC | (BUTTON_ON * setup.sound_music_on);
- sound_state[1] = BUTTON_SOUND_LOOPS | (BUTTON_ON * setup.sound_loops_on);
- sound_state[2] = BUTTON_SOUND_SIMPLE | (BUTTON_ON * setup.sound_simple_on);
+ sound_state[0] = BUTTON_SOUND_MUSIC | (BUTTON_ON * setup.sound_music);
+ sound_state[1] = BUTTON_SOUND_LOOPS | (BUTTON_ON * setup.sound_loops);
+ sound_state[2] = BUTTON_SOUND_SIMPLE | (BUTTON_ON * setup.sound_simple);
if (button)
{
static int toon_nr = 0;
int draw_mode;
- if (!setup.toons_on)
+ if (!setup.toons)
return;
switch(mode)
reset_delay = TRUE;
/* Fill empty backbuffer for animation functions */
- if (setup.direct_draw_on && game_status == PLAYING)
+ if (setup.direct_draw && game_status == PLAYING)
{
int xx,yy;
SetDrawtoField(DRAW_DIRECT);
}
- if (setup.soft_scrolling_on && game_status == PLAYING)
+ if (setup.soft_scrolling && game_status == PLAYING)
{
int fx = FX, fy = FY;
redraw_mask |= (REDRAW_FIELD | REDRAW_FROM_BACKBUFFER);
/* Redraw background even when in direct drawing mode */
- draw_mode = setup.direct_draw_on;
- setup.direct_draw_on = FALSE;
+ draw_mode = setup.direct_draw;
+ setup.direct_draw = FALSE;
BackToFront();
- setup.direct_draw_on = draw_mode;
+ setup.direct_draw = draw_mode;
return;
break;
int x = event->x, y = event->y;
int width = event->width, height = event->height;
- if (setup.direct_draw_on && game_status==PLAYING)
+ if (setup.direct_draw && game_status==PLAYING)
{
int xx,yy;
int x1 = (x-SX)/TILEX, y1 = (y-SY)/TILEY;
SetDrawtoField(DRAW_DIRECT);
}
- if (setup.soft_scrolling_on && game_status == PLAYING)
+ if (setup.soft_scrolling && game_status == PLAYING)
{
int fx = FX, fy = FY;
}
*/
- printf("direct_draw_on == %d\n", setup.direct_draw_on);
+ printf("direct_draw == %d\n", setup.direct_draw);
break;
}
}
+static int HandleJoystickForAllPlayers()
+{
+ int i;
+ int result = 0;
+
+ for (i=0; i<MAX_PLAYERS; i++)
+ {
+ byte joy_action = 0;
+
+ if (!setup.input[i].use_joystick)
+ continue;
+
+ joy_action = Joystick(i);
+
+ result |= joy_action;
+
+ if (network_playing)
+ local_player->potential_action |= joy_action;
+ else
+ stored_player[i].action |= joy_action;
+ }
+
+ return result;
+}
+
void HandleJoystick()
{
- int joystick = Joystick();
+ int joystick = HandleJoystickForAllPlayers();
int keyboard = key_joystick_mapping;
int joy = (joystick | keyboard);
int left = joy & JOY_LEFT;
int up = joy & JOY_UP;
int down = joy & JOY_DOWN;
int button = joy & JOY_BUTTON;
- int newbutton = (JoystickButton() == JOY_BUTTON_NEW_PRESSED);
+ int newbutton = (AnyJoystickButton() == JOY_BUTTON_NEW_PRESSED);
int dx = (left ? -1 : right ? 1 : 0);
int dy = (up ? -1 : down ? 1 : 0);
fclose(file);
}
+
+
+#if 0
+
void LoadJoystickData()
{
int i;
}
+#endif
+
+
+
/* ------------------------------------------------------------------------- */
/* new setup functions */
/* ------------------------------------------------------------------------- */
#define SETUP_TOKEN_SOUND_MUSIC 2
#define SETUP_TOKEN_SOUND_SIMPLE 3
#define SETUP_TOKEN_TOONS 4
-#define SETUP_TOKEN_DIRECT_DRAW 5
+#define SETUP_TOKEN_DOUBLE_BUFFERING 5
#define SETUP_TOKEN_SCROLL_DELAY 6
#define SETUP_TOKEN_SOFT_SCROLLING 7
#define SETUP_TOKEN_FADING 8
#define SETUP_TOKEN_AUTORECORD 9
#define SETUP_TOKEN_QUICK_DOORS 10
-#define SETUP_TOKEN_USE_JOYSTICK 11
-#define SETUP_TOKEN_JOYSTICK_NR 12
-#define SETUP_TOKEN_JOY_SNAP 13
-#define SETUP_TOKEN_JOY_BOMB 14
-#define SETUP_TOKEN_KEY_LEFT 15
-#define SETUP_TOKEN_KEY_RIGHT 16
-#define SETUP_TOKEN_KEY_UP 17
-#define SETUP_TOKEN_KEY_DOWN 18
-#define SETUP_TOKEN_KEY_SNAP 19
-#define SETUP_TOKEN_KEY_BOMB 20
-
-#define NUM_SETUP_TOKENS 21
-
+#define SETUP_TOKEN_ALIAS_NAMES 11
+
+#define SETUP_TOKEN_USE_JOYSTICK 12
+#define SETUP_TOKEN_JOY_DEVICE_NAME 13
+#define SETUP_TOKEN_JOY_XLEFT 14
+#define SETUP_TOKEN_JOY_XMIDDLE 15
+#define SETUP_TOKEN_JOY_XRIGHT 16
+#define SETUP_TOKEN_JOY_YUPPER 17
+#define SETUP_TOKEN_JOY_YMIDDLE 18
+#define SETUP_TOKEN_JOY_YLOWER 19
+#define SETUP_TOKEN_JOY_SNAP 20
+#define SETUP_TOKEN_JOY_BOMB 21
+#define SETUP_TOKEN_KEY_LEFT 22
+#define SETUP_TOKEN_KEY_RIGHT 23
+#define SETUP_TOKEN_KEY_UP 24
+#define SETUP_TOKEN_KEY_DOWN 25
+#define SETUP_TOKEN_KEY_SNAP 26
+#define SETUP_TOKEN_KEY_BOMB 27
+
+#define NUM_SETUP_TOKENS 28
+
+#define FIRST_GLOBAL_SETUP_TOKEN SETUP_TOKEN_SOUND
+#define LAST_GLOBAL_SETUP_TOKEN SETUP_TOKEN_ALIAS_NAMES
+
+#define FIRST_PLAYER_SETUP_TOKEN SETUP_TOKEN_USE_JOYSTICK
+#define LAST_PLAYER_SETUP_TOKEN SETUP_TOKEN_KEY_BOMB
+
+#define TYPE_BOOLEAN 1
+#define TYPE_SWITCH 2
+#define TYPE_KEYSYM 3
+#define TYPE_INTEGER 4
+#define TYPE_STRING 5
+
+static struct SetupInfo si;
+static struct SetupInputInfo sii;
static struct
{
- char *token, *value_true, *value_false;
-} setup_info[] =
+ int type;
+ void *value;
+ char *text;
+} token_info[] =
{
- { "sound", "on", "off" },
- { "repeating_sound_loops", "on", "off" },
- { "background_music", "on", "off" },
- { "simple_sound_effects", "on", "off" },
- { "toons", "on", "off" },
- { "double_buffering", "off", "on" },
- { "scroll_delay", "on", "off" },
- { "soft_scrolling", "on", "off" },
- { "screen_fading", "on", "off" },
- { "automatic_tape_recording", "on", "off" },
- { "quick_doors", "on", "off" },
+ { TYPE_SWITCH, &si.sound, "sound" },
+ { TYPE_SWITCH, &si.sound_loops, "repeating_sound_loops" },
+ { TYPE_SWITCH, &si.sound_music, "background_music" },
+ { TYPE_SWITCH, &si.sound_simple, "simple_sound_effects" },
+ { TYPE_SWITCH, &si.toons, "toons" },
+ { TYPE_SWITCH, &si.double_buffering, "double_buffering" },
+ { TYPE_SWITCH, &si.scroll_delay, "scroll_delay" },
+ { TYPE_SWITCH, &si.soft_scrolling, "soft_scrolling" },
+ { TYPE_SWITCH, &si.fading, "screen_fading" },
+ { TYPE_SWITCH, &si.autorecord, "automatic_tape_recording" },
+ { TYPE_SWITCH, &si.quick_doors, "quick_doors" },
+ { TYPE_STRING, &si.alias_name, "alias_name" },
/* for each player: */
- { ".use_joystick", "true", "false" },
- { ".joystick_device", "second", "first" },
- { ".joy.snap_field", "", "" },
- { ".joy.place_bomb", "", "" },
- { ".key.move_left", "", "" },
- { ".key.move_right", "", "" },
- { ".key.move_up", "", "" },
- { ".key.move_down", "", "" },
- { ".key.snap_field", "", "" },
- { ".key.place_bomb", "", "" }
+ { TYPE_BOOLEAN, &sii.use_joystick, ".use_joystick" },
+ { TYPE_STRING, &sii.joy.device_name, ".joy.device_name" },
+ { TYPE_INTEGER, &sii.joy.xleft, ".joy.xleft" },
+ { TYPE_INTEGER, &sii.joy.xmiddle, ".joy.xmiddle" },
+ { TYPE_INTEGER, &sii.joy.xright, ".joy.xright" },
+ { TYPE_INTEGER, &sii.joy.yupper, ".joy.yupper" },
+ { TYPE_INTEGER, &sii.joy.ymiddle, ".joy.ymiddle" },
+ { TYPE_INTEGER, &sii.joy.ylower, ".joy.ylower" },
+ { TYPE_INTEGER, &sii.joy.snap, ".joy.snap_field" },
+ { TYPE_INTEGER, &sii.joy.bomb, ".joy.place_bomb" },
+ { TYPE_KEYSYM, &sii.key.left, ".key.move_left" },
+ { TYPE_KEYSYM, &sii.key.right, ".key.move_right" },
+ { TYPE_KEYSYM, &sii.key.up, ".key.move_up" },
+ { TYPE_KEYSYM, &sii.key.down, ".key.move_down" },
+ { TYPE_KEYSYM, &sii.key.snap, ".key.snap_field" },
+ { TYPE_KEYSYM, &sii.key.bomb, ".key.place_bomb" }
};
static char *string_tolower(char *s)
if (strcmp(string_tolower(s), number_text[i][j]) == 0)
return i;
- return -1;
+ return atoi(s);
}
static boolean get_string_boolean_value(char *s)
return FALSE;
}
+
+
+#if 0
+
static char *getSetupToken(int token_nr)
{
- return setup_info[token_nr].token;
+ return token_info[token_nr].text;
}
static char *getSetupValue(int token_nr, boolean token_value)
{
+ return (token_value == TRUE ? "true" : "false");
+
+ /*
if (token_value == TRUE)
- return setup_info[token_nr].value_true;
+ return token_info[token_nr].value_true;
else
- return setup_info[token_nr].value_false;
+ return token_info[token_nr].value_false;
+ */
+
}
+#endif
+
+
+
static char *getFormattedSetupEntry(char *token, char *value)
{
int i;
return entry;
}
+
+
+#if 0
+
static char *getSetupEntry(char *prefix, int token_nr, int token_value)
{
int i;
return entry;
}
+#endif
+
+
static void freeSetupFileList(struct SetupFileList *setup_file_list)
{
if (!setup_file_list)
struct SetupFileList *setup_file_list = newSetupFileList("", "");
struct SetupFileList *first_valid_list_entry;
-
-
- /*
- struct SetupFileList **next_entry = &setup_file_list;
- */
-
-
FILE *file;
if (!(file = fopen(filename, "r")))
if (*token && *value)
updateSetupFileListEntry(setup_file_list, token, value);
-
-
-#if 0
- {
- /* allocate new token/value pair */
-
- *next_entry = newSetupFileList(token, value);
- next_entry = &((*next_entry)->next);
- }
-#endif
-
-
-
}
fclose(file);
int player_nr = 0;
char *token;
char *token_value;
- int token_integer_value;
boolean token_boolean_value;
+ int token_integer_value;
int token_player_prefix_len;
if (!setup_file_list)
token = setup_file_list->token;
token_value = setup_file_list->value;
- token_integer_value = get_string_integer_value(token_value);
token_boolean_value = get_string_boolean_value(token_value);
+ token_integer_value = get_string_integer_value(token_value);
token_player_prefix_len = strlen(TOKEN_STR_PLAYER_PREFIX);
for (i=0; i<NUM_SETUP_TOKENS; i++)
{
- if (strcmp(token, setup_info[i].token) == 0)
+ if (strcmp(token, token_info[i].text) == 0)
{
token_nr = i;
break;
switch (token_nr)
{
case SETUP_TOKEN_SOUND:
- setup.sound_on = token_boolean_value;
+ setup.sound = token_boolean_value;
break;
case SETUP_TOKEN_SOUND_LOOPS:
- setup.sound_loops_on = token_boolean_value;
+ setup.sound_loops = token_boolean_value;
break;
case SETUP_TOKEN_SOUND_MUSIC:
- setup.sound_music_on = token_boolean_value;
+ setup.sound_music = token_boolean_value;
break;
case SETUP_TOKEN_SOUND_SIMPLE:
- setup.sound_simple_on = token_boolean_value;
+ setup.sound_simple = token_boolean_value;
break;
case SETUP_TOKEN_TOONS:
- setup.toons_on = token_boolean_value;
+ setup.toons = token_boolean_value;
break;
- case SETUP_TOKEN_DIRECT_DRAW:
- setup.direct_draw_on = !token_boolean_value;
+ case SETUP_TOKEN_DOUBLE_BUFFERING:
+ setup.double_buffering = token_boolean_value;
break;
case SETUP_TOKEN_SCROLL_DELAY:
- setup.scroll_delay_on = token_boolean_value;
+ setup.scroll_delay = token_boolean_value;
break;
case SETUP_TOKEN_SOFT_SCROLLING:
- setup.soft_scrolling_on = token_boolean_value;
+ setup.soft_scrolling = token_boolean_value;
break;
case SETUP_TOKEN_FADING:
- setup.fading_on = token_boolean_value;
+ setup.fading = token_boolean_value;
break;
case SETUP_TOKEN_AUTORECORD:
- setup.autorecord_on = token_boolean_value;
+ setup.autorecord = token_boolean_value;
break;
case SETUP_TOKEN_QUICK_DOORS:
setup.quick_doors = token_boolean_value;
break;
+ case SETUP_TOKEN_ALIAS_NAME:
+ strncpy(setup.alias_name, token_value, MAX_NAMELEN-1);
+ setup.alias_name[MAX_NAMELEN-1] = '\0';
+ break;
+
case SETUP_TOKEN_USE_JOYSTICK:
setup.input[player_nr].use_joystick = token_boolean_value;
break;
- case SETUP_TOKEN_JOYSTICK_NR:
- if (token_integer_value < 0 || token_integer_value > 1)
- token_integer_value = 1;
- setup.input[player_nr].joystick_nr = token_integer_value - 1;
+ case SETUP_TOKEN_JOY_DEVICE_NAME:
+ strncpy(setup.input[player_nr].joy.device_name, token_value,
+ MAX_FILENAME_LEN-1);
+ setup.input[player_nr].joy.device_name[MAX_FILENAME_LEN-1] = '\0';
break;
case SETUP_TOKEN_JOY_SNAP:
setup.input[player_nr].joy.snap = getJoySymbolFromJoyName(token_value);
break;
- case SETUP_TOKEN_JOY_BOMB :
+ case SETUP_TOKEN_JOY_XLEFT:
+ setup.input[player_nr].joy.xleft = token_integer_value;
+ break;
+ case SETUP_TOKEN_JOY_XMIDDLE:
+ setup.input[player_nr].joy.xmiddle = token_integer_value;
+ break;
+ case SETUP_TOKEN_JOY_XRIGHT:
+ setup.input[player_nr].joy.xright = token_integer_value;
+ break;
+ case SETUP_TOKEN_JOY_YUPPER:
+ setup.input[player_nr].joy.yupper = token_integer_value;
+ break;
+ case SETUP_TOKEN_JOY_YMIDDLE:
+ setup.input[player_nr].joy.ymiddle = token_integer_value;
+ break;
+ case SETUP_TOKEN_JOY_YLOWER:
+ setup.input[player_nr].joy.ylower = token_integer_value;
+ break;
+ case SETUP_TOKEN_JOY_BOMB:
setup.input[player_nr].joy.bomb = getJoySymbolFromJoyName(token_value);
break;
case SETUP_TOKEN_KEY_LEFT:
setup.input[player_nr].key.bomb = getKeySymFromX11KeyName(token_value);
break;
- case SETUP_TOKEN_ALIAS_NAME:
- strncpy(local_player->alias_name, token_value, MAX_NAMELEN-1);
- local_player->alias_name[MAX_NAMELEN-1] = '\0';
- break;
-
case TOKEN_INVALID:
Error(ERR_WARN, "unknown token '%s' not recognized", token);
break;
decodeSetupFileList(setup_file_list->next);
}
+int getLevelSeriesNrFromLevelSeriesName(char *level_series_name)
+{
+ int i;
+
+ if (!level_series_name)
+ return 0;
+
+ for (i=0; i<num_leveldirs; i++)
+ if (strcmp(level_series_name, leveldir[i].filename) == 0)
+ return i;
+
+ return 0;
+}
+
+int getLastPlayedLevelOfLevelSeries(char *level_series_name)
+{
+ char *token_value;
+ int level_series_nr = getLevelSeriesNrFromLevelSeriesName(level_series_name);
+ int last_level_nr = 0;
+
+ if (!level_series_name)
+ return 0;
+
+ token_value = getSetupFileListEntry(level_setup_list, level_series_name);
+
+ if (token_value)
+ {
+ int highest_level_nr = leveldir[level_series_nr].levels - 1;
+
+ last_level_nr = atoi(token_value);
+
+ if (last_level_nr < 0)
+ last_level_nr = 0;
+ if (last_level_nr > highest_level_nr)
+ last_level_nr = highest_level_nr;
+ }
+
+ return last_level_nr;
+}
+
void LoadSetup()
{
int i;
/* always start with reliable default setup values */
- strncpy(local_player->login_name, GetLoginName(), MAX_NAMELEN-1);
- local_player->login_name[MAX_NAMELEN-1] = '\0';
-
- strncpy(local_player->alias_name, GetLoginName(), MAX_NAMELEN-1);
- local_player->alias_name[MAX_NAMELEN-1] = '\0';
-
- setup.sound_on = TRUE;
- setup.sound_loops_on = FALSE;
- setup.sound_music_on = FALSE;
- setup.sound_simple_on = FALSE;
- setup.toons_on = TRUE;
- setup.direct_draw_on = FALSE;
- setup.scroll_delay_on = FALSE;
- setup.soft_scrolling_on = TRUE;
- setup.fading_on = FALSE;
- setup.autorecord_on = FALSE;
+ setup.sound = TRUE;
+ setup.sound_loops = FALSE;
+ setup.sound_music = FALSE;
+ setup.sound_simple = FALSE;
+ setup.toons = TRUE;
+ setup.double_buffering = TRUE;
+ setup.direct_draw = !setup.double_buffering;
+ setup.scroll_delay = FALSE;
+ setup.soft_scrolling = TRUE;
+ setup.fading = FALSE;
+ setup.autorecord = FALSE;
setup.quick_doors = FALSE;
+ strncpy(setup.login_name, GetLoginName(), MAX_NAMELEN-1);
+ setup.login_name[MAX_NAMELEN-1] = '\0';
+ strncpy(setup.alias_name, GetLoginName(), MAX_NAMELEN-1);
+ setup.alias_name[MAX_NAMELEN-1] = '\0';
+
for (i=0; i<MAX_PLAYERS; i++)
{
setup.input[i].use_joystick = FALSE;
- setup.input[i].joystick_nr = 0;
+ strcpy(setup.input[i].joy.device_name, joystick_device_name[i]);
+ setup.input[i].joy.xleft = JOYSTICK_XLEFT;
+ setup.input[i].joy.xmiddle = JOYSTICK_XMIDDLE;
+ setup.input[i].joy.xright = JOYSTICK_XRIGHT;
+ setup.input[i].joy.yupper = JOYSTICK_YUPPER;
+ setup.input[i].joy.ymiddle = JOYSTICK_YMIDDLE;
+ setup.input[i].joy.ylower = JOYSTICK_YLOWER;
setup.input[i].joy.snap = (i == 0 ? JOY_BUTTON_1 : 0);
setup.input[i].joy.bomb = (i == 0 ? JOY_BUTTON_2 : 0);
setup.input[i].key.left = (i == 0 ? DEFAULT_KEY_LEFT : KEY_UNDEFINDED);
checkSetupFileListIdentifier(setup_file_list, SETUP_COOKIE);
decodeSetupFileList(setup_file_list);
+ setup.direct_draw = !setup.double_buffering;
+
freeSetupFileList(setup_file_list);
}
else
- Error(ERR_RETURN, "using default setup values");
+ Error(ERR_WARN, "using default setup values");
}
-void LoadLevelSetup()
-{
- char filename[MAX_FILENAME_LEN];
-
- /* always start with reliable default setup values */
-
- leveldir_nr = 0;
- level_nr = 0;
-
- sprintf(filename, "%s/%s", SETUP_PATH, LEVELSETUP_FILENAME);
-
- if (level_setup_list)
- freeSetupFileList(level_setup_list);
-
- level_setup_list = loadSetupFileList(filename);
-
- if (level_setup_list)
- {
- int i;
-
- char *last_level_series =
- getSetupFileListEntry(level_setup_list, TOKEN_STR_LAST_LEVEL_SERIES);
-
- if (last_level_series)
- {
- for (i=0; i<num_leveldirs; i++)
- {
- if (strcmp(last_level_series, leveldir[i].filename) == 0)
- {
- char *token_value =
- getSetupFileListEntry(level_setup_list, last_level_series);
-
- leveldir_nr = i;
-
- if (token_value)
- {
- level_nr = atoi(token_value);
-
- if (level_nr < 0)
- level_nr = 0;
- if (level_nr > leveldir[leveldir_nr].levels - 1)
- level_nr = leveldir[leveldir_nr].levels - 1;
- }
-
- break;
- }
- }
- }
-
#if 0
- printSetupFileList(level_setup_list);
-#endif
-
- checkSetupFileListIdentifier(level_setup_list, LEVELSETUP_COOKIE);
- }
- else
- Error(ERR_RETURN, "using default setup values");
-}
void SaveSetup()
{
fprintf(file, "%s\n",
getSetupEntry("", SETUP_TOKEN_SOUND,
- setup.sound_on));
+ setup.sound));
fprintf(file, "%s\n",
getSetupEntry("", SETUP_TOKEN_SOUND_LOOPS,
- setup.sound_loops_on));
+ setup.sound_loops));
fprintf(file, "%s\n",
getSetupEntry("", SETUP_TOKEN_SOUND_MUSIC,
- setup.sound_music_on));
+ setup.sound_music));
fprintf(file, "%s\n",
getSetupEntry("", SETUP_TOKEN_SOUND_SIMPLE,
- setup.sound_simple_on));
+ setup.sound_simple));
fprintf(file, "%s\n",
getSetupEntry("", SETUP_TOKEN_TOONS,
- setup.toons_on));
+ setup.toons));
fprintf(file, "%s\n",
getSetupEntry("", SETUP_TOKEN_DIRECT_DRAW,
- setup.direct_draw_on));
+ setup.direct_draw));
fprintf(file, "%s\n",
getSetupEntry("", SETUP_TOKEN_SCROLL_DELAY,
- setup.scroll_delay_on));
+ setup.scroll_delay));
fprintf(file, "%s\n",
getSetupEntry("", SETUP_TOKEN_SOFT_SCROLLING,
- setup.soft_scrolling_on));
+ setup.soft_scrolling));
fprintf(file, "%s\n",
getSetupEntry("", SETUP_TOKEN_FADING,
- setup.fading_on));
+ setup.fading));
fprintf(file, "%s\n",
getSetupEntry("", SETUP_TOKEN_AUTORECORD,
- setup.autorecord_on));
+ setup.autorecord));
fprintf(file, "%s\n",
getSetupEntry("", SETUP_TOKEN_QUICK_DOORS,
setup.quick_doors));
fprintf(file, "%s\n",
getFormattedSetupEntry(TOKEN_STR_ALIAS_NAME,
- local_player->alias_name));
+ setup.alias_name));
for (i=0; i<MAX_PLAYERS; i++)
{
fprintf(file, "%s\n",
getSetupEntry(prefix, SETUP_TOKEN_USE_JOYSTICK,
setup.input[i].use_joystick));
- fprintf(file, "%s\n",
- getSetupEntry(prefix, SETUP_TOKEN_JOYSTICK_NR,
- setup.input[i].joystick_nr));
+ fprintf(file, "%s%s: %s\n", prefix,
+ getSetupToken(SETUP_TOKEN_JOY_DEVICE_NAME),
+ setup.input[i].joy.device_name);
+
+ fprintf(file, "%s%s: %d\n", prefix,
+ getSetupToken(SETUP_TOKEN_JOY_XLEFT),
+ setup.input[i].joy.xleft);
+ fprintf(file, "%s%s: %d\n", prefix,
+ getSetupToken(SETUP_TOKEN_JOY_XMIDDLE),
+ setup.input[i].joy.xmiddle);
+ fprintf(file, "%s%s: %d\n", prefix,
+ getSetupToken(SETUP_TOKEN_JOY_XRIGHT),
+ setup.input[i].joy.xright);
+ fprintf(file, "%s%s: %d\n", prefix,
+ getSetupToken(SETUP_TOKEN_JOY_YUPPER),
+ setup.input[i].joy.yupper);
+ fprintf(file, "%s%s: %d\n", prefix,
+ getSetupToken(SETUP_TOKEN_JOY_YMIDDLE),
+ setup.input[i].joy.ymiddle);
+ fprintf(file, "%s%s: %d\n", prefix,
+ getSetupToken(SETUP_TOKEN_JOY_YLOWER),
+ setup.input[i].joy.ylower);
fprintf(file, "%s%s: %s\n", prefix,
getSetupToken(SETUP_TOKEN_JOY_SNAP),
getJoyNameFromJoySymbol(setup.input[i].joy.snap));
chmod(filename, SETUP_PERMS);
}
+#endif
+
+
+
+static char *getSetupLine(char *prefix, int token_nr)
+{
+ int i;
+ static char entry[MAX_LINE_LEN];
+ int token_type = token_info[token_nr].type;
+ void *token_value = token_info[token_nr].value;
+ char *token_text = token_info[token_nr].text;
+
+ /* start with the prefix, token and some spaces to format output line */
+ sprintf(entry, "%s%s:", prefix, token_text);
+ for (i=strlen(entry); i<TOKEN_VALUE_POSITION; i++)
+ strcat(entry, " ");
+
+ /* continue with the token's value (which can have different types) */
+ switch (token_type)
+ {
+ case TYPE_BOOLEAN:
+ strcat(entry, (*(boolean *)token_value ? "true" : "false"));
+ break;
+
+ case TYPE_SWITCH:
+ strcat(entry, (*(boolean *)token_value ? "on" : "off"));
+ break;
+
+ case TYPE_KEYSYM:
+ {
+ KeySym keysym = *(KeySym *)token_value;
+ char *keyname = getKeyNameFromKeySym(keysym);
+
+ strcat(entry, getX11KeyNameFromKeySym(keysym));
+ for (i=strlen(entry); i<50; i++)
+ strcat(entry, " ");
+
+ /* add comment, if useful */
+ if (strcmp(keyname, "(undefined)") != 0 &&
+ strcmp(keyname, "(unknown)") != 0)
+ {
+ strcat(entry, "# ");
+ strcat(entry, keyname);
+ }
+ }
+ break;
+
+ case TYPE_INTEGER:
+ {
+ char buffer[MAX_LINE_LEN];
+
+ sprintf(buffer, "%d", *(int *)token_value);
+ strcat(entry, buffer);
+ }
+ break;
+
+ case TYPE_STRING:
+ strcat(entry, *(char **)token_value);
+ break;
+
+ default:
+ break;
+ }
+
+ return entry;
+}
+
+void SaveSetup()
+{
+ int i, pnr;
+ char filename[MAX_FILENAME_LEN];
+ FILE *file;
+
+ sprintf(filename, "%s/%s", SETUP_PATH, SETUP_FILENAME);
+
+ if (!(file = fopen(filename, "w")))
+ {
+ Error(ERR_WARN, "cannot write setup file '%s'", filename);
+ return;
+ }
+
+ fprintf(file, "%s: %s\n",
+ TOKEN_STR_FILE_IDENTIFIER, SETUP_COOKIE);
+
+ fprintf(file, "\n");
+
+ for (i=FIRST_GLOBAL_SETUP_TOKEN; i<=LAST_GLOBAL_SETUP_TOKEN; i++)
+ fprintf(file, "%s\n", getSetupLine("", i));
+
+ for (pnr=0; pnr<MAX_PLAYERS; pnr++)
+ {
+ char prefix[30];
+
+ sprintf(prefix, "%s%d", TOKEN_STR_PLAYER_PREFIX, i + 1);
+ fprintf(file, "\n");
+
+ for (i=FIRST_PLAYER_SETUP_TOKEN; i<=LAST_PLAYER_SETUP_TOKEN; i++)
+ {
+ sii = setup.input[pnr];
+ fprintf(file, "%s\n", getSetupLine(prefix, i));
+ }
+ }
+
+ fclose(file);
+
+ chmod(filename, SETUP_PERMS);
+}
+
+void LoadLevelSetup()
+{
+ char filename[MAX_FILENAME_LEN];
+
+ /* always start with reliable default setup values */
+
+ leveldir_nr = 0;
+ level_nr = 0;
+
+ sprintf(filename, "%s/%s", SETUP_PATH, LEVELSETUP_FILENAME);
+
+ if (level_setup_list)
+ freeSetupFileList(level_setup_list);
+
+ level_setup_list = loadSetupFileList(filename);
+
+ if (level_setup_list)
+ {
+ char *last_level_series =
+ getSetupFileListEntry(level_setup_list, TOKEN_STR_LAST_LEVEL_SERIES);
+
+ leveldir_nr = getLevelSeriesNrFromLevelSeriesName(last_level_series);
+ level_nr = getLastPlayedLevelOfLevelSeries(last_level_series);
+
+#if 0
+ printSetupFileList(level_setup_list);
+#endif
+
+ checkSetupFileListIdentifier(level_setup_list, LEVELSETUP_COOKIE);
+ }
+ else
+ Error(ERR_WARN, "using default setup values");
+}
+
void SaveLevelSetup()
{
char filename[MAX_FILENAME_LEN];
#include "main.h"
boolean LoadLevelInfo(void);
+
void LoadLevel(int);
void SaveLevel(int);
+
void LoadLevelTape(int);
void SaveLevelTape(int);
void LoadScore(int);
void SaveScore(int);
+
+
+#if 0
+
void LoadJoystickData(void);
void SaveJoystickData(void);
+#endif
+
+
+
+int getLastPlayedLevelOfLevelSeries(char *);
+
void LoadSetup(void);
-void LoadLevelSetup(void);
void SaveSetup(void);
+
+void LoadLevelSetup(void);
void SaveLevelSetup(void);
#endif /* FILES_H */
void GetPlayerConfig()
{
- int old_joystick_nr = setup.input[0].joystick_nr;
-
if (sound_status == SOUND_OFF)
- setup.sound_on = FALSE;
+ setup.sound = FALSE;
if (!sound_loops_allowed)
{
- setup.sound_loops_on = FALSE;
- setup.sound_music_on = FALSE;
+ setup.sound_loops = FALSE;
+ setup.sound_music = FALSE;
}
- setup.sound_simple_on = setup.sound_on;
+ setup.sound_simple = setup.sound;
-#ifndef MSDOS
- if (setup.input[0].joystick_nr != old_joystick_nr)
- {
- if (joystick_device)
- close(joystick_device);
- InitJoystick();
- }
-#endif
+ InitJoysticks();
}
void InitGame()
DrawGameButton(BUTTON_GAME_STOP);
DrawGameButton(BUTTON_GAME_PAUSE);
DrawGameButton(BUTTON_GAME_PLAY);
- DrawSoundDisplay(BUTTON_SOUND_MUSIC | (BUTTON_ON * setup.sound_music_on));
- DrawSoundDisplay(BUTTON_SOUND_LOOPS | (BUTTON_ON * setup.sound_loops_on));
- DrawSoundDisplay(BUTTON_SOUND_SIMPLE | (BUTTON_ON * setup.sound_simple_on));
+ DrawSoundDisplay(BUTTON_SOUND_MUSIC | (BUTTON_ON * setup.sound_music));
+ DrawSoundDisplay(BUTTON_SOUND_LOOPS | (BUTTON_ON * setup.sound_loops));
+ DrawSoundDisplay(BUTTON_SOUND_SIMPLE | (BUTTON_ON * setup.sound_simple));
XCopyArea(display,drawto,pix[PIX_DB_DOOR],gc,
DX+GAME_CONTROL_XPOS,DY+GAME_CONTROL_YPOS,
GAME_CONTROL_XSIZE,2*GAME_CONTROL_YSIZE,
OpenDoor(DOOR_OPEN_1);
- if (setup.sound_music_on)
+ if (setup.sound_music)
PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
XAutoRepeatOff(display);
if (TimeLeft)
{
- if (setup.sound_loops_on)
+ if (setup.sound_loops)
PlaySoundExt(SND_SIRR, PSND_MAX_VOLUME, PSND_MAX_RIGHT, PSND_LOOP);
while(TimeLeft > 0)
{
- if (!setup.sound_loops_on)
+ if (!setup.sound_loops)
PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT);
if (TimeLeft && !(TimeLeft % 10))
RaiseScore(level.score[SC_ZEITBONUS]);
Delay(10);
}
- if (setup.sound_loops_on)
+ if (setup.sound_loops)
StopSound(SND_SIRR);
}
LoadScore(level_nr);
- if (!strcmp(local_player->alias_name,EMPTY_ALIAS) ||
+ if (!strcmp(setup.alias_name,EMPTY_ALIAS) ||
local_player->score < highscore[MAX_SCORE_ENTRIES-1].Score)
return(-1);
#ifdef ONE_PER_NAME
for(l=k;l<MAX_SCORE_ENTRIES;l++)
- if (!strcmp(local_player->alias_name,highscore[l].Name))
+ if (!strcmp(setup.alias_name,highscore[l].Name))
m = l;
if (m==k) /* Spieler überschreibt seine alte Position */
goto put_into_list;
#ifdef ONE_PER_NAME
put_into_list:
#endif
- sprintf(highscore[k].Name,local_player->alias_name);
+ sprintf(highscore[k].Name,setup.alias_name);
highscore[k].Score = local_player->score;
position = k;
break;
}
#ifdef ONE_PER_NAME
- else if (!strcmp(local_player->alias_name,highscore[k].Name))
+ else if (!strcmp(setup.alias_name,highscore[k].Name))
break; /* Spieler schon mit besserer Punktzahl in der Liste */
#endif
{
MovDelay[x][y]--;
- if (setup.direct_draw_on && MovDelay[x][y])
+ if (setup.direct_draw && MovDelay[x][y])
SetDrawtoField(DRAW_BUFFERED);
DrawGraphic(SCREENX(x),SCREENY(y), el2gfx(Feld[x][y]));
DrawGraphicThruMask(SCREENX(x),SCREENY(y), GFX_FUNKELN_WEISS + phase);
- if (setup.direct_draw_on)
+ if (setup.direct_draw)
{
int dest_x,dest_y;
void ScrollLevel(int dx, int dy)
{
- int softscroll_offset = (setup.soft_scrolling_on ? TILEX : 0);
+ int softscroll_offset = (setup.soft_scrolling ? TILEX : 0);
int x,y;
- /*
- ScreenGfxPos = local_player->GfxPos;
- */
-
XCopyArea(display,drawto_field,drawto_field,gc,
FX + TILEX*(dx==-1) - softscroll_offset,
FY + TILEY*(dy==-1) - softscroll_offset,
jx = player->jx;
jy = player->jy;
-
-
- /*
- if (moved & MF_MOVING && player == local_player)
- */
-
if (moved & MF_MOVING && !ScreenMovPos &&
(player == local_player || !options.network))
{
int old_scroll_x = scroll_x, old_scroll_y = scroll_y;
- int offset = (setup.scroll_delay_on ? 3 : 0);
-
- /*
- if (player == local_player)
- {
- printf("MOVING LOCAL PLAYER && SCROLLING\n");
- }
- */
+ int offset = (setup.scroll_delay ? 3 : 0);
if (!IN_VIS_FIELD(SCREENX(jx),SCREENY(jy)))
{
{
if (jx != old_jx) /* player has moved horizontally */
{
- /*
- if ((scroll_x < jx-MIDPOSX-offset || scroll_x > jx-MIDPOSX+offset) &&
- jx >= MIDPOSX-1-offset && jx <= lev_fieldx-(MIDPOSX-offset))
- scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : +offset);
- */
-
if ((player->MovDir == MV_LEFT && scroll_x > jx-MIDPOSX+offset) ||
(player->MovDir == MV_RIGHT && scroll_x < jx-MIDPOSX-offset))
scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : +offset);
}
else /* player has moved vertically */
{
- /*
- if ((scroll_y < jy-MIDPOSY-offset || scroll_y > jy-MIDPOSY+offset) &&
- jy >= MIDPOSY-1-offset && jy <= lev_fieldy-(MIDPOSY-offset))
- scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : +offset);
- */
-
if ((player->MovDir == MV_UP && scroll_y > jy-MIDPOSY+offset) ||
(player->MovDir == MV_DOWN && scroll_y < jy-MIDPOSY-offset))
scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : +offset);
}
}
-#if 0
- if (player == local_player)
- {
- if ((scroll_x < jx-MIDPOSX-offset || scroll_x > jx-MIDPOSX+offset) &&
- jx >= MIDPOSX-1-offset && jx <= lev_fieldx-(MIDPOSX-offset))
- scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : offset);
- if ((scroll_y < jy-MIDPOSY-offset || scroll_y > jy-MIDPOSY+offset) &&
- jy >= MIDPOSY-1-offset && jy <= lev_fieldy-(MIDPOSY-offset))
- scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : offset);
-
- /* don't scroll more than one field at a time */
- scroll_x = old_scroll_x + SIGN(scroll_x - old_scroll_x);
- scroll_y = old_scroll_y + SIGN(scroll_y - old_scroll_y);
- }
-#endif
-
if (scroll_x != old_scroll_x || scroll_y != old_scroll_y)
{
if (!options.network && !AllPlayersInVisibleScreen())
void TestIfBadThingHitsHero(int x, int y)
{
- /*
- TestIfGoodThingHitsBadThing(JX,JY);
- */
-
TestIfBadThingHitsGoodThing(x,y);
}
int volume, stereo;
int silence_distance = 8;
- if ((!setup.sound_simple_on && !IS_LOOP_SOUND(sound_nr)) ||
- (!setup.sound_loops_on && IS_LOOP_SOUND(sound_nr)))
+ if ((!setup.sound_simple && !IS_LOOP_SOUND(sound_nr)) ||
+ (!setup.sound_loops && IS_LOOP_SOUND(sound_nr)))
return;
if (!IN_LEV_FIELD(x,y) ||
return;
volume = PSND_MAX_VOLUME;
+
#ifndef MSDOS
stereo = (sx-SCR_FIELDX/2)*12;
#else
InitCounter();
InitSound();
InitSoundServer();
- InitJoystick();
+ InitJoysticks();
InitRND(NEW_RANDOMIZE);
signal(SIGINT, CloseAllAndExit);
/* choose default local player */
local_player = &stored_player[0];
+
for (i=0; i<MAX_PLAYERS; i++)
+ {
+ stored_player[i].joystick_fd = -1; /* joystick device closed */
stored_player[i].connected = FALSE;
+ }
+
local_player->connected = TRUE;
if (!LoadLevelInfo()) /* global level info */
if (!ConnectToServer(options.server_host, options.server_port))
Error(ERR_EXIT, "cannot connect to multiplayer server");
- SendToServer_Nickname(local_player->alias_name);
+ SendToServer_Nickname(setup.alias_name);
SendToServer_ProtocolVersion();
if (nr_wanted)
#endif
}
-void InitJoystick()
+void InitJoysticks()
{
- int joystick_nr = setup.input[0].joystick_nr;
+ int i;
if (global_joystick_status == JOYSTICK_OFF)
return;
+ joystick_status = JOYSTICK_OFF;
+
#ifndef MSDOS
- if (access(joystick_device_name[joystick_nr], R_OK) < 0)
+ for (i=0; i<MAX_PLAYERS; i++)
{
- Error(ERR_WARN, "cannot access joystick device '%s'",
- joystick_device_name[joystick_nr]);
- joystick_status = JOYSTICK_OFF;
- return;
- }
+ char *device_name = setup.input[i].joy.device_name;
- if ((joystick_device =
- open(joystick_device_name[joystick_nr], O_RDONLY)) < 0)
- {
- Error(ERR_WARN, "cannot open joystick device '%s'",
- joystick_device_name[joystick_nr]);
- joystick_status = JOYSTICK_OFF;
- return;
- }
+ /* this allows subsequent calls to 'InitJoysticks' for re-initialization */
+ if (stored_player[i].joystick_fd != -1)
+ {
+ close(stored_player[i].joystick_fd);
+ stored_player[i].joystick_fd = -1;
+ }
- joystick_status = JOYSTICK_AVAILABLE;
- LoadJoystickData();
+ if (!setup.input[i].use_joystick)
+ continue;
+
+ if (access(device_name, R_OK) < 0)
+ {
+ Error(ERR_WARN, "cannot access joystick device '%s'", device_name);
+ continue;
+ }
+
+ if ((stored_player[i].joystick_fd = open(device_name, O_RDONLY)) < 0)
+ {
+ Error(ERR_WARN, "cannot open joystick device '%s'", device_name);
+ continue;
+ }
+
+ joystick_status = JOYSTICK_AVAILABLE;
+ }
#else
joystick_status = JOYSTICK_AVAILABLE;
#endif
void OpenAll(int, char **);
void CloseAllAndExit(int);
-void InitJoystick(void);
+void InitJoysticks(void);
#endif
int i;
int distance = 100;
- for(i=0;i<2;i++)
+ for(i=0; i<MAX_PLAYERS; i++)
{
- if (joystick[i].xmiddle <= distance)
- joystick[i].xmiddle = distance;
- if (joystick[i].ymiddle <= distance)
- joystick[i].ymiddle = distance;
-
- if (joystick[i].xleft >= joystick[i].xmiddle)
- joystick[i].xleft = joystick[i].xmiddle-distance;
- if (joystick[i].xright <= joystick[i].xmiddle)
- joystick[i].xright = joystick[i].xmiddle+distance;
-
- if (joystick[i].yupper >= joystick[i].ymiddle)
- joystick[i].yupper = joystick[i].ymiddle-distance;
- if (joystick[i].ylower <= joystick[i].ymiddle)
- joystick[i].ylower = joystick[i].ymiddle+distance;
+ if (setup.input[i].joy.xmiddle <= distance)
+ setup.input[i].joy.xmiddle = distance;
+ if (setup.input[i].joy.ymiddle <= distance)
+ setup.input[i].joy.ymiddle = distance;
+
+ if (setup.input[i].joy.xleft >= setup.input[i].joy.xmiddle)
+ setup.input[i].joy.xleft = setup.input[i].joy.xmiddle - distance;
+ if (setup.input[i].joy.xright <= setup.input[i].joy.xmiddle)
+ setup.input[i].joy.xright = setup.input[i].joy.xmiddle + distance;
+
+ if (setup.input[i].joy.yupper >= setup.input[i].joy.ymiddle)
+ setup.input[i].joy.yupper = setup.input[i].joy.ymiddle - distance;
+ if (setup.input[i].joy.ylower <= setup.input[i].joy.ymiddle)
+ setup.input[i].joy.ylower = setup.input[i].joy.ymiddle + distance;
}
}
-int JoystickPosition(int middle, int margin, int actual)
+static int JoystickPosition(int middle, int margin, int actual)
{
long range, pos;
int percentage;
- if (margin<middle && actual>middle)
- return(0);
- if (margin>middle && actual<middle)
- return(0);
+ if (margin < middle && actual > middle)
+ return 0;
+ if (margin > middle && actual < middle)
+ return 0;
- range = ABS(margin-middle);
- pos = ABS(actual-middle);
- percentage = (int)(pos*100/range);
- if (percentage>100)
+ range = ABS(margin - middle);
+ pos = ABS(actual - middle);
+ percentage = (int)(pos * 100 / range);
+
+ if (percentage > 100)
percentage = 100;
- return(percentage);
+ return percentage;
}
-int Joystick()
+int Joystick(int player_nr)
{
#ifdef __FreeBSD__
struct joystick joy_ctrl;
} joy_ctrl;
#endif
- int joystick_nr = setup.input[0].joystick_nr;
+ int joystick_fd = stored_player[player_nr].joystick_fd;
int js_x,js_y, js_b1,js_b2;
int left, right, up, down;
- int result=0;
+ int result = 0;
+
+ if (joystick_status == JOYSTICK_OFF)
+ return 0;
- if (joystick_status==JOYSTICK_OFF)
- return(0);
+ if (!setup.input[player_nr].use_joystick || joystick_fd < 0)
+ return 0;
#ifndef MSDOS
- if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
+ if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
{
- Error(ERR_WARN, "cannot read joystick settings - no joystick support");
+ Error(ERR_WARN, "cannot read joystick device '%s'",
+ setup.input[player_nr].joy.device_name);
joystick_status = JOYSTICK_OFF;
- return(0);
+ return 0;
}
js_x = joy_ctrl.x;
js_y = joy_ctrl.y;
+
#ifdef __FreeBSD__
js_b1 = joy_ctrl.b1;
js_b2 = joy_ctrl.b2;
js_b2 = joy_ctrl.buttons & 2;
#endif
- left = JoystickPosition(joystick[joystick_nr].xmiddle,
- joystick[joystick_nr].xleft, js_x);
- right = JoystickPosition(joystick[joystick_nr].xmiddle,
- joystick[joystick_nr].xright, js_x);
- up = JoystickPosition(joystick[joystick_nr].ymiddle,
- joystick[joystick_nr].yupper, js_y);
- down = JoystickPosition(joystick[joystick_nr].ymiddle,
- joystick[joystick_nr].ylower, js_y);
+ left = JoystickPosition(setup.input[player_nr].joy.xmiddle,
+ setup.input[player_nr].joy.xleft, js_x);
+ right = JoystickPosition(setup.input[player_nr].joy.xmiddle,
+ setup.input[player_nr].joy.xright, js_x);
+ up = JoystickPosition(setup.input[player_nr].joy.ymiddle,
+ setup.input[player_nr].joy.yupper, js_y);
+ down = JoystickPosition(setup.input[player_nr].joy.ymiddle,
+ setup.input[player_nr].joy.ylower, js_y);
- if (left>JOYSTICK_PERCENT)
+ if (left > JOYSTICK_PERCENT)
result |= JOY_LEFT;
- else if (right>JOYSTICK_PERCENT)
+ else if (right > JOYSTICK_PERCENT)
result |= JOY_RIGHT;
- if (up>JOYSTICK_PERCENT)
+ if (up > JOYSTICK_PERCENT)
result |= JOY_UP;
- else if (down>JOYSTICK_PERCENT)
+ else if (down > JOYSTICK_PERCENT)
result |= JOY_DOWN;
+
if (js_b1)
result |= JOY_BUTTON_1;
if (js_b2)
result |= JOY_BUTTON_2;
- return(result);
+ return result;
#else
- return(0);
+ return 0;
#endif
}
-int JoystickButton()
+int JoystickButton(int player_nr)
{
static int last_joy_button = 0;
- int joy_button = (Joystick() & JOY_BUTTON);
+ int joy_button = (Joystick(player_nr) & JOY_BUTTON);
int result;
if (joy_button)
}
last_joy_button = joy_button;
- return(result);
+ return result;
+}
+
+int AnyJoystick()
+{
+ int i;
+ int result = 0;
+
+ for (i=0; i<MAX_PLAYERS; i++)
+ {
+ if (!setup.input[i].use_joystick)
+ continue;
+
+ result |= Joystick(i);
+ }
+
+ return result;
+}
+
+int AnyJoystickButton()
+{
+ int i;
+ int result = 0;
+
+ for (i=0; i<MAX_PLAYERS; i++)
+ {
+ if (!setup.input[i].use_joystick)
+ continue;
+
+ result |= JoystickButton(i);
+ }
+
+ return result;
}
#include <machine/joystick.h>
#define DEV_JOYSTICK_0 "/dev/joy0"
#define DEV_JOYSTICK_1 "/dev/joy1"
+#define DEV_JOYSTICK_2 "/dev/joy2"
+#define DEV_JOYSTICK_3 "/dev/joy3"
#else
#define DEV_JOYSTICK_0 "/dev/js0"
#define DEV_JOYSTICK_1 "/dev/js1"
+#define DEV_JOYSTICK_2 "/dev/js2"
+#define DEV_JOYSTICK_3 "/dev/js3"
#endif
/* get these values from the program 'js' from the joystick package, */
/* set JOYSTICK_PERCENT to a threshold appropriate for your joystick */
#define JOYSTICK_XLEFT 30
-#define JOYSTICK_XRIGHT 1250
#define JOYSTICK_XMIDDLE 530
+#define JOYSTICK_XRIGHT 1250
#define JOYSTICK_YUPPER 40
-#define JOYSTICK_YLOWER 1440
#define JOYSTICK_YMIDDLE 680
+#define JOYSTICK_YLOWER 1440
+
#define JOYSTICK_PERCENT 25
+
#define JOY_LEFT MV_LEFT
#define JOY_RIGHT MV_RIGHT
#define JOY_UP MV_UP
#define JOY_BUTTON_1 (1<<4)
#define JOY_BUTTON_2 (1<<5)
#define JOY_BUTTON (JOY_BUTTON_1 | JOY_BUTTON_2)
+
#define JOY_BUTTON_NOT_PRESSED 0
#define JOY_BUTTON_PRESSED 1
#define JOY_BUTTON_NEW_PRESSED 2
void CheckJoystickData(void);
-int JoystickPosition(int, int, int);
-int Joystick(void);
-int JoystickButton(void);
+int Joystick(int);
+int JoystickButton(int);
+int AnyJoystick(void);
+int AnyJoystickButton(void);
#endif
int sound_device;
char *sound_device_name = SOUND_DEVICE;
int joystick_device = 0;
-char *joystick_device_name[2] = { DEV_JOYSTICK_0, DEV_JOYSTICK_1 };
+char *joystick_device_name[MAX_PLAYERS] =
+{
+ DEV_JOYSTICK_0,
+ DEV_JOYSTICK_1,
+ DEV_JOYSTICK_2,
+ DEV_JOYSTICK_3
+};
+
char *level_directory = LEVEL_PATH;
int width, height;
struct SetupFileList *setup_list = NULL;
struct SetupFileList *level_setup_list = NULL;
-struct JoystickInfo joystick[2] =
-{
- { JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE,
- JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE },
- { JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE,
- JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE }
-};
-
/* data needed for playing sounds */
char *sound_name[NUM_SOUNDS] =
{
struct SetupJoystickInfo
{
+ char device_name[MAX_FILENAME_LEN];
+ int xleft, xmiddle, xright;
+ int yupper, ymiddle, ylower;
int snap;
int bomb;
};
KeySym bomb;
};
+struct SetupInputInfo
+{
+ boolean use_joystick;
+ struct SetupJoystickInfo joy;
+ struct SetupKeyboardInfo key;
+};
+
struct SetupInfo
{
- boolean sound_on;
- boolean sound_loops_on;
- boolean sound_music_on;
- boolean sound_simple_on;
- boolean toons_on;
- boolean direct_draw_on;
- boolean scroll_delay_on;
- boolean soft_scrolling_on;
- boolean fading_on;
- boolean autorecord_on;
+ boolean sound;
+ boolean sound_loops;
+ boolean sound_music;
+ boolean sound_simple;
+ boolean toons;
+ boolean double_buffering;
+ boolean direct_draw; /* !double_buffering (redundant!) */
+ boolean scroll_delay;
+ boolean soft_scrolling;
+ boolean fading;
+ boolean autorecord;
boolean quick_doors;
- struct
- {
- boolean use_joystick;
- int joystick_nr;
- struct SetupJoystickInfo joy;
- struct SetupKeyboardInfo key;
- } input[MAX_PLAYERS];
+
+ char login_name[MAX_NAMELEN];
+ char alias_name[MAX_NAMELEN];
+
+ struct SetupInputInfo input[MAX_PLAYERS];
};
struct SetupFileList
byte action; /* action from server or for local playing */
byte potential_action; /* must go to network server first */
- char login_name[MAX_NAMELEN];
- char alias_name[MAX_NAMELEN];
+ int joystick_fd; /* file descriptor of player's joystick */
int jx,jy, last_jx,last_jy;
int MovDir, MovPos, GfxPos;
} pos[MAX_TAPELEN];
};
-struct JoystickInfo
-{
- int xleft, xright, xmiddle;
- int yupper, ylower, ymiddle;
-};
-
extern Display *display;
extern Visual *visual;
extern int screen;
extern int sound_device;
extern char *sound_device_name;
extern int joystick_device;
-extern char *joystick_device_name[2];
+extern char *joystick_device_name[];
extern char *level_directory;
extern int width, height;
TapeErase();
LoadLevelTape(level_nr);
+ /*
GetPlayerConfig();
+ */
+
LoadLevel(level_nr);
- if (setup.autorecord_on)
+ if (setup.autorecord)
TapeStartRecording();
#include "joystick.h"
#include "cartoons.h"
#include "network.h"
+#include "init.h"
#ifdef MSDOS
extern unsigned char get_ascii(KeySym);
ClearWindow();
DrawHeadline();
DrawText(SX + 32, SY + 2*32, "Name:", FS_BIG, FC_GREEN);
- DrawText(SX + 6*32, SY + 2*32, local_player->alias_name, FS_BIG, FC_RED);
+ DrawText(SX + 6*32, SY + 2*32, setup.alias_name, FS_BIG, FC_RED);
DrawText(SX + 32, SY + 3*32, "Level:", FS_BIG, FC_GREEN);
DrawText(SX + 11*32, SY + 3*32, int2str(level_nr,3), FS_BIG,
(level_nr<leveldir[leveldir_nr].levels ? FC_RED : FC_YELLOW));
if (y==3)
{
game_status = TYPENAME;
- HandleTypeName(strlen(local_player->alias_name),0);
+ HandleTypeName(strlen(setup.alias_name),0);
}
else if (y==4)
{
}
else if (y==8)
{
- if (setup.autorecord_on)
+ if (setup.autorecord)
TapeStartRecording();
if (options.network)
if (newxpos)
{
xpos = newxpos;
- DrawText(SX+6*32, SY+ypos*32, local_player->alias_name, FS_BIG, FC_YELLOW);
+ DrawText(SX+6*32, SY+ypos*32, setup.alias_name, FS_BIG, FC_YELLOW);
DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
return;
}
if((ascii = get_ascii(key)) && xpos<MAX_NAMELEN-1)
{
#endif
- local_player->alias_name[xpos] = ascii;
- local_player->alias_name[xpos+1] = 0;
+ setup.alias_name[xpos] = ascii;
+ setup.alias_name[xpos+1] = 0;
xpos++;
DrawTextExt(drawto,gc,SX+6*32,SY+ypos*32,
- local_player->alias_name,FS_BIG,FC_YELLOW);
+ setup.alias_name,FS_BIG,FC_YELLOW);
DrawTextExt(window,gc,SX+6*32,SY+ypos*32,
- local_player->alias_name,FS_BIG,FC_YELLOW);
+ setup.alias_name,FS_BIG,FC_YELLOW);
DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
}
else if ((key==XK_Delete || key==XK_BackSpace) && xpos>0)
{
xpos--;
- local_player->alias_name[xpos] = 0;
+ setup.alias_name[xpos] = 0;
DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
DrawGraphic(xpos+7,ypos,GFX_LEERRAUM);
}
else if (key==XK_Return && xpos>0)
{
- DrawText(SX+6*32,SY+ypos*32,local_player->alias_name,FS_BIG,FC_RED);
+ DrawText(SX+6*32,SY+ypos*32,setup.alias_name,FS_BIG,FC_RED);
DrawGraphic(xpos+6,ypos,GFX_LEERRAUM);
SaveSetup();
else
{
leveldir_nr = y-3;
+ level_nr =
+ getLastPlayedLevelOfLevelSeries(leveldir[leveldir_nr].filename);
+
SaveLevelSetup();
TapeErase();
static struct setup
{
boolean *value;
- char *text, *mode[2];
+ char *text;
} setup_info[] =
{
- { &setup.sound_on, "Sound:", { "on", "off" } },
- { &setup.sound_loops_on, " Sound Loops:",{ "on", "off" } },
- { &setup.sound_music_on, " Game Music:", { "on", "off" } },
- { &setup.toons_on, "Toons:", { "on", "off" } },
- { &setup.direct_draw_on, "Buffered gfx:",{ "off","on" } },
- { &setup.scroll_delay_on, "Scroll Delay:",{ "on", "off" } },
- { &setup.soft_scrolling_on, "Soft Scroll.:",{ "on", "off" } },
- { &setup.fading_on, "Fading:", { "on", "off" } },
- { &setup.quick_doors, "Quick Doors:", { "on", "off" } },
- { &setup.autorecord_on, "Auto-Record:", { "on", "off" } },
- { NULL, "Input Devices",{ "", "" } },
- { NULL, "", { "", "" } },
- { NULL, "", { "", "" } },
- { NULL, "Exit", { "", "" } },
- { NULL, "Save and exit",{ "", "" } }
+ { &setup.sound, "Sound:", },
+ { &setup.sound_loops, " Sound Loops:" },
+ { &setup.sound_music, " Game Music:" },
+ { &setup.toons, "Toons:" },
+ { &setup.double_buffering, "Buffered gfx:" },
+ { &setup.scroll_delay, "Scroll Delay:" },
+ { &setup.soft_scrolling, "Soft Scroll.:" },
+ { &setup.fading, "Fading:" },
+ { &setup.quick_doors, "Quick Doors:" },
+ { &setup.autorecord, "Auto-Record:" },
+ { NULL, "Input Devices" },
+ { NULL, "" },
+ { NULL, "" },
+ { NULL, "Exit" },
+ { NULL, "Save and exit" }
};
CloseDoor(DOOR_CLOSE_2);
if (setup_info[base].value)
{
int setting_value = *setup_info[base].value;
- int setting_pos = (setting_value != 0 ? 0 : 1);
- int fc_on = (strcmp(setup_info[base].mode[setting_pos], "on") == 0);
- DrawText(SX+14*32, SY+i*32, setup_info[base].mode[setting_pos],
- FS_BIG, (fc_on ? FC_YELLOW : FC_BLUE));
+ DrawText(SX+14*32, SY+i*32, (setting_value ? "on" : "off"),
+ FS_BIG, (setting_value ? FC_YELLOW : FC_BLUE));
}
}
if (y==3 && sound_status==SOUND_AVAILABLE)
{
- if (setup.sound_on)
+ if (setup.sound)
{
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
- setup.sound_loops_on = FALSE;
- setup.sound_music_on = FALSE;
+ setup.sound_loops = FALSE;
+ setup.sound_music = FALSE;
}
else
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
- setup.sound_on = !setup.sound_on;
+ setup.sound = !setup.sound;
}
else if (y==4 && sound_loops_allowed)
{
- if (setup.sound_loops_on)
+ if (setup.sound_loops)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
else
{
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
- setup.sound_on = TRUE;
+ setup.sound = TRUE;
}
- setup.sound_loops_on = !setup.sound_loops_on;
+ setup.sound_loops = !setup.sound_loops;
}
else if (y==5 && sound_loops_allowed)
{
- if (setup.sound_music_on)
+ if (setup.sound_music)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
else
{
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
- setup.sound_on = TRUE;
+ setup.sound = TRUE;
}
- setup.sound_music_on = !setup.sound_music_on;
+ setup.sound_music = !setup.sound_music;
}
else if (y==6)
{
- if (setup.toons_on)
+ if (setup.toons)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
else
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
- setup.toons_on = !setup.toons_on;
+ setup.toons = !setup.toons;
}
else if (y==7)
{
- if (!setup.direct_draw_on)
+ if (setup.double_buffering)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
else
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
- setup.direct_draw_on = !setup.direct_draw_on;
+ setup.double_buffering = !setup.double_buffering;
+ setup.direct_draw = !setup.double_buffering;
}
else if (y==8)
{
- if (setup.scroll_delay_on)
+ if (setup.scroll_delay)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
else
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
- setup.scroll_delay_on = !setup.scroll_delay_on;
+ setup.scroll_delay = !setup.scroll_delay;
}
else if (y==9)
{
- if (setup.soft_scrolling_on)
+ if (setup.soft_scrolling)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
else
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
- setup.soft_scrolling_on = !setup.soft_scrolling_on;
+ setup.soft_scrolling = !setup.soft_scrolling;
}
else if (y==10)
{
- if (setup.fading_on)
+ if (setup.fading)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
else
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
- setup.fading_on = !setup.fading_on;
+ setup.fading = !setup.fading;
}
else if (y==11)
{
}
else if (y==12)
{
- if (setup.autorecord_on)
+ if (setup.autorecord)
DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
else
DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
- setup.autorecord_on = !setup.autorecord_on;
+ setup.autorecord = !setup.autorecord;
}
else if (y==13)
{
if (y==pos_end)
{
SaveSetup();
+
+ /*
SaveJoystickData();
+ */
+
}
game_status = MAINMENU;
HandleSetupInputScreen(0,0,0,0,MB_MENU_INITIALIZE);
}
+static int getJoystickNrFromDeviceName(char *device_name)
+{
+ char c;
+ int joystick_nr = 0;
+
+ if (device_name == NULL || device_name[0] == '\0')
+ return 0;
+
+ c = device_name[strlen(device_name) - 1];
+
+ if (c >= '0' && c <= '9')
+ joystick_nr = (int)(c - '0');
+
+ if (joystick_nr < 0 || joystick_nr >= MAX_PLAYERS)
+ joystick_nr = 0;
+
+ return joystick_nr;
+}
+
+static void setJoystickDeviceToNr(char *device_name, int device_nr)
+{
+ if (device_name == NULL)
+ return;
+
+ if (device_nr < 0 || device_nr >= MAX_PLAYERS)
+ device_nr = 0;
+
+ if (strlen(device_name) > 1)
+ {
+ char c1 = device_name[strlen(device_name) - 1];
+ char c2 = device_name[strlen(device_name) - 2];
+
+ if (c1 >= '0' && c1 <= '9' && !(c2 >= '0' && c2 <= '9'))
+ device_name[strlen(device_name) - 1] = '0' + (char)(device_nr % 10);
+ }
+ else
+ strcpy(device_name, joystick_device_name[device_nr]);
+}
+
static void drawPlayerSetupInputInfo(int player_nr)
{
int i;
{ &custom_key.snap, "Button 1" },
{ &custom_key.bomb, "Button 2" }
};
+ static char *joystick_name[MAX_PLAYERS] =
+ {
+ "Joystick1",
+ "Joystick2",
+ "Joystick3",
+ "Joystick4"
+ };
custom_key = setup.input[player_nr].key;
if (setup.input[player_nr].use_joystick)
{
+ char *device_name = setup.input[player_nr].joy.device_name;
+
DrawText(SX+8*32, SY+3*32,
- (setup.input[player_nr].joystick_nr == 0 ?
- "Joystick1" : "Joystick2"),
+ joystick_name[getJoystickNrFromDeviceName(device_name)],
FS_BIG, FC_YELLOW);
DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
}
{
static long delay = 0;
- if (!DelayReached(&delay,150))
+ if (!DelayReached(&delay, 150))
goto out;
player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
{
if (y == 4)
{
+ char *device_name = setup.input[player_nr].joy.device_name;
+
+ if (!setup.input[player_nr].use_joystick)
+ {
+ int new_device_nr = (dx >= 0 ? 0 : MAX_PLAYERS - 1);
+
+ setJoystickDeviceToNr(device_name, new_device_nr);
+ setup.input[player_nr].use_joystick = TRUE;
+ }
+ else
+ {
+ int device_nr = getJoystickNrFromDeviceName(device_name);
+ int new_device_nr = device_nr + (dx >= 0 ? +1 : -1);
+
+ if (new_device_nr < 0 || new_device_nr >= MAX_PLAYERS)
+ setup.input[player_nr].use_joystick = FALSE;
+ else
+ setJoystickDeviceToNr(device_name, new_device_nr);
+ }
+
+
+ /*
+ InitJoysticks();
+ */
+
+
+#if 0
int one_joystick_nr = (dx >= 0 ? 0 : 1);
int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
setup.input[player_nr].use_joystick = TRUE;
setup.input[player_nr].joystick_nr = one_joystick_nr;
}
+#endif
drawPlayerSetupInputInfo(player_nr);
}
else if (y == 5)
{
if (setup.input[player_nr].use_joystick)
- CalibrateJoystick(setup.input[player_nr].joystick_nr);
+ {
+ InitJoysticks();
+ CalibrateJoystick(player_nr);
+ }
else
CustomizeKeyboard(player_nr);
}
else if (y == pos_end)
{
+ InitJoysticks();
+
game_status = SETUP;
DrawSetupScreen();
redraw = TRUE;
DrawSetupInputScreen();
}
-void CalibrateJoystick(int joystick_nr)
+void CalibrateJoystick(int player_nr)
{
#ifdef __FreeBSD__
struct joystick joy_ctrl;
char joy_nr[4];
#endif
+ int joystick_fd = stored_player[player_nr].joystick_fd;
int new_joystick_xleft = 128, new_joystick_xright = 128;
int new_joystick_yupper = 128, new_joystick_ylower = 128;
int new_joystick_xmiddle, new_joystick_ymiddle;
if (joystick_status == JOYSTICK_OFF)
return;
+ if (!setup.input[player_nr].use_joystick || joystick_fd < 0)
+ return;
+
ClearWindow();
DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ",FS_BIG,FC_YELLOW);
DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS",FS_BIG,FC_YELLOW);
}
}
- joy = Joystick();
+ joy = Joystick(player_nr);
last_x = (joy & JOY_LEFT ? -1 : joy & JOY_RIGHT ? +1 : 0);
last_y = (joy & JOY_UP ? -1 : joy & JOY_DOWN ? +1 : 0);
DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
joy_ctrl.buttons = 0;
#endif
- while(Joystick() & JOY_BUTTON);
+ while(Joystick(player_nr) & JOY_BUTTON);
InitAnimation();
}
}
- if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
+ if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
{
joystick_status = JOYSTICK_OFF;
goto error_out;
new_joystick_ymiddle =
new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
- joystick[joystick_nr].xleft = new_joystick_xleft;
- joystick[joystick_nr].yupper = new_joystick_yupper;
- joystick[joystick_nr].xright = new_joystick_xright;
- joystick[joystick_nr].ylower = new_joystick_ylower;
- joystick[joystick_nr].xmiddle = new_joystick_xmiddle;
- joystick[joystick_nr].ymiddle = new_joystick_ymiddle;
+ setup.input[player_nr].joy.xleft = new_joystick_xleft;
+ setup.input[player_nr].joy.yupper = new_joystick_yupper;
+ setup.input[player_nr].joy.xright = new_joystick_xright;
+ setup.input[player_nr].joy.ylower = new_joystick_ylower;
+ setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
+ setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
CheckJoystickData();
- joy = Joystick();
+ joy = Joystick(player_nr);
if (joy & JOY_BUTTON && check_remaining == 0)
result = 1;
#if 0
printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
- joystick[joystick_nr].xleft,
- joystick[joystick_nr].xmiddle,
- joystick[joystick_nr].xright);
+ setup.input[player_nr].joy.xleft,
+ setup.input[player_nr].joy.xmiddle,
+ setup.input[player_nr].joy.xright);
printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
- joystick[joystick_nr].yupper,
- joystick[joystick_nr].ymiddle,
- joystick[joystick_nr].ylower);
+ setup.input[player_nr].joy.yupper,
+ setup.input[player_nr].joy.ymiddle,
+ setup.input[player_nr].joy.ylower);
#endif
}
StopAnimation();
DrawSetupInputScreen();
- while(Joystick() & JOY_BUTTON);
+ while(Joystick(player_nr) & JOY_BUTTON);
return;
error_out:
DrawSetupInputScreen();
}
+
+
+#if 0
+
void CalibrateJoystick_OLD()
{
#ifdef __FreeBSD__
new_joystick_xmiddle = joy_ctrl.x;
new_joystick_ymiddle = joy_ctrl.y;
- joystick[joystick_nr].xleft = new_joystick_xleft;
- joystick[joystick_nr].yupper = new_joystick_yupper;
- joystick[joystick_nr].xright = new_joystick_xright;
- joystick[joystick_nr].ylower = new_joystick_ylower;
- joystick[joystick_nr].xmiddle = new_joystick_xmiddle;
- joystick[joystick_nr].ymiddle = new_joystick_ymiddle;
+ setup.input[player_nr].joy.xleft = new_joystick_xleft;
+ setup.input[player_nr].joy.yupper = new_joystick_yupper;
+ setup.input[player_nr].joy.xright = new_joystick_xright;
+ setup.input[player_nr].joy.ylower = new_joystick_ylower;
+ setup.input[player_nr].joy.xmiddle = new_joystick_xmiddle;
+ setup.input[player_nr].joy.ymiddle = new_joystick_ymiddle;
CheckJoystickData();
DrawSetupScreen();
}
+#endif
+
+
+
void HandleGameActions()
{
if (game_status != PLAYING)
switch(CheckSoundButtons(mx,my,button))
{
case BUTTON_SOUND_MUSIC:
- if (setup.sound_music_on)
+ if (setup.sound_music)
{
- setup.sound_music_on = FALSE;
+ setup.sound_music = FALSE;
FadeSound(background_loop[level_nr % num_bg_loops]);
DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
}
else if (sound_loops_allowed)
{
- setup.sound_on = setup.sound_music_on = TRUE;
+ setup.sound = setup.sound_music = TRUE;
PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
DrawSoundDisplay(BUTTON_SOUND_MUSIC_ON);
}
break;
case BUTTON_SOUND_LOOPS:
- if (setup.sound_loops_on)
+ if (setup.sound_loops)
{
- setup.sound_loops_on = FALSE;
+ setup.sound_loops = FALSE;
DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
}
else if (sound_loops_allowed)
{
- setup.sound_on = setup.sound_loops_on = TRUE;
+ setup.sound = setup.sound_loops = TRUE;
DrawSoundDisplay(BUTTON_SOUND_LOOPS_ON);
}
else
break;
case BUTTON_SOUND_SIMPLE:
- if (setup.sound_simple_on)
+ if (setup.sound_simple)
{
- setup.sound_simple_on = FALSE;
+ setup.sound_simple = FALSE;
DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
}
else if (sound_status==SOUND_AVAILABLE)
{
- setup.sound_on = setup.sound_simple_on = TRUE;
+ setup.sound = setup.sound_simple = TRUE;
DrawSoundDisplay(BUTTON_SOUND_SIMPLE_ON);
}
else
{
struct SoundControl snd_ctrl = emptySoundControl;
- if (sound_status==SOUND_OFF || !setup.sound_on)
+ if (sound_status==SOUND_OFF || !setup.sound)
return;
if (volume<PSND_MIN_VOLUME)
void SetDrawtoField(int mode)
{
- if (mode == DRAW_BUFFERED && setup.soft_scrolling_on)
+ if (mode == DRAW_BUFFERED && setup.soft_scrolling)
{
FX = TILEX;
FY = TILEY;
int x,y;
Drawable buffer = (drawto_field != window ? drawto_field : backbuffer);
- if (setup.direct_draw_on && game_status == PLAYING)
+ if (setup.direct_draw && game_status == PLAYING)
redraw_mask &= ~REDRAW_MAIN;
if (redraw_mask & REDRAW_TILES && redraw_tiles > REDRAWTILES_THRESHOLD)
{
int fx = FX, fy = FY;
- if (setup.soft_scrolling_on)
+ if (setup.soft_scrolling)
{
fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
fy += (ScreenMovDir & (MV_UP|MV_DOWN) ? ScreenGfxPos : 0);
/*
long fading_delay = 300;
- if (setup.fading_on && (redraw_mask & REDRAW_FIELD))
+ if (setup.fading && (redraw_mask & REDRAW_FIELD))
{
*/
XFillRectangle(display,backbuffer,gc,
REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE);
- if (setup.soft_scrolling_on && game_status==PLAYING)
+ if (setup.soft_scrolling && game_status==PLAYING)
{
XFillRectangle(display,fieldbuffer,gc,
0,0, FXSIZE,FYSIZE);
else
SetDrawtoField(DRAW_BACKBUFFER);
- if (setup.direct_draw_on && game_status==PLAYING)
+ if (setup.direct_draw && game_status==PLAYING)
{
XFillRectangle(display,window,gc,
REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE);
int element = Feld[jx][jy];
int graphic, phase;
- /*
- if (!player->active || player->gone || !IN_SCR_FIELD(sx,sy))
- return;
- */
-
if (!player->active || player->gone ||
!IN_SCR_FIELD(SCREENX(last_jx),SCREENY(last_jy)))
return;
if (!IN_SCR_FIELD(sx,sy))
return;
- if (setup.direct_draw_on)
+ if (setup.direct_draw)
SetDrawtoField(DRAW_BUFFERED);
/* draw things behind the player, if needed */
syy = player->GfxPos;
}
- if (!setup.soft_scrolling_on && ScreenMovPos)
+ if (!setup.soft_scrolling && ScreenMovPos)
sxx = syy = 0;
DrawGraphicShiftedThruMask(sx,sy, sxx,syy, graphic, NO_CUTTING);
GFX_EXPLOSION + ((phase-1)/delay-1));
}
- if (setup.direct_draw_on)
+ if (setup.direct_draw)
{
int dest_x = SX + SCREENX(MIN(jx,last_jx))*TILEX;
int dest_y = SY + SCREENY(MIN(jy,last_jy))*TILEY;
for(y=BY1; y<=BY2; y++)
DrawScreenField(x,y);
- if (setup.soft_scrolling_on)
+ if (setup.soft_scrolling)
XCopyArea(display,fieldbuffer,backbuffer,gc,
FX,FY, SXSIZE,SYSIZE,
SX,SY);
break;
}
}
- else if (JoystickButton() == JOY_BUTTON_NEW_PRESSED)
+ else if (AnyJoystickButton() == JOY_BUTTON_NEW_PRESSED)
{
- int joy=Joystick();
+ int joy = AnyJoystick();
if (joy & JOY_BUTTON_1)
result = 1;