diff --git a/PropertySheets/Platform.props b/PropertySheets/Platform.props index 3487ef34c..b905993fe 100644 --- a/PropertySheets/Platform.props +++ b/PropertySheets/Platform.props @@ -2,7 +2,7 @@ - v140_xp + v120_xp diff --git a/Source/Project64/Logging.cpp b/Source/Project64/Logging.cpp index 3247ccca5..1f4180560 100644 --- a/Source/Project64/Logging.cpp +++ b/Source/Project64/Logging.cpp @@ -12,15 +12,15 @@ #include -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,96 +71,96 @@ 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; - HKEY hKeyResults = 0; - char String[200]; + int32_t lResult; + HKEY hKeyResults = 0; + char String[200]; - sprintf(String,"Software\\N64 Emulation\\%s\\Logging",g_Settings->LoadStringVal(Setting_ApplicationName).c_str()); - lResult = RegOpenKeyEx( HKEY_CURRENT_USER,String,0,KEY_ALL_ACCESS, - &hKeyResults); - - if (lResult == ERROR_SUCCESS) - { - //LoadLogSetting(hKeyResults,"Generate Log File",&LogOptions->GenerateLog); - if (LogOptions->GenerateLog || AlwaysFill) - { - LoadLogSetting(hKeyResults,"Log RDRAM",&LogOptions->LogRDRamRegisters); - LoadLogSetting(hKeyResults,"Log SP",&LogOptions->LogSPRegisters); - LoadLogSetting(hKeyResults,"Log DP Command",&LogOptions->LogDPCRegisters); - LoadLogSetting(hKeyResults,"Log DP Span",&LogOptions->LogDPSRegisters); - LoadLogSetting(hKeyResults,"Log MIPS Interface (MI)",&LogOptions->LogMIPSInterface); - LoadLogSetting(hKeyResults,"Log Video Interface (VI)",&LogOptions->LogVideoInterface); - LoadLogSetting(hKeyResults,"Log Audio Interface (AI)",&LogOptions->LogAudioInterface); - LoadLogSetting(hKeyResults,"Log Peripheral Interface (PI)",&LogOptions->LogPerInterface); - LoadLogSetting(hKeyResults,"Log RDRAM Interface (RI)",&LogOptions->LogRDRAMInterface); - LoadLogSetting(hKeyResults,"Log Serial Interface (SI)",&LogOptions->LogSerialInterface); - LoadLogSetting(hKeyResults,"Log PifRam DMA Operations",&LogOptions->LogPRDMAOperations); - LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Loads",&LogOptions->LogPRDirectMemLoads); - LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Loads",&LogOptions->LogPRDMAMemLoads); - LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Stores",&LogOptions->LogPRDirectMemStores); - LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Stores",&LogOptions->LogPRDMAMemStores); - LoadLogSetting(hKeyResults,"Log Controller Pak",&LogOptions->LogControllerPak); - LoadLogSetting(hKeyResults,"Log CP0 changes",&LogOptions->LogCP0changes); - LoadLogSetting(hKeyResults,"Log CP0 reads",&LogOptions->LogCP0reads); - LoadLogSetting(hKeyResults,"Log Exceptions",&LogOptions->LogExceptions); - LoadLogSetting(hKeyResults,"No Interrupts",&LogOptions->NoInterrupts); - LoadLogSetting(hKeyResults,"Log TLB",&LogOptions->LogTLB); - LoadLogSetting(hKeyResults,"Log Cache Operations",&LogOptions->LogCache); - LoadLogSetting(hKeyResults,"Log Rom Header",&LogOptions->LogRomHeader); - LoadLogSetting(hKeyResults,"Log Unknown access",&LogOptions->LogUnknown); - return; - } - } + sprintf(String,"Software\\N64 Emulation\\%s\\Logging",g_Settings->LoadStringVal(Setting_ApplicationName).c_str()); + lResult = RegOpenKeyEx( HKEY_CURRENT_USER,String,0,KEY_ALL_ACCESS, + &hKeyResults); - LogOptions->GenerateLog = FALSE; - LogOptions->LogRDRamRegisters = FALSE; - LogOptions->LogSPRegisters = FALSE; - LogOptions->LogDPCRegisters = FALSE; - LogOptions->LogDPSRegisters = FALSE; - LogOptions->LogMIPSInterface = FALSE; - LogOptions->LogVideoInterface = FALSE; - LogOptions->LogAudioInterface = FALSE; - LogOptions->LogPerInterface = FALSE; - LogOptions->LogRDRAMInterface = FALSE; - LogOptions->LogSerialInterface = FALSE; - - LogOptions->LogPRDMAOperations = FALSE; - LogOptions->LogPRDirectMemLoads = FALSE; - LogOptions->LogPRDMAMemLoads = FALSE; - LogOptions->LogPRDirectMemStores = FALSE; - LogOptions->LogPRDMAMemStores = FALSE; - LogOptions->LogControllerPak = FALSE; - - LogOptions->LogCP0changes = FALSE; - LogOptions->LogCP0reads = FALSE; - LogOptions->LogCache = FALSE; - LogOptions->LogExceptions = FALSE; - LogOptions->NoInterrupts = FALSE; - LogOptions->LogTLB = FALSE; - LogOptions->LogRomHeader = FALSE; - LogOptions->LogUnknown = FALSE; + if (lResult == ERROR_SUCCESS) + { + //LoadLogSetting(hKeyResults,"Generate Log File",&LogOptions->GenerateLog); + if (LogOptions->GenerateLog || AlwaysFill) + { + LoadLogSetting(hKeyResults,"Log RDRAM",&LogOptions->LogRDRamRegisters); + LoadLogSetting(hKeyResults,"Log SP",&LogOptions->LogSPRegisters); + LoadLogSetting(hKeyResults,"Log DP Command",&LogOptions->LogDPCRegisters); + LoadLogSetting(hKeyResults,"Log DP Span",&LogOptions->LogDPSRegisters); + LoadLogSetting(hKeyResults,"Log MIPS Interface (MI)",&LogOptions->LogMIPSInterface); + LoadLogSetting(hKeyResults,"Log Video Interface (VI)",&LogOptions->LogVideoInterface); + LoadLogSetting(hKeyResults,"Log Audio Interface (AI)",&LogOptions->LogAudioInterface); + LoadLogSetting(hKeyResults,"Log Peripheral Interface (PI)",&LogOptions->LogPerInterface); + LoadLogSetting(hKeyResults,"Log RDRAM Interface (RI)",&LogOptions->LogRDRAMInterface); + LoadLogSetting(hKeyResults,"Log Serial Interface (SI)",&LogOptions->LogSerialInterface); + LoadLogSetting(hKeyResults,"Log PifRam DMA Operations",&LogOptions->LogPRDMAOperations); + LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Loads",&LogOptions->LogPRDirectMemLoads); + LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Loads",&LogOptions->LogPRDMAMemLoads); + LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Stores",&LogOptions->LogPRDirectMemStores); + LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Stores",&LogOptions->LogPRDMAMemStores); + LoadLogSetting(hKeyResults,"Log Controller Pak",&LogOptions->LogControllerPak); + LoadLogSetting(hKeyResults,"Log CP0 changes",&LogOptions->LogCP0changes); + LoadLogSetting(hKeyResults,"Log CP0 reads",&LogOptions->LogCP0reads); + LoadLogSetting(hKeyResults,"Log Exceptions",&LogOptions->LogExceptions); + LoadLogSetting(hKeyResults,"No Interrupts",&LogOptions->NoInterrupts); + LoadLogSetting(hKeyResults,"Log TLB",&LogOptions->LogTLB); + LoadLogSetting(hKeyResults,"Log Cache Operations",&LogOptions->LogCache); + LoadLogSetting(hKeyResults,"Log Rom Header",&LogOptions->LogRomHeader); + LoadLogSetting(hKeyResults,"Log Unknown access",&LogOptions->LogUnknown); + return; + } + } + + LogOptions->GenerateLog = FALSE; + LogOptions->LogRDRamRegisters = FALSE; + LogOptions->LogSPRegisters = FALSE; + LogOptions->LogDPCRegisters = FALSE; + LogOptions->LogDPSRegisters = FALSE; + LogOptions->LogMIPSInterface = FALSE; + LogOptions->LogVideoInterface = FALSE; + LogOptions->LogAudioInterface = FALSE; + LogOptions->LogPerInterface = FALSE; + LogOptions->LogRDRAMInterface = FALSE; + LogOptions->LogSerialInterface = FALSE; + + LogOptions->LogPRDMAOperations = FALSE; + LogOptions->LogPRDirectMemLoads = FALSE; + LogOptions->LogPRDMAMemLoads = FALSE; + LogOptions->LogPRDirectMemStores = FALSE; + LogOptions->LogPRDMAMemStores = FALSE; + LogOptions->LogControllerPak = FALSE; + + LogOptions->LogCP0changes = FALSE; + LogOptions->LogCP0reads = FALSE; + LogOptions->LogCache = FALSE; + LogOptions->LogExceptions = FALSE; + LogOptions->NoInterrupts = FALSE; + LogOptions->LogTLB = FALSE; + LogOptions->LogRomHeader = 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; - long lResult; + DWORD Type, dwResult, Bytes = 4; + int32_t lResult; - lResult = RegQueryValueEx(hKey,String,0,&Type,(LPBYTE)(&dwResult),&Bytes); - if (Type == REG_DWORD && lResult == ERROR_SUCCESS) - { - *Value = (BOOL)dwResult; - } - else - { - *Value = FALSE; - } + lResult = RegQueryValueEx(hKey,String,0,&Type,(LPBYTE)(&dwResult),&Bytes); + if (Type == REG_DWORD && lResult == ERROR_SUCCESS) + { + *Value = dwResult != 0; + } + else + { + *Value = FALSE; + } } LRESULT CALLBACK LogGeneralProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) @@ -194,586 +194,562 @@ 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) - { - return; - } + if (!g_LogOptions.GenerateLog) + { + return; + } - if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) - { - DWORD PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr)) - { - if (LogOptions.LogUnknown) - { - LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr); - } - return; - } - VAddr = PAddr + 0xA0000000; - } - - DWORD Value; - if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) - { - return; - } - if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) - { - if (!LogOptions.LogRDRamRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) + { + uint32_t PAddr; + if (!g_TransVaddr->TranslateVaddr(VAddr,(DWORD &)PAddr)) + { + if (g_LogOptions.LogUnknown) + { + LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr); + } + return; + } + VAddr = PAddr + 0xA0000000; + } - switch (VAddr) - { - case 0xA3F00000: LogMessage("%08X: read from RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG (%08X)",PC, Value); return; - case 0xA3F00004: LogMessage("%08X: read from RDRAM_DEVICE_ID_REG (%08X)",PC, Value); return; - case 0xA3F00008: LogMessage("%08X: read from RDRAM_DELAY_REG (%08X)",PC, Value); return; - case 0xA3F0000C: LogMessage("%08X: read from RDRAM_MODE_REG (%08X)",PC, Value); return; - case 0xA3F00010: LogMessage("%08X: read from RDRAM_REF_INTERVAL_REG (%08X)",PC, Value); return; - case 0xA3F00014: LogMessage("%08X: read from RDRAM_REF_ROW_REG (%08X)",PC, Value); return; - case 0xA3F00018: LogMessage("%08X: read from RDRAM_RAS_INTERVAL_REG (%08X)",PC, Value); return; - case 0xA3F0001C: LogMessage("%08X: read from RDRAM_MIN_INTERVAL_REG (%08X)",PC, Value); return; - case 0xA3F00020: LogMessage("%08X: read from RDRAM_ADDR_SELECT_REG (%08X)",PC, Value); return; - case 0xA3F00024: LogMessage("%08X: read from RDRAM_DEVICE_MANUF_REG (%08X)",PC, Value); return; - } - } + uint32_t Value; + if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) + { + return; + } + if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) + { + if (!g_LogOptions.LogRDRamRegisters) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) - { - return; - } - if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C ) - { - if (!LogOptions.LogSPRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + switch (VAddr) + { + case 0xA3F00000: LogMessage("%08X: read from RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG (%08X)",PC, Value); return; + case 0xA3F00004: LogMessage("%08X: read from RDRAM_DEVICE_ID_REG (%08X)",PC, Value); return; + case 0xA3F00008: LogMessage("%08X: read from RDRAM_DELAY_REG (%08X)",PC, Value); return; + case 0xA3F0000C: LogMessage("%08X: read from RDRAM_MODE_REG (%08X)",PC, Value); return; + case 0xA3F00010: LogMessage("%08X: read from RDRAM_REF_INTERVAL_REG (%08X)",PC, Value); return; + case 0xA3F00014: LogMessage("%08X: read from RDRAM_REF_ROW_REG (%08X)",PC, Value); return; + case 0xA3F00018: LogMessage("%08X: read from RDRAM_RAS_INTERVAL_REG (%08X)",PC, Value); return; + case 0xA3F0001C: LogMessage("%08X: read from RDRAM_MIN_INTERVAL_REG (%08X)",PC, Value); return; + case 0xA3F00020: LogMessage("%08X: read from RDRAM_ADDR_SELECT_REG (%08X)",PC, Value); return; + case 0xA3F00024: LogMessage("%08X: read from RDRAM_DEVICE_MANUF_REG (%08X)",PC, Value); return; + } + } - switch (VAddr) - { - case 0xA4040000: LogMessage("%08X: read from SP_MEM_ADDR_REG (%08X)",PC, Value); break; - case 0xA4040004: LogMessage("%08X: read from SP_DRAM_ADDR_REG (%08X)",PC, Value); break; - case 0xA4040008: LogMessage("%08X: read from SP_RD_LEN_REG (%08X)",PC, Value); break; - case 0xA404000C: LogMessage("%08X: read from SP_WR_LEN_REG (%08X)",PC, Value); break; - case 0xA4040010: LogMessage("%08X: read from SP_STATUS_REG (%08X)",PC, Value); break; - case 0xA4040014: LogMessage("%08X: read from SP_DMA_FULL_REG (%08X)",PC, Value); break; - case 0xA4040018: LogMessage("%08X: read from SP_DMA_BUSY_REG (%08X)",PC, Value); break; - case 0xA404001C: LogMessage("%08X: read from SP_SEMAPHORE_REG (%08X)",PC, Value); break; - } - return; - } - if ( VAddr == 0xA4080000) - { - if (!LogOptions.LogSPRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SP_PC (%08X)",PC, Value); - return; - } - if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) - { - if (!LogOptions.LogDPCRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) + { + return; + } + if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C ) + { + if (!g_LogOptions.LogSPRegisters) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - switch (VAddr) - { - case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)",PC, Value); return; - case 0xA4100004: LogMessage("%08X: read from DPC_END_REG (%08X)",PC, Value); return; - case 0xA4100008: LogMessage("%08X: read from DPC_CURRENT_REG (%08X)",PC, Value); return; - case 0xA410000C: LogMessage("%08X: read from DPC_STATUS_REG (%08X)",PC, Value); return; - case 0xA4100010: LogMessage("%08X: read from DPC_CLOCK_REG (%08X)",PC, Value); return; - case 0xA4100014: LogMessage("%08X: read from DPC_BUFBUSY_REG (%08X)",PC, Value); return; - case 0xA4100018: LogMessage("%08X: read from DPC_PIPEBUSY_REG (%08X)",PC, Value); return; - case 0xA410001C: LogMessage("%08X: read from DPC_TMEM_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) - { - if (!LogOptions.LogMIPSInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + switch (VAddr) + { + case 0xA4040000: LogMessage("%08X: read from SP_MEM_ADDR_REG (%08X)",PC, Value); break; + case 0xA4040004: LogMessage("%08X: read from SP_DRAM_ADDR_REG (%08X)",PC, Value); break; + case 0xA4040008: LogMessage("%08X: read from SP_RD_LEN_REG (%08X)",PC, Value); break; + case 0xA404000C: LogMessage("%08X: read from SP_WR_LEN_REG (%08X)",PC, Value); break; + case 0xA4040010: LogMessage("%08X: read from SP_STATUS_REG (%08X)",PC, Value); break; + case 0xA4040014: LogMessage("%08X: read from SP_DMA_FULL_REG (%08X)",PC, Value); break; + case 0xA4040018: LogMessage("%08X: read from SP_DMA_BUSY_REG (%08X)",PC, Value); break; + case 0xA404001C: LogMessage("%08X: read from SP_SEMAPHORE_REG (%08X)",PC, Value); break; + } + return; + } + if ( VAddr == 0xA4080000) + { + if (!g_LogOptions.LogSPRegisters) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + LogMessage("%08X: read from SP_PC (%08X)",PC, Value); + return; + } + if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) + { + if (!g_LogOptions.LogDPCRegisters) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - switch (VAddr) - { - case 0xA4300000: LogMessage("%08X: read from MI_INIT_MODE_REG/MI_MODE_REG (%08X)",PC, Value); return; - case 0xA4300004: LogMessage("%08X: read from MI_VERSION_REG/MI_NOOP_REG (%08X)",PC, Value); return; - case 0xA4300008: LogMessage("%08X: read from MI_INTR_REG (%08X)",PC, Value); return; - case 0xA430000C: LogMessage("%08X: read from MI_INTR_MASK_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) - { - if (!LogOptions.LogVideoInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + switch (VAddr) + { + case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)",PC, Value); return; + case 0xA4100004: LogMessage("%08X: read from DPC_END_REG (%08X)",PC, Value); return; + case 0xA4100008: LogMessage("%08X: read from DPC_CURRENT_REG (%08X)",PC, Value); return; + case 0xA410000C: LogMessage("%08X: read from DPC_STATUS_REG (%08X)",PC, Value); return; + case 0xA4100010: LogMessage("%08X: read from DPC_CLOCK_REG (%08X)",PC, Value); return; + case 0xA4100014: LogMessage("%08X: read from DPC_BUFBUSY_REG (%08X)",PC, Value); return; + case 0xA4100018: LogMessage("%08X: read from DPC_PIPEBUSY_REG (%08X)",PC, Value); return; + case 0xA410001C: LogMessage("%08X: read from DPC_TMEM_REG (%08X)",PC, Value); return; + } + } + if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) + { + if (!g_LogOptions.LogMIPSInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - switch (VAddr) - { - case 0xA4400000: LogMessage("%08X: read from VI_STATUS_REG/VI_CONTROL_REG (%08X)",PC, Value); return; - case 0xA4400004: LogMessage("%08X: read from VI_ORIGIN_REG/VI_DRAM_ADDR_REG (%08X)",PC, Value); return; - case 0xA4400008: LogMessage("%08X: read from VI_WIDTH_REG/VI_H_WIDTH_REG (%08X)",PC, Value); return; - case 0xA440000C: LogMessage("%08X: read from VI_INTR_REG/VI_V_INTR_REG (%08X)",PC, Value); return; - case 0xA4400010: LogMessage("%08X: read from VI_CURRENT_REG/VI_V_CURRENT_LINE_REG (%08X)",PC, Value); return; - case 0xA4400014: LogMessage("%08X: read from VI_BURST_REG/VI_TIMING_REG (%08X)",PC, Value); return; - case 0xA4400018: LogMessage("%08X: read from VI_V_SYNC_REG (%08X)",PC, Value); return; - case 0xA440001C: LogMessage("%08X: read from VI_H_SYNC_REG (%08X)",PC, Value); return; - case 0xA4400020: LogMessage("%08X: read from VI_LEAP_REG/VI_H_SYNC_LEAP_REG (%08X)",PC, Value); return; - case 0xA4400024: LogMessage("%08X: read from VI_H_START_REG/VI_H_VIDEO_REG (%08X)",PC, Value); return; - case 0xA4400028: LogMessage("%08X: read from VI_V_START_REG/VI_V_VIDEO_REG (%08X)",PC, Value); return; - case 0xA440002C: LogMessage("%08X: read from VI_V_BURST_REG (%08X)",PC, Value); return; - case 0xA4400030: LogMessage("%08X: read from VI_X_SCALE_REG (%08X)",PC, Value); return; - case 0xA4400034: LogMessage("%08X: read from VI_Y_SCALE_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) - { - if (!LogOptions.LogAudioInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + switch (VAddr) + { + case 0xA4300000: LogMessage("%08X: read from MI_INIT_MODE_REG/MI_MODE_REG (%08X)",PC, Value); return; + case 0xA4300004: LogMessage("%08X: read from MI_VERSION_REG/MI_NOOP_REG (%08X)",PC, Value); return; + case 0xA4300008: LogMessage("%08X: read from MI_INTR_REG (%08X)",PC, Value); return; + case 0xA430000C: LogMessage("%08X: read from MI_INTR_MASK_REG (%08X)",PC, Value); return; + } + } + if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) + { + if (!g_LogOptions.LogVideoInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - switch (VAddr) - { - case 0xA4500000: LogMessage("%08X: read from AI_DRAM_ADDR_REG (%08X)",PC, Value); return; - case 0xA4500004: LogMessage("%08X: read from AI_LEN_REG (%08X)",PC, Value); return; - case 0xA4500008: LogMessage("%08X: read from AI_CONTROL_REG (%08X)",PC, Value); return; - case 0xA450000C: LogMessage("%08X: read from AI_STATUS_REG (%08X)",PC, Value); return; - case 0xA4500010: LogMessage("%08X: read from AI_DACRATE_REG (%08X)",PC, Value); return; - case 0xA4500014: LogMessage("%08X: read from AI_BITRATE_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) - { - if (!LogOptions.LogPerInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + switch (VAddr) + { + case 0xA4400000: LogMessage("%08X: read from VI_STATUS_REG/VI_CONTROL_REG (%08X)",PC, Value); return; + case 0xA4400004: LogMessage("%08X: read from VI_ORIGIN_REG/VI_DRAM_ADDR_REG (%08X)",PC, Value); return; + case 0xA4400008: LogMessage("%08X: read from VI_WIDTH_REG/VI_H_WIDTH_REG (%08X)",PC, Value); return; + case 0xA440000C: LogMessage("%08X: read from VI_INTR_REG/VI_V_INTR_REG (%08X)",PC, Value); return; + case 0xA4400010: LogMessage("%08X: read from VI_CURRENT_REG/VI_V_CURRENT_LINE_REG (%08X)",PC, Value); return; + case 0xA4400014: LogMessage("%08X: read from VI_BURST_REG/VI_TIMING_REG (%08X)",PC, Value); return; + case 0xA4400018: LogMessage("%08X: read from VI_V_SYNC_REG (%08X)",PC, Value); return; + case 0xA440001C: LogMessage("%08X: read from VI_H_SYNC_REG (%08X)",PC, Value); return; + case 0xA4400020: LogMessage("%08X: read from VI_LEAP_REG/VI_H_SYNC_LEAP_REG (%08X)",PC, Value); return; + case 0xA4400024: LogMessage("%08X: read from VI_H_START_REG/VI_H_VIDEO_REG (%08X)",PC, Value); return; + case 0xA4400028: LogMessage("%08X: read from VI_V_START_REG/VI_V_VIDEO_REG (%08X)",PC, Value); return; + case 0xA440002C: LogMessage("%08X: read from VI_V_BURST_REG (%08X)",PC, Value); return; + case 0xA4400030: LogMessage("%08X: read from VI_X_SCALE_REG (%08X)",PC, Value); return; + case 0xA4400034: LogMessage("%08X: read from VI_Y_SCALE_REG (%08X)",PC, Value); return; + } + } + if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) + { + if (!g_LogOptions.LogAudioInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - switch (VAddr) - { - case 0xA4600000: LogMessage("%08X: read from PI_DRAM_ADDR_REG (%08X)",PC, Value); return; - case 0xA4600004: LogMessage("%08X: read from PI_CART_ADDR_REG (%08X)",PC, Value); return; - case 0xA4600008: LogMessage("%08X: read from PI_RD_LEN_REG (%08X)",PC, Value); return; - case 0xA460000C: LogMessage("%08X: read from PI_WR_LEN_REG (%08X)",PC, Value); return; - case 0xA4600010: LogMessage("%08X: read from PI_STATUS_REG (%08X)",PC, Value); return; - case 0xA4600014: LogMessage("%08X: read from PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG (%08X)",PC, Value); return; - case 0xA4600018: LogMessage("%08X: read from PI_BSD_DOM1_PWD_REG (%08X)",PC, Value); return; - case 0xA460001C: LogMessage("%08X: read from PI_BSD_DOM1_PGS_REG (%08X)",PC, Value); return; - case 0xA4600020: LogMessage("%08X: read from PI_BSD_DOM1_RLS_REG (%08X)",PC, Value); return; - case 0xA4600024: LogMessage("%08X: read from PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG (%08X)",PC, Value); return; - case 0xA4600028: LogMessage("%08X: read from PI_BSD_DOM2_PWD_REG (%08X)",PC, Value); return; - case 0xA460002C: LogMessage("%08X: read from PI_BSD_DOM2_PGS_REG (%08X)",PC, Value); return; - case 0xA4600030: LogMessage("%08X: read from PI_BSD_DOM2_RLS_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) - { - if (!LogOptions.LogRDRAMInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + switch (VAddr) + { + case 0xA4500000: LogMessage("%08X: read from AI_DRAM_ADDR_REG (%08X)",PC, Value); return; + case 0xA4500004: LogMessage("%08X: read from AI_LEN_REG (%08X)",PC, Value); return; + case 0xA4500008: LogMessage("%08X: read from AI_CONTROL_REG (%08X)",PC, Value); return; + case 0xA450000C: LogMessage("%08X: read from AI_STATUS_REG (%08X)",PC, Value); return; + case 0xA4500010: LogMessage("%08X: read from AI_DACRATE_REG (%08X)",PC, Value); return; + case 0xA4500014: LogMessage("%08X: read from AI_BITRATE_REG (%08X)",PC, Value); return; + } + } + if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) + { + if (!g_LogOptions.LogPerInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - switch (VAddr) - { - case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)",PC, Value); return; - case 0xA4700004: LogMessage("%08X: read from RI_CONFIG_REG (%08X)",PC, Value); return; - case 0xA4700008: LogMessage("%08X: read from RI_CURRENT_LOAD_REG (%08X)",PC, Value); return; - case 0xA470000C: LogMessage("%08X: read from RI_SELECT_REG (%08X)",PC, Value); return; - case 0xA4700010: LogMessage("%08X: read from RI_REFRESH_REG/RI_COUNT_REG (%08X)",PC, Value); return; - case 0xA4700014: LogMessage("%08X: read from RI_LATENCY_REG (%08X)",PC, Value); return; - case 0xA4700018: LogMessage("%08X: read from RI_RERROR_REG (%08X)",PC, Value); return; - case 0xA470001C: LogMessage("%08X: read from RI_WERROR_REG (%08X)",PC, Value); return; - } - } - if ( VAddr == 0xA4800000) - { - if (!LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value); - return; - } - if ( VAddr == 0xA4800004) - { - if (!LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value); - return; - } - if ( VAddr == 0xA4800010) - { - if (!LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value); - return; - } - if ( VAddr == 0xA4800018) - { - if (!LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value); - return; - } - if ( VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0 ) - { - return; - } - if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) - { - if (!LogOptions.LogPRDirectMemLoads) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value); - return; - } - if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize())) - { - return; - } - if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040) - { - if (!LogOptions.LogRomHeader) - { - return; - } + switch (VAddr) + { + case 0xA4600000: LogMessage("%08X: read from PI_DRAM_ADDR_REG (%08X)",PC, Value); return; + case 0xA4600004: LogMessage("%08X: read from PI_CART_ADDR_REG (%08X)",PC, Value); return; + case 0xA4600008: LogMessage("%08X: read from PI_RD_LEN_REG (%08X)",PC, Value); return; + case 0xA460000C: LogMessage("%08X: read from PI_WR_LEN_REG (%08X)",PC, Value); return; + case 0xA4600010: LogMessage("%08X: read from PI_STATUS_REG (%08X)",PC, Value); return; + case 0xA4600014: LogMessage("%08X: read from PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG (%08X)",PC, Value); return; + case 0xA4600018: LogMessage("%08X: read from PI_BSD_DOM1_PWD_REG (%08X)",PC, Value); return; + case 0xA460001C: LogMessage("%08X: read from PI_BSD_DOM1_PGS_REG (%08X)",PC, Value); return; + case 0xA4600020: LogMessage("%08X: read from PI_BSD_DOM1_RLS_REG (%08X)",PC, Value); return; + case 0xA4600024: LogMessage("%08X: read from PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG (%08X)",PC, Value); return; + case 0xA4600028: LogMessage("%08X: read from PI_BSD_DOM2_PWD_REG (%08X)",PC, Value); return; + case 0xA460002C: LogMessage("%08X: read from PI_BSD_DOM2_PGS_REG (%08X)",PC, Value); return; + case 0xA4600030: LogMessage("%08X: read from PI_BSD_DOM2_RLS_REG (%08X)",PC, Value); return; + } + } + if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) + { + if (!g_LogOptions.LogRDRAMInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - g_MMU->LW_VAddr(VAddr,Value); - switch (VAddr) - { - case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break; - case 0xB0000008: LogMessage("%08X: read from Rom Boot address offset (%08X)",PC, Value); break; - case 0xB000000C: LogMessage("%08X: read from Rom Release offset (%08X)",PC, Value); break; - case 0xB0000010: LogMessage("%08X: read from Rom CRC1 (%08X)",PC, Value); break; - case 0xB0000014: LogMessage("%08X: read from Rom CRC2 (%08X)",PC, Value); break; - default: LogMessage("%08X: read from Rom header 0x%X (%08X)",PC, VAddr & 0xFF,Value); break; - } - return; - } - if (!LogOptions.LogUnknown) - { - return; - } - LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr); + switch (VAddr) + { + case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)",PC, Value); return; + case 0xA4700004: LogMessage("%08X: read from RI_CONFIG_REG (%08X)",PC, Value); return; + case 0xA4700008: LogMessage("%08X: read from RI_CURRENT_LOAD_REG (%08X)",PC, Value); return; + case 0xA470000C: LogMessage("%08X: read from RI_SELECT_REG (%08X)",PC, Value); return; + case 0xA4700010: LogMessage("%08X: read from RI_REFRESH_REG/RI_COUNT_REG (%08X)",PC, Value); return; + case 0xA4700014: LogMessage("%08X: read from RI_LATENCY_REG (%08X)",PC, Value); return; + case 0xA4700018: LogMessage("%08X: read from RI_RERROR_REG (%08X)",PC, Value); return; + case 0xA470001C: LogMessage("%08X: read from RI_WERROR_REG (%08X)",PC, Value); return; + } + } + if ( VAddr == 0xA4800000) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value); + return; + } + if ( VAddr == 0xA4800004) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value); + return; + } + if ( VAddr == 0xA4800010) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value); + return; + } + if ( VAddr == 0xA4800018) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value); + return; + } + if ( VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0 ) + { + return; + } + if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) + { + if (!g_LogOptions.LogPRDirectMemLoads) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value); + return; + } + if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize())) + { + return; + } + if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040) + { + if (!g_LogOptions.LogRomHeader) + { + return; + } + + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + switch (VAddr) + { + case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break; + case 0xB0000008: LogMessage("%08X: read from Rom Boot address offset (%08X)",PC, Value); break; + case 0xB000000C: LogMessage("%08X: read from Rom Release offset (%08X)",PC, Value); break; + case 0xB0000010: LogMessage("%08X: read from Rom CRC1 (%08X)",PC, Value); break; + case 0xB0000014: LogMessage("%08X: read from Rom CRC2 (%08X)",PC, Value); break; + default: LogMessage("%08X: read from Rom header 0x%X (%08X)",PC, VAddr & 0xFF,Value); break; + } + return; + } + 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_LogOptions.GenerateLog) + { + return; + } - if (!g_Settings->LoadBool(Debugger_Enabled)) - { - return; - } - if (hLogFile == NULL) - { - return; - } + if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) + { + uint32_t PAddr; + if (!g_TransVaddr->TranslateVaddr(VAddr,(DWORD &)PAddr)) + { + if (g_LogOptions.LogUnknown) + { + LogMessage("%08X: Writing 0x%08X to %08X",PC, Value, VAddr ); + } + return; + } + VAddr = PAddr + 0xA0000000; + } - 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; - } - - if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) - { - DWORD PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr)) - { - if (LogOptions.LogUnknown) - { - LogMessage("%08X: Writing 0x%08X to %08X",PC, Value, VAddr ); - } - return; - } - VAddr = PAddr + 0xA0000000; - } - - if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) - { - return; - } - if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) - { - if (!LogOptions.LogRDRamRegisters) - { - return; - } - switch (VAddr) - { - case 0xA3F00000: LogMessage("%08X: Writing 0x%08X to RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG",PC, Value ); return; - case 0xA3F00004: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_ID_REG",PC, Value ); return; - case 0xA3F00008: LogMessage("%08X: Writing 0x%08X to RDRAM_DELAY_REG",PC, Value ); return; - case 0xA3F0000C: LogMessage("%08X: Writing 0x%08X to RDRAM_MODE_REG",PC, Value ); return; - case 0xA3F00010: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_INTERVAL_REG",PC, Value ); return; - case 0xA3F00014: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_ROW_REG",PC, Value ); return; - case 0xA3F00018: LogMessage("%08X: Writing 0x%08X to RDRAM_RAS_INTERVAL_REG",PC, Value ); return; - case 0xA3F0001C: LogMessage("%08X: Writing 0x%08X to RDRAM_MIN_INTERVAL_REG",PC, Value ); return; - case 0xA3F00020: LogMessage("%08X: Writing 0x%08X to RDRAM_ADDR_SELECT_REG",PC, Value ); return; - case 0xA3F00024: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_MANUF_REG",PC, Value ); return; - } - } - if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) - { - return; - } + if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) + { + return; + } + if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) + { + if (!g_LogOptions.LogRDRamRegisters) + { + return; + } + switch (VAddr) + { + case 0xA3F00000: LogMessage("%08X: Writing 0x%08X to RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG",PC, Value ); return; + case 0xA3F00004: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_ID_REG",PC, Value ); return; + case 0xA3F00008: LogMessage("%08X: Writing 0x%08X to RDRAM_DELAY_REG",PC, Value ); return; + case 0xA3F0000C: LogMessage("%08X: Writing 0x%08X to RDRAM_MODE_REG",PC, Value ); return; + case 0xA3F00010: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_INTERVAL_REG",PC, Value ); return; + case 0xA3F00014: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_ROW_REG",PC, Value ); return; + case 0xA3F00018: LogMessage("%08X: Writing 0x%08X to RDRAM_RAS_INTERVAL_REG",PC, Value ); return; + case 0xA3F0001C: LogMessage("%08X: Writing 0x%08X to RDRAM_MIN_INTERVAL_REG",PC, Value ); return; + case 0xA3F00020: LogMessage("%08X: Writing 0x%08X to RDRAM_ADDR_SELECT_REG",PC, Value ); return; + case 0xA3F00024: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_MANUF_REG",PC, Value ); return; + } + } + if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) + { + return; + } if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C) - { - if (!LogOptions.LogSPRegisters) - { - return; - } - switch (VAddr) - { - case 0xA4040000: LogMessage("%08X: Writing 0x%08X to SP_MEM_ADDR_REG",PC, Value ); return; - case 0xA4040004: LogMessage("%08X: Writing 0x%08X to SP_DRAM_ADDR_REG",PC, Value ); return; - case 0xA4040008: LogMessage("%08X: Writing 0x%08X to SP_RD_LEN_REG",PC, Value ); return; - case 0xA404000C: LogMessage("%08X: Writing 0x%08X to SP_WR_LEN_REG",PC, Value ); return; - case 0xA4040010: LogMessage("%08X: Writing 0x%08X to SP_STATUS_REG",PC, Value ); return; - case 0xA4040014: LogMessage("%08X: Writing 0x%08X to SP_DMA_FULL_REG",PC, Value ); return; - case 0xA4040018: LogMessage("%08X: Writing 0x%08X to SP_DMA_BUSY_REG",PC, Value ); return; - case 0xA404001C: LogMessage("%08X: Writing 0x%08X to SP_SEMAPHORE_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogSPRegisters) + { + return; + } + switch (VAddr) + { + case 0xA4040000: LogMessage("%08X: Writing 0x%08X to SP_MEM_ADDR_REG",PC, Value ); return; + case 0xA4040004: LogMessage("%08X: Writing 0x%08X to SP_DRAM_ADDR_REG",PC, Value ); return; + case 0xA4040008: LogMessage("%08X: Writing 0x%08X to SP_RD_LEN_REG",PC, Value ); return; + case 0xA404000C: LogMessage("%08X: Writing 0x%08X to SP_WR_LEN_REG",PC, Value ); return; + case 0xA4040010: LogMessage("%08X: Writing 0x%08X to SP_STATUS_REG",PC, Value ); return; + case 0xA4040014: LogMessage("%08X: Writing 0x%08X to SP_DMA_FULL_REG",PC, Value ); return; + case 0xA4040018: LogMessage("%08X: Writing 0x%08X to SP_DMA_BUSY_REG",PC, Value ); return; + case 0xA404001C: LogMessage("%08X: Writing 0x%08X to SP_SEMAPHORE_REG",PC, Value ); return; + } + } if ( VAddr == 0xA4080000) - { - if (!LogOptions.LogSPRegisters) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SP_PC",PC, Value ); return; - } - + { + if (!g_LogOptions.LogSPRegisters) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SP_PC",PC, Value ); return; + } + if ( VAddr >= 0xA4100000 && VAddr <= 0xA410001C) - { - if (!LogOptions.LogDPCRegisters) - { - return; - } - switch (VAddr) - { - case 0xA4100000: LogMessage("%08X: Writing 0x%08X to DPC_START_REG",PC, Value ); return; - case 0xA4100004: LogMessage("%08X: Writing 0x%08X to DPC_END_REG",PC, Value ); return; - case 0xA4100008: LogMessage("%08X: Writing 0x%08X to DPC_CURRENT_REG",PC, Value ); return; - case 0xA410000C: LogMessage("%08X: Writing 0x%08X to DPC_STATUS_REG",PC, Value ); return; - case 0xA4100010: LogMessage("%08X: Writing 0x%08X to DPC_CLOCK_REG",PC, Value ); return; - case 0xA4100014: LogMessage("%08X: Writing 0x%08X to DPC_BUFBUSY_REG",PC, Value ); return; - case 0xA4100018: LogMessage("%08X: Writing 0x%08X to DPC_PIPEBUSY_REG",PC, Value ); return; - case 0xA410001C: LogMessage("%08X: Writing 0x%08X to DPC_TMEM_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogDPCRegisters) + { + return; + } + switch (VAddr) + { + case 0xA4100000: LogMessage("%08X: Writing 0x%08X to DPC_START_REG",PC, Value ); return; + case 0xA4100004: LogMessage("%08X: Writing 0x%08X to DPC_END_REG",PC, Value ); return; + case 0xA4100008: LogMessage("%08X: Writing 0x%08X to DPC_CURRENT_REG",PC, Value ); return; + case 0xA410000C: LogMessage("%08X: Writing 0x%08X to DPC_STATUS_REG",PC, Value ); return; + case 0xA4100010: LogMessage("%08X: Writing 0x%08X to DPC_CLOCK_REG",PC, Value ); return; + case 0xA4100014: LogMessage("%08X: Writing 0x%08X to DPC_BUFBUSY_REG",PC, Value ); return; + case 0xA4100018: LogMessage("%08X: Writing 0x%08X to DPC_PIPEBUSY_REG",PC, Value ); return; + case 0xA410001C: LogMessage("%08X: Writing 0x%08X to DPC_TMEM_REG",PC, Value ); return; + } + } if ( VAddr >= 0xA4200000 && VAddr <= 0xA420000C) - { - if (!LogOptions.LogDPSRegisters) - { - return; - } - switch (VAddr) - { - case 0xA4200000: LogMessage("%08X: Writing 0x%08X to DPS_TBIST_REG",PC, Value ); return; - case 0xA4200004: LogMessage("%08X: Writing 0x%08X to DPS_TEST_MODE_REG",PC, Value ); return; - case 0xA4200008: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_ADDR_REG",PC, Value ); return; - case 0xA420000C: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_DATA_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogDPSRegisters) + { + return; + } + switch (VAddr) + { + case 0xA4200000: LogMessage("%08X: Writing 0x%08X to DPS_TBIST_REG",PC, Value ); return; + case 0xA4200004: LogMessage("%08X: Writing 0x%08X to DPS_TEST_MODE_REG",PC, Value ); return; + case 0xA4200008: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_ADDR_REG",PC, Value ); return; + case 0xA420000C: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_DATA_REG",PC, Value ); return; + } + } if ( VAddr >= 0xA4300000 && VAddr <= 0xA430000C) - { - if (!LogOptions.LogMIPSInterface) - { - return; - } - switch (VAddr) - { - case 0xA4300000: LogMessage("%08X: Writing 0x%08X to MI_INIT_MODE_REG/MI_MODE_REG",PC, Value ); return; - case 0xA4300004: LogMessage("%08X: Writing 0x%08X to MI_VERSION_REG/MI_NOOP_REG",PC, Value ); return; - case 0xA4300008: LogMessage("%08X: Writing 0x%08X to MI_INTR_REG",PC, Value ); return; - case 0xA430000C: LogMessage("%08X: Writing 0x%08X to MI_INTR_MASK_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogMIPSInterface) + { + return; + } + switch (VAddr) + { + case 0xA4300000: LogMessage("%08X: Writing 0x%08X to MI_INIT_MODE_REG/MI_MODE_REG",PC, Value ); return; + case 0xA4300004: LogMessage("%08X: Writing 0x%08X to MI_VERSION_REG/MI_NOOP_REG",PC, Value ); return; + case 0xA4300008: LogMessage("%08X: Writing 0x%08X to MI_INTR_REG",PC, Value ); return; + case 0xA430000C: LogMessage("%08X: Writing 0x%08X to MI_INTR_MASK_REG",PC, Value ); return; + } + } if ( VAddr >= 0xA4400000 && VAddr <= 0xA4400034) - { - if (!LogOptions.LogVideoInterface) - { - return; - } - switch (VAddr) - { - case 0xA4400000: LogMessage("%08X: Writing 0x%08X to VI_STATUS_REG/VI_CONTROL_REG",PC, Value ); return; - case 0xA4400004: LogMessage("%08X: Writing 0x%08X to VI_ORIGIN_REG/VI_DRAM_ADDR_REG",PC, Value ); return; - case 0xA4400008: LogMessage("%08X: Writing 0x%08X to VI_WIDTH_REG/VI_H_WIDTH_REG",PC, Value ); return; - case 0xA440000C: LogMessage("%08X: Writing 0x%08X to VI_INTR_REG/VI_V_INTR_REG",PC, Value ); return; - case 0xA4400010: LogMessage("%08X: Writing 0x%08X to VI_CURRENT_REG/VI_V_CURRENT_LINE_REG",PC, Value ); return; - case 0xA4400014: LogMessage("%08X: Writing 0x%08X to VI_BURST_REG/VI_TIMING_REG",PC, Value ); return; - case 0xA4400018: LogMessage("%08X: Writing 0x%08X to VI_V_SYNC_REG",PC, Value ); return; - case 0xA440001C: LogMessage("%08X: Writing 0x%08X to VI_H_SYNC_REG",PC, Value ); return; - case 0xA4400020: LogMessage("%08X: Writing 0x%08X to VI_LEAP_REG/VI_H_SYNC_LEAP_REG",PC, Value ); return; - case 0xA4400024: LogMessage("%08X: Writing 0x%08X to VI_H_START_REG/VI_H_VIDEO_REG",PC, Value ); return; - case 0xA4400028: LogMessage("%08X: Writing 0x%08X to VI_V_START_REG/VI_V_VIDEO_REG",PC, Value ); return; - case 0xA440002C: LogMessage("%08X: Writing 0x%08X to VI_V_BURST_REG",PC, Value ); return; - case 0xA4400030: LogMessage("%08X: Writing 0x%08X to VI_X_SCALE_REG",PC, Value ); return; - case 0xA4400034: LogMessage("%08X: Writing 0x%08X to VI_Y_SCALE_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogVideoInterface) + { + return; + } + switch (VAddr) + { + case 0xA4400000: LogMessage("%08X: Writing 0x%08X to VI_STATUS_REG/VI_CONTROL_REG",PC, Value ); return; + case 0xA4400004: LogMessage("%08X: Writing 0x%08X to VI_ORIGIN_REG/VI_DRAM_ADDR_REG",PC, Value ); return; + case 0xA4400008: LogMessage("%08X: Writing 0x%08X to VI_WIDTH_REG/VI_H_WIDTH_REG",PC, Value ); return; + case 0xA440000C: LogMessage("%08X: Writing 0x%08X to VI_INTR_REG/VI_V_INTR_REG",PC, Value ); return; + case 0xA4400010: LogMessage("%08X: Writing 0x%08X to VI_CURRENT_REG/VI_V_CURRENT_LINE_REG",PC, Value ); return; + case 0xA4400014: LogMessage("%08X: Writing 0x%08X to VI_BURST_REG/VI_TIMING_REG",PC, Value ); return; + case 0xA4400018: LogMessage("%08X: Writing 0x%08X to VI_V_SYNC_REG",PC, Value ); return; + case 0xA440001C: LogMessage("%08X: Writing 0x%08X to VI_H_SYNC_REG",PC, Value ); return; + case 0xA4400020: LogMessage("%08X: Writing 0x%08X to VI_LEAP_REG/VI_H_SYNC_LEAP_REG",PC, Value ); return; + case 0xA4400024: LogMessage("%08X: Writing 0x%08X to VI_H_START_REG/VI_H_VIDEO_REG",PC, Value ); return; + case 0xA4400028: LogMessage("%08X: Writing 0x%08X to VI_V_START_REG/VI_V_VIDEO_REG",PC, Value ); return; + case 0xA440002C: LogMessage("%08X: Writing 0x%08X to VI_V_BURST_REG",PC, Value ); return; + case 0xA4400030: LogMessage("%08X: Writing 0x%08X to VI_X_SCALE_REG",PC, Value ); return; + case 0xA4400034: LogMessage("%08X: Writing 0x%08X to VI_Y_SCALE_REG",PC, Value ); return; + } + } if ( VAddr >= 0xA4500000 && VAddr <= 0xA4500014) - { - if (!LogOptions.LogAudioInterface) - { - return; - } - switch (VAddr) - { - case 0xA4500000: LogMessage("%08X: Writing 0x%08X to AI_DRAM_ADDR_REG",PC, Value ); return; - case 0xA4500004: LogMessage("%08X: Writing 0x%08X to AI_LEN_REG",PC, Value ); return; - case 0xA4500008: LogMessage("%08X: Writing 0x%08X to AI_CONTROL_REG",PC, Value ); return; - case 0xA450000C: LogMessage("%08X: Writing 0x%08X to AI_STATUS_REG",PC, Value ); return; - case 0xA4500010: LogMessage("%08X: Writing 0x%08X to AI_DACRATE_REG",PC, Value ); return; - case 0xA4500014: LogMessage("%08X: Writing 0x%08X to AI_BITRATE_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogAudioInterface) + { + return; + } + switch (VAddr) + { + case 0xA4500000: LogMessage("%08X: Writing 0x%08X to AI_DRAM_ADDR_REG",PC, Value ); return; + case 0xA4500004: LogMessage("%08X: Writing 0x%08X to AI_LEN_REG",PC, Value ); return; + case 0xA4500008: LogMessage("%08X: Writing 0x%08X to AI_CONTROL_REG",PC, Value ); return; + case 0xA450000C: LogMessage("%08X: Writing 0x%08X to AI_STATUS_REG",PC, Value ); return; + case 0xA4500010: LogMessage("%08X: Writing 0x%08X to AI_DACRATE_REG",PC, Value ); return; + case 0xA4500014: LogMessage("%08X: Writing 0x%08X to AI_BITRATE_REG",PC, Value ); return; + } + } if ( VAddr >= 0xA4600000 && VAddr <= 0xA4600030) - { - if (!LogOptions.LogPerInterface) - { - return; - } - switch (VAddr) - { - case 0xA4600000: LogMessage("%08X: Writing 0x%08X to PI_DRAM_ADDR_REG",PC, Value ); return; - case 0xA4600004: LogMessage("%08X: Writing 0x%08X to PI_CART_ADDR_REG",PC, Value ); return; - case 0xA4600008: LogMessage("%08X: Writing 0x%08X to PI_RD_LEN_REG",PC, Value ); return; - case 0xA460000C: LogMessage("%08X: Writing 0x%08X to PI_WR_LEN_REG",PC, Value ); return; - case 0xA4600010: LogMessage("%08X: Writing 0x%08X to PI_STATUS_REG",PC, Value ); return; - case 0xA4600014: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG",PC, Value ); return; - case 0xA4600018: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PWD_REG",PC, Value ); return; - case 0xA460001C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PGS_REG",PC, Value ); return; - case 0xA4600020: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_RLS_REG",PC, Value ); return; - case 0xA4600024: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG",PC, Value ); return; - case 0xA4600028: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PWD_REG",PC, Value ); return; - case 0xA460002C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PGS_REG",PC, Value ); return; - case 0xA4600030: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_RLS_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogPerInterface) + { + return; + } + switch (VAddr) + { + case 0xA4600000: LogMessage("%08X: Writing 0x%08X to PI_DRAM_ADDR_REG",PC, Value ); return; + case 0xA4600004: LogMessage("%08X: Writing 0x%08X to PI_CART_ADDR_REG",PC, Value ); return; + case 0xA4600008: LogMessage("%08X: Writing 0x%08X to PI_RD_LEN_REG",PC, Value ); return; + case 0xA460000C: LogMessage("%08X: Writing 0x%08X to PI_WR_LEN_REG",PC, Value ); return; + case 0xA4600010: LogMessage("%08X: Writing 0x%08X to PI_STATUS_REG",PC, Value ); return; + case 0xA4600014: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG",PC, Value ); return; + case 0xA4600018: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PWD_REG",PC, Value ); return; + case 0xA460001C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PGS_REG",PC, Value ); return; + case 0xA4600020: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_RLS_REG",PC, Value ); return; + case 0xA4600024: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG",PC, Value ); return; + case 0xA4600028: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PWD_REG",PC, Value ); return; + case 0xA460002C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PGS_REG",PC, Value ); return; + case 0xA4600030: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_RLS_REG",PC, Value ); return; + } + } if ( VAddr >= 0xA4700000 && VAddr <= 0xA470001C) - { - if (!LogOptions.LogRDRAMInterface) - { - return; - } - switch (VAddr) - { - case 0xA4700000: LogMessage("%08X: Writing 0x%08X to RI_MODE_REG",PC, Value ); return; - case 0xA4700004: LogMessage("%08X: Writing 0x%08X to RI_CONFIG_REG",PC, Value ); return; - case 0xA4700008: LogMessage("%08X: Writing 0x%08X to RI_CURRENT_LOAD_REG",PC, Value ); return; - case 0xA470000C: LogMessage("%08X: Writing 0x%08X to RI_SELECT_REG",PC, Value ); return; - case 0xA4700010: LogMessage("%08X: Writing 0x%08X to RI_REFRESH_REG/RI_COUNT_REG",PC, Value ); return; - case 0xA4700014: LogMessage("%08X: Writing 0x%08X to RI_LATENCY_REG",PC, Value ); return; - case 0xA4700018: LogMessage("%08X: Writing 0x%08X to RI_RERROR_REG",PC, Value ); return; - case 0xA470001C: LogMessage("%08X: Writing 0x%08X to RI_WERROR_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogRDRAMInterface) + { + return; + } + switch (VAddr) + { + case 0xA4700000: LogMessage("%08X: Writing 0x%08X to RI_MODE_REG",PC, Value ); return; + case 0xA4700004: LogMessage("%08X: Writing 0x%08X to RI_CONFIG_REG",PC, Value ); return; + case 0xA4700008: LogMessage("%08X: Writing 0x%08X to RI_CURRENT_LOAD_REG",PC, Value ); return; + case 0xA470000C: LogMessage("%08X: Writing 0x%08X to RI_SELECT_REG",PC, Value ); return; + case 0xA4700010: LogMessage("%08X: Writing 0x%08X to RI_REFRESH_REG/RI_COUNT_REG",PC, Value ); return; + case 0xA4700014: LogMessage("%08X: Writing 0x%08X to RI_LATENCY_REG",PC, Value ); return; + case 0xA4700018: LogMessage("%08X: Writing 0x%08X to RI_RERROR_REG",PC, Value ); return; + case 0xA470001C: LogMessage("%08X: Writing 0x%08X to RI_WERROR_REG",PC, Value ); return; + } + } if ( VAddr == 0xA4800000) - { - if (!LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_DRAM_ADDR_REG",PC, Value ); return; - } + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_DRAM_ADDR_REG",PC, Value ); return; + } if ( VAddr == 0xA4800004) - { - if (LogOptions.LogPRDMAOperations) - { - LogMessage("%08X: A DMA transfer from the PIF ram has occured",PC ); - } - if (!LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_RD64B_REG",PC, Value ); return; - } + { + if (g_LogOptions.LogPRDMAOperations) + { + LogMessage("%08X: A DMA transfer from the PIF ram has occured",PC ); + } + if (!g_LogOptions.LogSerialInterface) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_RD64B_REG",PC, Value ); return; + } if ( VAddr == 0xA4800010) - { - if (LogOptions.LogPRDMAOperations) - { - LogMessage("%08X: A DMA transfer to the PIF ram has occured",PC ); - } - if (!LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_WR64B_REG",PC, Value ); return; - } + { + if (g_LogOptions.LogPRDMAOperations) + { + LogMessage("%08X: A DMA transfer to the PIF ram has occured",PC ); + } + if (!g_LogOptions.LogSerialInterface) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_WR64B_REG",PC, Value ); return; + } if ( VAddr == 0xA4800018) - { - if (!LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_STATUS_REG",PC, Value ); return; - } + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_STATUS_REG",PC, Value ); return; + } - if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) - { - if (!LogOptions.LogPRDirectMemStores) - { - return; - } - LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X",PC,Value, VAddr - 0xBFC007C0); - return; - } - if (!LogOptions.LogUnknown) - { - return; - } - LogMessage("%08X: Writing 0x%08X to %08X ????",PC, Value, VAddr ); + if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) + { + if (!g_LogOptions.LogPRDirectMemStores) + { + return; + } + LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X",PC,Value, VAddr - 0xBFC007C0); + return; + } + if (!g_LogOptions.LogUnknown) + { + return; + } + LogMessage("%08X: Writing 0x%08X to %08X ????",PC, Value, VAddr ); } LRESULT CALLBACK LogPifProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) @@ -889,32 +865,55 @@ void SaveLogOptions (void) RegCloseKey(hKeyResults); } -void StartLog (void) +void LogMessage (const char * Message, ...) { - if (!LogOptions.GenerateLog) - { - StopLog(); - return; - } - if (hLogFile) - { - return; - } + DWORD dwWritten; + char Msg[400]; + va_list ap; - CPath LogFile(CPath::MODULE_DIRECTORY); - 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); + 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 (!g_LogOptions.GenerateLog) + { + StopLog(); + return; + } + if (g_hLogFile) + { + return; + } + + CPath LogFile(CPath::MODULE_DIRECTORY); + LogFile.AppendDirectory("Logs"); + LogFile.SetNameExtension("cpudebug.log"); + + 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) - { - CloseHandle(hLogFile); - } - hLogFile = NULL; + if (g_hLogFile) + { + CloseHandle(g_hLogFile); + } + g_hLogFile = NULL; } diff --git a/Source/Project64/Logging.h b/Source/Project64/Logging.h index 844fcdf04..c36aba4d4 100644 --- a/Source/Project64/Logging.h +++ b/Source/Project64/Logging.h @@ -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; + /* Registers Log */ + 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; + /* Pif Ram Log */ + 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; + /* Special Log */ + 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 StartLog ( void ); +void StopLog ( void ); +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, ... ); diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp index ee5934aac..c29282520 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp @@ -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 diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp index e7cc0d817..c3c6c14e4 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp @@ -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 diff --git a/Source/Project64/N64 System/Mips/Pif Ram.cpp b/Source/Project64/N64 System/Mips/Pif Ram.cpp index abf709b00..b477922ec 100644 --- a/Source/Project64/N64 System/Mips/Pif Ram.cpp +++ b/Source/Project64/N64 System/Mips/Pif Ram.cpp @@ -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"); } diff --git a/Source/Project64/N64 System/Mips/Register Class.cpp b/Source/Project64/N64 System/Mips/Register Class.cpp index f3bc474d5..1cb8fd13f 100644 --- a/Source/Project64/N64 System/Mips/Register Class.cpp +++ b/Source/Project64/N64 System/Mips/Register Class.cpp @@ -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); } diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 944f0008d..1f3d363ae 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -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(); } diff --git a/Source/Project64/Project64.vcxproj b/Source/Project64/Project64.vcxproj index 53f2f7048..c0fc9b536 100644 --- a/Source/Project64/Project64.vcxproj +++ b/Source/Project64/Project64.vcxproj @@ -41,6 +41,7 @@ + @@ -122,7 +123,6 @@ - @@ -178,6 +178,7 @@ + @@ -267,7 +268,6 @@ - diff --git a/Source/Project64/Project64.vcxproj.filters b/Source/Project64/Project64.vcxproj.filters index 2ad467552..e831f9869 100644 --- a/Source/Project64/Project64.vcxproj.filters +++ b/Source/Project64/Project64.vcxproj.filters @@ -330,9 +330,6 @@ Source Files\N64 System Source\Mips Source - - Source Files\N64 System Source\C Core Source - Source Files\N64 System Source\C Core Source @@ -420,6 +417,9 @@ Source Files\User Interface Source + + Source Files + @@ -722,9 +722,6 @@ Header Files\N64 System Headers\Mips Headers - - Header Files\N64 System Headers\C Core Headers - Header Files\N64 System Headers\C Core Headers @@ -848,5 +845,8 @@ Header Files\User Interface Headers + + Header Files + \ No newline at end of file