From 0d4ace80d081e080a704ee15227e209d5953e325 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 8 Jun 2010 22:12:49 +0200 Subject: [PATCH] rnd-20100608-1-src * added configurable key shortcuts for snap+direction player actions (probably most useful for recording tool-assisted speedrun (TAS) tapes using the single-step mode of the tape recorder) * version number set to 3.3.0.1 * version 3.3.0.0 released --- ChangeLog | 11 ++++++++++ src/Makefile | 2 +- src/conftime.h | 2 +- src/events.c | 28 ++++++++++++++--------- src/files.c | 15 ++++++++++++- src/libgame/joystick.h | 2 ++ src/libgame/system.h | 13 +++++++++++ src/main.h | 2 +- src/screens.c | 50 +++++++++++++++++++++++++++++++++--------- 9 files changed, 101 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 94518588..54ffface 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2010-06-08 + * added configurable key shortcuts for snap+direction player actions + (probably most useful for recording tool-assisted speedrun (TAS) + tapes using the single-step mode of the tape recorder) + +2010-05-28 + * version number set to 3.3.0.1 + +2010-05-25 + * version 3.3.0.0 released + 2010-05-22 * fixed missing memory allocation in SP engine when saving engine data for non-SP game engine snapshots (which also stores SP engine part) diff --git a/src/Makefile b/src/Makefile index 4bbbcca9..20b8f367 100644 --- a/src/Makefile +++ b/src/Makefile @@ -144,7 +144,7 @@ CONFIG_GAME_DIR = $(CONFIG_RO_GAME_DIR) $(CONFIG_RW_GAME_DIR) CONFIG_GAME = $(CONFIG_GAME_DIR) $(CONFIG_SCORE_ENTRIES) $(CONFIG_SPECIAL) CONFIG = $(CONFIG_GAME) $(JOYSTICK) -# DEBUG = -DDEBUG -g +DEBUG = -DDEBUG -g # PROFILING = $(PROFILING_FLAGS) # OPTIONS = $(DEBUG) -Wall # only for debugging purposes diff --git a/src/conftime.h b/src/conftime.h index 9be48364..902b91f3 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-05-25 22:42" +#define COMPILE_DATE_STRING "2010-06-08 22:05" diff --git a/src/events.c b/src/events.c index 9a42eb47..8c7aecae 100644 --- a/src/events.c +++ b/src/events.c @@ -607,20 +607,22 @@ static void HandleKeysSpecial(Key key) void HandleKey(Key key, int key_status) { boolean anyTextGadgetActiveOrJustFinished = anyTextGadgetActive(); - static struct SetupKeyboardInfo custom_key; + static struct SetupKeyboardInfo ski; + static struct SetupShortcutInfo ssi; static struct { Key *key_custom; + Key *key_snap; Key key_default; byte action; } key_info[] = { - { &custom_key.left, DEFAULT_KEY_LEFT, JOY_LEFT }, - { &custom_key.right, DEFAULT_KEY_RIGHT, JOY_RIGHT }, - { &custom_key.up, DEFAULT_KEY_UP, JOY_UP }, - { &custom_key.down, DEFAULT_KEY_DOWN, JOY_DOWN }, - { &custom_key.snap, DEFAULT_KEY_SNAP, JOY_BUTTON_1 }, - { &custom_key.drop, DEFAULT_KEY_DROP, JOY_BUTTON_2 } + { &ski.left, &ssi.snap_left, DEFAULT_KEY_LEFT, JOY_LEFT }, + { &ski.right, &ssi.snap_right, DEFAULT_KEY_RIGHT, JOY_RIGHT }, + { &ski.up, &ssi.snap_up, DEFAULT_KEY_UP, JOY_UP }, + { &ski.down, &ssi.snap_down, DEFAULT_KEY_DOWN, JOY_DOWN }, + { &ski.snap, NULL, DEFAULT_KEY_SNAP, JOY_BUTTON_SNAP }, + { &ski.drop, NULL, DEFAULT_KEY_DROP, JOY_BUTTON_DROP } }; int joy = 0; int i; @@ -632,6 +634,8 @@ void HandleKey(Key key, int key_status) static boolean element_dropped[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE }; int pnr; + ssi = setup.shortcut; + for (pnr = 0; pnr < MAX_PLAYERS; pnr++) { byte key_action = 0; @@ -639,12 +643,16 @@ void HandleKey(Key key, int key_status) if (setup.input[pnr].use_joystick) continue; - custom_key = setup.input[pnr].key; + ski = setup.input[pnr].key; - for (i = 0; i < 6; i++) + for (i = 0; i < NUM_PLAYER_ACTIONS; i++) if (key == *key_info[i].key_custom) key_action |= key_info[i].action; + for (i = 0; i < NUM_DIRECTIONS; i++) + if (key == *key_info[i].key_snap) + key_action |= key_info[i].action | JOY_BUTTON_SNAP; + if (tape.single_step && clear_button_2[pnr]) { stored_player[pnr].action &= ~KEY_BUTTON_2; @@ -699,7 +707,7 @@ void HandleKey(Key key, int key_status) } else { - for (i = 0; i < 6; i++) + for (i = 0; i < NUM_PLAYER_ACTIONS; i++) if (key == key_info[i].key_default) joy |= key_info[i].action; } diff --git a/src/files.c b/src/files.c index d7837486..349d2d52 100644 --- a/src/files.c +++ b/src/files.c @@ -9067,8 +9067,12 @@ void SaveScore(int nr) #define SETUP_TOKEN_SHORTCUT_SOUND_SIMPLE 13 #define SETUP_TOKEN_SHORTCUT_SOUND_LOOPS 14 #define SETUP_TOKEN_SHORTCUT_SOUND_MUSIC 15 +#define SETUP_TOKEN_SHORTCUT_SNAP_LEFT 16 +#define SETUP_TOKEN_SHORTCUT_SNAP_RIGHT 17 +#define SETUP_TOKEN_SHORTCUT_SNAP_UP 18 +#define SETUP_TOKEN_SHORTCUT_SNAP_DOWN 19 -#define NUM_SHORTCUT_SETUP_TOKENS 16 +#define NUM_SHORTCUT_SETUP_TOKENS 20 /* player setup */ #define SETUP_TOKEN_PLAYER_USE_JOYSTICK 0 @@ -9221,6 +9225,10 @@ static struct TokenInfo shortcut_setup_tokens[] = { TYPE_KEY_X11, &ssi.sound_simple, "shortcut.sound_simple" }, { TYPE_KEY_X11, &ssi.sound_loops, "shortcut.sound_loops" }, { TYPE_KEY_X11, &ssi.sound_music, "shortcut.sound_music" }, + { TYPE_KEY_X11, &ssi.snap_left, "shortcut.snap_left" }, + { TYPE_KEY_X11, &ssi.snap_right, "shortcut.snap_right" }, + { TYPE_KEY_X11, &ssi.snap_up, "shortcut.snap_up" }, + { TYPE_KEY_X11, &ssi.snap_down, "shortcut.snap_down" }, }; static struct TokenInfo player_setup_tokens[] = @@ -9347,6 +9355,11 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->shortcut.sound_loops = DEFAULT_KEY_SOUND_LOOPS; si->shortcut.sound_music = DEFAULT_KEY_SOUND_MUSIC; + si->shortcut.snap_left = DEFAULT_KEY_SNAP_LEFT; + si->shortcut.snap_right = DEFAULT_KEY_SNAP_RIGHT; + si->shortcut.snap_up = DEFAULT_KEY_SNAP_UP; + si->shortcut.snap_down = DEFAULT_KEY_SNAP_DOWN; + for (i = 0; i < MAX_PLAYERS; i++) { si->input[i].use_joystick = FALSE; diff --git a/src/libgame/joystick.h b/src/libgame/joystick.h index efaaf5b8..dfc3089b 100644 --- a/src/libgame/joystick.h +++ b/src/libgame/joystick.h @@ -61,6 +61,8 @@ #define JOY_DOWN MV_DOWN #define JOY_BUTTON_1 KEY_BUTTON_1 #define JOY_BUTTON_2 KEY_BUTTON_2 +#define JOY_BUTTON_SNAP KEY_BUTTON_SNAP +#define JOY_BUTTON_DROP KEY_BUTTON_DROP #define JOY_MOTION KEY_MOTION #define JOY_BUTTON KEY_BUTTON #define JOY_ACTION KEY_ACTION diff --git a/src/libgame/system.h b/src/libgame/system.h index cbcf5c86..4383b60b 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -80,6 +80,10 @@ #define DEFAULT_KEY_SOUND_SIMPLE KSYM_UNDEFINED #define DEFAULT_KEY_SOUND_LOOPS KSYM_UNDEFINED #define DEFAULT_KEY_SOUND_MUSIC KSYM_UNDEFINED +#define DEFAULT_KEY_SNAP_LEFT KSYM_UNDEFINED +#define DEFAULT_KEY_SNAP_RIGHT KSYM_UNDEFINED +#define DEFAULT_KEY_SNAP_UP KSYM_UNDEFINED +#define DEFAULT_KEY_SNAP_DOWN KSYM_UNDEFINED /* values for key_status */ #define KEY_NOT_PRESSED FALSE @@ -130,6 +134,8 @@ #define BUTTON_1 4 #define BUTTON_2 5 +#define NUM_PLAYER_ACTIONS 6 + /* values for special "focus player" bitmasks */ #define BIT_SET_FOCUS 6 @@ -153,6 +159,8 @@ #define KEY_BUTTON_1 (1 << BUTTON_1) #define KEY_BUTTON_2 (1 << BUTTON_2) +#define KEY_BUTTON_SNAP KEY_BUTTON_1 +#define KEY_BUTTON_DROP KEY_BUTTON_2 #define KEY_MOTION (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN) #define KEY_BUTTON (KEY_BUTTON_1 | KEY_BUTTON_2) #define KEY_ACTION (KEY_MOTION | KEY_BUTTON) @@ -863,6 +871,11 @@ struct SetupShortcutInfo Key sound_simple; Key sound_loops; Key sound_music; + + Key snap_left; + Key snap_right; + Key snap_up; + Key snap_down; }; struct SetupSystemInfo diff --git a/src/main.h b/src/main.h index 0933b064..d16f5bc9 100644 --- a/src/main.h +++ b/src/main.h @@ -2023,7 +2023,7 @@ #define PROGRAM_VERSION_MAJOR 3 #define PROGRAM_VERSION_MINOR 3 #define PROGRAM_VERSION_PATCH 0 -#define PROGRAM_VERSION_BUILD 0 +#define PROGRAM_VERSION_BUILD 1 #define PROGRAM_TITLE_STRING "Rocks'n'Diamonds" #define PROGRAM_AUTHOR_STRING "Holger Schemel" diff --git a/src/screens.c b/src/screens.c index db347cda..de24626a 100644 --- a/src/screens.c +++ b/src/screens.c @@ -50,20 +50,21 @@ #define SETUP_MODE_SHORTCUTS_2 9 #define SETUP_MODE_SHORTCUTS_3 10 #define SETUP_MODE_SHORTCUTS_4 11 +#define SETUP_MODE_SHORTCUTS_5 12 /* sub-screens on the setup screen (generic) */ -#define SETUP_MODE_CHOOSE_ARTWORK 12 -#define SETUP_MODE_CHOOSE_OTHER 13 +#define SETUP_MODE_CHOOSE_ARTWORK 13 +#define SETUP_MODE_CHOOSE_OTHER 14 /* sub-screens on the setup screen (specific) */ -#define SETUP_MODE_CHOOSE_GAME_SPEED 14 -#define SETUP_MODE_CHOOSE_SCREEN_MODE 15 -#define SETUP_MODE_CHOOSE_SCROLL_DELAY 16 -#define SETUP_MODE_CHOOSE_GRAPHICS 17 -#define SETUP_MODE_CHOOSE_SOUNDS 18 -#define SETUP_MODE_CHOOSE_MUSIC 19 +#define SETUP_MODE_CHOOSE_GAME_SPEED 15 +#define SETUP_MODE_CHOOSE_SCREEN_MODE 16 +#define SETUP_MODE_CHOOSE_SCROLL_DELAY 17 +#define SETUP_MODE_CHOOSE_GRAPHICS 18 +#define SETUP_MODE_CHOOSE_SOUNDS 19 +#define SETUP_MODE_CHOOSE_MUSIC 20 -#define MAX_SETUP_MODES 20 +#define MAX_SETUP_MODES 21 /* for input setup functions */ #define SETUPINPUT_SCREEN_POS_START 0 @@ -235,7 +236,7 @@ static struct INFO_MODE_MAIN) #define DRAW_MODE_SETUP(i) ((i) >= SETUP_MODE_MAIN && \ - (i) <= SETUP_MODE_SHORTCUTS_4 ? (i) : \ + (i) <= SETUP_MODE_SHORTCUTS_5 ? (i) : \ (i) >= SETUP_MODE_CHOOSE_GRAPHICS && \ (i) <= SETUP_MODE_CHOOSE_MUSIC ? \ SETUP_MODE_CHOOSE_ARTWORK : \ @@ -4135,6 +4136,13 @@ static void execSetupShortcuts4() DrawSetupScreen(); } +static void execSetupShortcuts5() +{ + setup_mode = SETUP_MODE_SHORTCUTS_5; + + DrawSetupScreen(); +} + static void execExitSetup() { game_status = GAME_MODE_MAIN; @@ -4308,6 +4316,7 @@ static struct TokenInfo setup_info_shortcuts[] = { TYPE_ENTER_MENU, execSetupShortcuts2, "Player Focus" }, { TYPE_ENTER_MENU, execSetupShortcuts3, "Tape Buttons" }, { TYPE_ENTER_MENU, execSetupShortcuts4, "Sound & Music" }, + { TYPE_ENTER_MENU, execSetupShortcuts5, "TAS Snap Keys" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, @@ -4381,6 +4390,22 @@ static struct TokenInfo setup_info_shortcuts_4[] = { 0, NULL, NULL } }; +static struct TokenInfo setup_info_shortcuts_5[] = +{ + { TYPE_KEYTEXT, NULL, "Snap Left:", }, + { TYPE_KEY, &setup.shortcut.snap_left, "" }, + { TYPE_KEYTEXT, NULL, "Snap Right:", }, + { TYPE_KEY, &setup.shortcut.snap_right, "" }, + { TYPE_KEYTEXT, NULL, "Snap Up:", }, + { TYPE_KEY, &setup.shortcut.snap_up, "" }, + { TYPE_KEYTEXT, NULL, "Snap Down:", }, + { TYPE_KEY, &setup.shortcut.snap_down, "" }, + { TYPE_EMPTY, NULL, "" }, + { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" }, + + { 0, NULL, NULL } +}; + static Key getSetupKey() { Key key = KSYM_UNDEFINED; @@ -4684,6 +4709,11 @@ static void DrawSetupScreen_Generic() setup_info = setup_info_shortcuts_4; title_string = "Setup Shortcuts"; } + else if (setup_mode == SETUP_MODE_SHORTCUTS_5) + { + setup_info = setup_info_shortcuts_5; + title_string = "Setup Shortcuts"; + } DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string); -- 2.34.1