From: gameblabla Date: Sat, 21 Aug 2021 15:23:33 +0000 (+0200) Subject: Fixes Diablo 1 SPU bug properly and remove Diablo hack. X-Git-Tag: r24l~569^2 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9601ca6d16dcef59d123539f5e2af07e504ac329;hp=9e0fad6aaa0ca02dff050abb730688e0bba41ed3;p=pcsx_rearmed.git Fixes Diablo 1 SPU bug properly and remove Diablo hack. (Mostly) inspired by the fixes done in PCSX Redux : https://github.com/grumpycoders/pcsx-redux/blob/93653ba5281487d3bed57371d7b64c32dfc669f0/src/spu/registers.cc#L504 It seems that there was an attempt to initially implement it in PCSX Reloaded (hence the bIgnoreLoop in freeze.c) but it was never implemented properly. Co-authored-by: Nicolas Noble --- diff --git a/frontend/libretro.c b/frontend/libretro.c index e071daa5..33f2a42d 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1700,17 +1700,6 @@ static void update_variables(bool in_flight) Config.RCntFix = 1; } - var.value = NULL; - var.key = "pcsx_rearmed_idiablofix"; - - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - if (strcmp(var.value, "disabled") == 0) - spu_config.idiablofix = 0; - else if (strcmp(var.value, "enabled") == 0) - spu_config.idiablofix = 1; - } - var.value = NULL; var.key = "pcsx_rearmed_inuyasha_fix"; diff --git a/frontend/libretro_core_options.h b/frontend/libretro_core_options.h index 813e30ab..1dbcefad 100644 --- a/frontend/libretro_core_options.h +++ b/frontend/libretro_core_options.h @@ -887,17 +887,6 @@ struct retro_core_option_definition option_defs_us[] = { }, "simple", }, - { - "pcsx_rearmed_idiablofix", - "Diablo Music Fix", - NULL, - { - { "disabled", NULL }, - { "enabled", NULL }, - { NULL, NULL }, - }, - "disabled", - }, { "pcsx_rearmed_pe2_fix", "Parasite Eve 2/Vandal Hearts 1/2 Fix", diff --git a/frontend/libretro_core_options_intl.h b/frontend/libretro_core_options_intl.h index 1601ec4b..174bb93e 100644 --- a/frontend/libretro_core_options_intl.h +++ b/frontend/libretro_core_options_intl.h @@ -371,15 +371,6 @@ struct retro_core_option_definition option_defs_tr[] = { }, NULL }, - { - "pcsx_rearmed_idiablofix", - "Diablo Müzik Düzeltmesi", - NULL, - { - { NULL, NULL }, - }, - NULL - }, { "pcsx_rearmed_pe2_fix", "Parasite Eve 2/Vandal Hearts 1/2 Düzeltmleri", diff --git a/frontend/main.c b/frontend/main.c index d3c7d403..a64e9bb8 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -148,7 +148,6 @@ 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; diff --git a/frontend/menu.c b/frontend/menu.c index bd56cf43..0f7933df 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -448,7 +448,6 @@ 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), @@ -1466,7 +1465,6 @@ 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 --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index 4fb3b931..c038ea31 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -113,7 +113,7 @@ typedef struct unsigned int bNoise:1; // noise active flag unsigned int bFMod:2; // freq mod (0=off, 1=sound channel, 2=freq channel) unsigned int prevflags:3; // flags from previous block - + unsigned int bIgnoreLoop:1; // Ignore loop int iLeftVolume; // left volume int iRightVolume; // right volume ADSRInfoEx ADSRX; @@ -235,6 +235,9 @@ typedef struct unsigned short regArea[0x400]; } SPUInfo; +#define regAreaGet(ch,offset) \ + spu.regArea[((ch<<4)|(offset))>>1] + /////////////////////////////////////////////////////////// // SPU.C globals /////////////////////////////////////////////////////////// @@ -246,9 +249,6 @@ extern SPUInfo spu; void do_samples(unsigned int cycles_to, int do_sync); void schedule_next_irq(void); -#define regAreaGet(ch,offset) \ - spu.regArea[((ch<<4)|(offset))>>1] - #define do_samples_if_needed(c, sync) \ do { \ if (sync || (int)((c) - spu.cycles_played) >= 16 * 768) \ diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index d508c068..cc720207 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -112,6 +112,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, //------------------------------------------------// case 14: // loop? spu.s_chan[ch].pLoop=spu.spuMemC+((val&~1)<<3); + spu.s_chan[ch].bIgnoreLoop = 1; goto upd_irq; //------------------------------------------------// } @@ -351,8 +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 !?! { - spu.s_chan[ch].pCurr=spu.spuMemC+((regAreaGet(ch,6)&~1)<<3); // must be block aligned - if (spu_config.idiablofix == 0) spu.s_chan[ch].pLoop=spu.spuMemC+((regAreaGet(ch,14)&~1)<<3); + spu.s_chan[ch].bIgnoreLoop = 0; spu.dwNewChannel|=(1<iSBPos=27; s_chan->spos=0; + s_chan->pCurr = spu.spuMemC+((regAreaGet(ch,6)&~1)<<3); + spu.dwNewChannel&=~(1<bIgnoreLoop)) s_chan->pLoop = start; // loop adress start += 16; @@ -1489,6 +1491,7 @@ long CALLBACK SPUinit(void) spu.s_chan[i].ADSRX.SustainIncrease = 1; spu.s_chan[i].pLoop = spu.spuMemC; spu.s_chan[i].pCurr = spu.spuMemC; + spu.s_chan[i].bIgnoreLoop = 0; } spu.bSpuInit=1; // flag: we are inited diff --git a/plugins/dfsound/spu_config.h b/plugins/dfsound/spu_config.h index 28965abb..95c89486 100644 --- a/plugins/dfsound/spu_config.h +++ b/plugins/dfsound/spu_config.h @@ -10,7 +10,6 @@ typedef struct int iUseReverb; int iUseInterpolation; int iTempo; - int idiablofix; int iUseThread; int iUseFixedUpdates; // output fixed number of samples/frame