Merge pull request #30 from xsacha/master

Removal of WX dependency and introduction of Qt UI alternative
This commit is contained in:
DHrpcs3 2013-11-28 04:09:49 -08:00
commit 1bc99a3762
33 changed files with 514 additions and 235 deletions

View File

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

View File

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

View File

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

View File

@ -59,7 +59,7 @@ public:
virtual void SetArg(const uint pos, const u64 arg) = 0; virtual void SetArg(const uint pos, const u64 arg) = 0;
void SetId(const u32 id); 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 SetPrio(const u64 prio) { m_prio = prio; }
void SetOffset(const u64 offset) { m_offset = offset; } void SetOffset(const u64 offset) { m_offset = offset; }
void SetExitStatus(const u32 status) { m_exit_status = status; } void SetExitStatus(const u32 status) { m_exit_status = status; }
@ -68,14 +68,14 @@ public:
u32 GetExitStatus() const { return m_exit_status; } u32 GetExitStatus() const { return m_exit_status; }
u64 GetPrio() const { return m_prio; } u64 GetPrio() const { return m_prio; }
wxString GetName() const { return m_name; } std::string GetName() const { return m_name; }
wxString GetFName() const wxString GetFName() const
{ {
return return
wxString::Format("%s[%d] Thread%s", wxString::Format("%s[%d] Thread%s",
GetTypeString().mb_str(), GetTypeString().mb_str(),
m_id, 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); } 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: 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)); new_thread->SetId(Emu.GetIdManager().GetNewID(wxString::Format("%s Thread", new_thread->GetTypeString().mb_str()), new_thread));
m_threads.Add(new_thread); m_threads.Add(new_thread);
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_CREATE_THREAD, new_thread); wxGetApp().SendDbgCommand(DID_CREATE_THREAD, new_thread);
#endif
return *new_thread; return *new_thread;
} }
@ -59,7 +61,9 @@ void CPUThreadManager::RemoveThread(const u32 id)
if(m_threads[i].GetId() != id) continue; if(m_threads[i].GetId() != id) continue;
CPUThread* thr = &m_threads[i]; CPUThread* thr = &m_threads[i];
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_REMOVE_THREAD, thr); wxGetApp().SendDbgCommand(DID_REMOVE_THREAD, thr);
#endif
if(thr->IsAlive()) if(thr->IsAlive())
{ {
thr->Close(); 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 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: protected:

View File

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

View File

@ -19,22 +19,22 @@ enum ArgType
struct Arg struct Arg
{ {
ArrayString string; std::string string;
u32 value; u32 value;
ArgType type; ArgType type;
Arg(const wxString& _string, const u32 _value = 0, const ArgType _type = ARG_ERR) Arg(const wxString& _string, const u32 _value = 0, const ArgType _type = ARG_ERR)
: string(_string) : value(_value)
, value(_value)
, type(_type) , type(_type)
{ {
string = _string.c_str();
} }
}; };
struct SectionInfo struct SectionInfo
{ {
Elf64_Shdr shdr; Elf64_Shdr shdr;
ArrayString name; std::string name;
Array<u8> code; Array<u8> code;
u32 section_num; u32 section_num;
@ -62,25 +62,25 @@ class CompilePPUProgram
{ {
struct Branch struct Branch
{ {
ArrayString m_name; std::string m_name;
s32 m_pos; s32 m_pos;
s32 m_id; s32 m_id;
s32 m_addr; s32 m_addr;
Branch(const wxString& name, s32 pos) Branch(const wxString& name, s32 pos)
: m_name(name) : m_pos(pos)
, m_pos(pos)
, m_id(-1) , m_id(-1)
, m_addr(-1) , m_addr(-1)
{ {
m_name = name.c_str();
} }
Branch(const wxString& name, u32 id, u32 addr) Branch(const wxString& name, u32 id, u32 addr)
: m_name(name) : m_pos(-1)
, m_pos(-1)
, m_id(id) , m_id(id)
, m_addr(addr) , m_addr(addr)
{ {
m_name = name.c_str();
} }
}; };
@ -101,13 +101,13 @@ class CompilePPUProgram
struct SpData struct SpData
{ {
ArrayString m_data; std::string m_data;
u32 m_addr; u32 m_addr;
SpData(const wxString& data, u32 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; break;
case vfsDevice_HDD: case vfsDevice_HDD:
dev = new vfsHDD(entries[i].device_path.GetPtr()); dev = new vfsHDD(entries[i].device_path);
break; break;
default: default:
continue; continue;
} }
wxString mpath = entries[i].path.GetPtr(); wxString mpath = entries[i].path;
mpath.Replace("$(EmulatorDir)", wxGetCwd()); mpath.Replace("$(EmulatorDir)", wxGetCwd());
mpath.Replace("$(GameDir)", vfsDevice::GetRoot(path)); 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) if(is_load)
{ {
new (res + i) VFSManagerEntry(); new (res + i) VFSManagerEntry();
res[i].path = entry_path.LoadValue(wxEmptyString); res[i].path = strdup(entry_path.LoadValue(wxEmptyString).c_str());
res[i].device_path = entry_device_path.LoadValue(wxEmptyString); res[i].device_path = strdup(entry_device_path.LoadValue(wxEmptyString).c_str());
res[i].mount = entry_mount.LoadValue(wxEmptyString); res[i].mount = strdup(entry_mount.LoadValue(wxEmptyString).c_str());
res[i].device = (vfsDeviceType)entry_device.LoadValue(vfsDevice_LocalFile); res[i].device = (vfsDeviceType)entry_device.LoadValue(vfsDevice_LocalFile);
} }
else else
{ {
entry_path.SaveValue(res[i].path.GetPtr()); entry_path.SaveValue(res[i].path);
entry_device_path.SaveValue(res[i].device_path.GetPtr()); entry_device_path.SaveValue(res[i].device_path);
entry_mount.SaveValue(res[i].mount.GetPtr()); entry_mount.SaveValue(res[i].mount);
entry_device.SaveValue(res[i].device); entry_device.SaveValue(res[i].device);
} }
} }

View File

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

View File

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

View File

@ -98,8 +98,8 @@ struct GLFragmentDecompilerThread : public ThreadBase
}; };
} src2; } src2;
wxString main; std::string main;
wxString& m_shader; std::string& m_shader;
GLParamArray& m_parr; GLParamArray& m_parr;
u32 m_addr; u32 m_addr;
u32& m_size; u32& m_size;
@ -108,7 +108,7 @@ struct GLFragmentDecompilerThread : public ThreadBase
u32 m_location; u32 m_location;
u32 m_ctrl; 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") : ThreadBase(false, "Fragment Shader Decompiler Thread")
, m_shader(shader) , m_shader(shader)
, m_parr(parr) , m_parr(parr)
@ -121,17 +121,17 @@ struct GLFragmentDecompilerThread : public ThreadBase
m_size = 0; m_size = 0;
} }
wxString GetMask(); std::string GetMask();
void AddCode(wxString code, bool append_mask = true); void AddCode(std::string code, bool append_mask = true);
wxString AddReg(u32 index, int fp16); std::string AddReg(u32 index, int fp16);
bool HasReg(u32 index, int fp16); bool HasReg(u32 index, int fp16);
wxString AddCond(int fp16); std::string AddCond(int fp16);
wxString AddConst(); std::string AddConst();
wxString AddTex(); std::string AddTex();
template<typename T> wxString GetSRC(T src); template<typename T> std::string GetSRC(T src);
wxString BuildCode(); std::string BuildCode();
virtual void Task(); virtual void Task();
@ -147,7 +147,7 @@ struct GLShaderProgram
GLParamArray parr; GLParamArray parr;
wxString shader; std::string shader;
u32 id; 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; 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.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; 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; 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.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; 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("*** vp data size = %d", rsx_vp.data.GetCount() * 4);
ConLog.Write("*** fp data size = %d", rsx_fp.size); ConLog.Write("*** fp data size = %d", rsx_fp.size);
ConLog.Write("*** vp shader = \n%s", gl_vp.shader.mb_str()); ConLog.Write("*** vp shader = \n%s", gl_vp.shader.c_str());
ConLog.Write("*** fp shader = \n%s", gl_fp.shader.mb_str()); ConLog.Write("*** fp shader = \n%s", gl_fp.shader.c_str());
new_buf.prog_id = prog.id; new_buf.prog_id = prog.id;
new_buf.vp_id = gl_vp.id; new_buf.vp_id = gl_vp.id;
@ -120,8 +120,8 @@ void GLProgramBuffer::Clear()
m_buf[i].fp_data.Clear(); m_buf[i].fp_data.Clear();
m_buf[i].vp_data.Clear(); m_buf[i].vp_data.Clear();
m_buf[i].vp_shader.Clear(); m_buf[i].vp_shader.clear();
m_buf[i].fp_shader.Clear(); m_buf[i].fp_shader.clear();
} }
m_buf.Clear(); m_buf.Clear();

View File

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

View File

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

View File

@ -35,7 +35,7 @@ wxString GLVertexDecompilerThread::GetScaMask()
wxString GLVertexDecompilerThread::GetDST(bool isSca) wxString GLVertexDecompilerThread::GetDST(bool isSca)
{ {
static const wxString reg_table[] = static const std::string reg_table[] =
{ {
"gl_Position", "gl_Position",
"col0", "col1", "col0", "col1",
@ -54,7 +54,7 @@ wxString GLVertexDecompilerThread::GetDST(bool isSca)
break; break;
case 0x1f: 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; break;
default: default:
@ -75,7 +75,7 @@ wxString GLVertexDecompilerThread::GetDST(bool isSca)
wxString GLVertexDecompilerThread::GetSRC(const u32 n, 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_pos", "in_weight", "in_normal",
"in_col0", "in_col1", "in_col0", "in_col1",
@ -90,7 +90,7 @@ wxString GLVertexDecompilerThread::GetSRC(const u32 n, bool isSca)
switch(src[n].reg_type) switch(src[n].reg_type)
{ {
case 1: //temp 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; break;
case 2: //input case 2: //input
if(d1.input_src < WXSIZEOF(reg_table)) if(d1.input_src < WXSIZEOF(reg_table))
@ -104,7 +104,7 @@ wxString GLVertexDecompilerThread::GetSRC(const u32 n, bool isSca)
} }
break; break;
case 3: //const 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; break;
default: default:

View File

@ -329,35 +329,35 @@ bool MemoryBlockLE::Write128(const u64 addr, const u128 value)
} }
//NullMemoryBlock //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); ConLog.Error("Read8 from null block: [%08llx]", addr);
Emu.Pause(); Emu.Pause();
return false; 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); ConLog.Error("Read16 from null block: [%08llx]", addr);
Emu.Pause(); Emu.Pause();
return false; 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); ConLog.Error("Read32 from null block: [%08llx]", addr);
Emu.Pause(); Emu.Pause();
return false; 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); ConLog.Error("Read64 from null block: [%08llx]", addr);
Emu.Pause(); Emu.Pause();
return false; 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); ConLog.Error("Read128 from null block: [%08llx]", addr);
Emu.Pause(); 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.SetPrio(prio);
new_thread.SetStackSize(stacksize); new_thread.SetStackSize(stacksize);
//new_thread.flags = flags; //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.Run();
new_thread.Exec(); new_thread.Exec();

View File

@ -35,18 +35,18 @@ u32 LoadSpuImage(vfsStream& stream)
//156 //156
int sys_spu_image_open(mem_ptr_t<sys_spu_image> img, u32 path_addr) int sys_spu_image_open(mem_ptr_t<sys_spu_image> img, u32 path_addr)
{ {
const wxString& path = Memory.ReadString(path_addr); 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.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)) if(!img.IsGood() || !Memory.IsGoodAddr(path_addr))
{ {
return CELL_EFAULT; return CELL_EFAULT;
} }
vfsFile f(path); vfsFile f(path.c_str());
if(!f.IsOpened()) 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; 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; 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 a1 = arg->arg1;
u64 a2 = arg->arg2; u64 a2 = arg->arg2;
u64 a3 = arg->arg3; 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("New SPU Thread:");
ConLog.Write("entry = 0x%x", entry); 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("a1 = 0x%x", a1);
ConLog.Write("a2 = 0x%x", a2); ConLog.Write("a2 = 0x%x", a2);
ConLog.Write("a3 = 0x%x", a3); 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.type=%d", attr->type.ToLE());
ConLog.Write("*** attr.option.ct=%d", attr->option.ct.ToLE()); ConLog.Write("*** attr.option.ct=%d", attr->option.ct.ToLE());
const wxString& name = Memory.ReadString(attr->name_addr, attr->name_len); const std::string& name = Memory.ReadString(attr->name_addr, attr->name_len).mb_str();
ConLog.Write("*** name='%s'", name.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; return CELL_OK;
} }

View File

@ -6,9 +6,11 @@
#include "Emu/Cell/PPUThread.h" #include "Emu/Cell/PPUThread.h"
#include "Emu/Cell/SPUThread.h" #include "Emu/Cell/SPUThread.h"
#include "Emu/Cell/PPUInstrTable.h" #include "Emu/Cell/PPUInstrTable.h"
#include <cstdlib>
#include <fstream>
using namespace PPU_instr; using namespace PPU_instr;
static const wxString& BreakPointsDBName = "BreakPoints.dat"; static const std::string& BreakPointsDBName = "BreakPoints.dat";
static const u16 bpdb_version = 0x1000; static const u16 bpdb_version = 0x1000;
ModuleInitializer::ModuleInitializer() ModuleInitializer::ModuleInitializer()
@ -234,7 +236,9 @@ void Emulator::Load()
wxCriticalSectionLocker lock(m_cs_status); wxCriticalSectionLocker lock(m_cs_status);
m_status = Ready; m_status = Ready;
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_READY_EMU); wxGetApp().SendDbgCommand(DID_READY_EMU);
#endif
} }
void Emulator::Run() void Emulator::Run()
@ -251,8 +255,9 @@ void Emulator::Run()
Resume(); Resume();
return; return;
} }
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_START_EMU); wxGetApp().SendDbgCommand(DID_START_EMU);
#endif
wxCriticalSectionLocker lock(m_cs_status); wxCriticalSectionLocker lock(m_cs_status);
//ConLog.Write("run..."); //ConLog.Write("run...");
@ -265,32 +270,42 @@ void Emulator::Run()
//m_memory_viewer->ShowPC(); //m_memory_viewer->ShowPC();
GetCPU().Exec(); GetCPU().Exec();
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_STARTED_EMU); wxGetApp().SendDbgCommand(DID_STARTED_EMU);
#endif
} }
void Emulator::Pause() void Emulator::Pause()
{ {
if(!IsRunning()) return; if(!IsRunning()) return;
//ConLog.Write("pause..."); //ConLog.Write("pause...");
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_PAUSE_EMU); wxGetApp().SendDbgCommand(DID_PAUSE_EMU);
#endif
wxCriticalSectionLocker lock(m_cs_status); wxCriticalSectionLocker lock(m_cs_status);
m_status = Paused; m_status = Paused;
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_PAUSED_EMU); wxGetApp().SendDbgCommand(DID_PAUSED_EMU);
#endif
} }
void Emulator::Resume() void Emulator::Resume()
{ {
if(!IsPaused()) return; if(!IsPaused()) return;
//ConLog.Write("resume..."); //ConLog.Write("resume...");
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_RESUME_EMU); wxGetApp().SendDbgCommand(DID_RESUME_EMU);
#endif
wxCriticalSectionLocker lock(m_cs_status); wxCriticalSectionLocker lock(m_cs_status);
m_status = Running; m_status = Running;
CheckStatus(); CheckStatus();
if(IsRunning() && Ini.CPUDecoderMode.GetValue() != 1) GetCPU().Exec(); if(IsRunning() && Ini.CPUDecoderMode.GetValue() != 1) GetCPU().Exec();
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_RESUMED_EMU); wxGetApp().SendDbgCommand(DID_RESUMED_EMU);
#endif
} }
void Emulator::Stop() void Emulator::Stop()
@ -298,7 +313,9 @@ void Emulator::Stop()
if(IsStopped()) return; if(IsStopped()) return;
//ConLog.Write("shutdown..."); //ConLog.Write("shutdown...");
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_STOP_EMU); wxGetApp().SendDbgCommand(DID_STOP_EMU);
#endif
{ {
wxCriticalSectionLocker lock(m_cs_status); wxCriticalSectionLocker lock(m_cs_status);
m_status = Stopped; m_status = Stopped;
@ -326,60 +343,63 @@ void Emulator::Stop()
Memory.Close(); Memory.Close();
//if(m_memory_viewer && m_memory_viewer->IsShown()) m_memory_viewer->Hide(); //if(m_memory_viewer && m_memory_viewer->IsShown()) m_memory_viewer->Hide();
#ifndef QT_UI
wxGetApp().SendDbgCommand(DID_STOPPED_EMU); 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 break_count = m_break_points.GetCount();
u32 marked_count = m_marked_points.GetCount(); u32 marked_count = m_marked_points.GetCount();
f.Write(&bpdb_version, sizeof(u16)); f << bpdb_version << break_count << marked_count;
f.Write(&break_count, sizeof(u32));
f.Write(&marked_count, sizeof(u32));
if(break_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) 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; struct stat buf;
if (!stat(path.c_str(), &buf))
wxFile f(path); 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; u32 break_count, marked_count;
u16 version; u16 version;
f.Read(&version, sizeof(u16)); f >> version >> break_count >> marked_count;
f.Read(&break_count, sizeof(u32));
f.Read(&marked_count, sizeof(u32));
if(version != bpdb_version || 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; return;
} }
if(break_count > 0) if(break_count > 0)
{ {
m_break_points.SetCount(break_count); 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) if(marked_count > 0)
{ {
m_marked_points.SetCount(marked_count); 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 Resume();
void Stop(); void Stop();
void SavePoints(const wxString& path); void SavePoints(const std::string& path);
void LoadPoints(const wxString& path); void LoadPoints(const std::string& path);
__forceinline bool IsRunning() const { wxCriticalSectionLocker lock(m_cs_status); return m_status == Running; } __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; } __forceinline bool IsPaused() const { wxCriticalSectionLocker lock(m_cs_status); return m_status == Paused; }

View File

@ -9,18 +9,18 @@
LogWriter ConLog; LogWriter ConLog;
LogFrame* ConLogFrame; LogFrame* ConLogFrame;
wxCriticalSection g_cs_conlog; std::mutex g_cs_conlog;
static const uint max_item_count = 500; static const uint max_item_count = 500;
static const uint buffer_size = 1024 * 64; static const uint buffer_size = 1024 * 64;
struct LogPacket struct LogPacket
{ {
wxString m_prefix; std::string m_prefix;
wxString m_text; std::string m_text;
wxString m_colour; 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_prefix(prefix)
, m_text(text) , m_text(text)
, m_colour(colour) , m_colour(colour)
@ -41,9 +41,9 @@ struct _LogBuffer : public MTPacketBuffer<LogPacket>
void _push(const LogPacket& data) void _push(const LogPacket& data)
{ {
const u32 sprefix = data.m_prefix.Len(); const u32 sprefix = data.m_prefix.length();
const u32 stext = data.m_text.Len(); const u32 stext = data.m_text.length();
const u32 scolour = data.m_colour.Len(); const u32 scolour = data.m_colour.length();
m_buffer.Reserve( m_buffer.Reserve(
sizeof(u32) + sprefix + sizeof(u32) + sprefix +
@ -79,17 +79,20 @@ struct _LogBuffer : public MTPacketBuffer<LogPacket>
const u32& sprefix = *(u32*)&m_buffer[c_get]; const u32& sprefix = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32); 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; c_get += sprefix;
const u32& stext = *(u32*)&m_buffer[c_get]; const u32& stext = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32); 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; c_get += stext;
const u32& scolour = *(u32*)&m_buffer[c_get]; const u32& scolour = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32); 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; c_get += scolour;
m_get = c_get; m_get = c_get;
@ -103,25 +106,32 @@ LogWriter::LogWriter()
{ {
if(!m_logfile.Open(_PRGNAME_ ".log", wxFile::write)) 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()) if(ThreadBase* thr = GetCurrentNamedThread())
{ {
prefix = (prefix.IsEmpty() ? "" : prefix + " : ") + thr->GetThreadName(); prefix = (prefix.empty() ? "" : prefix + " : ") + thr->GetThreadName();
} }
if(m_logfile.IsOpened()) 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; 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()) if(wxThread::IsMain())
#endif
{ {
while(LogBuffer.IsBusy()) wxYieldIfNeeded(); while(LogBuffer.IsBusy()) wxYieldIfNeeded();
} }
@ -161,7 +171,7 @@ void LogWriter::Write(const wxString fmt, ...)
va_end(list); va_end(list);
WriteToLog("!", frmt, "White"); WriteToLog("!", frmt.mb_str(), "White");
} }
void LogWriter::Error(const wxString fmt, ...) void LogWriter::Error(const wxString fmt, ...)
@ -173,7 +183,7 @@ void LogWriter::Error(const wxString fmt, ...)
va_end(list); va_end(list);
WriteToLog("E", frmt, "Red"); WriteToLog("E", frmt.mb_str(), "Red");
} }
void LogWriter::Warning(const wxString fmt, ...) void LogWriter::Warning(const wxString fmt, ...)
@ -185,12 +195,12 @@ void LogWriter::Warning(const wxString fmt, ...)
va_end(list); va_end(list);
WriteToLog("W", frmt, "Yellow"); WriteToLog("W", frmt.mb_str(), "Yellow");
} }
void LogWriter::SkipLn() void LogWriter::SkipLn()
{ {
WriteToLog(wxEmptyString, wxEmptyString, "Black"); WriteToLog("", "", "Black");
} }
BEGIN_EVENT_TABLE(LogFrame, wxPanel) BEGIN_EVENT_TABLE(LogFrame, wxPanel)
@ -210,7 +220,7 @@ LogFrame::LogFrame(wxWindow* parent)
s_main.Add(&m_log, 1, wxEXPAND); s_main.Add(&m_log, 1, wxEXPAND);
SetSizer(&s_main); SetSizer(&s_main);
Layout(); Layout();
Show(); Show();
ThreadBase::Start(); ThreadBase::Start();
} }
@ -250,9 +260,9 @@ void LogFrame::Task()
const int cur_item = m_log.GetItemCount(); const int cur_item = m_log.GetItemCount();
m_log.InsertItem(cur_item, item.m_prefix); m_log.InsertItem(cur_item, item.m_prefix.c_str());
m_log.SetItem(cur_item, 1, item.m_text); m_log.SetItem(cur_item, 1, item.m_text.c_str());
m_log.SetItemTextColour(cur_item, item.m_colour); m_log.SetItemTextColour(cur_item, item.m_colour.c_str());
m_log.SetColumnWidth(0, -1); m_log.SetColumnWidth(0, -1);
m_log.SetColumnWidth(1, -1); m_log.SetColumnWidth(1, -1);

View File

@ -8,10 +8,10 @@ class LogWriter
wxFile m_logfile; wxFile m_logfile;
wxColour m_txtcolour; wxColour m_txtcolour;
wxString m_prefix; std::string m_prefix;
wxString m_value; 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: public:
LogWriter(); LogWriter();
@ -38,7 +38,7 @@ private:
virtual void Task(); virtual void Task();
void OnQuit(wxCloseEvent& event); void OnQuit(wxCloseEvent& event);
DECLARE_EVENT_TABLE(); 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(m_btn_select_dev_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectDevPath));
Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnOk)); Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnOk));
m_tctrl_dev_path->SetValue(m_entry.device_path.GetPtr()); m_tctrl_dev_path->SetValue(m_entry.device_path);
m_tctrl_path->SetValue(m_entry.path.GetPtr()); m_tctrl_path->SetValue(m_entry.path);
m_tctrl_mount->SetValue(m_entry.mount.GetPtr()); m_tctrl_mount->SetValue(m_entry.mount);
m_ch_type->SetSelection(m_entry.device); m_ch_type->SetSelection(m_entry.device);
wxCommandEvent ce; wxCommandEvent ce;
@ -95,9 +95,9 @@ void VFSEntrySettingsDialog::OnSelectDevPath(wxCommandEvent& event)
void VFSEntrySettingsDialog::OnOk(wxCommandEvent& event) void VFSEntrySettingsDialog::OnOk(wxCommandEvent& event)
{ {
m_entry.device_path = m_tctrl_dev_path->GetValue(); m_entry.device_path = strdup( m_tctrl_dev_path->GetValue().c_str());
m_entry.path = m_tctrl_path->GetValue(); m_entry.path = strdup(m_tctrl_path->GetValue().c_str());
m_entry.mount = m_tctrl_mount->GetValue(); m_entry.mount = strdup(m_tctrl_mount->GetValue().c_str());
m_entry.device = (vfsDeviceType)m_ch_type->GetSelection(); m_entry.device = (vfsDeviceType)m_ch_type->GetSelection();
EndModal(wxID_OK); EndModal(wxID_OK);
@ -143,9 +143,9 @@ void VFSManagerDialog::UpdateList()
m_list->DeleteAllItems(); m_list->DeleteAllItems();
for(uint i=0; i<m_entries.GetCount(); ++i) for(uint i=0; i<m_entries.GetCount(); ++i)
{ {
m_list->InsertItem(i, m_entries[i].mount.GetPtr()); m_list->InsertItem(i, m_entries[i].mount);
m_list->SetItem(i, 1, m_entries[i].path.GetPtr()); m_list->SetItem(i, 1, m_entries[i].path);
m_list->SetItem(i, 2, m_entries[i].device_path.GetPtr()); m_list->SetItem(i, 2, m_entries[i].device_path);
m_list->SetItem(i, 3, vfsDeviceTypeNames[m_entries[i].device]); m_list->SetItem(i, 3, vfsDeviceTypeNames[m_entries[i].device]);
} }
m_list->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); m_list->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);

View File

@ -1,6 +1,6 @@
// This is a generated file. // 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. // If you don't want this file to update/recompile, change to 1.
#define RPCS3_GIT_VERSION_NO_UPDATE 0 #define RPCS3_GIT_VERSION_NO_UPDATE 0

View File

@ -0,0 +1,3 @@
# P is project dir, B is build dir
P = $$PWD/..
B = $$shadowed($$PWD)

View File

@ -0,0 +1,90 @@
#include "glviewer.h"
#include <QQuickWindow>
#include <QOpenGLContext>
#include <QSGSimpleTextureNode>
#include <QCoreApplication>
GLViewer::GLViewer(QQuickItem* parent)
: QQuickItem(parent),
m_timerID(0),
m_fbo(0)
{
this->setFlag(QQuickItem::ItemHasContents);
}
GLViewer::~GLViewer()
{
this->cleanup();
}
void GLViewer::timerEvent(QTimerEvent* evt)
{
if (evt && evt->timerId() == m_timerID)
this->update();
}
QSGNode* GLViewer::updatePaintNode(QSGNode* node, UpdatePaintNodeData* data)
{
QSGSimpleTextureNode* textureNode = static_cast<QSGSimpleTextureNode*>(node);
if (!textureNode)
textureNode = new QSGSimpleTextureNode();
// Push Qt state.
glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
glPushAttrib(GL_ALL_ATTRIB_BITS);
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glShadeModel(GL_FLAT);
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
glDisable(GL_STENCIL_TEST);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
delete m_fbo;
m_fbo = 0;
int width = this->width();
int height = this->height();
if (width && height) {
m_fbo = new QOpenGLFramebufferObject(width, height);
textureNode->setTexture(this->window()->createTextureFromId(m_fbo->texture(), m_fbo->size()));
}
else
{
textureNode->setTexture(this->window()->createTextureFromId(0, QSize(0,0)));
}
textureNode->setRect(this->boundingRect());
if (m_fbo) {
m_fbo->bind();
}
// Restore (pop) Qt state.
glMatrixMode(GL_TEXTURE);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopAttrib();
glPopClientAttrib();
if (!m_timerID)
m_timerID = this->startTimer(16);
return textureNode;
}
void GLViewer::cleanup() {
this->killTimer(m_timerID);
m_timerID = 0;
if (m_fbo) {
delete m_fbo;
m_fbo = 0;
}
}

23
rpcs3/rpcs3qt/glviewer.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include <QQuickItem>
#include <QOpenGLFramebufferObject>
class GLViewer : public QQuickItem
{
Q_OBJECT
public:
GLViewer(QQuickItem* parent = 0);
virtual ~GLViewer();
protected:
QSGNode* updatePaintNode(QSGNode* old, UpdatePaintNodeData* data);
void timerEvent(QTimerEvent* evt);
private slots:
void cleanup();
private:
int m_timerID;
QOpenGLFramebufferObject* m_fbo;
};

16
rpcs3/rpcs3qt/main.cpp Normal file
View File

@ -0,0 +1,16 @@
// Qt5.1+ frontend implementation for rpcs3. Known to work on Windows, Linux, Mac
// by Sacha Refshauge
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "glviewer.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
qmlRegisterType<GLViewer>("GLViewer", 1, 0, "GLViewer");
QQmlApplicationEngine engine(QUrl("qrc:/qml/main.qml"));
return app.exec();
Q_UNUSED(engine)
}

5
rpcs3/rpcs3qt/qml.qrc Normal file
View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>qml/main.qml</file>
</qresource>
</RCC>

View File

@ -0,0 +1,62 @@
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0
import GLViewer 1.0
ApplicationWindow {
visible: true
title: qsTr("RPCS3 Qt")
width: 500
height: 500
menuBar: MenuBar {
Menu {
title: qsTr("&Boot")
MenuItem { text: qsTr("&Boot Game...") }
MenuItem { text: qsTr("&Install PKG") }
MenuSeparator {}
MenuItem { text: qsTr("Boot &ELF") }
MenuItem { text: qsTr("Boot &SELF") }
MenuSeparator {}
MenuItem { text: qsTr("E\&xit"); onTriggered: Qt.quit() }
}
Menu {
title: qsTr("&System")
MenuItem { text: qsTr("&Pause") }
MenuItem { text: qsTr("&Stop") }
MenuSeparator {}
MenuItem { text: qsTr("Send '&Open System Menu' command") }
MenuItem { text: qsTr("Send 'E&xit' command") }
}
Menu {
title: qsTr("&Config")
MenuItem { text: qsTr("&Settings") }
MenuSeparator {}
MenuItem { text: qsTr("Virtual &File System Manager") }
MenuItem { text: qsTr("Virtual &HDD Manager") }
}
Menu {
title: qsTr("&Tools")
MenuItem { text: qsTr("&ELF Compiler") }
MenuItem { text: qsTr("&Memory Viewer") }
}
Menu {
title: qsTr("&Help")
MenuItem { text: qsTr("&About...") }
}
}
GLViewer {
anchors.fill: parent
Rectangle {
color: Qt.rgba(0, 0.5, 0.35);
height: Math.round(parent.height / 2)
width: height
radius: width
anchors.centerIn: parent
Text {
anchors.centerIn: parent
font.pixelSize: parent.height / 2
text: "Qt"
}
}
}
}

19
rpcs3/rpcs3qt/rpcs3qt.pro Normal file
View File

@ -0,0 +1,19 @@
# Qt5.1+ project for rpcs3. Works on Windows, Linux and Mac OSX
QT += gui opengl quick
CONFIG += c++11
# Qt UI
SOURCES += $$P/rpcs3qt/*.cpp
HEADERS += $$P/rpcs3qt/*.h
# RPCS3
HEADERS += $$P/stdafx.h
INCLUDEPATH += $$P $$P/..
DEFINES += QT_UI
# Installation path
# target.path =
OTHER_FILES += $$P/rpcs3qt/qml/*
RESOURCES += $$P/rpcs3qt/qml.qrc

View File

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