| 1 | #ifdef __GP2X__ |
| 2 | |
| 3 | #include <time.h> |
| 4 | #include "soc.h" |
| 5 | |
| 6 | static void menu_main_plat_draw(void) |
| 7 | { |
| 8 | static time_t last_bat_read = 0; |
| 9 | static int last_bat_val = -1; |
| 10 | unsigned short *bp = g_screen_ptr; |
| 11 | int bat_h = me_mfont_h * 2 / 3; |
| 12 | int i, u, w, wfill, batt_val; |
| 13 | struct tm *tmp; |
| 14 | time_t ltime; |
| 15 | char time_s[16]; |
| 16 | |
| 17 | if (!(currentConfig.EmuOpt & EOPT_SHOW_RTC)) |
| 18 | return; |
| 19 | |
| 20 | ltime = time(NULL); |
| 21 | tmp = gmtime(<ime); |
| 22 | strftime(time_s, sizeof(time_s), "%H:%M", tmp); |
| 23 | |
| 24 | text_out16(g_screen_width - me_mfont_w * 6, me_mfont_h + 2, time_s); |
| 25 | |
| 26 | if (ltime - last_bat_read > 10) { |
| 27 | last_bat_read = ltime; |
| 28 | last_bat_val = batt_val = gp2x_read_battery(); |
| 29 | } |
| 30 | else |
| 31 | batt_val = last_bat_val; |
| 32 | |
| 33 | if (batt_val < 0 || batt_val > 100) |
| 34 | return; |
| 35 | |
| 36 | /* battery info */ |
| 37 | bp += (me_mfont_h * 2 + 2) * g_screen_width + g_screen_width - me_mfont_w * 3 - 3; |
| 38 | for (i = 0; i < me_mfont_w * 2; i++) |
| 39 | bp[i] = menu_text_color; |
| 40 | for (i = 0; i < me_mfont_w * 2; i++) |
| 41 | bp[i + g_screen_width * bat_h] = menu_text_color; |
| 42 | for (i = 0; i <= bat_h; i++) |
| 43 | bp[i * g_screen_width] = |
| 44 | bp[i * g_screen_width + me_mfont_w * 2] = menu_text_color; |
| 45 | for (i = 2; i < bat_h - 1; i++) |
| 46 | bp[i * g_screen_width - 1] = |
| 47 | bp[i * g_screen_width - 2] = menu_text_color; |
| 48 | |
| 49 | w = me_mfont_w * 2 - 1; |
| 50 | wfill = batt_val * w / 100; |
| 51 | for (u = 1; u < bat_h; u++) |
| 52 | for (i = 0; i < wfill; i++) |
| 53 | bp[(w - i) + g_screen_width * u] = menu_text_color; |
| 54 | } |
| 55 | |
| 56 | // ------------ gfx options menu ------------ |
| 57 | |
| 58 | static const char *mgn_opt_renderer(menu_id id, int *offs) |
| 59 | { |
| 60 | *offs = -11; |
| 61 | if (PicoOpt & POPT_ALT_RENDERER) |
| 62 | return " 8bit fast"; |
| 63 | else if (currentConfig.EmuOpt & EOPT_16BPP) |
| 64 | return "16bit accurate"; |
| 65 | else |
| 66 | return " 8bit accurate"; |
| 67 | } |
| 68 | |
| 69 | static const char *mgn_opt_scaling(menu_id id, int *offs) |
| 70 | { |
| 71 | *offs = -13; |
| 72 | switch (currentConfig.scaling) { |
| 73 | default: return " OFF"; |
| 74 | case EOPT_SCALE_HW_H: return " hw horizontal"; |
| 75 | case EOPT_SCALE_HW_HV: return "hw horiz. + vert"; |
| 76 | case EOPT_SCALE_SW_H: return " sw horizontal"; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | static const char *mgn_aopt_gamma(menu_id id, int *offs) |
| 81 | { |
| 82 | sprintf(static_buff, "%i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100); |
| 83 | return static_buff; |
| 84 | } |
| 85 | |
| 86 | |
| 87 | #define MENU_GP2X_OPTIONS_GFX \ |
| 88 | mee_range_cust("Scaling", MA_OPT_SCALING, currentConfig.scaling, 0, 3, mgn_opt_scaling), \ |
| 89 | mee_onoff ("Tearing Fix", MA_OPT_TEARING_FIX, currentConfig.EmuOpt, EOPT_WIZ_TEAR_FIX), \ |
| 90 | mee_range_cust("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma), \ |
| 91 | mee_onoff ("A_SN's gamma curve", MA_OPT2_A_SN_GAMMA, currentConfig.EmuOpt, EOPT_A_SN_GAMMA), \ |
| 92 | mee_onoff ("Vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_VSYNC), |
| 93 | |
| 94 | #define MENU_GP2X_OPTIONS_ADV \ |
| 95 | mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoOpt, POPT_EXT_FM), \ |
| 96 | mee_onoff ("RAM overclock", MA_OPT2_RAMTIMINGS, currentConfig.EmuOpt, EOPT_RAM_TIMINGS), \ |
| 97 | mee_onoff ("MMU hack", MA_OPT2_SQUIDGEHACK, currentConfig.EmuOpt, EOPT_MMUHACK), \ |
| 98 | mee_onoff ("SVP dynarec", MA_OPT2_SVP_DYNAREC, PicoOpt, POPT_EN_SVP_DRC), \ |
| 99 | mee_onoff ("Status line in main menu", MA_OPT2_STATUS_LINE, currentConfig.EmuOpt, EOPT_SHOW_RTC ), |
| 100 | |
| 101 | #else |
| 102 | |
| 103 | #define MENU_GP2X_OPTIONS_GFX |
| 104 | #define MENU_GP2X_OPTIONS_ADV |
| 105 | #define mgn_opt_renderer NULL /* TODO */ |
| 106 | #define menu_main_plat_draw NULL |
| 107 | |
| 108 | #endif |