Fix eventcycles, add SPU Samples, allows much better performance

EventCycles should work up to 2048 now, now that it is used by MDEC and Timer

SPU samples option was added, audio glitches will occur in some games unless samples is 1
This commit is contained in:
Zachary Cook 2022-08-31 23:37:29 -04:00 committed by libretroadmin
parent ec4d708a31
commit 798fab9d5b
5 changed files with 42 additions and 15 deletions

View File

@ -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);

View File

@ -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),

View File

@ -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)

View File

@ -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;

View File

@ -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++)