First stage of WX dependency removal.

This commit is contained in:
Sacha 2013-11-28 05:16:19 +10:00
parent d83a9b12d6
commit 6bcaf469e8
26 changed files with 296 additions and 235 deletions

View File

@ -7,7 +7,7 @@ ThreadBase* GetCurrentNamedThread()
return thr ? thr->m_parent : nullptr;
}
ThreadBase::ThreadBase(bool detached, const wxString& name)
ThreadBase::ThreadBase(bool detached, const std::string& name)
: m_detached(detached)
, m_name(name)
, m_executor(nullptr)
@ -86,12 +86,12 @@ bool ThreadBase::TestDestroy() const
return m_executor->TestDestroy();
}
wxString ThreadBase::GetThreadName() const
std::string ThreadBase::GetThreadName() const
{
return m_name;
}
void ThreadBase::SetThreadName(const wxString& name)
void ThreadBase::SetThreadName(const std::string& name)
{
m_name = name;
}

View File

@ -10,14 +10,14 @@ class ThreadExec;
class ThreadBase
{
protected:
wxString m_name;
std::string m_name;
bool m_detached;
public:
wxMutex m_main_mutex;
std::mutex m_main_mutex;
protected:
ThreadBase(bool detached = true, const wxString& name = "Unknown ThreadBase");
ThreadBase(bool detached = true, const std::string& name = "Unknown ThreadBase");
public:
ThreadExec* m_executor;
@ -34,15 +34,15 @@ public:
virtual bool IsPaused() const;
virtual bool IsAlive() const;
virtual bool TestDestroy() const;
virtual wxString GetThreadName() const;
virtual void SetThreadName(const wxString& name);
virtual std::string GetThreadName() const;
virtual void SetThreadName(const std::string& name);
};
ThreadBase* GetCurrentNamedThread();
class ThreadExec : public wxThread
{
wxCriticalSection m_wait_for_exit;
std::mutex m_wait_for_exit;
volatile bool m_alive;
public:
@ -66,13 +66,13 @@ public:
if(wait)
{
Delete();
//wxCriticalSectionLocker lock(m_wait_for_exit);
//std::lock_guard<std::mutex> lock(m_wait_for_exit);
}
}
ExitCode Entry()
{
//wxCriticalSectionLocker lock(m_wait_for_exit);
//std::lock_guard<std::mutex> lock(m_wait_for_exit);
m_parent->Task();
m_alive = false;
if(m_parent) m_parent->m_executor = nullptr;
@ -89,7 +89,7 @@ protected:
volatile u32 m_put, m_get;
Array<u8> m_buffer;
u32 m_max_buffer_size;
mutable wxCriticalSection m_cs_main;
mutable std::recursive_mutex m_cs_main;
void CheckBusy()
{
@ -110,7 +110,7 @@ public:
void Flush()
{
wxCriticalSectionLocker lock(m_cs_main);
std::lock_guard<std::recursive_mutex> lock(m_cs_main);
m_put = m_get = 0;
m_buffer.Clear();
m_busy = false;
@ -123,17 +123,17 @@ private:
public:
void Push(const T& v)
{
wxCriticalSectionLocker lock(m_cs_main);
std::lock_guard<std::recursive_mutex> lock(m_cs_main);
_push(v);
}
T Pop()
{
wxCriticalSectionLocker lock(m_cs_main);
std::lock_guard<std::recursive_mutex> lock(m_cs_main);
return _pop();
}
bool HasNewPacket() const { wxCriticalSectionLocker lock(m_cs_main); return m_put != m_get; }
bool HasNewPacket() const { std::lock_guard<std::recursive_mutex> lock(m_cs_main); return m_put != m_get; }
bool IsBusy() const { return m_busy; }
};

View File

@ -76,7 +76,7 @@ void CPUThread::SetId(const u32 id)
m_id = id;
}
void CPUThread::SetName(const wxString& name)
void CPUThread::SetName(const std::string& name)
{
m_name = name;
}
@ -197,7 +197,9 @@ void CPUThread::Run()
return;
}
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_START_THREAD, this);
#endif
m_status = Running;
@ -207,14 +209,18 @@ void CPUThread::Run()
DoRun();
Emu.CheckStatus();
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_STARTED_THREAD, this);
#endif
}
void CPUThread::Resume()
{
if(!IsPaused()) return;
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_RESUME_THREAD, this);
#endif
m_status = Running;
DoResume();
@ -222,28 +228,36 @@ void CPUThread::Resume()
ThreadBase::Start();
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_RESUMED_THREAD, this);
#endif
}
void CPUThread::Pause()
{
if(!IsRunning()) return;
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_PAUSE_THREAD, this);
#endif
m_status = Paused;
DoPause();
Emu.CheckStatus();
ThreadBase::Stop(false);
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_PAUSED_THREAD, this);
#endif
}
void CPUThread::Stop()
{
if(IsStopped()) return;
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_STOP_THREAD, this);
#endif
m_status = Stopped;
ThreadBase::Stop(false);
@ -251,24 +265,32 @@ void CPUThread::Stop()
DoStop();
Emu.CheckStatus();
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_STOPED_THREAD, this);
#endif
}
void CPUThread::Exec()
{
m_is_step = false;
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_EXEC_THREAD, this);
#endif
ThreadBase::Start();
}
void CPUThread::ExecOnce()
{
m_is_step = true;
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_EXEC_THREAD, this);
#endif
ThreadBase::Start();
if(!ThreadBase::Wait()) while(m_is_step) Sleep(1);
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_PAUSE_THREAD, this);
wxGetApp().SendDbgCommand(DID_PAUSED_THREAD, this);
#endif
}
void CPUThread::Task()

View File

@ -59,7 +59,7 @@ public:
virtual void SetArg(const uint pos, const u64 arg) = 0;
void SetId(const u32 id);
void SetName(const wxString& name);
void SetName(const std::string& name);
void SetPrio(const u64 prio) { m_prio = prio; }
void SetOffset(const u64 offset) { m_offset = offset; }
void SetExitStatus(const u32 status) { m_exit_status = status; }
@ -68,14 +68,14 @@ public:
u32 GetExitStatus() const { return m_exit_status; }
u64 GetPrio() const { return m_prio; }
wxString GetName() const { return m_name; }
std::string GetName() const { return m_name; }
wxString GetFName() const
{
return
wxString::Format("%s[%d] Thread%s",
GetTypeString().mb_str(),
m_id,
(GetName().IsEmpty() ? "" : (" (" + GetName() + ")").mb_str())
(GetName().empty() ? "" : std::string(" (" + GetName() + ")").c_str())
);
}
@ -94,9 +94,9 @@ public:
wxString GetTypeString() const { return CPUThreadTypeToString(m_type); }
virtual wxString GetThreadName() const
virtual std::string GetThreadName() const
{
return GetFName() + wxString::Format("[0x%08llx]", PC);
return (GetFName() + wxString::Format("[0x%08llx]", PC)).mb_str();
}
public:

View File

@ -39,7 +39,9 @@ CPUThread& CPUThreadManager::AddThread(CPUThreadType type)
new_thread->SetId(Emu.GetIdManager().GetNewID(wxString::Format("%s Thread", new_thread->GetTypeString().mb_str()), new_thread));
m_threads.Add(new_thread);
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_CREATE_THREAD, new_thread);
#endif
return *new_thread;
}
@ -59,7 +61,9 @@ void CPUThreadManager::RemoveThread(const u32 id)
if(m_threads[i].GetId() != id) continue;
CPUThread* thr = &m_threads[i];
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_REMOVE_THREAD, thr);
#endif
if(thr->IsAlive())
{
thr->Close();

View File

@ -15,9 +15,9 @@ public:
virtual void SetArg(const uint pos, const u64 arg) { assert(pos < 4); m_args[pos] = arg; }
virtual wxString GetThreadName() const
virtual std::string GetThreadName() const
{
return GetFName() + wxString::Format("[0x%08llx]", PC);
return (GetFName() + wxString::Format("[0x%08llx]", PC)).mb_str();
}
protected:

View File

@ -63,8 +63,9 @@ ArrayF<SectionInfo> sections_list;
u32 section_name_offs = 0;
u32 section_offs = 0;
SectionInfo::SectionInfo(const wxString& _name) : name(_name)
SectionInfo::SectionInfo(const wxString& _name)
{
name = _name.c_str();
memset(&shdr, 0, sizeof(Elf64_Shdr));
section_num = sections_list.Add(this);
@ -72,7 +73,7 @@ SectionInfo::SectionInfo(const wxString& _name) : name(_name)
shdr.sh_offset = section_offs;
shdr.sh_name = section_name_offs;
section_name_offs += name.GetCount() + 1;
section_name_offs += name.length() + 1;
}
void SectionInfo::SetDataSize(u32 size, u32 align)
@ -107,11 +108,11 @@ SectionInfo::~SectionInfo()
for(u32 i=section_num + 1; i<sections_list.GetCount(); ++i)
{
sections_list[i].shdr.sh_offset -= code.GetCount();
sections_list[i].shdr.sh_name -= name.GetCount();
sections_list[i].shdr.sh_name -= name.length();
}
section_offs -= code.GetCount();
section_name_offs -= name.GetCount();
section_name_offs -= name.length();
}
CompilePPUProgram::CompilePPUProgram(
@ -354,7 +355,7 @@ bool CompilePPUProgram::CheckEnd(bool show_err)
void CompilePPUProgram::DetectArgInfo(Arg& arg)
{
const wxString str = arg.string.GetPtr();
const wxString str = arg.string;
if(str.Len() <= 0)
{
@ -372,7 +373,8 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg)
{
for(u32 i=0; i<m_branches.GetCount(); ++i)
{
if(str.Cmp(m_branches[i].m_name.GetPtr()) != 0) continue;
if(str.mb_str() != m_branches[i].m_name)
continue;
arg.type = ARG_BRANCH;
arg.value = GetBranchValue(str);
@ -468,7 +470,7 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg)
return;
}
arg.string = str(1, str.Len() - 2);
arg.string = str(1, str.Len() - 2).c_str();
arg.type = ARG_TXT;
return;
}
@ -532,7 +534,8 @@ u32 CompilePPUProgram::GetBranchValue(const wxString& branch)
{
for(u32 i=0; i<m_branches.GetCount(); ++i)
{
if(branch.Cmp(m_branches[i].m_name.GetPtr()) != 0) continue;
if(branch.mb_str() != m_branches[i].m_name)
continue;
if(m_branches[i].m_pos >= 0) return m_text_addr + m_branches[i].m_pos * 4;
return m_branches[i].m_addr;
@ -664,7 +667,7 @@ CompilePPUProgram::Branch& CompilePPUProgram::GetBranch(const wxString& name)
{
for(u32 i=0; i<m_branches.GetCount(); ++i)
{
if(name.Cmp(m_branches[i].m_name.GetPtr()) != 0) continue;
if(name.mb_str() != m_branches[i].m_name) continue;
return m_branches[i];
}
@ -684,7 +687,8 @@ void CompilePPUProgram::SetSp(const wxString& name, u32 addr, bool create)
for(u32 i=0; i<m_branches.GetCount(); ++i)
{
if(name.Cmp(m_branches[i].m_name.GetPtr()) != 0) continue;
if(name.mb_str() != m_branches[i].m_name)
continue;
m_branches[i].m_addr = addr;
}
}
@ -803,7 +807,7 @@ void CompilePPUProgram::LoadSp(const wxString& op, Elf64_Shdr& s_opd)
for(u32 i=0; i<m_sp_string.GetCount(); ++i)
{
if(src1.Cmp(m_sp_string[i].m_data.GetPtr()) != 0) continue;
if(src1.mb_str() != m_sp_string[i].m_data) continue;
*dst_branch = Branch(dst, -1, m_sp_string[i].m_addr);
founded = true;
}
@ -827,7 +831,7 @@ void CompilePPUProgram::LoadSp(const wxString& op, Elf64_Shdr& s_opd)
{
if(m_sp_string[i].m_addr == a_src1.value)
{
*dst_branch = Branch(dst, -1, m_sp_string[i].m_data.GetCount());
*dst_branch = Branch(dst, -1, m_sp_string[i].m_data.length());
break;
}
}
@ -957,7 +961,7 @@ void CompilePPUProgram::Compile()
for(u32 i=0; i<m_branches.GetCount(); ++i)
{
m_branches[i].m_name.Clear();
m_branches[i].m_name.clear();
}
m_branches.Clear();
@ -1335,7 +1339,7 @@ void CompilePPUProgram::Compile()
for(u32 i=0; i<m_branches.GetCount(); ++i)
{
if(name.Cmp(m_branches[i].m_name.GetPtr()) != 0) continue;
if(name.mb_str() != m_branches[i].m_name) continue;
WriteError(wxString::Format("'%s' already declared", name.mb_str()));
m_error = true;
break;
@ -1365,7 +1369,8 @@ void CompilePPUProgram::Compile()
bool has_entry = false;
for(u32 i=0; i<m_branches.GetCount(); ++i)
{
if(wxString("entry").Cmp(m_branches[i].m_name.GetPtr()) != 0) continue;
if(m_branches[i].m_name != "entry")
continue;
has_entry = true;
break;
@ -1502,7 +1507,7 @@ void CompilePPUProgram::Compile()
u32 entry_point = s_text.sh_addr;
for(u32 i=0; i<m_branches.GetCount(); ++i)
{
if(wxString("entry").Cmp(m_branches[i].m_name.GetPtr()) == 0)
if(m_branches[i].m_name == "entry")
{
entry_point += m_branches[i].m_pos * 4;
break;
@ -1553,7 +1558,7 @@ void CompilePPUProgram::Compile()
for(u32 i=0; i<m_sp_string.GetCount(); ++i)
{
f.Seek(s_opd.sh_offset + (m_sp_string[i].m_addr - s_opd.sh_addr));
f.Write(&m_sp_string[i].m_data[0], m_sp_string[i].m_data.GetCount() + 1);
f.Write(&m_sp_string[i].m_data[0], m_sp_string[i].m_data.length() + 1);
}
f.Seek(s_sceStub_text.sh_offset);
@ -1703,7 +1708,7 @@ void CompilePPUProgram::Compile()
for(u32 i=0; i<m_branches.GetCount(); ++i)
{
m_branches[i].m_name.Clear();
m_branches[i].m_name.clear();
}
m_branches.Clear();

View File

@ -19,22 +19,22 @@ enum ArgType
struct Arg
{
ArrayString string;
std::string string;
u32 value;
ArgType type;
Arg(const wxString& _string, const u32 _value = 0, const ArgType _type = ARG_ERR)
: string(_string)
, value(_value)
: value(_value)
, type(_type)
{
string = _string.c_str();
}
};
struct SectionInfo
{
Elf64_Shdr shdr;
ArrayString name;
std::string name;
Array<u8> code;
u32 section_num;
@ -62,25 +62,25 @@ class CompilePPUProgram
{
struct Branch
{
ArrayString m_name;
std::string m_name;
s32 m_pos;
s32 m_id;
s32 m_addr;
Branch(const wxString& name, s32 pos)
: m_name(name)
, m_pos(pos)
: m_pos(pos)
, m_id(-1)
, m_addr(-1)
{
m_name = name.c_str();
}
Branch(const wxString& name, u32 id, u32 addr)
: m_name(name)
, m_pos(-1)
: m_pos(-1)
, m_id(id)
, m_addr(addr)
{
m_name = name.c_str();
}
};
@ -101,13 +101,13 @@ class CompilePPUProgram
struct SpData
{
ArrayString m_data;
std::string m_data;
u32 m_addr;
SpData(const wxString& data, u32 addr)
: m_data(data)
, m_addr(addr)
: m_addr(addr)
{
m_data = data.c_str();
}
};

View File

@ -139,17 +139,17 @@ void VFS::Init(const wxString& path)
break;
case vfsDevice_HDD:
dev = new vfsHDD(entries[i].device_path.GetPtr());
dev = new vfsHDD(entries[i].device_path);
break;
default:
continue;
}
wxString mpath = entries[i].path.GetPtr();
wxString mpath = entries[i].path;
mpath.Replace("$(EmulatorDir)", wxGetCwd());
mpath.Replace("$(GameDir)", vfsDevice::GetRoot(path));
Mount(entries[i].mount.GetPtr(), mpath, dev);
Mount(entries[i].mount, mpath, dev);
}
}
@ -222,16 +222,16 @@ void VFS::SaveLoadDevices(Array<VFSManagerEntry>& res, bool is_load)
if(is_load)
{
new (res + i) VFSManagerEntry();
res[i].path = entry_path.LoadValue(wxEmptyString);
res[i].device_path = entry_device_path.LoadValue(wxEmptyString);
res[i].mount = entry_mount.LoadValue(wxEmptyString);
res[i].path = strdup(entry_path.LoadValue(wxEmptyString).c_str());
res[i].device_path = strdup(entry_device_path.LoadValue(wxEmptyString).c_str());
res[i].mount = strdup(entry_mount.LoadValue(wxEmptyString).c_str());
res[i].device = (vfsDeviceType)entry_device.LoadValue(vfsDevice_LocalFile);
}
else
{
entry_path.SaveValue(res[i].path.GetPtr());
entry_device_path.SaveValue(res[i].device_path.GetPtr());
entry_mount.SaveValue(res[i].mount.GetPtr());
entry_path.SaveValue(res[i].path);
entry_device_path.SaveValue(res[i].device_path);
entry_mount.SaveValue(res[i].mount);
entry_device.SaveValue(res[i].device);
}
}

View File

@ -15,9 +15,9 @@ static const char* vfsDeviceTypeNames[] =
struct VFSManagerEntry
{
ArrayString device_path;
ArrayString path;
ArrayString mount;
char* device_path;
char* path;
char* mount;
vfsDeviceType device;
VFSManagerEntry() : device(vfsDevice_LocalFile)

View File

@ -1,18 +1,18 @@
#include "stdafx.h"
#include "GLFragmentProgram.h"
void GLFragmentDecompilerThread::AddCode(wxString code, bool append_mask)
void GLFragmentDecompilerThread::AddCode(std::string code, bool append_mask)
{
if(!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_lt) return;
const wxString mask = GetMask();
wxString cond = wxEmptyString;
const std::string mask = GetMask().c_str();
std::string cond = "";
if(!src0.exec_if_gr || !src0.exec_if_lt || !src0.exec_if_eq)
{
static const char f[4] = {'x', 'y', 'z', 'w'};
wxString swizzle = wxEmptyString;
std::string swizzle = "";
swizzle += f[src0.cond_swizzle_x];
swizzle += f[src0.cond_swizzle_y];
swizzle += f[src0.cond_swizzle_z];
@ -43,7 +43,7 @@ void GLFragmentDecompilerThread::AddCode(wxString code, bool append_mask)
cond = "equal";
}
cond = wxString::Format("if(all(%s(%s.%s, vec4(0, 0, 0, 0)))) ", cond.mb_str(), AddCond(dst.no_dest).mb_str(), swizzle.mb_str());
cond = std::string("if(all(" + cond + "(" + AddCond(dst.no_dest) + "." + swizzle +", vec4(0, 0, 0, 0)))) ");
//ConLog.Error("cond! [eq: %d gr: %d lt: %d] (%s)", src0.exec_if_eq, src0.exec_if_gr, src0.exec_if_lt, cond);
//Emu.Pause();
//return;
@ -72,16 +72,16 @@ void GLFragmentDecompilerThread::AddCode(wxString code, bool append_mask)
code = "clamp(" + code + ", 0.0, 1.0)";
}
code = cond + (dst.set_cond ? m_parr.AddParam(PARAM_NONE , "vec4", wxString::Format(dst.fp16 ? "hc%d" : "rc%d", src0.cond_reg_index))
code = cond + (dst.set_cond ? m_parr.AddParam(PARAM_NONE , "vec4", std::string(dst.fp16 ? "hc" : "rc") + std::to_string(src0.cond_reg_index))
: AddReg(dst.dest_reg, dst.fp16)) + mask
+ " = " + code + (append_mask ? mask : wxString(wxEmptyString));
+ " = " + code + (append_mask ? mask : "");
main += "\t" + code + ";\n";
}
wxString GLFragmentDecompilerThread::GetMask()
std::string GLFragmentDecompilerThread::GetMask()
{
wxString ret = wxEmptyString;
std::string ret = "";
static const char dst_mask[4] =
{
@ -93,10 +93,10 @@ wxString GLFragmentDecompilerThread::GetMask()
if(dst.mask_z) ret += dst_mask[2];
if(dst.mask_w) ret += dst_mask[3];
return ret.IsEmpty() || strncmp(ret, dst_mask, 4) == 0 ? wxString(wxEmptyString) : ("." + ret);
return ret.empty() || strncmp(ret.c_str(), dst_mask, 4) == 0 ? "" : ("." + ret);
}
wxString GLFragmentDecompilerThread::AddReg(u32 index, int fp16)
std::string GLFragmentDecompilerThread::AddReg(u32 index, int fp16)
{
/*
if(HasReg(index, fp16))
@ -108,21 +108,21 @@ wxString GLFragmentDecompilerThread::AddReg(u32 index, int fp16)
//ConLog.Warning("%c%d: %d %d", (fp16 ? 'h' : 'r'), index, dst.tex_num, src2.use_index_reg);
return m_parr.AddParam((index >= 2 && index <= 4) ? PARAM_OUT : PARAM_NONE, "vec4",
wxString::Format((fp16 ? "h%u" : "r%u"), index), (fp16 || !index) ? -1 : ((index >= 2 && index <= 4) ? (index - 1) : -1));
std::string(fp16 ? "h" : "r") + std::to_string(index), (fp16 || !index) ? -1 : ((index >= 2 && index <= 4) ? (index - 1) : -1));
}
bool GLFragmentDecompilerThread::HasReg(u32 index, int fp16)
{
return m_parr.HasParam((index >= 2 && index <= 4) ? PARAM_OUT : PARAM_NONE, "vec4",
wxString::Format((fp16 ? "h%u" : "r%u"), index));
std::string(fp16 ? "h" : "r") + std::to_string(index));
}
wxString GLFragmentDecompilerThread::AddCond(int fp16)
std::string GLFragmentDecompilerThread::AddCond(int fp16)
{
return m_parr.AddParam(PARAM_NONE , "vec4", wxString::Format(fp16 ? "hc%d" : "rc%d", src0.cond_mod_reg_index));
return m_parr.AddParam(PARAM_NONE , "vec4", std::string(fp16 ? "hc" : "rc") + std::to_string(src0.cond_mod_reg_index));
}
wxString GLFragmentDecompilerThread::AddConst()
std::string GLFragmentDecompilerThread::AddConst()
{
mem32_ptr_t data(m_addr + m_size + m_offset);
@ -131,18 +131,19 @@ wxString GLFragmentDecompilerThread::AddConst()
u32 y = GetData(data[1]);
u32 z = GetData(data[2]);
u32 w = GetData(data[3]);
return m_parr.AddParam(PARAM_UNIFORM, "vec4", wxString::Format("fc%u", m_size + 4 * 4),
wxString::Format("vec4(%f, %f, %f, %f)", (float&)x, (float&)y, (float&)z, (float&)w));
return m_parr.AddParam(PARAM_UNIFORM, "vec4", std::string("fc") + std::to_string(m_size + 4 * 4),
std::string("vec4(") + std::to_string((float&)x) + ", " + std::to_string((float&)y)
+ ", " + std::to_string((float&)z) + ", " + std::to_string((float&)w) + ")");
}
wxString GLFragmentDecompilerThread::AddTex()
std::string GLFragmentDecompilerThread::AddTex()
{
return m_parr.AddParam(PARAM_UNIFORM, "sampler2D", wxString::Format("tex%d", dst.tex_num));
return m_parr.AddParam(PARAM_UNIFORM, "sampler2D", std::string("tex") + std::to_string(dst.tex_num));
}
template<typename T> wxString GLFragmentDecompilerThread::GetSRC(T src)
template<typename T> std::string GLFragmentDecompilerThread::GetSRC(T src)
{
wxString ret = wxEmptyString;
std::string ret = "";
switch(src.reg_type)
{
@ -152,7 +153,7 @@ template<typename T> wxString GLFragmentDecompilerThread::GetSRC(T src)
case 1: //input
{
static const wxString reg_table[] =
static const std::string reg_table[] =
{
"gl_Position",
"col0", "col1",
@ -164,7 +165,7 @@ template<typename T> wxString GLFragmentDecompilerThread::GetSRC(T src)
{
case 0x00: ret += reg_table[0]; break;
default:
if(dst.src_attr_reg_num < WXSIZEOF(reg_table))
if(dst.src_attr_reg_num < sizeof(reg_table)/sizeof(reg_table[0]))
{
ret += m_parr.AddParam(PARAM_IN, "vec4", reg_table[dst.src_attr_reg_num]);
}
@ -191,13 +192,13 @@ template<typename T> wxString GLFragmentDecompilerThread::GetSRC(T src)
static const char f[4] = {'x', 'y', 'z', 'w'};
wxString swizzle = wxEmptyString;
std::string swizzle = "";
swizzle += f[src.swizzle_x];
swizzle += f[src.swizzle_y];
swizzle += f[src.swizzle_z];
swizzle += f[src.swizzle_w];
if(strncmp(swizzle, f, 4) != 0) ret += "." + swizzle;
if(strncmp(swizzle.c_str(), f, 4) != 0) ret += "." + swizzle;
if(src.abs) ret = "abs(" + ret + ")";
if(src.neg) ret = "-" + ret;
@ -205,26 +206,23 @@ template<typename T> wxString GLFragmentDecompilerThread::GetSRC(T src)
return ret;
}
wxString GLFragmentDecompilerThread::BuildCode()
std::string GLFragmentDecompilerThread::BuildCode()
{
//main += wxString::Format("\tgl_FragColor = %c0;\n", m_ctrl & 0x40 ? 'r' : 'h');
main += "\t" + m_parr.AddParam(PARAM_OUT, "vec4", "ocol", 0) + " = " + (m_ctrl & 0x40 ? "r0" : "h0") + ";\n";
if(m_ctrl & 0xe) main += "\tgl_FragDepth = r1.z;\n";
wxString p = wxEmptyString;
std::string p = "";
for(u32 i=0; i<m_parr.params.GetCount(); ++i)
{
p += m_parr.params[i].Format();
}
static const wxString& prot =
"#version 330\n"
"\n"
"%s\n"
"void main()\n{\n%s}\n";
return wxString::Format(prot, p.mb_str(), main.mb_str());
return std::string("#version 330\n"
"\n"
+ p + "\n"
"void main()\n{\n" + main + "}\n");
}
void GLFragmentDecompilerThread::Task()
@ -325,7 +323,7 @@ void GLFragmentDecompilerThread::Task()
}
m_shader = BuildCode();
main.Clear();
main.clear();
m_parr.params.Clear();
}
@ -381,7 +379,7 @@ void GLShaderProgram::Compile()
id = glCreateShader(GL_FRAGMENT_SHADER);
const char* str = shader.c_str();
const int strlen = shader.Len();
const int strlen = shader.length();
glShaderSource(id, 1, &str, &strlen);
glCompileShader(id);
@ -402,7 +400,7 @@ void GLShaderProgram::Compile()
delete[] buf;
}
ConLog.Write(shader);
ConLog.Write(shader.c_str());
Emu.Pause();
}
//else ConLog.Write("Shader compiled successfully!");
@ -413,11 +411,11 @@ void GLShaderProgram::Delete()
for(u32 i=0; i<parr.params.GetCount(); ++i)
{
parr.params[i].items.Clear();
parr.params[i].type.Clear();
parr.params[i].type.clear();
}
parr.params.Clear();
shader.Clear();
shader.clear();
if(id)
{

View File

@ -98,8 +98,8 @@ struct GLFragmentDecompilerThread : public ThreadBase
};
} src2;
wxString main;
wxString& m_shader;
std::string main;
std::string& m_shader;
GLParamArray& m_parr;
u32 m_addr;
u32& m_size;
@ -108,7 +108,7 @@ struct GLFragmentDecompilerThread : public ThreadBase
u32 m_location;
u32 m_ctrl;
GLFragmentDecompilerThread(wxString& shader, GLParamArray& parr, u32 addr, u32& size, u32 ctrl)
GLFragmentDecompilerThread(std::string& shader, GLParamArray& parr, u32 addr, u32& size, u32 ctrl)
: ThreadBase(false, "Fragment Shader Decompiler Thread")
, m_shader(shader)
, m_parr(parr)
@ -121,17 +121,17 @@ struct GLFragmentDecompilerThread : public ThreadBase
m_size = 0;
}
wxString GetMask();
std::string GetMask();
void AddCode(wxString code, bool append_mask = true);
wxString AddReg(u32 index, int fp16);
void AddCode(std::string code, bool append_mask = true);
std::string AddReg(u32 index, int fp16);
bool HasReg(u32 index, int fp16);
wxString AddCond(int fp16);
wxString AddConst();
wxString AddTex();
std::string AddCond(int fp16);
std::string AddConst();
std::string AddTex();
template<typename T> wxString GetSRC(T src);
wxString BuildCode();
template<typename T> std::string GetSRC(T src);
std::string BuildCode();
virtual void Task();
@ -147,7 +147,7 @@ struct GLShaderProgram
GLParamArray parr;
wxString shader;
std::string shader;
u32 id;

View File

@ -8,7 +8,7 @@ int GLProgramBuffer::SearchFp(const RSXShaderProgram& rsx_fp, GLShaderProgram& g
if(memcmp(&m_buf[i].fp_data[0], &Memory[rsx_fp.addr], m_buf[i].fp_data.GetCount()) != 0) continue;
gl_fp.id = m_buf[i].fp_id;
gl_fp.shader = m_buf[i].fp_shader.GetPtr();
gl_fp.shader = m_buf[i].fp_shader.c_str();
return i;
}
@ -24,7 +24,7 @@ int GLProgramBuffer::SearchVp(const RSXVertexProgram& rsx_vp, GLVertexProgram& g
if(memcmp(m_buf[i].vp_data.GetPtr(), rsx_vp.data.GetPtr(), rsx_vp.data.GetCount() * 4) != 0) continue;
gl_vp.id = m_buf[i].vp_id;
gl_vp.shader = m_buf[i].vp_shader.GetPtr();
gl_vp.shader = m_buf[i].vp_shader.c_str();
return i;
}
@ -93,8 +93,8 @@ void GLProgramBuffer::Add(GLProgram& prog, GLShaderProgram& gl_fp, RSXShaderProg
ConLog.Write("*** vp data size = %d", rsx_vp.data.GetCount() * 4);
ConLog.Write("*** fp data size = %d", rsx_fp.size);
ConLog.Write("*** vp shader = \n%s", gl_vp.shader.mb_str());
ConLog.Write("*** fp shader = \n%s", gl_fp.shader.mb_str());
ConLog.Write("*** vp shader = \n%s", gl_vp.shader.c_str());
ConLog.Write("*** fp shader = \n%s", gl_fp.shader.c_str());
new_buf.prog_id = prog.id;
new_buf.vp_id = gl_vp.id;
@ -120,8 +120,8 @@ void GLProgramBuffer::Clear()
m_buf[i].fp_data.Clear();
m_buf[i].vp_data.Clear();
m_buf[i].vp_shader.Clear();
m_buf[i].fp_shader.Clear();
m_buf[i].vp_shader.clear();
m_buf[i].fp_shader.clear();
}
m_buf.Clear();

View File

@ -8,8 +8,8 @@ struct GLBufferInfo
u32 vp_id;
Array<u8> fp_data;
Array<u32> vp_data;
ArrayString fp_shader;
ArrayString vp_shader;
std::string fp_shader;
std::string vp_shader;
};
struct GLProgramBuffer

View File

@ -12,54 +12,53 @@ enum GLParamFlag
struct GLParamItem
{
ArrayString name;
ArrayString location;
ArrayString value;
std::string name;
std::string location;
std::string value;
GLParamItem(const wxString& _name, int _location, const wxString& _value = wxEmptyString)
GLParamItem(const std::string& _name, int _location, const std::string& _value = "")
: name(_name)
, location(_location > -1 ? wxString::Format("layout (location = %d) ", _location) : "")
, value(_value)
{
if (_location > -1)
location = "layout (location = " + std::to_string(_location) + ") ";
else
location = "";
}
};
struct GLParamType
{
const GLParamFlag flag;
ArrayString type;
std::string type;
Array<GLParamItem> items;
GLParamType(const GLParamFlag _flag, const wxString& _type)
: type(_type)
, flag(_flag)
GLParamType(const GLParamFlag _flag, const std::string& _type)
: flag(_flag)
, type(_type)
{
}
bool SearchName(const wxString& name)
bool SearchName(const std::string& name)
{
for(u32 i=0; i<items.GetCount(); ++i)
{
if(name.Cmp(items[i].name.GetPtr()) == 0) return true;
if(items[i].name.compare(name) == 0) return true;
}
return false;
}
wxString Format()
std::string Format()
{
wxString ret = wxEmptyString;
std::string ret = "";
for(u32 n=0; n<items.GetCount(); ++n)
{
ret += items[n].location.GetPtr();
ret += type.GetPtr();
ret += " ";
ret += items[n].name.GetPtr();
if(items[n].value.GetCount())
ret += items[n].location + type + " " + items[n].name;
if(!items[n].value.empty())
{
ret += " = ";
ret += items[n].value.GetPtr();
ret += " = " + items[n].value;
}
ret += ";\n";
}
@ -72,17 +71,18 @@ struct GLParamArray
{
Array<GLParamType> params;
GLParamType* SearchParam(const wxString& type)
GLParamType* SearchParam(const std::string& type)
{
for(u32 i=0; i<params.GetCount(); ++i)
{
if(type.Cmp(params[i].type.GetPtr()) == 0) return &params[i];
if (params[i].type.compare(type) == 0)
return &params[i];
}
return nullptr;
}
wxString GetParamFlag(const GLParamFlag flag)
std::string GetParamFlag(const GLParamFlag flag)
{
switch(flag)
{
@ -92,17 +92,17 @@ struct GLParamArray
case PARAM_CONST: return "const ";
}
return wxEmptyString;
return "";
}
bool HasParam(const GLParamFlag flag, wxString type, const wxString& name)
bool HasParam(const GLParamFlag flag, std::string type, const std::string& name)
{
type = GetParamFlag(flag) + type;
GLParamType* t = SearchParam(type);
return t && t->SearchName(name);
}
wxString AddParam(const GLParamFlag flag, wxString type, const wxString& name, const wxString& value)
std::string AddParam(const GLParamFlag flag, std::string type, const std::string& name, const std::string& value)
{
type = GetParamFlag(flag) + type;
GLParamType* t = SearchParam(type);
@ -121,7 +121,7 @@ struct GLParamArray
return name;
}
wxString AddParam(const GLParamFlag flag, wxString type, const wxString& name, int location = -1)
std::string AddParam(const GLParamFlag flag, std::string type, const std::string& name, int location = -1)
{
type = GetParamFlag(flag) + type;
GLParamType* t = SearchParam(type);

View File

@ -35,7 +35,7 @@ wxString GLVertexDecompilerThread::GetScaMask()
wxString GLVertexDecompilerThread::GetDST(bool isSca)
{
static const wxString reg_table[] =
static const std::string reg_table[] =
{
"gl_Position",
"col0", "col1",
@ -54,7 +54,7 @@ wxString GLVertexDecompilerThread::GetDST(bool isSca)
break;
case 0x1f:
ret += m_parr.AddParam(PARAM_NONE, "vec4", wxString::Format("tmp%u", isSca ? d3.sca_dst_tmp : d0.dst_tmp));
ret += m_parr.AddParam(PARAM_NONE, "vec4", std::string("tmp") + std::to_string(isSca ? d3.sca_dst_tmp : d0.dst_tmp));
break;
default:
@ -75,7 +75,7 @@ wxString GLVertexDecompilerThread::GetDST(bool isSca)
wxString GLVertexDecompilerThread::GetSRC(const u32 n, bool isSca)
{
static const wxString reg_table[] =
static const std::string reg_table[] =
{
"in_pos", "in_weight", "in_normal",
"in_col0", "in_col1",
@ -90,7 +90,7 @@ wxString GLVertexDecompilerThread::GetSRC(const u32 n, bool isSca)
switch(src[n].reg_type)
{
case 1: //temp
ret += m_parr.AddParam(PARAM_NONE, "vec4", wxString::Format("tmp%u", src[n].tmp_src));
ret += m_parr.AddParam(PARAM_NONE, "vec4", std::string("tmp") + std::to_string(src[n].tmp_src));
break;
case 2: //input
if(d1.input_src < WXSIZEOF(reg_table))
@ -104,7 +104,7 @@ wxString GLVertexDecompilerThread::GetSRC(const u32 n, bool isSca)
}
break;
case 3: //const
ret += m_parr.AddParam(PARAM_UNIFORM, "vec4", wxString::Format("vc%u", d1.const_src));
ret += m_parr.AddParam(PARAM_UNIFORM, "vec4", std::string("vc") + std::to_string(d1.const_src));
break;
default:

View File

@ -329,35 +329,35 @@ bool MemoryBlockLE::Write128(const u64 addr, const u128 value)
}
//NullMemoryBlock
bool NullMemoryBlock::Read8(const u64 addr, u8* WXUNUSED(value))
bool NullMemoryBlock::Read8(const u64 addr, u8* )
{
ConLog.Error("Read8 from null block: [%08llx]", addr);
Emu.Pause();
return false;
}
bool NullMemoryBlock::Read16(const u64 addr, u16* WXUNUSED(value))
bool NullMemoryBlock::Read16(const u64 addr, u16* )
{
ConLog.Error("Read16 from null block: [%08llx]", addr);
Emu.Pause();
return false;
}
bool NullMemoryBlock::Read32(const u64 addr, u32* WXUNUSED(value))
bool NullMemoryBlock::Read32(const u64 addr, u32* )
{
ConLog.Error("Read32 from null block: [%08llx]", addr);
Emu.Pause();
return false;
}
bool NullMemoryBlock::Read64(const u64 addr, u64* WXUNUSED(value))
bool NullMemoryBlock::Read64(const u64 addr, u64* )
{
ConLog.Error("Read64 from null block: [%08llx]", addr);
Emu.Pause();
return false;
}
bool NullMemoryBlock::Read128(const u64 addr, u128* WXUNUSED(value))
bool NullMemoryBlock::Read128(const u64 addr, u128* )
{
ConLog.Error("Read128 from null block: [%08llx]", addr);
Emu.Pause();

View File

@ -147,7 +147,7 @@ int sys_ppu_thread_create(u32 thread_id_addr, u32 entry, u32 arg, int prio, u32
new_thread.SetPrio(prio);
new_thread.SetStackSize(stacksize);
//new_thread.flags = flags;
new_thread.SetName(Memory.ReadString(threadname_addr));
new_thread.SetName(Memory.ReadString(threadname_addr).mb_str());
new_thread.Run();
new_thread.Exec();

View File

@ -35,18 +35,18 @@ u32 LoadSpuImage(vfsStream& stream)
//156
int sys_spu_image_open(mem_ptr_t<sys_spu_image> img, u32 path_addr)
{
const wxString& path = Memory.ReadString(path_addr);
sc_spu.Warning("sys_spu_image_open(img_addr=0x%x, path_addr=0x%x [%s])", img.GetAddr(), path_addr, path.mb_str());
const std::string& path = Memory.ReadString(path_addr).mb_str();
sc_spu.Warning("sys_spu_image_open(img_addr=0x%x, path_addr=0x%x [%s])", img.GetAddr(), path_addr, path);
if(!img.IsGood() || !Memory.IsGoodAddr(path_addr))
{
return CELL_EFAULT;
}
vfsFile f(path);
vfsFile f(path.c_str());
if(!f.IsOpened())
{
sc_spu.Error("sys_spu_image_open error: '%s' not found!", path.mb_str());
sc_spu.Error("sys_spu_image_open error: '%s' not found!", path);
return CELL_ENOENT;
}
@ -94,7 +94,7 @@ int sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t<
}
u32 entry = img->entry_point;
wxString name = Memory.ReadString(attr->name_addr, attr->name_len);
std::string name = Memory.ReadString(attr->name_addr, attr->name_len).mb_str();
u64 a1 = arg->arg1;
u64 a2 = arg->arg2;
u64 a3 = arg->arg3;
@ -102,7 +102,7 @@ int sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t<
ConLog.Write("New SPU Thread:");
ConLog.Write("entry = 0x%x", entry);
ConLog.Write("name = %s", name.mb_str());
ConLog.Write("name = %s", name);
ConLog.Write("a1 = 0x%x", a1);
ConLog.Write("a2 = 0x%x", a2);
ConLog.Write("a3 = 0x%x", a3);
@ -190,10 +190,10 @@ int sys_spu_thread_group_create(mem32_t id, u32 num, int prio, mem_ptr_t<sys_spu
ConLog.Write("*** attr.type=%d", attr->type.ToLE());
ConLog.Write("*** attr.option.ct=%d", attr->option.ct.ToLE());
const wxString& name = Memory.ReadString(attr->name_addr, attr->name_len);
ConLog.Write("*** name='%s'", name.mb_str());
const std::string& name = Memory.ReadString(attr->name_addr, attr->name_len).mb_str();
ConLog.Write("*** name='%s'", name);
id = Emu.GetIdManager().GetNewID(wxString::Format("sys_spu_thread_group '%s'", name.mb_str()), new SpuGroupInfo(*attr));
id = Emu.GetIdManager().GetNewID(wxString::Format("sys_spu_thread_group '%s'", name), new SpuGroupInfo(*attr));
return CELL_OK;
}

View File

@ -6,9 +6,11 @@
#include "Emu/Cell/PPUThread.h"
#include "Emu/Cell/SPUThread.h"
#include "Emu/Cell/PPUInstrTable.h"
#include <cstdlib>
#include <fstream>
using namespace PPU_instr;
static const wxString& BreakPointsDBName = "BreakPoints.dat";
static const std::string& BreakPointsDBName = "BreakPoints.dat";
static const u16 bpdb_version = 0x1000;
ModuleInitializer::ModuleInitializer()
@ -234,7 +236,9 @@ void Emulator::Load()
wxCriticalSectionLocker lock(m_cs_status);
m_status = Ready;
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_READY_EMU);
#endif
}
void Emulator::Run()
@ -251,8 +255,9 @@ void Emulator::Run()
Resume();
return;
}
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_START_EMU);
#endif
wxCriticalSectionLocker lock(m_cs_status);
//ConLog.Write("run...");
@ -265,32 +270,42 @@ void Emulator::Run()
//m_memory_viewer->ShowPC();
GetCPU().Exec();
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_STARTED_EMU);
#endif
}
void Emulator::Pause()
{
if(!IsRunning()) return;
//ConLog.Write("pause...");
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_PAUSE_EMU);
#endif
wxCriticalSectionLocker lock(m_cs_status);
m_status = Paused;
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_PAUSED_EMU);
#endif
}
void Emulator::Resume()
{
if(!IsPaused()) return;
//ConLog.Write("resume...");
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_RESUME_EMU);
#endif
wxCriticalSectionLocker lock(m_cs_status);
m_status = Running;
CheckStatus();
if(IsRunning() && Ini.CPUDecoderMode.GetValue() != 1) GetCPU().Exec();
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_RESUMED_EMU);
#endif
}
void Emulator::Stop()
@ -298,7 +313,9 @@ void Emulator::Stop()
if(IsStopped()) return;
//ConLog.Write("shutdown...");
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_STOP_EMU);
#endif
{
wxCriticalSectionLocker lock(m_cs_status);
m_status = Stopped;
@ -326,60 +343,63 @@ void Emulator::Stop()
Memory.Close();
//if(m_memory_viewer && m_memory_viewer->IsShown()) m_memory_viewer->Hide();
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_STOPPED_EMU);
#endif
}
void Emulator::SavePoints(const wxString& path)
void Emulator::SavePoints(const std::string& path)
{
wxFile f(path, wxFile::write);
std::ofstream f(path, std::ios::binary | std::ios::trunc);
u32 break_count = m_break_points.GetCount();
u32 marked_count = m_marked_points.GetCount();
f.Write(&bpdb_version, sizeof(u16));
f.Write(&break_count, sizeof(u32));
f.Write(&marked_count, sizeof(u32));
f << bpdb_version << break_count << marked_count;
if(break_count)
{
f.Write(&m_break_points[0], sizeof(u64) * break_count);
f.write(reinterpret_cast<char*>(&m_break_points[0]), sizeof(u64) * break_count);
}
if(marked_count)
{
f.Write(&m_marked_points[0], sizeof(u64) * marked_count);
f.write(reinterpret_cast<char*>(&m_marked_points[0]), sizeof(u64) * marked_count);
}
}
void Emulator::LoadPoints(const wxString& path)
void Emulator::LoadPoints(const std::string& path)
{
if(!wxFileExists(path)) return;
wxFile f(path);
struct stat buf;
if (!stat(path.c_str(), &buf))
return;
std::ifstream f(path, std::ios::binary);
if (!f.is_open())
return;
f.seekg(0, std::ios::end);
int length = f.tellg();
f.seekg(0, std::ios::beg);
u32 break_count, marked_count;
u16 version;
f.Read(&version, sizeof(u16));
f.Read(&break_count, sizeof(u32));
f.Read(&marked_count, sizeof(u32));
f >> version >> break_count >> marked_count;
if(version != bpdb_version ||
(sizeof(u16) + break_count * sizeof(u64) + sizeof(u32) + marked_count * sizeof(u64) + sizeof(u32)) != f.Length())
(sizeof(u16) + break_count * sizeof(u64) + sizeof(u32) + marked_count * sizeof(u64) + sizeof(u32)) != length)
{
ConLog.Error("'%s' is broken", path.mb_str());
ConLog.Error("'%s' is broken", path.c_str());
return;
}
if(break_count > 0)
{
m_break_points.SetCount(break_count);
f.Read(&m_break_points[0], sizeof(u64) * break_count);
f.read(reinterpret_cast<char*>(&m_break_points[0]), sizeof(u64) * break_count);
}
if(marked_count > 0)
{
m_marked_points.SetCount(marked_count);
f.Read(&m_marked_points[0], sizeof(u64) * marked_count);
f.read(reinterpret_cast<char*>(&m_marked_points[0]), sizeof(u64) * marked_count);
}
}

View File

@ -150,8 +150,8 @@ public:
void Resume();
void Stop();
void SavePoints(const wxString& path);
void LoadPoints(const wxString& path);
void SavePoints(const std::string& path);
void LoadPoints(const std::string& path);
__forceinline bool IsRunning() const { wxCriticalSectionLocker lock(m_cs_status); return m_status == Running; }
__forceinline bool IsPaused() const { wxCriticalSectionLocker lock(m_cs_status); return m_status == Paused; }

View File

@ -9,18 +9,18 @@
LogWriter ConLog;
LogFrame* ConLogFrame;
wxCriticalSection g_cs_conlog;
std::mutex g_cs_conlog;
static const uint max_item_count = 500;
static const uint buffer_size = 1024 * 64;
struct LogPacket
{
wxString m_prefix;
wxString m_text;
wxString m_colour;
std::string m_prefix;
std::string m_text;
std::string m_colour;
LogPacket(const wxString& prefix, const wxString& text, const wxString& colour)
LogPacket(const std::string& prefix, const std::string& text, const std::string& colour)
: m_prefix(prefix)
, m_text(text)
, m_colour(colour)
@ -41,9 +41,9 @@ struct _LogBuffer : public MTPacketBuffer<LogPacket>
void _push(const LogPacket& data)
{
const u32 sprefix = data.m_prefix.Len();
const u32 stext = data.m_text.Len();
const u32 scolour = data.m_colour.Len();
const u32 sprefix = data.m_prefix.length();
const u32 stext = data.m_text.length();
const u32 scolour = data.m_colour.length();
m_buffer.Reserve(
sizeof(u32) + sprefix +
@ -79,17 +79,20 @@ struct _LogBuffer : public MTPacketBuffer<LogPacket>
const u32& sprefix = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32);
if(sprefix) memcpy(wxStringBuffer(ret.m_prefix, sprefix), &m_buffer[c_get], sprefix);
ret.m_prefix.resize(sprefix);
if(sprefix) memcpy((void*)ret.m_prefix.c_str(), &m_buffer[c_get], sprefix);
c_get += sprefix;
const u32& stext = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32);
if(stext) memcpy(wxStringBuffer(ret.m_text, stext), &m_buffer[c_get], stext);
ret.m_text.resize(stext);
if(stext) memcpy((void*)ret.m_text.c_str(), &m_buffer[c_get], stext);
c_get += stext;
const u32& scolour = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32);
if(scolour) memcpy(wxStringBuffer(ret.m_colour, scolour), &m_buffer[c_get], scolour);
ret.m_colour.resize(scolour);
if(scolour) memcpy((void*)ret.m_colour.c_str(), &m_buffer[c_get], scolour);
c_get += scolour;
m_get = c_get;
@ -103,25 +106,32 @@ LogWriter::LogWriter()
{
if(!m_logfile.Open(_PRGNAME_ ".log", wxFile::write))
{
wxMessageBox("Cann't create log file! (" _PRGNAME_ ".log)", wxMessageBoxCaptionStr, wxICON_ERROR);
#ifndef QT_UI
wxMessageBox("Can't create log file! (" _PRGNAME_ ".log)", wxMessageBoxCaptionStr, wxICON_ERROR);
#endif
}
}
void LogWriter::WriteToLog(wxString prefix, wxString value, wxString colour/*, wxColour bgcolour*/)
void LogWriter::WriteToLog(std::string prefix, std::string value, std::string colour/*, wxColour bgcolour*/)
{
if(ThreadBase* thr = GetCurrentNamedThread())
{
prefix = (prefix.IsEmpty() ? "" : prefix + " : ") + thr->GetThreadName();
prefix = (prefix.empty() ? "" : prefix + " : ") + thr->GetThreadName();
}
if(m_logfile.IsOpened())
m_logfile.Write((prefix.IsEmpty() ? wxString(wxEmptyString) : "[" + prefix + "]: ") + value + "\n");
m_logfile.Write((prefix.empty() ? wxString(wxEmptyString) : std::string("[" + prefix + "]: ") + value + "\n").c_str());
if(!ConLogFrame) return;
wxCriticalSectionLocker lock(g_cs_conlog);
std::lock_guard<std::mutex> lock(g_cs_conlog);
#ifdef QT_UI
// TODO: Use ThreadBase instead, track main thread id
if(QThread::currentThread() == qApp->thread())
#else
if(wxThread::IsMain())
#endif
{
while(LogBuffer.IsBusy()) wxYieldIfNeeded();
}
@ -161,7 +171,7 @@ void LogWriter::Write(const wxString fmt, ...)
va_end(list);
WriteToLog("!", frmt, "White");
WriteToLog("!", frmt.mb_str(), "White");
}
void LogWriter::Error(const wxString fmt, ...)
@ -173,7 +183,7 @@ void LogWriter::Error(const wxString fmt, ...)
va_end(list);
WriteToLog("E", frmt, "Red");
WriteToLog("E", frmt.mb_str(), "Red");
}
void LogWriter::Warning(const wxString fmt, ...)
@ -185,12 +195,12 @@ void LogWriter::Warning(const wxString fmt, ...)
va_end(list);
WriteToLog("W", frmt, "Yellow");
WriteToLog("W", frmt.mb_str(), "Yellow");
}
void LogWriter::SkipLn()
{
WriteToLog(wxEmptyString, wxEmptyString, "Black");
WriteToLog("", "", "Black");
}
BEGIN_EVENT_TABLE(LogFrame, wxPanel)
@ -210,7 +220,7 @@ LogFrame::LogFrame(wxWindow* parent)
s_main.Add(&m_log, 1, wxEXPAND);
SetSizer(&s_main);
Layout();
Show();
ThreadBase::Start();
}
@ -250,9 +260,9 @@ void LogFrame::Task()
const int cur_item = m_log.GetItemCount();
m_log.InsertItem(cur_item, item.m_prefix);
m_log.SetItem(cur_item, 1, item.m_text);
m_log.SetItemTextColour(cur_item, item.m_colour);
m_log.InsertItem(cur_item, item.m_prefix.c_str());
m_log.SetItem(cur_item, 1, item.m_text.c_str());
m_log.SetItemTextColour(cur_item, item.m_colour.c_str());
m_log.SetColumnWidth(0, -1);
m_log.SetColumnWidth(1, -1);

View File

@ -8,10 +8,10 @@ class LogWriter
wxFile m_logfile;
wxColour m_txtcolour;
wxString m_prefix;
wxString m_value;
std::string m_prefix;
std::string m_value;
virtual void WriteToLog(wxString prefix, wxString value, wxString colour);
virtual void WriteToLog(std::string prefix, std::string value, std::string colour);
public:
LogWriter();
@ -38,7 +38,7 @@ private:
virtual void Task();
void OnQuit(wxCloseEvent& event);
DECLARE_EVENT_TABLE();
};

View File

@ -53,9 +53,9 @@ VFSEntrySettingsDialog::VFSEntrySettingsDialog(wxWindow* parent, VFSManagerEntry
Connect(m_btn_select_dev_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectDevPath));
Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnOk));
m_tctrl_dev_path->SetValue(m_entry.device_path.GetPtr());
m_tctrl_path->SetValue(m_entry.path.GetPtr());
m_tctrl_mount->SetValue(m_entry.mount.GetPtr());
m_tctrl_dev_path->SetValue(m_entry.device_path);
m_tctrl_path->SetValue(m_entry.path);
m_tctrl_mount->SetValue(m_entry.mount);
m_ch_type->SetSelection(m_entry.device);
wxCommandEvent ce;
@ -95,9 +95,9 @@ void VFSEntrySettingsDialog::OnSelectDevPath(wxCommandEvent& event)
void VFSEntrySettingsDialog::OnOk(wxCommandEvent& event)
{
m_entry.device_path = m_tctrl_dev_path->GetValue();
m_entry.path = m_tctrl_path->GetValue();
m_entry.mount = m_tctrl_mount->GetValue();
m_entry.device_path = strdup( m_tctrl_dev_path->GetValue().c_str());
m_entry.path = strdup(m_tctrl_path->GetValue().c_str());
m_entry.mount = strdup(m_tctrl_mount->GetValue().c_str());
m_entry.device = (vfsDeviceType)m_ch_type->GetSelection();
EndModal(wxID_OK);
@ -143,9 +143,9 @@ void VFSManagerDialog::UpdateList()
m_list->DeleteAllItems();
for(uint i=0; i<m_entries.GetCount(); ++i)
{
m_list->InsertItem(i, m_entries[i].mount.GetPtr());
m_list->SetItem(i, 1, m_entries[i].path.GetPtr());
m_list->SetItem(i, 2, m_entries[i].device_path.GetPtr());
m_list->InsertItem(i, m_entries[i].mount);
m_list->SetItem(i, 1, m_entries[i].path);
m_list->SetItem(i, 2, m_entries[i].device_path);
m_list->SetItem(i, 3, vfsDeviceTypeNames[m_entries[i].device]);
}
m_list->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);

View File

@ -1,6 +1,6 @@
// This is a generated file.
#define RPCS3_GIT_VERSION "cd3ad0b"
#define RPCS3_GIT_VERSION "d83a9b1"
// If you don't want this file to update/recompile, change to 1.
#define RPCS3_GIT_VERSION_NO_UPDATE 0

View File

@ -2,6 +2,7 @@
#define NOMINMAX
#ifndef QT_UI
#include <wx/string.h>
#include <wx/wx.h>
@ -17,6 +18,7 @@
#include <wx/filepicker.h>
#include <wx/wxprec.h>
#endif
#include <cstdint>