Resolve merge conflicts from `Controller Plugin.cpp`.

This commit is contained in:
unknown 2015-11-16 21:01:54 -05:00
commit dc65c0a075
290 changed files with 14405 additions and 14289 deletions

8
.gitignore vendored
View File

@ -4,6 +4,14 @@
*.sdf *.sdf
*.suo *.suo
*.user *.user
# compiler-generated sources (MSVC, GCC)
*.asm
*.s
# assembled linker objects (GCC)
*.o
Thumbs.db Thumbs.db
/Bin/Debug /Bin/Debug
/Bin/Debug64 /Bin/Debug64

BIN
Artwork/publisherlogo.psd Normal file

Binary file not shown.

View File

@ -88,6 +88,7 @@
#198# "插槽 8" #198# "插槽 8"
#199# "插槽 9" #199# "插槽 9"
#200# "插槽 10" #200# "插槽 10"
#201# "插槽 (%ws) 被选"
//Pop up Menu //Pop up Menu
#210# "运行游戏" #210# "运行游戏"
@ -224,7 +225,7 @@
#452# " 选择材质包目录" #452# " 选择材质包目录"
//Options Dialog //Options Dialog
#460# "当窗口处于非活动状态时暂停模拟器" #460# "当模拟器窗口不是处于屏幕最上方,暂停模拟器"
#461# "载入ROM后切换为全屏模式" #461# "载入ROM后切换为全屏模式"
#462# "隐藏高级设置" #462# "隐藏高级设置"
#463# "记住已选择的金手指" #463# "记住已选择的金手指"
@ -255,7 +256,7 @@
#503# "自我修改码方案:" #503# "自我修改码方案:"
#504# "默认存档容量:" #504# "默认存档容量:"
#505# "高级模块连接" #505# "高级模块连接"
#506# "当ROM加载后,开始模拟" #506# "当读取完ROM后开始模拟"
#507# "总是从 RDB 中覆盖默认设置" #507# "总是从 RDB 中覆盖默认设置"
#508# "自动压缩即时存档文件" #508# "自动压缩即时存档文件"
#509# "开启调试器" #509# "开启调试器"

View File

@ -88,6 +88,7 @@
#198# "Slot 8" #198# "Slot 8"
#199# "Slot 9" #199# "Slot 9"
#200# "Slot 10" #200# "Slot 10"
#201# "Save Slot (%ws) selected"
//Pop up Menu //Pop up Menu
#210# "Play Game" #210# "Play Game"

Binary file not shown.

View File

@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Configuration"> <PropertyGroup Label="Configuration">
<PlatformToolset>v140_xp</PlatformToolset> <PlatformToolset>$(DefaultPlatformToolset)_xp</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<ImportGroup Label="PropertySheets"> <ImportGroup Label="PropertySheets">

View File

@ -79,16 +79,11 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags)
sa.bInheritHandle = (nOpenFlags & modeNoInherit) == 0; sa.bInheritHandle = (nOpenFlags & modeNoInherit) == 0;
// map creation flags // map creation flags
ULONG dwCreateFlag = 0; ULONG dwCreateFlag = OPEN_EXISTING;
if (nOpenFlags & modeCreate) if (nOpenFlags & modeCreate)
{ {
if (nOpenFlags & modeNoTruncate) dwCreateFlag = ((nOpenFlags & modeNoTruncate) != 0) ? OPEN_ALWAYS : CREATE_ALWAYS;
dwCreateFlag = OPEN_ALWAYS;
else
dwCreateFlag = CREATE_ALWAYS;
} }
else
dwCreateFlag = OPEN_EXISTING;
// attempt file creation // attempt file creation
HANDLE hFile = ::CreateFile(lpszFileName, dwAccess, dwShareMode, &sa, dwCreateFlag, FILE_ATTRIBUTE_NORMAL, NULL); HANDLE hFile = ::CreateFile(lpszFileName, dwAccess, dwShareMode, &sa, dwCreateFlag, FILE_ATTRIBUTE_NORMAL, NULL);
@ -140,19 +135,15 @@ bool CFile::Flush()
return ::FlushFileBuffers(m_hFile) != 0; return ::FlushFileBuffers(m_hFile) != 0;
} }
bool CFile::Write(const void* lpBuf, size_t nCount) bool CFile::Write(const void* lpBuf, uint32_t nCount)
{ {
if (nCount == 0) if (nCount == 0)
{ {
return true; // avoid Win32 "null-write" option return true; // avoid Win32 "null-write" option
} }
if (nCount > ULONG_MAX)
{
nCount = ULONG_MAX; /* Or should we loop WriteFile() every 2 GB? */
}
DWORD nWritten = 0; ULONG nWritten = 0;
if (!::WriteFile(m_hFile, lpBuf, (DWORD)nCount, &nWritten, NULL)) if (!::WriteFile(m_hFile, lpBuf, nCount, &nWritten, NULL))
{ {
return false; return false;
} }
@ -165,23 +156,19 @@ bool CFile::Write(const void* lpBuf, size_t nCount)
return true; return true;
} }
size_t CFile::Read(void* lpBuf, size_t nCount) uint32_t CFile::Read(void* lpBuf, uint32_t nCount)
{ {
if (nCount == 0) if (nCount == 0)
{ {
return 0; // avoid Win32 "null-read" return 0; // avoid Win32 "null-read"
} }
if (nCount > ULONG_MAX)
{
nCount = ULONG_MAX; /* Or should we loop ReadFile() every 2 GB? */
}
DWORD dwRead = 0; DWORD dwRead = 0;
if (!::ReadFile(m_hFile, lpBuf, (DWORD)nCount, &dwRead, NULL)) if (!::ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL))
{ {
return 0; return 0;
} }
return (dwRead); return (uint32_t)dwRead;
} }
long CFile::Seek(long lOff, SeekPosition nFrom) long CFile::Seek(long lOff, SeekPosition nFrom)

View File

@ -40,8 +40,8 @@ public:
virtual bool SetLength(uint32_t dwNewLen) = 0; virtual bool SetLength(uint32_t dwNewLen) = 0;
virtual uint32_t GetLength() const = 0; virtual uint32_t GetLength() const = 0;
virtual size_t Read(void* lpBuf, size_t nCount) = 0; virtual uint32_t Read(void* lpBuf, uint32_t nCount) = 0;
virtual bool Write(const void* lpBuf, size_t nCount) = 0; virtual bool Write(const void* lpBuf, uint32_t nCount) = 0;
virtual bool Flush() = 0; virtual bool Flush() = 0;
virtual bool Close() = 0; virtual bool Close() = 0;
@ -78,8 +78,8 @@ public:
virtual bool SetLength(uint32_t dwNewLen); virtual bool SetLength(uint32_t dwNewLen);
virtual uint32_t GetLength() const; virtual uint32_t GetLength() const;
virtual size_t Read(void* lpBuf, size_t nCount); virtual uint32_t Read(void* lpBuf, uint32_t nCount);
virtual bool Write(const void* lpBuf, size_t nCount); virtual bool Write(const void* lpBuf, uint32_t nCount);
virtual bool Flush(); virtual bool Flush();
virtual bool Close(); virtual bool Close();

View File

@ -120,7 +120,7 @@ void CLog::LogArgs(const char * Message, va_list & args )
void CLog::Log( const char * Message ) void CLog::Log( const char * Message )
{ {
if (!m_hLogFile.IsOpen()) { return; } if (!m_hLogFile.IsOpen()) { return; }
m_hLogFile.Write(Message, strlen(Message)*sizeof(TCHAR)); m_hLogFile.Write(Message,(uint32_t)strlen(Message)*sizeof(TCHAR));
if (m_FlushOnWrite) if (m_FlushOnWrite)
{ {
m_hLogFile.Flush(); m_hLogFile.Flush();
@ -145,11 +145,11 @@ void CLog::Log( const char * Message )
m_hLogFile.Seek((end - m_MaxFileSize) + m_FileChangeSize,CFile::begin); m_hLogFile.Seek((end - m_MaxFileSize) + m_FileChangeSize,CFile::begin);
// Find next end of line // Find next end of line
size_t NextEnter = 0, dwRead = 0; uint32_t NextEnter = 0, dwRead = 0;
do do
{ {
BYTE Data[300]; BYTE Data[300];
size_t dwRead; uint32_t dwRead;
dwRead = m_hLogFile.Read(Data,sizeof(Data)); dwRead = m_hLogFile.Read(Data,sizeof(Data));
if (dwRead == 0) if (dwRead == 0)
@ -170,9 +170,8 @@ void CLog::Log( const char * Message )
} while(dwRead != 0); } while(dwRead != 0);
// copy content of log to the new file // copy content of log to the new file
size_t ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter; uint32_t ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter;
uint32_t WritePos = 0; uint32_t SizeToRead, WritePos = 0;
size_t SizeToRead;
do do
{ {
enum { fIS_MvSize = 0x5000 }; enum { fIS_MvSize = 0x5000 };
@ -183,7 +182,7 @@ void CLog::Log( const char * Message )
m_hLogFile.Seek(ReadPos,CFile::begin); m_hLogFile.Seek(ReadPos,CFile::begin);
size_t dwRead; uint32_t dwRead;
dwRead = m_hLogFile.Read(Data,SizeToRead); dwRead = m_hLogFile.Read(Data,SizeToRead);
m_hLogFile.Seek(WritePos,CFile::begin); m_hLogFile.Seek(WritePos,CFile::begin);

View File

@ -15,8 +15,8 @@ class CLog
bool m_FlushOnWrite; bool m_FlushOnWrite;
stdstr m_FileName; stdstr m_FileName;
bool m_TruncateFileLog; bool m_TruncateFileLog;
size_t m_MaxFileSize; uint32_t m_MaxFileSize;
size_t m_FileChangeSize; uint32_t m_FileChangeSize;
public: public:
CLog ( void ); CLog ( void );
@ -29,10 +29,10 @@ public:
bool Empty ( void ); bool Empty ( void );
void Close ( void ); void Close ( void );
inline void SetMaxFileSize(size_t Size) inline void SetMaxFileSize ( uint32_t Size )
{ {
m_MaxFileSize = Size; m_MaxFileSize = Size;
m_FileChangeSize = (size_t)(Size * 0.1); m_FileChangeSize = (uint32_t)(Size * 0.1);
} }
inline void SetTruncateFile( bool Truncate ) { m_TruncateFileLog = Truncate; } inline void SetTruncateFile( bool Truncate ) { m_TruncateFileLog = Truncate; }
inline void SetFlush ( bool Always ) { m_FlushOnWrite = Always; } inline void SetFlush ( bool Always ) { m_FlushOnWrite = Always; }

View File

@ -51,5 +51,22 @@ public:
} }
}; };
class stdwstr_f : public std::wstring
{
public:
stdwstr_f(const wchar_t * strFormat, ...)
{
va_list args;
va_start(args, strFormat);
wchar_t Msg[1000];
_vsnwprintf(Msg, sizeof(Msg) - 1, strFormat, args);
va_end(args);
this->assign(Msg);
}
};
typedef std::list<stdstr> strlist; typedef std::list<stdstr> strlist;
typedef strlist::iterator strlist_iter; typedef strlist::iterator strlist_iter;

View File

@ -0,0 +1,139 @@
#include "stdafx.h"
#include <Common\Util.h>
void FixDirectories(void);
void FixLocale(void);
static void IncreaseThreadPriority(void);
static CTraceFileLog * g_LogFile = NULL;
void LogLevelChanged(CTraceFileLog * LogFile)
{
LogFile->SetTraceLevel((TraceLevel)g_Settings->LoadDword(Debugger_AppLogLevel));
}
void LogFlushChanged(CTraceFileLog * LogFile)
{
LogFile->SetFlushFile(g_Settings->LoadDword(Debugger_AppLogFlush) != 0);
}
void InitializeLog(void)
{
CPath LogFilePath(CPath::MODULE_DIRECTORY);
LogFilePath.AppendDirectory("Logs");
if (!LogFilePath.DirectoryExists())
{
LogFilePath.DirectoryCreate();
}
LogFilePath.SetNameExtension("Project64.log");
g_LogFile = new CTraceFileLog(LogFilePath, g_Settings->LoadDword(Debugger_AppLogFlush) != 0, Log_New, 500);
#ifdef VALIDATE_DEBUG
g_LogFile->SetTraceLevel((TraceLevel)(g_Settings->LoadDword(Debugger_AppLogLevel) | TraceValidate | TraceDebug));
#else
g_LogFile->SetTraceLevel((TraceLevel)g_Settings->LoadDword(Debugger_AppLogLevel));
#endif
AddTraceModule(g_LogFile);
g_Settings->RegisterChangeCB(Debugger_AppLogLevel, g_LogFile, (CSettings::SettingChangedFunc)LogLevelChanged);
g_Settings->RegisterChangeCB(Debugger_AppLogFlush, g_LogFile, (CSettings::SettingChangedFunc)LogFlushChanged);
}
void AppInit(CNotification * Notify)
{
try
{
g_Notify = Notify;
FixDirectories();
FixLocale();
stdstr_f AppName("Project64 %s", VER_FILE_VERSION_STR);
IncreaseThreadPriority();
g_Settings = new CSettings;
g_Settings->Initialize(AppName.c_str());
if (g_Settings->LoadBool(Setting_CheckEmuRunning) &&
pjutil::TerminatedExistingExe())
{
delete g_Settings;
g_Settings = new CSettings;
g_Settings->Initialize(AppName.c_str());
}
InitializeLog();
WriteTrace(TraceDebug, __FUNCTION__ ": Application Starting");
CMipsMemoryVM::ReserveMemory();
//Create the plugin container
WriteTrace(TraceDebug, __FUNCTION__ ": Create Plugins");
g_Plugins = new CPlugins(g_Settings->LoadStringVal(Directory_Plugin));
g_Lang = new CLanguage();
g_Lang->LoadCurrentStrings();
g_Notify->AppInitDone();
}
catch (...)
{
g_Notify->DisplayError(stdstr_f("Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__).ToUTF16().c_str());
}
}
void AppCleanup(void)
{
g_Settings->UnregisterChangeCB(Debugger_AppLogLevel, g_LogFile, (CSettings::SettingChangedFunc)LogLevelChanged);
g_Settings->UnregisterChangeCB(Debugger_AppLogFlush, g_LogFile, (CSettings::SettingChangedFunc)LogFlushChanged);
WriteTrace(TraceDebug, __FUNCTION__ ": cleaning up global objects");
if (g_Rom) { delete g_Rom; g_Rom = NULL; }
if (g_Plugins) { delete g_Plugins; g_Plugins = NULL; }
if (g_Settings) { delete g_Settings; g_Settings = NULL; }
if (g_Lang) { delete g_Lang; g_Lang = NULL; }
CMipsMemoryVM::FreeReservedMemory();
WriteTrace(TraceDebug, __FUNCTION__ ": Done");
CloseTrace();
}
void FixDirectories(void)
{
CPath Directory(CPath::MODULE_DIRECTORY);
Directory.AppendDirectory("Config");
if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
Directory.UpDirectory();
Directory.AppendDirectory("Logs");
if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
Directory.UpDirectory();
Directory.AppendDirectory("Save");
if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
Directory.UpDirectory();
Directory.AppendDirectory("Screenshots");
if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
Directory.UpDirectory();
Directory.AppendDirectory("textures");
if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
}
#include <windows.h>
void FixLocale(void)
{
char *lbuffer = new char[10];
if (GetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVLANGNAME, lbuffer, 10))
{
setlocale(LC_ALL, lbuffer);
}
delete[] lbuffer;
}
void IncreaseThreadPriority(void)
{
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
}

View File

@ -0,0 +1,6 @@
#pragma once
#include <Project64\User Interface\Notification Class.h>
void AppInit(CNotification * Notify);
void AppCleanup(void);

View File

@ -1 +1,16 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once #pragma once
__interface CDebugger
{
virtual void TLBChanged(void) = 0;
};

View File

@ -1,919 +0,0 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#include "stdafx.h"
#include <prsht.h>
void LoadLogSetting (HKEY hKey,char * String, bool * Value);
void SaveLogOptions (void);
LRESULT CALLBACK LogGeneralProc ( HWND, UINT, WPARAM, LPARAM );
LRESULT CALLBACK LogPifProc ( HWND, UINT, WPARAM, LPARAM );
LRESULT CALLBACK LogRegProc ( HWND, UINT, WPARAM, LPARAM );
static HANDLE g_hLogFile = NULL;
LOG_OPTIONS g_LogOptions, TempOptions;
void EnterLogOptions(HWND hwndOwner)
{
PROPSHEETPAGE psp[3];
PROPSHEETHEADER psh;
psp[0].dwSize = sizeof(PROPSHEETPAGE);
psp[0].dwFlags = PSP_USETITLE;
psp[0].hInstance = GetModuleHandle(NULL);
psp[0].pszTemplate = MAKEINTRESOURCE(IDD_Logging_Registers);
psp[0].pfnDlgProc = (DLGPROC)LogRegProc;
psp[0].pszTitle = "Registers";
psp[0].lParam = 0;
psp[0].pfnCallback = NULL;
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_USETITLE;
psp[1].hInstance = GetModuleHandle(NULL);
psp[1].pszTemplate = MAKEINTRESOURCE(IDD_Logging_PifRam);
psp[1].pfnDlgProc = (DLGPROC)LogPifProc;
psp[1].pszTitle = "Pif Ram";
psp[1].lParam = 0;
psp[1].pfnCallback = NULL;
psp[2].dwSize = sizeof(PROPSHEETPAGE);
psp[2].dwFlags = PSP_USETITLE;
psp[2].hInstance = GetModuleHandle(NULL);
psp[2].pszTemplate = MAKEINTRESOURCE(IDD_Logging_General);
psp[2].pfnDlgProc = (DLGPROC)LogGeneralProc;
psp[2].pszTitle = "General";
psp[2].lParam = 0;
psp[2].pfnCallback = NULL;
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
psh.hwndParent = hwndOwner;
psh.hInstance = GetModuleHandle(NULL);
psh.pszCaption = (LPSTR) "Log Options";
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
psh.nStartPage = 0;
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
psh.pfnCallback = NULL;
LoadLogOptions(&TempOptions,TRUE);
#if defined(WINDOWS_UI)
PropertySheet(&psh);
#else
g_Notify -> BreakPoint(__FILEW__, __LINE__);
#endif
SaveLogOptions();
LoadLogOptions(&g_LogOptions, FALSE);
return;
}
void LoadLogOptions (LOG_OPTIONS * LogOptions, bool AlwaysFill)
{
int32_t lResult;
HKEY hKeyResults = 0;
char String[200];
sprintf(String,"Software\\N64 Emulation\\%s\\Logging",g_Settings->LoadStringVal(Setting_ApplicationName).c_str());
lResult = RegOpenKeyEx( HKEY_CURRENT_USER,String,0,KEY_ALL_ACCESS,
&hKeyResults);
if (lResult == ERROR_SUCCESS)
{
//LoadLogSetting(hKeyResults,"Generate Log File",&LogOptions->GenerateLog);
if (LogOptions->GenerateLog || AlwaysFill)
{
LoadLogSetting(hKeyResults,"Log RDRAM",&LogOptions->LogRDRamRegisters);
LoadLogSetting(hKeyResults,"Log SP",&LogOptions->LogSPRegisters);
LoadLogSetting(hKeyResults,"Log DP Command",&LogOptions->LogDPCRegisters);
LoadLogSetting(hKeyResults,"Log DP Span",&LogOptions->LogDPSRegisters);
LoadLogSetting(hKeyResults,"Log MIPS Interface (MI)",&LogOptions->LogMIPSInterface);
LoadLogSetting(hKeyResults,"Log Video Interface (VI)",&LogOptions->LogVideoInterface);
LoadLogSetting(hKeyResults,"Log Audio Interface (AI)",&LogOptions->LogAudioInterface);
LoadLogSetting(hKeyResults,"Log Peripheral Interface (PI)",&LogOptions->LogPerInterface);
LoadLogSetting(hKeyResults,"Log RDRAM Interface (RI)",&LogOptions->LogRDRAMInterface);
LoadLogSetting(hKeyResults,"Log Serial Interface (SI)",&LogOptions->LogSerialInterface);
LoadLogSetting(hKeyResults,"Log PifRam DMA Operations",&LogOptions->LogPRDMAOperations);
LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Loads",&LogOptions->LogPRDirectMemLoads);
LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Loads",&LogOptions->LogPRDMAMemLoads);
LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Stores",&LogOptions->LogPRDirectMemStores);
LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Stores",&LogOptions->LogPRDMAMemStores);
LoadLogSetting(hKeyResults,"Log Controller Pak",&LogOptions->LogControllerPak);
LoadLogSetting(hKeyResults,"Log CP0 changes",&LogOptions->LogCP0changes);
LoadLogSetting(hKeyResults,"Log CP0 reads",&LogOptions->LogCP0reads);
LoadLogSetting(hKeyResults,"Log Exceptions",&LogOptions->LogExceptions);
LoadLogSetting(hKeyResults,"No Interrupts",&LogOptions->NoInterrupts);
LoadLogSetting(hKeyResults,"Log TLB",&LogOptions->LogTLB);
LoadLogSetting(hKeyResults,"Log Cache Operations",&LogOptions->LogCache);
LoadLogSetting(hKeyResults,"Log Rom Header",&LogOptions->LogRomHeader);
LoadLogSetting(hKeyResults,"Log Unknown access",&LogOptions->LogUnknown);
return;
}
}
LogOptions->GenerateLog = FALSE;
LogOptions->LogRDRamRegisters = FALSE;
LogOptions->LogSPRegisters = FALSE;
LogOptions->LogDPCRegisters = FALSE;
LogOptions->LogDPSRegisters = FALSE;
LogOptions->LogMIPSInterface = FALSE;
LogOptions->LogVideoInterface = FALSE;
LogOptions->LogAudioInterface = FALSE;
LogOptions->LogPerInterface = FALSE;
LogOptions->LogRDRAMInterface = FALSE;
LogOptions->LogSerialInterface = FALSE;
LogOptions->LogPRDMAOperations = FALSE;
LogOptions->LogPRDirectMemLoads = FALSE;
LogOptions->LogPRDMAMemLoads = FALSE;
LogOptions->LogPRDirectMemStores = FALSE;
LogOptions->LogPRDMAMemStores = FALSE;
LogOptions->LogControllerPak = FALSE;
LogOptions->LogCP0changes = FALSE;
LogOptions->LogCP0reads = FALSE;
LogOptions->LogCache = FALSE;
LogOptions->LogExceptions = FALSE;
LogOptions->NoInterrupts = FALSE;
LogOptions->LogTLB = FALSE;
LogOptions->LogRomHeader = FALSE;
LogOptions->LogUnknown = FALSE;
}
void LoadLogSetting (HKEY hKey,char * String, bool * Value)
{
DWORD Type, dwResult, Bytes = 4;
int32_t lResult;
lResult = RegQueryValueEx(hKey,String,0,&Type,(LPBYTE)(&dwResult),&Bytes);
if (Type == REG_DWORD && lResult == ERROR_SUCCESS)
{
*Value = dwResult != 0;
}
else
{
*Value = FALSE;
}
}
LRESULT CALLBACK LogGeneralProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
if (TempOptions.LogCP0changes) { CheckDlgButton(hDlg,IDC_CP0_WRITE,BST_CHECKED); }
if (TempOptions.LogCP0reads) { CheckDlgButton(hDlg,IDC_CP0_READ,BST_CHECKED); }
if (TempOptions.LogCache) { CheckDlgButton(hDlg,IDC_CACHE,BST_CHECKED); }
if (TempOptions.LogExceptions) { CheckDlgButton(hDlg,IDC_EXCEPTIONS,BST_CHECKED); }
if (TempOptions.NoInterrupts) { CheckDlgButton(hDlg,IDC_INTERRUPTS,BST_CHECKED); }
if (TempOptions.LogTLB) { CheckDlgButton(hDlg,IDC_TLB,BST_CHECKED); }
if (TempOptions.LogRomHeader) { CheckDlgButton(hDlg,IDC_ROM_HEADER,BST_CHECKED); }
if (TempOptions.LogUnknown) { CheckDlgButton(hDlg,IDC_UNKOWN,BST_CHECKED); }
break;
case WM_NOTIFY:
if (((NMHDR FAR *) lParam)->code != PSN_APPLY) { break; }
TempOptions.LogCP0changes = IsDlgButtonChecked(hDlg,IDC_CP0_WRITE) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogCP0reads = IsDlgButtonChecked(hDlg,IDC_CP0_READ) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogCache = IsDlgButtonChecked(hDlg,IDC_CACHE) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogExceptions = IsDlgButtonChecked(hDlg,IDC_EXCEPTIONS) == BST_CHECKED?TRUE:FALSE;
TempOptions.NoInterrupts = IsDlgButtonChecked(hDlg,IDC_INTERRUPTS) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogTLB = IsDlgButtonChecked(hDlg,IDC_TLB) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogRomHeader = IsDlgButtonChecked(hDlg,IDC_ROM_HEADER) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogUnknown = IsDlgButtonChecked(hDlg,IDC_UNKOWN) == BST_CHECKED?TRUE:FALSE;
break;
default:
return FALSE;
}
return TRUE;
}
void Log_LW (uint32_t PC, uint32_t VAddr)
{
if (!g_LogOptions.GenerateLog)
{
return;
}
if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 )
{
uint32_t PAddr;
if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr))
{
if (g_LogOptions.LogUnknown)
{
LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr);
}
return;
}
VAddr = PAddr + 0xA0000000;
}
uint32_t Value;
if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize()))
{
return;
}
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024)
{
if (!g_LogOptions.LogRDRamRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA3F00000: LogMessage("%08X: read from RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG (%08X)",PC, Value); return;
case 0xA3F00004: LogMessage("%08X: read from RDRAM_DEVICE_ID_REG (%08X)",PC, Value); return;
case 0xA3F00008: LogMessage("%08X: read from RDRAM_DELAY_REG (%08X)",PC, Value); return;
case 0xA3F0000C: LogMessage("%08X: read from RDRAM_MODE_REG (%08X)",PC, Value); return;
case 0xA3F00010: LogMessage("%08X: read from RDRAM_REF_INTERVAL_REG (%08X)",PC, Value); return;
case 0xA3F00014: LogMessage("%08X: read from RDRAM_REF_ROW_REG (%08X)",PC, Value); return;
case 0xA3F00018: LogMessage("%08X: read from RDRAM_RAS_INTERVAL_REG (%08X)",PC, Value); return;
case 0xA3F0001C: LogMessage("%08X: read from RDRAM_MIN_INTERVAL_REG (%08X)",PC, Value); return;
case 0xA3F00020: LogMessage("%08X: read from RDRAM_ADDR_SELECT_REG (%08X)",PC, Value); return;
case 0xA3F00024: LogMessage("%08X: read from RDRAM_DEVICE_MANUF_REG (%08X)",PC, Value); return;
}
}
if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC )
{
return;
}
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C )
{
if (!g_LogOptions.LogSPRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4040000: LogMessage("%08X: read from SP_MEM_ADDR_REG (%08X)",PC, Value); break;
case 0xA4040004: LogMessage("%08X: read from SP_DRAM_ADDR_REG (%08X)",PC, Value); break;
case 0xA4040008: LogMessage("%08X: read from SP_RD_LEN_REG (%08X)",PC, Value); break;
case 0xA404000C: LogMessage("%08X: read from SP_WR_LEN_REG (%08X)",PC, Value); break;
case 0xA4040010: LogMessage("%08X: read from SP_STATUS_REG (%08X)",PC, Value); break;
case 0xA4040014: LogMessage("%08X: read from SP_DMA_FULL_REG (%08X)",PC, Value); break;
case 0xA4040018: LogMessage("%08X: read from SP_DMA_BUSY_REG (%08X)",PC, Value); break;
case 0xA404001C: LogMessage("%08X: read from SP_SEMAPHORE_REG (%08X)",PC, Value); break;
}
return;
}
if ( VAddr == 0xA4080000)
{
if (!g_LogOptions.LogSPRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SP_PC (%08X)",PC, Value);
return;
}
if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C)
{
if (!g_LogOptions.LogDPCRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)",PC, Value); return;
case 0xA4100004: LogMessage("%08X: read from DPC_END_REG (%08X)",PC, Value); return;
case 0xA4100008: LogMessage("%08X: read from DPC_CURRENT_REG (%08X)",PC, Value); return;
case 0xA410000C: LogMessage("%08X: read from DPC_STATUS_REG (%08X)",PC, Value); return;
case 0xA4100010: LogMessage("%08X: read from DPC_CLOCK_REG (%08X)",PC, Value); return;
case 0xA4100014: LogMessage("%08X: read from DPC_BUFBUSY_REG (%08X)",PC, Value); return;
case 0xA4100018: LogMessage("%08X: read from DPC_PIPEBUSY_REG (%08X)",PC, Value); return;
case 0xA410001C: LogMessage("%08X: read from DPC_TMEM_REG (%08X)",PC, Value); return;
}
}
if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C)
{
if (!g_LogOptions.LogMIPSInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4300000: LogMessage("%08X: read from MI_INIT_MODE_REG/MI_MODE_REG (%08X)",PC, Value); return;
case 0xA4300004: LogMessage("%08X: read from MI_VERSION_REG/MI_NOOP_REG (%08X)",PC, Value); return;
case 0xA4300008: LogMessage("%08X: read from MI_INTR_REG (%08X)",PC, Value); return;
case 0xA430000C: LogMessage("%08X: read from MI_INTR_MASK_REG (%08X)",PC, Value); return;
}
}
if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034)
{
if (!g_LogOptions.LogVideoInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4400000: LogMessage("%08X: read from VI_STATUS_REG/VI_CONTROL_REG (%08X)",PC, Value); return;
case 0xA4400004: LogMessage("%08X: read from VI_ORIGIN_REG/VI_DRAM_ADDR_REG (%08X)",PC, Value); return;
case 0xA4400008: LogMessage("%08X: read from VI_WIDTH_REG/VI_H_WIDTH_REG (%08X)",PC, Value); return;
case 0xA440000C: LogMessage("%08X: read from VI_INTR_REG/VI_V_INTR_REG (%08X)",PC, Value); return;
case 0xA4400010: LogMessage("%08X: read from VI_CURRENT_REG/VI_V_CURRENT_LINE_REG (%08X)",PC, Value); return;
case 0xA4400014: LogMessage("%08X: read from VI_BURST_REG/VI_TIMING_REG (%08X)",PC, Value); return;
case 0xA4400018: LogMessage("%08X: read from VI_V_SYNC_REG (%08X)",PC, Value); return;
case 0xA440001C: LogMessage("%08X: read from VI_H_SYNC_REG (%08X)",PC, Value); return;
case 0xA4400020: LogMessage("%08X: read from VI_LEAP_REG/VI_H_SYNC_LEAP_REG (%08X)",PC, Value); return;
case 0xA4400024: LogMessage("%08X: read from VI_H_START_REG/VI_H_VIDEO_REG (%08X)",PC, Value); return;
case 0xA4400028: LogMessage("%08X: read from VI_V_START_REG/VI_V_VIDEO_REG (%08X)",PC, Value); return;
case 0xA440002C: LogMessage("%08X: read from VI_V_BURST_REG (%08X)",PC, Value); return;
case 0xA4400030: LogMessage("%08X: read from VI_X_SCALE_REG (%08X)",PC, Value); return;
case 0xA4400034: LogMessage("%08X: read from VI_Y_SCALE_REG (%08X)",PC, Value); return;
}
}
if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014)
{
if (!g_LogOptions.LogAudioInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4500000: LogMessage("%08X: read from AI_DRAM_ADDR_REG (%08X)",PC, Value); return;
case 0xA4500004: LogMessage("%08X: read from AI_LEN_REG (%08X)",PC, Value); return;
case 0xA4500008: LogMessage("%08X: read from AI_CONTROL_REG (%08X)",PC, Value); return;
case 0xA450000C: LogMessage("%08X: read from AI_STATUS_REG (%08X)",PC, Value); return;
case 0xA4500010: LogMessage("%08X: read from AI_DACRATE_REG (%08X)",PC, Value); return;
case 0xA4500014: LogMessage("%08X: read from AI_BITRATE_REG (%08X)",PC, Value); return;
}
}
if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030)
{
if (!g_LogOptions.LogPerInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4600000: LogMessage("%08X: read from PI_DRAM_ADDR_REG (%08X)",PC, Value); return;
case 0xA4600004: LogMessage("%08X: read from PI_CART_ADDR_REG (%08X)",PC, Value); return;
case 0xA4600008: LogMessage("%08X: read from PI_RD_LEN_REG (%08X)",PC, Value); return;
case 0xA460000C: LogMessage("%08X: read from PI_WR_LEN_REG (%08X)",PC, Value); return;
case 0xA4600010: LogMessage("%08X: read from PI_STATUS_REG (%08X)",PC, Value); return;
case 0xA4600014: LogMessage("%08X: read from PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG (%08X)",PC, Value); return;
case 0xA4600018: LogMessage("%08X: read from PI_BSD_DOM1_PWD_REG (%08X)",PC, Value); return;
case 0xA460001C: LogMessage("%08X: read from PI_BSD_DOM1_PGS_REG (%08X)",PC, Value); return;
case 0xA4600020: LogMessage("%08X: read from PI_BSD_DOM1_RLS_REG (%08X)",PC, Value); return;
case 0xA4600024: LogMessage("%08X: read from PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG (%08X)",PC, Value); return;
case 0xA4600028: LogMessage("%08X: read from PI_BSD_DOM2_PWD_REG (%08X)",PC, Value); return;
case 0xA460002C: LogMessage("%08X: read from PI_BSD_DOM2_PGS_REG (%08X)",PC, Value); return;
case 0xA4600030: LogMessage("%08X: read from PI_BSD_DOM2_RLS_REG (%08X)",PC, Value); return;
}
}
if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C)
{
if (!g_LogOptions.LogRDRAMInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)",PC, Value); return;
case 0xA4700004: LogMessage("%08X: read from RI_CONFIG_REG (%08X)",PC, Value); return;
case 0xA4700008: LogMessage("%08X: read from RI_CURRENT_LOAD_REG (%08X)",PC, Value); return;
case 0xA470000C: LogMessage("%08X: read from RI_SELECT_REG (%08X)",PC, Value); return;
case 0xA4700010: LogMessage("%08X: read from RI_REFRESH_REG/RI_COUNT_REG (%08X)",PC, Value); return;
case 0xA4700014: LogMessage("%08X: read from RI_LATENCY_REG (%08X)",PC, Value); return;
case 0xA4700018: LogMessage("%08X: read from RI_RERROR_REG (%08X)",PC, Value); return;
case 0xA470001C: LogMessage("%08X: read from RI_WERROR_REG (%08X)",PC, Value); return;
}
}
if ( VAddr == 0xA4800000)
{
if (!g_LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value);
return;
}
if ( VAddr == 0xA4800004)
{
if (!g_LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value);
return;
}
if ( VAddr == 0xA4800010)
{
if (!g_LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value);
return;
}
if ( VAddr == 0xA4800018)
{
if (!g_LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value);
return;
}
if ( VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0 )
{
return;
}
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC )
{
if (!g_LogOptions.LogPRDirectMemLoads)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value);
return;
}
if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize()))
{
return;
}
if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040)
{
if (!g_LogOptions.LogRomHeader)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break;
case 0xB0000008: LogMessage("%08X: read from Rom Boot address offset (%08X)",PC, Value); break;
case 0xB000000C: LogMessage("%08X: read from Rom Release offset (%08X)",PC, Value); break;
case 0xB0000010: LogMessage("%08X: read from Rom CRC1 (%08X)",PC, Value); break;
case 0xB0000014: LogMessage("%08X: read from Rom CRC2 (%08X)",PC, Value); break;
default: LogMessage("%08X: read from Rom header 0x%X (%08X)",PC, VAddr & 0xFF,Value); break;
}
return;
}
if (!g_LogOptions.LogUnknown)
{
return;
}
LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr);
}
void Log_SW (uint32_t PC, uint32_t VAddr, uint32_t Value)
{
if (!g_LogOptions.GenerateLog)
{
return;
}
if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 )
{
uint32_t PAddr;
if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr))
{
if (g_LogOptions.LogUnknown)
{
LogMessage("%08X: Writing 0x%08X to %08X",PC, Value, VAddr );
}
return;
}
VAddr = PAddr + 0xA0000000;
}
if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize()))
{
return;
}
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024)
{
if (!g_LogOptions.LogRDRamRegisters)
{
return;
}
switch (VAddr)
{
case 0xA3F00000: LogMessage("%08X: Writing 0x%08X to RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG",PC, Value ); return;
case 0xA3F00004: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_ID_REG",PC, Value ); return;
case 0xA3F00008: LogMessage("%08X: Writing 0x%08X to RDRAM_DELAY_REG",PC, Value ); return;
case 0xA3F0000C: LogMessage("%08X: Writing 0x%08X to RDRAM_MODE_REG",PC, Value ); return;
case 0xA3F00010: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_INTERVAL_REG",PC, Value ); return;
case 0xA3F00014: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_ROW_REG",PC, Value ); return;
case 0xA3F00018: LogMessage("%08X: Writing 0x%08X to RDRAM_RAS_INTERVAL_REG",PC, Value ); return;
case 0xA3F0001C: LogMessage("%08X: Writing 0x%08X to RDRAM_MIN_INTERVAL_REG",PC, Value ); return;
case 0xA3F00020: LogMessage("%08X: Writing 0x%08X to RDRAM_ADDR_SELECT_REG",PC, Value ); return;
case 0xA3F00024: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_MANUF_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC )
{
return;
}
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C)
{
if (!g_LogOptions.LogSPRegisters)
{
return;
}
switch (VAddr)
{
case 0xA4040000: LogMessage("%08X: Writing 0x%08X to SP_MEM_ADDR_REG",PC, Value ); return;
case 0xA4040004: LogMessage("%08X: Writing 0x%08X to SP_DRAM_ADDR_REG",PC, Value ); return;
case 0xA4040008: LogMessage("%08X: Writing 0x%08X to SP_RD_LEN_REG",PC, Value ); return;
case 0xA404000C: LogMessage("%08X: Writing 0x%08X to SP_WR_LEN_REG",PC, Value ); return;
case 0xA4040010: LogMessage("%08X: Writing 0x%08X to SP_STATUS_REG",PC, Value ); return;
case 0xA4040014: LogMessage("%08X: Writing 0x%08X to SP_DMA_FULL_REG",PC, Value ); return;
case 0xA4040018: LogMessage("%08X: Writing 0x%08X to SP_DMA_BUSY_REG",PC, Value ); return;
case 0xA404001C: LogMessage("%08X: Writing 0x%08X to SP_SEMAPHORE_REG",PC, Value ); return;
}
}
if ( VAddr == 0xA4080000)
{
if (!g_LogOptions.LogSPRegisters)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SP_PC",PC, Value ); return;
}
if ( VAddr >= 0xA4100000 && VAddr <= 0xA410001C)
{
if (!g_LogOptions.LogDPCRegisters)
{
return;
}
switch (VAddr)
{
case 0xA4100000: LogMessage("%08X: Writing 0x%08X to DPC_START_REG",PC, Value ); return;
case 0xA4100004: LogMessage("%08X: Writing 0x%08X to DPC_END_REG",PC, Value ); return;
case 0xA4100008: LogMessage("%08X: Writing 0x%08X to DPC_CURRENT_REG",PC, Value ); return;
case 0xA410000C: LogMessage("%08X: Writing 0x%08X to DPC_STATUS_REG",PC, Value ); return;
case 0xA4100010: LogMessage("%08X: Writing 0x%08X to DPC_CLOCK_REG",PC, Value ); return;
case 0xA4100014: LogMessage("%08X: Writing 0x%08X to DPC_BUFBUSY_REG",PC, Value ); return;
case 0xA4100018: LogMessage("%08X: Writing 0x%08X to DPC_PIPEBUSY_REG",PC, Value ); return;
case 0xA410001C: LogMessage("%08X: Writing 0x%08X to DPC_TMEM_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4200000 && VAddr <= 0xA420000C)
{
if (!g_LogOptions.LogDPSRegisters)
{
return;
}
switch (VAddr)
{
case 0xA4200000: LogMessage("%08X: Writing 0x%08X to DPS_TBIST_REG",PC, Value ); return;
case 0xA4200004: LogMessage("%08X: Writing 0x%08X to DPS_TEST_MODE_REG",PC, Value ); return;
case 0xA4200008: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_ADDR_REG",PC, Value ); return;
case 0xA420000C: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_DATA_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4300000 && VAddr <= 0xA430000C)
{
if (!g_LogOptions.LogMIPSInterface)
{
return;
}
switch (VAddr)
{
case 0xA4300000: LogMessage("%08X: Writing 0x%08X to MI_INIT_MODE_REG/MI_MODE_REG",PC, Value ); return;
case 0xA4300004: LogMessage("%08X: Writing 0x%08X to MI_VERSION_REG/MI_NOOP_REG",PC, Value ); return;
case 0xA4300008: LogMessage("%08X: Writing 0x%08X to MI_INTR_REG",PC, Value ); return;
case 0xA430000C: LogMessage("%08X: Writing 0x%08X to MI_INTR_MASK_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4400000 && VAddr <= 0xA4400034)
{
if (!g_LogOptions.LogVideoInterface)
{
return;
}
switch (VAddr)
{
case 0xA4400000: LogMessage("%08X: Writing 0x%08X to VI_STATUS_REG/VI_CONTROL_REG",PC, Value ); return;
case 0xA4400004: LogMessage("%08X: Writing 0x%08X to VI_ORIGIN_REG/VI_DRAM_ADDR_REG",PC, Value ); return;
case 0xA4400008: LogMessage("%08X: Writing 0x%08X to VI_WIDTH_REG/VI_H_WIDTH_REG",PC, Value ); return;
case 0xA440000C: LogMessage("%08X: Writing 0x%08X to VI_INTR_REG/VI_V_INTR_REG",PC, Value ); return;
case 0xA4400010: LogMessage("%08X: Writing 0x%08X to VI_CURRENT_REG/VI_V_CURRENT_LINE_REG",PC, Value ); return;
case 0xA4400014: LogMessage("%08X: Writing 0x%08X to VI_BURST_REG/VI_TIMING_REG",PC, Value ); return;
case 0xA4400018: LogMessage("%08X: Writing 0x%08X to VI_V_SYNC_REG",PC, Value ); return;
case 0xA440001C: LogMessage("%08X: Writing 0x%08X to VI_H_SYNC_REG",PC, Value ); return;
case 0xA4400020: LogMessage("%08X: Writing 0x%08X to VI_LEAP_REG/VI_H_SYNC_LEAP_REG",PC, Value ); return;
case 0xA4400024: LogMessage("%08X: Writing 0x%08X to VI_H_START_REG/VI_H_VIDEO_REG",PC, Value ); return;
case 0xA4400028: LogMessage("%08X: Writing 0x%08X to VI_V_START_REG/VI_V_VIDEO_REG",PC, Value ); return;
case 0xA440002C: LogMessage("%08X: Writing 0x%08X to VI_V_BURST_REG",PC, Value ); return;
case 0xA4400030: LogMessage("%08X: Writing 0x%08X to VI_X_SCALE_REG",PC, Value ); return;
case 0xA4400034: LogMessage("%08X: Writing 0x%08X to VI_Y_SCALE_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4500000 && VAddr <= 0xA4500014)
{
if (!g_LogOptions.LogAudioInterface)
{
return;
}
switch (VAddr)
{
case 0xA4500000: LogMessage("%08X: Writing 0x%08X to AI_DRAM_ADDR_REG",PC, Value ); return;
case 0xA4500004: LogMessage("%08X: Writing 0x%08X to AI_LEN_REG",PC, Value ); return;
case 0xA4500008: LogMessage("%08X: Writing 0x%08X to AI_CONTROL_REG",PC, Value ); return;
case 0xA450000C: LogMessage("%08X: Writing 0x%08X to AI_STATUS_REG",PC, Value ); return;
case 0xA4500010: LogMessage("%08X: Writing 0x%08X to AI_DACRATE_REG",PC, Value ); return;
case 0xA4500014: LogMessage("%08X: Writing 0x%08X to AI_BITRATE_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4600000 && VAddr <= 0xA4600030)
{
if (!g_LogOptions.LogPerInterface)
{
return;
}
switch (VAddr)
{
case 0xA4600000: LogMessage("%08X: Writing 0x%08X to PI_DRAM_ADDR_REG",PC, Value ); return;
case 0xA4600004: LogMessage("%08X: Writing 0x%08X to PI_CART_ADDR_REG",PC, Value ); return;
case 0xA4600008: LogMessage("%08X: Writing 0x%08X to PI_RD_LEN_REG",PC, Value ); return;
case 0xA460000C: LogMessage("%08X: Writing 0x%08X to PI_WR_LEN_REG",PC, Value ); return;
case 0xA4600010: LogMessage("%08X: Writing 0x%08X to PI_STATUS_REG",PC, Value ); return;
case 0xA4600014: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG",PC, Value ); return;
case 0xA4600018: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PWD_REG",PC, Value ); return;
case 0xA460001C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PGS_REG",PC, Value ); return;
case 0xA4600020: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_RLS_REG",PC, Value ); return;
case 0xA4600024: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG",PC, Value ); return;
case 0xA4600028: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PWD_REG",PC, Value ); return;
case 0xA460002C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PGS_REG",PC, Value ); return;
case 0xA4600030: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_RLS_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4700000 && VAddr <= 0xA470001C)
{
if (!g_LogOptions.LogRDRAMInterface)
{
return;
}
switch (VAddr)
{
case 0xA4700000: LogMessage("%08X: Writing 0x%08X to RI_MODE_REG",PC, Value ); return;
case 0xA4700004: LogMessage("%08X: Writing 0x%08X to RI_CONFIG_REG",PC, Value ); return;
case 0xA4700008: LogMessage("%08X: Writing 0x%08X to RI_CURRENT_LOAD_REG",PC, Value ); return;
case 0xA470000C: LogMessage("%08X: Writing 0x%08X to RI_SELECT_REG",PC, Value ); return;
case 0xA4700010: LogMessage("%08X: Writing 0x%08X to RI_REFRESH_REG/RI_COUNT_REG",PC, Value ); return;
case 0xA4700014: LogMessage("%08X: Writing 0x%08X to RI_LATENCY_REG",PC, Value ); return;
case 0xA4700018: LogMessage("%08X: Writing 0x%08X to RI_RERROR_REG",PC, Value ); return;
case 0xA470001C: LogMessage("%08X: Writing 0x%08X to RI_WERROR_REG",PC, Value ); return;
}
}
if ( VAddr == 0xA4800000)
{
if (!g_LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_DRAM_ADDR_REG",PC, Value ); return;
}
if ( VAddr == 0xA4800004)
{
if (g_LogOptions.LogPRDMAOperations)
{
LogMessage("%08X: A DMA transfer from the PIF ram has occured",PC );
}
if (!g_LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_RD64B_REG",PC, Value ); return;
}
if ( VAddr == 0xA4800010)
{
if (g_LogOptions.LogPRDMAOperations)
{
LogMessage("%08X: A DMA transfer to the PIF ram has occured",PC );
}
if (!g_LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_WR64B_REG",PC, Value ); return;
}
if ( VAddr == 0xA4800018)
{
if (!g_LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_STATUS_REG",PC, Value ); return;
}
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC )
{
if (!g_LogOptions.LogPRDirectMemStores)
{
return;
}
LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X",PC,Value, VAddr - 0xBFC007C0);
return;
}
if (!g_LogOptions.LogUnknown)
{
return;
}
LogMessage("%08X: Writing 0x%08X to %08X ????",PC, Value, VAddr );
}
LRESULT CALLBACK LogPifProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
if (TempOptions.LogPRDMAOperations) { CheckDlgButton(hDlg,IDC_SI_DMA,BST_CHECKED); }
if (TempOptions.LogPRDirectMemLoads) { CheckDlgButton(hDlg,IDC_DIRECT_WRITE,BST_CHECKED); }
if (TempOptions.LogPRDMAMemLoads) { CheckDlgButton(hDlg,IDC_DMA_WRITE,BST_CHECKED); }
if (TempOptions.LogPRDirectMemStores) { CheckDlgButton(hDlg,IDC_DIRECT_READ,BST_CHECKED); }
if (TempOptions.LogPRDMAMemStores) { CheckDlgButton(hDlg,IDC_DMA_READ,BST_CHECKED); }
if (TempOptions.LogControllerPak) { CheckDlgButton(hDlg,IDC_CONT_PAK,BST_CHECKED); }
break;
case WM_NOTIFY:
if (((NMHDR FAR *) lParam)->code != PSN_APPLY)
{
break;
}
TempOptions.LogPRDMAOperations = IsDlgButtonChecked(hDlg,IDC_SI_DMA) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogPRDirectMemLoads = IsDlgButtonChecked(hDlg,IDC_DIRECT_WRITE) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogPRDMAMemLoads = IsDlgButtonChecked(hDlg,IDC_DMA_WRITE) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogPRDirectMemStores = IsDlgButtonChecked(hDlg,IDC_DIRECT_READ) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogPRDMAMemStores = IsDlgButtonChecked(hDlg,IDC_DMA_READ) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogControllerPak = IsDlgButtonChecked(hDlg,IDC_CONT_PAK) == BST_CHECKED?TRUE:FALSE;
break;
default:
return FALSE;
}
return TRUE;
}
LRESULT CALLBACK LogRegProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
if (TempOptions.LogRDRamRegisters) { CheckDlgButton(hDlg,IDC_RDRAM,BST_CHECKED); }
if (TempOptions.LogSPRegisters) { CheckDlgButton(hDlg,IDC_SP_REG,BST_CHECKED); }
if (TempOptions.LogDPCRegisters) { CheckDlgButton(hDlg,IDC_DPC_REG,BST_CHECKED); }
if (TempOptions.LogDPSRegisters) { CheckDlgButton(hDlg,IDC_DPS_REG,BST_CHECKED); }
if (TempOptions.LogMIPSInterface) { CheckDlgButton(hDlg,IDC_MI_REG,BST_CHECKED); }
if (TempOptions.LogVideoInterface) { CheckDlgButton(hDlg,IDC_VI_REG,BST_CHECKED); }
if (TempOptions.LogAudioInterface) { CheckDlgButton(hDlg,IDC_AI_REG,BST_CHECKED); }
if (TempOptions.LogPerInterface) { CheckDlgButton(hDlg,IDC_PI_REG,BST_CHECKED); }
if (TempOptions.LogRDRAMInterface) { CheckDlgButton(hDlg,IDC_RI_REG,BST_CHECKED); }
if (TempOptions.LogSerialInterface) { CheckDlgButton(hDlg,IDC_SI_REG,BST_CHECKED); }
break;
case WM_NOTIFY:
if (((NMHDR FAR *) lParam)->code != PSN_APPLY)
{
break;
}
TempOptions.LogRDRamRegisters = IsDlgButtonChecked(hDlg,IDC_RDRAM) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogSPRegisters = IsDlgButtonChecked(hDlg,IDC_SP_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogDPCRegisters = IsDlgButtonChecked(hDlg,IDC_DPC_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogDPSRegisters = IsDlgButtonChecked(hDlg,IDC_DPS_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogMIPSInterface = IsDlgButtonChecked(hDlg,IDC_MI_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogVideoInterface = IsDlgButtonChecked(hDlg,IDC_VI_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogAudioInterface = IsDlgButtonChecked(hDlg,IDC_AI_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogPerInterface = IsDlgButtonChecked(hDlg,IDC_PI_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogRDRAMInterface = IsDlgButtonChecked(hDlg,IDC_RI_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogSerialInterface = IsDlgButtonChecked(hDlg,IDC_SI_REG) == BST_CHECKED?TRUE:FALSE;
break;
default:
return FALSE;
}
return TRUE;
}
void SaveLogSetting (HKEY hKey,char * String, BOOL Value)
{
DWORD StoreValue = Value;
RegSetValueEx(hKey,String,0,REG_DWORD,(CONST BYTE *)&StoreValue,sizeof(DWORD));
}
void SaveLogOptions (void)
{
long lResult;
HKEY hKeyResults = 0;
DWORD Disposition = 0;
char String[200];
sprintf(String,"Software\\N64 Emulation\\%s\\Logging",g_Settings->LoadStringVal(Setting_ApplicationName).c_str());
lResult = RegCreateKeyEx( HKEY_CURRENT_USER,String,0,"", REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,NULL,&hKeyResults,&Disposition);
SaveLogSetting(hKeyResults,"Log RDRAM",TempOptions.LogRDRamRegisters);
SaveLogSetting(hKeyResults,"Log SP",TempOptions.LogSPRegisters);
SaveLogSetting(hKeyResults,"Log DP Command",TempOptions.LogDPCRegisters);
SaveLogSetting(hKeyResults,"Log DP Span",TempOptions.LogDPSRegisters);
SaveLogSetting(hKeyResults,"Log MIPS Interface (MI)",TempOptions.LogMIPSInterface);
SaveLogSetting(hKeyResults,"Log Video Interface (VI)",TempOptions.LogVideoInterface);
SaveLogSetting(hKeyResults,"Log Audio Interface (AI)",TempOptions.LogAudioInterface);
SaveLogSetting(hKeyResults,"Log Peripheral Interface (PI)",TempOptions.LogPerInterface);
SaveLogSetting(hKeyResults,"Log RDRAM Interface (RI)",TempOptions.LogRDRAMInterface);
SaveLogSetting(hKeyResults,"Log Serial Interface (SI)",TempOptions.LogSerialInterface);
SaveLogSetting(hKeyResults,"Log PifRam DMA Operations",TempOptions.LogPRDMAOperations);
SaveLogSetting(hKeyResults,"Log PifRam Direct Memory Loads",TempOptions.LogPRDirectMemLoads);
SaveLogSetting(hKeyResults,"Log PifRam DMA Memory Loads",TempOptions.LogPRDMAMemLoads);
SaveLogSetting(hKeyResults,"Log PifRam Direct Memory Stores",TempOptions.LogPRDirectMemStores);
SaveLogSetting(hKeyResults,"Log PifRam DMA Memory Stores",TempOptions.LogPRDMAMemStores);
SaveLogSetting(hKeyResults,"Log Controller Pak",TempOptions.LogControllerPak);
SaveLogSetting(hKeyResults,"Log CP0 changes",TempOptions.LogCP0changes);
SaveLogSetting(hKeyResults,"Log CP0 reads",TempOptions.LogCP0reads);
SaveLogSetting(hKeyResults,"Log Exceptions",TempOptions.LogExceptions);
SaveLogSetting(hKeyResults,"No Interrupts",TempOptions.NoInterrupts);
SaveLogSetting(hKeyResults,"Log TLB",TempOptions.LogTLB);
SaveLogSetting(hKeyResults,"Log Cache Operations",TempOptions.LogCache);
SaveLogSetting(hKeyResults,"Log Rom Header",TempOptions.LogRomHeader);
SaveLogSetting(hKeyResults,"Log Unknown access",TempOptions.LogUnknown);
RegCloseKey(hKeyResults);
}
void LogMessage (const char * Message, ...)
{
DWORD dwWritten;
char Msg[400];
va_list ap;
if (!g_Settings->LoadBool(Debugger_Enabled))
{
return;
}
if (g_hLogFile == NULL)
{
return;
}
va_start( ap, Message );
vsprintf( Msg, Message, ap );
va_end( ap );
strcat(Msg,"\r\n");
WriteFile( g_hLogFile,Msg,strlen(Msg),&dwWritten,NULL );
}
void StartLog (void)
{
if (!g_LogOptions.GenerateLog)
{
StopLog();
return;
}
if (g_hLogFile)
{
return;
}
CPath LogFile(CPath::MODULE_DIRECTORY);
LogFile.AppendDirectory("Logs");
LogFile.SetNameExtension("cpudebug.log");
g_hLogFile = CreateFile(LogFile,GENERIC_WRITE, FILE_SHARE_READ,NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
SetFilePointer(g_hLogFile,0,NULL,FILE_BEGIN);
}
void StopLog (void)
{
if (g_hLogFile)
{
CloseHandle(g_hLogFile);
}
g_hLogFile = NULL;
}

View File

@ -9,48 +9,20 @@
* * * *
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <Project64\Settings\Logging Settings.h>
#include <Common\File Class.h>
typedef struct class CLogging :
public CLogSettings
{ {
bool GenerateLog; public:
static void StartLog(void);
static void StopLog(void);
/* Registers Log */ static void Log_LW(uint32_t PC, uint32_t VAddr);
bool LogRDRamRegisters; static void Log_SW(uint32_t PC, uint32_t VAddr, uint32_t Value);
bool LogSPRegisters; static void LogMessage(const char * Message, ...);
bool LogDPCRegisters;
bool LogDPSRegisters;
bool LogMIPSInterface;
bool LogVideoInterface;
bool LogAudioInterface;
bool LogPerInterface;
bool LogRDRAMInterface;
bool LogSerialInterface;
/* Pif Ram Log */ private:
bool LogPRDMAOperations; static CFile * m_hLogFile;
bool LogPRDirectMemLoads; };
bool LogPRDMAMemLoads;
bool LogPRDirectMemStores;
bool LogPRDMAMemStores;
bool LogControllerPak;
/* Special Log */
bool LogCP0changes;
bool LogCP0reads;
bool LogTLB;
bool LogExceptions;
bool NoInterrupts;
bool LogCache;
bool LogRomHeader;
bool LogUnknown;
} LOG_OPTIONS;
extern LOG_OPTIONS g_LogOptions;
void EnterLogOptions ( HWND hwndOwner );
void StartLog ( void );
void StopLog ( void );
void LoadLogOptions ( LOG_OPTIONS * LogOptions, bool AlwaysFill );
void Log_LW ( uint32_t PC, uint32_t VAddr );
void Log_SW ( uint32_t PC, uint32_t VAddr, uint32_t Value );
void LogMessage ( const char * Message, ... );

View File

@ -117,6 +117,7 @@ enum LanguageStringID{
MENU_SLOT_8 = 198, MENU_SLOT_8 = 198,
MENU_SLOT_9 = 199, MENU_SLOT_9 = 199,
MENU_SLOT_10 = 200, MENU_SLOT_10 = 200,
MENU_SLOT_SAVE = 201,
//Pop up Menu //Pop up Menu
POPUP_PLAY = 210, POPUP_PLAY = 210,

View File

@ -124,6 +124,7 @@ void CLanguage::LoadDefaultStrings (void)
DEF_STR(MENU_SLOT_8, L"Slot 8"); DEF_STR(MENU_SLOT_8, L"Slot 8");
DEF_STR(MENU_SLOT_9, L"Slot 9"); DEF_STR(MENU_SLOT_9, L"Slot 9");
DEF_STR(MENU_SLOT_10, L"Slot 10"); DEF_STR(MENU_SLOT_10, L"Slot 10");
DEF_STR(MENU_SLOT_SAVE, L"Save slot (%ws) selected");
//Pop up Menu //Pop up Menu
DEF_STR(POPUP_PLAY, L"Play Game"); DEF_STR(POPUP_PLAY, L"Play Game");
@ -641,7 +642,7 @@ std::wstring CLanguage::GetLangString ( const char * FileName, LanguageStringID
LANG_STR CLanguage::GetNextLangString(void * OpenFile) LANG_STR CLanguage::GetNextLangString(void * OpenFile)
{ {
enum { MAX_STRING_LEN = 400 }; enum { MAX_STRING_LEN = 400 };
int StringID; int32_t StringID;
char szString[MAX_STRING_LEN]; //temp store the string from the file char szString[MAX_STRING_LEN]; //temp store the string from the file
FILE * file = (FILE *)OpenFile; FILE * file = (FILE *)OpenFile;
@ -686,7 +687,7 @@ LANG_STR CLanguage::GetNextLangString (void * OpenFile)
StringID = EMPTY_STRING; return LANG_STR(0, L""); StringID = EMPTY_STRING; return LANG_STR(0, L"");
} }
int pos = 0; int32_t pos = 0;
fread(&token, 1, 1, file); fread(&token, 1, 1, file);
while (token != '"' && !feof(file)) while (token != '"' && !feof(file))
{ {

View File

@ -14,8 +14,9 @@
#include <string> //stl string #include <string> //stl string
#include <map> //stl map #include <map> //stl map
#include <list> //stl list #include <list> //stl list
#include <common/stdtypes.h>
typedef std::map<int, std::wstring, std::less<int> > LANG_STRINGS; typedef std::map<int32_t, std::wstring, std::less<int32_t> > LANG_STRINGS;
typedef LANG_STRINGS::value_type LANG_STR; typedef LANG_STRINGS::value_type LANG_STR;
struct LanguageFile struct LanguageFile

View File

@ -20,130 +20,15 @@ void CLanguageSelector::Select ( void )
DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Lang_Select), NULL, (DLGPROC)LangSelectProc, (LPARAM)this); DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Lang_Select), NULL, (DLGPROC)LangSelectProc, (LPARAM)this);
} }
static WNDPROC pfnWndLangSelectOkProc = NULL;
static HBITMAP hOkButton = NULL;
DWORD CALLBACK LangSelectOkProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
{
static bool m_fPressed = false;
static HBITMAP hOkButtonDown = NULL;
switch (uMsg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
if (BeginPaint(hWnd,&ps))
{
if (m_fPressed)
{
if (hOkButtonDown == NULL)
{
hOkButtonDown = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK_DOWN));
}
if (hOkButtonDown)
{
RECT rcClient;
GetClientRect(hWnd, &rcClient);
BITMAP bmTL1;
GetObject(hOkButtonDown, sizeof(BITMAP), &bmTL1);
HDC memdc = CreateCompatibleDC(ps.hdc);
HGDIOBJ save = SelectObject(memdc, hOkButtonDown);
BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY);
SelectObject(memdc, save);
DeleteDC(memdc);
}
}
else
{
if (hOkButton)
{
RECT rcClient;
GetClientRect(hWnd, &rcClient);
BITMAP bmTL1;
GetObject(hOkButton, sizeof(BITMAP), &bmTL1);
HDC memdc = CreateCompatibleDC(ps.hdc);
HGDIOBJ save = SelectObject(memdc, hOkButton);
BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY);
SelectObject(memdc, save);
DeleteDC(memdc);
}
}
EndPaint(hWnd,&ps);
}
}
break;
case WM_MOUSEMOVE:
if (::GetCapture() == hWnd)
{
POINT ptCursor = { ((int)(short)LOWORD(lParam)), ((int)(short)HIWORD(lParam)) };
ClientToScreen(hWnd, &ptCursor);
RECT rect;
GetWindowRect(hWnd, &rect);
bool uPressed = ::PtInRect(&rect, ptCursor)==TRUE;
if ( m_fPressed != uPressed )
{
m_fPressed = uPressed;
::InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
}
}
break;
case WM_LBUTTONDOWN:
{
LRESULT lRet = 0;
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
SetCapture(hWnd);
if ( ::GetCapture()==hWnd )
{
m_fPressed = true;
if (m_fPressed)
{
::InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
}
}
return lRet;
}
break;
case WM_LBUTTONUP:
{
LRESULT lRet = 0;
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
if ( ::GetCapture() == hWnd )
{
::ReleaseCapture();
if ( m_fPressed )
{
::SendMessage(GetParent(hWnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hWnd), BN_CLICKED), (LPARAM)hWnd);
}
}
m_fPressed = false;
return lRet;
}
break;
}
return CallWindowProc(pfnWndLangSelectOkProc, hWnd, uMsg, wParam, lParam);
}
LRESULT CALLBACK CLanguageSelector::LangSelectProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK CLanguageSelector::LangSelectProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
static HBITMAP hbmpBackgroundTop = NULL; static HBITMAP hbmpBackgroundTop = NULL;
static HBITMAP hbmpBackgroundBottom = NULL;
static HBITMAP hbmpBackgroundMiddle = NULL;
static HFONT hTextFont = NULL; static HFONT hTextFont = NULL;
static CLanguageSelector * lngClass; static CLanguageSelector * lngClass;
switch (uMsg) switch (uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
SetWindowPos(hDlg,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOREPOSITION|SWP_NOSIZE);
{ {
lngClass = (CLanguageSelector *)lParam; lngClass = (CLanguageSelector *)lParam;
@ -167,47 +52,11 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_SETCURSEL, 0, 0); SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_SETCURSEL, 0, 0);
} }
enum { ROUND_EDGE = 15 };
DWORD dwStyle = GetWindowLong(hDlg, GWL_STYLE);
dwStyle &= ~(WS_CAPTION|WS_SIZEBOX);
SetWindowLong(hDlg, GWL_STYLE, dwStyle);
// Use the size of the image // Use the size of the image
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_TOP)); hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO));
hbmpBackgroundBottom = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_BOTTOM));
hbmpBackgroundMiddle = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_MIDDLE));
BITMAP bmTL; BITMAP bmTL;
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL); GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);
if (hbmpBackgroundTop)
{
// int iHeight = bmTL.bmHeight;
int iWidth = bmTL.bmWidth;
RECT rect;
GetWindowRect(hDlg, &rect);
rect.left -= rect.left;
rect.bottom -= rect.top;
rect.top -= rect.top;
// Tweaked
HRGN hWindowRegion= CreateRoundRectRgn
(
rect.left,
rect.top,
rect.left+iWidth+GetSystemMetrics(SM_CXEDGE)-1,
rect.bottom+GetSystemMetrics(SM_CYEDGE)-1,
ROUND_EDGE,
ROUND_EDGE
);
if (hWindowRegion)
{
SetWindowRgn(hDlg, hWindowRegion, TRUE);
DeleteObject(hWindowRegion);
}
}
hTextFont = ::CreateFont hTextFont = ::CreateFont
( (
18, 18,
@ -227,35 +76,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
); );
SendDlgItemMessage(hDlg, IDC_SELECT_LANG, WM_SETFONT, (WPARAM)hTextFont, TRUE); SendDlgItemMessage(hDlg, IDC_SELECT_LANG, WM_SETFONT, (WPARAM)hTextFont, TRUE);
} }
hOkButton = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK));
pfnWndLangSelectOkProc = (WNDPROC)::GetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC);
::SetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC,(LONG_PTR)LangSelectOkProc);
break;
case WM_NCHITTEST:
{
int xPos = LOWORD(lParam);
int yPos = HIWORD(lParam);
RECT client, a;
GetClientRect(hDlg,&a);
GetClientRect(hDlg,&client);
ClientToScreen(hDlg,(LPPOINT)&client);
client.right += client.left;
client.bottom += client.top;
int nCaption = GetSystemMetrics(SM_CYCAPTION)*4;
LRESULT lResult = HTCLIENT;
//check caption
if (xPos <= client.right && xPos >= client.left &&
(yPos >= client.top+ 0)&& (yPos <= client.top + 0+nCaption))
{
lResult = HTCAPTION;
}
SetWindowLong(hDlg, DWLP_MSGRESULT, lResult);
return TRUE;
}
break; break;
case WM_CTLCOLORSTATIC: case WM_CTLCOLORSTATIC:
{ {
@ -265,6 +85,22 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH)); return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH));
} }
break; break;
case WM_ERASEBKGND:
{
HPEN outline;
HBRUSH fill;
RECT rect;
outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF);
fill = CreateSolidBrush(0x00FFFFFF);
SelectObject((HDC)wParam, outline);
SelectObject((HDC)wParam, fill);
GetClientRect(hDlg, &rect);
Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom);
}
break;
case WM_PAINT: case WM_PAINT:
{ {
PAINTSTRUCT ps; PAINTSTRUCT ps;
@ -274,10 +110,8 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
RECT rcClient; RECT rcClient;
GetClientRect(hDlg, &rcClient); GetClientRect(hDlg, &rcClient);
BITMAP bmTL_top, bmTL_bottom, bmTL_Middle; BITMAP bmTL_top;
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top); GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top);
GetObject(hbmpBackgroundBottom, sizeof(BITMAP), &bmTL_bottom);
GetObject(hbmpBackgroundMiddle, sizeof(BITMAP), &bmTL_Middle);
HDC memdc = CreateCompatibleDC(ps.hdc); HDC memdc = CreateCompatibleDC(ps.hdc);
HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop); HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop);
@ -285,25 +119,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
SelectObject(memdc, save); SelectObject(memdc, save);
DeleteDC(memdc); DeleteDC(memdc);
memdc = CreateCompatibleDC(ps.hdc);
save = SelectObject(memdc, hbmpBackgroundMiddle);
for (int x = bmTL_top.bmHeight; x < rcClient.bottom; x += bmTL_Middle.bmHeight)
{
//BitBlt(ps.hdc, 0, bmTL_top.bmHeight, bmTL_Middle.bmWidth, rcClient.bottom - (bmTL_bottom.bmHeight + bmTL_top.bmHeight), memdc, 0, 0, SRCCOPY);
BitBlt(ps.hdc, 0, x, bmTL_Middle.bmWidth, bmTL_Middle.bmHeight, memdc, 0, 0, SRCCOPY);
}
SelectObject(memdc, save);
DeleteDC(memdc);
BITMAP ;
memdc = CreateCompatibleDC(ps.hdc);
save = SelectObject(memdc, hbmpBackgroundBottom);
BitBlt(ps.hdc, 0, rcClient.bottom - bmTL_bottom.bmHeight, bmTL_bottom.bmWidth, bmTL_bottom.bmHeight, memdc, 0, 0, SRCCOPY);
SelectObject(memdc, save);
DeleteDC(memdc);
BITMAP ;
EndPaint(hDlg, &ps); EndPaint(hDlg, &ps);
} }
} }
@ -316,14 +131,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
{ {
DeleteObject(hbmpBackgroundTop); DeleteObject(hbmpBackgroundTop);
} }
if (hbmpBackgroundBottom)
{
DeleteObject(hbmpBackgroundBottom);
}
if (hbmpBackgroundMiddle)
{
DeleteObject(hbmpBackgroundMiddle);
}
if (hTextFont) if (hTextFont)
{ {

View File

@ -0,0 +1,96 @@
/****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#include "stdafx.h"
#include <Project64\N64 System\N64 Class.h>
#include <common/Util.h>
#include <Windows.h>
#include <Objbase.h>
void CN64System::StartEmulationThead()
{
ThreadInfo * Info = new ThreadInfo;
HANDLE * hThread = new HANDLE;
*hThread = NULL;
//create the needed info into a structure to pass as one parameter
//for creating a thread
Info->ThreadHandle = hThread;
*hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartEmulationThread, Info, 0, (LPDWORD)&Info->ThreadID);
}
void CN64System::StartEmulationThread(ThreadInfo * Info)
{
if (g_Settings->LoadBool(Setting_CN64TimeCritical))
{
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
}
CoInitialize(NULL);
EmulationStarting(Info->ThreadHandle, Info->ThreadID);
delete ((HANDLE *)Info->ThreadHandle);
delete Info;
CoUninitialize();
}
void CN64System::CloseCpu()
{
if (m_CPU_Handle == NULL)
{
return;
}
m_EndEmulation = true;
if (g_Settings->LoadBool(GameRunning_CPU_Paused))
{
m_hPauseEvent.Trigger();
}
if (GetCurrentThreadId() == m_CPU_ThreadID)
{
ExternalEvent(SysEvent_CloseCPU);
return;
}
HANDLE hThread = m_CPU_Handle;
m_CPU_Handle = NULL;
for (int count = 0; count < 200; count++)
{
pjutil::Sleep(100);
if (g_Notify->ProcessGuiMessages())
{
return;
}
DWORD ExitCode;
if (GetExitCodeThread(hThread, &ExitCode))
{
if (ExitCode != STILL_ACTIVE)
{
break;
}
}
}
if (hThread)
{
DWORD ExitCode;
GetExitCodeThread(hThread, &ExitCode);
if (ExitCode == STILL_ACTIVE)
{
TerminateThread(hThread, 0);
}
}
CloseHandle(hThread);
CpuStopped();
}

View File

@ -339,7 +339,8 @@ void CInterpreterCPU::ExecuteCPU()
R4300iOp::m_NextInstruction = NORMAL; R4300iOp::m_NextInstruction = NORMAL;
} }
} }
} __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) }
__except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation()))
{ {
g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION)); g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION));
} }

View File

@ -10,13 +10,15 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <Project64\N64 System\Interpreter\Interpreter Ops.h>
class CInterpreterCPU : class CInterpreterCPU :
private R4300iOp private R4300iOp
{ {
public: public:
static void BuildCPU(); static void BuildCPU();
static void ExecuteCPU(); static void ExecuteCPU();
static void ExecuteOps(int Cycles); static void ExecuteOps(int32_t Cycles);
static void InPermLoop(); static void InPermLoop();
private: private:

View File

@ -9,6 +9,7 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include <Project64\Logging.h>
bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2);
@ -949,7 +950,7 @@ void R4300iOp32::LW()
ADDRESS_ERROR_EXCEPTION(Address, true); ADDRESS_ERROR_EXCEPTION(Address, true);
} }
if (g_LogOptions.GenerateLog) if (GenerateLog())
{ {
Log_LW((*_PROGRAM_COUNTER), Address); Log_LW((*_PROGRAM_COUNTER), Address);
} }
@ -1322,7 +1323,7 @@ void R4300iOp32::REGIMM_BGEZAL()
/************************** COP0 functions **************************/ /************************** COP0 functions **************************/
void R4300iOp32::COP0_MF() void R4300iOp32::COP0_MF()
{ {
if (g_LogOptions.LogCP0reads) if (LogCP0reads())
{ {
LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]);
} }
@ -1336,7 +1337,7 @@ void R4300iOp32::COP0_MF()
void R4300iOp32::COP0_MT() void R4300iOp32::COP0_MT()
{ {
if (g_LogOptions.LogCP0changes) if (LogCP0changes())
{ {
LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)", (*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0], CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)", (*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0], CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]);
if (m_Opcode.rd == 11) //Compare if (m_Opcode.rd == 11) //Compare

View File

@ -10,6 +10,8 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include "Interpreter Ops.h"
class R4300iOp32 : class R4300iOp32 :
public R4300iOp public R4300iOp
{ {

View File

@ -9,6 +9,7 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include <Project64\User Interface\LoggingUI.h>
void InPermLoop(); void InPermLoop();
void TestInterpreterJump(uint32_t PC, uint32_t TargetPC, int32_t Reg1, int32_t Reg2); void TestInterpreterJump(uint32_t PC, uint32_t TargetPC, int32_t Reg1, int32_t Reg2);
@ -1113,7 +1114,7 @@ void R4300iOp::LW()
ADDRESS_ERROR_EXCEPTION(Address, true); ADDRESS_ERROR_EXCEPTION(Address, true);
} }
if (g_LogOptions.GenerateLog) if (GenerateLog())
{ {
Log_LW((*_PROGRAM_COUNTER), Address); Log_LW((*_PROGRAM_COUNTER), Address);
} }
@ -1292,7 +1293,7 @@ void R4300iOp::SW()
{ {
ADDRESS_ERROR_EXCEPTION(Address, false); ADDRESS_ERROR_EXCEPTION(Address, false);
} }
if (g_LogOptions.GenerateLog) if (GenerateLog())
{ {
Log_SW((*_PROGRAM_COUNTER), Address, _GPR[m_Opcode.rt].UW[0]); Log_SW((*_PROGRAM_COUNTER), Address, _GPR[m_Opcode.rt].UW[0]);
} }
@ -1442,7 +1443,7 @@ void R4300iOp::SWR()
void R4300iOp::CACHE() void R4300iOp::CACHE()
{ {
if (!g_LogOptions.LogCache) if (!LogCache())
{ {
return; return;
} }
@ -2088,7 +2089,7 @@ void R4300iOp::REGIMM_BGEZAL()
/************************** COP0 functions **************************/ /************************** COP0 functions **************************/
void R4300iOp::COP0_MF() void R4300iOp::COP0_MF()
{ {
if (g_LogOptions.LogCP0reads) if (LogCP0reads())
{ {
LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]);
} }
@ -2102,7 +2103,7 @@ void R4300iOp::COP0_MF()
void R4300iOp::COP0_MT() void R4300iOp::COP0_MT()
{ {
if (g_LogOptions.LogCP0changes) if (LogCP0changes())
{ {
LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)", (*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0], CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)", (*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0], CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]);
if (m_Opcode.rd == 11) //Compare if (m_Opcode.rd == 11) //Compare

View File

@ -10,7 +10,12 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <Project64\Settings\Debug Settings.h>
#include <Project64\N64 System\Mips\Register Class.h>
#include <Project64\N64 System\Mips\OpCode.h>
class R4300iOp : class R4300iOp :
public CLogging,
protected CDebugSettings, protected CDebugSettings,
protected CSystemRegisters protected CSystemRegisters
{ {

View File

@ -9,6 +9,9 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include "Audio.h"
#include <Project64\N64 System\System Globals.h>
#include <Project64\N64 System\N64 Class.h>
CAudio::CAudio() CAudio::CAudio()
{ {
@ -17,7 +20,6 @@ CAudio::CAudio()
CAudio::~CAudio() CAudio::~CAudio()
{ {
} }
void CAudio::Reset() void CAudio::Reset()
@ -30,10 +32,10 @@ void CAudio::Reset()
m_FramesPerSecond = 60; m_FramesPerSecond = 60;
} }
DWORD CAudio::GetLength() uint32_t CAudio::GetLength()
{ {
WriteTraceF(TraceAudio, __FUNCTION__ ": Start (m_SecondBuff = %d)", m_SecondBuff); WriteTraceF(TraceAudio, __FUNCTION__ ": Start (m_SecondBuff = %d)", m_SecondBuff);
DWORD TimeLeft = g_SystemTimer->GetTimer(CSystemTimer::AiTimerInterrupt), Res = 0; uint32_t TimeLeft = g_SystemTimer->GetTimer(CSystemTimer::AiTimerInterrupt), Res = 0;
if (TimeLeft > 0) if (TimeLeft > 0)
{ {
Res = (TimeLeft / m_CountsPerByte); Res = (TimeLeft / m_CountsPerByte);
@ -42,7 +44,7 @@ DWORD CAudio::GetLength()
return (Res + 3)&~3; return (Res + 3)&~3;
} }
DWORD CAudio::GetStatus() uint32_t CAudio::GetStatus()
{ {
WriteTraceF(TraceAudio, __FUNCTION__ ": m_Status = %X", m_Status); WriteTraceF(TraceAudio, __FUNCTION__ ": m_Status = %X", m_Status);
return m_Status; return m_Status;
@ -56,9 +58,11 @@ void CAudio::LenChanged()
if (g_Reg->AI_LEN_REG >= 0x40000) if (g_Reg->AI_LEN_REG >= 0x40000)
{ {
WriteTraceF(TraceAudio, __FUNCTION__ ": *** Ignoring Write, To Large (%X)", g_Reg->AI_LEN_REG); WriteTraceF(TraceAudio, __FUNCTION__ ": *** Ignoring Write, To Large (%X)", g_Reg->AI_LEN_REG);
} else { }
else
{
m_Status |= ai_busy; m_Status |= ai_busy;
DWORD AudioLeft = g_SystemTimer->GetTimer(CSystemTimer::AiTimerInterrupt); uint32_t AudioLeft = g_SystemTimer->GetTimer(CSystemTimer::AiTimerInterrupt);
if (m_SecondBuff == 0) if (m_SecondBuff == 0)
{ {
if (AudioLeft == 0) if (AudioLeft == 0)
@ -124,20 +128,19 @@ void CAudio::BusyTimerDone()
m_Status &= ~ai_busy; m_Status &= ~ai_busy;
} }
void CAudio::SetViIntr ( DWORD VI_INTR_TIME ) void CAudio::SetViIntr(uint32_t VI_INTR_TIME)
{ {
double CountsPerSecond = (DWORD)((double)VI_INTR_TIME * m_FramesPerSecond); double CountsPerSecond = (uint32_t)((double)VI_INTR_TIME * m_FramesPerSecond);
if (m_BytesPerSecond != 0 && (g_System->AiCountPerBytes() == 0)) if (m_BytesPerSecond != 0 && (g_System->AiCountPerBytes() == 0))
{ {
m_CountsPerByte = (int)((double)CountsPerSecond / (double)m_BytesPerSecond); m_CountsPerByte = (int32_t)((double)CountsPerSecond / (double)m_BytesPerSecond);
} }
} }
void CAudio::SetFrequency(uint32_t Dacrate, uint32_t System)
void CAudio::SetFrequency (DWORD Dacrate, DWORD System)
{ {
WriteTraceF(TraceAudio, __FUNCTION__ "(Dacrate: %X System: %d): AI_BITRATE_REG = %X", Dacrate, System, g_Reg->AI_BITRATE_REG); WriteTraceF(TraceAudio, __FUNCTION__ "(Dacrate: %X System: %d): AI_BITRATE_REG = %X", Dacrate, System, g_Reg->AI_BITRATE_REG);
DWORD Frequency; uint32_t Frequency;
switch (System) switch (System)
{ {

View File

@ -21,19 +21,22 @@ public:
CAudio(); CAudio();
~CAudio(); ~CAudio();
DWORD GetLength (); uint32_t GetLength ();
DWORD GetStatus (); uint32_t GetStatus ();
void LenChanged (); void LenChanged ();
void InterruptTimerDone(); void InterruptTimerDone();
void BusyTimerDone (); void BusyTimerDone ();
void Reset (); void Reset ();
void SetViIntr ( DWORD VI_INTR_TIME ); void SetViIntr ( uint32_t VI_INTR_TIME );
void SetFrequency ( DWORD Dacrate, DWORD System ); void SetFrequency ( uint32_t Dacrate, uint32_t System );
private: private:
DWORD m_SecondBuff; CAudio(const CAudio&); // Disable copy constructor
DWORD m_Status; CAudio& operator=(const CAudio&); // Disable assignment
DWORD m_BytesPerSecond;
int m_CountsPerByte; uint32_t m_SecondBuff;
int m_FramesPerSecond; uint32_t m_Status;
uint32_t m_BytesPerSecond;
int32_t m_CountsPerByte;
int32_t m_FramesPerSecond;
}; };

View File

@ -14,28 +14,36 @@ CDMA::CDMA(CFlashram & FlashRam, CSram & Sram) :
m_FlashRam(FlashRam), m_FlashRam(FlashRam),
m_Sram(Sram) m_Sram(Sram)
{ {
} }
void CDMA::OnFirstDMA() void CDMA::OnFirstDMA()
{ {
int16_t offset;
const uint32_t base = 0x00000000;
const uint32_t rt = g_MMU->RdramSize();
switch (g_Rom->CicChipID()) switch (g_Rom->CicChipID())
{ {
case CIC_NUS_6101: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break; case CIC_NUS_6101: offset = +0x0318; break;
case CIC_NUS_5167: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break; case CIC_NUS_5167: offset = +0x0318; break;
case CIC_UNKNOWN: case CIC_UNKNOWN:
case CIC_NUS_6102: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break; case CIC_NUS_6102: offset = +0x0318; break;
case CIC_NUS_6103: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break; case CIC_NUS_6103: offset = +0x0318; break;
case CIC_NUS_6105: *(DWORD *)&((g_MMU->Rdram())[0x3F0]) = g_MMU->RdramSize(); break; case CIC_NUS_6105: offset = +0x03F0; break;
case CIC_NUS_6106: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break; case CIC_NUS_6106: offset = +0x0318; break;
default: g_Notify->DisplayError(stdstr_f("Unhandled CicChip(%d) in first DMA",g_Rom->CicChipID()).ToUTF16().c_str()); default:
g_Notify->DisplayError(
stdstr_f("Unhandled CicChip(%d) in first DMA", g_Rom->CicChipID()).ToUTF16().c_str()
);
return;
} }
g_MMU->SW_PAddr(base + offset, rt);
} }
void CDMA::PI_DMA_READ() void CDMA::PI_DMA_READ()
{ {
// PI_STATUS_REG |= PI_STATUS_DMA_BUSY; // PI_STATUS_REG |= PI_STATUS_DMA_BUSY;
DWORD PI_RD_LEN_REG = ((g_Reg->PI_RD_LEN_REG) & 0x00FFFFFFul) + 1; uint32_t PI_RD_LEN_REG = ((g_Reg->PI_RD_LEN_REG) & 0x00FFFFFFul) + 1;
if ((PI_RD_LEN_REG & 1) != 0) if ((PI_RD_LEN_REG & 1) != 0)
{ {
@ -57,9 +65,9 @@ void CDMA::PI_DMA_READ()
//Write ROM Area (for 64DD Convert) //Write ROM Area (for 64DD Convert)
if (g_Reg->PI_CART_ADDR_REG >= 0x10000000 && g_Reg->PI_CART_ADDR_REG <= 0x1FBFFFFF && g_Settings->LoadBool(Game_AllowROMWrites)) if (g_Reg->PI_CART_ADDR_REG >= 0x10000000 && g_Reg->PI_CART_ADDR_REG <= 0x1FBFFFFF && g_Settings->LoadBool(Game_AllowROMWrites))
{ {
DWORD i; uint32_t i;
BYTE * ROM = g_Rom->GetRomAddress(); uint8_t * ROM = g_Rom->GetRomAddress();
BYTE * RDRAM = g_MMU->Rdram(); uint8_t * RDRAM = g_MMU->Rdram();
DWORD OldProtect; DWORD OldProtect;
VirtualProtect(ROM, g_Rom->GetRomSize(), PAGE_READWRITE, &OldProtect); VirtualProtect(ROM, g_Rom->GetRomSize(), PAGE_READWRITE, &OldProtect);
@ -74,7 +82,7 @@ void CDMA::PI_DMA_READ()
} }
else else
{ {
DWORD Len; uint32_t Len;
Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG; Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
for (i = 0; i < Len; i++) for (i = 0; i < Len; i++)
{ {
@ -101,7 +109,7 @@ void CDMA::PI_DMA_READ()
return; return;
} }
if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08088000) if (g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000)
{ {
if (g_System->m_SaveUsing == SaveChip_Auto) if (g_System->m_SaveUsing == SaveChip_Auto)
{ {
@ -152,7 +160,7 @@ void CDMA::PI_DMA_READ()
void CDMA::PI_DMA_WRITE() void CDMA::PI_DMA_WRITE()
{ {
DWORD PI_WR_LEN_REG = ((g_Reg->PI_WR_LEN_REG) & 0x00FFFFFFul) + 1; uint32_t PI_WR_LEN_REG = ((g_Reg->PI_WR_LEN_REG) & 0x00FFFFFFul) + 1;
if ((PI_WR_LEN_REG & 1) != 0) if ((PI_WR_LEN_REG & 1) != 0)
{ {
@ -203,20 +211,20 @@ void CDMA::PI_DMA_WRITE()
if (g_Reg->PI_CART_ADDR_REG >= 0x10000000 && g_Reg->PI_CART_ADDR_REG <= 0x1FFFFFFF) if (g_Reg->PI_CART_ADDR_REG >= 0x10000000 && g_Reg->PI_CART_ADDR_REG <= 0x1FFFFFFF)
{ {
DWORD i; uint32_t i;
#ifdef tofix #ifdef tofix
#ifdef ROM_IN_MAPSPACE #ifdef ROM_IN_MAPSPACE
if (WrittenToRom) if (WrittenToRom)
{ {
DWORD OldProtect; uint32_t OldProtect;
VirtualProtect(ROM,m_RomFileSize,PAGE_READONLY, &OldProtect); VirtualProtect(ROM,m_RomFileSize,PAGE_READONLY, &OldProtect);
} }
#endif #endif
#endif #endif
BYTE * ROM = g_Rom->GetRomAddress(); uint8_t * ROM = g_Rom->GetRomAddress();
BYTE * RDRAM = g_MMU->Rdram(); uint8_t * RDRAM = g_MMU->Rdram();
g_Reg->PI_CART_ADDR_REG -= 0x10000000; g_Reg->PI_CART_ADDR_REG -= 0x10000000;
if (g_Reg->PI_CART_ADDR_REG + PI_WR_LEN_REG < g_Rom->GetRomSize()) if (g_Reg->PI_CART_ADDR_REG + PI_WR_LEN_REG < g_Rom->GetRomSize())
{ {
@ -227,7 +235,7 @@ void CDMA::PI_DMA_WRITE()
} }
else if (g_Reg->PI_CART_ADDR_REG >= g_Rom->GetRomSize()) else if (g_Reg->PI_CART_ADDR_REG >= g_Rom->GetRomSize())
{ {
DWORD cart = g_Reg->PI_CART_ADDR_REG - g_Rom->GetRomSize(); uint32_t cart = g_Reg->PI_CART_ADDR_REG - g_Rom->GetRomSize();
while (cart >= g_Rom->GetRomSize()) while (cart >= g_Rom->GetRomSize())
{ {
cart -= g_Rom->GetRomSize(); cart -= g_Rom->GetRomSize();
@ -239,7 +247,7 @@ void CDMA::PI_DMA_WRITE()
} }
else else
{ {
DWORD Len; uint32_t Len;
Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG; Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
for (i = 0; i < Len; i++) for (i = 0; i < Len; i++)
{ {
@ -264,8 +272,8 @@ void CDMA::PI_DMA_WRITE()
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
//ChangeTimer(PiTimer,(int)(PI_WR_LEN_REG * 8.9) + 50); //ChangeTimer(PiTimer,(int32_t)(PI_WR_LEN_REG * 8.9) + 50);
//ChangeTimer(PiTimer,(int)(PI_WR_LEN_REG * 8.9)); //ChangeTimer(PiTimer,(int32_t)(PI_WR_LEN_REG * 8.9));
return; return;
} }
@ -276,7 +284,6 @@ void CDMA::PI_DMA_WRITE()
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI; g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
} }
void CDMA::SP_DMA_READ() void CDMA::SP_DMA_READ()

View File

@ -9,6 +9,9 @@
* * * *
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <Project64\Settings\Debug Settings.h>
#include <Project64\N64 System\Mips\FlashRam.h>
#include <Project64\N64 System\Mips\Sram.h>
class CDMA : class CDMA :
private CDebugSettings private CDebugSettings
@ -24,10 +27,10 @@ public:
protected: protected:
CDMA(CFlashram & FlashRam, CSram & Sram); CDMA(CFlashram & FlashRam, CSram & Sram);
//void SI_DMA_READ();
//void SI_DMA_WRITE();
private: private:
CDMA(const CDMA&); // Disable copy constructor
CDMA& operator=(const CDMA&); // Disable assignment
CFlashram & m_FlashRam; CFlashram & m_FlashRam;
CSram & m_Sram; CSram & m_Sram;

View File

@ -9,6 +9,9 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include "Eeprom.h"
#include <Project64\N64 System\System Globals.h>
#include <Project64\N64 System\N64 Class.h>
#include <time.h> #include <time.h>
CEeprom::CEeprom(bool ReadOnly) : CEeprom::CEeprom(bool ReadOnly) :
@ -27,13 +30,13 @@ CEeprom::~CEeprom()
} }
} }
unsigned char byte2bcd(int n) uint8_t byte2bcd(int32_t n)
{ {
n %= 100; n %= 100;
return (unsigned char)(((n / 10) << 4) | (n % 10)); return (uint8_t)(((n / 10) << 4) | (n % 10));
} }
void CEeprom::EepromCommand ( BYTE * Command) void CEeprom::EepromCommand(uint8_t * Command)
{ {
time_t curtime_time; time_t curtime_time;
struct tm curtime; struct tm curtime;
@ -164,9 +167,9 @@ void CEeprom::LoadEeprom()
ReadFile(m_hFile, m_EEPROM, sizeof(m_EEPROM), &dwRead, NULL); ReadFile(m_hFile, m_EEPROM, sizeof(m_EEPROM), &dwRead, NULL);
} }
void CEeprom::ReadFrom(BYTE * Buffer, int line) void CEeprom::ReadFrom(uint8_t * Buffer, int32_t line)
{ {
int i; int32_t i;
if (m_hFile == NULL) if (m_hFile == NULL)
{ {
@ -179,10 +182,10 @@ void CEeprom::ReadFrom(BYTE * Buffer, int line)
} }
} }
void CEeprom::WriteTo(BYTE * Buffer, int line) void CEeprom::WriteTo(uint8_t * Buffer, int32_t line)
{ {
DWORD dwWritten; DWORD dwWritten;
int i; int32_t i;
if (m_hFile == NULL) if (m_hFile == NULL)
{ {

View File

@ -17,14 +17,18 @@ public:
CEeprom(bool ReadOnly); CEeprom(bool ReadOnly);
~CEeprom(); ~CEeprom();
void EepromCommand ( BYTE * Command ); void EepromCommand(uint8_t * Command);
private: private:
void LoadEeprom (); CEeprom(void); // Disable default constructor
void ReadFrom ( BYTE * Buffer, int line ); CEeprom(const CEeprom&); // Disable copy constructor
void WriteTo ( BYTE * Buffer, int line ); CEeprom& operator=(const CEeprom&); // Disable assignment
BYTE m_EEPROM[0x800]; void LoadEeprom();
void ReadFrom(uint8_t * Buffer, int32_t line);
void WriteTo(uint8_t * Buffer, int32_t line);
uint8_t m_EEPROM[0x800];
bool m_ReadOnly; bool m_ReadOnly;
HANDLE m_hFile; void * m_hFile;
}; };

View File

@ -9,6 +9,7 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include <Project64\User Interface\LoggingUI.h>
int CPifRamSettings::m_RefCount = 0; int CPifRamSettings::m_RefCount = 0;
bool CPifRamSettings::m_bShowPifRamErrors = false; bool CPifRamSettings::m_bShowPifRamErrors = false;
@ -45,7 +46,6 @@ CPifRam::CPifRam( bool SavesReadOnly ) :
CPifRam::~CPifRam() CPifRam::~CPifRam()
{ {
} }
void CPifRam::Reset() void CPifRam::Reset()
@ -86,7 +86,6 @@ void CPifRam::n64_cic_nus_6105(char challenge[], char respone[], int length)
} }
} }
void CPifRam::PifRamRead() void CPifRam::PifRamRead()
{ {
if (m_PifRam[0x3F] == 0x2) if (m_PifRam[0x3F] == 0x2)
@ -308,7 +307,7 @@ void CPifRam::SI_DMA_READ()
} }
} }
if (g_LogOptions.LogPRDMAMemStores) if (LogPRDMAMemStores())
{ {
int32_t count; int32_t count;
char HexData[100], AsciiData[100], Addon[20]; char HexData[100], AsciiData[100], Addon[20];
@ -394,7 +393,7 @@ void CPifRam::SI_DMA_WRITE()
} }
} }
if (g_LogOptions.LogPRDMAMemLoads) if (LogPRDMAMemLoads())
{ {
int32_t count; int32_t count;
char HexData[100], AsciiData[100], Addon[20]; char HexData[100], AsciiData[100], Addon[20];
@ -505,7 +504,7 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
} }
break; break;
case 0x02: //read from controller pack case 0x02: //read from controller pack
if (g_LogOptions.LogControllerPak) if (LogControllerPak())
{ {
LogControllerPakData("Read: Before Gettting Results"); LogControllerPakData("Read: Before Gettting Results");
} }
@ -541,13 +540,13 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
{ {
Command[1] |= 0x80; Command[1] |= 0x80;
} }
if (g_LogOptions.LogControllerPak) if (LogControllerPak())
{ {
LogControllerPakData("Read: After Gettting Results"); LogControllerPakData("Read: After Gettting Results");
} }
break; break;
case 0x03: //write controller pak case 0x03: //write controller pak
if (g_LogOptions.LogControllerPak) if (LogControllerPak())
{ {
LogControllerPakData("Write: Before Processing"); LogControllerPakData("Write: Before Processing");
} }
@ -581,7 +580,7 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
{ {
Command[1] |= 0x80; Command[1] |= 0x80;
} }
if (g_LogOptions.LogControllerPak) if (LogControllerPak())
{ {
LogControllerPakData("Write: After Processing"); LogControllerPakData("Write: After Processing");
} }

View File

@ -10,6 +10,7 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <Project64\Logging.h>
class CPifRamSettings class CPifRamSettings
{ {
protected: protected:
@ -31,6 +32,7 @@ private:
}; };
class CPifRam : class CPifRam :
public CLogging,
private CPifRamSettings, private CPifRamSettings,
private CEeprom private CEeprom
{ {

View File

@ -9,6 +9,7 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include <Project64\User Interface\LoggingUI.h>
const char * CRegName::GPR[32] = { "r0", "at", "v0", "v1", "a0", "a1", "a2", "a3", const char * CRegName::GPR[32] = { "r0", "at", "v0", "v1", "a0", "a1", "a2", "a3",
"t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
@ -451,7 +452,7 @@ bool CRegisters::DoIntrException(bool DelaySlot)
return false; return false;
} }
if (g_LogOptions.GenerateLog && g_LogOptions.LogExceptions && !g_LogOptions.NoInterrupts) if (GenerateLog() && LogExceptions() && !LogNoInterrupts())
{ {
LogMessage("%08X: Interrupt Generated", m_PROGRAM_COUNTER); LogMessage("%08X: Interrupt Generated", m_PROGRAM_COUNTER);
} }

View File

@ -10,6 +10,9 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <Project64\Settings\Game Settings.h>
#include <Project64\Logging.h>
//CPO registers by name //CPO registers by name
class CP0registers class CP0registers
{ {
@ -515,6 +518,7 @@ class CN64System;
class CSystemEvents; class CSystemEvents;
class CRegisters : class CRegisters :
public CLogging,
private CDebugSettings, private CDebugSettings,
private CGameSettings, private CGameSettings,
protected CSystemRegisters, protected CSystemRegisters,

View File

@ -9,6 +9,7 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include <common/Util.h>
#pragma warning(disable:4355) // Disable 'this' : used in base member initializer list #pragma warning(disable:4355) // Disable 'this' : used in base member initializer list
@ -22,7 +23,6 @@ m_SaveUsing((SAVE_CHIP_TYPE)g_Settings->LoadDword(Game_SaveChip)),
m_Plugins(Plugins), m_Plugins(Plugins),
m_SyncCPU(NULL), m_SyncCPU(NULL),
m_SyncPlugins(NULL), m_SyncPlugins(NULL),
m_SyncWindow(NULL),
m_MMU_VM(this, SavesReadOnly), m_MMU_VM(this, SavesReadOnly),
m_TLB(this), m_TLB(this),
m_Reg(this, this), m_Reg(this, this),
@ -42,14 +42,14 @@ m_TLBStoreAddress(0),
m_SyncCount(0), m_SyncCount(0),
m_CPU_Handle(NULL), m_CPU_Handle(NULL),
m_CPU_ThreadID(0), m_CPU_ThreadID(0),
m_hPauseEvent(true),
m_CheatsSlectionChanged(false) m_CheatsSlectionChanged(false)
{ {
DWORD gameHertz = g_Settings->LoadDword(Game_ScreenHertz); uint32_t gameHertz = g_Settings->LoadDword(Game_ScreenHertz);
if (gameHertz == 0) if (gameHertz == 0)
{ {
gameHertz = (SystemType() == SYSTEM_PAL) ? 50 : 60; gameHertz = (SystemType() == SYSTEM_PAL) ? 50 : 60;
} }
m_hPauseEvent = CreateEvent(NULL,true,false,NULL);
m_Limitor.SetHertz(gameHertz); m_Limitor.SetHertz(gameHertz);
g_Settings->SaveDword(GameRunning_ScreenHertz, gameHertz); g_Settings->SaveDword(GameRunning_ScreenHertz, gameHertz);
m_Cheats.LoadCheats(!g_Settings->LoadDword(Setting_RememberCheats), Plugins); m_Cheats.LoadCheats(!g_Settings->LoadDword(Setting_RememberCheats), Plugins);
@ -75,11 +75,6 @@ CN64System::~CN64System()
delete m_SyncPlugins; delete m_SyncPlugins;
m_SyncPlugins = NULL; m_SyncPlugins = NULL;
} }
if (m_SyncWindow)
{
delete m_SyncWindow;
m_SyncWindow = NULL;
}
} }
void CN64System::ExternalEvent(SystemEvent action) void CN64System::ExternalEvent(SystemEvent action)
@ -123,54 +118,54 @@ void CN64System::ExternalEvent ( SystemEvent action )
break; break;
case SysEvent_ResumeCPU_FromMenu: case SysEvent_ResumeCPU_FromMenu:
// always resume if from menu // always resume if from menu
SetEvent(m_hPauseEvent); m_hPauseEvent.Trigger();
break; break;
case SysEvent_ResumeCPU_AppGainedFocus: case SysEvent_ResumeCPU_AppGainedFocus:
if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostFocus) if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostFocus)
{ {
SetEvent(m_hPauseEvent); m_hPauseEvent.Trigger();
} }
break; break;
case SysEvent_ResumeCPU_AppGainedActive: case SysEvent_ResumeCPU_AppGainedActive:
if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostActive) if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostActive)
{ {
SetEvent(m_hPauseEvent); m_hPauseEvent.Trigger();
} }
break; break;
case SysEvent_ResumeCPU_SaveGame: case SysEvent_ResumeCPU_SaveGame:
if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SaveGame) if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SaveGame)
{ {
SetEvent(m_hPauseEvent); m_hPauseEvent.Trigger();
} }
break; break;
case SysEvent_ResumeCPU_LoadGame: case SysEvent_ResumeCPU_LoadGame:
if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_LoadGame) if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_LoadGame)
{ {
SetEvent(m_hPauseEvent); m_hPauseEvent.Trigger();
} }
break; break;
case SysEvent_ResumeCPU_DumpMemory: case SysEvent_ResumeCPU_DumpMemory:
if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_DumpMemory) if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_DumpMemory)
{ {
SetEvent(m_hPauseEvent); m_hPauseEvent.Trigger();
} }
break; break;
case SysEvent_ResumeCPU_SearchMemory: case SysEvent_ResumeCPU_SearchMemory:
if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SearchMemory) if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SearchMemory)
{ {
SetEvent(m_hPauseEvent); m_hPauseEvent.Trigger();
} }
break; break;
case SysEvent_ResumeCPU_Settings: case SysEvent_ResumeCPU_Settings:
if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Settings) if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Settings)
{ {
SetEvent(m_hPauseEvent); m_hPauseEvent.Trigger();
} }
break; break;
case SysEvent_ResumeCPU_Cheats: case SysEvent_ResumeCPU_Cheats:
if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Cheats) if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Cheats)
{ {
SetEvent(m_hPauseEvent); m_hPauseEvent.Trigger();
} }
break; break;
default: default:
@ -186,13 +181,11 @@ bool CN64System::RunFileImage ( const char * FileLoc )
{ {
return false; return false;
} }
g_Settings->SaveBool(GameRunning_LoadingInProgress,true);
WriteTrace(TraceDebug,__FUNCTION__ ": Mark Rom as loading");
//Mark the rom as loading //Mark the rom as loading
WriteTrace(TraceDebug, __FUNCTION__ ": Mark Rom as loading");
g_Settings->SaveString(Game_File, "");
g_Settings->SaveBool(GameRunning_LoadingInProgress, true); g_Settings->SaveBool(GameRunning_LoadingInProgress, true);
Notify().RefreshMenu();
//Try to load the passed N64 rom //Try to load the passed N64 rom
if (g_Rom == NULL) if (g_Rom == NULL)
@ -210,12 +203,8 @@ bool CN64System::RunFileImage ( const char * FileLoc )
{ {
g_System->RefreshGameSettings(); g_System->RefreshGameSettings();
WriteTrace(TraceDebug,__FUNCTION__ ": Add Recent Rom"); g_Settings->SaveString(Game_File, FileLoc);
Notify().AddRecentRom(FileLoc);
Notify().SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str());
g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
Notify().RefreshMenu();
if (g_Settings->LoadDword(Setting_AutoStart) != 0) if (g_Settings->LoadDword(Setting_AutoStart) != 0)
{ {
@ -233,7 +222,6 @@ bool CN64System::RunFileImage ( const char * FileLoc )
delete g_Rom; delete g_Rom;
g_Rom = NULL; g_Rom = NULL;
g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
Notify().RefreshMenu();
return false; return false;
} }
return true; return true;
@ -249,7 +237,7 @@ void CN64System::CloseSystem()
} }
} }
bool CN64System::EmulationStarting ( HANDLE hThread, DWORD ThreadId ) bool CN64System::EmulationStarting(void * hThread, uint32_t ThreadId)
{ {
bool bRes = true; bool bRes = true;
@ -260,7 +248,6 @@ bool CN64System::EmulationStarting ( HANDLE hThread, DWORD ThreadId )
g_BaseSystem->m_CPU_ThreadID = ThreadId; g_BaseSystem->m_CPU_ThreadID = ThreadId;
WriteTrace(TraceDebug, __FUNCTION__ ": Setting up N64 system done"); WriteTrace(TraceDebug, __FUNCTION__ ": Setting up N64 system done");
g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
Notify().RefreshMenu();
try try
{ {
WriteTrace(TraceDebug, __FUNCTION__ ": Game set to auto start, starting"); WriteTrace(TraceDebug, __FUNCTION__ ": Game set to auto start, starting");
@ -269,10 +256,7 @@ bool CN64System::EmulationStarting ( HANDLE hThread, DWORD ThreadId )
} }
catch (...) catch (...)
{ {
WriteTraceF(TraceError,__FUNCTION__ ": Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__); g_Notify->DisplayError(stdstr_f(__FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__).ToUTF16().c_str());
char Message[600];
sprintf(Message,__FUNCTION__ ": Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__);
MessageBox(NULL,Message,"Exception",MB_OK);
} }
} }
else else
@ -280,7 +264,6 @@ bool CN64System::EmulationStarting ( HANDLE hThread, DWORD ThreadId )
WriteTrace(TraceError, __FUNCTION__ ": SetActiveSystem failed"); WriteTrace(TraceError, __FUNCTION__ ": SetActiveSystem failed");
g_Notify->DisplayError(__FUNCTIONW__ L": Failed to Initialize N64 System"); g_Notify->DisplayError(__FUNCTIONW__ L": Failed to Initialize N64 System");
g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
Notify().RefreshMenu();
bRes = false; bRes = false;
} }
return bRes; return bRes;
@ -291,19 +274,14 @@ void CN64System::StartEmulation2 ( bool NewThread )
if (NewThread) if (NewThread)
{ {
WriteTrace(TraceDebug, __FUNCTION__ ": Starting"); WriteTrace(TraceDebug, __FUNCTION__ ": Starting");
Notify().HideRomBrowser();
if (bHaveDebugger()) if (bHaveDebugger())
{ {
g_LogOptions.GenerateLog = g_Settings->LoadBool(Debugger_GenerateDebugLog);
LoadLogOptions(&g_LogOptions, FALSE);
StartLog(); StartLog();
} }
CInterpreterCPU::BuildCPU(); CInterpreterCPU::BuildCPU();
DWORD CpuType = g_Settings->LoadDword(Game_CpuType); uint32_t CpuType = g_Settings->LoadDword(Game_CpuType);
if (CpuType == CPU_SyncCores && !g_Settings->LoadBool(Debugger_Enabled)) if (CpuType == CPU_SyncCores && !g_Settings->LoadBool(Debugger_Enabled))
{ {
@ -313,17 +291,15 @@ void CN64System::StartEmulation2 ( bool NewThread )
if (CpuType == CPU_SyncCores) if (CpuType == CPU_SyncCores)
{ {
if (g_Plugins->SyncWindow() == NULL)
{
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
g_Notify->DisplayMessage(5, L"Copy Plugins"); g_Notify->DisplayMessage(5, L"Copy Plugins");
g_Plugins->CopyPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); g_Plugins->CopyPlugins(g_Settings->LoadStringVal(Directory_PluginSync));
#if defined(WINDOWS_UI)
m_SyncWindow = new CMainGui(false);
m_SyncPlugins = new CPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); m_SyncPlugins = new CPlugins(g_Settings->LoadStringVal(Directory_PluginSync));
m_SyncPlugins->SetRenderWindows(m_SyncWindow,m_SyncWindow); m_SyncPlugins->SetRenderWindows(g_Plugins->SyncWindow(), NULL);
m_SyncCPU = new CN64System(m_SyncPlugins, true); m_SyncCPU = new CN64System(m_SyncPlugins, true);
#else
g_Notify -> BreakPoint(__FILEW__, __LINE__);
#endif
} }
if (CpuType == CPU_Recompiler || CpuType == CPU_SyncCores) if (CpuType == CPU_Recompiler || CpuType == CPU_SyncCores)
@ -346,41 +322,17 @@ void CN64System::StartEmulation2 ( bool NewThread )
{ {
g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT); g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT);
Notify().RefreshMenu();
Notify().ShowRomBrowser();
} }
else
Notify().MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop)); {
StartEmulationThead();
ThreadInfo * Info = new ThreadInfo; }
HANDLE * hThread = new HANDLE;
*hThread = NULL;
//create the needed info into a structure to pass as one parameter
//for creating a thread
Info->ThreadHandle = hThread;
*hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)StartEmulationThread,Info,0, &Info->ThreadID);
} }
else else
{ {
//mark the emulation as starting and fix up menus //mark the emulation as starting and fix up menus
g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED);
if (g_Settings->LoadBool(Setting_AutoFullscreen))
{
WriteTrace(TraceDebug,__FUNCTION__ " 15");
CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
stdstr Status = g_Settings->LoadStringVal(Rdb_Status);
char String[100];
RomIniFile.GetString("Rom Status",stdstr_f("%s.AutoFullScreen", Status.c_str()).c_str(),"true",String,sizeof(String));
if (_stricmp(String,"true") == 0)
{
Notify().ChangeFullScreen();
}
}
ExecuteCPU(); ExecuteCPU();
} }
} }
@ -393,121 +345,25 @@ void CN64System::StartEmulation ( bool NewThread )
} }
__except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation())) __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation()))
{ {
char Message[600]; wchar_t message[400];
sprintf(Message,"Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__); swprintf(message, sizeof(message), L"Exception caught\nFile: %s\nLine: %d", __FILEW__, __LINE__);
MessageBox(NULL,Message,"Exception",MB_OK); g_Notify->DisplayError(message);
} }
} }
void CN64System::StartEmulationThread ( ThreadInfo * Info )
{
CoInitialize(NULL);
EmulationStarting(*Info->ThreadHandle,Info->ThreadID);
delete Info->ThreadHandle;
delete Info;
CoUninitialize();
}
void CN64System::CloseCpu()
{
if (m_CPU_Handle == NULL)
{
return;
}
m_EndEmulation = true;
if (g_Settings->LoadBool(GameRunning_CPU_Paused))
{
SetEvent(m_hPauseEvent);
}
if (GetCurrentThreadId() == m_CPU_ThreadID)
{
ExternalEvent(SysEvent_CloseCPU);
return;
}
HANDLE hThread = m_CPU_Handle;
for (int count = 0; count < 200; count ++ )
{
Sleep(100);
if (Notify().ProcessGuiMessages())
{
return;
}
DWORD ExitCode;
if (GetExitCodeThread(hThread,&ExitCode))
{
if (ExitCode != STILL_ACTIVE)
{
break;
}
}
}
if (hThread)
{
DWORD ExitCode;
GetExitCodeThread(hThread,&ExitCode);
if (ExitCode == STILL_ACTIVE)
{
TerminateThread(hThread,0);
}
}
CpuStopped();
}
void CN64System::DisplayRomInfo ( HWND hParent )
{
if (!g_Rom) { return; }
RomInformation Info(g_Rom);
Info.DisplayInformation(hParent);
}
void CN64System::Pause() void CN64System::Pause()
{ {
if (m_EndEmulation) if (m_EndEmulation)
{ {
return; return;
} }
ResetEvent(m_hPauseEvent); m_hPauseEvent.Reset();
g_Settings->SaveBool(GameRunning_CPU_Paused, true); g_Settings->SaveBool(GameRunning_CPU_Paused, true);
Notify().RefreshMenu();
g_Notify->DisplayMessage(5, MSG_CPU_PAUSED); g_Notify->DisplayMessage(5, MSG_CPU_PAUSED);
WaitForSingleObject(m_hPauseEvent, INFINITE); m_hPauseEvent.IsTriggered(SyncEvent::INFINITE_TIMEOUT);
ResetEvent(m_hPauseEvent); m_hPauseEvent.Reset();
g_Settings->SaveBool(GameRunning_CPU_Paused,(DWORD)false); g_Settings->SaveBool(GameRunning_CPU_Paused, (uint32_t)false);
Notify().RefreshMenu(); g_Notify->DisplayMessage(5, MSG_CPU_RESUMED);
Notify().DisplayMessage(5, MSG_CPU_RESUMED);
}
stdstr CN64System::ChooseFileToOpen ( HWND hParent )
{
OPENFILENAME openfilename;
char FileName[_MAX_PATH],Directory[_MAX_PATH];
memset(&FileName, 0, sizeof(FileName));
memset(&openfilename, 0, sizeof(openfilename));
strcpy(Directory,g_Settings->LoadStringVal(Directory_Game).c_str());
openfilename.lStructSize = sizeof( openfilename );
openfilename.hwndOwner = (HWND)hParent;
openfilename.lpstrFilter = "N64 ROMs (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
openfilename.lpstrFile = FileName;
openfilename.lpstrInitialDir = Directory;
openfilename.nMaxFile = MAX_PATH;
openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if (GetOpenFileName (&openfilename))
{
return stdstr(FileName);
}
return stdstr("");
} }
void CN64System::GameReset() void CN64System::GameReset()
@ -543,7 +399,6 @@ void CN64System::PluginReset()
} }
} }
} }
Notify().RefreshMenu();
if (m_Recomp) if (m_Recomp)
{ {
m_Recomp->Reset(); m_Recomp->Reset();
@ -889,12 +744,11 @@ void CN64System::InitRegisters( bool bPostPif, CMipsMemory & MMU )
void CN64System::ExecuteCPU() void CN64System::ExecuteCPU()
{ {
//reset code //reset code
g_Settings->SaveBool(GameRunning_CPU_Running,true);
g_Settings->SaveBool(GameRunning_CPU_Paused, false); g_Settings->SaveBool(GameRunning_CPU_Paused, false);
g_Settings->SaveBool(GameRunning_CPU_Running, true);
g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED);
m_EndEmulation = false; m_EndEmulation = false;
Notify().RefreshMenu();
m_Plugins->RomOpened(); m_Plugins->RomOpened();
if (m_SyncCPU) if (m_SyncCPU)
@ -914,8 +768,7 @@ void CN64System::ExecuteCPU()
#endif #endif
default: ExecuteInterpret(); break; default: ExecuteInterpret(); break;
} }
g_Settings->SaveBool(GameRunning_CPU_Running,(DWORD)false); g_Settings->SaveBool(GameRunning_CPU_Running, (uint32_t)false);
Notify().WindowMode();
m_Plugins->RomClosed(); m_Plugins->RomClosed();
if (m_SyncCPU) if (m_SyncCPU)
{ {
@ -936,37 +789,24 @@ void CN64System::ExecuteRecompiler()
void CN64System::ExecuteSyncCPU() void CN64System::ExecuteSyncCPU()
{ {
Notify().BringToTop();
m_Recomp->Run(); m_Recomp->Run();
} }
void CN64System::CpuStopped() void CN64System::CpuStopped()
{ {
g_Settings->SaveBool(GameRunning_CPU_Running,(DWORD)false);
Notify().WindowMode();
if (!m_InReset) if (!m_InReset)
{ {
if (m_hPauseEvent) g_Settings->SaveBool(GameRunning_CPU_Running, (uint32_t)false);
{
CloseHandle(m_hPauseEvent);
m_hPauseEvent = NULL;
}
Notify().RefreshMenu();
Notify().MakeWindowOnTop(false);
g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED); g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED);
if (g_Settings->LoadDword(RomBrowser_Enabled))
{
Notify().ShowRomBrowser();
}
} }
if (m_SyncCPU) if (m_SyncCPU)
{ {
m_SyncCPU->CpuStopped(); m_SyncCPU->CpuStopped();
} }
m_CPU_Handle = NULL;
} }
void CN64System::UpdateSyncCPU (CN64System * const SecondCPU, DWORD const Cycles) void CN64System::UpdateSyncCPU(CN64System * const SecondCPU, uint32_t const Cycles)
{ {
int CyclesToExecute = Cycles - m_CyclesToSkip; int CyclesToExecute = Cycles - m_CyclesToSkip;
@ -1093,7 +933,7 @@ void CN64System::SyncCPU (CN64System * const SecondCPU)
if (bFastSP() && m_Recomp) if (bFastSP() && m_Recomp)
{ {
if (m_Recomp->MemoryStackPos() != (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))) if (m_Recomp->MemoryStackPos() != (uint32_t)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF)))
{ {
ErrorFound = true; ErrorFound = true;
} }
@ -1252,7 +1092,7 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU)
if (m_NextTimer != SecondCPU->m_NextTimer) if (m_NextTimer != SecondCPU->m_NextTimer)
{ {
Error.LogF("Current Time: %X %X\r\n",(DWORD)m_NextTimer,(DWORD)SecondCPU->m_NextTimer); Error.LogF("Current Time: %X %X\r\n", (uint32_t)m_NextTimer, (uint32_t)SecondCPU->m_NextTimer);
} }
m_TLB.RecordDifference(Error, SecondCPU->m_TLB); m_TLB.RecordDifference(Error, SecondCPU->m_TLB);
m_SystemTimer.RecordDifference(Error, SecondCPU->m_SystemTimer); m_SystemTimer.RecordDifference(Error, SecondCPU->m_SystemTimer);
@ -1262,13 +1102,13 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU)
} }
if (bFastSP() && m_Recomp) if (bFastSP() && m_Recomp)
{ {
if (m_Recomp->MemoryStackPos() != (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))) if (m_Recomp->MemoryStackPos() != (uint32_t)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF)))
{ {
Error.LogF("MemoryStack = %X should be: %X\r\n",m_Recomp->MemoryStackPos(), (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))); Error.LogF("MemoryStack = %X should be: %X\r\n", m_Recomp->MemoryStackPos(), (uint32_t)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF)));
} }
} }
DWORD * Rdram = (DWORD *)m_MMU_VM.Rdram(), * Rdram2 = (DWORD *)SecondCPU->m_MMU_VM.Rdram(); uint32_t * Rdram = (uint32_t *)m_MMU_VM.Rdram(), *Rdram2 = (uint32_t *)SecondCPU->m_MMU_VM.Rdram();
for (int z = 0, n = (RdramSize() >> 2); z < n; z++) for (int z = 0, n = (RdramSize() >> 2); z < n; z++)
{ {
if (Rdram[z] != Rdram2[z]) if (Rdram[z] != Rdram2[z])
@ -1277,7 +1117,7 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU)
} }
} }
DWORD * Imem = (DWORD *)m_MMU_VM.Imem(), * Imem2 = (DWORD *)SecondCPU->m_MMU_VM.Imem(); uint32_t * Imem = (uint32_t *)m_MMU_VM.Imem(), *Imem2 = (uint32_t *)SecondCPU->m_MMU_VM.Imem();
for (int z = 0; z < (0x1000 >> 2); z++) for (int z = 0; z < (0x1000 >> 2); z++)
{ {
if (Imem[z] != Imem2[z]) if (Imem[z] != Imem2[z])
@ -1285,7 +1125,7 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU)
Error.LogF("Imem[%X]: %X %X\r\n", z << 2, Imem[z], Imem2[z]); Error.LogF("Imem[%X]: %X %X\r\n", z << 2, Imem[z], Imem2[z]);
} }
} }
DWORD * Dmem = (DWORD *)m_MMU_VM.Dmem(), * Dmem2 = (DWORD *)SecondCPU->m_MMU_VM.Dmem(); uint32_t * Dmem = (uint32_t *)m_MMU_VM.Dmem(), *Dmem2 = (uint32_t *)SecondCPU->m_MMU_VM.Dmem();
for (int z = 0; z < (0x1000 >> 2); z++) for (int z = 0; z < (0x1000 >> 2); z++)
{ {
if (Dmem[z] != Dmem2[z]) if (Dmem[z] != Dmem2[z])
@ -1363,23 +1203,21 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU)
Error.Log("Code at PC:\r\n"); Error.Log("Code at PC:\r\n");
for (count = -10; count < 10; count++) for (count = -10; count < 10; count++)
{ {
DWORD OpcodeValue, Addr = m_Reg.m_PROGRAM_COUNTER + (count << 2); uint32_t OpcodeValue, Addr = m_Reg.m_PROGRAM_COUNTER + (count << 2);
if (g_MMU->LW_VAddr(Addr,(uint32_t &)OpcodeValue)) if (g_MMU->LW_VAddr(Addr, OpcodeValue))
{ {
Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr)); Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr));
} }
} }
Error.Log("\r\n"); Error.Log("\r\n");
Error.Log("Code at Last Sync PC:\r\n"); Error.Log("Code at Last Sync PC:\r\n");
for (count = 0; count < 50; count++) for (count = 0; count < 50; count++)
{ {
DWORD OpcodeValue, Addr = m_LastSuccessSyncPC[0] + (count << 2); uint32_t OpcodeValue, Addr = m_LastSuccessSyncPC[0] + (count << 2);
if (g_MMU->LW_VAddr(Addr,(uint32_t &)OpcodeValue)) if (g_MMU->LW_VAddr(Addr, OpcodeValue))
{ {
Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr)); Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr));
} }
} }
} }
@ -1450,10 +1288,10 @@ bool CN64System::SaveState()
} }
} }
DWORD dwWritten, SaveID_0 = 0x23D8A6C8, SaveID_1 = 0x56D2CD23; uint32_t SaveID_0 = 0x23D8A6C8, SaveID_1 = 0x56D2CD23;
DWORD RdramSize = g_Settings->LoadDword(Game_RDRamSize); uint32_t RdramSize = g_Settings->LoadDword(Game_RDRamSize);
DWORD MiInterReg = g_Reg->MI_INTR_REG; uint32_t MiInterReg = g_Reg->MI_INTR_REG;
DWORD NextViTimer = m_SystemTimer.GetTimer(CSystemTimer::ViTimer); uint32_t NextViTimer = m_SystemTimer.GetTimer(CSystemTimer::ViTimer);
if (g_Settings->LoadDword(Setting_AutoZipInstantSave)) if (g_Settings->LoadDword(Setting_AutoZipInstantSave))
{ {
zipFile file; zipFile file;
@ -1461,25 +1299,25 @@ bool CN64System::SaveState()
file = zipOpen(FileName.c_str(), 0); file = zipOpen(FileName.c_str(), 0);
zipOpenNewFileInZip(file, CurrentSaveName.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION); zipOpenNewFileInZip(file, CurrentSaveName.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION);
zipWriteInFileInZip(file, &SaveID_0, sizeof(SaveID_0)); zipWriteInFileInZip(file, &SaveID_0, sizeof(SaveID_0));
zipWriteInFileInZip(file,&RdramSize,sizeof(DWORD)); zipWriteInFileInZip(file, &RdramSize, sizeof(uint32_t));
zipWriteInFileInZip(file, g_Rom->GetRomAddress(), 0x40); zipWriteInFileInZip(file, g_Rom->GetRomAddress(), 0x40);
zipWriteInFileInZip(file,&NextViTimer,sizeof(DWORD)); zipWriteInFileInZip(file, &NextViTimer, sizeof(uint32_t));
zipWriteInFileInZip(file, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER)); zipWriteInFileInZip(file, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER));
zipWriteInFileInZip(file,m_Reg.m_GPR,sizeof(__int64)*32); zipWriteInFileInZip(file, m_Reg.m_GPR, sizeof(int64_t) * 32);
zipWriteInFileInZip(file,m_Reg.m_FPR,sizeof(__int64)*32); zipWriteInFileInZip(file, m_Reg.m_FPR, sizeof(int64_t) * 32);
zipWriteInFileInZip(file,m_Reg.m_CP0,sizeof(DWORD)*32); zipWriteInFileInZip(file, m_Reg.m_CP0, sizeof(uint32_t) * 32);
zipWriteInFileInZip(file,m_Reg.m_FPCR,sizeof(DWORD)*32); zipWriteInFileInZip(file, m_Reg.m_FPCR, sizeof(uint32_t) * 32);
zipWriteInFileInZip(file,&m_Reg.m_HI,sizeof(__int64)); zipWriteInFileInZip(file, &m_Reg.m_HI, sizeof(int64_t));
zipWriteInFileInZip(file,&m_Reg.m_LO,sizeof(__int64)); zipWriteInFileInZip(file, &m_Reg.m_LO, sizeof(int64_t));
zipWriteInFileInZip(file,m_Reg.m_RDRAM_Registers,sizeof(DWORD)*10); zipWriteInFileInZip(file, m_Reg.m_RDRAM_Registers, sizeof(uint32_t) * 10);
zipWriteInFileInZip(file,m_Reg.m_SigProcessor_Interface,sizeof(DWORD)*10); zipWriteInFileInZip(file, m_Reg.m_SigProcessor_Interface, sizeof(uint32_t) * 10);
zipWriteInFileInZip(file,m_Reg.m_Display_ControlReg,sizeof(DWORD)*10); zipWriteInFileInZip(file, m_Reg.m_Display_ControlReg, sizeof(uint32_t) * 10);
zipWriteInFileInZip(file,m_Reg.m_Mips_Interface,sizeof(DWORD)*4); zipWriteInFileInZip(file, m_Reg.m_Mips_Interface, sizeof(uint32_t) * 4);
zipWriteInFileInZip(file,m_Reg.m_Video_Interface,sizeof(DWORD)*14); zipWriteInFileInZip(file, m_Reg.m_Video_Interface, sizeof(uint32_t) * 14);
zipWriteInFileInZip(file,m_Reg.m_Audio_Interface,sizeof(DWORD)*6); zipWriteInFileInZip(file, m_Reg.m_Audio_Interface, sizeof(uint32_t) * 6);
zipWriteInFileInZip(file,m_Reg.m_Peripheral_Interface,sizeof(DWORD)*13); zipWriteInFileInZip(file, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13);
zipWriteInFileInZip(file,m_Reg.m_RDRAM_Interface,sizeof(DWORD)*8); zipWriteInFileInZip(file, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8);
zipWriteInFileInZip(file,m_Reg.m_SerialInterface,sizeof(DWORD)*4); zipWriteInFileInZip(file, m_Reg.m_SerialInterface, sizeof(uint32_t) * 4);
zipWriteInFileInZip(file, (void *const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); zipWriteInFileInZip(file, (void *const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32);
zipWriteInFileInZip(file, m_MMU_VM.PifRam(), 0x40); zipWriteInFileInZip(file, m_MMU_VM.PifRam(), 0x40);
zipWriteInFileInZip(file, m_MMU_VM.Rdram(), RdramSize); zipWriteInFileInZip(file, m_MMU_VM.Rdram(), RdramSize);
@ -1507,26 +1345,27 @@ bool CN64System::SaveState()
//Write info to file //Write info to file
SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN); SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN);
WriteFile( hSaveFile,&SaveID_0,sizeof(DWORD),&dwWritten,NULL); DWORD dwWritten;
WriteFile( hSaveFile,&RdramSize,sizeof(DWORD),&dwWritten,NULL); WriteFile(hSaveFile, &SaveID_0, sizeof(uint32_t), &dwWritten, NULL);
WriteFile(hSaveFile, &RdramSize, sizeof(uint32_t), &dwWritten, NULL);
WriteFile(hSaveFile, g_Rom->GetRomAddress(), 0x40, &dwWritten, NULL); WriteFile(hSaveFile, g_Rom->GetRomAddress(), 0x40, &dwWritten, NULL);
WriteFile( hSaveFile,&NextViTimer,sizeof(DWORD),&dwWritten,NULL); WriteFile(hSaveFile, &NextViTimer, sizeof(uint32_t), &dwWritten, NULL);
WriteFile(hSaveFile, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER), &dwWritten, NULL); WriteFile(hSaveFile, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER), &dwWritten, NULL);
WriteFile( hSaveFile,m_Reg.m_GPR,sizeof(__int64)*32,&dwWritten,NULL); WriteFile(hSaveFile, m_Reg.m_GPR, sizeof(int64_t) * 32, &dwWritten, NULL);
WriteFile( hSaveFile,m_Reg.m_FPR,sizeof(__int64)*32,&dwWritten,NULL); WriteFile(hSaveFile, m_Reg.m_FPR, sizeof(int64_t) * 32, &dwWritten, NULL);
WriteFile( hSaveFile,m_Reg.m_CP0,sizeof(DWORD)*32,&dwWritten,NULL); WriteFile(hSaveFile, m_Reg.m_CP0, sizeof(uint32_t) * 32, &dwWritten, NULL);
WriteFile( hSaveFile,m_Reg.m_FPCR,sizeof(DWORD)*32,&dwWritten,NULL); WriteFile(hSaveFile, m_Reg.m_FPCR, sizeof(uint32_t) * 32, &dwWritten, NULL);
WriteFile( hSaveFile,&m_Reg.m_HI,sizeof(__int64),&dwWritten,NULL); WriteFile(hSaveFile, &m_Reg.m_HI, sizeof(int64_t), &dwWritten, NULL);
WriteFile( hSaveFile,&m_Reg.m_LO,sizeof(__int64),&dwWritten,NULL); WriteFile(hSaveFile, &m_Reg.m_LO, sizeof(int64_t), &dwWritten, NULL);
WriteFile( hSaveFile,m_Reg.m_RDRAM_Registers,sizeof(DWORD)*10,&dwWritten,NULL); WriteFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(uint32_t) * 10, &dwWritten, NULL);
WriteFile( hSaveFile,m_Reg.m_SigProcessor_Interface,sizeof(DWORD)*10,&dwWritten,NULL); WriteFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(uint32_t) * 10, &dwWritten, NULL);
WriteFile( hSaveFile,m_Reg.m_Display_ControlReg,sizeof(DWORD)*10,&dwWritten,NULL); WriteFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(uint32_t) * 10, &dwWritten, NULL);
WriteFile( hSaveFile,m_Reg.m_Mips_Interface,sizeof(DWORD)*4,&dwWritten,NULL); WriteFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(uint32_t) * 4, &dwWritten, NULL);
WriteFile( hSaveFile,m_Reg.m_Video_Interface,sizeof(DWORD)*14,&dwWritten,NULL); WriteFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(uint32_t) * 14, &dwWritten, NULL);
WriteFile( hSaveFile,m_Reg.m_Audio_Interface,sizeof(DWORD)*6,&dwWritten,NULL); WriteFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(uint32_t) * 6, &dwWritten, NULL);
WriteFile( hSaveFile,m_Reg.m_Peripheral_Interface,sizeof(DWORD)*13,&dwWritten,NULL); WriteFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13, &dwWritten, NULL);
WriteFile( hSaveFile,m_Reg.m_RDRAM_Interface,sizeof(DWORD)*8,&dwWritten,NULL); WriteFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8, &dwWritten, NULL);
WriteFile( hSaveFile,m_Reg.m_SerialInterface,sizeof(DWORD)*4,&dwWritten,NULL); WriteFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(uint32_t) * 4, &dwWritten, NULL);
WriteFile(hSaveFile, &g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32, &dwWritten, NULL); WriteFile(hSaveFile, &g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32, &dwWritten, NULL);
WriteFile(hSaveFile, g_MMU->PifRam(), 0x40, &dwWritten, NULL); WriteFile(hSaveFile, g_MMU->PifRam(), 0x40, &dwWritten, NULL);
WriteFile(hSaveFile, g_MMU->Rdram(), RdramSize, &dwWritten, NULL); WriteFile(hSaveFile, g_MMU->Rdram(), RdramSize, &dwWritten, NULL);
@ -1591,9 +1430,9 @@ bool CN64System::LoadState()
return LoadState(FileName); return LoadState(FileName);
} }
bool CN64System::LoadState(LPCSTR FileName) bool CN64System::LoadState(const char * FileName)
{ {
DWORD dwRead, Value,SaveRDRAMSize, NextVITimer = 0, old_status, old_width, old_dacrate; uint32_t Value, SaveRDRAMSize, NextVITimer = 0, old_status, old_width, old_dacrate;
bool LoadedZipFile = false, AudioResetOnLoad; bool LoadedZipFile = false, AudioResetOnLoad;
old_status = g_Reg->VI_STATUS_REG; old_status = g_Reg->VI_STATUS_REG;
old_width = g_Reg->VI_WIDTH_REG; old_width = g_Reg->VI_WIDTH_REG;
@ -1618,7 +1457,7 @@ bool CN64System::LoadState(LPCSTR FileName)
{ {
port = unzGoToFirstFile(file); port = unzGoToFirstFile(file);
} }
DWORD Value; uint32_t Value;
while (port == UNZ_OK) while (port == UNZ_OK)
{ {
unz_file_info info; unz_file_info info;
@ -1649,7 +1488,7 @@ bool CN64System::LoadState(LPCSTR FileName)
unzReadCurrentFile(file, &SaveRDRAMSize, sizeof(SaveRDRAMSize)); unzReadCurrentFile(file, &SaveRDRAMSize, sizeof(SaveRDRAMSize));
//Check header //Check header
BYTE LoadHeader[64]; uint8_t LoadHeader[64];
unzReadCurrentFile(file, LoadHeader, 0x40); unzReadCurrentFile(file, LoadHeader, 0x40);
if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0) if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0)
{ {
@ -1667,21 +1506,21 @@ bool CN64System::LoadState(LPCSTR FileName)
g_Settings->SaveDword(Game_RDRamSize, SaveRDRAMSize); g_Settings->SaveDword(Game_RDRamSize, SaveRDRAMSize);
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_t) * 32);
unzReadCurrentFile(file,m_Reg.m_FPR,sizeof(__int64)*32); unzReadCurrentFile(file, m_Reg.m_FPR, sizeof(int64_t) * 32);
unzReadCurrentFile(file,m_Reg.m_CP0,sizeof(DWORD)*32); unzReadCurrentFile(file, m_Reg.m_CP0, sizeof(uint32_t) * 32);
unzReadCurrentFile(file,m_Reg.m_FPCR,sizeof(DWORD)*32); unzReadCurrentFile(file, m_Reg.m_FPCR, sizeof(uint32_t) * 32);
unzReadCurrentFile(file,&m_Reg.m_HI,sizeof(__int64)); unzReadCurrentFile(file, &m_Reg.m_HI, sizeof(int64_t));
unzReadCurrentFile(file,&m_Reg.m_LO,sizeof(__int64)); unzReadCurrentFile(file, &m_Reg.m_LO, sizeof(int64_t));
unzReadCurrentFile(file,m_Reg.m_RDRAM_Registers,sizeof(DWORD)*10); unzReadCurrentFile(file, m_Reg.m_RDRAM_Registers, sizeof(uint32_t) * 10);
unzReadCurrentFile(file,m_Reg.m_SigProcessor_Interface,sizeof(DWORD)*10); unzReadCurrentFile(file, m_Reg.m_SigProcessor_Interface, sizeof(uint32_t) * 10);
unzReadCurrentFile(file,m_Reg.m_Display_ControlReg,sizeof(DWORD)*10); unzReadCurrentFile(file, m_Reg.m_Display_ControlReg, sizeof(uint32_t) * 10);
unzReadCurrentFile(file,m_Reg.m_Mips_Interface,sizeof(DWORD)*4); unzReadCurrentFile(file, m_Reg.m_Mips_Interface, sizeof(uint32_t) * 4);
unzReadCurrentFile(file,m_Reg.m_Video_Interface,sizeof(DWORD)*14); unzReadCurrentFile(file, m_Reg.m_Video_Interface, sizeof(uint32_t) * 14);
unzReadCurrentFile(file,m_Reg.m_Audio_Interface,sizeof(DWORD)*6); unzReadCurrentFile(file, m_Reg.m_Audio_Interface, sizeof(uint32_t) * 6);
unzReadCurrentFile(file,m_Reg.m_Peripheral_Interface,sizeof(DWORD)*13); unzReadCurrentFile(file, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13);
unzReadCurrentFile(file,m_Reg.m_RDRAM_Interface,sizeof(DWORD)*8); unzReadCurrentFile(file, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8);
unzReadCurrentFile(file,m_Reg.m_SerialInterface,sizeof(DWORD)*4); unzReadCurrentFile(file, m_Reg.m_SerialInterface, sizeof(uint32_t) * 4);
unzReadCurrentFile(file, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); unzReadCurrentFile(file, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32);
unzReadCurrentFile(file, m_MMU_VM.PifRam(), 0x40); unzReadCurrentFile(file, m_MMU_VM.PifRam(), 0x40);
unzReadCurrentFile(file, m_MMU_VM.Rdram(), SaveRDRAMSize); unzReadCurrentFile(file, m_MMU_VM.Rdram(), SaveRDRAMSize);
@ -1712,23 +1551,25 @@ bool CN64System::LoadState(LPCSTR FileName)
} }
SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN); SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN);
DWORD dwRead;
ReadFile(hSaveFile, &Value, sizeof(Value), &dwRead, NULL); ReadFile(hSaveFile, &Value, sizeof(Value), &dwRead, NULL);
if (Value != 0x23D8A6C8) if (Value != 0x23D8A6C8)
return false; return false;
ReadFile(hSaveFile, &SaveRDRAMSize, sizeof(SaveRDRAMSize), &dwRead, NULL); ReadFile(hSaveFile, &SaveRDRAMSize, sizeof(SaveRDRAMSize), &dwRead, NULL);
//Check header //Check header
BYTE LoadHeader[64]; uint8_t LoadHeader[64];
ReadFile(hSaveFile, LoadHeader, 0x40, &dwRead, NULL); ReadFile(hSaveFile, LoadHeader, 0x40, &dwRead, NULL);
if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0) if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0)
{ {
//if (inFullScreen) { return false; } //if (inFullScreen) { return false; }
int result = MessageBoxW(NULL,GS(MSG_SAVE_STATE_HEADER),GS(MSG_MSGBOX_TITLE), int result = MessageBoxW(NULL, GS(MSG_SAVE_STATE_HEADER), GS(MSG_MSGBOX_TITLE), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2);
MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2);
if (result == IDNO) if (result == IDNO)
{
return false; return false;
} }
}
Reset(false, true); Reset(false, true);
m_MMU_VM.UnProtectMemory(0x80000000, 0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4); m_MMU_VM.UnProtectMemory(0x80000000, 0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4);
m_MMU_VM.UnProtectMemory(0xA4000000, 0xA4001FFC); m_MMU_VM.UnProtectMemory(0xA4000000, 0xA4001FFC);
@ -1736,21 +1577,21 @@ bool CN64System::LoadState(LPCSTR FileName)
ReadFile(hSaveFile, &NextVITimer, sizeof(NextVITimer), &dwRead, NULL); ReadFile(hSaveFile, &NextVITimer, sizeof(NextVITimer), &dwRead, NULL);
ReadFile(hSaveFile, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER), &dwRead, NULL); ReadFile(hSaveFile, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER), &dwRead, NULL);
ReadFile( hSaveFile,m_Reg.m_GPR,sizeof(__int64)*32,&dwRead,NULL); ReadFile(hSaveFile, m_Reg.m_GPR, sizeof(int64_t) * 32, &dwRead, NULL);
ReadFile( hSaveFile,m_Reg.m_FPR,sizeof(__int64)*32,&dwRead,NULL); ReadFile(hSaveFile, m_Reg.m_FPR, sizeof(int64_t) * 32, &dwRead, NULL);
ReadFile( hSaveFile,m_Reg.m_CP0,sizeof(DWORD)*32,&dwRead,NULL); ReadFile(hSaveFile, m_Reg.m_CP0, sizeof(uint32_t) * 32, &dwRead, NULL);
ReadFile( hSaveFile,m_Reg.m_FPCR,sizeof(DWORD)*32,&dwRead,NULL); ReadFile(hSaveFile, m_Reg.m_FPCR, sizeof(uint32_t) * 32, &dwRead, NULL);
ReadFile( hSaveFile,&m_Reg.m_HI,sizeof(__int64),&dwRead,NULL); ReadFile(hSaveFile, &m_Reg.m_HI, sizeof(int64_t), &dwRead, NULL);
ReadFile( hSaveFile,&m_Reg.m_LO,sizeof(__int64),&dwRead,NULL); ReadFile(hSaveFile, &m_Reg.m_LO, sizeof(int64_t), &dwRead, NULL);
ReadFile( hSaveFile,m_Reg.m_RDRAM_Registers,sizeof(DWORD)*10,&dwRead,NULL); ReadFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(uint32_t) * 10, &dwRead, NULL);
ReadFile( hSaveFile,m_Reg.m_SigProcessor_Interface,sizeof(DWORD)*10,&dwRead,NULL); ReadFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(uint32_t) * 10, &dwRead, NULL);
ReadFile( hSaveFile,m_Reg.m_Display_ControlReg,sizeof(DWORD)*10,&dwRead,NULL); ReadFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(uint32_t) * 10, &dwRead, NULL);
ReadFile( hSaveFile,m_Reg.m_Mips_Interface,sizeof(DWORD)*4,&dwRead,NULL); ReadFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(uint32_t) * 4, &dwRead, NULL);
ReadFile( hSaveFile,m_Reg.m_Video_Interface,sizeof(DWORD)*14,&dwRead,NULL); ReadFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(uint32_t) * 14, &dwRead, NULL);
ReadFile( hSaveFile,m_Reg.m_Audio_Interface,sizeof(DWORD)*6,&dwRead,NULL); ReadFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(uint32_t) * 6, &dwRead, NULL);
ReadFile( hSaveFile,m_Reg.m_Peripheral_Interface,sizeof(DWORD)*13,&dwRead,NULL); ReadFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13, &dwRead, NULL);
ReadFile( hSaveFile,m_Reg.m_RDRAM_Interface,sizeof(DWORD)*8,&dwRead,NULL); ReadFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8, &dwRead, NULL);
ReadFile( hSaveFile,m_Reg.m_SerialInterface,sizeof(DWORD)*4,&dwRead,NULL); ReadFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(uint32_t) * 4, &dwRead, NULL);
ReadFile(hSaveFile, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32, &dwRead, NULL); ReadFile(hSaveFile, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32, &dwRead, NULL);
ReadFile(hSaveFile, m_MMU_VM.PifRam(), 0x40, &dwRead, NULL); ReadFile(hSaveFile, m_MMU_VM.PifRam(), 0x40, &dwRead, NULL);
ReadFile(hSaveFile, m_MMU_VM.Rdram(), SaveRDRAMSize, &dwRead, NULL); ReadFile(hSaveFile, m_MMU_VM.Rdram(), SaveRDRAMSize, &dwRead, NULL);
@ -1854,10 +1695,10 @@ void CN64System::RunRSP()
{ {
SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfileAddr = Timer_None*/; SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfileAddr = Timer_None*/;
DWORD Task = 0; uint32_t Task = 0;
if (m_RspBroke) if (m_RspBroke)
{ {
g_MMU->LW_VAddr(0xA4000FC0,(uint32_t &)Task); g_MMU->LW_VAddr(0xA4000FC0, Task);
if (Task == 1 && (m_Reg.DPC_STATUS_REG & DPC_STATUS_FREEZE) != 0) if (Task == 1 && (m_Reg.DPC_STATUS_REG & DPC_STATUS_FREEZE) != 0)
{ {
WriteTrace(TraceRSP, __FUNCTION__ ": Dlist that is frozen"); WriteTrace(TraceRSP, __FUNCTION__ ": Dlist that is frozen");
@ -1896,7 +1737,6 @@ void CN64System::RunRSP()
} }
} }
__try __try
{ {
WriteTrace(TraceRSP, __FUNCTION__ ": do cycles - starting"); WriteTrace(TraceRSP, __FUNCTION__ ": do cycles - starting");
@ -1952,7 +1792,7 @@ void CN64System::SyncToAudio()
WriteTraceF(TraceAudio, __FUNCTION__ ": Audio Interrupt done (%d)", i); WriteTraceF(TraceAudio, __FUNCTION__ ": Audio Interrupt done (%d)", i);
break; break;
} }
Sleep(1); pjutil::Sleep(1);
} }
if (bShowCPUPer()) if (bShowCPUPer())
{ {
@ -1963,7 +1803,7 @@ void CN64System::SyncToAudio()
void CN64System::RefreshScreen() void CN64System::RefreshScreen()
{ {
SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfilingAddr = Timer_None*/; SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfilingAddr = Timer_None*/;
DWORD VI_INTR_TIME = 500000; uint32_t VI_INTR_TIME = 500000;
if (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RefreshScreen); } if (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RefreshScreen); }
//if (bProfiling) { ProfilingAddr = m_Profile.StartTimer(Timer_RefreshScreen); } //if (bProfiling) { ProfilingAddr = m_Profile.StartTimer(Timer_RefreshScreen); }
@ -2012,7 +1852,6 @@ void CN64System::RefreshScreen()
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Exception caught"); WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Exception caught");
WriteTrace(TraceError, __FUNCTION__ ": Exception caught"); WriteTrace(TraceError, __FUNCTION__ ": Exception caught");
} }
g_MMU->UpdateFieldSerration((m_Reg.VI_STATUS_REG & 0x40) != 0); g_MMU->UpdateFieldSerration((m_Reg.VI_STATUS_REG & 0x40) != 0);
if ((bBasicMode() || bLimitFPS()) && !bSyncToAudio()) if ((bBasicMode() || bLimitFPS()) && !bSyncToAudio())

View File

@ -10,9 +10,12 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <Common/SyncEvent.h>
#include <Project64\Logging.h>
typedef std::list<SystemEvent> EVENT_LIST; typedef std::list<SystemEvent> EVENT_LIST;
typedef std::map<DWORD, DWORD> FUNC_CALLS; typedef std::map<uint32_t, uint32_t> FUNC_CALLS;
class CPlugins; class CPlugins;
class CRSP_Plugin; class CRSP_Plugin;
@ -21,6 +24,7 @@ class CRecompiler;
//#define TEST_SP_TRACKING //track the SP to make sure all ops pick it up fine //#define TEST_SP_TRACKING //track the SP to make sure all ops pick it up fine
class CN64System : class CN64System :
public CLogging,
public CMipsMemory_CallBack, public CMipsMemory_CallBack,
public CTLB_CB, public CTLB_CB,
private CSystemEvents, private CSystemEvents,
@ -32,11 +36,6 @@ public:
CN64System(CPlugins * Plugins, bool SavesReadOnly); CN64System(CPlugins * Plugins, bool SavesReadOnly);
virtual ~CN64System(void); virtual ~CN64System(void);
struct ThreadInfo {
HANDLE * ThreadHandle;
DWORD ThreadID;
};
CProfiling m_Profile; CProfiling m_Profile;
CCheats m_Cheats; CCheats m_Cheats;
bool m_EndEmulation; bool m_EndEmulation;
@ -48,8 +47,6 @@ public:
void CloseCpu(); void CloseCpu();
void ExternalEvent(SystemEvent action); //covers gui interacting and timers etc.. void ExternalEvent(SystemEvent action); //covers gui interacting and timers etc..
stdstr ChooseFileToOpen ( HWND hParent );
void DisplayRomInfo ( HWND hParent );
void StartEmulation(bool NewThread); void StartEmulation(bool NewThread);
void SyncToAudio(); void SyncToAudio();
void IncreaseSpeed() { m_Limitor.IncreaseSpeed(); } void IncreaseSpeed() { m_Limitor.IncreaseSpeed(); }
@ -61,21 +58,21 @@ public:
void Pause(); void Pause();
void RunRSP(); void RunRSP();
bool SaveState(); bool SaveState();
bool LoadState ( LPCSTR FileName ); bool LoadState(const char * FileName);
bool LoadState(); bool LoadState();
bool DmaUsed() const { return m_DMAUsed; } bool DmaUsed() const { return m_DMAUsed; }
void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; } void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; }
void SetCheatsSlectionChanged(bool changed) { m_CheatsSlectionChanged = changed; } void SetCheatsSlectionChanged(bool changed) { m_CheatsSlectionChanged = changed; }
bool HasCheatsSlectionChanged(void) const { return m_CheatsSlectionChanged; } bool HasCheatsSlectionChanged(void) const { return m_CheatsSlectionChanged; }
DWORD GetButtons(int Control) const { return m_Buttons[Control]; } uint32_t GetButtons(int32_t Control) const { return m_Buttons[Control]; }
//Variable used to track that the SP is being handled and stays the same as the real SP in sync core //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 #ifdef TEST_SP_TRACKING
DWORD m_CurrentSP; uint32_t m_CurrentSP;
#endif #endif
//For Sync CPU //For Sync CPU
void UpdateSyncCPU ( CN64System * const SecondCPU, DWORD const Cycles ); void UpdateSyncCPU(CN64System * const SecondCPU, uint32_t const Cycles);
void SyncCPU(CN64System * const SecondCPU); void SyncCPU(CN64System * const SecondCPU);
void SyncCPUPC(CN64System * const SecondCPU); void SyncCPUPC(CN64System * const SecondCPU);
void SyncSystem(); void SyncSystem();
@ -91,8 +88,15 @@ private:
friend CSystemTimer; friend CSystemTimer;
//Used for loading and potentially executing the CPU in its own thread. //Used for loading and potentially executing the CPU in its own thread.
struct ThreadInfo
{
void * ThreadHandle;
uint32_t ThreadID;
};
static void StartEmulationThread(ThreadInfo * Info); static void StartEmulationThread(ThreadInfo * Info);
static bool EmulationStarting ( HANDLE hThread, DWORD ThreadId ); static bool EmulationStarting(void * hThread, uint32_t ThreadId);
static void StartEmulationThead();
void ExecuteCPU(); void ExecuteCPU();
void RefreshScreen(); void RefreshScreen();
@ -111,7 +115,7 @@ private:
void CpuStopped(); void CpuStopped();
//Function in CMipsMemory_CallBack //Function in CMipsMemory_CallBack
virtual bool WriteToProtectedMemory(uint32_t Address, int length); virtual bool WriteToProtectedMemory(uint32_t Address, int32_t length);
//Functions in CTLB_CB //Functions in CTLB_CB
void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly); void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly);
@ -121,7 +125,6 @@ private:
CPlugins * const m_Plugins; //The plugin container CPlugins * const m_Plugins; //The plugin container
CN64System * m_SyncCPU; CN64System * m_SyncCPU;
CPlugins * m_SyncPlugins; CPlugins * m_SyncPlugins;
CMainGui * m_SyncWindow;
CMipsMemoryVM m_MMU_VM; //Memory of the n64 CMipsMemoryVM m_MMU_VM; //Memory of the n64
CTLB m_TLB; CTLB m_TLB;
CRegisters m_Reg; CRegisters m_Reg;
@ -131,34 +134,34 @@ private:
CAudio m_Audio; CAudio m_Audio;
CSpeedLimitor m_Limitor; CSpeedLimitor m_Limitor;
bool m_InReset; bool m_InReset;
int m_NextTimer; int32_t m_NextTimer;
CSystemTimer m_SystemTimer; CSystemTimer m_SystemTimer;
bool m_bCleanFrameBox; bool m_bCleanFrameBox;
bool m_bInitialized; bool m_bInitialized;
bool m_RspBroke; bool m_RspBroke;
bool m_DMAUsed; bool m_DMAUsed;
DWORD m_Buttons[4]; uint32_t m_Buttons[4];
bool m_TestTimer; bool m_TestTimer;
DWORD m_NextInstruction; uint32_t m_NextInstruction;
DWORD m_JumpToLocation; uint32_t m_JumpToLocation;
uint32_t m_TLBLoadAddress; uint32_t m_TLBLoadAddress;
uint32_t m_TLBStoreAddress; uint32_t m_TLBStoreAddress;
DWORD m_SyncCount; uint32_t m_SyncCount;
bool m_CheatsSlectionChanged; bool m_CheatsSlectionChanged;
//When Syncing cores this is the PC where it last Sync'ed correctly //When Syncing cores this is the PC where it last Sync'ed correctly
DWORD m_LastSuccessSyncPC[10]; uint32_t m_LastSuccessSyncPC[10];
int m_CyclesToSkip; int32_t m_CyclesToSkip;
//Handle to the cpu thread //Handle to the cpu thread
HANDLE m_CPU_Handle; void * m_CPU_Handle;
DWORD m_CPU_ThreadID; uint32_t m_CPU_ThreadID;
//Handle to pause mutex //Handle to pause mutex
void * m_hPauseEvent; SyncEvent m_hPauseEvent;
//No of Alist and Dlist sent to the RSP //No of Alist and Dlist sent to the RSP
DWORD m_AlistCount, m_DlistCount, m_UnknownCount; uint32_t m_AlistCount, m_DlistCount, m_UnknownCount;
//list of function that have been called .. used in profiling //list of function that have been called .. used in profiling
FUNC_CALLS m_FunctionCalls; FUNC_CALLS m_FunctionCalls;

View File

@ -28,7 +28,8 @@ CN64Rom::~CN64Rom()
UnallocateRomImage(); UnallocateRomImage();
} }
bool CN64Rom::AllocateAndLoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) { bool CN64Rom::AllocateAndLoadN64Image(const char * FileLoc, bool LoadBootCodeOnly)
{
//Try to open the target file //Try to open the target file
HANDLE hFile = CreateFile(FileLoc, GENERIC_READ, FILE_SHARE_READ, NULL, HANDLE hFile = CreateFile(FileLoc, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,
@ -36,11 +37,12 @@ bool CN64Rom::AllocateAndLoadN64Image ( const char * FileLoc, bool LoadBootCodeO
if (hFile == INVALID_HANDLE_VALUE) { return false; } if (hFile == INVALID_HANDLE_VALUE) { return false; }
//Read the first 4 bytes and make sure it is a valid n64 image //Read the first 4 bytes and make sure it is a valid n64 image
DWORD dwRead; BYTE Test[4]; DWORD dwRead; uint8_t Test[4];
SetFilePointer(hFile, 0, 0, FILE_BEGIN); SetFilePointer(hFile, 0, 0, FILE_BEGIN);
ReadFile(hFile, Test, 4, &dwRead, NULL); ReadFile(hFile, Test, 4, &dwRead, NULL);
if (!IsValidRomImage(Test)) { if (!IsValidRomImage(Test))
{
CloseHandle(hFile); CloseHandle(hFile);
return false; return false;
} }
@ -50,8 +52,9 @@ bool CN64Rom::AllocateAndLoadN64Image ( const char * FileLoc, bool LoadBootCodeO
//if loading boot code then just load the first 0x1000 bytes //if loading boot code then just load the first 0x1000 bytes
if (LoadBootCodeOnly) { RomFileSize = 0x1000; } if (LoadBootCodeOnly) { RomFileSize = 0x1000; }
BYTE * Image = (BYTE *)VirtualAlloc(NULL,RomFileSize,MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); uint8_t * Image = (uint8_t *)VirtualAlloc(NULL, RomFileSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if (Image == NULL) { if (Image == NULL)
{
SetError(MSG_MEM_ALLOC_ERROR); SetError(MSG_MEM_ALLOC_ERROR);
CloseHandle(hFile); CloseHandle(hFile);
return false; return false;
@ -62,11 +65,13 @@ bool CN64Rom::AllocateAndLoadN64Image ( const char * FileLoc, bool LoadBootCodeO
SetFilePointer(hFile, 0, 0, FILE_BEGIN); SetFilePointer(hFile, 0, 0, FILE_BEGIN);
DWORD count, TotalRead = 0; DWORD count, TotalRead = 0;
for (count = 0; count < (int)RomFileSize; count += ReadFromRomSection) { for (count = 0; count < (int)RomFileSize; count += ReadFromRomSection)
{
DWORD dwToRead = RomFileSize - count; DWORD dwToRead = RomFileSize - count;
if (dwToRead > ReadFromRomSection) { dwToRead = ReadFromRomSection; } if (dwToRead > ReadFromRomSection) { dwToRead = ReadFromRomSection; }
if (!ReadFile(hFile,&Image[count],dwToRead,&dwRead,NULL)) { if (!ReadFile(hFile, &Image[count], dwToRead, &dwRead, NULL))
{
VirtualFree(Image, 0, MEM_RELEASE); VirtualFree(Image, 0, MEM_RELEASE);
CloseHandle(hFile); CloseHandle(hFile);
SetError(MSG_FAIL_IMAGE); SetError(MSG_FAIL_IMAGE);
@ -79,7 +84,8 @@ bool CN64Rom::AllocateAndLoadN64Image ( const char * FileLoc, bool LoadBootCodeO
} }
dwRead = TotalRead; dwRead = TotalRead;
if (RomFileSize != dwRead) { if (RomFileSize != dwRead)
{
VirtualFree(Image, 0, MEM_RELEASE); VirtualFree(Image, 0, MEM_RELEASE);
CloseHandle(hFile); CloseHandle(hFile);
SetError(MSG_FAIL_IMAGE); SetError(MSG_FAIL_IMAGE);
@ -101,40 +107,49 @@ bool CN64Rom::AllocateAndLoadN64Image ( const char * FileLoc, bool LoadBootCodeO
return true; return true;
} }
bool CN64Rom::AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnly) { bool CN64Rom::AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnly)
{
unzFile file = unzOpen(FileLoc); unzFile file = unzOpen(FileLoc);
if (file == NULL) if (file == NULL)
{
return false; return false;
}
int port = unzGoToFirstFile(file); int port = unzGoToFirstFile(file);
bool FoundRom = false; bool FoundRom = false;
//scan through all files in zip to a suitable file is found //scan through all files in zip to a suitable file is found
while(port == UNZ_OK && !FoundRom) { while (port == UNZ_OK && !FoundRom)
{
unz_file_info info; unz_file_info info;
char zname[_MAX_PATH]; char zname[_MAX_PATH];
unzGetCurrentFileInfo(file, &info, zname, sizeof(zname), NULL, 0, NULL, 0); unzGetCurrentFileInfo(file, &info, zname, sizeof(zname), NULL, 0, NULL, 0);
if (unzLocateFile(file, zname, 1) != UNZ_OK ) { if (unzLocateFile(file, zname, 1) != UNZ_OK)
{
SetError(MSG_FAIL_ZIP); SetError(MSG_FAIL_ZIP);
break; break;
} }
if( unzOpenCurrentFile(file) != UNZ_OK ) { if (unzOpenCurrentFile(file) != UNZ_OK)
{
SetError(MSG_FAIL_ZIP); SetError(MSG_FAIL_ZIP);
break; break;
} }
//Read the first 4 bytes to check magic number //Read the first 4 bytes to check magic number
BYTE Test[4]; uint8_t Test[4];
unzReadCurrentFile(file, Test, sizeof(Test)); unzReadCurrentFile(file, Test, sizeof(Test));
if (IsValidRomImage(Test)) { if (IsValidRomImage(Test))
{
//Get the size of the rom and try to allocate the memory needed. //Get the size of the rom and try to allocate the memory needed.
DWORD RomFileSize = info.uncompressed_size; DWORD RomFileSize = info.uncompressed_size;
if (LoadBootCodeOnly) { if (LoadBootCodeOnly)
{
RomFileSize = 0x1000; RomFileSize = 0x1000;
} }
BYTE * Image = (BYTE *)VirtualAlloc(NULL,RomFileSize,MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); uint8_t * Image = (uint8_t *)VirtualAlloc(NULL, RomFileSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if (Image == NULL) { if (Image == NULL)
{
SetError(MSG_MEM_ALLOC_ERROR); SetError(MSG_MEM_ALLOC_ERROR);
unzCloseCurrentFile(file); unzCloseCurrentFile(file);
break; break;
@ -145,12 +160,14 @@ bool CN64Rom::AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnl
memcpy(Image, Test, 4); memcpy(Image, Test, 4);
DWORD dwRead, count, TotalRead = 0; DWORD dwRead, count, TotalRead = 0;
for (count = 4; count < (int)RomFileSize; count += ReadFromRomSection) { for (count = 4; count < (int)RomFileSize; count += ReadFromRomSection)
{
DWORD dwToRead = RomFileSize - count; DWORD dwToRead = RomFileSize - count;
if (dwToRead > ReadFromRomSection) { dwToRead = ReadFromRomSection; } if (dwToRead > ReadFromRomSection) { dwToRead = ReadFromRomSection; }
dwRead = unzReadCurrentFile(file, &Image[count], dwToRead); dwRead = unzReadCurrentFile(file, &Image[count], dwToRead);
if (dwRead == 0) { if (dwRead == 0)
{
SetError(MSG_FAIL_ZIP); SetError(MSG_FAIL_ZIP);
VirtualFree(Image, 0, MEM_RELEASE); VirtualFree(Image, 0, MEM_RELEASE);
unzCloseCurrentFile(file); unzCloseCurrentFile(file);
@ -163,7 +180,8 @@ bool CN64Rom::AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnl
} }
dwRead = TotalRead + 4; dwRead = TotalRead + 4;
if (RomFileSize != dwRead) { if (RomFileSize != dwRead)
{
VirtualFree(Image, 0, MEM_RELEASE); VirtualFree(Image, 0, MEM_RELEASE);
unzCloseCurrentFile(file); unzCloseCurrentFile(file);
SetError(MSG_FAIL_ZIP); SetError(MSG_FAIL_ZIP);
@ -188,19 +206,24 @@ bool CN64Rom::AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnl
unzCloseCurrentFile(file); unzCloseCurrentFile(file);
if (!FoundRom) if (!FoundRom)
{
port = unzGoToNextFile(file); port = unzGoToNextFile(file);
} }
}
unzClose(file); unzClose(file);
return FoundRom; return FoundRom;
} }
void CN64Rom::ByteSwapRom() { void CN64Rom::ByteSwapRom()
{
DWORD count; DWORD count;
switch (*((DWORD *)&m_ROMImage[0])) { switch (*((DWORD *)&m_ROMImage[0]))
{
case 0x12408037: case 0x12408037:
for( count = 0 ; count < m_RomFileSize; count += 4 ) { for (count = 0; count < m_RomFileSize; count += 4)
{
m_ROMImage[count] ^= m_ROMImage[count + 2]; m_ROMImage[count] ^= m_ROMImage[count + 2];
m_ROMImage[count + 2] ^= m_ROMImage[count]; m_ROMImage[count + 2] ^= m_ROMImage[count];
m_ROMImage[count] ^= m_ROMImage[count + 2]; m_ROMImage[count] ^= m_ROMImage[count + 2];
@ -211,7 +234,8 @@ void CN64Rom::ByteSwapRom() {
break; break;
case 0x40072780: //64DD IPL case 0x40072780: //64DD IPL
case 0x40123780: case 0x40123780:
for( count = 0 ; count < m_RomFileSize; count += 4 ) { for (count = 0; count < m_RomFileSize; count += 4)
{
m_ROMImage[count] ^= m_ROMImage[count + 3]; m_ROMImage[count] ^= m_ROMImage[count + 3];
m_ROMImage[count + 3] ^= m_ROMImage[count]; m_ROMImage[count + 3] ^= m_ROMImage[count];
m_ROMImage[count] ^= m_ROMImage[count + 3]; m_ROMImage[count] ^= m_ROMImage[count + 3];
@ -228,7 +252,7 @@ void CN64Rom::ByteSwapRom() {
void CN64Rom::CalculateCicChip() void CN64Rom::CalculateCicChip()
{ {
__int64 CRC = 0; int64_t CRC = 0;
if (m_ROMImage == NULL) if (m_ROMImage == NULL)
{ {
@ -236,7 +260,8 @@ void CN64Rom::CalculateCicChip()
return; return;
} }
for (int count = 0x40; count < 0x1000; count += 4) { for (int count = 0x40; count < 0x1000; count += 4)
{
CRC += *(DWORD *)(m_ROMImage + count); CRC += *(DWORD *)(m_ROMImage + count);
} }
switch (CRC) { switch (CRC) {
@ -255,7 +280,6 @@ void CN64Rom::CalculateCicChip()
} }
m_CicChip = CIC_UNKNOWN; break; m_CicChip = CIC_UNKNOWN; break;
} }
} }
void CN64Rom::CalculateRomCrc() void CN64Rom::CalculateRomCrc()
@ -274,7 +298,8 @@ void CN64Rom::CalculateRomCrc()
// 64DD IPL at=0x02E90EDD , s6=0xdd // 64DD IPL at=0x02E90EDD , s6=0xdd
//v0 = 0xFFFFFFFF & (0x3F * at) + 1; //v0 = 0xFFFFFFFF & (0x3F * at) + 1;
switch (m_CicChip){ switch (m_CicChip)
{
case CIC_NUS_6101: case CIC_NUS_6101:
case CIC_NUS_6102: v0 = 0xF8CA4DDC; break; case CIC_NUS_6102: v0 = 0xF8CA4DDC; break;
case CIC_NUS_6103: v0 = 0xA3886759; break; case CIC_NUS_6103: v0 = 0xA3886759; break;
@ -298,7 +323,8 @@ void CN64Rom::CalculateRomCrc()
a2 = v0; a2 = v0;
t4 = v0; t4 = v0;
for (t0 = 0; t0 < 0x00100000; t0 += 4){ for (t0 = 0; t0 < 0x00100000; t0 += 4)
{
v0 = *(DWORD *)(m_ROMImage + t0 + 0x1000); v0 = *(DWORD *)(m_ROMImage + t0 + 0x1000);
v1 = a3 + v0; v1 = a3 + v0;
@ -316,20 +342,24 @@ void CN64Rom::CalculateRomCrc()
if (a2 < v0) a2 = a3 ^ v0 ^ a2; if (a2 < v0) a2 = a3 ^ v0 ^ a2;
else a2 = a2 ^ a0; else a2 = a2 ^ a0;
if (m_CicChip == CIC_NUS_6105){ if (m_CicChip == CIC_NUS_6105)
{
t4 = (v0 ^ (*(DWORD *)(m_ROMImage + (0xFF & t0) + 0x750))) + t4; t4 = (v0 ^ (*(DWORD *)(m_ROMImage + (0xFF & t0) + 0x750))) + t4;
} }
else t4 = (v0 ^ s0) + t4; else t4 = (v0 ^ s0) + t4;
} }
if (m_CicChip == CIC_NUS_6103){ if (m_CicChip == CIC_NUS_6103)
{
a3 = (a3 ^ t2) + t3; a3 = (a3 ^ t2) + t3;
s0 = (s0 ^ a2) + t4; s0 = (s0 ^ a2) + t4;
} }
else if (m_CicChip == CIC_NUS_6106){ else if (m_CicChip == CIC_NUS_6106)
{
a3 = 0xFFFFFFFF & (a3 * t2) + t3; a3 = 0xFFFFFFFF & (a3 * t2) + t3;
s0 = 0xFFFFFFFF & (s0 * a2) + t4; s0 = 0xFFFFFFFF & (s0 * a2) + t4;
} }
else { else
{
a3 = a3 ^ t2 ^ t3; a3 = a3 ^ t2 ^ t3;
s0 = s0 ^ a2 ^ t4; s0 = s0 ^ a2 ^ t4;
} }
@ -345,7 +375,8 @@ CICChip CN64Rom::CicChipID()
return m_CicChip; return m_CicChip;
} }
bool CN64Rom::IsValidRomImage ( BYTE Test[4] ) { bool CN64Rom::IsValidRomImage(uint8_t Test[4])
{
if (*((DWORD *)&Test[0]) == 0x40123780) { return true; } if (*((DWORD *)&Test[0]) == 0x40123780) { return true; }
if (*((DWORD *)&Test[0]) == 0x12408037) { return true; } if (*((DWORD *)&Test[0]) == 0x12408037) { return true; }
if (*((DWORD *)&Test[0]) == 0x80371240) { return true; } if (*((DWORD *)&Test[0]) == 0x80371240) { return true; }
@ -358,7 +389,8 @@ void CN64Rom::NotificationCB ( LPCWSTR Status, CN64Rom * /*_this*/ )
g_Notify->DisplayMessage(5, stdstr_f("%s", Status).ToUTF16().c_str()); g_Notify->DisplayMessage(5, stdstr_f("%s", Status).ToUTF16().c_str());
} }
bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) { bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly)
{
UnallocateRomImage(); UnallocateRomImage();
m_ErrorMsg = EMPTY_STRING; m_ErrorMsg = EMPTY_STRING;
@ -378,7 +410,9 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
//Pop up a dialog and select file //Pop up a dialog and select file
//allocate memory for sub name and copy selected file name to var //allocate memory for sub name and copy selected file name to var
//return false; //remove once dialog is done //return false; //remove once dialog is done
} else { }
else
{
*SubFile = '\0'; *SubFile = '\0';
SubFile += 1; SubFile += 1;
} }
@ -408,8 +442,9 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
//if loading boot code then just load the first 0x1000 bytes //if loading boot code then just load the first 0x1000 bytes
if (LoadBootCodeOnly) { RomFileSize = 0x1000; } if (LoadBootCodeOnly) { RomFileSize = 0x1000; }
BYTE * Image = (BYTE *)VirtualAlloc(NULL,RomFileSize,MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); uint8_t * Image = (uint8_t *)VirtualAlloc(NULL, RomFileSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if (Image == NULL) { if (Image == NULL)
{
SetError(MSG_MEM_ALLOC_ERROR); SetError(MSG_MEM_ALLOC_ERROR);
return false; return false;
} }
@ -454,8 +489,10 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
//Try to open the file as a zip file //Try to open the file as a zip file
if (!Loaded7zFile) if (!Loaded7zFile)
{ {
if (!AllocateAndLoadZipImage(FileLoc,LoadBootCodeOnly)) { if (!AllocateAndLoadZipImage(FileLoc, LoadBootCodeOnly))
if (m_ErrorMsg != EMPTY_STRING) { {
if (m_ErrorMsg != EMPTY_STRING)
{
return false; return false;
} }
@ -466,7 +503,8 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
//Create a file map //Create a file map
HANDLE hFileMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); HANDLE hFileMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
if (hFileMapping == NULL) { if (hFileMapping == NULL)
{
CloseHandle(hFile); CloseHandle(hFile);
SetError(MSG_FAIL_OPEN_IMAGE); SetError(MSG_FAIL_OPEN_IMAGE);
return false; return false;
@ -474,15 +512,17 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
//Map the file to a memory pointer .. ie a way of pretending to load the rom //Map the file to a memory pointer .. ie a way of pretending to load the rom
//loose the bonus of being able to flip it on the fly tho. //loose the bonus of being able to flip it on the fly tho.
BYTE * Image = (PBYTE)MapViewOfFile(hFileMapping,FILE_MAP_READ,0,0,0); uint8_t * Image = (PBYTE)MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0);
if (Image == NULL) { if (Image == NULL)
{
CloseHandle(hFileMapping); CloseHandle(hFileMapping);
CloseHandle(hFile); CloseHandle(hFile);
SetError(MSG_FAIL_OPEN_IMAGE); SetError(MSG_FAIL_OPEN_IMAGE);
return false; return false;
} }
if (!IsValidRomImage(Image)) { if (!IsValidRomImage(Image))
{
UnmapViewOfFile(Image); UnmapViewOfFile(Image);
CloseHandle(hFileMapping); CloseHandle(hFileMapping);
CloseHandle(hFile); CloseHandle(hFile);
@ -490,12 +530,15 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
return false; return false;
} }
if (*((DWORD *)Image) == 0x80371240) { if (*((DWORD *)Image) == 0x80371240)
{
m_hRomFile = hFile; m_hRomFile = hFile;
m_hRomFileMapping = hFileMapping; m_hRomFileMapping = hFileMapping;
m_ROMImage = Image; m_ROMImage = Image;
m_RomFileSize = GetFileSize(hFile, NULL); m_RomFileSize = GetFileSize(hFile, NULL);
} else { }
else
{
if (!AllocateAndLoadN64Image(FileLoc, LoadBootCodeOnly)) { return false; } if (!AllocateAndLoadN64Image(FileLoc, LoadBootCodeOnly)) { return false; }
} }
} }
@ -505,7 +548,8 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
int count; int count;
//Get the header from the rom image //Get the header from the rom image
memcpy(&RomName[0], (void *)(m_ROMImage + 0x20), 20); memcpy(&RomName[0], (void *)(m_ROMImage + 0x20), 20);
for( count = 0 ; count < 20; count += 4 ) { for (count = 0; count < 20; count += 4)
{
RomName[count] ^= RomName[count + 3]; RomName[count] ^= RomName[count + 3];
RomName[count + 3] ^= RomName[count]; RomName[count + 3] ^= RomName[count];
RomName[count] ^= RomName[count + 3]; RomName[count] ^= RomName[count + 3];
@ -515,24 +559,33 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
} }
//truncate all the spaces at the end of the string //truncate all the spaces at the end of the string
for( count = 19 ; count >= 0; count -- ) { for (count = 19; count >= 0; count--)
if (RomName[count] == ' ') { {
if (RomName[count] == ' ')
{
RomName[count] = '\0'; RomName[count] = '\0';
} else if (RomName[count] == '\0') { }
} else { else if (RomName[count] == '\0')
{
}
else
{
count = -1; count = -1;
} }
} }
RomName[20] = '\0'; RomName[20] = '\0';
if (strlen(RomName) == 0) { if (strlen(RomName) == 0)
{
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];
_splitpath(FileLoc, drive, dir, fname, ext); _splitpath(FileLoc, drive, dir, fname, ext);
strcpy(RomName, fname); strcpy(RomName, fname);
} }
//remove all /,\,: from the string //remove all /,\,: from the string
for( count = 0 ; count < (int)strlen(RomName); count ++ ) { for (count = 0; count < (int)strlen(RomName); count++)
switch (RomName[count]) { {
switch (RomName[count])
{
case '/': case '\\': RomName[count] = '-'; break; case '/': case '\\': RomName[count] = '-'; break;
case ':': RomName[count] = ';'; break; case ':': RomName[count] = ';'; break;
} }
@ -542,7 +595,8 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
m_FileName = FileLoc; m_FileName = FileLoc;
m_MD5 = ""; m_MD5 = "";
if (!LoadBootCodeOnly) { if (!LoadBootCodeOnly)
{
//Calculate files MD5 //Calculate files MD5
m_MD5 = MD5((const unsigned char *)m_ROMImage, m_RomFileSize).hex_digest(); m_MD5 = MD5((const unsigned char *)m_ROMImage, m_RomFileSize).hex_digest();
} }
@ -553,6 +607,7 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
if (!LoadBootCodeOnly && g_Rom == this) if (!LoadBootCodeOnly && g_Rom == this)
{ {
g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
SaveRomSettingID(false); SaveRomSettingID(false);
} }
@ -599,20 +654,23 @@ void CN64Rom::SetError(LanguageStringID ErrorMsg)
void CN64Rom::UnallocateRomImage() void CN64Rom::UnallocateRomImage()
{ {
if (m_hRomFileMapping) { if (m_hRomFileMapping)
{
UnmapViewOfFile(m_ROMImage); UnmapViewOfFile(m_ROMImage);
CloseHandle(m_hRomFileMapping); CloseHandle(m_hRomFileMapping);
m_ROMImage = NULL; m_ROMImage = NULL;
m_hRomFileMapping = NULL; m_hRomFileMapping = NULL;
} }
if (m_hRomFile) { if (m_hRomFile)
{
CloseHandle(m_hRomFile); CloseHandle(m_hRomFile);
m_hRomFile = NULL; m_hRomFile = NULL;
} }
//if this value is still set then the image was not created a map //if this value is still set then the image was not created a map
//file but created with VirtualAllocate //file but created with VirtualAllocate
if (m_ROMImage) { if (m_ROMImage)
{
VirtualFree(m_ROMImage, 0, MEM_RELEASE); VirtualFree(m_ROMImage, 0, MEM_RELEASE);
m_ROMImage = NULL; m_ROMImage = NULL;
} }

View File

@ -19,9 +19,9 @@ class CN64Rom :
enum { ReadFromRomSection = 0x400000 }; enum { ReadFromRomSection = 0x400000 };
//class variables //class variables
HANDLE m_hRomFile, m_hRomFileMapping; void * m_hRomFile, *m_hRomFileMapping;
BYTE * m_ROMImage; uint8_t * m_ROMImage;
DWORD m_RomFileSize; uint32_t m_RomFileSize;
Country m_Country; Country m_Country;
CICChip m_CicChip; CICChip m_CicChip;
LanguageStringID m_ErrorMsg; LanguageStringID m_ErrorMsg;
@ -31,7 +31,7 @@ class CN64Rom :
bool AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnly); bool AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnly);
void ByteSwapRom(); void ByteSwapRom();
void SetError(LanguageStringID ErrorMsg); void SetError(LanguageStringID ErrorMsg);
static void __stdcall NotificationCB ( LPCWSTR Status, CN64Rom * _this ); static void __stdcall NotificationCB(const wchar_t * Status, CN64Rom * _this);
void CalculateCicChip(); void CalculateCicChip();
void CalculateRomCrc(); void CalculateRomCrc();
@ -40,12 +40,12 @@ public:
~CN64Rom(); ~CN64Rom();
bool LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly = false); bool LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly = false);
static bool IsValidRomImage( BYTE Test[4] ); static bool IsValidRomImage(uint8_t Test[4]);
void SaveRomSettingID(bool temp); void SaveRomSettingID(bool temp);
void ClearRomSettingID(); void ClearRomSettingID();
CICChip CicChipID(); CICChip CicChipID();
BYTE * GetRomAddress () { return m_ROMImage; } uint8_t * GetRomAddress() { return m_ROMImage; }
DWORD GetRomSize () const { return m_RomFileSize; } uint32_t GetRomSize() const { return m_RomFileSize; }
stdstr GetRomMD5() const { return m_MD5; } stdstr GetRomMD5() const { return m_MD5; }
stdstr GetRomName() const { return m_RomName; } stdstr GetRomName() const { return m_RomName; }
stdstr GetFileName() const { return m_FileName; } stdstr GetFileName() const { return m_FileName; }

View File

@ -9,6 +9,7 @@
* * * *
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include "N64 Types.h"
typedef std::map<SPECIAL_TIMERS, __int64 > PROFILE_ENRTIES; typedef std::map<SPECIAL_TIMERS, __int64 > PROFILE_ENRTIES;
typedef PROFILE_ENRTIES::iterator PROFILE_ENRTY; typedef PROFILE_ENRTIES::iterator PROFILE_ENRTY;

View File

@ -9,6 +9,16 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include "Code Section.h"
#include <Project64\N64 System\Mips\OpCode.h>
#include <Project64\N64 System\System Globals.h>
#include <Project64\N64 System\Mips\Memory Class.h>
#include <Project64\N64 System\Recompiler\x86CodeLog.h>
#include <Project64\N64 System\Recompiler\Code Block.h>
#include <Project64\N64 System\N64 Class.h>
#include <Project64\N64 System\Interpreter\Interpreter CPU.h>
#include <Project64\N64 System\Recompiler\Loop Analysis.h>
#include <Project64\N64 System\Recompiler\Section Info.h>
void InPermLoop(); void InPermLoop();
@ -442,6 +452,7 @@ void CCodeSection::GenerateSectionLinkage()
// if (g_SyncSystem) { // if (g_SyncSystem) {
MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX); MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX);
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
//}
// MoveConstToVariable(DELAY_SLOT,&m_NextInstruction,"m_NextInstruction"); // MoveConstToVariable(DELAY_SLOT,&m_NextInstruction,"m_NextInstruction");
PushImm32(stdstr_f("0x%08X",CompilePC() + 4).c_str(),CompilePC() + 4); PushImm32(stdstr_f("0x%08X",CompilePC() + 4).c_str(),CompilePC() + 4);

View File

@ -10,6 +10,8 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <Project64\Settings\N64System Settings.h>
#include <Project64\Settings\Recompiler Settings.h>
class CCodeSection; class CCodeSection;

View File

@ -10,7 +10,7 @@
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
unsigned int CRegInfo::m_fpuControl = 0; uint32_t CRegInfo::m_fpuControl = 0;
char *Format_Name[] = { "Unknown", "dword", "qword", "float", "double" }; char *Format_Name[] = { "Unknown", "dword", "qword", "float", "double" };
@ -470,10 +470,7 @@ CX86Ops::x86Reg CRegInfo::Free8BitX86Reg()
if (GetX86Mapped(x86_ECX) == NotMapped && !GetX86Protected(x86_ECX)) { return x86_ECX; } if (GetX86Mapped(x86_ECX) == NotMapped && !GetX86Protected(x86_ECX)) { return x86_ECX; }
x86Reg Reg = UnMap_8BitTempReg(); x86Reg Reg = UnMap_8BitTempReg();
if (Reg > 0) if (Reg > 0) { return Reg; }
{
return Reg;
}
int32_t count, MapCount[10], MapReg[10]; int32_t count, MapCount[10], MapReg[10];
for (count = 0; count < 10; count++) for (count = 0; count < 10; count++)

View File

@ -10,6 +10,8 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include "../Settings/Game Settings.h"
class CSpeedLimitor : class CSpeedLimitor :
private CGameSettings private CGameSettings
{ {

View File

@ -51,7 +51,7 @@ bool CAudioPlugin::LoadFunctions(void)
return true; return true;
} }
bool CAudioPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window)
{ {
struct AUDIO_INFO struct AUDIO_INFO
{ {
@ -88,7 +88,7 @@ bool CAudioPlugin::Initiate(CN64System * System, CMainGui * RenderWindow)
AUDIO_INFO Info = { 0 }; AUDIO_INFO Info = { 0 };
Info.hwnd = (HWND)RenderWindow->m_hMainWindow;; Info.hwnd = (HWND)Window->GetWindowHandle();
Info.hinst = GetModuleHandle(NULL); Info.hinst = GetModuleHandle(NULL);
Info.MemoryBswaped = TRUE; Info.MemoryBswaped = TRUE;
Info.CheckInterrupts = DummyCheckInterrupts; Info.CheckInterrupts = DummyCheckInterrupts;
@ -182,6 +182,10 @@ void CAudioPlugin::DacrateChanged(SYSTEM_TYPE Type)
void CAudioPlugin::AudioThread(CAudioPlugin * _this) { void CAudioPlugin::AudioThread(CAudioPlugin * _this) {
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
if (g_Settings->LoadBool(Setting_CN64TimeCritical))
{
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_HIGHEST);
}
for (;;) for (;;)
{ {
_this->AiUpdate(true); _this->AiUpdate(true);

View File

@ -9,6 +9,7 @@
* * * *
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include "Plugin Base.h"
class CAudioPlugin : public CPlugin class CAudioPlugin : public CPlugin
{ {
@ -17,7 +18,7 @@ public:
~CAudioPlugin(); ~CAudioPlugin();
void DacrateChanged(SYSTEM_TYPE Type); void DacrateChanged(SYSTEM_TYPE Type);
bool Initiate(CN64System * System, CMainGui * RenderWindow); bool Initiate(CN64System * System, RenderWindow * Window);
void(__cdecl *AiLenChanged)(void); void(__cdecl *AiLenChanged)(void);
uint32_t(__cdecl *AiReadLength)(void); uint32_t(__cdecl *AiReadLength)(void);

View File

@ -58,7 +58,7 @@ bool CControl_Plugin::LoadFunctions(void)
return true; return true;
} }
bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window)
{ {
CONTROL_INFO ControlInfo; CONTROL_INFO ControlInfo;
uint8_t Buffer[100]; uint8_t Buffer[100];
@ -75,7 +75,7 @@ bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow)
ControlInfo.Controls = m_PluginControllers; ControlInfo.Controls = m_PluginControllers;
ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress()); ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress());
ControlInfo.hinst = GetModuleHandle(NULL); ControlInfo.hinst = GetModuleHandle(NULL);
ControlInfo.hMainWindow = (HWND)RenderWindow->m_hMainWindow; ControlInfo.hMainWindow = Window ? (HWND)Window->GetWindowHandle() : NULL;
ControlInfo.MemoryBswaped = TRUE; ControlInfo.MemoryBswaped = TRUE;
} }
@ -86,8 +86,7 @@ bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow)
void(__cdecl *InitiateControllers_1_0)(HWND hMainWindow, CONTROL Controls[4]); void(__cdecl *InitiateControllers_1_0)(HWND hMainWindow, CONTROL Controls[4]);
InitiateControllers_1_0 = (void(__cdecl *)(HWND, CONTROL *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); InitiateControllers_1_0 = (void(__cdecl *)(HWND, CONTROL *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers");
if (InitiateControllers_1_0 == NULL) { return false; } if (InitiateControllers_1_0 == NULL) { return false; }
InitiateControllers_1_0((HWND)Window->GetWindowHandle(), m_PluginControllers);
InitiateControllers_1_0((HWND)RenderWindow->m_hMainWindow, m_PluginControllers);
m_Initialized = true; m_Initialized = true;
} }
else if (m_PluginInfo.Version == 0x0101) else if (m_PluginInfo.Version == 0x0101)
@ -173,7 +172,7 @@ void CControl_Plugin::SetControl(CControl_Plugin const * const Plugin)
} }
} }
CCONTROL::CCONTROL(uint32_t &Present, uint32_t &RawData, int32_t &PlugType) : CCONTROL::CCONTROL(int32_t &Present, int32_t &RawData, int32_t &PlugType) :
m_Present(Present), m_RawData(RawData), m_PlugType(PlugType) m_Present(Present), m_RawData(RawData), m_PlugType(PlugType)
{ {
m_Buttons.Value = 0; m_Buttons.Value = 0;

View File

@ -9,6 +9,7 @@
* * * *
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include "Plugin Base.h"
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union #pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union
@ -45,8 +46,8 @@ typedef union
typedef struct typedef struct
{ {
uint32_t Present; int32_t Present;
uint32_t RawData; int32_t RawData;
int32_t Plugin; int32_t Plugin;
} CONTROL; } CONTROL;
@ -74,15 +75,15 @@ class CControl_Plugin;
class CCONTROL class CCONTROL
{ {
public: public:
CCONTROL(uint32_t &Present, uint32_t &RawData, int32_t &PlugType); CCONTROL(int32_t &Present, int32_t &RawData, int32_t &PlugType);
inline bool Present(void) const { return m_Present != 0; } inline bool Present(void) const { return m_Present != 0; }
inline uint32_t Buttons(void) const { return m_Buttons.Value; } inline uint32_t Buttons(void) const { return m_Buttons.Value; }
inline PluginType Plugin(void) const { return static_cast<PluginType>(m_PlugType); } inline PluginType Plugin(void) const { return static_cast<PluginType>(m_PlugType); }
private: private:
friend CControl_Plugin; //controller plugin class has full access friend CControl_Plugin; //controller plugin class has full access
uint32_t & m_Present; int32_t & m_Present;
uint32_t & m_RawData; int32_t & m_RawData;
int32_t & m_PlugType; int32_t & m_PlugType;
BUTTONS m_Buttons; BUTTONS m_Buttons;
@ -97,7 +98,7 @@ public:
CControl_Plugin(void); CControl_Plugin(void);
~CControl_Plugin(); ~CControl_Plugin();
bool Initiate(CN64System * System, CMainGui * RenderWindow); bool Initiate(CN64System * System, RenderWindow * Window);
void SetControl(CControl_Plugin const * const Plugin); void SetControl(CControl_Plugin const * const Plugin);
void UpdateKeys(void); void UpdateKeys(void);

View File

@ -93,7 +93,7 @@ bool CGfxPlugin::LoadFunctions(void)
return true; return true;
} }
bool CGfxPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window)
{ {
if (m_Initialized) if (m_Initialized)
{ {
@ -153,8 +153,8 @@ bool CGfxPlugin::Initiate(CN64System * System, CMainGui * RenderWindow)
GFX_INFO Info = { 0 }; GFX_INFO Info = { 0 };
Info.MemoryBswaped = TRUE; Info.MemoryBswaped = TRUE;
Info.hWnd = (HWND)RenderWindow->m_hMainWindow; Info.hWnd = (HWND)Window->GetWindowHandle();
Info.hStatusBar = (HWND)RenderWindow->m_hStatusWnd; Info.hStatusBar = (HWND)Window->GetStatusBar();
Info.CheckInterrupts = DummyCheckInterrupts; Info.CheckInterrupts = DummyCheckInterrupts;
// We are initializing the plugin before any rom is loaded so we do not have any correct // We are initializing the plugin before any rom is loaded so we do not have any correct

View File

@ -9,6 +9,7 @@
* * * *
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include "Plugin Base.h"
class CGfxPlugin : public CPlugin class CGfxPlugin : public CPlugin
{ {
@ -52,7 +53,7 @@ public:
~CGfxPlugin(); ~CGfxPlugin();
bool LoadFunctions(void); bool LoadFunctions(void);
bool Initiate(CN64System * System, CMainGui * RenderWindow); bool Initiate(CN64System * System, RenderWindow * Window);
void(__cdecl *CaptureScreen) (const char *); void(__cdecl *CaptureScreen) (const char *);
void(__cdecl *ChangeWindow) (void); void(__cdecl *ChangeWindow) (void);

View File

@ -71,7 +71,7 @@ bool CPlugin::Load (const char * FileName)
RomOpen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomOpen" ); RomOpen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomOpen" );
RomClosed = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomClosed" ); RomClosed = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomClosed" );
PluginOpened = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "PluginLoaded" ); PluginOpened = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "PluginLoaded" );
DllConfig = (void (__cdecl *)(uint32_t)) GetProcAddress( (HMODULE)m_hDll, "DllConfig" ); DllConfig = (void (__cdecl *)(void *)) GetProcAddress( (HMODULE)m_hDll, "DllConfig" );
DllAbout = (void (__cdecl *)(void *)) GetProcAddress( (HMODULE)m_hDll, "DllAbout" ); DllAbout = (void (__cdecl *)(void *)) GetProcAddress( (HMODULE)m_hDll, "DllAbout" );
SetSettingInfo3 = (void (__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo3" ); SetSettingInfo3 = (void (__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo3" );

View File

@ -30,7 +30,7 @@ public:
void Close(); void Close();
void(__cdecl *DllAbout) (void * hWnd); void(__cdecl *DllAbout) (void * hWnd);
void(__cdecl *DllConfig) (uint32_t hParent); void(__cdecl *DllConfig) (void * hParent);
static bool ValidPluginVersion ( PLUGIN_INFO & PluginInfo ); static bool ValidPluginVersion ( PLUGIN_INFO & PluginInfo );

View File

@ -9,9 +9,12 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include <Common\path.h>
#include "Plugin Class.h"
CPlugins::CPlugins(const stdstr & PluginDir) : CPlugins::CPlugins(const stdstr & PluginDir) :
m_RenderWindow(NULL), m_DummyWindow(NULL), m_MainWindow(NULL),
m_SyncWindow(NULL),
m_PluginDir(PluginDir), m_PluginDir(PluginDir),
m_Gfx(NULL), m_Gfx(NULL),
m_Audio(NULL), m_Audio(NULL),
@ -215,10 +218,10 @@ void CPlugins::DestroyControlPlugin(void)
// g_Settings->UnknownSetting_CTRL = NULL; // g_Settings->UnknownSetting_CTRL = NULL;
} }
void CPlugins::SetRenderWindows( CMainGui * RenderWindow, CMainGui * DummyWindow ) void CPlugins::SetRenderWindows(RenderWindow * MainWindow, RenderWindow * SyncWindow)
{ {
m_RenderWindow = RenderWindow; m_MainWindow = MainWindow;
m_DummyWindow = DummyWindow; m_SyncWindow = SyncWindow;
} }
void CPlugins::RomOpened(void) void CPlugins::RomOpened(void)
@ -247,13 +250,13 @@ bool CPlugins::Initiate(CN64System * System)
if (m_Control == NULL) { return false; } if (m_Control == NULL) { return false; }
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Starting"); WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Starting");
if (!m_Gfx->Initiate(System,m_RenderWindow)) { return false; } if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; }
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Done"); WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Done");
WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Starting"); WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Starting");
if (!m_Audio->Initiate(System,m_RenderWindow)) { return false; } if (!m_Audio->Initiate(System, m_MainWindow)) { return false; }
WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Done"); WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Done");
WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Starting"); WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Starting");
if (!m_Control->Initiate(System,m_RenderWindow)) { return false; } if (!m_Control->Initiate(System, m_MainWindow)) { return false; }
WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done"); WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done");
WriteTrace(TraceRSP, __FUNCTION__ ": RSP Initiate Starting"); WriteTrace(TraceRSP, __FUNCTION__ ": RSP Initiate Starting");
if (!m_RSP->Initiate(this, System)) { return false; } if (!m_RSP->Initiate(this, System)) { return false; }
@ -264,12 +267,7 @@ bool CPlugins::Initiate(CN64System * System)
bool CPlugins::ResetInUiThread(CN64System * System) bool CPlugins::ResetInUiThread(CN64System * System)
{ {
#if defined(WINDOWS_UI) return m_MainWindow->ResetPluginsInUiThread(this, System);
return m_RenderWindow->ResetPlugins(this, System);
#else
g_Notify -> BreakPoint(__FILEW__, __LINE__);
return false;
#endif
} }
bool CPlugins::Reset(CN64System * System) bool CPlugins::Reset(CN64System * System)
@ -295,19 +293,19 @@ bool CPlugins::Reset(CN64System * System)
if (m_Gfx && bGfxChange) if (m_Gfx && bGfxChange)
{ {
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Starting"); WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Starting");
if (!m_Gfx->Initiate(System,m_RenderWindow)) { return false; } if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; }
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Done"); WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Done");
} }
if (m_Audio && bAudioChange) if (m_Audio && bAudioChange)
{ {
WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Starting"); WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Starting");
if (!m_Audio->Initiate(System,m_RenderWindow)) { return false; } if (!m_Audio->Initiate(System, m_MainWindow)) { return false; }
WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Done"); WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Done");
} }
if (m_Control && bContChange) if (m_Control && bContChange)
{ {
WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Starting"); WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Starting");
if (!m_Control->Initiate(System,m_RenderWindow)) { return false; } if (!m_Control->Initiate(System, m_MainWindow)) { return false; }
WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done"); WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done");
} }
if (m_RSP && bRspChange) if (m_RSP && bRspChange)
@ -320,7 +318,7 @@ bool CPlugins::Reset(CN64System * System)
return true; return true;
} }
void CPlugins::ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type) void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type)
{ {
switch (Type) switch (Type)
{ {
@ -328,7 +326,7 @@ void CPlugins::ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type)
if (m_RSP == NULL || m_RSP->DllConfig == NULL) { break; } if (m_RSP == NULL || m_RSP->DllConfig == NULL) { break; }
if (!m_RSP->Initialized()) if (!m_RSP->Initialized())
{ {
if (!m_RSP->Initiate(NULL, NULL)) if (!m_RSP->Initiate(this, NULL))
{ {
break; break;
} }
@ -339,7 +337,7 @@ void CPlugins::ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type)
if (m_Gfx == NULL || m_Gfx->DllConfig == NULL) { break; } if (m_Gfx == NULL || m_Gfx->DllConfig == NULL) { break; }
if (!m_Gfx->Initialized()) if (!m_Gfx->Initialized())
{ {
if (!m_Gfx->Initiate(NULL, NULL)) if (!m_Gfx->Initiate(NULL, m_MainWindow))
{ {
break; break;
} }
@ -350,7 +348,7 @@ void CPlugins::ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type)
if (m_Audio == NULL || m_Audio->DllConfig == NULL) { break; } if (m_Audio == NULL || m_Audio->DllConfig == NULL) { break; }
if (!m_Audio->Initialized()) if (!m_Audio->Initialized())
{ {
if (!m_Audio->Initiate(NULL, NULL)) if (!m_Audio->Initiate(NULL, m_MainWindow))
{ {
break; break;
} }
@ -361,7 +359,7 @@ void CPlugins::ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type)
if (m_Control == NULL || m_Control->DllConfig == NULL) { break; } if (m_Control == NULL || m_Control->DllConfig == NULL) { break; }
if (!m_Control->Initialized()) if (!m_Control->Initialized())
{ {
if (!m_Control->Initiate(NULL, NULL)) if (!m_Control->Initiate(NULL, m_MainWindow))
{ {
break; break;
} }

View File

@ -10,7 +10,7 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <list> #include <list>
#include <Project64/Settings/Debug Settings.h>
#ifndef PLUGIN_INFO_STRUCT #ifndef PLUGIN_INFO_STRUCT
#define PLUGIN_INFO_STRUCT #define PLUGIN_INFO_STRUCT
@ -81,8 +81,16 @@ enum PLUGIN_TYPE
}; };
class CSettings; class CSettings;
class CMainGui;
class CGfxPlugin; class CAudioPlugin; class CRSP_Plugin; class CControl_Plugin; class CGfxPlugin; class CAudioPlugin; class CRSP_Plugin; class CControl_Plugin;
class CN64System;
class CPlugins;
__interface RenderWindow
{
bool ResetPluginsInUiThread(CPlugins * plugins, CN64System * System) = 0;
void * GetWindowHandle(void) const = 0;
void * GetStatusBar(void) const = 0;
};
class CPlugins : class CPlugins :
private CDebugSettings private CDebugSettings
@ -95,8 +103,8 @@ public:
bool Initiate(CN64System * System); bool Initiate(CN64System * System);
void RomOpened(void); void RomOpened(void);
void RomClosed(void); void RomClosed(void);
void SetRenderWindows ( CMainGui * RenderWindow, CMainGui * DummyWindow ); void SetRenderWindows(RenderWindow * MainWindow, RenderWindow * SyncWindow);
void ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type); void ConfigPlugin(void* hParent, PLUGIN_TYPE Type);
bool CopyPlugins(const stdstr & DstDir) const; bool CopyPlugins(const stdstr & DstDir) const;
void CreatePlugins(void); void CreatePlugins(void);
bool Reset(CN64System * System); bool Reset(CN64System * System);
@ -108,6 +116,8 @@ public:
inline CRSP_Plugin * RSP(void) const { return m_RSP; } inline CRSP_Plugin * RSP(void) const { return m_RSP; }
inline CControl_Plugin * Control(void) const { return m_Control; } inline CControl_Plugin * Control(void) const { return m_Control; }
inline RenderWindow * MainWindow(void) const { return m_MainWindow; }
inline RenderWindow * SyncWindow(void) const { return m_SyncWindow; }
private: private:
CPlugins(void); // Disable default constructor CPlugins(void); // Disable default constructor
@ -121,8 +131,8 @@ private:
static void PluginChanged(CPlugins * _this); static void PluginChanged(CPlugins * _this);
CMainGui * m_RenderWindow; RenderWindow * m_MainWindow;
CMainGui * m_DummyWindow; RenderWindow * m_SyncWindow;
stdstr const m_PluginDir; stdstr const m_PluginDir;

View File

@ -10,6 +10,8 @@
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include <io.h> #include <io.h>
#include "Plugin List.h"
#include <Project64\Plugins\Plugin Base.h>
CPluginList::CPluginList(bool bAutoFill /* = true */) : CPluginList::CPluginList(bool bAutoFill /* = true */) :
m_PluginDir(g_Settings->LoadStringVal(Directory_Plugin), "") m_PluginDir(g_Settings->LoadStringVal(Directory_Plugin), "")
@ -36,7 +38,6 @@ const CPluginList::PLUGIN * CPluginList::GetPluginInfo ( int indx ) const
return NULL; return NULL;
} }
return &m_PluginList[indx]; return &m_PluginList[indx];
} }
bool CPluginList::LoadList() bool CPluginList::LoadList()
@ -92,15 +93,13 @@ void CPluginList::AddPluginFromDir ( CPath Dir)
PLUGIN Plugin = { 0 }; PLUGIN Plugin = { 0 };
Plugin.Info.MemoryBswaped = true; Plugin.Info.MemoryBswaped = true;
GetDllInfo(&Plugin.Info); GetDllInfo(&Plugin.Info);
if (!ValidPluginVersion(Plugin.Info)) if (!CPlugin::ValidPluginVersion(Plugin.Info))
{ {
continue; continue;
} }
Plugin.FullPath = Dir; Plugin.FullPath = Dir;
std::string& fullPath = Dir; Plugin.FileName = stdstr((const char *)Dir).substr(strlen(m_PluginDir));
std::string& pluginPath = m_PluginDir;
Plugin.FileName = fullPath.substr(pluginPath.length());
if (GetProcAddress(hLib, "DllAbout") != NULL) if (GetProcAddress(hLib, "DllAbout") != NULL)
{ {
@ -116,33 +115,3 @@ void CPluginList::AddPluginFromDir ( CPath Dir)
} }
} }
} }
bool CPluginList::ValidPluginVersion ( PLUGIN_INFO & PluginInfo ) {
switch (PluginInfo.Type)
{
case PLUGIN_TYPE_RSP:
if (!PluginInfo.MemoryBswaped) { return false; }
if (PluginInfo.Version == 0x0001) { return true; }
if (PluginInfo.Version == 0x0100) { return true; }
if (PluginInfo.Version == 0x0101) { return true; }
if (PluginInfo.Version == 0x0102) { return true; }
break;
case PLUGIN_TYPE_GFX:
if (!PluginInfo.MemoryBswaped) { return false; }
if (PluginInfo.Version == 0x0102) { return true; }
if (PluginInfo.Version == 0x0103) { return true; }
if (PluginInfo.Version == 0x0104) { return true; }
break;
case PLUGIN_TYPE_AUDIO:
if (!PluginInfo.MemoryBswaped) { return false; }
if (PluginInfo.Version == 0x0101) { return true; }
if (PluginInfo.Version == 0x0102) { return true; }
break;
case PLUGIN_TYPE_CONTROLLER:
if (PluginInfo.Version == 0x0100) { return true; }
if (PluginInfo.Version == 0x0101) { return true; }
if (PluginInfo.Version == 0x0102) { return true; }
break;
}
return FALSE;
}

View File

@ -1,4 +1,16 @@
#include "..\\Settings.h" /****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
#include <Project64/Settings/Settings.h>
class CPluginList class CPluginList
{ {
@ -18,7 +30,6 @@ public:
bool LoadList(void); bool LoadList(void);
int GetPluginCount(void) const; int GetPluginCount(void) const;
const PLUGIN * GetPluginInfo(int indx) const; const PLUGIN * GetPluginInfo(int indx) const;
static bool ValidPluginVersion ( PLUGIN_INFO & PluginInfo );
private: private:
typedef std::vector<PLUGIN> PluginList; typedef std::vector<PLUGIN> PluginList;

View File

@ -1,28 +0,0 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns='urn:schemas-microsoft-com:asm.v3'>
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
<assemblyIdentity
version='2.1.0.1'
processorArchitecture='x86'
name='Project64'
type='win32'
/>
<dependency>
<dependentAssembly>
<assemblyIdentity
type='win32'
name='Microsoft.Windows.Common-Controls'
version='6.0.0.0'
processorArchitecture='X86'
publicKeyToken='6595b64144ccf1df'
language='*'
/>
</dependentAssembly>
</dependency>
</assembly>

View File

@ -145,6 +145,10 @@
Name="Source Files" Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
> >
<File
RelativePath=".\AppInit.cpp"
>
</File>
<File <File
RelativePath=".\Logging.cpp" RelativePath=".\Logging.cpp"
> >
@ -188,6 +192,10 @@
RelativePath="Settings\Gui Settings.cpp" RelativePath="Settings\Gui Settings.cpp"
> >
</File> </File>
<File
RelativePath=".\Settings\Logging Settings.cpp"
>
</File>
<File <File
RelativePath="Settings\N64System Settings.cpp" RelativePath="Settings\N64System Settings.cpp"
> >
@ -300,6 +308,10 @@
RelativePath="User Interface\Gui Class.cpp" RelativePath="User Interface\Gui Class.cpp"
> >
</File> </File>
<File
RelativePath=".\User Interface\LoggingUI.cpp"
>
</File>
<File <File
RelativePath="User Interface\Main Menu Class.cpp" RelativePath="User Interface\Main Menu Class.cpp"
> >
@ -428,6 +440,10 @@
RelativePath="N64 System\Cheat Class.cpp" RelativePath="N64 System\Cheat Class.cpp"
> >
</File> </File>
<File
RelativePath=".\N64 System\Emulation Thread.cpp"
>
</File>
<File <File
RelativePath="N64 System\N64 Class.cpp" RelativePath="N64 System\N64 Class.cpp"
> >
@ -789,6 +805,10 @@
Name="Header Files" Name="Header Files"
Filter="h;hpp;hxx;hm;inl" Filter="h;hpp;hxx;hm;inl"
> >
<File
RelativePath=".\AppInit.h"
>
</File>
<File <File
RelativePath=".\Logging.h" RelativePath=".\Logging.h"
> >
@ -840,6 +860,10 @@
RelativePath="Settings\Gui Settings.h" RelativePath="Settings\Gui Settings.h"
> >
</File> </File>
<File
RelativePath=".\Settings\Logging Settings.h"
>
</File>
<File <File
RelativePath="Settings\N64System Settings.h" RelativePath="Settings\N64System Settings.h"
> >
@ -960,6 +984,10 @@
RelativePath="User Interface\Log Class.h" RelativePath="User Interface\Log Class.h"
> >
</File> </File>
<File
RelativePath=".\User Interface\LoggingUI.h"
>
</File>
<File <File
RelativePath="User Interface\Main Menu Class.h" RelativePath="User Interface\Main Menu Class.h"
> >

View File

@ -39,13 +39,19 @@
<StackReserveSize>1</StackReserveSize> <StackReserveSize>1</StackReserveSize>
<DataExecutionPrevention>false</DataExecutionPrevention> <DataExecutionPrevention>false</DataExecutionPrevention>
</Link> </Link>
<Manifest>
<EnableDPIAwareness>true</EnableDPIAwareness>
</Manifest>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Logging.cpp" /> <ClCompile Include="AppInit.cpp" />
<ClCompile Include="logging.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="Multilanguage\LanguageSelector.cpp" /> <ClCompile Include="Multilanguage\LanguageSelector.cpp" />
<ClCompile Include="N64 System\Emulation Thread.cpp" />
<ClCompile Include="N64 System\Mips\Rumblepak.cpp" /> <ClCompile Include="N64 System\Mips\Rumblepak.cpp" />
<ClCompile Include="Plugins\Plugin Base.cpp" /> <ClCompile Include="Plugins\Plugin Base.cpp" />
<ClCompile Include="Settings\Logging Settings.cpp" />
<ClCompile Include="stdafx.cpp"> <ClCompile Include="stdafx.cpp">
<PrecompiledHeader>Create</PrecompiledHeader> <PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile> </ClCompile>
@ -78,6 +84,7 @@
<ClCompile Include="User Interface\Cheat Class UI.cpp" /> <ClCompile Include="User Interface\Cheat Class UI.cpp" />
<ClCompile Include="User Interface\Frame Per Second Class.cpp" /> <ClCompile Include="User Interface\Frame Per Second Class.cpp" />
<ClCompile Include="User Interface\Gui Class.cpp" /> <ClCompile Include="User Interface\Gui Class.cpp" />
<ClCompile Include="User Interface\LoggingUI.cpp" />
<ClCompile Include="User Interface\Main Menu Class.cpp" /> <ClCompile Include="User Interface\Main Menu Class.cpp" />
<ClCompile Include="User Interface\Menu Class.cpp" /> <ClCompile Include="User Interface\Menu Class.cpp" />
<ClCompile Include="User Interface\MenuShortCuts.cpp" /> <ClCompile Include="User Interface\MenuShortCuts.cpp" />
@ -156,12 +163,7 @@
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="User Interface\Bitmaps\AboutScreenBottom.bmp" /> <Image Include="User Interface\Bitmaps\AboutScreenLogo.bmp" />
<Image Include="User Interface\Bitmaps\AboutScreenMiddle.bmp" />
<Image Include="User Interface\Bitmaps\AboutScreenTop.bmp" />
<Image Include="User Interface\Bitmaps\CloseNormal.bmp" />
<Image Include="User Interface\Bitmaps\LangOK.bmp" />
<Image Include="User Interface\Bitmaps\LangOK_down.bmp" />
<Image Include="User Interface\Icons\left.ico" /> <Image Include="User Interface\Icons\left.ico" />
<Image Include="User Interface\Bitmaps\ListItems.bmp" /> <Image Include="User Interface\Bitmaps\ListItems.bmp" />
<Image Include="User Interface\Icons\PJ64.ICO" /> <Image Include="User Interface\Icons\PJ64.ICO" />
@ -178,6 +180,7 @@
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="AppInit.h" />
<ClInclude Include="Logging.h" /> <ClInclude Include="Logging.h" />
<ClInclude Include="Multilanguage.h" /> <ClInclude Include="Multilanguage.h" />
<ClInclude Include="Multilanguage\LanguageSelector.h" /> <ClInclude Include="Multilanguage\LanguageSelector.h" />
@ -185,10 +188,12 @@
<ClInclude Include="N64 System\Mips\Rumblepak.h" /> <ClInclude Include="N64 System\Mips\Rumblepak.h" />
<ClInclude Include="Plugin.h" /> <ClInclude Include="Plugin.h" />
<ClInclude Include="Plugins\Plugin Base.h" /> <ClInclude Include="Plugins\Plugin Base.h" />
<ClInclude Include="Settings.h" /> <ClInclude Include="Settings\Logging Settings.h" />
<ClInclude Include="Settings\Settings.h" />
<ClInclude Include="stdafx.h" /> <ClInclude Include="stdafx.h" />
<ClInclude Include="User Interface.h" /> <ClInclude Include="User Interface.h" />
<ClInclude Include="User Interface\Cheat Class UI.h" /> <ClInclude Include="User Interface\Cheat Class UI.h" />
<ClInclude Include="User Interface\LoggingUI.h" />
<ClInclude Include="Version.h" /> <ClInclude Include="Version.h" />
<ClInclude Include="WTL App.h" /> <ClInclude Include="WTL App.h" />
<ClInclude Include="Settings\Debug Settings.h" /> <ClInclude Include="Settings\Debug Settings.h" />

View File

@ -417,29 +417,23 @@
<ClCompile Include="User Interface\Cheat Class UI.cpp"> <ClCompile Include="User Interface\Cheat Class UI.cpp">
<Filter>Source Files\User Interface Source</Filter> <Filter>Source Files\User Interface Source</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Logging.cpp"> <ClCompile Include="User Interface\LoggingUI.cpp">
<Filter>Source Files\User Interface Source</Filter>
</ClCompile>
<ClCompile Include="logging.cpp">
<Filter>Source Files\N64 System Source</Filter>
</ClCompile>
<ClCompile Include="Settings\Logging Settings.cpp">
<Filter>Source Files\N64 System Source</Filter>
</ClCompile>
<ClCompile Include="AppInit.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="N64 System\Emulation Thread.cpp">
<Filter>Source Files\N64 System Source</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="User Interface\Bitmaps\AboutScreenBottom.bmp">
<Filter>Resource Files</Filter>
</Image>
<Image Include="User Interface\Bitmaps\AboutScreenMiddle.bmp">
<Filter>Resource Files</Filter>
</Image>
<Image Include="User Interface\Bitmaps\AboutScreenTop.bmp">
<Filter>Resource Files</Filter>
</Image>
<Image Include="User Interface\Bitmaps\CloseNormal.bmp">
<Filter>Resource Files</Filter>
</Image>
<Image Include="User Interface\Bitmaps\LangOK.bmp">
<Filter>Resource Files</Filter>
</Image>
<Image Include="User Interface\Bitmaps\LangOK_down.bmp">
<Filter>Resource Files</Filter>
</Image>
<Image Include="User Interface\Icons\left.ico"> <Image Include="User Interface\Icons\left.ico">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</Image> </Image>
@ -455,6 +449,9 @@
<Image Include="User Interface\Bitmaps\tri-state.bmp"> <Image Include="User Interface\Bitmaps\tri-state.bmp">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</Image> </Image>
<Image Include="User Interface\Bitmaps\AboutScreenLogo.bmp">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="User Interface\Icons\divider.cur"> <None Include="User Interface\Icons\divider.cur">
@ -479,9 +476,6 @@
<ClInclude Include="Plugin.h"> <ClInclude Include="Plugin.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Settings.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdafx.h"> <ClInclude Include="stdafx.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -845,7 +839,19 @@
<ClInclude Include="User Interface\Cheat Class UI.h"> <ClInclude Include="User Interface\Cheat Class UI.h">
<Filter>Header Files\User Interface Headers</Filter> <Filter>Header Files\User Interface Headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Settings\Settings.h">
<Filter>Header Files\Settings Headers</Filter>
</ClInclude>
<ClInclude Include="User Interface\LoggingUI.h">
<Filter>Header Files\User Interface Headers</Filter>
</ClInclude>
<ClInclude Include="Logging.h"> <ClInclude Include="Logging.h">
<Filter>Header Files\N64 System Headers</Filter>
</ClInclude>
<ClInclude Include="Settings\Logging Settings.h">
<Filter>Header Files\Settings Headers</Filter>
</ClInclude>
<ClInclude Include="AppInit.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>

View File

@ -1,272 +0,0 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
enum
{
MaxPluginSetting = 65535
};
enum SettingID
{
//Default values
Default_None,
Default_Constant,
//information - temp keys
Info_ShortCutsChanged,
//Support Files
SupportFile_Settings,
SupportFile_SettingsDefault,
SupportFile_RomDatabase,
SupportFile_RomDatabaseDefault,
SupportFile_Glide64RDB,
SupportFile_Glide64RDBDefault,
SupportFile_Cheats,
SupportFile_CheatsDefault,
SupportFile_Notes,
SupportFile_NotesDefault,
SupportFile_ExtInfo,
SupportFile_ExtInfoDefault,
SupportFile_ShortCuts,
SupportFile_ShortCutsDefault,
SupportFile_RomListCache,
SupportFile_RomListCacheDefault,
SupportFile_7zipCache,
SupportFile_7zipCacheDefault,
//Settings
Setting_ApplicationName,
Setting_UseFromRegistry,
Setting_RdbEditor,
Setting_PluginPageFirst,
Setting_DisableScrSaver,
Setting_AutoSleep,
Setting_AutoStart,
Setting_AutoFullscreen,
Setting_CheckEmuRunning,
Setting_EraseGameDefaults,
Setting_AutoZipInstantSave,
Setting_RememberCheats,
Setting_LanguageDir,
Setting_LanguageDirDefault,
Setting_CurrentLanguage,
//RDB TLB Settings
Rdb_GoodName,
Rdb_SaveChip,
Rdb_CpuType,
Rdb_RDRamSize,
Rdb_CounterFactor,
Rdb_UseTlb,
Rdb_DelayDP,
Rdb_DelaySi,
Rdb_32Bit,
Rdb_FastSP,
Rdb_Status,
Rdb_NotesCore,
Rdb_NotesPlugin,
Rdb_FixedAudio,
Rdb_SyncViaAudio,
Rdb_RspAudioSignal,
Rdb_TLB_VAddrStart,
Rdb_TLB_VAddrLen,
Rdb_TLB_PAddrStart,
Rdb_UseHleGfx,
Rdb_UseHleAudio,
Rdb_LoadRomToMemory,
Rdb_ScreenHertz,
Rdb_FuncLookupMode,
Rdb_RegCache,
Rdb_BlockLinking,
Rdb_SMM_StoreInstruc,
Rdb_SMM_Cache,
Rdb_SMM_PIDMA,
Rdb_SMM_TLB,
Rdb_SMM_Protect,
Rdb_SMM_ValidFunc,
Rdb_GameCheatFix,
Rdb_GameCheatFixPlugin,
Rdb_ViRefreshRate,
Rdb_AiCountPerBytes,
Rdb_AudioResetOnLoad,
Rdb_AllowROMWrites,
Rdb_CRC_Recalc,
//Individual Game Settings
Game_IniKey,
Game_GameName,
Game_GoodName,
Game_TempLoaded,
Game_SystemType,
Game_EditPlugin_Gfx,
Game_EditPlugin_Audio,
Game_EditPlugin_Contr,
Game_EditPlugin_RSP,
Game_Plugin_Gfx,
Game_Plugin_Audio,
Game_Plugin_Controller,
Game_Plugin_RSP,
Game_SaveChip,
Game_CpuType,
Game_LastSaveSlot,
Game_FixedAudio,
Game_SyncViaAudio,
Game_32Bit,
Game_SMM_Cache,
Game_SMM_Protect,
Game_SMM_ValidFunc,
Game_SMM_PIDMA,
Game_SMM_TLB,
Game_SMM_StoreInstruc,
Game_CurrentSaveState,
Game_RDRamSize,
Game_CounterFactor,
Game_UseTlb,
Game_DelayDP,
Game_DelaySI,
Game_FastSP,
Game_FuncLookupMode,
Game_RegCache,
Game_BlockLinking,
Game_ScreenHertz,
Game_RspAudioSignal,
Game_UseHleGfx,
Game_UseHleAudio,
Game_LoadRomToMemory,
Game_ViRefreshRate,
Game_AiCountPerBytes,
Game_AudioResetOnLoad,
Game_AllowROMWrites,
Game_CRC_Recalc,
// General Game running info
GameRunning_LoadingInProgress,
GameRunning_CPU_Running,
GameRunning_CPU_Paused,
GameRunning_CPU_PausedType,
GameRunning_InstantSaveFile,
GameRunning_LimitFPS,
GameRunning_ScreenHertz,
GameRunning_InReset,
//User Interface
UserInterface_BasicMode,
UserInterface_ShowCPUPer,
UserInterface_DisplayFrameRate,
UserInterface_InFullScreen,
UserInterface_FrameDisplayType,
UserInterface_MainWindowTop,
UserInterface_MainWindowLeft,
UserInterface_AlwaysOnTop,
RomBrowser_Enabled,
RomBrowser_ColoumnsChanged,
RomBrowser_Top,
RomBrowser_Left,
RomBrowser_Width,
RomBrowser_Height,
RomBrowser_PosIndex,
RomBrowser_WidthIndex,
RomBrowser_SortFieldIndex,
RomBrowser_SortAscendingIndex,
RomBrowser_Recursive,
RomBrowser_Maximized,
//Directory Info
Directory_LastSave,
Directory_RecentGameDirCount,
Directory_RecentGameDirIndex,
Directory_Game,
Directory_GameInitial,
Directory_GameSelected,
Directory_GameUseSelected,
Directory_Plugin,
Directory_PluginInitial,
Directory_PluginSelected,
Directory_PluginUseSelected,
Directory_PluginSync,
Directory_SnapShot,
Directory_SnapShotInitial,
Directory_SnapShotSelected,
Directory_SnapShotUseSelected,
Directory_NativeSave,
Directory_NativeSaveInitial,
Directory_NativeSaveSelected,
Directory_NativeSaveUseSelected,
Directory_InstantSave,
Directory_InstantSaveInitial,
Directory_InstantSaveSelected,
Directory_InstantSaveUseSelected,
Directory_Texture,
Directory_TextureInitial,
Directory_TextureSelected,
Directory_TextureUseSelected,
//File Info
File_RecentGameFileCount,
File_RecentGameFileIndex,
//Debugger
Debugger_Enabled,
Debugger_ShowTLBMisses,
Debugger_ShowUnhandledMemory,
Debugger_ShowPifErrors,
Debugger_ShowDivByZero,
Debugger_GenerateLogFiles,
Debugger_ProfileCode,
Debugger_DisableGameFixes,
Debugger_AppLogLevel,
Debugger_AppLogFlush,
Debugger_GenerateDebugLog,
Debugger_ShowDListAListCount,
Debugger_ShowRecompMemSize,
//Plugins
Plugin_RSP_Current,
Plugin_RSP_CurVer,
Plugin_GFX_Current,
Plugin_GFX_CurVer,
Plugin_AUDIO_Current,
Plugin_AUDIO_CurVer,
Plugin_CONT_Current,
Plugin_CONT_CurVer,
Plugin_UseHleGfx,
Plugin_UseHleAudio,
//Cheats
Cheat_Entry,
Cheat_Active,
Cheat_Extension,
Cheat_Notes,
Cheat_Options,
Cheat_Range,
Cheat_RangeNotes,
FirstRSPDefaultSet, LastRSPDefaultSet = FirstRSPDefaultSet + MaxPluginSetting,
FirstRSPSettings, LastRSPSettings = FirstRSPSettings + MaxPluginSetting,
FirstGfxDefaultSet, LastGfxDefaultSet = FirstGfxDefaultSet + MaxPluginSetting,
FirstGfxSettings, LastGfxSettings = FirstGfxSettings + MaxPluginSetting,
FirstAudioDefaultSet, LastAudioDefaultSet = FirstAudioDefaultSet + MaxPluginSetting,
FirstAudioSettings, LastAudioSettings = FirstAudioSettings + MaxPluginSetting,
FirstCtrlDefaultSet, LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting,
FirstCtrlSettings, LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting,
};
#include "Support.h"
#include "./Settings/Settings Class.h"
#include "./Settings/Debug Settings.h"
#include "./Settings/Game Settings.h"
#include "./Settings/Recompiler Settings.h"
#include "./Settings/N64System Settings.h"
#include "./Settings/Gui Settings.h"

View File

@ -9,6 +9,7 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include "Debug Settings.h"
int CDebugSettings::m_RefCount = 0; int CDebugSettings::m_RefCount = 0;

View File

@ -10,7 +10,7 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <N64 System/N64 Types.h> #include <Project64\N64 System\N64 Types.h>
class CDebugSettings class CDebugSettings
{ {
@ -37,6 +37,6 @@ private:
static bool m_bShowTLBMisses; static bool m_bShowTLBMisses;
static bool m_bShowDivByZero; static bool m_bShowDivByZero;
static int m_RefCount; static int32_t m_RefCount;
static bool m_Registered; static bool m_Registered;
}; };

View File

@ -9,6 +9,9 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include <Project64\N64 System\System Globals.h>
#include <Project64\N64 System\N64 Class.h>
#include "Game Settings.h"
bool CGameSettings::m_bSMM_StoreInstruc; bool CGameSettings::m_bSMM_StoreInstruc;
bool CGameSettings::m_bSMM_Protect; bool CGameSettings::m_bSMM_Protect;
@ -16,12 +19,12 @@ bool CGameSettings::m_bSMM_ValidFunc;
bool CGameSettings::m_bSMM_PIDMA; bool CGameSettings::m_bSMM_PIDMA;
bool CGameSettings::m_bSMM_TLB; bool CGameSettings::m_bSMM_TLB;
bool CGameSettings::m_bUseTlb; bool CGameSettings::m_bUseTlb;
DWORD CGameSettings::m_CountPerOp = 2; uint32_t CGameSettings::m_CountPerOp = 2;
DWORD CGameSettings::m_ViRefreshRate = 1500; uint32_t CGameSettings::m_ViRefreshRate = 1500;
DWORD CGameSettings::m_AiCountPerBytes = 500; uint32_t CGameSettings::m_AiCountPerBytes = 500;
bool CGameSettings::m_DelayDP = false; bool CGameSettings::m_DelayDP = false;
bool CGameSettings::m_DelaySI = false; bool CGameSettings::m_DelaySI = false;
DWORD CGameSettings::m_RdramSize = 0; uint32_t CGameSettings::m_RdramSize = 0;
bool CGameSettings::m_bFixedAudio = true; bool CGameSettings::m_bFixedAudio = true;
bool CGameSettings::m_bSyncingToAudio = true; bool CGameSettings::m_bSyncingToAudio = true;
bool CGameSettings::m_bSyncToAudio = true; bool CGameSettings::m_bSyncToAudio = true;
@ -31,7 +34,7 @@ bool CGameSettings::m_RspAudioSignal;
bool CGameSettings::m_bRomInMemory; bool CGameSettings::m_bRomInMemory;
bool CGameSettings::m_RegCaching; bool CGameSettings::m_RegCaching;
bool CGameSettings::m_bLinkBlocks; bool CGameSettings::m_bLinkBlocks;
DWORD CGameSettings::m_LookUpMode; //FUNC_LOOKUP_METHOD uint32_t CGameSettings::m_LookUpMode; //FUNC_LOOKUP_METHOD
SYSTEM_TYPE CGameSettings::m_SystemType = SYSTEM_NTSC; SYSTEM_TYPE CGameSettings::m_SystemType = SYSTEM_NTSC;
CPU_TYPE CGameSettings::m_CpuType = CPU_Recompiler; CPU_TYPE CGameSettings::m_CpuType = CPU_Recompiler;

View File

@ -10,7 +10,7 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <N64 System/N64 Types.h> #include <Project64\N64 System\N64 Types.h>
class CGameSettings class CGameSettings
{ {
@ -22,12 +22,12 @@ public:
inline static bool bLinkBlocks(void) { return m_bLinkBlocks; } inline static bool bLinkBlocks(void) { return m_bLinkBlocks; }
inline static FUNC_LOOKUP_METHOD LookUpMode(void) { return (FUNC_LOOKUP_METHOD)m_LookUpMode; } inline static FUNC_LOOKUP_METHOD LookUpMode(void) { return (FUNC_LOOKUP_METHOD)m_LookUpMode; }
inline static bool bUseTlb(void) { return m_bUseTlb; } inline static bool bUseTlb(void) { return m_bUseTlb; }
inline static DWORD CountPerOp ( void ) { return m_CountPerOp; } inline static uint32_t CountPerOp(void) { return m_CountPerOp; }
inline static DWORD ViRefreshRate ( void ) { return m_ViRefreshRate; } inline static uint32_t ViRefreshRate(void) { return m_ViRefreshRate; }
inline static DWORD AiCountPerBytes ( void ) { return m_AiCountPerBytes; } inline static uint32_t AiCountPerBytes(void) { return m_AiCountPerBytes; }
inline static bool bDelayDP(void) { return m_DelayDP; } inline static bool bDelayDP(void) { return m_DelayDP; }
inline static bool bDelaySI(void) { return m_DelaySI; } inline static bool bDelaySI(void) { return m_DelaySI; }
inline static DWORD RdramSize ( void ) { return m_RdramSize; } inline static uint32_t RdramSize(void) { return m_RdramSize; }
inline static bool bFixedAudio(void) { return m_bFixedAudio; } inline static bool bFixedAudio(void) { return m_bFixedAudio; }
inline static bool bSyncToAudio(void) { return m_bSyncingToAudio; } inline static bool bSyncToAudio(void) { return m_bSyncingToAudio; }
inline static bool bFastSP(void) { return m_bFastSP; } inline static bool bFastSP(void) { return m_bFastSP; }
@ -42,21 +42,21 @@ public:
inline static CPU_TYPE CpuType(void) { return m_CpuType; } inline static CPU_TYPE CpuType(void) { return m_CpuType; }
protected: protected:
static void SpeedChanged (int SpeedLimit ); static void SpeedChanged(int32_t SpeedLimit);
private: private:
//Settings that can be changed on the fly //Settings that can be changed on the fly
static bool m_bRomInMemory; static bool m_bRomInMemory;
static bool m_RegCaching; static bool m_RegCaching;
static bool m_bLinkBlocks; static bool m_bLinkBlocks;
static DWORD m_LookUpMode; //FUNC_LOOKUP_METHOD static uint32_t m_LookUpMode; //FUNC_LOOKUP_METHOD
static bool m_bUseTlb; static bool m_bUseTlb;
static DWORD m_CountPerOp; static uint32_t m_CountPerOp;
static DWORD m_ViRefreshRate; static uint32_t m_ViRefreshRate;
static DWORD m_AiCountPerBytes; static uint32_t m_AiCountPerBytes;
static bool m_DelayDP; static bool m_DelayDP;
static bool m_DelaySI; static bool m_DelaySI;
static DWORD m_RdramSize; static uint32_t m_RdramSize;
static bool m_bFixedAudio; static bool m_bFixedAudio;
static bool m_bSyncingToAudio; static bool m_bSyncingToAudio;
static bool m_bSyncToAudio; static bool m_bSyncToAudio;

View File

@ -0,0 +1,135 @@
/****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#include "stdafx.h"
#include "Logging Settings.h"
int CLogSettings::m_RefCount = 0;
bool CLogSettings::m_GenerateLog = 0;
bool CLogSettings::m_LogRDRamRegisters = 0;
bool CLogSettings::m_LogSPRegisters = 0;
bool CLogSettings::m_LogDPCRegisters = 0;
bool CLogSettings::m_LogDPSRegisters = 0;
bool CLogSettings::m_LogMIPSInterface = 0;
bool CLogSettings::m_LogVideoInterface = 0;
bool CLogSettings::m_LogAudioInterface = 0;
bool CLogSettings::m_LogPerInterface = 0;
bool CLogSettings::m_LogRDRAMInterface = 0;
bool CLogSettings::m_LogSerialInterface = 0;
bool CLogSettings::m_LogPRDMAOperations = 0;
bool CLogSettings::m_LogPRDirectMemLoads = 0;
bool CLogSettings::m_LogPRDMAMemLoads = 0;
bool CLogSettings::m_LogPRDirectMemStores = 0;
bool CLogSettings::m_LogPRDMAMemStores = 0;
bool CLogSettings::m_LogControllerPak = 0;
bool CLogSettings::m_LogCP0changes = 0;
bool CLogSettings::m_LogCP0reads = 0;
bool CLogSettings::m_LogTLB = 0;
bool CLogSettings::m_LogExceptions = 0;
bool CLogSettings::m_NoInterrupts = 0;
bool CLogSettings::m_LogCache = 0;
bool CLogSettings::m_LogRomHeader = 0;
bool CLogSettings::m_LogUnknown = 0;
CLogSettings::CLogSettings()
{
m_RefCount += 1;
if (m_RefCount == 1)
{
g_Settings->RegisterChangeCB(Logging_GenerateLog, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogRDRamRegisters, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogSPRegisters, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogDPCRegisters, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogDPSRegisters, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogMIPSInterface, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogVideoInterface, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogAudioInterface, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogPerInterface, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogRDRAMInterface, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogSerialInterface, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogPRDMAOperations, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogPRDirectMemLoads, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogPRDMAMemLoads, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogPRDirectMemStores, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogPRDMAMemStores, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogControllerPak, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogCP0changes, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogCP0reads, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogTLB, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogExceptions, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_NoInterrupts, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogCache, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogRomHeader, NULL, RefreshSettings);
g_Settings->RegisterChangeCB(Logging_LogUnknown, NULL, RefreshSettings);
RefreshSettings(NULL);
}
}
CLogSettings::~CLogSettings()
{
m_RefCount -= 1;
if (m_RefCount == 0)
{
g_Settings->UnregisterChangeCB(Logging_GenerateLog, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogRDRamRegisters, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogSPRegisters, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogDPCRegisters, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogDPSRegisters, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogMIPSInterface, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogVideoInterface, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogAudioInterface, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogPerInterface, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogRDRAMInterface, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogSerialInterface, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogPRDMAOperations, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogPRDirectMemLoads, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogPRDMAMemLoads, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogPRDirectMemStores, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogPRDMAMemStores, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogControllerPak, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogCP0changes, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogCP0reads, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogTLB, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogExceptions, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_NoInterrupts, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogCache, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogRomHeader, NULL, RefreshSettings);
g_Settings->UnregisterChangeCB(Logging_LogUnknown, NULL, RefreshSettings);
}
}
void CLogSettings::RefreshSettings(void *)
{
m_GenerateLog = g_Settings->LoadBool(Logging_GenerateLog);
m_LogRDRamRegisters = g_Settings->LoadBool(Logging_LogRDRamRegisters);
m_LogSPRegisters = g_Settings->LoadBool(Logging_LogSPRegisters);
m_LogDPCRegisters = g_Settings->LoadBool(Logging_LogDPCRegisters);
m_LogDPSRegisters = g_Settings->LoadBool(Logging_LogDPSRegisters);
m_LogMIPSInterface = g_Settings->LoadBool(Logging_LogMIPSInterface);
m_LogVideoInterface = g_Settings->LoadBool(Logging_LogVideoInterface);
m_LogAudioInterface = g_Settings->LoadBool(Logging_LogAudioInterface);
m_LogPerInterface = g_Settings->LoadBool(Logging_LogPerInterface);
m_LogRDRAMInterface = g_Settings->LoadBool(Logging_LogRDRAMInterface);
m_LogSerialInterface = g_Settings->LoadBool(Logging_LogSerialInterface);
m_LogPRDMAOperations = g_Settings->LoadBool(Logging_LogPRDMAOperations);
m_LogPRDirectMemLoads = g_Settings->LoadBool(Logging_LogPRDirectMemLoads);
m_LogPRDMAMemLoads = g_Settings->LoadBool(Logging_LogPRDMAMemLoads);
m_LogPRDirectMemStores = g_Settings->LoadBool(Logging_LogPRDirectMemStores);
m_LogPRDMAMemStores = g_Settings->LoadBool(Logging_LogPRDMAMemStores);
m_LogControllerPak = g_Settings->LoadBool(Logging_LogControllerPak);
m_LogCP0changes = g_Settings->LoadBool(Logging_LogCP0changes);
m_LogCP0reads = g_Settings->LoadBool(Logging_LogCP0reads);
m_LogTLB = g_Settings->LoadBool(Logging_LogTLB);
m_LogExceptions = g_Settings->LoadBool(Logging_LogExceptions);
m_NoInterrupts = g_Settings->LoadBool(Logging_NoInterrupts);
m_LogCache = g_Settings->LoadBool(Logging_LogCache);
m_LogRomHeader = g_Settings->LoadBool(Logging_LogRomHeader);
m_LogUnknown = g_Settings->LoadBool(Logging_LogUnknown);
}

View File

@ -0,0 +1,87 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
class CLogSettings
{
public:
CLogSettings();
virtual ~CLogSettings();
inline static bool GenerateLog ( void ) { return m_GenerateLog; }
/* Registers Log */
inline static bool LogRDRamRegisters ( void ) { return m_LogRDRamRegisters; }
inline static bool LogSPRegisters ( void ) { return m_LogSPRegisters; }
inline static bool LogDPCRegisters ( void ) { return m_LogDPCRegisters; }
inline static bool LogDPSRegisters ( void ) { return m_LogDPSRegisters; }
inline static bool LogMIPSInterface ( void ) { return m_LogMIPSInterface; }
inline static bool LogVideoInterface ( void ) { return m_LogVideoInterface; }
inline static bool LogAudioInterface ( void ) { return m_LogAudioInterface; }
inline static bool LogPerInterface ( void ) { return m_LogPerInterface; }
inline static bool LogRDRAMInterface ( void ) { return m_LogRDRAMInterface; }
inline static bool LogSerialInterface ( void ) { return m_LogSerialInterface; }
/* Pif Ram Log */
inline static bool LogPRDMAOperations ( void ) { return m_LogPRDMAOperations; }
inline static bool LogPRDirectMemLoads ( void ) { return m_LogPRDirectMemLoads; }
inline static bool LogPRDMAMemLoads ( void ) { return m_LogPRDMAMemLoads; }
inline static bool LogPRDirectMemStores ( void ) { return m_LogPRDirectMemStores; }
inline static bool LogPRDMAMemStores ( void ) { return m_LogPRDMAMemStores; }
inline static bool LogControllerPak ( void ) { return m_LogControllerPak; }
/* Special Log */
inline static bool LogCP0changes ( void ) { return m_LogCP0changes; }
inline static bool LogCP0reads ( void ) { return m_LogCP0reads; }
inline static bool LogTLB ( void ) { return m_LogTLB; }
inline static bool LogExceptions ( void ) { return m_LogExceptions; }
inline static bool LogNoInterrupts ( void ) { return m_NoInterrupts; }
inline static bool LogCache ( void ) { return m_LogCache; }
inline static bool LogRomHeader ( void ) { return m_LogRomHeader; }
inline static bool LogUnknown ( void ) { return m_LogUnknown; }
private:
static void RefreshSettings ( void * );
static bool m_GenerateLog;
/* Registers Log */
static bool m_LogRDRamRegisters;
static bool m_LogSPRegisters;
static bool m_LogDPCRegisters;
static bool m_LogDPSRegisters;
static bool m_LogMIPSInterface;
static bool m_LogVideoInterface;
static bool m_LogAudioInterface;
static bool m_LogPerInterface;
static bool m_LogRDRAMInterface;
static bool m_LogSerialInterface;
/* Pif Ram Log */
static bool m_LogPRDMAOperations;
static bool m_LogPRDirectMemLoads;
static bool m_LogPRDMAMemLoads;
static bool m_LogPRDirectMemStores;
static bool m_LogPRDMAMemStores;
static bool m_LogControllerPak;
/* Special Log */
static bool m_LogCP0changes;
static bool m_LogCP0reads;
static bool m_LogTLB;
static bool m_LogExceptions;
static bool m_NoInterrupts;
static bool m_LogCache;
static bool m_LogRomHeader;
static bool m_LogUnknown;
static int32_t m_RefCount;
};

View File

@ -9,8 +9,9 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include "N64System Settings.h"
int CN64SystemSettings::m_RefCount = 0; int32_t CN64SystemSettings::m_RefCount = 0;
bool CN64SystemSettings::m_bShowCPUPer; bool CN64SystemSettings::m_bShowCPUPer;
bool CN64SystemSettings::m_bProfiling; bool CN64SystemSettings::m_bProfiling;

View File

@ -33,6 +33,5 @@ private:
static bool m_bShowDListAListCount; static bool m_bShowDListAListCount;
static bool m_bDisplayFrameRate; static bool m_bDisplayFrameRate;
static int m_RefCount; static int32_t m_RefCount;
}; };

View File

@ -9,6 +9,7 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#include "Recompiler Settings.h"
int CRecompilerSettings::m_RefCount = 0; int CRecompilerSettings::m_RefCount = 0;

View File

@ -10,7 +10,7 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <N64 System/N64 Types.h> #include <Project64\N64 System\N64 Types.h>
class CRecompilerSettings class CRecompilerSettings
{ {
@ -30,10 +30,9 @@ private:
void RefreshSettings(void); void RefreshSettings(void);
//Settings that can be changed on the fly //Settings that can be changed on the fly
static bool m_bShowRecompMemSize; static bool m_bShowRecompMemSize;
static bool m_bProfiling; static bool m_bProfiling;
static int m_RefCount; static int32_t m_RefCount;
}; };

View File

@ -27,23 +27,23 @@ public:
virtual SettingType GetSettingType ( void ) const { return m_UseRegistry ? SettingType_Registry : SettingType_CfgFile; } virtual SettingType GetSettingType ( void ) const { return m_UseRegistry ? SettingType_Registry : SettingType_CfgFile; }
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int32_t Index, bool & Value ) const;
virtual void LoadDefault ( int Index, uint32_t & Value ) const; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int32_t Index );
// Initialize this class to use ini or registry // Initialize this class to use ini or registry
static void Initialize( const char * AppName ); static void Initialize( const char * AppName );

View File

@ -23,23 +23,23 @@ public:
virtual bool IndexBasedSetting ( void ) const { return true; } virtual bool IndexBasedSetting ( void ) const { return true; }
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int32_t Index, bool & Value ) const;
virtual void LoadDefault ( int Index, uint32_t & Value ) const; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int32_t Index );
private: private:
CSettingTypeApplicationIndex(void); // Disable default constructor CSettingTypeApplicationIndex(void); // Disable default constructor

View File

@ -19,7 +19,7 @@ public:
CSettingTypeApplicationPath(const char * Section, const char * Name, SettingID DefaultSetting ); CSettingTypeApplicationPath(const char * Section, const char * Name, SettingID DefaultSetting );
//return the values //return the values
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
private: private:
CSettingTypeApplicationPath(void); // Disable default constructor CSettingTypeApplicationPath(void); // Disable default constructor

View File

@ -39,21 +39,21 @@ public:
virtual bool IndexBasedSetting ( void ) const = 0; virtual bool IndexBasedSetting ( void ) const = 0;
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const = 0; virtual bool Load ( int32_t Index, bool & Value ) const = 0;
virtual bool Load ( int Index, uint32_t & Value ) const = 0; virtual bool Load ( int32_t Index, uint32_t & Value ) const = 0;
virtual bool Load ( int Index, stdstr & Value ) const = 0; virtual bool Load ( int32_t Index, stdstr & Value ) const = 0;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const = 0; virtual void LoadDefault ( int32_t Index, bool & Value ) const = 0;
virtual void LoadDefault ( int Index, uint32_t & Value ) const = 0; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const = 0;
virtual void LoadDefault ( int Index, stdstr & Value ) const = 0; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const = 0;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ) = 0; virtual void Save ( int32_t Index, bool Value ) = 0;
virtual void Save ( int Index, uint32_t Value ) = 0; virtual void Save ( int32_t Index, uint32_t Value ) = 0;
virtual void Save ( int Index, const stdstr & Value ) = 0; virtual void Save ( int32_t Index, const stdstr & Value ) = 0;
virtual void Save ( int Index, const char * Value ) = 0; virtual void Save ( int32_t Index, const char * Value ) = 0;
// Delete the setting // Delete the setting
virtual void Delete ( int Index ) = 0; virtual void Delete ( int32_t Index ) = 0;
}; };

View File

@ -24,23 +24,23 @@ public:
virtual SettingType GetSettingType ( void ) const { return SettingType_CheatSetting; } virtual SettingType GetSettingType ( void ) const { return SettingType_CheatSetting; }
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int32_t Index, bool & Value ) const;
virtual void LoadDefault ( int Index, uint32_t & Value ) const; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int32_t Index );
// Initialize this class to use ini or registry // Initialize this class to use ini or registry
static void Initialize ( void ); static void Initialize ( void );

View File

@ -35,23 +35,23 @@ public:
static void CleanUp ( void ); static void CleanUp ( void );
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int32_t Index, bool & Value ) const;
virtual void LoadDefault ( int Index, uint32_t & Value ) const; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int32_t Index );
private: private:
CSettingTypeGame(void); // Disable default constructor CSettingTypeGame(void); // Disable default constructor

View File

@ -25,23 +25,23 @@ public:
virtual SettingType GetSettingType ( void ) const { return SettingType_GameSetting; } virtual SettingType GetSettingType ( void ) const { return SettingType_GameSetting; }
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int32_t Index, bool & Value ) const;
virtual void LoadDefault ( int Index, uint32_t & Value ) const; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int32_t Index );
private: private:
CSettingTypeGameIndex(void); // Disable default constructor CSettingTypeGameIndex(void); // Disable default constructor

View File

@ -15,27 +15,27 @@ class CSettingTypeRDBCpuType :
{ {
public: public:
CSettingTypeRDBCpuType(const char * Name, SettingID DefaultSetting ); CSettingTypeRDBCpuType(const char * Name, SettingID DefaultSetting );
CSettingTypeRDBCpuType(const char * Name, int DefaultValue ); CSettingTypeRDBCpuType(const char * Name, int32_t DefaultValue );
~CSettingTypeRDBCpuType(); ~CSettingTypeRDBCpuType();
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int32_t Index, bool & Value ) const;
virtual void LoadDefault ( int Index, uint32_t & Value ) const; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int32_t Index );
private: private:
CSettingTypeRDBCpuType(void); // Disable default constructor CSettingTypeRDBCpuType(void); // Disable default constructor

View File

@ -15,27 +15,27 @@ class CSettingTypeRDBOnOff :
{ {
public: public:
CSettingTypeRDBOnOff(const char * Name, SettingID DefaultSetting ); CSettingTypeRDBOnOff(const char * Name, SettingID DefaultSetting );
CSettingTypeRDBOnOff(const char * Name, int DefaultValue ); CSettingTypeRDBOnOff(const char * Name, int32_t DefaultValue );
~CSettingTypeRDBOnOff(); ~CSettingTypeRDBOnOff();
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int32_t Index, bool & Value ) const;
virtual void LoadDefault ( int Index, uint32_t & Value ) const; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int32_t Index );
private: private:
CSettingTypeRDBOnOff(void); // Disable default constructor CSettingTypeRDBOnOff(void); // Disable default constructor

View File

@ -15,27 +15,27 @@ class CSettingTypeRDBRDRamSize :
{ {
public: public:
CSettingTypeRDBRDRamSize(const char * Name, SettingID DefaultSetting ); CSettingTypeRDBRDRamSize(const char * Name, SettingID DefaultSetting );
CSettingTypeRDBRDRamSize(const char * Name, int DefaultValue ); CSettingTypeRDBRDRamSize(const char * Name, int32_t DefaultValue );
~CSettingTypeRDBRDRamSize(); ~CSettingTypeRDBRDRamSize();
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int32_t Index, bool & Value ) const;
virtual void LoadDefault ( int Index, uint32_t & Value ) const; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int32_t Index );
private: private:
CSettingTypeRDBRDRamSize(void); // Disable default constructor CSettingTypeRDBRDRamSize(void); // Disable default constructor

View File

@ -15,27 +15,27 @@ class CSettingTypeRDBSaveChip :
{ {
public: public:
CSettingTypeRDBSaveChip(const char * Name, SettingID DefaultSetting ); CSettingTypeRDBSaveChip(const char * Name, SettingID DefaultSetting );
CSettingTypeRDBSaveChip(const char * Name, int DefaultValue ); CSettingTypeRDBSaveChip(const char * Name, int32_t DefaultValue );
~CSettingTypeRDBSaveChip(); ~CSettingTypeRDBSaveChip();
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int32_t Index, bool & Value ) const;
virtual void LoadDefault ( int Index, uint32_t & Value ) const; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int32_t Index );
private: private:
CSettingTypeRDBSaveChip(void); // Disable default constructor CSettingTypeRDBSaveChip(void); // Disable default constructor

View File

@ -15,27 +15,27 @@ class CSettingTypeRDBYesNo :
{ {
public: public:
CSettingTypeRDBYesNo(const char * Name, SettingID DefaultSetting ); CSettingTypeRDBYesNo(const char * Name, SettingID DefaultSetting );
CSettingTypeRDBYesNo(const char * Name, int DefaultValue ); CSettingTypeRDBYesNo(const char * Name, int32_t DefaultValue );
~CSettingTypeRDBYesNo(); ~CSettingTypeRDBYesNo();
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int32_t Index, bool & Value ) const;
virtual void LoadDefault ( int Index, uint32_t & Value ) const; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int32_t Index );
private: private:
CSettingTypeRDBYesNo(void); // Disable default constructor CSettingTypeRDBYesNo(void); // Disable default constructor

View File

@ -25,23 +25,23 @@ public:
SettingType GetSettingType ( void ) const { return SettingType_RelativePath; } SettingType GetSettingType ( void ) const { return SettingType_RelativePath; }
//return the values //return the values
bool Load ( int /*Index*/, bool & /*Value*/ ) const { return false; }; bool Load ( int32_t /*Index*/, bool & /*Value*/ ) const { return false; };
bool Load ( int /*Index*/, uint32_t & /*Value*/ ) const { return false; }; bool Load ( int32_t /*Index*/, uint32_t & /*Value*/ ) const { return false; };
bool Load ( int Index, stdstr & Value ) const; bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
void LoadDefault ( int Index, bool & Value ) const; void LoadDefault ( int32_t Index, bool & Value ) const;
void LoadDefault ( int Index, uint32_t & Value ) const; void LoadDefault ( int32_t Index, uint32_t & Value ) const;
void LoadDefault ( int Index, stdstr & Value ) const; void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
void Save ( int Index, bool Value ); void Save ( int32_t Index, bool Value );
void Save ( int Index, uint32_t Value ); void Save ( int32_t Index, uint32_t Value );
void Save ( int Index, const stdstr & Value ); void Save ( int32_t Index, const stdstr & Value );
void Save ( int Index, const char * Value ); void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
void Delete ( int Index ); void Delete ( int32_t Index );
private: private:
CSettingTypeRelativePath(void); // Disable default constructor CSettingTypeRelativePath(void); // Disable default constructor

View File

@ -19,7 +19,7 @@ class CSettingTypeRomDatabase :
public: public:
CSettingTypeRomDatabase(const char * Name, const char * DefaultValue, bool DeleteOnDefault = false ); CSettingTypeRomDatabase(const char * Name, const char * DefaultValue, bool DeleteOnDefault = false );
CSettingTypeRomDatabase(const char * Name, bool DefaultValue, bool DeleteOnDefault = false ); CSettingTypeRomDatabase(const char * Name, bool DefaultValue, bool DeleteOnDefault = false );
CSettingTypeRomDatabase(const char * Name, int DefaultValue, bool DeleteOnDefault = false ); CSettingTypeRomDatabase(const char * Name, int32_t DefaultValue, bool DeleteOnDefault = false );
CSettingTypeRomDatabase(const char * Name, SettingID DefaultSetting, bool DeleteOnDefault = false ); CSettingTypeRomDatabase(const char * Name, SettingID DefaultSetting, bool DeleteOnDefault = false );
virtual ~CSettingTypeRomDatabase(); virtual ~CSettingTypeRomDatabase();
@ -28,23 +28,23 @@ public:
virtual SettingType GetSettingType ( void ) const { return SettingType_RomDatabase; } virtual SettingType GetSettingType ( void ) const { return SettingType_RomDatabase; }
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int32_t Index, bool & Value ) const;
virtual void LoadDefault ( int Index, uint32_t & Value ) const; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int32_t Index );
static void Initialize( void ); static void Initialize( void );
static void CleanUp ( void ); static void CleanUp ( void );
@ -58,7 +58,7 @@ protected:
mutable stdstr m_KeyName; mutable stdstr m_KeyName;
const char *const m_DefaultStr; const char *const m_DefaultStr;
const int m_DefaultValue; const int32_t m_DefaultValue;
const SettingID m_DefaultSetting; const SettingID m_DefaultSetting;
const bool m_DeleteOnDefault; const bool m_DeleteOnDefault;
bool m_GlideSetting; bool m_GlideSetting;

View File

@ -16,7 +16,7 @@ class CSettingTypeRomDatabaseIndex :
public: public:
CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, const char * DefaultValue ); CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, const char * DefaultValue );
CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, bool DefaultValue ); CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, bool DefaultValue );
CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, int DefaultValue ); CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, int32_t DefaultValue );
CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, SettingID DefaultSetting ); CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, SettingID DefaultSetting );
virtual ~CSettingTypeRomDatabaseIndex(); virtual ~CSettingTypeRomDatabaseIndex();
@ -24,23 +24,23 @@ public:
virtual bool IndexBasedSetting ( void ) const { return true; } virtual bool IndexBasedSetting ( void ) const { return true; }
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int32_t Index, bool & Value ) const;
virtual void LoadDefault ( int Index, uint32_t & Value ) const; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int32_t Index );
private: private:
CSettingTypeRomDatabaseIndex(void); // Disable default constructor CSettingTypeRomDatabaseIndex(void); // Disable default constructor

View File

@ -6,22 +6,22 @@ class CSettingTypeRomDatabase :
public: public:
CSettingTypeRomDatabase(const char * Name, const char * DefaultValue ); CSettingTypeRomDatabase(const char * Name, const char * DefaultValue );
CSettingTypeRomDatabase(const char * Name, bool DefaultValue ); CSettingTypeRomDatabase(const char * Name, bool DefaultValue );
CSettingTypeRomDatabase(const char * Name, int DefaultValue ); CSettingTypeRomDatabase(const char * Name, int32_t DefaultValue );
CSettingTypeRomDatabase(const char * Name, SettingID DefaultSetting ); CSettingTypeRomDatabase(const char * Name, SettingID DefaultSetting );
~CSettingTypeRomDatabase(); ~CSettingTypeRomDatabase();
virtual SettingLocation GetSettingsLocation ( void ) const { return SettingLocation_RomDatabase; } virtual SettingLocation GetSettingsLocation ( void ) const { return SettingLocation_RomDatabase; }
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
static void Initilize ( void ); static void Initilize ( void );
@ -32,7 +32,7 @@ private:
const const char * m_KeyName; const const char * m_KeyName;
const const char * m_DefaultStr; const const char * m_DefaultStr;
const int m_DefaultValue; const int32_t m_DefaultValue;
const SettingID m_DefaultSetting; const SettingID m_DefaultSetting;
static CIniFile * m_SettingsIniFile; static CIniFile * m_SettingsIniFile;

View File

@ -25,23 +25,23 @@ public:
const char * GetName ( void ) const { return m_Name.c_str(); } const char * GetName ( void ) const { return m_Name.c_str(); }
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int32_t Index, bool & Value ) const;
virtual bool Load ( int Index, uint32_t & Value ) const; virtual bool Load ( int32_t Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int32_t Index, bool & Value ) const;
virtual void LoadDefault ( int Index, uint32_t & Value ) const; virtual void LoadDefault ( int32_t Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int32_t Index, bool Value );
virtual void Save ( int Index, uint32_t Value ); virtual void Save ( int32_t Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int32_t Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int32_t Index );
private: private:
CSettingTypeSelectedDirectory(void); // Disable default constructor CSettingTypeSelectedDirectory(void); // Disable default constructor

View File

@ -23,23 +23,23 @@ public:
SettingType GetSettingType ( void ) const { return SettingType_BoolVariable; } SettingType GetSettingType ( void ) const { return SettingType_BoolVariable; }
//return the values //return the values
bool Load ( int Index, bool & Value ) const; bool Load ( int32_t Index, bool & Value ) const;
bool Load ( int Index, uint32_t & Value ) const; bool Load ( int32_t Index, uint32_t & Value ) const;
bool Load ( int Index, stdstr & Value ) const; bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
void LoadDefault ( int Index, bool & Value ) const; void LoadDefault ( int32_t Index, bool & Value ) const;
void LoadDefault ( int Index, uint32_t & Value ) const; void LoadDefault ( int32_t Index, uint32_t & Value ) const;
void LoadDefault ( int Index, stdstr & Value ) const; void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
void Save ( int Index, bool Value ); void Save ( int32_t Index, bool Value );
void Save ( int Index, uint32_t Value ); void Save ( int32_t Index, uint32_t Value );
void Save ( int Index, const stdstr & Value ); void Save ( int32_t Index, const stdstr & Value );
void Save ( int Index, const char * Value ); void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
void Delete ( int Index ); void Delete ( int32_t Index );
private: private:
CSettingTypeTempBool(void); // Disable default constructor CSettingTypeTempBool(void); // Disable default constructor

View File

@ -23,23 +23,23 @@ public:
SettingType GetSettingType ( void ) const { return SettingType_NumberVariable; } SettingType GetSettingType ( void ) const { return SettingType_NumberVariable; }
//return the values //return the values
bool Load ( int Index, bool & Value ) const; bool Load ( int32_t Index, bool & Value ) const;
bool Load ( int Index, uint32_t & Value ) const; bool Load ( int32_t Index, uint32_t & Value ) const;
bool Load ( int Index, stdstr & Value ) const; bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
void LoadDefault ( int Index, bool & Value ) const; void LoadDefault ( int32_t Index, bool & Value ) const;
void LoadDefault ( int Index, uint32_t & Value ) const; void LoadDefault ( int32_t Index, uint32_t & Value ) const;
void LoadDefault ( int Index, stdstr & Value ) const; void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
void Save ( int Index, bool Value ); void Save ( int32_t Index, bool Value );
void Save ( int Index, uint32_t Value ); void Save ( int32_t Index, uint32_t Value );
void Save ( int Index, const stdstr & Value ); void Save ( int32_t Index, const stdstr & Value );
void Save ( int Index, const char * Value ); void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
void Delete ( int Index ); void Delete ( int32_t Index );
private: private:
CSettingTypeTempNumber(void); // Disable default constructor CSettingTypeTempNumber(void); // Disable default constructor

View File

@ -23,23 +23,23 @@ public:
SettingType GetSettingType ( void ) const { return SettingType_StringVariable; } SettingType GetSettingType ( void ) const { return SettingType_StringVariable; }
//return the values //return the values
bool Load ( int Index, bool & Value ) const; bool Load ( int32_t Index, bool & Value ) const;
bool Load ( int Index, uint32_t & Value ) const; bool Load ( int32_t Index, uint32_t & Value ) const;
bool Load ( int Index, stdstr & Value ) const; bool Load ( int32_t Index, stdstr & Value ) const;
//return the default values //return the default values
void LoadDefault ( int Index, bool & Value ) const; void LoadDefault ( int32_t Index, bool & Value ) const;
void LoadDefault ( int Index, uint32_t & Value ) const; void LoadDefault ( int32_t Index, uint32_t & Value ) const;
void LoadDefault ( int Index, stdstr & Value ) const; void LoadDefault ( int32_t Index, stdstr & Value ) const;
//Update the settings //Update the settings
void Save ( int Index, bool Value ); void Save ( int32_t Index, bool Value );
void Save ( int Index, uint32_t Value ); void Save ( int32_t Index, uint32_t Value );
void Save ( int Index, const stdstr & Value ); void Save ( int32_t Index, const stdstr & Value );
void Save ( int Index, const char * Value ); void Save ( int32_t Index, const char * Value );
// Delete the setting // Delete the setting
void Delete ( int Index ); void Delete ( int32_t Index );
private: private:
CSettingTypeTempString(void); // Disable default constructor CSettingTypeTempString(void); // Disable default constructor

View File

@ -30,6 +30,7 @@
#include "SettingType/SettingsType-TempNumber.h" #include "SettingType/SettingsType-TempNumber.h"
#include "SettingType/SettingsType-TempBool.h" #include "SettingType/SettingsType-TempBool.h"
#include "Settings Class.h" #include "Settings Class.h"
#include "N64 System/N64 Types.h"
#include <Common/TraceDefs.h> #include <Common/TraceDefs.h>
CSettings * g_Settings = NULL; CSettings * g_Settings = NULL;
@ -109,6 +110,7 @@ void CSettings::AddHowToHandleSetting ()
AddHandler(Setting_ApplicationName, new CSettingTypeTempString("")); AddHandler(Setting_ApplicationName, new CSettingTypeTempString(""));
AddHandler(Setting_UseFromRegistry, new CSettingTypeApplication("Settings", "Use Registry", (uint32_t)false)); AddHandler(Setting_UseFromRegistry, new CSettingTypeApplication("Settings", "Use Registry", (uint32_t)false));
AddHandler(Setting_RdbEditor, new CSettingTypeApplication("", "Rdb Editor", false)); AddHandler(Setting_RdbEditor, new CSettingTypeApplication("", "Rdb Editor", false));
AddHandler(Setting_CN64TimeCritical,new CSettingTypeApplication("","CN64TimeCritical",false));
AddHandler(Setting_PluginPageFirst, new CSettingTypeApplication("", "Plugin Page First", false)); AddHandler(Setting_PluginPageFirst, new CSettingTypeApplication("", "Plugin Page First", false));
AddHandler(Setting_DisableScrSaver, new CSettingTypeApplication("", "Disable Screen Saver", (uint32_t)true)); AddHandler(Setting_DisableScrSaver, new CSettingTypeApplication("", "Disable Screen Saver", (uint32_t)true));
AddHandler(Setting_AutoSleep, new CSettingTypeApplication("", "Auto Sleep", (uint32_t)true)); AddHandler(Setting_AutoSleep, new CSettingTypeApplication("", "Auto Sleep", (uint32_t)true));
@ -172,6 +174,7 @@ void CSettings::AddHowToHandleSetting ()
AddHandler(Rdb_CRC_Recalc, new CSettingTypeRDBYesNo("CRC-Recalc", false)); AddHandler(Rdb_CRC_Recalc, new CSettingTypeRDBYesNo("CRC-Recalc", false));
AddHandler(Game_IniKey, new CSettingTypeTempString("")); AddHandler(Game_IniKey, new CSettingTypeTempString(""));
AddHandler(Game_File, new CSettingTypeTempString(""));
AddHandler(Game_GameName, new CSettingTypeTempString("")); AddHandler(Game_GameName, new CSettingTypeTempString(""));
AddHandler(Game_GoodName, new CSettingTypeGame("Good Name", Rdb_GoodName)); AddHandler(Game_GoodName, new CSettingTypeGame("Good Name", Rdb_GoodName));
AddHandler(Game_TempLoaded, new CSettingTypeTempBool(false)); AddHandler(Game_TempLoaded, new CSettingTypeTempBool(false));
@ -304,7 +307,6 @@ void CSettings::AddHowToHandleSetting ()
AddHandler(Debugger_ShowDListAListCount, new CSettingTypeApplication("Debugger", "Show Dlist Alist Count", false)); AddHandler(Debugger_ShowDListAListCount, new CSettingTypeApplication("Debugger", "Show Dlist Alist Count", false));
AddHandler(Debugger_ShowRecompMemSize, new CSettingTypeApplication("Debugger", "Show Recompiler Memory size", false)); AddHandler(Debugger_ShowRecompMemSize, new CSettingTypeApplication("Debugger", "Show Recompiler Memory size", false));
AddHandler(Debugger_ShowDivByZero, new CSettingTypeApplication("Debugger", "Show Div by zero", false)); AddHandler(Debugger_ShowDivByZero, new CSettingTypeApplication("Debugger", "Show Div by zero", false));
AddHandler(Debugger_GenerateDebugLog, new CSettingTypeApplication("Debugger","Generate Debug Code",false));
AddHandler(Debugger_ProfileCode, new CSettingTypeApplication("Debugger", "Profile Code", (uint32_t)false)); AddHandler(Debugger_ProfileCode, new CSettingTypeApplication("Debugger", "Profile Code", (uint32_t)false));
AddHandler(Debugger_AppLogLevel, new CSettingTypeApplication("Logging", "Log Level", (uint32_t)TraceError)); AddHandler(Debugger_AppLogLevel, new CSettingTypeApplication("Logging", "Log Level", (uint32_t)TraceError));
AddHandler(Debugger_AppLogFlush, new CSettingTypeApplication("Logging", "Log Auto Flush", (uint32_t)false)); AddHandler(Debugger_AppLogFlush, new CSettingTypeApplication("Logging", "Log Auto Flush", (uint32_t)false));
@ -324,6 +326,33 @@ void CSettings::AddHowToHandleSetting ()
AddHandler(Plugin_UseHleGfx, new CSettingTypeApplication("RSP", "HLE GFX", true)); AddHandler(Plugin_UseHleGfx, new CSettingTypeApplication("RSP", "HLE GFX", true));
AddHandler(Plugin_UseHleAudio, new CSettingTypeApplication("RSP", "HLE Audio", false)); AddHandler(Plugin_UseHleAudio, new CSettingTypeApplication("RSP", "HLE Audio", false));
//Logging
AddHandler(Logging_GenerateLog, new CSettingTypeApplication("Logging", "Generate Log Files", false));
AddHandler(Logging_LogRDRamRegisters, new CSettingTypeApplication("Logging", "Log RDRam Registers", false));
AddHandler(Logging_LogSPRegisters, new CSettingTypeApplication("Logging", "Log SP Registers", false));
AddHandler(Logging_LogDPCRegisters, new CSettingTypeApplication("Logging", "Log DPC Registers", false));
AddHandler(Logging_LogDPSRegisters, new CSettingTypeApplication("Logging", "Log DPS Registers", false));
AddHandler(Logging_LogMIPSInterface, new CSettingTypeApplication("Logging", "Log MIPS Interface", false));
AddHandler(Logging_LogVideoInterface, new CSettingTypeApplication("Logging", "Log Video Interface", false));
AddHandler(Logging_LogAudioInterface, new CSettingTypeApplication("Logging", "Log Audio Interface", false));
AddHandler(Logging_LogPerInterface, new CSettingTypeApplication("Logging", "Log Per Interface", false));
AddHandler(Logging_LogRDRAMInterface, new CSettingTypeApplication("Logging", "Log RDRAM Interface", false));
AddHandler(Logging_LogSerialInterface, new CSettingTypeApplication("Logging", "Log Serial Interface", false));
AddHandler(Logging_LogPRDMAOperations, new CSettingTypeApplication("Logging", "Log PR DMA Operations", false));
AddHandler(Logging_LogPRDirectMemLoads, new CSettingTypeApplication("Logging", "Log PR Direct Mem Loads", false));
AddHandler(Logging_LogPRDMAMemLoads, new CSettingTypeApplication("Logging", "Log PR DMA Mem Loads", false));
AddHandler(Logging_LogPRDirectMemStores, new CSettingTypeApplication("Logging", "Log PR Direct Mem Stores", false));
AddHandler(Logging_LogPRDMAMemStores, new CSettingTypeApplication("Logging", "Log PRDMA Mem Stores", false));
AddHandler(Logging_LogControllerPak, new CSettingTypeApplication("Logging", "Log Controller Pak", false));
AddHandler(Logging_LogCP0changes, new CSettingTypeApplication("Logging", "Log CP0 changes", false));
AddHandler(Logging_LogCP0reads, new CSettingTypeApplication("Logging", "Log CP0 reads", false));
AddHandler(Logging_LogTLB, new CSettingTypeApplication("Logging", "Log TLB", false));
AddHandler(Logging_LogExceptions, new CSettingTypeApplication("Logging", "Log Exceptions", false));
AddHandler(Logging_NoInterrupts, new CSettingTypeApplication("Logging", "No Interrupts", false));
AddHandler(Logging_LogCache, new CSettingTypeApplication("Logging", "Log Cache", false));
AddHandler(Logging_LogRomHeader, new CSettingTypeApplication("Logging", "Generate Log Files", false));
AddHandler(Logging_LogUnknown, new CSettingTypeApplication("Logging", "Log Rom Header", false));
// cheats // cheats
AddHandler(Cheat_Entry, new CSettingTypeCheats("")); AddHandler(Cheat_Entry, new CSettingTypeCheats(""));
AddHandler(Cheat_Active, new CSettingTypeGameIndex("Cheat", "", (uint32_t)false)); AddHandler(Cheat_Active, new CSettingTypeGameIndex("Cheat", "", (uint32_t)false));
@ -391,7 +420,7 @@ const char * CSettings::GetSettingSz ( CSettings * _this, SettingID Type, char *
return Buffer; return Buffer;
} }
void CSettings::SetSetting ( CSettings * _this, SettingID ID, unsigned int Value ) void CSettings::SetSetting(CSettings * _this, SettingID ID, uint32_t Value)
{ {
_this->SaveDword(ID, Value); _this->SaveDword(ID, Value);
} }
@ -431,7 +460,9 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
if (DefaultID == Default_None) if (DefaultID == Default_None)
{ {
_this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, Value)); _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, Value));
} else { }
else
{
_this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, DefaultID)); _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, DefaultID));
} }
break; break;
@ -439,7 +470,9 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
if (DefaultID == Default_None) if (DefaultID == Default_None)
{ {
_this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, "")); _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, ""));
} else { }
else
{
_this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, DefaultID)); _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, DefaultID));
} }
break; break;
@ -459,7 +492,9 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
_this->m_NextAutoSettingId += 1; _this->m_NextAutoSettingId += 1;
_this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), (int)Value)); _this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), (int)Value));
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting)); _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting));
} else { }
else
{
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), DefaultID)); _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), DefaultID));
} }
break; break;
@ -467,7 +502,9 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
if (DefaultID == Default_None) if (DefaultID == Default_None)
{ {
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), "")); _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), ""));
} else { }
else
{
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), DefaultID)); _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), DefaultID));
} }
break; break;
@ -483,7 +520,9 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
if (DefaultID == Default_None) if (DefaultID == Default_None)
{ {
_this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, (int)Value, true)); _this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, (int)Value, true));
} else { }
else
{
_this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, (SettingID)Value, true)); _this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, (SettingID)Value, true));
} }
break; break;
@ -491,7 +530,9 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
if (DefaultID == Default_None) if (DefaultID == Default_None)
{ {
_this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, "", true)); _this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, "", true));
} else { }
else
{
_this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, DefaultID, true)); _this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, DefaultID, true));
} }
break; break;
@ -506,7 +547,9 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def
if (DefaultID == Default_None) if (DefaultID == Default_None)
{ {
_this->AddHandler(ID, new CSettingTypeRomDatabaseSetting(Category, DefaultStr, (int)Value, true)); _this->AddHandler(ID, new CSettingTypeRomDatabaseSetting(Category, DefaultStr, (int)Value, true));
} else { }
else
{
SettingID RdbSetting = (SettingID)_this->m_NextAutoSettingId; SettingID RdbSetting = (SettingID)_this->m_NextAutoSettingId;
_this->m_NextAutoSettingId += 1; _this->m_NextAutoSettingId += 1;
_this->AddHandler(RdbSetting, new CSettingTypeRomDatabaseSetting(Category, DefaultStr, DefaultID, true)); _this->AddHandler(RdbSetting, new CSettingTypeRomDatabaseSetting(Category, DefaultStr, DefaultID, true));
@ -553,7 +596,9 @@ bool CSettings::LoadBool ( SettingID Type, bool & Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else
{
return FindInfo->second->Load(0, Value); return FindInfo->second->Load(0, Value);
} }
return false; return false;
@ -578,7 +623,9 @@ bool CSettings::LoadBoolIndex( SettingID Type, int index , bool & Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
return FindInfo->second->Load(index, Value); return FindInfo->second->Load(index, Value);
} else { }
else
{
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
return false; return false;
@ -603,7 +650,9 @@ bool CSettings::LoadDword ( SettingID Type, uint32_t & Value)
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else
{
return FindInfo->second->Load(0, Value); return FindInfo->second->Load(0, Value);
} }
return false; return false;
@ -628,7 +677,9 @@ bool CSettings::LoadDwordIndex( SettingID Type, int index, uint32_t & Value)
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
return FindInfo->second->Load(index, Value); return FindInfo->second->Load(index, Value);
} else { }
else
{
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
return false; return false;
@ -653,7 +704,9 @@ bool CSettings::LoadStringVal ( SettingID Type, stdstr & Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else
{
return FindInfo->second->Load(0, Value); return FindInfo->second->Load(0, Value);
} }
return false; return false;
@ -672,7 +725,9 @@ bool CSettings::LoadStringVal ( SettingID Type, char * Buffer, int BufferSize )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else
{
stdstr Value; stdstr Value;
bRes = FindInfo->second->Load(0, Value); bRes = FindInfo->second->Load(0, Value);
int len = BufferSize; int len = BufferSize;
@ -704,7 +759,9 @@ bool CSettings::LoadStringIndex ( SettingID Type, int index, stdstr & Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
return FindInfo->second->Load(index, Value); return FindInfo->second->Load(index, Value);
} else { }
else
{
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
return false; return false;
@ -731,11 +788,15 @@ void CSettings::LoadDefaultBool ( SettingID Type, bool & Value )
{ {
//if not found do nothing //if not found do nothing
UnknownSetting(Type); UnknownSetting(Type);
} else { }
else
{
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else
{
FindInfo->second->LoadDefault(0, Value); FindInfo->second->LoadDefault(0, Value);
} }
} }
@ -766,11 +827,15 @@ void CSettings::LoadDefaultDword ( SettingID Type, uint32_t & Value)
{ {
//if not found do nothing //if not found do nothing
UnknownSetting(Type); UnknownSetting(Type);
} else { }
else
{
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else
{
FindInfo->second->LoadDefault(0, Value); FindInfo->second->LoadDefault(0, Value);
} }
} }
@ -801,11 +866,15 @@ void CSettings::LoadDefaultString ( SettingID Type, stdstr & Value )
{ {
//if not found do nothing //if not found do nothing
UnknownSetting(Type); UnknownSetting(Type);
} else { }
else
{
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else
{
FindInfo->second->LoadDefault(0, Value); FindInfo->second->LoadDefault(0, Value);
} }
} }
@ -844,7 +913,9 @@ void CSettings::SaveBool ( SettingID Type, bool Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else
{
FindInfo->second->Save(0, Value); FindInfo->second->Save(0, Value);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -862,7 +933,9 @@ void CSettings::SaveBoolIndex( SettingID Type, int index, bool Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
FindInfo->second->Save(index, Value); FindInfo->second->Save(index, Value);
} else { }
else
{
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -880,7 +953,9 @@ void CSettings::SaveDword ( SettingID Type, uint32_t Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else
{
FindInfo->second->Save(0, Value); FindInfo->second->Save(0, Value);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -898,7 +973,9 @@ void CSettings::SaveDwordIndex ( SettingID Type, int index, uint32_t Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
FindInfo->second->Save(index, Value); FindInfo->second->Save(index, Value);
} else { }
else
{
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -916,7 +993,9 @@ void CSettings::SaveString ( SettingID Type, const stdstr & Value )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else
{
FindInfo->second->Save(0, Value); FindInfo->second->Save(0, Value);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -933,7 +1012,9 @@ void CSettings::SaveString ( SettingID Type, const char * Buffer )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else
{
FindInfo->second->Save(0, Buffer); FindInfo->second->Save(0, Buffer);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -950,7 +1031,9 @@ void CSettings::SaveStringIndex( SettingID Type, int index, const char * Buffer
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
FindInfo->second->Save(index, Buffer); FindInfo->second->Save(index, Buffer);
} else { }
else
{
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -972,7 +1055,9 @@ void CSettings::DeleteSetting( SettingID Type )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} else { }
else
{
FindInfo->second->Delete(0); FindInfo->second->Delete(0);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -989,7 +1074,9 @@ void CSettings::DeleteSettingIndex( SettingID Type, int index )
if (FindInfo->second->IndexBasedSetting()) if (FindInfo->second->IndexBasedSetting())
{ {
FindInfo->second->Delete(index); FindInfo->second->Delete(index);
} else { }
else
{
g_Notify->BreakPoint(__FILEW__, __LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
NotifyCallBacks(Type); NotifyCallBacks(Type);
@ -1067,7 +1154,9 @@ void CSettings::RegisterChangeCB(SettingID Type,void * Data, SettingChangedFunc
item = item->Next; item = item->Next;
} }
item->Next = new_item; item->Next = new_item;
} else { }
else
{
m_Callback.insert(SETTING_CALLBACK::value_type(Type, new_item)); m_Callback.insert(SETTING_CALLBACK::value_type(Type, new_item));
} }
} }
@ -1096,10 +1185,14 @@ void CSettings::UnregisterChangeCB(SettingID Type,void * Data, SettingChangedFun
SETTING_CHANGED_CB * Next = item->Next; SETTING_CHANGED_CB * Next = item->Next;
m_Callback.erase(Callback); m_Callback.erase(Callback);
m_Callback.insert(SETTING_CALLBACK::value_type(Type, Next)); m_Callback.insert(SETTING_CALLBACK::value_type(Type, Next));
} else { }
else
{
m_Callback.erase(Callback); m_Callback.erase(Callback);
} }
} else { }
else
{
PrevItem->Next = item->Next; PrevItem->Next = item->Next;
} }
delete item; delete item;
@ -1109,7 +1202,9 @@ void CSettings::UnregisterChangeCB(SettingID Type,void * Data, SettingChangedFun
PrevItem = item; PrevItem = item;
item = item->Next; item = item->Next;
} }
} else { }
else
{
UnknownSetting(Type); UnknownSetting(Type);
return; return;
} }

View File

@ -53,48 +53,48 @@ public:
//return the values //return the values
bool LoadBool ( SettingID Type ); bool LoadBool ( SettingID Type );
bool LoadBool ( SettingID Type, bool & Value ); bool LoadBool ( SettingID Type, bool & Value );
bool LoadBoolIndex ( SettingID Type, int index ); bool LoadBoolIndex ( SettingID Type, int32_t index );
bool LoadBoolIndex ( SettingID Type, int index , bool & Value ); bool LoadBoolIndex ( SettingID Type, int32_t index , bool & Value );
uint32_t LoadDword ( SettingID Type ); uint32_t LoadDword ( SettingID Type );
bool LoadDword ( SettingID Type, uint32_t & Value ); bool LoadDword ( SettingID Type, uint32_t & Value );
uint32_t LoadDwordIndex ( SettingID Type, int index ); uint32_t LoadDwordIndex ( SettingID Type, int32_t index );
bool LoadDwordIndex ( SettingID Type, int index, uint32_t & Value); bool LoadDwordIndex ( SettingID Type, int32_t index, uint32_t & Value );
stdstr LoadStringVal ( SettingID Type ); stdstr LoadStringVal ( SettingID Type );
bool LoadStringVal (SettingID Type, stdstr & Value); bool LoadStringVal (SettingID Type, stdstr & Value);
bool LoadStringVal (SettingID Type, char * Buffer, int BufferSize); bool LoadStringVal (SettingID Type, char * Buffer, int32_t BufferSize );
stdstr LoadStringIndex ( SettingID Type, int index ); stdstr LoadStringIndex ( SettingID Type, int32_t index );
bool LoadStringIndex ( SettingID Type, int index, stdstr & Value ); bool LoadStringIndex ( SettingID Type, int32_t index, stdstr & Value );
bool LoadStringIndex ( SettingID Type, int index, char * Buffer, int BufferSize ); bool LoadStringIndex ( SettingID Type, int32_t index, char * Buffer, int32_t BufferSize );
//Load the default value for the setting //Load the default value for the setting
bool LoadDefaultBool ( SettingID Type ); bool LoadDefaultBool ( SettingID Type );
void LoadDefaultBool ( SettingID Type, bool & Value ); void LoadDefaultBool ( SettingID Type, bool & Value );
bool LoadDefaultBoolIndex ( SettingID Type, int index ); bool LoadDefaultBoolIndex ( SettingID Type, int32_t index );
void LoadDefaultBoolIndex ( SettingID Type, int index , bool & Value ); void LoadDefaultBoolIndex ( SettingID Type, int32_t index , bool & Value );
uint32_t LoadDefaultDword ( SettingID Type ); uint32_t LoadDefaultDword ( SettingID Type );
void LoadDefaultDword ( SettingID Type, uint32_t & Value); void LoadDefaultDword ( SettingID Type, uint32_t & Value);
uint32_t LoadDefaultDwordIndex ( SettingID Type, int index ); uint32_t LoadDefaultDwordIndex ( SettingID Type, int32_t index );
void LoadDefaultDwordIndex ( SettingID Type, int index, uint32_t & Value); void LoadDefaultDwordIndex ( SettingID Type, int32_t index, uint32_t & Value);
stdstr LoadDefaultString ( SettingID Type ); stdstr LoadDefaultString ( SettingID Type );
void LoadDefaultString ( SettingID Type, stdstr & Value ); void LoadDefaultString ( SettingID Type, stdstr & Value );
void LoadDefaultString ( SettingID Type, char * Buffer, int BufferSize ); void LoadDefaultString ( SettingID Type, char * Buffer, int32_t BufferSize );
stdstr LoadDefaultStringIndex ( SettingID Type, int index ); stdstr LoadDefaultStringIndex ( SettingID Type, int32_t index );
void LoadDefaultStringIndex ( SettingID Type, int index, stdstr & Value ); void LoadDefaultStringIndex ( SettingID Type, int32_t index, stdstr & Value );
void LoadDefaultStringIndex ( SettingID Type, int index, char * Buffer, int BufferSize ); void LoadDefaultStringIndex ( SettingID Type, int32_t index, char * Buffer, int32_t BufferSize );
//Update the settings //Update the settings
void SaveBool ( SettingID Type, bool Value ); void SaveBool ( SettingID Type, bool Value );
void SaveBoolIndex ( SettingID Type, int index, bool Value ); void SaveBoolIndex ( SettingID Type, int32_t index, bool Value );
void SaveDword ( SettingID Type, uint32_t Value ); void SaveDword ( SettingID Type, uint32_t Value );
void SaveDwordIndex ( SettingID Type, int index, uint32_t Value ); void SaveDwordIndex ( SettingID Type, int32_t index, uint32_t Value );
void SaveString ( SettingID Type, const stdstr & Value ); void SaveString ( SettingID Type, const stdstr & Value );
void SaveStringIndex ( SettingID Type, int index, const stdstr & Value ); void SaveStringIndex ( SettingID Type, int32_t index, const stdstr & Value );
void SaveString ( SettingID Type, const char * Buffer ); void SaveString ( SettingID Type, const char * Buffer );
void SaveStringIndex ( SettingID Type, int index, const char * Buffer ); void SaveStringIndex ( SettingID Type, int32_t index, const char * Buffer );
// Delete a setting // Delete a setting
void DeleteSetting ( SettingID Type ); void DeleteSetting ( SettingID Type );
void DeleteSettingIndex ( SettingID Type, int index ); void DeleteSettingIndex ( SettingID Type, int32_t index );
//Register Notification of change //Register Notification of change
void RegisterChangeCB ( SettingID Type, void * Data, SettingChangedFunc Func); void RegisterChangeCB ( SettingID Type, void * Data, SettingChangedFunc Func);
@ -107,8 +107,8 @@ public:
// static functions for plugins // static functions for plugins
static uint32_t GetSetting ( CSettings * _this, SettingID Type ); static uint32_t GetSetting ( CSettings * _this, SettingID Type );
static const char * GetSettingSz ( CSettings * _this, SettingID Type, char * Buffer, int BufferSize ); static const char * GetSettingSz ( CSettings * _this, SettingID Type, char * Buffer, int32_t BufferSize );
static void SetSetting ( CSettings * _this, SettingID ID, unsigned int Value ); static void SetSetting ( CSettings * _this, SettingID ID, uint32_t Value );
static void SetSettingSz ( CSettings * _this, SettingID ID, const char * Value ); static void SetSettingSz ( CSettings * _this, SettingID ID, const char * Value );
static void RegisterSetting ( CSettings * _this, SettingID ID, SettingID DefaultID, SettingDataType DataType, static void RegisterSetting ( CSettings * _this, SettingID ID, SettingID DefaultID, SettingDataType DataType,
SettingType Type, const char * Category, const char * DefaultStr, SettingType Type, const char * Category, const char * DefaultStr,
@ -121,7 +121,7 @@ private:
SETTING_MAP m_SettingInfo; SETTING_MAP m_SettingInfo;
SETTING_CALLBACK m_Callback; SETTING_CALLBACK m_Callback;
int m_NextAutoSettingId; int32_t m_NextAutoSettingId;
}; };
extern CSettings * g_Settings; extern CSettings * g_Settings;

View File

@ -0,0 +1,291 @@
/****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
enum
{
MaxPluginSetting = 65535
};
enum SettingID
{
//Default values
Default_None,
Default_Constant,
//information - temp keys
Info_ShortCutsChanged,
//Support Files
SupportFile_Settings,
SupportFile_SettingsDefault,
SupportFile_RomDatabase,
SupportFile_RomDatabaseDefault,
SupportFile_Glide64RDB,
SupportFile_Glide64RDBDefault,
SupportFile_Cheats,
SupportFile_CheatsDefault,
SupportFile_Notes,
SupportFile_NotesDefault,
SupportFile_ExtInfo,
SupportFile_ExtInfoDefault,
SupportFile_ShortCuts,
SupportFile_ShortCutsDefault,
SupportFile_RomListCache,
SupportFile_RomListCacheDefault,
SupportFile_7zipCache,
SupportFile_7zipCacheDefault,
//Settings
Setting_ApplicationName,
Setting_UseFromRegistry,
Setting_RdbEditor,
Setting_CN64TimeCritical,
Setting_PluginPageFirst,
Setting_DisableScrSaver,
Setting_AutoSleep,
Setting_AutoStart,
Setting_AutoFullscreen,
Setting_CheckEmuRunning,
Setting_EraseGameDefaults,
Setting_AutoZipInstantSave,
Setting_RememberCheats,
Setting_LanguageDir,
Setting_LanguageDirDefault,
Setting_CurrentLanguage,
//RDB TLB Settings
Rdb_GoodName,
Rdb_SaveChip,
Rdb_CpuType,
Rdb_RDRamSize,
Rdb_CounterFactor,
Rdb_UseTlb,
Rdb_DelayDP,
Rdb_DelaySi,
Rdb_32Bit,
Rdb_FastSP,
Rdb_Status,
Rdb_NotesCore,
Rdb_NotesPlugin,
Rdb_FixedAudio,
Rdb_SyncViaAudio,
Rdb_RspAudioSignal,
Rdb_TLB_VAddrStart,
Rdb_TLB_VAddrLen,
Rdb_TLB_PAddrStart,
Rdb_UseHleGfx,
Rdb_UseHleAudio,
Rdb_LoadRomToMemory,
Rdb_ScreenHertz,
Rdb_FuncLookupMode,
Rdb_RegCache,
Rdb_BlockLinking,
Rdb_SMM_StoreInstruc,
Rdb_SMM_Cache,
Rdb_SMM_PIDMA,
Rdb_SMM_TLB,
Rdb_SMM_Protect,
Rdb_SMM_ValidFunc,
Rdb_GameCheatFix,
Rdb_GameCheatFixPlugin,
Rdb_ViRefreshRate,
Rdb_AiCountPerBytes,
Rdb_AudioResetOnLoad,
Rdb_AllowROMWrites,
Rdb_CRC_Recalc,
//Individual Game Settings
Game_IniKey,
Game_File,
Game_GameName,
Game_GoodName,
Game_TempLoaded,
Game_SystemType,
Game_EditPlugin_Gfx,
Game_EditPlugin_Audio,
Game_EditPlugin_Contr,
Game_EditPlugin_RSP,
Game_Plugin_Gfx,
Game_Plugin_Audio,
Game_Plugin_Controller,
Game_Plugin_RSP,
Game_SaveChip,
Game_CpuType,
Game_LastSaveSlot,
Game_FixedAudio,
Game_SyncViaAudio,
Game_32Bit,
Game_SMM_Cache,
Game_SMM_Protect,
Game_SMM_ValidFunc,
Game_SMM_PIDMA,
Game_SMM_TLB,
Game_SMM_StoreInstruc,
Game_CurrentSaveState,
Game_RDRamSize,
Game_CounterFactor,
Game_UseTlb,
Game_DelayDP,
Game_DelaySI,
Game_FastSP,
Game_FuncLookupMode,
Game_RegCache,
Game_BlockLinking,
Game_ScreenHertz,
Game_RspAudioSignal,
Game_UseHleGfx,
Game_UseHleAudio,
Game_LoadRomToMemory,
Game_ViRefreshRate,
Game_AiCountPerBytes,
Game_AudioResetOnLoad,
Game_AllowROMWrites,
Game_CRC_Recalc,
// General Game running info
GameRunning_LoadingInProgress,
GameRunning_CPU_Running,
GameRunning_CPU_Paused,
GameRunning_CPU_PausedType,
GameRunning_InstantSaveFile,
GameRunning_LimitFPS,
GameRunning_ScreenHertz,
GameRunning_InReset,
//User Interface
UserInterface_BasicMode,
UserInterface_ShowCPUPer,
UserInterface_DisplayFrameRate,
UserInterface_InFullScreen,
UserInterface_FrameDisplayType,
UserInterface_MainWindowTop,
UserInterface_MainWindowLeft,
UserInterface_AlwaysOnTop,
RomBrowser_Enabled,
RomBrowser_ColoumnsChanged,
RomBrowser_Top,
RomBrowser_Left,
RomBrowser_Width,
RomBrowser_Height,
RomBrowser_PosIndex,
RomBrowser_WidthIndex,
RomBrowser_SortFieldIndex,
RomBrowser_SortAscendingIndex,
RomBrowser_Recursive,
RomBrowser_Maximized,
//Directory Info
Directory_LastSave,
Directory_RecentGameDirCount,
Directory_RecentGameDirIndex,
Directory_Game,
Directory_GameInitial,
Directory_GameSelected,
Directory_GameUseSelected,
Directory_Plugin,
Directory_PluginInitial,
Directory_PluginSelected,
Directory_PluginUseSelected,
Directory_PluginSync,
Directory_SnapShot,
Directory_SnapShotInitial,
Directory_SnapShotSelected,
Directory_SnapShotUseSelected,
Directory_NativeSave,
Directory_NativeSaveInitial,
Directory_NativeSaveSelected,
Directory_NativeSaveUseSelected,
Directory_InstantSave,
Directory_InstantSaveInitial,
Directory_InstantSaveSelected,
Directory_InstantSaveUseSelected,
Directory_Texture,
Directory_TextureInitial,
Directory_TextureSelected,
Directory_TextureUseSelected,
//File Info
File_RecentGameFileCount,
File_RecentGameFileIndex,
//Debugger
Debugger_Enabled,
Debugger_ShowTLBMisses,
Debugger_ShowUnhandledMemory,
Debugger_ShowPifErrors,
Debugger_ShowDivByZero,
Debugger_GenerateLogFiles,
Debugger_ProfileCode,
Debugger_DisableGameFixes,
Debugger_AppLogLevel,
Debugger_AppLogFlush,
Debugger_ShowDListAListCount,
Debugger_ShowRecompMemSize,
//Plugins
Plugin_RSP_Current,
Plugin_RSP_CurVer,
Plugin_GFX_Current,
Plugin_GFX_CurVer,
Plugin_AUDIO_Current,
Plugin_AUDIO_CurVer,
Plugin_CONT_Current,
Plugin_CONT_CurVer,
Plugin_UseHleGfx,
Plugin_UseHleAudio,
Logging_GenerateLog,
Logging_LogRDRamRegisters,
Logging_LogSPRegisters,
Logging_LogDPCRegisters,
Logging_LogDPSRegisters,
Logging_LogMIPSInterface,
Logging_LogVideoInterface,
Logging_LogAudioInterface,
Logging_LogPerInterface,
Logging_LogRDRAMInterface,
Logging_LogSerialInterface,
Logging_LogPRDMAOperations,
Logging_LogPRDirectMemLoads,
Logging_LogPRDMAMemLoads,
Logging_LogPRDirectMemStores,
Logging_LogPRDMAMemStores,
Logging_LogControllerPak,
Logging_LogCP0changes,
Logging_LogCP0reads,
Logging_LogTLB,
Logging_LogExceptions,
Logging_NoInterrupts,
Logging_LogCache,
Logging_LogRomHeader,
Logging_LogUnknown,
//Cheats
Cheat_Entry,
Cheat_Active,
Cheat_Extension,
Cheat_Notes,
Cheat_Options,
Cheat_Range,
Cheat_RangeNotes,
FirstRSPDefaultSet, LastRSPDefaultSet = FirstRSPDefaultSet + MaxPluginSetting,
FirstRSPSettings, LastRSPSettings = FirstRSPSettings + MaxPluginSetting,
FirstGfxDefaultSet, LastGfxDefaultSet = FirstGfxDefaultSet + MaxPluginSetting,
FirstGfxSettings, LastGfxSettings = FirstGfxSettings + MaxPluginSetting,
FirstAudioDefaultSet, LastAudioDefaultSet = FirstAudioDefaultSet + MaxPluginSetting,
FirstAudioSettings, LastAudioSettings = FirstAudioSettings + MaxPluginSetting,
FirstCtrlDefaultSet, LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting,
FirstCtrlSettings, LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting,
};

View File

@ -13,8 +13,8 @@
#pragma warning(disable:4786) #pragma warning(disable:4786)
#include "Support.h" #include "Support.h"
#include "Multilanguage.h" #include <Project64\Multilanguage.h>
#include "Settings.h" #include <Project64\Settings\Settings Class.h>
typedef unsigned char BYTE; typedef unsigned char BYTE;
typedef unsigned short WORD; typedef unsigned short WORD;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Some files were not shown because too many files have changed in this diff Show More