2010-06-04 06:25:07 +00:00
|
|
|
#include "stdafx.h"
|
2008-09-18 03:15:49 +00:00
|
|
|
#include "eeprom.h"
|
|
|
|
#include "mempak.h"
|
|
|
|
#include "Plugin.h"
|
|
|
|
#include "Logging.h"
|
|
|
|
#include "CPU Log.h"
|
|
|
|
#include "sram.h"
|
|
|
|
#include "flashram.h"
|
|
|
|
|
|
|
|
//settings
|
|
|
|
BOOL g_ShowUnhandledMemory = false, g_ShowCPUPer = false, g_ShowTLBMisses = false, g_UseTlb = true,
|
|
|
|
g_HaveDebugger = false, g_AudioSignal = false, g_ShowDListAListCount = false,
|
2010-05-25 09:15:19 +00:00
|
|
|
g_ShowPifRamErrors = false, g_GenerateLog = false, g_DelaySI = false,
|
2008-09-18 03:15:49 +00:00
|
|
|
g_DisableRegCaching = false, g_ShowCompMem = false, g_UseLinking = false,
|
|
|
|
g_FixedAudio = false, g_LogX86Code = false;
|
2008-12-04 10:41:51 +00:00
|
|
|
DWORD g_RomFileSize = 0, g_CountPerOp = 2, g_ViRefreshRate = 1500;
|
2008-09-18 03:15:49 +00:00
|
|
|
enum CPU_TYPE g_CPU_Type;
|
|
|
|
enum SAVE_CHIP_TYPE g_SaveUsing;
|
|
|
|
enum CICChip g_CicChip;
|
|
|
|
enum FUNC_LOOKUP_METHOD g_LookUpMode;
|
|
|
|
char g_RomName [300];
|
|
|
|
|
|
|
|
//Plugins
|
2010-05-22 04:47:15 +00:00
|
|
|
DWORD * _AudioIntrReg = NULL;
|
2008-09-18 03:15:49 +00:00
|
|
|
enum SystemType g_SystemType;
|
|
|
|
|
|
|
|
//Memory
|
2010-06-04 06:25:07 +00:00
|
|
|
DWORD g_RdramSize;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
BOOL g_IndvidualBlock, g_Profiling;
|
|
|
|
|
|
|
|
void CC_Core::SetSettings ( )
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_Settings)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
g_HaveDebugger = _Settings->LoadBool(Debugger_Enabled);
|
2008-09-18 03:15:49 +00:00
|
|
|
if (g_HaveDebugger)
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
g_ShowUnhandledMemory = _Settings->LoadBool(Debugger_ShowUnhandledMemory);
|
|
|
|
g_ShowDListAListCount = _Settings->LoadBool(Debugger_ShowDListAListCount);
|
2008-09-18 03:15:49 +00:00
|
|
|
} else {
|
|
|
|
g_ShowUnhandledMemory = false;
|
|
|
|
g_ShowUnhandledMemory = false;
|
|
|
|
|
|
|
|
}
|
2010-05-22 04:47:15 +00:00
|
|
|
g_ShowCPUPer = _Settings->LoadBool(UserInterface_ShowCPUPer);
|
2008-09-18 03:15:49 +00:00
|
|
|
g_ShowTLBMisses = false;
|
2010-05-22 04:47:15 +00:00
|
|
|
g_UseTlb = _Settings->LoadBool(Game_UseTlb);
|
|
|
|
g_CPU_Type = (CPU_TYPE)_Settings->LoadDword(Game_CpuType);
|
|
|
|
g_SaveUsing = (SAVE_CHIP_TYPE)_Settings->LoadDword(Game_SaveChip);
|
|
|
|
g_AudioSignal = _Settings->LoadBool(Game_RspAudioSignal);
|
|
|
|
g_RdramSize = _Settings->LoadDword(Game_RDRamSize);
|
|
|
|
g_ShowPifRamErrors = _Settings->LoadDword(Debugger_ShowPifErrors);
|
|
|
|
g_CountPerOp = _Settings->LoadDword(Game_CounterFactor);
|
|
|
|
g_GenerateLog = _Settings->LoadDword(Debugger_GenerateDebugLog);
|
|
|
|
g_DelaySI = _Settings->LoadBool(Game_DelaySI);
|
|
|
|
g_FixedAudio = _Settings->LoadBool(Game_FixedAudio);
|
|
|
|
g_LogX86Code = _Settings->LoadBool(Debugger_GenerateLogFiles);
|
|
|
|
g_LookUpMode = (FUNC_LOOKUP_METHOD)_Settings->LoadDword(Game_FuncLookupMode);
|
|
|
|
g_DisableRegCaching = !_Settings->LoadBool(Game_RegCache);
|
|
|
|
g_UseLinking = _Settings->LoadBool(Game_BlockLinking);
|
2008-09-18 03:15:49 +00:00
|
|
|
g_ShowCompMem = false;
|
2010-05-22 04:47:15 +00:00
|
|
|
g_ViRefreshRate = _Settings->LoadDword(Game_ViRefreshRate);
|
|
|
|
strcpy(g_RomName, _Settings->LoadString(Game_GameName).c_str());
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CC_Core::PauseExecution ( void )
|
|
|
|
{
|
2010-06-12 02:02:06 +00:00
|
|
|
_BaseSystem->Pause();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CC_Core::RunRsp ( void )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2010-06-12 02:02:06 +00:00
|
|
|
_System->RunRSP();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
char Message[600];
|
|
|
|
sprintf(Message,"Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__);
|
|
|
|
MessageBox(NULL,Message,"Exception",MB_OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CC_Core::GenerateProfileLog ( void )
|
|
|
|
{
|
2010-06-12 02:02:06 +00:00
|
|
|
_BaseSystem->m_Profile.GenerateLog();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CC_Core::ResetTimer ( void )
|
|
|
|
{
|
2010-06-12 02:02:06 +00:00
|
|
|
_System->m_Profile.ResetCounters();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD CC_Core::StartTimer ( DWORD Address )
|
|
|
|
{
|
2010-06-12 02:02:06 +00:00
|
|
|
return _System->m_Profile.StartTimer(Address);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD CC_Core::StopTimer ( void )
|
|
|
|
{
|
2010-06-12 02:02:06 +00:00
|
|
|
return _System->m_Profile.StopTimer();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PauseExecution ( void )
|
|
|
|
{
|
|
|
|
CC_Core::PauseExecution();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayError ( const char * Message, ... )
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_Notify == NULL) { return; }
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
va_list ap;
|
|
|
|
va_start( ap, Message );
|
2010-05-22 04:47:15 +00:00
|
|
|
_Notify->DisplayError(Message,ap);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayMessage ( int DisplayTime, const char * Message, ... )
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_Notify == NULL) { return; }
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
va_list ap;
|
|
|
|
va_start( ap, Message );
|
2010-05-22 04:47:15 +00:00
|
|
|
_Notify->DisplayMessage(DisplayTime, Message,ap);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayMessage2 ( const char * Message, ... )
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_Notify == NULL) { return; }
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
va_list ap;
|
|
|
|
va_start( ap, Message );
|
2010-05-22 04:47:15 +00:00
|
|
|
_Notify->DisplayMessage2(Message,ap);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char * GetAppName ( void )
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
static stdstr szAppName = _Settings->LoadString(Setting_ApplicationName);
|
2008-09-18 03:15:49 +00:00
|
|
|
return szAppName.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetAutoSaveDir( char * Directory )
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
strcpy(Directory,_Settings->LoadString(Directory_NativeSave).c_str());
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GetInstantSaveDir( char * Directory )
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
strcpy(Directory,_Settings->LoadString(Directory_InstantSave).c_str());
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetFpuLocations( void )
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
_Reg->FixFpuLocations();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL Limit_FPS ( void )
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
return _Settings->LoadDword(GameRunning_LimitFPS);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DacrateChanged ( enum SystemType Type )
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
_Plugins->Audio()->DacrateChanged(Type);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RunRsp( void )
|
|
|
|
{
|
|
|
|
CC_Core::RunRsp();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SyncSystem (void)
|
|
|
|
{
|
2010-06-12 02:02:06 +00:00
|
|
|
_BaseSystem->SyncCPU(_SyncSystem);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ApplyGSButtonCheats ( void )
|
|
|
|
{
|
2010-06-12 02:02:06 +00:00
|
|
|
CC_Core::ApplyGSButtonCheats(_BaseSystem);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChangePluginFunc ( void )
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
_Notify->DisplayMessage(0,MSG_PLUGIN_INIT);
|
|
|
|
if (_Settings->LoadBool(Plugin_GFX_Changed))
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
_Plugins->Reset(PLUGIN_TYPE_GFX);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_Settings->LoadBool(Plugin_AUDIO_Changed))
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
_Plugins->Reset(PLUGIN_TYPE_AUDIO);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_Settings->LoadBool(Plugin_CONT_Changed))
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
_Plugins->Reset(PLUGIN_TYPE_CONTROLLER);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_Settings->LoadBool(Plugin_RSP_Changed) ||
|
|
|
|
_Settings->LoadBool(Plugin_AUDIO_Changed) ||
|
|
|
|
_Settings->LoadBool(Plugin_GFX_Changed))
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
_Plugins->Reset(PLUGIN_TYPE_RSP);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2010-05-22 04:47:15 +00:00
|
|
|
_Settings->SaveBool(Plugin_RSP_Changed, false);
|
|
|
|
_Settings->SaveBool(Plugin_AUDIO_Changed,false);
|
|
|
|
_Settings->SaveBool(Plugin_GFX_Changed, false);
|
|
|
|
_Settings->SaveBool(Plugin_CONT_Changed, false);
|
|
|
|
_Notify->RefreshMenu();
|
|
|
|
if (!_Plugins->Initiate())
|
|
|
|
{
|
|
|
|
_Notify->DisplayMessage(5,MSG_PLUGIN_NOT_INIT);
|
2010-06-12 02:02:06 +00:00
|
|
|
_BaseSystem->m_EndEmulation = true;
|
2008-09-18 03:15:49 +00:00
|
|
|
} else {
|
2010-06-04 06:25:07 +00:00
|
|
|
//CC_Core::SetCurrentSystem(_N64System);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2010-05-22 04:47:15 +00:00
|
|
|
_Recompiler->ResetRecompCode();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChangeFullScreenFunc ( void )
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
_Notify->ChangeFullScreen();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL Machine_LoadState ( void )
|
|
|
|
{
|
2010-06-12 02:02:06 +00:00
|
|
|
bool Result = CC_Core::LoadState(_System);
|
2010-06-04 06:25:07 +00:00
|
|
|
//CC_Core::SetCurrentSystem(_N64System);
|
2008-09-18 03:15:49 +00:00
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetTimer ( void )
|
|
|
|
{
|
|
|
|
CC_Core::ResetTimer();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GenerateProfileLog ( void )
|
|
|
|
{
|
|
|
|
CC_Core::GenerateProfileLog();
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD StartTimer ( DWORD Address )
|
|
|
|
{
|
|
|
|
return CC_Core::StartTimer(Address);
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD StopTimer ( void )
|
|
|
|
{
|
|
|
|
return CC_Core::StopTimer();
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL Machine_SaveState ( void )
|
|
|
|
{
|
2010-06-12 02:02:06 +00:00
|
|
|
return CC_Core::SaveState(_BaseSystem);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BreakPoint(LPCSTR FileName, int LineNumber )
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_Notify)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
_Notify->BreakPoint(FileName,LineNumber);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CC_Core::ApplyGSButtonCheats (CN64System * System)
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
if (System == NULL)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2010-05-22 04:47:15 +00:00
|
|
|
if (System->m_Cheats.CheatsSlectionChanged())
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
System->m_Cheats.LoadCheats(false);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2010-05-22 04:47:15 +00:00
|
|
|
System->m_Cheats.ApplyGSButton(_MMU);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CC_Core::ApplyCheats (CN64System * System)
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
if (System == NULL)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2010-05-22 04:47:15 +00:00
|
|
|
if (System->m_Cheats.CheatsSlectionChanged())
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
System->m_Cheats.LoadCheats(false);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2010-05-22 04:47:15 +00:00
|
|
|
System->m_Cheats.ApplyCheats(_MMU);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ApplyCheats (void)
|
|
|
|
{
|
2010-06-12 02:02:06 +00:00
|
|
|
CC_Core::ApplyCheats(_BaseSystem);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResetX86Logs ( void )
|
|
|
|
{
|
|
|
|
if (g_LogX86Code)
|
|
|
|
{
|
|
|
|
Stop_x86_Log();
|
|
|
|
Start_x86_Log();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CloseSaveChips ( void )
|
|
|
|
{
|
|
|
|
CloseEeprom();
|
|
|
|
CloseMempak();
|
|
|
|
CloseSram();
|
|
|
|
CloseFlashRam();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SyncToPC (void) {
|
2010-05-31 00:21:08 +00:00
|
|
|
//FixRandomReg();
|
2008-09-18 03:15:49 +00:00
|
|
|
SyncSystem ();
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL ClearRecompCodeProtectMem ( DWORD Address, int length )
|
|
|
|
{
|
2010-05-30 01:54:42 +00:00
|
|
|
_Notify->BreakPoint(__FILE__,__LINE__);
|
|
|
|
#ifdef tofix
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_Recompiler)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
return _Recompiler->ClearRecompCode_Phys(Address,length,CRecompiler::Remove_ProtectedMem);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2010-05-30 01:54:42 +00:00
|
|
|
#endif
|
2008-09-18 03:15:49 +00:00
|
|
|
return false;
|
|
|
|
}
|