This commit is contained in:
Nekotekina 2014-02-03 01:20:48 +04:00
commit a0c8e116df
22 changed files with 220 additions and 84 deletions

View file

@ -34,12 +34,12 @@ public:
struct ID
{
wxString m_name;
std::string m_name;
u8 m_attr;
IDData* m_data;
template<typename T>
ID(const wxString& name, T* data, const u8 attr)
ID(const std::string& name, T* data, const u8 attr)
: m_name(name)
, m_attr(attr)
{
@ -58,8 +58,6 @@ struct ID
class IdManager
{
ArrayF<ID> IDs;
static const ID_TYPE s_first_id = 1;
static const ID_TYPE s_max_id = -1;
@ -99,7 +97,7 @@ public:
}
template<typename T>
ID_TYPE GetNewID(const wxString& name = wxEmptyString, T* data = nullptr, const u8 attr = 0)
ID_TYPE GetNewID(const std::string& name = "", T* data = nullptr, const u8 attr = 0)
{
std::lock_guard<std::mutex> lock(m_mtx_main);

View file

@ -1,29 +1,11 @@
#include "stdafx.h"
#include "Thread.h"
static DWORD g_tls_this_thread = 0xFFFFFFFF;
struct __init_tls
{
//NamedThreadBase m_main_thr;
__init_tls()
{
g_tls_this_thread = ::TlsAlloc();
//m_main_thr.SetThreadName("Main Thread");
//::TlsSetValue(g_tls_this_thread, &m_main_thr);
::TlsSetValue(g_tls_this_thread, nullptr);
}
~__init_tls()
{
::TlsFree(g_tls_this_thread);
}
} _init_tls;
__declspec(thread) NamedThreadBase* g_tls_this_thread = nullptr;
NamedThreadBase* GetCurrentNamedThread()
{
return (NamedThreadBase*)::TlsGetValue(g_tls_this_thread);
return g_tls_this_thread;
}
std::string NamedThreadBase::GetThreadName() const
@ -62,7 +44,7 @@ void ThreadBase::Start()
m_executor = new std::thread(
[this]()
{
::TlsSetValue(g_tls_this_thread, this);
g_tls_this_thread = this;
Task();
@ -130,7 +112,7 @@ thread::thread()
void thread::start(std::function<void()> func)
{
m_thr = std::thread([this, func]() { NamedThreadBase info(m_name); ::TlsSetValue(g_tls_this_thread, &info); func(); });
m_thr = std::thread([this, func]() { NamedThreadBase info(m_name); g_tls_this_thread = &info; func(); });
}
void thread::detach()

View file

@ -109,7 +109,7 @@ protected:
CPUThread(CPUThreadType type);
public:
~CPUThread();
virtual ~CPUThread();
u32 m_wait_thread_id;

View file

@ -36,7 +36,7 @@ CPUThread& CPUThreadManager::AddThread(CPUThreadType type)
default: assert(0);
}
new_thread->SetId(Emu.GetIdManager().GetNewID(wxString::Format("%s Thread", new_thread->GetTypeString().mb_str()), new_thread));
new_thread->SetId(Emu.GetIdManager().GetNewID(wxString::Format("%s Thread", new_thread->GetTypeString().mb_str()).mb_str(), new_thread));
m_threads.Add(new_thread);
#ifndef QT_UI

View file

@ -20,7 +20,6 @@ PPCThread::PPCThread(CPUThreadType type) : CPUThread(type)
PPCThread::~PPCThread()
{
Close();
}
void PPCThread::DoReset()

View file

@ -24,7 +24,7 @@ protected:
PPCThread(CPUThreadType type);
public:
~PPCThread();
virtual ~PPCThread();
protected:
virtual void DoReset() override;

View file

@ -22,7 +22,6 @@ PPUThread::PPUThread() : PPCThread(CPU_THREAD_PPU)
PPUThread::~PPUThread()
{
//~PPCThread();
}
void PPUThread::DoReset()

View file

@ -370,14 +370,14 @@ struct PPCdouble
case _FPCLASS_PINF: return FPR_PINF;
}
#else
switch (fpc)
{
case FP_NAN: return FPR_QNAN;
case FP_INFINITE: return signbit(_double) ? FPR_NINF : FPR_PINF;
case FP_SUBNORMAL: return signbit(_double) ? FPR_ND : FPR_PD;
case FP_ZERO: return signbit(_double) ? FPR_NZ : FPR_PZ;
default: return signbit(_double) ? FPR_NN : FPR_PN;
}
switch (fpc)
{
case FP_NAN: return FPR_QNAN;
case FP_INFINITE: return signbit(_double) ? FPR_NINF : FPR_PINF;
case FP_SUBNORMAL: return signbit(_double) ? FPR_ND : FPR_PD;
case FP_ZERO: return signbit(_double) ? FPR_NZ : FPR_PZ;
default: return signbit(_double) ? FPR_NN : FPR_PN;
}
#endif
throw wxString::Format("PPCdouble::UpdateType() -> unknown fpclass (0x%04x).", fpc);
@ -609,7 +609,7 @@ public:
public:
PPUThread();
~PPUThread();
virtual ~PPUThread();
inline u8 GetCR(const u8 n) const
{

View file

@ -50,7 +50,7 @@ class RawSPUThread
public:
RawSPUThread(u32 index, CPUThreadType type = CPU_THREAD_RAW_SPU);
~RawSPUThread();
virtual ~RawSPUThread();
virtual bool Read8(const u64 addr, u8* value) override;
virtual bool Read16(const u64 addr, u16* value) override;

View file

@ -698,7 +698,7 @@ public:
public:
SPUThread(CPUThreadType type = CPU_THREAD_SPU);
~SPUThread();
virtual ~SPUThread();
virtual wxString RegsToString()
{

View file

@ -1,3 +1,44 @@
#include "stdafx.h"
#include "vfsDirBase.h"
vfsDirBase::vfsDirBase(const wxString& path)
{
Open(path);
}
vfsDirBase::~vfsDirBase()
{
}
bool vfsDirBase::Open(const wxString& path)
{
if(!IsOpened())
Close();
if(!IsExists(path))
return false;
m_cwd += '/' + path;
return true;
}
bool vfsDirBase::IsOpened() const
{
return !m_cwd.IsEmpty();
}
const Array<DirEntryInfo>& vfsDirBase::GetEntryes() const
{
return m_entryes;
}
void vfsDirBase::Close()
{
m_cwd = wxEmptyString;
m_entryes.Clear();
}
wxString vfsDirBase::GetPath() const
{
return m_cwd;
}

View file

@ -1,19 +1,51 @@
#pragma once
struct DirInfo
enum DirEntryFlags
{
wxString m_name;
DirEntry_TypeDir = 0x0,
DirEntry_TypeFile = 0x1,
DirEntry_TypeMask = 0x1,
DirEntry_PermWritable = 0x20,
DirEntry_PermReadable = 0x40,
DirEntry_PermExecutable = 0x80,
};
struct DirEntryInfo
{
wxString name;
u32 flags;
time_t create_time;
time_t access_time;
time_t modify_time;
DirEntryInfo()
: flags(0)
, create_time(0)
, access_time(0)
, modify_time(0)
{
}
};
class vfsDirBase
{
virtual bool Open(const wxString& path)=0;
virtual Array<DirInfo> GetEntryes()=0;
virtual void Close()=0;
protected:
wxString m_cwd;
Array<DirEntryInfo> m_entryes;
public:
vfsDirBase(const wxString& path);
virtual ~vfsDirBase();
virtual bool Open(const wxString& path);
virtual bool IsOpened() const;
virtual const Array<DirEntryInfo>& GetEntryes() const;
virtual void Close();
virtual wxString GetPath() const;
virtual bool Create(const wxString& path)=0;
virtual bool Exists(const wxString& path)=0;
//virtual bool Create(const DirEntryInfo& info)=0;
virtual bool IsExists(const wxString& path) const=0;
virtual bool Rename(const wxString& from, const wxString& to)=0;
virtual bool Remove(const wxString& path)=0;
};

View file

@ -0,0 +1,58 @@
#include "stdafx.h"
#include "vfsLocalDir.h"
#include <direct.h>
vfsLocalDir::vfsLocalDir(const wxString& path) : vfsDirBase(path)
{
}
vfsLocalDir::~vfsLocalDir()
{
}
bool vfsLocalDir::Open(const wxString& path)
{
if(!vfsDirBase::Open(path))
return false;
wxDir dir;
if(!dir.Open(path))
return false;
wxString name;
for(bool is_ok = dir.GetFirst(&name); is_ok; is_ok = dir.GetNext(&name))
{
wxString dir_path = path + wxFILE_SEP_PATH + name;
DirEntryInfo& info = m_entryes[m_entryes.Move(new DirEntryInfo())];
info.name = name;
info.flags |= wxDirExists(dir_path) ? DirEntry_TypeDir : DirEntry_TypeFile;
if(wxIsWritable(dir_path)) info.flags |= DirEntry_PermWritable;
if(wxIsReadable(dir_path)) info.flags |= DirEntry_PermReadable;
if(wxIsExecutable(dir_path)) info.flags |= DirEntry_PermExecutable;
}
return true;
}
bool vfsLocalDir::Create(const wxString& path)
{
return wxFileName::Mkdir(path, 0777, wxPATH_MKDIR_FULL);
}
bool vfsLocalDir::IsExists(const wxString& path) const
{
return wxDirExists(path);
}
bool vfsLocalDir::Rename(const wxString& from, const wxString& to)
{
return false;
}
bool vfsLocalDir::Remove(const wxString& path)
{
return wxRmdir(path);
}

View file

@ -0,0 +1,16 @@
#pragma once
#include "vfsDirBase.h"
class vfsLocalDir : public vfsDirBase
{
public:
vfsLocalDir(const wxString& path = wxEmptyString);
virtual ~vfsLocalDir();
virtual bool Open(const wxString& path) override;
virtual bool Create(const wxString& path) override;
virtual bool IsExists(const wxString& path) const override;
virtual bool Rename(const wxString& from, const wxString& to) override;
virtual bool Remove(const wxString& path) override;
};

View file

@ -133,10 +133,11 @@ std::string GLFragmentDecompilerThread::AddCond(int fp16)
std::string GLFragmentDecompilerThread::AddConst()
{
if(m_parr.HasParam(PARAM_UNIFORM, "vec4", std::string("fc") + std::to_string(m_size + 4 * 4)))
{
return std::string("fc") + std::to_string(m_size + 4 * 4);
}
std::string name = std::string("fc") + std::to_string(m_size + 4 * 4);
if(m_parr.HasParam(PARAM_UNIFORM, "vec4", name))
{
return name;
}
mem32_ptr_t data(m_addr + m_size + m_offset);
@ -145,7 +146,7 @@ std::string GLFragmentDecompilerThread::AddConst()
u32 y = GetData(data[1]);
u32 z = GetData(data[2]);
u32 w = GetData(data[3]);
return m_parr.AddParam(PARAM_UNIFORM, "vec4", std::string("fc") + std::to_string(m_size + 4 * 4),
return m_parr.AddParam(PARAM_UNIFORM, "vec4", name,
std::string("vec4(") + std::to_string((float&)x) + ", " + std::to_string((float&)y)
+ ", " + std::to_string((float&)z) + ", " + std::to_string((float&)w) + ")");
}

View file

@ -564,6 +564,8 @@ protected:
Reset();
}
virtual ~RSXThread() {}
void Reset()
{
m_set_color_mask = false;

View file

@ -204,21 +204,21 @@ void UnloadModules()
g_modules_funcs_list.Clear();
}
Module* GetModuleByName(const wxString& name)
Module* GetModuleByName(const std::string& name)
{
for(u32 i=0; i<g_max_module_id; ++i)
{
if(g_modules[0][i] && g_modules[0][i]->GetName().Cmp(name) == 0)
if(g_modules[0][i] && g_modules[0][i]->GetName() == name)
{
return g_modules[0][i];
}
if(g_modules[1][i] && g_modules[1][i]->GetName().Cmp(name) == 0)
if(g_modules[1][i] && g_modules[1][i]->GetName() == name)
{
return g_modules[1][i];
}
if(g_modules[2][i] && g_modules[2][i]->GetName().Cmp(name) == 0)
if(g_modules[2][i] && g_modules[2][i]->GetName() == name)
{
return g_modules[2][i];
}
@ -396,12 +396,12 @@ u16 Module::GetID() const
return m_id;
}
wxString Module::GetName() const
std::string Module::GetName() const
{
return m_name;
}
void Module::SetName(const wxString& name)
void Module::SetName(const std::string& name)
{
m_name = name;
}
@ -412,7 +412,7 @@ void Module::Log(const u32 id, wxString fmt, ...)
{
va_list list;
va_start(list, fmt);
ConLog.Write(GetName() + wxString::Format("[%d]: ", id) + wxString::FormatV(fmt, list));
ConLog.Write(GetName() + wxString::Format("[%d]: ", id).mb_str() + wxString::FormatV(fmt, list).mb_str());
va_end(list);
}
}
@ -423,7 +423,7 @@ void Module::Log(wxString fmt, ...)
{
va_list list;
va_start(list, fmt);
ConLog.Write(GetName() + ": " + wxString::FormatV(fmt, list));
ConLog.Write(GetName() + ": " + wxString::FormatV(fmt, list).mb_str());
va_end(list);
}
}
@ -432,7 +432,7 @@ void Module::Warning(const u32 id, wxString fmt, ...)
{
va_list list;
va_start(list, fmt);
ConLog.Warning(GetName() + wxString::Format("[%d] warning: ", id) + wxString::FormatV(fmt, list));
ConLog.Warning(GetName() + wxString::Format("[%d] warning: ", id).mb_str() + wxString::FormatV(fmt, list).mb_str());
va_end(list);
}
@ -440,7 +440,7 @@ void Module::Warning(wxString fmt, ...)
{
va_list list;
va_start(list, fmt);
ConLog.Warning(GetName() + " warning: " + wxString::FormatV(fmt, list));
ConLog.Warning(GetName() + " warning: " + wxString::FormatV(fmt, list).mb_str());
va_end(list);
}
@ -448,7 +448,7 @@ void Module::Error(const u32 id, wxString fmt, ...)
{
va_list list;
va_start(list, fmt);
ConLog.Error(GetName() + wxString::Format("[%d] error: ", id) + wxString::FormatV(fmt, list));
ConLog.Error(GetName() + wxString::Format("[%d] error: ", id).mb_str() + wxString::FormatV(fmt, list).mb_str());
va_end(list);
}
@ -456,16 +456,16 @@ void Module::Error(wxString fmt, ...)
{
va_list list;
va_start(list, fmt);
ConLog.Error(GetName() + " error: " + wxString::FormatV(fmt, list));
ConLog.Error(GetName() + " error: " + wxString::FormatV(fmt, list).mb_str());
va_end(list);
}
bool Module::CheckID(u32 id) const
{
return Emu.GetIdManager().CheckID(id) && !Emu.GetIdManager().GetID(id).m_name.Cmp(GetName());
return Emu.GetIdManager().CheckID(id) && Emu.GetIdManager().GetID(id).m_name == GetName();
}
bool Module::CheckID(u32 id, ID*& _id) const
{
return Emu.GetIdManager().CheckID(id) && !(_id = &Emu.GetIdManager().GetID(id))->m_name.Cmp(GetName());
return Emu.GetIdManager().CheckID(id) && (_id = &Emu.GetIdManager().GetID(id))->m_name == GetName();
}

View file

@ -27,7 +27,7 @@ struct ModuleFunc
class Module
{
wxString m_name;
std::string m_name;
const u16 m_id;
bool m_is_loaded;
void (*m_load_func)();
@ -49,8 +49,8 @@ public:
bool IsLoaded() const;
u16 GetID() const;
wxString GetName() const;
void SetName(const wxString& name);
std::string GetName() const;
void SetName(const std::string& name);
public:
void Log(const u32 id, wxString fmt, ...);
@ -95,5 +95,5 @@ bool CallFunc(u32 num);
bool UnloadFunc(u32 id);
void UnloadModules();
u32 GetFuncNumById(u32 id);
Module* GetModuleByName(const wxString& name);
Module* GetModuleByName(const std::string& name);
Module* GetModuleById(u16 id);

View file

@ -17,17 +17,17 @@ extern bool enable_log;
class SysCallBase //Module
{
private:
wxString m_module_name;
std::string m_module_name;
//u32 m_id;
public:
SysCallBase(const wxString& name/*, u32 id*/)
SysCallBase(const std::string& name/*, u32 id*/)
: m_module_name(name)
//, m_id(id)
{
}
const wxString& GetName() const { return m_module_name; }
const std::string& GetName() const { return m_module_name; }
void Log(const u32 id, wxString fmt, ...)
{
@ -35,7 +35,7 @@ public:
{
va_list list;
va_start(list, fmt);
ConLog.Write(GetName() + wxString::Format("[%d]: ", id) + wxString::FormatV(fmt, list));
ConLog.Write(GetName() + wxString::Format("[%d]: ", id).mb_str() + wxString::FormatV(fmt, list).mb_str());
va_end(list);
}
}
@ -46,7 +46,7 @@ public:
{
va_list list;
va_start(list, fmt);
ConLog.Write(GetName() + ": " + wxString::FormatV(fmt, list));
ConLog.Write(GetName() + ": " + wxString::FormatV(fmt, list).mb_str());
va_end(list);
}
}
@ -56,7 +56,7 @@ public:
//#ifdef SYSCALLS_DEBUG
va_list list;
va_start(list, fmt);
ConLog.Warning(GetName() + wxString::Format("[%d] warning: ", id) + wxString::FormatV(fmt, list));
ConLog.Warning(GetName() + wxString::Format("[%d] warning: ", id).mb_str() + wxString::FormatV(fmt, list).mb_str());
va_end(list);
//#endif
}
@ -66,7 +66,7 @@ public:
//#ifdef SYSCALLS_DEBUG
va_list list;
va_start(list, fmt);
ConLog.Warning(GetName() + " warning: " + wxString::FormatV(fmt, list));
ConLog.Warning(GetName() + " warning: " + wxString::FormatV(fmt, list).mb_str());
va_end(list);
//#endif
}
@ -75,7 +75,7 @@ public:
{
va_list list;
va_start(list, fmt);
ConLog.Error(GetName() + wxString::Format("[%d] error: ", id) + wxString::FormatV(fmt, list));
ConLog.Error(GetName() + wxString::Format("[%d] error: ", id).mb_str() + wxString::FormatV(fmt, list).mb_str());
va_end(list);
}
@ -83,13 +83,13 @@ public:
{
va_list list;
va_start(list, fmt);
ConLog.Error(GetName() + " error: " + wxString::FormatV(fmt, list));
ConLog.Error(GetName() + " error: " + wxString::FormatV(fmt, list).mb_str());
va_end(list);
}
bool CheckId(u32 id) const
{
return Emu.GetIdManager().CheckID(id) && !Emu.GetIdManager().GetID(id).m_name.Cmp(GetName());
return Emu.GetIdManager().CheckID(id) && Emu.GetIdManager().GetID(id).m_name == GetName();
}
template<typename T> bool CheckId(u32 id, T*& data)
@ -105,7 +105,7 @@ public:
template<> bool CheckId(u32 id, ID*& _id)
{
return Emu.GetIdManager().CheckID(id) && !(_id = &Emu.GetIdManager().GetID(id))->m_name.Cmp(GetName());
return Emu.GetIdManager().CheckID(id) && (_id = &Emu.GetIdManager().GetID(id))->m_name == GetName();
}
template<typename T>

View file

@ -336,7 +336,7 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
stub.s_text = re(stub.s_text);
const wxString& module_name = Memory.ReadString(stub.s_modulename);
Module* module = GetModuleByName(module_name);
Module* module = GetModuleByName(module_name.mb_str());
if(module)
{
//module->SetLoaded();

View file

@ -221,8 +221,10 @@
<ClCompile Include="Emu\DbgConsole.cpp" />
<ClCompile Include="Emu\FS\VFS.cpp" />
<ClCompile Include="Emu\FS\vfsDevice.cpp" />
<ClCompile Include="Emu\FS\vfsDirBase.cpp" />
<ClCompile Include="Emu\FS\vfsFile.cpp" />
<ClCompile Include="Emu\FS\vfsFileBase.cpp" />
<ClCompile Include="Emu\FS\vfsLocalDir.cpp" />
<ClCompile Include="Emu\FS\vfsLocalFile.cpp" />
<ClCompile Include="Emu\FS\vfsStream.cpp" />
<ClCompile Include="Emu\FS\vfsStreamMemory.cpp" />

View file

@ -373,6 +373,12 @@
<ClCompile Include="Emu\SysCalls\lv2\SC_Lwcond.cpp">
<Filter>Emu\SysCalls\lv2</Filter>
</ClCompile>
<ClCompile Include="Emu\FS\vfsDirBase.cpp">
<Filter>Emu\FS</Filter>
</ClCompile>
<ClCompile Include="Emu\FS\vfsLocalDir.cpp">
<Filter>Emu\FS</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="rpcs3.rc" />