diff --git a/Source/Project64/N64 System.h b/Source/Project64/N64 System.h index 799d8e6e0..cf8c1c9ee 100644 --- a/Source/Project64/N64 System.h +++ b/Source/Project64/N64 System.h @@ -19,7 +19,10 @@ class CNotification; #include "N64 System/Mips/OpCode.h" #include "N64 System/Mips/OpCode Analysis Class.h" #include "N64 System/Recompiler/X86ops.h" +#include "N64 System/Mips/FlashRam.h" +#include "N64 System/Mips/Sram.h" #include "N64 System/Mips/Eeprom.h" +#include "N64 System/Mips/Dma.h" #include "N64 System/Mips/Pif Ram.h" #include "N64 System/Mips/Register Class.h" #include "N64 System/Mips/TranslateVaddr.h" @@ -34,7 +37,6 @@ class CNotification; //C Core - to be upgrdaded and removed #include "N64 System/C Core/CPU Log.h" #include "N64 System/C Core/r4300i Commands.h" -#include "N64 System/C Core/Dma.h" #include "N64 System/C Core/Win32Timer.h" #include "N64 System/C Core/Logging.h" diff --git a/Source/Project64/N64 System/C Core/C Core Interface.cpp b/Source/Project64/N64 System/C Core/C Core Interface.cpp index b6c32d265..f996f02a8 100644 --- a/Source/Project64/N64 System/C Core/C Core Interface.cpp +++ b/Source/Project64/N64 System/C Core/C Core Interface.cpp @@ -305,15 +305,3 @@ void SyncToPC (void) { //FixRandomReg(); SyncSystem (); } - -BOOL ClearRecompCodeProtectMem ( DWORD Address, int length ) -{ - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - if (_Recompiler) - { - return _Recompiler->ClearRecompCode_Phys(Address,length,CRecompiler::Remove_ProtectedMem); - } -#endif - return false; -} diff --git a/Source/Project64/N64 System/C Core/C Core Interface.h b/Source/Project64/N64 System/C Core/C Core Interface.h index 38bc6d641..025eb4714 100644 --- a/Source/Project64/N64 System/C Core/C Core Interface.h +++ b/Source/Project64/N64 System/C Core/C Core Interface.h @@ -57,8 +57,6 @@ void ResetX86Logs ( void ); void SyncToPC ( void ); void CloseSaveChips ( void ); -BOOL ClearRecompCodeProtectMem ( DWORD PhysicalAddress, int length ); - //Timer functions void ResetTimer ( void ); void GenerateProfileLog ( void ); diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp index 7f670a42d..3821fba42 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp @@ -79,7 +79,7 @@ LRESULT CDumpMemory::OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& b GetDlgItemText(IDC_FILENAME,FileName,sizeof(FileName)); if (strlen(FileName) == 0) { - Notify().DisplayError("Please Choose target file"); + _Notify->DisplayError("Please Choose target file"); ::SetFocus(GetDlgItem(IDC_FILENAME)); return false; } @@ -255,7 +255,7 @@ LRESULT CDumpMemory::OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& b // GetDlgItemText((HWND)hDlg,IDC_FILENAME,FileName,sizeof(FileName)); // if (strlen(FileName) == 0) // { -// Notify().DisplayError("Please Choose target file"); +// _Notify->DisplayError("Please Choose target file"); // SetFocus(GetDlgItem((HWND)hDlg,IDC_FILENAME)); // return false; // } @@ -299,7 +299,7 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, CLog LogFile; if (!LogFile.Open(FileName)) { - Notify().DisplayError("Failed to open\n%s",FileName); + _Notify->DisplayError("Failed to open\n%s",FileName); return false; } LogFile.SetFlush(false); @@ -479,7 +479,7 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, // // if (strlen(FileName) == 0) // { -// Notify().DisplayError("Please Choose target file"); +// _Notify->DisplayError("Please Choose target file"); // SetFocus(GetDlgItem((HWND)hDlg,IDC_FILENAME)); // return false; // } @@ -524,7 +524,7 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, // CLog LogFile(FileName); // if (!LogFile.IsOpen()) // { -// Notify().DisplayError("Failed to open\n%s",FileName); +// _Notify->DisplayError("Failed to open\n%s",FileName); // return false; // } // diff --git a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp index 903b3b04b..bcbef5c35 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp @@ -324,7 +324,7 @@ void CInterpreterCPU::ExecuteOps ( int Cycles ) *_NextTimer -= m_CountPerOp; m_R4300i_Opcode[ Opcode.op ](); - static DWORD TestAddress = 0x801AF8A0, TestValue = 0, CurrentValue = 0; + static DWORD TestAddress = 0x80077B0C, TestValue = 0, CurrentValue = 0; if (_MMU->LW_VAddr(TestAddress, TestValue)) { if (TestValue != CurrentValue) diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp index 19c6a1c78..4c2f37980 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp @@ -872,10 +872,12 @@ void R4300iOp32::LWL (void) { Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Offset = Address & 3; - if (!_MMU->LW_VAddr((Address & ~3),Value)) { -#ifndef EXTERNAL_RELEASE - DisplayError("LDL TLB: %X",Address); -#endif + if (!_MMU->LW_VAddr((Address & ~3),Value)) + { + if (g_ShowTLBMisses) + { + DisplayError("LWL TLB: %X",Address); + } return; } @@ -935,10 +937,12 @@ void R4300iOp32::LWR (void) { Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Offset = Address & 3; - if (!_MMU->LW_VAddr((Address & ~3),Value)) { -#ifndef EXTERNAL_RELEASE - DisplayError("LDL TLB: %X",Address); -#endif + if (!_MMU->LW_VAddr((Address & ~3),Value)) + { + if (g_ShowTLBMisses) + { + DisplayError("LWR TLB: %X",Address); + } return; } @@ -1015,9 +1019,10 @@ void R4300iOp32::SW (void) { #endif if (!_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) { -#ifndef EXTERNAL_RELEASE - DisplayError("SW TLB: %X",Address); -#endif + if (g_ShowTLBMisses) + { + DisplayError("SW TLB: %X",Address); + } } } @@ -1088,8 +1093,12 @@ void R4300iOp32::SC (void) { Log_SW((*_PROGRAM_COUNTER),Address,_GPR[m_Opcode.rt].UW[0]); #endif if ((*_LLBit) == 1) { - if (!_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) { - DisplayError("SW TLB: %X",Address); + if (!_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + { + if (g_ShowTLBMisses) + { + DisplayError("SC TLB: %X",Address); + } } } _GPR[m_Opcode.rt].UW[0] = (*_LLBit); diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp index 139000bee..69daf68f7 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp @@ -957,10 +957,12 @@ void R4300iOp::LDL (void) { Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Offset = Address & 7; - if (!_MMU->LD_VAddr((Address & ~7),Value)) { -#ifndef EXTERNAL_RELEASE - DisplayError("LDL TLB: %X",Address); -#endif + if (!_MMU->LD_VAddr((Address & ~7),Value)) + { + if (g_ShowTLBMisses) + { + DisplayError("LDL TLB: %X",Address); + } return; } _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].DW & LDL_MASK[Offset]; @@ -980,10 +982,12 @@ void R4300iOp::LDR (void) { Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Offset = Address & 7; - if (!_MMU->LD_VAddr((Address & ~7),Value)) { -#ifndef EXTERNAL_RELEASE - DisplayError("LDL TLB: %X",Address); -#endif + if (!_MMU->LD_VAddr((Address & ~7),Value)) + { + if (g_ShowTLBMisses) + { + DisplayError("LDR TLB: %X",Address); + } return; } @@ -1026,10 +1030,12 @@ void R4300iOp::LWL (void) { Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Offset = Address & 3; - if (!_MMU->LW_VAddr((Address & ~3),Value)) { -#ifndef EXTERNAL_RELEASE - DisplayError("LDL TLB: %X",Address); -#endif + if (!_MMU->LW_VAddr((Address & ~3),Value)) + { + if (g_ShowTLBMisses) + { + DisplayError("LWL TLB: %X",Address); + } return; } @@ -1106,10 +1112,12 @@ void R4300iOp::LWR (void) { Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Offset = Address & 3; - if (!_MMU->LW_VAddr((Address & ~3),Value)) { -#ifndef EXTERNAL_RELEASE - DisplayError("LDL TLB: %X",Address); -#endif + if (!_MMU->LW_VAddr((Address & ~3),Value)) + { + if (g_ShowTLBMisses) + { + DisplayError("LDL TLB: %X",Address); + } return; } @@ -1199,10 +1207,12 @@ void R4300iOp::SW (void) { } #endif - if (!_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) { -#ifndef EXTERNAL_RELEASE - DisplayError("SW TLB: %X",Address); -#endif + if (!_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + { + if (g_ShowTLBMisses) + { + DisplayError("SW TLB: %X",Address); + } } } @@ -1342,8 +1352,12 @@ void R4300iOp::SC (void) { Log_SW((*_PROGRAM_COUNTER),Address,_GPR[m_Opcode.rt].UW[0]); #endif if ((*_LLBit) == 1) { - if (!_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) { - DisplayError("SW TLB: %X",Address); + if (!_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + { + if (g_ShowTLBMisses) + { + DisplayError("SC TLB: %X",Address); + } } } _GPR[m_Opcode.rt].UW[0] = (*_LLBit); @@ -1539,7 +1553,8 @@ void R4300iOp::SPECIAL_DMULT (void) { _RegHI->UDW += (QWORD)Tmp[0].W[1] + (QWORD)Tmp[1].W[1] + Tmp[2].UW[1]; } -void R4300iOp::SPECIAL_DMULTU (void) { +void R4300iOp::SPECIAL_DMULTU (void) +{ MIPS_DWORD Tmp[3]; _RegLO->UDW = (QWORD)_GPR[m_Opcode.rs].UW[0] * (QWORD)_GPR[m_Opcode.rt].UW[0]; @@ -2299,15 +2314,13 @@ void R4300iOp::COP1_L_CVT_D (void) { } /************************** Other functions **************************/ -void R4300iOp::UnknownOpcode (void) { -#ifdef OLD_CODE - char Message[200]; - - sprintf(Message,"%s: %08X\n%s\n\n", GS(MSG_UNHANDLED_OP), (*_PROGRAM_COUNTER), - R4300im_OpcodeName(m_Opcode.Hex,(*_PROGRAM_COUNTER))); - strcat(Message,"Stopping Emulation !"); +void R4300iOp::UnknownOpcode (void) +{ + DisplayError("%s: %08X\n%s\n\nStopping Emulation !", GS(MSG_UNHANDLED_OP), (*_PROGRAM_COUNTER), + R4300iOpcodeName(m_Opcode.Hex,(*_PROGRAM_COUNTER))); + _System->m_EndEmulation = true; -#if (!defined(EXTERNAL_RELEASE)) +#ifdef tofix if (HaveDebugger && !inFullScreen) { int response; @@ -2322,12 +2335,5 @@ void R4300iOp::UnknownOpcode (void) { DisplayError(Message); ExitThread(0); } -#else - DisplayError(Message); - ExitThread(0); -#endif -#else - BreakPoint(__FILE__,__LINE__); - #endif } diff --git a/Source/Project64/N64 System/Mips/Dma.cpp b/Source/Project64/N64 System/Mips/Dma.cpp new file mode 100644 index 000000000..e883e8a6e --- /dev/null +++ b/Source/Project64/N64 System/Mips/Dma.cpp @@ -0,0 +1,222 @@ +#include "stdafx.h" + +CDMA::CDMA(CFlashram & FlashRam, CSram & Sram) : + m_FlashRam(FlashRam), + m_Sram(Sram) +{ +} + +void CDMA::OnFirstDMA (void) { + switch (_Rom->CicChipID()) { + case 1: *(DWORD *)&((_MMU->Rdram())[0x318]) = g_RdramSize; break; + case 2: *(DWORD *)&((_MMU->Rdram())[0x318]) = g_RdramSize; break; + case 3: *(DWORD *)&((_MMU->Rdram())[0x318]) = g_RdramSize; break; + case 5: *(DWORD *)&((_MMU->Rdram())[0x3F0]) = g_RdramSize; break; + case 6: *(DWORD *)&((_MMU->Rdram())[0x318]) = g_RdramSize; break; + default: DisplayError("Unhandled CicChip(%d) in first DMA",_Rom->CicChipID()); + } +} + +void CDMA::PI_DMA_READ (void) { +// PI_STATUS_REG |= PI_STATUS_DMA_BUSY; + + if ( _Reg->PI_DRAM_ADDR_REG + _Reg->PI_RD_LEN_REG + 1 > g_RdramSize) { +#ifndef EXTERNAL_RELEASE + DisplayError("PI_DMA_READ not in Memory"); +#endif + _Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; + _Reg->MI_INTR_REG |= MI_INTR_PI; + _Reg->CheckInterrupts(); + return; + } + + if ( _Reg->PI_CART_ADDR_REG >= 0x08000000 && _Reg->PI_CART_ADDR_REG <= 0x08010000) { + if (g_SaveUsing == SaveChip_Auto) { g_SaveUsing = SaveChip_Sram; } + if (g_SaveUsing == SaveChip_Sram) { + m_Sram.DmaToSram( + _MMU->Rdram() + _Reg->PI_DRAM_ADDR_REG, + _Reg->PI_CART_ADDR_REG - 0x08000000, + _Reg->PI_RD_LEN_REG + 1 + ); + _Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; + _Reg->MI_INTR_REG |= MI_INTR_PI; + _Reg->CheckInterrupts(); + return; + } + if (g_SaveUsing == SaveChip_FlashRam) { + m_FlashRam.DmaToFlashram( + _MMU->Rdram()+_Reg->PI_DRAM_ADDR_REG, + _Reg->PI_CART_ADDR_REG - 0x08000000, + _Reg->PI_WR_LEN_REG + 1 + ); + _Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; + _Reg->MI_INTR_REG |= MI_INTR_PI; + _Reg->CheckInterrupts(); + return; + } + } + if (g_SaveUsing == SaveChip_FlashRam) { +#ifndef EXTERNAL_RELEASE + DisplayError("**** FLashRam DMA Read address %X *****",_Reg->PI_CART_ADDR_REG); +#endif + _Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; + _Reg->MI_INTR_REG |= MI_INTR_PI; + _Reg->CheckInterrupts(); + return; + } +#ifndef EXTERNAL_RELEASE + DisplayError("PI_DMA_READ where are you dmaing to ?"); +#endif + _Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; + _Reg->MI_INTR_REG |= MI_INTR_PI; + _Reg->CheckInterrupts(); + return; +} + +void CDMA::PI_DMA_WRITE (void) { + + _Reg->PI_STATUS_REG |= PI_STATUS_DMA_BUSY; + if ( _Reg->PI_DRAM_ADDR_REG + _Reg->PI_WR_LEN_REG + 1 > g_RdramSize) + { + if (g_ShowUnhandledMemory) { DisplayError("PI_DMA_WRITE not in Memory"); } + _Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; + _Reg->MI_INTR_REG |= MI_INTR_PI; + _Reg->CheckInterrupts(); + return; + } + + if ( _Reg->PI_CART_ADDR_REG >= 0x08000000 && _Reg->PI_CART_ADDR_REG <= 0x08010000) { + if (g_SaveUsing == SaveChip_Auto) { g_SaveUsing = SaveChip_Sram; } + if (g_SaveUsing == SaveChip_Sram) { + m_Sram.DmaFromSram( + _MMU->Rdram()+_Reg->PI_DRAM_ADDR_REG, + _Reg->PI_CART_ADDR_REG - 0x08000000, + _Reg->PI_WR_LEN_REG + 1 + ); + _Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; + _Reg->MI_INTR_REG |= MI_INTR_PI; + _Reg->CheckInterrupts(); + return; + } + if (g_SaveUsing == SaveChip_FlashRam) { + m_FlashRam.DmaFromFlashram( + _MMU->Rdram()+_Reg->PI_DRAM_ADDR_REG, + _Reg->PI_CART_ADDR_REG - 0x08000000, + _Reg->PI_WR_LEN_REG + 1 + ); + _Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; + _Reg->MI_INTR_REG |= MI_INTR_PI; + _Reg->CheckInterrupts(); + } + return; + } + + if ( _Reg->PI_CART_ADDR_REG >= 0x10000000 && _Reg->PI_CART_ADDR_REG <= 0x1FBFFFFF) { + DWORD i; +#ifdef tofix +#ifdef ROM_IN_MAPSPACE + if (WrittenToRom) { + DWORD OldProtect; + VirtualProtect(ROM,g_RomFileSize,PAGE_READONLY, &OldProtect); + } +#endif +#endif + BYTE * ROM = _Rom->GetRomAddress(); + BYTE * RDRAM = _MMU->Rdram(); + _Reg->PI_CART_ADDR_REG -= 0x10000000; + if (_Reg->PI_CART_ADDR_REG + _Reg->PI_WR_LEN_REG + 1 < g_RomFileSize) { + for (i = 0; i < _Reg->PI_WR_LEN_REG + 1; i ++) { + *(RDRAM+((_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((_Reg->PI_CART_ADDR_REG + i) ^ 3)); + } + } else { + DWORD Len; + Len = g_RomFileSize - _Reg->PI_CART_ADDR_REG; + for (i = 0; i < Len; i ++) { + *(RDRAM+((_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((_Reg->PI_CART_ADDR_REG + i) ^ 3)); + } + for (i = Len; i < _Reg->PI_WR_LEN_REG + 1 - Len; i ++) { + *(RDRAM+((_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = 0; + } + } + _Reg->PI_CART_ADDR_REG += 0x10000000; + + if (!_System->DmaUsed()) + { + _System->SetDmaUsed(true); + OnFirstDMA(); + } + if (_Recompiler && _Recompiler->bSMM_PIDMA()) + { + _Recompiler->ClearRecompCode_Phys(_Reg->PI_DRAM_ADDR_REG, _Reg->PI_WR_LEN_REG,CRecompiler::Remove_DMA); + } + _Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; + _Reg->MI_INTR_REG |= MI_INTR_PI; + _Reg->CheckInterrupts(); + //ChangeTimer(PiTimer,(int)(PI_WR_LEN_REG * 8.9) + 50); + //ChangeTimer(PiTimer,(int)(PI_WR_LEN_REG * 8.9)); + return; + } + + if (g_ShowUnhandledMemory) { DisplayError("PI_DMA_WRITE not in ROM"); } + _Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; + _Reg->MI_INTR_REG |= MI_INTR_PI; + _Reg->CheckInterrupts(); + +} + +void CDMA::SP_DMA_READ (void) { + _Reg->SP_DRAM_ADDR_REG &= 0x1FFFFFFF; + + if (_Reg->SP_DRAM_ADDR_REG > g_RdramSize) { +#ifndef EXTERNAL_RELEASE + DisplayError("SP DMA\nSP_DRAM_ADDR_REG not in RDRam space"); +#endif + _Reg->SP_DMA_BUSY_REG = 0; + _Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY; + return; + } + + if (_Reg->SP_RD_LEN_REG + 1 + (_Reg->SP_MEM_ADDR_REG & 0xFFF) > 0x1000) { +#ifndef EXTERNAL_RELEASE + DisplayError("SP DMA\ncould not fit copy in memory segement"); +#endif + return; + } + + if ((_Reg->SP_MEM_ADDR_REG & 3) != 0) { BreakPoint(__FILE__,__LINE__); } + if ((_Reg->SP_DRAM_ADDR_REG & 3) != 0) { BreakPoint(__FILE__,__LINE__); } + if (((_Reg->SP_RD_LEN_REG + 1) & 3) != 0) { BreakPoint(__FILE__,__LINE__); } + + memcpy( _MMU->Dmem() + (_Reg->SP_MEM_ADDR_REG & 0x1FFF), _MMU->Rdram() + _Reg->SP_DRAM_ADDR_REG, + _Reg->SP_RD_LEN_REG + 1 ); + + _Reg->SP_DMA_BUSY_REG = 0; + _Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY; +} + +void CDMA::SP_DMA_WRITE (void) { + if (_Reg->SP_DRAM_ADDR_REG > g_RdramSize) { +#ifndef EXTERNAL_RELEASE + DisplayError("SP DMA WRITE\nSP_DRAM_ADDR_REG not in RDRam space"); +#endif + return; + } + + if (_Reg->SP_WR_LEN_REG + 1 + (_Reg->SP_MEM_ADDR_REG & 0xFFF) > 0x1000) { +#ifndef EXTERNAL_RELEASE + DisplayError("SP DMA WRITE\ncould not fit copy in memory segement"); +#endif + return; + } + + if ((_Reg->SP_MEM_ADDR_REG & 3) != 0) { BreakPoint(__FILE__,__LINE__); } + if ((_Reg->SP_DRAM_ADDR_REG & 3) != 0) { BreakPoint(__FILE__,__LINE__); } + if (((_Reg->SP_WR_LEN_REG + 1) & 3) != 0) { BreakPoint(__FILE__,__LINE__); } + + memcpy( _MMU->Rdram() + _Reg->SP_DRAM_ADDR_REG, _MMU->Dmem() + (_Reg->SP_MEM_ADDR_REG & 0x1FFF), + _Reg->SP_WR_LEN_REG + 1); + + _Reg->SP_DMA_BUSY_REG = 0; + _Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY; +} + diff --git a/Source/Project64/N64 System/Mips/Dma.h b/Source/Project64/N64 System/Mips/Dma.h new file mode 100644 index 000000000..5d7ce8c4e --- /dev/null +++ b/Source/Project64/N64 System/Mips/Dma.h @@ -0,0 +1,22 @@ +class CDMA +{ + CDMA(); + +protected: + CDMA (CFlashram & FlashRam, CSram & Sram); + + void PI_DMA_READ ( void ); + void PI_DMA_WRITE ( void ); + //void SI_DMA_READ ( void ); + //void SI_DMA_WRITE ( void ); + void SP_DMA_READ ( void ); + void SP_DMA_WRITE ( void ); + +private: + CFlashram & m_FlashRam; + CSram & m_Sram; + + void OnFirstDMA ( void ); +}; + + diff --git a/Source/Project64/N64 System/Mips/FlashRam.cpp b/Source/Project64/N64 System/Mips/FlashRam.cpp new file mode 100644 index 000000000..87c8d20d1 --- /dev/null +++ b/Source/Project64/N64 System/Mips/FlashRam.cpp @@ -0,0 +1,221 @@ +#include "stdafx.h" + +CFlashram::CFlashram (bool ReadOnly): + m_FlashFlag(FLASHRAM_MODE_NOPES), + m_FlashStatus(0), + m_FlashRamPointer(NULL), + m_FlashRAM_Offset(0), + m_ReadOnly(ReadOnly), + m_hFile(NULL) +{ +} + +CFlashram::~CFlashram (void) { + if (m_hFile) { + CloseHandle(m_hFile); + m_hFile = NULL; + } +} + +void CFlashram::DmaFromFlashram ( BYTE * dest, int StartOffset, int len) +{ + BYTE FlipBuffer[0x10000]; + DWORD dwRead, count; + + switch (m_FlashFlag) { + case FLASHRAM_MODE_READ: + if (m_hFile == NULL) { + if (!LoadFlashram()) { return; } + } + if (len > 0x10000) { +#ifndef EXTERNAL_RELEASE + DisplayError("DmaFromFlashram FlipBuffer to small (len: %d)",len); +#endif + len = 0x10000; + } + if ((len & 3) != 0) { +#ifndef EXTERNAL_RELEASE + DisplayError("Unaligned flash ram read ???"); +#endif + return; + } + memset(FlipBuffer,0,sizeof(FlipBuffer)); + StartOffset = StartOffset << 1; + SetFilePointer(m_hFile,StartOffset,NULL,FILE_BEGIN); + ReadFile(m_hFile,FlipBuffer,len,&dwRead,NULL); + for (count = dwRead; (int)count < len; count ++) { + FlipBuffer[count] = 0xFF; + } + _asm { + mov edi, dest + lea ecx, [FlipBuffer] + mov edx, 0 + mov ebx, len + + memcpyloop: + mov eax, dword ptr [ecx + edx] + ;bswap eax + mov dword ptr [edi + edx],eax + add edx, 4 + cmp edx, ebx + jb memcpyloop + } + break; + case FLASHRAM_MODE_STATUS: + if (StartOffset != 0 && len != 8) { +#ifndef EXTERNAL_RELEASE + DisplayError("Reading m_FlashStatus not being handled correctly\nStart: %X len: %X",StartOffset,len); +#endif + } + *((DWORD *)(dest)) = (DWORD)(m_FlashStatus >> 32); + *((DWORD *)(dest) + 1) = (DWORD)(m_FlashStatus); + break; +#ifndef EXTERNAL_RELEASE + default: + DisplayError("DmaFromFlashram Start: %X, Offset: %X len: %X",dest - _MMU->Rdram(),StartOffset,len); +#endif + } +} + +void CFlashram::DmaToFlashram(BYTE * Source, int StartOffset, int len) { + switch (m_FlashFlag) { + case FLASHRAM_MODE_WRITE: + m_FlashRamPointer = Source; + break; +#ifndef EXTERNAL_RELEASE + default: + DisplayError("DmaToFlashram Start: %X, Offset: %X len: %X",Source - _MMU->Rdram(),StartOffset,len); +#endif + } +} + +DWORD CFlashram::ReadFlashStatus (DWORD PAddr) +{ + switch (PAddr) { + case 0x08000000: return (DWORD)(m_FlashStatus >> 32); + default: +#ifndef EXTERNAL_RELEASE + DisplayError("Reading from flash ram status (%X)",PAddr); +#endif + break; + } + return (DWORD)(m_FlashStatus >> 32); +} + +bool CFlashram::LoadFlashram (void) { + CPath FileName; + + FileName.SetDriveDirectory( _Settings->LoadString(Directory_NativeSave).c_str()); + FileName.SetName(_Settings->LoadString(Game_GameName).c_str()); + FileName.SetExtension("fla"); + + if (!FileName.DirectoryExists()) + { + FileName.CreateDirectory(); + } + + m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); + if (m_hFile == INVALID_HANDLE_VALUE) + { + WriteTraceF(TraceError,"CFlashram::LoadFlashram: Failed to open (%s), ReadOnly = %d, LastError = %X",(LPCTSTR)FileName, m_ReadOnly, GetLastError()); + DisplayError(GS(MSG_FAIL_OPEN_FLASH)); + return false; + } + SetFilePointer(m_hFile,0,NULL,FILE_BEGIN); + return true; +} + +void CFlashram::WriteToFlashCommand(DWORD FlashRAM_Command) { + BYTE EmptyBlock[128]; + DWORD dwWritten; + + switch (FlashRAM_Command & 0xFF000000) { + case 0xD2000000: + switch (m_FlashFlag) { + case FLASHRAM_MODE_NOPES: break; + case FLASHRAM_MODE_READ: break; + case FLASHRAM_MODE_STATUS: break; + case FLASHRAM_MODE_ERASE: + memset(EmptyBlock,0xFF,sizeof(EmptyBlock)); + if (m_hFile == NULL) { + if (!LoadFlashram()) { return; } + } + SetFilePointer(m_hFile,m_FlashRAM_Offset,NULL,FILE_BEGIN); + WriteFile(m_hFile,EmptyBlock,128,&dwWritten,NULL); + break; + case FLASHRAM_MODE_WRITE: + if (m_hFile == NULL) { + if (!LoadFlashram()) { return; } + } + { + BYTE FlipBuffer[128]; + DWORD dwWritten; + BYTE * FlashRamPointer = m_FlashRamPointer; + + memset(FlipBuffer,0,sizeof(FlipBuffer)); + _asm { + lea edi, [FlipBuffer] + mov ecx, FlashRamPointer + mov edx, 0 + + memcpyloop: + mov eax, dword ptr [ecx + edx] + ;bswap eax + mov dword ptr [edi + edx],eax + add edx, 4 + cmp edx, 128 + jb memcpyloop + } + + SetFilePointer(m_hFile,m_FlashRAM_Offset,NULL,FILE_BEGIN); + WriteFile(m_hFile,FlipBuffer,128,&dwWritten,NULL); + } + break; + default: + DisplayError("Writing %X to flash ram command register\nm_FlashFlag: %d",FlashRAM_Command,m_FlashFlag); + } + m_FlashFlag = FLASHRAM_MODE_NOPES; + break; + case 0xE1000000: + m_FlashFlag = FLASHRAM_MODE_STATUS; + m_FlashStatus = 0x1111800100C20000; + break; + case 0xF0000000: + m_FlashFlag = FLASHRAM_MODE_READ; + m_FlashStatus = 0x11118004F0000000; + break; + case 0x4B000000: + m_FlashRAM_Offset = (FlashRAM_Command & 0xffff) * 128; + break; + case 0x78000000: + m_FlashFlag = FLASHRAM_MODE_ERASE; + m_FlashStatus = 0x1111800800C20000; + break; + case 0xB4000000: + m_FlashFlag = FLASHRAM_MODE_WRITE; //???? + break; + case 0xA5000000: + m_FlashRAM_Offset = (FlashRAM_Command & 0xffff) * 128; + m_FlashStatus = 0x1111800400C20000; + break; +#ifndef EXTERNAL_RELEASE + default: + DisplayError("Writing %X to flash ram command register",FlashRAM_Command); +#endif + } +} + +DWORD CFlashram::ReadFromFlashStatus (DWORD PAddr) +{ + switch (PAddr) { + case 0x08000000: return (DWORD)(m_FlashStatus >> 32); + default: +#ifndef EXTERNAL_RELEASE + DisplayError("Reading from flash ram status (%X)",PAddr); +#endif + break; + } + return (DWORD)(m_FlashStatus >> 32); +} + diff --git a/Source/Project64/N64 System/Mips/FlashRam.h b/Source/Project64/N64 System/Mips/FlashRam.h new file mode 100644 index 000000000..2c3d94732 --- /dev/null +++ b/Source/Project64/N64 System/Mips/FlashRam.h @@ -0,0 +1,30 @@ +class CFlashram +{ + enum Modes { + FLASHRAM_MODE_NOPES = 0, + FLASHRAM_MODE_ERASE = 1, + FLASHRAM_MODE_WRITE = 2, + FLASHRAM_MODE_READ = 3, + FLASHRAM_MODE_STATUS = 4, + }; + +public: + CFlashram ( bool ReadOnly ); + ~CFlashram ( void ); + + void DmaFromFlashram ( BYTE * dest, int StartOffset, int len ); + void DmaToFlashram ( BYTE * Source, int StartOffset, int len ); + DWORD ReadFromFlashStatus ( DWORD PAddr ); + void WriteToFlashCommand ( DWORD Value ); + +private: + DWORD ReadFlashStatus ( DWORD PAddr ); + bool LoadFlashram ( void ); + + BYTE * m_FlashRamPointer; + Modes m_FlashFlag; + QWORD m_FlashStatus; + DWORD m_FlashRAM_Offset; + bool m_ReadOnly; + HANDLE m_hFile; +}; diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp index 5ec464eff..536839a75 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp @@ -3,7 +3,11 @@ DWORD RegModValue; CMipsMemoryVM::CMipsMemoryVM ( CMipsMemory_CallBack * CallBack, bool SavesReadOnly ) : + CPifRam(SavesReadOnly), + CFlashram(SavesReadOnly), + CSram(SavesReadOnly), + CDMA(*this,*this), m_CBClass(CallBack), m_TLB_ReadMap(NULL), m_TLB_WriteMap(NULL), @@ -671,7 +675,8 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { case 0x04040008: MoveConstToVariable(Value,&_Reg->SP_RD_LEN_REG,"SP_RD_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - Call_Direct(&SP_DMA_READ,"SP_DMA_READ"); + MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); + Call_Direct(AddressOf(CDMA::SP_DMA_READ),"CDMA::SP_DMA_READ"); AfterCallDirect(m_RegWorkingSet); break; case 0x04040010: @@ -893,13 +898,15 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { case 0x04600008: MoveConstToVariable(Value,&_Reg->PI_RD_LEN_REG,"PI_RD_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - Call_Direct(&PI_DMA_READ,"PI_DMA_READ"); + MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); + Call_Direct(AddressOf(CDMA::PI_DMA_READ),"CDMA::PI_DMA_READ"); AfterCallDirect(m_RegWorkingSet); break; case 0x0460000C: MoveConstToVariable(Value,&_Reg->PI_WR_LEN_REG,"PI_WR_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - Call_Direct(&PI_DMA_WRITE,"PI_DMA_WRITE"); + MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); + Call_Direct(AddressOf(CDMA::PI_DMA_WRITE),"CDMA::PI_DMA_WRITE"); AfterCallDirect(m_RegWorkingSet); break; case 0x04600010: @@ -994,13 +1001,15 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) case 0x04040008: MoveX86regToVariable(Reg,&_Reg->SP_RD_LEN_REG,"SP_RD_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - Call_Direct(&SP_DMA_READ,"SP_DMA_READ"); + MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); + Call_Direct(AddressOf(CDMA::SP_DMA_READ),"CDMA::SP_DMA_READ"); AfterCallDirect(m_RegWorkingSet); break; case 0x0404000C: MoveX86regToVariable(Reg,&_Reg->SP_WR_LEN_REG,"SP_WR_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - Call_Direct(&SP_DMA_WRITE,"SP_DMA_WRITE"); + MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); + Call_Direct(AddressOf(CDMA::SP_DMA_WRITE),"CDMA::SP_DMA_WRITE"); AfterCallDirect(m_RegWorkingSet); break; case 0x04040010: @@ -1149,13 +1158,15 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) case 0x04600008: MoveX86regToVariable(Reg,&_Reg->PI_RD_LEN_REG,"PI_RD_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - Call_Direct(&PI_DMA_READ,"PI_DMA_READ"); + MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); + Call_Direct(AddressOf(CDMA::PI_DMA_READ),"CDMA::PI_DMA_READ"); AfterCallDirect(m_RegWorkingSet); break; case 0x0460000C: MoveX86regToVariable(Reg,&_Reg->PI_WR_LEN_REG,"PI_WR_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - Call_Direct(&PI_DMA_WRITE,"PI_DMA_WRITE"); + MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); + Call_Direct(AddressOf(CDMA::PI_DMA_WRITE),"CDMA::PI_DMA_WRITE"); AfterCallDirect(m_RegWorkingSet); break; case 0x04600010: @@ -1302,53 +1313,19 @@ int CMipsMemoryVM::MemoryFilter( DWORD dwExptCode, void * lpExceptionPointer ) return EXCEPTION_CONTINUE_EXECUTION; } #endif - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - if ((int)End < RdramSize) { - for ( count = Start; count < End; count += 0x1000 ) { - BreakPoint(__FILE__,__LINE__); - if (N64_Blocks.NoOfRDRamBlocks[(count >> 12)] > 0) { - N64_Blocks.NoOfRDRamBlocks[(count >> 12)] = 0; - memset(JumpTable + ((count & 0x00FFFFF0) >> 2),0,0x1000); - *(DelaySlotTable + count) = NULL; - if (VirtualProtect(m_RDRAM + count, 4, PAGE_READWRITE, &OldProtect) == 0) { -#ifndef EXTERNAL_RELEASE - DisplayError("Failed to unprotect %X\n1", count); -#endif - } - } + if (End < RdramSize()) + { + for (DWORD count = (Start & ~0xFFF); count < End; count += 0x1000 ) + { + _Recompiler->ClearRecompCode_Phys(count,0x1000,CRecompiler::Remove_ProtectedMem); } return EXCEPTION_CONTINUE_EXECUTION; } - if (Start >= 0x04000000 && End < 0x04001000) { - BreakPoint(__FILE__,__LINE__); - N64_Blocks.NoOfDMEMBlocks = 0; - memset(JumpTable + (0x04000000 >> 2),0,0x1000); - *(DelaySlotTable + (0x04000000 >> 12)) = NULL; - if (VirtualProtect(m_RDRAM + 0x04000000, 4, PAGE_READWRITE, &OldProtect) == 0) { -#ifndef EXTERNAL_RELEASE - DisplayError("Failed to unprotect %X\n7", 0x04000000); -#endif - } + if (Start >= 0x04000000 && End < 0x04002000) { + _Recompiler->ClearRecompCode_Phys(Start & ~0xFFF,0x1000,CRecompiler::Remove_ProtectedMem); return EXCEPTION_CONTINUE_EXECUTION; } - if (Start >= 0x04001000 && End < 0x04002000) { - BreakPoint(__FILE__,__LINE__); - N64_Blocks.NoOfIMEMBlocks = 0; - memset(JumpTable + (0x04001000 >> 2),0,0x1000); - *(DelaySlotTable + (0x04001000 >> 12)) = NULL; - if (VirtualProtect(m_RDRAM + 0x04001000, 4, PAGE_READWRITE, &OldProtect) == 0) { -#ifndef EXTERNAL_RELEASE - DisplayError("Failed to unprotect %X\n6", 0x04001000); -#endif - } - return EXCEPTION_CONTINUE_EXECUTION; - } -#ifndef EXTERNAL_RELEASE - DisplayError("hmmm.... where does this dma End ?\nstart: %X\nend:%X\nlocation %X", - Start,End,lpEP->ContextRecord->Eip); -#endif -#endif + DisplayError("hmmm.... where does this dma End ?\nstart: %X\nend:%X\nlocation %X", Start,End,lpEP->ContextRecord->Eip); return EXCEPTION_CONTINUE_SEARCH; } @@ -1403,6 +1380,7 @@ int CMipsMemoryVM::MemoryFilter( DWORD dwExptCode, void * lpExceptionPointer ) case 0x41: ReadPos += 2; break; case 0x42: ReadPos += 2; break; case 0x43: ReadPos += 2; break; + case 0x44: ReadPos += 3; break; case 0x46: ReadPos += 2; break; case 0x47: ReadPos += 2; break; case 0x80: ReadPos += 5; break; @@ -1799,10 +1777,7 @@ int CMipsMemoryVM::LW_NonMemory ( DWORD PAddr, DWORD * Value ) { *Value = (*Value << 16) | *Value; return FALSE; } - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix *Value = ReadFromFlashStatus(PAddr); -#endif break; case 0x1FC00000: if (PAddr < 0x1FC007C0) { @@ -1864,18 +1839,8 @@ int CMipsMemoryVM::SB_NonMemory ( DWORD PAddr, BYTE Value ) { } #endif if (PAddr < RdramSize()) { - bool ProtectMem = false; - DWORD Start = PAddr & ~0xFFF; - WriteTraceF(TraceDebug,"WriteToProtectedMemory Addres: %X Len: %d",PAddr,1); - if (!ClearRecompCodeProtectMem(Start,0xFFF)) { ProtectMem = true; } - - DWORD OldProtect; - VirtualProtect((m_RDRAM + PAddr), 1, PAGE_READWRITE, &OldProtect); + _Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF,0x1000,CRecompiler::Remove_ProtectedMem); *(BYTE *)(m_RDRAM+PAddr) = Value; - if (ProtectMem) - { - VirtualProtect((m_RDRAM + PAddr), 1, PAGE_READONLY, &OldProtect); - } } break; default: @@ -1908,18 +1873,8 @@ int CMipsMemoryVM::SH_NonMemory ( DWORD PAddr, WORD Value ) { } #endif if (PAddr < RdramSize()) { - bool ProtectMem = false; - DWORD Start = PAddr & ~0xFFF; - WriteTraceF(TraceDebug,"WriteToProtectedMemory Addres: %X Len: %d",PAddr,1); - if (!ClearRecompCodeProtectMem(Start,0xFFF)) { ProtectMem = true; } - - DWORD OldProtect; - VirtualProtect((m_RDRAM + PAddr), 1, PAGE_READWRITE, &OldProtect); + _Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF,0x1000,CRecompiler::Remove_ProtectedMem); *(WORD *)(m_RDRAM+PAddr) = Value; - if (ProtectMem) - { - VirtualProtect((m_RDRAM + PAddr), 1, PAGE_READONLY, &OldProtect); - } } break; default: @@ -1968,19 +1923,8 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) { } #endif if (PAddr < RdramSize()) { - bool ProtectMem = false; - - DWORD Start = PAddr & ~0xFFF; - WriteTraceF(TraceDebug,"WriteToProtectedMemory Addres: %X Len: %d",PAddr,1); - if (!ClearRecompCodeProtectMem(Start,0xFFF)) { ProtectMem = true; } - - DWORD OldProtect; - VirtualProtect((m_RDRAM + PAddr), 4, PAGE_READWRITE, &OldProtect); + _Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF,0x1000,CRecompiler::Remove_ProtectedMem); *(DWORD *)(m_RDRAM+PAddr) = Value; - if (ProtectMem) - { - VirtualProtect((m_RDRAM + PAddr), 4, PAGE_READONLY, &OldProtect); - } } break; case 0x03F00000: @@ -2007,19 +1951,8 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) { break; case 0x04000000: if (PAddr < 0x04002000) { - bool ProtectMem = false; - - DWORD Start = PAddr & ~0xFFF; - WriteTraceF(TraceDebug,"WriteToProtectedMemory Addres: %X Len: %d",PAddr,1); - if (!ClearRecompCodeProtectMem(Start,0xFFF)) { ProtectMem = true; } - - DWORD OldProtect; - VirtualProtect((m_RDRAM + PAddr), 4, PAGE_READWRITE, &OldProtect); + _Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF,0xFFF,CRecompiler::Remove_ProtectedMem); *(DWORD *)(m_RDRAM+PAddr) = Value; - if (ProtectMem) - { - VirtualProtect((m_RDRAM + PAddr), 4, PAGE_READONLY, &OldProtect); - } } else { switch (PAddr) { case 0x04040000: _Reg->SP_MEM_ADDR_REG = Value; break; @@ -2296,13 +2229,10 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) { } break; case 0x08000000: - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix if (PAddr != 0x08010000) { return FALSE; } - if (SaveUsing == SaveChip_Auto) { SaveUsing = SaveChip_FlashRam; } - if (SaveUsing != SaveChip_FlashRam) { return TRUE; } + if (g_SaveUsing == SaveChip_Auto) { g_SaveUsing = SaveChip_FlashRam; } + if (g_SaveUsing != SaveChip_FlashRam) { return TRUE; } WriteToFlashCommand(Value); -#endif return FALSE; break; case 0x1FC00000: @@ -2343,9 +2273,8 @@ void CMipsMemoryVM::UpdateHalfLine (void) void CMipsMemoryVM::ProtectMemory( DWORD StartVaddr, DWORD EndVaddr ) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - if (!CTLB::ValidVaddr(StartVaddr) || !CTLB::ValidVaddr(EndVaddr)) { return; } + WriteTraceF(TraceError,"ProtectMemory: StartVaddr: %X EndVaddr: %X",StartVaddr,EndVaddr); + if (!ValidVaddr(StartVaddr) || !ValidVaddr(EndVaddr)) { return; } //Get Physical Addresses passed DWORD StartPAddr, EndPAddr; @@ -2353,24 +2282,21 @@ void CMipsMemoryVM::ProtectMemory( DWORD StartVaddr, DWORD EndVaddr ) if (!TranslateVaddr(EndVaddr,EndPAddr)) { _Notify->BreakPoint(__FILE__,__LINE__); } //Get Length of memory being protected - int Length = (EndPAddr + 4) - StartPAddr; + int Length = ((EndPAddr + 3) - StartPAddr) & ~3; if (Length < 0) { _Notify->BreakPoint(__FILE__,__LINE__); } //Proect that memory address space DWORD OldProtect; - void * MemLoc; + BYTE * MemLoc = Rdram() + StartPAddr; + WriteTraceF(TraceError,"ProtectMemory: Paddr: %X Length: %X",StartPAddr,Length); - if (!VAddrToRealAddr(StartVaddr,MemLoc)) { _Notify->BreakPoint(__FILE__,__LINE__); } VirtualProtect(MemLoc, Length, PAGE_READONLY, &OldProtect); -#endif } void CMipsMemoryVM::UnProtectMemory( DWORD StartVaddr, DWORD EndVaddr ) { -// _Notify->BreakPoint(__FILE__,__LINE__); - WriteTraceF(TraceError,"CMipsMemoryVM::UnProtectMemory: Not implemented startVaddr: %X EndVaddr: %X",StartVaddr,EndVaddr); -#ifdef tofix - if (!CTLB::ValidVaddr(StartVaddr) || !CTLB::ValidVaddr(EndVaddr)) { return; } + WriteTraceF(TraceError,"UnProtectMemory: StartVaddr: %X EndVaddr: %X",StartVaddr,EndVaddr); + if (!ValidVaddr(StartVaddr) || !ValidVaddr(EndVaddr)) { return; } //Get Physical Addresses passed DWORD StartPAddr, EndPAddr; @@ -2378,19 +2304,16 @@ void CMipsMemoryVM::UnProtectMemory( DWORD StartVaddr, DWORD EndVaddr ) if (!TranslateVaddr(EndVaddr,EndPAddr)) { _Notify->BreakPoint(__FILE__,__LINE__); } //Get Length of memory being protected - int Length = (EndPAddr + 4) - StartPAddr; + int Length = ((EndPAddr + 3) - StartPAddr) & ~3; if (Length < 0) { _Notify->BreakPoint(__FILE__,__LINE__); } //Proect that memory address space DWORD OldProtect; - void * MemLoc; + BYTE * MemLoc = Rdram() + StartPAddr; - if (!VAddrToRealAddr(StartVaddr,MemLoc)) { _Notify->BreakPoint(__FILE__,__LINE__); } - VirtualProtect(MemLoc, Length, PAGE_READWRITE, &OldProtect); -#endif + VirtualProtect(MemLoc, Length, PAGE_READWRITE, &OldProtect); } - void CMipsMemoryVM::Compile_LB (void) { OPCODE & Opcode = CRecompilerOps::m_Opcode; @@ -3060,31 +2983,27 @@ void CMipsMemoryVM::Compile_LDC1 (void) void CMipsMemoryVM::Compile_LDL (void) { OPCODE & Opcode = CRecompilerOps::m_Opcode; - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); if (Opcode.base != 0) { UnMap_GPR(Opcode.base,TRUE); } if (Opcode.rt != 0) { UnMap_GPR(Opcode.rt,TRUE); } BeforeCallDirect(m_RegWorkingSet); - MoveConstToVariable(Opcode.Hex, &Opcode.Hex, "Opcode.Hex" ); + MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); Call_Direct(R4300iOp::LDL, "R4300iOp::LDL"); AfterCallDirect(m_RegWorkingSet); -#endif } void CMipsMemoryVM::Compile_LDR (void) { OPCODE & Opcode = CRecompilerOps::m_Opcode; - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); if (Opcode.base != 0) { UnMap_GPR(Opcode.base,TRUE); } if (Opcode.rt != 0) { UnMap_GPR(Opcode.rt,TRUE); } BeforeCallDirect(m_RegWorkingSet); - MoveConstToVariable(Opcode.Hex, &Opcode.Hex, "Opcode.Hex" ); + MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); Call_Direct(R4300iOp::LDR, "R4300iOp::LDR"); AfterCallDirect(m_RegWorkingSet); -#endif } void CMipsMemoryVM::Compile_SB (void) @@ -3762,13 +3681,15 @@ void CMipsMemoryVM::Compile_SDC1 (void) } void CMipsMemoryVM::Compile_SDL (void) { + OPCODE & Opcode = R4300iOp::m_Opcode; + _Notify->BreakPoint(__FILE__,__LINE__); #ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); if (Opcode.base != 0) { UnMap_GPR(Opcode.base,TRUE); } if (Opcode.rt != 0) { UnMap_GPR(Opcode.rt,TRUE); } BeforeCallDirect(m_RegWorkingSet); - MoveConstToVariable(Opcode.Hex, &Opcode.Hex, "Opcode.Hex" ); + MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); Call_Direct(R4300iOp::SDL, "R4300iOp::SDL"); AfterCallDirect(m_RegWorkingSet); @@ -3776,13 +3697,15 @@ void CMipsMemoryVM::Compile_SDL (void) { } void CMipsMemoryVM::Compile_SDR (void) { + OPCODE & Opcode = R4300iOp::m_Opcode; + _Notify->BreakPoint(__FILE__,__LINE__); #ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); if (Opcode.base != 0) { UnMap_GPR(Opcode.base,TRUE); } if (Opcode.rt != 0) { UnMap_GPR(Opcode.rt,TRUE); } BeforeCallDirect(m_RegWorkingSet); - MoveConstToVariable(Opcode.Hex, &Opcode.Hex, "Opcode.Hex" ); + MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); Call_Direct(R4300iOp::SDR, "R4300iOp::SDR"); AfterCallDirect(m_RegWorkingSet); #endif diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h index 45c3997e8..6670c6cdf 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h @@ -3,7 +3,10 @@ class CMipsMemoryVM : public CTransVaddr, private CRecompilerOps, private R4300iOp, - private CPifRam + private CPifRam, + private CFlashram, + private CSram, + private CDMA { CMipsMemory_CallBack * const m_CBClass; diff --git a/Source/Project64/N64 System/Mips/OpCode Class.cpp b/Source/Project64/N64 System/Mips/OpCode Class.cpp index 8c6090cd2..e985a06e3 100644 --- a/Source/Project64/N64 System/Mips/OpCode Class.cpp +++ b/Source/Project64/N64 System/Mips/OpCode Class.cpp @@ -41,7 +41,7 @@ COpcode::COpcode ( DWORD VirtualAddress ): //set up the details about the current opcode m_opcode.VirtualAddress = VirtualAddress & ~3; if (!SetPC(m_opcode.VirtualAddress)) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } } @@ -84,7 +84,7 @@ bool COpcode::Next (void) { break; default: m_opcode.VirtualAddress += m_OpLen; - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } if (!_MMU->LW_VAddr(m_opcode.VirtualAddress,m_opcode.Hex)) { diff --git a/Source/Project64/N64 System/Mips/TLB Class.h b/Source/Project64/N64 System/Mips/TLB Class.h index 29ff5bbc8..db1c8770d 100644 --- a/Source/Project64/N64 System/Mips/TLB Class.h +++ b/Source/Project64/N64 System/Mips/TLB Class.h @@ -110,6 +110,9 @@ public: bool AddressDefined ( DWORD VAddr ); const TLB_ENTRY & TlbEntry ( int Entry) const { return m_tlb[Entry]; } + + bool PAddrToVAddr ( DWORD PAddr, DWORD & VAddr, DWORD & Index ); + //Change the Virtual address to a Phyiscal Address /*inline bool TranslateVaddr ( DWORD VAddr, DWORD &PAddr) const { diff --git a/Source/Project64/N64 System/Mips/TLB class.cpp b/Source/Project64/N64 System/Mips/TLB class.cpp index 335e59501..9bc8c6d70 100644 --- a/Source/Project64/N64 System/Mips/TLB class.cpp +++ b/Source/Project64/N64 System/Mips/TLB class.cpp @@ -204,13 +204,6 @@ void CTLB::SetupTLB_Entry (int index, bool Random) { } } -#ifdef tofix -bool CTLB::VAddrToRealAddr(DWORD VAddr, void * &RealAddress) { - if (TLB_ReadMap[VAddr >> 12] == 0) { return false; } - RealAddress = (BYTE *)(TLB_ReadMap[VAddr >> 12] + VAddr); - return true; -} - bool CTLB::PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index ) { for (int i = Index; i < 64; i++) @@ -226,5 +219,3 @@ bool CTLB::PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index ) } return false; } - -#endif diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index eaced5b09..6a29ef075 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -765,7 +765,6 @@ void CN64System::ExecuteCPU ( void ) _Notify->RefreshMenu(); g_RomFileSize = _Rom->GetRomSize(); - g_CicChip = _Rom->CicChipID(); CC_Core C_Core; C_Core.SetSettings(); @@ -896,6 +895,8 @@ void CN64System::SyncCPU (CN64System * const SecondCPU) { if (m_Reg.m_FPCR[0] != SecondCPU->m_Reg.m_FPCR[0]) { ErrorFound = true; } if (m_Reg.m_FPCR[31] != SecondCPU->m_Reg.m_FPCR[31]) { ErrorFound = true; } + if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW) { ErrorFound = true; } + if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW) { ErrorFound = true; } for (int z = 0; z < 0x100; z++) { @@ -950,45 +951,51 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU) { } #endif if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) { - Error.LogF("PROGRAM_COUNTER, 0x%X, 0x%X\r\n",m_Reg.m_PROGRAM_COUNTER,SecondCPU->m_Reg.m_PROGRAM_COUNTER); + Error.LogF("PROGRAM_COUNTER 0x%X, 0x%X\r\n",m_Reg.m_PROGRAM_COUNTER,SecondCPU->m_Reg.m_PROGRAM_COUNTER); } for (count = 0; count < 32; count ++) { if (m_Reg.m_GPR[count].DW != SecondCPU->m_Reg.m_GPR[count].DW) { - Error.LogF("GPR[%s] Different,0x%08X%08X, 0x%08X%08X\r\n",CRegName::GPR[count], + Error.LogF("GPR[%s] 0x%08X%08X, 0x%08X%08X\r\n",CRegName::GPR[count], m_Reg.m_GPR[count].W[1],m_Reg.m_GPR[count].W[0], SecondCPU->m_Reg.m_GPR[count].W[1],SecondCPU->m_Reg.m_GPR[count].W[0]); } } for (count = 0; count < 32; count ++) { if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW) { - Error.LogF("FPR[%s] Different,0x%08X%08X, 0x%08X%08X\r\n",CRegName::FPR[count], + Error.LogF("FPR[%s] 0x%08X%08X, 0x%08X%08X\r\n",CRegName::FPR[count], m_Reg.m_FPR[count].W[1],m_Reg.m_FPR[count].W[0], SecondCPU->m_Reg.m_FPR[count].W[1],SecondCPU->m_Reg.m_FPR[count].W[0]); } } for (count = 0; count < 32; count ++) { if (m_Reg.m_FPCR[count] != SecondCPU->m_Reg.m_FPCR[count]) { - Error.LogF("FPCR[%s] Different,0x%08X, 0x%08X\r\n",CRegName::FPR_Ctrl[count], + Error.LogF("FPCR[%s] 0x%08X, 0x%08X\r\n",CRegName::FPR_Ctrl[count], m_Reg.m_FPCR[count], SecondCPU->m_Reg.m_FPCR[count]); } } for (count = 0; count < 32; count ++) { if (m_Reg.m_CP0[count] != SecondCPU->m_Reg.m_CP0[count]) { - Error.LogF("CP0[%s] Different,0x%08X, 0x%08X\r\n",CRegName::Cop0[count], + Error.LogF("CP0[%s] 0x%08X, 0x%08X\r\n",CRegName::Cop0[count], m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]); } } + if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW) { + Error.LogF("HI Reg 0x%08X%08X, 0x%08X%08X\r\n",m_Reg.m_HI.UW[1],m_Reg.m_HI.UW[0],SecondCPU->m_Reg.m_HI.UW[1],SecondCPU->m_Reg.m_HI.UW[0]); + } + if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW) { + Error.LogF("LO Reg 0x%08X%08X, 0x%08X%08X\r\n",m_Reg.m_LO.UW[1],m_Reg.m_LO.UW[0], SecondCPU->m_Reg.m_LO.UW[1],SecondCPU->m_Reg.m_LO.UW[0]); + } if (m_NextTimer != SecondCPU->m_NextTimer) { - Error.LogF("Current Time is Different: %X %X\r\n",(DWORD)m_NextTimer,(DWORD)SecondCPU->m_NextTimer); + Error.LogF("Current Time: %X %X\r\n",(DWORD)m_NextTimer,(DWORD)SecondCPU->m_NextTimer); } if (m_SystemTimer.CurrentType() != SecondCPU->m_SystemTimer.CurrentType()) { - Error.LogF("Current Time Type is Different: %X %X\r\n",m_SystemTimer.CurrentType(),SecondCPU->m_SystemTimer.CurrentType()); + Error.LogF("Current Time Type: %X %X\r\n",m_SystemTimer.CurrentType(),SecondCPU->m_SystemTimer.CurrentType()); } if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) { - Error.LogF("RoundingModel is Different: %X %X\r\n",m_Reg.m_RoundingModel,SecondCPU->m_Reg.m_RoundingModel); + Error.LogF("RoundingModel: %X %X\r\n",m_Reg.m_RoundingModel,SecondCPU->m_Reg.m_RoundingModel); } if (_Settings->LoadBool(Game_SPHack)) { diff --git a/Source/Project64/N64 System/Recompiler/Code Section.cpp b/Source/Project64/N64 System/Recompiler/Code Section.cpp index cb791fd7f..c98856439 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Section.cpp @@ -150,7 +150,7 @@ void CCodeSection::CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo ExitRegS } if (_SyncSystem) { - Call_Direct(SyncToPC, "SyncToPC"); + Call_Direct(SyncSystem, "SyncSystem"); } #ifdef LinkBlocks if (bSMM_ValidFunc == false) @@ -243,7 +243,7 @@ void CCodeSection::CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo ExitRegS case CExitInfo::DoCPU_Action: MoveConstToX86reg((DWORD)_SystemEvents,x86_ECX); Call_Direct(AddressOf(CSystemEvents::ExecuteEvents),"CSystemEvents::ExecuteEvents"); - if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); } + if (_SyncSystem) { Call_Direct(SyncSystem, "SyncSystem"); } ExitCodeBlock(); break; case CExitInfo::DoSysCall: @@ -252,7 +252,7 @@ void CCodeSection::CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo ExitRegS PushImm32(bDelay ? "true" : "false", bDelay); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::DoSysCallException), "CRegisters::DoSysCallException"); - if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); } + if (_SyncSystem) { Call_Direct(SyncSystem, "SyncSystem"); } ExitCodeBlock(); } break; @@ -263,7 +263,7 @@ void CCodeSection::CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo ExitRegS PushImm32(bDelay ? "true" : "false", bDelay); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException"); - if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); } + if (_SyncSystem) { Call_Direct(SyncSystem, "SyncSystem"); } ExitCodeBlock(); } break; @@ -273,7 +273,7 @@ void CCodeSection::CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo ExitRegS if (NextInstruction == JUMP || NextInstruction == DELAY_SLOT) { X86BreakPoint(__FILE__,__LINE__); } - if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); } + if (_SyncSystem) { Call_Direct(SyncSystem, "SyncSystem"); } X86BreakPoint(__FILE__,__LINE__); MoveVariableToX86reg(this,"this",x86_ECX); Call_Direct(AddressOf(ResetRecompCode), "ResetRecompCode"); @@ -286,7 +286,7 @@ void CCodeSection::CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo ExitRegS MoveConstToX86reg(NextInstruction == JUMP || NextInstruction == DELAY_SLOT,x86_ECX); MoveVariableToX86reg(&TLBLoadAddress,"TLBLoadAddress",x86_EDX); Call_Direct(DoTLBMiss,"DoTLBMiss"); - if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); } + if (_SyncSystem) { Call_Direct(SyncSystem, "SyncSystem"); } Ret(); #endif break; @@ -372,7 +372,7 @@ void CCodeSection::GenerateSectionLinkage (void) m_RegWorkingSet.WriteBackRegisters(); UpdateCounters(m_RegWorkingSet,false,true); // WriteBackRegisters(Section); - // if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); } + // if (_SyncSystem) { Call_Direct(SyncSystem, "SyncSystem"); } // MoveConstToVariable(DELAY_SLOT,&NextInstruction,"NextInstruction"); PushImm32(stdstr_f("0x%08X",CRecompilerOps::CompilePC() + 4).c_str(),CRecompilerOps::CompilePC() + 4); diff --git a/Source/Project64/N64 System/Recompiler/Function Info.cpp b/Source/Project64/N64 System/Recompiler/Function Info.cpp index 9aa672871..7c164e13d 100644 --- a/Source/Project64/N64 System/Recompiler/Function Info.cpp +++ b/Source/Project64/N64 System/Recompiler/Function Info.cpp @@ -10,118 +10,3 @@ CCompiledFunc::CCompiledFunc( const CCodeBlock & CodeBlock ) : { } -#ifdef tofix - -CCompiledFunc::CCompiledFunc(DWORD StartAddress, DWORD PhysicalStartAddress) : - m_VEnterPC(StartAddress), - m_PEnterPC(PhysicalStartAddress), - m_VMinPC(StartAddress), - m_VMaxPC(StartAddress), - m_Function(NULL), - Next(NULL) -{ - for (int i = 0; i < (sizeof(MemContents) / sizeof(MemContents[0])); i++ ) - { - MemContents[i] = 0; - MemLocation[i] = NULL; - } -} - -bool CCompiledFunc::CompilerCodeBlock(void) -{ - DWORD StartTime = timeGetTime(); - WriteTraceF(TraceRecompiler,"Compile Block-Start: VEnterPC: %X PEnterPC",m_VEnterPC,m_PEnterPC); - - //if (bProfiling()) { m_Profile.StartTimer(Timer_GetBlockInfo); } - - CBlockInfo BlockInfo(*_PROGRAM_COUNTER, RecompPos); - //if (bProfiling()) { m_Profile.StartTimer(Timer_AnalyseBlock); } -#ifdef tofix - if (bProfiling()) { m_Profile.StartTimer(Timer_CompileBlock); } - _Notify->BreakPoint(__FILE__,__LINE__); - DWORD StartAddress; - if (!_TLB->TranslateVaddr(BlockInfo.StartVAddr,StartAddress)) - { - DisplayError("Ummm... Where does this block go\n%X",BlockInfo.StartVAddr); - return false; - } - MarkCodeBlock(StartAddress); - if (StartAddress < RdramSize()) { - CPU_Message("====== RDRAM: block (%X:%d) ======", StartAddress>>12,N64_Blocks.NoOfRDRamBlocks[StartAddress>>12]); - } else if (StartAddress >= 0x04000000 && StartAddress <= 0x04000FFC) { - CPU_Message("====== DMEM: block (%d) ======", N64_Blocks.NoOfDMEMBlocks); - } else if (StartAddress >= 0x04001000 && StartAddress <= 0x04001FFC) { - CPU_Message("====== IMEM: block (%d) ======", N64_Blocks.NoOfIMEMBlocks); - } else if (StartAddress >= 0x1FC00000 && StartAddress <= 0x1FC00800) { - CPU_Message("====== PIF ROM: block ======"); - } else { -#ifndef ROM_IN_MAPSPACE -#ifndef EXTERNAL_RELEASE - DisplayError("Ummm... Where does this block go"); -#endif - ExitThread(0); -#endif - } -#endif - CPU_Message("====== Code block ======"); - CPU_Message("VAddress: %X",BlockInfo.StartVAddr ); - CPU_Message("x86 code at: %X",BlockInfo.CompiledLocation); - CPU_Message("No of Sections: %d",BlockInfo.NoOfSections ); - CPU_Message("====== recompiled code ======"); - /*if (bLinkBlocks()) { - for (int count = 0; count < BlockInfo.NoOfSections; count ++) { - DisplaySectionInformation(&BlockInfo.ParentSection,count + 1,CBlockSection::GetNewTestValue()); - } - } - if (m_SyncSystem) { - //if ((DWORD)BlockInfo.CompiledLocation == 0x60A7B73B) { X86BreakPoint(__FILE__,__LINE__); } - //MoveConstToVariable((DWORD)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock"); - } - - BlockInfo.ParentSection.RegStart.Initilize(); - BlockInfo.ParentSection.RegWorking = BlockInfo.ParentSection.RegStart; - if (bLinkBlocks()) { - while (GenerateX86Code(BlockInfo,&BlockInfo.ParentSection,CBlockSection::GetNewTestValue())); - } else { - GenerateX86Code(BlockInfo,&BlockInfo.ParentSection,CBlockSection::GetNewTestValue()); - } - CompileExitCode(BlockInfo); - - CPU_Message("====== End of recompiled code ======"); - if (bProfiling()) { m_Profile.StartTimer(Timer_CompileDone); } - - info->SetVEndPC(BlockInfo.EndVAddr); -// info->SetFunctionAddr(BlockInfo.CompiledLocation); - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - _TLB->VAddrToRealAddr(info->VStartPC(),*(reinterpret_cast(&info->MemLocation[0]))); - info->MemLocation[1] = info->MemLocation[0] + 1; - info->MemContents[0] = *info->MemLocation[0]; - info->MemContents[1] = *info->MemLocation[1]; - if (bSMM_Protect()) - { - _MMU->ProtectMemory(info->VStartPC(),info->VEndPC()); - } - NextInstruction = NORMAL; - - if (bShowRecompMemSize()) - { - DWORD Size = RecompPos - RecompCode; - DWORD MB = Size / 0x100000; - Size -= MB * 0x100000; - DWORD KB = Size / 1024; - Size -= KB * 1024; - - DWORD TotalAvaliable = _MMU->GetRecompBufferSize() / 0x100000; - - DisplayMessage(0,"Memory used: %d mb %-3d kb %-3d bytes Total Available: %d mb",MB,KB,Size, TotalAvaliable); - } - if (bProfiling()) { m_Profile.StopTimer(); } -#endif - - DWORD TimeTaken = timeGetTime() - StartTime; - WriteTraceF(TraceRecompiler,"Compile Block-Done: %X-%X - Taken: %d",info->VStartPC(),info->VEndPC(),TimeTaken);*/ - return true; -} - -#endif \ No newline at end of file diff --git a/Source/Project64/N64 System/Recompiler/Function Map Class.cpp b/Source/Project64/N64 System/Recompiler/Function Map Class.cpp index ac4a073a1..0fb8a18ef 100644 --- a/Source/Project64/N64 System/Recompiler/Function Map Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Function Map Class.cpp @@ -17,6 +17,7 @@ bool CFunctionMap::AllocateMemory() { m_FunctionTable = (PCCompiledFunc_TABLE *)VirtualAlloc(NULL,0xFFFFF * sizeof(CCompiledFunc *),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); if (m_FunctionTable == NULL) { + WriteTrace(TraceError,"CFunctionMap::AllocateMemory: failed to allocate function table"); _Notify->FatalError(MSG_MEM_ALLOC_ERROR); return false; } @@ -26,6 +27,7 @@ bool CFunctionMap::AllocateMemory() { m_DelaySlotTable = (BYTE **)VirtualAlloc(NULL,0xFFFFF * sizeof(BYTE *),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); if (m_DelaySlotTable == NULL) { + WriteTrace(TraceError,"CFunctionMap::AllocateMemory: failed to allocate delay slot table"); _Notify->FatalError(MSG_MEM_ALLOC_ERROR); return false; } @@ -159,7 +161,7 @@ void CFunctionMap::Reset( bool AllocateMemory ) { m_FunctionTable = (CCompiledFunc *)VirtualAlloc(NULL,0xFFFFF * sizeof(CCompiledFunc *),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); if (m_FunctionTable == NULL) { - Notify().FatalError(MSG_MEM_ALLOC_ERROR); + _Notify->FatalError(MSG_MEM_ALLOC_ERROR); } } memset(m_FunctionTable,0,0xFFFFF * sizeof(DWORD)); @@ -175,7 +177,7 @@ CCompiledFunc * CFunctionMap::AddFunctionInfo( DWORD vAddr, DWORD pAddr ) table = new PCCompiledFunc[(0x1000 >> 2)]; if (table == NULL) { - Notify().FatalError(MSG_MEM_ALLOC_ERROR); + _Notify->FatalError(MSG_MEM_ALLOC_ERROR); } memset(table,0,sizeof(PCCompiledFunc) * (0x1000 >> 2)); } @@ -213,7 +215,7 @@ void CFunctionMap::Remove(CCompiledFunc * info) delete info; table[(vAddr & 0xFFF) >> 2] = NULL; } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } } */ \ No newline at end of file diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp index ec945630a..88fa997af 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp @@ -9,10 +9,7 @@ CRecompiler::CRecompiler(CProfiling & Profile, bool & EndEmulation ) : CRecompiler::~CRecompiler() { - for (int i = 0, n = m_Functions.size(); i < n; i++) - { - delete m_Functions[i]; - } + ResetRecompCode(); } void CRecompiler::Run() @@ -60,7 +57,7 @@ void CRecompiler::Run() } __except( _MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) { - Notify().DisplayError(MSG_UNKNOWN_MEM_ACTION); + _Notify->DisplayError(MSG_UNKNOWN_MEM_ACTION); } } @@ -101,9 +98,15 @@ void CRecompiler::RecompilerMain_VirtualTable ( void ) table = new PCCompiledFunc[(0x1000 >> 2)]; if (table == NULL) { - Notify().FatalError(MSG_MEM_ALLOC_ERROR); + WriteTrace(TraceError,"CRecompiler::RecompilerMain_VirtualTable: failed to allocate PCCompiledFunc"); + _Notify->FatalError(MSG_MEM_ALLOC_ERROR); } memset(table,0,sizeof(PCCompiledFunc) * (0x1000 >> 2)); + if (bSMM_Protect()) + { + WriteTraceF(TraceError,"Create Table (%X): Index = %d",table, PROGRAM_COUNTER >> 0xC); + _MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF); + } } table[TableEntry] = info; @@ -445,6 +448,19 @@ void CRecompiler::ResetRecompCode() { CRecompMemory::Reset(); CFunctionMap::Reset(); + + for (CCompiledFuncList::iterator iter = m_Functions.begin(); iter != m_Functions.end(); iter++) + { + CCompiledFunc * Func = iter->second; + while (Func != NULL) + { + CCompiledFunc * CurrentFunc = Func; + Func = Func->Next(); + + delete CurrentFunc; + } + } + m_Functions.clear(); } BYTE * CRecompiler::CompileDelaySlot(DWORD PC) @@ -1744,7 +1760,7 @@ void CRecompiler::RecompilerMain_ChangeMemory ( void ) CCompiledFunc * CRecompiler::CompilerCode ( void ) { - DWORD pAddr; + DWORD pAddr = 0; if (!_TransVaddr->TranslateVaddr(*_PROGRAM_COUNTER,pAddr)) { WriteTraceF(TraceError,"CRecompiler::CompilerCode: Failed to translate %X",*_PROGRAM_COUNTER); @@ -1756,14 +1772,16 @@ CCompiledFunc * CRecompiler::CompilerCode ( void ) { for (CCompiledFunc * Func = iter->second; Func != NULL; Func = Func->Next()) { - MD5Digest Hash; DWORD PAddr; - _TransVaddr->TranslateVaddr(Func->MinPC(),PAddr); - MD5(_MMU->Rdram() + PAddr,(Func->MaxPC() - Func->MinPC())+ 4).get_digest(Hash); - if (memcmp(Hash.digest,Func->Hash().digest,sizeof(Hash.digest)) == 0) + if (_TransVaddr->TranslateVaddr(Func->MinPC(),PAddr)) { - return Func; - } + MD5Digest Hash; + MD5(_MMU->Rdram() + PAddr,(Func->MaxPC() - Func->MinPC())+ 4).get_digest(Hash); + if (memcmp(Hash.digest,Func->Hash().digest,sizeof(Hash.digest)) == 0) + { + return Func; + } + } } } @@ -1772,7 +1790,6 @@ CCompiledFunc * CRecompiler::CompilerCode ( void ) DWORD StartTime = timeGetTime(); WriteTraceF(TraceRecompiler,"Compile Block-Start: Program Counter: %X pAddr: %X",*_PROGRAM_COUNTER,pAddr); - CCodeBlock CodeBlock(*_PROGRAM_COUNTER, RecompPos(),false); if (!CodeBlock.Compile()) { @@ -1796,37 +1813,31 @@ CCompiledFunc * CRecompiler::CompilerCode ( void ) } -bool CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON Reason ) { +void CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON Reason ) { WriteTraceF(TraceError,"CRecompiler::ClearRecompCode_Phys Not Implemented (Address: %X, Length: %d Reason: %d)",Address,length,Reason); - bool Result = true; -#ifdef tofix - if (!ClearRecompCode_Virt(Address + 0x80000000,length,Reason)) { Result = false; } - if (!ClearRecompCode_Virt(Address + 0xA0000000,length,Reason)) { Result = false; } - - if (g_UseTlb) + if (LookUpMode() == FuncFind_VirtualLookup) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - DWORD VAddr, Index = 0; - while (_TLB->PAddrToVAddr(Address,VAddr,Index)) + ClearRecompCode_Virt(Address + 0x80000000,length,Reason); + ClearRecompCode_Virt(Address + 0xA0000000,length,Reason); + + if (g_UseTlb) { - WriteTraceF(TraceRecompiler,"ClearRecompCode Vaddr %X len: %d",VAddr,length); - if (!ClearRecompCode_Virt(VAddr,length,Reason)) + DWORD VAddr, Index = 0; + while (_TLB->PAddrToVAddr(Address,VAddr,Index)) { - Result = false; + WriteTraceF(TraceRecompiler,"ClearRecompCode Vaddr %X len: %d",VAddr,length); + ClearRecompCode_Virt(VAddr,length,Reason); } } -#endif } - if (LookUpMode() == FuncFind_PhysicalLookup) +#ifdef tofix + else if (LookUpMode() == FuncFind_PhysicalLookup) { WriteTraceF(TraceRecompiler,"Reseting Jump Table, Addr: %X len: %d",Address,((length + 3) & ~3)); memset((BYTE *)JumpTable + Address,0,((length + 3) & ~3)); } - #endif - return Result; } void CRecompiler::ClearRecompCode_Virt(DWORD Address, int length,REMOVE_REASON Reason ) @@ -1837,6 +1848,7 @@ void CRecompiler::ClearRecompCode_Virt(DWORD Address, int length,REMOVE_REASON R { DWORD AddressIndex = Address >> 0xC; DWORD WriteStart = (Address & 0xFFC); + bool bUnProtect = false; length = ((length + 3) & ~0x3); BYTE ** DelaySlotFuncs = DelaySlotTable(); @@ -1844,6 +1856,7 @@ void CRecompiler::ClearRecompCode_Virt(DWORD Address, int length,REMOVE_REASON R if (WriteStart == 0 && DelaySlotFuncs[AddressIndex] != NULL) { DelaySlotFuncs[AddressIndex] = NULL; + _MMU->UnProtectMemory(Address,Address+ 4); } DWORD DataInBlock = 0x1000 - WriteStart; @@ -1853,7 +1866,10 @@ void CRecompiler::ClearRecompCode_Virt(DWORD Address, int length,REMOVE_REASON R PCCompiledFunc_TABLE & table = FunctionTable()[AddressIndex]; if (table) { - memset(((BYTE *)&table[0]) + WriteStart,0,DataToWrite); + WriteTraceF(TraceError,"Delete Table (%X): Index = %d",table, AddressIndex); + delete table; + table = NULL; + _MMU->UnProtectMemory(Address,Address + length); } if (DataLeft > 0) diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.h b/Source/Project64/N64 System/Recompiler/Recompiler Class.h index d1ca6fd61..813ff3942 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.h @@ -30,7 +30,7 @@ public: //Self modifying code methods void ClearRecompCode_Virt ( DWORD VirtualAddress, int length, REMOVE_REASON Reason ); - bool ClearRecompCode_Phys ( DWORD PhysicalAddress, int length, REMOVE_REASON Reason ); + void ClearRecompCode_Phys ( DWORD PhysicalAddress, int length, REMOVE_REASON Reason ); private: CCompiledFuncList m_Functions; diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Memory.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Memory.cpp index b88f900e8..05f1aba63 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Memory.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Memory.cpp @@ -22,6 +22,7 @@ bool CRecompMemory::AllocateMemory() BYTE * RecompCodeBase = (BYTE *)VirtualAlloc( NULL, MaxCompileBufferSize + 4, MEM_RESERVE|MEM_TOP_DOWN, PAGE_EXECUTE_READWRITE); if (RecompCodeBase==NULL) { + WriteTrace(TraceError,"CRecompMemory::AllocateMemory: failed to allocate RecompCodeBase"); _Notify->DisplayError(MSG_MEM_ALLOC_ERROR); return FALSE; } @@ -29,6 +30,7 @@ bool CRecompMemory::AllocateMemory() m_RecompCode = (BYTE *)VirtualAlloc( RecompCodeBase, InitialCompileBufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (m_RecompCode==NULL) { + WriteTrace(TraceError,"CRecompMemory::AllocateMemory: failed to commit initial buffer"); VirtualFree( RecompCodeBase, 0 , MEM_RELEASE); _Notify->DisplayError(MSG_MEM_ALLOC_ERROR); return FALSE; @@ -51,12 +53,13 @@ void CRecompMemory::CheckRecompMem ( void ) return; } LPVOID MemAddr = VirtualAlloc( m_RecompCode + m_RecompSize , IncreaseCompileBufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); - m_RecompSize += IncreaseCompileBufferSize; - if (MemAddr == NULL) { + WriteTrace(TraceError,"CRecompMemory::CheckRecompMem: failed to increase buffer"); _Notify->FatalError(MSG_MEM_ALLOC_ERROR); } + m_RecompSize += IncreaseCompileBufferSize; + } void CRecompMemory::Reset() diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp index 11424620e..c85018565 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp @@ -1768,7 +1768,8 @@ void CRecompilerOps::SPECIAL_JR (void) { m_Section->CompileExit(m_CompilePC,(DWORD)-1,m_RegWorkingSet,CExitInfo::Normal,TRUE,NULL); } else { if (IsConst(m_Opcode.rs)) { - memcpy(&m_Section->m_Jump.RegSet,&m_RegWorkingSet,sizeof(CRegInfo)); + UpdateCounters(m_RegWorkingSet,true,true); + m_Section->m_Jump.RegSet = m_RegWorkingSet; m_Section->GenerateSectionLinkage(); } else { if (IsMapped(m_Opcode.rs)) { @@ -1918,8 +1919,6 @@ void CRecompilerOps::SPECIAL_MTHI (void) { } void CRecompilerOps::SPECIAL_DSLLV (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix BYTE * Jump[2]; CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); @@ -1936,8 +1935,8 @@ void CRecompilerOps::SPECIAL_DSLLV (void) { CompConstToX86reg(x86_ECX,0x20); JaeLabel8("MORE32", 0); Jump[0] = m_RecompPos - 1; - ShiftLeftDouble(MipsRegHi(m_Opcode.rd),cMipsRegLo(m_Opcode.rd)); - ShiftLeftSign(cMipsRegLo(m_Opcode.rd)); + ShiftLeftDouble(cMipsRegMapHi(m_Opcode.rd),cMipsRegMapLo(m_Opcode.rd)); + ShiftLeftSign(cMipsRegMapLo(m_Opcode.rd)); JmpLabel8("continue", 0); Jump[1] = m_RecompPos - 1; @@ -1945,16 +1944,15 @@ void CRecompilerOps::SPECIAL_DSLLV (void) { CPU_Message(""); CPU_Message(" MORE32:"); *((BYTE *)(Jump[0]))=(BYTE)(m_RecompPos - Jump[0] - 1); - MoveX86RegToX86Reg(cMipsRegLo(m_Opcode.rd),MipsRegHi(m_Opcode.rd)); - XorX86RegToX86Reg(cMipsRegLo(m_Opcode.rd),cMipsRegLo(m_Opcode.rd)); + MoveX86RegToX86Reg(cMipsRegMapLo(m_Opcode.rd),cMipsRegMapHi(m_Opcode.rd)); + XorX86RegToX86Reg(cMipsRegMapLo(m_Opcode.rd),cMipsRegMapLo(m_Opcode.rd)); AndConstToX86Reg(x86_ECX,0x1F); - ShiftLeftSign(MipsRegHi(m_Opcode.rd)); + ShiftLeftSign(cMipsRegMapHi(m_Opcode.rd)); //continue: CPU_Message(""); CPU_Message(" continue:"); *((BYTE *)(Jump[1]))=(BYTE)(m_RecompPos - Jump[1] - 1); -#endif } void CRecompilerOps::SPECIAL_DSRLV (void) { @@ -2222,23 +2220,29 @@ void CRecompilerOps::SPECIAL_DIVU ( void) { } } -void CRecompilerOps::SPECIAL_DMULT (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix +void CRecompilerOps::SPECIAL_DMULT (void) +{ CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); if (m_Opcode.rs != 0) { UnMap_GPR(m_Opcode.rs,TRUE); } if (m_Opcode.rs != 0) { UnMap_GPR(m_Opcode.rt,TRUE); } - BeforeCallDirect(); + BeforeCallDirect(m_RegWorkingSet); MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); Call_Direct(R4300iOp::SPECIAL_DMULT, "R4300iOp::SPECIAL_DMULT"); - AfterCallDirect(); -#endif + AfterCallDirect(m_RegWorkingSet); } void CRecompilerOps::SPECIAL_DMULTU (void) { CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + UnMap_GPR(m_Opcode.rs,TRUE); + UnMap_GPR(m_Opcode.rt,TRUE); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); + Call_Direct(R4300iOp::SPECIAL_DMULTU, "R4300iOp::SPECIAL_DMULTU"); + AfterCallDirect(m_RegWorkingSet); + +#ifdef toremove /* _RegLO->UDW = (uint64)_GPR[m_Opcode.rs].UW[0] * (uint64)_GPR[m_Opcode.rt].UW[0]; */ X86Protected(x86_EDX) = TRUE; Map_TempReg(x86_EAX,m_Opcode.rs,FALSE); @@ -2303,6 +2307,7 @@ void CRecompilerOps::SPECIAL_DMULTU (void) { AddX86regToVariable(x86_EDX, &_RegHI->UW[0], "_RegHI->UW[0]"); AdcConstToVariable(&_RegHI->UW[1], "_RegHI->UW[1]", 0); +#endif } void CRecompilerOps::SPECIAL_DDIV (void) { @@ -3232,8 +3237,6 @@ void CRecompilerOps::SPECIAL_SLTU (void) { } void CRecompilerOps::SPECIAL_DADD (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); if (m_Opcode.rd == 0) { return; } @@ -3255,24 +3258,21 @@ void CRecompilerOps::SPECIAL_DADD (void) { Map_GPR_64bit(m_Opcode.rd,source1); if (IsConst(source2)) { - AddConstToX86Reg(cMipsRegLo(m_Opcode.rd),cMipsRegLo(source2)); - AddConstToX86Reg(MipsRegHi(m_Opcode.rd),MipsRegHi(source2)); + AddConstToX86Reg(cMipsRegMapLo(m_Opcode.rd),cMipsRegLo(source2)); + AddConstToX86Reg(cMipsRegMapHi(m_Opcode.rd),MipsRegHi(source2)); } else if (IsMapped(source2)) { x86Reg HiReg = Is64Bit(source2)?MipsRegMapHi(source2):Map_TempReg(x86_Any,source2,TRUE); ProtectGPR(source2); AddX86RegToX86Reg(cMipsRegMapLo(m_Opcode.rd),cMipsRegMapLo(source2)); AdcX86RegToX86Reg(cMipsRegMapHi(m_Opcode.rd),HiReg); } else { - AddVariableToX86reg(cMipsRegLo(m_Opcode.rd),&_GPR[source2].W[0],CRegName::GPR_Lo[source2]); - AdcVariableToX86reg(MipsRegHi(m_Opcode.rd),&_GPR[source2].W[1],CRegName::GPR_Hi[source2]); + AddVariableToX86reg(cMipsRegMapLo(m_Opcode.rd),&_GPR[source2].W[0],CRegName::GPR_Lo[source2]); + AdcVariableToX86reg(cMipsRegMapHi(m_Opcode.rd),&_GPR[source2].W[1],CRegName::GPR_Hi[source2]); } } -#endif } void CRecompilerOps::SPECIAL_DADDU (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); if (m_Opcode.rd == 0) { return; } @@ -3294,24 +3294,21 @@ void CRecompilerOps::SPECIAL_DADDU (void) { Map_GPR_64bit(m_Opcode.rd,source1); if (IsConst(source2)) { - AddConstToX86Reg(cMipsRegLo(m_Opcode.rd),cMipsRegLo(source2)); - AddConstToX86Reg(MipsRegHi(m_Opcode.rd),MipsRegHi(source2)); + AddConstToX86Reg(cMipsRegMapLo(m_Opcode.rd),cMipsRegLo(source2)); + AddConstToX86Reg(cMipsRegMapHi(m_Opcode.rd),MipsRegHi(source2)); } else if (IsMapped(source2)) { x86Reg HiReg = Is64Bit(source2)?MipsRegMapHi(source2):Map_TempReg(x86_Any,source2,TRUE); ProtectGPR(source2); AddX86RegToX86Reg(cMipsRegMapLo(m_Opcode.rd),cMipsRegMapLo(source2)); AdcX86RegToX86Reg(cMipsRegMapHi(m_Opcode.rd),HiReg); } else { - AddVariableToX86reg(cMipsRegLo(m_Opcode.rd),&_GPR[source2].W[0],CRegName::GPR_Lo[source2]); - AdcVariableToX86reg(MipsRegHi(m_Opcode.rd),&_GPR[source2].W[1],CRegName::GPR_Hi[source2]); + AddVariableToX86reg(cMipsRegMapLo(m_Opcode.rd),&_GPR[source2].W[0],CRegName::GPR_Lo[source2]); + AdcVariableToX86reg(cMipsRegMapHi(m_Opcode.rd),&_GPR[source2].W[1],CRegName::GPR_Hi[source2]); } } -#endif } void CRecompilerOps::SPECIAL_DSUB (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); if (m_Opcode.rd == 0) { return; } @@ -3332,25 +3329,24 @@ void CRecompilerOps::SPECIAL_DSUB (void) { x86Reg HiReg = Map_TempReg(x86_Any,m_Opcode.rt,TRUE); x86Reg LoReg = Map_TempReg(x86_Any,m_Opcode.rt,FALSE); Map_GPR_64bit(m_Opcode.rd,m_Opcode.rs); - SubX86RegToX86Reg(cMipsRegLo(m_Opcode.rd),LoReg); + SubX86RegToX86Reg(cMipsRegMapLo(m_Opcode.rd),LoReg); SbbX86RegToX86Reg(cMipsRegMapHi(m_Opcode.rd),HiReg); return; } Map_GPR_64bit(m_Opcode.rd,m_Opcode.rs); if (IsConst(m_Opcode.rt)) { - SubConstFromX86Reg(cMipsRegLo(m_Opcode.rd),cMipsRegLo(m_Opcode.rt)); - SbbConstFromX86Reg(MipsRegHi(m_Opcode.rd),MipsRegHi(m_Opcode.rt)); + SubConstFromX86Reg(cMipsRegMapLo(m_Opcode.rd),cMipsRegLo(m_Opcode.rt)); + SbbConstFromX86Reg(cMipsRegMapHi(m_Opcode.rd),MipsRegHi(m_Opcode.rt)); } else if (IsMapped(m_Opcode.rt)) { x86Reg HiReg = Is64Bit(m_Opcode.rt)?cMipsRegMapHi(m_Opcode.rt):Map_TempReg(x86_Any,m_Opcode.rt,TRUE); ProtectGPR(m_Opcode.rt); - SubX86RegToX86Reg(cMipsRegLo(m_Opcode.rd),cMipsRegLo(m_Opcode.rt)); + SubX86RegToX86Reg(cMipsRegMapLo(m_Opcode.rd),cMipsRegMapLo(m_Opcode.rt)); SbbX86RegToX86Reg(cMipsRegMapHi(m_Opcode.rd),HiReg); } else { - SubVariableFromX86reg(cMipsRegLo(m_Opcode.rd),&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]); - SbbVariableFromX86reg(MipsRegHi(m_Opcode.rd),&_GPR[m_Opcode.rt].W[1],CRegName::GPR_Hi[m_Opcode.rt]); + SubVariableFromX86reg(cMipsRegMapLo(m_Opcode.rd),&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]); + SbbVariableFromX86reg(cMipsRegMapHi(m_Opcode.rd),&_GPR[m_Opcode.rt].W[1],CRegName::GPR_Hi[m_Opcode.rt]); } } -#endif } void CRecompilerOps::SPECIAL_DSUBU (void) { @@ -4232,7 +4228,7 @@ void CRecompilerOps::COP1_S_CMP (void) { CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); m_Section->CompileCop1Test(); - if ((m_Opcode.funct & 1) != 0) { CRecompilerOps::UnknownOpcode(); } + if ((m_Opcode.funct & 7) == 0) { CRecompilerOps::UnknownOpcode(); } if ((m_Opcode.funct & 2) != 0) { cmp |= 0x4000; } if ((m_Opcode.funct & 4) != 0) { cmp |= 0x0100; } @@ -4392,12 +4388,9 @@ void CRecompilerOps::COP1_D_DIV (void) { } void CRecompilerOps::COP1_D_ABS (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); fpuAbs(); -#endif } void CRecompilerOps::COP1_D_NEG (void) { @@ -4407,12 +4400,9 @@ void CRecompilerOps::COP1_D_NEG (void) { } void CRecompilerOps::COP1_D_SQRT (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); fpuSqrt(); -#endif } void CRecompilerOps::COP1_D_MOV (void) { @@ -4675,23 +4665,19 @@ void CRecompilerOps::COP1_L_CVT_D (void) { /************************** Other functions **************************/ void CRecompilerOps::UnknownOpcode (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - CPU_Message(" %X Unhandled Opcode: %s",m_CompilePC, R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X Unhandled Opcode: %s",m_CompilePC, R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); -// FreeSection(m_Section->m_ContinueSection,m_Section); -// FreeSection(m_Section->m_JumpSection,m_Section); - m_RegWorkingSet.BlockCycleCount() -= CountPerOp; - m_RegWorkingSet.BlockRandomModifier() -= 1; - MoveConstToVariable(m_CompilePC,_PROGRAM_COUNTER,"PROGRAM_COUNTER"); m_RegWorkingSet.WriteBackRegisters(); - UpdateCounters(&m_RegWorkingSet.BlockCycleCount(),&m_RegWorkingSet.BlockRandomModifier(),FALSE); - if (CPU_Type == CPU_SyncCores) { Call_Direct(SyncToPC, "SyncToPC"); } - MoveConstToVariable(Opcode.Hex,&Opcode.Hex,"Opcode.Hex"); + UpdateCounters(m_RegWorkingSet,false,true); + MoveConstToVariable(m_CompilePC,&_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); + if (_SyncSystem) { Call_Direct(SyncSystem, "SyncSystem"); } + + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_CountPerOp); + + MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); Call_Direct(R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode"); Ret(); if (m_NextInstruction == NORMAL) { m_NextInstruction = END_BLOCK; } -#endif } void CRecompilerOps::BeforeCallDirect ( CRegInfo & RegSet ) @@ -4710,6 +4696,9 @@ void CRecompilerOps::EnterCodeBlock ( void ) { #ifdef _DEBUG Push(x86_ESI); +#else + Push(x86_ESI); + Push(x86_EBX); #endif } @@ -4717,6 +4706,9 @@ void CRecompilerOps::ExitCodeBlock ( void ) { #ifdef _DEBUG Pop(x86_ESI); +#else + Pop(x86_EBX); + Pop(x86_ESI); #endif Ret(); } diff --git a/Source/Project64/N64 System/Recompiler/Section Info.cpp b/Source/Project64/N64 System/Recompiler/Section Info.cpp index 9b989407e..7cff4fe76 100644 --- a/Source/Project64/N64 System/Recompiler/Section Info.cpp +++ b/Source/Project64/N64 System/Recompiler/Section Info.cpp @@ -151,7 +151,7 @@ void CCodeSection::UnlinkParent( CCodeSection * Parent, bool AllowDelete, bool C // { // if (!ContinueSection && Parent->ContinueSection == this) // { -// Notify().BreakPoint(__FILE__,__LINE__); +// _Notify->BreakPoint(__FILE__,__LINE__); // } // } if (ContinueSection && Parent->ContinueSection == this) @@ -162,7 +162,7 @@ void CCodeSection::UnlinkParent( CCodeSection * Parent, bool AllowDelete, bool C // { // if (ContinueSection && Parent->JumpSection == this) // { -// Notify().BreakPoint(__FILE__,__LINE__); +// _Notify->BreakPoint(__FILE__,__LINE__); // } // } if (!ContinueSection && Parent->JumpSection == this) @@ -201,7 +201,7 @@ CCodeSection::~CCodeSection ( void ) ContinueSection->UnlinkParent(this, true, true); if (ContinueSection) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } ContinueSection = NULL; } @@ -210,7 +210,7 @@ CCodeSection::~CCodeSection ( void ) JumpSection->UnlinkParent(this, true, false); if (JumpSection) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } JumpSection = NULL; } @@ -274,7 +274,7 @@ void CCodeSection::AddParent(CCodeSection * Parent ) } else if (Parent->JumpSection == this) { RegStart = Parent->Jump.RegSet; } else { - Notify().DisplayError("How are these sections joined?????"); + _Notify->DisplayError("How are these sections joined?????"); } RegWorking = RegStart; } else { diff --git a/Source/Project64/N64 System/Recompiler/X86ops.cpp b/Source/Project64/N64 System/Recompiler/X86ops.cpp index 41b1cfa66..9462703f7 100644 --- a/Source/Project64/N64 System/Recompiler/X86ops.cpp +++ b/Source/Project64/N64 System/Recompiler/X86ops.cpp @@ -51,7 +51,7 @@ void CX86Ops::AdcConstToX86Reg (x86Reg reg, DWORD Const) { void CX86Ops::AdcVariableToX86reg(x86Reg reg, void * Variable, const char * VariableName) { CPU_Message(" adc %s, dword ptr [%s]",x86_Name(reg),VariableName); - PUTDST16(m_RecompPos,0x0513 + (reg * 0x100)); + PUTDST16(m_RecompPos,0x0513 + (reg * 0x800)); PUTDST32(m_RecompPos,Variable); } diff --git a/Source/Project64/Plugins/Plugin Class.cpp b/Source/Project64/Plugins/Plugin Class.cpp index b5febb810..402f6c3ad 100644 --- a/Source/Project64/Plugins/Plugin Class.cpp +++ b/Source/Project64/Plugins/Plugin Class.cpp @@ -59,7 +59,7 @@ void CPlugins::CreatePlugins( void ) { if (_Settings->LoadBool(Debugger_Enabled)) { - Notify().RefreshMenu(); + _Notify->RefreshMenu(); } } diff --git a/Source/Project64/Project64.dsp b/Source/Project64/Project64.dsp index 71f42232c..458d38fe8 100644 --- a/Source/Project64/Project64.dsp +++ b/Source/Project64/Project64.dsp @@ -354,10 +354,18 @@ SOURCE="N64 System\Mips\Audio.cpp" # End Source File # Begin Source File +SOURCE=".\N64 System\Mips\Dma.cpp" +# End Source File +# Begin Source File + SOURCE=".\N64 System\Mips\Eeprom.cpp" # End Source File # Begin Source File +SOURCE=".\N64 System\Mips\FlashRam.cpp" +# End Source File +# Begin Source File + SOURCE="N64 System\Mips\Memory Labels Class.cpp" # End Source File # Begin Source File @@ -386,6 +394,10 @@ SOURCE="N64 System\Mips\Register Class.cpp" # End Source File # Begin Source File +SOURCE=".\N64 System\Mips\Sram.cpp" +# End Source File +# Begin Source File + SOURCE=".\N64 System\Mips\System Events.cpp" # End Source File # Begin Source File @@ -418,14 +430,6 @@ SOURCE=".\N64 System\C Core\CPU Log.cpp" # End Source File # Begin Source File -SOURCE="N64 System\C Core\Dma.cpp" -# End Source File -# Begin Source File - -SOURCE=".\N64 System\C Core\FlashRam.cpp" -# End Source File -# Begin Source File - SOURCE=".\N64 System\C Core\Logging.cpp" # End Source File # Begin Source File @@ -434,10 +438,6 @@ SOURCE=".\N64 System\C Core\Mempak.cpp" # End Source File # Begin Source File -SOURCE=".\N64 System\C Core\Pif.cpp" -# End Source File -# Begin Source File - SOURCE=".\N64 System\C Core\r4300i Commands.cpp" # End Source File # Begin Source File @@ -446,10 +446,6 @@ SOURCE=".\N64 System\C Core\r4300i Registers.cpp" # End Source File # Begin Source File -SOURCE=".\N64 System\C Core\Sram.cpp" -# End Source File -# Begin Source File - SOURCE=".\N64 System\C Core\Win32Timer.cpp" # End Source File # End Group @@ -975,6 +971,10 @@ SOURCE="N64 System\Mips\Audio.h" # End Source File # Begin Source File +SOURCE=".\N64 System\Mips\Dma.h" +# End Source File +# Begin Source File + SOURCE=".\N64 System\Mips\Eeprom.h" # End Source File # Begin Source File @@ -983,6 +983,10 @@ SOURCE=".\N64 System\Mips\Exception.h" # End Source File # Begin Source File +SOURCE=".\N64 System\Mips\FlashRam.h" +# End Source File +# Begin Source File + SOURCE="N64 System\Mips\Memory Class.h" # End Source File # Begin Source File @@ -1015,6 +1019,10 @@ SOURCE="N64 System\Mips\Register Class.h" # End Source File # Begin Source File +SOURCE=".\N64 System\Mips\Sram.h" +# End Source File +# Begin Source File + SOURCE=".\N64 System\Mips\System Events.h" # End Source File # Begin Source File @@ -1059,10 +1067,6 @@ SOURCE="N64 System\C Core\Debugger.h" # End Source File # Begin Source File -SOURCE="N64 System\C Core\Dma.h" -# End Source File -# Begin Source File - SOURCE="N64 System\C Core\Eeprom.h" # End Source File # Begin Source File @@ -1083,10 +1087,6 @@ SOURCE="N64 System\C Core\MEMPAK.H" # End Source File # Begin Source File -SOURCE="N64 System\C Core\Pif.h" -# End Source File -# Begin Source File - SOURCE="N64 System\C Core\r4300i Commands.h" # End Source File # Begin Source File @@ -1099,10 +1099,6 @@ SOURCE="N64 System\C Core\r4300i Registers.h" # End Source File # Begin Source File -SOURCE="N64 System\C Core\Sram.h" -# End Source File -# Begin Source File - SOURCE="N64 System\C Core\Win32Timer.h" # End Source File # End Group diff --git a/Source/Project64/Settings.h b/Source/Project64/Settings.h index d7fca81f5..9ae624dfb 100644 --- a/Source/Project64/Settings.h +++ b/Source/Project64/Settings.h @@ -232,176 +232,6 @@ enum SettingID { FirstAudioSettings, LastAudioSettings = FirstAudioSettings + MaxPluginSetting, FirstCtrlDefaultSet, LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting, FirstCtrlSettings, LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting, - - -/* No_Default, Default_False, Default_True, Default_Language, Default_RdramSize, - Default_RomStatus,Default_RomBrowserWidth,Default_RomBrowserHeight, - Default_RememberedRomFiles, Default_RememberedRomDirs, Default_CheatExt, - Default_SelfModCheck, Default_BlockLinking, Default_SaveSlot, Default_FunctionLookup, - Default_LogLevel, Default_FrameDisplayType, - - //Settings - UseSettingFromRegistry, - - //Language - CurrentLanguage, - - //Gui Settings - MainWindowTop, MainWindowLeft, RomBrowser, RomBrowserRecursive, - RomBrowserSortFieldIndex, RomBrowserSortAscendingIndex, - RomBrowserWidth, RomBrowserHeight,RomBrowserTop, RomBrowserLeft, RomBrowserMaximized, - RomBrowserPosIndex, RomBrowserWidthIndex, TLBWindowTop, TLBWindowLeft, - - //Beta Settings - IsBetaVersion, BetaUserName, BetaUserNameMD5, BetaEmailAddress, BetaEmailAddressMD5, BetaVersion, - IsValidExe, - - //General Settings - AutoSleep, AutoFullScreen, AutoStart, AutoZip, BasicMode, RememberCheats, - DisableScrSaver, ShowCPUPer, LogFunctionCalls, ProfileCode, GenerateLogFiles, - LimitFPS, AlwaysOnTop, GenerateDebugLog, UseHighLevelGfx, UseHighLevelAudio, - DisableGameFixes, AppLogLevel, AppLogFlush, DisplayFrameRate, FrameDisplayType, - - - //Debugger - Debugger, ShowUnhandledMemory, ShowPifErrors, ShowDListAListCount, ShowCheckOpUsageErrors, - ShowRecompMemSize, ShowPifRamErrors, - - //Recent Files and Directories - RememberedRomFilesCount, RecentRomFileIndex, RememberedRomDirCount, RecentRomDirIndex, - - //Directories - InitialPluginDirectory, PluginDirectory, SelectedPluginDirectory, UsePluginDirSelected, - InitialRomDirectory, RomDirectory, SelectedRomDir, UseRomDirSelected, - InitialSaveDirectory, SaveDirectory, SelectedSaveDirectory, UseSaveDirSelected, - InitialInstantSaveDirectory, InstantSaveDirectory, SelectedInstantSaveDirectory, UseInstantDirSelected, - InitialSnapShotDir, SnapShotDir, SelectedSnapShotDir, UseSnapShotDirSelected, - SyncPluginDir, LastSaveDir, InitialTextureDir, TextureDir, - - //Support Files - RomDatabaseFile, CheatIniName, SettingsIniName, NotesIniName, ExtIniName, ShortCutFile, - RomListCache, ZipCacheIniName, - - //Plugins - DefaultRSP_Plugin, DefaultGFX_Plugin, DefaultAUDIO_Plugin, DefaultCONT_Plugin, - CurrentRSP_Plugin, CurrentGFX_Plugin, CurrentAUDIO_Plugin, CurrentCONT_Plugin, - CurVerRSP_Plugin, CurVerGFX_Plugin, CurVerAUDIO_Plugin, CurVerCONT_Plugin, - RSP_PluginChanged, GFX_PluginChanged, AUDIO_PluginChanged, CONT_PluginChanged, - FirstRSPDefaultSet, LastRSPDefaultSet = FirstRSPDefaultSet + MaxPluginSetting, - FirstRSPSettings, LastRSPSettings = FirstRSPSettings + MaxPluginSetting, - FirstGfxDefaultSet, LastGfxDefaultSet = FirstGfxDefaultSet + MaxPluginSetting, - FirstGfxSettings, LastGfxSettings = FirstGfxSettings + MaxPluginSetting, - FirstAudioDefaultSet, LastAudioDefaultSet = FirstAudioDefaultSet + MaxPluginSetting, - FirstAudioSettings, LastAudioSettings = FirstAudioSettings + MaxPluginSetting, - FirstCtrlDefaultSet, LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting, - FirstCtrlSettings, LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting, - - //Cheats - CheatEntry, LastCheatEntry = CheatEntry + MaxCheats, - CheatPermEntry, LastPermCheatEntry = CheatPermEntry + MaxCheats, - CheatOptions, LastCheatOptions = CheatOptions + MaxCheats, - CheatRange, LastCheatRange = CheatRange + MaxCheats, - CheatRangeNotes,LastCheatRangeNotes= CheatRangeNotes+ MaxCheats, - CheatNotes, LastCheatNotes = CheatNotes + MaxCheats, - CheatActive, LastCheatActive = CheatActive + MaxCheats, - CheatExtension, LastCheatExtension = CheatExtension + MaxCheats, - - //Individual Game Settings - Game_SaveChip, - Game_LastSaveSlot, - - //RDB Settings - Rdb_SaveChip, - - //Default Values - System_SaveChip, - - //Rom Settings - Default_CPUType, - Default_CFactor, - ROM_IniKey, - ROM_NAME, - ROM_GoodName, - ROM_MD5, ROM_LastMD5 = ROM_MD5 + MaxMD5_Per_Rom, - ROM_InternalName, - ROM_Default, - ROM_CPUType, - ROM_RomInMemory, - ROM_FunctionLookup, - ROM_RamSize, - ROM_Status, - ROM_CoreNotes, - ROM_PluginNotes, - ROM_CounterFactor, - ROM_CustomSMM, - ROM_SMM_Cache, - ROM_SMM_PIDMA, - ROM_SMM_TLB, - ROM_SMM_Protect, - ROM_SMM_ValidFunc, - ROM_SyncAudio, - ROM_UseTlb, - ROM_RegCache, - ROM_BlockLinking, - ROM_UseJumpTable, - ROM_DelayDlists, - ROM_DelaySI, - ROM_AudioSignal, - ROM_SPHack, - ROM_FixedAudio, - - //Rom TLB Settings - ROM_TLB_VAddrStart, - ROM_TLB_VAddrLen, - ROM_TLB_PAddrStart, - - - //System Settings - SYSTEM_CPUType, - SYSTEM_RDRamSize, - SYSTEM_SelfModMethod, - SYSTEM_BlockLinking, - SYSTEM_FunctionLookup, - SYSTEM_SMM_Cache, //DWORD - Self mod method (clear code on clearing instruction cache) - SYSTEM_SMM_PIDMA, //DWORD - Self mod method (clear code on PI DMA blocks) - SYSTEM_SMM_ValidFunc, //DWORD - Self mod method (Compare memory contents of function on finding) - SYSTEM_SMM_Protect, //DWORD - Self mod method (Protect Memory from any write to the code pages) - SYSTEM_SMM_TLB, //DWORD - Self mod method (clear code on TLB unmapping) - - //Currrent Running Information - RamSize, //DWORD - Size of RDRAM - CPUType, //DWORD - Current CPU - CPU_Paused, //bool - Is CPU Paused - CPU_Paused_type, //DWORD - What type of pause is it - SMM_ChangeMemory, - SMM_CheckMemory2, - SMM_CheckMemoryCache, - BlockLinking, - FuncLookupMode, - DelayDlists, //DWORD - Delay when interrupt is set for DLIST - DelaySI, - CounterFactor, //DWORD - how many cycles each Opcode takes, 0 for variable - UseTLB, - UseJumpTable, - RomInMemory, - SyncViaAudio, - AudioSignal, - - //Temporay Keys - ApplicationName, //String - LoadingRom, //bool - CPU_Running, //bool - FirstDMA, //bool - CurrentSaveState,//DWORD - ScreenHertz, //DWORD - InstantSaveFile, //String - InFullScreen, //bool - SMM_Cache, //bool - Self mod method (clear code on clearing instruction cache) - SMM_PIDMA, //bool - Self mod method (clear code on PI DMA blocks) - SMM_ValidFunc, //bool - Self mod method (Compare memory contents of function on finding) - SMM_Protect, //bool - Self mod method (Protect Memory from any write to the code pages) - SMM_TLB, //bool - Self mod method (clear code on TLB unmapping) -*/ }; #include "Support.h" diff --git a/Source/Project64/Settings/SettingType/SettingsType-Application.cpp b/Source/Project64/Settings/SettingType/SettingsType-Application.cpp index 555abdd3a..aecf87031 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-Application.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-Application.cpp @@ -96,7 +96,7 @@ bool CSettingTypeApplication::Load ( int Index, bool & Value ) const Value = dwValue != 0; } } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } if (!bRes && m_DefaultSetting != Default_None) @@ -118,7 +118,7 @@ bool CSettingTypeApplication::Load ( int Index, ULONG & Value ) const { bRes = m_SettingsIniFile->GetNumber(SectionName(),m_KeyNameIdex.c_str(),Value,Value); } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } if (!bRes && m_DefaultSetting != Default_None) { @@ -149,7 +149,7 @@ bool CSettingTypeApplication::Load ( int Index, stdstr & Value ) const bRes = false; } } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } if (!bRes) { @@ -205,7 +205,7 @@ void CSettingTypeApplication::Save ( int Index, bool Value ) { m_SettingsIniFile->SaveNumber(SectionName(),m_KeyNameIdex.c_str(),Value); } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } } @@ -215,7 +215,7 @@ void CSettingTypeApplication::Save ( int Index, ULONG Value ) { m_SettingsIniFile->SaveNumber(SectionName(),m_KeyNameIdex.c_str(),Value); } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } } @@ -225,7 +225,7 @@ void CSettingTypeApplication::Save ( int Index, const stdstr & Value ) { m_SettingsIniFile->SaveString(SectionName(),m_KeyNameIdex.c_str(),Value.c_str()); } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } } @@ -235,7 +235,7 @@ void CSettingTypeApplication::Save ( int Index, const char * Value ) { m_SettingsIniFile->SaveString(SectionName(),m_KeyNameIdex.c_str(),Value); } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } } @@ -260,6 +260,6 @@ void CSettingTypeApplication::Delete( int Index ) { m_SettingsIniFile->SaveString(SectionName(),m_KeyNameIdex.c_str(),NULL); } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } } diff --git a/Source/Project64/Settings/SettingType/SettingsType-Cheats.cpp b/Source/Project64/Settings/SettingType/SettingsType-Cheats.cpp index e60fe6ffb..0104848d9 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-Cheats.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-Cheats.cpp @@ -53,18 +53,18 @@ LPCSTR CSettingTypeCheats::SectionName ( void ) const void CSettingTypeCheats::UpdateSettings ( void * ) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); }*/ bool CSettingTypeCheats::Load ( int Index, bool & Value ) const { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); return false; } bool CSettingTypeCheats::Load ( int Index, ULONG & Value ) const { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); return false; } @@ -81,28 +81,28 @@ bool CSettingTypeCheats::Load ( int Index, stdstr & Value ) const //return the default values void CSettingTypeCheats::LoadDefault ( int Index, bool & Value ) const { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } void CSettingTypeCheats::LoadDefault ( int Index, ULONG & Value ) const { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } void CSettingTypeCheats::LoadDefault ( int Index, stdstr & Value ) const { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } //Update the settings void CSettingTypeCheats::Save ( int Index, bool Value ) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } void CSettingTypeCheats::Save ( int Index, ULONG Value ) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } void CSettingTypeCheats::Save ( int Index, const stdstr & Value ) diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp b/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp index 0a06a6427..021357a69 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp @@ -44,13 +44,13 @@ bool CSettingTypeRDBYesNo::Load ( int Index, bool & Value ) const bool CSettingTypeRDBYesNo::Load ( int Index, ULONG & Value ) const { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); return false; } bool CSettingTypeRDBYesNo::Load ( int Index, stdstr & Value ) const { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); return false; } @@ -70,12 +70,12 @@ void CSettingTypeRDBYesNo::LoadDefault ( int Index, bool & Value ) const void CSettingTypeRDBYesNo::LoadDefault ( int Index, ULONG & Value ) const { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } void CSettingTypeRDBYesNo::LoadDefault ( int Index, stdstr & Value ) const { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } @@ -92,12 +92,12 @@ void CSettingTypeRDBYesNo::Save ( int Index, ULONG Value ) void CSettingTypeRDBYesNo::Save ( int Index, const stdstr & Value ) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } void CSettingTypeRDBYesNo::Save ( int Index, const char * Value ) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } void CSettingTypeRDBYesNo::Delete( int Index ) diff --git a/Source/Project64/Settings/Settings Class.cpp b/Source/Project64/Settings/Settings Class.cpp index 7a96b7278..9c9a354fa 100644 --- a/Source/Project64/Settings/Settings Class.cpp +++ b/Source/Project64/Settings/Settings Class.cpp @@ -341,7 +341,7 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def case SettingType_ConstValue: if (DataType != Data_DWORD) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); return; } _this->AddHandler(ID,new CSettingTypeTempNumber(Value)); @@ -349,7 +349,7 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def case SettingType_ConstString: if (DataType != Data_String) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); return; } _this->AddHandler(ID,new CSettingTypeTempString(DefaultStr)); @@ -375,7 +375,7 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def } break; default: - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } break; case SettingType_GameSetting: @@ -400,7 +400,7 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def } break; default: - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } } break; @@ -424,11 +424,11 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def } break; default: - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } break; default: - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } } @@ -462,7 +462,7 @@ bool CSettings::LoadBool ( SettingID Type, bool & Value ) } if (FindInfo->second->IndexBasedSetting()) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } else { return FindInfo->second->Load(0,Value); } @@ -489,7 +489,7 @@ bool CSettings::LoadBoolIndex( SettingID Type, int index , bool & Value ) { return FindInfo->second->Load(index,Value); } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } return false; } @@ -512,7 +512,7 @@ bool CSettings::LoadDword ( SettingID Type, DWORD & Value) } if (FindInfo->second->IndexBasedSetting()) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } else { return FindInfo->second->Load(0,Value); } @@ -539,7 +539,7 @@ bool CSettings::LoadDwordIndex( SettingID Type, int index, DWORD & Value) { return FindInfo->second->Load(index,Value); } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } return false; } @@ -562,7 +562,7 @@ bool CSettings::LoadString ( SettingID Type, stdstr & Value ) } if (FindInfo->second->IndexBasedSetting()) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } else { return FindInfo->second->Load(0,Value); } @@ -581,7 +581,7 @@ bool CSettings::LoadString ( SettingID Type, char * Buffer, int BufferSize ) bool bRes = false; if (FindInfo->second->IndexBasedSetting()) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } else { stdstr Value; bRes = FindInfo->second->Load(0,Value); @@ -615,14 +615,14 @@ bool CSettings::LoadStringIndex ( SettingID Type, int index, stdstr & Value ) { return FindInfo->second->Load(index,Value); } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } return false; } bool CSettings::LoadStringIndex ( SettingID Type, int index, char * Buffer, int BufferSize ) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); return false; } @@ -644,7 +644,7 @@ void CSettings::LoadDefaultBool ( SettingID Type, bool & Value ) } else { if (FindInfo->second->IndexBasedSetting()) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } else { FindInfo->second->LoadDefault(0,Value); } @@ -653,13 +653,13 @@ void CSettings::LoadDefaultBool ( SettingID Type, bool & Value ) bool CSettings::LoadDefaultBoolIndex ( SettingID Type, int index ) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); return false; } void CSettings::LoadDefaultBoolIndex ( SettingID Type, int index , bool & Value ) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } DWORD CSettings::LoadDefaultDword ( SettingID Type ) @@ -679,7 +679,7 @@ void CSettings::LoadDefaultDword ( SettingID Type, DWORD & Value) } else { if (FindInfo->second->IndexBasedSetting()) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } else { FindInfo->second->LoadDefault(0,Value); } @@ -688,13 +688,13 @@ void CSettings::LoadDefaultDword ( SettingID Type, DWORD & Value) DWORD CSettings::LoadDefaultDwordIndex ( SettingID Type, int index ) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); return false; } void CSettings::LoadDefaultDwordIndex ( SettingID Type, int index, DWORD & Value) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } stdstr CSettings::LoadDefaultString ( SettingID Type ) @@ -714,7 +714,7 @@ void CSettings::LoadDefaultString ( SettingID Type, stdstr & Value ) } else { if (FindInfo->second->IndexBasedSetting()) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } else { FindInfo->second->LoadDefault(0,Value); } @@ -723,23 +723,23 @@ void CSettings::LoadDefaultString ( SettingID Type, stdstr & Value ) void CSettings::LoadDefaultString ( SettingID Type, char * Buffer, int BufferSize ) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } stdstr CSettings::LoadDefaultStringIndex ( SettingID Type, int index ) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); return false; } void CSettings::LoadDefaultStringIndex ( SettingID Type, int index, stdstr & Value ) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } void CSettings::LoadDefaultStringIndex ( SettingID Type, int index, char * Buffer, int BufferSize ) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } void CSettings::SaveBool ( SettingID Type, bool Value ) @@ -753,7 +753,7 @@ void CSettings::SaveBool ( SettingID Type, bool Value ) } if (FindInfo->second->IndexBasedSetting()) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } else { FindInfo->second->Save(0,Value); } @@ -773,7 +773,7 @@ void CSettings::SaveBoolIndex( SettingID Type, int index, bool Value ) { FindInfo->second->Save(index,Value); } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } NotifyCallBacks(Type); } @@ -789,7 +789,7 @@ void CSettings::SaveDword ( SettingID Type, DWORD Value ) } if (FindInfo->second->IndexBasedSetting()) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } else { FindInfo->second->Save(0,Value); } @@ -809,7 +809,7 @@ void CSettings::SaveDwordIndex ( SettingID Type, int index, DWORD Value ) { FindInfo->second->Save(index,Value); } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } NotifyCallBacks(Type); } @@ -825,7 +825,7 @@ void CSettings::SaveString ( SettingID Type, const stdstr & Value ) } if (FindInfo->second->IndexBasedSetting()) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } else { FindInfo->second->Save(0,Value); } @@ -842,7 +842,7 @@ void CSettings::SaveString ( SettingID Type, const char * Buffer ) } if (FindInfo->second->IndexBasedSetting()) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } else { FindInfo->second->Save(0,Buffer); } @@ -861,7 +861,7 @@ void CSettings::SaveStringIndex( SettingID Type, int index, const char * Buffer { FindInfo->second->Save(index,Buffer); } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } NotifyCallBacks(Type); } @@ -881,7 +881,7 @@ void CSettings::DeleteSetting( SettingID Type ) } if (FindInfo->second->IndexBasedSetting()) { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } else { FindInfo->second->Delete(0); } @@ -900,7 +900,7 @@ void CSettings::DeleteSettingIndex( SettingID Type, int index ) { FindInfo->second->Delete(index); } else { - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } NotifyCallBacks(Type); } @@ -945,7 +945,7 @@ void CSettings::SettingTypeChanged( SettingType Type ) void CSettings::UnknownSetting (SettingID Type) { #ifdef _DEBUG - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); #endif } diff --git a/Source/Project64/User Interface/Settings Config.cpp b/Source/Project64/User Interface/Settings Config.cpp index db01b1b56..cfee80a4c 100644 --- a/Source/Project64/User Interface/Settings Config.cpp +++ b/Source/Project64/User Interface/Settings Config.cpp @@ -200,6 +200,7 @@ void CSettingConfig::ApplySettings( bool UpdateScreen ) ::EnableWindow(GetDlgItem(IDAPPLY),false); ::EnableWindow(GetDlgItem(IDC_RESET_PAGE), m_CurrentPage->EnableReset()); } + } LRESULT CSettingConfig::OnPageListItemChanged(NMHDR* phdr) diff --git a/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp b/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp index 9e3d59e5f..dabaff391 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp @@ -120,13 +120,13 @@ void COptionsShortCutsPage::OnRemoveClicked ( UINT Code, int id, HWND ctl ) HTREEITEM hSelectedItem = m_MenuItems.GetSelectedItem(); if (hSelectedItem == NULL) { - Notify().DisplayError(GS(MSG_NO_SEL_SHORTCUT)); + _Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); return; } HTREEITEM hParent = m_MenuItems.GetParentItem(hSelectedItem); if (hParent == NULL) { - Notify().DisplayError(GS(MSG_NO_SEL_SHORTCUT)); + _Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); return; } @@ -138,7 +138,7 @@ void COptionsShortCutsPage::OnRemoveClicked ( UINT Code, int id, HWND ctl ) int index = m_CurrentKeys.GetCurSel(); if (index < 0) { - Notify().DisplayError(GS(MSG_NO_SEL_SHORTCUT)); + _Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); return; } ShortCut->RemoveItem((CMenuShortCutKey *)m_CurrentKeys.GetItemData(index)); @@ -161,7 +161,7 @@ void COptionsShortCutsPage::OnAssignClicked ( UINT Code, int id, HWND ctl ) int index = m_VirtualKeyList.GetCurSel(); if (index < 0) { - Notify().DisplayError(GS(MSG_NO_SHORTCUT_SEL)); + _Notify->DisplayError(GS(MSG_NO_SHORTCUT_SEL)); return; } @@ -176,13 +176,13 @@ void COptionsShortCutsPage::OnAssignClicked ( UINT Code, int id, HWND ctl ) HTREEITEM hSelectedItem = m_MenuItems.GetSelectedItem(); if (hSelectedItem == NULL) { - Notify().DisplayError(GS(MSG_NO_MENUITEM_SEL)); + _Notify->DisplayError(GS(MSG_NO_MENUITEM_SEL)); return; } HTREEITEM hParent = m_MenuItems.GetParentItem(hSelectedItem); if (hParent == NULL) { - Notify().DisplayError(GS(MSG_NO_MENUITEM_SEL)); + _Notify->DisplayError(GS(MSG_NO_MENUITEM_SEL)); return; } @@ -191,7 +191,7 @@ void COptionsShortCutsPage::OnAssignClicked ( UINT Code, int id, HWND ctl ) LanguageStringID strid = m_ShortCuts.GetMenuItemName(key,bCtrl,bAlt,bShift,AccessLevel); if (strid != EMPTY_STRING) { - Notify().DisplayError(GS(MSG_MENUITEM_ASSIGNED)); + _Notify->DisplayError(GS(MSG_MENUITEM_ASSIGNED)); return; } ShortCut->AddShortCut(key,bCtrl,bAlt,bShift,AccessLevel,true,false); diff --git a/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp b/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp index 9c3f54229..8d0b92870 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp @@ -244,7 +244,7 @@ void COptionPluginPage::ApplyComboBoxes ( void ) case PLUGIN_TYPE_AUDIO: _Settings->SaveBool(Plugin_AUDIO_Changed,true); break; case PLUGIN_TYPE_CONTROLLER: _Settings->SaveBool(Plugin_CONT_Changed,true); break; default: - Notify().BreakPoint(__FILE__,__LINE__); + _Notify->BreakPoint(__FILE__,__LINE__); } } if (ComboBox->IsReset()) diff --git a/Source/Project64/stdafx.h b/Source/Project64/stdafx.h index aa13173bc..96013c434 100644 --- a/Source/Project64/stdafx.h +++ b/Source/Project64/stdafx.h @@ -13,9 +13,7 @@ #include #include "N64 System/C Core/CPU Log.h" -#include "N64 System/C Core/Dma.h" #include "N64 System/C Core/C Core Interface.h" -#include "N64 System/C Core/Pif.h" #include "3rd Party/Zip.h" #include "3rd Party/7zip.h"