From 0c9ae59222a6fa9af18dcc072fdfb06cfca124d6 Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 29 Jan 2010 17:26:40 +0000 Subject: [PATCH] sh2 overclock and logging stuff, menu refactoring git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@869 be3aeb3a-fb24-0410-a615-afba39da0efa --- common/config.c | 227 ++++++++++++++++++------------------------------ common/emu.c | 119 ++++++++++++++----------- common/emu.h | 12 ++- common/main.c | 2 +- common/menu.c | 202 +++++++++++++++++++++++------------------- common/menu.h | 45 +++++++--- common/plat.h | 4 +- gp2x/emu.c | 8 +- gp2x/menu.c | 17 +--- linux/emu.c | 6 +- pandora/emu.c | 6 +- win32/main.c | 2 +- win32/plat.c | 4 +- 13 files changed, 328 insertions(+), 326 deletions(-) diff --git a/common/config.c b/common/config.c index 4292000..bf1f5cf 100644 --- a/common/config.c +++ b/common/config.c @@ -50,53 +50,6 @@ static int seek_sect(FILE *f, const char *section) } -static void custom_write(FILE *f, const menu_entry *me, int no_def) -{ - char str24[24]; - - switch (me->id) - { - /* TODO: this should be rm'd when PSP menu is converted */ - case MA_OPT3_SCALE: - if (no_def && defaultConfig.scale == currentConfig.scale) return; - fprintf(f, "Scale factor = %.2f", currentConfig.scale); - break; - case MA_OPT3_HSCALE32: - if (no_def && defaultConfig.hscale32 == currentConfig.hscale32) return; - fprintf(f, "Hor. scale (for low res. games) = %.2f", currentConfig.hscale32); - break; - case MA_OPT3_HSCALE40: - if (no_def && defaultConfig.hscale40 == currentConfig.hscale40) return; - fprintf(f, "Hor. scale (for hi res. games) = %.2f", currentConfig.hscale40); - break; - case MA_OPT3_FILTERING: - if (no_def && defaultConfig.scaling == currentConfig.scaling) return; - fprintf(f, "Bilinear filtering = %i", currentConfig.scaling); - break; - case MA_OPT3_GAMMAA: - if (no_def && defaultConfig.gamma == currentConfig.gamma) return; - fprintf(f, "Gamma adjustment = %i", currentConfig.gamma); - break; - case MA_OPT3_BLACKLVL: - if (no_def && defaultConfig.gamma2 == currentConfig.gamma2) return; - fprintf(f, "Black level = %i", currentConfig.gamma2); - break; - case MA_OPT3_VSYNC: - if (no_def && (defaultConfig.EmuOpt&0x12000) == (currentConfig.gamma2&0x12000)) return; - strcpy(str24, "never"); - if (currentConfig.EmuOpt & 0x2000) - strcpy(str24, (currentConfig.EmuOpt & 0x10000) ? "sometimes" : "always"); - fprintf(f, "Wait for vsync = %s", str24); - break; - - default: - lprintf("unhandled custom_write: %i\n", me->id); - return; - } - fprintf(f, NL); -} - - static void keys_write(FILE *fn, const char *bind_str, int dev_id, const int *binds, int no_defaults) { char act[48]; @@ -170,6 +123,8 @@ static int default_var(const menu_entry *me) case MA_CDOPT_SCALEROT_CHIP: case MA_CDOPT_BETTER_SYNC: case MA_CDOPT_SAVERAM: + case MA_32XOPT_ENABLE_32X: + case MA_32XOPT_PWM: case MA_OPT2_SVP_DYNAREC: case MA_OPT2_NO_SPRITE_LIM: case MA_OPT2_NO_IDLE_LOOPS: @@ -197,11 +152,16 @@ static int default_var(const menu_entry *me) case MA_OPT_ROTATION: return defaultConfig.rotation; case MA_OPT2_GAMMA: return defaultConfig.gamma; case MA_OPT_FRAMESKIP: return defaultConfig.Frameskip; + case MA_OPT_CONFIRM_STATES: return defaultConfig.confirm_save; case MA_OPT_CPU_CLOCKS: return defaultConfig.CPUclock; case MA_OPT_RENDERER: return defaultConfig.renderer; + case MA_32XOPT_RENDERER: return defaultConfig.renderer32x; case MA_OPT_SAVE_SLOT: + return 0; + default: + lprintf("missing default for %d\n", me->id); return 0; } } @@ -216,11 +176,12 @@ static int is_cust_val_default(const menu_entry *me) case MA_OPT_SOUND_QUALITY: return defaultConfig.s_PsndRate == PsndRate && ((defaultConfig.s_PicoOpt ^ PicoOpt) & POPT_EN_STEREO) == 0; - case MA_OPT_CONFIRM_STATES: - return !((defaultConfig.EmuOpt ^ currentConfig.EmuOpt) & - (EOPT_CONFIRM_LOAD|EOPT_CONFIRM_SAVE)) == 0; case MA_CDOPT_READAHEAD: return defaultConfig.s_PicoCDBuffers == PicoCDBuffers; + case MA_32XOPT_MSH2_CYCLES: + return p32x_msh2_multiplier == MSH2_MULTI_DEFAULT; + case MA_32XOPT_SSH2_CYCLES: + return p32x_ssh2_multiplier == SSH2_MULTI_DEFAULT; default:break; } @@ -302,29 +263,42 @@ write: if (section != NULL) fprintf(fn, "[%s]" NL, section); - me = me_list_get_first(); - while (me != NULL) + for (me = me_list_get_first(); me != NULL; me = me_list_get_next()) { int dummy; if (!me->need_to_save) - goto next; + continue; + if (me->beh == MB_OPT_ONOFF || me->beh == MB_OPT_CUSTONOFF) { if (!no_defaults || ((*(int *)me->var ^ default_var(me)) & me->mask)) fprintf(fn, "%s = %i" NL, me->name, (*(int *)me->var & me->mask) ? 1 : 0); - } else if (me->beh == MB_OPT_RANGE || me->beh == MB_OPT_CUSTRANGE) { + } + else if (me->beh == MB_OPT_RANGE || me->beh == MB_OPT_CUSTRANGE) { if (!no_defaults || (*(int *)me->var ^ default_var(me))) fprintf(fn, "%s = %i" NL, me->name, *(int *)me->var); - } else if (me->name != NULL && me->generate_name != NULL) { + } + else if (me->beh == MB_OPT_ENUM && me->data != NULL) { + const char **names = (const char **)me->data; + for (t = 0; names[t] != NULL; t++) + if (*(int *)me->var == t && (!no_defaults || (*(int *)me->var ^ default_var(me)))) { + strncpy(line, names[t], sizeof(line)); + goto write_line; + } + } + else if (me->name != NULL && me->generate_name != NULL) { if (!no_defaults || !is_cust_val_default(me)) { strncpy(line, me->generate_name(0, &dummy), sizeof(line)); - line[sizeof(line) - 1] = 0; - mystrip(line); - fprintf(fn, "%s = %s" NL, me->name, line); + goto write_line; } - } else - custom_write(fn, me, no_defaults); -next: - me = me_list_get_next(); + } + else + lprintf("config: unhandled write: %i\n", me->id); + continue; + +write_line: + line[sizeof(line) - 1] = 0; + mystrip(line); + fprintf(fn, "%s = %s" NL, me->name, line); } /* input: save device names */ @@ -467,40 +441,9 @@ int config_readlrom(const char *fname) static int custom_read(menu_entry *me, const char *var, const char *val) { char *tmp; - int i; switch (me->id) { - case MA_OPT_RENDERER: - if (strcasecmp(var, "Renderer") != 0 || renderer_names == NULL) - return 0; - - for (i = 0; renderer_names[i] != NULL; i++) { - if (strcasecmp(val, renderer_names[i]) == 0) { - currentConfig.renderer = i; - return 1; - } - } - return 0; - - case MA_OPT_SCALING: -#ifdef __GP2X__ - if (strcasecmp(var, "Scaling") != 0) return 0; - if (strcasecmp(val, "OFF") == 0) { - currentConfig.scaling = EOPT_SCALE_NONE; - } else if (strcasecmp(val, "hw horizontal") == 0) { - currentConfig.scaling = EOPT_SCALE_HW_H; - } else if (strcasecmp(val, "hw horiz. + vert.") == 0) { - currentConfig.scaling = EOPT_SCALE_HW_HV; - } else if (strcasecmp(val, "sw horizontal") == 0) { - currentConfig.scaling = EOPT_SCALE_SW_H; - } else - currentConfig.scaling = atoi(val); - return 1; -#else - return 0; -#endif - case MA_OPT_FRAMESKIP: if (strcasecmp(var, "Frameskip") != 0) return 0; if (strcasecmp(val, "Auto") == 0) @@ -559,40 +502,23 @@ static int custom_read(menu_entry *me, const char *var, const char *val) return 0; return 1; - case MA_OPT_CONFIRM_STATES: - if (strcasecmp(var, "Confirm savestate") != 0) return 0; - if (strcasecmp(val, "OFF") == 0) { - currentConfig.EmuOpt &= ~(5<<9); - } else if (strcasecmp(val, "writes") == 0) { - currentConfig.EmuOpt &= ~(5<<9); - currentConfig.EmuOpt |= 1<<9; - } else if (strcasecmp(val, "loads") == 0) { - currentConfig.EmuOpt &= ~(5<<9); - currentConfig.EmuOpt |= 4<<9; - } else if (strcasecmp(val, "both") == 0) { - currentConfig.EmuOpt &= ~(5<<9); - currentConfig.EmuOpt |= 5<<9; - } else - return 0; - return 1; - case MA_OPT2_GAMMA: if (strcasecmp(var, "Gamma correction") != 0) return 0; currentConfig.gamma = (int) (atof(val) * 100.0); return 1; - case MA_OPT2_SQUIDGEHACK: - if (strcasecmp(var, "Squidgehack") != 0) return 0; - i = atoi(val); - if (i) *(int *)me->var |= me->mask; - else *(int *)me->var &= ~me->mask; - return 1; - case MA_CDOPT_READAHEAD: if (strcasecmp(var, "ReadAhead buffer") != 0) return 0; PicoCDBuffers = atoi(val) / 2; return 1; + case MA_32XOPT_MSH2_CYCLES: + case MA_32XOPT_SSH2_CYCLES: { + int *mul = (me->id == MA_32XOPT_MSH2_CYCLES) ? &p32x_msh2_multiplier : &p32x_ssh2_multiplier; + *mul = ((unsigned int)atoi(val) << SH2_MULTI_SHIFT) / 7670; + return 1; + } + /* PSP */ case MA_OPT3_SCALE: if (strcasecmp(var, "Scale factor") != 0) return 0; @@ -606,19 +532,8 @@ static int custom_read(menu_entry *me, const char *var, const char *val) if (strcasecmp(var, "Hor. scale (for hi res. games)") != 0) return 0; currentConfig.hscale40 = atof(val); return 1; - case MA_OPT3_FILTERING: - if (strcasecmp(var, "Bilinear filtering") != 0) return 0; - currentConfig.scaling = atoi(val); - return 1; - case MA_OPT3_GAMMAA: - if (strcasecmp(var, "Gamma adjustment") != 0) return 0; - currentConfig.gamma = atoi(val); - return 1; - case MA_OPT3_BLACKLVL: - if (strcasecmp(var, "Black level") != 0) return 0; - currentConfig.gamma2 = atoi(val); - return 1; case MA_OPT3_VSYNC: + // XXX: use enum if (strcasecmp(var, "Wait for vsync") != 0) return 0; if (strcasecmp(val, "never") == 0) { currentConfig.EmuOpt &= ~0x12000; @@ -632,7 +547,7 @@ static int custom_read(menu_entry *me, const char *var, const char *val) return 1; default: - lprintf("unhandled custom_read: %i\n", me->id); + lprintf("unhandled custom_read %i: %s\n", me->id, var); return 0; } } @@ -708,7 +623,7 @@ static unsigned char input_dev_map[IN_MAX_DEVS]; static void parse(const char *var, const char *val) { menu_entry *me; - int tmp, ret = 0; + int tmp; if (strcasecmp(var, "LastUsedROM") == 0) return; /* handled elsewhere */ @@ -749,32 +664,60 @@ static void parse(const char *var, const char *val) return; } - me = me_list_get_first(); - while (me != NULL && ret == 0) + for (me = me_list_get_first(); me != NULL; me = me_list_get_next()) { + char *p; + if (!me->need_to_save) - goto next; + continue; if (me->name != NULL && me->name[0] != 0) { if (strcasecmp(var, me->name) != 0) - goto next; /* surely not this one */ + continue; /* surely not this one */ if (me->beh == MB_OPT_ONOFF) { - tmp = atoi(val); + tmp = strtol(val, &p, 0); + if (*p != 0) + goto bad_val; if (tmp) *(int *)me->var |= me->mask; else *(int *)me->var &= ~me->mask; return; - } else if (me->beh == MB_OPT_RANGE) { - tmp = atoi(val); + } + else if (me->beh == MB_OPT_RANGE) { + tmp = strtol(val, &p, 0); + if (*p != 0) + goto bad_val; if (tmp < me->min) tmp = me->min; if (tmp > me->max) tmp = me->max; *(int *)me->var = tmp; return; } + else if (me->beh == MB_OPT_ENUM) { + const char **names, *p1; + int i; + + names = (const char **)me->data; + if (names == NULL) + goto bad_val; + for (i = 0; names[i] != NULL; i++) { + for (p1 = names[i]; *p1 == ' '; p1++) + ; + if (strcasecmp(p1, val) == 0) { + *(int *)me->var = i; + return; + } + } + goto bad_val; + } } - ret = custom_read(me, var, val); -next: - me = me_list_get_next(); + if (!custom_read(me, var, val)) + break; + return; } - if (!ret) lprintf("config_readsect: unhandled var: \"%s\"\n", var); + + lprintf("config_readsect: unhandled var: \"%s\"\n", var); + return; + +bad_val: + lprintf("config_readsect: unhandled val for \"%s\": %s\n", var, val); } diff --git a/common/emu.c b/common/emu.c index 1e83694..a075abd 100644 --- a/common/emu.c +++ b/common/emu.c @@ -92,6 +92,36 @@ static void get_ext(const char *file, char *ext) strlwr_(ext); } +static void fname_ext(char *dst, int dstlen, const char *prefix, const char *ext, const char *fname) +{ + int prefix_len = 0; + const char *p; + + *dst = 0; + if (prefix) { + int len = plat_get_root_dir(dst, dstlen); + strcpy(dst + len, prefix); + prefix_len = len + strlen(prefix); + } + + p = fname + strlen(fname) - 1; + for (; p >= fname && *p != PATH_SEP_C; p--) + ; + p++; + strncpy(dst + prefix_len, p, dstlen - prefix_len - 1); + + dst[dstlen - 8] = 0; + if (dst[strlen(dst) - 4] == '.') + dst[strlen(dst) - 4] = 0; + if (ext) + strcat(dst, ext); +} + +static void romfname_ext(char *dst, int dstlen, const char *prefix, const char *ext) +{ + fname_ext(dst, dstlen, prefix, ext, rom_fname_loaded); +} + void emu_status_msg(const char *format, ...) { va_list vl; @@ -365,7 +395,7 @@ static int extract_text(char *dest, const unsigned char *src, int len, int swab) return p - dest; } -static char *emu_make_rom_id(void) +static char *emu_make_rom_id(const char *fname) { static char id_string[3+0xe*3+0x3*3+0x30*3+3]; int pos, swab = 1; @@ -374,15 +404,25 @@ static char *emu_make_rom_id(void) strcpy(id_string, "CD|"); swab = 0; } - else strcpy(id_string, "MD|"); + else if (PicoAHW & PAHW_SMS) + strcpy(id_string, "MS|"); + else strcpy(id_string, "MD|"); pos = 3; - pos += extract_text(id_string + pos, id_header + 0x80, 0x0e, swab); // serial - id_string[pos] = '|'; pos++; - pos += extract_text(id_string + pos, id_header + 0xf0, 0x03, swab); // region - id_string[pos] = '|'; pos++; - pos += extract_text(id_string + pos, id_header + 0x50, 0x30, swab); // overseas name - id_string[pos] = 0; + if (!(PicoAHW & PAHW_SMS)) { + pos += extract_text(id_string + pos, id_header + 0x80, 0x0e, swab); // serial + id_string[pos] = '|'; pos++; + pos += extract_text(id_string + pos, id_header + 0xf0, 0x03, swab); // region + id_string[pos] = '|'; pos++; + pos += extract_text(id_string + pos, id_header + 0x50, 0x30, swab); // overseas name + id_string[pos] = 0; + if (pos > 5) + return id_string; + pos = 3; + } + + // can't find name in ROM, use filename + fname_ext(id_string + 3, sizeof(id_string) - 3, NULL, NULL, fname); return id_string; } @@ -530,8 +570,8 @@ int emu_reload_rom(char *rom_fname) // valid CD image, check for BIOS.. // we need to have config loaded at this point - ret = emu_read_config(1, 0); - if (!ret) emu_read_config(0, 0); + ret = emu_read_config(rom_fname, 0); + if (!ret) emu_read_config(NULL, 0); cfg_loaded = 1; if (PicoRegionOverride) { @@ -593,8 +633,8 @@ int emu_reload_rom(char *rom_fname) if (!(PicoAHW & PAHW_MCD)) memcpy(id_header, rom_data + 0x100, sizeof(id_header)); if (!cfg_loaded) { - ret = emu_read_config(1, 0); - if (!ret) emu_read_config(0, 0); + ret = emu_read_config(rom_fname, 0); + if (!ret) emu_read_config(NULL, 0); } emu_make_path(static_buff, "carthw.cfg", sizeof(static_buff)); @@ -681,29 +721,6 @@ int emu_swap_cd(const char *fname) return 1; } -static void romfname_ext(char *dst, const char *prefix, const char *ext) -{ - char *p; - int prefix_len = 0; - - // make save filename - p = rom_fname_loaded + strlen(rom_fname_loaded) - 1; - for (; p >= rom_fname_loaded && *p != PATH_SEP_C; p--); p++; - *dst = 0; - if (prefix) { - int len = plat_get_root_dir(dst, 512); - strcpy(dst + len, prefix); - prefix_len = len + strlen(prefix); - } -#ifdef UIQ3 - else p = rom_fname_loaded; // backward compatibility -#endif - strncpy(dst + prefix_len, p, 511-prefix_len); - dst[511-8] = 0; - if (dst[strlen(dst)-4] == '.') dst[strlen(dst)-4] = 0; - if (ext) strcat(dst, ext); -} - // void emu_make_path(char *buff, const char *end, int size) { @@ -733,7 +750,7 @@ static void make_config_cfg(char *cfg_buff_512) void emu_prep_defconfig(void) { memset(&defaultConfig, 0, sizeof(defaultConfig)); - defaultConfig.EmuOpt = 0x9d | EOPT_RAM_TIMINGS|EOPT_CONFIRM_SAVE|EOPT_EN_CD_LEDS; + defaultConfig.EmuOpt = 0x9d | EOPT_RAM_TIMINGS|EOPT_EN_CD_LEDS; defaultConfig.s_PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES | POPT_EN_32X|POPT_EN_PWM; @@ -741,6 +758,7 @@ void emu_prep_defconfig(void) defaultConfig.s_PicoRegion = 0; // auto defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP defaultConfig.s_PicoCDBuffers = 0; + defaultConfig.confirm_save = EOPT_CONFIRM_SAVE; defaultConfig.Frameskip = -1; // auto defaultConfig.volume = 50; defaultConfig.gamma = 100; @@ -759,9 +777,11 @@ void emu_set_defconfig(void) PicoRegionOverride = currentConfig.s_PicoRegion; PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder; PicoCDBuffers = currentConfig.s_PicoCDBuffers; + p32x_msh2_multiplier = MSH2_MULTI_DEFAULT; + p32x_ssh2_multiplier = SSH2_MULTI_DEFAULT; } -int emu_read_config(int game, int no_defaults) +int emu_read_config(const char *rom_fname, int no_defaults) { char cfg[512]; int ret; @@ -769,16 +789,16 @@ int emu_read_config(int game, int no_defaults) if (!no_defaults) emu_set_defconfig(); - if (!game) + if (rom_fname == NULL) { + // global config make_config_cfg(cfg); ret = config_readsect(cfg, NULL); } else { - char *sect = emu_make_rom_id(); + char *sect = emu_make_rom_id(rom_fname); - // try new .cfg way if (config_slot != 0) sprintf(cfg, "game.%i.cfg", config_slot); else strcpy(cfg, "game.cfg"); @@ -839,7 +859,7 @@ int emu_write_config(int is_game) if (config_slot != 0) sprintf(cfg, "game.%i.cfg", config_slot); else strcpy(cfg, "game.cfg"); - game_sect = emu_make_rom_id(); + game_sect = emu_make_rom_id(rom_fname_loaded); lprintf("emu_write_config: sect \"%s\"\n", game_sect); } @@ -939,14 +959,15 @@ char *emu_get_save_fname(int load, int is_sram, int slot) if (is_sram) { strcpy(ext, (PicoAHW & PAHW_MCD) ? ".brm" : ".srm"); - romfname_ext(saveFname, (PicoAHW & PAHW_MCD) ? "brm"PATH_SEP : "srm"PATH_SEP, ext); + romfname_ext(saveFname, sizeof(static_buff), + (PicoAHW & PAHW_MCD) ? "brm"PATH_SEP : "srm"PATH_SEP, ext); if (!load) return saveFname; if (try_ropen_file(saveFname)) return saveFname; - romfname_ext(saveFname, NULL, ext); + romfname_ext(saveFname, sizeof(static_buff), NULL, ext); if (try_ropen_file(saveFname)) return saveFname; } @@ -960,15 +981,15 @@ char *emu_get_save_fname(int load, int is_sram, int slot) strcat(ext, ext_main); if (!load) { - romfname_ext(saveFname, "mds" PATH_SEP, ext); + romfname_ext(saveFname, sizeof(static_buff), "mds" PATH_SEP, ext); return saveFname; } else { - romfname_ext(saveFname, "mds" PATH_SEP, ext); + romfname_ext(saveFname, sizeof(static_buff), "mds" PATH_SEP, ext); if (try_ropen_file(saveFname)) return saveFname; - romfname_ext(saveFname, NULL, ext); + romfname_ext(saveFname, sizeof(static_buff), NULL, ext); if (try_ropen_file(saveFname)) return saveFname; @@ -978,7 +999,7 @@ char *emu_get_save_fname(int load, int is_sram, int slot) sprintf(ext, ".%i", slot); strcat(ext, ext_othr); - romfname_ext(saveFname, "mds"PATH_SEP, ext); + romfname_ext(saveFname, sizeof(static_buff), "mds"PATH_SEP, ext); if (try_ropen_file(saveFname)) return saveFname; } @@ -1212,8 +1233,8 @@ static void run_events_ui(unsigned int which) { int do_it = 1; if ( emu_check_save_file(state_slot) && - (((which & PEV_STATE_LOAD) && (currentConfig.EmuOpt & EOPT_CONFIRM_LOAD)) || - ((which & PEV_STATE_SAVE) && (currentConfig.EmuOpt & EOPT_CONFIRM_SAVE))) ) + (((which & PEV_STATE_LOAD) && (currentConfig.confirm_save & EOPT_CONFIRM_LOAD)) || + ((which & PEV_STATE_SAVE) && (currentConfig.confirm_save & EOPT_CONFIRM_SAVE))) ) { const char *nm; char tmp[64]; diff --git a/common/emu.h b/common/emu.h index 518d5fd..f51907f 100644 --- a/common/emu.h +++ b/common/emu.h @@ -30,9 +30,7 @@ extern int g_screen_height; #define EOPT_NO_AUTOSVCFG (1<<5) #define EOPT_16BPP (1<<7) // depreceted for .renderer #define EOPT_RAM_TIMINGS (1<<8) -#define EOPT_CONFIRM_SAVE (1<<9) #define EOPT_EN_CD_LEDS (1<<10) -#define EOPT_CONFIRM_LOAD (1<<11) #define EOPT_A_SN_GAMMA (1<<12) #define EOPT_VSYNC (1<<13) #define EOPT_GIZ_SCANLN (1<<14) @@ -50,6 +48,13 @@ enum { EOPT_SCALE_HW_HV, }; +enum { + EOPT_CONFIRM_NONE = 0, + EOPT_CONFIRM_SAVE = 1, + EOPT_CONFIRM_LOAD = 2, + EOPT_CONFIRM_BOTH = 3, +}; + typedef struct _currentConfig_t { int EmuOpt; int s_PicoOpt; @@ -58,6 +63,7 @@ typedef struct _currentConfig_t { int s_PicoAutoRgnOrder; int s_PicoCDBuffers; int Frameskip; + int confirm_save; int CPUclock; int volume; int gamma; @@ -121,7 +127,7 @@ void emu_reset_game(void); void emu_prep_defconfig(void); void emu_set_defconfig(void); -int emu_read_config(int game, int no_defaults); +int emu_read_config(const char *rom_fname, int no_defaults); int emu_write_config(int game); char *emu_get_save_fname(int load, int is_sram, int slot); diff --git a/common/main.c b/common/main.c index 7167df2..072fcfd 100644 --- a/common/main.c +++ b/common/main.c @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) /* in_init() must go before config, config accesses in_ fwk */ in_init(); emu_prep_defconfig(); - emu_read_config(0, 0); + emu_read_config(NULL, 0); config_readlrom(PicoConfigFile); plat_init(); diff --git a/common/menu.c b/common/menu.c index 5b0474a..9402796 100644 --- a/common/menu.c +++ b/common/menu.c @@ -423,6 +423,9 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) if (name != NULL) wt += (strlen(name) + offs) * me_mfont_w; break; + case MB_OPT_ENUM: + wt += 10 * me_mfont_w; + break; } } @@ -452,6 +455,9 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) for (ent = entries; ent->name; ent++) { + const char **names; + int len; + if (!ent->enabled) continue; @@ -482,14 +488,28 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) if (name != NULL) text_out16(x + col2_offs + offs * me_mfont_w, y, "%s", name); break; + case MB_OPT_ENUM: + names = (const char **)ent->data; + offs = 0; + for (i = 0; names[i] != NULL; i++) { + len = strlen(names[i]); + if (len > 10) + offs = 10 - len - 2; + if (i == *(int *)ent->var) { + text_out16(x + col2_offs + offs * me_mfont_w, y, "%s", names[i]); + break; + } + } + break; } y += me_mfont_h; } - /* display message if we have one */ + /* display help or message if we have one */ + h = (g_screen_height - h) / 2; // bottom area height if (menu_error_msg[0] != 0) { - if (g_screen_height - h >= 2 * me_mfont_h) + if (h >= me_mfont_h + 4) text_out16(5, g_screen_height - me_mfont_h - 4, menu_error_msg); else lprintf("menu msg doesn't fit!\n"); @@ -497,6 +517,15 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) if (plat_get_ticks_ms() - menu_error_time > 2048) menu_error_msg[0] = 0; } + else if (entries[asel].help != NULL) { + const char *tmp = entries[asel].help; + int l; + for (l = 0; tmp != NULL && *tmp != 0; l++) + tmp = strchr(tmp + 1, '\n'); + if (h >= l * me_sfont_h + 4) + for (tmp = entries[asel].help; l > 0; l--, tmp = strchr(tmp, '\n') + 1) + smalltext_out16(5, g_screen_height - (l * me_sfont_h + 4), tmp, 0xffff); + } if (draw_more != NULL) draw_more(); @@ -506,6 +535,7 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) static int me_process(menu_entry *entry, int is_next, int is_lr) { + const char **names; int c; switch (entry->beh) { @@ -522,6 +552,16 @@ static int me_process(menu_entry *entry, int is_next, int is_lr) if (*(int *)entry->var > (int)entry->max) *(int *)entry->var = (int)entry->min; return 1; + case MB_OPT_ENUM: + names = (const char **)entry->data; + for (c = 0; names[c] != NULL; c++) + ; + *(int *)entry->var += is_next ? 1 : -1; + if (*(int *)entry->var < 0) + *(int *)entry->var = 0; + if (*(int *)entry->var >= c) + *(int *)entry->var = c - 1; + return 1; default: return 0; } @@ -581,12 +621,13 @@ static void me_loop(menu_entry *menu, int *menu_sel, void (*draw_more)(void)) continue; } - if (inp & (PBTN_MOK|PBTN_LEFT|PBTN_RIGHT)) + if (inp & (PBTN_MOK|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R)) { - if (menu[sel].handler != NULL) { + /* require PBTN_MOK for MB_NONE */ + if (menu[sel].handler != NULL && (menu[sel].beh != MB_NONE || (inp & PBTN_MOK))) { ret = menu[sel].handler(menu[sel].id, inp); if (ret) break; - menu_sel_max = me_count(menu) - 1; /* might change */ + menu_sel_max = me_count(menu) - 1; /* might change, so update */ } } } @@ -1405,7 +1446,7 @@ static const char *mgn_dev_name(menu_id id, int *offs) } static int mh_saveloadcfg(menu_id id, int keys); -static const char *mgn_savecfg(menu_id id, int *offs); +static const char *mgn_saveloadcfg(menu_id id, int *offs); static menu_entry e_menu_keyconfig[] = { @@ -1414,8 +1455,8 @@ static menu_entry e_menu_keyconfig[] = mee_handler_id("Emulator controls", MA_CTRL_EMU, key_config_loop_wrap), mee_onoff ("6 button pad", MA_OPT_6BUTTON_PAD, PicoOpt, POPT_6BTN_PAD), mee_range ("Turbo rate", MA_CTRL_TURBO_RATE, currentConfig.turbo_rate, 1, 30), - mee_handler_mkname_id(MA_OPT_SAVECFG, mh_saveloadcfg, mgn_savecfg), - mee_handler_id("Save cfg for loaded game", MA_OPT_SAVECFG_GAME, mh_saveloadcfg), + mee_cust_nosave("Save global config", MA_OPT_SAVECFG, mh_saveloadcfg, mgn_saveloadcfg), + mee_cust_nosave("Save cfg for loaded game", MA_OPT_SAVECFG_GAME, mh_saveloadcfg, mgn_saveloadcfg), mee_label (""), mee_label ("Input devices:"), mee_label_mk (MA_CTRL_DEV_FIRST, mgn_dev_name), @@ -1464,15 +1505,25 @@ static int mh_cdopt_ra(menu_id id, int keys) return 0; } +static const char h_cdleds[] = "Show power/CD LEDs of emulated console"; +static const char h_cdda[] = "Play audio tracks from mp3s/wavs/bins"; +static const char h_cdpcm[] = "Emulate PCM audio chip for effects/voices/music"; +static const char h_srcart[] = "Emulate the save RAM cartridge accessory\n" + "most games don't need this"; +static const char h_scfx[] = "Emulate scale/rotate ASIC chip for graphics effects\n" + "disable to improve performance"; +static const char h_bsync[] = "More accurate mode for CPUs (needed for some games)\n" + "disable to improve performance"; + static menu_entry e_menu_cd_options[] = { - mee_onoff("CD LEDs", MA_CDOPT_LEDS, currentConfig.EmuOpt, EOPT_EN_CD_LEDS), - mee_onoff("CDDA audio", MA_CDOPT_CDDA, PicoOpt, POPT_EN_MCD_CDDA), - mee_onoff("PCM audio", MA_CDOPT_PCM, PicoOpt, POPT_EN_MCD_PCM), - mee_cust ("ReadAhead buffer", MA_CDOPT_READAHEAD, mh_cdopt_ra, mgn_cdopt_ra), - mee_onoff("SaveRAM cart", MA_CDOPT_SAVERAM, PicoOpt, POPT_EN_MCD_RAMCART), - mee_onoff("Scale/Rot. fx (slow)", MA_CDOPT_SCALEROT_CHIP, PicoOpt, POPT_EN_MCD_GFX), - mee_onoff("Better sync (slow)", MA_CDOPT_BETTER_SYNC, PicoOpt, POPT_EN_MCD_PSYNC), + mee_onoff_h("CD LEDs", MA_CDOPT_LEDS, currentConfig.EmuOpt, EOPT_EN_CD_LEDS, h_cdleds), + mee_onoff_h("CDDA audio", MA_CDOPT_CDDA, PicoOpt, POPT_EN_MCD_CDDA, h_cdda), + mee_onoff_h("PCM audio", MA_CDOPT_PCM, PicoOpt, POPT_EN_MCD_PCM, h_cdpcm), + mee_cust ("ReadAhead buffer", MA_CDOPT_READAHEAD, mh_cdopt_ra, mgn_cdopt_ra), + mee_onoff_h("SaveRAM cart", MA_CDOPT_SAVERAM, PicoOpt, POPT_EN_MCD_RAMCART, h_srcart), + mee_onoff_h("Scale/Rot. fx (slow)", MA_CDOPT_SCALEROT_CHIP, PicoOpt, POPT_EN_MCD_GFX, h_scfx), + mee_onoff_h("Better sync (slow)", MA_CDOPT_BETTER_SYNC, PicoOpt, POPT_EN_MCD_PSYNC, h_bsync), mee_end, }; @@ -1485,48 +1536,55 @@ static int menu_loop_cd_options(menu_id id, int keys) // ------------ 32X options menu ------------ -static const char *get_rname(const char **rn, int val, int *offs) +// convert from multiplier of VClk +static int mh_opt_sh2cycles(menu_id id, int keys) { - int i, len, found = -1, maxlen = 0; + int *mul = (id == MA_32XOPT_MSH2_CYCLES) ? &p32x_msh2_multiplier : &p32x_ssh2_multiplier; - for (i = 0; rn[i] != NULL; i++) { - len = strlen(rn[i]); - if (len > maxlen) - maxlen = len; - if (i == val) - found = i; - } + if (keys & (PBTN_LEFT|PBTN_RIGHT)) + *mul += (keys & PBTN_LEFT) ? -10 : 10; + if (keys & (PBTN_L|PBTN_R)) + *mul += (keys & PBTN_L) ? -100 : 100; + + if (*mul < 1) + *mul = 1; + else if (*mul > (10 << SH2_MULTI_SHIFT)) + *mul = 10 << SH2_MULTI_SHIFT; - *offs = 3 - maxlen; - if (found >= 0) - return rn[found]; - return "???"; + return 0; } -static const char *mgn_opt_renderer32x(menu_id id, int *offs) +static const char *mgn_opt_sh2cycles(menu_id id, int *offs) { - return get_rname(renderer_names32x, currentConfig.renderer32x, offs); + int mul = (id == MA_32XOPT_MSH2_CYCLES) ? p32x_msh2_multiplier : p32x_ssh2_multiplier; + + sprintf(static_buff, "%d", 7670 * mul >> SH2_MULTI_SHIFT); + return static_buff; } +static const char h_32x_enable[] = "Enable emulation of the 32X addon"; +static const char h_pwm[] = "Disabling may improve performance, but break sound"; +static const char h_sh2cycles[] = "Cycles/millisecond (similar to DOSBox)\n" + "lower values speed up emulation but break games\n" + "at least 11000 recommended for compatibility"; + static menu_entry e_menu_32x_options[] = { - mee_onoff ("32X enabled", MA_32XOPT_ENABLE_32X, PicoOpt, POPT_EN_32X), - mee_range_cust("32X renderer", MA_32XOPT_RENDERER, currentConfig.renderer32x, 0, 0, mgn_opt_renderer32x), - mee_onoff ("PWM sound", MA_32XOPT_PWM, PicoOpt, POPT_EN_PWM), + mee_onoff_h ("32X enabled", MA_32XOPT_ENABLE_32X, PicoOpt, POPT_EN_32X, h_32x_enable), + mee_enum ("32X renderer", MA_32XOPT_RENDERER, currentConfig.renderer32x, renderer_names32x), + mee_onoff_h ("PWM sound", MA_32XOPT_PWM, PicoOpt, POPT_EN_PWM, h_pwm), + mee_cust_h ("Master SH2 cycles", MA_32XOPT_MSH2_CYCLES, mh_opt_sh2cycles, mgn_opt_sh2cycles, h_sh2cycles), + mee_cust_h ("Slave SH2 cycles", MA_32XOPT_SSH2_CYCLES, mh_opt_sh2cycles, mgn_opt_sh2cycles, h_sh2cycles), mee_end, }; static int menu_loop_32x_options(menu_id id, int keys) { static int sel = 0; - int i, c; - - for (c = 0; renderer_names32x != NULL && renderer_names32x[c] != NULL; ) - c++; - i = me_id2offset(e_menu_32x_options, MA_32XOPT_RENDERER); - e_menu_32x_options[i].max = c > 0 ? (c - 1) : 0; + me_enable(e_menu_32x_options, MA_32XOPT_RENDERER, renderer_names32x != NULL); me_loop(e_menu_32x_options, &sel, NULL); + return 0; } @@ -1556,14 +1614,9 @@ static int menu_loop_adv_options(menu_id id, int keys) // ------------ gfx options menu ------------ -static const char *mgn_opt_renderer(menu_id id, int *offs) -{ - return get_rname(renderer_names, currentConfig.renderer, offs); -} - static menu_entry e_menu_gfx_options[] = { - mee_range_cust("Renderer", MA_OPT_RENDERER, currentConfig.renderer, 0, 0, mgn_opt_renderer), + mee_enum("Renderer", MA_OPT_RENDERER, currentConfig.renderer, renderer_names), MENU_OPTIONS_GFX mee_end, }; @@ -1571,15 +1624,10 @@ static menu_entry e_menu_gfx_options[] = static int menu_loop_gfx_options(menu_id id, int keys) { static int sel = 0; - int i, c; - - for (c = 0; renderer_names != NULL && renderer_names[c] != NULL; ) - c++; - i = me_id2offset(e_menu_gfx_options, MA_OPT_RENDERER); - e_menu_gfx_options[i].max = c > 0 ? (c - 1) : 0; - me_enable(e_menu_gfx_options, MA_OPT_RENDERER, renderer_names != NULL); + me_enable(e_menu_gfx_options, MA_OPT_RENDERER, renderer_names[0] != NULL); me_loop(e_menu_gfx_options, &sel, NULL); + return 0; } @@ -1643,8 +1691,6 @@ static void region_prevnext(int right) static int mh_opt_misc(menu_id id, int keys) { - int i; - switch (id) { case MA_OPT_SOUND_QUALITY: PsndRate = sndrate_prevnext(PsndRate, keys & PBTN_RIGHT); @@ -1652,14 +1698,6 @@ static int mh_opt_misc(menu_id id, int keys) case MA_OPT_REGION: region_prevnext(keys & PBTN_RIGHT); break; - case MA_OPT_CONFIRM_STATES: - i = ((currentConfig.EmuOpt>>9)&1) | ((currentConfig.EmuOpt>>10)&2); - i += (keys & PBTN_LEFT) ? -1 : 1; - if (i < 0) i = 0; else if (i > 3) i = 3; - i |= i << 1; i &= ~2; - currentConfig.EmuOpt &= ~0xa00; - currentConfig.EmuOpt |= i << 9; - break; default: break; } @@ -1687,8 +1725,8 @@ static int mh_saveloadcfg(menu_id id, int keys) me_update_msg("failed to write config"); break; case MA_OPT_LOADCFG: - ret = emu_read_config(1, 1); - if (!ret) ret = emu_read_config(0, 1); + ret = emu_read_config(rom_fname_loaded, 1); + if (!ret) ret = emu_read_config(NULL, 1); if (ret) me_update_msg("config loaded"); else me_update_msg("failed to load config"); break; @@ -1749,29 +1787,17 @@ static const char *mgn_opt_region(menu_id id, int *offs) } } -static const char *mgn_opt_c_saves(menu_id id, int *offs) +static const char *mgn_saveloadcfg(menu_id id, int *offs) { - switch ((currentConfig.EmuOpt >> 9) & 5) { - default: return "OFF"; - case 1: return "writes"; - case 4: return "loads"; - case 5: return "both"; - } -} - -static const char *mgn_savecfg(menu_id id, int *offs) -{ - strcpy(static_buff, "Save global config"); + static_buff[0] = 0; if (config_slot != 0) - sprintf(static_buff + strlen(static_buff), " (profile: %i)", config_slot); + sprintf(static_buff, "[%i]", config_slot); return static_buff; } -static const char *mgn_loadcfg(menu_id id, int *offs) -{ - sprintf(static_buff, "Load cfg from profile %i", config_slot); - return static_buff; -} +static const char *men_confirm_save[] = { "OFF", "writes", "loads", "both", NULL }; +static const char h_confirm_save[] = "Ask for confirmation when overwriting save,\n" + "loading state or both"; static menu_entry e_menu_options[] = { @@ -1781,15 +1807,15 @@ static menu_entry e_menu_options[] = mee_onoff ("Show FPS", MA_OPT_SHOW_FPS, currentConfig.EmuOpt, EOPT_SHOW_FPS), mee_onoff ("Enable sound", MA_OPT_ENABLE_SOUND, currentConfig.EmuOpt, EOPT_EN_SOUND), mee_cust ("Sound Quality", MA_OPT_SOUND_QUALITY, mh_opt_misc, mgn_opt_sound), - mee_cust ("Confirm savestate", MA_OPT_CONFIRM_STATES,mh_opt_misc, mgn_opt_c_saves), + mee_enum_h ("Confirm savestate", MA_OPT_CONFIRM_STATES,currentConfig.confirm_save, men_confirm_save, h_confirm_save), mee_range (cpu_clk_name, MA_OPT_CPU_CLOCKS, currentConfig.CPUclock, 20, 900), mee_handler ("[Display options]", menu_loop_gfx_options), mee_handler ("[Sega/Mega CD options]", menu_loop_cd_options), mee_handler ("[32X options]", menu_loop_32x_options), mee_handler ("[Advanced options]", menu_loop_adv_options), - mee_handler_mkname_id(MA_OPT_SAVECFG, mh_saveloadcfg, mgn_savecfg), - mee_handler_id("Save cfg for current game only", MA_OPT_SAVECFG_GAME, mh_saveloadcfg), - mee_handler_mkname_id(MA_OPT_LOADCFG, mh_saveloadcfg, mgn_loadcfg), + mee_cust_nosave("Save global config", MA_OPT_SAVECFG, mh_saveloadcfg, mgn_saveloadcfg), + mee_cust_nosave("Save cfg for loaded game",MA_OPT_SAVECFG_GAME, mh_saveloadcfg, mgn_saveloadcfg), + mee_cust_nosave("Load cfg from profile", MA_OPT_LOADCFG, mh_saveloadcfg, mgn_saveloadcfg), mee_handler ("Restore defaults", mh_restore_defaults), mee_end, }; @@ -2040,8 +2066,8 @@ static menu_entry e_menu_main[] = mee_handler_id("Load State", MA_MAIN_LOAD_STATE, main_menu_handler), mee_handler_id("Reset game", MA_MAIN_RESET_GAME, main_menu_handler), mee_handler_id("Load new ROM/ISO", MA_MAIN_LOAD_ROM, main_menu_handler), - mee_handler_id("Change options", MA_MAIN_OPTIONS, menu_loop_options), - mee_handler_id("Configure controls", MA_MAIN_OPTIONS, menu_loop_keyconfig), + mee_handler ("Change options", menu_loop_options), + mee_handler ("Configure controls", menu_loop_keyconfig), mee_handler_id("Credits", MA_MAIN_CREDITS, main_menu_handler), mee_handler_id("Patches / GameGenie",MA_MAIN_PATCHES, main_menu_handler), mee_handler_id("Exit", MA_MAIN_EXIT, main_menu_handler), diff --git a/common/menu.h b/common/menu.h index 83cb9c2..74bf8e6 100644 --- a/common/menu.h +++ b/common/menu.h @@ -8,6 +8,7 @@ typedef enum MB_OPT_CUSTOM, /* custom value */ MB_OPT_CUSTONOFF, MB_OPT_CUSTRANGE, + MB_OPT_ENUM, } menu_behavior; typedef enum @@ -18,7 +19,6 @@ typedef enum MA_MAIN_LOAD_STATE, MA_MAIN_RESET_GAME, MA_MAIN_LOAD_ROM, - MA_MAIN_OPTIONS, MA_MAIN_CONTROLS, MA_MAIN_CREDITS, MA_MAIN_PATCHES, @@ -88,6 +88,8 @@ typedef enum MA_32XOPT_ENABLE_32X, MA_32XOPT_RENDERER, MA_32XOPT_PWM, + MA_32XOPT_MSH2_CYCLES, + MA_32XOPT_SSH2_CYCLES, MA_CTRL_PLAYER1, MA_CTRL_PLAYER2, MA_CTRL_EMU, @@ -111,40 +113,57 @@ typedef struct int selectable:1; int (*handler)(menu_id id, int keys); const char * (*generate_name)(menu_id id, int *offs); + const void *data; + const char *help; } menu_entry; #define mee_handler_id(name, id, handler) \ - { name, MB_NONE, id, NULL, 0, 0, 0, 1, 0, 1, handler, NULL } + { name, MB_NONE, id, NULL, 0, 0, 0, 1, 0, 1, handler, NULL, NULL, NULL } #define mee_handler(name, handler) \ mee_handler_id(name, MA_NONE, handler) -#define mee_handler_mkname_id(id, handler, name_func) \ - { "", MB_NONE, id, NULL, 0, 0, 0, 1, 0, 1, handler, name_func } - #define mee_label(name) \ - { name, MB_NONE, MA_NONE, NULL, 0, 0, 0, 1, 0, 0, NULL, NULL } + { name, MB_NONE, MA_NONE, NULL, 0, 0, 0, 1, 0, 0, NULL, NULL, NULL, NULL } #define mee_label_mk(id, name_func) \ - { "", MB_NONE, id, NULL, 0, 0, 0, 1, 0, 0, NULL, name_func } + { "", MB_NONE, id, NULL, 0, 0, 0, 1, 0, 0, NULL, name_func, NULL, NULL } + +#define mee_onoff_h(name, id, var, mask, help) \ + { name, MB_OPT_ONOFF, id, &(var), mask, 0, 0, 1, 1, 1, NULL, NULL, NULL, help } #define mee_onoff(name, id, var, mask) \ - { name, MB_OPT_ONOFF, id, &(var), mask, 0, 0, 1, 1, 1, NULL, NULL } + mee_onoff_h(name, id, var, mask, NULL) #define mee_range(name, id, var, min, max) \ - { name, MB_OPT_RANGE, id, &(var), 0, min, max, 1, 1, 1, NULL, NULL } + { name, MB_OPT_RANGE, id, &(var), 0, min, max, 1, 1, 1, NULL, NULL, NULL, NULL } + +#define mee_cust_s_h(name, id, need_save, handler, name_func, help) \ + { name, MB_OPT_CUSTOM, id, NULL, 0, 0, 0, 1, need_save, 1, handler, name_func, NULL, help } + +#define mee_cust_h(name, id, handler, name_func, help) \ + mee_cust_s_h(name, id, 1, handler, name_func, help) #define mee_cust(name, id, handler, name_func) \ - { name, MB_OPT_CUSTOM, id, NULL, 0, 0, 0, 1, 1, 1, handler, name_func } + mee_cust_h(name, id, handler, name_func, NULL) + +#define mee_cust_nosave(name, id, handler, name_func) \ + mee_cust_s_h(name, id, 0, handler, name_func, NULL) #define mee_onoff_cust(name, id, var, mask, name_func) \ - { name, MB_OPT_CUSTONOFF, id, &(var), mask, 0, 0, 1, 1, 1, NULL, name_func } + { name, MB_OPT_CUSTONOFF, id, &(var), mask, 0, 0, 1, 1, 1, NULL, name_func, NULL, NULL } #define mee_range_cust(name, id, var, min, max, name_func) \ - { name, MB_OPT_CUSTRANGE, id, &(var), 0, min, max, 1, 1, 1, NULL, name_func } + { name, MB_OPT_CUSTRANGE, id, &(var), 0, min, max, 1, 1, 1, NULL, name_func, NULL, NULL } + +#define mee_enum_h(name, id, var, names_list, help) \ + { name, MB_OPT_ENUM, id, &(var), 0, 0, 0, 1, 1, 1, NULL, NULL, names_list, help } + +#define mee_enum(name, id, var, names_list) \ + mee_enum_h(name, id, var, names_list, NULL) #define mee_end \ - { NULL, 0, 0, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL } + { NULL, 0, 0, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL } typedef struct { diff --git a/common/plat.h b/common/plat.h index 4f89b2c..99557da 100644 --- a/common/plat.h +++ b/common/plat.h @@ -4,8 +4,8 @@ extern "C" { /* stuff to be implemented by platform code */ extern char cpu_clk_name[]; -extern const char **renderer_names; -extern const char **renderer_names32x; +extern const char *renderer_names[]; +extern const char *renderer_names32x[]; void pemu_prep_defconfig(void); void pemu_validate_config(void); diff --git a/gp2x/emu.c b/gp2x/emu.c index ccb5e87..1f60e16 100644 --- a/gp2x/emu.c +++ b/gp2x/emu.c @@ -43,10 +43,8 @@ static short __attribute__((aligned(4))) sndBuffer[2*(44100+100)/50]; static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)]; unsigned char *PicoDraw2FB = PicoDraw2FB_; static int osd_fps_x, osd_y; -const char *renderer_names_[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL }; -const char *renderer_names32x_[] = { "accurate", "faster ", "fastest ", NULL }; -const char **renderer_names = renderer_names_; -const char **renderer_names32x = renderer_names32x_; +const char *renderer_names[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL }; +const char *renderer_names32x[] = { "accurate", "faster", "fastest", NULL }; enum renderer_types { RT_16BIT, RT_8BIT_ACC, RT_8BIT_FAST, RT_COUNT }; extern void *gp2x_screens[4]; @@ -902,7 +900,7 @@ void pemu_loop_end(void) const char *plat_get_credits(void) { - return "PicoDrive v" VERSION " (c) notaz, 2006-2009\n\n\n" + return "PicoDrive v" VERSION " (c) notaz, 2006-2010\n\n\n" "Credits:\n" "fDave: Cyclone 68000 core,\n" " base code of PicoDrive\n" diff --git a/gp2x/menu.c b/gp2x/menu.c index fb9d24a..9dbabe4 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -53,26 +53,17 @@ static void menu_main_plat_draw(void) // ------------ gfx options menu ------------ -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); + sprintf(static_buff, "%i.%02i", currentConfig.gamma / 100, currentConfig.gamma % 100); return static_buff; } +const char *men_scaling_opts[] = { "OFF", "sw horizontal", "hw horizontal", "hw horiz. + vert", NULL }; + #define MENU_OPTIONS_GFX \ - mee_range_cust("Scaling", MA_OPT_SCALING, currentConfig.scaling, 0, 3, mgn_opt_scaling), \ + mee_enum ("Scaling", MA_OPT_SCALING, currentConfig.scaling, men_scaling_opts), \ 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), \ diff --git a/linux/emu.c b/linux/emu.c index 0ef599d..08421fa 100644 --- a/linux/emu.c +++ b/linux/emu.c @@ -18,10 +18,8 @@ static short __attribute__((aligned(4))) sndBuffer[2*44100/50]; char cpu_clk_name[] = "unused"; -const char *renderer_names_[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL }; -const char *renderer_names32x_[] = { "accurate", "faster ", "fastest ", NULL }; -const char **renderer_names = renderer_names_; -const char **renderer_names32x = renderer_names32x_; +const char *renderer_names[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL }; +const char *renderer_names32x[] = { "accurate", "faster", "fastest", NULL }; enum renderer_types { RT_16BIT, RT_8BIT_ACC, RT_8BIT_FAST, RT_COUNT }; diff --git a/pandora/emu.c b/pandora/emu.c index 2bd8be8..951d85e 100644 --- a/pandora/emu.c +++ b/pandora/emu.c @@ -23,8 +23,8 @@ static short __attribute__((aligned(4))) sndBuffer[2*44100/50]; static unsigned char temp_frame[g_screen_width * g_screen_height * 2]; unsigned char *PicoDraw2FB = temp_frame; -const char **renderer_names = NULL; -const char **renderer_names32x = NULL; +const char *renderer_names[] = { NULL }; +const char *renderer_names32x[] = { NULL }; char cpu_clk_name[] = "unused"; @@ -406,7 +406,7 @@ void plat_wait_till_us(unsigned int us_to) const char *plat_get_credits(void) { - return "PicoDrive v" VERSION " (c) notaz, 2006-2009\n\n\n" + return "PicoDrive v" VERSION " (c) notaz, 2006-2010\n\n\n" "Credits:\n" "fDave: Cyclone 68000 core,\n" " base code of PicoDrive\n" diff --git a/win32/main.c b/win32/main.c index d43149c..85d153b 100644 --- a/win32/main.c +++ b/win32/main.c @@ -566,7 +566,7 @@ void xxinit(void) /* in_init() must go before config, config accesses in_ fwk */ in_init(); emu_prep_defconfig(); - emu_read_config(0, 0); + emu_read_config(NULL, 0); config_readlrom(PicoConfigFile); plat_init(); diff --git a/win32/plat.c b/win32/plat.c index 4173da3..ecf4719 100644 --- a/win32/plat.c +++ b/win32/plat.c @@ -13,8 +13,8 @@ static unsigned short screen_buff[320 * 240]; static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)]; unsigned char *PicoDraw2FB = PicoDraw2FB_; -const char **renderer_names = NULL; -const char **renderer_names32x = NULL; +const char *renderer_names[] = { NULL }; +const char *renderer_names32x[] = { NULL }; char cpu_clk_name[] = "unused"; -- 2.39.5