aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneonloop2021-04-03 19:00:40 +0000
committerneonloop2021-04-03 19:00:40 +0000
commitf924bac9babee54b91c1a66055afdabb9feea339 (patch)
tree4bbf74f9da0ed0bcf377d201adbbf9935073fe8e
parent871d11afb4cd574388b6f56074ec553034e1e117 (diff)
downloadpcsx_rearmed-f924bac9babee54b91c1a66055afdabb9feea339.tar.gz
pcsx_rearmed-f924bac9babee54b91c1a66055afdabb9feea339.tar.bz2
pcsx_rearmed-f924bac9babee54b91c1a66055afdabb9feea339.zip
Blit correctly when rendered w/h < screen w/h
This fixes and centers Lunar FMVs.
-rw-r--r--frontend/plat_trimui.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/frontend/plat_trimui.c b/frontend/plat_trimui.c
index 6b1038a..f9502d6 100644
--- a/frontend/plat_trimui.c
+++ b/frontend/plat_trimui.c
@@ -176,33 +176,37 @@ void plat_minimize(void)
{
}
-#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_; \
- unsigned char *conv = (unsigned char *)cspace_buf; \
- unsigned char *dst = (unsigned char *)screen->pixels + \
- (fb_offset_y * 320 + fb_offset_x) * sizeof(uint16_t); \
- int dst_stride = 640; \
- int len = psx_src_width * psx_bpp / 8; \
- int i; \
- void (*convertfunc)(void *dst, const void *src, int bytes); \
- convertfunc = psx_bpp == 24 ? bgr888_to_rgb565 : bgr555_to_rgb565; \
- \
- SDL_LockSurface(screen); \
- vram += psx_offset_y * 1024 + psx_offset_x; \
- for (i = psx_src_height; i > 0; i--, \
- vram += psx_step * 1024, \
- dst += dst_stride, \
- conv += dst_stride) { \
- if (scale) { \
- convertfunc(conv, vram, len); \
- blitfunc(dst, conv, dst_stride); \
- } else { \
- convertfunc(dst, vram, len); \
- } \
- } \
- SDL_UnlockSurface(screen); \
+#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 ); \
+ unsigned char *conv = (unsigned char *)cspace_buf; \
+ unsigned char *dst = (unsigned char *)screen->pixels + \
+ (dst_offset_y * 320 + dst_offset_x) * sizeof(uint16_t); \
+ int dst_stride = 640; \
+ int len = w * psx_bpp / 8; \
+ int i; \
+ void (*convertfunc)(void *dst, const void *src, int bytes); \
+ convertfunc = psx_bpp == 24 ? bgr888_to_rgb565 : bgr555_to_rgb565; \
+ \
+ 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); \
+ blitfunc(dst, conv, dst_stride); \
+ } else { \
+ convertfunc(dst, vram, len); \
+ } \
+ } \
+ SDL_UnlockSurface(screen); \
}
make_flip_func(raw_blit_soft, false, memcpy)
@@ -223,7 +227,7 @@ void *plat_gvideo_set_mode(int *w_, int *h_, int *bpp_)
psx_height = h;
psx_bpp = bpp;
- switch (w + (bpp != 16) + !soft_scaling) {
+ switch (w + (bpp != 16)) {
case 640:
pl_plat_blit = raw_blit_soft_640;
w_max = 640;