major menu unification, minor reorganization

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@639 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2009-03-02 23:13:15 +00:00
parent 1fb0dd88aa
commit 713c922402
25 changed files with 1640 additions and 507 deletions

View file

@ -206,7 +206,7 @@
cmp r4, #0xe
ldrgeb r4, [r1,#\ofs]
orrlt r4, r3, r4
orrge r4, r3, 0x80
orrge r4, r3, #0x80
strb r4, [r1,#\ofs]
0:
.endm

View file

@ -21,44 +21,8 @@ static char *mystrip(char *str);
#include "emu.h"
#include <pico/pico.h>
extern menu_entry opt_entries[];
extern menu_entry opt2_entries[];
extern menu_entry cdopt_entries[];
extern menu_entry ctrlopt_entries[];
extern const int opt_entry_count;
extern const int opt2_entry_count;
extern const int cdopt_entry_count;
extern const int ctrlopt_entry_count;
#ifdef PSP
extern menu_entry opt3_entries[];
extern const int opt3_entry_count;
#endif
static menu_entry *cfg_opts[] =
{
opt_entries,
opt2_entries,
cdopt_entries,
ctrlopt_entries,
#ifdef PSP
opt3_entries,
#endif
};
static const int *cfg_opt_counts[] =
{
&opt_entry_count,
&opt2_entry_count,
&cdopt_entry_count,
&ctrlopt_entry_count,
#ifdef PSP
&opt3_entry_count,
#endif
};
#define NL "\r\n"
static int seek_sect(FILE *f, const char *section)
{
char line[128], *tmp;
@ -82,79 +46,10 @@ static int seek_sect(FILE *f, const char *section)
static void custom_write(FILE *f, const menu_entry *me, int no_def)
{
char *str, str24[24];
char str24[24];
switch (me->id)
{
case MA_OPT_RENDERER:
if (no_def && !((defaultConfig.s_PicoOpt^PicoOpt)&POPT_ALT_RENDERER) &&
!((defaultConfig.EmuOpt^currentConfig.EmuOpt)&0x80)) return;
if (PicoOpt&POPT_ALT_RENDERER)
str =
#ifndef PSP
"8bit "
#endif
"fast";
else if (currentConfig.EmuOpt&0x80)
str =
#ifndef PSP
"16bit "
#endif
"accurate";
else
str = "8bit accurate";
fprintf(f, "Renderer = %s", str);
break;
case MA_OPT_SCALING:
if (no_def && defaultConfig.scaling == currentConfig.scaling) return;
#ifdef __GP2X__
switch (currentConfig.scaling) {
default: str = "OFF"; break;
case 1: str = "hw horizontal"; break;
case 2: str = "hw horiz. + vert."; break;
case 3: str = "sw horizontal"; break;
}
fprintf(f, "Scaling = %s", str);
#endif
break;
case MA_OPT_FRAMESKIP:
if (no_def && defaultConfig.Frameskip == currentConfig.Frameskip) return;
if (currentConfig.Frameskip < 0)
strcpy(str24, "Auto");
else sprintf(str24, "%i", currentConfig.Frameskip);
fprintf(f, "Frameskip = %s", str24);
break;
case MA_OPT_SOUND_QUALITY:
if (no_def && !((defaultConfig.s_PicoOpt^PicoOpt)&POPT_EN_STEREO) &&
defaultConfig.s_PsndRate == PsndRate) return;
str = (PicoOpt&POPT_EN_STEREO)?"stereo":"mono";
fprintf(f, "Sound Quality = %i %s", PsndRate, str);
break;
case MA_OPT_REGION:
if (no_def && defaultConfig.s_PicoRegion == PicoRegionOverride &&
defaultConfig.s_PicoAutoRgnOrder == PicoAutoRgnOrder) return;
strncpy(str24, me_region_name(PicoRegionOverride, PicoAutoRgnOrder), 23); str24[23] = 0;
fprintf(f, "Region = %s", mystrip(str24));
break;
case MA_OPT_CONFIRM_STATES:
if (no_def && !((defaultConfig.EmuOpt^currentConfig.EmuOpt)&(5<<9))) return;
switch ((currentConfig.EmuOpt >> 9) & 5) {
default: str = "OFF"; break;
case 1: str = "writes"; break;
case 4: str = "loads"; break;
case 5: str = "both"; break;
}
fprintf(f, "Confirm savestate = %s", str);
break;
case MA_OPT_CPU_CLOCKS:
if (no_def && defaultConfig.CPUclock == currentConfig.CPUclock) return;
#ifdef __GP2X__
fprintf(f, "GP2X CPU clocks = %i", currentConfig.CPUclock);
#elif defined(PSP)
fprintf(f, "PSP CPU clock = %i", currentConfig.CPUclock);
#endif
break;
case MA_OPT2_GAMMA:
if (no_def && defaultConfig.gamma == currentConfig.gamma) return;
fprintf(f, "Gamma correction = %.3f", (double)currentConfig.gamma / 100.0);
@ -299,7 +194,7 @@ int config_writesect(const char *fname, const char *section)
FILE *fo = NULL, *fn = NULL; // old and new
int no_defaults = 0; // avoid saving defaults
menu_entry *me;
int t, i, tlen, ret;
int t, tlen, ret;
char line[128], *tmp;
if (section != NULL)
@ -368,30 +263,34 @@ write:
if (section != NULL)
fprintf(fn, "[%s]" NL, section);
for (t = 0; t < sizeof(cfg_opts) / sizeof(cfg_opts[0]); t++)
me = me_list_get_first();
while (me != NULL)
{
me = cfg_opts[t];
tlen = *(cfg_opt_counts[t]);
for (i = 0; i < tlen; i++, me++)
{
if (!me->need_to_save) continue;
if ((me->beh != MB_ONOFF && me->beh != MB_RANGE) || me->name == NULL)
custom_write(fn, me, no_defaults);
else if (me->beh == MB_ONOFF) {
int dummy;
if (!me->need_to_save)
goto next;
if (me->beh == MB_OPT_ONOFF) {
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_RANGE) {
} else if (me->beh == MB_OPT_RANGE) {
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) {
strncpy(line, me->generate_name(0, &dummy), sizeof(line));
line[sizeof(line) - 1] = 0;
mystrip(line);
fprintf(fn, "%s = %s" NL, me->name, line);
} else
custom_write(fn, me, no_defaults);
next:
me = me_list_get_next();
}
/* input: save device names */
for (t = 0; t < IN_MAX_DEVS; t++)
{
const int *binds = in_get_dev_binds(t);
const char *name = in_get_dev_name(t, 0);
const char *name = in_get_dev_name(t, 0, 0);
if (binds == NULL || name == NULL)
continue;
@ -402,7 +301,7 @@ write:
for (t = 0; t < IN_MAX_DEVS; t++)
{
const int *binds = in_get_dev_binds(t);
const char *name = in_get_dev_name(t, 0);
const char *name = in_get_dev_name(t, 0, 0);
char strbind[16];
int count;
@ -449,7 +348,7 @@ int config_writelrom(const char *fname)
int size;
FILE *f;
if (strlen(loadedRomFName) == 0) return -1;
if (strlen(rom_fname_loaded) == 0) return -1;
f = fopen(fname, "r");
if (f != NULL)
@ -482,7 +381,7 @@ int config_writelrom(const char *fname)
fwrite(old_data, 1, optr - old_data, f);
free(old_data);
}
fprintf(f, "LastUsedROM = %s" NL, loadedRomFName);
fprintf(f, "LastUsedROM = %s" NL, rom_fname_loaded);
fclose(f);
return 0;
}
@ -513,9 +412,9 @@ int config_readlrom(const char *fname)
tmp++;
mystrip(tmp);
len = sizeof(loadedRomFName);
strncpy(loadedRomFName, tmp, len);
loadedRomFName[len-1] = 0;
len = sizeof(rom_fname_loaded);
strncpy(rom_fname_loaded, tmp, len);
rom_fname_loaded[len-1] = 0;
ret = 0;
break;
}
@ -773,7 +672,7 @@ static unsigned char input_dev_map[IN_MAX_DEVS];
static void parse(const char *var, const char *val)
{
menu_entry *me;
int t, i, tlen, tmp, ret = 0;
int tmp, ret = 0;
if (strcasecmp(var, "LastUsedROM") == 0)
return; /* handled elsewhere */
@ -814,21 +713,20 @@ static void parse(const char *var, const char *val)
return;
}
for (t = 0; t < sizeof(cfg_opts) / sizeof(cfg_opts[0]) && ret == 0; t++)
me = me_list_get_first();
while (me != NULL && ret == 0)
{
me = cfg_opts[t];
tlen = *(cfg_opt_counts[t]);
for (i = 0; i < tlen && ret == 0; i++, me++)
{
if (!me->need_to_save) continue;
if (me->name != NULL) {
if (strcasecmp(var, me->name) != 0) continue; // surely not this one
if (me->beh == MB_ONOFF) {
if (!me->need_to_save)
goto next;
if (me->name != NULL && me->name[0] != 0) {
if (strcasecmp(var, me->name) != 0)
goto next; /* surely not this one */
if (me->beh == MB_OPT_ONOFF) {
tmp = atoi(val);
if (tmp) *(int *)me->var |= me->mask;
else *(int *)me->var &= ~me->mask;
return;
} else if (me->beh == MB_RANGE) {
} else if (me->beh == MB_OPT_RANGE) {
tmp = atoi(val);
if (tmp < me->min) tmp = me->min;
if (tmp > me->max) tmp = me->max;
@ -837,7 +735,8 @@ static void parse(const char *var, const char *val)
}
}
ret = custom_read(me, var, val);
}
next:
me = me_list_get_next();
}
if (!ret) lprintf("config_readsect: unhandled var: \"%s\"\n", var);
}

View file

@ -16,6 +16,7 @@
#include "lprintf.h"
#include "config.h"
#include "common.h"
#include "plat.h"
#include <pico/pico_int.h>
#include <pico/patch.h>
@ -25,23 +26,21 @@
char *PicoConfigFile = "config.cfg";
currentConfig_t currentConfig, defaultConfig;
int rom_loaded = 0;
char noticeMsg[64] = { 0, };
int state_slot = 0;
int config_slot = 0, config_slot_current = 0;
char loadedRomFName[512] = { 0, };
int kb_combo_keys = 0, kb_combo_acts = 0; // keys and actions which need button combos
int pico_inp_mode = 0;
int engineState = PGS_Menu;
/* TODO: len checking */
char rom_fname_reload[512] = { 0, };
char rom_fname_loaded[512] = { 0, };
int rom_loaded = 0;
unsigned char *movie_data = NULL;
static int movie_size = 0;
// provided by platform code:
extern void emu_noticeMsgUpdated(void);
extern int emu_getMainDir(char *dst, int len);
extern void menu_romload_prepare(const char *rom_name);
extern void menu_romload_end(void);
// utilities
static void strlwr_(char *string)
@ -492,8 +491,8 @@ int emu_ReloadRom(char *rom_fname)
if (currentConfig.EmuOpt & EOPT_USE_SRAM)
emu_SaveLoadGame(1, 1);
strncpy(loadedRomFName, rom_fname, sizeof(loadedRomFName)-1);
loadedRomFName[sizeof(loadedRomFName)-1] = 0;
strncpy(rom_fname_loaded, rom_fname, sizeof(rom_fname_loaded)-1);
rom_fname_loaded[sizeof(rom_fname_loaded)-1] = 0;
rom_loaded = 1;
return 1;
@ -518,8 +517,8 @@ static void romfname_ext(char *dst, const char *prefix, const char *ext)
int prefix_len = 0;
// make save filename
p = loadedRomFName+strlen(loadedRomFName)-1;
for (; p >= loadedRomFName && *p != PATH_SEP_C; p--); p++;
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 = emu_getMainDir(dst, 512);
@ -527,7 +526,7 @@ static void romfname_ext(char *dst, const char *prefix, const char *ext)
prefix_len = len + strlen(prefix);
}
#ifdef UIQ3
else p = loadedRomFName; // backward compatibility
else p = rom_fname_loaded; // backward compatibility
#endif
strncpy(dst + prefix_len, p, 511-prefix_len);
dst[511-8] = 0;

View file

@ -50,11 +50,14 @@ extern char noticeMsg[64];
extern int state_slot;
extern int config_slot, config_slot_current;
extern unsigned char *movie_data;
extern char loadedRomFName[512]; // last loaded ROM filename
extern int kb_combo_keys, kb_combo_acts; // keys and actions which need button combos
extern int pico_inp_mode;
extern char rom_fname_reload[512]; // ROM to try loading on next PGS_ReloadRom
extern char rom_fname_loaded[512]; // currently loaded ROM filename
// engine states
extern int engineState;
enum TPicoGameState {
PGS_Paused = 1,
PGS_Running,

View file

@ -380,14 +380,14 @@ int in_menu_wait_any(int timeout_ms)
}
/* wait for menu input, do autorepeat */
int in_menu_wait(int interesting)
int in_menu_wait(int interesting, int autorep_delay_ms)
{
static int inp_prev = 0;
static int repeats = 0;
int ret, release = 0, wait = 666;
if (repeats)
wait = 33;
wait = autorep_delay_ms;
ret = in_menu_wait_any(wait);
if (ret == inp_prev)
@ -439,14 +439,22 @@ int in_get_dev_bind_count(int dev_id)
return in_bind_count(in_devices[dev_id].drv_id);
}
const char *in_get_dev_name(int dev_id, int must_be_active)
const char *in_get_dev_name(int dev_id, int must_be_active, int skip_pfix)
{
const char *name, *tmp;
if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
return NULL;
if (must_be_active && !in_devices[dev_id].probed)
return NULL;
return in_devices[dev_id].name;
name = in_devices[dev_id].name;
tmp = strchr(name, ':');
if (tmp != NULL)
name = tmp + 1;
return name;
}
/* never returns NULL */

View file

@ -31,7 +31,7 @@ int in_update(void);
void in_set_blocking(int is_blocking);
int in_update_keycode(int *dev_id, int *is_down, int timeout_ms);
int in_menu_wait_any(int timeout_ms);
int in_menu_wait(int interesting);
int in_menu_wait(int interesting, int autorep_delay_ms);
int in_get_dev_bind_count(int dev_id);
void in_config_start(void);
int in_config_parse_dev(const char *dev_name);
@ -42,5 +42,5 @@ void in_debug_dump(void);
const int *in_get_dev_binds(int dev_id);
const int *in_get_dev_def_binds(int dev_id);
const char *in_get_dev_name(int dev_id, int must_be_active);
const char *in_get_dev_name(int dev_id, int must_be_active, int skip_pfix);
const char *in_get_key_name(int dev_id, int keycode);

File diff suppressed because it is too large Load diff

View file

@ -4,9 +4,6 @@
void menu_init(void);
void text_out16(int x, int y, const char *texto, ...);
void smalltext_out16(int x, int y, const char *texto, int color);
void smalltext_out16_lim(int x, int y, const char *texto, int color, int max);
void menu_draw_selection(int x, int y, int w);
void debug_menu_loop(void);
extern char menuErrorMsg[64];
@ -15,7 +12,9 @@ typedef enum
MB_NONE = 1, /* no auto processing */
MB_OPT_ONOFF, /* ON/OFF setting */
MB_OPT_RANGE, /* [min-max] setting */
MB_OPT_CUSTOM,
MB_OPT_CUSTOM, /* custom value */
MB_OPT_CUSTONOFF,
MB_OPT_CUSTRANGE,
} menu_behavior;
typedef enum
@ -97,6 +96,8 @@ typedef enum
MA_CTRL_PLAYER2,
MA_CTRL_EMU,
MA_CTRL_TURBO_RATE,
MA_CTRL_DEV_FIRST,
MA_CTRL_DEV_NEXT,
MA_CTRL_DONE,
} menu_id;
@ -107,22 +108,47 @@ typedef struct
menu_id id;
void *var; /* for on-off/range settings */
int mask; /* bit to toggle for on/off */
signed char min; /* for ranged integer settings, to be sign-extended */
signed char max;
char enabled;
char need_to_save;
int (*submenu_handler)(menu_id id);
const char * (*generate_name)(int is_left);
signed short min; /* for ranged integer settings, to be sign-extended */
signed short max;
int enabled:1;
int need_to_save:1;
int selectable:1;
int (*handler)(menu_id id, int keys);
const char * (*generate_name)(menu_id id, int *offs);
} menu_entry;
#define mee_submenu_id(name, id, handler) \
{ name, MB_NONE, id, NULL, 0, 0, 0, 1, 0, handler, NULL }
#define mee_handler_id(name, id, handler) \
{ name, MB_NONE, id, NULL, 0, 0, 0, 1, 0, 1, handler, NULL }
#define mee_submenu(name, handler) \
mee_submenu_id(name, MA_NONE, handler)
#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 }
#define mee_label_mk(id, name_func) \
{ "", MB_NONE, id, NULL, 0, 0, 0, 1, 0, 0, NULL, name_func }
#define mee_onoff(name, id, var, mask) \
{ name, MB_OPT_ONOFF, id, &(var), mask, 0, 0, 1, 1, 1, NULL, NULL }
#define mee_range(name, id, var, min, max) \
{ name, MB_OPT_RANGE, id, &(var), 0, min, max, 1, 1, 1, NULL, NULL }
#define mee_cust(name, id, handler, name_func) \
{ name, MB_OPT_CUSTOM, id, NULL, 0, 0, 0, 1, 1, 1, handler, name_func }
#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 }
#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 }
#define mee_end \
{ NULL, 0, 0, NULL, 0, 0, 0, 0, 0, NULL, NULL }
{ NULL, 0, 0, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL }
typedef struct
{
@ -133,18 +159,8 @@ typedef struct
extern me_bind_action me_ctrl_actions[15];
extern me_bind_action emuctrl_actions[]; // platform code
typedef void (me_draw_custom_f)(const menu_entry *entry, int x, int y, void *param);
/* TODO: move? */
int me_id2offset(const menu_entry *entries, menu_id id);
void me_enable(menu_entry *entries, menu_id id, int enable);
int me_count_enabled(const menu_entry *ent);
menu_id me_index2id(const menu_entry *entries, int index);
void me_draw(const menu_entry *entries, int count, int x, int y, me_draw_custom_f *cust_draw, void *param);
int me_process(menu_entry *entries, menu_id id, int is_next);
const char *me_region_name(unsigned int code, int auto_order);
menu_entry *me_list_get_first(void);
menu_entry *me_list_get_next(void);
void menu_darken_bg(void *dst, int pixels, int darker);

View file

@ -1,22 +1,32 @@
/* stuff to be implemented by platform code */
#ifdef __cplusplus
extern "C" {
#endif
extern const char * const keyNames[];
/* stuff to be implemented by platform code */
/* TODO rename all these */
extern const char * const keyNames[]; // TODO rm
void emu_prepareDefaultConfig(void);
void emu_platformDebugCat(char *str);
void emu_forcedFrame(int opts);
void emu_startSound(void);
void emu_endSound(void);
void emu_waitSound(void);
void emu_ResetGame(void); // TODO mv rm?
void emu_noticeMsgUpdated(void);
int emu_getMainDir(char *dst, int len);
void menu_romload_prepare(const char *rom_name);
void menu_romload_end(void);
/* menu: enter (switch bpp, etc), begin/end drawing */
void plat_video_menu_enter(int is_rom_loaded);
void plat_video_menu_begin(void);
void plat_video_menu_end(void);
int plat_is_dir(const char *path);
const char *plat_get_credits(void);
#ifdef __cplusplus
} // extern "C"
#endif

13
platform/common/posix.h Normal file
View file

@ -0,0 +1,13 @@
/* define POSIX stuff: dirent, scandir, getcwd */
#if defined(__linux__)
#include <dirent.h>
#include <unistd.h>
#else
#error "must define dirent"
#endif

View file

@ -26,8 +26,6 @@
// main 300K gfx-related buffer. Used by menu and renderers.
unsigned char gfx_buffer[321*240*2*2];
char romFileName[MAX_PATH];
int engineState;
unsigned char *PicoDraw2FB = gfx_buffer; // temporary buffer for alt renderer ( (8+320)*(8+240+8) )
int reset_timing = 0;

View file

@ -4,9 +4,6 @@
// For commercial use, separate licencing terms must be obtained.
extern unsigned char gfx_buffer[321*240*2*2];
extern char romFileName[];
extern int engineState;
void emu_Init(void);
void emu_Deinit(void);

View file

@ -31,7 +31,7 @@ else
use_cyclone = 1
endif
DEFINC = -I../.. -I. -DARM -D__GP2X__ # -DBENCHMARK
DEFINC = -I../.. -I. -DARM -D__GP2X__ -DIN_GP2X # -DBENCHMARK
COPT_COMMON = -static -Wall -Winline
ifeq ($(DEBUG),)
COPT_COMMON += -O3 -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math
@ -54,14 +54,15 @@ LD = $(CROSS)ld
OBJCOPY = $(CROSS)objcopy
# frontend
OBJS += main.o menu.o gp2x.o emu.o squidgehack.o cpuctrl.o
OBJS += main.o gp2x.o emu.o in_gp2x.o squidgehack.o cpuctrl.o
# 940 core control
OBJS += 940ctl.o
# common
OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \
platform/common/arm_utils.o platform/common/arm_linux.o platform/common/readpng.o \
platform/common/mp3_helix.o platform/linux/usbjoy.o platform/linux/sndout_oss.o
platform/common/mp3_helix.o platform/common/input.o platform/linux/usbjoy.o \
platform/linux/sndout_oss.o platform/linux/plat.o
# Pico
ifeq "$(amalgamate)" "1"

View file

@ -25,6 +25,7 @@
#include "../common/input.h"
#include "../linux/sndout_oss.h"
#include "cpuctrl.h"
#include "version.h"
#include <pico/pico_int.h>
#include <pico/patch.h>
@ -40,11 +41,8 @@
#endif
int engineState;
int select_exits = 0;
char romFileName[PATH_MAX];
extern int crashed_940;
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
@ -1065,3 +1063,24 @@ void emu_ResetGame(void)
reset_timing = 1;
}
const char *plat_get_credits(void)
{
return "PicoDrive v" VERSION " (c) notaz, 2006-2009\n\n\n"
"Credits:\n"
"fDave: Cyclone 68000 core,\n"
" base code of PicoDrive\n"
"Reesy & FluBBa: DrZ80 core\n"
"MAME devs: YM2612 and SN76496 cores\n"
"rlyeh and others: minimal SDK\n"
"Squidge: squidgehack\n"
"Dzz: ARM940 sample\n"
"GnoStiC / Puck2099: USB joy code\n"
"craigix: GP2X hardware\n"
"ketchupgun: skin design\n"
"\n"
"special thanks (for docs, ideas):\n"
" Charles MacDonald, Haze,\n"
" Stephane Dallongeville,\n"
" Lordus, Exophase, Rokas,\n"
" Nemesis, Tasco Deluxe";
}

View file

@ -4,14 +4,9 @@
// For commercial use, separate licencing terms must be obtained.
extern char romFileName[];
extern int engineState;
void emu_Init(void);
void emu_Deinit(void);
void emu_Loop(void);
void emu_ResetGame(void);
void osd_text(int x, int y, const char *text);

View file

@ -103,7 +103,9 @@ static int in_gp2x_menu_translate(int keycode)
case BTN_RIGHT: return PBTN_RIGHT;
case BTN_B: return PBTN_MOK;
case BTN_X: return PBTN_MBACK;
case BTN_START: return PBTN_MENU;
case BTN_SELECT:return PBTN_MENU;
case BTN_L: return PBTN_L;
case BTN_R: return PBTN_R;
default: return 0;
}
}

View file

@ -16,6 +16,7 @@
#include "../common/emu.h"
#include "../common/config.h"
#include "../common/input.h"
#include "../common/plat.h"
#include "emu.h"
#include "940ctl.h"
#include "version.h"
@ -61,9 +62,9 @@ void parse_cmd_line(int argc, char *argv[])
} else {
/* External Frontend: ROM Name */
FILE *f;
strncpy(romFileName, argv[x], PATH_MAX);
romFileName[PATH_MAX-1] = 0;
f = fopen(romFileName, "rb");
strncpy(rom_fname_reload, argv[x], PATH_MAX);
rom_fname_reload[PATH_MAX-1] = 0;
f = fopen(rom_fname_reload, "rb");
if (f) fclose(f);
else unrecognized = 1;
engineState = PGS_ReloadRom;
@ -122,7 +123,7 @@ int main(int argc, char *argv[])
if (engineState == PGS_ReloadRom)
{
if (emu_ReloadRom(romFileName)) {
if (emu_ReloadRom(rom_fname_reload)) {
engineState = PGS_Running;
if (load_state_slot >= 0) {
state_slot = load_state_slot;
@ -140,7 +141,7 @@ int main(int argc, char *argv[])
break;
case PGS_ReloadRom:
if (emu_ReloadRom(romFileName))
if (emu_ReloadRom(rom_fname_reload))
engineState = PGS_Running;
else {
printf("PGS_ReloadRom == 0\n");

View file

@ -28,7 +28,7 @@ LDFLAGS += `pkg-config --libs gthread-2.0`
# frontend
OBJS += platform/gp2x/main.o platform/gp2x/emu.o platform/gp2x/plat.o usbjoy.o blit.o \
in_evdev.o sndout_oss.o gp2x.o 940ctl_ym2612.o log_io.o
in_evdev.o plat.o sndout_oss.o gp2x.o 940ctl_ym2612.o log_io.o
# platform/gp2x/menu.o
ifeq "$(fake_in_gp2x)" "1"

14
platform/linux/plat.c Normal file
View file

@ -0,0 +1,14 @@
#include <dirent.h>
#include "../common/plat.h"
int plat_is_dir(const char *path)
{
DIR *dir;
if ((dir = opendir(path))) {
closedir(dir);
return 1;
}
return 0;
}

View file

@ -42,11 +42,8 @@
#endif
int engineState;
int select_exits = 0;
char romFileName[PATH_MAX];
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
static struct timeval noticeMsgTime = { 0, 0 }; // when started showing
static int osd_fps_x;

View file

@ -50,9 +50,9 @@ void parse_cmd_line(int argc, char *argv[])
} else {
/* External Frontend: ROM Name */
FILE *f;
strncpy(romFileName, argv[x], PATH_MAX);
romFileName[PATH_MAX-1] = 0;
f = fopen(romFileName, "rb");
strncpy(rom_fname_reload, argv[x], PATH_MAX);
rom_fname_reload[PATH_MAX-1] = 0;
f = fopen(rom_fname_reload, "rb");
if (f) fclose(f);
else unrecognized = 1;
engineState = PGS_ReloadRom;
@ -96,7 +96,7 @@ int main(int argc, char *argv[])
if (engineState == PGS_ReloadRom)
{
if (emu_ReloadRom(romFileName)) {
if (emu_ReloadRom(rom_fname_reload)) {
engineState = PGS_Running;
if (load_state_slot >= 0) {
state_slot = load_state_slot;
@ -114,7 +114,7 @@ int main(int argc, char *argv[])
break;
case PGS_ReloadRom:
if (emu_ReloadRom(romFileName))
if (emu_ReloadRom(rom_fname_reload))
engineState = PGS_Running;
else {
printf("PGS_ReloadRom == 0\n");

View file

@ -33,9 +33,8 @@ int sceAudio_E0727056(int volume, void *buffer); // blocking output
int sceAudioOutput2GetRestSample();
char romFileName[PATH_MAX];
unsigned char *PicoDraw2FB = (unsigned char *)VRAM_CACHED_STUFF + 8; // +8 to be able to skip border with 1 quadword..
int engineState = PGS_Menu, engineStateSuspend;
int engineStateSuspend;
static unsigned int noticeMsgTime = 0;
int reset_timing = 0; // do we need this?
@ -1127,13 +1126,13 @@ void emu_HandleResume(void)
// reopen first CD track
if (Pico_mcd->TOC.Tracks[0].F != NULL)
{
char *fname = romFileName;
int len = strlen(romFileName);
char *fname = rom_fname_reload;
int len = strlen(rom_fname_reload);
cue_data_t *cue_data = NULL;
if (len > 4 && strcasecmp(fname + len - 4, ".cue") == 0)
{
cue_data = cue_parse(romFileName);
cue_data = cue_parse(rom_fname_reload);
if (cue_data != NULL)
fname = cue_data->tracks[1].fname;
}

View file

@ -4,10 +4,7 @@
// For commercial use, separate licencing terms must be obtained.
extern char romFileName[];
extern int engineState, engineStateSuspend;
extern int engineStateSuspend;
void emu_Init(void);
void emu_Deinit(void);

View file

@ -23,7 +23,7 @@
void dummy(void)
{
engineState = atoi(romFileName);
engineState = atoi(rom_fname_reload);
setbuf(NULL, NULL);
getenv(NULL);
}
@ -52,13 +52,13 @@ int pico_main(void)
#ifndef GPROF
menu_loop();
#else
strcpy(romFileName, loadedRomFName);
strcpy(rom_fname_reload, rom_fname_loaded);
engineState = PGS_ReloadRom;
#endif
break;
case PGS_ReloadRom:
if (emu_ReloadRom(romFileName)) {
if (emu_ReloadRom(rom_fname_reload)) {
engineState = PGS_Running;
if (mp3_last_error != 0)
engineState = PGS_Menu; // send to menu to display mp3 error

View file

@ -216,7 +216,7 @@ void CPicolAppView::DisplayOpenROMDialogL()
CleanupStack::PushL(fileArray);
_LIT16(KDlgTitle, "Select a ROM file");
TPtrC8 text8((TUint8*) loadedRomFName);
TPtrC8 text8((TUint8*) rom_fname_loaded);
iCurrentConfig.iLastROMFile.Copy(text8);
if( CQikSelectFileDlg::RunDlgLD( *mimeArray, *fileArray, &KDlgTitle, &iCurrentConfig.iLastROMFile) )