aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneonloop2021-04-03 21:26:23 +0000
committerneonloop2021-04-03 21:26:23 +0000
commit076eba28b80edeb7566d8e12713b029bd324a67b (patch)
tree979e2953c23417bfa1a2775a92b379cbfc72ded2
parentf924bac9babee54b91c1a66055afdabb9feea339 (diff)
downloadpcsx_rearmed-076eba28b80edeb7566d8e12713b029bd324a67b.tar.gz
pcsx_rearmed-076eba28b80edeb7566d8e12713b029bd324a67b.tar.bz2
pcsx_rearmed-076eba28b80edeb7566d8e12713b029bd324a67b.zip
Adds an option for scaling 256px-wide screens
This option takes over the Software Scaling option in the display menu. There is a performance cost (about 10%). It does subpixel scaling to keep the image as sharp as it can be. This also moves scaling into its own loop -- I saw a 4-6% increase in performance when upscaling and downscaling after making that change.
-rw-r--r--frontend/menu.c7
-rw-r--r--frontend/menu_trimui.h7
-rw-r--r--frontend/plat_trimui.c67
3 files changed, 61 insertions, 20 deletions
diff --git a/frontend/menu.c b/frontend/menu.c
index fc95294..b73e257 100644
--- a/frontend/menu.c
+++ b/frontend/menu.c
@@ -132,6 +132,7 @@ static int bios_sel, gpu_plugsel, spu_plugsel;
#define MENU_SHOW_FULLSCREEN 1
#define MENU_SHOW_VOLUME 0
#define MENU_SHOW_DISPLAY 1
+#define MENU_SHOW_PEOPS 1
#endif
static int min(int x, int y) { return x < y ? x : y; }
@@ -2560,10 +2561,8 @@ void menu_init(void)
me_enable(e_menu_keyconfig, MA_CTRL_DEADZONE, MENU_SHOW_DEADZONE);
me_enable(e_menu_options, MA_OPT_DISP_OPTS, MENU_SHOW_DISPLAY);
-#ifdef TRIMUI
- me_enable(e_menu_plugin_options, MA_PLUG_PEOPS, FALSE);
- me_enable(e_menu_plugin_options, MA_PLUG_PEOPSGL, FALSE);
-#endif
+ me_enable(e_menu_plugin_options, MA_PLUG_PEOPS, MENU_SHOW_PEOPS);
+ me_enable(e_menu_plugin_options, MA_PLUG_PEOPSGL, MENU_SHOW_PEOPS);
}
void menu_notify_mode_change(int w, int h, int bpp)
diff --git a/frontend/menu_trimui.h b/frontend/menu_trimui.h
index 6fa0fdc..87824f2 100644
--- a/frontend/menu_trimui.h
+++ b/frontend/menu_trimui.h
@@ -19,13 +19,14 @@
#define MENU_BIOS_PATH "pcsx_rearmed/bios/"
#define MENU_SHOW_VARSCALER 0
#define MENU_SHOW_VOUTMODE 0
-#define MENU_SHOW_SCALER2 0
+#define MENU_SHOW_SCALER2 1
#define MENU_SHOW_NUBS_BTNS 0
#define MENU_SHOW_VIBRATION 0
#define MENU_SHOW_DEADZONE 0
#define MENU_SHOW_MINIMIZE 0
-#define MENU_SHOW_FULLSCREEN 1
+#define MENU_SHOW_FULLSCREEN 0
#define MENU_SHOW_VOLUME 0
-#define MENU_SHOW_DISPLAY 0
+#define MENU_SHOW_DISPLAY 1
+#define MENU_SHOW_PEOPS 0
#endif
diff --git a/frontend/plat_trimui.c b/frontend/plat_trimui.c
index f9502d6..1042704 100644
--- a/frontend/plat_trimui.c
+++ b/frontend/plat_trimui.c
@@ -176,17 +176,48 @@ void plat_minimize(void)
{
}
+#define EXTRACT(c, mask, offset) ((c >> offset) & mask)
+#define BLENDCHANNEL(cl, cm, cr, mask, offset) ((((EXTRACT(cl, mask, offset) + 2 * EXTRACT(cm, mask, offset) + EXTRACT(cr, mask, offset)) >> 2) & mask) << offset)
+#define BLENDB(cl, cm, cr) BLENDCHANNEL(cl, cm, cr, 0b0000000000011111, 0)
+#define BLENDG(cl, cm, cr) BLENDCHANNEL(cl, cm, cr, 0b0000011111100000, 0)
+#define BLENDR(cl, cm, cr) BLENDCHANNEL(cl, cm, cr, 0b0011111000000000, 2)
+static void blit320_256(unsigned char *dst8, const unsigned char *src8, int unused)
+{
+ int source = 0;
+ int x;
+ uint16_t *src = (uint16_t *)src8;
+ uint16_t *dst = (uint16_t *)dst8;
+
+ for (x = 0; x < 320/5; x++)
+ {
+ register uint16_t a, b, c, d;
+
+ a = src[source];
+ b = src[source+1];
+ c = src[source+2];
+ d = src[source+3];
+
+ *dst++ = a;
+ *dst++ = b;
+ *dst++ = BLENDB(b, b, c) | BLENDG(b, c, c) | BLENDR(c, c, c);
+ *dst++ = BLENDB(c, c, c) | BLENDG(c, c, d) | BLENDR(c, d, d);
+ *dst++ = d;
+
+ source+=4;
+ }
+}
+
#define make_flip_func(name, scale, blitfunc) \
static void name(int doffs, const void *vram_, int w_, int h_, int sstride, int bgr24) \
{ \
const unsigned short *vram = vram_; \
int w = w_ < psx_src_width ? w_ : psx_src_width; \
int h = h_ < psx_src_height ? h_ : psx_src_height; \
- int dst_offset_x = fb_offset_x + ((psx_src_width - w) / 2 ); \
- int dst_offset_y = fb_offset_y + ((psx_src_height - h) / 2 ); \
+ int dst_offset_x = (fb_offset_x + ((psx_src_width - w) / 2)) * sizeof(uint16_t); \
+ int dst_offset_y = (fb_offset_y + ((psx_src_height - h) / 2)) * sizeof(uint16_t); \
unsigned char *conv = (unsigned char *)cspace_buf; \
- unsigned char *dst = (unsigned char *)screen->pixels + \
- (dst_offset_y * 320 + dst_offset_x) * sizeof(uint16_t); \
+ unsigned char *dst = (unsigned char *)screen->pixels + dst_offset_y * 320; \
+ unsigned char *buf = (scale ? conv : dst) + dst_offset_x; \
int dst_stride = 640; \
int len = w * psx_bpp / 8; \
int i; \
@@ -195,20 +226,20 @@ void plat_minimize(void)
\
SDL_LockSurface(screen); \
vram += psx_offset_y * 1024 + psx_offset_x; \
- for (i = h; i > 0; i--, \
- vram += psx_step * 1024, \
- dst += dst_stride, \
- conv += dst_stride) { \
- if (scale) { \
- convertfunc(conv, vram, len); \
+ \
+ for (i = h; i > 0; i--, vram += psx_step * 1024, buf += dst_stride) { \
+ convertfunc(buf, vram, len); \
+ } \
+ \
+ if (scale) { \
+ for (i = h; i > 0; i--, dst += dst_stride, conv += dst_stride) { \
blitfunc(dst, conv, dst_stride); \
- } else { \
- convertfunc(dst, vram, len); \
} \
} \
SDL_UnlockSurface(screen); \
}
+make_flip_func(raw_blit_soft_256, true, blit320_256)
make_flip_func(raw_blit_soft, false, memcpy)
make_flip_func(raw_blit_soft_368, true, blit320_368)
make_flip_func(raw_blit_soft_512, true, blit320_512)
@@ -241,6 +272,16 @@ void *plat_gvideo_set_mode(int *w_, int *h_, int *bpp_)
pl_plat_blit = raw_blit_soft_368;
w_max = 368;
break;
+ case 256:
+ case 257:
+ if (soft_scaling) {
+ pl_plat_blit = raw_blit_soft_256;
+ w_max = 256;
+ } else {
+ pl_plat_blit = raw_blit_soft;
+ w_max = 320;
+ }
+ break;
default:
pl_plat_blit = raw_blit_soft;
w_max = 320;
@@ -259,7 +300,7 @@ void *plat_gvideo_set_mode(int *w_, int *h_, int *bpp_)
w = w_max;
}
fb_offset_x = 0;
- if (w < 320)
+ if (w < 320 && !soft_scaling)
fb_offset_x = 320/2 - w / 2;
if (h > 240) {
poff_h = h / 2 - 240/2;