[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">

View File

@ -12,15 +12,15 @@
#include <prsht.h> #include <prsht.h>
void LoadLogSetting (HKEY hKey,char * String, BOOL * Value); void LoadLogSetting (HKEY hKey,char * String, bool * Value);
void SaveLogOptions (void); void SaveLogOptions (void);
LRESULT CALLBACK LogGeneralProc ( HWND, UINT, WPARAM, LPARAM ); LRESULT CALLBACK LogGeneralProc ( HWND, UINT, WPARAM, LPARAM );
LRESULT CALLBACK LogPifProc ( HWND, UINT, WPARAM, LPARAM ); LRESULT CALLBACK LogPifProc ( HWND, UINT, WPARAM, LPARAM );
LRESULT CALLBACK LogRegProc ( HWND, UINT, WPARAM, LPARAM ); LRESULT CALLBACK LogRegProc ( HWND, UINT, WPARAM, LPARAM );
LOG_OPTIONS LogOptions,TempOptions; static HANDLE g_hLogFile = NULL;
HANDLE hLogFile = NULL; LOG_OPTIONS g_LogOptions, TempOptions;
void EnterLogOptions(HWND hwndOwner) void EnterLogOptions(HWND hwndOwner)
{ {
@ -71,13 +71,13 @@ void EnterLogOptions(HWND hwndOwner)
g_Notify -> BreakPoint(__FILEW__, __LINE__); g_Notify -> BreakPoint(__FILEW__, __LINE__);
#endif #endif
SaveLogOptions(); SaveLogOptions();
LoadLogOptions(&LogOptions, FALSE); LoadLogOptions(&g_LogOptions, FALSE);
return; return;
} }
void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill) void LoadLogOptions (LOG_OPTIONS * LogOptions, bool AlwaysFill)
{ {
long lResult; int32_t lResult;
HKEY hKeyResults = 0; HKEY hKeyResults = 0;
char String[200]; char String[200];
@ -147,15 +147,15 @@ void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill)
LogOptions->LogUnknown = FALSE; LogOptions->LogUnknown = FALSE;
} }
void LoadLogSetting (HKEY hKey,char * String, BOOL * Value) void LoadLogSetting (HKEY hKey,char * String, bool * Value)
{ {
DWORD Type, dwResult, Bytes = 4; DWORD Type, dwResult, Bytes = 4;
long lResult; int32_t lResult;
lResult = RegQueryValueEx(hKey,String,0,&Type,(LPBYTE)(&dwResult),&Bytes); lResult = RegQueryValueEx(hKey,String,0,&Type,(LPBYTE)(&dwResult),&Bytes);
if (Type == REG_DWORD && lResult == ERROR_SUCCESS) if (Type == REG_DWORD && lResult == ERROR_SUCCESS)
{ {
*Value = (BOOL)dwResult; *Value = dwResult != 0;
} }
else else
{ {
@ -194,19 +194,19 @@ LRESULT CALLBACK LogGeneralProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM
return TRUE; return TRUE;
} }
void Log_LW (DWORD PC, DWORD VAddr) void Log_LW (uint32_t PC, uint32_t VAddr)
{ {
if (!LogOptions.GenerateLog) if (!g_LogOptions.GenerateLog)
{ {
return; return;
} }
if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 )
{ {
DWORD PAddr; uint32_t PAddr;
if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr)) if (!g_TransVaddr->TranslateVaddr(VAddr,(DWORD &)PAddr))
{ {
if (LogOptions.LogUnknown) if (g_LogOptions.LogUnknown)
{ {
LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr); LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr);
} }
@ -215,18 +215,18 @@ void Log_LW (DWORD PC, DWORD VAddr)
VAddr = PAddr + 0xA0000000; VAddr = PAddr + 0xA0000000;
} }
DWORD Value; uint32_t Value;
if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize()))
{ {
return; return;
} }
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024)
{ {
if (!LogOptions.LogRDRamRegisters) if (!g_LogOptions.LogRDRamRegisters)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
switch (VAddr) switch (VAddr)
{ {
@ -249,11 +249,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
} }
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C ) if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C )
{ {
if (!LogOptions.LogSPRegisters) if (!g_LogOptions.LogSPRegisters)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
switch (VAddr) switch (VAddr)
{ {
@ -270,21 +270,21 @@ void Log_LW (DWORD PC, DWORD VAddr)
} }
if ( VAddr == 0xA4080000) if ( VAddr == 0xA4080000)
{ {
if (!LogOptions.LogSPRegisters) if (!g_LogOptions.LogSPRegisters)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
LogMessage("%08X: read from SP_PC (%08X)",PC, Value); LogMessage("%08X: read from SP_PC (%08X)",PC, Value);
return; return;
} }
if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C)
{ {
if (!LogOptions.LogDPCRegisters) if (!g_LogOptions.LogDPCRegisters)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
switch (VAddr) switch (VAddr)
{ {
@ -300,11 +300,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
} }
if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C)
{ {
if (!LogOptions.LogMIPSInterface) if (!g_LogOptions.LogMIPSInterface)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
switch (VAddr) switch (VAddr)
{ {
@ -316,11 +316,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
} }
if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034)
{ {
if (!LogOptions.LogVideoInterface) if (!g_LogOptions.LogVideoInterface)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
switch (VAddr) switch (VAddr)
{ {
@ -342,11 +342,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
} }
if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014)
{ {
if (!LogOptions.LogAudioInterface) if (!g_LogOptions.LogAudioInterface)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
switch (VAddr) switch (VAddr)
{ {
@ -360,11 +360,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
} }
if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030)
{ {
if (!LogOptions.LogPerInterface) if (!g_LogOptions.LogPerInterface)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
switch (VAddr) switch (VAddr)
{ {
@ -385,11 +385,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
} }
if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C)
{ {
if (!LogOptions.LogRDRAMInterface) if (!g_LogOptions.LogRDRAMInterface)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
switch (VAddr) switch (VAddr)
{ {
@ -405,41 +405,41 @@ void Log_LW (DWORD PC, DWORD VAddr)
} }
if ( VAddr == 0xA4800000) if ( VAddr == 0xA4800000)
{ {
if (!LogOptions.LogSerialInterface) if (!g_LogOptions.LogSerialInterface)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value); LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value);
return; return;
} }
if ( VAddr == 0xA4800004) if ( VAddr == 0xA4800004)
{ {
if (!LogOptions.LogSerialInterface) if (!g_LogOptions.LogSerialInterface)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value); LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value);
return; return;
} }
if ( VAddr == 0xA4800010) if ( VAddr == 0xA4800010)
{ {
if (!LogOptions.LogSerialInterface) if (!g_LogOptions.LogSerialInterface)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value); LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value);
return; return;
} }
if ( VAddr == 0xA4800018) if ( VAddr == 0xA4800018)
{ {
if (!LogOptions.LogSerialInterface) if (!g_LogOptions.LogSerialInterface)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value); LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value);
return; return;
} }
@ -449,11 +449,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
} }
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC )
{ {
if (!LogOptions.LogPRDirectMemLoads) if (!g_LogOptions.LogPRDirectMemLoads)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value); LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value);
return; return;
} }
@ -463,12 +463,12 @@ void Log_LW (DWORD PC, DWORD VAddr)
} }
if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040) if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040)
{ {
if (!LogOptions.LogRomHeader) if (!g_LogOptions.LogRomHeader)
{ {
return; return;
} }
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
switch (VAddr) switch (VAddr)
{ {
case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break; case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break;
@ -480,50 +480,26 @@ void Log_LW (DWORD PC, DWORD VAddr)
} }
return; return;
} }
if (!LogOptions.LogUnknown) if (!g_LogOptions.LogUnknown)
{ {
return; return;
} }
LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr); LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr);
} }
void __cdecl LogMessage (char * Message, ...) void Log_SW (uint32_t PC, uint32_t VAddr, uint32_t Value)
{ {
DWORD dwWritten; if (!g_LogOptions.GenerateLog)
char Msg[400];
va_list ap;
if (!g_Settings->LoadBool(Debugger_Enabled))
{
return;
}
if (hLogFile == NULL)
{
return;
}
va_start( ap, Message );
vsprintf( Msg, Message, ap );
va_end( ap );
strcat(Msg,"\r\n");
WriteFile( hLogFile,Msg,strlen(Msg),&dwWritten,NULL );
}
void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
{
if (!LogOptions.GenerateLog)
{ {
return; return;
} }
if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 )
{ {
DWORD PAddr; uint32_t PAddr;
if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr)) if (!g_TransVaddr->TranslateVaddr(VAddr,(DWORD &)PAddr))
{ {
if (LogOptions.LogUnknown) if (g_LogOptions.LogUnknown)
{ {
LogMessage("%08X: Writing 0x%08X to %08X",PC, Value, VAddr ); LogMessage("%08X: Writing 0x%08X to %08X",PC, Value, VAddr );
} }
@ -538,7 +514,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
} }
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024)
{ {
if (!LogOptions.LogRDRamRegisters) if (!g_LogOptions.LogRDRamRegisters)
{ {
return; return;
} }
@ -563,7 +539,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C) if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C)
{ {
if (!LogOptions.LogSPRegisters) if (!g_LogOptions.LogSPRegisters)
{ {
return; return;
} }
@ -581,7 +557,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
} }
if ( VAddr == 0xA4080000) if ( VAddr == 0xA4080000)
{ {
if (!LogOptions.LogSPRegisters) if (!g_LogOptions.LogSPRegisters)
{ {
return; return;
} }
@ -590,7 +566,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
if ( VAddr >= 0xA4100000 && VAddr <= 0xA410001C) if ( VAddr >= 0xA4100000 && VAddr <= 0xA410001C)
{ {
if (!LogOptions.LogDPCRegisters) if (!g_LogOptions.LogDPCRegisters)
{ {
return; return;
} }
@ -609,7 +585,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
if ( VAddr >= 0xA4200000 && VAddr <= 0xA420000C) if ( VAddr >= 0xA4200000 && VAddr <= 0xA420000C)
{ {
if (!LogOptions.LogDPSRegisters) if (!g_LogOptions.LogDPSRegisters)
{ {
return; return;
} }
@ -624,7 +600,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
if ( VAddr >= 0xA4300000 && VAddr <= 0xA430000C) if ( VAddr >= 0xA4300000 && VAddr <= 0xA430000C)
{ {
if (!LogOptions.LogMIPSInterface) if (!g_LogOptions.LogMIPSInterface)
{ {
return; return;
} }
@ -638,7 +614,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
} }
if ( VAddr >= 0xA4400000 && VAddr <= 0xA4400034) if ( VAddr >= 0xA4400000 && VAddr <= 0xA4400034)
{ {
if (!LogOptions.LogVideoInterface) if (!g_LogOptions.LogVideoInterface)
{ {
return; return;
} }
@ -663,7 +639,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
if ( VAddr >= 0xA4500000 && VAddr <= 0xA4500014) if ( VAddr >= 0xA4500000 && VAddr <= 0xA4500014)
{ {
if (!LogOptions.LogAudioInterface) if (!g_LogOptions.LogAudioInterface)
{ {
return; return;
} }
@ -680,7 +656,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
if ( VAddr >= 0xA4600000 && VAddr <= 0xA4600030) if ( VAddr >= 0xA4600000 && VAddr <= 0xA4600030)
{ {
if (!LogOptions.LogPerInterface) if (!g_LogOptions.LogPerInterface)
{ {
return; return;
} }
@ -703,7 +679,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
} }
if ( VAddr >= 0xA4700000 && VAddr <= 0xA470001C) if ( VAddr >= 0xA4700000 && VAddr <= 0xA470001C)
{ {
if (!LogOptions.LogRDRAMInterface) if (!g_LogOptions.LogRDRAMInterface)
{ {
return; return;
} }
@ -721,7 +697,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
} }
if ( VAddr == 0xA4800000) if ( VAddr == 0xA4800000)
{ {
if (!LogOptions.LogSerialInterface) if (!g_LogOptions.LogSerialInterface)
{ {
return; return;
} }
@ -729,11 +705,11 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
} }
if ( VAddr == 0xA4800004) if ( VAddr == 0xA4800004)
{ {
if (LogOptions.LogPRDMAOperations) if (g_LogOptions.LogPRDMAOperations)
{ {
LogMessage("%08X: A DMA transfer from the PIF ram has occured",PC ); LogMessage("%08X: A DMA transfer from the PIF ram has occured",PC );
} }
if (!LogOptions.LogSerialInterface) if (!g_LogOptions.LogSerialInterface)
{ {
return; return;
} }
@ -741,11 +717,11 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
} }
if ( VAddr == 0xA4800010) if ( VAddr == 0xA4800010)
{ {
if (LogOptions.LogPRDMAOperations) if (g_LogOptions.LogPRDMAOperations)
{ {
LogMessage("%08X: A DMA transfer to the PIF ram has occured",PC ); LogMessage("%08X: A DMA transfer to the PIF ram has occured",PC );
} }
if (!LogOptions.LogSerialInterface) if (!g_LogOptions.LogSerialInterface)
{ {
return; return;
} }
@ -753,7 +729,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
} }
if ( VAddr == 0xA4800018) if ( VAddr == 0xA4800018)
{ {
if (!LogOptions.LogSerialInterface) if (!g_LogOptions.LogSerialInterface)
{ {
return; return;
} }
@ -762,14 +738,14 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC )
{ {
if (!LogOptions.LogPRDirectMemStores) if (!g_LogOptions.LogPRDirectMemStores)
{ {
return; return;
} }
LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X",PC,Value, VAddr - 0xBFC007C0); LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X",PC,Value, VAddr - 0xBFC007C0);
return; return;
} }
if (!LogOptions.LogUnknown) if (!g_LogOptions.LogUnknown)
{ {
return; return;
} }
@ -889,14 +865,38 @@ void SaveLogOptions (void)
RegCloseKey(hKeyResults); RegCloseKey(hKeyResults);
} }
void LogMessage (const char * Message, ...)
{
DWORD dwWritten;
char Msg[400];
va_list ap;
if (!g_Settings->LoadBool(Debugger_Enabled))
{
return;
}
if (g_hLogFile == NULL)
{
return;
}
va_start( ap, Message );
vsprintf( Msg, Message, ap );
va_end( ap );
strcat(Msg,"\r\n");
WriteFile( g_hLogFile,Msg,strlen(Msg),&dwWritten,NULL );
}
void StartLog (void) void StartLog (void)
{ {
if (!LogOptions.GenerateLog) if (!g_LogOptions.GenerateLog)
{ {
StopLog(); StopLog();
return; return;
} }
if (hLogFile) if (g_hLogFile)
{ {
return; return;
} }
@ -905,16 +905,15 @@ void StartLog (void)
LogFile.AppendDirectory("Logs"); LogFile.AppendDirectory("Logs");
LogFile.SetNameExtension("cpudebug.log"); LogFile.SetNameExtension("cpudebug.log");
hLogFile = CreateFile(LogFile,GENERIC_WRITE, FILE_SHARE_READ,NULL,CREATE_ALWAYS, g_hLogFile = CreateFile(LogFile,GENERIC_WRITE, FILE_SHARE_READ,NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); SetFilePointer(g_hLogFile,0,NULL,FILE_BEGIN);
SetFilePointer(hLogFile,0,NULL,FILE_BEGIN);
} }
void StopLog (void) void StopLog (void)
{ {
if (hLogFile) if (g_hLogFile)
{ {
CloseHandle(hLogFile); CloseHandle(g_hLogFile);
} }
hLogFile = NULL; g_hLogFile = NULL;
} }

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 Log_LW ( DWORD PC, DWORD VAddr );
void __cdecl LogMessage ( char * Message, ... );
void Log_SW ( DWORD PC, DWORD VAddr, DWORD Value );
void StartLog ( void ); void StartLog ( void );
void StopLog ( void ); void StopLog ( void );
void LoadLogOptions ( LOG_OPTIONS * LogOptions, bool AlwaysFill );
#ifdef __cplusplus void Log_LW ( uint32_t PC, uint32_t VAddr );
} void Log_SW ( uint32_t PC, uint32_t VAddr, uint32_t Value );
#endif void LogMessage ( const char * Message, ... );

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>