From: gameblabla Date: Wed, 25 Aug 2021 09:39:02 +0000 (+0000) Subject: Merge pull request #543 from gameblabla/hle_fies_corruption_libretro X-Git-Tag: r24l~565 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=606e46a1ec09c89ecfb7261b5f58860dfe6973f8;hp=423b0da8be20ec189818f0014a108df31ab7bcdb;p=pcsx_rearmed.git Merge pull request #543 from gameblabla/hle_fies_corruption_libretro Properly protect the HLE instructions against corrupted memory. --- 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/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index 47d45cd0..00a10e12 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -1117,9 +1117,14 @@ void cdrReadInterrupt() { cdr.Channel = cdr.Transfer[4 + 1]; } + /* Gameblabla + * Skips playing on channel 255. + * Fixes missing audio in Blue's Clues : Blue's Big Musical. (Should also fix Taxi 2) + * TODO : Check if this is the proper behaviour. + * */ if((cdr.Transfer[4 + 2] & 0x4) && (cdr.Transfer[4 + 1] == cdr.Channel) && - (cdr.Transfer[4 + 0] == cdr.File)) { + (cdr.Transfer[4 + 0] == cdr.File) && cdr.Channel != 255) { int ret = xa_decode_sector(&cdr.Xa, cdr.Transfer+4, cdr.FirstSector); if (!ret) { cdrAttenuate(cdr.Xa.pcm, cdr.Xa.nsamples, cdr.Xa.stereo); diff --git a/libpcsxcore/mdec.c b/libpcsxcore/mdec.c index d6c7ab68..61ed5ea5 100644 --- a/libpcsxcore/mdec.c +++ b/libpcsxcore/mdec.c @@ -32,7 +32,14 @@ * 320x240x16@60Hz => 9.216 MB/s * so 2.0 to 4.0 should be fine. */ -#define MDEC_BIAS 2 + +/* Was set to 2 before but it would cause issues in R-types and Vandal Hearts videos. + * Setting it to 6 as dmitrysmagin did fix those... except for Galerians. + * Galerians needs this to be set to 10 (!!) before it looks properly. + * I've tried this with a few other games (including R-Types) and so far, this + * has not backfired. + * */ +#define MDEC_BIAS 10 #define DSIZE 8 #define DSIZE2 (DSIZE * DSIZE) diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index 6016f7e7..cd627a05 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -1408,37 +1408,37 @@ void psxBios_FlushCache() { // 44 void psxBios_GPU_dw() { // 0x46 int size; - s32 *ptr; + u32 *ptr; #ifdef PSXBIOS_LOG PSXBIOS_LOG("psxBios_%s\n", biosA0n[0x46]); #endif GPU_writeData(0xa0000000); - GPU_writeData((a1<<16)|(a0&0xffff)); - GPU_writeData((a3<<16)|(a2&0xffff)); - size = (a2*a3+1)/2; - ptr = (s32*)PSXM(Rsp[4]); //that is correct? - do { - GPU_writeData(SWAP32(*ptr)); - ptr++; - } while(--size); + GPU_writeData((a1<<0x10)|(a0&0xffff)); + GPU_writeData((a3<<0x10)|(a2&0xffff)); + size = (a2*a3)/2; + ptr = (u32*)PSXM(Rsp[4]); //that is correct? + while(size--) + { + GPU_writeData(SWAPu32(*ptr++)); + } pc0 = ra; } void psxBios_mem2vram() { // 0x47 int size; - + gpuSyncPluginSR(); GPU_writeData(0xa0000000); - GPU_writeData((a1<<16)|(a0&0xffff)); - GPU_writeData((a3<<16)|(a2&0xffff)); - size = (a2*a3+1)/2; + GPU_writeData((a1<<0x10)|(a0&0xffff)); + GPU_writeData((a3<<0x10)|(a2&0xffff)); + size = ((((a2 * a3) / 2) >> 4) << 16); GPU_writeStatus(0x04000002); psxHwWrite32(0x1f8010f4,0); psxHwWrite32(0x1f8010f0,psxHwRead32(0x1f8010f0)|0x800); psxHwWrite32(0x1f8010a0,Rsp[4]);//might have a buggy... - psxHwWrite32(0x1f8010a4,((size/16)<<16)|16); + psxHwWrite32(0x1f8010a4, size | 0x10); psxHwWrite32(0x1f8010a8,0x01000201); pc0 = ra; @@ -1451,22 +1451,26 @@ void psxBios_SendGPU() { // 0x48 } void psxBios_GPU_cw() { // 0x49 + gpuSyncPluginSR(); GPU_writeData(a0); + v0 = HW_GPU_STATUS; pc0 = ra; } void psxBios_GPU_cwb() { // 0x4a - s32 *ptr = (s32*)Ra0; + u32 *ptr = (u32*)Ra0; int size = a1; - while(size--) { - GPU_writeData(SWAP32(*ptr)); - ptr++; + gpuSyncPluginSR(); + while(size--) + { + GPU_writeData(SWAPu32(*ptr++)); } pc0 = ra; } - -void psxBios_GPU_SendPackets() { //4b: + +void psxBios_GPU_SendPackets() { //4b: + gpuSyncPluginSR(); GPU_writeStatus(0x04000002); psxHwWrite32(0x1f8010f4,0); psxHwWrite32(0x1f8010f0,psxHwRead32(0x1f8010f0)|0x800); 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