⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui.c

📁 psp上的GBA模拟器
💻 C
📖 第 1 页 / 共 3 页
字号:
  void menu_save_state()  {    if(!first_load)    {      get_savestate_filename_noshot(savestate_slot,       current_savestate_filename);      save_state(current_savestate_filename, original_screen);    }    menu_change_state();  }  void menu_load_state()  {    if(!first_load)    {      load_state(current_savestate_filename);      return_value = 1;      repeat = 0;    }  }  void menu_load_state_file()  {    u8 *file_ext[] = { ".svs", NULL };    u8 load_filename[512];    if(load_file(file_ext, load_filename) != -1)    {      load_state(load_filename);      return_value = 1;      repeat = 0;    }    else    {      choose_menu(current_menu);    }  }  void menu_fix_gamepad_help()  {    clear_help();    current_option->help_string =     gamepad_help[gamepad_config_map[     gamepad_config_line_to_psp_button[current_option_num]]];  }  void submenu_graphics_sound()  {  }  void submenu_cheats_misc()  {  }  void submenu_gamepad()  {  }  void submenu_analog()  {  }  void submenu_savestate()  {    print_string("Savestate options:", COLOR_ACTIVE_ITEM, COLOR_BG, 10, 70);    menu_change_state();  }  void submenu_main()  {    get_savestate_filename_noshot(savestate_slot,     current_savestate_filename);  }  u8 *yes_no_options[] = { "no", "yes" };  u8 *enable_disable_options[] = { "disabled", "enabled" };  u8 *scale_options[] =  {    "unscaled 3:2", "scaled 3:2", "fullscreen 16:9"  };  u8 *frameskip_options[] = { "automatic", "manual", "off" };  u8 *frameskip_variation_options[] = { "uniform", "random" };  u8 *audio_buffer_options[] =  {    "2048 bytes", "3072 bytes", "4096 bytes", "5120 bytes", "6144 bytes",    "7168 bytes", "8192 bytes", "9216 bytes", "10240 bytes", "11264 bytes",    "12288 bytes"  };  u8 *update_backup_options[] = { "Exit only", "Automatic" };  u8 *clock_speed_options[] =  {    "33MHz", "66MHz", "100MHz", "133MHz", "166MHz", "200MHz", "233MHz",    "266MHz", "300MHz", "333MHz"  };  u8 *gamepad_config_buttons[] =  {    "UP",    "DOWN",    "LEFT",    "RIGHT",    "A",    "B",    "L",    "R",    "START",    "SELECT",    "MENU",    "FASTFORWARD",    "LOAD STATE",    "SAVE STATE",    "RAPIDFIRE A",    "RAPIDFIRE B",    "RAPIDFIRE L",    "RAPIDFIRE R",    "NOTHING"  };  // Marker for help information, don't go past this mark (except \n)------*  menu_option_type graphics_sound_options[] =  {    string_selection_option(NULL, "Display scaling", scale_options,     (u32 *)(&screen_scale), 3,     "Determines how the GBA screen is resized in relation to the entire\n"     "screen. Select unscaled 3:2 for GBA resolution, scaled 3:2 for GBA\n"     "aspect ratio scaled to fill the height of the PSP screen, and\n"     "fullscreen to fill the entire PSP screen.", 2),    string_selection_option(NULL, "Screen filtering", yes_no_options,     (u32 *)(&screen_filter), 2,     "Determines whether or not bilinear filtering should be used when\n"     "scaling the screen. Selecting this will produce a more even and\n"     "smooth image, at the cost of being blurry and having less vibrant\n"     "colors.", 3),    string_selection_option(NULL, "Frameskip type", frameskip_options,     (u32 *)(&current_frameskip_type), 3,     "Determines what kind of frameskipping should be employed.\n"     "Frameskipping may improve emulation speed of many games.\n"     "Off: Do not skip any frames.\n"     "Auto: Skip up to N frames (see next option) as needed.\n"     "Manual: Always render only 1 out of N + 1 frames.", 5),    numeric_selection_option(NULL, "Frameskip value", &frameskip_value, 100,     "For auto frameskip, determines the maximum number of frames that\n"     "are allowed to be skipped consecutively.\n"     "For manual frameskip, determines the number of frames that will\n"     "always be skipped.", 6),    string_selection_option(NULL, "Framskip variation",     frameskip_variation_options, &random_skip, 2,     "If objects in the game flicker at a regular rate certain manual\n"     "frameskip values may cause them to normally disappear. Change this\n"     "value to 'random' to avoid this. Do not use otherwise, as it tends to\n"     "make the image quality worse, especially in high motion games.", 7),    string_selection_option(NULL, "Audio output", yes_no_options,     &global_enable_audio, 2,     "Select 'no' to turn off all audio output. This will not result in a\n"     "significant change in performance.", 9),    string_selection_option(NULL, "Audio buffer", audio_buffer_options,             &audio_buffer_size_number, 11,     "Set the size (in bytes) of the audio buffer. Larger values may result\n"     "in slightly better performance at the cost of latency; the lowest\n"     "value will give the most responsive audio.\n"     "This option requires gpSP to be restarted before it will take effect.",     10),    submenu_option(NULL, "Back", "Return to the main menu.", 12)  };  make_menu(graphics_sound, submenu_graphics_sound, NULL);  menu_option_type cheats_misc_options[] =  {    cheat_option(0),    cheat_option(1),    cheat_option(2),    cheat_option(3),    cheat_option(4),    cheat_option(5),    cheat_option(6),    cheat_option(7),    cheat_option(8),    cheat_option(9),    string_selection_option(NULL, "Clock speed",     clock_speed_options, &clock_speed_number, 10,     "Change the clock speed of the device. Higher clock speed will yield\n"     "better performance, but will use drain battery life further.", 11),    string_selection_option(NULL, "Update backup",     update_backup_options, &update_backup_flag, 2,     "Determines when in-game save files should be written back to\n"     "memstick. If set to 'automatic' writebacks will occur shortly after\n"     "the game's backup is altered. On 'exit only' it will only be written\n"     "back when you exit from this menu (NOT from using the home button).\n"     "Use the latter with extreme care.", 12),    submenu_option(NULL, "Back", "Return to the main menu.", 14)  };  make_menu(cheats_misc, submenu_cheats_misc, NULL);  menu_option_type savestate_options[] =  {    numeric_selection_action_hide_option(menu_load_state, menu_change_state,     "Load savestate from current slot", &savestate_slot, 10,     "Select to load the game state from the current slot for this game.\n"     "Press left + right to change the current slot.", 6),    numeric_selection_action_hide_option(menu_save_state, menu_change_state,     "Save savestate to current slot", &savestate_slot, 10,     "Select to save the game state to the current slot for this game.\n"     "Press left + right to change the current slot.", 7),    numeric_selection_action_hide_option(menu_load_state_file,      menu_change_state,     "Load savestate from file", &savestate_slot, 10,     "Restore gameplay from a savestate file.\n"     "Note: The same file used to save the state must be present.\n", 9),    numeric_selection_option(menu_change_state,     "Current savestate slot", &savestate_slot, 10,     "Change the current savestate slot.\n", 11),    submenu_option(NULL, "Back", "Return to the main menu.", 13)  };  make_menu(savestate, submenu_savestate, NULL);  menu_option_type gamepad_config_options[] =  {    gamepad_config_option("D-pad up     ", 0),    gamepad_config_option("D-pad down   ", 1),    gamepad_config_option("D-pad left   ", 2),    gamepad_config_option("D-pad right  ", 3),    gamepad_config_option("Circle       ", 4),    gamepad_config_option("Cross        ", 5),    gamepad_config_option("Square       ", 6),    gamepad_config_option("Triangle     ", 7),    gamepad_config_option("Left Trigger ", 8),    gamepad_config_option("Right Trigger", 9),    gamepad_config_option("Start        ", 10),    gamepad_config_option("Select       ", 11),    submenu_option(NULL, "Back", "Return to the main menu.", 13)  };  make_menu(gamepad_config, submenu_gamepad, NULL);  menu_option_type analog_config_options[] =  {    analog_config_option("Analog up   ", 0),    analog_config_option("Analog down ", 1),    analog_config_option("Analog left ", 2),    analog_config_option("Analog right", 3),    string_selection_option(NULL, "Enable analog", yes_no_options,     &global_enable_analog, 2,     "Select 'no' to block analog input entirely.", 7),    numeric_selection_option(NULL, "Analog sensitivity",     &analog_sensitivity_level, 10,     "Determine sensitivity/responsiveness of the analog input.\n"     "Lower numbers are less sensitive.", 8),    submenu_option(NULL, "Back", "Return to the main menu.", 11)  };  make_menu(analog_config, submenu_analog, NULL);  menu_option_type main_options[] =  {    submenu_option(&graphics_sound_menu, "Graphics and Sound options",     "Select to set display parameters and frameskip behavior,\n"     "audio on/off, audio buffer size, and audio filtering.", 0),    numeric_selection_action_option(menu_load_state, NULL,     "Load state from slot", &savestate_slot, 10,     "Select to load the game state from the current slot for this game,\n"     "if it exists (see the extended menu for more information)\n"     "Press left + right to change the current slot.", 2),    numeric_selection_action_option(menu_save_state, NULL,     "Save state to slot", &savestate_slot, 10,     "Select to save the game state to the current slot for this game.\n"     "See the extended menu for more information.\n"     "Press left + right to change the current slot.", 3),    submenu_option(&savestate_menu, "Savestate options",     "Select to enter a menu for loading, saving, and viewing the\n"     "currently active savestate for this game (or to load a savestate\n"     "file from another game)", 4),    submenu_option(&gamepad_config_menu, "Configure gamepad input",     "Select to change the in-game behavior of the PSP buttons and d-pad.",     6),    submenu_option(&analog_config_menu, "Configure analog input",     "Select to change the in-game behavior of the PSP analog nub.", 7),    submenu_option(&cheats_misc_menu, "Cheats and Miscellaneous options",     "Select to manage cheats, set backup behavior, and set device clock\n"     "speed.", 9),    action_option(menu_load, NULL, "Load new game",     "Select to load a new game (will exit a game if currently playing).",     11),    action_option(menu_restart, NULL, "Restart game",     "Select to reset the GBA with the current game loaded.", 12),    action_option(menu_exit, NULL, "Return to game",     "Select to exit this menu and resume gameplay.", 13),    action_option(menu_quit, NULL, "Exit gpSP",     "Select to exit gpSP and return to the PSP XMB/loader.", 15)  };  make_menu(main, submenu_main, NULL);  void choose_menu(menu_type *new_menu)  {    if(new_menu == NULL)      new_menu = &main_menu;    clear_screen(COLOR_BG);    blit_to_screen(original_screen, 240, 160, 230, 40);    current_menu = new_menu;    current_option = new_menu->options;    current_option_num = 0;    if(current_menu->init_function)     current_menu->init_function();  }  void clear_help()  {    for(i = 0; i < 6; i++)    {      print_string_pad(" ", COLOR_BG, COLOR_BG, 30, 210 + (i * 10), 70);    }  }  video_resolution_large();  SDL_LockMutex(sound_mutex);  SDL_PauseAudio(1);  SDL_UnlockMutex(sound_mutex);  if(gamepak_filename[0] == 0)  {    first_load = 1;    memset(original_screen, 0x00, 240 * 160 * 2);    print_string_ext("No game loaded yet.", 0xFFFF, 0x0000,     60, 75,original_screen, 240, 0);  }  choose_menu(&main_menu);  for(i = 0; i < 10; i++)  {    if(i >= num_cheats)    {      sprintf(cheat_format_str[i], "cheat %d (none loaded)", i);    }    else    {      sprintf(cheat_format_str[i], "cheat %d (%s): %%s", i,       cheats[i].cheat_name);    }  }  current_menu->init_function();  while(repeat)  {    display_option = current_menu->options;    for(i = 0; i < current_menu->num_options; i++, display_option++)    {      if(display_option->option_type & NUMBER_SELECTION_OPTION)      {        sprintf(line_buffer, display_option->display_string,         *(display_option->current_option));      }      else      if(display_option->option_type & STRING_SELECTION_OPTION)      {        sprintf(line_buffer, display_option->display_string,         ((u32 *)display_option->options)[*(display_option->current_option)]);      }      else      {        strcpy(line_buffer, display_option->display_string);      }      if(display_option == current_option)      {        print_string_pad(line_buffer, COLOR_ACTIVE_ITEM, COLOR_BG, 10,         (display_option->line_number * 10) + 40, 36);      }      else      {        print_string_pad(line_buffer, COLOR_INACTIVE_ITEM, COLOR_BG, 10,         (display_option->line_number * 10) + 40, 36);      }    }    print_string(current_option->help_string, COLOR_HELP_TEXT,     COLOR_BG, 30, 210);    flip_screen();    gui_action = get_gui_input();    switch(gui_action)    {      case CURSOR_DOWN:        current_option_num = (current_option_num + 1) %          current_menu->num_options;        current_option = current_menu->options + current_option_num;        clear_help();        break;      case CURSOR_UP:        if(current_option_num)          current_option_num--;        else          current_option_num = current_menu->num_options - 1;        current_option = current_menu->options + current_option_num;        clear_help();        break;      case CURSOR_RIGHT:        if(current_option->option_type & (NUMBER_SELECTION_OPTION |         STRING_SELECTION_OPTION))        {          *(current_option->current_option) =           (*current_option->current_option + 1) %           current_option->num_options;          if(current_option->passive_function)            current_option->passive_function();        }        break;      case CURSOR_LEFT:        if(current_option->option_type & (NUMBER_SELECTION_OPTION |         STRING_SELECTION_OPTION))        {          u32 current_option_val = *(current_option->current_option);          if(current_option_val)            current_option_val--;          else            current_option_val = current_option->num_options - 1;          *(current_option->current_option) = current_option_val;          if(current_option->passive_function)            current_option->passive_function();        }        break;      case CURSOR_EXIT:        if(current_menu == &main_menu)          menu_exit();        choose_menu(&main_menu);        break;      case CURSOR_SELECT:        if(current_option->option_type & ACTION_OPTION)          current_option->action_function();        if(current_option->option_type & SUBMENU_OPTION)          choose_menu(current_option->sub_menu);        break;    }  }  set_gba_resolution(screen_scale);  video_resolution_small();  clock_speed = (clock_speed_number + 1) * 33;  #ifdef PSP_BUILD    scePowerSetClockFrequency(clock_speed, clock_speed, clock_speed / 2);  #endif  SDL_PauseAudio(0);  return return_value;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -