From 7badc9353b9570fd1c67827cfb477cef07974ddb Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 23 Apr 2012 02:00:48 +0300 Subject: frontend: generic: preliminary SDL support --- frontend/menu.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'frontend/menu.c') diff --git a/frontend/menu.c b/frontend/menu.c index 989c6ec..d99156b 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -1504,7 +1504,7 @@ static int menu_loop_options(int id, int keys) int i; i = me_id2offset(e_menu_options, MA_OPT_CPU_CLOCKS); - e_menu_options[i].enabled = cpu_clock_st != 0 ? 1 : 0; + e_menu_options[i].enabled = cpu_clock_st > 0 ? 1 : 0; me_enable(e_menu_options, MA_OPT_SAVECFG_GAME, ready_to_go && CdromId[0]); me_loop(e_menu_options, &sel); @@ -1714,8 +1714,10 @@ static void draw_frame_main(void) { struct tm *tmp; time_t ltime; + int capacity; char ltime_s[16]; char buff[64]; + char *out; if (CdromId[0] != 0) { snprintf(buff, sizeof(buff), "%.32s/%.9s (running as %s, with %s)", @@ -1725,11 +1727,17 @@ static void draw_frame_main(void) } if (ready_to_go) { + capacity = plat_get_bat_capacity(); ltime = time(NULL); tmp = localtime(<ime); strftime(ltime_s, sizeof(ltime_s), "%H:%M", tmp); - snprintf(buff, sizeof(buff), "%s %3d%%", ltime_s, plat_get_bat_capacity()); - smalltext_out16(4, 1 + me_sfont_h, buff, 0x105f); + if (capacity >= 0) { + snprintf(buff, sizeof(buff), "%s %3d%%", ltime_s, capacity); + out = buff; + } + else + out = ltime_s; + smalltext_out16(4, 1 + me_sfont_h, out, 0x105f); } } @@ -2241,8 +2249,12 @@ void menu_init(void) last_psx_bpp = 16; g_menubg_src_ptr = calloc(g_menuscreen_w * g_menuscreen_h * 2, 1); - if (g_menubg_src_ptr == NULL) + g_menubg_ptr = calloc(g_menuscreen_w * g_menuscreen_h * 2, 1); + if (g_menubg_src_ptr == NULL || g_menubg_ptr == NULL) { + fprintf(stderr, "OOM\n"); exit(1); + } + emu_make_path(buff, "skin/background.png", sizeof(buff)); readpng(g_menubg_src_ptr, buff, READPNG_BG, g_menuscreen_w, g_menuscreen_h); @@ -2362,7 +2374,8 @@ void menu_prepare_emu(void) menu_sync_config(); apply_lcdrate(Config.PsxType); apply_filter(filter); - plat_cpu_clock_apply(cpu_clock); + if (cpu_clock > 0) + plat_cpu_clock_apply(cpu_clock); // push config to GPU plugin plugin_call_rearmed_cbs(); -- cgit v1.2.3