mirror of
https://github.com/simple64/simple64.git
synced 2026-11-14 10:58:42 +01:00
update core
This commit is contained in:
1 parent
92263d300e
commit
08e0d52b6b
2 files changed
+19
-28
No files matched your search
@@ -850,7 +850,6 @@ void new_frame(void)
|
||||
}
|
||||
}
|
||||
|
||||
#define SAMPLE_COUNT 3
|
||||
static void apply_speed_limiter(void)
|
||||
{
|
||||
static unsigned long totalVIs = 0;
|
||||
@@ -859,8 +858,6 @@ static void apply_speed_limiter(void)
|
||||
static unsigned int StartFPSTime = 0;
|
||||
static const double defaultSpeedFactor = 100.0;
|
||||
unsigned int CurrentFPSTime = SDL_GetTicks();
|
||||
static double sleepTimes[SAMPLE_COUNT];
|
||||
static unsigned int sleepTimesIndex = 0;
|
||||
|
||||
// calculate frame duration based upon ROM setting (50/60hz) and mupen64plus speed adjustment
|
||||
const double VILimitMilliseconds = 1000.0 / g_dev.vi.expected_refresh_rate;
|
||||
@@ -901,28 +898,19 @@ static void apply_speed_limiter(void)
|
||||
resetOnce = 0;
|
||||
}
|
||||
|
||||
sleepTimes[sleepTimesIndex%SAMPLE_COUNT] = sleepTime;
|
||||
sleepTimesIndex++;
|
||||
|
||||
unsigned int elementsForAverage = sleepTimesIndex > SAMPLE_COUNT ? SAMPLE_COUNT : sleepTimesIndex;
|
||||
|
||||
// compute the average sleepTime
|
||||
double sum = 0;
|
||||
unsigned int index;
|
||||
for(index = 0; index < elementsForAverage; index++)
|
||||
{
|
||||
sum += sleepTimes[index];
|
||||
if (sleepTime < minSleepNeeded) {
|
||||
totalVIs += (unsigned long)(minSleepNeeded/AdjustedLimit);
|
||||
}
|
||||
|
||||
double averageSleep = sum/elementsForAverage;
|
||||
|
||||
int sleepMs = (int)averageSleep;
|
||||
|
||||
if(sleepMs > 0 && sleepMs < maxSleepNeeded*SpeedFactorMultiple && l_MainSpeedLimit)
|
||||
if(l_MainSpeedLimit && sleepTime > 0 && sleepTime < maxSleepNeeded*SpeedFactorMultiple)
|
||||
{
|
||||
DebugMessage(M64MSG_VERBOSE, " apply_speed_limiter(): Waiting %ims", sleepMs);
|
||||
while(sleepTime >= 0) {
|
||||
SDL_Delay((unsigned int) sleepTime);
|
||||
|
||||
SDL_Delay(sleepMs);
|
||||
CurrentFPSTime = SDL_GetTicks();
|
||||
elapsedRealTime = CurrentFPSTime - StartFPSTime;
|
||||
sleepTime = totalElapsedGameTime - elapsedRealTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -137,15 +137,18 @@ m64p_error netplay_stop()
|
||||
return M64ERR_INVALID_STATE;
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 4; ++i)
|
||||
if (l_cin_compats != NULL)
|
||||
{
|
||||
struct netplay_event* current = l_cin_compats[i].event_first;
|
||||
struct netplay_event* next;
|
||||
while (current != NULL)
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
next = current->next;
|
||||
free(current);
|
||||
current = next;
|
||||
struct netplay_event* current = l_cin_compats[i].event_first;
|
||||
struct netplay_event* next;
|
||||
while (current != NULL)
|
||||
{
|
||||
next = current->next;
|
||||
free(current);
|
||||
current = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user