Clean up access to PowerPC::state. Some warning fixes. Restore hold-tab-to-release-throttle on Windows. Fix some project settings.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2297 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-02-17 22:48:16 +00:00
parent f33997e686
commit e010ef25da
16 changed files with 63 additions and 49 deletions

View File

@ -201,19 +201,18 @@ bool Init()
return true;
}
// Called from GUI thread or VI thread
void Stop() // - Hammertime!
void Stop() // - Hammertime!
{
Host_SetWaitCursor(true);
if (PowerPC::state == PowerPC::CPU_POWERDOWN)
if (PowerPC::GetState() == PowerPC::CPU_POWERDOWN)
return;
// stop the CPU
PowerPC::state = PowerPC::CPU_POWERDOWN;
CCPU::StepOpcode(); //kick it if it's waiting
// stop the CPU
PowerPC::Stop();
CCPU::StepOpcode(); //kick it if it's waiting
// The quit is to get it out of its message loop
// Should be moved inside the plugin.
@ -222,7 +221,7 @@ void Stop() // - Hammertime!
#else
CPluginManager::GetInstance().GetVideo()->Video_Stop();
#endif
#ifdef _WIN32
/* I have to use this to avoid the hangings, it seems harmless and it works so I'm
okay with it */
@ -256,7 +255,7 @@ THREAD_RETURN CpuThread(void *pArg)
if (_CoreParameter.bRunCompareServer)
{
CPUCompare::StartServer();
PowerPC::state = PowerPC::CPU_RUNNING;
PowerPC::Start();
}
else if (_CoreParameter.bRunCompareClient)
{
@ -265,7 +264,7 @@ THREAD_RETURN CpuThread(void *pArg)
}
if (_CoreParameter.bLockThreads)
Common::Thread::SetCurrentThreadAffinity(1); //Force to first core
Common::Thread::SetCurrentThreadAffinity(1); // Force to first core
if (_CoreParameter.bUseFastMem)
{
@ -353,7 +352,7 @@ THREAD_RETURN EmuThread(void *pArg)
dspInit.pDebuggerBreak = Callback_DebuggerBreak;
dspInit.pGenerateDSPInterrupt = Callback_DSPInterrupt;
dspInit.pGetAudioStreaming = AudioInterface::Callback_GetStreaming;
dspInit.pEmulatorState = (int *)&PowerPC::state;
dspInit.pEmulatorState = (int *)PowerPC::GetStatePtr();
dspInit.bWii = _CoreParameter.bWii;
// Needed for Stop and Start
#ifdef SETUP_FREE_PLUGIN_ON_BOOT
@ -436,9 +435,10 @@ THREAD_RETURN EmuThread(void *pArg)
//Common::SetCurrentThreadName("Idle thread");
//TODO(ector) : investigate using GetMessage instead .. although
//then we lose the powerdown check. ... unless powerdown sends a message :P
while (PowerPC::state != PowerPC::CPU_POWERDOWN)
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
{
if (Callback_PeekMessages) Callback_PeekMessages();
if (Callback_PeekMessages)
Callback_PeekMessages();
Common::SleepCurrentThread(20);
}
#else

View File

@ -26,8 +26,6 @@
#include "../Debugger/Debugger_BreakPoints.h"
using namespace PowerPC;
namespace
{
static bool g_Branch;
@ -56,19 +54,19 @@ void CCPU::Run()
while (true)
{
reswitch:
switch (PowerPC::state)
switch (PowerPC::GetState())
{
case CPU_RUNNING:
case PowerPC::CPU_RUNNING:
//1: enter a fast runloop
PowerPC::RunLoop();
break;
case CPU_STEPPING:
case PowerPC::CPU_STEPPING:
m_StepEvent.Wait();
//1: wait for step command..
if (state == CPU_POWERDOWN)
if (PowerPC::GetState() == PowerPC::CPU_POWERDOWN)
return;
if (state != CPU_STEPPING)
if (PowerPC::GetState() != PowerPC::CPU_STEPPING)
goto reswitch;
//2: check for cpu compare
@ -89,7 +87,7 @@ reswitch:
Host_UpdateDisasmDialog();
break;
case CPU_POWERDOWN:
case PowerPC::CPU_POWERDOWN:
//1: Exit loop!!
return;
}
@ -104,7 +102,7 @@ void CCPU::Stop()
bool CCPU::IsStepping()
{
return PowerPC::state == CPU_STEPPING;
return PowerPC::GetState() == PowerPC::CPU_STEPPING;
}
void CCPU::Reset()
@ -115,7 +113,7 @@ void CCPU::Reset()
void CCPU::StepOpcode(Common::Event *event)
{
m_StepEvent.Set();
if (PowerPC::state == CPU_STEPPING)
if (PowerPC::GetState() == PowerPC::CPU_STEPPING)
{
m_SyncEvent = event;
}

View File

@ -130,10 +130,10 @@ void SingleStep()
}
}
// sFastRun - inspired by GCemu
// FastRun - inspired by GCemu (to imitate the JIT so that they can be compared).
void Run()
{
while (!PowerPC::state)
while (!PowerPC::GetState())
{
//we have to check exceptions at branches apparently (or maybe just rfi?)
if (Core::GetStartupParameter().bEnableDebugging)

View File

@ -154,7 +154,7 @@ void AsmRoutineManager::Generate()
MOV(32, M(&PC), R(EAX));
SetJumpTarget(skipExceptions);
TEST(32, M((void*)&PowerPC::state), Imm32(0xFFFFFFFF));
TEST(32, M((void*)PowerPC::GetStatePtr()), Imm32(0xFFFFFFFF));
J_CC(CC_Z, outerLoop, true);
//Landing pad for drec space

View File

@ -184,7 +184,11 @@ namespace CPUCompare
jo.optimizeStack = true;
jo.enableBlocklink = true; // Speed boost, but not 100% safe
#ifdef _M_X64
#ifdef JITTEST
jo.enableFastMem = false;
#else
jo.enableFastMem = Core::GetStartupParameter().bUseFastMem;
#endif
#else
jo.enableFastMem = false;
#endif
@ -275,8 +279,8 @@ namespace CPUCompare
}
}
static const bool ImHereDebug = false;
static const bool ImHereLog = false;
static const bool ImHereDebug = true;
static const bool ImHereLog = true;
static std::map<u32, int> been_here;
void ImHere()

View File

@ -65,7 +65,6 @@ AsmRoutineManager asm_routines;
// dynarec buffer
// At this offset - 4, there is an int specifying the block number.
void AsmRoutineManager::Generate()
{
enterCode = AlignCode16();
@ -156,9 +155,8 @@ void AsmRoutineManager::Generate()
MOV(32, M(&PC), R(EAX));
SetJumpTarget(skipExceptions);
TEST(32, M((void*)&PowerPC::state), Imm32(0xFFFFFFFF));
TEST(32, M((void*)PowerPC::GetStatePtr()), Imm32(0xFFFFFFFF));
J_CC(CC_Z, outerLoop, true);
//Landing pad for drec space
ABI_PopAllCalleeSavedRegsAndAdjustStack();
RET();

View File

@ -176,23 +176,32 @@ void RunLoop()
Host_UpdateDisasmDialog();
}
CPUState GetState()
{
return state;
}
volatile CPUState *GetStatePtr()
{
return &state;
}
void Start()
{
// Select running mode for CPU.cpp
state = CPU_RUNNING;
Host_UpdateDisasmDialog();
Host_UpdateDisasmDialog();
}
void Pause()
{
state = CPU_STEPPING;
Host_UpdateDisasmDialog();
Host_UpdateDisasmDialog();
}
void Stop()
{
state = CPU_POWERDOWN;
Host_UpdateDisasmDialog();
Host_UpdateDisasmDialog();
}
void CheckExceptions()

View File

@ -72,7 +72,6 @@ enum CPUState
};
extern PowerPCState ppcState;
extern volatile CPUState state; // Execution engines should poll this to know when to exit.
void Init();
void Shutdown();
@ -86,6 +85,8 @@ void RunLoop();
void Start();
void Pause();
void Stop();
CPUState GetState();
volatile CPUState *GetStatePtr(); // this oddity is here instead of an extern declaration to easily be able to find all direct accesses throughout the code.
void CompactCR();
void ExpandCR();

View File

@ -68,7 +68,7 @@ CCodeWindow* g_pCodeWindow = NULL;
LONG WINAPI MyUnhandledExceptionFilter(LPEXCEPTION_POINTERS e) {
//EnterCriticalSection(&g_uefcs);
FILE* file=NULL;
FILE* file = NULL;
fopen_s(&file, "exceptioninfo.txt", "a");
fseek(file, 0, SEEK_END);
etfprint(file, "\n");

View File

@ -50,11 +50,11 @@ namespace InputCommon
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
float Deg2Rad(float Deg)
{
return Deg * (M_PI / 180.0);
return Deg * ((float)M_PI / 180.0f);
}
float Rad2Deg(float Rad)
{
return (Rad * 180.0) / M_PI;
return (Rad * 180.0f) / (float)M_PI;
}
/////////////////////////////////////////
@ -70,7 +70,7 @@ float CoordinatesToRadius(int x, int y)
bool IsDeadZone(float DeadZone, int x, int y)
{
// Get the distance from the center
float Distance = CoordinatesToRadius(x, y) / 32767.0;
float Distance = CoordinatesToRadius(x, y) / 32767.0f;
//Console::Print("%f\n", Distance);
@ -159,7 +159,7 @@ std::vector<int> Square2Circle(int _x, int _y, int _pad, std::string SDiagonal,
// -----------
// Get the manually configured diagonal distance
int Tmp = atoi (SDiagonal.substr(0, SDiagonal.length() - 1).c_str());
float Diagonal = Tmp / 100.0;
float Diagonal = Tmp / 100.0f;
// First make a perfect square in case we don't have one already
float OrigDist = sqrt( pow((float)_y, 2) + pow((float)_x, 2) ); // Get current distance

View File

@ -123,7 +123,7 @@ bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_
if (SDL_JoystickOpened(i)) SDL_JoystickClose(_joyinfo[i].joy);
}
_NumPads = _joyinfo.size();
_NumPads = (int)_joyinfo.size();
return true;
}

View File

@ -121,12 +121,16 @@ void Mixer_PushSamples(short *buffer, int num_stereo_samples, int sample_rate)
static int PV1l=0,PV2l=0,PV3l=0,PV4l=0;
static int PV1r=0,PV2r=0,PV3r=0,PV4r=0;
static int acc=0;
#ifdef _WIN32
if (GetAsyncKeyState(VK_TAB))
return;
#endif
// Write Other Audio
//bThrottling = g_Config.m_EnableThrottle;
if(g_Config.m_EnableThrottle)
if (g_Config.m_EnableThrottle)
{
/* This is only needed for non-AX sound, currently directly
streamed and DTK sound. For AX we call SoundStream::Update in
AXTask() for example. */

View File

@ -172,6 +172,7 @@
WarningLevel="3"
WarnAsError="false"
SuppressStartupBanner="true"
DebugInformationFormat="3"
ForcedIncludeFiles="stdafx.h"
/>
<Tool

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Version="9,00"
Name="Plugin_PadSimpleEvnt"
ProjectGUID="{58E81545-241B-416E-8088-E62452EB25FA}"
RootNamespace="Plugin_PadSimpleEvnt"
@ -172,6 +172,7 @@
WarningLevel="3"
WarnAsError="false"
SuppressStartupBanner="true"
DebugInformationFormat="3"
ForcedIncludeFiles="stdafx.h"
/>
<Tool

View File

@ -52,7 +52,6 @@ namespace EmuWindow
break;
case WM_CLOSE:
//Core::SetState(Core::CORE_UNINITIALIZED);
return 0;
case WM_DESTROY:

View File

@ -228,7 +228,6 @@ namespace EmuWindow
if(m_hParent == NULL)
{
ExitProcess(0);
//Core::SetState(Core::CORE_UNINITIALIZED);
/* Attempt to only Stop when we close the separate window. But it didn't work, it hanged.
It may need some more coordination with the Stop code in the Core */