diff options
author | Nebuleon Fumika | 2013-01-19 02:24:37 -0500 |
---|---|---|
committer | Nebuleon Fumika | 2013-01-19 02:24:37 -0500 |
commit | 2bb2ee8c0aee044998858ff8263be71cb908a663 (patch) | |
tree | e350afccb07324962f773e5372254e4da31d7e99 /source | |
parent | 71a57cc449a42721eb0cd90cab07c57bbd9c9512 (diff) | |
download | snes9x2005-2bb2ee8c0aee044998858ff8263be71cb908a663.tar.gz snes9x2005-2bb2ee8c0aee044998858ff8263be71cb908a663.tar.bz2 snes9x2005-2bb2ee8c0aee044998858ff8263be71cb908a663.zip |
Prepare code to ask for a hotkey. Prepare a temporary fast-forward switch.
Diffstat (limited to 'source')
-rw-r--r-- | source/nds/draw.c | 78 | ||||
-rw-r--r-- | source/nds/draw.h | 1 | ||||
-rw-r--r-- | source/nds/entry.cpp | 8 | ||||
-rw-r--r-- | source/nds/gui.c | 11 | ||||
-rw-r--r-- | source/nds/gui.h | 2 | ||||
-rw-r--r-- | source/nds/message.h | 3 |
6 files changed, 98 insertions, 5 deletions
diff --git a/source/nds/draw.c b/source/nds/draw.c index 6799836..b6916a3 100644 --- a/source/nds/draw.c +++ b/source/nds/draw.c @@ -830,6 +830,84 @@ u32 draw_yesno_dialog(enum SCREEN_ID screen, u32 sy, char *yes, char *no) } /* +* Draw hotkey dialog +* Returns DS keys pressed, as in ds2io.h. +*/ +u32 draw_hotkey_dialog(enum SCREEN_ID screen, u32 sy, char *clear, char *cancel) +{ + u16 unicode[8]; + u32 len, width, box_width, i; + char *string; + void* screen_addr; + + len= 0; + string= clear; + while(*string) + { + string= utf8decode(string, &unicode[len]); + if(unicode[len] != 0x0D && unicode[len] != 0x0A) + { + if(len < 8) len++; + else break; + } + } + width= BDF_cut_unicode(unicode, len, 0, 3); + + len= 0; + string= cancel; + while(*string) + { + string= utf8decode(string, &unicode[len]); + if(unicode[len] != 0x0D && unicode[len] != 0x0A) + { + if(len < 8) len++; + else break; + } + } + i= BDF_cut_unicode(unicode, len, 0, 3); + + if(width < i) width= i; + box_width= 64; + if(box_width < (width +6)) box_width = width +6; + + if(screen & UP_MASK) + screen_addr = up_screen_addr; + else + screen_addr = down_screen_addr; + + i= SCREEN_WIDTH/2 - box_width - 2; + show_icon((unsigned short*)screen_addr, &ICON_BUTTON, 49, 128); + draw_string_vcenter((unsigned short*)screen_addr, 51, 130, 73, COLOR_WHITE, clear); + + i= SCREEN_WIDTH/2 + 3; + show_icon((unsigned short*)screen_addr, &ICON_BUTTON, 136, 128); + draw_string_vcenter((unsigned short*)screen_addr, 138, 130, 73, COLOR_WHITE, cancel); + + ds2_flipScreen(screen, 2); + + // While there are no keys pressed, wait for keys. + struct key_buf inputdata; + 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; + + do { + mdelay(1); + ds2_getrawInput(&inputdata); + TotalKeys |= inputdata.key & ~(KEY_TOUCH | KEY_LID | KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT); + } while (inputdata.key != 0); + + return TotalKeys; +} + +/* * Drawing progress bar */ static enum SCREEN_ID _progress_screen_id; diff --git a/source/nds/draw.h b/source/nds/draw.h index c57624e..2b27473 100644 --- a/source/nds/draw.h +++ b/source/nds/draw.h @@ -177,6 +177,7 @@ extern void show_progress(char *text); extern void scrollbar(void* screen_addr, u32 sx, u32 sy, u32 ex, u32 ey, u32 all, u32 view, u32 now); extern u32 yesno_dialog(char *text); extern u32 draw_yesno_dialog(enum SCREEN_ID screen, u32 sy, char *yes, char *no); +extern u32 draw_hotkey_dialog(enum SCREEN_ID screen, u32 sy, char *clear, char *cancel); extern void msg_screen_init(const char *title); extern void msg_screen_draw(); extern void msg_printf(const char *text, ...); diff --git a/source/nds/entry.cpp b/source/nds/entry.cpp index 7852bc9..1fb5bd8 100644 --- a/source/nds/entry.cpp +++ b/source/nds/entry.cpp @@ -588,8 +588,6 @@ static unsigned int sync_last= 0; static unsigned int sync_next = 0; static unsigned int auto_equivalent_skip = 0; -extern "C" u32 game_fast_forward; - static unsigned int skip_rate= 0; void S9xSyncSpeed () @@ -607,7 +605,7 @@ void S9xSyncSpeed () #endif syncnow = getSysTime(); - if (game_fast_forward) + if (game_fast_forward || temporary_fast_forward /* hotkey is held */) { sync_last = syncnow; sync_next = syncnow; @@ -620,7 +618,7 @@ void S9xSyncSpeed () IPPU.RenderThisFrame = true; } } - else if (Settings.SkipFrames == AUTO_FRAMERATE /* && !game_fast_forward */) + else if (Settings.SkipFrames == AUTO_FRAMERATE /* && !game_fast_forward && !temporary_fast_forward */) { // frame_time is in getSysTime units: 42.667 microseconds. int32 frame_time = Settings.PAL ? 468 /* = 20.0 ms */ : 391 /* = 16.67 ms */; @@ -701,7 +699,7 @@ void S9xSyncSpeed () } #endif } - else /* if (Settings.SkipFrames != AUTO_FRAMERATE && !game_fast_forward) */ + else /* if (Settings.SkipFrames != AUTO_FRAMERATE && !game_fast_forward && !temporary_fast_forward) */ { // frame_time is in getSysTime units: 42.667 microseconds. uint32 frame_time = Settings.PAL ? 468 /* = 20.0 ms */ : 391 /* = 16.67 ms */; diff --git a/source/nds/gui.c b/source/nds/gui.c index 0a0a82a..1582b16 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -84,6 +84,16 @@ static int32 latest_save; // Slot number of the latest (in time) save for this g static bool8 SavedStateExistenceCached [SAVE_STATE_SLOT_NUM]; // [I] == TRUE if Cache[I] is meaningful static bool8 SavedStateExistenceCache [SAVE_STATE_SLOT_NUM]; +// These are U+05C8 and subsequent codepoints encoded in UTF-8. +const uint8 HOTKEY_A_DISPLAY[] = {0xD7, 0x88, 0x00}; +const uint8 HOTKEY_B_DISPLAY[] = {0xD7, 0x89, 0x00}; +const uint8 HOTKEY_X_DISPLAY[] = {0xD7, 0x8A, 0x00}; +const uint8 HOTKEY_Y_DISPLAY[] = {0xD7, 0x8B, 0x00}; +const uint8 HOTKEY_L_DISPLAY[] = {0xD7, 0x8C, 0x00}; +const uint8 HOTKEY_R_DISPLAY[] = {0xD7, 0x8D, 0x00}; +const uint8 HOTKEY_START_DISPLAY[] = {0xD7, 0x8E, 0x00}; +const uint8 HOTKEY_SELECT_DISPLAY[] = {0xD7, 0x8F, 0x00}; + #define MAKE_MENU(name, init_function, passive_function, key_function, end_function, \ focus_option, screen_focus) \ MENU_TYPE name##_menu = \ @@ -270,6 +280,7 @@ char DEFAULT_CFG_DIR[MAX_PATH]; char DEFAULT_SS_DIR[MAX_PATH]; char DEFAULT_CHEAT_DIR[MAX_PATH]; u32 game_fast_forward= 0; +u32 temporary_fast_forward = 0; u32 game_enable_audio = 1; diff --git a/source/nds/gui.h b/source/nds/gui.h index 5c1fbd1..d733ee5 100644 --- a/source/nds/gui.h +++ b/source/nds/gui.h @@ -145,6 +145,8 @@ extern char rom_path[MAX_PATH]; extern u32 game_enable_audio; extern u32 clock_speed_number; +extern u32 game_fast_forward; +extern u32 temporary_fast_forward; /****************************************************************************** ******************************************************************************/ diff --git a/source/nds/message.h b/source/nds/message.h index f1de990..0aff8d9 100644 --- a/source/nds/message.h +++ b/source/nds/message.h @@ -53,6 +53,9 @@ enum MSG MSG_HOTKEY_MAIN_MENU, // currently unused MSG_HOTKEY_TEMPORARY_FAST_FORWARD, // currently unused MSG_HOTKEY_SOUND_TOGGLE, // currently unused + MSG_PROGRESS_HOTKEY_WAITING_FOR_KEYS, // currently unused + MSG_HOTKEY_DELETE_WITH_A, // currently unused + MSG_HOTKEY_CANCEL_WITH_B, // currently unused MSG_LOAD_GAME_RECENTLY_PLAYED, MSG_LOAD_GAME_FROM_CARD, MSG_LOAD_GAME_MENU_TITLE, |