From 367b6f1f939dcd7930d372aee0ca900b0b8790b1 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 24 Mar 2008 23:11:47 +0000 Subject: [PATCH] bugfixes, new config system and messed code for it git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@393 be3aeb3a-fb24-0410-a615-afba39da0efa --- common/config.c | 229 +++++++++++++++++++++++++++++++++++++++++------- common/config.h | 4 +- common/emu.c | 53 ++++++----- common/emu.h | 4 +- common/menu.c | 18 ++++ common/menu.h | 13 ++- gp2x/emu.c | 5 +- gp2x/main.c | 1 + gp2x/menu.c | 59 +++++-------- psp/menu.c | 26 +----- 10 files changed, 286 insertions(+), 126 deletions(-) diff --git a/common/config.c b/common/config.c index 2f987e8..534fb40 100644 --- a/common/config.c +++ b/common/config.c @@ -24,6 +24,21 @@ static const int *cfg_opt_counts[] = { &opt_entry_count, &opt2_entry_count, &cdo #define NL "\n" +static void mystrip(char *str) +{ + int i, len; + + len = strlen(str); + for (i = 0; i < len; i++) + if (str[i] != ' ') break; + if (i > 0) memmove(str, str + i, len - i + 1); + len = strlen(str); + for (i = len - 1; i >= 0; i--) + if (str[i] != ' ') break; + str[i+1] = 0; +} + + static int seek_sect(FILE *f, const char *section) { char line[128], *tmp; @@ -126,6 +141,52 @@ static void custom_write(FILE *f, const menu_entry *me, int no_def) fprintf(f, NL); } + +static const char *joyKeyNames[32] = +{ + "UP", "DOWN", "LEFT", "RIGHT", "b1", "b2", "b3", "b4", + "b5", "b6", "b7", "b8", "b9", "b10", "b11", "b12", + "b13", "b14", "b15", "b16", "b17", "b19", "b19", "b20", + "b21", "b22", "b23", "b24", "b25", "b26", "b27", "b28" +}; + +static void keys_write(FILE *fn, const char *bind_str, const int binds[32], + const int def_binds[32], const char *names[32], int no_defaults) +{ + int t, i; + char act[48]; + + for (t = 0; t < 32; t++) + { + act[0] = act[31] = 0; + if (no_defaults && binds[t] == def_binds[t]) + continue; + if (strcmp(names[t], "???") == 0) continue; +#ifdef __GP2X__ + if (strcmp(names[t], "SELECT") == 0) continue; +#endif + for (i = 0; i < sizeof(me_ctrl_actions) / sizeof(me_ctrl_actions[0]); i++) { + if (me_ctrl_actions[i].mask & binds[t]) { + sprintf(act, "player%i ", ((binds[t]>>16)&1)+1); + strncpy(act + 8, me_ctrl_actions[i].name, 31); + break; + } + } + if (act[0] == 0) + { + for (i = 0; emuctrl_actions[i].name != NULL; i++) + if (emuctrl_actions[i].mask & binds[t]) { + strncpy(act, emuctrl_actions[i].name, 31); + break; + } + } + mystrip(act); + + fprintf(fn, "%s %s = %s" NL, bind_str, names[t], act); + } +} + + static int default_var(const menu_entry *me) { switch (me->id) @@ -137,6 +198,7 @@ static int default_var(const menu_entry *me) case MA_OPT2_ENABLE_Z80: case MA_OPT2_ENABLE_YM2612: case MA_OPT2_ENABLE_SN76496: + case MA_OPT2_SVP_DYNAREC: case MA_CDOPT_CDDA: case MA_CDOPT_PCM: case MA_CDOPT_SAVERAM: @@ -253,6 +315,14 @@ write: } } } + + // save key config + keys_write(fn, "bind", currentConfig.KeyBinds, defaultConfig.KeyBinds, keyNames, no_defaults); + keys_write(fn, "bind_joy0", currentConfig.JoyBinds[0], defaultConfig.JoyBinds[0], joyKeyNames, 1); + keys_write(fn, "bind_joy1", currentConfig.JoyBinds[1], defaultConfig.JoyBinds[1], joyKeyNames, 1); + keys_write(fn, "bind_joy2", currentConfig.JoyBinds[2], defaultConfig.JoyBinds[2], joyKeyNames, 1); + keys_write(fn, "bind_joy3", currentConfig.JoyBinds[3], defaultConfig.JoyBinds[3], joyKeyNames, 1); + fprintf(fn, NL); if (fo != NULL) @@ -274,21 +344,6 @@ write: } -static void mystrip(char *str) -{ - int i, len; - - len = strlen(str); - for (i = 0; i < len; i++) - if (str[i] != ' ') break; - if (i > 0) memmove(str, str + i, len - i + 1); - len = strlen(str); - for (i = len - 1; i >= 0; i--) - if (str[i] != ' ') break; - str[i+1] = 0; -} - - int config_writelrom(const char *fname) { char line[128], *tmp, *optr = NULL; @@ -296,7 +351,7 @@ int config_writelrom(const char *fname) int size; FILE *f; - if (strlen(currentConfig.lastRomFile) == 0) return 0; + if (strlen(lastRomFile) == 0) return 0; f = fopen(fname, "r"); if (f != NULL) @@ -329,11 +384,47 @@ int config_writelrom(const char *fname) fwrite(old_data, 1, optr - old_data, f); free(old_data); } - fprintf(f, "LastUsedROM = %s" NL, currentConfig.lastRomFile); + fprintf(f, "LastUsedROM = %s" NL, lastRomFile); fclose(f); return 0; } +/* --------------------------------------------------------------------------*/ + +int config_readlrom(const char *fname) +{ + char line[128], *tmp; + int i, len, ret = -1; + FILE *f; + + f = fopen(fname, "r"); + if (f == NULL) return -1; + + // seek to the section needed + while (!feof(f)) + { + tmp = fgets(line, sizeof(line), f); + if (tmp == NULL) break; + + if (strncasecmp(line, "LastUsedROM", 11) != 0) continue; + len = strlen(line); + for (i = 0; i < len; i++) + if (line[i] == '#' || line[i] == '\r' || line[i] == '\n') { line[i] = 0; break; } + tmp = strchr(line, '='); + if (tmp == NULL) break; + tmp++; + mystrip(tmp); + + len = sizeof(lastRomFile); + strncpy(lastRomFile, tmp, len); + lastRomFile[len-1] = 0; + ret = 0; + break; + } + fclose(f); + return ret; +} + static int custom_read(menu_entry *me, const char *var, const char *val) { @@ -432,16 +523,16 @@ static int custom_read(menu_entry *me, const char *var, const char *val) case MA_OPT_CONFIRM_STATES: if (strcasecmp(var, "Confirm savestate") != 0) return 0; if (strcasecmp(val, "OFF") == 0) { - currentConfig.EmuOpt &= 5<<9; + currentConfig.EmuOpt &= ~(5<<9); } else if (strcasecmp(val, "writes") == 0) { - currentConfig.EmuOpt &= 5<<9; - currentConfig.EmuOpt |= 1<<9; + currentConfig.EmuOpt &= ~(5<<9); + currentConfig.EmuOpt |= 1<<9; } else if (strcasecmp(val, "loads") == 0) { - currentConfig.EmuOpt &= 5<<9; - currentConfig.EmuOpt |= 4<<9; + currentConfig.EmuOpt &= ~(5<<9); + currentConfig.EmuOpt |= 4<<9; } else if (strcasecmp(val, "both") == 0) { - currentConfig.EmuOpt &= 5<<9; - currentConfig.EmuOpt |= 5<<9; + currentConfig.EmuOpt &= ~(5<<9); + currentConfig.EmuOpt |= 5<<9; } else return 0; return 1; @@ -469,23 +560,82 @@ static int custom_read(menu_entry *me, const char *var, const char *val) return 1; default: - if (strcasecmp(var, "LastUsedROM") == 0) { - tmpi = sizeof(currentConfig.lastRomFile); - strncpy(currentConfig.lastRomFile, val, tmpi); - currentConfig.lastRomFile[tmpi-1] = 0; - return 1; - } lprintf("unhandled custom_read: %i\n", me->id); return 0; } } +static void keys_parse(const char *var, const char *val, int binds[32], const char *names[32]) +{ + int t, i, keys_encountered = 0; + unsigned int player; + + for (t = 0; t < 32; t++) + { + if (strcmp(names[t], var) == 0) break; + } + if (t == 32) { + lprintf("unhandled bind \"%s\"\n", var); + return; + } + + if (!(keys_encountered & (1< 1) goto fail; + for (i = 0; i < sizeof(me_ctrl_actions) / sizeof(me_ctrl_actions[0]); i++) { + if (strncasecmp(me_ctrl_actions[i].name, val + 8, strlen(val + 8)) == 0) { + binds[t] |= me_ctrl_actions[i].mask | (player<<16); + return; + } + } + } + for (i = 0; emuctrl_actions[i].name != NULL; i++) { + if (strncasecmp(emuctrl_actions[i].name, val, strlen(val)) == 0) { + binds[t] |= emuctrl_actions[i].mask; + return; + } + } + +fail: + lprintf("unhandled action \"%s\"\n", val); + return; + +} + + +#define try_joy_parse(num) { \ + if (strncasecmp(var, "bind_joy"#num " ", 10) == 0) { \ + keys_parse(var + 10, val, currentConfig.JoyBinds[num], joyKeyNames); \ + return; \ + } \ +} + static void parse(const char *var, const char *val) { menu_entry *me; int t, i, tlen, tmp, ret = 0; + if (strcasecmp(var, "LastUsedROM") == 0) + return; /* handled elsewhere */ + + // key binds + if (strncasecmp(var, "bind ", 5) == 0) { + keys_parse(var + 5, val, currentConfig.KeyBinds, keyNames); + return; + } + try_joy_parse(0) + try_joy_parse(1) + try_joy_parse(2) + try_joy_parse(3) + for (t = 0; t < sizeof(cfg_opts) / sizeof(cfg_opts[0]) && ret == 0; t++) { me = cfg_opts[t]; @@ -515,12 +665,27 @@ static void parse(const char *var, const char *val) } +int config_havesect(const char *fname, const char *section) +{ + FILE *f; + int ret; + + f = fopen(fname, "r"); + if (f == NULL) return 0; + + ret = seek_sect(f, section); + fclose(f); + return ret; +} + + int config_readsect(const char *fname, const char *section) { char line[128], *var, *val, *tmp; - FILE *f = fopen(fname, "r"); int len, i, ret; + FILE *f; + f = fopen(fname, "r"); if (f == NULL) return 0; if (section != NULL) @@ -560,7 +725,7 @@ int config_readsect(const char *fname, const char *section) val = &line[i+1]; mystrip(var); mystrip(val); - if (strlen(var) == 0 || strlen(val) == 0) { + if (strlen(var) == 0 || (strlen(val) == 0 && strncasecmp(var, "bind", 4) != 0)) { lprintf("config_readsect: something's empty: \"%s\" = \"%s\"\n", var, val); continue; } diff --git a/common/config.h b/common/config.h index 8fab6d4..2d8a303 100644 --- a/common/config.h +++ b/common/config.h @@ -1,6 +1,6 @@ -#include - int config_writesect(const char *fname, const char *section); int config_writelrom(const char *fname); int config_readsect(const char *fname, const char *section); +int config_readlrom(const char *fname); +int config_havesect(const char *fname, const char *section); diff --git a/common/emu.c b/common/emu.c index 9d573bf..936665b 100644 --- a/common/emu.c +++ b/common/emu.c @@ -40,6 +40,7 @@ int rom_loaded = 0; char noticeMsg[64]; int state_slot = 0; int config_slot = 0, config_slot_current = 0; +char lastRomFile[512]; unsigned char *movie_data = NULL; static int movie_size = 0; @@ -139,6 +140,7 @@ int emu_findBios(int region, char **bios_file) } /* check if the name begins with BIOS name */ +/* static int emu_isBios(const char *name) { int i; @@ -150,8 +152,9 @@ static int emu_isBios(const char *name) if (strstr(name, biosfiles_jp[i]) != NULL) return 1; return 0; } +*/ -static unsigned char scd_id_header[0x100]; +static unsigned char id_header[0x100]; /* checks if romFileName points to valid MegaCD image * if so, checks for suitable BIOS */ @@ -177,7 +180,7 @@ int emu_cdCheck(int *pregion) } pm_seek(cd_f, (type == 1) ? 0x100 : 0x110, SEEK_SET); - pm_read(scd_id_header, sizeof(scd_id_header), cd_f); + pm_read(id_header, sizeof(id_header), cd_f); /* it seems we have a CD image here. Try to detect region now.. */ pm_seek(cd_f, (type == 1) ? 0x100+0x10B : 0x110+0x10B, SEEK_SET); @@ -229,21 +232,11 @@ static int extract_text(char *dest, unsigned char *src, int len, int swab) char *emu_makeRomId(void) { static char id_string[3+0x11+0x11+0x30+16]; - unsigned char *id_header; int pos; - if (Pico.rom == NULL) { - id_string[0] = 0; - return id_string; - } - - if (PicoMCD & 1) { - id_header = scd_id_header; - strcpy(id_string, "CD|"); - } else { - id_header = Pico.rom + 0x100; - strcpy(id_string, "MD|"); - } + if (PicoMCD & 1) + strcpy(id_string, "CD|"); + else strcpy(id_string, "MD|"); pos = 3; pos += extract_text(id_string + pos, id_header + 0x80, 0x0e, 1); // serial @@ -253,7 +246,6 @@ char *emu_makeRomId(void) pos += extract_text(id_string + pos, id_header + 0x50, 0x30, 1); // overseas name id_string[pos] = 0; - printf("id_string: %s\n", id_string); return id_string; } @@ -391,6 +383,8 @@ int emu_ReloadRom(void) } // load config for this ROM (do this before insert to get correct region) + if (!(PicoMCD&1)) + memcpy(id_header, rom_data + 0x100, sizeof(id_header)); if (!cfg_loaded) { ret = emu_ReadConfig(1, 1); if (!ret) emu_ReadConfig(0, 1); @@ -418,13 +412,6 @@ int emu_ReloadRom(void) menu_romload_end(); - if (!emu_isBios(romFileName)) - { - // emu_ReadConfig() might have messed currentConfig.lastRomFile - strncpy(currentConfig.lastRomFile, romFileName, sizeof(currentConfig.lastRomFile)-1); - currentConfig.lastRomFile[sizeof(currentConfig.lastRomFile)-1] = 0; - } - if (PicoPatches) { PicoPatchPrepare(); PicoPatchApply(); @@ -463,6 +450,8 @@ int emu_ReloadRom(void) if (currentConfig.EmuOpt & 1) emu_SaveLoadGame(1, 1); + strncpy(lastRomFile, romFileName, sizeof(lastRomFile)-1); + lastRomFile[sizeof(lastRomFile)-1] = 0; rom_loaded = 1; return 1; } @@ -509,14 +498,18 @@ int emu_ReadConfig(int game, int no_defaults) } else { - if (!no_defaults) - emu_setDefaultConfig(); + char *sect = emu_makeRomId(); // try new .cfg way if (config_slot != 0) sprintf(cfg, "game.%i.cfg", config_slot); else strcpy(cfg, "game.cfg"); - ret = config_readsect(cfg, emu_makeRomId()); + + ret = -1; + if (config_havesect(cfg, sect)) { + emu_setDefaultConfig(); + ret = config_readsect(cfg, sect); + } if (ret != 0) { @@ -532,7 +525,9 @@ int emu_ReadConfig(int game, int no_defaults) f = fopen(cfg, "rb"); } if (f) { - int bread = fread(¤tConfig, 1, sizeof(currentConfig), f); + int bread; + fseek(f, 512, SEEK_SET); // skip unused lrom buffer + bread = fread(¤tConfig, 1, sizeof(currentConfig), f); lprintf("emu_ReadConfig: %s %s\n", cfg, bread > 0 ? "(ok)" : "(failed)"); fclose(f); ret = 0; @@ -548,7 +543,7 @@ int emu_ReadConfig(int game, int no_defaults) } else { - lprintf("loaded cf from game sect\n"); + lprintf("loaded cfg from sect \"%s\"\n", sect); } } @@ -593,10 +588,12 @@ int emu_WriteConfig(int is_game) sprintf(cfg, "game.%i.cfg", config_slot); else strcpy(cfg, "game.cfg"); game_sect = emu_makeRomId(); + lprintf("emu_WriteConfig: sect \"%s\"\n", game_sect); } lprintf("emu_WriteConfig: %s ", cfg); ret = config_writesect(cfg, game_sect); + if (write_lrom) config_writelrom(cfg); #ifndef NO_SYNC sync(); #endif diff --git a/common/emu.h b/common/emu.h index 484080a..93a8823 100644 --- a/common/emu.h +++ b/common/emu.h @@ -4,7 +4,7 @@ // For commercial use, separate licencing terms must be obtained. typedef struct { - char lastRomFile[512]; + // char lastRomFile[512]; int EmuOpt; // LSb->MSb: use_sram, show_fps, enable_sound, gzip_saves, // squidgehack, no_save_cfg_on_exit, , 16_bit_mode // craigix_ram, confirm_save, show_cd_leds, confirm_load @@ -33,6 +33,7 @@ extern char noticeMsg[64]; extern int state_slot; extern int config_slot, config_slot_current; extern unsigned char *movie_data; +extern char lastRomFile[512]; int emu_ReloadRom(void); @@ -49,4 +50,5 @@ void emu_textOut8 (int x, int y, const char *text); void emu_textOut16(int x, int y, const char *text); char *emu_makeRomId(void); +extern const char *keyNames[]; void emu_prepareDefaultConfig(void); diff --git a/common/menu.c b/common/menu.c index 16d4342..359517a 100644 --- a/common/menu.c +++ b/common/menu.c @@ -30,6 +30,24 @@ char menuErrorMsg[64] = { 0, }; +// PicoPad[] format: MXYZ SACB RLDU +me_bind_action me_ctrl_actions[12] = +{ + { "UP ", 0x001 }, + { "DOWN ", 0x002 }, + { "LEFT ", 0x004 }, + { "RIGHT ", 0x008 }, + { "A ", 0x040 }, + { "B ", 0x010 }, + { "C ", 0x020 }, + { "START ", 0x080 }, + { "MODE ", 0x800 }, + { "X ", 0x400 }, + { "Y ", 0x200 }, + { "Z ", 0x100 } +}; + + static unsigned char menu_font_data[10240]; static int menu_text_color = 0xffff; // default to white static int menu_sel_color = -1; // disabled diff --git a/common/menu.h b/common/menu.h index 0b5aac3..1a4ded2 100644 --- a/common/menu.h +++ b/common/menu.h @@ -1,4 +1,4 @@ -// (c) Copyright 2006,2007 notaz, All rights reserved. +// (c) Copyright 2006-2008 notaz, All rights reserved. void menu_init(void); @@ -9,7 +9,6 @@ void menu_draw_selection(int x, int y, int w); extern char menuErrorMsg[64]; - typedef enum { MB_NONE = 1, /* no auto processing */ @@ -65,6 +64,7 @@ typedef enum MA_OPT2_SQUIDGEHACK, /* gp2x */ MA_OPT2_STATUS_LINE, /* psp */ MA_OPT2_NO_FRAME_LIMIT, /* psp */ + MA_OPT2_SVP_DYNAREC, MA_OPT2_DONE, MA_OPT3_SCALE, /* psp (all OPT3) */ MA_OPT3_HSCALE32, @@ -102,6 +102,15 @@ typedef struct char need_to_save; } menu_entry; +typedef struct +{ + char *name; + int mask; +} me_bind_action; + +extern me_bind_action me_ctrl_actions[12]; +extern me_bind_action emuctrl_actions[]; // platform code + typedef void (me_draw_custom_f)(const menu_entry *entry, int x, int y, void *param); diff --git a/gp2x/emu.c b/gp2x/emu.c index bd4253d..74bcde8 100644 --- a/gp2x/emu.c +++ b/gp2x/emu.c @@ -179,9 +179,8 @@ void emu_Deinit(void) void emu_prepareDefaultConfig(void) { memset(&defaultConfig, 0, sizeof(defaultConfig)); - defaultConfig.lastRomFile[0] = 0; - defaultConfig.EmuOpt = 0x1f | 0x600; // | confirm_save, cd_leds - defaultConfig.s_PicoOpt = 0x0f | 0xe00; // | use_940, cd_pcm, cd_cdda + defaultConfig.EmuOpt = 0x1d | 0x00700; // | <- ram_tmng, confirm_save, cd_leds + defaultConfig.s_PicoOpt = 0x0f | 0x20e00; // | <- use_940, cd_pcm, cd_cdda, svp drc defaultConfig.s_PsndRate = 44100; defaultConfig.s_PicoRegion = 0; // auto defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP diff --git a/gp2x/main.c b/gp2x/main.c index 3728685..f016411 100644 --- a/gp2x/main.c +++ b/gp2x/main.c @@ -84,6 +84,7 @@ int main(int argc, char *argv[]) emu_prepareDefaultConfig(); emu_ReadConfig(0, 0); + config_readlrom(PicoConfigFile); gp2x_init(); if (currentConfig.EmuOpt&0x10) { diff --git a/gp2x/menu.c b/gp2x/menu.c index b3c1d75..06abac6 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -30,7 +30,7 @@ extern int mmuhack_status; -static const char *gp2xKeyNames[] = { +const char *keyNames[] = { "UP", "???", "LEFT", "???", "DOWN", "???", "RIGHT", "???", "START", "SELECT", "L", "R", "A", "B", "X", "Y", "???", "???", "???", "???", "???", "???", "VOL DOWN", "VOL UP", @@ -121,6 +121,10 @@ static unsigned long wait_for_input_usbjoy(unsigned long interesting, int *joy) inp_prev = ret; inp_prevjoy = *joy; + // handle only 1 event at a time + for (i = 1; i != 0; i <<= 1) + if (ret & i) { ret &= i; break; } + return ret; } @@ -614,8 +618,8 @@ static char *action_binds(int player_idx, int action_mask) if (currentConfig.KeyBinds[i] & action_mask) { if (player_idx >= 0 && ((currentConfig.KeyBinds[i] >> 16) & 3) != player_idx) continue; - if (strkeys[0]) { strcat(strkeys, " + "); strcat(strkeys, gp2xKeyNames[i]); break; } - else strcpy(strkeys, gp2xKeyNames[i]); + if (strkeys[0]) { strcat(strkeys, " + "); strcat(strkeys, keyNames[i]); break; } + else strcpy(strkeys, keyNames[i]); } } for (joy = 0; joy < num_of_joys; joy++) @@ -689,9 +693,7 @@ static int count_bound_keys(int action, int pl_idx, int joy) return keys; } -typedef struct { char *name; int mask; } bind_action_t; - -static void draw_key_config(const bind_action_t *opts, int opt_cnt, int player_idx, int sel) +static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx, int sel) { int x, y, tl_y = 40, i; @@ -725,7 +727,7 @@ static void draw_key_config(const bind_action_t *opts, int opt_cnt, int player_i menu_flip(); } -static void key_config_loop(const bind_action_t *opts, int opt_cnt, int player_idx) +static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_idx) { int joy = 0, sel = 0, menu_sel_max = opt_cnt, prev_select = 0, i; unsigned long inp = 0; @@ -768,12 +770,12 @@ static void key_config_loop(const bind_action_t *opts, int opt_cnt, int player_i if (inp & (1 << i)) { int *bind = ¤tConfig.JoyBinds[joy-1][i]; if ((*bind & opts[sel].mask) && (player_idx < 0 || player_idx == ((*bind>>16)&3))) - currentConfig.JoyBinds[joy-1][i] &= ~opts[sel].mask; + *bind &= ~opts[sel].mask; else { // override unbind_action(opts[sel].mask, player_idx, joy); *bind = opts[sel].mask; - if (player_idx >= 0) *bind |= player_idx << 16; + if (player_idx > 0) *bind |= player_idx << 16; } } } @@ -809,27 +811,10 @@ static void draw_kc_sel(int menu_sel) } -// PicoPad[] format: MXYZ SACB RLDU -static bind_action_t ctrl_actions[] = -{ - { "UP ", 0x001 }, - { "DOWN ", 0x002 }, - { "LEFT ", 0x004 }, - { "RIGHT ", 0x008 }, - { "A ", 0x040 }, - { "B ", 0x010 }, - { "C ", 0x020 }, - { "START ", 0x080 }, - { "MODE ", 0x800 }, - { "X ", 0x400 }, - { "Y ", 0x200 }, - { "Z ", 0x100 }, -}; - // player2_flag, ?, ?, ?, ?, ?, ?, menu // "NEXT SAVE SLOT", "PREV SAVE SLOT", "SWITCH RENDERER", "SAVE STATE", // "LOAD STATE", "VOLUME UP", "VOLUME DOWN", "DONE" -static bind_action_t emuctrl_actions[] = +me_bind_action emuctrl_actions[] = { { "Load State ", 1<<28 }, { "Save State ", 1<<27 }, @@ -840,6 +825,7 @@ static bind_action_t emuctrl_actions[] = { "Volume Up ", 1<<29 }, { "Fast forward ", 1<<22 }, { "Enter Menu ", 1<<23 }, + { NULL, 0 } }; static void kc_sel_loop(void) @@ -856,8 +842,8 @@ static void kc_sel_loop(void) if (inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & GP2X_B) { switch (menu_sel) { - case 0: key_config_loop(ctrl_actions, is_6button ? 12 : 8, 0); return; - case 1: key_config_loop(ctrl_actions, is_6button ? 12 : 8, 1); return; + case 0: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 0); return; + case 1: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 1); return; case 2: key_config_loop(emuctrl_actions, sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]), -1); return; case 3: if (!rom_loaded) emu_WriteConfig(0); return; @@ -1027,14 +1013,15 @@ menu_entry opt2_entries[] = { NULL, MB_NONE, MA_OPT2_GAMMA, NULL, 0, 0, 0, 1, 1 }, { "A_SN's gamma curve", MB_ONOFF, MA_OPT2_A_SN_GAMMA, ¤tConfig.EmuOpt, 0x1000, 0, 0, 1, 1 }, { "Perfect vsync", MB_ONOFF, MA_OPT2_VSYNC, ¤tConfig.EmuOpt, 0x2000, 0, 0, 1, 1 }, - { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, &PicoOpt, 0x0004, 0, 0, 1, 1 }, - { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, &PicoOpt, 0x0001, 0, 0, 1, 1 }, - { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,&PicoOpt, 0x0002, 0, 0, 1, 1 }, + { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, &PicoOpt, 0x00004, 0, 0, 1, 1 }, + { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, &PicoOpt, 0x00001, 0, 0, 1, 1 }, + { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,&PicoOpt, 0x00002, 0, 0, 1, 1 }, { "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, ¤tConfig.EmuOpt, 0x0008, 0, 0, 1, 1 }, { "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, ¤tConfig.EmuOpt, 0x0020, 0, 0, 1, 1 }, { "needs restart:", MB_NONE, MA_NONE, NULL, 0, 0, 0, 1, 0 }, { "craigix's RAM timings", MB_ONOFF, MA_OPT2_RAMTIMINGS, ¤tConfig.EmuOpt, 0x0100, 0, 0, 1, 1 }, { NULL, MB_ONOFF, MA_OPT2_SQUIDGEHACK, ¤tConfig.EmuOpt, 0x0010, 0, 0, 1, 1 }, + { "SVP dynarec", MB_ONOFF, MA_OPT2_SVP_DYNAREC, &PicoOpt, 0x20000, 0, 0, 1, 1 }, { "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1, 0 }, }; @@ -1522,10 +1509,10 @@ static void menu_loop_root(void) { char curr_path[PATH_MAX], *selfname; FILE *tstf; - if ( (tstf = fopen(currentConfig.lastRomFile, "rb")) ) + if ( (tstf = fopen(lastRomFile, "rb")) ) { fclose(tstf); - strcpy(curr_path, currentConfig.lastRomFile); + strcpy(curr_path, lastRomFile); } else getcwd(curr_path, PATH_MAX); @@ -1665,10 +1652,10 @@ int menu_loop_tray(void) gp2x_memset_all_buffers(0, 0, 320*240*2); menu_gfx_prepare(); - if ( (tstf = fopen(currentConfig.lastRomFile, "rb")) ) + if ( (tstf = fopen(lastRomFile, "rb")) ) { fclose(tstf); - strcpy(curr_path, currentConfig.lastRomFile); + strcpy(curr_path, lastRomFile); } else { diff --git a/psp/menu.c b/psp/menu.c index 15c01c9..b5f3203 100644 --- a/psp/menu.c +++ b/psp/menu.c @@ -699,8 +699,6 @@ static int count_bound_keys(int action, int pl_idx) return keys; } -typedef struct { char *name; int mask; } bind_action_t; - static void draw_key_config(const bind_action_t *opts, int opt_cnt, int player_idx, int sel) { int x, y, tl_y = 16+40, i; @@ -789,33 +787,17 @@ static void draw_kc_sel(int menu_sel) } -// PicoPad[] format: MXYZ SACB RLDU -static bind_action_t ctrl_actions[] = -{ - { "UP ", 0x001 }, - { "DOWN ", 0x002 }, - { "LEFT ", 0x004 }, - { "RIGHT ", 0x008 }, - { "A ", 0x040 }, - { "B ", 0x010 }, - { "C ", 0x020 }, - { "START ", 0x080 }, - { "MODE ", 0x800 }, - { "X ", 0x400 }, - { "Y ", 0x200 }, - { "Z ", 0x100 }, -}; - // player2_flag, ?, ?, ?, ?, ?, ?, menu // "NEXT SAVE SLOT", "PREV SAVE SLOT", "SWITCH RENDERER", "SAVE STATE", // "LOAD STATE", "VOLUME UP", "VOLUME DOWN", "DONE" -static bind_action_t emuctrl_actions[] = +me_bind_action emuctrl_actions[] = { { "Load State ", 1<<28 }, { "Save State ", 1<<27 }, { "Prev Save Slot ", 1<<25 }, { "Next Save Slot ", 1<<24 }, { "Switch Renderer", 1<<26 }, + { NULL, 0 } }; static void kc_sel_loop(void) @@ -832,8 +814,8 @@ static void kc_sel_loop(void) if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & BTN_CIRCLE) { switch (menu_sel) { - case 0: key_config_loop(ctrl_actions, is_6button ? 12 : 8, 0); return; - case 1: key_config_loop(ctrl_actions, is_6button ? 12 : 8, 1); return; + case 0: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 0); return; + case 1: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 1); return; case 2: key_config_loop(emuctrl_actions, sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]), -1); return; case 3: if (!rom_loaded) emu_WriteConfig(0); return; -- 2.39.2