diff --git a/Config/Glide64.rdb b/Config/Glide64.rdb
index b2eb8bca0..aa717d550 100644
--- a/Config/Glide64.rdb
+++ b/Config/Glide64.rdb
@@ -263,12 +263,14 @@ Good Name=Akumajou Dracula Mokushiroku - Real Action Adventure (J)
Internal Name=DRACULA MOKUSHIROKU
depthmode=0
fb_clear=1
+old_style_adither=1
[A5533106-B9F25E5B-C:4A]
Good Name=Akumajou Dracula Mokushiroku Gaiden - Legend of Cornell (J)
Internal Name=DRACULA MOKUSHIROKU2
depthmode=0
fb_clear=1
+old_style_adither=1
[D9EDD54D-6BB8E274-C:50]
Good Name=All-Star Baseball '99 (E)
@@ -633,12 +635,14 @@ Good Name=Castlevania - Legacy of Darkness (E) (M3)
Internal Name=CASTLEVANIA2
depthmode=0
fb_clear=1
+old_style_adither=1
[1CC06338-87388926-C:45]
Good Name=Castlevania - Legacy of Darkness (U)
Internal Name=CASTLEVANIA2
depthmode=0
fb_clear=1
+old_style_adither=1
[DCCF2134-9DD63578-C:50]
Good Name=Centre Court Tennis (E)
@@ -2250,6 +2254,7 @@ wrap_big_tex=1
Good Name=Nintama Rantarou 64 Game Gallery (J)
Internal Name=NINTAMAGAMEGALLERY64
depthmode=0
+fb_smart=0
force_microcheck=1
[8A97A197-272DF6C1-C:50]
@@ -2382,6 +2387,20 @@ filtering=1
optimize_texrect=0
useless_is_useless=1
+[EE08C602-6BC2D5A6-C:50]
+Good Name=PGA European Tour (E) (M5)
+Internal Name=PGA European Tour
+buff_clear=0
+fb_read_always=1
+swapmode=0
+
+[B54CE881-BCCB6126-C:45]
+Good Name=PGA European Tour (U)
+Internal Name=PGA European Tour
+buff_clear=0
+fb_read_always=1
+swapmode=0
+
[1AA05AD5-46F52D80-C:50]
Good Name=Pilotwings 64 (E) (M3)
Internal Name=Pilot Wings64
@@ -2745,8 +2764,10 @@ force_quad3d=1
Good Name=Pro Mahjong Tsuwamono 64 - Jansou Battle ni Chousen (J)
Internal Name=TSUWAMONO64
depthmode=0
+fb_smart=0 //disabling FB is a horrible hack
force_microcheck=1
+
//================ Q ================
[16931D74-65DC6D34-C:50]
Good Name=Quake 64 (E)
@@ -3162,7 +3183,7 @@ Good Name=Super Mario 64 (E) (M3)
Internal Name=SUPER MARIO 64
depth_bias=32
depthmode=1
-filtering=1
+filtering=0
lodmode=1
[4EAA3D0E-74757C24-C:4A]
@@ -3170,7 +3191,7 @@ Good Name=Super Mario 64 (J)
Internal Name=SUPER MARIO 64
depth_bias=32
depthmode=1
-filtering=1
+filtering=0
lodmode=1
[635A2BFF-8B022326-C:45]
@@ -3178,7 +3199,7 @@ Good Name=Super Mario 64 (U)
Internal Name=SUPER MARIO 64
depth_bias=32
depthmode=1
-filtering=1
+filtering=0
lodmode=1
[D6FBA4A8-6326AA2C-C:4A]
@@ -3186,7 +3207,7 @@ Good Name=Super Mario 64 - Shindou Edition (J)
Internal Name=SUPERMARIO64
depth_bias=32
depthmode=1
-filtering=1
+filtering=0
lodmode=1
[66572080-28E348E1-C:4A]
@@ -3757,30 +3778,38 @@ depthmode=1
Good Name=Waialae Country Club - True Golf Classics (E) (M4) (V1.0)
Internal Name=Waialae Country Club
depthmode=0
-fb_smart=0
+fb_smart=1
wrap_big_tex=1
[0C5057AD-046E126E-C:50]
Good Name=Waialae Country Club - True Golf Classics (E) (M4) (V1.1)
Internal Name=Waialae Country Club
depthmode=0
-fb_smart=0
+fb_smart=1
wrap_big_tex=1
[8066D58A-C3DECAC1-C:45]
Good Name=Waialae Country Club - True Golf Classics (U) (V1.0)
Internal Name=Waialae Country Club
depthmode=0
-fb_smart=0
+fb_smart=1
wrap_big_tex=1
[DD318CE2-B73798BA-C:45]
Good Name=Waialae Country Club - True Golf Classics (U) (V1.1)
Internal Name=Waialae Country Club
depthmode=0
-fb_smart=0
+fb_smart=1
wrap_big_tex=1
+[D715CC70-271CF5D6-C:50]
+Good Name=War Gods (E)
+filtering=2
+
+[F7FE28F6-C3F2ACC3-C:45]
+Good Name=War Gods (U)
+filtering=2
+
[650EFA96-30DDF9A7-C:50]
Good Name=Wave Race 64 (E) (M2)
Internal Name=WAVE RACE 64
@@ -4000,3 +4029,6 @@ buff_clear=0
force_microcheck=1
swapmode=0
+[37955E65-C6F2B7B3-C:0]
+Good Name=Tamiya Racing 64 (Unreleased)
+force_microcheck=1
diff --git a/Config/Project64.rdb b/Config/Project64.rdb
index 947948476..2397b7d2a 100644
--- a/Config/Project64.rdb
+++ b/Config/Project64.rdb
@@ -2605,6 +2605,7 @@ RDRAM Size=8
RSP-JumpTableSize=3584
SMM-FUNC=0
SMM-PI DMA=0
+SMM-Protect=1
SMM-TLB=0
ViRefresh=1800
@@ -2624,6 +2625,7 @@ RDRAM Size=8
RSP-JumpTableSize=3584
SMM-FUNC=0
SMM-PI DMA=0
+SMM-Protect=1
SMM-TLB=0
ViRefresh=2050
@@ -4085,6 +4087,7 @@ Good Name=Nuclear Strike 64 (E) (M2)
Internal Name=NUCLEARSTRIKE64
Status=Compatible
Core Note=high system requirement
+Linking=Off
RDRAM Size=8
[8F50B845-D729D22F-C:44]
@@ -4092,6 +4095,7 @@ Good Name=Nuclear Strike 64 (G)
Internal Name=NUCLEARSTRIKE64
Status=Compatible
Core Note=high system requirement
+Linking=Off
RDRAM Size=8
[4998DDBB-F7B7AEBC-C:45]
@@ -4099,6 +4103,7 @@ Good Name=Nuclear Strike 64 (U)
Internal Name=NUCLEARSTRIKE64
Status=Compatible
Core Note=high system requirement
+Linking=Off
RDRAM Size=8
[D83BB920-CC406416-C:4A]
diff --git a/Source/3rdParty/7zip/Lzma2Dec.c b/Source/3rdParty/7zip/Lzma2Dec.c
index 7ea1cc953..c7a85c6e8 100644
--- a/Source/3rdParty/7zip/Lzma2Dec.c
+++ b/Source/3rdParty/7zip/Lzma2Dec.c
@@ -65,10 +65,10 @@ static SRes Lzma2Dec_GetOldProps(Byte prop, Byte *props)
return SZ_ERROR_UNSUPPORTED;
dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop);
props[0] = (Byte)LZMA2_LCLP_MAX;
- props[1] = (Byte)(dicSize);
- props[2] = (Byte)(dicSize >> 8);
- props[3] = (Byte)(dicSize >> 16);
- props[4] = (Byte)(dicSize >> 24);
+ props[1] = (Byte)((dicSize)& 0xFF);
+ props[2] = (Byte)((dicSize >> 8) & 0xFF);
+ props[3] = (Byte)((dicSize >> 16) & 0xFF);
+ props[4] = (Byte)((dicSize >> 24) & 0xFF);
return SZ_OK;
}
diff --git a/Source/Common/Common.vcproj b/Source/Common/Common.vcproj
index ff469900a..a4fd7bef7 100644
--- a/Source/Common/Common.vcproj
+++ b/Source/Common/Common.vcproj
@@ -157,6 +157,10 @@
RelativePath=".\path.cpp"
>
+
+
@@ -230,6 +234,10 @@
RelativePath=".\path.h"
>
+
+
@@ -258,6 +266,10 @@
RelativePath=".\TraceDefs.h"
>
+
+
diff --git a/Source/Common/MemoryManagement.cpp b/Source/Common/MemoryManagement.cpp
index a967a79c4..50d2e66dd 100644
--- a/Source/Common/MemoryManagement.cpp
+++ b/Source/Common/MemoryManagement.cpp
@@ -2,38 +2,52 @@
#include
#include "MemoryManagement.h"
-static bool TranslateFromMemProtect ( MEM_PROTECTION memProtection, int & OsMemProtection)
+static bool TranslateFromMemProtect(MEM_PROTECTION memProtection, int & OsMemProtection)
{
- switch (memProtection)
- {
- case MEM_NOACCESS: OsMemProtection = PAGE_NOACCESS; break;
- case MEM_READONLY: OsMemProtection = PAGE_READONLY; break;
- case MEM_READWRITE: OsMemProtection = PAGE_READWRITE; break;
- case MEM_EXECUTE_READWRITE: OsMemProtection = PAGE_EXECUTE_READWRITE; break;
- default:
- return false;
- }
- return true;
+ switch (memProtection)
+ {
+ case MEM_NOACCESS: OsMemProtection = PAGE_NOACCESS; break;
+ case MEM_READONLY: OsMemProtection = PAGE_READONLY; break;
+ case MEM_READWRITE: OsMemProtection = PAGE_READWRITE; break;
+ case MEM_EXECUTE_READWRITE: OsMemProtection = PAGE_EXECUTE_READWRITE; break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+static bool TranslateToMemProtect(int OsMemProtection, MEM_PROTECTION & memProtection)
+{
+ switch (OsMemProtection)
+ {
+ case PAGE_NOACCESS: memProtection = MEM_NOACCESS; break;
+ case PAGE_READONLY: memProtection = MEM_READONLY; break;
+ case PAGE_READWRITE: memProtection = MEM_READWRITE; break;
+ case PAGE_EXECUTE_READWRITE: memProtection = MEM_EXECUTE_READWRITE; break;
+ default:
+ return false;
+ }
+ return true;
}
void* AllocateAddressSpace(size_t size)
{
- return VirtualAlloc(NULL, size, MEM_RESERVE | MEM_TOP_DOWN, PAGE_NOACCESS);
+ return VirtualAlloc(NULL, size, MEM_RESERVE | MEM_TOP_DOWN, PAGE_NOACCESS);
}
bool FreeAddressSpace(void* addr, size_t size)
{
- return VirtualFree(addr, 0, MEM_RELEASE) != 0;
+ return VirtualFree(addr, 0, MEM_RELEASE) != 0;
}
void* CommitMemory(void* addr, size_t size, MEM_PROTECTION memProtection)
{
- int OsMemProtection;
- if (!TranslateFromMemProtect(memProtection,OsMemProtection))
- {
- return NULL;
- }
- return VirtualAlloc(addr, size, MEM_COMMIT, OsMemProtection);
+ int OsMemProtection;
+ if (!TranslateFromMemProtect(memProtection, OsMemProtection))
+ {
+ return NULL;
+ }
+ return VirtualAlloc(addr, size, MEM_COMMIT, OsMemProtection);
}
bool DecommitMemory(void* addr, size_t size)
@@ -43,16 +57,20 @@ bool DecommitMemory(void* addr, size_t size)
bool ProtectMemory(void* addr, size_t size, MEM_PROTECTION memProtection, MEM_PROTECTION * OldProtect)
{
- int OsMemProtection;
- if (!TranslateFromMemProtect(memProtection,OsMemProtection))
- {
- return NULL;
- }
+ int OsMemProtection;
+ if (!TranslateFromMemProtect(memProtection, OsMemProtection))
+ {
+ return NULL;
+ }
- DWORD OldOsProtect;
+ DWORD OldOsProtect;
BOOL res = VirtualProtect(addr, size, OsMemProtection, &OldOsProtect);
- if (OldProtect != NULL)
- {
- }
- return res != 0;
-}
+ if (OldProtect != NULL)
+ {
+ if (!TranslateToMemProtect(OldOsProtect, *OldProtect))
+ {
+ return NULL;
+ }
+ }
+ return res != 0;
+}
\ No newline at end of file
diff --git a/Source/Common/Platform.cpp b/Source/Common/Platform.cpp
index 043294401..26ee3f3e4 100644
--- a/Source/Common/Platform.cpp
+++ b/Source/Common/Platform.cpp
@@ -1,13 +1,28 @@
#include "stdafx.h"
#ifndef _WIN32
-int _vscprintf (const char * format, va_list pargs)
+int _vscprintf(const char * format, va_list pargs)
{
- int retval;
- va_list argcopy;
- va_copy(argcopy, pargs);
- retval = vsnprintf(NULL, 0, format, argcopy);
- va_end(argcopy);
- return retval;
+ int retval;
+ va_list argcopy;
+ va_copy(argcopy, pargs);
+ retval = vsnprintf(NULL, 0, format, argcopy);
+ va_end(argcopy);
+ return retval;
}
-#endif
\ No newline at end of file
+#endif
+
+#ifdef _MSC_VER
+#include
+
+int fesetround(int RoundType)
+{
+ static const unsigned int msRound[4] = { _RC_NEAR, _RC_CHOP, _RC_UP, _RC_DOWN };
+ int32_t res = _controlfp(msRound[RoundType], _MCW_RC);
+ if (res == _RC_NEAR) { return FE_TONEAREST; }
+ if (res == _RC_CHOP) { return FE_TOWARDZERO; }
+ if (res == _RC_UP) { return FE_UPWARD; }
+ if (res == _RC_DOWN) { return FE_DOWNWARD; }
+ return FE_TONEAREST;
+}
+#endif
diff --git a/Source/Common/Platform.h b/Source/Common/Platform.h
index 8fd411564..5757a41b9 100644
--- a/Source/Common/Platform.h
+++ b/Source/Common/Platform.h
@@ -7,8 +7,17 @@
#define _stricmp strcasecmp
#define _strnicmp strncasecmp
#define _snprintf snprintf
+#define _isnan isnan
#define GetCurrentThreadId pthread_self
int _vscprintf (const char * format, va_list pargs);
-#endif
\ No newline at end of file
+#endif
+
+//FPU rounding code
+#ifdef _WIN32
+typedef enum { FE_TONEAREST = 0, FE_TOWARDZERO, FE_UPWARD, FE_DOWNWARD } eRoundType;
+int fesetround(int RoundType);
+#else
+#include
+#endif
diff --git a/Source/Common/StdString.cpp b/Source/Common/StdString.cpp
index bcc3dc824..7f1c19c19 100644
--- a/Source/Common/StdString.cpp
+++ b/Source/Common/StdString.cpp
@@ -4,22 +4,23 @@
#ifdef _WIN32
#include
#endif
+
stdstr::stdstr()
{
}
stdstr::stdstr(const std::string & str) :
-std::string(str)
+ std::string(str)
{
}
stdstr::stdstr(const stdstr & str) :
-std::string((const std::string &)str)
+ std::string((const std::string &)str)
{
}
stdstr::stdstr(const char * str) :
-std::string(str ? str : "")
+ std::string(str ? str : "")
{
}
diff --git a/Source/Common/Util.cpp b/Source/Common/Util.cpp
index b79ca65e1..753041fc3 100644
--- a/Source/Common/Util.cpp
+++ b/Source/Common/Util.cpp
@@ -1,13 +1,61 @@
#include "stdafx.h"
#include "Util.h"
+#ifdef _WIN32
#include
#include
+#else
+#include
+#endif
+
+pjutil::DynLibHandle pjutil::DynLibOpen(const char *pccLibraryPath, bool ShowErrors)
+{
+ if (pccLibraryPath == NULL)
+ {
+ return NULL;
+ }
+ UINT LastErrorMode = SetErrorMode(ShowErrors ? 0 : SEM_FAILCRITICALERRORS);
+ pjutil::DynLibHandle lib = (pjutil::DynLibHandle)LoadLibrary(pccLibraryPath);
+ SetErrorMode(LastErrorMode);
+ return lib;
+}
+
+void * pjutil::DynLibGetProc(pjutil::DynLibHandle LibHandle, const char * ProcedureName)
+{
+ if (ProcedureName == NULL)
+ return NULL;
+
+ return GetProcAddress((HMODULE)LibHandle, ProcedureName);
+}
+
+void pjutil::DynLibClose(pjutil::DynLibHandle LibHandle)
+{
+ FreeLibrary((HMODULE)LibHandle);
+}
+
+#ifdef _WIN32
+static void EmptyThreadFunction(void)
+{
+}
+
+void pjutil::DynLibCallDllMain(void)
+{
+ //jabo had a bug so I call CreateThread so the dllmain in the plugins will get called again with thread attached
+ DWORD ThreadID;
+ HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)EmptyThreadFunction, NULL, 0, &ThreadID);
+ CloseHandle(hthread);
+}
+#endif
void pjutil::Sleep(uint32_t timeout)
{
+#ifdef _WIN32
::Sleep(timeout);
+#else
+ sleep(timeout);
+#endif
}
+#ifdef _WIN32
bool pjutil::TerminatedExistingExe()
{
bool bTerminated = false;
@@ -59,4 +107,5 @@ bool pjutil::TerminatedExistingExe()
CloseHandle(nSearch);
}
return bTerminated;
-}
\ No newline at end of file
+}
+#endif
diff --git a/Source/Common/Util.h b/Source/Common/Util.h
index 4dc0a48a1..eaaf95505 100644
--- a/Source/Common/Util.h
+++ b/Source/Common/Util.h
@@ -4,6 +4,14 @@
class pjutil
{
public:
+ typedef void * DynLibHandle;
+
+ static DynLibHandle DynLibOpen(const char *pccLibraryPath, bool ShowErrors = true);
+ static void * DynLibGetProc(DynLibHandle LibHandle, const char * ProcedureName);
+ static void DynLibClose(DynLibHandle LibHandle);
+#ifdef _WIN32
+ static void DynLibCallDllMain(void);
+#endif
static void Sleep(uint32_t timeout);
static bool TerminatedExistingExe();
diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp
index 5a0541bf9..87a4cb670 100644
--- a/Source/Glide64/Main.cpp
+++ b/Source/Glide64/Main.cpp
@@ -2038,14 +2038,14 @@ void newSwapBuffers()
}
}
//hotkeys
- if (CheckKeyPressed(G64_VK_BACK, 0x0001))
- {
- hotkey_info.hk_filtering = 100;
- if (settings.filtering < 2)
- settings.filtering++;
- else
- settings.filtering = 0;
- }
+ //if (CheckKeyPressed(G64_VK_BACK, 0x0001))
+ //{
+ //hotkey_info.hk_filtering = 100;
+ //if (settings.filtering < 2)
+ //settings.filtering++;
+ //else
+ //settings.filtering = 0;
+ //}
if ((abs((int)(frame_count - curframe)) > 3 ) && CheckKeyPressed(G64_VK_ALT, 0x8000)) //alt +
{
if (CheckKeyPressed(G64_VK_B, 0x8000)) //b
diff --git a/Source/Project64-core/3rdParty/7zip.cpp b/Source/Project64-core/3rdParty/7zip.cpp
index f90092c40..b9b51f95e 100644
--- a/Source/Project64-core/3rdParty/7zip.cpp
+++ b/Source/Project64-core/3rdParty/7zip.cpp
@@ -7,7 +7,7 @@ typedef const char * LPCSTR;
#include "7zip.h"
#include
-C7zip::C7zip (const char * FileName) :
+C7zip::C7zip(const char * FileName) :
m_FileSize(0),
m_CurrentFile(-1),
m_blockIndex(0xFFFFFFFF),
@@ -129,7 +129,7 @@ bool C7zip::GetFile(int index, Byte * Data, size_t DataLen)
char Msg[200];
std::wstring FileName = FileNameIndex(index);
- _snprintf(Msg, sizeof(Msg) / sizeof(Msg[0]), "extracting %s", stdstr().FromUTF16(FileName.c_str()));
+ _snprintf(Msg, sizeof(Msg) / sizeof(Msg[0]), "extracting %s", stdstr().FromUTF16(FileName.c_str()).c_str());
m_NotfyCallback(Msg, m_NotfyCallbackInfo);
SRes res = SzArEx_Extract(m_db, &m_archiveLookStream.s, index,
diff --git a/Source/Project64-core/N64System/FramePerSecondClass.cpp b/Source/Project64-core/N64System/FramePerSecondClass.cpp
index 3f2bd54e6..87c4e79db 100644
--- a/Source/Project64-core/N64System/FramePerSecondClass.cpp
+++ b/Source/Project64-core/N64System/FramePerSecondClass.cpp
@@ -11,7 +11,9 @@
#include "stdafx.h"
#include "FramePerSecondClass.h"
#include
+#ifdef _WIN32
#include
+#endif
CFramePerSecond::CFramePerSecond()
{
@@ -25,9 +27,11 @@ CFramePerSecond::CFramePerSecond()
m_ScreenHertz = 60;
}
+#ifdef _WIN32
LARGE_INTEGER Freq;
QueryPerformanceFrequency(&Freq);
m_Frequency = Freq.QuadPart;
+#endif
Reset(true);
}
@@ -48,7 +52,9 @@ void CFramePerSecond::Reset(bool ClearDisplay)
}
if (ClearDisplay)
{
+#ifdef _WIN32
g_Notify->DisplayMessage2("");
+#endif
return;
}
@@ -60,6 +66,7 @@ void CFramePerSecond::Reset(bool ClearDisplay)
void CFramePerSecond::UpdateViCounter(void)
{
+#ifdef _WIN32
if (m_iFrameRateType != FR_VIs && m_iFrameRateType != FR_PERCENT)
{
return;
@@ -73,10 +80,12 @@ void CFramePerSecond::UpdateViCounter(void)
DisplayViCounter(0);
}
m_CurrentFrame += 1;
+#endif
}
void CFramePerSecond::DisplayViCounter(uint32_t FrameRate)
{
+#ifdef _WIN32
if (m_iFrameRateType == FR_VIs)
{
if (FrameRate != 0)
@@ -87,7 +96,7 @@ void CFramePerSecond::DisplayViCounter(uint32_t FrameRate)
{
if (m_CurrentFrame > (NoOfFrames << 3))
{
- __int64 Total;
+ int64_t Total;
Total = 0;
for (int count = 0; count < NoOfFrames; count++)
@@ -113,7 +122,7 @@ void CFramePerSecond::DisplayViCounter(uint32_t FrameRate)
{
if (m_CurrentFrame > (NoOfFrames << 3))
{
- __int64 Total;
+ int64_t Total;
Total = 0;
for (int count = 0; count < NoOfFrames; count++)
@@ -130,6 +139,7 @@ void CFramePerSecond::DisplayViCounter(uint32_t FrameRate)
}
g_Notify->DisplayMessage2(stdstr_f("%.1f %%", Percent * 100).c_str());
}
+#endif
}
void CFramePerSecond::FrameRateTypeChanged(CFramePerSecond * _this)
@@ -146,6 +156,7 @@ void CFramePerSecond::ScreenHertzChanged(CFramePerSecond * _this)
void CFramePerSecond::UpdateDlCounter(void)
{
+#ifdef _WIN32
if (m_iFrameRateType != FR_DLs)
{
return;
@@ -158,10 +169,12 @@ void CFramePerSecond::UpdateDlCounter(void)
DisplayDlCounter(0);
}
m_CurrentFrame += 1;
+#endif
}
void CFramePerSecond::DisplayDlCounter(uint32_t FrameRate)
{
+#ifdef _WIN32
if (m_iFrameRateType != FR_DLs)
{
return;
@@ -174,7 +187,7 @@ void CFramePerSecond::DisplayDlCounter(uint32_t FrameRate)
{
if (m_CurrentFrame > (NoOfFrames << 2))
{
- __int64 Total;
+ int64_t Total;
Total = 0;
for (int count = 0; count < NoOfFrames; count++)
@@ -188,4 +201,5 @@ void CFramePerSecond::DisplayDlCounter(uint32_t FrameRate)
g_Notify->DisplayMessage2("DL/s: -.--");
}
}
+#endif
}
\ No newline at end of file
diff --git a/Source/Project64-core/N64System/FramePerSecondClass.h b/Source/Project64-core/N64System/FramePerSecondClass.h
index a39a07ece..746be9f7c 100644
--- a/Source/Project64-core/N64System/FramePerSecondClass.h
+++ b/Source/Project64-core/N64System/FramePerSecondClass.h
@@ -24,13 +24,16 @@ public:
void DisplayViCounter(uint32_t FrameRate);
private:
+ CFramePerSecond(const CFramePerSecond&); // Disable copy constructor
+ CFramePerSecond& operator=(const CFramePerSecond&); // Disable assignment
+
static void FrameRateTypeChanged(CFramePerSecond * _this);
static void ScreenHertzChanged(CFramePerSecond * _this);
- int m_iFrameRateType, m_ScreenHertz;
+ int32_t m_iFrameRateType, m_ScreenHertz;
enum { NoOfFrames = 7 };
int64_t m_Frequency, m_Frames[NoOfFrames], m_LastFrame;
- int m_CurrentFrame;
+ int32_t m_CurrentFrame;
};
diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp b/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp
index e297097a2..12c81e95e 100644
--- a/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp
+++ b/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp
@@ -21,6 +21,30 @@
#include
#include
+#if (defined(_MSC_VER) && (_MSC_VER < 1800))
+double round(double num)
+{
+ return (num - floor(num) > 0.5) ? ceil(num) : floor(num);
+}
+
+float roundf(float num)
+{
+ return (num - floorf(num) > 0.5) ? ceilf(num) : floorf(num);
+}
+#endif
+
+#if (defined(_MSC_VER) && (_MSC_VER < 1700))
+double trunc(double num)
+{
+ return (num < 0) ? ceil(num) : floor(num);
+}
+
+float truncf(float num)
+{
+ return (num < 0) ? ceilf(num) : floorf(num);
+}
+#endif
+
void InPermLoop();
void TestInterpreterJump(uint32_t PC, uint32_t TargetPC, int32_t Reg1, int32_t Reg2);
@@ -57,14 +81,12 @@ const int32_t R4300iOp::LWR_SHIFT[4] = { 24, 16, 8, 0 };
m_JumpToLocation = (*_PROGRAM_COUNTER);\
return;
-//#define TEST_COP1_USABLE_EXCEPTION
#define TEST_COP1_USABLE_EXCEPTION() \
if ((g_Reg->STATUS_REGISTER & STATUS_CU1) == 0) {\
g_Reg->DoCopUnusableException(m_NextInstruction == JUMP,1);\
m_NextInstruction = JUMP;\
m_JumpToLocation = (*_PROGRAM_COUNTER);\
- return;\
- }
+ return;}\
#define TLB_READ_EXCEPTION(Address) \
g_Reg->DoTLBReadMiss(m_NextInstruction == JUMP,Address);\
@@ -104,13 +126,13 @@ void R4300iOp::COP1_BC()
void R4300iOp::COP1_S()
{
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
Jump_CoP1_S[m_Opcode.funct]();
}
void R4300iOp::COP1_D()
{
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
Jump_CoP1_D[m_Opcode.funct]();
}
@@ -2255,15 +2277,15 @@ void R4300iOp::COP1_DMF()
void R4300iOp::COP1_CF()
{
TEST_COP1_USABLE_EXCEPTION();
- if (m_Opcode.fs != 31 && m_Opcode.fs != 0)
- {
- if (bHaveDebugger())
- {
- g_Notify->DisplayError("CFC1 what register are you writing to ?");
- }
- return;
- }
- _GPR[m_Opcode.rt].DW = (int32_t)_FPCR[m_Opcode.fs];
+ if (m_Opcode.fs != 31 && m_Opcode.fs != 0)
+ {
+ if (bHaveDebugger())
+ {
+ g_Notify->DisplayError("CFC1 what register are you writing to ?");
+ }
+ return;
+ }
+ _GPR[m_Opcode.rt].DW = (int32_t)_FPCR[m_Opcode.fs];
}
void R4300iOp::COP1_MT()
@@ -2281,15 +2303,15 @@ void R4300iOp::COP1_DMT()
void R4300iOp::COP1_CT()
{
TEST_COP1_USABLE_EXCEPTION();
- if (m_Opcode.fs == 31)
- {
+ if (m_Opcode.fs == 31)
+ {
_FPCR[m_Opcode.fs] = _GPR[m_Opcode.rt].W[0];
switch ((_FPCR[m_Opcode.fs] & 3))
{
- case 0: *_RoundingModel = ROUND_NEAR; break;
- case 1: *_RoundingModel = ROUND_CHOP; break;
- case 2: *_RoundingModel = ROUND_UP; break;
- case 3: *_RoundingModel = ROUND_DOWN; break;
+ case 0: *_RoundingModel = FE_TONEAREST; break;
+ case 1: *_RoundingModel = FE_TOWARDZERO; break;
+ case 2: *_RoundingModel = FE_UPWARD; break;
+ case 3: *_RoundingModel = FE_DOWNWARD; break;
}
return;
}
@@ -2358,186 +2380,148 @@ void R4300iOp::COP1_BCTL()
}
}
/************************** COP1: S functions ************************/
-__inline void Float_RoundToInteger32(int32_t * Dest, float * Source)
+__inline void Float_RoundToInteger32(int32_t * Dest, const float * Source, int RoundType)
{
-#ifdef _M_IX86
- _asm
- {
- mov esi, [Source]
- mov edi, [Dest]
- fld dword ptr[esi]
- fistp dword ptr[edi]
- }
-#else
- __m128 xmm;
+#pragma warning(push)
+#pragma warning(disable:4244) //warning C4244: disabe conversion from 'float' to 'int32_t', possible loss of data
- xmm = _mm_load_ss(Source);
- *(Dest) = _mm_cvt_ss2si(xmm);
-#endif
+ if (RoundType == FE_TONEAREST) { *Dest = roundf(*Source); }
+ if (RoundType == FE_TOWARDZERO) { *Dest = truncf(*Source); }
+ if (RoundType == FE_UPWARD) { *Dest = ceilf(*Source); }
+ if (RoundType == FE_DOWNWARD) { *Dest = floorf(*Source); }
+
+#pragma warning(pop)
}
-__inline void Float_RoundToInteger64(int64_t * Dest, float * Source)
+__inline void Float_RoundToInteger64(int64_t * Dest, const float * Source, int RoundType)
{
-#ifdef _M_IX86
- _asm
- {
- mov esi, [Source]
- mov edi, [Dest]
- fld dword ptr[esi]
- fistp qword ptr[edi]
- }
-#else
- __m128 xmm;
+#pragma warning(push)
+#pragma warning(disable:4244) //warning C4244: disabe conversion from 'float' to 'int64_t', possible loss of data
- xmm = _mm_load_ss(Source);
- *(Dest) = _mm_cvtss_si64(xmm);
-#endif
+ if (RoundType == FE_TONEAREST) { *Dest = roundf(*Source); }
+ if (RoundType == FE_TOWARDZERO) { *Dest = truncf(*Source); }
+ if (RoundType == FE_UPWARD) { *Dest = ceilf(*Source); }
+ if (RoundType == FE_DOWNWARD) { *Dest = floorf(*Source); }
+
+#pragma warning(pop)
}
void R4300iOp::COP1_S_ADD()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] + *(float *)_FPR_S[m_Opcode.ft]);
}
void R4300iOp::COP1_S_SUB()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] - *(float *)_FPR_S[m_Opcode.ft]);
}
void R4300iOp::COP1_S_MUL()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] * *(float *)_FPR_S[m_Opcode.ft]);
}
void R4300iOp::COP1_S_DIV()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] / *(float *)_FPR_S[m_Opcode.ft]);
}
void R4300iOp::COP1_S_SQRT()
{
- float * Dest = (float *)(_FPR_S[m_Opcode.fd]);
- float * Source = (float *)(_FPR_S[m_Opcode.fs]);
-
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
-#ifdef _M_IX86
- _asm
- {
- push esi
- mov esi, dword ptr[Source]
- fld dword ptr[esi]
- fsqrt
- mov esi, dword ptr[Dest]
- fstp dword ptr[esi]
- pop esi
- }
-#else
- __m128 xmm;
+ fesetround(*_RoundingModel);
- xmm = _mm_load_ss(Source);
- xmm = _mm_sqrt_ss(xmm);
- *(Dest) = _mm_cvtss_f32(xmm);
-#endif
+ *(float *)(_FPR_S[m_Opcode.fd]) = sqrtf(*(float *)(_FPR_S[m_Opcode.fs]));
}
void R4300iOp::COP1_S_ABS()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(float *)_FPR_S[m_Opcode.fd] = (float)fabs(*(float *)_FPR_S[m_Opcode.fs]);
}
void R4300iOp::COP1_S_MOV()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(float *)_FPR_S[m_Opcode.fd] = *(float *)_FPR_S[m_Opcode.fs];
}
void R4300iOp::COP1_S_NEG()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] * -1.0f);
}
void R4300iOp::COP1_S_TRUNC_L()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(_RC_CHOP, _MCW_RC);
- Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]);
+ Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs], FE_TOWARDZERO);
}
void R4300iOp::COP1_S_CEIL_L()
{ //added by Witten
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(_RC_UP, _MCW_RC);
- Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]);
+ Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs], FE_UPWARD);
}
void R4300iOp::COP1_S_FLOOR_L()
{ //added by Witten
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(_RC_DOWN, _MCW_RC);
- Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]);
+ Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs], FE_DOWNWARD);
}
void R4300iOp::COP1_S_ROUND_W()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(_RC_NEAR, _MCW_RC);
- Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]);
+ Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs], FE_TONEAREST);
}
void R4300iOp::COP1_S_TRUNC_W()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(_RC_CHOP, _MCW_RC);
- Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]);
+ Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs], FE_TOWARDZERO);
}
void R4300iOp::COP1_S_CEIL_W()
{ //added by Witten
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(_RC_UP, _MCW_RC);
- Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]);
+ Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs], FE_UPWARD);
}
void R4300iOp::COP1_S_FLOOR_W()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(_RC_DOWN, _MCW_RC);
- Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]);
+ Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs], FE_DOWNWARD);
}
void R4300iOp::COP1_S_CVT_D()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(double *)_FPR_D[m_Opcode.fd] = (double)(*(float *)_FPR_S[m_Opcode.fs]);
}
void R4300iOp::COP1_S_CVT_W()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
- Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]);
+ Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs], *_RoundingModel);
}
void R4300iOp::COP1_S_CVT_L()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
- Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]);
+ Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs], *_RoundingModel);
}
void R4300iOp::COP1_S_CMP()
@@ -2554,7 +2538,7 @@ void R4300iOp::COP1_S_CMP()
{
if (bHaveDebugger())
{
- g_Notify->DisplayError(stdstr_f("%s: Nan ?",__FUNCTION__).c_str());
+ g_Notify->DisplayError(stdstr_f("%s: Nan ?", __FUNCTION__).c_str());
}
less = false;
equal = false;
@@ -2588,166 +2572,147 @@ void R4300iOp::COP1_S_CMP()
}
/************************** COP1: D functions ************************/
-__inline void Double_RoundToInteger32(uint32_t * Dest, double * Source)
+__inline void Double_RoundToInteger32(uint32_t * Dest, const double * Source, int RoundType)
{
-#ifdef _M_IX86
- _asm
- {
- mov esi, [Source]
- mov edi, [Dest]
- fld qword ptr [esi]
- fistp dword ptr [edi]
- }
-#else
- __m128d xmm;
+#pragma warning(push)
+#pragma warning(disable:4244) //warning C4244: disabe conversion from 'double' to 'uint32_t', possible loss of data
- xmm = _mm_load_sd(Source);
- *(Dest) = _mm_cvtsd_si32(xmm);
-#endif
+ if (RoundType == FE_TONEAREST) { *Dest = round(*Source); }
+ if (RoundType == FE_TOWARDZERO) { *Dest = trunc(*Source); }
+ if (RoundType == FE_UPWARD) { *Dest = ceil(*Source); }
+ if (RoundType == FE_DOWNWARD) { *Dest = floor(*Source); }
+
+#pragma warning(pop)
}
-__inline void Double_RoundToInteger64(uint64_t * Dest, double * Source)
+__inline void Double_RoundToInteger64(uint64_t * Dest, const double * Source, int RoundType)
{
-#ifdef _M_IX86
- _asm
- {
- mov esi, [Source]
- mov edi, [Dest]
- fld qword ptr [esi]
- fistp qword ptr [edi]
- }
-#else
- __m128d xmm;
+#pragma warning(push)
+#pragma warning(disable:4244) //warning C4244: disabe conversion from 'double' to 'uint64_t', possible loss of data
- xmm = _mm_load_sd(Source);
- *(Dest) = _mm_cvtsd_si64(xmm);
-#endif
+ if (RoundType == FE_TONEAREST) { *Dest = round(*Source); }
+ if (RoundType == FE_TOWARDZERO) { *Dest = trunc(*Source); }
+ if (RoundType == FE_UPWARD) { *Dest = ceil(*Source); }
+ if (RoundType == FE_DOWNWARD) { *Dest = floor(*Source); }
+
+#pragma warning(pop)
}
void R4300iOp::COP1_D_ADD()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] + *(double *)_FPR_D[m_Opcode.ft];
}
void R4300iOp::COP1_D_SUB()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] - *(double *)_FPR_D[m_Opcode.ft];
}
void R4300iOp::COP1_D_MUL()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] * *(double *)_FPR_D[m_Opcode.ft];
}
void R4300iOp::COP1_D_DIV()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] / *(double *)_FPR_D[m_Opcode.ft];
}
void R4300iOp::COP1_D_SQRT()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(double *)_FPR_D[m_Opcode.fd] = (double)sqrt(*(double *)_FPR_D[m_Opcode.fs]);
}
void R4300iOp::COP1_D_ABS()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(double *)_FPR_D[m_Opcode.fd] = fabs(*(double *)_FPR_D[m_Opcode.fs]);
}
void R4300iOp::COP1_D_MOV()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(int64_t *)_FPR_D[m_Opcode.fd] = *(int64_t *)_FPR_D[m_Opcode.fs];
}
void R4300iOp::COP1_D_NEG()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(double *)_FPR_D[m_Opcode.fd] = (*(double *)_FPR_D[m_Opcode.fs] * -1.0);
}
void R4300iOp::COP1_D_TRUNC_L()
{ //added by Witten
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(RC_CHOP, _MCW_RC);
- Double_RoundToInteger64(&*(uint64_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]);
+ Double_RoundToInteger64(&*(uint64_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs], FE_TOWARDZERO);
}
void R4300iOp::COP1_D_CEIL_L()
{ //added by Witten
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(RC_UP, _MCW_RC);
- Double_RoundToInteger64(&*(uint64_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]);
+ Double_RoundToInteger64(&*(uint64_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs], FE_UPWARD);
}
void R4300iOp::COP1_D_FLOOR_L()
{ //added by Witten
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(_RC_DOWN, _MCW_RC);
- Double_RoundToInteger64(&*(uint64_t *)_FPR_D[m_Opcode.fd], &*(double *)_FPR_S[m_Opcode.fs]);
+ Double_RoundToInteger64(&*(uint64_t *)_FPR_D[m_Opcode.fd], &*(double *)_FPR_S[m_Opcode.fs], FE_DOWNWARD);
}
void R4300iOp::COP1_D_ROUND_W()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(_RC_NEAR, _MCW_RC);
- Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]);
+ Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs], FE_TONEAREST);
}
void R4300iOp::COP1_D_TRUNC_W()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(RC_CHOP, _MCW_RC);
- Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]);
+ Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs], FE_TOWARDZERO);
}
void R4300iOp::COP1_D_CEIL_W()
{ //added by Witten
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(RC_UP, _MCW_RC);
- Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]);
+ Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs], FE_UPWARD);
}
void R4300iOp::COP1_D_FLOOR_W()
{ //added by Witten
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(_RC_DOWN, _MCW_RC);
- Double_RoundToInteger32(&*(uint32_t *)_FPR_D[m_Opcode.fd], &*(double *)_FPR_S[m_Opcode.fs]);
+ Double_RoundToInteger32(&*(uint32_t *)_FPR_D[m_Opcode.fd], &*(double *)_FPR_S[m_Opcode.fs], FE_DOWNWARD);
}
void R4300iOp::COP1_D_CVT_S()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(float *)_FPR_S[m_Opcode.fd] = (float)*(double *)_FPR_D[m_Opcode.fs];
}
void R4300iOp::COP1_D_CVT_W()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
- Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]);
+ Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs], *_RoundingModel);
}
void R4300iOp::COP1_D_CVT_L()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
- Double_RoundToInteger64(&*(uint64_t *)_FPR_D[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]);
+ Double_RoundToInteger64(&*(uint64_t *)_FPR_D[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs], *_RoundingModel);
}
void R4300iOp::COP1_D_CMP()
@@ -2765,7 +2730,7 @@ void R4300iOp::COP1_D_CMP()
{
if (bHaveDebugger())
{
- g_Notify->DisplayError(stdstr_f("%s: Nan ?",__FUNCTION__).c_str());
+ g_Notify->DisplayError(stdstr_f("%s: Nan ?", __FUNCTION__).c_str());
}
less = false;
equal = false;
@@ -2802,14 +2767,14 @@ void R4300iOp::COP1_D_CMP()
void R4300iOp::COP1_W_CVT_S()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(float *)_FPR_S[m_Opcode.fd] = (float)*(int32_t *)_FPR_S[m_Opcode.fs];
}
void R4300iOp::COP1_W_CVT_D()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(double *)_FPR_D[m_Opcode.fd] = (double)*(int32_t *)_FPR_S[m_Opcode.fs];
}
@@ -2817,14 +2782,14 @@ void R4300iOp::COP1_W_CVT_D()
void R4300iOp::COP1_L_CVT_S()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(float *)_FPR_S[m_Opcode.fd] = (float)*(int64_t *)_FPR_D[m_Opcode.fs];
}
void R4300iOp::COP1_L_CVT_D()
{
TEST_COP1_USABLE_EXCEPTION();
- _controlfp(*_RoundingModel, _MCW_RC);
+ fesetround(*_RoundingModel);
*(double *)_FPR_D[m_Opcode.fd] = (double)*(int64_t *)_FPR_D[m_Opcode.fs];
}
diff --git a/Source/Project64-core/N64System/Mips/Dma.cpp b/Source/Project64-core/N64System/Mips/Dma.cpp
index 7720e417d..5a5ba3794 100644
--- a/Source/Project64-core/N64System/Mips/Dma.cpp
+++ b/Source/Project64-core/N64System/Mips/Dma.cpp
@@ -34,6 +34,7 @@ void CDMA::OnFirstDMA()
{
case CIC_NUS_6101: offset = +0x0318; break;
case CIC_NUS_5167: offset = +0x0318; break;
+ case CIC_NUS_8303: offset = +0x0318; break;
case CIC_UNKNOWN:
case CIC_NUS_6102: offset = +0x0318; break;
case CIC_NUS_6103: offset = +0x0318; break;
@@ -75,7 +76,7 @@ void CDMA::PI_DMA_READ()
uint8_t * ROM = g_Rom->GetRomAddress();
uint8_t * RDRAM = g_MMU->Rdram();
- ProtectMemory(ROM, g_Rom->GetRomSize(), MEM_READWRITE);
+ ProtectMemory(ROM, g_Rom->GetRomSize(), MEM_READWRITE);
g_Reg->PI_CART_ADDR_REG -= 0x10000000;
if (g_Reg->PI_CART_ADDR_REG + PI_RD_LEN_REG < g_Rom->GetRomSize())
{
@@ -105,7 +106,7 @@ void CDMA::PI_DMA_READ()
g_Recompiler->ClearRecompCode_Phys(g_Reg->PI_DRAM_ADDR_REG, g_Reg->PI_WR_LEN_REG, CRecompiler::Remove_DMA);
}
- ProtectMemory(ROM, g_Rom->GetRomSize(), MEM_READONLY);
+ ProtectMemory(ROM, g_Rom->GetRomSize(), MEM_READONLY);
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
@@ -181,6 +182,75 @@ void CDMA::PI_DMA_WRITE()
return;
}
+ //64DD IPL ROM
+ if (g_Reg->PI_CART_ADDR_REG >= 0x06000000 && g_Reg->PI_CART_ADDR_REG <= 0x063FFFFF)
+ {
+ uint32_t i;
+
+#ifdef legacycode
+#ifdef ROM_IN_MAPSPACE
+ if (WrittenToRom)
+ {
+ uint32_t OldProtect;
+ VirtualProtect(ROM, m_RomFileSize, PAGE_READONLY, &OldProtect);
+ }
+#endif
+#endif
+
+ uint8_t * ROM = g_DDRom->GetRomAddress();
+ uint8_t * RDRAM = g_MMU->Rdram();
+ g_Reg->PI_CART_ADDR_REG -= 0x06000000;
+ if (g_Reg->PI_CART_ADDR_REG + PI_WR_LEN_REG < g_DDRom->GetRomSize())
+ {
+ for (i = 0; i < PI_WR_LEN_REG; i++)
+ {
+ *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM + ((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
+ }
+ }
+ else if (g_Reg->PI_CART_ADDR_REG >= g_DDRom->GetRomSize())
+ {
+ uint32_t cart = g_Reg->PI_CART_ADDR_REG - g_DDRom->GetRomSize();
+ while (cart >= g_DDRom->GetRomSize())
+ {
+ cart -= g_DDRom->GetRomSize();
+ }
+ for (i = 0; i < PI_WR_LEN_REG; i++)
+ {
+ *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM + ((cart + i) ^ 3));
+ }
+ }
+ else
+ {
+ uint32_t Len;
+ Len = g_DDRom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
+ for (i = 0; i < Len; i++)
+ {
+ *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM + ((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
+ }
+ for (i = Len; i < PI_WR_LEN_REG - Len; i++)
+ {
+ *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = 0;
+ }
+ }
+ g_Reg->PI_CART_ADDR_REG += 0x06000000;
+
+ if (!g_System->DmaUsed())
+ {
+ g_System->SetDmaUsed(true);
+ OnFirstDMA();
+ }
+ if (g_Recompiler && g_System->bSMM_PIDMA())
+ {
+ g_Recompiler->ClearRecompCode_Phys(g_Reg->PI_DRAM_ADDR_REG, g_Reg->PI_WR_LEN_REG, CRecompiler::Remove_DMA);
+ }
+ g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
+ g_Reg->MI_INTR_REG |= MI_INTR_PI;
+ g_Reg->CheckInterrupts();
+ //ChangeTimer(PiTimer,(int32_t)(PI_WR_LEN_REG * 8.9) + 50);
+ //ChangeTimer(PiTimer,(int32_t)(PI_WR_LEN_REG * 8.9));
+ return;
+ }
+
if (g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08088000)
{
if (g_System->m_SaveUsing == SaveChip_Auto)
diff --git a/Source/Project64-core/N64System/Mips/MemoryLabelsClass.cpp b/Source/Project64-core/N64System/Mips/MemoryLabelsClass.cpp
deleted file mode 100644
index 3158798fd..000000000
--- a/Source/Project64-core/N64System/Mips/MemoryLabelsClass.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/****************************************************************************
-* *
-* 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"
-
-DWORD CMemoryLabel::AsciiToHex (char * HexValue)
-{
- DWORD Count, Finish, Current, Value = 0;
-
- Finish = strlen(HexValue);
- if (Finish > 8 )
- {
- Finish = 8;
- }
-
- for (Count = 0; Count < Finish; Count++)
- {
- Value = (Value << 4);
- Current = HexValue[Count];
- if(Current >= '0' && Current <= '9')
- {
- Value += Current - '0';
- }
- else
- {
- if(Current > 'F')
- Current -= 32; //32 is the distance between A and a
-
- if (Current >= 'A' && Current <= 'F')
- {
- Value += Current - 55; //55 is the code for 'A' less 10
- }
- else
- {
- Value = (Value >> 4);
- Count = Finish;
- }
- }
- }
- return Value;
-}
-
-void CMemoryLabel::AddMemoryLabel ( DWORD Address, const char * Message, ... )
-{
- StringMap::iterator Item = m_LabelList.find(Address);
- if (Item == m_LabelList.end())
- {
- char Msg[1000];
- va_list ap;
-
- va_start( ap, Message );
- _vsnprintf( Msg,sizeof(Msg),Message, ap );
- va_end( ap );
-
- //if item is already in the list then do not add it
- m_LabelList.insert(StringMap::value_type(Address,stdstr(Msg)));
- m_NewLabels += 1;
- }
-}
-
-stdstr CMemoryLabel::LabelName ( DWORD Address ) const
-{
- //StringMap::iterator theIterator = m_LabelList.find(Address);
- //if (theIterator != m_LabelList.end())
- //{
- // return (*theIterator).second;
- //}
-
- char strLabelName[100];
- sprintf(strLabelName,"0x%08X",Address);
- return stdstr(strLabelName);
-}
-
-stdstr CMemoryLabel::StoredLabelName ( DWORD Address )
-{
- StringMap::iterator theIterator = m_LabelList.find(Address);
- if (theIterator != m_LabelList.end())
- {
- return (*theIterator).second;
- }
- return stdstr("");
-}
-
-void CMemoryLabel::LoadLabelList ( char * file )
-{
- m_LabelList.clear();
- CurrentLabelFile = file;
-
- HANDLE hFile = CreateFile(file,GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,
- OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
- if (hFile == INVALID_HANDLE_VALUE)
- {
- return;
- }
-
- SetFilePointer(hFile,0,NULL,FILE_BEGIN);
-
- DWORD FileSize = GetFileSize(hFile,NULL);
- void * FileContents = VirtualAlloc(NULL,FileSize,MEM_COMMIT,PAGE_READWRITE );
-
- if (FileContents)
- {
- DWORD dwRead;
- if (!ReadFile(hFile,FileContents,FileSize,&dwRead,NULL))
- {
- VirtualFree(FileContents, 0, MEM_RELEASE);
- FileContents = NULL;
- }
- }
-
- if (FileContents)
- {
- ProcessCODFile((BYTE *)FileContents, FileSize);
- }
-
- VirtualFree(FileContents, 0, MEM_RELEASE);
- CloseHandle(hFile);
-
- m_NewLabels = 0;
-}
-
-// How many new labels been added since loading/saving label file
-int CMemoryLabel::NewLabels()
-{
- return m_NewLabels;
-}
-
-void CMemoryLabel::SaveLabelList()
-{
- m_NewLabels = 0;
-
- if (CurrentLabelFile.length() == 0)
- {
- return;
- }
-
- HANDLE hFile = CreateFile(CurrentLabelFile.c_str(),GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,
- CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
- SetFilePointer(hFile,0,NULL,FILE_BEGIN);
-
- for (StringMap::iterator Item = m_LabelList.begin(); Item != m_LabelList.end(); Item++)
- {
- char Text[300];
- DWORD dwWritten;
-
- sprintf(Text, "0x%08X,%s\r\n",(*Item).first,((*Item).second).c_str());
-
- WriteFile( hFile,Text,strlen(Text),&dwWritten,NULL );
- }
-
- CloseHandle(hFile);
-
-}
-
-void CMemoryLabel::ProcessCODFile(BYTE * File, DWORD FileLen)
-{
- char * CurrentPos = (char *)File;
- char Label[40];
- DWORD Address;
- int Length;
-
- while ( CurrentPos < (char *)File + FileLen )
- {
- if (*CurrentPos != '0')
- {
- return;
- }
- CurrentPos += 1;
- if (*CurrentPos != 'x')
- {
- return;
- }
- CurrentPos += 1;
-
- if (strchr(CurrentPos,',') - CurrentPos != 8)
- {
- return;
- }
- Address = AsciiToHex (CurrentPos);
- CurrentPos += 9;
-
-
- if (strchr(CurrentPos,'\r') == NULL)
- {
- Length = strchr(CurrentPos,'\n') - CurrentPos;
- }
- else
- {
- Length = strchr(CurrentPos,'\r') - CurrentPos;
- if (Length > (strchr(CurrentPos,'\n') - CurrentPos))
- {
- Length = strchr(CurrentPos,'\n') - CurrentPos;
- }
- }
-
- // Stay within label array bounds
- if (Length > 39)
- Length = 39;
-
- memcpy(Label,CurrentPos,Length);
- Label[Length] = '\0';
-
- AddMemoryLabel (Address, Label);
- CurrentPos = strchr(CurrentPos,'\n') + 1;
- }
-}
diff --git a/Source/Project64-core/N64System/Mips/MemoryLabelsClass.h b/Source/Project64-core/N64System/Mips/MemoryLabelsClass.h
deleted file mode 100644
index 559c04721..000000000
--- a/Source/Project64-core/N64System/Mips/MemoryLabelsClass.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/****************************************************************************
-* *
-* 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
-
-typedef std::map StringMap;
-
-class CMemoryLabel
-{
- // Variable dealing with Labels
- StringMap m_LabelList;
- int m_NewLabels;
- stdstr CurrentLabelFile;
-
- DWORD AsciiToHex ( char * HexValue );
- void ProcessCODFile ( BYTE * File, DWORD FileLen );
-
-public:
- //Functions related to Labels
- void AddMemoryLabel ( DWORD Address, const char * Message, ... );
- stdstr LabelName ( DWORD Address ) const;
- stdstr StoredLabelName ( DWORD Address );
- void LoadLabelList ( char * file );
- int NewLabels (); // How many new labels been added since loading/saving label file
- void SaveLabelList ();
-};
diff --git a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp
index 798152ac4..72e742ac2 100644
--- a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp
+++ b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp
@@ -194,6 +194,33 @@ bool CMipsMemoryVM::Initialize()
m_Rom = g_Rom->GetRomAddress();
m_RomSize = g_Rom->GetRomSize();
}
+
+ //64DD IPL
+ if (g_DDRom != NULL)
+ {
+ if (g_Settings->LoadBool(Game_LoadRomToMemory))
+ {
+ m_DDRomMapped = true;
+ m_DDRom = m_RDRAM + 0x06000000;
+ m_DDRomSize = g_DDRom->GetRomSize();
+ if (CommitMemory(m_DDRom, g_DDRom->GetRomSize(), MEM_READWRITE) == NULL)
+ {
+ WriteTrace(TraceN64System, TraceError, "Failed to Allocate Rom (Size: 0x%X)", g_DDRom->GetRomSize());
+ FreeMemory();
+ return false;
+ }
+ memcpy(m_DDRom, g_DDRom->GetRomAddress(), g_DDRom->GetRomSize());
+
+ ::ProtectMemory(m_DDRom, g_DDRom->GetRomSize(), MEM_READONLY);
+ }
+ else
+ {
+ m_DDRomMapped = false;
+ m_DDRom = g_DDRom->GetRomAddress();
+ m_DDRomSize = g_DDRom->GetRomSize();
+ }
+ }
+
CPifRam::Reset();
m_TLB_ReadMap = new size_t[0x100000];
@@ -838,7 +865,7 @@ void CMipsMemoryVM::Compile_LW(x86Reg Reg, uint32_t VAddr)
if (g_Plugins->Audio()->AiReadLength != NULL)
{
BeforeCallDirect(m_RegWorkingSet);
- Call_Direct(g_Plugins->Audio()->AiReadLength, "AiReadLength");
+ Call_Direct((void *)g_Plugins->Audio()->AiReadLength, "AiReadLength");
MoveX86regToVariable(x86_EAX, &m_TempValue, "m_TempValue");
AfterCallDirect(m_RegWorkingSet);
MoveVariableToX86reg(&m_TempValue, "m_TempValue", Reg);
@@ -928,6 +955,12 @@ void CMipsMemoryVM::Compile_LW(x86Reg Reg, uint32_t VAddr)
sprintf(VarName, "m_RDRAM + %X", PAddr);
MoveVariableToX86reg(PAddr + m_RDRAM, VarName, Reg);
}
+ else if ((PAddr & 0xFF000000) == 0x06000000 && (PAddr - 0x06000000) < m_DDRomSize)
+ {
+ // read from ddrom
+ sprintf(VarName, "m_RDRAM + %X", PAddr);
+ MoveVariableToX86reg(PAddr + m_RDRAM, VarName, Reg);
+ }
else
{
MoveConstToX86reg(((PAddr & 0xFFFF) << 16) | (PAddr & 0xFFFF), Reg);
@@ -1392,7 +1425,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr)
Jump = m_RecompPos - 1;
MoveConstToVariable(Value, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG");
BeforeCallDirect(m_RegWorkingSet);
- Call_Direct(g_Plugins->Gfx()->ViStatusChanged, "ViStatusChanged");
+ Call_Direct((void *)g_Plugins->Gfx()->ViStatusChanged, "ViStatusChanged");
AfterCallDirect(m_RegWorkingSet);
CPU_Message("");
CPU_Message(" Continue:");
@@ -1408,7 +1441,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr)
Jump = m_RecompPos - 1;
MoveConstToVariable(Value, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG");
BeforeCallDirect(m_RegWorkingSet);
- Call_Direct(g_Plugins->Gfx()->ViWidthChanged, "ViWidthChanged");
+ Call_Direct((void *)g_Plugins->Gfx()->ViWidthChanged, "ViWidthChanged");
AfterCallDirect(m_RegWorkingSet);
CPU_Message("");
CPU_Message(" Continue:");
@@ -1454,7 +1487,7 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr)
}
else
{
- Call_Direct(g_Plugins->Audio()->AiLenChanged, "AiLenChanged");
+ Call_Direct((void *)g_Plugins->Audio()->AiLenChanged, "AiLenChanged");
}
AfterCallDirect(m_RegWorkingSet);
break;
@@ -1747,7 +1780,7 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr)
Jump = m_RecompPos - 1;
MoveX86regToVariable(Reg, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG");
BeforeCallDirect(m_RegWorkingSet);
- Call_Direct(g_Plugins->Gfx()->ViStatusChanged, "ViStatusChanged");
+ Call_Direct((void *)g_Plugins->Gfx()->ViStatusChanged, "ViStatusChanged");
AfterCallDirect(m_RegWorkingSet);
CPU_Message("");
CPU_Message(" Continue:");
@@ -1766,7 +1799,7 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr)
Jump = m_RecompPos - 1;
MoveX86regToVariable(Reg, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG");
BeforeCallDirect(m_RegWorkingSet);
- Call_Direct(g_Plugins->Gfx()->ViWidthChanged, "ViWidthChanged");
+ Call_Direct((void *)g_Plugins->Gfx()->ViWidthChanged, "ViWidthChanged");
AfterCallDirect(m_RegWorkingSet);
CPU_Message("");
CPU_Message(" Continue:");
@@ -1814,7 +1847,7 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr)
}
else
{
- Call_Direct(g_Plugins->Audio()->AiLenChanged, "g_Plugins->Audio()->LenChanged");
+ Call_Direct((void *)g_Plugins->Audio()->AiLenChanged, "g_Plugins->Audio()->LenChanged");
}
AfterCallDirect(m_RegWorkingSet);
break;
@@ -2106,8 +2139,10 @@ bool CMipsMemoryVM::LW_NonMemory(uint32_t PAddr, uint32_t* Value)
case 0x04700000: Load32RDRAMInterface(); break;
case 0x04800000: Load32SerialInterface(); break;
case 0x05000000: Load32CartridgeDomain2Address1(); break;
+ case 0x06000000: Load32CartridgeDomain1Address1(); break;
case 0x08000000: Load32CartridgeDomain2Address2(); break;
case 0x1FC00000: Load32PifRam(); break;
+ case 0x1FF00000: Load32CartridgeDomain1Address3(); break;
default:
if (bHaveDebugger())
{
@@ -4257,8 +4292,8 @@ void CMipsMemoryVM::TLB_Unmaped(uint32_t Vaddr, uint32_t Len)
for (count = Vaddr; count < End; count += 0x1000)
{
size_t Index = count >> 12;
- m_TLB_ReadMap[Index] = NULL;
- m_TLB_WriteMap[Index] = NULL;
+ m_TLB_ReadMap[Index] = 0;
+ m_TLB_WriteMap[Index] = 0;
}
}
@@ -4678,6 +4713,26 @@ void CMipsMemoryVM::Load32SerialInterface(void)
}
}
+void CMipsMemoryVM::Load32CartridgeDomain1Address1(void)
+{
+ //64DD IPL ROM
+ if (g_DDRom != NULL && (m_MemLookupAddress & 0xFFFFFF) < g_MMU->m_DDRomSize)
+ {
+ m_MemLookupValue.UW[0] = *(uint32_t *)&g_MMU->m_DDRom[(m_MemLookupAddress & 0xFFFFFF)];
+ }
+ else
+ {
+ m_MemLookupValue.UW[0] = m_MemLookupAddress & 0xFFFF;
+ m_MemLookupValue.UW[0] = (m_MemLookupValue.UW[0] << 16) | m_MemLookupValue.UW[0];
+ }
+}
+
+void CMipsMemoryVM::Load32CartridgeDomain1Address3(void)
+{
+ m_MemLookupValue.UW[0] = m_MemLookupAddress & 0xFFFF;
+ m_MemLookupValue.UW[0] = (m_MemLookupValue.UW[0] << 16) | m_MemLookupValue.UW[0];
+}
+
void CMipsMemoryVM::Load32CartridgeDomain2Address1(void)
{
m_MemLookupValue.UW[0] = m_MemLookupAddress & 0xFFFF;
@@ -4765,10 +4820,6 @@ void CMipsMemoryVM::Load32Rom(void)
{
m_MemLookupValue.UW[0] = m_MemLookupAddress & 0xFFFF;
m_MemLookupValue.UW[0] = (m_MemLookupValue.UW[0] << 16) | m_MemLookupValue.UW[0];
- if (bHaveDebugger())
- {
- g_Notify->BreakPoint(__FILE__, __LINE__);
- }
}
}
diff --git a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h
index 16463488e..542e4af5f 100644
--- a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h
+++ b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h
@@ -185,6 +185,8 @@ private:
static void Load32PeripheralInterface(void);
static void Load32RDRAMInterface(void);
static void Load32SerialInterface(void);
+ static void Load32CartridgeDomain1Address1(void);
+ static void Load32CartridgeDomain1Address3(void);
static void Load32CartridgeDomain2Address1(void);
static void Load32CartridgeDomain2Address2(void);
static void Load32PifRam(void);
@@ -214,6 +216,11 @@ private:
bool m_RomWrittenTo;
uint32_t m_RomWroteValue;
+ //DDRom Information
+ bool m_DDRomMapped;
+ uint8_t * m_DDRom;
+ uint32_t m_DDRomSize;
+
//Current Half line
void UpdateHalfLine();
uint32_t m_HalfLine;
diff --git a/Source/Project64-core/N64System/Mips/PifRam.cpp b/Source/Project64-core/N64System/Mips/PifRam.cpp
index 33e2d175f..bb0f493c2 100644
--- a/Source/Project64-core/N64System/Mips/PifRam.cpp
+++ b/Source/Project64-core/N64System/Mips/PifRam.cpp
@@ -21,8 +21,8 @@
#include
#include
-int CPifRamSettings::m_RefCount = 0;
-bool CPifRamSettings::m_bShowPifRamErrors = false;
+int32_t CPifRamSettings::m_RefCount = 0;
+bool CPifRamSettings::m_bShowPifRamErrors = false;
CPifRamSettings::CPifRamSettings()
{
@@ -64,7 +64,7 @@ void CPifRam::Reset()
memset(m_PifRom, 0, sizeof(m_PifRom));
}
-void CPifRam::n64_cic_nus_6105(char challenge[], char respone[], int length)
+void CPifRam::n64_cic_nus_6105(char challenge[], char respone[], int32_t length)
{
static char lut0[0x10] = {
0x4, 0x7, 0xA, 0x7, 0xE, 0x5, 0xE, 0x1,
@@ -75,7 +75,7 @@ void CPifRam::n64_cic_nus_6105(char challenge[], char respone[], int length)
0xC, 0x9, 0x8, 0x5, 0x6, 0x3, 0xC, 0x9
};
char key, *lut;
- int i, sgn, mag, mod;
+ int32_t i, sgn, mag, mod;
for (key = 0xB, lut = lut0, i = 0; i < length; i++)
{
@@ -105,8 +105,8 @@ void CPifRam::PifRamRead()
CONTROL * Controllers = g_Plugins->Control()->PluginControllers();
- int Channel = 0;
- for (int CurPos = 0; CurPos < 0x40; CurPos++)
+ int32_t Channel = 0;
+ for (int32_t CurPos = 0; CurPos < 0x40; CurPos++)
{
switch (m_PifRam[CurPos])
{
@@ -160,7 +160,7 @@ void CPifRam::PifRamRead()
void CPifRam::PifRamWrite()
{
CONTROL * Controllers = g_Plugins->Control()->PluginControllers();
- int Channel = 0, CurPos;
+ int32_t Channel = 0, CurPos;
if (m_PifRam[0x3F] > 0x1)
{
@@ -168,29 +168,29 @@ void CPifRam::PifRamWrite()
{
case 0x02:
// format the 'challenge' message into 30 nibbles for X-Scale's CIC code
- {
- char Challenge[30], Response[30];
- for (int i = 0; i < 15; i++)
{
- Challenge[i * 2] = (m_PifRam[48 + i] >> 4) & 0x0f;
- Challenge[i * 2 + 1] = m_PifRam[48 + i] & 0x0f;
+ char Challenge[30], Response[30];
+ for (int32_t i = 0; i < 15; i++)
+ {
+ Challenge[i * 2] = (m_PifRam[48 + i] >> 4) & 0x0f;
+ Challenge[i * 2 + 1] = m_PifRam[48 + i] & 0x0f;
+ }
+ n64_cic_nus_6105(Challenge, Response, CHALLENGE_LENGTH - 2);
+ uint64_t ResponseValue = 0;
+ m_PifRam[46] = m_PifRam[47] = 0x00;
+ for (int32_t z = 8; z > 0; z--)
+ {
+ ResponseValue = (ResponseValue << 8) | ((Response[(z - 1) * 2] << 4) + Response[(z - 1) * 2 + 1]);
+ }
+ memcpy(&m_PifRam[48], &ResponseValue, sizeof(uint64_t));
+ ResponseValue = 0;
+ for (int32_t z = 7; z > 0; z--)
+ {
+ ResponseValue = (ResponseValue << 8) | ((Response[((z + 8) - 1) * 2] << 4) + Response[((z + 8) - 1) * 2 + 1]);
+ }
+ memcpy(&m_PifRam[56], &ResponseValue, sizeof(uint64_t));
}
- n64_cic_nus_6105(Challenge, Response, CHALLENGE_LENGTH - 2);
- uint64_t ResponseValue = 0;
- m_PifRam[46] = m_PifRam[47] = 0x00;
- for (int z = 8; z > 0; z--)
- {
- ResponseValue = (ResponseValue << 8) | ((Response[(z - 1) * 2] << 4) + Response[(z - 1) * 2 + 1]);
- }
- memcpy(&m_PifRam[48], &ResponseValue, sizeof(uint64_t));
- ResponseValue = 0;
- for (int z = 7; z > 0; z--)
- {
- ResponseValue = (ResponseValue << 8) | ((Response[((z + 8) - 1) * 2] << 4) + Response[((z + 8) - 1) * 2 + 1]);
- }
- memcpy(&m_PifRam[56], &ResponseValue, sizeof(uint64_t));
- }
- break;
+ break;
case 0x08:
m_PifRam[0x3F] = 0;
g_Reg->MI_INTR_REG |= MI_INTR_SI;
@@ -327,8 +327,8 @@ void CPifRam::SI_DMA_READ()
{
if ((count % 4) == 0)
{
- sprintf(HexData, "\0");
- sprintf(AsciiData, "\0");
+ HexData[0] = '\0';
+ AsciiData[0] = '\0';
}
sprintf(Addon, "%02X %02X %02X %02X",
m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1],
@@ -414,8 +414,8 @@ void CPifRam::SI_DMA_WRITE()
{
if ((count % 4) == 0)
{
- sprintf(HexData, "\0");
- sprintf(AsciiData, "\0");
+ HexData[0] = '\0';
+ AsciiData[0] = '\0';
}
sprintf(Addon, "%02X %02X %02X %02X",
m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1],
@@ -454,7 +454,7 @@ void CPifRam::SI_DMA_WRITE()
}
}
-void CPifRam::ProcessControllerCommand(int Control, uint8_t * Command)
+void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command)
{
CONTROL * Controllers = g_Plugins->Control()->PluginControllers();
@@ -603,7 +603,8 @@ void CPifRam::ProcessControllerCommand(int Control, uint8_t * Command)
}
}
-void CPifRam::ReadControllerCommand(int Control, uint8_t * Command) {
+void CPifRam::ReadControllerCommand(int32_t Control, uint8_t * Command)
+{
CONTROL * Controllers = g_Plugins->Control()->PluginControllers();
switch (Command[2])
@@ -642,11 +643,11 @@ void CPifRam::ReadControllerCommand(int Control, uint8_t * Command) {
}
}
-void CPifRam::LogControllerPakData(char * Description)
+void CPifRam::LogControllerPakData(const char * Description)
{
uint8_t * PIF_Ram = g_MMU->PifRam();
- int count, count2;
+ int32_t count, count2;
char HexData[100], AsciiData[100], Addon[20];
LogMessage("\t%s:", Description);
LogMessage("\t------------------------------");
@@ -654,8 +655,8 @@ void CPifRam::LogControllerPakData(char * Description)
{
if ((count % 4) == 0)
{
- sprintf(HexData, "\0");
- sprintf(AsciiData, "\0");
+ HexData[0] = '\0';
+ AsciiData[0] = '\0';
}
sprintf(Addon, "%02X %02X %02X %02X",
PIF_Ram[(count << 2) + 0], PIF_Ram[(count << 2) + 1],
diff --git a/Source/Project64-core/N64System/Mips/PifRam.h b/Source/Project64-core/N64System/Mips/PifRam.h
index c9911d4a3..c440417f4 100644
--- a/Source/Project64-core/N64System/Mips/PifRam.h
+++ b/Source/Project64-core/N64System/Mips/PifRam.h
@@ -29,7 +29,7 @@ private:
static bool m_bShowPifRamErrors;
- static int m_RefCount;
+ static int32_t m_RefCount;
};
class CPifRam :
@@ -54,9 +54,13 @@ protected:
uint8_t m_PifRam[0x40];
private:
-#define CHALLENGE_LENGTH 0x20
- void ProcessControllerCommand(int Control, uint8_t * Command);
- void ReadControllerCommand(int Control, uint8_t * Command);
- void LogControllerPakData(char * Description);
- void n64_cic_nus_6105(char challenge[], char response[], int length);
+ CPifRam(); // Disable default constructor
+ CPifRam(const CPifRam&); // Disable copy constructor
+ CPifRam& operator=(const CPifRam&); // Disable assignment
+
+ enum { CHALLENGE_LENGTH = 0x20 };
+ void ProcessControllerCommand(int32_t Control, uint8_t * Command);
+ void ReadControllerCommand(int32_t Control, uint8_t * Command);
+ void LogControllerPakData(const char * Description);
+ void n64_cic_nus_6105(char challenge[], char response[], int32_t length);
};
diff --git a/Source/Project64-core/N64System/Mips/RegisterClass.cpp b/Source/Project64-core/N64System/Mips/RegisterClass.cpp
index 18657b827..574b3df60 100644
--- a/Source/Project64-core/N64System/Mips/RegisterClass.cpp
+++ b/Source/Project64-core/N64System/Mips/RegisterClass.cpp
@@ -60,7 +60,7 @@ float ** CSystemRegisters::_FPR_S;
double ** CSystemRegisters::_FPR_D;
uint32_t * CSystemRegisters::_FPCR = NULL;
uint32_t * CSystemRegisters::_LLBit = NULL;
-ROUNDING_MODE * CSystemRegisters::_RoundingModel = NULL;
+int32_t * CSystemRegisters::_RoundingModel = NULL;
CP0registers::CP0registers(uint32_t * _CP0) :
INDEX_REGISTER(_CP0[0]),
@@ -240,7 +240,7 @@ void CRegisters::Reset()
memset(m_FPCR, 0, sizeof(m_FPCR));
m_HI.DW = 0;
m_LO.DW = 0;
- m_RoundingModel = ROUND_NEAR;
+ m_RoundingModel = FE_TONEAREST;
m_LLBit = 0;
diff --git a/Source/Project64-core/N64System/Mips/RegisterClass.h b/Source/Project64-core/N64System/Mips/RegisterClass.h
index 9f6a4befa..01b2f9f1a 100644
--- a/Source/Project64-core/N64System/Mips/RegisterClass.h
+++ b/Source/Project64-core/N64System/Mips/RegisterClass.h
@@ -482,14 +482,6 @@ enum
SI_STATUS_INTERRUPT = 0x1000,
};
-enum ROUNDING_MODE
-{
- ROUND_NEAR = 0x00000000, // _RC_NEAR
- ROUND_DOWN = 0x00000100, // _RC_DOWN
- ROUND_UP = 0x00000200, // _RC_UP
- ROUND_CHOP = 0x00000300, // _RC_CHOP
-};
-
class CRegName
{
public:
@@ -514,7 +506,7 @@ protected:
static double ** _FPR_D;
static uint32_t * _FPCR;
static uint32_t * _LLBit;
- static ROUNDING_MODE * _RoundingModel;
+ static int32_t * _RoundingModel;
};
class CN64System;
@@ -549,7 +541,7 @@ public:
//Floating point registers/information
uint32_t m_FPCR[32];
- ROUNDING_MODE m_RoundingModel;
+ int32_t m_RoundingModel;
MIPS_DWORD m_FPR[32];
float * m_FPR_S[32];
double * m_FPR_D[32];
diff --git a/Source/Project64-core/N64System/Mips/Rumblepak.cpp b/Source/Project64-core/N64System/Mips/Rumblepak.cpp
index f63d69ef1..fd1607613 100644
--- a/Source/Project64-core/N64System/Mips/Rumblepak.cpp
+++ b/Source/Project64-core/N64System/Mips/Rumblepak.cpp
@@ -29,7 +29,7 @@ void Rumblepak::ReadFrom(uint8_t * command)
}
}
-void Rumblepak::WriteTo(int Control, uint8_t * command)
+void Rumblepak::WriteTo(int32_t Control, uint8_t * command)
{
uint32_t address = (command[3] << 8) | (command[4] & 0xE0);
diff --git a/Source/Project64-core/N64System/Mips/Rumblepak.h b/Source/Project64-core/N64System/Mips/Rumblepak.h
index 7101c8043..3e76eacce 100644
--- a/Source/Project64-core/N64System/Mips/Rumblepak.h
+++ b/Source/Project64-core/N64System/Mips/Rumblepak.h
@@ -14,5 +14,5 @@ class Rumblepak
{
public:
static void ReadFrom(uint8_t * command);
- static void WriteTo(int Control, uint8_t * command);
+ static void WriteTo(int32_t Control, uint8_t * command);
};
diff --git a/Source/Project64-core/N64System/Mips/Sram.cpp b/Source/Project64-core/N64System/Mips/Sram.cpp
index 601a34edf..930578951 100644
--- a/Source/Project64-core/N64System/Mips/Sram.cpp
+++ b/Source/Project64-core/N64System/Mips/Sram.cpp
@@ -52,7 +52,7 @@ bool CSram::LoadSram()
return true;
}
-void CSram::DmaFromSram(uint8_t * dest, int StartOffset, int len)
+void CSram::DmaFromSram(uint8_t * dest, int32_t StartOffset, int32_t len)
{
DWORD dwRead;
uint32_t i;
@@ -133,7 +133,7 @@ void CSram::DmaFromSram(uint8_t * dest, int StartOffset, int len)
}
}
-void CSram::DmaToSram(uint8_t * Source, int StartOffset, int len)
+void CSram::DmaToSram(uint8_t * Source, int32_t StartOffset, int32_t len)
{
DWORD dwWritten;
uint32_t i;
diff --git a/Source/Project64-core/N64System/Mips/Sram.h b/Source/Project64-core/N64System/Mips/Sram.h
index ff1d1f0b9..555e8d240 100644
--- a/Source/Project64-core/N64System/Mips/Sram.h
+++ b/Source/Project64-core/N64System/Mips/Sram.h
@@ -16,8 +16,8 @@ public:
CSram(bool ReadOnly);
~CSram();
- void DmaFromSram(uint8_t * dest, int StartOffset, int len);
- void DmaToSram(uint8_t * Source, int StartOffset, int len);
+ void DmaFromSram(uint8_t * dest, int32_t StartOffset, int32_t len);
+ void DmaToSram(uint8_t * Source, int32_t StartOffset, int32_t len);
private:
bool LoadSram();
diff --git a/Source/Project64-core/N64System/Mips/SystemEvents.cpp b/Source/Project64-core/N64System/Mips/SystemEvents.cpp
index 5ae518330..5f2790450 100644
--- a/Source/Project64-core/N64System/Mips/SystemEvents.cpp
+++ b/Source/Project64-core/N64System/Mips/SystemEvents.cpp
@@ -18,12 +18,10 @@ CSystemEvents::CSystemEvents(CN64System * System, CPlugins * Plugins) :
m_Plugins(Plugins),
m_bDoSomething(false)
{
-
}
CSystemEvents::~CSystemEvents()
{
-
}
void CSystemEvents::QueueEvent(SystemEvent action)
diff --git a/Source/Project64-core/N64System/Mips/SystemTiming.cpp b/Source/Project64-core/N64System/Mips/SystemTiming.cpp
index 83f2f7b8e..0bc492da3 100644
--- a/Source/Project64-core/N64System/Mips/SystemTiming.cpp
+++ b/Source/Project64-core/N64System/Mips/SystemTiming.cpp
@@ -15,7 +15,7 @@
#include
#include
-CSystemTimer::CSystemTimer(int & NextTimer) :
+CSystemTimer::CSystemTimer( int32_t & NextTimer ) :
m_NextTimer(NextTimer),
m_inFixTimer(false)
{
diff --git a/Source/Project64-core/N64System/Mips/SystemTiming.h b/Source/Project64-core/N64System/Mips/SystemTiming.h
index 45381f9ba..a9b98efb9 100644
--- a/Source/Project64-core/N64System/Mips/SystemTiming.h
+++ b/Source/Project64-core/N64System/Mips/SystemTiming.h
@@ -39,7 +39,7 @@ public:
};
public:
- CSystemTimer(int & NextTimer);
+ CSystemTimer(int32_t & NextTimer);
void SetTimer(TimerType Type, uint32_t Cycles, bool bRelative);
uint32_t GetTimer(TimerType Type);
void StopTimer(TimerType Type);
@@ -65,8 +65,8 @@ private:
CSystemTimer& operator=(const CSystemTimer&); // Disable assignment
TIMER_DETAILS m_TimerDetatils[MaxTimer];
- int m_LastUpdate; //Timer at last update
- int & m_NextTimer;
+ int32_t m_LastUpdate; //Timer at last update
+ int32_t & m_NextTimer;
TimerType m_Current;
bool m_inFixTimer;
diff --git a/Source/Project64-core/N64System/N64Class.cpp b/Source/Project64-core/N64System/N64Class.cpp
index 4ed0f7769..f6d5b9352 100644
--- a/Source/Project64-core/N64System/N64Class.cpp
+++ b/Source/Project64-core/N64System/N64Class.cpp
@@ -212,6 +212,12 @@ bool CN64System::RunFileImage(const char * FileLoc)
WriteTrace(TraceN64System, TraceDebug, "Loading \"%s\"", FileLoc);
if (g_Rom->LoadN64Image(FileLoc))
{
+ if (g_Rom->CicChipID() == CIC_NUS_8303)
+ {
+ //64DD IPL
+ g_DDRom = g_Rom;
+ }
+
g_System->RefreshGameSettings();
g_Settings->SaveString(Game_File, FileLoc);
diff --git a/Source/Project64-core/N64System/N64Class.h b/Source/Project64-core/N64System/N64Class.h
index 40876f865..df41ba593 100644
--- a/Source/Project64-core/N64System/N64Class.h
+++ b/Source/Project64-core/N64System/N64Class.h
@@ -117,7 +117,7 @@ private:
void StartEmulation2(bool NewThread);
bool SetActiveSystem(bool bActive = true);
void InitRegisters(bool bPostPif, CMipsMemoryVM & MMU);
- void DisplayRSPListCount();
+ void DisplayRSPListCount();
//CPU Methods
void ExecuteRecompiler();
diff --git a/Source/Project64-core/N64System/N64RomClass.cpp b/Source/Project64-core/N64System/N64RomClass.cpp
index c7fe82272..33cbd81c6 100644
--- a/Source/Project64-core/N64System/N64RomClass.cpp
+++ b/Source/Project64-core/N64System/N64RomClass.cpp
@@ -127,8 +127,6 @@ bool CN64Rom::AllocateAndLoadN64Image(const char * FileLoc, bool LoadBootCodeOnl
ByteSwapRom();
//Protect the memory so that it can not be written to.
- DWORD OldProtect;
- VirtualProtect(m_ROMImage, m_RomFileSize, PAGE_READONLY, &OldProtect);
ProtectMemory(m_ROMImage, m_RomFileSize, MEM_READONLY);
return true;
}
diff --git a/Source/Project64-core/N64System/ProfilingClass.cpp b/Source/Project64-core/N64System/ProfilingClass.cpp
index 4042835ad..09f21d849 100644
--- a/Source/Project64-core/N64System/ProfilingClass.cpp
+++ b/Source/Project64-core/N64System/ProfilingClass.cpp
@@ -33,11 +33,11 @@ SPECIAL_TIMERS CProfiling::StartTimer(SPECIAL_TIMERS Address)
uint32_t HiValue, LoValue;
_asm
{
- pushad
- rdtsc
- mov HiValue, edx
- mov LoValue, eax
- popad
+ pushad;
+ rdtsc;
+ mov HiValue, edx;
+ mov LoValue, eax;
+ popad;
}
m_StartTimeHi = HiValue;
m_StartTimeLo = LoValue;
@@ -47,18 +47,19 @@ SPECIAL_TIMERS CProfiling::StartTimer(SPECIAL_TIMERS Address)
return OldTimerAddr;
}
-SPECIAL_TIMERS CProfiling::StopTimer() {
+SPECIAL_TIMERS CProfiling::StopTimer()
+{
uint32_t HiValue, LoValue;
if (m_CurrentTimerAddr == Timer_None) { return m_CurrentTimerAddr; }
#ifdef _M_IX86
_asm {
- pushad
- rdtsc
- mov HiValue, edx
- mov LoValue, eax
- popad
+ pushad;
+ rdtsc;
+ mov HiValue, edx;
+ mov LoValue, eax;
+ popad;
}
#else
g_Notify->BreakPoint(__FILE__, __LINE__);
@@ -81,7 +82,8 @@ SPECIAL_TIMERS CProfiling::StopTimer() {
return OldTimerAddr;
}
-void CProfiling::ShowCPU_Usage() {
+void CProfiling::ShowCPU_Usage()
+{
int64_t TotalTime, CPU = 0, Alist = 0, Dlist = 0, Idle = 0;
PROFILE_ENRTY Entry;
@@ -117,16 +119,19 @@ void CProfiling::ShowCPU_Usage() {
ResetCounters();
}
-void CProfiling::ResetCounters() {
+void CProfiling::ResetCounters()
+{
m_Entries.clear();
}
-struct TIMER_NAME {
+struct TIMER_NAME
+{
SPECIAL_TIMERS Timer;
- char * Name;
+ const char * Name;
};
-void CProfiling::GenerateLog() {
+void CProfiling::GenerateLog()
+{
stdstr LogFileName;
{
CLog Log;
@@ -135,20 +140,25 @@ void CProfiling::GenerateLog() {
//Get the total time
int64_t TotalTime = 0;
- for (PROFILE_ENRTY itemTime = m_Entries.begin(); itemTime != m_Entries.end(); itemTime++) {
+ for (PROFILE_ENRTY itemTime = m_Entries.begin(); itemTime != m_Entries.end(); itemTime++)
+ {
TotalTime += itemTime->second;
}
//Create a sortable list of items
std::vector ItemList;
- for (PROFILE_ENRTY Entry = m_Entries.begin(); Entry != m_Entries.end(); Entry++) {
+ for (PROFILE_ENRTY Entry = m_Entries.begin(); Entry != m_Entries.end(); Entry++)
+ {
ItemList.push_back(&(*Entry));
}
//sort the list with a basic bubble sort
- for (size_t OuterPass = 0; OuterPass < (ItemList.size() - 1); OuterPass++) {
- for (size_t InnerPass = 0; InnerPass < (ItemList.size() - 1); InnerPass++) {
- if (ItemList[InnerPass]->second < ItemList[InnerPass + 1]->second) {
+ for (size_t OuterPass = 0; OuterPass < (ItemList.size() - 1); OuterPass++)
+ {
+ for (size_t InnerPass = 0; InnerPass < (ItemList.size() - 1); InnerPass++)
+ {
+ if (ItemList[InnerPass]->second < ItemList[InnerPass + 1]->second)
+ {
PROFILE_VALUE * TempPtr = ItemList[InnerPass];
ItemList[InnerPass] = ItemList[InnerPass + 1];
ItemList[InnerPass + 1] = TempPtr;
@@ -156,7 +166,8 @@ void CProfiling::GenerateLog() {
}
}
- TIMER_NAME TimerNames[] = {
+ TIMER_NAME TimerNames[] =
+ {
{ Timer_R4300, "R4300" },
{ Timer_RSP_Dlist, "RSP: Dlist" },
{ Timer_RSP_Alist, "RSP: Alist" },
@@ -172,13 +183,16 @@ void CProfiling::GenerateLog() {
{ Timer_CompileDone, "Timer_CompileDone" },
};
- for (size_t count = 0; count < ItemList.size(); count++) {
+ for (size_t count = 0; count < ItemList.size(); count++)
+ {
char Buffer[255];
double CpuUsage = ((double)ItemList[count]->second / (double)TotalTime) * 100;
if (CpuUsage <= 0.2) { continue; }
sprintf(Buffer, "Func 0x%08X", ItemList[count]->first);
- for (int NameID = 0; NameID < (sizeof(TimerNames) / sizeof(TIMER_NAME)); NameID++) {
- if (ItemList[count]->first == TimerNames[NameID].Timer) {
+ for (int NameID = 0; NameID < (sizeof(TimerNames) / sizeof(TIMER_NAME)); NameID++)
+ {
+ if (ItemList[count]->first == TimerNames[NameID].Timer)
+ {
strcpy(Buffer, TimerNames[NameID].Name);
break;
}
diff --git a/Source/Project64-core/N64System/Recompiler/CodeSection.cpp b/Source/Project64-core/N64System/Recompiler/CodeSection.cpp
index 66d1e1dd2..9cfc153db 100644
--- a/Source/Project64-core/N64System/Recompiler/CodeSection.cpp
+++ b/Source/Project64-core/N64System/Recompiler/CodeSection.cpp
@@ -20,7 +20,6 @@
#include
#include
#include
-#include
void InPermLoop();
@@ -31,7 +30,9 @@ static bool DelaySlotEffectsJump(uint32_t JumpPC)
OPCODE Command;
if (!g_MMU->LW_VAddr(JumpPC, Command.Hex))
+ {
return true;
+ }
switch (Command.op)
{
@@ -72,29 +73,29 @@ static bool DelaySlotEffectsJump(uint32_t JumpPC)
case R4300i_COP1_BC_BCT:
case R4300i_COP1_BC_BCFL:
case R4300i_COP1_BC_BCTL:
- {
- bool EffectDelaySlot = false;
- OPCODE NewCommand;
-
- if (!g_MMU->LW_VAddr(JumpPC + 4, NewCommand.Hex))
{
- return true;
- }
+ bool EffectDelaySlot = false;
+ OPCODE NewCommand;
- if (NewCommand.op == R4300i_CP1)
- {
- if (NewCommand.fmt == R4300i_COP1_S && (NewCommand.funct & 0x30) == 0x30)
+ if (!g_MMU->LW_VAddr(JumpPC + 4, NewCommand.Hex))
{
- EffectDelaySlot = true;
+ return true;
}
- if (NewCommand.fmt == R4300i_COP1_D && (NewCommand.funct & 0x30) == 0x30)
+
+ if (NewCommand.op == R4300i_CP1)
{
- EffectDelaySlot = true;
+ if (NewCommand.fmt == R4300i_COP1_S && (NewCommand.funct & 0x30) == 0x30)
+ {
+ EffectDelaySlot = true;
+ }
+ if (NewCommand.fmt == R4300i_COP1_D && (NewCommand.funct & 0x30) == 0x30)
+ {
+ EffectDelaySlot = true;
+ }
}
+ return EffectDelaySlot;
}
- return EffectDelaySlot;
- }
- break;
+ break;
}
break;
}
@@ -109,21 +110,21 @@ static bool DelaySlotEffectsJump(uint32_t JumpPC)
}
CCodeSection::CCodeSection(CCodeBlock * CodeBlock, uint32_t EnterPC, uint32_t ID, bool LinkAllowed) :
-m_BlockInfo(CodeBlock),
-m_SectionID(ID),
-m_EnterPC(EnterPC),
-m_EndPC((uint32_t)-1),
-m_ContinueSection(NULL),
-m_JumpSection(NULL),
-m_EndSection(false),
-m_LinkAllowed(LinkAllowed),
-m_Test(0),
-m_Test2(0),
-m_CompiledLocation(NULL),
-m_InLoop(false),
-m_DelaySlot(false)
+ m_BlockInfo(CodeBlock),
+ m_SectionID(ID),
+ m_EnterPC(EnterPC),
+ m_EndPC((uint32_t)-1),
+ m_ContinueSection(NULL),
+ m_JumpSection(NULL),
+ m_EndSection(false),
+ m_LinkAllowed(LinkAllowed),
+ m_Test(0),
+ m_Test2(0),
+ m_CompiledLocation(NULL),
+ m_InLoop(false),
+ m_DelaySlot(false)
{
- CPU_Message(__FUNCTION__ ": ID %d EnterPC 0x%08X", ID, EnterPC);
+ CPU_Message("%s: ID %d EnterPC 0x%08X", __FUNCTION__, ID, EnterPC);
}
CCodeSection::~CCodeSection()
@@ -298,34 +299,34 @@ void CCodeSection::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &Exi
ExitCodeBlock();
break;
case CExitInfo::DoSysCall:
- {
- bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT;
- PushImm32(bDelay ? "true" : "false", bDelay);
- MoveConstToX86reg((uint32_t)g_Reg, x86_ECX);
- Call_Direct(AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException");
- if (g_SyncSystem)
{
- MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX);
- Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
+ bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT;
+ PushImm32(bDelay ? "true" : "false", bDelay);
+ MoveConstToX86reg((uint32_t)g_Reg, x86_ECX);
+ Call_Direct(AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException");
+ if (g_SyncSystem)
+ {
+ MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX);
+ Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
+ }
+ ExitCodeBlock();
}
- ExitCodeBlock();
- }
- break;
+ break;
case CExitInfo::COP1_Unuseable:
- {
- bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT;
- PushImm32("1", 1);
- PushImm32(bDelay ? "true" : "false", bDelay);
- MoveConstToX86reg((uint32_t)g_Reg, x86_ECX);
- Call_Direct(AddressOf(&CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException");
- if (g_SyncSystem)
{
- MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX);
- Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
+ bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT;
+ PushImm32("1", 1);
+ PushImm32(bDelay ? "true" : "false", bDelay);
+ MoveConstToX86reg((uint32_t)g_Reg, x86_ECX);
+ Call_Direct(AddressOf(&CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException");
+ if (g_SyncSystem)
+ {
+ MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX);
+ Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
+ }
+ ExitCodeBlock();
}
- ExitCodeBlock();
- }
- break;
+ break;
case CExitInfo::ExitResetRecompCode:
g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
@@ -802,137 +803,137 @@ void CCodeSection::SyncRegState(const CRegInfo & SyncTo)
{
case CRegInfo::STATE_UNKNOWN: UnMap_GPR(i, true); break;
case CRegInfo::STATE_MAPPED_64:
- {
- x86Reg Reg = SyncTo.GetMipsRegMapLo(i);
- x86Reg x86RegHi = SyncTo.GetMipsRegMapHi(i);
- UnMap_X86reg(Reg);
- UnMap_X86reg(x86RegHi);
- switch (GetMipsRegState(i))
{
- case CRegInfo::STATE_UNKNOWN:
- MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg);
- MoveVariableToX86reg(&_GPR[i].UW[1], CRegName::GPR_Hi[i], x86RegHi);
- break;
- case CRegInfo::STATE_MAPPED_64:
- MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
- m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
- MoveX86RegToX86Reg(GetMipsRegMapHi(i), x86RegHi);
- m_RegWorkingSet.SetX86Mapped(GetMipsRegMapHi(i), CRegInfo::NotMapped);
- break;
- case CRegInfo::STATE_MAPPED_32_SIGN:
- MoveX86RegToX86Reg(GetMipsRegMapLo(i), x86RegHi);
- ShiftRightSignImmed(x86RegHi, 31);
- MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
- m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
- break;
- case CRegInfo::STATE_MAPPED_32_ZERO:
- XorX86RegToX86Reg(x86RegHi, x86RegHi);
- MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
- m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
- break;
- case CRegInfo::STATE_CONST_64:
- MoveConstToX86reg(GetMipsRegHi(i), x86RegHi);
- MoveConstToX86reg(GetMipsRegLo(i), Reg);
- break;
- case CRegInfo::STATE_CONST_32_SIGN:
- MoveConstToX86reg(GetMipsRegLo_S(i) >> 31, x86RegHi);
- MoveConstToX86reg(GetMipsRegLo(i), Reg);
- break;
- default:
- CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_64\n%d", GetMipsRegState(i));
- g_Notify->BreakPoint(__FILE__, __LINE__);
- continue;
+ x86Reg Reg = SyncTo.GetMipsRegMapLo(i);
+ x86Reg x86RegHi = SyncTo.GetMipsRegMapHi(i);
+ UnMap_X86reg(Reg);
+ UnMap_X86reg(x86RegHi);
+ switch (GetMipsRegState(i))
+ {
+ case CRegInfo::STATE_UNKNOWN:
+ MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg);
+ MoveVariableToX86reg(&_GPR[i].UW[1], CRegName::GPR_Hi[i], x86RegHi);
+ break;
+ case CRegInfo::STATE_MAPPED_64:
+ MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
+ m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
+ MoveX86RegToX86Reg(GetMipsRegMapHi(i), x86RegHi);
+ m_RegWorkingSet.SetX86Mapped(GetMipsRegMapHi(i), CRegInfo::NotMapped);
+ break;
+ case CRegInfo::STATE_MAPPED_32_SIGN:
+ MoveX86RegToX86Reg(GetMipsRegMapLo(i), x86RegHi);
+ ShiftRightSignImmed(x86RegHi, 31);
+ MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
+ m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
+ break;
+ case CRegInfo::STATE_MAPPED_32_ZERO:
+ XorX86RegToX86Reg(x86RegHi, x86RegHi);
+ MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
+ m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
+ break;
+ case CRegInfo::STATE_CONST_64:
+ MoveConstToX86reg(GetMipsRegHi(i), x86RegHi);
+ MoveConstToX86reg(GetMipsRegLo(i), Reg);
+ break;
+ case CRegInfo::STATE_CONST_32_SIGN:
+ MoveConstToX86reg(GetMipsRegLo_S(i) >> 31, x86RegHi);
+ MoveConstToX86reg(GetMipsRegLo(i), Reg);
+ break;
+ default:
+ CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_64\n%d", GetMipsRegState(i));
+ g_Notify->BreakPoint(__FILE__, __LINE__);
+ continue;
+ }
+ m_RegWorkingSet.SetMipsRegMapLo(i, Reg);
+ m_RegWorkingSet.SetMipsRegMapHi(i, x86RegHi);
+ m_RegWorkingSet.SetMipsRegState(i, CRegInfo::STATE_MAPPED_64);
+ m_RegWorkingSet.SetX86Mapped(Reg, CRegInfo::GPR_Mapped);
+ m_RegWorkingSet.SetX86Mapped(x86RegHi, CRegInfo::GPR_Mapped);
+ m_RegWorkingSet.SetX86MapOrder(Reg, 1);
+ m_RegWorkingSet.SetX86MapOrder(x86RegHi, 1);
}
- m_RegWorkingSet.SetMipsRegMapLo(i, Reg);
- m_RegWorkingSet.SetMipsRegMapHi(i, x86RegHi);
- m_RegWorkingSet.SetMipsRegState(i, CRegInfo::STATE_MAPPED_64);
- m_RegWorkingSet.SetX86Mapped(Reg, CRegInfo::GPR_Mapped);
- m_RegWorkingSet.SetX86Mapped(x86RegHi, CRegInfo::GPR_Mapped);
- m_RegWorkingSet.SetX86MapOrder(Reg, 1);
- m_RegWorkingSet.SetX86MapOrder(x86RegHi, 1);
- }
- break;
+ break;
case CRegInfo::STATE_MAPPED_32_SIGN:
- {
- x86Reg Reg = SyncTo.GetMipsRegMapLo(i);
- UnMap_X86reg(Reg);
- switch (GetMipsRegState(i))
{
- case CRegInfo::STATE_UNKNOWN: MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); break;
- case CRegInfo::STATE_CONST_32_SIGN: MoveConstToX86reg(GetMipsRegLo(i), Reg); break;
- case CRegInfo::STATE_MAPPED_32_SIGN:
- MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
- m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
- break;
- case CRegInfo::STATE_MAPPED_32_ZERO:
- if (GetMipsRegMapLo(i) != Reg)
+ x86Reg Reg = SyncTo.GetMipsRegMapLo(i);
+ UnMap_X86reg(Reg);
+ switch (GetMipsRegState(i))
{
+ case CRegInfo::STATE_UNKNOWN: MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); break;
+ case CRegInfo::STATE_CONST_32_SIGN: MoveConstToX86reg(GetMipsRegLo(i), Reg); break;
+ case CRegInfo::STATE_MAPPED_32_SIGN:
MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
+ break;
+ case CRegInfo::STATE_MAPPED_32_ZERO:
+ if (GetMipsRegMapLo(i) != Reg)
+ {
+ MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
+ m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
+ }
+ break;
+ case CRegInfo::STATE_MAPPED_64:
+ MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
+ m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
+ m_RegWorkingSet.SetX86Mapped(GetMipsRegMapHi(i), CRegInfo::NotMapped);
+ break;
+ case CRegInfo::STATE_CONST_64:
+ CPU_Message("hi %X\nLo %X", GetMipsRegHi(i), GetMipsRegLo(i));
+ default:
+ CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_SIGN\n%d", GetMipsRegState(i));
+ g_Notify->BreakPoint(__FILE__, __LINE__);
}
- break;
- case CRegInfo::STATE_MAPPED_64:
- MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
- m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
- m_RegWorkingSet.SetX86Mapped(GetMipsRegMapHi(i), CRegInfo::NotMapped);
- break;
- case CRegInfo::STATE_CONST_64:
- CPU_Message("hi %X\nLo %X", GetMipsRegHi(i), GetMipsRegLo(i));
- default:
- CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_SIGN\n%d", GetMipsRegState(i));
- g_Notify->BreakPoint(__FILE__, __LINE__);
+ m_RegWorkingSet.SetMipsRegMapLo(i, Reg);
+ m_RegWorkingSet.SetMipsRegState(i, CRegInfo::STATE_MAPPED_32_SIGN);
+ m_RegWorkingSet.SetX86Mapped(Reg, CRegInfo::GPR_Mapped);
+ m_RegWorkingSet.SetX86MapOrder(Reg, 1);
}
- m_RegWorkingSet.SetMipsRegMapLo(i, Reg);
- m_RegWorkingSet.SetMipsRegState(i, CRegInfo::STATE_MAPPED_32_SIGN);
- m_RegWorkingSet.SetX86Mapped(Reg, CRegInfo::GPR_Mapped);
- m_RegWorkingSet.SetX86MapOrder(Reg, 1);
- }
- break;
+ break;
case CRegInfo::STATE_MAPPED_32_ZERO:
- {
- x86Reg Reg = SyncTo.GetMipsRegMapLo(i);
- UnMap_X86reg(Reg);
- switch (GetMipsRegState(i))
{
- case CRegInfo::STATE_MAPPED_64:
- case CRegInfo::STATE_UNKNOWN:
- MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg);
- break;
- case CRegInfo::STATE_MAPPED_32_ZERO:
- MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
- m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
- break;
- case CRegInfo::STATE_MAPPED_32_SIGN:
- if (g_System->b32BitCore())
+ x86Reg Reg = SyncTo.GetMipsRegMapLo(i);
+ UnMap_X86reg(Reg);
+ switch (GetMipsRegState(i))
{
+ case CRegInfo::STATE_MAPPED_64:
+ case CRegInfo::STATE_UNKNOWN:
+ MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg);
+ break;
+ case CRegInfo::STATE_MAPPED_32_ZERO:
MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
- }
- else
- {
+ break;
+ case CRegInfo::STATE_MAPPED_32_SIGN:
+ if (g_System->b32BitCore())
+ {
+ MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg);
+ m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped);
+ }
+ else
+ {
+ CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d", GetMipsRegState(i));
+ g_Notify->BreakPoint(__FILE__, __LINE__);
+ }
+ break;
+ case CRegInfo::STATE_CONST_32_SIGN:
+ if (!g_System->b32BitCore() && GetMipsRegLo_S(i) < 0)
+ {
+ CPU_Message("Sign Problems in SyncRegState\nSTATE_MAPPED_32_ZERO");
+ CPU_Message("%s: %X", CRegName::GPR[i], GetMipsRegLo_S(i));
+ g_Notify->BreakPoint(__FILE__, __LINE__);
+ }
+ MoveConstToX86reg(GetMipsRegLo(i), Reg);
+ break;
+ default:
CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d", GetMipsRegState(i));
g_Notify->BreakPoint(__FILE__, __LINE__);
}
- break;
- case CRegInfo::STATE_CONST_32_SIGN:
- if (!g_System->b32BitCore() && GetMipsRegLo_S(i) < 0)
- {
- CPU_Message("Sign Problems in SyncRegState\nSTATE_MAPPED_32_ZERO");
- CPU_Message("%s: %X", CRegName::GPR[i], GetMipsRegLo_S(i));
- g_Notify->BreakPoint(__FILE__, __LINE__);
- }
- MoveConstToX86reg(GetMipsRegLo(i), Reg);
- break;
- default:
- CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d", GetMipsRegState(i));
- g_Notify->BreakPoint(__FILE__, __LINE__);
+ m_RegWorkingSet.SetMipsRegMapLo(i, Reg);
+ m_RegWorkingSet.SetMipsRegState(i, SyncTo.GetMipsRegState(i));
+ m_RegWorkingSet.SetX86Mapped(Reg, CRegInfo::GPR_Mapped);
+ m_RegWorkingSet.SetX86MapOrder(Reg, 1);
}
- m_RegWorkingSet.SetMipsRegMapLo(i, Reg);
- m_RegWorkingSet.SetMipsRegState(i, SyncTo.GetMipsRegState(i));
- m_RegWorkingSet.SetX86Mapped(Reg, CRegInfo::GPR_Mapped);
- m_RegWorkingSet.SetX86MapOrder(Reg, 1);
- }
- break;
+ break;
default:
CPU_Message("%d - %d reg: %s (%d)", SyncTo.GetMipsRegState(i), GetMipsRegState(i), CRegName::GPR[i], i);
g_Notify->BreakPoint(__FILE__, __LINE__);
@@ -1035,14 +1036,14 @@ bool CCodeSection::GenerateX86Code(uint32_t Test)
do
{
- __try
+ __except_try()
{
if (!g_MMU->LW_VAddr(m_CompilePC, m_Opcode.Hex))
{
g_Notify->FatalError(GS(MSG_FAIL_LOAD_WORD));
}
}
- __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation()))
+ __except_catch()
{
g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION));
}
@@ -1659,7 +1660,7 @@ void CCodeSection::UnlinkParent(CCodeSection * Parent, bool ContinueSection)
return;
}
- CPU_Message(__FUNCTION__ ": Section %d Parent: %d ContinueSection = %s", m_SectionID, Parent->m_SectionID, ContinueSection ? "Yes" : "No");
+ CPU_Message("%s: Section %d Parent: %d ContinueSection = %s", __FUNCTION__, m_SectionID, Parent->m_SectionID, ContinueSection ? "Yes" : "No");
if (Parent->m_ContinueSection == this && Parent->m_JumpSection == this)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerClass.cpp b/Source/Project64-core/N64System/Recompiler/RecompilerClass.cpp
index a0b3e8adf..e85867ef3 100644
--- a/Source/Project64-core/N64System/Recompiler/RecompilerClass.cpp
+++ b/Source/Project64-core/N64System/Recompiler/RecompilerClass.cpp
@@ -15,7 +15,6 @@
#include
#include
#include
-#include
CRecompiler::CRecompiler(CRegisters & Registers, CProfiling & Profile, bool & EndEmulation) :
m_Registers(Registers),
@@ -36,7 +35,6 @@ CRecompiler::~CRecompiler()
void CRecompiler::Run()
{
- CoInitialize(NULL);
if (bLogX86Code())
{
Start_x86_Log();
@@ -57,7 +55,7 @@ void CRecompiler::Run()
#ifdef legacycode
*g_MemoryStack = (uint32_t)(RDRAM+(_GPR[29].W[0] & 0x1FFFFFFF));
#endif
- __try
+ __except_try()
{
if (g_System->LookUpMode() == FuncFind_VirtualLookup)
{
@@ -100,7 +98,7 @@ void CRecompiler::Run()
}
}
}
- __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation()))
+ __except_catch()
{
g_Notify->DisplayError(MSG_UNKNOWN_MEM_ACTION);
}
@@ -945,7 +943,7 @@ CCompiledFunc * CRecompiler::CompilerCode()
}
CCompiledFunc * Func = new CCompiledFunc(CodeBlock);
- CCompiledFuncList::_Pairib ret = m_Functions.insert(CCompiledFuncList::value_type(Func->EnterPC(), Func));
+ std::pair ret = m_Functions.insert(CCompiledFuncList::value_type(Func->EnterPC(), Func));
if (ret.second == false)
{
Func->SetNext(ret.first->second->Next());
@@ -1048,7 +1046,7 @@ void CRecompiler::ResetMemoryStackPos()
}
if (m_Registers.m_GPR[29].UW[0] == 0)
{
- m_MemoryStack = NULL;
+ m_MemoryStack = 0;
return;
}
diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp b/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp
index 1d852f692..7bd359adb 100644
--- a/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp
+++ b/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp
@@ -13,7 +13,6 @@
#include
#include
#include
-#include
CRecompMemory::CRecompMemory() :
m_RecompCode(NULL),
@@ -26,7 +25,7 @@ CRecompMemory::~CRecompMemory()
{
if (m_RecompCode)
{
- VirtualFree(m_RecompCode, 0, MEM_RELEASE);
+ FreeAddressSpace(m_RecompCode,MaxCompileBufferSize + 4);
m_RecompCode = NULL;
}
m_RecompPos = NULL;
@@ -34,7 +33,7 @@ CRecompMemory::~CRecompMemory()
bool CRecompMemory::AllocateMemory()
{
- uint8_t * RecompCodeBase = (uint8_t *)VirtualAlloc(NULL, MaxCompileBufferSize + 4, MEM_RESERVE | MEM_TOP_DOWN, PAGE_EXECUTE_READWRITE);
+ uint8_t * RecompCodeBase = (uint8_t *)AllocateAddressSpace(MaxCompileBufferSize + 4);
if (RecompCodeBase == NULL)
{
WriteTrace(TraceRecompiler, TraceError, "failed to allocate RecompCodeBase");
@@ -42,11 +41,11 @@ bool CRecompMemory::AllocateMemory()
return false;
}
- m_RecompCode = (uint8_t *)VirtualAlloc(RecompCodeBase, InitialCompileBufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ m_RecompCode = (uint8_t *)CommitMemory(RecompCodeBase, InitialCompileBufferSize, MEM_EXECUTE_READWRITE);
if (m_RecompCode == NULL)
{
WriteTrace(TraceRecompiler, TraceError, "failed to commit initial buffer");
- VirtualFree(RecompCodeBase, 0, MEM_RELEASE);
+ FreeAddressSpace(RecompCodeBase,MaxCompileBufferSize + 4);
g_Notify->DisplayError(MSG_MEM_ALLOC_ERROR);
return false;
}
@@ -68,7 +67,7 @@ void CRecompMemory::CheckRecompMem()
g_Recompiler->ResetRecompCode(true);
return;
}
- LPVOID MemAddr = VirtualAlloc(m_RecompCode + m_RecompSize, IncreaseCompileBufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ void * MemAddr = CommitMemory(m_RecompCode + m_RecompSize, IncreaseCompileBufferSize, MEM_EXECUTE_READWRITE);
if (MemAddr == NULL)
{
WriteTrace(TraceRecompiler, TraceError, "failed to increase buffer");
diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/RecompilerOps.cpp
index 57f704e5d..7e478a0b4 100644
--- a/Source/Project64-core/N64System/Recompiler/RecompilerOps.cpp
+++ b/Source/Project64-core/N64System/Recompiler/RecompilerOps.cpp
@@ -2300,7 +2300,7 @@ void CRecompilerOps::DADDIU()
BeforeCallDirect(m_RegWorkingSet);
MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex");
- Call_Direct(R4300iOp::DADDIU, "R4300iOp::DADDIU");
+ Call_Direct((void *)R4300iOp::DADDIU, "R4300iOp::DADDIU");
AfterCallDirect(m_RegWorkingSet);
}
@@ -3191,7 +3191,7 @@ void CRecompilerOps::SPECIAL_DMULT()
BeforeCallDirect(m_RegWorkingSet);
MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex");
- Call_Direct(R4300iOp::SPECIAL_DMULT, "R4300iOp::SPECIAL_DMULT");
+ Call_Direct((void *)R4300iOp::SPECIAL_DMULT, "R4300iOp::SPECIAL_DMULT");
AfterCallDirect(m_RegWorkingSet);
}
@@ -3203,7 +3203,7 @@ void CRecompilerOps::SPECIAL_DMULTU()
UnMap_GPR(m_Opcode.rt, true);
BeforeCallDirect(m_RegWorkingSet);
MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex");
- Call_Direct(R4300iOp::SPECIAL_DMULTU, "R4300iOp::SPECIAL_DMULTU");
+ Call_Direct((void *)R4300iOp::SPECIAL_DMULTU, "R4300iOp::SPECIAL_DMULTU");
AfterCallDirect(m_RegWorkingSet);
#ifdef toremove
@@ -3282,7 +3282,7 @@ void CRecompilerOps::SPECIAL_DDIV()
UnMap_GPR(m_Opcode.rt, true);
BeforeCallDirect(m_RegWorkingSet);
MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex");
- Call_Direct(R4300iOp::SPECIAL_DDIV, "R4300iOp::SPECIAL_DDIV");
+ Call_Direct((void *)R4300iOp::SPECIAL_DDIV, "R4300iOp::SPECIAL_DDIV");
AfterCallDirect(m_RegWorkingSet);
}
@@ -3294,7 +3294,7 @@ void CRecompilerOps::SPECIAL_DDIVU()
UnMap_GPR(m_Opcode.rt, true);
BeforeCallDirect(m_RegWorkingSet);
MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex");
- Call_Direct(R4300iOp::SPECIAL_DDIVU, "R4300iOp::SPECIAL_DDIVU");
+ Call_Direct((void *)R4300iOp::SPECIAL_DDIVU, "R4300iOp::SPECIAL_DDIVU");
AfterCallDirect(m_RegWorkingSet);
}
@@ -4876,7 +4876,7 @@ void CRecompilerOps::SPECIAL_DADDU()
if (IsConst(source2))
{
AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegLo(source2));
- AddConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegHi(source2));
+ AdcConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegHi(source2));
}
else if (IsMapped(source2))
{
@@ -5563,7 +5563,7 @@ void CRecompilerOps::COP0_CO_ERET(void)
CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC));
m_RegWorkingSet.WriteBackRegisters();
- Call_Direct(compiler_COP0_CO_ERET, "compiler_COP0_CO_ERET");
+ Call_Direct((void *)compiler_COP0_CO_ERET, "compiler_COP0_CO_ERET");
UpdateCounters(m_RegWorkingSet, true, true);
m_Section->CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL);
@@ -5573,11 +5573,12 @@ void CRecompilerOps::COP0_CO_ERET(void)
/************************** FPU Options **************************/
void CRecompilerOps::ChangeDefaultRoundingModel()
{
- switch ((_FPCR[31] & 3)) {
- case 0: *_RoundingModel = ROUND_NEAR; break;
- case 1: *_RoundingModel = ROUND_CHOP; break;
- case 2: *_RoundingModel = ROUND_UP; break;
- case 3: *_RoundingModel = ROUND_DOWN; break;
+ switch ((_FPCR[31] & 3))
+ {
+ case 0: *_RoundingModel = FE_TONEAREST; break;
+ case 1: *_RoundingModel = FE_TOWARDZERO; break;
+ case 2: *_RoundingModel = FE_UPWARD; break;
+ case 3: *_RoundingModel = FE_DOWNWARD; break;
}
}
@@ -5746,7 +5747,7 @@ void CRecompilerOps::COP1_CT()
MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_FPCR[m_Opcode.fs], CRegName::FPR_Ctrl[m_Opcode.fs]);
}
BeforeCallDirect(m_RegWorkingSet);
- Call_Direct(ChangeDefaultRoundingModel, "ChangeDefaultRoundingModel");
+ Call_Direct((void *)ChangeDefaultRoundingModel, "ChangeDefaultRoundingModel");
AfterCallDirect(m_RegWorkingSet);
m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown);
}
@@ -6578,7 +6579,7 @@ void CRecompilerOps::UnknownOpcode()
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp());
MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex");
- Call_Direct(R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode");
+ Call_Direct((void *)R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode");
Ret();
if (m_NextInstruction == NORMAL) { m_NextInstruction = END_BLOCK; }
}
@@ -6712,7 +6713,7 @@ void CRecompilerOps::OverflowDelaySlot(bool TestTimer)
}
PushImm32("g_System->CountPerOp()", g_System->CountPerOp());
- Call_Direct(CInterpreterCPU::ExecuteOps, "CInterpreterCPU::ExecuteOps");
+ Call_Direct((void *)CInterpreterCPU::ExecuteOps, "CInterpreterCPU::ExecuteOps");
AddConstToX86Reg(x86_ESP, 4);
if (g_System->bFastSP() && g_Recompiler)
diff --git a/Source/Project64-core/N64System/Recompiler/RegInfo.cpp b/Source/Project64-core/N64System/Recompiler/RegInfo.cpp
index 1d3b705b8..510ce69cc 100644
--- a/Source/Project64-core/N64System/Recompiler/RegInfo.cpp
+++ b/Source/Project64-core/N64System/Recompiler/RegInfo.cpp
@@ -16,11 +16,12 @@
#include
#include
+#include
#include "x86CodeLog.h"
uint32_t CRegInfo::m_fpuControl = 0;
-char *Format_Name[] = { "Unknown", "dword", "qword", "float", "double" };
+const char *Format_Name[] = { "Unknown", "dword", "qword", "float", "double" };
CRegInfo::CRegInfo() :
m_CycleCount(0),
@@ -160,8 +161,12 @@ void CRegInfo::FixRoundModel(FPU_ROUND RoundMethod)
if (RoundMethod == RoundDefault)
{
+ static const unsigned int msRound[4] = { _RC_NEAR, _RC_CHOP, _RC_UP, _RC_DOWN };
+
x86Reg RoundReg = Map_TempReg(x86_Any, -1, false);
MoveVariableToX86reg(&g_Reg->m_RoundingModel, "m_RoundingModel", RoundReg);
+ MoveVariableDispToX86Reg((void *)&msRound[0], "msRound", RoundReg, RoundReg, Multip_x4);
+
ShiftLeftSignImmed(RoundReg, 2);
OrX86RegToX86Reg(reg, RoundReg);
SetX86Protected(RoundReg, false);
@@ -526,7 +531,7 @@ CX86Ops::x86Reg CRegInfo::UnMap_8BitTempReg()
for (count = 0; count < 10; count++)
{
if (!Is8BitReg((x86Reg)count)) { continue; }
- if (GetMipsRegState((x86Reg)count) == Temp_Mapped)
+ if (GetX86Mapped((x86Reg)count) == Temp_Mapped)
{
if (GetX86Protected((x86Reg)count) == false)
{
diff --git a/Source/Project64-core/N64System/Recompiler/X86ops.cpp b/Source/Project64-core/N64System/Recompiler/X86ops.cpp
index 21983b5bf..c1b681bd3 100644
--- a/Source/Project64-core/N64System/Recompiler/X86ops.cpp
+++ b/Source/Project64-core/N64System/Recompiler/X86ops.cpp
@@ -11,7 +11,7 @@
#include "stdafx.h"
#include
#include
-#include "X86ops.h"
+#include
#include "x86CodeLog.h"
#define PUTDST8(dest,value) (*((uint8_t *)(dest))=(uint8_t)(value)); dest += 1;
@@ -211,7 +211,7 @@ void CX86Ops::X86BreakPoint(const char * FileName, int LineNumber)
Pushad();
PushImm32(stdstr_f("%d", LineNumber).c_str(), LineNumber);
PushImm32(FileName, (uint32_t)FileName);
- Call_Direct(BreakPointNotification, "BreakPointNotification");
+ Call_Direct((void *)BreakPointNotification, "BreakPointNotification");
AddConstToX86Reg(x86_ESP, 8);
Popad();
}
diff --git a/Source/Project64-core/N64System/SpeedLimiterClass.cpp b/Source/Project64-core/N64System/SpeedLimiterClass.cpp
index d44d66578..f090d53cb 100644
--- a/Source/Project64-core/N64System/SpeedLimiterClass.cpp
+++ b/Source/Project64-core/N64System/SpeedLimiterClass.cpp
@@ -11,10 +11,11 @@
#include "stdafx.h"
#include "SpeedLimiterClass.h"
#include
+#ifdef _WIN32
#include
#include
-
#pragma comment(lib, "winmm.lib")
+#endif
CSpeedLimiter::CSpeedLimiter()
{
@@ -24,19 +25,23 @@ CSpeedLimiter::CSpeedLimiter()
m_BaseSpeed = 60;
m_Ratio = 1000.0F / (float)m_Speed;
+#ifdef _WIN32
TIMECAPS Caps;
timeGetDevCaps(&Caps, sizeof(Caps));
if (timeBeginPeriod(Caps.wPeriodMin) == TIMERR_NOCANDO)
{
g_Notify->DisplayError("Error during timer begin");
}
+#endif
}
CSpeedLimiter::~CSpeedLimiter()
{
+#ifdef _WIN32
TIMECAPS Caps;
timeGetDevCaps(&Caps, sizeof(Caps));
timeEndPeriod(Caps.wPeriodMin);
+#endif
}
void CSpeedLimiter::SetHertz(uint32_t Hertz)
@@ -50,11 +55,14 @@ void CSpeedLimiter::FixSpeedRatio()
{
m_Ratio = 1000.0f / static_cast(m_Speed);
m_Frames = 0;
+#ifdef _WIN32
m_LastTime = timeGetTime();
+#endif
}
bool CSpeedLimiter::Timer_Process(uint32_t * FrameRate)
{
+#ifdef _WIN32
m_Frames += 1;
uint32_t CurrentTime = timeGetTime();
@@ -85,6 +93,9 @@ bool CSpeedLimiter::Timer_Process(uint32_t * FrameRate)
{
return false;
}
+#else
+ return false;
+#endif
}
void CSpeedLimiter::IncreaseSpeed()
diff --git a/Source/Project64-core/N64System/SystemGlobals.cpp b/Source/Project64-core/N64System/SystemGlobals.cpp
index edf1c2678..6ab72f809 100644
--- a/Source/Project64-core/N64System/SystemGlobals.cpp
+++ b/Source/Project64-core/N64System/SystemGlobals.cpp
@@ -21,6 +21,7 @@ CRegisters * g_Reg = NULL; //Current Register Set attacted to the g_MMU
CNotification * g_Notify = NULL;
CPlugins * g_Plugins = NULL;
CN64Rom * g_Rom = NULL; //The current rom that this system is executing.. it can only execute one file at the time
+CN64Rom * g_DDRom = NULL; //64DD IPL ROM
CAudio * g_Audio = NULL;
CSystemTimer * g_SystemTimer = NULL;
CTransVaddr * g_TransVaddr = NULL;
diff --git a/Source/Project64-core/N64System/SystemGlobals.h b/Source/Project64-core/N64System/SystemGlobals.h
index 50951ffa5..cd279afaf 100644
--- a/Source/Project64-core/N64System/SystemGlobals.h
+++ b/Source/Project64-core/N64System/SystemGlobals.h
@@ -35,6 +35,7 @@ extern CPlugins * g_Plugins;
class CN64Rom;
extern CN64Rom * g_Rom; //The current rom that this system is executing.. it can only execute one file at the time
+extern CN64Rom * g_DDRom; //64DD IPL ROM
class CAudio;
extern CAudio * g_Audio;
diff --git a/Source/Project64-core/Plugins/AudioPlugin.cpp b/Source/Project64-core/Plugins/AudioPlugin.cpp
index 20c0732a3..dd8749d56 100644
--- a/Source/Project64-core/Plugins/AudioPlugin.cpp
+++ b/Source/Project64-core/Plugins/AudioPlugin.cpp
@@ -14,16 +14,18 @@
#include
#include
#include
-#include "AudioPlugin.h"
+#include
+#ifdef _WIN32
#include
+#endif
CAudioPlugin::CAudioPlugin() :
-AiLenChanged(NULL),
-AiReadLength(NULL),
-ProcessAList(NULL),
-m_hAudioThread(NULL),
-AiUpdate(NULL),
-AiDacrateChanged(NULL)
+ AiLenChanged(NULL),
+ AiReadLength(NULL),
+ ProcessAList(NULL),
+ m_hAudioThread(NULL),
+ AiUpdate(NULL),
+ AiDacrateChanged(NULL)
{
}
@@ -36,7 +38,7 @@ CAudioPlugin::~CAudioPlugin()
bool CAudioPlugin::LoadFunctions(void)
{
// Find entries for functions in DLL
- void(__cdecl *InitiateAudio) (void);
+ void(CALL *InitiateAudio)(void);
LoadFunction(InitiateAudio);
LoadFunction(AiDacrateChanged);
LoadFunction(AiLenChanged);
@@ -62,8 +64,8 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window)
{
struct AUDIO_INFO
{
- HWND hwnd;
- HINSTANCE hinst;
+ void * hwnd;
+ void * hinst;
int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre
@@ -85,19 +87,19 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window)
uint32_t * AI__DACRATE_REG;
uint32_t * AI__BITRATE_REG;
- void(__cdecl *CheckInterrupts)(void);
+ void(CALL *CheckInterrupts)(void);
};
//Get Function from DLL
- int32_t(__cdecl *InitiateAudio)(AUDIO_INFO Audio_Info);
+ int32_t(CALL *InitiateAudio)(AUDIO_INFO Audio_Info);
LoadFunction(InitiateAudio);
if (InitiateAudio == NULL) { return false; }
AUDIO_INFO Info = { 0 };
- Info.hwnd = (HWND)Window->GetWindowHandle();
- Info.hinst = GetModuleHandle(NULL);
- Info.MemoryBswaped = TRUE;
+ Info.hwnd = Window ? Window->GetWindowHandle() : NULL;
+ Info.hinst = Window ? Window->GetModuleInstance() : NULL;;
+ Info.MemoryBswaped = true;
Info.CheckInterrupts = DummyCheckInterrupts;
// We are initializing the plugin before any rom is loaded so we do not have any correct
@@ -137,10 +139,9 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window)
m_Initialized = InitiateAudio(Info) != 0;
- //jabo had a bug so I call CreateThread so his dllmain gets called again
- DWORD ThreadID;
- HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
- CloseHandle(hthread);
+#ifdef _WIN32
+ //jabo had a bug so I call CreateThread so his dllmain gets called again
+ pjutil::DynLibCallDllMain();
if (System != NULL)
{
@@ -151,6 +152,7 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window)
WriteTrace(TraceAudioPlugin, TraceDebug, "Terminate Audio Thread");
TerminateThread(m_hAudioThread, 0);
}
+ DWORD ThreadID;
m_hAudioThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)AudioThread, (LPVOID)this, 0, &ThreadID);
}
@@ -159,18 +161,21 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window)
DacrateChanged(System->SystemType());
}
}
+#endif
return m_Initialized;
}
void CAudioPlugin::UnloadPluginDetails(void)
{
+#ifdef _WIN32
if (m_hAudioThread)
{
WriteTrace(TraceAudioPlugin, TraceDebug, "Terminate Audio Thread");
TerminateThread(m_hAudioThread, 0);
m_hAudioThread = NULL;
}
- AiDacrateChanged = NULL;
+#endif
+ AiDacrateChanged = NULL;
AiLenChanged = NULL;
AiReadLength = NULL;
AiUpdate = NULL;
@@ -187,6 +192,7 @@ void CAudioPlugin::DacrateChanged(SYSTEM_TYPE Type)
AiDacrateChanged(Type);
}
+#ifdef _WIN32
void CAudioPlugin::AudioThread(CAudioPlugin * _this)
{
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
@@ -198,4 +204,5 @@ void CAudioPlugin::AudioThread(CAudioPlugin * _this)
{
_this->AiUpdate(true);
}
-}
\ No newline at end of file
+}
+#endif
diff --git a/Source/Project64-core/Plugins/AudioPlugin.h b/Source/Project64-core/Plugins/AudioPlugin.h
index 0f6112f9f..97a924bae 100644
--- a/Source/Project64-core/Plugins/AudioPlugin.h
+++ b/Source/Project64-core/Plugins/AudioPlugin.h
@@ -9,7 +9,7 @@
* *
****************************************************************************/
#pragma once
-#include "PluginBase.h"
+#include
class CAudioPlugin : public CPlugin
{
diff --git a/Source/Project64-core/Plugins/ControllerPlugin.cpp b/Source/Project64-core/Plugins/ControllerPlugin.cpp
index 2ecabf1a4..5a6854455 100644
--- a/Source/Project64-core/Plugins/ControllerPlugin.cpp
+++ b/Source/Project64-core/Plugins/ControllerPlugin.cpp
@@ -13,16 +13,15 @@
#include
#include
#include "ControllerPlugin.h"
-#include
CControl_Plugin::CControl_Plugin(void) :
-WM_KeyDown(NULL),
-WM_KeyUp(NULL),
-RumbleCommand(NULL),
-GetKeys(NULL),
-ReadController(NULL),
-ControllerCommand(NULL),
-m_AllocatedControllers(false)
+ WM_KeyDown(NULL),
+ WM_KeyUp(NULL),
+ RumbleCommand(NULL),
+ GetKeys(NULL),
+ ReadController(NULL),
+ ControllerCommand(NULL),
+ m_AllocatedControllers(false)
{
memset(&m_PluginControllers, 0, sizeof(m_PluginControllers));
memset(&m_Controllers, 0, sizeof(m_Controllers));
@@ -37,7 +36,7 @@ CControl_Plugin::~CControl_Plugin()
bool CControl_Plugin::LoadFunctions(void)
{
// Find entries for functions in DLL
- void(__cdecl *InitiateControllers)(void);
+ void(CALL *InitiateControllers)(void);
LoadFunction(InitiateControllers);
LoadFunction(ControllerCommand);
LoadFunction(GetKeys);
@@ -65,60 +64,60 @@ bool CControl_Plugin::LoadFunctions(void)
bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window)
{
- CONTROL_INFO ControlInfo;
uint8_t Buffer[100];
for (int32_t i = 0; i < 4; i++)
{
- m_PluginControllers[i].Present = FALSE;
- m_PluginControllers[i].RawData = FALSE;
+ m_PluginControllers[i].Present = false;
+ m_PluginControllers[i].RawData = false;
m_PluginControllers[i].Plugin = PLUGIN_NONE;
}
- if (m_PluginInfo.Version >= 0x0101)
- {
- ControlInfo.Controls = m_PluginControllers;
- ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress());
- ControlInfo.hinst = GetModuleHandle(NULL);
- ControlInfo.hMainWindow = Window ? (HWND)Window->GetWindowHandle() : NULL;
- ControlInfo.MemoryBswaped = TRUE;
- }
-
// Test Plugin version
if (m_PluginInfo.Version == 0x0100)
{
//Get Function from DLL
- void(__cdecl *InitiateControllers_1_0)(HWND hMainWindow, CONTROL Controls[4]);
- InitiateControllers_1_0 = (void(__cdecl *)(HWND, CONTROL *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers");
+ void(CALL *InitiateControllers_1_0)(void * hMainWindow, CONTROL Controls[4]);
+ _LoadFunction("InitiateControllers",InitiateControllers_1_0);
if (InitiateControllers_1_0 == NULL) { return false; }
- InitiateControllers_1_0((HWND)Window->GetWindowHandle(), m_PluginControllers);
+ InitiateControllers_1_0(Window->GetWindowHandle(), m_PluginControllers);
m_Initialized = true;
}
- else if (m_PluginInfo.Version == 0x0101)
+ else if (m_PluginInfo.Version >= 0x0101)
{
- //Get Function from DLL
- void(__cdecl *InitiateControllers_1_1)(CONTROL_INFO ControlInfo);
- InitiateControllers_1_1 = (void(__cdecl *)(CONTROL_INFO))GetProcAddress((HMODULE)m_hDll, "InitiateControllers");
- if (InitiateControllers_1_1 == NULL) { return false; }
+ CONTROL_INFO ControlInfo;
+ ControlInfo.Controls = m_PluginControllers;
+ ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress());
+ ControlInfo.hinst = Window ? Window->GetModuleInstance() : NULL;
+ ControlInfo.hMainWindow = Window ? Window->GetWindowHandle() : NULL;
+ ControlInfo.MemoryBswaped = true;
- InitiateControllers_1_1(ControlInfo);
- m_Initialized = true;
- }
- else if (m_PluginInfo.Version >= 0x0102)
- {
- //Get Function from DLL
- void(__cdecl *InitiateControllers_1_2)(CONTROL_INFO * ControlInfo);
- InitiateControllers_1_2 = (void(__cdecl *)(CONTROL_INFO *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers");
- if (InitiateControllers_1_2 == NULL) { return false; }
+ if (m_PluginInfo.Version == 0x0101)
+ {
+ //Get Function from DLL
+ void(CALL *InitiateControllers_1_1)(CONTROL_INFO ControlInfo);
+ _LoadFunction("InitiateControllers",InitiateControllers_1_1);
+ if (InitiateControllers_1_1 == NULL) { return false; }
- InitiateControllers_1_2(&ControlInfo);
- m_Initialized = true;
+ InitiateControllers_1_1(ControlInfo);
+ m_Initialized = true;
+ }
+ else if (m_PluginInfo.Version >= 0x0102)
+ {
+ //Get Function from DLL
+ void(CALL *InitiateControllers_1_2)(CONTROL_INFO * ControlInfo);
+ _LoadFunction("InitiateControllers",InitiateControllers_1_2);
+ if (InitiateControllers_1_2 == NULL) { return false; }
+
+ InitiateControllers_1_2(&ControlInfo);
+ m_Initialized = true;
+ }
}
- //jabo had a bug so I call CreateThread so his dllmain gets called again
- DWORD ThreadID;
- HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
- CloseHandle(hthread);
+#ifdef _WIN32
+ //jabo had a bug so I call CreateThread so his dllmain gets called again
+ pjutil::DynLibCallDllMain();
+#endif
return m_Initialized;
}
@@ -178,7 +177,7 @@ void CControl_Plugin::SetControl(CControl_Plugin const * const Plugin)
}
CCONTROL::CCONTROL(int32_t &Present, int32_t &RawData, int32_t &PlugType) :
-m_Present(Present), m_RawData(RawData), m_PlugType(PlugType)
+ m_Present(Present), m_RawData(RawData), m_PlugType(PlugType)
{
m_Buttons.Value = 0;
}
diff --git a/Source/Project64-core/Plugins/ControllerPlugin.h b/Source/Project64-core/Plugins/ControllerPlugin.h
index 862a7e79e..6923174f5 100644
--- a/Source/Project64-core/Plugins/ControllerPlugin.h
+++ b/Source/Project64-core/Plugins/ControllerPlugin.h
@@ -9,7 +9,7 @@
* *
****************************************************************************/
#pragma once
-#include "PluginBase.h"
+#include
#pragma warning(push)
#pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union
diff --git a/Source/Project64-core/Plugins/GFXPlugin.cpp b/Source/Project64-core/Plugins/GFXPlugin.cpp
index 6d1dfede3..7170922b8 100644
--- a/Source/Project64-core/Plugins/GFXPlugin.cpp
+++ b/Source/Project64-core/Plugins/GFXPlugin.cpp
@@ -14,25 +14,24 @@
#include
#include
#include "GFXPlugin.h"
-#include
CGfxPlugin::CGfxPlugin() :
-CaptureScreen(NULL),
-ChangeWindow(NULL),
-DrawScreen(NULL),
-DrawStatus(NULL),
-MoveScreen(NULL),
-ProcessDList(NULL),
-ProcessRDPList(NULL),
-ShowCFB(NULL),
-UpdateScreen(NULL),
-ViStatusChanged(NULL),
-ViWidthChanged(NULL),
-SoftReset(NULL),
-GetRomBrowserMenu(NULL),
-OnRomBrowserMenuItem(NULL),
-GetDebugInfo(NULL),
-InitiateDebugger(NULL)
+ CaptureScreen(NULL),
+ ChangeWindow(NULL),
+ DrawScreen(NULL),
+ DrawStatus(NULL),
+ MoveScreen(NULL),
+ ProcessDList(NULL),
+ ProcessRDPList(NULL),
+ ShowCFB(NULL),
+ UpdateScreen(NULL),
+ ViStatusChanged(NULL),
+ ViWidthChanged(NULL),
+ SoftReset(NULL),
+ GetRomBrowserMenu(NULL),
+ OnRomBrowserMenuItem(NULL),
+ GetDebugInfo(NULL),
+ InitiateDebugger(NULL)
{
memset(&m_GFXDebug, 0, sizeof(m_GFXDebug));
}
@@ -46,7 +45,7 @@ CGfxPlugin::~CGfxPlugin()
bool CGfxPlugin::LoadFunctions(void)
{
// Find entries for functions in DLL
- int32_t(__cdecl *InitiateGFX) (void * Gfx_Info);
+ int32_t(CALL *InitiateGFX) (void * Gfx_Info);
LoadFunction(InitiateGFX);
LoadFunction(ChangeWindow);
LoadFunction(DrawScreen);
@@ -94,8 +93,9 @@ bool CGfxPlugin::LoadFunctions(void)
}
if (GetDebugInfo != NULL)
+ {
GetDebugInfo(&m_GFXDebug);
-
+ }
return true;
}
@@ -108,8 +108,8 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window)
typedef struct
{
- HWND hWnd; /* Render window */
- HWND hStatusBar; /* if render window does not have a status bar then this is NULL */
+ void * hWnd; /* Render window */
+ void * hStatusBar; /* if render window does not have a status bar then this is NULL */
int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre
// bswap on a dword (32 bits) boundry
@@ -148,19 +148,19 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window)
uint32_t * VI__X_SCALE_REG;
uint32_t * VI__Y_SCALE_REG;
- void(__cdecl *CheckInterrupts)(void);
+ void(CALL *CheckInterrupts)(void);
} GFX_INFO;
//Get Function from DLL
- int32_t(__cdecl *InitiateGFX)(GFX_INFO Gfx_Info);
- InitiateGFX = (int32_t(__cdecl *)(GFX_INFO))GetProcAddress((HMODULE)m_hDll, "InitiateGFX");
+ int32_t(CALL *InitiateGFX)(GFX_INFO Gfx_Info);
+ _LoadFunction("InitiateGFX",InitiateGFX);
if (InitiateGFX == NULL) { return false; }
GFX_INFO Info = { 0 };
- Info.MemoryBswaped = TRUE;
- Info.hWnd = (HWND)Window->GetWindowHandle();
- Info.hStatusBar = (HWND)Window->GetStatusBar();
+ Info.MemoryBswaped = true;
+ Info.hWnd = Window->GetWindowHandle();
+ Info.hStatusBar = Window->GetStatusBar();
Info.CheckInterrupts = DummyCheckInterrupts;
// We are initializing the plugin before any rom is loaded so we do not have any correct
@@ -224,20 +224,20 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window)
m_Initialized = InitiateGFX(Info) != 0;
- //jabo had a bug so I call CreateThread so his dllmain gets called again
- DWORD ThreadID;
- HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
- CloseHandle(hthread);
+#ifdef _WIN32
+ //jabo had a bug so I call CreateThread so his dllmain gets called again
+ pjutil::DynLibCallDllMain();
+#endif
return m_Initialized;
}
void CGfxPlugin::UnloadPluginDetails(void)
{
- if (m_hDll != NULL)
+ if (m_LibHandle != NULL)
{
- FreeLibrary((HMODULE)m_hDll);
- m_hDll = NULL;
+ pjutil::DynLibClose(m_LibHandle);
+ m_LibHandle = NULL;
}
memset(&m_GFXDebug, 0, sizeof(m_GFXDebug));
diff --git a/Source/Project64-core/Plugins/GFXPlugin.h b/Source/Project64-core/Plugins/GFXPlugin.h
index b76fc2231..562e4da9d 100644
--- a/Source/Project64-core/Plugins/GFXPlugin.h
+++ b/Source/Project64-core/Plugins/GFXPlugin.h
@@ -9,7 +9,7 @@
* *
****************************************************************************/
#pragma once
-#include "PluginBase.h"
+#include
class CGfxPlugin : public CPlugin
{
diff --git a/Source/Project64-core/Plugins/PluginBase.cpp b/Source/Project64-core/Plugins/PluginBase.cpp
index 80de16028..9886b1056 100644
--- a/Source/Project64-core/Plugins/PluginBase.cpp
+++ b/Source/Project64-core/Plugins/PluginBase.cpp
@@ -9,22 +9,21 @@
* *
****************************************************************************/
#include "stdafx.h"
-#include "PluginBase.h"
-#include
+#include
CPlugin::CPlugin() :
-DllAbout(NULL),
-DllConfig(NULL),
-CloseDLL(NULL),
-RomOpen(NULL),
-RomClosed(NULL),
-PluginOpened(NULL),
-SetSettingInfo(NULL),
-SetSettingInfo2(NULL),
-SetSettingInfo3(NULL),
-m_hDll(NULL),
-m_Initialized(false),
-m_RomOpen(false)
+ DllAbout(NULL),
+ DllConfig(NULL),
+ CloseDLL(NULL),
+ RomOpen(NULL),
+ RomClosed(NULL),
+ PluginOpened(NULL),
+ SetSettingInfo(NULL),
+ SetSettingInfo2(NULL),
+ SetSettingInfo3(NULL),
+ m_LibHandle(NULL),
+ m_Initialized(false),
+ m_RomOpen(false)
{
memset(&m_PluginInfo, 0, sizeof(m_PluginInfo));
}
@@ -37,31 +36,21 @@ CPlugin::~CPlugin()
bool CPlugin::Load(const char * FileName)
{
// Already loaded, so unload first.
- if (m_hDll != NULL)
+ if (m_LibHandle != NULL)
{
UnloadPlugin();
}
// Try to load the plugin DLL
//Try to load the DLL library
- if (bHaveDebugger())
- {
- m_hDll = LoadLibrary(FileName);
- }
- else
- {
- UINT LastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
- m_hDll = LoadLibrary(FileName);
- SetErrorMode(LastErrorMode);
- }
-
- if (m_hDll == NULL)
+ m_LibHandle = pjutil::DynLibOpen(FileName, bHaveDebugger());
+ if (m_LibHandle == NULL)
{
return false;
}
// Get DLL information
- void(__cdecl *GetDllInfo) (PLUGIN_INFO * PluginInfo);
+ void(CALL *GetDllInfo) (PLUGIN_INFO * PluginInfo);
LoadFunction(GetDllInfo);
if (GetDllInfo == NULL) { return false; }
@@ -69,14 +58,14 @@ bool CPlugin::Load(const char * FileName)
if (!ValidPluginVersion(m_PluginInfo)) { return false; }
if (m_PluginInfo.Type != type()) { return false; }
- CloseDLL = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "CloseDLL");
- RomOpen = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "RomOpen");
- RomClosed = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "RomClosed");
- PluginOpened = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "PluginLoaded");
- DllConfig = (void(__cdecl *)(void *)) GetProcAddress((HMODULE)m_hDll, "DllConfig");
- DllAbout = (void(__cdecl *)(void *)) GetProcAddress((HMODULE)m_hDll, "DllAbout");
+ LoadFunction(CloseDLL);
+ LoadFunction(RomOpen);
+ LoadFunction(RomClosed);
+ _LoadFunction("PluginLoaded", PluginOpened);
+ LoadFunction(DllConfig);
+ LoadFunction(DllAbout);
- SetSettingInfo3 = (void(__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo3");
+ LoadFunction(SetSettingInfo3);
if (SetSettingInfo3)
{
PLUGIN_SETTINGS3 info;
@@ -84,7 +73,7 @@ bool CPlugin::Load(const char * FileName)
SetSettingInfo3(&info);
}
- SetSettingInfo2 = (void(__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo2");
+ LoadFunction(SetSettingInfo2);
if (SetSettingInfo2)
{
PLUGIN_SETTINGS2 info;
@@ -92,7 +81,7 @@ bool CPlugin::Load(const char * FileName)
SetSettingInfo2(&info);
}
- SetSettingInfo = (void(__cdecl *)(PLUGIN_SETTINGS *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo");
+ LoadFunction(SetSettingInfo);
if (SetSettingInfo)
{
PLUGIN_SETTINGS info;
@@ -114,7 +103,9 @@ bool CPlugin::Load(const char * FileName)
}
if (RomClosed == NULL)
+ {
return false;
+ }
if (!LoadFunctions())
{
@@ -150,7 +141,9 @@ void CPlugin::RomOpened()
void CPlugin::RomClose()
{
if (!m_RomOpen)
+ {
return;
+ }
WriteTrace(PluginTraceType(), TraceDebug, "Before Rom Close");
RomClosed();
@@ -186,11 +179,11 @@ void CPlugin::UnloadPlugin()
{
WriteTrace(PluginTraceType(), TraceDebug, "(%s): unloading", PluginType());
memset(&m_PluginInfo, 0, sizeof(m_PluginInfo));
- if (m_hDll != NULL)
+ if (m_LibHandle != NULL)
{
UnloadPluginDetails();
- FreeLibrary((HMODULE)m_hDll);
- m_hDll = NULL;
+ pjutil::DynLibClose(m_LibHandle);
+ m_LibHandle = NULL;
}
DllAbout = NULL;
@@ -256,5 +249,5 @@ bool CPlugin::ValidPluginVersion(PLUGIN_INFO & PluginInfo)
if (PluginInfo.Version == 0x0102) { return true; }
break;
}
- return FALSE;
+ return false;
}
\ No newline at end of file
diff --git a/Source/Project64-core/Plugins/PluginBase.h b/Source/Project64-core/Plugins/PluginBase.h
index 2cef8f452..bb616570a 100644
--- a/Source/Project64-core/Plugins/PluginBase.h
+++ b/Source/Project64-core/Plugins/PluginBase.h
@@ -12,7 +12,8 @@
#include
#include
-#include "PluginClass.h"
+#include
+#include
#if defined(_WIN32)
#define CALL __cdecl
@@ -60,17 +61,18 @@ protected:
void(CALL *SetSettingInfo2) (PLUGIN_SETTINGS2 *);
void(CALL *SetSettingInfo3) (PLUGIN_SETTINGS3 *);
- void * m_hDll;
- bool m_Initialized, m_RomOpen;
+ pjutil::DynLibHandle m_LibHandle;
+ bool m_Initialized, m_RomOpen;
PLUGIN_INFO m_PluginInfo;
// Loads a function pointer from the currently loaded DLL
- template
- void _LoadFunction(const char * szFunctionName, T & functionPointer) {
- functionPointer = (T)GetProcAddress((HMODULE)m_hDll, szFunctionName);
+ void _LoadFunctionVoid(const char * szFunctionName, void ** functionPointer)
+ {
+ *functionPointer = pjutil::DynLibGetProc(m_LibHandle, szFunctionName);
}
// Simple wrapper around _LoadFunction() to avoid having to specify the same two arguments
// i.e. _LoadFunction("CloseDLL", CloseDLL);
-#define LoadFunction(functionName) _LoadFunction(#functionName, functionName)
+#define LoadFunction(functionName) _LoadFunctionVoid(#functionName, (void **)&functionName)
+#define _LoadFunction(functionName,function) _LoadFunctionVoid(functionName, (void **)&function)
};
diff --git a/Source/Project64-core/Plugins/PluginClass.cpp b/Source/Project64-core/Plugins/PluginClass.cpp
index 21189a135..af6b7ea21 100644
--- a/Source/Project64-core/Plugins/PluginClass.cpp
+++ b/Source/Project64-core/Plugins/PluginClass.cpp
@@ -11,17 +11,17 @@
#include "stdafx.h"
#include
#include
+#include
#include
-#include "PluginClass.h"
CPlugins::CPlugins(const stdstr & PluginDir) :
-m_MainWindow(NULL),
-m_SyncWindow(NULL),
-m_PluginDir(PluginDir),
-m_Gfx(NULL),
-m_Audio(NULL),
-m_RSP(NULL),
-m_Control(NULL)
+ m_MainWindow(NULL),
+ m_SyncWindow(NULL),
+ m_PluginDir(PluginDir),
+ m_Gfx(NULL),
+ m_Audio(NULL),
+ m_RSP(NULL),
+ m_Control(NULL)
{
CreatePlugins();
g_Settings->RegisterChangeCB(Plugin_RSP_Current, this, (CSettings::SettingChangedFunc)PluginChanged);
@@ -288,7 +288,7 @@ bool CPlugins::Reset(CN64System * System)
if (m_Gfx && bGfxChange)
{
WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Starting");
- if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; }
+ if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; }
WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Done");
}
if (m_Audio && bAudioChange)
@@ -306,7 +306,7 @@ bool CPlugins::Reset(CN64System * System)
if (m_RSP && bRspChange)
{
WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Starting");
- if (!m_RSP->Initiate(this, System)) { return false; }
+ if (!m_RSP->Initiate(this, System)) { return false; }
WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Done");
}
WriteTrace(TracePlugins, TraceDebug, "Done");
diff --git a/Source/Project64-core/Plugins/PluginClass.h b/Source/Project64-core/Plugins/PluginClass.h
index c7d158b45..bac35b984 100644
--- a/Source/Project64-core/Plugins/PluginClass.h
+++ b/Source/Project64-core/Plugins/PluginClass.h
@@ -90,6 +90,7 @@ __interface RenderWindow
virtual bool ResetPluginsInUiThread(CPlugins * plugins, CN64System * System) = 0;
virtual void * GetWindowHandle(void) const = 0;
virtual void * GetStatusBar(void) const = 0;
+ virtual void * GetModuleInstance(void) const = 0;
};
class CPlugins :
diff --git a/Source/Project64-core/Plugins/RSPPlugin.cpp b/Source/Project64-core/Plugins/RSPPlugin.cpp
index 67009521b..a5a9897ba 100644
--- a/Source/Project64-core/Plugins/RSPPlugin.cpp
+++ b/Source/Project64-core/Plugins/RSPPlugin.cpp
@@ -14,17 +14,16 @@
#include
#include "RSPPlugin.h"
#include "GFXPlugin.h"
-#include "AudioPlugin.h"
-#include
+#include
void DummyFunc1(int a) { a += 1; }
CRSP_Plugin::CRSP_Plugin(void) :
-DoRspCycles(NULL),
-EnableDebugging(NULL),
-m_CycleCount(0),
-GetDebugInfo(NULL),
-InitiateDebugger(NULL)
+ DoRspCycles(NULL),
+ EnableDebugging(NULL),
+ m_CycleCount(0),
+ GetDebugInfo(NULL),
+ InitiateDebugger(NULL)
{
memset(&m_RSPDebug, 0, sizeof(m_RSPDebug));
}
@@ -38,7 +37,7 @@ CRSP_Plugin::~CRSP_Plugin()
bool CRSP_Plugin::LoadFunctions(void)
{
// Find entries for functions in DLL
- void(__cdecl *InitiateRSP)(void);
+ void(CALL *InitiateRSP)(void);
LoadFunction(InitiateRSP);
LoadFunction(DoRspCycles);
_LoadFunction("GetRspDebugInfo", GetDebugInfo);
@@ -59,8 +58,9 @@ bool CRSP_Plugin::LoadFunctions(void)
// Get debug info if able
if (GetDebugInfo != NULL)
+ {
GetDebugInfo(&m_RSPDebug);
-
+ }
return true;
}
@@ -73,7 +73,7 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
typedef struct
{
- HINSTANCE hInst;
+ void * hInst;
int MemoryBswaped; /* If this is set to TRUE, then the memory has been pre
bswap on a dword (32 bits) boundry */
uint8_t * RDRAM;
@@ -101,21 +101,21 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
uint32_t * DPC__PIPEBUSY_REG;
uint32_t * DPC__TMEM_REG;
- void(__cdecl *CheckInterrupts)(void);
- void(__cdecl *ProcessDlist)(void);
- void(__cdecl *ProcessAlist)(void);
- void(__cdecl *ProcessRdpList)(void);
- void(__cdecl *ShowCFB)(void);
+ void(CALL *CheckInterrupts)(void);
+ void(CALL *ProcessDlist)(void);
+ void(CALL *ProcessAlist)(void);
+ void(CALL *ProcessRdpList)(void);
+ void(CALL *ShowCFB)(void);
} RSP_INFO_1_1;
RSP_INFO_1_1 Info = { 0 };
- Info.hInst = GetModuleHandle(NULL);
+ Info.hInst = Plugins->MainWindow()->GetModuleInstance();
Info.CheckInterrupts = DummyCheckInterrupts;
Info.MemoryBswaped = (System == NULL); // only true when the system's not yet loaded
//Get Function from DLL
- void(__cdecl *InitiateRSP) (RSP_INFO_1_1 Audio_Info, uint32_t * Cycles);
+ void(CALL *InitiateRSP) (RSP_INFO_1_1 Audio_Info, uint32_t * Cycles);
LoadFunction(InitiateRSP);
if (InitiateRSP == NULL) { return false; }
@@ -193,10 +193,10 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
InitiateRSP(Info, &m_CycleCount);
m_Initialized = true;
- //jabo had a bug so I call CreateThread so his dllmain gets called again
- DWORD ThreadID;
- HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
- CloseHandle(hthread);
+#ifdef _WIN32
+ //jabo had a bug so I call CreateThread so his dllmain gets called again
+ pjutil::DynLibCallDllMain();
+#endif
return m_Initialized;
}
diff --git a/Source/Project64-core/Plugins/RSPPlugin.h b/Source/Project64-core/Plugins/RSPPlugin.h
index 3bc6b6c82..1fa8401f2 100644
--- a/Source/Project64-core/Plugins/RSPPlugin.h
+++ b/Source/Project64-core/Plugins/RSPPlugin.h
@@ -9,7 +9,7 @@
* *
****************************************************************************/
#pragma once
-#include "PluginBase.h"
+#include
class CRSP_Plugin : public CPlugin
{
diff --git a/Source/Project64-core/Plugins/stdafx.h b/Source/Project64-core/Plugins/stdafx.h
new file mode 100644
index 000000000..8b696d0b1
--- /dev/null
+++ b/Source/Project64-core/Plugins/stdafx.h
@@ -0,0 +1 @@
+#include "../stdafx.h"
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp
index 137a824fc..08294dbe9 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp
@@ -60,6 +60,13 @@ CSettingTypeApplication::~CSettingTypeApplication()
void CSettingTypeApplication::Initialize( const char * /*AppName*/ )
{
+ CPath BaseDir(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(),"");
+ if (!BaseDir.DirectoryExists())
+ {
+ printf("BaseDir does not exists, doing nothing");
+ return;
+ }
+
stdstr SettingsFile, OrigSettingsFile;
for (int i = 0; i < 100; i++)
@@ -77,7 +84,11 @@ 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())
{
SettingsDir.DirectoryCreate();
@@ -123,7 +134,9 @@ bool CSettingTypeApplication::Load ( int /*Index*/, bool & Value ) const
if (m_DefaultSetting == Default_Constant)
{
Value = m_DefaultValue != 0;
- } else {
+ }
+ else
+ {
g_Settings->LoadBool(m_DefaultSetting,Value);
}
}
@@ -138,7 +151,9 @@ bool CSettingTypeApplication::Load ( int /*Index*/, uint32_t & Value ) const
if (m_DefaultSetting == Default_Constant)
{
Value = m_DefaultValue;
- } else {
+ }
+ else
+ {
g_Settings->LoadDword(m_DefaultSetting,Value);
}
}
@@ -168,20 +183,24 @@ void CSettingTypeApplication::LoadDefault ( int /*Index*/, bool & Value ) cons
if (m_DefaultSetting == Default_Constant)
{
Value = m_DefaultValue != 0;
- } else {
+ }
+ else
+ {
g_Settings->LoadBool(m_DefaultSetting,Value);
}
}
}
-void CSettingTypeApplication::LoadDefault ( int /*Index*/, uint32_t & Value ) const
+void CSettingTypeApplication::LoadDefault(int /*Index*/, uint32_t & Value) const
{
if (m_DefaultSetting != Default_None)
{
if (m_DefaultSetting == Default_Constant)
{
Value = m_DefaultValue;
- } else {
+ }
+ else
+ {
g_Settings->LoadDword(m_DefaultSetting,Value);
}
}
@@ -194,7 +213,9 @@ void CSettingTypeApplication::LoadDefault ( int /*Index*/, stdstr & Value ) cons
if (m_DefaultSetting == Default_Constant)
{
Value = m_DefaultStr;
- } else {
+ }
+ else
+ {
g_Settings->LoadStringVal(m_DefaultSetting,Value);
}
}
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Application.h b/Source/Project64-core/Settings/SettingType/SettingsType-Application.h
index 06dd2726e..9412a8e3a 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-Application.h
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-Application.h
@@ -11,7 +11,7 @@
#pragma once
#include
-#include "SettingsType-Base.h"
+#include
class CSettingTypeApplication :
public CSettingType
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.cpp
index 15331ec52..5b2cf754d 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.cpp
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.cpp
@@ -26,6 +26,7 @@ CSettingTypeApplicationPath::~CSettingTypeApplicationPath()
bool CSettingTypeApplicationPath::Load ( int Index, stdstr & Value ) const
{
bool bRes = CSettingTypeApplication::Load(Index,Value);
+#ifdef WIN32
if (bRes)
{
if (Value.substr(0,2) == ".\\" || Value.substr(0,2) == "./" ||
@@ -38,5 +39,6 @@ bool CSettingTypeApplicationPath::Load ( int Index, stdstr & Value ) const
Value = (const std::string &)FullFilePath;
}
}
+#endif
return bRes;
}
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Base.h b/Source/Project64-core/Settings/SettingType/SettingsType-Base.h
index 58134054a..c0c78233c 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-Base.h
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-Base.h
@@ -10,9 +10,11 @@
****************************************************************************/
#pragma once
-#include "../Settings.h"
+#include
+#include
-enum SettingType {
+enum SettingType
+{
SettingType_Unknown = -1,
SettingType_ConstString = 0,
SettingType_ConstValue = 1,
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Cheats.h b/Source/Project64-core/Settings/SettingType/SettingsType-Cheats.h
index 08ca22a67..c78eac2f8 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-Cheats.h
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-Cheats.h
@@ -10,7 +10,7 @@
****************************************************************************/
#pragma once
-#include "SettingsType-Base.h"
+#include
#include
class CSettingTypeCheats :
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.cpp
index 8c5cb491a..7395ec57d 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.cpp
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.cpp
@@ -11,7 +11,7 @@
#include "stdafx.h"
#include "SettingsType-RomDatabase.h"
#include "SettingsType-RDBCpuType.h"
-#include "../../N64System/N64Types.h"
+#include
CSettingTypeRDBCpuType::CSettingTypeRDBCpuType(const char * Name, SettingID DefaultSetting ) :
CSettingTypeRomDatabase(Name,DefaultSetting)
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.cpp
index 75de85156..fb754db34 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.cpp
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.cpp
@@ -11,7 +11,7 @@
#include "stdafx.h"
#include "SettingsType-RomDatabase.h"
#include "SettingsType-RDBSaveChip.h"
-#include "../../N64System/N64Types.h"
+#include
CSettingTypeRDBSaveChip::CSettingTypeRDBSaveChip(const char * Name, SettingID DefaultSetting ) :
CSettingTypeRomDatabase(Name,DefaultSetting)
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.cpp
index 03f789ab0..88049c257 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.cpp
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.cpp
@@ -11,59 +11,79 @@
#include "stdafx.h"
#include "SettingsType-RelativePath.h"
-CSettingTypeRelativePath::CSettingTypeRelativePath(const char * Path, const char * FileName)
+CSettingTypeRelativePath::CSettingTypeRelativePath(const char * Directory, const char * FileName) :
+m_Directory(Directory),
+m_FileName(FileName)
{
- m_FileName = CPath(CPath::MODULE_DIRECTORY,FileName);
- m_FileName.AppendDirectory(Path);
+ BuildPath();
+ g_Settings->RegisterChangeCB(Cmd_BaseDirectory, this, RefreshSettings);
}
-CSettingTypeRelativePath::~CSettingTypeRelativePath ( void )
+CSettingTypeRelativePath::~CSettingTypeRelativePath(void)
{
+ g_Settings->UnregisterChangeCB(Cmd_BaseDirectory, this, RefreshSettings);
}
-bool CSettingTypeRelativePath::Load ( int /*Index*/, stdstr & value ) const
+bool CSettingTypeRelativePath::Load(int /*Index*/, stdstr & value) const
{
- value = (const char *)m_FileName;
+ value = m_FullPath;
return true;
}
//return the default values
-void CSettingTypeRelativePath::LoadDefault ( int /*Index*/, bool & /*Value*/ ) const
+void CSettingTypeRelativePath::LoadDefault(int /*Index*/, bool & /*Value*/) const
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
-void CSettingTypeRelativePath::LoadDefault ( int /*Index*/, uint32_t & /*Value*/ ) const
+void CSettingTypeRelativePath::LoadDefault(int /*Index*/, uint32_t & /*Value*/) const
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
-void CSettingTypeRelativePath::LoadDefault ( int /*Index*/, stdstr & /*Value*/ ) const
+void CSettingTypeRelativePath::LoadDefault(int /*Index*/, stdstr & /*Value*/) const
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
-void CSettingTypeRelativePath::Save ( int /*Index*/, bool /*Value*/ )
+void CSettingTypeRelativePath::Save(int /*Index*/, bool /*Value*/)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
-void CSettingTypeRelativePath::Save ( int /*Index*/, uint32_t /*Value*/ )
+void CSettingTypeRelativePath::Save(int /*Index*/, uint32_t /*Value*/)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
-void CSettingTypeRelativePath::Save ( int /*Index*/, const stdstr & Value )
+void CSettingTypeRelativePath::Save(int /*Index*/, const stdstr & Value)
{
- m_FileName = CPath(CPath::MODULE_DIRECTORY,Value.c_str());
+ m_Directory = "";
+ m_FileName = Value;
+ BuildPath();
}
-void CSettingTypeRelativePath::Save ( int /*Index*/, const char * Value )
+void CSettingTypeRelativePath::Save(int /*Index*/, const char * Value)
{
- m_FileName = CPath(CPath::MODULE_DIRECTORY,Value);
+ m_Directory = "";
+ m_FileName = Value;
+ BuildPath();
}
-void CSettingTypeRelativePath::Delete ( int /*Index*/ )
+void CSettingTypeRelativePath::Delete(int /*Index*/)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
+
+void CSettingTypeRelativePath::BuildPath(void)
+{
+ CPath FullPath(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(),"");
+ FullPath.AppendDirectory(m_Directory.c_str());
+ FullPath.SetNameExtension(m_FileName.c_str());
+ m_FullPath = (const char *)FullPath;
+}
+
+void CSettingTypeRelativePath::RefreshSettings(void * _this)
+{
+ ((CSettingTypeRelativePath *)_this)->BuildPath();
+}
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.h b/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.h
index fefb5b16b..ab5ef6876 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.h
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.h
@@ -10,15 +10,13 @@
****************************************************************************/
#pragma once
#include
-#include "SettingsType-Base.h"
+#include
class CSettingTypeRelativePath :
public CSettingType
{
- CPath m_FileName;
-
public:
- CSettingTypeRelativePath(const char * Path, const char * FileName);
+ CSettingTypeRelativePath(const char * Directory, const char * FileName);
~CSettingTypeRelativePath();
bool IndexBasedSetting ( void ) const { return false; }
@@ -47,4 +45,11 @@ private:
CSettingTypeRelativePath(void); // Disable default constructor
CSettingTypeRelativePath(const CSettingTypeRelativePath&); // Disable copy constructor
CSettingTypeRelativePath& operator=(const CSettingTypeRelativePath&); // Disable assignment
+
+ static void RefreshSettings(void * _this);
+ void BuildPath ( void );
+
+ std::string m_FullPath;
+ std::string m_Directory;
+ std::string m_FileName;
};
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp
index dbd95b041..c45e6b69e 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp
@@ -65,12 +65,14 @@ void CSettingTypeRomDatabase::Initialize( void )
m_GlideIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_Glide64RDB).c_str());
g_Settings->RegisterChangeCB(Game_IniKey,NULL,GameChanged);
+ g_Settings->RegisterChangeCB(Cmd_BaseDirectory,NULL,BaseDirChanged);
m_SectionIdent = new stdstr(g_Settings->LoadStringVal(Game_IniKey));
}
void CSettingTypeRomDatabase::CleanUp( void )
{
+ g_Settings->UnregisterChangeCB(Cmd_BaseDirectory,NULL,BaseDirChanged);
g_Settings->UnregisterChangeCB(Game_IniKey,NULL,GameChanged);
if (m_SettingsIniFile)
{
@@ -89,6 +91,22 @@ void CSettingTypeRomDatabase::CleanUp( void )
}
}
+void CSettingTypeRomDatabase::BaseDirChanged ( void * /*Data */ )
+{
+ if (m_SettingsIniFile)
+ {
+ delete m_SettingsIniFile;
+ m_SettingsIniFile = NULL;
+ }
+ if (m_GlideIniFile)
+ {
+ delete m_GlideIniFile;
+ m_GlideIniFile = NULL;
+ }
+ m_SettingsIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
+ m_GlideIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_Glide64RDB).c_str());
+}
+
void CSettingTypeRomDatabase::GameChanged ( void * /*Data */ )
{
if (m_SectionIdent)
@@ -195,7 +213,7 @@ void CSettingTypeRomDatabase::Save ( int /*Index*/, bool Value )
}
if (m_DeleteOnDefault)
{
- g_Notify->BreakPoint(__FILE__, __LINE__);
+ g_Notify->BreakPoint(__FILE__,__LINE__);
}
if (m_GlideSetting)
{
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h
index c4d5a6755..6df365f0d 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h
@@ -11,7 +11,7 @@
#pragma once
#include
-#include "SettingsType-Base.h"
+#include
class CSettingTypeRomDatabase :
public CSettingType
@@ -51,6 +51,7 @@ public:
protected:
static void GameChanged ( void * /*Data */ );
+ static void BaseDirChanged ( void * /*Data */ );
static bool IsGlideSetting (const char * Name);
static const char * StripNameSection (const char * Name);
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.cpp
index e0920612b..c48a0b304 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.cpp
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.cpp
@@ -25,13 +25,13 @@ CSettingTypeSelectedDirectory::~CSettingTypeSelectedDirectory()
bool CSettingTypeSelectedDirectory::Load ( int /*Index*/, bool & /*Value*/ ) const
{
- g_Notify->BreakPoint(__FILE__, __LINE__);
+ g_Notify->BreakPoint(__FILE__,__LINE__);
return false;
}
bool CSettingTypeSelectedDirectory::Load ( int /*Index*/, uint32_t & /*Value*/ ) const
{
- g_Notify->BreakPoint(__FILE__, __LINE__);
+ g_Notify->BreakPoint(__FILE__,__LINE__);
return false;
}
@@ -44,33 +44,33 @@ bool CSettingTypeSelectedDirectory::Load ( int /*Index*/, stdstr & Value ) const
//return the default values
void CSettingTypeSelectedDirectory::LoadDefault ( int /*Index*/, bool & /*Value*/ ) const
{
- g_Notify->BreakPoint(__FILE__, __LINE__);
+ g_Notify->BreakPoint(__FILE__,__LINE__);
}
void CSettingTypeSelectedDirectory::LoadDefault ( int /*Index*/, uint32_t & /*Value*/ ) const
{
- g_Notify->BreakPoint(__FILE__, __LINE__);
+ g_Notify->BreakPoint(__FILE__,__LINE__);
}
void CSettingTypeSelectedDirectory::LoadDefault ( int /*Index*/, stdstr & /*Value*/ ) const
{
- g_Notify->BreakPoint(__FILE__, __LINE__);
+ g_Notify->BreakPoint(__FILE__,__LINE__);
}
//Update the settings
void CSettingTypeSelectedDirectory::Save ( int /*Index*/, bool /*Value*/ )
{
- g_Notify->BreakPoint(__FILE__, __LINE__);
+ g_Notify->BreakPoint(__FILE__,__LINE__);
}
void CSettingTypeSelectedDirectory::Save ( int /*Index*/, uint32_t /*Value*/ )
{
- g_Notify->BreakPoint(__FILE__, __LINE__);
+ g_Notify->BreakPoint(__FILE__,__LINE__);
}
void CSettingTypeSelectedDirectory::Save ( int /*Index*/, const stdstr & /*Value*/ )
{
- g_Notify->BreakPoint(__FILE__, __LINE__);
+ g_Notify->BreakPoint(__FILE__,__LINE__);
}
void CSettingTypeSelectedDirectory::Save ( int /*Index*/, const char * Value )
@@ -81,5 +81,5 @@ void CSettingTypeSelectedDirectory::Save ( int /*Index*/, const char * Value )
void CSettingTypeSelectedDirectory::Delete( int /*Index*/ )
{
- g_Notify->BreakPoint(__FILE__, __LINE__);
+ g_Notify->BreakPoint(__FILE__,__LINE__);
}
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.h b/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.h
index b51be8046..ea20bc320 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.h
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.h
@@ -10,7 +10,7 @@
****************************************************************************/
#pragma once
-#include "SettingsType-Base.h"
+#include
class CSettingTypeSelectedDirectory :
public CSettingType
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.h b/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.h
index 05dfb0146..e09181793 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.h
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.h
@@ -10,7 +10,7 @@
****************************************************************************/
#pragma once
-#include "SettingsType-Base.h"
+#include
class CSettingTypeTempBool :
public CSettingType
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.h b/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.h
index 2011a751d..9b5727bc8 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.h
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.h
@@ -10,7 +10,7 @@
****************************************************************************/
#pragma once
-#include "SettingsType-Base.h"
+#include
class CSettingTypeTempNumber :
public CSettingType
diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempString.h b/Source/Project64-core/Settings/SettingType/SettingsType-TempString.h
index 0c2143d19..e7f3be1e4 100644
--- a/Source/Project64-core/Settings/SettingType/SettingsType-TempString.h
+++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempString.h
@@ -10,7 +10,7 @@
****************************************************************************/
#pragma once
-#include "SettingsType-Base.h"
+#include
class CSettingTypeTempString :
public CSettingType
diff --git a/Source/Project64/Plugins/PluginList.cpp b/Source/Project64/Plugins/PluginList.cpp
index eed868da0..38a47384a 100644
--- a/Source/Project64/Plugins/PluginList.cpp
+++ b/Source/Project64/Plugins/PluginList.cpp
@@ -54,7 +54,8 @@ void CPluginList::AddPluginFromDir(CPath Dir)
Dir.SetNameExtension("*.*");
if (Dir.FindFirst(_A_SUBDIR))
{
- do {
+ do
+ {
AddPluginFromDir(Dir);
} while (Dir.FindNext());
Dir.UpDirectory();
@@ -64,7 +65,8 @@ void CPluginList::AddPluginFromDir(CPath Dir)
if (Dir.FindFirst())
{
HMODULE hLib = NULL;
- do {
+ do
+ {
if (hLib)
{
FreeLibrary(hLib);
@@ -83,8 +85,8 @@ void CPluginList::AddPluginFromDir(CPath Dir)
continue;
}
- void(__cdecl *GetDllInfo) (PLUGIN_INFO * PluginInfo);
- GetDllInfo = (void(__cdecl *)(PLUGIN_INFO *))GetProcAddress(hLib, "GetDllInfo");
+ void(CALL *GetDllInfo) (PLUGIN_INFO * PluginInfo);
+ GetDllInfo = (void(CALL *)(PLUGIN_INFO *))GetProcAddress(hLib, "GetDllInfo");
if (GetDllInfo == NULL)
{
continue;
diff --git a/Source/Project64/UserInterface/GuiClass.cpp b/Source/Project64/UserInterface/GuiClass.cpp
index ad4fa883e..d81e3d28a 100644
--- a/Source/Project64/UserInterface/GuiClass.cpp
+++ b/Source/Project64/UserInterface/GuiClass.cpp
@@ -24,14 +24,14 @@ LRESULT CALLBACK MainGui_Proc(HWND WndHandle, DWORD uMsg, DWORD wParam, DWORD lP
extern BOOL set_about_field(HWND hDlg, int nIDDlgItem, const wchar_t * config_string, const wchar_t * language_string);
CMainGui::CMainGui(bool bMainWindow, const char * WindowTitle) :
-CRomBrowser(m_hMainWindow, m_hStatusWnd),
-m_ThreadId(GetCurrentThreadId()),
-m_bMainWindow(bMainWindow),
-m_Created(false),
-m_AttachingMenu(false),
-m_MakingVisible(false),
-m_ResetPlugins(false),
-m_ResetInfo(NULL)
+ CRomBrowser(m_hMainWindow, m_hStatusWnd),
+ m_ThreadId(GetCurrentThreadId()),
+ m_bMainWindow(bMainWindow),
+ m_Created(false),
+ m_AttachingMenu(false),
+ m_MakingVisible(false),
+ m_ResetPlugins(false),
+ m_ResetInfo(NULL)
{
m_Menu = NULL;
@@ -273,6 +273,11 @@ void CMainGui::ChangeWinSize(long width, long height)
MoveWindow(m_hMainWindow, wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top, rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE);
}
+void * CMainGui::GetModuleInstance(void) const
+{
+ return GetModuleHandle(NULL);
+}
+
void CMainGui::AboutBox(void)
{
DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_About), m_hMainWindow, (DLGPROC)AboutBoxProc, (LPARAM)this);
diff --git a/Source/Project64/UserInterface/GuiClass.h b/Source/Project64/UserInterface/GuiClass.h
index 2172c5522..04869ea96 100644
--- a/Source/Project64/UserInterface/GuiClass.h
+++ b/Source/Project64/UserInterface/GuiClass.h
@@ -89,6 +89,7 @@ public:
//Get Window Handle
void * GetWindowHandle(void) const { return m_hMainWindow; }
void * GetStatusBar(void) const { return m_hStatusWnd; }
+ void * GetModuleInstance(void) const;
private:
CMainGui(void); // Disable default constructor
diff --git a/Source/Project64/UserInterface/RomBrowserClass.cpp b/Source/Project64/UserInterface/RomBrowserClass.cpp
index 16e99cf14..97f444470 100644
--- a/Source/Project64/UserInterface/RomBrowserClass.cpp
+++ b/Source/Project64/UserInterface/RomBrowserClass.cpp
@@ -459,8 +459,7 @@ bool CRomBrowser::FillRomInfo(ROM_INFO * pRomInfo)
}
else
{
- char drive[_MAX_DRIVE], dir[_MAX_DIR], ext[_MAX_EXT];
- _splitpath(pRomInfo->szFullFileName, drive, dir, pRomInfo->FileName, ext);
+ strncpy(pRomInfo->FileName, CPath(pRomInfo->szFullFileName).GetNameExtension().c_str(), sizeof(pRomInfo->FileName) / sizeof(pRomInfo->FileName[0]));
}
if (m_Fields[RB_InternalName].Pos() >= 0)
{
@@ -1576,9 +1575,9 @@ void CRomBrowser::RomList_SortList(void)
}
/*
- * SaveRomList - save all the rom information about the current roms in the rom brower
- * to a cache file, so it is quick to reload the information
- */
+* SaveRomList - save all the rom information about the current roms in the rom brower
+* to a cache file, so it is quick to reload the information
+*/
void CRomBrowser::SaveRomList(strlist & FileList)
{
MD5 ListHash = RomListHash(FileList);
diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp
index c49b10072..64f3c5d27 100644
--- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp
+++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp
@@ -126,8 +126,8 @@ void CGamePluginPage::ShowAboutButton(int id)
}
//Get DLL about
- void(__cdecl *DllAbout) (HWND hWnd);
- DllAbout = (void(__cdecl *)(HWND))GetProcAddress(hLib, "DllAbout");
+ void(CALL *DllAbout) (HWND hWnd);
+ DllAbout = (void(CALL *)(HWND))GetProcAddress(hLib, "DllAbout");
//call the function from the dll
DllAbout(m_hWnd);
diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp
index abdb313d7..fcd661b2f 100644
--- a/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp
+++ b/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp
@@ -118,8 +118,8 @@ void COptionPluginPage::ShowAboutButton(int id)
}
//Get DLL about
- void(__cdecl *DllAbout) (HWND hWnd);
- DllAbout = (void(__cdecl *)(HWND))GetProcAddress(hLib, "DllAbout");
+ void(CALL *DllAbout) (HWND hWnd);
+ DllAbout = (void(CALL *)(HWND))GetProcAddress(hLib, "DllAbout");
//call the function from the dll
DllAbout(m_hWnd);