Clang format

This commit is contained in:
Clang-Format 2018-04-30 21:01:23 +01:00
parent 2efab18cb5
commit acf75535ec
707 changed files with 21870 additions and 21827 deletions

View file

@ -1,13 +1,12 @@
#include "AppConfig.h"
#include "PathUtils.h"
#define BASE_DATA_PATH (L"Play Data Files")
#define CONFIG_FILENAME (L"config.xml")
#define BASE_DATA_PATH (L"Play Data Files")
#define CONFIG_FILENAME (L"config.xml")
CAppConfig::CAppConfig()
: CConfig(BuildConfigPath())
: CConfig(BuildConfigPath())
{
}
Framework::CConfig::PathType CAppConfig::GetBasePath()

View file

@ -6,11 +6,11 @@
class CAppConfig : public Framework::CConfig, public CSingleton<CAppConfig>
{
public:
CAppConfig();
virtual ~CAppConfig() = default;
CAppConfig();
virtual ~CAppConfig() = default;
static CConfig::PathType GetBasePath();
static CConfig::PathType GetBasePath();
private:
static CConfig::PathType BuildConfigPath();
static CConfig::PathType BuildConfigPath();
};

View file

@ -26,12 +26,13 @@
#pragma pack(push, 1)
struct AOT_BLOCK
{
AOT_BLOCK_KEY key;
void* fct;
AOT_BLOCK_KEY key;
void* fct;
};
#pragma pack(pop)
extern "C" {
extern "C"
{
extern AOT_BLOCK _aot_firstBlock;
extern uint32 _aot_blockCount;
}
@ -39,11 +40,11 @@ extern "C" {
#endif
CBasicBlock::CBasicBlock(CMIPS& context, uint32 begin, uint32 end)
: m_begin(begin)
, m_end(end)
, m_context(context)
: m_begin(begin)
, m_end(end)
, m_context(context)
#ifdef AOT_USE_CACHE
, m_function(nullptr)
, m_function(nullptr)
#endif
{
assert(m_end >= m_begin);
@ -51,8 +52,8 @@ CBasicBlock::CBasicBlock(CMIPS& context, uint32 begin, uint32 end)
#ifdef AOT_BUILD_CACHE
Framework::CStdStream* CBasicBlock::m_aotBlockOutputStream(nullptr);
std::mutex CBasicBlock::m_aotBlockOutputStreamMutex;
Framework::CStdStream* CBasicBlock::m_aotBlockOutputStream(nullptr);
std::mutex CBasicBlock::m_aotBlockOutputStreamMutex;
void CBasicBlock::SetAotBlockOutputStream(Framework::CStdStream* outputStream)
{
@ -70,9 +71,9 @@ void CBasicBlock::Compile()
{
static
#ifdef AOT_BUILD_CACHE
__declspec(thread)
__declspec(thread)
#endif
CMipsJitter* jitter = nullptr;
CMipsJitter* jitter = nullptr;
if(jitter == nullptr)
{
Jitter::CCodeGen* codeGen = Jitter::CreateCodeGen();
@ -81,17 +82,16 @@ void CBasicBlock::Compile()
for(unsigned int i = 0; i < 4; i++)
{
jitter->SetVariableAsConstant(
offsetof(CMIPS, m_State.nGPR[CMIPS::R0].nV[i]),
0
);
offsetof(CMIPS, m_State.nGPR[CMIPS::R0].nV[i]),
0);
}
}
jitter->SetStream(&stream);
jitter->Begin();
CompileRange(jitter);
// codeGen.DumpVariables(0);
// codeGen.EndQuota();
// codeGen.DumpVariables(0);
// codeGen.EndQuota();
jitter->End();
}
@ -137,15 +137,14 @@ void CBasicBlock::Compile()
AOT_BLOCK* blocksBegin = &_aot_firstBlock;
AOT_BLOCK* blocksEnd = blocksBegin + _aot_blockCount;
AOT_BLOCK blockRef = { blockChecksum, m_begin, m_end, nullptr };
AOT_BLOCK blockRef = {blockChecksum, m_begin, m_end, nullptr};
static const auto blockComparer =
[] (const AOT_BLOCK& item1, const AOT_BLOCK& item2)
{
return item1.key < item2.key;
};
[](const AOT_BLOCK& item1, const AOT_BLOCK& item2) {
return item1.key < item2.key;
};
// assert(std::is_sorted(blocksBegin, blocksEnd, blockComparer));
// assert(std::is_sorted(blocksBegin, blocksEnd, blockComparer));
bool blockExists = std::binary_search(blocksBegin, blocksEnd, blockRef, blockComparer);
auto blockIterator = std::lower_bound(blocksBegin, blocksEnd, blockRef, blockComparer);
@ -192,9 +191,9 @@ void CBasicBlock::CompileRange(CMipsJitter* jitter)
for(uint32 address = m_begin; address <= fixedEnd; address += 4)
{
m_context.m_pArch->CompileInstruction(
address,
jitter,
&m_context);
address,
jitter,
&m_context);
//Sanity check
assert(jitter->IsStackEmpty());
}

View file

@ -9,11 +9,11 @@
struct AOT_BLOCK_KEY
{
uint32 crc;
uint32 begin;
uint32 end;
uint32 crc;
uint32 begin;
uint32 end;
bool operator <(const AOT_BLOCK_KEY& k2) const
bool operator<(const AOT_BLOCK_KEY& k2) const
{
const auto& k1 = (*this);
if(k1.crc == k2.crc)
@ -43,36 +43,35 @@ namespace Jitter
class CBasicBlock
{
public:
CBasicBlock(CMIPS&, uint32, uint32);
virtual ~CBasicBlock() = default;
unsigned int Execute();
void Compile();
CBasicBlock(CMIPS&, uint32, uint32);
virtual ~CBasicBlock() = default;
unsigned int Execute();
void Compile();
uint32 GetBeginAddress() const;
uint32 GetEndAddress() const;
bool IsCompiled() const;
uint32 GetBeginAddress() const;
uint32 GetEndAddress() const;
bool IsCompiled() const;
#ifdef AOT_BUILD_CACHE
static void SetAotBlockOutputStream(Framework::CStdStream*);
static void SetAotBlockOutputStream(Framework::CStdStream*);
#endif
protected:
uint32 m_begin;
uint32 m_end;
CMIPS& m_context;
uint32 m_begin;
uint32 m_end;
CMIPS& m_context;
virtual void CompileRange(CMipsJitter*);
virtual void CompileRange(CMipsJitter*);
private:
#ifdef AOT_BUILD_CACHE
static Framework::CStdStream* m_aotBlockOutputStream;
static std::mutex m_aotBlockOutputStreamMutex;
static Framework::CStdStream* m_aotBlockOutputStream;
static std::mutex m_aotBlockOutputStreamMutex;
#endif
#ifndef AOT_USE_CACHE
CMemoryFunction m_function;
CMemoryFunction m_function;
#else
void (*m_function)(void*);
void (*m_function)(void*);
#endif
};

View file

@ -7,10 +7,10 @@
struct BIOS_DEBUG_MODULE_INFO
{
std::string name;
uint32 begin;
uint32 end;
void* param;
std::string name;
uint32 begin;
uint32 end;
void* param;
};
typedef std::vector<BIOS_DEBUG_MODULE_INFO> BiosDebugModuleInfoArray;
@ -18,12 +18,12 @@ typedef BiosDebugModuleInfoArray::iterator BiosDebugModuleInfoIterator;
struct BIOS_DEBUG_THREAD_INFO
{
uint32 id;
uint32 priority;
uint32 pc;
uint32 ra;
uint32 sp;
std::string stateDescription;
uint32 id;
uint32 priority;
uint32 pc;
uint32 ra;
uint32 sp;
std::string stateDescription;
};
typedef std::vector<BIOS_DEBUG_THREAD_INFO> BiosDebugThreadInfoArray;
@ -31,10 +31,12 @@ typedef std::vector<BIOS_DEBUG_THREAD_INFO> BiosDebugThreadInfoArray;
class CBiosDebugInfoProvider
{
public:
virtual ~CBiosDebugInfoProvider() {}
virtual ~CBiosDebugInfoProvider()
{
}
#ifdef DEBUGGER_INCLUDED
virtual BiosDebugModuleInfoArray GetModulesDebugInfo() const = 0;
virtual BiosDebugThreadInfoArray GetThreadsDebugInfo() const = 0;
virtual BiosDebugModuleInfoArray GetModulesDebugInfo() const = 0;
virtual BiosDebugThreadInfoArray GetThreadsDebugInfo() const = 0;
#endif
};

View file

@ -7,19 +7,18 @@
#include "MemoryUtils.h"
const uint32 CCOP_FPU::m_ccMask[8] =
{
0x00800000,
0x02000000,
0x04000000,
0x08000000,
0x10000000,
0x20000000,
0x40000000,
0x80000000
};
{
0x00800000,
0x02000000,
0x04000000,
0x08000000,
0x10000000,
0x20000000,
0x40000000,
0x80000000};
CCOP_FPU::CCOP_FPU(MIPS_REGSIZE regSize)
: CMIPSCoprocessor(regSize)
: CMIPSCoprocessor(regSize)
{
SetupReflectionTables();
}

View file

@ -6,108 +6,108 @@
class CCOP_FPU : public CMIPSCoprocessor
{
public:
CCOP_FPU(MIPS_REGSIZE);
void CompileInstruction(uint32, CMipsJitter*, CMIPS*) override;
void GetInstruction(uint32, char*) override;
void GetArguments(uint32, uint32, char*) override;
uint32 GetEffectiveAddress(uint32, uint32) override;
MIPS_BRANCH_TYPE IsBranch(uint32) override;
CCOP_FPU(MIPS_REGSIZE);
void CompileInstruction(uint32, CMipsJitter*, CMIPS*) override;
void GetInstruction(uint32, char*) override;
void GetArguments(uint32, uint32, char*) override;
uint32 GetEffectiveAddress(uint32, uint32) override;
MIPS_BRANCH_TYPE IsBranch(uint32) override;
protected:
void SetupReflectionTables();
void SetupReflectionTables();
static void ReflOpRtFs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRtFcs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpFdFs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpFdFt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpFsFt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpCcFsFt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpFdFsFt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpFtOffRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpCcOff(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRtFs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRtFcs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpFdFs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpFdFt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpFsFt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpCcFsFt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpFdFsFt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpFtOffRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpCcOff(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static uint32 ReflEaOffset(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32);
static uint32 ReflEaOffset(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32);
MIPSReflection::INSTRUCTION m_reflGeneral[64];
MIPSReflection::INSTRUCTION m_reflCop1[32];
MIPSReflection::INSTRUCTION m_reflBc1[4];
MIPSReflection::INSTRUCTION m_reflS[64];
MIPSReflection::INSTRUCTION m_reflW[64];
MIPSReflection::INSTRUCTION m_reflGeneral[64];
MIPSReflection::INSTRUCTION m_reflCop1[32];
MIPSReflection::INSTRUCTION m_reflBc1[4];
MIPSReflection::INSTRUCTION m_reflS[64];
MIPSReflection::INSTRUCTION m_reflW[64];
MIPSReflection::SUBTABLE m_reflGeneralTable;
MIPSReflection::SUBTABLE m_reflCop1Table;
MIPSReflection::SUBTABLE m_reflBc1Table;
MIPSReflection::SUBTABLE m_reflSTable;
MIPSReflection::SUBTABLE m_reflWTable;
MIPSReflection::SUBTABLE m_reflGeneralTable;
MIPSReflection::SUBTABLE m_reflCop1Table;
MIPSReflection::SUBTABLE m_reflBc1Table;
MIPSReflection::SUBTABLE m_reflSTable;
MIPSReflection::SUBTABLE m_reflWTable;
private:
typedef void (CCOP_FPU::*InstructionFuncConstant)();
uint8 m_ft = 0;
uint8 m_fs = 0;
uint8 m_fd = 0;
uint8 m_ft = 0;
uint8 m_fs = 0;
uint8 m_fd = 0;
static const uint32 m_ccMask[8];
static const uint32 m_ccMask[8];
void SetCCBit(bool, uint32);
void PushCCBit(uint32);
void SetCCBit(bool, uint32);
void PushCCBit(uint32);
static InstructionFuncConstant m_opGeneral[0x20];
static InstructionFuncConstant m_opSingle[0x40];
static InstructionFuncConstant m_opWord[0x40];
static InstructionFuncConstant m_opGeneral[0x20];
static InstructionFuncConstant m_opSingle[0x40];
static InstructionFuncConstant m_opWord[0x40];
//General
void MFC1();
void CFC1();
void MTC1();
void CTC1();
void BC1();
void S();
void W();
void MFC1();
void CFC1();
void MTC1();
void CTC1();
void BC1();
void S();
void W();
//Branch
void BC1F();
void BC1T();
void BC1FL();
void BC1TL();
void BC1F();
void BC1T();
void BC1FL();
void BC1TL();
//Single
void ADD_S();
void SUB_S();
void MUL_S();
void DIV_S();
void SQRT_S();
void ABS_S();
void MOV_S();
void NEG_S();
void TRUNC_W_S();
void RSQRT_S();
void ADDA_S();
void SUBA_S();
void MULA_S();
void MADD_S();
void MSUB_S();
void MADDA_S();
void MSUBA_S();
void CVT_W_S();
void MAX_S();
void MIN_S();
void C_F_S();
void C_EQ_S();
void C_LT_S();
void C_LE_S();
void ADD_S();
void SUB_S();
void MUL_S();
void DIV_S();
void SQRT_S();
void ABS_S();
void MOV_S();
void NEG_S();
void TRUNC_W_S();
void RSQRT_S();
void ADDA_S();
void SUBA_S();
void MULA_S();
void MADD_S();
void MSUB_S();
void MADDA_S();
void MSUBA_S();
void CVT_W_S();
void MAX_S();
void MIN_S();
void C_F_S();
void C_EQ_S();
void C_LT_S();
void C_LE_S();
//Word
void CVT_S_W();
void CVT_S_W();
//Misc
void LWC1();
void SWC1();
void LWC1();
void SWC1();
//Reflection tables
static MIPSReflection::INSTRUCTION m_cReflGeneral[64];
static MIPSReflection::INSTRUCTION m_cReflCop1[32];
static MIPSReflection::INSTRUCTION m_cReflBc1[4];
static MIPSReflection::INSTRUCTION m_cReflS[64];
static MIPSReflection::INSTRUCTION m_cReflW[64];
static MIPSReflection::INSTRUCTION m_cReflGeneral[64];
static MIPSReflection::INSTRUCTION m_cReflCop1[32];
static MIPSReflection::INSTRUCTION m_cReflBc1[4];
static MIPSReflection::INSTRUCTION m_cReflS[64];
static MIPSReflection::INSTRUCTION m_cReflW[64];
};

View file

@ -24,7 +24,7 @@ void CCOP_FPU::ReflOpRtFcs(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress, ui
void CCOP_FPU::ReflOpFdFs(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress, uint32 nOpcode, char* sText, unsigned int nCount)
{
uint8 nFS = static_cast<uint8>((nOpcode >> 11) & 0x001F);
uint8 nFD = static_cast<uint8>((nOpcode >> 6) & 0x001F);
uint8 nFD = static_cast<uint8>((nOpcode >> 6) & 0x001F);
sprintf(sText, "F%i, F%i", nFD, nFS);
}
@ -32,7 +32,7 @@ void CCOP_FPU::ReflOpFdFs(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress, uin
void CCOP_FPU::ReflOpFdFt(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress, uint32 nOpcode, char* sText, unsigned int nCount)
{
uint8 nFT = static_cast<uint8>((nOpcode >> 16) & 0x001F);
uint8 nFD = static_cast<uint8>((nOpcode >> 6) & 0x001F);
uint8 nFD = static_cast<uint8>((nOpcode >> 6) & 0x001F);
sprintf(sText, "F%i, F%i", nFD, nFT);
}
@ -49,7 +49,7 @@ void CCOP_FPU::ReflOpCcFsFt(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress, u
{
uint8 nFT = static_cast<uint8>((nOpcode >> 16) & 0x001F);
uint8 nFS = static_cast<uint8>((nOpcode >> 11) & 0x001F);
uint8 nCC = static_cast<uint8>((nOpcode >> 8) & 0x0007);
uint8 nCC = static_cast<uint8>((nOpcode >> 8) & 0x0007);
sprintf(sText, "CC%i, F%i, F%i", nCC, nFS, nFT);
}
@ -58,30 +58,30 @@ void CCOP_FPU::ReflOpFdFsFt(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress, u
{
uint8 nFT = static_cast<uint8>((nOpcode >> 16) & 0x001F);
uint8 nFS = static_cast<uint8>((nOpcode >> 11) & 0x001F);
uint8 nFD = static_cast<uint8>((nOpcode >> 6) & 0x001F);
uint8 nFD = static_cast<uint8>((nOpcode >> 6) & 0x001F);
sprintf(sText, "F%i, F%i, F%i", nFD, nFS, nFT);
}
void CCOP_FPU::ReflOpFtOffRs(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress, uint32 nOpcode, char* sText, unsigned int nCount)
{
uint8 nRS = static_cast<uint8> ((nOpcode >> 21) & 0x001F);
uint8 nFT = static_cast<uint8> ((nOpcode >> 16) & 0x001F);
uint16 nImm = static_cast<uint16>((nOpcode >> 0) & 0xFFFF);
uint8 nRS = static_cast<uint8>((nOpcode >> 21) & 0x001F);
uint8 nFT = static_cast<uint8>((nOpcode >> 16) & 0x001F);
uint16 nImm = static_cast<uint16>((nOpcode >> 0) & 0xFFFF);
sprintf(sText, "F%i, $%04X(%s)", nFT, nImm, CMIPS::m_sGPRName[nRS]);
}
void CCOP_FPU::ReflOpCcOff(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress, uint32 nOpcode, char* sText, unsigned int nCount)
{
uint16 nImm = static_cast<uint16>((nOpcode >> 0) & 0xFFFF);
uint16 nImm = static_cast<uint16>((nOpcode >> 0) & 0xFFFF);
nAddress += 4;
sprintf(sText, "CC%i, $%08X", (nOpcode >> 18) & 0x07, nAddress + CMIPS::GetBranch(nImm));
}
uint32 CCOP_FPU::ReflEaOffset(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress, uint32 nOpcode)
{
uint16 nImm = static_cast<uint16>((nOpcode >> 0) & 0xFFFF);
uint16 nImm = static_cast<uint16>((nOpcode >> 0) & 0xFFFF);
nAddress += 4;
return (nAddress + CMIPS::GetBranch(nImm));
}
@ -367,43 +367,43 @@ INSTRUCTION CCOP_FPU::m_cReflW[64] =
void CCOP_FPU::SetupReflectionTables()
{
static_assert(sizeof(m_reflGeneral) == sizeof(m_cReflGeneral), "Array sizes don't match");
static_assert(sizeof(m_reflCop1) == sizeof(m_cReflCop1), "Array sizes don't match");
static_assert(sizeof(m_reflBc1) == sizeof(m_cReflBc1), "Array sizes don't match");
static_assert(sizeof(m_reflS) == sizeof(m_cReflS), "Array sizes don't match");
static_assert(sizeof(m_reflW) == sizeof(m_cReflW), "Array sizes don't match");
static_assert(sizeof(m_reflGeneral) == sizeof(m_cReflGeneral), "Array sizes don't match");
static_assert(sizeof(m_reflCop1) == sizeof(m_cReflCop1), "Array sizes don't match");
static_assert(sizeof(m_reflBc1) == sizeof(m_cReflBc1), "Array sizes don't match");
static_assert(sizeof(m_reflS) == sizeof(m_cReflS), "Array sizes don't match");
static_assert(sizeof(m_reflW) == sizeof(m_cReflW), "Array sizes don't match");
memcpy(m_reflGeneral, m_cReflGeneral, sizeof(m_cReflGeneral));
memcpy(m_reflCop1, m_cReflCop1, sizeof(m_cReflCop1));
memcpy(m_reflBc1, m_cReflBc1, sizeof(m_cReflBc1));
memcpy(m_reflS, m_cReflS, sizeof(m_cReflS));
memcpy(m_reflW, m_cReflW, sizeof(m_cReflW));
memcpy(m_reflGeneral, m_cReflGeneral, sizeof(m_cReflGeneral));
memcpy(m_reflCop1, m_cReflCop1, sizeof(m_cReflCop1));
memcpy(m_reflBc1, m_cReflBc1, sizeof(m_cReflBc1));
memcpy(m_reflS, m_cReflS, sizeof(m_cReflS));
memcpy(m_reflW, m_cReflW, sizeof(m_cReflW));
m_reflGeneralTable.nShift = 26;
m_reflGeneralTable.nMask = 0x3F;
m_reflGeneralTable.pTable = m_reflGeneral;
m_reflGeneralTable.nShift = 26;
m_reflGeneralTable.nMask = 0x3F;
m_reflGeneralTable.pTable = m_reflGeneral;
m_reflCop1Table.nShift = 21;
m_reflCop1Table.nMask = 0x1F;
m_reflCop1Table.pTable = m_reflCop1;
m_reflCop1Table.nShift = 21;
m_reflCop1Table.nMask = 0x1F;
m_reflCop1Table.pTable = m_reflCop1;
m_reflBc1Table.nShift = 16;
m_reflBc1Table.nMask = 0x03;
m_reflBc1Table.pTable = m_reflBc1;
m_reflBc1Table.nShift = 16;
m_reflBc1Table.nMask = 0x03;
m_reflBc1Table.pTable = m_reflBc1;
m_reflSTable.nShift = 0;
m_reflSTable.nMask = 0x3F;
m_reflSTable.pTable = m_reflS;
m_reflSTable.nShift = 0;
m_reflSTable.nMask = 0x3F;
m_reflSTable.pTable = m_reflS;
m_reflWTable.nShift = 0;
m_reflWTable.nMask = 0x3F;
m_reflWTable.pTable = m_reflW;
m_reflWTable.nShift = 0;
m_reflWTable.nMask = 0x3F;
m_reflWTable.pTable = m_reflW;
m_reflGeneral[0x11].pSubTable = &m_reflCop1Table;
m_reflGeneral[0x11].pSubTable = &m_reflCop1Table;
m_reflCop1[0x08].pSubTable = &m_reflBc1Table;
m_reflCop1[0x10].pSubTable = &m_reflSTable;
m_reflCop1[0x14].pSubTable = &m_reflWTable;
m_reflCop1[0x08].pSubTable = &m_reflBc1Table;
m_reflCop1[0x10].pSubTable = &m_reflSTable;
m_reflCop1[0x14].pSubTable = &m_reflWTable;
}
void CCOP_FPU::GetInstruction(uint32 nOpcode, char* sText)
@ -416,8 +416,8 @@ void CCOP_FPU::GetInstruction(uint32 nOpcode, char* sText)
}
INSTRUCTION Instr;
Instr.pGetMnemonic = SubTableMnemonic;
Instr.pSubTable = &m_reflGeneralTable;
Instr.pGetMnemonic = SubTableMnemonic;
Instr.pSubTable = &m_reflGeneralTable;
Instr.pGetMnemonic(&Instr, NULL, nOpcode, sText, nCount);
}
@ -431,8 +431,8 @@ void CCOP_FPU::GetArguments(uint32 nAddress, uint32 nOpcode, char* sText)
}
INSTRUCTION Instr;
Instr.pGetOperands = SubTableOperands;
Instr.pSubTable = &m_reflGeneralTable;
Instr.pGetOperands = SubTableOperands;
Instr.pSubTable = &m_reflGeneralTable;
Instr.pGetOperands(&Instr, NULL, nAddress, nOpcode, sText, nCount);
}
@ -441,8 +441,8 @@ MIPS_BRANCH_TYPE CCOP_FPU::IsBranch(uint32 nOpcode)
if(nOpcode == 0) return MIPS_BRANCH_NONE;
INSTRUCTION Instr;
Instr.pIsBranch = SubTableIsBranch;
Instr.pSubTable = &m_reflGeneralTable;
Instr.pIsBranch = SubTableIsBranch;
Instr.pSubTable = &m_reflGeneralTable;
return Instr.pIsBranch(&Instr, NULL, nOpcode);
}
@ -451,7 +451,7 @@ uint32 CCOP_FPU::GetEffectiveAddress(uint32 nAddress, uint32 nOpcode)
if(nOpcode == 0) return 0;
INSTRUCTION Instr;
Instr.pGetEffectiveAddress = SubTableEffAddr;
Instr.pSubTable = &m_reflGeneralTable;
Instr.pGetEffectiveAddress = SubTableEffAddr;
Instr.pSubTable = &m_reflGeneralTable;
return Instr.pGetEffectiveAddress(&Instr, NULL, nAddress, nOpcode);
}

View file

@ -45,9 +45,9 @@ const char* CCOP_SCU::m_sRegName[] =
// clang-format on
CCOP_SCU::CCOP_SCU(MIPS_REGSIZE nRegSize)
: CMIPSCoprocessor(nRegSize)
, m_nRT(0)
, m_nRD(0)
: CMIPSCoprocessor(nRegSize)
, m_nRT(0)
, m_nRD(0)
{
SetupReflectionTables();
}
@ -56,8 +56,8 @@ void CCOP_SCU::CompileInstruction(uint32 nAddress, CMipsJitter* codeGen, CMIPS*
{
SetupQuickVariables(nAddress, codeGen, pCtx);
m_nRT = (uint8)((m_nOpcode >> 16) & 0x1F);
m_nRD = (uint8)((m_nOpcode >> 11) & 0x1F);
m_nRT = (uint8)((m_nOpcode >> 16) & 0x1F);
m_nRD = (uint8)((m_nOpcode >> 11) & 0x1F);
((this)->*(m_pOpGeneral[(m_nOpcode >> 21) & 0x1F]))();
}

View file

@ -9,105 +9,104 @@ class CCOP_SCU : public CMIPSCoprocessor
public:
enum REGISTER
{
COUNT = 0x09,
STATUS = 0x0C,
EPC = 0x0E,
CPCOND0 = 0x15,
ERROREPC = 0x1E,
COUNT = 0x09,
STATUS = 0x0C,
EPC = 0x0E,
CPCOND0 = 0x15,
ERROREPC = 0x1E,
};
struct PCCR : public convertible<uint32>
{
unsigned int reserved0 : 1;
unsigned int exl0 : 1;
unsigned int k0 : 1;
unsigned int s0 : 1;
unsigned int u0 : 1;
unsigned int event0 : 5;
unsigned int reserved1 : 1;
unsigned int exl1 : 1;
unsigned int k1 : 1;
unsigned int s1 : 1;
unsigned int u1 : 1;
unsigned int event1 : 5;
unsigned int reserved2 : 11;
unsigned int cte : 1;
unsigned int reserved0 : 1;
unsigned int exl0 : 1;
unsigned int k0 : 1;
unsigned int s0 : 1;
unsigned int u0 : 1;
unsigned int event0 : 5;
unsigned int reserved1 : 1;
unsigned int exl1 : 1;
unsigned int k1 : 1;
unsigned int s1 : 1;
unsigned int u1 : 1;
unsigned int event1 : 5;
unsigned int reserved2 : 11;
unsigned int cte : 1;
};
static_assert(sizeof(PCCR) == 4, "PCCR must be 4 bytes long.");
CCOP_SCU(MIPS_REGSIZE);
virtual void CompileInstruction(uint32, CMipsJitter*, CMIPS*) override;
virtual void GetInstruction(uint32, char*) override;
virtual void GetArguments(uint32, uint32, char*) override;
virtual uint32 GetEffectiveAddress(uint32, uint32) override;
virtual MIPS_BRANCH_TYPE IsBranch(uint32) override;
CCOP_SCU(MIPS_REGSIZE);
virtual void CompileInstruction(uint32, CMipsJitter*, CMIPS*) override;
virtual void GetInstruction(uint32, char*) override;
virtual void GetArguments(uint32, uint32, char*) override;
virtual uint32 GetEffectiveAddress(uint32, uint32) override;
virtual MIPS_BRANCH_TYPE IsBranch(uint32) override;
static const char* m_sRegName[];
static const char* m_sRegName[];
protected:
void SetupReflectionTables();
void SetupReflectionTables();
static void ReflOpRt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRtPcr(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRtRd(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpCcOff(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRtPcr(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRtRd(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpCcOff(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static uint32 ReflEaOffset(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32);
static uint32 ReflEaOffset(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32);
MIPSReflection::INSTRUCTION m_ReflGeneral[64];
MIPSReflection::INSTRUCTION m_ReflMfc0[32];
MIPSReflection::INSTRUCTION m_ReflMtc0[32];
MIPSReflection::INSTRUCTION m_ReflCop0[32];
MIPSReflection::INSTRUCTION m_ReflBc0[4];
MIPSReflection::INSTRUCTION m_ReflC0[64];
MIPSReflection::INSTRUCTION m_ReflMfPerf[2];
MIPSReflection::INSTRUCTION m_ReflMtPerf[2];
MIPSReflection::SUBTABLE m_ReflGeneralTable;
MIPSReflection::SUBTABLE m_ReflMfc0Table;
MIPSReflection::SUBTABLE m_ReflMtc0Table;
MIPSReflection::SUBTABLE m_ReflCop0Table;
MIPSReflection::SUBTABLE m_ReflBc0Table;
MIPSReflection::SUBTABLE m_ReflC0Table;
MIPSReflection::SUBTABLE m_ReflMfPerfTable;
MIPSReflection::SUBTABLE m_ReflMtPerfTable;
MIPSReflection::INSTRUCTION m_ReflGeneral[64];
MIPSReflection::INSTRUCTION m_ReflMfc0[32];
MIPSReflection::INSTRUCTION m_ReflMtc0[32];
MIPSReflection::INSTRUCTION m_ReflCop0[32];
MIPSReflection::INSTRUCTION m_ReflBc0[4];
MIPSReflection::INSTRUCTION m_ReflC0[64];
MIPSReflection::INSTRUCTION m_ReflMfPerf[2];
MIPSReflection::INSTRUCTION m_ReflMtPerf[2];
MIPSReflection::SUBTABLE m_ReflGeneralTable;
MIPSReflection::SUBTABLE m_ReflMfc0Table;
MIPSReflection::SUBTABLE m_ReflMtc0Table;
MIPSReflection::SUBTABLE m_ReflCop0Table;
MIPSReflection::SUBTABLE m_ReflBc0Table;
MIPSReflection::SUBTABLE m_ReflC0Table;
MIPSReflection::SUBTABLE m_ReflMfPerfTable;
MIPSReflection::SUBTABLE m_ReflMtPerfTable;
private:
typedef void (CCOP_SCU::*InstructionFuncConstant)();
static InstructionFuncConstant m_pOpGeneral[0x20];
static InstructionFuncConstant m_pOpMtc0[0x20];
static InstructionFuncConstant m_pOpBC0[0x20];
static InstructionFuncConstant m_pOpC0[0x40];
static InstructionFuncConstant m_pOpGeneral[0x20];
static InstructionFuncConstant m_pOpMtc0[0x20];
static InstructionFuncConstant m_pOpBC0[0x20];
static InstructionFuncConstant m_pOpC0[0x40];
uint8 m_nRT;
uint8 m_nRD;
uint8 m_nRT;
uint8 m_nRD;
//General
void MFC0();
void MTC0();
void BC0();
void C0();
void MFC0();
void MTC0();
void BC0();
void C0();
//BC0
void BC0F();
void BC0T();
void BC0FL();
void BC0F();
void BC0T();
void BC0FL();
//C0
void TLBWI();
void ERET();
void EI();
void DI();
void TLBWI();
void ERET();
void EI();
void DI();
//Reflection tables
static MIPSReflection::INSTRUCTION m_cReflGeneral[64];
static MIPSReflection::INSTRUCTION m_cReflCop0[32];
static MIPSReflection::INSTRUCTION m_cReflMfc0[32];
static MIPSReflection::INSTRUCTION m_cReflMtc0[32];
static MIPSReflection::INSTRUCTION m_cReflBc0[4];
static MIPSReflection::INSTRUCTION m_cReflC0[64];
static MIPSReflection::INSTRUCTION m_cReflMfPerf[2];
static MIPSReflection::INSTRUCTION m_cReflMtPerf[2];
static MIPSReflection::INSTRUCTION m_cReflGeneral[64];
static MIPSReflection::INSTRUCTION m_cReflCop0[32];
static MIPSReflection::INSTRUCTION m_cReflMfc0[32];
static MIPSReflection::INSTRUCTION m_cReflMtc0[32];
static MIPSReflection::INSTRUCTION m_cReflBc0[4];
static MIPSReflection::INSTRUCTION m_cReflC0[64];
static MIPSReflection::INSTRUCTION m_cReflMfPerf[2];
static MIPSReflection::INSTRUCTION m_cReflMtPerf[2];
};

View file

@ -30,14 +30,14 @@ void CCOP_SCU::ReflOpRtRd(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress, uin
void CCOP_SCU::ReflOpCcOff(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress, uint32 nOpcode, char* sText, unsigned int nCount)
{
uint16 nImm = static_cast<uint16>((nOpcode >> 0) & 0xFFFF);
uint16 nImm = static_cast<uint16>((nOpcode >> 0) & 0xFFFF);
nAddress += 4;
sprintf(sText, "CC%i, $%08X", (nOpcode >> 18) & 0x07, nAddress + CMIPS::GetBranch(nImm));
}
uint32 CCOP_SCU::ReflEaOffset(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress, uint32 nOpcode)
{
uint16 nImm = static_cast<uint16>((nOpcode >> 0) & 0xFFFF);
uint16 nImm = static_cast<uint16>((nOpcode >> 0) & 0xFFFF);
nAddress += 4;
return (nAddress + CMIPS::GetBranch(nImm));
}
@ -339,66 +339,66 @@ INSTRUCTION CCOP_SCU::m_cReflMtPerf[2] =
void CCOP_SCU::SetupReflectionTables()
{
static_assert(sizeof(m_ReflGeneral) == sizeof(m_cReflGeneral), "Array sizes don't match");
static_assert(sizeof(m_ReflCop0) == sizeof(m_cReflCop0), "Array sizes don't match");
static_assert(sizeof(m_ReflMfc0) == sizeof(m_cReflMfc0), "Array sizes don't match");
static_assert(sizeof(m_ReflMtc0) == sizeof(m_cReflMtc0), "Array sizes don't match");
static_assert(sizeof(m_ReflBc0) == sizeof(m_cReflBc0), "Array sizes don't match");
static_assert(sizeof(m_ReflC0) == sizeof(m_cReflC0), "Array sizes don't match");
static_assert(sizeof(m_ReflMtPerf) == sizeof(m_cReflMtPerf), "Array sizes don't match");
static_assert(sizeof(m_ReflMfPerf) == sizeof(m_cReflMfPerf), "Array sizes don't match");
static_assert(sizeof(m_ReflGeneral) == sizeof(m_cReflGeneral), "Array sizes don't match");
static_assert(sizeof(m_ReflCop0) == sizeof(m_cReflCop0), "Array sizes don't match");
static_assert(sizeof(m_ReflMfc0) == sizeof(m_cReflMfc0), "Array sizes don't match");
static_assert(sizeof(m_ReflMtc0) == sizeof(m_cReflMtc0), "Array sizes don't match");
static_assert(sizeof(m_ReflBc0) == sizeof(m_cReflBc0), "Array sizes don't match");
static_assert(sizeof(m_ReflC0) == sizeof(m_cReflC0), "Array sizes don't match");
static_assert(sizeof(m_ReflMtPerf) == sizeof(m_cReflMtPerf), "Array sizes don't match");
static_assert(sizeof(m_ReflMfPerf) == sizeof(m_cReflMfPerf), "Array sizes don't match");
memcpy(m_ReflGeneral, m_cReflGeneral, sizeof(m_cReflGeneral));
memcpy(m_ReflCop0, m_cReflCop0, sizeof(m_cReflCop0));
memcpy(m_ReflMtc0, m_cReflMtc0, sizeof(m_cReflMtc0));
memcpy(m_ReflMfc0, m_cReflMfc0, sizeof(m_cReflMfc0));
memcpy(m_ReflBc0, m_cReflBc0, sizeof(m_cReflBc0));
memcpy(m_ReflC0, m_cReflC0, sizeof(m_cReflC0));
memcpy(m_ReflMtPerf, m_cReflMtPerf, sizeof(m_cReflMtPerf));
memcpy(m_ReflMfPerf, m_cReflMfPerf, sizeof(m_cReflMfPerf));
memcpy(m_ReflGeneral, m_cReflGeneral, sizeof(m_cReflGeneral));
memcpy(m_ReflCop0, m_cReflCop0, sizeof(m_cReflCop0));
memcpy(m_ReflMtc0, m_cReflMtc0, sizeof(m_cReflMtc0));
memcpy(m_ReflMfc0, m_cReflMfc0, sizeof(m_cReflMfc0));
memcpy(m_ReflBc0, m_cReflBc0, sizeof(m_cReflBc0));
memcpy(m_ReflC0, m_cReflC0, sizeof(m_cReflC0));
memcpy(m_ReflMtPerf, m_cReflMtPerf, sizeof(m_cReflMtPerf));
memcpy(m_ReflMfPerf, m_cReflMfPerf, sizeof(m_cReflMfPerf));
m_ReflGeneralTable.nShift = 26;
m_ReflGeneralTable.nMask = 0x3F;
m_ReflGeneralTable.pTable = m_ReflGeneral;
m_ReflGeneralTable.nShift = 26;
m_ReflGeneralTable.nMask = 0x3F;
m_ReflGeneralTable.pTable = m_ReflGeneral;
m_ReflCop0Table.nShift = 21;
m_ReflCop0Table.nMask = 0x1F;
m_ReflCop0Table.pTable = m_ReflCop0;
m_ReflCop0Table.nShift = 21;
m_ReflCop0Table.nMask = 0x1F;
m_ReflCop0Table.pTable = m_ReflCop0;
m_ReflMfc0Table.nShift = 11;
m_ReflMfc0Table.nMask = 0x1F;
m_ReflMfc0Table.pTable = m_ReflMfc0;
m_ReflMfc0Table.nShift = 11;
m_ReflMfc0Table.nMask = 0x1F;
m_ReflMfc0Table.pTable = m_ReflMfc0;
m_ReflMtc0Table.nShift = 11;
m_ReflMtc0Table.nMask = 0x1F;
m_ReflMtc0Table.pTable = m_ReflMtc0;
m_ReflMtc0Table.nShift = 11;
m_ReflMtc0Table.nMask = 0x1F;
m_ReflMtc0Table.pTable = m_ReflMtc0;
m_ReflBc0Table.nShift = 16;
m_ReflBc0Table.nMask = 0x03;
m_ReflBc0Table.pTable = m_ReflBc0;
m_ReflBc0Table.nShift = 16;
m_ReflBc0Table.nMask = 0x03;
m_ReflBc0Table.pTable = m_ReflBc0;
m_ReflC0Table.nShift = 0;
m_ReflC0Table.nMask = 0x3F;
m_ReflC0Table.pTable = m_ReflC0;
m_ReflC0Table.nShift = 0;
m_ReflC0Table.nMask = 0x3F;
m_ReflC0Table.pTable = m_ReflC0;
m_ReflMfPerfTable.nShift = 0;
m_ReflMfPerfTable.nMask = 1;
m_ReflMfPerfTable.pTable = m_ReflMfPerf;
m_ReflMfPerfTable.nShift = 0;
m_ReflMfPerfTable.nMask = 1;
m_ReflMfPerfTable.pTable = m_ReflMfPerf;
m_ReflMtPerfTable.nShift = 0;
m_ReflMtPerfTable.nMask = 1;
m_ReflMtPerfTable.pTable = m_ReflMtPerf;
m_ReflMtPerfTable.nShift = 0;
m_ReflMtPerfTable.nMask = 1;
m_ReflMtPerfTable.pTable = m_ReflMtPerf;
m_ReflGeneral[0x10].pSubTable = &m_ReflCop0Table;
m_ReflGeneral[0x10].pSubTable = &m_ReflCop0Table;
m_ReflCop0[0x00].pSubTable = &m_ReflMfc0Table;
m_ReflCop0[0x04].pSubTable = &m_ReflMtc0Table;
m_ReflCop0[0x08].pSubTable = &m_ReflBc0Table;
m_ReflCop0[0x10].pSubTable = &m_ReflC0Table;
m_ReflCop0[0x00].pSubTable = &m_ReflMfc0Table;
m_ReflCop0[0x04].pSubTable = &m_ReflMtc0Table;
m_ReflCop0[0x08].pSubTable = &m_ReflBc0Table;
m_ReflCop0[0x10].pSubTable = &m_ReflC0Table;
m_ReflMfc0[0x19].pSubTable = &m_ReflMfPerfTable;
m_ReflMfc0[0x19].pSubTable = &m_ReflMfPerfTable;
m_ReflMtc0[0x19].pSubTable = &m_ReflMtPerfTable;
m_ReflMtc0[0x19].pSubTable = &m_ReflMtPerfTable;
}
void CCOP_SCU::GetInstruction(uint32 nOpcode, char* sText)
@ -411,8 +411,8 @@ void CCOP_SCU::GetInstruction(uint32 nOpcode, char* sText)
}
INSTRUCTION Instr;
Instr.pGetMnemonic = SubTableMnemonic;
Instr.pSubTable = &m_ReflGeneralTable;
Instr.pGetMnemonic = SubTableMnemonic;
Instr.pSubTable = &m_ReflGeneralTable;
Instr.pGetMnemonic(&Instr, NULL, nOpcode, sText, nCount);
}
@ -426,8 +426,8 @@ void CCOP_SCU::GetArguments(uint32 nAddress, uint32 nOpcode, char* sText)
}
INSTRUCTION Instr;
Instr.pGetOperands = SubTableOperands;
Instr.pSubTable = &m_ReflGeneralTable;
Instr.pGetOperands = SubTableOperands;
Instr.pSubTable = &m_ReflGeneralTable;
Instr.pGetOperands(&Instr, NULL, nAddress, nOpcode, sText, nCount);
}
@ -436,8 +436,8 @@ MIPS_BRANCH_TYPE CCOP_SCU::IsBranch(uint32 nOpcode)
if(nOpcode == 0) return MIPS_BRANCH_NONE;
INSTRUCTION Instr;
Instr.pIsBranch = SubTableIsBranch;
Instr.pSubTable = &m_ReflGeneralTable;
Instr.pIsBranch = SubTableIsBranch;
Instr.pSubTable = &m_ReflGeneralTable;
return Instr.pIsBranch(&Instr, NULL, nOpcode);
}
@ -446,7 +446,7 @@ uint32 CCOP_SCU::GetEffectiveAddress(uint32 nAddress, uint32 nOpcode)
if(nOpcode == 0) return 0;
INSTRUCTION Instr;
Instr.pGetEffectiveAddress = SubTableEffAddr;
Instr.pSubTable = &m_ReflGeneralTable;
Instr.pGetEffectiveAddress = SubTableEffAddr;
Instr.pSubTable = &m_ReflGeneralTable;
return Instr.pGetEffectiveAddress(&Instr, NULL, nAddress, nOpcode);
}

View file

@ -3,34 +3,32 @@
using namespace PS2;
const char* CControllerInfo::m_buttonName[CControllerInfo::MAX_BUTTONS] =
{
"analog_left_x",
"analog_left_y",
"analog_right_x",
"analog_right_y",
"dpad_up",
"dpad_down",
"dpad_left",
"dpad_right",
"select",
"start",
"square",
"triangle",
"circle",
"cross",
"l1",
"l2",
"l3",
"r1",
"r2",
"r3"
};
{
"analog_left_x",
"analog_left_y",
"analog_right_x",
"analog_right_y",
"dpad_up",
"dpad_down",
"dpad_left",
"dpad_right",
"select",
"start",
"square",
"triangle",
"circle",
"cross",
"l1",
"l2",
"l3",
"r1",
"r2",
"r3"};
bool CControllerInfo::IsAxis(BUTTON button)
{
return
(button == ANALOG_LEFT_X) ||
(button == ANALOG_LEFT_Y) ||
(button == ANALOG_RIGHT_X) ||
(button == ANALOG_RIGHT_Y);
return (button == ANALOG_LEFT_X) ||
(button == ANALOG_LEFT_Y) ||
(button == ANALOG_RIGHT_X) ||
(button == ANALOG_RIGHT_Y);
}

View file

@ -32,8 +32,8 @@ namespace PS2
MAX_BUTTONS
};
static const char* m_buttonName[MAX_BUTTONS];
static const char* m_buttonName[MAX_BUTTONS];
static bool IsAxis(BUTTON);
static bool IsAxis(BUTTON);
};
};

View file

@ -22,7 +22,11 @@ struct CsoHeader
};
CCsoImageStream::CCsoImageStream(CStream* baseStream)
: m_baseStream(baseStream), m_readBuffer(nullptr), m_zlibBuffer(nullptr), m_index(nullptr), m_position(0)
: m_baseStream(baseStream)
, m_readBuffer(nullptr)
, m_zlibBuffer(nullptr)
, m_index(nullptr)
, m_position(0)
{
if(baseStream == nullptr)
{
@ -35,9 +39,9 @@ CCsoImageStream::CCsoImageStream(CStream* baseStream)
CCsoImageStream::~CCsoImageStream()
{
delete [] m_readBuffer;
delete [] m_zlibBuffer;
delete [] m_index;
delete[] m_readBuffer;
delete[] m_zlibBuffer;
delete[] m_index;
}
void CCsoImageStream::ReadFileHeader()
@ -106,7 +110,7 @@ void CCsoImageStream::InitializeBuffers()
void CCsoImageStream::Seek(int64 position, Framework::STREAM_SEEK_DIRECTION origin)
{
switch (origin)
switch(origin)
{
case Framework::STREAM_SEEK_CUR:
m_position += position;

View file

@ -6,31 +6,31 @@
class CCsoImageStream : public Framework::CStream
{
public:
CCsoImageStream(Framework::CStream* baseStream);
virtual ~CCsoImageStream();
CCsoImageStream(Framework::CStream* baseStream);
virtual ~CCsoImageStream();
virtual void Seek(int64 pos, Framework::STREAM_SEEK_DIRECTION whence) override;
virtual uint64 Tell() override;
virtual bool IsEOF() override;
virtual uint64 Read(void* dest, uint64 bytes) override;
virtual uint64 Write(const void* src, uint64 bytes) override;
virtual void Seek(int64 pos, Framework::STREAM_SEEK_DIRECTION whence) override;
virtual uint64 Tell() override;
virtual bool IsEOF() override;
virtual uint64 Read(void* dest, uint64 bytes) override;
virtual uint64 Write(const void* src, uint64 bytes) override;
private:
void ReadFileHeader();
void InitializeBuffers();
uint64 GetTotalSize() const;
uint32 ReadFromNextFrame(uint8* dest, uint64 maxBytes);
uint64 ReadBaseAt(uint64 pos, uint8* dest, uint64 bytes);
void DecompressFrame(uint32 frame, uint64 readBufferSize);
void ReadFileHeader();
void InitializeBuffers();
uint64 GetTotalSize() const;
uint32 ReadFromNextFrame(uint8* dest, uint64 maxBytes);
uint64 ReadBaseAt(uint64 pos, uint8* dest, uint64 bytes);
void DecompressFrame(uint32 frame, uint64 readBufferSize);
Framework::CStream* m_baseStream;
uint32 m_frameSize;
uint8 m_frameShift;
uint8 m_indexShift;
uint8* m_readBuffer;
uint8* m_zlibBuffer;
uint32 m_zlibBufferFrame;
uint32* m_index;
uint64 m_totalSize;
uint64 m_position;
Framework::CStream* m_baseStream;
uint32 m_frameSize;
uint8 m_frameShift;
uint8 m_indexShift;
uint8* m_readBuffer;
uint8* m_zlibBuffer;
uint32 m_zlibBufferFrame;
uint32* m_index;
uint64 m_totalSize;
uint64 m_position;
};

View file

@ -10,8 +10,8 @@ namespace DiskUtils
typedef std::unique_ptr<COpticalMedia> OpticalMediaPtr;
typedef std::map<std::string, std::string> SystemConfigMap;
OpticalMediaPtr CreateOpticalMediaFromPath(const boost::filesystem::path&);
SystemConfigMap ParseSystemConfigFile(Framework::CStream*);
OpticalMediaPtr CreateOpticalMediaFromPath(const boost::filesystem::path&);
SystemConfigMap ParseSystemConfigFile(Framework::CStream*);
bool TryGetDiskId(const boost::filesystem::path&, std::string*);
bool TryGetDiskId(const boost::filesystem::path&, std::string*);
}

View file

@ -5,7 +5,7 @@
#include "PtrStream.h"
CELF::CELF(uint8* content)
: m_content(content)
: m_content(content)
{
Framework::CPtrStream stream(m_content, -1);
@ -46,8 +46,8 @@ CELF::CELF(uint8* content)
CELF::~CELF()
{
delete [] m_pProgram;
delete [] m_pSection;
delete[] m_pProgram;
delete[] m_pSection;
}
uint8* CELF::GetContent() const

View file

@ -7,56 +7,56 @@
struct ELFSYMBOL
{
uint32 nName;
uint32 nValue;
uint32 nSize;
uint8 nInfo;
uint8 nOther;
uint16 nSectionIndex;
uint32 nName;
uint32 nValue;
uint32 nSize;
uint8 nInfo;
uint8 nOther;
uint16 nSectionIndex;
};
struct ELFHEADER
{
uint8 nId[16];
uint16 nType;
uint16 nCPU;
uint32 nVersion;
uint32 nEntryPoint;
uint32 nProgHeaderStart;
uint32 nSectHeaderStart;
uint32 nFlags;
uint16 nSize;
uint16 nProgHeaderEntrySize;
uint16 nProgHeaderCount;
uint16 nSectHeaderEntrySize;
uint16 nSectHeaderCount;
uint16 nSectHeaderStringTableIndex;
uint8 nId[16];
uint16 nType;
uint16 nCPU;
uint32 nVersion;
uint32 nEntryPoint;
uint32 nProgHeaderStart;
uint32 nSectHeaderStart;
uint32 nFlags;
uint16 nSize;
uint16 nProgHeaderEntrySize;
uint16 nProgHeaderCount;
uint16 nSectHeaderEntrySize;
uint16 nSectHeaderCount;
uint16 nSectHeaderStringTableIndex;
};
struct ELFSECTIONHEADER
{
uint32 nStringTableIndex;
uint32 nType;
uint32 nFlags;
uint32 nStart;
uint32 nOffset;
uint32 nSize;
uint32 nIndex;
uint32 nInfo;
uint32 nAlignment;
uint32 nOther;
uint32 nStringTableIndex;
uint32 nType;
uint32 nFlags;
uint32 nStart;
uint32 nOffset;
uint32 nSize;
uint32 nIndex;
uint32 nInfo;
uint32 nAlignment;
uint32 nOther;
};
struct ELFPROGRAMHEADER
{
uint32 nType;
uint32 nOffset;
uint32 nVAddress;
uint32 nPAddress;
uint32 nFileSize;
uint32 nMemorySize;
uint32 nFlags;
uint32 nAlignment;
uint32 nType;
uint32 nOffset;
uint32 nVAddress;
uint32 nPAddress;
uint32 nFileSize;
uint32 nMemorySize;
uint32 nFlags;
uint32 nAlignment;
};
#pragma pack(pop)
@ -66,75 +66,75 @@ class CELF
public:
enum EXECUTABLE_TYPE
{
ET_NONE = 0,
ET_REL = 1,
ET_EXEC = 2,
ET_DYN = 3,
ET_CORE = 4,
ET_NONE = 0,
ET_REL = 1,
ET_EXEC = 2,
ET_DYN = 3,
ET_CORE = 4,
};
enum MACHINE_TYPE
{
EM_NONE = 0,
EM_M32 = 1,
EM_SPARC = 2,
EM_386 = 3,
EM_68K = 4,
EM_88K = 5,
EM_860 = 7,
EM_MIPS = 8,
EM_ARM = 40,
EM_NONE = 0,
EM_M32 = 1,
EM_SPARC = 2,
EM_386 = 3,
EM_68K = 4,
EM_88K = 5,
EM_860 = 7,
EM_MIPS = 8,
EM_ARM = 40,
};
enum EXECUTABLE_VERSION
{
EV_NONE = 0,
EV_CURRENT = 1,
EV_NONE = 0,
EV_CURRENT = 1,
};
enum SECTION_HEADER_TYPE
{
SHT_NULL = 0,
SHT_PROGBITS = 1,
SHT_SYMTAB = 2,
SHT_STRTAB = 3,
SHT_HASH = 5,
SHT_DYNAMIC = 6,
SHT_NOTE = 7,
SHT_NOBITS = 8,
SHT_REL = 9,
SHT_DYNSYM = 11,
SHT_NULL = 0,
SHT_PROGBITS = 1,
SHT_SYMTAB = 2,
SHT_STRTAB = 3,
SHT_HASH = 5,
SHT_DYNAMIC = 6,
SHT_NOTE = 7,
SHT_NOBITS = 8,
SHT_REL = 9,
SHT_DYNSYM = 11,
};
enum PROGRAM_HEADER_TYPE
{
PT_NULL = 0,
PT_LOAD = 1,
PT_DYNAMIC = 2,
PT_INTERP = 3,
PT_NOTE = 4,
PT_SHLIB = 5,
PT_PHDR = 6,
PT_NULL = 0,
PT_LOAD = 1,
PT_DYNAMIC = 2,
PT_INTERP = 3,
PT_NOTE = 4,
PT_SHLIB = 5,
PT_PHDR = 6,
};
enum PROGRAM_HEADER_FLAG
{
PF_X = 0x01,
PF_W = 0x02,
PF_R = 0x04,
PF_X = 0x01,
PF_W = 0x02,
PF_R = 0x04,
};
enum DYNAMIC_INFO_TYPE
{
DT_NONE = 0,
DT_NEEDED = 1,
DT_PLTRELSZ = 2,
DT_PLTGOT = 3,
DT_HASH = 4,
DT_STRTAB = 5,
DT_SYMTAB = 6,
DT_SONAME = 14,
DT_SYMBOLIC = 16,
DT_NONE = 0,
DT_NEEDED = 1,
DT_PLTRELSZ = 2,
DT_PLTGOT = 3,
DT_HASH = 4,
DT_STRTAB = 5,
DT_SYMTAB = 6,
DT_SONAME = 14,
DT_SYMBOLIC = 16,
};
enum MIPS_RELOCATION_TYPE
@ -146,29 +146,29 @@ public:
R_MIPS_GPREL16 = 7,
};
CELF(uint8*);
CELF(const CELF&) = delete;
virtual ~CELF();
CELF(uint8*);
CELF(const CELF&) = delete;
virtual ~CELF();
CELF& operator =(const CELF&) = delete;
CELF& operator=(const CELF&) = delete;
uint8* GetContent() const;
const ELFHEADER& GetHeader() const;
uint8* GetContent() const;
const ELFHEADER& GetHeader() const;
ELFSECTIONHEADER* GetSection(unsigned int);
const void* GetSectionData(unsigned int);
const char* GetSectionName(unsigned int);
ELFSECTIONHEADER* GetSection(unsigned int);
const void* GetSectionData(unsigned int);
const char* GetSectionName(unsigned int);
ELFSECTIONHEADER* FindSection(const char*);
unsigned int FindSectionIndex(const char*);
const void* FindSectionData(const char*);
ELFSECTIONHEADER* FindSection(const char*);
unsigned int FindSectionIndex(const char*);
const void* FindSectionData(const char*);
ELFPROGRAMHEADER* GetProgram(unsigned int);
ELFPROGRAMHEADER* GetProgram(unsigned int);
private:
ELFHEADER m_Header;
uint8* m_content = nullptr;
ELFHEADER m_Header;
uint8* m_content = nullptr;
ELFSECTIONHEADER* m_pSection = nullptr;
ELFPROGRAMHEADER* m_pProgram = nullptr;
ELFSECTIONHEADER* m_pSection = nullptr;
ELFPROGRAMHEADER* m_pProgram = nullptr;
};

View file

@ -1,18 +1,15 @@
#include "ElfFile.h"
CElfFile::CElfFile(Framework::CStream& stream)
: CElfFileContainer(stream)
, CELF(GetFileContent())
: CElfFileContainer(stream)
, CELF(GetFileContent())
{
}
CElfFile::~CElfFile()
{
}
CElfFileContainer::CElfFileContainer(Framework::CStream& input)
{
uint32 size = static_cast<uint32>(input.GetLength());
@ -22,7 +19,7 @@ CElfFileContainer::CElfFileContainer(Framework::CStream& input)
CElfFileContainer::~CElfFileContainer()
{
delete [] m_content;
delete[] m_content;
}
uint8* CElfFileContainer::GetFileContent() const

View file

@ -6,24 +6,22 @@
class CElfFileContainer
{
public:
CElfFileContainer(Framework::CStream&);
virtual ~CElfFileContainer();
CElfFileContainer(Framework::CStream&);
virtual ~CElfFileContainer();
uint8* GetFileContent() const;
uint8* GetFileContent() const;
private:
uint8* m_content;
uint8* m_content;
};
class CElfFile : protected CElfFileContainer, public CELF
{
public:
CElfFile(Framework::CStream&);
virtual ~CElfFile();
CElfFile(Framework::CStream&);
virtual ~CElfFile();
private:
};
#endif

View file

@ -2,14 +2,14 @@
#include "MemoryStateFile.h"
#include "RegisterStateFile.h"
#define STATE_INITIAL_GSRAM "init/gsram"
#define STATE_INITIAL_GSREGS "init/gsregs"
#define STATE_INITIAL_GSPRIVREGS "init/gsprivregs"
#define STATE_PACKET_METADATA_PREFIX "packet_metadata_"
#define STATE_INITIAL_GSRAM "init/gsram"
#define STATE_INITIAL_GSREGS "init/gsregs"
#define STATE_INITIAL_GSPRIVREGS "init/gsprivregs"
#define STATE_PACKET_METADATA_PREFIX "packet_metadata_"
#define STATE_PACKET_REGISTERWRITES_PREFIX "packet_registerwrites_"
#define STATE_PACKET_IMAGEDATA_PREFIX "packet_imagedata_"
#define STATE_PACKET_IMAGEDATA_PREFIX "packet_imagedata_"
#define STATE_PRIVREG_SMODE2 "SMODE2"
#define STATE_PRIVREG_SMODE2 "SMODE2"
CFrameDump::CFrameDump()
{
@ -19,7 +19,7 @@ CFrameDump::CFrameDump()
CFrameDump::~CFrameDump()
{
delete [] m_initialGsRam;
delete[] m_initialGsRam;
}
void CFrameDump::Reset()
@ -135,8 +135,8 @@ void CFrameDump::Write(Framework::CStream& output) const
{
Framework::CZipArchiveWriter archive;
archive.InsertFile(new CMemoryStateFile(STATE_INITIAL_GSRAM, m_initialGsRam, CGSHandler::RAMSIZE));
archive.InsertFile(new CMemoryStateFile(STATE_INITIAL_GSREGS, m_initialGsRegisters, sizeof(uint64) * CGSHandler::REGISTER_MAX));
archive.InsertFile(new CMemoryStateFile(STATE_INITIAL_GSRAM, m_initialGsRam, CGSHandler::RAMSIZE));
archive.InsertFile(new CMemoryStateFile(STATE_INITIAL_GSREGS, m_initialGsRegisters, sizeof(uint64) * CGSHandler::REGISTER_MAX));
{
auto privRegsStateFile = new CRegisterStateFile(STATE_INITIAL_GSPRIVREGS);
@ -171,8 +171,8 @@ void CFrameDump::IdentifyDrawingKicks()
DRAWINGKICK_INFO drawingKickInfo;
static const unsigned int g_initVertexCounts[8] = { 1, 2, 2, 3, 3, 3, 2, 0 };
static const unsigned int g_nextVertexCounts[8] = { 1, 2, 1, 3, 1, 1, 2, 0 };
static const unsigned int g_initVertexCounts[8] = {1, 2, 2, 3, 3, 3, 2, 0};
static const unsigned int g_nextVertexCounts[8] = {1, 2, 1, 3, 1, 1, 2, 0};
CGSHandler::PRIM currentPrim;
currentPrim <<= GetInitialGsRegisters()[GS_REG_PRIM];
@ -194,16 +194,16 @@ void CFrameDump::IdentifyDrawingKicks()
vertexCount = g_initVertexCounts[currentPrim.nType];
}
else if(
(registerWrite.first == GS_REG_XYOFFSET_1) ||
(registerWrite.first == GS_REG_XYOFFSET_2))
(registerWrite.first == GS_REG_XYOFFSET_1) ||
(registerWrite.first == GS_REG_XYOFFSET_2))
{
currentOfs[registerWrite.first - GS_REG_XYOFFSET_1] <<= registerWrite.second;
}
else if(
(registerWrite.first == GS_REG_XYZ2) ||
(registerWrite.first == GS_REG_XYZ3) ||
(registerWrite.first == GS_REG_XYZF2) ||
(registerWrite.first == GS_REG_XYZF3))
(registerWrite.first == GS_REG_XYZ2) ||
(registerWrite.first == GS_REG_XYZ3) ||
(registerWrite.first == GS_REG_XYZF2) ||
(registerWrite.first == GS_REG_XYZF3))
{
if(vertexCount != 0)
{
@ -213,7 +213,7 @@ void CFrameDump::IdentifyDrawingKicks()
drawingKickInfo.primType = currentPrim.nType;
drawingKickInfo.context = currentPrim.nContext;
drawingKickInfo.vertex[vertexCount].x = ((registerWrite.second >> 0) & 0xFFFF) - offset.nOffsetX;
drawingKickInfo.vertex[vertexCount].x = ((registerWrite.second >> 0) & 0xFFFF) - offset.nOffsetX;
drawingKickInfo.vertex[vertexCount].y = ((registerWrite.second >> 16) & 0xFFFF) - offset.nOffsetY;
if(vertexCount == 0)

View file

@ -10,7 +10,7 @@ class CGsPacketMetadata
{
public:
explicit CGsPacketMetadata(unsigned int pathIndex = 0)
: pathIndex(pathIndex)
: pathIndex(pathIndex)
{
#ifdef DEBUGGER_INCLUDED
memset(&vu1State, 0, sizeof(vu1State));
@ -19,14 +19,14 @@ public:
#endif
}
unsigned int pathIndex = 0;
unsigned int pathIndex = 0;
#ifdef DEBUGGER_INCLUDED
MIPSSTATE vu1State;
uint8 microMem1[PS2::MICROMEM1SIZE];
uint8 vuMem1[PS2::VUMEM1SIZE];
uint32 vpu1Top = 0;
uint32 vpu1Itop = 0;
uint32 vuMemPacketAddress = 0;
MIPSSTATE vu1State;
uint8 microMem1[PS2::MICROMEM1SIZE];
uint8 vuMem1[PS2::VUMEM1SIZE];
uint32 vpu1Top = 0;
uint32 vpu1Itop = 0;
uint32 vuMemPacketAddress = 0;
#endif
};
@ -36,9 +36,9 @@ public:
typedef std::vector<CGSHandler::RegisterWrite> RegisterWriteArray;
typedef std::vector<uint8> ImageDataArray;
CGsPacketMetadata metadata;
RegisterWriteArray registerWrites;
ImageDataArray imageData;
CGsPacketMetadata metadata;
RegisterWriteArray registerWrites;
ImageDataArray imageData;
};
struct DRAWINGKICK_INFO
@ -49,9 +49,9 @@ struct DRAWINGKICK_INFO
uint16 y = 0;
};
unsigned int context = 0;
unsigned int primType = CGSHandler::PRIM_INVALID;
VERTEX vertex[3];
unsigned int context = 0;
unsigned int primType = CGSHandler::PRIM_INVALID;
VERTEX vertex[3];
};
typedef std::map<uint32, DRAWINGKICK_INFO> DrawingKickInfoMap;
@ -61,31 +61,31 @@ class CFrameDump
public:
typedef std::vector<CGsPacket> PacketArray;
CFrameDump();
virtual ~CFrameDump();
CFrameDump();
virtual ~CFrameDump();
void Reset();
void Reset();
uint8* GetInitialGsRam();
uint64* GetInitialGsRegisters();
uint8* GetInitialGsRam();
uint64* GetInitialGsRegisters();
uint64 GetInitialSMODE2() const;
void SetInitialSMODE2(uint64);
uint64 GetInitialSMODE2() const;
void SetInitialSMODE2(uint64);
const PacketArray& GetPackets() const;
void AddRegisterPacket(const CGSHandler::RegisterWrite*, uint32, const CGsPacketMetadata*);
void AddImagePacket(const uint8*, uint32);
const PacketArray& GetPackets() const;
void AddRegisterPacket(const CGSHandler::RegisterWrite*, uint32, const CGsPacketMetadata*);
void AddImagePacket(const uint8*, uint32);
void Read(Framework::CStream&);
void Write(Framework::CStream&) const;
void Read(Framework::CStream&);
void Write(Framework::CStream&) const;
void IdentifyDrawingKicks();
const DrawingKickInfoMap& GetDrawingKicks() const;
void IdentifyDrawingKicks();
const DrawingKickInfoMap& GetDrawingKicks() const;
private:
uint8* m_initialGsRam = nullptr;
uint64 m_initialGsRegisters[CGSHandler::REGISTER_MAX];
uint64 m_initialSMODE2 = 0;
PacketArray m_packets;
DrawingKickInfoMap m_drawingKicks;
uint8* m_initialGsRam = nullptr;
uint64 m_initialGsRegisters[CGSHandler::REGISTER_MAX];
uint64 m_initialSMODE2 = 0;
PacketArray m_packets;
DrawingKickInfoMap m_drawingKicks;
};

View file

@ -18,7 +18,7 @@ public:
void Execute()
{
auto newEnd = std::remove_if(m_futures.begin(), m_futures.end(),
[] (const FuturePtr& future) { return future->IsDone(); } );
[](const FuturePtr& future) { return future->IsDone(); });
m_futures.erase(newEnd, m_futures.end());
}
@ -31,16 +31,16 @@ private:
};
typedef std::unique_ptr<CFuture> FuturePtr;
template<typename ResultType>
template <typename ResultType>
class CFutureWrapper : public CFuture
{
public:
typedef std::function<void (const ResultType&)> CallbackType;
typedef std::function<void(const ResultType&)> CallbackType;
CFutureWrapper(std::future<ResultType> future, CallbackType callback)
: m_future(std::move(future)), m_callback(std::move(callback))
: m_future(std::move(future))
, m_callback(std::move(callback))
{
}
bool IsDone() override

View file

@ -14,8 +14,8 @@ namespace ISO9660
BLOCKSIZE = 0x800ULL
};
virtual ~CBlockProvider() {};
virtual void ReadBlock(uint32, void*) = 0;
virtual ~CBlockProvider(){};
virtual void ReadBlock(uint32, void*) = 0;
};
class CBlockProvider2048 : public CBlockProvider
@ -24,14 +24,12 @@ namespace ISO9660
typedef std::shared_ptr<Framework::CStream> StreamPtr;
CBlockProvider2048(const StreamPtr& stream)
: m_stream(stream)
: m_stream(stream)
{
}
virtual ~CBlockProvider2048()
{
}
void ReadBlock(uint32 address, void* block) override
@ -50,14 +48,12 @@ namespace ISO9660
typedef std::shared_ptr<Framework::CStream> StreamPtr;
CBlockProviderCDROMXA(const StreamPtr& stream)
: m_stream(stream)
: m_stream(stream)
{
}
virtual ~CBlockProviderCDROMXA()
{
}
void ReadBlock(uint32 address, void* block) override

View file

@ -32,7 +32,6 @@ CDirectoryRecord::CDirectoryRecord(Framework::CStream* stream)
CDirectoryRecord::~CDirectoryRecord()
{
}
uint8 CDirectoryRecord::GetLength() const

View file

@ -8,22 +8,22 @@ namespace ISO9660
class CDirectoryRecord
{
public:
CDirectoryRecord();
CDirectoryRecord(Framework::CStream*);
~CDirectoryRecord();
CDirectoryRecord();
CDirectoryRecord(Framework::CStream*);
~CDirectoryRecord();
bool IsDirectory() const;
uint8 GetLength() const;
const char* GetName() const;
uint32 GetPosition() const;
uint32 GetDataLength() const;
bool IsDirectory() const;
uint8 GetLength() const;
const char* GetName() const;
uint32 GetPosition() const;
uint32 GetDataLength() const;
private:
uint8 m_length = 0;
uint8 m_exLength = 0;
uint32 m_position = 0;
uint32 m_dataLength = 0;
uint8 m_flags = 0;
char m_name[256];
uint8 m_length = 0;
uint8 m_exLength = 0;
uint32 m_position = 0;
uint32 m_dataLength = 0;
uint8 m_flags = 0;
char m_name[256];
};
}

View file

@ -7,24 +7,23 @@
using namespace ISO9660;
CFile::CFile(CBlockProvider* blockProvider, uint64 start)
: m_blockProvider(blockProvider)
, m_start(start)
, m_end(ULLONG_MAX)
: m_blockProvider(blockProvider)
, m_start(start)
, m_end(ULLONG_MAX)
{
InitBlock();
}
CFile::CFile(CBlockProvider* blockProvider, uint64 start, uint64 size)
: m_blockProvider(blockProvider)
, m_start(start)
, m_end(start + size)
: m_blockProvider(blockProvider)
, m_start(start)
, m_end(start + size)
{
InitBlock();
}
CFile::~CFile()
{
}
void CFile::Seek(int64 amount, Framework::STREAM_SEEK_DIRECTION whence)
@ -65,9 +64,9 @@ uint64 CFile::Read(void* data, uint64 length)
while(1)
{
SyncBlock();
uint64 blockPosition = (m_start + m_position) % CBlockProvider::BLOCKSIZE;
uint64 blockRemain = CBlockProvider::BLOCKSIZE - blockPosition;
uint64 toRead = (length > blockRemain) ? (blockRemain) : (length);
uint64 blockPosition = (m_start + m_position) % CBlockProvider::BLOCKSIZE;
uint64 blockRemain = CBlockProvider::BLOCKSIZE - blockPosition;
uint64 toRead = (length > blockRemain) ? (blockRemain) : (length);
memcpy(data, m_block + blockPosition, static_cast<uint32>(toRead));

View file

@ -8,26 +8,25 @@ namespace ISO9660
class CFile : public Framework::CStream
{
public:
CFile(CBlockProvider*, uint64);
CFile(CBlockProvider*, uint64, uint64);
~CFile();
void Seek(int64, Framework::STREAM_SEEK_DIRECTION) override;
uint64 Tell() override;
uint64 Read(void*, uint64) override;
uint64 Write(const void*, uint64) override;
bool IsEOF() override;
CFile(CBlockProvider*, uint64);
CFile(CBlockProvider*, uint64, uint64);
~CFile();
void Seek(int64, Framework::STREAM_SEEK_DIRECTION) override;
uint64 Tell() override;
uint64 Read(void*, uint64) override;
uint64 Write(const void*, uint64) override;
bool IsEOF() override;
private:
void InitBlock();
void SyncBlock();
void InitBlock();
void SyncBlock();
CBlockProvider* m_blockProvider = nullptr;
uint64 m_start = 0;
uint64 m_end = 0;
uint64 m_position = 0;
uint32 m_blockPosition = 0;
uint8 m_block[CBlockProvider::BLOCKSIZE];
bool m_isEof = false;
CBlockProvider* m_blockProvider = nullptr;
uint64 m_start = 0;
uint64 m_end = 0;
uint64 m_position = 0;
uint32 m_blockPosition = 0;
uint8 m_block[CBlockProvider::BLOCKSIZE];
bool m_isEof = false;
};
}

View file

@ -9,16 +9,14 @@
using namespace ISO9660;
CISO9660::CISO9660(const BlockProviderPtr& blockProvider)
: m_blockProvider(blockProvider)
, m_volumeDescriptor(blockProvider.get())
, m_pathTable(blockProvider.get(), m_volumeDescriptor.GetLPathTableAddress())
: m_blockProvider(blockProvider)
, m_volumeDescriptor(blockProvider.get())
, m_pathTable(blockProvider.get(), m_volumeDescriptor.GetLPathTableAddress())
{
}
CISO9660::~CISO9660()
{
}
void CISO9660::ReadBlock(uint32 address, void* data)

View file

@ -11,20 +11,20 @@ class CISO9660
public:
typedef std::shared_ptr<ISO9660::CBlockProvider> BlockProviderPtr;
CISO9660(const BlockProviderPtr&);
~CISO9660();
CISO9660(const BlockProviderPtr&);
~CISO9660();
void ReadBlock(uint32, void*);
void ReadBlock(uint32, void*);
Framework::CStream* Open(const char*);
bool GetFileRecord(ISO9660::CDirectoryRecord*, const char*);
Framework::CStream* Open(const char*);
bool GetFileRecord(ISO9660::CDirectoryRecord*, const char*);
private:
bool GetFileRecordFromDirectory(ISO9660::CDirectoryRecord*, uint32, const char*);
bool GetFileRecordFromDirectory(ISO9660::CDirectoryRecord*, uint32, const char*);
BlockProviderPtr m_blockProvider;
ISO9660::CVolumeDescriptor m_volumeDescriptor;
ISO9660::CPathTable m_pathTable;
BlockProviderPtr m_blockProvider;
ISO9660::CVolumeDescriptor m_volumeDescriptor;
ISO9660::CPathTable m_pathTable;
uint8 m_blockBuffer[ISO9660::CBlockProvider::BLOCKSIZE];
uint8 m_blockBuffer[ISO9660::CBlockProvider::BLOCKSIZE];
};

View file

@ -21,7 +21,6 @@ CPathTable::CPathTable(CBlockProvider* blockProvider, uint32 tableLba)
CPathTable::~CPathTable()
{
}
uint32 CPathTable::GetDirectoryAddress(unsigned int recordIndex) const

View file

@ -11,17 +11,16 @@ namespace ISO9660
class CPathTable
{
public:
CPathTable(CBlockProvider*, uint32);
~CPathTable();
CPathTable(CBlockProvider*, uint32);
~CPathTable();
unsigned int FindRoot() const;
unsigned int FindDirectory(const char*, unsigned int) const;
uint32 GetDirectoryAddress(unsigned int) const;
unsigned int FindRoot() const;
unsigned int FindDirectory(const char*, unsigned int) const;
uint32 GetDirectoryAddress(unsigned int) const;
private:
typedef std::map<size_t, CPathTableRecord> RecordMapType;
RecordMapType m_records;
RecordMapType m_records;
};
}

View file

@ -19,7 +19,6 @@ CPathTableRecord::CPathTableRecord(Framework::CStream& stream)
CPathTableRecord::~CPathTableRecord()
{
}
uint8 CPathTableRecord::GetNameLength() const

View file

@ -9,19 +9,19 @@ namespace ISO9660
class CPathTableRecord
{
public:
CPathTableRecord(Framework::CStream&);
~CPathTableRecord();
CPathTableRecord(Framework::CStream&);
~CPathTableRecord();
uint8 GetNameLength() const;
uint32 GetAddress() const;
uint32 GetParentRecord() const;
const char* GetName() const;
uint8 GetNameLength() const;
uint32 GetAddress() const;
uint32 GetParentRecord() const;
const char* GetName() const;
private:
uint8 m_nameLength = 0;
uint8 m_exLength = 0;
uint32 m_location = 0;
uint16 m_parentDir = 0;
std::string m_directory;
uint8 m_nameLength = 0;
uint8 m_exLength = 0;
uint32 m_location = 0;
uint16 m_parentDir = 0;
std::string m_directory;
};
}

View file

@ -39,7 +39,6 @@ CVolumeDescriptor::CVolumeDescriptor(CBlockProvider* blockProvider)
CVolumeDescriptor::~CVolumeDescriptor()
{
}
uint32 CVolumeDescriptor::GetLPathTableAddress() const

View file

@ -8,18 +8,17 @@ namespace ISO9660
class CVolumeDescriptor
{
public:
CVolumeDescriptor(CBlockProvider*);
~CVolumeDescriptor();
CVolumeDescriptor(CBlockProvider*);
~CVolumeDescriptor();
uint32 GetLPathTableAddress() const;
uint32 GetMPathTableAddress() const;
uint32 GetLPathTableAddress() const;
uint32 GetMPathTableAddress() const;
private:
uint8 m_type = 0;
char m_stdId[6];
char m_volumeId[33];
uint32 m_LPathTableAddress = 0;
uint32 m_MPathTableAddress = 0;
uint8 m_type = 0;
char m_stdId[6];
char m_volumeId[33];
uint32 m_LPathTableAddress = 0;
uint32 m_MPathTableAddress = 0;
};
}

View file

@ -5,8 +5,7 @@
struct INTEGER64
{
union
{
union {
uint64 q;
struct
{

View file

@ -8,7 +8,7 @@
#include "StdStream.h"
CIszImageStream::CIszImageStream(CStream* baseStream)
: m_baseStream(baseStream)
: m_baseStream(baseStream)
{
if(baseStream == nullptr)
{
@ -36,9 +36,9 @@ CIszImageStream::CIszImageStream(CStream* baseStream)
CIszImageStream::~CIszImageStream()
{
delete [] m_cachedBlock;
delete [] m_readBuffer;
delete [] m_blockDescriptorTable;
delete[] m_cachedBlock;
delete[] m_readBuffer;
delete[] m_blockDescriptorTable;
delete m_baseStream;
}
@ -117,7 +117,7 @@ void CIszImageStream::ReadBlockDescriptorTable()
m_blockDescriptorTable[i].storageType = static_cast<uint8>(value >> 22);
}
delete [] cryptedTable;
delete[] cryptedTable;
}
uint64 CIszImageStream::GetTotalSize() const
@ -199,8 +199,8 @@ void CIszImageStream::ReadGzipBlock(uint32 compressedBlockSize)
m_baseStream->Read(m_readBuffer, compressedBlockSize);
uLongf destLength = m_header.blockSize;
if(uncompress(
reinterpret_cast<Bytef*>(m_cachedBlock), &destLength,
reinterpret_cast<Bytef*>(m_readBuffer), compressedBlockSize) != Z_OK)
reinterpret_cast<Bytef*>(m_cachedBlock), &destLength,
reinterpret_cast<Bytef*>(m_readBuffer), compressedBlockSize) != Z_OK)
{
throw std::runtime_error("Error decompressing zlib block.");
}
@ -215,8 +215,8 @@ void CIszImageStream::ReadBz2Block(uint32 compressedBlockSize)
m_readBuffer[2] = 'h';
unsigned int destLength = m_header.blockSize;
if(BZ2_bzBuffToBuffDecompress(
reinterpret_cast<char*>(m_cachedBlock), &destLength,
reinterpret_cast<char*>(m_readBuffer), compressedBlockSize, 0, 0) != BZ_OK)
reinterpret_cast<char*>(m_cachedBlock), &destLength,
reinterpret_cast<char*>(m_readBuffer), compressedBlockSize, 0, 0) != BZ_OK)
{
throw std::runtime_error("Error decompressing bz2 block.");
}

View file

@ -6,49 +6,49 @@
class CIszImageStream : public Framework::CStream
{
public:
CIszImageStream(Framework::CStream*);
virtual ~CIszImageStream();
CIszImageStream(Framework::CStream*);
virtual ~CIszImageStream();
virtual void Seek(int64, Framework::STREAM_SEEK_DIRECTION) override;
virtual uint64 Tell() override;
virtual uint64 Read(void*, uint64) override;
virtual uint64 Write(const void*, uint64) override;
virtual bool IsEOF() override;
virtual void Seek(int64, Framework::STREAM_SEEK_DIRECTION) override;
virtual uint64 Tell() override;
virtual uint64 Read(void*, uint64) override;
virtual uint64 Write(const void*, uint64) override;
virtual bool IsEOF() override;
private:
#pragma pack(push, 1)
struct HEADER
{
char signature[4];
uint8 headerSize;
int8 version;
uint32 volumeSerialNumber;
char signature[4];
uint8 headerSize;
int8 version;
uint32 volumeSerialNumber;
uint16 sectorSize;
uint32 totalSectors;
uint16 sectorSize;
uint32 totalSectors;
int8 hasPassword;
int8 hasPassword;
int64 segmentSize;
int64 segmentSize;
uint32 blockNumber;
uint32 blockSize;
uint8 blockPtrLength;
uint32 blockNumber;
uint32 blockSize;
uint8 blockPtrLength;
int8 segmentNumber;
int8 segmentNumber;
uint32 blockPtrOffset;
uint32 segmentPtrOffset;
uint32 dataOffset;
uint32 blockPtrOffset;
uint32 segmentPtrOffset;
uint32 dataOffset;
int8 reserved;
int8 reserved;
};
#pragma pack(pop)
struct BLOCKDESCRIPTOR
{
uint32 size;
uint8 storageType;
uint32 size;
uint8 storageType;
};
enum HASPASSWORD
@ -68,21 +68,21 @@ private:
ADI_BZ2 = 3
};
void ReadBlockDescriptorTable();
uint64 GetTotalSize() const;
const BLOCKDESCRIPTOR& SeekToBlock(uint64);
void SyncCache();
void ReadBlockDescriptorTable();
uint64 GetTotalSize() const;
const BLOCKDESCRIPTOR& SeekToBlock(uint64);
void SyncCache();
void ReadZeroBlock(uint32);
void ReadDataBlock(uint32);
void ReadGzipBlock(uint32);
void ReadBz2Block(uint32);
void ReadZeroBlock(uint32);
void ReadDataBlock(uint32);
void ReadGzipBlock(uint32);
void ReadBz2Block(uint32);
Framework::CStream* m_baseStream = nullptr;
HEADER m_header;
BLOCKDESCRIPTOR* m_blockDescriptorTable = nullptr;
int64 m_cachedBlockNumber = -1;
uint8* m_cachedBlock = nullptr;
uint8* m_readBuffer = nullptr;
uint64 m_position = 0;
Framework::CStream* m_baseStream = nullptr;
HEADER m_header;
BLOCKDESCRIPTOR* m_blockDescriptorTable = nullptr;
int64 m_cachedBlockNumber = -1;
uint8* m_cachedBlock = nullptr;
uint8* m_readBuffer = nullptr;
uint64 m_position = 0;
};

View file

@ -17,7 +17,6 @@ CLog::CLog()
CLog::~CLog()
{
}
void CLog::Print(const char* logName, const char* format, ...)

View file

@ -10,18 +10,18 @@
class CLog : public CSingleton<CLog>
{
public:
CLog();
virtual ~CLog();
CLog();
virtual ~CLog();
void Print(const char*, const char*, ...);
void Print(const char*, const char*, ...);
private:
typedef std::map<std::string, Framework::CStdStream> LogMapType;
Framework::CStdStream& GetLog(const char*);
Framework::CStdStream& GetLog(const char*);
boost::filesystem::path m_logBasePath;
LogMapType m_logs;
boost::filesystem::path m_logBasePath;
LogMapType m_logs;
};
#endif

View file

@ -8,43 +8,43 @@
#include "placeholder_def.h"
uint32 g_LWMaskRight[4] =
{
0x00FFFFFF,
0x0000FFFF,
0x000000FF,
0x00000000,
{
0x00FFFFFF,
0x0000FFFF,
0x000000FF,
0x00000000,
};
uint32 g_LWMaskLeft[4] =
{
0xFFFFFF00,
0xFFFF0000,
0xFF000000,
0x00000000,
{
0xFFFFFF00,
0xFFFF0000,
0xFF000000,
0x00000000,
};
uint64 g_LDMaskRight[8] =
{
0x00FFFFFFFFFFFFFFULL,
0x0000FFFFFFFFFFFFULL,
0x000000FFFFFFFFFFULL,
0x00000000FFFFFFFFULL,
0x0000000000FFFFFFULL,
0x000000000000FFFFULL,
0x00000000000000FFULL,
0x0000000000000000ULL,
{
0x00FFFFFFFFFFFFFFULL,
0x0000FFFFFFFFFFFFULL,
0x000000FFFFFFFFFFULL,
0x00000000FFFFFFFFULL,
0x0000000000FFFFFFULL,
0x000000000000FFFFULL,
0x00000000000000FFULL,
0x0000000000000000ULL,
};
uint64 g_LDMaskLeft[8] =
{
0xFFFFFFFFFFFFFF00ULL,
0xFFFFFFFFFFFF0000ULL,
0xFFFFFFFFFF000000ULL,
0xFFFFFFFF00000000ULL,
0xFFFFFF0000000000ULL,
0xFFFF000000000000ULL,
0xFF00000000000000ULL,
0x0000000000000000ULL,
{
0xFFFFFFFFFFFFFF00ULL,
0xFFFFFFFFFFFF0000ULL,
0xFFFFFFFFFF000000ULL,
0xFFFFFFFF00000000ULL,
0xFFFFFF0000000000ULL,
0xFFFF000000000000ULL,
0xFF00000000000000ULL,
0x0000000000000000ULL,
};
extern "C" uint32 LWL_Proxy(uint32 address, uint32 rt, CMIPS* context)
@ -143,8 +143,8 @@ extern "C" void SDR_Proxy(uint32 address, uint64 rt, CMIPS* context)
MemoryUtils_SetDoubleProxy(context, memory, alignedAddress);
}
CMA_MIPSIV::CMA_MIPSIV(MIPS_REGSIZE nRegSize) :
CMIPSArchitecture(nRegSize)
CMA_MIPSIV::CMA_MIPSIV(MIPS_REGSIZE nRegSize)
: CMIPSArchitecture(nRegSize)
{
SetupInstructionTables();
SetupReflectionTables();
@ -152,7 +152,6 @@ CMIPSArchitecture(nRegSize)
CMA_MIPSIV::~CMA_MIPSIV()
{
}
void CMA_MIPSIV::SetupInstructionTables()
@ -182,11 +181,11 @@ void CMA_MIPSIV::CompileInstruction(uint32 nAddress, CMipsJitter* codeGen, CMIPS
{
SetupQuickVariables(nAddress, codeGen, pCtx);
m_nRS = (uint8)((m_nOpcode >> 21) & 0x1F);
m_nRT = (uint8)((m_nOpcode >> 16) & 0x1F);
m_nRD = (uint8)((m_nOpcode >> 11) & 0x1F);
m_nSA = (uint8)((m_nOpcode >> 6) & 0x1F);
m_nImmediate = (uint16)(m_nOpcode & 0xFFFF);
m_nRS = (uint8)((m_nOpcode >> 21) & 0x1F);
m_nRT = (uint8)((m_nOpcode >> 16) & 0x1F);
m_nRD = (uint8)((m_nOpcode >> 11) & 0x1F);
m_nSA = (uint8)((m_nOpcode >> 6) & 0x1F);
m_nImmediate = (uint16)(m_nOpcode & 0xFFFF);
if(m_nOpcode)
{

View file

@ -7,13 +7,13 @@
class CMA_MIPSIV : public CMIPSArchitecture
{
public:
CMA_MIPSIV(MIPS_REGSIZE);
virtual ~CMA_MIPSIV();
virtual void CompileInstruction(uint32, CMipsJitter*, CMIPS*);
virtual void GetInstructionMnemonic(CMIPS*, uint32, uint32, char*, unsigned int);
virtual void GetInstructionOperands(CMIPS*, uint32, uint32, char*, unsigned int);
virtual MIPS_BRANCH_TYPE IsInstructionBranch(CMIPS*, uint32, uint32);
virtual uint32 GetInstructionEffectiveAddress(CMIPS*, uint32, uint32);
CMA_MIPSIV(MIPS_REGSIZE);
virtual ~CMA_MIPSIV();
virtual void CompileInstruction(uint32, CMipsJitter*, CMIPS*);
virtual void GetInstructionMnemonic(CMIPS*, uint32, uint32, char*, unsigned int);
virtual void GetInstructionOperands(CMIPS*, uint32, uint32, char*, unsigned int);
virtual MIPS_BRANCH_TYPE IsInstructionBranch(CMIPS*, uint32, uint32);
virtual uint32 GetInstructionEffectiveAddress(CMIPS*, uint32, uint32);
protected:
enum
@ -24,55 +24,55 @@ protected:
MAX_REGIMM_OPS = 0x20,
};
typedef std::function<void ()> InstructionFunction;
typedef std::function<void()> InstructionFunction;
InstructionFunction m_pOpGeneral[MAX_GENERAL_OPS];
InstructionFunction m_pOpSpecial[MAX_SPECIAL_OPS];
InstructionFunction m_pOpSpecial2[MAX_SPECIAL2_OPS];
InstructionFunction m_pOpRegImm[MAX_REGIMM_OPS];
InstructionFunction m_pOpGeneral[MAX_GENERAL_OPS];
InstructionFunction m_pOpSpecial[MAX_SPECIAL_OPS];
InstructionFunction m_pOpSpecial2[MAX_SPECIAL2_OPS];
InstructionFunction m_pOpRegImm[MAX_REGIMM_OPS];
static void ReflOpTarget(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRtRsImm(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRtImm(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRsRtOff(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRsOff(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRtOffRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpHintOffRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpIdOffRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRdRsRt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRdRtSa(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRdRtRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRd(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRdRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRsRt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpTarget(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRtRsImm(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRtImm(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRsRtOff(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRsOff(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRtOffRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpHintOffRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpIdOffRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRdRsRt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRdRtSa(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRdRtRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRd(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRdRs(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static void ReflOpRsRt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static uint32 ReflEaTarget(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32);
static uint32 ReflEaOffset(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32);
static uint32 ReflEaTarget(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32);
static uint32 ReflEaOffset(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32);
static void ReflCOPMnemonic(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, char*, unsigned int);
static void ReflCOPOperands(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static MIPS_BRANCH_TYPE ReflCOPIsBranch(MIPSReflection::INSTRUCTION*, CMIPS*, uint32);
static uint32 ReflCOPEffeAddr(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32);
static void ReflCOPMnemonic(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, char*, unsigned int);
static void ReflCOPOperands(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
static MIPS_BRANCH_TYPE ReflCOPIsBranch(MIPSReflection::INSTRUCTION*, CMIPS*, uint32);
static uint32 ReflCOPEffeAddr(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32);
MIPSReflection::INSTRUCTION m_ReflGeneral[MAX_GENERAL_OPS];
MIPSReflection::INSTRUCTION m_ReflSpecial[MAX_SPECIAL_OPS];
MIPSReflection::INSTRUCTION m_ReflRegImm[MAX_REGIMM_OPS];
MIPSReflection::INSTRUCTION m_ReflGeneral[MAX_GENERAL_OPS];
MIPSReflection::INSTRUCTION m_ReflSpecial[MAX_SPECIAL_OPS];
MIPSReflection::INSTRUCTION m_ReflRegImm[MAX_REGIMM_OPS];
MIPSReflection::SUBTABLE m_ReflGeneralTable;
MIPSReflection::SUBTABLE m_ReflSpecialTable;
MIPSReflection::SUBTABLE m_ReflRegImmTable;
MIPSReflection::SUBTABLE m_ReflGeneralTable;
MIPSReflection::SUBTABLE m_ReflSpecialTable;
MIPSReflection::SUBTABLE m_ReflRegImmTable;
uint8 m_nRS;
uint8 m_nRT;
uint8 m_nRD;
uint8 m_nSA;
uint16 m_nImmediate;
uint8 m_nRS;
uint8 m_nRT;
uint8 m_nRD;
uint8 m_nSA;
uint16 m_nImmediate;
protected:
//Instruction compiler templates
typedef std::function<void (uint8)> TemplateParamedOperationFunctionType;
typedef std::function<void ()> TemplateOperationFunctionType;
typedef std::function<void(uint8)> TemplateParamedOperationFunctionType;
typedef std::function<void()> TemplateOperationFunctionType;
void Template_Add32(bool);
void Template_Add64(bool);
@ -91,131 +91,131 @@ protected:
void Template_BranchLez(bool, bool);
private:
void SetupInstructionTables();
void SetupReflectionTables();
void SetupInstructionTables();
void SetupReflectionTables();
void SPECIAL();
void SPECIAL2();
void REGIMM();
void SPECIAL();
void SPECIAL2();
void REGIMM();
//General
void J();
void JAL();
void BEQ();
void BNE();
void BLEZ();
void BGTZ();
void ADDI();
void ADDIU();
void SLTI();
void SLTIU();
void ANDI();
void ORI();
void XORI();
void LUI();
void COP0();
void COP1();
void COP2();
void BEQL();
void BNEL();
void BLEZL();
void BGTZL();
void DADDI();
void DADDIU();
void LDL();
void LDR();
void LB();
void LH();
void LWL();
void LW();
void LBU();
void LHU();
void LWR();
void LWU();
void SB();
void SH();
void SWL();
void SW();
void SDL();
void SDR();
void SWR();
void CACHE();
void LWC1();
void PREF();
void LDC2();
void LD();
void SWC1();
void SDC2();
void SD();
void J();
void JAL();
void BEQ();
void BNE();
void BLEZ();
void BGTZ();
void ADDI();
void ADDIU();
void SLTI();
void SLTIU();
void ANDI();
void ORI();
void XORI();
void LUI();
void COP0();
void COP1();
void COP2();
void BEQL();
void BNEL();
void BLEZL();
void BGTZL();
void DADDI();
void DADDIU();
void LDL();
void LDR();
void LB();
void LH();
void LWL();
void LW();
void LBU();
void LHU();
void LWR();
void LWU();
void SB();
void SH();
void SWL();
void SW();
void SDL();
void SDR();
void SWR();
void CACHE();
void LWC1();
void PREF();
void LDC2();
void LD();
void SWC1();
void SDC2();
void SD();
//Special
void SLL();
void SRL();
void SRA();
void SLLV();
void SRLV();
void SRAV();
void JR();
void JALR();
void MOVZ();
void MOVN();
void SYSCALL();
void BREAK();
void SYNC();
void DSLLV();
void DSRLV();
void DSRAV();
void MFHI();
void MTHI();
void MFLO();
void MTLO();
void MULT();
void MULTU();
void DIV();
void DIVU();
void ADD();
void ADDU();
void SUB();
void SUBU();
void AND();
void OR();
void XOR();
void NOR();
void SLT();
void SLTU();
void DADD();
void DADDU();
void DSUB();
void DSUBU();
void TEQ();
void DSLL();
void DSRL();
void DSRA();
void DSLL32();
void DSRL32();
void DSRA32();
void SLL();
void SRL();
void SRA();
void SLLV();
void SRLV();
void SRAV();
void JR();
void JALR();
void MOVZ();
void MOVN();
void SYSCALL();
void BREAK();
void SYNC();
void DSLLV();
void DSRLV();
void DSRAV();
void MFHI();
void MTHI();
void MFLO();
void MTLO();
void MULT();
void MULTU();
void DIV();
void DIVU();
void ADD();
void ADDU();
void SUB();
void SUBU();
void AND();
void OR();
void XOR();
void NOR();
void SLT();
void SLTU();
void DADD();
void DADDU();
void DSUB();
void DSUBU();
void TEQ();
void DSLL();
void DSRL();
void DSRA();
void DSLL32();
void DSRL32();
void DSRA32();
//Special2
//RegImm
void BLTZ();
void BGEZ();
void BLTZL();
void BGEZL();
void BLTZAL();
void BGEZAL();
void BLTZALL();
void BGEZALL();
void BLTZ();
void BGEZ();
void BLTZL();
void BGEZL();
void BLTZAL();
void BGEZAL();
void BLTZALL();
void BGEZALL();
//Opcode tables
typedef void (CMA_MIPSIV::*InstructionFuncConstant)();
static InstructionFuncConstant m_cOpGeneral[MAX_GENERAL_OPS];
static InstructionFuncConstant m_cOpSpecial[MAX_SPECIAL_OPS];
static InstructionFuncConstant m_cOpRegImm[MAX_REGIMM_OPS];
static InstructionFuncConstant m_cOpGeneral[MAX_GENERAL_OPS];
static InstructionFuncConstant m_cOpSpecial[MAX_SPECIAL_OPS];
static InstructionFuncConstant m_cOpRegImm[MAX_REGIMM_OPS];
//Reflection tables
static MIPSReflection::INSTRUCTION m_cReflGeneral[MAX_GENERAL_OPS];
static MIPSReflection::INSTRUCTION m_cReflSpecial[MAX_SPECIAL_OPS];
static MIPSReflection::INSTRUCTION m_cReflRegImm[MAX_REGIMM_OPS];
static MIPSReflection::INSTRUCTION m_cReflGeneral[MAX_GENERAL_OPS];
static MIPSReflection::INSTRUCTION m_cReflSpecial[MAX_SPECIAL_OPS];
static MIPSReflection::INSTRUCTION m_cReflRegImm[MAX_REGIMM_OPS];
};

View file

@ -16,9 +16,9 @@ void CMA_MIPSIV::ReflOpRtRsImm(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress
uint8 nRS, nRT;
uint16 nImm;
nRS = (uint8) ((nOpcode >> 21) & 0x001F);
nRT = (uint8) ((nOpcode >> 16) & 0x001F);
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
nRS = (uint8)((nOpcode >> 21) & 0x001F);
nRT = (uint8)((nOpcode >> 16) & 0x001F);
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
sprintf(sText, "%s, %s, $%04X", CMIPS::m_sGPRName[nRT], CMIPS::m_sGPRName[nRS], nImm);
}
@ -28,8 +28,8 @@ void CMA_MIPSIV::ReflOpRtImm(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress,
uint8 nRT;
uint16 nImm;
nRT = (uint8) ((nOpcode >> 16) & 0x001F);
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
nRT = (uint8)((nOpcode >> 16) & 0x001F);
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
sprintf(sText, "%s, $%04X", CMIPS::m_sGPRName[nRT], nImm);
}
@ -39,9 +39,9 @@ void CMA_MIPSIV::ReflOpRsRtOff(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress
uint8 nRS, nRT;
uint16 nImm;
nRS = (uint8) ((nOpcode >> 21) & 0x001F);
nRT = (uint8) ((nOpcode >> 16) & 0x001F);
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
nRS = (uint8)((nOpcode >> 21) & 0x001F);
nRT = (uint8)((nOpcode >> 16) & 0x001F);
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
nAddress += 4;
sprintf(sText, "%s, %s, $%08X", CMIPS::m_sGPRName[nRS], CMIPS::m_sGPRName[nRT], (nAddress + CMIPS::GetBranch(nImm)));
@ -52,8 +52,8 @@ void CMA_MIPSIV::ReflOpRsOff(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress,
uint8 nRS;
uint16 nImm;
nRS = (uint8) ((nOpcode >> 21) & 0x001F);
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
nRS = (uint8)((nOpcode >> 21) & 0x001F);
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
nAddress += 4;
sprintf(sText, "%s, $%08X", CMIPS::m_sGPRName[nRS], (nAddress + CMIPS::GetBranch(nImm)));
@ -64,9 +64,9 @@ void CMA_MIPSIV::ReflOpRtOffRs(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress
uint8 nRS, nRT;
uint16 nImm;
nRS = (uint8) ((nOpcode >> 21) & 0x001F);
nRT = (uint8) ((nOpcode >> 16) & 0x001F);
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
nRS = (uint8)((nOpcode >> 21) & 0x001F);
nRT = (uint8)((nOpcode >> 16) & 0x001F);
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
nAddress += 4;
sprintf(sText, "%s, $%04X(%s)", CMIPS::m_sGPRName[nRT], nImm, CMIPS::m_sGPRName[nRS]);
@ -74,9 +74,9 @@ void CMA_MIPSIV::ReflOpRtOffRs(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress
void CMA_MIPSIV::ReflOpHintOffRs(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress, uint32 nOpcode, char* sText, unsigned int nCount)
{
uint8 nRS = (uint8) ((nOpcode >> 21) & 0x001F);
uint8 nHint = (uint8) ((nOpcode >> 16) & 0x001F);
uint16 nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
uint8 nRS = (uint8)((nOpcode >> 21) & 0x001F);
uint8 nHint = (uint8)((nOpcode >> 16) & 0x001F);
uint16 nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
nAddress += 4;
sprintf(sText, "%i, $%04X(%s)", nHint, nImm, CMIPS::m_sGPRName[nRS]);
@ -87,9 +87,9 @@ void CMA_MIPSIV::ReflOpIdOffRs(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress
uint8 nRS, nRT;
uint16 nImm;
nRS = (uint8) ((nOpcode >> 21) & 0x001F);
nRT = (uint8) ((nOpcode >> 16) & 0x001F);
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
nRS = (uint8)((nOpcode >> 21) & 0x001F);
nRT = (uint8)((nOpcode >> 16) & 0x001F);
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
nAddress += 4;
sprintf(sText, "$%02X, $%04X(%s)", nRT, nImm, CMIPS::m_sGPRName[nRS]);
@ -112,7 +112,7 @@ void CMA_MIPSIV::ReflOpRdRtSa(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddress,
nRT = (uint8)((nOpcode >> 16) & 0x001F);
nRD = (uint8)((nOpcode >> 11) & 0x001F);
nSA = (uint8)((nOpcode >> 6) & 0x001F);
nSA = (uint8)((nOpcode >> 6) & 0x001F);
sprintf(sText, "%s, %s, %i", CMIPS::m_sGPRName[nRD], CMIPS::m_sGPRName[nRT], nSA);
}
@ -176,7 +176,7 @@ uint32 CMA_MIPSIV::ReflEaOffset(INSTRUCTION* pInstr, CMIPS* pCtx, uint32 nAddres
{
uint16 nImm;
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
nImm = (uint16)((nOpcode >> 0) & 0xFFFF);
nAddress += 4;
return (nAddress + CMIPS::GetBranch(nImm));
@ -430,28 +430,28 @@ INSTRUCTION CMA_MIPSIV::m_cReflRegImm[32] =
void CMA_MIPSIV::SetupReflectionTables()
{
static_assert(sizeof(m_ReflGeneral) == sizeof(m_cReflGeneral), "Array sizes don't match");
static_assert(sizeof(m_ReflSpecial) == sizeof(m_cReflSpecial), "Array sizes don't match");
static_assert(sizeof(m_ReflRegImm) == sizeof(m_cReflRegImm), "Array sizes don't match");
static_assert(sizeof(m_ReflGeneral) == sizeof(m_cReflGeneral), "Array sizes don't match");
static_assert(sizeof(m_ReflSpecial) == sizeof(m_cReflSpecial), "Array sizes don't match");
static_assert(sizeof(m_ReflRegImm) == sizeof(m_cReflRegImm), "Array sizes don't match");
memcpy(m_ReflGeneral, m_cReflGeneral, sizeof(m_cReflGeneral));
memcpy(m_ReflSpecial, m_cReflSpecial, sizeof(m_cReflSpecial));
memcpy(m_ReflRegImm, m_cReflRegImm, sizeof(m_cReflRegImm));
memcpy(m_ReflGeneral, m_cReflGeneral, sizeof(m_cReflGeneral));
memcpy(m_ReflSpecial, m_cReflSpecial, sizeof(m_cReflSpecial));
memcpy(m_ReflRegImm, m_cReflRegImm, sizeof(m_cReflRegImm));
m_ReflGeneralTable.nShift = 26;
m_ReflGeneralTable.nMask = 0x3F;
m_ReflGeneralTable.pTable = m_ReflGeneral;
m_ReflGeneralTable.nShift = 26;
m_ReflGeneralTable.nMask = 0x3F;
m_ReflGeneralTable.pTable = m_ReflGeneral;
m_ReflSpecialTable.nShift = 0;
m_ReflSpecialTable.nMask = 0x3F;
m_ReflSpecialTable.pTable = m_ReflSpecial;
m_ReflSpecialTable.nShift = 0;
m_ReflSpecialTable.nMask = 0x3F;
m_ReflSpecialTable.pTable = m_ReflSpecial;
m_ReflRegImmTable.nShift = 16;
m_ReflRegImmTable.nMask = 0x1F;
m_ReflRegImmTable.pTable = m_ReflRegImm;
m_ReflRegImmTable.nShift = 16;
m_ReflRegImmTable.nMask = 0x1F;
m_ReflRegImmTable.pTable = m_ReflRegImm;
m_ReflGeneral[0x00].pSubTable = &m_ReflSpecialTable;
m_ReflGeneral[0x01].pSubTable = &m_ReflRegImmTable;
m_ReflGeneral[0x00].pSubTable = &m_ReflSpecialTable;
m_ReflGeneral[0x01].pSubTable = &m_ReflRegImmTable;
}
void CMA_MIPSIV::GetInstructionMnemonic(CMIPS* pCtx, uint32 nAddress, uint32 nOpcode, char* sText, unsigned int nCount)
@ -464,8 +464,8 @@ void CMA_MIPSIV::GetInstructionMnemonic(CMIPS* pCtx, uint32 nAddress, uint32 nOp
return;
}
Instr.pGetMnemonic = SubTableMnemonic;
Instr.pSubTable = &m_ReflGeneralTable;
Instr.pGetMnemonic = SubTableMnemonic;
Instr.pSubTable = &m_ReflGeneralTable;
Instr.pGetMnemonic(&Instr, pCtx, nOpcode, sText, nCount);
}
@ -479,8 +479,8 @@ void CMA_MIPSIV::GetInstructionOperands(CMIPS* pCtx, uint32 nAddress, uint32 nOp
return;
}
Instr.pGetOperands = SubTableOperands;
Instr.pSubTable = &m_ReflGeneralTable;
Instr.pGetOperands = SubTableOperands;
Instr.pSubTable = &m_ReflGeneralTable;
Instr.pGetOperands(&Instr, pCtx, nAddress, nOpcode, sText, nCount);
}
@ -490,8 +490,8 @@ MIPS_BRANCH_TYPE CMA_MIPSIV::IsInstructionBranch(CMIPS* pCtx, uint32 nAddress, u
if(nOpcode == 0) return MIPS_BRANCH_NONE;
Instr.pIsBranch = SubTableIsBranch;
Instr.pSubTable = &m_ReflGeneralTable;
Instr.pIsBranch = SubTableIsBranch;
Instr.pSubTable = &m_ReflGeneralTable;
return Instr.pIsBranch(&Instr, pCtx, nOpcode);
}
@ -501,7 +501,7 @@ uint32 CMA_MIPSIV::GetInstructionEffectiveAddress(CMIPS* pCtx, uint32 nAddress,
if(nOpcode == 0) return 0;
Instr.pGetEffectiveAddress = SubTableEffAddr;
Instr.pSubTable = &m_ReflGeneralTable;
Instr.pGetEffectiveAddress = SubTableEffAddr;
Instr.pSubTable = &m_ReflGeneralTable;
return Instr.pGetEffectiveAddress(&Instr, pCtx, nAddress, nOpcode);
}

View file

@ -4,12 +4,11 @@
#include "COP_SCU.h"
const char* CMIPS::m_sGPRName[] =
{
"R0", "AT", "V0", "V1", "A0", "A1", "A2", "A3",
"T0", "T1", "T2", "T3", "T4", "T5", "T6", "T7",
"S0", "S1", "S2", "S3", "S4", "S5", "S6", "S7",
"T8", "T9", "K0", "K1", "GP", "SP", "FP", "RA"
};
{
"R0", "AT", "V0", "V1", "A0", "A1", "A2", "A3",
"T0", "T1", "T2", "T3", "T4", "T5", "T6", "T7",
"S0", "S1", "S2", "S3", "S4", "S5", "S6", "S7",
"T8", "T9", "K0", "K1", "GP", "SP", "FP", "RA"};
CMIPS::CMIPS(MEMORYMAP_ENDIANESS nEnd)
{

View file

@ -12,8 +12,8 @@
struct REGISTER_PIPELINE
{
uint32 counter;
uint32 heldValue;
uint32 counter;
uint32 heldValue;
};
enum
@ -27,9 +27,9 @@ enum
//- The value at index - 1 is the latest value
struct FLAG_PIPELINE
{
uint32 index;
uint32 values[FLAG_PIPELINE_SLOTS];
uint32 pipeTimes[FLAG_PIPELINE_SLOTS];
uint32 index;
uint32 values[FLAG_PIPELINE_SLOTS];
uint32 pipeTimes[FLAG_PIPELINE_SLOTS];
};
enum
@ -44,127 +44,155 @@ enum
struct MIPSSTATE
{
uint32 nPC;
uint32 nDelayedJumpAddr;
uint32 nHasException;
uint32 nPC;
uint32 nDelayedJumpAddr;
uint32 nHasException;
#ifdef _WIN32
__declspec(align(16))
__declspec(align(16))
#else
__attribute__((aligned(16)))
__attribute__((aligned(16)))
#endif
uint128 nGPR[32];
uint128 nGPR[32];
uint32 nHI[2];
uint32 nLO[2];
uint32 nHI1[2];
uint32 nLO1[2];
uint32 nSA;
uint32 nHI[2];
uint32 nLO[2];
uint32 nHI1[2];
uint32 nLO1[2];
uint32 nSA;
//COP0
uint32 nCOP0[32];
uint32 nCOP0[32];
uint32 cop0_pccr;
uint32 cop0_pcr[2];
uint32 cop0_pccr;
uint32 cop0_pcr[2];
//COP1
uint32 nCOP1[32];
uint32 nCOP1A;
uint32 nFCSR;
uint32 nCOP1[32];
uint32 nCOP1A;
uint32 nFCSR;
//COP2
#ifdef _WIN32
__declspec(align(16))
__declspec(align(16))
#else
__attribute__((aligned(16)))
__attribute__((aligned(16)))
#endif
uint128 nCOP2[33];
uint128 nCOP2[33];
uint128 nCOP2A;
uint128 nCOP2A;
uint128 nCOP2VF_PreUp;
uint128 nCOP2VF_UpRes;
uint128 nCOP2VF_PreUp;
uint128 nCOP2VF_UpRes;
uint32 nCOP2Q;
uint32 nCOP2I;
uint32 nCOP2P;
uint32 nCOP2R;
uint32 nCOP2CF; //Mirror of CLIP flag (computed with values from pipeClip)
uint32 nCOP2MF; //Mirror of MACflag (computed with values from pipeMac)
uint32 nCOP2SF; //Sticky values of sign and zero MACflag (ie.: SxSySzSw ZxZyZzZw)
uint32 nCOP2T;
uint32 nCOP2Q;
uint32 nCOP2I;
uint32 nCOP2P;
uint32 nCOP2R;
uint32 nCOP2CF; //Mirror of CLIP flag (computed with values from pipeClip)
uint32 nCOP2MF; //Mirror of MACflag (computed with values from pipeMac)
uint32 nCOP2SF; //Sticky values of sign and zero MACflag (ie.: SxSySzSw ZxZyZzZw)
uint32 nCOP2T;
uint32 nCOP2VI[16];
uint32 nCOP2VI[16];
REGISTER_PIPELINE pipeQ;
REGISTER_PIPELINE pipeP;
FLAG_PIPELINE pipeMac;
FLAG_PIPELINE pipeClip;
REGISTER_PIPELINE pipeQ;
REGISTER_PIPELINE pipeP;
FLAG_PIPELINE pipeMac;
FLAG_PIPELINE pipeClip;
uint32 pipeTime;
uint32 pipeTime;
uint32 cmsar0;
uint32 callMsEnabled;
uint32 callMsAddr;
uint32 cmsar0;
uint32 callMsEnabled;
uint32 callMsAddr;
uint32 savedIntReg;
uint32 savedIntRegTemp;
uint32 xgkickAddress;
uint32 savedIntReg;
uint32 savedIntRegTemp;
uint32 xgkickAddress;
};
#define MIPS_INVALID_PC (0x00000001)
#define MIPS_INVALID_PC (0x00000001)
class CMIPS
{
public:
typedef uint32 (*AddressTranslator)(CMIPS*, uint32);
typedef std::set<uint32> BreakpointSet;
typedef uint32 (*AddressTranslator)(CMIPS*, uint32);
typedef std::set<uint32> BreakpointSet;
CMIPS(MEMORYMAP_ENDIANESS);
~CMIPS();
void ToggleBreakpoint(uint32);
bool IsBranch(uint32);
static int32 GetBranch(uint16);
static uint32 TranslateAddress64(CMIPS*, uint32);
CMIPS(MEMORYMAP_ENDIANESS);
~CMIPS();
void ToggleBreakpoint(uint32);
bool IsBranch(uint32);
static int32 GetBranch(uint16);
static uint32 TranslateAddress64(CMIPS*, uint32);
void Reset();
void Reset();
bool CanGenerateInterrupt() const;
bool GenerateInterrupt(uint32);
bool GenerateException(uint32);
bool CanGenerateInterrupt() const;
bool GenerateInterrupt(uint32);
bool GenerateException(uint32);
MIPSSTATE m_State;
MIPSSTATE m_State;
void* m_vuMem = nullptr;
void* m_vuMem = nullptr;
CMIPSArchitecture* m_pArch = nullptr;
CMIPSCoprocessor* m_pCOP[4];
CMemoryMap* m_pMemoryMap = nullptr;
BreakpointSet m_breakpoints;
CMIPSArchitecture* m_pArch = nullptr;
CMIPSCoprocessor* m_pCOP[4];
CMemoryMap* m_pMemoryMap = nullptr;
BreakpointSet m_breakpoints;
CMIPSAnalysis* m_analysis = nullptr;
CMIPSTags m_Comments;
CMIPSTags m_Functions;
CMIPSAnalysis* m_analysis = nullptr;
CMIPSTags m_Comments;
CMIPSTags m_Functions;
AddressTranslator m_pAddrTranslator = nullptr;
AddressTranslator m_pAddrTranslator = nullptr;
enum REGISTER
{
R0 = 0, AT, V0, V1, A0, A1, A2, A3,
T0, T1, T2, T3, T4, T5, T6, T7,
S0, S1, S2, S3, S4, S5, S6, S7,
T8, T9, K0, K1, GP, SP, FP, RA
R0 = 0,
AT,
V0,
V1,
A0,
A1,
A2,
A3,
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
S0,
S1,
S2,
S3,
S4,
S5,
S6,
S7,
T8,
T9,
K0,
K1,
GP,
SP,
FP,
RA
};
enum
{
STATUS_IE = (1 << 0),
STATUS_EXL = (1 << 1),
STATUS_ERL = (1 << 2),
STATUS_EIE = (1 << 16), //PS2 EE specific
STATUS_IE = (1 << 0),
STATUS_EXL = (1 << 1),
STATUS_ERL = (1 << 2),
STATUS_EIE = (1 << 16), //PS2 EE specific
};
static const char* m_sGPRName[];
static const char* m_sGPRName[];
};
#endif

View file

@ -3,14 +3,12 @@
#include "MIPS.h"
CMIPSAnalysis::CMIPSAnalysis(CMIPS* ctx)
: m_ctx(ctx)
: m_ctx(ctx)
{
}
CMIPSAnalysis::~CMIPSAnalysis()
{
}
void CMIPSAnalysis::Clear()
@ -30,12 +28,12 @@ void CMIPSAnalysis::InsertSubroutine(uint32 start, uint32 end, uint32 stackAlloc
assert(FindSubroutine(end) == nullptr);
SUBROUTINE subroutine;
subroutine.start = start;
subroutine.end = end;
subroutine.stackAllocStart = stackAllocStart;
subroutine.stackAllocEnd = stackAllocEnd;
subroutine.stackSize = stackSize;
subroutine.returnAddrPos = returnAddrPos;
subroutine.start = start;
subroutine.end = end;
subroutine.stackAllocStart = stackAllocStart;
subroutine.stackAllocEnd = stackAllocEnd;
subroutine.stackSize = stackSize;
subroutine.returnAddrPos = returnAddrPos;
m_subroutines.insert(std::make_pair(start, subroutine));
}
@ -118,9 +116,9 @@ void CMIPSAnalysis::FindSubroutinesByStackAllocation(uint32 start, uint32 end)
//Check SW/SD/SQ RA, 0x????(SP)
if(
((opcode & 0xFFFF0000) == 0xAFBF0000) || //SW
((opcode & 0xFFFF0000) == 0xFFBF0000) || //SD
((opcode & 0xFFFF0000) == 0x7FBF0000)) //SQ
((opcode & 0xFFFF0000) == 0xAFBF0000) || //SW
((opcode & 0xFFFF0000) == 0xFFBF0000) || //SD
((opcode & 0xFFFF0000) == 0x7FBF0000)) //SQ
{
returnAddr = (opcode & 0xFFFF);
}
@ -179,8 +177,8 @@ void CMIPSAnalysis::FindSubroutinesByJumpTargets(uint32 start, uint32 end, uint3
{
uint32 opcode = m_ctx->m_pMemoryMap->GetInstruction(address);
if(
(opcode & 0xFC000000) == 0x0C000000 ||
(opcode & 0xFC000000) == 0x08000000)
(opcode & 0xFC000000) == 0x0C000000 ||
(opcode & 0xFC000000) == 0x08000000)
{
uint32 jumpTarget = (opcode & 0x03FFFFFF) * 4;
if(jumpTarget < start) continue;
@ -229,31 +227,30 @@ void CMIPSAnalysis::ExpandSubroutines(uint32 executableStart, uint32 executableE
static const uint32 searchLimit = 0x1000;
const auto& findFreeSubroutineEnd =
[this](uint32 begin, uint32 end) -> uint32
[this](uint32 begin, uint32 end) -> uint32 {
for(uint32 address = begin; address <= begin + searchLimit; address += 4)
{
for(uint32 address = begin; address <= begin + searchLimit; address += 4)
if(FindSubroutine(address) != nullptr) return MIPS_INVALID_PC;
uint32 opcode = m_ctx->m_pMemoryMap->GetInstruction(address);
//Check for JR RA or J
if((opcode == 0x03E00008) || ((opcode & 0xFC000000) == 0x08000000))
{
if(FindSubroutine(address) != nullptr) return MIPS_INVALID_PC;
uint32 opcode = m_ctx->m_pMemoryMap->GetInstruction(address);
//Check for JR RA or J
if((opcode == 0x03E00008) || ((opcode & 0xFC000000) == 0x08000000))
{
//+4 for delay slot
return address + 4;
}
//Check for BEQ R0, R0, $label
if((opcode & 0xFFFF0000) == 0x10000000)
{
//+4 for delay slot
return address + 4;
}
//+4 for delay slot
return address + 4;
}
return MIPS_INVALID_PC;
};
//Check for BEQ R0, R0, $label
if((opcode & 0xFFFF0000) == 0x10000000)
{
//+4 for delay slot
return address + 4;
}
}
return MIPS_INVALID_PC;
};
for(auto& subroutinePair : m_subroutines)
{
@ -324,9 +321,9 @@ static bool TryGetStringAtAddress(CMIPS* context, uint32 address, std::string& r
if(byte == 0) break;
if(byte > 0x7F) return false;
if((byte < 0x20) &&
(byte != '\t') &&
(byte != '\n') &&
(byte != '\r'))
(byte != '\t') &&
(byte != '\n') &&
(byte != '\r'))
{
return false;
}
@ -341,8 +338,8 @@ void CMIPSAnalysis::AnalyseStringReferences()
for(auto subroutinePair : m_subroutines)
{
const auto& subroutine = subroutinePair.second;
uint32 registerValue[0x20] = { 0 };
bool registerWritten[0x20] = { false };
uint32 registerValue[0x20] = {0};
bool registerWritten[0x20] = {false};
for(uint32 address = subroutine.start; address <= subroutine.end; address += 4)
{
uint32 op = m_ctx->m_pMemoryMap->GetInstruction(address);

View file

@ -12,38 +12,38 @@ class CMIPSAnalysis
public:
struct SUBROUTINE
{
uint32 start;
uint32 end;
uint32 stackAllocStart;
uint32 stackAllocEnd;
uint32 stackSize;
uint32 returnAddrPos;
uint32 start;
uint32 end;
uint32 stackAllocStart;
uint32 stackAllocEnd;
uint32 stackSize;
uint32 returnAddrPos;
};
typedef std::vector<uint32> CallStackItemArray;
CMIPSAnalysis(CMIPS*);
~CMIPSAnalysis();
void Analyse(uint32, uint32, uint32 = -1);
const SUBROUTINE* FindSubroutine(uint32) const;
void Clear();
CMIPSAnalysis(CMIPS*);
~CMIPSAnalysis();
void Analyse(uint32, uint32, uint32 = -1);
const SUBROUTINE* FindSubroutine(uint32) const;
void Clear();
void InsertSubroutine(uint32, uint32, uint32, uint32, uint32, uint32);
void ChangeSubroutineStart(uint32, uint32);
void ChangeSubroutineEnd(uint32, uint32);
void InsertSubroutine(uint32, uint32, uint32, uint32, uint32, uint32);
void ChangeSubroutineStart(uint32, uint32);
void ChangeSubroutineEnd(uint32, uint32);
static CallStackItemArray GetCallStack(CMIPS*, uint32 pc, uint32 sp, uint32 ra);
static CallStackItemArray GetCallStack(CMIPS*, uint32 pc, uint32 sp, uint32 ra);
private:
typedef std::map<uint32, SUBROUTINE, std::greater<uint32>> SubroutineList;
void AnalyseSubroutines(uint32, uint32, uint32);
void AnalyseStringReferences();
void AnalyseSubroutines(uint32, uint32, uint32);
void AnalyseStringReferences();
void FindSubroutinesByStackAllocation(uint32, uint32);
void FindSubroutinesByJumpTargets(uint32, uint32, uint32);
void ExpandSubroutines(uint32, uint32);
void FindSubroutinesByStackAllocation(uint32, uint32);
void FindSubroutinesByJumpTargets(uint32, uint32, uint32);
void ExpandSubroutines(uint32, uint32);
CMIPS* m_ctx;
SubroutineList m_subroutines;
CMIPS* m_ctx;
SubroutineList m_subroutines;
};

View file

@ -1,7 +1,6 @@
#include "MIPSArchitecture.h"
CMIPSArchitecture::CMIPSArchitecture(MIPS_REGSIZE regSize)
: CMIPSInstructionFactory(regSize)
: CMIPSInstructionFactory(regSize)
{
}

View file

@ -5,10 +5,10 @@
class CMIPSArchitecture : public CMIPSInstructionFactory
{
public:
CMIPSArchitecture(MIPS_REGSIZE);
virtual ~CMIPSArchitecture() = default;
virtual void GetInstructionMnemonic(CMIPS*, uint32, uint32, char*, unsigned int) = 0;
virtual void GetInstructionOperands(CMIPS*, uint32, uint32, char*, unsigned int) = 0;
virtual MIPS_BRANCH_TYPE IsInstructionBranch(CMIPS*, uint32, uint32) = 0;
virtual uint32 GetInstructionEffectiveAddress(CMIPS*, uint32, uint32) = 0;
CMIPSArchitecture(MIPS_REGSIZE);
virtual ~CMIPSArchitecture() = default;
virtual void GetInstructionMnemonic(CMIPS*, uint32, uint32, char*, unsigned int) = 0;
virtual void GetInstructionOperands(CMIPS*, uint32, uint32, char*, unsigned int) = 0;
virtual MIPS_BRANCH_TYPE IsInstructionBranch(CMIPS*, uint32, uint32) = 0;
virtual uint32 GetInstructionEffectiveAddress(CMIPS*, uint32, uint32) = 0;
};

View file

@ -4,11 +4,10 @@
#include "lexical_cast_ex.h"
CMIPSAssembler::CMIPSAssembler(uint32* ptr)
: m_ptr(ptr)
, m_startPtr(ptr)
, m_nextLabelId(1)
: m_ptr(ptr)
, m_startPtr(ptr)
, m_nextLabelId(1)
{
}
CMIPSAssembler::~CMIPSAssembler()
@ -71,13 +70,13 @@ void CMIPSAssembler::ADDIU(unsigned int rt, unsigned int rs, uint16 immediate)
void CMIPSAssembler::ADDU(unsigned int rd, unsigned int rs, unsigned int rt)
{
(*m_ptr) = (rs << 21) | (rt << 16) | (rd << 11) | (0x21);
(*m_ptr) = (rs << 21) | (rt << 16) | (rd << 11) | (0x21);
m_ptr++;
}
void CMIPSAssembler::AND(unsigned int rd, unsigned int rs, unsigned int rt)
{
(*m_ptr) = (rs << 21) | (rt << 16) | (rd << 11) | (0x24);
(*m_ptr) = (rs << 21) | (rt << 16) | (rd << 11) | (0x24);
m_ptr++;
}

View file

@ -10,92 +10,92 @@ public:
{
unsigned int id;
bool operator < (const LABEL& rhs) const
bool operator<(const LABEL& rhs) const
{
return id < rhs.id;
};
};
CMIPSAssembler(uint32*);
~CMIPSAssembler();
CMIPSAssembler(uint32*);
~CMIPSAssembler();
unsigned int GetProgramSize();
LABEL CreateLabel();
void MarkLabel(LABEL);
unsigned int GetProgramSize();
LABEL CreateLabel();
void MarkLabel(LABEL);
void ADDIU(unsigned int, unsigned int, uint16);
void ADDU(unsigned int, unsigned int, unsigned int);
void AND(unsigned int, unsigned int, unsigned int);
void ANDI(unsigned int, unsigned int, uint16);
void BEQ(unsigned int, unsigned int, uint16);
void BEQ(unsigned int, unsigned int, LABEL);
void BGEZ(unsigned int, uint16);
void BGEZ(unsigned int, LABEL);
void BGTZ(unsigned int, uint16);
void BNE(unsigned int, unsigned int, uint16);
void BNE(unsigned int, unsigned int, LABEL);
void BLEZ(unsigned int, uint16);
void BLTZ(unsigned int, uint16);
void DADDU(unsigned int, unsigned int, unsigned int);
void DADDIU(unsigned int, unsigned int, uint16);
void DSLL(unsigned int, unsigned int, unsigned int);
void DSLL32(unsigned int, unsigned int, unsigned int);
void DSLLV(unsigned int, unsigned int, unsigned int);
void DSRA(unsigned int, unsigned int, unsigned int);
void DSRA32(unsigned int, unsigned int, unsigned int);
void DSRAV(unsigned int, unsigned int, unsigned int);
void DSRL(unsigned int, unsigned int, unsigned int);
void DSRL32(unsigned int, unsigned int, unsigned int);
void DSRLV(unsigned int, unsigned int, unsigned int);
void DSUBU(unsigned int, unsigned int, unsigned int);
void ERET();
void JR(unsigned int);
void JAL(uint32);
void JALR(unsigned int, unsigned int = 31);
void LBU(unsigned int, uint16, unsigned int);
void LD(unsigned int, uint16, unsigned int);
void LDL(unsigned int, uint16, unsigned int);
void LDR(unsigned int, uint16, unsigned int);
void LHU(unsigned int, uint16, unsigned int);
void LI(unsigned int, uint32);
void LUI(unsigned int, uint16);
void LW(unsigned int, uint16, unsigned int);
void LWL(unsigned int, uint16, unsigned int);
void LWR(unsigned int, uint16, unsigned int);
void MFC0(unsigned int, unsigned int);
void MFHI(unsigned int);
void MFLO(unsigned int);
void MTC0(unsigned int, unsigned int);
void MTHI(unsigned int);
void MTLO(unsigned int);
void MOV(unsigned int, unsigned int);
void MULT(unsigned int, unsigned int, unsigned int);
void MULTU(unsigned int, unsigned int, unsigned int);
void NOP();
void NOR(unsigned int, unsigned int, unsigned int);
void OR(unsigned int, unsigned int, unsigned int);
void ORI(unsigned int, unsigned int, uint16);
void SD(unsigned int, uint16, unsigned int);
void SLL(unsigned int, unsigned int, unsigned int);
void SLLV(unsigned int, unsigned int, unsigned int);
void SLT(unsigned int, unsigned int, unsigned int);
void SLTI(unsigned int, unsigned int, uint16);
void SLTIU(unsigned int, unsigned int, uint16);
void SLTU(unsigned int, unsigned int, unsigned int);
void SRA(unsigned int, unsigned int, unsigned int);
void SRAV(unsigned int, unsigned int, unsigned int);
void SRL(unsigned int, unsigned int, unsigned int);
void SRLV(unsigned int, unsigned int, unsigned int);
void SB(unsigned int, uint16, unsigned int);
void SW(unsigned int, uint16, unsigned int);
void SYSCALL();
void ADDIU(unsigned int, unsigned int, uint16);
void ADDU(unsigned int, unsigned int, unsigned int);
void AND(unsigned int, unsigned int, unsigned int);
void ANDI(unsigned int, unsigned int, uint16);
void BEQ(unsigned int, unsigned int, uint16);
void BEQ(unsigned int, unsigned int, LABEL);
void BGEZ(unsigned int, uint16);
void BGEZ(unsigned int, LABEL);
void BGTZ(unsigned int, uint16);
void BNE(unsigned int, unsigned int, uint16);
void BNE(unsigned int, unsigned int, LABEL);
void BLEZ(unsigned int, uint16);
void BLTZ(unsigned int, uint16);
void DADDU(unsigned int, unsigned int, unsigned int);
void DADDIU(unsigned int, unsigned int, uint16);
void DSLL(unsigned int, unsigned int, unsigned int);
void DSLL32(unsigned int, unsigned int, unsigned int);
void DSLLV(unsigned int, unsigned int, unsigned int);
void DSRA(unsigned int, unsigned int, unsigned int);
void DSRA32(unsigned int, unsigned int, unsigned int);
void DSRAV(unsigned int, unsigned int, unsigned int);
void DSRL(unsigned int, unsigned int, unsigned int);
void DSRL32(unsigned int, unsigned int, unsigned int);
void DSRLV(unsigned int, unsigned int, unsigned int);
void DSUBU(unsigned int, unsigned int, unsigned int);
void ERET();
void JR(unsigned int);
void JAL(uint32);
void JALR(unsigned int, unsigned int = 31);
void LBU(unsigned int, uint16, unsigned int);
void LD(unsigned int, uint16, unsigned int);
void LDL(unsigned int, uint16, unsigned int);
void LDR(unsigned int, uint16, unsigned int);
void LHU(unsigned int, uint16, unsigned int);
void LI(unsigned int, uint32);
void LUI(unsigned int, uint16);
void LW(unsigned int, uint16, unsigned int);
void LWL(unsigned int, uint16, unsigned int);
void LWR(unsigned int, uint16, unsigned int);
void MFC0(unsigned int, unsigned int);
void MFHI(unsigned int);
void MFLO(unsigned int);
void MTC0(unsigned int, unsigned int);
void MTHI(unsigned int);
void MTLO(unsigned int);
void MOV(unsigned int, unsigned int);
void MULT(unsigned int, unsigned int, unsigned int);
void MULTU(unsigned int, unsigned int, unsigned int);
void NOP();
void NOR(unsigned int, unsigned int, unsigned int);
void OR(unsigned int, unsigned int, unsigned int);
void ORI(unsigned int, unsigned int, uint16);
void SD(unsigned int, uint16, unsigned int);
void SLL(unsigned int, unsigned int, unsigned int);
void SLLV(unsigned int, unsigned int, unsigned int);
void SLT(unsigned int, unsigned int, unsigned int);
void SLTI(unsigned int, unsigned int, uint16);
void SLTIU(unsigned int, unsigned int, uint16);
void SLTU(unsigned int, unsigned int, unsigned int);
void SRA(unsigned int, unsigned int, unsigned int);
void SRAV(unsigned int, unsigned int, unsigned int);
void SRL(unsigned int, unsigned int, unsigned int);
void SRLV(unsigned int, unsigned int, unsigned int);
void SB(unsigned int, uint16, unsigned int);
void SW(unsigned int, uint16, unsigned int);
void SYSCALL();
protected:
uint32* m_ptr = nullptr;
uint32* m_ptr = nullptr;
private:
void ResolveLabelReferences();
void CreateLabelReference(LABEL);
void ResolveLabelReferences();
void CreateLabelReference(LABEL);
struct LABELREF
{
@ -105,8 +105,8 @@ private:
typedef std::map<LABEL, size_t> LabelMapType;
typedef std::multimap<LABEL, LABELREF> LabelReferenceMapType;
uint32* m_startPtr = nullptr;
LabelMapType m_labels;
LabelReferenceMapType m_labelReferences;
unsigned int m_nextLabelId;
uint32* m_startPtr = nullptr;
LabelMapType m_labels;
LabelReferenceMapType m_labelReferences;
unsigned int m_nextLabelId;
};

View file

@ -1,12 +1,10 @@
#include "MIPSCoprocessor.h"
CMIPSCoprocessor::CMIPSCoprocessor(MIPS_REGSIZE nRegSize) :
CMIPSInstructionFactory(nRegSize)
CMIPSCoprocessor::CMIPSCoprocessor(MIPS_REGSIZE nRegSize)
: CMIPSInstructionFactory(nRegSize)
{
}
CMIPSCoprocessor::~CMIPSCoprocessor()
{
}

View file

@ -6,12 +6,12 @@
class CMIPSCoprocessor : public CMIPSInstructionFactory
{
public:
CMIPSCoprocessor(MIPS_REGSIZE);
virtual ~CMIPSCoprocessor();
virtual void GetInstruction(uint32, char*) = 0;
virtual void GetArguments(uint32, uint32, char*) = 0;
virtual uint32 GetEffectiveAddress(uint32, uint32) = 0;
virtual MIPS_BRANCH_TYPE IsBranch(uint32) = 0;
CMIPSCoprocessor(MIPS_REGSIZE);
virtual ~CMIPSCoprocessor();
virtual void GetInstruction(uint32, char*) = 0;
virtual void GetArguments(uint32, uint32, char*) = 0;
virtual uint32 GetEffectiveAddress(uint32, uint32) = 0;
virtual MIPS_BRANCH_TYPE IsBranch(uint32) = 0;
};
#endif

View file

@ -5,24 +5,23 @@
#include "offsetof_def.h"
CMIPSInstructionFactory::CMIPSInstructionFactory(MIPS_REGSIZE nRegSize)
: m_regSize(nRegSize)
: m_regSize(nRegSize)
{
}
void CMIPSInstructionFactory::SetupQuickVariables(uint32 nAddress, CMipsJitter* codeGen, CMIPS* pCtx)
{
m_pCtx = pCtx;
m_codeGen = codeGen;
m_nAddress = nAddress;
m_pCtx = pCtx;
m_codeGen = codeGen;
m_nAddress = nAddress;
m_nOpcode = m_pCtx->m_pMemoryMap->GetInstruction(m_nAddress);
m_nOpcode = m_pCtx->m_pMemoryMap->GetInstruction(m_nAddress);
}
void CMIPSInstructionFactory::ComputeMemAccessAddr()
{
uint8 nRS = (uint8) ((m_nOpcode >> 21) & 0x001F);
uint16 nImmediate = (uint16)((m_nOpcode >> 0) & 0xFFFF);
uint8 nRS = (uint8)((m_nOpcode >> 21) & 0x001F);
uint16 nImmediate = (uint16)((m_nOpcode >> 0) & 0xFFFF);
if(m_pCtx->m_pAddrTranslator == &CMIPS::TranslateAddress64)
{

View file

@ -7,35 +7,35 @@ class CMIPS;
enum MIPS_REGSIZE
{
MIPS_REGSIZE_32 = 0,
MIPS_REGSIZE_64 = 1,
MIPS_REGSIZE_32 = 0,
MIPS_REGSIZE_64 = 1,
};
enum MIPS_BRANCH_TYPE
{
MIPS_BRANCH_NONE = 0,
MIPS_BRANCH_NORMAL = 1,
MIPS_BRANCH_NODELAY = 2,
MIPS_BRANCH_NONE = 0,
MIPS_BRANCH_NORMAL = 1,
MIPS_BRANCH_NODELAY = 2,
};
class CMIPSInstructionFactory
{
public:
CMIPSInstructionFactory(MIPS_REGSIZE);
virtual ~CMIPSInstructionFactory() = default;
virtual void CompileInstruction(uint32, CMipsJitter*, CMIPS*) = 0;
CMIPSInstructionFactory(MIPS_REGSIZE);
virtual ~CMIPSInstructionFactory() = default;
virtual void CompileInstruction(uint32, CMipsJitter*, CMIPS*) = 0;
protected:
void ComputeMemAccessAddr();
void Branch(Jitter::CONDITION);
void BranchLikely(Jitter::CONDITION);
void ComputeMemAccessAddr();
void Branch(Jitter::CONDITION);
void BranchLikely(Jitter::CONDITION);
void Illegal();
void SetupQuickVariables(uint32, CMipsJitter*, CMIPS*);
void Illegal();
void SetupQuickVariables(uint32, CMipsJitter*, CMIPS*);
CMipsJitter* m_codeGen = nullptr;
CMIPS* m_pCtx = nullptr;
uint32 m_nOpcode = 0;
uint32 m_nAddress = 0;
MIPS_REGSIZE m_regSize;
CMipsJitter* m_codeGen = nullptr;
CMIPS* m_pCtx = nullptr;
uint32 m_nOpcode = 0;
uint32 m_nAddress = 0;
MIPS_REGSIZE m_regSize;
};

View file

@ -12,33 +12,34 @@ namespace MIPSReflection
struct SUBTABLE
{
uint32 nShift;
uint32 nMask;
INSTRUCTION* pTable;
uint32 nShift;
uint32 nMask;
INSTRUCTION* pTable;
};
struct INSTRUCTION
{
const char* sMnemonic;
SUBTABLE* pSubTable;
void (*pGetMnemonic)(INSTRUCTION*, CMIPS*, uint32, char*, unsigned int);
void (*pGetOperands)(INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
MIPS_BRANCH_TYPE (*pIsBranch)(INSTRUCTION*, CMIPS*, uint32);
uint32 (*pGetEffectiveAddress)(INSTRUCTION*, CMIPS*, uint32, uint32);
const char* sMnemonic;
SUBTABLE* pSubTable;
void (*pGetMnemonic)(INSTRUCTION*, CMIPS*, uint32, char*, unsigned int);
void (*pGetOperands)(INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
MIPS_BRANCH_TYPE(*pIsBranch)
(INSTRUCTION*, CMIPS*, uint32);
uint32 (*pGetEffectiveAddress)(INSTRUCTION*, CMIPS*, uint32, uint32);
};
INSTRUCTION* DereferenceInstruction(SUBTABLE*, uint32);
INSTRUCTION* DereferenceInstruction(SUBTABLE*, uint32);
void CopyMnemonic(INSTRUCTION*, CMIPS*, uint32, char*, unsigned int);
void SubTableMnemonic(INSTRUCTION*, CMIPS*, uint32, char*, unsigned int);
void CopyMnemonic(INSTRUCTION*, CMIPS*, uint32, char*, unsigned int);
void SubTableMnemonic(INSTRUCTION*, CMIPS*, uint32, char*, unsigned int);
void SubTableOperands(INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
void SubTableOperands(INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
MIPS_BRANCH_TYPE IsBranch(INSTRUCTION*, CMIPS*, uint32);
MIPS_BRANCH_TYPE IsNoDelayBranch(INSTRUCTION*, CMIPS*, uint32);
MIPS_BRANCH_TYPE SubTableIsBranch(INSTRUCTION*, CMIPS*, uint32);
MIPS_BRANCH_TYPE IsBranch(INSTRUCTION*, CMIPS*, uint32);
MIPS_BRANCH_TYPE IsNoDelayBranch(INSTRUCTION*, CMIPS*, uint32);
MIPS_BRANCH_TYPE SubTableIsBranch(INSTRUCTION*, CMIPS*, uint32);
uint32 SubTableEffAddr(INSTRUCTION*, CMIPS*, uint32, uint32);
uint32 SubTableEffAddr(INSTRUCTION*, CMIPS*, uint32, uint32);
};
#endif

View file

@ -3,9 +3,9 @@
#include "lexical_cast_ex.h"
#include "xml/FilteringNodeIterator.h"
#define TAG_ELEMENT_NAME ("tag")
#define TAG_ELEMENT_ATTRIBUTE_ADDRESS ("address")
#define TAG_ELEMENT_ATTRIBUTE_VALUE ("value")
#define TAG_ELEMENT_NAME ("tag")
#define TAG_ELEMENT_ATTRIBUTE_ADDRESS ("address")
#define TAG_ELEMENT_ATTRIBUTE_VALUE ("value")
void CMIPSTags::InsertTag(uint32 nAddress, const char* sTag)
{
@ -75,8 +75,8 @@ void CMIPSTags::Unserialize(const char* sPath)
{
char sTag[256];
uint32 nKey = Stream.Read32();
uint8 nLength = Stream.Read8();
uint32 nKey = Stream.Read32();
uint8 nLength = Stream.Read8();
Stream.Read(sTag, nLength);
sTag[nLength] = 0;
@ -86,7 +86,6 @@ void CMIPSTags::Unserialize(const char* sPath)
}
catch(...)
{
}
}
@ -118,11 +117,11 @@ void CMIPSTags::Serialize(Framework::Xml::CNode* parentNode) const
void CMIPSTags::Unserialize(Framework::Xml::CNode* parentNode)
{
for(Framework::Xml::CFilteringNodeIterator nodeIterator(parentNode, TAG_ELEMENT_NAME);
!nodeIterator.IsEnd(); nodeIterator++)
!nodeIterator.IsEnd(); nodeIterator++)
{
auto node = *nodeIterator;
auto addressText = node->GetAttribute(TAG_ELEMENT_ATTRIBUTE_ADDRESS);
auto valueText = node->GetAttribute(TAG_ELEMENT_ATTRIBUTE_VALUE);
auto valueText = node->GetAttribute(TAG_ELEMENT_ATTRIBUTE_VALUE);
if(!addressText || !valueText) continue;
uint32 address = lexical_cast_hex<std::string>(addressText);
InsertTag(address, valueText);

View file

@ -9,27 +9,27 @@
class CMIPSTags
{
public:
typedef std::map<uint32, std::string> TagMap;
typedef TagMap::const_iterator TagIterator;
typedef std::map<uint32, std::string> TagMap;
typedef TagMap::const_iterator TagIterator;
boost::signals2::signal<void ()> OnTagListChange;
boost::signals2::signal<void()> OnTagListChange;
void InsertTag(uint32, const char*);
void RemoveTags();
const char* Find(uint32) const;
void InsertTag(uint32, const char*);
void RemoveTags();
const char* Find(uint32) const;
void Serialize(Framework::Xml::CNode*, const char*) const;
void Unserialize(Framework::Xml::CNode*, const char*);
void Serialize(Framework::Xml::CNode*, const char*) const;
void Unserialize(Framework::Xml::CNode*, const char*);
void Serialize(Framework::Xml::CNode*) const;
void Unserialize(Framework::Xml::CNode*);
void Serialize(Framework::Xml::CNode*) const;
void Unserialize(Framework::Xml::CNode*);
void Serialize(const char*) const;
void Unserialize(const char*);
void Serialize(const char*) const;
void Unserialize(const char*);
TagIterator GetTagsBegin() const;
TagIterator GetTagsEnd() const;
TagIterator GetTagsBegin() const;
TagIterator GetTagsEnd() const;
private:
TagMap m_tags;
TagMap m_tags;
};

View file

@ -26,7 +26,7 @@ void CMailBox::WaitForCall(unsigned int timeOut)
void CMailBox::FlushCalls()
{
SendCall([] () { }, true);
SendCall([]() {}, true);
}
void CMailBox::SendCall(const FunctionType& function, bool waitForCompletion)
@ -36,7 +36,7 @@ void CMailBox::SendCall(const FunctionType& function, bool waitForCompletion)
{
MESSAGE message;
message.function = function;
message.sync = waitForCompletion;
message.sync = waitForCompletion;
m_calls.push_back(std::move(message));
}
@ -69,7 +69,7 @@ void CMailBox::SendCall(FunctionType&& function)
{
MESSAGE message;
message.function = std::move(function);
message.sync = false;
message.sync = false;
m_calls.push_back(std::move(message));
}

View file

@ -8,18 +8,18 @@
class CMailBox
{
public:
virtual ~CMailBox() = default;
virtual ~CMailBox() = default;
typedef std::function<void ()> FunctionType;
typedef std::function<void()> FunctionType;
void SendCall(const FunctionType&, bool = false);
void SendCall(FunctionType&&);
void FlushCalls();
void SendCall(const FunctionType&, bool = false);
void SendCall(FunctionType&&);
void FlushCalls();
bool IsPending() const;
void ReceiveCall();
void WaitForCall();
void WaitForCall(unsigned int);
bool IsPending() const;
void ReceiveCall();
void WaitForCall();
void WaitForCall(unsigned int);
private:
struct MESSAGE
@ -29,18 +29,18 @@ private:
MESSAGE(MESSAGE&&) = default;
MESSAGE(const MESSAGE&) = delete;
MESSAGE& operator =(MESSAGE&&) = default;
MESSAGE& operator =(const MESSAGE&) = delete;
MESSAGE& operator=(MESSAGE&&) = default;
MESSAGE& operator=(const MESSAGE&) = delete;
FunctionType function;
bool sync;
FunctionType function;
bool sync;
};
typedef std::deque<MESSAGE> FunctionCallQueue;
FunctionCallQueue m_calls;
std::mutex m_callMutex;
std::condition_variable m_callFinished;
std::condition_variable m_waitCondition;
bool m_callDone;
FunctionCallQueue m_calls;
std::mutex m_callMutex;
std::condition_variable m_callFinished;
std::condition_variable m_waitCondition;
bool m_callDone;
};

View file

@ -47,21 +47,21 @@ const CMemoryMap::MEMORYMAPELEMENT* CMemoryMap::GetWriteMap(uint32 address) cons
void CMemoryMap::InsertMap(MemoryMapListType& memoryMap, uint32 start, uint32 end, void* pointer, unsigned char key)
{
MEMORYMAPELEMENT element;
element.nStart = start;
element.nEnd = end;
element.pPointer = pointer;
element.nType = MEMORYMAP_TYPE_MEMORY;
element.nStart = start;
element.nEnd = end;
element.pPointer = pointer;
element.nType = MEMORYMAP_TYPE_MEMORY;
memoryMap.push_back(element);
}
void CMemoryMap::InsertMap(MemoryMapListType& memoryMap, uint32 start, uint32 end, const MemoryMapHandlerType& handler, unsigned char key)
{
MEMORYMAPELEMENT element;
element.nStart = start;
element.nEnd = end;
element.handler = handler;
element.pPointer = nullptr;
element.nType = MEMORYMAP_TYPE_FUNCTION;
element.nStart = start;
element.nEnd = end;
element.handler = handler;
element.pPointer = nullptr;
element.nType = MEMORYMAP_TYPE_FUNCTION;
memoryMap.push_back(element);
}

View file

@ -14,7 +14,7 @@ enum MEMORYMAP_ENDIANESS
class CMemoryMap
{
public:
typedef std::function<uint32 (uint32, uint32)> MemoryMapHandlerType;
typedef std::function<uint32(uint32, uint32)> MemoryMapHandlerType;
enum MEMORYMAP_TYPE
{
@ -24,51 +24,51 @@ public:
struct MEMORYMAPELEMENT
{
uint32 nStart;
uint32 nEnd;
void* pPointer;
MemoryMapHandlerType handler;
MEMORYMAP_TYPE nType;
uint32 nStart;
uint32 nEnd;
void* pPointer;
MemoryMapHandlerType handler;
MEMORYMAP_TYPE nType;
};
virtual ~CMemoryMap() = default;
uint8 GetByte(uint32);
virtual uint16 GetHalf(uint32) = 0;
virtual uint32 GetWord(uint32) = 0;
virtual uint32 GetInstruction(uint32) = 0;
virtual void SetByte(uint32, uint8);
virtual void SetHalf(uint32, uint16) = 0;
virtual void SetWord(uint32, uint32) = 0;
void InsertReadMap(uint32, uint32, void*, unsigned char);
void InsertReadMap(uint32, uint32, const MemoryMapHandlerType&, unsigned char);
void InsertWriteMap(uint32, uint32, void*, unsigned char);
void InsertWriteMap(uint32, uint32, const MemoryMapHandlerType&, unsigned char);
void InsertInstructionMap(uint32, uint32, void*, unsigned char);
const MEMORYMAPELEMENT* GetReadMap(uint32) const;
const MEMORYMAPELEMENT* GetWriteMap(uint32) const;
virtual ~CMemoryMap() = default;
uint8 GetByte(uint32);
virtual uint16 GetHalf(uint32) = 0;
virtual uint32 GetWord(uint32) = 0;
virtual uint32 GetInstruction(uint32) = 0;
virtual void SetByte(uint32, uint8);
virtual void SetHalf(uint32, uint16) = 0;
virtual void SetWord(uint32, uint32) = 0;
void InsertReadMap(uint32, uint32, void*, unsigned char);
void InsertReadMap(uint32, uint32, const MemoryMapHandlerType&, unsigned char);
void InsertWriteMap(uint32, uint32, void*, unsigned char);
void InsertWriteMap(uint32, uint32, const MemoryMapHandlerType&, unsigned char);
void InsertInstructionMap(uint32, uint32, void*, unsigned char);
const MEMORYMAPELEMENT* GetReadMap(uint32) const;
const MEMORYMAPELEMENT* GetWriteMap(uint32) const;
protected:
typedef std::vector<MEMORYMAPELEMENT> MemoryMapListType;
static const MEMORYMAPELEMENT* GetMap(const MemoryMapListType&, uint32);
static const MEMORYMAPELEMENT* GetMap(const MemoryMapListType&, uint32);
MemoryMapListType m_instructionMap;
MemoryMapListType m_readMap;
MemoryMapListType m_writeMap;
MemoryMapListType m_instructionMap;
MemoryMapListType m_readMap;
MemoryMapListType m_writeMap;
private:
static void InsertMap(MemoryMapListType&, uint32, uint32, void*, unsigned char);
static void InsertMap(MemoryMapListType&, uint32, uint32, const MemoryMapHandlerType&, unsigned char);
static void InsertMap(MemoryMapListType&, uint32, uint32, void*, unsigned char);
static void InsertMap(MemoryMapListType&, uint32, uint32, const MemoryMapHandlerType&, unsigned char);
};
class CMemoryMap_LSBF : public CMemoryMap
{
public:
uint16 GetHalf(uint32);
uint32 GetWord(uint32);
uint32 GetInstruction(uint32);
void SetHalf(uint32, uint16);
void SetWord(uint32, uint32);
uint16 GetHalf(uint32);
uint32 GetWord(uint32);
uint32 GetInstruction(uint32);
void SetHalf(uint32, uint16);
void SetWord(uint32, uint32);
};
#endif

View file

@ -1,11 +1,10 @@
#include "MemoryStateFile.h"
CMemoryStateFile::CMemoryStateFile(const char* name, const void* memory, size_t size)
: CZipFile(name)
, m_memory(memory)
, m_size(size)
: CZipFile(name)
, m_memory(memory)
, m_size(size)
{
}
void CMemoryStateFile::Write(Framework::CStream& stream)

View file

@ -5,12 +5,12 @@
class CMemoryStateFile : public Framework::CZipFile
{
public:
CMemoryStateFile(const char*, const void*, size_t);
virtual ~CMemoryStateFile() = default;
CMemoryStateFile(const char*, const void*, size_t);
virtual ~CMemoryStateFile() = default;
void Write(Framework::CStream&) override;
void Write(Framework::CStream&) override;
private:
const void* m_memory = nullptr;
size_t m_size = 0;
const void* m_memory = nullptr;
size_t m_size = 0;
};

View file

@ -101,7 +101,7 @@ void MemoryUtils_SetDoubleProxy(CMIPS* context, uint64 value64, uint32 address)
if(!e)
{
CLog::GetInstance().Print(LOG_NAME, "Wrote to unmapped memory (0x%08X, [0x%08X, 0x%08X]).\r\n",
address, value.d0, value.d1);
address, value.d0, value.d1);
return;
}
switch(e->nType)
@ -128,7 +128,7 @@ void MemoryUtils_SetQuadProxy(CMIPS* context, const uint128& value, uint32 addre
if(!e)
{
CLog::GetInstance().Print(LOG_NAME, "Wrote to unmapped memory (0x%08X, [0x%08X, 0x%08X, 0x%08X, 0x%08X]).\r\n",
address, value.nV0, value.nV1, value.nV2, value.nV3);
address, value.nV0, value.nV1, value.nV2, value.nV3);
return;
}
switch(e->nType)

View file

@ -4,15 +4,15 @@
extern "C"
{
uint32 MemoryUtils_GetByteProxy(CMIPS*, uint32);
uint32 MemoryUtils_GetHalfProxy(CMIPS*, uint32);
uint32 MemoryUtils_GetWordProxy(CMIPS*, uint32);
uint64 MemoryUtils_GetDoubleProxy(CMIPS*, uint32);
uint128 MemoryUtils_GetQuadProxy(CMIPS*, uint32);
uint32 MemoryUtils_GetByteProxy(CMIPS*, uint32);
uint32 MemoryUtils_GetHalfProxy(CMIPS*, uint32);
uint32 MemoryUtils_GetWordProxy(CMIPS*, uint32);
uint64 MemoryUtils_GetDoubleProxy(CMIPS*, uint32);
uint128 MemoryUtils_GetQuadProxy(CMIPS*, uint32);
void MemoryUtils_SetByteProxy(CMIPS*, uint32, uint32);
void MemoryUtils_SetHalfProxy(CMIPS*, uint32, uint32);
void MemoryUtils_SetWordProxy(CMIPS*, uint32, uint32);
void MemoryUtils_SetDoubleProxy(CMIPS*, uint64, uint32);
void MemoryUtils_SetQuadProxy(CMIPS*, const uint128&, uint32);
void MemoryUtils_SetByteProxy(CMIPS*, uint32, uint32);
void MemoryUtils_SetHalfProxy(CMIPS*, uint32, uint32);
void MemoryUtils_SetWordProxy(CMIPS*, uint32, uint32);
void MemoryUtils_SetDoubleProxy(CMIPS*, uint64, uint32);
void MemoryUtils_SetQuadProxy(CMIPS*, const uint128&, uint32);
}

View file

@ -10,8 +10,8 @@ static bool IsInsideRange(uint32 address, uint32 start, uint32 end)
#define SUBTABLE_MASK (SUBTABLE_SIZE - 1)
CMipsExecutor::CMipsExecutor(CMIPS& context, uint32 maxAddress)
: m_context(context)
, m_maxAddress(maxAddress)
: m_context(context)
, m_maxAddress(maxAddress)
{
m_subTableCount = (m_maxAddress + SUBTABLE_MASK) / SUBTABLE_SIZE;
assert(m_subTableCount != 0);
@ -26,10 +26,10 @@ CMipsExecutor::~CMipsExecutor()
CBasicBlock** subTable = m_blockTable[i];
if(subTable != NULL)
{
delete [] subTable;
delete[] subTable;
}
}
delete [] m_blockTable;
delete[] m_blockTable;
}
void CMipsExecutor::Reset()
@ -44,7 +44,7 @@ void CMipsExecutor::ClearActiveBlocks()
CBasicBlock** subTable = m_blockTable[i];
if(subTable != NULL)
{
delete [] subTable;
delete[] subTable;
m_blockTable[i] = NULL;
}
}
@ -80,8 +80,7 @@ void CMipsExecutor::ClearActiveBlocksInRangeInternal(uint32 start, uint32 end, C
auto block = table[lo / 4];
if(block == nullptr) continue;
if(block == protectedBlock) continue;
if(!IsInsideRange(block->GetBeginAddress(), start, end)
&& !IsInsideRange(block->GetEndAddress(), start, end)) continue;
if(!IsInsideRange(block->GetBeginAddress(), start, end) && !IsInsideRange(block->GetEndAddress(), start, end)) continue;
table[lo / 4] = nullptr;
blocksToDelete.insert(block);
}
@ -89,7 +88,7 @@ void CMipsExecutor::ClearActiveBlocksInRangeInternal(uint32 start, uint32 end, C
if(!blocksToDelete.empty())
{
m_blocks.remove_if([&] (const BasicBlockPtr& block) { return blocksToDelete.find(block.get()) != std::end(blocksToDelete); });
m_blocks.remove_if([&](const BasicBlockPtr& block) { return blocksToDelete.find(block.get()) != std::end(blocksToDelete); });
}
}
@ -214,7 +213,7 @@ void CMipsExecutor::DeleteBlock(CBasicBlock* block)
}
//Remove block from our lists
auto blockIterator = std::find_if(std::begin(m_blocks), std::end(m_blocks), [&] (const BasicBlockPtr& blockPtr) { return blockPtr.get() == block; });
auto blockIterator = std::find_if(std::begin(m_blocks), std::end(m_blocks), [&](const BasicBlockPtr& blockPtr) { return blockPtr.get() == block; });
assert(blockIterator != std::end(m_blocks));
m_blocks.erase(blockIterator);
}
@ -236,7 +235,7 @@ void CMipsExecutor::PartitionFunction(uint32 functionAddress)
partitionPoints.insert(functionAddress);
//Find the end
for(uint32 address = functionAddress; ; address += 4)
for(uint32 address = functionAddress;; address += 4)
{
//Probably going too far...
if((address - functionAddress) > 0x10000)
@ -292,7 +291,7 @@ void CMipsExecutor::PartitionFunction(uint32 functionAddress)
{
uint32 currentPoint = -1;
for(PartitionPointSet::const_iterator pointIterator(partitionPoints.begin());
pointIterator != partitionPoints.end(); ++pointIterator)
pointIterator != partitionPoints.end(); ++pointIterator)
{
if(currentPoint != -1)
{

View file

@ -7,8 +7,8 @@
class CMipsExecutor
{
public:
CMipsExecutor(CMIPS&, uint32);
virtual ~CMipsExecutor();
CMipsExecutor(CMIPS&, uint32);
virtual ~CMipsExecutor();
template <uint32 (*TranslateFunction)(CMIPS*, uint32) = CMIPS::TranslateAddress64>
int Execute(int cycles)
@ -40,36 +40,36 @@ public:
return cycles;
}
CBasicBlock* FindBlockAt(uint32) const;
CBasicBlock* FindBlockStartingAt(uint32) const;
void DeleteBlock(CBasicBlock*);
virtual void Reset();
void ClearActiveBlocks();
virtual void ClearActiveBlocksInRange(uint32, uint32);
CBasicBlock* FindBlockAt(uint32) const;
CBasicBlock* FindBlockStartingAt(uint32) const;
void DeleteBlock(CBasicBlock*);
virtual void Reset();
void ClearActiveBlocks();
virtual void ClearActiveBlocksInRange(uint32, uint32);
#ifdef DEBUGGER_INCLUDED
bool MustBreak() const;
void DisableBreakpointsOnce();
bool MustBreak() const;
void DisableBreakpointsOnce();
#endif
protected:
typedef std::shared_ptr<CBasicBlock> BasicBlockPtr;
typedef std::list<BasicBlockPtr> BlockList;
void CreateBlock(uint32, uint32);
virtual BasicBlockPtr BlockFactory(CMIPS&, uint32, uint32);
virtual void PartitionFunction(uint32);
void CreateBlock(uint32, uint32);
virtual BasicBlockPtr BlockFactory(CMIPS&, uint32, uint32);
virtual void PartitionFunction(uint32);
void ClearActiveBlocksInRangeInternal(uint32, uint32, CBasicBlock*);
void ClearActiveBlocksInRangeInternal(uint32, uint32, CBasicBlock*);
BlockList m_blocks;
CMIPS& m_context;
uint32 m_maxAddress = 0;
BlockList m_blocks;
CMIPS& m_context;
uint32 m_maxAddress = 0;
CBasicBlock*** m_blockTable = nullptr;
uint32 m_subTableCount = 0;
CBasicBlock*** m_blockTable = nullptr;
uint32 m_subTableCount = 0;
#ifdef DEBUGGER_INCLUDED
bool m_breakpointsDisabledOnce = false;
bool m_breakpointsDisabledOnce = false;
#endif
};

View file

@ -9,7 +9,6 @@ CMipsFunctionPatternDb::CMipsFunctionPatternDb(Framework::Xml::CNode* node)
CMipsFunctionPatternDb::~CMipsFunctionPatternDb()
{
}
const CMipsFunctionPatternDb::PatternArray& CMipsFunctionPatternDb::GetPatterns() const
@ -25,7 +24,7 @@ void CMipsFunctionPatternDb::Read(Framework::Xml::CNode* node)
m_patterns.reserve(patternsNode->GetChildCount());
for(Framework::Xml::CFilteringNodeIterator patternNodeIterator(patternsNode, "FunctionPattern");
!patternNodeIterator.IsEnd(); patternNodeIterator++)
!patternNodeIterator.IsEnd(); patternNodeIterator++)
{
auto patternNode = (*patternNodeIterator);
@ -69,7 +68,7 @@ CMipsFunctionPatternDb::Pattern CMipsFunctionPatternDb::ParsePattern(const char*
if(currValue.length() != 0)
{
//Parse value
PATTERNITEM item = { 0 };
PATTERNITEM item = {0};
if(ParsePatternItem(currValue.c_str(), item))
{
result.items.push_back(item);

View file

@ -11,8 +11,8 @@ class CMipsFunctionPatternDb
public:
struct PATTERNITEM
{
uint32 value;
uint32 mask;
uint32 value;
uint32 mask;
};
class Pattern
@ -20,26 +20,25 @@ public:
public:
typedef std::vector<PATTERNITEM> ItemArray;
bool Matches(uint32*, uint32) const;
bool Matches(uint32*, uint32) const;
std::string name;
ItemArray items;
std::string name;
ItemArray items;
};
typedef std::vector<Pattern> PatternArray;
CMipsFunctionPatternDb(Framework::Xml::CNode*);
virtual ~CMipsFunctionPatternDb();
CMipsFunctionPatternDb(Framework::Xml::CNode*);
virtual ~CMipsFunctionPatternDb();
const PatternArray& GetPatterns() const;
const PatternArray& GetPatterns() const;
private:
void Read(Framework::Xml::CNode*);
Pattern ParsePattern(const char*);
bool ParsePatternItem(const char*, PATTERNITEM&);
void Read(Framework::Xml::CNode*);
Pattern ParsePattern(const char*);
bool ParsePatternItem(const char*, PATTERNITEM&);
PatternArray m_patterns;
PatternArray m_patterns;
};
#endif

View file

@ -2,15 +2,13 @@
#include "MipsJitter.h"
CMipsJitter::CMipsJitter(Jitter::CCodeGen* codeGen)
: CJitter(codeGen)
, m_lastBlockLabel(-1)
: CJitter(codeGen)
, m_lastBlockLabel(-1)
{
}
CMipsJitter::~CMipsJitter()
{
}
void CMipsJitter::Begin()

View file

@ -6,30 +6,30 @@
class CMipsJitter : public Jitter::CJitter
{
public:
CMipsJitter(Jitter::CCodeGen*);
virtual ~CMipsJitter();
CMipsJitter(Jitter::CCodeGen*);
virtual ~CMipsJitter();
virtual void Begin();
virtual void End();
virtual void PushRel(size_t);
virtual void PushRel64(size_t);
virtual void Begin();
virtual void End();
virtual void PushRel(size_t);
virtual void PushRel64(size_t);
void SetVariableAsConstant(size_t, uint32);
LABEL GetFinalBlockLabel();
void SetVariableAsConstant(size_t, uint32);
LABEL GetFinalBlockLabel();
private:
struct VARIABLESTATUS
{
uint32 operandType;
uint32 operandValue;
uint32 operandType;
uint32 operandValue;
};
typedef std::map<size_t, VARIABLESTATUS> VariableStatusMap;
VARIABLESTATUS* GetVariableStatus(size_t);
void SetVariableStatus(size_t, const VARIABLESTATUS&);
void SaveVariableStatus(size_t, const VARIABLESTATUS&);
VARIABLESTATUS* GetVariableStatus(size_t);
void SetVariableStatus(size_t, const VARIABLESTATUS&);
void SaveVariableStatus(size_t, const VARIABLESTATUS&);
VariableStatusMap m_variableStatus;
LABEL m_lastBlockLabel;
VariableStatusMap m_variableStatus;
LABEL m_lastBlockLabel;
};

View file

@ -81,9 +81,8 @@ void COpticalMedia::CheckDualLayerDvd(const StreamPtr& stream)
char blockHeader[blockHeaderSize];
stream->Read(blockHeader, blockHeaderSize);
if(
(blockHeader[0] == 0x01) &&
(!strncmp(blockHeader + 1, "CD001", 5))
)
(blockHeader[0] == 0x01) &&
(!strncmp(blockHeader + 1, "CD001", 5)))
{
//We've found a valid ISO9660 descriptor
m_dvdSecondLayerStart = lba;

View file

@ -18,19 +18,19 @@ public:
COpticalMedia(const StreamPtr&);
//TODO: Get Track Count
TRACK_DATA_TYPE GetTrackDataType(uint32) const;
CISO9660* GetFileSystem();
TRACK_DATA_TYPE GetTrackDataType(uint32) const;
CISO9660* GetFileSystem();
bool GetDvdIsDualLayer() const;
uint32 GetDvdSecondLayerStart() const;
bool GetDvdIsDualLayer() const;
uint32 GetDvdSecondLayerStart() const;
private:
typedef std::unique_ptr<CISO9660> Iso9660Ptr;
void CheckDualLayerDvd(const StreamPtr&);
void CheckDualLayerDvd(const StreamPtr&);
TRACK_DATA_TYPE m_track0DataType = TRACK_DATA_TYPE_MODE1_2048;
bool m_dvdIsDualLayer = false;
uint32 m_dvdSecondLayerStart = 0;
Iso9660Ptr m_fileSystem;
bool m_dvdIsDualLayer = false;
uint32 m_dvdSecondLayerStart = 0;
Iso9660Ptr m_fileSystem;
};

View file

@ -1,34 +1,38 @@
#pragma once
#include <cassert>
template<typename StructType>
template <typename StructType>
class COsStructManager
{
public:
class iterator
{
public:
iterator(const COsStructManager& container, uint32 id) : m_container(container), m_id(id) {}
iterator(const COsStructManager& container, uint32 id)
: m_container(container)
, m_id(id)
{
}
iterator& operator ++()
iterator& operator++()
{
m_id++;
return (*this);
}
iterator operator ++(int)
iterator operator++(int)
{
iterator copy(*this);
m_id++;
return copy;
}
bool operator !=(const iterator& rhs) const
bool operator!=(const iterator& rhs) const
{
return m_id != rhs.m_id;
}
StructType* operator *() const
StructType* operator*() const
{
return m_container[m_id];
}
@ -49,22 +53,22 @@ public:
};
COsStructManager(StructType* structBase, uint32 idBase, uint32 structMax)
: m_structBase(structBase)
, m_structMax(structMax)
, m_idBase(idBase)
: m_structBase(structBase)
, m_structMax(structMax)
, m_idBase(idBase)
{
assert(m_idBase != 0);
}
COsStructManager(const COsStructManager&) = delete;
COsStructManager& operator =(const COsStructManager) = delete;
COsStructManager& operator=(const COsStructManager) = delete;
StructType* GetBase() const
{
return m_structBase;
}
StructType* operator [](uint32 index) const
StructType* operator[](uint32 index) const
{
index -= m_idBase;
if(index >= m_structMax)
@ -121,7 +125,7 @@ public:
}
private:
StructType* m_structBase = nullptr;
uint32 m_structMax = 0;
uint32 m_idBase = 0;
StructType* m_structBase = nullptr;
uint32 m_structMax = 0;
uint32 m_idBase = 0;
};

View file

@ -9,27 +9,31 @@ public:
class iterator
{
public:
iterator(const StructManager& container, uint32* idPtr) : m_container(container), m_idPtr(idPtr) {}
iterator(const StructManager& container, uint32* idPtr)
: m_container(container)
, m_idPtr(idPtr)
{
}
iterator& operator ++()
iterator& operator++()
{
MoveNext();
return (*this);
}
iterator operator ++(int)
iterator operator++(int)
{
iterator copy(*this);
MoveNext();
return copy;
}
bool operator !=(const iterator& rhs) const
bool operator!=(const iterator& rhs) const
{
return m_idPtr != rhs.m_idPtr;
}
std::pair<uint32, StructType*> operator *() const
std::pair<uint32, StructType*> operator*() const
{
assert(m_idPtr);
return std::make_pair(*m_idPtr, m_container[*m_idPtr]);
@ -52,14 +56,13 @@ public:
};
COsStructQueue(StructManager& items, uint32* headIdPtr)
: m_items(items)
, m_headIdPtr(headIdPtr)
: m_items(items)
, m_headIdPtr(headIdPtr)
{
}
COsStructQueue(const COsStructQueue&) = delete;
COsStructQueue& operator =(const COsStructQueue) = delete;
COsStructQueue& operator=(const COsStructQueue) = delete;
bool IsEmpty() const
{
@ -142,6 +145,6 @@ public:
}
private:
StructManager& m_items;
uint32* m_headIdPtr = nullptr;
StructManager& m_items;
uint32* m_headIdPtr = nullptr;
};

View file

@ -4,18 +4,21 @@ template <typename Type>
struct OsVariableWrapper
{
public:
explicit OsVariableWrapper(Type* storage) : m_storage(storage) { }
explicit OsVariableWrapper(Type* storage)
: m_storage(storage)
{
}
OsVariableWrapper(const OsVariableWrapper&) = delete;
OsVariableWrapper& operator =(const OsVariableWrapper&) = delete;
OsVariableWrapper& operator=(const OsVariableWrapper&) = delete;
OsVariableWrapper& operator =(const Type& value)
OsVariableWrapper& operator=(const Type& value)
{
(*m_storage) = value;
return (*this);
}
Type& operator +=(const Type& addend)
Type& operator+=(const Type& addend)
{
(*m_storage) += addend;
return (*m_storage);
@ -32,5 +35,5 @@ public:
}
private:
Type* m_storage;
Type* m_storage;
};

View file

@ -10,12 +10,11 @@ CPH_Generic::CPH_Generic()
CPH_Generic::~CPH_Generic()
{
}
CPadHandler::FactoryFunction CPH_Generic::GetFactoryFunction()
{
return [] () { return new CPH_Generic(); };
return []() { return new CPH_Generic(); };
}
void CPH_Generic::Update(uint8* ram)

View file

@ -5,17 +5,17 @@
class CPH_Generic : public CPadHandler
{
public:
CPH_Generic();
virtual ~CPH_Generic();
CPH_Generic();
virtual ~CPH_Generic();
static FactoryFunction GetFactoryFunction();
static FactoryFunction GetFactoryFunction();
void Update(uint8*) override;
void Update(uint8*) override;
void SetButtonState(uint32, bool);
void SetAxisState(uint32, float);
void SetButtonState(uint32, bool);
void SetAxisState(uint32, float);
private:
bool m_buttonStates[PS2::CControllerInfo::MAX_BUTTONS];
float m_axisStates[PS2::CControllerInfo::MAX_BUTTONS];
bool m_buttonStates[PS2::CControllerInfo::MAX_BUTTONS];
float m_axisStates[PS2::CControllerInfo::MAX_BUTTONS];
};

View file

@ -28,43 +28,43 @@
#include "ISO9660/BlockProvider.h"
#include "DiskUtils.h"
#define LOG_NAME ("ps2vm")
#define LOG_NAME ("ps2vm")
#define PREF_PS2_HOST_DIRECTORY_DEFAULT ("vfs/host")
#define PREF_PS2_MC0_DIRECTORY_DEFAULT ("vfs/mc0")
#define PREF_PS2_MC1_DIRECTORY_DEFAULT ("vfs/mc1")
#define PREF_PS2_HOST_DIRECTORY_DEFAULT ("vfs/host")
#define PREF_PS2_MC0_DIRECTORY_DEFAULT ("vfs/mc0")
#define PREF_PS2_MC1_DIRECTORY_DEFAULT ("vfs/mc1")
#define FRAME_TICKS (PS2::EE_CLOCK_FREQ / 60)
#define ONSCREEN_TICKS (FRAME_TICKS * 9 / 10)
#define VBLANK_TICKS (FRAME_TICKS / 10)
#define FRAME_TICKS (PS2::EE_CLOCK_FREQ / 60)
#define ONSCREEN_TICKS (FRAME_TICKS * 9 / 10)
#define VBLANK_TICKS (FRAME_TICKS / 10)
namespace filesystem = boost::filesystem;
CPS2VM::CPS2VM()
: m_nStatus(PAUSED)
, m_nEnd(false)
, m_pad(NULL)
, m_singleStepEe(false)
, m_singleStepIop(false)
, m_singleStepVu0(false)
, m_singleStepVu1(false)
, m_vblankTicks(0)
, m_inVblank(false)
, m_eeExecutionTicks(0)
, m_iopExecutionTicks(0)
, m_spuUpdateTicks(SPU_UPDATE_TICKS)
, m_eeProfilerZone(CProfiler::GetInstance().RegisterZone("EE"))
, m_iopProfilerZone(CProfiler::GetInstance().RegisterZone("IOP"))
, m_spuProfilerZone(CProfiler::GetInstance().RegisterZone("SPU"))
, m_gsSyncProfilerZone(CProfiler::GetInstance().RegisterZone("GSSYNC"))
, m_otherProfilerZone(CProfiler::GetInstance().RegisterZone("OTHER"))
: m_nStatus(PAUSED)
, m_nEnd(false)
, m_pad(NULL)
, m_singleStepEe(false)
, m_singleStepIop(false)
, m_singleStepVu0(false)
, m_singleStepVu1(false)
, m_vblankTicks(0)
, m_inVblank(false)
, m_eeExecutionTicks(0)
, m_iopExecutionTicks(0)
, m_spuUpdateTicks(SPU_UPDATE_TICKS)
, m_eeProfilerZone(CProfiler::GetInstance().RegisterZone("EE"))
, m_iopProfilerZone(CProfiler::GetInstance().RegisterZone("IOP"))
, m_spuProfilerZone(CProfiler::GetInstance().RegisterZone("SPU"))
, m_gsSyncProfilerZone(CProfiler::GetInstance().RegisterZone("GSSYNC"))
, m_otherProfilerZone(CProfiler::GetInstance().RegisterZone("OTHER"))
{
static const std::pair<const char*, const char*> basicDirectorySettings[] =
{
std::make_pair(PREF_PS2_HOST_DIRECTORY, PREF_PS2_HOST_DIRECTORY_DEFAULT),
std::make_pair(PREF_PS2_MC0_DIRECTORY, PREF_PS2_MC0_DIRECTORY_DEFAULT),
std::make_pair(PREF_PS2_MC1_DIRECTORY, PREF_PS2_MC1_DIRECTORY_DEFAULT),
};
{
std::make_pair(PREF_PS2_HOST_DIRECTORY, PREF_PS2_HOST_DIRECTORY_DEFAULT),
std::make_pair(PREF_PS2_MC0_DIRECTORY, PREF_PS2_MC0_DIRECTORY_DEFAULT),
std::make_pair(PREF_PS2_MC1_DIRECTORY, PREF_PS2_MC1_DIRECTORY_DEFAULT),
};
for(const auto& basicDirectorySetting : basicDirectorySettings)
{
@ -101,7 +101,7 @@ CPS2VM::~CPS2VM()
void CPS2VM::CreateGSHandler(const CGSHandler::FactoryFunction& factoryFunction)
{
if(m_ee->m_gs != nullptr) return;
m_mailBox.SendCall([this, factoryFunction] () { CreateGsHandlerImpl(factoryFunction); }, true);
m_mailBox.SendCall([this, factoryFunction]() { CreateGsHandlerImpl(factoryFunction); }, true);
}
CGSHandler* CPS2VM::GetGSHandler()
@ -112,13 +112,13 @@ CGSHandler* CPS2VM::GetGSHandler()
void CPS2VM::DestroyGSHandler()
{
if(m_ee->m_gs == nullptr) return;
m_mailBox.SendCall([this] () { DestroyGsHandlerImpl(); }, true);
m_mailBox.SendCall([this]() { DestroyGsHandlerImpl(); }, true);
}
void CPS2VM::CreatePadHandler(const CPadHandler::FactoryFunction& factoryFunction)
{
if(m_pad != nullptr) return;
m_mailBox.SendCall([this, factoryFunction] () { CreatePadHandlerImpl(factoryFunction); }, true);
m_mailBox.SendCall([this, factoryFunction]() { CreatePadHandlerImpl(factoryFunction); }, true);
}
CPadHandler* CPS2VM::GetPadHandler()
@ -129,19 +129,19 @@ CPadHandler* CPS2VM::GetPadHandler()
void CPS2VM::DestroyPadHandler()
{
if(m_pad == nullptr) return;
m_mailBox.SendCall([this] () { DestroyPadHandlerImpl(); }, true);
m_mailBox.SendCall([this]() { DestroyPadHandlerImpl(); }, true);
}
void CPS2VM::CreateSoundHandler(const CSoundHandler::FactoryFunction& factoryFunction)
{
if(m_soundHandler != nullptr) return;
m_mailBox.SendCall([this, factoryFunction] () { CreateSoundHandlerImpl(factoryFunction); }, true);
m_mailBox.SendCall([this, factoryFunction]() { CreateSoundHandlerImpl(factoryFunction); }, true);
}
void CPS2VM::DestroySoundHandler()
{
if(m_soundHandler == nullptr) return;
m_mailBox.SendCall([this] () { DestroySoundHandlerImpl(); }, true);
m_mailBox.SendCall([this]() { DestroySoundHandlerImpl(); }, true);
}
CVirtualMachine::STATUS CPS2VM::GetStatus() const
@ -200,14 +200,14 @@ void CPS2VM::Reset()
void CPS2VM::DumpEEIntcHandlers()
{
// if(m_pOS == NULL) return;
// if(m_pOS == NULL) return;
if(m_nStatus != PAUSED) return;
m_ee->m_os->DumpIntcHandlers();
}
void CPS2VM::DumpEEDmacHandlers()
{
// if(m_pOS == NULL) return;
// if(m_pOS == NULL) return;
if(m_nStatus != PAUSED) return;
m_ee->m_os->DumpDmacHandlers();
}
@ -216,7 +216,7 @@ void CPS2VM::Initialize()
{
CreateVM();
m_nEnd = false;
m_thread = std::thread([&] () { EmuThread(); });
m_thread = std::thread([&]() { EmuThread(); });
}
void CPS2VM::Destroy()
@ -242,12 +242,10 @@ std::future<bool> CPS2VM::SaveState(const filesystem::path& statePath)
auto promise = std::make_shared<std::promise<bool>>();
auto future = promise->get_future();
m_mailBox.SendCall(
[this, promise, statePath] ()
{
auto result = SaveVMState(statePath);
promise->set_value(result);
}
);
[this, promise, statePath]() {
auto result = SaveVMState(statePath);
promise->set_value(result);
});
return future;
}
@ -256,26 +254,22 @@ std::future<bool> CPS2VM::LoadState(const filesystem::path& statePath)
auto promise = std::make_shared<std::promise<bool>>();
auto future = promise->get_future();
m_mailBox.SendCall(
[this, promise, statePath] ()
{
auto result = LoadVMState(statePath);
promise->set_value(result);
}
);
[this, promise, statePath]() {
auto result = LoadVMState(statePath);
promise->set_value(result);
});
return future;
}
void CPS2VM::TriggerFrameDump(const FrameDumpCallback& frameDumpCallback)
{
m_mailBox.SendCall(
[=] ()
{
std::unique_lock<std::mutex> frameDumpCallbackMutexLock(m_frameDumpCallbackMutex);
if(m_frameDumpCallback) return;
m_frameDumpCallback = frameDumpCallback;
},
false
);
[=]() {
std::unique_lock<std::mutex> frameDumpCallbackMutexLock(m_frameDumpCallbackMutex);
if(m_frameDumpCallback) return;
m_frameDumpCallback = frameDumpCallback;
},
false);
}
CPS2VM::CPU_UTILISATION_INFO CPS2VM::GetCpuUtilisationInfo() const
@ -285,16 +279,16 @@ CPS2VM::CPU_UTILISATION_INFO CPS2VM::GetCpuUtilisationInfo() const
#ifdef DEBUGGER_INCLUDED
#define TAGS_SECTION_TAGS ("tags")
#define TAGS_SECTION_EE_FUNCTIONS ("ee_functions")
#define TAGS_SECTION_EE_COMMENTS ("ee_comments")
#define TAGS_SECTION_VU1_FUNCTIONS ("vu1_functions")
#define TAGS_SECTION_VU1_COMMENTS ("vu1_comments")
#define TAGS_SECTION_IOP ("iop")
#define TAGS_SECTION_IOP_FUNCTIONS ("functions")
#define TAGS_SECTION_IOP_COMMENTS ("comments")
#define TAGS_SECTION_TAGS ("tags")
#define TAGS_SECTION_EE_FUNCTIONS ("ee_functions")
#define TAGS_SECTION_EE_COMMENTS ("ee_comments")
#define TAGS_SECTION_VU1_FUNCTIONS ("vu1_functions")
#define TAGS_SECTION_VU1_COMMENTS ("vu1_comments")
#define TAGS_SECTION_IOP ("iop")
#define TAGS_SECTION_IOP_FUNCTIONS ("functions")
#define TAGS_SECTION_IOP_COMMENTS ("comments")
#define TAGS_PATH ("tags/")
#define TAGS_PATH ("tags/")
std::string CPS2VM::MakeDebugTagsPackagePath(const char* packageName)
{
@ -329,7 +323,6 @@ void CPS2VM::LoadDebugTags(const char* packageName)
}
catch(...)
{
}
}
@ -355,7 +348,6 @@ void CPS2VM::SaveDebugTags(const char* packageName)
}
catch(...)
{
}
}
@ -800,10 +792,10 @@ void CPS2VM::EmuThread()
}
#ifdef DEBUGGER_INCLUDED
if(
m_ee->m_executor.MustBreak() ||
m_iop->m_executor.MustBreak() ||
m_ee->m_vpu1->MustBreak() ||
m_singleStepEe || m_singleStepIop || m_singleStepVu0 || m_singleStepVu1)
m_ee->m_executor.MustBreak() ||
m_iop->m_executor.MustBreak() ||
m_ee->m_vpu1->MustBreak() ||
m_singleStepEe || m_singleStepIop || m_singleStepVu0 || m_singleStepVu1)
{
m_nStatus = PAUSED;
m_singleStepEe = false;

View file

@ -31,146 +31,146 @@ public:
typedef std::unique_ptr<Ee::CSubSystem> EeSubSystemPtr;
typedef std::unique_ptr<Iop::CSubSystem> IopSubSystemPtr;
typedef std::function<void (const CFrameDump&)> FrameDumpCallback;
typedef boost::signals2::signal<void (const CProfiler::ZoneArray&)> ProfileFrameDoneSignal;
typedef std::function<void(const CFrameDump&)> FrameDumpCallback;
typedef boost::signals2::signal<void(const CProfiler::ZoneArray&)> ProfileFrameDoneSignal;
CPS2VM();
virtual ~CPS2VM();
CPS2VM();
virtual ~CPS2VM();
void Initialize();
void Destroy();
void Initialize();
void Destroy();
void StepEe();
void StepIop();
void StepVu0();
void StepVu1();
void StepEe();
void StepIop();
void StepVu0();
void StepVu1();
void Resume() override;
void Pause() override;
void Reset();
void Resume() override;
void Pause() override;
void Reset();
STATUS GetStatus() const override;
STATUS GetStatus() const override;
void DumpEEIntcHandlers();
void DumpEEDmacHandlers();
void DumpEEIntcHandlers();
void DumpEEDmacHandlers();
void CreateGSHandler(const CGSHandler::FactoryFunction&);
CGSHandler* GetGSHandler();
void DestroyGSHandler();
void CreateGSHandler(const CGSHandler::FactoryFunction&);
CGSHandler* GetGSHandler();
void DestroyGSHandler();
void CreatePadHandler(const CPadHandler::FactoryFunction&);
CPadHandler* GetPadHandler();
void DestroyPadHandler();
void CreatePadHandler(const CPadHandler::FactoryFunction&);
CPadHandler* GetPadHandler();
void DestroyPadHandler();
void CreateSoundHandler(const CSoundHandler::FactoryFunction&);
void DestroySoundHandler();
void CreateSoundHandler(const CSoundHandler::FactoryFunction&);
void DestroySoundHandler();
static boost::filesystem::path GetStateDirectoryPath();
boost::filesystem::path GenerateStatePath(unsigned int) const;
static boost::filesystem::path GetStateDirectoryPath();
boost::filesystem::path GenerateStatePath(unsigned int) const;
std::future<bool> SaveState(const boost::filesystem::path&);
std::future<bool> LoadState(const boost::filesystem::path&);
std::future<bool> SaveState(const boost::filesystem::path&);
std::future<bool> LoadState(const boost::filesystem::path&);
void TriggerFrameDump(const FrameDumpCallback&);
void TriggerFrameDump(const FrameDumpCallback&);
CPU_UTILISATION_INFO GetCpuUtilisationInfo() const;
CPU_UTILISATION_INFO GetCpuUtilisationInfo() const;
#ifdef DEBUGGER_INCLUDED
std::string MakeDebugTagsPackagePath(const char*);
void LoadDebugTags(const char*);
void SaveDebugTags(const char*);
std::string MakeDebugTagsPackagePath(const char*);
void LoadDebugTags(const char*);
void SaveDebugTags(const char*);
#endif
CPadHandler* m_pad;
CPadHandler* m_pad;
EeSubSystemPtr m_ee;
IopSubSystemPtr m_iop;
EeSubSystemPtr m_ee;
IopSubSystemPtr m_iop;
IopBiosPtr m_iopOs;
IopBiosPtr m_iopOs;
ProfileFrameDoneSignal ProfileFrameDone;
ProfileFrameDoneSignal ProfileFrameDone;
private:
typedef std::unique_ptr<COpticalMedia> OpticalMediaPtr;
void CreateVM();
void ResetVM();
void DestroyVM();
bool SaveVMState(const boost::filesystem::path&);
bool LoadVMState(const boost::filesystem::path&);
void CreateVM();
void ResetVM();
void DestroyVM();
bool SaveVMState(const boost::filesystem::path&);
bool LoadVMState(const boost::filesystem::path&);
void ReloadExecutable(const char*, const CPS2OS::ArgumentList&);
void ReloadExecutable(const char*, const CPS2OS::ArgumentList&);
void ResumeImpl();
void PauseImpl();
void DestroyImpl();
void ResumeImpl();
void PauseImpl();
void DestroyImpl();
void CreateGsHandlerImpl(const CGSHandler::FactoryFunction&);
void DestroyGsHandlerImpl();
void CreateGsHandlerImpl(const CGSHandler::FactoryFunction&);
void DestroyGsHandlerImpl();
void CreatePadHandlerImpl(const CPadHandler::FactoryFunction&);
void DestroyPadHandlerImpl();
void CreatePadHandlerImpl(const CPadHandler::FactoryFunction&);
void DestroyPadHandlerImpl();
void CreateSoundHandlerImpl(const CSoundHandler::FactoryFunction&);
void DestroySoundHandlerImpl();
void CreateSoundHandlerImpl(const CSoundHandler::FactoryFunction&);
void DestroySoundHandlerImpl();
void UpdateEe();
void UpdateIop();
void UpdateSpu();
void UpdateEe();
void UpdateIop();
void UpdateSpu();
void OnGsNewFrame();
void OnGsNewFrame();
void CDROM0_SyncPath();
void CDROM0_Reset();
void SetIopOpticalMedia(COpticalMedia*);
void CDROM0_SyncPath();
void CDROM0_Reset();
void SetIopOpticalMedia(COpticalMedia*);
void RegisterModulesInPadHandler();
void RegisterModulesInPadHandler();
void EmuThread();
void EmuThread();
std::thread m_thread;
CMailBox m_mailBox;
STATUS m_nStatus;
bool m_nEnd;
std::thread m_thread;
CMailBox m_mailBox;
STATUS m_nStatus;
bool m_nEnd;
int m_vblankTicks = 0;
bool m_inVblank = 0;
int m_spuUpdateTicks = 0;
int m_eeExecutionTicks = 0;
int m_iopExecutionTicks = 0;
int m_vblankTicks = 0;
bool m_inVblank = 0;
int m_spuUpdateTicks = 0;
int m_eeExecutionTicks = 0;
int m_iopExecutionTicks = 0;
CPU_UTILISATION_INFO m_cpuUtilisation;
CPU_UTILISATION_INFO m_cpuUtilisation;
bool m_singleStepEe;
bool m_singleStepIop;
bool m_singleStepVu0;
bool m_singleStepVu1;
bool m_singleStepEe;
bool m_singleStepIop;
bool m_singleStepVu0;
bool m_singleStepVu1;
CFrameDump m_frameDump;
FrameDumpCallback m_frameDumpCallback;
std::mutex m_frameDumpCallbackMutex;
bool m_dumpingFrame = false;
CFrameDump m_frameDump;
FrameDumpCallback m_frameDumpCallback;
std::mutex m_frameDumpCallbackMutex;
bool m_dumpingFrame = false;
OpticalMediaPtr m_cdrom0;
OpticalMediaPtr m_cdrom0;
//SPU update parameters
enum
{
DST_SAMPLE_RATE = 44100,
UPDATE_RATE = 1000, //Number of SPU updates per second (on PS2 time scale)
UPDATE_RATE = 1000, //Number of SPU updates per second (on PS2 time scale)
SPU_UPDATE_TICKS = PS2::IOP_CLOCK_OVER_FREQ / UPDATE_RATE,
SAMPLE_COUNT = DST_SAMPLE_RATE / UPDATE_RATE,
BLOCK_SIZE = SAMPLE_COUNT * 2,
BLOCK_COUNT = 400,
};
int16 m_samples[BLOCK_SIZE * BLOCK_COUNT];
int m_currentSpuBlock = 0;
CSoundHandler* m_soundHandler = nullptr;
int16 m_samples[BLOCK_SIZE * BLOCK_COUNT];
int m_currentSpuBlock = 0;
CSoundHandler* m_soundHandler = nullptr;
CProfiler::ZoneHandle m_eeProfilerZone = 0;
CProfiler::ZoneHandle m_iopProfilerZone = 0;
CProfiler::ZoneHandle m_spuProfilerZone = 0;
CProfiler::ZoneHandle m_gsSyncProfilerZone = 0;
CProfiler::ZoneHandle m_otherProfilerZone = 0;
CProfiler::ZoneHandle m_eeProfilerZone = 0;
CProfiler::ZoneHandle m_iopProfilerZone = 0;
CProfiler::ZoneHandle m_spuProfilerZone = 0;
CProfiler::ZoneHandle m_gsSyncProfilerZone = 0;
CProfiler::ZoneHandle m_otherProfilerZone = 0;
};

View file

@ -1,7 +1,7 @@
#pragma once
#define PREF_PS2_CDROM0_PATH ("ps2.cdrom0.path.v2")
#define PREF_PS2_CDROM0_PATH ("ps2.cdrom0.path.v2")
#define PREF_PS2_HOST_DIRECTORY ("ps2.host.directory.v2")
#define PREF_PS2_MC0_DIRECTORY ("ps2.mc0.directory.v2")
#define PREF_PS2_MC1_DIRECTORY ("ps2.mc1.directory.v2")
#define PREF_PS2_HOST_DIRECTORY ("ps2.host.directory.v2")
#define PREF_PS2_MC0_DIRECTORY ("ps2.mc0.directory.v2")
#define PREF_PS2_MC1_DIRECTORY ("ps2.mc1.directory.v2")

View file

@ -2,12 +2,10 @@
CPadHandler::CPadHandler()
{
}
CPadHandler::~CPadHandler()
{
}
void CPadHandler::InsertListener(CPadListener* pListener)
@ -17,5 +15,5 @@ void CPadHandler::InsertListener(CPadListener* pListener)
void CPadHandler::RemoveAllListeners()
{
m_listeners.clear();
m_listeners.clear();
}

View file

@ -8,17 +8,17 @@
class CPadHandler
{
public:
typedef std::function<CPadHandler* (void)> FactoryFunction;
typedef std::function<CPadHandler*(void)> FactoryFunction;
CPadHandler();
virtual ~CPadHandler();
virtual void Update(uint8*) = 0;
void InsertListener(CPadListener*);
void RemoveAllListeners();
CPadHandler();
virtual ~CPadHandler();
virtual void Update(uint8*) = 0;
void InsertListener(CPadListener*);
void RemoveAllListeners();
protected:
typedef std::list<CPadListener*> ListenerList;
ListenerList m_listeners;
typedef std::list<CPadListener*> ListenerList;
ListenerList m_listeners;
};
#endif

View file

@ -6,28 +6,28 @@ using namespace PS2;
uint32 CPadListener::GetButtonMask(CControllerInfo::BUTTON button)
{
static uint32 buttonMask[CControllerInfo::MAX_BUTTONS] =
{
static_cast<uint32>(-1),
static_cast<uint32>(-1),
static_cast<uint32>(-1),
static_cast<uint32>(-1),
0x1000,
0x4000,
0x8000,
0x2000,
0x0100,
0x0800,
0x0080,
0x0010,
0x0020,
0x0040,
0x0004, //L1
0x0001, //L2
0x0200, //L3
0x0008, //R1
0x0002, //R2
0x0400, //R3
};
{
static_cast<uint32>(-1),
static_cast<uint32>(-1),
static_cast<uint32>(-1),
static_cast<uint32>(-1),
0x1000,
0x4000,
0x8000,
0x2000,
0x0100,
0x0800,
0x0080,
0x0010,
0x0020,
0x0040,
0x0004, //L1
0x0001, //L2
0x0200, //L3
0x0008, //R1
0x0002, //R2
0x0400, //R3
};
uint32 result = buttonMask[button];
assert(result != -1);

View file

@ -6,8 +6,10 @@
class CPadListener
{
public:
virtual ~CPadListener() {}
virtual void SetButtonState(unsigned int, PS2::CControllerInfo::BUTTON, bool, uint8*) = 0;
virtual void SetAxisState(unsigned int, PS2::CControllerInfo::BUTTON, uint8, uint8*) = 0;
static uint32 GetButtonMask(PS2::CControllerInfo::BUTTON);
virtual ~CPadListener()
{
}
virtual void SetButtonState(unsigned int, PS2::CControllerInfo::BUTTON, bool, uint8*) = 0;
virtual void SetAxisState(unsigned int, PS2::CControllerInfo::BUTTON, uint8, uint8*) = 0;
static uint32 GetButtonMask(PS2::CControllerInfo::BUTTON);
};

View file

@ -13,7 +13,6 @@
#include <sys/statvfs.h>
#endif
#include "Posix_VolumeStream.h"
using namespace Framework::Posix;

View file

@ -10,24 +10,24 @@ namespace Framework
class CVolumeStream : public CStream
{
public:
CVolumeStream(const char*);
virtual ~CVolumeStream();
CVolumeStream(const char*);
virtual ~CVolumeStream();
virtual void Seek(int64, STREAM_SEEK_DIRECTION);
virtual uint64 Tell();
virtual uint64 Read(void*, uint64);
virtual uint64 Write(const void*, uint64);
virtual bool IsEOF();
virtual void Seek(int64, STREAM_SEEK_DIRECTION);
virtual uint64 Tell();
virtual uint64 Read(void*, uint64);
virtual uint64 Write(const void*, uint64);
virtual bool IsEOF();
private:
void SyncCache();
void SyncCache();
int m_fd;
void* m_cache;
uint64 m_cacheSector;
int m_fd;
void* m_cache;
uint64 m_cacheSector;
uint64 m_position;
uint32 m_sectorSize;
uint64 m_position;
uint32 m_sectorSize;
};
}
}

View file

@ -4,12 +4,10 @@
CProfiler::CProfiler()
{
}
CProfiler::~CProfiler()
{
}
CProfiler::ZoneHandle CProfiler::RegisterZone(const char* name)

View file

@ -15,45 +15,45 @@ public:
struct ZONE
{
std::string name;
uint64 totalTime = 0;
std::string name;
uint64 totalTime = 0;
};
typedef std::vector<ZONE> ZoneArray;
typedef std::chrono::high_resolution_clock::time_point TimePoint;
CProfiler();
virtual ~CProfiler();
CProfiler();
virtual ~CProfiler();
ZoneHandle RegisterZone(const char*);
ZoneHandle RegisterZone(const char*);
void CountCurrentZone();
void CountCurrentZone();
void EnterZone(ZoneHandle);
void ExitZone();
void EnterZone(ZoneHandle);
void ExitZone();
ZoneArray GetStats() const;
void Reset();
ZoneArray GetStats() const;
void Reset();
void SetWorkThread();
void SetWorkThread();
private:
typedef std::stack<ZoneHandle> ZoneStack;
void AddTimeToZone(ZoneHandle, uint64);
void AddTimeToZone(ZoneHandle, uint64);
ZoneArray m_zones;
ZoneStack m_zoneStack;
TimePoint m_currentTime;
ZoneArray m_zones;
ZoneStack m_zoneStack;
TimePoint m_currentTime;
#ifdef _DEBUG
std::thread::id m_workThreadId;
std::thread::id m_workThreadId;
#endif
};
class CProfilerZone
{
public:
CProfilerZone(CProfiler::ZoneHandle);
~CProfilerZone();
CProfilerZone(CProfiler::ZoneHandle);
~CProfilerZone();
};

View file

@ -7,20 +7,18 @@
#include "lexical_cast_ex.h"
CRegisterStateFile::CRegisterStateFile(const char* name)
: CZipFile(name)
: CZipFile(name)
{
}
CRegisterStateFile::CRegisterStateFile(Framework::CStream& stream)
: CZipFile("")
: CZipFile("")
{
Read(stream);
}
CRegisterStateFile::~CRegisterStateFile()
{
}
void CRegisterStateFile::Read(Framework::CStream& stream)
@ -29,7 +27,7 @@ void CRegisterStateFile::Read(Framework::CStream& stream)
auto rootNode = std::unique_ptr<Framework::Xml::CNode>(Framework::Xml::CParser::ParseDocument(stream));
auto registerList = rootNode->SelectNodes("RegisterFile/Register");
for(Framework::Xml::CNode::NodeIterator nodeIterator(registerList.begin());
nodeIterator != registerList.end(); nodeIterator++)
nodeIterator != registerList.end(); nodeIterator++)
{
try
{
@ -52,7 +50,6 @@ void CRegisterStateFile::Read(Framework::CStream& stream)
}
catch(...)
{
}
}
}
@ -61,7 +58,7 @@ void CRegisterStateFile::Write(Framework::CStream& stream)
{
auto rootNode = new Framework::Xml::CNode("RegisterFile", true);
for(auto registerIterator(m_registers.begin());
registerIterator != m_registers.end(); registerIterator++)
registerIterator != m_registers.end(); registerIterator++)
{
const Register& reg(registerIterator->second);
auto registerNode = new Framework::Xml::CNode("Register", true);

View file

@ -7,24 +7,24 @@
class CRegisterStateFile : public Framework::CZipFile
{
public:
CRegisterStateFile(const char*);
CRegisterStateFile(Framework::CStream&);
virtual ~CRegisterStateFile();
CRegisterStateFile(const char*);
CRegisterStateFile(Framework::CStream&);
virtual ~CRegisterStateFile();
void SetRegister32(const char*, uint32);
void SetRegister64(const char*, uint64);
void SetRegister128(const char*, uint128);
void SetRegister32(const char*, uint32);
void SetRegister64(const char*, uint64);
void SetRegister128(const char*, uint128);
uint32 GetRegister32(const char*) const;
uint64 GetRegister64(const char*) const;
uint128 GetRegister128(const char*) const;
uint32 GetRegister32(const char*) const;
uint64 GetRegister64(const char*) const;
uint128 GetRegister128(const char*) const;
void Read(Framework::CStream&);
void Write(Framework::CStream&) override;
void Read(Framework::CStream&);
void Write(Framework::CStream&) override;
private:
typedef std::pair<uint8, uint128> Register;
typedef std::map<std::string, Register> RegisterList;
RegisterList m_registers;
RegisterList m_registers;
};

View file

@ -2,7 +2,7 @@
#include "VirtualMachine.h"
CScopedVmPauser::CScopedVmPauser(CVirtualMachine& virtualMachine)
: m_virtualMachine(virtualMachine)
: m_virtualMachine(virtualMachine)
{
if(m_virtualMachine.GetStatus() == CVirtualMachine::RUNNING)
{

View file

@ -5,10 +5,10 @@ class CVirtualMachine;
class CScopedVmPauser
{
public:
CScopedVmPauser(CVirtualMachine&);
virtual ~CScopedVmPauser();
CScopedVmPauser(CVirtualMachine&);
virtual ~CScopedVmPauser();
private:
CVirtualMachine& m_virtualMachine;
bool m_paused = false;
CVirtualMachine& m_virtualMachine;
bool m_paused = false;
};

View file

@ -13,25 +13,23 @@
void CScreenShotUtils::TriggerGetScreenshot(CPS2VM* virtualMachine, Callback completionCallback)
{
virtualMachine->m_ee->m_gs->OnFlipComplete.connect_extended(
[=](const boost::signals2::connection &c)->void
{
c.disconnect();
try
{
auto buffer = virtualMachine->m_ee->m_gs->GetScreenshot();
auto name = GenerateScreenShotPath(virtualMachine->m_ee->m_os->GetExecutableName());
Framework::CStdStream outputStream(name.string().c_str(), "wb");
Framework::CBMP::WriteBitmap(buffer, outputStream);
[=](const boost::signals2::connection& c) -> void {
c.disconnect();
try
{
auto buffer = virtualMachine->m_ee->m_gs->GetScreenshot();
auto name = GenerateScreenShotPath(virtualMachine->m_ee->m_os->GetExecutableName());
Framework::CStdStream outputStream(name.string().c_str(), "wb");
Framework::CBMP::WriteBitmap(buffer, outputStream);
auto msgstr = string_format("Screenshot saved as '%s'.", name.filename().string().c_str());
completionCallback(0, msgstr.c_str());
}
catch(const std::exception&)
{
completionCallback(-1, "Error occured while trying to save screenshot.");
}
}
);
auto msgstr = string_format("Screenshot saved as '%s'.", name.filename().string().c_str());
completionCallback(0, msgstr.c_str());
}
catch(const std::exception&)
{
completionCallback(-1, "Error occured while trying to save screenshot.");
}
});
}
Framework::CConfig::PathType CScreenShotUtils::GetScreenShotDirectoryPath()

View file

@ -5,11 +5,11 @@
class CScreenShotUtils : public Framework::CConfig
{
public:
typedef std::function<void(int, const char*)> Callback;
typedef std::function<void(int, const char*)> Callback;
static void TriggerGetScreenshot(CPS2VM*, Callback);
static void TriggerGetScreenshot(CPS2VM*, Callback);
private:
static CConfig::PathType GetScreenShotDirectoryPath();
static CConfig::PathType GenerateScreenShotPath(const char* gameID);
static CConfig::PathType GetScreenShotDirectoryPath();
static CConfig::PathType GenerateScreenShotPath(const char* gameID);
};

View file

@ -4,12 +4,12 @@
enum CONST_SIF_CMD
{
SIF_CMD_SETSREG = 0x80000001,
SIF_CMD_INIT = 0x80000002,
SIF_CMD_REND = 0x80000008,
SIF_CMD_BIND = 0x80000009,
SIF_CMD_CALL = 0x8000000A,
SIF_CMD_OTHERDATA = 0x8000000C,
SIF_CMD_SETSREG = 0x80000001,
SIF_CMD_INIT = 0x80000002,
SIF_CMD_REND = 0x80000008,
SIF_CMD_BIND = 0x80000009,
SIF_CMD_CALL = 0x8000000A,
SIF_CMD_OTHERDATA = 0x8000000C,
};
struct SIFDMAREG
@ -24,7 +24,7 @@ static_assert(sizeof(SIFDMAREG) == 0x10, "sizeof(SIFDMAREG) must be 16 bytes.");
struct SIFCMDHEADER
{
uint32 packetSize : 8;
uint32 destSize : 24;
uint32 destSize : 24;
uint32 dest;
uint32 commandId;
uint32 optional;
@ -33,83 +33,83 @@ static_assert(sizeof(SIFCMDHEADER) == 0x10, "sizeof(SIFCMDHEADER) must be 16 byt
struct SIFSETSREG
{
SIFCMDHEADER header;
uint32 index;
uint32 value;
SIFCMDHEADER header;
uint32 index;
uint32 value;
};
static_assert(sizeof(SIFSETSREG) == 0x18, "sizeof(SIFSETREG) must be 24 bytes.");
struct SIFRPCBIND
{
SIFCMDHEADER header;
uint32 recordId;
uint32 packetAddr;
uint32 rpcId;
uint32 clientDataAddr;
uint32 serverId;
SIFCMDHEADER header;
uint32 recordId;
uint32 packetAddr;
uint32 rpcId;
uint32 clientDataAddr;
uint32 serverId;
};
static_assert(sizeof(SIFRPCBIND) == 0x24, "sizeof(SIFRPCBIND) must be 36 bytes.");
struct SIFRPCCALL
{
SIFCMDHEADER header;
uint32 recordId;
uint32 packetAddr;
uint32 rpcId;
uint32 clientDataAddr;
uint32 rpcNumber;
uint32 sendSize;
uint32 recv;
uint32 recvSize;
uint32 recvMode;
uint32 serverDataAddr;
SIFCMDHEADER header;
uint32 recordId;
uint32 packetAddr;
uint32 rpcId;
uint32 clientDataAddr;
uint32 rpcNumber;
uint32 sendSize;
uint32 recv;
uint32 recvSize;
uint32 recvMode;
uint32 serverDataAddr;
};
static_assert(sizeof(SIFRPCCALL) == 0x38, "sizeof(SIFRPCCALL) must be 56 bytes.");
struct SIFRPCREQUESTEND
{
SIFCMDHEADER header;
uint32 recordId;
uint32 packetAddr;
uint32 rpcId;
uint32 clientDataAddr;
uint32 commandId;
uint32 serverDataAddr;
uint32 buffer;
uint32 cbuffer;
SIFCMDHEADER header;
uint32 recordId;
uint32 packetAddr;
uint32 rpcId;
uint32 clientDataAddr;
uint32 commandId;
uint32 serverDataAddr;
uint32 buffer;
uint32 cbuffer;
};
static_assert(sizeof(SIFRPCREQUESTEND) == 0x30, "sizeof(SIFRPCREQUESTEND) must be 48 bytes.");
struct SIFRPCOTHERDATA
{
SIFCMDHEADER header;
uint32 recordId;
uint32 packetAddr;
uint32 rpcId;
uint32 receiveDataAddr;
uint32 srcPtr;
uint32 dstPtr;
uint32 size;
SIFCMDHEADER header;
uint32 recordId;
uint32 packetAddr;
uint32 rpcId;
uint32 receiveDataAddr;
uint32 srcPtr;
uint32 dstPtr;
uint32 size;
};
static_assert(sizeof(SIFRPCOTHERDATA) == 0x2C, "sizeof(SIFRPCOTHERDATA) must be 44 bytes.");
struct SIFRPCHEADER
{
uint32 packetAddr;
uint32 rpcId;
uint32 semaId;
uint32 mode;
uint32 packetAddr;
uint32 rpcId;
uint32 semaId;
uint32 mode;
};
static_assert(sizeof(SIFRPCHEADER) == 0x10, "sizeof(SIFRPCHEADER) must be 16 bytes.");
struct SIFRPCCLIENTDATA
{
SIFRPCHEADER header;
uint32 command;
uint32 buffPtr;
uint32 cbuffPtr;
uint32 endFctPtr;
uint32 endParam;
uint32 serverDataAddr;
SIFRPCHEADER header;
uint32 command;
uint32 buffPtr;
uint32 cbuffPtr;
uint32 endFctPtr;
uint32 endParam;
uint32 serverDataAddr;
};
static_assert(sizeof(SIFRPCCLIENTDATA) == 0x28, "sizeof(SIFRPCCLIENTDATA) must be 40 bytes.");

View file

@ -5,6 +5,6 @@
class CSifModule
{
public:
virtual ~CSifModule() = default;
virtual bool Invoke(uint32, uint32*, uint32, uint32*, uint32, uint8*) = 0;
virtual ~CSifModule() = default;
virtual bool Invoke(uint32, uint32*, uint32, uint32*, uint32, uint8*) = 0;
};

View file

@ -6,22 +6,19 @@
class CSifModuleAdapter : public CSifModule
{
public:
typedef std::function<bool (uint32, uint32*, uint32, uint32*, uint32, uint8*)> SifCommandHandler;
typedef std::function<bool(uint32, uint32*, uint32, uint32*, uint32, uint8*)> SifCommandHandler;
CSifModuleAdapter()
{
}
CSifModuleAdapter(const SifCommandHandler& handler)
: m_handler(handler)
: m_handler(handler)
{
}
virtual ~CSifModuleAdapter()
{
}
virtual bool Invoke(uint32 method, uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram) override

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