Cocoa Port: Begin refactoring some of the emulation execution loop code to be less port-dependent.

- Also clean up some UI code with switching app preferences views when
running OS X Leopard.
This commit is contained in:
rogerman 2017-08-28 17:30:19 -07:00
parent a05e03e2cc
commit 1e9b179bf4
16 changed files with 1409 additions and 568 deletions

View File

@ -0,0 +1,432 @@
/*
Copyright (C) 2017 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#include "NDSSystem.h"
#include "ClientExecutionControl.h"
ClientExecutionControl::ClientExecutionControl()
{
_settingsPending.cpuEngineID = CPUEmulationEngineID_Interpreter;
_settingsPending.JITMaxBlockSize = 12;
_settingsPending.enableAdvancedBusLevelTiming = true;
_settingsPending.enableRigorous3DRenderingTiming = false;
_settingsPending.enableExternalBIOS = false;
_settingsPending.enableBIOSInterrupts = false;
_settingsPending.enableBIOSPatchDelayLoop = false;
_settingsPending.enableExternalFirmware = false;
_settingsPending.enableFirmwareBoot = false;
_settingsPending.enableDebugConsole = false;
_settingsPending.enableEnsataEmulation = false;
_settingsPending.executionSpeed = 1.0f;
_settingsPending.enableFrameSkip = true;
_settingsPending.framesToSkip = 0;
_settingsPending.frameJumpTarget = 0;
_settingsPending.execBehavior = ExecutionBehavior_Pause;
_settingsPending.jumpBehavior = FrameJumpBehavior_Forward;
pthread_mutex_init(&_mutexSettingsPendingOnReset, NULL);
pthread_mutex_init(&_mutexSettingsApplyOnReset, NULL);
pthread_mutex_init(&_mutexSettingsPendingOnExecutionLoopStart, NULL);
pthread_mutex_init(&_mutexSettingsApplyOnExecutionLoopStart, NULL);
pthread_mutex_init(&_mutexSettingsPendingOnNDSExec, NULL);
pthread_mutex_init(&_mutexSettingsApplyOnNDSExec, NULL);
}
ClientExecutionControl::~ClientExecutionControl()
{
pthread_mutex_destroy(&this->_mutexSettingsPendingOnReset);
pthread_mutex_destroy(&this->_mutexSettingsApplyOnReset);
pthread_mutex_destroy(&this->_mutexSettingsPendingOnExecutionLoopStart);
pthread_mutex_destroy(&this->_mutexSettingsApplyOnExecutionLoopStart);
pthread_mutex_destroy(&this->_mutexSettingsPendingOnNDSExec);
pthread_mutex_destroy(&this->_mutexSettingsApplyOnNDSExec);
}
CPUEmulationEngineID ClientExecutionControl::GetCPUEmulationEngineID()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnReset);
const CPUEmulationEngineID engineID = this->_settingsPending.cpuEngineID;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnReset);
return engineID;
}
void ClientExecutionControl::SetCPUEmulationEngineID(CPUEmulationEngineID engineID)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnReset);
this->_settingsPending.cpuEngineID = engineID;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnReset);
}
uint8_t ClientExecutionControl::GetJITMaxBlockSize()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnReset);
const uint8_t blockSize = this->_settingsPending.JITMaxBlockSize;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnReset);
return blockSize;
}
void ClientExecutionControl::SetJITMaxBlockSize(uint8_t blockSize)
{
if (blockSize == 0)
{
blockSize = 1;
}
else if (blockSize > 100)
{
blockSize = 100;
}
pthread_mutex_lock(&this->_mutexSettingsPendingOnReset);
this->_settingsPending.JITMaxBlockSize = blockSize;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnReset);
}
bool ClientExecutionControl::GetEnableAdvancedBusLevelTiming()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
const bool enable = this->_settingsPending.enableAdvancedBusLevelTiming;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
return enable;
}
void ClientExecutionControl::SetEnableAdvancedBusLevelTiming(bool enable)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
this->_settingsPending.enableAdvancedBusLevelTiming = enable;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
}
bool ClientExecutionControl::GetEnableRigorous3DRenderingTiming()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
const bool enable = this->_settingsPending.enableRigorous3DRenderingTiming;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
return enable;
}
void ClientExecutionControl::SetEnableRigorous3DRenderingTiming(bool enable)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
this->_settingsPending.enableRigorous3DRenderingTiming = enable;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
}
bool ClientExecutionControl::GetEnableExternalBIOS()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
const bool enable = this->_settingsPending.enableExternalBIOS;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
return enable;
}
void ClientExecutionControl::SetEnableExternalBIOS(bool enable)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
this->_settingsPending.enableExternalBIOS = enable;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
}
bool ClientExecutionControl::GetEnableBIOSInterrupts()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
const bool enable = this->_settingsPending.enableBIOSInterrupts;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
return enable;
}
void ClientExecutionControl::SetEnableBIOSInterrupts(bool enable)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
this->_settingsPending.enableBIOSInterrupts = enable;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
}
bool ClientExecutionControl::GetEnableBIOSPatchDelayLoop()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
const bool enable = this->_settingsPending.enableBIOSPatchDelayLoop;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
return enable;
}
void ClientExecutionControl::SetEnableBIOSPatchDelayLoop(bool enable)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
this->_settingsPending.enableBIOSPatchDelayLoop = enable;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
}
bool ClientExecutionControl::GetEnableExternalFirmware()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
const bool enable = this->_settingsPending.enableExternalFirmware;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
return enable;
}
void ClientExecutionControl::SetEnableExternalFirmware(bool enable)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
this->_settingsPending.enableExternalFirmware = enable;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
}
bool ClientExecutionControl::GetEnableFirmwareBoot()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
const bool enable = this->_settingsPending.enableFirmwareBoot;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
return enable;
}
void ClientExecutionControl::SetEnableFirmwareBoot(bool enable)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
this->_settingsPending.enableFirmwareBoot = enable;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
}
bool ClientExecutionControl::GetEnableDebugConsole()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
const bool enable = this->_settingsPending.enableDebugConsole;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
return enable;
}
void ClientExecutionControl::SetEnableDebugConsole(bool enable)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
this->_settingsPending.enableDebugConsole = enable;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
}
bool ClientExecutionControl::GetEnableEnsataEmulation()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
const bool enable = this->_settingsPending.enableEnsataEmulation;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
return enable;
}
void ClientExecutionControl::SetEnableEnsataEmulation(bool enable)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
this->_settingsPending.enableEnsataEmulation = enable;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
}
bool ClientExecutionControl::GetEnableSpeedLimiter()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnExecutionLoopStart);
const bool enable = this->_settingsPending.enableSpeedLimiter;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnExecutionLoopStart);
return enable;
}
void ClientExecutionControl::SetEnableSpeedLimiter(bool enable)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnExecutionLoopStart);
this->_settingsPending.enableSpeedLimiter = enable;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnExecutionLoopStart);
}
float ClientExecutionControl::GetExecutionSpeed()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnExecutionLoopStart);
const float speedScalar = this->_settingsPending.executionSpeed;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnExecutionLoopStart);
return speedScalar;
}
void ClientExecutionControl::SetExecutionSpeed(float speedScalar)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnExecutionLoopStart);
this->_settingsPending.executionSpeed = speedScalar;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnExecutionLoopStart);
}
bool ClientExecutionControl::GetEnableFrameSkip()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnExecutionLoopStart);
const bool enable = this->_settingsPending.enableFrameSkip;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnExecutionLoopStart);
return enable;
}
void ClientExecutionControl::SetEnableFrameSkip(bool enable)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnExecutionLoopStart);
if (this->_settingsPending.enableFrameSkip != enable)
{
this->_settingsPending.enableFrameSkip = enable;
this->_settingsPending.framesToSkip = 0;
}
pthread_mutex_unlock(&this->_mutexSettingsPendingOnExecutionLoopStart);
}
uint8_t ClientExecutionControl::GetFramesToSkip()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnExecutionLoopStart);
const uint8_t numFramesToSkip = this->_settingsPending.framesToSkip;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnExecutionLoopStart);
return numFramesToSkip;
}
uint64_t ClientExecutionControl::GetFrameJumpTarget()
{
return this->_settingsPending.frameJumpTarget;
}
void ClientExecutionControl::SetFrameJumpTarget(uint64_t newJumpTarget)
{
this->_settingsPending.frameJumpTarget = newJumpTarget;
}
ExecutionBehavior ClientExecutionControl::GetExecutionBehavior()
{
return this->_settingsPending.execBehavior;
}
void ClientExecutionControl::SetExecutionBehavior(ExecutionBehavior newBehavior)
{
this->_settingsPending.execBehavior = newBehavior;
}
FrameJumpBehavior ClientExecutionControl::GetFrameJumpBehavior()
{
return this->_settingsPending.jumpBehavior;
}
void ClientExecutionControl::SetFrameJumpBehavior(FrameJumpBehavior newBehavior)
{
this->_settingsPending.jumpBehavior = newBehavior;
}
void ClientExecutionControl::FlushSettingsOnReset()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnReset);
CommonSettings.use_jit = (this->_settingsPending.cpuEngineID == CPUEmulationEngineID_DynamicRecompiler);
CommonSettings.jit_max_block_size = this->_settingsPending.JITMaxBlockSize;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnReset);
}
void ClientExecutionControl::FlushSettingsOnExecutionLoopStart()
{
pthread_mutex_lock(&this->_mutexSettingsApplyOnExecutionLoopStart);
pthread_mutex_lock(&this->_mutexSettingsPendingOnExecutionLoopStart);
const bool didFrameSkipSettingChange = (this->_settingsPending.enableFrameSkip != this->_settingsApplied.enableFrameSkip);
if (didFrameSkipSettingChange)
{
this->_settingsApplied.enableFrameSkip = this->_settingsPending.enableFrameSkip;
this->_settingsApplied.framesToSkip = this->_settingsPending.framesToSkip;
}
const float speedScalar = (this->_settingsPending.executionSpeed > SPEED_SCALAR_MIN) ? this->_settingsPending.executionSpeed : SPEED_SCALAR_MIN;
const bool didExecutionSpeedChange = (speedScalar != this->_settingsApplied.executionSpeed) || (this->_settingsPending.enableSpeedLimiter != this->_settingsApplied.enableSpeedLimiter);
if (didExecutionSpeedChange)
{
this->_settingsApplied.enableSpeedLimiter = this->_settingsPending.enableSpeedLimiter;
this->_settingsApplied.executionSpeed = speedScalar;
}
pthread_mutex_unlock(&this->_mutexSettingsPendingOnExecutionLoopStart);
if (didFrameSkipSettingChange)
{
NDS_OmitFrameSkip(2);
}
if (didExecutionSpeedChange)
{
if (this->_settingsApplied.enableSpeedLimiter)
{
this->_settingsApplied.timeBudget = this->GetFrameAbsoluteTime(1.0f/speedScalar);
}
else
{
this->_settingsApplied.timeBudget = 0;
}
}
pthread_mutex_unlock(&this->_mutexSettingsApplyOnExecutionLoopStart);
}
void ClientExecutionControl::FlushSettingsOnNDSExec()
{
pthread_mutex_lock(&this->_mutexSettingsApplyOnNDSExec);
pthread_mutex_lock(&this->_mutexSettingsPendingOnNDSExec);
this->_settingsApplied.enableAdvancedBusLevelTiming = this->_settingsPending.enableAdvancedBusLevelTiming;
this->_settingsApplied.enableRigorous3DRenderingTiming = this->_settingsPending.enableRigorous3DRenderingTiming;
this->_settingsApplied.enableExternalBIOS = this->_settingsPending.enableExternalBIOS;
this->_settingsApplied.enableBIOSInterrupts = this->_settingsPending.enableBIOSInterrupts;
this->_settingsApplied.enableBIOSPatchDelayLoop = this->_settingsPending.enableBIOSPatchDelayLoop;
this->_settingsApplied.enableExternalFirmware = this->_settingsPending.enableExternalFirmware;
this->_settingsApplied.enableFirmwareBoot = this->_settingsPending.enableFirmwareBoot;
this->_settingsApplied.enableDebugConsole = this->_settingsPending.enableDebugConsole;
this->_settingsApplied.enableEnsataEmulation = this->_settingsPending.enableEnsataEmulation;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnNDSExec);
CommonSettings.advanced_timing = this->_settingsApplied.enableAdvancedBusLevelTiming;
CommonSettings.rigorous_timing = this->_settingsApplied.enableRigorous3DRenderingTiming;
CommonSettings.UseExtBIOS = this->_settingsApplied.enableExternalBIOS;
CommonSettings.SWIFromBIOS = this->_settingsApplied.enableBIOSInterrupts;
CommonSettings.PatchSWI3 = this->_settingsApplied.enableBIOSPatchDelayLoop;
CommonSettings.UseExtFirmware = this->_settingsApplied.enableExternalFirmware;
CommonSettings.UseExtFirmwareSettings = this->_settingsApplied.enableExternalFirmware;
CommonSettings.BootFromFirmware = this->_settingsApplied.enableFirmwareBoot;
CommonSettings.DebugConsole = this->_settingsApplied.enableDebugConsole;
CommonSettings.EnsataEmulation = this->_settingsApplied.enableEnsataEmulation;
pthread_mutex_unlock(&this->_mutexSettingsApplyOnNDSExec);
}
uint64_t ClientExecutionControl::GetFrameAbsoluteTime(double frameTimeScalar)
{
// Do nothing. This is implementation dependent;
return 1.0;
}

View File

@ -0,0 +1,166 @@
/*
Copyright (C) 2017 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CLIENT_EXECUTION_CONTROL_H_
#define _CLIENT_EXECUTION_CONTROL_H_
#include <pthread.h>
#define SPEED_SCALAR_QUARTER 0.25 // Speed scalar for quarter execution speed.
#define SPEED_SCALAR_HALF 0.5 // Speed scalar for half execution speed.
#define SPEED_SCALAR_THREE_QUARTER 0.75 // Speed scalar for three quarters execution speed.
#define SPEED_SCALAR_NORMAL 1.0 // Speed scalar for normal execution speed.
#define SPEED_SCALAR_DOUBLE 2.0 // Speed scalar for double execution speed.
#define SPEED_SCALAR_MIN 0.005 // Lower limit for the speed multiplier.
#define DS_FRAMES_PER_SECOND 59.8261 // Number of DS frames per second.
#define DS_SECONDS_PER_FRAME (1.0 / DS_FRAMES_PER_SECOND) // The length of time in seconds that, ideally, a frame should be processed within.
#define FRAME_SKIP_AGGRESSIVENESS 9.0 // Must be a value between 0.0 (inclusive) and positive infinity.
// This value acts as a scalar multiple of the frame skip.
#define FRAME_SKIP_BIAS 0.1 // May be any real number. This value acts as a vector addition to the frame skip.
#define MAX_FRAME_SKIP (DS_FRAMES_PER_SECOND / 2.98)
enum ExecutionBehavior
{
ExecutionBehavior_Pause = 0,
ExecutionBehavior_Run,
ExecutionBehavior_FrameAdvance,
ExecutionBehavior_FrameJump
};
enum FrameJumpBehavior
{
FrameJumpBehavior_Forward = 0,
FrameJumpBehavior_ToFrame = 1,
FrameJumpBehavior_NextMarker = 2
};
enum CPUEmulationEngineID
{
CPUEmulationEngineID_Interpreter = 0,
CPUEmulationEngineID_DynamicRecompiler = 1
};
typedef struct ClientExecutionControlSettings
{
CPUEmulationEngineID cpuEngineID;
uint8_t JITMaxBlockSize;
bool enableAdvancedBusLevelTiming;
bool enableRigorous3DRenderingTiming;
bool enableExternalBIOS;
bool enableBIOSInterrupts;
bool enableBIOSPatchDelayLoop;
bool enableExternalFirmware;
bool enableFirmwareBoot;
bool enableDebugConsole;
bool enableEnsataEmulation;
bool enableSpeedLimiter;
float executionSpeed;
uint64_t timeBudget;
bool enableFrameSkip;
uint8_t framesToSkip;
uint64_t frameJumpTarget;
ExecutionBehavior execBehavior;
FrameJumpBehavior jumpBehavior;
} ClientExecutionControlSettings;
class ClientExecutionControl
{
private:
ClientExecutionControlSettings _settingsPending;
ClientExecutionControlSettings _settingsApplied;
pthread_mutex_t _mutexSettingsPendingOnReset;
pthread_mutex_t _mutexSettingsApplyOnReset;
pthread_mutex_t _mutexSettingsPendingOnExecutionLoopStart;
pthread_mutex_t _mutexSettingsApplyOnExecutionLoopStart;
pthread_mutex_t _mutexSettingsPendingOnNDSExec;
pthread_mutex_t _mutexSettingsApplyOnNDSExec;
public:
ClientExecutionControl();
~ClientExecutionControl();
CPUEmulationEngineID GetCPUEmulationEngineID();
void SetCPUEmulationEngineID(CPUEmulationEngineID engineID);
uint8_t GetJITMaxBlockSize();
void SetJITMaxBlockSize(uint8_t blockSize);
bool GetEnableAdvancedBusLevelTiming();
void SetEnableAdvancedBusLevelTiming(bool enable);
bool GetEnableRigorous3DRenderingTiming();
void SetEnableRigorous3DRenderingTiming(bool enable);
bool GetEnableExternalBIOS();
void SetEnableExternalBIOS(bool enable);
bool GetEnableBIOSInterrupts();
void SetEnableBIOSInterrupts(bool enable);
bool GetEnableBIOSPatchDelayLoop();
void SetEnableBIOSPatchDelayLoop(bool enable);
bool GetEnableExternalFirmware();
void SetEnableExternalFirmware(bool enable);
bool GetEnableFirmwareBoot();
void SetEnableFirmwareBoot(bool enable);
bool GetEnableDebugConsole();
void SetEnableDebugConsole(bool enable);
bool GetEnableEnsataEmulation();
void SetEnableEnsataEmulation(bool enable);
bool GetEnableSpeedLimiter();
void SetEnableSpeedLimiter(bool enable);
float GetExecutionSpeed();
void SetExecutionSpeed(float speedScalar);
bool GetEnableFrameSkip();
void SetEnableFrameSkip(bool enable);
uint8_t GetFramesToSkip();
uint64_t GetFrameJumpTarget();
void SetFrameJumpTarget(uint64_t newJumpTarget);
ExecutionBehavior GetExecutionBehavior();
void SetExecutionBehavior(ExecutionBehavior newBehavior);
FrameJumpBehavior GetFrameJumpBehavior();
void SetFrameJumpBehavior(FrameJumpBehavior newBehavior);
void FlushSettingsOnReset();
void FlushSettingsOnExecutionLoopStart();
void FlushSettingsOnNDSExec();
virtual uint64_t GetFrameAbsoluteTime(double frameTimeScalar);
};
#endif // _CLIENT_EXECUTION_CONTROL_H_

View File

@ -895,6 +895,10 @@
ABB0FBDA1A9FD0260060C55A /* Icon_MicrophoneGray_256x256.png in Resources */ = {isa = PBXBuildFile; fileRef = ABB0FBD81A9FD0260060C55A /* Icon_MicrophoneGray_256x256.png */; };
ABB0FBDB1A9FD0260060C55A /* Icon_MicrophoneGray_256x256.png in Resources */ = {isa = PBXBuildFile; fileRef = ABB0FBD81A9FD0260060C55A /* Icon_MicrophoneGray_256x256.png */; };
ABB1C9451F4D6B340004844F /* macosx_10_5_compat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB23567216C2F6F400DA782E /* macosx_10_5_compat.cpp */; };
ABB1C9481F5281AE0004844F /* ClientExecutionControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABB1C9461F5281AE0004844F /* ClientExecutionControl.cpp */; };
ABB1C9491F5281AE0004844F /* ClientExecutionControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABB1C9461F5281AE0004844F /* ClientExecutionControl.cpp */; };
ABB1C94A1F5281AE0004844F /* ClientExecutionControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABB1C9461F5281AE0004844F /* ClientExecutionControl.cpp */; };
ABB1C94B1F5281AE0004844F /* ClientExecutionControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABB1C9461F5281AE0004844F /* ClientExecutionControl.cpp */; };
ABB24F6D1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABB24F6B1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp */; };
ABB24F6E1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABB24F6B1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp */; };
ABB24F6F1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABB24F6B1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp */; };
@ -1564,6 +1568,8 @@
ABB0FBCA1A9EED350060C55A /* Icon_MicrophoneGreen_256x256.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_MicrophoneGreen_256x256.png; path = images/Icon_MicrophoneGreen_256x256.png; sourceTree = "<group>"; };
ABB0FBCB1A9EED350060C55A /* Icon_MicrophoneRed_256x256.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_MicrophoneRed_256x256.png; path = images/Icon_MicrophoneRed_256x256.png; sourceTree = "<group>"; };
ABB0FBD81A9FD0260060C55A /* Icon_MicrophoneGray_256x256.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_MicrophoneGray_256x256.png; path = images/Icon_MicrophoneGray_256x256.png; sourceTree = "<group>"; };
ABB1C9461F5281AE0004844F /* ClientExecutionControl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClientExecutionControl.cpp; sourceTree = "<group>"; };
ABB1C9471F5281AE0004844F /* ClientExecutionControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClientExecutionControl.h; sourceTree = "<group>"; };
ABB24F6B1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OGLDisplayOutput_3_2.cpp; sourceTree = "<group>"; };
ABB24F6C1A81EE92006C1108 /* OGLDisplayOutput_3_2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OGLDisplayOutput_3_2.h; sourceTree = "<group>"; };
ABB3C63B1501BB8300E0C22E /* DeSmuME_Prefix_OpenEmu.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeSmuME_Prefix_OpenEmu.pch; sourceTree = "<group>"; };
@ -1993,6 +1999,7 @@
AB82445A1704AE9A00B8EE20 /* utilities.c */,
ABD10AE51715FCDD00B5729D /* audiosamplegenerator.cpp */,
ABAD07DA1E19CAA6007867CA /* ClientDisplayView.cpp */,
ABB1C9461F5281AE0004844F /* ClientExecutionControl.cpp */,
AB1B9E5F1501A78000464647 /* coreaudiosound.cpp */,
AB23567216C2F6F400DA782E /* macosx_10_5_compat.cpp */,
ABD10AE61715FCDD00B5729D /* mic_ext.cpp */,
@ -2002,6 +2009,7 @@
ABD104141346652500AF11D1 /* sndOSX.cpp */,
ABD10AE31715FCDD00B5729D /* audiosamplegenerator.h */,
ABAD07DB1E19CAA6007867CA /* ClientDisplayView.h */,
ABB1C9471F5281AE0004844F /* ClientExecutionControl.h */,
ABA6574914511EC90077E5E9 /* cocoa_cheat.h */,
ABD103FE1346652500AF11D1 /* cocoa_core.h */,
AB58F32B1364F44B0074C376 /* cocoa_file.h */,
@ -3825,6 +3833,7 @@
ABD1FEF51345AC8400AF11D1 /* ROMReader.cpp in Sources */,
ABD1FEF61345AC8400AF11D1 /* rtc.cpp in Sources */,
ABD1FEF71345AC8400AF11D1 /* saves.cpp in Sources */,
ABB1C94A1F5281AE0004844F /* ClientExecutionControl.cpp in Sources */,
ABD1FEF81345AC8400AF11D1 /* slot1.cpp in Sources */,
ABD1FF0B1345AC9C00AF11D1 /* slot1_none.cpp in Sources */,
ABD1FF0C1345AC9C00AF11D1 /* slot1_r4.cpp in Sources */,
@ -4044,6 +4053,7 @@
AB796D1A15CDCBA200C59155 /* MMU.cpp in Sources */,
ABB24F6D1A81EE92006C1108 /* OGLDisplayOutput_3_2.cpp in Sources */,
AB796D1B15CDCBA200C59155 /* mmx_optimized.cpp in Sources */,
ABB1C9481F5281AE0004844F /* ClientExecutionControl.cpp in Sources */,
AB2ABA3F1C9F9CFA00173B15 /* rsemaphore.c in Sources */,
AB796D1C15CDCBA200C59155 /* movie.cpp in Sources */,
AB9038B817C5ED2200F410BD /* slot1comp_rom.cpp in Sources */,
@ -4208,6 +4218,7 @@
ABFEA8361BB4EC1100B08C25 /* ftmm.c in Sources */,
ABFEA81E1BB4EC1000B08C25 /* ftfstype.c in Sources */,
ABA731601BB51E7000B26147 /* pshinter.c in Sources */,
ABB1C9491F5281AE0004844F /* ClientExecutionControl.cpp in Sources */,
AB301BE01D9C8BCD00246A93 /* deposterize.cpp in Sources */,
ABFEA8211BB4EC1000B08C25 /* ftgasp.c in Sources */,
ABFEA83C1BB4EC1100B08C25 /* ftotval.c in Sources */,
@ -4447,6 +4458,7 @@
ABB3C6851501C04F00E0C22E /* bilinear.cpp in Sources */,
ABB3C6861501C04F00E0C22E /* epx.cpp in Sources */,
ABB3C6871501C04F00E0C22E /* hq2x.cpp in Sources */,
ABB1C94B1F5281AE0004844F /* ClientExecutionControl.cpp in Sources */,
ABB3C6881501C04F00E0C22E /* hq4x.cpp in Sources */,
ABB3C6891501C04F00E0C22E /* lq2x.cpp in Sources */,
ABB3C68A1501C04F00E0C22E /* scanline.cpp in Sources */,

View File

@ -1468,6 +1468,11 @@
ABD21B641DE9010B001D2DFA /* features_cpu.c in Sources */ = {isa = PBXBuildFile; fileRef = ABD21B611DE9010B001D2DFA /* features_cpu.c */; };
ABD21B651DE9010B001D2DFA /* features_cpu.c in Sources */ = {isa = PBXBuildFile; fileRef = ABD21B611DE9010B001D2DFA /* features_cpu.c */; };
ABD21B661DE9010B001D2DFA /* features_cpu.c in Sources */ = {isa = PBXBuildFile; fileRef = ABD21B611DE9010B001D2DFA /* features_cpu.c */; };
ABD4F2731F54A51000D75A1F /* ClientExecutionControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD4F2711F54A51000D75A1F /* ClientExecutionControl.cpp */; };
ABD4F2741F54A51000D75A1F /* ClientExecutionControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD4F2711F54A51000D75A1F /* ClientExecutionControl.cpp */; };
ABD4F2751F54A51000D75A1F /* ClientExecutionControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD4F2711F54A51000D75A1F /* ClientExecutionControl.cpp */; };
ABD4F2761F54A51000D75A1F /* ClientExecutionControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD4F2711F54A51000D75A1F /* ClientExecutionControl.cpp */; };
ABD4F2771F54A51000D75A1F /* ClientExecutionControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD4F2711F54A51000D75A1F /* ClientExecutionControl.cpp */; };
ABD597BC187CD95A00069403 /* Image_GuitarGrip.png in Resources */ = {isa = PBXBuildFile; fileRef = ABD597BB187CD95A00069403 /* Image_GuitarGrip.png */; };
ABD597BD187CD95A00069403 /* Image_GuitarGrip.png in Resources */ = {isa = PBXBuildFile; fileRef = ABD597BB187CD95A00069403 /* Image_GuitarGrip.png */; };
ABD597BE187CD95A00069403 /* Image_GuitarGrip.png in Resources */ = {isa = PBXBuildFile; fileRef = ABD597BB187CD95A00069403 /* Image_GuitarGrip.png */; };
@ -2159,6 +2164,8 @@
ABD21B591DE900D3001D2DFA /* Database.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Database.h; sourceTree = "<group>"; };
ABD21B5A1DE900D3001D2DFA /* Database.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Database.cpp; sourceTree = "<group>"; };
ABD21B611DE9010B001D2DFA /* features_cpu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = features_cpu.c; sourceTree = "<group>"; };
ABD4F2711F54A51000D75A1F /* ClientExecutionControl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClientExecutionControl.cpp; sourceTree = "<group>"; };
ABD4F2721F54A51000D75A1F /* ClientExecutionControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClientExecutionControl.h; sourceTree = "<group>"; };
ABD597BB187CD95A00069403 /* Image_GuitarGrip.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Image_GuitarGrip.png; path = images/Image_GuitarGrip.png; sourceTree = "<group>"; };
ABD59813187D417900069403 /* Icon_GuitarGrip_Button_Blue_512x512.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_GuitarGrip_Button_Blue_512x512.png; path = images/Icon_GuitarGrip_Button_Blue_512x512.png; sourceTree = "<group>"; };
ABD59814187D417900069403 /* Icon_GuitarGrip_Button_Green_512x512.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_GuitarGrip_Button_Green_512x512.png; path = images/Icon_GuitarGrip_Button_Green_512x512.png; sourceTree = "<group>"; };
@ -2378,6 +2385,7 @@
AB2F56EF1704C86900E28885 /* utilities.c */,
AB2145221714DFF4006DDB0F /* audiosamplegenerator.cpp */,
AB0F13911E1B7C320075684F /* ClientDisplayView.cpp */,
ABD4F2711F54A51000D75A1F /* ClientExecutionControl.cpp */,
ABD0A5341501AA5A0074A094 /* coreaudiosound.cpp */,
ABD9A46413DB99B300777194 /* mic_ext.cpp */,
ABECB51318A460910052D52A /* OGLDisplayOutput.cpp */,
@ -2385,6 +2393,7 @@
ABD104141346652500AF11D1 /* sndOSX.cpp */,
AB2145211714DFF4006DDB0F /* audiosamplegenerator.h */,
AB0F13901E1B7C320075684F /* ClientDisplayView.h */,
ABD4F2721F54A51000D75A1F /* ClientExecutionControl.h */,
ABA6574914511EC90077E5E9 /* cocoa_cheat.h */,
ABD103FE1346652500AF11D1 /* cocoa_core.h */,
AB58F32B1364F44B0074C376 /* cocoa_file.h */,
@ -4571,6 +4580,7 @@
AB0F13931E1B7C320075684F /* ClientDisplayView.cpp in Sources */,
AB3E69111E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */,
AB3E69841E25FBBF00D4CC75 /* DisplayViewCALayer.mm in Sources */,
ABD4F2741F54A51000D75A1F /* ClientExecutionControl.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -4755,6 +4765,7 @@
AB0F13941E1B7C320075684F /* ClientDisplayView.cpp in Sources */,
AB3E69121E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */,
AB3E69851E25FBBF00D4CC75 /* DisplayViewCALayer.mm in Sources */,
ABD4F2751F54A51000D75A1F /* ClientExecutionControl.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -4969,6 +4980,7 @@
AB0F13921E1B7C320075684F /* ClientDisplayView.cpp in Sources */,
AB3E69101E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */,
AB3E69831E25FBBF00D4CC75 /* DisplayViewCALayer.mm in Sources */,
ABD4F2731F54A51000D75A1F /* ClientExecutionControl.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -5183,6 +5195,7 @@
AB0F13961E1B7C320075684F /* ClientDisplayView.cpp in Sources */,
AB3E69141E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */,
AB3E69871E25FBBF00D4CC75 /* DisplayViewCALayer.mm in Sources */,
ABD4F2771F54A51000D75A1F /* ClientExecutionControl.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -5367,6 +5380,7 @@
AB0F13951E1B7C320075684F /* ClientDisplayView.cpp in Sources */,
AB3E69131E231E9900D4CC75 /* MacOGLDisplayView.mm in Sources */,
AB3E69861E25FBBF00D4CC75 /* DisplayViewCALayer.mm in Sources */,
ABD4F2761F54A51000D75A1F /* ClientExecutionControl.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -21,6 +21,7 @@
#include <libkern/OSAtomic.h>
#include <string>
#import "cocoa_util.h"
#include "ClientExecutionControl.h"
@class CocoaDSCore;
@ -34,10 +35,10 @@ typedef void *gdbstub_handle_t;
typedef struct
{
CocoaDSCore *cdsCore;
int state;
ExecutionBehavior behavior;
bool isFrameSkipEnabled;
NSUInteger frameJumpTarget;
int framesToSkip;
uint64_t frameJumpTarget;
uint8_t framesToSkip;
uint64_t timeBudgetMachAbsTime;
pthread_mutex_t mutexOutputList;
pthread_mutex_t mutexThreadExecute;
@ -72,7 +73,6 @@ typedef struct
volatile gdbstub_handle_t gdbStubHandleARM9;
volatile gdbstub_handle_t gdbStubHandleARM7;
NSUInteger emulationFlags;
BOOL emuFlagAdvancedBusLevelTiming;
BOOL emuFlagRigorousTiming;
BOOL emuFlagUseExternalBios;
@ -118,7 +118,6 @@ typedef struct
@property (assign) NSUInteger gdbStubPortARM9;
@property (assign) NSUInteger gdbStubPortARM7;
@property (assign) NSUInteger emulationFlags;
@property (assign) BOOL emuFlagAdvancedBusLevelTiming;
@property (assign) BOOL emuFlagRigorousTiming;
@property (assign) BOOL emuFlagUseGameSpecificHacks;
@ -144,7 +143,6 @@ typedef struct
@property (readonly) pthread_rwlock_t *rwlockCoreExecute;
- (BOOL) ejectCardFlag;
- (void) setEjectCardFlag;
- (void) slot1Eject;
- (void) changeRomSaveType:(NSInteger)saveTypeID;
@ -173,5 +171,5 @@ typedef struct
@end
static void* RunCoreThread(void *arg);
static int CalculateFrameSkip(uint64_t timeBudgetMachAbsTime, uint64_t frameStartMachAbsTime);
static uint8_t CalculateFrameSkip(uint64_t timeBudgetMachAbsTime, uint64_t frameStartMachAbsTime);
uint64_t GetFrameAbsoluteTime(const double frameTimeScalar);

View File

@ -25,6 +25,8 @@
#import "cocoa_rom.h"
#import "cocoa_util.h"
#include "ClientExecutionControl.h"
#include <mach/mach.h>
#include <mach/mach_time.h>
@ -95,17 +97,16 @@ volatile bool execute = true;
@synthesize gdbStubPortARM9;
@synthesize gdbStubPortARM7;
@dynamic emulationFlags;
@synthesize emuFlagAdvancedBusLevelTiming;
@synthesize emuFlagRigorousTiming;
@dynamic emuFlagAdvancedBusLevelTiming;
@dynamic emuFlagRigorousTiming;
@dynamic emuFlagUseGameSpecificHacks;
@synthesize emuFlagUseExternalBios;
@synthesize emuFlagEmulateBiosInterrupts;
@synthesize emuFlagPatchDelayLoop;
@synthesize emuFlagUseExternalFirmware;
@synthesize emuFlagFirmwareBoot;
@synthesize emuFlagDebugConsole;
@synthesize emuFlagEmulateEnsata;
@dynamic emuFlagUseExternalBios;
@dynamic emuFlagEmulateBiosInterrupts;
@dynamic emuFlagPatchDelayLoop;
@dynamic emuFlagUseExternalFirmware;
@dynamic emuFlagFirmwareBoot;
@dynamic emuFlagDebugConsole;
@dynamic emuFlagEmulateEnsata;
@dynamic cpuEmulationEngine;
@dynamic maxJITBlockSize;
@synthesize slot1DeviceType;
@ -153,7 +154,6 @@ volatile bool execute = true;
cdsGPU = [[[[CocoaDSGPU alloc] init] autorelease] retain];
cdsOutputList = [[[[NSMutableArray alloc] initWithCapacity:32] autorelease] retain];
emulationFlags = EMULATION_ADVANCED_BUS_LEVEL_TIMING_MASK;
emuFlagAdvancedBusLevelTiming = YES;
emuFlagRigorousTiming = NO;
emuFlagUseExternalBios = NO;
@ -176,13 +176,13 @@ volatile bool execute = true;
isSpeedLimitEnabled = YES;
speedScalar = SPEED_SCALAR_NORMAL;
prevCoreState = CORESTATE_PAUSE;
prevCoreState = ExecutionBehavior_Pause;
slot1R4URL = nil;
_slot1R4Path = "";
threadParam.cdsCore = self;
threadParam.state = CORESTATE_PAUSE;
threadParam.behavior = ExecutionBehavior_Pause;
threadParam.isFrameSkipEnabled = true;
threadParam.framesToSkip = 0;
threadParam.frameJumpTarget = 0;
@ -232,7 +232,7 @@ volatile bool execute = true;
- (void)dealloc
{
[self setCoreState:CORESTATE_PAUSE];
[self setCoreState:ExecutionBehavior_Pause];
[self removeAllOutputs];
@ -475,125 +475,36 @@ volatile bool execute = true;
return isInDebugTrap;
}
- (void) setEmulationFlags:(NSUInteger)theFlags
- (void) setEmuFlagAdvancedBusLevelTiming:(BOOL)enable
{
OSSpinLockLock(&spinlockEmulationFlags);
emulationFlags = theFlags;
OSSpinLockUnlock(&spinlockEmulationFlags);
pthread_rwlock_wrlock(&threadParam.rwlockCoreExecute);
if (theFlags & EMULATION_ADVANCED_BUS_LEVEL_TIMING_MASK)
{
self.emuFlagAdvancedBusLevelTiming = YES;
CommonSettings.advanced_timing = true;
}
else
{
self.emuFlagAdvancedBusLevelTiming = NO;
CommonSettings.advanced_timing = false;
}
if (theFlags & EMULATION_RIGOROUS_TIMING_MASK)
{
self.emuFlagRigorousTiming = YES;
CommonSettings.rigorous_timing = true;
}
else
{
self.emuFlagRigorousTiming = NO;
CommonSettings.rigorous_timing = false;
}
if (theFlags & EMULATION_ENSATA_MASK)
{
self.emuFlagEmulateEnsata = YES;
CommonSettings.EnsataEmulation = true;
}
else
{
self.emuFlagEmulateEnsata = NO;
CommonSettings.EnsataEmulation = false;
}
if (theFlags & EMULATION_USE_EXTERNAL_BIOS_MASK)
{
self.emuFlagUseExternalBios = YES;
CommonSettings.UseExtBIOS = true;
}
else
{
self.emuFlagUseExternalBios = NO;
CommonSettings.UseExtBIOS = false;
}
if (theFlags & EMULATION_BIOS_SWI_MASK)
{
self.emuFlagEmulateBiosInterrupts = YES;
CommonSettings.SWIFromBIOS = true;
}
else
{
self.emuFlagEmulateBiosInterrupts = NO;
CommonSettings.SWIFromBIOS = false;
}
if (theFlags & EMULATION_PATCH_DELAY_LOOP_MASK)
{
self.emuFlagPatchDelayLoop = YES;
CommonSettings.PatchSWI3 = true;
}
else
{
self.emuFlagPatchDelayLoop = NO;
CommonSettings.PatchSWI3 = false;
}
if (theFlags & EMULATION_USE_EXTERNAL_FIRMWARE_MASK)
{
self.emuFlagUseExternalFirmware = YES;
CommonSettings.UseExtFirmware = true;
CommonSettings.UseExtFirmwareSettings = true;
}
else
{
self.emuFlagUseExternalFirmware = NO;
CommonSettings.UseExtFirmware = false;
CommonSettings.UseExtFirmwareSettings = false;
}
if (theFlags & EMULATION_BOOT_FROM_FIRMWARE_MASK)
{
self.emuFlagFirmwareBoot = YES;
CommonSettings.BootFromFirmware = true;
}
else
{
self.emuFlagFirmwareBoot = NO;
CommonSettings.BootFromFirmware = false;
}
if (theFlags & EMULATION_DEBUG_CONSOLE_MASK)
{
self.emuFlagDebugConsole = YES;
CommonSettings.DebugConsole = true;
}
else
{
self.emuFlagDebugConsole = NO;
CommonSettings.DebugConsole = false;
}
CommonSettings.advanced_timing = (enable) ? true : false;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
}
- (NSUInteger) emulationFlags
- (BOOL) emuFlagAdvancedBusLevelTiming
{
OSSpinLockLock(&spinlockEmulationFlags);
const NSUInteger theFlags = emulationFlags;
OSSpinLockUnlock(&spinlockEmulationFlags);
pthread_rwlock_rdlock(&threadParam.rwlockCoreExecute);
const BOOL enable = (CommonSettings.advanced_timing) ? YES : NO;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
return theFlags;
return enable;
}
- (void) setEmuFlagRigorousTiming:(BOOL)enable
{
pthread_rwlock_wrlock(&threadParam.rwlockCoreExecute);
CommonSettings.rigorous_timing = (enable) ? true : false;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
}
- (BOOL) emuFlagRigorousTiming
{
pthread_rwlock_rdlock(&threadParam.rwlockCoreExecute);
const BOOL enable = (CommonSettings.rigorous_timing) ? YES : NO;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
return enable;
}
- (void) setEmuFlagUseGameSpecificHacks:(BOOL)useTiming
@ -613,13 +524,126 @@ volatile bool execute = true;
return useTiming;
}
- (void) setEmuFlagUseExternalBios:(BOOL)enable
{
pthread_rwlock_wrlock(&threadParam.rwlockCoreExecute);
CommonSettings.UseExtBIOS = (enable) ? true : false;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
}
- (BOOL) emuFlagUseExternalBios
{
pthread_rwlock_rdlock(&threadParam.rwlockCoreExecute);
const BOOL enable = (CommonSettings.UseExtBIOS) ? YES : NO;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
return enable;
}
- (void) setEmuFlagEmulateBiosInterrupts:(BOOL)enable
{
pthread_rwlock_wrlock(&threadParam.rwlockCoreExecute);
CommonSettings.SWIFromBIOS = (enable) ? true : false;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
}
- (BOOL) emuFlagEmulateBiosInterrupts
{
pthread_rwlock_rdlock(&threadParam.rwlockCoreExecute);
const BOOL enable = (CommonSettings.SWIFromBIOS) ? YES : NO;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
return enable;
}
- (void) setEmuFlagPatchDelayLoop:(BOOL)enable
{
pthread_rwlock_wrlock(&threadParam.rwlockCoreExecute);
CommonSettings.PatchSWI3 = (enable) ? true : false;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
}
- (BOOL) emuFlagPatchDelayLoop
{
pthread_rwlock_rdlock(&threadParam.rwlockCoreExecute);
const BOOL enable = (CommonSettings.PatchSWI3) ? YES : NO;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
return enable;
}
- (void) setEmuFlagUseExternalFirmware:(BOOL)enable
{
pthread_rwlock_wrlock(&threadParam.rwlockCoreExecute);
CommonSettings.UseExtFirmware = (enable) ? true : false;
CommonSettings.UseExtFirmwareSettings = CommonSettings.UseExtFirmware;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
}
- (BOOL) emuFlagUseExternalFirmware
{
pthread_rwlock_rdlock(&threadParam.rwlockCoreExecute);
const BOOL enable = (CommonSettings.UseExtFirmware) ? YES : NO;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
return enable;
}
- (void) setEmuFlagFirmwareBoot:(BOOL)enable
{
pthread_rwlock_wrlock(&threadParam.rwlockCoreExecute);
CommonSettings.BootFromFirmware = (enable) ? true : false;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
}
- (BOOL) emuFlagFirmwareBoot
{
pthread_rwlock_rdlock(&threadParam.rwlockCoreExecute);
const BOOL enable = (CommonSettings.BootFromFirmware) ? YES : NO;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
return enable;
}
- (void) setEmuFlagDebugConsole:(BOOL)enable
{
pthread_rwlock_wrlock(&threadParam.rwlockCoreExecute);
CommonSettings.DebugConsole = (enable) ? true : false;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
}
- (BOOL) emuFlagDebugConsole
{
pthread_rwlock_rdlock(&threadParam.rwlockCoreExecute);
const BOOL enable = (CommonSettings.DebugConsole) ? YES : NO;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
return enable;
}
- (void) setEmuFlagEmulateEnsata:(BOOL)enable
{
pthread_rwlock_wrlock(&threadParam.rwlockCoreExecute);
CommonSettings.EnsataEmulation = (enable) ? true : false;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
}
- (BOOL) emuFlagEmulateEnsata
{
pthread_rwlock_rdlock(&threadParam.rwlockCoreExecute);
const BOOL enable = (CommonSettings.EnsataEmulation) ? YES : NO;
pthread_rwlock_unlock(&threadParam.rwlockCoreExecute);
return enable;
}
- (void) setCpuEmulationEngine:(NSInteger)engineID
{
OSSpinLockLock(&spinlockCPUEmulationEngine);
#if defined(__i386__) || defined(__x86_64__)
cpuEmulationEngine = engineID;
#else
cpuEmulationEngine = CPU_EMULATION_ENGINE_INTERPRETER;
cpuEmulationEngine = CPUEmulationEngine_Interpreter;
#endif
OSSpinLockUnlock(&spinlockCPUEmulationEngine);
}
@ -653,18 +677,18 @@ volatile bool execute = true;
{
pthread_mutex_lock(&threadParam.mutexThreadExecute);
if (threadParam.state == CORESTATE_EXECUTE || threadParam.state == CORESTATE_PAUSE)
if (threadParam.behavior == ExecutionBehavior_Run || threadParam.behavior == ExecutionBehavior_Pause)
{
prevCoreState = threadParam.state;
prevCoreState = threadParam.behavior;
}
threadParam.state = coreState;
threadParam.behavior = (ExecutionBehavior)coreState;
threadParam.framesToSkip = 0;
NDS_OmitFrameSkip(2);
switch (coreState)
switch ((ExecutionBehavior)coreState)
{
case CORESTATE_PAUSE:
case ExecutionBehavior_Pause:
{
for (CocoaDSOutput *cdsOutput in cdsOutputList)
{
@ -677,7 +701,7 @@ volatile bool execute = true;
break;
}
case CORESTATE_FRAMEADVANCE:
case ExecutionBehavior_FrameAdvance:
{
for (CocoaDSOutput *cdsOutput in cdsOutputList)
{
@ -690,7 +714,7 @@ volatile bool execute = true;
break;
}
case CORESTATE_EXECUTE:
case ExecutionBehavior_Run:
{
for (CocoaDSOutput *cdsOutput in cdsOutputList)
{
@ -714,7 +738,7 @@ volatile bool execute = true;
break;
}
case CORESTATE_FRAMEJUMP:
case ExecutionBehavior_FrameJump:
{
for (CocoaDSOutput *cdsOutput in cdsOutputList)
{
@ -737,14 +761,14 @@ volatile bool execute = true;
pthread_cond_signal(&threadParam.condThreadExecute);
pthread_mutex_unlock(&threadParam.mutexThreadExecute);
[[self cdsGPU] respondToPauseState:(coreState == CORESTATE_PAUSE)];
[[self cdsController] setHardwareMicPause:!(coreState == CORESTATE_EXECUTE)];
[[self cdsGPU] respondToPauseState:(coreState == ExecutionBehavior_Pause)];
[[self cdsController] setHardwareMicPause:(coreState != ExecutionBehavior_Run)];
}
- (NSInteger) coreState
{
pthread_mutex_lock(&threadParam.mutexThreadExecute);
const NSInteger theState = threadParam.state;
const NSInteger theState = threadParam.behavior;
pthread_mutex_unlock(&threadParam.mutexThreadExecute);
return theState;
@ -806,26 +830,10 @@ volatile bool execute = true;
return &threadParam.rwlockCoreExecute;
}
- (void) setEjectCardFlag
{
if (nds.cardEjected)
{
self.emulationFlags = self.emulationFlags | EMULATION_CARD_EJECT_MASK;
return;
}
self.emulationFlags = self.emulationFlags & ~EMULATION_CARD_EJECT_MASK;
}
- (BOOL) ejectCardFlag
{
[self setEjectCardFlag];
if (nds.cardEjected)
{
return YES;
}
return NO;
const BOOL isEjected = (nds.cardEjected) ? YES : NO;
return isEjected;
}
- (void) slot1Eject
@ -888,7 +896,7 @@ volatile bool execute = true;
const NSInteger engineID = [self cpuEmulationEngine];
pthread_mutex_lock(&threadParam.mutexThreadExecute);
CommonSettings.use_jit = (engineID == CPU_EMULATION_ENGINE_DYNAMIC_RECOMPILER);
CommonSettings.use_jit = (engineID == CPUEmulationEngineID_DynamicRecompiler);
pthread_mutex_unlock(&threadParam.mutexThreadExecute);
}
@ -943,7 +951,7 @@ volatile bool execute = true;
- (void) reset
{
[self setCoreState:CORESTATE_PAUSE];
[self setCoreState:ExecutionBehavior_Pause];
[self applyDynaRec];
[self applySlot1Device];
@ -1006,7 +1014,7 @@ volatile bool execute = true;
pthread_mutex_unlock(&threadParam.mutexThreadExecute);
[self setCoreState:CORESTATE_FRAMEJUMP];
[self setCoreState:ExecutionBehavior_FrameJump];
}
- (void) frameJump:(NSUInteger)relativeFrameNum
@ -1051,11 +1059,11 @@ volatile bool execute = true;
switch ([self cpuEmulationEngine])
{
case CPU_EMULATION_ENGINE_INTERPRETER:
case CPUEmulationEngineID_Interpreter:
theString = @"Interpreter";
break;
case CPU_EMULATION_ENGINE_DYNAMIC_RECOMPILER:
case CPUEmulationEngineID_DynamicRecompiler:
theString = @"Dynamic Recompiler";
break;
@ -1166,7 +1174,7 @@ static void* RunCoreThread(void *arg)
pthread_mutex_lock(&param->mutexThreadExecute);
timeBudget = param->timeBudgetMachAbsTime;
while (!(param->state != CORESTATE_PAUSE && execute))
while (!(param->behavior != ExecutionBehavior_Pause && execute))
{
pthread_cond_wait(&param->condThreadExecute, &param->mutexThreadExecute);
startTime = mach_absolute_time();
@ -1174,7 +1182,7 @@ static void* RunCoreThread(void *arg)
}
CocoaDSController *cdsController = [cdsCore cdsController];
if (param->state != CORESTATE_FRAMEJUMP)
if (param->behavior != ExecutionBehavior_FrameJump)
{
[cdsController flush];
}
@ -1210,15 +1218,15 @@ static void* RunCoreThread(void *arg)
pthread_mutex_lock(&param->mutexOutputList);
switch (param->state)
switch (param->behavior)
{
case CORESTATE_EXECUTE:
case CORESTATE_FRAMEADVANCE:
case CORESTATE_FRAMEJUMP:
case ExecutionBehavior_Run:
case ExecutionBehavior_FrameAdvance:
case ExecutionBehavior_FrameJump:
{
for (CocoaDSOutput *cdsOutput in cdsOutputList)
{
if (![cdsOutput isKindOfClass:[CocoaDSDisplay class]] || param->framesToSkip <= 0)
if (![cdsOutput isKindOfClass:[CocoaDSDisplay class]] || param->framesToSkip == 0)
{
[cdsOutput doCoreEmuFrame];
}
@ -1232,9 +1240,9 @@ static void* RunCoreThread(void *arg)
pthread_mutex_unlock(&param->mutexOutputList);
switch (param->state)
switch (param->behavior)
{
case CORESTATE_EXECUTE:
case ExecutionBehavior_Run:
{
// Determine the number of frames to skip based on how much time "debt"
// we owe on timeBudget.
@ -1253,7 +1261,7 @@ static void* RunCoreThread(void *arg)
break;
}
case CORESTATE_FRAMEJUMP:
case ExecutionBehavior_FrameJump:
{
if (param->framesToSkip > 0)
{
@ -1262,7 +1270,7 @@ static void* RunCoreThread(void *arg)
}
else
{
param->framesToSkip = (int)((DS_FRAMES_PER_SECOND * 1.0) + 0.85);
param->framesToSkip = (uint8_t)((DS_FRAMES_PER_SECOND * 1.0) + 0.85);
}
break;
}
@ -1273,13 +1281,13 @@ static void* RunCoreThread(void *arg)
pthread_mutex_unlock(&param->mutexThreadExecute);
// If we doing a frame advance, switch back to pause state immediately
// If we're doing a frame advance, switch back to pause state immediately
// after we're done with the frame.
if (param->state == CORESTATE_FRAMEADVANCE)
if (param->behavior == ExecutionBehavior_FrameAdvance)
{
[cdsCore setCoreState:CORESTATE_PAUSE];
[cdsCore setCoreState:ExecutionBehavior_Pause];
}
else if (param->state == CORESTATE_FRAMEJUMP)
else if (param->behavior == ExecutionBehavior_FrameJump)
{
if (frameNum == (param->frameJumpTarget - 1))
{
@ -1302,27 +1310,27 @@ static void* RunCoreThread(void *arg)
return NULL;
}
static int CalculateFrameSkip(uint64_t timeBudgetMachAbsTime, uint64_t frameStartMachAbsTime)
static uint8_t CalculateFrameSkip(uint64_t timeBudgetMachAbsTime, uint64_t frameStartMachAbsTime)
{
static const double skipCurve[10] = {0.60, 0.58, 0.55, 0.51, 0.46, 0.40, 0.30, 0.20, 0.10, 0.00};
static const double unskipCurve[10] = {0.75, 0.70, 0.65, 0.60, 0.50, 0.40, 0.30, 0.20, 0.10, 0.00};
static size_t skipStep = 0;
static size_t unskipStep = 0;
static int lastSetFrameSkip = 0;
static uint64_t lastSetFrameSkip = 0;
// Calculate the time remaining.
const uint64_t elapsed = mach_absolute_time() - frameStartMachAbsTime;
int framesToSkip = 0;
uint64_t framesToSkip = 0;
if (elapsed > timeBudgetMachAbsTime)
{
if (timeBudgetMachAbsTime > 0)
{
framesToSkip = (int)( (((double)(elapsed - timeBudgetMachAbsTime) * FRAME_SKIP_AGGRESSIVENESS) / (double)timeBudgetMachAbsTime) + FRAME_SKIP_BIAS );
framesToSkip = (uint64_t)( (((double)(elapsed - timeBudgetMachAbsTime) * FRAME_SKIP_AGGRESSIVENESS) / (double)timeBudgetMachAbsTime) + FRAME_SKIP_BIAS );
if (framesToSkip > lastSetFrameSkip)
{
framesToSkip -= (int)((double)(framesToSkip - lastSetFrameSkip) * skipCurve[skipStep]);
framesToSkip -= (uint64_t)((double)(framesToSkip - lastSetFrameSkip) * skipCurve[skipStep]);
if (skipStep < 9)
{
skipStep++;
@ -1330,7 +1338,7 @@ static int CalculateFrameSkip(uint64_t timeBudgetMachAbsTime, uint64_t frameStar
}
else
{
framesToSkip += (int)((double)(lastSetFrameSkip - framesToSkip) * skipCurve[skipStep]);
framesToSkip += (uint64_t)((double)(lastSetFrameSkip - framesToSkip) * skipCurve[skipStep]);
if (skipStep > 0)
{
skipStep--;
@ -1340,14 +1348,14 @@ static int CalculateFrameSkip(uint64_t timeBudgetMachAbsTime, uint64_t frameStar
else
{
static const double frameRate100x = (double)FRAME_SKIP_AGGRESSIVENESS / (double)GetFrameAbsoluteTime(1.0/100.0);
framesToSkip = (int)((double)elapsed * frameRate100x);
framesToSkip = (uint64_t)((double)elapsed * frameRate100x);
}
unskipStep = 0;
}
else
{
framesToSkip = (int)((double)lastSetFrameSkip * unskipCurve[unskipStep]);
framesToSkip = (uint64_t)((double)lastSetFrameSkip * unskipCurve[unskipStep]);
if (unskipStep < 9)
{
unskipStep++;
@ -1357,7 +1365,7 @@ static int CalculateFrameSkip(uint64_t timeBudgetMachAbsTime, uint64_t frameStar
}
// Bound the frame skip.
static const int kMaxFrameSkip = (int)MAX_FRAME_SKIP;
static const uint64_t kMaxFrameSkip = (uint64_t)MAX_FRAME_SKIP;
if (framesToSkip > kMaxFrameSkip)
{
framesToSkip = kMaxFrameSkip;
@ -1365,7 +1373,7 @@ static int CalculateFrameSkip(uint64_t timeBudgetMachAbsTime, uint64_t frameStar
lastSetFrameSkip = framesToSkip;
return framesToSkip;
return (uint8_t)framesToSkip;
}
uint64_t GetFrameAbsoluteTime(const double frameTimeScalar)

View File

@ -187,21 +187,6 @@
#define WINDOW_STATUS_BAR_HEIGHT 24 // Height of an emulation window status bar in pixels.
#define SPEED_SCALAR_QUARTER 0.25 // Speed scalar for quarter execution speed.
#define SPEED_SCALAR_HALF 0.5 // Speed scalar for half execution speed.
#define SPEED_SCALAR_THREE_QUARTER 0.75 // Speed scalar for three quarters execution speed.
#define SPEED_SCALAR_NORMAL 1.0 // Speed scalar for normal execution speed.
#define SPEED_SCALAR_DOUBLE 2.0 // Speed scalar for double execution speed.
#define SPEED_SCALAR_MIN 0.005 // Lower limit for the speed multiplier.
#define DS_FRAMES_PER_SECOND 59.8261 // Number of DS frames per second.
#define DS_SECONDS_PER_FRAME (1.0 / DS_FRAMES_PER_SECOND) // The length of time in seconds that, ideally, a frame should be processed within.
#define FRAME_SKIP_AGGRESSIVENESS 9.0 // Must be a value between 0.0 (inclusive) and positive infinity.
// This value acts as a scalar multiple of the frame skip.
#define FRAME_SKIP_BIAS 0.1 // May be any real number. This value acts as a vector addition to the frame skip.
#define MAX_FRAME_SKIP (DS_FRAMES_PER_SECOND / 3.0)
//#define SPU_SAMPLE_RATE (44100.0 * DS_FRAMES_PER_SECOND / 60.0) // Samples per second
#define SPU_SAMPLE_RATE 44100.0 // Samples per second
#define SPU_SAMPLE_RESOLUTION 16 // Bits per sample; must be a multiple of 8
@ -274,42 +259,6 @@ enum
ROMSAVETYPE_AUTOMATIC = 0
};
enum
{
EMULATION_ENSATA_BIT = 0,
EMULATION_ADVANCED_BUS_LEVEL_TIMING_BIT = 1,
EMULATION_USE_EXTERNAL_BIOS_BIT = 2,
EMULATION_BIOS_SWI_BIT = 3,
EMULATION_PATCH_DELAY_LOOP_BIT = 4,
EMULATION_USE_EXTERNAL_FIRMWARE_BIT = 5,
EMULATION_BOOT_FROM_FIRMWARE_BIT = 6,
EMULATION_SLEEP_BIT = 7,
EMULATION_CARD_EJECT_BIT = 8,
EMULATION_DEBUG_CONSOLE_BIT = 9,
EMULATION_RIGOROUS_TIMING_BIT = 10
};
enum
{
EMULATION_ENSATA_MASK = 1 << EMULATION_ENSATA_BIT,
EMULATION_ADVANCED_BUS_LEVEL_TIMING_MASK = 1 << EMULATION_ADVANCED_BUS_LEVEL_TIMING_BIT,
EMULATION_USE_EXTERNAL_BIOS_MASK = 1 << EMULATION_USE_EXTERNAL_BIOS_BIT,
EMULATION_BIOS_SWI_MASK = 1 << EMULATION_BIOS_SWI_BIT,
EMULATION_PATCH_DELAY_LOOP_MASK = 1 << EMULATION_PATCH_DELAY_LOOP_BIT,
EMULATION_USE_EXTERNAL_FIRMWARE_MASK = 1 << EMULATION_USE_EXTERNAL_FIRMWARE_BIT,
EMULATION_BOOT_FROM_FIRMWARE_MASK = 1 << EMULATION_BOOT_FROM_FIRMWARE_BIT,
EMULATION_SLEEP_MASK = 1 << EMULATION_SLEEP_BIT,
EMULATION_CARD_EJECT_MASK = 1 << EMULATION_CARD_EJECT_BIT,
EMULATION_DEBUG_CONSOLE_MASK = 1 << EMULATION_DEBUG_CONSOLE_BIT,
EMULATION_RIGOROUS_TIMING_MASK = 1 << EMULATION_RIGOROUS_TIMING_BIT
};
enum
{
CPU_EMULATION_ENGINE_INTERPRETER = 0,
CPU_EMULATION_ENGINE_DYNAMIC_RECOMPILER = 1
};
enum
{
GPUSTATE_MAIN_GPU_BIT = 0,
@ -438,17 +387,6 @@ enum
VIDEO_SOURCE_EMULATOR = 1
};
/*
COCOA DS CORE STATES
*/
enum
{
CORESTATE_PAUSE = 0,
CORESTATE_EXECUTE,
CORESTATE_FRAMEADVANCE,
CORESTATE_FRAMEJUMP
};
/*
DESMUME 3D RENDERER TYPES
*/
@ -472,13 +410,6 @@ enum
MICMODE_SINE_WAVE
};
enum
{
FRAMEJUMP_TYPE_FORWARD = 0,
FRAMEJUMP_TYPE_TOFRAME = 1,
FRAMEJUMP_TYPE_NEXTMARKER = 2
};
enum
{
PADDLE_CONTROL_RELATIVE = 0,

View File

@ -1586,7 +1586,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
enable = NO;
}
if ([emuControl executionState] == CORESTATE_PAUSE)
if ([emuControl executionState] == ExecutionBehavior_Pause)
{
[theItem setLabel:NSSTRING_TITLE_EXECUTE_CONTROL];
[theItem setImage:[emuControl iconExecute]];
@ -1602,7 +1602,7 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
if (![emuControl masterExecuteFlag] ||
[emuControl currentRom] == nil ||
[emuControl isUserInterfaceBlockingExecution] ||
[emuControl executionState] != CORESTATE_PAUSE)
[emuControl executionState] != ExecutionBehavior_Pause)
{
enable = NO;
}

View File

@ -215,7 +215,6 @@ class AudioSampleBlockGenerator;
- (IBAction) setVerticalSyncForNonLayerBackedViews:(id)sender;
- (IBAction) changeCoreSpeed:(id)sender;
- (IBAction) changeCoreEmuFlags:(id)sender;
- (IBAction) changeFirmwareSettings:(id)sender;
- (IBAction) changeHardwareMicGain:(id)sender;
- (IBAction) changeHardwareMicMute:(id)sender;

View File

@ -129,7 +129,7 @@
currentSaveStateURL = nil;
selectedRomSaveTypeID = ROMSAVETYPE_AUTOMATIC;
selectedExportRomSaveID = 0;
frameJumpType = FRAMEJUMP_TYPE_FORWARD;
frameJumpType = FrameJumpBehavior_Forward;
frameJumpFramesForward = 60;
frameJumpToFrame = 0;
@ -815,30 +815,6 @@
[self setVerticalSyncForNonLayerBackedViews:sender];
}
- (IBAction) changeCoreEmuFlags:(id)sender
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
NSUInteger flags = [cdsCore emulationFlags];
NSInteger flagBit = [CocoaDSUtil getIBActionSenderTag:sender];
if (flagBit < 0)
{
return;
}
BOOL flagState = [CocoaDSUtil getIBActionSenderButtonStateBool:sender];
if (flagState)
{
flags |= (1 << flagBit);
}
else
{
flags &= ~(1 << flagBit);
}
[cdsCore setEmulationFlags:flags];
}
- (IBAction) changeFirmwareSettings:(id)sender
{
// Force end of editing of any text fields.
@ -859,7 +835,7 @@
const BOOL muteState = [CocoaDSUtil getIBActionSenderButtonStateBool:sender];
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[[cdsCore cdsController] setHardwareMicMute:muteState];
[[cdsCore cdsController] setHardwareMicPause:([cdsCore coreState] != CORESTATE_EXECUTE)];
[[cdsCore cdsController] setHardwareMicPause:([cdsCore coreState] != ExecutionBehavior_Run)];
[self updateMicStatusIcon];
}
@ -1426,7 +1402,7 @@
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
if ([cdsCore coreState] == CORESTATE_PAUSE)
if ([cdsCore coreState] == ExecutionBehavior_Pause)
{
[self executeCore];
}
@ -1469,12 +1445,12 @@
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
if (cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_OFF || [cdsCore coreState] != CORESTATE_PAUSE || [self currentRom] == nil)
if (cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_OFF || [cdsCore coreState] != ExecutionBehavior_Pause || [self currentRom] == nil)
{
return;
}
[cdsCore setCoreState:CORESTATE_FRAMEADVANCE];
[cdsCore setCoreState:ExecutionBehavior_FrameAdvance];
}
- (void) cmdFrameJump:(NSValue *)cmdAttrValue
@ -1493,17 +1469,17 @@
switch ([self frameJumpType])
{
case FRAMEJUMP_TYPE_FORWARD:
case FrameJumpBehavior_Forward:
jumpFrames = [self frameJumpFramesForward];
[cdsCore frameJump:jumpFrames];
break;
case FRAMEJUMP_TYPE_TOFRAME:
case FrameJumpBehavior_ToFrame:
jumpFrames = [self frameJumpToFrame];
[cdsCore frameJumpTo:jumpFrames];
break;
case FRAMEJUMP_TYPE_NEXTMARKER:
case FrameJumpBehavior_NextMarker:
// TODO: Support when replay markers are implemented.
break;
@ -1964,14 +1940,14 @@
- (void) executeCore
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore setCoreState:CORESTATE_EXECUTE];
[cdsCore setCoreState:ExecutionBehavior_Run];
[self updateMicStatusIcon];
}
- (void) pauseCore
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore setCoreState:CORESTATE_PAUSE];
[cdsCore setCoreState:ExecutionBehavior_Pause];
[self updateMicStatusIcon];
}
@ -2269,23 +2245,23 @@
if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{
if ([cdsCore coreState] == CORESTATE_PAUSE)
if ([cdsCore coreState] == ExecutionBehavior_Pause)
{
[(NSMenuItem*)theItem setTitle:NSSTRING_TITLE_EXECUTE_CONTROL];
}
else if ([cdsCore coreState] == CORESTATE_EXECUTE)
else if ([cdsCore coreState] == ExecutionBehavior_Run)
{
[(NSMenuItem*)theItem setTitle:NSSTRING_TITLE_PAUSE_CONTROL];
}
}
else if ([(id)theItem isMemberOfClass:[NSToolbarItem class]])
{
if ([cdsCore coreState] == CORESTATE_PAUSE)
if ([cdsCore coreState] == ExecutionBehavior_Pause)
{
[(NSToolbarItem*)theItem setLabel:NSSTRING_TITLE_EXECUTE_CONTROL];
[(NSToolbarItem*)theItem setImage:iconExecute];
}
else if ([cdsCore coreState] == CORESTATE_EXECUTE)
else if ([cdsCore coreState] == ExecutionBehavior_Run)
{
[(NSToolbarItem*)theItem setLabel:NSSTRING_TITLE_PAUSE_CONTROL];
[(NSToolbarItem*)theItem setImage:iconPause];
@ -2294,12 +2270,12 @@
}
else if (theAction == @selector(frameAdvance:))
{
if ([cdsCore coreState] != CORESTATE_PAUSE)
if ([cdsCore coreState] != ExecutionBehavior_Pause)
{
enable = NO;
}
if ([cdsCore coreState] != CORESTATE_PAUSE ||
if ([cdsCore coreState] != ExecutionBehavior_Pause ||
![cdsCore masterExecute] ||
[self currentRom] == nil ||
[self isShowingSaveStateDialog])
@ -2318,8 +2294,8 @@
}
else if (theAction == @selector(coreExecute:))
{
if ([cdsCore coreState] == CORESTATE_EXECUTE ||
[cdsCore coreState] == CORESTATE_FRAMEADVANCE ||
if ([cdsCore coreState] == ExecutionBehavior_Run ||
[cdsCore coreState] == ExecutionBehavior_FrameAdvance ||
![cdsCore masterExecute] ||
[self currentRom] == nil ||
[self isShowingSaveStateDialog])
@ -2329,7 +2305,7 @@
}
else if (theAction == @selector(corePause:))
{
if ([cdsCore coreState] == CORESTATE_PAUSE ||
if ([cdsCore coreState] == ExecutionBehavior_Pause ||
![cdsCore masterExecute] ||
[self currentRom] == nil ||
[self isShowingSaveStateDialog])

View File

@ -145,7 +145,7 @@
- (IBAction) showInputPreferences:(id)sender
{
[[prefWindowDelegate toolbar] setSelectedItemIdentifier:@"Input"];
[[prefWindowDelegate toolbar] setSelectedItemIdentifier:[[prefWindowDelegate toolbarItemInput] itemIdentifier]];
[prefWindowDelegate changePrefView:sender];
[[prefWindowDelegate window] makeKeyAndOrderFront:sender];
}

View File

@ -170,7 +170,7 @@
[aboutWindowController setContent:aboutWindowProperties];
// Set the preferences window to the general view by default.
[[prefWindowDelegate toolbar] setSelectedItemIdentifier:@"General"];
[[prefWindowDelegate toolbar] setSelectedItemIdentifier:[[prefWindowDelegate toolbarItemGeneral] itemIdentifier]];
[prefWindowDelegate changePrefView:self];
// Setup the slot menu items. We set this up manually instead of through Interface
@ -446,59 +446,20 @@
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
// Set the emulation flags.
NSUInteger emuFlags = 0;
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_AdvancedBusLevelTiming"])
{
emuFlags |= EMULATION_ADVANCED_BUS_LEVEL_TIMING_MASK;
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_RigorousTiming"])
{
emuFlags |= EMULATION_RIGOROUS_TIMING_MASK;
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_UseExternalBIOSImages"])
{
emuFlags |= EMULATION_USE_EXTERNAL_BIOS_MASK;
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_BIOSEmulateSWI"])
{
emuFlags |= EMULATION_BIOS_SWI_MASK;
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_BIOSPatchDelayLoopSWI"])
{
emuFlags |= EMULATION_PATCH_DELAY_LOOP_MASK;
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_UseExternalFirmwareImage"])
{
emuFlags |= EMULATION_USE_EXTERNAL_FIRMWARE_MASK;
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_FirmwareBoot"])
{
emuFlags |= EMULATION_BOOT_FROM_FIRMWARE_MASK;
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_EmulateEnsata"])
{
emuFlags |= EMULATION_ENSATA_MASK;
}
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_UseDebugConsole"])
{
emuFlags |= EMULATION_DEBUG_CONSOLE_MASK;
}
[cdsCore setEmulationFlags:emuFlags];
[cdsCore setEmuFlagAdvancedBusLevelTiming:[[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_AdvancedBusLevelTiming"]];
[cdsCore setEmuFlagRigorousTiming:[[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_RigorousTiming"]];
[cdsCore setEmuFlagUseExternalBios:[[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_UseExternalBIOSImages"]];
[cdsCore setEmuFlagEmulateBiosInterrupts:[[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_BIOSEmulateSWI"]];
[cdsCore setEmuFlagPatchDelayLoop:[[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_BIOSPatchDelayLoopSWI"]];
[cdsCore setEmuFlagUseExternalFirmware:[[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_UseExternalFirmwareImage"]];
[cdsCore setEmuFlagFirmwareBoot:[[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_FirmwareBoot"]];
[cdsCore setEmuFlagEmulateEnsata:[[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_EmulateEnsata"]];
[cdsCore setEmuFlagDebugConsole:[[NSUserDefaults standardUserDefaults] boolForKey:@"Emulation_UseDebugConsole"]];
// If we're not running on Intel, force the CPU emulation engine to use the interpreter engine.
if (!isAppRunningOnIntel)
{
[[NSUserDefaults standardUserDefaults] setInteger:CPU_EMULATION_ENGINE_INTERPRETER forKey:@"Emulation_CPUEmulationEngine"];
[[NSUserDefaults standardUserDefaults] setInteger:CPUEmulationEngineID_Interpreter forKey:@"Emulation_CPUEmulationEngine"];
}
// Set the CPU emulation engine per user preferences.

View File

@ -57,6 +57,12 @@ class OGLImage;
NSObjectController *cheatWindowController;
NSArrayController *cheatDatabaseController;
NSToolbarItem *toolbarItemGeneral;
NSToolbarItem *toolbarItemInput;
NSToolbarItem *toolbarItemDisplay;
NSToolbarItem *toolbarItemSound;
NSToolbarItem *toolbarItemEmulation;
NSView *viewGeneral;
InputPrefsView *viewInput;
NSView *viewDisplay;
@ -88,6 +94,11 @@ class OGLImage;
@property (readonly) IBOutlet NSObjectController *prefWindowController;
@property (readonly) IBOutlet NSObjectController *cheatWindowController;
@property (readonly) IBOutlet NSArrayController *cheatDatabaseController;
@property (readonly) IBOutlet NSToolbarItem *toolbarItemGeneral;
@property (readonly) IBOutlet NSToolbarItem *toolbarItemInput;
@property (readonly) IBOutlet NSToolbarItem *toolbarItemDisplay;
@property (readonly) IBOutlet NSToolbarItem *toolbarItemSound;
@property (readonly) IBOutlet NSToolbarItem *toolbarItemEmulation;
@property (readonly) IBOutlet NSView *viewGeneral;
@property (readonly) IBOutlet InputPrefsView *viewInput;
@property (readonly) IBOutlet NSView *viewDisplay;

View File

@ -286,6 +286,12 @@
@synthesize cheatWindowController;
@synthesize cheatDatabaseController;
@synthesize toolbarItemGeneral;
@synthesize toolbarItemInput;
@synthesize toolbarItemDisplay;
@synthesize toolbarItemSound;
@synthesize toolbarItemEmulation;
@synthesize viewGeneral;
@synthesize viewInput;
@synthesize viewDisplay;
@ -347,11 +353,11 @@
{
// Associates NSView objects to their respective toolbar identifiers.
prefViewDict = [[NSDictionary alloc] initWithObjectsAndKeys:
viewGeneral, @"General",
viewInput, @"Input",
viewDisplay, @"Display",
viewSound, @"Sound",
viewEmulation, @"Emulation",
viewGeneral, [toolbarItemGeneral itemIdentifier],
viewInput, [toolbarItemInput itemIdentifier],
viewDisplay, [toolbarItemDisplay itemIdentifier],
viewSound, [toolbarItemSound itemIdentifier],
viewEmulation, [toolbarItemEmulation itemIdentifier],
nil];
}
@ -361,7 +367,7 @@
{
[self switchContentView:theView];
if ([toolbarItemIdentifier isEqualToString:@"Input"])
if ([toolbarItemIdentifier isEqualToString:[toolbarItemDisplay itemIdentifier]])
{
[window makeFirstResponder:theView];
}

View File

@ -113,7 +113,7 @@
finalFormTextStr = [[finalFormTextStr stringByAppendingString:@"\nSLOT-2 Device Type: "] stringByAppendingString:[cdsCore slot2DeviceTypeString]];
finalFormTextStr = [[finalFormTextStr stringByAppendingString:@"\nAdvanced Bus-Level Timing: "] stringByAppendingString:([cdsCore emuFlagAdvancedBusLevelTiming] ? @"YES" : @"NO")];
finalFormTextStr = [[finalFormTextStr stringByAppendingString:@"\nRigorous 3D Rendering Timing: "] stringByAppendingString:([cdsCore emuFlagRigorousTiming] ? @"YES" : @"NO")];
finalFormTextStr = [[finalFormTextStr stringByAppendingString:@"\nCPU Emulation Engine: "] stringByAppendingString:([cdsCore cpuEmulationEngine] == CPU_EMULATION_ENGINE_DYNAMIC_RECOMPILER ? [NSString stringWithFormat:@"%@ (BlockSize=%li)", [cdsCore cpuEmulationEngineString], (long)[cdsCore maxJITBlockSize]] : [cdsCore cpuEmulationEngineString])];
finalFormTextStr = [[finalFormTextStr stringByAppendingString:@"\nCPU Emulation Engine: "] stringByAppendingString:([cdsCore cpuEmulationEngine] == CPUEmulationEngineID_DynamicRecompiler ? [NSString stringWithFormat:@"%@ (BlockSize=%li)", [cdsCore cpuEmulationEngineString], (long)[cdsCore maxJITBlockSize]] : [cdsCore cpuEmulationEngineString])];
finalFormTextStr = [[finalFormTextStr stringByAppendingString:@"\nExternal BIOS: "] stringByAppendingString:([cdsCore emuFlagUseExternalBios] ? @"YES" : @"NO")];
finalFormTextStr = [[finalFormTextStr stringByAppendingString:@"\nExternal Firmware: "] stringByAppendingString:([cdsCore emuFlagUseExternalFirmware] ? @"YES" : @"NO")];
finalFormTextStr = [[finalFormTextStr stringByAppendingString:@"\nGPU - Scaling Factor: "] stringByAppendingString:[NSString stringWithFormat:@"%ldx", (unsigned long)[[cdsCore cdsGPU] gpuScale]]];