[Project64] Add more logging

This commit is contained in:
zilmar 2016-02-01 17:33:19 +11:00
parent b8bdf17499
commit 2b6fdc000e
8 changed files with 110 additions and 68 deletions

View File

@ -374,6 +374,7 @@ void CN64System::CloseSystem()
bool CN64System::EmulationStarting(void * hThread, uint32_t ThreadId)
{
WriteTrace(TraceN64System, TraceDebug, "Starting (hThread: %p ThreadId: %d)", hThread, ThreadId);
bool bRes = true;
WriteTrace(TraceN64System, TraceDebug, "Setting N64 system as active");
@ -406,18 +407,19 @@ bool CN64System::EmulationStarting(void * hThread, uint32_t ThreadId)
void CN64System::StartEmulation2(bool NewThread)
{
WriteTrace(TraceN64System, TraceDebug, "Start (NewThread: %s)",NewThread ? "true" : "false");
if (NewThread)
{
WriteTrace(TraceN64System, TraceDebug, "Starting");
if (bHaveDebugger())
{
StartLog();
}
WriteTrace(TraceN64System, TraceDebug, "Setting up system");
CInterpreterCPU::BuildCPU();
uint32_t CpuType = g_Settings->LoadDword(Game_CpuType);
WriteTrace(TraceN64System, TraceDebug, "CpuType = %d",CpuType);
if (CpuType == CPU_SyncCores && !g_Settings->LoadBool(Debugger_Enabled))
{
g_Settings->SaveDword(Game_CpuType, CPU_Recompiler);
@ -432,7 +434,7 @@ void CN64System::StartEmulation2(bool NewThread)
}
g_Notify->DisplayMessage(5, "Copy Plugins");
g_Plugins->CopyPlugins(g_Settings->LoadStringVal(Directory_PluginSync));
m_SyncPlugins = new CPlugins(g_Settings->LoadStringVal(Directory_PluginSync));
m_SyncPlugins = new CPlugins(Directory_PluginSync);
m_SyncPlugins->SetRenderWindows(g_Plugins->SyncWindow(), NULL);
m_SyncCPU = new CN64System(m_SyncPlugins, true);
}
@ -442,6 +444,7 @@ void CN64System::StartEmulation2(bool NewThread)
m_Recomp = new CRecompiler(m_Reg, m_Profile, m_EndEmulation);
}
WriteTrace(TraceN64System, TraceDebug, "Setting system as active");
bool bSetActive = true;
if (m_SyncCPU)
{
@ -455,11 +458,13 @@ void CN64System::StartEmulation2(bool NewThread)
if (!bSetActive)
{
WriteTrace(TraceN64System, TraceWarning, "Failed to set system as active");
g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT);
}
else
{
WriteTrace(TraceN64System, TraceDebug, "Starting emulation thread");
StartEmulationThead();
}
}
@ -467,14 +472,15 @@ void CN64System::StartEmulation2(bool NewThread)
{
//mark the emulation as starting and fix up menus
g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED);
WriteTrace(TraceN64System, TraceDebug, "Start Executing CPU");
ExecuteCPU();
}
WriteTrace(TraceN64System, TraceDebug, "Done");
}
void CN64System::StartEmulation(bool NewThread)
{
WriteTrace(TraceN64System, TraceDebug, "Start");
WriteTrace(TraceN64System, TraceDebug, "Start (NewThread: %s)", NewThread ? "true" : "false");
__except_try()
{
StartEmulation2(NewThread);
@ -485,7 +491,7 @@ void CN64System::StartEmulation(bool NewThread)
sprintf(message, "Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__);
g_Notify->DisplayError(message);
}
WriteTrace(TraceN64System, TraceDebug, "Done");
WriteTrace(TraceN64System, TraceDebug, "Done (NewThread: %s)", NewThread ? "true" : "false")
}
void CN64System::Pause()

View File

@ -16,22 +16,22 @@
#include "GFXPlugin.h"
CGfxPlugin::CGfxPlugin() :
CaptureScreen(NULL),
ChangeWindow(NULL),
DrawScreen(NULL),
DrawStatus(NULL),
MoveScreen(NULL),
ProcessDList(NULL),
ProcessRDPList(NULL),
ShowCFB(NULL),
UpdateScreen(NULL),
ViStatusChanged(NULL),
ViWidthChanged(NULL),
SoftReset(NULL),
GetRomBrowserMenu(NULL),
OnRomBrowserMenuItem(NULL),
GetDebugInfo(NULL),
InitiateDebugger(NULL)
CaptureScreen(NULL),
ChangeWindow(NULL),
DrawScreen(NULL),
DrawStatus(NULL),
MoveScreen(NULL),
ProcessDList(NULL),
ProcessRDPList(NULL),
ShowCFB(NULL),
UpdateScreen(NULL),
ViStatusChanged(NULL),
ViWidthChanged(NULL),
SoftReset(NULL),
GetRomBrowserMenu(NULL),
OnRomBrowserMenuItem(NULL),
GetDebugInfo(NULL),
InitiateDebugger(NULL)
{
memset(&m_GFXDebug, 0, sizeof(m_GFXDebug));
}
@ -101,6 +101,7 @@ bool CGfxPlugin::LoadFunctions(void)
bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window)
{
WriteTrace(TraceGFXPlugin, TraceDebug, "Starting");
if (m_Initialized)
{
Close();
@ -153,14 +154,18 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window)
//Get Function from DLL
int32_t(CALL *InitiateGFX)(GFX_INFO Gfx_Info);
_LoadFunction("InitiateGFX",InitiateGFX);
if (InitiateGFX == NULL) { return false; }
_LoadFunction("InitiateGFX", InitiateGFX);
if (InitiateGFX == NULL)
{
WriteTrace(TraceGFXPlugin, TraceDebug, "Failed to find InitiateGFX");
return false;
}
GFX_INFO Info = { 0 };
Info.MemoryBswaped = true;
Info.hWnd = Window->GetWindowHandle();
Info.hStatusBar = Window->GetStatusBar();
Info.hWnd = Window ? Window->GetWindowHandle() : NULL;
Info.hStatusBar = Window ? Window->GetStatusBar() : NULL;
Info.CheckInterrupts = DummyCheckInterrupts;
// We are initializing the plugin before any rom is loaded so we do not have any correct
@ -222,13 +227,15 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window)
Info.VI__Y_SCALE_REG = &g_Reg->VI_Y_SCALE_REG;
}
WriteTrace(TraceGFXPlugin, TraceDebug, "Calling InitiateGFX");
m_Initialized = InitiateGFX(Info) != 0;
#ifdef _WIN32
//jabo had a bug so I call CreateThread so his dllmain gets called again
//jabo had a bug so I call CreateThread so his dllmain gets called again
pjutil::DynLibCallDllMain();
#endif
WriteTrace(TraceGFXPlugin, TraceDebug, "InitiateGFX done (res: %s)", m_Initialized ? "true" : "false");
return m_Initialized;
}

View File

@ -10,20 +10,21 @@
****************************************************************************/
#include "stdafx.h"
#include <Project64-core/Plugins/PluginBase.h>
#include <Common/path.h>
CPlugin::CPlugin() :
DllAbout(NULL),
DllConfig(NULL),
CloseDLL(NULL),
RomOpen(NULL),
RomClosed(NULL),
PluginOpened(NULL),
SetSettingInfo(NULL),
SetSettingInfo2(NULL),
SetSettingInfo3(NULL),
m_LibHandle(NULL),
m_Initialized(false),
m_RomOpen(false)
DllAbout(NULL),
DllConfig(NULL),
CloseDLL(NULL),
RomOpen(NULL),
RomClosed(NULL),
PluginOpened(NULL),
SetSettingInfo(NULL),
SetSettingInfo2(NULL),
SetSettingInfo3(NULL),
m_LibHandle(NULL),
m_Initialized(false),
m_RomOpen(false)
{
memset(&m_PluginInfo, 0, sizeof(m_PluginInfo));
}

View File

@ -14,14 +14,15 @@
#include <Project64-core/Plugins/PluginClass.h>
#include <Common/path.h>
CPlugins::CPlugins(const stdstr & PluginDir) :
m_MainWindow(NULL),
m_SyncWindow(NULL),
m_PluginDir(PluginDir),
m_Gfx(NULL),
m_Audio(NULL),
m_RSP(NULL),
m_Control(NULL)
CPlugins::CPlugins(SettingID PluginDirSetting) :
m_MainWindow(NULL),
m_SyncWindow(NULL),
m_PluginDirSetting(PluginDirSetting),
m_PluginDir(g_Settings->LoadStringVal(PluginDirSetting)),
m_Gfx(NULL),
m_Audio(NULL),
m_RSP(NULL),
m_Control(NULL)
{
CreatePlugins();
g_Settings->RegisterChangeCB(Plugin_RSP_Current, this, (CSettings::SettingChangedFunc)PluginChanged);
@ -34,6 +35,7 @@ CPlugins::CPlugins(const stdstr & PluginDir) :
g_Settings->RegisterChangeCB(Game_EditPlugin_Audio, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->RegisterChangeCB(Game_EditPlugin_Contr, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->RegisterChangeCB(Game_EditPlugin_RSP, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->RegisterChangeCB(m_PluginDirSetting, this, (CSettings::SettingChangedFunc)PluginChanged);
}
CPlugins::~CPlugins(void)
@ -48,6 +50,7 @@ CPlugins::~CPlugins(void)
g_Settings->UnregisterChangeCB(Game_EditPlugin_Audio, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->UnregisterChangeCB(Game_EditPlugin_Contr, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->UnregisterChangeCB(Game_EditPlugin_RSP, this, (CSettings::SettingChangedFunc)PluginChanged);
g_Settings->UnregisterChangeCB(m_PluginDirSetting, this, (CSettings::SettingChangedFunc)PluginChanged);
DestroyGfxPlugin();
DestroyAudioPlugin();
@ -59,15 +62,29 @@ void CPlugins::PluginChanged(CPlugins * _this)
{
if (g_Settings->LoadBool(Game_TempLoaded) == true)
{
WriteTrace(TracePlugins, TraceDebug, "Game is temporary loaded, not changing plugins");
return;
}
bool bGfxChange = _stricmp(_this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()) != 0;
bool bAudioChange = _stricmp(_this->m_AudioFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()) != 0;
bool bRspChange = _stricmp(_this->m_RSPFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()) != 0;
bool bContChange = _stricmp(_this->m_ControlFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()) != 0;
if (_stricmp(_this->m_PluginDir.c_str(), g_Settings->LoadStringVal(_this->m_PluginDirSetting).c_str()) != 0)
{
bGfxChange = true;
bAudioChange = true;
bRspChange = true;
bContChange = true;
WriteTrace(TracePlugins, TraceDebug, "plugin directory changed");
}
if (bGfxChange || bAudioChange || bRspChange || bContChange)
{
if (bGfxChange) { WriteTrace(TracePlugins, TraceDebug, "Gfx plugin changed"); }
if (bAudioChange) { WriteTrace(TracePlugins, TraceDebug, "Audio plugin changed"); }
if (bRspChange) { WriteTrace(TracePlugins, TraceDebug, "RSP plugin changed"); }
if (bContChange) { WriteTrace(TracePlugins, TraceDebug, "Controller plugin changed"); }
if (g_Settings->LoadBool(GameRunning_CPU_Running))
{
//Ensure that base system actually exists before we go triggering the event
@ -81,6 +98,7 @@ void CPlugins::PluginChanged(CPlugins * _this)
_this->Reset(NULL);
}
}
WriteTrace(TracePlugins, TraceDebug, "Done");
}
template <typename plugin_type>
@ -103,7 +121,7 @@ static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID,
}
else
{
WriteTrace(TraceError, TraceDebug, "Failed to load %s", (const char *)PluginFileName);
WriteTrace(TraceLevel, TraceError, "Failed to load %s", (const char *)PluginFileName);
delete plugin;
plugin = NULL;
}
@ -111,7 +129,7 @@ static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID,
}
else
{
WriteTrace(TraceError, TraceDebug, "Failed to allocate %s plugin", type);
WriteTrace(TraceLevel, TraceError, "Failed to allocate %s plugin", type);
}
}

View File

@ -98,7 +98,7 @@ class CPlugins :
{
public:
//Functions
CPlugins(const stdstr & PluginDir);
CPlugins(SettingID PluginDirSetting);
~CPlugins();
bool Initiate(CN64System * System);
@ -135,7 +135,8 @@ private:
RenderWindow * m_MainWindow;
RenderWindow * m_SyncWindow;
stdstr const m_PluginDir;
SettingID m_PluginDirSetting;
stdstr m_PluginDir;
//Plugins
CGfxPlugin * m_Gfx;

View File

@ -66,8 +66,11 @@ bool CRSP_Plugin::LoadFunctions(void)
bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
{
WriteTrace(TraceRSPPlugin, TraceDebug, "Starting");
if (m_PluginInfo.Version == 1 || m_PluginInfo.Version == 0x100)
{
WriteTrace(TraceRSPPlugin, TraceDebug, "Invalid Version: %X",m_PluginInfo.Version);
WriteTrace(TraceRSPPlugin, TraceDebug, "Done (res: false)");
return false;
}
@ -110,14 +113,19 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
RSP_INFO_1_1 Info = { 0 };
Info.hInst = Plugins->MainWindow()->GetModuleInstance();
Info.hInst = (Plugins != NULL && Plugins->MainWindow()!= NULL ) ? Plugins->MainWindow()->GetModuleInstance() : NULL;
Info.CheckInterrupts = DummyCheckInterrupts;
Info.MemoryBswaped = (System == NULL); // only true when the system's not yet loaded
//Get Function from DLL
void(CALL *InitiateRSP) (RSP_INFO_1_1 Audio_Info, uint32_t * Cycles);
LoadFunction(InitiateRSP);
if (InitiateRSP == NULL) { return false; }
if (InitiateRSP == NULL)
{
WriteTrace(TraceRSPPlugin, TraceDebug, "Failed to find InitiateRSP");
WriteTrace(TraceRSPPlugin, TraceDebug, "Done (res: false)");
return false;
}
// We are initializing the plugin before any rom is loaded so we do not have any correct
// parameters here.. just needed to we can config the DLL.
@ -197,6 +205,7 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
//jabo had a bug so I call CreateThread so his dllmain gets called again
pjutil::DynLibCallDllMain();
#endif
WriteTrace(TraceRSPPlugin, TraceDebug, "Done (res: %s)",m_Initialized ? "true" : "false");
return m_Initialized;
}

View File

@ -13,30 +13,29 @@
#include "SettingsType-ApplicationPath.h"
#include <Common/path.h>
CSettingTypeApplicationPath::CSettingTypeApplicationPath(const char * Section, const char * Name, SettingID DefaultSetting ) :
CSettingTypeApplication(Section,Name,DefaultSetting)
CSettingTypeApplicationPath::CSettingTypeApplicationPath(const char * Section, const char * Name, SettingID DefaultSetting) :
CSettingTypeApplication(Section, Name, DefaultSetting)
{
}
CSettingTypeApplicationPath::~CSettingTypeApplicationPath()
{
}
bool CSettingTypeApplicationPath::Load ( int Index, stdstr & Value ) const
bool CSettingTypeApplicationPath::Load(int Index, stdstr & Value) const
{
bool bRes = CSettingTypeApplication::Load(Index,Value);
if (bRes)
{
if (Value.substr(0,2) == ".\\" || Value.substr(0,2) == "./" ||
Value.substr(0,3) == "..\\" || Value.substr(0,3) == "../")
{
bool bRes = CSettingTypeApplication::Load(Index, Value);
if (bRes)
{
if (Value.substr(0, 2) == ".\\" || Value.substr(0, 2) == "./" ||
Value.substr(0, 3) == "..\\" || Value.substr(0, 3) == "../")
{
CPath FullFilePath(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(), ""), RelativePath(Value);
FullFilePath.SetNameExtension(RelativePath.GetNameExtension().c_str());
FullFilePath.AppendDirectory(RelativePath.GetDirectory().c_str());
FullFilePath.SetNameExtension(RelativePath.GetNameExtension().c_str());
FullFilePath.AppendDirectory(RelativePath.GetDirectory().c_str());
Value = (const std::string &)FullFilePath;
}
}
return bRes;
}
}
return bRes;
}

View File

@ -12,6 +12,7 @@
#include <Project64-core/Settings/Settings.h>
#include <Common/StdString.h>
#include <Common/stdtypes.h>
enum SettingType
{