From f2f7ef3fe9ac8333b1db09b023dac191ed4736fb Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sat, 26 Jan 2013 17:07:26 -0500 Subject: Fix Tools/Global hotkeys/* refusing to work by touch. --- source/nds/gui.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 09e01ac..9dfe95b 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -3727,7 +3727,6 @@ u32 menu(u16 *screen) && current_menu != ((main_menu.options +1)->sub_menu->options + 3)->sub_menu && current_menu != (main_menu.options +3)->sub_menu && current_menu != ((main_menu.options +3)->sub_menu->options + 1)->sub_menu - && current_menu != ((main_menu.options +3)->sub_menu->options + 2)->sub_menu && current_menu != (main_menu.options +6)->sub_menu && current_menu != ((main_menu.options +6)->sub_menu->options + 2)->sub_menu) { -- cgit v1.2.3 From 365a69d72ebfc986a59d269359bf04f53a18a8e5 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sat, 26 Jan 2013 19:44:37 -0500 Subject: Release 1.24. --- source/nds/gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 9dfe95b..93b3e7b 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.23" +#define NDSSFC_VERSION "1.24" #define SAVE_STATE_SLOT_NUM 16 -- cgit v1.2.3 From 362b28e9372d124ac6602bfc49e9775e510ba929 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sun, 27 Jan 2013 00:30:48 -0500 Subject: Suspend on lid-close in the menu. --- source/nds/gui.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 93b3e7b..ece310c 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -324,6 +324,21 @@ gui_action_type get_gui_input(void) key = getKey(); + if (key & KEY_LID) + { + ds2_setSupend(); + struct key_buf inputdata; + do { + ds2_getrawInput(&inputdata); + mdelay(1); + } while (inputdata.key & KEY_LID); + ds2_wakeup(); + // In the menu, the lower screen's backlight needs to be on, + // and it is on right away after resuming from suspend. + // mdelay(100); // needed to avoid ds2_setBacklight crashing + // ds2_setBacklight(3); + } + switch(key) { case KEY_UP: -- cgit v1.2.3 From cfa1c811c65f1b8a10d9034a5974d617cda92ec6 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sun, 27 Jan 2013 00:45:59 -0500 Subject: Reimplement Quicksort correctly for file selection screens. Before this commit, the emulator could sometimes give a file out of its order, for example an O* file between two S* files. --- source/nds/gui.c | 69 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 35 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index ece310c..c57c660 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -435,53 +435,52 @@ void change_ext(char *src, char *buffer, char *extension) --------------------------------------------------------*/ static int sort_function(const void *dest_str_ptr, const void *src_str_ptr) { - char *dest_str = *((char **)dest_str_ptr); - char *src_str = *((char **)src_str_ptr); + char *dest_str = ((char *)dest_str_ptr); + char *src_str = ((char *)src_str_ptr); // For files and directories, . and .. sort first. - if(src_str[0] == '.') + if(src_str[0] == '.' && dest_str[0] != '.') return 1; - if(dest_str[0] == '.') + if(dest_str[0] == '.' && src_str[0] != '.') return -1; return strcasecmp(dest_str, src_str); } -static int my_array_partion(void *array, int left, int right) +static int my_array_partion(void **array, int left, int right) { - unsigned int pivot= *((unsigned int*)array + left); - - while(left < right) - { - while(sort_function((void*)((unsigned int*)array+left), (void*)((unsigned int *)array+right)) < 0) { - right--; - } - - if(right== left) break; - *((unsigned int*)array + left) = *((unsigned int*)array + right); - *((unsigned int*)array + right) = pivot; - - if(left < right) - { - left++; - if(right== left) break; - } - - while(sort_function((void*)((unsigned int*)array+right), (void*)((unsigned int *)array+left)) > 0) { - left++; - } + // Choose a pivot, left <= pivot <= right + unsigned int pivotIndex = left + (right - left) / 2; + + // Move pivot value to the end + void *temp = array[pivotIndex]; + array[pivotIndex] = array[right]; + array[right] = temp; + + // Move values that sort before the pivot value to before the new + // pivot's location + unsigned int storeIndex = left, i; + for (i = left; i <= right - 1; i++) + { + if (sort_function(array[i], array[right]) < 0) + { + temp = array[i]; + array[i] = array[storeIndex]; + array[storeIndex] = temp; + storeIndex++; + } + } - if(left== right) break; - *((unsigned int*)array + right) = *((unsigned int*)array + left); - *((unsigned int*)array + left) = pivot; - right--; - } + // Move the pivot value to its correct location + temp = array[storeIndex]; + array[storeIndex] = array[right]; + array[right] = temp; - return left; + return storeIndex; } -static void my_qsort(void *array, int left, int right) +static void my_qsort(void **array, int left, int right) { if(left < right) { @@ -748,9 +747,9 @@ static int load_file_list(struct FILE_LIST_INFO *filelist_infop) #if 0 my_qsort((void *)file_list, 0, num_files-1); #else //to support ".." directory, but take it as file - my_qsort((void *)file_list, 1, num_files-1); + my_qsort((void **)file_list, 1, num_files-1); #endif - my_qsort((void *)dir_list, 0, num_dirs-1); + my_qsort((void **)dir_list, 0, num_dirs-1); return 0; } -- cgit v1.2.3 From f0fab191e48f165c551980d724bba2f26a764795 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Tue, 29 Jan 2013 22:24:20 -0500 Subject: Prevent a file descriptor becoming unusable if the emulator configuration file is not in the correct format. --- source/nds/gui.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index c57c660..fd9007b 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -4335,6 +4335,10 @@ int load_emu_config_file(void) fclose(fp); return 0; } + else + { + fclose(fp); + } } //have no confiure file, set default -- cgit v1.2.3 From 60f6ffcc701c4175e31d90f950fb34f6b07a1712 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Fri, 1 Feb 2013 00:36:51 -0500 Subject: When starting CATSFC, assume the backlights are both on, so don't delay 100 milliseconds and set both backlights to on. --- source/nds/gui.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index fd9007b..b529b9f 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -1682,7 +1682,7 @@ unsigned int frame_interval; /*-------------------------------------------------------- Main Menu --------------------------------------------------------*/ -u32 menu(u16 *screen) +u32 menu(u16 *screen, bool8 FirstInvocation) { gui_action_type gui_action; u32 i; @@ -3568,9 +3568,11 @@ u32 menu(u16 *screen) //----------------------------------------------------------------------------// // Menu Start ds2_setCPUclocklevel(0); - mdelay(100); // to prevent ds2_setBacklight() from crashing - ds2_setBacklight(3); - + if (!FirstInvocation) + { // assume that the backlight is already at 3 when the emulator starts + mdelay(100); // to prevent ds2_setBacklight() from crashing + ds2_setBacklight(3); + } wait_Allkey_release(0); bg_screenp= (u16*)malloc(256*192*2); -- cgit v1.2.3 From d4dd98e8c180532f24de342482e54f28874f06ef Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Fri, 1 Feb 2013 20:09:24 -0500 Subject: Add an option that controls which element should be more fluid, per game: video or audio. This makes most games playable, but the player can choose to get fluid audio instead of fluid video in sound-test modes or games with epic soundtracks. --- source/nds/gui.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index b529b9f..b6bd0f4 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -2814,6 +2814,8 @@ u32 menu(u16 *screen, bool8 FirstInvocation) char *frameskip_options[] = { (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_AUTOMATIC], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_0], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_1], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_2], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_3], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_4], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_5], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_6], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_7], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_8], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_9], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_10] }; + char *fluidity_options[] = { (char*)&msg[MSG_VIDEO_AUDIO_FLUIDITY_PREFER_VIDEO], (char*)&msg[MSG_VIDEO_AUDIO_FLUIDITY_PREFER_AUDIO] }; + char *on_off_options[] = { (char*)&msg[MSG_GENERAL_OFF], (char*)&msg[MSG_GENERAL_ON] }; char *sound_seletion[] = { (char*)&msg[MSG_AUDIO_MUTED], (char*)&msg[MSG_AUDIO_ENABLED] }; @@ -2838,8 +2840,11 @@ u32 menu(u16 *screen, bool8 FirstInvocation) /* 03 */ STRING_SELECTION_OPTION(game_disableAudio, NULL, &msg[FMT_AUDIO_SOUND], sound_seletion, &game_enable_audio, 2, NULL, ACTION_TYPE, 3), - /* 04 */ STRING_SELECTION_OPTION(game_set_frameskip, NULL, &msg[FMT_VIDEO_FRAME_SKIPPING], frameskip_options, - &game_config.frameskip_value, 12 /* auto (0) and 0..10 (1..11) make 12 option values */, NULL, ACTION_TYPE, 4) + /* 04 */ STRING_SELECTION_OPTION(game_set_fluidity, NULL, &msg[FMT_VIDEO_AUDIO_FLUIDITY_PREFERENCE], fluidity_options, + &game_config.SoundSync, 2, NULL, ACTION_TYPE, 4), + + /* 05 */ STRING_SELECTION_OPTION(game_set_frameskip, NULL, &msg[FMT_VIDEO_FRAME_SKIPPING], frameskip_options, + &game_config.frameskip_value, 12 /* auto (0) and 0..10 (1..11) make 12 option values */, NULL, ACTION_TYPE, 5) }; MAKE_MENU(graphics, NULL, NULL, NULL, NULL, 0, 0); @@ -4253,6 +4258,7 @@ void init_game_config(void) clock_speed_number = 5; game_config.graphic = 3; // By default, have a good-looking aspect ratio game_config.frameskip_value = 0; // Automatic frame skipping + game_config.SoundSync = 0; // Prefer fluid images by default game_config.backward = 0; //time backward disable game_config.backward_time = 2; //time backward granularity 1s @@ -4306,7 +4312,8 @@ void load_game_config_file(void) fread(&game_config, 1, sizeof(GAME_CONFIG), fp); clock_speed_number = game_config.clock_speed_number; - Settings.SkipFrames = (game_config.frameskip_value == 0 ? AUTO_FRAMERATE : game_config.frameskip_value - 1 /* 1 -> 0 and so on */); + game_set_frameskip(); + game_set_fluidity(); } fclose(fp); -- cgit v1.2.3 From 25aeb83f7bf395a49742c957ada5d2b917fe62aa Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Fri, 1 Feb 2013 20:47:46 -0500 Subject: Release 1.25. --- source/nds/gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index b6bd0f4..3933277 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.24" +#define NDSSFC_VERSION "1.25" #define SAVE_STATE_SLOT_NUM 16 -- cgit v1.2.3 From 984682682c26edb5a9bbcd1e1d8f4aa6ce135596 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sat, 2 Feb 2013 01:39:50 -0500 Subject: Release 1.26. --- source/nds/gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 3933277..4f808b4 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.25" +#define NDSSFC_VERSION "1.26" #define SAVE_STATE_SLOT_NUM 16 -- cgit v1.2.3 From 02f8184fe07d99cceb85f4abd3ef0e5e3765b5ea Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sat, 2 Feb 2013 17:37:51 -0500 Subject: Make it easier to change the "high" and "low" CPU frequencies, as well as to switch to the user's chosen frequency for the game. Conflicts: source/nds/ds2_main.c source/nds/entry.cpp source/nds/gui.c --- source/nds/gui.c | 54 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 4f808b4..3942672 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -1651,12 +1651,22 @@ int save_state(char* file, void* screen) return 0; } -void set_cpu_clock(u32 num) +void LowFrequencyCPU() { - u32 clock_speed_table[6] = {6, 9, 10, 11, 12, 13}; //240, 300, 336, 360, 384, 394 + ds2_setCPUclocklevel(0); // 60 MHz +} + +void HighFrequencyCPU() +{ + ds2_setCPUclocklevel(13); // 396 MHz +} + +void GameFrequencyCPU() +{ + u32 clock_speed_table[6] = {6, 9, 10, 11, 12, 13}; //240, 300, 336, 360, 384, 396 - if(num <= 5) - ds2_setCPUclocklevel(clock_speed_table[num]); + if(clock_speed_number <= 5) + ds2_setCPULevel(clock_speed_table[clock_speed_number]); } void savefast_int(void) @@ -1761,7 +1771,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) void menu_exit() { - ds2_setCPUclocklevel(13); // Crank it up, leave quickly + HighFrequencyCPU(); // Crank it up, leave quickly if(gamepak_name[0] != 0) { game_config.clock_speed_number = clock_speed_number; @@ -1794,9 +1804,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_PROGRESS_LOADING_GAME]); ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); - ds2_setCPUclocklevel(13); + HighFrequencyCPU(); int load_result = load_gamepak(line_buffer); - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); if(load_result == -1) { first_load = 1; @@ -1862,9 +1872,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_PROGRESS_LOADING_GAME]); ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); - ds2_setCPUclocklevel(13); + HighFrequencyCPU(); int load_result = load_gamepak(args[1]); - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); if(load_result == -1) { @@ -2074,9 +2084,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_PROGRESS_SAVED_STATE_CREATING]); ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); - ds2_setCPUclocklevel(13); + HighFrequencyCPU(); int flag = save_state(tmp_filename, (void*)screen); - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); //clear message draw_message(down_screen_addr, NULL, 28, 31, 227, 96, 0); if(flag < 0) @@ -2143,9 +2153,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color); draw_string_vcenter(up_screen_addr, 36, 75, 190, COLOR_MSSG, msg[MSG_PROGRESS_SAVED_STATE_LOADING]); - ds2_setCPUclocklevel(13); + HighFrequencyCPU(); int flag = load_state(tmp_filename); - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); if(0 == flag) { return_value = 1; @@ -2160,9 +2170,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) } else //load screen snapshot { - ds2_setCPUclocklevel(13); + HighFrequencyCPU(); load_game_stat_snapshot(tmp_filename); - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); } } else @@ -2732,7 +2742,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { if(gui_action == CURSOR_LEFT || gui_action == CURSOR_RIGHT) { - ds2_setCPUclocklevel(13); // crank it up + HighFrequencyCPU(); // crank it up if(bg_screenp != NULL) { bg_screenp_color = COLOR16(43, 11, 11); @@ -2757,7 +2767,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) } save_emu_config_file(); - ds2_setCPUclocklevel(0); // and back down + LowFrequencyCPU(); // and back down wait_Allkey_release(0); } } @@ -3497,9 +3507,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) ext_pos = emu_config.latest_file[current_option_num -1]; - ds2_setCPUclocklevel(13); + HighFrequencyCPU(); int load_result = load_gamepak(ext_pos); - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); if(load_result == -1) { first_load = 1; @@ -3572,7 +3582,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) //----------------------------------------------------------------------------// // Menu Start - ds2_setCPUclocklevel(0); + LowFrequencyCPU(); if (!FirstInvocation) { // assume that the backlight is already at 3 when the emulator starts mdelay(100); // to prevent ds2_setBacklight() from crashing @@ -4100,7 +4110,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) mdelay(100); // to prevent ds2_setBacklight() from crashing ds2_setBacklight(2); - set_cpu_clock(clock_speed_number); + GameFrequencyCPU(); return return_value; } @@ -4708,7 +4718,7 @@ void gui_init(u32 lang_id) { int flag; - ds2_setCPUclocklevel(13); // Crank it up. When the menu starts, -> 0. + HighFrequencyCPU(); // Crank it up. When the menu starts, -> 0. // Start with no saved state existing, as no game is loaded yet. int i; -- cgit v1.2.3 From fd92545013ed91d2867e1e180a9b86611eb19f9c Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sun, 3 Feb 2013 04:20:51 -0500 Subject: Whoops. I forgot to replace an instance of ds2_setCPULevel from the experimental branch cherry-pick. --- source/nds/gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 3942672..7100cf2 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -1666,7 +1666,7 @@ void GameFrequencyCPU() u32 clock_speed_table[6] = {6, 9, 10, 11, 12, 13}; //240, 300, 336, 360, 384, 396 if(clock_speed_number <= 5) - ds2_setCPULevel(clock_speed_table[clock_speed_number]); + ds2_setCPUclocklevel(clock_speed_table[clock_speed_number]); } void savefast_int(void) -- cgit v1.2.3 From 4096050f400f0a9cafa237ac11766e6b0faa70f0 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sun, 3 Feb 2013 20:12:29 -0500 Subject: Release 1.27. --- source/nds/gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 7100cf2..e2a469d 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.26" +#define NDSSFC_VERSION "1.27" #define SAVE_STATE_SLOT_NUM 16 -- cgit v1.2.3 From 1c9094d99f6cb2f9ca63134cb7a348370b568b7c Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Mon, 4 Feb 2013 05:57:53 -0500 Subject: Release 1.28 after disabling the controller status sync hack. --- source/nds/gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index e2a469d..3d2ab70 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.27" +#define NDSSFC_VERSION "1.28" #define SAVE_STATE_SLOT_NUM 16 -- cgit v1.2.3 From e7ac6f675f9faf5894aea8dd80e01c649933c322 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Tue, 5 Feb 2013 16:35:45 -0500 Subject: Disable the free space line in the options for the time being. Currently it invokes a recursive directory scan to calculate how much space is used first. --- source/nds/gui.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 3d2ab70..764ca66 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -1756,7 +1756,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) auto void latest_game_menu_end(); auto void language_set(); auto void game_fastforward(); +#ifdef ENABLE_FREE_SPACE auto void show_card_space(); +#endif auto void savestate_selitem(u32 sel, u32 y_pos); auto void game_state_menu_passive(); auto void gamestate_delette_menu_passive(); @@ -2772,6 +2774,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) } } +#ifdef ENABLE_FREE_SPACE unsigned int freespace; void show_card_space () { @@ -2815,6 +2818,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) PRINT_STRING_BG(down_screen_addr, line_buffer, COLOR_INACTIVE_ITEM, COLOR_TRANS, 147, 40 + (display_option->line_number)*27); } +#endif char *screen_ratio_options[] = { (char*)&msg[MSG_VIDEO_ASPECT_RATIO_0], (char*)&msg[MSG_VIDEO_ASPECT_RATIO_1], @@ -3004,12 +3008,26 @@ u32 menu(u16 *screen, bool8 FirstInvocation) /* 02 */ STRING_SELECTION_OPTION(language_set, NULL, &msg[FMT_OPTIONS_LANGUAGE], language_options, &emu_config.language, sizeof(language_options) / sizeof(language_options[0]) /* number of possible languages */, NULL, ACTION_TYPE, 2), +#ifdef ENABLE_FREE_SPACE /* 03 */ STRING_SELECTION_OPTION(NULL, show_card_space, &msg[MSG_OPTIONS_CARD_CAPACITY], NULL, &desert, 2, NULL, PASSIVE_TYPE | HIDEN_TYPE, 3), +#endif - /* 04 */ ACTION_OPTION(load_default_setting, NULL, &msg[MSG_OPTIONS_RESET], NULL, 4), + /* 04 */ ACTION_OPTION(load_default_setting, NULL, &msg[MSG_OPTIONS_RESET], NULL, +#ifdef ENABLE_FREE_SPACE + 4 +#else + 3 +#endif + ), - /* 05 */ ACTION_OPTION(check_gbaemu_version, NULL, &msg[MSG_OPTIONS_VERSION], NULL, 5), + /* 05 */ ACTION_OPTION(check_gbaemu_version, NULL, &msg[MSG_OPTIONS_VERSION], NULL, +#ifdef ENABLE_FREE_SPACE + 5 +#else + 4 +#endif + ), }; MAKE_MENU(others, others_menu_init, NULL, NULL, NULL, 1, 1); @@ -3556,11 +3574,13 @@ u32 menu(u16 *screen, bool8 FirstInvocation) void others_menu_init() { +#ifdef ENABLE_FREE_SPACE unsigned int total, used; //get card space info freespace = 0; fat_getDiskSpaceInfo("fat:", &total, &used, &freespace); +#endif } void choose_menu(MENU_TYPE *new_menu) -- cgit v1.2.3 From f2adea7bb2250876df3d1b6e076a6b5380c6b13e Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Tue, 5 Feb 2013 19:39:09 -0500 Subject: Force both manual and automatic frameskipping to be at or above 2. Resets the default value for all games which previously had this value configured. --- source/nds/gui.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 764ca66..4b5955a 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -2826,7 +2826,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) (char*)&msg[MSG_VIDEO_ASPECT_RATIO_3], (char*)&msg[MSG_VIDEO_ASPECT_RATIO_4]}; - char *frameskip_options[] = { (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_AUTOMATIC], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_0], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_1], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_2], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_3], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_4], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_5], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_6], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_7], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_8], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_9], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_10] }; + char *frameskip_options[] = { (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_AUTOMATIC], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_2], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_3], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_4], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_5], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_6], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_7], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_8], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_9], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_10] }; char *fluidity_options[] = { (char*)&msg[MSG_VIDEO_AUDIO_FLUIDITY_PREFER_VIDEO], (char*)&msg[MSG_VIDEO_AUDIO_FLUIDITY_PREFER_AUDIO] }; @@ -2858,7 +2858,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) &game_config.SoundSync, 2, NULL, ACTION_TYPE, 4), /* 05 */ STRING_SELECTION_OPTION(game_set_frameskip, NULL, &msg[FMT_VIDEO_FRAME_SKIPPING], frameskip_options, - &game_config.frameskip_value, 12 /* auto (0) and 0..10 (1..11) make 12 option values */, NULL, ACTION_TYPE, 5) + &game_config.frameskip_value, 10 /* auto (0) and 2..10 (1..9) make 10 option values */, NULL, ACTION_TYPE, 5) }; MAKE_MENU(graphics, NULL, NULL, NULL, NULL, 0, 0); -- cgit v1.2.3 From 9e87a7a2b2659785bc05266fbb3292b60aecdf27 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Wed, 6 Feb 2013 00:34:01 -0500 Subject: Implement automatic CPU frequency switching, which improves battery life if playing games that don't use all of the MIPS CPU. If all of it is indeed needed, then the game will constantly play at 396 MHz. --- source/nds/gui.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 4b5955a..2dad9c8 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -289,7 +289,6 @@ u32 game_enable_audio = 1; /****************************************************************************** ******************************************************************************/ static u32 menu_cheat_page = 0; -u32 clock_speed_number = 5; u32 gamepad_config_menu; /****************************************************************************** @@ -1665,8 +1664,10 @@ void GameFrequencyCPU() { u32 clock_speed_table[6] = {6, 9, 10, 11, 12, 13}; //240, 300, 336, 360, 384, 396 - if(clock_speed_number <= 5) - ds2_setCPUclocklevel(clock_speed_table[clock_speed_number]); + if (game_config.clock_speed_number == 0) + ds2_setCPUclocklevel(clock_speed_table[AutoCPUFrequency]); + else if(game_config.clock_speed_number <= 6) + ds2_setCPUclocklevel(clock_speed_table[game_config.clock_speed_number - 1]); } void savefast_int(void) @@ -1776,8 +1777,6 @@ u32 menu(u16 *screen, bool8 FirstInvocation) HighFrequencyCPU(); // Crank it up, leave quickly if(gamepak_name[0] != 0) { - game_config.clock_speed_number = clock_speed_number; - reorder_latest_file(); S9xAutoSaveSRAM (); save_game_config_file(); @@ -2828,6 +2827,8 @@ u32 menu(u16 *screen, bool8 FirstInvocation) char *frameskip_options[] = { (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_AUTOMATIC], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_2], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_3], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_4], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_5], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_6], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_7], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_8], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_9], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_10] }; + char *cpu_frequency_options[] = { (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_AUTOMATIC], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_0], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_1], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_2], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_3], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_4], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_5] }; + char *fluidity_options[] = { (char*)&msg[MSG_VIDEO_AUDIO_FLUIDITY_PREFER_VIDEO], (char*)&msg[MSG_VIDEO_AUDIO_FLUIDITY_PREFER_AUDIO] }; char *on_off_options[] = { (char*)&msg[MSG_GENERAL_OFF], (char*)&msg[MSG_GENERAL_ON] }; @@ -3002,8 +3003,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { /* 00 */ SUBMENU_OPTION(NULL, &msg[MSG_MAIN_MENU_OPTIONS], NULL, 0), - //CPU speed - /* 01 */ NUMERIC_SELECTION_OPTION(NULL, &msg[FMT_OPTIONS_CPU_FREQUENCY], &clock_speed_number, 6, NULL, 1), + //CPU speed (string: shows MHz) + /* 01 */ STRING_SELECTION_OPTION(NULL, NULL, &msg[FMT_OPTIONS_CPU_FREQUENCY], cpu_frequency_options, + &game_config.clock_speed_number, 7, NULL, PASSIVE_TYPE, 1), /* 02 */ STRING_SELECTION_OPTION(language_set, NULL, &msg[FMT_OPTIONS_LANGUAGE], language_options, &emu_config.language, sizeof(language_options) / sizeof(language_options[0]) /* number of possible languages */, NULL, ACTION_TYPE, 2), @@ -4113,8 +4115,6 @@ u32 menu(u16 *screen, bool8 FirstInvocation) if(gamepak_name[0] != 0) { - game_config.clock_speed_number = clock_speed_number; - reorder_latest_file(); S9xAutoSaveSRAM (); save_game_config_file(); @@ -4284,8 +4284,7 @@ u32 load_font() --------------------------------------------------------*/ void init_game_config(void) { - game_config.clock_speed_number = 5; // 396 MHz by default - clock_speed_number = 5; + game_config.clock_speed_number = 0; // "Auto" by default game_config.graphic = 3; // By default, have a good-looking aspect ratio game_config.frameskip_value = 0; // Automatic frame skipping game_config.SoundSync = 0; // Prefer fluid images by default @@ -4341,7 +4340,6 @@ void load_game_config_file(void) { fread(&game_config, 1, sizeof(GAME_CONFIG), fp); - clock_speed_number = game_config.clock_speed_number; game_set_frameskip(); game_set_fluidity(); } -- cgit v1.2.3 From 4ac61d443d5786db1b1e365e0005a1d5740183b0 Mon Sep 17 00:00:00 2001 From: BassAceGold Date: Wed, 6 Feb 2013 00:56:33 -0500 Subject: Load the game from plug-in launch arguments. Make the CATSFC system directory become the one transferred via arguments in that case. --- source/nds/gui.c | 276 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 143 insertions(+), 133 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 2dad9c8..495e3c8 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -45,10 +45,13 @@ char rom_path[MAX_PATH]; char gamepak_name[MAX_PATH]; char gcheat_filename[MAX_PATH]; +//program arguments +char argv[2][MAX_PATH]; + // If adding a language, make sure you update the size of the array in // message.h too. char *lang[3] = - { + { "English", // 0 "简体中文", // 1 "Français", // 2 @@ -571,7 +574,7 @@ static int manage_filelist_info(struct FILE_LIST_INFO *filelist_infop, int flag) int i; void *pt; - //Increase all + //Increase all if(flag & 0x1) { i = NAME_MEM_SIZE; @@ -1095,7 +1098,7 @@ s32 load_file(char **wildcards, char *result, char *default_dir_name) //Path if(-1 == redraw) { draw_hscroll_over(0); - draw_hscroll_init(down_screen_addr, 49, 10, 170, COLOR_TRANS, + draw_hscroll_init(down_screen_addr, 49, 10, 170, COLOR_TRANS, COLOR_WHITE, default_dir_name); path_scroll = 0x8000; //first scroll left } @@ -1142,7 +1145,7 @@ s32 load_file(char **wildcards, char *result, char *default_dir_name) pt = file_list[m]; } - draw_hscroll_init(down_screen_addr, 41, 40 + k*27, 185, + draw_hscroll_init(down_screen_addr, 41, 40 + k*27, 185, COLOR_TRANS, color, pt); } @@ -1273,7 +1276,7 @@ u32 play_screen_snapshot(void) if(draw_yesno_dialog(DOWN_SCREEN, 115, msg[MSG_GENERAL_CONFIRM_WITH_A], msg[MSG_GENERAL_CANCEL_WITH_B])) return 1; - else + else return 0; } @@ -1378,7 +1381,7 @@ u32 play_screen_snapshot(void) time1= time0; } break; - + case CURSOR_DOWN: if(!pause) { @@ -1386,21 +1389,21 @@ u32 play_screen_snapshot(void) time1= time0; } break; - + case CURSOR_LEFT: time1 = ticks; if(i > 1) i -= 2; else if(i == 1) i= file_num -1; else i= file_num -2; break; - + case CURSOR_RIGHT: time1 = ticks; break; - + case CURSOR_SELECT: if(!pause) - { + { time1 = -1; pause= 1; } @@ -1408,15 +1411,15 @@ u32 play_screen_snapshot(void) { time1 = ticks; pause= 0; - } + } break; - - case CURSOR_BACK: + + case CURSOR_BACK: if(screenp) free((void*)screenp); //deconstruct filelist_info struct manage_filelist_info(&filelist_info, -1); repeat = 0; - break; + break; default: gui_action= CURSOR_NONE; break; @@ -1456,7 +1459,7 @@ int search_dir(char *directory, char* directory_path) //while((current_file = readdir(current_dir)) != NULL) while((current_file = readdir_ex(current_dir, &st)) != NULL) { - //Is directory + //Is directory if(S_ISDIR(st.st_mode)) { if(strcmp(".", current_file->d_name) || strcmp("..", current_file->d_name)) @@ -1635,7 +1638,7 @@ int save_state(char* file, void* screen) n = ftell(fp); ds2_getTime(&time); - sprintf(str, "%02d-%02d %02d:%02d:%02d", + sprintf(str, "%02d-%02d %02d:%02d:%02d", time.month, time.day, time.hours, time.minutes, time.seconds); PRINT_STRING_BG(screen, str, COLOR_WHITE, COLOR_BLACK, 0, 0); @@ -1709,7 +1712,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) MENU_TYPE *current_menu = NULL; MENU_OPTION_TYPE *current_option = NULL; MENU_OPTION_TYPE *display_option = NULL; - + u32 current_option_num; // u32 parent_option_num; u32 string_select; @@ -1801,7 +1804,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) strcat(line_buffer, "/"); strcat(line_buffer, tmp_filename); - draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color); + draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color); draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_PROGRESS_LOADING_GAME]); ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); @@ -1833,71 +1836,36 @@ u32 menu(u16 *screen, bool8 FirstInvocation) choose_menu(current_menu); } } - - bool Get_Args(char *file, char **filebuf) - { - FILE* dat = fat_fopen(file, "rb"); - if(dat) - { - int i = 0; - while(!fat_feof (dat)) - { - fat_fgets(filebuf[i], 512, dat); - int len = strlen(filebuf[i]); - if(filebuf[i][len - 1] == '\n') - filebuf[i][len - 1] = '\0'; - i++; - } - - fat_fclose(dat); - fat_remove(file); - return i; - } - return 0; - } - int CheckLoad_Arg() - { - char args[2][512]; - char *argarray[2]; - - argarray[0] = args[0]; - argarray[1] = args[1]; - - if(!Get_Args("/plgargs.dat", argarray)) - return 0; - - fat_remove("plgargs.dat"); - - draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color); - draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_PROGRESS_LOADING_GAME]); - ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); + int Menu_loadGame(char *filename){ + draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color); + draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_PROGRESS_LOADING_GAME]); + ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); - HighFrequencyCPU(); - int load_result = load_gamepak(args[1]); - LowFrequencyCPU(); + HighFrequencyCPU(); + int load_result = load_gamepak(filename); + LowFrequencyCPU(); - if(load_result == -1) - { - first_load = 1; - gamepak_name[0] = '\0'; - return 0; - } + if(load_result == -1) + { + first_load = 1; + gamepak_name[0] = '\0'; + return 0; + } - strcpy(gamepak_name, args[1]); - first_load = 0; - load_game_config_file(); + strcpy(gamepak_name, filename); + first_load = 0; + load_game_config_file(); - return_value = 1; - repeat = 0; + return_value = 1; + repeat = 0; - reorder_latest_file(); - get_savestate_filelist(); + reorder_latest_file(); + get_savestate_filelist(); - game_fast_forward= 0; - return 1; - - } + game_fast_forward= 0; + return 1; + } void menu_restart() { @@ -2111,7 +2079,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) } } } - + void menu_load_state() { if(!first_load) @@ -2151,7 +2119,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) //right if(gui_action == CURSOR_SELECT) { - draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color); + draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color); draw_string_vcenter(up_screen_addr, 36, 75, 190, COLOR_MSSG, msg[MSG_PROGRESS_SAVED_STATE_LOADING]); HighFrequencyCPU(); @@ -2235,7 +2203,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) } else if(current_option_num == 2) //delette single { - draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color); + draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color); if(SavedStateFileExists(delette_savestate_num)) { @@ -2303,7 +2271,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { m= current_menu->screen_focus -1; draw_hscroll_over(m+1); - draw_hscroll_init(down_screen_addr, 23, 40 + m*27, 200, + draw_hscroll_init(down_screen_addr, 23, 40 + m*27, 200, COLOR_TRANS, COLOR_INACTIVE_ITEM, *dynamic_cheat_options[current_option_num].display_string); } else @@ -2313,7 +2281,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) m= current_menu->focus_option - current_menu->screen_focus+2; for(n= 0; n < SUBMENU_ROW_NUM-1; n++) - draw_hscroll_init(down_screen_addr, 23, 40 + n*27, 200, + draw_hscroll_init(down_screen_addr, 23, 40 + n*27, 200, COLOR_TRANS, COLOR_INACTIVE_ITEM, *dynamic_cheat_options[m+n].display_string); } } @@ -2321,7 +2289,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) if(current_option_num == 0) { draw_hscroll_over(0); - draw_hscroll_init(down_screen_addr, 50, 9, 180, + draw_hscroll_init(down_screen_addr, 50, 9, 180, COLOR_TRANS, COLOR_ACTIVE_ITEM, *dynamic_cheat_options[0].display_string); } @@ -2334,7 +2302,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) if(m >= SUBMENU_ROW_NUM) m -= 1; draw_hscroll_over(m+1); - draw_hscroll_init(down_screen_addr, 23, 40 + m*27, 200, + draw_hscroll_init(down_screen_addr, 23, 40 + m*27, 200, COLOR_TRANS, COLOR_ACTIVE_ITEM, *dynamic_cheat_options[current_option_num].display_string); } @@ -2348,7 +2316,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { m = current_menu->screen_focus -1; draw_hscroll_over(m+1); - draw_hscroll_init(down_screen_addr, 23, 40 + m*27, 200, + draw_hscroll_init(down_screen_addr, 23, 40 + m*27, 200, COLOR_TRANS, COLOR_INACTIVE_ITEM, *dynamic_cheat_options[current_option_num].display_string); } else @@ -2363,7 +2331,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) if(k > SUBMENU_ROW_NUM) k = SUBMENU_ROW_NUM; for(n= 1; n < k; n++) - draw_hscroll_init(down_screen_addr, 23, 40 + n*27, 200, + draw_hscroll_init(down_screen_addr, 23, 40 + n*27, 200, COLOR_TRANS, COLOR_INACTIVE_ITEM, *dynamic_cheat_options[m+n].display_string); } } @@ -2375,7 +2343,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) if(current_option_num == 0) { draw_hscroll_over(0); - draw_hscroll_init(down_screen_addr, 50, 9, 180, + draw_hscroll_init(down_screen_addr, 50, 9, 180, COLOR_TRANS, COLOR_ACTIVE_ITEM, *dynamic_cheat_options[0].display_string); } } @@ -2390,7 +2358,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) m = current_menu->screen_focus -1; draw_hscroll_over(m+1); - draw_hscroll_init(down_screen_addr, 23, 40 + m*27, 200, + draw_hscroll_init(down_screen_addr, 23, 40 + m*27, 200, COLOR_TRANS, COLOR_ACTIVE_ITEM, *dynamic_cheat_options[current_option_num].display_string); } break; @@ -2666,7 +2634,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) mm = *(display_option->current_option); sprintf(line_buffer, *(display_option->display_string), str[mm]); - + PRINT_STRING_BG(down_screen_addr, line_buffer, color, COLOR_TRANS, 27, 38 + (display_option-> line_number)*32); } @@ -2757,7 +2725,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) draw_string_vcenter(down_screen_addr, 36, 95, 190, COLOR_MSSG, msg[MSG_CHANGE_LANGUAGE_WAITING]); ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); - load_language_msg(LANGUAGE_PACK, emu_config.language); + load_language_msg(LANGUAGE_PACK, emu_config.language); // gui_change_icon(emu_config.language); // uncomment if images change per language [Neb] if(first_load) @@ -2846,18 +2814,18 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { /* 00 */ SUBMENU_OPTION(NULL, &msg[MSG_MAIN_MENU_VIDEO_AUDIO], NULL, 0), - /* 01 */ STRING_SELECTION_OPTION(NULL, NULL, &msg[FMT_VIDEO_ASPECT_RATIO], screen_ratio_options, + /* 01 */ STRING_SELECTION_OPTION(NULL, NULL, &msg[FMT_VIDEO_ASPECT_RATIO], screen_ratio_options, &game_config.graphic, 5, NULL, PASSIVE_TYPE, 1), - /* 02 */ STRING_SELECTION_OPTION(game_fastforward, NULL, &msg[FMT_VIDEO_FAST_FORWARD], on_off_options, + /* 02 */ STRING_SELECTION_OPTION(game_fastforward, NULL, &msg[FMT_VIDEO_FAST_FORWARD], on_off_options, &game_fast_forward, 2, NULL, ACTION_TYPE, 2), - + /* 03 */ STRING_SELECTION_OPTION(game_disableAudio, NULL, &msg[FMT_AUDIO_SOUND], sound_seletion, &game_enable_audio, 2, NULL, ACTION_TYPE, 3), - + /* 04 */ STRING_SELECTION_OPTION(game_set_fluidity, NULL, &msg[FMT_VIDEO_AUDIO_FLUIDITY_PREFERENCE], fluidity_options, &game_config.SoundSync, 2, NULL, ACTION_TYPE, 4), - + /* 05 */ STRING_SELECTION_OPTION(game_set_frameskip, NULL, &msg[FMT_VIDEO_FRAME_SKIPPING], frameskip_options, &game_config.frameskip_value, 10 /* auto (0) and 2..10 (1..9) make 10 option values */, NULL, ACTION_TYPE, 5) }; @@ -2905,9 +2873,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { /* 00 */ SUBMENU_OPTION(NULL, &msg[MSG_MAIN_MENU_CHEATS], NULL,0), - /* 01 */ CHEAT_OPTION(cheat_option_action, cheat_option_passive, + /* 01 */ CHEAT_OPTION(cheat_option_action, cheat_option_passive, ((CHEATS_PER_PAGE * menu_cheat_page) + 0), 1), - /* 02 */ CHEAT_OPTION(cheat_option_action, cheat_option_passive, + /* 02 */ CHEAT_OPTION(cheat_option_action, cheat_option_passive, ((CHEATS_PER_PAGE * menu_cheat_page) + 1), 2), /* 03 */ CHEAT_OPTION(cheat_option_action, cheat_option_passive, ((CHEATS_PER_PAGE * menu_cheat_page) + 2), 3), @@ -2974,7 +2942,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) /*-------------------------------------------------------- Tools --------------------------------------------------------*/ - MENU_OPTION_TYPE tools_options[] = + MENU_OPTION_TYPE tools_options[] = { /* 00 */ SUBMENU_OPTION(NULL, &msg[MSG_MAIN_MENU_TOOLS], NULL, 0), @@ -2986,10 +2954,10 @@ u32 menu(u16 *screen, bool8 FirstInvocation) // /* 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, +// /* 03 */ STRING_SELECTION_OPTION(time_backward_action, NULL, &msg[MSG_SUB_MENU_302], on_off_options, // &game_config.backward, 2, NULL, ACTION_TYPE, 3), -// /* 04 */ NUMERIC_SELECTION_ACTION_OPTION(time_period_action, time_period_passive, &msg[MSG_SUB_MENU_32], +// /* 04 */ NUMERIC_SELECTION_ACTION_OPTION(time_period_action, time_period_passive, &msg[MSG_SUB_MENU_32], // &game_config.backward_time, 6, NULL, 4) }; @@ -3038,7 +3006,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) Load_game --------------------------------------------------------*/ MENU_TYPE latest_game_menu; - + MENU_OPTION_TYPE load_game_options[] = { /* 00 */ SUBMENU_OPTION(NULL, &msg[MSG_LOAD_GAME_MENU_TITLE], NULL, 0), @@ -3169,7 +3137,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) show_icon(down_screen_addr, &ICON_MSEL, 173, 131); } else { - show_icon(down_screen_addr, &ICON_NEXIT, 187, 75); + show_icon(down_screen_addr, &ICON_NEXIT, 187, 75); show_icon(down_screen_addr, &ICON_MNSEL, 173, 131); } draw_string_vcenter(down_screen_addr, 175, 131, 75, COLOR_WHITE, line_buffer); @@ -3364,7 +3332,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { ext_pos= strrchr(emu_config.latest_file[k], '/'); if(ext_pos != NULL) - draw_hscroll_init(down_screen_addr, 26, 40 + k*27, 200, + draw_hscroll_init(down_screen_addr, 26, 40 + k*27, 200, COLOR_TRANS, COLOR_INACTIVE_ITEM, ext_pos+1); else break; @@ -3422,7 +3390,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) void latest_game_menu_end() { u32 k; - + for(k= 0; k < 5; k++) { if(emu_config.latest_file[k][0] != '\0') @@ -3442,12 +3410,12 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { draw_hscroll_over(current_option_num-1); ext_pos= strrchr(emu_config.latest_file[current_option_num-1], '/'); - draw_hscroll_init(down_screen_addr, 26, 40 + (current_option_num-1)*27, 200, + draw_hscroll_init(down_screen_addr, 26, 40 + (current_option_num-1)*27, 200, COLOR_TRANS, COLOR_INACTIVE_ITEM, ext_pos+1); } current_option_num += 1; - if(current_option_num >= latest_game_menu.num_options) + if(current_option_num >= latest_game_menu.num_options) current_option_num = 0; current_option = current_menu->options + current_option_num; @@ -3456,7 +3424,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { draw_hscroll_over(current_option_num-1); ext_pos= strrchr(emu_config.latest_file[current_option_num-1], '/'); - draw_hscroll_init(down_screen_addr, 26, 40 + (current_option_num-1)*27, 200, + draw_hscroll_init(down_screen_addr, 26, 40 + (current_option_num-1)*27, 200, COLOR_TRANS, COLOR_ACTIVE_ITEM, ext_pos+1); } @@ -3468,7 +3436,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { draw_hscroll_over(current_option_num-1); ext_pos= strrchr(emu_config.latest_file[current_option_num-1], '/'); - draw_hscroll_init(down_screen_addr, 26, 40 + (current_option_num-1)*27, 200, + draw_hscroll_init(down_screen_addr, 26, 40 + (current_option_num-1)*27, 200, COLOR_TRANS, COLOR_INACTIVE_ITEM, ext_pos+1); } @@ -3481,7 +3449,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { draw_hscroll_over(current_option_num-1); ext_pos= strrchr(emu_config.latest_file[current_option_num-1], '/'); - draw_hscroll_init(down_screen_addr, 26, 40 + (current_option_num-1)*27, 200, + draw_hscroll_init(down_screen_addr, 26, 40 + (current_option_num-1)*27, 200, COLOR_TRANS, COLOR_ACTIVE_ITEM, ext_pos+1); } @@ -3562,7 +3530,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) void game_fastforward() { } - + void reload_cheats_page() @@ -3610,7 +3578,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) mdelay(100); // to prevent ds2_setBacklight() from crashing ds2_setBacklight(3); } - + wait_Allkey_release(0); bg_screenp= (u16*)malloc(256*192*2); @@ -3619,7 +3587,8 @@ u32 menu(u16 *screen, bool8 FirstInvocation) if(gamepak_name[0] == 0) { first_load = 1; - if(CheckLoad_Arg()) + //try auto loading games passed through argv first + if(Menu_loadGame(argv[1])) repeat = 0; else { @@ -3642,7 +3611,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) choose_menu(&main_menu); // Menu loop - + while(repeat) { display_option = current_menu->options; @@ -3691,7 +3660,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) focus_option = line_num; } current_menu -> focus_option = focus_option; - + i = focus_option - screen_focus; display_option += i +1; @@ -3737,7 +3706,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) color= COLOR_ACTIVE_ITEM; else color= COLOR_INACTIVE_ITEM; - + PRINT_STRING_BG(down_screen_addr, line_buffer, color, COLOR_TRANS, 23, 40 + i*27); } } @@ -3767,7 +3736,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) current_option_num = (inputdata.y / 80) * 3 + (inputdata.x / 86); current_option = current_menu->options + current_option_num; - + if(current_option -> option_type & HIDEN_TYPE) break; else if(current_option->option_type & ACTION_TYPE) @@ -3776,9 +3745,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) choose_menu(current_option->sub_menu); } /* This is the majority case, covering all menus except save states, screen shots, and game loading */ - else if(current_menu != (main_menu.options + 1)->sub_menu + else if(current_menu != (main_menu.options + 1)->sub_menu && current_menu != ((main_menu.options +1)->sub_menu->options + 3)->sub_menu - && current_menu != (main_menu.options +3)->sub_menu + && current_menu != (main_menu.options +3)->sub_menu && current_menu != ((main_menu.options +3)->sub_menu->options + 1)->sub_menu && current_menu != (main_menu.options +6)->sub_menu && current_menu != ((main_menu.options +6)->sub_menu->options + 2)->sub_menu) @@ -3846,9 +3815,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) next_option_num = 3; else break; - + struct _MENU_OPTION_TYPE *next_option = current_menu->options + next_option_num; - + if(next_option_num == 1 /* write */ || next_option_num == 2 /* read */) { u32 current_option_val = *(next_option->current_option); @@ -3893,7 +3862,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) } break; } - + gui_action = CURSOR_SELECT; if(next_option -> option_type & HIDEN_TYPE) break; @@ -3920,9 +3889,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) next_option_num = 2; else break; - + struct _MENU_OPTION_TYPE *next_option = current_menu->options + next_option_num; - + if(next_option_num == 2) { u32 current_option_val = *(next_option->current_option); @@ -3960,7 +3929,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) } break; } - + gui_action = CURSOR_SELECT; if(next_option -> option_type & HIDEN_TYPE) break; @@ -4093,7 +4062,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) choose_menu(current_option->sub_menu); break; - case CURSOR_BACK: + case CURSOR_BACK: if(current_menu != &main_menu) choose_menu(current_menu->options->sub_menu); else @@ -4112,7 +4081,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) destroy_dynamic_cheats(); if(bg_screenp != NULL) free((void*)bg_screenp); - + if(gamepak_name[0] != 0) { reorder_latest_file(); @@ -4120,7 +4089,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) save_game_config_file(); } save_emu_config_file(); - + ds2_clearScreen(DOWN_SCREEN, 0); ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); copy_screen(up_screen_addr, (void*) screen, 0, 0, 256, 192); @@ -4396,7 +4365,7 @@ int save_game_config_file(void) sprintf(game_config_filename, "%s/%s", DEFAULT_CFG_DIR, gamepak_name); pt = strrchr(game_config_filename, '.'); - if(NULL == pt) + if(NULL == pt) return -1; *pt = '\0'; @@ -4472,7 +4441,7 @@ void reorder_latest_file(void) else break; } - + strcpy(emu_config.latest_file[i-1], full_file); } return ; @@ -4638,7 +4607,7 @@ void get_newest_savestate(char *name_buffer) get_savestate_filename(latest_save, name_buffer); } -static void get_timestamp_string(char *buffer, u16 msg_id, u16 year, u16 mon, +static void get_timestamp_string(char *buffer, u16 msg_id, u16 year, u16 mon, u16 day, u16 wday, u16 hour, u16 min, u16 sec, u32 msec) { char *weekday_strings[] = @@ -4646,7 +4615,7 @@ static void get_timestamp_string(char *buffer, u16 msg_id, u16 year, u16 mon, "SUN", "MON", "TUE", "WED", "TUR", "FRI", "SAT" }; - sprintf(buffer, "%s %02d/%02d/%04d %02d:%02d:%02d", weekday_strings[wday], + sprintf(buffer, "%s %02d/%02d/%04d %02d:%02d:%02d", weekday_strings[wday], day, mon, year, hour, min, sec); } @@ -4671,7 +4640,7 @@ static u32 save_ss_bmp(u16 *image) change_ext(gamepak_name, ss_filename, "_"); ds2_getTime(¤t_time); - sprintf(save_ss_path, "%s/%s%02d%02d%02d%02d%02d.bmp", DEFAULT_SS_DIR, ss_filename, + sprintf(save_ss_path, "%s/%s%02d%02d%02d%02d%02d.bmp", DEFAULT_SS_DIR, ss_filename, current_time.month, current_time.day, current_time.hours, current_time.minutes, current_time.seconds); for(y = 0; y < 192; y++) @@ -4706,7 +4675,7 @@ void quit(void) __asm__ __volatile__("or %0, $0, $ra" : "=r" (reg_ra) :); - + dbg_printf("return address= %08x\n", reg_ra); */ @@ -4732,6 +4701,37 @@ u32 file_length(FILE* file) /* * GUI Initialize */ +static bool Get_Args(char *file, char **filebuf){ + FILE* dat = fat_fopen(file, "rb"); + if(dat){ + int i = 0; + while(!fat_feof (dat)){ + fat_fgets(filebuf[i], 512, dat); + int len = strlen(filebuf[i]); + if(filebuf[i][len - 1] == '\n') + filebuf[i][len - 1] = '\0'; + i++; + } + + fat_fclose(dat); + fat_remove(file); + return i; + } + return 0; +} + +int CheckLoad_Arg(){ + char *argarray[2]; + argarray[0] = argv[0]; + argarray[1] = argv[1]; + + if(!Get_Args("/plgargs.dat", argarray)) + return 0; + + fat_remove("plgargs.dat"); + return 1; +} + void gui_init(u32 lang_id) { int flag; @@ -4749,7 +4749,17 @@ void gui_init(u32 lang_id) //Find the "CATSFC" system directory DIR *current_dir; - strcpy(main_path, "fat:/CATSFC"); + if(CheckLoad_Arg()){ + //copy new folder location + strcpy(main_path, "fat:"); + strcat(main_path, argv[0]); + //strip off the binary name + char *endStr = strrchr(main_path, '/'); + *endStr = '\0'; + } + else + strcpy(main_path, "fat:/CATSFC"); + current_dir = opendir(main_path); if(current_dir) closedir(current_dir); -- cgit v1.2.3 From ea330e8f79c16894deda51509e769cbd02ff83df Mon Sep 17 00:00:00 2001 From: BassAceGold Date: Wed, 6 Feb 2013 02:04:39 -0500 Subject: Fix settings not getting loaded with a ROM provided by plugin arguments. --- source/nds/gui.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 495e3c8..427f7d7 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -1853,7 +1853,21 @@ u32 menu(u16 *screen, bool8 FirstInvocation) return 0; } - strcpy(gamepak_name, filename); + char tempPath[MAX_PATH]; + strcpy(tempPath, filename); + + //update folders and names for settings/config uses + char *dirEnd = strrchr(tempPath, '/'); + //make sure a valid path was provided + if(!dirEnd) + return 0; + + //copy file name as gamepak_name + strcpy(gamepak_name, dirEnd+1); + //then strip filename from directory path and set it + *dirEnd = '\0'; + strcpy(g_default_rom_dir, tempPath); + first_load = 0; load_game_config_file(); -- cgit v1.2.3 From a358ef69a85a7252ed6b5a30496c49b28b26eecd Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Wed, 6 Feb 2013 02:18:35 -0500 Subject: Make all gamepak loads call LoadGameAndItsData, that way its "Loading" screen, current gamepak variables, game config stuff and so on are all consistent. --- source/nds/gui.c | 106 ++++++++++++++----------------------------------------- 1 file changed, 27 insertions(+), 79 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 427f7d7..f71f70f 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -1788,56 +1788,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) quit(); } - void menu_load() - { - char *file_ext[] = { ".smc", ".sfc", ".zip", NULL }; - - if(gamepak_name[0] != 0) - { - S9xAutoSaveSRAM (); - save_game_config_file(); - } - - if(load_file(file_ext, tmp_filename, g_default_rom_dir) != -1) - { - strcpy(line_buffer, g_default_rom_dir); - strcat(line_buffer, "/"); - strcat(line_buffer, tmp_filename); - - draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color); - draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_PROGRESS_LOADING_GAME]); - ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); - - HighFrequencyCPU(); - int load_result = load_gamepak(line_buffer); - LowFrequencyCPU(); - if(load_result == -1) - { - first_load = 1; - gamepak_name[0] = '\0'; - return; - } - - strcpy(gamepak_name, tmp_filename); - first_load = 0; - load_game_config_file(); -// time_period_action(); - - return_value = 1; - repeat = 0; - - reorder_latest_file(); - get_savestate_filelist(); - - game_fast_forward= 0; - } - else - { - choose_menu(current_menu); - } - } - - int Menu_loadGame(char *filename){ + int LoadGameAndItsData(char *filename){ draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color); draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_PROGRESS_LOADING_GAME]); ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); @@ -1881,6 +1832,30 @@ u32 menu(u16 *screen, bool8 FirstInvocation) return 1; } + void menu_load() + { + char *file_ext[] = { ".smc", ".sfc", ".zip", NULL }; + + if(gamepak_name[0] != 0) + { + S9xAutoSaveSRAM (); + save_game_config_file(); + } + + if(load_file(file_ext, tmp_filename, g_default_rom_dir) != -1) + { + strcpy(line_buffer, g_default_rom_dir); + strcat(line_buffer, "/"); + strcat(line_buffer, tmp_filename); + + LoadGameAndItsData(line_buffer); + } + else + { + choose_menu(current_menu); + } + } + void menu_restart() { if(!first_load) @@ -3486,10 +3461,6 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { char *ext_pos; - draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, 0); - draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_PROGRESS_LOADING_GAME]); - ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); - if(gamepak_name[0] != 0) { S9xAutoSaveSRAM (); @@ -3509,36 +3480,13 @@ u32 menu(u16 *screen, bool8 FirstInvocation) ext_pos = emu_config.latest_file[current_option_num -1]; - HighFrequencyCPU(); - int load_result = load_gamepak(ext_pos); - LowFrequencyCPU(); - - if(load_result == -1) { - first_load = 1; - return; - } - - strcpy(g_default_rom_dir, ext_pos); - ext_pos = strrchr(g_default_rom_dir, '/'); - *ext_pos= '\0'; - strcpy(gamepak_name, ext_pos+1); - - - load_game_config_file(); -// time_period_action(); - - reorder_latest_file(); - get_savestate_filelist(); - game_fast_forward= 0; + LoadGameAndItsData(ext_pos); get_newest_savestate(tmp_filename); if(tmp_filename[0] != '\0') { load_state(tmp_filename); } - - return_value = 1; - repeat = 0; } void game_fastforward() @@ -3602,7 +3550,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { first_load = 1; //try auto loading games passed through argv first - if(Menu_loadGame(argv[1])) + if(LoadGameAndItsData(argv[1])) repeat = 0; else { -- cgit v1.2.3 From 9829c836089c44d5c8cc7e3d0f7007ab33b0cb1a Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Wed, 6 Feb 2013 02:31:55 -0500 Subject: Fix the loading screen for a ROM appearing for a split second after the splash screen. Fix uninitialised memory access in Check_LoadArg. --- source/nds/gui.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index f71f70f..5d969a2 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -3550,7 +3550,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { first_load = 1; //try auto loading games passed through argv first - if(LoadGameAndItsData(argv[1])) + if(strlen(argv[1]) > 0 && LoadGameAndItsData(argv[1])) repeat = 0; else { @@ -4683,6 +4683,8 @@ static bool Get_Args(char *file, char **filebuf){ } int CheckLoad_Arg(){ + argv[0][0] = '\0'; // Initialise the first byte to be a NULL in case + argv[1][0] = '\0'; // there are no arguments to avoid uninit. memory char *argarray[2]; argarray[0] = argv[0]; argarray[1] = argv[1]; -- cgit v1.2.3 From 772e24ae503310eb1ee0d5ed5061eebb138e5808 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Wed, 6 Feb 2013 03:46:48 -0500 Subject: Reinstate frame skipping options 0 and 1, but keep the new meaning (>= 2 equivalent skip level) for automatic frame skipping. Remove the automatic CPU frequency option, which was making audio emit 0.25 second of silence every so often. --- source/nds/gui.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 5d969a2..838b5b9 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -1667,10 +1667,8 @@ void GameFrequencyCPU() { u32 clock_speed_table[6] = {6, 9, 10, 11, 12, 13}; //240, 300, 336, 360, 384, 396 - if (game_config.clock_speed_number == 0) - ds2_setCPUclocklevel(clock_speed_table[AutoCPUFrequency]); - else if(game_config.clock_speed_number <= 6) - ds2_setCPUclocklevel(clock_speed_table[game_config.clock_speed_number - 1]); + if(game_config.clock_speed_number <= 5) + ds2_setCPUclocklevel(clock_speed_table[game_config.clock_speed_number]); } void savefast_int(void) @@ -2782,9 +2780,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) (char*)&msg[MSG_VIDEO_ASPECT_RATIO_3], (char*)&msg[MSG_VIDEO_ASPECT_RATIO_4]}; - char *frameskip_options[] = { (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_AUTOMATIC], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_2], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_3], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_4], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_5], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_6], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_7], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_8], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_9], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_10] }; + char *frameskip_options[] = { (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_AUTOMATIC], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_0], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_1], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_2], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_3], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_4], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_5], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_6], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_7], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_8], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_9], (char*)&msg[MSG_VIDEO_FRAME_SKIPPING_10] }; - char *cpu_frequency_options[] = { (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_AUTOMATIC], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_0], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_1], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_2], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_3], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_4], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_5] }; + char *cpu_frequency_options[] = { (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_0], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_1], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_2], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_3], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_4], (char*)&msg[MSG_OPTIONS_CPU_FREQUENCY_5] }; char *fluidity_options[] = { (char*)&msg[MSG_VIDEO_AUDIO_FLUIDITY_PREFER_VIDEO], (char*)&msg[MSG_VIDEO_AUDIO_FLUIDITY_PREFER_AUDIO] }; @@ -2816,7 +2814,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) &game_config.SoundSync, 2, NULL, ACTION_TYPE, 4), /* 05 */ STRING_SELECTION_OPTION(game_set_frameskip, NULL, &msg[FMT_VIDEO_FRAME_SKIPPING], frameskip_options, - &game_config.frameskip_value, 10 /* auto (0) and 2..10 (1..9) make 10 option values */, NULL, ACTION_TYPE, 5) + &game_config.frameskip_value, 12 /* auto (0) and 0..10 (1..11) make 12 option values */, NULL, ACTION_TYPE, 5) }; MAKE_MENU(graphics, NULL, NULL, NULL, NULL, 0, 0); @@ -2962,7 +2960,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) //CPU speed (string: shows MHz) /* 01 */ STRING_SELECTION_OPTION(NULL, NULL, &msg[FMT_OPTIONS_CPU_FREQUENCY], cpu_frequency_options, - &game_config.clock_speed_number, 7, NULL, PASSIVE_TYPE, 1), + &game_config.clock_speed_number, 6, NULL, PASSIVE_TYPE, 1), /* 02 */ STRING_SELECTION_OPTION(language_set, NULL, &msg[FMT_OPTIONS_LANGUAGE], language_options, &emu_config.language, sizeof(language_options) / sizeof(language_options[0]) /* number of possible languages */, NULL, ACTION_TYPE, 2), @@ -4215,7 +4213,7 @@ u32 load_font() --------------------------------------------------------*/ void init_game_config(void) { - game_config.clock_speed_number = 0; // "Auto" by default + game_config.clock_speed_number = 5; // 396 MHz by default game_config.graphic = 3; // By default, have a good-looking aspect ratio game_config.frameskip_value = 0; // Automatic frame skipping game_config.SoundSync = 0; // Prefer fluid images by default -- cgit v1.2.3 From b277570daee54faf93804f5ae2d5e82e8fa11708 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Wed, 6 Feb 2013 04:38:18 -0500 Subject: Quit saving the files so often for nothing; that uses up erase cycles on storage cards! Instead, save them once when the menu that contains the settings that the user changed is exited, IF the settings' values changed, OR once when updating the list of most-recently played games. Automatically save the SRAM in most cases, including game changes. This commit also makes it unnecessary to save the game config of the previous game when loading another, makes it load certain settings correctly, and MAY make it avoid creating a file for a game's settings if the user never changes them from the defaults. --- source/nds/gui.c | 58 +++++++++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 838b5b9..581c905 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -1718,6 +1718,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation) u16 *bg_screenp; u32 bg_screenp_color; + GAME_CONFIG PreviousGameConfig; // Compared with current settings to + EMU_CONFIG PreviousEmuConfig; // determine if they need to be saved + auto void choose_menu(); auto void menu_return(); auto void menu_exit(); @@ -1776,17 +1779,32 @@ u32 menu(u16 *screen, bool8 FirstInvocation) void menu_exit() { HighFrequencyCPU(); // Crank it up, leave quickly - if(gamepak_name[0] != 0) - { - reorder_latest_file(); + if(gamepak_name[0] != 0) + { S9xAutoSaveSRAM (); - save_game_config_file(); } - save_emu_config_file(); quit(); } + void SaveConfigsIfNeeded() + { + if (memcmp(&PreviousGameConfig, &game_config, sizeof(GAME_CONFIG)) != 0) + save_game_config_file(); + if (memcmp(&PreviousEmuConfig, &emu_config, sizeof(EMU_CONFIG)) != 0) + save_emu_config_file(); + } + + void PreserveConfigs() + { + memcpy(&PreviousGameConfig, &game_config, sizeof(GAME_CONFIG)); + memcpy(&PreviousEmuConfig, &emu_config, sizeof(EMU_CONFIG)); + } + int LoadGameAndItsData(char *filename){ + if (gamepak_name[0] != '\0') { + S9xAutoSaveSRAM(); + } + draw_message(down_screen_addr, bg_screenp, 28, 31, 227, 165, bg_screenp_color); draw_string_vcenter(down_screen_addr, 36, 100, 190, COLOR_MSSG, msg[MSG_PROGRESS_LOADING_GAME]); ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); @@ -1819,6 +1837,8 @@ u32 menu(u16 *screen, bool8 FirstInvocation) first_load = 0; load_game_config_file(); + PreserveConfigs(); // Make the emulator not save what we've JUST read + // but it will save the emulator configuration below for latest files return_value = 1; repeat = 0; @@ -1834,12 +1854,6 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { char *file_ext[] = { ".smc", ".sfc", ".zip", NULL }; - if(gamepak_name[0] != 0) - { - S9xAutoSaveSRAM (); - save_game_config_file(); - } - if(load_file(file_ext, tmp_filename, g_default_rom_dir) != -1) { strcpy(line_buffer, g_default_rom_dir); @@ -2056,10 +2070,6 @@ u32 menu(u16 *screen, bool8 FirstInvocation) ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); - //save game config - reorder_latest_file(); - save_game_config_file(); - SavedStateCacheInvalidate (); mdelay(500); // let the progress message linger @@ -2722,7 +2732,6 @@ u32 menu(u16 *screen, bool8 FirstInvocation) ds2_flipScreen(UP_SCREEN, 1); } - save_emu_config_file(); LowFrequencyCPU(); // and back down wait_Allkey_release(0); } @@ -3459,12 +3468,6 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { char *ext_pos; - if(gamepak_name[0] != 0) - { - S9xAutoSaveSRAM (); - save_game_config_file(); - } - if(bg_screenp != NULL) { bg_screenp_color = COLOR16(43, 11, 11); } @@ -3521,11 +3524,13 @@ u32 menu(u16 *screen, bool8 FirstInvocation) if(NULL != current_menu) { if(current_menu->end_function) current_menu->end_function(); + SaveConfigsIfNeeded(); } current_menu = new_menu; current_option_num= current_menu -> focus_option; current_option = new_menu->options + current_option_num; + PreserveConfigs(); if(current_menu->init_function) current_menu->init_function(); } @@ -4038,18 +4043,11 @@ u32 menu(u16 *screen, bool8 FirstInvocation) if (current_menu && current_menu->end_function) current_menu->end_function(); + SaveConfigsIfNeeded(); destroy_dynamic_cheats(); if(bg_screenp != NULL) free((void*)bg_screenp); - if(gamepak_name[0] != 0) - { - reorder_latest_file(); - S9xAutoSaveSRAM (); - save_game_config_file(); - } - save_emu_config_file(); - ds2_clearScreen(DOWN_SCREEN, 0); ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); copy_screen(up_screen_addr, (void*) screen, 0, 0, 256, 192); -- cgit v1.2.3 From 3c3a97219dbe3a2e7555e6f65eb093d4f3435e49 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Wed, 6 Feb 2013 04:57:12 -0500 Subject: Fix 2 compiler warnings in gui.c. --- source/nds/gui.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 581c905..9ce602c 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -2852,10 +2852,12 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { /* 00 */ SUBMENU_OPTION(NULL, &msg[MSG_MAIN_MENU_SAVED_STATES], NULL, 0), - /* 01 */ NUMERIC_SELECTION_ACTION_OPTION(menu_save_state, NULL, &msg[FMT_SAVED_STATE_CREATE], &savestate_index, SAVE_STATE_SLOT_NUM, NULL, 1), + // savestate_index is still a signed int + /* 01 */ NUMERIC_SELECTION_ACTION_OPTION(menu_save_state, NULL, &msg[FMT_SAVED_STATE_CREATE], (u32*) &savestate_index, SAVE_STATE_SLOT_NUM, NULL, 1), + // savestate_index is still a signed int /* 02 */ NUMERIC_SELECTION_ACTION_OPTION(menu_load_state, NULL, - &msg[FMT_SAVED_STATE_LOAD], &savestate_index, SAVE_STATE_SLOT_NUM, NULL, 2), + &msg[FMT_SAVED_STATE_LOAD], (u32*) &savestate_index, SAVE_STATE_SLOT_NUM, NULL, 2), /* 03 */ SUBMENU_OPTION(&gamestate_delette_menu, &msg[MSG_SAVED_STATE_DELETE_GENERAL], NULL, 5), }; -- cgit v1.2.3 From 04037a309694dc56e3139f676b409ba7deab9298 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Wed, 6 Feb 2013 06:27:11 -0500 Subject: When changing languages, quit doing the "Changing language, please wait..." as it only takes a few milliseconds. --- source/nds/gui.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 9ce602c..5e02a55 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -2709,21 +2709,8 @@ u32 menu(u16 *screen, bool8 FirstInvocation) if(gui_action == CURSOR_LEFT || gui_action == CURSOR_RIGHT) { HighFrequencyCPU(); // crank it up - if(bg_screenp != NULL) - { - bg_screenp_color = COLOR16(43, 11, 11); - memcpy(bg_screenp, down_screen_addr, 256*192*2); - } - else - bg_screenp_color = COLOR_BG; - - 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_CHANGE_LANGUAGE]); - draw_string_vcenter(down_screen_addr, 36, 95, 190, COLOR_MSSG, msg[MSG_CHANGE_LANGUAGE_WAITING]); - ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD); load_language_msg(LANGUAGE_PACK, emu_config.language); - // gui_change_icon(emu_config.language); // uncomment if images change per language [Neb] if(first_load) { @@ -2733,7 +2720,6 @@ u32 menu(u16 *screen, bool8 FirstInvocation) } LowFrequencyCPU(); // and back down - wait_Allkey_release(0); } } -- cgit v1.2.3 From 0b165c3133b2c97bfe2eaf6195f36094c1213164 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Wed, 6 Feb 2013 16:16:43 -0500 Subject: Use key pictograms from Pictochat to display keys for yes/no dialog(ue)s. --- source/nds/gui.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 5e02a55..7270891 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -4140,7 +4140,61 @@ int load_language_msg(char *filename, u32 language) break; len= strlen(pt); - memcpy(dst, pt, len); + // memcpy(dst, pt, len); + + // Replace key definitions (*letter) with Pictochat icons + // while copying. + unsigned int curChar; + for (curChar = 0; curChar < len; curChar++) + { + if (pt[curChar] == '*') + { + switch (pt[curChar + 1]) + { + case 'A': + memcpy(&dst[curChar], HOTKEY_A_DISPLAY, 2); + curChar++; + break; + case 'B': + memcpy(&dst[curChar], HOTKEY_B_DISPLAY, 2); + curChar++; + break; + case 'X': + memcpy(&dst[curChar], HOTKEY_X_DISPLAY, 2); + curChar++; + break; + case 'Y': + memcpy(&dst[curChar], HOTKEY_Y_DISPLAY, 2); + curChar++; + break; + case 'L': + memcpy(&dst[curChar], HOTKEY_L_DISPLAY, 2); + curChar++; + break; + case 'R': + memcpy(&dst[curChar], HOTKEY_R_DISPLAY, 2); + curChar++; + break; + case 'S': + memcpy(&dst[curChar], HOTKEY_START_DISPLAY, 2); + curChar++; + break; + case 's': + memcpy(&dst[curChar], HOTKEY_SELECT_DISPLAY, 2); + curChar++; + break; + case '\0': + dst[curChar] = pt[curChar]; + break; + default: + memcpy(&dst[curChar], &pt[curChar], 2); + curChar++; + break; + } + } + else + dst[curChar] = pt[curChar]; + } dst += len; //at a line return, when "\n" paded, this message not end @@ -4163,7 +4217,7 @@ int load_language_msg(char *filename, u32 language) else//a message end { if(*(dst-2) == 0x0D) - dst -= 1; + dst -= 1; *(dst-1) = '\0'; msg[++loop] = dst; } -- cgit v1.2.3 From 90de0280db8e33d9e54a65639be6ec76510e4bb0 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Wed, 6 Feb 2013 16:24:09 -0500 Subject: gui.c: Require all keys to be released after the B, A or X button or the Touch Screen is pressed. This avoids bringing up, or exiting from, multiple menus if you happen to press something for longer than 1/5 second. The modification does not apply to the directional pad in all menus, or the L and R buttons in file selectors. --- source/nds/gui.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 7270891..f0671b0 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -836,6 +836,7 @@ s32 load_file(char **wildcards, char *result, char *default_dir_name) { case CURSOR_TOUCH: ds2_getrawInput(&inputdata); + wait_Allkey_release(0); // ___ 33 This screen has 6 possible rows. Touches // ___ 60 above or below these are ignored. // . . . (+27) @@ -1001,6 +1002,7 @@ s32 load_file(char **wildcards, char *result, char *default_dir_name) break; case CURSOR_SELECT: + wait_Allkey_release(0); //file selected if(selected_item_on_list + 1 <= num_files) { @@ -1040,6 +1042,7 @@ s32 load_file(char **wildcards, char *result, char *default_dir_name) case CURSOR_BACK: { + wait_Allkey_release(0); char *ext_pos; strcpy(filelist_info.current_path, default_dir_name); @@ -1057,6 +1060,7 @@ s32 load_file(char **wildcards, char *result, char *default_dir_name) } case CURSOR_EXIT: + wait_Allkey_release(0); return_value = -1; repeat = 0; break; @@ -3672,6 +3676,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { case CURSOR_TOUCH: ds2_getrawInput(&inputdata); + wait_Allkey_release(0); /* Back button at the top of every menu but the main one */ if(current_menu != &main_menu && inputdata.x > 231 && inputdata.y <= 25) { @@ -4006,9 +4011,11 @@ u32 menu(u16 *screen, bool8 FirstInvocation) break; case CURSOR_EXIT: + wait_Allkey_release(0); break; case CURSOR_SELECT: + wait_Allkey_release(0); if(current_option->option_type & ACTION_TYPE) current_option->action_function(); else if(current_option->option_type & SUBMENU_TYPE) @@ -4016,6 +4023,7 @@ u32 menu(u16 *screen, bool8 FirstInvocation) break; case CURSOR_BACK: + wait_Allkey_release(0); if(current_menu != &main_menu) choose_menu(current_menu->options->sub_menu); else -- cgit v1.2.3 From ea8ff33951d53f0e71801052c540dcc1bd0f7f42 Mon Sep 17 00:00:00 2001 From: SignZ Date: Thu, 7 Feb 2013 04:56:34 -0500 Subject: EN: Added a German translation. DE: Deutsche Übersetzung hinzugefügt. --- source/nds/gui.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index f0671b0..190fcc9 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -50,14 +50,15 @@ char argv[2][MAX_PATH]; // If adding a language, make sure you update the size of the array in // message.h too. -char *lang[3] = +char *lang[4] = { "English", // 0 "简体中文", // 1 - "Français", // 2 + "Français", // 2 + "Deutsch", // 3 }; -char *language_options[] = { (char *) &lang[0], (char *) &lang[1], (char *) &lang[2] }; +char *language_options[] = { (char *) &lang[0], (char *) &lang[1], (char *) &lang[2], (char *) &lang[3] }; /****************************************************************************** * Macro definition @@ -4105,6 +4106,10 @@ int load_language_msg(char *filename, u32 language) strcpy(start, "STARTFRENCH"); strcpy(end, "ENDFRENCH"); break; + case GERMAN: + strcpy(start, "STARTGERMAN"); + strcpy(end, "ENDGERMAN"); + break; } u32 cmplen = strlen(start); -- cgit v1.2.3 From 635c87890530777a2e7b2f4c45a72f8f51c7d5f0 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Thu, 7 Feb 2013 17:58:37 -0500 Subject: Allow the user to be pressing a button when the emulator starts. This allows the Loading screen to disappear, and allows invoking New Game straight away. --- source/nds/gui.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/nds/gui.c') diff --git a/source/nds/gui.c b/source/nds/gui.c index 190fcc9..4299db2 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -3535,9 +3535,10 @@ u32 menu(u16 *screen, bool8 FirstInvocation) { // assume that the backlight is already at 3 when the emulator starts mdelay(100); // to prevent ds2_setBacklight() from crashing ds2_setBacklight(3); + // also allow the user to press A for New Game right away + wait_Allkey_release(0); } - wait_Allkey_release(0); bg_screenp= (u16*)malloc(256*192*2); repeat = 1; -- cgit v1.2.3