diff options
author | Nebuleon Fumika | 2013-01-23 20:16:46 -0500 |
---|---|---|
committer | Nebuleon Fumika | 2013-01-23 20:16:46 -0500 |
commit | 433749b6ef1e2b070755c3bb7fc0d81b5ecaa7b1 (patch) | |
tree | 38600503fea7fa1607ebb1e7c501d1f4d41f88b8 /source/nds | |
parent | 40596a7d6810c2d3bc2db28e8f9c2b825972d21d (diff) | |
parent | d57eea6b4fd4d5d642cb730f6291dabfb0c6a633 (diff) | |
download | snesemu-433749b6ef1e2b070755c3bb7fc0d81b5ecaa7b1.tar.gz snesemu-433749b6ef1e2b070755c3bb7fc0d81b5ecaa7b1.tar.bz2 snesemu-433749b6ef1e2b070755c3bb7fc0d81b5ecaa7b1.zip |
Merge branch 'master' into 8bitsound
Diffstat (limited to 'source/nds')
-rw-r--r-- | source/nds/draw.c | 26 | ||||
-rw-r--r-- | source/nds/entry.cpp | 26 | ||||
-rw-r--r-- | source/nds/gui.c | 172 |
3 files changed, 215 insertions, 9 deletions
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 792608a..702442e 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 293361f..09e01ac 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -61,7 +61,7 @@ char *language_options[] = { (char *) &lang[0], (char *) &lang[1], (char *) &lan ******************************************************************************/ #define SUBMENU_ROW_NUM 6 -#define NDSSFC_VERSION "1.22" +#define NDSSFC_VERSION "1.23" #define SAVE_STATE_SLOT_NUM 16 @@ -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; @@ -3615,6 +3773,8 @@ u32 menu(u16 *screen) } else if(current_option->option_type & ACTION_TYPE) current_option->action_function(); + else if(current_option->option_type & SUBMENU_TYPE) + choose_menu(current_option->sub_menu); } /* Save states */ else if(current_menu == (main_menu.options + 1)->sub_menu) @@ -3894,6 +4054,10 @@ u32 menu(u16 *screen) ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); } // end while + + if (current_menu && current_menu->end_function) + current_menu->end_function(); + destroy_dynamic_cheats(); if(bg_screenp != NULL) free((void*)bg_screenp); |