merge remote-tracking branch 'notaz/master'
authorretro-wertz <retro-wertz@users.noreply.github.com>
Wed, 13 Mar 2019 01:22:23 +0000 (09:22 +0800)
committerretro-wertz <retro-wertz@users.noreply.github.com>
Wed, 13 Mar 2019 01:23:56 +0000 (09:23 +0800)
1  2 
frontend/main.c
frontend/menu.c
libpcsxcore/cdriso.c
plugins/cdrcimg/cdrcimg.c

diff --combined frontend/main.c
@@@ -11,7 -11,7 +11,7 @@@
  #include <unistd.h>
  #include <signal.h>
  #include <time.h>
 -#ifndef _WIN32
 +#if !defined(_WIN32) && !defined(NO_DYLIB)
  #include <dlfcn.h>
  #endif
  
@@@ -138,6 -138,7 +138,7 @@@ void emu_set_default_config(void
        pl_rearmed_cbs.gpu_peopsgl.iTexGarbageCollection = 1;
  
        spu_config.iUseReverb = 1;
+       spu_config.idiablofix = 0;
        spu_config.iUseInterpolation = 1;
        spu_config.iXAPitch = 0;
        spu_config.iVolume = 768;
        new_dynarec_hacks = 0;
        cycle_multiplier = 200;
  
 -      in_type1 = PSE_PAD_TYPE_STANDARD;
 -      in_type2 = PSE_PAD_TYPE_STANDARD;
 +      in_type[0] = PSE_PAD_TYPE_STANDARD;
 +      in_type[1] = PSE_PAD_TYPE_STANDARD;
  }
  
  void do_emu_action(void)
@@@ -721,10 -722,10 +722,10 @@@ void SysReset() 
        // reset can run code, timing must be set
        pl_timing_prepare(Config.PsxType);
  
 -      EmuReset();
 -
 -      // hmh core forgets this
 +   // hmh core forgets this
        CDR_stop();
 +   
 +      EmuReset();
  
        GPU_updateLace = real_lace;
        g_emu_resetting = 0;
@@@ -772,7 -773,7 +773,7 @@@ int emu_save_state(int slot
                return ret;
  
        ret = SaveState(fname);
 -#ifdef HAVE_PRE_ARMV7 /* XXX GPH hack */
 +#if defined(HAVE_PRE_ARMV7) && !defined(_3DS) /* XXX GPH hack */
        sync();
  #endif
        SysPrintf("* %s \"%s\" [%d]\n",
@@@ -986,7 -987,7 +987,7 @@@ void *SysLoadLibrary(const char *lib) 
                                return (void *)(long)(PLUGIN_DL_BASE + builtin_plugin_ids[i]);
        }
  
 -#ifndef _WIN32
 +#if !defined(_WIN32) && !defined(NO_DYLIB)
        ret = dlopen(lib, RTLD_NOW);
        if (ret == NULL)
                SysMessage("dlopen: %s", dlerror());
@@@ -1003,7 -1004,7 +1004,7 @@@ void *SysLoadSym(void *lib, const char 
        if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins))
                return plugin_link(plugid - PLUGIN_DL_BASE, sym);
  
 -#ifndef _WIN32
 +#if !defined(_WIN32) && !defined(NO_DYLIB)
        return dlsym(lib, sym);
  #else
        return NULL;
  }
  
  const char *SysLibError() {
 -#ifndef _WIN32
 +#if defined(NO_DYLIB)
 +   return NULL;
 +#elif !defined(_WIN32)
        return dlerror();
  #else
        return "not supported";
@@@ -1026,7 -1025,8 +1027,7 @@@ void SysCloseLibrary(void *lib) 
        if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins))
                return;
  
 -#ifndef _WIN32
 +#if !defined(_WIN32) && !defined(NO_DYLIB)
        dlclose(lib);
  #endif
  }
 -
diff --combined frontend/menu.c
@@@ -101,10 -101,13 +101,10 @@@ int scanlines, scanline_level = 20
  int soft_scaling, analog_deadzone; // for Caanoo
  int soft_filter;
  
 -#ifndef HAVE_PRE_ARMV7
 -#define DEFAULT_PSX_CLOCK 57
 -#define DEFAULT_PSX_CLOCK_S "57"
 -#else
 -#define DEFAULT_PSX_CLOCK 50
 -#define DEFAULT_PSX_CLOCK_S "50"
 -#endif
 +// Default to 100% CPU speed as most hardware can handle it nowadays using the dynamic recompiler.
 +// If not, the option is in the advanced speed hacks menu, so in a logical place.
 +#define DEFAULT_PSX_CLOCK 100
 +#define DEFAULT_PSX_CLOCK_S "100"
  
  static const char *bioses[24];
  static const char *gpu_plugins[16];
@@@ -306,12 -309,12 +306,12 @@@ static void menu_sync_config(void
  
        switch (in_type_sel1) {
        case 1:  in_type1 = PSE_PAD_TYPE_ANALOGPAD; break;
 -      case 2:  in_type1 = PSE_PAD_TYPE_GUNCON;    break;
 +      case 2:  in_type1 = PSE_PAD_TYPE_NEGCON;    break;
        default: in_type1 = PSE_PAD_TYPE_STANDARD;
        }
        switch (in_type_sel2) {
        case 1:  in_type2 = PSE_PAD_TYPE_ANALOGPAD; break;
 -      case 2:  in_type2 = PSE_PAD_TYPE_GUNCON;    break;
 +      case 2:  in_type2 = PSE_PAD_TYPE_NEGCON;    break;
        default: in_type2 = PSE_PAD_TYPE_STANDARD;
        }
        if (in_evdev_allow_abs_only != allow_abs_only_old) {
@@@ -440,6 -443,7 +440,7 @@@ static const struct 
        CE_INTVAL_P(gpu_peopsgl.iTexGarbageCollection),
        CE_INTVAL_P(gpu_peopsgl.dwActFixes),
        CE_INTVAL(spu_config.iUseReverb),
+       CE_INTVAL(spu_config.idiablofix),
        CE_INTVAL(spu_config.iXAPitch),
        CE_INTVAL(spu_config.iUseInterpolation),
        CE_INTVAL(spu_config.iTempo),
@@@ -1451,6 -1455,7 +1452,7 @@@ static menu_entry e_menu_plugin_spu[] 
        mee_range_h   ("Volume boost",              0, volume_boost, -5, 30, h_spu_volboost),
        mee_onoff     ("Reverb",                    0, spu_config.iUseReverb, 1),
        mee_enum      ("Interpolation",             0, spu_config.iUseInterpolation, men_spu_interp),
+       mee_onoff     ("Diablo Music fix",          0, spu_config.idiablofix, 1),
        mee_onoff     ("Adjust XA pitch",           0, spu_config.iXAPitch, 1),
        mee_onoff_h   ("Adjust tempo",              0, spu_config.iTempo, 1, h_spu_tempo),
        mee_end,
diff --combined libpcsxcore/cdriso.c
  #include "cdriso.h"
  #include "ppf.h"
  
 +#include <errno.h>
 +#include <zlib.h>
 +
  #ifdef _WIN32
  #define WIN32_LEAN_AND_MEAN
  #include <process.h>
  #include <windows.h>
  #define strcasecmp _stricmp
 -#define usleep(x) Sleep((x) / 1000)
 +#define usleep(x) (Sleep((x) / 1000))
  #else
  #include <pthread.h>
  #include <sys/time.h>
  #include <unistd.h>
  #endif
 -#include <errno.h>
 -#include <zlib.h>
  
  #define OFF_T_MSB ((off_t)1 << (sizeof(off_t) * 8 - 1))
  
@@@ -226,9 -225,7 +226,9 @@@ static void *playthread(void *param
                        do {
                                ret = SPU_playCDDAchannel((short *)sndbuffer, s);
                                if (ret == 0x7761)
 +            {
                                        usleep(6 * 1000);
 +            }
                        } while (ret == 0x7761 && playing); // rearmed_wait
                }
  
                        // HACK: stop feeding data while emu is paused
                        extern int stop;
                        while (stop && playing)
 +         {
                                usleep(10000);
 +         }
  
                        now = GetTickCount();
                        osleep = t - now;
@@@ -565,15 -560,20 +565,15 @@@ static int parsecue(const char *isofile
                        if (t != 1)
                                sscanf(linebuf, " FILE %255s", tmpb);
  
 -                      // absolute path?
 -                      ti[numtracks + 1].handle = fopen(tmpb, "rb");
 -                      if (ti[numtracks + 1].handle == NULL) {
 -                              // relative to .cue?
 -                              tmp = strrchr(tmpb, '\\');
 -                              if (tmp == NULL)
 -                                      tmp = strrchr(tmpb, '/');
 -                              if (tmp != NULL)
 -                                      tmp++;
 -                              else
 -                                      tmp = tmpb;
 -                              strncpy(incue_fname, tmp, incue_max_len);
 -                              ti[numtracks + 1].handle = fopen(filepath, "rb");
 -                      }
 +                      tmp = strrchr(tmpb, '\\');
 +                      if (tmp == NULL)
 +                              tmp = strrchr(tmpb, '/');
 +                      if (tmp != NULL)
 +                              tmp++;
 +                      else
 +                              tmp = tmpb;
 +                      strncpy(incue_fname, tmp, incue_max_len);
 +                      ti[numtracks + 1].handle = fopen(filepath, "rb");
  
                        // update global offset if this is not first file in this .cue
                        if (numtracks + 1 > 1) {
@@@ -1089,7 -1089,7 +1089,7 @@@ static int cdread_sub_mixed(FILE *f, un
        return ret;
  }
  
- static int uncomp2(void *out, unsigned long *out_size, void *in, unsigned long in_size)
+ static int uncompress2_pcsx(void *out, unsigned long *out_size, void *in, unsigned long in_size)
  {
        static z_stream z;
        int ret = 0;
@@@ -1169,7 -1169,7 +1169,7 @@@ static int cdread_compressed(FILE *f, u
        if (is_compressed) {
                cdbuffer_size_expect = sizeof(compr_img->buff_raw[0]) << compr_img->block_shift;
                cdbuffer_size = cdbuffer_size_expect;
-               ret = uncomp2(compr_img->buff_raw[0], &cdbuffer_size, compr_img->buff_compressed, size);
+               ret = uncompress2_pcsx(compr_img->buff_raw[0], &cdbuffer_size, compr_img->buff_compressed, size);
                if (ret != 0) {
                        SysPrintf("uncompress failed with %d for block %d, sector %d\n",
                                        ret, block, sector);
@@@ -14,9 -14,7 +14,9 @@@
  #include <zlib.h>
  #ifndef _WIN32
  #define CALLBACK
 +#ifndef NO_DYLIB
  #include <dlfcn.h>
 +#endif
  #else
  #define WIN32_LEAN_AND_MEAN
  #include <windows.h>
@@@ -100,7 -98,7 +100,7 @@@ static long CDRgetTD(unsigned char trac
        return 0;
  }
  
int uncomp2(void *out, unsigned long *out_size, void *in, unsigned long in_size)
static int uncompress2_pcsx(void *out, unsigned long *out_size, void *in, unsigned long in_size)
  {
        static z_stream z;
        int ret = 0;
@@@ -201,7 -199,7 +201,7 @@@ static long CDRreadTrack(unsigned char 
                ret = uncompress(cdbuffer->raw[0], &cdbuffer_size, cdbuffer->compressed, size);
                break;
        case CDRC_ZLIB2:
-               ret = uncomp2(cdbuffer->raw[0], &cdbuffer_size, cdbuffer->compressed, size);
+               ret = uncompress2_pcsx(cdbuffer->raw[0], &cdbuffer_size, cdbuffer->compressed, size);
                break;
        case CDRC_BZ:
                ret = pBZ2_bzBuffToBuffDecompress((char *)cdbuffer->raw, (unsigned int *)&cdbuffer_size,
@@@ -287,7 -285,7 +287,7 @@@ static long CDRinit(void
                        return -1;
                }
        }
 -#ifndef _WIN32
 +#if !defined(_WIN32) && !defined(NO_DYLIB)
        if (pBZ2_bzBuffToBuffDecompress == NULL) {
                void *h = dlopen("/usr/lib/libbz2.so.1", RTLD_LAZY);
                if (h == NULL)