From 16f3ca666fb090dcb9ac0b399b767e4ed0aabece Mon Sep 17 00:00:00 2001 From: gameblabla Date: Sun, 22 Aug 2021 21:50:09 +0000 Subject: [PATCH] Fixes Diablo 1 SPU bug properly and remove Diablo hack. (#191) (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 --- frontend/main.c | 1 - frontend/menu.c | 2 -- maemo/main.c | 1 - plugins/dfsound/externals.h | 8 ++++---- plugins/dfsound/registers.c | 4 ++-- plugins/dfsound/spu.c | 5 ++++- plugins/dfsound/spu_config.h | 1 - 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/frontend/main.c b/frontend/main.c index 43a55481..a824fdcc 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -138,7 +138,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 c806aa9e..d9fee04c 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -443,7 +443,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), @@ -1458,7 +1457,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/maemo/main.c b/maemo/main.c index c382c511..564e8ed5 100644 --- a/maemo/main.c +++ b/maemo/main.c @@ -197,7 +197,6 @@ 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; diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index 2db75ac2..de4b5dbe 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -110,7 +110,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; @@ -232,6 +232,9 @@ typedef struct unsigned short regArea[0x400]; } SPUInfo; +#define regAreaGet(ch,offset) \ + spu.regArea[((ch<<4)|(offset))>>1] + /////////////////////////////////////////////////////////// // SPU.C globals /////////////////////////////////////////////////////////// @@ -243,9 +246,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 6b46bf38..3e88a2c2 100644 --- a/plugins/dfsound/spu_config.h +++ b/plugins/dfsound/spu_config.h @@ -7,7 +7,6 @@ typedef struct int iUseReverb; int iUseInterpolation; int iTempo; - int idiablofix; int iUseThread; int iUseFixedUpdates; // output fixed number of samples/frame -- 2.39.5