[Projet64] Move logging class and clean up code

This commit is contained in:
zilmar 2015-11-08 20:17:13 +11:00
parent 786be5b062
commit 4ac266bd94
10 changed files with 709 additions and 717 deletions

View File

@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Configuration"> <PropertyGroup Label="Configuration">
<PlatformToolset>v140_xp</PlatformToolset> <PlatformToolset>v120_xp</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<ImportGroup Label="PropertySheets"> <ImportGroup Label="PropertySheets">

File diff suppressed because it is too large Load Diff

View File

@ -9,55 +9,48 @@
* * * *
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#ifdef __cplusplus
extern "C" {
#endif
typedef struct typedef struct
{ {
BOOL GenerateLog; bool GenerateLog;
/* Registers Log */ /* Registers Log */
BOOL LogRDRamRegisters; bool LogRDRamRegisters;
BOOL LogSPRegisters; bool LogSPRegisters;
BOOL LogDPCRegisters; bool LogDPCRegisters;
BOOL LogDPSRegisters; bool LogDPSRegisters;
BOOL LogMIPSInterface; bool LogMIPSInterface;
BOOL LogVideoInterface; bool LogVideoInterface;
BOOL LogAudioInterface; bool LogAudioInterface;
BOOL LogPerInterface; bool LogPerInterface;
BOOL LogRDRAMInterface; bool LogRDRAMInterface;
BOOL LogSerialInterface; bool LogSerialInterface;
/* Pif Ram Log */ /* Pif Ram Log */
BOOL LogPRDMAOperations; bool LogPRDMAOperations;
BOOL LogPRDirectMemLoads; bool LogPRDirectMemLoads;
BOOL LogPRDMAMemLoads; bool LogPRDMAMemLoads;
BOOL LogPRDirectMemStores; bool LogPRDirectMemStores;
BOOL LogPRDMAMemStores; bool LogPRDMAMemStores;
BOOL LogControllerPak; bool LogControllerPak;
/* Special Log */ /* Special Log */
BOOL LogCP0changes; bool LogCP0changes;
BOOL LogCP0reads; bool LogCP0reads;
BOOL LogTLB; bool LogTLB;
BOOL LogExceptions; bool LogExceptions;
BOOL NoInterrupts; bool NoInterrupts;
BOOL LogCache; bool LogCache;
BOOL LogRomHeader; bool LogRomHeader;
BOOL LogUnknown; bool LogUnknown;
} LOG_OPTIONS; } LOG_OPTIONS;
extern LOG_OPTIONS LogOptions; extern LOG_OPTIONS g_LogOptions;
void EnterLogOptions ( HWND hwndOwner ); void EnterLogOptions ( HWND hwndOwner );
void LoadLogOptions ( LOG_OPTIONS * LogOptions, BOOL AlwaysFill ); void StartLog ( void );
void Log_LW ( DWORD PC, DWORD VAddr ); void StopLog ( void );
void __cdecl LogMessage ( char * Message, ... ); void LoadLogOptions ( LOG_OPTIONS * LogOptions, bool AlwaysFill );
void Log_SW ( DWORD PC, DWORD VAddr, DWORD Value ); void Log_LW ( uint32_t PC, uint32_t VAddr );
void StartLog ( void ); void Log_SW ( uint32_t PC, uint32_t VAddr, uint32_t Value );
void StopLog ( void ); void LogMessage ( const char * Message, ... );
#ifdef __cplusplus
}
#endif

View File

@ -951,7 +951,7 @@ void R4300iOp32::LW()
ADDRESS_ERROR_EXCEPTION(Address, true); ADDRESS_ERROR_EXCEPTION(Address, true);
} }
if (LogOptions.GenerateLog) if (g_LogOptions.GenerateLog)
{ {
Log_LW((*_PROGRAM_COUNTER),Address); Log_LW((*_PROGRAM_COUNTER),Address);
} }
@ -1323,7 +1323,7 @@ void R4300iOp32::REGIMM_BGEZAL()
} }
/************************** COP0 functions **************************/ /************************** COP0 functions **************************/
void R4300iOp32::COP0_MF() { void R4300iOp32::COP0_MF() {
if (LogOptions.LogCP0reads) if (g_LogOptions.LogCP0reads)
{ {
LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]);
} }
@ -1337,7 +1337,7 @@ void R4300iOp32::COP0_MF() {
void R4300iOp32::COP0_MT() void R4300iOp32::COP0_MT()
{ {
if (LogOptions.LogCP0changes) if (g_LogOptions.LogCP0changes)
{ {
LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)",(*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0],CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)",(*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0],CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]);
if (m_Opcode.rd == 11) //Compare if (m_Opcode.rd == 11) //Compare

View File

@ -1115,7 +1115,7 @@ void R4300iOp::LW()
ADDRESS_ERROR_EXCEPTION(Address, true); ADDRESS_ERROR_EXCEPTION(Address, true);
} }
if (LogOptions.GenerateLog) if (g_LogOptions.GenerateLog)
{ {
Log_LW((*_PROGRAM_COUNTER),Address); Log_LW((*_PROGRAM_COUNTER),Address);
} }
@ -1295,7 +1295,7 @@ void R4300iOp::SW()
{ {
ADDRESS_ERROR_EXCEPTION(Address, false); ADDRESS_ERROR_EXCEPTION(Address, false);
} }
if (LogOptions.GenerateLog) if (g_LogOptions.GenerateLog)
{ {
Log_SW((*_PROGRAM_COUNTER),Address,_GPR[m_Opcode.rt].UW[0]); Log_SW((*_PROGRAM_COUNTER),Address,_GPR[m_Opcode.rt].UW[0]);
} }
@ -1445,7 +1445,7 @@ void R4300iOp::SWR()
void R4300iOp::CACHE() void R4300iOp::CACHE()
{ {
if (!LogOptions.LogCache) if (!g_LogOptions.LogCache)
{ {
return; return;
} }
@ -2094,7 +2094,7 @@ void R4300iOp::REGIMM_BGEZAL()
/************************** COP0 functions **************************/ /************************** COP0 functions **************************/
void R4300iOp::COP0_MF() void R4300iOp::COP0_MF()
{ {
if (LogOptions.LogCP0reads) if (g_LogOptions.LogCP0reads)
{ {
LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]);
} }
@ -2108,7 +2108,7 @@ void R4300iOp::COP0_MF()
void R4300iOp::COP0_MT() void R4300iOp::COP0_MT()
{ {
if (LogOptions.LogCP0changes) if (g_LogOptions.LogCP0changes)
{ {
LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)",(*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0],CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)",(*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0],CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]);
if (m_Opcode.rd == 11) //Compare if (m_Opcode.rd == 11) //Compare

View File

@ -308,7 +308,7 @@ void CPifRam::SI_DMA_READ()
} }
} }
if (LogOptions.LogPRDMAMemStores) if (g_LogOptions.LogPRDMAMemStores)
{ {
int count; int count;
char HexData[100], AsciiData[100], Addon[20]; char HexData[100], AsciiData[100], Addon[20];
@ -394,7 +394,7 @@ void CPifRam::SI_DMA_WRITE()
} }
} }
if (LogOptions.LogPRDMAMemLoads) if (g_LogOptions.LogPRDMAMemLoads)
{ {
int count; int count;
char HexData[100], AsciiData[100], Addon[20]; char HexData[100], AsciiData[100], Addon[20];
@ -505,7 +505,7 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
} }
break; break;
case 0x02: //read from controller pack case 0x02: //read from controller pack
if (LogOptions.LogControllerPak) if (g_LogOptions.LogControllerPak)
{ {
LogControllerPakData("Read: Before Gettting Results"); LogControllerPakData("Read: Before Gettting Results");
} }
@ -541,13 +541,13 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
{ {
Command[1] |= 0x80; Command[1] |= 0x80;
} }
if (LogOptions.LogControllerPak) if (g_LogOptions.LogControllerPak)
{ {
LogControllerPakData("Read: After Gettting Results"); LogControllerPakData("Read: After Gettting Results");
} }
break; break;
case 0x03: //write controller pak case 0x03: //write controller pak
if (LogOptions.LogControllerPak) if (g_LogOptions.LogControllerPak)
{ {
LogControllerPakData("Write: Before Processing"); LogControllerPakData("Write: Before Processing");
} }
@ -581,7 +581,7 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
{ {
Command[1] |= 0x80; Command[1] |= 0x80;
} }
if (LogOptions.LogControllerPak) if (g_LogOptions.LogControllerPak)
{ {
LogControllerPakData("Write: After Processing"); LogControllerPakData("Write: After Processing");
} }

View File

@ -463,7 +463,7 @@ bool CRegisters::DoIntrException(bool DelaySlot)
return false; return false;
} }
if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts) if (g_LogOptions.GenerateLog && g_LogOptions.LogExceptions && !g_LogOptions.NoInterrupts)
{ {
LogMessage("%08X: Interrupt Generated", m_PROGRAM_COUNTER); LogMessage("%08X: Interrupt Generated", m_PROGRAM_COUNTER);
} }

View File

@ -296,8 +296,8 @@ void CN64System::StartEmulation2 ( bool NewThread )
if (bHaveDebugger()) if (bHaveDebugger())
{ {
LogOptions.GenerateLog = g_Settings->LoadDword(Debugger_GenerateDebugLog); g_LogOptions.GenerateLog = g_Settings->LoadBool(Debugger_GenerateDebugLog);
LoadLogOptions(&LogOptions, FALSE); LoadLogOptions(&g_LogOptions, FALSE);
StartLog(); StartLog();
} }

View File

@ -41,6 +41,7 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Logging.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="Multilanguage\LanguageSelector.cpp" /> <ClCompile Include="Multilanguage\LanguageSelector.cpp" />
<ClCompile Include="N64 System\Mips\Rumblepak.cpp" /> <ClCompile Include="N64 System\Mips\Rumblepak.cpp" />
@ -122,7 +123,6 @@
<ClCompile Include="N64 System\Mips\System Events.cpp" /> <ClCompile Include="N64 System\Mips\System Events.cpp" />
<ClCompile Include="N64 System\Mips\System Timing.cpp" /> <ClCompile Include="N64 System\Mips\System Timing.cpp" />
<ClCompile Include="N64 System\Mips\TLB class.cpp" /> <ClCompile Include="N64 System\Mips\TLB class.cpp" />
<ClCompile Include="N64 System\C Core\Logging.cpp" />
<ClCompile Include="N64 System\C Core\r4300i Commands.cpp" /> <ClCompile Include="N64 System\C Core\r4300i Commands.cpp" />
<ClCompile Include="N64 System\Recompiler\Code Block.cpp" /> <ClCompile Include="N64 System\Recompiler\Code Block.cpp" />
<ClCompile Include="N64 System\Recompiler\Code Section.cpp" /> <ClCompile Include="N64 System\Recompiler\Code Section.cpp" />
@ -178,6 +178,7 @@
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Logging.h" />
<ClInclude Include="Multilanguage.h" /> <ClInclude Include="Multilanguage.h" />
<ClInclude Include="Multilanguage\LanguageSelector.h" /> <ClInclude Include="Multilanguage\LanguageSelector.h" />
<ClInclude Include="N64 System.h" /> <ClInclude Include="N64 System.h" />
@ -267,7 +268,6 @@
<ClInclude Include="N64 System\Mips\System Timing.h" /> <ClInclude Include="N64 System\Mips\System Timing.h" />
<ClInclude Include="N64 System\Mips\TLB Class.h" /> <ClInclude Include="N64 System\Mips\TLB Class.h" />
<ClInclude Include="N64 System\Mips\TranslateVaddr.h" /> <ClInclude Include="N64 System\Mips\TranslateVaddr.h" />
<ClInclude Include="N64 System\C Core\Logging.h" />
<ClInclude Include="N64 System\C Core\r4300i Commands.h" /> <ClInclude Include="N64 System\C Core\r4300i Commands.h" />
<ClInclude Include="N64 System\Debugger\Debugger - Memory Dump.h" /> <ClInclude Include="N64 System\Debugger\Debugger - Memory Dump.h" />
<ClInclude Include="N64 System\Debugger\Debugger - Memory Search.h" /> <ClInclude Include="N64 System\Debugger\Debugger - Memory Search.h" />

View File

@ -330,9 +330,6 @@
<ClCompile Include="N64 System\Mips\TLB class.cpp"> <ClCompile Include="N64 System\Mips\TLB class.cpp">
<Filter>Source Files\N64 System Source\Mips Source</Filter> <Filter>Source Files\N64 System Source\Mips Source</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="N64 System\C Core\Logging.cpp">
<Filter>Source Files\N64 System Source\C Core Source</Filter>
</ClCompile>
<ClCompile Include="N64 System\C Core\r4300i Commands.cpp"> <ClCompile Include="N64 System\C Core\r4300i Commands.cpp">
<Filter>Source Files\N64 System Source\C Core Source</Filter> <Filter>Source Files\N64 System Source\C Core Source</Filter>
</ClCompile> </ClCompile>
@ -420,6 +417,9 @@
<ClCompile Include="User Interface\Cheat Class UI.cpp"> <ClCompile Include="User Interface\Cheat Class UI.cpp">
<Filter>Source Files\User Interface Source</Filter> <Filter>Source Files\User Interface Source</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Logging.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="User Interface\Bitmaps\AboutScreenBottom.bmp"> <Image Include="User Interface\Bitmaps\AboutScreenBottom.bmp">
@ -722,9 +722,6 @@
<ClInclude Include="N64 System\Mips\TranslateVaddr.h"> <ClInclude Include="N64 System\Mips\TranslateVaddr.h">
<Filter>Header Files\N64 System Headers\Mips Headers</Filter> <Filter>Header Files\N64 System Headers\Mips Headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="N64 System\C Core\Logging.h">
<Filter>Header Files\N64 System Headers\C Core Headers</Filter>
</ClInclude>
<ClInclude Include="N64 System\C Core\r4300i Commands.h"> <ClInclude Include="N64 System\C Core\r4300i Commands.h">
<Filter>Header Files\N64 System Headers\C Core Headers</Filter> <Filter>Header Files\N64 System Headers\C Core Headers</Filter>
</ClInclude> </ClInclude>
@ -848,5 +845,8 @@
<ClInclude Include="User Interface\Cheat Class UI.h"> <ClInclude Include="User Interface\Cheat Class UI.h">
<Filter>Header Files\User Interface Headers</Filter> <Filter>Header Files\User Interface Headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Logging.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>