diff --git a/libretro.cpp b/libretro.cpp index a55f9fa4..4f26fa4b 100644 --- a/libretro.cpp +++ b/libretro.cpp @@ -110,6 +110,7 @@ int memfd; #endif uint32 EventCycles = 128; +uint8_t spu_samples = 1; // CPU overclock factor (or 0 if disabled) int32_t psx_overclock_factor = 0; @@ -3200,6 +3201,15 @@ static void check_variables(bool startup) } else EventCycles = 128; + + var.key = BEETLE_OPT(dynarec_spu_samples); + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + spu_samples = atoi(var.value); + } + else + spu_samples = 1; #endif var.key = BEETLE_OPT(cpu_freq_scale); diff --git a/libretro_core_options.h b/libretro_core_options.h index 28654c32..5471b791 100644 --- a/libretro_core_options.h +++ b/libretro_core_options.h @@ -1102,24 +1102,36 @@ struct retro_core_option_v2_definition option_defs_us[] = { }, { BEETLE_OPT(dynarec_eventcycles), - "Dynarec DMA/GPU Event Cycles", - NULL, - "Max cycles run by CPU before a GPU or DMA Update is checked, higher number will be faster, has much less impact on beetle interpreter than dynarec.", + "Dynarec DMA/GPU/MDEC/Timer Event Cycles", NULL, + "Max cycles run by CPU before a GPU/DMA/MDEC/Timer Update is checked, higher number will be faster, has much less impact on beetle interpreter than dynarec.", NULL, + "hacks", { - { "128", NULL }, + { "128", "128 (Default)" }, { "256", NULL }, - { "384", NULL }, { "512", NULL }, - { "640", NULL }, - { "768", NULL }, - { "896", NULL }, { "1024", NULL }, + { "2048", NULL }, { NULL, NULL }, }, "128" }, + { + BEETLE_OPT(dynarec_spu_samples), + "Dynarec SPU Samples", + NULL, + "Max SPU samples to run before a SPU Update is checked, higher number will be faster, but will cause sound glitches in some games with anything other than 1.", + NULL, + "hacks", + { + { "1", "1 (Default)" }, + { "4", NULL }, + { "16", NULL }, + { NULL, NULL }, + }, + "1" + }, #endif { BEETLE_OPT(core_timing_fps), diff --git a/mednafen/psx/mdec.cpp b/mednafen/psx/mdec.cpp index 27264d59..829dd446 100644 --- a/mednafen/psx/mdec.cpp +++ b/mednafen/psx/mdec.cpp @@ -124,6 +124,8 @@ static const uint8 ZigZag[64] = 0x2e, 0x27, 0x2f, 0x36, 0x3d, 0x3e, 0x37, 0x3f, }; +extern int32 EventCycles; + void MDEC_Power(void) { ClockCounter = 0; @@ -527,11 +529,11 @@ void MDEC_Run(int32 clocks) ClockCounter += clocks; - if(ClockCounter > 128) + if(ClockCounter > EventCycles) { //if(MDRPhase != 0) // printf("SNORT: %d\n", ClockCounter); - ClockCounter = 128; + ClockCounter = EventCycles; } switch(MDRPhase + MDRPhaseBias) diff --git a/mednafen/psx/spu.cpp b/mednafen/psx/spu.cpp index 1f6afcc5..513628ae 100644 --- a/mednafen/psx/spu.cpp +++ b/mednafen/psx/spu.cpp @@ -76,6 +76,7 @@ uint32_t IntermediateBufferPos; int16_t IntermediateBuffer[4096][2]; +extern uint8_t spu_samples; static const int16 FIR_Table[256][4] = { @@ -746,8 +747,8 @@ int32 PS_SPU::UpdateFromCDC(int32 clocks) while(clock_divider <= 0) { - clock_divider += 768; - sample_clocks++; + clock_divider += spu_samples*768; + sample_clocks += spu_samples; } while(sample_clocks > 0) @@ -1451,8 +1452,8 @@ int PS_SPU::StateAction(StateMem *sm, int load, int data_only) Voices[i].LoopAddr &= 0x3FFFF; } - if(clock_divider <= 0 || clock_divider > 768) - clock_divider = 768; + if(clock_divider <= 0 || clock_divider > spu_samples*768) + clock_divider = spu_samples*768; RWAddr &= 0x3FFFF; CWA &= 0x1FF; diff --git a/mednafen/psx/timer.cpp b/mednafen/psx/timer.cpp index b7cac703..e0a691a6 100644 --- a/mednafen/psx/timer.cpp +++ b/mednafen/psx/timer.cpp @@ -111,9 +111,11 @@ static bool hretrace; static Timer Timers[3]; static int32_t lastts; +extern int32 EventCycles; + static uint32_t CalcNextEvent(void) { - int32_t next_event = 1024; /**/ + int32_t next_event = 8*EventCycles; /**/ unsigned i; for(i = 0; i < 3; i++)