Code clean up
This commit is contained in:
parent
0d7f25138c
commit
761a1ee52a
|
@ -131,12 +131,13 @@ void MD5::finalize()
|
|||
{
|
||||
unsigned char bits[8];
|
||||
unsigned int index, padLen;
|
||||
static uint1 PADDING[64] =
|
||||
{
|
||||
// clang-format off
|
||||
static uint1 PADDING[64] = {
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
if (finalized)
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
typedef const char * LPCSTR;
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include "7zip.h"
|
||||
#include <Common/StdString.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
C7zip::C7zip(const char * FileName) :
|
||||
m_FileSize(0),
|
||||
|
@ -78,7 +78,6 @@ void C7zip::SetNotificationCallback(LP7ZNOTIFICATION NotfyFnc, void * CBInfo)
|
|||
m_NotfyCallbackInfo = CBInfo;
|
||||
}
|
||||
|
||||
|
||||
bool C7zip::GetFile(int index, Byte * Data, size_t DataLen)
|
||||
{
|
||||
m_CurrentFile = -1;
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
#include <string>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "7zip/7zCrc.h"
|
||||
#include "7zip/7z.h"
|
||||
#include "7zip/7zCrc.h"
|
||||
#include "7zip/7zFile.h"
|
||||
#include "7zip/Types.h"
|
||||
|
||||
|
@ -17,16 +18,27 @@ extern "C" {
|
|||
class C7zip
|
||||
{
|
||||
public:
|
||||
|
||||
C7zip(const char * FileName);
|
||||
~C7zip();
|
||||
|
||||
typedef void (*LP7ZNOTIFICATION)(const char * Status, void * CBInfo);
|
||||
|
||||
inline int NumFiles(void) const { return m_db ? m_db->db.NumFiles : 0; }
|
||||
inline CSzFileItem * FileItem(int index) const { return m_db ? &m_db->db.Files[index] : nullptr; }
|
||||
inline int FileSize(void) const { return m_FileSize; }
|
||||
inline bool OpenSuccess(void) const { return m_Opened; }
|
||||
inline int NumFiles(void) const
|
||||
{
|
||||
return m_db ? m_db->db.NumFiles : 0;
|
||||
}
|
||||
inline CSzFileItem * FileItem(int index) const
|
||||
{
|
||||
return m_db ? &m_db->db.Files[index] : nullptr;
|
||||
}
|
||||
inline int FileSize(void) const
|
||||
{
|
||||
return m_FileSize;
|
||||
}
|
||||
inline bool OpenSuccess(void) const
|
||||
{
|
||||
return m_Opened;
|
||||
}
|
||||
|
||||
bool GetFile(int index, Byte * Data, size_t DataLen);
|
||||
const char * FileName(char * FileName, size_t SizeOfFileName) const;
|
||||
|
@ -62,7 +74,9 @@ private:
|
|||
|
||||
//static void __stdcall StatusUpdate(_7Z_STATUS status, int Value1, int Value2, C7zip * _this);
|
||||
|
||||
static void NotfyCallbackDefault(const char * /*Status*/, void * /*CBInfo*/) { }
|
||||
static void NotfyCallbackDefault(const char * /*Status*/, void * /*CBInfo*/)
|
||||
{
|
||||
}
|
||||
|
||||
LP7ZNOTIFICATION m_NotfyCallback;
|
||||
void * m_NotfyCallbackInfo;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include <Project64-core/Settings/LoggingSettings.h>
|
||||
#include <Common/File.h>
|
||||
#include <Project64-core/Settings/LoggingSettings.h>
|
||||
|
||||
class CLogging :
|
||||
public CLogSettings
|
||||
|
|
|
@ -172,33 +172,33 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex
|
|||
uint8_t Value = 0;
|
||||
g_MMU->LB_NonMemory((MemAddress | 0x80000000) ^ 3, Value);
|
||||
*(uint32_t *)Reg = Value;
|
||||
}
|
||||
*context.Eip = (uint32_t)ReadPos;
|
||||
return true;
|
||||
}
|
||||
case 0xB7:
|
||||
{
|
||||
uint16_t Value = 0;
|
||||
g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, Value);
|
||||
*(uint32_t *)Reg = Value;
|
||||
}
|
||||
*context.Eip = (uint32_t)ReadPos;
|
||||
return true;
|
||||
}
|
||||
case 0xBE:
|
||||
{
|
||||
uint8_t Value = 0;
|
||||
g_MMU->LB_NonMemory((MemAddress | 0x80000000) ^ 3, Value);
|
||||
*(int32_t *)Reg = (int8_t)Value;
|
||||
}
|
||||
*context.Eip = (uint32_t)ReadPos;
|
||||
return true;
|
||||
}
|
||||
case 0xBF:
|
||||
{
|
||||
uint16_t Value = 0;
|
||||
g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, Value);
|
||||
*(int32_t *)Reg = (int16_t)Value;
|
||||
}
|
||||
*context.Eip = (uint32_t)ReadPos;
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
if (HaveDebugger())
|
||||
{
|
||||
|
@ -215,9 +215,9 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex
|
|||
uint16_t Value = 0;
|
||||
g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, Value);
|
||||
*(uint32_t *)Reg = Value;
|
||||
}
|
||||
*context.Eip = (uint32_t)ReadPos;
|
||||
return true;
|
||||
}
|
||||
case 0x89:
|
||||
g_MMU->SH_NonMemory((MemAddress | 0x80000000) ^ 2, *(uint16_t *)Reg);
|
||||
*context.Eip = (uint32_t)ReadPos;
|
||||
|
@ -251,9 +251,9 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex
|
|||
uint8_t Value = 0;
|
||||
g_MMU->LB_NonMemory((MemAddress | 0x80000000) ^ 3, Value);
|
||||
*(uint32_t *)Reg = Value;
|
||||
}
|
||||
*context.Eip = (uint32_t)ReadPos;
|
||||
return true;
|
||||
}
|
||||
case 0x8B:
|
||||
g_MMU->LW_NonMemory(MemAddress | 0x80000000, *((uint32_t *)Reg));
|
||||
*context.Eip = (uint32_t)ReadPos;
|
||||
|
@ -379,12 +379,23 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context
|
|||
return false;
|
||||
}
|
||||
|
||||
uint32_t * ArmRegisters[16] =
|
||||
{
|
||||
(uint32_t*)&context.arm_r0, (uint32_t*)&context.arm_r1, (uint32_t*)&context.arm_r2, (uint32_t*)&context.arm_r3,
|
||||
(uint32_t*)&context.arm_r4, (uint32_t*)&context.arm_r5, (uint32_t*)&context.arm_r6, (uint32_t*)&context.arm_r7,
|
||||
(uint32_t*)&context.arm_r8, (uint32_t*)&context.arm_r9, (uint32_t*)&context.arm_r10,(uint32_t*)&context.arm_fp,
|
||||
(uint32_t*)&context.arm_ip, (uint32_t*)&context.arm_sp, (uint32_t*)&context.arm_lr, (uint32_t*)&context.arm_pc,
|
||||
uint32_t * ArmRegisters[16] = {
|
||||
(uint32_t *)&context.arm_r0,
|
||||
(uint32_t *)&context.arm_r1,
|
||||
(uint32_t *)&context.arm_r2,
|
||||
(uint32_t *)&context.arm_r3,
|
||||
(uint32_t *)&context.arm_r4,
|
||||
(uint32_t *)&context.arm_r5,
|
||||
(uint32_t *)&context.arm_r6,
|
||||
(uint32_t *)&context.arm_r7,
|
||||
(uint32_t *)&context.arm_r8,
|
||||
(uint32_t *)&context.arm_r9,
|
||||
(uint32_t *)&context.arm_r10,
|
||||
(uint32_t *)&context.arm_fp,
|
||||
(uint32_t *)&context.arm_ip,
|
||||
(uint32_t *)&context.arm_sp,
|
||||
(uint32_t *)&context.arm_lr,
|
||||
(uint32_t *)&context.arm_pc,
|
||||
};
|
||||
|
||||
ArmThumbOpcode * OpCode = (ArmThumbOpcode *)context.arm_pc;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#pragma warning(disable : 4786)
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
typedef std::map<int32_t, std::string, std::less<int32_t>> LANG_STRINGS;
|
||||
typedef LANG_STRINGS::value_type LANG_STR;
|
||||
|
@ -28,7 +28,10 @@ public:
|
|||
void SetLanguage(const char * LanguageName);
|
||||
bool LoadCurrentStrings(void);
|
||||
bool IsCurrentLang(LanguageFile & File);
|
||||
bool IsLanguageLoaded(void) const { return m_LanguageLoaded; }
|
||||
bool IsLanguageLoaded(void) const
|
||||
{
|
||||
return m_LanguageLoaded;
|
||||
}
|
||||
|
||||
private:
|
||||
CLanguage(const CLanguage &);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include <Common/Util.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/Notification.h>
|
||||
#include <Common/Util.h>
|
||||
|
||||
void CN64System::StartEmulationThead()
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include <Project64-core/N64System/Enhancement/Enhancement.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
|
|
|
@ -36,21 +36,66 @@ public:
|
|||
void SetOnByDefault(bool OnByDefault);
|
||||
void SetOverClock(bool OverClock, uint32_t OverClockModifier);
|
||||
|
||||
inline const std::string & GetName(void) const { return m_Name; }
|
||||
inline const std::string & GetNameAndExtension(void) const { return m_NameAndExtension; }
|
||||
inline const std::string & GetAuthor(void) const { return m_Author; }
|
||||
inline const std::string & GetNote(void) const { return m_Note; }
|
||||
inline const CodeEntries & GetEntries(void) const { return m_Entries; }
|
||||
inline const CodeOptions & GetOptions(void) const { return m_Options; }
|
||||
inline const PluginList & GetPluginList(void) const { return m_PluginList; }
|
||||
inline uint32_t CodeOptionSize(void) const { return m_CodeOptionSize; }
|
||||
inline bool Valid(void) const { return m_Valid; }
|
||||
inline bool Active(void) const { return m_Active; }
|
||||
inline bool GetOnByDefault(void) const { return m_OnByDefault; }
|
||||
inline bool OverClock(void) const { return m_OverClock; }
|
||||
inline uint32_t OverClockModifier(void) const { return m_OverClockModifier; }
|
||||
bool OptionSelected() const { return (m_SelectedOption & 0xFFFF0000) == 0; }
|
||||
uint16_t SelectedOption() const { return (uint16_t)(m_SelectedOption & 0xFFFF); }
|
||||
inline const std::string & GetName(void) const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
inline const std::string & GetNameAndExtension(void) const
|
||||
{
|
||||
return m_NameAndExtension;
|
||||
}
|
||||
inline const std::string & GetAuthor(void) const
|
||||
{
|
||||
return m_Author;
|
||||
}
|
||||
inline const std::string & GetNote(void) const
|
||||
{
|
||||
return m_Note;
|
||||
}
|
||||
inline const CodeEntries & GetEntries(void) const
|
||||
{
|
||||
return m_Entries;
|
||||
}
|
||||
inline const CodeOptions & GetOptions(void) const
|
||||
{
|
||||
return m_Options;
|
||||
}
|
||||
inline const PluginList & GetPluginList(void) const
|
||||
{
|
||||
return m_PluginList;
|
||||
}
|
||||
inline uint32_t CodeOptionSize(void) const
|
||||
{
|
||||
return m_CodeOptionSize;
|
||||
}
|
||||
inline bool Valid(void) const
|
||||
{
|
||||
return m_Valid;
|
||||
}
|
||||
inline bool Active(void) const
|
||||
{
|
||||
return m_Active;
|
||||
}
|
||||
inline bool GetOnByDefault(void) const
|
||||
{
|
||||
return m_OnByDefault;
|
||||
}
|
||||
inline bool OverClock(void) const
|
||||
{
|
||||
return m_OverClock;
|
||||
}
|
||||
inline uint32_t OverClockModifier(void) const
|
||||
{
|
||||
return m_OverClockModifier;
|
||||
}
|
||||
bool OptionSelected() const
|
||||
{
|
||||
return (m_SelectedOption & 0xFFFF0000) == 0;
|
||||
}
|
||||
uint16_t SelectedOption() const
|
||||
{
|
||||
return (uint16_t)(m_SelectedOption & 0xFFFF);
|
||||
}
|
||||
|
||||
private:
|
||||
CEnhancement();
|
||||
|
|
|
@ -192,8 +192,14 @@ bool CEnhancmentFile::MoveToSection(const char * Section, bool ChangeCurrentSect
|
|||
do
|
||||
{
|
||||
result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos);
|
||||
if (result <= 1) { continue; }
|
||||
if (strlen(CleanLine(Input)) <= 1) { continue; }
|
||||
if (result <= 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (strlen(CleanLine(Input)) <= 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// We only care about sections
|
||||
char * CurrentSection = Input;
|
||||
|
@ -203,9 +209,15 @@ bool CEnhancmentFile::MoveToSection(const char * Section, bool ChangeCurrentSect
|
|||
CurrentSection += 3;
|
||||
}
|
||||
|
||||
if (CurrentSection[0] != '[') { continue; }
|
||||
if (CurrentSection[0] != '[')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int lineEndPos = (int)strlen(CurrentSection) - 1;
|
||||
if (CurrentSection[lineEndPos] != ']') { continue; }
|
||||
if (CurrentSection[lineEndPos] != ']')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Take off the ']' from the end of the string
|
||||
CurrentSection[lineEndPos] = 0;
|
||||
CurrentSection += 1;
|
||||
|
@ -236,9 +248,18 @@ bool CEnhancmentFile::MoveToSection(const char * Section, bool ChangeCurrentSect
|
|||
do
|
||||
{
|
||||
result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos);
|
||||
if (result <= 1) { continue; }
|
||||
if (strlen(CleanLine(Input)) <= 1) { continue; }
|
||||
if (Input[0] == '[') { break; }
|
||||
if (result <= 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (strlen(CleanLine(Input)) <= 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (Input[0] == '[')
|
||||
{
|
||||
break;
|
||||
}
|
||||
char * Pos = strchr(Input, '=');
|
||||
if (Input[0] == '$')
|
||||
{
|
||||
|
@ -397,7 +418,10 @@ void CEnhancmentFile::SaveCurrentSection(void)
|
|||
do
|
||||
{
|
||||
result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos);
|
||||
if (result <= 1) { continue; }
|
||||
if (result <= 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (strlen(CleanLine(Input)) <= 1 || Input[0] != '[')
|
||||
{
|
||||
EndPos = ((m_File.GetPosition() - DataSize) + ReadPos);
|
||||
|
@ -425,7 +449,10 @@ void CEnhancmentFile::SaveCurrentSection(void)
|
|||
|
||||
int CEnhancmentFile::GetStringFromFile(char *& String, std::unique_ptr<char> & Data, int & MaxDataSize, int & DataSize, int & ReadPos)
|
||||
{
|
||||
enum { BufferIncrease = 0x2000 };
|
||||
enum
|
||||
{
|
||||
BufferIncrease = 0x2000
|
||||
};
|
||||
if (MaxDataSize == 0)
|
||||
{
|
||||
ReadPos = 0;
|
||||
|
@ -542,7 +569,10 @@ const char * CEnhancmentFile::CleanLine(char * Line)
|
|||
|
||||
void CEnhancmentFile::fInsertSpaces(int Pos, int NoOfSpaces)
|
||||
{
|
||||
enum { fIS_MvSize = 0x2000 };
|
||||
enum
|
||||
{
|
||||
fIS_MvSize = 0x2000
|
||||
};
|
||||
|
||||
unsigned char Data[fIS_MvSize + 1];
|
||||
int SizeToRead, result;
|
||||
|
@ -558,7 +588,10 @@ void CEnhancmentFile::fInsertSpaces(int Pos, int NoOfSpaces)
|
|||
do
|
||||
{
|
||||
SizeToRead = end - Pos;
|
||||
if (SizeToRead > fIS_MvSize) { SizeToRead = fIS_MvSize; }
|
||||
if (SizeToRead > fIS_MvSize)
|
||||
{
|
||||
SizeToRead = fIS_MvSize;
|
||||
}
|
||||
if (SizeToRead > 0)
|
||||
{
|
||||
m_File.Seek(SizeToRead * -1, CFileBase::current);
|
||||
|
@ -582,7 +615,10 @@ void CEnhancmentFile::fInsertSpaces(int Pos, int NoOfSpaces)
|
|||
do
|
||||
{
|
||||
SizeToRead = end - ReadPos;
|
||||
if (SizeToRead > fIS_MvSize) { SizeToRead = fIS_MvSize; }
|
||||
if (SizeToRead > fIS_MvSize)
|
||||
{
|
||||
SizeToRead = fIS_MvSize;
|
||||
}
|
||||
m_File.Seek(ReadPos, CFileBase::begin);
|
||||
m_File.Read(Data, SizeToRead);
|
||||
m_File.Seek(WritePos, CFileBase::begin);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#pragma once
|
||||
#include <Common/CriticalSection.h>
|
||||
#include <Common/File.h>
|
||||
#include <Project64-core/N64System/Enhancement/Enhancement.h>
|
||||
#include <Project64-core/N64System/Enhancement/EnhancementList.h>
|
||||
#include <Common/File.h>
|
||||
#include <Common/CriticalSection.h>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
class CEnhancmentFile
|
||||
{
|
||||
|
@ -38,7 +38,10 @@ public:
|
|||
|
||||
void GetSections(SectionList & sections);
|
||||
|
||||
const char * FileName(void) const { return m_FileName.c_str(); }
|
||||
const char * FileName(void) const
|
||||
{
|
||||
return m_FileName.c_str();
|
||||
}
|
||||
|
||||
private:
|
||||
CEnhancmentFile();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <Project64-core/N64System/Enhancement/Enhancement.h>
|
||||
#include <Common/Platform.h>
|
||||
#include <Project64-core/N64System/Enhancement/Enhancement.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct EnhancementItemList_compare
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
#include <Common/CriticalSection.h>
|
||||
#include <Common/Thread.h>
|
||||
#include <Project64-core/N64System/Enhancement/EnhancementFile.h>
|
||||
#include <Project64-core/N64System/Enhancement/EnhancementList.h>
|
||||
#include <Common/Thread.h>
|
||||
#include <Common/CriticalSection.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
|
@ -39,10 +39,22 @@ private:
|
|||
GAMESHARK_CODE(const GAMESHARK_CODE &);
|
||||
GAMESHARK_CODE(uint32_t Command, uint16_t Value, bool HasDisableValue, uint16_t DisableValue);
|
||||
|
||||
uint32_t Command(void) const { return m_Command; }
|
||||
uint16_t Value(void) const { return m_Value; }
|
||||
bool HasDisableValue(void) const { return m_HasDisableValue; }
|
||||
uint16_t DisableValue(void) const { return m_DisableValue; }
|
||||
uint32_t Command(void) const
|
||||
{
|
||||
return m_Command;
|
||||
}
|
||||
uint16_t Value(void) const
|
||||
{
|
||||
return m_Value;
|
||||
}
|
||||
bool HasDisableValue(void) const
|
||||
{
|
||||
return m_HasDisableValue;
|
||||
}
|
||||
uint16_t DisableValue(void) const
|
||||
{
|
||||
return m_DisableValue;
|
||||
}
|
||||
|
||||
private:
|
||||
GAMESHARK_CODE();
|
||||
|
@ -86,7 +98,11 @@ private:
|
|||
static uint32_t ConvertXP64Address(uint32_t Address);
|
||||
static uint16_t ConvertXP64Value(uint16_t Value);
|
||||
|
||||
static uint32_t stScanFileThread(void * lpThreadParameter) { ((CEnhancements *)lpThreadParameter)->ScanFileThread(); return 0; }
|
||||
static uint32_t stScanFileThread(void * lpThreadParameter)
|
||||
{
|
||||
((CEnhancements *)lpThreadParameter)->ScanFileThread();
|
||||
return 0;
|
||||
}
|
||||
|
||||
CriticalSection m_CS;
|
||||
SectionFiles m_CheatFiles, m_EnhancementFiles;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "FramePerSecond.h"
|
||||
#include <Project64-core/N64System/N64Types.h>
|
||||
|
||||
|
@ -86,7 +87,10 @@ void CFramePerSecond::UpdateDisplay(void)
|
|||
}
|
||||
if (m_iFrameRateType == FR_DLs || m_iFrameRateType == FR_VIs_DLs)
|
||||
{
|
||||
if (DisplayString.length() > 0) { DisplayString += " "; }
|
||||
if (DisplayString.length() > 0)
|
||||
{
|
||||
DisplayString += " ";
|
||||
}
|
||||
DisplayString += stdstr_f(m_DlistFrameRate >= 0 ? "DL/s: %.1f" : "DL/s: -.--", m_DlistFrameRate);
|
||||
}
|
||||
g_Notify->DisplayMessage2(DisplayString.c_str());
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include <Common/HighResTimeStamp.h>
|
||||
#include "../Settings/N64SystemSettings.h"
|
||||
#include <Common/HighResTimeStamp.h>
|
||||
|
||||
class CFramePerSecond : public CN64SystemSettings
|
||||
{
|
||||
|
@ -24,7 +24,10 @@ private:
|
|||
|
||||
int32_t m_iFrameRateType, m_ScreenHertz;
|
||||
|
||||
enum { NoOfFrames = 7 };
|
||||
enum
|
||||
{
|
||||
NoOfFrames = 7
|
||||
};
|
||||
|
||||
HighResTimeStamp m_LastViFrame;
|
||||
uint64_t m_ViFrames[NoOfFrames];
|
||||
|
|
|
@ -2155,9 +2155,18 @@ __inline void Float_RoundToInteger32(int32_t * Dest, const float * Source, int R
|
|||
*Dest = roundf(*Source);
|
||||
}
|
||||
}
|
||||
else if (RoundType == FE_TOWARDZERO) { *Dest = truncf(*Source); }
|
||||
else if (RoundType == FE_UPWARD) { *Dest = ceilf(*Source); }
|
||||
else if (RoundType == FE_DOWNWARD) { *Dest = floorf(*Source); }
|
||||
else if (RoundType == FE_TOWARDZERO)
|
||||
{
|
||||
*Dest = truncf(*Source);
|
||||
}
|
||||
else if (RoundType == FE_UPWARD)
|
||||
{
|
||||
*Dest = ceilf(*Source);
|
||||
}
|
||||
else if (RoundType == FE_DOWNWARD)
|
||||
{
|
||||
*Dest = floorf(*Source);
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
}
|
||||
|
@ -2187,9 +2196,18 @@ __inline void Float_RoundToInteger64(int64_t * Dest, const float * Source, int R
|
|||
*Dest = roundf(*Source);
|
||||
}
|
||||
}
|
||||
else if (RoundType == FE_TOWARDZERO) { *Dest = truncf(*Source); }
|
||||
else if (RoundType == FE_UPWARD) { *Dest = ceilf(*Source); }
|
||||
else if (RoundType == FE_DOWNWARD) { *Dest = floorf(*Source); }
|
||||
else if (RoundType == FE_TOWARDZERO)
|
||||
{
|
||||
*Dest = truncf(*Source);
|
||||
}
|
||||
else if (RoundType == FE_UPWARD)
|
||||
{
|
||||
*Dest = ceilf(*Source);
|
||||
}
|
||||
else if (RoundType == FE_DOWNWARD)
|
||||
{
|
||||
*Dest = floorf(*Source);
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
}
|
||||
|
@ -2392,9 +2410,18 @@ __inline void Double_RoundToInteger32(int32_t * Dest, const double * Source, int
|
|||
*Dest = round(*Source);
|
||||
}
|
||||
}
|
||||
else if (RoundType == FE_TOWARDZERO) { *Dest = trunc(*Source); }
|
||||
else if (RoundType == FE_UPWARD) { *Dest = ceil(*Source); }
|
||||
else if (RoundType == FE_DOWNWARD) { *Dest = floor(*Source); }
|
||||
else if (RoundType == FE_TOWARDZERO)
|
||||
{
|
||||
*Dest = trunc(*Source);
|
||||
}
|
||||
else if (RoundType == FE_UPWARD)
|
||||
{
|
||||
*Dest = ceil(*Source);
|
||||
}
|
||||
else if (RoundType == FE_DOWNWARD)
|
||||
{
|
||||
*Dest = floor(*Source);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
|
@ -2428,9 +2455,18 @@ __inline void Double_RoundToInteger64(int64_t * Dest, const double * Source, int
|
|||
*Dest = round(*Source);
|
||||
}
|
||||
}
|
||||
else if (RoundType == FE_TOWARDZERO) { *Dest = trunc(*Source); }
|
||||
else if (RoundType == FE_UPWARD) { *Dest = ceil(*Source); }
|
||||
else if (RoundType == FE_DOWNWARD) { *Dest = floor(*Source); }
|
||||
else if (RoundType == FE_TOWARDZERO)
|
||||
{
|
||||
*Dest = trunc(*Source);
|
||||
}
|
||||
else if (RoundType == FE_UPWARD)
|
||||
{
|
||||
*Dest = ceil(*Source);
|
||||
}
|
||||
else if (RoundType == FE_DOWNWARD)
|
||||
{
|
||||
*Dest = floor(*Source);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <Project64-core/Settings/DebugSettings.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iOpcode.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/Settings/DebugSettings.h>
|
||||
|
||||
class R4300iOp :
|
||||
public CLogging,
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "InterpreterOps32.h"
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Mips/SystemTiming.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
|
||||
#include <Project64-core/N64System/Interpreter/InterpreterCPU.h>
|
||||
#include <Project64-core/Logging.h>
|
||||
#include <Project64-core/Debugger.h>
|
||||
#include <Project64-core/Logging.h>
|
||||
#include <Project64-core/N64System/Interpreter/InterpreterCPU.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
|
||||
#include <Project64-core/N64System/Mips/SystemTiming.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
|
||||
#define TEST_COP1_USABLE_EXCEPTION \
|
||||
if ((g_Reg->STATUS_REGISTER & STATUS_CU1) == 0) {\
|
||||
if ((g_Reg->STATUS_REGISTER & STATUS_CU1) == 0) \
|
||||
{ \
|
||||
g_Reg->DoCopUnusableException(g_System->m_PipelineStage == PIPELINE_STAGE_JUMP, 1); \
|
||||
g_System->m_PipelineStage = PIPELINE_STAGE_JUMP; \
|
||||
g_System->m_JumpToLocation = (*_PROGRAM_COUNTER); \
|
||||
|
@ -1261,7 +1263,10 @@ void R4300iOp32::COP1_CF()
|
|||
TEST_COP1_USABLE_EXCEPTION
|
||||
if (m_Opcode.fs != 31 && m_Opcode.fs != 0)
|
||||
{
|
||||
if (CDebugSettings::HaveDebugger()) { g_Notify->DisplayError("CFC1: what register are you writing to?"); }
|
||||
if (CDebugSettings::HaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError("CFC1: what register are you writing to?");
|
||||
}
|
||||
return;
|
||||
}
|
||||
_GPR[m_Opcode.rt].W[0] = (int32_t)_FPCR[m_Opcode.fs];
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "AudioInterfaceHandler.h"
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
|
||||
AudioInterfaceReg::AudioInterfaceReg(uint32_t * _AudioInterface) :
|
||||
|
@ -301,4 +302,3 @@ void AudioInterfaceHandler::LenChanged()
|
|||
}
|
||||
WriteTrace(TraceAudio, TraceDebug, "Done");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
#include "MemoryHandler.h"
|
||||
#include <Project64-core\Logging.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <Project64-core\Settings\GameSettings.h>
|
||||
#include <Project64-core\Logging.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum
|
||||
|
@ -60,8 +60,14 @@ private:
|
|||
AudioInterfaceHandler(const AudioInterfaceHandler &);
|
||||
AudioInterfaceHandler & operator=(const AudioInterfaceHandler &);
|
||||
|
||||
static void stSystemReset(AudioInterfaceHandler * _this) { _this->SystemReset(); }
|
||||
static void stLoadedGameState(AudioInterfaceHandler * _this) { _this->LoadedGameState(); }
|
||||
static void stSystemReset(AudioInterfaceHandler * _this)
|
||||
{
|
||||
_this->SystemReset();
|
||||
}
|
||||
static void stLoadedGameState(AudioInterfaceHandler * _this)
|
||||
{
|
||||
_this->LoadedGameState();
|
||||
}
|
||||
|
||||
void LoadedGameState(void);
|
||||
void SystemReset(void);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "CartridgeDomain1Address1Handler.h"
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
#include <Project64-core\N64System\N64Rom.h>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "CartridgeDomain1Address3Handler.h"
|
||||
|
||||
CartridgeDomain1Address3Handler::CartridgeDomain1Address3Handler()
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "CartridgeDomain2Address1Handler.h"
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
#include <Project64-core\N64System\Mips\Disk.h>
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
|
||||
DiskInterfaceReg::DiskInterfaceReg(uint32_t * DiskInterface) :
|
||||
ASIC_DATA(DiskInterface[0]),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "CartridgeDomain2Address2Handler.h"
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
#include <Project64-core\N64System\SaveType\Sram.h>
|
||||
#include <Project64-core\N64System\SaveType\FlashRam.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include "MemoryHandler.h"
|
||||
#include <Project64-core\N64System\SaveType\FlashRam.h>
|
||||
#include <Project64-core\N64System\SaveType\Sram.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
|
||||
class CN64System;
|
||||
class CMipsMemoryVM;
|
||||
|
@ -21,8 +21,14 @@ public:
|
|||
bool DMARead();
|
||||
void DMAWrite();
|
||||
|
||||
CSram & Sram(void) { return m_Sram; }
|
||||
CFlashRam & FlashRam (void) { return m_FlashRam; }
|
||||
CSram & Sram(void)
|
||||
{
|
||||
return m_Sram;
|
||||
}
|
||||
CFlashRam & FlashRam(void)
|
||||
{
|
||||
return m_FlashRam;
|
||||
}
|
||||
|
||||
private:
|
||||
CartridgeDomain2Address2Handler(void);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#include "stdafx.h"
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
#include <Project64-core\Plugins\Plugin.h>
|
||||
#include <Project64-core\Plugins\GFXPlugin.h>
|
||||
#include <Project64-core\ExceptionHandler.h>
|
||||
|
||||
#include "SPRegistersHandler.h"
|
||||
#include <Project64-core\ExceptionHandler.h>
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
#include <Project64-core\Plugins\GFXPlugin.h>
|
||||
#include <Project64-core\Plugins\Plugin.h>
|
||||
|
||||
DisplayControlRegHandler::DisplayControlRegHandler(CN64System & N64System, CPlugins * Plugins, CRegisters & Reg) :
|
||||
DisplayControlReg(Reg.m_Display_ControlReg),
|
||||
|
@ -143,4 +144,3 @@ bool DisplayControlRegHandler::Write32(uint32_t Address, uint32_t Value, uint32_
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <Project64-core\Logging.h>
|
||||
#include "SPRegistersHandler.h"
|
||||
#include "MemoryHandler.h"
|
||||
#include "SPRegistersHandler.h"
|
||||
#include <Project64-core\Logging.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "ISViewerHandler.h"
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Common/path.h>
|
||||
#include <Common/File.h>
|
||||
#include <Common/path.h>
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
|
||||
ISViewerHandler::ISViewerHandler(CN64System & System) :
|
||||
m_hLogFile(nullptr),
|
||||
|
@ -70,10 +71,7 @@ uint32_t ISViewerHandler::Swap32by8(uint32_t Value)
|
|||
#elif defined(__GNUC__)
|
||||
__builtin_bswap32(Value)
|
||||
#else
|
||||
(Value & 0x000000FFul) << 24
|
||||
| (Value & 0x0000FF00ul) << 8
|
||||
| (Value & 0x00FF0000ul) >> 8
|
||||
| (Value & 0xFF000000ul) >> 24
|
||||
(Value & 0x000000FFul) << 24 | (Value & 0x0000FF00ul) << 8 | (Value & 0x00FF0000ul) >> 8 | (Value & 0xFF000000ul) >> 24
|
||||
#endif
|
||||
;
|
||||
return (Swapped & 0xFFFFFFFFul);
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#include "MemoryHandler.h"
|
||||
#include <Common/File.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
class CN64System;
|
||||
|
||||
|
@ -21,7 +21,10 @@ private:
|
|||
ISViewerHandler(const ISViewerHandler &);
|
||||
ISViewerHandler & operator=(const ISViewerHandler &);
|
||||
|
||||
static void stSystemReset(ISViewerHandler * _this) { _this->SystemReset(); }
|
||||
static void stSystemReset(ISViewerHandler * _this)
|
||||
{
|
||||
_this->SystemReset();
|
||||
}
|
||||
static uint32_t Swap32by8(uint32_t Value);
|
||||
|
||||
void SystemReset(void);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "MIPSInterfaceHandler.h"
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
|
||||
MIPSInterfaceReg::MIPSInterfaceReg(uint32_t * MipsInterface) :
|
||||
MI_INIT_MODE_REG(MipsInterface[0]),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "MemoryHandler.h"
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <Project64-core\Logging.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class MIPSInterfaceReg
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
#include "stdafx.h"
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
#include <Project64-core\N64System\Mips\MemoryVirtualMem.h>
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
#include <Project64-core\N64System\Mips\Disk.h>
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\N64Rom.h>
|
||||
#include <Project64-core\N64System\N64Disk.h>
|
||||
#include <Project64-core\Debugger.h>
|
||||
|
||||
#include "PeripheralInterfaceHandler.h"
|
||||
#include <Common\MemoryManagement.h>
|
||||
#include <Project64-core\Debugger.h>
|
||||
#include <Project64-core\N64System\Mips\Disk.h>
|
||||
#include <Project64-core\N64System\Mips\MemoryVirtualMem.h>
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
#include <Project64-core\N64System\N64Disk.h>
|
||||
#include <Project64-core\N64System\N64Rom.h>
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
|
||||
PeripheralInterfaceReg::PeripheralInterfaceReg(uint32_t * PeripheralInterface) :
|
||||
PI_DRAM_ADDR_REG(PeripheralInterface[0]),
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#pragma once
|
||||
#include <Project64-core\Settings\GameSettings.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <Project64-core\Logging.h>
|
||||
#include "MemoryHandler.h"
|
||||
#include <Project64-core/Logging.h>
|
||||
#include <Project64-core/N64System/MemoryHandler/MIPSInterfaceHandler.h>
|
||||
#include <Project64-core/Settings/DebugSettings.h>
|
||||
#include <Project64-core/Settings/GameSettings.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class PeripheralInterfaceReg
|
||||
|
@ -33,6 +34,7 @@ private:
|
|||
PeripheralInterfaceReg & operator=(const PeripheralInterfaceReg &);
|
||||
};
|
||||
|
||||
class CN64System;
|
||||
class CRegisters;
|
||||
class CMipsMemoryVM;
|
||||
class CartridgeDomain2Address2Handler;
|
||||
|
@ -68,8 +70,14 @@ private:
|
|||
PeripheralInterfaceHandler(const PeripheralInterfaceHandler &);
|
||||
PeripheralInterfaceHandler & operator=(const PeripheralInterfaceHandler &);
|
||||
|
||||
static void stSystemReset(PeripheralInterfaceHandler * _this) { _this->SystemReset(); }
|
||||
static void stLoadedGameState(PeripheralInterfaceHandler * _this) { _this->LoadedGameState(); }
|
||||
static void stSystemReset(PeripheralInterfaceHandler * _this)
|
||||
{
|
||||
_this->SystemReset();
|
||||
}
|
||||
static void stLoadedGameState(PeripheralInterfaceHandler * _this)
|
||||
{
|
||||
_this->LoadedGameState();
|
||||
}
|
||||
|
||||
void PI_DMA_READ();
|
||||
void PI_DMA_WRITE();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "PifRamHandler.h"
|
||||
#include <Project64-core\N64System\Mips\MemoryVirtualMem.h>
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
|
@ -79,10 +80,7 @@ uint32_t PifRamHandler::swap32by8(uint32_t word)
|
|||
#elif defined(__GNUC__)
|
||||
__builtin_bswap32(word)
|
||||
#else
|
||||
(word & 0x000000FFul) << 24
|
||||
| (word & 0x0000FF00ul) << 8
|
||||
| (word & 0x00FF0000ul) >> 8
|
||||
| (word & 0xFF000000ul) >> 24
|
||||
(word & 0x000000FFul) << 24 | (word & 0x0000FF00ul) << 8 | (word & 0x00FF0000ul) >> 8 | (word & 0xFF000000ul) >> 24
|
||||
#endif
|
||||
;
|
||||
return (swapped & 0xFFFFFFFFul);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "MemoryHandler.h"
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <Project64-core\Logging.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class CMipsMemoryVM;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
|
||||
#include "RDRAMInterfaceHandler.h"
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
|
||||
RDRAMInterfaceReg::RDRAMInterfaceReg(uint32_t * RdramInterface) :
|
||||
RI_MODE_REG(RdramInterface[0]),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "MemoryHandler.h"
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <Project64-core\Logging.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class RDRAMInterfaceReg
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "RDRAMRegistersHandler.h"
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "MemoryHandler.h"
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <Project64-core\Logging.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class RDRAMRegistersReg
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "RomMemoryHandler.h"
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
#include <Project64-core\N64System\N64Rom.h>
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
|
||||
RomMemoryHandler::RomMemoryHandler(CN64System & System, CRegisters & Reg, CN64Rom & Rom) :
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "MemoryHandler.h"
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <Project64-core\Logging.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class CRegisters;
|
||||
|
@ -29,8 +29,14 @@ private:
|
|||
void SystemReset(void);
|
||||
void LoadedGameState(void);
|
||||
|
||||
static void stSystemReset(RomMemoryHandler * _this) { _this->SystemReset(); }
|
||||
static void stLoadedGameState(RomMemoryHandler * _this) { _this->LoadedGameState(); }
|
||||
static void stSystemReset(RomMemoryHandler * _this)
|
||||
{
|
||||
_this->SystemReset();
|
||||
}
|
||||
static void stLoadedGameState(RomMemoryHandler * _this)
|
||||
{
|
||||
_this->LoadedGameState();
|
||||
}
|
||||
|
||||
uint32_t & m_PC;
|
||||
CRegisters & m_Reg;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "SPRegistersHandler.h"
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\Mips\MemoryVirtualMem.h>
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
|
||||
SPRegistersReg::SPRegistersReg(uint32_t * SignalProcessorInterface) :
|
||||
|
@ -119,36 +120,111 @@ bool SPRegistersHandler::Write32(uint32_t Address, uint32_t Value, uint32_t Mask
|
|||
SP_DMA_WRITE();
|
||||
break;
|
||||
case 0x04040010:
|
||||
if ((MaskedValue & SP_CLR_HALT) != 0) { SP_STATUS_REG &= ~SP_STATUS_HALT; }
|
||||
if ((MaskedValue & SP_SET_HALT) != 0) { SP_STATUS_REG |= SP_STATUS_HALT; }
|
||||
if ((MaskedValue & SP_CLR_BROKE) != 0) { SP_STATUS_REG &= ~SP_STATUS_BROKE; }
|
||||
if ((MaskedValue & SP_CLR_HALT) != 0)
|
||||
{
|
||||
SP_STATUS_REG &= ~SP_STATUS_HALT;
|
||||
}
|
||||
if ((MaskedValue & SP_SET_HALT) != 0)
|
||||
{
|
||||
SP_STATUS_REG |= SP_STATUS_HALT;
|
||||
}
|
||||
if ((MaskedValue & SP_CLR_BROKE) != 0)
|
||||
{
|
||||
SP_STATUS_REG &= ~SP_STATUS_BROKE;
|
||||
}
|
||||
if ((MaskedValue & SP_CLR_INTR) != 0)
|
||||
{
|
||||
MI_INTR_REG &= ~MI_INTR_SP;
|
||||
m_RspIntrReg &= ~MI_INTR_SP;
|
||||
m_Reg.CheckInterrupts();
|
||||
}
|
||||
if ((MaskedValue & SP_SET_INTR) != 0) { if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); } }
|
||||
if ((MaskedValue & SP_CLR_SSTEP) != 0) { SP_STATUS_REG &= ~SP_STATUS_SSTEP; }
|
||||
if ((MaskedValue & SP_SET_SSTEP) != 0) { SP_STATUS_REG |= SP_STATUS_SSTEP; }
|
||||
if ((MaskedValue & SP_CLR_INTR_BREAK) != 0) { SP_STATUS_REG &= ~SP_STATUS_INTR_BREAK; }
|
||||
if ((MaskedValue & SP_SET_INTR_BREAK) != 0) { SP_STATUS_REG |= SP_STATUS_INTR_BREAK; }
|
||||
if ((MaskedValue & SP_CLR_SIG0) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG0; }
|
||||
if ((MaskedValue & SP_SET_SIG0) != 0) { SP_STATUS_REG |= SP_STATUS_SIG0; }
|
||||
if ((MaskedValue & SP_CLR_SIG1) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG1; }
|
||||
if ((MaskedValue & SP_SET_SIG1) != 0) { SP_STATUS_REG |= SP_STATUS_SIG1; }
|
||||
if ((MaskedValue & SP_CLR_SIG2) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG2; }
|
||||
if ((MaskedValue & SP_SET_SIG2) != 0) { SP_STATUS_REG |= SP_STATUS_SIG2; }
|
||||
if ((MaskedValue & SP_CLR_SIG3) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG3; }
|
||||
if ((MaskedValue & SP_SET_SIG3) != 0) { SP_STATUS_REG |= SP_STATUS_SIG3; }
|
||||
if ((MaskedValue & SP_CLR_SIG4) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG4; }
|
||||
if ((MaskedValue & SP_SET_SIG4) != 0) { SP_STATUS_REG |= SP_STATUS_SIG4; }
|
||||
if ((MaskedValue & SP_CLR_SIG5) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG5; }
|
||||
if ((MaskedValue & SP_SET_SIG5) != 0) { SP_STATUS_REG |= SP_STATUS_SIG5; }
|
||||
if ((MaskedValue & SP_CLR_SIG6) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG6; }
|
||||
if ((MaskedValue & SP_SET_SIG6) != 0) { SP_STATUS_REG |= SP_STATUS_SIG6; }
|
||||
if ((MaskedValue & SP_CLR_SIG7) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG7; }
|
||||
if ((MaskedValue & SP_SET_SIG7) != 0) { SP_STATUS_REG |= SP_STATUS_SIG7; }
|
||||
if ((MaskedValue & SP_SET_INTR) != 0)
|
||||
{
|
||||
if (BreakOnUnhandledMemory())
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
if ((MaskedValue & SP_CLR_SSTEP) != 0)
|
||||
{
|
||||
SP_STATUS_REG &= ~SP_STATUS_SSTEP;
|
||||
}
|
||||
if ((MaskedValue & SP_SET_SSTEP) != 0)
|
||||
{
|
||||
SP_STATUS_REG |= SP_STATUS_SSTEP;
|
||||
}
|
||||
if ((MaskedValue & SP_CLR_INTR_BREAK) != 0)
|
||||
{
|
||||
SP_STATUS_REG &= ~SP_STATUS_INTR_BREAK;
|
||||
}
|
||||
if ((MaskedValue & SP_SET_INTR_BREAK) != 0)
|
||||
{
|
||||
SP_STATUS_REG |= SP_STATUS_INTR_BREAK;
|
||||
}
|
||||
if ((MaskedValue & SP_CLR_SIG0) != 0)
|
||||
{
|
||||
SP_STATUS_REG &= ~SP_STATUS_SIG0;
|
||||
}
|
||||
if ((MaskedValue & SP_SET_SIG0) != 0)
|
||||
{
|
||||
SP_STATUS_REG |= SP_STATUS_SIG0;
|
||||
}
|
||||
if ((MaskedValue & SP_CLR_SIG1) != 0)
|
||||
{
|
||||
SP_STATUS_REG &= ~SP_STATUS_SIG1;
|
||||
}
|
||||
if ((MaskedValue & SP_SET_SIG1) != 0)
|
||||
{
|
||||
SP_STATUS_REG |= SP_STATUS_SIG1;
|
||||
}
|
||||
if ((MaskedValue & SP_CLR_SIG2) != 0)
|
||||
{
|
||||
SP_STATUS_REG &= ~SP_STATUS_SIG2;
|
||||
}
|
||||
if ((MaskedValue & SP_SET_SIG2) != 0)
|
||||
{
|
||||
SP_STATUS_REG |= SP_STATUS_SIG2;
|
||||
}
|
||||
if ((MaskedValue & SP_CLR_SIG3) != 0)
|
||||
{
|
||||
SP_STATUS_REG &= ~SP_STATUS_SIG3;
|
||||
}
|
||||
if ((MaskedValue & SP_SET_SIG3) != 0)
|
||||
{
|
||||
SP_STATUS_REG |= SP_STATUS_SIG3;
|
||||
}
|
||||
if ((MaskedValue & SP_CLR_SIG4) != 0)
|
||||
{
|
||||
SP_STATUS_REG &= ~SP_STATUS_SIG4;
|
||||
}
|
||||
if ((MaskedValue & SP_SET_SIG4) != 0)
|
||||
{
|
||||
SP_STATUS_REG |= SP_STATUS_SIG4;
|
||||
}
|
||||
if ((MaskedValue & SP_CLR_SIG5) != 0)
|
||||
{
|
||||
SP_STATUS_REG &= ~SP_STATUS_SIG5;
|
||||
}
|
||||
if ((MaskedValue & SP_SET_SIG5) != 0)
|
||||
{
|
||||
SP_STATUS_REG |= SP_STATUS_SIG5;
|
||||
}
|
||||
if ((MaskedValue & SP_CLR_SIG6) != 0)
|
||||
{
|
||||
SP_STATUS_REG &= ~SP_STATUS_SIG6;
|
||||
}
|
||||
if ((MaskedValue & SP_SET_SIG6) != 0)
|
||||
{
|
||||
SP_STATUS_REG |= SP_STATUS_SIG6;
|
||||
}
|
||||
if ((MaskedValue & SP_CLR_SIG7) != 0)
|
||||
{
|
||||
SP_STATUS_REG &= ~SP_STATUS_SIG7;
|
||||
}
|
||||
if ((MaskedValue & SP_SET_SIG7) != 0)
|
||||
{
|
||||
SP_STATUS_REG |= SP_STATUS_SIG7;
|
||||
}
|
||||
if ((MaskedValue & SP_SET_SIG0) != 0 && RspAudioSignal())
|
||||
{
|
||||
MI_INTR_REG |= MI_INTR_SP;
|
||||
|
@ -218,7 +294,10 @@ void SPRegistersHandler::SP_DMA_READ()
|
|||
if ((CopyLength + ReadPos) > m_MMU.RdramSize())
|
||||
{
|
||||
int32_t CopyAmount = m_MMU.RdramSize() - ReadPos;
|
||||
if (CopyAmount < 0) { CopyAmount = 0; }
|
||||
if (CopyAmount < 0)
|
||||
{
|
||||
CopyAmount = 0;
|
||||
}
|
||||
NullLen = CopyLength - CopyAmount;
|
||||
|
||||
if (CopyAmount > 0)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#pragma once
|
||||
#include "MemoryHandler.h"
|
||||
#include "MIPSInterfaceHandler.h"
|
||||
#include <Project64-core\Settings\GameSettings.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include "MemoryHandler.h"
|
||||
#include <Project64-core\Logging.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <Project64-core\Settings\GameSettings.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class SPRegistersReg
|
||||
|
@ -51,8 +51,14 @@ private:
|
|||
SPRegistersHandler(const SPRegistersHandler &);
|
||||
SPRegistersHandler & operator=(const SPRegistersHandler &);
|
||||
|
||||
static void stSystemReset(SPRegistersHandler * _this) { _this->SystemReset(); }
|
||||
static void stLoadedGameState(SPRegistersHandler * _this) { _this->LoadedGameState(); }
|
||||
static void stSystemReset(SPRegistersHandler * _this)
|
||||
{
|
||||
_this->SystemReset();
|
||||
}
|
||||
static void stLoadedGameState(SPRegistersHandler * _this)
|
||||
{
|
||||
_this->LoadedGameState();
|
||||
}
|
||||
|
||||
void SP_DMA_READ();
|
||||
void SP_DMA_WRITE();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "SerialInterfaceHandler.h"
|
||||
#include <Project64-core\N64System\Mips\MemoryVirtualMem.h>
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
#include "MemoryHandler.h"
|
||||
#include "MIPSInterfaceHandler.h"
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include "MemoryHandler.h"
|
||||
#include <Project64-core\Logging.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "VideoInterfaceHandler.h"
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\Mips\MemoryVirtualMem.h>
|
||||
#include <Project64-core\N64System\Mips\SystemTiming.h>
|
||||
#include <Project64-core\N64System\Mips\Register.h>
|
||||
#include <Project64-core\Plugin.h>
|
||||
#include <Project64-core\N64System\Mips\SystemTiming.h>
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
#include <Project64-core\Plugin.h>
|
||||
|
||||
VideoInterfaceReg::VideoInterfaceReg(uint32_t * VideoInterface) :
|
||||
VI_STATUS_REG(VideoInterface[0]),
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
#include "MemoryHandler.h"
|
||||
#include <Project64-core\Logging.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <Project64-core\Settings\GameSettings.h>
|
||||
#include <Project64-core\Logging.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class VideoInterfaceReg
|
||||
|
@ -67,8 +67,14 @@ private:
|
|||
VideoInterfaceHandler(const VideoInterfaceHandler &);
|
||||
VideoInterfaceHandler & operator=(const VideoInterfaceHandler &);
|
||||
|
||||
static void stSystemReset(VideoInterfaceHandler * _this) { _this->SystemReset(); }
|
||||
static void stLoadedGameState(VideoInterfaceHandler * _this) { _this->LoadedGameState(); }
|
||||
static void stSystemReset(VideoInterfaceHandler * _this)
|
||||
{
|
||||
_this->SystemReset();
|
||||
}
|
||||
static void stLoadedGameState(VideoInterfaceHandler * _this)
|
||||
{
|
||||
_this->LoadedGameState();
|
||||
}
|
||||
|
||||
void UpdateHalfLine();
|
||||
void LoadedGameState(void);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
// Based on MAME's N64DD driver code by Happy_
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "Disk.h"
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/N64Disk.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/Mips/SystemTiming.h>
|
||||
#include <Project64-core/N64System/N64Disk.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
|
@ -72,7 +73,8 @@ void DiskCommand()
|
|||
break;
|
||||
case 0x00080000:
|
||||
// Unset disk changed bit
|
||||
g_Reg->ASIC_STATUS &= ~DD_STATUS_DISK_CHNG; break;
|
||||
g_Reg->ASIC_STATUS &= ~DD_STATUS_DISK_CHNG;
|
||||
break;
|
||||
case 0x00090000:
|
||||
// Unset reset and disk changed bit bit
|
||||
g_Reg->ASIC_STATUS &= ~DD_STATUS_RST_STATE;
|
||||
|
@ -84,16 +86,20 @@ void DiskCommand()
|
|||
break;
|
||||
case 0x00120000:
|
||||
// RTC get year and month
|
||||
g_Reg->ASIC_DATA = (year << 24) | (month << 16); break;
|
||||
g_Reg->ASIC_DATA = (year << 24) | (month << 16);
|
||||
break;
|
||||
case 0x00130000:
|
||||
// RTC get day and hour
|
||||
g_Reg->ASIC_DATA = (day << 24) | (hour << 16); break;
|
||||
g_Reg->ASIC_DATA = (day << 24) | (hour << 16);
|
||||
break;
|
||||
case 0x00140000:
|
||||
// RTC get minute and second
|
||||
g_Reg->ASIC_DATA = (minute << 24) | (second << 16); break;
|
||||
g_Reg->ASIC_DATA = (minute << 24) | (second << 16);
|
||||
break;
|
||||
case 0x001B0000:
|
||||
// Disk inquiry
|
||||
g_Reg->ASIC_DATA = 0x00000000; break;
|
||||
g_Reg->ASIC_DATA = 0x00000000;
|
||||
break;
|
||||
}
|
||||
|
||||
if (isSeek)
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
// GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GBCart.h"
|
||||
|
||||
#include <time.h>
|
||||
#include "GBCart.h"
|
||||
#include <memory>
|
||||
#include <time.h>
|
||||
|
||||
static void read_gb_cart_normal(struct gb_cart * gb_cart, uint16_t address, uint8_t * data)
|
||||
{
|
||||
|
@ -232,32 +232,38 @@ void memoryUpdateMBC3Clock(struct gb_cart* gb_cart)
|
|||
{
|
||||
time_t now = time(nullptr);
|
||||
time_t diff = now - gb_cart->rtc_last_time;
|
||||
if (diff > 0) {
|
||||
if (diff > 0)
|
||||
{
|
||||
// Update the clock according to the last update time
|
||||
gb_cart->rtc_data[0] += (int)(diff % 60);
|
||||
if (gb_cart->rtc_data[0] > 59) {
|
||||
if (gb_cart->rtc_data[0] > 59)
|
||||
{
|
||||
gb_cart->rtc_data[0] -= 60;
|
||||
gb_cart->rtc_data[1]++;
|
||||
}
|
||||
diff /= 60;
|
||||
|
||||
gb_cart->rtc_data[1] += (int)(diff % 60);
|
||||
if (gb_cart->rtc_data[1] > 59) {
|
||||
if (gb_cart->rtc_data[1] > 59)
|
||||
{
|
||||
gb_cart->rtc_data[1] -= 60;
|
||||
gb_cart->rtc_data[2]++;
|
||||
}
|
||||
diff /= 60;
|
||||
|
||||
gb_cart->rtc_data[2] += (int)(diff % 24);
|
||||
if (gb_cart->rtc_data[2] > 23) {
|
||||
if (gb_cart->rtc_data[2] > 23)
|
||||
{
|
||||
gb_cart->rtc_data[2] -= 24;
|
||||
gb_cart->rtc_data[3]++;
|
||||
}
|
||||
diff /= 24;
|
||||
|
||||
gb_cart->rtc_data[3] += (int)(diff & 0xFFFFFFFF);
|
||||
if (gb_cart->rtc_data[3] > 255) {
|
||||
if (gb_cart->rtc_data[3] > 511) {
|
||||
if (gb_cart->rtc_data[3] > 255)
|
||||
{
|
||||
if (gb_cart->rtc_data[3] > 511)
|
||||
{
|
||||
gb_cart->rtc_data[3] %= 512;
|
||||
gb_cart->rtc_data[3] |= 0x80;
|
||||
}
|
||||
|
@ -641,8 +647,7 @@ static const struct parsed_cart_type* parse_cart_type(uint8_t cart_type)
|
|||
{MBC(pocket_cam), GED_NONE},
|
||||
{MBC(bandai_tama5), GED_NONE},
|
||||
{MBC(huc3), GED_NONE},
|
||||
{ MBC(huc1), GED_RAM | GED_BATTERY }
|
||||
};
|
||||
{MBC(huc1), GED_RAM | GED_BATTERY}};
|
||||
#undef MBC
|
||||
|
||||
switch (cart_type)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include <Project64-core\N64System\Mips\MemoryVirtualMem.h>
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
#include <Project64-core\N64System\N64Rom.h>
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\Mips\Disk.h>
|
||||
#include <Common\MemoryManagement.h>
|
||||
#include <Project64-core\Debugger.h>
|
||||
#include <Project64-core\ExceptionHandler.h>
|
||||
#include <Common\MemoryManagement.h>
|
||||
#include <Project64-core\N64System\Mips\Disk.h>
|
||||
#include <Project64-core\N64System\Mips\MemoryVirtualMem.h>
|
||||
#include <Project64-core\N64System\N64Rom.h>
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Project64-core\N64System\SystemGlobals.h>
|
||||
#include <stdio.h>
|
||||
|
||||
uint8_t * CMipsMemoryVM::m_Reserve1 = nullptr;
|
||||
|
@ -296,7 +296,6 @@ uint8_t * CMipsMemoryVM::MemoryPtr(uint32_t VAddr, uint32_t Size, bool Read)
|
|||
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
bool CMipsMemoryVM::MemoryValue8(uint32_t VAddr, uint8_t & Value)
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
#pragma once
|
||||
#include <Project64-core\N64System\Mips\MemoryVirtualMem.h>
|
||||
#include <Project64-core\N64System\Recompiler\RecompilerOps.h>
|
||||
#include <Project64-core\N64System\Interpreter\InterpreterOps.h>
|
||||
#include <Project64-core\N64System\Mips\PifRam.h>
|
||||
#include <Project64-core\N64System\SaveType\FlashRam.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\AudioInterfaceHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\CartridgeDomain1Address1Handler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\CartridgeDomain1Address3Handler.h>
|
||||
|
@ -17,9 +13,13 @@
|
|||
#include <Project64-core\N64System\MemoryHandler\RDRAMInterfaceHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\RDRAMRegistersHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\RomMemoryHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\SerialInterfaceHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\SPRegistersHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\SerialInterfaceHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\VideoInterfaceHandler.h>
|
||||
#include <Project64-core\N64System\Mips\MemoryVirtualMem.h>
|
||||
#include <Project64-core\N64System\Mips\PifRam.h>
|
||||
#include <Project64-core\N64System\Recompiler\RecompilerOps.h>
|
||||
#include <Project64-core\N64System\SaveType\FlashRam.h>
|
||||
#include <Project64-core\Settings\GameSettings.h>
|
||||
|
||||
#ifdef __arm__
|
||||
|
@ -63,14 +63,35 @@ public:
|
|||
bool Initialize(bool SyncSystem);
|
||||
void Reset(bool EraseMemory);
|
||||
|
||||
uint8_t * Rdram() const { return m_RDRAM; }
|
||||
uint32_t RdramSize() const { return m_AllocatedRdramSize; }
|
||||
uint8_t * Dmem() const { return m_DMEM; }
|
||||
uint8_t * Imem() const { return m_IMEM; }
|
||||
uint8_t * PifRam() { return &m_PifRam[0]; }
|
||||
uint8_t * Rdram() const
|
||||
{
|
||||
return m_RDRAM;
|
||||
}
|
||||
uint32_t RdramSize() const
|
||||
{
|
||||
return m_AllocatedRdramSize;
|
||||
}
|
||||
uint8_t * Dmem() const
|
||||
{
|
||||
return m_DMEM;
|
||||
}
|
||||
uint8_t * Imem() const
|
||||
{
|
||||
return m_IMEM;
|
||||
}
|
||||
uint8_t * PifRam()
|
||||
{
|
||||
return &m_PifRam[0];
|
||||
}
|
||||
|
||||
CSram & GetSram() { return m_CartridgeDomain2Address2Handler.Sram(); }
|
||||
CFlashRam & GetFlashRam() { return m_CartridgeDomain2Address2Handler.FlashRam(); }
|
||||
CSram & GetSram()
|
||||
{
|
||||
return m_CartridgeDomain2Address2Handler.Sram();
|
||||
}
|
||||
CFlashRam & GetFlashRam()
|
||||
{
|
||||
return m_CartridgeDomain2Address2Handler.FlashRam();
|
||||
}
|
||||
|
||||
uint8_t * MemoryPtr(uint32_t VAddr, uint32_t Size, bool Read);
|
||||
|
||||
|
@ -116,9 +137,18 @@ public:
|
|||
// Labels
|
||||
const char * LabelName(uint32_t Address) const;
|
||||
|
||||
AudioInterfaceHandler & AudioInterface(void) { return m_AudioInterfaceHandler; }
|
||||
VideoInterfaceHandler & VideoInterface(void) { return m_VideoInterfaceHandler; }
|
||||
RomMemoryHandler & RomMemory(void) { return m_RomMemoryHandler; };
|
||||
AudioInterfaceHandler & AudioInterface(void)
|
||||
{
|
||||
return m_AudioInterfaceHandler;
|
||||
}
|
||||
VideoInterfaceHandler & VideoInterface(void)
|
||||
{
|
||||
return m_VideoInterfaceHandler;
|
||||
}
|
||||
RomMemoryHandler & RomMemory(void)
|
||||
{
|
||||
return m_RomMemoryHandler;
|
||||
};
|
||||
|
||||
private:
|
||||
CMipsMemoryVM();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
#include "Mempak.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "Mempak.h"
|
||||
#include <Common/path.h>
|
||||
#include <stdio.h>
|
||||
|
||||
CMempak::CMempak()
|
||||
{
|
||||
|
@ -67,6 +67,7 @@ void CMempak::LoadMempak(int32_t Control, bool Create)
|
|||
|
||||
void CMempak::Format(int32_t Control)
|
||||
{
|
||||
// clang-format off
|
||||
static const uint8_t Initialize[] = {
|
||||
0x81, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
|
@ -107,8 +108,9 @@ void CMempak::Format(int32_t Control)
|
|||
0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03,
|
||||
0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03,
|
||||
0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03,
|
||||
0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03
|
||||
0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03,
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
memcpy(&m_Mempaks[Control][0], &Initialize[0], sizeof(Initialize));
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#include "stdafx.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Project64-core/Debugger.h>
|
||||
#include <Project64-core/Logging.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Mips/Mempak.h>
|
||||
#include <Project64-core/N64System/Mips/PifRam.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/Mips/Rumblepak.h>
|
||||
#include <Project64-core/N64System/Mips/Transferpak.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/Plugins/ControllerPlugin.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/Mips/Transferpak.h>
|
||||
#include <Project64-core/N64System/Mips/Rumblepak.h>
|
||||
#include <Project64-core/N64System/Mips/Mempak.h>
|
||||
#include <Project64-core/Logging.h>
|
||||
#include <Project64-core/Debugger.h>
|
||||
#include <Project64-plugin-spec/Input.h>
|
||||
|
||||
CPifRam::CPifRam(bool SavesReadOnly) :
|
||||
|
@ -32,14 +32,16 @@ void CPifRam::Reset()
|
|||
|
||||
void CPifRam::n64_cic_nus_6105(char challenge[], char respone[], int32_t length)
|
||||
{
|
||||
// clang-format off
|
||||
static char lut0[0x10] = {
|
||||
0x4, 0x7, 0xA, 0x7, 0xE, 0x5, 0xE, 0x1,
|
||||
0xC, 0xF, 0x8, 0xF, 0x6, 0x3, 0x6, 0x9
|
||||
0xC, 0xF, 0x8, 0xF, 0x6, 0x3, 0x6, 0x9,
|
||||
};
|
||||
static char lut1[0x10] = {
|
||||
0x4, 0x1, 0xA, 0x7, 0xE, 0x5, 0xE, 0x1,
|
||||
0xC, 0x9, 0x8, 0x5, 0x6, 0x3, 0xC, 0x9
|
||||
0xC, 0x9, 0x8, 0x5, 0x6, 0x3, 0xC, 0x9,
|
||||
};
|
||||
// clang-format on
|
||||
char key, *lut;
|
||||
int32_t i, sgn, mag, mod;
|
||||
|
||||
|
@ -85,8 +87,11 @@ void CPifRam::PifRamRead()
|
|||
break;
|
||||
case 0xFD: CurPos = 0x40; break;
|
||||
case 0xFE: CurPos = 0x40; break;
|
||||
case 0xFF: break;
|
||||
case 0xB4: case 0x56: case 0xB8: break;
|
||||
case 0xFF:
|
||||
case 0xB4:
|
||||
case 0x56:
|
||||
case 0xB8:
|
||||
break;
|
||||
default:
|
||||
if ((m_PifRam[CurPos] & 0xC0) == 0)
|
||||
{
|
||||
|
@ -195,8 +200,11 @@ void CPifRam::PifRamWrite()
|
|||
break;
|
||||
case 0xFD: CurPos = 0x40; break;
|
||||
case 0xFE: CurPos = 0x40; break;
|
||||
case 0xFF: break;
|
||||
case 0xB4: case 0x56: case 0xB8: break; // ???
|
||||
case 0xFF:
|
||||
case 0xB4:
|
||||
case 0x56:
|
||||
case 0xB8:
|
||||
break;
|
||||
default:
|
||||
if ((m_PifRam[CurPos] & 0xC0) == 0)
|
||||
{
|
||||
|
@ -378,7 +386,8 @@ void CPifRam::SI_DMA_WRITE()
|
|||
{
|
||||
if (RdramPos < 0)
|
||||
{
|
||||
m_PifRam[count] = 0; continue;
|
||||
m_PifRam[count] = 0;
|
||||
continue;
|
||||
}
|
||||
m_PifRam[count] = RDRAM[RdramPos ^ 3];
|
||||
}
|
||||
|
@ -474,7 +483,8 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command)
|
|||
case PLUGIN_RUMBLE_PAK:
|
||||
case PLUGIN_MEMPAK:
|
||||
case PLUGIN_RAW:
|
||||
Command[5] = 1; break;
|
||||
Command[5] = 1;
|
||||
break;
|
||||
default: Command[5] = 0; break;
|
||||
}
|
||||
}
|
||||
|
@ -526,7 +536,12 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command)
|
|||
case PLUGIN_RUMBLE_PAK: Rumblepak::ReadFrom(address, data); break;
|
||||
case PLUGIN_MEMPAK: g_Mempak->ReadFrom(Control, address, data); break;
|
||||
case PLUGIN_TRANSFER_PAK: Transferpak::ReadFrom((uint16_t)address, data); break;
|
||||
case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break;
|
||||
case PLUGIN_RAW:
|
||||
if (g_Plugins->Control()->ControllerCommand)
|
||||
{
|
||||
g_Plugins->Control()->ControllerCommand(Control, Command);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
memset(&Command[5], 0, 0x20);
|
||||
}
|
||||
|
@ -567,7 +582,12 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command)
|
|||
case PLUGIN_MEMPAK: g_Mempak->WriteTo(Control, address, data); break;
|
||||
case PLUGIN_RUMBLE_PAK: Rumblepak::WriteTo(Control, address, data); break;
|
||||
case PLUGIN_TRANSFER_PAK: Transferpak::WriteTo((uint16_t)address, data); break;
|
||||
case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break;
|
||||
case PLUGIN_RAW:
|
||||
if (g_Plugins->Control()->ControllerCommand)
|
||||
{
|
||||
g_Plugins->Control()->ControllerCommand(Control, Command);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (Controllers[Control].Plugin != PLUGIN_RAW)
|
||||
|
@ -603,7 +623,10 @@ void CPifRam::ReadControllerCommand(int32_t Control, uint8_t * Command)
|
|||
{
|
||||
if (bShowPifRamErrors())
|
||||
{
|
||||
if (Command[0] != 1 || Command[1] != 4) { g_Notify->DisplayError("What am I meant to do with this controller command?"); }
|
||||
if (Command[0] != 1 || Command[1] != 4)
|
||||
{
|
||||
g_Notify->DisplayError("What am I meant to do with this controller command?");
|
||||
}
|
||||
}
|
||||
|
||||
const uint32_t buttons = g_BaseSystem->GetButtons(Control);
|
||||
|
@ -615,7 +638,12 @@ void CPifRam::ReadControllerCommand(int32_t Control, uint8_t * Command)
|
|||
{
|
||||
switch (Controllers[Control].Plugin)
|
||||
{
|
||||
case PLUGIN_RAW: if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Control, Command); } break;
|
||||
case PLUGIN_RAW:
|
||||
if (g_Plugins->Control()->ReadController)
|
||||
{
|
||||
g_Plugins->Control()->ReadController(Control, Command);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -624,7 +652,12 @@ void CPifRam::ReadControllerCommand(int32_t Control, uint8_t * Command)
|
|||
{
|
||||
switch (Controllers[Control].Plugin)
|
||||
{
|
||||
case PLUGIN_RAW: if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Control, Command); } break;
|
||||
case PLUGIN_RAW:
|
||||
if (g_Plugins->Control()->ReadController)
|
||||
{
|
||||
g_Plugins->Control()->ReadController(Control, Command);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -28,7 +28,10 @@ private:
|
|||
CPifRam(const CPifRam &);
|
||||
CPifRam & operator=(const CPifRam &);
|
||||
|
||||
enum { CHALLENGE_LENGTH = 0x20 };
|
||||
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);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "stdafx.h"
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
|
||||
#include "R4300iInstruction.h"
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
|
||||
R4300iInstruction::R4300iInstruction(uint32_t Address, uint32_t Instruction) :
|
||||
m_Address(Address)
|
||||
|
@ -326,10 +327,22 @@ bool R4300iInstruction::DelaySlotEffectsCompare(uint32_t DelayInstruction) const
|
|||
|
||||
const char * R4300iInstruction::FPR_Type(uint32_t COP1OpCode)
|
||||
{
|
||||
if (COP1OpCode == R4300i_COP1_S) { return "S"; };
|
||||
if (COP1OpCode == R4300i_COP1_D) { return "D"; };
|
||||
if (COP1OpCode == R4300i_COP1_W) { return "W"; };
|
||||
if (COP1OpCode == R4300i_COP1_L) { return "L"; };
|
||||
if (COP1OpCode == R4300i_COP1_S)
|
||||
{
|
||||
return "S";
|
||||
};
|
||||
if (COP1OpCode == R4300i_COP1_D)
|
||||
{
|
||||
return "D";
|
||||
};
|
||||
if (COP1OpCode == R4300i_COP1_W)
|
||||
{
|
||||
return "W";
|
||||
};
|
||||
if (COP1OpCode == R4300i_COP1_L)
|
||||
{
|
||||
return "L";
|
||||
};
|
||||
return "?";
|
||||
}
|
||||
|
||||
|
@ -1152,4 +1165,3 @@ void R4300iInstruction::DecodeCop1Name(void)
|
|||
sprintf(m_Param, "0x%08X", m_Instruction.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include <Project64-core/Logging.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/Logging.h>
|
||||
|
||||
const char * CRegName::GPR[32] = {
|
||||
"R0",
|
||||
|
@ -36,11 +37,10 @@ const char * CRegName::GPR[32] = {
|
|||
"GP",
|
||||
"SP",
|
||||
"FP",
|
||||
"RA"
|
||||
"RA",
|
||||
};
|
||||
|
||||
const char *CRegName::GPR_Hi[32] =
|
||||
{
|
||||
const char * CRegName::GPR_Hi[32] = {
|
||||
"r0.HI",
|
||||
"at.HI",
|
||||
"v0.HI",
|
||||
|
@ -72,11 +72,10 @@ const char *CRegName::GPR_Hi[32] =
|
|||
"gp.HI",
|
||||
"sp.HI",
|
||||
"fp.HI",
|
||||
"ra.HI"
|
||||
"ra.HI",
|
||||
};
|
||||
|
||||
const char *CRegName::GPR_Lo[32] =
|
||||
{
|
||||
const char * CRegName::GPR_Lo[32] = {
|
||||
"r0.LO",
|
||||
"at.LO",
|
||||
"v0.LO",
|
||||
|
@ -108,11 +107,10 @@ const char *CRegName::GPR_Lo[32] =
|
|||
"gp.LO",
|
||||
"sp.LO",
|
||||
"fp.LO",
|
||||
"ra.LO"
|
||||
"ra.LO",
|
||||
};
|
||||
|
||||
const char * CRegName::Cop0[32] =
|
||||
{
|
||||
const char * CRegName::Cop0[32] = {
|
||||
"Index",
|
||||
"Random",
|
||||
"EntryLo0",
|
||||
|
@ -144,11 +142,10 @@ const char * CRegName::Cop0[32] =
|
|||
"TagLo",
|
||||
"TagHi",
|
||||
"ErrEPC",
|
||||
"Reg31"
|
||||
"Reg31",
|
||||
};
|
||||
|
||||
const char * CRegName::FPR[32] =
|
||||
{
|
||||
const char * CRegName::FPR[32] = {
|
||||
"F0",
|
||||
"F1",
|
||||
"F2",
|
||||
|
@ -180,11 +177,10 @@ const char * CRegName::FPR[32] =
|
|||
"F28",
|
||||
"F29",
|
||||
"F30",
|
||||
"F31"
|
||||
"F31",
|
||||
};
|
||||
|
||||
const char * CRegName::FPR_Ctrl[32] =
|
||||
{
|
||||
const char * CRegName::FPR_Ctrl[32] = {
|
||||
"Revision",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
|
@ -216,7 +212,7 @@ const char * CRegName::FPR_Ctrl[32] =
|
|||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"FCSR"
|
||||
"FCSR",
|
||||
};
|
||||
|
||||
uint32_t * CSystemRegisters::_PROGRAM_COUNTER = nullptr;
|
||||
|
@ -579,7 +575,6 @@ void CRegisters::DoTrapException(bool DelaySlot)
|
|||
EPC_REGISTER = (int64_t)((int32_t)m_PROGRAM_COUNTER);
|
||||
}
|
||||
m_PROGRAM_COUNTER = 0x80000180;
|
||||
|
||||
}
|
||||
|
||||
void CRegisters::DoCopUnusableException(bool DelaySlot, int32_t Coprocessor)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <Common/Platform.h>
|
||||
#include <Project64-core\N64System\N64Types.h>
|
||||
#include <Project64-core\Logging.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\AudioInterfaceHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\CartridgeDomain2Address1Handler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\DisplayControlRegHandler.h>
|
||||
|
@ -9,12 +9,12 @@
|
|||
#include <Project64-core\N64System\MemoryHandler\PeripheralInterfaceHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\RDRAMInterfaceHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\RDRAMRegistersHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\SerialInterfaceHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\SPRegistersHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\SerialInterfaceHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\VideoInterfaceHandler.h>
|
||||
#include <Project64-core\N64System\N64Types.h>
|
||||
#include <Project64-core\Settings\DebugSettings.h>
|
||||
#include <Project64-core\Settings\GameSettings.h>
|
||||
#include <Project64-core\Logging.h>
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4201) // Non-standard extension used: nameless struct/union
|
||||
|
@ -86,11 +86,21 @@ private:
|
|||
enum
|
||||
{
|
||||
// Status register
|
||||
STATUS_IE = 0x00000001, STATUS_EXL = 0x00000002, STATUS_ERL = 0x00000004,
|
||||
STATUS_IP0 = 0x00000100, STATUS_IP1 = 0x00000200, STATUS_IP2 = 0x00000400,
|
||||
STATUS_IP3 = 0x00000800, STATUS_IP4 = 0x00001000, STATUS_IP5 = 0x00002000,
|
||||
STATUS_IP6 = 0x00004000, STATUS_IP7 = 0x00008000, STATUS_BEV = 0x00400000,
|
||||
STATUS_FR = 0x04000000, STATUS_CU0 = 0x10000000, STATUS_CU1 = 0x20000000,
|
||||
STATUS_IE = 0x00000001,
|
||||
STATUS_EXL = 0x00000002,
|
||||
STATUS_ERL = 0x00000004,
|
||||
STATUS_IP0 = 0x00000100,
|
||||
STATUS_IP1 = 0x00000200,
|
||||
STATUS_IP2 = 0x00000400,
|
||||
STATUS_IP3 = 0x00000800,
|
||||
STATUS_IP4 = 0x00001000,
|
||||
STATUS_IP5 = 0x00002000,
|
||||
STATUS_IP6 = 0x00004000,
|
||||
STATUS_IP7 = 0x00008000,
|
||||
STATUS_BEV = 0x00400000,
|
||||
STATUS_FR = 0x04000000,
|
||||
STATUS_CU0 = 0x10000000,
|
||||
STATUS_CU1 = 0x20000000,
|
||||
|
||||
// Cause flags
|
||||
CAUSE_EXC_CODE = 0xFF,
|
||||
|
@ -153,7 +163,6 @@ enum
|
|||
FPCSR_RM_RM = 0x00000003, // Round to negative infinity
|
||||
};
|
||||
|
||||
|
||||
// MIPS interface flags
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "stdafx.h"
|
||||
#include "Rumblepak.h"
|
||||
|
||||
#include "Rumblepak.h"
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/Plugins/Plugin.h>
|
||||
#include <Project64-core/Plugins/ControllerPlugin.h>
|
||||
#include <Project64-core/Plugins/Plugin.h>
|
||||
|
||||
void Rumblepak::ReadFrom(uint32_t address, uint8_t * data)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include <Project64-core/N64System/Mips/SystemEvents.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
|
||||
const char * SystemEventName(SystemEvent event)
|
||||
{
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#include "stdafx.h"
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/Mips/SystemTiming.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/Mips/Disk.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/MemoryHandler/AudioInterfaceHandler.h>
|
||||
#include <Project64-core/3rdParty/zip.h>
|
||||
#include <Project64-core/N64System/MemoryHandler/AudioInterfaceHandler.h>
|
||||
#include <Project64-core/N64System/Mips/Disk.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/Mips/SystemTiming.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
|
||||
CSystemTimer::CSystemTimer(CN64System & System) :
|
||||
m_System(System),
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <Common/Log.h>
|
||||
#include <Project64-core/N64System/N64Types.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/3rdParty/zip.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/N64Types.h>
|
||||
|
||||
class AudioInterfaceHandler;
|
||||
class RomMemoryHandler;
|
||||
|
||||
class CSystemTimer
|
||||
{
|
||||
|
@ -57,7 +58,10 @@ public:
|
|||
|
||||
void RecordDifference(CLog & LogFile, const CSystemTimer & rSystemTimer);
|
||||
|
||||
TimerType CurrentType() const { return m_Current; }
|
||||
TimerType CurrentType() const
|
||||
{
|
||||
return m_Current;
|
||||
}
|
||||
|
||||
bool operator==(const CSystemTimer & rSystemTimer) const;
|
||||
bool operator!=(const CSystemTimer & rSystemTimer) const;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "TLB.h"
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
|
||||
CTLB::CTLB(CTLB_CB * CallBack) :
|
||||
m_CB(CallBack)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "GBCart.h"
|
||||
#include "Transferpak.h"
|
||||
|
||||
|
@ -71,7 +72,6 @@ void Transferpak::ReadFrom(uint16_t address, uint8_t * data)
|
|||
GBCart::read_gb_cart(&tpak.gb_cart, gb_cart_address(tpak.bank, address), data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Transferpak::WriteTo(uint16_t address, uint8_t * data)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include "GBCart.h"
|
||||
|
||||
enum cart_access_mode
|
||||
{
|
||||
CART_NOT_INSERTED = 0x40,
|
||||
|
@ -19,7 +20,6 @@ struct transferpak
|
|||
class Transferpak
|
||||
{
|
||||
public:
|
||||
|
||||
static void Release();
|
||||
static void Init();
|
||||
static void ReadFrom(uint16_t address, uint8_t * command);
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "N64Disk.h"
|
||||
#include "SystemGlobals.h"
|
||||
#include <Common/md5.h>
|
||||
#include <Common/Platform.h>
|
||||
#include <Common/MemoryManagement.h>
|
||||
#include <Common/Platform.h>
|
||||
#include <Common/md5.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <memory>
|
||||
|
||||
|
@ -193,9 +194,18 @@ bool CN64Disk::IsValidDiskImage(uint8_t Test[0x20])
|
|||
if (ipl_load_addr < 0x80000000 && ipl_load_addr >= 0x80800000) return false;
|
||||
|
||||
// Country code
|
||||
if (*((uint32_t *)&Test[0]) == 0x16D348E8) { return true; }
|
||||
else if (*((uint32_t *)&Test[0]) == 0x56EE6322) { return true; }
|
||||
else if (*((uint32_t *)&Test[0]) == 0x00000000) { return true; }
|
||||
if (*((uint32_t *)&Test[0]) == 0x16D348E8)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (*((uint32_t *)&Test[0]) == 0x56EE6322)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (*((uint32_t *)&Test[0]) == 0x00000000)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -339,7 +349,10 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc)
|
|||
for (count = 0; count < (int)DiskFileSize; count += ReadFromRomSection)
|
||||
{
|
||||
uint32_t dwToRead = DiskFileSize - count;
|
||||
if (dwToRead > ReadFromRomSection) { dwToRead = ReadFromRomSection; }
|
||||
if (dwToRead > ReadFromRomSection)
|
||||
{
|
||||
dwToRead = ReadFromRomSection;
|
||||
}
|
||||
|
||||
if (m_DiskFile.Read(&m_DiskImage[count], dwToRead) != dwToRead)
|
||||
{
|
||||
|
@ -416,7 +429,10 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc)
|
|||
for (count = 0; count < (int)DiskFileSize; count += ReadFromRomSection)
|
||||
{
|
||||
uint32_t dwToRead = DiskFileSize - count;
|
||||
if (dwToRead > ReadFromRomSection) { dwToRead = ReadFromRomSection; }
|
||||
if (dwToRead > ReadFromRomSection)
|
||||
{
|
||||
dwToRead = ReadFromRomSection;
|
||||
}
|
||||
|
||||
if (m_DiskFile.Read(&m_DiskImage[count], dwToRead) != dwToRead)
|
||||
{
|
||||
|
@ -795,7 +811,9 @@ bool CN64Disk::IsSysSectorGood(uint32_t block, uint32_t sectorsize)
|
|||
|
||||
uint8_t alt = 0xC; // Retail
|
||||
if ((block & 2) != 0)
|
||||
{
|
||||
alt = 0xA; // Development
|
||||
}
|
||||
|
||||
// Alternate tracks offsets (always the same)
|
||||
for (int i = 0; i < 16; i++)
|
||||
|
@ -881,8 +899,10 @@ void CN64Disk::DetectRamAddress()
|
|||
|
||||
uint32_t CN64Disk::LBAToVZone(uint32_t lba)
|
||||
{
|
||||
for (uint32_t vzone = 0; vzone < 16; vzone++) {
|
||||
if (lba < VZONE_LBA_TBL[m_DiskType][vzone]) {
|
||||
for (uint32_t vzone = 0; vzone < 16; vzone++)
|
||||
{
|
||||
if (lba < VZONE_LBA_TBL[m_DiskType][vzone])
|
||||
{
|
||||
return vzone;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,24 +15,66 @@ public:
|
|||
static bool IsValidDiskImage(uint8_t Test[0x20]);
|
||||
void SaveDiskSettingID(bool temp);
|
||||
void ClearDiskSettingID();
|
||||
uint8_t * GetDiskAddress() { return m_DiskImage; }
|
||||
uint8_t * GetDiskAddressBuffer() { return m_DiskImage + m_DiskBufAddress; }
|
||||
uint8_t * GetDiskAddressSys() { return m_DiskImage + m_DiskSysAddress; }
|
||||
uint8_t * GetDiskAddressID() { return m_DiskImage + m_DiskIDAddress; }
|
||||
uint8_t * GetDiskAddressRom() { return m_DiskImage + m_DiskRomAddress; }
|
||||
uint8_t * GetDiskAddressRam() { return m_DiskImage + m_DiskRamAddress; }
|
||||
uint32_t GetDiskSize() const { return m_DiskFileSize; }
|
||||
uint8_t * GetDiskHeader() { return m_DiskHeader; }
|
||||
void SetDiskAddressBuffer(uint32_t address) { m_DiskBufAddress = address; }
|
||||
uint8_t * GetDiskAddress()
|
||||
{
|
||||
return m_DiskImage;
|
||||
}
|
||||
uint8_t * GetDiskAddressBuffer()
|
||||
{
|
||||
return m_DiskImage + m_DiskBufAddress;
|
||||
}
|
||||
uint8_t * GetDiskAddressSys()
|
||||
{
|
||||
return m_DiskImage + m_DiskSysAddress;
|
||||
}
|
||||
uint8_t * GetDiskAddressID()
|
||||
{
|
||||
return m_DiskImage + m_DiskIDAddress;
|
||||
}
|
||||
uint8_t * GetDiskAddressRom()
|
||||
{
|
||||
return m_DiskImage + m_DiskRomAddress;
|
||||
}
|
||||
uint8_t * GetDiskAddressRam()
|
||||
{
|
||||
return m_DiskImage + m_DiskRamAddress;
|
||||
}
|
||||
uint32_t GetDiskSize() const
|
||||
{
|
||||
return m_DiskFileSize;
|
||||
}
|
||||
uint8_t * GetDiskHeader()
|
||||
{
|
||||
return m_DiskHeader;
|
||||
}
|
||||
void SetDiskAddressBuffer(uint32_t address)
|
||||
{
|
||||
m_DiskBufAddress = address;
|
||||
}
|
||||
uint32_t GetDiskAddressBlock(uint16_t head, uint16_t track, uint16_t block, uint16_t sector, uint16_t sectorsize);
|
||||
uint32_t CalculateCrc();
|
||||
stdstr GetRomName() const { return m_RomName; }
|
||||
stdstr GetFileName() const { return m_FileName; }
|
||||
stdstr GetDiskIdent() const { return m_DiskIdent; }
|
||||
Country GetCountry() const { return m_Country; }
|
||||
stdstr GetRomName() const
|
||||
{
|
||||
return m_RomName;
|
||||
}
|
||||
stdstr GetFileName() const
|
||||
{
|
||||
return m_FileName;
|
||||
}
|
||||
stdstr GetDiskIdent() const
|
||||
{
|
||||
return m_DiskIdent;
|
||||
}
|
||||
Country GetCountry() const
|
||||
{
|
||||
return m_Country;
|
||||
}
|
||||
void UnallocateDiskImage();
|
||||
|
||||
LanguageStringID GetError() const { return m_ErrorMsg; }
|
||||
LanguageStringID GetError() const
|
||||
{
|
||||
return m_ErrorMsg;
|
||||
}
|
||||
|
||||
private:
|
||||
bool AllocateDiskImage(uint32_t DiskFileSize);
|
||||
|
@ -56,8 +98,15 @@ private:
|
|||
uint16_t PhysToLBA(uint16_t head, uint16_t track, uint16_t block);
|
||||
|
||||
// Constant values
|
||||
enum { ReadFromRomSection = 0x400000, MameFormatSize = 0x0435B0C0, SDKFormatSize = 0x03DEC800,
|
||||
DiskFormatMAME = 0x0, DiskFormatSDK = 0x1, DiskFormatD64 = 0x2 };
|
||||
enum
|
||||
{
|
||||
ReadFromRomSection = 0x400000,
|
||||
MameFormatSize = 0x0435B0C0,
|
||||
SDKFormatSize = 0x03DEC800,
|
||||
DiskFormatMAME = 0x0,
|
||||
DiskFormatSDK = 0x1,
|
||||
DiskFormatD64 = 0x2
|
||||
};
|
||||
|
||||
// Class variables
|
||||
CFile m_DiskFile;
|
||||
|
@ -104,7 +153,7 @@ private:
|
|||
{0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08B4, 0x09C6, 0x0AEA, 0x0C0E, 0x0D20, 0x0DEC, 0x0EB8, 0x0FCA, 0x10DC},
|
||||
{0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08B4, 0x09C6, 0x0AD8, 0x0BEA, 0x0D0E, 0x0E32, 0x0EFE, 0x0FCA, 0x10DC},
|
||||
{0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x0980, 0x0A92, 0x0BA4, 0x0CB6, 0x0DC8, 0x0EEC, 0x1010, 0x10DC},
|
||||
{0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x093A, 0x0A4C, 0x0B5E, 0x0C70, 0x0D82, 0x0E94, 0x0FB8, 0x10DC}
|
||||
{0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x093A, 0x0A4C, 0x0B5E, 0x0C70, 0x0D82, 0x0E94, 0x0FB8, 0x10DC},
|
||||
};
|
||||
|
||||
const uint8_t VZONE_PZONE_TBL[7][16] = {
|
||||
|
@ -114,12 +163,12 @@ private:
|
|||
{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0xC, 0xB, 0xA, 0x9, 0x8, 0x6, 0x7, 0xF, 0xE, 0xD},
|
||||
{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8, 0x7, 0xF, 0xE},
|
||||
{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8, 0xF},
|
||||
{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0xF, 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8}
|
||||
{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0xF, 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8},
|
||||
};
|
||||
|
||||
const uint16_t SCYL_ZONE_TBL[2][8] = {
|
||||
{0x000, 0x09E, 0x13C, 0x1D1, 0x266, 0x2FB, 0x390, 0x425},
|
||||
{0x091, 0x12F, 0x1C4, 0x259, 0x2EE, 0x383, 0x418, 0x48A}
|
||||
{0x091, 0x12F, 0x1C4, 0x259, 0x2EE, 0x383, 0x418, 0x48A},
|
||||
};
|
||||
|
||||
const uint16_t OUTERCYL_TBL[8] = {0x000, 0x09E, 0x13C, 0x1D1, 0x266, 0x2FB, 0x390, 0x425};
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "N64Rom.h"
|
||||
#include "SystemGlobals.h"
|
||||
#include <Project64-core/3rdParty/zip.h>
|
||||
#include <Common/md5.h>
|
||||
#include <Common/Platform.h>
|
||||
#include <Common/MemoryManagement.h>
|
||||
#include <Common/IniFile.h>
|
||||
#include <Common/MemoryManagement.h>
|
||||
#include <Common/Platform.h>
|
||||
#include <Common/md5.h>
|
||||
#include <Project64-core/3rdParty/zip.h>
|
||||
#include <memory>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -95,7 +96,10 @@ bool CN64Rom::AllocateAndLoadN64Image(const char * FileLoc, bool LoadBootCodeOnl
|
|||
for (count = 0; count < (int)RomFileSize; count += ReadFromRomSection)
|
||||
{
|
||||
uint32_t dwToRead = RomFileSize - count;
|
||||
if (dwToRead > ReadFromRomSection) { dwToRead = ReadFromRomSection; }
|
||||
if (dwToRead > ReadFromRomSection)
|
||||
{
|
||||
dwToRead = ReadFromRomSection;
|
||||
}
|
||||
|
||||
if (m_RomFile.Read(&m_ROMImage[count], dwToRead) != dwToRead)
|
||||
{
|
||||
|
@ -181,7 +185,10 @@ bool CN64Rom::AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnl
|
|||
for (count = 4; count < (int)RomFileSize; count += ReadFromRomSection)
|
||||
{
|
||||
uint32_t dwToRead = RomFileSize - count;
|
||||
if (dwToRead > ReadFromRomSection) { dwToRead = ReadFromRomSection; }
|
||||
if (dwToRead > ReadFromRomSection)
|
||||
{
|
||||
dwToRead = ReadFromRomSection;
|
||||
}
|
||||
|
||||
dwRead = unzReadCurrentFile(file, &m_ROMImage[count], dwToRead);
|
||||
if (dwRead == 0)
|
||||
|
@ -270,7 +277,10 @@ CICChip CN64Rom::GetCicChipID(uint8_t * RomData, uint64_t * CRC)
|
|||
if (count == 0xC00) crcAleck64 = crc; //From 0x40 to 0xC00 (Aleck64)
|
||||
crc += *(uint32_t *)(RomData + count);
|
||||
}
|
||||
if (CRC != nullptr) { *CRC = crc; }
|
||||
if (CRC != nullptr)
|
||||
{
|
||||
*CRC = crc;
|
||||
}
|
||||
|
||||
switch (crc)
|
||||
{
|
||||
|
@ -289,7 +299,10 @@ CICChip CN64Rom::GetCicChipID(uint8_t * RomData, uint64_t * CRC)
|
|||
//Aleck64 CIC
|
||||
if (crcAleck64 == 0x000000A5F80BF620)
|
||||
{
|
||||
if (CRC != nullptr) { *CRC = crcAleck64; }
|
||||
if (CRC != nullptr)
|
||||
{
|
||||
*CRC = crcAleck64;
|
||||
}
|
||||
return CIC_NUS_5101;
|
||||
}
|
||||
return CIC_UNKNOWN;
|
||||
|
@ -343,9 +356,18 @@ void CN64Rom::CalculateRomCrc()
|
|||
case CIC_NUS_6103: v0 = 0xA3886759; break;
|
||||
case CIC_NUS_6105: v0 = 0xDF26F436; break;
|
||||
case CIC_NUS_6106: v0 = 0x1FEA617A; break;
|
||||
case CIC_NUS_DDUS: length = 0x000A0000; v0 = 0x861AE3A7; break;
|
||||
case CIC_NUS_8303: length = 0x000A0000; v0 = 0x8331D4CA; break;
|
||||
case CIC_NUS_8401: length = 0x000A0000; v0 = 0x0D8303E2; break;
|
||||
case CIC_NUS_DDUS:
|
||||
length = 0x000A0000;
|
||||
v0 = 0x861AE3A7;
|
||||
break;
|
||||
case CIC_NUS_8303:
|
||||
length = 0x000A0000;
|
||||
v0 = 0x8331D4CA;
|
||||
break;
|
||||
case CIC_NUS_8401:
|
||||
length = 0x000A0000;
|
||||
v0 = 0x0D8303E2;
|
||||
break;
|
||||
case CIC_NUS_5101: v0 = 0x95104FDD; break;
|
||||
default:
|
||||
return;
|
||||
|
@ -374,7 +396,8 @@ void CN64Rom::CalculateRomCrc()
|
|||
v1 = a3 + v0;
|
||||
a1 = v1;
|
||||
|
||||
if (v1 < a3) {
|
||||
if (v1 < a3)
|
||||
{
|
||||
if (m_CicChip == CIC_NUS_DDUS || m_CicChip == CIC_NUS_8303)
|
||||
{
|
||||
t2 = t2 ^ t3;
|
||||
|
@ -408,7 +431,8 @@ void CN64Rom::CalculateRomCrc()
|
|||
{
|
||||
t4 = (v0 ^ (*(uint32_t *)(m_ROMImage + (0xFF & t0) + 0x750))) + t4;
|
||||
}
|
||||
else t4 = (v0 ^ s0) + t4;
|
||||
else
|
||||
t4 = (v0 ^ s0) + t4;
|
||||
}
|
||||
if (m_CicChip == CIC_NUS_6103)
|
||||
{
|
||||
|
@ -444,10 +468,22 @@ CICChip CN64Rom::CicChipID()
|
|||
|
||||
bool CN64Rom::IsValidRomImage(uint8_t Test[4])
|
||||
{
|
||||
if (*((uint32_t *)&Test[0]) == 0x40123780) { return true; }
|
||||
if (*((uint32_t *)&Test[0]) == 0x12408037) { return true; }
|
||||
if (*((uint32_t *)&Test[0]) == 0x80371240) { return true; }
|
||||
if (*((uint32_t *)&Test[0]) == 0x40072780) { return true; } // 64DD IPL
|
||||
if (*((uint32_t *)&Test[0]) == 0x40123780)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (*((uint32_t *)&Test[0]) == 0x12408037)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (*((uint32_t *)&Test[0]) == 0x80371240)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (*((uint32_t *)&Test[0]) == 0x40072780)
|
||||
{
|
||||
return true;
|
||||
} // 64DD IPL
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -501,7 +537,8 @@ void CN64Rom::CleanRomName(char * RomName, bool byteswap)
|
|||
{
|
||||
switch (RomName[count])
|
||||
{
|
||||
case '/': case '\\': RomName[count] = '-'; break;
|
||||
case '/':
|
||||
case '\\': RomName[count] = '-'; break;
|
||||
case ':': RomName[count] = ';'; break;
|
||||
}
|
||||
}
|
||||
|
@ -563,7 +600,10 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly)
|
|||
// Get the size of the ROM and try to allocate the memory needed
|
||||
uint32_t RomFileSize = (uint32_t)f->Size;
|
||||
// If loading boot code then just load the first 0x1000 bytes
|
||||
if (LoadBootCodeOnly) { RomFileSize = 0x1000; }
|
||||
if (LoadBootCodeOnly)
|
||||
{
|
||||
RomFileSize = 0x1000;
|
||||
}
|
||||
|
||||
if (!AllocateRomImage(RomFileSize))
|
||||
{
|
||||
|
@ -759,7 +799,10 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly)
|
|||
// Get the size of the ROM and try to allocate the memory needed
|
||||
uint32_t RomFileSize = (uint32_t)f->Size;
|
||||
// If loading boot code then just load the first 0x1000 bytes
|
||||
if (LoadBootCodeOnly) { RomFileSize = 0x1000; }
|
||||
if (LoadBootCodeOnly)
|
||||
{
|
||||
RomFileSize = 0x1000;
|
||||
}
|
||||
|
||||
if (!AllocateRomImage(RomFileSize))
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <Project64-core/Multilanguage.h>
|
||||
#include <Project64-core/N64System/N64Types.h>
|
||||
#include <Project64-core/Settings/DebugSettings.h>
|
||||
#include <Project64-core/Multilanguage.h>
|
||||
|
||||
class CN64Rom :
|
||||
protected CDebugSettings
|
||||
|
@ -18,17 +18,38 @@ public:
|
|||
void SaveRomSettingID(bool temp);
|
||||
void ClearRomSettingID();
|
||||
CICChip CicChipID();
|
||||
uint8_t * GetRomAddress() const { return m_ROMImage; }
|
||||
uint32_t GetRomSize() const { return m_RomFileSize; }
|
||||
const std::string & GetRomMD5() const { return m_MD5; }
|
||||
const std::string & GetRomName() const { return m_RomName; }
|
||||
const std::string & GetFileName() const { return m_FileName; }
|
||||
Country GetCountry() const { return m_Country; }
|
||||
uint8_t * GetRomAddress() const
|
||||
{
|
||||
return m_ROMImage;
|
||||
}
|
||||
uint32_t GetRomSize() const
|
||||
{
|
||||
return m_RomFileSize;
|
||||
}
|
||||
const std::string & GetRomMD5() const
|
||||
{
|
||||
return m_MD5;
|
||||
}
|
||||
const std::string & GetRomName() const
|
||||
{
|
||||
return m_RomName;
|
||||
}
|
||||
const std::string & GetFileName() const
|
||||
{
|
||||
return m_FileName;
|
||||
}
|
||||
Country GetCountry() const
|
||||
{
|
||||
return m_Country;
|
||||
}
|
||||
bool IsPal();
|
||||
void UnallocateRomImage();
|
||||
|
||||
// Get a message ID for the reason that you failed to load the ROM
|
||||
LanguageStringID GetError() const { return m_ErrorMsg; }
|
||||
LanguageStringID GetError() const
|
||||
{
|
||||
return m_ErrorMsg;
|
||||
}
|
||||
static CICChip GetCicChipID(uint8_t * RomData, uint64_t * CRC = nullptr);
|
||||
static void CleanRomName(char * RomName, bool byteswap = true);
|
||||
|
||||
|
@ -44,7 +65,10 @@ private:
|
|||
static void NotificationCB(const char * Status, CN64Rom * _this);
|
||||
|
||||
// Constant values
|
||||
enum { ReadFromRomSection = 0x400000 };
|
||||
enum
|
||||
{
|
||||
ReadFromRomSection = 0x400000
|
||||
};
|
||||
|
||||
// Class variables
|
||||
CFile m_RomFile;
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "N64System.h"
|
||||
#include <Common/Util.h>
|
||||
#include <Project64-core/3rdParty/zip.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/Mips/Mempak.h>
|
||||
#include <Project64-core/N64System/Mips/Transferpak.h>
|
||||
#include <Project64-core/N64System/Interpreter/InterpreterCPU.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
|
||||
#include <Project64-core/N64System/Mips/Disk.h>
|
||||
#include <Project64-core/N64System/N64Disk.h>
|
||||
#include <Project64-core/N64System/Enhancement/Enhancements.h>
|
||||
#include <Project64-core/N64System/N64Rom.h>
|
||||
#include <Project64-core/Debugger.h>
|
||||
#include <Project64-core/ExceptionHandler.h>
|
||||
#include <Project64-core/Logging.h>
|
||||
#include <Project64-core/Debugger.h>
|
||||
#include <Common/Util.h>
|
||||
#include <Project64-core/N64System/Enhancement/Enhancements.h>
|
||||
#include <Project64-core/N64System/Interpreter/InterpreterCPU.h>
|
||||
#include <Project64-core/N64System/Mips/Disk.h>
|
||||
#include <Project64-core/N64System/Mips/Mempak.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
|
||||
#include <Project64-core/N64System/Mips/Transferpak.h>
|
||||
#include <Project64-core/N64System/N64Disk.h>
|
||||
#include <Project64-core/N64System/N64Rom.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <float.h>
|
||||
#include <time.h>
|
||||
#if defined(ANDROID)
|
||||
|
@ -822,7 +823,8 @@ void CN64System::EndEmulation(void)
|
|||
|
||||
void CN64System::Pause()
|
||||
{
|
||||
if (m_Plugins && m_Plugins->Control()->EmulationPaused) {
|
||||
if (m_Plugins && m_Plugins->Control()->EmulationPaused)
|
||||
{
|
||||
m_Plugins->Control()->EmulationPaused();
|
||||
}
|
||||
if (m_EndEmulation)
|
||||
|
@ -1323,10 +1325,16 @@ void CN64System::UpdateSyncCPU(CN64System * const SecondCPU, uint32_t const Cycl
|
|||
|
||||
// Update the number of cycles to skip
|
||||
m_CyclesToSkip -= Cycles;
|
||||
if (m_CyclesToSkip < 0) { m_CyclesToSkip = 0; }
|
||||
if (m_CyclesToSkip < 0)
|
||||
{
|
||||
m_CyclesToSkip = 0;
|
||||
}
|
||||
|
||||
// Run the other CPU For the same amount of cycles
|
||||
if (CyclesToExecute < 0) { return; }
|
||||
if (CyclesToExecute < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SecondCPU->SetActiveSystem(true);
|
||||
CInterpreterCPU::ExecuteOps(Cycles);
|
||||
|
@ -1343,11 +1351,23 @@ void CN64System::SyncCPUPC(CN64System * const SecondCPU)
|
|||
ErrorFound = true;
|
||||
}
|
||||
|
||||
if (m_TLB != SecondCPU->m_TLB) { ErrorFound = true; }
|
||||
if (m_SystemTimer != SecondCPU->m_SystemTimer) { ErrorFound = true; }
|
||||
if (m_NextTimer != SecondCPU->m_NextTimer) { ErrorFound = true; }
|
||||
if (m_TLB != SecondCPU->m_TLB)
|
||||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
if (m_SystemTimer != SecondCPU->m_SystemTimer)
|
||||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
if (m_NextTimer != SecondCPU->m_NextTimer)
|
||||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
|
||||
if (ErrorFound) { DumpSyncErrors(SecondCPU); }
|
||||
if (ErrorFound)
|
||||
{
|
||||
DumpSyncErrors(SecondCPU);
|
||||
}
|
||||
|
||||
for (int i = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--)
|
||||
{
|
||||
|
@ -1364,7 +1384,8 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
|
|||
g_SystemTimer->UpdateTimers();
|
||||
|
||||
#ifdef TEST_SP_TRACKING
|
||||
if (m_CurrentSP != GPR[29].UW[0]) {
|
||||
if (m_CurrentSP != GPR[29].UW[0])
|
||||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
#endif
|
||||
|
@ -1413,11 +1434,26 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
|
|||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
if (m_TLB != SecondCPU->m_TLB) { ErrorFound = true; }
|
||||
if (m_Reg.m_FPCR[0] != SecondCPU->m_Reg.m_FPCR[0]) { ErrorFound = true; }
|
||||
if (m_Reg.m_FPCR[31] != SecondCPU->m_Reg.m_FPCR[31]) { ErrorFound = true; }
|
||||
if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW) { ErrorFound = true; }
|
||||
if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW) { ErrorFound = true; }
|
||||
if (m_TLB != SecondCPU->m_TLB)
|
||||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
if (m_Reg.m_FPCR[0] != SecondCPU->m_Reg.m_FPCR[0])
|
||||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
if (m_Reg.m_FPCR[31] != SecondCPU->m_Reg.m_FPCR[31])
|
||||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW)
|
||||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW)
|
||||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
/*if (m_SyncCount > 4788000)
|
||||
{
|
||||
if (memcmp(m_MMU_VM.Rdram(),SecondCPU->m_MMU_VM.Rdram(),RdramSize()) != 0)
|
||||
|
@ -1455,9 +1491,18 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
|
|||
#endif
|
||||
}
|
||||
|
||||
if (m_SystemTimer != SecondCPU->m_SystemTimer) { ErrorFound = true; }
|
||||
if (m_NextTimer != SecondCPU->m_NextTimer) { ErrorFound = true; }
|
||||
if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) { ErrorFound = true; }
|
||||
if (m_SystemTimer != SecondCPU->m_SystemTimer)
|
||||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
if (m_NextTimer != SecondCPU->m_NextTimer)
|
||||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel)
|
||||
{
|
||||
ErrorFound = true;
|
||||
}
|
||||
|
||||
for (int i = 0, n = sizeof(m_Reg.m_Mips_Interface) / sizeof(m_Reg.m_Mips_Interface[0]); i < n; i++)
|
||||
{
|
||||
|
@ -1483,7 +1528,10 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
|
|||
}
|
||||
}
|
||||
|
||||
if (ErrorFound) { DumpSyncErrors(SecondCPU); }
|
||||
if (ErrorFound)
|
||||
{
|
||||
DumpSyncErrors(SecondCPU);
|
||||
}
|
||||
|
||||
for (int i = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--)
|
||||
{
|
||||
|
@ -1716,7 +1764,10 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
|
|||
bool bHasTlb = false;
|
||||
for (count = 0; count < 32; count++)
|
||||
{
|
||||
if (!m_TLB.TlbEntry(count).EntryDefined) { continue; }
|
||||
if (!m_TLB.TlbEntry(count).EntryDefined)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!bHasTlb)
|
||||
{
|
||||
Error.Log("\r\n");
|
||||
|
@ -1725,8 +1776,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
|
|||
}
|
||||
Error.LogF("TLB[%2d], %08X, %08X, %08X, %08X\r\n", count,
|
||||
m_TLB.TlbEntry(count).EntryHi.Value, m_TLB.TlbEntry(count).PageMask.Value,
|
||||
SecondCPU->m_TLB.TlbEntry(count).EntryHi.Value, SecondCPU->m_TLB.TlbEntry(count).PageMask.Value
|
||||
);
|
||||
SecondCPU->m_TLB.TlbEntry(count).EntryHi.Value, SecondCPU->m_TLB.TlbEntry(count).PageMask.Value);
|
||||
}
|
||||
Error.Log("\r\n");
|
||||
Error.Log("Code at PC:\r\n");
|
||||
|
@ -2283,7 +2333,10 @@ bool CN64System::LoadState(const char * FileName)
|
|||
#ifdef TEST_SP_TRACKING
|
||||
m_CurrentSP = GPR[29].UW[0];
|
||||
#endif
|
||||
if (bFastSP() && m_Recomp) { m_Recomp->ResetMemoryStackPos(); }
|
||||
if (bFastSP() && m_Recomp)
|
||||
{
|
||||
m_Recomp->ResetMemoryStackPos();
|
||||
}
|
||||
|
||||
if (g_Settings->LoadDword(Game_CpuType) == CPU_SyncCores)
|
||||
{
|
||||
|
@ -2450,7 +2503,10 @@ void CN64System::RefreshScreen()
|
|||
PROFILE_TIMERS CPU_UsageAddr = Timer_None /*, ProfilingAddr = Timer_None*/;
|
||||
uint32_t VI_INTR_TIME = 500000;
|
||||
|
||||
if (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RefreshScreen); }
|
||||
if (bShowCPUPer())
|
||||
{
|
||||
CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RefreshScreen);
|
||||
}
|
||||
|
||||
// Calculate how many cycles to next refresh
|
||||
if (m_Reg.VI_V_SYNC_REG == 0)
|
||||
|
@ -2482,7 +2538,10 @@ void CN64System::RefreshScreen()
|
|||
}
|
||||
}
|
||||
|
||||
if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_UpdateScreen); }
|
||||
if (bShowCPUPer())
|
||||
{
|
||||
m_CPU_Usage.StartTimer(Timer_UpdateScreen);
|
||||
}
|
||||
|
||||
__except_try()
|
||||
{
|
||||
|
@ -2502,18 +2561,27 @@ void CN64System::RefreshScreen()
|
|||
|
||||
if ((bBasicMode() || bLimitFPS()) && (!bSyncToAudio() || !FullSpeed()))
|
||||
{
|
||||
if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_Idel); }
|
||||
if (bShowCPUPer())
|
||||
{
|
||||
m_CPU_Usage.StartTimer(Timer_Idel);
|
||||
}
|
||||
uint32_t FrameRate;
|
||||
if (m_Limiter.Timer_Process(&FrameRate) && bDisplayFrameRate())
|
||||
{
|
||||
m_FPS.DisplayViCounter(FrameRate, 0);
|
||||
m_bCleanFrameBox = true;
|
||||
}
|
||||
if (bShowCPUPer()) { m_CPU_Usage.StopTimer(); }
|
||||
if (bShowCPUPer())
|
||||
{
|
||||
m_CPU_Usage.StopTimer();
|
||||
}
|
||||
}
|
||||
else if (bDisplayFrameRate())
|
||||
{
|
||||
if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_UpdateFPS); }
|
||||
if (bShowCPUPer())
|
||||
{
|
||||
m_CPU_Usage.StartTimer(Timer_UpdateFPS);
|
||||
}
|
||||
m_FPS.UpdateViCounter();
|
||||
m_bCleanFrameBox = true;
|
||||
}
|
||||
|
|
|
@ -3,19 +3,19 @@
|
|||
#include <Common/Random.h>
|
||||
#include <Common/SyncEvent.h>
|
||||
#include <Common/Thread.h>
|
||||
#include <Project64-core/Settings/N64SystemSettings.h>
|
||||
#include <Project64-core/N64System/Profiling.h>
|
||||
#include <Project64-core/N64System/Recompiler/Recompiler.h>
|
||||
#include <Project64-core/Logging.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Mips/Mempak.h>
|
||||
#include <Project64-core/N64System/Mips/SystemEvents.h>
|
||||
#include <Project64-core/N64System/Mips/SystemTiming.h>
|
||||
#include <Project64-core/N64System/Mips/Mempak.h>
|
||||
#include <Project64-core/Settings/DebugSettings.h>
|
||||
#include <Project64-core/N64System/Profiling.h>
|
||||
#include <Project64-core/N64System/Recompiler/Recompiler.h>
|
||||
#include <Project64-core/Plugin.h>
|
||||
#include <Project64-core/Logging.h>
|
||||
#include <Project64-core/Settings/DebugSettings.h>
|
||||
#include <Project64-core/Settings/N64SystemSettings.h>
|
||||
|
||||
#include "Mips/TLB.h"
|
||||
#include "FramePerSecond.h"
|
||||
#include "Mips/TLB.h"
|
||||
#include "SpeedLimiter.h"
|
||||
|
||||
typedef std::list<SystemEvent> EVENT_LIST;
|
||||
|
@ -70,10 +70,22 @@ public:
|
|||
void ExternalEvent(SystemEvent action); // Covers GUI interactions and timers etc.
|
||||
void StartEmulation(bool NewThread);
|
||||
void EndEmulation();
|
||||
void AlterSpeed(const CSpeedLimiter::ESpeedChange SpeedChange) { m_Limiter.AlterSpeed(SpeedChange); }
|
||||
void SetSpeed(int Speed) { m_Limiter.SetSpeed(Speed); }
|
||||
int GetSpeed(void) const { return m_Limiter.GetSpeed(); }
|
||||
int GetBaseSpeed(void) const { return m_Limiter.GetBaseSpeed(); }
|
||||
void AlterSpeed(const CSpeedLimiter::ESpeedChange SpeedChange)
|
||||
{
|
||||
m_Limiter.AlterSpeed(SpeedChange);
|
||||
}
|
||||
void SetSpeed(int Speed)
|
||||
{
|
||||
m_Limiter.SetSpeed(Speed);
|
||||
}
|
||||
int GetSpeed(void) const
|
||||
{
|
||||
return m_Limiter.GetSpeed();
|
||||
}
|
||||
int GetBaseSpeed(void) const
|
||||
{
|
||||
return m_Limiter.GetBaseSpeed();
|
||||
}
|
||||
void Reset(bool bInitReg, bool ClearMenory);
|
||||
void GameReset();
|
||||
void PluginReset();
|
||||
|
@ -97,9 +109,18 @@ public:
|
|||
void SyncSystem();
|
||||
void SyncSystemPC();
|
||||
|
||||
CPlugins * GetPlugins() { return m_Plugins; }
|
||||
PIPELINE_STAGE PipelineStage() const { return m_PipelineStage; }
|
||||
uint32_t JumpToLocation() const { return m_JumpToLocation; }
|
||||
CPlugins * GetPlugins()
|
||||
{
|
||||
return m_Plugins;
|
||||
}
|
||||
PIPELINE_STAGE PipelineStage() const
|
||||
{
|
||||
return m_PipelineStage;
|
||||
}
|
||||
uint32_t JumpToLocation() const
|
||||
{
|
||||
return m_JumpToLocation;
|
||||
}
|
||||
|
||||
private:
|
||||
struct SETTING_CHANGED_CB
|
||||
|
|
|
@ -31,44 +31,70 @@ enum PauseType
|
|||
|
||||
enum CPU_TYPE
|
||||
{
|
||||
CPU_Default = -1, CPU_Interpreter = 1, CPU_Recompiler = 2, CPU_SyncCores = 3
|
||||
CPU_Default = -1,
|
||||
CPU_Interpreter = 1,
|
||||
CPU_Recompiler = 2,
|
||||
CPU_SyncCores = 3
|
||||
};
|
||||
|
||||
enum FRAMERATE_TYPE
|
||||
{
|
||||
FR_VIs = 0, FR_DLs = 1, FR_PERCENT = 2, FR_VIs_DLs = 3,
|
||||
FR_VIs = 0,
|
||||
FR_DLs = 1,
|
||||
FR_PERCENT = 2,
|
||||
FR_VIs_DLs = 3,
|
||||
};
|
||||
|
||||
enum SAVE_CHIP_TYPE
|
||||
{
|
||||
SaveChip_Auto = -1, SaveChip_Eeprom_4K, SaveChip_Eeprom_16K, SaveChip_Sram, SaveChip_FlashRam
|
||||
SaveChip_Auto = -1,
|
||||
SaveChip_Eeprom_4K,
|
||||
SaveChip_Eeprom_16K,
|
||||
SaveChip_Sram,
|
||||
SaveChip_FlashRam
|
||||
};
|
||||
|
||||
enum SAVE_DISK_TYPE
|
||||
{
|
||||
SaveDisk_ShadowFile = 0, SaveDisk_RAMFile = 1,
|
||||
SaveDisk_ShadowFile = 0,
|
||||
SaveDisk_RAMFile = 1,
|
||||
};
|
||||
|
||||
enum DISK_SEEK_TYPE
|
||||
{
|
||||
DiskSeek_Turbo = 0, DiskSeek_Slow = 1,
|
||||
DiskSeek_Turbo = 0,
|
||||
DiskSeek_Slow = 1,
|
||||
};
|
||||
|
||||
enum FUNC_LOOKUP_METHOD
|
||||
{
|
||||
FuncFind_Default = -1, FuncFind_PhysicalLookup = 1, FuncFind_VirtualLookup = 2, FuncFind_ChangeMemory = 3,
|
||||
FuncFind_Default = -1,
|
||||
FuncFind_PhysicalLookup = 1,
|
||||
FuncFind_VirtualLookup = 2,
|
||||
FuncFind_ChangeMemory = 3,
|
||||
};
|
||||
|
||||
enum SYSTEM_TYPE
|
||||
{
|
||||
SYSTEM_NTSC = 0, SYSTEM_PAL = 1, SYSTEM_MPAL = 2
|
||||
SYSTEM_NTSC = 0,
|
||||
SYSTEM_PAL = 1,
|
||||
SYSTEM_MPAL = 2
|
||||
};
|
||||
|
||||
enum CICChip
|
||||
{
|
||||
CIC_UNKNOWN = -1, CIC_NUS_6101 = 1, CIC_NUS_6102 = 2, CIC_NUS_6103 = 3,
|
||||
CIC_NUS_6104 = 4, CIC_NUS_6105 = 5, CIC_NUS_6106 = 6, CIC_NUS_5167 = 7,
|
||||
CIC_NUS_8303 = 8, CIC_NUS_DDUS = 9, CIC_NUS_8401 = 10, CIC_NUS_5101 = 11,
|
||||
CIC_UNKNOWN = -1,
|
||||
CIC_NUS_6101 = 1,
|
||||
CIC_NUS_6102 = 2,
|
||||
CIC_NUS_6103 = 3,
|
||||
CIC_NUS_6104 = 4,
|
||||
CIC_NUS_6105 = 5,
|
||||
CIC_NUS_6106 = 6,
|
||||
CIC_NUS_5167 = 7,
|
||||
CIC_NUS_8303 = 8,
|
||||
CIC_NUS_DDUS = 9,
|
||||
CIC_NUS_8401 = 10,
|
||||
CIC_NUS_5101 = 11,
|
||||
CIC_MINI_IPL3 = 12,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Project64-core/N64System/Profiling.h>
|
||||
#include <Common/Log.h>
|
||||
#include <Project64-core/N64System/Profiling.h>
|
||||
|
||||
enum { MAX_FRAMES = 13 };
|
||||
enum
|
||||
{
|
||||
MAX_FRAMES = 13
|
||||
};
|
||||
|
||||
CProfiling::CProfiling() :
|
||||
m_CurrentDisplayCount(MAX_FRAMES),
|
||||
|
@ -42,7 +46,10 @@ PROFILE_TIMERS CProfiling::StartTimer(PROFILE_TIMERS TimerType)
|
|||
|
||||
PROFILE_TIMERS CProfiling::StopTimer()
|
||||
{
|
||||
if (m_CurrentTimerType == Timer_None) { return m_CurrentTimerType; }
|
||||
if (m_CurrentTimerType == Timer_None)
|
||||
{
|
||||
return m_CurrentTimerType;
|
||||
}
|
||||
HighResTimeStamp EndTime;
|
||||
EndTime.SetToNow();
|
||||
uint64_t TimeTaken = EndTime.GetMicroSeconds() - m_StartTime.GetMicroSeconds();
|
||||
|
@ -71,7 +78,8 @@ void CProfiling::ShowCPU_Usage()
|
|||
|
||||
m_CurrentDisplayCount = MAX_FRAMES;
|
||||
g_Notify->DisplayMessage(0, stdstr_f("r4300i: %d.%02d%% GFX: %d.%02d%% Alist: %d.%02d%% Idle: %d.%02d%%",
|
||||
R4300 / 100, R4300 % 100, RSP_Dlist / 100, RSP_Dlist % 100, RSP_Alist / 100, RSP_Alist % 100, Idel / 100, Idel % 100).c_str());
|
||||
R4300 / 100, R4300 % 100, RSP_Dlist / 100, RSP_Dlist % 100, RSP_Alist / 100, RSP_Alist % 100, Idel / 100, Idel % 100)
|
||||
.c_str());
|
||||
|
||||
ResetTimers();
|
||||
if (PreviousType != Timer_None)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include <Project64-core/N64System/N64Types.h>
|
||||
#include <Common/HighResTimeStamp.h>
|
||||
#include <Project64-core/N64System/N64Types.h>
|
||||
|
||||
class CProfiling
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#pragma once
|
||||
#if defined(__aarch64__)
|
||||
|
||||
#include <Project64-core/N64System/Recompiler/RegInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/ExitInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/Aarch64/Aarch64ops.h>
|
||||
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iOpcode.h>
|
||||
#include <Project64-core/N64System/Recompiler/Aarch64/Aarch64ops.h>
|
||||
#include <Project64-core/N64System/Recompiler/ExitInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/RegInfo.h>
|
||||
|
||||
class CMipsMemoryVM;
|
||||
class CCodeBlock;
|
||||
|
@ -220,7 +220,10 @@ public:
|
|||
void CompileExecuteBP(void);
|
||||
void CompileExecuteDelaySlotBP(void);
|
||||
|
||||
CAarch64Ops & Assembler() { return m_Assembler; }
|
||||
CAarch64Ops & Assembler()
|
||||
{
|
||||
return m_Assembler;
|
||||
}
|
||||
|
||||
private:
|
||||
CAarch64RecompilerOps(const CAarch64RecompilerOps &);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#if defined(__arm__) || defined(_M_ARM)
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Recompiler/Arm/ArmOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/Arm/ArmOpCode.h>
|
||||
#include <Project64-core/N64System/Recompiler/Arm/ArmOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/CodeBlock.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
|
||||
CArmOps::CArmOps(CCodeBlock & CodeBlock, CArmRegInfo & RegWorkingSet) :
|
||||
m_CodeBlock(CodeBlock),
|
||||
|
@ -857,8 +857,14 @@ void CArmOps::PushArmReg(uint16_t Registers)
|
|||
{
|
||||
return;
|
||||
}
|
||||
if ((Registers & ArmPushPop_SP) != 0) { g_Notify->BreakPoint(__FILE__, __LINE__); }
|
||||
if ((Registers & ArmPushPop_PC) != 0) { g_Notify->BreakPoint(__FILE__, __LINE__); }
|
||||
if ((Registers & ArmPushPop_SP) != 0)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
if ((Registers & ArmPushPop_PC) != 0)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
if ((Registers & ArmPushPop_LR) == 0)
|
||||
{
|
||||
m_PushRegisters = Registers;
|
||||
|
@ -918,8 +924,14 @@ void CArmOps::PopArmReg(uint16_t Registers)
|
|||
CodeLog("%s: Setting m_PushRegisters: %X Registers: %X", __FUNCTION__, m_PushRegisters, Registers);
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
if ((Registers & ArmPushPop_SP) != 0) { g_Notify->BreakPoint(__FILE__, __LINE__); }
|
||||
if ((Registers & ArmPushPop_LR) != 0) { g_Notify->BreakPoint(__FILE__, __LINE__); }
|
||||
if ((Registers & ArmPushPop_SP) != 0)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
if ((Registers & ArmPushPop_LR) != 0)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__);
|
||||
m_PopRegisters = Registers;
|
||||
|
@ -976,8 +988,7 @@ uint32_t CArmOps::PushPopRegisterSize(uint16_t Registers)
|
|||
{
|
||||
ArmPushPop_R0, ArmPushPop_R1, ArmPushPop_R2, ArmPushPop_R3, ArmPushPop_R4,
|
||||
ArmPushPop_R5, ArmPushPop_R6, ArmPushPop_R7, ArmPushPop_R8, ArmPushPop_R9,
|
||||
ArmPushPop_R10, ArmPushPop_R11, ArmPushPop_R12, ArmPushPop_LR, ArmPushPop_PC
|
||||
};
|
||||
ArmPushPop_R10, ArmPushPop_R11, ArmPushPop_R12, ArmPushPop_LR, ArmPushPop_PC};
|
||||
uint32_t size = 0;
|
||||
for (uint32_t i = 0; i < (sizeof(RegisterList) / sizeof(RegisterList[0])); i++)
|
||||
{
|
||||
|
@ -991,18 +1002,40 @@ uint32_t CArmOps::PushPopRegisterSize(uint16_t Registers)
|
|||
|
||||
std::string CArmOps::PushPopRegisterList(uint16_t Registers)
|
||||
{
|
||||
static uint32_t PushPopRegisterList[] =
|
||||
{
|
||||
ArmPushPop_R0, ArmPushPop_R1, ArmPushPop_R2, ArmPushPop_R3, ArmPushPop_R4,
|
||||
ArmPushPop_R5, ArmPushPop_R6, ArmPushPop_R7, ArmPushPop_R8, ArmPushPop_R9,
|
||||
ArmPushPop_R10, ArmPushPop_R11, ArmPushPop_R12, ArmPushPop_LR, ArmPushPop_PC
|
||||
static uint32_t PushPopRegisterList[] = {
|
||||
ArmPushPop_R0,
|
||||
ArmPushPop_R1,
|
||||
ArmPushPop_R2,
|
||||
ArmPushPop_R3,
|
||||
ArmPushPop_R4,
|
||||
ArmPushPop_R5,
|
||||
ArmPushPop_R6,
|
||||
ArmPushPop_R7,
|
||||
ArmPushPop_R8,
|
||||
ArmPushPop_R9,
|
||||
ArmPushPop_R10,
|
||||
ArmPushPop_R11,
|
||||
ArmPushPop_R12,
|
||||
ArmPushPop_LR,
|
||||
ArmPushPop_PC,
|
||||
};
|
||||
|
||||
static ArmReg RegisterList[] =
|
||||
{
|
||||
Arm_R0, Arm_R1, Arm_R2, Arm_R3, Arm_R4,
|
||||
Arm_R5, Arm_R6, Arm_R7, Arm_R8, Arm_R9,
|
||||
Arm_R10, Arm_R11, Arm_R12, ArmRegLR, ArmRegPC,
|
||||
static ArmReg RegisterList[] = {
|
||||
Arm_R0,
|
||||
Arm_R1,
|
||||
Arm_R2,
|
||||
Arm_R3,
|
||||
Arm_R4,
|
||||
Arm_R5,
|
||||
Arm_R6,
|
||||
Arm_R7,
|
||||
Arm_R8,
|
||||
Arm_R9,
|
||||
Arm_R10,
|
||||
Arm_R11,
|
||||
Arm_R12,
|
||||
ArmRegLR,
|
||||
ArmRegPC,
|
||||
};
|
||||
|
||||
std::string RegisterResult;
|
||||
|
@ -1140,7 +1173,11 @@ void CArmOps::StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, uint
|
|||
|
||||
if (DestReg > 0x7 || RegPointer > 0x7 || (Offset & (~0x7C)) != 0)
|
||||
{
|
||||
if ((Offset & (~0xFFF)) != 0) { g_Notify->BreakPoint(__FILE__, __LINE__); return; }
|
||||
if ((Offset & (~0xFFF)) != 0)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
CodeLog(" str\t%s, [%s, #%d]%s%s", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)Offset, comment != nullptr ? "\t; " : "", comment != nullptr ? comment : "");
|
||||
Arm32Opcode op = {0};
|
||||
|
@ -1615,12 +1652,30 @@ bool CArmOps::ArmCompareInverse(ArmCompareType CompareType)
|
|||
|
||||
CArmOps::ArmCompareType CArmOps::ArmCompareInverseType(ArmCompareType CompareType)
|
||||
{
|
||||
if (CompareType == ArmBranch_Equal) { return ArmBranch_Notequal; }
|
||||
if (CompareType == ArmBranch_Notequal) { return ArmBranch_Equal; }
|
||||
if (CompareType == ArmBranch_GreaterThanOrEqual) { return ArmBranch_LessThan; }
|
||||
if (CompareType == ArmBranch_LessThan) { return ArmBranch_GreaterThanOrEqual; }
|
||||
if (CompareType == ArmBranch_GreaterThan) { return ArmBranch_LessThanOrEqual; }
|
||||
if (CompareType == ArmBranch_LessThanOrEqual) { return ArmBranch_GreaterThan; }
|
||||
if (CompareType == ArmBranch_Equal)
|
||||
{
|
||||
return ArmBranch_Notequal;
|
||||
}
|
||||
if (CompareType == ArmBranch_Notequal)
|
||||
{
|
||||
return ArmBranch_Equal;
|
||||
}
|
||||
if (CompareType == ArmBranch_GreaterThanOrEqual)
|
||||
{
|
||||
return ArmBranch_LessThan;
|
||||
}
|
||||
if (CompareType == ArmBranch_LessThan)
|
||||
{
|
||||
return ArmBranch_GreaterThanOrEqual;
|
||||
}
|
||||
if (CompareType == ArmBranch_GreaterThan)
|
||||
{
|
||||
return ArmBranch_LessThanOrEqual;
|
||||
}
|
||||
if (CompareType == ArmBranch_LessThanOrEqual)
|
||||
{
|
||||
return ArmBranch_GreaterThan;
|
||||
}
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
return ArmBranch_Equal;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,17 +1,17 @@
|
|||
#pragma once
|
||||
#if defined(__arm__) || defined(_M_ARM)
|
||||
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iOpcode.h>
|
||||
#include <Project64-core/N64System/Recompiler/ExitInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/RegInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/Arm/ArmOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/JumpInfo.h>
|
||||
#include <Project64-core/N64System/Interpreter/InterpreterOps.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iOpcode.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/Recompiler/Arm/ArmOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/ExitInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/JumpInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/RegInfo.h>
|
||||
#include <Project64-core/Settings/GameSettings.h>
|
||||
#include <Project64-core/Settings/N64SystemSettings.h>
|
||||
#include <Project64-core/Settings/RecompilerSettings.h>
|
||||
#include <Project64-core/Settings/GameSettings.h>
|
||||
|
||||
class CCodeBlock;
|
||||
class CCodeSection;
|
||||
|
@ -235,43 +235,133 @@ public:
|
|||
void CompileExecuteBP(void);
|
||||
void CompileExecuteDelaySlotBP(void);
|
||||
|
||||
CArmOps & Assembler() { return m_Assembler; }
|
||||
CArmOps & Assembler()
|
||||
{
|
||||
return m_Assembler;
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
typedef CRegInfo::REG_STATE REG_STATE;
|
||||
|
||||
REG_STATE GetMipsRegState(int32_t Reg) { return m_RegWorkingSet.GetMipsRegState(Reg); }
|
||||
uint64_t GetMipsReg(int32_t Reg) { return m_RegWorkingSet.GetMipsReg(Reg); }
|
||||
uint32_t GetMipsRegLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo(Reg); }
|
||||
int32_t GetMipsRegLo_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo_S(Reg); }
|
||||
uint32_t GetMipsRegHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi(Reg); }
|
||||
int32_t GetMipsRegHi_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi_S(Reg); }
|
||||
CArmOps::ArmReg GetMipsRegMapLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapLo(Reg); }
|
||||
CArmOps::ArmReg GetMipsRegMapHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapHi(Reg); }
|
||||
REG_STATE GetMipsRegState(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegState(Reg);
|
||||
}
|
||||
uint64_t GetMipsReg(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsReg(Reg);
|
||||
}
|
||||
uint32_t GetMipsRegLo(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegLo(Reg);
|
||||
}
|
||||
int32_t GetMipsRegLo_S(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegLo_S(Reg);
|
||||
}
|
||||
uint32_t GetMipsRegHi(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegHi(Reg);
|
||||
}
|
||||
int32_t GetMipsRegHi_S(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegHi_S(Reg);
|
||||
}
|
||||
CArmOps::ArmReg GetMipsRegMapLo(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegMapLo(Reg);
|
||||
}
|
||||
CArmOps::ArmReg GetMipsRegMapHi(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegMapHi(Reg);
|
||||
}
|
||||
|
||||
bool IsKnown(int32_t Reg) { return m_RegWorkingSet.IsKnown(Reg); }
|
||||
bool IsUnknown(int32_t Reg) { return m_RegWorkingSet.IsUnknown(Reg); }
|
||||
bool IsMapped(int32_t Reg) { return m_RegWorkingSet.IsMapped(Reg); }
|
||||
bool IsConst(int32_t Reg) { return m_RegWorkingSet.IsConst(Reg); }
|
||||
bool IsSigned(int32_t Reg) { return m_RegWorkingSet.IsSigned(Reg); }
|
||||
bool IsUnsigned(int32_t Reg) { return m_RegWorkingSet.IsUnsigned(Reg); }
|
||||
bool Is32Bit(int32_t Reg) { return m_RegWorkingSet.Is32Bit(Reg); }
|
||||
bool Is64Bit(int32_t Reg) { return m_RegWorkingSet.Is64Bit(Reg); }
|
||||
bool Is32BitMapped(int32_t Reg) { return m_RegWorkingSet.Is32BitMapped(Reg); }
|
||||
bool Is64BitMapped(int32_t Reg) { return m_RegWorkingSet.Is64BitMapped(Reg); }
|
||||
void Map_GPR_32bit(int32_t Reg, bool SignValue, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_32bit(Reg, SignValue, MipsRegToLoad); }
|
||||
void Map_GPR_64bit(int32_t Reg, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_64bit(Reg, MipsRegToLoad); }
|
||||
void UnMap_GPR(uint32_t Reg, bool WriteBackValue){ m_RegWorkingSet.UnMap_GPR(Reg, WriteBackValue); }
|
||||
void WriteBack_GPR(uint32_t Reg, bool Unmapping){ m_RegWorkingSet.WriteBack_GPR(Reg, Unmapping); }
|
||||
CArmOps::ArmReg Map_TempReg(CArmOps::ArmReg Reg, int32_t MipsReg, bool LoadHiWord) { return m_RegWorkingSet.Map_TempReg(Reg, MipsReg, LoadHiWord); }
|
||||
CArmOps::ArmReg Map_Variable(CArmRegInfo::VARIABLE_MAPPED variable, CArmOps::ArmReg Reg = CArmOps::Arm_Any) { return m_RegWorkingSet.Map_Variable(variable, Reg); }
|
||||
bool IsKnown(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.IsKnown(Reg);
|
||||
}
|
||||
bool IsUnknown(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.IsUnknown(Reg);
|
||||
}
|
||||
bool IsMapped(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.IsMapped(Reg);
|
||||
}
|
||||
bool IsConst(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.IsConst(Reg);
|
||||
}
|
||||
bool IsSigned(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.IsSigned(Reg);
|
||||
}
|
||||
bool IsUnsigned(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.IsUnsigned(Reg);
|
||||
}
|
||||
bool Is32Bit(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.Is32Bit(Reg);
|
||||
}
|
||||
bool Is64Bit(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.Is64Bit(Reg);
|
||||
}
|
||||
bool Is32BitMapped(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.Is32BitMapped(Reg);
|
||||
}
|
||||
bool Is64BitMapped(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.Is64BitMapped(Reg);
|
||||
}
|
||||
void Map_GPR_32bit(int32_t Reg, bool SignValue, int32_t MipsRegToLoad)
|
||||
{
|
||||
m_RegWorkingSet.Map_GPR_32bit(Reg, SignValue, MipsRegToLoad);
|
||||
}
|
||||
void Map_GPR_64bit(int32_t Reg, int32_t MipsRegToLoad)
|
||||
{
|
||||
m_RegWorkingSet.Map_GPR_64bit(Reg, MipsRegToLoad);
|
||||
}
|
||||
void UnMap_GPR(uint32_t Reg, bool WriteBackValue)
|
||||
{
|
||||
m_RegWorkingSet.UnMap_GPR(Reg, WriteBackValue);
|
||||
}
|
||||
void WriteBack_GPR(uint32_t Reg, bool Unmapping)
|
||||
{
|
||||
m_RegWorkingSet.WriteBack_GPR(Reg, Unmapping);
|
||||
}
|
||||
CArmOps::ArmReg Map_TempReg(CArmOps::ArmReg Reg, int32_t MipsReg, bool LoadHiWord)
|
||||
{
|
||||
return m_RegWorkingSet.Map_TempReg(Reg, MipsReg, LoadHiWord);
|
||||
}
|
||||
CArmOps::ArmReg Map_Variable(CArmRegInfo::VARIABLE_MAPPED variable, CArmOps::ArmReg Reg = CArmOps::Arm_Any)
|
||||
{
|
||||
return m_RegWorkingSet.Map_Variable(variable, Reg);
|
||||
}
|
||||
|
||||
void ResetRegProtection() { m_RegWorkingSet.ResetRegProtection(); }
|
||||
void FixRoundModel(CRegInfo::FPU_ROUND RoundMethod) { m_RegWorkingSet.FixRoundModel(RoundMethod); }
|
||||
void ResetRegProtection()
|
||||
{
|
||||
m_RegWorkingSet.ResetRegProtection();
|
||||
}
|
||||
void FixRoundModel(CRegInfo::FPU_ROUND RoundMethod)
|
||||
{
|
||||
m_RegWorkingSet.FixRoundModel(RoundMethod);
|
||||
}
|
||||
|
||||
void ProtectGPR(uint32_t Reg) { m_RegWorkingSet.ProtectGPR(Reg); }
|
||||
void UnProtectGPR(uint32_t Reg) { m_RegWorkingSet.UnProtectGPR(Reg); }
|
||||
bool UnMap_ArmReg(CArmOps::ArmReg Reg) { return m_RegWorkingSet.UnMap_ArmReg(Reg); }
|
||||
void ProtectGPR(uint32_t Reg)
|
||||
{
|
||||
m_RegWorkingSet.ProtectGPR(Reg);
|
||||
}
|
||||
void UnProtectGPR(uint32_t Reg)
|
||||
{
|
||||
m_RegWorkingSet.UnProtectGPR(Reg);
|
||||
}
|
||||
bool UnMap_ArmReg(CArmOps::ArmReg Reg)
|
||||
{
|
||||
return m_RegWorkingSet.UnMap_ArmReg(Reg);
|
||||
}
|
||||
|
||||
void SW(bool bCheckLLbit);
|
||||
void SW_Const(uint32_t Value, uint32_t VAddr);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#if defined(__arm__) || defined(_M_ARM)
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/Recompiler/Recompiler.h>
|
||||
#include <Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/Recompiler.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
|
||||
CArmRegInfo::CArmRegInfo(CCodeBlock & CodeBlock, CArmOps & Assembler) :
|
||||
m_CodeBlock(CodeBlock),
|
||||
|
@ -66,16 +66,34 @@ bool CArmRegInfo::operator==(const CArmRegInfo& right) const
|
|||
|
||||
for (int32_t count = 0; count < 32; count++)
|
||||
{
|
||||
if (m_RegMapHi[count] != right.m_RegMapHi[count]) { return false; }
|
||||
if (m_RegMapLo[count] != right.m_RegMapLo[count]) { return false; }
|
||||
if (m_RegMapHi[count] != right.m_RegMapHi[count])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_RegMapLo[count] != right.m_RegMapLo[count])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t count = 0; count < 16; count++)
|
||||
{
|
||||
if (m_ArmReg_MapOrder[count] != right.m_ArmReg_MapOrder[count]) { return false; }
|
||||
if (m_ArmReg_Protected[count] != right.m_ArmReg_Protected[count]) { return false; }
|
||||
if (m_ArmReg_MappedTo[count] != right.m_ArmReg_MappedTo[count]) { return false; }
|
||||
if (m_Variable_MappedTo[count] != right.m_Variable_MappedTo[count]) { return false; }
|
||||
if (m_ArmReg_MapOrder[count] != right.m_ArmReg_MapOrder[count])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_ArmReg_Protected[count] != right.m_ArmReg_Protected[count])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_ArmReg_MappedTo[count] != right.m_ArmReg_MappedTo[count])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_Variable_MappedTo[count] != right.m_Variable_MappedTo[count])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -95,18 +113,36 @@ bool CArmRegInfo::ShouldPushPopReg(CArmOps::ArmReg Reg)
|
|||
|
||||
void CArmRegInfo::BeforeCallDirect(void)
|
||||
{
|
||||
static uint32_t PushPopRegisterList[] =
|
||||
{
|
||||
CArmOps::ArmPushPop_R0, CArmOps::ArmPushPop_R1, CArmOps::ArmPushPop_R2, CArmOps::ArmPushPop_R3, CArmOps::ArmPushPop_R4,
|
||||
CArmOps::ArmPushPop_R5, CArmOps::ArmPushPop_R6, CArmOps::ArmPushPop_R7, CArmOps::ArmPushPop_R8, CArmOps::ArmPushPop_R9,
|
||||
CArmOps::ArmPushPop_R10, CArmOps::ArmPushPop_R11, CArmOps::ArmPushPop_R12
|
||||
static uint32_t PushPopRegisterList[] = {
|
||||
CArmOps::ArmPushPop_R0,
|
||||
CArmOps::ArmPushPop_R1,
|
||||
CArmOps::ArmPushPop_R2,
|
||||
CArmOps::ArmPushPop_R3,
|
||||
CArmOps::ArmPushPop_R4,
|
||||
CArmOps::ArmPushPop_R5,
|
||||
CArmOps::ArmPushPop_R6,
|
||||
CArmOps::ArmPushPop_R7,
|
||||
CArmOps::ArmPushPop_R8,
|
||||
CArmOps::ArmPushPop_R9,
|
||||
CArmOps::ArmPushPop_R10,
|
||||
CArmOps::ArmPushPop_R11,
|
||||
CArmOps::ArmPushPop_R12,
|
||||
};
|
||||
|
||||
static CArmOps::ArmReg RegisterList[] =
|
||||
{
|
||||
CArmOps::Arm_R0, CArmOps::Arm_R1, CArmOps::Arm_R2, CArmOps::Arm_R3, CArmOps::Arm_R4,
|
||||
CArmOps::Arm_R5, CArmOps::Arm_R6, CArmOps::Arm_R7, CArmOps::Arm_R8, CArmOps::Arm_R9,
|
||||
CArmOps::Arm_R10, CArmOps::Arm_R11, CArmOps::Arm_R12
|
||||
static CArmOps::ArmReg RegisterList[] = {
|
||||
CArmOps::Arm_R0,
|
||||
CArmOps::Arm_R1,
|
||||
CArmOps::Arm_R2,
|
||||
CArmOps::Arm_R3,
|
||||
CArmOps::Arm_R4,
|
||||
CArmOps::Arm_R5,
|
||||
CArmOps::Arm_R6,
|
||||
CArmOps::Arm_R7,
|
||||
CArmOps::Arm_R8,
|
||||
CArmOps::Arm_R9,
|
||||
CArmOps::Arm_R10,
|
||||
CArmOps::Arm_R11,
|
||||
CArmOps::Arm_R12,
|
||||
};
|
||||
|
||||
if (m_InCallDirect)
|
||||
|
@ -119,7 +155,10 @@ void CArmRegInfo::BeforeCallDirect(void)
|
|||
int PushPopRegisters = 0;
|
||||
for (int i = 0; i < (sizeof(RegisterList) / sizeof(RegisterList[0])); i++)
|
||||
{
|
||||
if (ShouldPushPopReg(RegisterList[i])) { PushPopRegisters |= PushPopRegisterList[i]; }
|
||||
if (ShouldPushPopReg(RegisterList[i]))
|
||||
{
|
||||
PushPopRegisters |= PushPopRegisterList[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (PushPopRegisters == 0)
|
||||
|
@ -148,7 +187,10 @@ void CArmRegInfo::BeforeCallDirect(void)
|
|||
PushPopRegisters = 0;
|
||||
for (int i = 0; i < (sizeof(RegisterList) / sizeof(RegisterList[0])); i++)
|
||||
{
|
||||
if (ShouldPushPopReg(RegisterList[i])) { PushPopRegisters |= PushPopRegisterList[i]; }
|
||||
if (ShouldPushPopReg(RegisterList[i]))
|
||||
{
|
||||
PushPopRegisters |= PushPopRegisterList[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((m_Assembler.PushPopRegisterSize(PushPopRegisters) % 8) != 0)
|
||||
|
@ -162,18 +204,40 @@ void CArmRegInfo::BeforeCallDirect(void)
|
|||
|
||||
void CArmRegInfo::AfterCallDirect(void)
|
||||
{
|
||||
static uint32_t PushPopRegisterList[] =
|
||||
{
|
||||
CArmOps::ArmPushPop_R0, CArmOps::ArmPushPop_R1, CArmOps::ArmPushPop_R2, CArmOps::ArmPushPop_R3, CArmOps::ArmPushPop_R4,
|
||||
CArmOps::ArmPushPop_R5, CArmOps::ArmPushPop_R6, CArmOps::ArmPushPop_R7, CArmOps::ArmPushPop_R8, CArmOps::ArmPushPop_R9,
|
||||
CArmOps::ArmPushPop_R10, CArmOps::ArmPushPop_R11, CArmOps::ArmPushPop_R12, CArmOps::ArmPushPop_LR, CArmOps::ArmPushPop_PC
|
||||
static uint32_t PushPopRegisterList[] = {
|
||||
CArmOps::ArmPushPop_R0,
|
||||
CArmOps::ArmPushPop_R1,
|
||||
CArmOps::ArmPushPop_R2,
|
||||
CArmOps::ArmPushPop_R3,
|
||||
CArmOps::ArmPushPop_R4,
|
||||
CArmOps::ArmPushPop_R5,
|
||||
CArmOps::ArmPushPop_R6,
|
||||
CArmOps::ArmPushPop_R7,
|
||||
CArmOps::ArmPushPop_R8,
|
||||
CArmOps::ArmPushPop_R9,
|
||||
CArmOps::ArmPushPop_R10,
|
||||
CArmOps::ArmPushPop_R11,
|
||||
CArmOps::ArmPushPop_R12,
|
||||
CArmOps::ArmPushPop_LR,
|
||||
CArmOps::ArmPushPop_PC,
|
||||
};
|
||||
|
||||
static CArmOps::ArmReg RegisterList[] =
|
||||
{
|
||||
CArmOps::Arm_R0, CArmOps::Arm_R1, CArmOps::Arm_R2, CArmOps::Arm_R3, CArmOps::Arm_R4,
|
||||
CArmOps::Arm_R5, CArmOps::Arm_R6, CArmOps::Arm_R7, CArmOps::Arm_R8, CArmOps::Arm_R9,
|
||||
CArmOps::Arm_R10, CArmOps::Arm_R11, CArmOps::Arm_R12, CArmOps::ArmRegLR, CArmOps::ArmRegPC,
|
||||
static CArmOps::ArmReg RegisterList[] = {
|
||||
CArmOps::Arm_R0,
|
||||
CArmOps::Arm_R1,
|
||||
CArmOps::Arm_R2,
|
||||
CArmOps::Arm_R3,
|
||||
CArmOps::Arm_R4,
|
||||
CArmOps::Arm_R5,
|
||||
CArmOps::Arm_R6,
|
||||
CArmOps::Arm_R7,
|
||||
CArmOps::Arm_R8,
|
||||
CArmOps::Arm_R9,
|
||||
CArmOps::Arm_R10,
|
||||
CArmOps::Arm_R11,
|
||||
CArmOps::Arm_R12,
|
||||
CArmOps::ArmRegLR,
|
||||
CArmOps::ArmRegPC,
|
||||
};
|
||||
|
||||
if (!m_InCallDirect)
|
||||
|
@ -186,7 +250,10 @@ void CArmRegInfo::AfterCallDirect(void)
|
|||
int PushPopRegisters = 0;
|
||||
for (int i = 0; i < (sizeof(RegisterList) / sizeof(RegisterList[0])); i++)
|
||||
{
|
||||
if (ShouldPushPopReg(RegisterList[i])) { PushPopRegisters |= PushPopRegisterList[i]; }
|
||||
if (ShouldPushPopReg(RegisterList[i]))
|
||||
{
|
||||
PushPopRegisters |= PushPopRegisterList[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (PushPopRegisters != 0)
|
||||
|
@ -258,7 +325,10 @@ void CArmRegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsReg
|
|||
Reg = FreeArmReg(false);
|
||||
if (Reg < 0)
|
||||
{
|
||||
if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_32bit\n\nOut of registers"); }
|
||||
if (HaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError("Map_GPR_32bit\n\nOut of registers");
|
||||
}
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
@ -331,7 +401,10 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad)
|
|||
|
||||
if (MipsReg == 0)
|
||||
{
|
||||
if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_64bit\n\nWhy are you trying to map register 0?"); }
|
||||
if (HaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError("Map_GPR_64bit\n\nWhy are you trying to map register 0?");
|
||||
}
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
@ -342,7 +415,10 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad)
|
|||
regHi = FreeArmReg(false);
|
||||
if (regHi < 0)
|
||||
{
|
||||
if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); }
|
||||
if (HaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers");
|
||||
}
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
@ -351,7 +427,10 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad)
|
|||
reglo = FreeArmReg(false);
|
||||
if (reglo < 0)
|
||||
{
|
||||
if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); }
|
||||
if (HaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers");
|
||||
}
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
@ -369,7 +448,10 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad)
|
|||
regHi = FreeArmReg(false);
|
||||
if (regHi < 0)
|
||||
{
|
||||
if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); }
|
||||
if (HaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers");
|
||||
}
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
@ -475,7 +557,10 @@ void CArmRegInfo::UnMap_GPR(uint32_t MipsReg, bool WriteBackValue)
|
|||
return;
|
||||
}
|
||||
|
||||
if (IsUnknown(MipsReg)) { return; }
|
||||
if (IsUnknown(MipsReg))
|
||||
{
|
||||
return;
|
||||
}
|
||||
//m_CodeBlock.Log("UnMap_GPR: State: %X\tReg: %s\tWriteBack: %s",State,CRegName::GPR[Reg],WriteBackValue?"true":"false");
|
||||
if (IsConst(MipsReg))
|
||||
{
|
||||
|
@ -582,9 +667,18 @@ void CArmRegInfo::WriteBackRegisters()
|
|||
UnMap_AllFPRs();
|
||||
|
||||
int32_t ArmRegCount = sizeof(m_ArmReg_MappedTo) / sizeof(m_ArmReg_MappedTo[0]);
|
||||
for (int32_t i = 1; i < 32; i++) { UnMap_GPR(i, true); }
|
||||
for (int32_t i = 0; i < ArmRegCount; i++) { UnMap_ArmReg((CArmOps::ArmReg)i); }
|
||||
for (int32_t i = 0; i < ArmRegCount; i++) { SetArmRegProtected((CArmOps::ArmReg)i, false); }
|
||||
for (int32_t i = 1; i < 32; i++)
|
||||
{
|
||||
UnMap_GPR(i, true);
|
||||
}
|
||||
for (int32_t i = 0; i < ArmRegCount; i++)
|
||||
{
|
||||
UnMap_ArmReg((CArmOps::ArmReg)i);
|
||||
}
|
||||
for (int32_t i = 0; i < ArmRegCount; i++)
|
||||
{
|
||||
SetArmRegProtected((CArmOps::ArmReg)i, false);
|
||||
}
|
||||
|
||||
for (int32_t count = 1; count < 32; count++)
|
||||
{
|
||||
|
@ -628,21 +722,57 @@ CArmOps::ArmReg CArmRegInfo::UnMap_TempReg(bool TempMapping)
|
|||
}
|
||||
CArmOps::ArmReg Reg = CArmOps::Arm_Unknown;
|
||||
|
||||
if (GetArmRegMapped( CArmOps::Arm_R7) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R7)) { return CArmOps::Arm_R7; }
|
||||
if (GetArmRegMapped( CArmOps::Arm_R6) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R6)) { return CArmOps::Arm_R6; }
|
||||
if (GetArmRegMapped( CArmOps::Arm_R5) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R5)) { return CArmOps::Arm_R5; }
|
||||
if (GetArmRegMapped( CArmOps::Arm_R4) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R4)) { return CArmOps::Arm_R4; }
|
||||
if (GetArmRegMapped( CArmOps::Arm_R3) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R3)) { return CArmOps::Arm_R3; }
|
||||
if (GetArmRegMapped( CArmOps::Arm_R2) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R2)) { return CArmOps::Arm_R2; }
|
||||
if (GetArmRegMapped( CArmOps::Arm_R1) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R1)) { return CArmOps::Arm_R1; }
|
||||
if (GetArmRegMapped( CArmOps::Arm_R0) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R0)) { return CArmOps::Arm_R0; }
|
||||
if (GetArmRegMapped(CArmOps::Arm_R7) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R7))
|
||||
{
|
||||
return CArmOps::Arm_R7;
|
||||
}
|
||||
if (GetArmRegMapped(CArmOps::Arm_R6) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R6))
|
||||
{
|
||||
return CArmOps::Arm_R6;
|
||||
}
|
||||
if (GetArmRegMapped(CArmOps::Arm_R5) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R5))
|
||||
{
|
||||
return CArmOps::Arm_R5;
|
||||
}
|
||||
if (GetArmRegMapped(CArmOps::Arm_R4) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R4))
|
||||
{
|
||||
return CArmOps::Arm_R4;
|
||||
}
|
||||
if (GetArmRegMapped(CArmOps::Arm_R3) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R3))
|
||||
{
|
||||
return CArmOps::Arm_R3;
|
||||
}
|
||||
if (GetArmRegMapped(CArmOps::Arm_R2) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R2))
|
||||
{
|
||||
return CArmOps::Arm_R2;
|
||||
}
|
||||
if (GetArmRegMapped(CArmOps::Arm_R1) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R1))
|
||||
{
|
||||
return CArmOps::Arm_R1;
|
||||
}
|
||||
if (GetArmRegMapped(CArmOps::Arm_R0) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R0))
|
||||
{
|
||||
return CArmOps::Arm_R0;
|
||||
}
|
||||
if (TempMapping)
|
||||
{
|
||||
if (GetArmRegMapped( CArmOps::Arm_R11) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R11)) { return CArmOps::Arm_R11; }
|
||||
if (GetArmRegMapped( CArmOps::Arm_R10) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R10)) { return CArmOps::Arm_R10; }
|
||||
if (GetArmRegMapped(CArmOps::Arm_R11) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R11))
|
||||
{
|
||||
return CArmOps::Arm_R11;
|
||||
}
|
||||
if (GetArmRegMapped(CArmOps::Arm_R10) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R10))
|
||||
{
|
||||
return CArmOps::Arm_R10;
|
||||
}
|
||||
}
|
||||
if (GetArmRegMapped(CArmOps::Arm_R9) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R9))
|
||||
{
|
||||
return CArmOps::Arm_R9;
|
||||
}
|
||||
if (GetArmRegMapped(CArmOps::Arm_R8) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R8))
|
||||
{
|
||||
return CArmOps::Arm_R8;
|
||||
}
|
||||
if (GetArmRegMapped( CArmOps::Arm_R9) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R9)) { return CArmOps::Arm_R9; }
|
||||
if (GetArmRegMapped( CArmOps::Arm_R8) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R8)) { return CArmOps::Arm_R8; }
|
||||
|
||||
if (Reg != CArmOps::Arm_Unknown)
|
||||
{
|
||||
|
@ -742,24 +872,63 @@ CArmOps::ArmReg CArmRegInfo::FreeArmReg(bool TempMapping)
|
|||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
return CArmOps::Arm_Unknown;
|
||||
}
|
||||
if ((GetArmRegMapped( CArmOps::Arm_R7) == NotMapped || GetArmRegMapped( CArmOps::Arm_R7) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R7)) { return CArmOps::Arm_R7; }
|
||||
if ((GetArmRegMapped( CArmOps::Arm_R6) == NotMapped || GetArmRegMapped( CArmOps::Arm_R6) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R6)) { return CArmOps::Arm_R6; }
|
||||
if ((GetArmRegMapped( CArmOps::Arm_R5) == NotMapped || GetArmRegMapped( CArmOps::Arm_R5) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R5)) { return CArmOps::Arm_R5; }
|
||||
if ((GetArmRegMapped( CArmOps::Arm_R4) == NotMapped || GetArmRegMapped( CArmOps::Arm_R4) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R4)) { return CArmOps::Arm_R4; }
|
||||
if ((GetArmRegMapped( CArmOps::Arm_R3) == NotMapped || GetArmRegMapped( CArmOps::Arm_R3) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R3)) { return CArmOps::Arm_R3; }
|
||||
if ((GetArmRegMapped( CArmOps::Arm_R2) == NotMapped || GetArmRegMapped( CArmOps::Arm_R2) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R2)) { return CArmOps::Arm_R2; }
|
||||
if ((GetArmRegMapped( CArmOps::Arm_R1) == NotMapped || GetArmRegMapped( CArmOps::Arm_R1) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R1)) { return CArmOps::Arm_R1; }
|
||||
if ((GetArmRegMapped( CArmOps::Arm_R0) == NotMapped || GetArmRegMapped( CArmOps::Arm_R0) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R0)) { return CArmOps::Arm_R0; }
|
||||
if ((GetArmRegMapped(CArmOps::Arm_R7) == NotMapped || GetArmRegMapped(CArmOps::Arm_R7) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R7))
|
||||
{
|
||||
return CArmOps::Arm_R7;
|
||||
}
|
||||
if ((GetArmRegMapped(CArmOps::Arm_R6) == NotMapped || GetArmRegMapped(CArmOps::Arm_R6) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R6))
|
||||
{
|
||||
return CArmOps::Arm_R6;
|
||||
}
|
||||
if ((GetArmRegMapped(CArmOps::Arm_R5) == NotMapped || GetArmRegMapped(CArmOps::Arm_R5) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R5))
|
||||
{
|
||||
return CArmOps::Arm_R5;
|
||||
}
|
||||
if ((GetArmRegMapped(CArmOps::Arm_R4) == NotMapped || GetArmRegMapped(CArmOps::Arm_R4) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R4))
|
||||
{
|
||||
return CArmOps::Arm_R4;
|
||||
}
|
||||
if ((GetArmRegMapped(CArmOps::Arm_R3) == NotMapped || GetArmRegMapped(CArmOps::Arm_R3) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R3))
|
||||
{
|
||||
return CArmOps::Arm_R3;
|
||||
}
|
||||
if ((GetArmRegMapped(CArmOps::Arm_R2) == NotMapped || GetArmRegMapped(CArmOps::Arm_R2) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R2))
|
||||
{
|
||||
return CArmOps::Arm_R2;
|
||||
}
|
||||
if ((GetArmRegMapped(CArmOps::Arm_R1) == NotMapped || GetArmRegMapped(CArmOps::Arm_R1) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R1))
|
||||
{
|
||||
return CArmOps::Arm_R1;
|
||||
}
|
||||
if ((GetArmRegMapped(CArmOps::Arm_R0) == NotMapped || GetArmRegMapped(CArmOps::Arm_R0) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R0))
|
||||
{
|
||||
return CArmOps::Arm_R0;
|
||||
}
|
||||
if (TempMapping)
|
||||
{
|
||||
if ((GetArmRegMapped( CArmOps::Arm_R11) == NotMapped || GetArmRegMapped( CArmOps::Arm_R11) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R11)) { return CArmOps::Arm_R11; }
|
||||
if ((GetArmRegMapped( CArmOps::Arm_R10) == NotMapped || GetArmRegMapped( CArmOps::Arm_R10) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R10)) { return CArmOps::Arm_R10; }
|
||||
if ((GetArmRegMapped(CArmOps::Arm_R11) == NotMapped || GetArmRegMapped(CArmOps::Arm_R11) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R11))
|
||||
{
|
||||
return CArmOps::Arm_R11;
|
||||
}
|
||||
if ((GetArmRegMapped(CArmOps::Arm_R10) == NotMapped || GetArmRegMapped(CArmOps::Arm_R10) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R10))
|
||||
{
|
||||
return CArmOps::Arm_R10;
|
||||
}
|
||||
}
|
||||
if ((GetArmRegMapped(CArmOps::Arm_R9) == NotMapped || GetArmRegMapped(CArmOps::Arm_R9) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R9))
|
||||
{
|
||||
return CArmOps::Arm_R9;
|
||||
}
|
||||
if ((GetArmRegMapped(CArmOps::Arm_R8) == NotMapped || GetArmRegMapped(CArmOps::Arm_R8) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R8))
|
||||
{
|
||||
return CArmOps::Arm_R8;
|
||||
}
|
||||
if ((GetArmRegMapped( CArmOps::Arm_R9) == NotMapped || GetArmRegMapped( CArmOps::Arm_R9) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R9)) { return CArmOps::Arm_R9; }
|
||||
if ((GetArmRegMapped( CArmOps::Arm_R8) == NotMapped || GetArmRegMapped( CArmOps::Arm_R8) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R8)) { return CArmOps::Arm_R8; }
|
||||
|
||||
CArmOps::ArmReg Reg = UnMap_TempReg(TempMapping);
|
||||
if (Reg != CArmOps::Arm_Unknown) { return Reg; }
|
||||
if (Reg != CArmOps::Arm_Unknown)
|
||||
{
|
||||
return Reg;
|
||||
}
|
||||
|
||||
int32_t MapCount[CArmOps::Arm_R12];
|
||||
CArmOps::ArmReg MapReg[CArmOps::Arm_R12];
|
||||
|
@ -847,8 +1016,7 @@ void CArmRegInfo::LogRegisterState(void)
|
|||
GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped ? stdstr_f(" (%s)", CArmRegInfo::VariableMapName(GetVariableMappedTo((CArmOps::ArmReg)i))).c_str() : "",
|
||||
regname.length() > 0 ? stdstr_f(" (%s)", regname.c_str()).c_str() : "",
|
||||
GetArmRegProtected((CArmOps::ArmReg)i) ? "true" : "false",
|
||||
GetArmRegMapOrder((CArmOps::ArmReg)i)
|
||||
);
|
||||
GetArmRegMapOrder((CArmOps::ArmReg)i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -864,18 +1032,54 @@ CArmOps::ArmReg CArmRegInfo::Map_TempReg(CArmOps::ArmReg Reg, int32_t MipsReg, b
|
|||
|
||||
if (Reg == CArmOps::Arm_Any)
|
||||
{
|
||||
if (GetArmRegMapped( CArmOps::Arm_R7) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R7)) { Reg = CArmOps::Arm_R7; }
|
||||
else if (GetArmRegMapped( CArmOps::Arm_R6) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R6)) { Reg = CArmOps::Arm_R6; }
|
||||
else if (GetArmRegMapped( CArmOps::Arm_R5) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R5)) { Reg = CArmOps::Arm_R5; }
|
||||
else if (GetArmRegMapped( CArmOps::Arm_R4) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R4)) { Reg = CArmOps::Arm_R4; }
|
||||
else if (GetArmRegMapped( CArmOps::Arm_R3) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R3)) { Reg = CArmOps::Arm_R3; }
|
||||
else if (GetArmRegMapped( CArmOps::Arm_R2) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R2)) { Reg = CArmOps::Arm_R2; }
|
||||
else if (GetArmRegMapped( CArmOps::Arm_R1) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R1)) { Reg = CArmOps::Arm_R1; }
|
||||
else if (GetArmRegMapped( CArmOps::Arm_R0) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R0)) { Reg = CArmOps::Arm_R0; }
|
||||
else if (GetArmRegMapped( CArmOps::Arm_R11) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R11)) { Reg = CArmOps::Arm_R11; }
|
||||
else if (GetArmRegMapped( CArmOps::Arm_R10) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R10)) { Reg = CArmOps::Arm_R10; }
|
||||
else if (GetArmRegMapped( CArmOps::Arm_R9) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R9)) { Reg = CArmOps::Arm_R9; }
|
||||
else if (GetArmRegMapped( CArmOps::Arm_R8) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R8)) { Reg = CArmOps::Arm_R8; }
|
||||
if (GetArmRegMapped(CArmOps::Arm_R7) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R7))
|
||||
{
|
||||
Reg = CArmOps::Arm_R7;
|
||||
}
|
||||
else if (GetArmRegMapped(CArmOps::Arm_R6) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R6))
|
||||
{
|
||||
Reg = CArmOps::Arm_R6;
|
||||
}
|
||||
else if (GetArmRegMapped(CArmOps::Arm_R5) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R5))
|
||||
{
|
||||
Reg = CArmOps::Arm_R5;
|
||||
}
|
||||
else if (GetArmRegMapped(CArmOps::Arm_R4) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R4))
|
||||
{
|
||||
Reg = CArmOps::Arm_R4;
|
||||
}
|
||||
else if (GetArmRegMapped(CArmOps::Arm_R3) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R3))
|
||||
{
|
||||
Reg = CArmOps::Arm_R3;
|
||||
}
|
||||
else if (GetArmRegMapped(CArmOps::Arm_R2) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R2))
|
||||
{
|
||||
Reg = CArmOps::Arm_R2;
|
||||
}
|
||||
else if (GetArmRegMapped(CArmOps::Arm_R1) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R1))
|
||||
{
|
||||
Reg = CArmOps::Arm_R1;
|
||||
}
|
||||
else if (GetArmRegMapped(CArmOps::Arm_R0) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R0))
|
||||
{
|
||||
Reg = CArmOps::Arm_R0;
|
||||
}
|
||||
else if (GetArmRegMapped(CArmOps::Arm_R11) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R11))
|
||||
{
|
||||
Reg = CArmOps::Arm_R11;
|
||||
}
|
||||
else if (GetArmRegMapped(CArmOps::Arm_R10) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R10))
|
||||
{
|
||||
Reg = CArmOps::Arm_R10;
|
||||
}
|
||||
else if (GetArmRegMapped(CArmOps::Arm_R9) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R9))
|
||||
{
|
||||
Reg = CArmOps::Arm_R9;
|
||||
}
|
||||
else if (GetArmRegMapped(CArmOps::Arm_R8) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R8))
|
||||
{
|
||||
Reg = CArmOps::Arm_R8;
|
||||
}
|
||||
|
||||
if (Reg == CArmOps::Arm_Any)
|
||||
{
|
||||
|
@ -1035,13 +1239,34 @@ CArmOps::ArmReg CArmRegInfo::Map_Variable(VARIABLE_MAPPED variable, CArmOps::Arm
|
|||
|
||||
m_CodeBlock.Log(" regcache: allocate %s as pointer to %s", m_Assembler.ArmRegName(Reg), VariableMapName(variable));
|
||||
m_Variable_MappedTo[Reg] = variable;
|
||||
if (variable == VARIABLE_GPR) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)_GPR, "_GPR"); }
|
||||
else if (variable == VARIABLE_FPR) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)_FPR_S, "_FPR_S"); }
|
||||
else if (variable == VARIABLE_TLB_READMAP) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_MMU->m_TLB_ReadMap), "MMU->TLB_ReadMap"); }
|
||||
else if (variable == VARIABLE_TLB_WRITEMAP) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_MMU->m_TLB_WriteMap), "MMU->m_TLB_WriteMap"); }
|
||||
else if (variable == VARIABLE_TLB_LOAD_ADDRESS) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_TLBLoadAddress), "g_TLBLoadAddress"); }
|
||||
else if (variable == VARIABLE_TLB_STORE_ADDRESS) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_TLBStoreAddress), "g_TLBStoreAddress"); }
|
||||
else if (variable == VARIABLE_NEXT_TIMER) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_NextTimer), "g_NextTimer"); }
|
||||
if (variable == VARIABLE_GPR)
|
||||
{
|
||||
m_Assembler.MoveConstToArmReg(Reg, (uint32_t)_GPR, "_GPR");
|
||||
}
|
||||
else if (variable == VARIABLE_FPR)
|
||||
{
|
||||
m_Assembler.MoveConstToArmReg(Reg, (uint32_t)_FPR_S, "_FPR_S");
|
||||
}
|
||||
else if (variable == VARIABLE_TLB_READMAP)
|
||||
{
|
||||
m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_MMU->m_TLB_ReadMap), "MMU->TLB_ReadMap");
|
||||
}
|
||||
else if (variable == VARIABLE_TLB_WRITEMAP)
|
||||
{
|
||||
m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_MMU->m_TLB_WriteMap), "MMU->m_TLB_WriteMap");
|
||||
}
|
||||
else if (variable == VARIABLE_TLB_LOAD_ADDRESS)
|
||||
{
|
||||
m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_TLBLoadAddress), "g_TLBLoadAddress");
|
||||
}
|
||||
else if (variable == VARIABLE_TLB_STORE_ADDRESS)
|
||||
{
|
||||
m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_TLBStoreAddress), "g_TLBStoreAddress");
|
||||
}
|
||||
else if (variable == VARIABLE_NEXT_TIMER)
|
||||
{
|
||||
m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_NextTimer), "g_NextTimer");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
#if defined(__arm__) || defined(_M_ARM)
|
||||
#include <Project64-core/N64System/Recompiler/RegBase.h>
|
||||
#include <Project64-core/N64System/Recompiler/Arm/ArmOps.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/Recompiler/Arm/ArmOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/RegBase.h>
|
||||
|
||||
class CArmRegInfo :
|
||||
public CRegBase,
|
||||
|
@ -61,21 +61,57 @@ public:
|
|||
bool UnMap_ArmReg(CArmOps::ArmReg Reg);
|
||||
void ResetRegProtection();
|
||||
|
||||
inline CArmOps::ArmReg GetMipsRegMapLo(int32_t Reg) const { return m_RegMapLo[Reg]; }
|
||||
inline CArmOps::ArmReg GetMipsRegMapHi(int32_t Reg) const { return m_RegMapHi[Reg]; }
|
||||
inline void SetMipsRegMapLo(int32_t GetMipsReg, CArmOps::ArmReg Reg) { m_RegMapLo[GetMipsReg] = Reg; }
|
||||
inline void SetMipsRegMapHi(int32_t GetMipsReg, CArmOps::ArmReg Reg) { m_RegMapHi[GetMipsReg] = Reg; }
|
||||
inline CArmOps::ArmReg GetMipsRegMapLo(int32_t Reg) const
|
||||
{
|
||||
return m_RegMapLo[Reg];
|
||||
}
|
||||
inline CArmOps::ArmReg GetMipsRegMapHi(int32_t Reg) const
|
||||
{
|
||||
return m_RegMapHi[Reg];
|
||||
}
|
||||
inline void SetMipsRegMapLo(int32_t GetMipsReg, CArmOps::ArmReg Reg)
|
||||
{
|
||||
m_RegMapLo[GetMipsReg] = Reg;
|
||||
}
|
||||
inline void SetMipsRegMapHi(int32_t GetMipsReg, CArmOps::ArmReg Reg)
|
||||
{
|
||||
m_RegMapHi[GetMipsReg] = Reg;
|
||||
}
|
||||
|
||||
inline uint32_t GetArmRegMapOrder(CArmOps::ArmReg Reg) const { return m_ArmReg_MapOrder[Reg]; }
|
||||
inline bool GetArmRegProtected(CArmOps::ArmReg Reg) const { return m_ArmReg_Protected[Reg]; }
|
||||
inline REG_MAPPED GetArmRegMapped(CArmOps::ArmReg Reg) const { return m_ArmReg_MappedTo[Reg]; }
|
||||
inline uint32_t GetArmRegMapOrder(CArmOps::ArmReg Reg) const
|
||||
{
|
||||
return m_ArmReg_MapOrder[Reg];
|
||||
}
|
||||
inline bool GetArmRegProtected(CArmOps::ArmReg Reg) const
|
||||
{
|
||||
return m_ArmReg_Protected[Reg];
|
||||
}
|
||||
inline REG_MAPPED GetArmRegMapped(CArmOps::ArmReg Reg) const
|
||||
{
|
||||
return m_ArmReg_MappedTo[Reg];
|
||||
}
|
||||
|
||||
inline void SetArmRegMapOrder(CArmOps::ArmReg Reg, uint32_t Order) { m_ArmReg_MapOrder[Reg] = Order; }
|
||||
inline void SetArmRegProtected(CArmOps::ArmReg Reg, bool Protected) { m_ArmReg_Protected[Reg] = Protected; }
|
||||
inline void SetArmRegMapped(CArmOps::ArmReg Reg, REG_MAPPED Mapping) { m_ArmReg_MappedTo[Reg] = Mapping; }
|
||||
inline void SetArmRegMapOrder(CArmOps::ArmReg Reg, uint32_t Order)
|
||||
{
|
||||
m_ArmReg_MapOrder[Reg] = Order;
|
||||
}
|
||||
inline void SetArmRegProtected(CArmOps::ArmReg Reg, bool Protected)
|
||||
{
|
||||
m_ArmReg_Protected[Reg] = Protected;
|
||||
}
|
||||
inline void SetArmRegMapped(CArmOps::ArmReg Reg, REG_MAPPED Mapping)
|
||||
{
|
||||
m_ArmReg_MappedTo[Reg] = Mapping;
|
||||
}
|
||||
|
||||
inline VARIABLE_MAPPED GetVariableMappedTo(CArmOps::ArmReg Reg) const { return m_Variable_MappedTo[Reg]; }
|
||||
inline void SetVariableMappedTo(CArmOps::ArmReg Reg, VARIABLE_MAPPED variable) { m_Variable_MappedTo[Reg] = variable; }
|
||||
inline VARIABLE_MAPPED GetVariableMappedTo(CArmOps::ArmReg Reg) const
|
||||
{
|
||||
return m_Variable_MappedTo[Reg];
|
||||
}
|
||||
inline void SetVariableMappedTo(CArmOps::ArmReg Reg, VARIABLE_MAPPED variable)
|
||||
{
|
||||
m_Variable_MappedTo[Reg] = variable;
|
||||
}
|
||||
static const char * VariableMapName(VARIABLE_MAPPED variable);
|
||||
|
||||
void LogRegisterState(void);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#include "stdafx.h"
|
||||
#include <string.h>
|
||||
|
||||
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/CodeBlock.h>
|
||||
#include <Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(ANDROID) && (defined(__arm__) || defined(_M_ARM))
|
||||
/* bug-fix to implement __clear_cache (missing in Android; http://code.google.com/p/android/issues/detail?id=1803) */
|
||||
|
@ -451,22 +452,53 @@ bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t &
|
|||
case R4300i_SPECIAL:
|
||||
switch (Command.funct)
|
||||
{
|
||||
case R4300i_SPECIAL_SLL: case R4300i_SPECIAL_SRL: case R4300i_SPECIAL_SRA:
|
||||
case R4300i_SPECIAL_SLLV: case R4300i_SPECIAL_SRLV: case R4300i_SPECIAL_SRAV:
|
||||
case R4300i_SPECIAL_MFHI: case R4300i_SPECIAL_MTHI: case R4300i_SPECIAL_MFLO:
|
||||
case R4300i_SPECIAL_MTLO: case R4300i_SPECIAL_DSLLV: case R4300i_SPECIAL_DSRLV:
|
||||
case R4300i_SPECIAL_DSRAV: case R4300i_SPECIAL_ADD: case R4300i_SPECIAL_ADDU:
|
||||
case R4300i_SPECIAL_SUB: case R4300i_SPECIAL_SUBU: case R4300i_SPECIAL_AND:
|
||||
case R4300i_SPECIAL_OR: case R4300i_SPECIAL_XOR: case R4300i_SPECIAL_NOR:
|
||||
case R4300i_SPECIAL_SLT: case R4300i_SPECIAL_SLTU: case R4300i_SPECIAL_DADD:
|
||||
case R4300i_SPECIAL_DADDU: case R4300i_SPECIAL_DSUB: case R4300i_SPECIAL_DSUBU:
|
||||
case R4300i_SPECIAL_DSLL: case R4300i_SPECIAL_DSRL: case R4300i_SPECIAL_DSRA:
|
||||
case R4300i_SPECIAL_DSLL32: case R4300i_SPECIAL_DSRL32: case R4300i_SPECIAL_DSRA32:
|
||||
case R4300i_SPECIAL_MULT: case R4300i_SPECIAL_MULTU: case R4300i_SPECIAL_DIV:
|
||||
case R4300i_SPECIAL_DIVU: case R4300i_SPECIAL_DMULT: case R4300i_SPECIAL_DMULTU:
|
||||
case R4300i_SPECIAL_DDIV: case R4300i_SPECIAL_DDIVU: case R4300i_SPECIAL_TEQ:
|
||||
case R4300i_SPECIAL_TNE: case R4300i_SPECIAL_TGE: case R4300i_SPECIAL_TGEU:
|
||||
case R4300i_SPECIAL_TLT: case R4300i_SPECIAL_TLTU:
|
||||
case R4300i_SPECIAL_SLL:
|
||||
case R4300i_SPECIAL_SRL:
|
||||
case R4300i_SPECIAL_SRA:
|
||||
case R4300i_SPECIAL_SLLV:
|
||||
case R4300i_SPECIAL_SRLV:
|
||||
case R4300i_SPECIAL_SRAV:
|
||||
case R4300i_SPECIAL_MFHI:
|
||||
case R4300i_SPECIAL_MTHI:
|
||||
case R4300i_SPECIAL_MFLO:
|
||||
case R4300i_SPECIAL_MTLO:
|
||||
case R4300i_SPECIAL_DSLLV:
|
||||
case R4300i_SPECIAL_DSRLV:
|
||||
case R4300i_SPECIAL_DSRAV:
|
||||
case R4300i_SPECIAL_ADD:
|
||||
case R4300i_SPECIAL_ADDU:
|
||||
case R4300i_SPECIAL_SUB:
|
||||
case R4300i_SPECIAL_SUBU:
|
||||
case R4300i_SPECIAL_AND:
|
||||
case R4300i_SPECIAL_OR:
|
||||
case R4300i_SPECIAL_XOR:
|
||||
case R4300i_SPECIAL_NOR:
|
||||
case R4300i_SPECIAL_SLT:
|
||||
case R4300i_SPECIAL_SLTU:
|
||||
case R4300i_SPECIAL_DADD:
|
||||
case R4300i_SPECIAL_DADDU:
|
||||
case R4300i_SPECIAL_DSUB:
|
||||
case R4300i_SPECIAL_DSUBU:
|
||||
case R4300i_SPECIAL_DSLL:
|
||||
case R4300i_SPECIAL_DSRL:
|
||||
case R4300i_SPECIAL_DSRA:
|
||||
case R4300i_SPECIAL_DSLL32:
|
||||
case R4300i_SPECIAL_DSRL32:
|
||||
case R4300i_SPECIAL_DSRA32:
|
||||
case R4300i_SPECIAL_MULT:
|
||||
case R4300i_SPECIAL_MULTU:
|
||||
case R4300i_SPECIAL_DIV:
|
||||
case R4300i_SPECIAL_DIVU:
|
||||
case R4300i_SPECIAL_DMULT:
|
||||
case R4300i_SPECIAL_DMULTU:
|
||||
case R4300i_SPECIAL_DDIV:
|
||||
case R4300i_SPECIAL_DDIVU:
|
||||
case R4300i_SPECIAL_TEQ:
|
||||
case R4300i_SPECIAL_TNE:
|
||||
case R4300i_SPECIAL_TGE:
|
||||
case R4300i_SPECIAL_TGEU:
|
||||
case R4300i_SPECIAL_TLT:
|
||||
case R4300i_SPECIAL_TLTU:
|
||||
break;
|
||||
case R4300i_SPECIAL_JALR:
|
||||
case R4300i_SPECIAL_JR:
|
||||
|
@ -563,8 +595,12 @@ bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t &
|
|||
LikelyBranch = true;
|
||||
IncludeDelaySlot = true;
|
||||
break;
|
||||
case R4300i_REGIMM_TEQI: case R4300i_REGIMM_TNEI: case R4300i_REGIMM_TGEI:
|
||||
case R4300i_REGIMM_TGEIU: case R4300i_REGIMM_TLTI: case R4300i_REGIMM_TLTIU:
|
||||
case R4300i_REGIMM_TEQI:
|
||||
case R4300i_REGIMM_TNEI:
|
||||
case R4300i_REGIMM_TGEI:
|
||||
case R4300i_REGIMM_TGEIU:
|
||||
case R4300i_REGIMM_TLTI:
|
||||
case R4300i_REGIMM_TLTIU:
|
||||
break;
|
||||
default:
|
||||
if (Command.Value == 0x0407000D)
|
||||
|
@ -639,15 +675,18 @@ bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t &
|
|||
case R4300i_CP0:
|
||||
switch (Command.rs)
|
||||
{
|
||||
case R4300i_COP0_MT: case R4300i_COP0_MF:
|
||||
case R4300i_COP0_MT:
|
||||
case R4300i_COP0_MF:
|
||||
break;
|
||||
default:
|
||||
if ((Command.rs & 0x10) != 0)
|
||||
{
|
||||
switch (Command.funct)
|
||||
{
|
||||
case R4300i_COP0_CO_TLBR: case R4300i_COP0_CO_TLBWI:
|
||||
case R4300i_COP0_CO_TLBWR: case R4300i_COP0_CO_TLBP:
|
||||
case R4300i_COP0_CO_TLBR:
|
||||
case R4300i_COP0_CO_TLBWI:
|
||||
case R4300i_COP0_CO_TLBWR:
|
||||
case R4300i_COP0_CO_TLBP:
|
||||
break;
|
||||
case R4300i_COP0_CO_ERET:
|
||||
EndBlock = true;
|
||||
|
@ -668,12 +707,20 @@ bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t &
|
|||
case R4300i_CP1:
|
||||
switch (Command.fmt)
|
||||
{
|
||||
case R4300i_COP1_MF: case R4300i_COP1_DMF: case R4300i_COP1_CF: case R4300i_COP1_MT:
|
||||
case R4300i_COP1_DMT: case R4300i_COP1_CT: case R4300i_COP1_S: case R4300i_COP1_D:
|
||||
case R4300i_COP1_W: case R4300i_COP1_L:
|
||||
case R4300i_COP1_MF:
|
||||
case R4300i_COP1_DMF:
|
||||
case R4300i_COP1_CF:
|
||||
case R4300i_COP1_MT:
|
||||
case R4300i_COP1_DMT:
|
||||
case R4300i_COP1_CT:
|
||||
case R4300i_COP1_S:
|
||||
case R4300i_COP1_D:
|
||||
case R4300i_COP1_W:
|
||||
case R4300i_COP1_L:
|
||||
break;
|
||||
case R4300i_COP1_BC:
|
||||
switch (Command.ft) {
|
||||
switch (Command.ft)
|
||||
{
|
||||
case R4300i_COP1_BC_BCF:
|
||||
case R4300i_COP1_BC_BCT:
|
||||
TargetPC = PC + ((int16_t)Command.offset << 2) + 4;
|
||||
|
@ -711,15 +758,42 @@ bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t &
|
|||
return false;
|
||||
}
|
||||
break;
|
||||
case R4300i_ANDI: case R4300i_ORI: case R4300i_XORI: case R4300i_LUI:
|
||||
case R4300i_ADDI: case R4300i_ADDIU: case R4300i_SLTI: case R4300i_SLTIU:
|
||||
case R4300i_DADDI: case R4300i_DADDIU: case R4300i_LDL: case R4300i_LDR:
|
||||
case R4300i_LB: case R4300i_LH: case R4300i_LWL: case R4300i_LW:
|
||||
case R4300i_LBU: case R4300i_LHU: case R4300i_LWR: case R4300i_LWU:
|
||||
case R4300i_SB: case R4300i_SH: case R4300i_SWL: case R4300i_SW:
|
||||
case R4300i_SDL: case R4300i_SDR: case R4300i_SWR: case R4300i_CACHE:
|
||||
case R4300i_LL: case R4300i_LWC1: case R4300i_LDC1: case R4300i_LD:
|
||||
case R4300i_SC: case R4300i_SWC1: case R4300i_SDC1: case R4300i_SD:
|
||||
case R4300i_ANDI:
|
||||
case R4300i_ORI:
|
||||
case R4300i_XORI:
|
||||
case R4300i_LUI:
|
||||
case R4300i_ADDI:
|
||||
case R4300i_ADDIU:
|
||||
case R4300i_SLTI:
|
||||
case R4300i_SLTIU:
|
||||
case R4300i_DADDI:
|
||||
case R4300i_DADDIU:
|
||||
case R4300i_LDL:
|
||||
case R4300i_LDR:
|
||||
case R4300i_LB:
|
||||
case R4300i_LH:
|
||||
case R4300i_LWL:
|
||||
case R4300i_LW:
|
||||
case R4300i_LBU:
|
||||
case R4300i_LHU:
|
||||
case R4300i_LWR:
|
||||
case R4300i_LWU:
|
||||
case R4300i_SB:
|
||||
case R4300i_SH:
|
||||
case R4300i_SWL:
|
||||
case R4300i_SW:
|
||||
case R4300i_SDL:
|
||||
case R4300i_SDR:
|
||||
case R4300i_SWR:
|
||||
case R4300i_CACHE:
|
||||
case R4300i_LL:
|
||||
case R4300i_LWC1:
|
||||
case R4300i_LDC1:
|
||||
case R4300i_LD:
|
||||
case R4300i_SC:
|
||||
case R4300i_SWC1:
|
||||
case R4300i_SDC1:
|
||||
case R4300i_SD:
|
||||
break;
|
||||
case R4300i_BEQL:
|
||||
TargetPC = PC + ((int16_t)Command.offset << 2) + 4;
|
||||
|
@ -786,7 +860,8 @@ bool CCodeBlock::Compile()
|
|||
m_RecompilerOps->EnterCodeBlock();
|
||||
if (g_System->bLinkBlocks())
|
||||
{
|
||||
while (m_EnterSection !=nullptr && m_EnterSection->GenerateNativeCode(NextTest()));
|
||||
while (m_EnterSection != nullptr && m_EnterSection->GenerateNativeCode(NextTest()))
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include <Common/md5.h>
|
||||
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/CodeSection.h>
|
||||
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
|
||||
|
||||
#if !defined(_MSC_VER) && !defined(_Printf_format_string_)
|
||||
#define _Printf_format_string_
|
||||
|
@ -17,25 +17,73 @@ public:
|
|||
|
||||
bool Compile();
|
||||
|
||||
uint32_t VAddrEnter() const { return m_VAddrEnter; }
|
||||
uint32_t VAddrFirst() const { return m_VAddrFirst; }
|
||||
uint32_t VAddrLast() const { return m_VAddrLast; }
|
||||
uint8_t * CompiledLocation() const { return m_CompiledLocation; }
|
||||
uint8_t * CompiledLocationEnd() const { return m_CompiledLocationEnd; }
|
||||
int32_t NoOfSections() const { return (int32_t)m_Sections.size() - 1; }
|
||||
const CCodeSection & EnterSection() const { return *m_EnterSection; }
|
||||
const MD5Digest & Hash() const { return m_Hash; }
|
||||
CRecompilerOps *& RecompilerOps() { return m_RecompilerOps; }
|
||||
const std::string & CodeLog() const { return m_CodeLog; }
|
||||
uint32_t VAddrEnter() const
|
||||
{
|
||||
return m_VAddrEnter;
|
||||
}
|
||||
uint32_t VAddrFirst() const
|
||||
{
|
||||
return m_VAddrFirst;
|
||||
}
|
||||
uint32_t VAddrLast() const
|
||||
{
|
||||
return m_VAddrLast;
|
||||
}
|
||||
uint8_t * CompiledLocation() const
|
||||
{
|
||||
return m_CompiledLocation;
|
||||
}
|
||||
uint8_t * CompiledLocationEnd() const
|
||||
{
|
||||
return m_CompiledLocationEnd;
|
||||
}
|
||||
int32_t NoOfSections() const
|
||||
{
|
||||
return (int32_t)m_Sections.size() - 1;
|
||||
}
|
||||
const CCodeSection & EnterSection() const
|
||||
{
|
||||
return *m_EnterSection;
|
||||
}
|
||||
const MD5Digest & Hash() const
|
||||
{
|
||||
return m_Hash;
|
||||
}
|
||||
CRecompilerOps *& RecompilerOps()
|
||||
{
|
||||
return m_RecompilerOps;
|
||||
}
|
||||
const std::string & CodeLog() const
|
||||
{
|
||||
return m_CodeLog;
|
||||
}
|
||||
|
||||
void SetVAddrFirst(uint32_t VAddr) { m_VAddrFirst = VAddr; }
|
||||
void SetVAddrLast(uint32_t VAddr) { m_VAddrLast = VAddr; }
|
||||
void SetVAddrFirst(uint32_t VAddr)
|
||||
{
|
||||
m_VAddrFirst = VAddr;
|
||||
}
|
||||
void SetVAddrLast(uint32_t VAddr)
|
||||
{
|
||||
m_VAddrLast = VAddr;
|
||||
}
|
||||
|
||||
CCodeSection * ExistingSection(uint32_t Addr) { return m_EnterSection->ExistingSection(Addr, NextTest()); }
|
||||
bool SectionAccessible(uint32_t m_SectionID) { return m_EnterSection->SectionAccessible(m_SectionID, NextTest()); }
|
||||
CCodeSection * ExistingSection(uint32_t Addr)
|
||||
{
|
||||
return m_EnterSection->ExistingSection(Addr, NextTest());
|
||||
}
|
||||
bool SectionAccessible(uint32_t m_SectionID)
|
||||
{
|
||||
return m_EnterSection->SectionAccessible(m_SectionID, NextTest());
|
||||
}
|
||||
|
||||
uint64_t MemContents(int32_t i) const { return m_MemContents[i]; }
|
||||
uint64_t * MemLocation(int32_t i) const { return m_MemLocation[i]; }
|
||||
uint64_t MemContents(int32_t i) const
|
||||
{
|
||||
return m_MemContents[i];
|
||||
}
|
||||
uint64_t * MemLocation(int32_t i) const
|
||||
{
|
||||
return m_MemLocation[i];
|
||||
}
|
||||
|
||||
uint32_t NextTest();
|
||||
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
#include "stdafx.h"
|
||||
#include <Project64-core/N64System/Recompiler/CodeSection.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iOpcode.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Recompiler/CodeBlock.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
|
||||
#include <Project64-core/Debugger.h>
|
||||
#include <Project64-core/ExceptionHandler.h>
|
||||
#include <Project64-core/N64System/Interpreter/InterpreterCPU.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iOpcode.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/Recompiler/CodeBlock.h>
|
||||
#include <Project64-core/N64System/Recompiler/CodeSection.h>
|
||||
#include <Project64-core/N64System/Recompiler/LoopAnalysis.h>
|
||||
#include <Project64-core/N64System/Recompiler/SectionInfo.h>
|
||||
#include <Project64-core/ExceptionHandler.h>
|
||||
#include <Project64-core/Debugger.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
|
||||
CCodeSection::CCodeSection(CCodeBlock & CodeBlock, uint32_t EnterPC, uint32_t ID, bool LinkAllowed) :
|
||||
m_CodeBlock(CodeBlock),
|
||||
|
@ -90,8 +91,14 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
}
|
||||
else if (TargetSection[i] != nullptr && JumpInfo[i] != nullptr)
|
||||
{
|
||||
if (!JumpInfo[i]->FallThrough) { continue; }
|
||||
if (JumpInfo[i]->TargetPC == TargetSection[i]->m_EnterPC) { continue; }
|
||||
if (!JumpInfo[i]->FallThrough)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (JumpInfo[i]->TargetPC == TargetSection[i]->m_EnterPC)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
m_RecompilerOps->LinkJump(*JumpInfo[i], (uint32_t)-1);
|
||||
m_RecompilerOps->CompileExit(JumpInfo[i]->JumpPC, JumpInfo[i]->TargetPC, JumpInfo[i]->RegSet, JumpInfo[i]->Reason);
|
||||
//FreeSection(TargetSection[i],Section);
|
||||
|
@ -100,8 +107,14 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
}
|
||||
else
|
||||
{
|
||||
if (m_Cont.LinkLocation == nullptr && m_Cont.FallThrough == false) { m_ContinueSection = nullptr; }
|
||||
if (m_Jump.LinkLocation == nullptr && m_Jump.FallThrough == false) { m_JumpSection = nullptr; }
|
||||
if (m_Cont.LinkLocation == nullptr && m_Cont.FallThrough == false)
|
||||
{
|
||||
m_ContinueSection = nullptr;
|
||||
}
|
||||
if (m_Jump.LinkLocation == nullptr && m_Jump.FallThrough == false)
|
||||
{
|
||||
m_JumpSection = nullptr;
|
||||
}
|
||||
if (m_JumpSection == nullptr && m_ContinueSection == nullptr)
|
||||
{
|
||||
//FreeSection(TargetSection[0],Section);
|
||||
|
@ -111,9 +124,16 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
TargetSection[0] = m_ContinueSection;
|
||||
TargetSection[1] = m_JumpSection;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (TargetSection[i] == nullptr) { continue; }
|
||||
if (!JumpInfo[i]->FallThrough) { continue; }
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (TargetSection[i] == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!JumpInfo[i]->FallThrough)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (TargetSection[i]->m_CompiledLocation != nullptr)
|
||||
{
|
||||
|
@ -147,14 +167,26 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (TargetSection[i] == nullptr) { continue; }
|
||||
if (TargetSection[i]->m_ParentSection.empty()) { continue; }
|
||||
if (TargetSection[i] == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (TargetSection[i]->m_ParentSection.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (SECTION_LIST::iterator iter = TargetSection[i]->m_ParentSection.begin(); iter != TargetSection[i]->m_ParentSection.end(); iter++)
|
||||
{
|
||||
CCodeSection * Parent = *iter;
|
||||
|
||||
if (Parent->m_CompiledLocation != nullptr) { continue; }
|
||||
if (Parent->m_InLoop) { continue; }
|
||||
if (Parent->m_CompiledLocation != nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (Parent->m_InLoop)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (JumpInfo[i]->PermLoop)
|
||||
{
|
||||
m_CodeBlock.Log("PermLoop *** 2");
|
||||
|
@ -195,7 +227,10 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
//CodeLog("Section %d",m_SectionID);
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (JumpInfo[i]->LinkLocation == nullptr) { continue; }
|
||||
if (JumpInfo[i]->LinkLocation == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (TargetSection[i] == nullptr)
|
||||
{
|
||||
m_CodeBlock.Log("ExitBlock (from %d):", m_SectionID);
|
||||
|
@ -269,8 +304,14 @@ bool CCodeSection::ParentContinue()
|
|||
for (SECTION_LIST::iterator iter = m_ParentSection.begin(); iter != m_ParentSection.end(); iter++)
|
||||
{
|
||||
CCodeSection * Parent = *iter;
|
||||
if (Parent->m_CompiledLocation != nullptr) { continue; }
|
||||
if (IsAllParentLoops(Parent, true, m_CodeBlock.NextTest())) { continue; }
|
||||
if (Parent->m_CompiledLocation != nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (IsAllParentLoops(Parent, true, m_CodeBlock.NextTest()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
m_RecompilerOps->SetCurrentSection(this);
|
||||
|
@ -291,8 +332,14 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test)
|
|||
return false;
|
||||
}
|
||||
m_Test = Test;
|
||||
if (m_ContinueSection != nullptr && m_ContinueSection->GenerateNativeCode(Test)) { return true; }
|
||||
if (m_JumpSection != nullptr && m_JumpSection->GenerateNativeCode(Test)) { return true; }
|
||||
if (m_ContinueSection != nullptr && m_ContinueSection->GenerateNativeCode(Test))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (m_JumpSection != nullptr && m_JumpSection->GenerateNativeCode(Test))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -389,9 +436,9 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test)
|
|||
case R4300i_SPECIAL_TGEU: m_RecompilerOps->Compile_TrapCompare(RecompilerTrapCompare_TGEU); break;
|
||||
case R4300i_SPECIAL_TLT: m_RecompilerOps->Compile_TrapCompare(RecompilerTrapCompare_TLT); break;
|
||||
case R4300i_SPECIAL_TLTU: m_RecompilerOps->Compile_TrapCompare(RecompilerTrapCompare_TLTU); break;
|
||||
break;
|
||||
default:
|
||||
m_RecompilerOps->UnknownOpcode(); break;
|
||||
m_RecompilerOps->UnknownOpcode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case R4300i_REGIMM:
|
||||
|
@ -410,7 +457,8 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test)
|
|||
case R4300i_REGIMM_TLTI: m_RecompilerOps->Compile_TrapCompare(RecompilerTrapCompare_TLTI); break;
|
||||
case R4300i_REGIMM_TLTIU: m_RecompilerOps->Compile_TrapCompare(RecompilerTrapCompare_TLTIU); break;
|
||||
default:
|
||||
m_RecompilerOps->UnknownOpcode(); break;
|
||||
m_RecompilerOps->UnknownOpcode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case R4300i_BEQ: m_RecompilerOps->Compile_Branch(RecompilerBranchCompare_BEQ, false); break;
|
||||
|
@ -468,7 +516,8 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test)
|
|||
case R4300i_COP1_BC_BCFL: m_RecompilerOps->Compile_BranchLikely(RecompilerBranchCompare_COP1BCF, false); break;
|
||||
case R4300i_COP1_BC_BCTL: m_RecompilerOps->Compile_BranchLikely(RecompilerBranchCompare_COP1BCT, false); break;
|
||||
default:
|
||||
m_RecompilerOps->UnknownOpcode(); break;
|
||||
m_RecompilerOps->UnknownOpcode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case R4300i_COP1_S:
|
||||
|
@ -493,17 +542,27 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test)
|
|||
case R4300i_COP1_FUNCT_CVT_D: m_RecompilerOps->COP1_S_CVT_D(); break;
|
||||
case R4300i_COP1_FUNCT_CVT_W: m_RecompilerOps->COP1_S_CVT_W(); break;
|
||||
case R4300i_COP1_FUNCT_CVT_L: m_RecompilerOps->COP1_S_CVT_L(); break;
|
||||
case R4300i_COP1_FUNCT_C_F: case R4300i_COP1_FUNCT_C_UN:
|
||||
case R4300i_COP1_FUNCT_C_EQ: case R4300i_COP1_FUNCT_C_UEQ:
|
||||
case R4300i_COP1_FUNCT_C_OLT: case R4300i_COP1_FUNCT_C_ULT:
|
||||
case R4300i_COP1_FUNCT_C_OLE: case R4300i_COP1_FUNCT_C_ULE:
|
||||
case R4300i_COP1_FUNCT_C_SF: case R4300i_COP1_FUNCT_C_NGLE:
|
||||
case R4300i_COP1_FUNCT_C_SEQ: case R4300i_COP1_FUNCT_C_NGL:
|
||||
case R4300i_COP1_FUNCT_C_LT: case R4300i_COP1_FUNCT_C_NGE:
|
||||
case R4300i_COP1_FUNCT_C_LE: case R4300i_COP1_FUNCT_C_NGT:
|
||||
m_RecompilerOps->COP1_S_CMP(); break;
|
||||
case R4300i_COP1_FUNCT_C_F:
|
||||
case R4300i_COP1_FUNCT_C_UN:
|
||||
case R4300i_COP1_FUNCT_C_EQ:
|
||||
case R4300i_COP1_FUNCT_C_UEQ:
|
||||
case R4300i_COP1_FUNCT_C_OLT:
|
||||
case R4300i_COP1_FUNCT_C_ULT:
|
||||
case R4300i_COP1_FUNCT_C_OLE:
|
||||
case R4300i_COP1_FUNCT_C_ULE:
|
||||
case R4300i_COP1_FUNCT_C_SF:
|
||||
case R4300i_COP1_FUNCT_C_NGLE:
|
||||
case R4300i_COP1_FUNCT_C_SEQ:
|
||||
case R4300i_COP1_FUNCT_C_NGL:
|
||||
case R4300i_COP1_FUNCT_C_LT:
|
||||
case R4300i_COP1_FUNCT_C_NGE:
|
||||
case R4300i_COP1_FUNCT_C_LE:
|
||||
case R4300i_COP1_FUNCT_C_NGT:
|
||||
m_RecompilerOps->COP1_S_CMP();
|
||||
break;
|
||||
default:
|
||||
m_RecompilerOps->UnknownOpcode(); break;
|
||||
m_RecompilerOps->UnknownOpcode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case R4300i_COP1_D:
|
||||
|
@ -528,17 +587,27 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test)
|
|||
case R4300i_COP1_FUNCT_CVT_S: m_RecompilerOps->COP1_D_CVT_S(); break;
|
||||
case R4300i_COP1_FUNCT_CVT_W: m_RecompilerOps->COP1_D_CVT_W(); break;
|
||||
case R4300i_COP1_FUNCT_CVT_L: m_RecompilerOps->COP1_D_CVT_L(); break;
|
||||
case R4300i_COP1_FUNCT_C_F: case R4300i_COP1_FUNCT_C_UN:
|
||||
case R4300i_COP1_FUNCT_C_EQ: case R4300i_COP1_FUNCT_C_UEQ:
|
||||
case R4300i_COP1_FUNCT_C_OLT: case R4300i_COP1_FUNCT_C_ULT:
|
||||
case R4300i_COP1_FUNCT_C_OLE: case R4300i_COP1_FUNCT_C_ULE:
|
||||
case R4300i_COP1_FUNCT_C_SF: case R4300i_COP1_FUNCT_C_NGLE:
|
||||
case R4300i_COP1_FUNCT_C_SEQ: case R4300i_COP1_FUNCT_C_NGL:
|
||||
case R4300i_COP1_FUNCT_C_LT: case R4300i_COP1_FUNCT_C_NGE:
|
||||
case R4300i_COP1_FUNCT_C_LE: case R4300i_COP1_FUNCT_C_NGT:
|
||||
m_RecompilerOps->COP1_D_CMP(); break;
|
||||
case R4300i_COP1_FUNCT_C_F:
|
||||
case R4300i_COP1_FUNCT_C_UN:
|
||||
case R4300i_COP1_FUNCT_C_EQ:
|
||||
case R4300i_COP1_FUNCT_C_UEQ:
|
||||
case R4300i_COP1_FUNCT_C_OLT:
|
||||
case R4300i_COP1_FUNCT_C_ULT:
|
||||
case R4300i_COP1_FUNCT_C_OLE:
|
||||
case R4300i_COP1_FUNCT_C_ULE:
|
||||
case R4300i_COP1_FUNCT_C_SF:
|
||||
case R4300i_COP1_FUNCT_C_NGLE:
|
||||
case R4300i_COP1_FUNCT_C_SEQ:
|
||||
case R4300i_COP1_FUNCT_C_NGL:
|
||||
case R4300i_COP1_FUNCT_C_LT:
|
||||
case R4300i_COP1_FUNCT_C_NGE:
|
||||
case R4300i_COP1_FUNCT_C_LE:
|
||||
case R4300i_COP1_FUNCT_C_NGT:
|
||||
m_RecompilerOps->COP1_D_CMP();
|
||||
break;
|
||||
default:
|
||||
m_RecompilerOps->UnknownOpcode(); break;
|
||||
m_RecompilerOps->UnknownOpcode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case R4300i_COP1_W:
|
||||
|
@ -547,7 +616,8 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test)
|
|||
case R4300i_COP1_FUNCT_CVT_S: m_RecompilerOps->COP1_W_CVT_S(); break;
|
||||
case R4300i_COP1_FUNCT_CVT_D: m_RecompilerOps->COP1_W_CVT_D(); break;
|
||||
default:
|
||||
m_RecompilerOps->UnknownOpcode(); break;
|
||||
m_RecompilerOps->UnknownOpcode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case R4300i_COP1_L:
|
||||
|
@ -556,11 +626,13 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test)
|
|||
case R4300i_COP1_FUNCT_CVT_S: m_RecompilerOps->COP1_L_CVT_S(); break;
|
||||
case R4300i_COP1_FUNCT_CVT_D: m_RecompilerOps->COP1_L_CVT_D(); break;
|
||||
default:
|
||||
m_RecompilerOps->UnknownOpcode(); break;
|
||||
m_RecompilerOps->UnknownOpcode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
m_RecompilerOps->UnknownOpcode(); break;
|
||||
m_RecompilerOps->UnknownOpcode();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case R4300i_BEQL: m_RecompilerOps->Compile_BranchLikely(RecompilerBranchCompare_BEQ, false); break;
|
||||
|
@ -596,7 +668,8 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test)
|
|||
case R4300i_SDC1: m_RecompilerOps->SDC1(); break;
|
||||
case R4300i_SD: m_RecompilerOps->SD(); break;
|
||||
default:
|
||||
m_RecompilerOps->UnknownOpcode(); break;
|
||||
m_RecompilerOps->UnknownOpcode();
|
||||
break;
|
||||
}
|
||||
|
||||
m_RecompilerOps->PostCompileOpcode();
|
||||
|
@ -829,13 +902,22 @@ CCodeSection * CCodeSection::ExistingSection(uint32_t Addr, uint32_t Test)
|
|||
{
|
||||
return this;
|
||||
}
|
||||
if (m_Test == Test) { return nullptr; }
|
||||
if (m_Test == Test)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
m_Test = Test;
|
||||
|
||||
CCodeSection * Section = m_JumpSection ? m_JumpSection->ExistingSection(Addr, Test) : nullptr;
|
||||
if (Section != nullptr) { return Section; }
|
||||
if (Section != nullptr)
|
||||
{
|
||||
return Section;
|
||||
}
|
||||
Section = m_ContinueSection ? m_ContinueSection->ExistingSection(Addr, Test) : nullptr;
|
||||
if (Section != nullptr) { return Section; }
|
||||
if (Section != nullptr)
|
||||
{
|
||||
return Section;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -847,7 +929,10 @@ bool CCodeSection::SectionAccessible(uint32_t SectionId, uint32_t Test)
|
|||
return true;
|
||||
}
|
||||
|
||||
if (m_Test == Test) { return false; }
|
||||
if (m_Test == Test)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_Test = Test;
|
||||
|
||||
if (m_ContinueSection && m_ContinueSection->SectionAccessible(SectionId, Test))
|
||||
|
@ -937,18 +1022,39 @@ void CCodeSection::UnlinkParent(CCodeSection * Parent, bool ContinueSection)
|
|||
|
||||
bool CCodeSection::IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled, uint32_t Test)
|
||||
{
|
||||
if (IgnoreIfCompiled && Parent->m_CompiledLocation != nullptr) { return true; }
|
||||
if (!m_InLoop) { return false; }
|
||||
if (!Parent->m_InLoop) { return false; }
|
||||
if (Parent->m_ParentSection.empty()) { return false; }
|
||||
if (this == Parent) { return true; }
|
||||
if (Parent->m_Test == Test) { return true; }
|
||||
if (IgnoreIfCompiled && Parent->m_CompiledLocation != nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!m_InLoop)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!Parent->m_InLoop)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (Parent->m_ParentSection.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (this == Parent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (Parent->m_Test == Test)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Parent->m_Test = Test;
|
||||
|
||||
for (SECTION_LIST::iterator iter = Parent->m_ParentSection.begin(); iter != Parent->m_ParentSection.end(); iter++)
|
||||
{
|
||||
CCodeSection * ParentSection = *iter;
|
||||
if (!IsAllParentLoops(ParentSection, IgnoreIfCompiled, Test)) { return false; }
|
||||
if (!IsAllParentLoops(ParentSection, IgnoreIfCompiled, Test))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -959,12 +1065,21 @@ bool CCodeSection::DisplaySectionInformation(uint32_t ID, uint32_t Test)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
if (m_Test == Test) { return false; }
|
||||
if (m_Test == Test)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_Test = Test;
|
||||
if (m_SectionID != ID)
|
||||
{
|
||||
if (m_ContinueSection != nullptr && m_ContinueSection->DisplaySectionInformation(ID, Test)) { return true; }
|
||||
if (m_JumpSection != nullptr && m_JumpSection->DisplaySectionInformation(ID, Test)) { return true; }
|
||||
if (m_ContinueSection != nullptr && m_ContinueSection->DisplaySectionInformation(ID, Test))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (m_JumpSection != nullptr && m_JumpSection->DisplaySectionInformation(ID, Test))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
DisplaySectionInformation();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "stdafx.h"
|
||||
#include <Project64-core\N64System\Recompiler\ExitInfo.h>
|
||||
|
||||
#include <Project64-core\N64System\Recompiler\CodeBlock.h>
|
||||
#include <Project64-core\N64System\Recompiler\ExitInfo.h>
|
||||
|
||||
CExitInfo::CExitInfo(CCodeBlock & CodeBlock) :
|
||||
ID(0),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <Project64-core/N64System/Recompiler/RegInfo.h>
|
||||
#include <Project64-core/N64System/N64Types.h>
|
||||
#include <Project64-core/N64System/Recompiler/RegInfo.h>
|
||||
|
||||
class CCodeBlock;
|
||||
|
||||
|
|
|
@ -8,18 +8,48 @@ public:
|
|||
|
||||
typedef void (*Func)();
|
||||
|
||||
const uint32_t EnterPC () const { return m_EnterPC; }
|
||||
const uint32_t MinPC () const { return m_MinPC; }
|
||||
const uint32_t MaxPC () const { return m_MaxPC; }
|
||||
const Func Function () const { return m_Function; }
|
||||
const uint8_t *FunctionEnd() const { return m_FunctionEnd; }
|
||||
const MD5Digest& Hash () const { return m_Hash; }
|
||||
const uint32_t EnterPC() const
|
||||
{
|
||||
return m_EnterPC;
|
||||
}
|
||||
const uint32_t MinPC() const
|
||||
{
|
||||
return m_MinPC;
|
||||
}
|
||||
const uint32_t MaxPC() const
|
||||
{
|
||||
return m_MaxPC;
|
||||
}
|
||||
const Func Function() const
|
||||
{
|
||||
return m_Function;
|
||||
}
|
||||
const uint8_t * FunctionEnd() const
|
||||
{
|
||||
return m_FunctionEnd;
|
||||
}
|
||||
const MD5Digest & Hash() const
|
||||
{
|
||||
return m_Hash;
|
||||
}
|
||||
|
||||
CCompiledFunc* Next () const { return m_Next; }
|
||||
void SetNext(CCompiledFunc* Next) { m_Next = Next; }
|
||||
CCompiledFunc * Next() const
|
||||
{
|
||||
return m_Next;
|
||||
}
|
||||
void SetNext(CCompiledFunc * Next)
|
||||
{
|
||||
m_Next = Next;
|
||||
}
|
||||
|
||||
uint64_t MemContents(int32_t i) { return m_MemContents[i]; }
|
||||
uint64_t* MemLocation(int32_t i) { return m_MemLocation[i]; }
|
||||
uint64_t MemContents(int32_t i)
|
||||
{
|
||||
return m_MemContents[i];
|
||||
}
|
||||
uint64_t * MemLocation(int32_t i)
|
||||
{
|
||||
return m_MemLocation[i];
|
||||
}
|
||||
|
||||
private:
|
||||
CCompiledFunc(void);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/Recompiler/FunctionMap.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
|
||||
CFunctionMap::CFunctionMap() :
|
||||
m_JumpTable(nullptr),
|
||||
|
|
|
@ -16,8 +16,14 @@ protected:
|
|||
void Reset(bool bAllocate);
|
||||
|
||||
public:
|
||||
PCCompiledFunc_TABLE * FunctionTable() const { return m_FunctionTable; }
|
||||
PCCompiledFunc * JumpTable() const { return m_JumpTable; }
|
||||
PCCompiledFunc_TABLE * FunctionTable() const
|
||||
{
|
||||
return m_FunctionTable;
|
||||
}
|
||||
PCCompiledFunc * JumpTable() const
|
||||
{
|
||||
return m_JumpTable;
|
||||
}
|
||||
|
||||
private:
|
||||
void CleanBuffers();
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
#include <Project64-core\N64System\Recompiler\CodeBlock.h>
|
||||
#include "SectionInfo.h"
|
||||
|
||||
#include "JumpInfo.h"
|
||||
#include "SectionInfo.h"
|
||||
#include <Project64-core\N64System\Recompiler\CodeBlock.h>
|
||||
|
||||
CJumpInfo::CJumpInfo(CCodeBlock & CodeBlock) :
|
||||
RegSet(CodeBlock, CodeBlock.RecompilerOps()->Assembler())
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#include "stdafx.h"
|
||||
#include <string.h>
|
||||
#include "LoopAnalysis.h"
|
||||
|
||||
#include "LoopAnalysis.h"
|
||||
#include <string.h>
|
||||
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
|
||||
#include <Project64-core/N64System/N64Types.h>
|
||||
#include <Project64-core/N64System/Recompiler/CodeBlock.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define CHECKED_BUILD 1
|
||||
|
@ -69,7 +70,11 @@ bool LoopAnalysis::SetupEnterSection(CCodeSection * Section, bool & bChanged, bo
|
|||
{
|
||||
bChanged = false;
|
||||
bSkipedSection = false;
|
||||
if (Section->m_ParentSection.empty()) { g_Notify->BreakPoint(__FILE__, __LINE__); return true; }
|
||||
if (Section->m_ParentSection.empty())
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
return true;
|
||||
}
|
||||
|
||||
m_CodeBlock.Log("%s: Block EnterPC: %X Section ID %d Test: %X Section Test: %X CompiledLocation: %X", __FUNCTION__, m_CodeBlock.VAddrEnter(), Section->m_SectionID, m_Test, Section->m_Test, Section->m_CompiledLocation);
|
||||
|
||||
|
@ -93,12 +98,14 @@ bool LoopAnalysis::SetupEnterSection(CCodeSection * Section, bool & bChanged, bo
|
|||
CRegInfo * JumpRegInfo[] =
|
||||
{
|
||||
Continue_itr == m_ContinueRegisters.end() ? &Parent->m_Cont.RegSet : Continue_itr->second,
|
||||
Jump_itr == m_JumpRegisters.end() ? &Parent->m_Jump.RegSet : Jump_itr->second
|
||||
};
|
||||
Jump_itr == m_JumpRegisters.end() ? &Parent->m_Jump.RegSet : Jump_itr->second};
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (TargetSection[i] != Section) { continue; }
|
||||
if (TargetSection[i] != Section)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (bFirstParent)
|
||||
{
|
||||
bFirstParent = false;
|
||||
|
@ -138,19 +145,31 @@ bool LoopAnalysis::SetupEnterSection(CCodeSection * Section, bool & bChanged, bo
|
|||
|
||||
bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
|
||||
{
|
||||
if (Section == nullptr) { return true; }
|
||||
if (!Section->m_InLoop) { return true; }
|
||||
if (Section == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!Section->m_InLoop)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
m_CodeBlock.Log("%s: Section %d Block PC: 0x%X", __FUNCTION__, Section->m_SectionID, m_CodeBlock.VAddrEnter());
|
||||
|
||||
bool bChanged = false, bSkipedSection = false;
|
||||
if (Section == m_EnterSection && Section->m_Test == m_Test)
|
||||
{
|
||||
if (!SetupEnterSection(Section, bChanged, bSkipedSection)) { return false; }
|
||||
if (!SetupEnterSection(Section, bChanged, bSkipedSection))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!SetupEnterSection(Section, bChanged, bSkipedSection)) { return false; }
|
||||
if (!SetupEnterSection(Section, bChanged, bSkipedSection))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Section->m_Test == m_Test && !bChanged)
|
||||
{
|
||||
|
@ -226,8 +245,12 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
|
|||
case R4300i_SPECIAL_DSLL32: SPECIAL_DSLL32(); break;
|
||||
case R4300i_SPECIAL_DSRL32: SPECIAL_DSRL32(); break;
|
||||
case R4300i_SPECIAL_DSRA32: SPECIAL_DSRA32(); break;
|
||||
case R4300i_SPECIAL_TEQ: case R4300i_SPECIAL_TNE: case R4300i_SPECIAL_TGE:
|
||||
case R4300i_SPECIAL_TGEU: case R4300i_SPECIAL_TLT: case R4300i_SPECIAL_TLTU:
|
||||
case R4300i_SPECIAL_TEQ:
|
||||
case R4300i_SPECIAL_TNE:
|
||||
case R4300i_SPECIAL_TGE:
|
||||
case R4300i_SPECIAL_TGEU:
|
||||
case R4300i_SPECIAL_TLT:
|
||||
case R4300i_SPECIAL_TLTU:
|
||||
break;
|
||||
default:
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
|
@ -238,8 +261,12 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
|
|||
case R4300i_REGIMM:
|
||||
switch (m_Command.rt)
|
||||
{
|
||||
case R4300i_REGIMM_TEQI: case R4300i_REGIMM_TNEI: case R4300i_REGIMM_TGEI:
|
||||
case R4300i_REGIMM_TGEIU: case R4300i_REGIMM_TLTI: case R4300i_REGIMM_TLTIU:
|
||||
case R4300i_REGIMM_TEQI:
|
||||
case R4300i_REGIMM_TNEI:
|
||||
case R4300i_REGIMM_TGEI:
|
||||
case R4300i_REGIMM_TGEIU:
|
||||
case R4300i_REGIMM_TLTI:
|
||||
case R4300i_REGIMM_TLTIU:
|
||||
break;
|
||||
case R4300i_REGIMM_BLTZ:
|
||||
case R4300i_REGIMM_BGEZ:
|
||||
|
@ -400,7 +427,10 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
|
|||
break;
|
||||
case R4300i_ADDI:
|
||||
case R4300i_ADDIU:
|
||||
if (m_Command.rt == 0) { break; }
|
||||
if (m_Command.rt == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
/*if (m_Command.rs == 0) {
|
||||
m_Reg.GetMipsRegLo(m_Command.rt) = (int16_t)m_Command.immediate;
|
||||
m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_CONST_32_SIGN);
|
||||
|
@ -410,11 +440,17 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
|
|||
break;
|
||||
case R4300i_SLTI:
|
||||
case R4300i_SLTIU:
|
||||
if (m_Command.rt == 0) { break; }
|
||||
if (m_Command.rt == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED);
|
||||
break;
|
||||
case R4300i_LUI:
|
||||
if (m_Command.rt == 0) { break; }
|
||||
if (m_Command.rt == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!m_Reg.IsModified(m_Command.rt))
|
||||
{
|
||||
m_Reg.SetMipsRegLo(m_Command.rt, ((int16_t)m_Command.offset << 16));
|
||||
|
@ -422,25 +458,36 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
|
|||
}
|
||||
break;
|
||||
case R4300i_ANDI:
|
||||
if (m_Command.rt == 0) { break; }
|
||||
if (m_Command.rt == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED);
|
||||
break;
|
||||
case R4300i_ORI:
|
||||
if (m_Command.rt == 0) { break; }
|
||||
if (m_Command.rt == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (m_Command.rs == m_Command.rt)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
if (m_Reg.IsConst(m_Command.rs)) {
|
||||
if (m_Reg.IsConst(m_Command.rs))
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_CONST_32_SIGN);
|
||||
m_Reg.SetMipsRegLo(m_Command.rt, m_Reg.GetMipsRegLo(m_Command.rs) | m_Command.immediate);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
break;
|
||||
case R4300i_XORI:
|
||||
if (m_Command.rt == 0) { break; }
|
||||
if (m_Command.rt == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (m_Command.rs == m_Command.rt)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -459,7 +506,10 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
|
|||
switch (m_Command.rs)
|
||||
{
|
||||
case R4300i_COP0_MF:
|
||||
if (m_Command.rt == 0) { break; }
|
||||
if (m_Command.rt == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED);
|
||||
break;
|
||||
case R4300i_COP0_MT: break;
|
||||
|
@ -493,7 +543,10 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
|
|||
case R4300i_COP1_CF:
|
||||
case R4300i_COP1_MF:
|
||||
case R4300i_COP1_DMF:
|
||||
if (m_Command.rt == 0) { break; }
|
||||
if (m_Command.rt == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED);
|
||||
break;
|
||||
case R4300i_COP1_BC:
|
||||
|
@ -584,7 +637,10 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
|
|||
break;
|
||||
case R4300i_DADDI:
|
||||
case R4300i_DADDIU:
|
||||
if (m_Command.rt == 0) { break; }
|
||||
if (m_Command.rt == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (m_Command.rs == m_Command.rt)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -620,7 +676,10 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
|
|||
case R4300i_LHU:
|
||||
case R4300i_LWR:
|
||||
case R4300i_SC:
|
||||
if (m_Command.rt == 0) { break; }
|
||||
if (m_Command.rt == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED);
|
||||
break;
|
||||
case R4300i_SB: break;
|
||||
|
@ -635,7 +694,10 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
|
|||
case R4300i_SWC1: break;
|
||||
case R4300i_LDC1: break;
|
||||
case R4300i_LD:
|
||||
if (m_Command.rt == 0) { break; }
|
||||
if (m_Command.rt == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED);
|
||||
break;
|
||||
case R4300i_SDC1: break;
|
||||
|
@ -643,11 +705,26 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
|
|||
default:
|
||||
m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
|
||||
m_PC -= 4;
|
||||
if (m_Command.Value == 0x7C1C97C0) { break; }
|
||||
if (m_Command.Value == 0x7FFFFFFF) { break; }
|
||||
if (m_Command.Value == 0xF1F3F5F7) { break; }
|
||||
if (m_Command.Value == 0xC1200000) { break; }
|
||||
if (m_Command.Value == 0x4C5A5353) { break; }
|
||||
if (m_Command.Value == 0x7C1C97C0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (m_Command.Value == 0x7FFFFFFF)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (m_Command.Value == 0xF1F3F5F7)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (m_Command.Value == 0xC1200000)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (m_Command.Value == 0x4C5A5353)
|
||||
{
|
||||
break;
|
||||
}
|
||||
g_Notify->DisplayError(stdstr_f("Unhandled R4300i opcode in FillSectionInfo 1\n%s\n%X", R4300iInstruction(m_PC, m_Command.Value).NameAndParam().c_str(), m_Command.Value).c_str());
|
||||
}
|
||||
|
||||
|
@ -710,8 +787,14 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
|
|||
}
|
||||
} while (m_PipelineStage != PIPELINE_STAGE_END_BLOCK);
|
||||
|
||||
if (!CheckLoopRegisterUsage(Section->m_ContinueSection)) { return false; }
|
||||
if (!CheckLoopRegisterUsage(Section->m_JumpSection)) { return false; }
|
||||
if (!CheckLoopRegisterUsage(Section->m_ContinueSection))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!CheckLoopRegisterUsage(Section->m_JumpSection))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -768,25 +851,37 @@ void LoopAnalysis::SetContinueRegSet(CCodeSection * Section, const CRegInfo &Reg
|
|||
|
||||
void LoopAnalysis::SPECIAL_SLL()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
|
||||
void LoopAnalysis::SPECIAL_SRL()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
|
||||
void LoopAnalysis::SPECIAL_SRA()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
|
||||
void LoopAnalysis::SPECIAL_SLLV()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -804,7 +899,10 @@ void LoopAnalysis::SPECIAL_SLLV()
|
|||
|
||||
void LoopAnalysis::SPECIAL_SRLV()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -822,7 +920,10 @@ void LoopAnalysis::SPECIAL_SRLV()
|
|||
|
||||
void LoopAnalysis::SPECIAL_SRAV()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -910,7 +1011,10 @@ void LoopAnalysis::SPECIAL_MTLO()
|
|||
|
||||
void LoopAnalysis::SPECIAL_DSLLV()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -928,7 +1032,10 @@ void LoopAnalysis::SPECIAL_DSLLV()
|
|||
|
||||
void LoopAnalysis::SPECIAL_DSRLV()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -946,12 +1053,16 @@ void LoopAnalysis::SPECIAL_DSRLV()
|
|||
|
||||
void LoopAnalysis::SPECIAL_DSRAV()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) {
|
||||
if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs))
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64);
|
||||
m_Reg.SetMipsReg(m_Command.rd, m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg_S(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) >> (m_Reg.GetMipsRegLo(m_Command.rs) & 0x3F));
|
||||
}
|
||||
|
@ -963,67 +1074,100 @@ void LoopAnalysis::SPECIAL_DSRAV()
|
|||
|
||||
void LoopAnalysis::SPECIAL_ADD()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
|
||||
void LoopAnalysis::SPECIAL_ADDU()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
|
||||
void LoopAnalysis::SPECIAL_SUB()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
|
||||
void LoopAnalysis::SPECIAL_SUBU()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
|
||||
void LoopAnalysis::SPECIAL_AND()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
|
||||
void LoopAnalysis::SPECIAL_OR()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
|
||||
void LoopAnalysis::SPECIAL_XOR()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
|
||||
void LoopAnalysis::SPECIAL_NOR()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
|
||||
void LoopAnalysis::SPECIAL_SLT()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
|
||||
void LoopAnalysis::SPECIAL_SLTU()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
}
|
||||
|
||||
void LoopAnalysis::SPECIAL_DADD()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -1032,8 +1176,7 @@ void LoopAnalysis::SPECIAL_DADD()
|
|||
{
|
||||
m_Reg.SetMipsReg(m_Command.rd,
|
||||
(m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) +
|
||||
(m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt))
|
||||
);
|
||||
(m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt)));
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64);
|
||||
}
|
||||
else
|
||||
|
@ -1044,7 +1187,10 @@ void LoopAnalysis::SPECIAL_DADD()
|
|||
|
||||
void LoopAnalysis::SPECIAL_DADDU()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -1053,8 +1199,7 @@ void LoopAnalysis::SPECIAL_DADDU()
|
|||
{
|
||||
m_Reg.SetMipsReg(m_Command.rd,
|
||||
(m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) +
|
||||
(m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt))
|
||||
);
|
||||
(m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt)));
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64);
|
||||
}
|
||||
else
|
||||
|
@ -1065,7 +1210,10 @@ void LoopAnalysis::SPECIAL_DADDU()
|
|||
|
||||
void LoopAnalysis::SPECIAL_DSUB()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -1074,8 +1222,7 @@ void LoopAnalysis::SPECIAL_DSUB()
|
|||
{
|
||||
m_Reg.SetMipsReg(m_Command.rd,
|
||||
(m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) -
|
||||
(m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt))
|
||||
);
|
||||
(m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt)));
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64);
|
||||
}
|
||||
else
|
||||
|
@ -1086,7 +1233,10 @@ void LoopAnalysis::SPECIAL_DSUB()
|
|||
|
||||
void LoopAnalysis::SPECIAL_DSUBU()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -1095,8 +1245,7 @@ void LoopAnalysis::SPECIAL_DSUBU()
|
|||
{
|
||||
m_Reg.SetMipsReg(m_Command.rd,
|
||||
(m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) -
|
||||
(m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt))
|
||||
);
|
||||
(m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt)));
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64);
|
||||
}
|
||||
else
|
||||
|
@ -1107,7 +1256,10 @@ void LoopAnalysis::SPECIAL_DSUBU()
|
|||
|
||||
void LoopAnalysis::SPECIAL_DSLL()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -1125,7 +1277,10 @@ void LoopAnalysis::SPECIAL_DSLL()
|
|||
|
||||
void LoopAnalysis::SPECIAL_DSRL()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -1143,7 +1298,10 @@ void LoopAnalysis::SPECIAL_DSRL()
|
|||
|
||||
void LoopAnalysis::SPECIAL_DSRA()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -1161,7 +1319,10 @@ void LoopAnalysis::SPECIAL_DSRA()
|
|||
|
||||
void LoopAnalysis::SPECIAL_DSLL32()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -1179,7 +1340,10 @@ void LoopAnalysis::SPECIAL_DSLL32()
|
|||
|
||||
void LoopAnalysis::SPECIAL_DSRL32()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
@ -1197,7 +1361,10 @@ void LoopAnalysis::SPECIAL_DSRL32()
|
|||
|
||||
void LoopAnalysis::SPECIAL_DSRA32()
|
||||
{
|
||||
if (m_Command.rd == 0) { return; }
|
||||
if (m_Command.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_Command.rt == m_Command.rd)
|
||||
{
|
||||
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include <Project64-core/N64System/Recompiler/RegInfo.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iOpcode.h>
|
||||
#include <Project64-core/N64System/N64Types.h>
|
||||
#include <Project64-core/N64System/Recompiler/RegInfo.h>
|
||||
#include <map>
|
||||
|
||||
class CCodeSection;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include <Project64-core/ExceptionHandler.h>
|
||||
#include <Project64-core/N64System/Interpreter/InterpreterCPU.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/Recompiler/Recompiler.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/Interpreter/InterpreterCPU.h>
|
||||
#include <Project64-core/ExceptionHandler.h>
|
||||
|
||||
CRecompiler::CRecompiler(CMipsMemoryVM & MMU, CRegisters & Registers, bool & EndEmulation) :
|
||||
m_MMU(MMU),
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/Profiling.h>
|
||||
#include <Project64-core/N64System/Recompiler/FunctionMap.h>
|
||||
#include <Project64-core/N64System/Recompiler/RecompilerMemory.h>
|
||||
#include <Project64-core/N64System/Profiling.h>
|
||||
#include <Project64-core/Settings/RecompilerSettings.h>
|
||||
#include <Project64-core/Settings/DebugSettings.h>
|
||||
#include <Project64-core/Settings/RecompilerSettings.h>
|
||||
|
||||
class CLog;
|
||||
|
||||
|
@ -18,7 +18,6 @@ class CRecompiler :
|
|||
private CSystemRegisters
|
||||
{
|
||||
public:
|
||||
|
||||
enum REMOVE_REASON
|
||||
{
|
||||
Remove_InitialCode,
|
||||
|
@ -51,7 +50,10 @@ public:
|
|||
void ResetFunctionTimes();
|
||||
void DumpFunctionTimes();
|
||||
|
||||
uint32_t& MemoryStackPos() { return m_MemoryStack; }
|
||||
uint32_t & MemoryStackPos()
|
||||
{
|
||||
return m_MemoryStack;
|
||||
}
|
||||
|
||||
private:
|
||||
CRecompiler();
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include <Common/MemoryManagement.h>
|
||||
#include <Project64-core/N64System/Recompiler/Recompiler.h>
|
||||
#include <Project64-core/N64System/Recompiler/RecompilerMemory.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/Recompiler/Recompiler.h>
|
||||
#include <Common/MemoryManagement.h>
|
||||
|
||||
CRecompMemory::CRecompMemory() :
|
||||
m_RecompCode(nullptr),
|
||||
|
|
|
@ -13,7 +13,10 @@ protected:
|
|||
void ShowMemUsed();
|
||||
|
||||
public:
|
||||
uint8_t** RecompPos() { return &m_RecompPos; }
|
||||
uint8_t ** RecompPos()
|
||||
{
|
||||
return &m_RecompPos;
|
||||
}
|
||||
|
||||
private:
|
||||
CRecompMemory(const CRecompMemory &);
|
||||
|
@ -23,7 +26,16 @@ private:
|
|||
uint32_t m_RecompSize;
|
||||
uint8_t * m_RecompPos;
|
||||
|
||||
enum { MaxCompileBufferSize = 0x03C00000 };
|
||||
enum { InitialCompileBufferSize = 0x00500000 };
|
||||
enum { IncreaseCompileBufferSize = 0x00100000 };
|
||||
enum
|
||||
{
|
||||
MaxCompileBufferSize = 0x03C00000
|
||||
};
|
||||
enum
|
||||
{
|
||||
InitialCompileBufferSize = 0x00500000
|
||||
};
|
||||
enum
|
||||
{
|
||||
IncreaseCompileBufferSize = 0x00100000
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include <Project64-core/N64System/Recompiler/RegBase.h>
|
||||
|
||||
CRegBase::CRegBase() :
|
||||
|
@ -31,9 +32,18 @@ bool CRegBase::operator==(const CRegBase& right) const
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (m_CycleCount != right.m_CycleCount) { return false; }
|
||||
if (m_Fpu_Used != right.m_Fpu_Used) { return false; }
|
||||
if (GetRoundingModel() != right.GetRoundingModel()) { return false; }
|
||||
if (m_CycleCount != right.m_CycleCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_Fpu_Used != right.m_Fpu_Used)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (GetRoundingModel() != right.GetRoundingModel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,45 +35,132 @@ public:
|
|||
RoundUp = 4,
|
||||
};
|
||||
|
||||
inline void SetMipsRegState(int32_t GetMipsReg, REG_STATE State) { m_MIPS_RegState[GetMipsReg] = State; }
|
||||
inline REG_STATE GetMipsRegState(int32_t Reg) const { return m_MIPS_RegState[Reg]; }
|
||||
inline void SetMipsRegState(int32_t GetMipsReg, REG_STATE State)
|
||||
{
|
||||
m_MIPS_RegState[GetMipsReg] = State;
|
||||
}
|
||||
inline REG_STATE GetMipsRegState(int32_t Reg) const
|
||||
{
|
||||
return m_MIPS_RegState[Reg];
|
||||
}
|
||||
|
||||
inline bool IsKnown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); }
|
||||
inline bool IsUnknown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) == 0); }
|
||||
inline bool IsModified(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_MODIFIED) != 0); }
|
||||
inline bool IsKnown(int32_t Reg) const
|
||||
{
|
||||
return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0);
|
||||
}
|
||||
inline bool IsUnknown(int32_t Reg) const
|
||||
{
|
||||
return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) == 0);
|
||||
}
|
||||
inline bool IsModified(int32_t Reg) const
|
||||
{
|
||||
return ((GetMipsRegState(Reg) & STATE_MODIFIED) != 0);
|
||||
}
|
||||
|
||||
inline bool IsMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); }
|
||||
inline bool IsConst(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == STATE_KNOWN_VALUE); }
|
||||
inline bool IsMapped(int32_t Reg) const
|
||||
{
|
||||
return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED));
|
||||
}
|
||||
inline bool IsConst(int32_t Reg) const
|
||||
{
|
||||
return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == STATE_KNOWN_VALUE);
|
||||
}
|
||||
|
||||
inline bool IsSigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == (STATE_KNOWN_VALUE | STATE_SIGN)); }
|
||||
inline bool IsUnsigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == STATE_KNOWN_VALUE); }
|
||||
inline bool IsSigned(int32_t Reg) const
|
||||
{
|
||||
return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == (STATE_KNOWN_VALUE | STATE_SIGN));
|
||||
}
|
||||
inline bool IsUnsigned(int32_t Reg) const
|
||||
{
|
||||
return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == STATE_KNOWN_VALUE);
|
||||
}
|
||||
|
||||
inline bool Is32Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == (STATE_KNOWN_VALUE | STATE_32BIT)); }
|
||||
inline bool Is64Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == STATE_KNOWN_VALUE); }
|
||||
inline bool Is32Bit(int32_t Reg) const
|
||||
{
|
||||
return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == (STATE_KNOWN_VALUE | STATE_32BIT));
|
||||
}
|
||||
inline bool Is64Bit(int32_t Reg) const
|
||||
{
|
||||
return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == STATE_KNOWN_VALUE);
|
||||
}
|
||||
|
||||
inline bool Is32BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)); }
|
||||
inline bool Is64BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); }
|
||||
inline bool Is32BitMapped(int32_t Reg) const
|
||||
{
|
||||
return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED));
|
||||
}
|
||||
inline bool Is64BitMapped(int32_t Reg) const
|
||||
{
|
||||
return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED));
|
||||
}
|
||||
|
||||
inline uint64_t GetMipsReg(int32_t Reg) const { return m_MIPS_RegVal[Reg].UDW; }
|
||||
inline int64_t GetMipsReg_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].DW; }
|
||||
inline uint32_t GetMipsRegLo(int32_t Reg) const { return m_MIPS_RegVal[Reg].UW[0]; }
|
||||
inline int32_t GetMipsRegLo_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].W[0]; }
|
||||
inline uint32_t GetMipsRegHi(int32_t Reg) const { return m_MIPS_RegVal[Reg].UW[1]; }
|
||||
inline int32_t GetMipsRegHi_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].W[1]; }
|
||||
inline uint64_t GetMipsReg(int32_t Reg) const
|
||||
{
|
||||
return m_MIPS_RegVal[Reg].UDW;
|
||||
}
|
||||
inline int64_t GetMipsReg_S(int32_t Reg) const
|
||||
{
|
||||
return m_MIPS_RegVal[Reg].DW;
|
||||
}
|
||||
inline uint32_t GetMipsRegLo(int32_t Reg) const
|
||||
{
|
||||
return m_MIPS_RegVal[Reg].UW[0];
|
||||
}
|
||||
inline int32_t GetMipsRegLo_S(int32_t Reg) const
|
||||
{
|
||||
return m_MIPS_RegVal[Reg].W[0];
|
||||
}
|
||||
inline uint32_t GetMipsRegHi(int32_t Reg) const
|
||||
{
|
||||
return m_MIPS_RegVal[Reg].UW[1];
|
||||
}
|
||||
inline int32_t GetMipsRegHi_S(int32_t Reg) const
|
||||
{
|
||||
return m_MIPS_RegVal[Reg].W[1];
|
||||
}
|
||||
|
||||
inline void SetMipsRegLo(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[0] = Value; }
|
||||
inline void SetMipsRegHi(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[1] = Value; }
|
||||
inline void SetMipsReg(int32_t Reg, uint64_t Value) { m_MIPS_RegVal[Reg].UDW = Value; }
|
||||
inline void SetMipsReg_S(int32_t Reg, int64_t Value) { m_MIPS_RegVal[Reg].DW = Value; }
|
||||
inline void SetMipsRegLo(int32_t Reg, uint32_t Value)
|
||||
{
|
||||
m_MIPS_RegVal[Reg].UW[0] = Value;
|
||||
}
|
||||
inline void SetMipsRegHi(int32_t Reg, uint32_t Value)
|
||||
{
|
||||
m_MIPS_RegVal[Reg].UW[1] = Value;
|
||||
}
|
||||
inline void SetMipsReg(int32_t Reg, uint64_t Value)
|
||||
{
|
||||
m_MIPS_RegVal[Reg].UDW = Value;
|
||||
}
|
||||
inline void SetMipsReg_S(int32_t Reg, int64_t Value)
|
||||
{
|
||||
m_MIPS_RegVal[Reg].DW = Value;
|
||||
}
|
||||
|
||||
inline void SetBlockCycleCount(uint32_t CyleCount) { m_CycleCount = CyleCount; }
|
||||
inline uint32_t GetBlockCycleCount() const { return m_CycleCount; }
|
||||
inline void SetBlockCycleCount(uint32_t CyleCount)
|
||||
{
|
||||
m_CycleCount = CyleCount;
|
||||
}
|
||||
inline uint32_t GetBlockCycleCount() const
|
||||
{
|
||||
return m_CycleCount;
|
||||
}
|
||||
|
||||
inline void SetFpuBeenUsed(bool FpuUsed) { m_Fpu_Used = FpuUsed; }
|
||||
inline bool GetFpuBeenUsed() const { return m_Fpu_Used; }
|
||||
inline void SetFpuBeenUsed(bool FpuUsed)
|
||||
{
|
||||
m_Fpu_Used = FpuUsed;
|
||||
}
|
||||
inline bool GetFpuBeenUsed() const
|
||||
{
|
||||
return m_Fpu_Used;
|
||||
}
|
||||
|
||||
inline FPU_ROUND GetRoundingModel() const { return m_RoundingModel; }
|
||||
inline void SetRoundingModel(FPU_ROUND RoundingModel) { m_RoundingModel = RoundingModel; }
|
||||
inline FPU_ROUND GetRoundingModel() const
|
||||
{
|
||||
return m_RoundingModel;
|
||||
}
|
||||
inline void SetRoundingModel(FPU_ROUND RoundingModel)
|
||||
{
|
||||
m_RoundingModel = RoundingModel;
|
||||
}
|
||||
|
||||
CRegBase & operator=(const CRegBase &);
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#pragma once
|
||||
#if defined(__amd64__) || defined(_M_X64)
|
||||
|
||||
#include <Project64-core/N64System/Recompiler/RegInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/ExitInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/x64-86/x64ops.h>
|
||||
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iOpcode.h>
|
||||
#include <Project64-core/N64System/Recompiler/ExitInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/RegInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/x64-86/x64ops.h>
|
||||
|
||||
class CMipsMemoryVM;
|
||||
class CCodeBlock;
|
||||
|
@ -220,7 +220,10 @@ public:
|
|||
void CompileExecuteBP(void);
|
||||
void CompileExecuteDelaySlotBP(void);
|
||||
|
||||
CX64Ops & Assembler() { return m_Assembler; }
|
||||
CX64Ops & Assembler()
|
||||
{
|
||||
return m_Assembler;
|
||||
}
|
||||
|
||||
private:
|
||||
CX64RecompilerOps(const CX64RecompilerOps &);
|
||||
|
|
|
@ -2,21 +2,21 @@
|
|||
|
||||
#if defined(__i386__) || defined(_M_IX86)
|
||||
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/Mips/Disk.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Interpreter/InterpreterOps.h>
|
||||
#include <Project64-core/N64System/Interpreter/InterpreterCPU.h>
|
||||
#include <Project64-core/N64System/Recompiler/Recompiler.h>
|
||||
#include <Project64-core/N64System/Recompiler/CodeSection.h>
|
||||
#include <Project64-core/N64System/Recompiler/SectionInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/LoopAnalysis.h>
|
||||
#include <Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/N64Rom.h>
|
||||
#include <Project64-core/ExceptionHandler.h>
|
||||
#include <Project64-core/Debugger.h>
|
||||
#include <Project64-core/ExceptionHandler.h>
|
||||
#include <Project64-core/N64System/Interpreter/InterpreterCPU.h>
|
||||
#include <Project64-core/N64System/Interpreter/InterpreterOps.h>
|
||||
#include <Project64-core/N64System/Mips/Disk.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
|
||||
#include <Project64-core/N64System/N64Rom.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/Recompiler/CodeSection.h>
|
||||
#include <Project64-core/N64System/Recompiler/LoopAnalysis.h>
|
||||
#include <Project64-core/N64System/Recompiler/Recompiler.h>
|
||||
#include <Project64-core/N64System/Recompiler/SectionInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <stdio.h>
|
||||
|
||||
uint32_t CX86RecompilerOps::m_TempValue32 = 0;
|
||||
|
@ -323,7 +323,10 @@ void CX86RecompilerOps::PreCompileOpcode(void)
|
|||
void CX86RecompilerOps::PostCompileOpcode(void)
|
||||
{
|
||||
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp());
|
||||
if (!g_System->bRegCaching()) { m_RegWorkingSet.WriteBackRegisters(); }
|
||||
if (!g_System->bRegCaching())
|
||||
{
|
||||
m_RegWorkingSet.WriteBackRegisters();
|
||||
}
|
||||
m_RegWorkingSet.UnMap_AllFPRs();
|
||||
|
||||
/*if (m_CompilePC >= 0x800933B4 && m_CompilePC <= 0x80093414 && (m_PipelineStage == PIPELINE_STAGE_NORMAL || m_PipelineStage == PIPELINE_STAGE_DO_DELAY_SLOT))
|
||||
|
@ -585,7 +588,10 @@ void CX86RecompilerOps::Compile_Branch(RecompilerBranchCompare CompareType, bool
|
|||
if (m_Section->m_Jump.LinkLocation != nullptr || m_Section->m_Jump.LinkLocation2 != nullptr)
|
||||
{
|
||||
m_Assembler.JmpLabel8("DoDelaySlot", 0);
|
||||
if (DelayLinkLocation != nullptr) { g_Notify->BreakPoint(__FILE__, __LINE__); }
|
||||
if (DelayLinkLocation != nullptr)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
DelayLinkLocation = (uint8_t *)(*g_RecompPos - 1);
|
||||
|
||||
m_CodeBlock.Log(" ");
|
||||
|
@ -596,7 +602,10 @@ void CX86RecompilerOps::Compile_Branch(RecompilerBranchCompare CompareType, bool
|
|||
if (m_Section->m_Cont.LinkLocation != nullptr || m_Section->m_Cont.LinkLocation2 != nullptr)
|
||||
{
|
||||
m_Assembler.JmpLabel8("DoDelaySlot", 0);
|
||||
if (DelayLinkLocation != nullptr) { g_Notify->BreakPoint(__FILE__, __LINE__); }
|
||||
if (DelayLinkLocation != nullptr)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
DelayLinkLocation = (uint8_t *)(*g_RecompPos - 1);
|
||||
|
||||
m_CodeBlock.Log(" ");
|
||||
|
@ -892,8 +901,7 @@ void CX86RecompilerOps::BNE_Compare()
|
|||
{
|
||||
m_Assembler.CompX86RegToX86Reg(
|
||||
Is32Bit(m_Opcode.rs) ? Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rs, true, false) : GetMipsRegMapHi(m_Opcode.rs),
|
||||
Is32Bit(m_Opcode.rt) ? Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false) : GetMipsRegMapHi(m_Opcode.rt)
|
||||
);
|
||||
Is32Bit(m_Opcode.rt) ? Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false) : GetMipsRegMapHi(m_Opcode.rt));
|
||||
|
||||
if (m_Section->m_Jump.FallThrough)
|
||||
{
|
||||
|
@ -1218,8 +1226,7 @@ void CX86RecompilerOps::BEQ_Compare()
|
|||
|
||||
m_Assembler.CompX86RegToX86Reg(
|
||||
Is32Bit(m_Opcode.rs) ? Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rs, true, false) : GetMipsRegMapHi(m_Opcode.rs),
|
||||
Is32Bit(m_Opcode.rt) ? Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false) : GetMipsRegMapHi(m_Opcode.rt)
|
||||
);
|
||||
Is32Bit(m_Opcode.rt) ? Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false) : GetMipsRegMapHi(m_Opcode.rt));
|
||||
if (m_Section->m_Cont.FallThrough)
|
||||
{
|
||||
m_Assembler.JneLabel8("Continue", 0);
|
||||
|
@ -1297,7 +1304,8 @@ void CX86RecompilerOps::BEQ_Compare()
|
|||
{
|
||||
m_Assembler.CompConstToX86reg(GetMipsRegMapHi(MappedReg), GetMipsRegHi(ConstReg));
|
||||
}
|
||||
if (m_Section->m_Cont.FallThrough) {
|
||||
if (m_Section->m_Cont.FallThrough)
|
||||
{
|
||||
m_Assembler.JneLabel8("Continue", 0);
|
||||
Jump = *g_RecompPos - 1;
|
||||
}
|
||||
|
@ -1769,7 +1777,8 @@ void CX86RecompilerOps::BLEZ_Compare()
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
uint8_t * Jump = nullptr;
|
||||
|
||||
if (!g_System->b32BitCore())
|
||||
|
@ -2136,7 +2145,7 @@ void CX86RecompilerOps::J()
|
|||
return;
|
||||
}
|
||||
|
||||
m_Section->m_Jump.TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2);;
|
||||
m_Section->m_Jump.TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2);
|
||||
m_Section->m_Jump.JumpPC = m_CompilePC;
|
||||
if (m_Section->m_JumpSection != nullptr)
|
||||
{
|
||||
|
@ -2317,8 +2326,8 @@ void CX86RecompilerOps::SLTIU()
|
|||
|
||||
if (IsConst(m_Opcode.rs))
|
||||
{
|
||||
uint32_t Result = Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) < ((unsigned)((int64_t)((int16_t)m_Opcode.immediate))) ? 1 : 0 :
|
||||
GetMipsRegLo(m_Opcode.rs) < ((unsigned)((int16_t)m_Opcode.immediate)) ? 1 : 0;
|
||||
uint32_t Result = Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) < ((unsigned)((int64_t)((int16_t)m_Opcode.immediate))) ? 1 : 0 : GetMipsRegLo(m_Opcode.rs) < ((unsigned)((int16_t)m_Opcode.immediate)) ? 1
|
||||
: 0;
|
||||
UnMap_GPR(m_Opcode.rt, false);
|
||||
m_RegWorkingSet.SetMipsRegState(m_Opcode.rt, CRegInfo::STATE_CONST_32_SIGN);
|
||||
m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, Result);
|
||||
|
@ -2387,9 +2396,7 @@ void CX86RecompilerOps::SLTI()
|
|||
|
||||
if (IsConst(m_Opcode.rs))
|
||||
{
|
||||
uint32_t Result = Is64Bit(m_Opcode.rs) ?
|
||||
((int64_t)GetMipsReg(m_Opcode.rs) < (int64_t)((int16_t)m_Opcode.immediate) ? 1 : 0) :
|
||||
(GetMipsRegLo_S(m_Opcode.rs) < (int16_t)m_Opcode.immediate ? 1 : 0);
|
||||
uint32_t Result = Is64Bit(m_Opcode.rs) ? ((int64_t)GetMipsReg(m_Opcode.rs) < (int64_t)((int16_t)m_Opcode.immediate) ? 1 : 0) : (GetMipsRegLo_S(m_Opcode.rs) < (int16_t)m_Opcode.immediate ? 1 : 0);
|
||||
|
||||
UnMap_GPR(m_Opcode.rt, false);
|
||||
m_RegWorkingSet.SetMipsRegState(m_Opcode.rt, CRegInfo::STATE_CONST_32_SIGN);
|
||||
|
@ -2604,7 +2611,10 @@ void CX86RecompilerOps::XORI()
|
|||
{
|
||||
Map_GPR_64bit(m_Opcode.rt, m_Opcode.rs);
|
||||
}
|
||||
if (m_Opcode.immediate != 0) { m_Assembler.XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), m_Opcode.immediate); }
|
||||
if (m_Opcode.immediate != 0)
|
||||
{
|
||||
m_Assembler.XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), m_Opcode.immediate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3200,8 +3210,8 @@ void CX86RecompilerOps::LW_KnownAddress(CX86Ops::x86Reg Reg, uint32_t VAddr)
|
|||
m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler)[0][0], "VideoInterfaceHandler::Read32", 16);
|
||||
m_RegWorkingSet.AfterCallDirect();
|
||||
m_Assembler.MoveVariableToX86reg(&m_TempValue32, "m_TempValue32", Reg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x04500000:
|
||||
{
|
||||
UpdateCounters(m_RegWorkingSet, false, true, false);
|
||||
|
@ -3212,8 +3222,8 @@ void CX86RecompilerOps::LW_KnownAddress(CX86Ops::x86Reg Reg, uint32_t VAddr)
|
|||
m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler)[0][0], "AudioInterfaceHandler::Read32", 16);
|
||||
m_RegWorkingSet.AfterCallDirect();
|
||||
m_Assembler.MoveVariableToX86reg(&m_TempValue32, "m_TempValue32", Reg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x04600000:
|
||||
switch (PAddr)
|
||||
{
|
||||
|
@ -4440,7 +4450,10 @@ void CX86RecompilerOps::SPECIAL_SYSCALL()
|
|||
|
||||
void CX86RecompilerOps::SPECIAL_MFLO()
|
||||
{
|
||||
if (m_Opcode.rd == 0) { return; }
|
||||
if (m_Opcode.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Map_GPR_64bit(m_Opcode.rd, -1);
|
||||
m_Assembler.MoveVariableToX86reg(&_RegLO->UW[0], "_RegLO->UW[0]", GetMipsRegMapLo(m_Opcode.rd));
|
||||
|
@ -4491,7 +4504,10 @@ void CX86RecompilerOps::SPECIAL_MTLO()
|
|||
|
||||
void CX86RecompilerOps::SPECIAL_MFHI()
|
||||
{
|
||||
if (m_Opcode.rd == 0) { return; }
|
||||
if (m_Opcode.rd == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Map_GPR_64bit(m_Opcode.rd, -1);
|
||||
m_Assembler.MoveVariableToX86reg(&_RegHI->UW[0], "_RegHI->UW[0]", GetMipsRegMapLo(m_Opcode.rd));
|
||||
|
@ -5337,8 +5353,7 @@ void CX86RecompilerOps::SPECIAL_AND()
|
|||
{
|
||||
m_RegWorkingSet.SetMipsReg(m_Opcode.rd,
|
||||
(Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)) &
|
||||
(Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs))
|
||||
);
|
||||
(Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs)));
|
||||
|
||||
if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1)
|
||||
{
|
||||
|
@ -5547,8 +5562,7 @@ void CX86RecompilerOps::SPECIAL_OR()
|
|||
{
|
||||
m_RegWorkingSet.SetMipsReg(m_Opcode.rd,
|
||||
(Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)) |
|
||||
(Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs))
|
||||
);
|
||||
(Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs)));
|
||||
if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1)
|
||||
{
|
||||
m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN);
|
||||
|
@ -5626,7 +5640,10 @@ void CX86RecompilerOps::SPECIAL_OR()
|
|||
{
|
||||
int Value = GetMipsRegLo(ConstReg);
|
||||
Map_GPR_32bit(m_Opcode.rd, true, MappedReg);
|
||||
if (Value != 0) { m_Assembler.OrConstToX86Reg(Value, GetMipsRegMapLo(m_Opcode.rd)); }
|
||||
if (Value != 0)
|
||||
{
|
||||
m_Assembler.OrConstToX86Reg(Value, GetMipsRegMapLo(m_Opcode.rd));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5720,7 +5737,10 @@ void CX86RecompilerOps::SPECIAL_XOR()
|
|||
|
||||
if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs))
|
||||
{
|
||||
if (HaveDebugger()) { g_Notify->DisplayError("XOR 1"); }
|
||||
if (HaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError("XOR 1");
|
||||
}
|
||||
CX86RecompilerOps::UnknownOpcode();
|
||||
}
|
||||
else
|
||||
|
@ -5774,8 +5794,14 @@ void CX86RecompilerOps::SPECIAL_XOR()
|
|||
ConstHi = Is32Bit(ConstReg) ? (uint32_t)(GetMipsRegLo_S(ConstReg) >> 31) : GetMipsRegHi(ConstReg);
|
||||
ConstLo = GetMipsRegLo(ConstReg);
|
||||
Map_GPR_64bit(m_Opcode.rd, MappedReg);
|
||||
if (ConstHi != 0) { m_Assembler.XorConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd), ConstHi); }
|
||||
if (ConstLo != 0) { m_Assembler.XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), ConstLo); }
|
||||
if (ConstHi != 0)
|
||||
{
|
||||
m_Assembler.XorConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd), ConstHi);
|
||||
}
|
||||
if (ConstLo != 0)
|
||||
{
|
||||
m_Assembler.XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), ConstLo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5788,7 +5814,10 @@ void CX86RecompilerOps::SPECIAL_XOR()
|
|||
{
|
||||
Map_GPR_32bit(m_Opcode.rd, IsSigned(MappedReg), MappedReg);
|
||||
}
|
||||
if (Value != 0) { m_Assembler.XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), Value); }
|
||||
if (Value != 0)
|
||||
{
|
||||
m_Assembler.XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5869,8 +5898,7 @@ void CX86RecompilerOps::SPECIAL_NOR()
|
|||
{
|
||||
m_RegWorkingSet.SetMipsReg(m_Opcode.rd,
|
||||
~((Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)) |
|
||||
(Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs)))
|
||||
);
|
||||
(Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs))));
|
||||
if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1)
|
||||
{
|
||||
m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN);
|
||||
|
@ -5939,7 +5967,8 @@ void CX86RecompilerOps::SPECIAL_NOR()
|
|||
m_Assembler.OrConstToX86Reg((uint32_t)(Value >> 32), GetMipsRegMapHi(m_Opcode.rd));
|
||||
}
|
||||
uint32_t dwValue = (uint32_t)(Value & 0xFFFFFFFF);
|
||||
if (dwValue != 0) {
|
||||
if (dwValue != 0)
|
||||
{
|
||||
m_Assembler.OrConstToX86Reg(dwValue, GetMipsRegMapLo(m_Opcode.rd));
|
||||
}
|
||||
}
|
||||
|
@ -5947,7 +5976,10 @@ void CX86RecompilerOps::SPECIAL_NOR()
|
|||
{
|
||||
int Value = GetMipsRegLo(ConstReg);
|
||||
Map_GPR_32bit(m_Opcode.rd, true, MappedReg);
|
||||
if (Value != 0) { m_Assembler.OrConstToX86Reg(Value, GetMipsRegMapLo(m_Opcode.rd)); }
|
||||
if (Value != 0)
|
||||
{
|
||||
m_Assembler.OrConstToX86Reg(Value, GetMipsRegMapLo(m_Opcode.rd));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6067,8 +6099,7 @@ void CX86RecompilerOps::SPECIAL_SLT()
|
|||
|
||||
m_Assembler.CompX86RegToX86Reg(
|
||||
Is64Bit(m_Opcode.rs) ? GetMipsRegMapHi(m_Opcode.rs) : Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rs, true, false),
|
||||
Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false)
|
||||
);
|
||||
Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false));
|
||||
m_Assembler.JeLabel8("Low Compare", 0);
|
||||
Jump[0] = *g_RecompPos - 1;
|
||||
m_Assembler.SetlVariable(&m_BranchCompare, "m_BranchCompare");
|
||||
|
@ -6115,8 +6146,7 @@ void CX86RecompilerOps::SPECIAL_SLT()
|
|||
|
||||
m_Assembler.CompConstToX86reg(
|
||||
Is64Bit(MappedReg) ? GetMipsRegMapHi(MappedReg) : Map_TempReg(CX86Ops::x86_Unknown, MappedReg, true, false),
|
||||
Is64Bit(ConstReg) ? GetMipsRegHi(ConstReg) : (GetMipsRegLo_S(ConstReg) >> 31)
|
||||
);
|
||||
Is64Bit(ConstReg) ? GetMipsRegHi(ConstReg) : (GetMipsRegLo_S(ConstReg) >> 31));
|
||||
m_Assembler.JeLabel8("Low Compare", 0);
|
||||
Jump[0] = *g_RecompPos - 1;
|
||||
if (MappedReg == m_Opcode.rs)
|
||||
|
@ -6383,8 +6413,7 @@ void CX86RecompilerOps::SPECIAL_SLTU()
|
|||
|
||||
m_Assembler.CompX86RegToX86Reg(
|
||||
Is64Bit(m_Opcode.rs) ? GetMipsRegMapHi(m_Opcode.rs) : Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rs, true, false),
|
||||
Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false)
|
||||
);
|
||||
Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false));
|
||||
m_Assembler.JeLabel8("Low Compare", 0);
|
||||
Jump[0] = *g_RecompPos - 1;
|
||||
m_Assembler.SetbVariable(&m_BranchCompare, "m_BranchCompare");
|
||||
|
@ -6423,7 +6452,10 @@ void CX86RecompilerOps::SPECIAL_SLTU()
|
|||
|
||||
ConstLo = GetMipsRegLo_S(ConstReg);
|
||||
ConstHi = GetMipsRegLo_S(ConstReg) >> 31;
|
||||
if (Is64Bit(ConstReg)) { ConstHi = GetMipsRegHi(ConstReg); }
|
||||
if (Is64Bit(ConstReg))
|
||||
{
|
||||
ConstHi = GetMipsRegHi(ConstReg);
|
||||
}
|
||||
|
||||
ProtectGPR(MappedReg);
|
||||
MappedRegLo = GetMipsRegMapLo(MappedReg);
|
||||
|
@ -6723,7 +6755,10 @@ void CX86RecompilerOps::SPECIAL_DADDU()
|
|||
int source1 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rt : m_Opcode.rs;
|
||||
int source2 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rs : m_Opcode.rt;
|
||||
|
||||
if (IsMapped(source2)) { ProtectGPR(source2); }
|
||||
if (IsMapped(source2))
|
||||
{
|
||||
ProtectGPR(source2);
|
||||
}
|
||||
Map_GPR_64bit(m_Opcode.rd, source1);
|
||||
if (IsConst(source2))
|
||||
{
|
||||
|
@ -6840,9 +6875,8 @@ void CX86RecompilerOps::SPECIAL_DSUBU()
|
|||
}
|
||||
|
||||
m_RegWorkingSet.SetMipsReg(m_Opcode.rd,
|
||||
Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs) -
|
||||
Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)
|
||||
);
|
||||
Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs) - Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt)
|
||||
: (int64_t)GetMipsRegLo_S(m_Opcode.rt));
|
||||
if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1)
|
||||
{
|
||||
m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN);
|
||||
|
@ -6867,7 +6901,10 @@ void CX86RecompilerOps::SPECIAL_DSUBU()
|
|||
m_Assembler.SbbX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), HiReg);
|
||||
return;
|
||||
}
|
||||
if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); }
|
||||
if (IsMapped(m_Opcode.rt))
|
||||
{
|
||||
ProtectGPR(m_Opcode.rt);
|
||||
}
|
||||
Map_GPR_64bit(m_Opcode.rd, m_Opcode.rs);
|
||||
if (IsConst(m_Opcode.rt))
|
||||
{
|
||||
|
@ -7095,7 +7132,8 @@ void CX86RecompilerOps::SPECIAL_DSRL32()
|
|||
CX86RecompilerOps::UnknownOpcode();
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
Map_GPR_32bit(m_Opcode.rd, false, -1);
|
||||
m_Assembler.MoveVariableToX86reg(&_GPR[m_Opcode.rt].UW[1], CRegName::GPR_Hi[m_Opcode.rt], GetMipsRegMapLo(m_Opcode.rd));
|
||||
if ((uint8_t)m_Opcode.sa != 0)
|
||||
|
@ -7145,7 +7183,8 @@ void CX86RecompilerOps::SPECIAL_DSRA32()
|
|||
CX86RecompilerOps::UnknownOpcode();
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
Map_GPR_32bit(m_Opcode.rd, true, -1);
|
||||
m_Assembler.MoveVariableToX86reg(&_GPR[m_Opcode.rt].UW[1], CRegName::GPR_Lo[m_Opcode.rt], GetMipsRegMapLo(m_Opcode.rd));
|
||||
if ((uint8_t)m_Opcode.sa != 0)
|
||||
|
@ -7261,7 +7300,8 @@ void CX86RecompilerOps::COP0_MT()
|
|||
{
|
||||
m_Assembler.MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
m_Assembler.MoveX86regToVariable(Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, false, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]);
|
||||
}
|
||||
m_Assembler.XorVariableToX86reg(&_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd], OldStatusReg);
|
||||
|
@ -7276,8 +7316,8 @@ void CX86RecompilerOps::COP0_MT()
|
|||
m_RegWorkingSet.BeforeCallDirect();
|
||||
m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts", 4);
|
||||
m_RegWorkingSet.AfterCallDirect();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6: // Wired
|
||||
UpdateCounters(m_RegWorkingSet, false, true);
|
||||
m_RegWorkingSet.BeforeCallDirect();
|
||||
|
@ -7483,7 +7523,8 @@ void CX86RecompilerOps::COP1_DMT()
|
|||
|
||||
if ((m_Opcode.fs & 1) == 0)
|
||||
{
|
||||
if (RegInStack(m_Opcode.fs + 1, CRegInfo::FPU_Float) || RegInStack(m_Opcode.fs + 1, CRegInfo::FPU_Dword)) {
|
||||
if (RegInStack(m_Opcode.fs + 1, CRegInfo::FPU_Float) || RegInStack(m_Opcode.fs + 1, CRegInfo::FPU_Dword))
|
||||
{
|
||||
UnMap_FPR(m_Opcode.fs + 1, true);
|
||||
}
|
||||
}
|
||||
|
@ -7851,9 +7892,18 @@ void CX86RecompilerOps::COP1_S_CMP()
|
|||
}
|
||||
|
||||
CompileCop1Test();
|
||||
if ((m_Opcode.funct & 7) == 0) { CX86RecompilerOps::UnknownOpcode(); }
|
||||
if ((m_Opcode.funct & 2) != 0) { cmp |= 0x4000; }
|
||||
if ((m_Opcode.funct & 4) != 0) { cmp |= 0x0100; }
|
||||
if ((m_Opcode.funct & 7) == 0)
|
||||
{
|
||||
CX86RecompilerOps::UnknownOpcode();
|
||||
}
|
||||
if ((m_Opcode.funct & 2) != 0)
|
||||
{
|
||||
cmp |= 0x4000;
|
||||
}
|
||||
if ((m_Opcode.funct & 4) != 0)
|
||||
{
|
||||
cmp |= 0x0100;
|
||||
}
|
||||
|
||||
Load_FPR_ToTop(Reg1, Reg1, CRegInfo::FPU_Float);
|
||||
Map_TempReg(CX86Ops::x86_EAX, 0, false, false);
|
||||
|
@ -8225,9 +8275,18 @@ void CX86RecompilerOps::COP1_D_CMP()
|
|||
}
|
||||
|
||||
CompileCop1Test();
|
||||
if ((m_Opcode.funct & 7) == 0) { CX86RecompilerOps::UnknownOpcode(); }
|
||||
if ((m_Opcode.funct & 2) != 0) { cmp |= 0x4000; }
|
||||
if ((m_Opcode.funct & 4) != 0) { cmp |= 0x0100; }
|
||||
if ((m_Opcode.funct & 7) == 0)
|
||||
{
|
||||
CX86RecompilerOps::UnknownOpcode();
|
||||
}
|
||||
if ((m_Opcode.funct & 2) != 0)
|
||||
{
|
||||
cmp |= 0x4000;
|
||||
}
|
||||
if ((m_Opcode.funct & 4) != 0)
|
||||
{
|
||||
cmp |= 0x0100;
|
||||
}
|
||||
|
||||
Load_FPR_ToTop(Reg1, Reg1, CRegInfo::FPU_Double);
|
||||
Map_TempReg(CX86Ops::x86_EAX, 0, false, false);
|
||||
|
@ -8335,7 +8394,10 @@ void CX86RecompilerOps::UnknownOpcode()
|
|||
m_Assembler.MoveConstToVariable(m_Opcode.Value, &R4300iOp::m_Opcode.Value, "R4300iOp::m_Opcode.Value");
|
||||
m_Assembler.CallFunc((uint32_t)R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode");
|
||||
m_Assembler.Ret();
|
||||
if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { m_PipelineStage = PIPELINE_STAGE_END_BLOCK; }
|
||||
if (m_PipelineStage == PIPELINE_STAGE_NORMAL)
|
||||
{
|
||||
m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
void CX86RecompilerOps::ClearCachedInstructionInfo()
|
||||
|
@ -8503,7 +8565,10 @@ void CX86RecompilerOps::SyncRegState(const CRegInfo & SyncTo)
|
|||
|
||||
bool changed = false;
|
||||
UnMap_AllFPRs();
|
||||
if (m_RegWorkingSet.GetRoundingModel() != SyncTo.GetRoundingModel()) { m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); }
|
||||
if (m_RegWorkingSet.GetRoundingModel() != SyncTo.GetRoundingModel())
|
||||
{
|
||||
m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown);
|
||||
}
|
||||
CX86Ops::x86Reg MemStackReg = Get_MemoryStack();
|
||||
CX86Ops::x86Reg TargetStackReg = SyncTo.Get_MemoryStack();
|
||||
|
||||
|
@ -8626,8 +8691,8 @@ void CX86RecompilerOps::SyncRegState(const CRegInfo & SyncTo)
|
|||
m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(x86RegHi), CRegInfo::GPR_Mapped);
|
||||
m_RegWorkingSet.SetX86MapOrder(GetIndexFromX86Reg(Reg), 1);
|
||||
m_RegWorkingSet.SetX86MapOrder(GetIndexFromX86Reg(x86RegHi), 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CRegInfo::STATE_MAPPED_32_SIGN:
|
||||
{
|
||||
CX86Ops::x86Reg Reg = SyncTo.GetMipsRegMapLo(i);
|
||||
|
@ -8662,8 +8727,8 @@ void CX86RecompilerOps::SyncRegState(const CRegInfo & SyncTo)
|
|||
m_RegWorkingSet.SetMipsRegState(i, CRegInfo::STATE_MAPPED_32_SIGN);
|
||||
m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(Reg), CRegInfo::GPR_Mapped);
|
||||
m_RegWorkingSet.SetX86MapOrder(GetIndexFromX86Reg(Reg), 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CRegInfo::STATE_MAPPED_32_ZERO:
|
||||
{
|
||||
CX86Ops::x86Reg Reg = SyncTo.GetMipsRegMapLo(i);
|
||||
|
@ -8707,8 +8772,8 @@ void CX86RecompilerOps::SyncRegState(const CRegInfo & SyncTo)
|
|||
m_RegWorkingSet.SetMipsRegState(i, SyncTo.GetMipsRegState(i));
|
||||
m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(Reg), CRegInfo::GPR_Mapped);
|
||||
m_RegWorkingSet.SetX86MapOrder(GetIndexFromX86Reg(Reg), 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
m_CodeBlock.Log("%d - %d reg: %s (%d)", SyncTo.GetMipsRegState(i), GetMipsRegState(i), CRegName::GPR[i], i);
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
|
@ -8769,7 +8834,10 @@ bool CX86RecompilerOps::InheritParentInfo()
|
|||
CCodeSection * Parent = *iter;
|
||||
BLOCK_PARENT BlockParent;
|
||||
|
||||
if (Parent->m_CompiledLocation == nullptr) { continue; }
|
||||
if (Parent->m_CompiledLocation == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (Parent->m_JumpSection != Parent->m_ContinueSection)
|
||||
{
|
||||
BlockParent.Parent = Parent;
|
||||
|
@ -8799,7 +8867,10 @@ bool CX86RecompilerOps::InheritParentInfo()
|
|||
CCodeSection * Parent = *iter;
|
||||
BLOCK_PARENT BlockParent;
|
||||
|
||||
if (Parent->m_CompiledLocation != nullptr) { continue; }
|
||||
if (Parent->m_CompiledLocation != nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (Parent->m_JumpSection != Parent->m_ContinueSection)
|
||||
{
|
||||
BlockParent.Parent = Parent;
|
||||
|
@ -8874,7 +8945,10 @@ bool CX86RecompilerOps::InheritParentInfo()
|
|||
// Determine loop registry usage
|
||||
if (m_Section->m_InLoop && ParentList.size() > 1)
|
||||
{
|
||||
if (!SetupRegisterForLoop(m_Section->m_CodeBlock, m_Section->m_RegEnter)) { return false; }
|
||||
if (!SetupRegisterForLoop(m_Section->m_CodeBlock, m_Section->m_RegEnter))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown);
|
||||
}
|
||||
|
||||
|
@ -8883,7 +8957,10 @@ bool CX86RecompilerOps::InheritParentInfo()
|
|||
CX86Ops::x86Reg MemoryStackPos;
|
||||
int i2;
|
||||
|
||||
if (i == (size_t)FirstParent) { continue; }
|
||||
if (i == (size_t)FirstParent)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Parent = ParentList[i].Parent;
|
||||
if (Parent->m_CompiledLocation == nullptr)
|
||||
{
|
||||
|
@ -8891,7 +8968,10 @@ bool CX86RecompilerOps::InheritParentInfo()
|
|||
}
|
||||
CRegInfo * RegSet = &ParentList[i].JumpInfo->RegSet;
|
||||
|
||||
if (m_RegWorkingSet.GetRoundingModel() != RegSet->GetRoundingModel()) { m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); }
|
||||
if (m_RegWorkingSet.GetRoundingModel() != RegSet->GetRoundingModel())
|
||||
{
|
||||
m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown);
|
||||
}
|
||||
|
||||
// Find parent MapRegState
|
||||
MemoryStackPos = CX86Ops::x86_Unknown;
|
||||
|
@ -8951,7 +9031,8 @@ bool CX86RecompilerOps::InheritParentInfo()
|
|||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
if (IsConst(i2)) {
|
||||
if (IsConst(i2))
|
||||
{
|
||||
if (GetMipsRegState(i2) != RegSet->GetMipsRegState(i2))
|
||||
{
|
||||
switch (RegSet->GetMipsRegState(i2))
|
||||
|
@ -9023,12 +9104,18 @@ bool CX86RecompilerOps::InheritParentInfo()
|
|||
CRegInfo * RegSet;
|
||||
int i2;
|
||||
|
||||
if (i == (size_t)FirstParent) { continue; }
|
||||
if (i == (size_t)FirstParent)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Parent = ParentList[i].Parent;
|
||||
JumpInfo = ParentList[i].JumpInfo;
|
||||
RegSet = &ParentList[i].JumpInfo->RegSet;
|
||||
|
||||
if (JumpInfo->RegSet.GetBlockCycleCount() != 0) { NeedSync = true; }
|
||||
if (JumpInfo->RegSet.GetBlockCycleCount() != 0)
|
||||
{
|
||||
NeedSync = true;
|
||||
}
|
||||
|
||||
for (i2 = 0; !NeedSync && i2 < 8; i2++)
|
||||
{
|
||||
|
@ -9051,7 +9138,10 @@ bool CX86RecompilerOps::InheritParentInfo()
|
|||
}
|
||||
for (i2 = 0; !NeedSync && i2 < 32; i2++)
|
||||
{
|
||||
if (NeedSync == true) { break; }
|
||||
if (NeedSync == true)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (m_RegWorkingSet.GetMipsRegState(i2) != RegSet->GetMipsRegState(i2))
|
||||
{
|
||||
NeedSync = true;
|
||||
|
@ -9087,7 +9177,10 @@ bool CX86RecompilerOps::InheritParentInfo()
|
|||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
if (NeedSync == false) { continue; }
|
||||
if (NeedSync == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Parent = ParentList[CurrentParent].Parent;
|
||||
JumpInfo = ParentList[CurrentParent].JumpInfo;
|
||||
m_Assembler.JmpLabel32(Label.c_str(), 0);
|
||||
|
@ -9534,8 +9627,8 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo
|
|||
m_Assembler.PushImm32(bDelay ? "true" : "false", bDelay);
|
||||
m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException", 4);
|
||||
ExitCodeBlock();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ExitReason_COP1Unuseable:
|
||||
{
|
||||
bool bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT;
|
||||
|
@ -9543,8 +9636,8 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo
|
|||
m_Assembler.PushImm32(bDelay ? "true" : "false", bDelay);
|
||||
m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException", 12);
|
||||
ExitCodeBlock();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ExitReason_ResetRecompCode:
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
ExitCodeBlock();
|
||||
|
@ -10389,7 +10482,8 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr)
|
|||
{
|
||||
ModValue |= MI_MODE_RDRAM;
|
||||
}
|
||||
if (ModValue != 0) {
|
||||
if (ModValue != 0)
|
||||
{
|
||||
m_Assembler.OrConstToVariable(ModValue, &g_Reg->MI_MODE_REG, "MI_MODE_REG");
|
||||
}
|
||||
if ((Value & MI_CLR_DP_INTR) != 0)
|
||||
|
@ -10397,8 +10491,8 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr)
|
|||
m_Assembler.AndConstToVariable((uint32_t)~MI_INTR_DP, &g_Reg->MI_INTR_REG, "MI_INTR_REG");
|
||||
m_Assembler.AndConstToVariable((uint32_t)~MI_INTR_DP, &g_Reg->m_GfxIntrReg, "m_GfxIntrReg");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x0430000C:
|
||||
{
|
||||
uint32_t ModValue;
|
||||
|
@ -10461,8 +10555,8 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr)
|
|||
{
|
||||
m_Assembler.OrConstToVariable(ModValue, &g_Reg->MI_INTR_MASK_REG, "MI_INTR_MASK_REG");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (BreakOnUnhandledMemory())
|
||||
{
|
||||
|
@ -10659,8 +10753,8 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr)
|
|||
m_Assembler.PushImm32(PAddr | 0xA0000000);
|
||||
m_Assembler.CallThis((uint32_t)g_MMU, AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory", 4);
|
||||
m_RegWorkingSet.AfterCallDirect();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (PAddr >= 0x10000000 && PAddr < 0x20000000)
|
||||
{
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#pragma once
|
||||
#if defined(__i386__) || defined(_M_IX86)
|
||||
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iOpcode.h>
|
||||
#include <Project64-core/N64System/Recompiler/ExitInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/RegInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/x86/x86ops.h>
|
||||
#include <Project64-core/N64System/Recompiler/JumpInfo.h>
|
||||
#include <Project64-core/N64System/Interpreter/InterpreterOps.h>
|
||||
#include <Project64-core/N64System/Mips/R4300iOpcode.h>
|
||||
#include <Project64-core/N64System/Mips/Register.h>
|
||||
#include <Project64-core/N64System/Recompiler/ExitInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/JumpInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/RegInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/x86/x86ops.h>
|
||||
#include <Project64-core/Settings/GameSettings.h>
|
||||
#include <Project64-core/Settings/N64SystemSettings.h>
|
||||
#include <Project64-core/Settings/RecompilerSettings.h>
|
||||
#include <Project64-core/Settings/GameSettings.h>
|
||||
|
||||
class CCodeBlock;
|
||||
class CCodeSection;
|
||||
|
@ -243,56 +243,179 @@ public:
|
|||
static void ChangeDefaultRoundingModel();
|
||||
void OverflowDelaySlot(bool TestTimer);
|
||||
|
||||
CX86Ops & Assembler() { return m_Assembler; }
|
||||
CX86Ops & Assembler()
|
||||
{
|
||||
return m_Assembler;
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
typedef CRegInfo::REG_STATE REG_STATE;
|
||||
|
||||
REG_STATE GetMipsRegState(int32_t Reg) { return m_RegWorkingSet.GetMipsRegState(Reg); }
|
||||
uint64_t GetMipsReg(int32_t Reg) { return m_RegWorkingSet.GetMipsReg(Reg); }
|
||||
int64_t GetMipsReg_S(int32_t Reg) { return m_RegWorkingSet.GetMipsReg_S(Reg); }
|
||||
uint32_t GetMipsRegLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo(Reg); }
|
||||
int32_t GetMipsRegLo_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo_S(Reg); }
|
||||
uint32_t GetMipsRegHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi(Reg); }
|
||||
int32_t GetMipsRegHi_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi_S(Reg); }
|
||||
CX86Ops::x86Reg GetMipsRegMapLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapLo(Reg); }
|
||||
CX86Ops::x86Reg GetMipsRegMapHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapHi(Reg); }
|
||||
REG_STATE GetMipsRegState(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegState(Reg);
|
||||
}
|
||||
uint64_t GetMipsReg(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsReg(Reg);
|
||||
}
|
||||
int64_t GetMipsReg_S(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsReg_S(Reg);
|
||||
}
|
||||
uint32_t GetMipsRegLo(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegLo(Reg);
|
||||
}
|
||||
int32_t GetMipsRegLo_S(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegLo_S(Reg);
|
||||
}
|
||||
uint32_t GetMipsRegHi(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegHi(Reg);
|
||||
}
|
||||
int32_t GetMipsRegHi_S(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegHi_S(Reg);
|
||||
}
|
||||
CX86Ops::x86Reg GetMipsRegMapLo(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegMapLo(Reg);
|
||||
}
|
||||
CX86Ops::x86Reg GetMipsRegMapHi(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.GetMipsRegMapHi(Reg);
|
||||
}
|
||||
|
||||
bool IsKnown(int32_t Reg) { return m_RegWorkingSet.IsKnown(Reg); }
|
||||
bool IsUnknown(int32_t Reg) { return m_RegWorkingSet.IsUnknown(Reg); }
|
||||
bool IsMapped(int32_t Reg) { return m_RegWorkingSet.IsMapped(Reg); }
|
||||
bool IsConst(int32_t Reg) { return m_RegWorkingSet.IsConst(Reg); }
|
||||
bool IsSigned(int32_t Reg) { return m_RegWorkingSet.IsSigned(Reg); }
|
||||
bool IsUnsigned(int32_t Reg) { return m_RegWorkingSet.IsUnsigned(Reg); }
|
||||
bool Is32Bit(int32_t Reg) { return m_RegWorkingSet.Is32Bit(Reg); }
|
||||
bool Is64Bit(int32_t Reg) { return m_RegWorkingSet.Is64Bit(Reg); }
|
||||
bool Is32BitMapped(int32_t Reg) { return m_RegWorkingSet.Is32BitMapped(Reg); }
|
||||
bool Is64BitMapped(int32_t Reg) { return m_RegWorkingSet.Is64BitMapped(Reg); }
|
||||
bool IsKnown(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.IsKnown(Reg);
|
||||
}
|
||||
bool IsUnknown(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.IsUnknown(Reg);
|
||||
}
|
||||
bool IsMapped(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.IsMapped(Reg);
|
||||
}
|
||||
bool IsConst(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.IsConst(Reg);
|
||||
}
|
||||
bool IsSigned(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.IsSigned(Reg);
|
||||
}
|
||||
bool IsUnsigned(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.IsUnsigned(Reg);
|
||||
}
|
||||
bool Is32Bit(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.Is32Bit(Reg);
|
||||
}
|
||||
bool Is64Bit(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.Is64Bit(Reg);
|
||||
}
|
||||
bool Is32BitMapped(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.Is32BitMapped(Reg);
|
||||
}
|
||||
bool Is64BitMapped(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.Is64BitMapped(Reg);
|
||||
}
|
||||
|
||||
void FixRoundModel(CRegInfo::FPU_ROUND RoundMethod) { m_RegWorkingSet.FixRoundModel(RoundMethod); }
|
||||
void ChangeFPURegFormat(int32_t Reg, CRegInfo::FPU_STATE OldFormat, CRegInfo::FPU_STATE NewFormat, CRegInfo::FPU_ROUND RoundingModel) { m_RegWorkingSet.ChangeFPURegFormat(Reg, OldFormat, NewFormat, RoundingModel); }
|
||||
void Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, CRegInfo::FPU_STATE Format) { m_RegWorkingSet.Load_FPR_ToTop(Reg, RegToLoad, Format); }
|
||||
bool RegInStack(int32_t Reg, CRegInfo::FPU_STATE Format) { return m_RegWorkingSet.RegInStack(Reg, Format); }
|
||||
CX86Ops::x86FpuValues StackPosition(int32_t Reg) { return m_RegWorkingSet.StackPosition(Reg); }
|
||||
void UnMap_AllFPRs() { m_RegWorkingSet.UnMap_AllFPRs(); }
|
||||
void UnMap_FPR(uint32_t Reg, bool WriteBackValue) { m_RegWorkingSet.UnMap_FPR(Reg, WriteBackValue); }
|
||||
void FixRoundModel(CRegInfo::FPU_ROUND RoundMethod)
|
||||
{
|
||||
m_RegWorkingSet.FixRoundModel(RoundMethod);
|
||||
}
|
||||
void ChangeFPURegFormat(int32_t Reg, CRegInfo::FPU_STATE OldFormat, CRegInfo::FPU_STATE NewFormat, CRegInfo::FPU_ROUND RoundingModel)
|
||||
{
|
||||
m_RegWorkingSet.ChangeFPURegFormat(Reg, OldFormat, NewFormat, RoundingModel);
|
||||
}
|
||||
void Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, CRegInfo::FPU_STATE Format)
|
||||
{
|
||||
m_RegWorkingSet.Load_FPR_ToTop(Reg, RegToLoad, Format);
|
||||
}
|
||||
bool RegInStack(int32_t Reg, CRegInfo::FPU_STATE Format)
|
||||
{
|
||||
return m_RegWorkingSet.RegInStack(Reg, Format);
|
||||
}
|
||||
CX86Ops::x86FpuValues StackPosition(int32_t Reg)
|
||||
{
|
||||
return m_RegWorkingSet.StackPosition(Reg);
|
||||
}
|
||||
void UnMap_AllFPRs()
|
||||
{
|
||||
m_RegWorkingSet.UnMap_AllFPRs();
|
||||
}
|
||||
void UnMap_FPR(uint32_t Reg, bool WriteBackValue)
|
||||
{
|
||||
m_RegWorkingSet.UnMap_FPR(Reg, WriteBackValue);
|
||||
}
|
||||
|
||||
CX86Ops::x86Reg FreeX86Reg() { return m_RegWorkingSet.FreeX86Reg(); }
|
||||
CX86Ops::x86Reg Free8BitX86Reg() { return m_RegWorkingSet.Free8BitX86Reg(); }
|
||||
void Map_GPR_32bit(int32_t Reg, bool SignValue, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_32bit(Reg, SignValue, MipsRegToLoad); }
|
||||
void Map_GPR_64bit(int32_t Reg, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_64bit(Reg, MipsRegToLoad); }
|
||||
CX86Ops::x86Reg Get_MemoryStack() { return m_RegWorkingSet.Get_MemoryStack(); }
|
||||
CX86Ops::x86Reg Map_MemoryStack(CX86Ops::x86Reg Reg, bool bMapRegister, bool LoadValue = true) { return m_RegWorkingSet.Map_MemoryStack(Reg, bMapRegister, LoadValue); }
|
||||
CX86Ops::x86Reg Map_TempReg(CX86Ops::x86Reg Reg, int32_t MipsReg, bool LoadHiWord, bool Reg8Bit) { return m_RegWorkingSet.Map_TempReg(Reg, MipsReg, LoadHiWord, Reg8Bit); }
|
||||
void ProtectGPR(uint32_t Reg) { m_RegWorkingSet.ProtectGPR(Reg); }
|
||||
void UnProtectGPR(uint32_t Reg) { m_RegWorkingSet.UnProtectGPR(Reg); }
|
||||
void ResetX86Protection() { m_RegWorkingSet.ResetX86Protection(); }
|
||||
CX86Ops::x86Reg UnMap_TempReg() { return m_RegWorkingSet.UnMap_TempReg(); }
|
||||
void UnMap_GPR(uint32_t Reg, bool WriteBackValue) { m_RegWorkingSet.UnMap_GPR(Reg, WriteBackValue); }
|
||||
bool UnMap_X86reg(CX86Ops::x86Reg Reg) { return m_RegWorkingSet.UnMap_X86reg(Reg); }
|
||||
CX86Ops::x86Reg FreeX86Reg()
|
||||
{
|
||||
return m_RegWorkingSet.FreeX86Reg();
|
||||
}
|
||||
CX86Ops::x86Reg Free8BitX86Reg()
|
||||
{
|
||||
return m_RegWorkingSet.Free8BitX86Reg();
|
||||
}
|
||||
void Map_GPR_32bit(int32_t Reg, bool SignValue, int32_t MipsRegToLoad)
|
||||
{
|
||||
m_RegWorkingSet.Map_GPR_32bit(Reg, SignValue, MipsRegToLoad);
|
||||
}
|
||||
void Map_GPR_64bit(int32_t Reg, int32_t MipsRegToLoad)
|
||||
{
|
||||
m_RegWorkingSet.Map_GPR_64bit(Reg, MipsRegToLoad);
|
||||
}
|
||||
CX86Ops::x86Reg Get_MemoryStack()
|
||||
{
|
||||
return m_RegWorkingSet.Get_MemoryStack();
|
||||
}
|
||||
CX86Ops::x86Reg Map_MemoryStack(CX86Ops::x86Reg Reg, bool bMapRegister, bool LoadValue = true)
|
||||
{
|
||||
return m_RegWorkingSet.Map_MemoryStack(Reg, bMapRegister, LoadValue);
|
||||
}
|
||||
CX86Ops::x86Reg Map_TempReg(CX86Ops::x86Reg Reg, int32_t MipsReg, bool LoadHiWord, bool Reg8Bit)
|
||||
{
|
||||
return m_RegWorkingSet.Map_TempReg(Reg, MipsReg, LoadHiWord, Reg8Bit);
|
||||
}
|
||||
void ProtectGPR(uint32_t Reg)
|
||||
{
|
||||
m_RegWorkingSet.ProtectGPR(Reg);
|
||||
}
|
||||
void UnProtectGPR(uint32_t Reg)
|
||||
{
|
||||
m_RegWorkingSet.UnProtectGPR(Reg);
|
||||
}
|
||||
void ResetX86Protection()
|
||||
{
|
||||
m_RegWorkingSet.ResetX86Protection();
|
||||
}
|
||||
CX86Ops::x86Reg UnMap_TempReg()
|
||||
{
|
||||
return m_RegWorkingSet.UnMap_TempReg();
|
||||
}
|
||||
void UnMap_GPR(uint32_t Reg, bool WriteBackValue)
|
||||
{
|
||||
m_RegWorkingSet.UnMap_GPR(Reg, WriteBackValue);
|
||||
}
|
||||
bool UnMap_X86reg(CX86Ops::x86Reg Reg)
|
||||
{
|
||||
return m_RegWorkingSet.UnMap_X86reg(Reg);
|
||||
}
|
||||
|
||||
public:
|
||||
uint32_t CompilePC() { return m_CompilePC; }
|
||||
uint32_t CompilePC()
|
||||
{
|
||||
return m_CompilePC;
|
||||
}
|
||||
|
||||
private:
|
||||
CX86RecompilerOps(const CX86RecompilerOps &);
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#if defined(__i386__) || defined(_M_IX86)
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
#include <Project64-core/N64System/Recompiler/Recompiler.h>
|
||||
#include <Project64-core/N64System/Recompiler/x86/x86RegInfo.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
|
||||
#include <float.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <float.h>
|
||||
|
||||
uint32_t CX86RegInfo::m_fpuControl = 0;
|
||||
|
||||
|
@ -122,17 +122,38 @@ bool CX86RegInfo::operator==(const CX86RegInfo& right) const
|
|||
|
||||
for (count = 0; count < 10; count++)
|
||||
{
|
||||
if (m_x86reg_MappedTo[count] != right.m_x86reg_MappedTo[count]) { return false; }
|
||||
if (m_x86reg_Protected[count] != right.m_x86reg_Protected[count]) { return false; }
|
||||
if (m_x86reg_MapOrder[count] != right.m_x86reg_MapOrder[count]) { return false; }
|
||||
if (m_x86reg_MappedTo[count] != right.m_x86reg_MappedTo[count])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_x86reg_Protected[count] != right.m_x86reg_Protected[count])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_x86reg_MapOrder[count] != right.m_x86reg_MapOrder[count])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (m_Stack_TopPos != right.m_Stack_TopPos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_Stack_TopPos != right.m_Stack_TopPos) { return false; }
|
||||
|
||||
for (count = 0; count < 8; count++)
|
||||
{
|
||||
if (m_x86fpu_MappedTo[count] != right.m_x86fpu_MappedTo[count]) { return false; }
|
||||
if (m_x86fpu_State[count] != right.m_x86fpu_State[count]) { return false; }
|
||||
if (m_x86fpu_RoundingModel[count] != right.m_x86fpu_RoundingModel[count]) { return false; }
|
||||
if (m_x86fpu_MappedTo[count] != right.m_x86fpu_MappedTo[count])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_x86fpu_State[count] != right.m_x86fpu_State[count])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_x86fpu_RoundingModel[count] != right.m_x86fpu_RoundingModel[count])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -144,8 +165,14 @@ bool CX86RegInfo::operator!=(const CX86RegInfo& right) const
|
|||
|
||||
CX86RegInfo::REG_STATE CX86RegInfo::ConstantsType(int64_t Value)
|
||||
{
|
||||
if (((Value >> 32) == -1) && ((Value & 0x80000000) != 0)) { return STATE_CONST_32_SIGN; }
|
||||
if (((Value >> 32) == 0) && ((Value & 0x80000000) == 0)) { return STATE_CONST_32_SIGN; }
|
||||
if (((Value >> 32) == -1) && ((Value & 0x80000000) != 0))
|
||||
{
|
||||
return STATE_CONST_32_SIGN;
|
||||
}
|
||||
if (((Value >> 32) == 0) && ((Value & 0x80000000) == 0))
|
||||
{
|
||||
return STATE_CONST_32_SIGN;
|
||||
}
|
||||
return STATE_CONST_64;
|
||||
}
|
||||
|
||||
|
@ -265,8 +292,16 @@ void CX86RegInfo::Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, FPU_STATE Forma
|
|||
m_CodeBlock.Log("CurrentRoundingModel: %s FpuRoundingModel(StackTopPos()): %s", RoundingModelName(GetRoundingModel()), RoundingModelName(FpuRoundingModel(StackTopPos())));
|
||||
int32_t i;
|
||||
|
||||
if (RegToLoad < 0) { g_Notify->DisplayError("Load_FPR_ToTop\nRegToLoad < 0 ???"); return; }
|
||||
if (Reg < 0) { g_Notify->DisplayError("Load_FPR_ToTop\nReg < 0 ???"); return; }
|
||||
if (RegToLoad < 0)
|
||||
{
|
||||
g_Notify->DisplayError("Load_FPR_ToTop\nRegToLoad < 0 ???");
|
||||
return;
|
||||
}
|
||||
if (Reg < 0)
|
||||
{
|
||||
g_Notify->DisplayError("Load_FPR_ToTop\nReg < 0 ???");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Format == FPU_Double || Format == FPU_Qword)
|
||||
{
|
||||
|
@ -427,7 +462,10 @@ void CX86RegInfo::Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, FPU_STATE Forma
|
|||
m_Assembler.fpuLoadQwordFromX86Reg(&StackTopPos(), TempReg);
|
||||
break;
|
||||
default:
|
||||
if (HaveDebugger()) { g_Notify->DisplayError(stdstr_f("Load_FPR_ToTop\nUnkown format to load %d", Format).c_str()); }
|
||||
if (HaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError(stdstr_f("Load_FPR_ToTop\nUnkown format to load %d", Format).c_str());
|
||||
}
|
||||
}
|
||||
SetX86Protected(GetIndexFromX86Reg(TempReg), false);
|
||||
FpuRoundingModel(StackTopPos()) = RoundDefault;
|
||||
|
@ -453,15 +491,36 @@ CX86Ops::x86FpuValues CX86RegInfo::StackPosition(int32_t Reg)
|
|||
|
||||
CX86Ops::x86Reg CX86RegInfo::FreeX86Reg()
|
||||
{
|
||||
if (GetX86Mapped(x86RegIndex_EDI) == NotMapped && !GetX86Protected(x86RegIndex_EDI)) { return CX86Ops::x86_EDI; }
|
||||
if (GetX86Mapped(x86RegIndex_ESI) == NotMapped && !GetX86Protected(x86RegIndex_ESI)) { return CX86Ops::x86_ESI; }
|
||||
if (GetX86Mapped(x86RegIndex_EBX) == NotMapped && !GetX86Protected(x86RegIndex_EBX)) { return CX86Ops::x86_EBX; }
|
||||
if (GetX86Mapped(x86RegIndex_EAX) == NotMapped && !GetX86Protected(x86RegIndex_EAX)) { return CX86Ops::x86_EAX; }
|
||||
if (GetX86Mapped(x86RegIndex_EDX) == NotMapped && !GetX86Protected(x86RegIndex_EDX)) { return CX86Ops::x86_EDX; }
|
||||
if (GetX86Mapped(x86RegIndex_ECX) == NotMapped && !GetX86Protected(x86RegIndex_ECX)) { return CX86Ops::x86_ECX; }
|
||||
if (GetX86Mapped(x86RegIndex_EDI) == NotMapped && !GetX86Protected(x86RegIndex_EDI))
|
||||
{
|
||||
return CX86Ops::x86_EDI;
|
||||
}
|
||||
if (GetX86Mapped(x86RegIndex_ESI) == NotMapped && !GetX86Protected(x86RegIndex_ESI))
|
||||
{
|
||||
return CX86Ops::x86_ESI;
|
||||
}
|
||||
if (GetX86Mapped(x86RegIndex_EBX) == NotMapped && !GetX86Protected(x86RegIndex_EBX))
|
||||
{
|
||||
return CX86Ops::x86_EBX;
|
||||
}
|
||||
if (GetX86Mapped(x86RegIndex_EAX) == NotMapped && !GetX86Protected(x86RegIndex_EAX))
|
||||
{
|
||||
return CX86Ops::x86_EAX;
|
||||
}
|
||||
if (GetX86Mapped(x86RegIndex_EDX) == NotMapped && !GetX86Protected(x86RegIndex_EDX))
|
||||
{
|
||||
return CX86Ops::x86_EDX;
|
||||
}
|
||||
if (GetX86Mapped(x86RegIndex_ECX) == NotMapped && !GetX86Protected(x86RegIndex_ECX))
|
||||
{
|
||||
return CX86Ops::x86_ECX;
|
||||
}
|
||||
|
||||
CX86Ops::x86Reg Reg = UnMap_TempReg();
|
||||
if (Reg != CX86Ops::x86_Unknown) { return Reg; }
|
||||
if (Reg != CX86Ops::x86_Unknown)
|
||||
{
|
||||
return Reg;
|
||||
}
|
||||
|
||||
uint32_t MapCount[x86RegIndex_Size];
|
||||
x86RegIndex MapReg[x86RegIndex_Size];
|
||||
|
@ -497,7 +556,10 @@ CX86Ops::x86Reg CX86RegInfo::FreeX86Reg()
|
|||
return (CX86Ops::x86Reg)MapReg[i];
|
||||
}
|
||||
}
|
||||
if (GetX86Mapped(MapReg[i]) == Stack_Mapped) { StackReg = GetX86RegFromIndex(MapReg[i]); }
|
||||
if (GetX86Mapped(MapReg[i]) == Stack_Mapped)
|
||||
{
|
||||
StackReg = GetX86RegFromIndex(MapReg[i]);
|
||||
}
|
||||
}
|
||||
if (StackReg != CX86Ops::x86_Unknown)
|
||||
{
|
||||
|
@ -510,13 +572,28 @@ CX86Ops::x86Reg CX86RegInfo::FreeX86Reg()
|
|||
|
||||
CX86Ops::x86Reg CX86RegInfo::Free8BitX86Reg()
|
||||
{
|
||||
if (GetX86Mapped(x86RegIndex_EBX) == NotMapped && !GetX86Protected(x86RegIndex_EBX)) { return CX86Ops::x86_EBX; }
|
||||
if (GetX86Mapped(x86RegIndex_EAX) == NotMapped && !GetX86Protected(x86RegIndex_EAX)) { return CX86Ops::x86_EAX; }
|
||||
if (GetX86Mapped(x86RegIndex_EDX) == NotMapped && !GetX86Protected(x86RegIndex_EDX)) { return CX86Ops::x86_EDX; }
|
||||
if (GetX86Mapped(x86RegIndex_ECX) == NotMapped && !GetX86Protected(x86RegIndex_ECX)) { return CX86Ops::x86_ECX; }
|
||||
if (GetX86Mapped(x86RegIndex_EBX) == NotMapped && !GetX86Protected(x86RegIndex_EBX))
|
||||
{
|
||||
return CX86Ops::x86_EBX;
|
||||
}
|
||||
if (GetX86Mapped(x86RegIndex_EAX) == NotMapped && !GetX86Protected(x86RegIndex_EAX))
|
||||
{
|
||||
return CX86Ops::x86_EAX;
|
||||
}
|
||||
if (GetX86Mapped(x86RegIndex_EDX) == NotMapped && !GetX86Protected(x86RegIndex_EDX))
|
||||
{
|
||||
return CX86Ops::x86_EDX;
|
||||
}
|
||||
if (GetX86Mapped(x86RegIndex_ECX) == NotMapped && !GetX86Protected(x86RegIndex_ECX))
|
||||
{
|
||||
return CX86Ops::x86_ECX;
|
||||
}
|
||||
|
||||
CX86Ops::x86Reg Reg = UnMap_8BitTempReg();
|
||||
if (Reg > 0) { return Reg; }
|
||||
if (Reg > 0)
|
||||
{
|
||||
return Reg;
|
||||
}
|
||||
|
||||
uint32_t MapCount[10];
|
||||
x86RegIndex MapReg[10];
|
||||
|
@ -544,7 +621,10 @@ CX86Ops::x86Reg CX86RegInfo::Free8BitX86Reg()
|
|||
{
|
||||
if (MapCount[i] > 0)
|
||||
{
|
||||
if (!CX86Ops::Is8BitReg((CX86Ops::x86Reg)i)) { continue; }
|
||||
if (!CX86Ops::Is8BitReg((CX86Ops::x86Reg)i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (UnMap_X86reg((CX86Ops::x86Reg)i))
|
||||
{
|
||||
return (CX86Ops::x86Reg)i;
|
||||
|
@ -558,7 +638,10 @@ CX86Ops::x86Reg CX86RegInfo::UnMap_8BitTempReg()
|
|||
{
|
||||
for (uint32_t i = 0; i < x86RegIndex_Size; i++)
|
||||
{
|
||||
if (!CX86Ops::Is8BitReg(GetX86RegFromIndex((x86RegIndex)i))) { continue; }
|
||||
if (!CX86Ops::Is8BitReg(GetX86RegFromIndex((x86RegIndex)i)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (GetX86Mapped((x86RegIndex)i) == Temp_Mapped)
|
||||
{
|
||||
if (GetX86Protected((x86RegIndex)i) == false)
|
||||
|
@ -655,7 +738,10 @@ void CX86RegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsReg
|
|||
Reg = FreeX86Reg();
|
||||
if (Reg < 0)
|
||||
{
|
||||
if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_32bit\n\nOut of registers"); }
|
||||
if (HaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError("Map_GPR_32bit\n\nOut of registers");
|
||||
}
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
@ -718,7 +804,10 @@ void CX86RegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad)
|
|||
CX86Ops::x86Reg x86Hi = CX86Ops::x86_Unknown, x86lo = CX86Ops::x86_Unknown;
|
||||
if (MipsReg == 0)
|
||||
{
|
||||
if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_32bit\n\nWhy are you trying to map register 0?"); }
|
||||
if (HaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError("Map_GPR_32bit\n\nWhy are you trying to map register 0?");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -728,13 +817,20 @@ void CX86RegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad)
|
|||
x86Hi = FreeX86Reg();
|
||||
if (x86Hi < 0)
|
||||
{
|
||||
if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); }
|
||||
if (HaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers");
|
||||
}
|
||||
return;
|
||||
}
|
||||
SetX86Protected(GetIndexFromX86Reg(x86Hi), true);
|
||||
|
||||
x86lo = FreeX86Reg();
|
||||
if (x86lo < 0) { g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); return; }
|
||||
if (x86lo < 0)
|
||||
{
|
||||
g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers");
|
||||
return;
|
||||
}
|
||||
SetX86Protected(GetIndexFromX86Reg(x86lo), true);
|
||||
|
||||
m_CodeBlock.Log(" regcache: allocate %s to hi word of %s", CX86Ops::x86_Name(x86Hi), CRegName::GPR[MipsReg]);
|
||||
|
@ -844,14 +940,38 @@ CX86Ops::x86Reg CX86RegInfo::Map_TempReg(CX86Ops::x86Reg Reg, int32_t MipsReg, b
|
|||
{
|
||||
if (!Reg8Bit && Reg == CX86Ops::x86_Unknown)
|
||||
{
|
||||
if (GetX86Mapped(x86RegIndex_EAX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EAX)) { Reg = CX86Ops::x86_EAX; }
|
||||
else if (GetX86Mapped(x86RegIndex_EBX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBX)) { Reg = CX86Ops::x86_EBX; }
|
||||
else if (GetX86Mapped(x86RegIndex_ECX) == Temp_Mapped && !GetX86Protected(x86RegIndex_ECX)) { Reg = CX86Ops::x86_ECX; }
|
||||
else if (GetX86Mapped(x86RegIndex_EDX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDX)) { Reg = CX86Ops::x86_EDX; }
|
||||
else if (GetX86Mapped(x86RegIndex_ESI) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESI)) { Reg = CX86Ops::x86_ESI; }
|
||||
else if (GetX86Mapped(x86RegIndex_EDI) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDI)) { Reg = CX86Ops::x86_EDI; }
|
||||
else if (GetX86Mapped(x86RegIndex_EBP) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBP)) { Reg = CX86Ops::x86_EBP; }
|
||||
else if (GetX86Mapped(x86RegIndex_ESP) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESP)) { Reg = CX86Ops::x86_ESP; }
|
||||
if (GetX86Mapped(x86RegIndex_EAX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EAX))
|
||||
{
|
||||
Reg = CX86Ops::x86_EAX;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_EBX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBX))
|
||||
{
|
||||
Reg = CX86Ops::x86_EBX;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_ECX) == Temp_Mapped && !GetX86Protected(x86RegIndex_ECX))
|
||||
{
|
||||
Reg = CX86Ops::x86_ECX;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_EDX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDX))
|
||||
{
|
||||
Reg = CX86Ops::x86_EDX;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_ESI) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESI))
|
||||
{
|
||||
Reg = CX86Ops::x86_ESI;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_EDI) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDI))
|
||||
{
|
||||
Reg = CX86Ops::x86_EDI;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_EBP) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBP))
|
||||
{
|
||||
Reg = CX86Ops::x86_EBP;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_ESP) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESP))
|
||||
{
|
||||
Reg = CX86Ops::x86_ESP;
|
||||
}
|
||||
|
||||
if (Reg == CX86Ops::x86_Unknown)
|
||||
{
|
||||
|
@ -866,10 +986,22 @@ CX86Ops::x86Reg CX86RegInfo::Map_TempReg(CX86Ops::x86Reg Reg, int32_t MipsReg, b
|
|||
}
|
||||
else if (Reg8Bit && Reg == CX86Ops::x86_Unknown)
|
||||
{
|
||||
if (GetX86Mapped(x86RegIndex_EAX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EAX)) { Reg = CX86Ops::x86_EAX; }
|
||||
else if (GetX86Mapped(x86RegIndex_EBX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBX)) { Reg = CX86Ops::x86_EBX; }
|
||||
else if (GetX86Mapped(x86RegIndex_ECX) == Temp_Mapped && !GetX86Protected(x86RegIndex_ECX)) { Reg = CX86Ops::x86_ECX; }
|
||||
else if (GetX86Mapped(x86RegIndex_EDX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDX)) { Reg = CX86Ops::x86_EDX; }
|
||||
if (GetX86Mapped(x86RegIndex_EAX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EAX))
|
||||
{
|
||||
Reg = CX86Ops::x86_EAX;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_EBX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBX))
|
||||
{
|
||||
Reg = CX86Ops::x86_EBX;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_ECX) == Temp_Mapped && !GetX86Protected(x86RegIndex_ECX))
|
||||
{
|
||||
Reg = CX86Ops::x86_ECX;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_EDX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDX))
|
||||
{
|
||||
Reg = CX86Ops::x86_EDX;
|
||||
}
|
||||
|
||||
if (Reg == CX86Ops::x86_Unknown)
|
||||
{
|
||||
|
@ -1073,9 +1205,15 @@ void CX86RegInfo::UnMap_AllFPRs()
|
|||
int32_t StartPos = StackTopPos();
|
||||
for (int32_t i = 0; i < 8; i++)
|
||||
{
|
||||
if (m_x86fpu_MappedTo[(StartPos + i) & 7] != -1) { m_Assembler.fpuIncStack(&StackTopPos()); }
|
||||
if (m_x86fpu_MappedTo[(StartPos + i) & 7] != -1)
|
||||
{
|
||||
m_Assembler.fpuIncStack(&StackTopPos());
|
||||
}
|
||||
}
|
||||
if (StackPos != StackTopPos())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (StackPos != StackTopPos()) { continue; }
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1085,10 +1223,16 @@ void CX86RegInfo::UnMap_FPR(int32_t Reg, bool WriteBackValue)
|
|||
char Name[50];
|
||||
int32_t i;
|
||||
|
||||
if (Reg < 0) { return; }
|
||||
if (Reg < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (m_x86fpu_MappedTo[i] != Reg) { continue; }
|
||||
if (m_x86fpu_MappedTo[i] != Reg)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
m_CodeBlock.Log(" regcache: unallocate %s from ST(%d)", CRegName::FPR[Reg], (i - StackTopPos() + 8) & 7);
|
||||
if (WriteBackValue)
|
||||
{
|
||||
|
@ -1179,7 +1323,10 @@ void CX86RegInfo::UnMap_GPR(uint32_t Reg, bool WriteBackValue)
|
|||
return;
|
||||
}
|
||||
|
||||
if (IsUnknown(Reg)) { return; }
|
||||
if (IsUnknown(Reg))
|
||||
{
|
||||
return;
|
||||
}
|
||||
//m_CodeBlock.Log("UnMap_GPR: State: %X\tReg: %s\tWriteBack: %s",State,CRegName::GPR[Reg],WriteBackValue?"true":"false");
|
||||
if (IsConst(Reg))
|
||||
{
|
||||
|
@ -1252,14 +1399,38 @@ CX86Ops::x86Reg CX86RegInfo::UnMap_TempReg()
|
|||
{
|
||||
CX86Ops::x86Reg Reg = CX86Ops::x86_Unknown;
|
||||
|
||||
if (GetX86Mapped(x86RegIndex_EAX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EAX)) { Reg = CX86Ops::x86_EAX; }
|
||||
else if (GetX86Mapped(x86RegIndex_EBX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBX)) { Reg = CX86Ops::x86_EBX; }
|
||||
else if (GetX86Mapped(x86RegIndex_ECX) == Temp_Mapped && !GetX86Protected(x86RegIndex_ECX)) { Reg = CX86Ops::x86_ECX; }
|
||||
else if (GetX86Mapped(x86RegIndex_EDX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDX)) { Reg = CX86Ops::x86_EDX; }
|
||||
else if (GetX86Mapped(x86RegIndex_ESI) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESI)) { Reg = CX86Ops::x86_ESI; }
|
||||
else if (GetX86Mapped(x86RegIndex_EDI) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDI)) { Reg = CX86Ops::x86_EDI; }
|
||||
else if (GetX86Mapped(x86RegIndex_EBP) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBP)) { Reg = CX86Ops::x86_EBP; }
|
||||
else if (GetX86Mapped(x86RegIndex_ESP) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESP)) { Reg = CX86Ops::x86_ESP; }
|
||||
if (GetX86Mapped(x86RegIndex_EAX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EAX))
|
||||
{
|
||||
Reg = CX86Ops::x86_EAX;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_EBX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBX))
|
||||
{
|
||||
Reg = CX86Ops::x86_EBX;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_ECX) == Temp_Mapped && !GetX86Protected(x86RegIndex_ECX))
|
||||
{
|
||||
Reg = CX86Ops::x86_ECX;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_EDX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDX))
|
||||
{
|
||||
Reg = CX86Ops::x86_EDX;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_ESI) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESI))
|
||||
{
|
||||
Reg = CX86Ops::x86_ESI;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_EDI) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDI))
|
||||
{
|
||||
Reg = CX86Ops::x86_EDI;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_EBP) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBP))
|
||||
{
|
||||
Reg = CX86Ops::x86_EBP;
|
||||
}
|
||||
else if (GetX86Mapped(x86RegIndex_ESP) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESP))
|
||||
{
|
||||
Reg = CX86Ops::x86_ESP;
|
||||
}
|
||||
|
||||
if (Reg != CX86Ops::x86_Unknown)
|
||||
{
|
||||
|
@ -1338,8 +1509,14 @@ void CX86RegInfo::WriteBackRegisters()
|
|||
bool bEdiZero = false;
|
||||
bool bEsiSign = false;
|
||||
|
||||
for (uint32_t i = 0; i < x86RegIndex_Size; i++) { SetX86Protected((x86RegIndex)i, false); }
|
||||
for (uint32_t i = 0; i < x86RegIndex_Size; i++) { UnMap_X86reg(GetX86RegFromIndex((x86RegIndex)i)); }
|
||||
for (uint32_t i = 0; i < x86RegIndex_Size; i++)
|
||||
{
|
||||
SetX86Protected((x86RegIndex)i, false);
|
||||
}
|
||||
for (uint32_t i = 0; i < x86RegIndex_Size; i++)
|
||||
{
|
||||
UnMap_X86reg(GetX86RegFromIndex((x86RegIndex)i));
|
||||
}
|
||||
|
||||
for (count = 1; count < 32; count++)
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue