From 63b4a4c00373a57cebc51618dcec2f8b30d91e79 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 15 Nov 2018 21:28:51 +1100 Subject: [PATCH 01/32] [Project64] Make Project project LargeAddressAware --- Source/Project64/Project64.vcxproj | 1 + Source/Project64/Project64.vcxproj.filters | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/Project64/Project64.vcxproj b/Source/Project64/Project64.vcxproj index dad2dda96..1e7962529 100644 --- a/Source/Project64/Project64.vcxproj +++ b/Source/Project64/Project64.vcxproj @@ -41,6 +41,7 @@ 5.02 1 false + true true diff --git a/Source/Project64/Project64.vcxproj.filters b/Source/Project64/Project64.vcxproj.filters index 863b978a2..3e07a311c 100644 --- a/Source/Project64/Project64.vcxproj.filters +++ b/Source/Project64/Project64.vcxproj.filters @@ -120,9 +120,6 @@ Source Files\User Interface Source - - Source Files\User Interface Source - Source Files\User Interface Source @@ -216,6 +213,9 @@ Source Files\User Interface Source\WTL Controls Source + + Source Files + @@ -242,9 +242,6 @@ Header Files\User Interface Headers - - Header Files\User Interface Headers - Header Files\User Interface Headers @@ -413,6 +410,9 @@ Header Files\User Interface Headers\WTL Controls Headers + + Header Files + From dca4399567810af045e8f1aed56463a9fb5f8c22 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 18 Nov 2018 08:54:34 +1030 Subject: [PATCH 02/32] [Project64] Order alphabetically settings in Project64.cfg.development --- Config/Project64.cfg.development | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Config/Project64.cfg.development b/Config/Project64.cfg.development index d2e79b9a0..abb071316 100644 --- a/Config/Project64.cfg.development +++ b/Config/Project64.cfg.development @@ -1,15 +1,15 @@ [default] 7zipCache=..\..\Config\Project64.zcache +AudioRDB=..\..\Config\Audio.rdb Auto Sleep=0 Basic Mode=0 Cheats=..\..\Config\Project64.cht ExtInfo=..\..\Config\Project64.rdx -VideoRDB=..\..\Config\Video.rdb -AudioRDB=..\..\Config\Audio.rdb Notes=..\..\Config\Project64.rdn RomDatabase=..\..\Config\Project64.rdb RomListCache=..\..\Config\Project64.cache3 ShortCuts=..\..\Config\Project64.sc3 +VideoRDB=..\..\Config\Video.rdb [Debugger] Debugger=1 From e7f93f2def159215ae8ca1c31d1f8f1496fef8d0 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 18 Nov 2018 11:12:49 +1030 Subject: [PATCH 03/32] [Project64] Remove #include from Common/Trace.h --- Source/Common/CriticalSection.cpp | 3 +++ Source/Common/HighResTimeStamp.cpp | 4 +++- Source/Common/Thread.cpp | 4 +++- Source/Common/Trace.h | 6 ++---- Source/Project64-audio/AudioMain.cpp | 4 ++++ Source/Project64-core/N64System/Mips/FlashRam.cpp | 4 ---- Source/Project64-core/N64System/Mips/Sram.cpp | 4 ---- Source/Project64-video/Main.cpp | 1 + Source/Project64-video/ScreenResolution.cpp | 4 +++- 9 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Source/Common/CriticalSection.cpp b/Source/Common/CriticalSection.cpp index a1ea7bfcc..cacb214d9 100644 --- a/Source/Common/CriticalSection.cpp +++ b/Source/Common/CriticalSection.cpp @@ -1,4 +1,7 @@ #include "stdafx.h" +#ifdef _WIN32 +#include +#endif CriticalSection::CriticalSection() { diff --git a/Source/Common/HighResTimeStamp.cpp b/Source/Common/HighResTimeStamp.cpp index 29a59b130..926ee3907 100644 --- a/Source/Common/HighResTimeStamp.cpp +++ b/Source/Common/HighResTimeStamp.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "HighResTimeStamp.h" -#ifndef _WIN32 +#ifdef _WIN32 +#include +#else #include #endif diff --git a/Source/Common/Thread.cpp b/Source/Common/Thread.cpp index b47145453..a8cc74f82 100644 --- a/Source/Common/Thread.cpp +++ b/Source/Common/Thread.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "Thread.h" -#ifndef _WIN32 +#ifdef _WIN32 +#include +#else #include #include #include diff --git a/Source/Common/Trace.h b/Source/Common/Trace.h index 8f6440bc7..fb63555ea 100644 --- a/Source/Common/Trace.h +++ b/Source/Common/Trace.h @@ -11,10 +11,8 @@ enum TraceSeverity TraceVerbose = 0x00000006, }; -#if defined(_WIN32) -#include -#else -#define __interface struct +#ifndef _WIN32 +#define __interface struct #endif __interface CTraceModule diff --git a/Source/Project64-audio/AudioMain.cpp b/Source/Project64-audio/AudioMain.cpp index 5b16a8392..fd9e9bc00 100644 --- a/Source/Project64-audio/AudioMain.cpp +++ b/Source/Project64-audio/AudioMain.cpp @@ -249,6 +249,10 @@ EXPORT void CALL ProcessAList(void) WriteTrace(TraceAudioInterface, TraceDebug, "Called"); } +#ifdef _WIN32 +#include +#endif + extern "C" void UseUnregisteredSetting(int /*SettingID*/) { WriteTrace(TraceAudioInterface, TraceDebug, "Called"); diff --git a/Source/Project64-core/N64System/Mips/FlashRam.cpp b/Source/Project64-core/N64System/Mips/FlashRam.cpp index d20d2554b..2fc760de7 100644 --- a/Source/Project64-core/N64System/Mips/FlashRam.cpp +++ b/Source/Project64-core/N64System/Mips/FlashRam.cpp @@ -133,11 +133,7 @@ bool CFlashram::LoadFlashram() if (!m_File.Open(FileName, (m_ReadOnly ? CFileBase::modeRead : CFileBase::modeReadWrite) | CFileBase::modeNoTruncate | CFileBase::modeCreate)) { -#ifdef _WIN32 - WriteTrace(TraceN64System, TraceError, "Failed to open (%s), ReadOnly = %d, LastError = %X", (const char *)FileName, m_ReadOnly, GetLastError()); -#else WriteTrace(TraceN64System, TraceError, "Failed to open (%s), ReadOnly = %d", (const char *)FileName, m_ReadOnly); -#endif g_Notify->DisplayError(GS(MSG_FAIL_OPEN_FLASH)); return false; } diff --git a/Source/Project64-core/N64System/Mips/Sram.cpp b/Source/Project64-core/N64System/Mips/Sram.cpp index 1d9525f05..42ab34b65 100644 --- a/Source/Project64-core/N64System/Mips/Sram.cpp +++ b/Source/Project64-core/N64System/Mips/Sram.cpp @@ -36,11 +36,7 @@ bool CSram::LoadSram() if (!m_File.Open(FileName, (m_ReadOnly ? CFileBase::modeRead : CFileBase::modeReadWrite) | CFileBase::modeNoTruncate | CFileBase::modeCreate)) { -#ifdef _WIN32 - WriteTrace(TraceN64System, TraceError, "Failed to open (%s), ReadOnly = %d, LastError = %X", (const char *)FileName, m_ReadOnly, GetLastError()); -#else WriteTrace(TraceN64System, TraceError, "Failed to open (%s), ReadOnly = %d", (const char *)FileName, m_ReadOnly); -#endif return false; } m_File.SeekToBegin(); diff --git a/Source/Project64-video/Main.cpp b/Source/Project64-video/Main.cpp index ed993a0f9..bf487d150 100644 --- a/Source/Project64-video/Main.cpp +++ b/Source/Project64-video/Main.cpp @@ -37,6 +37,7 @@ #include "ScreenResolution.h" #ifdef _WIN32 +#include #include #endif diff --git a/Source/Project64-video/ScreenResolution.cpp b/Source/Project64-video/ScreenResolution.cpp index 73f341d5e..aa03fc455 100644 --- a/Source/Project64-video/ScreenResolution.cpp +++ b/Source/Project64-video/ScreenResolution.cpp @@ -11,7 +11,9 @@ #include "ScreenResolution.h" #include "settings.h" #include "trace.h" - +#ifdef _WIN32 +#include +#endif #ifdef ANDROID #include #include From 3b0e7a8527f4c57294c1334f6540d2dcc0ffb4b9 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 18 Nov 2018 11:36:02 +1030 Subject: [PATCH 04/32] [Project64] Clean up some code and warnings in Common code --- Source/Common/IniFileClass.cpp | 20 +++++++++++++++---- Source/Common/IniFileClass.h | 5 +++-- Source/Common/LogClass.cpp | 5 +---- Source/Common/MemoryManagement.cpp | 1 + Source/Common/StdString.h | 4 ++-- Source/Common/Thread.cpp | 4 ++++ Source/Common/Thread.h | 1 + Source/Common/Trace.cpp | 12 ++++++++--- Source/Common/path.h | 9 ++++----- .../Settings/SettingsPage-Game-Status.cpp | 4 ++-- 10 files changed, 43 insertions(+), 22 deletions(-) diff --git a/Source/Common/IniFileClass.cpp b/Source/Common/IniFileClass.cpp index 7f8d43e9d..9c1afda72 100644 --- a/Source/Common/IniFileClass.cpp +++ b/Source/Common/IniFileClass.cpp @@ -55,7 +55,7 @@ void CIniFileBase::fInsertSpaces(int Pos, int NoOfSpaces) if (NoOfSpaces < 0) { int ReadPos = Pos + (NoOfSpaces * -1); - int WritePos = Pos; + WritePos = Pos; do { @@ -338,6 +338,18 @@ bool CIniFileBase::MoveToSectionNameData(const char * lpSectionName, bool Change } while (result >= 0); } + if (!bFoundSection && strcmp(lpSectionName, "default") == 0) + { + m_SectionsPos.insert(FILELOC::value_type(lpSectionName, 0)); + if (ChangeCurrentSection) + { + m_CurrentSection = lpSectionName; + m_CurrentSectionFilePos = 0; + } + m_File.Seek(m_lastSectionSearch, CFileBase::begin); + bFoundSection = true; + } + if (bFoundSection && ChangeCurrentSection) { m_CurrentSectionData.clear(); @@ -482,7 +494,7 @@ bool CIniFileBase::DeleteSection(const char * lpSectionName) { return false; } - uint32_t dwRet = m_File.Read(pData.get(), dwSize); + uint32_t dwRet = m_File.Read(pData.get(), (uint32_t)dwSize); if (dwRet == 0 || dwRet < dwSize) { return false; @@ -502,11 +514,11 @@ bool CIniFileBase::DeleteSection(const char * lpSectionName) char *pEndSection = pSection + strlen(strSection.c_str()), *Data = pData.get(); char *pNextSection = NULL; - int result, ReadPos = pEndSection - pData.get(); + int result, ReadPos = (int)(pEndSection - pData.get()); do { char * Input = NULL; - int MaxDataSize = dwSize + 1; + int MaxDataSize = (int)(dwSize + 1); result = -1; for (int count = ReadPos; count < MaxDataSize; count++) { diff --git a/Source/Common/IniFileClass.h b/Source/Common/IniFileClass.h index f68c29da6..6d8b90e88 100644 --- a/Source/Common/IniFileClass.h +++ b/Source/Common/IniFileClass.h @@ -27,8 +27,9 @@ class CIniFileBase typedef std::map KeyValueList; public: - typedef std::map KeyValueData; - typedef std::vector SectionList; + typedef std::map KeyValueData; + typedef std::vector SectionList; + typedef std::list strlist; protected: CFileBase & m_File; diff --git a/Source/Common/LogClass.cpp b/Source/Common/LogClass.cpp index 972e6e8c4..2a899486e 100644 --- a/Source/Common/LogClass.cpp +++ b/Source/Common/LogClass.cpp @@ -82,7 +82,7 @@ void CLog::LogArgs(const char * Message, va_list & args ) void CLog::Log( const char * Message ) { if (!m_hLogFile.IsOpen()) { return; } - uint32_t message_len = strlen(Message); + uint32_t message_len = (uint32_t)strlen(Message); m_hLogFile.Write(Message, message_len); if (m_FlushOnWrite) { @@ -113,8 +113,6 @@ void CLog::Log( const char * Message ) do { uint8_t Data[300]; - uint32_t dwRead; - dwRead = m_hLogFile.Read(Data,sizeof(Data)); if (dwRead == 0) { @@ -146,7 +144,6 @@ void CLog::Log( const char * Message ) m_hLogFile.Seek(ReadPos,CFile::begin); - uint32_t dwRead; dwRead = m_hLogFile.Read(Data,SizeToRead); m_hLogFile.Seek(WritePos,CFile::begin); diff --git a/Source/Common/MemoryManagement.cpp b/Source/Common/MemoryManagement.cpp index c2342ea5d..be8a54ef5 100644 --- a/Source/Common/MemoryManagement.cpp +++ b/Source/Common/MemoryManagement.cpp @@ -66,6 +66,7 @@ void* AllocateAddressSpace(size_t size, void * base_address) bool FreeAddressSpace(void* addr, size_t size) { #ifdef _WIN32 + size = 0; //unused return VirtualFree(addr, 0, MEM_RELEASE) != 0; #else msync(addr, size, MS_SYNC); diff --git a/Source/Common/StdString.h b/Source/Common/StdString.h index 411fbdd4a..f6bcc4df9 100644 --- a/Source/Common/StdString.h +++ b/Source/Common/StdString.h @@ -60,5 +60,5 @@ public: }; #endif -typedef std::list strlist; -typedef strlist::iterator strlist_iter; +typedef std::list strlist; +typedef strlist::iterator strlist_iter; diff --git a/Source/Common/Thread.cpp b/Source/Common/Thread.cpp index a8cc74f82..1dcc10565 100644 --- a/Source/Common/Thread.cpp +++ b/Source/Common/Thread.cpp @@ -66,7 +66,11 @@ void * CThread::ThreadWrapper (CThread * _this) void * res = NULL; try { +#if defined(__i386__) || defined(_M_IX86) || defined(__arm__) || defined(_M_ARM) res = (void *)_this->m_StartAddress(_this->m_lpThreadParameter); +#else + res = (void *)((uint64_t)_this->m_StartAddress(_this->m_lpThreadParameter)); +#endif } catch (...) { diff --git a/Source/Common/Thread.h b/Source/Common/Thread.h index 38bc03559..ab89fd113 100644 --- a/Source/Common/Thread.h +++ b/Source/Common/Thread.h @@ -1,4 +1,5 @@ #pragma once +#include class CThread { diff --git a/Source/Common/Trace.cpp b/Source/Common/Trace.cpp index 4a0a1730a..03bd9e721 100644 --- a/Source/Common/Trace.cpp +++ b/Source/Common/Trace.cpp @@ -122,12 +122,18 @@ void CTraceLog::CloseTrace(void) { CGuard Guard(m_CS); m_Modules.clear(); + + if (g_ModuleLogLevel) + { + delete g_ModuleLogLevel; + g_ModuleLogLevel = NULL; + } } void CTraceLog::FlushTrace(void) { CGuard Guard(m_CS); - for (uint32_t i = 0, n = m_Modules.size(); i < n; i++) + for (size_t i = 0, n = m_Modules.size(); i < n; i++) { m_Modules[i]->FlushTrace(); } @@ -138,7 +144,7 @@ void CTraceLog::TraceMessage(uint32_t module, uint8_t severity, const char * fil { CGuard Guard(m_CS); - for (uint32_t i = 0, n = m_Modules.size(); i < n; i++) + for (size_t i = 0, n = m_Modules.size(); i < n; i++) { m_Modules[i]->Write(module, severity, file, line, function, Message); } @@ -200,7 +206,7 @@ CTraceFileLog::CTraceFileLog(const char * FileName, bool FlushFile, CLog::LOG_OP { /* Clamp file size to 5 MB if it exceeds 2047 or falls short of 3. */ dwMaxFileSize = 5; } - m_hLogFile.SetMaxFileSize(dwMaxFileSize * MB); + m_hLogFile.SetMaxFileSize((uint32_t)(dwMaxFileSize * MB)); m_hLogFile.Open(FileName, eMode); } diff --git a/Source/Common/path.h b/Source/Common/path.h index 1ac02be49..3fd6eef7c 100644 --- a/Source/Common/path.h +++ b/Source/Common/path.h @@ -7,7 +7,7 @@ class CPath //Enums public: - enum DIR_CURRENT_DIRECTORY { CURRENT_DIRECTORY = 1 }; + enum DIR_CURRENT_DIRECTORY { CURRENT_DIRECTORY = 1 }; #ifdef _WIN32 enum DIR_MODULE_DIRECTORY { MODULE_DIRECTORY = 2 }; enum DIR_MODULE_FILE { MODULE_FILE = 3 }; @@ -22,7 +22,6 @@ public: //Attributes private: - std::string m_strPath; #ifdef _WIN32 void * m_hFindFile; @@ -119,10 +118,10 @@ public: bool DirectoryExists() const; //File Information - bool IsFile() const { return !IsDirectory(); } - bool Exists() const; + bool IsFile() const { return !IsDirectory(); } + bool Exists() const; #ifdef _WIN32 - bool SelectFile(void * hwndOwner, const char * InitialDir, const char * FileFilter, bool FileMustExist); + bool SelectFile(void * hwndOwner, const char * InitialDir, const char * FileFilter, bool FileMustExist); #endif //Directory operations diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.cpp index 446fb1ab1..f1a0e6b09 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.cpp @@ -21,7 +21,7 @@ CGameStatusPage::CGameStatusPage(HWND hParent, const RECT & rcDispay) } CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); - strlist Keys; + CIniFile::strlist Keys; RomIniFile.GetKeyList("Rom Status", Keys); stdstr Status = UISettingsLoadStringVal(Rdb_Status); @@ -29,7 +29,7 @@ CGameStatusPage::CGameStatusPage(HWND hParent, const RECT & rcDispay) ComboBox = AddModComboBoxTxt(GetDlgItem(IDC_STATUS_TYPE), Rdb_Status); if (ComboBox) { - for (strlist::iterator item = Keys.begin(); item != Keys.end(); item++) + for (CIniFile::strlist::iterator item = Keys.begin(); item != Keys.end(); item++) { if (strstr(item->c_str(), ".Sel") != NULL) { continue; } if (strstr(item->c_str(), ".Auto") != NULL) { continue; } From 485339300d83c0566f1223a5f6af347bed125b13 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 18 Nov 2018 12:26:00 +1030 Subject: [PATCH 05/32] [Project64] Make mem test more header friendly --- Source/Common/MemTest.cpp | 416 ++++++++++++++------------------------ Source/Common/MemTest.h | 100 +-------- 2 files changed, 156 insertions(+), 360 deletions(-) diff --git a/Source/Common/MemTest.cpp b/Source/Common/MemTest.cpp index 4fbff4911..d44d2721e 100644 --- a/Source/Common/MemTest.cpp +++ b/Source/Common/MemTest.cpp @@ -1,33 +1,39 @@ #include "stdafx.h" - -#if defined(_MSC_VER) -#include -#else -#define _ASSERTE(expr) ((void)0) -#endif - -#ifdef _DEBUG - -#pragma warning(disable:4786) //Disable std library warning -#pragma warning(disable:4530) //Disable std library warning -#include -#include - -#include "MemTest.h" -#ifdef MEM_LEAK_TEST - -#include //Needed for ShellExecute -#pragma comment(lib, "shell32.lib") //Needed for ShellExecute +#include #undef new -#undef malloc -#undef realloc -#undef free -#undef VirtualAlloc -#undef VirtualFree -#ifndef MB_SERVICE_NOTIFICATION -#define MB_SERVICE_NOTIFICATION 0x00200000L -#endif +#ifdef _WIN32 +#include + +static bool InInit = false; + +class CMemList +{ + typedef struct + { + char File[300]; + int line; + int size; + int order; + } DEBUG_LOCATION; + + typedef std::map MEMLIST; + typedef MEMLIST::const_iterator MEMLIST_ITER; + +public: + CMemList(); + ~CMemList(); + + void removeItem(void * ptr); + void RecordAddItem(void * ptr, size_t size, const char * filename, int line); + void DumpItems(void); + +private: + MEMLIST * m_MemList; + HMODULE m_hModule; + CRITICAL_SECTION m_cs; + uint32_t m_NextOrder; +}; CMemList *MemList(void) { @@ -36,15 +42,15 @@ CMemList *MemList(void) return &m_MemList; } -CMemList::CMemList() +CMemList::CMemList() : + m_MemList(NULL), + m_hModule(NULL), + m_cs({0}), + m_NextOrder(1) { - MemList.clear(); - hSemaphone = CreateSemaphore(NULL, 1, 1, NULL); - State = Initialized; - order = 0; - LogAllocate = false; - ThreadID = 0; - m_hModule = NULL; + InInit = true; + InitializeCriticalSection(&m_cs); + m_MemList = new MEMLIST; for (UINT_PTR TestLoc = ((UINT_PTR)::MemList) & ~0xFFF; TestLoc != 0; TestLoc -= 0x1000) { @@ -56,259 +62,152 @@ CMemList::CMemList() m_hModule = (HMODULE)TestLoc; break; } + InInit = false; } CMemList::~CMemList() { - size_t ItemsLeft = MemList.size(); + InInit = true; + size_t ItemsLeft = m_MemList->size(); if (ItemsLeft > 0) { - char path_buffer[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR]; - char fname[_MAX_FNAME], ext[_MAX_EXT], LogFileName[_MAX_PATH]; - - memset(path_buffer, 0, sizeof(path_buffer)); - memset(drive, 0, sizeof(drive)); - memset(dir, 0, sizeof(dir)); - memset(fname, 0, sizeof(fname)); - memset(ext, 0, sizeof(ext)); - memset(LogFileName, 0, sizeof(LogFileName)); - - GetModuleFileName(m_hModule, path_buffer, sizeof(path_buffer)); - _splitpath(path_buffer, drive, dir, fname, ext); - - _makepath(LogFileName, drive, dir, fname, "leak.csv"); - - HANDLE hLogFile = INVALID_HANDLE_VALUE; - do - { - hLogFile = CreateFile( - LogFileName, - GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, - NULL - ); - if (hLogFile == INVALID_HANDLE_VALUE) - { - if (GetLastError() == ERROR_SHARING_VIOLATION) - { - TCHAR Msg[3000]; - sprintf(Msg, "%s\nCan not be opened for writing please close app using this file\n\nTry Again ?", LogFileName); - int Result = MessageBox(NULL, Msg, "Memory Leak", MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND | MB_SERVICE_NOTIFICATION); - if (Result == IDNO) - { - break; - } - } - } - } while (hLogFile == INVALID_HANDLE_VALUE); - - if (hLogFile != INVALID_HANDLE_VALUE) - { - SetFilePointer(hLogFile, 0, NULL, FILE_BEGIN); - - DWORD dwWritten = 0; - char Msg[800]; - _snprintf(Msg, sizeof(Msg), "Order, Source File, Line Number, Mem Size\r\n"); - WriteFile(hLogFile, Msg, (DWORD)strlen(Msg), &dwWritten, NULL); - - for (MEMLIST_ITER item = MemList.begin(); item != MemList.end(); item++) - { - _snprintf(Msg, sizeof(Msg), "%d,%s, %d, %d\r\n", - (*item).second.order, - (*item).second.File, - (*item).second.line, - (*item).second.size); - WriteFile(hLogFile, Msg, (DWORD)strlen(Msg), &dwWritten, NULL); - } - CloseHandle(hLogFile); - } - char Msg[3000]; - sprintf(Msg, "%s%s\n\nMemory Leaks detected\n\nOpen the Log File ?", fname, ext); - int Result = MessageBox(NULL, Msg, "Memory Leak", MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND | MB_SERVICE_NOTIFICATION); - if (Result == IDYES) - { - ShellExecute(NULL, "open", LogFileName, NULL, NULL, SW_SHOW); - } + DumpItems(); } - CloseHandle(hSemaphone); - hSemaphone = NULL; - State = NotInitialized; -} - -void * CMemList::AddItem(size_t size, char * filename, int line) -{ - void *res = malloc(size); - if (res == NULL) - { - return res; - } - RecordAddItem(res, size, filename, line); - return res; + delete m_MemList; + m_MemList = NULL; + DeleteCriticalSection(&m_cs); } void CMemList::RecordAddItem(void * ptr, size_t size, const char * filename, int line) { - __try + EnterCriticalSection(&m_cs); + if (m_cs.RecursionCount > 1) { - if (State == Initialized && hSemaphone != NULL) + LeaveCriticalSection(&m_cs); + return; + } + + DEBUG_LOCATION info; + strncpy(info.File, filename, sizeof(info.File)); + info.line = line; + info.size = (int)size; + info.order = m_NextOrder++; + if (info.order == 628) + { + int a = 5; + a = 6; + } + + m_MemList->insert(MEMLIST::value_type(ptr, info)); + LeaveCriticalSection(&m_cs); +} + +void CMemList::removeItem(void * ptr) +{ + EnterCriticalSection(&m_cs); + if (m_cs.RecursionCount > 1) + { + LeaveCriticalSection(&m_cs); + return; + } + MEMLIST_ITER item = m_MemList->find(ptr); + if (item != m_MemList->end()) + { + m_MemList->erase(item); + } + + LeaveCriticalSection(&m_cs); +} + +void CMemList::DumpItems(void) +{ + char path_buffer[_MAX_PATH] = { 0 }, drive[_MAX_DRIVE] = { 0 }, dir[_MAX_DIR] = { 0 }; + char fname[_MAX_FNAME] = { 0 }, ext[_MAX_EXT] = { 0 }, LogFileName[_MAX_PATH] = { 0 }; + + GetModuleFileName(m_hModule, path_buffer, sizeof(path_buffer)); + _splitpath(path_buffer, drive, dir, fname, ext); + _makepath(LogFileName, drive, dir, fname, "leak.csv"); + + HANDLE hLogFile = INVALID_HANDLE_VALUE; + do + { + hLogFile = CreateFile( LogFileName, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL ); + if (hLogFile == INVALID_HANDLE_VALUE) { - DWORD CurrentThread = GetCurrentThreadId(); - DWORD Result = WaitForSingleObject(hSemaphone, CurrentThread != ThreadID ? 30000 : 0); - if (Result != WAIT_TIMEOUT) + if (GetLastError() == ERROR_SHARING_VIOLATION) { - ThreadID = CurrentThread; - - DEBUG_LOCATION info; - strncpy(info.File, filename, sizeof(info.File)); - info.line = line; - info.size = (int)size; - info.order = order++; - - Insert(ptr, info); - - long dwSemCount = 0; - ThreadID = (DWORD)-1; - ReleaseSemaphore(hSemaphone, 1, &dwSemCount); + TCHAR Msg[3000]; + sprintf(Msg, "%s\nCan not be opened for writing please close app using this file\n\nTry Again ?", LogFileName); + int Result = MessageBox(NULL, Msg, "Memory Leak", MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND | MB_SERVICE_NOTIFICATION); + if (Result == IDNO) + { + break; + } } } - } - __except (EXCEPTION_EXECUTE_HANDLER) + } while (hLogFile == INVALID_HANDLE_VALUE); + + if (hLogFile != INVALID_HANDLE_VALUE) { - //_asm int 3 + SetFilePointer(hLogFile, 0, NULL, FILE_BEGIN); + + DWORD dwWritten = 0; + char Msg[800]; + _snprintf(Msg, sizeof(Msg), "Order, Source File, Line Number, Mem Size\r\n"); + WriteFile(hLogFile, Msg, (DWORD)strlen(Msg), &dwWritten, NULL); + + for (MEMLIST_ITER item = m_MemList->begin(); item != m_MemList->end(); item++) + { + _snprintf(Msg, sizeof(Msg), "%d,%s, %d, %d\r\n", (*item).second.order, (*item).second.File, (*item).second.line, (*item).second.size); + WriteFile(hLogFile, Msg, (DWORD)strlen(Msg), &dwWritten, NULL); + } + CloseHandle(hLogFile); + } + char Msg[3000]; + sprintf(Msg, "%s%s\n\nMemory Leaks detected\n\nOpen the Log File ?", fname, ext); + int Result = MessageBox(NULL, Msg, "Memory Leak", MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND | MB_SERVICE_NOTIFICATION); + if (Result == IDYES) + { + ShellExecute(NULL, "open", LogFileName, NULL, NULL, SW_SHOW); } } -void CMemList::Insert(void *res, DEBUG_LOCATION &info) +void* AllocateMemory(size_t size, const char* filename, unsigned int line) { - MemList.insert(MEMLIST::value_type(res, info)); -} - -void * CMemList::ReAllocItem(void * ptr, size_t size, const char * filename, int line) -{ - void *res = realloc(ptr, size); + void * res = malloc(size); if (res == NULL) { return res; } - if (ptr != res) + if (!InInit) { - __try - { - if (State == Initialized && hSemaphone != NULL) - { - DWORD CurrentThread = GetCurrentThreadId(); - DWORD Result = WaitForSingleObject(hSemaphone, CurrentThread != ThreadID ? 30000 : 0); - if (Result != WAIT_TIMEOUT) - { - ThreadID = CurrentThread; - //Add new pointer - DEBUG_LOCATION info; - strncpy(info.File, filename, sizeof(info.File)); - info.line = line; - info.size = (int)size; - info.order = order++; - - Insert(res, info); - - //remove old pointer - Remove(ptr); - - long dwSemCount = 0; - ThreadID = (DWORD)-1; - ReleaseSemaphore(hSemaphone, 1, &dwSemCount); - } - } - } - __except (EXCEPTION_EXECUTE_HANDLER) - { - //_asm int 3 - } + MemList()->RecordAddItem(res, size, filename, line); } return res; } -void CMemList::Remove(void *ptr) +void* operator new (size_t size, const char* filename, unsigned int line) { - //remove old pointer - MEMLIST_ITER item = MemList.find(ptr); - if (item != MemList.end()) - { - MemList.erase(ptr); - } + return AllocateMemory(size, filename, line); } -void CMemList::removeItem(void * ptr, bool bFree) +void* operator new[] (size_t size, const char* filename, unsigned int line) { - if (bFree) - { - free(ptr); - } - - __try - { - if (State == Initialized && hSemaphone != NULL) - { - DWORD CurrentThread = GetCurrentThreadId(); - DWORD Result = WaitForSingleObject(hSemaphone, CurrentThread != ThreadID ? 30000 : 0); - if (Result != WAIT_TIMEOUT) - { - ThreadID = CurrentThread; - - Remove(ptr); - - long dwSemCount = 0; - ThreadID = (DWORD)-1; - ReleaseSemaphore(hSemaphone, 1, &dwSemCount); - } - } - } - __except (EXCEPTION_EXECUTE_HANDLER) - { - //_asm int 3 - } -} - -void MemTest_AddLeak(char* Comment) -{ - MemList()->AddItem(1, Comment, -1); -} - -void* MemTest_malloc(size_t size, char* filename, int line) -{ - return MemList()->AddItem(size, filename, line); -} - -void* MemTest_realloc(void* ptr, size_t size, char* filename, int line) -{ - return MemList()->ReAllocItem(ptr, size, filename, line); -} - -void* operator new (size_t size, char* filename, int line) -{ - return MemList()->AddItem(size, filename, line); + return AllocateMemory(size, filename, line); } void* operator new (size_t size) { - return MemList()->AddItem(size, "Unknown", 0); -} - -void* operator new [](size_t size, char* filename, int line) -{ - return MemList()->AddItem(size, filename, line); -} - -void* operator new [](size_t size) -{ - return MemList()->AddItem(size, "Unknown", 0); + return AllocateMemory(size, "Unknown", 0); } void operator delete (void* ptr) { - MemList()->removeItem(ptr, true); + free(ptr); + if (!InInit) + { + MemList()->removeItem(ptr); + } } void operator delete[](void* ptr) @@ -316,31 +215,14 @@ void operator delete[](void* ptr) delete ptr; } -LPVOID MemTest_VirtualAlloc( -LPVOID lpAddress, // region to reserve or commit -SIZE_T dwSize, // size of region -DWORD flAllocationType, // type of allocation -DWORD flProtect, // type of access protection -LPCSTR filename, -int line) +void operator delete (void* ptr, const char* /*filename*/, unsigned int /*line*/) { - LPVOID ptr = VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect); - - if (ptr && lpAddress == NULL && (flAllocationType & MEM_RESERVE) != 0) - { - MemList()->RecordAddItem(ptr, dwSize, filename, line); - } - return ptr; + delete ptr; } -BOOL MemTest_VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType) +void operator delete[](void* ptr, const char* /*filename*/, unsigned int /*line*/) { - if ((dwFreeType & MEM_RELEASE) != 0) - { - MemList()->removeItem(lpAddress, false); - } - return VirtualFree(lpAddress, dwSize, dwFreeType); + delete ptr; } #endif -#endif \ No newline at end of file diff --git a/Source/Common/MemTest.h b/Source/Common/MemTest.h index eb2635e36..c06f446eb 100644 --- a/Source/Common/MemTest.h +++ b/Source/Common/MemTest.h @@ -1,102 +1,16 @@ -#ifdef _DEBUG +#pragma once -#if (defined(_MSC_VER) && (_MSC_VER < 1900)) +#if (defined(_MSC_VER) && _DEBUG) #define MEM_LEAK_TEST #endif #ifdef MEM_LEAK_TEST -#ifndef __MEM_TEST__H__ -#define __MEM_TEST__H__ -#pragma warning(disable:4786) -#pragma warning(disable:4291) - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0500 -#endif - -#include -#include -#include -#include - -#define new new(__FILE__, __LINE__) -#include -#include -#undef new - -/* -#include -#include -#include -#include -#include -#include -#include -*/ - - -typedef struct { - char File[300]; - int line; - int size; - int order; -} DEBUG_LOCATION; - -typedef std::map MEMLIST; -typedef MEMLIST::iterator MEMLIST_ITER; - -class CMemList { - MEMLIST MemList; - HANDLE hSemaphone; - DWORD ThreadID; - HMODULE m_hModule; - - enum INIT { Initialized = 123, NotInitialized }; - INIT State; - int order; - bool LogAllocate; - - void Insert(void *res, DEBUG_LOCATION &info); - void Remove(void *ptr); - -public: - CMemList(); - ~CMemList(); - void * AddItem ( size_t size, char * filename, int line ); - void * ReAllocItem ( void * ptr, size_t size, const char * filename, int line ); - void removeItem ( void * ptr, bool bFree ); - void RecordAddItem ( void * ptr, size_t size, const char * filename, int line ); -}; - -void* operator new (size_t size ); -void* operator new (size_t size, char* filename, int line); -void* operator new [] (size_t size ); -void* operator new [] (size_t size, char* filename, int line); -void operator delete ( void* ptr); -void operator delete[](void* ptr); - -void* MemTest_malloc(size_t size, char* filename, int line); -void* MemTest_realloc(void* ptr, size_t size, char* filename, int line); -void MemTest_AddLeak(char* Comment); -LPVOID MemTest_VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect, LPCSTR filename, int line); -BOOL MemTest_VirtualFree( LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType ); +void* operator new (size_t size, const char* filename, unsigned int line); +void* operator new[](size_t size, const char* filename, unsigned int line); +void operator delete (void* ptr, const char* filename, unsigned int line); +void operator delete[](void* ptr, const char* filename, unsigned int line); - -#endif - -#undef new -#undef malloc -#undef free -#define new new(__FILE__, __LINE__) -#define malloc(x) (MemTest_malloc((x),__FILE__, __LINE__)) -#define realloc(mem,x) (MemTest_realloc((mem),(x),__FILE__, __LINE__)) -#define free(x) (delete (x)) -#define VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect ) \ - (MemTest_VirtualAlloc((lpAddress), (dwSize), (flAllocationType), (flProtect),__FILE__, __LINE__)) -#define VirtualFree(lpAddress, dwSize, dwFreeType ) \ - (MemTest_VirtualFree((lpAddress), (dwSize), (dwFreeType))) - -#endif +#define new new(__FILE__, __LINE__) #endif From b93736414f359ca110090c1dff4f3c3b9ebbf6a1 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 19 Nov 2018 21:16:58 +1030 Subject: [PATCH 06/32] [Project64] Normalize paths --- Source/Common/IniFileClass.h | 5 +- Source/Common/path.cpp | 116 +++++++++++++----- Source/Common/path.h | 1 + .../Project64-core/N64System/Mips/Eeprom.cpp | 1 + .../N64System/Mips/FlashRam.cpp | 1 + .../Project64-core/N64System/Mips/Mempak.cpp | 1 + Source/Project64-core/N64System/Mips/Sram.cpp | 1 + Source/Project64-core/N64System/N64Class.cpp | 2 + Source/Project64-core/RomList/RomList.h | 1 + .../SettingType/SettingsType-Application.cpp | 13 +- .../UserInterface/Debugger/Symbols.cpp | 1 + Source/Project64/UserInterface/MainMenu.cpp | 3 +- changes.txt | 3 +- 13 files changed, 109 insertions(+), 40 deletions(-) diff --git a/Source/Common/IniFileClass.h b/Source/Common/IniFileClass.h index 6d8b90e88..23530b672 100644 --- a/Source/Common/IniFileClass.h +++ b/Source/Common/IniFileClass.h @@ -4,13 +4,14 @@ /* for POSIX method away from Win32 _stricmp--see "Platform.h" */ #include #endif -#include "Platform.h" #include "FileClass.h" #include "CriticalSection.h" -#include "StdString.h" #include "SmartPointer.h" +#include #include +#include +#include class CIniFileBase { diff --git a/Source/Common/path.cpp b/Source/Common/path.cpp index c86ec16bf..3f773258d 100644 --- a/Source/Common/path.cpp +++ b/Source/Common/path.cpp @@ -306,17 +306,47 @@ CPath::CPath(DIR_MODULE_FILE /*sdt*/) #ifdef _WIN32 void CPath::GetComponents(std::string* pDrive, std::string* pDirectory, std::string* pName, std::string* pExtension) const { - char buff_drive[_MAX_DRIVE + 1]; - char buff_dir[_MAX_DIR + 1]; - char buff_name[_MAX_FNAME + 1]; - char buff_ext[_MAX_EXT + 1]; + WriteTrace(TracePath, TraceDebug, "Start (m_strPath: \"%s\")", m_strPath.c_str()); - ZeroMemory(buff_drive, sizeof(buff_drive)); - ZeroMemory(buff_dir, sizeof(buff_dir)); - ZeroMemory(buff_name, sizeof(buff_name)); - ZeroMemory(buff_ext, sizeof(buff_ext)); + char buff_drive[_MAX_DRIVE + 1] = { 0 }; + char buff_dir[_MAX_DIR + 1] = { 0 }; + char buff_name[_MAX_FNAME + 1] = { 0 }; + char buff_ext[_MAX_EXT + 1] = { 0 }; - _splitpath(m_strPath.c_str(), pDrive ? buff_drive : NULL, pDirectory ? buff_dir : NULL, pName ? buff_name : NULL, pExtension ? buff_ext : NULL); + const char * BasePath = m_strPath.c_str(); + const char * DriveDir = strrchr(BasePath, DRIVE_DELIMITER); + if (DriveDir != NULL) + { + int len = sizeof(buff_dir) < (DriveDir - BasePath) ? sizeof(buff_drive) : DriveDir - BasePath; + strncpy(buff_drive, BasePath, len); + BasePath += len + 1; + } + + const char * last = strrchr(BasePath, DIRECTORY_DELIMITER); + if (last != NULL) + { + int len = sizeof(buff_dir) < (last - BasePath) ? sizeof(buff_dir) : last - BasePath; + if (len > 0) + { + strncpy(buff_dir, BasePath, len); + } + else + { + buff_dir[0] = DIRECTORY_DELIMITER; + buff_dir[1] = '\0'; + } + strncpy(buff_name, last + 1, sizeof(buff_name)); + } + else + { + strncpy(buff_dir, BasePath, sizeof(buff_dir)); + } + char * ext = strrchr(buff_name, '.'); + if (ext != NULL) + { + strncpy(buff_ext, ext + 1, sizeof(buff_ext)); + *ext = '\0'; + } if (pDrive) { @@ -334,24 +364,7 @@ void CPath::GetComponents(std::string* pDrive, std::string* pDirectory, std::str { *pExtension = buff_ext; } - - // DOS's _splitpath returns "d:", we return "d" - if (pDrive) - { - StripTrailingChar(*pDrive, DRIVE_DELIMITER); - } - - // DOS's _splitpath returns "\dir\subdir\", we return "\dir\subdir" - if (pDirectory) - { - StripTrailingBackslash(*pDirectory); - } - - // DOS's _splitpath returns ".ext", we return "ext" - if (pExtension) - { - StripLeadingChar(*pExtension, EXTENSION_DELIMITER); - } + WriteTrace(TracePath, TraceDebug, "Done (dir: \"%s\" name: \"%s\" ext: \"%s\")", buff_dir, buff_name, buff_ext); } #else void CPath::GetComponents(std::string* pDirectory, std::string* pName, std::string* pExtension) const @@ -423,8 +436,8 @@ void CPath::GetDriveDirectory(std::string& rDriveDirectory) const if (!Drive.empty()) { rDriveDirectory += DRIVE_DELIMITER; - rDriveDirectory += Directory; } + rDriveDirectory += Directory; } std::string CPath::GetDriveDirectory(void) const @@ -1438,6 +1451,53 @@ bool CPath::ChangeDirectory() #endif } +void CPath::NormalizePath(CPath BaseDir) +{ +#ifdef _WIN32 + stdstr Directory = BaseDir.GetDriveDirectory(); +#else + stdstr Directory = BaseDir.GetDirectory(); +#endif + bool Changed = false; + if (IsRelative()) + { + EnsureTrailingBackslash(Directory); + Directory += GetDirectory(); + Changed = true; + } + strvector Parts = Directory.Tokenize(DIRECTORY_DELIMITER); + strvector NormalizesParts; + for (strvector::const_iterator itr = Parts.begin(); itr != Parts.end(); itr++) + { + if (*itr == ".") + { + Changed = true; + } + else if (*itr == "..") + { + NormalizesParts.pop_back(); + Changed = true; + } + else + { + NormalizesParts.push_back(*itr); + } + } + if (Changed) + { + Directory.clear(); + for (strvector::const_iterator itr = NormalizesParts.begin(); itr != NormalizesParts.end(); itr++) + { + Directory += *itr + DIRECTORY_DELIMITER; + } +#ifdef _WIN32 + SetDriveDirectory(Directory.c_str()); +#else + SetDirectory(Directory.c_str()); +#endif + } +} + //------------------------------------------------------------- // Pre : If bCreateIntermediates is TRUE, create all eventually // missing parent directories too diff --git a/Source/Common/path.h b/Source/Common/path.h index 3fd6eef7c..f012c272e 100644 --- a/Source/Common/path.h +++ b/Source/Common/path.h @@ -127,6 +127,7 @@ public: //Directory operations bool DirectoryCreate(bool bCreateIntermediates = true); bool ChangeDirectory(); + void NormalizePath(CPath BaseDir); //File operations bool Delete(bool bEvenIfReadOnly = true) const; diff --git a/Source/Project64-core/N64System/Mips/Eeprom.cpp b/Source/Project64-core/N64System/Mips/Eeprom.cpp index 7de9eaa9e..bd57ba471 100644 --- a/Source/Project64-core/N64System/Mips/Eeprom.cpp +++ b/Source/Project64-core/N64System/Mips/Eeprom.cpp @@ -148,6 +148,7 @@ void CEeprom::LoadEeprom() { FileName.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } + FileName.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); if (!FileName.DirectoryExists()) { diff --git a/Source/Project64-core/N64System/Mips/FlashRam.cpp b/Source/Project64-core/N64System/Mips/FlashRam.cpp index 2fc760de7..2d31ec994 100644 --- a/Source/Project64-core/N64System/Mips/FlashRam.cpp +++ b/Source/Project64-core/N64System/Mips/FlashRam.cpp @@ -125,6 +125,7 @@ bool CFlashram::LoadFlashram() { FileName.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } + FileName.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); if (!FileName.DirectoryExists()) { diff --git a/Source/Project64-core/N64System/Mips/Mempak.cpp b/Source/Project64-core/N64System/Mips/Mempak.cpp index d21d09bdf..2e1a53e36 100644 --- a/Source/Project64-core/N64System/Mips/Mempak.cpp +++ b/Source/Project64-core/N64System/Mips/Mempak.cpp @@ -34,6 +34,7 @@ void CMempak::LoadMempak(int32_t Control, bool Create) { MempakPath.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } + MempakPath.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); if (!Create && !MempakPath.Exists()) { diff --git a/Source/Project64-core/N64System/Mips/Sram.cpp b/Source/Project64-core/N64System/Mips/Sram.cpp index 42ab34b65..307306939 100644 --- a/Source/Project64-core/N64System/Mips/Sram.cpp +++ b/Source/Project64-core/N64System/Mips/Sram.cpp @@ -28,6 +28,7 @@ bool CSram::LoadSram() { FileName.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } + FileName.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); if (!FileName.DirectoryExists()) { diff --git a/Source/Project64-core/N64System/N64Class.cpp b/Source/Project64-core/N64System/N64Class.cpp index 3543ec92f..72bffb968 100644 --- a/Source/Project64-core/N64System/N64Class.cpp +++ b/Source/Project64-core/N64System/N64Class.cpp @@ -1547,6 +1547,7 @@ bool CN64System::SaveState() { SaveFile.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } + SaveFile.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); SaveFile.SetName(g_Settings->LoadStringVal(Rdb_GoodName).c_str()); g_Settings->SaveDword(Game_LastSaveSlot, g_Settings->LoadDword(Game_CurrentSaveState)); } @@ -1702,6 +1703,7 @@ bool CN64System::LoadState() { FileName.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } + FileName.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); if (g_Settings->LoadDword(Game_CurrentSaveState) != 0) { FileName.SetNameExtension(stdstr_f("%s.pj%d", g_Settings->LoadStringVal(Rdb_GoodName).c_str(), g_Settings->LoadDword(Game_CurrentSaveState)).c_str()); diff --git a/Source/Project64-core/RomList/RomList.h b/Source/Project64-core/RomList/RomList.h index ea22ff53c..7f07d49f6 100644 --- a/Source/Project64-core/RomList/RomList.h +++ b/Source/Project64-core/RomList/RomList.h @@ -11,6 +11,7 @@ #pragma once #include #include +#include #include #include #include diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp index 3874cb045..73319e776 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp @@ -91,17 +91,14 @@ void CSettingTypeApplication::Initialize(const char * /*AppName*/) { delete m_SettingsIniFile; } -#ifdef _WIN32 - CPath SettingsDir(CPath(SettingsFile).GetDriveDirectory(), ""); -#else - CPath SettingsDir(CPath(SettingsFile).GetDirectory(), ""); -#endif - if (!SettingsDir.DirectoryExists()) + CPath SettingPath(SettingsFile.c_str()); + SettingPath.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); + if (!SettingPath.DirectoryExists()) { - SettingsDir.DirectoryCreate(); + SettingPath.DirectoryCreate(); } - m_SettingsIniFile = new CIniFile(SettingsFile.c_str()); + m_SettingsIniFile = new CIniFile(SettingPath); } m_SettingsIniFile->SetAutoFlush(false); diff --git a/Source/Project64/UserInterface/Debugger/Symbols.cpp b/Source/Project64/UserInterface/Debugger/Symbols.cpp index a99c2e0fe..e125b1ca1 100644 --- a/Source/Project64/UserInterface/Debugger/Symbols.cpp +++ b/Source/Project64/UserInterface/Debugger/Symbols.cpp @@ -52,6 +52,7 @@ CPath CSymbols::GetSymFilePath() { symFilePath.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } + symFilePath.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); if (!symFilePath.DirectoryExists()) { symFilePath.DirectoryCreate(); diff --git a/Source/Project64/UserInterface/MainMenu.cpp b/Source/Project64/UserInterface/MainMenu.cpp index 0b47e87b6..e923b862b 100644 --- a/Source/Project64/UserInterface/MainMenu.cpp +++ b/Source/Project64/UserInterface/MainMenu.cpp @@ -632,7 +632,8 @@ std::wstring CMainMenu::GetSaveSlotString(int Slot) { FileName.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } - if (Slot != 0) + FileName.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); + if (Slot != 0) { FileName.SetNameExtension(stdstr_f("%s.pj%d", g_Settings->LoadStringVal(Rdb_GoodName).c_str(), Slot).c_str()); } diff --git a/changes.txt b/changes.txt index 794525d10..21fc3604f 100644 --- a/changes.txt +++ b/changes.txt @@ -8,4 +8,5 @@ Windows 2.4 - fixed fpu issue - Indiana Jones (#76) - Fix bug in key assignment (#1309) - Add Shygoo's debugger code -- New audio plugin \ No newline at end of file +- New audio plugin +- large address aware From dc299faebc6dbc987556e3187a95169b251b1b29 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 20 Nov 2018 12:17:22 +1030 Subject: [PATCH 07/32] [Project64] Fix compile bug --- Source/Project64-video/3dmath.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Project64-video/3dmath.cpp b/Source/Project64-video/3dmath.cpp index c771b4106..44196a8ec 100644 --- a/Source/Project64-video/3dmath.cpp +++ b/Source/Project64-video/3dmath.cpp @@ -18,6 +18,9 @@ extern "C" { #endif } +#ifdef _WIN32 +#include +#endif #include #include "3dmath.h" #include "trace.h" From d9fae50e16db778bdbdf2e80dedae02688a69b45 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 20 Nov 2018 13:20:20 +1030 Subject: [PATCH 08/32] [Project64] Try to fix android build --- Source/Common/IniFileClass.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Common/IniFileClass.h b/Source/Common/IniFileClass.h index 23530b672..47236724e 100644 --- a/Source/Common/IniFileClass.h +++ b/Source/Common/IniFileClass.h @@ -8,6 +8,7 @@ #include "FileClass.h" #include "CriticalSection.h" #include "SmartPointer.h" +#include "Platform.h" #include #include #include From 6a65305e742c58a24a8555493eac88686383e00a Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 20 Nov 2018 14:11:32 +1030 Subject: [PATCH 09/32] [Project64] More fixing for android --- Source/Project64-core/N64System/Mips/Eeprom.cpp | 4 +++- Source/Project64-core/N64System/Mips/FlashRam.cpp | 4 +++- Source/Project64-core/N64System/Mips/Mempak.cpp | 4 +++- Source/Project64-core/N64System/Mips/Sram.cpp | 4 +++- Source/Project64-core/N64System/N64Class.cpp | 8 ++++++-- .../Settings/SettingType/SettingsType-Application.cpp | 2 ++ 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Source/Project64-core/N64System/Mips/Eeprom.cpp b/Source/Project64-core/N64System/Mips/Eeprom.cpp index bd57ba471..96062180f 100644 --- a/Source/Project64-core/N64System/Mips/Eeprom.cpp +++ b/Source/Project64-core/N64System/Mips/Eeprom.cpp @@ -148,7 +148,9 @@ void CEeprom::LoadEeprom() { FileName.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } - FileName.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); +#ifdef _WIN32 + FileName.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); +#endif if (!FileName.DirectoryExists()) { diff --git a/Source/Project64-core/N64System/Mips/FlashRam.cpp b/Source/Project64-core/N64System/Mips/FlashRam.cpp index 2d31ec994..03de81eda 100644 --- a/Source/Project64-core/N64System/Mips/FlashRam.cpp +++ b/Source/Project64-core/N64System/Mips/FlashRam.cpp @@ -125,7 +125,9 @@ bool CFlashram::LoadFlashram() { FileName.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } - FileName.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); +#ifdef _WIN32 + FileName.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); +#endif if (!FileName.DirectoryExists()) { diff --git a/Source/Project64-core/N64System/Mips/Mempak.cpp b/Source/Project64-core/N64System/Mips/Mempak.cpp index 2e1a53e36..44c670f71 100644 --- a/Source/Project64-core/N64System/Mips/Mempak.cpp +++ b/Source/Project64-core/N64System/Mips/Mempak.cpp @@ -34,7 +34,9 @@ void CMempak::LoadMempak(int32_t Control, bool Create) { MempakPath.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } - MempakPath.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); +#ifdef _WIN32 + MempakPath.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); +#endif if (!Create && !MempakPath.Exists()) { diff --git a/Source/Project64-core/N64System/Mips/Sram.cpp b/Source/Project64-core/N64System/Mips/Sram.cpp index 307306939..61d155a0b 100644 --- a/Source/Project64-core/N64System/Mips/Sram.cpp +++ b/Source/Project64-core/N64System/Mips/Sram.cpp @@ -28,7 +28,9 @@ bool CSram::LoadSram() { FileName.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } - FileName.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); +#ifdef _WIN32 + FileName.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); +#endif if (!FileName.DirectoryExists()) { diff --git a/Source/Project64-core/N64System/N64Class.cpp b/Source/Project64-core/N64System/N64Class.cpp index 72bffb968..d8ab2da09 100644 --- a/Source/Project64-core/N64System/N64Class.cpp +++ b/Source/Project64-core/N64System/N64Class.cpp @@ -1547,7 +1547,9 @@ bool CN64System::SaveState() { SaveFile.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } - SaveFile.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); +#ifdef _WIN32 + SaveFile.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); +#endif SaveFile.SetName(g_Settings->LoadStringVal(Rdb_GoodName).c_str()); g_Settings->SaveDword(Game_LastSaveSlot, g_Settings->LoadDword(Game_CurrentSaveState)); } @@ -1703,7 +1705,9 @@ bool CN64System::LoadState() { FileName.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str()); } - FileName.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); +#ifdef _WIN32 + FileName.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); +#endif if (g_Settings->LoadDword(Game_CurrentSaveState) != 0) { FileName.SetNameExtension(stdstr_f("%s.pj%d", g_Settings->LoadStringVal(Rdb_GoodName).c_str(), g_Settings->LoadDword(Game_CurrentSaveState)).c_str()); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp index 73319e776..e647091fc 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp @@ -92,7 +92,9 @@ void CSettingTypeApplication::Initialize(const char * /*AppName*/) delete m_SettingsIniFile; } CPath SettingPath(SettingsFile.c_str()); +#ifdef _WIN32 SettingPath.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); +#endif if (!SettingPath.DirectoryExists()) { SettingPath.DirectoryCreate(); From f76769622cd80fd0c05e39a9e9bec6d8a6940b86 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 24 Nov 2018 13:11:50 +1030 Subject: [PATCH 10/32] [Audio] Make sure trace is stopped --- Source/Common/MemTest.cpp | 6 ------ Source/Project64-audio/AudioMain.cpp | 1 + Source/Project64-audio/trace.cpp | 12 +++++++++++- Source/Project64-audio/trace.h | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Source/Common/MemTest.cpp b/Source/Common/MemTest.cpp index d44d2721e..94760d81a 100644 --- a/Source/Common/MemTest.cpp +++ b/Source/Common/MemTest.cpp @@ -92,12 +92,6 @@ void CMemList::RecordAddItem(void * ptr, size_t size, const char * filename, int info.line = line; info.size = (int)size; info.order = m_NextOrder++; - if (info.order == 628) - { - int a = 5; - a = 6; - } - m_MemList->insert(MEMLIST::value_type(ptr, info)); LeaveCriticalSection(&m_cs); } diff --git a/Source/Project64-audio/AudioMain.cpp b/Source/Project64-audio/AudioMain.cpp index fd9e9bc00..78b075575 100644 --- a/Source/Project64-audio/AudioMain.cpp +++ b/Source/Project64-audio/AudioMain.cpp @@ -166,6 +166,7 @@ EXPORT void CALL CloseDLL(void) { WriteTrace(TraceAudioInterface, TraceDebug, "Called"); CleanupAudioSettings(); + StopTrace(); } EXPORT void CALL DllAbout(void * /*hParent*/) diff --git a/Source/Project64-audio/trace.cpp b/Source/Project64-audio/trace.cpp index 723402ca7..718b4ceb3 100644 --- a/Source/Project64-audio/trace.cpp +++ b/Source/Project64-audio/trace.cpp @@ -79,4 +79,14 @@ void StartTrace(void) } g_LogFile = new CTraceFileLog(LogFilePath, g_settings->FlushLogs(), CLog::Log_New, 500); TraceAddModule(g_LogFile); -} \ No newline at end of file +} + +void StopTrace(void) +{ + if (g_LogFile) + { + TraceRemoveModule(g_LogFile); + delete g_LogFile; + g_LogFile = NULL; + } +} diff --git a/Source/Project64-audio/trace.h b/Source/Project64-audio/trace.h index 59baf3404..d228180e6 100644 --- a/Source/Project64-audio/trace.h +++ b/Source/Project64-audio/trace.h @@ -22,3 +22,4 @@ enum TraceModuleAndroidAudio void SetupTrace(void); void StartTrace(void); +void StopTrace(void); From 58305edc8b62b3de0a75955e413bfc8136570805 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 24 Nov 2018 13:17:37 +1030 Subject: [PATCH 11/32] [Video] Make sure to close trace --- Source/Project64-video/Main.cpp | 1 + Source/Project64-video/ScreenResolution.cpp | 2 +- Source/Project64-video/trace.cpp | 12 +++++++++++- Source/Project64-video/trace.h | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/Project64-video/Main.cpp b/Source/Project64-video/Main.cpp index bf487d150..10b911ce2 100644 --- a/Source/Project64-video/Main.cpp +++ b/Source/Project64-video/Main.cpp @@ -675,6 +675,7 @@ void CALL CloseDLL(void) voodoo.gamma_table_g = 0; delete[] voodoo.gamma_table_b; voodoo.gamma_table_b = 0; + StopTrace(); } /****************************************************************** diff --git a/Source/Project64-video/ScreenResolution.cpp b/Source/Project64-video/ScreenResolution.cpp index aa03fc455..5f82ac243 100644 --- a/Source/Project64-video/ScreenResolution.cpp +++ b/Source/Project64-video/ScreenResolution.cpp @@ -270,7 +270,7 @@ void FullScreenResolutions::init() int current = 0; char smode[256]; memset(&enumMode, 0, sizeof(DEVMODE)); - memset(&prevInfo, 0, sizeof(ResolutionInfo)); + prevInfo = ResolutionInfo(); while (EnumDisplaySettings(NULL, iModeNum++, &enumMode) != 0) { ResolutionInfo curInfo(NULL, enumMode.dmPelsWidth, enumMode.dmPelsHeight, enumMode.dmDisplayFrequency); diff --git a/Source/Project64-video/trace.cpp b/Source/Project64-video/trace.cpp index 20c5ef362..66931bf07 100644 --- a/Source/Project64-video/trace.cpp +++ b/Source/Project64-video/trace.cpp @@ -96,4 +96,14 @@ void StartTrace(void) } g_LogFile = new CTraceFileLog(LogFilePath, g_settings->FlushLogs(), CLog::Log_New, 500); TraceAddModule(g_LogFile); -} \ No newline at end of file +} + +void StopTrace(void) +{ + if (g_LogFile) + { + TraceRemoveModule(g_LogFile); + delete g_LogFile; + g_LogFile = NULL; + } +} diff --git a/Source/Project64-video/trace.h b/Source/Project64-video/trace.h index f947b2036..4dc2f6789 100644 --- a/Source/Project64-video/trace.h +++ b/Source/Project64-video/trace.h @@ -30,3 +30,4 @@ enum TraceModuleGlide64 void SetupTrace(void); void StartTrace(void); +void StopTrace(void); From a22512c9ca61778b715d5addc9149198555b4666 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 24 Nov 2018 13:22:35 +1030 Subject: [PATCH 12/32] [Project64] Always close plugins --- Source/Project64-core/Plugins/PluginBase.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/Project64-core/Plugins/PluginBase.cpp b/Source/Project64-core/Plugins/PluginBase.cpp index 78e037f73..354334045 100644 --- a/Source/Project64-core/Plugins/PluginBase.cpp +++ b/Source/Project64-core/Plugins/PluginBase.cpp @@ -230,11 +230,8 @@ void CPlugin::Close(RenderWindow * Render) { WriteTrace(PluginTraceType(), TraceDebug, "(%s): Start", PluginType()); RomClose(Render); - if (m_Initialized) - { - CloseDLL(); - m_Initialized = false; - } + m_Initialized = false; + CloseDLL(); WriteTrace(PluginTraceType(), TraceDebug, "(%s): Done", PluginType()); } From d531abc8854ab15ffedc5ba8d254f414fae222ca Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 25 Nov 2018 20:14:15 +1030 Subject: [PATCH 13/32] [Project64] Add ability to change defaults --- Lang/English.pj.Lang | 1 + Source/Project64-core/Multilanguage.h | 3 +- .../Multilanguage/LanguageClass.cpp | 1 + Source/Project64-core/Settings.cpp | 28 ++++-- .../SettingType/SettingsType-RDBRamSize.cpp | 4 +- .../SettingType/SettingsType-RomDatabase.cpp | 56 ++++++----- .../SettingType/SettingsType-RomDatabase.h | 2 + Source/Project64-core/Settings/SettingsID.h | 11 +++ Source/Project64/Project64.vcxproj | 2 + Source/Project64/Project64.vcxproj.filters | 6 ++ .../Settings/SettingsPage-AdvancedOptions.h | 13 ++- .../Settings/SettingsPage-Defaults.cpp | 98 +++++++++++++++++++ .../Settings/SettingsPage-Defaults.h | 46 +++++++++ .../Settings/SettingsPage-Game-General.h | 2 +- .../UserInterface/Settings/SettingsPage.h | 1 + .../UserInterface/SettingsConfig.cpp | 8 +- .../Project64/UserInterface/SettingsConfig.h | 2 +- Source/Project64/UserInterface/UIResources.rc | 33 +++++++ Source/Project64/UserInterface/resource.h | 3 +- changes.txt | 1 + 20 files changed, 271 insertions(+), 50 deletions(-) create mode 100644 Source/Project64/UserInterface/Settings/SettingsPage-Defaults.cpp create mode 100644 Source/Project64/UserInterface/Settings/SettingsPage-Defaults.h diff --git a/Lang/English.pj.Lang b/Lang/English.pj.Lang index 09e7531a4..245dc60cb 100644 --- a/Lang/English.pj.Lang +++ b/Lang/English.pj.Lang @@ -200,6 +200,7 @@ #409# "Keyboard Shortcuts" #410# "Status" #411# "Recompiler" +#412# "Defaults" //Plugin Dialog #420# "About" diff --git a/Source/Project64-core/Multilanguage.h b/Source/Project64-core/Multilanguage.h index bed85934f..f0abd0b8b 100644 --- a/Source/Project64-core/Multilanguage.h +++ b/Source/Project64-core/Multilanguage.h @@ -229,7 +229,8 @@ enum LanguageStringID TAB_ROMNOTES = 408, TAB_SHORTCUTS = 409, TAB_ROMSTATUS = 410, - TAB_RECOMPILER = 411, //Added in 1.7.0.50 + TAB_RECOMPILER = 411, + TAB_DEFAULTS = 412, //Plugin Dialog PLUG_ABOUT = 420, diff --git a/Source/Project64-core/Multilanguage/LanguageClass.cpp b/Source/Project64-core/Multilanguage/LanguageClass.cpp index 645755eaf..297576bca 100644 --- a/Source/Project64-core/Multilanguage/LanguageClass.cpp +++ b/Source/Project64-core/Multilanguage/LanguageClass.cpp @@ -198,6 +198,7 @@ void CLanguage::LoadDefaultStrings(void) DEF_STR(TAB_SHORTCUTS, "Keyboard Shortcuts"); DEF_STR(TAB_ROMSTATUS, "Status"); DEF_STR(TAB_RECOMPILER, "Recompiler"); + DEF_STR(TAB_DEFAULTS, "Defaults"); //Plugin Dialog DEF_STR(PLUG_ABOUT, "About"); diff --git a/Source/Project64-core/Settings.cpp b/Source/Project64-core/Settings.cpp index 3825f44d6..41bce5442 100644 --- a/Source/Project64-core/Settings.cpp +++ b/Source/Project64-core/Settings.cpp @@ -128,6 +128,16 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Setting_LanguageDirDefault, new CSettingTypeRelativePath("Lang", "")); AddHandler(Setting_LanguageDir, new CSettingTypeApplicationPath("Lang Directory", "Directory", Setting_LanguageDirDefault)); + AddHandler(Default_RDRamSize, new CSettingTypeApplication("Defaults", "RDRAM Size", 0x400000u)); + AddHandler(Default_UseHleGfx, new CSettingTypeApplication("Defaults", "HLE GFX", true)); + AddHandler(Default_UseTlb, new CSettingTypeApplication("Defaults", "Use TLB", true)); + AddHandler(Default_ViRefreshRate, new CSettingTypeApplication("Defaults", "ViRefresh", 1500u)); + AddHandler(Default_AiCountPerBytes, new CSettingTypeApplication("Defaults", "AiCountPerBytes", 0u)); + AddHandler(Default_CounterFactor, new CSettingTypeApplication("Defaults", "Counter Factor", 2u)); + AddHandler(Default_32Bit, new CSettingTypeApplication("Defaults", "32bit", true)); + AddHandler(Default_SyncViaAudio, new CSettingTypeApplication("Defaults", "Audio-Sync Audio", true)); + AddHandler(Default_FixedAudio, new CSettingTypeApplication("Defaults", "Fixed Audio", true)); + AddHandler(Rdb_GoodName, new CSettingTypeRomDatabase("Good Name", Game_GameName)); AddHandler(Rdb_SaveChip, new CSettingTypeRDBSaveChip("Save Type", (uint32_t)SaveChip_Auto)); #ifdef _DEBUG @@ -135,15 +145,15 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) #else AddHandler(Rdb_CpuType, new CSettingTypeRDBCpuType("CPU Type", CPU_Recompiler)); #endif - AddHandler(Rdb_RDRamSize, new CSettingTypeRDBRDRamSize("RDRAM Size", 0x400000)); - AddHandler(Rdb_CounterFactor, new CSettingTypeRomDatabase("Counter Factor", (uint32_t)2)); - AddHandler(Rdb_UseTlb, new CSettingTypeRDBYesNo("Use TLB", true)); + AddHandler(Rdb_RDRamSize, new CSettingTypeRDBRDRamSize("RDRAM Size", Default_RDRamSize)); + AddHandler(Rdb_CounterFactor, new CSettingTypeRomDatabase("Counter Factor", Default_CounterFactor)); + AddHandler(Rdb_UseTlb, new CSettingTypeRDBYesNo("Use TLB", Default_UseTlb)); AddHandler(Rdb_DelayDP, new CSettingTypeRDBYesNo("Delay DP", true)); AddHandler(Rdb_DelaySi, new CSettingTypeRDBYesNo("Delay SI", false)); - AddHandler(Rdb_32Bit, new CSettingTypeRDBYesNo("32bit", true)); + AddHandler(Rdb_32Bit, new CSettingTypeRDBYesNo("32bit", Default_32Bit)); AddHandler(Rdb_FastSP, new CSettingTypeRDBYesNo("Fast SP", true)); - AddHandler(Rdb_FixedAudio, new CSettingTypeRomDatabase("Fixed Audio", true)); - AddHandler(Rdb_SyncViaAudio, new CSettingTypeRomDatabase("Audio-Sync Audio", true)); + AddHandler(Rdb_FixedAudio, new CSettingTypeRomDatabase("Fixed Audio", Default_FixedAudio)); + AddHandler(Rdb_SyncViaAudio, new CSettingTypeRomDatabase("Audio-Sync Audio", Default_SyncViaAudio)); AddHandler(Rdb_RspAudioSignal, new CSettingTypeRDBYesNo("Audio Signal", false)); AddHandler(Rdb_TLB_VAddrStart, new CSettingTypeRomDatabase("TLB: Vaddr Start", (uint32_t)0)); AddHandler(Rdb_TLB_VAddrLen, new CSettingTypeRomDatabase("TLB: Vaddr Len", (uint32_t)0)); @@ -163,8 +173,8 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Rdb_SMM_ValidFunc, new CSettingTypeRomDatabase("SMM-FUNC", true)); AddHandler(Rdb_GameCheatFix, new CSettingTypeRomDatabaseIndex("Cheat", "", "")); AddHandler(Rdb_GameCheatFixPlugin, new CSettingTypeRomDatabaseIndex("CheatPlugin", "", "")); - AddHandler(Rdb_ViRefreshRate, new CSettingTypeRomDatabase("ViRefresh", (uint32_t)1500)); - AddHandler(Rdb_AiCountPerBytes, new CSettingTypeRomDatabase("AiCountPerBytes", (uint32_t)0)); + AddHandler(Rdb_ViRefreshRate, new CSettingTypeRomDatabase("ViRefresh", Default_ViRefreshRate)); + AddHandler(Rdb_AiCountPerBytes, new CSettingTypeRomDatabase("AiCountPerBytes", Default_AiCountPerBytes)); AddHandler(Rdb_AudioResetOnLoad, new CSettingTypeRDBYesNo("AudioResetOnLoad", false)); AddHandler(Rdb_AllowROMWrites, new CSettingTypeRDBYesNo("AllowROMWrites", false)); AddHandler(Rdb_CRC_Recalc, new CSettingTypeRDBYesNo("CRC-Recalc", false)); @@ -370,7 +380,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Plugin_AUDIO_CurVer, new CSettingTypeApplication("Plugin", "Audio Dll Ver", "")); AddHandler(Plugin_CONT_CurVer, new CSettingTypeApplication("Plugin", "Controller Dll Ver", "")); - AddHandler(Plugin_UseHleGfx, new CSettingTypeApplication("RSP", "HLE GFX", true)); + AddHandler(Plugin_UseHleGfx, new CSettingTypeApplication("RSP", "HLE GFX", Default_UseHleGfx)); AddHandler(Plugin_UseHleAudio, new CSettingTypeApplication("RSP", "HLE Audio", false)); AddHandler(Plugin_EnableAudio, new CSettingTypeApplication("Audio", "Enable Audio", true)); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.cpp index c45a57925..f97a27e16 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.cpp @@ -45,7 +45,7 @@ bool CSettingTypeRDBRDRamSize::Load (uint32_t Index, uint32_t & Value ) const LoadDefault(Index,ulValue); } Value = 0x400000; - if (ulValue == 8 || !existsInRdb) //default to 8MB if ROM is not in the RDB + if (ulValue == 8 || ulValue == 0x800000 || !existsInRdb) //default to 8MB if ROM is not in the RDB { Value = 0x800000; } @@ -66,7 +66,7 @@ void CSettingTypeRDBRDRamSize::LoadDefault (uint32_t /*Index*/, bool & /*Value*/ void CSettingTypeRDBRDRamSize::LoadDefault (uint32_t /*Index*/, uint32_t & Value ) const { - Value = m_DefaultValue; + Value = m_DefaultSetting == Default_Constant ? m_DefaultValue : g_Settings->LoadDword(m_DefaultSetting); } void CSettingTypeRDBRDRamSize::LoadDefault (uint32_t /*Index*/, std::string & /*Value*/ ) const diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp index 78e774f93..7a5fbe124 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp @@ -135,34 +135,44 @@ void CSettingTypeRomDatabase::GameChanged(void * /*Data */) } } +bool CSettingTypeRomDatabase::Load(uint32_t & Value) const +{ + bool bRes = false; + if (m_VideoSetting) + { + bRes = m_VideoIniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value); + } + else if (m_AudioSetting) + { + bRes = m_AudioIniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value); + } + else + { + bRes = m_SettingsIniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value); + } + return bRes; +} + bool CSettingTypeRomDatabase::Load(uint32_t Index, bool & Value) const { uint32_t temp_value = Value; - bool bRes = Load(Index, temp_value); - Value = temp_value != 0; - return bRes; + if (Load(temp_value)) + { + Value = temp_value != 0; + true; + } + LoadDefault(Index, Value); + return false; } bool CSettingTypeRomDatabase::Load(uint32_t Index, uint32_t & Value) const { - bool bRes = false; - if (m_VideoSetting) - { - bRes = m_VideoIniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value); - } - else if (m_AudioSetting) - { - bRes = m_AudioIniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value); - } - else - { - bRes = m_SettingsIniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value); - } - if (!bRes) + if (!Load(Value)) { LoadDefault(Index, Value); - } - return bRes; + return false; + } + return true; } bool CSettingTypeRomDatabase::Load(uint32_t Index, std::string & Value) const @@ -211,13 +221,7 @@ void CSettingTypeRomDatabase::LoadDefault(uint32_t /*Index*/, uint32_t & Value) { if (m_DefaultSetting != Default_None) { - if (m_DefaultSetting == Default_Constant) - { - Value = m_DefaultValue; - } - else { - g_Settings->LoadDword(m_DefaultSetting, Value); - } + Value = m_DefaultSetting == Default_Constant ? m_DefaultValue : g_Settings->LoadDword(m_DefaultSetting); } } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h index 21ed7f663..b97845731 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h @@ -76,4 +76,6 @@ private: CSettingTypeRomDatabase(); // Disable default constructor CSettingTypeRomDatabase(const CSettingTypeRomDatabase&); // Disable copy constructor CSettingTypeRomDatabase& operator=(const CSettingTypeRomDatabase&); // Disable assignment + + bool Load(uint32_t & Value) const; }; diff --git a/Source/Project64-core/Settings/SettingsID.h b/Source/Project64-core/Settings/SettingsID.h index dfb1bcdde..af221c4d7 100644 --- a/Source/Project64-core/Settings/SettingsID.h +++ b/Source/Project64-core/Settings/SettingsID.h @@ -61,6 +61,17 @@ enum SettingID Setting_CurrentLanguage, Setting_EnableDisk, + //Default Settings + Default_RDRamSize, + Default_UseHleGfx, + Default_UseTlb, + Default_ViRefreshRate, + Default_AiCountPerBytes, + Default_CounterFactor, + Default_32Bit, + Default_SyncViaAudio, + Default_FixedAudio, + //RDB Settings Rdb_GoodName, Rdb_SaveChip, diff --git a/Source/Project64/Project64.vcxproj b/Source/Project64/Project64.vcxproj index 1e7962529..3127a0965 100644 --- a/Source/Project64/Project64.vcxproj +++ b/Source/Project64/Project64.vcxproj @@ -111,6 +111,7 @@ + @@ -174,6 +175,7 @@ + diff --git a/Source/Project64/Project64.vcxproj.filters b/Source/Project64/Project64.vcxproj.filters index 3e07a311c..4b3fb4c71 100644 --- a/Source/Project64/Project64.vcxproj.filters +++ b/Source/Project64/Project64.vcxproj.filters @@ -216,6 +216,9 @@ Source Files + + Source Files\User Interface Source\Settings Source + @@ -413,6 +416,9 @@ Header Files + + Header Files\User Interface Headers\Settings Header + diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.h b/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.h index 4c8cd3084..130ad04d0 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.h @@ -27,7 +27,6 @@ class CAdvancedOptionsPage : COMMAND_ID_HANDLER_EX(IDC_SELECT_IPL_DIR, SelectIplDir) COMMAND_HANDLER_EX(IDC_IPL_DIR, EN_UPDATE, IplDirChanged) COMMAND_HANDLER_EX(IDC_FRAME_DISPLAY_TYPE,LBN_SELCHANGE,ComboBoxChanged) - END_MSG_MAP() enum { IDD = IDD_Settings_Advanced }; @@ -35,12 +34,12 @@ class CAdvancedOptionsPage : public: CAdvancedOptionsPage(HWND hParent, const RECT & rcDispay ); - LanguageStringID PageTitle ( void ) { return TAB_ADVANCED; } - void HidePage ( void ); - void ShowPage ( void ); - void ApplySettings ( bool UpdateScreen ); - bool EnableReset ( void ); - void ResetPage ( void ); + LanguageStringID PageTitle ( void ) { return TAB_ADVANCED; } + void HidePage ( void ); + void ShowPage ( void ); + void ApplySettings ( bool UpdateScreen ); + bool EnableReset ( void ); + void ResetPage ( void ); private: void SelectIplDir(UINT Code, int id, HWND ctl); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.cpp new file mode 100644 index 000000000..bb082f785 --- /dev/null +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +* * +* 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 "SettingsPage.h" + +CDefaultsOptionsPage::CDefaultsOptionsPage(HWND hParent, const RECT & rcDispay) +{ + if (!Create(hParent, rcDispay)) + { + return; + } + UpdatePageSettings(); + + SetDlgItemTextW(m_hWnd, IDC_MEMORY_SIZE_TEXT, wGS(ROM_MEM_SIZE).c_str()); + SetDlgItemTextW(m_hWnd, IDC_HLE_GFX, wGS(PLUG_HLE_GFX).c_str()); + SetDlgItemTextW(m_hWnd, IDC_USE_TLB, wGS(ROM_USE_TLB).c_str()); + SetDlgItemTextW(m_hWnd, IDC_VIREFESH_TEXT, wGS(ROM_VIREFRESH).c_str()); + SetDlgItemTextW(m_hWnd, IDC_COUNTPERBYTE_TEXT, wGS(ROM_COUNTPERBYTE).c_str()); + SetDlgItemTextW(m_hWnd, IDC_COUNTFACT_TEXT, wGS(ROM_COUNTER_FACTOR).c_str()); + SetDlgItemTextW(m_hWnd, IDC_ROM_32BIT, wGS(ROM_32BIT).c_str()); + SetDlgItemTextW(m_hWnd, IDC_ROM_FIXEDAUDIO, wGS(ROM_FIXED_AUDIO).c_str()); + SetDlgItemTextW(m_hWnd, IDC_SYNC_AUDIO, wGS(ROM_SYNC_AUDIO).c_str()); + + CModifiedComboBox * ComboBox; + ComboBox = AddModComboBox(GetDlgItem(IDC_RDRAM_SIZE), Default_RDRamSize); + if (ComboBox) + { + ComboBox->SetTextField(GetDlgItem(IDC_MEMORY_SIZE_TEXT)); + ComboBox->AddItemW(wGS(RDRAM_4MB).c_str(), 0x400000); + ComboBox->AddItemW(wGS(RDRAM_8MB).c_str(), 0x800000); + } + + ComboBox = AddModComboBox(GetDlgItem(IDC_COUNTFACT), Default_CounterFactor); + if (ComboBox) + { + ComboBox->SetTextField(GetDlgItem(IDC_COUNTFACT_TEXT)); + ComboBox->AddItemW(wGS(NUMBER_1).c_str(), 1); + ComboBox->AddItemW(wGS(NUMBER_2).c_str(), 2); + ComboBox->AddItemW(wGS(NUMBER_3).c_str(), 3); + ComboBox->AddItemW(wGS(NUMBER_4).c_str(), 4); + ComboBox->AddItemW(wGS(NUMBER_5).c_str(), 5); + ComboBox->AddItemW(wGS(NUMBER_6).c_str(), 6); + } + + CModifiedEditBox * TxtBox = AddModTextBox(GetDlgItem(IDC_VIREFRESH), Default_ViRefreshRate, false); + TxtBox->SetTextField(GetDlgItem(IDC_VIREFESH_TEXT)); + TxtBox = AddModTextBox(GetDlgItem(IDC_COUNTPERBYTE), Default_AiCountPerBytes, false); + TxtBox->SetTextField(GetDlgItem(IDC_COUNTPERBYTE_TEXT)); + + AddModCheckBox(GetDlgItem(IDC_HLE_GFX), Default_UseHleGfx); + AddModCheckBox(GetDlgItem(IDC_USE_TLB), Default_UseTlb); + AddModCheckBox(GetDlgItem(IDC_ROM_32BIT), Default_32Bit); + AddModCheckBox(GetDlgItem(IDC_SYNC_AUDIO), Default_SyncViaAudio); + AddModCheckBox(GetDlgItem(IDC_ROM_FIXEDAUDIO), Default_FixedAudio); + + UpdatePageSettings(); +} + +void CDefaultsOptionsPage::HidePage() +{ + ShowWindow(SW_HIDE); +} + +void CDefaultsOptionsPage::ShowPage() +{ + ShowWindow(SW_SHOW); +} + +void CDefaultsOptionsPage::ApplySettings(bool UpdateScreen) +{ + CSettingsPageImpl::ApplySettings(UpdateScreen); +} + +bool CDefaultsOptionsPage::EnableReset(void) +{ + if (CSettingsPageImpl::EnableReset()) { return true; } + return false; +} + +void CDefaultsOptionsPage::ResetPage() +{ + CSettingsPageImpl::ResetPage(); +} + +void CDefaultsOptionsPage::UpdatePageSettings(void) +{ + m_InUpdateSettings = true; + CSettingsPageImpl::UpdatePageSettings(); + m_InUpdateSettings = false; +} \ No newline at end of file diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.h b/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.h new file mode 100644 index 000000000..0e2877ff5 --- /dev/null +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.h @@ -0,0 +1,46 @@ +/**************************************************************************** +* * +* 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 + +class CDefaultsOptionsPage : + public CSettingsPageImpl, + public CSettingsPage +{ + BEGIN_MSG_MAP_EX(CDefaultsOptionsPage) + COMMAND_ID_HANDLER_EX(IDC_HLE_GFX, CheckBoxChanged) + COMMAND_ID_HANDLER_EX(IDC_USE_TLB, CheckBoxChanged) + COMMAND_ID_HANDLER_EX(IDC_ROM_32BIT, CheckBoxChanged) + COMMAND_ID_HANDLER_EX(IDC_SYNC_AUDIO, CheckBoxChanged) + COMMAND_ID_HANDLER_EX(IDC_ROM_FIXEDAUDIO, CheckBoxChanged) + COMMAND_HANDLER_EX(IDC_RDRAM_SIZE, LBN_SELCHANGE, ComboBoxChanged) + COMMAND_HANDLER_EX(IDC_COUNTFACT, LBN_SELCHANGE, ComboBoxChanged) + COMMAND_HANDLER_EX(IDC_VIREFRESH, EN_UPDATE, EditBoxChanged) + COMMAND_HANDLER_EX(IDC_COUNTPERBYTE, EN_UPDATE, EditBoxChanged) + COMMAND_HANDLER_EX(IDC_RDRAM_SIZE, EN_UPDATE, EditBoxChanged) + END_MSG_MAP() + + enum { IDD = IDD_Settings_Defaults }; + +public: + CDefaultsOptionsPage(HWND hParent, const RECT & rcDispay ); + + LanguageStringID PageTitle ( void ) { return TAB_DEFAULTS; } + void HidePage ( void ); + void ShowPage ( void ); + void ApplySettings ( bool UpdateScreen ); + bool EnableReset ( void ); + void ResetPage ( void ); + +private: + void UpdatePageSettings(void); + + bool m_InUpdateSettings; +}; diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.h b/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.h index eb08d247c..d4c1a16f7 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.h @@ -31,7 +31,7 @@ class CGameGeneralPage : COMMAND_HANDLER_EX(IDC_VIREFRESH, EN_UPDATE, EditBoxChanged) COMMAND_HANDLER_EX(IDC_COUNTPERBYTE, EN_UPDATE, EditBoxChanged) COMMAND_HANDLER_EX(IDC_OVER_CLOCK_MODIFIER, EN_UPDATE, EditBoxChanged) - END_MSG_MAP() + END_MSG_MAP() enum { IDD = IDD_Settings_GameGeneral }; diff --git a/Source/Project64/UserInterface/Settings/SettingsPage.h b/Source/Project64/UserInterface/Settings/SettingsPage.h index 1c39307e6..95011381a 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage.h @@ -582,6 +582,7 @@ public: }; #include "SettingsPage-AdvancedOptions.h" +#include "SettingsPage-Defaults.h" #include "SettingsPage-Directories.h" #include "SettingsPage-Game-General.h" #include "SettingsPage-Game-Plugin.h" diff --git a/Source/Project64/UserInterface/SettingsConfig.cpp b/Source/Project64/UserInterface/SettingsConfig.cpp index ee642b629..1b45c2375 100644 --- a/Source/Project64/UserInterface/SettingsConfig.cpp +++ b/Source/Project64/UserInterface/SettingsConfig.cpp @@ -8,6 +8,7 @@ CSettingConfig::CSettingConfig(bool bJustGameSetting /* = false */) : m_CurrentPage(NULL), m_GeneralOptionsPage(NULL), m_AdvancedPage(NULL), + m_DefaultsPage(NULL), m_GameConfig(bJustGameSetting) { } @@ -55,7 +56,7 @@ bool CSettingConfig::UpdateAdvanced(bool AdvancedMode, HTREEITEM hItem) while (hItem) { CSettingsPage * Page = (CSettingsPage *)m_PagesTreeList.GetItemData(hItem); - if (!AdvancedMode && Page == m_AdvancedPage) + if (!AdvancedMode && (Page == m_AdvancedPage || Page == m_DefaultsPage)) { m_PagesTreeList.DeleteItem(hItem); return true; @@ -63,6 +64,7 @@ bool CSettingConfig::UpdateAdvanced(bool AdvancedMode, HTREEITEM hItem) if (AdvancedMode && Page == m_GeneralOptionsPage) { m_PagesTreeList.InsertItemW(TVIF_TEXT | TVIF_PARAM, wGS(m_AdvancedPage->PageTitle()).c_str(), 0, 0, 0, 0, (ULONG)m_AdvancedPage, hItem, TVI_FIRST); + m_PagesTreeList.InsertItemW(TVIF_TEXT | TVIF_PARAM, wGS(m_DefaultsPage->PageTitle()).c_str(), 0, 0, 0, 0, (ULONG)m_DefaultsPage, hItem, TVI_FIRST); return true; } if (UpdateAdvanced(AdvancedMode, m_PagesTreeList.GetChildItem(hItem))) @@ -127,10 +129,12 @@ LRESULT CSettingConfig::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* m_GeneralOptionsPage = new CGeneralOptionsPage(this, this->m_hWnd, rcSettingInfo); m_AdvancedPage = new CAdvancedOptionsPage(this->m_hWnd, rcSettingInfo); + m_DefaultsPage = new CDefaultsOptionsPage(this->m_hWnd, rcSettingInfo); SettingsSection = new CConfigSettingSection(wGS(TAB_OPTIONS).c_str()); SettingsSection->AddPage(m_GeneralOptionsPage); SettingsSection->AddPage(m_AdvancedPage); + SettingsSection->AddPage(m_DefaultsPage); SettingsSection->AddPage(new COptionsDirectoriesPage(this->m_hWnd, rcSettingInfo)); m_Sections.push_back(SettingsSection); @@ -177,7 +181,7 @@ LRESULT CSettingConfig::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* for (size_t i = 0; i < Section->GetPageCount(); i++) { CSettingsPage * Page = Section->GetPage(i); - if (HideAdvanced && Page == m_AdvancedPage) + if (HideAdvanced && (Page == m_AdvancedPage || Page == m_DefaultsPage)) { continue; } diff --git a/Source/Project64/UserInterface/SettingsConfig.h b/Source/Project64/UserInterface/SettingsConfig.h index 02a005787..1717c5994 100644 --- a/Source/Project64/UserInterface/SettingsConfig.h +++ b/Source/Project64/UserInterface/SettingsConfig.h @@ -40,6 +40,6 @@ private: CTreeViewCtrl m_PagesTreeList; SETTING_SECTIONS m_Sections; - CSettingsPage * m_CurrentPage, *m_GeneralOptionsPage, *m_AdvancedPage; + CSettingsPage * m_CurrentPage, *m_GeneralOptionsPage, *m_AdvancedPage, *m_DefaultsPage; bool m_GameConfig; }; diff --git a/Source/Project64/UserInterface/UIResources.rc b/Source/Project64/UserInterface/UIResources.rc index 2badf997c..bbf840a83 100644 --- a/Source/Project64/UserInterface/UIResources.rc +++ b/Source/Project64/UserInterface/UIResources.rc @@ -1256,6 +1256,26 @@ BEGIN EDITTEXT IDC_DD48_EDIT,87,226,39,10,ES_UPPERCASE | ES_AUTOHSCROLL,WS_EX_RIGHT END +IDD_Settings_Defaults DIALOGEX 0, 0, 218, 169 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Memory Size:",IDC_MEMORY_SIZE_TEXT,6,8,91,10 + COMBOBOX IDC_RDRAM_SIZE,102,6,109,49,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Use High Level GFX",IDC_HLE_GFX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,81,91,10 + CONTROL "Use TLB",IDC_USE_TLB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,58,91,10 + LTEXT "Vi Refresh Rate:",IDC_VIREFESH_TEXT,6,32,91,10 + EDITTEXT IDC_VIREFRESH,102,30,109,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "AI Count Per Byte:",IDC_COUNTPERBYTE_TEXT,6,45,91,10 + EDITTEXT IDC_COUNTPERBYTE,102,44,109,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Counter Factor:",IDC_COUNTFACT_TEXT,6,19,91,10 + COMBOBOX IDC_COUNTFACT,102,18,109,49,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "32 Bit Engine",IDC_ROM_32BIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,58,91,10 + CONTROL "Fixed Audio Timing",IDC_ROM_FIXEDAUDIO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,69,91,10 + CONTROL "Sync using Audio",IDC_SYNC_AUDIO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,102,69,91,10 +END + ///////////////////////////////////////////////////////////////////////////// // @@ -1669,6 +1689,14 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 219 END + + IDD_Settings_Defaults, DIALOG + BEGIN + LEFTMARGIN, 4 + RIGHTMARGIN, 216 + TOPMARGIN, 4 + BOTTOMMARGIN, 163 + END END #endif // APSTUDIO_INVOKED @@ -1848,6 +1876,11 @@ BEGIN 0, 0, 0, 0 END +IDD_Settings_Defaults AFX_DIALOG_LAYOUT +BEGIN + 0 +END + ///////////////////////////////////////////////////////////////////////////// // diff --git a/Source/Project64/UserInterface/resource.h b/Source/Project64/UserInterface/resource.h index e87e9232a..7135613b4 100644 --- a/Source/Project64/UserInterface/resource.h +++ b/Source/Project64/UserInterface/resource.h @@ -72,6 +72,7 @@ #define IDD_Debugger_RegRDRAM 198 #define IDD_Debugger_RegVI 199 #define IDD_Debugger_RegDD 200 +#define IDD_Settings_Defaults 201 #define IDC_MENU_ITEM_TEXT 1000 #define IDC_CLOSE_BUTTON 1001 #define IDC_LIST2 1003 @@ -637,7 +638,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 194 +#define _APS_NEXT_RESOURCE_VALUE 195 #define _APS_NEXT_COMMAND_VALUE 40043 #define _APS_NEXT_CONTROL_VALUE 1445 #define _APS_NEXT_SYMED_VALUE 102 diff --git a/changes.txt b/changes.txt index 21fc3604f..2e34fc04b 100644 --- a/changes.txt +++ b/changes.txt @@ -10,3 +10,4 @@ Windows 2.4 - Add Shygoo's debugger code - New audio plugin - large address aware +- Ability to change defaults From bb29e788069db7b7bc29d63bba2b7d357d351727 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 26 Nov 2018 07:30:50 +1030 Subject: [PATCH 14/32] [Project64] Disable memory test in release --- Source/Common/MemTest.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Common/MemTest.cpp b/Source/Common/MemTest.cpp index 94760d81a..ef5698db6 100644 --- a/Source/Common/MemTest.cpp +++ b/Source/Common/MemTest.cpp @@ -1,8 +1,11 @@ #include "stdafx.h" -#include +#include "MemTest.h" + +#if defined(MEM_LEAK_TEST) && defined(_WIN32) + #undef new -#ifdef _WIN32 +#include #include static bool InInit = false; @@ -219,4 +222,4 @@ void operator delete[](void* ptr, const char* /*filename*/, unsigned int /*line* delete ptr; } -#endif +#endif \ No newline at end of file From 529b162656a9b8212af2bae1fd13b74673d49ccf Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 26 Nov 2018 08:02:41 +1030 Subject: [PATCH 15/32] [Audio] Make sure freeing g_SoundDriver on closing --- Source/Project64-audio/AudioMain.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Project64-audio/AudioMain.cpp b/Source/Project64-audio/AudioMain.cpp index 78b075575..f0b1b8658 100644 --- a/Source/Project64-audio/AudioMain.cpp +++ b/Source/Project64-audio/AudioMain.cpp @@ -165,6 +165,12 @@ EXPORT void CALL AiUpdate(int32_t Wait) EXPORT void CALL CloseDLL(void) { WriteTrace(TraceAudioInterface, TraceDebug, "Called"); + if (g_SoundDriver != NULL) + { + g_SoundDriver->AI_Shutdown(); + delete g_SoundDriver; + g_SoundDriver = NULL; + } CleanupAudioSettings(); StopTrace(); } From 6c2c0d5dd64161a2394138651f0452009ad164be Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 26 Nov 2018 11:23:39 +1030 Subject: [PATCH 16/32] [Project64] Make sure closeDll is set before calling it --- Source/Project64-core/Plugins/PluginBase.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Project64-core/Plugins/PluginBase.cpp b/Source/Project64-core/Plugins/PluginBase.cpp index 354334045..5ed8f19e7 100644 --- a/Source/Project64-core/Plugins/PluginBase.cpp +++ b/Source/Project64-core/Plugins/PluginBase.cpp @@ -231,7 +231,10 @@ void CPlugin::Close(RenderWindow * Render) WriteTrace(PluginTraceType(), TraceDebug, "(%s): Start", PluginType()); RomClose(Render); m_Initialized = false; - CloseDLL(); + if (CloseDLL != NULL) + { + CloseDLL(); + } WriteTrace(PluginTraceType(), TraceDebug, "(%s): Done", PluginType()); } From 75b78e02a74e001d93eec2187f5cc4c96ccc0cb9 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 26 Nov 2018 11:25:26 +1030 Subject: [PATCH 17/32] [Project64] Renumber IDC_ROM_FIXEDAUDIO --- Source/Project64/UserInterface/resource.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Project64/UserInterface/resource.h b/Source/Project64/UserInterface/resource.h index 7135613b4..8e34ce16d 100644 --- a/Source/Project64/UserInterface/resource.h +++ b/Source/Project64/UserInterface/resource.h @@ -99,7 +99,6 @@ #define IDC_INFO_CIC 1011 #define IDC_CTL 1011 #define IDC_CACHE 1011 -#define IDC_ROM_FIXEDAUDIO 1011 #define IDC_DEBUGGER 1011 #define IDC_USE_ALT_PC 1011 #define IDC_HLE_GFX 1011 @@ -603,6 +602,7 @@ #define IDC_DD40_EDIT 1442 #define IDC_DD44_EDIT 1443 #define IDC_DD48_EDIT 1444 +#define IDC_ROM_FIXEDAUDIO 1445 #define ID_POPUP_SHOWINMEMORYVIEWER 40005 #define ID_POPUPMENU_PLAYGAMEWITHDISK 40008 #define ID_POPUPMENU_ADDSYMBOL 40013 @@ -640,7 +640,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 195 #define _APS_NEXT_COMMAND_VALUE 40043 -#define _APS_NEXT_CONTROL_VALUE 1445 +#define _APS_NEXT_CONTROL_VALUE 1446 #define _APS_NEXT_SYMED_VALUE 102 #endif #endif From bac6023a5c705cdbf810b053f0860488c3529e9e Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 26 Nov 2018 11:26:08 +1030 Subject: [PATCH 18/32] [Project64] Use Settings instead of default in config file --- Bin/Debug/Config/Project64.cfg | 2 +- Bin/Debug64/Config/Project64.cfg | 2 +- Bin/Release/Config/Project64.cfg | 2 +- Bin/Release64/Config/Project64.cfg | 2 +- Source/Project64-core/Settings.cpp | 52 +++++++++++++++--------------- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Bin/Debug/Config/Project64.cfg b/Bin/Debug/Config/Project64.cfg index 9b71c50ea..6bf557e20 100644 --- a/Bin/Debug/Config/Project64.cfg +++ b/Bin/Debug/Config/Project64.cfg @@ -1,2 +1,2 @@ -[default] +[Settings] ConfigFile=..\..\Config\Project64.cfg diff --git a/Bin/Debug64/Config/Project64.cfg b/Bin/Debug64/Config/Project64.cfg index de2c5dfbc..f3fe29ca9 100644 --- a/Bin/Debug64/Config/Project64.cfg +++ b/Bin/Debug64/Config/Project64.cfg @@ -1,2 +1,2 @@ -[default] +[Settings] ConfigFile=..\..\Config\Project64.cfg diff --git a/Bin/Release/Config/Project64.cfg b/Bin/Release/Config/Project64.cfg index 9b71c50ea..6bf557e20 100644 --- a/Bin/Release/Config/Project64.cfg +++ b/Bin/Release/Config/Project64.cfg @@ -1,2 +1,2 @@ -[default] +[Settings] ConfigFile=..\..\Config\Project64.cfg diff --git a/Bin/Release64/Config/Project64.cfg b/Bin/Release64/Config/Project64.cfg index de2c5dfbc..f3fe29ca9 100644 --- a/Bin/Release64/Config/Project64.cfg +++ b/Bin/Release64/Config/Project64.cfg @@ -1,2 +1,2 @@ -[default] +[Settings] ConfigFile=..\..\Config\Project64.cfg diff --git a/Source/Project64-core/Settings.cpp b/Source/Project64-core/Settings.cpp index 41bce5442..7b6a3d539 100644 --- a/Source/Project64-core/Settings.cpp +++ b/Source/Project64-core/Settings.cpp @@ -90,40 +90,40 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Cmd_RomFile, new CSettingTypeTempString("")); //Support Files - AddHandler(SupportFile_Settings, new CSettingTypeApplicationPath("", "ConfigFile", SupportFile_SettingsDefault)); + AddHandler(SupportFile_Settings, new CSettingTypeApplicationPath("Settings", "ConfigFile", SupportFile_SettingsDefault)); AddHandler(SupportFile_SettingsDefault, new CSettingTypeRelativePath("Config", "Project64.cfg")); - AddHandler(SupportFile_RomDatabase, new CSettingTypeApplicationPath("", "RomDatabase", SupportFile_RomDatabaseDefault)); + AddHandler(SupportFile_RomDatabase, new CSettingTypeApplicationPath("Settings", "RomDatabase", SupportFile_RomDatabaseDefault)); AddHandler(SupportFile_RomDatabaseDefault, new CSettingTypeRelativePath("Config", "Project64.rdb")); - AddHandler(SupportFile_VideoRDB, new CSettingTypeApplicationPath("", "VideoRDB", SupportFile_VideoRDBDefault)); + AddHandler(SupportFile_VideoRDB, new CSettingTypeApplicationPath("Settings", "VideoRDB", SupportFile_VideoRDBDefault)); AddHandler(SupportFile_VideoRDBDefault, new CSettingTypeRelativePath("Config", "Video.rdb")); - AddHandler(SupportFile_AudioRDB, new CSettingTypeApplicationPath("", "AudioRDB", SupportFile_AudioRDBDefault)); + AddHandler(SupportFile_AudioRDB, new CSettingTypeApplicationPath("Settings", "AudioRDB", SupportFile_AudioRDBDefault)); AddHandler(SupportFile_AudioRDBDefault, new CSettingTypeRelativePath("Config", "Audio.rdb")); - AddHandler(SupportFile_Cheats, new CSettingTypeApplicationPath("", "Cheats", SupportFile_CheatsDefault)); + AddHandler(SupportFile_Cheats, new CSettingTypeApplicationPath("Settings", "Cheats", SupportFile_CheatsDefault)); AddHandler(SupportFile_CheatsDefault, new CSettingTypeRelativePath("Config", "Project64.cht")); - AddHandler(SupportFile_Notes, new CSettingTypeApplicationPath("", "Notes", SupportFile_NotesDefault)); + AddHandler(SupportFile_Notes, new CSettingTypeApplicationPath("Settings", "Notes", SupportFile_NotesDefault)); AddHandler(SupportFile_NotesDefault, new CSettingTypeRelativePath("Config", "Project64.rdn")); - AddHandler(SupportFile_ExtInfo, new CSettingTypeApplicationPath("", "ExtInfo", SupportFile_ExtInfoDefault)); + AddHandler(SupportFile_ExtInfo, new CSettingTypeApplicationPath("Settings", "ExtInfo", SupportFile_ExtInfoDefault)); AddHandler(SupportFile_ExtInfoDefault, new CSettingTypeRelativePath("Config", "Project64.rdx")); //Settings location AddHandler(Setting_ApplicationName, new CSettingTypeTempString("")); AddHandler(Setting_UseFromRegistry, new CSettingTypeApplication("Settings", "Use Registry", (uint32_t)false)); - AddHandler(Setting_RdbEditor, new CSettingTypeApplication("", "Rdb Editor", false)); - AddHandler(Setting_CN64TimeCritical, new CSettingTypeApplication("", "CN64TimeCritical", false)); - AddHandler(Setting_AutoStart, new CSettingTypeApplication("", "Auto Start", (uint32_t)true)); - AddHandler(Setting_AutoZipInstantSave, new CSettingTypeApplication("", "Auto Zip Saves", (uint32_t)true)); - AddHandler(Setting_EraseGameDefaults, new CSettingTypeApplication("", "Erase on default", (uint32_t)true)); - AddHandler(Setting_CheckEmuRunning, new CSettingTypeApplication("", "Check Running", (uint32_t)true)); - AddHandler(Setting_ForceInterpreterCPU, new CSettingTypeApplication("", "Force Interpreter CPU", false)); - AddHandler(Setting_FixedRdramAddress, new CSettingTypeApplication("", "Fixed Rdram Address", (uint32_t)0)); + AddHandler(Setting_RdbEditor, new CSettingTypeApplication("Settings", "Rdb Editor", false)); + AddHandler(Setting_CN64TimeCritical, new CSettingTypeApplication("Settings", "CN64TimeCritical", false)); + AddHandler(Setting_AutoStart, new CSettingTypeApplication("Settings", "Auto Start", (uint32_t)true)); + AddHandler(Setting_AutoZipInstantSave, new CSettingTypeApplication("Settings", "Auto Zip Saves", (uint32_t)true)); + AddHandler(Setting_EraseGameDefaults, new CSettingTypeApplication("Settings", "Erase on default", (uint32_t)true)); + AddHandler(Setting_CheckEmuRunning, new CSettingTypeApplication("Settings", "Check Running", (uint32_t)true)); + AddHandler(Setting_ForceInterpreterCPU, new CSettingTypeApplication("Settings", "Force Interpreter CPU", false)); + AddHandler(Setting_FixedRdramAddress, new CSettingTypeApplication("Settings", "Fixed Rdram Address", (uint32_t)0)); - AddHandler(Setting_RememberCheats, new CSettingTypeApplication("", "Remember Cheats", (uint32_t)false)); + AddHandler(Setting_RememberCheats, new CSettingTypeApplication("Settings", "Remember Cheats", (uint32_t)false)); #ifdef ANDROID AddHandler(Setting_UniqueSaveDir, new CSettingTypeTempBool(true)); #else - AddHandler(Setting_UniqueSaveDir, new CSettingTypeApplication("", "Unique Game Dir", (uint32_t)false)); + AddHandler(Setting_UniqueSaveDir, new CSettingTypeApplication("Settings", "Unique Game Dir", (uint32_t)false)); #endif - AddHandler(Setting_CurrentLanguage, new CSettingTypeApplication("", "Current Language", "")); + AddHandler(Setting_CurrentLanguage, new CSettingTypeApplication("Settings", "Current Language", "")); AddHandler(Setting_EnableDisk, new CSettingTypeTempBool(false)); AddHandler(Setting_LanguageDirDefault, new CSettingTypeRelativePath("Lang", "")); AddHandler(Setting_LanguageDir, new CSettingTypeApplicationPath("Lang Directory", "Directory", Setting_LanguageDirDefault)); @@ -239,13 +239,13 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Game_FullSpeed, new CSettingTypeTempBool(true, "Full Speed")); //User Interface - AddHandler(UserInterface_ShowCPUPer, new CSettingTypeApplication("", "Display CPU Usage", (uint32_t)false)); + AddHandler(UserInterface_ShowCPUPer, new CSettingTypeApplication("Settings", "Display CPU Usage", (uint32_t)false)); #ifdef ANDROID - AddHandler(UserInterface_DisplayFrameRate, new CSettingTypeApplication("", "Display Frame Rate", (uint32_t)false)); + AddHandler(UserInterface_DisplayFrameRate, new CSettingTypeApplication("Settings", "Display Frame Rate", (uint32_t)false)); #else - AddHandler(UserInterface_DisplayFrameRate, new CSettingTypeApplication("", "Display Frame Rate", (uint32_t)true)); + AddHandler(UserInterface_DisplayFrameRate, new CSettingTypeApplication("Settings", "Display Frame Rate", (uint32_t)true)); #endif - AddHandler(UserInterface_FrameDisplayType, new CSettingTypeApplication("", "Frame Rate Display Type", (uint32_t)FR_VIs)); + AddHandler(UserInterface_FrameDisplayType, new CSettingTypeApplication("Settings", "Frame Rate Display Type", (uint32_t)FR_VIs)); AddHandler(Directory_Plugin, new CSettingTypeSelectedDirectory("Dir:Plugin", Directory_PluginInitial, Directory_PluginSelected, Directory_PluginUseSelected, Directory_Plugin)); #ifndef _M_X64 AddHandler(Directory_PluginInitial, new CSettingTypeRelativePath("Plugin", "")); @@ -295,13 +295,13 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Directory_LogUseSelected, new CSettingTypeApplication("Log Directory", "Use Selected", false)); AddHandler(RomList_RomListCacheDefault, new CSettingTypeRelativePath("Config", "Project64.cache3")); - AddHandler(RomList_RomListCache, new CSettingTypeApplicationPath("", "RomListCache", RomList_RomListCacheDefault)); + AddHandler(RomList_RomListCache, new CSettingTypeApplicationPath("Settings", "RomListCache", RomList_RomListCacheDefault)); AddHandler(RomList_GameDir, new CSettingTypeSelectedDirectory("Dir:Game", RomList_GameDirInitial, RomList_GameDirSelected, RomList_GameDirUseSelected, RomList_GameDir)); AddHandler(RomList_GameDirInitial, new CSettingTypeRelativePath("Game Directory", "")); AddHandler(RomList_GameDirSelected, new CSettingTypeApplication("Game Directory", "Directory", RomList_GameDirInitial)); AddHandler(RomList_GameDirUseSelected, new CSettingTypeApplication("Game Directory", "Use Selected", false)); AddHandler(RomList_GameDirRecursive, new CSettingTypeApplication("Game Directory", "Recursive", false)); - AddHandler(RomList_7zipCache, new CSettingTypeApplicationPath("", "7zipCache", RomList_7zipCacheDefault)); + AddHandler(RomList_7zipCache, new CSettingTypeApplicationPath("Settings", "7zipCache", RomList_7zipCacheDefault)); AddHandler(RomList_7zipCacheDefault, new CSettingTypeRelativePath("Config", "Project64.zcache")); AddHandler(GameRunning_LoadingInProgress, new CSettingTypeTempBool(false)); @@ -313,8 +313,8 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(GameRunning_ScreenHertz, new CSettingTypeTempNumber(60)); AddHandler(GameRunning_InReset, new CSettingTypeTempBool(false)); - AddHandler(UserInterface_BasicMode, new CSettingTypeApplication("", "Basic Mode", (uint32_t)true)); - AddHandler(File_DiskIPLPath, new CSettingTypeApplicationPath("", "Disk IPL ROM Path", Default_None)); + AddHandler(UserInterface_BasicMode, new CSettingTypeApplication("Settings", "Basic Mode", (uint32_t)true)); + AddHandler(File_DiskIPLPath, new CSettingTypeApplicationPath("Settings", "Disk IPL ROM Path", Default_None)); AddHandler(Debugger_Enabled, new CSettingTypeApplication("Debugger", "Debugger", false)); AddHandler(Debugger_ShowTLBMisses, new CSettingTypeApplication("Debugger", "Show TLB Misses", false)); From 5f39f3d12248066b9b0aa1b4373e033116479ded Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 26 Nov 2018 23:03:27 +1030 Subject: [PATCH 19/32] [Project64] Fix bug in CSettingTypeRomDatabase::Load and some code clean up --- Config/Project64.cfg.development | 2 +- .../SettingType/SettingsType-Application.cpp | 36 +++++++++---------- .../SettingType/SettingsType-RomDatabase.cpp | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Config/Project64.cfg.development b/Config/Project64.cfg.development index abb071316..073f76d99 100644 --- a/Config/Project64.cfg.development +++ b/Config/Project64.cfg.development @@ -1,4 +1,4 @@ -[default] +[Settings] 7zipCache=..\..\Config\Project64.zcache AudioRDB=..\..\Config\Audio.rdb Auto Sleep=0 diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp index e647091fc..5db127ffe 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp @@ -25,32 +25,32 @@ CSettingTypeApplication::CSettingTypeApplication(const char * Section, const cha } CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, bool DefaultValue) : -m_DefaultStr(""), -m_DefaultValue(DefaultValue), -m_DefaultSetting(Default_Constant), -m_Section(FixSectionName(Section)), -m_KeyName(Name), -m_KeyNameIdex(m_KeyName) + m_DefaultStr(""), + m_DefaultValue(DefaultValue), + m_DefaultSetting(Default_Constant), + m_Section(FixSectionName(Section)), + m_KeyName(Name), + m_KeyNameIdex(m_KeyName) { } CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, const char * DefaultValue) : -m_DefaultStr(DefaultValue), -m_DefaultValue(0), -m_DefaultSetting(Default_Constant), -m_Section(FixSectionName(Section)), -m_KeyName(Name), -m_KeyNameIdex(m_KeyName) + m_DefaultStr(DefaultValue), + m_DefaultValue(0), + m_DefaultSetting(Default_Constant), + m_Section(FixSectionName(Section)), + m_KeyName(Name), + m_KeyNameIdex(m_KeyName) { } CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, SettingID DefaultSetting) : -m_DefaultStr(""), -m_DefaultValue(0), -m_DefaultSetting(DefaultSetting), -m_Section(FixSectionName(Section)), -m_KeyName(Name), -m_KeyNameIdex(m_KeyName) + m_DefaultStr(""), + m_DefaultValue(0), + m_DefaultSetting(DefaultSetting), + m_Section(FixSectionName(Section)), + m_KeyName(Name), + m_KeyNameIdex(m_KeyName) { } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp index 7a5fbe124..8df9dafa4 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp @@ -159,7 +159,7 @@ bool CSettingTypeRomDatabase::Load(uint32_t Index, bool & Value) const if (Load(temp_value)) { Value = temp_value != 0; - true; + return true; } LoadDefault(Index, Value); return false; From 9535641b7a33d252d524de435383d1e140bfa0e1 Mon Sep 17 00:00:00 2001 From: Frank-74 Date: Mon, 26 Nov 2018 22:39:56 +0000 Subject: [PATCH 20/32] Get Fixed Audio from audio rdb --- Source/Project64-core/Settings.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Project64-core/Settings.cpp b/Source/Project64-core/Settings.cpp index 7b6a3d539..25b2efd54 100644 --- a/Source/Project64-core/Settings.cpp +++ b/Source/Project64-core/Settings.cpp @@ -136,7 +136,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Default_CounterFactor, new CSettingTypeApplication("Defaults", "Counter Factor", 2u)); AddHandler(Default_32Bit, new CSettingTypeApplication("Defaults", "32bit", true)); AddHandler(Default_SyncViaAudio, new CSettingTypeApplication("Defaults", "Audio-Sync Audio", true)); - AddHandler(Default_FixedAudio, new CSettingTypeApplication("Defaults", "Fixed Audio", true)); + AddHandler(Default_FixedAudio, new CSettingTypeApplication("Defaults", "Audio-Fixed Audio", true)); AddHandler(Rdb_GoodName, new CSettingTypeRomDatabase("Good Name", Game_GameName)); AddHandler(Rdb_SaveChip, new CSettingTypeRDBSaveChip("Save Type", (uint32_t)SaveChip_Auto)); @@ -152,7 +152,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Rdb_DelaySi, new CSettingTypeRDBYesNo("Delay SI", false)); AddHandler(Rdb_32Bit, new CSettingTypeRDBYesNo("32bit", Default_32Bit)); AddHandler(Rdb_FastSP, new CSettingTypeRDBYesNo("Fast SP", true)); - AddHandler(Rdb_FixedAudio, new CSettingTypeRomDatabase("Fixed Audio", Default_FixedAudio)); + AddHandler(Rdb_FixedAudio, new CSettingTypeRomDatabase("Audio-Fixed Audio", Default_FixedAudio)); AddHandler(Rdb_SyncViaAudio, new CSettingTypeRomDatabase("Audio-Sync Audio", Default_SyncViaAudio)); AddHandler(Rdb_RspAudioSignal, new CSettingTypeRDBYesNo("Audio Signal", false)); AddHandler(Rdb_TLB_VAddrStart, new CSettingTypeRomDatabase("TLB: Vaddr Start", (uint32_t)0)); @@ -1311,4 +1311,4 @@ void CSettings::UnregisterChangeCB(SettingID Type, void * Data, SettingChangedFu { g_Notify->BreakPoint(__FILE__, __LINE__); } -} \ No newline at end of file +} From 4d88a0d9b507af46d91228c23cd596f93a232129 Mon Sep 17 00:00:00 2001 From: Frank-74 Date: Mon, 26 Nov 2018 22:51:47 +0000 Subject: [PATCH 21/32] Fixed Audio from Audio.rdb --- Source/Project64-audio/AudioSettings.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Project64-audio/AudioSettings.cpp b/Source/Project64-audio/AudioSettings.cpp index 0d05f9721..a2ac8c26a 100644 --- a/Source/Project64-audio/AudioSettings.cpp +++ b/Source/Project64-audio/AudioSettings.cpp @@ -17,6 +17,7 @@ CSettings * g_settings = NULL; CSettings::CSettings() : m_Set_EnableAudio(0), + m_Set_FixedAudio(0), m_Set_SyncAudio(0), m_Set_FullSpeed(0), m_Set_LimitFPS(0), @@ -31,6 +32,7 @@ CSettings::CSettings() : m_Volume(100), m_TinyBuffer(true), m_FPSBuffer(true), + m_FixedAudio(false), m_SyncAudio(false), m_FullSpeed(true) { @@ -42,6 +44,7 @@ CSettings::CSettings() : if (m_Set_basic_mode != 0) { SettingsRegisterChange(true, m_Set_basic_mode, this, stSettingsChanged); } if (m_Set_debugger != 0) { SettingsRegisterChange(true, m_Set_debugger, this, stSettingsChanged); } if (m_Set_log_flush != 0) { SettingsRegisterChange(true, m_Set_log_flush, this, stSettingsChanged); } + if (m_Set_FixedAudio != 0) { SettingsRegisterChange(true, m_Set_FixedAudio, this, stSettingsChanged); } if (m_Set_SyncAudio != 0) { SettingsRegisterChange(true, m_Set_SyncAudio, this, stSettingsChanged); } if (m_Set_FullSpeed != 0) { SettingsRegisterChange(true, m_Set_FullSpeed, this, stSettingsChanged); } if (m_Set_LimitFPS != 0) { SettingsRegisterChange(true, m_Set_LimitFPS, this, stSettingsChanged); } @@ -61,6 +64,7 @@ CSettings::~CSettings() if (m_Set_basic_mode != 0) { SettingsUnregisterChange(true, m_Set_basic_mode, this, stSettingsChanged); } if (m_Set_debugger != 0) { SettingsUnregisterChange(true, m_Set_debugger, this, stSettingsChanged); } if (m_Set_log_flush != 0) { SettingsUnregisterChange(true, m_Set_log_flush, this, stSettingsChanged); } + if (m_Set_FixedAudio != 0) { SettingsUnregisterChange(true, m_Set_FixedAudio, this, stSettingsChanged); } if (m_Set_SyncAudio != 0) { SettingsUnregisterChange(true, m_Set_SyncAudio, this, stSettingsChanged); } if (m_Set_FullSpeed != 0) { SettingsUnregisterChange(true, m_Set_FullSpeed, this, stSettingsChanged); } if (m_Set_LimitFPS != 0) { SettingsUnregisterChange(true, m_Set_LimitFPS, this, stSettingsChanged); } @@ -78,6 +82,7 @@ void CSettings::RegisterSettings(void) { SetModuleName("default"); m_Set_EnableAudio = FindSystemSettingId("Enable Audio"); + m_Set_FixedAudio = FindSystemSettingId("Fixed Audio"); m_Set_SyncAudio = FindSystemSettingId("Sync Audio"); m_Set_FullSpeed = FindSystemSettingId("Full Speed"); m_Set_LimitFPS = FindSystemSettingId("Limit FPS"); From 6a12fe96e44f9968f78db10b312b013fc7982fa4 Mon Sep 17 00:00:00 2001 From: Frank-74 Date: Mon, 26 Nov 2018 22:53:55 +0000 Subject: [PATCH 22/32] Fixed Audio from Audio.rdb --- Source/Project64-audio/AudioSettings.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Project64-audio/AudioSettings.h b/Source/Project64-audio/AudioSettings.h index 1632c3e65..2e3d254f5 100644 --- a/Source/Project64-audio/AudioSettings.h +++ b/Source/Project64-audio/AudioSettings.h @@ -46,6 +46,7 @@ private: void LogLevelChanged(void); short m_Set_EnableAudio; + short m_Set_FixedAudio; short m_Set_SyncAudio; short m_Set_FullSpeed; short m_Set_LimitFPS; @@ -61,6 +62,7 @@ private: uint32_t m_Volume; bool m_TinyBuffer; bool m_FPSBuffer; + bool m_FixedAudio; bool m_SyncAudio; bool m_FullSpeed; }; From d2b22ce45aa3c63d234c41cf546a91aeac337034 Mon Sep 17 00:00:00 2001 From: Frank-74 Date: Mon, 26 Nov 2018 22:56:14 +0000 Subject: [PATCH 23/32] Update Audio.rdb --- Config/Audio.rdb | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/Config/Audio.rdb b/Config/Audio.rdb index c06ae045b..a47333dde 100644 --- a/Config/Audio.rdb +++ b/Config/Audio.rdb @@ -1,4 +1,65 @@ // ============ Audio RDB for Project64 ==================================== +[5326696F-FE9A99C3-C:45] +FPSBuffer=0 +Fixed Audio=0 +Good Name=Body Harvest (U) + +[07861842-A12EBC9F-C:45] +Fixed Audio=0 +Good Name=Excitebike 64 (U) (V1.0) +Sync Audio=0 + +[776646F6-06B9AC2B-C:50] +Fixed Audio=0 +Good Name=F-ZERO X (E) + +[4D3E622E-9B828B4E-C:4A] +Fixed Audio=0 +Good Name=F-ZERO X (J) + +[B30ED978-3003C9F9-C:45] +Fixed Audio=0 +Good Name=F-ZERO X (U) + +[BBFDEC37-D93B9EC0-C:4A] +Fixed Audio=0 +Good Name=F-ZERO X + Expansion Kit (J) [CART HACK] + +[C6E39C0A-D2726676-C:45] +Fixed Audio=0 +Good Name=F-ZERO X + Expansion Kit (U) [CART HACK] + [AA18B1A5-07DB6AEB-C:45] Good Name=Resident Evil 2 (U) (V1.1) Sync Audio=0 + +[9510D8D7-35100DD2-C:45] +Fixed Audio=0 +Good Name=Stunt Racer 64 (U) +Sync Audio=0 + +[7F43E701-536328D1-C:50] +Good Name=Top Gear Rally (E) +Sync Audio=0 + +[62269B3D-FE11B1E8-C:45] +Good Name=Top Gear Rally (U) +Sync Audio=0 + +[AC062778-DFADFCB8-C:50] +Fixed Audio=0 +Good Name=World Driver Championship (E) (M5) +Sync Audio=0 + +[308DFEC8-CE2EB5F6-C:45] +Fixed Audio=0 +Good Name=World Driver Championship (U) +Sync Audio=0 + +[00000000-00000000-C:4A] +Fixed Audio=0 +Good Name=64DD IPL (JPN) + +[00000000-00000000-C:45] +Fixed Audio=0 +Good Name=64DD IPL (USA) From 1d93bed18f42fef4bbcb3daa21e91c8fc9ef2208 Mon Sep 17 00:00:00 2001 From: Frank-74 Date: Mon, 26 Nov 2018 23:04:58 +0000 Subject: [PATCH 24/32] Update Project64.rdb --- Config/Project64.rdb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Config/Project64.rdb b/Config/Project64.rdb index ffbda9974..0551d1889 100644 --- a/Config/Project64.rdb +++ b/Config/Project64.rdb @@ -1850,7 +1850,6 @@ Status=Compatible Plugin Note=[Glide64] missing menu effects 32bit=No Culling=1 -Fixed Audio=0 [B30ED978-3003C9F9-C:45] Good Name=F-ZERO X (U) @@ -5562,7 +5561,6 @@ Plugin Note=[video] HLE not supported [audio] needs audio plugin 32bit=No AudioResetOnLoad=Yes HLE GFX=No -Fixed Audio=0 RDRAM Size=8 RSP-Mfc0Count=10 @@ -6871,7 +6869,6 @@ Status=Issues (plugin) Plugin Note=[video] HLE not supported [audio] needs audio plugin 32bit=No AudioResetOnLoad=Yes -Fixed Audio=0 HLE GFX=No RSP-Mfc0Count=10 @@ -6882,7 +6879,6 @@ Status=Issues (plugin) Plugin Note=[video] HLE not supported [audio] needs audio plugin 32bit=No AudioResetOnLoad=Yes -Fixed Audio=0 HLE GFX=No RSP-Mfc0Count=10 @@ -8207,14 +8203,12 @@ Status=Unsupported [00000000-00000000-C:4A] 32bit=No -Fixed Audio=0 Good Name=64DD IPL (JPN) RDRAM Size=8 Status=Compatible [00000000-00000000-C:45] 32bit=No -Fixed Audio=0 Good Name=64DD IPL (USA) RDRAM Size=8 Status=Compatible From b957cac73df99726d2bf4c38316c3d842753de87 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 2 Dec 2018 15:01:54 +1030 Subject: [PATCH 25/32] [Project64] Remove parameter to CSettingTypeApplication::Initialize --- Source/Project64-core/Settings.cpp | 2 +- .../SettingType/SettingsType-Application.cpp | 42 +++++++++---------- .../SettingType/SettingsType-Application.h | 2 +- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Source/Project64-core/Settings.cpp b/Source/Project64-core/Settings.cpp index 25b2efd54..6cc7e1d57 100644 --- a/Source/Project64-core/Settings.cpp +++ b/Source/Project64-core/Settings.cpp @@ -654,7 +654,7 @@ bool CSettings::Initialize(const char * BaseDirectory, const char * AppName) { WriteTrace(TraceAppInit, TraceDebug, "Start"); AddHowToHandleSetting(BaseDirectory); - CSettingTypeApplication::Initialize(AppName); + CSettingTypeApplication::Initialize(); CSettingTypeRomDatabase::Initialize(); CSettingTypeGame::Initialize(); CSettingTypeCheats::Initialize(); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp index 5db127ffe..253addfa0 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp @@ -25,32 +25,32 @@ CSettingTypeApplication::CSettingTypeApplication(const char * Section, const cha } CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, bool DefaultValue) : - m_DefaultStr(""), - m_DefaultValue(DefaultValue), - m_DefaultSetting(Default_Constant), - m_Section(FixSectionName(Section)), - m_KeyName(Name), - m_KeyNameIdex(m_KeyName) + m_DefaultStr(""), + m_DefaultValue(DefaultValue), + m_DefaultSetting(Default_Constant), + m_Section(FixSectionName(Section)), + m_KeyName(Name), + m_KeyNameIdex(m_KeyName) { } CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, const char * DefaultValue) : - m_DefaultStr(DefaultValue), - m_DefaultValue(0), - m_DefaultSetting(Default_Constant), - m_Section(FixSectionName(Section)), - m_KeyName(Name), - m_KeyNameIdex(m_KeyName) + m_DefaultStr(DefaultValue), + m_DefaultValue(0), + m_DefaultSetting(Default_Constant), + m_Section(FixSectionName(Section)), + m_KeyName(Name), + m_KeyNameIdex(m_KeyName) { } CSettingTypeApplication::CSettingTypeApplication(const char * Section, const char * Name, SettingID DefaultSetting) : - m_DefaultStr(""), - m_DefaultValue(0), - m_DefaultSetting(DefaultSetting), - m_Section(FixSectionName(Section)), - m_KeyName(Name), - m_KeyNameIdex(m_KeyName) + m_DefaultStr(""), + m_DefaultValue(0), + m_DefaultSetting(DefaultSetting), + m_Section(FixSectionName(Section)), + m_KeyName(Name), + m_KeyNameIdex(m_KeyName) { } @@ -63,7 +63,7 @@ bool CSettingTypeApplication::IsSettingSet(void) const return m_SettingsIniFile ? m_SettingsIniFile->EntryExists(SectionName(), m_KeyNameIdex.c_str()) : false; } -void CSettingTypeApplication::Initialize(const char * /*AppName*/) +void CSettingTypeApplication::Initialize(void) { WriteTrace(TraceAppInit, TraceDebug, "Start"); CPath BaseDir(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(), ""); @@ -92,9 +92,7 @@ void CSettingTypeApplication::Initialize(const char * /*AppName*/) delete m_SettingsIniFile; } CPath SettingPath(SettingsFile.c_str()); -#ifdef _WIN32 - SettingPath.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); -#endif + SettingPath.NormalizePath(BaseDir); if (!SettingPath.DirectoryExists()) { SettingPath.DirectoryCreate(); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Application.h b/Source/Project64-core/Settings/SettingType/SettingsType-Application.h index 75233dc2e..8cf5c8096 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-Application.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-Application.h @@ -47,7 +47,7 @@ public: virtual void Delete(uint32_t Index); // Initialize this class to use ini or registry - static void Initialize(const char * AppName); + static void Initialize(void); static void CleanUp(void); static void Flush(void); static void ResetAll(void); From 9e35a1afc3b490ffb729c53980ef1164bdf31ae6 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 2 Dec 2018 15:06:37 +1030 Subject: [PATCH 26/32] [Audio] Set timer resolution to 0.5ms --- Source/Project64-audio/AudioMain.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Source/Project64-audio/AudioMain.cpp b/Source/Project64-audio/AudioMain.cpp index f0b1b8658..c9b1fbfd1 100644 --- a/Source/Project64-audio/AudioMain.cpp +++ b/Source/Project64-audio/AudioMain.cpp @@ -29,6 +29,10 @@ #include "ConfigUI.h" #include "SettingsID.h" +#ifdef _WIN32 +void SetTimerResolution ( void ); +#endif + /* Read header for type definition */ AUDIO_INFO g_AudioInfo; @@ -51,6 +55,9 @@ void PluginInit(void) SetupTrace(); SetupAudioSettings(); StartTrace(); +#ifdef _WIN32 + SetTimerResolution(); +#endif g_PluginInit = true; } @@ -267,3 +274,17 @@ extern "C" void UseUnregisteredSetting(int /*SettingID*/) DebugBreak(); #endif } + +#ifdef _WIN32 +void SetTimerResolution(void) +{ + HMODULE hMod = GetModuleHandle("ntdll.dll"); + if (hMod != NULL) + { + typedef LONG(NTAPI* tNtSetTimerResolution)(IN ULONG DesiredResolution, IN BOOLEAN SetResolution, OUT PULONG CurrentResolution); + tNtSetTimerResolution NtSetTimerResolution = (tNtSetTimerResolution)GetProcAddress(hMod, "NtSetTimerResolution"); + ULONG CurrentResolution = 0; + NtSetTimerResolution(5000, TRUE, &CurrentResolution); + } +} +#endif From bb5f8ea4f03257959bbd38f3fb3009d246a16617 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 2 Dec 2018 15:11:27 +1030 Subject: [PATCH 27/32] [Project64] Make Project64-Video default plugin --- Source/Project64-core/Settings.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Project64-core/Settings.cpp b/Source/Project64-core/Settings.cpp index 6cc7e1d57..c24aac10f 100644 --- a/Source/Project64-core/Settings.cpp +++ b/Source/Project64-core/Settings.cpp @@ -362,11 +362,12 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) //Plugin #ifdef _WIN32 AddHandler(Plugin_RSP_Current, new CSettingTypeApplication("Plugin", "RSP Dll", "RSP\\RSP 1.7.dll")); - AddHandler(Plugin_GFX_Current, new CSettingTypeApplication("Plugin", "Graphics Dll", "GFX\\Jabo_Direct3D8.dll")); #ifdef _DEBUG - AddHandler(Plugin_AUDIO_Current, new CSettingTypeApplication("Plugin", "Audio Dll", "Audio\\Project64-Audio_d.dll")); + AddHandler(Plugin_GFX_Current, new CSettingTypeApplication("Plugin", "Graphics Dll", "GFX\\Project64-Video_d.dll")); + AddHandler(Plugin_AUDIO_Current, new CSettingTypeApplication("Plugin", "Audio Dll", "Audio\\Project64-Audio_d.dll")); #else - AddHandler(Plugin_AUDIO_Current, new CSettingTypeApplication("Plugin", "Audio Dll", "Audio\\Project64-Audio.dll")); + AddHandler(Plugin_GFX_Current, new CSettingTypeApplication("Plugin", "Graphics Dll", "GFX\\Project64-Video.dll")); + AddHandler(Plugin_AUDIO_Current, new CSettingTypeApplication("Plugin", "Audio Dll", "Audio\\Project64-Audio.dll")); #endif AddHandler(Plugin_CONT_Current, new CSettingTypeApplication("Plugin", "Controller Dll", "Input\\PJ64_NRage.dll")); #else From 6a8405f7edb52b9bde657edd259846cbd1d81dcd Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 2 Dec 2018 16:00:56 +1030 Subject: [PATCH 28/32] [Project64]Add option to not show VI/s and make it default --- Source/Project64-core/Multilanguage.h | 1 + Source/Project64-core/Multilanguage/LanguageClass.cpp | 3 ++- Source/Project64-core/N64System/N64Types.h | 2 +- Source/Project64-core/Settings.cpp | 2 +- .../UserInterface/Settings/SettingsPage-AdvancedOptions.cpp | 5 +++-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/Project64-core/Multilanguage.h b/Source/Project64-core/Multilanguage.h index f0abd0b8b..ae1b5e80e 100644 --- a/Source/Project64-core/Multilanguage.h +++ b/Source/Project64-core/Multilanguage.h @@ -386,6 +386,7 @@ enum LanguageStringID STR_FR_DLS = 701, STR_FR_PERCENT = 702, STR_FR_DLS_VIS = 703, + STR_FR_NONE = 704, // Increase speed STR_INSREASE_SPEED = 710, diff --git a/Source/Project64-core/Multilanguage/LanguageClass.cpp b/Source/Project64-core/Multilanguage/LanguageClass.cpp index 297576bca..05f871a77 100644 --- a/Source/Project64-core/Multilanguage/LanguageClass.cpp +++ b/Source/Project64-core/Multilanguage/LanguageClass.cpp @@ -353,7 +353,8 @@ void CLanguage::LoadDefaultStrings(void) DEF_STR(STR_FR_VIS, "Vertical interrupts per second"); DEF_STR(STR_FR_DLS, "Display lists per second"); DEF_STR(STR_FR_PERCENT, "Percentage of full speed"); - DEF_STR(STR_FR_DLS_VIS, "VI/s & DL/s"); + DEF_STR(STR_FR_DLS_VIS, "VI/s & DL/s"); + DEF_STR(STR_FR_NONE, "None"); // Increase speed DEF_STR(STR_INSREASE_SPEED, "Increase Game Speed"); diff --git a/Source/Project64-core/N64System/N64Types.h b/Source/Project64-core/N64System/N64Types.h index 204c9adab..0a4d80bf2 100644 --- a/Source/Project64-core/N64System/N64Types.h +++ b/Source/Project64-core/N64System/N64Types.h @@ -45,7 +45,7 @@ enum CPU_TYPE enum FRAMERATE_TYPE { - FR_VIs = 0, FR_DLs = 1, FR_PERCENT = 2, FR_VIs_DLs = 3, + FR_VIs = 0, FR_DLs = 1, FR_PERCENT = 2, FR_VIs_DLs = 3, FR_None = 4, }; enum SAVE_CHIP_TYPE diff --git a/Source/Project64-core/Settings.cpp b/Source/Project64-core/Settings.cpp index c24aac10f..dd61177a8 100644 --- a/Source/Project64-core/Settings.cpp +++ b/Source/Project64-core/Settings.cpp @@ -245,7 +245,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) #else AddHandler(UserInterface_DisplayFrameRate, new CSettingTypeApplication("Settings", "Display Frame Rate", (uint32_t)true)); #endif - AddHandler(UserInterface_FrameDisplayType, new CSettingTypeApplication("Settings", "Frame Rate Display Type", (uint32_t)FR_VIs)); + AddHandler(UserInterface_FrameDisplayType, new CSettingTypeApplication("Settings", "Frame Rate Display Type", (uint32_t)FR_None)); AddHandler(Directory_Plugin, new CSettingTypeSelectedDirectory("Dir:Plugin", Directory_PluginInitial, Directory_PluginSelected, Directory_PluginUseSelected, Directory_Plugin)); #ifndef _M_X64 AddHandler(Directory_PluginInitial, new CSettingTypeRelativePath("Plugin", "")); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.cpp index a99b2d375..f2085be65 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.cpp @@ -45,8 +45,9 @@ CAdvancedOptionsPage::CAdvancedOptionsPage(HWND hParent, const RECT & rcDispay) ComboBox->AddItemW(wGS(STR_FR_VIS).c_str(), FR_VIs); ComboBox->AddItemW(wGS(STR_FR_DLS).c_str(), FR_DLs); ComboBox->AddItemW(wGS(STR_FR_PERCENT).c_str(), FR_PERCENT); - ComboBox->AddItemW(wGS(STR_FR_DLS_VIS).c_str(), FR_VIs_DLs); - } + ComboBox->AddItemW(wGS(STR_FR_DLS_VIS).c_str(), FR_VIs_DLs); + ComboBox->AddItemW(wGS(STR_FR_NONE).c_str(), FR_None); + } m_IplDir.Attach(GetDlgItem(IDC_IPL_DIR)); From 1acf6410100a1467c98d0a941b33673379e5abdb Mon Sep 17 00:00:00 2001 From: Frank-74 Date: Sun, 2 Dec 2018 22:08:44 +0000 Subject: [PATCH 29/32] [Audio] Fix Body Harvest audio and framerate More precise framerate fixes Body Harvest (U) audio clicks and slow framerate, with Sync using audio OFF or ON. --- Source/Project64-audio/AudioMain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Project64-audio/AudioMain.cpp b/Source/Project64-audio/AudioMain.cpp index c9b1fbfd1..34eeb5dba 100644 --- a/Source/Project64-audio/AudioMain.cpp +++ b/Source/Project64-audio/AudioMain.cpp @@ -110,8 +110,8 @@ EXPORT void CALL AiDacrateChanged(int SystemType) } else { - framerate = 64; - if (SystemType == SYSTEM_PAL) { framerate = 53.33333; } + framerate = 60.95; // Needed for Body Harvest (U) + if (SystemType == SYSTEM_PAL) { framerate = 50.79166; } } if (g_settings->TinyBuffer() == true) { From 0e24ea1ca99a1f9d8096d04ec7da888e382a7d0b Mon Sep 17 00:00:00 2001 From: Frank-74 Date: Tue, 4 Dec 2018 03:54:44 +0000 Subject: [PATCH 30/32] [Audio] Code cleanup and slightly smaller buffer. --- Source/Project64-audio/AudioMain.cpp | 31 +++++++++------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/Source/Project64-audio/AudioMain.cpp b/Source/Project64-audio/AudioMain.cpp index 34eeb5dba..a62b5d11e 100644 --- a/Source/Project64-audio/AudioMain.cpp +++ b/Source/Project64-audio/AudioMain.cpp @@ -85,14 +85,15 @@ EXPORT void CALL AiDacrateChanged(int SystemType) WriteTrace(TraceAudioInterface, TraceNotice, "Unknown/reserved bits in AI_DACRATE_REG set. 0x%08X", *g_AudioInfo.AI_DACRATE_REG); } - uint32_t video_clock = 0; + uint32_t video_clock = 0; int32_t BufferSize = 0; double audio_clock = 0; double framerate = 29.97; + switch (SystemType) { case SYSTEM_NTSC: video_clock = 48681812; break; - case SYSTEM_PAL: video_clock = 49656530; break; + case SYSTEM_PAL: video_clock = 49656530; framerate = 25; break; case SYSTEM_MPAL: video_clock = 48628316; break; } - uint32_t Frequency = video_clock / (g_Dacrate + 1); + uint32_t Frequency = (video_clock / (g_Dacrate + 1)); if (Frequency < 4000) { @@ -101,28 +102,16 @@ EXPORT void CALL AiDacrateChanged(int SystemType) } else { - int32_t BufferSize = 0; double audio_clock = 0; double framerate = 0; - - if (g_settings->FPSBuffer() == true) + if (g_settings->FPSBuffer() == false && SystemType != SYSTEM_PAL) { - framerate = 59.94004; - if (SystemType == SYSTEM_PAL) { framerate = 50; } + framerate = 30.475; // Needed for Body Harvest (U) } - else + if (g_settings->TinyBuffer() == false) { - framerate = 60.95; // Needed for Body Harvest (U) - if (SystemType == SYSTEM_PAL) { framerate = 50.79166; } + framerate = (framerate / 2); } - if (g_settings->TinyBuffer() == true) - { - audio_clock = ((video_clock / framerate) * 2); - } - else - { - audio_clock = ((video_clock / framerate) * 4); - } - - BufferSize = (int32_t)audio_clock / (g_Dacrate) + 1 & ~0x1; + audio_clock = (video_clock / framerate); + BufferSize = (int32_t)(audio_clock / (g_Dacrate + 1)) & ~0x1; g_SoundDriver->AI_SetFrequency(Frequency, BufferSize); } } From af6c354efc1b24c5dc83183525d3d0fff0c98535 Mon Sep 17 00:00:00 2001 From: Frank-74 Date: Tue, 4 Dec 2018 05:14:35 +0000 Subject: [PATCH 31/32] [Audio] 30 / 1.001 is the exact NTSC fps 30 / 1.001 = 29.97002997002997002997002997003 --- Source/Project64-audio/AudioMain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Project64-audio/AudioMain.cpp b/Source/Project64-audio/AudioMain.cpp index a62b5d11e..53bd31467 100644 --- a/Source/Project64-audio/AudioMain.cpp +++ b/Source/Project64-audio/AudioMain.cpp @@ -85,7 +85,8 @@ EXPORT void CALL AiDacrateChanged(int SystemType) WriteTrace(TraceAudioInterface, TraceNotice, "Unknown/reserved bits in AI_DACRATE_REG set. 0x%08X", *g_AudioInfo.AI_DACRATE_REG); } - uint32_t video_clock = 0; int32_t BufferSize = 0; double audio_clock = 0; double framerate = 29.97; + uint32_t video_clock = 0; int32_t BufferSize = 0; + double audio_clock = 0; double framerate = (30 / 1.001); switch (SystemType) { From 9936933f6849dea47151334e5aa47b64357c217e Mon Sep 17 00:00:00 2001 From: Frank-74 Date: Tue, 4 Dec 2018 06:32:31 +0000 Subject: [PATCH 32/32] [Audio] Fix typo in buffersize It caused clicks in goldeneye / pd without +1. --- Source/Project64-audio/AudioMain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Project64-audio/AudioMain.cpp b/Source/Project64-audio/AudioMain.cpp index 53bd31467..7bfb4036c 100644 --- a/Source/Project64-audio/AudioMain.cpp +++ b/Source/Project64-audio/AudioMain.cpp @@ -112,7 +112,7 @@ EXPORT void CALL AiDacrateChanged(int SystemType) framerate = (framerate / 2); } audio_clock = (video_clock / framerate); - BufferSize = (int32_t)(audio_clock / (g_Dacrate + 1)) & ~0x1; + BufferSize = (int32_t)(audio_clock / (g_Dacrate + 1)) + 1 & ~0x1; g_SoundDriver->AI_SetFrequency(Frequency, BufferSize); } }