Merge pull request #137 from gameblabla/hle
authornotaz <notasas@gmail.com>
Wed, 24 Jul 2019 20:39:11 +0000 (23:39 +0300)
committerGitHub <noreply@github.com>
Wed, 24 Jul 2019 20:39:11 +0000 (23:39 +0300)
HLE BIOS improvements (based on nocash doc, pcsx4all, upstream pcsxr etc...)

frontend/main.c
frontend/menu.c
libpcsxcore/cdriso.c
libpcsxcore/gte.c
libpcsxcore/psxmem.c
maemo/main.c
plugins/cdrcimg/cdrcimg.c
plugins/dfsound/registers.c
plugins/dfsound/spu_config.h

index a824fdc..43a5548 100644 (file)
@@ -138,6 +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;
index cf9382a..0b3f553 100644 (file)
@@ -443,6 +443,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),
@@ -1454,6 +1455,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,
index 515370f..dca64fa 100644 (file)
@@ -1089,7 +1089,7 @@ static int cdread_sub_mixed(FILE *f, unsigned int base, void *dest, int sector)
        return ret;
 }
 
-static int uncompress2(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 @@ static int cdread_compressed(FILE *f, unsigned int base, void *dest, int sector)
        if (is_compressed) {
                cdbuffer_size_expect = sizeof(compr_img->buff_raw[0]) << compr_img->block_shift;
                cdbuffer_size = cdbuffer_size_expect;
-               ret = uncompress2(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);
index 62fc7f3..77dff1b 100644 (file)
 
 #ifndef FLAGLESS
 
-static inline s32 BOUNDS_(psxCP2Regs *regs, s64 n_value, s64 n_max, int n_maxflag, s64 n_min, int n_minflag) {
+static inline s64 BOUNDS_(psxCP2Regs *regs, s64 n_value, s64 n_max, int n_maxflag, s64 n_min, int n_minflag) {
        if (n_value > n_max) {
                gteFLAG |= n_maxflag;
        } else if (n_value < n_min) {
@@ -404,6 +404,7 @@ static u32 DIVIDE_(s16 n, u16 d) {
 
 void gteRTPS(psxCP2Regs *regs) {
        int quotient;
+       s64 tmp;
 
 #ifdef GTE_LOG
        GTE_LOG("GTE RTPS\n");
@@ -426,14 +427,16 @@ void gteRTPS(psxCP2Regs *regs) {
        gteSX2 = limG1(F((s64)gteOFX + ((s64)gteIR1 * quotient)) >> 16);
        gteSY2 = limG2(F((s64)gteOFY + ((s64)gteIR2 * quotient)) >> 16);
 
-       gteMAC0 = F((s64)gteDQB + ((s64)gteDQA * quotient));
-       gteIR0 = limH(gteMAC0 >> 12);
+       tmp = (s64)gteDQB + ((s64)gteDQA * quotient);
+       gteMAC0 = F(tmp);
+       gteIR0 = limH(tmp >> 12);
 }
 
 void gteRTPT(psxCP2Regs *regs) {
        int quotient;
        int v;
        s32 vx, vy, vz;
+       s64 tmp;
 
 #ifdef GTE_LOG
        GTE_LOG("GTE RTPT\n");
@@ -456,8 +459,10 @@ void gteRTPT(psxCP2Regs *regs) {
                fSX(v) = limG1(F((s64)gteOFX + ((s64)gteIR1 * quotient)) >> 16);
                fSY(v) = limG2(F((s64)gteOFY + ((s64)gteIR2 * quotient)) >> 16);
        }
-       gteMAC0 = F((s64)gteDQB + ((s64)gteDQA * quotient));
-       gteIR0 = limH(gteMAC0 >> 12);
+
+       tmp = (s64)gteDQB + ((s64)gteDQA * quotient);
+       gteMAC0 = F(tmp);
+       gteIR0 = limH(tmp >> 12);
 }
 
 void gteMVMVA(psxCP2Regs *regs) {
index 14fd911..a1a641d 100644 (file)
@@ -187,7 +187,7 @@ void psxMemReset() {
        char bios[1024];
 
        memset(psxM, 0, 0x00200000);
-       memset(psxP, 0, 0x00010000);
+       memset(psxP, 0xff, 0x00010000);
 
        if (strcmp(Config.Bios, "HLE") != 0) {
                sprintf(bios, "%s/%s", Config.BiosDir, Config.Bios);
index 85db400..c382c51 100644 (file)
@@ -197,7 +197,7 @@ int main(int argc, char **argv)
        strcpy(Config.Bios, "HLE");
        spu_config.iUseReverb = 1;
        spu_config.iUseInterpolation = 1;
-
+       spu_config.idiablofix = 0;
        in_type1 = PSE_PAD_TYPE_STANDARD;
        in_type2 = PSE_PAD_TYPE_STANDARD;
 
index 76cdfba..91cf1ca 100644 (file)
@@ -98,7 +98,7 @@ static long CDRgetTD(unsigned char track, unsigned char *buffer)
        return 0;
 }
 
-int uncompress2(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;
@@ -199,7 +199,7 @@ static long CDRreadTrack(unsigned char *time)
                ret = uncompress(cdbuffer->raw[0], &cdbuffer_size, cdbuffer->compressed, size);
                break;
        case CDRC_ZLIB2:
-               ret = uncompress2(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,
index 91bcaf8..bb64658 100644 (file)
@@ -352,7 +352,7 @@ static void SoundOn(int start,int end,unsigned short val)
    if((val&1) && regAreaGet(ch,6))                     // mmm... start has to be set before key on !?!\r
     {\r
      spu.s_chan[ch].pCurr=spu.spuMemC+((regAreaGet(ch,6)&~1)<<3); // must be block aligned\r
-     spu.s_chan[ch].pLoop=spu.spuMemC+((regAreaGet(ch,14)&~1)<<3);\r
+     if (spu_config.idiablofix == 0) spu.s_chan[ch].pLoop=spu.spuMemC+((regAreaGet(ch,14)&~1)<<3);\r
      spu.dwNewChannel|=(1<<ch);\r
     }\r
   }\r
index 3e88a2c..6b46bf3 100644 (file)
@@ -7,6 +7,7 @@ typedef struct
  int        iUseReverb;
  int        iUseInterpolation;
  int        iTempo;
+ int        idiablofix;
  int        iUseThread;
  int        iUseFixedUpdates;  // output fixed number of samples/frame