Merge pull request #120 from pjft/pjft-experimental
authorTwinaphex <libretro@gmail.com>
Sun, 7 May 2017 00:17:23 +0000 (02:17 +0200)
committerGitHub <noreply@github.com>
Sun, 7 May 2017 00:17:23 +0000 (02:17 +0200)
Adding enable/disable dithering core option with support for Neon GPU

1  2 
frontend/libretro.c

diff --combined frontend/libretro.c
  
  #define PORTS_NUMBER 8
  
 +#ifndef MIN
 +#define MIN(a, b) ((a) < (b) ? (a) : (b))
 +#endif
 +
  #define ISHEXDEC ((buf[cursor]>='0') && (buf[cursor]<='9')) || ((buf[cursor]>='a') && (buf[cursor]<='f')) || ((buf[cursor]>='A') && (buf[cursor]<='F'))
  
  //hack to prevent retroarch freezing when reseting in the menu but not while running with the hot key
@@@ -68,7 -64,6 +68,7 @@@ static int is_pal_mode
  
  /* memory card data */
  extern char Mcd1Data[MCD_SIZE];
 +extern char Mcd2Data[MCD_SIZE];
  extern char McdDisable[2];
  
  /* PCSX ReARMed core calls and stuff */
@@@ -87,15 -82,6 +87,15 @@@ int in_enable_vibration = 1
  #define VOUT_MAX_WIDTH 1024
  #define VOUT_MAX_HEIGHT 512
  
 +//Dummy functions
 +bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, size_t num_info){return false;}
 +void retro_unload_game(void){}
 +static int vout_open(void){return 0;}
 +static void vout_close(void){}
 +static int snd_init(void){return 0;}
 +static void snd_finish(void){}
 +static int snd_busy(void){return 0;}
 +
  static void init_memcard(char *mcd_data)
  {
        unsigned off = 0;
        }
  }
  
 -static int vout_open(void)
 -{
 -      return 0;
 -}
 -
  static void vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp)
  {
        vout_width = w;
@@@ -207,6 -198,10 +207,6 @@@ out
        pl_rearmed_cbs.flip_cnt++;
  }
  
 -static void vout_close(void)
 -{
 -}
 -
  #ifdef _3DS
  typedef struct
  {
@@@ -415,6 -410,20 +415,6 @@@ void pl_update_gun(int *xn, int *yn, in
  }
  
  /* sound calls */
 -static int snd_init(void)
 -{
 -      return 0;
 -}
 -
 -static void snd_finish(void)
 -{
 -}
 -
 -static int snd_busy(void)
 -{
 -      return 0;
 -}
 -
  static void snd_feed(void *buf, int bytes)
  {
        if (audio_batch_cb != NULL)
@@@ -447,6 -456,7 +447,7 @@@ void retro_set_environment(retro_enviro
        { "pcsx_rearmed_multitap1", "Multitap 1; auto|disabled|enabled" },
        { "pcsx_rearmed_multitap2", "Multitap 2; auto|disabled|enabled" },
        { "pcsx_rearmed_vibration", "Enable Vibration; enabled|disabled" },
+       { "pcsx_rearmed_dithering", "Enable Dithering; enabled|disabled" },
  #ifndef DRC_DISABLE
        { "pcsx_rearmed_drc", "Dynamic recompiler; enabled|disabled" },
  #endif
@@@ -1271,6 -1281,15 +1272,6 @@@ bool retro_load_game(const struct retro
        return true;
  }
  
 -bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, size_t num_info)
 -{
 -      return false;
 -}
 -
 -void retro_unload_game(void)
 -{
 -}
 -
  unsigned retro_get_region(void)
  {
        return is_pal_mode ? RETRO_REGION_PAL : RETRO_REGION_NTSC;
@@@ -1358,6 -1377,27 +1359,27 @@@ static void update_variables(bool in_fl
           in_enable_vibration = 1;
     }
  
+    var.value = NULL;
+    var.key = "pcsx_rearmed_dithering";
+    if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
+    {
+       if (strcmp(var.value, "disabled") == 0) {
+          pl_rearmed_cbs.gpu_peops.iUseDither = 0;
+          pl_rearmed_cbs.gpu_peopsgl.bDrawDither = 0;
+ #ifdef __ARM_NEON__
+          pl_rearmed_cbs.gpu_neon.allow_dithering = 0;
+ #endif
+       }
+       else if (strcmp(var.value, "enabled") == 0) {
+          pl_rearmed_cbs.gpu_peops.iUseDither = 1;
+          pl_rearmed_cbs.gpu_peopsgl.bDrawDither = 1;
+ #ifdef __ARM_NEON__
+          pl_rearmed_cbs.gpu_neon.allow_dithering = 1;
+ #endif
+       }
+    }
  #ifdef __ARM_NEON__
     var.value = "NULL";
     var.key = "pcsx_rearmed_neon_interlace_enable";
     }
  }
  
 -static int min(int a, int b)
 -{
 -    return a < b ? a : b;
 -}
 -
  void retro_run(void)
  {
      int i;
  
                if (in_type[i] == PSE_PAD_TYPE_ANALOGPAD)
                {
 -                      in_analog_left[i][0] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255);
 -                      in_analog_left[i][1] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255);
 -                      in_analog_right[i][0] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255);
 -                      in_analog_right[i][1] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255);
 +                      in_analog_left[i][0] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255);
 +                      in_analog_left[i][1] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255);
 +                      in_analog_right[i][0] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255);
 +                      in_analog_right[i][1] = MIN((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255);
                }
        }
  
@@@ -1613,7 -1658,7 +1635,7 @@@ static void check_system_specs(void
  
  void retro_init(void)
  {
 -      const char *bios[] = { "scph1001", "scph5501", "scph7001" };
 +      const char *bios[] = { "SCPH101", "SCPH7001", "SCPH5501", "SCPH1001" };
        const char *dir;
        char path[256];
        int i, ret;
                SysPrintf("no BIOS files found.\n");
                struct retro_message msg =
                {
 -                      "no BIOS found, expect bugs!",
 +                      "No BIOS file found - add for better compatibility",
                        180
                };
                environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, (void*)&msg);
        McdDisable[0] = 0;
        McdDisable[1] = 1;
        init_memcard(Mcd1Data);
 +   init_memcard(Mcd2Data);
  
        SaveFuncs.open = save_open;
        SaveFuncs.read = save_read;