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

This commit is contained in:
zilmar 2010-06-12 02:02:06 +00:00
parent 41d4f7ff04
commit a5bfa92557
36 changed files with 4136 additions and 6434 deletions

View File

@ -3,52 +3,9 @@
<pre> <pre>
<h1>Build Log</h1> <h1>Build Log</h1>
<h3> <h3>
--------------------Configuration: 7zip - Win32 Release-------------------- --------------------Configuration: 7zip - Win32 External Release--------------------
</h3> </h3>
<h3>Command Lines</h3> <h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\NICHOL~1\LOCALS~1\Temp\RSPC52.tmp" with contents
[
/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"../../Build/7zip/Release/7zip.pch" /YX /Fo"../../Build/7zip/Release/" /Fd"../../Build/7zip/Release/" /FD /c
"D:\My Programs\Emulation\Projedt64\SOURCE\7zip\7zAlloc.c"
"D:\My Programs\Emulation\Projedt64\SOURCE\7zip\7zBuffer.c"
"D:\My Programs\Emulation\Projedt64\SOURCE\7zip\7zCrc.c"
"D:\My Programs\Emulation\Projedt64\SOURCE\7zip\7zDecode.c"
"D:\My Programs\Emulation\Projedt64\SOURCE\7zip\7zExtract.c"
"D:\My Programs\Emulation\Projedt64\SOURCE\7zip\7zHeader.c"
"D:\My Programs\Emulation\Projedt64\SOURCE\7zip\7zIn.c"
"D:\My Programs\Emulation\Projedt64\SOURCE\7zip\7zItem.c"
"D:\My Programs\Emulation\Projedt64\SOURCE\7zip\7zMethodID.c"
"D:\My Programs\Emulation\Projedt64\SOURCE\7zip\Compress\LzmaDecode.c"
]
Creating command line "cl.exe @C:\DOCUME~1\NICHOL~1\LOCALS~1\Temp\RSPC52.tmp"
Creating temporary file "C:\DOCUME~1\NICHOL~1\LOCALS~1\Temp\RSPC53.tmp" with contents
[
/nologo /out:"../../Build/7zip/Release\7zip.lib"
"\My Programs\Emulation\Projedt64\Build\7zip\Release\7zAlloc.obj"
"\My Programs\Emulation\Projedt64\Build\7zip\Release\7zBuffer.obj"
"\My Programs\Emulation\Projedt64\Build\7zip\Release\7zCrc.obj"
"\My Programs\Emulation\Projedt64\Build\7zip\Release\7zDecode.obj"
"\My Programs\Emulation\Projedt64\Build\7zip\Release\7zExtract.obj"
"\My Programs\Emulation\Projedt64\Build\7zip\Release\7zHeader.obj"
"\My Programs\Emulation\Projedt64\Build\7zip\Release\7zIn.obj"
"\My Programs\Emulation\Projedt64\Build\7zip\Release\7zItem.obj"
"\My Programs\Emulation\Projedt64\Build\7zip\Release\7zMethodID.obj"
"\My Programs\Emulation\Projedt64\Build\7zip\Release\LzmaDecode.obj"
]
Creating command line "link.exe -lib @C:\DOCUME~1\NICHOL~1\LOCALS~1\Temp\RSPC53.tmp"
<h3>Output Window</h3>
Compiling...
7zAlloc.c
7zBuffer.c
7zCrc.c
7zDecode.c
7zExtract.c
7zHeader.c
7zIn.c
7zItem.c
7zMethodID.c
LzmaDecode.c
Creating library...

View File

@ -67,14 +67,14 @@ void CC_Core::SetSettings ( )
void CC_Core::PauseExecution ( void ) void CC_Core::PauseExecution ( void )
{ {
_N64System->Pause(); _BaseSystem->Pause();
} }
void CC_Core::RunRsp ( void ) void CC_Core::RunRsp ( void )
{ {
try try
{ {
_N64System->RunRSP(); _System->RunRSP();
} }
catch (...) catch (...)
{ {
@ -86,22 +86,22 @@ void CC_Core::RunRsp ( void )
void CC_Core::GenerateProfileLog ( void ) void CC_Core::GenerateProfileLog ( void )
{ {
_N64System->m_Profile.GenerateLog(); _BaseSystem->m_Profile.GenerateLog();
} }
void CC_Core::ResetTimer ( void ) void CC_Core::ResetTimer ( void )
{ {
_N64System->m_Profile.ResetCounters(); _System->m_Profile.ResetCounters();
} }
DWORD CC_Core::StartTimer ( DWORD Address ) DWORD CC_Core::StartTimer ( DWORD Address )
{ {
return _N64System->m_Profile.StartTimer(Address); return _System->m_Profile.StartTimer(Address);
} }
DWORD CC_Core::StopTimer ( void ) DWORD CC_Core::StopTimer ( void )
{ {
return _N64System->m_Profile.StopTimer(); return _System->m_Profile.StopTimer();
} }
void PauseExecution ( void ) void PauseExecution ( void )
@ -167,19 +167,6 @@ void DacrateChanged ( enum SystemType Type )
_Plugins->Audio()->DacrateChanged(Type); _Plugins->Audio()->DacrateChanged(Type);
} }
BOOL Close_C_CPU ( void )
{
if (_Settings == NULL || !_Settings->LoadBool(GameRunning_CPU_Running))
{
return true;
}
_N64System->m_EndEmulation = true;
_Notify->BreakPoint(__FILE__,__LINE__);
// g_Main_CPU_Action->DoSomething = true;
// g_Main_CPU_Action->CloseCPU = true;
return false;
}
void RunRsp( void ) void RunRsp( void )
{ {
CC_Core::RunRsp(); CC_Core::RunRsp();
@ -187,12 +174,12 @@ void RunRsp( void )
void SyncSystem (void) void SyncSystem (void)
{ {
_N64System->SyncCPU(_SyncSystem); _BaseSystem->SyncCPU(_SyncSystem);
} }
void ApplyGSButtonCheats ( void ) void ApplyGSButtonCheats ( void )
{ {
CC_Core::ApplyGSButtonCheats(_N64System); CC_Core::ApplyGSButtonCheats(_BaseSystem);
} }
void ChangePluginFunc ( void ) void ChangePluginFunc ( void )
@ -224,7 +211,7 @@ void ChangePluginFunc ( void )
if (!_Plugins->Initiate()) if (!_Plugins->Initiate())
{ {
_Notify->DisplayMessage(5,MSG_PLUGIN_NOT_INIT); _Notify->DisplayMessage(5,MSG_PLUGIN_NOT_INIT);
_N64System->m_EndEmulation = true; _BaseSystem->m_EndEmulation = true;
} else { } else {
//CC_Core::SetCurrentSystem(_N64System); //CC_Core::SetCurrentSystem(_N64System);
} }
@ -238,7 +225,7 @@ void ChangeFullScreenFunc ( void )
BOOL Machine_LoadState ( void ) BOOL Machine_LoadState ( void )
{ {
bool Result = CC_Core::LoadState(_N64System); bool Result = CC_Core::LoadState(_System);
//CC_Core::SetCurrentSystem(_N64System); //CC_Core::SetCurrentSystem(_N64System);
return Result; return Result;
} }
@ -265,7 +252,7 @@ DWORD StopTimer ( void )
BOOL Machine_SaveState ( void ) BOOL Machine_SaveState ( void )
{ {
return CC_Core::SaveState(_N64System); return CC_Core::SaveState(_BaseSystem);
} }
void BreakPoint(LPCSTR FileName, int LineNumber ) void BreakPoint(LPCSTR FileName, int LineNumber )
@ -305,7 +292,7 @@ void CC_Core::ApplyCheats (CN64System * System)
void ApplyCheats (void) void ApplyCheats (void)
{ {
CC_Core::ApplyCheats(_N64System); CC_Core::ApplyCheats(_BaseSystem);
} }
void ResetX86Logs ( void ) void ResetX86Logs ( void )

View File

@ -45,7 +45,6 @@ void DacrateChanged ( enum SystemType Type );
void ChangePluginFunc ( void ); void ChangePluginFunc ( void );
void ApplyGSButtonCheats ( void ); void ApplyGSButtonCheats ( void );
void ChangeFullScreenFunc ( void ); void ChangeFullScreenFunc ( void );
BOOL Close_C_CPU ( void );
void StartInterpreterCPU ( void ); void StartInterpreterCPU ( void );
void SyncSystem ( void ); void SyncSystem ( void );
BOOL Machine_LoadState ( void ); BOOL Machine_LoadState ( void );

View File

@ -136,9 +136,9 @@ void PI_DMA_WRITE (void) {
} }
_Reg->PI_CART_ADDR_REG += 0x10000000; _Reg->PI_CART_ADDR_REG += 0x10000000;
if (!_N64System->DmaUsed()) if (!_System->DmaUsed())
{ {
_N64System->SetDmaUsed(true); _System->SetDmaUsed(true);
OnFirstDMA(); OnFirstDMA();
} }
if (_Recompiler && _Recompiler->bSMM_PIDMA()) if (_Recompiler && _Recompiler->bSMM_PIDMA())

View File

@ -54,7 +54,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;
_N64System->ExternalEvent(SysEvent_PauseCPU_DumpMemory); _BaseSystem->ExternalEvent(SysEvent_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 +65,7 @@ LRESULT CDumpMemory::OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& b
} }
SetDlgItemText(IDC_FILENAME,FileName); SetDlgItemText(IDC_FILENAME,FileName);
} }
_N64System->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); _BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
} }
break; break;
case IDOK: case IDOK:
@ -97,14 +97,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);
_N64System->ExternalEvent(SysEvent_PauseCPU_DumpMemory); _BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory);
if (!DumpMemory(FileName,Format,StartPC,EndPC,DumpPC)) if (!DumpMemory(FileName,Format,StartPC,EndPC,DumpPC))
{ {
//enable buttons //enable buttons
_N64System->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); _BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
return false; return false;
} }
_N64System->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); _BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
} }
EndDialog(0); EndDialog(0);
break; break;

View File

@ -178,7 +178,7 @@ void InPermLoop (void) {
if (( _Reg->STATUS_REGISTER & 0xFF00) == 0) { goto InterruptsDisabled; } if (( _Reg->STATUS_REGISTER & 0xFF00) == 0) { goto InterruptsDisabled; }
/* check sound playing */ /* check sound playing */
_N64System->SyncToAudio(); _System->SyncToAudio();
/* check RSP running */ /* check RSP running */
/* check RDP running */ /* check RDP running */
@ -196,7 +196,7 @@ InterruptsDisabled:
//CurrentPercent = 0; //CurrentPercent = 0;
//DisplayFPS(); //DisplayFPS();
DisplayError(GS(MSG_PERM_LOOP)); DisplayError(GS(MSG_PERM_LOOP));
_N64System->CloseCpu(); _System->CloseCpu();
} }
@ -223,7 +223,7 @@ void CInterpreterCPU::BuildCPU (void )
void CInterpreterCPU::ExecuteCPU (void ) void CInterpreterCPU::ExecuteCPU (void )
{ {
bool & Done = _N64System->m_EndEmulation; bool & Done = _System->m_EndEmulation;
DWORD & PROGRAM_COUNTER = *_PROGRAM_COUNTER; DWORD & PROGRAM_COUNTER = *_PROGRAM_COUNTER;
OPCODE & Opcode = R4300iOp::m_Opcode; OPCODE & Opcode = R4300iOp::m_Opcode;
DWORD & JumpToLocation = R4300iOp::m_JumpToLocation; DWORD & JumpToLocation = R4300iOp::m_JumpToLocation;
@ -290,7 +290,7 @@ void CInterpreterCPU::ExecuteCPU (void )
void CInterpreterCPU::ExecuteOps ( int Cycles ) void CInterpreterCPU::ExecuteOps ( int Cycles )
{ {
bool & Done = _N64System->m_EndEmulation; bool & Done = _System->m_EndEmulation;
DWORD & PROGRAM_COUNTER = *_PROGRAM_COUNTER; DWORD & PROGRAM_COUNTER = *_PROGRAM_COUNTER;
OPCODE & Opcode = R4300iOp::m_Opcode; OPCODE & Opcode = R4300iOp::m_Opcode;
DWORD & JumpToLocation = R4300iOp::m_JumpToLocation; DWORD & JumpToLocation = R4300iOp::m_JumpToLocation;

View File

@ -1,11 +1,3 @@
#ifdef toremove
#include <windows.h>
enum MemorySize { _8Bit, _16Bit, _32Bit, _64Bit };
class CC_Core;
#endif
class CMipsMemory_CallBack { class CMipsMemory_CallBack {
public: public:

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +1,11 @@
class CCodeSection;
class CRegInfo;
class CRSP_Plugin;
class CMipsMemoryVM : class CMipsMemoryVM :
public CMipsMemory, public CMipsMemory,
public CTransVaddr, public CTransVaddr,
private CRecompilerOps, private CRecompilerOps,
private R4300iOp private R4300iOp
{ {
//Make sure plugins can directly access this information
friend CGfxPlugin;
friend CAudioPlugin;
friend CRSP_Plugin;
friend CControl_Plugin;
friend CN64System; //Need to manipulate all memory in loading/saveing save state
// friend CC_Core;
#ifdef toremove
CNotification * const _Notify; //Original Notify member used to notify the user when something occurs
CN64System * const _System;
CN64Rom * const _Rom2; //Current loaded ROM
CRegisters * const _Reg;
#endif
CMipsMemory_CallBack * const m_CBClass; CMipsMemory_CallBack * const m_CBClass;
#ifdef toremove
//Save Chips accessed by memory
/*CSram * m_Sram;
CFlashRam * m_FlashRam;
bool m_SavesReadOnly;
*/
#endif
//Memory Locations //Memory Locations
BYTE * m_RDRAM, * m_DMEM, * m_IMEM, m_PIF_Ram[0x40]; BYTE * m_RDRAM, * m_DMEM, * m_IMEM, m_PIF_Ram[0x40];
DWORD m_AllocatedRdramSize; DWORD m_AllocatedRdramSize;
@ -44,29 +17,13 @@ class CMipsMemoryVM :
bool m_RomWrittenTo; bool m_RomWrittenTo;
DWORD m_RomWroteValue; DWORD m_RomWroteValue;
// Recompiler
void ** JumpTable/*, ** DelaySlotTable*/;
BYTE * m_RecompCode;
DWORD m_RecompSize;
enum { MaxCompileBufferSize = 0x03C00000 };
enum { InitialCompileBufferSize = 0x00500000 };
enum { IncreaseCompileBufferSize = 0x00100000 };
//Current Half line //Current Half line
void UpdateHalfLine ( void ); void UpdateHalfLine ( void );
DWORD m_HalfLine; DWORD m_HalfLine;
DWORD m_MemoryStack; DWORD m_MemoryStack;
DWORD m_TempValue; DWORD m_TempValue;
//Searching memory
BYTE * m_MemoryState;
DWORD m_MemoryStateSize;
//Initilizing and reseting information about the memory system //Initilizing and reseting information about the memory system
void AllocateSystemMemory ( void );
void InitalizeSystem ( bool PostPif );
void FixRDramSize ( void );
void FreeMemory ( void ); void FreeMemory ( void );
public: public:
@ -144,56 +101,14 @@ public:
bool TranslateVaddr ( DWORD VAddr, DWORD &PAddr) const; bool TranslateVaddr ( DWORD VAddr, DWORD &PAddr) const;
bool ValidVaddr ( DWORD VAddr ) const; bool ValidVaddr ( DWORD VAddr ) const;
// Recompiler Memory
bool AllocateRecompilerMemory ( bool AllocateJumpTable );
inline void ** GetJumpTable ( void ) const { return JumpTable; }
inline BYTE * GetRecompCode ( void ) const { return m_RecompCode; }
inline DWORD GetRecompBufferSize ( void ) const { return m_RecompSize; }
void CheckRecompMem ( BYTE * RecompPos );
#ifdef toremove
bool LoadPhysical32 ( DWORD PAddr, 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 Store64 ( DWORD VAddr, QWORD Value, MemorySize Size );
bool StorePhysical64 ( DWORD PAddr, QWORD Value, MemorySize Size );
inline DWORD RomFileSize ( void ) { return m_RomFileSize; }
//Win32 exception handler
void MemoryFilterFailed ( char * FailureType, DWORD MipsAddress, DWORD x86Address, DWORD Value);
int SystemMemoryFilter ( DWORD dwExptCode, void * lpExceptionPointer );
DWORD GetExceptionCodeFn ( void );
void * GetExceptionInformationFn ( void );
//Searching for value
enum SearchMemChangeState
{
SearchChangeState_Reset,
SearchChangeState_Changed,
SearchChangeState_Unchanged,
SearchChangeState_Greater,
SearchChangeState_Lessthan,
};
bool SearchSetBaseForChanges ( void );
bool SearchForChanges ( SearchMemChangeState SearchType, MemorySize Size,
DWORD &StartAddress, DWORD &Len,
DWORD &OldValue, DWORD &NewValue );
bool SearchForValue (DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len);
#endif
// Labels // Labels
LPCTSTR LabelName ( DWORD Address ) const; LPCTSTR LabelName ( DWORD Address ) const;
private: private:
static void RdramChanged ( CMipsMemoryVM * _this );
static void ChangeSpStatus ( void );
static void ChangeMiIntrMask ( void );
int LB_NonMemory ( DWORD PAddr, DWORD * Value, BOOL SignExtend ); int LB_NonMemory ( DWORD PAddr, DWORD * Value, BOOL SignExtend );
int LH_NonMemory ( DWORD PAddr, DWORD * Value, int SignExtend ); int LH_NonMemory ( DWORD PAddr, DWORD * Value, int SignExtend );
int LW_NonMemory ( DWORD PAddr, DWORD * Value ); int LW_NonMemory ( DWORD PAddr, DWORD * Value );
@ -208,5 +123,3 @@ private:
DWORD * m_TLB_ReadMap; DWORD * m_TLB_ReadMap;
DWORD * m_TLB_WriteMap; DWORD * m_TLB_WriteMap;
}; };
extern void ** JumpTable;

File diff suppressed because it is too large Load Diff

View File

@ -228,8 +228,8 @@ void CRegisters::Reset()
m_LO.DW = 0; m_LO.DW = 0;
m_RoundingModel = ROUND_NEAR; m_RoundingModel = ROUND_NEAR;
//LLBit = 0; m_LLBit = 0;
//LLAddr = 0; m_LLAddr = 0;
//Reset System Registers //Reset System Registers
memset(m_RDRAM_Interface,0,sizeof(m_RDRAM_Interface)); memset(m_RDRAM_Interface,0,sizeof(m_RDRAM_Interface));

View File

@ -49,6 +49,9 @@ void CSystemEvents::ExecuteEvents ( void )
_Reg->CheckInterrupts(); _Reg->CheckInterrupts();
_Plugins->Gfx()->SoftReset(); _Plugins->Gfx()->SoftReset();
break; break;
case SysEvent_ResetCPU_SoftDone:
_System->SoftReset();
break;
case SysEvent_Profile_GenerateLogs: case SysEvent_Profile_GenerateLogs:
GenerateProfileLog(); GenerateProfileLog();
break; break;
@ -158,6 +161,9 @@ void CSystemEvents::ExecuteEvents ( void )
bPause = true; bPause = true;
} }
break; break;
default:
_Notify->BreakPoint(__FILE__,__LINE__);
break;
} }
} }

View File

@ -2,6 +2,7 @@ enum SystemEvent {
SysEvent_ExecuteInterrupt, SysEvent_ExecuteInterrupt,
SysEvent_GSButtonPressed, SysEvent_GSButtonPressed,
SysEvent_ResetCPU_Soft, SysEvent_ResetCPU_Soft,
SysEvent_ResetCPU_SoftDone,
SysEvent_ResetCPU_Hard, SysEvent_ResetCPU_Hard,
SysEvent_CloseCPU, SysEvent_CloseCPU,
SysEvent_PauseCPU_FromMenu, SysEvent_PauseCPU_FromMenu,

View File

@ -4,7 +4,6 @@ CSystemTimer::CSystemTimer( int & NextTimer ) :
m_NextTimer(NextTimer) m_NextTimer(NextTimer)
{ {
Reset(); Reset();
SetTimer(ViTimer,50000,false);
} }
void CSystemTimer::Reset ( void ) void CSystemTimer::Reset ( void )
@ -18,6 +17,8 @@ void CSystemTimer::Reset ( void )
m_Current = UnknownTimer; m_Current = UnknownTimer;
m_Timer = 0; m_Timer = 0;
m_NextTimer = 0; m_NextTimer = 0;
SetTimer(ViTimer,50000,false);
} }
void CSystemTimer::SetTimer ( TimerType Type, DWORD Cycles, bool bRelative ) void CSystemTimer::SetTimer ( TimerType Type, DWORD Cycles, bool bRelative )
@ -137,7 +138,7 @@ void CSystemTimer::TimerDone (void)
break; break;
case CSystemTimer::SoftResetTimer: case CSystemTimer::SoftResetTimer:
_SystemTimer->StopTimer(CSystemTimer::SoftResetTimer); _SystemTimer->StopTimer(CSystemTimer::SoftResetTimer);
_N64System->SoftReset(); _System->ExternalEvent(SysEvent_ResetCPU_SoftDone);
break; break;
case CSystemTimer::SiTimer: case CSystemTimer::SiTimer:
_SystemTimer->StopTimer(CSystemTimer::SiTimer); _SystemTimer->StopTimer(CSystemTimer::SiTimer);
@ -154,7 +155,7 @@ void CSystemTimer::TimerDone (void)
case CSystemTimer::ViTimer: case CSystemTimer::ViTimer:
try try
{ {
_N64System->RefreshScreen(); _System->RefreshScreen();
} }
catch (...) catch (...)
{ {

View File

@ -49,9 +49,6 @@ CN64System::CN64System ( CPlugins * Plugins, bool SavesReadOnly ) :
//InterpreterOpcode = NULL; //InterpreterOpcode = NULL;
m_hPauseEvent = CreateEvent(NULL,true,false,NULL); m_hPauseEvent = CreateEvent(NULL,true,false,NULL);
//stop CPU and destroy current MMU
Reset();
switch (_Rom->GetCountry()) switch (_Rom->GetCountry())
{ {
case Germany: case french: case Italian: case Germany: case french: case Italian:
@ -73,7 +70,6 @@ CN64System::~CN64System ( void ) {
void CN64System::ExternalEvent ( SystemEvent action ) void CN64System::ExternalEvent ( SystemEvent action )
{ {
switch (action) { switch (action) {
case SysEvent_Profile_GenerateLogs: case SysEvent_Profile_GenerateLogs:
case SysEvent_Profile_StartStop: case SysEvent_Profile_StartStop:
@ -84,7 +80,7 @@ void CN64System::ExternalEvent ( SystemEvent action )
case SysEvent_ChangePlugins: case SysEvent_ChangePlugins:
case SysEvent_ChangingFullScreen: case SysEvent_ChangingFullScreen:
case SysEvent_GSButtonPressed: case SysEvent_GSButtonPressed:
case SysEvent_ResetCPU_Soft: case SysEvent_ResetCPU_SoftDone:
case SysEvent_Interrupt_SP: case SysEvent_Interrupt_SP:
case SysEvent_Interrupt_SI: case SysEvent_Interrupt_SI:
case SysEvent_Interrupt_AI: case SysEvent_Interrupt_AI:
@ -93,6 +89,13 @@ void CN64System::ExternalEvent ( SystemEvent action )
case SysEvent_Interrupt_DP: case SysEvent_Interrupt_DP:
QueueEvent(action); QueueEvent(action);
break; break;
case SysEvent_ResetCPU_Soft:
QueueEvent(action);
if (m_SyncCPU)
{
m_SyncCPU->QueueEvent(action);
}
break;
case SysEvent_PauseCPU_FromMenu: case SysEvent_PauseCPU_FromMenu:
case SysEvent_PauseCPU_AppLostFocus: case SysEvent_PauseCPU_AppLostFocus:
case SysEvent_PauseCPU_AppLostActive: case SysEvent_PauseCPU_AppLostActive:
@ -213,26 +216,26 @@ bool CN64System::EmulationStarting ( HANDLE hThread, DWORD ThreadId )
{ {
bool bRes = true; bool bRes = true;
if (_N64System) if (_BaseSystem)
{ {
WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Destroying old N64 system"); WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Destroying old N64 system");
delete _N64System; delete _BaseSystem;
_N64System = NULL; _BaseSystem = NULL;
} }
WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Creating N64 system"); WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Creating N64 system");
CN64System * System = new CN64System(_Plugins,false); _BaseSystem = new CN64System(_Plugins,false);
WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Setting N64 system as active"); WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Setting N64 system as active");
if (System->SetActiveSystem(true)) if (_BaseSystem->SetActiveSystem(true))
{ {
System->m_CPU_Handle = hThread; _BaseSystem->m_CPU_Handle = hThread;
System->m_CPU_ThreadID = ThreadId; _BaseSystem->m_CPU_ThreadID = ThreadId;
WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Setting up N64 system done"); WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Setting up N64 system done");
_Settings->SaveBool(GameRunning_LoadingInProgress,false); _Settings->SaveBool(GameRunning_LoadingInProgress,false);
_Notify->RefreshMenu(); _Notify->RefreshMenu();
try try
{ {
WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Game set to auto start, starting"); WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Game set to auto start, starting");
System->StartEmulation2(false); _BaseSystem->StartEmulation2(false);
WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Game Done"); WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Game Done");
} }
catch (...) catch (...)
@ -242,8 +245,8 @@ bool CN64System::EmulationStarting ( HANDLE hThread, DWORD ThreadId )
sprintf(Message,"CN64System::LoadFileImage - Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__); sprintf(Message,"CN64System::LoadFileImage - Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__);
MessageBox(NULL,Message,"Exception",MB_OK); MessageBox(NULL,Message,"Exception",MB_OK);
} }
System->m_CPU_Handle = NULL; _BaseSystem->m_CPU_Handle = NULL;
System->m_CPU_ThreadID = 0; _BaseSystem->m_CPU_ThreadID = 0;
} else { } else {
WriteTrace(TraceError,"CN64System::stLoadFileImage: SetActiveSystem failed"); WriteTrace(TraceError,"CN64System::stLoadFileImage: SetActiveSystem failed");
_Notify->DisplayError("Failed to Initialize N64 System"); _Notify->DisplayError("Failed to Initialize N64 System");
@ -252,10 +255,10 @@ bool CN64System::EmulationStarting ( HANDLE hThread, DWORD ThreadId )
bRes = false; bRes = false;
} }
if (System) if (_BaseSystem)
{ {
delete System; delete _BaseSystem;
System = NULL; _BaseSystem = NULL;
} }
return bRes; return bRes;
} }
@ -354,7 +357,6 @@ void CN64System::StartEmulation2 ( bool NewThread )
_Notify->MakeWindowOnTop(_Settings->LoadBool(UserInterface_AlwaysOnTop)); _Notify->MakeWindowOnTop(_Settings->LoadBool(UserInterface_AlwaysOnTop));
if (!_Settings->LoadBool(Beta_IsValidExe)) if (!_Settings->LoadBool(Beta_IsValidExe))
{ {
Reset();
return; return;
} }
@ -506,35 +508,12 @@ bool CN64System::IsDialogMsg( MSG * msg )
return false; return false;
} }
void CN64System::SoftReset()
{
if (GetRecompiler())
{
GetRecompiler()->ResetRecompCode();
}
//g_CPU_Action->DoSomething = TRUE;
if (_Plugins) { _Plugins->GameReset(); }
bool PostPif = true;
InitRegisters(PostPif,m_MMU_VM);
if (PostPif)
{
memcpy((m_MMU_VM.Dmem()+0x40), (_Rom->GetRomAddress() + 0x040), 0xFBC);
}
m_SystemTimer.SetTimer(CSystemTimer::CompareTimer,m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER,false);
Debug_Reset();
CloseSaveChips();
m_CyclesToSkip = 0;
m_AlistCount = 0;
m_DlistCount = 0;
m_UnknownCount = 0;
m_DMAUsed = false;
//g_CPU_Action->InterruptExecuted = false;
}
void CN64System::Reset (void) void CN64System::Reset (void)
{ {
if (m_Recomp)
{
m_Recomp->ResetRecompCode();
}
if (_Plugins) { _Plugins->GameReset(); } if (_Plugins) { _Plugins->GameReset(); }
m_Audio.ResetAudioSettings(); m_Audio.ResetAudioSettings();
Debug_Reset(); Debug_Reset();
@ -545,6 +524,23 @@ void CN64System::Reset (void)
m_DlistCount = 0; m_DlistCount = 0;
m_UnknownCount = 0; m_UnknownCount = 0;
m_SystemType = SYSTEM_NTSC; m_SystemType = SYSTEM_NTSC;
m_DMAUsed = false;
m_Reg.Reset();
m_SystemTimer.Reset();
m_SystemTimer.SetTimer(CSystemTimer::CompareTimer,m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER,false);
}
void CN64System::SoftReset()
{
Reset();
bool PostPif = true;
InitRegisters(PostPif,m_MMU_VM);
if (PostPif)
{
memcpy((m_MMU_VM.Dmem()+0x40), (_Rom->GetRomAddress() + 0x040), 0xFBC);
}
} }
bool CN64System::SetActiveSystem( bool bActive ) bool CN64System::SetActiveSystem( bool bActive )
@ -559,21 +555,14 @@ bool CN64System::SetActiveSystem( bool bActive )
{ {
return false; return false;
} }
bool PostPif = true; SoftReset();
InitRegisters(PostPif,m_MMU_VM);
if (PostPif)
{
memcpy((m_MMU_VM.Dmem()+0x40), (_Rom->GetRomAddress() + 0x040), 0xFBC);
}
m_SystemTimer.SetTimer(CSystemTimer::CompareTimer,m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER,false);
m_bInitilized = true; m_bInitilized = true;
bInitPlugin = true; bInitPlugin = true;
} }
m_Reg.SetAsCurrentSystem(); m_Reg.SetAsCurrentSystem();
_N64System = this; _System = this;
_SyncSystem = m_SyncCPU; _SyncSystem = m_SyncCPU;
_Recompiler = m_Recomp; _Recompiler = m_Recomp;
_MMU = &m_MMU_VM; _MMU = &m_MMU_VM;
@ -587,9 +576,9 @@ bool CN64System::SetActiveSystem( bool bActive )
_NextTimer = &m_NextTimer; _NextTimer = &m_NextTimer;
_Plugins = m_Plugins; _Plugins = m_Plugins;
} else { } else {
if (_N64System == this) if (this == _BaseSystem)
{ {
_N64System = NULL; _System = NULL;
_SyncSystem = NULL; _SyncSystem = NULL;
_Recompiler = NULL; _Recompiler = NULL;
_MMU = NULL; _MMU = NULL;
@ -614,6 +603,8 @@ bool CN64System::SetActiveSystem( bool bActive )
void CN64System::InitRegisters( bool bPostPif, CMipsMemory & MMU ) void CN64System::InitRegisters( bool bPostPif, CMipsMemory & MMU )
{ {
m_Reg.Reset();
//COP0 Registers //COP0 Registers
m_Reg.RANDOM_REGISTER = 0x1F; m_Reg.RANDOM_REGISTER = 0x1F;
m_Reg.COUNT_REGISTER = 0x5000; m_Reg.COUNT_REGISTER = 0x5000;
@ -850,7 +841,6 @@ void CN64System::CpuStopped ( void ) {
{ {
_Plugins->ShutDownPlugins(); _Plugins->ShutDownPlugins();
} }
Reset();
if (m_hPauseEvent) if (m_hPauseEvent)
{ {
CloseHandle(m_hPauseEvent); CloseHandle(m_hPauseEvent);
@ -1135,9 +1125,9 @@ bool CN64System::SaveState(void)
//Open the file //Open the file
if (_Settings->LoadDword(Game_FuncLookupMode) == FuncFind_ChangeMemory) if (_Settings->LoadDword(Game_FuncLookupMode) == FuncFind_ChangeMemory)
{ {
if (GetRecompiler()) if (m_Recomp)
{ {
GetRecompiler()->ResetRecompCode(); m_Recomp->ResetRecompCode();
} }
} }
@ -1332,15 +1322,11 @@ bool CN64System::LoadState(LPCSTR FileName) {
MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2); MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2);
if (result == IDNO) { return FALSE; } if (result == IDNO) { return FALSE; }
} }
m_Reg.Reset();
_MMU->UnProtectMemory(0x80000000,0x80000000 + _Settings->LoadDword(Game_RDRamSize) - 4); _MMU->UnProtectMemory(0x80000000,0x80000000 + _Settings->LoadDword(Game_RDRamSize) - 4);
_MMU->UnProtectMemory(0xA4000000,0xA4001FFC); _MMU->UnProtectMemory(0xA4000000,0xA4001FFC);
_Settings->SaveDword(Game_RDRamSize,SaveRDRAMSize); _Settings->SaveDword(Game_RDRamSize,SaveRDRAMSize);
WriteTrace(TraceError,"Make sure memory is tracking changes to Game_RDRamSize");
#ifdef tofix
if (SaveRDRAMSize != _Settings->LoadDword(Game_RDRamSize)) {
//_MMU->FixRDramSize();
}
#endif
unzReadCurrentFile(file,&NextVITimer,sizeof(NextVITimer)); unzReadCurrentFile(file,&NextVITimer,sizeof(NextVITimer));
unzReadCurrentFile(file,&m_Reg.m_PROGRAM_COUNTER,sizeof(m_Reg.m_PROGRAM_COUNTER)); unzReadCurrentFile(file,&m_Reg.m_PROGRAM_COUNTER,sizeof(m_Reg.m_PROGRAM_COUNTER));
unzReadCurrentFile(file,m_Reg.m_GPR,sizeof(_int64)*32); unzReadCurrentFile(file,m_Reg.m_GPR,sizeof(_int64)*32);
@ -1388,6 +1374,7 @@ bool CN64System::LoadState(LPCSTR FileName) {
MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2); MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2);
if (result == IDNO) { return FALSE; } if (result == IDNO) { return FALSE; }
} }
m_Reg.Reset();
_Notify->BreakPoint(__FILE__,__LINE__); _Notify->BreakPoint(__FILE__,__LINE__);
_MMU->UnProtectMemory(0x80000000,0x80000000 + _Settings->LoadDword(Game_RDRamSize) - 4); _MMU->UnProtectMemory(0x80000000,0x80000000 + _Settings->LoadDword(Game_RDRamSize) - 4);
_MMU->UnProtectMemory(0xA4000000,0xA4001FFC); _MMU->UnProtectMemory(0xA4000000,0xA4001FFC);
@ -1431,11 +1418,12 @@ bool CN64System::LoadState(LPCSTR FileName) {
m_Reg.RANDOM_REGISTER += 32 - m_Reg.WIRED_REGISTER; m_Reg.RANDOM_REGISTER += 32 - m_Reg.WIRED_REGISTER;
} }
WriteTrace(TraceDebug,"CN64System::LoadState 1"); WriteTrace(TraceDebug,"CN64System::LoadState 1");
if (GetRecompiler()) if (m_Recomp)
{ {
GetRecompiler()->ResetRecompCode(); m_Recomp->ResetRecompCode();
} }
SoftReset();
//Fix up timer //Fix up timer
m_Reg.m_CP0[32] = 0; m_Reg.m_CP0[32] = 0;
WriteTrace(TraceDebug,"CN64System::LoadState 2"); WriteTrace(TraceDebug,"CN64System::LoadState 2");

View File

@ -43,11 +43,7 @@ public:
void SoftReset ( void ); void SoftReset ( void );
bool m_EndEmulation; bool m_EndEmulation;
//Get the pointer to the Internal Classes // inline CPlugins * Plugins ( void ) const { return m_Plugins; }
CRecompiler * GetRecompiler ( void ) { return m_Recomp; }
//CN64Rom * GetCurrentRom ( void ) { return _Rom; }
inline CPlugins * Plugins ( void ) const { return m_Plugins; }
inline bool DmaUsed ( void ) const { return m_DMAUsed; } inline bool DmaUsed ( void ) const { return m_DMAUsed; }
inline void SetDmaUsed ( bool DMAUsed) { m_DMAUsed = DMAUsed; } inline void SetDmaUsed ( bool DMAUsed) { m_DMAUsed = DMAUsed; }

View File

@ -88,7 +88,6 @@ CCodeSection::CCodeSection( CCodeBlock * CodeBlock, DWORD EnterPC, DWORD ID) :
/* /*
Test2 = 0; Test2 = 0;
InLoop = false; InLoop = false;
DelaySlotSection = false;
*/ */
if (&CodeBlock->EnterSection() == this) if (&CodeBlock->EnterSection() == this)

View File

@ -1,77 +1,2 @@
#include "stdafx.h" #include "stdafx.h"
CDelaySlotFunctionMap::CDelaySlotFunctionMap()
{
}
CDelaySlotFunctionMap::~CDelaySlotFunctionMap()
{
Reset();
}
CCompiledFunc * CDelaySlotFunctionMap::AddFunctionInfo ( DWORD vAddr, DWORD pAddr )
{
Notify().BreakPoint(__FILE__,__LINE__);
#ifdef tofix
if (FunctionMap.find(vAddr) != FunctionMap.end())
{
Notify().BreakPoint(__FILE__,__LINE__);
}
CCompiledFunc * info = new CCompiledFunc(vAddr,pAddr);
FunctionMap.insert(FUNCTION_MAP::value_type(vAddr,info));
return info;
Notify().BreakPoint(__FILE__,__LINE__);
#endif
return NULL;
}
CCompiledFunc * CDelaySlotFunctionMap::FindFunction ( DWORD vAddr, int Length )
{
DWORD Start = ((vAddr + 0xFFF) >> 0xC);
DWORD End = ((vAddr + Length) >> 0xC);
for (DWORD i = Start; i < End; i++)
{
CCompiledFunc * info = FindFunction(i << 0xC);
if (info)
{
return info;
}
}
return NULL;
}
CCompiledFunc * CDelaySlotFunctionMap::FindFunction ( DWORD vAddr ) const
{
FUNCTION_MAP::const_iterator iter = FunctionMap.find(vAddr);
if (iter == FunctionMap.end())
{
return NULL;
}
return iter->second;
}
void CDelaySlotFunctionMap::Remove ( CCompiledFunc * info )
{
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
FUNCTION_MAP::iterator iter = FunctionMap.find(info->VAddrEnter());
if (iter != FunctionMap.end())
{
delete iter->second;
FunctionMap.erase(iter);
}
#endif
}
void CDelaySlotFunctionMap::Reset ( void )
{
for (FUNCTION_MAP::iterator iter = FunctionMap.begin(); iter != FunctionMap.end(); iter++)
{
delete iter->second;
}
FunctionMap.clear();
}

View File

@ -8,23 +8,7 @@ CFunctionMap::CFunctionMap() :
CFunctionMap::~CFunctionMap() CFunctionMap::~CFunctionMap()
{ {
if (m_FunctionTable) CleanBuffers();
{
for (int i = 0, n = 0x100000; i < n; i++)
{
if (m_FunctionTable[i] != NULL)
{
delete m_FunctionTable[i];
}
}
VirtualFree( m_FunctionTable, 0 , MEM_RELEASE);
m_FunctionTable = NULL;
}
if (m_DelaySlotTable)
{
VirtualFree( m_DelaySlotTable, 0 , MEM_RELEASE);
m_DelaySlotTable = NULL;
}
} }
bool CFunctionMap::AllocateMemory() bool CFunctionMap::AllocateMemory()
@ -50,6 +34,37 @@ bool CFunctionMap::AllocateMemory()
return true; return true;
} }
void CFunctionMap::CleanBuffers ( void )
{
if (m_FunctionTable)
{
for (int i = 0, n = 0x100000; i < n; i++)
{
if (m_FunctionTable[i] != NULL)
{
delete m_FunctionTable[i];
}
}
VirtualFree( m_FunctionTable, 0 , MEM_RELEASE);
m_FunctionTable = NULL;
}
if (m_DelaySlotTable)
{
VirtualFree( m_DelaySlotTable, 0 , MEM_RELEASE);
m_DelaySlotTable = NULL;
}
}
void CFunctionMap::Reset ( void )
{
bool bAllocate = m_FunctionTable != NULL;
CleanBuffers();
if (bAllocate)
{
AllocateMemory();
}
}
/* /*
CFunctionMap::~CFunctionMap() CFunctionMap::~CFunctionMap()

View File

@ -8,6 +8,13 @@ protected:
~CFunctionMap(); ~CFunctionMap();
bool AllocateMemory ( void ); bool AllocateMemory ( void );
void Reset ( void );
inline PCCompiledFunc_TABLE * FunctionTable ( void ) const { return m_FunctionTable; }
inline BYTE ** DelaySlotTable ( void ) const { return m_DelaySlotTable; }
private:
void CleanBuffers ( void );
PCCompiledFunc_TABLE * m_FunctionTable; PCCompiledFunc_TABLE * m_FunctionTable;
BYTE ** m_DelaySlotTable; BYTE ** m_DelaySlotTable;

View File

@ -3,10 +3,8 @@
CRecompiler::CRecompiler(CProfiling & Profile, bool & EndEmulation ) : CRecompiler::CRecompiler(CProfiling & Profile, bool & EndEmulation ) :
m_Profile(Profile), m_Profile(Profile),
PROGRAM_COUNTER(_Reg->m_PROGRAM_COUNTER), PROGRAM_COUNTER(_Reg->m_PROGRAM_COUNTER),
m_EndEmulation(EndEmulation), m_EndEmulation(EndEmulation)
m_FunctionsDelaySlot()
{ {
} }
CRecompiler::~CRecompiler() CRecompiler::~CRecompiler()
@ -30,18 +28,6 @@ void CRecompiler::Run()
WriteTrace(TraceError,"CRecompiler::Run: CRecompMemory::AllocateMemory failed"); WriteTrace(TraceError,"CRecompiler::Run: CRecompMemory::AllocateMemory failed");
return; return;
} }
WriteTrace(TraceError,"CRecompiler::Run Fix _MMU->AllocateRecompilerMemory");
#ifdef tofix
if (!_MMU->AllocateRecompilerMemory(LookUpMode() != FuncFind_VirtualLookup && LookUpMode() != FuncFind_ChangeMemory))
{
return;
}
JumpTable = _MMU->GetJumpTable();
RecompCode = _MMU->GetRecompCode();
#endif
ResetRecompCode();
m_EndEmulation = false; m_EndEmulation = false;
WriteTrace(TraceError,"CRecompiler::Run Fix g_MemoryStack"); WriteTrace(TraceError,"CRecompiler::Run Fix g_MemoryStack");
@ -82,7 +68,7 @@ void CRecompiler::RecompilerMain_VirtualTable ( void )
{ {
while(!m_EndEmulation) while(!m_EndEmulation)
{ {
PCCompiledFunc_TABLE & table = m_FunctionTable[PROGRAM_COUNTER >> 0xC]; PCCompiledFunc_TABLE & table = FunctionTable()[PROGRAM_COUNTER >> 0xC];
DWORD TableEntry = (PROGRAM_COUNTER & 0xFFF) >> 2; DWORD TableEntry = (PROGRAM_COUNTER & 0xFFF) >> 2;
if (table) if (table)
{ {
@ -461,77 +447,14 @@ void CRecompiler::RecompilerMain_Lookup( void )
void CRecompiler::ResetRecompCode() void CRecompiler::ResetRecompCode()
{ {
/* CRecompMemory::Reset();
RecompPos() = RecompCode; CFunctionMap::Reset();
m_Functions.Reset();
m_FunctionsDelaySlot.Reset();
if (JumpTable)
{
memset(JumpTable,0,_MMU->RdramSize());
memset(JumpTable + (0x04000000 >> 2),0,0x1000);
memset(JumpTable + (0x04001000 >> 2),0,0x1000);
if (bRomInMemory())
{
memset(JumpTable + (0x10000000 >> 2),0,RomFileSize);
}
}
#ifdef to_clean
DWORD count, OldProtect;
if (SelfModCheck == ModCode_ChangeMemory) {
DWORD count, PAddr, Value;
for (count = 0; count < TargetIndex; count++) {
PAddr = OrigMem[(WORD)(count)].PAddr;
Value = *(DWORD *)(RDRAM + PAddr);
if ( ((Value >> 16) == 0x7C7C) && ((Value & 0xFFFF) == count)) {
*(DWORD *)(RDRAM + PAddr) = OrigMem[(WORD)(count)].OriginalValue;
}
}
}
TargetIndex = 0;
//Jump Table
for (count = 0; count < (RdramSize >> 12); count ++ ) {
if (N64_Blocks.NoOfRDRamBlocks[count] > 0) {
N64_Blocks.NoOfRDRamBlocks[count] = 0;
memset(JumpTable + (count << 10),0,0x1000);
*(DelaySlotTable + count) = NULL;
if (VirtualProtect((RDRAM + (count << 12)), 4, PAGE_READWRITE, &OldProtect) == 0) {
DisplayError("Failed to unprotect %X\n1", (count << 12));
}
}
}
if (N64_Blocks.NoOfDMEMBlocks > 0) {
N64_Blocks.NoOfDMEMBlocks = 0;
memset(JumpTable + (0x04000000 >> 2),0,0x1000);
*(DelaySlotTable + (0x04000000 >> 12)) = NULL;
if (VirtualProtect((RDRAM + 0x04000000), 4, PAGE_READWRITE, &OldProtect) == 0) {
DisplayError("Failed to unprotect %X\n0", 0x04000000);
}
}
if (N64_Blocks.NoOfIMEMBlocks > 0) {
N64_Blocks.NoOfIMEMBlocks = 0;
memset(JumpTable + (0x04001000 >> 2),0,0x1000);
*(DelaySlotTable + (0x04001000 >> 12)) = NULL;
if (VirtualProtect((RDRAM + 0x04001000), 4, PAGE_READWRITE, &OldProtect) == 0) {
DisplayError("Failed to unprotect %X\n4", 0x04001000);
}
}
// if (N64_Blocks.NoOfPifRomBlocks > 0) {
// N64_Blocks.NoOfPifRomBlocks = 0;
// memset(JumpTable + (0x1FC00000 >> 2),0,0x1000);
// }
#endif
*/
} }
BYTE * CRecompiler::CompileDelaySlot(DWORD PC) BYTE * CRecompiler::CompileDelaySlot(DWORD PC)
{ {
int Index = PC >> 0xC; int Index = PC >> 0xC;
BYTE * delayFunc = m_DelaySlotTable[Index]; BYTE * delayFunc = DelaySlotTable()[Index];
if (delayFunc) if (delayFunc)
{ {
return delayFunc; return delayFunc;
@ -553,7 +476,8 @@ BYTE * CRecompiler::CompileDelaySlot(DWORD PC)
CCompiledFunc * Func = new CCompiledFunc(CodeBlock); CCompiledFunc * Func = new CCompiledFunc(CodeBlock);
delayFunc = (BYTE *)Func->Function(); delayFunc = (BYTE *)Func->Function();
m_DelaySlotTable[Index] = delayFunc; DelaySlotTable()[Index] = delayFunc;
delete Func;
return delayFunc; return delayFunc;
} }
@ -1889,12 +1813,19 @@ void CRecompiler::ClearRecompCode_Virt(DWORD Address, int length,REMOVE_REASON R
case FuncFind_VirtualLookup: case FuncFind_VirtualLookup:
{ {
DWORD AddressIndex = Address >> 0xC; DWORD AddressIndex = Address >> 0xC;
BYTE ** DelaySlotFuncs = DelaySlotTable();
if ((Address & 0xFFC) == 0 && DelaySlotFuncs[AddressIndex] != NULL)
{
DelaySlotFuncs[AddressIndex] = NULL;
}
DWORD WriteStart = (Address & 0xFFC); DWORD WriteStart = (Address & 0xFFC);
DWORD DataInBlock = 0x1000 - WriteStart; DWORD DataInBlock = 0x1000 - WriteStart;
int DataToWrite = length < DataInBlock ? length : DataInBlock; int DataToWrite = length < DataInBlock ? length : DataInBlock;
int DataLeft = length - DataToWrite; int DataLeft = length - DataToWrite;
PCCompiledFunc_TABLE & table = m_FunctionTable[AddressIndex]; PCCompiledFunc_TABLE & table = FunctionTable()[AddressIndex];
if (table) if (table)
{ {
memset(((BYTE *)table) + WriteStart,0,DataToWrite); memset(((BYTE *)table) + WriteStart,0,DataToWrite);

View File

@ -39,10 +39,6 @@ private:
//Quick access to registers //Quick access to registers
DWORD & PROGRAM_COUNTER; DWORD & PROGRAM_COUNTER;
//Functions
CDelaySlotFunctionMap m_FunctionsDelaySlot;
//CFunctionMap m_Functions;
CCompiledFunc * CompilerCode ( void ); CCompiledFunc * CompilerCode ( void );
bool Compiler4300iBlock ( CCompiledFunc * info ); bool Compiler4300iBlock ( CCompiledFunc * info );
@ -54,7 +50,6 @@ private:
bool FixConstants ( CCodeSection * Section, DWORD Test ); bool FixConstants ( CCodeSection * Section, DWORD Test );
bool InheritParentInfo ( CCodeSection * Section ); bool InheritParentInfo ( CCodeSection * Section );
void InheritConstants ( CCodeSection * Section ); void InheritConstants ( CCodeSection * Section );
// bool IsAllParentLoops ( CCodeSection * Section, CCodeSection * Parent, bool IgnoreIfCompiled, DWORD Test );
bool FillSectionInfo ( CCodeSection * Section, STEP_TYPE StartStepType ); bool FillSectionInfo ( CCodeSection * Section, STEP_TYPE StartStepType );
void SyncRegState ( CCodeSection * Section, CRegInfo * SyncTo ); void SyncRegState ( CCodeSection * Section, CRegInfo * SyncTo );
CCodeSection * ExistingSection( CCodeSection * StartSection, DWORD Addr, DWORD Test); CCodeSection * ExistingSection( CCodeSection * StartSection, DWORD Addr, DWORD Test);

View File

@ -35,6 +35,7 @@ bool CRecompMemory::AllocateMemory()
} }
m_RecompSize = InitialCompileBufferSize; m_RecompSize = InitialCompileBufferSize;
m_RecompPos = m_RecompCode; m_RecompPos = m_RecompCode;
memset(m_RecompCode,0,InitialCompileBufferSize);
return true; return true;
} }
@ -57,3 +58,8 @@ void CRecompMemory::CheckRecompMem ( void )
_Notify->FatalError(MSG_MEM_ALLOC_ERROR); _Notify->FatalError(MSG_MEM_ALLOC_ERROR);
} }
} }
void CRecompMemory::Reset()
{
m_RecompPos = m_RecompCode;
}

View File

@ -7,6 +7,7 @@ protected:
bool AllocateMemory ( void ); bool AllocateMemory ( void );
void CheckRecompMem ( void ); void CheckRecompMem ( void );
void Reset ( void );
inline BYTE * RecompPos ( void ) const { return m_RecompPos; } inline BYTE * RecompPos ( void ) const { return m_RecompPos; }

View File

@ -151,12 +151,8 @@ void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc,
} }
if (FallInfo->TargetPC <= m_CompilePC) if (FallInfo->TargetPC <= m_CompilePC)
{ {
_Notify->BreakPoint(__FILE__,__LINE__); UpdateCounters(m_RegWorkingSet,true,true);
#ifdef tofix
UpdateCounters(&(FallInfo->RegSet.BlockCycleCount()),&(FallInfo->RegSet.BlockRandomModifier()),true);
m_Section->CompileSystemCheck(FallInfo->TargetPC,FallInfo->RegSet);
ResetX86Protection(); ResetX86Protection();
#endif
} }
} else { } else {
if (m_Section->m_ContinueSection != NULL) { if (m_Section->m_ContinueSection != NULL) {
@ -1427,7 +1423,7 @@ void CRecompilerOps::CACHE (void){
AddConstToX86Reg(x86_EAX,(short)m_Opcode.offset); AddConstToX86Reg(x86_EAX,(short)m_Opcode.offset);
Push(x86_EAX); Push(x86_EAX);
} }
MoveConstToX86reg((DWORD)_N64System->GetRecompiler(),x86_ECX); MoveConstToX86reg((DWORD)_Recompiler,x86_ECX);
Call_Direct(AddressOf(CRecompiler::ClearRecompCode_Virt), "CRecompiler::ClearRecompCode_Virt"); Call_Direct(AddressOf(CRecompiler::ClearRecompCode_Virt), "CRecompiler::ClearRecompCode_Virt");
AfterCallDirect(); AfterCallDirect();
break; break;
@ -1748,21 +1744,13 @@ void CRecompilerOps::SPECIAL_JR (void) {
} }
} }
if ((m_CompilePC & 0xFFC) == 0xFFC) { if ((m_CompilePC & 0xFFC) == 0xFFC) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
if (IsMapped(m_Opcode.rs)) { if (IsMapped(m_Opcode.rs)) {
MoveX86regToVariable(cMipsRegLo(m_Opcode.rs),&JumpToLocation, "JumpToLocation"); Push(cMipsRegMapLo(m_Opcode.rs));
} else { } else {
MoveX86regToVariable(Map_TempReg(x86_Any,m_Opcode.rs,FALSE),&JumpToLocation, "JumpToLocation"); Push(Map_TempReg(x86_Any,m_Opcode.rs,FALSE));
} }
MoveConstToVariable(m_CompilePC + 4,_PROGRAM_COUNTER,"PROGRAM_COUNTER"); m_Section->GenerateSectionLinkage();
UpdateCounters(&m_RegWorkingSet.BlockCycleCount(),&m_RegWorkingSet.BlockRandomModifier(),FALSE);
m_RegWorkingSet.WriteBackRegisters();
if (CPU_Type == CPU_SyncCores) { Call_Direct(SyncToPC, "SyncToPC"); }
MoveConstToVariable(DELAY_SLOT,&m_NextInstruction,"m_NextInstruction");
Ret();
m_NextInstruction = END_BLOCK; m_NextInstruction = END_BLOCK;
#endif
return; return;
} }
if (DelaySlotEffectsCompare(m_CompilePC,m_Opcode.rs,0)) { if (DelaySlotEffectsCompare(m_CompilePC,m_Opcode.rs,0)) {
@ -1979,8 +1967,6 @@ void CRecompilerOps::SPECIAL_DSLLV (void) {
} }
void CRecompilerOps::SPECIAL_DSRLV (void) { void CRecompilerOps::SPECIAL_DSRLV (void) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
BYTE * Jump[2]; BYTE * Jump[2];
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
@ -2004,17 +1990,16 @@ void CRecompilerOps::SPECIAL_DSRLV (void) {
//if (Shift < 0x20) { //if (Shift < 0x20) {
//} else { //} else {
//} //}
//CRecompilerOps::UnknownOpcode(); CRecompilerOps::UnknownOpcode();
//return; } else {
}
Map_TempReg(x86_ECX,m_Opcode.rs,FALSE); Map_TempReg(x86_ECX,m_Opcode.rs,FALSE);
AndConstToX86Reg(x86_ECX,0x3F); AndConstToX86Reg(x86_ECX,0x3F);
Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt); Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt);
CompConstToX86reg(x86_ECX,0x20); CompConstToX86reg(x86_ECX,0x20);
JaeLabel8("MORE32", 0); JaeLabel8("MORE32", 0);
Jump[0] = m_RecompPos - 1; Jump[0] = m_RecompPos - 1;
ShiftRightDouble(cMipsRegLo(m_Opcode.rd),MipsRegHi(m_Opcode.rd)); ShiftRightDouble(cMipsRegMapLo(m_Opcode.rd),cMipsRegMapHi(m_Opcode.rd));
ShiftRightUnsign(MipsRegHi(m_Opcode.rd)); ShiftRightUnsign(cMipsRegMapHi(m_Opcode.rd));
JmpLabel8("continue", 0); JmpLabel8("continue", 0);
Jump[1] = m_RecompPos - 1; Jump[1] = m_RecompPos - 1;
@ -2022,16 +2007,16 @@ void CRecompilerOps::SPECIAL_DSRLV (void) {
CPU_Message(""); CPU_Message("");
CPU_Message(" MORE32:"); CPU_Message(" MORE32:");
*((BYTE *)(Jump[0]))=(BYTE)(m_RecompPos - Jump[0] - 1); *((BYTE *)(Jump[0]))=(BYTE)(m_RecompPos - Jump[0] - 1);
MoveX86RegToX86Reg(MipsRegHi(m_Opcode.rd),cMipsRegLo(m_Opcode.rd)); MoveX86RegToX86Reg(cMipsRegMapHi(m_Opcode.rd),cMipsRegMapLo(m_Opcode.rd));
XorX86RegToX86Reg(MipsRegHi(m_Opcode.rd),MipsRegHi(m_Opcode.rd)); XorX86RegToX86Reg(cMipsRegMapHi(m_Opcode.rd),cMipsRegMapHi(m_Opcode.rd));
AndConstToX86Reg(x86_ECX,0x1F); AndConstToX86Reg(x86_ECX,0x1F);
ShiftRightUnsign(cMipsRegLo(m_Opcode.rd)); ShiftRightUnsign(cMipsRegMapLo(m_Opcode.rd));
//continue: //continue:
CPU_Message(""); CPU_Message("");
CPU_Message(" continue:"); CPU_Message(" continue:");
*((BYTE *)(Jump[1]))=(BYTE)(m_RecompPos - Jump[1] - 1); *((BYTE *)(Jump[1]))=(BYTE)(m_RecompPos - Jump[1] - 1);
#endif }
} }
void CRecompilerOps::SPECIAL_DSRAV (void) { void CRecompilerOps::SPECIAL_DSRAV (void) {
@ -2075,13 +2060,11 @@ void CRecompilerOps::SPECIAL_DSRAV (void) {
} }
void CRecompilerOps::SPECIAL_MULT ( void) { void CRecompilerOps::SPECIAL_MULT ( void) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
cX86Protected(x86_EDX) = TRUE; X86Protected(x86_EDX) = TRUE;
Map_TempReg(x86_EAX,m_Opcode.rs,FALSE); Map_TempReg(x86_EAX,m_Opcode.rs,FALSE);
cX86Protected(x86_EDX) = FALSE; X86Protected(x86_EDX) = FALSE;
Map_TempReg(x86_EDX,m_Opcode.rt,FALSE); Map_TempReg(x86_EDX,m_Opcode.rt,FALSE);
imulX86reg(x86_EDX); imulX86reg(x86_EDX);
@ -2092,7 +2075,6 @@ void CRecompilerOps::SPECIAL_MULT ( void) {
ShiftRightSignImmed(x86_EDX,31); ShiftRightSignImmed(x86_EDX,31);
MoveX86regToVariable(x86_EAX,&_RegLO->UW[1],"_RegLO->UW[1]"); MoveX86regToVariable(x86_EAX,&_RegLO->UW[1],"_RegLO->UW[1]");
MoveX86regToVariable(x86_EDX,&_RegHI->UW[1],"_RegHI->UW[1]"); MoveX86regToVariable(x86_EDX,&_RegHI->UW[1],"_RegHI->UW[1]");
#endif
} }
void CRecompilerOps::SPECIAL_MULTU (void) { void CRecompilerOps::SPECIAL_MULTU (void) {
@ -3867,9 +3849,8 @@ void CRecompilerOps::COP1_MF (void) {
} }
void CRecompilerOps::COP1_DMF (void) { void CRecompilerOps::COP1_DMF (void) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
x86Reg TempReg; x86Reg TempReg;
char Name[50];
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
m_Section->CompileCop1Test(); m_Section->CompileCop1Test();
@ -3880,11 +3861,10 @@ void CRecompilerOps::COP1_DMF (void) {
sprintf(Name,"_FPR_D[%d]",m_Opcode.fs); sprintf(Name,"_FPR_D[%d]",m_Opcode.fs);
MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.fs],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.fs],Name,TempReg);
AddConstToX86Reg(TempReg,4); AddConstToX86Reg(TempReg,4);
MoveX86PointerToX86reg(MipsRegHi(m_Opcode.rt),TempReg); MoveX86PointerToX86reg(cMipsRegMapHi(m_Opcode.rt),TempReg);
sprintf(Name,"_FPR_D[%d]",m_Opcode.fs); sprintf(Name,"_FPR_D[%d]",m_Opcode.fs);
MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.fs],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.fs],Name,TempReg);
MoveX86PointerToX86reg(cMipsRegLo(m_Opcode.rt),TempReg); MoveX86PointerToX86reg(cMipsRegMapLo(m_Opcode.rt),TempReg);
#endif
} }
void CRecompilerOps::COP1_CF(void) { void CRecompilerOps::COP1_CF(void) {
@ -3924,8 +3904,6 @@ void CRecompilerOps::COP1_MT( void) {
} }
void CRecompilerOps::COP1_DMT( void) { void CRecompilerOps::COP1_DMT( void) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
x86Reg TempReg; x86Reg TempReg;
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
@ -3938,22 +3916,23 @@ void CRecompilerOps::COP1_DMT( void) {
} }
UnMap_FPR(m_Opcode.fs,TRUE); UnMap_FPR(m_Opcode.fs,TRUE);
TempReg = Map_TempReg(x86_Any,-1,FALSE); TempReg = Map_TempReg(x86_Any,-1,FALSE);
char Name[50];
sprintf(Name,"_FPR_D[%d]",m_Opcode.fs); sprintf(Name,"_FPR_D[%d]",m_Opcode.fs);
MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.fs],Name,TempReg); MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.fs],Name,TempReg);
if (IsConst(m_Opcode.rt)) { if (IsConst(m_Opcode.rt)) {
MoveConstToX86Pointer(cMipsRegLo(m_Opcode.rt),TempReg); MoveConstToX86Pointer(cMipsRegLo(m_Opcode.rt),TempReg);
AddConstToX86Reg(TempReg,4); AddConstToX86Reg(TempReg,4);
if (Section->Is64Bit(m_Opcode.rt)) { if (Is64Bit(m_Opcode.rt)) {
MoveConstToX86Pointer(MipsRegHi(m_Opcode.rt),TempReg); MoveConstToX86Pointer(MipsRegHi(m_Opcode.rt),TempReg);
} else { } else {
MoveConstToX86Pointer(Section->MipsRegLo_S(m_Opcode.rt) >> 31,TempReg); MoveConstToX86Pointer(MipsRegLo_S(m_Opcode.rt) >> 31,TempReg);
} }
} else if (IsMapped(m_Opcode.rt)) { } else if (IsMapped(m_Opcode.rt)) {
MoveX86regToX86Pointer(cMipsRegMapLo(m_Opcode.rt),TempReg); MoveX86regToX86Pointer(cMipsRegMapLo(m_Opcode.rt),TempReg);
AddConstToX86Reg(TempReg,4); AddConstToX86Reg(TempReg,4);
if (Section->Is64Bit(m_Opcode.rt)) { if (Is64Bit(m_Opcode.rt)) {
MoveX86regToX86Pointer(MipsRegHi(m_Opcode.rt),TempReg); MoveX86regToX86Pointer(cMipsRegMapHi(m_Opcode.rt),TempReg);
} else { } else {
MoveX86regToX86Pointer(Map_TempReg(x86_Any, m_Opcode.rt, TRUE),TempReg); MoveX86regToX86Pointer(Map_TempReg(x86_Any, m_Opcode.rt, TRUE),TempReg);
} }
@ -3963,7 +3942,6 @@ void CRecompilerOps::COP1_DMT( void) {
AddConstToX86Reg(TempReg,4); AddConstToX86Reg(TempReg,4);
MoveX86regToX86Pointer(Map_TempReg(Reg, m_Opcode.rt, TRUE),TempReg); MoveX86regToX86Pointer(Map_TempReg(Reg, m_Opcode.rt, TRUE),TempReg);
} }
#endif
} }
@ -4149,8 +4127,6 @@ void CRecompilerOps::COP1_S_MOV (void) {
} }
void CRecompilerOps::COP1_S_TRUNC_L (void) { void CRecompilerOps::COP1_S_TRUNC_L (void) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
m_Section->CompileCop1Test(); m_Section->CompileCop1Test();
@ -4158,7 +4134,6 @@ void CRecompilerOps::COP1_S_TRUNC_L (void) {
Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float);
} }
ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Qword,CRegInfo::RoundTruncate); ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Qword,CRegInfo::RoundTruncate);
#endif
} }
void CRecompilerOps::COP1_S_CEIL_L (void) { //added by Witten void CRecompilerOps::COP1_S_CEIL_L (void) { //added by Witten
@ -4447,12 +4422,9 @@ void CRecompilerOps::COP1_D_ABS (void) {
} }
void CRecompilerOps::COP1_D_NEG (void) { void CRecompilerOps::COP1_D_NEG (void) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double);
fpuNeg(); fpuNeg();
#endif
} }
void CRecompilerOps::COP1_D_SQRT (void) { void CRecompilerOps::COP1_D_SQRT (void) {
@ -4700,8 +4672,6 @@ void CRecompilerOps::COP1_W_CVT_D (void) {
/************************** COP1: L functions ************************/ /************************** COP1: L functions ************************/
void CRecompilerOps::COP1_L_CVT_S (void) { void CRecompilerOps::COP1_L_CVT_S (void) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
m_Section->CompileCop1Test(); m_Section->CompileCop1Test();
@ -4709,7 +4679,6 @@ void CRecompilerOps::COP1_L_CVT_S (void) {
Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Qword); Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Qword);
} }
ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Qword,CRegInfo::FPU_Float,CRegInfo::RoundDefault); ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Qword,CRegInfo::FPU_Float,CRegInfo::RoundDefault);
#endif
} }
void CRecompilerOps::COP1_L_CVT_D (void) { void CRecompilerOps::COP1_L_CVT_D (void) {
@ -4783,7 +4752,7 @@ void CRecompilerOps::UpdateCounters ( CRegInfo & RegSet, bool CheckTimer, bool C
BeforeCallDirect(); BeforeCallDirect();
PushImm32(stdstr_f("%d",RegSet.GetBlockCycleCount()).c_str(),RegSet.GetBlockCycleCount()); PushImm32(stdstr_f("%d",RegSet.GetBlockCycleCount()).c_str(),RegSet.GetBlockCycleCount());
PushImm32("_SyncSystem",(DWORD)_SyncSystem); PushImm32("_SyncSystem",(DWORD)_SyncSystem);
MoveConstToX86reg((DWORD)_N64System,x86_ECX); MoveConstToX86reg((DWORD)_System,x86_ECX);
Call_Direct(AddressOf(CN64System::UpdateSyncCPU),"CN64System::UpdateSyncCPU"); Call_Direct(AddressOf(CN64System::UpdateSyncCPU),"CN64System::UpdateSyncCPU");
AfterCallDirect(); AfterCallDirect();
} }

View File

@ -1,6 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
CN64System * _N64System = NULL; CN64System * _System = NULL;
CN64System * _BaseSystem = NULL;
CN64System * _SyncSystem = NULL; CN64System * _SyncSystem = NULL;
CRecompiler * _Recompiler = NULL; CRecompiler * _Recompiler = NULL;
CMipsMemory * _MMU = NULL; //Memory of the n64 CMipsMemory * _MMU = NULL; //Memory of the n64

View File

@ -1,7 +1,8 @@
extern CNotification * _Notify; extern CNotification * _Notify;
extern CSettings * _Settings; extern CSettings * _Settings;
extern CN64System * _N64System; extern CN64System * _System;
extern CN64System * _BaseSystem;
extern CN64System * _SyncSystem; extern CN64System * _SyncSystem;
extern CRecompiler * _Recompiler; extern CRecompiler * _Recompiler;
extern CMipsMemory * _MMU; //Memory of the n64 extern CMipsMemory * _MMU; //Memory of the n64

View File

@ -43,7 +43,7 @@ void CPlugins::PluginChanged ( CPlugins * _this )
{ {
if (_Settings->LoadBool(GameRunning_CPU_Running) != 0) if (_Settings->LoadBool(GameRunning_CPU_Running) != 0)
{ {
if (_N64System) { _N64System->ExternalEvent(SysEvent_ChangePlugins); } if (_BaseSystem) { _BaseSystem->ExternalEvent(SysEvent_ChangePlugins); }
} else { } else {
_this->Reset(); _this->Reset();
_Notify->RefreshMenu(); _Notify->RefreshMenu();
@ -160,14 +160,14 @@ bool CPlugins::InitiateMainThread( void )
WriteTrace(TraceDebug,"CPlugins::Initiate 6"); WriteTrace(TraceDebug,"CPlugins::Initiate 6");
WriteTrace(TraceGfxPlugin,"Initiate: Starting"); WriteTrace(TraceGfxPlugin,"Initiate: Starting");
if (!m_Gfx->Initiate(_N64System,_RenderWindow)) { return false; } if (!m_Gfx->Initiate(_System,_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(_N64System,_RenderWindow)) { return false; } if (!m_Audio->Initiate(_System,_RenderWindow)) { return false; }
WriteTrace(TraceDebug,"CPlugins::Initiate 8"); WriteTrace(TraceDebug,"CPlugins::Initiate 8");
if (!m_Control->Initiate(_N64System,_RenderWindow)) { return false; } if (!m_Control->Initiate(_System,_RenderWindow)) { return false; }
WriteTrace(TraceRSP ,"Initiate: Starting"); WriteTrace(TraceRSP ,"Initiate: Starting");
if (!m_RSP->Initiate(this,_N64System)) { return false; } if (!m_RSP->Initiate(this,_System)) { return false; }
WriteTrace(TraceRSP,"Initiate: Done"); WriteTrace(TraceRSP,"Initiate: Done");
WriteTrace(TraceDebug,"CPlugins::Initiate 10"); WriteTrace(TraceDebug,"CPlugins::Initiate 10");

View File

@ -586,6 +586,8 @@ SOURCE="3rd Party\zlib\UNZIP.C"
!IF "$(CFG)" == "Project64 - Win32 Release" !IF "$(CFG)" == "Project64 - Win32 Release"
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "Project64 - Win32 Debug" !ELSEIF "$(CFG)" == "Project64 - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
@ -601,6 +603,8 @@ SOURCE="3rd Party\zlib\zip.c"
!IF "$(CFG)" == "Project64 - Win32 Release" !IF "$(CFG)" == "Project64 - Win32 Release"
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "Project64 - Win32 Debug" !ELSEIF "$(CFG)" == "Project64 - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
@ -617,6 +621,8 @@ SOURCE="3rd Party\7zip.cpp"
!IF "$(CFG)" == "Project64 - Win32 Release" !IF "$(CFG)" == "Project64 - Win32 Release"
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "Project64 - Win32 Debug" !ELSEIF "$(CFG)" == "Project64 - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
@ -632,6 +638,8 @@ SOURCE="3rd Party\Processor Info.cpp"
!IF "$(CFG)" == "Project64 - Win32 Release" !IF "$(CFG)" == "Project64 - Win32 Release"
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "Project64 - Win32 Debug" !ELSEIF "$(CFG)" == "Project64 - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu

View File

@ -430,23 +430,6 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
} }
} }
/*#include <windows.h>
*/
/*CSettings::CSettings() :
RomIniFile(NULL),
CheatIniFile(NULL),
SettingsIniFile(NULL),
UnknownSetting_RSP(NULL),
UnknownSetting_GFX(NULL),
UnknownSetting_AUDIO(NULL),
UnknownSetting_CTRL(NULL)
{
}
*/
bool CSettings::Initilize( const char * AppName ) bool CSettings::Initilize( const char * AppName )
{ {
AddHowToHandleSetting(); AddHowToHandleSetting();
@ -964,709 +947,6 @@ void CSettings::UnknownSetting (SettingID Type)
#endif #endif
} }
/*CSettings::~CSettings() {
if (RomIniFile) {
delete RomIniFile;
RomIniFile = NULL;
}
if (CheatIniFile) {
delete CheatIniFile;
CheatIniFile = NULL;
}
if (SettingsIniFile)
{
delete SettingsIniFile;
SettingsIniFile = NULL;
}
}
void CSettings::Load(SettingID Type, char * Buffer, int BufferSize) {
if (Type != IsValidExe)
{
WriteTraceF(TraceSettings,"CSettings::Load 1 - %d",Type);
}
//Find out the information for handling the setting type from the list
SETTING_MAP::iterator FindInfo = SettingInfo.find(Type);
if (FindInfo == SettingInfo.end())
{ //if not found do nothing
UnknownSetting(Type);
return;
}
CSettingInfo * Info = &FindInfo->second;
if (Info->DefaultValue != Default_None) {
Load(Info->DefaultValue,Buffer, BufferSize);
}
//Copy Default String
if (Info->Location == ConstString) {
strncpy(Buffer,Info->Name.c_str(),BufferSize);
} else if (Info->Location == RelativePath) {
char path_buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR];
char fname[_MAX_FNAME],ext[_MAX_EXT];
GetModuleFileName(NULL,path_buffer,sizeof(path_buffer));
_splitpath( path_buffer, drive, dir, fname, ext );
sprintf(path_buffer,"%s%s",drive,dir);
if (Info->SubNode.size() > 0) {
strncat(path_buffer,Info->SubNode.c_str(),sizeof(path_buffer));
strncat(path_buffer,"\\",sizeof(path_buffer));
}
if (Info->Name.size() > 0) {
strncat(path_buffer,Info->Name.c_str(),sizeof(path_buffer));
}
strncpy(Buffer,path_buffer,BufferSize);
} else if (Info->Location == TemporarySetting) {
CGuard Guard(m_CS);
TEMP_SETTING_MAP::iterator TempInfo = TempKeys.find(Type);
if (TempInfo != TempKeys.end()) {
CTempInfo * temp = &TempInfo->second;
if (temp->DataType == Data_String) {
strncpy(Buffer,temp->String,BufferSize);
}
}
} else if (Info->Location == LocalSettings) {
if (SettingsIniFile == NULL) { return; }
if (Info->DataType == Data_String)
{
stdstr_f Ident("%s",Info->SubNode.c_str());
if (Ident.empty())
{
Ident = "default";
}
Ident.replace("\\","-");
SettingsIniFile->GetString(Ident.c_str(),Info->Name.c_str(),Buffer,Buffer,BufferSize);
} else {
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
}
} else if (Info->Location == InRegistry) {
char String[255];
//Get the location in the registry we are writing to
strncpy(String,Registrylocation,sizeof(String));
if (Info->SubNode.size() > 0) {
strncat(String,"\\",sizeof(String));
strncat(String,Info->SubNode.c_str(),sizeof(String));
}
//Open the registry key
long lResult;
HKEY hKeyResults = 0;
lResult = RegOpenKeyEx( (HKEY)RegistryKey,String,0, KEY_ALL_ACCESS,&hKeyResults);
if (lResult == ERROR_SUCCESS) {
//Get the value from the registry
DWORD RegType, Bytes = BufferSize;
lResult = RegQueryValueEx(hKeyResults,Info->Name.c_str(),0,&RegType,(LPBYTE)(Buffer),&Bytes);
if (RegType != REG_SZ || lResult != ERROR_SUCCESS) {
//Reload Defaults just in case data has changed
if (Info->DefaultValue != Default_None) {
Load(Info->DefaultValue,Buffer, BufferSize);
}
}
RegCloseKey(hKeyResults);
}
} else if (Info->Location == RomSetting) {
if (RomIniFile == NULL) { return; }
if (Info->DataType == Data_String) {
RomIniFile->GetString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),Buffer,Buffer,BufferSize);
}
} else if (Info->Location == CheatSetting) {
if (CheatIniFile == NULL) { return; }
if (Info->DataType == Data_String) {
CheatIniFile->GetString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),Buffer,Buffer,BufferSize);
}
} else if (Info->Location == GameSetting) {
if (SettingsIniFile == NULL) { return; }
if (Info->DataType == Data_String)
{
char Ident[400];
//Get the location in the registry we are writing to
sprintf(Ident,"%s%s%s",LoadString(ROM_IniKey).c_str(),Info->SubNode.empty()?"":"-",Info->SubNode.c_str());
int len = strlen(Ident);
for (int i = 0; i < len; i++)
{
if (Ident[i] == '\\')
{
Ident[i] = '-';
}
}
SettingsIniFile->GetString(Ident,Info->Name.c_str(),Buffer,Buffer,BufferSize);
} else {
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
}
} else {
//unknown ??
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
}
}
DWORD CSettings::LoadDword(SettingID Type ) {
if (Type != IsValidExe)
{
WriteTraceF(TraceSettings,"CSettings::Load 2 - %d",Type);
}
DWORD Value = 0;
Load(Type,Value);
return Value;
}
stdstr CSettings::LoadString ( SettingID Type ) {
if (Type != IsValidExe)
{
WriteTraceF(TraceSettings,"CSettings::Load 3 - %d",Type);
}
char Buffer[8000] = "";
Load(Type,Buffer,sizeof(Buffer));
return stdstr_f("%s",Buffer);
}
void CSettings::UnknownSetting (SettingID Type)
{
if (UnknownSetting_RSP)
{
if (Type >= FirstRSPDefaultSet && Type < LastRSPDefaultSet)
{
UnknownSetting_RSP(Type - FirstRSPDefaultSet);
return;
}
if (Type >= FirstRSPSettings && Type < LastRSPSettings)
{
UnknownSetting_RSP(Type - FirstRSPSettings);
return;
}
}
if (UnknownSetting_GFX)
{
if (Type >= FirstGfxDefaultSet && Type < LastGfxDefaultSet)
{
UnknownSetting_GFX(Type - FirstGfxDefaultSet);
return;
}
if (Type >= FirstGfxSettings && Type < LastGfxSettings)
{
UnknownSetting_GFX(Type - FirstGfxSettings);
return;
}
}
if (UnknownSetting_AUDIO)
{
if (Type >= FirstAudioDefaultSet && Type < LastAudioDefaultSet)
{
UnknownSetting_AUDIO(Type - FirstAudioDefaultSet);
return;
}
if (Type >= FirstAudioSettings && Type < LastAudioSettings)
{
UnknownSetting_AUDIO(Type - FirstAudioSettings);
return;
}
}
if (UnknownSetting_CTRL)
{
if (Type >= FirstCtrlDefaultSet && Type < LastCtrlDefaultSet)
{
UnknownSetting_CTRL(Type - FirstCtrlDefaultSet);
return;
}
if (Type >= FirstCtrlSettings && Type < LastCtrlSettings)
{
UnknownSetting_CTRL(Type - FirstCtrlSettings);
return;
}
}
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
}
void CSettings::Load(SettingID Type, DWORD & Value)
{
if (Type == Default_False || Type == Default_True)
{
Value = (Type == Default_True);
return;
}
if (Type != IsValidExe)
{
WriteTraceF(TraceSettings,"CSettings::Load 4 - %d",Type);
}
//Find out the information for handling the setting type from the list
SETTING_MAP::iterator FindInfo = SettingInfo.find(Type);
if (FindInfo == SettingInfo.end())
{
//if not found do nothing
UnknownSetting(Type);
return;
}
CSettingInfo * Info = &FindInfo->second;
if (Info->DefaultValue != Default_None) {
Load(Info->DefaultValue,Value);
}
if (Info->Location == ConstValue) {
Value = Info->Value;
}
else if (Info->Location == TemporarySetting)
{
CGuard Guard(m_CS);
TEMP_SETTING_MAP::iterator TempInfo = TempKeys.find(Type);
if (TempInfo != TempKeys.end()) {
CTempInfo * temp = &TempInfo->second;
if (temp->DataType == Data_DWORD) {
Value = temp->Value;
}
}
}
else if (Info->Location == InRegistry)
{
char String[255];
//Get the location in the registry we are writing to
strncpy(String,Registrylocation,sizeof(String));
if (Info->SubNode.size() > 0) {
strncat(String,"\\",sizeof(String));
strncat(String,Info->SubNode.c_str(),sizeof(String));
}
//Open the registry key
long lResult;
HKEY hKeyResults = 0;
lResult = RegOpenKeyEx( (HKEY)RegistryKey,String,0, KEY_ALL_ACCESS,&hKeyResults);
if (lResult == ERROR_SUCCESS) {
//Get the value from the registry
DWORD RegValue, RegType, Bytes = 4;
lResult = RegQueryValueEx(hKeyResults,Info->Name.c_str(),0,&RegType,(LPBYTE)(&RegValue),&Bytes);
if (RegType == REG_DWORD && lResult == ERROR_SUCCESS) {
Value = RegValue;
}
RegCloseKey(hKeyResults);
}
}
else if (Info->Location == RomSetting)
{
if (RomIniFile == NULL) { return; }
if (Info->DataType == Data_DWORD) {
Value = RomIniFile->GetNumber(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),Value);
} else if (Info->DataType == Data_CPUTYPE) {
char String [100];
strcpy(String,"");
RomIniFile->GetString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),String,String,sizeof(String));
if (strcmp(String,"Interpreter") == 0) { Value = CPU_Interpreter; }
else if (strcmp(String,"Recompiler") == 0) { Value = CPU_Recompiler; }
else if (strcmp(String,"SyncCores") == 0) { Value = CPU_SyncCores; }
else { Value = CPU_Default; }
// } else if (Info->DataType == Data_SelfMod) {
// char String [100];
// strcpy(String,"");
// RomIniFile->GetString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),String,String,sizeof(String));
// if (strcmp(String,"None") == 0) { *Value = ModCode_None; }
// else if (strcmp(String,"Cache") == 0) { *Value = ModCode_Cache; }
// else if (strcmp(String,"Protected Memory") == 0) { *Value = ModCode_ProtectedMemory; }
// else if (strcmp(String,"Check Memory") == 0) { *Value = ModCode_CheckMemoryCache; }
// else if (strcmp(String,"Check Memory & cache") == 0) { *Value = ModCode_CheckMemoryCache; }
// else if (strcmp(String,"Check Memory Advance") == 0) { *Value = ModCode_CheckMemory2; }
// else if (strcmp(String,"Change Memory") == 0) { *Value = ModCode_ChangeMemory; }
} else if (Info->DataType == Data_SaveChip) {
char String [100];
strcpy(String,"");
RomIniFile->GetString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),String,String,sizeof(String));
if (strcmp(String,"4kbit Eeprom") == 0) { Value = SaveChip_Eeprom_4K; }
else if (strcmp(String,"16kbit Eeprom") == 0) { Value = SaveChip_Eeprom_16K; }
else if (strcmp(String,"Sram") == 0) { Value = SaveChip_Sram; }
else if (strcmp(String,"FlashRam") == 0) { Value = SaveChip_FlashRam; }
} else if (Info->DataType == Data_OnOff) {
char String [100];
strcpy(String,"");
RomIniFile->GetString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),String,String,sizeof(String));
if (strcmp(String,"On") == 0) { Value = 1; }
if (strcmp(String,"Off") == 0) { Value = 0; }
} else if (Info->DataType == Data_YesNo) {
char String [100];
strcpy(String,"");
RomIniFile->GetString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),String,String,sizeof(String));
if (strcmp(String,"Yes") == 0) { Value = true; }
if (strcmp(String,"No") == 0) { Value = false; }
} else {
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
}
}
else if (Info->Location == GameSetting)
{
char Ident[400];
//Get the location in the registry we are writing to
sprintf(Ident,"%s%s%s",LoadString(ROM_IniKey).c_str(),Info->SubNode.empty()?"":"-",Info->SubNode.c_str());
int len = strlen(Ident);
for (int i = 0; i < len; i++)
{
if (Ident[i] == '\\')
{
Ident[i] = '-';
}
}
if (Info->DataType == Data_DWORD)
{
Value = SettingsIniFile->GetNumber(Ident,Info->Name.c_str(),Value);
}
else
{
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
}
}
else if (Info->Location == LocalSettings)
{
if (SettingsIniFile == NULL) { return; }
stdstr_f Ident("%s",Info->SubNode.c_str());
if (Ident.empty())
{
Ident = "default";
}
Ident.replace("\\","-");
if (Info->DataType == Data_DWORD)
{
Value = SettingsIniFile->GetNumber(Ident.c_str(),Info->Name.c_str(),Value);
}
else
{
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
}
} else {
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
}
}
void CSettings::SaveString(SettingID Type, const char * Buffer) {
//Find out the information for handling the setting type from the list
SETTING_MAP::iterator FindInfo = SettingInfo.find(Type);
if (FindInfo == SettingInfo.end())
{ //if not found do nothing
UnknownSetting(Type);
return;
}
CSettingInfo * Info = &FindInfo->second;
//make sure the setting type is a string
if (Info->DataType != Data_String)
{
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
return;
}
//create an entry in the temporary settings
if (Info->Location == TemporarySetting) {
CGuard Guard(m_CS);
TEMP_SETTING_MAP::iterator TempInfo = TempKeys.find(Type);
if (TempInfo != TempKeys.end()) { TempKeys.erase(TempInfo); } //free the previous memory
TempKeys.insert(TEMP_SETTING_MAP::value_type(Type,CTempInfo(Type,Buffer)));
}
//Save data to the registry
else if (Info->Location == InRegistry) {
char String[255];
//Get the location in the registry we are writing to
strncpy(String,Registrylocation,sizeof(String));
if (Info->SubNode.size() > 0) {
strncat(String,"\\",sizeof(String));
strncat(String,Info->SubNode.c_str(),sizeof(String));
}
//Create the target Key
DWORD Disposition = 0;
HKEY hKeyResults = 0;
long lResult;
lResult = RegCreateKeyEx( (HKEY)RegistryKey, String,0,"", REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,NULL, &hKeyResults,&Disposition);
if (lResult == ERROR_SUCCESS) {
RegSetValueEx(hKeyResults,Info->Name.c_str(),0, REG_SZ,(CONST BYTE *)(Buffer),strlen(Buffer));
}
RegCloseKey(hKeyResults);
}
else if (Info->Location == RomSetting) {
if (RomIniFile == NULL) { return; }
RomIniFile->SaveString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),Buffer);
}
else if (Info->Location == CheatSetting) {
if (CheatIniFile == NULL) { return; }
if (Info->DataType == Data_String) {
stdstr DefaultValue;
if (Info->DefaultValue != Default_None) {
DefaultValue = LoadString(Info->DefaultValue);
}
if (DefaultValue == Buffer) {
CheatIniFile->SaveString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),NULL);
} else {
CheatIniFile->SaveString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),Buffer);
}
} else {
Notify().BreakPoint(__FILE__,__LINE__);
}
}
else if (Info->Location == GameSetting) {
char Ident[400];
//Get the location in the registry we are writing to
sprintf(Ident,"%s%s%s",LoadString(ROM_IniKey).c_str(),Info->SubNode.empty()?"":"-",Info->SubNode.c_str());
int len = strlen(Ident);
for (int i = 0; i < len; i++)
{
if (Ident[i] == '\\')
{
Ident[i] = '-';
}
}
stdstr DefaultValue;
if (Info->DefaultValue != Default_None) {
DefaultValue = LoadString(Info->DefaultValue);
}
if (Info->DataType == Data_String)
{
if (DefaultValue == Buffer) {
SettingsIniFile->SaveString(Ident,Info->Name.c_str(),NULL);
} else {
SettingsIniFile->SaveString(Ident,Info->Name.c_str(),Buffer);
}
}
else
{
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
}
} else if (Info->Location == LocalSettings) {
if (SettingsIniFile == NULL) { return; }
stdstr DefaultValue;
if (Info->DefaultValue != Default_None) {
DefaultValue = LoadString(Info->DefaultValue);
}
stdstr_f Ident("%s",Info->SubNode.c_str());
Ident.replace("\\","-");
if (Ident.empty())
{
Ident = "default";
}
if (DefaultValue == Buffer) {
SettingsIniFile->SaveString(Ident.c_str(),Info->Name.c_str(),NULL);
} else {
SettingsIniFile->SaveString(Ident.c_str(),Info->Name.c_str(),Buffer);
}
}
else {
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
}
}
void CSettings::SaveDword(SettingID Type, DWORD Value) {
//Find out the information for handling the setting type from the list
SETTING_MAP::iterator FindInfo = SettingInfo.find(Type);
if (FindInfo == SettingInfo.end())
{ //if not found do nothing
UnknownSetting(Type);
return;
}
CSettingInfo * Info = &FindInfo->second;
//create an entry in the temporary settings
if (Info->Location == TemporarySetting) {
CGuard Guard(m_CS);
TEMP_SETTING_MAP::iterator TempInfo = TempKeys.find(Type);
if (TempInfo != TempKeys.end()) { TempKeys.erase(TempInfo); } //free the previous memory
TempKeys.insert(TEMP_SETTING_MAP::value_type(Type,CTempInfo(Type,Value)));
} else if (Info->Location == LocalSettings) {
if (SettingsIniFile == NULL) { return; }
DWORD DefaultValue = 0;
if (Info->DefaultValue != Default_None) {
Load(Info->DefaultValue,DefaultValue);
}
stdstr_f Ident("%s",Info->SubNode.c_str());
if (Ident.empty())
{
Ident = "default";
}
Ident.replace("\\","-");
if (Info->DefaultValue != Default_None && Value == DefaultValue) {
SettingsIniFile->SaveString(Ident.c_str(),Info->Name.c_str(),NULL);
} else {
SettingsIniFile->SaveNumber(Ident.c_str(),Info->Name.c_str(),Value);
}
} else if (Info->Location == InRegistry) {
char String[255];
//Get the location in the registry we are writing to
strncpy(String,Registrylocation,sizeof(String));
if (Info->SubNode.size() > 0) {
strncat(String,"\\",sizeof(String));
strncat(String,Info->SubNode.c_str(),sizeof(String));
}
//Create the target Key
DWORD Disposition = 0;
HKEY hKeyResults = 0;
long lResult;
lResult = RegCreateKeyEx( (HKEY)RegistryKey, String,0,"", REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,NULL, &hKeyResults,&Disposition);
if (lResult == ERROR_SUCCESS) {
RegSetValueEx(hKeyResults,Info->Name.c_str(),0, REG_DWORD,(CONST BYTE *)(&Value),sizeof(DWORD));
}
RegCloseKey(hKeyResults);
} else if (Info->Location == RomSetting) {
if (RomIniFile == NULL) { return; }
if (Info->DataType == Data_DWORD) {
DWORD DefaultValue = 0;
if (Info->DefaultValue != Default_None) {
Load(Info->DefaultValue,DefaultValue);
}
if (Info->DefaultValue != Default_None && Value == DefaultValue) {
RomIniFile->SaveString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),NULL);
} else {
RomIniFile->SaveNumber(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),Value);
}
} else if (Info->DataType == Data_CPUTYPE) {
const char * String;
switch (Value) {
case CPU_Interpreter: String = "Interpreter"; break;
case CPU_Recompiler: String = "Recompiler"; break;
case CPU_SyncCores: String = "SyncCores"; break;
default: String = NULL; break;
}
RomIniFile->SaveString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),String);
} else if (Info->DataType == Data_SaveChip) {
const char * String;
switch (Value) {
case SaveChip_Eeprom_4K: String = "4kbit Eeprom"; break;
case SaveChip_Eeprom_16K: String = "16kbit Eeprom"; break;
case SaveChip_Sram: String = "Sram"; break;
case SaveChip_FlashRam: String = "FlashRam"; break;
default: String = NULL; break;
}
RomIniFile->SaveString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),String);
// } else if (Info->DataType == Data_SelfMod) {
// const char * String;
// switch (Value) {
// case ModCode_None: String = "None"; break;
// case ModCode_Cache: String = "Cache"; break;
// case ModCode_ProtectedMemory: String = "Protected Memory"; break;
// case ModCode_CheckMemoryCache: String = "Check Memory & cache"; break;
// case ModCode_CheckMemory2: String = "Check Memory Advance"; break;
// case ModCode_ChangeMemory: String = "Change Memory"; break;
// default: String = NULL; break;
// }
// RomIniFile->SaveString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),String);
} else if (Info->DataType == Data_YesNo) {
DWORD DefaultValue = 0;
if (Info->DefaultValue != Default_None) {
Load(Info->DefaultValue,DefaultValue);
}
if (Info->DefaultValue != Default_None && Value == DefaultValue) {
RomIniFile->SaveString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),NULL);
} else {
RomIniFile->SaveString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),Value ? "Yes" : "No");
}
} else if (Info->DataType == Data_OnOff) {
const char * String;
switch (Value) {
case 0: String = "Off"; break;
case 1: String = "On"; break;
default: String = NULL; break;
}
RomIniFile->SaveString(LoadString(ROM_IniKey).c_str(),Info->Name.c_str(),String);
} else {
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
}
} else if (Info->Location == GameSetting) {
if (SettingsIniFile == NULL) { return; }
if (Info->DataType == Data_DWORD)
{
char Ident[400];
//Get the location in the registry we are writing to
sprintf(Ident,"%s%s%s",LoadString(ROM_IniKey).c_str(),Info->SubNode.empty()?"":"-",Info->SubNode.c_str());
int len = strlen(Ident);
for (int i = 0; i < len; i++)
{
if (Ident[i] == '\\')
{
Ident[i] = '-';
}
}
DWORD DefaultValue = 0;
if (Info->DefaultValue != Default_None) {
Load(Info->DefaultValue,DefaultValue);
}
if (Info->DefaultValue != Default_None && Value == DefaultValue) {
SettingsIniFile->SaveString(Ident,Info->Name.c_str(),NULL);
} else {
SettingsIniFile->SaveNumber(Ident,Info->Name.c_str(),Value);
}
} else{
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
}
} else {
#ifdef _DEBUG
Notify().BreakPoint(__FILE__,__LINE__);
#endif
}
for (SETTING_CHANGED_CB_LIST::iterator iter = m_CBDwordList.begin(); iter != m_CBDwordList.end(); iter ++)
{
SETTING_CHANGED_CB & item = *iter;
if (item.Type != Type) { continue; }
item.Func(item.Data);
}
}
*/
void CSettings::NotifyCallBacks( SettingID Type ) void CSettings::NotifyCallBacks( SettingID Type )
{ {
SETTING_CALLBACK::iterator Callback = m_Callback.find(Type); SETTING_CALLBACK::iterator Callback = m_Callback.find(Type);

View File

@ -298,7 +298,7 @@ int CMainGui::ProcessAllMessages (void) {
MSG msg; MSG msg;
while (GetMessage(&msg,NULL,0,0)) { while (GetMessage(&msg,NULL,0,0)) {
if (_N64System && _N64System->IsDialogMsg(&msg)) if (_BaseSystem && _BaseSystem->IsDialogMsg(&msg))
{ {
continue; continue;
} }
@ -518,11 +518,10 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
} }
} }
} }
if (CGuiSettings::bCPURunning() && _N64System) { if (CGuiSettings::bCPURunning() && _BaseSystem) {
CPlugins * Plugins = _N64System->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");
} }
} }
@ -612,11 +611,10 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
if (_this->m_bMainWindow && bCPURunning()) if (_this->m_bMainWindow && bCPURunning())
{ {
if (_N64System) if (_BaseSystem)
{ {
CPlugins * Plugins = _N64System->Plugins(); if (_Plugins && _Plugins->Control()->WM_KeyUp) {
if (Plugins && Plugins->Control()->WM_KeyUp) { _Plugins->Control()->WM_KeyUp(wParam, lParam);
Plugins->Control()->WM_KeyUp(wParam, lParam);
} }
} }
} }
@ -628,12 +626,11 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
if (_this->m_bMainWindow && bCPURunning()) if (_this->m_bMainWindow && bCPURunning())
{ {
if (_N64System) if (_BaseSystem)
{ {
CPlugins * Plugins = _N64System->Plugins(); if (_Plugins && _Plugins->Control()->WM_KeyDown)
if (Plugins && Plugins->Control()->WM_KeyDown)
{ {
Plugins->Control()->WM_KeyDown(wParam, lParam); _Plugins->Control()->WM_KeyDown(wParam, lParam);
} }
} }
} }
@ -650,9 +647,9 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) if (_this->m_bMainWindow && bCPURunning() && bAutoSleep())
{ {
if (_N64System) if (_BaseSystem)
{ {
_N64System->ExternalEvent( SysEvent_ResumeCPU_AppGainedFocus ); _BaseSystem->ExternalEvent( SysEvent_ResumeCPU_AppGainedFocus );
} }
} }
} }
@ -667,9 +664,9 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) if (_this->m_bMainWindow && bCPURunning() && bAutoSleep())
{ {
if (_N64System) if (_BaseSystem)
{ {
_N64System->ExternalEvent( SysEvent_PauseCPU_AppLostFocus ); _BaseSystem->ExternalEvent( SysEvent_PauseCPU_AppLostFocus );
} }
} }
} }
@ -687,7 +684,7 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
if (!fActive && _Settings->LoadBool(UserInterface_InFullScreen)) if (!fActive && _Settings->LoadBool(UserInterface_InFullScreen))
{ {
_Notify->WindowMode(); _Notify->WindowMode();
if (bAutoSleep() && _N64System) if (bAutoSleep() && _BaseSystem)
{ {
//System->ExternalEvent(PauseCPU_AppLostActiveDelayed ); //System->ExternalEvent(PauseCPU_AppLostActiveDelayed );
} }
@ -695,9 +692,9 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
} }
if (bAutoSleep()) if (bAutoSleep())
{ {
if (_N64System) if (_BaseSystem)
{ {
_N64System->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive ); _BaseSystem->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive );
} }
} }
} }
@ -729,7 +726,7 @@ 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: _N64System->RunFileImage(_this->CurrentedSelectedRom()); break; case ID_POPUPMENU_PLAYGAME: _BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); break;
case ID_POPUPMENU_ROMDIRECTORY: _this->SelectRomDir(); 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:
@ -771,20 +768,17 @@ 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 ) {
CPlugins * Plugins = _N64System->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 ) {
CPlugins * Plugins = _N64System->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 ) {
CPlugins * Plugins = _N64System->Plugins(); if (_Plugins->Gfx() && _Plugins->Gfx()->OnRomBrowserMenuItem != NULL)
if (Plugins->Gfx() && Plugins->Gfx()->OnRomBrowserMenuItem != NULL)
{ {
CN64Rom Rom; CN64Rom Rom;
if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(),true)) if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(),true))
@ -795,7 +789,7 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
_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");
if (_Rom) { if (_Rom) {
_Rom->SaveRomSettingID(); _Rom->SaveRomSettingID();
@ -840,7 +834,7 @@ DWORD CALLBACK CMainGui::MainGui_Proc (WND_HANDLE hWnd, DWORD uMsg, DWORD wParam
{ {
if (uMsg == _this->m_InvalidExeMsg) if (uMsg == _this->m_InvalidExeMsg)
{ {
_N64System->CloseCpu(); _BaseSystem->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

@ -63,24 +63,24 @@ 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 = _N64System->ChooseFileToOpen(hWnd); stdstr File = _BaseSystem->ChooseFileToOpen(hWnd);
if (File.length() > 0) { if (File.length() > 0) {
_N64System->RunFileImage(File.c_str()); _BaseSystem->RunFileImage(File.c_str());
} }
} }
break; break;
case ID_FILE_ROM_INFO: case ID_FILE_ROM_INFO:
{ {
_N64System->DisplayRomInfo(hWnd); _BaseSystem->DisplayRomInfo(hWnd);
} }
break; break;
case ID_FILE_STARTEMULATION: case ID_FILE_STARTEMULATION:
_Gui->SaveWindowLoc(); _Gui->SaveWindowLoc();
_N64System->StartEmulation(true); _BaseSystem->StartEmulation(true);
break; break;
case ID_FILE_ENDEMULATION: case ID_FILE_ENDEMULATION:
WriteTrace(TraceDebug,"ID_FILE_ENDEMULATION"); WriteTrace(TraceDebug,"ID_FILE_ENDEMULATION");
_N64System->CloseCpu(); _BaseSystem->CloseCpu();
_Gui->SaveWindowLoc(); _Gui->SaveWindowLoc();
break; break;
case ID_FILE_ROMDIRECTORY: case ID_FILE_ROMDIRECTORY:
@ -94,20 +94,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");
_N64System->ExternalEvent(SysEvent_ResetCPU_Soft); _BaseSystem->ExternalEvent(SysEvent_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");
_N64System->ExternalEvent(SysEvent_ResetCPU_Hard); _BaseSystem->ExternalEvent(SysEvent_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))
{ {
_N64System->ExternalEvent(SysEvent_ResumeCPU_FromMenu); _BaseSystem->ExternalEvent(SysEvent_ResumeCPU_FromMenu);
} else { } else {
_N64System->ExternalEvent(SysEvent_PauseCPU_FromMenu); _BaseSystem->ExternalEvent(SysEvent_PauseCPU_FromMenu);
} }
WriteTrace(TraceDebug,"ID_SYSTEM_PAUSE 1"); WriteTrace(TraceDebug,"ID_SYSTEM_PAUSE 1");
break; break;
@ -124,7 +124,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"); _N64System->ExternalEvent(SysEvent_SaveMachineState); break; case ID_SYSTEM_SAVE: WriteTrace(TraceDebug,"ID_SYSTEM_SAVE"); _BaseSystem->ExternalEvent(SysEvent_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];
@ -144,7 +144,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;
_N64System->ExternalEvent(SysEvent_PauseCPU_SaveGame); _BaseSystem->ExternalEvent(SysEvent_PauseCPU_SaveGame);
if (GetSaveFileName (&openfilename)) if (GetSaveFileName (&openfilename))
{ {
@ -164,13 +164,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);
_N64System->ExternalEvent(SysEvent_SaveMachineState); _BaseSystem->ExternalEvent(SysEvent_SaveMachineState);
} }
_N64System->ExternalEvent(SysEvent_ResumeCPU_SaveGame); _BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SaveGame);
} }
break; break;
case ID_SYSTEM_RESTORE: WriteTrace(TraceDebug,"ID_SYSTEM_RESTORE"); _N64System->ExternalEvent(SysEvent_LoadMachineState); break; case ID_SYSTEM_RESTORE: WriteTrace(TraceDebug,"ID_SYSTEM_RESTORE"); _BaseSystem->ExternalEvent(SysEvent_LoadMachineState); break;
case ID_SYSTEM_LOAD: case ID_SYSTEM_LOAD:
{ {
char Directory[255], SaveFile[255]; char Directory[255], SaveFile[255];
@ -189,7 +189,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;
_N64System->ExternalEvent(SysEvent_PauseCPU_LoadGame); _BaseSystem->ExternalEvent(SysEvent_PauseCPU_LoadGame);
if (GetOpenFileName (&openfilename)) { if (GetOpenFileName (&openfilename)) {
_Settings->SaveString(GameRunning_InstantSaveFile,SaveFile); _Settings->SaveString(GameRunning_InstantSaveFile,SaveFile);
@ -199,18 +199,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);
_N64System->ExternalEvent(SysEvent_LoadMachineState); _BaseSystem->ExternalEvent(SysEvent_LoadMachineState);
} }
_N64System->ExternalEvent(SysEvent_ResumeCPU_LoadGame); _BaseSystem->ExternalEvent(SysEvent_ResumeCPU_LoadGame);
} }
break; break;
case ID_SYSTEM_CHEAT: case ID_SYSTEM_CHEAT:
{ {
_N64System->SelectCheats(hWnd); _BaseSystem->SelectCheats(hWnd);
} }
break; break;
case ID_SYSTEM_GSBUTTON: case ID_SYSTEM_GSBUTTON:
_N64System->ExternalEvent(SysEvent_GSButtonPressed); _BaseSystem->ExternalEvent(SysEvent_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));
@ -229,13 +229,13 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
} }
break; break;
case ID_OPTIONS_INCREASE_SPEED: case ID_OPTIONS_INCREASE_SPEED:
_N64System->IncreaseSpeed(); _BaseSystem->IncreaseSpeed();
break; break;
case ID_OPTIONS_DECREASE_SPEED: case ID_OPTIONS_DECREASE_SPEED:
_N64System->DecreaeSpeed(); _BaseSystem->DecreaeSpeed();
break; break;
case ID_OPTIONS_FULLSCREEN: case ID_OPTIONS_FULLSCREEN:
_N64System->ExternalEvent(SysEvent_ChangingFullScreen); _BaseSystem->ExternalEvent(SysEvent_ChangingFullScreen);
break; break;
case ID_OPTIONS_FULLSCREEN2: case ID_OPTIONS_FULLSCREEN2:
if (_Settings->LoadBool(UserInterface_InFullScreen)) if (_Settings->LoadBool(UserInterface_InFullScreen))
@ -300,7 +300,7 @@ bool CMainMenu::ProcessMessage(WND_HANDLE hWnd, DWORD FromAccelerator, DWORD Men
} else { } else {
_Settings->SaveBool(UserInterface_ShowCPUPer,true); _Settings->SaveBool(UserInterface_ShowCPUPer,true);
} }
_N64System->ExternalEvent(SysEvent_CPUUsageTimerChanged); _BaseSystem->ExternalEvent(SysEvent_CPUUsageTimerChanged);
break; break;
case ID_OPTIONS_SETTINGS: case ID_OPTIONS_SETTINGS:
{ {
@ -310,10 +310,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));
_N64System->ExternalEvent(SysEvent_Profile_StartStop); _BaseSystem->ExternalEvent(SysEvent_Profile_StartStop);
break; break;
case ID_PROFILE_RESETCOUNTER: _N64System->ExternalEvent(SysEvent_Profile_ResetLogs); break; case ID_PROFILE_RESETCOUNTER: _BaseSystem->ExternalEvent(SysEvent_Profile_ResetLogs); break;
case ID_PROFILE_GENERATELOG: _N64System->ExternalEvent(SysEvent_Profile_GenerateLogs); break; case ID_PROFILE_GENERATELOG: _BaseSystem->ExternalEvent(SysEvent_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;
@ -435,17 +435,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:
_N64System->Debug_ShowMemoryDump(); _BaseSystem->Debug_ShowMemoryDump();
break; break;
case ID_DEBUGGER_SEARCHMEMORY: _N64System->Debug_ShowMemorySearch(); break; case ID_DEBUGGER_SEARCHMEMORY: _BaseSystem->Debug_ShowMemorySearch(); break;
case ID_DEBUGGER_MEMORY: _N64System->Debug_ShowMemoryWindow(); break; case ID_DEBUGGER_MEMORY: _BaseSystem->Debug_ShowMemoryWindow(); break;
case ID_DEBUGGER_TLBENTRIES: _N64System->Debug_ShowTLBWindow(); break; case ID_DEBUGGER_TLBENTRIES: _BaseSystem->Debug_ShowTLBWindow(); break;
case ID_DEBUGGER_INTERRUPT_SP: _N64System->ExternalEvent(SysEvent_Interrupt_SP); break; case ID_DEBUGGER_INTERRUPT_SP: _BaseSystem->ExternalEvent(SysEvent_Interrupt_SP); break;
case ID_DEBUGGER_INTERRUPT_SI: _N64System->ExternalEvent(SysEvent_Interrupt_SI); break; case ID_DEBUGGER_INTERRUPT_SI: _BaseSystem->ExternalEvent(SysEvent_Interrupt_SI); break;
case ID_DEBUGGER_INTERRUPT_AI: _N64System->ExternalEvent(SysEvent_Interrupt_AI); break; case ID_DEBUGGER_INTERRUPT_AI: _BaseSystem->ExternalEvent(SysEvent_Interrupt_AI); break;
case ID_DEBUGGER_INTERRUPT_VI: _N64System->ExternalEvent(SysEvent_Interrupt_VI); break; case ID_DEBUGGER_INTERRUPT_VI: _BaseSystem->ExternalEvent(SysEvent_Interrupt_VI); break;
case ID_DEBUGGER_INTERRUPT_PI: _N64System->ExternalEvent(SysEvent_Interrupt_PI); break; case ID_DEBUGGER_INTERRUPT_PI: _BaseSystem->ExternalEvent(SysEvent_Interrupt_PI); break;
case ID_DEBUGGER_INTERRUPT_DP: _N64System->ExternalEvent(SysEvent_Interrupt_DP); break; case ID_DEBUGGER_INTERRUPT_DP: _BaseSystem->ExternalEvent(SysEvent_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));
@ -503,7 +503,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)
{ {
_N64System->RunFileImage(FileName.c_str()); _BaseSystem->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) {
@ -653,6 +653,8 @@ stdstr CMainMenu::GetSaveSlotString (int Slot)
} }
void CMainMenu::FillOutMenu ( MENU_HANDLE hMenu ) { void CMainMenu::FillOutMenu ( MENU_HANDLE hMenu ) {
CGuard Guard(m_CS);
MENU_ITEM Item; MENU_ITEM Item;
//Get all flags //Get all flags
@ -1142,6 +1144,8 @@ void CMainMenu::FillOutMenu ( MENU_HANDLE hMenu ) {
} }
void CMainMenu::RebuildAccelerators(void) { void CMainMenu::RebuildAccelerators(void) {
CGuard Guard(m_CS);
//Delete the old accel list //Delete the old accel list
WriteTrace(TraceDebug,"CMainMenu::RebuildAccelerators - Start"); WriteTrace(TraceDebug,"CMainMenu::RebuildAccelerators - Start");
@ -1154,6 +1158,7 @@ void CMainMenu::RebuildAccelerators(void) {
} }
void CMainMenu::ResetMenu(void) { void CMainMenu::ResetMenu(void) {
CGuard Guard(m_CS);
WriteTrace(TraceDebug,"CMainMenu::ResetMenu - Start"); WriteTrace(TraceDebug,"CMainMenu::ResetMenu - Start");
m_ShortCuts.Load(); m_ShortCuts.Load();

View File

@ -60,6 +60,7 @@ class CMainMenu:public CBaseMenu
bool m_ResetAccelerators; bool m_ResetAccelerators;
CShortCuts m_ShortCuts; CShortCuts m_ShortCuts;
SettingList m_ChangeSettingList; SettingList m_ChangeSettingList;
CriticalSection m_CS;
void FillOutMenu ( MENU_HANDLE hMenu ); void FillOutMenu ( MENU_HANDLE hMenu );
//stdstr ShortCutString(MSC_MAP & ShortCuts, int MenuID, CMenuShortCutKey::ACCESS_MODE AccessLevel); //stdstr ShortCutString(MSC_MAP & ShortCuts, int MenuID, CMenuShortCutKey::ACCESS_MODE AccessLevel);

View File

@ -1332,7 +1332,7 @@ void CRomBrowser::RomList_OpenRom(DWORD pnmh) {
if (!pRomInfo) { return; } if (!pRomInfo) { return; }
m_StopRefresh = true; m_StopRefresh = true;
_N64System->RunFileImage(pRomInfo->szFullFileName); _BaseSystem->RunFileImage(pRomInfo->szFullFileName);
} }
void CRomBrowser::RomList_PopupMenu(DWORD pnmh) { void CRomBrowser::RomList_PopupMenu(DWORD pnmh) {

View File

@ -317,11 +317,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");
if (_N64System) if (_BaseSystem)
{ {
_N64System->CloseCpu(); _BaseSystem->CloseCpu();
delete _N64System; delete _BaseSystem;
_N64System = NULL; _BaseSystem = NULL;
} }
WriteTrace(TraceDebug,"WinMain - System Closed"); WriteTrace(TraceDebug,"WinMain - System Closed");

View File

@ -1,6 +1,8 @@
#pragma warning(disable:4247) #pragma warning(disable:4247)
#pragma warning(disable:4786) #pragma warning(disable:4786)
#include <common/MemTest.h>
#include <common/CriticalSection.h>
#include "Multilanguage.h" #include "Multilanguage.h"
#include "User Interface.h" #include "User Interface.h"
#include "N64 System.h" #include "N64 System.h"