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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -72,7 +72,6 @@ enum CPUState
}; };
extern PowerPCState ppcState; extern PowerPCState ppcState;
extern volatile CPUState state; // Execution engines should poll this to know when to exit.
void Init(); void Init();
void Shutdown(); void Shutdown();
@ -86,6 +85,8 @@ void RunLoop();
void Start(); void Start();
void Pause(); void Pause();
void Stop(); 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 CompactCR();
void ExpandCR(); void ExpandCR();

View File

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

View File

@ -50,11 +50,11 @@ namespace InputCommon
// ¯¯¯¯¯¯¯¯¯¯¯¯¯ // ¯¯¯¯¯¯¯¯¯¯¯¯¯
float Deg2Rad(float Deg) float Deg2Rad(float Deg)
{ {
return Deg * (M_PI / 180.0); return Deg * ((float)M_PI / 180.0f);
} }
float Rad2Deg(float Rad) 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) bool IsDeadZone(float DeadZone, int x, int y)
{ {
// Get the distance from the center // 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); //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 // Get the manually configured diagonal distance
int Tmp = atoi (SDiagonal.substr(0, SDiagonal.length() - 1).c_str()); 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 // 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 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); if (SDL_JoystickOpened(i)) SDL_JoystickClose(_joyinfo[i].joy);
} }
_NumPads = _joyinfo.size(); _NumPads = (int)_joyinfo.size();
return true; 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 PV1l=0,PV2l=0,PV3l=0,PV4l=0;
static int PV1r=0,PV2r=0,PV3r=0,PV4r=0; static int PV1r=0,PV2r=0,PV3r=0,PV4r=0;
static int acc=0; static int acc=0;
#ifdef _WIN32
if (GetAsyncKeyState(VK_TAB))
return;
#endif
// Write Other Audio // Write Other Audio
//bThrottling = g_Config.m_EnableThrottle; //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 /* This is only needed for non-AX sound, currently directly
streamed and DTK sound. For AX we call SoundStream::Update in streamed and DTK sound. For AX we call SoundStream::Update in
AXTask() for example. */ AXTask() for example. */

View File

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

View File

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

View File

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

View File

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