UIQ3 update, some makefile unification, rm old configs, stuff

git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@569 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2008-08-21 10:45:54 +00:00
parent 5d239ae7a4
commit 36f6fd5afe
18 changed files with 339 additions and 264 deletions

66
common/common_arm.mak Normal file
View file

@ -0,0 +1,66 @@
.c.o:
@echo ">>>" $<
$(CC) $(CFLAGS) $(DEFINC) -c $< -o $@
.S.o:
@echo ">>>" $<
$(CC) $(SFLAGS) $(DEFINC) -c $< -o $@
../../tools/textfilter: ../../tools/textfilter.c
make -C ../../tools/ textfilter
clean_prof:
find ../.. -name '*.gcno' -delete
find ../.. -name '*.gcda' -delete
mkdirs:
mkdir -p $(DIRS)
# deps
Pico/carthw/svp/compiler.o : ../../Pico/carthw/svp/ssp16.o ../../Pico/carthw/svp/gen_arm.c
Pico/Pico.o Pico/cd/Pico.o : ../../Pico/PicoFrameHints.c ../../Pico/PicoInt.h
Pico/Memory.o Pico/cd/Memory.o : ../../Pico/MemoryCmn.c ../../Pico/PicoInt.h
# individual rules
Pico/draw_asm.o : ../../Pico/Draw.s
@echo ">>>" $@
$(AS) $(ASFLAGS) $< -o $@
Pico/draw2_asm.o : ../../Pico/Draw2.s
@echo ">>>" $@
$(AS) $(ASFLAGS) $< -o $@
Pico/memory_asm.o : ../../Pico/Memory.s
@echo ">>>" $@
$(AS) $(ASFLAGS) $< -o $@
Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s
@echo ">>>" $@
$(AS) $(ASFLAGS) $< -o $@
Pico/sound/mix_asm.o : ../../Pico/sound/mix.s
@echo ">>>" $@
$(AS) $(ASFLAGS) $< -o $@
Pico/misc_asm.o : ../../Pico/Misc.s
@echo ">>>" $@
$(AS) $(ASFLAGS) $< -o $@
Pico/cd/pico_asm.o : ../../Pico/cd/Pico.s
@echo ">>>" $@
$(AS) $(ASFLAGS) $< -o $@
Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s
@echo ">>>" $@
$(AS) $(ASFLAGS) $< -o $@
Pico/cd/misc_asm.o : ../../Pico/cd/Misc.s
@echo ">>>" $@
$(AS) $(ASFLAGS) $< -o $@
#Pico/carthw/svp/stub_arm.o : ../../Pico/carthw/svp/stub_arm.S
# @echo ">>>" $@
# $(GCC) $(CFLAGS) $(DEFINC) -c $< -o $@
# build Cyclone
cpu/Cyclone/proj/Cyclone.s:
@echo building Cyclone...
@make -C ../../cpu/Cyclone/proj CONFIG_FILE=config_pico.h
# build helix libs
../common/helix/$(CROSS)helix-mp3.a:
make -C ../common/helix clean all

View file

@ -1,11 +1,14 @@
/* /*
* Human-readable config file management for PicoDrive * Human-readable config file management for PicoDrive
* (c) * (c) notaz, 2008
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef UIQ3
#include <unistd.h>
#endif
#include "config.h" #include "config.h"
#include "lprintf.h" #include "lprintf.h"
@ -205,6 +208,7 @@ static void custom_write(FILE *f, const menu_entry *me, int no_def)
} }
#if PLAT_HAVE_JOY
static const char *joyKeyNames[32] = static const char *joyKeyNames[32] =
{ {
"UP", "DOWN", "LEFT", "RIGHT", "b1", "b2", "b3", "b4", "UP", "DOWN", "LEFT", "RIGHT", "b1", "b2", "b3", "b4",
@ -212,31 +216,40 @@ static const char *joyKeyNames[32] =
"b13", "b14", "b15", "b16", "b17", "b19", "b19", "b20", "b13", "b14", "b15", "b16", "b17", "b19", "b19", "b20",
"b21", "b22", "b23", "b24", "b25", "b26", "b27", "b28" "b21", "b22", "b23", "b24", "b25", "b26", "b27", "b28"
}; };
#endif
static void keys_write(FILE *fn, const char *bind_str, const int binds[32], static void keys_write(FILE *fn, const char *bind_str, const int binds[32],
const int def_binds[32], const char * const names[32], int no_defaults) const int def_binds[32], const char * const names[32], int key_count, int no_defaults)
{ {
int t, i; int t, i;
char act[48]; char act[48], name[32];
for (t = 0; t < 32; t++) for (t = 0; t < key_count; t++)
{ {
act[0] = act[31] = 0; act[0] = act[31] = 0;
if (no_defaults && binds[t] == def_binds[t]) if (no_defaults && binds[t] == def_binds[t])
continue; continue;
if (strcmp(names[t], "???") == 0) continue;
#ifdef __GP2X__ #ifdef __GP2X__
if (strcmp(names[t], "SELECT") == 0) continue; if (strcmp(names[t], "SELECT") == 0) continue;
#endif #endif
if (t >= 32 || names[t] == NULL || strcmp(names[t], "???") == 0) {
if ((t >= '0' && t <= '9') || (t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z'))
sprintf(name, "%c", t);
else
sprintf(name, "\\x%02x", t);
}
else
strcpy(name, names[t]);
if (binds[t] == 0 && def_binds[t] != 0) { if (binds[t] == 0 && def_binds[t] != 0) {
fprintf(fn, "%s %s =" NL, bind_str, names[t]); // no binds fprintf(fn, "%s %s =" NL, bind_str, name); // no binds
continue; continue;
} }
for (i = 0; i < sizeof(me_ctrl_actions) / sizeof(me_ctrl_actions[0]); i++) { for (i = 0; i < sizeof(me_ctrl_actions) / sizeof(me_ctrl_actions[0]); i++) {
if (me_ctrl_actions[i].mask & binds[t]) { if (me_ctrl_actions[i].mask & binds[t]) {
strncpy(act, me_ctrl_actions[i].name, 31); strncpy(act, me_ctrl_actions[i].name, 31);
fprintf(fn, "%s %s = player%i %s" NL, bind_str, names[t], fprintf(fn, "%s %s = player%i %s" NL, bind_str, name,
((binds[t]>>16)&1)+1, mystrip(act)); ((binds[t]>>16)&1)+1, mystrip(act));
} }
} }
@ -244,7 +257,7 @@ static void keys_write(FILE *fn, const char *bind_str, const int binds[32],
for (i = 0; emuctrl_actions[i].name != NULL; i++) { for (i = 0; emuctrl_actions[i].name != NULL; i++) {
if (emuctrl_actions[i].mask & binds[t]) { if (emuctrl_actions[i].mask & binds[t]) {
strncpy(act, emuctrl_actions[i].name, 31); strncpy(act, emuctrl_actions[i].name, 31);
fprintf(fn, "%s %s = %s" NL, bind_str, names[t], mystrip(act)); fprintf(fn, "%s %s = %s" NL, bind_str, name, mystrip(act));
} }
} }
} }
@ -281,8 +294,9 @@ static int default_var(const menu_entry *me)
case MA_CDOPT_LEDS: case MA_CDOPT_LEDS:
return defaultConfig.EmuOpt; return defaultConfig.EmuOpt;
case MA_CTRL_TURBO_RATE: case MA_CTRL_TURBO_RATE: return defaultConfig.turbo_rate;
return defaultConfig.turbo_rate; case MA_OPT_SCALING: return defaultConfig.scaling;
case MA_OPT_ROTATION: return defaultConfig.rotation;
case MA_OPT_SAVE_SLOT: case MA_OPT_SAVE_SLOT:
default: default:
@ -384,11 +398,13 @@ write:
} }
// save key config // save key config
keys_write(fn, "bind", currentConfig.KeyBinds, defaultConfig.KeyBinds, keyNames, no_defaults); keys_write(fn, "bind", currentConfig.KeyBinds, defaultConfig.KeyBinds, keyNames, PLAT_MAX_KEYS, no_defaults);
keys_write(fn, "bind_joy0", currentConfig.JoyBinds[0], defaultConfig.JoyBinds[0], joyKeyNames, 1); #if PLAT_HAVE_JOY
keys_write(fn, "bind_joy1", currentConfig.JoyBinds[1], defaultConfig.JoyBinds[1], joyKeyNames, 1); keys_write(fn, "bind_joy0", currentConfig.JoyBinds[0], defaultConfig.JoyBinds[0], joyKeyNames, 32, 1);
keys_write(fn, "bind_joy2", currentConfig.JoyBinds[2], defaultConfig.JoyBinds[2], joyKeyNames, 1); keys_write(fn, "bind_joy1", currentConfig.JoyBinds[1], defaultConfig.JoyBinds[1], joyKeyNames, 32, 1);
keys_write(fn, "bind_joy3", currentConfig.JoyBinds[3], defaultConfig.JoyBinds[3], joyKeyNames, 1); keys_write(fn, "bind_joy2", currentConfig.JoyBinds[2], defaultConfig.JoyBinds[2], joyKeyNames, 32, 1);
keys_write(fn, "bind_joy3", currentConfig.JoyBinds[3], defaultConfig.JoyBinds[3], joyKeyNames, 32, 1);
#endif
#ifndef PSP #ifndef PSP
if (section == NULL) if (section == NULL)
@ -423,7 +439,7 @@ int config_writelrom(const char *fname)
int size; int size;
FILE *f; FILE *f;
if (strlen(lastRomFile) == 0) return -1; if (strlen(loadedRomFName) == 0) return -1;
f = fopen(fname, "r"); f = fopen(fname, "r");
if (f != NULL) if (f != NULL)
@ -456,7 +472,7 @@ int config_writelrom(const char *fname)
fwrite(old_data, 1, optr - old_data, f); fwrite(old_data, 1, optr - old_data, f);
free(old_data); free(old_data);
} }
fprintf(f, "LastUsedROM = %s" NL, lastRomFile); fprintf(f, "LastUsedROM = %s" NL, loadedRomFName);
fclose(f); fclose(f);
return 0; return 0;
} }
@ -487,9 +503,9 @@ int config_readlrom(const char *fname)
tmp++; tmp++;
mystrip(tmp); mystrip(tmp);
len = sizeof(lastRomFile); len = sizeof(loadedRomFName);
strncpy(lastRomFile, tmp, len); strncpy(loadedRomFName, tmp, len);
lastRomFile[len-1] = 0; loadedRomFName[len-1] = 0;
ret = 0; ret = 0;
break; break;
} }
@ -686,16 +702,29 @@ static int custom_read(menu_entry *me, const char *var, const char *val)
static unsigned int keys_encountered = 0; static unsigned int keys_encountered = 0;
static void keys_parse(const char *var, const char *val, int binds[32], const char * const names[32]) static void keys_parse(const char *var, const char *val, int binds[32],
const char * const names[32], int max_keys)
{ {
int t, i; int t, i;
unsigned int player; unsigned int player;
for (t = 0; t < 32; t++) for (t = 0; t < 32; t++)
{ {
if (strcmp(names[t], var) == 0) break; if (names[t] && strcmp(names[t], var) == 0) break;
} }
if (t == 32) { if (t == 32)
{
int len = strlen(var);
if (len == 1) t = var[0];
else if (len >= 4 && var[0] == '\\' && var[1] == 'x') {
char *p;
t = (int)strtoul(var + 2, &p, 16);
if (*p != 0) t = max_keys; // parse failed
}
else
t = max_keys; // invalid
}
if (t < 0 || t >= max_keys) {
lprintf("unhandled bind \"%s\"\n", var); lprintf("unhandled bind \"%s\"\n", var);
return; return;
} }
@ -732,7 +761,7 @@ fail:
#define try_joy_parse(num) { \ #define try_joy_parse(num) { \
if (strncasecmp(var, "bind_joy"#num " ", 10) == 0) { \ if (strncasecmp(var, "bind_joy"#num " ", 10) == 0) { \
keys_parse(var + 10, val, currentConfig.JoyBinds[num], joyKeyNames); \ keys_parse(var + 10, val, currentConfig.JoyBinds[num], joyKeyNames, 32); \
return; \ return; \
} \ } \
} }
@ -752,13 +781,15 @@ static void parse(const char *var, const char *val)
// key binds // key binds
if (strncasecmp(var, "bind ", 5) == 0) { if (strncasecmp(var, "bind ", 5) == 0) {
keys_parse(var + 5, val, currentConfig.KeyBinds, keyNames); keys_parse(var + 5, val, currentConfig.KeyBinds, keyNames, PLAT_MAX_KEYS);
return; return;
} }
#if PLAT_HAVE_JOY
try_joy_parse(0) try_joy_parse(0)
try_joy_parse(1) try_joy_parse(1)
try_joy_parse(2) try_joy_parse(2)
try_joy_parse(3) try_joy_parse(3)
#endif
for (t = 0; t < sizeof(cfg_opts) / sizeof(cfg_opts[0]) && ret == 0; t++) for (t = 0; t < sizeof(cfg_opts) / sizeof(cfg_opts[0]) && ret == 0; t++)
{ {

View file

@ -26,10 +26,10 @@
char *PicoConfigFile = "config.cfg"; char *PicoConfigFile = "config.cfg";
currentConfig_t currentConfig, defaultConfig; currentConfig_t currentConfig, defaultConfig;
int rom_loaded = 0; int rom_loaded = 0;
char noticeMsg[64]; char noticeMsg[64] = { 0, };
int state_slot = 0; int state_slot = 0;
int config_slot = 0, config_slot_current = 0; int config_slot = 0, config_slot_current = 0;
char lastRomFile[512]; char loadedRomFName[512] = { 0, };
int kb_combo_keys = 0, kb_combo_acts = 0; // keys and actions which need button combos int kb_combo_keys = 0, kb_combo_acts = 0; // keys and actions which need button combos
int pico_inp_mode = 0; int pico_inp_mode = 0;
@ -37,10 +37,8 @@ unsigned char *movie_data = NULL;
static int movie_size = 0; static int movie_size = 0;
// provided by platform code: // provided by platform code:
extern char romFileName[];
extern void emu_noticeMsgUpdated(void); extern void emu_noticeMsgUpdated(void);
extern void emu_getMainDir(char *dst, int len); extern int emu_getMainDir(char *dst, int len);
extern void emu_setDefaultConfig(void);
extern void menu_romload_prepare(const char *rom_name); extern void menu_romload_prepare(const char *rom_name);
extern void menu_romload_end(void); extern void menu_romload_end(void);
@ -51,17 +49,17 @@ static void strlwr_(char* string)
while ( (*string++ = (char)tolower(*string)) ); while ( (*string++ = (char)tolower(*string)) );
} }
static int try_rfn_cut(void) static int try_rfn_cut(char *fname)
{ {
FILE *tmp; FILE *tmp;
char *p; char *p;
p = romFileName + strlen(romFileName) - 1; p = fname + strlen(fname) - 1;
for (; p > romFileName; p--) for (; p > fname; p--)
if (*p == '.') break; if (*p == '.') break;
*p = 0; *p = 0;
if((tmp = fopen(romFileName, "rb"))) { if((tmp = fopen(fname, "rb"))) {
fclose(tmp); fclose(tmp);
return 1; return 1;
} }
@ -147,20 +145,20 @@ static int emu_isBios(const char *name)
static unsigned char id_header[0x100]; static unsigned char id_header[0x100];
/* checks if romFileName points to valid MegaCD image /* checks if fname points to valid MegaCD image
* if so, checks for suitable BIOS */ * if so, checks for suitable BIOS */
int emu_cdCheck(int *pregion) int emu_cdCheck(int *pregion, char *fname_in)
{ {
unsigned char buf[32]; unsigned char buf[32];
pm_file *cd_f; pm_file *cd_f;
int region = 4; // 1: Japan, 4: US, 8: Europe int region = 4; // 1: Japan, 4: US, 8: Europe
char ext[5], *fname = romFileName; char ext[5], *fname = fname_in;
cue_track_type type = CT_UNKNOWN; cue_track_type type = CT_UNKNOWN;
cue_data_t *cue_data = NULL; cue_data_t *cue_data = NULL;
get_ext(romFileName, ext); get_ext(fname_in, ext);
if (strcasecmp(ext, ".cue") == 0) { if (strcasecmp(ext, ".cue") == 0) {
cue_data = cue_parse(romFileName); cue_data = cue_parse(fname_in);
if (cue_data != NULL) { if (cue_data != NULL) {
fname = cue_data->tracks[1].fname; fname = cue_data->tracks[1].fname;
type = cue_data->tracks[1].type; type = cue_data->tracks[1].type;
@ -248,7 +246,7 @@ static int extract_text(char *dest, const unsigned char *src, int len, int swab)
char *emu_makeRomId(void) char *emu_makeRomId(void)
{ {
static char id_string[3+0x11+0x11+0x30+16]; static char id_string[3+0xe*3+0x3*3+0x30*3+3];
int pos, swab = 1; int pos, swab = 1;
if (PicoAHW & PAHW_MCD) { if (PicoAHW & PAHW_MCD) {
@ -268,18 +266,36 @@ char *emu_makeRomId(void)
return id_string; return id_string;
} }
int emu_ReloadRom(void) // buffer must be at least 150 byte long
void emu_getGameName(char *str150)
{
int ret, swab = (PicoAHW & PAHW_MCD) ? 0 : 1;
char *s, *d;
ret = extract_text(str150, id_header + 0x50, 0x30, swab); // overseas name
for (s = d = str150 + 1; s < str150+ret; s++)
{
if (*s == 0) break;
if (*s != ' ' || d[-1] != ' ')
*d++ = *s;
}
*d = 0;
}
// note: this function might mangle rom_fname
int emu_ReloadRom(char *rom_fname)
{ {
unsigned int rom_size = 0; unsigned int rom_size = 0;
char *used_rom_name = romFileName; char *used_rom_name = rom_fname;
unsigned char *rom_data = NULL; unsigned char *rom_data = NULL;
char ext[5]; char ext[5];
pm_file *rom = NULL; pm_file *rom = NULL;
int ret, cd_state, cd_region, cfg_loaded = 0; int ret, cd_state, cd_region, cfg_loaded = 0;
lprintf("emu_ReloadRom(%s)\n", romFileName); lprintf("emu_ReloadRom(%s)\n", rom_fname);
get_ext(romFileName, ext); get_ext(rom_fname, ext);
// detect wrong extensions // detect wrong extensions
if (!strcmp(ext, ".srm") || !strcmp(ext, "s.gz") || !strcmp(ext, ".mds")) { // s.gz ~ .mds.gz if (!strcmp(ext, ".srm") || !strcmp(ext, "s.gz") || !strcmp(ext, ".mds")) { // s.gz ~ .mds.gz
@ -298,7 +314,7 @@ int emu_ReloadRom(void)
{ {
// check for both gmv and rom // check for both gmv and rom
int dummy; int dummy;
FILE *movie_file = fopen(romFileName, "rb"); FILE *movie_file = fopen(rom_fname, "rb");
if(!movie_file) { if(!movie_file) {
sprintf(menuErrorMsg, "Failed to open movie."); sprintf(menuErrorMsg, "Failed to open movie.");
return 0; return 0;
@ -323,29 +339,29 @@ int emu_ReloadRom(void)
sprintf(menuErrorMsg, "Invalid GMV file."); sprintf(menuErrorMsg, "Invalid GMV file.");
return 0; return 0;
} }
dummy = try_rfn_cut() || try_rfn_cut(); dummy = try_rfn_cut(rom_fname) || try_rfn_cut(rom_fname);
if (!dummy) { if (!dummy) {
sprintf(menuErrorMsg, "Could't find a ROM for movie."); sprintf(menuErrorMsg, "Could't find a ROM for movie.");
return 0; return 0;
} }
get_ext(romFileName, ext); get_ext(rom_fname, ext);
} }
else if (!strcmp(ext, ".pat")) { else if (!strcmp(ext, ".pat"))
{
int dummy; int dummy;
PicoPatchLoad(romFileName); PicoPatchLoad(rom_fname);
dummy = try_rfn_cut() || try_rfn_cut(); dummy = try_rfn_cut(rom_fname) || try_rfn_cut(rom_fname);
if (!dummy) { if (!dummy) {
sprintf(menuErrorMsg, "Could't find a ROM to patch."); sprintf(menuErrorMsg, "Could't find a ROM to patch.");
return 0; return 0;
} }
get_ext(romFileName, ext); get_ext(rom_fname, ext);
} }
if ((PicoAHW & PAHW_MCD) && Pico_mcd != NULL) emu_shutdownMCD();
Stop_CD();
// check for MegaCD image // check for MegaCD image
cd_state = emu_cdCheck(&cd_region); cd_state = emu_cdCheck(&cd_region, rom_fname);
if (cd_state >= 0 && cd_state != CIT_NOT_CD) if (cd_state >= 0 && cd_state != CIT_NOT_CD)
{ {
PicoAHW |= PAHW_MCD; PicoAHW |= PAHW_MCD;
@ -422,7 +438,7 @@ int emu_ReloadRom(void)
// insert CD if it was detected // insert CD if it was detected
if (cd_state != CIT_NOT_CD) { if (cd_state != CIT_NOT_CD) {
ret = Insert_CD(romFileName, cd_state); ret = Insert_CD(rom_fname, cd_state);
if (ret != 0) { if (ret != 0) {
sprintf(menuErrorMsg, "Insert_CD() failed, invalid CD image?"); sprintf(menuErrorMsg, "Insert_CD() failed, invalid CD image?");
lprintf("%s\n", menuErrorMsg); lprintf("%s\n", menuErrorMsg);
@ -468,11 +484,11 @@ int emu_ReloadRom(void)
emu_noticeMsgUpdated(); emu_noticeMsgUpdated();
// load SRAM for this ROM // load SRAM for this ROM
if (currentConfig.EmuOpt & 1) if (currentConfig.EmuOpt & EOPT_USE_SRAM)
emu_SaveLoadGame(1, 1); emu_SaveLoadGame(1, 1);
strncpy(lastRomFile, romFileName, sizeof(lastRomFile)-1); strncpy(loadedRomFName, rom_fname, sizeof(loadedRomFName)-1);
lastRomFile[sizeof(lastRomFile)-1] = 0; loadedRomFName[sizeof(loadedRomFName)-1] = 0;
rom_loaded = 1; rom_loaded = 1;
return 1; return 1;
@ -484,18 +500,30 @@ fail:
} }
void emu_shutdownMCD(void)
{
if ((PicoAHW & PAHW_MCD) && Pico_mcd != NULL)
Stop_CD();
PicoAHW &= ~PAHW_MCD;
}
static void romfname_ext(char *dst, const char *prefix, const char *ext) static void romfname_ext(char *dst, const char *prefix, const char *ext)
{ {
char *p; char *p;
int prefix_len = 0; int prefix_len = 0;
// make save filename // make save filename
for (p = romFileName+strlen(romFileName)-1; p >= romFileName && *p != '/'; p--); p++; p = loadedRomFName+strlen(loadedRomFName)-1;
for (; p >= loadedRomFName && *p != PATH_SEP_C; p--); p++;
*dst = 0; *dst = 0;
if (prefix) { if (prefix) {
strcpy(dst, prefix); int len = emu_getMainDir(dst, 512);
prefix_len = strlen(prefix); strcpy(dst + len, prefix);
prefix_len = len + strlen(prefix);
} }
#ifdef UIQ3
else p = loadedRomFName; // backward compatibility
#endif
strncpy(dst + prefix_len, p, 511-prefix_len); strncpy(dst + prefix_len, p, 511-prefix_len);
dst[511-8] = 0; dst[511-8] = 0;
if (dst[strlen(dst)-4] == '.') dst[strlen(dst)-4] = 0; if (dst[strlen(dst)-4] == '.') dst[strlen(dst)-4] = 0;
@ -505,7 +533,9 @@ static void romfname_ext(char *dst, const char *prefix, const char *ext)
static void make_config_cfg(char *cfg) static void make_config_cfg(char *cfg)
{ {
strncpy(cfg, PicoConfigFile, 511); int len;
len = emu_getMainDir(cfg, 512);
strncpy(cfg + len, PicoConfigFile, 512-6-1-len);
if (config_slot != 0) if (config_slot != 0)
{ {
char *p = strrchr(cfg, '.'); char *p = strrchr(cfg, '.');
@ -515,10 +545,34 @@ static void make_config_cfg(char *cfg)
cfg[511] = 0; cfg[511] = 0;
} }
void emu_packConfig(void)
{
currentConfig.s_PicoOpt = PicoOpt;
currentConfig.s_PsndRate = PsndRate;
currentConfig.s_PicoRegion = PicoRegionOverride;
currentConfig.s_PicoAutoRgnOrder = PicoAutoRgnOrder;
currentConfig.s_PicoCDBuffers = PicoCDBuffers;
}
void emu_unpackConfig(void)
{
PicoOpt = currentConfig.s_PicoOpt;
PsndRate = currentConfig.s_PsndRate;
PicoRegionOverride = currentConfig.s_PicoRegion;
PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;
PicoCDBuffers = currentConfig.s_PicoCDBuffers;
}
static void emu_setDefaultConfig(void)
{
memcpy(&currentConfig, &defaultConfig, sizeof(currentConfig));
emu_unpackConfig();
}
int emu_ReadConfig(int game, int no_defaults) int emu_ReadConfig(int game, int no_defaults)
{ {
char cfg[512]; char cfg[512];
FILE *f;
int ret; int ret;
if (!game) if (!game)
@ -554,37 +608,7 @@ int emu_ReadConfig(int game, int no_defaults)
ret = config_readsect("game_def.cfg", sect); ret = config_readsect("game_def.cfg", sect);
} }
if (ret != 0) if (ret == 0)
{
// fall back to old game specific cfg
char extbuf[16];
if (config_slot != 0)
sprintf(extbuf, ".%i.pbcfg", config_slot);
else strcpy(extbuf, ".pbcfg");
romfname_ext(cfg, "cfg/", extbuf);
f = fopen(cfg, "rb");
if (!f) {
romfname_ext(cfg, NULL, ".pbcfg");
f = fopen(cfg, "rb");
}
if (f) {
int bread;
fseek(f, 512, SEEK_SET); // skip unused lrom buffer
bread = fread(&currentConfig, 1, sizeof(currentConfig), f);
lprintf("emu_ReadConfig: %s %s\n", cfg, bread > 0 ? "(ok)" : "(failed)");
fclose(f);
ret = 0;
}
if (ret == 0) {
PicoOpt = currentConfig.s_PicoOpt;
PsndRate = currentConfig.s_PsndRate;
PicoRegionOverride = currentConfig.s_PicoRegion;
PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;
// PicoCDBuffers = currentConfig.s_PicoCDBuffers; // ignore in this case
}
}
else
{ {
lprintf("loaded cfg from sect \"%s\"\n", sect); lprintf("loaded cfg from sect \"%s\"\n", sect);
} }
@ -618,14 +642,7 @@ int emu_WriteConfig(int is_game)
if (!is_game) if (!is_game)
{ {
strncpy(cfg, PicoConfigFile, 511); make_config_cfg(cfg);
if (config_slot != 0)
{
char *p = strrchr(cfg, '.');
if (p == NULL) p = cfg + strlen(cfg);
sprintf(p, ".%i.cfg", config_slot);
}
cfg[511] = 0;
write_lrom = 1; write_lrom = 1;
} else { } else {
if (config_slot != 0) if (config_slot != 0)
@ -648,6 +665,7 @@ int emu_WriteConfig(int is_game)
} }
#ifndef UIQ3
void emu_textOut8(int x, int y, const char *text) void emu_textOut8(int x, int y, const char *text)
{ {
int i,l,len=strlen(text); int i,l,len=strlen(text);
@ -694,6 +712,7 @@ void emu_textOut16(int x, int y, const char *text)
screen += 8; screen += 8;
} }
} }
#endif
#ifdef PSP #ifdef PSP
#define MAX_COMBO_KEY 23 #define MAX_COMBO_KEY 23
@ -802,7 +821,7 @@ char *emu_GetSaveFName(int load, int is_sram, int slot)
if (is_sram) if (is_sram)
{ {
romfname_ext(saveFname, (PicoAHW&1) ? "brm/" : "srm/", (PicoAHW&1) ? ".brm" : ".srm"); romfname_ext(saveFname, (PicoAHW&1) ? "brm"PATH_SEP : "srm"PATH_SEP, (PicoAHW&1) ? ".brm" : ".srm");
if (load) { if (load) {
if (try_ropen_file(saveFname)) return saveFname; if (try_ropen_file(saveFname)) return saveFname;
// try in current dir.. // try in current dir..
@ -815,19 +834,21 @@ char *emu_GetSaveFName(int load, int is_sram, int slot)
{ {
ext[0] = 0; ext[0] = 0;
if(slot > 0 && slot < 10) sprintf(ext, ".%i", slot); if(slot > 0 && slot < 10) sprintf(ext, ".%i", slot);
strcat(ext, (currentConfig.EmuOpt & 8) ? ".mds.gz" : ".mds"); strcat(ext, (currentConfig.EmuOpt & EOPT_GZIP_SAVES) ? ".mds.gz" : ".mds");
romfname_ext(saveFname, "mds/", ext); romfname_ext(saveFname, "mds" PATH_SEP, ext);
if (load) { if (load) {
if (try_ropen_file(saveFname)) return saveFname; if (try_ropen_file(saveFname)) return saveFname;
romfname_ext(saveFname, NULL, ext); romfname_ext(saveFname, NULL, ext);
if (try_ropen_file(saveFname)) return saveFname; if (try_ropen_file(saveFname)) return saveFname;
if (currentConfig.EmuOpt & 8) { // no gzipped states, search for non-gzipped
if (currentConfig.EmuOpt & EOPT_GZIP_SAVES)
{
ext[0] = 0; ext[0] = 0;
if(slot > 0 && slot < 10) sprintf(ext, ".%i", slot); if(slot > 0 && slot < 10) sprintf(ext, ".%i", slot);
strcat(ext, ".mds"); strcat(ext, ".mds");
romfname_ext(saveFname, "mds/", ext); romfname_ext(saveFname, "mds"PATH_SEP, ext);
if (try_ropen_file(saveFname)) return saveFname; if (try_ropen_file(saveFname)) return saveFname;
romfname_ext(saveFname, NULL, ext); romfname_ext(saveFname, NULL, ext);
if (try_ropen_file(saveFname)) return saveFname; if (try_ropen_file(saveFname)) return saveFname;

View file

@ -3,7 +3,18 @@
// For commercial use, separate licencing terms must be obtained. // For commercial use, separate licencing terms must be obtained.
typedef struct { #include "port_config.h"
#ifdef __cplusplus
extern "C" {
#endif
#define EOPT_USE_SRAM (1<<0)
#define EOPT_SHOW_FPS (1<<1)
#define EOPT_EN_SOUND (1<<2)
#define EOPT_GZIP_SAVES (1<<3)
typedef struct _currentConfig_t {
// char lastRomFile[512]; // char lastRomFile[512];
int EmuOpt; // LSb->MSb: use_sram, show_fps, enable_sound, gzip_saves, int EmuOpt; // LSb->MSb: use_sram, show_fps, enable_sound, gzip_saves,
// squidgehack, no_save_cfg_on_exit, <unused>, 16_bit_mode // squidgehack, no_save_cfg_on_exit, <unused>, 16_bit_mode
@ -13,15 +24,18 @@ typedef struct {
int s_PicoOpt; // for old cfg files only int s_PicoOpt; // for old cfg files only
int s_PsndRate; int s_PsndRate;
int s_PicoRegion; int s_PicoRegion;
int Frameskip;
int CPUclock;
int KeyBinds[32];
int volume;
int gamma;
int JoyBinds[4][32];
int s_PicoAutoRgnOrder; int s_PicoAutoRgnOrder;
int s_PicoCDBuffers; int s_PicoCDBuffers;
int scaling; // gp2x: 0=center, 1=hscale, 2=hvscale, 3=hsoftscale; psp: bilinear filtering int Frameskip;
int CPUclock;
int KeyBinds[PLAT_MAX_KEYS];
int volume;
int gamma;
#if PLAT_HAVE_JOY
int JoyBinds[4][32];
#endif
int scaling; // gp2x: 0=center, 1=hscale, 2=hvscale, 3=hsoftscale; psp: bilinear filtering
int rotation; // for UIQ
float scale; // psp: screen scale float scale; // psp: screen scale
float hscale32, hscale40; // psp: horizontal scale float hscale32, hscale40; // psp: horizontal scale
int gamma2; // psp: black level int gamma2; // psp: black level
@ -35,12 +49,12 @@ extern char noticeMsg[64];
extern int state_slot; extern int state_slot;
extern int config_slot, config_slot_current; extern int config_slot, config_slot_current;
extern unsigned char *movie_data; extern unsigned char *movie_data;
extern char lastRomFile[512]; 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 kb_combo_keys, kb_combo_acts; // keys and actions which need button combos
extern int pico_inp_mode; extern int pico_inp_mode;
int emu_ReloadRom(void); int emu_ReloadRom(char *rom_fname);
int emu_SaveLoadGame(int load, int sram); int emu_SaveLoadGame(int load, int sram);
int emu_ReadConfig(int game, int no_defaults); int emu_ReadConfig(int game, int no_defaults);
int emu_WriteConfig(int game); int emu_WriteConfig(int game);
@ -48,17 +62,26 @@ char *emu_GetSaveFName(int load, int is_sram, int slot);
int emu_checkSaveFile(int slot); int emu_checkSaveFile(int slot);
void emu_setSaveStateCbs(int gz); void emu_setSaveStateCbs(int gz);
void emu_updateMovie(void); void emu_updateMovie(void);
int emu_cdCheck(int *pregion); int emu_cdCheck(int *pregion, char *fname_in);
int emu_findBios(int region, char **bios_file); int emu_findBios(int region, char **bios_file);
void emu_textOut8 (int x, int y, const char *text); void emu_textOut8 (int x, int y, const char *text);
void emu_textOut16(int x, int y, const char *text); void emu_textOut16(int x, int y, const char *text);
char *emu_makeRomId(void); char *emu_makeRomId(void);
void emu_getGameName(char *str150);
void emu_findKeyBindCombos(void); void emu_findKeyBindCombos(void);
void emu_forcedFrame(int opts); void emu_forcedFrame(int opts);
void emu_changeFastForward(int set_on); void emu_changeFastForward(int set_on);
void emu_RunEventsPico(unsigned int events); void emu_RunEventsPico(unsigned int events);
void emu_DoTurbo(int *pad, int acts); void emu_DoTurbo(int *pad, int acts);
void emu_packConfig(void);
void emu_unpackConfig(void);
void emu_shutdownMCD(void);
extern const char * const keyNames[]; extern const char * const keyNames[];
void emu_prepareDefaultConfig(void); void emu_prepareDefaultConfig(void);
void emu_platformDebugCat(char *str); void emu_platformDebugCat(char *str);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -39,6 +39,8 @@ me_bind_action me_ctrl_actions[15] =
}; };
#ifndef UIQ3
static unsigned char menu_font_data[10240]; static unsigned char menu_font_data[10240];
static int menu_text_color = 0xffff; // default to white static int menu_text_color = 0xffff; // default to white
static int menu_sel_color = -1; // disabled static int menu_sel_color = -1; // disabled
@ -331,28 +333,6 @@ int me_process(menu_entry *entries, int count, menu_id id, int is_next)
} }
} }
const char *me_region_name(unsigned int code, int auto_order)
{
static const char *names[] = { "Auto", " Japan NTSC", " Japan PAL", " USA", " Europe" };
static const char *names_short[] = { "", " JP", " JP", " US", " EU" };
int u, i = 0;
if (code) {
code <<= 1;
while((code >>= 1)) i++;
if (i > 4) return "unknown";
return names[i];
} else {
static char name[24];
strcpy(name, "Auto:");
for (u = 0; u < 3; u++) {
i = 0; code = ((auto_order >> u*4) & 0xf) << 1;
while((code >>= 1)) i++;
strcat(name, names_short[i]);
}
return name;
}
}
// ------------ debug menu ------------ // ------------ debug menu ------------
#include <sys/stat.h> #include <sys/stat.h>
@ -472,4 +452,30 @@ void debug_menu_loop(void)
} }
} }
#endif // !UIQ3
// ------------ util ------------
const char *me_region_name(unsigned int code, int auto_order)
{
static const char *names[] = { "Auto", " Japan NTSC", " Japan PAL", " USA", " Europe" };
static const char *names_short[] = { "", " JP", " JP", " US", " EU" };
int u, i = 0;
if (code) {
code <<= 1;
while((code >>= 1)) i++;
if (i > 4) return "unknown";
return names[i];
} else {
static char name[24];
strcpy(name, "Auto:");
for (u = 0; u < 3; u++) {
i = 0; code = ((auto_order >> u*4) & 0xf) << 1;
while((code >>= 1)) i++;
strcat(name, names_short[i]);
}
return name;
}
}

View file

@ -52,6 +52,7 @@ typedef enum
MA_OPT_SAVECFG_GAME, MA_OPT_SAVECFG_GAME,
MA_OPT_LOADCFG, MA_OPT_LOADCFG,
MA_OPT_INTERLACED, /* giz */ MA_OPT_INTERLACED, /* giz */
MA_OPT_ROTATION, /* uiq */
MA_OPT2_GAMMA, MA_OPT2_GAMMA,
MA_OPT2_A_SN_GAMMA, MA_OPT2_A_SN_GAMMA,
MA_OPT2_DBLBUFF, /* giz */ MA_OPT2_DBLBUFF, /* giz */

View file

@ -44,16 +44,17 @@ endif
ifeq "$(profile)" "2" ifeq "$(profile)" "2"
COPT_COMMON += -fprofile-use COPT_COMMON += -fprofile-use
endif endif
COPT = $(COPT_COMMON) -mtune=arm920t CFLAGS = $(COPT_COMMON) -mcpu=arm920t -mtune=arm920t
ASOPT = -mcpu=arm920t -mfloat-abi=soft SFLAGS = $(CFLAGS)
GCC = $(CROSS)gcc ASFLAGS = -mcpu=arm920t -mfloat-abi=soft
CC = $(CROSS)gcc
STRIP = $(CROSS)strip STRIP = $(CROSS)strip
AS = $(CROSS)as AS = $(CROSS)as
LD = $(CROSS)ld LD = $(CROSS)ld
OBJCOPY = $(CROSS)objcopy OBJCOPY = $(CROSS)objcopy
# frontend # frontend
OBJS += main.o menu.o gp2x.o usbjoy.o emu.o squidgehack.o cpuctrl.o OBJS += main.o menu.o gp2x.o usbjoy.o emu.o squidgehack.o cpuctrl.o asm_utils.o
# 940 core control # 940 core control
OBJS += 940ctl.o OBJS += 940ctl.o
@ -149,7 +150,7 @@ all: mkdirs PicoDrive.gpe
PicoDrive.gpe : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a PicoDrive.gpe : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a
@echo ">>>" $@ @echo ">>>" $@
$(GCC) -o $@ $(COPT) $^ -lm -lpng -Wl,-Map=PicoDrive.map $(CC) -o $@ $(CFLAGS) $^ -lm -lpng -Wl,-Map=PicoDrive.map
ifeq ($(DEBUG),) ifeq ($(DEBUG),)
$(STRIP) $@ $(STRIP) $@
endif endif
@ -168,75 +169,10 @@ tidy:
# @make -C ../../cpu/Cyclone/proj -f Makefile.linux clean # @make -C ../../cpu/Cyclone/proj -f Makefile.linux clean
clean_prof:
find ../.. -name '*.gcno' -delete
find ../.. -name '*.gcda' -delete
mkdirs:
mkdir -p $(DIRS)
.c.o:
@echo ">>>" $<
$(GCC) $(COPT) $(DEFINC) -c $< -o $@
.s.o:
@echo ">>>" $<
$(GCC) $(COPT) $(DEFINC) -c $< -o $@
.S.o:
@echo ">>>" $<
$(GCC) $(COPT) $(DEFINC) -c $< -o $@
Pico/carthw/svp/compiler.o : ../../Pico/carthw/svp/ssp16.o ../../Pico/carthw/svp/gen_arm.c
Pico/draw_asm.o : ../../Pico/Draw.s
@echo ">>>" $<
$(AS) $(ASOPT) $< -o $@
Pico/draw2_asm.o : ../../Pico/Draw2.s
@echo ">>>" $<
$(AS) $(ASOPT) $< -o $@
Pico/memory_asm.o : ../../Pico/Memory.s
@echo ">>>" $<
$(AS) $(ASOPT) $< -o $@
Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s
@echo ">>>" $<
$(AS) $(ASOPT) $< -o $@
Pico/sound/mix_asm.o : ../../Pico/sound/mix.s
@echo ">>>" $<
$(AS) $(ASOPT) $< -o $@
Pico/misc_asm.o : ../../Pico/Misc.s
@echo ">>>" $<
$(AS) $(ASOPT) $< -o $@
Pico/cd/pico_asm.o : ../../Pico/cd/Pico.s
@echo ">>>" $<
$(AS) $(ASOPT) $< -o $@
Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s
@echo ">>>" $<
$(AS) $(ASOPT) $< -o $@
Pico/cd/misc_asm.o : ../../Pico/cd/Misc.s
@echo ">>>" $<
$(AS) $(ASOPT) $< -o $@
# build Cyclone
../../cpu/Cyclone/proj/Cyclone.s :
@echo building Cyclone...
@make -C ../../cpu/Cyclone/proj CONFIG_FILE=config_pico.h
../../cpu/musashi/m68kops.c :
@make -C ../../cpu/musashi
Pico/Pico.o Pico/cd/Pico.o: ../../Pico/PicoFrameHints.c ../../Pico/PicoInt.h
Pico/Memory.o Pico/cd/Memory.o : ../../Pico/MemoryCmn.c ../../Pico/PicoInt.h
# build helix libs
../common/helix/$(CROSS)helix-mp3.a:
make -C ../common/helix clean all
readme.txt: ../../tools/textfilter ../base_readme.txt readme.txt: ../../tools/textfilter ../base_readme.txt
../../tools/textfilter ../base_readme.txt $@ GP2X ../../tools/textfilter ../base_readme.txt $@ GP2X
../../tools/textfilter: ../../tools/textfilter.c include ../common/common_arm.mak
make -C ../../tools/ textfilter
# ----------- release ----------- # ----------- release -----------
ifneq ($(findstring rel,$(MAKECMDGOALS)),) ifneq ($(findstring rel,$(MAKECMDGOALS)),)

View file

@ -49,7 +49,6 @@ static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
static struct timeval noticeMsgTime = { 0, 0 }; // when started showing static struct timeval noticeMsgTime = { 0, 0 }; // when started showing
static int osd_fps_x; static int osd_fps_x;
static int gp2x_old_gamma = 100; static int gp2x_old_gamma = 100;
char noticeMsg[64]; // notice msg to draw
unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer
int reset_timing = 0; int reset_timing = 0;
@ -66,7 +65,7 @@ void emu_noticeMsgUpdated(void)
gettimeofday(&noticeMsgTime, 0); gettimeofday(&noticeMsgTime, 0);
} }
void emu_getMainDir(char *dst, int len) int emu_getMainDir(char *dst, int len)
{ {
extern char **g_argv; extern char **g_argv;
int j; int j;
@ -77,6 +76,8 @@ void emu_getMainDir(char *dst, int len)
dst[len] = 0; dst[len] = 0;
for (j = strlen(dst); j > 0; j--) for (j = strlen(dst); j > 0; j--)
if (dst[j] == '/') { dst[j+1] = 0; break; } if (dst[j] == '/') { dst[j+1] = 0; break; }
return j + 1;
} }
void emu_Init(void) void emu_Init(void)
@ -167,16 +168,6 @@ void emu_prepareDefaultConfig(void)
defaultConfig.turbo_rate = 15; defaultConfig.turbo_rate = 15;
} }
void emu_setDefaultConfig(void)
{
memcpy(&currentConfig, &defaultConfig, sizeof(currentConfig));
PicoOpt = currentConfig.s_PicoOpt;
PsndRate = currentConfig.s_PsndRate;
PicoRegionOverride = currentConfig.s_PicoRegion;
PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;
PicoCDBuffers = currentConfig.s_PicoCDBuffers;
}
void osd_text(int x, int y, const char *text) void osd_text(int x, int y, const char *text)
{ {
int len = strlen(text)*8; int len = strlen(text)*8;

View file

@ -118,7 +118,7 @@ int main(int argc, char *argv[])
if (engineState == PGS_ReloadRom) if (engineState == PGS_ReloadRom)
{ {
if (emu_ReloadRom()) { if (emu_ReloadRom(romFileName)) {
engineState = PGS_Running; engineState = PGS_Running;
if (load_state_slot >= 0) { if (load_state_slot >= 0) {
state_slot = load_state_slot; state_slot = load_state_slot;
@ -136,7 +136,7 @@ int main(int argc, char *argv[])
break; break;
case PGS_ReloadRom: case PGS_ReloadRom:
if (emu_ReloadRom()) if (emu_ReloadRom(romFileName))
engineState = PGS_Running; engineState = PGS_Running;
else { else {
printf("PGS_ReloadRom == 0\n"); printf("PGS_ReloadRom == 0\n");

View file

@ -901,7 +901,7 @@ menu_entry cdopt_entries[] =
{ NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 }, { NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 },
{ NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 }, { NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 },
{ "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, &currentConfig.EmuOpt, 0x0400, 0, 0, 1, 1 }, { "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, &currentConfig.EmuOpt, 0x0400, 0, 0, 1, 1 },
{ "CDDA audio (using mp3s)", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 }, { "CDDA audio", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 },
{ "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoOpt, 0x0400, 0, 0, 1, 1 }, { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoOpt, 0x0400, 0, 0, 1, 1 },
{ NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 }, { NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 },
{ "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoOpt, 0x8000, 0, 0, 1, 1 }, { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoOpt, 0x8000, 0, 0, 1, 1 },
@ -1551,10 +1551,10 @@ static void menu_loop_root(void)
{ {
char curr_path[PATH_MAX], *selfname; char curr_path[PATH_MAX], *selfname;
FILE *tstf; FILE *tstf;
if ( (tstf = fopen(lastRomFile, "rb")) ) if ( (tstf = fopen(loadedRomFName, "rb")) )
{ {
fclose(tstf); fclose(tstf);
strcpy(curr_path, lastRomFile); strcpy(curr_path, loadedRomFName);
} }
else else
getcwd(curr_path, PATH_MAX); getcwd(curr_path, PATH_MAX);
@ -1694,10 +1694,10 @@ int menu_loop_tray(void)
gp2x_memset_all_buffers(0, 0, 320*240*2); gp2x_memset_all_buffers(0, 0, 320*240*2);
menu_gfx_prepare(); menu_gfx_prepare();
if ( (tstf = fopen(lastRomFile, "rb")) ) if ( (tstf = fopen(loadedRomFName, "rb")) )
{ {
fclose(tstf); fclose(tstf);
strcpy(curr_path, lastRomFile); strcpy(curr_path, loadedRomFName);
} }
else else
{ {
@ -1721,7 +1721,7 @@ int menu_loop_tray(void)
if (selfname) { if (selfname) {
int ret = -1; int ret = -1;
cd_img_type cd_type; cd_img_type cd_type;
cd_type = emu_cdCheck(NULL); cd_type = emu_cdCheck(NULL, romFileName);
if (cd_type != CIT_NOT_CD) if (cd_type != CIT_NOT_CD)
ret = Insert_CD(romFileName, cd_type); ret = Insert_CD(romFileName, cd_type);
if (ret != 0) { if (ret != 0) {

View file

@ -24,4 +24,10 @@
//#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__) //#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)
#define dprintf(x...) #define dprintf(x...)
// platform
#define PLAT_MAX_KEYS 32
#define PLAT_HAVE_JOY 1
#define PATH_SEP "/"
#define PATH_SEP_C '/'
#endif //PORT_CONFIG_H #endif //PORT_CONFIG_H

View file

@ -48,7 +48,6 @@ char romFileName[PATH_MAX];
static short __attribute__((aligned(4))) sndBuffer[2*44100/50]; static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
static struct timeval noticeMsgTime = { 0, 0 }; // when started showing static struct timeval noticeMsgTime = { 0, 0 }; // when started showing
static int osd_fps_x; static int osd_fps_x;
char noticeMsg[64]; // notice msg to draw
unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer
int reset_timing = 0; int reset_timing = 0;
@ -65,7 +64,7 @@ void emu_noticeMsgUpdated(void)
gettimeofday(&noticeMsgTime, 0); gettimeofday(&noticeMsgTime, 0);
} }
void emu_getMainDir(char *dst, int len) int emu_getMainDir(char *dst, int len)
{ {
extern char **g_argv; extern char **g_argv;
int j; int j;
@ -76,6 +75,8 @@ void emu_getMainDir(char *dst, int len)
dst[len] = 0; dst[len] = 0;
for (j = strlen(dst); j > 0; j--) for (j = strlen(dst); j > 0; j--)
if (dst[j] == '/') { dst[j+1] = 0; break; } if (dst[j] == '/') { dst[j+1] = 0; break; }
return j + 1;
} }
void emu_Init(void) void emu_Init(void)
@ -151,16 +152,6 @@ void emu_prepareDefaultConfig(void)
defaultConfig.turbo_rate = 15; defaultConfig.turbo_rate = 15;
} }
void emu_setDefaultConfig(void)
{
memcpy(&currentConfig, &defaultConfig, sizeof(currentConfig));
PicoOpt = currentConfig.s_PicoOpt;
PsndRate = currentConfig.s_PsndRate;
PicoRegionOverride = currentConfig.s_PicoRegion;
PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;
PicoCDBuffers = currentConfig.s_PicoCDBuffers;
}
static void textOut16(int x, int y, const char *text) static void textOut16(int x, int y, const char *text)
{ {
int i,l,len=strlen(text); int i,l,len=strlen(text);

View file

@ -92,7 +92,7 @@ int main(int argc, char *argv[])
if (engineState == PGS_ReloadRom) if (engineState == PGS_ReloadRom)
{ {
if (emu_ReloadRom()) { if (emu_ReloadRom(romFileName)) {
engineState = PGS_Running; engineState = PGS_Running;
if (load_state_slot >= 0) { if (load_state_slot >= 0) {
state_slot = load_state_slot; state_slot = load_state_slot;
@ -110,7 +110,7 @@ int main(int argc, char *argv[])
break; break;
case PGS_ReloadRom: case PGS_ReloadRom:
if (emu_ReloadRom()) if (emu_ReloadRom(romFileName))
engineState = PGS_Running; engineState = PGS_Running;
else { else {
printf("PGS_ReloadRom == 0\n"); printf("PGS_ReloadRom == 0\n");

View file

@ -24,4 +24,10 @@
//#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__) //#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)
#define dprintf(x...) #define dprintf(x...)
// platform
#define PLAT_MAX_KEYS 32
#define PLAT_HAVE_JOY 1
#define PATH_SEP "/"
#define PATH_SEP_C '/'
#endif //PORT_CONFIG_H #endif //PORT_CONFIG_H

View file

@ -54,9 +54,10 @@ void emu_noticeMsgUpdated(void)
noticeMsgTime = sceKernelGetSystemTimeLow(); noticeMsgTime = sceKernelGetSystemTimeLow();
} }
void emu_getMainDir(char *dst, int len) int emu_getMainDir(char *dst, int len)
{ {
if (len > 0) *dst = 0; if (len > 0) *dst = 0;
return 0;
} }
static void osd_text(int x, const char *text, int is_active, int clear_all) static void osd_text(int x, const char *text, int is_active, int clear_all)
@ -155,16 +156,6 @@ void emu_prepareDefaultConfig(void)
defaultConfig.turbo_rate = 15; defaultConfig.turbo_rate = 15;
} }
void emu_setDefaultConfig(void)
{
memcpy(&currentConfig, &defaultConfig, sizeof(currentConfig));
PicoOpt = currentConfig.s_PicoOpt;
PsndRate = currentConfig.s_PsndRate;
PicoRegionOverride = currentConfig.s_PicoRegion;
PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;
PicoCDBuffers = currentConfig.s_PicoCDBuffers;
}
extern void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count); extern void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count);
extern void amips_clut_6bit(unsigned short *dst, unsigned char *src, unsigned short *pal, int count); extern void amips_clut_6bit(unsigned short *dst, unsigned char *src, unsigned short *pal, int count);

View file

@ -52,13 +52,13 @@ int pico_main(void)
#ifndef GPROF #ifndef GPROF
menu_loop(); menu_loop();
#else #else
strcpy(romFileName, lastRomFile); strcpy(romFileName, loadedRomFName);
engineState = PGS_ReloadRom; engineState = PGS_ReloadRom;
#endif #endif
break; break;
case PGS_ReloadRom: case PGS_ReloadRom:
if (emu_ReloadRom()) { if (emu_ReloadRom(romFileName)) {
engineState = PGS_Running; engineState = PGS_Running;
if (mp3_last_error != 0) if (mp3_last_error != 0)
engineState = PGS_Menu; // send to menu to display mp3 error engineState = PGS_Menu; // send to menu to display mp3 error

View file

@ -825,7 +825,7 @@ menu_entry cdopt_entries[] =
{ NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 }, { NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 },
{ NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 }, { NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 },
{ "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, &currentConfig.EmuOpt, 0x0400, 0, 0, 1, 1 }, { "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, &currentConfig.EmuOpt, 0x0400, 0, 0, 1, 1 },
{ "CDDA audio (using mp3s)", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 }, { "CDDA audio", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 },
{ "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoOpt, 0x0400, 0, 0, 1, 1 }, { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoOpt, 0x0400, 0, 0, 1, 1 },
{ NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 }, { NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 },
{ "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoOpt, 0x8000, 0, 0, 1, 1 }, { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoOpt, 0x8000, 0, 0, 1, 1 },
@ -1632,10 +1632,10 @@ static void menu_loop_root(void)
{ {
char curr_path[PATH_MAX], *selfname; char curr_path[PATH_MAX], *selfname;
FILE *tstf; FILE *tstf;
if ( (tstf = fopen(lastRomFile, "rb")) ) if ( (tstf = fopen(loadedRomFName, "rb")) )
{ {
fclose(tstf); fclose(tstf);
strcpy(curr_path, lastRomFile); strcpy(curr_path, loadedRomFName);
} }
else else
getcwd(curr_path, PATH_MAX); getcwd(curr_path, PATH_MAX);
@ -1777,10 +1777,10 @@ int menu_loop_tray(void)
menu_gfx_prepare(); menu_gfx_prepare();
if ( (tstf = fopen(lastRomFile, "rb")) ) if ( (tstf = fopen(loadedRomFName, "rb")) )
{ {
fclose(tstf); fclose(tstf);
strcpy(curr_path, lastRomFile); strcpy(curr_path, loadedRomFName);
} }
else else
{ {
@ -1804,7 +1804,7 @@ int menu_loop_tray(void)
if (selfname) { if (selfname) {
int ret = -1; int ret = -1;
cd_img_type cd_type; cd_img_type cd_type;
cd_type = emu_cdCheck(NULL); cd_type = emu_cdCheck(NULL, romFileName);
if (cd_type != CIT_NOT_CD) if (cd_type != CIT_NOT_CD)
ret = Insert_CD(romFileName, cd_type); ret = Insert_CD(romFileName, cd_type);
if (ret != 0) { if (ret != 0) {

View file

@ -28,4 +28,10 @@ extern void blit1(void);
//#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__) //#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)
#define dprintf(x...) #define dprintf(x...)
// platform
#define PLAT_MAX_KEYS 32
#define PLAT_HAVE_JOY 0
#define PATH_SEP "/"
#define PATH_SEP_C '/'
#endif //PORT_CONFIG_H #endif //PORT_CONFIG_H