aboutsummaryrefslogtreecommitdiff
path: root/source/nds/gui.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/nds/gui.c')
-rw-r--r--source/nds/gui.c704
1 files changed, 392 insertions, 312 deletions
diff --git a/source/nds/gui.c b/source/nds/gui.c
index 09e01ac..4299db2 100644
--- a/source/nds/gui.c
+++ b/source/nds/gui.c
@@ -45,23 +45,27 @@ 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] =
- {
+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
******************************************************************************/
#define SUBMENU_ROW_NUM 6
-#define NDSSFC_VERSION "1.23"
+#define NDSSFC_VERSION "1.28"
#define SAVE_STATE_SLOT_NUM 16
@@ -289,7 +293,6 @@ u32 game_enable_audio = 1;
/******************************************************************************
******************************************************************************/
static u32 menu_cheat_page = 0;
-u32 clock_speed_number = 5;
u32 gamepad_config_menu;
/******************************************************************************
@@ -324,6 +327,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:
@@ -420,53 +438,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)
{
@@ -558,7 +575,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;
@@ -733,9 +750,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;
}
@@ -820,6 +837,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)
@@ -985,6 +1003,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)
{
@@ -1024,6 +1043,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);
@@ -1041,6 +1061,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;
@@ -1082,7 +1103,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
}
@@ -1129,7 +1150,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);
}
@@ -1260,7 +1281,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;
}
@@ -1365,7 +1386,7 @@ u32 play_screen_snapshot(void)
time1= time0;
}
break;
-
+
case CURSOR_DOWN:
if(!pause)
{
@@ -1373,21 +1394,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;
}
@@ -1395,15 +1416,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;
@@ -1443,7 +1464,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))
@@ -1622,7 +1643,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);
@@ -1637,12 +1658,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
+}
- if(num <= 5)
- ds2_setCPUclocklevel(clock_speed_table[num]);
+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(game_config.clock_speed_number <= 5)
+ ds2_setCPUclocklevel(clock_speed_table[game_config.clock_speed_number]);
}
void savefast_int(void)
@@ -1668,7 +1699,7 @@ unsigned int frame_interval;
/*--------------------------------------------------------
Main Menu
--------------------------------------------------------*/
-u32 menu(u16 *screen)
+u32 menu(u16 *screen, bool8 FirstInvocation)
{
gui_action_type gui_action;
u32 i;
@@ -1684,7 +1715,7 @@ u32 menu(u16 *screen)
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;
@@ -1692,6 +1723,9 @@ u32 menu(u16 *screen)
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();
@@ -1732,7 +1766,9 @@ u32 menu(u16 *screen)
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();
@@ -1747,131 +1783,94 @@ u32 menu(u16 *screen)
void menu_exit()
{
- ds2_setCPUclocklevel(13); // Crank it up, leave quickly
- if(gamepak_name[0] != 0)
- {
- game_config.clock_speed_number = clock_speed_number;
-
- reorder_latest_file();
+ HighFrequencyCPU(); // Crank it up, leave quickly
+ if(gamepak_name[0] != 0)
+ {
S9xAutoSaveSRAM ();
- save_game_config_file();
}
- save_emu_config_file();
quit();
}
- void menu_load()
+ void SaveConfigsIfNeeded()
{
- char *file_ext[] = { ".smc", ".sfc", ".zip", NULL };
-
- if(gamepak_name[0] != 0)
- {
- S9xAutoSaveSRAM ();
+ 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();
+ }
- 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);
+ void PreserveConfigs()
+ {
+ memcpy(&PreviousGameConfig, &game_config, sizeof(GAME_CONFIG));
+ memcpy(&PreviousEmuConfig, &emu_config, sizeof(EMU_CONFIG));
+ }
- 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 LoadGameAndItsData(char *filename){
+ if (gamepak_name[0] != '\0') {
+ S9xAutoSaveSRAM();
+ }
- ds2_setCPUclocklevel(13);
- int load_result = load_gamepak(line_buffer);
- ds2_setCPUclocklevel(0);
- if(load_result == -1)
- {
- first_load = 1;
- gamepak_name[0] = '\0';
- return;
- }
+ 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);
- strcpy(gamepak_name, tmp_filename);
- first_load = 0;
- load_game_config_file();
-// time_period_action();
+ HighFrequencyCPU();
+ int load_result = load_gamepak(filename);
+ LowFrequencyCPU();
- return_value = 1;
- repeat = 0;
+ if(load_result == -1)
+ {
+ first_load = 1;
+ gamepak_name[0] = '\0';
+ return 0;
+ }
- reorder_latest_file();
- get_savestate_filelist();
+ char tempPath[MAX_PATH];
+ strcpy(tempPath, filename);
- game_fast_forward= 0;
- }
- else
- {
- 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;
- }
+ //update folders and names for settings/config uses
+ char *dirEnd = strrchr(tempPath, '/');
+ //make sure a valid path was provided
+ if(!dirEnd)
+ 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);
+ //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);
- ds2_setCPUclocklevel(13);
- int load_result = load_gamepak(args[1]);
- ds2_setCPUclocklevel(0);
+ 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
- if(load_result == -1)
- {
- first_load = 1;
- gamepak_name[0] = '\0';
- return 0;
- }
+ return_value = 1;
+ repeat = 0;
- strcpy(gamepak_name, args[1]);
- first_load = 0;
- load_game_config_file();
+ reorder_latest_file();
+ get_savestate_filelist();
- return_value = 1;
- repeat = 0;
+ game_fast_forward= 0;
+ return 1;
+ }
- reorder_latest_file();
- get_savestate_filelist();
+ void menu_load()
+ {
+ char *file_ext[] = { ".smc", ".sfc", ".zip", NULL };
+
+ 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);
- game_fast_forward= 0;
- return 1;
-
+ LoadGameAndItsData(line_buffer);
+ }
+ else
+ {
+ choose_menu(current_menu);
+ }
}
void menu_restart()
@@ -2060,9 +2059,9 @@ u32 menu(u16 *screen)
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)
@@ -2076,17 +2075,13 @@ u32 menu(u16 *screen)
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
}
}
}
-
+
void menu_load_state()
{
if(!first_load)
@@ -2126,12 +2121,12 @@ u32 menu(u16 *screen)
//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]);
- ds2_setCPUclocklevel(13);
+ HighFrequencyCPU();
int flag = load_state(tmp_filename);
- ds2_setCPUclocklevel(0);
+ LowFrequencyCPU();
if(0 == flag)
{
return_value = 1;
@@ -2146,9 +2141,9 @@ u32 menu(u16 *screen)
}
else //load screen snapshot
{
- ds2_setCPUclocklevel(13);
+ HighFrequencyCPU();
load_game_stat_snapshot(tmp_filename);
- ds2_setCPUclocklevel(0);
+ LowFrequencyCPU();
}
}
else
@@ -2210,7 +2205,7 @@ u32 menu(u16 *screen)
}
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))
{
@@ -2278,7 +2273,7 @@ u32 menu(u16 *screen)
{
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
@@ -2288,7 +2283,7 @@ u32 menu(u16 *screen)
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);
}
}
@@ -2296,7 +2291,7 @@ u32 menu(u16 *screen)
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);
}
@@ -2309,7 +2304,7 @@ u32 menu(u16 *screen)
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);
}
@@ -2323,7 +2318,7 @@ u32 menu(u16 *screen)
{
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
@@ -2338,7 +2333,7 @@ u32 menu(u16 *screen)
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);
}
}
@@ -2350,7 +2345,7 @@ u32 menu(u16 *screen)
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);
}
}
@@ -2365,7 +2360,7 @@ u32 menu(u16 *screen)
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;
@@ -2641,7 +2636,7 @@ u32 menu(u16 *screen)
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);
}
@@ -2718,22 +2713,9 @@ u32 menu(u16 *screen)
{
if(gui_action == CURSOR_LEFT || gui_action == CURSOR_RIGHT)
{
- ds2_setCPUclocklevel(13); // 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;
+ HighFrequencyCPU(); // crank it up
- 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]
+ load_language_msg(LANGUAGE_PACK, emu_config.language);
if(first_load)
{
@@ -2742,12 +2724,11 @@ u32 menu(u16 *screen)
ds2_flipScreen(UP_SCREEN, 1);
}
- save_emu_config_file();
- ds2_setCPUclocklevel(0); // and back down
- wait_Allkey_release(0);
+ LowFrequencyCPU(); // and back down
}
}
+#ifdef ENABLE_FREE_SPACE
unsigned int freespace;
void show_card_space ()
{
@@ -2791,6 +2772,7 @@ u32 menu(u16 *screen)
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],
@@ -2800,6 +2782,10 @@ u32 menu(u16 *screen)
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_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] };
char *sound_seletion[] = { (char*)&msg[MSG_AUDIO_MUTED], (char*)&msg[MSG_AUDIO_ENABLED] };
@@ -2815,17 +2801,20 @@ u32 menu(u16 *screen)
{
/* 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_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);
@@ -2854,10 +2843,12 @@ u32 menu(u16 *screen)
{
/* 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),
};
@@ -2871,9 +2862,9 @@ u32 menu(u16 *screen)
{
/* 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),
@@ -2940,7 +2931,7 @@ u32 menu(u16 *screen)
/*--------------------------------------------------------
Tools
--------------------------------------------------------*/
- MENU_OPTION_TYPE tools_options[] =
+ MENU_OPTION_TYPE tools_options[] =
{
/* 00 */ SUBMENU_OPTION(NULL, &msg[MSG_MAIN_MENU_TOOLS], NULL, 0),
@@ -2952,10 +2943,10 @@ u32 menu(u16 *screen)
// /* 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)
};
@@ -2969,18 +2960,33 @@ u32 menu(u16 *screen)
{
/* 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, 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),
+#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);
@@ -2989,7 +2995,7 @@ u32 menu(u16 *screen)
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),
@@ -3120,7 +3126,7 @@ u32 menu(u16 *screen)
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);
@@ -3315,7 +3321,7 @@ u32 menu(u16 *screen)
{
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;
@@ -3373,7 +3379,7 @@ u32 menu(u16 *screen)
void latest_game_menu_end()
{
u32 k;
-
+
for(k= 0; k < 5; k++)
{
if(emu_config.latest_file[k][0] != '\0')
@@ -3393,12 +3399,12 @@ u32 menu(u16 *screen)
{
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;
@@ -3407,7 +3413,7 @@ u32 menu(u16 *screen)
{
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);
}
@@ -3419,7 +3425,7 @@ u32 menu(u16 *screen)
{
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);
}
@@ -3432,7 +3438,7 @@ u32 menu(u16 *screen)
{
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);
}
@@ -3455,16 +3461,6 @@ u32 menu(u16 *screen)
{
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 ();
- save_game_config_file();
- }
-
if(bg_screenp != NULL) {
bg_screenp_color = COLOR16(43, 11, 11);
}
@@ -3478,42 +3474,19 @@ u32 menu(u16 *screen)
ext_pos = emu_config.latest_file[current_option_num -1];
- ds2_setCPUclocklevel(13);
- int load_result = load_gamepak(ext_pos);
- ds2_setCPUclocklevel(0);
-
- 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()
{
}
-
+
void reload_cheats_page()
@@ -3527,11 +3500,13 @@ u32 menu(u16 *screen)
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)
@@ -3542,23 +3517,28 @@ u32 menu(u16 *screen)
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();
}
//----------------------------------------------------------------------------//
// Menu Start
- ds2_setCPUclocklevel(0);
- mdelay(100); // to prevent ds2_setBacklight() from crashing
- ds2_setBacklight(3);
-
-
- wait_Allkey_release(0);
+ LowFrequencyCPU();
+ 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);
+ // also allow the user to press A for New Game right away
+ wait_Allkey_release(0);
+ }
+
bg_screenp= (u16*)malloc(256*192*2);
repeat = 1;
@@ -3566,7 +3546,8 @@ u32 menu(u16 *screen)
if(gamepak_name[0] == 0)
{
first_load = 1;
- if(CheckLoad_Arg())
+ //try auto loading games passed through argv first
+ if(strlen(argv[1]) > 0 && LoadGameAndItsData(argv[1]))
repeat = 0;
else
{
@@ -3589,7 +3570,7 @@ u32 menu(u16 *screen)
choose_menu(&main_menu);
// Menu loop
-
+
while(repeat)
{
display_option = current_menu->options;
@@ -3638,7 +3619,7 @@ u32 menu(u16 *screen)
focus_option = line_num;
}
current_menu -> focus_option = focus_option;
-
+
i = focus_option - screen_focus;
display_option += i +1;
@@ -3684,7 +3665,7 @@ u32 menu(u16 *screen)
color= COLOR_ACTIVE_ITEM;
else
color= COLOR_INACTIVE_ITEM;
-
+
PRINT_STRING_BG(down_screen_addr, line_buffer, color, COLOR_TRANS, 23, 40 + i*27);
}
}
@@ -3697,6 +3678,7 @@ u32 menu(u16 *screen)
{
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)
{
@@ -3714,7 +3696,7 @@ u32 menu(u16 *screen)
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)
@@ -3723,11 +3705,10 @@ u32 menu(u16 *screen)
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 +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)
{
@@ -3794,9 +3775,9 @@ u32 menu(u16 *screen)
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);
@@ -3841,7 +3822,7 @@ u32 menu(u16 *screen)
}
break;
}
-
+
gui_action = CURSOR_SELECT;
if(next_option -> option_type & HIDEN_TYPE)
break;
@@ -3868,9 +3849,9 @@ u32 menu(u16 *screen)
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);
@@ -3908,7 +3889,7 @@ u32 menu(u16 *screen)
}
break;
}
-
+
gui_action = CURSOR_SELECT;
if(next_option -> option_type & HIDEN_TYPE)
break;
@@ -4032,16 +4013,19 @@ u32 menu(u16 *screen)
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)
choose_menu(current_option->sub_menu);
break;
- case CURSOR_BACK:
+ case CURSOR_BACK:
+ wait_Allkey_release(0);
if(current_menu != &main_menu)
choose_menu(current_menu->options->sub_menu);
else
@@ -4057,20 +4041,11 @@ u32 menu(u16 *screen)
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)
- {
- game_config.clock_speed_number = clock_speed_number;
- 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);
@@ -4080,7 +4055,7 @@ u32 menu(u16 *screen)
mdelay(100); // to prevent ds2_setBacklight() from crashing
ds2_setBacklight(2);
- set_cpu_clock(clock_speed_number);
+ GameFrequencyCPU();
return return_value;
}
@@ -4132,6 +4107,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);
@@ -4175,7 +4154,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
@@ -4198,7 +4231,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;
}
@@ -4235,9 +4268,9 @@ u32 load_font()
void init_game_config(void)
{
game_config.clock_speed_number = 5; // 396 MHz by default
- 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
@@ -4290,8 +4323,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);
@@ -4322,6 +4355,10 @@ int load_emu_config_file(void)
fclose(fp);
return 0;
}
+ else
+ {
+ fclose(fp);
+ }
}
//have no confiure file, set default
@@ -4342,7 +4379,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';
@@ -4418,7 +4455,7 @@ void reorder_latest_file(void)
else
break;
}
-
+
strcpy(emu_config.latest_file[i-1], full_file);
}
return ;
@@ -4584,7 +4621,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[] =
@@ -4592,7 +4629,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);
}
@@ -4617,7 +4654,7 @@ static u32 save_ss_bmp(u16 *image)
change_ext(gamepak_name, ss_filename, "_");
ds2_getTime(&current_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++)
@@ -4652,7 +4689,7 @@ void quit(void)
__asm__ __volatile__("or %0, $0, $ra"
: "=r" (reg_ra)
:);
-
+
dbg_printf("return address= %08x\n", reg_ra);
*/
@@ -4678,11 +4715,44 @@ 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(){
+ 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];
+
+ if(!Get_Args("/plgargs.dat", argarray))
+ return 0;
+
+ fat_remove("plgargs.dat");
+ return 1;
+}
+
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;
@@ -4695,7 +4765,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);