From 173d9fb38b029122e85610a69334ddb44107bd78 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sun, 6 Nov 2016 14:08:46 -0500 Subject: boost selectively Change-Id: Ic11542cef53716869c5348c18a2846308b4e867b --- apps/plugins/xworld/sys.c | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) (limited to 'apps/plugins') diff --git a/apps/plugins/xworld/sys.c b/apps/plugins/xworld/sys.c index ea3dacd..53f6b78 100644 --- a/apps/plugins/xworld/sys.c +++ b/apps/plugins/xworld/sys.c @@ -231,7 +231,6 @@ static void do_video_settings(struct System* sys) } break; case 5: - rb->lcd_clear_display(); sys_save_settings(sys); return; } @@ -296,6 +295,38 @@ static int mainmenu_cb(int action, const struct menu_item_ex *this_item) return action; } +static bool is_boosted = false; + +void sys_boost(struct System *sys) +{ + (void) sys; +#ifdef HAVE_ADJUSTABLE_CPU_FREQ + if(!is_boosted) + { + rb->cpu_boost(true); + is_boosted = true; + } +#endif +} + +void sys_unboost(struct System *sys) +{ + (void) sys; +#ifdef HAVE_ADJUSTABLE_CPU_FREQ + if(is_boosted) + { + rb->cpu_boost(false); + is_boosted = false; + } +#endif +} + +static void boost_if_needed(struct System *sys) +{ + if(sys->e->vm._fastMode || sys->settings.scaling_quality == 2) + sys_boost(sys); +} + static AudioCallback audio_callback = NULL; static void get_more(const void** start, size_t* size); static void* audio_param; @@ -377,16 +408,16 @@ void sys_menu(struct System* sys) break; } } - rb->lcd_clear_display(); + + /* boost CPU if necessary */ + boost_if_needed(sys); + sys_startAudio(sys, audio_callback, audio_param); } void sys_init(struct System* sys, const char* title) { (void) title; -#ifdef HAVE_ADJUSTABLE_CPU_FREQ - rb->cpu_boost(true); -#endif backlight_ignore_timeout(); rb_atexit(exit_handler); save_sys = sys; @@ -621,6 +652,7 @@ void sys_copyRect(struct System* sys, uint16_t x, uint16_t y, uint16_t w, uint16 static void do_pause_menu(struct System* sys) { sys_stopAudio(sys); + sys_unboost(sys); int sel = 0; MENUITEM_STRINGLIST(menu, "XWorld Menu", NULL, "Resume Game", /* 0 */ @@ -685,7 +717,9 @@ static void do_pause_menu(struct System* sys) break; } } - rb->lcd_clear_display(); + + boost_if_needed(sys); + sys_startAudio(sys, audio_callback, audio_param); } -- cgit v1.1