psp, scaling revisited

This commit is contained in:
kub 2021-09-10 18:53:31 +02:00
parent d5d1778252
commit 0924243a53
6 changed files with 57 additions and 119 deletions

2
configure vendored
View file

@ -128,7 +128,7 @@ set_platform()
# use newlib # use newlib
SYSLIBS="-lc -lpspuser -lpspkernel" SYSLIBS="-lc -lpspuser -lpspkernel"
CFLAGS="$CFLAGS -D__PSP__" CFLAGS="$CFLAGS -D__PSP__"
MFLAGS="-march=mips32r2" MFLAGS="-march=allegrex"
ARCH=mipsel ARCH=mipsel
;; ;;
*) *)

View file

@ -338,18 +338,6 @@ static int custom_read(menu_entry *me, const char *var, const char *val)
return 1; return 1;
/* PSP */ /* PSP */
case MA_OPT3_SCALE:
if (strcasecmp(var, "Scale factor") != 0) return 0;
currentConfig.scale = atof(val);
return 1;
case MA_OPT3_HSCALE32:
if (strcasecmp(var, "Hor. scale (for low res. games)") != 0) return 0;
currentConfig.hscale32 = atof(val);
return 1;
case MA_OPT3_HSCALE40:
if (strcasecmp(var, "Hor. scale (for hi res. games)") != 0) return 0;
currentConfig.hscale40 = atof(val);
return 1;
case MA_OPT3_VSYNC: case MA_OPT3_VSYNC:
// XXX: use enum // XXX: use enum
if (strcasecmp(var, "Wait for vsync") != 0) return 0; if (strcasecmp(var, "Wait for vsync") != 0) return 0;

View file

@ -40,10 +40,19 @@ enum {
// linux, GP2X: // linux, GP2X:
EOPT_SCALE_SW = 1, EOPT_SCALE_SW = 1,
EOPT_SCALE_HW, EOPT_SCALE_HW,
// PSP horiz:
EOPT_SCALE_43 = 1, // DAR 4:3 (12:9)
EOPT_SCALE_WIDE, // DAR 14:9
EOPT_SCALE_FULL, // DAR 16:9
// PSP vert:
EOPT_VSCALE_PAL = 1, // always 240 lines
EOPT_VSCALE_FULL, // zoomed to full height
}; };
enum { enum {
EOPT_FILTER_NONE = 0, EOPT_FILTER_NONE = 0,
// PSP texture filtering
EOPT_FILTER_BILINEAR = 1,
// software scalers // software scalers
EOPT_FILTER_SMOOTHER = 1, EOPT_FILTER_SMOOTHER = 1,
EOPT_FILTER_BILINEAR1, EOPT_FILTER_BILINEAR1,
@ -75,8 +84,6 @@ typedef struct _currentConfig_t {
int scaling; // EOPT_SCALE_* int scaling; // EOPT_SCALE_*
int vscaling; int vscaling;
int rotation; // for UIQ int rotation; // for UIQ
float scale; // psp: screen scale
float hscale32, hscale40; // psp: horizontal scale
int gamma2; // psp: black level int gamma2; // psp: black level
int turbo_rate; int turbo_rate;
int renderer; int renderer;

View file

@ -62,13 +62,7 @@ typedef enum
MA_OPT2_MAX_FRAMESKIP, MA_OPT2_MAX_FRAMESKIP,
MA_OPT2_PWM_IRQ_OPT, MA_OPT2_PWM_IRQ_OPT,
MA_OPT2_DONE, MA_OPT2_DONE,
MA_OPT3_SCALE, /* psp (all OPT3) */ MA_OPT3_GAMMAA, /* psp (all OPT3) */
MA_OPT3_HSCALE32,
MA_OPT3_HSCALE40,
MA_OPT3_GAMMAA,
MA_OPT3_PRES_NOSCALE,
MA_OPT3_PRES_SCALE43,
MA_OPT3_PRES_FULLSCR,
MA_OPT3_FILTERING, MA_OPT3_FILTERING,
MA_OPT3_VSYNC, MA_OPT3_VSYNC,
MA_OPT3_BLACKLVL, MA_OPT3_BLACKLVL,

View file

@ -50,9 +50,9 @@ static int need_pal_upload = 0;
static u16 __attribute__((aligned(16))) osd_buf[512*8]; // buffer for osd text static u16 __attribute__((aligned(16))) osd_buf[512*8]; // buffer for osd text
static int h32_mode = 0;
static int out_x, out_y; static int out_x, out_y;
static int out_w, out_h; static int out_w, out_h;
static float hscale, vscale;
static struct in_default_bind in_psp_defbinds[] = static struct in_default_bind in_psp_defbinds[] =
{ {
@ -152,11 +152,8 @@ static void set_scaling_params(void)
int fbimg_width, fbimg_height, fbimg_xoffs, fbimg_yoffs, border_hack = 0; int fbimg_width, fbimg_height, fbimg_xoffs, fbimg_yoffs, border_hack = 0;
g_vertices[0].z = g_vertices[1].z = 0; g_vertices[0].z = g_vertices[1].z = 0;
fbimg_height = (int)(out_h * currentConfig.scale + 0.5); fbimg_height = (int)(out_h * vscale + 0.5);
if (!h32_mode) fbimg_width = (int)(out_w * hscale + 0.5);
fbimg_width = (int)(out_w * currentConfig.scale * currentConfig.hscale40 + 0.5);
else
fbimg_width = (int)(out_w * currentConfig.scale * currentConfig.hscale32 + 0.5);
if (fbimg_width & 1) fbimg_width++; // make even if (fbimg_width & 1) fbimg_width++; // make even
if (fbimg_height & 1) fbimg_height++; if (fbimg_height & 1) fbimg_height++;
@ -370,7 +367,7 @@ static void vidResetMode(void)
sceGuClutMode(GU_PSM_5650,0,0xff,0); sceGuClutMode(GU_PSM_5650,0,0xff,0);
sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGB); sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGB);
if (currentConfig.scaling) if (currentConfig.filter)
sceGuTexFilter(GU_LINEAR, GU_LINEAR); sceGuTexFilter(GU_LINEAR, GU_LINEAR);
else sceGuTexFilter(GU_NEAREST, GU_NEAREST); else sceGuTexFilter(GU_NEAREST, GU_NEAREST);
sceGuTexScale(1.0f,1.0f); sceGuTexScale(1.0f,1.0f);
@ -575,10 +572,9 @@ void pemu_prep_defconfig(void)
defaultConfig.s_PsndRate = 22050; defaultConfig.s_PsndRate = 22050;
defaultConfig.s_PicoCDBuffers = 64; defaultConfig.s_PicoCDBuffers = 64;
defaultConfig.CPUclock = 333; defaultConfig.CPUclock = 333;
defaultConfig.scaling = 1; // bilinear filtering for psp defaultConfig.filter = EOPT_FILTER_BILINEAR; // bilinear filtering
defaultConfig.scale = 1.20; // fullscreen defaultConfig.scaling = EOPT_SCALE_43;
defaultConfig.hscale40 = 1.25; defaultConfig.vscaling = EOPT_VSCALE_FULL;
defaultConfig.hscale32 = 1.56;
defaultConfig.EmuOpt |= EOPT_SHOW_RTC; defaultConfig.EmuOpt |= EOPT_SHOW_RTC;
} }
@ -587,12 +583,6 @@ void pemu_validate_config(void)
{ {
if (currentConfig.CPUclock < 33 || currentConfig.CPUclock > 333) if (currentConfig.CPUclock < 33 || currentConfig.CPUclock > 333)
currentConfig.CPUclock = 333; currentConfig.CPUclock = 333;
if (currentConfig.scaling < 0.01)
currentConfig.scaling = 0.01;
if (currentConfig.hscale40 < 0.01)
currentConfig.hscale40 = 0.01;
if (currentConfig.hscale32 < 0.01)
currentConfig.hscale32 = 0.01;
if (currentConfig.gamma < -4 || currentConfig.gamma > 16) if (currentConfig.gamma < -4 || currentConfig.gamma > 16)
currentConfig.gamma = 0; currentConfig.gamma = 0;
if (currentConfig.gamma2 < 0 || currentConfig.gamma2 > 2) if (currentConfig.gamma2 < 0 || currentConfig.gamma2 > 2)
@ -676,12 +666,37 @@ void plat_update_volume(int has_changed, int is_up)
/* prepare for MD screen mode change */ /* prepare for MD screen mode change */
void emu_video_mode_change(int start_line, int line_count, int start_col, int col_count) void emu_video_mode_change(int start_line, int line_count, int start_col, int col_count)
{ {
h32_mode = col_count < 320; out_y = start_line; out_x = start_col;
out_y = start_line; out_x = (h32_mode ? 32 : 0); out_h = line_count; out_w = col_count;
out_h = line_count; out_w = (h32_mode ? 256:320);
switch (currentConfig.vscaling) {
case EOPT_VSCALE_PAL:
vscale = (float)270/240;
break;
case EOPT_VSCALE_FULL:
vscale = (float)270/line_count;
break;
default:
vscale = 1;
break;
}
switch (currentConfig.scaling) {
case EOPT_SCALE_43:
hscale = (float)360/col_count;
break;
case EOPT_SCALE_WIDE:
hscale = (float)420/col_count;
break;
case EOPT_SCALE_FULL:
hscale = (float)480/col_count;
break;
default:
hscale = 1;
break;
}
vidResetMode(); vidResetMode();
if (h32_mode) // clear borders from h40 remnants if (col_count < 320) // clear borders from h40 remnants
clearArea(1); clearArea(1);
} }

View file

@ -1,84 +1,18 @@
static const char h_scale43[] = "Scales low and high res to 4:3 screen size.\n" static const char *men_hscaling_opts[] = { "OFF", "4:3", "wide", "fullscreen", NULL };
"For 240 line PAL use Scale factor 1.12"; static const char *men_vscaling_opts[] = { "OFF", "PAL", "fullscreen", NULL };
static const char h_scalefull[] = "Scales low and high res to full screen.\n" static const char *men_filter_opts[] = { "OFF", "bilinear" };
"For 240 line PAL use scaling 1.12, 1.6, 1.28";
#define MENU_OPTIONS_GFX \ #define MENU_OPTIONS_GFX \
mee_cust("Scale factor", MA_OPT3_SCALE, mh_scale, ms_scale), \ mee_enum ("Horizontal scaling", MA_OPT_SCALING, currentConfig.scaling, men_hscaling_opts), \
mee_cust("Hor. scale (for low res. games)", MA_OPT3_HSCALE32, mh_scale, ms_scale), \ mee_enum ("Vertical scaling", MA_OPT_VSCALING, currentConfig.vscaling, men_vscaling_opts), \
mee_cust("Hor. scale (for hi res. games)", MA_OPT3_HSCALE40, mh_scale, ms_scale), \ mee_enum_h ("Scaler type", MA_OPT3_FILTERING, currentConfig.filter, men_filter_opts, NULL), \
mee_onoff("Bilinear filtering", MA_OPT3_FILTERING, currentConfig.scaling, 1), \
mee_range ("Gamma adjustment", MA_OPT3_GAMMAA, currentConfig.gamma, -4, 16), \ mee_range ("Gamma adjustment", MA_OPT3_GAMMAA, currentConfig.gamma, -4, 16), \
mee_range ("Black level", MA_OPT3_BLACKLVL, currentConfig.gamma2, 0, 2), \ mee_range ("Black level", MA_OPT3_BLACKLVL, currentConfig.gamma2, 0, 2), \
mee_onoff("wait for vsync", MA_OPT3_VSYNC, currentConfig.EmuOpt, EOPT_VSYNC), \ mee_onoff ("Wait for vsync", MA_OPT3_VSYNC, currentConfig.EmuOpt, EOPT_VSYNC), \
mee_cust_nosave("Set to unscaled centered", MA_OPT3_PRES_NOSCALE, mh_preset_scale, NULL), \
mee_cust_nosave("Set to 4:3 scaled", MA_OPT3_PRES_SCALE43, mh_preset_scale, NULL), \
mee_cust_nosave("Set to fullscreen", MA_OPT3_PRES_FULLSCR, mh_preset_scale, NULL), \
#define MENU_OPTIONS_ADV #define MENU_OPTIONS_ADV
static const char *ms_scale(int id, int *offs)
{
float val = 0;
switch (id) {
case MA_OPT3_SCALE: val = currentConfig.scale; break;
case MA_OPT3_HSCALE32: val = currentConfig.hscale32; break;
case MA_OPT3_HSCALE40: val = currentConfig.hscale40; break;
}
sprintf(static_buff, "%.2f", val);
return static_buff;
}
static int mh_scale(int id, int keys)
{
float *val = NULL;
switch (id) {
case MA_OPT3_SCALE: val = &currentConfig.scale; break;
case MA_OPT3_HSCALE32: val = &currentConfig.hscale32; break;
case MA_OPT3_HSCALE40: val = &currentConfig.hscale40; break;
}
if (keys & PBTN_LEFT) *val += -0.01;
if (keys & PBTN_RIGHT) *val += +0.01;
if (*val < 0.01) *val = +0.01;
return 0;
}
static int mh_preset_scale(int id, int keys)
{
switch (id) {
case MA_OPT3_PRES_NOSCALE:
currentConfig.scale = 1.0;
currentConfig.hscale32 = 1.0;
currentConfig.hscale40 = 1.0;
break;
case MA_OPT3_PRES_SCALE43:
// parameters for 224 lines; for 240 lines scale = 1.125
// moreover, H32 and H40 had the same width on a TV.
currentConfig.scale = 1.2;
currentConfig.hscale32 = 1.25;
currentConfig.hscale40 = 1.0;
break;
case MA_OPT3_PRES_FULLSCR:
// uses width 460 to avoid some ugly moiree effects
currentConfig.scale = 1.2;
currentConfig.hscale32 = 1.5;
currentConfig.hscale40 = 1.2;
break;
}
return 0;
}
static menu_entry e_menu_gfx_options[];
void psp_menu_init(void) void psp_menu_init(void)
{ {
int i;
for (i = 0; e_menu_gfx_options[i].name; i++) {
switch (e_menu_gfx_options[i].id) {
case MA_OPT3_PRES_SCALE43: e_menu_gfx_options[i].help = h_scale43; break;
case MA_OPT3_PRES_FULLSCR: e_menu_gfx_options[i].help = h_scalefull; break;
}
}
} }