[Projet64] Move logging class and clean up code
This commit is contained in:
parent
786be5b062
commit
4ac266bd94
|
@ -2,7 +2,7 @@
|
|||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<PropertyGroup Label="Configuration">
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
|
||||
<ImportGroup Label="PropertySheets">
|
||||
|
|
|
@ -12,15 +12,15 @@
|
|||
|
||||
#include <prsht.h>
|
||||
|
||||
void LoadLogSetting (HKEY hKey,char * String, BOOL * Value);
|
||||
void LoadLogSetting (HKEY hKey,char * String, bool * Value);
|
||||
void SaveLogOptions (void);
|
||||
|
||||
LRESULT CALLBACK LogGeneralProc ( HWND, UINT, WPARAM, LPARAM );
|
||||
LRESULT CALLBACK LogPifProc ( HWND, UINT, WPARAM, LPARAM );
|
||||
LRESULT CALLBACK LogRegProc ( HWND, UINT, WPARAM, LPARAM );
|
||||
|
||||
LOG_OPTIONS LogOptions,TempOptions;
|
||||
HANDLE hLogFile = NULL;
|
||||
static HANDLE g_hLogFile = NULL;
|
||||
LOG_OPTIONS g_LogOptions, TempOptions;
|
||||
|
||||
void EnterLogOptions(HWND hwndOwner)
|
||||
{
|
||||
|
@ -71,13 +71,13 @@ void EnterLogOptions(HWND hwndOwner)
|
|||
g_Notify -> BreakPoint(__FILEW__, __LINE__);
|
||||
#endif
|
||||
SaveLogOptions();
|
||||
LoadLogOptions(&LogOptions, FALSE);
|
||||
LoadLogOptions(&g_LogOptions, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill)
|
||||
void LoadLogOptions (LOG_OPTIONS * LogOptions, bool AlwaysFill)
|
||||
{
|
||||
long lResult;
|
||||
int32_t lResult;
|
||||
HKEY hKeyResults = 0;
|
||||
char String[200];
|
||||
|
||||
|
@ -147,15 +147,15 @@ void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill)
|
|||
LogOptions->LogUnknown = FALSE;
|
||||
}
|
||||
|
||||
void LoadLogSetting (HKEY hKey,char * String, BOOL * Value)
|
||||
void LoadLogSetting (HKEY hKey,char * String, bool * Value)
|
||||
{
|
||||
DWORD Type, dwResult, Bytes = 4;
|
||||
long lResult;
|
||||
int32_t lResult;
|
||||
|
||||
lResult = RegQueryValueEx(hKey,String,0,&Type,(LPBYTE)(&dwResult),&Bytes);
|
||||
if (Type == REG_DWORD && lResult == ERROR_SUCCESS)
|
||||
{
|
||||
*Value = (BOOL)dwResult;
|
||||
*Value = dwResult != 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -194,19 +194,19 @@ LRESULT CALLBACK LogGeneralProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM
|
|||
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;
|
||||
}
|
||||
|
||||
if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 )
|
||||
{
|
||||
DWORD PAddr;
|
||||
if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr))
|
||||
uint32_t PAddr;
|
||||
if (!g_TransVaddr->TranslateVaddr(VAddr,(DWORD &)PAddr))
|
||||
{
|
||||
if (LogOptions.LogUnknown)
|
||||
if (g_LogOptions.LogUnknown)
|
||||
{
|
||||
LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr);
|
||||
}
|
||||
|
@ -215,18 +215,18 @@ void Log_LW (DWORD PC, DWORD VAddr)
|
|||
VAddr = PAddr + 0xA0000000;
|
||||
}
|
||||
|
||||
DWORD Value;
|
||||
uint32_t Value;
|
||||
if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024)
|
||||
{
|
||||
if (!LogOptions.LogRDRamRegisters)
|
||||
if (!g_LogOptions.LogRDRamRegisters)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_MMU->LW_VAddr(VAddr,Value);
|
||||
g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
|
||||
|
||||
switch (VAddr)
|
||||
{
|
||||
|
@ -249,11 +249,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
|
|||
}
|
||||
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C )
|
||||
{
|
||||
if (!LogOptions.LogSPRegisters)
|
||||
if (!g_LogOptions.LogSPRegisters)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_MMU->LW_VAddr(VAddr,Value);
|
||||
g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
|
||||
|
||||
switch (VAddr)
|
||||
{
|
||||
|
@ -270,21 +270,21 @@ void Log_LW (DWORD PC, DWORD VAddr)
|
|||
}
|
||||
if ( VAddr == 0xA4080000)
|
||||
{
|
||||
if (!LogOptions.LogSPRegisters)
|
||||
if (!g_LogOptions.LogSPRegisters)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_MMU->LW_VAddr(VAddr,Value);
|
||||
g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
|
||||
LogMessage("%08X: read from SP_PC (%08X)",PC, Value);
|
||||
return;
|
||||
}
|
||||
if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C)
|
||||
{
|
||||
if (!LogOptions.LogDPCRegisters)
|
||||
if (!g_LogOptions.LogDPCRegisters)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_MMU->LW_VAddr(VAddr,Value);
|
||||
g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
|
||||
|
||||
switch (VAddr)
|
||||
{
|
||||
|
@ -300,11 +300,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
|
|||
}
|
||||
if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C)
|
||||
{
|
||||
if (!LogOptions.LogMIPSInterface)
|
||||
if (!g_LogOptions.LogMIPSInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_MMU->LW_VAddr(VAddr,Value);
|
||||
g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
|
||||
|
||||
switch (VAddr)
|
||||
{
|
||||
|
@ -316,11 +316,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
|
|||
}
|
||||
if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034)
|
||||
{
|
||||
if (!LogOptions.LogVideoInterface)
|
||||
if (!g_LogOptions.LogVideoInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_MMU->LW_VAddr(VAddr,Value);
|
||||
g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
|
||||
|
||||
switch (VAddr)
|
||||
{
|
||||
|
@ -342,11 +342,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
|
|||
}
|
||||
if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014)
|
||||
{
|
||||
if (!LogOptions.LogAudioInterface)
|
||||
if (!g_LogOptions.LogAudioInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_MMU->LW_VAddr(VAddr,Value);
|
||||
g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
|
||||
|
||||
switch (VAddr)
|
||||
{
|
||||
|
@ -360,11 +360,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
|
|||
}
|
||||
if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030)
|
||||
{
|
||||
if (!LogOptions.LogPerInterface)
|
||||
if (!g_LogOptions.LogPerInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_MMU->LW_VAddr(VAddr,Value);
|
||||
g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
|
||||
|
||||
switch (VAddr)
|
||||
{
|
||||
|
@ -385,11 +385,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
|
|||
}
|
||||
if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C)
|
||||
{
|
||||
if (!LogOptions.LogRDRAMInterface)
|
||||
if (!g_LogOptions.LogRDRAMInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_MMU->LW_VAddr(VAddr,Value);
|
||||
g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
|
||||
|
||||
switch (VAddr)
|
||||
{
|
||||
|
@ -405,41 +405,41 @@ void Log_LW (DWORD PC, DWORD VAddr)
|
|||
}
|
||||
if ( VAddr == 0xA4800000)
|
||||
{
|
||||
if (!LogOptions.LogSerialInterface)
|
||||
if (!g_LogOptions.LogSerialInterface)
|
||||
{
|
||||
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);
|
||||
return;
|
||||
}
|
||||
if ( VAddr == 0xA4800004)
|
||||
{
|
||||
if (!LogOptions.LogSerialInterface)
|
||||
if (!g_LogOptions.LogSerialInterface)
|
||||
{
|
||||
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);
|
||||
return;
|
||||
}
|
||||
if ( VAddr == 0xA4800010)
|
||||
{
|
||||
if (!LogOptions.LogSerialInterface)
|
||||
if (!g_LogOptions.LogSerialInterface)
|
||||
{
|
||||
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);
|
||||
return;
|
||||
}
|
||||
if ( VAddr == 0xA4800018)
|
||||
{
|
||||
if (!LogOptions.LogSerialInterface)
|
||||
if (!g_LogOptions.LogSerialInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_MMU->LW_VAddr(VAddr,Value);
|
||||
g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
|
||||
LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value);
|
||||
return;
|
||||
}
|
||||
|
@ -449,11 +449,11 @@ void Log_LW (DWORD PC, DWORD VAddr)
|
|||
}
|
||||
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC )
|
||||
{
|
||||
if (!LogOptions.LogPRDirectMemLoads)
|
||||
if (!g_LogOptions.LogPRDirectMemLoads)
|
||||
{
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -463,12 +463,12 @@ void Log_LW (DWORD PC, DWORD VAddr)
|
|||
}
|
||||
if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040)
|
||||
{
|
||||
if (!LogOptions.LogRomHeader)
|
||||
if (!g_LogOptions.LogRomHeader)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_MMU->LW_VAddr(VAddr,Value);
|
||||
g_MMU->LW_VAddr(VAddr,(DWORD &)Value);
|
||||
switch (VAddr)
|
||||
{
|
||||
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;
|
||||
}
|
||||
if (!LogOptions.LogUnknown)
|
||||
if (!g_LogOptions.LogUnknown)
|
||||
{
|
||||
return;
|
||||
}
|
||||
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;
|
||||
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)
|
||||
if (!g_LogOptions.GenerateLog)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 )
|
||||
{
|
||||
DWORD PAddr;
|
||||
if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr))
|
||||
uint32_t 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 );
|
||||
}
|
||||
|
@ -538,7 +514,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
}
|
||||
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024)
|
||||
{
|
||||
if (!LogOptions.LogRDRamRegisters)
|
||||
if (!g_LogOptions.LogRDRamRegisters)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -563,7 +539,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
|
||||
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C)
|
||||
{
|
||||
if (!LogOptions.LogSPRegisters)
|
||||
if (!g_LogOptions.LogSPRegisters)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -581,7 +557,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
}
|
||||
if ( VAddr == 0xA4080000)
|
||||
{
|
||||
if (!LogOptions.LogSPRegisters)
|
||||
if (!g_LogOptions.LogSPRegisters)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -590,7 +566,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
|
||||
if ( VAddr >= 0xA4100000 && VAddr <= 0xA410001C)
|
||||
{
|
||||
if (!LogOptions.LogDPCRegisters)
|
||||
if (!g_LogOptions.LogDPCRegisters)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -609,7 +585,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
|
||||
if ( VAddr >= 0xA4200000 && VAddr <= 0xA420000C)
|
||||
{
|
||||
if (!LogOptions.LogDPSRegisters)
|
||||
if (!g_LogOptions.LogDPSRegisters)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -624,7 +600,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
|
||||
if ( VAddr >= 0xA4300000 && VAddr <= 0xA430000C)
|
||||
{
|
||||
if (!LogOptions.LogMIPSInterface)
|
||||
if (!g_LogOptions.LogMIPSInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -638,7 +614,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
}
|
||||
if ( VAddr >= 0xA4400000 && VAddr <= 0xA4400034)
|
||||
{
|
||||
if (!LogOptions.LogVideoInterface)
|
||||
if (!g_LogOptions.LogVideoInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -663,7 +639,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
|
||||
if ( VAddr >= 0xA4500000 && VAddr <= 0xA4500014)
|
||||
{
|
||||
if (!LogOptions.LogAudioInterface)
|
||||
if (!g_LogOptions.LogAudioInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -680,7 +656,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
|
||||
if ( VAddr >= 0xA4600000 && VAddr <= 0xA4600030)
|
||||
{
|
||||
if (!LogOptions.LogPerInterface)
|
||||
if (!g_LogOptions.LogPerInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -703,7 +679,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
}
|
||||
if ( VAddr >= 0xA4700000 && VAddr <= 0xA470001C)
|
||||
{
|
||||
if (!LogOptions.LogRDRAMInterface)
|
||||
if (!g_LogOptions.LogRDRAMInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -721,7 +697,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
}
|
||||
if ( VAddr == 0xA4800000)
|
||||
{
|
||||
if (!LogOptions.LogSerialInterface)
|
||||
if (!g_LogOptions.LogSerialInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -729,11 +705,11 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
}
|
||||
if ( VAddr == 0xA4800004)
|
||||
{
|
||||
if (LogOptions.LogPRDMAOperations)
|
||||
if (g_LogOptions.LogPRDMAOperations)
|
||||
{
|
||||
LogMessage("%08X: A DMA transfer from the PIF ram has occured",PC );
|
||||
}
|
||||
if (!LogOptions.LogSerialInterface)
|
||||
if (!g_LogOptions.LogSerialInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -741,11 +717,11 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
}
|
||||
if ( VAddr == 0xA4800010)
|
||||
{
|
||||
if (LogOptions.LogPRDMAOperations)
|
||||
if (g_LogOptions.LogPRDMAOperations)
|
||||
{
|
||||
LogMessage("%08X: A DMA transfer to the PIF ram has occured",PC );
|
||||
}
|
||||
if (!LogOptions.LogSerialInterface)
|
||||
if (!g_LogOptions.LogSerialInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -753,7 +729,7 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
}
|
||||
if ( VAddr == 0xA4800018)
|
||||
{
|
||||
if (!LogOptions.LogSerialInterface)
|
||||
if (!g_LogOptions.LogSerialInterface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -762,14 +738,14 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
|
|||
|
||||
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC )
|
||||
{
|
||||
if (!LogOptions.LogPRDirectMemStores)
|
||||
if (!g_LogOptions.LogPRDirectMemStores)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X",PC,Value, VAddr - 0xBFC007C0);
|
||||
return;
|
||||
}
|
||||
if (!LogOptions.LogUnknown)
|
||||
if (!g_LogOptions.LogUnknown)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -889,14 +865,38 @@ void SaveLogOptions (void)
|
|||
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)
|
||||
{
|
||||
if (!LogOptions.GenerateLog)
|
||||
if (!g_LogOptions.GenerateLog)
|
||||
{
|
||||
StopLog();
|
||||
return;
|
||||
}
|
||||
if (hLogFile)
|
||||
if (g_hLogFile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -905,16 +905,15 @@ void StartLog (void)
|
|||
LogFile.AppendDirectory("Logs");
|
||||
LogFile.SetNameExtension("cpudebug.log");
|
||||
|
||||
hLogFile = CreateFile(LogFile,GENERIC_WRITE, FILE_SHARE_READ,NULL,CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||
SetFilePointer(hLogFile,0,NULL,FILE_BEGIN);
|
||||
g_hLogFile = CreateFile(LogFile,GENERIC_WRITE, FILE_SHARE_READ,NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||
SetFilePointer(g_hLogFile,0,NULL,FILE_BEGIN);
|
||||
}
|
||||
|
||||
void StopLog (void)
|
||||
{
|
||||
if (hLogFile)
|
||||
if (g_hLogFile)
|
||||
{
|
||||
CloseHandle(hLogFile);
|
||||
CloseHandle(g_hLogFile);
|
||||
}
|
||||
hLogFile = NULL;
|
||||
g_hLogFile = NULL;
|
||||
}
|
||||
|
|
|
@ -9,55 +9,48 @@
|
|||
* *
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BOOL GenerateLog;
|
||||
bool GenerateLog;
|
||||
|
||||
/* Registers Log */
|
||||
BOOL LogRDRamRegisters;
|
||||
BOOL LogSPRegisters;
|
||||
BOOL LogDPCRegisters;
|
||||
BOOL LogDPSRegisters;
|
||||
BOOL LogMIPSInterface;
|
||||
BOOL LogVideoInterface;
|
||||
BOOL LogAudioInterface;
|
||||
BOOL LogPerInterface;
|
||||
BOOL LogRDRAMInterface;
|
||||
BOOL LogSerialInterface;
|
||||
bool LogRDRamRegisters;
|
||||
bool LogSPRegisters;
|
||||
bool LogDPCRegisters;
|
||||
bool LogDPSRegisters;
|
||||
bool LogMIPSInterface;
|
||||
bool LogVideoInterface;
|
||||
bool LogAudioInterface;
|
||||
bool LogPerInterface;
|
||||
bool LogRDRAMInterface;
|
||||
bool LogSerialInterface;
|
||||
|
||||
/* Pif Ram Log */
|
||||
BOOL LogPRDMAOperations;
|
||||
BOOL LogPRDirectMemLoads;
|
||||
BOOL LogPRDMAMemLoads;
|
||||
BOOL LogPRDirectMemStores;
|
||||
BOOL LogPRDMAMemStores;
|
||||
BOOL LogControllerPak;
|
||||
bool LogPRDMAOperations;
|
||||
bool LogPRDirectMemLoads;
|
||||
bool LogPRDMAMemLoads;
|
||||
bool LogPRDirectMemStores;
|
||||
bool LogPRDMAMemStores;
|
||||
bool LogControllerPak;
|
||||
|
||||
/* Special Log */
|
||||
BOOL LogCP0changes;
|
||||
BOOL LogCP0reads;
|
||||
BOOL LogTLB;
|
||||
BOOL LogExceptions;
|
||||
BOOL NoInterrupts;
|
||||
BOOL LogCache;
|
||||
BOOL LogRomHeader;
|
||||
BOOL LogUnknown;
|
||||
bool LogCP0changes;
|
||||
bool LogCP0reads;
|
||||
bool LogTLB;
|
||||
bool LogExceptions;
|
||||
bool NoInterrupts;
|
||||
bool LogCache;
|
||||
bool LogRomHeader;
|
||||
bool LogUnknown;
|
||||
} LOG_OPTIONS;
|
||||
|
||||
extern LOG_OPTIONS LogOptions;
|
||||
extern LOG_OPTIONS g_LogOptions;
|
||||
|
||||
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 StopLog ( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
void LoadLogOptions ( LOG_OPTIONS * LogOptions, bool AlwaysFill );
|
||||
void Log_LW ( uint32_t PC, uint32_t VAddr );
|
||||
void Log_SW ( uint32_t PC, uint32_t VAddr, uint32_t Value );
|
||||
void LogMessage ( const char * Message, ... );
|
||||
|
|
|
@ -951,7 +951,7 @@ void R4300iOp32::LW()
|
|||
ADDRESS_ERROR_EXCEPTION(Address, true);
|
||||
}
|
||||
|
||||
if (LogOptions.GenerateLog)
|
||||
if (g_LogOptions.GenerateLog)
|
||||
{
|
||||
Log_LW((*_PROGRAM_COUNTER),Address);
|
||||
}
|
||||
|
@ -1323,7 +1323,7 @@ void R4300iOp32::REGIMM_BGEZAL()
|
|||
}
|
||||
/************************** COP0 functions **************************/
|
||||
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]);
|
||||
}
|
||||
|
@ -1337,7 +1337,7 @@ void R4300iOp32::COP0_MF() {
|
|||
|
||||
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]);
|
||||
if (m_Opcode.rd == 11) //Compare
|
||||
|
|
|
@ -1115,7 +1115,7 @@ void R4300iOp::LW()
|
|||
ADDRESS_ERROR_EXCEPTION(Address, true);
|
||||
}
|
||||
|
||||
if (LogOptions.GenerateLog)
|
||||
if (g_LogOptions.GenerateLog)
|
||||
{
|
||||
Log_LW((*_PROGRAM_COUNTER),Address);
|
||||
}
|
||||
|
@ -1295,7 +1295,7 @@ void R4300iOp::SW()
|
|||
{
|
||||
ADDRESS_ERROR_EXCEPTION(Address, false);
|
||||
}
|
||||
if (LogOptions.GenerateLog)
|
||||
if (g_LogOptions.GenerateLog)
|
||||
{
|
||||
Log_SW((*_PROGRAM_COUNTER),Address,_GPR[m_Opcode.rt].UW[0]);
|
||||
}
|
||||
|
@ -1445,7 +1445,7 @@ void R4300iOp::SWR()
|
|||
|
||||
void R4300iOp::CACHE()
|
||||
{
|
||||
if (!LogOptions.LogCache)
|
||||
if (!g_LogOptions.LogCache)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -2094,7 +2094,7 @@ void R4300iOp::REGIMM_BGEZAL()
|
|||
/************************** COP0 functions **************************/
|
||||
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]);
|
||||
}
|
||||
|
@ -2108,7 +2108,7 @@ void R4300iOp::COP0_MF()
|
|||
|
||||
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]);
|
||||
if (m_Opcode.rd == 11) //Compare
|
||||
|
|
|
@ -308,7 +308,7 @@ void CPifRam::SI_DMA_READ()
|
|||
}
|
||||
}
|
||||
|
||||
if (LogOptions.LogPRDMAMemStores)
|
||||
if (g_LogOptions.LogPRDMAMemStores)
|
||||
{
|
||||
int count;
|
||||
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;
|
||||
char HexData[100], AsciiData[100], Addon[20];
|
||||
|
@ -505,7 +505,7 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
|
|||
}
|
||||
break;
|
||||
case 0x02: //read from controller pack
|
||||
if (LogOptions.LogControllerPak)
|
||||
if (g_LogOptions.LogControllerPak)
|
||||
{
|
||||
LogControllerPakData("Read: Before Gettting Results");
|
||||
}
|
||||
|
@ -541,13 +541,13 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
|
|||
{
|
||||
Command[1] |= 0x80;
|
||||
}
|
||||
if (LogOptions.LogControllerPak)
|
||||
if (g_LogOptions.LogControllerPak)
|
||||
{
|
||||
LogControllerPakData("Read: After Gettting Results");
|
||||
}
|
||||
break;
|
||||
case 0x03: //write controller pak
|
||||
if (LogOptions.LogControllerPak)
|
||||
if (g_LogOptions.LogControllerPak)
|
||||
{
|
||||
LogControllerPakData("Write: Before Processing");
|
||||
}
|
||||
|
@ -581,7 +581,7 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
|
|||
{
|
||||
Command[1] |= 0x80;
|
||||
}
|
||||
if (LogOptions.LogControllerPak)
|
||||
if (g_LogOptions.LogControllerPak)
|
||||
{
|
||||
LogControllerPakData("Write: After Processing");
|
||||
}
|
||||
|
|
|
@ -463,7 +463,7 @@ bool CRegisters::DoIntrException(bool DelaySlot)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -296,8 +296,8 @@ void CN64System::StartEmulation2 ( bool NewThread )
|
|||
|
||||
if (bHaveDebugger())
|
||||
{
|
||||
LogOptions.GenerateLog = g_Settings->LoadDword(Debugger_GenerateDebugLog);
|
||||
LoadLogOptions(&LogOptions, FALSE);
|
||||
g_LogOptions.GenerateLog = g_Settings->LoadBool(Debugger_GenerateDebugLog);
|
||||
LoadLogOptions(&g_LogOptions, FALSE);
|
||||
StartLog();
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Logging.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="Multilanguage\LanguageSelector.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 Timing.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\Recompiler\Code Block.cpp" />
|
||||
<ClCompile Include="N64 System\Recompiler\Code Section.cpp" />
|
||||
|
@ -178,6 +178,7 @@
|
|||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Logging.h" />
|
||||
<ClInclude Include="Multilanguage.h" />
|
||||
<ClInclude Include="Multilanguage\LanguageSelector.h" />
|
||||
<ClInclude Include="N64 System.h" />
|
||||
|
@ -267,7 +268,6 @@
|
|||
<ClInclude Include="N64 System\Mips\System Timing.h" />
|
||||
<ClInclude Include="N64 System\Mips\TLB Class.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\Debugger\Debugger - Memory Dump.h" />
|
||||
<ClInclude Include="N64 System\Debugger\Debugger - Memory Search.h" />
|
||||
|
|
|
@ -330,9 +330,6 @@
|
|||
<ClCompile Include="N64 System\Mips\TLB class.cpp">
|
||||
<Filter>Source Files\N64 System Source\Mips Source</Filter>
|
||||
</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">
|
||||
<Filter>Source Files\N64 System Source\C Core Source</Filter>
|
||||
</ClCompile>
|
||||
|
@ -420,6 +417,9 @@
|
|||
<ClCompile Include="User Interface\Cheat Class UI.cpp">
|
||||
<Filter>Source Files\User Interface Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Logging.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="User Interface\Bitmaps\AboutScreenBottom.bmp">
|
||||
|
@ -722,9 +722,6 @@
|
|||
<ClInclude Include="N64 System\Mips\TranslateVaddr.h">
|
||||
<Filter>Header Files\N64 System Headers\Mips Headers</Filter>
|
||||
</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">
|
||||
<Filter>Header Files\N64 System Headers\C Core Headers</Filter>
|
||||
</ClInclude>
|
||||
|
@ -848,5 +845,8 @@
|
|||
<ClInclude Include="User Interface\Cheat Class UI.h">
|
||||
<Filter>Header Files\User Interface Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Logging.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue