aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authortwinaphex2013-01-10 03:06:17 +0100
committertwinaphex2013-01-10 03:06:17 +0100
commite5f4d90401d099d5191f95e9f771ab5a81c87ed8 (patch)
tree8de3efcfd7bf5111ea62a43ecd7db558f2ec8350 /frontend
parentac7b2a33ddb2392582c50d29c772e9e99cd762c9 (diff)
parentd77e74383a9134e51c31607cfddf4dcd3535a0ae (diff)
downloadpcsx_rearmed-e5f4d90401d099d5191f95e9f771ab5a81c87ed8.tar.gz
pcsx_rearmed-e5f4d90401d099d5191f95e9f771ab5a81c87ed8.tar.bz2
pcsx_rearmed-e5f4d90401d099d5191f95e9f771ab5a81c87ed8.zip
Merge git://github.com/notaz/pcsx_rearmed
Diffstat (limited to 'frontend')
m---------frontend/libpicofe0
-rw-r--r--frontend/main.c13
-rw-r--r--frontend/main.h2
-rw-r--r--frontend/menu.c182
-rw-r--r--frontend/plugin_lib.c20
5 files changed, 185 insertions, 32 deletions
diff --git a/frontend/libpicofe b/frontend/libpicofe
-Subproject 0d645bc539fdc073f20c4dea9f4a4e218cebec0
+Subproject 4db02226eb3c80f49f5c412f7718c437c5e817f
diff --git a/frontend/main.c b/frontend/main.c
index c8841b9..43a1a03 100644
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -48,7 +48,7 @@ extern int iUseInterpolation;
extern int iXAPitch;
extern int iVolume;
-int ready_to_go;
+int ready_to_go, g_resetting;
unsigned long gpuDisp;
char cfgfile_basename[MAXPATHLEN];
int state_slot;
@@ -311,12 +311,19 @@ do_state_slot:
hud_new_msg = 3;
}
+static char basic_lcase(char c)
+{
+ if ('A' <= c && c <= 'Z')
+ return c - 'A' + 'a';
+ return c;
+}
+
static int cdidcmp(const char *id1, const char *id2)
{
while (*id1 != 0 && *id2 != 0) {
if (*id1 == '_') { id1++; continue; }
if (*id2 == '_') { id2++; continue; }
- if (*id1 != *id2)
+ if (basic_lcase(*id1) != basic_lcase(*id2))
break;
id1++;
id2++;
@@ -669,6 +676,7 @@ void SysReset() {
// so we need to prevent updateLace() call..
void *real_lace = GPU_updateLace;
GPU_updateLace = dummy_lace;
+ g_resetting = 1;
// reset can run code, timing must be set
pl_timing_prepare(Config.PsxType);
@@ -679,6 +687,7 @@ void SysReset() {
CDR_stop();
GPU_updateLace = real_lace;
+ g_resetting = 0;
}
void SysClose() {
diff --git a/frontend/main.h b/frontend/main.h
index 45e0aeb..d971890 100644
--- a/frontend/main.h
+++ b/frontend/main.h
@@ -52,7 +52,7 @@ int emu_load_state(int slot);
void set_cd_image(const char *fname);
extern unsigned long gpuDisp;
-extern int ready_to_go;
+extern int ready_to_go, g_resetting;
extern char hud_msg[64];
extern int hud_new_msg;
diff --git a/frontend/menu.c b/frontend/menu.c
index 7bec49a..7dab2e6 100644
--- a/frontend/menu.c
+++ b/frontend/menu.c
@@ -1,5 +1,5 @@
/*
- * (C) Gražvydas "notaz" Ignotas, 2010-2011
+ * (C) Gražvydas "notaz" Ignotas, 2010-2013
*
* This work is licensed under the terms of any of these licenses
* (at your option):
@@ -8,6 +8,7 @@
* See the COPYING file in the top-level directory.
*/
+#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <errno.h>
@@ -16,6 +17,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <dirent.h>
#include "main.h"
#include "menu.h"
@@ -84,7 +86,6 @@ typedef enum
static int last_vout_w, last_vout_h, last_vout_bpp;
static int cpu_clock, cpu_clock_st, volume_boost, frameskip;
-static char rom_fname_reload[MAXPATHLEN];
static char last_selected_fname[MAXPATHLEN];
static int config_save_counter, region, in_type_sel1, in_type_sel2;
static int psx_clock;
@@ -187,6 +188,107 @@ static int emu_save_load_game(int load, int unused)
return ret;
}
+static void rm_namelist_entry(struct dirent **namelist,
+ int count, const char *name)
+{
+ int i;
+
+ for (i = 1; i < count; i++) {
+ if (namelist[i] == NULL || namelist[i]->d_type == DT_DIR)
+ continue;
+
+ if (strcmp(name, namelist[i]->d_name) == 0) {
+ free(namelist[i]);
+ namelist[i] = NULL;
+ break;
+ }
+ }
+}
+
+static int optional_cdimg_filter(struct dirent **namelist, int count,
+ const char *basedir)
+{
+ const char *ext, *p;
+ char buf[256], buf2[256];
+ int i, d, ret, good_cue;
+ struct stat64 statf;
+ FILE *f;
+
+ for (i = 1; i < count; i++) {
+ if (namelist[i] == NULL || namelist[i]->d_type == DT_DIR)
+ continue;
+
+ ext = strrchr(namelist[i]->d_name, '.');
+ if (ext == NULL) {
+ // should not happen but whatever
+ free(namelist[i]);
+ namelist[i] = NULL;
+ continue;
+ }
+ ext++;
+
+ // first find .cue files and remove files they reference
+ if (strcasecmp(ext, "cue") == 0)
+ {
+ snprintf(buf, sizeof(buf), "%s/%s", basedir,
+ namelist[i]->d_name);
+
+ f = fopen(buf, "r");
+ if (f == NULL) {
+ free(namelist[i]);
+ namelist[i] = NULL;
+ continue;
+ }
+
+ good_cue = 0;
+ while (fgets(buf, sizeof(buf), f)) {
+ ret = sscanf(buf, " FILE \"%256[^\"]\"", buf2);
+ if (ret != 1)
+ ret = sscanf(buf, " FILE %256s", buf2);
+ if (ret != 1)
+ continue;
+
+ p = strrchr(buf2, '/');
+ if (p == NULL)
+ p = strrchr(buf2, '\\');
+ if (p == NULL)
+ p = buf2;
+
+ snprintf(buf, sizeof(buf), "%s/%s", basedir, p);
+ ret = stat64(buf, &statf);
+ if (ret == 0) {
+ rm_namelist_entry(namelist, count, p);
+ good_cue = 1;
+ }
+ }
+ fclose(f);
+
+ if (!good_cue) {
+ free(namelist[i]);
+ namelist[i] = NULL;
+ }
+ continue;
+ }
+
+ p = strcasestr(namelist[i]->d_name, "track");
+ if (p != NULL) {
+ ret = strtoul(p + 5, NULL, 10);
+ if (ret > 1) {
+ free(namelist[i]);
+ namelist[i] = NULL;
+ continue;
+ }
+ }
+ }
+
+ // compact namelist
+ for (i = d = 1; i < count; i++)
+ if (namelist[i] != NULL)
+ namelist[d++] = namelist[i];
+
+ return d;
+}
+
// propagate menu settings to the emu vars
static void menu_sync_config(void)
{
@@ -406,14 +508,18 @@ static int menu_write_config(int is_game)
static int menu_do_last_cd_img(int is_get)
{
+ static const char *defaults[] = { "/media", "/mnt/sd", "/mnt" };
char path[256];
+ struct stat64 st;
FILE *f;
- int ret;
+ int i, ret = -1;
snprintf(path, sizeof(path), "." PCSX_DOT_DIR "lastcdimg.txt");
f = fopen(path, is_get ? "r" : "w");
- if (f == NULL)
- return -1;
+ if (f == NULL) {
+ ret = -1;
+ goto out;
+ }
if (is_get) {
ret = fread(last_selected_fname, 1, sizeof(last_selected_fname) - 1, f);
@@ -424,6 +530,17 @@ static int menu_do_last_cd_img(int is_get)
fprintf(f, "%s\n", last_selected_fname);
fclose(f);
+out:
+ if (is_get) {
+ for (i = 0; last_selected_fname[0] == 0
+ || stat64(last_selected_fname, &st) != 0; i++)
+ {
+ if (i >= ARRAY_SIZE(defaults))
+ break;
+ strcpy(last_selected_fname, defaults[i]);
+ }
+ }
+
return 0;
}
@@ -547,20 +664,25 @@ fail:
return ret;
}
+static const char *filter_exts[] = {
+ "bin", "img", "mdf", "iso", "cue", "z",
+ "bz", "znx", "pbp", "cbn", NULL
+};
+
// rrrr rggg gggb bbbb
static unsigned short fname2color(const char *fname)
{
- static const char *cdimg_exts[] = { ".bin", ".img", ".mdf", ".iso", ".cue", ".z",
- ".bz", ".znx", ".pbp", ".cbn" };
- static const char *other_exts[] = { ".ccd", ".toc", ".mds", ".sub",
- ".table", ".index", ".sbi" };
+ static const char *other_exts[] = {
+ "ccd", "toc", "mds", "sub", "table", "index", "sbi"
+ };
const char *ext = strrchr(fname, '.');
int i;
if (ext == NULL)
return 0xffff;
- for (i = 0; i < array_size(cdimg_exts); i++)
- if (strcasecmp(ext, cdimg_exts[i]) == 0)
+ ext++;
+ for (i = 0; filter_exts[i] != NULL; i++)
+ if (strcasecmp(ext, filter_exts[i]) == 0)
return 0x7bff;
for (i = 0; i < array_size(other_exts); i++)
if (strcasecmp(ext, other_exts[i]) == 0)
@@ -570,10 +692,6 @@ static unsigned short fname2color(const char *fname)
static void draw_savestate_bg(int slot);
-static const char *filter_exts[] = {
- ".mp3", ".MP3", ".txt", ".htm", "html", ".jpg", ".pnd"
-};
-
#define MENU_ALIGN_LEFT
#ifdef __ARM_ARCH_7A__ // assume hires device
#define MENU_X2 1
@@ -603,8 +721,8 @@ static void draw_savestate_bg(int slot)
if (f == NULL)
return;
- if (gzseek(f, 0x29933d, SEEK_SET) != 0x29933d) {
- fprintf(stderr, "gzseek failed\n");
+ if ((ret = (int)gzseek(f, 0x29933d, SEEK_SET)) != 0x29933d) {
+ fprintf(stderr, "gzseek failed: %d\n", ret);
gzclose(f);
return;
}
@@ -1818,9 +1936,11 @@ static int run_bios(void)
static int run_exe(void)
{
+ const char *exts[] = { "exe", NULL };
const char *fname;
- fname = menu_loop_romsel(last_selected_fname, sizeof(last_selected_fname));
+ fname = menu_loop_romsel(last_selected_fname,
+ sizeof(last_selected_fname), exts, NULL);
if (fname == NULL)
return -1;
@@ -1874,7 +1994,9 @@ static int romsel_run(void)
int prev_gpu, prev_spu;
const char *fname;
- fname = menu_loop_romsel(last_selected_fname, sizeof(last_selected_fname));
+ fname = menu_loop_romsel(last_selected_fname,
+ sizeof(last_selected_fname), filter_exts,
+ optional_cdimg_filter);
if (fname == NULL)
return -1;
@@ -1898,16 +2020,18 @@ static int romsel_run(void)
return -1;
}
- strcpy(last_selected_fname, rom_fname_reload);
+ strcpy(last_selected_fname, fname);
menu_do_last_cd_img(0);
return 0;
}
static int swap_cd_image(void)
{
- char *fname;
+ const char *fname;
- fname = menu_loop_romsel(last_selected_fname, sizeof(last_selected_fname));
+ fname = menu_loop_romsel(last_selected_fname,
+ sizeof(last_selected_fname), filter_exts,
+ optional_cdimg_filter);
if (fname == NULL)
return -1;
@@ -1929,7 +2053,7 @@ static int swap_cd_image(void)
SetCdOpenCaseTime(time(NULL) + 2);
LidInterrupt();
- strcpy(last_selected_fname, rom_fname_reload);
+ strcpy(last_selected_fname, fname);
return 0;
}
@@ -1953,11 +2077,12 @@ static int swap_cd_multidisk(void)
static void load_pcsx_cht(void)
{
+ const char *exts[] = { "cht", NULL };
+ const char *fname;
char path[256];
- char *fname;
path[0] = 0;
- fname = menu_loop_romsel(path, sizeof(path));
+ fname = menu_loop_romsel(path, sizeof(path), exts, NULL);
if (fname == NULL)
return;
@@ -2278,8 +2403,6 @@ void menu_init(void)
char buff[MAXPATHLEN];
int i;
- strcpy(last_selected_fname, "/media");
-
cpu_clock_st = cpu_clock = plat_target_cpu_clock_get();
scan_bios_plugins();
@@ -2380,9 +2503,12 @@ void menu_prepare_emu(void)
plat_video_menu_leave();
psxCpu = (Config.Cpu == CPU_INTERPRETER) ? &psxInt : &psxRec;
- if (psxCpu != prev_cpu)
+ if (psxCpu != prev_cpu) {
+ prev_cpu->Shutdown();
+ psxCpu->Init();
// note that this does not really reset, just clears drc caches
psxCpu->Reset();
+ }
// core doesn't care about Config.Cdda changes,
// so handle them manually here
diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c
index aa771ed..dfff868 100644
--- a/frontend/plugin_lib.c
+++ b/frontend/plugin_lib.c
@@ -44,7 +44,7 @@ void *tsdev;
void *pl_vout_buf;
int g_layer_x, g_layer_y, g_layer_w, g_layer_h;
static int pl_vout_w, pl_vout_h, pl_vout_bpp; /* output display/layer */
-static int pl_vout_scale;
+static int pl_vout_scale, pl_vout_yoffset;
static int psx_w, psx_h, psx_bpp;
static int vsync_cnt;
static int is_pal, frame_interval, frame_interval1024;
@@ -230,6 +230,7 @@ static int resolution_ok(int w, int h)
static void pl_vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp)
{
int vout_w, vout_h, vout_bpp;
+ int buf_yoffset = 0;
// special h handling, Wipeout likes to change it by 1-6
static int vsync_cnt_ms_prev;
@@ -243,6 +244,12 @@ static void pl_vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp)
vout_h = h;
vout_bpp = psx_bpp = bpp;
+ // don't use very low heights
+ if (vout_h < 192) {
+ buf_yoffset = (192 - vout_h) / 2;
+ vout_h = 192;
+ }
+
pl_vout_scale = 1;
#ifdef __ARM_NEON__
if (soft_filter) {
@@ -268,7 +275,11 @@ static void pl_vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp)
pl_vout_w = vout_w;
pl_vout_h = vout_h;
pl_vout_bpp = vout_bpp;
+ pl_vout_yoffset = buf_yoffset;
}
+ if (pl_vout_buf != NULL)
+ pl_vout_buf = (char *)pl_vout_buf
+ + pl_vout_yoffset * pl_vout_w * pl_vout_bpp / 8;
menu_notify_mode_change(pl_vout_w, pl_vout_h, pl_vout_bpp);
}
@@ -366,6 +377,10 @@ out:
// let's flip now
pl_vout_buf = plat_gvideo_flip();
+ if (pl_vout_buf != NULL)
+ pl_vout_buf = (char *)pl_vout_buf
+ + pl_vout_yoffset * pl_vout_w * pl_vout_bpp / 8;
+
pl_rearmed_cbs.flip_cnt++;
}
@@ -591,6 +606,9 @@ void pl_frame_limit(void)
struct timeval now;
int diff, usadj;
+ if (g_resetting)
+ return;
+
vsync_cnt++;
/* doing input here because the pad is polled