git-svn-id: https://localhost/svn/Project64/trunk@27 111125ac-702d-7242-af9c-5ba8ae61c1ef

This commit is contained in:
zilmar 2010-05-22 04:47:15 +00:00
parent f148d1b94c
commit f9db52309f
95 changed files with 9926 additions and 7373 deletions

View File

@ -1,6 +1,27 @@
Project64 1.7.0.51
------------------
Project64 1.7.0.50
------------------
Update: Rearranged Source Project Update: Rearranged Source Project
Update: Change creating of global classes Update: Change creating of global classes
update: Optimize writing to an ini file update: Optimize writing to an ini file
* Redesigned settings dialog to use more modern vertical pages instead of tabs
* Plugins can now be set per rom
* Added Soft Reset function (resets only game, like pushing reset button on console, default shortcut F1, old Hard Reset now defaults SHIFT+F1).
* When app loses focus in fullscreen make sure it is in window mode, should improve stability on fullscreen error messages.
* Max cheats per game raised to 50,000
* changed how settings is used globally
* new setting: allow user to edit VI Refresh rate (see http://forum.pj64-emu.com/showpost.php?p=4457&postcount=18)
* changed internal of how settings work
* Cleaned up rom browser refresh to remove more unneeded refreshes (Windows returning files in different orders)
* re-arranged project source files (please report new errors!)
* changed how languages is used globally
* optimized writing to ini file
* added RDB editor mode and indicator (see hidden settings info)
* updated Help menu
* updates to video plugin interface for ROM settings

View File

@ -189,15 +189,15 @@ CTraceFileLog::CTraceFileLog(LPCTSTR FileName, bool FlushFile ) :
} }
CTraceFileLog::CTraceFileLog (LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, DWORD dwMaxFileSize) : CTraceFileLog::CTraceFileLog (LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, DWORD dwMaxFileSize) :
m_FlushFile(FlushFile) m_FlushFile(FlushFile)
{ {
enum { MB = 1024 * 1024 }; enum { MB = 1024 * 1024 };
m_hLogFile.SetFlush(false); m_hLogFile.SetFlush(false);
m_hLogFile.SetTruncateFile(true); m_hLogFile.SetTruncateFile(true);
if(dwMaxFileSize > 10240) if(dwMaxFileSize < 2048 && dwMaxFileSize > 2)
m_hLogFile.SetMaxFileSize(dwMaxFileSize); m_hLogFile.SetMaxFileSize(dwMaxFileSize * MB);
else else
m_hLogFile.SetMaxFileSize(5 * MB); m_hLogFile.SetMaxFileSize(5 * MB);

View File

@ -97,8 +97,13 @@ stdstr FileVersionInfo( LPCTSTR Info, LPCTSTR FileName )
try try
{ {
Result = ReadVersionInfo(Array,Info); Result = ReadVersionInfo(Array,Info);
if(Result.empty()) if(!Result.empty())
{ {
if (strcmp(Info,VERSION_PRODUCT_VERSION) == 0)
{
Result.replace(" ","");
}
} else {
WriteTraceF(TraceError,_T("FileVersionInfo(%s), ReadVersionInfo() failed"), FileName); WriteTraceF(TraceError,_T("FileVersionInfo(%s), ReadVersionInfo() failed"), FileName);
} }
} }

View File

@ -37,5 +37,6 @@ class CNotification;
//Main Files //Main Files
#include "N64 System/N64 Class.h" #include "N64 System/N64 Class.h"
#include "N64 System/System Globals.h"
#endif #endif

View File

@ -14,27 +14,28 @@ enum STEP_TYPE NextInstruction, Main_NextInstruction, Sync_NextInstruction;
} }
CN64System * g_N64System = NULL; #ifdef toremove
CN64System * g_SyncSystem = NULL; CN64System * _N64System = NULL;
CRecompiler * g_Recompiler = NULL; CN64System * _SyncSystem = NULL;
CMipsMemory * g_MMU = NULL; //Memory of the n64 CRecompiler * _Recompiler = NULL;
CTLB * g_TLB = NULL; //TLB Unit CMipsMemoryVM * _MMU = NULL; //Memory of the n64
CRegisters * g_Reg = NULL; //Current Register Set attacted to the _MMU CTLB * _TLB = NULL; //TLB Unit
CNotification * g_Notify = NULL; CRegisters * _Reg = NULL; //Current Register Set attacted to the _MMU
CSettings * g_Settings = NULL; CNotification * _Notify = NULL;
CPlugins * g_Plugins = NULL; CSettings * _Settings = NULL;
CN64Rom * g_Rom = NULL; //The current rom that this system is executing.. it can only execute one file at the time CPlugins * _Plugins = NULL;
CAudio * g_Audio = NULL; CN64Rom * _Rom = NULL; //The current rom that this system is executing.. it can only execute one file at the time
//registers //registers
MULTI_ACCESS_QWORD * g_GPR = NULL, * g_FPR = NULL, * g_HI = NULL, * g_LO = NULL; MULTI_ACCESS_QWORD * _GPR = NULL, * _FPR = NULL, * g_HI = NULL, * g_LO = NULL;
DWORD * g_PROGRAM_COUNTER = NULL, * g_CP0 = NULL, * g_RegMI = NULL, * g_LLBit = NULL, DWORD * _PROGRAM_COUNTER = NULL, * _CP0 = NULL, * _RegMI = NULL, * _LLBit = NULL,
* g_LLAddr = NULL, * g_FPCR = NULL, * g_RegSI = NULL, * g_RegRI = NULL, * g_RegPI = NULL, * _LLAddr = NULL, * _FPCR = NULL, * _RegSI = NULL, * _RegRI = NULL, * _RegPI = NULL,
* g_RegAI = NULL, * g_RegVI = NULL, * g_RegDPC = NULL, * g_RegSP = NULL, * g_RegRDRAM = NULL; * _RegAI = NULL, * _RegVI = NULL, * _RegDPC = NULL, * _RegSP = NULL, * _RegRDRAM = NULL;
double ** g_FPRDoubleLocation; double ** _FPRDoubleLocation;
float ** g_FPRFloatLocation; float ** _FPRFloatLocation;
enum TimerType * g_CurrentTimerType; enum TimerType * _CurrentTimerType;
int * g_Timer = NULL; int * _Timer = NULL;
#endif
//Register Name //Register Name
const char ** g_Cop0_Name; const char ** g_Cop0_Name;
@ -53,7 +54,7 @@ enum FUNC_LOOKUP_METHOD g_LookUpMode;
char g_RomName [300]; char g_RomName [300];
//Plugins //Plugins
DWORD * g_AudioIntrReg = NULL; DWORD * _AudioIntrReg = NULL;
CONTROL * g_Controllers; CONTROL * g_Controllers;
enum SystemType g_SystemType; enum SystemType g_SystemType;
@ -122,8 +123,8 @@ void (__cdecl *ReadController) ( int Control, BYTE * Command );
void (__cdecl *RumbleCommand) ( int Control, BOOL bRumble ); void (__cdecl *RumbleCommand) ( int Control, BOOL bRumble );
//Memory //Memory
DWORD * g_TLB_ReadMap, * g_TLB_WriteMap, g_RdramSize, * g_HalfLine, * g_MemoryStack; DWORD * g_TLB_ReadMap, * g_TLB_WriteMap, g_RdramSize;
BYTE * g_N64MEM, *g_RDRAM, *g_DMEM, *g_IMEM, *g_ROM, *g_PIF_Ram; BYTE *g_RDRAM, *g_DMEM, *g_IMEM, *g_Rom;
OPCODE g_Opcode; OPCODE g_Opcode;
BOOL g_IndvidualBlock, g_Profiling; BOOL g_IndvidualBlock, g_Profiling;
@ -148,8 +149,8 @@ void CC_Core::SetN64System (CN64System * N64System)
if (N64System) if (N64System)
{ {
g_RomFileSize = N64System->_Rom->GetRomSize(); g_RomFileSize = _Rom->GetRomSize();
g_CicChip = N64System->_Rom->CicChipID(); g_CicChip = _Rom->CicChipID();
} }
g_CurrentFrame = 0; g_CurrentFrame = 0;
SetCurrentSystem(N64System); SetCurrentSystem(N64System);
@ -168,59 +169,58 @@ void CC_Core::SetSyncCpu ( CN64System * System )
g_Sync_CPU_Action = new CPU_ACTION; g_Sync_CPU_Action = new CPU_ACTION;
memset(g_Sync_CPU_Action,0,sizeof(CPU_ACTION)); memset(g_Sync_CPU_Action,0,sizeof(CPU_ACTION));
} }
g_SyncSystem = System; _SyncSystem = System;
} }
void CC_Core::SetSettings ( ) void CC_Core::SetSettings ( )
{ {
g_Settings = _Settings; _Settings = _Settings;
if (g_Settings) if (_Settings)
{ {
g_HaveDebugger = g_Settings->LoadBool(Debugger_Enabled); g_HaveDebugger = _Settings->LoadBool(Debugger_Enabled);
if (g_HaveDebugger) if (g_HaveDebugger)
{ {
g_ShowUnhandledMemory = g_Settings->LoadBool(Debugger_ShowUnhandledMemory); g_ShowUnhandledMemory = _Settings->LoadBool(Debugger_ShowUnhandledMemory);
g_ShowDListAListCount = g_Settings->LoadBool(Debugger_ShowDListAListCount); g_ShowDListAListCount = _Settings->LoadBool(Debugger_ShowDListAListCount);
} else { } else {
g_ShowUnhandledMemory = false; g_ShowUnhandledMemory = false;
g_ShowUnhandledMemory = false; g_ShowUnhandledMemory = false;
} }
g_ShowCPUPer = g_Settings->LoadBool(UserInterface_ShowCPUPer); g_ShowCPUPer = _Settings->LoadBool(UserInterface_ShowCPUPer);
g_ShowTLBMisses = false; g_ShowTLBMisses = false;
g_UseTlb = g_Settings->LoadBool(Game_UseTlb); g_UseTlb = _Settings->LoadBool(Game_UseTlb);
g_CPU_Type = (CPU_TYPE)g_Settings->LoadDword(Game_CpuType); g_CPU_Type = (CPU_TYPE)_Settings->LoadDword(Game_CpuType);
g_SaveUsing = (SAVE_CHIP_TYPE)g_Settings->LoadDword(Game_SaveChip); g_SaveUsing = (SAVE_CHIP_TYPE)_Settings->LoadDword(Game_SaveChip);
g_AudioSignal = g_Settings->LoadBool(Game_RspAudioSignal); g_AudioSignal = _Settings->LoadBool(Game_RspAudioSignal);
g_RdramSize = g_Settings->LoadDword(Game_RDRamSize); g_RdramSize = _Settings->LoadDword(Game_RDRamSize);
g_ShowPifRamErrors = g_Settings->LoadDword(Debugger_ShowPifErrors); g_ShowPifRamErrors = _Settings->LoadDword(Debugger_ShowPifErrors);
g_CountPerOp = g_Settings->LoadDword(Game_CounterFactor); g_CountPerOp = _Settings->LoadDword(Game_CounterFactor);
g_GenerateLog = g_Settings->LoadDword(Debugger_GenerateDebugLog); g_GenerateLog = _Settings->LoadDword(Debugger_GenerateDebugLog);
g_DelaySI = g_Settings->LoadBool(Game_DelaySI); g_DelaySI = _Settings->LoadBool(Game_DelaySI);
g_SPHack = g_Settings->LoadBool(Game_SPHack); g_SPHack = _Settings->LoadBool(Game_SPHack);
g_FixedAudio = g_Settings->LoadBool(Game_FixedAudio); g_FixedAudio = _Settings->LoadBool(Game_FixedAudio);
g_LogX86Code = g_Settings->LoadBool(Debugger_GenerateLogFiles); g_LogX86Code = _Settings->LoadBool(Debugger_GenerateLogFiles);
g_LookUpMode = (FUNC_LOOKUP_METHOD)g_Settings->LoadDword(Game_FuncLookupMode); g_LookUpMode = (FUNC_LOOKUP_METHOD)_Settings->LoadDword(Game_FuncLookupMode);
g_DisableRegCaching = !g_Settings->LoadBool(Game_RegCache); g_DisableRegCaching = !_Settings->LoadBool(Game_RegCache);
g_UseLinking = g_Settings->LoadBool(Game_BlockLinking); g_UseLinking = _Settings->LoadBool(Game_BlockLinking);
g_ShowCompMem = false; g_ShowCompMem = false;
g_ViRefreshRate = g_Settings->LoadDword(Game_ViRefreshRate); g_ViRefreshRate = _Settings->LoadDword(Game_ViRefreshRate);
strcpy(g_RomName, g_Settings->LoadString(Game_GameName).c_str()); strcpy(g_RomName, _Settings->LoadString(Game_GameName).c_str());
} }
} }
void CC_Core::SetCurrentSystem (CN64System * System ) void CC_Core::SetCurrentSystem (CN64System * System )
{ {
g_MMU = NULL; _MMU = NULL;
g_Reg = NULL; _Reg = NULL;
g_TLB = NULL; _TLB = NULL;
g_Audio = NULL; _Audio = NULL;
g_Recompiler = NULL; _Recompiler = NULL;
g_N64System = System; _N64System = System;
g_Notify = System->_Notify;
if (g_SyncSystem == System) if (_SyncSystem == System)
{ {
Main_NextInstruction = NextInstruction; Main_NextInstruction = NextInstruction;
g_CPU_Action = g_Sync_CPU_Action; g_CPU_Action = g_Sync_CPU_Action;
@ -230,124 +230,122 @@ void CC_Core::SetCurrentSystem (CN64System * System )
g_CPU_Action = g_Main_CPU_Action; g_CPU_Action = g_Main_CPU_Action;
NextInstruction = Main_NextInstruction; NextInstruction = Main_NextInstruction;
} }
if (g_N64System) if (_N64System)
{ {
g_Recompiler = System->_Recomp; _Recompiler = System->m_Recomp;
g_MMU = System->_MMU; _MMU = &System->m_MMU_VM;
g_TLB = System->_MMU; _TLB = &System->m_TLB;
g_Plugins = System->_Plugins; _Plugins = System->m_Plugins;
g_Rom = System->_Rom; _Audio = &System->m_Audio;
g_Audio = System->_Audio; _Reg = &System->m_Reg;
} }
if (g_MMU) { g_Reg = g_MMU->SystemRegisters(); } if (_Reg)
if (g_Reg)
{ {
g_GPR = g_Reg->GPR; _GPR = _Reg->GPR;
g_CP0 = g_Reg->CP0; _CP0 = _Reg->CP0;
g_FPR = g_Reg->FPR; _FPR = _Reg->FPR;
g_FPCR = g_Reg->FPCR; _FPCR = _Reg->FPCR;
g_FPRFloatLocation = g_Reg->FPR_S; _FPRFloatLocation = _Reg->FPR_S;
g_FPRDoubleLocation = g_Reg->FPR_D; _FPRDoubleLocation = _Reg->FPR_D;
g_HI = &g_Reg->HI; _RegHI = &_Reg->HI;
g_LO = &g_Reg->LO; _RegLO = &_Reg->LO;
g_LLBit = &g_Reg->LLBit; _LLBit = &_Reg->LLBit;
g_LLAddr = &g_Reg->LLAddr; _LLAddr = &_Reg->LLAddr;
g_RegRI = g_Reg->RDRAM_Interface; _RegRI = _Reg->RDRAM_Interface;
g_RegRDRAM = g_Reg->RDRAM_Registers; _RegRDRAM = _Reg->RDRAM_Registers;
g_RegMI = g_Reg->Mips_Interface; _RegMI = _Reg->Mips_Interface;
g_RegVI = g_Reg->Video_Interface; _RegVI = _Reg->Video_Interface;
g_RegDPC = g_Reg->Display_ControlReg; _RegDPC = _Reg->Display_ControlReg;
g_RegAI = g_Reg->Audio_Interface; _RegAI = _Reg->Audio_Interface;
g_RegSP = g_Reg->SigProcessor_Interface; _RegSP = _Reg->SigProcessor_Interface;
g_RegPI = g_Reg->Peripheral_Interface; _RegPI = _Reg->Peripheral_Interface;
g_RegSI = g_Reg->SerialInterface; _RegSI = _Reg->SerialInterface;
g_AudioIntrReg = &g_Reg->AudioIntrReg; _AudioIntrReg = &_Reg->AudioIntrReg;
g_PROGRAM_COUNTER = &g_Reg->PROGRAM_COUNTER; _PROGRAM_COUNTER = &_Reg->PROGRAM_COUNTER;
g_Cop0_Name = g_Reg->Cop0_Name; g_Cop0_Name = _Reg->Cop0_Name;
g_Timer = &g_Reg->Timer; _Timer = &_Reg->Timer;
g_CurrentTimerType = &g_Reg->CurrentTimerType; _CurrentTimerType = &_Reg->CurrentTimerType;
} }
CaptureScreen = g_Plugins->Gfx()->CaptureScreen; CaptureScreen = _Plugins->Gfx()->CaptureScreen;
ChangeWindow = g_Plugins->Gfx()->ChangeWindow; ChangeWindow = _Plugins->Gfx()->ChangeWindow;
// GetGfxDebugInfo = g_Plugins->Gfx()->GetGfxDebugInfo; // GetGfxDebugInfo = _Plugins->Gfx()->GetGfxDebugInfo;
// GFXCloseDLL = g_Plugins->Gfx()->GFXCloseDLL; // GFXCloseDLL = _Plugins->Gfx()->GFXCloseDLL;
// GFXDllAbout = g_Plugins->Gfx()->GFXDllAbout; // GFXDllAbout = _Plugins->Gfx()->GFXDllAbout;
// GFXDllConfig = g_Plugins->Gfx()->GFXDllConfig; // GFXDllConfig = _Plugins->Gfx()->GFXDllConfig;
// GfxRomClosed = g_Plugins->Gfx()->GfxRomClosed; // GfxRomClosed = _Plugins->Gfx()->GfxRomClosed;
// GfxRomOpen = g_Plugins->Gfx()->GfxRomOpen; // GfxRomOpen = _Plugins->Gfx()->GfxRomOpen;
DrawScreen = g_Plugins->Gfx()->DrawScreen; DrawScreen = _Plugins->Gfx()->DrawScreen;
// FrameBufferRead = g_Plugins->Gfx()->FrameBufferRead; // FrameBufferRead = _Plugins->Gfx()->FrameBufferRead;
// FrameBufferWrite = g_Plugins->Gfx()->FrameBufferWrite; // FrameBufferWrite = _Plugins->Gfx()->FrameBufferWrite;
// InitiateGFX = g_Plugins->Gfx()->InitiateGFX; // InitiateGFX = _Plugins->Gfx()->InitiateGFX;
// InitiateGFXDebugger = g_Plugins->Gfx()->InitiateGFXDebugger; // InitiateGFXDebugger = _Plugins->Gfx()->InitiateGFXDebugger;
MoveScreen = g_Plugins->Gfx()->MoveScreen; MoveScreen = _Plugins->Gfx()->MoveScreen;
ProcessDList = g_Plugins->Gfx()->ProcessDList; ProcessDList = _Plugins->Gfx()->ProcessDList;
ProcessRDPList = g_Plugins->Gfx()->ProcessRDPList; ProcessRDPList = _Plugins->Gfx()->ProcessRDPList;
ShowCFB = g_Plugins->Gfx()->ShowCFB; ShowCFB = _Plugins->Gfx()->ShowCFB;
UpdateScreen = g_Plugins->Gfx()->UpdateScreen; UpdateScreen = _Plugins->Gfx()->UpdateScreen;
ViStatusChanged = g_Plugins->Gfx()->ViStatusChanged; ViStatusChanged = _Plugins->Gfx()->ViStatusChanged;
ViWidthChanged = g_Plugins->Gfx()->ViWidthChanged; ViWidthChanged = _Plugins->Gfx()->ViWidthChanged;
// ContCloseDLL = g_Plugins->Control()->ContCloseDLL; // ContCloseDLL = _Plugins->Control()->ContCloseDLL;
ControllerCommand = g_Plugins->Control()->ControllerCommand; ControllerCommand = _Plugins->Control()->ControllerCommand;
// ContDllAbout = g_Plugins->Control()->ContDllAbout; // ContDllAbout = _Plugins->Control()->ContDllAbout;
// ContConfig = g_Plugins->Control()->ContConfig; // ContConfig = _Plugins->Control()->ContConfig;
// InitiateControllers_1_0= g_Plugins->Control()->InitiateControllers_1_0; // InitiateControllers_1_0= _Plugins->Control()->InitiateControllers_1_0;
// InitiateControllers_1_1= g_Plugins->Control()->InitiateControllers_1_1; // InitiateControllers_1_1= _Plugins->Control()->InitiateControllers_1_1;
GetKeys = g_Plugins->Control()->GetKeys; GetKeys = _Plugins->Control()->GetKeys;
ReadController = g_Plugins->Control()->ReadController; ReadController = _Plugins->Control()->ReadController;
// ContRomOpen = g_Plugins->Control()->ContRomOpen; // ContRomOpen = _Plugins->Control()->ContRomOpen;
// ContRomClosed = g_Plugins->Control()->ContRomClosed; // ContRomClosed = _Plugins->Control()->ContRomClosed;
// WM_KeyDown = g_Plugins->Control()->WM_KeyDown; // WM_KeyDown = _Plugins->Control()->WM_KeyDown;
// WM_KeyUp = g_Plugins->Control()->WM_KeyUp; // WM_KeyUp = _Plugins->Control()->WM_KeyUp;
RumbleCommand = g_Plugins->Control()->RumbleCommand; RumbleCommand = _Plugins->Control()->RumbleCommand;
g_Controllers = g_Plugins->Control()->m_PluginControllers; g_Controllers = _Plugins->Control()->m_PluginControllers;
// GetRspDebugInfo = g_Plugins->RSP()->GetRspDebugInfo; // GetRspDebugInfo = _Plugins->RSP()->GetRspDebugInfo;
// RSPCloseDLL = g_Plugins->RSP()->RSPCloseDLL; // RSPCloseDLL = _Plugins->RSP()->RSPCloseDLL;
// RSPDllAbout = g_Plugins->RSP()->RSPDllAbout; // RSPDllAbout = _Plugins->RSP()->RSPDllAbout;
// RSPDllConfig = g_Plugins->RSP()->RSPDllConfig; // RSPDllConfig = _Plugins->RSP()->RSPDllConfig;
// RSPRomClosed = g_Plugins->RSP()->RSPRomClosed; // RSPRomClosed = _Plugins->RSP()->RSPRomClosed;
DoRspCycles = g_Plugins->RSP()->DoRspCycles; DoRspCycles = _Plugins->RSP()->DoRspCycles;
// InitiateRSP_1_0 = g_Plugins->RSP()->InitiateRSP_1_0; // InitiateRSP_1_0 = _Plugins->RSP()->InitiateRSP_1_0;
// InitiateRSP_1_1 = g_Plugins->RSP()->InitiateRSP_1_1; // InitiateRSP_1_1 = _Plugins->RSP()->InitiateRSP_1_1;
// InitiateRSPDebugger = g_Plugins->RSP()->InitiateRSPDebugger; // InitiateRSPDebugger = _Plugins->RSP()->InitiateRSPDebugger;
// AiCloseDLL = g_Plugins->Audio()->AiCloseDLL; // AiCloseDLL = _Plugins->Audio()->AiCloseDLL;
// AiDacrateChanged = g_Plugins->Audio()->AiDacrateChanged; // AiDacrateChanged = _Plugins->Audio()->AiDacrateChanged;
AiLenChanged = g_Plugins->Audio()->LenChanged; AiLenChanged = _Plugins->Audio()->LenChanged;
// AiDllAbout = g_Plugins->Audio()->AiDllAbout; // AiDllAbout = _Plugins->Audio()->AiDllAbout;
// AiDllConfig = g_Plugins->Audio()->AiDllConfig; // AiDllConfig = _Plugins->Audio()->AiDllConfig;
// AiDllTest = g_Plugins->Audio()->AiDllTest; // AiDllTest = _Plugins->Audio()->AiDllTest;
AiReadLength = g_Plugins->Audio()->ReadLength; AiReadLength = _Plugins->Audio()->ReadLength;
// AiRomClosed = g_Plugins->Audio()->AiRomClosed; // AiRomClosed = _Plugins->Audio()->AiRomClosed;
// AiUpdate = g_Plugins->Audio()->Update; // AiUpdate = _Plugins->Audio()->Update;
// InitiateAudio = g_Plugins->Audio()->InitiateAudio; // InitiateAudio = _Plugins->Audio()->InitiateAudio;
ProcessAList = g_Plugins->Audio()->ProcessAList; ProcessAList = _Plugins->Audio()->ProcessAList;
g_N64MEM = System->_MMU->RDRAM; g_RDRAM = _MMU->Rdram();
g_RDRAM = System->_MMU->RDRAM; g_DMEM = _MMU->Dmem();
g_DMEM = System->_MMU->DMEM; g_IMEM = _MMU->Imem();
g_IMEM = System->_MMU->IMEM; g_Rom = _Rom->GetRomAddress();
g_ROM = System->_MMU->ROM; g_TLB_ReadMap = NULL; //System->m_TLB.TLB_ReadMap;
g_PIF_Ram = System->_MMU->PIF_Ram; g_TLB_WriteMap = NULL; //System->m_TLB.TLB_WriteMap;
g_TLB_ReadMap = System->_MMU->TLB_ReadMap; #ifdef tofix
g_TLB_WriteMap = System->_MMU->TLB_WriteMap; g_MemorStack = &_MMU->m_MemoryStack;
g_HalfLine = &System->_MMU->m_HalfLine; #endif
g_MemoryStack = &System->_MMU->m_MemoryStack;
} }
void CC_Core::PauseExecution ( void ) void CC_Core::PauseExecution ( void )
{ {
g_N64System->Pause(); _N64System->Pause();
} }
void CC_Core::RunRsp ( void ) void CC_Core::RunRsp ( void )
{ {
try try
{ {
g_N64System->RunRSP(); _N64System->RunRSP();
} }
catch (...) catch (...)
{ {
@ -361,7 +359,7 @@ void CC_Core::RefreshScreen(void)
{ {
try try
{ {
g_N64System->RefreshScreen(); _N64System->RefreshScreen();
} }
catch (...) catch (...)
{ {
@ -371,22 +369,22 @@ void CC_Core::RefreshScreen(void)
void CC_Core::GenerateProfileLog ( void ) void CC_Core::GenerateProfileLog ( void )
{ {
g_N64System->m_Profile.GenerateLog(); _N64System->m_Profile.GenerateLog();
} }
void CC_Core::ResetTimer ( void ) void CC_Core::ResetTimer ( void )
{ {
g_N64System->m_Profile.ResetCounters(); _N64System->m_Profile.ResetCounters();
} }
DWORD CC_Core::StartTimer ( DWORD Address ) DWORD CC_Core::StartTimer ( DWORD Address )
{ {
return g_N64System->m_Profile.StartTimer(Address); return _N64System->m_Profile.StartTimer(Address);
} }
DWORD CC_Core::StopTimer ( void ) DWORD CC_Core::StopTimer ( void )
{ {
return g_N64System->m_Profile.StopTimer(); return _N64System->m_Profile.StopTimer();
} }
void PauseExecution ( void ) void PauseExecution ( void )
@ -396,65 +394,65 @@ void PauseExecution ( void )
void DisplayError ( const char * Message, ... ) void DisplayError ( const char * Message, ... )
{ {
if (g_Notify == NULL) { return; } if (_Notify == NULL) { return; }
va_list ap; va_list ap;
va_start( ap, Message ); va_start( ap, Message );
g_Notify->DisplayError(Message,ap); _Notify->DisplayError(Message,ap);
} }
void DisplayMessage ( int DisplayTime, const char * Message, ... ) void DisplayMessage ( int DisplayTime, const char * Message, ... )
{ {
if (g_Notify == NULL) { return; } if (_Notify == NULL) { return; }
va_list ap; va_list ap;
va_start( ap, Message ); va_start( ap, Message );
g_Notify->DisplayMessage(DisplayTime, Message,ap); _Notify->DisplayMessage(DisplayTime, Message,ap);
} }
void DisplayMessage2 ( const char * Message, ... ) void DisplayMessage2 ( const char * Message, ... )
{ {
if (g_Notify == NULL) { return; } if (_Notify == NULL) { return; }
va_list ap; va_list ap;
va_start( ap, Message ); va_start( ap, Message );
g_Notify->DisplayMessage2(Message,ap); _Notify->DisplayMessage2(Message,ap);
} }
const char * GetAppName ( void ) const char * GetAppName ( void )
{ {
static stdstr szAppName = g_Settings->LoadString(Setting_ApplicationName); static stdstr szAppName = _Settings->LoadString(Setting_ApplicationName);
return szAppName.c_str(); return szAppName.c_str();
} }
void GetAutoSaveDir( char * Directory ) void GetAutoSaveDir( char * Directory )
{ {
strcpy(Directory,g_Settings->LoadString(Directory_NativeSave).c_str()); strcpy(Directory,_Settings->LoadString(Directory_NativeSave).c_str());
} }
void GetInstantSaveDir( char * Directory ) void GetInstantSaveDir( char * Directory )
{ {
strcpy(Directory,g_Settings->LoadString(Directory_InstantSave).c_str()); strcpy(Directory,_Settings->LoadString(Directory_InstantSave).c_str());
} }
void SetFpuLocations( void ) void SetFpuLocations( void )
{ {
g_Reg->FixFpuLocations(); _Reg->FixFpuLocations();
} }
BOOL Limit_FPS ( void ) BOOL Limit_FPS ( void )
{ {
return g_Settings->LoadDword(GameRunning_LimitFPS); return _Settings->LoadDword(GameRunning_LimitFPS);
} }
void DacrateChanged ( enum SystemType Type ) void DacrateChanged ( enum SystemType Type )
{ {
g_Plugins->Audio()->DacrateChanged(Type); _Plugins->Audio()->DacrateChanged(Type);
} }
BOOL Close_C_CPU ( void ) BOOL Close_C_CPU ( void )
{ {
if (g_Settings == NULL || !g_Settings->LoadBool(GameRunning_CPU_Running)) if (_Settings == NULL || !_Settings->LoadBool(GameRunning_CPU_Running))
{ {
return true; return true;
} }
@ -466,7 +464,7 @@ BOOL Close_C_CPU ( void )
void StopEmulation ( void ) void StopEmulation ( void )
{ {
g_N64System->CloseCpu(); _N64System->CloseCpu();
} }
void CleanCMemory ( void ) void CleanCMemory ( void )
@ -485,7 +483,7 @@ void CleanCMemory ( void )
void __stdcall UpdateSyncCPU ( DWORD const Cycles ) void __stdcall UpdateSyncCPU ( DWORD const Cycles )
{ {
g_N64System->UpdateSyncCPU(g_SyncSystem,Cycles); _N64System->UpdateSyncCPU(_SyncSystem,Cycles);
} }
void RunRsp( void ) void RunRsp( void )
@ -505,74 +503,75 @@ void ExecuteCycles(DWORD Cycles)
void SyncSystem (void) void SyncSystem (void)
{ {
g_N64System->SyncCPU(g_SyncSystem); _N64System->SyncCPU(_SyncSystem);
} }
void ChangeTimer ( enum TimerType Type, int Value ) void ChangeTimer ( enum TimerType Type, int Value )
{ {
if (Value == 0) if (Value == 0)
{ {
g_Reg->DeactiateTimer(Type); _Reg->DeactiateTimer(Type);
} else } else
{ {
g_Reg->ChangeTimerFixed(Type,Value); _Reg->ChangeTimerFixed(Type,Value);
} }
} }
void ChangeTimerRelative ( enum TimerType Type, int Value ) void ChangeTimerRelative ( enum TimerType Type, int Value )
{ {
g_Reg->ChangeTimerRelative(Type,Value); _Reg->ChangeTimerRelative(Type,Value);
} }
void ApplyGSButtonCheats ( void ) void ApplyGSButtonCheats ( void )
{ {
CC_Core::ApplyGSButtonCheats(g_N64System); CC_Core::ApplyGSButtonCheats(_N64System);
} }
void ChangePluginFunc ( void ) void ChangePluginFunc ( void )
{ {
g_Notify->DisplayMessage(0,MSG_PLUGIN_INIT); _Notify->DisplayMessage(0,MSG_PLUGIN_INIT);
if (g_Settings->LoadBool(Plugin_GFX_Changed)) if (_Settings->LoadBool(Plugin_GFX_Changed))
{ {
g_Plugins->Reset(PLUGIN_TYPE_GFX); _Plugins->Reset(PLUGIN_TYPE_GFX);
} }
if (g_Settings->LoadBool(Plugin_AUDIO_Changed)) if (_Settings->LoadBool(Plugin_AUDIO_Changed))
{ {
g_Plugins->Reset(PLUGIN_TYPE_AUDIO); _Plugins->Reset(PLUGIN_TYPE_AUDIO);
} }
if (g_Settings->LoadBool(Plugin_CONT_Changed)) if (_Settings->LoadBool(Plugin_CONT_Changed))
{ {
g_Plugins->Reset(PLUGIN_TYPE_CONTROLLER); _Plugins->Reset(PLUGIN_TYPE_CONTROLLER);
} }
if (g_Settings->LoadBool(Plugin_RSP_Changed) || if (_Settings->LoadBool(Plugin_RSP_Changed) ||
g_Settings->LoadBool(Plugin_AUDIO_Changed) || _Settings->LoadBool(Plugin_AUDIO_Changed) ||
g_Settings->LoadBool(Plugin_GFX_Changed)) _Settings->LoadBool(Plugin_GFX_Changed))
{ {
g_Plugins->Reset(PLUGIN_TYPE_RSP); _Plugins->Reset(PLUGIN_TYPE_RSP);
} }
g_Settings->SaveBool(Plugin_RSP_Changed, false); _Settings->SaveBool(Plugin_RSP_Changed, false);
g_Settings->SaveBool(Plugin_AUDIO_Changed,false); _Settings->SaveBool(Plugin_AUDIO_Changed,false);
g_Settings->SaveBool(Plugin_GFX_Changed, false); _Settings->SaveBool(Plugin_GFX_Changed, false);
g_Settings->SaveBool(Plugin_CONT_Changed, false); _Settings->SaveBool(Plugin_CONT_Changed, false);
g_Notify->RefreshMenu(); _Notify->RefreshMenu();
if (!g_Plugins->Initiate(g_N64System)) { if (!_Plugins->Initiate())
g_Notify->DisplayMessage(5,MSG_PLUGIN_NOT_INIT); {
_Notify->DisplayMessage(5,MSG_PLUGIN_NOT_INIT);
SetEndEmulation(true); SetEndEmulation(true);
} else { } else {
CC_Core::SetCurrentSystem(g_N64System); CC_Core::SetCurrentSystem(_N64System);
} }
g_Recompiler->ResetRecompCode(); _Recompiler->ResetRecompCode();
} }
void ChangeFullScreenFunc ( void ) void ChangeFullScreenFunc ( void )
{ {
g_Notify->ChangeFullScreen(); _Notify->ChangeFullScreen();
} }
BOOL Machine_LoadState ( void ) BOOL Machine_LoadState ( void )
{ {
bool Result = CC_Core::LoadState(g_N64System); bool Result = CC_Core::LoadState(_N64System);
CC_Core::SetCurrentSystem(g_N64System); CC_Core::SetCurrentSystem(_N64System);
return Result; return Result;
} }
@ -598,60 +597,47 @@ DWORD StopTimer ( void )
BOOL Machine_SaveState ( void ) BOOL Machine_SaveState ( void )
{ {
return CC_Core::SaveState(g_N64System); return CC_Core::SaveState(_N64System);
} }
void BreakPoint(LPCSTR FileName, int LineNumber ) void BreakPoint(LPCSTR FileName, int LineNumber )
{ {
if (g_Notify) if (_Notify)
{ {
g_Notify->BreakPoint(FileName,LineNumber); _Notify->BreakPoint(FileName,LineNumber);
} }
} }
void UpdateCurrentHalfLine (void)
{
if (*g_Timer < 0) {
*g_HalfLine = 0;
return;
}
//DisplayError("Timer: %X",Timers.Timer);
//HalfLine = (Timer / 1500) + VI_INTR_REG;
*g_HalfLine = (DWORD)(*g_Timer / g_ViRefreshRate);
*g_HalfLine &= ~1;
// *g_HalfLine += ViFieldNumber;
//Timers.Timer -= g_ViRefreshRate;
}
void CC_Core::ApplyGSButtonCheats (CN64System * System) void CC_Core::ApplyGSButtonCheats (CN64System * System)
{ {
if (System == NULL || System->_Cheats == NULL) if (System == NULL)
{ {
return; return;
} }
if (System->_Cheats->CheatsSlectionChanged()) if (System->m_Cheats.CheatsSlectionChanged())
{ {
System->_Cheats->LoadCheats(false); System->m_Cheats.LoadCheats(false);
} }
System->_Cheats->ApplyGSButton(System->_MMU); System->m_Cheats.ApplyGSButton(_MMU);
} }
void CC_Core::ApplyCheats (CN64System * System) void CC_Core::ApplyCheats (CN64System * System)
{ {
if (System == NULL || System->_Cheats == NULL) if (System == NULL)
{ {
return; return;
} }
if (System->_Cheats->CheatsSlectionChanged()) if (System->m_Cheats.CheatsSlectionChanged())
{ {
System->_Cheats->LoadCheats(false); System->m_Cheats.LoadCheats(false);
} }
System->_Cheats->ApplyCheats(System->_MMU); System->m_Cheats.ApplyCheats(_MMU);
} }
void ApplyCheats (void) void ApplyCheats (void)
{ {
CC_Core::ApplyCheats(g_N64System); CC_Core::ApplyCheats(_N64System);
} }
void ResetX86Logs ( void ) void ResetX86Logs ( void )
@ -665,12 +651,12 @@ void ResetX86Logs ( void )
BOOL EndEmulation ( void ) BOOL EndEmulation ( void )
{ {
return g_N64System->EndEmulation; return _N64System->m_EndEmulation;
} }
void SetEndEmulation ( BOOL End ) void SetEndEmulation ( BOOL End )
{ {
g_N64System->EndEmulation = End != 0; _N64System->m_EndEmulation = End != 0;
} }
void CloseSaveChips ( void ) void CloseSaveChips ( void )
@ -681,25 +667,9 @@ void CloseSaveChips ( void )
CloseFlashRam(); CloseFlashRam();
} }
BOOL TranslateVaddr( DWORD VAddr, DWORD * PAddr )
{
#ifdef _DEBUG
if (PAddr == NULL)
{
BreakPoint(__FILE__,__LINE__);
}
#endif
return g_TLB->TranslateVaddr(VAddr,*PAddr);
}
BOOL AddressDefined ( DWORD VAddr )
{
return g_TLB->TLB_AddressDefined(VAddr);
}
void TLB_ReadEntry ( void ) void TLB_ReadEntry ( void )
{ {
g_TLB->TLB_ReadEntry(); _TLB->ReadEntry();
} }
void TLB_WriteEntry( int index, BOOL Random ) void TLB_WriteEntry( int index, BOOL Random )
@ -708,12 +678,12 @@ void TLB_WriteEntry( int index, BOOL Random )
{ {
BreakPoint(__FILE__,__LINE__); BreakPoint(__FILE__,__LINE__);
} }
g_TLB->TLB_WriteEntry(index,Random != 0); _TLB->WriteEntry(index,Random != 0);
} }
void TLB_Probe() void TLB_Probe()
{ {
g_TLB->TLB_Probe(); _TLB->Probe();
} }
void SyncToPC (void) { void SyncToPC (void) {
@ -723,18 +693,18 @@ void SyncToPC (void) {
BOOL ClearRecompCodeProtectMem ( DWORD Address, int length ) BOOL ClearRecompCodeProtectMem ( DWORD Address, int length )
{ {
if (g_Recompiler) if (_Recompiler)
{ {
return g_Recompiler->ClearRecompCode_Phys(Address,length,CRecompiler::Remove_ProtectedMem); return _Recompiler->ClearRecompCode_Phys(Address,length,CRecompiler::Remove_ProtectedMem);
} }
return false; return false;
} }
BOOL ClearRecompCodeInitialCode ( void ) BOOL ClearRecompCodeInitialCode ( void )
{ {
if (g_Recompiler) if (_Recompiler)
{ {
return g_Recompiler->ClearRecompCode_Virt(0x80000000,0x200,CRecompiler::Remove_InitialCode); return _Recompiler->ClearRecompCode_Virt(0x80000000,0x200,CRecompiler::Remove_InitialCode);
} }
return false; return false;
} }

View File

@ -4,10 +4,11 @@
#include "..\\..\\Multilanguage.h" #include "..\\..\\Multilanguage.h"
#include "..\\..\\Plugin.h" #include "..\\..\\Plugin.h"
#ifdef toremove
extern CN64System * g_N64System; extern CN64System * g_N64System;
extern CN64System * g_SyncSystem; extern CN64System * g_SyncSystem;
extern CRecompiler * g_Recompiler; extern CRecompiler * g_Recompiler;
extern CMipsMemory * g_MMU; //Memory of the n64 extern CMipsMemoryVM * g_MMU; //Memory of the n64
extern CTLB * g_TLB; //TLB Unit extern CTLB * g_TLB; //TLB Unit
extern CRegisters * g_Reg; //Current Register Set attacted to the _MMU extern CRegisters * g_Reg; //Current Register Set attacted to the _MMU
extern CNotification * g_Notify; extern CNotification * g_Notify;
@ -15,6 +16,7 @@ extern CSettings * g_Settings;
extern CPlugins * g_Plugins; extern CPlugins * g_Plugins;
extern CN64Rom * g_Rom; //The current rom that this system is executing.. it can only execute one file at the time extern CN64Rom * g_Rom; //The current rom that this system is executing.. it can only execute one file at the time
extern CAudio * g_Audio; extern CAudio * g_Audio;
#endif
class CC_Core class CC_Core
{ {
@ -70,7 +72,6 @@ BOOL Machine_LoadState ( void );
BOOL Machine_SaveState ( void ); BOOL Machine_SaveState ( void );
void BreakPoint ( LPCSTR FileName, int LineNumber ); void BreakPoint ( LPCSTR FileName, int LineNumber );
void CleanCMemory ( void ); void CleanCMemory ( void );
void UpdateCurrentHalfLine ( void );
void ApplyCheats ( void ); void ApplyCheats ( void );
void RunRsp ( void ); void RunRsp ( void );
void RefreshScreen ( void ); void RefreshScreen ( void );
@ -82,9 +83,7 @@ void CloseSaveChips ( void );
//TLB Functions //TLB Functions
BOOL AddressDefined ( DWORD VAddr );
BOOL TranslateVaddr ( DWORD VAddr, DWORD * PAddr); BOOL TranslateVaddr ( DWORD VAddr, DWORD * PAddr);
void TLB_Probe ( void );
void TLB_ReadEntry ( void ); void TLB_ReadEntry ( void );
void TLB_WriteEntry ( int index, BOOL Random ); void TLB_WriteEntry ( int index, BOOL Random );
@ -100,6 +99,7 @@ DWORD StopTimer ( void );
//registers //registers
#ifdef toremove
extern MULTI_ACCESS_QWORD * g_GPR, * g_FPR, * g_HI, * g_LO; extern MULTI_ACCESS_QWORD * g_GPR, * g_FPR, * g_HI, * g_LO;
extern DWORD * g_PROGRAM_COUNTER, * g_CP0, * g_RegMI, * g_LLBit, extern DWORD * g_PROGRAM_COUNTER, * g_CP0, * g_RegMI, * g_LLBit,
* g_LLAddr, * g_FPCR, * g_RegSI, * g_RegRI, * g_RegPI, * g_RegAI, * g_LLAddr, * g_FPCR, * g_RegSI, * g_RegRI, * g_RegPI, * g_RegAI,
@ -108,6 +108,7 @@ extern double ** g_FPRDoubleLocation;
extern float ** g_FPRFloatLocation; extern float ** g_FPRFloatLocation;
extern enum TimerType * g_CurrentTimerType; extern enum TimerType * g_CurrentTimerType;
extern int * g_Timer; extern int * g_Timer;
#endif
//Register Name //Register Name
extern const char ** g_Cop0_Name; extern const char ** g_Cop0_Name;
@ -130,8 +131,8 @@ extern CONTROL * g_Controllers;
extern enum SystemType g_SystemType; extern enum SystemType g_SystemType;
//Memory //Memory
extern DWORD * g_TLB_ReadMap, * g_TLB_WriteMap, g_RdramSize, g_SystemRdramSize, *g_HalfLine, * g_MemoryStack; extern DWORD * g_TLB_ReadMap, * g_TLB_WriteMap, g_RdramSize, g_SystemRdramSize;
extern BYTE * g_N64MEM, *g_RDRAM, *g_DMEM, *g_IMEM, *g_ROM, *g_PIF_Ram; extern BYTE *g_RDRAM, *g_DMEM, *g_IMEM;
//Misc //Misc
enum { NoOfFrames = 7 }; enum { NoOfFrames = 7 };

View File

@ -5,7 +5,7 @@
#define Profiling g_Profiling #define Profiling g_Profiling
// Registers // Registers
#define GPR g_GPR /*#define GPR g_GPR
#define CP0 g_CP0 #define CP0 g_CP0
#define FPR g_FPR #define FPR g_FPR
#define FPCR g_FPCR #define FPCR g_FPCR
@ -23,7 +23,7 @@
#define HI (*g_HI) #define HI (*g_HI)
#define LO (*g_LO) #define LO (*g_LO)
#define FPRDoubleLocation g_FPRDoubleLocation #define FPRDoubleLocation g_FPRDoubleLocation
#define FPRFloatLocation g_FPRFloatLocation #define FPRFloatLocation g_FPRFloatLocation*/
//Register Names //Register Names
#define Cop0_Name g_Cop0_Name #define Cop0_Name g_Cop0_Name
@ -50,17 +50,14 @@
#define LookUpMode g_LookUpMode #define LookUpMode g_LookUpMode
//Plugins //Plugins
#define AudioIntrReg (*g_AudioIntrReg) //#define AudioIntrReg (*g_AudioIntrReg)
#define Controllers g_Controllers #define Controllers g_Controllers
//Misc //Misc
#define AppName GetAppName() #define AppName GetAppName()
#define N64MEM g_N64MEM
#define RDRAM g_RDRAM #define RDRAM g_RDRAM
#define DMEM g_DMEM #define DMEM g_DMEM
#define IMEM g_IMEM #define IMEM g_IMEM
#define ROM g_ROM
#define PIF_Ram g_PIF_Ram
#define TLB_WriteMap g_TLB_WriteMap #define TLB_WriteMap g_TLB_WriteMap
#define TLB_ReadMap g_TLB_ReadMap #define TLB_ReadMap g_TLB_ReadMap
#define RdramSize g_RdramSize #define RdramSize g_RdramSize

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,10 @@
* should be forwarded to them so if they want them. * should be forwarded to them so if they want them.
* *
*/ */
#ifdef toremove
extern void ** JumpTable;
extern BYTE *RecompCode, *RecompPos;
#include <Windows.h> #include <Windows.h>
#define ROM_IN_MAPSPACE #define ROM_IN_MAPSPACE
@ -72,3 +76,4 @@ void Compile_SW_Register ( CBlockSection * Section, int x86Reg, DWORD Ad
void ResetMemoryStack ( CBlockSection * Section ); void ResetMemoryStack ( CBlockSection * Section );
#endif #endif
#endif

View File

@ -1,6 +1,7 @@
#include "main.h" #include "main.h"
#include "CPU.h" #include "CPU.h"
#include "debugger.h" #include "debugger.h"
#include "Interpreter Ops 32.h"
//int NextInstruction, ManualPaused; //int NextInstruction, ManualPaused;
//int DlistCount, AlistCount; //int DlistCount, AlistCount;
@ -8,19 +9,21 @@
//DWORD MemoryStack; //DWORD MemoryStack;
DWORD JumpToLocation; DWORD JumpToLocation;
extern R4300iOp_FUNC * R4300i_Opcode;
void InitializeCPUCore ( void ) void InitializeCPUCore ( void )
{ {
LARGE_INTEGER PerformanceFrequency; LARGE_INTEGER PerformanceFrequency;
BuildInterpreter(); R4300i_Opcode = R4300iOp::BuildInterpreter();
//R4300i_Opcode = R4300iOp32::BuildInterpreter();
CurrentFrame = 0; CurrentFrame = 0;
QueryPerformanceFrequency(&PerformanceFrequency); QueryPerformanceFrequency(&PerformanceFrequency);
Frequency = PerformanceFrequency.QuadPart; Frequency = PerformanceFrequency.QuadPart;
{ {
BYTE Country = *(ROM + 0x3D); switch (_Rom->GetCountry())
switch (Country)
{ {
case Germany: case french: case Italian: case Germany: case french: case Italian:
case Europe: case Spanish: case Australia: case Europe: case Spanish: case Australia:
@ -58,7 +61,7 @@ void InitializeCPUCore ( void )
int DelaySlotEffectsJump (DWORD JumpPC) { int DelaySlotEffectsJump (DWORD JumpPC) {
OPCODE Command; OPCODE Command;
if (!r4300i_LW_VAddr(JumpPC, &Command.Hex)) { return TRUE; } if (!_MMU->LW_VAddr(JumpPC, Command.Hex)) { return TRUE; }
switch (Command.op) { switch (Command.op) {
case R4300i_SPECIAL: case R4300i_SPECIAL:
@ -98,7 +101,7 @@ int DelaySlotEffectsJump (DWORD JumpPC) {
int EffectDelaySlot; int EffectDelaySlot;
OPCODE NewCommand; OPCODE NewCommand;
if (!r4300i_LW_VAddr(JumpPC + 4, &NewCommand.Hex)) { return TRUE; } if (!_MMU->LW_VAddr(JumpPC + 4, NewCommand.Hex)) { return TRUE; }
EffectDelaySlot = FALSE; EffectDelaySlot = FALSE;
if (NewCommand.op == R4300i_CP1) { if (NewCommand.op == R4300i_CP1) {
@ -138,7 +141,7 @@ void DoSomething ( void ) {
ShowCFB(); ShowCFB();
FAKE_CAUSE_REGISTER |= CAUSE_IP4; FAKE_CAUSE_REGISTER |= CAUSE_IP4;
CheckInterrupts(); CheckInterrupts();
g_Plugins->Gfx()->SoftReset(); _Plugins->Gfx()->SoftReset();
} }
if (CPU_Action.GenerateInterrupt) if (CPU_Action.GenerateInterrupt)
@ -216,11 +219,11 @@ void TimerDone (void) {
} }
#if (!defined(EXTERNAL_RELEASE)) #if (!defined(EXTERNAL_RELEASE))
if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts) { if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts) {
LogMessage("%08X: Timer Done (Type: %d CurrentTimer: %d)", PROGRAM_COUNTER, *g_CurrentTimerType, *g_Timer ); LogMessage("%08X: Timer Done (Type: %d CurrentTimer: %d)", *_PROGRAM_COUNTER, *_CurrentTimerType, *_Timer );
} }
#endif #endif
switch (*g_CurrentTimerType) { switch (*_CurrentTimerType) {
case CompareTimer: case CompareTimer:
FAKE_CAUSE_REGISTER |= CAUSE_IP7; FAKE_CAUSE_REGISTER |= CAUSE_IP7;
CheckInterrupts(); CheckInterrupts();
@ -228,7 +231,7 @@ void TimerDone (void) {
break; break;
case SoftResetTimer: case SoftResetTimer:
ChangeTimer(SoftResetTimer,0); ChangeTimer(SoftResetTimer,0);
g_N64System->SoftReset(); _N64System->SoftReset();
break; break;
case SiTimer: case SiTimer:
ChangeTimer(SiTimer,0); ChangeTimer(SiTimer,0);
@ -255,7 +258,7 @@ void TimerDone (void) {
ChangeTimer(AiTimer,0); ChangeTimer(AiTimer,0);
MI_INTR_REG |= MI_INTR_AI; MI_INTR_REG |= MI_INTR_AI;
CheckInterrupts(); CheckInterrupts();
g_Audio->AiCallBack(); _Audio->AiCallBack();
break; break;
default: default:
BreakPoint(__FILE__,__LINE__); BreakPoint(__FILE__,__LINE__);
@ -283,15 +286,15 @@ void InPermLoop (void) {
if (( STATUS_REGISTER & 0xFF00) == 0) { goto InterruptsDisabled; } if (( STATUS_REGISTER & 0xFF00) == 0) { goto InterruptsDisabled; }
/* check sound playing */ /* check sound playing */
g_N64System->SyncToAudio(); _N64System->SyncToAudio();
/* check RSP running */ /* check RSP running */
/* check RDP running */ /* check RDP running */
if (*g_Timer > 0) { if (*_Timer > 0) {
COUNT_REGISTER += *g_Timer + 1; COUNT_REGISTER += *_Timer + 1;
//if (CPU_Type == CPU_SyncCores) { SyncRegisters.CP0[9] += Timers.Timer + 1; } //if (CPU_Type == CPU_SyncCores) { SyncRegisters.CP0[9] += Timers.Timer + 1; }
*g_Timer = -1; *_Timer = -1;
} }
return; return;
@ -308,7 +311,7 @@ InterruptsDisabled:
int DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) { int DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) {
OPCODE Command; OPCODE Command;
if (!r4300i_LW_VAddr(PC + 4, &Command.Hex)) { if (!_MMU->LW_VAddr(PC + 4, Command.Hex)) {
//DisplayError("Failed to load word 2"); //DisplayError("Failed to load word 2");
//ExitThread(0); //ExitThread(0);
return TRUE; return TRUE;

View File

@ -31,11 +31,11 @@
void OnFirstDMA (void) { void OnFirstDMA (void) {
switch (CicChip) { switch (CicChip) {
case 1: *(DWORD *)&N64MEM[0x318] = RdramSize; break; case 1: *(DWORD *)&RDRAM[0x318] = RdramSize; break;
case 2: *(DWORD *)&N64MEM[0x318] = RdramSize; break; case 2: *(DWORD *)&RDRAM[0x318] = RdramSize; break;
case 3: *(DWORD *)&N64MEM[0x318] = RdramSize; break; case 3: *(DWORD *)&RDRAM[0x318] = RdramSize; break;
case 5: *(DWORD *)&N64MEM[0x3F0] = RdramSize; break; case 5: *(DWORD *)&RDRAM[0x3F0] = RdramSize; break;
case 6: *(DWORD *)&N64MEM[0x318] = RdramSize; break; case 6: *(DWORD *)&RDRAM[0x318] = RdramSize; break;
default: DisplayError("Unhandled CicChip(%d) in first DMA",CicChip); default: DisplayError("Unhandled CicChip(%d) in first DMA",CicChip);
} }
} }
@ -57,7 +57,7 @@ void PI_DMA_READ (void) {
if (SaveUsing == SaveChip_Auto) { SaveUsing = SaveChip_Sram; } if (SaveUsing == SaveChip_Auto) { SaveUsing = SaveChip_Sram; }
if (SaveUsing == SaveChip_Sram) { if (SaveUsing == SaveChip_Sram) {
DmaToSram( DmaToSram(
N64MEM+PI_DRAM_ADDR_REG, RDRAM+PI_DRAM_ADDR_REG,
PI_CART_ADDR_REG - 0x08000000, PI_CART_ADDR_REG - 0x08000000,
PI_RD_LEN_REG + 1 PI_RD_LEN_REG + 1
); );
@ -68,7 +68,7 @@ void PI_DMA_READ (void) {
} }
if (SaveUsing == SaveChip_FlashRam) { if (SaveUsing == SaveChip_FlashRam) {
DmaToFlashram( DmaToFlashram(
N64MEM+PI_DRAM_ADDR_REG, RDRAM+PI_DRAM_ADDR_REG,
PI_CART_ADDR_REG - 0x08000000, PI_CART_ADDR_REG - 0x08000000,
PI_WR_LEN_REG + 1 PI_WR_LEN_REG + 1
); );
@ -97,7 +97,6 @@ void PI_DMA_READ (void) {
} }
void PI_DMA_WRITE (void) { void PI_DMA_WRITE (void) {
DWORD i;
PI_STATUS_REG |= PI_STATUS_DMA_BUSY; PI_STATUS_REG |= PI_STATUS_DMA_BUSY;
if ( PI_DRAM_ADDR_REG + PI_WR_LEN_REG + 1 > RdramSize) if ( PI_DRAM_ADDR_REG + PI_WR_LEN_REG + 1 > RdramSize)
@ -113,7 +112,7 @@ void PI_DMA_WRITE (void) {
if (SaveUsing == SaveChip_Auto) { SaveUsing = SaveChip_Sram; } if (SaveUsing == SaveChip_Auto) { SaveUsing = SaveChip_Sram; }
if (SaveUsing == SaveChip_Sram) { if (SaveUsing == SaveChip_Sram) {
DmaFromSram( DmaFromSram(
N64MEM+PI_DRAM_ADDR_REG, RDRAM+PI_DRAM_ADDR_REG,
PI_CART_ADDR_REG - 0x08000000, PI_CART_ADDR_REG - 0x08000000,
PI_WR_LEN_REG + 1 PI_WR_LEN_REG + 1
); );
@ -124,7 +123,7 @@ void PI_DMA_WRITE (void) {
} }
if (SaveUsing == SaveChip_FlashRam) { if (SaveUsing == SaveChip_FlashRam) {
DmaFromFlashram( DmaFromFlashram(
N64MEM+PI_DRAM_ADDR_REG, RDRAM+PI_DRAM_ADDR_REG,
PI_CART_ADDR_REG - 0x08000000, PI_CART_ADDR_REG - 0x08000000,
PI_WR_LEN_REG + 1 PI_WR_LEN_REG + 1
); );
@ -136,25 +135,29 @@ void PI_DMA_WRITE (void) {
} }
if ( PI_CART_ADDR_REG >= 0x10000000 && PI_CART_ADDR_REG <= 0x1FBFFFFF) { if ( PI_CART_ADDR_REG >= 0x10000000 && PI_CART_ADDR_REG <= 0x1FBFFFFF) {
DWORD i;
#ifdef tofix
#ifdef ROM_IN_MAPSPACE #ifdef ROM_IN_MAPSPACE
if (WrittenToRom) { if (WrittenToRom) {
DWORD OldProtect; DWORD OldProtect;
VirtualProtect(ROM,RomFileSize,PAGE_READONLY, &OldProtect); VirtualProtect(ROM,RomFileSize,PAGE_READONLY, &OldProtect);
} }
#endif #endif
#endif
BYTE * ROM = _Rom->GetRomAddress();
PI_CART_ADDR_REG -= 0x10000000; PI_CART_ADDR_REG -= 0x10000000;
if (PI_CART_ADDR_REG + PI_WR_LEN_REG + 1 < RomFileSize) { if (PI_CART_ADDR_REG + PI_WR_LEN_REG + 1 < RomFileSize) {
for (i = 0; i < PI_WR_LEN_REG + 1; i ++) { for (i = 0; i < PI_WR_LEN_REG + 1; i ++) {
*(N64MEM+((PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((PI_CART_ADDR_REG + i) ^ 3)); *(RDRAM+((PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((PI_CART_ADDR_REG + i) ^ 3));
} }
} else { } else {
DWORD Len; DWORD Len;
Len = RomFileSize - PI_CART_ADDR_REG; Len = RomFileSize - PI_CART_ADDR_REG;
for (i = 0; i < Len; i ++) { for (i = 0; i < Len; i ++) {
*(N64MEM+((PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((PI_CART_ADDR_REG + i) ^ 3)); *(RDRAM+((PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((PI_CART_ADDR_REG + i) ^ 3));
} }
for (i = Len; i < PI_WR_LEN_REG + 1 - Len; i ++) { for (i = Len; i < PI_WR_LEN_REG + 1 - Len; i ++) {
*(N64MEM+((PI_DRAM_ADDR_REG + i) ^ 3)) = 0; *(RDRAM+((PI_DRAM_ADDR_REG + i) ^ 3)) = 0;
} }
} }
PI_CART_ADDR_REG += 0x10000000; PI_CART_ADDR_REG += 0x10000000;
@ -163,9 +166,9 @@ void PI_DMA_WRITE (void) {
CPU_Action.DMAUsed = TRUE; CPU_Action.DMAUsed = TRUE;
OnFirstDMA(); OnFirstDMA();
} }
if (g_Recompiler && g_Recompiler->bSMM_PIDMA()) if (_Recompiler && _Recompiler->bSMM_PIDMA())
{ {
g_Recompiler->ClearRecompCode_Phys(PI_DRAM_ADDR_REG, PI_WR_LEN_REG,CRecompiler::Remove_DMA); _Recompiler->ClearRecompCode_Phys(PI_DRAM_ADDR_REG, PI_WR_LEN_REG,CRecompiler::Remove_DMA);
} }
PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
MI_INTR_REG |= MI_INTR_PI; MI_INTR_REG |= MI_INTR_PI;
@ -183,7 +186,8 @@ void PI_DMA_WRITE (void) {
} }
void SI_DMA_READ (void) { void SI_DMA_READ (void) {
BYTE * PifRamPos = &PIF_Ram[0]; BYTE * PIF_Ram = _MMU->PifRam();
BYTE * PifRamPos = _MMU->PifRam();
if ((int)SI_DRAM_ADDR_REG > (int)RdramSize) { if ((int)SI_DRAM_ADDR_REG > (int)RdramSize) {
#ifndef EXTERNAL_RELEASE #ifndef EXTERNAL_RELEASE
@ -200,13 +204,13 @@ void SI_DMA_READ (void) {
RdramPos = (int)SI_DRAM_ADDR_REG; RdramPos = (int)SI_DRAM_ADDR_REG;
for (count = 0; count < 0x40; count++, RdramPos++) { for (count = 0; count < 0x40; count++, RdramPos++) {
if (RdramPos < 0) { continue; } if (RdramPos < 0) { continue; }
N64MEM[RdramPos ^3] = PIF_Ram[count]; RDRAM[RdramPos ^3] = PIF_Ram[count];
} }
} else { } else {
_asm { _asm {
mov edi, dword ptr [RegSI] mov edi, dword ptr [_RegSI]
mov edi, dword ptr [edi] mov edi, dword ptr [edi]
add edi, N64MEM add edi, RDRAM
mov ecx, PifRamPos mov ecx, PifRamPos
mov edx, 0 mov edx, 0
memcpyloop: memcpyloop:
@ -271,7 +275,8 @@ void SI_DMA_READ (void) {
} }
void SI_DMA_WRITE (void) { void SI_DMA_WRITE (void) {
BYTE * PifRamPos = &PIF_Ram[0]; BYTE * PIF_Ram = _MMU->PifRam();
BYTE * PifRamPos = PIF_Ram;
if ((int)SI_DRAM_ADDR_REG > (int)RdramSize) { if ((int)SI_DRAM_ADDR_REG > (int)RdramSize) {
#ifndef EXTERNAL_RELEASE #ifndef EXTERNAL_RELEASE
@ -287,13 +292,13 @@ void SI_DMA_WRITE (void) {
RdramPos = (int)SI_DRAM_ADDR_REG; RdramPos = (int)SI_DRAM_ADDR_REG;
for (count = 0; count < 0x40; count++, RdramPos++) { for (count = 0; count < 0x40; count++, RdramPos++) {
if (RdramPos < 0) { PIF_Ram[count] = 0; continue; } if (RdramPos < 0) { PIF_Ram[count] = 0; continue; }
PIF_Ram[count] = N64MEM[RdramPos ^3]; PIF_Ram[count] = RDRAM[RdramPos ^3];
} }
} else { } else {
_asm { _asm {
mov ecx, dword ptr [RegSI] mov ecx, dword ptr [_RegSI]
mov ecx, dword ptr [ecx] mov ecx, dword ptr [ecx]
add ecx, N64MEM add ecx, RDRAM
mov edi, PifRamPos mov edi, PifRamPos
mov edx, 0 mov edx, 0
memcpyloop: memcpyloop:
@ -383,7 +388,7 @@ void SP_DMA_READ (void) {
if ((SP_DRAM_ADDR_REG & 3) != 0) { BreakPoint(__FILE__,__LINE__); } if ((SP_DRAM_ADDR_REG & 3) != 0) { BreakPoint(__FILE__,__LINE__); }
if (((SP_RD_LEN_REG + 1) & 3) != 0) { BreakPoint(__FILE__,__LINE__); } if (((SP_RD_LEN_REG + 1) & 3) != 0) { BreakPoint(__FILE__,__LINE__); }
memcpy( DMEM + (SP_MEM_ADDR_REG & 0x1FFF), N64MEM + SP_DRAM_ADDR_REG, memcpy( DMEM + (SP_MEM_ADDR_REG & 0x1FFF), RDRAM + SP_DRAM_ADDR_REG,
SP_RD_LEN_REG + 1 ); SP_RD_LEN_REG + 1 );
SP_DMA_BUSY_REG = 0; SP_DMA_BUSY_REG = 0;
@ -409,7 +414,7 @@ void SP_DMA_WRITE (void) {
if ((SP_DRAM_ADDR_REG & 3) != 0) { BreakPoint(__FILE__,__LINE__); } if ((SP_DRAM_ADDR_REG & 3) != 0) { BreakPoint(__FILE__,__LINE__); }
if (((SP_WR_LEN_REG + 1) & 3) != 0) { BreakPoint(__FILE__,__LINE__); } if (((SP_WR_LEN_REG + 1) & 3) != 0) { BreakPoint(__FILE__,__LINE__); }
memcpy( N64MEM + SP_DRAM_ADDR_REG, DMEM + (SP_MEM_ADDR_REG & 0x1FFF), memcpy( RDRAM + SP_DRAM_ADDR_REG, DMEM + (SP_MEM_ADDR_REG & 0x1FFF),
SP_WR_LEN_REG + 1); SP_WR_LEN_REG + 1);
SP_DMA_BUSY_REG = 0; SP_DMA_BUSY_REG = 0;

View File

@ -38,7 +38,7 @@ void __cdecl CheckInterrupts ( void ) {
if (!g_FixedAudio && CPU_Type != CPU_SyncCores) { if (!g_FixedAudio && CPU_Type != CPU_SyncCores) {
MI_INTR_REG &= ~MI_INTR_AI; MI_INTR_REG &= ~MI_INTR_AI;
MI_INTR_REG |= (AudioIntrReg & MI_INTR_AI); MI_INTR_REG |= (_Reg->AudioIntrReg & MI_INTR_AI);
} }
if ((MI_INTR_MASK_REG & MI_INTR_REG) != 0) { if ((MI_INTR_MASK_REG & MI_INTR_REG) != 0) {
FAKE_CAUSE_REGISTER |= CAUSE_IP2; FAKE_CAUSE_REGISTER |= CAUSE_IP2;
@ -76,12 +76,12 @@ void DoAddressError ( BOOL DelaySlot, DWORD BadVaddr, BOOL FromRead) {
BAD_VADDR_REGISTER = BadVaddr; BAD_VADDR_REGISTER = BadVaddr;
if (DelaySlot) { if (DelaySlot) {
CAUSE_REGISTER |= CAUSE_BD; CAUSE_REGISTER |= CAUSE_BD;
EPC_REGISTER = PROGRAM_COUNTER - 4; EPC_REGISTER = (*_PROGRAM_COUNTER) - 4;
} else { } else {
EPC_REGISTER = PROGRAM_COUNTER; EPC_REGISTER = (*_PROGRAM_COUNTER);
} }
STATUS_REGISTER |= STATUS_EXL; STATUS_REGISTER |= STATUS_EXL;
PROGRAM_COUNTER = 0x80000180; (*_PROGRAM_COUNTER) = 0x80000180;
} }
void DoBreakException ( BOOL DelaySlot) { void DoBreakException ( BOOL DelaySlot) {
@ -97,12 +97,12 @@ void DoBreakException ( BOOL DelaySlot) {
CAUSE_REGISTER = EXC_BREAK; CAUSE_REGISTER = EXC_BREAK;
if (DelaySlot) { if (DelaySlot) {
CAUSE_REGISTER |= CAUSE_BD; CAUSE_REGISTER |= CAUSE_BD;
EPC_REGISTER = PROGRAM_COUNTER - 4; EPC_REGISTER = (*_PROGRAM_COUNTER) - 4;
} else { } else {
EPC_REGISTER = PROGRAM_COUNTER; EPC_REGISTER = (*_PROGRAM_COUNTER);
} }
STATUS_REGISTER |= STATUS_EXL; STATUS_REGISTER |= STATUS_EXL;
PROGRAM_COUNTER = 0x80000180; (*_PROGRAM_COUNTER) = 0x80000180;
} }
void _fastcall DoCopUnusableException ( BOOL DelaySlot, int Coprocessor ) { void _fastcall DoCopUnusableException ( BOOL DelaySlot, int Coprocessor ) {
@ -119,12 +119,12 @@ void _fastcall DoCopUnusableException ( BOOL DelaySlot, int Coprocessor ) {
if (Coprocessor == 1) { CAUSE_REGISTER |= 0x10000000; } if (Coprocessor == 1) { CAUSE_REGISTER |= 0x10000000; }
if (DelaySlot) { if (DelaySlot) {
CAUSE_REGISTER |= CAUSE_BD; CAUSE_REGISTER |= CAUSE_BD;
EPC_REGISTER = PROGRAM_COUNTER - 4; EPC_REGISTER = (*_PROGRAM_COUNTER) - 4;
} else { } else {
EPC_REGISTER = PROGRAM_COUNTER; EPC_REGISTER = (*_PROGRAM_COUNTER);
} }
STATUS_REGISTER |= STATUS_EXL; STATUS_REGISTER |= STATUS_EXL;
PROGRAM_COUNTER = 0x80000180; (*_PROGRAM_COUNTER) = 0x80000180;
} }
BOOL DoIntrException ( BOOL DelaySlot ) { BOOL DoIntrException ( BOOL DelaySlot ) {
@ -133,19 +133,19 @@ BOOL DoIntrException ( BOOL DelaySlot ) {
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) { return FALSE; } if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) { return FALSE; }
#if (!defined(EXTERNAL_RELEASE)) #if (!defined(EXTERNAL_RELEASE))
if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts) { if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts) {
LogMessage("%08X: Interupt Generated", PROGRAM_COUNTER ); LogMessage("%08X: Interupt Generated", (*_PROGRAM_COUNTER) );
} }
#endif #endif
CAUSE_REGISTER = FAKE_CAUSE_REGISTER; CAUSE_REGISTER = FAKE_CAUSE_REGISTER;
CAUSE_REGISTER |= EXC_INT; CAUSE_REGISTER |= EXC_INT;
if (DelaySlot) { if (DelaySlot) {
CAUSE_REGISTER |= CAUSE_BD; CAUSE_REGISTER |= CAUSE_BD;
EPC_REGISTER = PROGRAM_COUNTER - 4; EPC_REGISTER = (*_PROGRAM_COUNTER) - 4;
} else { } else {
EPC_REGISTER = PROGRAM_COUNTER; EPC_REGISTER = (*_PROGRAM_COUNTER);
} }
STATUS_REGISTER |= STATUS_EXL; STATUS_REGISTER |= STATUS_EXL;
PROGRAM_COUNTER = 0x80000180; (*_PROGRAM_COUNTER) = 0x80000180;
return TRUE; return TRUE;
} }
@ -158,21 +158,25 @@ void _fastcall DoTLBMiss ( BOOL DelaySlot, DWORD BadVaddr ) {
if ((STATUS_REGISTER & STATUS_EXL) == 0) { if ((STATUS_REGISTER & STATUS_EXL) == 0) {
if (DelaySlot) { if (DelaySlot) {
CAUSE_REGISTER |= CAUSE_BD; CAUSE_REGISTER |= CAUSE_BD;
EPC_REGISTER = PROGRAM_COUNTER - 4; EPC_REGISTER = (*_PROGRAM_COUNTER) - 4;
} else { } else {
EPC_REGISTER = PROGRAM_COUNTER; EPC_REGISTER = (*_PROGRAM_COUNTER);
} }
if (AddressDefined(BadVaddr)) { if (_TLB->AddressDefined(BadVaddr))
PROGRAM_COUNTER = 0x80000180; {
(*_PROGRAM_COUNTER) = 0x80000180;
} else { } else {
PROGRAM_COUNTER = 0x80000000; (*_PROGRAM_COUNTER) = 0x80000000;
} }
STATUS_REGISTER |= STATUS_EXL; STATUS_REGISTER |= STATUS_EXL;
} else { } else {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
#ifndef EXTERNAL_RELEASE #ifndef EXTERNAL_RELEASE
DisplayError("TLBMiss - EXL Set\nBadVaddr = %X\nAddress Defined: %s",BadVaddr,AddressDefined(BadVaddr)?"TRUE":"FALSE"); DisplayError("TLBMiss - EXL Set\nBadVaddr = %X\nAddress Defined: %s",BadVaddr,_TLB->TLB_AddressDefined(BadVaddr)?"TRUE":"FALSE");
#endif #endif
PROGRAM_COUNTER = 0x80000180; #endif
(*_PROGRAM_COUNTER) = 0x80000180;
} }
} }
@ -189,10 +193,10 @@ void _fastcall DoSysCallException ( BOOL DelaySlot) {
CAUSE_REGISTER = EXC_SYSCALL; CAUSE_REGISTER = EXC_SYSCALL;
if (DelaySlot) { if (DelaySlot) {
CAUSE_REGISTER |= CAUSE_BD; CAUSE_REGISTER |= CAUSE_BD;
EPC_REGISTER = PROGRAM_COUNTER - 4; EPC_REGISTER = (*_PROGRAM_COUNTER) - 4;
} else { } else {
EPC_REGISTER = PROGRAM_COUNTER; EPC_REGISTER = (*_PROGRAM_COUNTER);
} }
STATUS_REGISTER |= STATUS_EXL; STATUS_REGISTER |= STATUS_EXL;
PROGRAM_COUNTER = 0x80000180; (*_PROGRAM_COUNTER) = 0x80000180;
} }

View File

@ -106,7 +106,7 @@ void DmaFromFlashram(BYTE * dest, int StartOffset, int len) {
break; break;
#ifndef EXTERNAL_RELEASE #ifndef EXTERNAL_RELEASE
default: default:
DisplayError("DmaFromFlashram Start: %X, Offset: %X len: %X",dest - N64MEM,StartOffset,len); DisplayError("DmaFromFlashram Start: %X, Offset: %X len: %X",dest - RDRAM,StartOffset,len);
#endif #endif
} }
} }
@ -118,7 +118,7 @@ void DmaToFlashram(BYTE * Source, int StartOffset, int len) {
break; break;
#ifndef EXTERNAL_RELEASE #ifndef EXTERNAL_RELEASE
default: default:
DisplayError("DmaToFlashram Start: %X, Offset: %X len: %X",Source - N64MEM,StartOffset,len); DisplayError("DmaToFlashram Start: %X, Offset: %X len: %X",Source - RDRAM,StartOffset,len);
#endif #endif
} }
} }

View File

@ -32,660 +32,20 @@
#include "debugger.h" #include "debugger.h"
#include "plugin.h" #include "plugin.h"
void * R4300i_Opcode[64];
void * R4300i_Special[64];
void * R4300i_Regimm[32];
void * R4300i_CoP0[32];
void * R4300i_CoP0_Function[64];
void * R4300i_CoP1[32];
void * R4300i_CoP1_BC[32];
void * R4300i_CoP1_S[64];
void * R4300i_CoP1_D[64];
void * R4300i_CoP1_W[64];
void * R4300i_CoP1_L[64];
BOOL TestTimer = FALSE; BOOL TestTimer = FALSE;
void _fastcall R4300i_opcode_SPECIAL (void) { R4300iOp_FUNC * R4300i_Opcode;
((void (_fastcall *)()) R4300i_Special[ Opcode.funct ])();
}
void _fastcall R4300i_opcode_REGIMM (void) { BOOL ExecuteInterpreterOpCode (void)
((void (_fastcall *)()) R4300i_Regimm[ Opcode.rt ])(); {
} if (!_MMU->LW_VAddr((*_PROGRAM_COUNTER), Opcode.Hex)) {
DoTLBMiss(NextInstruction == JUMP,(*_PROGRAM_COUNTER));
void _fastcall R4300i_opcode_COP0 (void) {
((void (_fastcall *)()) R4300i_CoP0[ Opcode.rs ])();
}
void _fastcall R4300i_opcode_COP0_CO (void) {
((void (_fastcall *)()) R4300i_CoP0_Function[ Opcode.funct ])();
}
void _fastcall R4300i_opcode_COP1 (void) {
((void (_fastcall *)()) R4300i_CoP1[ Opcode.fmt ])();
}
void _fastcall R4300i_opcode_COP1_BC (void) {
((void (_fastcall *)()) R4300i_CoP1_BC[ Opcode.ft ])();
}
void _fastcall R4300i_opcode_COP1_S (void) {
_controlfp(RoundingModel,_MCW_RC);
((void (_fastcall *)()) R4300i_CoP1_S[ Opcode.funct ])();
}
void _fastcall R4300i_opcode_COP1_D (void) {
_controlfp(RoundingModel,_MCW_RC);
((void (_fastcall *)()) R4300i_CoP1_D[ Opcode.funct ])();
}
void _fastcall R4300i_opcode_COP1_W (void) {
((void (_fastcall *)()) R4300i_CoP1_W[ Opcode.funct ])();
}
void _fastcall R4300i_opcode_COP1_L (void) {
((void (_fastcall *)()) R4300i_CoP1_L[ Opcode.funct ])();
}
void BuildInterpreter (void ) {
R4300i_Opcode[ 0] = R4300i_opcode_SPECIAL;
R4300i_Opcode[ 1] = R4300i_opcode_REGIMM;
R4300i_Opcode[ 2] = r4300i_J;
R4300i_Opcode[ 3] = r4300i_JAL;
R4300i_Opcode[ 4] = r4300i_BEQ;
R4300i_Opcode[ 5] = r4300i_BNE;
R4300i_Opcode[ 6] = r4300i_BLEZ;
R4300i_Opcode[ 7] = r4300i_BGTZ;
R4300i_Opcode[ 8] = r4300i_ADDI;
R4300i_Opcode[ 9] = r4300i_ADDIU;
R4300i_Opcode[10] = r4300i_SLTI;
R4300i_Opcode[11] = r4300i_SLTIU;
R4300i_Opcode[12] = r4300i_ANDI;
R4300i_Opcode[13] = r4300i_ORI;
R4300i_Opcode[14] = r4300i_XORI;
R4300i_Opcode[15] = r4300i_LUI;
R4300i_Opcode[16] = R4300i_opcode_COP0;
R4300i_Opcode[17] = R4300i_opcode_COP1;
R4300i_Opcode[18] = R4300i_UnknownOpcode;
R4300i_Opcode[19] = R4300i_UnknownOpcode;
R4300i_Opcode[20] = r4300i_BEQL;
R4300i_Opcode[21] = r4300i_BNEL;
R4300i_Opcode[22] = r4300i_BLEZL;
R4300i_Opcode[23] = r4300i_BGTZL;
R4300i_Opcode[24] = R4300i_UnknownOpcode;
R4300i_Opcode[25] = r4300i_DADDIU;
R4300i_Opcode[26] = r4300i_LDL;
R4300i_Opcode[27] = r4300i_LDR;
R4300i_Opcode[28] = R4300i_UnknownOpcode;
R4300i_Opcode[29] = R4300i_UnknownOpcode;
R4300i_Opcode[30] = R4300i_UnknownOpcode;
R4300i_Opcode[31] = R4300i_UnknownOpcode;
R4300i_Opcode[32] = r4300i_LB;
R4300i_Opcode[33] = r4300i_LH;
R4300i_Opcode[34] = r4300i_LWL;
R4300i_Opcode[35] = r4300i_LW;
R4300i_Opcode[36] = r4300i_LBU;
R4300i_Opcode[37] = r4300i_LHU;
R4300i_Opcode[38] = r4300i_LWR;
R4300i_Opcode[39] = r4300i_LWU;
R4300i_Opcode[40] = r4300i_SB;
R4300i_Opcode[41] = r4300i_SH;
R4300i_Opcode[42] = r4300i_SWL;
R4300i_Opcode[43] = r4300i_SW;
R4300i_Opcode[44] = r4300i_SDL;
R4300i_Opcode[45] = r4300i_SDR;
R4300i_Opcode[46] = r4300i_SWR;
R4300i_Opcode[47] = r4300i_CACHE;
R4300i_Opcode[48] = r4300i_LL;
R4300i_Opcode[49] = r4300i_LWC1;
R4300i_Opcode[50] = R4300i_UnknownOpcode;
R4300i_Opcode[51] = R4300i_UnknownOpcode;
R4300i_Opcode[52] = R4300i_UnknownOpcode;
R4300i_Opcode[53] = r4300i_LDC1;
R4300i_Opcode[54] = R4300i_UnknownOpcode;
R4300i_Opcode[55] = r4300i_LD;
R4300i_Opcode[56] = r4300i_SC;
R4300i_Opcode[57] = r4300i_SWC1;
R4300i_Opcode[58] = R4300i_UnknownOpcode;
R4300i_Opcode[59] = R4300i_UnknownOpcode;
R4300i_Opcode[60] = R4300i_UnknownOpcode;
R4300i_Opcode[61] = r4300i_SDC1;
R4300i_Opcode[62] = R4300i_UnknownOpcode;
R4300i_Opcode[63] = r4300i_SD;
R4300i_Special[ 0] = r4300i_SPECIAL_SLL;
R4300i_Special[ 1] = R4300i_UnknownOpcode;
R4300i_Special[ 2] = r4300i_SPECIAL_SRL;
R4300i_Special[ 3] = r4300i_SPECIAL_SRA;
R4300i_Special[ 4] = r4300i_SPECIAL_SLLV;
R4300i_Special[ 5] = R4300i_UnknownOpcode;
R4300i_Special[ 6] = r4300i_SPECIAL_SRLV;
R4300i_Special[ 7] = r4300i_SPECIAL_SRAV;
R4300i_Special[ 8] = r4300i_SPECIAL_JR;
R4300i_Special[ 9] = r4300i_SPECIAL_JALR;
R4300i_Special[10] = R4300i_UnknownOpcode;
R4300i_Special[11] = R4300i_UnknownOpcode;
R4300i_Special[12] = r4300i_SPECIAL_SYSCALL;
R4300i_Special[13] = R4300i_UnknownOpcode;
R4300i_Special[14] = R4300i_UnknownOpcode;
R4300i_Special[15] = r4300i_SPECIAL_SYNC;
R4300i_Special[16] = r4300i_SPECIAL_MFHI;
R4300i_Special[17] = r4300i_SPECIAL_MTHI;
R4300i_Special[18] = r4300i_SPECIAL_MFLO;
R4300i_Special[19] = r4300i_SPECIAL_MTLO;
R4300i_Special[20] = r4300i_SPECIAL_DSLLV;
R4300i_Special[21] = R4300i_UnknownOpcode;
R4300i_Special[22] = r4300i_SPECIAL_DSRLV;
R4300i_Special[23] = r4300i_SPECIAL_DSRAV;
R4300i_Special[24] = r4300i_SPECIAL_MULT;
R4300i_Special[25] = r4300i_SPECIAL_MULTU;
R4300i_Special[26] = r4300i_SPECIAL_DIV;
R4300i_Special[27] = r4300i_SPECIAL_DIVU;
R4300i_Special[28] = r4300i_SPECIAL_DMULT;
R4300i_Special[29] = r4300i_SPECIAL_DMULTU;
R4300i_Special[30] = r4300i_SPECIAL_DDIV;
R4300i_Special[31] = r4300i_SPECIAL_DDIVU;
R4300i_Special[32] = r4300i_SPECIAL_ADD;
R4300i_Special[33] = r4300i_SPECIAL_ADDU;
R4300i_Special[34] = r4300i_SPECIAL_SUB;
R4300i_Special[35] = r4300i_SPECIAL_SUBU;
R4300i_Special[36] = r4300i_SPECIAL_AND;
R4300i_Special[37] = r4300i_SPECIAL_OR;
R4300i_Special[38] = r4300i_SPECIAL_XOR;
R4300i_Special[39] = r4300i_SPECIAL_NOR;
R4300i_Special[40] = R4300i_UnknownOpcode;
R4300i_Special[41] = R4300i_UnknownOpcode;
R4300i_Special[42] = r4300i_SPECIAL_SLT;
R4300i_Special[43] = r4300i_SPECIAL_SLTU;
R4300i_Special[44] = r4300i_SPECIAL_DADD;
R4300i_Special[45] = r4300i_SPECIAL_DADDU;
R4300i_Special[46] = r4300i_SPECIAL_DSUB;
R4300i_Special[47] = r4300i_SPECIAL_DSUBU;
R4300i_Special[48] = R4300i_UnknownOpcode;
R4300i_Special[49] = R4300i_UnknownOpcode;
R4300i_Special[50] = R4300i_UnknownOpcode;
R4300i_Special[51] = R4300i_UnknownOpcode;
R4300i_Special[52] = r4300i_SPECIAL_TEQ;
R4300i_Special[53] = R4300i_UnknownOpcode;
R4300i_Special[54] = R4300i_UnknownOpcode;
R4300i_Special[55] = R4300i_UnknownOpcode;
R4300i_Special[56] = r4300i_SPECIAL_DSLL;
R4300i_Special[57] = R4300i_UnknownOpcode;
R4300i_Special[58] = r4300i_SPECIAL_DSRL;
R4300i_Special[59] = r4300i_SPECIAL_DSRA;
R4300i_Special[60] = r4300i_SPECIAL_DSLL32;
R4300i_Special[61] = R4300i_UnknownOpcode;
R4300i_Special[62] = r4300i_SPECIAL_DSRL32;
R4300i_Special[63] = r4300i_SPECIAL_DSRA32;
R4300i_Regimm[ 0] = r4300i_REGIMM_BLTZ;
R4300i_Regimm[ 1] = r4300i_REGIMM_BGEZ;
R4300i_Regimm[ 2] = r4300i_REGIMM_BLTZL;
R4300i_Regimm[ 3] = r4300i_REGIMM_BGEZL;
R4300i_Regimm[ 4] = R4300i_UnknownOpcode;
R4300i_Regimm[ 5] = R4300i_UnknownOpcode;
R4300i_Regimm[ 6] = R4300i_UnknownOpcode;
R4300i_Regimm[ 7] = R4300i_UnknownOpcode;
R4300i_Regimm[ 8] = R4300i_UnknownOpcode;
R4300i_Regimm[ 9] = R4300i_UnknownOpcode;
R4300i_Regimm[10] = R4300i_UnknownOpcode;
R4300i_Regimm[11] = R4300i_UnknownOpcode;
R4300i_Regimm[12] = R4300i_UnknownOpcode;
R4300i_Regimm[13] = R4300i_UnknownOpcode;
R4300i_Regimm[14] = R4300i_UnknownOpcode;
R4300i_Regimm[15] = R4300i_UnknownOpcode;
R4300i_Regimm[16] = r4300i_REGIMM_BLTZAL;
R4300i_Regimm[17] = r4300i_REGIMM_BGEZAL;
R4300i_Regimm[18] = R4300i_UnknownOpcode;
R4300i_Regimm[19] = R4300i_UnknownOpcode;
R4300i_Regimm[20] = R4300i_UnknownOpcode;
R4300i_Regimm[21] = R4300i_UnknownOpcode;
R4300i_Regimm[22] = R4300i_UnknownOpcode;
R4300i_Regimm[23] = R4300i_UnknownOpcode;
R4300i_Regimm[24] = R4300i_UnknownOpcode;
R4300i_Regimm[25] = R4300i_UnknownOpcode;
R4300i_Regimm[26] = R4300i_UnknownOpcode;
R4300i_Regimm[27] = R4300i_UnknownOpcode;
R4300i_Regimm[28] = R4300i_UnknownOpcode;
R4300i_Regimm[29] = R4300i_UnknownOpcode;
R4300i_Regimm[30] = R4300i_UnknownOpcode;
R4300i_Regimm[31] = R4300i_UnknownOpcode;
R4300i_CoP0[ 0] = r4300i_COP0_MF;
R4300i_CoP0[ 1] = R4300i_UnknownOpcode;
R4300i_CoP0[ 2] = R4300i_UnknownOpcode;
R4300i_CoP0[ 3] = R4300i_UnknownOpcode;
R4300i_CoP0[ 4] = r4300i_COP0_MT;
R4300i_CoP0[ 5] = R4300i_UnknownOpcode;
R4300i_CoP0[ 6] = R4300i_UnknownOpcode;
R4300i_CoP0[ 7] = R4300i_UnknownOpcode;
R4300i_CoP0[ 8] = R4300i_UnknownOpcode;
R4300i_CoP0[ 9] = R4300i_UnknownOpcode;
R4300i_CoP0[10] = R4300i_UnknownOpcode;
R4300i_CoP0[11] = R4300i_UnknownOpcode;
R4300i_CoP0[12] = R4300i_UnknownOpcode;
R4300i_CoP0[13] = R4300i_UnknownOpcode;
R4300i_CoP0[14] = R4300i_UnknownOpcode;
R4300i_CoP0[15] = R4300i_UnknownOpcode;
R4300i_CoP0[16] = R4300i_opcode_COP0_CO;
R4300i_CoP0[17] = R4300i_opcode_COP0_CO;
R4300i_CoP0[18] = R4300i_opcode_COP0_CO;
R4300i_CoP0[19] = R4300i_opcode_COP0_CO;
R4300i_CoP0[20] = R4300i_opcode_COP0_CO;
R4300i_CoP0[21] = R4300i_opcode_COP0_CO;
R4300i_CoP0[22] = R4300i_opcode_COP0_CO;
R4300i_CoP0[23] = R4300i_opcode_COP0_CO;
R4300i_CoP0[24] = R4300i_opcode_COP0_CO;
R4300i_CoP0[25] = R4300i_opcode_COP0_CO;
R4300i_CoP0[26] = R4300i_opcode_COP0_CO;
R4300i_CoP0[27] = R4300i_opcode_COP0_CO;
R4300i_CoP0[28] = R4300i_opcode_COP0_CO;
R4300i_CoP0[29] = R4300i_opcode_COP0_CO;
R4300i_CoP0[30] = R4300i_opcode_COP0_CO;
R4300i_CoP0[31] = R4300i_opcode_COP0_CO;
R4300i_CoP0_Function[ 0] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[ 1] = r4300i_COP0_CO_TLBR;
R4300i_CoP0_Function[ 2] = r4300i_COP0_CO_TLBWI;
R4300i_CoP0_Function[ 3] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[ 4] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[ 5] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[ 6] = r4300i_COP0_CO_TLBWR;
R4300i_CoP0_Function[ 7] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[ 8] = r4300i_COP0_CO_TLBP;
R4300i_CoP0_Function[ 9] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[10] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[11] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[12] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[13] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[14] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[15] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[16] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[17] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[18] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[19] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[20] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[21] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[22] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[23] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[24] = r4300i_COP0_CO_ERET;
R4300i_CoP0_Function[25] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[26] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[27] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[28] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[29] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[30] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[31] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[32] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[33] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[34] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[35] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[36] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[37] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[38] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[39] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[40] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[41] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[42] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[43] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[44] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[45] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[46] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[47] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[48] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[49] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[50] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[51] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[52] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[53] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[54] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[55] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[56] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[57] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[58] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[59] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[60] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[61] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[62] = R4300i_UnknownOpcode;
R4300i_CoP0_Function[63] = R4300i_UnknownOpcode;
R4300i_CoP1[ 0] = r4300i_COP1_MF;
R4300i_CoP1[ 1] = r4300i_COP1_DMF;
R4300i_CoP1[ 2] = r4300i_COP1_CF;
R4300i_CoP1[ 3] = R4300i_UnknownOpcode;
R4300i_CoP1[ 4] = r4300i_COP1_MT;
R4300i_CoP1[ 5] = r4300i_COP1_DMT;
R4300i_CoP1[ 6] = r4300i_COP1_CT;
R4300i_CoP1[ 7] = R4300i_UnknownOpcode;
R4300i_CoP1[ 8] = R4300i_opcode_COP1_BC;
R4300i_CoP1[ 9] = R4300i_UnknownOpcode;
R4300i_CoP1[10] = R4300i_UnknownOpcode;
R4300i_CoP1[11] = R4300i_UnknownOpcode;
R4300i_CoP1[12] = R4300i_UnknownOpcode;
R4300i_CoP1[13] = R4300i_UnknownOpcode;
R4300i_CoP1[14] = R4300i_UnknownOpcode;
R4300i_CoP1[15] = R4300i_UnknownOpcode;
R4300i_CoP1[16] = R4300i_opcode_COP1_S;
R4300i_CoP1[17] = R4300i_opcode_COP1_D;
R4300i_CoP1[18] = R4300i_UnknownOpcode;
R4300i_CoP1[19] = R4300i_UnknownOpcode;
R4300i_CoP1[20] = R4300i_opcode_COP1_W;
R4300i_CoP1[21] = R4300i_opcode_COP1_L;
R4300i_CoP1[22] = R4300i_UnknownOpcode;
R4300i_CoP1[23] = R4300i_UnknownOpcode;
R4300i_CoP1[24] = R4300i_UnknownOpcode;
R4300i_CoP1[25] = R4300i_UnknownOpcode;
R4300i_CoP1[26] = R4300i_UnknownOpcode;
R4300i_CoP1[27] = R4300i_UnknownOpcode;
R4300i_CoP1[28] = R4300i_UnknownOpcode;
R4300i_CoP1[29] = R4300i_UnknownOpcode;
R4300i_CoP1[30] = R4300i_UnknownOpcode;
R4300i_CoP1[31] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[ 0] = r4300i_COP1_BCF;
R4300i_CoP1_BC[ 1] = r4300i_COP1_BCT;
R4300i_CoP1_BC[ 2] = r4300i_COP1_BCFL;
R4300i_CoP1_BC[ 3] = r4300i_COP1_BCTL;
R4300i_CoP1_BC[ 4] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[ 5] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[ 6] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[ 7] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[ 8] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[ 9] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[10] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[11] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[12] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[13] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[14] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[15] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[16] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[17] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[18] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[19] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[20] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[21] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[22] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[23] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[24] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[25] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[26] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[27] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[28] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[29] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[30] = R4300i_UnknownOpcode;
R4300i_CoP1_BC[31] = R4300i_UnknownOpcode;
R4300i_CoP1_S[ 0] = r4300i_COP1_S_ADD;
R4300i_CoP1_S[ 1] = r4300i_COP1_S_SUB;
R4300i_CoP1_S[ 2] = r4300i_COP1_S_MUL;
R4300i_CoP1_S[ 3] = r4300i_COP1_S_DIV;
R4300i_CoP1_S[ 4] = r4300i_COP1_S_SQRT;
R4300i_CoP1_S[ 5] = r4300i_COP1_S_ABS;
R4300i_CoP1_S[ 6] = r4300i_COP1_S_MOV;
R4300i_CoP1_S[ 7] = r4300i_COP1_S_NEG;
R4300i_CoP1_S[ 8] = R4300i_UnknownOpcode;
R4300i_CoP1_S[ 9] = r4300i_COP1_S_TRUNC_L;
R4300i_CoP1_S[10] = r4300i_COP1_S_CEIL_L; //added by Witten
R4300i_CoP1_S[11] = r4300i_COP1_S_FLOOR_L; //added by Witten
R4300i_CoP1_S[12] = r4300i_COP1_S_ROUND_W;
R4300i_CoP1_S[13] = r4300i_COP1_S_TRUNC_W;
R4300i_CoP1_S[14] = r4300i_COP1_S_CEIL_W; //added by Witten
R4300i_CoP1_S[15] = r4300i_COP1_S_FLOOR_W;
R4300i_CoP1_S[16] = R4300i_UnknownOpcode;
R4300i_CoP1_S[17] = R4300i_UnknownOpcode;
R4300i_CoP1_S[18] = R4300i_UnknownOpcode;
R4300i_CoP1_S[19] = R4300i_UnknownOpcode;
R4300i_CoP1_S[20] = R4300i_UnknownOpcode;
R4300i_CoP1_S[21] = R4300i_UnknownOpcode;
R4300i_CoP1_S[22] = R4300i_UnknownOpcode;
R4300i_CoP1_S[23] = R4300i_UnknownOpcode;
R4300i_CoP1_S[24] = R4300i_UnknownOpcode;
R4300i_CoP1_S[25] = R4300i_UnknownOpcode;
R4300i_CoP1_S[26] = R4300i_UnknownOpcode;
R4300i_CoP1_S[27] = R4300i_UnknownOpcode;
R4300i_CoP1_S[28] = R4300i_UnknownOpcode;
R4300i_CoP1_S[29] = R4300i_UnknownOpcode;
R4300i_CoP1_S[30] = R4300i_UnknownOpcode;
R4300i_CoP1_S[31] = R4300i_UnknownOpcode;
R4300i_CoP1_S[32] = R4300i_UnknownOpcode;
R4300i_CoP1_S[33] = r4300i_COP1_S_CVT_D;
R4300i_CoP1_S[34] = R4300i_UnknownOpcode;
R4300i_CoP1_S[35] = R4300i_UnknownOpcode;
R4300i_CoP1_S[36] = r4300i_COP1_S_CVT_W;
R4300i_CoP1_S[37] = r4300i_COP1_S_CVT_L;
R4300i_CoP1_S[38] = R4300i_UnknownOpcode;
R4300i_CoP1_S[39] = R4300i_UnknownOpcode;
R4300i_CoP1_S[40] = R4300i_UnknownOpcode;
R4300i_CoP1_S[41] = R4300i_UnknownOpcode;
R4300i_CoP1_S[42] = R4300i_UnknownOpcode;
R4300i_CoP1_S[43] = R4300i_UnknownOpcode;
R4300i_CoP1_S[44] = R4300i_UnknownOpcode;
R4300i_CoP1_S[45] = R4300i_UnknownOpcode;
R4300i_CoP1_S[46] = R4300i_UnknownOpcode;
R4300i_CoP1_S[47] = R4300i_UnknownOpcode;
R4300i_CoP1_S[48] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[49] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[50] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[51] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[52] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[53] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[54] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[55] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[56] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[57] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[58] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[59] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[60] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[61] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[62] = r4300i_COP1_S_CMP;
R4300i_CoP1_S[63] = r4300i_COP1_S_CMP;
R4300i_CoP1_D[ 0] = r4300i_COP1_D_ADD;
R4300i_CoP1_D[ 1] = r4300i_COP1_D_SUB;
R4300i_CoP1_D[ 2] = r4300i_COP1_D_MUL;
R4300i_CoP1_D[ 3] = r4300i_COP1_D_DIV;
R4300i_CoP1_D[ 4] = r4300i_COP1_D_SQRT;
R4300i_CoP1_D[ 5] = r4300i_COP1_D_ABS;
R4300i_CoP1_D[ 6] = r4300i_COP1_D_MOV;
R4300i_CoP1_D[ 7] = r4300i_COP1_D_NEG;
R4300i_CoP1_D[ 8] = R4300i_UnknownOpcode;
R4300i_CoP1_D[ 9] = r4300i_COP1_D_TRUNC_L; //added by Witten
R4300i_CoP1_D[10] = r4300i_COP1_D_CEIL_L; //added by Witten
R4300i_CoP1_D[11] = r4300i_COP1_D_FLOOR_L; //added by Witten
R4300i_CoP1_D[12] = r4300i_COP1_D_ROUND_W;
R4300i_CoP1_D[13] = r4300i_COP1_D_TRUNC_W;
R4300i_CoP1_D[14] = r4300i_COP1_D_CEIL_W; //added by Witten
R4300i_CoP1_D[15] = r4300i_COP1_D_FLOOR_W; //added by Witten
R4300i_CoP1_D[16] = R4300i_UnknownOpcode;
R4300i_CoP1_D[17] = R4300i_UnknownOpcode;
R4300i_CoP1_D[18] = R4300i_UnknownOpcode;
R4300i_CoP1_D[19] = R4300i_UnknownOpcode;
R4300i_CoP1_D[20] = R4300i_UnknownOpcode;
R4300i_CoP1_D[21] = R4300i_UnknownOpcode;
R4300i_CoP1_D[22] = R4300i_UnknownOpcode;
R4300i_CoP1_D[23] = R4300i_UnknownOpcode;
R4300i_CoP1_D[24] = R4300i_UnknownOpcode;
R4300i_CoP1_D[25] = R4300i_UnknownOpcode;
R4300i_CoP1_D[26] = R4300i_UnknownOpcode;
R4300i_CoP1_D[27] = R4300i_UnknownOpcode;
R4300i_CoP1_D[28] = R4300i_UnknownOpcode;
R4300i_CoP1_D[29] = R4300i_UnknownOpcode;
R4300i_CoP1_D[30] = R4300i_UnknownOpcode;
R4300i_CoP1_D[31] = R4300i_UnknownOpcode;
R4300i_CoP1_D[32] = r4300i_COP1_D_CVT_S;
R4300i_CoP1_D[33] = R4300i_UnknownOpcode;
R4300i_CoP1_D[34] = R4300i_UnknownOpcode;
R4300i_CoP1_D[35] = R4300i_UnknownOpcode;
R4300i_CoP1_D[36] = r4300i_COP1_D_CVT_W;
R4300i_CoP1_D[37] = r4300i_COP1_D_CVT_L;
R4300i_CoP1_D[38] = R4300i_UnknownOpcode;
R4300i_CoP1_D[39] = R4300i_UnknownOpcode;
R4300i_CoP1_D[40] = R4300i_UnknownOpcode;
R4300i_CoP1_D[41] = R4300i_UnknownOpcode;
R4300i_CoP1_D[42] = R4300i_UnknownOpcode;
R4300i_CoP1_D[43] = R4300i_UnknownOpcode;
R4300i_CoP1_D[44] = R4300i_UnknownOpcode;
R4300i_CoP1_D[45] = R4300i_UnknownOpcode;
R4300i_CoP1_D[46] = R4300i_UnknownOpcode;
R4300i_CoP1_D[47] = R4300i_UnknownOpcode;
R4300i_CoP1_D[48] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[49] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[50] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[51] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[52] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[53] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[54] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[55] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[56] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[57] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[58] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[59] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[60] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[61] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[62] = r4300i_COP1_D_CMP;
R4300i_CoP1_D[63] = r4300i_COP1_D_CMP;
R4300i_CoP1_W[ 0] = R4300i_UnknownOpcode;
R4300i_CoP1_W[ 1] = R4300i_UnknownOpcode;
R4300i_CoP1_W[ 2] = R4300i_UnknownOpcode;
R4300i_CoP1_W[ 3] = R4300i_UnknownOpcode;
R4300i_CoP1_W[ 4] = R4300i_UnknownOpcode;
R4300i_CoP1_W[ 5] = R4300i_UnknownOpcode;
R4300i_CoP1_W[ 6] = R4300i_UnknownOpcode;
R4300i_CoP1_W[ 7] = R4300i_UnknownOpcode;
R4300i_CoP1_W[ 8] = R4300i_UnknownOpcode;
R4300i_CoP1_W[ 9] = R4300i_UnknownOpcode;
R4300i_CoP1_W[10] = R4300i_UnknownOpcode;
R4300i_CoP1_W[11] = R4300i_UnknownOpcode;
R4300i_CoP1_W[12] = R4300i_UnknownOpcode;
R4300i_CoP1_W[13] = R4300i_UnknownOpcode;
R4300i_CoP1_W[14] = R4300i_UnknownOpcode;
R4300i_CoP1_W[15] = R4300i_UnknownOpcode;
R4300i_CoP1_W[16] = R4300i_UnknownOpcode;
R4300i_CoP1_W[17] = R4300i_UnknownOpcode;
R4300i_CoP1_W[18] = R4300i_UnknownOpcode;
R4300i_CoP1_W[19] = R4300i_UnknownOpcode;
R4300i_CoP1_W[20] = R4300i_UnknownOpcode;
R4300i_CoP1_W[21] = R4300i_UnknownOpcode;
R4300i_CoP1_W[22] = R4300i_UnknownOpcode;
R4300i_CoP1_W[23] = R4300i_UnknownOpcode;
R4300i_CoP1_W[24] = R4300i_UnknownOpcode;
R4300i_CoP1_W[25] = R4300i_UnknownOpcode;
R4300i_CoP1_W[26] = R4300i_UnknownOpcode;
R4300i_CoP1_W[27] = R4300i_UnknownOpcode;
R4300i_CoP1_W[28] = R4300i_UnknownOpcode;
R4300i_CoP1_W[29] = R4300i_UnknownOpcode;
R4300i_CoP1_W[30] = R4300i_UnknownOpcode;
R4300i_CoP1_W[31] = R4300i_UnknownOpcode;
R4300i_CoP1_W[32] = r4300i_COP1_W_CVT_S;
R4300i_CoP1_W[33] = r4300i_COP1_W_CVT_D;
R4300i_CoP1_W[34] = R4300i_UnknownOpcode;
R4300i_CoP1_W[35] = R4300i_UnknownOpcode;
R4300i_CoP1_W[36] = R4300i_UnknownOpcode;
R4300i_CoP1_W[37] = R4300i_UnknownOpcode;
R4300i_CoP1_W[38] = R4300i_UnknownOpcode;
R4300i_CoP1_W[39] = R4300i_UnknownOpcode;
R4300i_CoP1_W[40] = R4300i_UnknownOpcode;
R4300i_CoP1_W[41] = R4300i_UnknownOpcode;
R4300i_CoP1_W[42] = R4300i_UnknownOpcode;
R4300i_CoP1_W[43] = R4300i_UnknownOpcode;
R4300i_CoP1_W[44] = R4300i_UnknownOpcode;
R4300i_CoP1_W[45] = R4300i_UnknownOpcode;
R4300i_CoP1_W[46] = R4300i_UnknownOpcode;
R4300i_CoP1_W[47] = R4300i_UnknownOpcode;
R4300i_CoP1_W[48] = R4300i_UnknownOpcode;
R4300i_CoP1_W[49] = R4300i_UnknownOpcode;
R4300i_CoP1_W[50] = R4300i_UnknownOpcode;
R4300i_CoP1_W[51] = R4300i_UnknownOpcode;
R4300i_CoP1_W[52] = R4300i_UnknownOpcode;
R4300i_CoP1_W[53] = R4300i_UnknownOpcode;
R4300i_CoP1_W[54] = R4300i_UnknownOpcode;
R4300i_CoP1_W[55] = R4300i_UnknownOpcode;
R4300i_CoP1_W[56] = R4300i_UnknownOpcode;
R4300i_CoP1_W[57] = R4300i_UnknownOpcode;
R4300i_CoP1_W[58] = R4300i_UnknownOpcode;
R4300i_CoP1_W[59] = R4300i_UnknownOpcode;
R4300i_CoP1_W[60] = R4300i_UnknownOpcode;
R4300i_CoP1_W[61] = R4300i_UnknownOpcode;
R4300i_CoP1_W[62] = R4300i_UnknownOpcode;
R4300i_CoP1_W[63] = R4300i_UnknownOpcode;
R4300i_CoP1_L[ 0] = R4300i_UnknownOpcode;
R4300i_CoP1_L[ 1] = R4300i_UnknownOpcode;
R4300i_CoP1_L[ 2] = R4300i_UnknownOpcode;
R4300i_CoP1_L[ 3] = R4300i_UnknownOpcode;
R4300i_CoP1_L[ 4] = R4300i_UnknownOpcode;
R4300i_CoP1_L[ 5] = R4300i_UnknownOpcode;
R4300i_CoP1_L[ 6] = R4300i_UnknownOpcode;
R4300i_CoP1_L[ 7] = R4300i_UnknownOpcode;
R4300i_CoP1_L[ 8] = R4300i_UnknownOpcode;
R4300i_CoP1_L[ 9] = R4300i_UnknownOpcode;
R4300i_CoP1_L[10] = R4300i_UnknownOpcode;
R4300i_CoP1_L[11] = R4300i_UnknownOpcode;
R4300i_CoP1_L[12] = R4300i_UnknownOpcode;
R4300i_CoP1_L[13] = R4300i_UnknownOpcode;
R4300i_CoP1_L[14] = R4300i_UnknownOpcode;
R4300i_CoP1_L[15] = R4300i_UnknownOpcode;
R4300i_CoP1_L[16] = R4300i_UnknownOpcode;
R4300i_CoP1_L[17] = R4300i_UnknownOpcode;
R4300i_CoP1_L[18] = R4300i_UnknownOpcode;
R4300i_CoP1_L[19] = R4300i_UnknownOpcode;
R4300i_CoP1_L[20] = R4300i_UnknownOpcode;
R4300i_CoP1_L[21] = R4300i_UnknownOpcode;
R4300i_CoP1_L[22] = R4300i_UnknownOpcode;
R4300i_CoP1_L[23] = R4300i_UnknownOpcode;
R4300i_CoP1_L[24] = R4300i_UnknownOpcode;
R4300i_CoP1_L[25] = R4300i_UnknownOpcode;
R4300i_CoP1_L[26] = R4300i_UnknownOpcode;
R4300i_CoP1_L[27] = R4300i_UnknownOpcode;
R4300i_CoP1_L[28] = R4300i_UnknownOpcode;
R4300i_CoP1_L[29] = R4300i_UnknownOpcode;
R4300i_CoP1_L[30] = R4300i_UnknownOpcode;
R4300i_CoP1_L[31] = R4300i_UnknownOpcode;
R4300i_CoP1_L[32] = r4300i_COP1_L_CVT_S;
R4300i_CoP1_L[33] = r4300i_COP1_L_CVT_D;
R4300i_CoP1_L[34] = R4300i_UnknownOpcode;
R4300i_CoP1_L[35] = R4300i_UnknownOpcode;
R4300i_CoP1_L[36] = R4300i_UnknownOpcode;
R4300i_CoP1_L[37] = R4300i_UnknownOpcode;
R4300i_CoP1_L[38] = R4300i_UnknownOpcode;
R4300i_CoP1_L[39] = R4300i_UnknownOpcode;
R4300i_CoP1_L[40] = R4300i_UnknownOpcode;
R4300i_CoP1_L[41] = R4300i_UnknownOpcode;
R4300i_CoP1_L[42] = R4300i_UnknownOpcode;
R4300i_CoP1_L[43] = R4300i_UnknownOpcode;
R4300i_CoP1_L[44] = R4300i_UnknownOpcode;
R4300i_CoP1_L[45] = R4300i_UnknownOpcode;
R4300i_CoP1_L[46] = R4300i_UnknownOpcode;
R4300i_CoP1_L[47] = R4300i_UnknownOpcode;
R4300i_CoP1_L[48] = R4300i_UnknownOpcode;
R4300i_CoP1_L[49] = R4300i_UnknownOpcode;
R4300i_CoP1_L[50] = R4300i_UnknownOpcode;
R4300i_CoP1_L[51] = R4300i_UnknownOpcode;
R4300i_CoP1_L[52] = R4300i_UnknownOpcode;
R4300i_CoP1_L[53] = R4300i_UnknownOpcode;
R4300i_CoP1_L[54] = R4300i_UnknownOpcode;
R4300i_CoP1_L[55] = R4300i_UnknownOpcode;
R4300i_CoP1_L[56] = R4300i_UnknownOpcode;
R4300i_CoP1_L[57] = R4300i_UnknownOpcode;
R4300i_CoP1_L[58] = R4300i_UnknownOpcode;
R4300i_CoP1_L[59] = R4300i_UnknownOpcode;
R4300i_CoP1_L[60] = R4300i_UnknownOpcode;
R4300i_CoP1_L[61] = R4300i_UnknownOpcode;
R4300i_CoP1_L[62] = R4300i_UnknownOpcode;
R4300i_CoP1_L[63] = R4300i_UnknownOpcode;
}
BOOL ExecuteInterpreterOpCode (void) {
if (!r4300i_LW_VAddr(PROGRAM_COUNTER, &Opcode.Hex)) {
DoTLBMiss(NextInstruction == JUMP,PROGRAM_COUNTER);
NextInstruction = NORMAL; NextInstruction = NORMAL;
return FALSE; return FALSE;
} }
COUNT_REGISTER += CountPerOp; COUNT_REGISTER += CountPerOp;
*g_Timer -= CountPerOp; *_Timer -= CountPerOp;
RANDOM_REGISTER -= 1; RANDOM_REGISTER -= 1;
if ((int)RANDOM_REGISTER < (int)WIRED_REGISTER) { if ((int)RANDOM_REGISTER < (int)WIRED_REGISTER) {
@ -694,35 +54,35 @@ BOOL ExecuteInterpreterOpCode (void) {
((void (_fastcall *)()) R4300i_Opcode[ Opcode.op ])(); ((void (_fastcall *)()) R4300i_Opcode[ Opcode.op ])();
if (GPR[0].DW != 0) { if (_GPR[0].DW != 0) {
#if (!defined(EXTERNAL_RELEASE)) #if (!defined(EXTERNAL_RELEASE))
DisplayError("GPR[0].DW has been written to"); DisplayError("_GPR[0].DW has been written to");
#endif #endif
GPR[0].DW = 0; _GPR[0].DW = 0;
} }
#ifdef Interpreter_StackTest #ifdef Interpreter_StackTest
if (StackValue != GPR[29].UW[0]) { if (StackValue != _GPR[29].UW[0]) {
DisplayError("Stack has Been changed"); DisplayError("Stack has Been changed");
} }
#endif #endif
switch (NextInstruction) { switch (NextInstruction) {
case NORMAL: case NORMAL:
PROGRAM_COUNTER += 4; (*_PROGRAM_COUNTER) += 4;
break; break;
case DELAY_SLOT: case DELAY_SLOT:
NextInstruction = JUMP; NextInstruction = JUMP;
PROGRAM_COUNTER += 4; (*_PROGRAM_COUNTER) += 4;
break; break;
case JUMP: case JUMP:
{ {
BOOL CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer); BOOL CheckTimer = (JumpToLocation < (*_PROGRAM_COUNTER) || TestTimer);
PROGRAM_COUNTER = JumpToLocation; (*_PROGRAM_COUNTER) = JumpToLocation;
NextInstruction = NORMAL; NextInstruction = NORMAL;
if (CheckTimer) if (CheckTimer)
{ {
TestTimer = FALSE; TestTimer = FALSE;
if (*g_Timer < 0) if (*_Timer < 0)
{ {
TimerDone(); TimerDone();
} }
@ -732,7 +92,7 @@ BOOL ExecuteInterpreterOpCode (void) {
if (CPU_Type != CPU_SyncCores) { if (CPU_Type != CPU_SyncCores) {
if (Profiling) { if (Profiling) {
if (IndvidualBlock) { if (IndvidualBlock) {
StartTimer(PROGRAM_COUNTER); StartTimer((*_PROGRAM_COUNTER));
} else { } else {
StartTimer(Timer_R4300); StartTimer(Timer_R4300);
} }
@ -759,12 +119,12 @@ void ExecuteInterpreterOps (DWORD Cycles)
while(!EndEmulation()) { while(!EndEmulation()) {
#if (!defined(EXTERNAL_RELEASE)) #if (!defined(EXTERNAL_RELEASE))
if (NoOfBpoints != 0) { if (NoOfBpoints != 0) {
if (CheckForR4300iBPoint(PROGRAM_COUNTER)) { if (CheckForR4300iBPoint((*_PROGRAM_COUNTER))) {
UpdateCurrentR4300iRegisterPanel(); UpdateCurrentR4300iRegisterPanel();
Refresh_Memory(); Refresh_Memory();
if (InR4300iCommandsWindow) { if (InR4300iCommandsWindow) {
Enter_R4300i_Commands_Window(); Enter_R4300i_Commands_Window();
SetR4300iCommandViewto( PROGRAM_COUNTER ); SetR4300iCommandViewto( (*_PROGRAM_COUNTER) );
if (CPU_Action.Stepping) { if (CPU_Action.Stepping) {
DisplayError ( "Encounted a R4300i Breakpoint" ); DisplayError ( "Encounted a R4300i Breakpoint" );
} else { } else {
@ -785,7 +145,7 @@ void ExecuteInterpreterOps (DWORD Cycles)
//Value2 = Value; //Value2 = Value;
if (CPU_Action.Stepping) { if (CPU_Action.Stepping) {
do { do {
SetR4300iCommandViewto (PROGRAM_COUNTER); SetR4300iCommandViewto ((*_PROGRAM_COUNTER));
UpdateCurrentR4300iRegisterPanel(); UpdateCurrentR4300iRegisterPanel();
Refresh_Memory(); Refresh_Memory();
WaitForSingleObject( CPU_Action.hStepping, INFINITE ); WaitForSingleObject( CPU_Action.hStepping, INFINITE );
@ -806,7 +166,7 @@ void ExecuteInterpreterOps (DWORD Cycles)
ExecuteInterpreterOpCode(); ExecuteInterpreterOpCode();
} }
} }
} __except( r4300i_CPU_MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) { } __except( _MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) {
DisplayError(GS(MSG_UNKNOWN_MEM_ACTION)); DisplayError(GS(MSG_UNKNOWN_MEM_ACTION));
ExitThread(0); ExitThread(0);
} }

View File

@ -27,14 +27,11 @@
extern "C" { extern "C" {
#endif #endif
void BuildInterpreter ( void );
BOOL ExecuteInterpreterOpCode ( void ); BOOL ExecuteInterpreterOpCode ( void );
void StartInterpreterCPU ( void ); void StartInterpreterCPU ( void );
void TestInterpreterJump ( DWORD PC, DWORD TargetPC, int Reg1, int Reg2 ); void TestInterpreterJump ( DWORD PC, DWORD TargetPC, int Reg1, int Reg2 );
void ExecuteInterpreterOps ( DWORD Cycles ); void ExecuteInterpreterOps ( DWORD Cycles );
extern void * R4300i_Opcode[64];
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,184 @@
typedef void (_fastcall * R4300iOp_FUNC )();
class R4300iOp32
{
public:
/************************* OpCode functions *************************/
static void _fastcall J ( void );
static void _fastcall JAL ( void );
static void _fastcall BNE ( void );
static void _fastcall BEQ ( void );
static void _fastcall BLEZ ( void );
static void _fastcall BGTZ ( void );
static void _fastcall ADDI ( void );
static void _fastcall ADDIU ( void );
static void _fastcall SLTI ( void );
static void _fastcall SLTIU ( void );
static void _fastcall ANDI ( void );
static void _fastcall ORI ( void );
static void _fastcall XORI ( void );
static void _fastcall LUI ( void );
static void _fastcall BEQL ( void );
static void _fastcall BNEL ( void );
static void _fastcall BLEZL ( void );
static void _fastcall BGTZL ( void );
static void _fastcall LB ( void );
static void _fastcall LH ( void );
static void _fastcall LWL ( void );
static void _fastcall LW ( void );
static void _fastcall LBU ( void );
static void _fastcall LHU ( void );
static void _fastcall LWR ( void );
static void _fastcall LWU ( void );
static void _fastcall SB ( void );
static void _fastcall SH ( void );
static void _fastcall SWL ( void );
static void _fastcall SW ( void );
static void _fastcall SWR ( void );
static void _fastcall CACHE ( void );
static void _fastcall LL ( void );
static void _fastcall LWC1 ( void );
static void _fastcall SC ( void );
static void _fastcall SWC1 ( void );
/********************** R4300i OpCodes: Special **********************/
static void _fastcall SPECIAL_SLL ( void );
static void _fastcall SPECIAL_SRL ( void );
static void _fastcall SPECIAL_SRA ( void );
static void _fastcall SPECIAL_SLLV ( void );
static void _fastcall SPECIAL_SRLV ( void );
static void _fastcall SPECIAL_SRAV ( void );
static void _fastcall SPECIAL_JR ( void );
static void _fastcall SPECIAL_JALR ( void );
static void _fastcall SPECIAL_SYSCALL ( void );
static void _fastcall SPECIAL_BREAK ( void );
static void _fastcall SPECIAL_SYNC ( void );
static void _fastcall SPECIAL_MFHI ( void );
static void _fastcall SPECIAL_MTHI ( void );
static void _fastcall SPECIAL_MFLO ( void );
static void _fastcall SPECIAL_MTLO ( void );
static void _fastcall SPECIAL_ADD ( void );
static void _fastcall SPECIAL_ADDU ( void );
static void _fastcall SPECIAL_SUB ( void );
static void _fastcall SPECIAL_SUBU ( void );
static void _fastcall SPECIAL_AND ( void );
static void _fastcall SPECIAL_OR ( void );
static void _fastcall SPECIAL_XOR ( void );
static void _fastcall SPECIAL_NOR ( void );
static void _fastcall SPECIAL_SLT ( void );
static void _fastcall SPECIAL_SLTU ( void );
static void _fastcall SPECIAL_TEQ ( void );
/********************** R4300i OpCodes: RegImm **********************/
static void _fastcall REGIMM_BLTZ ( void );
static void _fastcall REGIMM_BGEZ ( void );
static void _fastcall REGIMM_BLTZL ( void );
static void _fastcall REGIMM_BGEZL ( void );
static void _fastcall REGIMM_BLTZAL ( void );
static void _fastcall REGIMM_BGEZAL ( void );
/************************** COP0 functions **************************/
static void _fastcall COP0_MF ( void );
static void _fastcall COP0_MT ( void );
/************************** COP0 CO functions ***********************/
static void _fastcall COP0_CO_TLBR ( void );
static void _fastcall COP0_CO_TLBWI ( void );
static void _fastcall COP0_CO_TLBWR ( void );
static void _fastcall COP0_CO_TLBP ( void );
static void _fastcall COP0_CO_ERET ( void );
/************************** COP1 functions **************************/
static void _fastcall COP1_MF ( void );
static void _fastcall COP1_DMF ( void );
static void _fastcall COP1_CF ( void );
static void _fastcall COP1_MT ( void );
static void _fastcall COP1_DMT ( void );
static void _fastcall COP1_CT ( void );
/************************* COP1: BC1 functions ***********************/
static void _fastcall COP1_BCF ( void );
static void _fastcall COP1_BCT ( void );
static void _fastcall COP1_BCFL ( void );
static void _fastcall COP1_BCTL ( void );
/************************** COP1: S functions ************************/
static void _fastcall COP1_S_ADD ( void );
static void _fastcall COP1_S_SUB ( void );
static void _fastcall COP1_S_MUL ( void );
static void _fastcall COP1_S_DIV ( void );
static void _fastcall COP1_S_SQRT ( void );
static void _fastcall COP1_S_ABS ( void );
static void _fastcall COP1_S_MOV ( void );
static void _fastcall COP1_S_NEG ( void );
static void _fastcall COP1_S_TRUNC_L ( void );
static void _fastcall COP1_S_CEIL_L ( void ); //added by Witten
static void _fastcall COP1_S_FLOOR_L ( void ); //added by Witten
static void _fastcall COP1_S_ROUND_W ( void );
static void _fastcall COP1_S_TRUNC_W ( void );
static void _fastcall COP1_S_CEIL_W ( void ); //added by Witten
static void _fastcall COP1_S_FLOOR_W ( void );
static void _fastcall COP1_S_CVT_D ( void );
static void _fastcall COP1_S_CVT_W ( void );
static void _fastcall COP1_S_CVT_L ( void );
static void _fastcall COP1_S_CMP ( void );
/************************** COP1: D functions ************************/
static void _fastcall COP1_D_ADD ( void );
static void _fastcall COP1_D_SUB ( void );
static void _fastcall COP1_D_MUL ( void );
static void _fastcall COP1_D_DIV ( void );
static void _fastcall COP1_D_SQRT ( void );
static void _fastcall COP1_D_ABS ( void );
static void _fastcall COP1_D_MOV ( void );
static void _fastcall COP1_D_NEG ( void );
static void _fastcall COP1_D_TRUNC_L ( void ); //added by Witten
static void _fastcall COP1_D_CEIL_L ( void ); //added by Witten
static void _fastcall COP1_D_FLOOR_L ( void ); //added by Witten
static void _fastcall COP1_D_ROUND_W ( void );
static void _fastcall COP1_D_TRUNC_W ( void );
static void _fastcall COP1_D_CEIL_W ( void ); //added by Witten
static void _fastcall COP1_D_FLOOR_W ( void ); //added by Witten
static void _fastcall COP1_D_CVT_S ( void );
static void _fastcall COP1_D_CVT_W ( void );
static void _fastcall COP1_D_CVT_L ( void );
static void _fastcall COP1_D_CMP ( void );
/************************** COP1: W functions ************************/
static void _fastcall COP1_W_CVT_S ( void );
static void _fastcall COP1_W_CVT_D ( void );
/************************** COP1: L functions ************************/
static void _fastcall COP1_L_CVT_S ( void );
static void _fastcall COP1_L_CVT_D ( void );
/************************** Other functions **************************/
static void _fastcall UnknownOpcode ( void );
static R4300iOp_FUNC * BuildInterpreter (void );
private:
static void _fastcall SPECIAL (void);
static void _fastcall REGIMM (void);
static void _fastcall COP0 (void);
static void _fastcall COP0_CO (void);
static void _fastcall COP1 (void);
static void _fastcall COP1_BC (void);
static void _fastcall COP1_S (void);
static void _fastcall COP1_D (void);
static void _fastcall COP1_W (void);
static void _fastcall COP1_L (void);
static R4300iOp_FUNC Jump_Opcode[64];
static R4300iOp_FUNC Jump_Special[64];
static R4300iOp_FUNC Jump_Regimm[32];
static R4300iOp_FUNC Jump_CoP0[32];
static R4300iOp_FUNC Jump_CoP0_Function[64];
static R4300iOp_FUNC Jump_CoP1[32];
static R4300iOp_FUNC Jump_CoP1_BC[32];
static R4300iOp_FUNC Jump_CoP1_S[64];
static R4300iOp_FUNC Jump_CoP1_D[64];
static R4300iOp_FUNC Jump_CoP1_W[64];
static R4300iOp_FUNC Jump_CoP1_L[64];
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -24,192 +24,225 @@
* *
*/ */
typedef void (_fastcall * R4300iOp_FUNC )();
class R4300iOp
{
public:
/************************* OpCode functions *************************/
static void _fastcall J ( void );
static void _fastcall JAL ( void );
static void _fastcall BNE ( void );
static void _fastcall BEQ ( void );
static void _fastcall BLEZ ( void );
static void _fastcall BGTZ ( void );
static void _fastcall ADDI ( void );
static void _fastcall ADDIU ( void );
static void _fastcall SLTI ( void );
static void _fastcall SLTIU ( void );
static void _fastcall ANDI ( void );
static void _fastcall ORI ( void );
static void _fastcall XORI ( void );
static void _fastcall LUI ( void );
static void _fastcall BEQL ( void );
static void _fastcall BNEL ( void );
static void _fastcall BLEZL ( void );
static void _fastcall BGTZL ( void );
static void _fastcall DADDIU ( void );
static void _fastcall LDL ( void );
static void _fastcall LDR ( void );
static void _fastcall LB ( void );
static void _fastcall LH ( void );
static void _fastcall LWL ( void );
static void _fastcall LW ( void );
static void _fastcall LBU ( void );
static void _fastcall LHU ( void );
static void _fastcall LWR ( void );
static void _fastcall LWU ( void );
static void _fastcall SB ( void );
static void _fastcall SH ( void );
static void _fastcall SWL ( void );
static void _fastcall SW ( void );
static void _fastcall SDL ( void );
static void _fastcall SDR ( void );
static void _fastcall SWR ( void );
static void _fastcall CACHE ( void );
static void _fastcall LL ( void );
static void _fastcall LWC1 ( void );
static void _fastcall LDC1 ( void );
static void _fastcall LD ( void );
static void _fastcall SC ( void );
static void _fastcall SWC1 ( void );
static void _fastcall SDC1 ( void );
static void _fastcall SD ( void );
/********************** R4300i OpCodes: Special **********************/
static void _fastcall SPECIAL_SLL ( void );
static void _fastcall SPECIAL_SRL ( void );
static void _fastcall SPECIAL_SRA ( void );
static void _fastcall SPECIAL_SLLV ( void );
static void _fastcall SPECIAL_SRLV ( void );
static void _fastcall SPECIAL_SRAV ( void );
static void _fastcall SPECIAL_JR ( void );
static void _fastcall SPECIAL_JALR ( void );
static void _fastcall SPECIAL_SYSCALL ( void );
static void _fastcall SPECIAL_BREAK ( void );
static void _fastcall SPECIAL_SYNC ( void );
static void _fastcall SPECIAL_MFHI ( void );
static void _fastcall SPECIAL_MTHI ( void );
static void _fastcall SPECIAL_MFLO ( void );
static void _fastcall SPECIAL_MTLO ( void );
static void _fastcall SPECIAL_DSLLV ( void );
static void _fastcall SPECIAL_DSRLV ( void );
static void _fastcall SPECIAL_DSRAV ( void );
static void _fastcall SPECIAL_MULT ( void );
static void _fastcall SPECIAL_MULTU ( void );
static void _fastcall SPECIAL_DIV ( void );
static void _fastcall SPECIAL_DIVU ( void );
static void _fastcall SPECIAL_DMULT ( void );
static void _fastcall SPECIAL_DMULTU ( void );
static void _fastcall SPECIAL_DDIV ( void );
static void _fastcall SPECIAL_DDIVU ( void );
static void _fastcall SPECIAL_ADD ( void );
static void _fastcall SPECIAL_ADDU ( void );
static void _fastcall SPECIAL_SUB ( void );
static void _fastcall SPECIAL_SUBU ( void );
static void _fastcall SPECIAL_AND ( void );
static void _fastcall SPECIAL_OR ( void );
static void _fastcall SPECIAL_XOR ( void );
static void _fastcall SPECIAL_NOR ( void );
static void _fastcall SPECIAL_SLT ( void );
static void _fastcall SPECIAL_SLTU ( void );
static void _fastcall SPECIAL_DADD ( void );
static void _fastcall SPECIAL_DADDU ( void );
static void _fastcall SPECIAL_DSUB ( void );
static void _fastcall SPECIAL_DSUBU ( void );
static void _fastcall SPECIAL_TEQ ( void );
static void _fastcall SPECIAL_DSLL ( void );
static void _fastcall SPECIAL_DSRL ( void );
static void _fastcall SPECIAL_DSRA ( void );
static void _fastcall SPECIAL_DSLL32 ( void );
static void _fastcall SPECIAL_DSRL32 ( void );
static void _fastcall SPECIAL_DSRA32 ( void );
/********************** R4300i OpCodes: RegImm **********************/
static void _fastcall REGIMM_BLTZ ( void );
static void _fastcall REGIMM_BGEZ ( void );
static void _fastcall REGIMM_BLTZL ( void );
static void _fastcall REGIMM_BGEZL ( void );
static void _fastcall REGIMM_BLTZAL ( void );
static void _fastcall REGIMM_BGEZAL ( void );
/************************** COP0 functions **************************/
static void _fastcall COP0_MF ( void );
static void _fastcall COP0_MT ( void );
/************************** COP0 CO functions ***********************/
static void _fastcall COP0_CO_TLBR ( void );
static void _fastcall COP0_CO_TLBWI ( void );
static void _fastcall COP0_CO_TLBWR ( void );
static void _fastcall COP0_CO_TLBP ( void );
static void _fastcall COP0_CO_ERET ( void );
/************************** COP1 functions **************************/
static void _fastcall COP1_MF ( void );
static void _fastcall COP1_DMF ( void );
static void _fastcall COP1_CF ( void );
static void _fastcall COP1_MT ( void );
static void _fastcall COP1_DMT ( void );
static void _fastcall COP1_CT ( void );
/************************* COP1: BC1 functions ***********************/
static void _fastcall COP1_BCF ( void );
static void _fastcall COP1_BCT ( void );
static void _fastcall COP1_BCFL ( void );
static void _fastcall COP1_BCTL ( void );
/************************** COP1: S functions ************************/
static void _fastcall COP1_S_ADD ( void );
static void _fastcall COP1_S_SUB ( void );
static void _fastcall COP1_S_MUL ( void );
static void _fastcall COP1_S_DIV ( void );
static void _fastcall COP1_S_SQRT ( void );
static void _fastcall COP1_S_ABS ( void );
static void _fastcall COP1_S_MOV ( void );
static void _fastcall COP1_S_NEG ( void );
static void _fastcall COP1_S_TRUNC_L ( void );
static void _fastcall COP1_S_CEIL_L ( void ); //added by Witten
static void _fastcall COP1_S_FLOOR_L ( void ); //added by Witten
static void _fastcall COP1_S_ROUND_W ( void );
static void _fastcall COP1_S_TRUNC_W ( void );
static void _fastcall COP1_S_CEIL_W ( void ); //added by Witten
static void _fastcall COP1_S_FLOOR_W ( void );
static void _fastcall COP1_S_CVT_D ( void );
static void _fastcall COP1_S_CVT_W ( void );
static void _fastcall COP1_S_CVT_L ( void );
static void _fastcall COP1_S_CMP ( void );
/************************** COP1: D functions ************************/
static void _fastcall COP1_D_ADD ( void );
static void _fastcall COP1_D_SUB ( void );
static void _fastcall COP1_D_MUL ( void );
static void _fastcall COP1_D_DIV ( void );
static void _fastcall COP1_D_SQRT ( void );
static void _fastcall COP1_D_ABS ( void );
static void _fastcall COP1_D_MOV ( void );
static void _fastcall COP1_D_NEG ( void );
static void _fastcall COP1_D_TRUNC_L ( void ); //added by Witten
static void _fastcall COP1_D_CEIL_L ( void ); //added by Witten
static void _fastcall COP1_D_FLOOR_L ( void ); //added by Witten
static void _fastcall COP1_D_ROUND_W ( void );
static void _fastcall COP1_D_TRUNC_W ( void );
static void _fastcall COP1_D_CEIL_W ( void ); //added by Witten
static void _fastcall COP1_D_FLOOR_W ( void ); //added by Witten
static void _fastcall COP1_D_CVT_S ( void );
static void _fastcall COP1_D_CVT_W ( void );
static void _fastcall COP1_D_CVT_L ( void );
static void _fastcall COP1_D_CMP ( void );
/************************** COP1: W functions ************************/
static void _fastcall COP1_W_CVT_S ( void );
static void _fastcall COP1_W_CVT_D ( void );
/************************** COP1: L functions ************************/
static void _fastcall COP1_L_CVT_S ( void );
static void _fastcall COP1_L_CVT_D ( void );
/************************** Other functions **************************/
static void _fastcall UnknownOpcode ( void );
static R4300iOp_FUNC * BuildInterpreter (void );
private:
static void _fastcall SPECIAL (void);
static void _fastcall REGIMM (void);
static void _fastcall COP0 (void);
static void _fastcall COP0_CO (void);
static void _fastcall COP1 (void);
static void _fastcall COP1_BC (void);
static void _fastcall COP1_S (void);
static void _fastcall COP1_D (void);
static void _fastcall COP1_W (void);
static void _fastcall COP1_L (void);
static R4300iOp_FUNC Jump_Opcode[64];
static R4300iOp_FUNC Jump_Special[64];
static R4300iOp_FUNC Jump_Regimm[32];
static R4300iOp_FUNC Jump_CoP0[32];
static R4300iOp_FUNC Jump_CoP0_Function[64];
static R4300iOp_FUNC Jump_CoP1[32];
static R4300iOp_FUNC Jump_CoP1_BC[32];
static R4300iOp_FUNC Jump_CoP1_S[64];
static R4300iOp_FUNC Jump_CoP1_D[64];
static R4300iOp_FUNC Jump_CoP1_W[64];
static R4300iOp_FUNC Jump_CoP1_L[64];
};
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/************************* OpCode functions *************************/
void _fastcall r4300i_J ( void );
void _fastcall r4300i_JAL ( void );
void _fastcall r4300i_BNE ( void );
void _fastcall r4300i_BEQ ( void );
void _fastcall r4300i_BLEZ ( void );
void _fastcall r4300i_BGTZ ( void );
void _fastcall r4300i_ADDI ( void );
void _fastcall r4300i_ADDIU ( void );
void _fastcall r4300i_SLTI ( void );
void _fastcall r4300i_SLTIU ( void );
void _fastcall r4300i_ANDI ( void );
void _fastcall r4300i_ORI ( void );
void _fastcall r4300i_XORI ( void );
void _fastcall r4300i_LUI ( void );
void _fastcall r4300i_BEQL ( void );
void _fastcall r4300i_BNEL ( void );
void _fastcall r4300i_BLEZL ( void );
void _fastcall r4300i_BGTZL ( void );
void _fastcall r4300i_DADDIU ( void );
void _fastcall r4300i_LDL ( void );
void _fastcall r4300i_LDR ( void );
void _fastcall r4300i_LB ( void );
void _fastcall r4300i_LH ( void );
void _fastcall r4300i_LWL ( void );
void _fastcall r4300i_LW ( void );
void _fastcall r4300i_LBU ( void );
void _fastcall r4300i_LHU ( void );
void _fastcall r4300i_LWR ( void );
void _fastcall r4300i_LWU ( void );
void _fastcall r4300i_SB ( void );
void _fastcall r4300i_SH ( void );
void _fastcall r4300i_SWL ( void );
void _fastcall r4300i_SW ( void );
void _fastcall r4300i_SDL ( void );
void _fastcall r4300i_SDR ( void );
void _fastcall r4300i_SWR ( void );
void _fastcall r4300i_CACHE ( void );
void _fastcall r4300i_LL ( void );
void _fastcall r4300i_LWC1 ( void );
void _fastcall r4300i_LDC1 ( void );
void _fastcall r4300i_LD ( void );
void _fastcall r4300i_SC ( void );
void _fastcall r4300i_SWC1 ( void );
void _fastcall r4300i_SDC1 ( void );
void _fastcall r4300i_SD ( void );
/********************** R4300i OpCodes: Special **********************/
void _fastcall r4300i_SPECIAL_SLL ( void );
void _fastcall r4300i_SPECIAL_SRL ( void );
void _fastcall r4300i_SPECIAL_SRA ( void );
void _fastcall r4300i_SPECIAL_SLLV ( void );
void _fastcall r4300i_SPECIAL_SRLV ( void );
void _fastcall r4300i_SPECIAL_SRAV ( void );
void _fastcall r4300i_SPECIAL_JR ( void );
void _fastcall r4300i_SPECIAL_JALR ( void );
void _fastcall r4300i_SPECIAL_SYSCALL ( void );
void _fastcall r4300i_SPECIAL_BREAK ( void );
void _fastcall r4300i_SPECIAL_SYNC ( void );
void _fastcall r4300i_SPECIAL_MFHI ( void );
void _fastcall r4300i_SPECIAL_MTHI ( void );
void _fastcall r4300i_SPECIAL_MFLO ( void );
void _fastcall r4300i_SPECIAL_MTLO ( void );
void _fastcall r4300i_SPECIAL_DSLLV ( void );
void _fastcall r4300i_SPECIAL_DSRLV ( void );
void _fastcall r4300i_SPECIAL_DSRAV ( void );
void _fastcall r4300i_SPECIAL_MULT ( void );
void _fastcall r4300i_SPECIAL_MULTU ( void );
void _fastcall r4300i_SPECIAL_DIV ( void );
void _fastcall r4300i_SPECIAL_DIVU ( void );
void _fastcall r4300i_SPECIAL_DMULT ( void );
void _fastcall r4300i_SPECIAL_DMULTU ( void );
void _fastcall r4300i_SPECIAL_DDIV ( void );
void _fastcall r4300i_SPECIAL_DDIVU ( void );
void _fastcall r4300i_SPECIAL_ADD ( void );
void _fastcall r4300i_SPECIAL_ADDU ( void );
void _fastcall r4300i_SPECIAL_SUB ( void );
void _fastcall r4300i_SPECIAL_SUBU ( void );
void _fastcall r4300i_SPECIAL_AND ( void );
void _fastcall r4300i_SPECIAL_OR ( void );
void _fastcall r4300i_SPECIAL_XOR ( void );
void _fastcall r4300i_SPECIAL_NOR ( void );
void _fastcall r4300i_SPECIAL_SLT ( void );
void _fastcall r4300i_SPECIAL_SLTU ( void );
void _fastcall r4300i_SPECIAL_DADD ( void );
void _fastcall r4300i_SPECIAL_DADDU ( void );
void _fastcall r4300i_SPECIAL_DSUB ( void );
void _fastcall r4300i_SPECIAL_DSUBU ( void );
void _fastcall r4300i_SPECIAL_TEQ ( void );
void _fastcall r4300i_SPECIAL_DSLL ( void );
void _fastcall r4300i_SPECIAL_DSRL ( void );
void _fastcall r4300i_SPECIAL_DSRA ( void );
void _fastcall r4300i_SPECIAL_DSLL32 ( void );
void _fastcall r4300i_SPECIAL_DSRL32 ( void );
void _fastcall r4300i_SPECIAL_DSRA32 ( void );
/********************** R4300i OpCodes: RegImm **********************/
void _fastcall r4300i_REGIMM_BLTZ ( void );
void _fastcall r4300i_REGIMM_BGEZ ( void );
void _fastcall r4300i_REGIMM_BLTZL ( void );
void _fastcall r4300i_REGIMM_BGEZL ( void );
void _fastcall r4300i_REGIMM_BLTZAL ( void );
void _fastcall r4300i_REGIMM_BGEZAL ( void );
/************************** COP0 functions **************************/
void _fastcall r4300i_COP0_MF ( void );
void _fastcall r4300i_COP0_MT ( void );
/************************** COP0 CO functions ***********************/
void _fastcall r4300i_COP0_CO_TLBR ( void );
void _fastcall r4300i_COP0_CO_TLBWI ( void );
void _fastcall r4300i_COP0_CO_TLBWR ( void );
void _fastcall r4300i_COP0_CO_TLBP ( void );
void _fastcall r4300i_COP0_CO_ERET ( void );
/************************** COP1 functions **************************/
void _fastcall r4300i_COP1_MF ( void );
void _fastcall r4300i_COP1_DMF ( void );
void _fastcall r4300i_COP1_CF ( void );
void _fastcall r4300i_COP1_MT ( void );
void _fastcall r4300i_COP1_DMT ( void );
void _fastcall r4300i_COP1_CT ( void );
/************************* COP1: BC1 functions ***********************/
void _fastcall r4300i_COP1_BCF ( void );
void _fastcall r4300i_COP1_BCT ( void );
void _fastcall r4300i_COP1_BCFL ( void );
void _fastcall r4300i_COP1_BCTL ( void );
/************************** COP1: S functions ************************/
void _fastcall r4300i_COP1_S_ADD ( void );
void _fastcall r4300i_COP1_S_SUB ( void );
void _fastcall r4300i_COP1_S_MUL ( void );
void _fastcall r4300i_COP1_S_DIV ( void );
void _fastcall r4300i_COP1_S_SQRT ( void );
void _fastcall r4300i_COP1_S_ABS ( void );
void _fastcall r4300i_COP1_S_MOV ( void );
void _fastcall r4300i_COP1_S_NEG ( void );
void _fastcall r4300i_COP1_S_TRUNC_L ( void );
void _fastcall r4300i_COP1_S_CEIL_L ( void ); //added by Witten
void _fastcall r4300i_COP1_S_FLOOR_L ( void ); //added by Witten
void _fastcall r4300i_COP1_S_ROUND_W ( void );
void _fastcall r4300i_COP1_S_TRUNC_W ( void );
void _fastcall r4300i_COP1_S_CEIL_W ( void ); //added by Witten
void _fastcall r4300i_COP1_S_FLOOR_W ( void );
void _fastcall r4300i_COP1_S_CVT_D ( void );
void _fastcall r4300i_COP1_S_CVT_W ( void );
void _fastcall r4300i_COP1_S_CVT_L ( void );
void _fastcall r4300i_COP1_S_CMP ( void );
/************************** COP1: D functions ************************/
void _fastcall r4300i_COP1_D_ADD ( void );
void _fastcall r4300i_COP1_D_SUB ( void );
void _fastcall r4300i_COP1_D_MUL ( void );
void _fastcall r4300i_COP1_D_DIV ( void );
void _fastcall r4300i_COP1_D_SQRT ( void );
void _fastcall r4300i_COP1_D_ABS ( void );
void _fastcall r4300i_COP1_D_MOV ( void );
void _fastcall r4300i_COP1_D_NEG ( void );
void _fastcall r4300i_COP1_D_TRUNC_L ( void ); //added by Witten
void _fastcall r4300i_COP1_D_CEIL_L ( void ); //added by Witten
void _fastcall r4300i_COP1_D_FLOOR_L ( void ); //added by Witten
void _fastcall r4300i_COP1_D_ROUND_W ( void );
void _fastcall r4300i_COP1_D_TRUNC_W ( void );
void _fastcall r4300i_COP1_D_CEIL_W ( void ); //added by Witten
void _fastcall r4300i_COP1_D_FLOOR_W ( void ); //added by Witten
void _fastcall r4300i_COP1_D_CVT_S ( void );
void _fastcall r4300i_COP1_D_CVT_W ( void );
void _fastcall r4300i_COP1_D_CVT_L ( void );
void _fastcall r4300i_COP1_D_CMP ( void );
/************************** COP1: W functions ************************/
void _fastcall r4300i_COP1_W_CVT_S ( void );
void _fastcall r4300i_COP1_W_CVT_D ( void );
/************************** COP1: L functions ************************/
void _fastcall r4300i_COP1_L_CVT_S ( void );
void _fastcall r4300i_COP1_L_CVT_D ( void );
/************************** Other functions **************************/
void _fastcall R4300i_UnknownOpcode ( void );
extern DWORD SWL_MASK[4], SWR_MASK[4], LWL_MASK[4], LWR_MASK[4]; extern DWORD SWL_MASK[4], SWR_MASK[4], LWL_MASK[4], LWR_MASK[4];
extern int SWL_SHIFT[4], SWR_SHIFT[4], LWL_SHIFT[4], LWR_SHIFT[4]; extern int SWL_SHIFT[4], SWR_SHIFT[4], LWL_SHIFT[4], LWR_SHIFT[4];
extern int RoundingModel; extern int RoundingModel;

View File

@ -219,7 +219,7 @@ void Log_LW (DWORD PC, DWORD VAddr) {
if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + RdramSize)) { return; } if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + RdramSize)) { return; }
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) { if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) {
if (!LogOptions.LogRDRamRegisters) { return; } if (!LogOptions.LogRDRamRegisters) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
switch (VAddr) { switch (VAddr) {
case 0xA3F00000: LogMessage("%08X: read from RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG (%08X)",PC, Value); return; case 0xA3F00000: LogMessage("%08X: read from RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG (%08X)",PC, Value); return;
@ -238,7 +238,7 @@ void Log_LW (DWORD PC, DWORD VAddr) {
if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) { return; } if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) { return; }
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C ) { if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C ) {
if (!LogOptions.LogSPRegisters) { return; } if (!LogOptions.LogSPRegisters) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
switch (VAddr) { switch (VAddr) {
case 0xA4040000: LogMessage("%08X: read from SP_MEM_ADDR_REG (%08X)",PC, Value); break; case 0xA4040000: LogMessage("%08X: read from SP_MEM_ADDR_REG (%08X)",PC, Value); break;
@ -254,13 +254,13 @@ void Log_LW (DWORD PC, DWORD VAddr) {
} }
if ( VAddr == 0xA4080000) { if ( VAddr == 0xA4080000) {
if (!LogOptions.LogSPRegisters) { return; } if (!LogOptions.LogSPRegisters) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SP_PC (%08X)",PC, Value); LogMessage("%08X: read from SP_PC (%08X)",PC, Value);
return; return;
} }
if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) { if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) {
if (!LogOptions.LogDPCRegisters) { return; } if (!LogOptions.LogDPCRegisters) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
switch (VAddr) { switch (VAddr) {
case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)",PC, Value); return; case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)",PC, Value); return;
@ -275,7 +275,7 @@ void Log_LW (DWORD PC, DWORD VAddr) {
} }
if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) { if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) {
if (!LogOptions.LogMIPSInterface) { return; } if (!LogOptions.LogMIPSInterface) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
switch (VAddr) { switch (VAddr) {
case 0xA4300000: LogMessage("%08X: read from MI_INIT_MODE_REG/MI_MODE_REG (%08X)",PC, Value); return; case 0xA4300000: LogMessage("%08X: read from MI_INIT_MODE_REG/MI_MODE_REG (%08X)",PC, Value); return;
@ -286,7 +286,7 @@ void Log_LW (DWORD PC, DWORD VAddr) {
} }
if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) { if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) {
if (!LogOptions.LogVideoInterface) { return; } if (!LogOptions.LogVideoInterface) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
switch (VAddr) { switch (VAddr) {
case 0xA4400000: LogMessage("%08X: read from VI_STATUS_REG/VI_CONTROL_REG (%08X)",PC, Value); return; case 0xA4400000: LogMessage("%08X: read from VI_STATUS_REG/VI_CONTROL_REG (%08X)",PC, Value); return;
@ -307,7 +307,7 @@ void Log_LW (DWORD PC, DWORD VAddr) {
} }
if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) { if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) {
if (!LogOptions.LogAudioInterface) { return; } if (!LogOptions.LogAudioInterface) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
switch (VAddr) { switch (VAddr) {
case 0xA4500000: LogMessage("%08X: read from AI_DRAM_ADDR_REG (%08X)",PC, Value); return; case 0xA4500000: LogMessage("%08X: read from AI_DRAM_ADDR_REG (%08X)",PC, Value); return;
@ -320,7 +320,7 @@ void Log_LW (DWORD PC, DWORD VAddr) {
} }
if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) { if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) {
if (!LogOptions.LogPerInterface) { return; } if (!LogOptions.LogPerInterface) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
switch (VAddr) { switch (VAddr) {
case 0xA4600000: LogMessage("%08X: read from PI_DRAM_ADDR_REG (%08X)",PC, Value); return; case 0xA4600000: LogMessage("%08X: read from PI_DRAM_ADDR_REG (%08X)",PC, Value); return;
@ -340,7 +340,7 @@ void Log_LW (DWORD PC, DWORD VAddr) {
} }
if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) { if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) {
if (!LogOptions.LogRDRAMInterface) { return; } if (!LogOptions.LogRDRAMInterface) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
switch (VAddr) { switch (VAddr) {
case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)",PC, Value); return; case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)",PC, Value); return;
@ -355,32 +355,32 @@ void Log_LW (DWORD PC, DWORD VAddr) {
} }
if ( VAddr == 0xA4800000) { if ( VAddr == 0xA4800000) {
if (!LogOptions.LogSerialInterface) { return; } if (!LogOptions.LogSerialInterface) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value); LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value);
return; return;
} }
if ( VAddr == 0xA4800004) { if ( VAddr == 0xA4800004) {
if (!LogOptions.LogSerialInterface) { return; } if (!LogOptions.LogSerialInterface) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value); LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value);
return; return;
} }
if ( VAddr == 0xA4800010) { if ( VAddr == 0xA4800010) {
if (!LogOptions.LogSerialInterface) { return; } if (!LogOptions.LogSerialInterface) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value); LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value);
return; return;
} }
if ( VAddr == 0xA4800018) { if ( VAddr == 0xA4800018) {
if (!LogOptions.LogSerialInterface) { return; } if (!LogOptions.LogSerialInterface) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value); LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value);
return; return;
} }
if ( VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0 ) { return; } if ( VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0 ) { return; }
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) { if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) {
if (!LogOptions.LogPRDirectMemLoads) { return; } if (!LogOptions.LogPRDirectMemLoads) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value); LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value);
return; return;
} }
@ -388,7 +388,7 @@ void Log_LW (DWORD PC, DWORD VAddr) {
if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040) { if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040) {
if (!LogOptions.LogRomHeader) { return; } if (!LogOptions.LogRomHeader) { return; }
r4300i_LW_VAddr(VAddr,&Value); _MMU->LW_VAddr(VAddr,Value);
switch (VAddr) { switch (VAddr) {
case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break; case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break;
case 0xB0000008: LogMessage("%08X: read from Rom Boot address offset (%08X)",PC, Value); break; case 0xB0000008: LogMessage("%08X: read from Rom Boot address offset (%08X)",PC, Value); break;

View File

@ -34,7 +34,7 @@
void ProcessControllerCommand ( int Control, BYTE * Command); void ProcessControllerCommand ( int Control, BYTE * Command);
void ReadControllerCommand (int Control, BYTE * Command); void ReadControllerCommand (int Control, BYTE * Command);
BYTE PifRom[0x7C0]/*, *PIF_Ram*/; BYTE PifRom[0x7C0];
int GetCicChipID (char * RomData) { int GetCicChipID (char * RomData) {
_int64 CRC = 0; _int64 CRC = 0;
@ -56,6 +56,8 @@ int GetCicChipID (char * RomData) {
} }
void LogControllerPakData (char * Description) { void LogControllerPakData (char * Description) {
BYTE * PIF_Ram = _MMU->PifRam();
#if (!defined(EXTERNAL_RELEASE)) #if (!defined(EXTERNAL_RELEASE))
int count, count2; int count, count2;
char HexData[100], AsciiData[100], Addon[20]; char HexData[100], AsciiData[100], Addon[20];
@ -159,6 +161,7 @@ void LoadPIF2 () {
} }
void PifRamRead (void) { void PifRamRead (void) {
BYTE * PIF_Ram = _MMU->PifRam();
int Channel, CurPos; int Channel, CurPos;
Channel = 0; Channel = 0;
@ -241,6 +244,7 @@ void PifRamRead (void) {
} }
void PifRamWrite (void) { void PifRamWrite (void) {
BYTE * PIF_Ram = _MMU->PifRam();
int Channel, CurPos; int Channel, CurPos;
Channel = 0; Channel = 0;

View File

@ -27,7 +27,7 @@
extern "C" { extern "C" {
#endif #endif
extern BYTE PifRom[0x7C0], *PIF_Ram; extern BYTE PifRom[0x7C0];
int GetCicChipID ( char * RomData ); int GetCicChipID ( char * RomData );
int LoadPifRom ( int country ); int LoadPifRom ( int country );

View File

@ -39,8 +39,8 @@ N64_BLOCKS N64_Blocks;
DWORD TLBLoadAddress, TLBStoreAddress; DWORD TLBLoadAddress, TLBStoreAddress;
void FixRandomReg (void) { void FixRandomReg (void) {
while ((int)CP0[1] < (int)CP0[6]) { while ((int)_CP0[1] < (int)_CP0[6]) {
CP0[1] += 32 - CP0[6]; _CP0[1] += 32 - _CP0[6];
} }
} }

View File

@ -30,12 +30,13 @@
#include "x86.h" #include "x86.h"
#include "debugger.h" #include "debugger.h"
#include "Recompiler Ops.h" #include "Recompiler Ops.h"
#include "../System Globals.h"
WORD FPU_RoundingMode = 0x0000;//_RC_NEAR WORD FPU_RoundingMode = 0x0000;//_RC_NEAR
char Name[50]; char Name[50];
void ChangeDefaultRoundingModel (void) { void ChangeDefaultRoundingModel (void) {
switch((FPCR[31] & 3)) { switch((_FPCR[31] & 3)) {
case 0: FPU_RoundingMode = 0x0000; break; //_RC_NEAR case 0: FPU_RoundingMode = 0x0000; break; //_RC_NEAR
case 1: FPU_RoundingMode = 0x0C00; break; //_RC_CHOP case 1: FPU_RoundingMode = 0x0C00; break; //_RC_CHOP
case 2: FPU_RoundingMode = 0x0800; break; //_RC_UP case 2: FPU_RoundingMode = 0x0800; break; //_RC_UP
@ -46,7 +47,7 @@ void ChangeDefaultRoundingModel (void) {
void CompileCop1Test (CBlockSection * Section) { void CompileCop1Test (CBlockSection * Section) {
if (Section->FpuBeenUsed()) { return; } if (Section->FpuBeenUsed()) { return; }
TestVariable(STATUS_CU1,&STATUS_REGISTER,"STATUS_REGISTER"); TestVariable(STATUS_CU1,&STATUS_REGISTER,"STATUS_REGISTER");
g_N64System->GetRecompiler()->CompileExit(Section,Section->CompilePC,Section->CompilePC,Section->RegWorking,CExitInfo::COP1_Unuseable,FALSE,JeLabel32); _N64System->GetRecompiler()->CompileExit(Section,Section->CompilePC,Section->CompilePC,Section->RegWorking,CExitInfo::COP1_Unuseable,FALSE,JeLabel32);
Section->FpuBeenUsed() = TRUE; Section->FpuBeenUsed() = TRUE;
} }
@ -72,11 +73,11 @@ void Compile_R4300i_LWC1 (CBlockSection * Section) {
DWORD Address = Section->MipsRegLo(Opcode.base) + (short)Opcode.offset; DWORD Address = Section->MipsRegLo(Opcode.base) + (short)Opcode.offset;
TempReg1 = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg1 = Map_TempReg(Section,x86_Any,-1,FALSE);
Compile_LW(Section, TempReg1,Address); _MMU->Compile_LW(Section, TempReg1,Address);
TempReg2 = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg2 = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRFloatLocation[%d]",Opcode.ft); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.ft);
MoveVariableToX86reg(&FPRFloatLocation[Opcode.ft],Name,TempReg2); MoveVariableToX86reg(&_FPRFloatLocation[Opcode.ft],Name,TempReg2);
MoveX86regToX86Pointer(TempReg1,TempReg2); MoveX86regToX86Pointer(TempReg1,TempReg2);
return; return;
} }
@ -123,8 +124,8 @@ void Compile_R4300i_LWC1 (CBlockSection * Section) {
TempReg3 = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg3 = Map_TempReg(Section,x86_Any,-1,FALSE);
MoveN64MemToX86reg(TempReg3,TempReg1); MoveN64MemToX86reg(TempReg3,TempReg1);
} }
sprintf(Name,"FPRFloatLocation[%d]",Opcode.ft); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.ft);
MoveVariableToX86reg(&FPRFloatLocation[Opcode.ft],Name,TempReg2); MoveVariableToX86reg(&_FPRFloatLocation[Opcode.ft],Name,TempReg2);
MoveX86regToX86Pointer(TempReg3,TempReg2); MoveX86regToX86Pointer(TempReg3,TempReg2);
} }
@ -139,17 +140,17 @@ void Compile_R4300i_LDC1 (CBlockSection * Section) {
if (Section->IsConst(Opcode.base)) { if (Section->IsConst(Opcode.base)) {
DWORD Address = Section->MipsRegLo(Opcode.base) + (short)Opcode.offset; DWORD Address = Section->MipsRegLo(Opcode.base) + (short)Opcode.offset;
TempReg1 = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg1 = Map_TempReg(Section,x86_Any,-1,FALSE);
Compile_LW(Section, TempReg1,Address); _MMU->Compile_LW(Section, TempReg1,Address);
TempReg2 = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg2 = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRDoubleLocation[%d]",Opcode.ft); sprintf(Name,"_FPRDoubleLocation[%d]",Opcode.ft);
MoveVariableToX86reg(&FPRDoubleLocation[Opcode.ft],Name,TempReg2); MoveVariableToX86reg(&_FPRDoubleLocation[Opcode.ft],Name,TempReg2);
AddConstToX86Reg(TempReg2,4); AddConstToX86Reg(TempReg2,4);
MoveX86regToX86Pointer(TempReg1,TempReg2); MoveX86regToX86Pointer(TempReg1,TempReg2);
Compile_LW(Section,TempReg1,Address + 4); _MMU->Compile_LW(Section,TempReg1,Address + 4);
sprintf(Name,"FPRFloatLocation[%d]",Opcode.ft); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.ft);
MoveVariableToX86reg(&FPRDoubleLocation[Opcode.ft],Name,TempReg2); MoveVariableToX86reg(&_FPRDoubleLocation[Opcode.ft],Name,TempReg2);
MoveX86regToX86Pointer(TempReg1,TempReg2); MoveX86regToX86Pointer(TempReg1,TempReg2);
return; return;
} }
@ -191,28 +192,28 @@ void Compile_R4300i_LDC1 (CBlockSection * Section) {
TempReg3 = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg3 = Map_TempReg(Section,x86_Any,-1,FALSE);
MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg3); MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg3);
Push(TempReg2); Push(TempReg2);
sprintf(Name,"FPRFloatLocation[%d]",Opcode.ft); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.ft);
MoveVariableToX86reg(&FPRDoubleLocation[Opcode.ft],Name,TempReg2); MoveVariableToX86reg(&_FPRDoubleLocation[Opcode.ft],Name,TempReg2);
AddConstToX86Reg(TempReg2,4); AddConstToX86Reg(TempReg2,4);
MoveX86regToX86Pointer(TempReg3,TempReg2); MoveX86regToX86Pointer(TempReg3,TempReg2);
Pop(TempReg2); Pop(TempReg2);
MoveX86regPointerToX86regDisp8(TempReg1, TempReg2,TempReg3,4); MoveX86regPointerToX86regDisp8(TempReg1, TempReg2,TempReg3,4);
sprintf(Name,"FPRFloatLocation[%d]",Opcode.ft); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.ft);
MoveVariableToX86reg(&FPRDoubleLocation[Opcode.ft],Name,TempReg2); MoveVariableToX86reg(&_FPRDoubleLocation[Opcode.ft],Name,TempReg2);
MoveX86regToX86Pointer(TempReg3,TempReg2); MoveX86regToX86Pointer(TempReg3,TempReg2);
} else { } else {
AndConstToX86Reg(TempReg1,0x1FFFFFFF); AndConstToX86Reg(TempReg1,0x1FFFFFFF);
TempReg3 = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg3 = Map_TempReg(Section,x86_Any,-1,FALSE);
MoveN64MemToX86reg(TempReg3,TempReg1); MoveN64MemToX86reg(TempReg3,TempReg1);
sprintf(Name,"FPRFloatLocation[%d]",Opcode.ft); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.ft);
MoveVariableToX86reg(&FPRDoubleLocation[Opcode.ft],Name,TempReg2); MoveVariableToX86reg(&_FPRDoubleLocation[Opcode.ft],Name,TempReg2);
AddConstToX86Reg(TempReg2,4); AddConstToX86Reg(TempReg2,4);
MoveX86regToX86Pointer(TempReg3,TempReg2); MoveX86regToX86Pointer(TempReg3,TempReg2);
MoveN64MemDispToX86reg(TempReg3,TempReg1,4); MoveN64MemDispToX86reg(TempReg3,TempReg1,4);
sprintf(Name,"FPRFloatLocation[%d]",Opcode.ft); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.ft);
MoveVariableToX86reg(&FPRDoubleLocation[Opcode.ft],Name,TempReg2); MoveVariableToX86reg(&_FPRDoubleLocation[Opcode.ft],Name,TempReg2);
MoveX86regToX86Pointer(TempReg3,TempReg2); MoveX86regToX86Pointer(TempReg3,TempReg2);
} }
} }
@ -230,10 +231,10 @@ void Compile_R4300i_SWC1 (CBlockSection * Section){
UnMap_FPR(Section,Opcode.ft,TRUE); UnMap_FPR(Section,Opcode.ft,TRUE);
TempReg1 = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg1 = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRFloatLocation[%d]",Opcode.ft); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.ft);
MoveVariableToX86reg(&FPRFloatLocation[Opcode.ft],Name,TempReg1); MoveVariableToX86reg(&_FPRFloatLocation[Opcode.ft],Name,TempReg1);
MoveX86PointerToX86reg(TempReg1,TempReg1); MoveX86PointerToX86reg(TempReg1,TempReg1);
Compile_SW_Register(Section,TempReg1, Address); _MMU->Compile_SW_Register(Section,TempReg1, Address);
return; return;
} }
if (Section->IsMapped(Opcode.base)) { if (Section->IsMapped(Opcode.base)) {
@ -266,15 +267,15 @@ void Compile_R4300i_SWC1 (CBlockSection * Section){
UnMap_FPR(Section,Opcode.ft,TRUE); UnMap_FPR(Section,Opcode.ft,TRUE);
TempReg3 = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg3 = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRFloatLocation[%d]",Opcode.ft); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.ft);
MoveVariableToX86reg(&FPRFloatLocation[Opcode.ft],Name,TempReg3); MoveVariableToX86reg(&_FPRFloatLocation[Opcode.ft],Name,TempReg3);
MoveX86PointerToX86reg(TempReg3,TempReg3); MoveX86PointerToX86reg(TempReg3,TempReg3);
MoveX86regToX86regPointer(TempReg3,TempReg1, TempReg2); MoveX86regToX86regPointer(TempReg3,TempReg1, TempReg2);
} else { } else {
TempReg2 = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg2 = Map_TempReg(Section,x86_Any,-1,FALSE);
UnMap_FPR(Section,Opcode.ft,TRUE); UnMap_FPR(Section,Opcode.ft,TRUE);
sprintf(Name,"FPRFloatLocation[%d]",Opcode.ft); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.ft);
MoveVariableToX86reg(&FPRFloatLocation[Opcode.ft],Name,TempReg2); MoveVariableToX86reg(&_FPRFloatLocation[Opcode.ft],Name,TempReg2);
MoveX86PointerToX86reg(TempReg2,TempReg2); MoveX86PointerToX86reg(TempReg2,TempReg2);
AndConstToX86Reg(TempReg1,0x1FFFFFFF); AndConstToX86Reg(TempReg1,0x1FFFFFFF);
MoveX86regToN64Mem(TempReg2, TempReg1); MoveX86regToN64Mem(TempReg2, TempReg1);
@ -292,16 +293,16 @@ void Compile_R4300i_SDC1 (CBlockSection * Section){
DWORD Address = Section->MipsRegLo(Opcode.base) + (short)Opcode.offset; DWORD Address = Section->MipsRegLo(Opcode.base) + (short)Opcode.offset;
TempReg1 = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg1 = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRDoubleLocation[%d]",Opcode.ft); sprintf(Name,"_FPRDoubleLocation[%d]",Opcode.ft);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Opcode.ft],Name,TempReg1); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Opcode.ft],Name,TempReg1);
AddConstToX86Reg(TempReg1,4); AddConstToX86Reg(TempReg1,4);
MoveX86PointerToX86reg(TempReg1,TempReg1); MoveX86PointerToX86reg(TempReg1,TempReg1);
Compile_SW_Register(Section,TempReg1, Address); _MMU->Compile_SW_Register(Section,TempReg1, Address);
sprintf(Name,"FPRDoubleLocation[%d]",Opcode.ft); sprintf(Name,"_FPRDoubleLocation[%d]",Opcode.ft);
MoveVariableToX86reg(&FPRDoubleLocation[Opcode.ft],Name,TempReg1); MoveVariableToX86reg(&_FPRDoubleLocation[Opcode.ft],Name,TempReg1);
MoveX86PointerToX86reg(TempReg1,TempReg1); MoveX86PointerToX86reg(TempReg1,TempReg1);
Compile_SW_Register(Section,TempReg1, Address + 4); _MMU->Compile_SW_Register(Section,TempReg1, Address + 4);
return; return;
} }
if (Section->IsMapped(Opcode.base)) { if (Section->IsMapped(Opcode.base)) {
@ -333,27 +334,27 @@ void Compile_R4300i_SDC1 (CBlockSection * Section){
//0041C524 75 01 jne 0041C527 //0041C524 75 01 jne 0041C527
TempReg3 = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg3 = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRDoubleLocation[%d]",Opcode.ft); sprintf(Name,"_FPRDoubleLocation[%d]",Opcode.ft);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Opcode.ft],Name,TempReg3); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Opcode.ft],Name,TempReg3);
AddConstToX86Reg(TempReg3,4); AddConstToX86Reg(TempReg3,4);
MoveX86PointerToX86reg(TempReg3,TempReg3); MoveX86PointerToX86reg(TempReg3,TempReg3);
MoveX86regToX86regPointer(TempReg3,TempReg1, TempReg2); MoveX86regToX86regPointer(TempReg3,TempReg1, TempReg2);
AddConstToX86Reg(TempReg1,4); AddConstToX86Reg(TempReg1,4);
sprintf(Name,"FPRDoubleLocation[%d]",Opcode.ft); sprintf(Name,"_FPRDoubleLocation[%d]",Opcode.ft);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Opcode.ft],Name,TempReg3); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Opcode.ft],Name,TempReg3);
MoveX86PointerToX86reg(TempReg3,TempReg3); MoveX86PointerToX86reg(TempReg3,TempReg3);
MoveX86regToX86regPointer(TempReg3,TempReg1, TempReg2); MoveX86regToX86regPointer(TempReg3,TempReg1, TempReg2);
} else { } else {
AndConstToX86Reg(TempReg1,0x1FFFFFFF); AndConstToX86Reg(TempReg1,0x1FFFFFFF);
TempReg3 = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg3 = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRDoubleLocation[%d]",Opcode.ft); sprintf(Name,"_FPRDoubleLocation[%d]",Opcode.ft);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Opcode.ft],Name,TempReg3); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Opcode.ft],Name,TempReg3);
AddConstToX86Reg(TempReg3,4); AddConstToX86Reg(TempReg3,4);
MoveX86PointerToX86reg(TempReg3,TempReg3); MoveX86PointerToX86reg(TempReg3,TempReg3);
MoveX86regToN64Mem(TempReg3, TempReg1); MoveX86regToN64Mem(TempReg3, TempReg1);
sprintf(Name,"FPRDoubleLocation[%d]",Opcode.ft); sprintf(Name,"_FPRDoubleLocation[%d]",Opcode.ft);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Opcode.ft],Name,TempReg3); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Opcode.ft],Name,TempReg3);
MoveX86PointerToX86reg(TempReg3,TempReg3); MoveX86PointerToX86reg(TempReg3,TempReg3);
MoveX86regToN64MemDisp(TempReg3, TempReg1,4); MoveX86regToN64MemDisp(TempReg3, TempReg1,4);
} }
@ -370,8 +371,8 @@ void Compile_R4300i_COP1_MF (CBlockSection * Section) {
UnMap_FPR(Section,Opcode.fs,TRUE); UnMap_FPR(Section,Opcode.fs,TRUE);
Map_GPR_32bit(Section,Opcode.rt, TRUE, -1); Map_GPR_32bit(Section,Opcode.rt, TRUE, -1);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRFloatLocation[%d]",Opcode.fs); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.fs);
MoveVariableToX86reg((BYTE *)&FPRFloatLocation[Opcode.fs],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRFloatLocation[Opcode.fs],Name,TempReg);
MoveX86PointerToX86reg(Section->MipsRegLo(Opcode.rt),TempReg); MoveX86PointerToX86reg(Section->MipsRegLo(Opcode.rt),TempReg);
} }
@ -384,12 +385,12 @@ void Compile_R4300i_COP1_DMF (CBlockSection * Section) {
UnMap_FPR(Section,Opcode.fs,TRUE); UnMap_FPR(Section,Opcode.fs,TRUE);
Map_GPR_64bit(Section,Opcode.rt, -1); Map_GPR_64bit(Section,Opcode.rt, -1);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRDoubleLocation[%d]",Opcode.fs); sprintf(Name,"_FPRDoubleLocation[%d]",Opcode.fs);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Opcode.fs],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Opcode.fs],Name,TempReg);
AddConstToX86Reg(TempReg,4); AddConstToX86Reg(TempReg,4);
MoveX86PointerToX86reg(Section->MipsRegHi(Opcode.rt),TempReg); MoveX86PointerToX86reg(Section->MipsRegHi(Opcode.rt),TempReg);
sprintf(Name,"FPRDoubleLocation[%d]",Opcode.fs); sprintf(Name,"_FPRDoubleLocation[%d]",Opcode.fs);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Opcode.fs],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Opcode.fs],Name,TempReg);
MoveX86PointerToX86reg(Section->MipsRegLo(Opcode.rt),TempReg); MoveX86PointerToX86reg(Section->MipsRegLo(Opcode.rt),TempReg);
} }
@ -400,7 +401,7 @@ void Compile_R4300i_COP1_CF(CBlockSection * Section) {
if (Opcode.fs != 31 && Opcode.fs != 0) { Compile_R4300i_UnknownOpcode (Section); return; } if (Opcode.fs != 31 && Opcode.fs != 0) { Compile_R4300i_UnknownOpcode (Section); return; }
Map_GPR_32bit(Section,Opcode.rt,TRUE,-1); Map_GPR_32bit(Section,Opcode.rt,TRUE,-1);
MoveVariableToX86reg(&FPCR[Opcode.fs],FPR_Ctrl_Name[Opcode.fs],Section->MipsRegLo(Opcode.rt)); MoveVariableToX86reg(&_FPCR[Opcode.fs],FPR_Ctrl_Name[Opcode.fs],Section->MipsRegLo(Opcode.rt));
} }
void Compile_R4300i_COP1_MT( CBlockSection * Section) { void Compile_R4300i_COP1_MT( CBlockSection * Section) {
@ -416,8 +417,8 @@ void Compile_R4300i_COP1_MT( CBlockSection * Section) {
} }
UnMap_FPR(Section,Opcode.fs,TRUE); UnMap_FPR(Section,Opcode.fs,TRUE);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRFloatLocation[%d]",Opcode.fs); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.fs);
MoveVariableToX86reg((BYTE *)&FPRFloatLocation[Opcode.fs],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRFloatLocation[Opcode.fs],Name,TempReg);
if (Section->IsConst(Opcode.rt)) { if (Section->IsConst(Opcode.rt)) {
MoveConstToX86Pointer(Section->MipsRegLo(Opcode.rt),TempReg); MoveConstToX86Pointer(Section->MipsRegLo(Opcode.rt),TempReg);
@ -441,8 +442,8 @@ void Compile_R4300i_COP1_DMT( CBlockSection * Section) {
} }
UnMap_FPR(Section,Opcode.fs,TRUE); UnMap_FPR(Section,Opcode.fs,TRUE);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRDoubleLocation[%d]",Opcode.fs); sprintf(Name,"_FPRDoubleLocation[%d]",Opcode.fs);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Opcode.fs],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Opcode.fs],Name,TempReg);
if (Section->IsConst(Opcode.rt)) { if (Section->IsConst(Opcode.rt)) {
MoveConstToX86Pointer(Section->MipsRegLo(Opcode.rt),TempReg); MoveConstToX86Pointer(Section->MipsRegLo(Opcode.rt),TempReg);
@ -476,11 +477,11 @@ void Compile_R4300i_COP1_CT(CBlockSection * Section) {
if (Opcode.fs != 31) { Compile_R4300i_UnknownOpcode (Section); return; } if (Opcode.fs != 31) { Compile_R4300i_UnknownOpcode (Section); return; }
if (Section->IsConst(Opcode.rt)) { if (Section->IsConst(Opcode.rt)) {
MoveConstToVariable(Section->MipsRegLo(Opcode.rt),&FPCR[Opcode.fs],FPR_Ctrl_Name[Opcode.fs]); MoveConstToVariable(Section->MipsRegLo(Opcode.rt),&_FPCR[Opcode.fs],FPR_Ctrl_Name[Opcode.fs]);
} else if (Section->IsMapped(Opcode.rt)) { } else if (Section->IsMapped(Opcode.rt)) {
MoveX86regToVariable(Section->MipsRegLo(Opcode.rt),&FPCR[Opcode.fs],FPR_Ctrl_Name[Opcode.fs]); MoveX86regToVariable(Section->MipsRegLo(Opcode.rt),&_FPCR[Opcode.fs],FPR_Ctrl_Name[Opcode.fs]);
} else { } else {
MoveX86regToVariable(Map_TempReg(Section,x86_Any,Opcode.rt,FALSE),&FPCR[Opcode.fs],FPR_Ctrl_Name[Opcode.fs]); MoveX86regToVariable(Map_TempReg(Section,x86_Any,Opcode.rt,FALSE),&_FPCR[Opcode.fs],FPR_Ctrl_Name[Opcode.fs]);
} }
Pushad(); Pushad();
Call_Direct(ChangeDefaultRoundingModel, "ChangeDefaultRoundingModel"); Call_Direct(ChangeDefaultRoundingModel, "ChangeDefaultRoundingModel");
@ -506,8 +507,8 @@ void Compile_R4300i_COP1_S_ADD (CBlockSection * Section) {
UnMap_FPR(Section,Reg2,TRUE); UnMap_FPR(Section,Reg2,TRUE);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRFloatLocation[%d]",Reg2); sprintf(Name,"_FPRFloatLocation[%d]",Reg2);
MoveVariableToX86reg((BYTE *)&FPRFloatLocation[Reg2],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRFloatLocation[Reg2],Name,TempReg);
Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Float); Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Float);
fpuAddDwordRegPointer(TempReg); fpuAddDwordRegPointer(TempReg);
} }
@ -529,8 +530,8 @@ void Compile_R4300i_COP1_S_SUB (CBlockSection * Section) {
Load_FPR_ToTop(Section,Opcode.fd,Opcode.fs,CRegInfo::FPU_Float); Load_FPR_ToTop(Section,Opcode.fd,Opcode.fs,CRegInfo::FPU_Float);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRFloatLocation[%d]",Opcode.ft); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.ft);
MoveVariableToX86reg((BYTE *)&FPRFloatLocation[Opcode.ft],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRFloatLocation[Opcode.ft],Name,TempReg);
fpuSubDwordRegPointer(TempReg); fpuSubDwordRegPointer(TempReg);
} else { } else {
Load_FPR_ToTop(Section,Opcode.fd,Reg1, CRegInfo::FPU_Float); Load_FPR_ToTop(Section,Opcode.fd,Reg1, CRegInfo::FPU_Float);
@ -541,8 +542,8 @@ void Compile_R4300i_COP1_S_SUB (CBlockSection * Section) {
Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Float); Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Float);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRFloatLocation[%d]",Reg2); sprintf(Name,"_FPRFloatLocation[%d]",Reg2);
MoveVariableToX86reg((BYTE *)&FPRFloatLocation[Reg2],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRFloatLocation[Reg2],Name,TempReg);
fpuSubDwordRegPointer(TempReg); fpuSubDwordRegPointer(TempReg);
} }
} }
@ -567,8 +568,8 @@ void Compile_R4300i_COP1_S_MUL (CBlockSection * Section) {
Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Float); Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Float);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRFloatLocation[%d]",Reg2); sprintf(Name,"_FPRFloatLocation[%d]",Reg2);
MoveVariableToX86reg((BYTE *)&FPRFloatLocation[Reg2],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRFloatLocation[Reg2],Name,TempReg);
fpuMulDwordRegPointer(TempReg); fpuMulDwordRegPointer(TempReg);
} }
UnMap_FPR(Section,Opcode.fd,TRUE); UnMap_FPR(Section,Opcode.fd,TRUE);
@ -589,8 +590,8 @@ void Compile_R4300i_COP1_S_DIV (CBlockSection * Section) {
Load_FPR_ToTop(Section,Opcode.fd,Opcode.fs,CRegInfo::FPU_Float); Load_FPR_ToTop(Section,Opcode.fd,Opcode.fs,CRegInfo::FPU_Float);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRFloatLocation[%d]",Opcode.ft); sprintf(Name,"_FPRFloatLocation[%d]",Opcode.ft);
MoveVariableToX86reg((BYTE *)&FPRFloatLocation[Opcode.ft],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRFloatLocation[Opcode.ft],Name,TempReg);
fpuDivDwordRegPointer(TempReg); fpuDivDwordRegPointer(TempReg);
} else { } else {
Load_FPR_ToTop(Section,Opcode.fd,Reg1, CRegInfo::FPU_Float); Load_FPR_ToTop(Section,Opcode.fd,Reg1, CRegInfo::FPU_Float);
@ -601,8 +602,8 @@ void Compile_R4300i_COP1_S_DIV (CBlockSection * Section) {
Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Float); Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Float);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRFloatLocation[%d]",Reg2); sprintf(Name,"_FPRFloatLocation[%d]",Reg2);
MoveVariableToX86reg((BYTE *)&FPRFloatLocation[Reg2],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRFloatLocation[Reg2],Name,TempReg);
fpuDivDwordRegPointer(TempReg); fpuDivDwordRegPointer(TempReg);
} }
} }
@ -768,8 +769,8 @@ void Compile_R4300i_COP1_S_CMP (CBlockSection * Section) {
Load_FPR_ToTop(Section,Reg1,Reg1, CRegInfo::FPU_Float); Load_FPR_ToTop(Section,Reg1,Reg1, CRegInfo::FPU_Float);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRFloatLocation[%d]",Reg2); sprintf(Name,"_FPRFloatLocation[%d]",Reg2);
MoveVariableToX86reg((BYTE *)&FPRFloatLocation[Reg2],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRFloatLocation[Reg2],Name,TempReg);
fpuComDwordRegPointer(TempReg,FALSE); fpuComDwordRegPointer(TempReg,FALSE);
} }
AndConstToVariable(~FPCSR_C, &FSTATUS_REGISTER, "FSTATUS_REGISTER"); AndConstToVariable(~FPCSR_C, &FSTATUS_REGISTER, "FSTATUS_REGISTER");
@ -796,7 +797,7 @@ void Compile_R4300i_COP1_S_CMP (CBlockSection * Section) {
Setz(x86reg); Setz(x86reg);
} }
ShiftLeftSignImmed(x86reg, 23); ShiftLeftSignImmed(x86reg, 23);
OrX86RegToVariable(&FPCR[31], "FPCR[31]", x86reg); OrX86RegToVariable(&_FPCR[31], "_FPCR[31]", x86reg);
} }
/************************** COP1: D functions ************************/ /************************** COP1: D functions ************************/
@ -816,8 +817,8 @@ void Compile_R4300i_COP1_D_ADD (CBlockSection * Section) {
UnMap_FPR(Section,Reg2,TRUE); UnMap_FPR(Section,Reg2,TRUE);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRDoubleLocation[%d]",Reg2); sprintf(Name,"_FPRDoubleLocation[%d]",Reg2);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Reg2],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Reg2],Name,TempReg);
Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Double); Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Double);
fpuAddQwordRegPointer(TempReg); fpuAddQwordRegPointer(TempReg);
} }
@ -835,8 +836,8 @@ void Compile_R4300i_COP1_D_SUB (CBlockSection * Section) {
if (Opcode.fd == Opcode.ft) { if (Opcode.fd == Opcode.ft) {
UnMap_FPR(Section,Opcode.fd,TRUE); UnMap_FPR(Section,Opcode.fd,TRUE);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRDoubleLocation[%d]",Opcode.ft); sprintf(Name,"_FPRDoubleLocation[%d]",Opcode.ft);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Opcode.ft],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Opcode.ft],Name,TempReg);
Load_FPR_ToTop(Section,Opcode.fd,Opcode.fs,CRegInfo::FPU_Double); Load_FPR_ToTop(Section,Opcode.fd,Opcode.fs,CRegInfo::FPU_Double);
fpuSubQwordRegPointer(TempReg); fpuSubQwordRegPointer(TempReg);
} else { } else {
@ -847,8 +848,8 @@ void Compile_R4300i_COP1_D_SUB (CBlockSection * Section) {
UnMap_FPR(Section,Reg2,TRUE); UnMap_FPR(Section,Reg2,TRUE);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRDoubleLocation[%d]",Reg2); sprintf(Name,"_FPRDoubleLocation[%d]",Reg2);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Reg2],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Reg2],Name,TempReg);
Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Double); Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Double);
fpuSubQwordRegPointer(TempReg); fpuSubQwordRegPointer(TempReg);
} }
@ -872,8 +873,8 @@ void Compile_R4300i_COP1_D_MUL (CBlockSection * Section) {
UnMap_FPR(Section,Reg2,TRUE); UnMap_FPR(Section,Reg2,TRUE);
Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Double); Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Double);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRDoubleLocation[%d]",Reg2); sprintf(Name,"_FPRDoubleLocation[%d]",Reg2);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Reg2],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Reg2],Name,TempReg);
fpuMulQwordRegPointer(TempReg); fpuMulQwordRegPointer(TempReg);
} }
} }
@ -890,8 +891,8 @@ void Compile_R4300i_COP1_D_DIV (CBlockSection * Section) {
if (Opcode.fd == Opcode.ft) { if (Opcode.fd == Opcode.ft) {
UnMap_FPR(Section,Opcode.fd,TRUE); UnMap_FPR(Section,Opcode.fd,TRUE);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRDoubleLocation[%d]",Opcode.ft); sprintf(Name,"_FPRDoubleLocation[%d]",Opcode.ft);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Opcode.ft],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Opcode.ft],Name,TempReg);
Load_FPR_ToTop(Section,Opcode.fd,Opcode.fs,CRegInfo::FPU_Double); Load_FPR_ToTop(Section,Opcode.fd,Opcode.fs,CRegInfo::FPU_Double);
fpuDivQwordRegPointer(TempReg); fpuDivQwordRegPointer(TempReg);
} else { } else {
@ -901,8 +902,8 @@ void Compile_R4300i_COP1_D_DIV (CBlockSection * Section) {
} else { } else {
UnMap_FPR(Section,Reg2,TRUE); UnMap_FPR(Section,Reg2,TRUE);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRDoubleLocation[%d]",Reg2); sprintf(Name,"_FPRDoubleLocation[%d]",Reg2);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Reg2],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Reg2],Name,TempReg);
Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Double); Load_FPR_ToTop(Section,Opcode.fd,Opcode.fd, CRegInfo::FPU_Double);
fpuDivQwordRegPointer(TempReg); fpuDivQwordRegPointer(TempReg);
} }
@ -1084,8 +1085,8 @@ void Compile_R4300i_COP1_D_CMP (CBlockSection * Section) {
UnMap_FPR(Section,Reg2,TRUE); UnMap_FPR(Section,Reg2,TRUE);
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
sprintf(Name,"FPRDoubleLocation[%d]",Reg2); sprintf(Name,"_FPRDoubleLocation[%d]",Reg2);
MoveVariableToX86reg((BYTE *)&FPRDoubleLocation[Reg2],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Reg2],Name,TempReg);
Load_FPR_ToTop(Section,Reg1,Reg1, CRegInfo::FPU_Double); Load_FPR_ToTop(Section,Reg1,Reg1, CRegInfo::FPU_Double);
fpuComQwordRegPointer(TempReg,FALSE); fpuComQwordRegPointer(TempReg,FALSE);
} }
@ -1112,7 +1113,7 @@ void Compile_R4300i_COP1_D_CMP (CBlockSection * Section) {
Setz(x86reg); Setz(x86reg);
} }
ShiftLeftSignImmed(x86reg, 23); ShiftLeftSignImmed(x86reg, 23);
OrX86RegToVariable(&FPCR[31], "FPCR[31]", x86reg); OrX86RegToVariable(&_FPCR[31], "_FPCR[31]", x86reg);
} }
/************************** COP1: W functions ************************/ /************************** COP1: W functions ************************/

File diff suppressed because it is too large Load Diff

View File

@ -286,7 +286,7 @@ void InitalizeR4300iRegisters (int UsePif, int Country, int CIC_Chip) {
memset(RegPI,0,sizeof(Registers.PI)); memset(RegPI,0,sizeof(Registers.PI));
memset(RegRI,0,sizeof(Registers.RI)); memset(RegRI,0,sizeof(Registers.RI));
memset(RegSI,0,sizeof(Registers.SI)); memset(RegSI,0,sizeof(Registers.SI));
memset(GPR,0,sizeof(Registers.GPR)); memset(_GPR,0,sizeof(Registers._GPR));
memset(FPR,0,sizeof(Registers.FPR)); memset(FPR,0,sizeof(Registers.FPR));
if (CIC_Chip < 0) { if (CIC_Chip < 0) {
@ -347,23 +347,23 @@ void InitalizeR4300iRegisters (int UsePif, int Country, int CIC_Chip) {
memcpy( (N64MEM+0x4000040), (ROM + 0x040), 0xFBC); memcpy( (N64MEM+0x4000040), (ROM + 0x040), 0xFBC);
PROGRAM_COUNTER = 0xA4000040; PROGRAM_COUNTER = 0xA4000040;
GPR[0].DW=0x0000000000000000; _GPR[0].DW=0x0000000000000000;
GPR[6].DW=0xFFFFFFFFA4001F0C; _GPR[6].DW=0xFFFFFFFFA4001F0C;
GPR[7].DW=0xFFFFFFFFA4001F08; _GPR[7].DW=0xFFFFFFFFA4001F08;
GPR[8].DW=0x00000000000000C0; _GPR[8].DW=0x00000000000000C0;
GPR[9].DW=0x0000000000000000; _GPR[9].DW=0x0000000000000000;
GPR[10].DW=0x0000000000000040; _GPR[10].DW=0x0000000000000040;
GPR[11].DW=0xFFFFFFFFA4000040; _GPR[11].DW=0xFFFFFFFFA4000040;
GPR[16].DW=0x0000000000000000; _GPR[16].DW=0x0000000000000000;
GPR[17].DW=0x0000000000000000; _GPR[17].DW=0x0000000000000000;
GPR[18].DW=0x0000000000000000; _GPR[18].DW=0x0000000000000000;
GPR[19].DW=0x0000000000000000; _GPR[19].DW=0x0000000000000000;
GPR[21].DW=0x0000000000000000; _GPR[21].DW=0x0000000000000000;
GPR[26].DW=0x0000000000000000; _GPR[26].DW=0x0000000000000000;
GPR[27].DW=0x0000000000000000; _GPR[27].DW=0x0000000000000000;
GPR[28].DW=0x0000000000000000; _GPR[28].DW=0x0000000000000000;
GPR[29].DW=0xFFFFFFFFA4001FF0; _GPR[29].DW=0xFFFFFFFFA4001FF0;
GPR[30].DW=0x0000000000000000; _GPR[30].DW=0x0000000000000000;
switch (Country) { switch (Country) {
case 0x44: //Germany case 0x44: //Germany
@ -376,31 +376,31 @@ void InitalizeR4300iRegisters (int UsePif, int Country, int CIC_Chip) {
case 0x59: // X (PAL) case 0x59: // X (PAL)
switch (CIC_Chip) { switch (CIC_Chip) {
case 2: case 2:
GPR[5].DW=0xFFFFFFFFC0F1D859; _GPR[5].DW=0xFFFFFFFFC0F1D859;
GPR[14].DW=0x000000002DE108EA; _GPR[14].DW=0x000000002DE108EA;
GPR[24].DW=0x0000000000000000; _GPR[24].DW=0x0000000000000000;
break; break;
case 3: case 3:
GPR[5].DW=0xFFFFFFFFD4646273; _GPR[5].DW=0xFFFFFFFFD4646273;
GPR[14].DW=0x000000001AF99984; _GPR[14].DW=0x000000001AF99984;
GPR[24].DW=0x0000000000000000; _GPR[24].DW=0x0000000000000000;
break; break;
case 5: case 5:
*(DWORD *)&IMEM[0x04] = 0xBDA807FC; *(DWORD *)&IMEM[0x04] = 0xBDA807FC;
GPR[5].DW=0xFFFFFFFFDECAAAD1; _GPR[5].DW=0xFFFFFFFFDECAAAD1;
GPR[14].DW=0x000000000CF85C13; _GPR[14].DW=0x000000000CF85C13;
GPR[24].DW=0x0000000000000002; _GPR[24].DW=0x0000000000000002;
break; break;
case 6: case 6:
GPR[5].DW=0xFFFFFFFFB04DC903; _GPR[5].DW=0xFFFFFFFFB04DC903;
GPR[14].DW=0x000000001AF99984; _GPR[14].DW=0x000000001AF99984;
GPR[24].DW=0x0000000000000002; _GPR[24].DW=0x0000000000000002;
break; break;
} }
GPR[20].DW=0x0000000000000000; _GPR[20].DW=0x0000000000000000;
GPR[23].DW=0x0000000000000006; _GPR[23].DW=0x0000000000000006;
GPR[31].DW=0xFFFFFFFFA4001554; _GPR[31].DW=0xFFFFFFFFA4001554;
break; break;
case 0x37: // 7 (Beta) case 0x37: // 7 (Beta)
case 0x41: // ???? case 0x41: // ????
@ -409,53 +409,53 @@ void InitalizeR4300iRegisters (int UsePif, int Country, int CIC_Chip) {
default: default:
switch (CIC_Chip) { switch (CIC_Chip) {
case 2: case 2:
GPR[5].DW=0xFFFFFFFFC95973D5; _GPR[5].DW=0xFFFFFFFFC95973D5;
GPR[14].DW=0x000000002449A366; _GPR[14].DW=0x000000002449A366;
break; break;
case 3: case 3:
GPR[5].DW=0xFFFFFFFF95315A28; _GPR[5].DW=0xFFFFFFFF95315A28;
GPR[14].DW=0x000000005BACA1DF; _GPR[14].DW=0x000000005BACA1DF;
break; break;
case 5: case 5:
*(DWORD *)&IMEM[0x04] = 0x8DA807FC; *(DWORD *)&IMEM[0x04] = 0x8DA807FC;
GPR[5].DW=0x000000005493FB9A; _GPR[5].DW=0x000000005493FB9A;
GPR[14].DW=0xFFFFFFFFC2C20384; _GPR[14].DW=0xFFFFFFFFC2C20384;
case 6: case 6:
GPR[5].DW=0xFFFFFFFFE067221F; _GPR[5].DW=0xFFFFFFFFE067221F;
GPR[14].DW=0x000000005CD2B70F; _GPR[14].DW=0x000000005CD2B70F;
break; break;
} }
GPR[20].DW=0x0000000000000001; _GPR[20].DW=0x0000000000000001;
GPR[23].DW=0x0000000000000000; _GPR[23].DW=0x0000000000000000;
GPR[24].DW=0x0000000000000003; _GPR[24].DW=0x0000000000000003;
GPR[31].DW=0xFFFFFFFFA4001550; _GPR[31].DW=0xFFFFFFFFA4001550;
} }
switch (CIC_Chip) { switch (CIC_Chip) {
case 1: case 1:
GPR[22].DW=0x000000000000003F; _GPR[22].DW=0x000000000000003F;
break; break;
case 2: case 2:
GPR[1].DW=0x0000000000000001; _GPR[1].DW=0x0000000000000001;
GPR[2].DW=0x000000000EBDA536; _GPR[2].DW=0x000000000EBDA536;
GPR[3].DW=0x000000000EBDA536; _GPR[3].DW=0x000000000EBDA536;
GPR[4].DW=0x000000000000A536; _GPR[4].DW=0x000000000000A536;
GPR[12].DW=0xFFFFFFFFED10D0B3; _GPR[12].DW=0xFFFFFFFFED10D0B3;
GPR[13].DW=0x000000001402A4CC; _GPR[13].DW=0x000000001402A4CC;
GPR[15].DW=0x000000003103E121; _GPR[15].DW=0x000000003103E121;
GPR[22].DW=0x000000000000003F; _GPR[22].DW=0x000000000000003F;
GPR[25].DW=0xFFFFFFFF9DEBB54F; _GPR[25].DW=0xFFFFFFFF9DEBB54F;
break; break;
case 3: case 3:
GPR[1].DW=0x0000000000000001; _GPR[1].DW=0x0000000000000001;
GPR[2].DW=0x0000000049A5EE96; _GPR[2].DW=0x0000000049A5EE96;
GPR[3].DW=0x0000000049A5EE96; _GPR[3].DW=0x0000000049A5EE96;
GPR[4].DW=0x000000000000EE96; _GPR[4].DW=0x000000000000EE96;
GPR[12].DW=0xFFFFFFFFCE9DFBF7; _GPR[12].DW=0xFFFFFFFFCE9DFBF7;
GPR[13].DW=0xFFFFFFFFCE9DFBF7; _GPR[13].DW=0xFFFFFFFFCE9DFBF7;
GPR[15].DW=0x0000000018B63D28; _GPR[15].DW=0x0000000018B63D28;
GPR[22].DW=0x0000000000000078; _GPR[22].DW=0x0000000000000078;
GPR[25].DW=0xFFFFFFFF825B21C9; _GPR[25].DW=0xFFFFFFFF825B21C9;
break; break;
case 5: case 5:
*(DWORD *)&IMEM[0x00] = 0x3C0DBFC0; *(DWORD *)&IMEM[0x00] = 0x3C0DBFC0;
@ -465,33 +465,33 @@ void InitalizeR4300iRegisters (int UsePif, int Country, int CIC_Chip) {
*(DWORD *)&IMEM[0x14] = 0x3C0DBFC0; *(DWORD *)&IMEM[0x14] = 0x3C0DBFC0;
*(DWORD *)&IMEM[0x18] = 0x8DA80024; *(DWORD *)&IMEM[0x18] = 0x8DA80024;
*(DWORD *)&IMEM[0x1C] = 0x3C0BB000; *(DWORD *)&IMEM[0x1C] = 0x3C0BB000;
GPR[1].DW=0x0000000000000000; _GPR[1].DW=0x0000000000000000;
GPR[2].DW=0xFFFFFFFFF58B0FBF; _GPR[2].DW=0xFFFFFFFFF58B0FBF;
GPR[3].DW=0xFFFFFFFFF58B0FBF; _GPR[3].DW=0xFFFFFFFFF58B0FBF;
GPR[4].DW=0x0000000000000FBF; _GPR[4].DW=0x0000000000000FBF;
GPR[12].DW=0xFFFFFFFF9651F81E; _GPR[12].DW=0xFFFFFFFF9651F81E;
GPR[13].DW=0x000000002D42AAC5; _GPR[13].DW=0x000000002D42AAC5;
GPR[15].DW=0x0000000056584D60; _GPR[15].DW=0x0000000056584D60;
GPR[22].DW=0x0000000000000091; _GPR[22].DW=0x0000000000000091;
GPR[25].DW=0xFFFFFFFFCDCE565F; _GPR[25].DW=0xFFFFFFFFCDCE565F;
break; break;
case 6: case 6:
GPR[1].DW=0x0000000000000000; _GPR[1].DW=0x0000000000000000;
GPR[2].DW=0xFFFFFFFFA95930A4; _GPR[2].DW=0xFFFFFFFFA95930A4;
GPR[3].DW=0xFFFFFFFFA95930A4; _GPR[3].DW=0xFFFFFFFFA95930A4;
GPR[4].DW=0x00000000000030A4; _GPR[4].DW=0x00000000000030A4;
GPR[12].DW=0xFFFFFFFFBCB59510; _GPR[12].DW=0xFFFFFFFFBCB59510;
GPR[13].DW=0xFFFFFFFFBCB59510; _GPR[13].DW=0xFFFFFFFFBCB59510;
GPR[15].DW=0x000000007A3C07F4; _GPR[15].DW=0x000000007A3C07F4;
GPR[22].DW=0x0000000000000085; _GPR[22].DW=0x0000000000000085;
GPR[25].DW=0x00000000465E3F72; _GPR[25].DW=0x00000000465E3F72;
break; break;
} }
} }
#ifdef Interpreter_StackTest #ifdef Interpreter_StackTest
StackValue = GPR[29].W[0]; StackValue = _GPR[29].W[0];
#endif #endif
MemoryStack = (DWORD)(N64MEM+(GPR[29].W[0] & 0x1FFFFFFF)); MemoryStack = (DWORD)(N64MEM+(_GPR[29].W[0] & 0x1FFFFFFF));
} }
#endif #endif
@ -604,23 +604,23 @@ void Load_FPR_ToTop (CBlockSection * Section, int Reg, int RegToLoad, CRegInfo::
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
switch (Format) { switch (Format) {
case CRegInfo::FPU_Dword: case CRegInfo::FPU_Dword:
sprintf(Name,"FPRFloatLocation[%d]",RegToLoad); sprintf(Name,"_FPRFloatLocation[%d]",RegToLoad);
MoveVariableToX86reg(&FPRFloatLocation[RegToLoad],Name,TempReg); MoveVariableToX86reg(&_FPRFloatLocation[RegToLoad],Name,TempReg);
fpuLoadIntegerDwordFromX86Reg(&Section->StackTopPos(),TempReg); fpuLoadIntegerDwordFromX86Reg(&Section->StackTopPos(),TempReg);
break; break;
case CRegInfo::FPU_Qword: case CRegInfo::FPU_Qword:
sprintf(Name,"FPRDoubleLocation[%d]",RegToLoad); sprintf(Name,"_FPRDoubleLocation[%d]",RegToLoad);
MoveVariableToX86reg(&FPRDoubleLocation[RegToLoad],Name,TempReg); MoveVariableToX86reg(&_FPRDoubleLocation[RegToLoad],Name,TempReg);
fpuLoadIntegerQwordFromX86Reg(&Section->StackTopPos(),TempReg); fpuLoadIntegerQwordFromX86Reg(&Section->StackTopPos(),TempReg);
break; break;
case CRegInfo::FPU_Float: case CRegInfo::FPU_Float:
sprintf(Name,"FPRFloatLocation[%d]",RegToLoad); sprintf(Name,"_FPRFloatLocation[%d]",RegToLoad);
MoveVariableToX86reg(&FPRFloatLocation[RegToLoad],Name,TempReg); MoveVariableToX86reg(&_FPRFloatLocation[RegToLoad],Name,TempReg);
fpuLoadDwordFromX86Reg(&Section->StackTopPos(),TempReg); fpuLoadDwordFromX86Reg(&Section->StackTopPos(),TempReg);
break; break;
case CRegInfo::FPU_Double: case CRegInfo::FPU_Double:
sprintf(Name,"FPRDoubleLocation[%d]",RegToLoad); sprintf(Name,"_FPRDoubleLocation[%d]",RegToLoad);
MoveVariableToX86reg(&FPRDoubleLocation[RegToLoad],Name,TempReg); MoveVariableToX86reg(&_FPRDoubleLocation[RegToLoad],Name,TempReg);
fpuLoadQwordFromX86Reg(&Section->StackTopPos(),TempReg); fpuLoadQwordFromX86Reg(&Section->StackTopPos(),TempReg);
break; break;
#ifndef EXTERNAL_RELEASE #ifndef EXTERNAL_RELEASE
@ -676,7 +676,7 @@ void Map_GPR_32bit (CBlockSection * Section, int Reg, BOOL SignValue, int MipsRe
if (MipsRegToLoad > 0) { if (MipsRegToLoad > 0) {
if (Section->IsUnknown(MipsRegToLoad)) { if (Section->IsUnknown(MipsRegToLoad)) {
MoveVariableToX86reg(&GPR[MipsRegToLoad].UW[0],GPR_NameLo[MipsRegToLoad],x86Reg); MoveVariableToX86reg(&_GPR[MipsRegToLoad].UW[0],GPR_NameLo[MipsRegToLoad],x86Reg);
} else if (Section->IsMapped(MipsRegToLoad)) { } else if (Section->IsMapped(MipsRegToLoad)) {
if (Reg != MipsRegToLoad) { if (Reg != MipsRegToLoad) {
MoveX86RegToX86Reg(Section->MipsRegLo(MipsRegToLoad),x86Reg); MoveX86RegToX86Reg(Section->MipsRegLo(MipsRegToLoad),x86Reg);
@ -739,8 +739,8 @@ void Map_GPR_64bit (CBlockSection * Section, int Reg, int MipsRegToLoad) {
Section->x86MapOrder(x86lo) = 1; Section->x86MapOrder(x86lo) = 1;
if (MipsRegToLoad > 0) { if (MipsRegToLoad > 0) {
if (Section->IsUnknown(MipsRegToLoad)) { if (Section->IsUnknown(MipsRegToLoad)) {
MoveVariableToX86reg(&GPR[MipsRegToLoad].UW[1],GPR_NameHi[MipsRegToLoad],x86Hi); MoveVariableToX86reg(&_GPR[MipsRegToLoad].UW[1],GPR_NameHi[MipsRegToLoad],x86Hi);
MoveVariableToX86reg(&GPR[MipsRegToLoad].UW[0],GPR_NameLo[MipsRegToLoad],x86lo); MoveVariableToX86reg(&_GPR[MipsRegToLoad].UW[0],GPR_NameLo[MipsRegToLoad],x86lo);
} else if (Section->IsMapped(MipsRegToLoad)) { } else if (Section->IsMapped(MipsRegToLoad)) {
if (Section->Is32Bit(MipsRegToLoad)) { if (Section->Is32Bit(MipsRegToLoad)) {
if (Section->IsSigned(MipsRegToLoad)) { if (Section->IsSigned(MipsRegToLoad)) {
@ -816,6 +816,8 @@ int Map_MemoryStack (CBlockSection * Section, int Reg, bool MapRegister)
return CurrentMap; return CurrentMap;
} }
// map a register // map a register
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
if (Reg == x86_Any) if (Reg == x86_Any)
{ {
if (CurrentMap > 0) if (CurrentMap > 0)
@ -848,6 +850,7 @@ int Map_MemoryStack (CBlockSection * Section, int Reg, bool MapRegister)
CPU_Message(" regcache: allocate %s as Memory Stack",x86_Name(Reg)); CPU_Message(" regcache: allocate %s as Memory Stack",x86_Name(Reg));
MoveVariableToX86reg(g_MemoryStack,"MemoryStack",Reg); MoveVariableToX86reg(g_MemoryStack,"MemoryStack",Reg);
} }
#endif
return Reg; return Reg;
} }
@ -945,7 +948,7 @@ int Map_TempReg (CBlockSection * Section, int x86Reg, int MipsReg, BOOL LoadHiWo
if (MipsReg >= 0) { if (MipsReg >= 0) {
if (LoadHiWord) { if (LoadHiWord) {
if (Section->IsUnknown(MipsReg)) { if (Section->IsUnknown(MipsReg)) {
MoveVariableToX86reg(&GPR[MipsReg].UW[1],GPR_NameHi[MipsReg],x86Reg); MoveVariableToX86reg(&_GPR[MipsReg].UW[1],GPR_NameHi[MipsReg],x86Reg);
} else if (Section->IsMapped(MipsReg)) { } else if (Section->IsMapped(MipsReg)) {
if (Section->Is64Bit(MipsReg)) { if (Section->Is64Bit(MipsReg)) {
MoveX86RegToX86Reg(Section->MipsRegHi(MipsReg),x86Reg); MoveX86RegToX86Reg(Section->MipsRegHi(MipsReg),x86Reg);
@ -972,7 +975,7 @@ int Map_TempReg (CBlockSection * Section, int x86Reg, int MipsReg, BOOL LoadHiWo
} }
} else { } else {
if (Section->IsUnknown(MipsReg)) { if (Section->IsUnknown(MipsReg)) {
MoveVariableToX86reg(&GPR[MipsReg].UW[0],GPR_NameLo[MipsReg],x86Reg); MoveVariableToX86reg(&_GPR[MipsReg].UW[0],GPR_NameLo[MipsReg],x86Reg);
} else if (Section->IsMapped(MipsReg)) { } else if (Section->IsMapped(MipsReg)) {
MoveX86RegToX86Reg(Section->MipsRegLo(MipsReg),x86Reg); MoveX86RegToX86Reg(Section->MipsRegLo(MipsReg),x86Reg);
} else { } else {
@ -1024,15 +1027,15 @@ void SetFpuLocations (void) {
if ((STATUS_REGISTER & STATUS_FR) == 0) { if ((STATUS_REGISTER & STATUS_FR) == 0) {
for (count = 0; count < 32; count ++) { for (count = 0; count < 32; count ++) {
FPRFloatLocation[count] = (void *)(&FPR[count >> 1].W[count & 1]); _FPRFloatLocation[count] = (void *)(&FPR[count >> 1].W[count & 1]);
//FPRDoubleLocation[count] = FPRFloatLocation[count]; //_FPRDoubleLocation[count] = _FPRFloatLocation[count];
FPRDoubleLocation[count] = (void *)(&FPR[count >> 1].DW); _FPRDoubleLocation[count] = (void *)(&FPR[count >> 1].DW);
} }
} else { } else {
for (count = 0; count < 32; count ++) { for (count = 0; count < 32; count ++) {
FPRFloatLocation[count] = (void *)(&FPR[count].W[1]); _FPRFloatLocation[count] = (void *)(&FPR[count].W[1]);
//FPRDoubleLocation[count] = FPRFloatLocation[count]; //_FPRDoubleLocation[count] = _FPRFloatLocation[count];
FPRDoubleLocation[count] = (void *)(&FPR[count].DW); _FPRDoubleLocation[count] = (void *)(&FPR[count].DW);
} }
} }
} }
@ -1042,7 +1045,7 @@ void SetupRegisters(N64_REGISTERS * n64_Registers) {
HI.DW = n64_Registers->HI.DW; HI.DW = n64_Registers->HI.DW;
LO.DW = n64_Registers->LO.DW; LO.DW = n64_Registers->LO.DW;
CP0 = n64_Registers->CP0; CP0 = n64_Registers->CP0;
GPR = n64_Registers->GPR; _GPR = n64_Registers->_GPR;
FPR = n64_Registers->FPR; FPR = n64_Registers->FPR;
FPCR = n64_Registers->FPCR; FPCR = n64_Registers->FPCR;
RegRDRAM = n64_Registers->RDRAM; RegRDRAM = n64_Registers->RDRAM;
@ -1167,23 +1170,23 @@ void UnMap_FPR (CBlockSection * Section, int Reg, int WriteBackValue ) {
TempReg = Map_TempReg(Section,x86_Any,-1,FALSE); TempReg = Map_TempReg(Section,x86_Any,-1,FALSE);
switch (Section->FpuState(Section->StackTopPos())) { switch (Section->FpuState(Section->StackTopPos())) {
case CRegInfo::FPU_Dword: case CRegInfo::FPU_Dword:
sprintf(Name,"FPRFloatLocation[%d]",Section->FpuMappedTo(Section->StackTopPos())); sprintf(Name,"_FPRFloatLocation[%d]",Section->FpuMappedTo(Section->StackTopPos()));
MoveVariableToX86reg(&FPRFloatLocation[Section->FpuMappedTo(Section->StackTopPos())],Name,TempReg); MoveVariableToX86reg(&_FPRFloatLocation[Section->FpuMappedTo(Section->StackTopPos())],Name,TempReg);
fpuStoreIntegerDwordFromX86Reg(&Section->StackTopPos(),TempReg, TRUE); fpuStoreIntegerDwordFromX86Reg(&Section->StackTopPos(),TempReg, TRUE);
break; break;
case CRegInfo::FPU_Qword: case CRegInfo::FPU_Qword:
sprintf(Name,"FPRDoubleLocation[%d]",Section->FpuMappedTo(Section->StackTopPos())); sprintf(Name,"_FPRDoubleLocation[%d]",Section->FpuMappedTo(Section->StackTopPos()));
MoveVariableToX86reg(&FPRDoubleLocation[Section->FpuMappedTo(Section->StackTopPos())],Name,TempReg); MoveVariableToX86reg(&_FPRDoubleLocation[Section->FpuMappedTo(Section->StackTopPos())],Name,TempReg);
fpuStoreIntegerQwordFromX86Reg(&Section->StackTopPos(),TempReg, TRUE); fpuStoreIntegerQwordFromX86Reg(&Section->StackTopPos(),TempReg, TRUE);
break; break;
case CRegInfo::FPU_Float: case CRegInfo::FPU_Float:
sprintf(Name,"FPRFloatLocation[%d]",Section->FpuMappedTo(Section->StackTopPos())); sprintf(Name,"_FPRFloatLocation[%d]",Section->FpuMappedTo(Section->StackTopPos()));
MoveVariableToX86reg(&FPRFloatLocation[Section->FpuMappedTo(Section->StackTopPos())],Name,TempReg); MoveVariableToX86reg(&_FPRFloatLocation[Section->FpuMappedTo(Section->StackTopPos())],Name,TempReg);
fpuStoreDwordFromX86Reg(&Section->StackTopPos(),TempReg, TRUE); fpuStoreDwordFromX86Reg(&Section->StackTopPos(),TempReg, TRUE);
break; break;
case CRegInfo::FPU_Double: case CRegInfo::FPU_Double:
sprintf(Name,"FPRDoubleLocation[%d]",Section->FpuMappedTo(Section->StackTopPos())); sprintf(Name,"_FPRDoubleLocation[%d]",Section->FpuMappedTo(Section->StackTopPos()));
MoveVariableToX86reg(&FPRDoubleLocation[Section->FpuMappedTo(Section->StackTopPos())],Name,TempReg); MoveVariableToX86reg(&_FPRDoubleLocation[Section->FpuMappedTo(Section->StackTopPos())],Name,TempReg);
fpuStoreQwordFromX86Reg(&Section->StackTopPos(),TempReg, TRUE); fpuStoreQwordFromX86Reg(&Section->StackTopPos(),TempReg, TRUE);
break; break;
#ifndef EXTERNAL_RELEASE #ifndef EXTERNAL_RELEASE
@ -1221,17 +1224,17 @@ void UnMap_GPR (CBlockSection * Section, DWORD Reg, int WriteBackValue) {
return; return;
} }
if (Section->Is64Bit(Reg)) { if (Section->Is64Bit(Reg)) {
MoveConstToVariable(Section->MipsRegHi(Reg),&GPR[Reg].UW[1],GPR_NameHi[Reg]); MoveConstToVariable(Section->MipsRegHi(Reg),&_GPR[Reg].UW[1],GPR_NameHi[Reg]);
MoveConstToVariable(Section->MipsRegLo(Reg),&GPR[Reg].UW[0],GPR_NameLo[Reg]); MoveConstToVariable(Section->MipsRegLo(Reg),&_GPR[Reg].UW[0],GPR_NameLo[Reg]);
Section->MipsRegState(Reg) = CRegInfo::STATE_UNKNOWN; Section->MipsRegState(Reg) = CRegInfo::STATE_UNKNOWN;
return; return;
} }
if ((Section->MipsRegLo(Reg) & 0x80000000) != 0) { if ((Section->MipsRegLo(Reg) & 0x80000000) != 0) {
MoveConstToVariable(0xFFFFFFFF,&GPR[Reg].UW[1],GPR_NameHi[Reg]); MoveConstToVariable(0xFFFFFFFF,&_GPR[Reg].UW[1],GPR_NameHi[Reg]);
} else { } else {
MoveConstToVariable(0,&GPR[Reg].UW[1],GPR_NameHi[Reg]); MoveConstToVariable(0,&_GPR[Reg].UW[1],GPR_NameHi[Reg]);
} }
MoveConstToVariable(Section->MipsRegLo(Reg),&GPR[Reg].UW[0],GPR_NameLo[Reg]); MoveConstToVariable(Section->MipsRegLo(Reg),&_GPR[Reg].UW[0],GPR_NameLo[Reg]);
Section->MipsRegState(Reg) = CRegInfo::STATE_UNKNOWN; Section->MipsRegState(Reg) = CRegInfo::STATE_UNKNOWN;
return; return;
} }
@ -1247,15 +1250,15 @@ void UnMap_GPR (CBlockSection * Section, DWORD Reg, int WriteBackValue) {
Section->MipsRegState(Reg) = CRegInfo::STATE_UNKNOWN; Section->MipsRegState(Reg) = CRegInfo::STATE_UNKNOWN;
return; return;
} }
MoveX86regToVariable(Section->MipsRegLo(Reg),&GPR[Reg].UW[0],GPR_NameLo[Reg]); MoveX86regToVariable(Section->MipsRegLo(Reg),&_GPR[Reg].UW[0],GPR_NameLo[Reg]);
if (Section->Is64Bit(Reg)) { if (Section->Is64Bit(Reg)) {
MoveX86regToVariable(Section->MipsRegHi(Reg),&GPR[Reg].UW[1],GPR_NameHi[Reg]); MoveX86regToVariable(Section->MipsRegHi(Reg),&_GPR[Reg].UW[1],GPR_NameHi[Reg]);
} else { } else {
if (Section->IsSigned(Reg)) { if (Section->IsSigned(Reg)) {
ShiftRightSignImmed(Section->MipsRegLo(Reg),31); ShiftRightSignImmed(Section->MipsRegLo(Reg),31);
MoveX86regToVariable(Section->MipsRegLo(Reg),&GPR[Reg].UW[1],GPR_NameHi[Reg]); MoveX86regToVariable(Section->MipsRegLo(Reg),&_GPR[Reg].UW[1],GPR_NameHi[Reg]);
} else { } else {
MoveConstToVariable(0,&GPR[Reg].UW[1],GPR_NameHi[Reg]); MoveConstToVariable(0,&_GPR[Reg].UW[1],GPR_NameHi[Reg]);
} }
} }
Section->MipsRegState(Reg) = CRegInfo::STATE_UNKNOWN; Section->MipsRegState(Reg) = CRegInfo::STATE_UNKNOWN;
@ -1308,12 +1311,15 @@ BOOL UnMap_X86reg (CBlockSection * Section, DWORD x86Reg) {
} }
} }
} }
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
if (Section->x86Mapped(x86Reg) == CRegInfo::Stack_Mapped) { if (Section->x86Mapped(x86Reg) == CRegInfo::Stack_Mapped) {
CPU_Message(" regcache: unallocate %s from Memory Stack",x86_Name(x86Reg)); CPU_Message(" regcache: unallocate %s from Memory Stack",x86_Name(x86Reg));
MoveX86regToVariable(x86Reg,g_MemoryStack,"MemoryStack"); MoveX86regToVariable(x86Reg,g_MemoryStack,"MemoryStack");
Section->x86Mapped(x86Reg) = CRegInfo::NotMapped; Section->x86Mapped(x86Reg) = CRegInfo::NotMapped;
return TRUE; return TRUE;
} }
#endif
return FALSE; return FALSE;
} }
@ -1336,11 +1342,11 @@ void UnProtectGPR(CBlockSection * Section, DWORD Reg) {
case CRegInfo::STATE_UNKNOWN: break; case CRegInfo::STATE_UNKNOWN: break;
case STATE_CONST_32: case STATE_CONST_32:
if ((Section->MipsRegLo(count) & 0x80000000) != 0) { if ((Section->MipsRegLo(count) & 0x80000000) != 0) {
MoveConstToVariable(0xFFFFFFFF,&GPR[count].UW[1],GPR_NameHi[count]); MoveConstToVariable(0xFFFFFFFF,&_GPR[count].UW[1],GPR_NameHi[count]);
} else { } else {
MoveConstToVariable(0,&GPR[count].UW[1],GPR_NameHi[count]); MoveConstToVariable(0,&_GPR[count].UW[1],GPR_NameHi[count]);
} }
MoveConstToVariable(Section->MipsRegLo(count),&GPR[count].UW[0],GPR_NameLo[count]); MoveConstToVariable(Section->MipsRegLo(count),&_GPR[count].UW[0],GPR_NameLo[count]);
Section->MipsRegState(count) = CRegInfo::STATE_UNKNOWN; Section->MipsRegState(count) = CRegInfo::STATE_UNKNOWN;
break; break;
default: default:
@ -1376,17 +1382,17 @@ void WriteBackRegisters (CBlockSection * Section) {
} }
if ((Section->MipsRegLo(count) & 0x80000000) != 0) { if ((Section->MipsRegLo(count) & 0x80000000) != 0) {
MoveX86regToVariable(x86_ESI,&GPR[count].UW[1],GPR_NameHi[count]); MoveX86regToVariable(x86_ESI,&_GPR[count].UW[1],GPR_NameHi[count]);
} else { } else {
MoveX86regToVariable(x86_EDI,&GPR[count].UW[1],GPR_NameHi[count]); MoveX86regToVariable(x86_EDI,&_GPR[count].UW[1],GPR_NameHi[count]);
} }
if (Section->MipsRegLo(count) == 0) { if (Section->MipsRegLo(count) == 0) {
MoveX86regToVariable(x86_EDI,&GPR[count].UW[0],GPR_NameLo[count]); MoveX86regToVariable(x86_EDI,&_GPR[count].UW[0],GPR_NameLo[count]);
} else if (Section->MipsRegLo(count) == 0xFFFFFFFF) { } else if (Section->MipsRegLo(count) == 0xFFFFFFFF) {
MoveX86regToVariable(x86_ESI,&GPR[count].UW[0],GPR_NameLo[count]); MoveX86regToVariable(x86_ESI,&_GPR[count].UW[0],GPR_NameLo[count]);
} else } else
MoveConstToVariable(Section->MipsRegLo(count),&GPR[count].UW[0],GPR_NameLo[count]); MoveConstToVariable(Section->MipsRegLo(count),&_GPR[count].UW[0],GPR_NameLo[count]);
Section->MipsRegState(count) = CRegInfo::STATE_UNKNOWN; Section->MipsRegState(count) = CRegInfo::STATE_UNKNOWN;
break; break;
@ -1401,19 +1407,19 @@ void WriteBackRegisters (CBlockSection * Section) {
} }
if (Section->MipsRegHi(count) == 0) { if (Section->MipsRegHi(count) == 0) {
MoveX86regToVariable(x86_EDI,&GPR[count].UW[1],GPR_NameHi[count]); MoveX86regToVariable(x86_EDI,&_GPR[count].UW[1],GPR_NameHi[count]);
} else if (Section->MipsRegLo(count) == 0xFFFFFFFF) { } else if (Section->MipsRegLo(count) == 0xFFFFFFFF) {
MoveX86regToVariable(x86_ESI,&GPR[count].UW[1],GPR_NameHi[count]); MoveX86regToVariable(x86_ESI,&_GPR[count].UW[1],GPR_NameHi[count]);
} else { } else {
MoveConstToVariable(Section->MipsRegHi(count),&GPR[count].UW[1],GPR_NameHi[count]); MoveConstToVariable(Section->MipsRegHi(count),&_GPR[count].UW[1],GPR_NameHi[count]);
} }
if (Section->MipsRegLo(count) == 0) { if (Section->MipsRegLo(count) == 0) {
MoveX86regToVariable(x86_EDI,&GPR[count].UW[0],GPR_NameLo[count]); MoveX86regToVariable(x86_EDI,&_GPR[count].UW[0],GPR_NameLo[count]);
} else if (Section->MipsRegLo(count) == 0xFFFFFFFF) { } else if (Section->MipsRegLo(count) == 0xFFFFFFFF) {
MoveX86regToVariable(x86_ESI,&GPR[count].UW[0],GPR_NameLo[count]); MoveX86regToVariable(x86_ESI,&_GPR[count].UW[0],GPR_NameLo[count]);
} else { } else {
MoveConstToVariable(Section->MipsRegLo(count),&GPR[count].UW[0],GPR_NameLo[count]); MoveConstToVariable(Section->MipsRegLo(count),&_GPR[count].UW[0],GPR_NameLo[count]);
} }
Section->MipsRegState(count) = CRegInfo::STATE_UNKNOWN; Section->MipsRegState(count) = CRegInfo::STATE_UNKNOWN;
break; break;

View File

@ -24,311 +24,156 @@
* *
*/ */
#define INDEX_REGISTER CP0[0]
#define RANDOM_REGISTER CP0[1] #define INDEX_REGISTER _CP0[0]
#define ENTRYLO0_REGISTER CP0[2] #define RANDOM_REGISTER _CP0[1]
#define ENTRYLO1_REGISTER CP0[3] #define ENTRYLO0_REGISTER _CP0[2]
#define CONTEXT_REGISTER CP0[4] #define ENTRYLO1_REGISTER _CP0[3]
#define PAGE_MASK_REGISTER CP0[5] #define CONTEXT_REGISTER _CP0[4]
#define WIRED_REGISTER CP0[6] #define PAGE_MASK_REGISTER _CP0[5]
#define BAD_VADDR_REGISTER CP0[8] #define WIRED_REGISTER _CP0[6]
#define COUNT_REGISTER CP0[9] #define BAD_VADDR_REGISTER _CP0[8]
#define ENTRYHI_REGISTER CP0[10] #define COUNT_REGISTER _CP0[9]
#define COMPARE_REGISTER CP0[11] #define ENTRYHI_REGISTER _CP0[10]
#define STATUS_REGISTER CP0[12] #define COMPARE_REGISTER _CP0[11]
#define CAUSE_REGISTER CP0[13] #define STATUS_REGISTER _CP0[12]
#define EPC_REGISTER CP0[14] #define CAUSE_REGISTER _CP0[13]
#define CONFIG_REGISTER CP0[16] #define EPC_REGISTER _CP0[14]
#define TAGLO_REGISTER CP0[28] #define CONFIG_REGISTER _CP0[16]
#define TAGHI_REGISTER CP0[29] #define TAGLO_REGISTER _CP0[28]
#define ERROREPC_REGISTER CP0[30] #define TAGHI_REGISTER _CP0[29]
#define FAKE_CAUSE_REGISTER CP0[32] #define ERROREPC_REGISTER _CP0[30]
#define FAKE_CAUSE_REGISTER _CP0[32]
#define COMPARE_REGISTER_NO 11 #define COMPARE_REGISTER_NO 11
#define STATUS_REGISTER_NO 12 #define STATUS_REGISTER_NO 12
#define CAUSE_REGISTER_NO 13 #define CAUSE_REGISTER_NO 13
#define REVISION_REGISTER FPCR[0] #define REVISION_REGISTER _FPCR[0]
#define FSTATUS_REGISTER FPCR[31] #define FSTATUS_REGISTER _FPCR[31]
#define GPR_S0 GPR[16] #define GPR_S0 _GPR[16]
#define GPR_S1 GPR[17] #define GPR_S1 _GPR[17]
#define GPR_S2 GPR[18] #define GPR_S2 _GPR[18]
#define GPR_S3 GPR[19] #define GPR_S3 _GPR[19]
#define GPR_S4 GPR[20] #define GPR_S4 _GPR[20]
#define GPR_S5 GPR[21] #define GPR_S5 _GPR[21]
#define GPR_S6 GPR[22] #define GPR_S6 _GPR[22]
#define GPR_S7 GPR[23] #define GPR_S7 _GPR[23]
#define GPR_SP GPR[29] #define GPR_SP _GPR[29]
#define GPR_RA GPR[31] #define GPR_RA _GPR[31]
#define RDRAM_CONFIG_REG RegRDRAM[0] #define RDRAM_CONFIG_REG _RegRDRAM[0]
#define RDRAM_DEVICE_TYPE_REG RegRDRAM[0] #define RDRAM_DEVICE_TYPE_REG _RegRDRAM[0]
#define RDRAM_DEVICE_ID_REG RegRDRAM[1] #define RDRAM_DEVICE_ID_REG _RegRDRAM[1]
#define RDRAM_DELAY_REG RegRDRAM[2] #define RDRAM_DELAY_REG _RegRDRAM[2]
#define RDRAM_MODE_REG RegRDRAM[3] #define RDRAM_MODE_REG _RegRDRAM[3]
#define RDRAM_REF_INTERVAL_REG RegRDRAM[4] #define RDRAM_REF_INTERVAL_REG _RegRDRAM[4]
#define RDRAM_REF_ROW_REG RegRDRAM[5] #define RDRAM_REF_ROW_REG _RegRDRAM[5]
#define RDRAM_RAS_INTERVAL_REG RegRDRAM[6] #define RDRAM_RAS_INTERVAL_REG _RegRDRAM[6]
#define RDRAM_MIN_INTERVAL_REG RegRDRAM[7] #define RDRAM_MIN_INTERVAL_REG _RegRDRAM[7]
#define RDRAM_ADDR_SELECT_REG RegRDRAM[8] #define RDRAM_ADDR_SELECT_REG _RegRDRAM[8]
#define RDRAM_DEVICE_MANUF_REG RegRDRAM[9] #define RDRAM_DEVICE_MANUF_REG _RegRDRAM[9]
#define SP_MEM_ADDR_REG RegSP[0] #define SP_MEM_ADDR_REG _RegSP[0]
#define SP_DRAM_ADDR_REG RegSP[1] #define SP_DRAM_ADDR_REG _RegSP[1]
#define SP_RD_LEN_REG RegSP[2] #define SP_RD_LEN_REG _RegSP[2]
#define SP_WR_LEN_REG RegSP[3] #define SP_WR_LEN_REG _RegSP[3]
#define SP_STATUS_REG RegSP[4] #define SP_STATUS_REG _RegSP[4]
#define SP_DMA_FULL_REG RegSP[5] #define SP_DMA_FULL_REG _RegSP[5]
#define SP_DMA_BUSY_REG RegSP[6] #define SP_DMA_BUSY_REG _RegSP[6]
#define SP_SEMAPHORE_REG RegSP[7] #define SP_SEMAPHORE_REG _RegSP[7]
#define SP_PC_REG RegSP[8] #define SP_PC_REG _RegSP[8]
#define SP_IBIST_REG RegSP[9] #define SP_IBIST_REG _RegSP[9]
#define DPC_START_REG RegDPC[0] #define DPC_START_REG _RegDPC[0]
#define DPC_END_REG RegDPC[1] #define DPC_END_REG _RegDPC[1]
#define DPC_CURRENT_REG RegDPC[2] #define DPC_CURRENT_REG _RegDPC[2]
#define DPC_STATUS_REG RegDPC[3] #define DPC_STATUS_REG _RegDPC[3]
#define DPC_CLOCK_REG RegDPC[4] #define DPC_CLOCK_REG _RegDPC[4]
#define DPC_BUFBUSY_REG RegDPC[5] #define DPC_BUFBUSY_REG _RegDPC[5]
#define DPC_PIPEBUSY_REG RegDPC[6] #define DPC_PIPEBUSY_REG _RegDPC[6]
#define DPC_TMEM_REG RegDPC[7] #define DPC_TMEM_REG _RegDPC[7]
#define MI_INIT_MODE_REG RegMI[0] #define MI_INIT_MODE_REG _RegMI[0]
#define MI_MODE_REG RegMI[0] #define MI_MODE_REG _RegMI[0]
#define MI_VERSION_REG RegMI[1] #define MI_VERSION_REG _RegMI[1]
#define MI_NOOP_REG RegMI[1] #define MI_NOOP_REG _RegMI[1]
#define MI_INTR_REG RegMI[2] #define MI_INTR_REG _RegMI[2]
#define MI_INTR_MASK_REG RegMI[3] #define MI_INTR_MASK_REG _RegMI[3]
#define VI_STATUS_REG RegVI[0] #define VI_STATUS_REG _RegVI[0]
#define VI_CONTROL_REG RegVI[0] #define VI_CONTROL_REG _RegVI[0]
#define VI_ORIGIN_REG RegVI[1] #define VI_ORIGIN_REG _RegVI[1]
#define VI_DRAM_ADDR_REG RegVI[1] #define VI_DRAM_ADDR_REG _RegVI[1]
#define VI_WIDTH_REG RegVI[2] #define VI_WIDTH_REG _RegVI[2]
#define VI_H_WIDTH_REG RegVI[2] #define VI_H_WIDTH_REG _RegVI[2]
#define VI_INTR_REG RegVI[3] #define VI_INTR_REG _RegVI[3]
#define VI_V_INTR_REG RegVI[3] #define VI_V_INTR_REG _RegVI[3]
#define VI_CURRENT_REG RegVI[4] #define VI_CURRENT_REG _RegVI[4]
#define VI_V_CURRENT_LINE_REG RegVI[4] #define VI_V_CURRENT_LINE_REG _RegVI[4]
#define VI_BURST_REG RegVI[5] #define VI_BURST_REG _RegVI[5]
#define VI_TIMING_REG RegVI[5] #define VI_TIMING_REG _RegVI[5]
#define VI_V_SYNC_REG RegVI[6] #define VI_V_SYNC_REG _RegVI[6]
#define VI_H_SYNC_REG RegVI[7] #define VI_H_SYNC_REG _RegVI[7]
#define VI_LEAP_REG RegVI[8] #define VI_LEAP_REG _RegVI[8]
#define VI_H_SYNC_LEAP_REG RegVI[8] #define VI_H_SYNC_LEAP_REG _RegVI[8]
#define VI_H_START_REG RegVI[9] #define VI_H_START_REG _RegVI[9]
#define VI_H_VIDEO_REG RegVI[9] #define VI_H_VIDEO_REG _RegVI[9]
#define VI_V_START_REG RegVI[10] #define VI_V_START_REG _RegVI[10]
#define VI_V_VIDEO_REG RegVI[10] #define VI_V_VIDEO_REG _RegVI[10]
#define VI_V_BURST_REG RegVI[11] #define VI_V_BURST_REG _RegVI[11]
#define VI_X_SCALE_REG RegVI[12] #define VI_X_SCALE_REG _RegVI[12]
#define VI_Y_SCALE_REG RegVI[13] #define VI_Y_SCALE_REG _RegVI[13]
#define AI_DRAM_ADDR_REG RegAI[0] #define AI_DRAM_ADDR_REG _RegAI[0]
#define AI_LEN_REG RegAI[1] #define AI_LEN_REG _RegAI[1]
#define AI_CONTROL_REG RegAI[2] #define AI_CONTROL_REG _RegAI[2]
#define AI_STATUS_REG RegAI[3] #define AI_STATUS_REG _RegAI[3]
#define AI_DACRATE_REG RegAI[4] #define AI_DACRATE_REG _RegAI[4]
#define AI_BITRATE_REG RegAI[5] #define AI_BITRATE_REG _RegAI[5]
#define PI_DRAM_ADDR_REG RegPI[0] #define PI_DRAM_ADDR_REG _RegPI[0]
#define PI_CART_ADDR_REG RegPI[1] #define PI_CART_ADDR_REG _RegPI[1]
#define PI_RD_LEN_REG RegPI[2] #define PI_RD_LEN_REG _RegPI[2]
#define PI_WR_LEN_REG RegPI[3] #define PI_WR_LEN_REG _RegPI[3]
#define PI_STATUS_REG RegPI[4] #define PI_STATUS_REG _RegPI[4]
#define PI_BSD_DOM1_LAT_REG RegPI[5] #define PI_BSD_DOM1_LAT_REG _RegPI[5]
#define PI_DOMAIN1_REG RegPI[5] #define PI_DOMAIN1_REG _RegPI[5]
#define PI_BSD_DOM1_PWD_REG RegPI[6] #define PI_BSD_DOM1_PWD_REG _RegPI[6]
#define PI_BSD_DOM1_PGS_REG RegPI[7] #define PI_BSD_DOM1_PGS_REG _RegPI[7]
#define PI_BSD_DOM1_RLS_REG RegPI[8] #define PI_BSD_DOM1_RLS_REG _RegPI[8]
#define PI_BSD_DOM2_LAT_REG RegPI[9] #define PI_BSD_DOM2_LAT_REG _RegPI[9]
#define PI_DOMAIN2_REG RegPI[9] #define PI_DOMAIN2_REG _RegPI[9]
#define PI_BSD_DOM2_PWD_REG RegPI[10] #define PI_BSD_DOM2_PWD_REG _RegPI[10]
#define PI_BSD_DOM2_PGS_REG RegPI[11] #define PI_BSD_DOM2_PGS_REG _RegPI[11]
#define PI_BSD_DOM2_RLS_REG RegPI[12] #define PI_BSD_DOM2_RLS_REG _RegPI[12]
#define RI_MODE_REG RegRI[0] #define RI_MODE_REG _RegRI[0]
#define RI_CONFIG_REG RegRI[1] #define RI_CONFIG_REG _RegRI[1]
#define RI_CURRENT_LOAD_REG RegRI[2] #define RI_CURRENT_LOAD_REG _RegRI[2]
#define RI_SELECT_REG RegRI[3] #define RI_SELECT_REG _RegRI[3]
#define RI_COUNT_REG RegRI[4] #define RI_COUNT_REG _RegRI[4]
#define RI_REFRESH_REG RegRI[4] #define RI_REFRESH_REG _RegRI[4]
#define RI_LATENCY_REG RegRI[5] #define RI_LATENCY_REG _RegRI[5]
#define RI_RERROR_REG RegRI[6] #define RI_RERROR_REG _RegRI[6]
#define RI_WERROR_REG RegRI[7] #define RI_WERROR_REG _RegRI[7]
#define SI_DRAM_ADDR_REG RegSI[0] #define SI_DRAM_ADDR_REG _RegSI[0]
#define SI_PIF_ADDR_RD64B_REG RegSI[1] #define SI_PIF_ADDR_RD64B_REG _RegSI[1]
#define SI_PIF_ADDR_WR64B_REG RegSI[2] #define SI_PIF_ADDR_WR64B_REG _RegSI[2]
#define SI_STATUS_REG RegSI[3] #define SI_STATUS_REG _RegSI[3]
#define STATUS_IE 0x00000001 enum
#define STATUS_EXL 0x00000002 {
#define STATUS_ERL 0x00000004
#define STATUS_IP0 0x00000100
#define STATUS_IP1 0x00000200
#define STATUS_IP2 0x00000400
#define STATUS_IP3 0x00000800
#define STATUS_IP4 0x00001000
#define STATUS_IP5 0x00002000
#define STATUS_IP6 0x00004000
#define STATUS_IP7 0x00008000
#define STATUS_BEV 0x00400000
#define STATUS_FR 0x04000000
#define STATUS_CU0 0x10000000
#define STATUS_CU1 0x20000000
#define CAUSE_EXC_CODE 0xFF MI_MODE_INIT = 0x0080, /* Bit 7: init mode */
#define CAUSE_IP0 0x100 MI_MODE_EBUS = 0x0100, /* Bit 8: ebus test mode */
#define CAUSE_IP1 0x200 MI_MODE_RDRAM = 0x0200, /* Bit 9: RDRAM reg mode */
#define CAUSE_IP2 0x400
#define CAUSE_IP3 0x800
#define CAUSE_IP4 0x1000
#define CAUSE_IP5 0x2000
#define CAUSE_IP6 0x4000
#define CAUSE_IP7 0x8000
#define CAUSE_BD 0x80000000
#define SP_CLR_HALT 0x00001 /* Bit 0: clear halt */ };
#define SP_SET_HALT 0x00002 /* Bit 1: set halt */
#define SP_CLR_BROKE 0x00004 /* Bit 2: clear broke */
#define SP_CLR_INTR 0x00008 /* Bit 3: clear intr */
#define SP_SET_INTR 0x00010 /* Bit 4: set intr */
#define SP_CLR_SSTEP 0x00020 /* Bit 5: clear sstep */
#define SP_SET_SSTEP 0x00040 /* Bit 6: set sstep */
#define SP_CLR_INTR_BREAK 0x00080 /* Bit 7: clear intr on break */
#define SP_SET_INTR_BREAK 0x00100 /* Bit 8: set intr on break */
#define SP_CLR_SIG0 0x00200 /* Bit 9: clear signal 0 */
#define SP_SET_SIG0 0x00400 /* Bit 10: set signal 0 */
#define SP_CLR_SIG1 0x00800 /* Bit 11: clear signal 1 */
#define SP_SET_SIG1 0x01000 /* Bit 12: set signal 1 */
#define SP_CLR_SIG2 0x02000 /* Bit 13: clear signal 2 */
#define SP_SET_SIG2 0x04000 /* Bit 14: set signal 2 */
#define SP_CLR_SIG3 0x08000 /* Bit 15: clear signal 3 */
#define SP_SET_SIG3 0x10000 /* Bit 16: set signal 3 */
#define SP_CLR_SIG4 0x20000 /* Bit 17: clear signal 4 */
#define SP_SET_SIG4 0x40000 /* Bit 18: set signal 4 */
#define SP_CLR_SIG5 0x80000 /* Bit 19: clear signal 5 */
#define SP_SET_SIG5 0x100000 /* Bit 20: set signal 5 */
#define SP_CLR_SIG6 0x200000 /* Bit 21: clear signal 6 */
#define SP_SET_SIG6 0x400000 /* Bit 22: set signal 6 */
#define SP_CLR_SIG7 0x800000 /* Bit 23: clear signal 7 */
#define SP_SET_SIG7 0x1000000 /* Bit 24: set signal 7 */
#define SP_STATUS_HALT 0x001 /* Bit 0: halt */
#define SP_STATUS_BROKE 0x002 /* Bit 1: broke */
#define SP_STATUS_DMA_BUSY 0x004 /* Bit 2: dma busy */
#define SP_STATUS_DMA_FULL 0x008 /* Bit 3: dma full */
#define SP_STATUS_IO_FULL 0x010 /* Bit 4: io full */
#define SP_STATUS_SSTEP 0x020 /* Bit 5: single step */
#define SP_STATUS_INTR_BREAK 0x040 /* Bit 6: interrupt on break */
#define SP_STATUS_SIG0 0x080 /* Bit 7: signal 0 set */
#define SP_STATUS_SIG1 0x100 /* Bit 8: signal 1 set */
#define SP_STATUS_SIG2 0x200 /* Bit 9: signal 2 set */
#define SP_STATUS_SIG3 0x400 /* Bit 10: signal 3 set */
#define SP_STATUS_SIG4 0x800 /* Bit 11: signal 4 set */
#define SP_STATUS_SIG5 0x1000 /* Bit 12: signal 5 set */
#define SP_STATUS_SIG6 0x2000 /* Bit 13: signal 6 set */
#define SP_STATUS_SIG7 0x4000 /* Bit 14: signal 7 set */
#define DPC_CLR_XBUS_DMEM_DMA 0x0001 /* Bit 0: clear xbus_dmem_dma */
#define DPC_SET_XBUS_DMEM_DMA 0x0002 /* Bit 1: set xbus_dmem_dma */
#define DPC_CLR_FREEZE 0x0004 /* Bit 2: clear freeze */
#define DPC_SET_FREEZE 0x0008 /* Bit 3: set freeze */
#define DPC_CLR_FLUSH 0x0010 /* Bit 4: clear flush */
#define DPC_SET_FLUSH 0x0020 /* Bit 5: set flush */
#define DPC_CLR_TMEM_CTR 0x0040 /* Bit 6: clear tmem ctr */
#define DPC_CLR_PIPE_CTR 0x0080 /* Bit 7: clear pipe ctr */
#define DPC_CLR_CMD_CTR 0x0100 /* Bit 8: clear cmd ctr */
#define DPC_CLR_CLOCK_CTR 0x0200 /* Bit 9: clear clock ctr */
#define DPC_STATUS_XBUS_DMEM_DMA 0x001 /* Bit 0: xbus_dmem_dma */
#define DPC_STATUS_FREEZE 0x002 /* Bit 1: freeze */
#define DPC_STATUS_FLUSH 0x004 /* Bit 2: flush */
#define DPC_STATUS_START_GCLK 0x008 /* Bit 3: start gclk */
#define DPC_STATUS_TMEM_BUSY 0x010 /* Bit 4: tmem busy */
#define DPC_STATUS_PIPE_BUSY 0x020 /* Bit 5: pipe busy */
#define DPC_STATUS_CMD_BUSY 0x040 /* Bit 6: cmd busy */
#define DPC_STATUS_CBUF_READY 0x080 /* Bit 7: cbuf ready */
#define DPC_STATUS_DMA_BUSY 0x100 /* Bit 8: dma busy */
#define DPC_STATUS_END_VALID 0x200 /* Bit 9: end valid */
#define DPC_STATUS_START_VALID 0x400 /* Bit 10: start valid */
#define MI_CLR_INIT 0x0080 /* Bit 7: clear init mode */
#define MI_SET_INIT 0x0100 /* Bit 8: set init mode */
#define MI_CLR_EBUS 0x0200 /* Bit 9: clear ebus test */
#define MI_SET_EBUS 0x0400 /* Bit 10: set ebus test mode */
#define MI_CLR_DP_INTR 0x0800 /* Bit 11: clear dp interrupt */
#define MI_CLR_RDRAM 0x1000 /* Bit 12: clear RDRAM reg */
#define MI_SET_RDRAM 0x2000 /* Bit 13: set RDRAM reg mode */
#define MI_MODE_INIT 0x0080 /* Bit 7: init mode */
#define MI_MODE_EBUS 0x0100 /* Bit 8: ebus test mode */
#define MI_MODE_RDRAM 0x0200 /* Bit 9: RDRAM reg mode */
#define MI_INTR_MASK_CLR_SP 0x0001 /* Bit 0: clear SP mask */
#define MI_INTR_MASK_SET_SP 0x0002 /* Bit 1: set SP mask */
#define MI_INTR_MASK_CLR_SI 0x0004 /* Bit 2: clear SI mask */
#define MI_INTR_MASK_SET_SI 0x0008 /* Bit 3: set SI mask */
#define MI_INTR_MASK_CLR_AI 0x0010 /* Bit 4: clear AI mask */
#define MI_INTR_MASK_SET_AI 0x0020 /* Bit 5: set AI mask */
#define MI_INTR_MASK_CLR_VI 0x0040 /* Bit 6: clear VI mask */
#define MI_INTR_MASK_SET_VI 0x0080 /* Bit 7: set VI mask */
#define MI_INTR_MASK_CLR_PI 0x0100 /* Bit 8: clear PI mask */
#define MI_INTR_MASK_SET_PI 0x0200 /* Bit 9: set PI mask */
#define MI_INTR_MASK_CLR_DP 0x0400 /* Bit 10: clear DP mask */
#define MI_INTR_MASK_SET_DP 0x0800 /* Bit 11: set DP mask */
#define MI_INTR_MASK_SP 0x01 /* Bit 0: SP intr mask */
#define MI_INTR_MASK_SI 0x02 /* Bit 1: SI intr mask */
#define MI_INTR_MASK_AI 0x04 /* Bit 2: AI intr mask */
#define MI_INTR_MASK_VI 0x08 /* Bit 3: VI intr mask */
#define MI_INTR_MASK_PI 0x10 /* Bit 4: PI intr mask */
#define MI_INTR_MASK_DP 0x20 /* Bit 5: DP intr mask */
#define MI_INTR_SP 0x01 /* Bit 0: SP intr */
#define MI_INTR_SI 0x02 /* Bit 1: SI intr */
#define MI_INTR_AI 0x04 /* Bit 2: AI intr */
#define MI_INTR_VI 0x08 /* Bit 3: VI intr */
#define MI_INTR_PI 0x10 /* Bit 4: PI intr */
#define MI_INTR_DP 0x20 /* Bit 5: DP intr */
#define PI_STATUS_DMA_BUSY 0x01
#define PI_STATUS_IO_BUSY 0x02
#define PI_STATUS_ERROR 0x04
#define PI_SET_RESET 0x01
#define PI_CLR_INTR 0x02
#define SI_STATUS_DMA_BUSY 0x0001
#define SI_STATUS_RD_BUSY 0x0002
#define SI_STATUS_DMA_ERROR 0x0008
#define SI_STATUS_INTERRUPT 0x1000
#define FPCSR_FS 0x01000000 /* flush denorm to zero */
#define FPCSR_C 0x00800000 /* condition bit */
#define FPCSR_CE 0x00020000 /* cause: unimplemented operation */
#define FPCSR_CV 0x00010000 /* cause: invalid operation */
#define FPCSR_CZ 0x00008000 /* cause: division by zero */
#define FPCSR_CO 0x00004000 /* cause: overflow */
#define FPCSR_CU 0x00002000 /* cause: underflow */
#define FPCSR_CI 0x00001000 /* cause: inexact operation */
#define FPCSR_EV 0x00000800 /* enable: invalid operation */
#define FPCSR_EZ 0x00000400 /* enable: division by zero */
#define FPCSR_EO 0x00000200 /* enable: overflow */
#define FPCSR_EU 0x00000100 /* enable: underflow */
#define FPCSR_EI 0x00000080 /* enable: inexact operation */
#define FPCSR_FV 0x00000040 /* flag: invalid operation */
#define FPCSR_FZ 0x00000020 /* flag: division by zero */
#define FPCSR_FO 0x00000010 /* flag: overflow */
#define FPCSR_FU 0x00000008 /* flag: underflow */
#define FPCSR_FI 0x00000004 /* flag: inexact operation */
#define FPCSR_RM_MASK 0x00000003 /* rounding mode mask */
#define FPCSR_RM_RN 0x00000000 /* round to nearest */
#define FPCSR_RM_RZ 0x00000001 /* round to zero */
#define FPCSR_RM_RP 0x00000002 /* round to positive infinity */
#define FPCSR_RM_RM 0x00000003 /* round to negative infinity */
#define FPR_Type(Reg) (Reg) == R4300i_COP1_S ? "S" : (Reg) == R4300i_COP1_D ? "D" :\ #define FPR_Type(Reg) (Reg) == R4300i_COP1_S ? "S" : (Reg) == R4300i_COP1_D ? "D" :\
(Reg) == R4300i_COP1_W ? "W" : "L" (Reg) == R4300i_COP1_W ? "W" : "L"

View File

@ -57,7 +57,7 @@ BOOL LoadSram (void) {
FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,0,NULL (LPTSTR) &lpMsgBuf,0,NULL
); );
DisplayError(lpMsgBuf); DisplayError((const char *)lpMsgBuf);
LocalFree( lpMsgBuf ); LocalFree( lpMsgBuf );
return FALSE; return FALSE;
} }
@ -67,7 +67,7 @@ BOOL LoadSram (void) {
FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,0,NULL (LPTSTR) &lpMsgBuf,0,NULL
); );
DisplayError(lpMsgBuf); DisplayError((const char *)lpMsgBuf);
LocalFree( lpMsgBuf ); LocalFree( lpMsgBuf );
return FALSE; return FALSE;
} }

View File

@ -45,9 +45,11 @@ N64_REGISTERS SyncRegisters;
int MemAddrUsedCount[2]; int MemAddrUsedCount[2];
BYTE * SyncMemory; BYTE * SyncMemory;
#ifdef toremove
//TLB //TLB
//FASTTLB SyncFastTlb[64]; //FASTTLB SyncFastTlb[64];
//TLB SyncTlb[32]; //TLB SyncTlb[32];
#endif
int Sync_MemoryFilter( DWORD dwExptCode, LPEXCEPTION_POINTERS lpEP); int Sync_MemoryFilter( DWORD dwExptCode, LPEXCEPTION_POINTERS lpEP);
@ -339,7 +341,8 @@ void StopErrorLog (void) {
} }
void SwitchSyncRegisters (void) { void SwitchSyncRegisters (void) {
#ifdef hhh _Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
FASTTLB TempFastTlb[64]; FASTTLB TempFastTlb[64];
TLB Temptlb[32]; TLB Temptlb[32];
BYTE * TempMemPtr; BYTE * TempMemPtr;

View File

@ -490,7 +490,7 @@ void CompX86RegToX86Reg(int Destination, int Source) {
PUTDST16(RecompPos,x86Command); PUTDST16(RecompPos,x86Command);
} }
void DecX86reg(x86Reg) { void DecX86reg(int x86Reg) {
CPU_Message(" dec %s",x86_Name(x86Reg)); CPU_Message(" dec %s",x86_Name(x86Reg));
switch (x86Reg) { switch (x86Reg) {
case x86_EAX: PUTDST16(RecompPos,0xC8FF); break; case x86_EAX: PUTDST16(RecompPos,0xC8FF); break;
@ -796,7 +796,7 @@ void LeaRegReg(int x86RegDest, int x86RegSrc, int multiplier) {
PUTDST32(RecompPos,0x00000000); PUTDST32(RecompPos,0x00000000);
} }
void LeaSourceAndOffset(x86DestReg, x86SourceReg, offset) { void LeaSourceAndOffset(int x86DestReg, int x86SourceReg, int offset) {
WORD x86Command; WORD x86Command;
CPU_Message(" lea %s, [%s + %0Xh]",x86_Name(x86DestReg),x86_Name(x86SourceReg),offset); CPU_Message(" lea %s, [%s + %0Xh]",x86_Name(x86DestReg),x86_Name(x86SourceReg),offset);
@ -873,7 +873,7 @@ void MoveConstByteToN64Mem(BYTE Const, int AddrReg) {
default: default:
DisplayError("MoveConstByteToN64Mem\nUnknown x86 Register"); DisplayError("MoveConstByteToN64Mem\nUnknown x86 Register");
} }
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
PUTDST8(RecompPos,Const); PUTDST8(RecompPos,Const);
} }
@ -899,7 +899,7 @@ void MoveConstHalfToN64Mem(WORD Const, int AddrReg) {
default: default:
DisplayError("MoveConstToN64Mem\nUnknown x86 Register"); DisplayError("MoveConstToN64Mem\nUnknown x86 Register");
} }
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
PUTDST16(RecompPos,Const); PUTDST16(RecompPos,Const);
} }
@ -978,7 +978,7 @@ void MoveConstToN64Mem(DWORD Const, int AddrReg) {
default: default:
DisplayError("MoveConstToN64Mem\nUnknown x86 Register"); DisplayError("MoveConstToN64Mem\nUnknown x86 Register");
} }
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,Const); PUTDST32(RecompPos,Const);
} }
@ -996,7 +996,7 @@ void MoveConstToN64MemDisp (DWORD Const, int AddrReg, BYTE Disp) {
default: default:
DisplayError("MoveConstToN64Mem\nUnknown x86 Register"); DisplayError("MoveConstToN64Mem\nUnknown x86 Register");
} }
PUTDST32(RecompPos,N64MEM + Disp); PUTDST32(RecompPos,RDRAM + Disp);
PUTDST32(RecompPos,Const); PUTDST32(RecompPos,Const);
} }
@ -1136,7 +1136,7 @@ void MoveN64MemDispToX86reg(int x86reg, int AddrReg, BYTE Disp) {
case x86_EBP: x86Command += 0xA800; break; case x86_EBP: x86Command += 0xA800; break;
} }
PUTDST16(RecompPos,x86Command); PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,N64MEM + Disp); PUTDST32(RecompPos,RDRAM + Disp);
} }
void MoveN64MemToX86reg(int x86reg, int AddrReg) { void MoveN64MemToX86reg(int x86reg, int AddrReg) {
@ -1165,7 +1165,7 @@ void MoveN64MemToX86reg(int x86reg, int AddrReg) {
case x86_EBP: x86Command += 0xA800; break; case x86_EBP: x86Command += 0xA800; break;
} }
PUTDST16(RecompPos,x86Command); PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void MoveN64MemToX86regByte(int x86reg, int AddrReg) { void MoveN64MemToX86regByte(int x86reg, int AddrReg) {
@ -1195,7 +1195,7 @@ void MoveN64MemToX86regByte(int x86reg, int AddrReg) {
break; break;
} }
PUTDST16(RecompPos,x86Command); PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void MoveN64MemToX86regHalf(int x86reg, int AddrReg) { void MoveN64MemToX86regHalf(int x86reg, int AddrReg) {
@ -1225,7 +1225,7 @@ void MoveN64MemToX86regHalf(int x86reg, int AddrReg) {
case x86_EBP: x86Command += 0xA800; break; case x86_EBP: x86Command += 0xA800; break;
} }
PUTDST16(RecompPos,x86Command); PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void MoveSxByteX86regPointerToX86reg(int AddrReg1, int AddrReg2, int x86reg) { void MoveSxByteX86regPointerToX86reg(int AddrReg1, int AddrReg2, int x86reg) {
@ -1347,7 +1347,7 @@ void MoveSxN64MemToX86regByte(int x86reg, int AddrReg) {
} }
PUTDST8(RecompPos,0x0f); PUTDST8(RecompPos,0x0f);
PUTDST16(RecompPos,x86Command); PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void MoveSxN64MemToX86regHalf(int x86reg, int AddrReg) { void MoveSxN64MemToX86regHalf(int x86reg, int AddrReg) {
@ -1378,7 +1378,7 @@ void MoveSxN64MemToX86regHalf(int x86reg, int AddrReg) {
PUTDST8(RecompPos, 0x0f); PUTDST8(RecompPos, 0x0f);
PUTDST16(RecompPos,x86Command); PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void MoveSxVariableToX86regByte(void *Variable, const char * VariableName, int x86reg) { void MoveSxVariableToX86regByte(void *Variable, const char * VariableName, int x86reg) {
@ -1525,7 +1525,7 @@ void MoveX86regByteToN64Mem(int x86reg, int AddrReg) {
case x86_EDX: x86Command += 0x9000; break; case x86_EDX: x86Command += 0x9000; break;
} }
PUTDST16(RecompPos,x86Command); PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void MoveX86regByteToVariable(int x86reg, void * Variable, const char * VariableName) { void MoveX86regByteToVariable(int x86reg, void * Variable, const char * VariableName) {
@ -1611,7 +1611,7 @@ void MoveX86regHalfToN64Mem(int x86reg, int AddrReg) {
case x86_EBP: x86Command += 0xA800; break; case x86_EBP: x86Command += 0xA800; break;
} }
PUTDST16(RecompPos,x86Command); PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void MoveX86regHalfToVariable(int x86reg, void * Variable, const char * VariableName) { void MoveX86regHalfToVariable(int x86reg, void * Variable, const char * VariableName) {
@ -1874,7 +1874,7 @@ void MoveX86regToN64Mem(int x86reg, int AddrReg) {
case x86_EBP: x86Command += 0xA800; break; case x86_EBP: x86Command += 0xA800; break;
} }
PUTDST16(RecompPos,x86Command); PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void MoveX86regToN64MemDisp(int x86reg, int AddrReg, BYTE Disp) { void MoveX86regToN64MemDisp(int x86reg, int AddrReg, BYTE Disp) {
@ -1902,7 +1902,7 @@ void MoveX86regToN64MemDisp(int x86reg, int AddrReg, BYTE Disp) {
case x86_EBP: x86Command += 0xA800; break; case x86_EBP: x86Command += 0xA800; break;
} }
PUTDST16(RecompPos,x86Command); PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,N64MEM+Disp); PUTDST32(RecompPos,RDRAM+Disp);
} }
void MoveX86regToVariable(int x86reg, void * Variable, const char * VariableName) { void MoveX86regToVariable(int x86reg, void * Variable, const char * VariableName) {
@ -2119,7 +2119,7 @@ void MoveZxHalfX86regPointerToX86reg(int AddrReg1, int AddrReg2, int x86reg) {
void MoveZxN64MemToX86regByte(int x86reg, int AddrReg) { void MoveZxN64MemToX86regByte(int x86reg, int AddrReg) {
WORD x86Command; WORD x86Command;
CPU_Message(" movzx %s, byte ptr [%s+N64MEM]",x86_Name(x86reg),x86_Name(AddrReg)); CPU_Message(" movzx %s, byte ptr [%s+RDRAM]",x86_Name(x86reg),x86_Name(AddrReg));
switch (AddrReg) { switch (AddrReg) {
case x86_EAX: x86Command = 0x00B6; break; case x86_EAX: x86Command = 0x00B6; break;
case x86_EBX: x86Command = 0x03B6; break; case x86_EBX: x86Command = 0x03B6; break;
@ -2145,13 +2145,13 @@ void MoveZxN64MemToX86regByte(int x86reg, int AddrReg) {
} }
PUTDST8(RecompPos,0x0f); PUTDST8(RecompPos,0x0f);
PUTDST16(RecompPos,x86Command); PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void MoveZxN64MemToX86regHalf(int x86reg, int AddrReg) { void MoveZxN64MemToX86regHalf(int x86reg, int AddrReg) {
WORD x86Command; WORD x86Command;
CPU_Message(" movzx %s, word ptr [%s+N64MEM]",x86_Name(x86reg),x86_Name(AddrReg)); CPU_Message(" movzx %s, word ptr [%s+RDRAM]",x86_Name(x86reg),x86_Name(AddrReg));
switch (AddrReg) { switch (AddrReg) {
case x86_EAX: x86Command = 0x00B7; break; case x86_EAX: x86Command = 0x00B7; break;
@ -2176,7 +2176,7 @@ void MoveZxN64MemToX86regHalf(int x86reg, int AddrReg) {
PUTDST8(RecompPos, 0x0f); PUTDST8(RecompPos, 0x0f);
PUTDST16(RecompPos,x86Command); PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void MoveZxVariableToX86regByte(void *Variable, const char * VariableName, int x86reg) { void MoveZxVariableToX86regByte(void *Variable, const char * VariableName, int x86reg) {

View File

@ -354,7 +354,7 @@ void fpuLoadDwordFromN64Mem(int * StackPos,int x86reg) {
default: default:
DisplayError("fpuLoadDwordFromN64Mem\nUnknown x86 Register"); DisplayError("fpuLoadDwordFromN64Mem\nUnknown x86 Register");
} }
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void fpuLoadInt32bFromN64Mem(int * StackPos,int x86reg) { void fpuLoadInt32bFromN64Mem(int * StackPos,int x86reg) {
@ -371,7 +371,7 @@ void fpuLoadInt32bFromN64Mem(int * StackPos,int x86reg) {
default: default:
DisplayError("fpuLoadIntDwordFromN64Mem\nUnknown x86 Register"); DisplayError("fpuLoadIntDwordFromN64Mem\nUnknown x86 Register");
} }
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void fpuLoadIntegerDword(int * StackPos,void *Variable, const char * VariableName) { void fpuLoadIntegerDword(int * StackPos,void *Variable, const char * VariableName) {
@ -457,7 +457,7 @@ void fpuLoadQwordFromN64Mem(int * StackPos,int x86reg) {
default: default:
DisplayError("fpuLoadQwordFromN64Mem\nUnknown x86 Register"); DisplayError("fpuLoadQwordFromN64Mem\nUnknown x86 Register");
} }
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void fpuLoadReg(int * StackPos,int Reg) { void fpuLoadReg(int * StackPos,int Reg) {
@ -619,7 +619,7 @@ void fpuStoreDwordToN64Mem(int * StackPos,int x86reg, BOOL Pop) {
default: default:
DisplayError("fpuStoreDwordToN64Mem\nUnknown x86 Register"); DisplayError("fpuStoreDwordToN64Mem\nUnknown x86 Register");
} }
PUTDST32(RecompPos,N64MEM); PUTDST32(RecompPos,RDRAM);
} }
void fpuStoreIntegerDword(int * StackPos,void *Variable, const char * VariableName, BOOL pop) { void fpuStoreIntegerDword(int * StackPos,void *Variable, const char * VariableName, BOOL pop) {

View File

@ -9,8 +9,7 @@
enum { WM_EDITCHEAT = WM_USER + 0x120 }; enum { WM_EDITCHEAT = WM_USER + 0x120 };
enum { UM_CHANGECODEEXTENSION = WM_USER + 0x121 }; enum { UM_CHANGECODEEXTENSION = WM_USER + 0x121 };
CCheats::CCheats (CN64Rom * const Rom, CNotification * const Notify ) : CCheats::CCheats (CN64Rom * const Rom ) :
_Notify(Notify),
_Rom(Rom), _Rom(Rom),
m_rcList(new RECT), m_rcList(new RECT),
m_rcAdd(new RECT), m_rcAdd(new RECT),
@ -192,20 +191,20 @@ void CCheats::ApplyGSButton (CMipsMemory * _MMU)
switch (Code.Command & 0xFF000000) { switch (Code.Command & 0xFF000000) {
case 0x88000000: case 0x88000000:
Address = 0x80000000 | (Code.Command & 0xFFFFFF); Address = 0x80000000 | (Code.Command & 0xFFFFFF);
_MMU->Store64(Address,Code.Value,_8Bit); _MMU->SB_VAddr(Address,Code.Value);
break; break;
case 0x89000000: case 0x89000000:
Address = 0x80000000 | (Code.Command & 0xFFFFFF); Address = 0x80000000 | (Code.Command & 0xFFFFFF);
_MMU->Store64(Address,Code.Value,_16Bit); _MMU->SH_VAddr(Address,Code.Value);
break; break;
// Xplorer64 // Xplorer64
case 0xA8000000: case 0xA8000000:
Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF);
_MMU->Store64(Address,ConvertXP64Value(Code.Value),_8Bit); _MMU->SB_VAddr(Address,ConvertXP64Value(Code.Value));
break; break;
case 0xA9000000: case 0xA9000000:
Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF);
_MMU->Store64(Address,ConvertXP64Value(Code.Value),_16Bit); _MMU->SH_VAddr(Address,ConvertXP64Value(Code.Value));
break; break;
} }
} }
@ -298,8 +297,9 @@ int CCheats::ApplyCheatEntry (CMipsMemory * _MMU, const CODES & CodeEntry, int C
return 0; return 0;
} }
const GAMESHARK_CODE & Code = CodeEntry[CurrentEntry]; const GAMESHARK_CODE & Code = CodeEntry[CurrentEntry];
DWORD Address, dwMemory; DWORD Address;
WORD Memory; WORD wMemory;
BYTE bMemory;
switch (Code.Command & 0xFF000000) { switch (Code.Command & 0xFF000000) {
// Gameshark / AR // Gameshark / AR
@ -320,21 +320,21 @@ int CCheats::ApplyCheatEntry (CMipsMemory * _MMU, const CODES & CodeEntry, int C
case 0x10000000: // Xplorer64 case 0x10000000: // Xplorer64
case 0x80000000: case 0x80000000:
Address = 0x80000000 | (NextCodeEntry.Command & 0xFFFFFF); Address = 0x80000000 | (NextCodeEntry.Command & 0xFFFFFF);
Memory = NextCodeEntry.Value; wMemory = NextCodeEntry.Value;
for (count=0; count<numrepeats; count++) { for (count=0; count<numrepeats; count++) {
_MMU->Store64(Address,Memory,_8Bit); _MMU->SB_VAddr(Address,wMemory);
Address += offset; Address += offset;
Memory += incr; wMemory += incr;
} }
return 2; return 2;
case 0x11000000: // Xplorer64 case 0x11000000: // Xplorer64
case 0x81000000: case 0x81000000:
Address = 0x80000000 | (NextCodeEntry.Command & 0xFFFFFF); Address = 0x80000000 | (NextCodeEntry.Command & 0xFFFFFF);
Memory = NextCodeEntry.Value; wMemory = NextCodeEntry.Value;
for (count=0; count<numrepeats; count++) { for (count=0; count<numrepeats; count++) {
_MMU->Store64(Address,Memory,_16Bit); _MMU->SH_VAddr(Address,wMemory);
Address += offset; Address += offset;
Memory += incr; wMemory += incr;
} }
return 2; return 2;
default: return 1; default: return 1;
@ -343,39 +343,39 @@ int CCheats::ApplyCheatEntry (CMipsMemory * _MMU, const CODES & CodeEntry, int C
break; break;
case 0x80000000: case 0x80000000:
Address = 0x80000000 | (Code.Command & 0xFFFFFF); Address = 0x80000000 | (Code.Command & 0xFFFFFF);
if (Execute) { _MMU->Store64(Address,Code.Value,_8Bit); } if (Execute) { _MMU->SB_VAddr(Address,Code.Value); }
break; break;
case 0x81000000: case 0x81000000:
Address = 0x80000000 | (Code.Command & 0xFFFFFF); Address = 0x80000000 | (Code.Command & 0xFFFFFF);
if (Execute) { _MMU->Store64(Address,Code.Value,_16Bit); } if (Execute) { _MMU->SH_VAddr(Address,Code.Value); }
break; break;
case 0xA0000000: case 0xA0000000:
Address = 0xA0000000 | (Code.Command & 0xFFFFFF); Address = 0xA0000000 | (Code.Command & 0xFFFFFF);
if (Execute) { _MMU->Store64(Address,Code.Value,_8Bit); } if (Execute) { _MMU->SB_VAddr(Address,Code.Value); }
break; break;
case 0xA1000000: case 0xA1000000:
Address = 0xA0000000 | (Code.Command & 0xFFFFFF); Address = 0xA0000000 | (Code.Command & 0xFFFFFF);
if (Execute) { _MMU->Store64(Address,Code.Value,_16Bit); } if (Execute) { _MMU->SH_VAddr(Address,Code.Value); }
break; break;
case 0xD0000000: // Added by Witten (witten@pj64cheats.net) case 0xD0000000: // Added by Witten (witten@pj64cheats.net)
Address = 0x80000000 | (Code.Command & 0xFFFFFF); Address = 0x80000000 | (Code.Command & 0xFFFFFF);
_MMU->Load32(Address,dwMemory,_8Bit,false); _MMU->LB_VAddr(Address,bMemory);
if (dwMemory != Code.Value) { Execute = FALSE; } if (bMemory != Code.Value) { Execute = FALSE; }
return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1;
case 0xD1000000: // Added by Witten (witten@pj64cheats.net) case 0xD1000000: // Added by Witten (witten@pj64cheats.net)
Address = 0x80000000 | (Code.Command & 0xFFFFFF); Address = 0x80000000 | (Code.Command & 0xFFFFFF);
_MMU->Load32(Address,dwMemory,_16Bit,false); _MMU->LH_VAddr(Address,wMemory);
if (dwMemory != Code.Value) { Execute = FALSE; } if (wMemory != Code.Value) { Execute = FALSE; }
return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1;
case 0xD2000000: // Added by Witten (witten@pj64cheats.net) case 0xD2000000: // Added by Witten (witten@pj64cheats.net)
Address = 0x80000000 | (Code.Command & 0xFFFFFF); Address = 0x80000000 | (Code.Command & 0xFFFFFF);
_MMU->Load32(Address,dwMemory,_8Bit,false); _MMU->LB_VAddr(Address,bMemory);
if (dwMemory == Code.Value) { Execute = FALSE; } if (bMemory == Code.Value) { Execute = FALSE; }
return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1;
case 0xD3000000: // Added by Witten (witten@pj64cheats.net) case 0xD3000000: // Added by Witten (witten@pj64cheats.net)
Address = 0x80000000 | (Code.Command & 0xFFFFFF); Address = 0x80000000 | (Code.Command & 0xFFFFFF);
_MMU->Load32(Address,dwMemory,_16Bit,false); _MMU->LH_VAddr(Address,wMemory);
if (dwMemory == Code.Value) { Execute = FALSE; } if (wMemory == Code.Value) { Execute = FALSE; }
return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1;
// Xplorer64 (Author: Witten) // Xplorer64 (Author: Witten)
@ -383,49 +383,49 @@ int CCheats::ApplyCheatEntry (CMipsMemory * _MMU, const CODES & CodeEntry, int C
case 0x82000000: case 0x82000000:
case 0x84000000: case 0x84000000:
Address = 0x80000000 | (Code.Command & 0xFFFFFF); Address = 0x80000000 | (Code.Command & 0xFFFFFF);
if (Execute) { _MMU->Store64(Address,Code.Value,_8Bit); } if (Execute) { _MMU->SB_VAddr(Address,Code.Value); }
break; break;
case 0x31000000: case 0x31000000:
case 0x83000000: case 0x83000000:
case 0x85000000: case 0x85000000:
Address = 0x80000000 | (Code.Command & 0xFFFFFF); Address = 0x80000000 | (Code.Command & 0xFFFFFF);
if (Execute) { _MMU->Store64(Address,Code.Value,_16Bit); } if (Execute) { _MMU->SH_VAddr(Address,Code.Value); }
break; break;
case 0xE8000000: case 0xE8000000:
Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF);
if (Execute) { _MMU->Store64(Address,(BYTE)ConvertXP64Value(Code.Value),_8Bit); } if (Execute) { _MMU->SB_VAddr(Address,(BYTE)ConvertXP64Value(Code.Value)); }
break; break;
case 0xE9000000: case 0xE9000000:
Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF);
if (Execute) { _MMU->Store64(Address,ConvertXP64Value(Code.Value),_16Bit); } if (Execute) { _MMU->SH_VAddr(Address,ConvertXP64Value(Code.Value)); }
break; break;
case 0xC8000000: case 0xC8000000:
Address = 0xA0000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); Address = 0xA0000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF);
if (Execute) { _MMU->Store64(Address,Code.Value,_8Bit); } if (Execute) { _MMU->SB_VAddr(Address,Code.Value); }
break; break;
case 0xC9000000: case 0xC9000000:
Address = 0xA0000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); Address = 0xA0000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF);
if (Execute) { _MMU->Store64(Address,ConvertXP64Value(Code.Value),_16Bit); } if (Execute) { _MMU->SH_VAddr(Address,ConvertXP64Value(Code.Value)); }
break; break;
case 0xB8000000: case 0xB8000000:
Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF);
_MMU->Load32(Address,dwMemory,_8Bit,false); _MMU->LB_VAddr(Address,bMemory);
if (dwMemory != ConvertXP64Value(Code.Value)) { Execute = FALSE; } if (bMemory != ConvertXP64Value(Code.Value)) { Execute = FALSE; }
return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1;
case 0xB9000000: case 0xB9000000:
Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF);
_MMU->Load32(Address,dwMemory,_16Bit,false); _MMU->LH_VAddr(Address,wMemory);
if (dwMemory != ConvertXP64Value(Code.Value)) { Execute = FALSE; } if (wMemory != ConvertXP64Value(Code.Value)) { Execute = FALSE; }
return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1;
case 0xBA000000: case 0xBA000000:
Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF);
_MMU->Load32(Address,dwMemory,_8Bit,false); _MMU->LB_VAddr(Address,bMemory);
if (dwMemory == ConvertXP64Value(Code.Value)) { Execute = FALSE; } if (bMemory == ConvertXP64Value(Code.Value)) { Execute = FALSE; }
return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1;
case 0xBB000000: case 0xBB000000:
Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF);
_MMU->Load32(Address,dwMemory,_16Bit,false); _MMU->LH_VAddr(Address,wMemory);
if (dwMemory == ConvertXP64Value(Code.Value)) { Execute = FALSE; } if (wMemory == ConvertXP64Value(Code.Value)) { Execute = FALSE; }
return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; return ApplyCheatEntry(_MMU,CodeEntry,CurrentEntry + 1,Execute) + 1;
case 0: return MaxGSEntries; break; case 0: return MaxGSEntries; break;
} }
@ -744,7 +744,6 @@ int CALLBACK CCheats::CheatAddProc (WND_HANDLE hDlg,DWORD uMsg,DWORD wParam, DWO
case IDC_ADD: case IDC_ADD:
{ {
CCheats * _this = (CCheats *)GetProp((HWND)hDlg,"Class"); CCheats * _this = (CCheats *)GetProp((HWND)hDlg,"Class");
CNotification * _Notify = _this->_Notify;
stdstr NewCheatName = GetDlgItemStr(hDlg,IDC_CODE_NAME); stdstr NewCheatName = GetDlgItemStr(hDlg,IDC_CODE_NAME);
for (int count = 0; count < MaxCheats; count ++) { for (int count = 0; count < MaxCheats; count ++) {
@ -811,7 +810,6 @@ int CALLBACK CCheats::CheatAddProc (WND_HANDLE hDlg,DWORD uMsg,DWORD wParam, DWO
case WM_EDITCHEAT: case WM_EDITCHEAT:
{ {
CCheats * _this = (CCheats *)GetProp((HWND)hDlg,"Class"); CCheats * _this = (CCheats *)GetProp((HWND)hDlg,"Class");
CNotification * _Notify = _this->_Notify;
_this->m_EditCheat = wParam; _this->m_EditCheat = wParam;
if (_this->m_EditCheat < 0) if (_this->m_EditCheat < 0)
{ {

View File

@ -9,7 +9,6 @@ class CCheats {
enum { MaxCheats = 50000 }; enum { MaxCheats = 50000 };
CNotification * const _Notify;
CN64Rom * const _Rom; CN64Rom * const _Rom;
static int CALLBACK CheatAddProc ( WND_HANDLE hDlg,DWORD uMsg,DWORD wParam, DWORD lParam ); static int CALLBACK CheatAddProc ( WND_HANDLE hDlg,DWORD uMsg,DWORD wParam, DWORD lParam );
@ -67,7 +66,7 @@ class CCheats {
static stdstr GetDlgItemStr (WND_HANDLE hDlg, int nIDDlgItem); static stdstr GetDlgItemStr (WND_HANDLE hDlg, int nIDDlgItem);
public: public:
CCheats (CN64Rom * const Rom, CNotification * const Notify ); CCheats (CN64Rom * const Rom = NULL);
~CCheats ( void ); ~CCheats ( void );
bool IsCheatMessage ( MSG * msg ); bool IsCheatMessage ( MSG * msg );

View File

@ -3,7 +3,6 @@ class CDebugDialog :
public CDialogImpl<T> public CDialogImpl<T>
{ {
protected: protected:
CMipsMemory * m_MMU;
CDebugger * m_Debugger; CDebugger * m_Debugger;
HANDLE m_CreatedEvent; HANDLE m_CreatedEvent;
HANDLE m_DialogThread; HANDLE m_DialogThread;
@ -21,8 +20,7 @@ protected:
} }
public: public:
CDebugDialog (CMipsMemory * MMU, CDebugger * debugger) : CDebugDialog (CDebugger * debugger) :
m_MMU(MMU),
m_Debugger(debugger), m_Debugger(debugger),
m_CreatedEvent(CreateEvent(NULL,true,false,NULL)), m_CreatedEvent(CreateEvent(NULL,true,false,NULL)),
m_DialogThread(NULL) m_DialogThread(NULL)

View File

@ -1,8 +1,7 @@
#include "Debugger UI.h" #include "Debugger UI.h"
CDumpMemory::CDumpMemory(CN64System * System, CMipsMemory * MMU, CDebugger * debugger) : CDumpMemory::CDumpMemory(CDebugger * debugger) :
CDebugDialog<CDumpMemory>(MMU,debugger), CDebugDialog<CDumpMemory>(debugger)
m_System(System)
{ {
} }
@ -54,7 +53,7 @@ LRESULT CDumpMemory::OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& b
openfilename.lpstrInitialDir = Directory; openfilename.lpstrInitialDir = Directory;
openfilename.nMaxFile = MAX_PATH; openfilename.nMaxFile = MAX_PATH;
openfilename.Flags = OFN_HIDEREADONLY; openfilename.Flags = OFN_HIDEREADONLY;
m_System->ExternalEvent(PauseCPU_DumpMemory); _N64System->ExternalEvent(PauseCPU_DumpMemory);
if (GetOpenFileName (&openfilename)) if (GetOpenFileName (&openfilename))
{ {
char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
@ -65,7 +64,7 @@ LRESULT CDumpMemory::OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& b
} }
SetDlgItemText(IDC_FILENAME,FileName); SetDlgItemText(IDC_FILENAME,FileName);
} }
m_System->ExternalEvent(ResumeCPU_DumpMemory); _N64System->ExternalEvent(ResumeCPU_DumpMemory);
} }
break; break;
case IDOK: case IDOK:
@ -85,7 +84,7 @@ LRESULT CDumpMemory::OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& b
} }
if (SendDlgItemMessage(IDC_USE_ALT_PC,BM_GETSTATE, 0,0) != BST_CHECKED) if (SendDlgItemMessage(IDC_USE_ALT_PC,BM_GETSTATE, 0,0) != BST_CHECKED)
{ {
DumpPC = m_MMU->SystemRegisters()->PROGRAM_COUNTER; DumpPC = _Reg->PROGRAM_COUNTER;
} }
//disable buttons //disable buttons
::EnableWindow(GetDlgItem(IDC_E_START_ADDR),FALSE); ::EnableWindow(GetDlgItem(IDC_E_START_ADDR),FALSE);
@ -97,14 +96,14 @@ LRESULT CDumpMemory::OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& b
::EnableWindow(GetDlgItem(IDC_FORMAT),FALSE); ::EnableWindow(GetDlgItem(IDC_FORMAT),FALSE);
::EnableWindow(GetDlgItem(IDOK),FALSE); ::EnableWindow(GetDlgItem(IDOK),FALSE);
::EnableWindow(GetDlgItem(IDCANCEL),FALSE); ::EnableWindow(GetDlgItem(IDCANCEL),FALSE);
m_System->ExternalEvent(PauseCPU_DumpMemory); _N64System->ExternalEvent(PauseCPU_DumpMemory);
if (!DumpMemory(FileName,Format,StartPC,EndPC,DumpPC)) if (!DumpMemory(FileName,Format,StartPC,EndPC,DumpPC))
{ {
//enable buttons //enable buttons
m_System->ExternalEvent(ResumeCPU_DumpMemory); _N64System->ExternalEvent(ResumeCPU_DumpMemory);
return false; return false;
} }
m_System->ExternalEvent(ResumeCPU_DumpMemory); _N64System->ExternalEvent(ResumeCPU_DumpMemory);
} }
EndDialog(0); EndDialog(0);
break; break;
@ -305,7 +304,7 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC,
LogFile.SetFlush(false); LogFile.SetFlush(false);
LogFile.SetTruncateFile(false); LogFile.SetTruncateFile(false);
char Command[200]; char Command[200];
for (COpcode OpCode(m_MMU,StartPC); OpCode.PC() < EndPC; OpCode.Next()) for (COpcode OpCode(StartPC); OpCode.PC() < EndPC; OpCode.Next())
{ {
const char * szOpName = OpCode.OpcodeName(); const char * szOpName = OpCode.OpcodeName();
OpCode.OpcodeParam(Command); OpCode.OpcodeParam(Command);

View File

@ -18,12 +18,11 @@ class CDumpMemory :
bool DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC ); bool DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC );
CEditNumber m_StartAddress, m_EndAddress, m_PC; CEditNumber m_StartAddress, m_EndAddress, m_PC;
CN64System * const m_System;
public: public:
enum { IDD = IDD_Cheats_DumpMemory }; enum { IDD = IDD_Cheats_DumpMemory };
CDumpMemory(CN64System * System, CMipsMemory * MMU, CDebugger * debugger); CDumpMemory(CDebugger * debugger);
virtual ~CDumpMemory(void); virtual ~CDumpMemory(void);
}; };

View File

@ -1,8 +1,7 @@
#include "Debugger UI.h" #include "Debugger UI.h"
CDebugMemorySearch::CDebugMemorySearch(CN64System * System, CMipsMemory * MMU, CDebugger * debugger) : CDebugMemorySearch::CDebugMemorySearch(CDebugger * debugger) :
CDebugDialog<CDebugMemorySearch>(MMU,debugger), CDebugDialog<CDebugMemorySearch>(debugger)
m_System(System)
{ {
} }
@ -13,12 +12,15 @@ CDebugMemorySearch::~CDebugMemorySearch()
void CDebugMemorySearch::AddAlignmentOptions (CComboBox & ctrl) void CDebugMemorySearch::AddAlignmentOptions (CComboBox & ctrl)
{ {
int Index = ctrl.AddString("32 bits (aligned)"); int Index = ctrl.AddString("32 bits (aligned)");
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
ctrl.SetItemData(Index,_32Bit); ctrl.SetItemData(Index,_32Bit);
Index = ctrl.AddString("16bits (aligned)"); Index = ctrl.AddString("16bits (aligned)");
ctrl.SetItemData(Index,_16Bit); ctrl.SetItemData(Index,_16Bit);
Index = ctrl.AddString("8bits"); Index = ctrl.AddString("8bits");
ctrl.SetCurSel(Index); ctrl.SetCurSel(Index);
ctrl.SetItemData(Index,_8Bit); ctrl.SetItemData(Index,_8Bit);
#endif
} }
LRESULT CDebugMemorySearch::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) LRESULT CDebugMemorySearch::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
@ -67,11 +69,11 @@ LRESULT CDebugMemorySearch::OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl,
break; break;
case IDC_BTN_RDRAM: case IDC_BTN_RDRAM:
m_PAddrStart.SetValue(0,true,true); m_PAddrStart.SetValue(0,true,true);
m_SearchLen.SetValue(m_MMU->RdramSize(),true,true); m_SearchLen.SetValue(_MMU->RdramSize(),true,true);
break; break;
case IDC_BTN_ROM: case IDC_BTN_ROM:
m_PAddrStart.SetValue(0x10000000,true,true); m_PAddrStart.SetValue(0x10000000,true,true);
m_SearchLen.SetValue(m_MMU->RomFileSize(),true,true); m_SearchLen.SetValue(_Rom->GetRomSize(),true,true);
break; break;
case IDC_BTN_SPMEM: case IDC_BTN_SPMEM:
m_PAddrStart.SetValue(0x04000000,true,true); m_PAddrStart.SetValue(0x04000000,true,true);
@ -222,6 +224,8 @@ void CDebugMemorySearch::EnableUnknownOptions( bool Enable )
void CDebugMemorySearch::SearchForValue( void ) void CDebugMemorySearch::SearchForValue( void )
{ {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
MemorySize Size = (MemorySize)m_ValueSize.GetItemData(m_ValueSize.GetCurSel()); MemorySize Size = (MemorySize)m_ValueSize.GetItemData(m_ValueSize.GetCurSel());
DWORD Value = m_SearchValue.GetValue(); DWORD Value = m_SearchValue.GetValue();
DWORD StartAddress = m_PAddrStart.GetValue(); DWORD StartAddress = m_PAddrStart.GetValue();
@ -244,7 +248,7 @@ void CDebugMemorySearch::SearchForValue( void )
m_SearchResults.DeleteAllItems(); m_SearchResults.DeleteAllItems();
DWORD ItemsAdded = 0; DWORD ItemsAdded = 0;
while (m_MMU->SearchForValue(Value,Size,StartAddress,Len)) /*while (_MMU->SearchForValue(Value,Size,StartAddress,Len))
{ {
SearchResultItem Result; SearchResultItem Result;
Result.PAddr = StartAddress; Result.PAddr = StartAddress;
@ -268,7 +272,7 @@ void CDebugMemorySearch::SearchForValue( void )
{ {
break; break;
} }
} }*/
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search Results"); ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search Results");
::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW); ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW);
::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN),false); ::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN),false);
@ -280,7 +284,7 @@ void CDebugMemorySearch::SearchForValue( void )
SearchResultItem & Result = m_SearchResult[ItemId]; SearchResultItem & Result = m_SearchResult[ItemId];
DWORD NewValue; DWORD NewValue;
m_MMU->LoadPhysical32(Result.PAddr,NewValue,Size,false); /*_MMU->LoadPhysical32(Result.PAddr,NewValue,Size,false);
if (Value == NewValue) if (Value == NewValue)
{ {
@ -292,19 +296,20 @@ void CDebugMemorySearch::SearchForValue( void )
Result.Value = NewValue; Result.Value = NewValue;
} else { } else {
m_SearchResults.DeleteItem(i); m_SearchResults.DeleteItem(i);
} }*/
} }
} }
::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS),stdstr_f("Results (%d)",m_SearchResults.GetItemCount()).c_str()); ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS),stdstr_f("Results (%d)",m_SearchResults.GetItemCount()).c_str());
#endif
} }
void CDebugMemorySearch::SearchForUnknown() void CDebugMemorySearch::SearchForUnknown()
{ {
CMipsMemory::SearchMemChangeState Option = (CMipsMemory::SearchMemChangeState)m_UnknownOptions.GetItemData(m_UnknownOptions.GetCurSel()); /*CMipsMemory::SearchMemChangeState Option = (CMipsMemory::SearchMemChangeState)m_UnknownOptions.GetItemData(m_UnknownOptions.GetCurSel());
if (Option == CMipsMemory::SearchChangeState_Reset) if (Option == CMipsMemory::SearchChangeState_Reset)
{ {
m_SearchResults.DeleteAllItems(); m_SearchResults.DeleteAllItems();
m_MMU->SearchSetBaseForChanges(); //_MMU->SearchSetBaseForChanges();
FixUnknownOptions(false); FixUnknownOptions(false);
::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW); ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW);
::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN),true ); ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN),true );
@ -343,7 +348,7 @@ void CDebugMemorySearch::SearchForUnknown()
m_SearchResults.DeleteAllItems(); m_SearchResults.DeleteAllItems();
DWORD ItemsAdded = 0, OldValue, NewValue; DWORD ItemsAdded = 0, OldValue, NewValue;
while (m_MMU->SearchForChanges(Option,Size,StartAddress,Len,OldValue,NewValue)) while (_MMU->SearchForChanges(Option,Size,StartAddress,Len,OldValue,NewValue))
{ {
SearchResultItem Result; SearchResultItem Result;
Result.PAddr = StartAddress; Result.PAddr = StartAddress;
@ -382,7 +387,7 @@ void CDebugMemorySearch::SearchForUnknown()
bool UpdateResult = false; bool UpdateResult = false;
DWORD NewValue; DWORD NewValue;
m_MMU->LoadPhysical32(Result.PAddr,NewValue,Size,false); _MMU->LoadPhysical32(Result.PAddr,NewValue,Size,false);
switch (Option) switch (Option)
{ {
case CMipsMemory::SearchChangeState_Changed: case CMipsMemory::SearchChangeState_Changed:
@ -427,6 +432,7 @@ void CDebugMemorySearch::SearchForUnknown()
} }
} }
::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS),stdstr_f("Results (%d)",m_SearchResults.GetItemCount()).c_str()); ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS),stdstr_f("Results (%d)",m_SearchResults.GetItemCount()).c_str());
*/
} }
void CDebugMemorySearch::SearchForText() void CDebugMemorySearch::SearchForText()
@ -467,7 +473,7 @@ void CDebugMemorySearch::Reset ( void )
void CDebugMemorySearch::FixUnknownOptions ( bool Reset ) void CDebugMemorySearch::FixUnknownOptions ( bool Reset )
{ {
CComboBox & cb = m_UnknownOptions ; /* CComboBox & cb = m_UnknownOptions ;
if (!Reset && cb.GetCount() > 1) if (!Reset && cb.GetCount() > 1)
{ {
@ -485,6 +491,6 @@ void CDebugMemorySearch::FixUnknownOptions ( bool Reset )
cb.SetItemData(cb.AddString("Value has increased"),CMipsMemory::SearchChangeState_Greater); cb.SetItemData(cb.AddString("Value has increased"),CMipsMemory::SearchChangeState_Greater);
cb.SetItemData(cb.AddString("Value has descreased"),CMipsMemory::SearchChangeState_Lessthan); cb.SetItemData(cb.AddString("Value has descreased"),CMipsMemory::SearchChangeState_Lessthan);
cb.SetCurSel(1); cb.SetCurSel(1);
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search"); ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search");*/
} }

View File

@ -40,7 +40,7 @@ class CDebugMemorySearch :
public: public:
enum { IDD = IDD_Debugger_Search }; enum { IDD = IDD_Debugger_Search };
CDebugMemorySearch(CN64System * System, CMipsMemory * MMU, CDebugger * debugger); CDebugMemorySearch(CDebugger * debugger);
virtual ~CDebugMemorySearch(void); virtual ~CDebugMemorySearch(void);
}; };

View File

@ -1,7 +1,7 @@
#include "Debugger UI.h" #include "Debugger UI.h"
CDebugTlb::CDebugTlb(CMipsMemory * MMU, CDebugger * debugger) : CDebugTlb::CDebugTlb(CDebugger * debugger) :
CDebugDialog<CDebugTlb>(MMU,debugger) CDebugDialog<CDebugTlb>(debugger)
{ {
} }
@ -91,20 +91,19 @@ LRESULT CDebugTlb::OnClicked (WORD wNotifyCode, WORD wID, HWND , BOOL& bHandled)
return FALSE; return FALSE;
} }
void CDebugTlb::RefreshTLBWindow (void) { void CDebugTlb::RefreshTLBWindow (void)
HWND hList = GetDlgItem(IDC_LIST); {
char Output[100], OldText[100];
LV_ITEM item, OldItem;
int count;
TLB * tlb = m_MMU->tlb;
FASTTLB * FastTlb = m_MMU->FastTlb;
if (m_hWnd == NULL) if (m_hWnd == NULL)
{ {
return; return;
} }
HWND hList = GetDlgItem(IDC_LIST);
char Output[100], OldText[100];
LV_ITEM item, OldItem;
int count;
CTLB::TLB_ENTRY * tlb = _TLB->m_tlb;
for (count = 0; count < 32; count ++) { for (count = 0; count < 32; count ++) {
sprintf(Output,"0x%02X",count); sprintf(Output,"0x%02X",count);
item.mask = LVIF_TEXT; item.mask = LVIF_TEXT;
@ -175,8 +174,8 @@ void CDebugTlb::RefreshTLBWindow (void) {
} }
} }
hList = GetDlgItem(IDC_LIST2); CTLB::FASTTLB * FastTlb = _TLB->m_FastTlb;
hList = GetDlgItem(IDC_LIST2);
for (count = 0; count < 64; count ++) { for (count = 0; count < 64; count ++) {
sprintf(Output,"0x%02X",count); sprintf(Output,"0x%02X",count);
item.mask = LVIF_TEXT; item.mask = LVIF_TEXT;
@ -237,264 +236,3 @@ void CDebugTlb::RefreshTLBWindow (void) {
} }
} }
} }
//{
// if (m_hDebugWnd)
// {
// SetForegroundWindow((HWND)m_hDebugWnd);
// } else {
// DWORD ThreadID;
// HANDLE hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)CreateDebugWindow,(LPVOID)this,0, &ThreadID);
// CloseHandle(hThread);
// }
//}
//
//void CDebugTlb::CreateDebugWindow ( CDebugTlb * _this ) {
// DialogBoxParam( GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Debugger_TLB), NULL,(DLGPROC) DebugWndProc, (LPARAM)_this );
// _this->m_hDebugWnd = NULL;
//}
//
//void CDebugTlb::SetupDebugWindow (void)
//{
// LV_COLUMN col;
//
// col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
// col.fmt = LVCFMT_LEFT;
//
// col.pszText = "Index";
// col.cx = 40;
// col.iSubItem = 0;
// ListView_InsertColumn ( GetDlgItem((HWND)m_hDebugWnd,IDC_LIST), 0, &col);
//
// col.pszText = "Page Mask";
// col.cx = 90;
// col.iSubItem = 1;
// ListView_InsertColumn ( GetDlgItem((HWND)m_hDebugWnd,IDC_LIST), 1, &col);
//
// col.pszText = "Entry Hi";
// col.cx = 90;
// col.iSubItem = 2;
// ListView_InsertColumn ( GetDlgItem((HWND)m_hDebugWnd,IDC_LIST), 2, &col);
//
// col.pszText = "Entry Lo0";
// col.cx = 90;
// col.iSubItem = 3;
// ListView_InsertColumn ( GetDlgItem((HWND)m_hDebugWnd,IDC_LIST), 3, &col);
//
// col.pszText = "Entry Lo1";
// col.cx = 90;
// col.iSubItem = 4;
// ListView_InsertColumn ( GetDlgItem((HWND)m_hDebugWnd,IDC_LIST), 4, &col);
//
// col.pszText = "Index";
// col.cx = 40;
// col.iSubItem = 0;
// ListView_InsertColumn ( GetDlgItem((HWND)m_hDebugWnd,IDC_LIST2), 0, &col);
//
// col.pszText = "Valid";
// col.cx = 40;
// col.iSubItem = 1;
// ListView_InsertColumn ( GetDlgItem((HWND)m_hDebugWnd,IDC_LIST2), 1, &col);
//
// col.pszText = "Dirty";
// col.cx = 40;
// col.iSubItem = 2;
// ListView_InsertColumn ( GetDlgItem((HWND)m_hDebugWnd,IDC_LIST2), 2, &col);
//
// col.pszText = "Rule";
// col.cx = 280;
// col.iSubItem = 3;
// ListView_InsertColumn ( GetDlgItem((HWND)m_hDebugWnd,IDC_LIST2), 3, &col);
//
// RefreshTLBWindow();
// SendMessage(GetDlgItem((HWND)m_hDebugWnd,IDC_TLB_ENTRIES),BM_SETCHECK, BST_CHECKED,0);
//
// if (Settings().Load(TLBWindowLeft) <= 0)
// {
// SetWindowPos((HWND)m_hDebugWnd,NULL,Settings().Load(TLBWindowLeft),Settings().Load(TLBWindowTop),0,0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW);
// }
//}
//
//void CDebugTlb::RefreshTLBWindow (void) {
// HWND hList = GetDlgItem((HWND)m_hDebugWnd,IDC_LIST);
// char Output[100], OldText[100];
// LV_ITEM item, OldItem;
// int count;
//
// TLB * tlb = _TLB->tlb;
// FASTTLB * FastTlb = _TLB->FastTlb;
//
// if (!(HWND)m_hDebugWnd) { return; }
// for (count = 0; count < 32; count ++) {
// sprintf(Output,"0x%02X",count);
// item.mask = LVIF_TEXT;
// item.iItem = count;
// item.pszText = Output;
// item.iSubItem = 0;
//
// OldItem.mask = LVIF_TEXT;
// OldItem.iItem = count;
// OldItem.pszText = OldText;
// OldItem.cchTextMax = sizeof( OldText )-1;
// OldItem.iSubItem = 0;
//
// if (ListView_GetItemCount(hList) <= count) {
// ListView_InsertItem(hList,&item);
// } else {
// ListView_GetItem(hList,&OldItem);
// if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
// ListView_SetItem(hList,&item);
// }
// }
// if (tlb[count].EntryDefined) {
// sprintf(Output,"0x%08X",tlb[count].PageMask.Value);
// } else {
// strcpy(Output,"................");
// }
// item.iSubItem = 1;
// OldItem.iSubItem = 1;
// ListView_GetItem(hList,&OldItem);
// if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
// ListView_SetItem(hList,&item);
// }
//
// if (tlb[count].EntryDefined) {
// sprintf(Output,"0x%08X",tlb[count].EntryHi.Value);
// } else {
// strcpy(Output,"................");
// }
// item.iSubItem = 2;
// OldItem.iSubItem = 2;
// ListView_GetItem(hList,&OldItem);
// if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
// ListView_SetItem(hList,&item);
// }
//
// if (tlb[count].EntryDefined) {
// sprintf(Output,"0x%08X",tlb[count].EntryLo0.Value);
// } else {
// strcpy(Output,"................");
// }
// item.iSubItem = 3;
// OldItem.iSubItem = 3;
// ListView_GetItem(hList,&OldItem);
// if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
// ListView_SetItem(hList,&item);
// }
//
// if (tlb[count].EntryDefined) {
// sprintf(Output,"0x%08X",tlb[count].EntryLo1.Value);
// } else {
// strcpy(Output,"................");
// }
// item.iSubItem = 4;
// OldItem.iSubItem = 4;
// ListView_GetItem(hList,&OldItem);
// if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
// ListView_SetItem(hList,&item);
// }
// }
//
// hList = GetDlgItem((HWND)m_hDebugWnd,IDC_LIST2);
//
// for (count = 0; count < 64; count ++) {
// sprintf(Output,"0x%02X",count);
// item.mask = LVIF_TEXT;
// item.iItem = count;
// item.pszText = Output;
// item.iSubItem = 0;
//
// OldItem.mask = LVIF_TEXT;
// OldItem.iItem = count;
// OldItem.pszText = OldText;
// OldItem.cchTextMax = sizeof( OldText )-1;
// OldItem.iSubItem = 0;
//
// if (ListView_GetItemCount(hList) <= count) {
// item.iItem = ListView_InsertItem(hList,&item);
// } else {
// ListView_GetItem(hList,&OldItem);
// if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
// ListView_SetItem(hList,&item);
// }
// }
//
// if (FastTlb[count].ValidEntry) {
// sprintf(Output,"%s",FastTlb[count].VALID?"Yes":"No");
// } else {
// strcpy(Output,"................");
// }
// item.iSubItem = 1;
// OldItem.iSubItem = 1;
// ListView_GetItem(hList,&OldItem);
// if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
// ListView_SetItem(hList,&item);
// }
//
// if (FastTlb[count].ValidEntry && FastTlb[count].VALID) {
// sprintf(Output,"%s",FastTlb[count].DIRTY?"Yes":"No");
// } else {
// strcpy(Output,"................");
// }
// item.iSubItem = 2;
// OldItem.iSubItem = 2;
// ListView_GetItem(hList,&OldItem);
// if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
// ListView_SetItem(hList,&item);
// }
//
// if (FastTlb[count].ValidEntry && FastTlb[count].VALID) {
// sprintf(Output,"%08X:%08X -> %08X:%08X",FastTlb[count].VSTART,FastTlb[count].VEND,
// FastTlb[count].PHYSSTART,FastTlb[count].PHYSEND);
// } else {
// strcpy(Output,"................");
// }
// item.iSubItem = 3;
// OldItem.iSubItem = 3;
// ListView_GetItem(hList,&OldItem);
// if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
// ListView_SetItem(hList,&item);
// }
// }
//}
//
//DWORD CALLBACK DebugWndProc (WND_HANDLE hDlg, DWORD uMsg, DWORD wParam, DWORD lParam)
//{
// switch (uMsg) {
// case WM_INITDIALOG:
// {
// CDebugTlb * _this = (CDebugTlb *)lParam;
// SetProp((HWND)hDlg,"Class",_this);
// _this->m_hDebugWnd = hDlg;
// _this->SetupDebugWindow();
// }
// break;
// case WM_MOVE:
// {
// RECT WinRect;
// GetWindowRect((HWND)hDlg, &WinRect );
//
// Settings().Save(TLBWindowLeft,WinRect.left);
// Settings().Save(TLBWindowTop,WinRect.top);
// }
// break;
// case WM_COMMAND:
// switch (LOWORD(wParam)) {
// case IDC_TLB_ENTRIES:
// ShowWindow(GetDlgItem((HWND)hDlg,IDC_LIST),SW_SHOW);
// ShowWindow(GetDlgItem((HWND)hDlg,IDC_LIST2),SW_HIDE);
// break;
// case IDC_TLB_RULES:
// ShowWindow(GetDlgItem((HWND)hDlg,IDC_LIST),SW_HIDE);
// ShowWindow(GetDlgItem((HWND)hDlg,IDC_LIST2),SW_SHOW);
// break;
// case IDCANCEL:
// EndDialog( (HWND)hDlg, IDCANCEL );
// break;
// }
// break;
// default:
// return FALSE;
// }
// return TRUE;
//}

View File

@ -13,7 +13,7 @@ class CDebugTlb :
public: public:
enum { IDD = IDD_Debugger_TLB }; enum { IDD = IDD_Debugger_TLB };
CDebugTlb(CMipsMemory * MMU, CDebugger * debugger); CDebugTlb(CDebugger * debugger);
virtual ~CDebugTlb(void); virtual ~CDebugTlb(void);
void RefreshTLBWindow ( void ); void RefreshTLBWindow ( void );

View File

@ -1,7 +1,7 @@
#include "Debugger UI.h" #include "Debugger UI.h"
CDebugMemoryView::CDebugMemoryView(CMipsMemory * MMU, CDebugger * debugger) : CDebugMemoryView::CDebugMemoryView(CDebugger * debugger) :
CDebugDialog<CDebugMemoryView>(MMU,debugger), CDebugDialog<CDebugMemoryView>(debugger),
m_MemoryList(NULL) m_MemoryList(NULL)
{ {
if (m_MemoryList== NULL) if (m_MemoryList== NULL)
@ -170,15 +170,15 @@ LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR )
//sb //sb
if ( m_DataVAddrr ) if ( m_DataVAddrr )
{ {
if (!m_MMU->Store64(m_DataStartLoc+ Pos,Value,_8Bit)) if (!_MMU->SB_VAddr(m_DataStartLoc+ Pos,Value))
{ {
WriteTraceF(TraceError,"CDebugMemoryView::OnMemoryModified - failed to store at %X",m_DataStartLoc + Pos); WriteTraceF(TraceError,"CDebugMemoryView::OnMemoryModified - failed to store at %X",m_DataStartLoc + Pos);
} }
} else { } else {
if (!m_MMU->StorePhysical64(m_DataStartLoc+ Pos,Value,_8Bit)) /*if (!_MMU->SD_VAddr(m_DataStartLoc+ Pos,Value,_8Bit))
{ {
WriteTraceF(TraceError,"CDebugMemoryView::OnMemoryModified - failed to store at %X",m_DataStartLoc + Pos); WriteTraceF(TraceError,"CDebugMemoryView::OnMemoryModified - failed to store at %X",m_DataStartLoc + Pos);
} }*/
} }
Insert_MemoryLineDump(LineNumber); Insert_MemoryLineDump(LineNumber);
@ -251,8 +251,13 @@ void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber )
Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_WINDOWTEXT ) ); Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_WINDOWTEXT ) );
m_MemoryList->SetItemHighlightColours( LineNumber, col, m_MemoryList->SetItemHighlightColours( LineNumber, col,
Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_HIGHLIGHTTEXT ) ); Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_HIGHLIGHTTEXT ) );
sprintf(AsciiAddOn,"%c",m_CurrentData[((LineNumber << 4) + i)]); if (m_CurrentData[Pos] < 30)
strcat(Ascii,AsciiAddOn); {
strcat(Ascii,".");
} else {
sprintf(AsciiAddOn,"%c",m_CurrentData[Pos]);
strcat(Ascii,AsciiAddOn);
}
} else { } else {
m_MemoryList->SetItemText(LineNumber,col,"**"); m_MemoryList->SetItemText(LineNumber,col,"**");
m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE ); m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE );
@ -310,6 +315,11 @@ void CDebugMemoryView::OnVScroll(int request, short Pos, HWND ctrl )
void CDebugMemoryView::RefreshMemory ( bool ResetCompare ) void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
{ {
if (m_MemoryList && m_MemoryList->GetHasEditItem())
{
m_MemoryList->SetFocus();
}
DWORD NewAddress = m_MemAddr.GetValue(); DWORD NewAddress = m_MemAddr.GetValue();
if (NewAddress != m_DataStartLoc) if (NewAddress != m_DataStartLoc)
{ {
@ -347,15 +357,15 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
if ( m_DataVAddrr ) if ( m_DataVAddrr )
{ {
if (!m_MMU->Load32(m_DataStartLoc & ~3, word.UW,_32Bit,false)) if (!_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW))
{ {
ValidData = false; ValidData = false;
} }
} else { } else {
if (!m_MMU->LoadPhysical32(m_DataStartLoc & ~3, word.UW, _32Bit,false)) /*if (!_MMU->LoadPhysical32(m_DataStartLoc & ~3, word.UW, _32Bit,false))
{ {
ValidData = false; ValidData = false;
} }*/
} }
int Offset = (m_DataStartLoc & 3); int Offset = (m_DataStartLoc & 3);
@ -382,15 +392,15 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
if ( m_DataVAddrr ) if ( m_DataVAddrr )
{ {
if (!m_MMU->Load32(Pos, word.UW,_32Bit,false)) if (!_MMU->LW_VAddr(Pos, word.UW))
{ {
ValidData = false; ValidData = false;
} }
} else { } else {
if (!m_MMU->LoadPhysical32(Pos, word.UW, _32Bit,false)) /*if (!_MMU->LoadPhysical32(Pos, word.UW, _32Bit,false))
{ {
ValidData = false; ValidData = false;
} }*/
} }
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)

View File

@ -39,7 +39,7 @@ class CDebugMemoryView :
public: public:
enum { IDD = IDD_Debugger_Memory }; enum { IDD = IDD_Debugger_Memory };
CDebugMemoryView(CMipsMemory * MMU, CDebugger * debugger); CDebugMemoryView(CDebugger * debugger);
virtual ~CDebugMemoryView(void); virtual ~CDebugMemoryView(void);
void ShowAddress (DWORD Address, bool VAddr); void ShowAddress (DWORD Address, bool VAddr);

View File

@ -45,3 +45,4 @@
#include "Debugger - Memory Dump.h" #include "Debugger - Memory Dump.h"
#include "Debugger - TLB.h" #include "Debugger - TLB.h"

View File

@ -7,13 +7,11 @@
CPj64Module _Module; CPj64Module _Module;
CDebugger::CDebugger (CN64System * System, CMipsMemory *& MMU) : CDebugger::CDebugger () :
m_MemoryDump(NULL), m_MemoryDump(NULL),
m_MemoryView(NULL), m_MemoryView(NULL),
m_MemorySearch(NULL), m_MemorySearch(NULL),
m_DebugTLB(NULL), m_DebugTLB(NULL)
m_MMU(MMU),
m_System(System)
{ {
} }
@ -52,13 +50,13 @@ void CDebugger::Debug_Reset ( void )
void CDebugger::Debug_ShowMemoryDump() void CDebugger::Debug_ShowMemoryDump()
{ {
if (m_MMU == NULL) if (_MMU == NULL)
{ {
return; return;
} }
if (m_MemoryDump == NULL) if (m_MemoryDump == NULL)
{ {
m_MemoryDump = new CDumpMemory(m_System, m_MMU, this); m_MemoryDump = new CDumpMemory(this);
} }
if (m_MemoryDump) if (m_MemoryDump)
{ {
@ -68,13 +66,13 @@ void CDebugger::Debug_ShowMemoryDump()
void CDebugger::Debug_ShowMemoryWindow ( void ) void CDebugger::Debug_ShowMemoryWindow ( void )
{ {
if (m_MMU == NULL) if (_MMU == NULL)
{ {
return; return;
} }
if (m_MemoryView == NULL) if (m_MemoryView == NULL)
{ {
m_MemoryView = new CDebugMemoryView(m_MMU, this); m_MemoryView = new CDebugMemoryView(this);
} }
if (m_MemoryView) if (m_MemoryView)
{ {
@ -93,13 +91,13 @@ void CDebugger::Debug_ShowMemoryLocation ( DWORD Address, bool VAddr )
void CDebugger::Debug_ShowTLBWindow (void) void CDebugger::Debug_ShowTLBWindow (void)
{ {
if (m_MMU == NULL) if (_MMU == NULL)
{ {
return; return;
} }
if (m_DebugTLB == NULL) if (m_DebugTLB == NULL)
{ {
m_DebugTLB = new CDebugTlb(m_MMU, this); m_DebugTLB = new CDebugTlb(this);
} }
if (m_DebugTLB) if (m_DebugTLB)
{ {
@ -119,7 +117,7 @@ void CDebugger::Debug_ShowMemorySearch()
{ {
if (m_MemorySearch == NULL) if (m_MemorySearch == NULL)
{ {
m_MemorySearch = new CDebugMemorySearch(m_System, m_MMU, this); m_MemorySearch = new CDebugMemorySearch(this);
} }
if (m_MemorySearch) if (m_MemorySearch)
{ {

View File

@ -8,11 +8,9 @@ class CDebugger
CDebugMemoryView * m_MemoryView; CDebugMemoryView * m_MemoryView;
CDebugMemorySearch * m_MemorySearch; CDebugMemorySearch * m_MemorySearch;
CDebugTlb * m_DebugTLB; CDebugTlb * m_DebugTLB;
CMipsMemory *& m_MMU;
CN64System * m_System;
protected: protected:
CDebugger(CN64System * System, CMipsMemory *& MMU); CDebugger();
~CDebugger(); ~CDebugger();
public: public:

View File

@ -0,0 +1 @@
#include "../stdafx.h"

View File

@ -29,41 +29,42 @@
// ****************** Testing Audio Stuff ***************** // ****************** Testing Audio Stuff *****************
CAudio::CAudio (CRegisters * Reg) : CAudio::CAudio (void)
_Reg(Reg),
VSyncTiming(789000.0f)
{ {
//float CAudio::VSyncTiming = 789000.0f; // 500000
////const float VSyncTiming = 760000.0f;
ResetAudioSettings(); ResetAudioSettings();
} }
// I seem to be getting clicking when I set CF to 1 and VSyncTiming to 789000 // I seem to be getting clicking when I set CF to 1 and VSyncTiming to 789000
void CAudio::ResetAudioSettings (void) void CAudio::ResetAudioSettings (void)
{ {
FramesPerSecond = 60.0f; //float CAudio::VSyncTiming = 789000.0f; // 500000
BytesPerSecond = 0; ////const float VSyncTiming = 760000.0f;
Length = 0; m_FramesPerSecond = 60.0f;
Status = 0; m_BytesPerSecond = 0;
CountsPerByte = 0; m_Length = 0;
SecondBuff = 0; m_Status = 0;
CurrentCount = 0; m_CountsPerByte = 0;
CurrentLength = 0; m_SecondBuff = 0;
IntScheduled = 0; m_CurrentCount = 0;
m_CurrentLength = 0;
m_IntScheduled = 0;
m_VSyncTiming = 789000.0f;
} }
void CAudio::AiCallBack () { void CAudio::AiCallBack ()
if (SecondBuff != 0) { {
IntScheduled = (DWORD)((double)SecondBuff * CountsPerByte); if (m_SecondBuff != 0) {
_Reg->ChangeTimerFixed(AiTimer, IntScheduled); m_IntScheduled = (DWORD)((double)m_SecondBuff * m_CountsPerByte);
_Reg->ChangeTimerFixed(AiTimer, m_IntScheduled);
} }
CurrentCount = _Reg->COUNT_REGISTER; m_CurrentCount = _Reg->COUNT_REGISTER;
CurrentLength = SecondBuff; m_CurrentLength = m_SecondBuff;
SecondBuff = 0; m_SecondBuff = 0;
Status &= 0x7FFFFFFF; m_Status &= 0x7FFFFFFF;
} }
DWORD CAudio::AiGetLength (CAudio * _this) { DWORD CAudio::AiGetLength (void)
{
double AiCounts; double AiCounts;
// static DWORD LengthReadHack = 0; // static DWORD LengthReadHack = 0;
// if ((COUNT_REGISTER - LengthReadHack) < 0x20) { // if ((COUNT_REGISTER - LengthReadHack) < 0x20) {
@ -73,52 +74,56 @@ DWORD CAudio::AiGetLength (CAudio * _this) {
// COUNT_REGISTER+=0xA; // This hack is necessary... but what is a good value?? // COUNT_REGISTER+=0xA; // This hack is necessary... but what is a good value??
// } // }
// LengthReadHack = COUNT_REGISTER; // LengthReadHack = COUNT_REGISTER;
AiCounts = _this->CountsPerByte * _this->CurrentLength; AiCounts = m_CountsPerByte * m_CurrentLength;
AiCounts = AiCounts - (double)(_this->_Reg->COUNT_REGISTER - _this->CurrentCount); AiCounts = AiCounts - (double)(_Reg->COUNT_REGISTER - m_CurrentCount);
if (AiCounts < 0) if (AiCounts < 0)
{
return 0; return 0;
}
// return 0; // return 0;
return (DWORD)(AiCounts/_this->CountsPerByte); return (DWORD)(AiCounts / m_CountsPerByte);
} }
DWORD CAudio::AiGetStatus (CAudio * _this) { DWORD CAudio::AiGetStatus (void)
return _this->Status; {
return m_Status;
} }
void CAudio::AiSetLength (CAudio * _this, DWORD data) { void CAudio::AiSetLength (void)
{
// Set Status to FULL for a few COUNT cycles // Set Status to FULL for a few COUNT cycles
if (_this->CurrentLength == 0) { if (m_CurrentLength == 0) {
_this->CurrentLength = _this->_Reg->AI_LEN_REG; m_CurrentLength = _Reg->AI_LEN_REG;
_this->CurrentCount = _this->_Reg->COUNT_REGISTER; m_CurrentCount = _Reg->COUNT_REGISTER;
_this->IntScheduled = (DWORD)((double)_this->_Reg->AI_LEN_REG * _this->CountsPerByte); m_IntScheduled = (DWORD)((double)_Reg->AI_LEN_REG * m_CountsPerByte);
_this->_Reg->ChangeTimerFixed(AiTimer, _this->IntScheduled); _Reg->ChangeTimerFixed(AiTimer, m_IntScheduled);
} else { } else {
_this->SecondBuff = _this->_Reg->AI_LEN_REG; m_SecondBuff = _Reg->AI_LEN_REG;
_this->Status |= 0x80000000; m_Status |= 0x80000000;
} }
} }
void CAudio::UpdateAudioTimer (DWORD CountsPerFrame) { void CAudio::UpdateAudioTimer (DWORD CountsPerFrame)
double CountsPerSecond; {
CountsPerSecond = (DWORD)((double)CountsPerFrame * FramesPerSecond); // This will only work with NTSC... VSyncTiming... double CountsPerSecond = (DWORD)((double)CountsPerFrame * m_FramesPerSecond); // This will only work with NTSC... VSyncTiming...
CountsPerByte = (double)CountsPerSecond / (double)BytesPerSecond; m_CountsPerByte = CountsPerSecond / (double)m_BytesPerSecond;
} }
void CAudio::AiSetFrequency (DWORD Dacrate, DWORD System) { void CAudio::AiSetFrequency (DWORD Dacrate, DWORD System) {
double CountsPerSecond; double CountsPerSecond;
switch (System) { switch (System) {
case SYSTEM_NTSC: BytesPerSecond = 48681812 / (Dacrate + 1); break; case SYSTEM_NTSC: m_BytesPerSecond = 48681812 / (Dacrate + 1); break;
case SYSTEM_PAL: BytesPerSecond = 49656530 / (Dacrate + 1); break; case SYSTEM_PAL: m_BytesPerSecond = 49656530 / (Dacrate + 1); break;
case SYSTEM_MPAL: BytesPerSecond = 48628316 / (Dacrate + 1); break; case SYSTEM_MPAL: m_BytesPerSecond = 48628316 / (Dacrate + 1); break;
} }
if (System == SYSTEM_PAL) { if (System == SYSTEM_PAL) {
FramesPerSecond = 50.0; m_FramesPerSecond = 50.0;
} else { } else {
FramesPerSecond = 60.0; m_FramesPerSecond = 60.0;
} }
BytesPerSecond = (BytesPerSecond * 4); // This makes it Bytes Per Second... m_BytesPerSecond = (m_BytesPerSecond * 4); // This makes it Bytes Per Second...
CountsPerSecond = (double)(((double)VSyncTiming) * (double)60.0); // This will only work with NTSC... VSyncTiming... CountsPerSecond = (double)(((double)m_VSyncTiming) * (double)60.0); // This will only work with NTSC... VSyncTiming...
CountsPerByte = (double)CountsPerSecond / (double)BytesPerSecond; m_CountsPerByte = (double)CountsPerSecond / (double)m_BytesPerSecond;
SecondBuff = Status = CurrentLength = 0; m_SecondBuff = m_Status = m_CurrentLength = 0;
//CountsPerByte /= CountPerOp; //CountsPerByte /= CountPerOp;
} }

View File

@ -1,29 +1,25 @@
#ifdef __cplusplus class CAudio
{
class CAudio {
CRegisters * const _Reg;
const float VSyncTiming;
double FramesPerSecond;
DWORD BytesPerSecond;
DWORD Length;
DWORD Status;
double CountsPerByte;
DWORD SecondBuff;
DWORD CurrentCount;
DWORD CurrentLength;
DWORD IntScheduled;
public: public:
CAudio (CRegisters * Reg); CAudio (void);
void AiCallBack (); void AiCallBack ( void );
static DWORD __fastcall AiGetLength (CAudio * _this); DWORD AiGetLength ( void );
static DWORD __fastcall AiGetStatus (CAudio * _this); DWORD AiGetStatus ( void );
static void __fastcall AiSetLength (CAudio * _this, DWORD data); void AiSetLength ( void );
void AiSetFrequency (DWORD Dacrate, DWORD System); void AiSetFrequency ( DWORD Dacrate, DWORD System );
void UpdateAudioTimer (DWORD CountsPerFrame); void UpdateAudioTimer ( DWORD CountsPerFrame );
void ResetAudioSettings (void); void ResetAudioSettings ( void);
private:
float m_VSyncTiming;
double m_FramesPerSecond;
DWORD m_BytesPerSecond;
DWORD m_Length;
DWORD m_Status;
double m_CountsPerByte;
DWORD m_SecondBuff;
DWORD m_CurrentCount;
DWORD m_CurrentLength;
DWORD m_IntScheduled;
}; };
#endif

View File

@ -1,17 +1,10 @@
#include <windows.h>
#ifdef toremove
enum MemorySize { _8Bit, _16Bit, _32Bit, _64Bit }; enum MemorySize { _8Bit, _16Bit, _32Bit, _64Bit };
class CRSP_Plugin;
class CC_Core; class CC_Core;
#endif
extern "C" {
int r4300i_SB_NonMemory ( DWORD PAddr, BYTE Value );
int r4300i_SH_NonMemory ( DWORD PAddr, WORD Value );
int r4300i_SW_NonMemory ( DWORD PAddr, DWORD Value );
int r4300i_LB_NonMemory ( DWORD PAddr, DWORD * Value, int SignExtend );
int r4300i_LH_NonMemory ( DWORD PAddr, DWORD * Value, int SignExtend );
int r4300i_LW_NonMemory ( DWORD PAddr, DWORD * Value );
}
class CMipsMemory_CallBack { class CMipsMemory_CallBack {
public: public:
@ -20,10 +13,60 @@ public:
virtual bool WriteToProtectedMemory (DWORD Address, int length) = 0; virtual bool WriteToProtectedMemory (DWORD Address, int length) = 0;
}; };
class CMipsMemory : class CBlockSection;
class CMipsMemory
{
public:
virtual BYTE * Rdram ( void ) = 0;
virtual DWORD RdramSize ( void ) = 0;
virtual BYTE * Dmem ( void ) = 0;
virtual BYTE * Imem ( void ) = 0;
virtual BYTE * PifRam ( void ) = 0;
virtual BOOL LB_VAddr ( DWORD VAddr, BYTE & Value ) = 0;
virtual BOOL LH_VAddr ( DWORD VAddr, WORD & Value ) = 0;
virtual BOOL LW_VAddr ( DWORD VAddr, DWORD & Value ) = 0;
virtual BOOL LD_VAddr ( DWORD VAddr, QWORD & Value ) = 0;
virtual BOOL SB_VAddr ( DWORD VAddr, BYTE Value ) = 0;
virtual BOOL SH_VAddr ( DWORD VAddr, WORD Value ) = 0;
virtual BOOL SW_VAddr ( DWORD VAddr, DWORD Value ) = 0;
virtual BOOL SD_VAddr ( DWORD VAddr, QWORD Value ) = 0;
virtual bool ValidVaddr ( DWORD VAddr ) const = 0;
virtual int MemoryFilter ( DWORD dwExptCode, void * lpExceptionPointer ) = 0;
//Protect the Memory from being written to
virtual void ProtectMemory ( DWORD StartVaddr, DWORD EndVaddr ) = 0;
virtual void UnProtectMemory ( DWORD StartVaddr, DWORD EndVaddr ) = 0;
//Compilation Functions
virtual void ResetMemoryStack ( CBlockSection * Section ) = 0;
virtual void Compile_LB ( int Reg, DWORD Addr, BOOL SignExtend ) = 0;
virtual void Compile_LH ( int Reg, DWORD Addr, BOOL SignExtend ) = 0;
virtual void Compile_LW ( CBlockSection * Section, int Reg, DWORD Addr ) = 0;
virtual void Compile_SB_Const ( BYTE Value, DWORD Addr ) = 0;
virtual void Compile_SB_Register ( int x86Reg, DWORD Addr ) = 0;
virtual void Compile_SH_Const ( WORD Value, DWORD Addr ) = 0;
virtual void Compile_SH_Register ( int x86Reg, DWORD Addr ) = 0;
virtual void Compile_SW_Const ( DWORD Value, DWORD Addr ) = 0;
virtual void Compile_SW_Register ( CBlockSection * Section, int x86Reg, DWORD Addr ) = 0;
};
class CRSP_Plugin;
class CMipsMemoryVM :
public CMipsMemory
#ifdef toremove
,
public CTLB, public CTLB,
public CMemoryLabel/*, public CMemoryLabel/*,
private CPIFRam*/ private CPIFRam*/
#endif
{ {
//Make sure plugins can directly access this information //Make sure plugins can directly access this information
friend CGfxPlugin; friend CGfxPlugin;
@ -33,26 +76,34 @@ class CMipsMemory :
friend CN64System; //Need to manipulate all memory in loading/saveing save state friend CN64System; //Need to manipulate all memory in loading/saveing save state
friend CC_Core; friend CC_Core;
#ifdef toremove
CNotification * const _Notify; //Original Notify member used to notify the user when something occurs CNotification * const _Notify; //Original Notify member used to notify the user when something occurs
CN64System * const _System; CN64System * const _System;
CN64Rom * const _Rom; //Current loaded ROM CN64Rom * const _Rom2; //Current loaded ROM
CRegisters * const _Reg; CRegisters * const _Reg;
CMipsMemory_CallBack * const CBClass; #endif
CMipsMemory_CallBack * const m_CBClass;
#ifdef toremove
//Save Chips accessed by memory //Save Chips accessed by memory
/*CSram * m_Sram; /*CSram * m_Sram;
CFlashRam * m_FlashRam; CFlashRam * m_FlashRam;
bool m_SavesReadOnly; bool m_SavesReadOnly;
//Writing to the rom
bool m_WrittenToRom;
DWORD m_WroteToRom;
*/ */
#endif
//Memory Locations //Memory Locations
BYTE * RDRAM, * DMEM, * IMEM, * ROM, PIF_Ram[0x40]; BYTE * m_RDRAM, * m_DMEM, * m_IMEM, m_PIF_Ram[0x40];
DWORD m_RomFileSize;
DWORD m_AllocatedRdramSize; DWORD m_AllocatedRdramSize;
//Rom Information
bool m_RomMapped;
BYTE * m_Rom;
DWORD m_RomSize;
bool m_RomWrittenTo;
DWORD m_RomWroteValue;
// Recompiler // Recompiler
void ** JumpTable/*, ** DelaySlotTable*/; void ** JumpTable/*, ** DelaySlotTable*/;
BYTE * m_RecompCode; BYTE * m_RecompCode;
@ -66,6 +117,7 @@ class CMipsMemory :
void UpdateHalfLine ( void ); void UpdateHalfLine ( void );
DWORD m_HalfLine; DWORD m_HalfLine;
DWORD m_MemoryStack; DWORD m_MemoryStack;
DWORD m_TempValue;
//Searching memory //Searching memory
BYTE * m_MemoryState; BYTE * m_MemoryState;
@ -75,44 +127,59 @@ class CMipsMemory :
void AllocateSystemMemory ( void ); void AllocateSystemMemory ( void );
void InitalizeSystem ( bool PostPif ); void InitalizeSystem ( bool PostPif );
void FixRDramSize ( void ); void FixRDramSize ( void );
void FreeMemory ( void );
//Loading from/Storing to Non Memory
bool LoadByte_NonMemory ( DWORD PAddr, BYTE * Value )
{
DWORD dwValue;
int Result = r4300i_LB_NonMemory(PAddr,&dwValue, false);
*Value = (BYTE)dwValue;
return Result != 0;
}
bool LoadHalf_NonMemory ( DWORD PAddr, WORD * Value )
{
DWORD dwValue;
int Result = r4300i_LH_NonMemory(PAddr,&dwValue, false);
*Value = (WORD)dwValue;
return Result != 0;
}
bool LoadWord_NonMemory ( DWORD PAddr, DWORD * Value ) { return r4300i_LW_NonMemory(PAddr,Value) != 0; }
bool StoreByte_NonMemory ( DWORD PAddr, BYTE Value ) { return r4300i_SB_NonMemory(PAddr,Value) != 0; }
bool StoreHalf_NonMemory ( DWORD PAddr, WORD Value ) { return r4300i_SH_NonMemory(PAddr,Value) != 0; }
bool StoreWord_NonMemory ( DWORD PAddr, DWORD Value ) { return r4300i_SW_NonMemory(PAddr,Value) != 0; }
//DMAing data around memory
/*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 );
//Fix up
void WriteRDRAMSize ( void );*/
public: public:
CMipsMemory ( CMipsMemory_CallBack * CallBack, CN64System * System, CN64Rom * CurrentRom, CNotification * Notify, CRegisters * RegSet, bool SavesReadOnly = false ); CMipsMemoryVM ( CMipsMemory_CallBack * CallBack );
~CMipsMemory ( void ); ~CMipsMemoryVM ( void );
//Get a pointer to the system registers BOOL Initialize ( void );
CRegisters * SystemRegisters ( void ) { return _Reg; }
BYTE * Rdram ( void );
DWORD RdramSize ( void );
BYTE * Dmem ( void );
BYTE * Imem ( void );
BYTE * PifRam ( void );
BOOL LB_VAddr ( DWORD VAddr, BYTE & Value );
BOOL LH_VAddr ( DWORD VAddr, WORD & Value );
BOOL LW_VAddr ( DWORD VAddr, DWORD & Value );
BOOL LD_VAddr ( DWORD VAddr, QWORD & Value );
BOOL SB_VAddr ( DWORD VAddr, BYTE Value );
BOOL SH_VAddr ( DWORD VAddr, WORD Value );
BOOL SW_VAddr ( DWORD VAddr, DWORD Value );
BOOL SD_VAddr ( DWORD VAddr, QWORD Value );
bool ValidVaddr ( DWORD VAddr ) const;
int MemoryFilter ( DWORD dwExptCode, void * lpExceptionPointer );
//Protect the Memory from being written to
void ProtectMemory ( DWORD StartVaddr, DWORD EndVaddr );
void UnProtectMemory ( DWORD StartVaddr, DWORD EndVaddr );
//Compilation Functions
void ResetMemoryStack ( CBlockSection * Section );
void Compile_LB ( int Reg, DWORD Addr, BOOL SignExtend );
void Compile_LH ( int Reg, DWORD Addr, BOOL SignExtend );
void Compile_LW ( CBlockSection * Section, int Reg, DWORD Addr );
void Compile_SB_Const ( BYTE Value, DWORD Addr );
void Compile_SB_Register ( int x86Reg, DWORD Addr );
void Compile_SH_Const ( WORD Value, DWORD Addr );
void Compile_SH_Register ( int x86Reg, DWORD Addr );
void Compile_SW_Const ( DWORD Value, DWORD Addr );
void Compile_SW_Register ( CBlockSection * Section, int x86Reg, DWORD Addr );
//Functions for TLB notification
void TLB_Mapped ( DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly );
void TLB_Unmaped ( DWORD Vaddr, DWORD Len );
// Recompiler Memory // Recompiler Memory
bool AllocateRecompilerMemory ( bool AllocateJumpTable ); bool AllocateRecompilerMemory ( bool AllocateJumpTable );
@ -122,19 +189,14 @@ public:
void CheckRecompMem ( BYTE * RecompPos ); void CheckRecompMem ( BYTE * RecompPos );
//Accessing Memory #ifdef toremove
bool LoadPhysical32 ( DWORD PAddr, DWORD & Variable, MemorySize Size, bool SignExtend ); bool LoadPhysical32 ( DWORD PAddr, DWORD & Variable, MemorySize Size, bool SignExtend );
bool Load32 ( DWORD VAddr, DWORD & Variable, MemorySize Size, bool SignExtend ); bool Load32 ( DWORD VAddr, DWORD & Variable, MemorySize Size, bool SignExtend );
bool Load64 ( DWORD VAddr, QWORD & Variable, MemorySize Size, bool SignExtend ); bool Load64 ( DWORD VAddr, QWORD & Variable, MemorySize Size, bool SignExtend );
bool Store64 ( DWORD VAddr, QWORD Value, MemorySize Size ); bool Store64 ( DWORD VAddr, QWORD Value, MemorySize Size );
bool StorePhysical64 ( DWORD PAddr, QWORD Value, MemorySize Size ); bool StorePhysical64 ( DWORD PAddr, QWORD Value, MemorySize Size );
//Protect the Memory from being written to
void ProtectMemory ( DWORD StartVaddr, DWORD EndVaddr );
void UnProtectMemory ( DWORD StartVaddr, DWORD EndVaddr );
inline DWORD RomFileSize ( void ) { return m_RomFileSize; } inline DWORD RomFileSize ( void ) { return m_RomFileSize; }
inline DWORD RdramSize ( void ) { return m_AllocatedRdramSize; }
//Win32 exception handler //Win32 exception handler
void MemoryFilterFailed ( char * FailureType, DWORD MipsAddress, DWORD x86Address, DWORD Value); void MemoryFilterFailed ( char * FailureType, DWORD MipsAddress, DWORD x86Address, DWORD Value);
@ -158,4 +220,26 @@ public:
DWORD &StartAddress, DWORD &Len, DWORD &StartAddress, DWORD &Len,
DWORD &OldValue, DWORD &NewValue ); DWORD &OldValue, DWORD &NewValue );
bool SearchForValue (DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len); bool SearchForValue (DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len);
#endif
// Labels
LPCTSTR LabelName ( DWORD Address ) const;
private:
int LB_NonMemory ( DWORD PAddr, DWORD * Value, BOOL SignExtend );
int LH_NonMemory ( DWORD PAddr, DWORD * Value, int SignExtend );
int LW_NonMemory ( DWORD PAddr, DWORD * Value );
int SB_NonMemory ( DWORD PAddr, BYTE Value );
int SH_NonMemory ( DWORD PAddr, WORD Value );
int SW_NonMemory ( DWORD PAddr, DWORD Value );
mutable char m_strLabelName[100];
//BIG look up table to quickly translate the tlb to real mem address
DWORD * m_TLB_ReadMap;
DWORD * m_TLB_WriteMap;
}; };
extern void ** JumpTable;
extern BYTE *RecompCode, *RecompPos;

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,13 @@
#include "..\..\N64 System.h" #include "..\..\N64 System.h"
extern CLog TlbLog; extern CLog TlbLog;
COpcodeAnalysis::COpcodeAnalysis(CMipsMemory * MMU, OPCODE &opcode) : COpcodeAnalysis::COpcodeAnalysis(OPCODE &opcode) :
m_opcode(opcode),_MMU(MMU),_Notify(Notify()) m_opcode(opcode)
{ {
} }
bool COpcodeAnalysis::DelaySlotEffectsCompare (DWORD Reg1, DWORD Reg2) { bool COpcodeAnalysis::DelaySlotEffectsCompare (DWORD Reg1, DWORD Reg2) {
COpcode DelayOp(_MMU,m_opcode.VirtualAddress + 4); COpcode DelayOp(m_opcode.VirtualAddress + 4);
switch (DelayOp.m_opcode.op) { switch (DelayOp.m_opcode.op) {
case R4300i_SPECIAL: case R4300i_SPECIAL:
@ -197,7 +197,7 @@ bool COpcodeAnalysis::DelaySlotEffectsJump (void) {
case R4300i_COP1_BC_BCFL: case R4300i_COP1_BC_BCFL:
case R4300i_COP1_BC_BCTL: case R4300i_COP1_BC_BCTL:
{ {
COpcode DelayOp(_MMU,m_opcode.VirtualAddress + 4); COpcode DelayOp(m_opcode.VirtualAddress + 4);
if (DelayOp.m_opcode.op == R4300i_CP1) { if (DelayOp.m_opcode.op == R4300i_CP1) {
if (DelayOp.m_opcode.fmt == R4300i_COP1_S && (DelayOp.m_opcode.funct & 0x30) == 0x30 ) { if (DelayOp.m_opcode.fmt == R4300i_COP1_S && (DelayOp.m_opcode.funct & 0x30) == 0x30 ) {
@ -430,7 +430,7 @@ stdstr COpcodeAnalysis::FullName(bool * MultipleOps) {
DWORD Value = m_opcode.immediate * 0x10000; DWORD Value = m_opcode.immediate * 0x10000;
int Register = m_opcode.rt; int Register = m_opcode.rt;
COpcode NextOp(_MMU,m_opcode.VirtualAddress + 4); COpcode NextOp(m_opcode.VirtualAddress + 4);
if ((NextOp.m_opcode.op == R4300i_ADDIU || NextOp.m_opcode.op == R4300i_ORI) && if ((NextOp.m_opcode.op == R4300i_ADDIU || NextOp.m_opcode.op == R4300i_ORI) &&
NextOp.m_opcode.rt == m_opcode.rt && NextOp.m_opcode.rs == m_opcode.rt) NextOp.m_opcode.rt == m_opcode.rt && NextOp.m_opcode.rs == m_opcode.rt)
{ {
@ -458,7 +458,7 @@ stdstr COpcodeAnalysis::FullName(bool * MultipleOps) {
OpParam = stdstr(Param); OpParam = stdstr(Param);
} }
_Notify.BreakPoint(__FILE__,__LINE__); _Notify->BreakPoint(__FILE__,__LINE__);
// if (OpName.length() == 0) { OpName = OpcodeName(); } // if (OpName.length() == 0) { OpName = OpcodeName(); }
// if (OpParam.length() == 0) { OpParam = OpcodeParam(); } // if (OpParam.length() == 0) { OpParam = OpcodeParam(); }
while (OpName.length() < 7) { OpName += " "; } while (OpName.length() < 7) { OpName += " "; }
@ -922,26 +922,26 @@ void COpcodeAnalysis::OpcodeParam(char * CommandName)
break; break;
case R4300i_J: case R4300i_J:
case R4300i_JAL: case R4300i_JAL:
sprintf(CommandName,"%s",_MMU->LabelName((m_opcode.VirtualAddress & 0xF0000000) + (m_opcode.target << 2)).c_str()); sprintf(CommandName,"%s",_Labels->LabelName((m_opcode.VirtualAddress & 0xF0000000) + (m_opcode.target << 2)));
break; break;
case R4300i_BEQ: case R4300i_BEQ:
if (m_opcode.rs == 0 && m_opcode.rt == 0) { if (m_opcode.rs == 0 && m_opcode.rt == 0) {
sprintf(CommandName,"%s", _MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); sprintf(CommandName,"%s", _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
} else if (m_opcode.rs == 0 || m_opcode.rt == 0) { } else if (m_opcode.rs == 0 || m_opcode.rt == 0) {
sprintf(CommandName,"%s, %s", GPR_Name[m_opcode.rs == 0 ? m_opcode.rt : m_opcode.rs ], sprintf(CommandName,"%s, %s", GPR_Name[m_opcode.rs == 0 ? m_opcode.rt : m_opcode.rs ],
_MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
} else { } else {
sprintf(CommandName,"%s, %s, %s", GPR_Name[m_opcode.rs], GPR_Name[m_opcode.rt], sprintf(CommandName,"%s, %s, %s", GPR_Name[m_opcode.rs], GPR_Name[m_opcode.rt],
_MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
} }
break; break;
case R4300i_BNE: case R4300i_BNE:
if ((m_opcode.rs == 0) ^ (m_opcode.rt == 0)){ if ((m_opcode.rs == 0) ^ (m_opcode.rt == 0)){
sprintf(CommandName,"%s, %s", GPR_Name[m_opcode.rs == 0 ? m_opcode.rt : m_opcode.rs ], sprintf(CommandName,"%s, %s", GPR_Name[m_opcode.rs == 0 ? m_opcode.rt : m_opcode.rs ],
_MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
} else { } else {
sprintf(CommandName,"%s, %s, %s", GPR_Name[m_opcode.rs], GPR_Name[m_opcode.rt], sprintf(CommandName,"%s, %s, %s", GPR_Name[m_opcode.rs], GPR_Name[m_opcode.rt],
_MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
} }
break; break;
case R4300i_REGIMM: case R4300i_REGIMM:
@ -952,14 +952,14 @@ void COpcodeAnalysis::OpcodeParam(char * CommandName)
case R4300i_REGIMM_BLTZAL: case R4300i_REGIMM_BLTZAL:
case R4300i_REGIMM_BLTZALL: case R4300i_REGIMM_BLTZALL:
case R4300i_REGIMM_BGEZALL: case R4300i_REGIMM_BGEZALL:
sprintf(CommandName,"%s, %s", GPR_Name[m_opcode.rs], _MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); sprintf(CommandName,"%s, %s", GPR_Name[m_opcode.rs], _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
break; break;
case R4300i_REGIMM_BGEZ: case R4300i_REGIMM_BGEZ:
case R4300i_REGIMM_BGEZAL: case R4300i_REGIMM_BGEZAL:
if (m_opcode.rs == 0) { if (m_opcode.rs == 0) {
sprintf(CommandName,"%s", _MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); sprintf(CommandName,"%s", _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
} else { } else {
sprintf(CommandName,"%s, %s", GPR_Name[m_opcode.rs], _MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); sprintf(CommandName,"%s, %s", GPR_Name[m_opcode.rs], _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
} }
break; break;
case R4300i_REGIMM_TGEI: case R4300i_REGIMM_TGEI:
@ -974,7 +974,7 @@ void COpcodeAnalysis::OpcodeParam(char * CommandName)
break; break;
case R4300i_BLEZ: case R4300i_BLEZ:
case R4300i_BGTZ: case R4300i_BGTZ:
sprintf(CommandName,"%s, %s",GPR_Name[m_opcode.rs], _MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); sprintf(CommandName,"%s, %s",GPR_Name[m_opcode.rs], _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
break; break;
case R4300i_ADDI: case R4300i_ADDI:
case R4300i_ADDIU: case R4300i_ADDIU:
@ -1029,7 +1029,7 @@ void COpcodeAnalysis::OpcodeParam(char * CommandName)
case R4300i_COP1_BC_BCT: case R4300i_COP1_BC_BCT:
case R4300i_COP1_BC_BCFL: case R4300i_COP1_BC_BCFL:
case R4300i_COP1_BC_BCTL: case R4300i_COP1_BC_BCTL:
sprintf(CommandName,"%s",_MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); sprintf(CommandName,"%s",_Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
break; break;
} }
break; break;
@ -1086,27 +1086,27 @@ void COpcodeAnalysis::OpcodeParam(char * CommandName)
break; break;
case R4300i_BEQL: case R4300i_BEQL:
if (m_opcode.rs == m_opcode.rt) { if (m_opcode.rs == m_opcode.rt) {
sprintf(CommandName,"%s", _MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); sprintf(CommandName,"%s", _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
} else if ((m_opcode.rs == 0) ^ (m_opcode.rt == 0)){ } else if ((m_opcode.rs == 0) ^ (m_opcode.rt == 0)){
sprintf(CommandName,"%s, %s", GPR_Name[m_opcode.rs == 0 ? m_opcode.rt : m_opcode.rs ], sprintf(CommandName,"%s, %s", GPR_Name[m_opcode.rs == 0 ? m_opcode.rt : m_opcode.rs ],
_MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
} else { } else {
sprintf(CommandName,"%s, %s, %s", GPR_Name[m_opcode.rs], GPR_Name[m_opcode.rt], sprintf(CommandName,"%s, %s, %s", GPR_Name[m_opcode.rs], GPR_Name[m_opcode.rt],
_MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
} }
break; break;
case R4300i_BNEL: case R4300i_BNEL:
if ((m_opcode.rs == 0) ^ (m_opcode.rt == 0)){ if ((m_opcode.rs == 0) ^ (m_opcode.rt == 0)){
sprintf(CommandName,"%s, %s", GPR_Name[m_opcode.rs == 0 ? m_opcode.rt : m_opcode.rs ], sprintf(CommandName,"%s, %s", GPR_Name[m_opcode.rs == 0 ? m_opcode.rt : m_opcode.rs ],
_MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
} else { } else {
sprintf(CommandName,"%s, %s, %s", GPR_Name[m_opcode.rs], GPR_Name[m_opcode.rt], sprintf(CommandName,"%s, %s, %s", GPR_Name[m_opcode.rs], GPR_Name[m_opcode.rt],
_MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
} }
break; break;
case R4300i_BLEZL: case R4300i_BLEZL:
case R4300i_BGTZL: case R4300i_BGTZL:
sprintf(CommandName,"%s, %s",GPR_Name[m_opcode.rs], _MMU->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4).c_str()); sprintf(CommandName,"%s, %s",GPR_Name[m_opcode.rs], _Labels->LabelName(m_opcode.VirtualAddress + ((short)m_opcode.offset << 2) + 4));
break; break;
case R4300i_DADDI: case R4300i_DADDI:
case R4300i_DADDIU: case R4300i_DADDIU:

View File

@ -2,11 +2,9 @@ class COpcodeAnalysis :
private CRegistersName private CRegistersName
{ {
OPCODE &m_opcode; OPCODE &m_opcode;
CMipsMemory * const _MMU;
CNotification & _Notify;
public: public:
COpcodeAnalysis(CMipsMemory * MMU, OPCODE &opcode); COpcodeAnalysis(OPCODE &opcode);
//Functions dealing with the name of the opcode //Functions dealing with the name of the opcode
const char * OpcodeName ( void ); const char * OpcodeName ( void );

View File

@ -22,10 +22,8 @@ DWORD const COpcode::SWR_MASK[4] = { 0x00FFFFFF,0x0000FFFF,0x000000FF,0x00000000
int const COpcode::WL_SHIFT[4] = { 0, 8, 16, 24 }; int const COpcode::WL_SHIFT[4] = { 0, 8, 16, 24 };
int const COpcode::WR_SHIFT[4] = { 24, 16 , 8, 0 }; int const COpcode::WR_SHIFT[4] = { 24, 16 , 8, 0 };
COpcode::COpcode ( CMipsMemory * MMU, DWORD VirtualAddress ): COpcode::COpcode ( DWORD VirtualAddress ):
COpcodeAnalysis(MMU,m_opcode), COpcodeAnalysis(m_opcode),
_MMU(MMU),
_Reg(MMU->SystemRegisters()),
m_OpLen(OpCode_Size), m_OpLen(OpCode_Size),
m_OpcodeCount(_Settings->LoadDword(Game_CounterFactor)), m_OpcodeCount(_Settings->LoadDword(Game_CounterFactor)),
m_FixedOpcodeCount(_Settings->LoadDword(Game_CounterFactor) != 0) m_FixedOpcodeCount(_Settings->LoadDword(Game_CounterFactor) != 0)
@ -88,7 +86,7 @@ bool COpcode::Next (void) {
Notify().BreakPoint(__FILE__,__LINE__); Notify().BreakPoint(__FILE__,__LINE__);
} }
if (!_MMU->Load32(m_opcode.VirtualAddress,m_opcode.Hex,_32Bit,false)) { if (!_MMU->LW_VAddr(m_opcode.VirtualAddress,m_opcode.Hex)) {
return false; return false;
} }
return true; return true;

View File

@ -155,9 +155,6 @@ class CRecompilerOps;
class COpcode : public COpcodeAnalysis { class COpcode : public COpcodeAnalysis {
friend CRecompilerOps; //Can manipulate how the opcode moves friend CRecompilerOps; //Can manipulate how the opcode moves
CMipsMemory * const _MMU;
CRegisters * const _Reg;
DWORD const m_OpLen; //Length of the current opcode (MIPS will always be 4) DWORD const m_OpLen; //Length of the current opcode (MIPS will always be 4)
bool const m_FixedOpcodeCount; //Is the opcode count fixed or is it variable bool const m_FixedOpcodeCount; //Is the opcode count fixed or is it variable
float const m_OpcodeCount; //how many cycles is the fixed opcode count float const m_OpcodeCount; //how many cycles is the fixed opcode count
@ -167,7 +164,7 @@ class COpcode : public COpcodeAnalysis {
public: public:
//Constructor/deconstructor //Constructor/deconstructor
COpcode ( CMipsMemory * MMU, DWORD VirtualAddress ); COpcode ( DWORD VirtualAddress );
//Geting/changing details about the opcode stored //Geting/changing details about the opcode stored
bool Next ( void ); //move to the next opcode, if it is a jump returns true bool Next ( void ); //move to the next opcode, if it is a jump returns true

View File

@ -136,7 +136,7 @@ SigProcessor_InterfaceReg::SigProcessor_InterfaceReg(DWORD * _SignalProcessorInt
{ {
} }
void CRegisters::InitalizeR4300iRegisters (CMipsMemory * MMU, bool PostPif, int Country, CICChip CIC_Chip) void CRegisters::InitalizeR4300iRegisters (CMipsMemory & MMU, bool PostPif, int Country, CICChip CIC_Chip)
{ {
//Reset General Registers //Reset General Registers
memset(GPR,0,sizeof(GPR)); memset(GPR,0,sizeof(GPR));
@ -214,7 +214,7 @@ void CRegisters::InitalizeR4300iRegisters (CMipsMemory * MMU, bool PostPif, int
GPR[24].DW=0x0000000000000000; GPR[24].DW=0x0000000000000000;
break; break;
case CIC_NUS_6105: case CIC_NUS_6105:
MMU->Store64(0xA4001004,0xBDA807FC,_32Bit); MMU.SW_VAddr(0xA4001004,0xBDA807FC);
GPR[5].DW=0xFFFFFFFFDECAAAD1; GPR[5].DW=0xFFFFFFFFDECAAAD1;
GPR[14].DW=0x000000000CF85C13; GPR[14].DW=0x000000000CF85C13;
GPR[24].DW=0x0000000000000002; GPR[24].DW=0x0000000000000002;
@ -242,7 +242,7 @@ void CRegisters::InitalizeR4300iRegisters (CMipsMemory * MMU, bool PostPif, int
GPR[14].DW=0x000000005BACA1DF; GPR[14].DW=0x000000005BACA1DF;
break; break;
case CIC_NUS_6105: case CIC_NUS_6105:
MMU->Store64(0xA4001004,0x8DA807FC,_32Bit); MMU.SW_VAddr(0xA4001004,0x8DA807FC);
GPR[5].DW=0x000000005493FB9A; GPR[5].DW=0x000000005493FB9A;
GPR[14].DW=0xFFFFFFFFC2C20384; GPR[14].DW=0xFFFFFFFFC2C20384;
case CIC_NUS_6106: case CIC_NUS_6106:
@ -283,13 +283,13 @@ void CRegisters::InitalizeR4300iRegisters (CMipsMemory * MMU, bool PostPif, int
GPR[25].DW=0xFFFFFFFF825B21C9; GPR[25].DW=0xFFFFFFFF825B21C9;
break; break;
case CIC_NUS_6105: case CIC_NUS_6105:
MMU->Store64(0xA4001000,0x3C0DBFC0,_32Bit); MMU.SW_VAddr(0xA4001000,0x3C0DBFC0);
MMU->Store64(0xA4001008,0x25AD07C0,_32Bit); MMU.SW_VAddr(0xA4001008,0x25AD07C0);
MMU->Store64(0xA400100C,0x31080080,_32Bit); MMU.SW_VAddr(0xA400100C,0x31080080);
MMU->Store64(0xA4001010,0x5500FFFC,_32Bit); MMU.SW_VAddr(0xA4001010,0x5500FFFC);
MMU->Store64(0xA4001014,0x3C0DBFC0,_32Bit); MMU.SW_VAddr(0xA4001014,0x3C0DBFC0);
MMU->Store64(0xA4001018,0x8DA80024,_32Bit); MMU.SW_VAddr(0xA4001018,0x8DA80024);
MMU->Store64(0xA400101C,0x3C0BB000,_32Bit); MMU.SW_VAddr(0xA400101C,0x3C0BB000);
GPR[1].DW=0x0000000000000000; GPR[1].DW=0x0000000000000000;
GPR[2].DW=0xFFFFFFFFF58B0FBF; GPR[2].DW=0xFFFFFFFFF58B0FBF;
GPR[3].DW=0xFFFFFFFFF58B0FBF; GPR[3].DW=0xFFFFFFFFF58B0FBF;
@ -354,7 +354,7 @@ void CRegisters::CheckInterrupts ( void ) {
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) { return; } if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) { return; }
if (( STATUS_REGISTER & FAKE_CAUSE_REGISTER & 0xFF00) != 0) { if (( STATUS_REGISTER & FAKE_CAUSE_REGISTER & 0xFF00) != 0) {
_System->ExternalEvent(ExecuteInterrupt); _N64System->ExternalEvent(ExecuteInterrupt);
} }
} }

View File

@ -164,10 +164,6 @@ enum {
MI_CLR_RDRAM = 0x1000, /* Bit 12: clear RDRAM reg */ MI_CLR_RDRAM = 0x1000, /* Bit 12: clear RDRAM reg */
MI_SET_RDRAM = 0x2000, /* Bit 13: set RDRAM reg mode */ MI_SET_RDRAM = 0x2000, /* Bit 13: set RDRAM reg mode */
MI_MODE_INIT = 0x0080, /* Bit 7: init mode */
MI_MODE_EBUS = 0x0100, /* Bit 8: ebus test mode */
MI_MODE_RDRAM = 0x0200, /* Bit 9: RDRAM reg mode */
//Flags for writing to MI_INTR_MASK_REG //Flags for writing to MI_INTR_MASK_REG
MI_INTR_MASK_CLR_SP = 0x0001, /* Bit 0: clear SP mask */ MI_INTR_MASK_CLR_SP = 0x0001, /* Bit 0: clear SP mask */
MI_INTR_MASK_SET_SP = 0x0002, /* Bit 1: set SP mask */ MI_INTR_MASK_SET_SP = 0x0002, /* Bit 1: set SP mask */
@ -318,47 +314,47 @@ public:
//Signal Processor interface flags //Signal Processor interface flags
enum { enum {
SP_CLR_HALT = 0x00001, /* Bit 0: clear halt */ SP_CLR_HALT = 0x00001, /* Bit 0: clear halt */
SP_SET_HALT = 0x00002, /* Bit 1: set halt */ SP_SET_HALT = 0x00002, /* Bit 1: set halt */
SP_CLR_BROKE = 0x00004, /* Bit 2: clear broke */ SP_CLR_BROKE = 0x00004, /* Bit 2: clear broke */
SP_CLR_INTR = 0x00008, /* Bit 3: clear intr */ SP_CLR_INTR = 0x00008, /* Bit 3: clear intr */
SP_SET_INTR = 0x00010, /* Bit 4: set intr */ SP_SET_INTR = 0x00010, /* Bit 4: set intr */
SP_CLR_SSTEP = 0x00020, /* Bit 5: clear sstep */ SP_CLR_SSTEP = 0x00020, /* Bit 5: clear sstep */
SP_SET_SSTEP = 0x00040, /* Bit 6: set sstep */ SP_SET_SSTEP = 0x00040, /* Bit 6: set sstep */
SP_CLR_INTR_BREAK = 0x00080, /* Bit 7: clear intr on break */ SP_CLR_INTR_BREAK = 0x00080, /* Bit 7: clear intr on break */
SP_SET_INTR_BREAK = 0x00100, /* Bit 8: set intr on break */ SP_SET_INTR_BREAK = 0x00100, /* Bit 8: set intr on break */
SP_CLR_SIG0 = 0x00200, /* Bit 9: clear signal 0 */ SP_CLR_SIG0 = 0x00200, /* Bit 9: clear signal 0 */
SP_SET_SIG0 = 0x00400, /* Bit 10: set signal 0 */ SP_SET_SIG0 = 0x00400, /* Bit 10: set signal 0 */
SP_CLR_SIG1 = 0x00800, /* Bit 11: clear signal 1 */ SP_CLR_SIG1 = 0x00800, /* Bit 11: clear signal 1 */
SP_SET_SIG1 = 0x01000, /* Bit 12: set signal 1 */ SP_SET_SIG1 = 0x01000, /* Bit 12: set signal 1 */
SP_CLR_SIG2 = 0x02000, /* Bit 13: clear signal 2 */ SP_CLR_SIG2 = 0x02000, /* Bit 13: clear signal 2 */
SP_SET_SIG2 = 0x04000, /* Bit 14: set signal 2 */ SP_SET_SIG2 = 0x04000, /* Bit 14: set signal 2 */
SP_CLR_SIG3 = 0x08000, /* Bit 15: clear signal 3 */ SP_CLR_SIG3 = 0x08000, /* Bit 15: clear signal 3 */
SP_SET_SIG3 = 0x10000, /* Bit 16: set signal 3 */ SP_SET_SIG3 = 0x10000, /* Bit 16: set signal 3 */
SP_CLR_SIG4 = 0x20000, /* Bit 17: clear signal 4 */ SP_CLR_SIG4 = 0x20000, /* Bit 17: clear signal 4 */
SP_SET_SIG4 = 0x40000, /* Bit 18: set signal 4 */ SP_SET_SIG4 = 0x40000, /* Bit 18: set signal 4 */
SP_CLR_SIG5 = 0x80000, /* Bit 19: clear signal 5 */ SP_CLR_SIG5 = 0x80000, /* Bit 19: clear signal 5 */
SP_SET_SIG5 = 0x100000, /* Bit 20: set signal 5 */ SP_SET_SIG5 = 0x100000, /* Bit 20: set signal 5 */
SP_CLR_SIG6 = 0x200000, /* Bit 21: clear signal 6 */ SP_CLR_SIG6 = 0x200000, /* Bit 21: clear signal 6 */
SP_SET_SIG6 = 0x400000, /* Bit 22: set signal 6 */ SP_SET_SIG6 = 0x400000, /* Bit 22: set signal 6 */
SP_CLR_SIG7 = 0x800000, /* Bit 23: clear signal 7 */ SP_CLR_SIG7 = 0x800000, /* Bit 23: clear signal 7 */
SP_SET_SIG7 = 0x1000000, /* Bit 24: set signal 7 */ SP_SET_SIG7 = 0x1000000, /* Bit 24: set signal 7 */
SP_STATUS_HALT = 0x001, /* Bit 0: halt */ SP_STATUS_HALT = 0x001, /* Bit 0: halt */
SP_STATUS_BROKE = 0x002, /* Bit 1: broke */ SP_STATUS_BROKE = 0x002, /* Bit 1: broke */
SP_STATUS_DMA_BUSY = 0x004, /* Bit 2: dma busy */ SP_STATUS_DMA_BUSY = 0x004, /* Bit 2: dma busy */
SP_STATUS_DMA_FULL = 0x008, /* Bit 3: dma full */ SP_STATUS_DMA_FULL = 0x008, /* Bit 3: dma full */
SP_STATUS_IO_FULL = 0x010, /* Bit 4: io full */ SP_STATUS_IO_FULL = 0x010, /* Bit 4: io full */
SP_STATUS_SSTEP = 0x020, /* Bit 5: single step */ SP_STATUS_SSTEP = 0x020, /* Bit 5: single step */
SP_STATUS_INTR_BREAK= 0x040, /* Bit 6: interrupt on break */ SP_STATUS_INTR_BREAK = 0x040, /* Bit 6: interrupt on break */
SP_STATUS_SIG0 = 0x080, /* Bit 7: signal 0 set */ SP_STATUS_SIG0 = 0x080, /* Bit 7: signal 0 set */
SP_STATUS_SIG1 = 0x100, /* Bit 8: signal 1 set */ SP_STATUS_SIG1 = 0x100, /* Bit 8: signal 1 set */
SP_STATUS_SIG2 = 0x200, /* Bit 9: signal 2 set */ SP_STATUS_SIG2 = 0x200, /* Bit 9: signal 2 set */
SP_STATUS_SIG3 = 0x400, /* Bit 10: signal 3 set */ SP_STATUS_SIG3 = 0x400, /* Bit 10: signal 3 set */
SP_STATUS_SIG4 = 0x800, /* Bit 11: signal 4 set */ SP_STATUS_SIG4 = 0x800, /* Bit 11: signal 4 set */
SP_STATUS_SIG5 = 0x1000, /* Bit 12: signal 5 set */ SP_STATUS_SIG5 = 0x1000, /* Bit 12: signal 5 set */
SP_STATUS_SIG6 = 0x2000, /* Bit 13: signal 6 set */ SP_STATUS_SIG6 = 0x2000, /* Bit 13: signal 6 set */
SP_STATUS_SIG7 = 0x4000, /* Bit 14: signal 7 set */ SP_STATUS_SIG7 = 0x4000, /* Bit 14: signal 7 set */
}; };
//Peripheral Interface //Peripheral Interface
@ -426,21 +422,15 @@ class CRegisters:
public CSystemTimer, public CSystemTimer,
public CRegistersName public CRegistersName
{ {
CN64System * const _System;
CNotification * const _Notify;
public: public:
//Constructor/Deconstructor //Constructor/Deconstructor
CRegisters ( CN64System * System, CNotification * Notify ) : CRegisters ( void ) :
CSystemTimer(System,Notify),
CP0registers(CP0), CP0registers(CP0),
AudioInterfaceReg(Audio_Interface), AudioInterfaceReg(Audio_Interface),
Mips_InterfaceReg(Mips_Interface), Mips_InterfaceReg(Mips_Interface),
Video_InterfaceReg(Video_Interface), Video_InterfaceReg(Video_Interface),
SigProcessor_InterfaceReg(SigProcessor_Interface), SigProcessor_InterfaceReg(SigProcessor_Interface),
DisplayControlReg(Display_ControlReg), DisplayControlReg(Display_ControlReg)
_System(System),
_Notify(Notify)
{ {
FixFpuLocations(); FixFpuLocations();
} }
@ -473,7 +463,7 @@ public:
DWORD AudioIntrReg; DWORD AudioIntrReg;
void InitalizeR4300iRegisters ( CMipsMemory * MMU, bool PostPif, int Country, CICChip CIC_Chip); void InitalizeR4300iRegisters ( CMipsMemory & MMU, bool PostPif, int Country, CICChip CIC_Chip);
void CheckInterrupts ( void ); void CheckInterrupts ( void );
void ExecuteCopUnusableException ( bool DelaySlot, int Coprocessor ); void ExecuteCopUnusableException ( bool DelaySlot, int Coprocessor );
void ExecuteInterruptException ( bool DelaySlot ); void ExecuteInterruptException ( bool DelaySlot );

View File

@ -2,9 +2,7 @@
extern CLog TlbLog; extern CLog TlbLog;
CSystemTimer::CSystemTimer(CN64System * System, CNotification * Notify) : CSystemTimer::CSystemTimer( void )
_System(System),
_Notify(Notify)
{ {
ResetTimer(50000); ResetTimer(50000);
} }
@ -35,11 +33,11 @@ void CSystemTimer::CheckTimer (void) {
// TlbLog.Log("%s: Timer = %d, CurrentTimerType = %d",_System->GetRecompiler() ? "Recomp" : "Interp",Timer, CurrentTimerType); // TlbLog.Log("%s: Timer = %d, CurrentTimerType = %d",_System->GetRecompiler() ? "Recomp" : "Interp",Timer, CurrentTimerType);
switch (CurrentTimerType) { switch (CurrentTimerType) {
case ViTimer: _System->ExternalEvent(TimerDone_Vi); break; case ViTimer: _N64System->ExternalEvent(TimerDone_Vi); break;
case AiTimer: _System->ExternalEvent(TimerDone_Ai); break; case AiTimer: _N64System->ExternalEvent(TimerDone_Ai); break;
case AiTimerDMA: _System->ExternalEvent(TimerDone_AiDMA); break; case AiTimerDMA: _N64System->ExternalEvent(TimerDone_AiDMA); break;
case RSPTimerDlist:_System->ExternalEvent(TimerDone_RSPDlist); break; case RSPTimerDlist:_N64System->ExternalEvent(TimerDone_RSPDlist); break;
case CompareTimer: _System->ExternalEvent(TimerDone_Compare); break; case CompareTimer: _N64System->ExternalEvent(TimerDone_Compare); break;
default: default:
_Notify->BreakPoint(__FILE__,__LINE__); _Notify->BreakPoint(__FILE__,__LINE__);
} }

View File

@ -7,19 +7,17 @@ typedef struct {
class CC_Core; class CC_Core;
class CSystemTimer { class CSystemTimer
{
friend CC_Core; friend CC_Core;
CN64System * const _System; //Main system being run .. pass back any times that occur
CNotification * const _Notify;
TIMER_DETAILS TimerDetatils[MaxTimer]; TIMER_DETAILS TimerDetatils[MaxTimer];
int Timer; //How many cycles to the next event int Timer; //How many cycles to the next event
TimerType CurrentTimerType; TimerType CurrentTimerType;
void FixTimers ( void ); void FixTimers ( void );
public: public:
CSystemTimer ( CN64System * System, CNotification * Notify ); CSystemTimer ( void );
void CheckTimer ( void ); void CheckTimer ( void );
void ChangeTimerRelative ( TimerType Type, DWORD Cycles ); void ChangeTimerRelative ( TimerType Type, DWORD Cycles );
void ChangeTimerFixed ( TimerType Type, DWORD Cycles ); void ChangeTimerFixed ( TimerType Type, DWORD Cycles );

View File

@ -1,130 +1,116 @@
typedef struct {
bool EntryDefined;
union {
unsigned long Value;
unsigned char A[4];
struct {
unsigned zero : 13;
unsigned Mask : 12;
unsigned zero2 : 7;
} ;
} PageMask;
union {
unsigned long Value;
unsigned char A[4];
struct {
unsigned ASID : 8;
unsigned Zero : 4;
unsigned G : 1;
unsigned VPN2 : 19;
};
} EntryHi;
union {
unsigned long Value;
unsigned char A[4];
struct {
unsigned GLOBAL: 1;
unsigned V : 1;
unsigned D : 1;
unsigned C : 3;
unsigned PFN : 20;
unsigned ZERO: 6;
} ;
} EntryLo0;
union {
unsigned long Value;
unsigned char A[4];
struct {
unsigned GLOBAL: 1;
unsigned V : 1;
unsigned D : 1;
unsigned C : 3;
unsigned PFN : 20;
unsigned ZERO: 6;
} ;
} EntryLo1;
} TLB;
typedef struct {
DWORD VSTART;
DWORD VEND;
DWORD PHYSSTART;
DWORD PHYSEND;
bool VALID;
bool DIRTY;
bool GLOBAL;
bool ValidEntry;
bool Random;
bool Probed;
} FASTTLB;
class CRecompilerOps;
class CC_Core; class CC_Core;
class CDebugTlb; class CDebugTlb;
class CMipsTLB_CallBack { class CTLB_CB
public: {
public:
//Protected memory has been written to, returns true if that memory has been unprotected virtual void TLB_Mapped ( DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly ) = 0;
virtual void TLB_Changed ( void ) = 0; virtual void TLB_Unmaped ( DWORD VAddr, DWORD Len ) = 0;
virtual void TLB_Unmapping ( int TlbEntry, int FastTlbEntry, DWORD Vaddr, DWORD Len ) = 0; virtual void TLB_Changed ( void ) = 0;
}; };
class CTLB class CTLB
{ {
friend CN64System; //Need to manipulate all variables in loading/saveing save state public:
friend CRecompilerOps; // so can manipulate for ops typedef struct {
friend CC_Core; bool EntryDefined;
union {
unsigned long Value;
unsigned char A[4];
struct {
unsigned zero : 13;
unsigned Mask : 12;
unsigned zero2 : 7;
} ;
} PageMask;
union {
unsigned long Value;
unsigned char A[4];
struct {
unsigned ASID : 8;
unsigned Zero : 4;
unsigned G : 1;
unsigned VPN2 : 19;
};
} EntryHi;
union {
unsigned long Value;
unsigned char A[4];
struct {
unsigned GLOBAL: 1;
unsigned V : 1;
unsigned D : 1;
unsigned C : 3;
unsigned PFN : 20;
unsigned ZERO: 6;
} ;
} EntryLo0;
union {
unsigned long Value;
unsigned char A[4];
struct {
unsigned GLOBAL: 1;
unsigned V : 1;
unsigned D : 1;
unsigned C : 3;
unsigned PFN : 20;
unsigned ZERO: 6;
} ;
} EntryLo1;
} TLB_ENTRY;
private:
typedef struct {
DWORD VSTART;
DWORD VEND;
DWORD PHYSSTART;
DWORD PHYSEND;
DWORD Length;
bool VALID;
bool DIRTY;
bool GLOBAL;
bool ValidEntry;
bool Random;
bool Probed;
} FASTTLB;
//friend CC_Core;
friend CDebugTlb; // enable debug window to read class friend CDebugTlb; // enable debug window to read class
BYTE * const &m_BasePAddr; //Base Physical Address (eg RDRAM) CTLB_CB * const m_CB;
CMipsTLB_CallBack * const CBClass;
//Registers
DWORD & PROGRAM_COUNTER;
DWORD & INDEX_REGISTER;
DWORD & PAGE_MASK_REGISTER;
DWORD & ENTRYHI_REGISTER;
DWORD & ENTRYLO0_REGISTER;
DWORD & ENTRYLO1_REGISTER;
TLB tlb[32]; TLB_ENTRY m_tlb[32];
FASTTLB FastTlb[64]; FASTTLB m_FastTlb[64];
//BIG look up table to quickly translate the tlb to real mem address
DWORD * TLB_ReadMap;
DWORD * TLB_WriteMap;
void SetupTLB_Entry ( int index, bool Random ); void SetupTLB_Entry ( int index, bool Random );
public: public:
CTLB ( CMipsTLB_CallBack * CallBack, BYTE * &BasePAddr, CRegisters *const & Registers ); CTLB ( CTLB_CB * CallBack );
~CTLB ( void ); ~CTLB ( void );
void TLB_Reset ( bool InvalidateTLB ); void Reset ( bool InvalidateTLB );
//Used by opcodes of the same name to manipulate the tlb (reads the registers) //Used by opcodes of the same name to manipulate the tlb (reads the registers)
void TLB_Probe ( void ); void Probe ( void );
void TLB_ReadEntry ( void ); void ReadEntry ( void );
void TLB_WriteEntry ( int index, bool Random ); void WriteEntry ( int index, bool Random );
//See if a VAddr has an entry to translate to a PAddr //See if a VAddr has an entry to translate to a PAddr
bool TLB_AddressDefined ( DWORD VAddr ); bool AddressDefined ( DWORD VAddr );
//Change the Virtual address to a Phyiscal Address //Change the Virtual address to a Phyiscal Address
inline bool TranslateVaddr ( DWORD VAddr, DWORD &PAddr) const /*inline bool TranslateVaddr ( DWORD VAddr, DWORD &PAddr) const
{ {
//Change the Virtual address to a Phyiscal Address //Change the Virtual address to a Phyiscal Address
if (TLB_ReadMap[VAddr >> 12] == 0) { return false; } if (TLB_ReadMap[VAddr >> 12] == 0) { return false; }
@ -144,10 +130,7 @@ public:
// Find a matching Virtual Addres from a phyiscal one // Find a matching Virtual Addres from a phyiscal one
bool PAddrToVAddr ( DWORD PAddr, DWORD & VAddr, DWORD & Index ); bool PAddrToVAddr ( DWORD PAddr, DWORD & VAddr, DWORD & Index );
//find out information about the tlb
bool TLB_EntryUsed ( int index ); //Test to see if TLB entry is valid
int TLB_UnusedEntry ( int MinIndx );//Find a valid entry above MinIndx
//see if the Vaddr is valid //see if the Vaddr is valid
inline bool ValidVaddr ( DWORD VAddr ) const { return TLB_ReadMap[VAddr >> 12] != 0; } inline bool ValidVaddr ( DWORD VAddr ) const { return TLB_ReadMap[VAddr >> 12] != 0; }
*/
}; };

View File

@ -1,290 +1,223 @@
#include "..\..\N64 System.h" #include "stdafx.h"
#include "../C Core/C Core Interface.h"
#include <windows.h> //needed for memory allocation
#include <commctrl.h> //needed for debug window
CTLB::CTLB(CTLB_CB * CallBack ):
//CLog TlbLog("TLB Log.txt"); m_CB(CallBack)
CTLB::CTLB(CMipsTLB_CallBack * CallBack, BYTE * &BasePAddr, CRegisters * const &Registers ):
CBClass (CallBack),
m_BasePAddr(BasePAddr),
PROGRAM_COUNTER(Registers->PROGRAM_COUNTER),
INDEX_REGISTER(Registers->INDEX_REGISTER),
PAGE_MASK_REGISTER(Registers->PAGE_MASK_REGISTER),
ENTRYHI_REGISTER(Registers->ENTRYHI_REGISTER),
ENTRYLO0_REGISTER(Registers->ENTRYLO0_REGISTER),
ENTRYLO1_REGISTER(Registers->ENTRYLO1_REGISTER)
{ {
WriteTrace(TraceTLB,"CTLB::CTLB - Start"); WriteTrace(TraceTLB,"CTLB::CTLB - Start");
TLB_ReadMap = (DWORD *)VirtualAlloc(NULL,0xFFFFF * sizeof(DWORD),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); Reset(true);
if (TLB_ReadMap == NULL) {
Notify().FatalError(MSG_MEM_ALLOC_ERROR);
}
TLB_WriteMap = (DWORD *)VirtualAlloc(NULL,0xFFFFF * sizeof(DWORD),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE);
if (TLB_WriteMap == NULL) {
Notify().FatalError(MSG_MEM_ALLOC_ERROR);
}
//TLB_Reset(true);
WriteTrace(TraceTLB,"CTLB::CTLB - Done"); WriteTrace(TraceTLB,"CTLB::CTLB - Done");
} }
CTLB::~CTLB (void) { CTLB::~CTLB (void) {
WriteTrace(TraceTLB,"CTLB::~CTLB - Done"); WriteTrace(TraceTLB,"CTLB::~CTLB - Done");
VirtualFree( TLB_ReadMap, 0 , MEM_RELEASE);
VirtualFree( TLB_WriteMap, 0 , MEM_RELEASE);
WriteTrace(TraceTLB,"CTLB::~CTLB - Done"); WriteTrace(TraceTLB,"CTLB::~CTLB - Done");
} }
void CTLB::TLB_Reset (bool InvalidateTLB) { void CTLB::Reset (bool InvalidateTLB) {
DWORD count; DWORD count;
if (InvalidateTLB) { for (count = 0; count < 64; count++)
for (count = 0; count < 32; count++) { tlb[count].EntryDefined = false; } {
m_FastTlb[count].ValidEntry = false;
} }
for (count = 0; count < 64; count++) { FastTlb[count].ValidEntry = false; }
memset(TLB_ReadMap,0,(0xFFFFF * sizeof(DWORD)));
memset(TLB_WriteMap,0,(0xFFFFF * sizeof(DWORD)));
for (count = 0x80000000; count < 0xC0000000; count += 0x1000) {
TLB_ReadMap[count >> 12] = ((DWORD)m_BasePAddr + (count & 0x1FFFFFFF)) - count;
TLB_WriteMap[count >> 12] = ((DWORD)m_BasePAddr + (count & 0x1FFFFFFF)) - count;
}
for (count = 0; count < 32; count ++) { SetupTLB_Entry(count,false); }
//GE Hack
if (_Settings->LoadDword(Rdb_TLB_VAddrStart) != 0) if (InvalidateTLB)
{ {
DWORD Start = _Settings->LoadDword(Rdb_TLB_VAddrStart); //0x7F000000; for (count = 0; count < 32; count++)
DWORD Len = _Settings->LoadDword(Rdb_TLB_VAddrLen); //0x01000000; {
DWORD PAddr = _Settings->LoadDword(Rdb_TLB_PAddrStart); //0x10034b30; m_tlb[count].EntryDefined = false;
DWORD End = Start + Len; }
for (count = Start; count < End; count += 0x1000) { } else {
TLB_ReadMap[count >> 12] = ((DWORD)m_BasePAddr + (count - Start + PAddr)) - count; for (count = 0; count < 32; count ++)
TLB_WriteMap[count >> 12] = ((DWORD)m_BasePAddr + (count - Start + PAddr)) - count; {
SetupTLB_Entry(count,false);
} }
} }
} }
bool CTLB::TLB_AddressDefined ( DWORD VAddr) { bool CTLB::AddressDefined ( DWORD VAddr) {
DWORD i; DWORD i;
if (VAddr >= 0x80000000 && VAddr <= 0xBFFFFFFF) { if (VAddr >= 0x80000000 && VAddr <= 0xBFFFFFFF) {
return true; return true;
} }
for (i = 0; i < 64; i++) { for (i = 0; i < 64; i++)
if (FastTlb[i].ValidEntry == FALSE) { continue; } {
if (VAddr >= FastTlb[i].VSTART && VAddr <= FastTlb[i].VEND) { if (m_FastTlb[i].ValidEntry &&
//TlbLog.Log("AddressDefined from tlb entry %d",i); VAddr >= m_FastTlb[i].VSTART &&
VAddr <= m_FastTlb[i].VEND)
{
//TlbLog.Log("AddressDefined from m_tlb entry %d",i);
return true; return true;
} }
} }
return FALSE; return false;
} }
void CTLB::TLB_Probe (void) { void CTLB::Probe (void) {
int Counter; int Counter;
WriteTrace(TraceTLB,"TLB Probe"); WriteTrace(TraceTLB,"TLB Probe");
INDEX_REGISTER |= 0x80000000; _Reg->INDEX_REGISTER |= 0x80000000;
for (Counter = 0; Counter < 32; Counter ++) { for (Counter = 0; Counter < 32; Counter ++)
if (!tlb[Counter].EntryDefined) { continue; } {
DWORD TlbValue = tlb[Counter].EntryHi.Value & (~tlb[Counter].PageMask.Mask << 13); if (!m_tlb[Counter].EntryDefined)
DWORD EntryHi = ENTRYHI_REGISTER & (~tlb[Counter].PageMask.Mask << 13); {
continue;
}
DWORD & TlbEntryHiValue = m_tlb[Counter].EntryHi.Value;
DWORD Mask = ~m_tlb[Counter].PageMask.Mask << 13;
DWORD TlbValueMasked = TlbEntryHiValue & Mask;
DWORD EntryHiMasked = _Reg->ENTRYHI_REGISTER & Mask;
if (TlbValue == EntryHi) { if (TlbValueMasked == EntryHiMasked) {
BOOL Global = (tlb[Counter].EntryHi.Value & 0x100) != 0; if ((TlbEntryHiValue & 0x100) != 0 || //Global
BOOL SameAsid = ((tlb[Counter].EntryHi.Value & 0xFF) == (ENTRYHI_REGISTER & 0xFF)); ((TlbEntryHiValue & 0xFF) == (_Reg->ENTRYHI_REGISTER & 0xFF))) //SameAsid
{
if (Global || SameAsid) { _Reg->INDEX_REGISTER = Counter;
INDEX_REGISTER = Counter; int FastIndx = Counter << 1;
FastTlb[Counter << 1].Probed = true; m_FastTlb[FastIndx].Probed = true;
FastTlb[(Counter << 1) + 1].Probed = true; m_FastTlb[FastIndx + 1].Probed = true;
return; return;
} }
} }
} }
} }
void CTLB::TLB_ReadEntry (void) { void CTLB::ReadEntry (void) {
DWORD index = INDEX_REGISTER & 0x1F; DWORD index = _Reg->INDEX_REGISTER & 0x1F;
PAGE_MASK_REGISTER = tlb[index].PageMask.Value ; _Reg->PAGE_MASK_REGISTER = m_tlb[index].PageMask.Value ;
ENTRYHI_REGISTER = (tlb[index].EntryHi.Value & ~tlb[index].PageMask.Value) ; _Reg->ENTRYHI_REGISTER = (m_tlb[index].EntryHi.Value & ~m_tlb[index].PageMask.Value) ;
ENTRYLO0_REGISTER = tlb[index].EntryLo0.Value; _Reg->ENTRYLO0_REGISTER = m_tlb[index].EntryLo0.Value;
ENTRYLO1_REGISTER = tlb[index].EntryLo1.Value; _Reg->ENTRYLO1_REGISTER = m_tlb[index].EntryLo1.Value;
} }
void CTLB::TLB_WriteEntry (int index, bool Random) { void CTLB::WriteEntry (int index, bool Random) {
int FastIndx; int FastIndx;
WriteTraceF(TraceTLB,"Write Entry %02d %d %08X %08X %08X %08X ",index,Random,PAGE_MASK_REGISTER,ENTRYHI_REGISTER,ENTRYLO0_REGISTER,ENTRYLO1_REGISTER); WriteTraceF(TraceTLB,"Write Entry %02d %d %08X %08X %08X %08X ",index,Random,_Reg->PAGE_MASK_REGISTER,_Reg->ENTRYHI_REGISTER,_Reg->ENTRYLO0_REGISTER,_Reg->ENTRYLO1_REGISTER);
//Check to see if entry is unmapping it self //Check to see if entry is unmapping it self
if (tlb[index].EntryDefined) { if (m_tlb[index].EntryDefined) {
FastIndx = index << 1; FastIndx = index << 1;
if ((PROGRAM_COUNTER >= FastTlb[FastIndx].VSTART && if (*_PROGRAM_COUNTER >= m_FastTlb[FastIndx].VSTART &&
PROGRAM_COUNTER < FastTlb[FastIndx].VEND && *_PROGRAM_COUNTER < m_FastTlb[FastIndx].VEND &&
FastTlb[FastIndx].ValidEntry && FastTlb[FastIndx].VALID) m_FastTlb[FastIndx].ValidEntry && m_FastTlb[FastIndx].VALID)
||
(PROGRAM_COUNTER >= FastTlb[FastIndx + 1].VSTART &&
PROGRAM_COUNTER < FastTlb[FastIndx + 1].VEND &&
FastTlb[FastIndx + 1].ValidEntry && FastTlb[FastIndx + 1].VALID))
{ {
WriteTraceF(TraceTLB,"Write Entry: Ignored PC: %X VAddr Start: %X VEND: %X",*_PROGRAM_COUNTER,m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].VEND);
return;
}
if (*_PROGRAM_COUNTER >= m_FastTlb[FastIndx + 1].VSTART &&
*_PROGRAM_COUNTER < m_FastTlb[FastIndx + 1].VEND &&
m_FastTlb[FastIndx + 1].ValidEntry && m_FastTlb[FastIndx + 1].VALID)
{
WriteTraceF(TraceTLB,"Write Entry: Ignored PC: %X VAddr Start: %X VEND: %X",*_PROGRAM_COUNTER,m_FastTlb[FastIndx + 1].VSTART,m_FastTlb[FastIndx + 1].VEND);
return; return;
} }
} }
//see if tlb entry is the same
//Reset old addresses //Reset old addresses
if (tlb[index].EntryDefined) { if (m_tlb[index].EntryDefined)
DWORD count; {
for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) { for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) {
if (!FastTlb[FastIndx].ValidEntry) { continue; } if (!m_FastTlb[FastIndx].ValidEntry) { continue; }
if (!FastTlb[FastIndx].VALID) { continue; } if (!m_FastTlb[FastIndx].VALID) { continue; }
if (tlb[index].PageMask.Value == PAGE_MASK_REGISTER && if (m_tlb[index].PageMask.Value == _Reg->PAGE_MASK_REGISTER &&
tlb[index].EntryHi.Value == ENTRYHI_REGISTER) m_tlb[index].EntryHi.Value == _Reg->ENTRYHI_REGISTER)
{ {
if (FastIndx == (index << 1) && tlb[index].EntryLo0.Value == ENTRYLO0_REGISTER) { if (FastIndx == (index << 1) && m_tlb[index].EntryLo0.Value == _Reg->ENTRYLO0_REGISTER) {
continue; continue;
} }
if (FastIndx != (index << 1) && tlb[index].EntryLo1.Value == ENTRYLO1_REGISTER) { if (FastIndx != (index << 1) && m_tlb[index].EntryLo1.Value == _Reg->ENTRYLO1_REGISTER) {
continue; continue;
} }
} }
if (FastTlb[FastIndx].Random && !FastTlb[FastIndx].Probed) { m_CB->TLB_Unmaped(m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].Length);
//Move tlb if possible
//int NewIndex = TLB_UnusedEntry((int)WIRED_REGISTER);
/*if (NewIndex > 0) {
tlb[NewIndex].PageMask.Value = tlb[index].PageMask.Value;
tlb[NewIndex].EntryHi.Value = tlb[index].EntryHi.Value;
tlb[NewIndex].EntryLo0.Value = tlb[index].EntryLo0.Value;
tlb[NewIndex].EntryLo1.Value = tlb[index].EntryLo1.Value;
tlb[NewIndex].EntryDefined = tlb[index].EntryDefined;
SetupTLB_Entry(NewIndex,FastTlb[FastIndx].Random);
break;
}*/
}
CBClass->TLB_Unmapping(index,FastIndx,FastTlb[FastIndx].VSTART,(FastTlb[FastIndx].VEND - FastTlb[FastIndx].VSTART));
for (count = FastTlb[FastIndx].VSTART; count < FastTlb[FastIndx].VEND; count += 0x1000) {
TLB_ReadMap[count >> 12] = 0;
TLB_WriteMap[count >> 12] = 0;
}
} }
} }
//fill in tlb entry //fill in m_tlb entry
tlb[index].PageMask.Value = PAGE_MASK_REGISTER; m_tlb[index].PageMask.Value = _Reg->PAGE_MASK_REGISTER;
tlb[index].EntryHi.Value = ENTRYHI_REGISTER; m_tlb[index].EntryHi.Value = _Reg->ENTRYHI_REGISTER;
tlb[index].EntryLo0.Value = ENTRYLO0_REGISTER; m_tlb[index].EntryLo0.Value = _Reg->ENTRYLO0_REGISTER;
tlb[index].EntryLo1.Value = ENTRYLO1_REGISTER; m_tlb[index].EntryLo1.Value = _Reg->ENTRYLO1_REGISTER;
tlb[index].EntryDefined = true; m_tlb[index].EntryDefined = true;
SetupTLB_Entry(index,Random); SetupTLB_Entry(index,Random);
CBClass->TLB_Changed(); m_CB->TLB_Changed();
//RefreshTLBWindow();
} }
void CTLB::SetupTLB_Entry (int index, bool Random) { void CTLB::SetupTLB_Entry (int index, bool Random) {
//Fix up Fast TLB entries //Fix up Fast TLB entries
if (!tlb[index].EntryDefined) { return; } if (!m_tlb[index].EntryDefined) { return; }
int FastIndx = index << 1; int FastIndx = index << 1;
FastTlb[FastIndx].VSTART=tlb[index].EntryHi.VPN2 << 13; m_FastTlb[FastIndx].Length = (m_tlb[index].PageMask.Mask << 12) + 0xFFF;
FastTlb[FastIndx].VEND = FastTlb[FastIndx].VSTART + (tlb[index].PageMask.Mask << 12) + 0xFFF; m_FastTlb[FastIndx].VSTART=m_tlb[index].EntryHi.VPN2 << 13;
FastTlb[FastIndx].PHYSSTART = tlb[index].EntryLo0.PFN << 12; m_FastTlb[FastIndx].VEND = m_FastTlb[FastIndx].VSTART + m_FastTlb[FastIndx].Length;
FastTlb[FastIndx].PHYSEND = FastTlb[FastIndx].PHYSSTART + (tlb[index].PageMask.Mask << 12) + 0xFFF; m_FastTlb[FastIndx].PHYSSTART = m_tlb[index].EntryLo0.PFN << 12;
FastTlb[FastIndx].VALID = tlb[index].EntryLo0.V; m_FastTlb[FastIndx].PHYSEND = m_FastTlb[FastIndx].PHYSSTART + m_FastTlb[FastIndx].Length;
FastTlb[FastIndx].DIRTY = tlb[index].EntryLo0.D; m_FastTlb[FastIndx].VALID = m_tlb[index].EntryLo0.V;
FastTlb[FastIndx].GLOBAL = tlb[index].EntryLo0.GLOBAL & tlb[index].EntryLo1.GLOBAL; m_FastTlb[FastIndx].DIRTY = m_tlb[index].EntryLo0.D;
FastTlb[FastIndx].ValidEntry = FALSE; m_FastTlb[FastIndx].GLOBAL = m_tlb[index].EntryLo0.GLOBAL & m_tlb[index].EntryLo1.GLOBAL;
FastTlb[FastIndx].Random = Random; m_FastTlb[FastIndx].ValidEntry = FALSE;
FastTlb[FastIndx].Probed = false; m_FastTlb[FastIndx].Random = Random;
m_FastTlb[FastIndx].Probed = false;
FastIndx = (index << 1) + 1; FastIndx = (index << 1) + 1;
FastTlb[FastIndx].VSTART=(tlb[index].EntryHi.VPN2 << 13) + ((tlb[index].PageMask.Mask << 12) + 0xFFF + 1); m_FastTlb[FastIndx].Length = (m_tlb[index].PageMask.Mask << 12) + 0xFFF;
FastTlb[FastIndx].VEND = FastTlb[FastIndx].VSTART + (tlb[index].PageMask.Mask << 12) + 0xFFF; m_FastTlb[FastIndx].VSTART=(m_tlb[index].EntryHi.VPN2 << 13) + (m_FastTlb[FastIndx].Length + 1);
FastTlb[FastIndx].PHYSSTART = tlb[index].EntryLo1.PFN << 12; m_FastTlb[FastIndx].VEND = m_FastTlb[FastIndx].VSTART + m_FastTlb[FastIndx].Length;
FastTlb[FastIndx].PHYSEND = FastTlb[FastIndx].PHYSSTART + (tlb[index].PageMask.Mask << 12) + 0xFFF; m_FastTlb[FastIndx].PHYSSTART = m_tlb[index].EntryLo1.PFN << 12;
FastTlb[FastIndx].VALID = tlb[index].EntryLo1.V; m_FastTlb[FastIndx].PHYSEND = m_FastTlb[FastIndx].PHYSSTART + m_FastTlb[FastIndx].Length;
FastTlb[FastIndx].DIRTY = tlb[index].EntryLo1.D; m_FastTlb[FastIndx].VALID = m_tlb[index].EntryLo1.V;
FastTlb[FastIndx].GLOBAL = tlb[index].EntryLo0.GLOBAL & tlb[index].EntryLo1.GLOBAL; m_FastTlb[FastIndx].DIRTY = m_tlb[index].EntryLo1.D;
FastTlb[FastIndx].ValidEntry = FALSE; m_FastTlb[FastIndx].GLOBAL = m_tlb[index].EntryLo0.GLOBAL & m_tlb[index].EntryLo1.GLOBAL;
FastTlb[FastIndx].Random = Random; m_FastTlb[FastIndx].ValidEntry = FALSE;
FastTlb[FastIndx].Probed = false; m_FastTlb[FastIndx].Random = Random;
m_FastTlb[FastIndx].Probed = false;
//Test both entries to see if they are valid //Test both entries to see if they are valid
for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) { for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) {
DWORD count; if (!m_FastTlb[FastIndx].VALID) {
m_FastTlb[FastIndx].ValidEntry = true;
if (!FastTlb[FastIndx].VALID) {
FastTlb[FastIndx].ValidEntry = true;
continue; continue;
} }
if (FastTlb[FastIndx].VEND <= FastTlb[FastIndx].VSTART) { if (m_FastTlb[FastIndx].VEND <= m_FastTlb[FastIndx].VSTART) {
continue; continue;
} }
if (FastTlb[FastIndx].VSTART >= 0x80000000 && FastTlb[FastIndx].VEND <= 0xBFFFFFFF) { if (m_FastTlb[FastIndx].VSTART >= 0x80000000 && m_FastTlb[FastIndx].VEND <= 0xBFFFFFFF) {
continue; continue;
} }
if (FastTlb[FastIndx].PHYSSTART > 0x1FFFFFFF) { if (m_FastTlb[FastIndx].PHYSSTART > 0x1FFFFFFF) {
continue; continue;
} }
//MAP the new tlb entry for reading and writing //MAP the new m_tlb entry for reading and writing
FastTlb[FastIndx].ValidEntry = true; m_FastTlb[FastIndx].ValidEntry = true;
for (count = FastTlb[FastIndx].VSTART; count < FastTlb[FastIndx].VEND; count += 0x1000) { m_CB->TLB_Mapped(m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].Length,m_FastTlb[FastIndx].PHYSSTART, !m_FastTlb[FastIndx].DIRTY);
TLB_ReadMap[count >> 12] = ((DWORD)m_BasePAddr + (count - FastTlb[FastIndx].VSTART + FastTlb[FastIndx].PHYSSTART)) - count;
if (!FastTlb[FastIndx].DIRTY) { continue; }
TLB_WriteMap[count >> 12] = ((DWORD)m_BasePAddr + (count - FastTlb[FastIndx].VSTART + FastTlb[FastIndx].PHYSSTART)) - count;
}
} }
} }
#ifdef tofix
bool CTLB::VAddrToRealAddr(DWORD VAddr, void * &RealAddress) { bool CTLB::VAddrToRealAddr(DWORD VAddr, void * &RealAddress) {
if (TLB_ReadMap[VAddr >> 12] == 0) { return false; } if (TLB_ReadMap[VAddr >> 12] == 0) { return false; }
RealAddress = (BYTE *)(TLB_ReadMap[VAddr >> 12] + VAddr); RealAddress = (BYTE *)(TLB_ReadMap[VAddr >> 12] + VAddr);
return true; return true;
} }
bool CTLB::TLB_EntryUsed(int index ) {
if (!tlb[index].EntryDefined) { return false; }
//Test both entries to see if they are valid
bool ValidEntry = false;
for ( int FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) {
if (!FastTlb[FastIndx].VALID) { continue; }
if (FastTlb[FastIndx].VEND <= FastTlb[FastIndx].VSTART) { continue; }
if (FastTlb[FastIndx].VSTART >= 0x80000000 && FastTlb[FastIndx].VEND <= 0xBFFFFFFF) { continue; }
if (FastTlb[FastIndx].PHYSSTART > 0x1FFFFFFF) { continue; }
ValidEntry = true;
}
return ValidEntry;
}
int CTLB::TLB_UnusedEntry (int MinIndx ) {
MinIndx &= 0x1f;
for (int count = 31; count >= MinIndx; count --) {
if (!TLB_EntryUsed(count)) { return count; }
}
return -1;
}
bool CTLB::PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index ) bool CTLB::PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index )
{ {
for (int i = Index; i < 64; i++) for (int i = Index; i < 64; i++)
{ {
if (FastTlb[i].ValidEntry == false) { continue; } if (m_FastTlb[i].ValidEntry == false) { continue; }
if (PAddr >= FastTlb[i].PHYSSTART && PAddr < FastTlb[i].PHYSEND) if (PAddr >= m_FastTlb[i].PHYSSTART && PAddr < m_FastTlb[i].PHYSEND)
{ {
VAddr = FastTlb[i].VSTART + (PAddr - FastTlb[i].PHYSSTART); VAddr = m_FastTlb[i].VSTART + (PAddr - m_FastTlb[i].PHYSSTART);
Index = i + 1; Index = i + 1;
return true; return true;
} }
@ -293,3 +226,4 @@ bool CTLB::PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index )
return false; return false;
} }
#endif

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,6 @@
typedef std::list<SystemEvent> EVENT_LIST; typedef std::list<SystemEvent> EVENT_LIST;
typedef struct { typedef struct {
CN64System * _this;
stdstr FileName; stdstr FileName;
void * ThreadHandle; void * ThreadHandle;
DWORD ThreadID; DWORD ThreadID;
@ -23,10 +22,46 @@ class CC_Core;
class CN64System : class CN64System :
private CMipsMemory_CallBack, private CMipsMemory_CallBack,
public CMipsTLB_CallBack, private CTLB_CB,
protected CN64SystemSettings, protected CN64SystemSettings,
public CDebugger public CDebugger
{ {
public:
CN64System ( CPlugins * Plugins, bool SavesReadOnly );
~CN64System ( void );
//Methods
static bool CN64System::RunFileImage ( const char * FileLoc );
void CloseCpu ( void );
void ExternalEvent ( SystemEvent Event ); //covers gui interacting and timers etc..
stdstr ChooseFileToOpen ( WND_HANDLE hParent );
void DisplayRomInfo ( WND_HANDLE hParent );
void SelectCheats ( WND_HANDLE hParent );
void StartEmulation ( bool NewThread );
void SyncToAudio ( void );
bool IsDialogMsg ( MSG * msg );
void IncreaseSpeed ( void ) { m_Limitor.IncreaeSpeed(10); }
void DecreaeSpeed ( void ) { m_Limitor.DecreaeSpeed(10); }
void SoftReset ( void );
bool m_EndEmulation;
//Get the pointer to the Internal Classes
CRecompiler * GetRecompiler ( void ) { return m_Recomp; }
//CN64Rom * GetCurrentRom ( void ) { return _Rom; }
inline CPlugins * Plugins ( void ) const { return m_Plugins; }
//Variable used to track that the SP is being handled and stays the same as the real SP in sync core
#ifdef TEST_SP_TRACKING
DWORD m_CurrentSP;
#endif
//For Sync CPU
void UpdateSyncCPU ( CN64System * const SecondCPU, DWORD const Cycles );
void SyncCPU ( CN64System * const SecondCPU );
private:
//Make sure plugins can directly access this information //Make sure plugins can directly access this information
friend CGfxPlugin; friend CGfxPlugin;
friend CAudioPlugin; friend CAudioPlugin;
@ -36,48 +71,8 @@ class CN64System :
//Recompiler has access to manipulate and call functions //Recompiler has access to manipulate and call functions
friend CC_Core; friend CC_Core;
CNotification * const _Notify; //Original Notify member used to notify the user when something occurs
CPlugins * const _Plugins; //The plugin container
CN64System * _SyncCPU;
CMipsMemory * _MMU; //Memory of the n64
CRegisters * _Reg; //Current Register Set attacted to the _MMU
CN64Rom * _Rom; //The current rom that this system is executing.. it can only execute one file at the time
bool m_OwnRomObject;
CCheats * _Cheats;
CFramePerSecond FPS;
CProfiling m_CPU_Usage, m_Profile; //used to track the cpu usage
// CInterpreterOps * InterpreterOpcode; //Pointer to the interpter Opcode
CRecompiler * _Recomp;
CAudio * _Audio;
CSpeedLimitor m_Limitor;
bool m_InReset;
SystemType m_SystemType;
bool m_bCleanFrameBox;
//When Syncing cores this is the PC where it last Sync'ed correctly
DWORD m_LastSuccessSyncPC[10];
int m_CyclesToSkip;
//List of Internal events that need to be acted on by CPU
EVENT_LIST EventList;
DWORD NoOfEvents;
//Handle to the cpu thread
void * CPU_Handle;
DWORD CPU_ThreadID;
//Handle to pause mutex
void * m_hPauseEvent;
//No of Alist and Dlist sent to the RSP
DWORD m_AlistCount, m_DlistCount, m_UnknownCount;
//list of function that have been called .. used in profiling
FUNC_CALLS m_FunctionCalls;
//Used for loading and potentialy executing the CPU in its own thread. //Used for loading and potentialy executing the CPU in its own thread.
static void LoadFileImage ( FileImageInfo * Info ); static void stLoadFileImage ( FileImageInfo * Info );
static void StartEmulationThread ( FileImageInfo * Info ); static void StartEmulationThread ( FileImageInfo * Info );
void ExecuteCycles ( DWORD Cycles ); void ExecuteCycles ( DWORD Cycles );
@ -87,12 +82,12 @@ class CN64System :
bool InPermLoop ( void ); bool InPermLoop ( void );
void Reset ( void ); void Reset ( void );
void RunRSP ( void ); void RunRSP ( void );
void SetupSystem ( CN64Rom * Rom, bool OwnRomObject, bool SavesReadOnly = false );
bool SaveState ( void ); bool SaveState ( void );
bool LoadState ( LPCSTR FileName ); bool LoadState ( LPCSTR FileName );
bool LoadState ( void ); bool LoadState ( void );
void DumpSyncErrors ( CN64System * SecondCPU ); void DumpSyncErrors ( CN64System * SecondCPU );
void StartEmulation2 ( bool NewThread ); void StartEmulation2 ( bool NewThread );
bool SetActiveSystem ( bool bActive );
//CPU Methods //CPU Methods
void ExecuteRecompiler ( CC_Core & C_Core ); void ExecuteRecompiler ( CC_Core & C_Core );
@ -114,44 +109,47 @@ class CN64System :
//Function in CMipsMemory_CallBack //Function in CMipsMemory_CallBack
virtual bool WriteToProtectedMemory (DWORD Address, int length); virtual bool WriteToProtectedMemory (DWORD Address, int length);
//Functions in CMipsTLB_CallBack //Functions in CTLB_CB
virtual void TLB_Changed ( void ); void TLB_Mapped ( DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly );
virtual void TLB_Unmapping ( int TlbEntry, int FastTlbEntry, DWORD Vaddr, DWORD Len ); void TLB_Unmaped ( DWORD VAddr, DWORD Len );
void TLB_Changed ( void );
public: CPlugins * const m_Plugins; //The plugin container
CN64System ( CNotification * Notify, CPlugins * Plugins ); CN64System * m_SyncCPU;
~CN64System ( void ); CMipsMemoryVM m_MMU_VM; //Memory of the n64
CTLB m_TLB;
CRegisters m_Reg;
CCheats m_Cheats;
CFramePerSecond m_FPS;
CProfiling m_CPU_Usage, m_Profile; //used to track the cpu usage
CRecompiler * m_Recomp;
CAudio m_Audio;
CSpeedLimitor m_Limitor;
bool m_InReset;
SystemType m_SystemType;
bool m_bCleanFrameBox;
bool m_bInitilized;
//When Syncing cores this is the PC where it last Sync'ed correctly
DWORD m_LastSuccessSyncPC[10];
int m_CyclesToSkip;
//Methods //List of Internal events that need to be acted on by CPU
void CloseCpu ( void ); EVENT_LIST m_EventList;
void RunFileImage ( const char * FileLoc ); DWORD m_NoOfEvents;
void ExternalEvent ( SystemEvent Event ); //covers gui interacting and timers etc..
stdstr ChooseFileToOpen ( WND_HANDLE hParent );
void DisplayRomInfo ( WND_HANDLE hParent );
void SelectCheats ( WND_HANDLE hParent );
void StartEmulation ( bool NewThread );
void SyncToAudio ( void );
bool IsDialogMsg ( MSG * msg );
void IncreaseSpeed ( void ) { m_Limitor.IncreaeSpeed(10); }
void DecreaeSpeed ( void ) { m_Limitor.DecreaeSpeed(10); }
void SoftReset ( void );
bool EndEmulation; //Handle to the cpu thread
HANDLE m_CPU_Handle;
DWORD m_CPU_ThreadID;
//Handle to pause mutex
void * m_hPauseEvent;
//Get the pointer to the Internal Classes //No of Alist and Dlist sent to the RSP
CRecompiler * GetRecompiler ( void ) { return _Recomp; } DWORD m_AlistCount, m_DlistCount, m_UnknownCount;
CN64Rom * GetCurrentRom ( void ) { return _Rom; }
inline CPlugins * Plugins ( void ) const { return _Plugins; }
//Variable used to track that the SP is being handled and stays the same as the real SP in sync core
#ifdef TEST_SP_TRACKING
DWORD m_CurrentSP;
#endif
//For Sync CPU
void UpdateSyncCPU ( CN64System * const SecondCPU, DWORD const Cycles );
void SyncCPU ( CN64System * const SecondCPU );
//list of function that have been called .. used in profiling
FUNC_CALLS m_FunctionCalls;
}; };
#endif #endif

View File

@ -6,8 +6,7 @@
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>
CN64Rom::CN64Rom ( CNotification * Notify ) : CN64Rom::CN64Rom ( void )
_Notify(Notify)
{ {
m_hRomFile = NULL; m_hRomFile = NULL;
m_hRomFileMapping = NULL; m_hRomFileMapping = NULL;
@ -259,7 +258,7 @@ bool CN64Rom::IsValidRomImage ( BYTE Test[4] ) {
void CN64Rom::NotificationCB ( LPCSTR Status, CN64Rom * _this ) void CN64Rom::NotificationCB ( LPCSTR Status, CN64Rom * _this )
{ {
_this->_Notify->DisplayMessage(5,"%s",Status); _Notify->DisplayMessage(5,"%s",Status);
} }
bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) { bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
@ -453,6 +452,11 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
m_Country = (Country)m_ROMImage[0x3D]; m_Country = (Country)m_ROMImage[0x3D];
m_RomIdent.Format("%08X-%08X-C:%X",*(DWORD *)(&m_ROMImage[0x10]),*(DWORD *)(&m_ROMImage[0x14]),m_ROMImage[0x3D]); m_RomIdent.Format("%08X-%08X-C:%X",*(DWORD *)(&m_ROMImage[0x10]),*(DWORD *)(&m_ROMImage[0x14]),m_ROMImage[0x3D]);
CalculateCicChip(); CalculateCicChip();
if (!LoadBootCodeOnly && _Rom == this)
{
SaveRomSettingID();
}
return true; return true;
} }

View File

@ -1,8 +1,7 @@
#include "N64 Types.h" #include "N64 Types.h"
class CN64Rom { class CN64Rom
CNotification * const _Notify; //Original Notify member used to notify the user when something occurs {
//constant values //constant values
enum { ReadFromRomSection = 0x400000 }; enum { ReadFromRomSection = 0x400000 };
@ -24,7 +23,7 @@ class CN64Rom {
void CalculateCicChip ( void ); void CalculateCicChip ( void );
public: public:
CN64Rom ( CNotification * Notify ); CN64Rom ( void );
~CN64Rom ( void ); ~CN64Rom ( void );
bool LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly = false ); bool LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly = false );
void SaveRomSettingID ( void ); void SaveRomSettingID ( void );

View File

@ -10,9 +10,7 @@
#undef LinkBlocks #undef LinkBlocks
#undef CountPerOp #undef CountPerOp
CRecompiler::CRecompiler(CMipsMemory * MMU, CProfiling & Profile, bool & EndEmulation, bool SyncSystem) : CRecompiler::CRecompiler(CProfiling & Profile, bool & EndEmulation, bool SyncSystem) :
_MMU(MMU),
_Reg(MMU->SystemRegisters()),
m_Profile(Profile), m_Profile(Profile),
PROGRAM_COUNTER(_Reg->PROGRAM_COUNTER), PROGRAM_COUNTER(_Reg->PROGRAM_COUNTER),
m_EndEmulation(EndEmulation), m_EndEmulation(EndEmulation),
@ -29,19 +27,25 @@ CRecompiler::~CRecompiler()
void CRecompiler::Run() void CRecompiler::Run()
{ {
*g_MemoryStack = (DWORD)(N64MEM+(GPR[29].W[0] & 0x1FFFFFFF)); _Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
*g_MemoryStack = (DWORD)(RDRAM+(_GPR[29].W[0] & 0x1FFFFFFF));
#endif
CoInitialize(NULL); CoInitialize(NULL);
if (g_LogX86Code) if (g_LogX86Code)
{ {
Start_x86_Log(); Start_x86_Log();
} }
if (!g_MMU->AllocateRecompilerMemory(LookUpMode() != FuncFind_VirtualLookup && LookUpMode() != FuncFind_ChangeMemory)) _Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
if (!_MMU->AllocateRecompilerMemory(LookUpMode() != FuncFind_VirtualLookup && LookUpMode() != FuncFind_ChangeMemory))
{ {
return; return;
} }
JumpTable = g_MMU->GetJumpTable(); JumpTable = _MMU->GetJumpTable();
RecompCode = g_MMU->GetRecompCode(); RecompCode = _MMU->GetRecompCode();
#endif
ResetRecompCode(); ResetRecompCode();
m_EndEmulation = false; m_EndEmulation = false;
@ -65,7 +69,7 @@ void CRecompiler::Run()
RecompilerMain_Lookup(); RecompilerMain_Lookup();
} }
} }
__except( _MMU->SystemMemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) __except( _MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) )
{ {
Notify().DisplayError(MSG_UNKNOWN_MEM_ACTION); Notify().DisplayError(MSG_UNKNOWN_MEM_ACTION);
} }
@ -94,16 +98,19 @@ void CRecompiler::RecompilerMain_VirtualTable ( void )
continue; continue;
} }
} }
if (!_MMU->ValidVaddr(PROGRAM_COUNTER)) _Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
if (!_TLB->ValidVaddr(PROGRAM_COUNTER))
{ {
DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER);
NextInstruction = NORMAL; NextInstruction = NORMAL;
if (!_MMU->ValidVaddr(PROGRAM_COUNTER)) if (!_TLB->ValidVaddr(PROGRAM_COUNTER))
{ {
DisplayError("Failed to tranlate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); DisplayError("Failed to tranlate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER);
return; return;
} }
} }
#endif
FUNCTION_INFO * info = CompilerCode(); FUNCTION_INFO * info = CompilerCode();
if (info == NULL || EndEmulation()) if (info == NULL || EndEmulation())
@ -115,18 +122,20 @@ void CRecompiler::RecompilerMain_VirtualTable ( void )
//Find Block on hash table //Find Block on hash table
if (Info == NULL) if (Info == NULL)
{ {
if (!_MMU->ValidVaddr(PROGRAM_COUNTER)) _Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
if (!_TLB->ValidVaddr(PROGRAM_COUNTER))
{ {
DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER);
NextInstruction = NORMAL; NextInstruction = NORMAL;
if (!_MMU->ValidVaddr(PROGRAM_COUNTER)) if (!_TLB->ValidVaddr(PROGRAM_COUNTER))
{ {
DisplayError("Failed to tranlate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); DisplayError("Failed to tranlate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER);
return; return;
} }
continue; continue;
} }
#endif
//Find Block on hash table //Find Block on hash table
Info = CompileDelaySlot(PROGRAM_COUNTER); Info = CompileDelaySlot(PROGRAM_COUNTER);
@ -158,18 +167,20 @@ void CRecompiler::RecompilerMain_VirtualTable_validate ( void )
//Find Block on hash table //Find Block on hash table
if (Info == NULL) if (Info == NULL)
{ {
if (!_MMU->ValidVaddr(PROGRAM_COUNTER)) _Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
if (!_TLB->ValidVaddr(PROGRAM_COUNTER))
{ {
DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER);
NextInstruction = NORMAL; NextInstruction = NORMAL;
if (!_MMU->ValidVaddr(PROGRAM_COUNTER)) if (!_TLB->ValidVaddr(PROGRAM_COUNTER))
{ {
DisplayError("Failed to tranlate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); DisplayError("Failed to tranlate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER);
return; return;
} }
continue; continue;
} }
#endif
//Find Block on hash table //Find Block on hash table
Info = CompileDelaySlot(PROGRAM_COUNTER); Info = CompileDelaySlot(PROGRAM_COUNTER);
@ -216,16 +227,19 @@ void CRecompiler::RecompilerMain_VirtualTable_validate ( void )
continue; continue;
} }
} }
if (!_MMU->ValidVaddr(PROGRAM_COUNTER)) _Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
if (!_TLB->ValidVaddr(PROGRAM_COUNTER))
{ {
DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER);
NextInstruction = NORMAL; NextInstruction = NORMAL;
if (!_MMU->ValidVaddr(PROGRAM_COUNTER)) if (!_TLB->ValidVaddr(PROGRAM_COUNTER))
{ {
DisplayError("Failed to tranlate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); DisplayError("Failed to tranlate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER);
return; return;
} }
} }
#endif
FUNCTION_INFO * info = CompilerCode(); FUNCTION_INFO * info = CompilerCode();
if (info == NULL || EndEmulation()) if (info == NULL || EndEmulation())
@ -324,7 +338,9 @@ void CRecompiler::RecompilerMain_Lookup( void )
{ {
if (g_UseTlb) if (g_UseTlb)
{ {
if (!g_TLB->TranslateVaddr(PROGRAM_COUNTER, Addr)) _Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
if (!_TLB->TranslateVaddr(PROGRAM_COUNTER, Addr))
{ {
DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER);
NextInstruction = NORMAL; NextInstruction = NORMAL;
@ -333,6 +349,7 @@ void CRecompiler::RecompilerMain_Lookup( void )
return; return;
} }
} }
#endif
} else { } else {
Addr = PROGRAM_COUNTER & 0x1FFFFFFF; Addr = PROGRAM_COUNTER & 0x1FFFFFFF;
} }
@ -421,7 +438,7 @@ void CRecompiler::RecompilerMain_Lookup( void )
*(JumpTable + (Addr >> 2)) = (void *)Info; *(JumpTable + (Addr >> 2)) = (void *)Info;
// if (SelfModCheck == ModCode_ProtectedMemory) { // if (SelfModCheck == ModCode_ProtectedMemory) {
// VirtualProtect(N64MEM + Addr, 4, PAGE_READONLY, &OldProtect); // VirtualProtect(RDRAM + Addr, 4, PAGE_READONLY, &OldProtect);
// } // }
} }
if (bSMM_ValidFunc()) if (bSMM_ValidFunc())
@ -434,6 +451,7 @@ void CRecompiler::RecompilerMain_Lookup( void )
continue; continue;
} }
} }
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix #ifdef tofix
if (Profiling && IndvidualBlock) { if (Profiling && IndvidualBlock) {
static DWORD ProfAddress = 0; static DWORD ProfAddress = 0;
@ -471,7 +489,7 @@ void CRecompiler::ResetRecompCode()
m_FunctionsDelaySlot.Reset(); m_FunctionsDelaySlot.Reset();
if (JumpTable) if (JumpTable)
{ {
memset(JumpTable,0,g_MMU->RdramSize()); memset(JumpTable,0,_MMU->RdramSize());
memset(JumpTable + (0x04000000 >> 2),0,0x1000); memset(JumpTable + (0x04000000 >> 2),0,0x1000);
memset(JumpTable + (0x04001000 >> 2),0,0x1000); memset(JumpTable + (0x04001000 >> 2),0,0x1000);
if (bRomInMemory()) if (bRomInMemory())
@ -486,9 +504,9 @@ void CRecompiler::ResetRecompCode()
for (count = 0; count < TargetIndex; count++) { for (count = 0; count < TargetIndex; count++) {
PAddr = OrigMem[(WORD)(count)].PAddr; PAddr = OrigMem[(WORD)(count)].PAddr;
Value = *(DWORD *)(N64MEM + PAddr); Value = *(DWORD *)(RDRAM + PAddr);
if ( ((Value >> 16) == 0x7C7C) && ((Value & 0xFFFF) == count)) { if ( ((Value >> 16) == 0x7C7C) && ((Value & 0xFFFF) == count)) {
*(DWORD *)(N64MEM + PAddr) = OrigMem[(WORD)(count)].OriginalValue; *(DWORD *)(RDRAM + PAddr) = OrigMem[(WORD)(count)].OriginalValue;
} }
} }
} }
@ -501,7 +519,7 @@ void CRecompiler::ResetRecompCode()
memset(JumpTable + (count << 10),0,0x1000); memset(JumpTable + (count << 10),0,0x1000);
*(DelaySlotTable + count) = NULL; *(DelaySlotTable + count) = NULL;
if (VirtualProtect((N64MEM + (count << 12)), 4, PAGE_READWRITE, &OldProtect) == 0) { if (VirtualProtect((RDRAM + (count << 12)), 4, PAGE_READWRITE, &OldProtect) == 0) {
DisplayError("Failed to unprotect %X\n1", (count << 12)); DisplayError("Failed to unprotect %X\n1", (count << 12));
} }
} }
@ -511,7 +529,7 @@ void CRecompiler::ResetRecompCode()
N64_Blocks.NoOfDMEMBlocks = 0; N64_Blocks.NoOfDMEMBlocks = 0;
memset(JumpTable + (0x04000000 >> 2),0,0x1000); memset(JumpTable + (0x04000000 >> 2),0,0x1000);
*(DelaySlotTable + (0x04000000 >> 12)) = NULL; *(DelaySlotTable + (0x04000000 >> 12)) = NULL;
if (VirtualProtect((N64MEM + 0x04000000), 4, PAGE_READWRITE, &OldProtect) == 0) { if (VirtualProtect((RDRAM + 0x04000000), 4, PAGE_READWRITE, &OldProtect) == 0) {
DisplayError("Failed to unprotect %X\n0", 0x04000000); DisplayError("Failed to unprotect %X\n0", 0x04000000);
} }
} }
@ -519,7 +537,7 @@ void CRecompiler::ResetRecompCode()
N64_Blocks.NoOfIMEMBlocks = 0; N64_Blocks.NoOfIMEMBlocks = 0;
memset(JumpTable + (0x04001000 >> 2),0,0x1000); memset(JumpTable + (0x04001000 >> 2),0,0x1000);
*(DelaySlotTable + (0x04001000 >> 12)) = NULL; *(DelaySlotTable + (0x04001000 >> 12)) = NULL;
if (VirtualProtect((N64MEM + 0x04001000), 4, PAGE_READWRITE, &OldProtect) == 0) { if (VirtualProtect((RDRAM + 0x04001000), 4, PAGE_READWRITE, &OldProtect) == 0) {
DisplayError("Failed to unprotect %X\n4", 0x04001000); DisplayError("Failed to unprotect %X\n4", 0x04001000);
} }
} }
@ -538,12 +556,14 @@ FUNCTION_INFO * CRecompiler::CompileDelaySlot(DWORD PC)
return NULL; return NULL;
} }
if (!r4300i_LW_VAddr(PC, &g_Opcode.Hex)) { if (!_MMU->LW_VAddr(PC, g_Opcode.Hex)) {
DisplayError("TLB Miss in delay slot\nEmulation will know stop"); DisplayError("TLB Miss in delay slot\nEmulation will know stop");
return NULL; return NULL;
} }
FUNCTION_INFO * info = m_FunctionsDelaySlot.AddFunctionInfo(PC, _MMU->TranslateVaddr(PC)); _Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
FUNCTION_INFO * info = m_FunctionsDelaySlot.AddFunctionInfo(PC, _TLB->TranslateVaddr(PC));
CBlockInfo BlockInfo(PROGRAM_COUNTER, RecompPos); CBlockInfo BlockInfo(PROGRAM_COUNTER, RecompPos);
CBlockSection * Section = &BlockInfo.ParentSection; CBlockSection * Section = &BlockInfo.ParentSection;
@ -723,12 +743,14 @@ FUNCTION_INFO * CRecompiler::CompileDelaySlot(DWORD PC)
info->SetVEndPC(BlockInfo.EndVAddr); info->SetVEndPC(BlockInfo.EndVAddr);
info->SetFunctionAddr(BlockInfo.CompiledLocation); info->SetFunctionAddr(BlockInfo.CompiledLocation);
_MMU->VAddrToRealAddr(info->VStartPC(),*(reinterpret_cast<void **>(&info->MemLocation[0]))); _TLB->VAddrToRealAddr(info->VStartPC(),*(reinterpret_cast<void **>(&info->MemLocation[0])));
info->MemLocation[1] = info->MemLocation[0] + 1; info->MemLocation[1] = info->MemLocation[0] + 1;
info->MemContents[0] = *info->MemLocation[0]; info->MemContents[0] = *info->MemLocation[0];
info->MemContents[1] = *info->MemLocation[1]; info->MemContents[1] = *info->MemLocation[1];
NextInstruction = NORMAL; NextInstruction = NORMAL;
return info; return info;
#endif
return NULL;
} }
bool CRecompiler::AnalyseBlock ( CBlockInfo & BlockInfo) bool CRecompiler::AnalyseBlock ( CBlockInfo & BlockInfo)
@ -936,7 +958,7 @@ bool CRecompiler::FillSectionInfo(CBlockSection * Section, STEP_TYPE StartStepTy
Section->RegWorking = Section->RegStart; Section->RegWorking = Section->RegStart;
NextInstruction = StartStepType; NextInstruction = StartStepType;
do { do {
if (!r4300i_LW_VAddr(Section->CompilePC, &Command.Hex)) { if (!_MMU->LW_VAddr(Section->CompilePC, Command.Hex)) {
DisplayError(GS(MSG_FAIL_LOAD_WORD)); DisplayError(GS(MSG_FAIL_LOAD_WORD));
return false; return false;
} }
@ -1624,7 +1646,7 @@ bool CRecompiler::FillSectionInfo(CBlockSection * Section, STEP_TYPE StartStepTy
int EffectDelaySlot; int EffectDelaySlot;
OPCODE NewCommand; OPCODE NewCommand;
if (!r4300i_LW_VAddr(Section->CompilePC + 4, &NewCommand.Hex)) { if (!_MMU->LW_VAddr(Section->CompilePC + 4, NewCommand.Hex)) {
DisplayError(GS(MSG_FAIL_LOAD_WORD)); DisplayError(GS(MSG_FAIL_LOAD_WORD));
ExitThread(0); ExitThread(0);
} }
@ -1652,7 +1674,7 @@ bool CRecompiler::FillSectionInfo(CBlockSection * Section, STEP_TYPE StartStepTy
int EffectDelaySlot; int EffectDelaySlot;
OPCODE NewCommand; OPCODE NewCommand;
if (!r4300i_LW_VAddr(Section->CompilePC + 4, &NewCommand.Hex)) { if (!_MMU->LW_VAddr(Section->CompilePC + 4, NewCommand.Hex)) {
DisplayError(GS(MSG_FAIL_LOAD_WORD)); DisplayError(GS(MSG_FAIL_LOAD_WORD));
ExitThread(0); ExitThread(0);
} }
@ -1860,12 +1882,15 @@ bool CRecompiler::Compiler4300iBlock(FUNCTION_INFO * info) {
if (bProfiling()) { m_Profile.StartTimer(Timer_CompileBlock); } if (bProfiling()) { m_Profile.StartTimer(Timer_CompileBlock); }
DWORD StartAddress; DWORD StartAddress;
if (!_MMU->TranslateVaddr(BlockInfo.StartVAddr,StartAddress)) _Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
if (!_TLB->TranslateVaddr(BlockInfo.StartVAddr,StartAddress))
{ {
DisplayError("Ummm... Where does this block go\n%X",BlockInfo.StartVAddr); DisplayError("Ummm... Where does this block go\n%X",BlockInfo.StartVAddr);
return false; return false;
} }
#endif
/* MarkCodeBlock(StartAddress); /* MarkCodeBlock(StartAddress);
if (StartAddress < RdramSize()) { if (StartAddress < RdramSize()) {
CPU_Message("====== RDRAM: block (%X:%d) ======", StartAddress>>12,N64_Blocks.NoOfRDRamBlocks[StartAddress>>12]); CPU_Message("====== RDRAM: block (%X:%d) ======", StartAddress>>12,N64_Blocks.NoOfRDRamBlocks[StartAddress>>12]);
@ -1911,7 +1936,9 @@ bool CRecompiler::Compiler4300iBlock(FUNCTION_INFO * info) {
info->SetVEndPC(BlockInfo.EndVAddr); info->SetVEndPC(BlockInfo.EndVAddr);
info->SetFunctionAddr(BlockInfo.CompiledLocation); info->SetFunctionAddr(BlockInfo.CompiledLocation);
_MMU->VAddrToRealAddr(info->VStartPC(),*(reinterpret_cast<void **>(&info->MemLocation[0]))); _Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
_TLB->VAddrToRealAddr(info->VStartPC(),*(reinterpret_cast<void **>(&info->MemLocation[0])));
info->MemLocation[1] = info->MemLocation[0] + 1; info->MemLocation[1] = info->MemLocation[0] + 1;
info->MemContents[0] = *info->MemLocation[0]; info->MemContents[0] = *info->MemLocation[0];
info->MemContents[1] = *info->MemLocation[1]; info->MemContents[1] = *info->MemLocation[1];
@ -1934,6 +1961,7 @@ bool CRecompiler::Compiler4300iBlock(FUNCTION_INFO * info) {
DisplayMessage(0,"Memory used: %d mb %-3d kb %-3d bytes Total Available: %d mb",MB,KB,Size, TotalAvaliable); DisplayMessage(0,"Memory used: %d mb %-3d kb %-3d bytes Total Available: %d mb",MB,KB,Size, TotalAvaliable);
} }
if (bProfiling()) { m_Profile.StopTimer(); } if (bProfiling()) { m_Profile.StopTimer(); }
#endif
DWORD TimeTaken = timeGetTime() - StartTime; DWORD TimeTaken = timeGetTime() - StartTime;
WriteTraceF(TraceRecompiler,"Compile Block-Done: %X-%X - Taken: %d",info->VStartPC(),info->VEndPC(),TimeTaken); WriteTraceF(TraceRecompiler,"Compile Block-Done: %X-%X - Taken: %d",info->VStartPC(),info->VEndPC(),TimeTaken);
@ -1943,6 +1971,7 @@ bool CRecompiler::Compiler4300iBlock(FUNCTION_INFO * info) {
void CRecompiler::RecompilerMain_ChangeMemory ( void ) void CRecompiler::RecompilerMain_ChangeMemory ( void )
{ {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix #ifdef tofix
DWORD Value, Addr; DWORD Value, Addr;
BYTE * Block; BYTE * Block;
@ -1987,7 +2016,7 @@ void CRecompiler::RecompilerMain_ChangeMemory ( void )
Block = CompileDelaySlot(); Block = CompileDelaySlot();
Value = 0x7C7C0000; Value = 0x7C7C0000;
Value += (WORD)(TargetIndex); Value += (WORD)(TargetIndex);
MemValue = *(DWORD *)(N64MEM + Addr); MemValue = *(DWORD *)(RDRAM + Addr);
if ( (MemValue >> 16) == 0x7C7C) { if ( (MemValue >> 16) == 0x7C7C) {
MemValue = OrigMem[(MemValue & 0xFFFF)].OriginalValue; MemValue = OrigMem[(MemValue & 0xFFFF)].OriginalValue;
} }
@ -2008,7 +2037,7 @@ void CRecompiler::RecompilerMain_ChangeMemory ( void )
} }
__try { __try {
Value = *(DWORD *)(N64MEM + Addr); Value = *(DWORD *)(RDRAM + Addr);
if ( (Value >> 16) == 0x7C7C) { if ( (Value >> 16) == 0x7C7C) {
DWORD Index = (Value & 0xFFFF); DWORD Index = (Value & 0xFFFF);
Block = (BYTE *)OrigMem[Index].CompiledLocation; Block = (BYTE *)OrigMem[Index].CompiledLocation;
@ -2042,7 +2071,7 @@ void CRecompiler::RecompilerMain_ChangeMemory ( void )
} }
Value = 0x7C7C0000; Value = 0x7C7C0000;
Value += (WORD)(TargetIndex); Value += (WORD)(TargetIndex);
MemValue = *(DWORD *)(N64MEM + Addr); MemValue = *(DWORD *)(RDRAM + Addr);
if ( (MemValue >> 16) == 0x7C7C) { if ( (MemValue >> 16) == 0x7C7C) {
MemValue = OrigMem[(MemValue & 0xFFFF)].OriginalValue; MemValue = OrigMem[(MemValue & 0xFFFF)].OriginalValue;
} }
@ -2051,7 +2080,7 @@ void CRecompiler::RecompilerMain_ChangeMemory ( void )
OrigMem[(WORD)(TargetIndex)].PAddr = Addr; OrigMem[(WORD)(TargetIndex)].PAddr = Addr;
OrigMem[(WORD)(TargetIndex)].VAddr = PROGRAM_COUNTER; OrigMem[(WORD)(TargetIndex)].VAddr = PROGRAM_COUNTER;
TargetIndex += 1; TargetIndex += 1;
*(DWORD *)(N64MEM + Addr) = Value; *(DWORD *)(RDRAM + Addr) = Value;
NextInstruction = NORMAL; NextInstruction = NORMAL;
} }
if (Profiling && IndvidualBlock) { if (Profiling && IndvidualBlock) {
@ -2083,8 +2112,10 @@ void CRecompiler::RecompilerMain_ChangeMemory ( void )
FUNCTION_INFO * CRecompiler::CompilerCode ( void ) FUNCTION_INFO * CRecompiler::CompilerCode ( void )
{ {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
_MMU->CheckRecompMem(RecompPos); _MMU->CheckRecompMem(RecompPos);
FUNCTION_INFO * Info = m_Functions.AddFunctionInfo(PROGRAM_COUNTER,_MMU->TranslateVaddr(PROGRAM_COUNTER)); FUNCTION_INFO * Info = m_Functions.AddFunctionInfo(PROGRAM_COUNTER,_TLB->TranslateVaddr(PROGRAM_COUNTER));
__try { __try {
if (!Compiler4300iBlock(Info)) if (!Compiler4300iBlock(Info))
{ {
@ -2093,13 +2124,14 @@ FUNCTION_INFO * CRecompiler::CompilerCode ( void )
return Info; return Info;
} __except(EXCEPTION_EXECUTE_HANDLER) { } __except(EXCEPTION_EXECUTE_HANDLER) {
ResetRecompCode(); ResetRecompCode();
Info = m_Functions.AddFunctionInfo(PROGRAM_COUNTER,_MMU->TranslateVaddr(PROGRAM_COUNTER)); Info = m_Functions.AddFunctionInfo(PROGRAM_COUNTER,_TLB->TranslateVaddr(PROGRAM_COUNTER));
if (!Compiler4300iBlock(Info)) if (!Compiler4300iBlock(Info))
{ {
return NULL; return NULL;
} }
return Info; return Info;
} }
#endif
return NULL; return NULL;
} }
@ -2519,10 +2551,10 @@ bool CRecompiler::GenerateX86Code(CBlockInfo & BlockInfo, CBlockSection * Sectio
//if (m_SyncSystem && (DWORD)RecompPos > 0x6094C283) { //if (m_SyncSystem && (DWORD)RecompPos > 0x6094C283) {
MoveConstToVariable(Section->StartPC,&PROGRAM_COUNTER,"PROGRAM_COUNTER"); MoveConstToVariable(Section->StartPC,&PROGRAM_COUNTER,"PROGRAM_COUNTER");
if (BlockCycleCount != 0) { if (BlockCycleCount != 0) {
AddConstToVariable(BlockCycleCount,&CP0[9],Cop0_Name[9]); AddConstToVariable(BlockCycleCount,&_CP0[9],Cop0_Name[9]);
SubConstFromVariable(BlockCycleCount,&Timers.Timer,"Timer"); SubConstFromVariable(BlockCycleCount,&Timers.Timer,"Timer");
} }
if (BlockRandomModifier != 0) { SubConstFromVariable(BlockRandomModifier,&CP0[1],Cop0_Name[1]); } if (BlockRandomModifier != 0) { SubConstFromVariable(BlockRandomModifier,&_CP0[1],Cop0_Name[1]); }
BlockCycleCount = 0; BlockCycleCount = 0;
BlockRandomModifier = 0; BlockRandomModifier = 0;
Call_Direct(SyncToPC, "SyncToPC"); Call_Direct(SyncToPC, "SyncToPC");
@ -2530,11 +2562,11 @@ bool CRecompiler::GenerateX86Code(CBlockInfo & BlockInfo, CBlockSection * Sectio
}*/ }*/
do { do {
__try { __try {
if (!r4300i_LW_VAddr(Section->CompilePC, &g_Opcode.Hex)) { if (!_MMU->LW_VAddr(Section->CompilePC, g_Opcode.Hex)) {
DisplayError(GS(MSG_FAIL_LOAD_WORD)); DisplayError(GS(MSG_FAIL_LOAD_WORD));
ExitThread(0); ExitThread(0);
} }
} __except( r4300i_CPU_MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) { } __except( _MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) {
DisplayError(GS(MSG_UNKNOWN_MEM_ACTION)); DisplayError(GS(MSG_UNKNOWN_MEM_ACTION));
ExitThread(0); ExitThread(0);
} }
@ -2545,7 +2577,7 @@ bool CRecompiler::GenerateX86Code(CBlockInfo & BlockInfo, CBlockSection * Sectio
// WriteBackRegisters(Section); // WriteBackRegisters(Section);
// UpdateCounters(&Section->BlockCycleCount(),&Section->BlockRandomModifier(),false); // UpdateCounters(&Section->BlockCycleCount(),&Section->BlockRandomModifier(),false);
// //
// CompConstToVariable(0x26D5BB0,&CP0[9],Cop0_Name[9]); // CompConstToVariable(0x26D5BB0,&_CP0[9],Cop0_Name[9]);
// JlLabel8("blah",0); // JlLabel8("blah",0);
// BYTE * Jump = RecompPos - 1; // BYTE * Jump = RecompPos - 1;
// // BreakPoint(__FILE__,__LINE__); // // BreakPoint(__FILE__,__LINE__);
@ -2969,7 +3001,7 @@ void CRecompiler::CompileExit ( CBlockSection * Section, DWORD JumpPC, DWORD Tar
// if (TargetPC >= 0x80000000 && TargetPC < 0xC0000000) { // if (TargetPC >= 0x80000000 && TargetPC < 0xC0000000) {
// DWORD pAddr = TargetPC & 0x1FFFFFFF; // DWORD pAddr = TargetPC & 0x1FFFFFFF;
// //
// MoveVariableToX86reg((BYTE *)N64MEM + pAddr,"N64MEM + pAddr",x86_EAX); // MoveVariableToX86reg((BYTE *)RDRAM + pAddr,"RDRAM + pAddr",x86_EAX);
// Jump2 = NULL; // Jump2 = NULL;
// } else { // } else {
// MoveConstToX86reg((TargetPC >> 12),x86_ECX); // MoveConstToX86reg((TargetPC >> 12),x86_ECX);
@ -3024,7 +3056,7 @@ void CRecompiler::CompileExit ( CBlockSection * Section, DWORD JumpPC, DWORD Tar
TestX86RegToX86Reg(x86_ECX,x86_ECX); TestX86RegToX86Reg(x86_ECX,x86_ECX);
JeLabel8("NoTlbEntry",0); JeLabel8("NoTlbEntry",0);
Jump2 = RecompPos - 1; Jump2 = RecompPos - 1;
AddConstToX86Reg(x86_ECX,(DWORD)JumpTable - (DWORD)N64MEM); AddConstToX86Reg(x86_ECX,(DWORD)JumpTable - (DWORD)RDRAM);
MoveX86regPointerToX86reg(x86_ECX, x86_EBX,x86_ECX); MoveX86regPointerToX86reg(x86_ECX, x86_EBX,x86_ECX);
} }
if (TargetPC < 0x90000000 || TargetPC >= 0xC0000000) if (TargetPC < 0x90000000 || TargetPC >= 0xC0000000)
@ -3096,7 +3128,7 @@ void CRecompiler::UpdateCounters ( DWORD * Cycles, DWORD * RandomMod, BOOL Check
if (*RandomMod != 0 || *Cycles != 0) { if (*RandomMod != 0 || *Cycles != 0) {
WriteX86Comment("Update Counters"); WriteX86Comment("Update Counters");
} }
if (*RandomMod != 0) { SubConstFromVariable(*RandomMod,&CP0[1],Cop0_Name[1]); } if (*RandomMod != 0) { SubConstFromVariable(*RandomMod,&_CP0[1],Cop0_Name[1]); }
if (*Cycles != 0) { if (*Cycles != 0) {
if (m_SyncSystem) { if (m_SyncSystem) {
char text[100]; char text[100];
@ -3108,8 +3140,8 @@ void CRecompiler::UpdateCounters ( DWORD * Cycles, DWORD * RandomMod, BOOL Check
Call_Direct(UpdateSyncCPU,"UpdateSyncCPU"); Call_Direct(UpdateSyncCPU,"UpdateSyncCPU");
Popad(); Popad();
} }
AddConstToVariable(*Cycles,&CP0[9],Cop0_Name[9]); AddConstToVariable(*Cycles,&_CP0[9],Cop0_Name[9]);
SubConstFromVariable(*Cycles,g_Timer,"Timer"); SubConstFromVariable(*Cycles,_Timer,"Timer");
} }
*Cycles = 0; *Cycles = 0;
*RandomMod = 0; *RandomMod = 0;
@ -3120,9 +3152,9 @@ void CRecompiler::UpdateCounters ( DWORD * Cycles, DWORD * RandomMod, BOOL Check
// Timer // Timer
if (*Cycles == 0) { if (*Cycles == 0) {
CompConstToVariable(0,g_Timer,"Timer"); CompConstToVariable(0,_Timer,"Timer");
//} else{ //} else{
// uses SubConstFromVariable(Cycles,g_Timer,"Timer"); for compare flag // uses SubConstFromVariable(Cycles,_Timer,"Timer"); for compare flag
} }
JnsLabel8("Continue_From_Timer_Test",0); JnsLabel8("Continue_From_Timer_Test",0);
Jump = RecompPos - 1; Jump = RecompPos - 1;
@ -3186,7 +3218,10 @@ void SyncRegState (CBlockSection * Section, CRegInfo * SyncTo) {
} }
} }
if (!changed) { if (!changed) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
MoveVariableToX86reg(g_MemoryStack,"MemoryStack",x86Reg); MoveVariableToX86reg(g_MemoryStack,"MemoryStack",x86Reg);
#endif
} }
changed = true; changed = true;
} }
@ -3244,8 +3279,8 @@ void SyncRegState (CBlockSection * Section, CRegInfo * SyncTo) {
UnMap_X86reg(Section,x86RegHi); UnMap_X86reg(Section,x86RegHi);
switch (Section->MipsRegState(count)) { switch (Section->MipsRegState(count)) {
case CRegInfo::STATE_UNKNOWN: case CRegInfo::STATE_UNKNOWN:
MoveVariableToX86reg(&GPR[count].UW[0],GPR_NameLo[count],x86Reg); MoveVariableToX86reg(&_GPR[count].UW[0],GPR_NameLo[count],x86Reg);
MoveVariableToX86reg(&GPR[count].UW[1],GPR_NameHi[count],x86RegHi); MoveVariableToX86reg(&_GPR[count].UW[1],GPR_NameHi[count],x86RegHi);
break; break;
case CRegInfo::STATE_MAPPED_64: case CRegInfo::STATE_MAPPED_64:
MoveX86RegToX86Reg(Section->MipsRegLo(count),x86Reg); MoveX86RegToX86Reg(Section->MipsRegLo(count),x86Reg);
@ -3291,7 +3326,7 @@ void SyncRegState (CBlockSection * Section, CRegInfo * SyncTo) {
x86Reg = SyncTo->MipsRegLo(count); x86Reg = SyncTo->MipsRegLo(count);
UnMap_X86reg(Section,x86Reg); UnMap_X86reg(Section,x86Reg);
switch (Section->MipsRegState(count)) { switch (Section->MipsRegState(count)) {
case CRegInfo::STATE_UNKNOWN: MoveVariableToX86reg(&GPR[count].UW[0],GPR_NameLo[count],x86Reg); break; case CRegInfo::STATE_UNKNOWN: MoveVariableToX86reg(&_GPR[count].UW[0],GPR_NameLo[count],x86Reg); break;
case CRegInfo::STATE_CONST_32: MoveConstToX86reg(Section->MipsRegLo(count),x86Reg); break; case CRegInfo::STATE_CONST_32: MoveConstToX86reg(Section->MipsRegLo(count),x86Reg); break;
case CRegInfo::STATE_MAPPED_32_SIGN: case CRegInfo::STATE_MAPPED_32_SIGN:
MoveX86RegToX86Reg(Section->MipsRegLo(count),x86Reg); MoveX86RegToX86Reg(Section->MipsRegLo(count),x86Reg);
@ -3327,7 +3362,7 @@ void SyncRegState (CBlockSection * Section, CRegInfo * SyncTo) {
switch (Section->MipsRegState(count)) { switch (Section->MipsRegState(count)) {
case CRegInfo::STATE_MAPPED_64: case CRegInfo::STATE_MAPPED_64:
case CRegInfo::STATE_UNKNOWN: case CRegInfo::STATE_UNKNOWN:
MoveVariableToX86reg(&GPR[count].UW[0],GPR_NameLo[count],x86Reg); MoveVariableToX86reg(&_GPR[count].UW[0],GPR_NameLo[count],x86Reg);
break; break;
case CRegInfo::STATE_MAPPED_32_ZERO: case CRegInfo::STATE_MAPPED_32_ZERO:
MoveX86RegToX86Reg(Section->MipsRegLo(count),x86Reg); MoveX86RegToX86Reg(Section->MipsRegLo(count),x86Reg);
@ -3420,9 +3455,9 @@ void CRecompiler::GenerateSectionLinkage (CBlockSection * Section) {
CPU_Message(" $FinishBlock:"); CPU_Message(" $FinishBlock:");
SetJump8(Jump,RecompPos); SetJump8(Jump,RecompPos);
} }
MoveConstToVariable(Section->CompilePC + 4,g_PROGRAM_COUNTER,"PROGRAM_COUNTER"); MoveConstToVariable(Section->CompilePC + 4,_PROGRAM_COUNTER,"PROGRAM_COUNTER");
WriteBackRegisters(Section); WriteBackRegisters(Section);
g_N64System->GetRecompiler()->UpdateCounters(&Section->BlockCycleCount(),&Section->BlockRandomModifier(),false); _N64System->GetRecompiler()->UpdateCounters(&Section->BlockCycleCount(),&Section->BlockRandomModifier(),false);
// WriteBackRegisters(Section); // WriteBackRegisters(Section);
// if (m_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); } // if (m_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); }
MoveConstToVariable(DELAY_SLOT,&NextInstruction,"NextInstruction"); MoveConstToVariable(DELAY_SLOT,&NextInstruction,"NextInstruction");
@ -3433,14 +3468,14 @@ void CRecompiler::GenerateSectionLinkage (CBlockSection * Section) {
if (Section->CompilePC == Section->Jump.TargetPC && (Section->Cont.FallThrough == false)) { if (Section->CompilePC == Section->Jump.TargetPC && (Section->Cont.FallThrough == false)) {
if (!DelaySlotEffectsJump(Section->CompilePC)) { if (!DelaySlotEffectsJump(Section->CompilePC)) {
CPU_Message("PermLoop *** a"); CPU_Message("PermLoop *** a");
MoveConstToVariable(Section->CompilePC,g_PROGRAM_COUNTER,"PROGRAM_COUNTER"); MoveConstToVariable(Section->CompilePC,_PROGRAM_COUNTER,"PROGRAM_COUNTER");
WriteBackRegisters(Section); WriteBackRegisters(Section);
Section->RegWorking.BlockCycleCount() -= CountPerOp(); Section->RegWorking.BlockCycleCount() -= CountPerOp();
g_N64System->GetRecompiler()->UpdateCounters(&Section->RegWorking.BlockCycleCount(),&Section->RegWorking.BlockRandomModifier(), false); _N64System->GetRecompiler()->UpdateCounters(&Section->RegWorking.BlockCycleCount(),&Section->RegWorking.BlockRandomModifier(), false);
Call_Direct(InPermLoop,"InPermLoop"); Call_Direct(InPermLoop,"InPermLoop");
Section->RegWorking.BlockCycleCount() += CountPerOp(); Section->RegWorking.BlockCycleCount() += CountPerOp();
g_N64System->GetRecompiler()->UpdateCounters(&Section->RegWorking.BlockCycleCount(),&Section->RegWorking.BlockRandomModifier(), true); _N64System->GetRecompiler()->UpdateCounters(&Section->RegWorking.BlockCycleCount(),&Section->RegWorking.BlockRandomModifier(), true);
g_N64System->GetRecompiler()->CompileSystemCheck(-1,Section->RegWorking); _N64System->GetRecompiler()->CompileSystemCheck(-1,Section->RegWorking);
} }
} }
@ -3461,7 +3496,7 @@ CPU_Message("PermLoop *** a");
JumpInfo[count]->LinkLocation2 = NULL; JumpInfo[count]->LinkLocation2 = NULL;
} }
} }
g_N64System->GetRecompiler()->CompileExit (Section,Section->CompilePC, JumpInfo[count]->TargetPC,JumpInfo[count]->RegSet,CExitInfo::Normal,true,NULL); _N64System->GetRecompiler()->CompileExit (Section,Section->CompilePC, JumpInfo[count]->TargetPC,JumpInfo[count]->RegSet,CExitInfo::Normal,true,NULL);
JumpInfo[count]->FallThrough = false; JumpInfo[count]->FallThrough = false;
} else if ((*TargetSection[count]) != NULL && JumpInfo[count] != NULL) { } else if ((*TargetSection[count]) != NULL && JumpInfo[count] != NULL) {
if (!JumpInfo[count]->FallThrough) { continue; } if (!JumpInfo[count]->FallThrough) { continue; }
@ -3474,7 +3509,7 @@ CPU_Message("PermLoop *** a");
JumpInfo[count]->LinkLocation2 = NULL; JumpInfo[count]->LinkLocation2 = NULL;
} }
} }
g_N64System->GetRecompiler()->CompileExit (Section,Section->CompilePC, JumpInfo[count]->TargetPC,JumpInfo[count]->RegSet,CExitInfo::Normal,true,NULL); _N64System->GetRecompiler()->CompileExit (Section,Section->CompilePC, JumpInfo[count]->TargetPC,JumpInfo[count]->RegSet,CExitInfo::Normal,true,NULL);
//FreeSection((*TargetSection[count]),Section); //FreeSection((*TargetSection[count]),Section);
} }
} }
@ -3508,19 +3543,19 @@ CPU_Message("PermLoop *** a");
if (JumpInfo[count]->TargetPC <= Section->CompilePC) { if (JumpInfo[count]->TargetPC <= Section->CompilePC) {
if (JumpInfo[count]->PermLoop) { if (JumpInfo[count]->PermLoop) {
CPU_Message("PermLoop *** 1"); CPU_Message("PermLoop *** 1");
MoveConstToVariable(JumpInfo[count]->TargetPC,g_PROGRAM_COUNTER,"PROGRAM_COUNTER"); MoveConstToVariable(JumpInfo[count]->TargetPC,_PROGRAM_COUNTER,"PROGRAM_COUNTER");
JumpInfo[count]->RegSet.BlockCycleCount() -= CountPerOp(); JumpInfo[count]->RegSet.BlockCycleCount() -= CountPerOp();
g_N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(), false); _N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(), false);
Call_Direct(InPermLoop,"InPermLoop"); Call_Direct(InPermLoop,"InPermLoop");
JumpInfo[count]->RegSet.BlockCycleCount() += CountPerOp(); JumpInfo[count]->RegSet.BlockCycleCount() += CountPerOp();
g_N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(), true); _N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(), true);
g_N64System->GetRecompiler()->CompileSystemCheck(-1,JumpInfo[count]->RegSet); _N64System->GetRecompiler()->CompileSystemCheck(-1,JumpInfo[count]->RegSet);
} else { } else {
g_N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(), &JumpInfo[count]->RegSet.BlockRandomModifier(), true); _N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(), &JumpInfo[count]->RegSet.BlockRandomModifier(), true);
g_N64System->GetRecompiler()->CompileSystemCheck(JumpInfo[count]->TargetPC,JumpInfo[count]->RegSet); _N64System->GetRecompiler()->CompileSystemCheck(JumpInfo[count]->TargetPC,JumpInfo[count]->RegSet);
} }
} else { } else {
g_N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(), &JumpInfo[count]->RegSet.BlockRandomModifier(), false); _N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(), &JumpInfo[count]->RegSet.BlockRandomModifier(), false);
} }
JumpInfo[count]->RegSet.BlockRandomModifier() = 0; JumpInfo[count]->RegSet.BlockRandomModifier() = 0;
JumpInfo[count]->RegSet.BlockCycleCount() = 0; JumpInfo[count]->RegSet.BlockCycleCount() = 0;
@ -3544,13 +3579,13 @@ CPU_Message("PermLoop *** 1");
if (Parent->CompiledLocation != NULL) { continue; } if (Parent->CompiledLocation != NULL) { continue; }
if (JumpInfo[count]->PermLoop) { if (JumpInfo[count]->PermLoop) {
CPU_Message("PermLoop *** 2"); CPU_Message("PermLoop *** 2");
MoveConstToVariable(JumpInfo[count]->TargetPC,g_PROGRAM_COUNTER,"PROGRAM_COUNTER"); MoveConstToVariable(JumpInfo[count]->TargetPC,_PROGRAM_COUNTER,"PROGRAM_COUNTER");
JumpInfo[count]->RegSet.BlockCycleCount() -= CountPerOp(); JumpInfo[count]->RegSet.BlockCycleCount() -= CountPerOp();
g_N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(), false); _N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(), false);
Call_Direct(InPermLoop,"InPermLoop"); Call_Direct(InPermLoop,"InPermLoop");
JumpInfo[count]->RegSet.BlockCycleCount() += CountPerOp(); JumpInfo[count]->RegSet.BlockCycleCount() += CountPerOp();
g_N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(), true); _N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(), true);
g_N64System->GetRecompiler()->CompileSystemCheck(-1,JumpInfo[count]->RegSet); _N64System->GetRecompiler()->CompileSystemCheck(-1,JumpInfo[count]->RegSet);
} }
if (JumpInfo[count]->FallThrough) { if (JumpInfo[count]->FallThrough) {
JumpInfo[count]->FallThrough = false; JumpInfo[count]->FallThrough = false;
@ -3563,8 +3598,8 @@ CPU_Message("PermLoop *** 1");
for (count = 0; count < 2; count ++) { for (count = 0; count < 2; count ++) {
if (JumpInfo[count]->FallThrough) { if (JumpInfo[count]->FallThrough) {
if (JumpInfo[count]->TargetPC < Section->CompilePC) { if (JumpInfo[count]->TargetPC < Section->CompilePC) {
g_N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(),true); _N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(),true);
g_N64System->GetRecompiler()->CompileSystemCheck(JumpInfo[count]->TargetPC,JumpInfo[count]->RegSet); _N64System->GetRecompiler()->CompileSystemCheck(JumpInfo[count]->TargetPC,JumpInfo[count]->RegSet);
} }
} }
} }
@ -3573,7 +3608,7 @@ CPU_Message("PermLoop *** 1");
for (count = 0; count < 2; count ++) { for (count = 0; count < 2; count ++) {
if (JumpInfo[count]->FallThrough) { if (JumpInfo[count]->FallThrough) {
g_N64System->GetRecompiler()->GenerateX86Code(*(Section->BlockInfo),(*TargetSection[count]),CBlockSection::GetNewTestValue()); _N64System->GetRecompiler()->GenerateX86Code(*(Section->BlockInfo),(*TargetSection[count]),CBlockSection::GetNewTestValue());
} }
} }
@ -3588,7 +3623,7 @@ CPU_Message("PermLoop *** 1");
SetJump32(JumpInfo[count]->LinkLocation2,RecompPos); SetJump32(JumpInfo[count]->LinkLocation2,RecompPos);
JumpInfo[count]->LinkLocation2 = NULL; JumpInfo[count]->LinkLocation2 = NULL;
} }
g_N64System->GetRecompiler()->CompileExit (Section,Section->CompilePC,JumpInfo[count]->TargetPC,JumpInfo[count]->RegSet,CExitInfo::Normal,true,NULL); _N64System->GetRecompiler()->CompileExit (Section,Section->CompilePC,JumpInfo[count]->TargetPC,JumpInfo[count]->RegSet,CExitInfo::Normal,true,NULL);
continue; continue;
} }
if (JumpInfo[count]->TargetPC != (*TargetSection[count])->StartPC) { if (JumpInfo[count]->TargetPC != (*TargetSection[count])->StartPC) {
@ -3596,7 +3631,7 @@ CPU_Message("PermLoop *** 1");
BreakPoint(__FILE__,__LINE__); BreakPoint(__FILE__,__LINE__);
} }
if ((*TargetSection[count])->CompiledLocation == NULL) { if ((*TargetSection[count])->CompiledLocation == NULL) {
g_N64System->GetRecompiler()->GenerateX86Code(*(*TargetSection[count])->BlockInfo,(*TargetSection[count]),CBlockSection::GetNewTestValue()); _N64System->GetRecompiler()->GenerateX86Code(*(*TargetSection[count])->BlockInfo,(*TargetSection[count]),CBlockSection::GetNewTestValue());
} else { } else {
char Label[100]; char Label[100];
@ -3609,18 +3644,18 @@ CPU_Message("PermLoop *** 1");
} }
Section->RegWorking = JumpInfo[count]->RegSet; Section->RegWorking = JumpInfo[count]->RegSet;
if (JumpInfo[count]->TargetPC <= Section->CompilePC) { if (JumpInfo[count]->TargetPC <= Section->CompilePC) {
g_N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(), true); _N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(), true);
if (JumpInfo[count]->PermLoop) { if (JumpInfo[count]->PermLoop) {
CPU_Message("PermLoop *** 3"); CPU_Message("PermLoop *** 3");
MoveConstToVariable(JumpInfo[count]->TargetPC,g_PROGRAM_COUNTER,"PROGRAM_COUNTER"); MoveConstToVariable(JumpInfo[count]->TargetPC,_PROGRAM_COUNTER,"PROGRAM_COUNTER");
Call_Direct(InPermLoop,"InPermLoop"); Call_Direct(InPermLoop,"InPermLoop");
g_N64System->GetRecompiler()->CompileSystemCheck(-1,JumpInfo[count]->RegSet); _N64System->GetRecompiler()->CompileSystemCheck(-1,JumpInfo[count]->RegSet);
} else { } else {
g_N64System->GetRecompiler()->CompileSystemCheck(JumpInfo[count]->TargetPC,JumpInfo[count]->RegSet); _N64System->GetRecompiler()->CompileSystemCheck(JumpInfo[count]->TargetPC,JumpInfo[count]->RegSet);
} }
} else{ } else{
g_N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(), false); _N64System->GetRecompiler()->UpdateCounters(&JumpInfo[count]->RegSet.BlockCycleCount(),&JumpInfo[count]->RegSet.BlockRandomModifier(), false);
} }
Section->RegWorking = JumpInfo[count]->RegSet; Section->RegWorking = JumpInfo[count]->RegSet;
SyncRegState(Section,&(*TargetSection[count])->RegStart); SyncRegState(Section,&(*TargetSection[count])->RegStart);
@ -3693,7 +3728,10 @@ void CRecompiler::RemoveFunction (FUNCTION_INFO * FunInfo, bool DelaySlot, REMOV
FUNCTION_INFO * info = m_Functions.FindFunction(Addr,0xFFF); FUNCTION_INFO * info = m_Functions.FindFunction(Addr,0xFFF);
if (info == NULL) if (info == NULL)
{ {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
_MMU->UnProtectMemory(Addr,Addr + 0xFFC); _MMU->UnProtectMemory(Addr,Addr + 0xFFC);
#endif
} }
} }
} }
@ -3707,7 +3745,9 @@ bool CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON
if (g_UseTlb) if (g_UseTlb)
{ {
DWORD VAddr, Index = 0; DWORD VAddr, Index = 0;
while (_MMU->PAddrToVAddr(Address,VAddr,Index)) _Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
while (_TLB->PAddrToVAddr(Address,VAddr,Index))
{ {
WriteTraceF(TraceRecompiler,"ClearRecompCode Vaddr %X len: %d",VAddr,length); WriteTraceF(TraceRecompiler,"ClearRecompCode Vaddr %X len: %d",VAddr,length);
if (!ClearRecompCode_Virt(VAddr,length,Reason)) if (!ClearRecompCode_Virt(VAddr,length,Reason))
@ -3715,6 +3755,7 @@ bool CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON
Result = false; Result = false;
} }
} }
#endif
} }
if (LookUpMode() == FuncFind_PhysicalLookup) if (LookUpMode() == FuncFind_PhysicalLookup)
{ {
@ -3787,7 +3828,10 @@ void CRecompiler::SyncRegState (CBlockSection * Section, CRegInfo * SyncTo)
} }
} }
if (!changed) { if (!changed) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
MoveVariableToX86reg(g_MemoryStack,"MemoryStack",x86Reg); MoveVariableToX86reg(g_MemoryStack,"MemoryStack",x86Reg);
#endif
} }
changed = TRUE; changed = TRUE;
} }
@ -3845,8 +3889,8 @@ void CRecompiler::SyncRegState (CBlockSection * Section, CRegInfo * SyncTo)
UnMap_X86reg(Section,x86RegHi); UnMap_X86reg(Section,x86RegHi);
switch (Section->MipsRegState(count)) { switch (Section->MipsRegState(count)) {
case CRegInfo::STATE_UNKNOWN: case CRegInfo::STATE_UNKNOWN:
MoveVariableToX86reg(&GPR[count].UW[0],GPR_NameLo[count],x86Reg); MoveVariableToX86reg(&_GPR[count].UW[0],GPR_NameLo[count],x86Reg);
MoveVariableToX86reg(&GPR[count].UW[1],GPR_NameHi[count],x86RegHi); MoveVariableToX86reg(&_GPR[count].UW[1],GPR_NameHi[count],x86RegHi);
break; break;
case CRegInfo::STATE_MAPPED_64: case CRegInfo::STATE_MAPPED_64:
MoveX86RegToX86Reg(Section->MipsRegLo(count),x86Reg); MoveX86RegToX86Reg(Section->MipsRegLo(count),x86Reg);
@ -3892,7 +3936,7 @@ void CRecompiler::SyncRegState (CBlockSection * Section, CRegInfo * SyncTo)
x86Reg = SyncTo->MipsRegLo(count); x86Reg = SyncTo->MipsRegLo(count);
UnMap_X86reg(Section,x86Reg); UnMap_X86reg(Section,x86Reg);
switch (Section->MipsRegState(count)) { switch (Section->MipsRegState(count)) {
case CRegInfo::STATE_UNKNOWN: MoveVariableToX86reg(&GPR[count].UW[0],GPR_NameLo[count],x86Reg); break; case CRegInfo::STATE_UNKNOWN: MoveVariableToX86reg(&_GPR[count].UW[0],GPR_NameLo[count],x86Reg); break;
case CRegInfo::STATE_CONST_32: MoveConstToX86reg(Section->MipsRegLo(count),x86Reg); break; case CRegInfo::STATE_CONST_32: MoveConstToX86reg(Section->MipsRegLo(count),x86Reg); break;
case CRegInfo::STATE_MAPPED_32_SIGN: case CRegInfo::STATE_MAPPED_32_SIGN:
MoveX86RegToX86Reg(Section->MipsRegLo(count),x86Reg); MoveX86RegToX86Reg(Section->MipsRegLo(count),x86Reg);
@ -3928,7 +3972,7 @@ void CRecompiler::SyncRegState (CBlockSection * Section, CRegInfo * SyncTo)
switch (Section->MipsRegState(count)) { switch (Section->MipsRegState(count)) {
case CRegInfo::STATE_MAPPED_64: case CRegInfo::STATE_MAPPED_64:
case CRegInfo::STATE_UNKNOWN: case CRegInfo::STATE_UNKNOWN:
MoveVariableToX86reg(&GPR[count].UW[0],GPR_NameLo[count],x86Reg); MoveVariableToX86reg(&_GPR[count].UW[0],GPR_NameLo[count],x86Reg);
break; break;
case CRegInfo::STATE_MAPPED_32_ZERO: case CRegInfo::STATE_MAPPED_32_ZERO:
MoveX86RegToX86Reg(Section->MipsRegLo(count),x86Reg); MoveX86RegToX86Reg(Section->MipsRegLo(count),x86Reg);

View File

@ -13,8 +13,6 @@ public:
}; };
private: private:
CMipsMemory * const _MMU; //Memory of the n64
CRegisters * const _Reg;
bool const m_SyncSystem; bool const m_SyncSystem;
CProfiling & m_Profile; CProfiling & m_Profile;
bool & m_EndEmulation; bool & m_EndEmulation;
@ -53,7 +51,7 @@ private:
void RemoveFunction (FUNCTION_INFO * FunInfo, bool DelaySlot, REMOVE_REASON Reason ); void RemoveFunction (FUNCTION_INFO * FunInfo, bool DelaySlot, REMOVE_REASON Reason );
public: public:
CRecompiler (CMipsMemory * MMU, CProfiling & Profile, bool & EndEmulation, bool SyncSystem); CRecompiler (CProfiling & Profile, bool & EndEmulation, bool SyncSystem);
~CRecompiler (void); ~CRecompiler (void);
void Run ( void ); void Run ( void );

View File

@ -1,14 +1,13 @@
#include "..\N64 System.h" #include "..\N64 System.h"
#include "..\\User Interface\\resource.h" #include "..\\User Interface\\resource.h"
RomInformation::RomInformation (const char * RomFile, CNotification * Notify): RomInformation::RomInformation (const char * RomFile):
_Notify(Notify),
m_DeleteRomInfo(true), m_DeleteRomInfo(true),
m_FileName(RomFile? RomFile : ""), m_FileName(RomFile? RomFile : ""),
m_pRomInfo(NULL) m_pRomInfo(NULL)
{ {
if (m_FileName.length() == 0) { return; } if (m_FileName.length() == 0) { return; }
m_pRomInfo = new CN64Rom(Notify); m_pRomInfo = new CN64Rom;
if (!m_pRomInfo->LoadN64Image(m_FileName.c_str())) { if (!m_pRomInfo->LoadN64Image(m_FileName.c_str())) {
delete m_pRomInfo; delete m_pRomInfo;
m_pRomInfo = NULL; m_pRomInfo = NULL;
@ -16,8 +15,7 @@ RomInformation::RomInformation (const char * RomFile, CNotification * Notify):
} }
} }
RomInformation::RomInformation (CN64Rom * RomInfo, CNotification * Notify): RomInformation::RomInformation (CN64Rom * RomInfo) :
_Notify(Notify),
m_DeleteRomInfo(false), m_DeleteRomInfo(false),
m_FileName(RomInfo ? RomInfo->GetFileName().c_str() : ""), m_FileName(RomInfo ? RomInfo->GetFileName().c_str() : ""),
m_pRomInfo(RomInfo) m_pRomInfo(RomInfo)

View File

@ -1,5 +1,5 @@
class RomInformation { class RomInformation
CNotification * const _Notify; {
bool const m_DeleteRomInfo; bool const m_DeleteRomInfo;
stdstr const m_FileName; stdstr const m_FileName;
CN64Rom * m_pRomInfo; CN64Rom * m_pRomInfo;
@ -7,8 +7,8 @@ class RomInformation {
friend DWORD CALLBACK RomInfoProc ( WND_HANDLE, DWORD, DWORD, DWORD ); friend DWORD CALLBACK RomInfoProc ( WND_HANDLE, DWORD, DWORD, DWORD );
public: public:
RomInformation(const char * RomFile, CNotification * Notify); RomInformation(const char * RomFile );
RomInformation(CN64Rom * RomInfo, CNotification * Notify); RomInformation(CN64Rom * RomInfo );
~RomInformation(void); ~RomInformation(void);
void DisplayInformation (WND_HANDLE hParent) const; void DisplayInformation (WND_HANDLE hParent) const;

View File

@ -0,0 +1,27 @@
#include "N64 System/C Core/C Core.h"
#include "System Globals.h"
CN64System * _N64System;
CN64System * _SyncSystem;
CRecompiler * _Recompiler;
CMipsMemory * _MMU; //Memory of the n64
CTLB * _TLB; //TLB Unit
CRegisters * _Reg; //Current Register Set attacted to the _MMU
CNotification * _Notify;
//CSettings * _Settings;
CPlugins * _Plugins;
CN64Rom * _Rom; //The current rom that this system is executing.. it can only execute one file at the time
CAudio * _Audio;
CMemoryLabel * _Labels;
MULTI_ACCESS_QWORD * _GPR, * _FPR, * _RegHI, * _RegLO;
DWORD * _PROGRAM_COUNTER, * _CP0, * _RegMI, * _LLBit,
* _LLAddr, * _FPCR, * _RegSI, * _RegRI, * _RegPI, * _RegAI,
* _RegVI, * _RegDPC, * _RegSP, * _RegRDRAM;
double ** _FPRDoubleLocation;
float ** _FPRFloatLocation;
enum TimerType * _CurrentTimerType;
int * _Timer;

View File

@ -0,0 +1,21 @@
extern CN64System * _N64System;
extern CN64System * _SyncSystem;
extern CRecompiler * _Recompiler;
extern CMipsMemory * _MMU; //Memory of the n64
extern CTLB * _TLB; //TLB Unit
extern CRegisters * _Reg; //Current Register Set attacted to the _MMU
extern CNotification * _Notify;
extern CSettings * _Settings;
extern CPlugins * _Plugins;
extern CN64Rom * _Rom; //The current rom that this system is executing.. it can only execute one file at the time
extern CAudio * _Audio;
extern CMemoryLabel * _Labels;
extern MULTI_ACCESS_QWORD * _GPR, * _FPR, * _RegHI, * _RegLO;
extern DWORD * _PROGRAM_COUNTER, * _CP0, * _RegMI, * _LLBit,
* _LLAddr, * _FPCR, * _RegSI, * _RegRI, * _RegPI, * _RegAI,
* _RegVI, * _RegDPC, * _RegSP, * _RegRDRAM;
extern double ** _FPRDoubleLocation;
extern float ** _FPRFloatLocation;
extern enum TimerType * _CurrentTimerType;
extern int * _Timer;

View File

@ -0,0 +1 @@
#include "../stdafx.h"

View File

@ -3,7 +3,8 @@
void FixUPXIssue ( BYTE * ProgramLocation ); void FixUPXIssue ( BYTE * ProgramLocation );
CAudioPlugin::CAudioPlugin ( const char * FileName) { CAudioPlugin::CAudioPlugin ( const char * FileName)
{
//Make sure all parts of the class are initialized //Make sure all parts of the class are initialized
m_Initilized = false; m_Initilized = false;
m_RomOpen = false; m_RomOpen = false;
@ -90,7 +91,6 @@ CAudioPlugin::CAudioPlugin ( const char * FileName) {
if (PluginOpened == NULL) { UnloadPlugin(); return; } if (PluginOpened == NULL) { UnloadPlugin(); return; }
PluginOpened(); PluginOpened();
} }
} }
CAudioPlugin::~CAudioPlugin (void) { CAudioPlugin::~CAudioPlugin (void) {
@ -162,18 +162,16 @@ bool CAudioPlugin::Initiate ( CN64System * System, CMainGui * RenderWindow ) {
Sleep(100); Sleep(100);
return m_Initilized; return m_Initilized;
} }
_System = System;
_Reg = System->_MMU->_Reg;
m_StatusReg = 0; m_StatusReg = 0;
//Send Initilization information to the DLL //Send Initilization information to the DLL
Info.hwnd = (HWND)RenderWindow->m_hMainWindow; Info.hwnd = (HWND)RenderWindow->m_hMainWindow;
Info.hinst = GetModuleHandle(NULL); Info.hinst = GetModuleHandle(NULL);
Info.MemoryBswaped = TRUE; Info.MemoryBswaped = TRUE;
Info.HEADER = System->_MMU->ROM; Info.HEADER = _Rom->GetRomAddress();
Info.RDRAM = System->_MMU->RDRAM; Info.RDRAM = _MMU->Rdram();
Info.DMEM = System->_MMU->DMEM; Info.DMEM = _MMU->Dmem();
Info.IMEM = System->_MMU->IMEM; Info.IMEM = _MMU->Imem();
Info.MI__INTR_REG = &_Reg->AudioIntrReg; Info.MI__INTR_REG = &_Reg->AudioIntrReg;
Info.AI__DRAM_ADDR_REG = &_Reg->AI_DRAM_ADDR_REG; Info.AI__DRAM_ADDR_REG = &_Reg->AI_DRAM_ADDR_REG;
Info.AI__LEN_REG = &_Reg->AI_LEN_REG; Info.AI__LEN_REG = &_Reg->AI_LEN_REG;
@ -263,9 +261,6 @@ void CAudioPlugin::UnloadPlugin(void) {
RomClosed = NULL; RomClosed = NULL;
CloseDLL = NULL; CloseDLL = NULL;
m_CountsPerByte = 100; m_CountsPerByte = 100;
_System = NULL;
_Reg = NULL;
} }
void CAudioPlugin::DacrateChanged (SystemType Type) { void CAudioPlugin::DacrateChanged (SystemType Type) {

View File

@ -3,9 +3,6 @@ class CAudioPlugin {
bool m_Initilized, m_RomOpen; bool m_Initilized, m_RomOpen;
void * m_hAudioThread; void * m_hAudioThread;
PLUGIN_INFO m_PluginInfo; PLUGIN_INFO m_PluginInfo;
CN64System * _System;
CRegisters * _Reg;
DWORD m_StatusReg; DWORD m_StatusReg;
DWORD m_CountsPerByte; DWORD m_CountsPerByte;

View File

@ -107,7 +107,6 @@ CControl_Plugin::~CControl_Plugin (void) {
} }
bool CControl_Plugin::Initiate ( CN64System * System, CMainGui * RenderWindow ) { bool CControl_Plugin::Initiate ( CN64System * System, CMainGui * RenderWindow ) {
_Notify = RenderWindow->GetNotifyClass();
m_PluginControllers[0].Present = FALSE; m_PluginControllers[0].Present = FALSE;
m_PluginControllers[0].RawData = FALSE; m_PluginControllers[0].RawData = FALSE;
m_PluginControllers[0].Plugin = PLUGIN_NONE; m_PluginControllers[0].Plugin = PLUGIN_NONE;
@ -174,7 +173,7 @@ bool CControl_Plugin::Initiate ( CN64System * System, CMainGui * RenderWindow )
m_Initilized = true; m_Initilized = true;
} else { } else {
ControlInfo.Controls = m_PluginControllers; ControlInfo.Controls = m_PluginControllers;
ControlInfo.HEADER = System->_MMU->ROM; ControlInfo.HEADER = _Rom->GetRomAddress();
ControlInfo.hinst = GetModuleHandle(NULL); ControlInfo.hinst = GetModuleHandle(NULL);
ControlInfo.hMainWindow = (HWND)RenderWindow->m_hMainWindow; ControlInfo.hMainWindow = (HWND)RenderWindow->m_hMainWindow;
ControlInfo.MemoryBswaped = TRUE; ControlInfo.MemoryBswaped = TRUE;

View File

@ -219,15 +219,14 @@ bool CGfxPlugin::Initiate ( CN64System * System, CMainGui * RenderWindow ) {
} }
//Send Initilization information to the DLL //Send Initilization information to the DLL
CRegisters * _Reg = System->_MMU->_Reg;
Info.MemoryBswaped = TRUE; Info.MemoryBswaped = TRUE;
Info.CheckInterrupts = DummyCheckInterrupts; Info.CheckInterrupts = DummyCheckInterrupts;
Info.hWnd = (HWND)RenderWindow->m_hMainWindow; Info.hWnd = (HWND)RenderWindow->m_hMainWindow;
Info.hStatusBar = (HWND)RenderWindow->m_hStatusWnd; Info.hStatusBar = (HWND)RenderWindow->m_hStatusWnd;
Info.HEADER = System->_MMU->ROM; Info.HEADER = _Rom->GetRomAddress();
Info.RDRAM = System->_MMU->RDRAM; Info.RDRAM = _MMU->Rdram();
Info.DMEM = System->_MMU->DMEM; Info.DMEM = _MMU->Dmem();
Info.IMEM = System->_MMU->IMEM; Info.IMEM = _MMU->Imem();
Info.MI__INTR_REG = &_Reg->MI_INTR_REG; Info.MI__INTR_REG = &_Reg->MI_INTR_REG;
Info.DPC__START_REG = &_Reg->DPC_START_REG; Info.DPC__START_REG = &_Reg->DPC_START_REG;
Info.DPC__END_REG = &_Reg->DPC_END_REG; Info.DPC__END_REG = &_Reg->DPC_END_REG;

View File

@ -88,30 +88,19 @@ void CPlugins::SetRenderWindows( CMainGui * RenderWindow, CMainGui * DummyWindow
_DummyWindow = DummyWindow; _DummyWindow = DummyWindow;
} }
bool CPlugins::Initiate ( CN64System * System ) bool CPlugins::Initiate ( void )
{ {
PVOID MemBuffer[] = { bool bResult = _RenderWindow->InitiatePlugins();
VirtualAlloc( NULL, 0x10000000, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE ),
VirtualAlloc( NULL, 0x10000000, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE ),
VirtualAlloc( NULL, 0x10000000, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE ),
};
bool bResult = _RenderWindow->InitiatePlugins(this, System);
if (bResult) if (bResult)
{ {
m_Gfx->RomOpened(); m_Gfx->RomOpened();
m_Audio->RomOpened(); m_Audio->RomOpened();
m_Control->RomOpened(); m_Control->RomOpened();
} }
for (int i = 0; i < sizeof(MemBuffer) / sizeof(MemBuffer[0]); i++)
{
VirtualFree( MemBuffer[i], 0 , MEM_RELEASE);
}
return bResult; return bResult;
} }
bool CPlugins::InitiateMainThread(CN64System * System ) bool CPlugins::InitiateMainThread( void )
{ {
WriteTrace(TraceDebug,"CPlugins::Initiate 1"); WriteTrace(TraceDebug,"CPlugins::Initiate 1");
//Check to make sure we have the plugin avaliable to be used //Check to make sure we have the plugin avaliable to be used
@ -132,14 +121,14 @@ bool CPlugins::InitiateMainThread(CN64System * System )
WriteTrace(TraceDebug,"CPlugins::Initiate 6"); WriteTrace(TraceDebug,"CPlugins::Initiate 6");
WriteTrace(TraceGfxPlugin,"Initiate: Starting"); WriteTrace(TraceGfxPlugin,"Initiate: Starting");
if (!m_Gfx->Initiate(System,_RenderWindow)) { return false; } if (!m_Gfx->Initiate(_N64System,_RenderWindow)) { return false; }
WriteTrace(TraceGfxPlugin,"Initiate: Done"); WriteTrace(TraceGfxPlugin,"Initiate: Done");
WriteTrace(TraceDebug,"CPlugins::Initiate 7"); WriteTrace(TraceDebug,"CPlugins::Initiate 7");
if (!m_Audio->Initiate(System,_RenderWindow)) { return false; } if (!m_Audio->Initiate(_N64System,_RenderWindow)) { return false; }
WriteTrace(TraceDebug,"CPlugins::Initiate 8"); WriteTrace(TraceDebug,"CPlugins::Initiate 8");
if (!m_Control->Initiate(System,_RenderWindow)) { return false; } if (!m_Control->Initiate(_N64System,_RenderWindow)) { return false; }
WriteTrace(TraceRSP ,"Initiate: Starting"); WriteTrace(TraceRSP ,"Initiate: Starting");
if (!m_RSP->Initiate(this,System)) { return false; } if (!m_RSP->Initiate(this,_N64System)) { return false; }
WriteTrace(TraceRSP,"Initiate: Done"); WriteTrace(TraceRSP,"Initiate: Done");
WriteTrace(TraceDebug,"CPlugins::Initiate 10"); WriteTrace(TraceDebug,"CPlugins::Initiate 10");

View File

@ -90,8 +90,8 @@ public:
CPlugins (const stdstr & PluginDir ); CPlugins (const stdstr & PluginDir );
~CPlugins (); ~CPlugins ();
bool Initiate ( CN64System * System ); bool Initiate ( void );
bool InitiateMainThread ( CN64System * System ); bool InitiateMainThread ( void );
void SetRenderWindows ( CMainGui * RenderWindow, CMainGui * DummyWindow ); void SetRenderWindows ( CMainGui * RenderWindow, CMainGui * DummyWindow );
void ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ); void ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type );
void CopyPlugins ( const stdstr & DstDir ) const; void CopyPlugins ( const stdstr & DstDir ) const;

View File

@ -134,7 +134,6 @@ bool CPluginList::ValidPluginVersion ( PLUGIN_INFO & PluginInfo ) {
} }
#ifdef tofix #ifdef tofix
CPluginList::CPluginList (CSettings * Settings) { CPluginList::CPluginList (CSettings * Settings) {
_Settings = Settings; _Settings = Settings;

View File

@ -119,7 +119,8 @@ void CRSP_Plugin::GameReset(void)
} }
} }
bool CRSP_Plugin::Initiate ( CPlugins * Plugins, CN64System * System ) { bool CRSP_Plugin::Initiate ( CPlugins * Plugins, CN64System * System )
{
//Get DLL information //Get DLL information
void (__cdecl *GetDllInfo) ( PLUGIN_INFO * PluginInfo ); void (__cdecl *GetDllInfo) ( PLUGIN_INFO * PluginInfo );
GetDllInfo = (void (__cdecl *)(PLUGIN_INFO *))GetProcAddress( (HMODULE)hDll, "GetDllInfo" ); GetDllInfo = (void (__cdecl *)(PLUGIN_INFO *))GetProcAddress( (HMODULE)hDll, "GetDllInfo" );
@ -179,7 +180,8 @@ bool CRSP_Plugin::Initiate ( CPlugins * Plugins, CN64System * System ) {
//We are initilizing the plugin before any rom is loaded so we do not have any correct //We are initilizing the plugin before any rom is loaded so we do not have any correct
//paramaters here .. just needed to we can config the DLL //paramaters here .. just needed to we can config the DLL
if (System == NULL) { if (System == NULL)
{
BYTE Buffer[100]; BYTE Buffer[100];
DWORD Value = 0; DWORD Value = 0;
@ -227,7 +229,6 @@ bool CRSP_Plugin::Initiate ( CPlugins * Plugins, CN64System * System ) {
} }
//Send Initilization information to the DLL //Send Initilization information to the DLL
CRegisters * _Reg = System->_MMU->_Reg;
Info.CheckInterrupts = DummyCheckInterrupts; Info.CheckInterrupts = DummyCheckInterrupts;
Info.ProcessDlist = Plugins->Gfx()->ProcessDList; Info.ProcessDlist = Plugins->Gfx()->ProcessDList;
Info.ProcessRdpList = Plugins->Gfx()->ProcessRDPList; Info.ProcessRdpList = Plugins->Gfx()->ProcessRDPList;
@ -235,9 +236,9 @@ bool CRSP_Plugin::Initiate ( CPlugins * Plugins, CN64System * System ) {
Info.ProcessAlist = Plugins->Audio()->ProcessAList; Info.ProcessAlist = Plugins->Audio()->ProcessAList;
Info.hInst = GetModuleHandle(NULL);; Info.hInst = GetModuleHandle(NULL);;
Info.RDRAM = System->_MMU->RDRAM; Info.RDRAM = _MMU->Rdram();
Info.DMEM = System->_MMU->DMEM; Info.DMEM = _MMU->Dmem();
Info.IMEM = System->_MMU->IMEM; Info.IMEM = _MMU->Imem();
Info.MemoryBswaped = FALSE; Info.MemoryBswaped = FALSE;
Info.MI__INTR_REG = &_Reg->MI_INTR_REG; Info.MI__INTR_REG = &_Reg->MI_INTR_REG;

View File

@ -44,7 +44,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "../" /I "./" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "../" /I "./" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# SUBTRACT CPP /Fr # SUBTRACT CPP /Fr
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@ -281,6 +281,30 @@ SOURCE=".\User Interface\WTL Controls\ModifiedEditBox.cpp"
SOURCE=".\User Interface\WTL Controls\PartialGroupBox.cpp" SOURCE=".\User Interface\WTL Controls\PartialGroupBox.cpp"
# End Source File # End Source File
# End Group # End Group
# Begin Group "Debugger Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE="N64 System\Debugger\Debugger - Memory Dump.cpp"
# End Source File
# Begin Source File
SOURCE="N64 System\Debugger\Debugger - Memory Search.cpp"
# End Source File
# Begin Source File
SOURCE="N64 System\Debugger\Debugger - TLB.cpp"
# End Source File
# Begin Source File
SOURCE="N64 System\Debugger\Debugger - View Memory.cpp"
# End Source File
# Begin Source File
SOURCE="N64 System\Debugger\Debugger.cpp"
# End Source File
# End Group
# Begin Source File # Begin Source File
SOURCE="User Interface\Cheats.cpp" SOURCE="User Interface\Cheats.cpp"
@ -378,7 +402,7 @@ SOURCE="N64 System\C Core\C Core Interface.cpp"
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE="N64 System\C Core\C main.c" SOURCE=".\N64 System\C Core\C main.cpp"
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -402,7 +426,7 @@ SOURCE=".\N64 System\C Core\Eeprom.cpp"
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE="N64 System\C Core\Exception.c" SOURCE=".\N64 System\C Core\Exception.cpp"
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -414,7 +438,15 @@ SOURCE=".\N64 System\C Core\Interpreter CPU.cpp"
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE="N64 System\C Core\Interpreter Ops.c" SOURCE=".\N64 System\C Core\Interpreter Ops 32.cpp"
# End Source File
# Begin Source File
SOURCE=".\N64 System\C Core\Interpreter Ops 32.h"
# End Source File
# Begin Source File
SOURCE=".\N64 System\C Core\Interpreter Ops.cpp"
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -430,7 +462,7 @@ SOURCE=".\N64 System\C Core\Pif.cpp"
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE="N64 System\C Core\r4300i Commands.c" SOURCE=".\N64 System\C Core\r4300i Commands.cpp"
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -458,7 +490,7 @@ SOURCE="N64 System\C Core\Registers.cpp"
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE="N64 System\C Core\Sram.c" SOURCE=".\N64 System\C Core\Sram.cpp"
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -470,43 +502,15 @@ SOURCE="N64 System\C Core\TLB Display.c"
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE="N64 System\C Core\Tlb.c"
# End Source File
# Begin Source File
SOURCE="N64 System\C Core\Win32Timer.c" SOURCE="N64 System\C Core\Win32Timer.c"
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE="N64 System\C Core\x86 fpu.c" SOURCE=".\N64 System\C Core\x86 fpu.cpp"
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE="N64 System\C Core\X86.c" SOURCE=".\N64 System\C Core\X86.cpp"
# End Source File
# End Group
# Begin Group "Debugger Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE="N64 System\Debugger\Debugger - Memory Dump.cpp"
# End Source File
# Begin Source File
SOURCE="N64 System\Debugger\Debugger - Memory Search.cpp"
# End Source File
# Begin Source File
SOURCE="N64 System\Debugger\Debugger - TLB.cpp"
# End Source File
# Begin Source File
SOURCE="N64 System\Debugger\Debugger - View Memory.cpp"
# End Source File
# Begin Source File
SOURCE="N64 System\Debugger\Debugger.cpp"
# End Source File # End Source File
# End Group # End Group
# Begin Group "Recompiler Files" # Begin Group "Recompiler Files"
@ -557,6 +561,10 @@ SOURCE="N64 System\Rom Information Class.cpp"
SOURCE="N64 System\Speed Limitor Class.cpp" SOURCE="N64 System\Speed Limitor Class.cpp"
# End Source File # End Source File
# Begin Source File
SOURCE=".\N64 System\System Globals.cpp"
# End Source File
# End Group # End Group
# Begin Group "Plugin Source" # Begin Group "Plugin Source"
@ -1171,6 +1179,10 @@ SOURCE="N64 System\Speed Limitor Class.h"
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=".\N64 System\System Globals.h"
# End Source File
# Begin Source File
SOURCE="N64 System\Types.h" SOURCE="N64 System\Types.h"
# End Source File # End Source File
# End Group # End Group
@ -1268,6 +1280,10 @@ SOURCE=Settings.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\stdafx.h
# End Source File
# Begin Source File
SOURCE="User Interface.h" SOURCE="User Interface.h"
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@ -52,6 +52,7 @@ class CN64System;
#include ".\\User Interface\\Frame Per Second Class.h" #include ".\\User Interface\\Frame Per Second Class.h"
#include ".\\User Interface\\Cheats.h" #include ".\\User Interface\\Cheats.h"
#include ".\\User Interface\\resource.h" #include ".\\User Interface\\resource.h"
#include ".\\User Interface\\Settings Config.h"
#endif #endif

View File

@ -1,16 +1,21 @@
#include "stdafx.h"
/*
#include "..\\User Interface.h" #include "..\\User Interface.h"
#include "..\\N64 System.h" #include "..\\N64 System.h"
#include "..\\Plugin.h" #include "..\\Plugin.h"
#include "..\\Validate Binary.h" #include "..\\Validate Binary.h"
#include "..\\User Interface\\Settings Config.h"
#include <common/CriticalSection.h> #include <common/CriticalSection.h>
#include <vector> #include <vector>
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
*/
// c functions for old debugger // c functions for old debugger
#ifdef toremove
extern CSettings * g_Settings; extern CSettings * g_Settings;
#endif
extern "C" { extern "C" {
void EnterLogOptions(HWND hwndOwner); void EnterLogOptions(HWND hwndOwner);
} }
@ -38,8 +43,9 @@ bool CMainGui::RegisterWinClass ( void ) {
return true; return true;
} }
CMainGui::CMainGui (const char * WindowTitle, CNotification * Notify, CN64System * System) : CMainGui::CMainGui (bool bMainWindow, const char * WindowTitle ) :
CRomBrowser(m_hMainWindow,m_hStatusWnd,Notify,System) CRomBrowser(m_hMainWindow,m_hStatusWnd),
m_bMainWindow(bMainWindow)
{ {
m_hacked = false; m_hacked = false;
if (_Settings) if (_Settings)
@ -50,8 +56,6 @@ CMainGui::CMainGui (const char * WindowTitle, CNotification * Notify, CN64System
m_hacked = true; m_hacked = true;
} }
} }
m_System = System;
m_Notify = Notify;
m_Menu = NULL; m_Menu = NULL;
m_hMainWindow = 0; m_hMainWindow = 0;
@ -66,7 +70,7 @@ CMainGui::CMainGui (const char * WindowTitle, CNotification * Notify, CN64System
m_InvalidExeMsg = RegisterWindowMessage("Invalid"); m_InvalidExeMsg = RegisterWindowMessage("Invalid");
if (m_System) if (m_bMainWindow)
{ {
_Settings->RegisterChangeCB(RomBrowser_Enabled,this,(CSettings::SettingChangedFunc)RomBowserEnabledChanged); _Settings->RegisterChangeCB(RomBrowser_Enabled,this,(CSettings::SettingChangedFunc)RomBowserEnabledChanged);
_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged,this,(CSettings::SettingChangedFunc)RomBowserColoumnsChanged); _Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged,this,(CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
@ -82,7 +86,7 @@ CMainGui::CMainGui (const char * WindowTitle, CNotification * Notify, CN64System
CMainGui::~CMainGui (void) CMainGui::~CMainGui (void)
{ {
WriteTrace(TraceDebug,"CMainGui::~CMainGui - start"); WriteTrace(TraceDebug,"CMainGui::~CMainGui - start");
if (m_System) if (m_bMainWindow)
{ {
_Settings->UnregisterChangeCB(RomBrowser_Enabled,this,(CSettings::SettingChangedFunc)RomBowserEnabledChanged); _Settings->UnregisterChangeCB(RomBrowser_Enabled,this,(CSettings::SettingChangedFunc)RomBowserEnabledChanged);
_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged,this,(CSettings::SettingChangedFunc)RomBowserColoumnsChanged); _Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged,this,(CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
@ -271,9 +275,9 @@ DWORD CALLBACK AboutIniBoxProc (WND_HANDLE WndHandle, DWORD uMsg, DWORD wParam,
return TRUE; return TRUE;
} }
bool CMainGui::InitiatePlugins (CPlugins * _this, CN64System * System) bool CMainGui::InitiatePlugins (void)
{ {
return SendMessage((HWND)m_hMainWindow,WM_INIATE_PLUGIN,(WPARAM)_this,(LPARAM)System) != 0; return SendMessage((HWND)m_hMainWindow,WM_INIATE_PLUGIN,0,0) != 0;
} }
void CMainGui::BringToTop (void) { void CMainGui::BringToTop (void) {
@ -310,7 +314,7 @@ int CMainGui::ProcessAllMessages (void) {
MSG msg; MSG msg;
while (GetMessage(&msg,NULL,0,0)) { while (GetMessage(&msg,NULL,0,0)) {
if (m_System && m_System->IsDialogMsg(&msg)) if (_N64System && _N64System->IsDialogMsg(&msg))
{ {
continue; continue;
} }
@ -363,10 +367,13 @@ void CMainGui::Show (bool Visible) {
void CMainGui::EnterLogOptions (void) void CMainGui::EnterLogOptions (void)
{ {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifndef EXTERNAL_RELEASE #ifndef EXTERNAL_RELEASE
#ifdef tofix
g_Settings = _Settings; g_Settings = _Settings;
::EnterLogOptions((HWND)m_hMainWindow); ::EnterLogOptions((HWND)m_hMainWindow);
#endif #endif
#endif
} }
int CMainGui::Height (void) { int CMainGui::Height (void) {
@ -502,36 +509,38 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
case WM_MOVE: case WM_MOVE:
{ {
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
CN64System * System = _this->m_System;
if (!IsIconic((HWND)hWnd)) { if (_this->m_bMainWindow)
//get the current position of the window {
RECT WinRect; if (!IsIconic((HWND)hWnd)) {
GetWindowRect((HWND)hWnd, &WinRect ); //get the current position of the window
RECT WinRect;
//save the location of the window GetWindowRect((HWND)hWnd, &WinRect );
if (!_this->ShowingRomBrowser()) {
if (_this->RomBrowserVisible()) //save the location of the window
{ if (!_this->ShowingRomBrowser()) {
if (!IsZoomed((HWND)hWnd)) if (_this->RomBrowserVisible())
{ {
_this->m_SaveRomBrowserPos = true; if (!IsZoomed((HWND)hWnd))
_this->m_SaveRomBrowserTop = WinRect.top; {
_this->m_SaveRomBrowserLeft = WinRect.left; _this->m_SaveRomBrowserPos = true;
_this->m_SaveRomBrowserTop = WinRect.top;
_this->m_SaveRomBrowserLeft = WinRect.left;
}
} else {
_this->m_SaveMainWindowPos = true;
_this->m_SaveMainWindowTop = WinRect.top;
_this->m_SaveMainWindowLeft = WinRect.left;
} }
} else {
_this->m_SaveMainWindowPos = true;
_this->m_SaveMainWindowTop = WinRect.top;
_this->m_SaveMainWindowLeft = WinRect.left;
} }
} }
} if (CGuiSettings::bCPURunning() && _N64System) {
if (CGuiSettings::bCPURunning() && System) { CPlugins * Plugins = _N64System->Plugins();
CPlugins * Plugins = System->Plugins(); if (Plugins->Gfx() && Plugins->Gfx()->MoveScreen) {
if (Plugins->Gfx() && Plugins->Gfx()->MoveScreen) { WriteTrace(TraceGfxPlugin,"MoveScreen: Starting");
WriteTrace(TraceGfxPlugin,"MoveScreen: Starting"); Plugins->Gfx()->MoveScreen((int)(short) LOWORD(lParam), (int)(short) HIWORD(lParam));
Plugins->Gfx()->MoveScreen((int)(short) LOWORD(lParam), (int)(short) HIWORD(lParam)); WriteTrace(TraceGfxPlugin,"MoveScreen: Done");
WriteTrace(TraceGfxPlugin,"MoveScreen: Done"); }
} }
} }
} }
@ -601,8 +610,8 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
break; break;
case WM_PAINT: case WM_PAINT:
{ {
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); // CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
CN64System * System = _this->m_System; // CN64System * System = _this->m_System;
// if (bCPURunning() && Settings->Load(CPU_Paused)) { // if (bCPURunning() && Settings->Load(CPU_Paused)) {
// CPlugins * Plugins = System->Plugins(); // CPlugins * Plugins = System->Plugins();
@ -617,11 +626,14 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
{ {
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
if (bCPURunning()) { if (_this->m_bMainWindow && bCPURunning())
CN64System * System = _this->m_System; {
CPlugins * Plugins = System->Plugins(); if (_N64System)
if (Plugins && Plugins->Control()->WM_KeyUp) { {
Plugins->Control()->WM_KeyUp(wParam, lParam); CPlugins * Plugins = _N64System->Plugins();
if (Plugins && Plugins->Control()->WM_KeyUp) {
Plugins->Control()->WM_KeyUp(wParam, lParam);
}
} }
} }
} }
@ -630,11 +642,15 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
{ {
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
if (bCPURunning()) { if (_this->m_bMainWindow && bCPURunning())
CN64System * System = _this->m_System; {
CPlugins * Plugins = System->Plugins(); if (_N64System)
if (Plugins && Plugins->Control()->WM_KeyDown) { {
Plugins->Control()->WM_KeyDown(wParam, lParam); CPlugins * Plugins = _N64System->Plugins();
if (Plugins && Plugins->Control()->WM_KeyDown)
{
Plugins->Control()->WM_KeyDown(wParam, lParam);
}
} }
} }
} }
@ -648,12 +664,12 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
break; break;
} }
if (!bCPURunning()) { break; } if (_this->m_bMainWindow && bCPURunning() && bAutoSleep())
if (!bAutoSleep()) { break; }
CN64System * System = _this->m_System;
if (System)
{ {
System->ExternalEvent( ResumeCPU_AppGainedFocus ); if (_N64System)
{
_N64System->ExternalEvent( ResumeCPU_AppGainedFocus );
}
} }
} }
break; break;
@ -665,12 +681,12 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
break; break;
} }
if (!bCPURunning()) { break; } if (_this->m_bMainWindow && bCPURunning() && bAutoSleep())
if (!bAutoSleep()) { break; } {
CN64System * System = _this->m_System; if (_N64System)
if (System) {
{ _N64System->ExternalEvent( PauseCPU_AppLostFocus );
System->ExternalEvent( PauseCPU_AppLostFocus ); }
} }
} }
break; break;
@ -682,23 +698,26 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
if (fActive && _this->RomBrowserVisible()) { if (fActive && _this->RomBrowserVisible()) {
PostMessage((HWND)hWnd,WM_BORWSER_TOP,0,0); PostMessage((HWND)hWnd,WM_BORWSER_TOP,0,0);
} }
if (!bCPURunning()) { break; } if (_this->m_bMainWindow && bCPURunning())
CN64System * System = _this->m_System;
if (!fActive && _Settings->LoadBool(UserInterface_InFullScreen))
{ {
_this->m_Notify->WindowMode(); if (!fActive && _Settings->LoadBool(UserInterface_InFullScreen))
if (bAutoSleep() && System)
{ {
//System->ExternalEvent(PauseCPU_AppLostActiveDelayed ); _Notify->WindowMode();
if (bAutoSleep() && _N64System)
{
//System->ExternalEvent(PauseCPU_AppLostActiveDelayed );
}
break;
}
if (bAutoSleep())
{
if (_N64System)
{
_N64System->ExternalEvent(fActive ? ResumeCPU_AppGainedActive : PauseCPU_AppLostActive );
}
} }
break;
}
if (!bAutoSleep()) { break; }
if (System)
{
System->ExternalEvent(fActive ? ResumeCPU_AppGainedActive : PauseCPU_AppLostActive );
} }
} }
break; break;
case WM_HIDE_CUROSR: case WM_HIDE_CUROSR:
@ -717,10 +736,7 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
break; break;
case WM_INIATE_PLUGIN: case WM_INIATE_PLUGIN:
{ {
CPlugins * pPlugin = (CPlugins *)wParam; return _Plugins->InitiateMainThread();
CN64System * pSystem = (CN64System *)lParam;
return pPlugin->InitiateMainThread(pSystem);
} }
break; break;
case WM_COMMAND: case WM_COMMAND:
@ -729,19 +745,19 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
if (_this == NULL) { break; } if (_this == NULL) { break; }
switch (LOWORD(wParam)) { switch (LOWORD(wParam)) {
case ID_POPUPMENU_PLAYGAME: _this->m_System->RunFileImage(_this->CurrentedSelectedRom()); break; case ID_POPUPMENU_PLAYGAME: _N64System->RunFileImage(_this->CurrentedSelectedRom()); break;
case ID_POPUPMENU_ROMDIRECTORY: _this->SelectRomDir(_this->GetNotifyClass()); break; case ID_POPUPMENU_ROMDIRECTORY: _this->SelectRomDir(); break;
case ID_POPUPMENU_REFRESHROMLIST: _this->RefreshRomBrowser(); break; case ID_POPUPMENU_REFRESHROMLIST: _this->RefreshRomBrowser(); break;
case ID_POPUPMENU_ROMINFORMATION: case ID_POPUPMENU_ROMINFORMATION:
{ {
RomInformation Info(_this->CurrentedSelectedRom(),_this->m_Notify); RomInformation Info(_this->CurrentedSelectedRom());
Info.DisplayInformation(hWnd); Info.DisplayInformation(hWnd);
} }
break; break;
case ID_POPUPMENU_EDITSETTINGS: case ID_POPUPMENU_EDITSETTINGS:
case ID_POPUPMENU_EDITCHEATS: case ID_POPUPMENU_EDITCHEATS:
{ {
CN64Rom Rom(_this->m_Notify); CN64Rom Rom;
Rom.LoadN64Image(_this->CurrentedSelectedRom(),true); Rom.LoadN64Image(_this->CurrentedSelectedRom(),true);
Rom.SaveRomSettingID(); Rom.SaveRomSettingID();
/*if (_Settings->LoadString(ROM_MD5).length() == 0) { /*if (_Settings->LoadString(ROM_MD5).length() == 0) {
@ -757,13 +773,12 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
} }
if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) { if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) {
CCheats RomCheats(&Rom,_this->m_Notify); CCheats RomCheats(&Rom);
RomCheats.SelectCheats(hWnd,true); RomCheats.SelectCheats(hWnd,true);
} }
CN64Rom * CurrentRom = _this->m_System->GetCurrentRom(); if (_Rom) {
if (CurrentRom) { _Rom->SaveRomSettingID();
CurrentRom->SaveRomSettingID();
} else { } else {
Rom.ClearRomSettingID(); Rom.ClearRomSettingID();
} }
@ -772,38 +787,34 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
default: default:
if (_this->m_Menu) { if (_this->m_Menu) {
if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100 ) { if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100 ) {
CN64System * System = _this->m_System; CPlugins * Plugins = _N64System->Plugins();
CPlugins * Plugins = System->Plugins();
if (Plugins->RSP() && Plugins->RSP()->ProcessMenuItem != NULL) { if (Plugins->RSP() && Plugins->RSP()->ProcessMenuItem != NULL) {
Plugins->RSP()->ProcessMenuItem(LOWORD(wParam)); Plugins->RSP()->ProcessMenuItem(LOWORD(wParam));
} }
} else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200 ) { } else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200 ) {
CN64System * System = _this->m_System; CPlugins * Plugins = _N64System->Plugins();
CPlugins * Plugins = System->Plugins();
if (Plugins->Gfx() && Plugins->Gfx()->ProcessMenuItem != NULL) { if (Plugins->Gfx() && Plugins->Gfx()->ProcessMenuItem != NULL) {
WriteTrace(TraceGfxPlugin,"ProcessMenuItem: Starting"); WriteTrace(TraceGfxPlugin,"ProcessMenuItem: Starting");
Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam)); Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam));
WriteTrace(TraceGfxPlugin,"ProcessMenuItem: Done"); WriteTrace(TraceGfxPlugin,"ProcessMenuItem: Done");
} }
} else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300 ) { } else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300 ) {
CN64System * System = _this->m_System; CPlugins * Plugins = _N64System->Plugins();
CPlugins * Plugins = System->Plugins();
if (Plugins->Gfx() && Plugins->Gfx()->OnRomBrowserMenuItem != NULL) if (Plugins->Gfx() && Plugins->Gfx()->OnRomBrowserMenuItem != NULL)
{ {
CN64Rom Rom(_this->m_Notify); CN64Rom Rom;
if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(),true)) if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(),true))
{ {
break; break;
} }
Rom.SaveRomSettingID(); Rom.SaveRomSettingID();
_this->m_Notify->DisplayMessage(0,""); _Notify->DisplayMessage(0,"");
BYTE * RomHeader = Rom.GetRomAddress(); BYTE * RomHeader = Rom.GetRomAddress();
WriteTrace(TraceGfxPlugin,"OnRomBrowserMenuItem: Starting"); WriteTrace(TraceGfxPlugin,"OnRomBrowserMenuItem: Starting");
Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam),hWnd,RomHeader); Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam),hWnd,RomHeader);
WriteTrace(TraceGfxPlugin,"OnRomBrowserMenuItem: Done"); WriteTrace(TraceGfxPlugin,"OnRomBrowserMenuItem: Done");
CN64Rom * CurrentRom = _this->m_System->GetCurrentRom(); if (_Rom) {
if (CurrentRom) { _Rom->SaveRomSettingID();
CurrentRom->SaveRomSettingID();
} else { } else {
_Settings->SaveString(Game_IniKey,""); _Settings->SaveString(Game_IniKey,"");
} }
@ -819,14 +830,13 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
WriteTrace(TraceDebug,"WM_DESTROY - start"); WriteTrace(TraceDebug,"WM_DESTROY - start");
{ {
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
if (_this->m_Notify) if (_this->m_bMainWindow)
{ {
_this->m_Notify->WindowMode(); _Notify->WindowMode();
} }
CN64System * System = _this->m_System;
_this->m_hMainWindow = NULL; _this->m_hMainWindow = NULL;
WriteTrace(TraceDebug,"WM_DESTROY - 1"); WriteTrace(TraceDebug,"WM_DESTROY - 1");
if (System) if (_this->m_bMainWindow)
{ {
_this->SaveRomListColoumnInfo(); _this->SaveRomListColoumnInfo();
WriteTrace(TraceDebug,"WM_DESTROY - 2"); WriteTrace(TraceDebug,"WM_DESTROY - 2");
@ -846,7 +856,7 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
{ {
if (uMsg == _this->m_InvalidExeMsg) if (uMsg == _this->m_InvalidExeMsg)
{ {
_this->m_System->CloseCpu(); _N64System->CloseCpu();
MessageBox((HWND)hWnd,GS(MSG_INVALID_EXE),GS(MSG_INVALID_EXE_TITLE),MB_OK|MB_ICONERROR); MessageBox((HWND)hWnd,GS(MSG_INVALID_EXE),GS(MSG_INVALID_EXE_TITLE),MB_OK|MB_ICONERROR);
PostQuitMessage(0); PostQuitMessage(0);
} }

View File

@ -14,9 +14,7 @@ class CMainGui :
friend CAudioPlugin; friend CAudioPlugin;
friend CControl_Plugin; friend CControl_Plugin;
CN64System * m_System;
CBaseMenu * m_Menu; CBaseMenu * m_Menu;
CNotification * m_Notify;
enum { StatusBarID = 400 }; enum { StatusBarID = 400 };
@ -29,6 +27,7 @@ class CMainGui :
WND_HANDLE m_hMainWindow, m_hStatusWnd; WND_HANDLE m_hMainWindow, m_hStatusWnd;
bool m_hacked; bool m_hacked;
const bool m_bMainWindow;
int m_InvalidExeMsg; int m_InvalidExeMsg;
CriticalSection m_CS; CriticalSection m_CS;
@ -55,7 +54,7 @@ class CMainGui :
friend void RomBrowserRecursiveChanged (CMainGui * Gui); friend void RomBrowserRecursiveChanged (CMainGui * Gui);
public: public:
CMainGui ( const char * WindowTitle = "", CNotification * Notify = 0, CN64System * System = 0 ); CMainGui ( bool bMainWindow, const char * WindowTitle = "" );
~CMainGui ( void ); ~CMainGui ( void );
//Message Processing //Message Processing
@ -91,10 +90,7 @@ public:
void AboutBox ( void ); void AboutBox ( void );
//Plugins //Plugins
bool InitiatePlugins ( CPlugins * _this, CN64System * System ); bool InitiatePlugins ( void );
//Get Notification class
CNotification * GetNotifyClass (void) { return m_Notify; }
//Get Window Handle //Get Window Handle
inline WND_HANDLE GetHandle ( void ) const { return m_hMainWindow; } inline WND_HANDLE GetHandle ( void ) const { return m_hMainWindow; }

View File

@ -6,12 +6,11 @@
#include "..\\3rd Party\\HTML Help\\HTMLHELP.H" #include "..\\3rd Party\\HTML Help\\HTMLHELP.H"
#include <common/CriticalSection.h> #include <common/CriticalSection.h>
CMainMenu::CMainMenu ( CMainGui * hMainWindow, CN64System * N64System ): CMainMenu::CMainMenu ( CMainGui * hMainWindow ):
CBaseMenu(), CBaseMenu(),
m_ResetAccelerators(true) m_ResetAccelerators(true)
{ {
_Gui = hMainWindow; //Make a copy of the attatched window _Gui = hMainWindow; //Make a copy of the attatched window
_System = N64System; //Make a copy of the n64 system that is being interacted with
ResetMenu(); ResetMenu();
hMainWindow->SetWindowMenu(this); hMainWindow->SetWindowMenu(this);
@ -69,29 +68,29 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
switch (MenuID) { switch (MenuID) {
case ID_FILE_OPEN_ROM: case ID_FILE_OPEN_ROM:
{ {
stdstr File = _System->ChooseFileToOpen(hWnd); stdstr File = _N64System->ChooseFileToOpen(hWnd);
if (File.length() > 0) { if (File.length() > 0) {
_System->RunFileImage(File.c_str()); _N64System->RunFileImage(File.c_str());
} }
} }
break; break;
case ID_FILE_ROM_INFO: case ID_FILE_ROM_INFO:
{ {
_System->DisplayRomInfo(hWnd); _N64System->DisplayRomInfo(hWnd);
} }
break; break;
case ID_FILE_STARTEMULATION: case ID_FILE_STARTEMULATION:
_Gui->SaveWindowLoc(); _Gui->SaveWindowLoc();
_System->StartEmulation(true); _N64System->StartEmulation(true);
break; break;
case ID_FILE_ENDEMULATION: case ID_FILE_ENDEMULATION:
WriteTrace(TraceDebug,"ID_FILE_ENDEMULATION"); WriteTrace(TraceDebug,"ID_FILE_ENDEMULATION");
_System->CloseCpu(); _N64System->CloseCpu();
_Gui->SaveWindowLoc(); _Gui->SaveWindowLoc();
break; break;
case ID_FILE_ROMDIRECTORY: case ID_FILE_ROMDIRECTORY:
WriteTrace(TraceDebug,"ID_FILE_ROMDIRECTORY 1"); WriteTrace(TraceDebug,"ID_FILE_ROMDIRECTORY 1");
_Gui->SelectRomDir(_Gui->GetNotifyClass()); _Gui->SelectRomDir();
WriteTrace(TraceDebug,"ID_FILE_ROMDIRECTORY 2"); WriteTrace(TraceDebug,"ID_FILE_ROMDIRECTORY 2");
_Gui->RefreshMenu(); _Gui->RefreshMenu();
WriteTrace(TraceDebug,"ID_FILE_ROMDIRECTORY 3"); WriteTrace(TraceDebug,"ID_FILE_ROMDIRECTORY 3");
@ -100,20 +99,20 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
case ID_FILE_EXIT: DestroyWindow((HWND)hWnd); break; case ID_FILE_EXIT: DestroyWindow((HWND)hWnd); break;
case ID_SYSTEM_RESET_SOFT: case ID_SYSTEM_RESET_SOFT:
WriteTrace(TraceDebug,"ID_SYSTEM_RESET_SOFT"); WriteTrace(TraceDebug,"ID_SYSTEM_RESET_SOFT");
_System->ExternalEvent(ResetCPU_Soft); _N64System->ExternalEvent(ResetCPU_Soft);
break; break;
case ID_SYSTEM_RESET_HARD: case ID_SYSTEM_RESET_HARD:
WriteTrace(TraceDebug,"ID_SYSTEM_RESET_HARD"); WriteTrace(TraceDebug,"ID_SYSTEM_RESET_HARD");
_System->ExternalEvent(ResetCPU_Hard); _N64System->ExternalEvent(ResetCPU_Hard);
break; break;
case ID_SYSTEM_PAUSE: case ID_SYSTEM_PAUSE:
_Gui->SaveWindowLoc(); _Gui->SaveWindowLoc();
WriteTrace(TraceDebug,"ID_SYSTEM_PAUSE"); WriteTrace(TraceDebug,"ID_SYSTEM_PAUSE");
if (_Settings->LoadBool(GameRunning_CPU_Paused)) if (_Settings->LoadBool(GameRunning_CPU_Paused))
{ {
_System->ExternalEvent(ResumeCPU_FromMenu); _N64System->ExternalEvent(ResumeCPU_FromMenu);
} else { } else {
_System->ExternalEvent(PauseCPU_FromMenu); _N64System->ExternalEvent(PauseCPU_FromMenu);
} }
WriteTrace(TraceDebug,"ID_SYSTEM_PAUSE 1"); WriteTrace(TraceDebug,"ID_SYSTEM_PAUSE 1");
break; break;
@ -121,7 +120,7 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
{ {
stdstr Dir(_Settings->LoadString(Directory_SnapShot)); stdstr Dir(_Settings->LoadString(Directory_SnapShot));
WriteTraceF(TraceGfxPlugin,"CaptureScreen(%s): Starting",Dir.c_str()); WriteTraceF(TraceGfxPlugin,"CaptureScreen(%s): Starting",Dir.c_str());
_System->Plugins()->Gfx()->CaptureScreen(Dir.c_str()); _Plugins->Gfx()->CaptureScreen(Dir.c_str());
WriteTrace(TraceGfxPlugin,"CaptureScreen: Done"); WriteTrace(TraceGfxPlugin,"CaptureScreen: Done");
} }
break; break;
@ -130,7 +129,7 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
_Settings->SaveBool(GameRunning_LimitFPS,!_Settings->LoadBool(GameRunning_LimitFPS)); _Settings->SaveBool(GameRunning_LimitFPS,!_Settings->LoadBool(GameRunning_LimitFPS));
WriteTrace(TraceDebug,"ID_SYSTEM_LIMITFPS 1"); WriteTrace(TraceDebug,"ID_SYSTEM_LIMITFPS 1");
break; break;
case ID_SYSTEM_SAVE: WriteTrace(TraceDebug,"ID_SYSTEM_SAVE"); _System->ExternalEvent(SaveMachineState); break; case ID_SYSTEM_SAVE: WriteTrace(TraceDebug,"ID_SYSTEM_SAVE"); _N64System->ExternalEvent(SaveMachineState); break;
case ID_SYSTEM_SAVEAS: case ID_SYSTEM_SAVEAS:
{ {
char drive[_MAX_DRIVE] ,dir[_MAX_DIR], fname[_MAX_FNAME],ext[_MAX_EXT]; char drive[_MAX_DRIVE] ,dir[_MAX_DIR], fname[_MAX_FNAME],ext[_MAX_EXT];
@ -150,7 +149,7 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
openfilename.nMaxFile = MAX_PATH; openfilename.nMaxFile = MAX_PATH;
openfilename.Flags = OFN_HIDEREADONLY; openfilename.Flags = OFN_HIDEREADONLY;
_System->ExternalEvent(PauseCPU_SaveGame); _N64System->ExternalEvent(PauseCPU_SaveGame);
if (GetSaveFileName (&openfilename)) if (GetSaveFileName (&openfilename))
{ {
@ -170,13 +169,13 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
_makepath( SaveDir, drive, dir, NULL, NULL ); _makepath( SaveDir, drive, dir, NULL, NULL );
_Settings->SaveString(Directory_LastSave,SaveDir); _Settings->SaveString(Directory_LastSave,SaveDir);
_System->ExternalEvent(SaveMachineState); _N64System->ExternalEvent(SaveMachineState);
} }
_System->ExternalEvent(ResumeCPU_SaveGame); _N64System->ExternalEvent(ResumeCPU_SaveGame);
} }
break; break;
case ID_SYSTEM_RESTORE: WriteTrace(TraceDebug,"ID_SYSTEM_RESTORE"); _System->ExternalEvent(LoadMachineState); break; case ID_SYSTEM_RESTORE: WriteTrace(TraceDebug,"ID_SYSTEM_RESTORE"); _N64System->ExternalEvent(LoadMachineState); break;
case ID_SYSTEM_LOAD: case ID_SYSTEM_LOAD:
{ {
char Directory[255], SaveFile[255]; char Directory[255], SaveFile[255];
@ -195,7 +194,7 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
openfilename.nMaxFile = MAX_PATH; openfilename.nMaxFile = MAX_PATH;
openfilename.Flags = OFN_HIDEREADONLY; openfilename.Flags = OFN_HIDEREADONLY;
_System->ExternalEvent(PauseCPU_LoadGame); _N64System->ExternalEvent(PauseCPU_LoadGame);
if (GetOpenFileName (&openfilename)) { if (GetOpenFileName (&openfilename)) {
_Settings->SaveString(GameRunning_InstantSaveFile,SaveFile); _Settings->SaveString(GameRunning_InstantSaveFile,SaveFile);
@ -205,18 +204,18 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
_makepath( SaveDir, drive, dir, NULL, NULL ); _makepath( SaveDir, drive, dir, NULL, NULL );
_Settings->SaveString(Directory_LastSave,SaveDir); _Settings->SaveString(Directory_LastSave,SaveDir);
_System->ExternalEvent(LoadMachineState); _N64System->ExternalEvent(LoadMachineState);
} }
_System->ExternalEvent(ResumeCPU_LoadGame); _N64System->ExternalEvent(ResumeCPU_LoadGame);
} }
break; break;
case ID_SYSTEM_CHEAT: case ID_SYSTEM_CHEAT:
{ {
_System->SelectCheats(hWnd); _N64System->SelectCheats(hWnd);
} }
break; break;
case ID_SYSTEM_GSBUTTON: case ID_SYSTEM_GSBUTTON:
_System->ExternalEvent(GSButtonPressed); _N64System->ExternalEvent(GSButtonPressed);
break; break;
case ID_OPTIONS_DISPLAY_FR: case ID_OPTIONS_DISPLAY_FR:
_Settings->SaveBool(UserInterface_DisplayFrameRate,!_Settings->LoadBool(UserInterface_DisplayFrameRate)); _Settings->SaveBool(UserInterface_DisplayFrameRate,!_Settings->LoadBool(UserInterface_DisplayFrameRate));
@ -235,13 +234,13 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
} }
break; break;
case ID_OPTIONS_INCREASE_SPEED: case ID_OPTIONS_INCREASE_SPEED:
_System->IncreaseSpeed(); _N64System->IncreaseSpeed();
break; break;
case ID_OPTIONS_DECREASE_SPEED: case ID_OPTIONS_DECREASE_SPEED:
_System->DecreaeSpeed(); _N64System->DecreaeSpeed();
break; break;
case ID_OPTIONS_FULLSCREEN: case ID_OPTIONS_FULLSCREEN:
_System->ExternalEvent(ChangingFullScreen); _N64System->ExternalEvent(ChangingFullScreen);
break; break;
case ID_OPTIONS_FULLSCREEN2: case ID_OPTIONS_FULLSCREEN2:
if (_Settings->LoadBool(UserInterface_InFullScreen)) if (_Settings->LoadBool(UserInterface_InFullScreen))
@ -250,7 +249,7 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
_Gui->MakeWindowOnTop(false); _Gui->MakeWindowOnTop(false);
Notify().SetGfxPlugin(NULL); Notify().SetGfxPlugin(NULL);
WriteTrace(TraceGfxPlugin,"ChangeWindow: Starting"); WriteTrace(TraceGfxPlugin,"ChangeWindow: Starting");
_System->Plugins()->Gfx()->ChangeWindow(); _Plugins->Gfx()->ChangeWindow();
WriteTrace(TraceGfxPlugin,"ChangeWindow: Done"); WriteTrace(TraceGfxPlugin,"ChangeWindow: Done");
ShowCursor(true); ShowCursor(true);
_Gui->ShowStatusBar(true); _Gui->ShowStatusBar(true);
@ -264,7 +263,7 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
WriteTrace(TraceDebug,"ID_OPTIONS_FULLSCREEN b 2"); WriteTrace(TraceDebug,"ID_OPTIONS_FULLSCREEN b 2");
try { try {
WriteTrace(TraceGfxPlugin,"ChangeWindow: Starting"); WriteTrace(TraceGfxPlugin,"ChangeWindow: Starting");
_System->Plugins()->Gfx()->ChangeWindow(); _Plugins->Gfx()->ChangeWindow();
WriteTrace(TraceGfxPlugin,"ChangeWindow: Done"); WriteTrace(TraceGfxPlugin,"ChangeWindow: Done");
} }
catch (...) catch (...)
@ -277,7 +276,7 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
WriteTrace(TraceDebug,"ID_OPTIONS_FULLSCREEN b 4"); WriteTrace(TraceDebug,"ID_OPTIONS_FULLSCREEN b 4");
_Gui->MakeWindowOnTop(false); _Gui->MakeWindowOnTop(false);
WriteTrace(TraceDebug,"ID_OPTIONS_FULLSCREEN b 5"); WriteTrace(TraceDebug,"ID_OPTIONS_FULLSCREEN b 5");
Notify().SetGfxPlugin(_System->Plugins()->Gfx()); Notify().SetGfxPlugin(_Plugins->Gfx());
WriteTrace(TraceDebug,"ID_OPTIONS_FULLSCREEN b 3"); WriteTrace(TraceDebug,"ID_OPTIONS_FULLSCREEN b 3");
_Settings->SaveBool(UserInterface_InFullScreen,true); _Settings->SaveBool(UserInterface_InFullScreen,true);
WriteTrace(TraceDebug,"ID_OPTIONS_FULLSCREEN b 6"); WriteTrace(TraceDebug,"ID_OPTIONS_FULLSCREEN b 6");
@ -293,20 +292,20 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
_Gui->MakeWindowOnTop(_Settings->LoadBool(GameRunning_CPU_Running)); _Gui->MakeWindowOnTop(_Settings->LoadBool(GameRunning_CPU_Running));
} }
break; break;
case ID_OPTIONS_CONFIG_RSP: WriteTrace(TraceDebug,"ID_OPTIONS_CONFIG_RSP"); _System->Plugins()->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_RSP); break; case ID_OPTIONS_CONFIG_RSP: WriteTrace(TraceDebug,"ID_OPTIONS_CONFIG_RSP"); _Plugins->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_RSP); break;
case ID_OPTIONS_CONFIG_GFX: WriteTrace(TraceDebug,"ID_OPTIONS_CONFIG_GFX"); _System->Plugins()->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_GFX); break; case ID_OPTIONS_CONFIG_GFX: WriteTrace(TraceDebug,"ID_OPTIONS_CONFIG_GFX"); _Plugins->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_GFX); break;
case ID_OPTIONS_CONFIG_AUDIO:WriteTrace(TraceDebug,"ID_OPTIONS_CONFIG_AUDIO"); _System->Plugins()->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_AUDIO); break; case ID_OPTIONS_CONFIG_AUDIO:WriteTrace(TraceDebug,"ID_OPTIONS_CONFIG_AUDIO"); _Plugins->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_AUDIO); break;
case ID_OPTIONS_CONFIG_CONT: WriteTrace(TraceDebug,"ID_OPTIONS_CONFIG_CONT"); _System->Plugins()->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_CONTROLLER); break; case ID_OPTIONS_CONFIG_CONT: WriteTrace(TraceDebug,"ID_OPTIONS_CONFIG_CONT"); _Plugins->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_CONTROLLER); break;
case ID_OPTIONS_CPU_USAGE: case ID_OPTIONS_CPU_USAGE:
WriteTrace(TraceDebug,"ID_OPTIONS_CPU_USAGE"); WriteTrace(TraceDebug,"ID_OPTIONS_CPU_USAGE");
if (_Settings->LoadBool(UserInterface_ShowCPUPer)) if (_Settings->LoadBool(UserInterface_ShowCPUPer))
{ {
_Settings->SaveBool(UserInterface_ShowCPUPer,false); _Settings->SaveBool(UserInterface_ShowCPUPer,false);
_Gui->GetNotifyClass()->DisplayMessage(0,""); _Notify->DisplayMessage(0,"");
} else { } else {
_Settings->SaveBool(UserInterface_ShowCPUPer,true); _Settings->SaveBool(UserInterface_ShowCPUPer,true);
} }
_System->ExternalEvent(CPUUsageTimerChanged); _N64System->ExternalEvent(CPUUsageTimerChanged);
break; break;
case ID_OPTIONS_SETTINGS: case ID_OPTIONS_SETTINGS:
{ {
@ -316,10 +315,10 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
break; break;
case ID_PROFILE_PROFILE: case ID_PROFILE_PROFILE:
_Settings->SaveBool(Debugger_ProfileCode,!_Settings->LoadBool(Debugger_ProfileCode)); _Settings->SaveBool(Debugger_ProfileCode,!_Settings->LoadBool(Debugger_ProfileCode));
_System->ExternalEvent(Profile_StartStop); _N64System->ExternalEvent(Profile_StartStop);
break; break;
case ID_PROFILE_RESETCOUNTER: _System->ExternalEvent(Profile_ResetLogs); break; case ID_PROFILE_RESETCOUNTER: _N64System->ExternalEvent(Profile_ResetLogs); break;
case ID_PROFILE_GENERATELOG: _System->ExternalEvent(Profile_GenerateLogs); break; case ID_PROFILE_GENERATELOG: _N64System->ExternalEvent(Profile_GenerateLogs); break;
case ID_DEBUG_SHOW_UNHANDLED_MEM: case ID_DEBUG_SHOW_UNHANDLED_MEM:
_Settings->SaveBool(Debugger_ShowUnhandledMemory,!_Settings->LoadBool(Debugger_ShowUnhandledMemory)); _Settings->SaveBool(Debugger_ShowUnhandledMemory,!_Settings->LoadBool(Debugger_ShowUnhandledMemory));
break; break;
@ -327,11 +326,11 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
_Settings->SaveBool(Debugger_ShowPifErrors,!_Settings->LoadBool(Debugger_ShowPifErrors)); _Settings->SaveBool(Debugger_ShowPifErrors,!_Settings->LoadBool(Debugger_ShowPifErrors));
break; break;
case ID_DEBUG_SHOW_DLIST_COUNT: case ID_DEBUG_SHOW_DLIST_COUNT:
_Gui->GetNotifyClass()->DisplayMessage(0,""); _Notify->DisplayMessage(0,"");
_Settings->SaveBool(Debugger_ShowDListAListCount,!_Settings->LoadBool(Debugger_ShowDListAListCount)); _Settings->SaveBool(Debugger_ShowDListAListCount,!_Settings->LoadBool(Debugger_ShowDListAListCount));
break; break;
case ID_DEBUG_SHOW_RECOMP_MEM_SIZE: case ID_DEBUG_SHOW_RECOMP_MEM_SIZE:
_Gui->GetNotifyClass()->DisplayMessage(0,""); _Notify->DisplayMessage(0,"");
_Settings->SaveBool(Debugger_ShowRecompMemSize,!_Settings->LoadBool(Debugger_ShowRecompMemSize)); _Settings->SaveBool(Debugger_ShowRecompMemSize,!_Settings->LoadBool(Debugger_ShowRecompMemSize));
break; break;
case ID_DEBUG_SHOW_CHECK_OPUSAGE: case ID_DEBUG_SHOW_CHECK_OPUSAGE:
@ -441,17 +440,17 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
_Settings->SaveBool(Debugger_GenerateDebugLog,!_Settings->LoadBool(Debugger_GenerateDebugLog)); _Settings->SaveBool(Debugger_GenerateDebugLog,!_Settings->LoadBool(Debugger_GenerateDebugLog));
break; break;
case ID_DEBUGGER_DUMPMEMORY: case ID_DEBUGGER_DUMPMEMORY:
_System->Debug_ShowMemoryDump(); _N64System->Debug_ShowMemoryDump();
break; break;
case ID_DEBUGGER_SEARCHMEMORY: _System->Debug_ShowMemorySearch(); break; case ID_DEBUGGER_SEARCHMEMORY: _N64System->Debug_ShowMemorySearch(); break;
case ID_DEBUGGER_MEMORY: _System->Debug_ShowMemoryWindow(); break; case ID_DEBUGGER_MEMORY: _N64System->Debug_ShowMemoryWindow(); break;
case ID_DEBUGGER_TLBENTRIES: _System->Debug_ShowTLBWindow(); break; case ID_DEBUGGER_TLBENTRIES: _N64System->Debug_ShowTLBWindow(); break;
case ID_DEBUGGER_INTERRUPT_SP: _System->ExternalEvent(Interrupt_SP); break; case ID_DEBUGGER_INTERRUPT_SP: _N64System->ExternalEvent(Interrupt_SP); break;
case ID_DEBUGGER_INTERRUPT_SI: _System->ExternalEvent(Interrupt_SI); break; case ID_DEBUGGER_INTERRUPT_SI: _N64System->ExternalEvent(Interrupt_SI); break;
case ID_DEBUGGER_INTERRUPT_AI: _System->ExternalEvent(Interrupt_AI); break; case ID_DEBUGGER_INTERRUPT_AI: _N64System->ExternalEvent(Interrupt_AI); break;
case ID_DEBUGGER_INTERRUPT_VI: _System->ExternalEvent(Interrupt_VI); break; case ID_DEBUGGER_INTERRUPT_VI: _N64System->ExternalEvent(Interrupt_VI); break;
case ID_DEBUGGER_INTERRUPT_PI: _System->ExternalEvent(Interrupt_PI); break; case ID_DEBUGGER_INTERRUPT_PI: _N64System->ExternalEvent(Interrupt_PI); break;
case ID_DEBUGGER_INTERRUPT_DP: _System->ExternalEvent(Interrupt_DP); break; case ID_DEBUGGER_INTERRUPT_DP: _N64System->ExternalEvent(Interrupt_DP); break;
case ID_CURRENT_SAVE_DEFAULT: case ID_CURRENT_SAVE_DEFAULT:
Notify().DisplayMessage(3,"Save Slot (%s) selected",GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str()); Notify().DisplayMessage(3,"Save Slot (%s) selected",GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str());
_Settings->SaveDword(Game_CurrentSaveState,(DWORD)(MenuID - ID_CURRENT_SAVE_DEFAULT)); _Settings->SaveDword(Game_CurrentSaveState,(DWORD)(MenuID - ID_CURRENT_SAVE_DEFAULT));
@ -509,7 +508,7 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
if (_Settings->LoadStringIndex(File_RecentGameFileIndex,MenuID - ID_RECENT_ROM_START,FileName) && if (_Settings->LoadStringIndex(File_RecentGameFileIndex,MenuID - ID_RECENT_ROM_START,FileName) &&
FileName.length() > 0) FileName.length() > 0)
{ {
_System->RunFileImage(FileName.c_str()); _N64System->RunFileImage(FileName.c_str());
} }
} }
if (MenuID >= ID_RECENT_DIR_START && MenuID < ID_RECENT_DIR_END) { if (MenuID >= ID_RECENT_DIR_START && MenuID < ID_RECENT_DIR_END) {
@ -517,7 +516,7 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
stdstr Dir = _Settings->LoadStringIndex(Directory_RecentGameDirIndex,Offset); stdstr Dir = _Settings->LoadStringIndex(Directory_RecentGameDirIndex,Offset);
if (Dir.length() > 0) { if (Dir.length() > 0) {
_Settings->SaveString(Directory_Game,Dir.c_str()); _Settings->SaveString(Directory_Game,Dir.c_str());
_Gui->GetNotifyClass()->AddRecentDir(Dir.c_str()); _Notify->AddRecentDir(Dir.c_str());
_Gui->RefreshMenu(); _Gui->RefreshMenu();
if (_Gui->RomBrowserVisible()) { if (_Gui->RomBrowserVisible()) {
_Gui->RefreshRomBrowser(); _Gui->RefreshRomBrowser();
@ -860,7 +859,7 @@ void CMainMenu::FillOutMenu ( MENU_HANDLE hMenu ) {
MenuItemList OptionMenu; MenuItemList OptionMenu;
Item.Reset(ID_OPTIONS_FULLSCREEN, MENU_FULL_SCREEN,m_ShortCuts.ShortCutString(ID_OPTIONS_FULLSCREEN,AccessLevel) ); Item.Reset(ID_OPTIONS_FULLSCREEN, MENU_FULL_SCREEN,m_ShortCuts.ShortCutString(ID_OPTIONS_FULLSCREEN,AccessLevel) );
Item.ItemEnabled = CPURunning; Item.ItemEnabled = CPURunning;
if (_System->Plugins()->Gfx() && _System->Plugins()->Gfx()->ChangeWindow == NULL) { if (_Plugins->Gfx() && _Plugins->Gfx()->ChangeWindow == NULL) {
Item.ItemEnabled = false; Item.ItemEnabled = false;
} }
OptionMenu.push_back(Item); OptionMenu.push_back(Item);
@ -873,24 +872,24 @@ void CMainMenu::FillOutMenu ( MENU_HANDLE hMenu ) {
OptionMenu.push_back(MENU_ITEM(SPLITER )); OptionMenu.push_back(MENU_ITEM(SPLITER ));
Item.Reset(ID_OPTIONS_CONFIG_GFX, MENU_CONFG_GFX,m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_GFX,AccessLevel)); Item.Reset(ID_OPTIONS_CONFIG_GFX, MENU_CONFG_GFX,m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_GFX,AccessLevel));
if (_System->Plugins()->Gfx() == NULL || _System->Plugins()->Gfx()->Config == NULL) { if (_Plugins->Gfx() == NULL || _Plugins->Gfx()->Config == NULL) {
Item.ItemEnabled = false; Item.ItemEnabled = false;
} }
OptionMenu.push_back(Item); OptionMenu.push_back(Item);
Item.Reset(ID_OPTIONS_CONFIG_AUDIO, MENU_CONFG_AUDIO,m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_AUDIO,AccessLevel)); Item.Reset(ID_OPTIONS_CONFIG_AUDIO, MENU_CONFG_AUDIO,m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_AUDIO,AccessLevel));
if (_System->Plugins()->Audio() == NULL || _System->Plugins()->Audio()->Config == NULL) { if (_Plugins->Audio() == NULL || _Plugins->Audio()->Config == NULL) {
Item.ItemEnabled = false; Item.ItemEnabled = false;
} }
OptionMenu.push_back(Item); OptionMenu.push_back(Item);
if (!inBasicMode) { if (!inBasicMode) {
Item.Reset(ID_OPTIONS_CONFIG_RSP, MENU_CONFG_RSP,m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_RSP,AccessLevel)); Item.Reset(ID_OPTIONS_CONFIG_RSP, MENU_CONFG_RSP,m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_RSP,AccessLevel));
if (_System->Plugins()->RSP() == NULL || _System->Plugins()->RSP()->Config == NULL) { if (_Plugins->RSP() == NULL || _Plugins->RSP()->Config == NULL) {
Item.ItemEnabled = false; Item.ItemEnabled = false;
} }
OptionMenu.push_back(Item); OptionMenu.push_back(Item);
} }
Item.Reset(ID_OPTIONS_CONFIG_CONT, MENU_CONFG_CTRL,m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_CONT,AccessLevel)); Item.Reset(ID_OPTIONS_CONFIG_CONT, MENU_CONFG_CTRL,m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_CONT,AccessLevel));
if (_System->Plugins()->Control() == NULL || _System->Plugins()->Control()->Config == NULL) { if (_Plugins->Control() == NULL || _Plugins->Control()->Config == NULL) {
Item.ItemEnabled = false; Item.ItemEnabled = false;
} }
OptionMenu.push_back(Item); OptionMenu.push_back(Item);
@ -1036,17 +1035,17 @@ void CMainMenu::FillOutMenu ( MENU_HANDLE hMenu ) {
/* Debug - RSP /* Debug - RSP
*******************/ *******************/
if (_System->Plugins()->RSP() != NULL && IsMenu((HMENU)_System->Plugins()->RSP()->GetDebugMenu())) if (_Plugins->RSP() != NULL && IsMenu((HMENU)_Plugins->RSP()->GetDebugMenu()))
{ {
Item.Reset(ID_PLUGIN_MENU,EMPTY_STRING,NULL,_System->Plugins()->RSP()->GetDebugMenu(),"&RSP" ); Item.Reset(ID_PLUGIN_MENU,EMPTY_STRING,NULL,_Plugins->RSP()->GetDebugMenu(),"&RSP" );
DebugMenu.push_back(Item); DebugMenu.push_back(Item);
} }
/* Debug - RDP /* Debug - RDP
*******************/ *******************/
if (_System->Plugins()->Gfx() != NULL && IsMenu((HMENU)_System->Plugins()->Gfx()->GetDebugMenu())) if (_Plugins->Gfx() != NULL && IsMenu((HMENU)_Plugins->Gfx()->GetDebugMenu()))
{ {
Item.Reset(ID_PLUGIN_MENU,EMPTY_STRING,NULL,_System->Plugins()->Gfx()->GetDebugMenu(),"&RDP" ); Item.Reset(ID_PLUGIN_MENU,EMPTY_STRING,NULL,_Plugins->Gfx()->GetDebugMenu(),"&RDP" );
DebugMenu.push_back(Item); DebugMenu.push_back(Item);
} }
@ -1180,13 +1179,13 @@ void CMainMenu::ResetMenu(void) {
_Gui->SetWindowMenu(this); _Gui->SetWindowMenu(this);
WriteTrace(TraceDebug,"CMainMenu::ResetMenu - Remove plugin menu"); WriteTrace(TraceDebug,"CMainMenu::ResetMenu - Remove plugin menu");
if (_System->Plugins()->Gfx() != NULL && IsMenu((HMENU)_System->Plugins()->Gfx()->GetDebugMenu())) if (_Plugins->Gfx() != NULL && IsMenu((HMENU)_Plugins->Gfx()->GetDebugMenu()))
{ {
RemoveMenu((HMENU)OldMenuHandle,(DWORD)_System->Plugins()->Gfx()->GetDebugMenu(), MF_BYCOMMAND); RemoveMenu((HMENU)OldMenuHandle,(DWORD)_Plugins->Gfx()->GetDebugMenu(), MF_BYCOMMAND);
} }
if (_System->Plugins()->RSP() != NULL && IsMenu((HMENU)_System->Plugins()->RSP()->GetDebugMenu())) if (_Plugins->RSP() != NULL && IsMenu((HMENU)_Plugins->RSP()->GetDebugMenu()))
{ {
RemoveMenu((HMENU)OldMenuHandle,(DWORD)_System->Plugins()->RSP()->GetDebugMenu(), MF_BYCOMMAND); RemoveMenu((HMENU)OldMenuHandle,(DWORD)_Plugins->RSP()->GetDebugMenu(), MF_BYCOMMAND);
} }
WriteTrace(TraceDebug,"CMainMenu::ResetMenu - Destroy Old Menu"); WriteTrace(TraceDebug,"CMainMenu::ResetMenu - Destroy Old Menu");

View File

@ -54,7 +54,6 @@ class CMainMenu:public CBaseMenu
typedef std::list<SettingID> SettingList; typedef std::list<SettingID> SettingList;
CMainGui * _Gui; CMainGui * _Gui;
CN64System * _System;
//MSC_MAP m_ShortCuts; //MSC_MAP m_ShortCuts;
void * m_AccelTable; void * m_AccelTable;
@ -70,13 +69,11 @@ class CMainMenu:public CBaseMenu
static void SettingsChanged (CMainMenu * _this ); static void SettingsChanged (CMainMenu * _this );
public: public:
CMainMenu ( CMainGui * Window, CN64System * N64System ); CMainMenu ( CMainGui * Window );
~CMainMenu(); ~CMainMenu();
int ProcessAccelerator ( WND_HANDLE hWnd, void * lpMsg ); int ProcessAccelerator ( WND_HANDLE hWnd, void * lpMsg );
bool ProcessMessage ( WND_HANDLE hWnd, DWORD wNotifyCode, DWORD wID); bool ProcessMessage ( WND_HANDLE hWnd, DWORD wNotifyCode, DWORD wID);
void ResetMenu ( void ); void ResetMenu ( void );
void ResetAccelerators ( void ) { m_ResetAccelerators = true; } void ResetAccelerators ( void ) { m_ResetAccelerators = true; }
// void SaveShortCuts ( MSC_MAP * ShortCuts );
// LanguageStringID GetShortCutMenuItemName (MSC_MAP * ShortCuts, WORD key, bool bCtrl, bool bAlt, bool bShift, CMenuShortCutKey::ACCESS_MODE Access);
}; };

View File

@ -9,7 +9,7 @@
#include <shlobj.h> #include <shlobj.h>
#include <math.h> #include <math.h>
CRomBrowser::CRomBrowser (WND_HANDLE & MainWindow, WND_HANDLE & StatusWindow, CNotification * Notify, CN64System * System) : CRomBrowser::CRomBrowser (WND_HANDLE & MainWindow, WND_HANDLE & StatusWindow ) :
m_MainWindow(MainWindow), m_MainWindow(MainWindow),
m_StatusWindow(StatusWindow), m_StatusWindow(StatusWindow),
m_RefreshThread(NULL), m_RefreshThread(NULL),
@ -19,9 +19,7 @@ CRomBrowser::CRomBrowser (WND_HANDLE & MainWindow, WND_HANDLE & StatusWindow, CN
m_ZipIniFile(NULL), m_ZipIniFile(NULL),
m_WatchThreadID(0), m_WatchThreadID(0),
m_ShowingRomBrowser(false), m_ShowingRomBrowser(false),
_Notify(Notify), m_AllowSelectionLastRom(true)
m_AllowSelectionLastRom(true),
m_Plugins(NULL)
{ {
if (_Settings) { if (_Settings) {
m_RomIniFile = new CIniFile(_Settings->LoadString(SupportFile_RomDatabase).c_str()); m_RomIniFile = new CIniFile(_Settings->LoadString(SupportFile_RomDatabase).c_str());
@ -29,7 +27,6 @@ CRomBrowser::CRomBrowser (WND_HANDLE & MainWindow, WND_HANDLE & StatusWindow, CN
m_ExtIniFile = new CIniFile(_Settings->LoadString(SupportFile_ExtInfo).c_str()); m_ExtIniFile = new CIniFile(_Settings->LoadString(SupportFile_ExtInfo).c_str());
m_ZipIniFile = new CIniFile(_Settings->LoadString(SupportFile_7zipCache).c_str()); m_ZipIniFile = new CIniFile(_Settings->LoadString(SupportFile_7zipCache).c_str());
} }
_System = System;
m_hRomList = 0; m_hRomList = 0;
m_Visible = false; m_Visible = false;
@ -549,7 +546,7 @@ void CRomBrowser::GetRomFileNames( strlist & FileList, CPath & BaseDirectory, st
void CRomBrowser::NotificationCB ( LPCSTR Status, CRomBrowser * _this ) void CRomBrowser::NotificationCB ( LPCSTR Status, CRomBrowser * _this )
{ {
_this->_Notify->DisplayMessage(5,"%s",Status); _Notify->DisplayMessage(5,"%s",Status);
} }
@ -1344,7 +1341,7 @@ void CRomBrowser::RomList_OpenRom(DWORD pnmh) {
if (!pRomInfo) { return; } if (!pRomInfo) { return; }
m_StopRefresh = true; m_StopRefresh = true;
_System->RunFileImage(pRomInfo->szFullFileName); _N64System->RunFileImage(pRomInfo->szFullFileName);
} }
void CRomBrowser::RomList_PopupMenu(DWORD pnmh) { void CRomBrowser::RomList_PopupMenu(DWORD pnmh) {
@ -1397,9 +1394,9 @@ void CRomBrowser::RomList_PopupMenu(DWORD pnmh) {
if (inBasicMode) { DeleteMenu((HMENU)hPopupMenu,8,MF_BYPOSITION); } if (inBasicMode) { DeleteMenu((HMENU)hPopupMenu,8,MF_BYPOSITION); }
if (inBasicMode && !CheatsRemembered) { DeleteMenu((HMENU)hPopupMenu,7,MF_BYPOSITION); } if (inBasicMode && !CheatsRemembered) { DeleteMenu((HMENU)hPopupMenu,7,MF_BYPOSITION); }
DeleteMenu((HMENU)hPopupMenu,6,MF_BYPOSITION); DeleteMenu((HMENU)hPopupMenu,6,MF_BYPOSITION);
if (!inBasicMode && m_Plugins && m_Plugins->Gfx() && m_Plugins->Gfx()->GetRomBrowserMenu != NULL) if (!inBasicMode && _Plugins && _Plugins->Gfx() && _Plugins->Gfx()->GetRomBrowserMenu != NULL)
{ {
HMENU GfxMenu = (HMENU)m_Plugins->Gfx()->GetRomBrowserMenu(); HMENU GfxMenu = (HMENU)_Plugins->Gfx()->GetRomBrowserMenu();
if (GfxMenu) if (GfxMenu)
{ {
MENUITEMINFO lpmii; MENUITEMINFO lpmii;
@ -1515,7 +1512,8 @@ int CALLBACK CRomBrowser::SelectRomDirCallBack(WND_HANDLE hwnd,DWORD uMsg,DWORD
return 0; return 0;
} }
void CRomBrowser::SelectRomDir(CNotification * Notify) { void CRomBrowser::SelectRomDir(void)
{
char SelectedDir[MAX_PATH]; char SelectedDir[MAX_PATH];
LPITEMIDLIST pidl; LPITEMIDLIST pidl;
BROWSEINFO bi; BROWSEINFO bi;
@ -1544,7 +1542,7 @@ void CRomBrowser::SelectRomDir(CNotification * Notify) {
WriteTrace(TraceDebug,"CRomBrowser::SelectRomDir 6"); WriteTrace(TraceDebug,"CRomBrowser::SelectRomDir 6");
_Settings->SaveString(Directory_Game,Directory); _Settings->SaveString(Directory_Game,Directory);
WriteTrace(TraceDebug,"CRomBrowser::SelectRomDir 7"); WriteTrace(TraceDebug,"CRomBrowser::SelectRomDir 7");
Notify->AddRecentDir(Directory); _Notify->AddRecentDir(Directory);
WriteTrace(TraceDebug,"CRomBrowser::SelectRomDir 8"); WriteTrace(TraceDebug,"CRomBrowser::SelectRomDir 8");
RefreshRomBrowser(); RefreshRomBrowser();
WriteTrace(TraceDebug,"CRomBrowser::SelectRomDir 9"); WriteTrace(TraceDebug,"CRomBrowser::SelectRomDir 9");
@ -1841,8 +1839,3 @@ void CRomBrowser::Store7ZipInfo (CSettings * Settings, C7zip & ZipFile, int File
stdstr CacheFileName = Settings->LoadString(SupportFile_RomListCache); stdstr CacheFileName = Settings->LoadString(SupportFile_RomListCache);
DeleteFile(CacheFileName.c_str()); DeleteFile(CacheFileName.c_str());
} }
void CRomBrowser::SetPluginList ( CPlugins * Plugins )
{
m_Plugins = Plugins;
}

View File

@ -66,9 +66,8 @@ typedef struct {
} SORT_FIELD; } SORT_FIELD;
class C7zip; class C7zip;
class CRomBrowser { class CRomBrowser
CNotification * _Notify; {
enum { IDC_ROMLIST = 223 }; enum { IDC_ROMLIST = 223 };
enum { RB_FileName = 0, RB_InternalName = 1, RB_GoodName = 2, enum { RB_FileName = 0, RB_InternalName = 1, RB_GoodName = 2,
RB_Status = 3, RB_RomSize = 4, RB_CoreNotes = 5, RB_Status = 3, RB_RomSize = 4, RB_CoreNotes = 5,
@ -119,7 +118,6 @@ class CRomBrowser {
typedef std::vector<ROM_INFO> ROMINFO_LIST; typedef std::vector<ROM_INFO> ROMINFO_LIST;
CN64System * _System;
WND_HANDLE & m_MainWindow; WND_HANDLE & m_MainWindow;
WND_HANDLE & m_StatusWindow; WND_HANDLE & m_StatusWindow;
WND_HANDLE m_hRomList; WND_HANDLE m_hRomList;
@ -135,7 +133,6 @@ class CRomBrowser {
CIniFile * m_NotesIniFile; CIniFile * m_NotesIniFile;
CIniFile * m_ExtIniFile; CIniFile * m_ExtIniFile;
CIniFile * m_ZipIniFile; CIniFile * m_ZipIniFile;
CPlugins * m_Plugins;
bool m_AllowSelectionLastRom; bool m_AllowSelectionLastRom;
void AddFileNameToList ( strlist & FileList, stdstr & Directory, CPath & File ); void AddFileNameToList ( strlist & FileList, stdstr & Directory, CPath & File );
@ -184,7 +181,7 @@ class CRomBrowser {
static int CALLBACK RomList_CompareItems ( DWORD lParam1, DWORD lParam2, DWORD lParamSort ); static int CALLBACK RomList_CompareItems ( DWORD lParam1, DWORD lParam2, DWORD lParamSort );
public: public:
CRomBrowser ( WND_HANDLE & hMainWindow, WND_HANDLE & StatusWindow, CNotification * Notify, CN64System * System ); CRomBrowser ( WND_HANDLE & hMainWindow, WND_HANDLE & StatusWindow );
~CRomBrowser ( void ); ~CRomBrowser ( void );
void HighLightLastRom ( void ); void HighLightLastRom ( void );
void HideRomList ( void ); void HideRomList ( void );
@ -197,11 +194,10 @@ public:
bool RomListDrawItem ( int idCtrl, DWORD lParam ); bool RomListDrawItem ( int idCtrl, DWORD lParam );
bool RomListNotify ( int idCtrl, DWORD pnmh ); bool RomListNotify ( int idCtrl, DWORD pnmh );
void SaveRomListColoumnInfo ( void ); void SaveRomListColoumnInfo ( void );
void SelectRomDir ( CNotification * Notify ); void SelectRomDir ( void );
void ShowRomList ( void ); void ShowRomList ( void );
bool ShowingRomBrowser ( void ) { return m_ShowingRomBrowser; } bool ShowingRomBrowser ( void ) { return m_ShowingRomBrowser; }
LPCSTR CurrentedSelectedRom ( void ) { return m_SelectedRom.c_str(); } LPCSTR CurrentedSelectedRom ( void ) { return m_SelectedRom.c_str(); }
void SetPluginList ( CPlugins * Plugins);
static void Store7ZipInfo ( CSettings * Settings, C7zip & ZipFile, int FileNo ); static void Store7ZipInfo ( CSettings * Settings, C7zip & ZipFile, int FileNo );
static void GetFieldInfo ( ROMBROWSER_FIELDS_LIST & Fields, bool UseDefault = false ); static void GetFieldInfo ( ROMBROWSER_FIELDS_LIST & Fields, bool UseDefault = false );

View File

@ -66,7 +66,7 @@ IDI_LEFT ICON DISCARDABLE "Icons\\left.ico"
IDD_Settings_PlugSel DIALOGEX 0, 0, 231, 206 IDD_Settings_PlugSel DIALOGEX 0, 0, 231, 206
STYLE DS_CENTER | WS_CHILD | WS_VISIBLE STYLE DS_CENTER | WS_CHILD | WS_VISIBLE
EXSTYLE WS_EX_CONTROLPARENT EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
COMBOBOX GFX_LIST,7,18,155,79,CBS_DROPDOWNLIST | CBS_SORT | COMBOBOX GFX_LIST,7,18,155,79,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP WS_VSCROLL | WS_TABSTOP
@ -134,7 +134,7 @@ END
IDD_Settings_RomBrowser DIALOGEX 0, 0, 231, 206 IDD_Settings_RomBrowser DIALOGEX 0, 0, 231, 206
STYLE WS_CHILD STYLE WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
CONTROL "Use Rom Browser",IDC_USE_ROMBROWSER,"Button", CONTROL "Use Rom Browser",IDC_USE_ROMBROWSER,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,6,7,206,10 BS_AUTOCHECKBOX | WS_TABSTOP,6,7,206,10
@ -158,7 +158,7 @@ END
IDD_Settings_General DIALOGEX 0, 0, 231, 210 IDD_Settings_General DIALOGEX 0, 0, 231, 210
STYLE WS_CHILD STYLE WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
CONTROL "Pause emulation when window is not active?", CONTROL "Pause emulation when window is not active?",
IDC_AUTOSLEEP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,9, IDC_AUTOSLEEP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,9,
@ -226,7 +226,7 @@ END
IDD_Settings_GameGeneral DIALOGEX 0, 0, 218, 158 IDD_Settings_GameGeneral DIALOGEX 0, 0, 218, 158
STYLE WS_CHILD STYLE WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
LTEXT "Good Name:",IDC_GOOD_NAME_TEXT,6,8,91,10 LTEXT "Good Name:",IDC_GOOD_NAME_TEXT,6,8,91,10
EDITTEXT IDC_GOOD_NAME,102,7,109,12,ES_AUTOHSCROLL | ES_READONLY EDITTEXT IDC_GOOD_NAME,102,7,109,12,ES_AUTOHSCROLL | ES_READONLY
@ -262,7 +262,7 @@ END
IDD_Settings_Accelerator DIALOGEX 0, 0, 218, 183 IDD_Settings_Accelerator DIALOGEX 0, 0, 218, 183
STYLE WS_CHILD STYLE WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
LTEXT "CPU State:",IDC_S_CPU_STATE,8,9,42,11 LTEXT "CPU State:",IDC_S_CPU_STATE,8,9,42,11
COMBOBOX IDC_C_CPU_STATE,58,7,156,66,CBS_DROPDOWNLIST | COMBOBOX IDC_C_CPU_STATE,58,7,156,66,CBS_DROPDOWNLIST |
@ -388,7 +388,7 @@ END
IDD_Settings_Advanced DIALOGEX 0, 0, 231, 206 IDD_Settings_Advanced DIALOGEX 0, 0, 231, 206
STYLE WS_CHILD STYLE WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
CONTROL "Start Emulation when rom is opened?", CONTROL "Start Emulation when rom is opened?",
IDC_START_ON_ROM_OPEN,"Button",BS_AUTOCHECKBOX | IDC_START_ON_ROM_OPEN,"Button",BS_AUTOCHECKBOX |
@ -408,7 +408,7 @@ END
IDD_Settings_ShellInt DIALOGEX 0, 0, 231, 206 IDD_Settings_ShellInt DIALOGEX 0, 0, 231, 206
STYLE WS_CHILD STYLE WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
GROUPBOX "",IDC_STATIC,5,13,218,168 GROUPBOX "",IDC_STATIC,5,13,218,168
LTEXT "File extension association:",IDC_SHELL_INT_TEXT,73,37, LTEXT "File extension association:",IDC_SHELL_INT_TEXT,73,37,
@ -717,7 +717,7 @@ END
IDD_Settings_GameRecompiler DIALOGEX 0, 0, 230, 156 IDD_Settings_GameRecompiler DIALOGEX 0, 0, 230, 156
STYLE WS_CHILD STYLE WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
LTEXT "CPU core style:",IDC_CPU_TYPE_TEXT,4,11,106,10 LTEXT "CPU core style:",IDC_CPU_TYPE_TEXT,4,11,106,10
COMBOBOX IDC_CPU_TYPE,113,8,99,49,CBS_DROPDOWNLIST | WS_VSCROLL | COMBOBOX IDC_CPU_TYPE,113,8,99,49,CBS_DROPDOWNLIST | WS_VSCROLL |
@ -747,7 +747,7 @@ END
IDD_Settings_GamePlugin DIALOGEX 0, 0, 231, 206 IDD_Settings_GamePlugin DIALOGEX 0, 0, 231, 206
STYLE DS_CENTER | WS_CHILD | WS_VISIBLE STYLE DS_CENTER | WS_CHILD | WS_VISIBLE
EXSTYLE WS_EX_CONTROLPARENT EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
COMBOBOX GFX_LIST,7,18,155,79,CBS_DROPDOWNLIST | CBS_SORT | COMBOBOX GFX_LIST,7,18,155,79,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP WS_VSCROLL | WS_TABSTOP
@ -774,7 +774,7 @@ END
IDD_Settings_GameStatus DIALOGEX 0, 0, 218, 158 IDD_Settings_GameStatus DIALOGEX 0, 0, 218, 158
STYLE WS_CHILD STYLE WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
LTEXT "Status:",IDC_STATUS_TEXT,6,12,74,10 LTEXT "Status:",IDC_STATUS_TEXT,6,12,74,10
COMBOBOX IDC_STATUS_TYPE,80,10,131,49,CBS_DROPDOWNLIST | COMBOBOX IDC_STATUS_TYPE,80,10,131,49,CBS_DROPDOWNLIST |
@ -1085,8 +1085,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,7,0,50 FILEVERSION 1,7,0,51
PRODUCTVERSION 1,7,0,50 PRODUCTVERSION 1,7,0,51
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -1099,25 +1099,25 @@ VS_VERSION_INFO VERSIONINFO
BEGIN BEGIN
BLOCK "StringFileInfo" BLOCK "StringFileInfo"
BEGIN BEGIN
BLOCK "0c0904b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "Comments", "\0" VALUE "Comments", "\0"
VALUE "CompanyName", " \0" VALUE "CompanyName", " \0"
VALUE "FileDescription", "Project64\0" VALUE "FileDescription", "Project64\0"
VALUE "FileVersion", "1,7,0,50\0" VALUE "FileVersion", "1, 7, 0, 51\0"
VALUE "InternalName", "Project64\0" VALUE "InternalName", "Project64\0"
VALUE "LegalCopyright", "Copyright © 2004\0" VALUE "LegalCopyright", "Copyright © 2004\0"
VALUE "LegalTrademarks", "\0" VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "Project64.exe\0" VALUE "OriginalFilename", "Project64.exe\0"
VALUE "PrivateBuild", "\0" VALUE "PrivateBuild", "\0"
VALUE "ProductName", " Project64\0" VALUE "ProductName", " Project64\0"
VALUE "ProductVersion", "1,7,0,50\0" VALUE "ProductVersion", "1, 7, 0, 51\0"
VALUE "SpecialBuild", "\0" VALUE "SpecialBuild", "\0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
BEGIN BEGIN
VALUE "Translation", 0xc09, 1200 VALUE "Translation", 0x409, 1200
END END
END END
@ -1138,7 +1138,7 @@ IDR_HTML_ABOUT HTML DISCARDABLE "about.htm"
IDC_DIVIDER CURSOR DISCARDABLE "Icons\\divider.cur" IDC_DIVIDER CURSOR DISCARDABLE "Icons\\divider.cur"
IDC_HYPERLINK CURSOR DISCARDABLE "Icons\\hand.cur" IDC_HYPERLINK CURSOR DISCARDABLE "Icons\\hand.cur"
#endif // English (Australia) resources #endif // English (U.S.) resources
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

View File

@ -434,6 +434,11 @@ public:
Invalidate(); Invalidate();
} }
BOOL GetHasEditItem ()
{
return m_bEditItem;
}
int GetColumnCount() int GetColumnCount()
{ {
return m_aColumns.GetSize(); return m_aColumns.GetSize();

View File

@ -1,12 +1,4 @@
#include "Multilanguage.h" #include "stdafx.h"
#include "User Interface.h"
#include "N64 System.h"
#include "Plugin.h"
#include "Support.h"
#include <windows.h>
#include "Validate Binary.h"
#include <Aclapi.h>
//#pragma comment(linker,"/merge:.rdata=.text") //#pragma comment(linker,"/merge:.rdata=.text")
void FixUPXIssue ( BYTE * ProgramLocation ) void FixUPXIssue ( BYTE * ProgramLocation )
@ -268,11 +260,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgs,
WriteTrace(TraceDebug,"WinMain - Application Starting"); WriteTrace(TraceDebug,"WinMain - Application Starting");
FixUPXIssue((BYTE *)hInstance); FixUPXIssue((BYTE *)hInstance);
_Notify = &Notify();
//Create the plugin container //Create the plugin container
WriteTrace(TraceDebug,"WinMain - Create Plugins"); WriteTrace(TraceDebug,"WinMain - Create Plugins");
CPlugins Plugins ( _Settings->LoadString(Directory_Plugin) ); _Plugins = new CPlugins(_Settings->LoadString(Directory_Plugin));
WriteTrace(TraceDebug,"WinMain - Create N64 system");
CN64System N64System ( &Notify(), &Plugins ); //Create the backend n64 system
//Select the language //Select the language
_Lang->LoadCurrentStrings(true); _Lang->LoadCurrentStrings(true);
@ -284,11 +276,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgs,
{ {
WinTitle.Format("Project64 %s (%s)",VersionInfo(VERSION_PRODUCT_VERSION).c_str(),_Settings->LoadString(Beta_UserName).c_str()); WinTitle.Format("Project64 %s (%s)",VersionInfo(VERSION_PRODUCT_VERSION).c_str(),_Settings->LoadString(Beta_UserName).c_str());
} }
CMainGui MainWindow(WinTitle.c_str(),&Notify(),&N64System), HiddenWindow; CMainGui MainWindow(true,WinTitle.c_str()), HiddenWindow(false);
CMainMenu MainMenu(&MainWindow, &N64System); CMainMenu MainMenu(&MainWindow);
Plugins.SetRenderWindows(&MainWindow,&HiddenWindow); _Plugins->SetRenderWindows(&MainWindow,&HiddenWindow);
Notify().SetMainWindow(&MainWindow); _Notify->SetMainWindow(&MainWindow);
{ {
stdstr_f User("%s",_Settings->LoadString(Beta_UserName).c_str()); stdstr_f User("%s",_Settings->LoadString(Beta_UserName).c_str());
@ -304,13 +295,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgs,
if (__argc > 1) { if (__argc > 1) {
WriteTraceF(TraceDebug,"WinMain - Cmd line found \"%s\"",__argv[1]); WriteTraceF(TraceDebug,"WinMain - Cmd line found \"%s\"",__argv[1]);
MainWindow.Show(true); //Show the main window MainWindow.Show(true); //Show the main window
N64System.RunFileImage(__argv[1]); CN64System::RunFileImage(__argv[1]);
} else { } else {
if (_Settings->LoadDword(RomBrowser_Enabled)) if (_Settings->LoadDword(RomBrowser_Enabled))
{ {
WriteTrace(TraceDebug,"WinMain - Show Rom Browser"); WriteTrace(TraceDebug,"WinMain - Show Rom Browser");
//Display the rom browser //Display the rom browser
MainWindow.SetPluginList(&Plugins);
MainWindow.ShowRomList(); MainWindow.ShowRomList();
MainWindow.Show(true); //Show the main window MainWindow.Show(true); //Show the main window
MainWindow.HighLightLastRom(); MainWindow.HighLightLastRom();
@ -325,8 +315,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgs,
MainWindow.ProcessAllMessages(); MainWindow.ProcessAllMessages();
WriteTrace(TraceDebug,"WinMain - Message Loop Finished"); WriteTrace(TraceDebug,"WinMain - Message Loop Finished");
N64System.CloseCpu(); //terminate the cpu thread before quiting if (_N64System)
{
delete _N64System;
_N64System = NULL;
}
WriteTrace(TraceDebug,"WinMain - System Closed"); WriteTrace(TraceDebug,"WinMain - System Closed");
} }
catch(...) catch(...)
@ -335,16 +328,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgs,
MessageBox(NULL,stdstr_f("Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__).c_str(),"Exception",MB_OK); MessageBox(NULL,stdstr_f("Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__).c_str(),"Exception",MB_OK);
} }
WriteTrace(TraceDebug,"WinMain - cleaning up global objects"); WriteTrace(TraceDebug,"WinMain - cleaning up global objects");
if (_Settings)
{ if (_Rom) { delete _Rom; _Rom = NULL; }
delete _Settings; if (_Plugins) { delete _Plugins; _Plugins = NULL; }
_Settings = NULL; if (_Settings) { delete _Settings; _Settings = NULL; }
} if (_Lang) { delete _Lang; _Lang = NULL; }
if (_Lang)
{
delete _Lang;
_Lang = NULL;
}
CoUninitialize(); CoUninitialize();
WriteTrace(TraceDebug,"WinMain - Done"); WriteTrace(TraceDebug,"WinMain - Done");
CloseTrace(); CloseTrace();

View File

@ -0,0 +1,8 @@
#include "Multilanguage.h"
#include "User Interface.h"
#include "N64 System.h"
#include "Plugin.h"
#include "Support.h"
#include <windows.h>
#include "Validate Binary.h"
#include <Aclapi.h>