From: Holger Schemel Date: Tue, 3 Dec 2024 18:56:19 +0000 (+0100) Subject: added support for suicide key for BD game engine X-Git-Tag: 4.4.0.0-test-5~18 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=2b62e20d1d4e3bc591d8bd12811525b980f06b46;p=rocksndiamonds.git added support for suicide key for BD game engine --- diff --git a/src/events.c b/src/events.c index 3117dc88..80c15c2e 100644 --- a/src/events.c +++ b/src/events.c @@ -2191,6 +2191,10 @@ void HandleKey(Key key, int key_status) tape.property_bits |= TAPE_PROPERTY_TAS_KEYS; } } + + // also handle suicide key for the first player only + if (key == setup.shortcut.suicide) + key_action |= KEY_SUICIDE; } if (key_status == KEY_PRESSED) diff --git a/src/files.c b/src/files.c index 839d5fb5..f9eabd78 100644 --- a/src/files.c +++ b/src/files.c @@ -12040,6 +12040,8 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->shortcut.speed_fast = DEFAULT_KEY_SPEED_FAST; si->shortcut.speed_slow = DEFAULT_KEY_SPEED_SLOW; + si->shortcut.suicide = DEFAULT_KEY_SUICIDE; + for (i = 0; i < MAX_PLAYERS; i++) { si->input[i].use_joystick = FALSE; diff --git a/src/game_bd/bd_gameplay.c b/src/game_bd/bd_gameplay.c index 94bdca2b..260d6d4a 100644 --- a/src/game_bd/bd_gameplay.c +++ b/src/game_bd/bd_gameplay.c @@ -238,6 +238,8 @@ GdGame *gd_game_new(const int cave, const int level) game->player_move = GD_MV_STILL; game->player_move_stick = FALSE; game->player_fire = FALSE; + game->player_suicide = FALSE; + game->player_suicide_stick = FALSE; game->state_counter = GAME_INT_LOAD_CAVE; @@ -253,10 +255,8 @@ boolean check_iteration_reached(GdGame *game) return (game->milliseconds_game + millisecs_elapsed >= game->cave->speed); } -static void iterate_cave(GdGame *game, GdDirection player_move, boolean fire) +static void iterate_cave(GdGame *game, GdDirection player_move, boolean fire, boolean suicide) { - boolean suicide = FALSE; - // ANYTHING EXCEPT A TIMEOUT, WE ITERATE THE CAVE if (game->cave->player_state != GD_PL_TIMEOUT) { @@ -270,6 +270,7 @@ static void iterate_cave(GdGame *game, GdDirection player_move, boolean fire) player_move = ((action_bd & GD_REPLAY_MOVE_MASK)); fire = ((action_bd & GD_REPLAY_FIRE_MASK) != 0); + suicide = ((action_bd & GD_REPLAY_SUICIDE_MASK) != 0); } } @@ -470,7 +471,7 @@ static GdGameState gd_game_main_int(GdGame *game, boolean allow_iterate, boolean // reset cycle frame counter for the next cave iteration game->itercycle = 0; - iterate_cave(game, game->player_move, game->player_fire); + iterate_cave(game, game->player_move, game->player_fire, game->player_suicide); game->cycle_counter++; @@ -484,6 +485,16 @@ static GdGameState gd_game_main_int(GdGame *game, boolean allow_iterate, boolean game->player_move = GD_MV_STILL; } + if (game->player_suicide == FALSE) + { + game->player_suicide_stick = FALSE; + } + else + { + game->player_suicide_stick = TRUE; + game->player_suicide = FALSE; + } + // as we iterated, the score and the like could have been changed. return_state = GD_GAME_LABELS_CHANGED; @@ -660,6 +671,7 @@ void play_game_func(GdGame *game, int action) boolean move_left = ((action & JOY_LEFT) != 0); boolean move_right = ((action & JOY_RIGHT) != 0); boolean fire = ((action & JOY_BUTTON) != 0); + boolean suicide = ((action & KEY_SUICIDE) != 0); if (game->player_move_stick || move_up || move_down || move_left || move_right) // no "fire"! { @@ -675,6 +687,9 @@ void play_game_func(GdGame *game, int action) if (game->player_move == GD_MV_STILL) game->player_fire = fire; + if (game->player_suicide_stick || suicide) + game->player_suicide = suicide; + // tell the interrupt "20ms has passed" state = gd_game_main_int(game, !game->out_of_window, FALSE); diff --git a/src/game_bd/bd_gameplay.h b/src/game_bd/bd_gameplay.h index 490ffa7e..adbb37a3 100644 --- a/src/game_bd/bd_gameplay.h +++ b/src/game_bd/bd_gameplay.h @@ -62,6 +62,8 @@ typedef struct _gd_game GdDirection player_move; boolean player_move_stick; boolean player_fire; + boolean player_suicide; + boolean player_suicide_stick; GdCave *cave; // Copy of the cave. This is the iterated, changed (ruined...) one GdCave *original_cave; // original cave from caveset. used to record highscore diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index fdf7afaf..488837b8 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -203,14 +203,16 @@ int map_action_RND_to_BD(int action) action & JOY_LEFT, action & JOY_RIGHT); int player_fire = ((action & JOY_BUTTON) != 0 ? GD_REPLAY_FIRE_MASK : 0); + int player_suicide = ((action & KEY_SUICIDE) != 0 ? GD_REPLAY_SUICIDE_MASK : 0); - return (player_move | player_fire); + return (player_move | player_fire | player_suicide); } int map_action_BD_to_RND(int action) { GdDirection player_move = ((action & GD_REPLAY_MOVE_MASK)); boolean player_fire = ((action & GD_REPLAY_FIRE_MASK) != 0); + boolean player_suicide = ((action & GD_REPLAY_SUICIDE_MASK) != 0); int action_move = (player_move == GD_MV_UP ? JOY_UP : player_move == GD_MV_UP_RIGHT ? JOY_UP | JOY_RIGHT : @@ -221,8 +223,9 @@ int map_action_BD_to_RND(int action) player_move == GD_MV_LEFT ? JOY_LEFT : player_move == GD_MV_UP_LEFT ? JOY_UP | JOY_LEFT : JOY_NO_ACTION); int action_fire = (player_fire ? JOY_BUTTON_1 : JOY_NO_ACTION); + int action_suicide = (player_suicide ? KEY_SUICIDE : JOY_NO_ACTION); - return (action_move | action_fire); + return (action_move | action_fire | action_suicide); } boolean checkGameRunning_BD(void) diff --git a/src/libgame/system.h b/src/libgame/system.h index a903ad09..a74ed155 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -199,6 +199,7 @@ #define DEFAULT_KEY_SNAP_DOWN KSYM_UNDEFINED #define DEFAULT_KEY_SPEED_FAST KSYM_f #define DEFAULT_KEY_SPEED_SLOW KSYM_s +#define DEFAULT_KEY_SUICIDE KSYM_F12 // default debug setup keys and values #define DEFAULT_FRAME_DELAY_0 20 // 100 % speed @@ -284,8 +285,9 @@ #define NUM_PLAYER_ACTIONS 6 -// values for special "focus player" bitmasks +// values for special "focus player" and "suicide" bitmasks #define BIT_SET_FOCUS 6 +#define BIT_SUICIDE 7 // values for drawing stages for global animations #define DRAW_GLOBAL_ANIM_STAGE_1 1 @@ -327,6 +329,7 @@ #define KEY_ACTION (KEY_MOTION | KEY_BUTTON) #define KEY_SET_FOCUS (1 << BIT_SET_FOCUS) +#define KEY_SUICIDE (1 << BIT_SUICIDE) #define MV_DIR_FROM_BIT(x) ((x) < NUM_DIRECTIONS ? 1 << (x) : \ (x) == MV_BIT_UPLEFT ? MV_UPLEFT : \ @@ -1435,6 +1438,8 @@ struct SetupShortcutInfo Key speed_fast; Key speed_slow; + + Key suicide; }; struct SetupSystemInfo