053bef76 |
1 | #include <time.h> |
2 | #include "soc.h" |
b6072c17 |
3 | #include "plat_gp2x.h" |
053bef76 |
4 | |
5 | static void menu_main_plat_draw(void) |
6 | { |
7 | static time_t last_bat_read = 0; |
8 | static int last_bat_val = -1; |
9 | unsigned short *bp = g_screen_ptr; |
10 | int bat_h = me_mfont_h * 2 / 3; |
11 | int i, u, w, wfill, batt_val; |
12 | struct tm *tmp; |
13 | time_t ltime; |
14 | char time_s[16]; |
15 | |
16 | if (!(currentConfig.EmuOpt & EOPT_SHOW_RTC)) |
17 | return; |
18 | |
19 | ltime = time(NULL); |
20 | tmp = gmtime(<ime); |
21 | strftime(time_s, sizeof(time_s), "%H:%M", tmp); |
22 | |
23 | text_out16(g_screen_width - me_mfont_w * 6, me_mfont_h + 2, time_s); |
24 | |
25 | if (ltime - last_bat_read > 10) { |
26 | last_bat_read = ltime; |
27 | last_bat_val = batt_val = gp2x_read_battery(); |
28 | } |
29 | else |
30 | batt_val = last_bat_val; |
31 | |
32 | if (batt_val < 0 || batt_val > 100) |
33 | return; |
34 | |
35 | /* battery info */ |
36 | bp += (me_mfont_h * 2 + 2) * g_screen_width + g_screen_width - me_mfont_w * 3 - 3; |
37 | for (i = 0; i < me_mfont_w * 2; i++) |
38 | bp[i] = menu_text_color; |
39 | for (i = 0; i < me_mfont_w * 2; i++) |
40 | bp[i + g_screen_width * bat_h] = menu_text_color; |
41 | for (i = 0; i <= bat_h; i++) |
42 | bp[i * g_screen_width] = |
43 | bp[i * g_screen_width + me_mfont_w * 2] = menu_text_color; |
44 | for (i = 2; i < bat_h - 1; i++) |
45 | bp[i * g_screen_width - 1] = |
46 | bp[i * g_screen_width - 2] = menu_text_color; |
47 | |
48 | w = me_mfont_w * 2 - 1; |
49 | wfill = batt_val * w / 100; |
50 | for (u = 1; u < bat_h; u++) |
51 | for (i = 0; i < wfill; i++) |
52 | bp[(w - i) + g_screen_width * u] = menu_text_color; |
53 | } |
54 | |
55 | // ------------ gfx options menu ------------ |
56 | |
c64c8d0e |
57 | static const char *mgn_aopt_gamma(int id, int *offs) |
053bef76 |
58 | { |
0c9ae592 |
59 | sprintf(static_buff, "%i.%02i", currentConfig.gamma / 100, currentConfig.gamma % 100); |
053bef76 |
60 | return static_buff; |
61 | } |
62 | |
63 | |
b6072c17 |
64 | const char *men_scaling_opts[] = { "OFF", "software", "hardware", NULL }; |
0c9ae592 |
65 | |
b188c2b6 |
66 | #define MENU_OPTIONS_GFX \ |
b6072c17 |
67 | mee_enum ("Horizontal scaling", MA_OPT_SCALING, currentConfig.scaling, men_scaling_opts), \ |
68 | mee_enum ("Vertical scaling", MA_OPT_VSCALING, currentConfig.vscaling, men_scaling_opts), \ |
053bef76 |
69 | mee_onoff ("Tearing Fix", MA_OPT_TEARING_FIX, currentConfig.EmuOpt, EOPT_WIZ_TEAR_FIX), \ |
70 | mee_range_cust("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma), \ |
71 | mee_onoff ("A_SN's gamma curve", MA_OPT2_A_SN_GAMMA, currentConfig.EmuOpt, EOPT_A_SN_GAMMA), \ |
f71361b5 |
72 | mee_onoff ("Vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_VSYNC), |
053bef76 |
73 | |
b188c2b6 |
74 | #define MENU_OPTIONS_ADV \ |
053bef76 |
75 | mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoOpt, POPT_EXT_FM), \ |
76 | mee_onoff ("RAM overclock", MA_OPT2_RAMTIMINGS, currentConfig.EmuOpt, EOPT_RAM_TIMINGS), \ |
77 | mee_onoff ("MMU hack", MA_OPT2_SQUIDGEHACK, currentConfig.EmuOpt, EOPT_MMUHACK), \ |
78 | mee_onoff ("SVP dynarec", MA_OPT2_SVP_DYNAREC, PicoOpt, POPT_EN_SVP_DRC), \ |
b188c2b6 |
79 | mee_onoff ("Status line in main menu", MA_OPT2_STATUS_LINE, currentConfig.EmuOpt, EOPT_SHOW_RTC), |
053bef76 |
80 | |
b6072c17 |
81 | |
82 | static menu_entry e_menu_adv_options[]; |
83 | static menu_entry e_menu_gfx_options[]; |
84 | static menu_entry e_menu_options[]; |
902972d1 |
85 | static menu_entry e_menu_keyconfig[]; |
b6072c17 |
86 | |
87 | void gp2x_menu_init(void) |
88 | { |
89 | static menu_entry *cpu_clk_ent; |
90 | int i; |
91 | |
92 | i = me_id2offset(e_menu_options, MA_OPT_CPU_CLOCKS); |
93 | cpu_clk_ent = &e_menu_options[i]; |
94 | |
95 | /* disable by default.. */ |
96 | me_enable(e_menu_adv_options, MA_OPT_ARM940_SOUND, 0); |
97 | me_enable(e_menu_gfx_options, MA_OPT_TEARING_FIX, 0); |
98 | me_enable(e_menu_gfx_options, MA_OPT2_GAMMA, 0); |
99 | me_enable(e_menu_gfx_options, MA_OPT2_A_SN_GAMMA, 0); |
100 | |
101 | switch (gp2x_dev_id) { |
102 | case GP2X_DEV_GP2X: |
103 | me_enable(e_menu_adv_options, MA_OPT_ARM940_SOUND, 1); |
104 | me_enable(e_menu_gfx_options, MA_OPT2_GAMMA, 1); |
105 | me_enable(e_menu_gfx_options, MA_OPT2_A_SN_GAMMA, 1); |
106 | cpu_clk_ent->name = "GP2X CPU clocks"; |
107 | break; |
108 | case GP2X_DEV_WIZ: |
109 | me_enable(e_menu_gfx_options, MA_OPT_TEARING_FIX, 1); |
110 | cpu_clk_ent->name = "Wiz/Caanoo CPU clock"; |
111 | break; |
112 | case GP2X_DEV_CAANOO: |
113 | cpu_clk_ent->name = "Wiz/Caanoo CPU clock"; |
114 | break; |
115 | default: |
116 | break; |
117 | } |
118 | |
119 | if (gp2x_set_cpuclk == NULL) |
120 | cpu_clk_ent->name = ""; |
121 | |
122 | if (gp2x_dev_id != GP2X_DEV_GP2X) |
123 | men_scaling_opts[2] = NULL; /* leave only off and sw */ |
902972d1 |
124 | |
125 | if (gp2x_dev_id != GP2X_DEV_CAANOO) |
126 | me_enable(e_menu_keyconfig, MA_CTRL_DEADZONE, 0); |
b6072c17 |
127 | } |
128 | |