aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorNebuleon Fumika2013-01-22 04:16:15 -0500
committerNebuleon Fumika2013-01-22 04:16:15 -0500
commit2cf733eef4323886e00a1e4788a2b3e803a797d7 (patch)
treec9fd2375c0bc7b8cb76bae04e5f9bc3ef1f6970a /source
parentf81781ae8cc8e849d6c91410da7d8e511b7bae5a (diff)
downloadsnes9x2005-2cf733eef4323886e00a1e4788a2b3e803a797d7.tar.gz
snes9x2005-2cf733eef4323886e00a1e4788a2b3e803a797d7.tar.bz2
snes9x2005-2cf733eef4323886e00a1e4788a2b3e803a797d7.zip
Add three hotkeys: temporary fast-forward, sound toggle and return to menu. These hotkeys can be overridden per game so that the global version of the hotkey can be ignored.
* Language file fixups related to \n (newlines). * Pictochat fixups: shorten START and SELECT to ST and SEL. Should still be recognisable.
Diffstat (limited to 'source')
-rw-r--r--source/font/Pictochat-16.bdf36
-rw-r--r--source/nds/draw.c26
-rw-r--r--source/nds/entry.cpp26
-rw-r--r--source/nds/gui.c164
4 files changed, 226 insertions, 26 deletions
diff --git a/source/font/Pictochat-16.bdf b/source/font/Pictochat-16.bdf
index 4a07e0b..a512814 100644
--- a/source/font/Pictochat-16.bdf
+++ b/source/font/Pictochat-16.bdf
@@ -1,7 +1,7 @@
STARTFONT 2.1
FONT -FontForge-Pictochat-Book-R-Normal--16-150-75-75-P-53-ISO10646-1
SIZE 15 75 75
-FONTBOUNDINGBOX 23 13 0 -1
+FONTBOUNDINGBOX 12 13 0 -1
COMMENT "Generated by fontforge, http://fontforge.sourceforge.net"
STARTPROPERTIES 37
FAMILY_NAME "Pictochat"
@@ -2657,27 +2657,27 @@ FF80
ENDCHAR
STARTCHAR uni05CE
ENCODING 1486
-SWIDTH 1250 0
-DWIDTH 20 0
-BBX 19 5 0 2
+SWIDTH 625 0
+DWIDTH 10 0
+BBX 7 5 1 2
BITMAP
-6E4CE0
-84AA40
-44EC40
-24AA40
-C4AA40
+6E
+84
+44
+24
+C4
ENDCHAR
STARTCHAR uni05CF
ENCODING 1487
-SWIDTH 1500 0
-DWIDTH 24 0
-BBX 23 5 0 2
-BITMAP
-6E8E6E
-888884
-4C8E84
-288884
-CEEE64
+SWIDTH 875 0
+DWIDTH 14 0
+BBX 11 5 1 2
+BITMAP
+6E80
+8880
+4C80
+2880
+CEE0
ENDCHAR
STARTCHAR quotedblleft
ENCODING 8220
diff --git a/source/nds/draw.c b/source/nds/draw.c
index f373aa3..3eab510 100644
--- a/source/nds/draw.c
+++ b/source/nds/draw.c
@@ -883,24 +883,42 @@ u32 draw_hotkey_dialog(enum SCREEN_ID screen, u32 sy, char *clear, char *cancel)
ds2_flipScreen(screen, 2);
- // While there are no keys pressed, wait for keys.
+ // This function has been started by a key press. Wait for it to end.
struct key_buf inputdata;
do {
mdelay(1);
ds2_getrawInput(&inputdata);
+ } while (inputdata.key != 0);
+
+ // While there are no keys pressed, wait for keys.
+ do {
+ mdelay(1);
+ ds2_getrawInput(&inputdata);
} while (inputdata.key == 0);
// Now, while there are keys pressed, keep a tally of keys that have
// been pressed. (IGNORE TOUCH AND LID! Otherwise, closing the lid or
// touching to get to the menu will do stuff the user doesn't expect.
// Also ignore the direction pad because every game uses it.)
- u32 TotalKeys = inputdata.key;
+ u32 TotalKeys = 0;
do {
+ TotalKeys |= inputdata.key & ~(KEY_TOUCH | KEY_LID | KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT);
+ // If there's a touch on either button, turn it into a
+ // clear (A) or cancel (B) request.
+ if (inputdata.key & KEY_TOUCH)
+ {
+ if (inputdata.y >= 128 && inputdata.y < 128 + ICON_BUTTON.y)
+ {
+ if (inputdata.x >= 49 && inputdata.x < 49 + ICON_BUTTON.x)
+ return KEY_A;
+ else if (inputdata.x >= 136 && inputdata.x < 136 + ICON_BUTTON.x)
+ return KEY_B;
+ }
+ }
mdelay(1);
ds2_getrawInput(&inputdata);
- TotalKeys |= inputdata.key & ~(KEY_TOUCH | KEY_LID | KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT);
- } while (inputdata.key != 0);
+ } while (inputdata.key != 0 || TotalKeys == 0);
return TotalKeys;
}
diff --git a/source/nds/entry.cpp b/source/nds/entry.cpp
index 8cd5c06..13486b0 100644
--- a/source/nds/entry.cpp
+++ b/source/nds/entry.cpp
@@ -1064,6 +1064,8 @@ const unsigned int keymap[12] = {
};
*/
+static bool8 SoundToggleWasHeld = FALSE;
+
unsigned int S9xReadJoypad (int which1)
{
struct key_buf inputdata;
@@ -1082,9 +1084,31 @@ unsigned int S9xReadJoypad (int which1)
set_cpu_clock(clock_speed_number);
}
- if(inputdata.key & KEY_TOUCH) //Active menu
+ u32 HotkeyReturnToMenu = game_config.HotkeyReturnToMenu != 0 ? game_config.HotkeyReturnToMenu : emu_config.HotkeyReturnToMenu;
+ u32 HotkeyTemporaryFastForward = game_config.HotkeyTemporaryFastForward != 0 ? game_config.HotkeyTemporaryFastForward : emu_config.HotkeyTemporaryFastForward;
+ u32 HotkeyToggleSound = game_config.HotkeyToggleSound != 0 ? game_config.HotkeyToggleSound : emu_config.HotkeyToggleSound;
+
+ if(inputdata.key & KEY_TOUCH ||
+ (HotkeyReturnToMenu && ((inputdata.key & HotkeyReturnToMenu) == HotkeyReturnToMenu))
+ ) //Active menu
Settings.Paused = 1;
+ temporary_fast_forward =
+ (HotkeyTemporaryFastForward && ((inputdata.key & HotkeyTemporaryFastForward) == HotkeyTemporaryFastForward))
+ ;
+
+ bool8 SoundToggleIsHeld =
+ (HotkeyToggleSound && ((inputdata.key & HotkeyToggleSound) == HotkeyToggleSound))
+ ;
+
+ if (SoundToggleIsHeld && !SoundToggleWasHeld)
+ {
+ game_enable_audio = !game_enable_audio;
+ game_disableAudio();
+ }
+
+ SoundToggleWasHeld = SoundToggleIsHeld;
+
if(which1 < 1)
{
unsigned int key;
diff --git a/source/nds/gui.c b/source/nds/gui.c
index fe23cb5..10814d6 100644
--- a/source/nds/gui.c
+++ b/source/nds/gui.c
@@ -1710,6 +1710,19 @@ u32 menu(u16 *screen)
auto void time_period_passive();
auto void time_period_action();
auto void tools_menu_init();
+ auto void obtain_hotkey (u32 *HotkeyBitfield);
+ auto void set_global_hotkey_return_to_menu();
+ auto void set_global_hotkey_temporary_fast_forward();
+ auto void set_global_hotkey_toggle_sound();
+ auto void set_game_specific_hotkey_return_to_menu();
+ auto void set_game_specific_hotkey_temporary_fast_forward();
+ auto void set_game_specific_hotkey_toggle_sound();
+ auto void global_hotkey_return_to_menu_passive();
+ auto void global_hotkey_temporary_fast_forward_passive();
+ auto void global_hotkey_toggle_sound_passive();
+ auto void game_specific_hotkey_return_to_menu_passive();
+ auto void game_specific_hotkey_temporary_fast_forward_passive();
+ auto void game_specific_hotkey_toggle_sound_passive();
auto void load_default_setting();
auto void check_gbaemu_version();
auto void load_lastest_played();
@@ -2468,9 +2481,9 @@ u32 menu(u16 *screen)
{
}
-#define CHEAT_NUMBER_X 26
-#define CHEAT_DESC_X 52
-#define CHEAT_DESC_SX 163
+#define CHEAT_NUMBER_X 23
+#define CHEAT_DESC_X 49
+#define CHEAT_DESC_SX 166
#define CHEAT_ACTIVE_X 225
void cheat_option_passive()
@@ -2891,6 +2904,39 @@ u32 menu(u16 *screen)
};
MAKE_MENU(tools_screensnap, NULL, NULL, NULL, NULL, 0, 0);
+
+ /*--------------------------------------------------------
+ Tools - Global hotkeys
+ --------------------------------------------------------*/
+ MENU_OPTION_TYPE tools_global_hotkeys_options[] =
+ {
+ /* 00 */ SUBMENU_OPTION(&tools_menu, &msg[MSG_TOOLS_GLOBAL_HOTKEY_GENERAL], NULL, 0),
+
+ /* 01 */ ACTION_OPTION(set_global_hotkey_return_to_menu, global_hotkey_return_to_menu_passive, &msg[MSG_HOTKEY_MAIN_MENU], NULL, 1),
+
+ /* 02 */ ACTION_OPTION(set_global_hotkey_temporary_fast_forward, global_hotkey_temporary_fast_forward_passive, &msg[MSG_HOTKEY_TEMPORARY_FAST_FORWARD], NULL, 2),
+
+ /* 03 */ ACTION_OPTION(set_global_hotkey_toggle_sound, global_hotkey_toggle_sound_passive, &msg[MSG_HOTKEY_SOUND_TOGGLE], NULL, 3)
+ };
+
+ MAKE_MENU(tools_global_hotkeys, NULL, NULL, NULL, NULL, 0, 0);
+
+ /*--------------------------------------------------------
+ Tools - Game-specific hotkey overrides
+ --------------------------------------------------------*/
+ MENU_OPTION_TYPE tools_game_specific_hotkeys_options[] =
+ {
+ /* 00 */ SUBMENU_OPTION(&tools_menu, &msg[MSG_TOOLS_GAME_HOTKEY_GENERAL], NULL, 0),
+
+ /* 01 */ ACTION_OPTION(set_game_specific_hotkey_return_to_menu, game_specific_hotkey_return_to_menu_passive, &msg[MSG_HOTKEY_MAIN_MENU], NULL, 1),
+
+ /* 02 */ ACTION_OPTION(set_game_specific_hotkey_temporary_fast_forward, game_specific_hotkey_temporary_fast_forward_passive, &msg[MSG_HOTKEY_TEMPORARY_FAST_FORWARD], NULL, 2),
+
+ /* 03 */ ACTION_OPTION(set_game_specific_hotkey_toggle_sound, game_specific_hotkey_toggle_sound_passive, &msg[MSG_HOTKEY_SOUND_TOGGLE], NULL, 3)
+ };
+
+ MAKE_MENU(tools_game_specific_hotkeys, NULL, NULL, NULL, NULL, 0, 0);
+
/*--------------------------------------------------------
Tools
--------------------------------------------------------*/
@@ -2900,6 +2946,10 @@ u32 menu(u16 *screen)
/* 01 */ SUBMENU_OPTION(&tools_screensnap_menu, &msg[MSG_TOOLS_SCREENSHOT_GENERAL], NULL, 1),
+ /* 02 */ SUBMENU_OPTION(&tools_global_hotkeys_menu, &msg[MSG_TOOLS_GLOBAL_HOTKEY_GENERAL], NULL, 2),
+
+ /* 03 */ SUBMENU_OPTION(&tools_game_specific_hotkeys_menu, &msg[MSG_TOOLS_GAME_HOTKEY_GENERAL], NULL, 3)
+
// /* 02 */ SUBMENU_OPTION(&tools_keyremap_menu, &msg[MSG_SUB_MENU_31], NULL, 2),
// /* 03 */ STRING_SELECTION_OPTION(time_backward_action, NULL, &msg[MSG_SUB_MENU_302], on_off_options,
@@ -3145,6 +3195,114 @@ u32 menu(u16 *screen)
else
tools_options[4].option_type |= HIDEN_TYPE; */
// OUT OF BOUNDS MEMORY ACCESS, REENABLE IF NEEDED [NEB]
+ if (first_load)
+ tools_options[3] /* game hotkeys */.option_type |= HIDEN_TYPE;
+ else
+ tools_options[3] /* game hotkeys */.option_type &= ~HIDEN_TYPE;
+ }
+
+ void obtain_hotkey (u32 *HotkeyBitfield)
+ {
+ draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color);
+ draw_string_vcenter(down_screen_addr, 36, 75, 190, COLOR_MSSG, msg[MSG_PROGRESS_HOTKEY_WAITING_FOR_KEYS]);
+
+ u32 Keys = draw_hotkey_dialog(DOWN_SCREEN, 115, msg[MSG_HOTKEY_DELETE_WITH_A], msg[MSG_HOTKEY_CANCEL_WITH_B]);
+ if (Keys == KEY_B)
+ ; // unmodified
+ else if (Keys == KEY_A)
+ *HotkeyBitfield = 0; // clear
+ else
+ *HotkeyBitfield = Keys; // set
+ }
+
+ void set_global_hotkey_return_to_menu()
+ {
+ obtain_hotkey(&emu_config.HotkeyReturnToMenu);
+ }
+
+ void set_global_hotkey_temporary_fast_forward()
+ {
+ obtain_hotkey(&emu_config.HotkeyTemporaryFastForward);
+ }
+
+ void set_global_hotkey_toggle_sound()
+ {
+ obtain_hotkey(&emu_config.HotkeyToggleSound);
+ }
+
+ void set_game_specific_hotkey_return_to_menu()
+ {
+ obtain_hotkey(&game_config.HotkeyReturnToMenu);
+ }
+
+ void set_game_specific_hotkey_temporary_fast_forward()
+ {
+ obtain_hotkey(&game_config.HotkeyTemporaryFastForward);
+ }
+
+ void set_game_specific_hotkey_toggle_sound()
+ {
+ obtain_hotkey(&game_config.HotkeyToggleSound);
+ }
+
+#define HOTKEY_CONTENT_X 156
+ void hotkey_option_passive_common(u32 HotkeyBitfield)
+ {
+ unsigned short color;
+ char tmp_buf[512];
+ unsigned int len;
+
+ if(display_option == current_option)
+ color= COLOR_ACTIVE_ITEM;
+ else
+ color= COLOR_INACTIVE_ITEM;
+
+ strcpy(tmp_buf, *(display_option->display_string));
+ PRINT_STRING_BG(down_screen_addr, tmp_buf, color, COLOR_TRANS, 23, 40 + display_option-> line_number*27);
+
+ // Construct a UTF-8 string showing the buttons in the
+ // bitfield.
+ tmp_buf[0] = '\0';
+ if (HotkeyBitfield & KEY_L) strcpy(tmp_buf, HOTKEY_L_DISPLAY);
+ if (HotkeyBitfield & KEY_R) strcat(tmp_buf, HOTKEY_R_DISPLAY);
+ if (HotkeyBitfield & KEY_A) strcat(tmp_buf, HOTKEY_A_DISPLAY);
+ if (HotkeyBitfield & KEY_B) strcat(tmp_buf, HOTKEY_B_DISPLAY);
+ if (HotkeyBitfield & KEY_Y) strcat(tmp_buf, HOTKEY_Y_DISPLAY);
+ if (HotkeyBitfield & KEY_X) strcat(tmp_buf, HOTKEY_X_DISPLAY);
+ if (HotkeyBitfield & KEY_START) strcat(tmp_buf, HOTKEY_START_DISPLAY);
+ if (HotkeyBitfield & KEY_SELECT) strcat(tmp_buf, HOTKEY_SELECT_DISPLAY);
+
+ PRINT_STRING_BG(down_screen_addr, tmp_buf, color, COLOR_TRANS, HOTKEY_CONTENT_X, 40 + display_option-> line_number*27);
+ }
+
+ void global_hotkey_return_to_menu_passive()
+ {
+ hotkey_option_passive_common(emu_config.HotkeyReturnToMenu);
+ }
+
+ void global_hotkey_temporary_fast_forward_passive()
+ {
+ hotkey_option_passive_common(emu_config.HotkeyTemporaryFastForward);
+ }
+
+ void global_hotkey_toggle_sound_passive()
+ {
+ hotkey_option_passive_common(emu_config.HotkeyToggleSound);
+ }
+
+ void game_specific_hotkey_return_to_menu_passive()
+ {
+ hotkey_option_passive_common(game_config.HotkeyReturnToMenu);
+ }
+
+ void game_specific_hotkey_temporary_fast_forward_passive()
+ {
+ hotkey_option_passive_common(game_config.HotkeyTemporaryFastForward);
+ }
+
+ void game_specific_hotkey_toggle_sound_passive()
+ {
+ hotkey_option_passive_common(game_config.HotkeyToggleSound);
}
int lastest_game_menu_scroll_value;