[Project64] Add ability to monitor Game Cpu Running to Gui

This commit is contained in:
zilmar 2015-11-15 15:44:40 +11:00
parent 8aa5b6ef47
commit 7d7026c33d
3 changed files with 84 additions and 43 deletions

View File

@ -321,40 +321,25 @@ void CN64System::StartEmulation2(bool NewThread)
{ {
g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT); g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT);
Notify().ShowRomBrowser();
} }
else
{
ThreadInfo * Info = new ThreadInfo;
HANDLE * hThread = new HANDLE;
*hThread = NULL;
Notify().MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop)); //create the needed info into a structure to pass as one parameter
//for creating a thread
Info->ThreadHandle = hThread;
ThreadInfo * Info = new ThreadInfo; *hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartEmulationThread, Info, 0, &Info->ThreadID);
HANDLE * hThread = new HANDLE; }
*hThread = NULL;
//create the needed info into a structure to pass as one parameter
//for creating a thread
Info->ThreadHandle = hThread;
*hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartEmulationThread, Info, 0, &Info->ThreadID);
} }
else else
{ {
//mark the emulation as starting and fix up menus //mark the emulation as starting and fix up menus
g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED);
if (g_Settings->LoadBool(Setting_AutoFullscreen))
{
WriteTrace(TraceDebug, __FUNCTION__ " 15");
CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
stdstr Status = g_Settings->LoadStringVal(Rdb_Status);
char String[100];
RomIniFile.GetString("Rom Status", stdstr_f("%s.AutoFullScreen", Status.c_str()).c_str(), "true", String, sizeof(String));
if (_stricmp(String, "true") == 0)
{
Notify().ChangeFullScreen();
}
}
ExecuteCPU(); ExecuteCPU();
} }
} }
@ -887,23 +872,15 @@ void CN64System::ExecuteRecompiler()
void CN64System::ExecuteSyncCPU() void CN64System::ExecuteSyncCPU()
{ {
Notify().BringToTop();
m_Recomp->Run(); m_Recomp->Run();
} }
void CN64System::CpuStopped() void CN64System::CpuStopped()
{ {
g_Settings->SaveBool(GameRunning_CPU_Running, (DWORD)false);
Notify().WindowMode();
if (!m_InReset) if (!m_InReset)
{ {
Notify().RefreshMenu(); g_Settings->SaveBool(GameRunning_CPU_Running, (uint32_t)false);
Notify().MakeWindowOnTop(false);
g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED); g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED);
if (g_Settings->LoadDword(RomBrowser_Enabled))
{
Notify().ShowRomBrowser();
}
} }
if (m_SyncCPU) if (m_SyncCPU)
{ {
@ -963,7 +940,7 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
#ifdef TEST_SP_TRACKING #ifdef TEST_SP_TRACKING
if (m_CurrentSP != GPR[29].UW[0]) { if (m_CurrentSP != GPR[29].UW[0]) {
ErrorFound = true; ErrorFound = true;
} }
#endif #endif
if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER)
{ {
@ -1082,7 +1059,7 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
// if (PROGRAM_COUNTER == 0x8009BBD8) { // if (PROGRAM_COUNTER == 0x8009BBD8) {
// g_Notify->BreakPoint(__FILEW__,__LINE__); // g_Notify->BreakPoint(__FILEW__,__LINE__);
// } // }
} }
void CN64System::SyncSystem() void CN64System::SyncSystem()
{ {
@ -1110,7 +1087,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
#ifdef TEST_SP_TRACKING #ifdef TEST_SP_TRACKING
if (m_CurrentSP != GPR[29].UW[0]) { if (m_CurrentSP != GPR[29].UW[0]) {
Error.Log("m_CurrentSP,%X,%X\r\n", m_CurrentSP, GPR[29].UW[0]); Error.Log("m_CurrentSP,%X,%X\r\n", m_CurrentSP, GPR[29].UW[0]);
} }
#endif #endif
if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) { if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) {
Error.LogF("PROGRAM_COUNTER 0x%X, 0x%X\r\n", m_Reg.m_PROGRAM_COUNTER, SecondCPU->m_Reg.m_PROGRAM_COUNTER); Error.LogF("PROGRAM_COUNTER 0x%X, 0x%X\r\n", m_Reg.m_PROGRAM_COUNTER, SecondCPU->m_Reg.m_PROGRAM_COUNTER);
@ -1324,7 +1301,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr)); Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr));
} }
} }
} }
g_Notify->DisplayError(L"Sync Error"); g_Notify->DisplayError(L"Sync Error");
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
@ -2011,9 +1988,9 @@ bool CN64System::WriteToProtectedMemory(uint32_t Address, int length)
#ifdef tofix #ifdef tofix
return m_Recomp->ClearRecompCode_Phys(Address, length, CRecompiler::Remove_ProtectedMem); return m_Recomp->ClearRecompCode_Phys(Address, length, CRecompiler::Remove_ProtectedMem);
#endif #endif
}
return false;
} }
return false;
}
void CN64System::TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly) void CN64System::TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly)
{ {

View File

@ -50,6 +50,7 @@ m_ResetInfo(NULL)
g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged);
g_Settings->RegisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); g_Settings->RegisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged);
g_Settings->RegisterChangeCB(GameRunning_CPU_Running, this, (CSettings::SettingChangedFunc)GameCpuRunning);
g_Settings->RegisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused); g_Settings->RegisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused);
g_Settings->RegisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded); g_Settings->RegisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded);
} }
@ -68,6 +69,7 @@ CMainGui::~CMainGui(void)
g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged);
g_Settings->UnregisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); g_Settings->UnregisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged);
g_Settings->UnregisterChangeCB(GameRunning_CPU_Running, this, (CSettings::SettingChangedFunc)GameCpuRunning);
g_Settings->UnregisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused); g_Settings->UnregisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused);
g_Settings->UnregisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded); g_Settings->UnregisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded);
} }
@ -150,6 +152,15 @@ void CMainGui::SetWindowCaption(const wchar_t * title)
Caption(WinTitle); Caption(WinTitle);
} }
void CMainGui::ShowRomBrowser(void)
{
if (g_Settings->LoadDword(RomBrowser_Enabled))
{
ShowRomList();
HighLightLastRom();
}
}
void RomBowserEnabledChanged(CMainGui * Gui) void RomBowserEnabledChanged(CMainGui * Gui)
{ {
if (Gui && g_Settings->LoadBool(RomBrowser_Enabled)) if (Gui && g_Settings->LoadBool(RomBrowser_Enabled))
@ -171,6 +182,15 @@ void RomBowserEnabledChanged(CMainGui * Gui)
void CMainGui::LoadingInProgressChanged(CMainGui * Gui) void CMainGui::LoadingInProgressChanged(CMainGui * Gui)
{ {
Gui->RefreshMenu(); Gui->RefreshMenu();
if (!g_Settings->LoadBool(GameRunning_LoadingInProgress) && g_Settings->LoadStringVal(Game_File).length() == 0)
{
Notify().WindowMode();
if (g_Settings->LoadDword(RomBrowser_Enabled))
{
Gui->ShowRomBrowser();
}
Gui->MakeWindowOnTop(false);
}
} }
void CMainGui::GameLoaded(CMainGui * Gui) void CMainGui::GameLoaded(CMainGui * Gui)
@ -181,7 +201,6 @@ void CMainGui::GameLoaded(CMainGui * Gui)
WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom"); WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom");
Gui->AddRecentRom(FileLoc.c_str()); Gui->AddRecentRom(FileLoc.c_str());
Gui->SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str()); Gui->SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str());
Gui->HideRomList(); Gui->HideRomList();
} }
} }
@ -191,6 +210,33 @@ void CMainGui::GamePaused(CMainGui * Gui)
Gui->RefreshMenu(); Gui->RefreshMenu();
} }
void CMainGui::GameCpuRunning(CMainGui * Gui)
{
if (g_Settings->LoadBool(GameRunning_CPU_Running))
{
Gui->MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop));
if (g_Settings->LoadBool(Setting_AutoFullscreen))
{
WriteTrace(TraceDebug, __FUNCTION__ " 15");
CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
stdstr Status = g_Settings->LoadStringVal(Rdb_Status);
char String[100];
RomIniFile.GetString("Rom Status", stdstr_f("%s.AutoFullScreen", Status.c_str()).c_str(), "true", String, sizeof(String));
if (_stricmp(String, "true") == 0)
{
g_Notify->ChangeFullScreen();
}
}
Gui->RefreshMenu();
Gui->BringToTop();
}
else
{
PostMessage(Gui->m_hMainWindow, WM_GAME_CLOSED, 0, 0);
}
}
void RomBowserColoumnsChanged(CMainGui * Gui) void RomBowserColoumnsChanged(CMainGui * Gui)
{ {
Gui->ResetRomBrowserColomuns(); Gui->ResetRomBrowserColomuns();
@ -375,6 +421,7 @@ bool CMainGui::ResetPluginsInUiThread(CPlugins * plugins, CN64System * System)
WriteTrace(TraceError, __FUNCTION__ ": Failed to create event"); WriteTrace(TraceError, __FUNCTION__ ": Failed to create event");
bRes = false; bRes = false;
} }
Notify().RefreshMenu();
return bRes; return bRes;
} }
@ -908,6 +955,20 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
_this->m_ResetPlugins = true; _this->m_ResetPlugins = true;
} }
break; break;
case WM_GAME_CLOSED:
{
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
Notify().WindowMode();
if (g_Settings->LoadDword(RomBrowser_Enabled))
{
_this->ShowRomBrowser();
}
_this->RefreshMenu();
_this->MakeWindowOnTop(false);
_this->SetStatusText(0, L"");
_this->SetStatusText(1, L"");
}
break;
case WM_COMMAND: case WM_COMMAND:
{ {
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");

View File

@ -25,8 +25,9 @@ enum
{ {
WM_HIDE_CUROSR = WM_USER + 10, WM_HIDE_CUROSR = WM_USER + 10,
WM_MAKE_FOCUS = WM_USER + 17, WM_MAKE_FOCUS = WM_USER + 17,
WM_RESET_PLUGIN = WM_USER + 18, WM_RESET_PLUGIN = WM_USER + 18,
WM_BORWSER_TOP = WM_USER + 40, WM_GAME_CLOSED = WM_USER + 19,
WM_BORWSER_TOP = WM_USER + 40,
}; };
class CMainGui : class CMainGui :
@ -105,6 +106,7 @@ private:
void Resize(DWORD fwSizeType, WORD nWidth, WORD nHeight); //responding to WM_SIZE void Resize(DWORD fwSizeType, WORD nWidth, WORD nHeight); //responding to WM_SIZE
void AddRecentRom(const char * ImagePath); void AddRecentRom(const char * ImagePath);
void SetWindowCaption(const wchar_t * Caption); void SetWindowCaption(const wchar_t * Caption);
void ShowRomBrowser(void);
friend DWORD CALLBACK AboutBoxProc(HWND, DWORD, DWORD, DWORD); friend DWORD CALLBACK AboutBoxProc(HWND, DWORD, DWORD, DWORD);
friend DWORD CALLBACK AboutIniBoxProc(HWND, DWORD, DWORD, DWORD); friend DWORD CALLBACK AboutIniBoxProc(HWND, DWORD, DWORD, DWORD);
@ -116,6 +118,7 @@ private:
static void LoadingInProgressChanged(CMainGui * Gui); static void LoadingInProgressChanged(CMainGui * Gui);
static void GameLoaded(CMainGui * Gui); static void GameLoaded(CMainGui * Gui);
static void GamePaused(CMainGui * Gui); static void GamePaused(CMainGui * Gui);
static void GameCpuRunning(CMainGui * Gui);
CBaseMenu * m_Menu; CBaseMenu * m_Menu;