--- /dev/null
+.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
+
+
/*
* Human-readable config file management for PicoDrive
- * (c)
+ * (c) notaz, 2008
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#ifdef UIQ3
+#include <unistd.h>
+#endif
#include "config.h"
#include "lprintf.h"
}
+#if PLAT_HAVE_JOY
static const char *joyKeyNames[32] =
{
"UP", "DOWN", "LEFT", "RIGHT", "b1", "b2", "b3", "b4",
"b13", "b14", "b15", "b16", "b17", "b19", "b19", "b20",
"b21", "b22", "b23", "b24", "b25", "b26", "b27", "b28"
};
+#endif
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;
- 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;
if (no_defaults && binds[t] == def_binds[t])
continue;
- if (strcmp(names[t], "???") == 0) continue;
#ifdef __GP2X__
if (strcmp(names[t], "SELECT") == 0) continue;
#endif
+ 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) {
- fprintf(fn, "%s %s =" NL, bind_str, names[t]); // no binds
+ fprintf(fn, "%s %s =" NL, bind_str, name); // no binds
continue;
}
for (i = 0; i < sizeof(me_ctrl_actions) / sizeof(me_ctrl_actions[0]); i++) {
if (me_ctrl_actions[i].mask & binds[t]) {
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));
}
}
for (i = 0; emuctrl_actions[i].name != NULL; i++) {
if (emuctrl_actions[i].mask & binds[t]) {
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));
}
}
}
case MA_CDOPT_LEDS:
return defaultConfig.EmuOpt;
- case MA_CTRL_TURBO_RATE:
- return defaultConfig.turbo_rate;
+ case MA_CTRL_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:
default:
}
// save key config
- keys_write(fn, "bind", currentConfig.KeyBinds, defaultConfig.KeyBinds, keyNames, no_defaults);
- keys_write(fn, "bind_joy0", currentConfig.JoyBinds[0], defaultConfig.JoyBinds[0], joyKeyNames, 1);
- keys_write(fn, "bind_joy1", currentConfig.JoyBinds[1], defaultConfig.JoyBinds[1], joyKeyNames, 1);
- keys_write(fn, "bind_joy2", currentConfig.JoyBinds[2], defaultConfig.JoyBinds[2], joyKeyNames, 1);
- keys_write(fn, "bind_joy3", currentConfig.JoyBinds[3], defaultConfig.JoyBinds[3], joyKeyNames, 1);
+ keys_write(fn, "bind", currentConfig.KeyBinds, defaultConfig.KeyBinds, keyNames, PLAT_MAX_KEYS, no_defaults);
+#if PLAT_HAVE_JOY
+ keys_write(fn, "bind_joy0", currentConfig.JoyBinds[0], defaultConfig.JoyBinds[0], joyKeyNames, 32, 1);
+ keys_write(fn, "bind_joy1", currentConfig.JoyBinds[1], defaultConfig.JoyBinds[1], joyKeyNames, 32, 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
if (section == NULL)
int size;
FILE *f;
- if (strlen(lastRomFile) == 0) return -1;
+ if (strlen(loadedRomFName) == 0) return -1;
f = fopen(fname, "r");
if (f != NULL)
fwrite(old_data, 1, optr - old_data, f);
free(old_data);
}
- fprintf(f, "LastUsedROM = %s" NL, lastRomFile);
+ fprintf(f, "LastUsedROM = %s" NL, loadedRomFName);
fclose(f);
return 0;
}
tmp++;
mystrip(tmp);
- len = sizeof(lastRomFile);
- strncpy(lastRomFile, tmp, len);
- lastRomFile[len-1] = 0;
+ len = sizeof(loadedRomFName);
+ strncpy(loadedRomFName, tmp, len);
+ loadedRomFName[len-1] = 0;
ret = 0;
break;
}
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;
unsigned int player;
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);
return;
}
#define try_joy_parse(num) { \
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; \
} \
}
// key binds
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;
}
+#if PLAT_HAVE_JOY
try_joy_parse(0)
try_joy_parse(1)
try_joy_parse(2)
try_joy_parse(3)
+#endif
for (t = 0; t < sizeof(cfg_opts) / sizeof(cfg_opts[0]) && ret == 0; t++)
{
char *PicoConfigFile = "config.cfg";\r
currentConfig_t currentConfig, defaultConfig;\r
int rom_loaded = 0;\r
-char noticeMsg[64];\r
+char noticeMsg[64] = { 0, };\r
int state_slot = 0;\r
int config_slot = 0, config_slot_current = 0;\r
-char lastRomFile[512];\r
+char loadedRomFName[512] = { 0, };\r
int kb_combo_keys = 0, kb_combo_acts = 0; // keys and actions which need button combos\r
int pico_inp_mode = 0;\r
\r
static int movie_size = 0;\r
\r
// provided by platform code:\r
-extern char romFileName[];\r
extern void emu_noticeMsgUpdated(void);\r
-extern void emu_getMainDir(char *dst, int len);\r
-extern void emu_setDefaultConfig(void);\r
+extern int emu_getMainDir(char *dst, int len);\r
extern void menu_romload_prepare(const char *rom_name);\r
extern void menu_romload_end(void);\r
\r
while ( (*string++ = (char)tolower(*string)) );\r
}\r
\r
-static int try_rfn_cut(void)\r
+static int try_rfn_cut(char *fname)\r
{\r
FILE *tmp;\r
char *p;\r
\r
- p = romFileName + strlen(romFileName) - 1;\r
- for (; p > romFileName; p--)\r
+ p = fname + strlen(fname) - 1;\r
+ for (; p > fname; p--)\r
if (*p == '.') break;\r
*p = 0;\r
\r
- if((tmp = fopen(romFileName, "rb"))) {\r
+ if((tmp = fopen(fname, "rb"))) {\r
fclose(tmp);\r
return 1;\r
}\r
\r
static unsigned char id_header[0x100];\r
\r
-/* checks if romFileName points to valid MegaCD image\r
+/* checks if fname points to valid MegaCD image\r
* if so, checks for suitable BIOS */\r
-int emu_cdCheck(int *pregion)\r
+int emu_cdCheck(int *pregion, char *fname_in)\r
{\r
unsigned char buf[32];\r
pm_file *cd_f;\r
int region = 4; // 1: Japan, 4: US, 8: Europe\r
- char ext[5], *fname = romFileName;\r
+ char ext[5], *fname = fname_in;\r
cue_track_type type = CT_UNKNOWN;\r
cue_data_t *cue_data = NULL;\r
\r
- get_ext(romFileName, ext);\r
+ get_ext(fname_in, ext);\r
if (strcasecmp(ext, ".cue") == 0) {\r
- cue_data = cue_parse(romFileName);\r
+ cue_data = cue_parse(fname_in);\r
if (cue_data != NULL) {\r
fname = cue_data->tracks[1].fname;\r
type = cue_data->tracks[1].type;\r
\r
char *emu_makeRomId(void)\r
{\r
- static char id_string[3+0x11+0x11+0x30+16];\r
+ static char id_string[3+0xe*3+0x3*3+0x30*3+3];\r
int pos, swab = 1;\r
\r
if (PicoAHW & PAHW_MCD) {\r
return id_string;\r
}\r
\r
-int emu_ReloadRom(void)\r
+// buffer must be at least 150 byte long\r
+void emu_getGameName(char *str150)\r
+{\r
+ int ret, swab = (PicoAHW & PAHW_MCD) ? 0 : 1;\r
+ char *s, *d;\r
+\r
+ ret = extract_text(str150, id_header + 0x50, 0x30, swab); // overseas name\r
+\r
+ for (s = d = str150 + 1; s < str150+ret; s++)\r
+ {\r
+ if (*s == 0) break;\r
+ if (*s != ' ' || d[-1] != ' ')\r
+ *d++ = *s;\r
+ }\r
+ *d = 0;\r
+}\r
+\r
+// note: this function might mangle rom_fname\r
+int emu_ReloadRom(char *rom_fname)\r
{\r
unsigned int rom_size = 0;\r
- char *used_rom_name = romFileName;\r
+ char *used_rom_name = rom_fname;\r
unsigned char *rom_data = NULL;\r
char ext[5];\r
pm_file *rom = NULL;\r
int ret, cd_state, cd_region, cfg_loaded = 0;\r
\r
- lprintf("emu_ReloadRom(%s)\n", romFileName);\r
+ lprintf("emu_ReloadRom(%s)\n", rom_fname);\r
\r
- get_ext(romFileName, ext);\r
+ get_ext(rom_fname, ext);\r
\r
// detect wrong extensions\r
if (!strcmp(ext, ".srm") || !strcmp(ext, "s.gz") || !strcmp(ext, ".mds")) { // s.gz ~ .mds.gz\r
{\r
// check for both gmv and rom\r
int dummy;\r
- FILE *movie_file = fopen(romFileName, "rb");\r
+ FILE *movie_file = fopen(rom_fname, "rb");\r
if(!movie_file) {\r
sprintf(menuErrorMsg, "Failed to open movie.");\r
return 0;\r
sprintf(menuErrorMsg, "Invalid GMV file.");\r
return 0;\r
}\r
- dummy = try_rfn_cut() || try_rfn_cut();\r
+ dummy = try_rfn_cut(rom_fname) || try_rfn_cut(rom_fname);\r
if (!dummy) {\r
sprintf(menuErrorMsg, "Could't find a ROM for movie.");\r
return 0;\r
}\r
- get_ext(romFileName, ext);\r
+ get_ext(rom_fname, ext);\r
}\r
- else if (!strcmp(ext, ".pat")) {\r
+ else if (!strcmp(ext, ".pat"))\r
+ {\r
int dummy;\r
- PicoPatchLoad(romFileName);\r
- dummy = try_rfn_cut() || try_rfn_cut();\r
+ PicoPatchLoad(rom_fname);\r
+ dummy = try_rfn_cut(rom_fname) || try_rfn_cut(rom_fname);\r
if (!dummy) {\r
sprintf(menuErrorMsg, "Could't find a ROM to patch.");\r
return 0;\r
}\r
- get_ext(romFileName, ext);\r
+ get_ext(rom_fname, ext);\r
}\r
\r
- if ((PicoAHW & PAHW_MCD) && Pico_mcd != NULL)\r
- Stop_CD();\r
+ emu_shutdownMCD();\r
\r
// check for MegaCD image\r
- cd_state = emu_cdCheck(&cd_region);\r
+ cd_state = emu_cdCheck(&cd_region, rom_fname);\r
if (cd_state >= 0 && cd_state != CIT_NOT_CD)\r
{\r
PicoAHW |= PAHW_MCD;\r
\r
// insert CD if it was detected\r
if (cd_state != CIT_NOT_CD) {\r
- ret = Insert_CD(romFileName, cd_state);\r
+ ret = Insert_CD(rom_fname, cd_state);\r
if (ret != 0) {\r
sprintf(menuErrorMsg, "Insert_CD() failed, invalid CD image?");\r
lprintf("%s\n", menuErrorMsg);\r
emu_noticeMsgUpdated();\r
\r
// load SRAM for this ROM\r
- if (currentConfig.EmuOpt & 1)\r
+ if (currentConfig.EmuOpt & EOPT_USE_SRAM)\r
emu_SaveLoadGame(1, 1);\r
\r
- strncpy(lastRomFile, romFileName, sizeof(lastRomFile)-1);\r
- lastRomFile[sizeof(lastRomFile)-1] = 0;\r
+ strncpy(loadedRomFName, rom_fname, sizeof(loadedRomFName)-1);\r
+ loadedRomFName[sizeof(loadedRomFName)-1] = 0;\r
rom_loaded = 1;\r
return 1;\r
\r
}\r
\r
\r
+void emu_shutdownMCD(void)\r
+{\r
+ if ((PicoAHW & PAHW_MCD) && Pico_mcd != NULL)\r
+ Stop_CD();\r
+ PicoAHW &= ~PAHW_MCD;\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
- for (p = romFileName+strlen(romFileName)-1; p >= romFileName && *p != '/'; p--); p++;\r
+ p = loadedRomFName+strlen(loadedRomFName)-1;\r
+ for (; p >= loadedRomFName && *p != PATH_SEP_C; p--); p++;\r
*dst = 0;\r
if (prefix) {\r
- strcpy(dst, prefix);\r
- prefix_len = strlen(prefix);\r
+ int len = emu_getMainDir(dst, 512);\r
+ strcpy(dst + len, prefix);\r
+ prefix_len = len + strlen(prefix);\r
}\r
+#ifdef UIQ3\r
+ else p = loadedRomFName; // 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
\r
static void make_config_cfg(char *cfg)\r
{\r
- strncpy(cfg, PicoConfigFile, 511);\r
+ int len;\r
+ len = emu_getMainDir(cfg, 512);\r
+ strncpy(cfg + len, PicoConfigFile, 512-6-1-len);\r
if (config_slot != 0)\r
{\r
char *p = strrchr(cfg, '.');\r
cfg[511] = 0;\r
}\r
\r
+void emu_packConfig(void)\r
+{\r
+ currentConfig.s_PicoOpt = PicoOpt;\r
+ currentConfig.s_PsndRate = PsndRate;\r
+ currentConfig.s_PicoRegion = PicoRegionOverride;\r
+ currentConfig.s_PicoAutoRgnOrder = PicoAutoRgnOrder;\r
+ currentConfig.s_PicoCDBuffers = PicoCDBuffers;\r
+}\r
+\r
+void emu_unpackConfig(void)\r
+{\r
+ PicoOpt = currentConfig.s_PicoOpt;\r
+ PsndRate = currentConfig.s_PsndRate;\r
+ PicoRegionOverride = currentConfig.s_PicoRegion;\r
+ PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;\r
+ PicoCDBuffers = currentConfig.s_PicoCDBuffers;\r
+}\r
+\r
+static void emu_setDefaultConfig(void)\r
+{\r
+ memcpy(¤tConfig, &defaultConfig, sizeof(currentConfig));\r
+ emu_unpackConfig();\r
+}\r
+\r
+\r
int emu_ReadConfig(int game, int no_defaults)\r
{\r
char cfg[512];\r
- FILE *f;\r
int ret;\r
\r
if (!game)\r
ret = config_readsect("game_def.cfg", sect);\r
}\r
\r
- if (ret != 0)\r
- {\r
- // fall back to old game specific cfg\r
- char extbuf[16];\r
- if (config_slot != 0)\r
- sprintf(extbuf, ".%i.pbcfg", config_slot);\r
- else strcpy(extbuf, ".pbcfg");\r
- romfname_ext(cfg, "cfg/", extbuf);\r
- f = fopen(cfg, "rb");\r
- if (!f) {\r
- romfname_ext(cfg, NULL, ".pbcfg");\r
- f = fopen(cfg, "rb");\r
- }\r
- if (f) {\r
- int bread;\r
- fseek(f, 512, SEEK_SET); // skip unused lrom buffer\r
- bread = fread(¤tConfig, 1, sizeof(currentConfig), f);\r
- lprintf("emu_ReadConfig: %s %s\n", cfg, bread > 0 ? "(ok)" : "(failed)");\r
- fclose(f);\r
- ret = 0;\r
- }\r
-\r
- if (ret == 0) {\r
- PicoOpt = currentConfig.s_PicoOpt;\r
- PsndRate = currentConfig.s_PsndRate;\r
- PicoRegionOverride = currentConfig.s_PicoRegion;\r
- PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;\r
- // PicoCDBuffers = currentConfig.s_PicoCDBuffers; // ignore in this case\r
- }\r
- }\r
- else\r
+ if (ret == 0)\r
{\r
lprintf("loaded cfg from sect \"%s\"\n", sect);\r
}\r
\r
if (!is_game)\r
{\r
- strncpy(cfg, PicoConfigFile, 511);\r
- if (config_slot != 0)\r
- {\r
- char *p = strrchr(cfg, '.');\r
- if (p == NULL) p = cfg + strlen(cfg);\r
- sprintf(p, ".%i.cfg", config_slot);\r
- }\r
- cfg[511] = 0;\r
+ make_config_cfg(cfg);\r
write_lrom = 1;\r
} else {\r
if (config_slot != 0)\r
}\r
\r
\r
+#ifndef UIQ3\r
void emu_textOut8(int x, int y, const char *text)\r
{\r
int i,l,len=strlen(text);\r
screen += 8;\r
}\r
}\r
+#endif\r
\r
#ifdef PSP\r
#define MAX_COMBO_KEY 23\r
\r
if (is_sram)\r
{\r
- romfname_ext(saveFname, (PicoAHW&1) ? "brm/" : "srm/", (PicoAHW&1) ? ".brm" : ".srm");\r
+ romfname_ext(saveFname, (PicoAHW&1) ? "brm"PATH_SEP : "srm"PATH_SEP, (PicoAHW&1) ? ".brm" : ".srm");\r
if (load) {\r
if (try_ropen_file(saveFname)) return saveFname;\r
// try in current dir..\r
{\r
ext[0] = 0;\r
if(slot > 0 && slot < 10) sprintf(ext, ".%i", slot);\r
- strcat(ext, (currentConfig.EmuOpt & 8) ? ".mds.gz" : ".mds");\r
+ strcat(ext, (currentConfig.EmuOpt & EOPT_GZIP_SAVES) ? ".mds.gz" : ".mds");\r
\r
- romfname_ext(saveFname, "mds/", ext);\r
+ romfname_ext(saveFname, "mds" PATH_SEP, ext);\r
if (load) {\r
if (try_ropen_file(saveFname)) return saveFname;\r
romfname_ext(saveFname, NULL, ext);\r
if (try_ropen_file(saveFname)) return saveFname;\r
- if (currentConfig.EmuOpt & 8) {\r
+ // no gzipped states, search for non-gzipped\r
+ if (currentConfig.EmuOpt & EOPT_GZIP_SAVES)\r
+ {\r
ext[0] = 0;\r
if(slot > 0 && slot < 10) sprintf(ext, ".%i", slot);\r
strcat(ext, ".mds");\r
\r
- romfname_ext(saveFname, "mds/", ext);\r
+ romfname_ext(saveFname, "mds"PATH_SEP, ext);\r
if (try_ropen_file(saveFname)) return saveFname;\r
romfname_ext(saveFname, NULL, ext);\r
if (try_ropen_file(saveFname)) return saveFname;\r
// 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];
int EmuOpt; // LSb->MSb: use_sram, show_fps, enable_sound, gzip_saves,
// squidgehack, no_save_cfg_on_exit, <unused>, 16_bit_mode
int s_PicoOpt; // for old cfg files only
int s_PsndRate;
int s_PicoRegion;
+ int s_PicoAutoRgnOrder;
+ int s_PicoCDBuffers;
int Frameskip;
int CPUclock;
- int KeyBinds[32];
+ int KeyBinds[PLAT_MAX_KEYS];
int volume;
int gamma;
+#if PLAT_HAVE_JOY
int JoyBinds[4][32];
- int s_PicoAutoRgnOrder;
- int s_PicoCDBuffers;
- int scaling; // gp2x: 0=center, 1=hscale, 2=hvscale, 3=hsoftscale; psp: bilinear filtering
+#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 hscale32, hscale40; // psp: horizontal scale
int gamma2; // psp: black level
extern int state_slot;
extern int config_slot, config_slot_current;
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 pico_inp_mode;
-int emu_ReloadRom(void);
+int emu_ReloadRom(char *rom_fname);
int emu_SaveLoadGame(int load, int sram);
int emu_ReadConfig(int game, int no_defaults);
int emu_WriteConfig(int game);
int emu_checkSaveFile(int slot);
void emu_setSaveStateCbs(int gz);
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);
void emu_textOut8 (int x, int y, const char *text);
void emu_textOut16(int x, int y, const char *text);
char *emu_makeRomId(void);
+void emu_getGameName(char *str150);
void emu_findKeyBindCombos(void);
void emu_forcedFrame(int opts);
void emu_changeFastForward(int set_on);
void emu_RunEventsPico(unsigned int events);
void emu_DoTurbo(int *pad, int acts);
+void emu_packConfig(void);
+void emu_unpackConfig(void);
+void emu_shutdownMCD(void);
extern const char * const keyNames[];
void emu_prepareDefaultConfig(void);
void emu_platformDebugCat(char *str);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
};\r
\r
\r
+#ifndef UIQ3\r
+\r
static unsigned char menu_font_data[10240];\r
static int menu_text_color = 0xffff; // default to white\r
static int menu_sel_color = -1; // disabled\r
}\r
}\r
\r
-const char *me_region_name(unsigned int code, int auto_order)\r
-{\r
- static const char *names[] = { "Auto", " Japan NTSC", " Japan PAL", " USA", " Europe" };\r
- static const char *names_short[] = { "", " JP", " JP", " US", " EU" };\r
- int u, i = 0;\r
- if (code) {\r
- code <<= 1;\r
- while((code >>= 1)) i++;\r
- if (i > 4) return "unknown";\r
- return names[i];\r
- } else {\r
- static char name[24];\r
- strcpy(name, "Auto:");\r
- for (u = 0; u < 3; u++) {\r
- i = 0; code = ((auto_order >> u*4) & 0xf) << 1;\r
- while((code >>= 1)) i++;\r
- strcat(name, names_short[i]);\r
- }\r
- return name;\r
- }\r
-}\r
-\r
// ------------ debug menu ------------\r
\r
#include <sys/stat.h>\r
}\r
}\r
\r
+#endif // !UIQ3\r
+\r
+// ------------ util ------------\r
+\r
+const char *me_region_name(unsigned int code, int auto_order)\r
+{\r
+ static const char *names[] = { "Auto", " Japan NTSC", " Japan PAL", " USA", " Europe" };\r
+ static const char *names_short[] = { "", " JP", " JP", " US", " EU" };\r
+ int u, i = 0;\r
+ if (code) {\r
+ code <<= 1;\r
+ while((code >>= 1)) i++;\r
+ if (i > 4) return "unknown";\r
+ return names[i];\r
+ } else {\r
+ static char name[24];\r
+ strcpy(name, "Auto:");\r
+ for (u = 0; u < 3; u++) {\r
+ i = 0; code = ((auto_order >> u*4) & 0xf) << 1;\r
+ while((code >>= 1)) i++;\r
+ strcat(name, names_short[i]);\r
+ }\r
+ return name;\r
+ }\r
+}\r
+\r
\r
MA_OPT_SAVECFG_GAME,
MA_OPT_LOADCFG,
MA_OPT_INTERLACED, /* giz */
+ MA_OPT_ROTATION, /* uiq */
MA_OPT2_GAMMA,
MA_OPT2_A_SN_GAMMA,
MA_OPT2_DBLBUFF, /* giz */
ifeq "$(profile)" "2"\r
COPT_COMMON += -fprofile-use\r
endif\r
-COPT = $(COPT_COMMON) -mtune=arm920t\r
-ASOPT = -mcpu=arm920t -mfloat-abi=soft\r
-GCC = $(CROSS)gcc\r
+CFLAGS = $(COPT_COMMON) -mcpu=arm920t -mtune=arm920t\r
+SFLAGS = $(CFLAGS)\r
+ASFLAGS = -mcpu=arm920t -mfloat-abi=soft\r
+CC = $(CROSS)gcc\r
STRIP = $(CROSS)strip\r
AS = $(CROSS)as\r
LD = $(CROSS)ld\r
OBJCOPY = $(CROSS)objcopy\r
\r
# frontend\r
-OBJS += main.o menu.o gp2x.o usbjoy.o emu.o squidgehack.o cpuctrl.o\r
+OBJS += main.o menu.o gp2x.o usbjoy.o emu.o squidgehack.o cpuctrl.o asm_utils.o\r
# 940 core control\r
OBJS += 940ctl.o\r
\r
\r
PicoDrive.gpe : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a\r
@echo ">>>" $@\r
- $(GCC) -o $@ $(COPT) $^ -lm -lpng -Wl,-Map=PicoDrive.map\r
+ $(CC) -o $@ $(CFLAGS) $^ -lm -lpng -Wl,-Map=PicoDrive.map\r
ifeq ($(DEBUG),)\r
$(STRIP) $@\r
endif\r
# @make -C ../../cpu/Cyclone/proj -f Makefile.linux clean\r
\r
\r
-clean_prof:\r
- find ../.. -name '*.gcno' -delete\r
- find ../.. -name '*.gcda' -delete\r
-\r
-\r
-mkdirs:\r
- mkdir -p $(DIRS)\r
-\r
-.c.o:\r
- @echo ">>>" $<\r
- $(GCC) $(COPT) $(DEFINC) -c $< -o $@\r
-.s.o:\r
- @echo ">>>" $<\r
- $(GCC) $(COPT) $(DEFINC) -c $< -o $@\r
-.S.o:\r
- @echo ">>>" $<\r
- $(GCC) $(COPT) $(DEFINC) -c $< -o $@\r
-\r
-Pico/carthw/svp/compiler.o : ../../Pico/carthw/svp/ssp16.o ../../Pico/carthw/svp/gen_arm.c\r
-\r
-Pico/draw_asm.o : ../../Pico/Draw.s\r
- @echo ">>>" $<\r
- $(AS) $(ASOPT) $< -o $@\r
-Pico/draw2_asm.o : ../../Pico/Draw2.s\r
- @echo ">>>" $<\r
- $(AS) $(ASOPT) $< -o $@\r
-Pico/memory_asm.o : ../../Pico/Memory.s\r
- @echo ">>>" $<\r
- $(AS) $(ASOPT) $< -o $@\r
-Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s\r
- @echo ">>>" $<\r
- $(AS) $(ASOPT) $< -o $@\r
-Pico/sound/mix_asm.o : ../../Pico/sound/mix.s\r
- @echo ">>>" $<\r
- $(AS) $(ASOPT) $< -o $@\r
-Pico/misc_asm.o : ../../Pico/Misc.s\r
- @echo ">>>" $<\r
- $(AS) $(ASOPT) $< -o $@\r
-Pico/cd/pico_asm.o : ../../Pico/cd/Pico.s\r
- @echo ">>>" $<\r
- $(AS) $(ASOPT) $< -o $@\r
-Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s\r
- @echo ">>>" $<\r
- $(AS) $(ASOPT) $< -o $@\r
-Pico/cd/misc_asm.o : ../../Pico/cd/Misc.s\r
- @echo ">>>" $<\r
- $(AS) $(ASOPT) $< -o $@\r
-\r
-# build Cyclone\r
-../../cpu/Cyclone/proj/Cyclone.s :\r
- @echo building Cyclone...\r
- @make -C ../../cpu/Cyclone/proj CONFIG_FILE=config_pico.h\r
-\r
-../../cpu/musashi/m68kops.c :\r
- @make -C ../../cpu/musashi\r
-\r
-Pico/Pico.o Pico/cd/Pico.o: ../../Pico/PicoFrameHints.c ../../Pico/PicoInt.h\r
-Pico/Memory.o Pico/cd/Memory.o : ../../Pico/MemoryCmn.c ../../Pico/PicoInt.h\r
-\r
-# build helix libs\r
-../common/helix/$(CROSS)helix-mp3.a:\r
- make -C ../common/helix clean all\r
-\r
readme.txt: ../../tools/textfilter ../base_readme.txt\r
../../tools/textfilter ../base_readme.txt $@ GP2X\r
\r
-../../tools/textfilter: ../../tools/textfilter.c\r
- make -C ../../tools/ textfilter\r
-\r
+include ../common/common_arm.mak\r
\r
# ----------- release -----------\r
ifneq ($(findstring rel,$(MAKECMDGOALS)),)\r
static struct timeval noticeMsgTime = { 0, 0 }; // when started showing\r
static int osd_fps_x;\r
static int gp2x_old_gamma = 100;\r
-char noticeMsg[64]; // notice msg to draw\r
unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer\r
int reset_timing = 0;\r
\r
gettimeofday(¬iceMsgTime, 0);\r
}\r
\r
-void emu_getMainDir(char *dst, int len)\r
+int emu_getMainDir(char *dst, int len)\r
{\r
extern char **g_argv;\r
int j;\r
dst[len] = 0;\r
for (j = strlen(dst); j > 0; j--)\r
if (dst[j] == '/') { dst[j+1] = 0; break; }\r
+\r
+ return j + 1;\r
}\r
\r
void emu_Init(void)\r
defaultConfig.turbo_rate = 15;\r
}\r
\r
-void emu_setDefaultConfig(void)\r
-{\r
- memcpy(¤tConfig, &defaultConfig, sizeof(currentConfig));\r
- PicoOpt = currentConfig.s_PicoOpt;\r
- PsndRate = currentConfig.s_PsndRate;\r
- PicoRegionOverride = currentConfig.s_PicoRegion;\r
- PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;\r
- PicoCDBuffers = currentConfig.s_PicoCDBuffers;\r
-}\r
-\r
void osd_text(int x, int y, const char *text)\r
{\r
int len = strlen(text)*8;\r
\r
if (engineState == PGS_ReloadRom)\r
{\r
- if (emu_ReloadRom()) {\r
+ if (emu_ReloadRom(romFileName)) {\r
engineState = PGS_Running;\r
if (load_state_slot >= 0) {\r
state_slot = load_state_slot;\r
break;\r
\r
case PGS_ReloadRom:\r
- if (emu_ReloadRom())\r
+ if (emu_ReloadRom(romFileName))\r
engineState = PGS_Running;\r
else {\r
printf("PGS_ReloadRom == 0\n");\r
{ NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 },\r
{ NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 },\r
{ "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, ¤tConfig.EmuOpt, 0x0400, 0, 0, 1, 1 },\r
- { "CDDA audio (using mp3s)", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 },\r
+ { "CDDA audio", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 },\r
{ "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoOpt, 0x0400, 0, 0, 1, 1 },\r
{ NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 },\r
{ "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoOpt, 0x8000, 0, 0, 1, 1 },\r
{\r
char curr_path[PATH_MAX], *selfname;\r
FILE *tstf;\r
- if ( (tstf = fopen(lastRomFile, "rb")) )\r
+ if ( (tstf = fopen(loadedRomFName, "rb")) )\r
{\r
fclose(tstf);\r
- strcpy(curr_path, lastRomFile);\r
+ strcpy(curr_path, loadedRomFName);\r
}\r
else\r
getcwd(curr_path, PATH_MAX);\r
gp2x_memset_all_buffers(0, 0, 320*240*2);\r
menu_gfx_prepare();\r
\r
- if ( (tstf = fopen(lastRomFile, "rb")) )\r
+ if ( (tstf = fopen(loadedRomFName, "rb")) )\r
{\r
fclose(tstf);\r
- strcpy(curr_path, lastRomFile);\r
+ strcpy(curr_path, loadedRomFName);\r
}\r
else\r
{\r
if (selfname) {\r
int ret = -1;\r
cd_img_type cd_type;\r
- cd_type = emu_cdCheck(NULL);\r
+ cd_type = emu_cdCheck(NULL, romFileName);\r
if (cd_type != CIT_NOT_CD)\r
ret = Insert_CD(romFileName, cd_type);\r
if (ret != 0) {\r
//#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)\r
#define dprintf(x...)\r
\r
+// platform\r
+#define PLAT_MAX_KEYS 32\r
+#define PLAT_HAVE_JOY 1\r
+#define PATH_SEP "/"\r
+#define PATH_SEP_C '/'\r
+\r
#endif //PORT_CONFIG_H\r
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
static struct timeval noticeMsgTime = { 0, 0 }; // when started showing\r
static int osd_fps_x;\r
-char noticeMsg[64]; // notice msg to draw\r
unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer\r
int reset_timing = 0;\r
\r
gettimeofday(¬iceMsgTime, 0);\r
}\r
\r
-void emu_getMainDir(char *dst, int len)\r
+int emu_getMainDir(char *dst, int len)\r
{\r
extern char **g_argv;\r
int j;\r
dst[len] = 0;\r
for (j = strlen(dst); j > 0; j--)\r
if (dst[j] == '/') { dst[j+1] = 0; break; }\r
+\r
+ return j + 1;\r
}\r
\r
void emu_Init(void)\r
defaultConfig.turbo_rate = 15;\r
}\r
\r
-void emu_setDefaultConfig(void)\r
-{\r
- memcpy(¤tConfig, &defaultConfig, sizeof(currentConfig));\r
- PicoOpt = currentConfig.s_PicoOpt;\r
- PsndRate = currentConfig.s_PsndRate;\r
- PicoRegionOverride = currentConfig.s_PicoRegion;\r
- PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;\r
- PicoCDBuffers = currentConfig.s_PicoCDBuffers;\r
-}\r
-\r
static void textOut16(int x, int y, const char *text)\r
{\r
int i,l,len=strlen(text);\r
\r
if (engineState == PGS_ReloadRom)\r
{\r
- if (emu_ReloadRom()) {\r
+ if (emu_ReloadRom(romFileName)) {\r
engineState = PGS_Running;\r
if (load_state_slot >= 0) {\r
state_slot = load_state_slot;\r
break;\r
\r
case PGS_ReloadRom:\r
- if (emu_ReloadRom())\r
+ if (emu_ReloadRom(romFileName))\r
engineState = PGS_Running;\r
else {\r
printf("PGS_ReloadRom == 0\n");\r
//#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)\r
#define dprintf(x...)\r
\r
+// platform\r
+#define PLAT_MAX_KEYS 32\r
+#define PLAT_HAVE_JOY 1\r
+#define PATH_SEP "/"\r
+#define PATH_SEP_C '/'\r
+\r
#endif //PORT_CONFIG_H\r
noticeMsgTime = sceKernelGetSystemTimeLow();
}
-void emu_getMainDir(char *dst, int len)
+int emu_getMainDir(char *dst, int len)
{
if (len > 0) *dst = 0;
+ return 0;
}
static void osd_text(int x, const char *text, int is_active, int clear_all)
defaultConfig.turbo_rate = 15;
}
-void emu_setDefaultConfig(void)
-{
- memcpy(¤tConfig, &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_6bit(unsigned short *dst, unsigned char *src, unsigned short *pal, int count);
#ifndef GPROF
menu_loop();
#else
- strcpy(romFileName, lastRomFile);
+ strcpy(romFileName, loadedRomFName);
engineState = PGS_ReloadRom;
#endif
break;
case PGS_ReloadRom:
- if (emu_ReloadRom()) {
+ if (emu_ReloadRom(romFileName)) {
engineState = PGS_Running;
if (mp3_last_error != 0)
engineState = PGS_Menu; // send to menu to display mp3 error
{ 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 },
{ "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, ¤tConfig.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 },
{ 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 },
{
char curr_path[PATH_MAX], *selfname;
FILE *tstf;
- if ( (tstf = fopen(lastRomFile, "rb")) )
+ if ( (tstf = fopen(loadedRomFName, "rb")) )
{
fclose(tstf);
- strcpy(curr_path, lastRomFile);
+ strcpy(curr_path, loadedRomFName);
}
else
getcwd(curr_path, PATH_MAX);
menu_gfx_prepare();
- if ( (tstf = fopen(lastRomFile, "rb")) )
+ if ( (tstf = fopen(loadedRomFName, "rb")) )
{
fclose(tstf);
- strcpy(curr_path, lastRomFile);
+ strcpy(curr_path, loadedRomFName);
}
else
{
if (selfname) {
int ret = -1;
cd_img_type cd_type;
- cd_type = emu_cdCheck(NULL);
+ cd_type = emu_cdCheck(NULL, romFileName);
if (cd_type != CIT_NOT_CD)
ret = Insert_CD(romFileName, cd_type);
if (ret != 0) {
//#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)\r
#define dprintf(x...)\r
\r
+// platform\r
+#define PLAT_MAX_KEYS 32\r
+#define PLAT_HAVE_JOY 0\r
+#define PATH_SEP "/"\r
+#define PATH_SEP_C '/'\r
+\r
#endif //PORT_CONFIG_H\r