From e2373bc5ffbb3ae6680e23513a4f94157afda499 Mon Sep 17 00:00:00 2001 From: rogerman Date: Tue, 3 May 2022 04:16:06 -0700 Subject: [PATCH] Cocoa Port: Calculate the execution speed less often, but more accurately. - Also fix a theoretical memory leak with the Video FPS timer. --- desmume/src/frontend/cocoa/cocoa_core.mm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/desmume/src/frontend/cocoa/cocoa_core.mm b/desmume/src/frontend/cocoa/cocoa_core.mm index 380265431..6c5ecc6a7 100644 --- a/desmume/src/frontend/cocoa/cocoa_core.mm +++ b/desmume/src/frontend/cocoa/cocoa_core.mm @@ -647,12 +647,11 @@ volatile bool execute = true; if (_fpsTimer == nil) { _isTimerAtSecond = NO; - _fpsTimer = [[NSTimer alloc] initWithFireDate:[NSDate date] - interval:0.5 - target:self - selector:@selector(getTimedEmulatorStatistics:) - userInfo:nil - repeats:YES]; + _fpsTimer = [NSTimer timerWithTimeInterval:0.5 + target:self + selector:@selector(getTimedEmulatorStatistics:) + userInfo:nil + repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:_fpsTimer forMode:NSRunLoopCommonModes]; } @@ -1278,7 +1277,7 @@ static void* RunCoreThread(void *arg) if ( (behavior == ExecutionBehavior_Run) || (behavior == ExecutionBehavior_FrameJump) ) { - if ((ndsFrameInfo.frameIndex & 0x1F) == 0x1F) + if ((ndsFrameInfo.frameIndex & 0x3F) == 0x3F) { if (executionSpeedAverageFramesCollected > 0.0001) {