restore defaults function + some refactoring

git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@716 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2009-07-26 13:13:01 +00:00
parent 92068389d8
commit 9ecdd73ae7
5 changed files with 47 additions and 35 deletions

View file

@ -557,7 +557,7 @@ static void make_config_cfg(char *cfg_buff_512)
cfg_buff_512[511] = 0;
}
static void emu_setDefaultConfig(void)
void emu_set_defconfig(void)
{
memcpy(&currentConfig, &defaultConfig, sizeof(currentConfig));
PicoOpt = currentConfig.s_PicoOpt;
@ -575,7 +575,7 @@ int emu_read_config(int game, int no_defaults)
if (!game)
{
if (!no_defaults)
emu_setDefaultConfig();
emu_set_defconfig();
make_config_cfg(cfg);
ret = config_readsect(cfg, NULL);
}
@ -593,7 +593,7 @@ int emu_read_config(int game, int no_defaults)
{
// read user's config
int vol = currentConfig.volume;
emu_setDefaultConfig();
emu_set_defconfig();
ret = config_readsect(cfg, sect);
currentConfig.volume = vol; // make vol global (bah)
}
@ -1076,7 +1076,7 @@ static void run_events_ui(unsigned int which)
}
if (which & PEV_SWITCH_RND)
{
plat_video_toggle_renderer();
plat_video_toggle_renderer(1, 0);
}
if (which & (PEV_SSLOT_PREV|PEV_SSLOT_NEXT))
{

View file

@ -103,6 +103,7 @@ int emu_reload_rom(char *rom_fname);
int emu_save_load_game(int load, int sram);
void emu_reset_game(void);
void emu_set_defconfig(void);
int emu_read_config(int game, int no_defaults);
int emu_write_config(int game);

View file

@ -1457,6 +1457,23 @@ static int menu_loop_adv_options(menu_id id, int keys)
// ------------ gfx options menu ------------
static int mh_opt_render(menu_id id, int keys)
{
plat_video_toggle_renderer((keys & PBTN_RIGHT) ? 1 : 0, 1);
return 0;
}
static const char *mgn_opt_renderer(menu_id id, int *offs)
{
*offs = -11;
if (PicoOpt & POPT_ALT_RENDERER)
return " 8bit fast";
else if (currentConfig.EmuOpt & EOPT_16BPP)
return "16bit accurate";
else
return " 8bit accurate";
}
static const char *mgn_opt_scaling(menu_id id, int *offs)
{
*offs = -13;
@ -1476,6 +1493,7 @@ static const char *mgn_aopt_gamma(menu_id id, int *offs)
static menu_entry e_menu_gfx_options[] =
{
mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer),
mee_range_cust("Scaling", MA_OPT_SCALING, currentConfig.scaling, 0, 3, mgn_opt_scaling),
mee_range_cust("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma),
mee_onoff ("A_SN's gamma curve", MA_OPT2_A_SN_GAMMA, currentConfig.EmuOpt, EOPT_A_SN_GAMMA),
@ -1494,20 +1512,6 @@ static int menu_loop_gfx_options(menu_id id, int keys)
static menu_entry e_menu_options[];
/* TODO: move to plat */
static int mh_opt_render(menu_id id, int keys)
{
if (keys & PBTN_LEFT) {
if (PicoOpt&0x10) PicoOpt&= ~0x10;
else if (!(currentConfig.EmuOpt &0x80))currentConfig.EmuOpt |= 0x80;
} else {
if (PicoOpt&0x10) return 0;
else if (!(currentConfig.EmuOpt &0x80))PicoOpt|= 0x10;
else if ( currentConfig.EmuOpt &0x80) currentConfig.EmuOpt &= ~0x80;
}
return 0;
}
static int sndrate_prevnext(int rate, int dir)
{
static const int rates[] = { 8000, 11025, 16000, 22050, 44100 };
@ -1620,15 +1624,11 @@ static int mh_saveloadcfg(menu_id id, int keys)
return 1;
}
static const char *mgn_opt_renderer(menu_id id, int *offs)
static int mh_restore_defaults(menu_id id, int keys)
{
*offs = -6;
if (PicoOpt & POPT_ALT_RENDERER)
return " 8bit fast";
else if (currentConfig.EmuOpt & 0x80)
return "16bit accurate";
else
return " 8bit accurate";
emu_set_defconfig();
me_update_msg("defaults restored");
return 1;
}
static const char *mgn_opt_fskip(menu_id id, int *offs)
@ -1703,9 +1703,8 @@ static menu_entry e_menu_options[] =
mee_range ("Save slot", MA_OPT_SAVE_SLOT, state_slot, 0, 9),
mee_range_cust("Frameskip", MA_OPT_FRAMESKIP, currentConfig.Frameskip, -1, 16, mgn_opt_fskip),
mee_cust ("Region", MA_OPT_REGION, mh_opt_misc, mgn_opt_region),
mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer),
mee_onoff ("Show FPS", MA_OPT_SHOW_FPS, currentConfig.EmuOpt, 0x002),
mee_onoff ("Enable sound", MA_OPT_ENABLE_SOUND, currentConfig.EmuOpt, 0x004),
mee_onoff ("Show FPS", MA_OPT_SHOW_FPS, currentConfig.EmuOpt, EOPT_SHOW_FPS),
mee_onoff ("Enable sound", MA_OPT_ENABLE_SOUND, currentConfig.EmuOpt, EOPT_EN_SOUND),
mee_cust ("Sound Quality", MA_OPT_SOUND_QUALITY, mh_opt_misc, mgn_opt_sound),
mee_cust ("Confirm savestate", MA_OPT_CONFIRM_STATES,mh_opt_misc, mgn_opt_c_saves),
mee_range (cpu_clk_name, MA_OPT_CPU_CLOCKS, currentConfig.CPUclock, 20, 900),
@ -1715,6 +1714,7 @@ static menu_entry e_menu_options[] =
mee_handler_mkname_id(MA_OPT_SAVECFG, mh_saveloadcfg, mgn_savecfg),
mee_handler_id("Save cfg for current game only", MA_OPT_SAVECFG_GAME, mh_saveloadcfg),
mee_handler_mkname_id(MA_OPT_LOADCFG, mh_saveloadcfg, mgn_loadcfg),
mee_handler ("Restore defaults", mh_restore_defaults),
mee_end,
};

View file

@ -34,7 +34,7 @@ void plat_video_menu_enter(int is_rom_loaded);
void plat_video_menu_begin(void);
void plat_video_menu_end(void);
void plat_video_toggle_renderer(void);
void plat_video_toggle_renderer(int is_next, int is_menu);
void plat_validate_config(void);
void plat_update_volume(int has_changed, int is_up);

View file

@ -341,15 +341,26 @@ static void vidResetMode(void)
else gp2x_video_RGB_setscaling(0, (PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 240);
}
void plat_video_toggle_renderer(void)
void plat_video_toggle_renderer(int is_next, int is_menu)
{
/* alt, 16bpp, 8bpp */
if (PicoOpt & POPT_ALT_RENDERER) {
PicoOpt &= ~POPT_ALT_RENDERER;
if (is_next)
currentConfig.EmuOpt |= EOPT_16BPP;
} else if (!(currentConfig.EmuOpt & EOPT_16BPP))
} else if (!(currentConfig.EmuOpt & EOPT_16BPP)) {
if (is_next)
PicoOpt |= POPT_ALT_RENDERER;
else
currentConfig.EmuOpt |= EOPT_16BPP;
} else {
currentConfig.EmuOpt &= ~EOPT_16BPP;
if (!is_next)
PicoOpt |= POPT_ALT_RENDERER;
}
if (is_menu)
return;
vidResetMode();