mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
start splitting plat menu code; batt + clock in menu; bugfix
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@719 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
645ec129e3
commit
61753a6724
7 changed files with 165 additions and 53 deletions
|
@ -327,7 +327,7 @@ static int me_count(const menu_entry *ent)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void me_draw(const menu_entry *entries, int sel)
|
||||
static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))
|
||||
{
|
||||
const menu_entry *ent;
|
||||
int x, y, w = 0, h = 0;
|
||||
|
@ -449,6 +449,9 @@ static void me_draw(const menu_entry *entries, int sel)
|
|||
menu_error_msg[0] = 0;
|
||||
}
|
||||
|
||||
if (draw_more != NULL)
|
||||
draw_more();
|
||||
|
||||
plat_video_menu_end();
|
||||
}
|
||||
|
||||
|
@ -475,12 +478,12 @@ static int me_process(menu_entry *entry, int is_next)
|
|||
|
||||
static void debug_menu_loop(void);
|
||||
|
||||
static void me_loop(menu_entry *menu, int *menu_sel)
|
||||
static void me_loop(menu_entry *menu, int *menu_sel, void (*draw_more)(void))
|
||||
{
|
||||
int ret, inp, sel = *menu_sel, menu_sel_max;
|
||||
|
||||
menu_sel_max = me_count(menu) - 1;
|
||||
if (menu_sel_max < 1) {
|
||||
if (menu_sel_max < 0) {
|
||||
lprintf("no enabled menu entries\n");
|
||||
return;
|
||||
}
|
||||
|
@ -489,12 +492,12 @@ static void me_loop(menu_entry *menu, int *menu_sel)
|
|||
sel++;
|
||||
|
||||
/* make sure action buttons are not pressed on entering menu */
|
||||
me_draw(menu, sel);
|
||||
me_draw(menu, sel, NULL);
|
||||
while (in_menu_wait_any(50) & (PBTN_MOK|PBTN_MBACK|PBTN_MENU));
|
||||
|
||||
for (;;)
|
||||
{
|
||||
me_draw(menu, sel);
|
||||
me_draw(menu, sel, draw_more);
|
||||
inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|
|
||||
PBTN_MOK|PBTN_MBACK|PBTN_MENU|PBTN_L|PBTN_R, 70);
|
||||
if (inp & (PBTN_MENU|PBTN_MBACK))
|
||||
|
@ -540,6 +543,9 @@ static void me_loop(menu_entry *menu, int *menu_sel)
|
|||
|
||||
/* ***************************************** */
|
||||
|
||||
/* platform specific options and handlers */
|
||||
#include "../gp2x/menu.c"
|
||||
|
||||
static void draw_menu_credits(void)
|
||||
{
|
||||
const char *creds, *p;
|
||||
|
@ -1379,7 +1385,7 @@ static int menu_loop_keyconfig(menu_id id, int keys)
|
|||
static int sel = 0;
|
||||
|
||||
me_enable(e_menu_keyconfig, MA_OPT_SAVECFG_GAME, rom_loaded);
|
||||
me_loop(e_menu_keyconfig, &sel);
|
||||
me_loop(e_menu_keyconfig, &sel, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1425,7 +1431,7 @@ static menu_entry e_menu_cd_options[] =
|
|||
static int menu_loop_cd_options(menu_id id, int keys)
|
||||
{
|
||||
static int sel = 0;
|
||||
me_loop(e_menu_cd_options, &sel);
|
||||
me_loop(e_menu_cd_options, &sel, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1435,23 +1441,20 @@ static menu_entry e_menu_adv_options[] =
|
|||
{
|
||||
mee_onoff ("SRAM/BRAM saves", MA_OPT_SRAM_STATES, currentConfig.EmuOpt, EOPT_EN_SRAM),
|
||||
mee_onoff ("Disable sprite limit", MA_OPT2_NO_SPRITE_LIM, PicoOpt, POPT_DIS_SPRITE_LIM),
|
||||
mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoOpt, POPT_EXT_FM),
|
||||
mee_onoff ("Emulate Z80", MA_OPT2_ENABLE_Z80, PicoOpt, POPT_EN_Z80),
|
||||
mee_onoff ("Emulate YM2612 (FM)", MA_OPT2_ENABLE_YM2612, PicoOpt, POPT_EN_FM),
|
||||
mee_onoff ("Emulate SN76496 (PSG)", MA_OPT2_ENABLE_SN76496,PicoOpt, POPT_EN_PSG),
|
||||
mee_onoff ("gzip savestates", MA_OPT2_GZIP_STATES, currentConfig.EmuOpt, EOPT_GZIP_SAVES),
|
||||
mee_onoff ("Don't save last used ROM", MA_OPT2_NO_LAST_ROM, currentConfig.EmuOpt, EOPT_NO_AUTOSVCFG),
|
||||
mee_onoff ("RAM overclock", MA_OPT2_RAMTIMINGS, currentConfig.EmuOpt, EOPT_RAM_TIMINGS),
|
||||
mee_onoff ("MMU hack", MA_OPT2_SQUIDGEHACK, currentConfig.EmuOpt, EOPT_MMUHACK),
|
||||
mee_onoff ("SVP dynarec", MA_OPT2_SVP_DYNAREC, PicoOpt, POPT_EN_SVP_DRC),
|
||||
mee_onoff ("Disable idle loop patching",MA_OPT2_NO_IDLE_LOOPS,PicoOpt, POPT_DIS_IDLE_DET),
|
||||
MENU_GP2X_OPTIONS_ADV
|
||||
mee_end,
|
||||
};
|
||||
|
||||
static int menu_loop_adv_options(menu_id id, int keys)
|
||||
{
|
||||
static int sel = 0;
|
||||
me_loop(e_menu_adv_options, &sel);
|
||||
me_loop(e_menu_adv_options, &sel, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1463,49 +1466,17 @@ static int mh_opt_render(menu_id id, int keys)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const char *mgn_opt_renderer(menu_id id, int *offs)
|
||||
{
|
||||
*offs = -11;
|
||||
if (PicoOpt & POPT_ALT_RENDERER)
|
||||
return " 8bit fast";
|
||||
else if (currentConfig.EmuOpt & EOPT_16BPP)
|
||||
return "16bit accurate";
|
||||
else
|
||||
return " 8bit accurate";
|
||||
}
|
||||
|
||||
static const char *mgn_opt_scaling(menu_id id, int *offs)
|
||||
{
|
||||
*offs = -13;
|
||||
switch (currentConfig.scaling) {
|
||||
default: return " OFF";
|
||||
case EOPT_SCALE_HW_H: return " hw horizontal";
|
||||
case EOPT_SCALE_HW_HV: return "hw horiz. + vert";
|
||||
case EOPT_SCALE_SW_H: return " sw horizontal";
|
||||
}
|
||||
}
|
||||
|
||||
static const char *mgn_aopt_gamma(menu_id id, int *offs)
|
||||
{
|
||||
sprintf(static_buff, "%i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100);
|
||||
return static_buff;
|
||||
}
|
||||
|
||||
static menu_entry e_menu_gfx_options[] =
|
||||
{
|
||||
mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer),
|
||||
mee_range_cust("Scaling", MA_OPT_SCALING, currentConfig.scaling, 0, 3, mgn_opt_scaling),
|
||||
mee_onoff ("Tearing Fix", MA_OPT_TEARING_FIX, currentConfig.EmuOpt, EOPT_WIZ_TEAR_FIX),
|
||||
mee_range_cust("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma),
|
||||
mee_onoff ("A_SN's gamma curve", MA_OPT2_A_SN_GAMMA, currentConfig.EmuOpt, EOPT_A_SN_GAMMA),
|
||||
mee_onoff ("Perfect vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_PSYNC),
|
||||
MENU_GP2X_OPTIONS_GFX
|
||||
mee_end,
|
||||
};
|
||||
|
||||
static int menu_loop_gfx_options(menu_id id, int keys)
|
||||
{
|
||||
static int sel = 0;
|
||||
me_loop(e_menu_gfx_options, &sel);
|
||||
me_loop(e_menu_gfx_options, &sel, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1726,7 +1697,7 @@ static int menu_loop_options(menu_id id, int keys)
|
|||
me_enable(e_menu_options, MA_OPT_SAVECFG_GAME, rom_loaded);
|
||||
me_enable(e_menu_options, MA_OPT_LOADCFG, config_slot != config_slot_current);
|
||||
|
||||
me_loop(e_menu_options, &sel);
|
||||
me_loop(e_menu_options, &sel, NULL);
|
||||
|
||||
if (PicoRegionOverride)
|
||||
// force setting possibly changed..
|
||||
|
@ -1977,7 +1948,7 @@ void menu_loop(void)
|
|||
|
||||
plat_video_menu_enter(rom_loaded);
|
||||
in_set_blocking(1);
|
||||
me_loop(e_menu_main, &sel);
|
||||
me_loop(e_menu_main, &sel, menu_main_plat_draw);
|
||||
|
||||
if (rom_loaded) {
|
||||
if (engineState == PGS_Menu)
|
||||
|
@ -2035,7 +2006,7 @@ int menu_loop_tray(void)
|
|||
plat_video_menu_enter(rom_loaded);
|
||||
|
||||
in_set_blocking(1);
|
||||
me_loop(e_menu_tray, &sel);
|
||||
me_loop(e_menu_tray, &sel, NULL);
|
||||
|
||||
if (engineState != PGS_RestartRun) {
|
||||
engineState = PGS_RestartRun;
|
||||
|
@ -2061,13 +2032,15 @@ void me_update_msg(const char *msg)
|
|||
|
||||
// ------------ util ------------
|
||||
|
||||
/* wiz for now, probably extend later */
|
||||
/* GP2X/wiz for now, probably extend later */
|
||||
void menu_plat_setup(int is_wiz)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!is_wiz)
|
||||
if (!is_wiz) {
|
||||
me_enable(e_menu_gfx_options, MA_OPT_TEARING_FIX, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
me_enable(e_menu_adv_options, MA_OPT_ARM940_SOUND, 0);
|
||||
me_enable(e_menu_gfx_options, MA_OPT2_GAMMA, 0);
|
||||
|
|
|
@ -109,7 +109,7 @@ void pemu_prep_defconfig(void)
|
|||
if (soc == SOCID_MMSP2)
|
||||
defaultConfig.s_PicoOpt |= POPT_EXT_FM;
|
||||
else if (soc == SOCID_POLLUX)
|
||||
defaultConfig.EmuOpt |= EOPT_WIZ_TEAR_FIX;
|
||||
defaultConfig.EmuOpt |= EOPT_WIZ_TEAR_FIX|EOPT_SHOW_RTC;
|
||||
}
|
||||
|
||||
static void (*osd_text)(int x, int y, const char *text);
|
||||
|
|
107
platform/gp2x/menu.c
Normal file
107
platform/gp2x/menu.c
Normal file
|
@ -0,0 +1,107 @@
|
|||
#ifdef __GP2X_H__
|
||||
|
||||
#include <time.h>
|
||||
#include "soc.h"
|
||||
|
||||
static void menu_main_plat_draw(void)
|
||||
{
|
||||
static time_t last_bat_read = 0;
|
||||
static int last_bat_val = -1;
|
||||
unsigned short *bp = g_screen_ptr;
|
||||
int bat_h = me_mfont_h * 2 / 3;
|
||||
int i, u, w, wfill, batt_val;
|
||||
struct tm *tmp;
|
||||
time_t ltime;
|
||||
char time_s[16];
|
||||
|
||||
if (!(currentConfig.EmuOpt & EOPT_SHOW_RTC))
|
||||
return;
|
||||
|
||||
ltime = time(NULL);
|
||||
tmp = gmtime(<ime);
|
||||
strftime(time_s, sizeof(time_s), "%H:%M", tmp);
|
||||
|
||||
text_out16(g_screen_width - me_mfont_w * 6, me_mfont_h + 2, time_s);
|
||||
|
||||
if (ltime - last_bat_read > 10) {
|
||||
last_bat_read = ltime;
|
||||
last_bat_val = batt_val = gp2x_read_battery();
|
||||
}
|
||||
else
|
||||
batt_val = last_bat_val;
|
||||
|
||||
if (batt_val < 0 || batt_val > 100)
|
||||
return;
|
||||
|
||||
/* battery info */
|
||||
bp += (me_mfont_h * 2 + 2) * g_screen_width + g_screen_width - me_mfont_w * 3 - 3;
|
||||
for (i = 0; i < me_mfont_w * 2; i++)
|
||||
bp[i] = menu_text_color;
|
||||
for (i = 0; i < me_mfont_w * 2; i++)
|
||||
bp[i + g_screen_width * bat_h] = menu_text_color;
|
||||
for (i = 0; i <= bat_h; i++)
|
||||
bp[i * g_screen_width] =
|
||||
bp[i * g_screen_width + me_mfont_w * 2] = menu_text_color;
|
||||
for (i = 2; i < bat_h - 1; i++)
|
||||
bp[i * g_screen_width - 1] =
|
||||
bp[i * g_screen_width - 2] = menu_text_color;
|
||||
|
||||
w = me_mfont_w * 2 - 1;
|
||||
wfill = batt_val * w / 100;
|
||||
for (u = 1; u < bat_h; u++)
|
||||
for (i = 0; i < wfill; i++)
|
||||
bp[(w - i) + g_screen_width * u] = menu_text_color;
|
||||
}
|
||||
|
||||
// ------------ gfx options menu ------------
|
||||
|
||||
static const char *mgn_opt_renderer(menu_id id, int *offs)
|
||||
{
|
||||
*offs = -11;
|
||||
if (PicoOpt & POPT_ALT_RENDERER)
|
||||
return " 8bit fast";
|
||||
else if (currentConfig.EmuOpt & EOPT_16BPP)
|
||||
return "16bit accurate";
|
||||
else
|
||||
return " 8bit accurate";
|
||||
}
|
||||
|
||||
static const char *mgn_opt_scaling(menu_id id, int *offs)
|
||||
{
|
||||
*offs = -13;
|
||||
switch (currentConfig.scaling) {
|
||||
default: return " OFF";
|
||||
case EOPT_SCALE_HW_H: return " hw horizontal";
|
||||
case EOPT_SCALE_HW_HV: return "hw horiz. + vert";
|
||||
case EOPT_SCALE_SW_H: return " sw horizontal";
|
||||
}
|
||||
}
|
||||
|
||||
static const char *mgn_aopt_gamma(menu_id id, int *offs)
|
||||
{
|
||||
sprintf(static_buff, "%i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100);
|
||||
return static_buff;
|
||||
}
|
||||
|
||||
|
||||
#define MENU_GP2X_OPTIONS_GFX \
|
||||
mee_range_cust("Scaling", MA_OPT_SCALING, currentConfig.scaling, 0, 3, mgn_opt_scaling), \
|
||||
mee_onoff ("Tearing Fix", MA_OPT_TEARING_FIX, currentConfig.EmuOpt, EOPT_WIZ_TEAR_FIX), \
|
||||
mee_range_cust("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma), \
|
||||
mee_onoff ("A_SN's gamma curve", MA_OPT2_A_SN_GAMMA, currentConfig.EmuOpt, EOPT_A_SN_GAMMA), \
|
||||
mee_onoff ("Perfect vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_PSYNC),
|
||||
|
||||
#define MENU_GP2X_OPTIONS_ADV \
|
||||
mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoOpt, POPT_EXT_FM), \
|
||||
mee_onoff ("RAM overclock", MA_OPT2_RAMTIMINGS, currentConfig.EmuOpt, EOPT_RAM_TIMINGS), \
|
||||
mee_onoff ("MMU hack", MA_OPT2_SQUIDGEHACK, currentConfig.EmuOpt, EOPT_MMUHACK), \
|
||||
mee_onoff ("SVP dynarec", MA_OPT2_SVP_DYNAREC, PicoOpt, POPT_EN_SVP_DRC), \
|
||||
mee_onoff ("Status line in main menu", MA_OPT2_STATUS_LINE, currentConfig.EmuOpt, EOPT_SHOW_RTC ),
|
||||
|
||||
#else
|
||||
|
||||
#define MENU_GP2X_OPTIONS_GFX
|
||||
#define MENU_GP2X_OPTIONS_ADV
|
||||
#define mgn_opt_renderer NULL /* TODO */
|
||||
|
||||
#endif
|
|
@ -23,6 +23,7 @@ void (*set_lcd_gamma)(int g100, int A_SNs_curve);
|
|||
|
||||
void (*set_ram_timings)(void);
|
||||
void (*unset_ram_timings)(void);
|
||||
int (*gp2x_read_battery)(void);
|
||||
|
||||
|
||||
gp2x_soc_t soc_detect(void)
|
||||
|
|
|
@ -28,4 +28,5 @@ extern void (*set_lcd_gamma)(int g100, int A_SNs_curve);
|
|||
|
||||
extern void (*set_ram_timings)(void);
|
||||
extern void (*unset_ram_timings)(void);
|
||||
extern int (*gp2x_read_battery)(void);
|
||||
|
||||
|
|
|
@ -353,6 +353,10 @@ static void set_lcd_gamma_(int g100, int A_SNs_curve)
|
|||
gamma_was_changed = 1;
|
||||
}
|
||||
|
||||
static int gp2x_read_battery_(void)
|
||||
{
|
||||
return -1; /* TODO? */
|
||||
}
|
||||
|
||||
/* these are not quite MMSP2 related,
|
||||
* more to GP2X F100/F200 consoles themselves. */
|
||||
|
@ -503,6 +507,7 @@ void mmsp2_init(void)
|
|||
|
||||
set_ram_timings = set_ram_timings_;
|
||||
unset_ram_timings = unset_ram_timings_;
|
||||
gp2x_read_battery = gp2x_read_battery_;
|
||||
}
|
||||
|
||||
void mmsp2_finish(void)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
static volatile unsigned short *memregs;
|
||||
static volatile unsigned long *memregl;
|
||||
static int memdev = -1;
|
||||
static int battdev = -1;
|
||||
|
||||
extern void *gp2x_screens[4];
|
||||
|
||||
|
@ -190,6 +191,23 @@ static void set_lcd_gamma_(int g100, int A_SNs_curve)
|
|||
/* hm, the LCD possibly can do it (but not POLLUX) */
|
||||
}
|
||||
|
||||
static int gp2x_read_battery_(void)
|
||||
{
|
||||
unsigned short magic_val = 0;
|
||||
|
||||
if (battdev < 0)
|
||||
return -1;
|
||||
if (read(battdev, &magic_val, sizeof(magic_val)) != sizeof(magic_val))
|
||||
return -1;
|
||||
switch (magic_val) {
|
||||
default:
|
||||
case 1: return 100;
|
||||
case 2: return 66;
|
||||
case 3: return 40;
|
||||
case 4: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void pollux_init(void)
|
||||
{
|
||||
struct fb_fix_screeninfo fbfix;
|
||||
|
@ -242,7 +260,11 @@ void pollux_init(void)
|
|||
fb_work_buf = 0;
|
||||
g_screen_ptr = gp2x_screens[0];
|
||||
|
||||
pllsetreg0 = memregl[0xf004];
|
||||
battdev = open("/dev/pollux_batt", O_RDONLY);
|
||||
if (battdev < 0)
|
||||
perror("Warning: could't open pollux_batt");
|
||||
|
||||
pllsetreg0 = memregl[0xf004>>2];
|
||||
memtimex_old[0] = memregs[0x14802>>1];
|
||||
memtimex_old[1] = memregs[0x14804>>1];
|
||||
|
||||
|
@ -261,6 +283,7 @@ void pollux_init(void)
|
|||
|
||||
set_ram_timings = set_ram_timings_;
|
||||
unset_ram_timings = unset_ram_timings_;
|
||||
gp2x_read_battery = gp2x_read_battery_;
|
||||
}
|
||||
|
||||
void pollux_finish(void)
|
||||
|
@ -279,5 +302,7 @@ void pollux_finish(void)
|
|||
|
||||
munmap((void *)memregs, 0x20000);
|
||||
close(memdev);
|
||||
if (battdev >= 0)
|
||||
close(battdev);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue