2010-05-23 10:05:41 +00:00
|
|
|
#pragma once
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
typedef std::list<SystemEvent> EVENT_LIST;
|
|
|
|
|
|
|
|
typedef struct {
|
2010-06-04 06:25:07 +00:00
|
|
|
stdstr FileName;
|
|
|
|
HANDLE * ThreadHandle;
|
|
|
|
DWORD ThreadID;
|
2008-09-18 03:15:49 +00:00
|
|
|
} FileImageInfo;
|
|
|
|
|
|
|
|
typedef std::map<DWORD, DWORD> FUNC_CALLS;
|
|
|
|
|
|
|
|
class CPlugins;
|
|
|
|
class CRSP_Plugin;
|
|
|
|
class CC_Core;
|
|
|
|
|
|
|
|
//#define TEST_SP_TRACKING //track the SP to make sure all ops pick it up fine
|
|
|
|
|
|
|
|
class CN64System :
|
|
|
|
private CMipsMemory_CallBack,
|
2010-05-22 04:47:15 +00:00
|
|
|
private CTLB_CB,
|
2010-06-04 06:25:07 +00:00
|
|
|
private CSystemEvents,
|
2008-09-18 03:15:49 +00:00
|
|
|
protected CN64SystemSettings,
|
|
|
|
public CDebugger
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
public:
|
|
|
|
CN64System ( CPlugins * Plugins, bool SavesReadOnly );
|
2010-06-04 06:25:07 +00:00
|
|
|
virtual ~CN64System ( void );
|
2010-05-22 04:47:15 +00:00
|
|
|
|
|
|
|
//Methods
|
|
|
|
static bool CN64System::RunFileImage ( const char * FileLoc );
|
|
|
|
|
|
|
|
void CloseCpu ( void );
|
2010-06-04 06:25:07 +00:00
|
|
|
void ExternalEvent ( SystemEvent action ); //covers gui interacting and timers etc..
|
2010-05-22 04:47:15 +00:00
|
|
|
stdstr ChooseFileToOpen ( WND_HANDLE hParent );
|
|
|
|
void DisplayRomInfo ( WND_HANDLE hParent );
|
|
|
|
void SelectCheats ( WND_HANDLE hParent );
|
|
|
|
void StartEmulation ( bool NewThread );
|
|
|
|
void SyncToAudio ( void );
|
|
|
|
bool IsDialogMsg ( MSG * msg );
|
|
|
|
void IncreaseSpeed ( void ) { m_Limitor.IncreaeSpeed(10); }
|
|
|
|
void DecreaeSpeed ( void ) { m_Limitor.DecreaeSpeed(10); }
|
|
|
|
void SoftReset ( void );
|
|
|
|
bool m_EndEmulation;
|
|
|
|
|
2010-06-12 02:02:06 +00:00
|
|
|
// inline CPlugins * Plugins ( void ) const { return m_Plugins; }
|
2010-06-04 06:25:07 +00:00
|
|
|
inline bool DmaUsed ( void ) const { return m_DMAUsed; }
|
|
|
|
inline void SetDmaUsed ( bool DMAUsed) { m_DMAUsed = DMAUsed; }
|
2010-05-22 04:47:15 +00:00
|
|
|
|
|
|
|
//Variable used to track that the SP is being handled and stays the same as the real SP in sync core
|
|
|
|
#ifdef TEST_SP_TRACKING
|
|
|
|
DWORD m_CurrentSP;
|
|
|
|
#endif
|
|
|
|
//For Sync CPU
|
|
|
|
void UpdateSyncCPU ( CN64System * const SecondCPU, DWORD const Cycles );
|
|
|
|
void SyncCPU ( CN64System * const SecondCPU );
|
|
|
|
|
|
|
|
private:
|
2008-09-18 03:15:49 +00:00
|
|
|
//Make sure plugins can directly access this information
|
|
|
|
friend CGfxPlugin;
|
|
|
|
friend CAudioPlugin;
|
|
|
|
friend CRSP_Plugin;
|
|
|
|
friend CControl_Plugin;
|
|
|
|
|
|
|
|
//Recompiler has access to manipulate and call functions
|
|
|
|
friend CC_Core;
|
2010-06-07 02:23:58 +00:00
|
|
|
friend CSystemTimer;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
//Used for loading and potentialy executing the CPU in its own thread.
|
2010-05-22 04:47:15 +00:00
|
|
|
static void stLoadFileImage ( FileImageInfo * Info );
|
2008-09-18 03:15:49 +00:00
|
|
|
static void StartEmulationThread ( FileImageInfo * Info );
|
2010-06-04 06:25:07 +00:00
|
|
|
static bool EmulationStarting ( HANDLE hThread, DWORD ThreadId );
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
void ExecuteCPU ( void );
|
|
|
|
void RefreshScreen ( void );
|
|
|
|
bool InternalEvent ( void );
|
|
|
|
bool InPermLoop ( void );
|
|
|
|
void Reset ( void );
|
|
|
|
void RunRSP ( void );
|
|
|
|
bool SaveState ( void );
|
|
|
|
bool LoadState ( LPCSTR FileName );
|
|
|
|
bool LoadState ( void );
|
|
|
|
void DumpSyncErrors ( CN64System * SecondCPU );
|
|
|
|
void StartEmulation2 ( bool NewThread );
|
2010-05-31 00:21:08 +00:00
|
|
|
bool SetActiveSystem ( bool bActive = true );
|
2010-05-23 10:05:41 +00:00
|
|
|
void InitRegisters ( bool bPostPif, CMipsMemory & MMU );
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
//CPU Methods
|
|
|
|
void ExecuteRecompiler ( CC_Core & C_Core );
|
|
|
|
void ExecuteInterpret ( CC_Core & C_Core );
|
|
|
|
void ExecuteSyncCPU ( CC_Core & C_Core );
|
|
|
|
|
|
|
|
void AddEvent ( SystemEvent Event);
|
|
|
|
|
|
|
|
//Notification of changing conditions
|
|
|
|
void FunctionStarted ( DWORD NewFuncAddress, DWORD OldFuncAddress, DWORD ReturnAddress );
|
|
|
|
void FunctionEnded ( DWORD ReturnAddress, DWORD StackPos );
|
|
|
|
|
|
|
|
//Mark information saying that the CPU has stoped
|
|
|
|
void CpuStopped ( void );
|
|
|
|
void Pause ( void );
|
|
|
|
|
|
|
|
//Function in CMipsMemory_CallBack
|
|
|
|
virtual bool WriteToProtectedMemory (DWORD Address, int length);
|
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
//Functions in CTLB_CB
|
|
|
|
void TLB_Mapped ( DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly );
|
|
|
|
void TLB_Unmaped ( DWORD VAddr, DWORD Len );
|
|
|
|
void TLB_Changed ( void );
|
|
|
|
|
|
|
|
CPlugins * const m_Plugins; //The plugin container
|
|
|
|
CN64System * m_SyncCPU;
|
|
|
|
CMipsMemoryVM m_MMU_VM; //Memory of the n64
|
|
|
|
CTLB m_TLB;
|
|
|
|
CRegisters m_Reg;
|
|
|
|
CCheats m_Cheats;
|
|
|
|
CFramePerSecond m_FPS;
|
|
|
|
CProfiling m_CPU_Usage, m_Profile; //used to track the cpu usage
|
|
|
|
CRecompiler * m_Recomp;
|
|
|
|
CAudio m_Audio;
|
|
|
|
CSpeedLimitor m_Limitor;
|
|
|
|
bool m_InReset;
|
2010-05-23 10:05:41 +00:00
|
|
|
CSystemTimer m_SystemTimer;
|
2010-05-22 04:47:15 +00:00
|
|
|
SystemType m_SystemType;
|
|
|
|
bool m_bCleanFrameBox;
|
|
|
|
bool m_bInitilized;
|
2010-05-23 10:05:41 +00:00
|
|
|
int m_NextTimer;
|
2010-06-04 06:25:07 +00:00
|
|
|
bool m_DMAUsed;
|
2010-05-22 04:47:15 +00:00
|
|
|
|
|
|
|
//When Syncing cores this is the PC where it last Sync'ed correctly
|
|
|
|
DWORD m_LastSuccessSyncPC[10];
|
|
|
|
int m_CyclesToSkip;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
//List of Internal events that need to be acted on by CPU
|
|
|
|
EVENT_LIST m_EventList;
|
|
|
|
DWORD m_NoOfEvents;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
//Handle to the cpu thread
|
|
|
|
HANDLE m_CPU_Handle;
|
|
|
|
DWORD m_CPU_ThreadID;
|
|
|
|
|
|
|
|
//Handle to pause mutex
|
|
|
|
void * m_hPauseEvent;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
//No of Alist and Dlist sent to the RSP
|
|
|
|
DWORD m_AlistCount, m_DlistCount, m_UnknownCount;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
//list of function that have been called .. used in profiling
|
|
|
|
FUNC_CALLS m_FunctionCalls;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|