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