#define dbg(...)
#endif
-#if (DRC_DEBUG & 2)
+#if (DRC_DEBUG & 4)
static u8 *tcache_dsm_ptrs[3];
static char sh2dasm_buff[64];
#define do_host_disasm(tcid) \
#define do_host_disasm(x)
#endif
-#if (DRC_DEBUG & 4) || defined(PDB)
+#if (DRC_DEBUG & 8) || defined(PDB)
static void REGPARM(3) *sh2_drc_log_entry(void *block, SH2 *sh2, u32 sr)
{
if (block != NULL) {
- dbg(4, "= %csh2 enter %08x %p, c=%d", sh2->is_slave ? 's' : 'm',
+ dbg(8, "= %csh2 enter %08x %p, c=%d", sh2->is_slave ? 's' : 'm',
sh2->pc, block, (signed int)sr >> 12);
pdb_step(sh2, sh2->pc);
}
u32 addr; // SH2 PC address
void *tcache_ptr; // translated block for above PC
struct block_desc_ *next; // next block with the same PC hash
-#if (DRC_DEBUG & 1)
+#if (DRC_DEBUG & 2)
int refcount;
#endif
} block_desc;
}
else
memset(Pico32xMem->drcblk_da[tcid - 1], 0, sizeof(Pico32xMem->drcblk_da[0]));
-#if (DRC_DEBUG & 2)
+#if (DRC_DEBUG & 4)
tcache_dsm_ptrs[tcid] = tcache_bases[tcid];
#endif
}
int cnt = block_link_counts[tcache_id];
if (cnt >= block_max_counts[tcache_id] * 2) {
- printf("bl overflow for tcache %d\n", tcache_id);
+ dbg(1, "bl overflow for tcache %d\n", tcache_id);
return -1;
}
bd = dr_get_bd(addr, is_slave, &tcache_id);
if (bd != NULL) {
- dbg(1, "block override for %08x", addr);
+ dbg(2, "block override for %08x", addr);
bd->tcache_ptr = tcache_ptr;
*blk_id = bd - block_tables[tcache_id];
return bd;
bcount = &block_counts[tcache_id];
if (*bcount >= block_max_counts[tcache_id]) {
- printf("bd overflow for tcache %d\n", tcache_id);
+ dbg(1, "bd overflow for tcache %d", tcache_id);
return NULL;
}
if (*bcount == 0)
if ((addr & 0xc6000000) == 0x02000000) { // ROM
bd->next = HASH_FUNC(hash_table, addr);
HASH_FUNC(hash_table, addr) = bd;
-#if (DRC_DEBUG & 1)
+#if (DRC_DEBUG & 2)
if (bd->next != NULL) {
printf(" hash collision with %08x\n", bd->next->addr);
hash_collisions++;
if (bd != NULL)
block = bd->tcache_ptr;
-#if (DRC_DEBUG & 1)
+#if (DRC_DEBUG & 2)
if (bd != NULL)
bd->refcount++;
#endif
for (i = 0; i < cnt; i++) {
if (bl[i].target_pc == pc) {
- dbg(1, "- link from %p", bl[i].jump);
+ dbg(2, "- link from %p", bl[i].jump);
emith_jump_patch(bl[i].jump, target);
// XXX: sync ARM caches (old jump should be fine)?
}
#define ADD_TO_ARRAY(array, count, item, failcode) \
array[count++] = item; \
if (count >= ARRAY_SIZE(array)) { \
- printf("warning: " #array " overflow\n"); \
+ dbg(1, "warning: " #array " overflow"); \
failcode; \
}
host_arg2reg(arg1, 1);
host_arg2reg(arg2, 2);
-#if (DRC_DEBUG & 4) || defined(PDB)
+#if (DRC_DEBUG & 8) || defined(PDB)
emit_do_static_regs(1, arg2);
emith_move_r_r(arg1, CONTEXT_REG);
emith_move_r_r(arg2, rcache_get_reg(SHR_SR, RC_GR_READ));
// predict tcache overflow
tmp = tcache_ptr - tcache_bases[tcache_id];
if (tmp > tcache_sizes[tcache_id] - MAX_BLOCK_SIZE) {
- printf("tcache %d overflow\n", tcache_id);
+ dbg(1, "tcache %d overflow", tcache_id);
return NULL;
}
block_entry = tcache_ptr;
- dbg(1, "== %csh2 block #%d,%d %08x -> %p", sh2->is_slave ? 's' : 'm',
+ dbg(2, "== %csh2 block #%d,%d %08x -> %p", sh2->is_slave ? 's' : 'm',
tcache_id, blkid_main, base_pc, block_entry);
dr_link_blocks(tcache_ptr, base_pc, tcache_id);
rcache_flush();
do_host_disasm(tcache_id);
- dbg(1, "-- %csh2 subblock #%d,%d %08x -> %p", sh2->is_slave ? 's' : 'm',
+ dbg(2, "-- %csh2 subblock #%d,%d %08x -> %p", sh2->is_slave ? 's' : 'm',
tcache_id, branch_target_blkid[i], pc, tcache_ptr);
subblock = dr_add_block(pc, sh2->is_slave, &branch_target_blkid[i]);
rcache_unlock_all();
}
-#if (DRC_DEBUG & 3)
- insns_compiled++;
#if (DRC_DEBUG & 2)
+ insns_compiled++;
+#if (DRC_DEBUG & 4)
DasmSH2(sh2dasm_buff, pc, op);
printf("%08x %04x %s\n", pc, op, sh2dasm_buff);
#endif
branch_patch_count++;
if (branch_patch_count == MAX_LOCAL_BRANCHES) {
- printf("warning: too many local branches\n");
+ dbg(1, "warning: too many local branches");
break;
}
}
t = find_in_array(branch_target_pc, branch_target_count, branch_patch_pc[i]);
target = branch_target_ptr[t];
if (target == NULL) {
- // flush pc and go back to dispatcher (should no longer happen)
- printf("stray branch to %08x %p\n", branch_patch_pc[i], tcache_ptr);
+ // flush pc and go back to dispatcher (this should no longer happen)
+ dbg(1, "stray branch to %08x %p", branch_patch_pc[i], tcache_ptr);
target = tcache_ptr;
emit_move_r_imm32(SHR_PC, branch_patch_pc[i]);
rcache_flush();
// mark literals
for (i = 0; i < literal_addr_count; i++) {
tmp = literal_addr[i];
- //printf("marking literal %08x\n", tmp);
drc_ram_blk[(tmp >> shift) & mask] = blkid_main << 1;
if (!(tmp & 3)) // assume long
drc_ram_blk[((tmp + 2) >> shift) & mask] = blkid_main << 1;
host_instructions_updated(block_entry, tcache_ptr);
do_host_disasm(tcache_id);
- dbg(1, " block #%d,%d tcache %d/%d, insns %d -> %d %.3f",
+ dbg(2, " block #%d,%d tcache %d/%d, insns %d -> %d %.3f",
tcache_id, block_counts[tcache_id],
tcache_ptr - tcache_bases[tcache_id], tcache_sizes[tcache_id],
insns_compiled, host_insn_count, (double)host_insn_count / insns_compiled);
if ((sh2->pc & 0xc6000000) == 0x02000000) // ROM
- dbg(1, " hash collisions %d/%d", hash_collisions, block_counts[tcache_id]);
+ dbg(2, " hash collisions %d/%d", hash_collisions, block_counts[tcache_id]);
/*
printf("~~~\n");
tcache_dsm_ptrs[tcache_id] = block_entry;
printf("~~~\n");
*/
-#if (DRC_DEBUG & 2)
+#if (DRC_DEBUG & 4)
fflush(stdout);
#endif
MAKE_WRITE_WRAPPER(sh2_drc_write16);
MAKE_WRITE_WRAPPER(sh2_drc_write16_slot);
MAKE_WRITE_WRAPPER(sh2_drc_write32);
-#if (DRC_DEBUG & 2)
+#if (DRC_DEBUG & 4)
host_dasm_new_symbol(sh2_drc_read8);
host_dasm_new_symbol(sh2_drc_read16);
host_dasm_new_symbol(sh2_drc_read32);
#endif
rcache_invalidate();
-#if (DRC_DEBUG & 2)
+#if (DRC_DEBUG & 4)
host_dasm_new_symbol(sh2_drc_entry);
host_dasm_new_symbol(sh2_drc_dispatcher);
host_dasm_new_symbol(sh2_drc_exit);
void *tmp;
// XXX: kill links somehow?
- dbg(1, " killing entry %08x, blkid %d", bd->addr, bd - block_tables[tcache_id]);
+ dbg(2, " killing entry %08x, blkid %d", bd->addr, bd - block_tables[tcache_id]);
if (bd->addr == 0 || bd->tcache_ptr == NULL) {
- printf(" killing dead block!? %08x\n", bd->addr);
+ dbg(1, " killing dead block!? %08x", bd->addr);
return bd->tcache_ptr;
}
break;
if (!(*p & 1)) {
- printf("smc rm: missing block start for %08x?\n", a);
+ dbg(1, "smc rm: missing block start for %08x?", a);
p = pt;
}
void sh2_drc_wcheck_ram(unsigned int a, int val, int cpuid)
{
- dbg(1, "%csh2 smc check @%08x", cpuid ? 's' : 'm', a);
+ dbg(2, "%csh2 smc check @%08x", cpuid ? 's' : 'm', a);
sh2_smc_rm_block(a, Pico32xMem->drcblk_ram, 0, SH2_DRCBLK_RAM_SHIFT, 0x3ffff);
}
void sh2_drc_wcheck_da(unsigned int a, int val, int cpuid)
{
- dbg(1, "%csh2 smc check @%08x", cpuid ? 's' : 'm', a);
+ dbg(2, "%csh2 smc check @%08x", cpuid ? 's' : 'm', a);
sh2_smc_rm_block(a, Pico32xMem->drcblk_da[cpuid],
1 + cpuid, SH2_DRCBLK_DA_SHIFT, 0xfff);
}
// TODO: irq cycles
ret_cycles = (signed int)sh2c->sr >> 12;
if (ret_cycles > 0)
- printf("warning: drc returned with cycles: %d\n", ret_cycles);
+ dbg(1, "warning: drc returned with cycles: %d", ret_cycles);
sh2c->cycles_done += cycles - ret_cycles;
}
-#if (DRC_DEBUG & 1)
+#if (DRC_DEBUG & 2)
void block_stats(void)
{
int c, b, i, total = 0;
// tmp
PicoOpt |= POPT_DIS_VDP_FIFO;
-#if (DRC_DEBUG & 2)
+#if (DRC_DEBUG & 4)
for (i = 0; i < ARRAY_SIZE(block_tables); i++)
tcache_dsm_ptrs[i] = tcache_bases[i];
// disasm the utils
block_stats();
for (i = 0; i < TCACHE_BUFFERS; i++) {
-#if (DRC_DEBUG & 2)
+#if (DRC_DEBUG & 4)
printf("~~~ tcache %d\n", i);
tcache_dsm_ptrs[i] = tcache_bases[i];
tcache_ptr = tcache_ptrs[i];
struct Pico32x Pico32x;
SH2 sh2s[2];
+int p32x_msh2_multiplier = MSH2_MULTI_DEFAULT;
+int p32x_ssh2_multiplier = SSH2_MULTI_DEFAULT;
+
static int REGPARM(2) sh2_irq_cb(SH2 *sh2, int level)
{
if (sh2->pending_irl > sh2->pending_int_irq) {
{
pprof_start(m68k);
+p32x_poll_event(3, 0);
#if defined(EMU_C68K)
PicoCpuCM68k.cycles = cyc;
CycloneRun(&PicoCpuCM68k);
// ~1463.8, but due to cache misses and slow mem
// it's much lower than that
//#define SH2_LINE_CYCLES 735
-#define CYCLES_M68K2SH2(x) ((x) * 6 / 4)
+#define CYCLES_M68K2MSH2(x) (((x) * p32x_msh2_multiplier) >> 10)
+#define CYCLES_M68K2SSH2(x) (((x) * p32x_ssh2_multiplier) >> 10)
#define PICO_32X
#define CPUS_RUN_SIMPLE(m68k_cycles,s68k_cycles) \
elprintf(EL_32X, "slice %d", slice); \
if (!(Pico32x.emu_flags & (P32XF_SSH2POLL|P32XF_SSH2VPOLL))) { \
pprof_start(ssh2); \
- sh2_execute(&ssh2, CYCLES_M68K2SH2(slice)); \
+ sh2_execute(&ssh2, CYCLES_M68K2SSH2(slice)); \
pprof_end(ssh2); \
} \
if (!(Pico32x.emu_flags & (P32XF_MSH2POLL|P32XF_MSH2VPOLL))) { \
pprof_start(msh2); \
- sh2_execute(&msh2, CYCLES_M68K2SH2(slice)); \
+ sh2_execute(&msh2, CYCLES_M68K2MSH2(slice)); \
pprof_end(msh2); \
} \
pprof_start(dummy); \
extern unsigned short *PicoCramHigh; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)\r
extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to use\r
\r
+// 32x/32x.c\r
+// multipliers against 68k clock\r
+extern int p32x_msh2_multiplier;\r
+extern int p32x_ssh2_multiplier;\r
+#define SH2_MULTI_SHIFT 10\r
+#define MSH2_MULTI_DEFAULT ((1 << SH2_MULTI_SHIFT) * 3 / 2)\r
+#define SSH2_MULTI_DEFAULT ((1 << SH2_MULTI_SHIFT) * 3 / 2)\r
+\r
// 32x/draw.c\r
void PicoDraw32xSetFrameMode(int is_on, int only_32x);\r
extern int (*PicoScan32xBegin)(unsigned int num);\r
}
-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];
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:
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;
}
}
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;
}
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 */
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)
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;
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;
return 1;
default:
- lprintf("unhandled custom_read: %i\n", me->id);
+ lprintf("unhandled custom_read %i: %s\n", me->id, var);
return 0;
}
}
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 */
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);
}
strlwr_(ext);\r
}\r
\r
+static void fname_ext(char *dst, int dstlen, const char *prefix, const char *ext, const char *fname)\r
+{\r
+ int prefix_len = 0;\r
+ const char *p;\r
+\r
+ *dst = 0;\r
+ if (prefix) {\r
+ int len = plat_get_root_dir(dst, dstlen);\r
+ strcpy(dst + len, prefix);\r
+ prefix_len = len + strlen(prefix);\r
+ }\r
+\r
+ p = fname + strlen(fname) - 1;\r
+ for (; p >= fname && *p != PATH_SEP_C; p--)\r
+ ;\r
+ p++;\r
+ strncpy(dst + prefix_len, p, dstlen - prefix_len - 1);\r
+\r
+ dst[dstlen - 8] = 0;\r
+ if (dst[strlen(dst) - 4] == '.')\r
+ dst[strlen(dst) - 4] = 0;\r
+ if (ext)\r
+ strcat(dst, ext);\r
+}\r
+\r
+static void romfname_ext(char *dst, int dstlen, const char *prefix, const char *ext)\r
+{\r
+ fname_ext(dst, dstlen, prefix, ext, rom_fname_loaded);\r
+}\r
+\r
void emu_status_msg(const char *format, ...)\r
{\r
va_list vl;\r
return p - dest;\r
}\r
\r
-static char *emu_make_rom_id(void)\r
+static char *emu_make_rom_id(const char *fname)\r
{\r
static char id_string[3+0xe*3+0x3*3+0x30*3+3];\r
int pos, swab = 1;\r
strcpy(id_string, "CD|");\r
swab = 0;\r
}\r
- else strcpy(id_string, "MD|");\r
+ else if (PicoAHW & PAHW_SMS)\r
+ strcpy(id_string, "MS|");\r
+ else strcpy(id_string, "MD|");\r
pos = 3;\r
\r
- pos += extract_text(id_string + pos, id_header + 0x80, 0x0e, swab); // serial\r
- id_string[pos] = '|'; pos++;\r
- pos += extract_text(id_string + pos, id_header + 0xf0, 0x03, swab); // region\r
- id_string[pos] = '|'; pos++;\r
- pos += extract_text(id_string + pos, id_header + 0x50, 0x30, swab); // overseas name\r
- id_string[pos] = 0;\r
+ if (!(PicoAHW & PAHW_SMS)) {\r
+ pos += extract_text(id_string + pos, id_header + 0x80, 0x0e, swab); // serial\r
+ id_string[pos] = '|'; pos++;\r
+ pos += extract_text(id_string + pos, id_header + 0xf0, 0x03, swab); // region\r
+ id_string[pos] = '|'; pos++;\r
+ pos += extract_text(id_string + pos, id_header + 0x50, 0x30, swab); // overseas name\r
+ id_string[pos] = 0;\r
+ if (pos > 5)\r
+ return id_string;\r
+ pos = 3;\r
+ }\r
+\r
+ // can't find name in ROM, use filename\r
+ fname_ext(id_string + 3, sizeof(id_string) - 3, NULL, NULL, fname);\r
\r
return id_string;\r
}\r
// valid CD image, check for BIOS..\r
\r
// we need to have config loaded at this point\r
- ret = emu_read_config(1, 0);\r
- if (!ret) emu_read_config(0, 0);\r
+ ret = emu_read_config(rom_fname, 0);\r
+ if (!ret) emu_read_config(NULL, 0);\r
cfg_loaded = 1;\r
\r
if (PicoRegionOverride) {\r
if (!(PicoAHW & PAHW_MCD))\r
memcpy(id_header, rom_data + 0x100, sizeof(id_header));\r
if (!cfg_loaded) {\r
- ret = emu_read_config(1, 0);\r
- if (!ret) emu_read_config(0, 0);\r
+ ret = emu_read_config(rom_fname, 0);\r
+ if (!ret) emu_read_config(NULL, 0);\r
}\r
\r
emu_make_path(static_buff, "carthw.cfg", sizeof(static_buff));\r
return 1;\r
}\r
\r
-static void romfname_ext(char *dst, const char *prefix, const char *ext)\r
-{\r
- char *p;\r
- int prefix_len = 0;\r
-\r
- // make save filename\r
- p = rom_fname_loaded + strlen(rom_fname_loaded) - 1;\r
- for (; p >= rom_fname_loaded && *p != PATH_SEP_C; p--); p++;\r
- *dst = 0;\r
- if (prefix) {\r
- int len = plat_get_root_dir(dst, 512);\r
- strcpy(dst + len, prefix);\r
- prefix_len = len + strlen(prefix);\r
- }\r
-#ifdef UIQ3\r
- else p = rom_fname_loaded; // backward compatibility\r
-#endif\r
- strncpy(dst + prefix_len, p, 511-prefix_len);\r
- dst[511-8] = 0;\r
- if (dst[strlen(dst)-4] == '.') dst[strlen(dst)-4] = 0;\r
- if (ext) strcat(dst, ext);\r
-}\r
-\r
// <base dir><end>\r
void emu_make_path(char *buff, const char *end, int size)\r
{\r
void emu_prep_defconfig(void)\r
{\r
memset(&defaultConfig, 0, sizeof(defaultConfig));\r
- defaultConfig.EmuOpt = 0x9d | EOPT_RAM_TIMINGS|EOPT_CONFIRM_SAVE|EOPT_EN_CD_LEDS;\r
+ defaultConfig.EmuOpt = 0x9d | EOPT_RAM_TIMINGS|EOPT_EN_CD_LEDS;\r
defaultConfig.s_PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 |\r
POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES |\r
POPT_EN_32X|POPT_EN_PWM;\r
defaultConfig.s_PicoRegion = 0; // auto\r
defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP\r
defaultConfig.s_PicoCDBuffers = 0;\r
+ defaultConfig.confirm_save = EOPT_CONFIRM_SAVE;\r
defaultConfig.Frameskip = -1; // auto\r
defaultConfig.volume = 50;\r
defaultConfig.gamma = 100;\r
PicoRegionOverride = currentConfig.s_PicoRegion;\r
PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;\r
PicoCDBuffers = currentConfig.s_PicoCDBuffers;\r
+ p32x_msh2_multiplier = MSH2_MULTI_DEFAULT;\r
+ p32x_ssh2_multiplier = SSH2_MULTI_DEFAULT;\r
}\r
\r
-int emu_read_config(int game, int no_defaults)\r
+int emu_read_config(const char *rom_fname, int no_defaults)\r
{\r
char cfg[512];\r
int ret;\r
if (!no_defaults)\r
emu_set_defconfig();\r
\r
- if (!game)\r
+ if (rom_fname == NULL)\r
{\r
+ // global config\r
make_config_cfg(cfg);\r
ret = config_readsect(cfg, NULL);\r
}\r
else\r
{\r
- char *sect = emu_make_rom_id();\r
+ char *sect = emu_make_rom_id(rom_fname);\r
\r
- // try new .cfg way\r
if (config_slot != 0)\r
sprintf(cfg, "game.%i.cfg", config_slot);\r
else strcpy(cfg, "game.cfg");\r
if (config_slot != 0)\r
sprintf(cfg, "game.%i.cfg", config_slot);\r
else strcpy(cfg, "game.cfg");\r
- game_sect = emu_make_rom_id();\r
+ game_sect = emu_make_rom_id(rom_fname_loaded);\r
lprintf("emu_write_config: sect \"%s\"\n", game_sect);\r
}\r
\r
if (is_sram)\r
{\r
strcpy(ext, (PicoAHW & PAHW_MCD) ? ".brm" : ".srm");\r
- romfname_ext(saveFname, (PicoAHW & PAHW_MCD) ? "brm"PATH_SEP : "srm"PATH_SEP, ext);\r
+ romfname_ext(saveFname, sizeof(static_buff),\r
+ (PicoAHW & PAHW_MCD) ? "brm"PATH_SEP : "srm"PATH_SEP, ext);\r
if (!load)\r
return saveFname;\r
\r
if (try_ropen_file(saveFname))\r
return saveFname;\r
\r
- romfname_ext(saveFname, NULL, ext);\r
+ romfname_ext(saveFname, sizeof(static_buff), NULL, ext);\r
if (try_ropen_file(saveFname))\r
return saveFname;\r
}\r
strcat(ext, ext_main);\r
\r
if (!load) {\r
- romfname_ext(saveFname, "mds" PATH_SEP, ext);\r
+ romfname_ext(saveFname, sizeof(static_buff), "mds" PATH_SEP, ext);\r
return saveFname;\r
}\r
else {\r
- romfname_ext(saveFname, "mds" PATH_SEP, ext);\r
+ romfname_ext(saveFname, sizeof(static_buff), "mds" PATH_SEP, ext);\r
if (try_ropen_file(saveFname))\r
return saveFname;\r
\r
- romfname_ext(saveFname, NULL, ext);\r
+ romfname_ext(saveFname, sizeof(static_buff), NULL, ext);\r
if (try_ropen_file(saveFname))\r
return saveFname;\r
\r
sprintf(ext, ".%i", slot);\r
strcat(ext, ext_othr);\r
\r
- romfname_ext(saveFname, "mds"PATH_SEP, ext);\r
+ romfname_ext(saveFname, sizeof(static_buff), "mds"PATH_SEP, ext);\r
if (try_ropen_file(saveFname))\r
return saveFname;\r
}\r
{\r
int do_it = 1;\r
if ( emu_check_save_file(state_slot) &&\r
- (((which & PEV_STATE_LOAD) && (currentConfig.EmuOpt & EOPT_CONFIRM_LOAD)) ||\r
- ((which & PEV_STATE_SAVE) && (currentConfig.EmuOpt & EOPT_CONFIRM_SAVE))) )\r
+ (((which & PEV_STATE_LOAD) && (currentConfig.confirm_save & EOPT_CONFIRM_LOAD)) ||\r
+ ((which & PEV_STATE_SAVE) && (currentConfig.confirm_save & EOPT_CONFIRM_SAVE))) )\r
{\r
const char *nm;\r
char tmp[64];\r
#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)
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;
int s_PicoAutoRgnOrder;
int s_PicoCDBuffers;
int Frameskip;
+ int confirm_save;
int CPUclock;
int volume;
int gamma;
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);
/* in_init() must go before config, config accesses in_ fwk */\r
in_init();\r
emu_prep_defconfig();\r
- emu_read_config(0, 0);\r
+ emu_read_config(NULL, 0);\r
config_readlrom(PicoConfigFile);\r
\r
plat_init();\r
if (name != NULL)\r
wt += (strlen(name) + offs) * me_mfont_w;\r
break;\r
+ case MB_OPT_ENUM:\r
+ wt += 10 * me_mfont_w;\r
+ break;\r
}\r
}\r
\r
\r
for (ent = entries; ent->name; ent++)\r
{\r
+ const char **names;\r
+ int len;\r
+\r
if (!ent->enabled)\r
continue;\r
\r
if (name != NULL)\r
text_out16(x + col2_offs + offs * me_mfont_w, y, "%s", name);\r
break;\r
+ case MB_OPT_ENUM:\r
+ names = (const char **)ent->data;\r
+ offs = 0;\r
+ for (i = 0; names[i] != NULL; i++) {\r
+ len = strlen(names[i]);\r
+ if (len > 10)\r
+ offs = 10 - len - 2;\r
+ if (i == *(int *)ent->var) {\r
+ text_out16(x + col2_offs + offs * me_mfont_w, y, "%s", names[i]);\r
+ break;\r
+ }\r
+ }\r
+ break;\r
}\r
\r
y += me_mfont_h;\r
}\r
\r
- /* display message if we have one */\r
+ /* display help or message if we have one */\r
+ h = (g_screen_height - h) / 2; // bottom area height\r
if (menu_error_msg[0] != 0) {\r
- if (g_screen_height - h >= 2 * me_mfont_h)\r
+ if (h >= me_mfont_h + 4)\r
text_out16(5, g_screen_height - me_mfont_h - 4, menu_error_msg);\r
else\r
lprintf("menu msg doesn't fit!\n");\r
if (plat_get_ticks_ms() - menu_error_time > 2048)\r
menu_error_msg[0] = 0;\r
}\r
+ else if (entries[asel].help != NULL) {\r
+ const char *tmp = entries[asel].help;\r
+ int l;\r
+ for (l = 0; tmp != NULL && *tmp != 0; l++)\r
+ tmp = strchr(tmp + 1, '\n');\r
+ if (h >= l * me_sfont_h + 4)\r
+ for (tmp = entries[asel].help; l > 0; l--, tmp = strchr(tmp, '\n') + 1)\r
+ smalltext_out16(5, g_screen_height - (l * me_sfont_h + 4), tmp, 0xffff);\r
+ }\r
\r
if (draw_more != NULL)\r
draw_more();\r
\r
static int me_process(menu_entry *entry, int is_next, int is_lr)\r
{\r
+ const char **names;\r
int c;\r
switch (entry->beh)\r
{\r
if (*(int *)entry->var > (int)entry->max)\r
*(int *)entry->var = (int)entry->min;\r
return 1;\r
+ case MB_OPT_ENUM:\r
+ names = (const char **)entry->data;\r
+ for (c = 0; names[c] != NULL; c++)\r
+ ;\r
+ *(int *)entry->var += is_next ? 1 : -1;\r
+ if (*(int *)entry->var < 0)\r
+ *(int *)entry->var = 0;\r
+ if (*(int *)entry->var >= c)\r
+ *(int *)entry->var = c - 1;\r
+ return 1;\r
default:\r
return 0;\r
}\r
continue;\r
}\r
\r
- if (inp & (PBTN_MOK|PBTN_LEFT|PBTN_RIGHT))\r
+ if (inp & (PBTN_MOK|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R))\r
{\r
- if (menu[sel].handler != NULL) {\r
+ /* require PBTN_MOK for MB_NONE */\r
+ if (menu[sel].handler != NULL && (menu[sel].beh != MB_NONE || (inp & PBTN_MOK))) {\r
ret = menu[sel].handler(menu[sel].id, inp);\r
if (ret) break;\r
- menu_sel_max = me_count(menu) - 1; /* might change */\r
+ menu_sel_max = me_count(menu) - 1; /* might change, so update */\r
}\r
}\r
}\r
}\r
\r
static int mh_saveloadcfg(menu_id id, int keys);\r
-static const char *mgn_savecfg(menu_id id, int *offs);\r
+static const char *mgn_saveloadcfg(menu_id id, int *offs);\r
\r
static menu_entry e_menu_keyconfig[] =\r
{\r
mee_handler_id("Emulator controls", MA_CTRL_EMU, key_config_loop_wrap),\r
mee_onoff ("6 button pad", MA_OPT_6BUTTON_PAD, PicoOpt, POPT_6BTN_PAD),\r
mee_range ("Turbo rate", MA_CTRL_TURBO_RATE, currentConfig.turbo_rate, 1, 30),\r
- mee_handler_mkname_id(MA_OPT_SAVECFG, mh_saveloadcfg, mgn_savecfg),\r
- mee_handler_id("Save cfg for loaded game", MA_OPT_SAVECFG_GAME, mh_saveloadcfg),\r
+ mee_cust_nosave("Save global config", MA_OPT_SAVECFG, mh_saveloadcfg, mgn_saveloadcfg),\r
+ mee_cust_nosave("Save cfg for loaded game", MA_OPT_SAVECFG_GAME, mh_saveloadcfg, mgn_saveloadcfg),\r
mee_label (""),\r
mee_label ("Input devices:"),\r
mee_label_mk (MA_CTRL_DEV_FIRST, mgn_dev_name),\r
return 0;\r
}\r
\r
+static const char h_cdleds[] = "Show power/CD LEDs of emulated console";\r
+static const char h_cdda[] = "Play audio tracks from mp3s/wavs/bins";\r
+static const char h_cdpcm[] = "Emulate PCM audio chip for effects/voices/music";\r
+static const char h_srcart[] = "Emulate the save RAM cartridge accessory\n"\r
+ "most games don't need this";\r
+static const char h_scfx[] = "Emulate scale/rotate ASIC chip for graphics effects\n"\r
+ "disable to improve performance";\r
+static const char h_bsync[] = "More accurate mode for CPUs (needed for some games)\n"\r
+ "disable to improve performance";\r
+\r
static menu_entry e_menu_cd_options[] =\r
{\r
- mee_onoff("CD LEDs", MA_CDOPT_LEDS, currentConfig.EmuOpt, EOPT_EN_CD_LEDS),\r
- mee_onoff("CDDA audio", MA_CDOPT_CDDA, PicoOpt, POPT_EN_MCD_CDDA),\r
- mee_onoff("PCM audio", MA_CDOPT_PCM, PicoOpt, POPT_EN_MCD_PCM),\r
- mee_cust ("ReadAhead buffer", MA_CDOPT_READAHEAD, mh_cdopt_ra, mgn_cdopt_ra),\r
- mee_onoff("SaveRAM cart", MA_CDOPT_SAVERAM, PicoOpt, POPT_EN_MCD_RAMCART),\r
- mee_onoff("Scale/Rot. fx (slow)", MA_CDOPT_SCALEROT_CHIP, PicoOpt, POPT_EN_MCD_GFX),\r
- mee_onoff("Better sync (slow)", MA_CDOPT_BETTER_SYNC, PicoOpt, POPT_EN_MCD_PSYNC),\r
+ mee_onoff_h("CD LEDs", MA_CDOPT_LEDS, currentConfig.EmuOpt, EOPT_EN_CD_LEDS, h_cdleds),\r
+ mee_onoff_h("CDDA audio", MA_CDOPT_CDDA, PicoOpt, POPT_EN_MCD_CDDA, h_cdda),\r
+ mee_onoff_h("PCM audio", MA_CDOPT_PCM, PicoOpt, POPT_EN_MCD_PCM, h_cdpcm),\r
+ mee_cust ("ReadAhead buffer", MA_CDOPT_READAHEAD, mh_cdopt_ra, mgn_cdopt_ra),\r
+ mee_onoff_h("SaveRAM cart", MA_CDOPT_SAVERAM, PicoOpt, POPT_EN_MCD_RAMCART, h_srcart),\r
+ mee_onoff_h("Scale/Rot. fx (slow)", MA_CDOPT_SCALEROT_CHIP, PicoOpt, POPT_EN_MCD_GFX, h_scfx),\r
+ mee_onoff_h("Better sync (slow)", MA_CDOPT_BETTER_SYNC, PicoOpt, POPT_EN_MCD_PSYNC, h_bsync),\r
mee_end,\r
};\r
\r
\r
// ------------ 32X options menu ------------\r
\r
-static const char *get_rname(const char **rn, int val, int *offs)\r
+// convert from multiplier of VClk\r
+static int mh_opt_sh2cycles(menu_id id, int keys)\r
{\r
- int i, len, found = -1, maxlen = 0;\r
+ int *mul = (id == MA_32XOPT_MSH2_CYCLES) ? &p32x_msh2_multiplier : &p32x_ssh2_multiplier;\r
\r
- for (i = 0; rn[i] != NULL; i++) {\r
- len = strlen(rn[i]);\r
- if (len > maxlen)\r
- maxlen = len;\r
- if (i == val)\r
- found = i;\r
- }\r
+ if (keys & (PBTN_LEFT|PBTN_RIGHT))\r
+ *mul += (keys & PBTN_LEFT) ? -10 : 10;\r
+ if (keys & (PBTN_L|PBTN_R))\r
+ *mul += (keys & PBTN_L) ? -100 : 100;\r
+\r
+ if (*mul < 1)\r
+ *mul = 1;\r
+ else if (*mul > (10 << SH2_MULTI_SHIFT))\r
+ *mul = 10 << SH2_MULTI_SHIFT;\r
\r
- *offs = 3 - maxlen;\r
- if (found >= 0)\r
- return rn[found];\r
- return "???";\r
+ return 0;\r
}\r
\r
-static const char *mgn_opt_renderer32x(menu_id id, int *offs)\r
+static const char *mgn_opt_sh2cycles(menu_id id, int *offs)\r
{\r
- return get_rname(renderer_names32x, currentConfig.renderer32x, offs);\r
+ int mul = (id == MA_32XOPT_MSH2_CYCLES) ? p32x_msh2_multiplier : p32x_ssh2_multiplier;\r
+ \r
+ sprintf(static_buff, "%d", 7670 * mul >> SH2_MULTI_SHIFT);\r
+ return static_buff;\r
}\r
\r
+static const char h_32x_enable[] = "Enable emulation of the 32X addon";\r
+static const char h_pwm[] = "Disabling may improve performance, but break sound";\r
+static const char h_sh2cycles[] = "Cycles/millisecond (similar to DOSBox)\n"\r
+ "lower values speed up emulation but break games\n"\r
+ "at least 11000 recommended for compatibility";\r
+\r
static menu_entry e_menu_32x_options[] =\r
{\r
- mee_onoff ("32X enabled", MA_32XOPT_ENABLE_32X, PicoOpt, POPT_EN_32X),\r
- mee_range_cust("32X renderer", MA_32XOPT_RENDERER, currentConfig.renderer32x, 0, 0, mgn_opt_renderer32x),\r
- mee_onoff ("PWM sound", MA_32XOPT_PWM, PicoOpt, POPT_EN_PWM),\r
+ mee_onoff_h ("32X enabled", MA_32XOPT_ENABLE_32X, PicoOpt, POPT_EN_32X, h_32x_enable),\r
+ mee_enum ("32X renderer", MA_32XOPT_RENDERER, currentConfig.renderer32x, renderer_names32x),\r
+ mee_onoff_h ("PWM sound", MA_32XOPT_PWM, PicoOpt, POPT_EN_PWM, h_pwm),\r
+ mee_cust_h ("Master SH2 cycles", MA_32XOPT_MSH2_CYCLES, mh_opt_sh2cycles, mgn_opt_sh2cycles, h_sh2cycles),\r
+ mee_cust_h ("Slave SH2 cycles", MA_32XOPT_SSH2_CYCLES, mh_opt_sh2cycles, mgn_opt_sh2cycles, h_sh2cycles),\r
mee_end,\r
};\r
\r
static int menu_loop_32x_options(menu_id id, int keys)\r
{\r
static int sel = 0;\r
- int i, c;\r
-\r
- for (c = 0; renderer_names32x != NULL && renderer_names32x[c] != NULL; )\r
- c++;\r
- i = me_id2offset(e_menu_32x_options, MA_32XOPT_RENDERER);\r
- e_menu_32x_options[i].max = c > 0 ? (c - 1) : 0;\r
\r
+ me_enable(e_menu_32x_options, MA_32XOPT_RENDERER, renderer_names32x != NULL);\r
me_loop(e_menu_32x_options, &sel, NULL);\r
+\r
return 0;\r
}\r
\r
\r
// ------------ gfx options menu ------------\r
\r
-static const char *mgn_opt_renderer(menu_id id, int *offs)\r
-{\r
- return get_rname(renderer_names, currentConfig.renderer, offs);\r
-}\r
-\r
static menu_entry e_menu_gfx_options[] =\r
{\r
- mee_range_cust("Renderer", MA_OPT_RENDERER, currentConfig.renderer, 0, 0, mgn_opt_renderer),\r
+ mee_enum("Renderer", MA_OPT_RENDERER, currentConfig.renderer, renderer_names),\r
MENU_OPTIONS_GFX\r
mee_end,\r
};\r
static int menu_loop_gfx_options(menu_id id, int keys)\r
{\r
static int sel = 0;\r
- int i, c;\r
-\r
- for (c = 0; renderer_names != NULL && renderer_names[c] != NULL; )\r
- c++;\r
- i = me_id2offset(e_menu_gfx_options, MA_OPT_RENDERER);\r
- e_menu_gfx_options[i].max = c > 0 ? (c - 1) : 0;\r
- me_enable(e_menu_gfx_options, MA_OPT_RENDERER, renderer_names != NULL);\r
\r
+ me_enable(e_menu_gfx_options, MA_OPT_RENDERER, renderer_names[0] != NULL);\r
me_loop(e_menu_gfx_options, &sel, NULL);\r
+\r
return 0;\r
}\r
\r
\r
static int mh_opt_misc(menu_id id, int keys)\r
{\r
- int i;\r
-\r
switch (id) {\r
case MA_OPT_SOUND_QUALITY:\r
PsndRate = sndrate_prevnext(PsndRate, keys & PBTN_RIGHT);\r
case MA_OPT_REGION:\r
region_prevnext(keys & PBTN_RIGHT);\r
break;\r
- case MA_OPT_CONFIRM_STATES:\r
- i = ((currentConfig.EmuOpt>>9)&1) | ((currentConfig.EmuOpt>>10)&2);\r
- i += (keys & PBTN_LEFT) ? -1 : 1;\r
- if (i < 0) i = 0; else if (i > 3) i = 3;\r
- i |= i << 1; i &= ~2;\r
- currentConfig.EmuOpt &= ~0xa00;\r
- currentConfig.EmuOpt |= i << 9;\r
- break;\r
default:\r
break;\r
}\r
me_update_msg("failed to write config");\r
break;\r
case MA_OPT_LOADCFG:\r
- ret = emu_read_config(1, 1);\r
- if (!ret) ret = emu_read_config(0, 1);\r
+ ret = emu_read_config(rom_fname_loaded, 1);\r
+ if (!ret) ret = emu_read_config(NULL, 1);\r
if (ret) me_update_msg("config loaded");\r
else me_update_msg("failed to load config");\r
break;\r
}\r
}\r
\r
-static const char *mgn_opt_c_saves(menu_id id, int *offs)\r
+static const char *mgn_saveloadcfg(menu_id id, int *offs)\r
{\r
- switch ((currentConfig.EmuOpt >> 9) & 5) {\r
- default: return "OFF";\r
- case 1: return "writes";\r
- case 4: return "loads";\r
- case 5: return "both";\r
- }\r
-}\r
-\r
-static const char *mgn_savecfg(menu_id id, int *offs)\r
-{\r
- strcpy(static_buff, "Save global config");\r
+ static_buff[0] = 0;\r
if (config_slot != 0)\r
- sprintf(static_buff + strlen(static_buff), " (profile: %i)", config_slot);\r
+ sprintf(static_buff, "[%i]", config_slot);\r
return static_buff;\r
}\r
\r
-static const char *mgn_loadcfg(menu_id id, int *offs)\r
-{\r
- sprintf(static_buff, "Load cfg from profile %i", config_slot);\r
- return static_buff;\r
-}\r
+static const char *men_confirm_save[] = { "OFF", "writes", "loads", "both", NULL };\r
+static const char h_confirm_save[] = "Ask for confirmation when overwriting save,\n"\r
+ "loading state or both";\r
\r
static menu_entry e_menu_options[] =\r
{\r
mee_onoff ("Show FPS", MA_OPT_SHOW_FPS, currentConfig.EmuOpt, EOPT_SHOW_FPS),\r
mee_onoff ("Enable sound", MA_OPT_ENABLE_SOUND, currentConfig.EmuOpt, EOPT_EN_SOUND),\r
mee_cust ("Sound Quality", MA_OPT_SOUND_QUALITY, mh_opt_misc, mgn_opt_sound),\r
- mee_cust ("Confirm savestate", MA_OPT_CONFIRM_STATES,mh_opt_misc, mgn_opt_c_saves),\r
+ mee_enum_h ("Confirm savestate", MA_OPT_CONFIRM_STATES,currentConfig.confirm_save, men_confirm_save, h_confirm_save),\r
mee_range (cpu_clk_name, MA_OPT_CPU_CLOCKS, currentConfig.CPUclock, 20, 900),\r
mee_handler ("[Display options]", menu_loop_gfx_options),\r
mee_handler ("[Sega/Mega CD options]", menu_loop_cd_options),\r
mee_handler ("[32X options]", menu_loop_32x_options),\r
mee_handler ("[Advanced options]", menu_loop_adv_options),\r
- mee_handler_mkname_id(MA_OPT_SAVECFG, mh_saveloadcfg, mgn_savecfg),\r
- mee_handler_id("Save cfg for current game only", MA_OPT_SAVECFG_GAME, mh_saveloadcfg),\r
- mee_handler_mkname_id(MA_OPT_LOADCFG, mh_saveloadcfg, mgn_loadcfg),\r
+ mee_cust_nosave("Save global config", MA_OPT_SAVECFG, mh_saveloadcfg, mgn_saveloadcfg),\r
+ mee_cust_nosave("Save cfg for loaded game",MA_OPT_SAVECFG_GAME, mh_saveloadcfg, mgn_saveloadcfg),\r
+ mee_cust_nosave("Load cfg from profile", MA_OPT_LOADCFG, mh_saveloadcfg, mgn_saveloadcfg),\r
mee_handler ("Restore defaults", mh_restore_defaults),\r
mee_end,\r
};\r
mee_handler_id("Load State", MA_MAIN_LOAD_STATE, main_menu_handler),\r
mee_handler_id("Reset game", MA_MAIN_RESET_GAME, main_menu_handler),\r
mee_handler_id("Load new ROM/ISO", MA_MAIN_LOAD_ROM, main_menu_handler),\r
- mee_handler_id("Change options", MA_MAIN_OPTIONS, menu_loop_options),\r
- mee_handler_id("Configure controls", MA_MAIN_OPTIONS, menu_loop_keyconfig),\r
+ mee_handler ("Change options", menu_loop_options),\r
+ mee_handler ("Configure controls", menu_loop_keyconfig),\r
mee_handler_id("Credits", MA_MAIN_CREDITS, main_menu_handler),\r
mee_handler_id("Patches / GameGenie",MA_MAIN_PATCHES, main_menu_handler),\r
mee_handler_id("Exit", MA_MAIN_EXIT, main_menu_handler),\r
MB_OPT_CUSTOM, /* custom value */
MB_OPT_CUSTONOFF,
MB_OPT_CUSTRANGE,
+ MB_OPT_ENUM,
} menu_behavior;
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,
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,
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
{
/* 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);
static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];\r
unsigned char *PicoDraw2FB = PicoDraw2FB_;\r
static int osd_fps_x, osd_y;\r
-const char *renderer_names_[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL };\r
-const char *renderer_names32x_[] = { "accurate", "faster ", "fastest ", NULL };\r
-const char **renderer_names = renderer_names_;\r
-const char **renderer_names32x = renderer_names32x_;\r
+const char *renderer_names[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL };\r
+const char *renderer_names32x[] = { "accurate", "faster", "fastest", NULL };\r
enum renderer_types { RT_16BIT, RT_8BIT_ACC, RT_8BIT_FAST, RT_COUNT };\r
\r
extern void *gp2x_screens[4];\r
\r
const char *plat_get_credits(void)\r
{\r
- return "PicoDrive v" VERSION " (c) notaz, 2006-2009\n\n\n"\r
+ return "PicoDrive v" VERSION " (c) notaz, 2006-2010\n\n\n"\r
"Credits:\n"\r
"fDave: Cyclone 68000 core,\n"\r
" base code of PicoDrive\n"\r
// ------------ 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), \
\r
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
char cpu_clk_name[] = "unused";\r
-const char *renderer_names_[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL };\r
-const char *renderer_names32x_[] = { "accurate", "faster ", "fastest ", NULL };\r
-const char **renderer_names = renderer_names_;\r
-const char **renderer_names32x = renderer_names32x_;\r
+const char *renderer_names[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL };\r
+const char *renderer_names32x[] = { "accurate", "faster", "fastest", NULL };\r
enum renderer_types { RT_16BIT, RT_8BIT_ACC, RT_8BIT_FAST, RT_COUNT };\r
\r
\r
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
static unsigned char temp_frame[g_screen_width * g_screen_height * 2];\r
unsigned char *PicoDraw2FB = temp_frame;\r
-const char **renderer_names = NULL;\r
-const char **renderer_names32x = NULL;\r
+const char *renderer_names[] = { NULL };\r
+const char *renderer_names32x[] = { NULL };\r
char cpu_clk_name[] = "unused";\r
\r
\r
\r
const char *plat_get_credits(void)\r
{\r
- return "PicoDrive v" VERSION " (c) notaz, 2006-2009\n\n\n"\r
+ return "PicoDrive v" VERSION " (c) notaz, 2006-2010\n\n\n"\r
"Credits:\n"\r
"fDave: Cyclone 68000 core,\n"\r
" base code of PicoDrive\n"\r
/* in_init() must go before config, config accesses in_ fwk */\r
in_init();\r
emu_prep_defconfig();\r
- emu_read_config(0, 0);\r
+ emu_read_config(NULL, 0);\r
config_readlrom(PicoConfigFile);\r
\r
plat_init();\r
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";