Merge pull request #444 from justinweiss/hires-downscale
authorhizzlekizzle <hizzlekizzle@users.noreply.github.com>
Thu, 13 Aug 2020 23:06:23 +0000 (18:06 -0500)
committerGitHub <noreply@github.com>
Thu, 13 Aug 2020 23:06:23 +0000 (18:06 -0500)
Add an option to downscale hi-res views

1  2 
frontend/libretro.c
frontend/libretro_core_options.h
frontend/plugin_lib.h
plugins/gpulib/gpu.h

diff --combined frontend/libretro.c
@@@ -1999,6 -1999,17 +1999,17 @@@ static void update_variables(bool in_fl
           pl_rearmed_cbs.gpu_unai.blending = 1;
     }
  
+    var.key = "pcsx_rearmed_gpu_unai_scale_hires";
+    var.value = NULL;
+    if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
+    {
+       if (strcmp(var.value, "disabled") == 0)
+          pl_rearmed_cbs.gpu_unai.scale_hires = 0;
+       else if (strcmp(var.value, "enabled") == 0)
+          pl_rearmed_cbs.gpu_unai.scale_hires = 1;
+    }
     var.key = "pcsx_rearmed_show_gpu_unai_settings";
     var.value = NULL;
  
        {
           unsigned i;
           struct retro_core_option_display option_display;
-          char gpu_unai_option[5][40] = {
+          char gpu_unai_option[6][40] = {
              "pcsx_rearmed_gpu_unai_blending",
              "pcsx_rearmed_gpu_unai_lighting",
              "pcsx_rearmed_gpu_unai_fast_lighting",
              "pcsx_rearmed_gpu_unai_ilace_force",
-             "pcsx_rearmed_gpu_unai_pixel_skip"
+             "pcsx_rearmed_gpu_unai_pixel_skip",
+             "pcsx_rearmed_gpu_unai_scale_hires"
           };
  
           option_display.visible = show_advanced_gpu_unai_settings;
  
-          for (i = 0; i < 5; i++)
+          for (i = 0; i < 6; i++)
           {
              option_display.key = gpu_unai_option[i];
              environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display);
@@@ -2885,17 -2897,3 +2897,17 @@@ void SysPrintf(const char *fmt, ...
     if (log_cb)
        log_cb(RETRO_LOG_INFO, "%s", msg);
  }
 +
 +/* Prints debug-level logs */
 +void SysDLog(const char *fmt, ...)
 +{
 +   va_list list;
 +   char msg[512];
 +
 +   va_start(list, fmt);
 +   vsprintf(msg, fmt, list);
 +   va_end(list);
 +
 +   if (log_cb)
 +      log_cb(RETRO_LOG_DEBUG, "%s", msg);
 +}
@@@ -937,7 -937,7 +937,7 @@@ struct retro_core_option_definition opt
           { "enabled",  NULL },
           { NULL, NULL},
        },
 -      "enabled",
 +      "disabled",
     },
     {
        "pcsx_rearmed_gpu_unai_ilace_force",
        },
        "disabled",
     },
+    {
+       "pcsx_rearmed_gpu_unai_scale_hires",
+       "(GPU) Enable Hi-Res Downscaling",
+       "When enabled, will scale hi-res modes to 320x240, skipping unrendered pixels.",
+       {
+          { "disabled", NULL },
+          { "enabled",  NULL },
+          { NULL, NULL},
+       },
+       "disabled",
+    },
  #endif /* GPU UNAI Advanced Settings */
  
     {
diff --combined frontend/plugin_lib.h
@@@ -1,5 -1,3 +1,5 @@@
 +#ifndef __PLUGIN_LIB_H__
 +#define __PLUGIN_LIB_H__
  
  enum {
        DKEY_SELECT = 0,
@@@ -93,6 -91,7 +93,7 @@@ struct rearmed_cbs 
                int   abe_hack;
                int   no_light, no_blend;
                int   lineskip;
+               int   scale_hires;
        } gpu_unai;
        struct {
                int   dwActFixes;
@@@ -120,5 -119,3 +121,5 @@@ extern void (*pl_plat_hud_print)(int x
  #ifndef ARRAY_SIZE
  #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
  #endif
 +
 +#endif /* __PLUGIN_LIB_H__ */
diff --combined plugins/gpulib/gpu.h
@@@ -8,9 -8,6 +8,9 @@@
   * See the COPYING file in the top-level directory.
   */
  
 +#ifndef __GPULIB_GPU_H__
 +#define __GPULIB_GPU_H__
 +
  #include <stdint.h>
  
  #ifdef __cplusplus
@@@ -71,6 -68,8 +71,8 @@@ struct psx_gpu 
      uint32_t blanked:1;
      uint32_t enhancement_enable:1;
      uint32_t enhancement_active:1;
+     uint32_t downscale_enable:1;
+     uint32_t downscale_active:1;
      uint32_t *frame_count;
      uint32_t *hcnt; /* hsync count */
      struct {
@@@ -94,6 -93,8 +96,8 @@@
    int useDithering:1; /* 0 - off , 1 - on */
    uint16_t *(*get_enhancement_bufer)
      (int *x, int *y, int *w, int *h, int *vram_h);
+   uint16_t *(*get_downscale_buffer)
+     (int *x, int *y, int *w, int *h, int *vram_h);
    void *(*mmap)(unsigned int size);
    void  (*munmap)(void *ptr, unsigned int size);
  };
@@@ -143,5 -144,3 +147,5 @@@ void GPUrearmedCallbacks(const struct r
  #ifdef __cplusplus
  }
  #endif
 +
 +#endif /* __GPULIB_GPU_H__ */