diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp new file mode 100644 index 0000000000..51ed10c3e6 --- /dev/null +++ b/Utilities/StrFmt.cpp @@ -0,0 +1,63 @@ +#include "stdafx.h" +#include "StrFmt.h" + +//wrapper to deal with advance sprintf formating options with automatic length finding +//can't take strings by reference because of "va_start", so overload it with char * +std::string fmt::FormatV(const char *fmt, va_list args) +{ + int length = 256; + std::string str; + + for (;;) + { + std::vector buffptr(length); + size_t printlen = vsnprintf(buffptr.data(), length, fmt, args); + if (printlen >= 0 && printlen < length) + { + str = std::string(buffptr.data(), printlen); + break; + } + length *= 2; + } + return str; +} + +std::string fmt::FormatV(std::string fmt, va_list args) +{ + std::string str = FormatV(fmt.c_str(), args); + return str; +} + +//convert a wxString to a std::string encoded in utf8 +//CAUTION, only use this to interface with wxWidgets classes +std::string fmt::ToUTF8(const wxString& right) +{ + auto ret = std::string(((const char *) right.utf8_str())); + return ret; +} + +//convert a std::string encoded in utf8 to a wxString +//CAUTION, only use this to interface with wxWidgets classes +wxString fmt::FromUTF8(const std::string& right) +{ + auto ret = wxString::FromUTF8(right.c_str()); + return ret; +} + +//TODO: remove this after every snippet that uses it is gone +//WARNING: not fully compatible with CmpNoCase from wxString +int fmt::CmpNoCase(const std::string& a, const std::string& b) +{ + if (a.length() != b.length()) + { + return -1; + } + else + { + return std::equal(a.begin(), + a.end(), + b.begin(), + [](const char& a, const char& b){return tolower(a) == tolower(b); }) + ? 0 : -1; + } +} \ No newline at end of file diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h new file mode 100644 index 0000000000..2338ea7d07 --- /dev/null +++ b/Utilities/StrFmt.h @@ -0,0 +1,117 @@ +#pragma once +#include +#include +#include +#include + +#if defined(_MSC_VER) +#define snprintf _snprintf +#endif + +namespace fmt{ + using std::string; + using std::ostream; + using std::ostringstream; + + struct empty_t{}; + + //static const string placeholder = "???"; + + // write `fmt` from `pos` to the first occurence of `fmt::placeholder` to + // the stream `os`. Then write `arg` to to the stream. If there's no + // `fmt::placeholder` after `pos` everything in `fmt` after pos is written + // to `os`. Then `arg` is written to `os` after appending a space character + template + empty_t write(const string &fmt, ostream &os, string::size_type &pos, T &&arg) + { + string::size_type ins = fmt.find(/*placeholder*/"???", pos); + + if (ins == string::npos) + { + os.write(fmt.data() + pos, fmt.size() - pos); + os << ' ' << arg; + + pos = fmt.size(); + } + else + { + os.write(fmt.data() + pos, ins - pos); + os << arg; + + pos = ins + placeholder.size(); + } + return{}; + } + + // typesafe version of a sprintf-like function. Returns the printed to + // string. To mark positions where the arguments are supposed to be + // inserted use `fmt::placeholder`. If there's not enough placeholders + // the rest of the arguments are appended at the end, seperated by spaces + template + string SFormat(const string &fmt, Args&& ... parameters) + { + ostringstream os; + string::size_type pos = 0; + std::initializer_list { write(fmt, os, pos, parameters)... }; + + if (!fmt.empty()) + { + os.write(fmt.data() + pos, fmt.size() - pos); + } + + string result = os.str(); + return result; + } + + //small wrapper used to deal with bitfields + template + T by_value(T x) { return x; } + + //wrapper to deal with advance sprintf formating options with automatic length finding + //can't take strings by reference because of "va_start", so overload it with char * + string FormatV(const char *fmt, va_list args); + + string FormatV(string fmt, va_list args); + + //wrapper to deal with advance sprintf formating options with automatic length finding + template + string Format(const string &fmt, Args&& ... parameters) + { + int length = 256; + string str; + + for (;;) + { + std::vector buffptr(length); + size_t printlen = snprintf(buffptr.data(), length, fmt.c_str(), std::forward(parameters)...); + if (printlen >= 0 && printlen < length) + { + str = string(buffptr.data(), printlen); + break; + } + length *= 2; + } + return str; + } + + //TODO:remove + //fmt alias for FormatV unused at the moment + template + auto fmt(Args&&... args) -> decltype(FormatV(std::forward(parameters)...)) + { + return FormatV(std::forward(args)...); + } + + //convert a wxString to a std::string encoded in utf8 + //CAUTION, only use this to interface with wxWidgets classes + std::string ToUTF8(const wxString& right); + + //convert a std::string encoded in utf8 to a wxString + //CAUTION, only use this to interface with wxWidgets classes + wxString FromUTF8(const string& right); + + //TODO: remove this after every snippet that uses it is gone + //WARNING: not fully compatible with CmpNoCase from wxString + int CmpNoCase(const std::string& a, const std::string& b); + +} diff --git a/rpcs3/Crypto/key_vault.h b/rpcs3/Crypto/key_vault.h index 3fbd2b5ff1..411c592fe5 100644 --- a/rpcs3/Crypto/key_vault.h +++ b/rpcs3/Crypto/key_vault.h @@ -22,7 +22,7 @@ struct SELF_KEY { u8 priv[0x15]; u32 curve_type; - SELF_KEY(u64 ver, u16 rev, u32 type, wxString e, wxString r, wxString pb, wxString pr, u32 ct) + SELF_KEY(u64 ver, u16 rev, u32 type, const std::string& e, const std::string& r, const std::string& pb, const std::string& pr, u32 ct) { version = ver; revision = rev; diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index dd04f2d754..cb678b28e8 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -396,7 +396,7 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32) wxFile e(elf.c_str(), wxFile::write); if(!e.IsOpened()) { - ConLog.Error("Could not create ELF file! (%s)", wxString(elf).wx_str()); + ConLog.Error("Could not create ELF file! (%s)", elf.c_str()); return false; } @@ -508,18 +508,18 @@ bool SELFDecrypter::GetKeyFromRap(u8 *content_id, u8 *npdrm_key) memset(rap_key, 0, 0x10); // Try to find a matching RAP file under dev_usb000. - wxString ci_str(content_id); - wxString rap_path(wxGetCwd() + "/dev_usb000/" + ci_str + ".rap"); + std::string ci_str((const char *)content_id); + std::string rap_path(fmt::ToUTF8(wxGetCwd()) + "/dev_usb000/" + ci_str + ".rap"); // Check if we have a valid RAP file. - if (!wxFile::Exists(rap_path)) + if (!wxFile::Exists(fmt::FromUTF8(rap_path))) { ConLog.Error("This application requires a valid RAP file for decryption!"); return false; } // Open the RAP file and read the key. - wxFile rap_file(rap_path, wxFile::read); + wxFile rap_file(fmt::FromUTF8(rap_path), wxFile::read); if (!rap_file.IsOpened()) { @@ -527,7 +527,7 @@ bool SELFDecrypter::GetKeyFromRap(u8 *content_id, u8 *npdrm_key) return false; } - ConLog.Write("Loading RAP file %s", ci_str.wc_str() + wchar_t(".rap")); + ConLog.Write("Loading RAP file %s", (ci_str + ".rap").c_str()); rap_file.Read(rap_key, 0x10); rap_file.Close(); @@ -573,11 +573,11 @@ bool IsSelfElf32(const std::string& path) bool CheckDebugSelf(const std::string& self, const std::string& elf) { // Open the SELF file. - wxFile s(self.c_str()); + wxFile s(fmt::FromUTF8(self)); if(!s.IsOpened()) { - ConLog.Error("Could not open SELF file! (%s)", wxString(self).wx_str()); + ConLog.Error("Could not open SELF file! (%s)", self.c_str()); return false; } @@ -601,10 +601,10 @@ bool CheckDebugSelf(const std::string& self, const std::string& elf) s.Seek(elf_offset); // Write the real ELF file back. - wxFile e(elf.c_str(), wxFile::write); + wxFile e(fmt::FromUTF8(elf), wxFile::write); if(!e.IsOpened()) { - ConLog.Error("Could not create ELF file! (%s)", wxString(elf).wx_str()); + ConLog.Error("Could not create ELF file! (%s)", elf.c_str()); return false; } diff --git a/rpcs3/Crypto/unself.h b/rpcs3/Crypto/unself.h index df721a588a..9d16fc2d6a 100644 --- a/rpcs3/Crypto/unself.h +++ b/rpcs3/Crypto/unself.h @@ -200,51 +200,51 @@ struct ControlInfo { if (size == 0x30) { - wxString digest_str; + std::string digest_str; for (int i = 0; i < 20; i++) - digest_str += wxString::Format("%02x", file_digest_30.digest[i]); + digest_str += fmt::Format("%02x", file_digest_30.digest[i]); - ConLog.Write("Digest: %s", digest_str.wc_str()); + ConLog.Write("Digest: %s", digest_str.c_str()); ConLog.Write("Unknown: 0x%llx", file_digest_30.unknown); } else if (size == 0x40) { - wxString digest_str1; - wxString digest_str2; + std::string digest_str1; + std::string digest_str2; for (int i = 0; i < 20; i++) { - digest_str1 += wxString::Format("%02x", file_digest_40.digest1[i]); - digest_str2 += wxString::Format("%02x", file_digest_40.digest2[i]); + digest_str1 += fmt::Format("%02x", file_digest_40.digest1[i]); + digest_str2 += fmt::Format("%02x", file_digest_40.digest2[i]); } - ConLog.Write("Digest1: %s", digest_str1.wc_str()); - ConLog.Write("Digest2: %s", digest_str2.wc_str()); + ConLog.Write("Digest1: %s", digest_str1.c_str()); + ConLog.Write("Digest2: %s", digest_str2.c_str()); ConLog.Write("Unknown: 0x%llx", file_digest_40.unknown); } } else if (type == 3) { - wxString contentid_str; - wxString digest_str; - wxString invdigest_str; - wxString xordigest_str; + std::string contentid_str; + std::string digest_str; + std::string invdigest_str; + std::string xordigest_str; for (int i = 0; i < 48; i++) - contentid_str += wxString::Format("%02x", npdrm.content_id[i]); + contentid_str += fmt::Format("%02x", npdrm.content_id[i]); for (int i = 0; i < 16; i++) { - digest_str += wxString::Format("%02x", npdrm.digest[i]); - invdigest_str += wxString::Format("%02x", npdrm.invdigest[i]); - xordigest_str += wxString::Format("%02x", npdrm.xordigest[i]); + digest_str += fmt::Format("%02x", npdrm.digest[i]); + invdigest_str += fmt::Format("%02x", npdrm.invdigest[i]); + xordigest_str += fmt::Format("%02x", npdrm.xordigest[i]); } ConLog.Write("Magic: 0x%08x", npdrm.magic); ConLog.Write("Unknown1: 0x%08x", npdrm.unknown1); ConLog.Write("License: 0x%08x", npdrm.license); ConLog.Write("Type: 0x%08x", npdrm.type); - ConLog.Write("ContentID: %s", contentid_str.wc_str()); - ConLog.Write("Digest: %s", digest_str.wc_str()); - ConLog.Write("Inverse digest: %s", invdigest_str.wc_str()); - ConLog.Write("XOR digest: %s", xordigest_str.wc_str()); + ConLog.Write("ContentID: %s", contentid_str.c_str()); + ConLog.Write("Digest: %s", digest_str.c_str()); + ConLog.Write("Inverse digest: %s", invdigest_str.c_str()); + ConLog.Write("XOR digest: %s", xordigest_str.c_str()); ConLog.Write("Unknown2: 0x%llx", npdrm.unknown2); ConLog.Write("Unknown3: 0x%llx", npdrm.unknown3); } @@ -269,22 +269,22 @@ struct MetadataInfo void Show() { - wxString key_str; - wxString key_pad_str; - wxString iv_str; - wxString iv_pad_str; + std::string key_str; + std::string key_pad_str; + std::string iv_str; + std::string iv_pad_str; for (int i = 0; i < 0x10; i++) { - key_str += wxString::Format("%02x", key[i]); - key_pad_str += wxString::Format("%02x", key_pad[i]); - iv_str += wxString::Format("%02x", iv[i]); - iv_pad_str += wxString::Format("%02x", iv_pad[i]); + key_str += fmt::Format("%02x", key[i]); + key_pad_str += fmt::Format("%02x", key_pad[i]); + iv_str += fmt::Format("%02x", iv[i]); + iv_pad_str += fmt::Format("%02x", iv_pad[i]); } - ConLog.Write("Key: %s", key_str.wc_str()); - ConLog.Write("Key pad: %s", key_pad_str.wc_str()); - ConLog.Write("IV: %s", iv_str.wc_str()); - ConLog.Write("IV pad: %s", iv_pad_str.wc_str()); + ConLog.Write("Key: %s", key_str.c_str()); + ConLog.Write("Key pad: %s", key_pad_str.c_str()); + ConLog.Write("IV: %s", iv_str.c_str()); + ConLog.Write("IV pad: %s", iv_pad_str.c_str()); } }; diff --git a/rpcs3/Emu/ARMv7/ARMv7DisAsm.h b/rpcs3/Emu/ARMv7/ARMv7DisAsm.h index 1998a40d46..1ccba0dc1b 100644 --- a/rpcs3/Emu/ARMv7/ARMv7DisAsm.h +++ b/rpcs3/Emu/ARMv7/ARMv7DisAsm.h @@ -27,15 +27,15 @@ protected: return dump_pc + imm; } - wxString GetRegsListString(u16 regs_list) + std::string GetRegsListString(u16 regs_list) { - wxString regs_str; + std::string regs_str; for(u16 mask=0x1, i=0; mask; mask <<= 1, i++) { if(regs_list & mask) { - if(!regs_str.IsEmpty()) + if(!regs_str.empty()) { regs_str += ", "; } @@ -54,12 +54,12 @@ protected: void PUSH(u16 regs_list) { - Write(wxString::Format("push {%s}", GetRegsListString(regs_list).mb_str())); + Write(fmt::Format("push {%s}", GetRegsListString(regs_list).c_str())); } void POP(u16 regs_list) { - Write(wxString::Format("pop {%s}", GetRegsListString(regs_list).mb_str())); + Write(fmt::Format("pop {%s}", GetRegsListString(regs_list).c_str())); } void NOP() @@ -71,26 +71,26 @@ protected: { if((cond & 0xe) == 0xe) { - Write(wxString::Format("b 0x%x", DisAsmBranchTarget(imm) + intstr_size)); + Write(fmt::Format("b 0x%x", DisAsmBranchTarget(imm) + intstr_size)); } else { - Write(wxString::Format("b[%s] 0x%x", g_arm_cond_name[cond], DisAsmBranchTarget(imm) + intstr_size)); + Write(fmt::Format("b[%s] 0x%x", g_arm_cond_name[cond], DisAsmBranchTarget(imm) + intstr_size)); } } virtual void CBZ(u8 op, u32 imm, u8 rn, u8 intstr_size) { - Write(wxString::Format("cb%sz 0x%x,%s", (op ? "n" : ""), DisAsmBranchTarget(imm) + intstr_size, g_arm_reg_name[rn])); + Write(fmt::Format("cb%sz 0x%x,%s", (op ? "n" : ""), DisAsmBranchTarget(imm) + intstr_size, g_arm_reg_name[rn])); } void BL(u32 imm, u8 intstr_size) { - Write(wxString::Format("bl 0x%x", DisAsmBranchTarget(imm) + intstr_size)); + Write(fmt::Format("bl 0x%x", DisAsmBranchTarget(imm) + intstr_size)); } void UNK(const u16 code0, const u16 code1) { - Write(wxString::Format("Unknown/Illegal opcode! (0x%04x : 0x%04x)", code0, code1)); + Write(fmt::Format("Unknown/Illegal opcode! (0x%04x : 0x%04x)", code0, code1)); } }; diff --git a/rpcs3/Emu/ARMv7/ARMv7Thread.cpp b/rpcs3/Emu/ARMv7/ARMv7Thread.cpp index 126569b379..5aff8a50c6 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Thread.cpp +++ b/rpcs3/Emu/ARMv7/ARMv7Thread.cpp @@ -37,25 +37,31 @@ void ARMv7Thread::SetArg(const uint pos, const u64 arg) assert(0); } -wxString ARMv7Thread::RegsToString() +std::string ARMv7Thread::RegsToString() { - wxString result = "Registers:\n=========\n"; + std::string result = "Registers:\n=========\n"; for(int i=0; i<15; ++i) { - result += wxString::Format("%s\t= 0x%08x\n", wxString(g_arm_reg_name[i]).wx_str(), GPR[i]); + result += fmt::Format("%s\t= 0x%08x\n", g_arm_reg_name[i], GPR[i]); } - result += wxString::Format("APSR\t= 0x%08x [N: %d, Z: %d, C: %d, V: %d, Q: %d]\n", APSR.APSR, APSR.N, APSR.Z, APSR.C, APSR.V, APSR.Q); + result += fmt::Format("APSR\t= 0x%08x [N: %d, Z: %d, C: %d, V: %d, Q: %d]\n", + APSR.APSR, + fmt::by_value(APSR.N), + fmt::by_value(APSR.Z), + fmt::by_value(APSR.C), + fmt::by_value(APSR.V), + fmt::by_value(APSR.Q)); return result; } -wxString ARMv7Thread::ReadRegString(wxString reg) +std::string ARMv7Thread::ReadRegString(const std::string& reg) { - return wxEmptyString; + return ""; } -bool ARMv7Thread::WriteRegString(wxString reg, wxString value) +bool ARMv7Thread::WriteRegString(const std::string& reg, std::string value) { return true; } diff --git a/rpcs3/Emu/ARMv7/ARMv7Thread.h b/rpcs3/Emu/ARMv7/ARMv7Thread.h index 7f5ad7dd52..f5a21c8cc8 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Thread.h +++ b/rpcs3/Emu/ARMv7/ARMv7Thread.h @@ -84,9 +84,9 @@ public: virtual void SetArg(const uint pos, const u64 arg); public: - virtual wxString RegsToString(); - virtual wxString ReadRegString(wxString reg); - virtual bool WriteRegString(wxString reg, wxString value); + virtual std::string RegsToString(); + virtual std::string ReadRegString(const std::string& reg); + virtual bool WriteRegString(const std::string& reg, std::string value); protected: virtual void DoReset(); diff --git a/rpcs3/Emu/Audio/AL/OpenALThread.cpp b/rpcs3/Emu/Audio/AL/OpenALThread.cpp index af49d5a01a..af988171cc 100644 --- a/rpcs3/Emu/Audio/AL/OpenALThread.cpp +++ b/rpcs3/Emu/Audio/AL/OpenALThread.cpp @@ -11,7 +11,7 @@ void printAlError(ALenum err, const char* situation) { if(err != AL_NO_ERROR) { - ConLog.Error("%s: OpenAL error 0x%04x", wxString(situation).wx_str(), err); + ConLog.Error("%s: OpenAL error 0x%04x", situation, err); Emu.Pause(); } } @@ -20,7 +20,7 @@ void printAlcError(ALCenum err, const char* situation) { if(err != ALC_NO_ERROR) { - ConLog.Error("%s: OpenALC error 0x%04x", wxString(situation).wx_str(), err); + ConLog.Error("%s: OpenALC error 0x%04x", situation, err); Emu.Pause(); } } diff --git a/rpcs3/Emu/CPU/CPUDisAsm.h b/rpcs3/Emu/CPU/CPUDisAsm.h index 13d7d2722d..1a46e623c7 100644 --- a/rpcs3/Emu/CPU/CPUDisAsm.h +++ b/rpcs3/Emu/CPU/CPUDisAsm.h @@ -15,24 +15,24 @@ class CPUDisAsm protected: const CPUDisAsmMode m_mode; - virtual void Write(const wxString& value) + virtual void Write(const std::string& value) { switch(m_mode) { case CPUDisAsm_DumpMode: - last_opcode = wxString::Format("\t%08llx:\t%02x %02x %02x %02x\t%s\n", dump_pc, + last_opcode = fmt::Format("\t%08llx:\t%02x %02x %02x %02x\t%s\n", dump_pc, Memory.Read8(offset + dump_pc), Memory.Read8(offset + dump_pc + 1), Memory.Read8(offset + dump_pc + 2), - Memory.Read8(offset + dump_pc + 3), value.wx_str()); + Memory.Read8(offset + dump_pc + 3), value.c_str()); break; case CPUDisAsm_InterpreterMode: - last_opcode = wxString::Format("[%08llx] %02x %02x %02x %02x: %s", dump_pc, + last_opcode = fmt::Format("[%08llx] %02x %02x %02x %02x: %s", dump_pc, Memory.Read8(offset + dump_pc), Memory.Read8(offset + dump_pc + 1), Memory.Read8(offset + dump_pc + 2), - Memory.Read8(offset + dump_pc + 3), value.wx_str()); + Memory.Read8(offset + dump_pc + 3), value.c_str()); break; case CPUDisAsm_CompilerElfMode: @@ -42,7 +42,7 @@ protected: } public: - wxString last_opcode; + std::string last_opcode; u64 dump_pc; u64 offset; @@ -55,9 +55,9 @@ protected: virtual u32 DisAsmBranchTarget(const s32 imm)=0; - wxString FixOp(wxString op) + std::string FixOp(std::string op) { - op.Append(' ', max(8 - op.Len(), 0)); + op.append(max(10 - (int)op.length(), 0),' '); return op; } }; diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index fda8b8807a..a318257e37 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -142,7 +142,7 @@ void CPUThread::SetBranch(const u64 pc, bool record_branch) { if(!Memory.IsGoodAddr(m_offset + pc)) { - ConLog.Error("%s branch error: bad address 0x%llx #pc: 0x%llx", GetFName().wx_str(), m_offset + pc, m_offset + PC); + ConLog.Error("%s branch error: bad address 0x%llx #pc: 0x%llx", GetFName().c_str(), m_offset + pc, m_offset + PC); Emu.Pause(); } @@ -296,7 +296,7 @@ void CPUThread::ExecOnce() void CPUThread::Task() { - if (Ini.HLELogging.GetValue()) ConLog.Write("%s enter", CPUThread::GetFName().wx_str()); + if (Ini.HLELogging.GetValue()) ConLog.Write("%s enter", CPUThread::GetFName().c_str()); const Array& bp = Emu.GetBreakPoints(); @@ -345,20 +345,20 @@ void CPUThread::Task() } } } - catch(const wxString& e) + catch(const std::string& e) { - ConLog.Error("Exception: %s", e.wx_str()); + ConLog.Error("Exception: %s", e.c_str()); } catch(const char* e) { - ConLog.Error("Exception: %s", wxString(e).wx_str()); + ConLog.Error("Exception: %s", e); } catch(int exitcode) { ConLog.Success("Exit Code: %d", exitcode); } - if (Ini.HLELogging.GetValue()) ConLog.Write("%s leave", CPUThread::GetFName().wx_str()); + if (Ini.HLELogging.GetValue()) ConLog.Write("%s leave", CPUThread::GetFName().c_str()); } s64 CPUThread::ExecAsCallback(u64 pc, bool wait, u64 a1, u64 a2, u64 a3, u64 a4) // not multithread-safe @@ -393,7 +393,7 @@ s64 CPUThread::ExecAsCallback(u64 pc, bool wait, u64 a1, u64 a2, u64 a3, u64 a4) { if (Emu.IsStopped()) { - ConLog.Warning("ExecAsCallback(wait=%s) aborted", wxString(wait ? "true" : "false").wx_str()); + ConLog.Warning("ExecAsCallback(wait=%s) aborted", wait ? "true" : "false"); return CELL_EABORT; // doesn't mean anything } Sleep(1); diff --git a/rpcs3/Emu/CPU/CPUThread.h b/rpcs3/Emu/CPU/CPUThread.h index ba9801f685..70a6723c81 100644 --- a/rpcs3/Emu/CPU/CPUThread.h +++ b/rpcs3/Emu/CPU/CPUThread.h @@ -87,17 +87,17 @@ public: u64 GetPrio() const { return m_prio; } std::string GetName() const { return NamedThreadBase::GetThreadName(); } - wxString GetFName() const + std::string GetFName() const { return - wxString::Format("%s[%d] Thread%s", - GetTypeString().wx_str(), + fmt::Format("%s[%d] Thread%s", + GetTypeString().c_str(), m_id, - wxString(GetName().empty() ? "" : wxString::Format(" (%s)", + wxString(GetName()).wx_str())).wx_str() + (GetName().empty() ? std::string("") : fmt::Format(" (%s)", GetName().c_str())).c_str() ); } - static wxString CPUThreadTypeToString(CPUThreadType type) + static std::string CPUThreadTypeToString(CPUThreadType type) { switch(type) { @@ -110,12 +110,12 @@ public: return "Unknown"; } - wxString GetTypeString() const { return CPUThreadTypeToString(m_type); } + std::string GetTypeString() const { return CPUThreadTypeToString(m_type); } virtual std::string GetThreadName() const { - wxString temp = (GetFName() + wxString::Format("[0x%08llx]", PC)); - return std::string(temp.mb_str()); + std::string temp = (GetFName() + fmt::Format("[0x%08llx]", PC)); + return temp; } public: @@ -181,11 +181,11 @@ public: void Resume(); void Stop(); - virtual void AddArgv(const wxString& arg) {} + virtual void AddArgv(const std::string& arg) {} - virtual wxString RegsToString() = 0; - virtual wxString ReadRegString(wxString reg) = 0; - virtual bool WriteRegString(wxString reg, wxString value) = 0; + virtual std::string RegsToString() = 0; + virtual std::string ReadRegString(const std::string& reg) = 0; + virtual bool WriteRegString(const std::string& reg, std::string value) = 0; virtual void Exec(); void ExecOnce(); @@ -198,13 +198,13 @@ public: Stack m_call_stack; - wxString CallStackToString() + std::string CallStackToString() { - wxString ret = "Call Stack:\n==========\n"; + std::string ret = "Call Stack:\n==========\n"; for(uint i=0; i 0x%llx\n", m_call_stack[i].pc, m_call_stack[i].branch_pc); + ret += fmt::Format("0x%llx -> 0x%llx\n", m_call_stack[i].pc, m_call_stack[i].branch_pc); } return ret; diff --git a/rpcs3/Emu/CPU/CPUThreadManager.cpp b/rpcs3/Emu/CPU/CPUThreadManager.cpp index a3a60a365f..a77b2802d9 100644 --- a/rpcs3/Emu/CPU/CPUThreadManager.cpp +++ b/rpcs3/Emu/CPU/CPUThreadManager.cpp @@ -36,7 +36,7 @@ CPUThread& CPUThreadManager::AddThread(CPUThreadType type) default: assert(0); } - new_thread->SetId(Emu.GetIdManager().GetNewID(wxString::Format("%s Thread", new_thread->GetTypeString().wx_str()).ToStdString(), new_thread)); + new_thread->SetId(Emu.GetIdManager().GetNewID(fmt::Format("%s Thread", new_thread->GetTypeString().c_str()), new_thread)); m_threads.Add(new_thread); #ifndef QT_UI diff --git a/rpcs3/Emu/Cell/PPCDisAsm.h b/rpcs3/Emu/Cell/PPCDisAsm.h index ec85cadcac..59086e8d94 100644 --- a/rpcs3/Emu/Cell/PPCDisAsm.h +++ b/rpcs3/Emu/Cell/PPCDisAsm.h @@ -13,226 +13,226 @@ protected: virtual u32 DisAsmBranchTarget(const s32 imm)=0; - void DisAsm_V4(const wxString& op, u32 v0, u32 v1, u32 v2, u32 v3) + void DisAsm_V4(const std::string& op, u32 v0, u32 v1, u32 v2, u32 v3) { - Write(wxString::Format("%s v%d,v%d,v%d,v%d", FixOp(op).wx_str(), v0, v1, v2, v3)); + Write(fmt::Format("%s v%d,v%d,v%d,v%d", FixOp(op).c_str(), v0, v1, v2, v3)); } - void DisAsm_V3_UIMM(const wxString& op, u32 v0, u32 v1, u32 v2, u32 uimm) + void DisAsm_V3_UIMM(const std::string& op, u32 v0, u32 v1, u32 v2, u32 uimm) { - Write(wxString::Format("%s v%d,v%d,v%d,%u #%x", FixOp(op).wx_str(), v0, v1, v2, uimm, uimm)); + Write(fmt::Format("%s v%d,v%d,v%d,%u #%x", FixOp(op).c_str(), v0, v1, v2, uimm, uimm)); } - void DisAsm_V3(const wxString& op, u32 v0, u32 v1, u32 v2) + void DisAsm_V3(const std::string& op, u32 v0, u32 v1, u32 v2) { - Write(wxString::Format("%s v%d,v%d,v%d", FixOp(op).wx_str(), v0, v1, v2)); + Write(fmt::Format("%s v%d,v%d,v%d", FixOp(op).c_str(), v0, v1, v2)); } - void DisAsm_V2_UIMM(const wxString& op, u32 v0, u32 v1, u32 uimm) + void DisAsm_V2_UIMM(const std::string& op, u32 v0, u32 v1, u32 uimm) { - Write(wxString::Format("%s v%d,v%d,%u #%x", FixOp(op).wx_str(), v0, v1, uimm, uimm)); + Write(fmt::Format("%s v%d,v%d,%u #%x", FixOp(op).c_str(), v0, v1, uimm, uimm)); } - void DisAsm_V2(const wxString& op, u32 v0, u32 v1) + void DisAsm_V2(const std::string& op, u32 v0, u32 v1) { - Write(wxString::Format("%s v%d,v%d", FixOp(op).wx_str(), v0, v1)); + Write(fmt::Format("%s v%d,v%d", FixOp(op).c_str(), v0, v1)); } - void DisAsm_V1_SIMM(const wxString& op, u32 v0, s32 simm) + void DisAsm_V1_SIMM(const std::string& op, u32 v0, s32 simm) { - Write(wxString::Format("%s v%d,%d #%x", FixOp(op).wx_str(), v0, simm, simm)); + Write(fmt::Format("%s v%d,%d #%x", FixOp(op).c_str(), v0, simm, simm)); } - void DisAsm_V1(const wxString& op, u32 v0) + void DisAsm_V1(const std::string& op, u32 v0) { - Write(wxString::Format("%s v%d", FixOp(op).wx_str(), v0)); + Write(fmt::Format("%s v%d", FixOp(op).c_str(), v0)); } - void DisAsm_V1_R2(const wxString& op, u32 v0, u32 r1, u32 r2) + void DisAsm_V1_R2(const std::string& op, u32 v0, u32 r1, u32 r2) { - Write(wxString::Format("%s v%d,r%d,r%d", FixOp(op).wx_str(), v0, r1, r2)); + Write(fmt::Format("%s v%d,r%d,r%d", FixOp(op).c_str(), v0, r1, r2)); } - void DisAsm_CR1_F2_RC(const wxString& op, u32 cr0, u32 f0, u32 f1, bool rc) + void DisAsm_CR1_F2_RC(const std::string& op, u32 cr0, u32 f0, u32 f1, bool rc) { - Write(wxString::Format("%s%s cr%d,f%d,f%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), cr0, f0, f1)); + Write(fmt::Format("%s%s cr%d,f%d,f%d", FixOp(op).c_str(), (rc ? "." : ""), cr0, f0, f1)); } - void DisAsm_CR1_F2(const wxString& op, u32 cr0, u32 f0, u32 f1) + void DisAsm_CR1_F2(const std::string& op, u32 cr0, u32 f0, u32 f1) { DisAsm_CR1_F2_RC(op, cr0, f0, f1, false); } - void DisAsm_INT1_R2(const wxString& op, u32 i0, u32 r0, u32 r1) + void DisAsm_INT1_R2(const std::string& op, u32 i0, u32 r0, u32 r1) { - Write(wxString::Format("%s %d,r%d,r%d", FixOp(op).wx_str(), i0, r0, r1)); + Write(fmt::Format("%s %d,r%d,r%d", FixOp(op).c_str(), i0, r0, r1)); } - void DisAsm_INT1_R1_IMM(const wxString& op, u32 i0, u32 r0, s32 imm0) + void DisAsm_INT1_R1_IMM(const std::string& op, u32 i0, u32 r0, s32 imm0) { - Write(wxString::Format("%s %d,r%d,%d #%x", FixOp(op).wx_str(), i0, r0, imm0, imm0)); + Write(fmt::Format("%s %d,r%d,%d #%x", FixOp(op).c_str(), i0, r0, imm0, imm0)); } - void DisAsm_INT1_R1_RC(const wxString& op, u32 i0, u32 r0, bool rc) + void DisAsm_INT1_R1_RC(const std::string& op, u32 i0, u32 r0, bool rc) { - Write(wxString::Format("%s%s %d,r%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), i0, r0)); + Write(fmt::Format("%s%s %d,r%d", FixOp(op).c_str(), (rc ? "." : ""), i0, r0)); } - void DisAsm_INT1_R1(const wxString& op, u32 i0, u32 r0) + void DisAsm_INT1_R1(const std::string& op, u32 i0, u32 r0) { DisAsm_INT1_R1_RC(op, i0, r0, false); } - void DisAsm_F4_RC(const wxString& op, u32 f0, u32 f1, u32 f2, u32 f3, bool rc) + void DisAsm_F4_RC(const std::string& op, u32 f0, u32 f1, u32 f2, u32 f3, bool rc) { - Write(wxString::Format("%s%s f%d,f%d,f%d,f%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), f0, f1, f2, f3)); + Write(fmt::Format("%s%s f%d,f%d,f%d,f%d", FixOp(op).c_str(), (rc ? "." : ""), f0, f1, f2, f3)); } - void DisAsm_F3_RC(const wxString& op, u32 f0, u32 f1, u32 f2, bool rc) + void DisAsm_F3_RC(const std::string& op, u32 f0, u32 f1, u32 f2, bool rc) { - Write(wxString::Format("%s%s f%d,f%d,f%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), f0, f1, f2)); + Write(fmt::Format("%s%s f%d,f%d,f%d", FixOp(op).c_str(), (rc ? "." : ""), f0, f1, f2)); } - void DisAsm_F3(const wxString& op, u32 f0, u32 f1, u32 f2) + void DisAsm_F3(const std::string& op, u32 f0, u32 f1, u32 f2) { DisAsm_F3_RC(op, f0, f1, f2, false); } - void DisAsm_F2_RC(const wxString& op, u32 f0, u32 f1, bool rc) + void DisAsm_F2_RC(const std::string& op, u32 f0, u32 f1, bool rc) { - Write(wxString::Format("%s%s f%d,f%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), f0, f1)); + Write(fmt::Format("%s%s f%d,f%d", FixOp(op).c_str(), (rc ? "." : ""), f0, f1)); } - void DisAsm_F2(const wxString& op, u32 f0, u32 f1) + void DisAsm_F2(const std::string& op, u32 f0, u32 f1) { DisAsm_F2_RC(op, f0, f1, false); } - void DisAsm_F1_R2(const wxString& op, u32 f0, u32 r0, u32 r1) + void DisAsm_F1_R2(const std::string& op, u32 f0, u32 r0, u32 r1) { if(m_mode == CPUDisAsm_CompilerElfMode) { - Write(wxString::Format("%s f%d,r%d,r%d", FixOp(op).wx_str(), f0, r0, r1)); + Write(fmt::Format("%s f%d,r%d,r%d", FixOp(op).c_str(), f0, r0, r1)); return; } - Write(wxString::Format("%s f%d,r%d(r%d)", FixOp(op).wx_str(), f0, r0, r1)); + Write(fmt::Format("%s f%d,r%d(r%d)", FixOp(op).c_str(), f0, r0, r1)); } - void DisAsm_F1_IMM_R1_RC(const wxString& op, u32 f0, s32 imm0, u32 r0, bool rc) + void DisAsm_F1_IMM_R1_RC(const std::string& op, u32 f0, s32 imm0, u32 r0, bool rc) { if(m_mode == CPUDisAsm_CompilerElfMode) { - Write(wxString::Format("%s%s f%d,r%d,%d #%x", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), f0, r0, imm0, imm0)); + Write(fmt::Format("%s%s f%d,r%d,%d #%x", FixOp(op).c_str(), (rc ? "." : ""), f0, r0, imm0, imm0)); return; } - Write(wxString::Format("%s%s f%d,%d(r%d) #%x", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), f0, imm0, r0, imm0)); + Write(fmt::Format("%s%s f%d,%d(r%d) #%x", FixOp(op).c_str(), (rc ? "." : ""), f0, imm0, r0, imm0)); } - void DisAsm_F1_IMM_R1(const wxString& op, u32 f0, s32 imm0, u32 r0) + void DisAsm_F1_IMM_R1(const std::string& op, u32 f0, s32 imm0, u32 r0) { DisAsm_F1_IMM_R1_RC(op, f0, imm0, r0, false); } - void DisAsm_F1_RC(const wxString& op, u32 f0, bool rc) + void DisAsm_F1_RC(const std::string& op, u32 f0, bool rc) { - Write(wxString::Format("%s%s f%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), f0)); + Write(fmt::Format("%s%s f%d", FixOp(op).c_str(), (rc ? "." : ""), f0)); } - void DisAsm_R1_RC(const wxString& op, u32 r0, bool rc) + void DisAsm_R1_RC(const std::string& op, u32 r0, bool rc) { - Write(wxString::Format("%s%s r%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), r0)); + Write(fmt::Format("%s%s r%d", FixOp(op).c_str(), (rc ? "." : ""), r0)); } - void DisAsm_R1(const wxString& op, u32 r0) + void DisAsm_R1(const std::string& op, u32 r0) { DisAsm_R1_RC(op, r0, false); } - void DisAsm_R2_OE_RC(const wxString& op, u32 r0, u32 r1, u32 oe, bool rc) + void DisAsm_R2_OE_RC(const std::string& op, u32 r0, u32 r1, u32 oe, bool rc) { - Write(wxString::Format("%s%s%s r%d,r%d", FixOp(op).wx_str(), wxString(oe ? "o" : "").wx_str(), wxString(rc ? "." : "").wx_str(), r0, r1)); + Write(fmt::Format("%s%s%s r%d,r%d", FixOp(op).c_str(), (oe ? "o" : ""), (rc ? "." : ""), r0, r1)); } - void DisAsm_R2_RC(const wxString& op, u32 r0, u32 r1, bool rc) + void DisAsm_R2_RC(const std::string& op, u32 r0, u32 r1, bool rc) { DisAsm_R2_OE_RC(op, r0, r1, false, rc); } - void DisAsm_R2(const wxString& op, u32 r0, u32 r1) + void DisAsm_R2(const std::string& op, u32 r0, u32 r1) { DisAsm_R2_RC(op, r0, r1, false); } - void DisAsm_R3_OE_RC(const wxString& op, u32 r0, u32 r1, u32 r2, u32 oe, bool rc) + void DisAsm_R3_OE_RC(const std::string& op, u32 r0, u32 r1, u32 r2, u32 oe, bool rc) { - Write(wxString::Format("%s%s%s r%d,r%d,r%d", FixOp(op).wx_str(), wxString(oe ? "o" : "").wx_str(), wxString(rc ? "." : "").wx_str(), r0, r1, r2)); + Write(fmt::Format("%s%s%s r%d,r%d,r%d", FixOp(op).c_str(), (oe ? "o" : ""), (rc ? "." : ""), r0, r1, r2)); } - void DisAsm_R3_INT2_RC(const wxString& op, u32 r0, u32 r1, u32 r2, s32 i0, s32 i1, bool rc) + void DisAsm_R3_INT2_RC(const std::string& op, u32 r0, u32 r1, u32 r2, s32 i0, s32 i1, bool rc) { - Write(wxString::Format("%s%s r%d,r%d,r%d,%d,%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), r0, r1, r2, i0, i1)); + Write(fmt::Format("%s%s r%d,r%d,r%d,%d,%d", FixOp(op).c_str(), (rc ? "." : ""), r0, r1, r2, i0, i1)); } - void DisAsm_R3_RC(const wxString& op, u32 r0, u32 r1, u32 r2, bool rc) + void DisAsm_R3_RC(const std::string& op, u32 r0, u32 r1, u32 r2, bool rc) { DisAsm_R3_OE_RC(op, r0, r1, r2, false, rc); } - void DisAsm_R3(const wxString& op, u32 r0, u32 r1, u32 r2) + void DisAsm_R3(const std::string& op, u32 r0, u32 r1, u32 r2) { DisAsm_R3_RC(op, r0, r1, r2, false); } - void DisAsm_R2_INT3_RC(const wxString& op, u32 r0, u32 r1, s32 i0, s32 i1, s32 i2, bool rc) + void DisAsm_R2_INT3_RC(const std::string& op, u32 r0, u32 r1, s32 i0, s32 i1, s32 i2, bool rc) { - Write(wxString::Format("%s%s r%d,r%d,%d,%d,%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), r0, r1, i0, i1, i2)); + Write(fmt::Format("%s%s r%d,r%d,%d,%d,%d", FixOp(op).c_str(), (rc ? "." : ""), r0, r1, i0, i1, i2)); } - void DisAsm_R2_INT3(const wxString& op, u32 r0, u32 r1, s32 i0, s32 i1, s32 i2) + void DisAsm_R2_INT3(const std::string& op, u32 r0, u32 r1, s32 i0, s32 i1, s32 i2) { DisAsm_R2_INT3_RC(op, r0, r1, i0, i1, i2, false); } - void DisAsm_R2_INT2_RC(const wxString& op, u32 r0, u32 r1, s32 i0, s32 i1, bool rc) + void DisAsm_R2_INT2_RC(const std::string& op, u32 r0, u32 r1, s32 i0, s32 i1, bool rc) { - Write(wxString::Format("%s%s r%d,r%d,%d,%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), r0, r1, i0, i1)); + Write(fmt::Format("%s%s r%d,r%d,%d,%d", FixOp(op).c_str(), (rc ? "." : ""), r0, r1, i0, i1)); } - void DisAsm_R2_INT2(const wxString& op, u32 r0, u32 r1, s32 i0, s32 i1) + void DisAsm_R2_INT2(const std::string& op, u32 r0, u32 r1, s32 i0, s32 i1) { DisAsm_R2_INT2_RC(op, r0, r1, i0, i1, false); } - void DisAsm_R2_INT1_RC(const wxString& op, u32 r0, u32 r1, s32 i0, bool rc) + void DisAsm_R2_INT1_RC(const std::string& op, u32 r0, u32 r1, s32 i0, bool rc) { - Write(wxString::Format("%s%s r%d,r%d,%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), r0, r1, i0)); + Write(fmt::Format("%s%s r%d,r%d,%d", FixOp(op).c_str(), (rc ? "." : ""), r0, r1, i0)); } - void DisAsm_R2_INT1(const wxString& op, u32 r0, u32 r1, s32 i0) + void DisAsm_R2_INT1(const std::string& op, u32 r0, u32 r1, s32 i0) { DisAsm_R2_INT1_RC(op, r0, r1, i0, false); } - void DisAsm_R2_IMM(const wxString& op, u32 r0, u32 r1, s32 imm0) + void DisAsm_R2_IMM(const std::string& op, u32 r0, u32 r1, s32 imm0) { if(m_mode == CPUDisAsm_CompilerElfMode) { - Write(wxString::Format("%s r%d,r%d,%d #%x", FixOp(op).wx_str(), r0, r1, imm0, imm0)); + Write(fmt::Format("%s r%d,r%d,%d #%x", FixOp(op).c_str(), r0, r1, imm0, imm0)); return; } - Write(wxString::Format("%s r%d,%d(r%d) #%x", FixOp(op).wx_str(), r0, imm0, r1, imm0)); + Write(fmt::Format("%s r%d,%d(r%d) #%x", FixOp(op).c_str(), r0, imm0, r1, imm0)); } - void DisAsm_R1_IMM(const wxString& op, u32 r0, s32 imm0) + void DisAsm_R1_IMM(const std::string& op, u32 r0, s32 imm0) { - Write(wxString::Format("%s r%d,%d #%x", FixOp(op).wx_str(), r0, imm0, imm0)); + Write(fmt::Format("%s r%d,%d #%x", FixOp(op).c_str(), r0, imm0, imm0)); } - void DisAsm_IMM_R1(const wxString& op, s32 imm0, u32 r0) + void DisAsm_IMM_R1(const std::string& op, s32 imm0, u32 r0) { - Write(wxString::Format("%s %d,r%d #%x", FixOp(op).wx_str(), imm0, r0, imm0)); + Write(fmt::Format("%s %d,r%d #%x", FixOp(op).c_str(), imm0, r0, imm0)); } - void DisAsm_CR1_R1_IMM(const wxString& op, u32 cr0, u32 r0, s32 imm0) + void DisAsm_CR1_R1_IMM(const std::string& op, u32 cr0, u32 r0, s32 imm0) { - Write(wxString::Format("%s cr%d,r%d,%d #%x", FixOp(op).wx_str(), cr0, r0, imm0, imm0)); + Write(fmt::Format("%s cr%d,r%d,%d #%x", FixOp(op).c_str(), cr0, r0, imm0, imm0)); } - void DisAsm_CR1_R2_RC(const wxString& op, u32 cr0, u32 r0, u32 r1, bool rc) + void DisAsm_CR1_R2_RC(const std::string& op, u32 cr0, u32 r0, u32 r1, bool rc) { - Write(wxString::Format("%s%s cr%d,r%d,r%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), cr0, r0, r1)); + Write(fmt::Format("%s%s cr%d,r%d,r%d", FixOp(op).c_str(), (rc ? "." : ""), cr0, r0, r1)); } - void DisAsm_CR1_R2(const wxString& op, u32 cr0, u32 r0, u32 r1) + void DisAsm_CR1_R2(const std::string& op, u32 cr0, u32 r0, u32 r1) { DisAsm_CR1_R2_RC(op, cr0, r0, r1, false); } - void DisAsm_CR2(const wxString& op, u32 cr0, u32 cr1) + void DisAsm_CR2(const std::string& op, u32 cr0, u32 cr1) { - Write(wxString::Format("%s cr%d,cr%d", FixOp(op).wx_str(), cr0, cr1)); + Write(fmt::Format("%s cr%d,cr%d", FixOp(op).c_str(), cr0, cr1)); } - void DisAsm_INT3(const wxString& op, const int i0, const int i1, const int i2) + void DisAsm_INT3(const std::string& op, const int i0, const int i1, const int i2) { - Write(wxString::Format("%s %d,%d,%d", FixOp(op).wx_str(), i0, i1, i2)); + Write(fmt::Format("%s %d,%d,%d", FixOp(op).c_str(), i0, i1, i2)); } - void DisAsm_INT1(const wxString& op, const int i0) + void DisAsm_INT1(const std::string& op, const int i0) { - Write(wxString::Format("%s %d", FixOp(op).wx_str(), i0)); + Write(fmt::Format("%s %d", FixOp(op).c_str(), i0)); } - void DisAsm_BRANCH(const wxString& op, const int pc) + void DisAsm_BRANCH(const std::string& op, const int pc) { - Write(wxString::Format("%s 0x%x", FixOp(op).wx_str(), DisAsmBranchTarget(pc))); + Write(fmt::Format("%s 0x%x", FixOp(op).c_str(), DisAsmBranchTarget(pc))); } - void DisAsm_BRANCH_A(const wxString& op, const int pc) + void DisAsm_BRANCH_A(const std::string& op, const int pc) { - Write(wxString::Format("%s 0x%x", FixOp(op).wx_str(), pc)); + Write(fmt::Format("%s 0x%x", FixOp(op).c_str(), pc)); } - void DisAsm_B2_BRANCH(const wxString& op, u32 b0, u32 b1, const int pc) + void DisAsm_B2_BRANCH(const std::string& op, u32 b0, u32 b1, const int pc) { - Write(wxString::Format("%s %d,%d,0x%x ", FixOp(op).wx_str(), b0, b1, DisAsmBranchTarget(pc))); + Write(fmt::Format("%s %d,%d,0x%x ", FixOp(op).c_str(), b0, b1, DisAsmBranchTarget(pc))); } - void DisAsm_CR_BRANCH(const wxString& op, u32 cr, const int pc) + void DisAsm_CR_BRANCH(const std::string& op, u32 cr, const int pc) { - Write(wxString::Format("%s cr%d,0x%x ", FixOp(op).wx_str(), cr, DisAsmBranchTarget(pc))); + Write(fmt::Format("%s cr%d,0x%x ", FixOp(op).c_str(), cr, DisAsmBranchTarget(pc))); } }; diff --git a/rpcs3/Emu/Cell/PPCThread.cpp b/rpcs3/Emu/Cell/PPCThread.cpp index 640e384a7f..f1d966cde7 100644 --- a/rpcs3/Emu/Cell/PPCThread.cpp +++ b/rpcs3/Emu/Cell/PPCThread.cpp @@ -8,7 +8,7 @@ PPCThread* GetCurrentPPCThread() if(!thread || (thread->GetType() != CPU_THREAD_PPU && thread->GetType() != CPU_THREAD_SPU && thread->GetType() != CPU_THREAD_RAW_SPU)) { - throw wxString("GetCurrentPPCThread: bad thread"); + throw std::string("GetCurrentPPCThread: bad thread"); } return (PPCThread*)thread; diff --git a/rpcs3/Emu/Cell/PPCThread.h b/rpcs3/Emu/Cell/PPCThread.h index b95f8e7c94..5b6f91dee2 100644 --- a/rpcs3/Emu/Cell/PPCThread.h +++ b/rpcs3/Emu/Cell/PPCThread.h @@ -17,7 +17,7 @@ public: virtual std::string GetThreadName() const { - return (GetFName() + wxString::Format("[0x%08llx]", PC)).ToStdString(); + return (GetFName() + fmt::Format("[0x%08llx]", PC)); } protected: diff --git a/rpcs3/Emu/Cell/PPUDisAsm.h b/rpcs3/Emu/Cell/PPUDisAsm.h index 3ca2a3a7f4..d9ec6b4706 100644 --- a/rpcs3/Emu/Cell/PPUDisAsm.h +++ b/rpcs3/Emu/Cell/PPUDisAsm.h @@ -22,227 +22,227 @@ private: } private: - void DisAsm_V4(const wxString& op, u32 v0, u32 v1, u32 v2, u32 v3) + void DisAsm_V4(const std::string& op, u32 v0, u32 v1, u32 v2, u32 v3) { - Write(wxString::Format("%s v%d,v%d,v%d,v%d", FixOp(op).wx_str(), v0, v1, v2, v3)); + Write(fmt::Format("%s v%d,v%d,v%d,v%d", FixOp(op).c_str(), v0, v1, v2, v3)); } - void DisAsm_V3_UIMM(const wxString& op, u32 v0, u32 v1, u32 v2, u32 uimm) + void DisAsm_V3_UIMM(const std::string& op, u32 v0, u32 v1, u32 v2, u32 uimm) { - Write(wxString::Format("%s v%d,v%d,v%d,%u #%x", FixOp(op).wx_str(), v0, v1, v2, uimm, uimm)); + Write(fmt::Format("%s v%d,v%d,v%d,%u #%x", FixOp(op).c_str(), v0, v1, v2, uimm, uimm)); } - void DisAsm_V3(const wxString& op, u32 v0, u32 v1, u32 v2) + void DisAsm_V3(const std::string& op, u32 v0, u32 v1, u32 v2) { - Write(wxString::Format("%s v%d,v%d,v%d", FixOp(op).wx_str(), v0, v1, v2)); + Write(fmt::Format("%s v%d,v%d,v%d", FixOp(op).c_str(), v0, v1, v2)); } - void DisAsm_V2_UIMM(const wxString& op, u32 v0, u32 v1, u32 uimm) + void DisAsm_V2_UIMM(const std::string& op, u32 v0, u32 v1, u32 uimm) { - Write(wxString::Format("%s v%d,v%d,%u #%x", FixOp(op).wx_str(), v0, v1, uimm, uimm)); + Write(fmt::Format("%s v%d,v%d,%u #%x", FixOp(op).c_str(), v0, v1, uimm, uimm)); } - void DisAsm_V2(const wxString& op, u32 v0, u32 v1) + void DisAsm_V2(const std::string& op, u32 v0, u32 v1) { - Write(wxString::Format("%s v%d,v%d", FixOp(op).wx_str(), v0, v1)); + Write(fmt::Format("%s v%d,v%d", FixOp(op).c_str(), v0, v1)); } - void DisAsm_V1_SIMM(const wxString& op, u32 v0, s32 simm) + void DisAsm_V1_SIMM(const std::string& op, u32 v0, s32 simm) { - Write(wxString::Format("%s v%d,%d #%x", FixOp(op).wx_str(), v0, simm, simm)); + Write(fmt::Format("%s v%d,%d #%x", FixOp(op).c_str(), v0, simm, simm)); } - void DisAsm_V1(const wxString& op, u32 v0) + void DisAsm_V1(const std::string& op, u32 v0) { - Write(wxString::Format("%s v%d", FixOp(op).wx_str(), v0)); + Write(fmt::Format("%s v%d", FixOp(op).c_str(), v0)); } - void DisAsm_V1_R2(const wxString& op, u32 v0, u32 r1, u32 r2) + void DisAsm_V1_R2(const std::string& op, u32 v0, u32 r1, u32 r2) { - Write(wxString::Format("%s v%d,r%d,r%d", FixOp(op).wx_str(), v0, r1, r2)); + Write(fmt::Format("%s v%d,r%d,r%d", FixOp(op).c_str(), v0, r1, r2)); } - void DisAsm_CR1_F2_RC(const wxString& op, u32 cr0, u32 f0, u32 f1, bool rc) + void DisAsm_CR1_F2_RC(const std::string& op, u32 cr0, u32 f0, u32 f1, bool rc) { - Write(wxString::Format("%s%s cr%d,f%d,f%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), cr0, f0, f1)); + Write(fmt::Format("%s%s cr%d,f%d,f%d", FixOp(op).c_str(), (rc ? "." : ""), cr0, f0, f1)); } - void DisAsm_CR1_F2(const wxString& op, u32 cr0, u32 f0, u32 f1) + void DisAsm_CR1_F2(const std::string& op, u32 cr0, u32 f0, u32 f1) { DisAsm_CR1_F2_RC(op, cr0, f0, f1, false); } - void DisAsm_INT1_R2(const wxString& op, u32 i0, u32 r0, u32 r1) + void DisAsm_INT1_R2(const std::string& op, u32 i0, u32 r0, u32 r1) { - Write(wxString::Format("%s %d,r%d,r%d", FixOp(op).wx_str(), i0, r0, r1)); + Write(fmt::Format("%s %d,r%d,r%d", FixOp(op).c_str(), i0, r0, r1)); } - void DisAsm_INT1_R1_IMM(const wxString& op, u32 i0, u32 r0, s32 imm0) + void DisAsm_INT1_R1_IMM(const std::string& op, u32 i0, u32 r0, s32 imm0) { - Write(wxString::Format("%s %d,r%d,%d #%x", FixOp(op).wx_str(), i0, r0, imm0, imm0)); + Write(fmt::Format("%s %d,r%d,%d #%x", FixOp(op).c_str(), i0, r0, imm0, imm0)); } - void DisAsm_INT1_R1_RC(const wxString& op, u32 i0, u32 r0, bool rc) + void DisAsm_INT1_R1_RC(const std::string& op, u32 i0, u32 r0, bool rc) { - Write(wxString::Format("%s%s %d,r%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), i0, r0)); + Write(fmt::Format("%s%s %d,r%d", FixOp(op).c_str(), (rc ? "." : ""), i0, r0)); } - void DisAsm_INT1_R1(const wxString& op, u32 i0, u32 r0) + void DisAsm_INT1_R1(const std::string& op, u32 i0, u32 r0) { DisAsm_INT1_R1_RC(op, i0, r0, false); } - void DisAsm_F4_RC(const wxString& op, u32 f0, u32 f1, u32 f2, u32 f3, bool rc) + void DisAsm_F4_RC(const std::string& op, u32 f0, u32 f1, u32 f2, u32 f3, bool rc) { - Write(wxString::Format("%s%s f%d,f%d,f%d,f%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), f0, f1, f2, f3)); + Write(fmt::Format("%s%s f%d,f%d,f%d,f%d", FixOp(op).c_str(), (rc ? "." : ""), f0, f1, f2, f3)); } - void DisAsm_F3_RC(const wxString& op, u32 f0, u32 f1, u32 f2, bool rc) + void DisAsm_F3_RC(const std::string& op, u32 f0, u32 f1, u32 f2, bool rc) { - Write(wxString::Format("%s%s f%d,f%d,f%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), f0, f1, f2)); + Write(fmt::Format("%s%s f%d,f%d,f%d", FixOp(op).c_str(), (rc ? "." : ""), f0, f1, f2)); } - void DisAsm_F3(const wxString& op, u32 f0, u32 f1, u32 f2) + void DisAsm_F3(const std::string& op, u32 f0, u32 f1, u32 f2) { DisAsm_F3_RC(op, f0, f1, f2, false); } - void DisAsm_F2_RC(const wxString& op, u32 f0, u32 f1, bool rc) + void DisAsm_F2_RC(const std::string& op, u32 f0, u32 f1, bool rc) { - Write(wxString::Format("%s%s f%d,f%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), f0, f1)); + Write(fmt::Format("%s%s f%d,f%d", FixOp(op).c_str(), (rc ? "." : ""), f0, f1)); } - void DisAsm_F2(const wxString& op, u32 f0, u32 f1) + void DisAsm_F2(const std::string& op, u32 f0, u32 f1) { DisAsm_F2_RC(op, f0, f1, false); } - void DisAsm_F1_R2(const wxString& op, u32 f0, u32 r0, u32 r1) + void DisAsm_F1_R2(const std::string& op, u32 f0, u32 r0, u32 r1) { if(m_mode == CPUDisAsm_CompilerElfMode) { - Write(wxString::Format("%s f%d,r%d,r%d", FixOp(op).wx_str(), f0, r0, r1)); + Write(fmt::Format("%s f%d,r%d,r%d", FixOp(op).c_str(), f0, r0, r1)); return; } - Write(wxString::Format("%s f%d,r%d(r%d)", FixOp(op).wx_str(), f0, r0, r1)); + Write(fmt::Format("%s f%d,r%d(r%d)", FixOp(op).c_str(), f0, r0, r1)); } - void DisAsm_F1_IMM_R1_RC(const wxString& op, u32 f0, s32 imm0, u32 r0, bool rc) + void DisAsm_F1_IMM_R1_RC(const std::string& op, u32 f0, s32 imm0, u32 r0, bool rc) { if(m_mode == CPUDisAsm_CompilerElfMode) { - Write(wxString::Format("%s%s f%d,r%d,%d #%x", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), f0, r0, imm0, imm0)); + Write(fmt::Format("%s%s f%d,r%d,%d #%x", FixOp(op).c_str(), (rc ? "." : ""), f0, r0, imm0, imm0)); return; } - Write(wxString::Format("%s%s f%d,%d(r%d) #%x", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), f0, imm0, r0, imm0)); + Write(fmt::Format("%s%s f%d,%d(r%d) #%x", FixOp(op).c_str(), (rc ? "." : ""), f0, imm0, r0, imm0)); } - void DisAsm_F1_IMM_R1(const wxString& op, u32 f0, s32 imm0, u32 r0) + void DisAsm_F1_IMM_R1(const std::string& op, u32 f0, s32 imm0, u32 r0) { DisAsm_F1_IMM_R1_RC(op, f0, imm0, r0, false); } - void DisAsm_F1_RC(const wxString& op, u32 f0, bool rc) + void DisAsm_F1_RC(const std::string& op, u32 f0, bool rc) { - Write(wxString::Format("%s%s f%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), f0)); + Write(fmt::Format("%s%s f%d", FixOp(op).c_str(), (rc ? "." : ""), f0)); } - void DisAsm_R1_RC(const wxString& op, u32 r0, bool rc) + void DisAsm_R1_RC(const std::string& op, u32 r0, bool rc) { - Write(wxString::Format("%s%s r%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), r0)); + Write(fmt::Format("%s%s r%d", FixOp(op).c_str(), (rc ? "." : ""), r0)); } - void DisAsm_R1(const wxString& op, u32 r0) + void DisAsm_R1(const std::string& op, u32 r0) { DisAsm_R1_RC(op, r0, false); } - void DisAsm_R2_OE_RC(const wxString& op, u32 r0, u32 r1, u32 oe, bool rc) + void DisAsm_R2_OE_RC(const std::string& op, u32 r0, u32 r1, u32 oe, bool rc) { - Write(wxString::Format("%s%s%s r%d,r%d", FixOp(op).wx_str(), wxString(oe ? "o" : "").wx_str(), wxString(rc ? "." : "").wx_str(), r0, r1)); + Write(fmt::Format("%s%s%s r%d,r%d", FixOp(op).c_str(), (oe ? "o" : ""), (rc ? "." : ""), r0, r1)); } - void DisAsm_R2_RC(const wxString& op, u32 r0, u32 r1, bool rc) + void DisAsm_R2_RC(const std::string& op, u32 r0, u32 r1, bool rc) { DisAsm_R2_OE_RC(op, r0, r1, false, rc); } - void DisAsm_R2(const wxString& op, u32 r0, u32 r1) + void DisAsm_R2(const std::string& op, u32 r0, u32 r1) { DisAsm_R2_RC(op, r0, r1, false); } - void DisAsm_R3_OE_RC(const wxString& op, u32 r0, u32 r1, u32 r2, u32 oe, bool rc) + void DisAsm_R3_OE_RC(const std::string& op, u32 r0, u32 r1, u32 r2, u32 oe, bool rc) { - Write(wxString::Format("%s%s%s r%d,r%d,r%d", FixOp(op).wx_str(), wxString(oe ? "o" : "").wx_str(), wxString(rc ? "." : "").wx_str(), r0, r1, r2)); + Write(fmt::Format("%s%s%s r%d,r%d,r%d", FixOp(op).c_str(), (oe ? "o" : ""), (rc ? "." : ""), r0, r1, r2)); } - void DisAsm_R3_INT2_RC(const wxString& op, u32 r0, u32 r1, u32 r2, s32 i0, s32 i1, bool rc) + void DisAsm_R3_INT2_RC(const std::string& op, u32 r0, u32 r1, u32 r2, s32 i0, s32 i1, bool rc) { - Write(wxString::Format("%s%s r%d,r%d,r%d,%d,%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), r0, r1, r2, i0, i1)); + Write(fmt::Format("%s%s r%d,r%d,r%d,%d,%d", FixOp(op).c_str(), (rc ? "." : ""), r0, r1, r2, i0, i1)); } - void DisAsm_R3_RC(const wxString& op, u32 r0, u32 r1, u32 r2, bool rc) + void DisAsm_R3_RC(const std::string& op, u32 r0, u32 r1, u32 r2, bool rc) { DisAsm_R3_OE_RC(op, r0, r1, r2, false, rc); } - void DisAsm_R3(const wxString& op, u32 r0, u32 r1, u32 r2) + void DisAsm_R3(const std::string& op, u32 r0, u32 r1, u32 r2) { DisAsm_R3_RC(op, r0, r1, r2, false); } - void DisAsm_R2_INT3_RC(const wxString& op, u32 r0, u32 r1, s32 i0, s32 i1, s32 i2, bool rc) + void DisAsm_R2_INT3_RC(const std::string& op, u32 r0, u32 r1, s32 i0, s32 i1, s32 i2, bool rc) { - Write(wxString::Format("%s%s r%d,r%d,%d,%d,%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), r0, r1, i0, i1, i2)); + Write(fmt::Format("%s%s r%d,r%d,%d,%d,%d", FixOp(op).c_str(), (rc ? "." : ""), r0, r1, i0, i1, i2)); } - void DisAsm_R2_INT3(const wxString& op, u32 r0, u32 r1, s32 i0, s32 i1, s32 i2) + void DisAsm_R2_INT3(const std::string& op, u32 r0, u32 r1, s32 i0, s32 i1, s32 i2) { DisAsm_R2_INT3_RC(op, r0, r1, i0, i1, i2, false); } - void DisAsm_R2_INT2_RC(const wxString& op, u32 r0, u32 r1, s32 i0, s32 i1, bool rc) + void DisAsm_R2_INT2_RC(const std::string& op, u32 r0, u32 r1, s32 i0, s32 i1, bool rc) { - Write(wxString::Format("%s%s r%d,r%d,%d,%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), r0, r1, i0, i1)); + Write(fmt::Format("%s%s r%d,r%d,%d,%d", FixOp(op).c_str(), (rc ? "." : ""), r0, r1, i0, i1)); } - void DisAsm_R2_INT2(const wxString& op, u32 r0, u32 r1, s32 i0, s32 i1) + void DisAsm_R2_INT2(const std::string& op, u32 r0, u32 r1, s32 i0, s32 i1) { DisAsm_R2_INT2_RC(op, r0, r1, i0, i1, false); } - void DisAsm_R2_INT1_RC(const wxString& op, u32 r0, u32 r1, s32 i0, bool rc) + void DisAsm_R2_INT1_RC(const std::string& op, u32 r0, u32 r1, s32 i0, bool rc) { - Write(wxString::Format("%s%s r%d,r%d,%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), r0, r1, i0)); + Write(fmt::Format("%s%s r%d,r%d,%d", FixOp(op).c_str(), (rc ? "." : ""), r0, r1, i0)); } - void DisAsm_R2_INT1(const wxString& op, u32 r0, u32 r1, s32 i0) + void DisAsm_R2_INT1(const std::string& op, u32 r0, u32 r1, s32 i0) { DisAsm_R2_INT1_RC(op, r0, r1, i0, false); } - void DisAsm_R2_IMM(const wxString& op, u32 r0, u32 r1, s32 imm0) + void DisAsm_R2_IMM(const std::string& op, u32 r0, u32 r1, s32 imm0) { if(m_mode == CPUDisAsm_CompilerElfMode) { - Write(wxString::Format("%s r%d,r%d,%d #%x", FixOp(op).wx_str(), r0, r1, imm0, imm0)); + Write(fmt::Format("%s r%d,r%d,%d #%x", FixOp(op).c_str(), r0, r1, imm0, imm0)); return; } - Write(wxString::Format("%s r%d,%d(r%d) #%x", FixOp(op).wx_str(), r0, imm0, r1, imm0)); + Write(fmt::Format("%s r%d,%d(r%d) #%x", FixOp(op).c_str(), r0, imm0, r1, imm0)); } - void DisAsm_R1_IMM(const wxString& op, u32 r0, s32 imm0) + void DisAsm_R1_IMM(const std::string& op, u32 r0, s32 imm0) { - Write(wxString::Format("%s r%d,%d #%x", FixOp(op).wx_str(), r0, imm0, imm0)); + Write(fmt::Format("%s r%d,%d #%x", FixOp(op).c_str(), r0, imm0, imm0)); } - void DisAsm_IMM_R1(const wxString& op, s32 imm0, u32 r0) + void DisAsm_IMM_R1(const std::string& op, s32 imm0, u32 r0) { - Write(wxString::Format("%s %d,r%d #%x", FixOp(op).wx_str(), imm0, r0, imm0)); + Write(fmt::Format("%s %d,r%d #%x", FixOp(op).c_str(), imm0, r0, imm0)); } - void DisAsm_CR1_R1_IMM(const wxString& op, u32 cr0, u32 r0, s32 imm0) + void DisAsm_CR1_R1_IMM(const std::string& op, u32 cr0, u32 r0, s32 imm0) { - Write(wxString::Format("%s cr%d,r%d,%d #%x", FixOp(op).wx_str(), cr0, r0, imm0, imm0)); + Write(fmt::Format("%s cr%d,r%d,%d #%x", FixOp(op).c_str(), cr0, r0, imm0, imm0)); } - void DisAsm_CR1_R2_RC(const wxString& op, u32 cr0, u32 r0, u32 r1, bool rc) + void DisAsm_CR1_R2_RC(const std::string& op, u32 cr0, u32 r0, u32 r1, bool rc) { - Write(wxString::Format("%s%s cr%d,r%d,r%d", FixOp(op).wx_str(), wxString(rc ? "." : "").wx_str(), cr0, r0, r1)); + Write(fmt::Format("%s%s cr%d,r%d,r%d", FixOp(op).c_str(), (rc ? "." : ""), cr0, r0, r1)); } - void DisAsm_CR1_R2(const wxString& op, u32 cr0, u32 r0, u32 r1) + void DisAsm_CR1_R2(const std::string& op, u32 cr0, u32 r0, u32 r1) { DisAsm_CR1_R2_RC(op, cr0, r0, r1, false); } - void DisAsm_CR2(const wxString& op, u32 cr0, u32 cr1) + void DisAsm_CR2(const std::string& op, u32 cr0, u32 cr1) { - Write(wxString::Format("%s cr%d,cr%d", FixOp(op).wx_str(), cr0, cr1)); + Write(fmt::Format("%s cr%d,cr%d", FixOp(op).c_str(), cr0, cr1)); } - void DisAsm_INT3(const wxString& op, const int i0, const int i1, const int i2) + void DisAsm_INT3(const std::string& op, const int i0, const int i1, const int i2) { - Write(wxString::Format("%s %d,%d,%d", FixOp(op).wx_str(), i0, i1, i2)); + Write(fmt::Format("%s %d,%d,%d", FixOp(op).c_str(), i0, i1, i2)); } - void DisAsm_INT1(const wxString& op, const int i0) + void DisAsm_INT1(const std::string& op, const int i0) { - Write(wxString::Format("%s %d", FixOp(op).wx_str(), i0)); + Write(fmt::Format("%s %d", FixOp(op).c_str(), i0)); } - void DisAsm_BRANCH(const wxString& op, const int pc) + void DisAsm_BRANCH(const std::string& op, const int pc) { - Write(wxString::Format("%s 0x%x", FixOp(op).wx_str(), DisAsmBranchTarget(pc))); + Write(fmt::Format("%s 0x%x", FixOp(op).c_str(), DisAsmBranchTarget(pc))); } - void DisAsm_BRANCH_A(const wxString& op, const int pc) + void DisAsm_BRANCH_A(const std::string& op, const int pc) { - Write(wxString::Format("%s 0x%x", FixOp(op).wx_str(), pc)); + Write(fmt::Format("%s 0x%x", FixOp(op).c_str(), pc)); } - void DisAsm_B2_BRANCH(const wxString& op, u32 b0, u32 b1, const int pc) + void DisAsm_B2_BRANCH(const std::string& op, u32 b0, u32 b1, const int pc) { - Write(wxString::Format("%s %d,%d,0x%x ", FixOp(op).wx_str(), b0, b1, DisAsmBranchTarget(pc))); + Write(fmt::Format("%s %d,%d,0x%x ", FixOp(op).c_str(), b0, b1, DisAsmBranchTarget(pc))); } - void DisAsm_CR_BRANCH(const wxString& op, u32 cr, const int pc) + void DisAsm_CR_BRANCH(const std::string& op, u32 cr, const int pc) { - Write(wxString::Format("%s cr%d,0x%x ", FixOp(op).wx_str(), cr, DisAsmBranchTarget(pc))); + Write(fmt::Format("%s cr%d,0x%x ", FixOp(op).c_str(), cr, DisAsmBranchTarget(pc))); } private: @@ -902,11 +902,11 @@ private: } void CMPLI(u32 crfd, u32 l, u32 ra, u32 uimm16) { - DisAsm_CR1_R1_IMM(wxString::Format("cmpl%si", wxString(l ? "d" : "w").wx_str()), crfd, ra, uimm16); + DisAsm_CR1_R1_IMM(fmt::Format("cmpl%si", (l ? "d" : "w")), crfd, ra, uimm16); } void CMPI(u32 crfd, u32 l, u32 ra, s32 simm16) { - DisAsm_CR1_R1_IMM(wxString::Format("cmp%si", wxString(l ? "d" : "w").wx_str()), crfd, ra, simm16); + DisAsm_CR1_R1_IMM(fmt::Format("cmp%si", (l ? "d" : "w")), crfd, ra, simm16); } void ADDIC(u32 rd, u32 ra, s32 simm16) { @@ -942,7 +942,7 @@ private: { if(m_mode == CPUDisAsm_CompilerElfMode) { - Write(wxString::Format("bc 0x%x, 0x%x, 0x%x, %d, %d", bo, bi, bd, aa, lk)); + Write(fmt::Format("bc 0x%x, 0x%x, 0x%x, %d, %d", bo, bi, bd, aa, lk)); return; } @@ -1032,7 +1032,7 @@ private: } } - Write(wxString::Format("bc [%x:%x:%x:%x:%x], cr%d[%x], 0x%x, %d, %d", bo0, bo1, bo2, bo3, bo4, bi/4, bi%4, bd, aa, lk)); + Write(fmt::Format("bc [%x:%x:%x:%x:%x], cr%d[%x], 0x%x, %d, %d", bo0, bo1, bo2, bo3, bo4, bi/4, bi%4, bd, aa, lk)); } void SC(s32 sc_code) { @@ -1041,14 +1041,14 @@ private: case 0x1: Write("HyperCall"); break; case 0x2: Write("sc"); break; case 0x22: Write("HyperCall LV1"); break; - default: Write(wxString::Format("Unknown sc: %x", sc_code)); + default: Write(fmt::Format("Unknown sc: %x", sc_code)); } } void B(s32 ll, u32 aa, u32 lk) { if(m_mode == CPUDisAsm_CompilerElfMode) { - Write(wxString::Format("b 0x%x, %d, %d", ll, aa, lk)); + Write(fmt::Format("b 0x%x, %d, %d", ll, aa, lk)); return; } @@ -1083,7 +1083,7 @@ private: const u8 bo3 = (bo & 0x02) ? 1 : 0; if(bo0 && !bo1 && bo2 && !bo3) {Write("blr"); return;} - Write(wxString::Format("bclr [%x:%x:%x:%x], cr%d[%x], %d, %d", bo0, bo1, bo2, bo3, bi/4, bi%4, bh, lk)); + Write(fmt::Format("bclr [%x:%x:%x:%x], cr%d[%x], %d, %d", bo0, bo1, bo2, bo3, bi/4, bi%4, bh, lk)); } void CRNOR(u32 bt, u32 ba, u32 bb) { @@ -1215,7 +1215,7 @@ private: } void CMP(u32 crfd, u32 l, u32 ra, u32 rb) { - DisAsm_CR1_R2(wxString::Format("cmp%s", wxString(l ? "d" : "w").wx_str()), crfd, ra, rb); + DisAsm_CR1_R2(fmt::Format("cmp%s", (l ? "d" : "w")), crfd, ra, rb); } void TW(u32 to, u32 ra, u32 rb) { @@ -1286,7 +1286,7 @@ private: } void CMPL(u32 crfd, u32 l, u32 ra, u32 rb) { - DisAsm_CR1_R2(wxString::Format("cmpl%s", wxString(l ? "d" : "w").wx_str()), crfd, ra, rb); + DisAsm_CR1_R2(fmt::Format("cmpl%s", (l ? "d" : "w")), crfd, ra, rb); } void LVSR(u32 vd, u32 ra, u32 rb) { @@ -2044,7 +2044,7 @@ private: void UNK(const u32 code, const u32 opcode, const u32 gcode) { - Write(wxString::Format("Unknown/Illegal opcode! (0x%08x : 0x%x : 0x%x)", code, opcode, gcode)); + Write(fmt::Format("Unknown/Illegal opcode! (0x%08x : 0x%x : 0x%x)", code, opcode, gcode)); } }; diff --git a/rpcs3/Emu/Cell/PPUInterpreter.h b/rpcs3/Emu/Cell/PPUInterpreter.h index 6904a68703..2087cefb12 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.h +++ b/rpcs3/Emu/Cell/PPUInterpreter.h @@ -139,7 +139,7 @@ private: case 0x100: return CPU.USPRG0; } - UNK(wxString::Format("GetRegBySPR error: Unknown SPR 0x%x!", n)); + UNK(fmt::Format("GetRegBySPR error: Unknown SPR 0x%x!", n)); return CPU.XER.XER; } @@ -153,7 +153,7 @@ private: ((u64)a < (u64)simm16 && (to & 0x2)) || ((u64)a > (u64)simm16 && (to & 0x1)) ) { - UNK(wxString::Format("Trap! (tdi %x, r%d, %x)", to, ra, simm16)); + UNK(fmt::Format("Trap! (tdi %x, r%d, %x)", to, ra, simm16)); } } @@ -167,7 +167,7 @@ private: ((u32)a < (u32)simm16 && (to & 0x2)) || ((u32)a > (u32)simm16 && (to & 0x1)) ) { - UNK(wxString::Format("Trap! (twi %x, r%d, %x)", to, ra, simm16)); + UNK(fmt::Format("Trap! (twi %x, r%d, %x)", to, ra, simm16)); } } @@ -2092,18 +2092,18 @@ private: { switch(sc_code) { - case 0x1: UNK(wxString::Format("HyperCall %d", CPU.GPR[0])); break; + case 0x1: UNK(fmt::Format("HyperCall %d", CPU.GPR[0])); break; case 0x2: SysCall(); break; case 0x3: StaticExecute(CPU.GPR[11]); if (Ini.HLELogging.GetValue()) { ConLog.Write("'%s' done with code[0x%llx]! #pc: 0x%llx", - wxString(g_static_funcs_list[CPU.GPR[11]].name).wx_str(), CPU.GPR[3], CPU.PC); + g_static_funcs_list[CPU.GPR[11]].name, CPU.GPR[3], CPU.PC); } break; case 0x22: UNK("HyperCall LV1"); break; - default: UNK(wxString::Format("Unknown sc: %x", sc_code)); + default: UNK(fmt::Format("Unknown sc: %x", sc_code)); } } void B(s32 ll, u32 aa, u32 lk) @@ -2264,7 +2264,7 @@ private: ((u32)a < (u32)b && (to & 0x2)) || ((u32)a > (u32)b && (to & 0x1)) ) { - UNK(wxString::Format("Trap! (tw %x, r%d, r%d)", to, ra, rb)); + UNK(fmt::Format("Trap! (tw %x, r%d, r%d)", to, ra, rb)); } } void LVSL(u32 vd, u32 ra, u32 rb) @@ -2874,7 +2874,7 @@ private: { case 0x10C: CPU.GPR[rd] = CPU.TB; break; case 0x10D: CPU.GPR[rd] = CPU.TBH; break; - default: UNK(wxString::Format("mftb r%d, %d", rd, spr)); break; + default: UNK(fmt::Format("mftb r%d, %d", rd, spr)); break; } } void LWAUX(u32 rd, u32 ra, u32 rb) @@ -4010,12 +4010,12 @@ private: void UNK(const u32 code, const u32 opcode, const u32 gcode) { - UNK(wxString::Format("Unknown/Illegal opcode! (0x%08x : 0x%x : 0x%x)", code, opcode, gcode)); + UNK(fmt::Format("Unknown/Illegal opcode! (0x%08x : 0x%x : 0x%x)", code, opcode, gcode)); } - void UNK(const wxString& err, bool pause = true) + void UNK(const std::string& err, bool pause = true) { - ConLog.Error(err + wxString::Format(" #pc: 0x%llx", CPU.PC)); + ConLog.Error(err + fmt::Format(" #pc: 0x%llx", CPU.PC)); if(!pause) return; @@ -4023,11 +4023,11 @@ private: for(uint i=0; i<32; ++i) ConLog.Write("r%d = 0x%llx", i, CPU.GPR[i]); for(uint i=0; i<32; ++i) ConLog.Write("f%d = %llf", i, CPU.FPR[i]); - for(uint i=0; i<32; ++i) ConLog.Write("v%d = 0x%s [%s]", i, CPU.VPR[i].ToString(true).wx_str(), CPU.VPR[i].ToString().wx_str()); + for(uint i=0; i<32; ++i) ConLog.Write("v%d = 0x%s [%s]", i, CPU.VPR[i].ToString(true).c_str(), CPU.VPR[i].ToString().c_str()); ConLog.Write("CR = 0x%08x", CPU.CR); ConLog.Write("LR = 0x%llx", CPU.LR); ConLog.Write("CTR = 0x%llx", CPU.CTR); - ConLog.Write("XER = 0x%llx [CA=%lld | OV=%lld | SO=%lld]", CPU.XER, CPU.XER.CA, CPU.XER.OV, CPU.XER.SO); + ConLog.Write("XER = 0x%llx [CA=%lld | OV=%lld | SO=%lld]", CPU.XER, fmt::by_value(CPU.XER.CA), fmt::by_value(CPU.XER.OV), fmt::by_value(CPU.XER.SO)); ConLog.Write("FPSCR = 0x%x " "[RN=%d | NI=%d | XE=%d | ZE=%d | UE=%d | OE=%d | VE=%d | " "VXCVI=%d | VXSQRT=%d | VXSOFT=%d | FPRF=%d | " @@ -4035,11 +4035,11 @@ private: "VXZDZ=%d | VXIDI=%d | VXISI=%d | VXSNAN=%d | " "XX=%d | ZX=%d | UX=%d | OX=%d | VX=%d | FEX=%d | FX=%d]", CPU.FPSCR, - CPU.FPSCR.RN, - CPU.FPSCR.NI, CPU.FPSCR.XE, CPU.FPSCR.ZE, CPU.FPSCR.UE, CPU.FPSCR.OE, CPU.FPSCR.VE, - CPU.FPSCR.VXCVI, CPU.FPSCR.VXSQRT, CPU.FPSCR.VXSOFT, CPU.FPSCR.FPRF, - CPU.FPSCR.FI, CPU.FPSCR.FR, CPU.FPSCR.VXVC, CPU.FPSCR.VXIMZ, - CPU.FPSCR.VXZDZ, CPU.FPSCR.VXIDI, CPU.FPSCR.VXISI, CPU.FPSCR.VXSNAN, - CPU.FPSCR.XX, CPU.FPSCR.ZX, CPU.FPSCR.UX, CPU.FPSCR.OX, CPU.FPSCR.VX, CPU.FPSCR.FEX, CPU.FPSCR.FX); + fmt::by_value(CPU.FPSCR.RN), + fmt::by_value(CPU.FPSCR.NI), fmt::by_value(CPU.FPSCR.XE), fmt::by_value(CPU.FPSCR.ZE), fmt::by_value(CPU.FPSCR.UE), fmt::by_value(CPU.FPSCR.OE), fmt::by_value(CPU.FPSCR.VE), + fmt::by_value(CPU.FPSCR.VXCVI), fmt::by_value(CPU.FPSCR.VXSQRT), fmt::by_value(CPU.FPSCR.VXSOFT), fmt::by_value(CPU.FPSCR.FPRF), + fmt::by_value(CPU.FPSCR.FI), fmt::by_value(CPU.FPSCR.FR), fmt::by_value(CPU.FPSCR.VXVC), fmt::by_value(CPU.FPSCR.VXIMZ), + fmt::by_value(CPU.FPSCR.VXZDZ), fmt::by_value(CPU.FPSCR.VXIDI), fmt::by_value(CPU.FPSCR.VXISI), fmt::by_value(CPU.FPSCR.VXSNAN), + fmt::by_value(CPU.FPSCR.XX), fmt::by_value(CPU.FPSCR.ZX), fmt::by_value(CPU.FPSCR.UX), fmt::by_value(CPU.FPSCR.OX), fmt::by_value(CPU.FPSCR.VX), fmt::by_value(CPU.FPSCR.FEX), fmt::by_value(CPU.FPSCR.FX)); } }; diff --git a/rpcs3/Emu/Cell/PPUProgramCompiler.cpp b/rpcs3/Emu/Cell/PPUProgramCompiler.cpp index 376f8a270e..03f7f4a796 100644 --- a/rpcs3/Emu/Cell/PPUProgramCompiler.cpp +++ b/rpcs3/Emu/Cell/PPUProgramCompiler.cpp @@ -4,7 +4,7 @@ using namespace PPU_instr; template -InstrBase* GetInstruction(T* list, const wxString& str) +InstrBase* GetInstruction(T* list, const std::string& str) { for(int i=0; icount; ++i) { @@ -12,7 +12,7 @@ InstrBase* GetInstruction(T* list, const wxString& str) if(instr) { - if(instr->GetName().Cmp(str) == 0) + if(instr->GetName().compare(str) == 0) { return instr; } @@ -23,7 +23,7 @@ InstrBase* GetInstruction(T* list, const wxString& str) } template -InstrBase* GetInstruction(const wxString& str) +InstrBase* GetInstruction(const std::string& str) { if(auto res = GetInstruction(main_list, str)) return res; if(auto res = GetInstruction(g04_list, str)) return res; @@ -40,19 +40,19 @@ InstrBase* GetInstruction(const wxString& str) return nullptr; } -s64 FindOp(const wxString& text, const wxString& op, s64 from) +s64 FindOp(const std::string& text, const std::string& op, s64 from) { - if(text.Len() < op.Len()) return -1; + if (text.length() < op.length()) return -1; - for(s64 i=from; i= text.Len() || text[(size_t)i + op.Len()] == '\n' || - CompilePPUProgram::IsSkip(text[(size_t)i + op.Len()])) return i; + if (text.substr(i, op.length()).compare(op) != 0) continue; + if (i + op.length() >= text.length() || text[(size_t) i + op.length()] == '\n' || + CompilePPUProgram::IsSkip(text[(size_t) i + op.length()])) return i; } } @@ -63,9 +63,9 @@ ArrayF sections_list; u32 section_name_offs = 0; u32 section_offs = 0; -SectionInfo::SectionInfo(const wxString& _name) +SectionInfo::SectionInfo(const std::string& _name) { - name = _name.ToStdString(); + name = _name; memset(&shdr, 0, sizeof(Elf64_Shdr)); section_num = sections_list.Add(this); @@ -116,8 +116,8 @@ SectionInfo::~SectionInfo() } CompilePPUProgram::CompilePPUProgram( - const wxString& asm_, - const wxString& file_path, + const std::string& asm_, + const std::string& file_path, wxTextCtrl* asm_list, wxTextCtrl* hex_list, wxTextCtrl* err_list, @@ -137,28 +137,28 @@ CompilePPUProgram::CompilePPUProgram( { } -void CompilePPUProgram::WriteHex(const wxString& text) +void CompilePPUProgram::WriteHex(const std::string& text) { if(m_hex_list) { - m_hex_list->WriteText(text); + m_hex_list->WriteText(fmt::FromUTF8(text)); } } -void CompilePPUProgram::WriteError(const wxString& error) +void CompilePPUProgram::WriteError(const std::string& error) { if(m_err_list) { - m_err_list->WriteText(wxString::Format("line %lld: %s\n", m_line, error.wx_str())); + m_err_list->WriteText(fmt::FromUTF8(fmt::Format("line %lld: %s\n", m_line, error))); } } bool CompilePPUProgram::IsSkip(const char c) { return c == ' ' || c == '\t'; } bool CompilePPUProgram::IsCommit(const char c) { return c == '#'; } -bool CompilePPUProgram::IsEnd() const { return p >= m_asm.Len(); } -bool CompilePPUProgram::IsEndLn(const char c) const { return c == '\n' || p - 1 >= m_asm.Len(); } +bool CompilePPUProgram::IsEnd() const { return p >= m_asm.length(); } +bool CompilePPUProgram::IsEndLn(const char c) const { return c == '\n' || p - 1 >= m_asm.length(); } -char CompilePPUProgram::NextChar() { return *(const char*)m_asm(p++, 1); } +char CompilePPUProgram::NextChar() { return *m_asm.substr(p++, 1).c_str(); } void CompilePPUProgram::NextLn() { while( !IsEndLn(NextChar()) ); if(!IsEnd()) m_line++; } void CompilePPUProgram::EndLn() { @@ -181,7 +181,7 @@ void CompilePPUProgram::PrevArg() if(IsEndLn(m_asm[(size_t)p])) p++; } -bool CompilePPUProgram::GetOp(wxString& result) +bool CompilePPUProgram::GetOp(std::string& result) { s64 from = -1; @@ -205,7 +205,7 @@ bool CompilePPUProgram::GetOp(wxString& result) if(skip || endln || commit) { const s64 to = (endln ? p : p - 1) - from; - result = m_asm(from, to); + result = m_asm.substr(from, to); return true; } @@ -214,7 +214,7 @@ bool CompilePPUProgram::GetOp(wxString& result) return false; } -int CompilePPUProgram::GetArg(wxString& result, bool func) +int CompilePPUProgram::GetArg(std::string& result, bool func) { s64 from = -1; @@ -246,7 +246,7 @@ int CompilePPUProgram::GetArg(wxString& result, bool func) if(text && !end_text) { - WriteError(wxString::Format("'\"' not found.")); + WriteError("'\"' not found."); m_error = true; } @@ -278,19 +278,19 @@ int CompilePPUProgram::GetArg(wxString& result, bool func) break; } - WriteError(wxString::Format("Bad symbol '%c'", cur_char)); + WriteError(fmt::Format("Bad symbol '%c'", cur_char)); m_error = true; break; } } - result = m_asm(from, to); + result = m_asm.substr(from, to); if(text) { - for(u32 pos = 0; (s32)(pos = result.find('\\', pos)) >= 0;) + for(u32 pos = 0; (s32)(pos = result.find('\\', pos)) != std::string::npos;) { - if(pos + 1 < result.Len() && result[pos + 1] == '\\') + if(pos + 1 < result.length() && result[pos + 1] == '\\') { pos += 2; continue; @@ -299,9 +299,9 @@ int CompilePPUProgram::GetArg(wxString& result, bool func) const char v = result[pos + 1]; switch(v) { - case 'n': result = result(0, pos) + '\n' + result(pos+2, result.Len()-(pos+2)); break; - case 'r': result = result(0, pos) + '\r' + result(pos+2, result.Len()-(pos+2)); break; - case 't': result = result(0, pos) + '\t' + result(pos+2, result.Len()-(pos+2)); break; + case 'n': result = result.substr(0, pos) + '\n' + result.substr(pos + 2, result.length() - (pos + 2)); break; + case 'r': result = result.substr(0, pos) + '\r' + result.substr(pos + 2, result.length() - (pos + 2)); break; + case 't': result = result.substr(0, pos) + '\t' + result.substr(pos + 2, result.length() - (pos + 2)); break; } pos++; @@ -345,7 +345,7 @@ bool CompilePPUProgram::CheckEnd(bool show_err) return true; } - WriteError(wxString::Format("Bad symbol '%c'", cur_char)); + WriteError(fmt::Format("Bad symbol '%c'", cur_char)); NextLn(); return false; } @@ -355,9 +355,9 @@ bool CompilePPUProgram::CheckEnd(bool show_err) void CompilePPUProgram::DetectArgInfo(Arg& arg) { - const wxString str = arg.string; + const std::string str = arg.string; - if(str.Len() <= 0) + if(str.empty()) { arg.type = ARG_ERR; return; @@ -369,11 +369,11 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) return; } - if(str.Len() > 1) + if(str.length() > 1) { for(u32 i=0; i '9') { @@ -409,7 +409,7 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) } u32 reg; - sscanf(str(1, str.Len() - 1), "%d", ®); + sscanf(str.substr(1, str.length() - 1).c_str(), "%d", ®); if(reg >= 32) { @@ -429,9 +429,9 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) return; case 'c': - if(str.Len() > 2 && str[1] == 'r') + if(str.length() > 2 && str[1] == 'r') { - for(u32 i=2; i '9') { @@ -441,7 +441,7 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) } u32 reg; - sscanf(str, "cr%d", ®); + sscanf(str.c_str(), "cr%d", ®); if(reg < 8) { @@ -458,26 +458,26 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) break; case '"': - if(str.Len() < 2) + if(str.length() < 2) { arg.type = ARG_ERR; return; } - if(str[str.Len() - 1] != '"') + if(str[str.length() - 1] != '"') { arg.type = ARG_ERR; return; } - arg.string = str(1, str.Len() - 2).ToStdString(); + arg.string = str.substr(1, str.length() - 2); arg.type = ARG_TXT; return; } - if(str.Len() > 2 && str(0, 2).Cmp("0x") == 0) + if(str.length() > 2 && str.substr(0, 2).compare("0x") == 0) { - for(u32 i=2; i= '0' && str[i] <= '9') || @@ -490,14 +490,14 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) } u32 val; - sscanf(str, "0x%x", &val); + sscanf(str.c_str(), "0x%x", &val); arg.type = ARG_NUM16; arg.value = val; return; } - for(u32 i= str[0] == '-' ? 1 : 0; i '9') { @@ -507,7 +507,7 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) } u32 val; - sscanf(str, "%d", &val); + sscanf(str.c_str(), "%d", &val); arg.type = ARG_NUM; arg.value = val; @@ -518,7 +518,7 @@ void CompilePPUProgram::LoadArgs() m_args.Clear(); m_cur_arg = 0; - wxString str; + std::string str; while(int r = GetArg(str)) { Arg* arg = new Arg(str); @@ -530,11 +530,11 @@ void CompilePPUProgram::LoadArgs() m_end_args = m_args.GetCount() > 0; } -u32 CompilePPUProgram::GetBranchValue(const wxString& branch) +u32 CompilePPUProgram::GetBranchValue(const std::string& branch) { for(u32 i=0; i= 0) return m_text_addr + m_branches[i].m_pos * 4; @@ -552,7 +552,7 @@ bool CompilePPUProgram::SetNextArgType(u32 types, bool show_err) { if(show_err) { - WriteError(wxString::Format("%d arg not found", m_cur_arg + 1)); + WriteError(fmt::Format("%d arg not found", m_cur_arg + 1)); m_error = true; } @@ -569,7 +569,7 @@ bool CompilePPUProgram::SetNextArgType(u32 types, bool show_err) if(show_err) { - WriteError(wxString::Format("Bad arg '%s'", wxString(&arg.string[0]).wx_str())); + WriteError(fmt::Format("Bad arg '%s'", arg.string.c_str())); m_error = true; } @@ -598,38 +598,38 @@ bool CompilePPUProgram::SetNextArgBranch(u8 aa, bool show_err) return ret; } -bool CompilePPUProgram::IsBranchOp(const wxString& op) +bool CompilePPUProgram::IsBranchOp(const std::string& op) { - return op.Len() > 1 && op[op.Len() - 1] == ':'; + return op.length() > 1 && op[op.length() - 1] == ':'; } -bool CompilePPUProgram::IsFuncOp(const wxString& op) +bool CompilePPUProgram::IsFuncOp(const std::string& op) { - return op.Len() >= 1 && op[0] == '['; + return op.length() >= 1 && op[0] == '['; } -CompilePPUProgram::SP_TYPE CompilePPUProgram::GetSpType(const wxString& op) +CompilePPUProgram::SP_TYPE CompilePPUProgram::GetSpType(const std::string& op) { - if(op.Cmp(".int") == 0) return SP_INT; - if(op.Cmp(".string") == 0) return SP_STRING; - if(op.Cmp(".strlen") == 0) return SP_STRLEN; - if(op.Cmp(".buf") == 0) return SP_BUF; - if(op.Cmp(".srl") == 0) return SP_SRL; - if(op.Cmp(".srr") == 0) return SP_SRR; - if(op.Cmp(".mul") == 0) return SP_MUL; - if(op.Cmp(".div") == 0) return SP_DIV; - if(op.Cmp(".add") == 0) return SP_ADD; - if(op.Cmp(".sub") == 0) return SP_SUB; - if(op.Cmp(".and") == 0) return SP_AND; - if(op.Cmp(".or") == 0) return SP_OR; - if(op.Cmp(".xor") == 0) return SP_XOR; - if(op.Cmp(".not") == 0) return SP_NOT; - if(op.Cmp(".nor") == 0) return SP_NOR; + if (op.compare(".int") == 0) return SP_INT; + if (op.compare(".string") == 0) return SP_STRING; + if (op.compare(".strlen") == 0) return SP_STRLEN; + if (op.compare(".buf") == 0) return SP_BUF; + if (op.compare(".srl") == 0) return SP_SRL; + if (op.compare(".srr") == 0) return SP_SRR; + if (op.compare(".mul") == 0) return SP_MUL; + if (op.compare(".div") == 0) return SP_DIV; + if (op.compare(".add") == 0) return SP_ADD; + if (op.compare(".sub") == 0) return SP_SUB; + if (op.compare(".and") == 0) return SP_AND; + if (op.compare(".or") == 0) return SP_OR; + if (op.compare(".xor") == 0) return SP_XOR; + if (op.compare(".not") == 0) return SP_NOT; + if (op.compare(".nor") == 0) return SP_NOR; return SP_ERR; } -wxString CompilePPUProgram::GetSpStyle(const SP_TYPE sp) +std::string CompilePPUProgram::GetSpStyle(const SP_TYPE sp) { switch(sp) { @@ -658,16 +658,16 @@ wxString CompilePPUProgram::GetSpStyle(const SP_TYPE sp) return "error"; } -bool CompilePPUProgram::IsSpOp(const wxString& op) +bool CompilePPUProgram::IsSpOp(const std::string& op) { return GetSpType(op) != SP_ERR; } -CompilePPUProgram::Branch& CompilePPUProgram::GetBranch(const wxString& name) +CompilePPUProgram::Branch& CompilePPUProgram::GetBranch(const std::string& name) { for(u32 i=0; i 0 && m_asm[(size_t)p] != '[') p--; p++; - wxString dst; + std::string dst; if(!GetArg(dst)) { if(m_analyze) WriteHex("error\n"); - WriteError(wxString::Format("dst not found. style: %s", GetSpStyle(sp).wx_str())); + WriteError(fmt::Format("dst not found. style: %s", GetSpStyle(sp).c_str())); m_error = true; NextLn(); return; @@ -736,7 +736,7 @@ void CompilePPUProgram::LoadSp(const wxString& op, Elf64_Shdr& s_opd) case ARG_ERR: { - m_branches.Move(new Branch(wxEmptyString, -1, 0)); + m_branches.Move(new Branch("", -1, 0)); //TODO: allocated with new, deleted with free() dst_branch = &m_branches[m_branches.GetCount() - 1]; } break; @@ -745,7 +745,7 @@ void CompilePPUProgram::LoadSp(const wxString& op, Elf64_Shdr& s_opd) if(!dst_branch) { if(m_analyze) WriteHex("error\n"); - WriteError(wxString::Format("bad dst type. style: %s", GetSpStyle(sp).wx_str())); + WriteError(fmt::Format("bad dst type. style: %s", GetSpStyle(sp).c_str())); m_error = true; NextLn(); return; @@ -759,11 +759,11 @@ void CompilePPUProgram::LoadSp(const wxString& op, Elf64_Shdr& s_opd) case SP_BUF: case SP_NOT: { - wxString src1; + std::string src1; if(!GetArg(src1, true)) { if(m_analyze) WriteHex("error\n"); - WriteError(wxString::Format("src not found. style: %s", GetSpStyle(sp).wx_str())); + WriteError(fmt::Format("src not found. style: %s", GetSpStyle(sp).c_str())); m_error = true; NextLn(); return; @@ -779,7 +779,7 @@ void CompilePPUProgram::LoadSp(const wxString& op, Elf64_Shdr& s_opd) : ~(ARG_IMM | ARG_BRANCH) & a_src1.type) { if(m_analyze) WriteHex("error\n"); - WriteError(wxString::Format("bad src type. style: %s", GetSpStyle(sp).wx_str())); + WriteError(fmt::Format("bad src type. style: %s", GetSpStyle(sp).c_str())); m_error = true; NextLn(); return; @@ -788,7 +788,7 @@ void CompilePPUProgram::LoadSp(const wxString& op, Elf64_Shdr& s_opd) if(m_asm[(size_t)p - 1] != ']') { if(m_analyze) WriteHex("error\n"); - WriteError(wxString::Format("']' not found. style: %s", GetSpStyle(sp).wx_str())); + WriteError(fmt::Format("']' not found. style: %s", GetSpStyle(sp).c_str())); m_error = true; NextLn(); return; @@ -802,12 +802,12 @@ void CompilePPUProgram::LoadSp(const wxString& op, Elf64_Shdr& s_opd) if(sp == SP_STRING) { - src1 = src1(1, src1.Len()-2); + src1 = src1.substr(1, src1.length()-2); bool founded = false; for(u32 i=0; i sections_names; u32 section_name_offset = 1; Elf64_Shdr s_text; @@ -1006,18 +1006,18 @@ void CompilePPUProgram::Compile() s_text.sh_addralign = 4; s_text.sh_flags = 6; s_text.sh_name = section_name_offset; - sections_names.Add(".text"); - section_name_offset += wxString(".text").Len() + 1; + sections_names.push_back(".text"); + section_name_offset += std::string(".text").length() + 1; section_offset += s_text.sh_size; m_text_addr = s_text.sh_addr; struct Module { - wxString m_name; + std::string m_name; Array m_imports; - Module(const wxString& name, u32 import) : m_name(name) + Module(const std::string& name, u32 import) : m_name(name) { Add(import); } @@ -1029,7 +1029,7 @@ void CompilePPUProgram::Compile() void Clear() { - m_name.Clear(); + m_name.clear(); m_imports.Clear(); } }; @@ -1039,7 +1039,7 @@ void CompilePPUProgram::Compile() FirstChar(); while(!IsEnd()) { - wxString op; + std::string op; if(!GetOp(op) || !IsFuncOp(op)) { NextLn(); @@ -1049,7 +1049,7 @@ void CompilePPUProgram::Compile() while(p > 0 && m_asm[(size_t)p] != '[') p--; p++; - wxString module, name, id; + std::string module, name, id; if(!GetArg(module)) { @@ -1118,13 +1118,13 @@ void CompilePPUProgram::Compile() if(!CheckEnd()) continue; - m_branches.Move(new Branch(name, a_id.value, 0)); + m_branches.Move(new Branch(name, a_id.value, 0)); //TODO: HACK: new and free() mixed const u32 import = m_branches.GetCount() - 1; bool founded = false; for(u32 i=0; i code; u32 section_num; - SectionInfo(const wxString& name); + SectionInfo(const std::string& name); ~SectionInfo(); void SetDataSize(u32 size, u32 align = 0); @@ -67,16 +67,16 @@ class CompilePPUProgram s32 m_id; s32 m_addr; - Branch(const wxString& name, s32 pos) - : m_name(name.ToStdString()) + Branch(const std::string& name, s32 pos) + : m_name(name) , m_pos(pos) , m_id(-1) , m_addr(-1) { } - Branch(const wxString& name, u32 id, u32 addr) - : m_name(name.ToStdString()) + Branch(const std::string& name, u32 id, u32 addr) + : m_name(name) , m_pos(-1) , m_id(id) , m_addr(addr) @@ -87,7 +87,7 @@ class CompilePPUProgram bool m_analyze; s64 p; u64 m_line; - const wxString& m_asm; + const std::string& m_asm; wxTextCtrl* m_asm_list; wxTextCtrl* m_hex_list; wxTextCtrl* m_err_list; @@ -97,15 +97,15 @@ class CompilePPUProgram Array m_branches; s32 m_branch_pos; u32 m_text_addr; - wxString m_file_path; + std::string m_file_path; struct SpData { std::string m_data; u32 m_addr; - SpData(const wxString& data, u32 addr) - : m_data(data.ToStdString()) + SpData(const std::string& data, u32 addr) + : m_data(data) , m_addr(addr) { } @@ -117,8 +117,8 @@ class CompilePPUProgram public: CompilePPUProgram( - const wxString& asm_, - const wxString& file_path = wxEmptyString, + const std::string& asm_, + const std::string& file_path = "", wxTextCtrl* asm_list = nullptr, wxTextCtrl* hex_list = nullptr, wxTextCtrl* err_list = nullptr, @@ -131,8 +131,8 @@ protected: bool IsEnd() const; bool IsEndLn(const char c) const; - void WriteHex(const wxString& text); - void WriteError(const wxString& error); + void WriteHex(const std::string& text); + void WriteError(const std::string& error); char NextChar(); void NextLn(); @@ -141,21 +141,21 @@ protected: void FirstChar(); void PrevArg(); - bool GetOp(wxString& result); - int GetArg(wxString& result, bool func = false); + bool GetOp(std::string& result); + int GetArg(std::string& result, bool func = false); bool CheckEnd(bool show_err = true); void DetectArgInfo(Arg& arg); void LoadArgs(); - u32 GetBranchValue(const wxString& branch); + u32 GetBranchValue(const std::string& branch); bool SetNextArgType(u32 types, bool show_err = true); bool SetNextArgBranch(u8 aa, bool show_err = true); public: - static bool IsBranchOp(const wxString& op); - static bool IsFuncOp(const wxString& op); + static bool IsBranchOp(const std::string& op); + static bool IsFuncOp(const std::string& op); enum SP_TYPE { @@ -177,15 +177,15 @@ public: SP_NOR, }; - static SP_TYPE GetSpType(const wxString& op); - static wxString GetSpStyle(const SP_TYPE sp); + static SP_TYPE GetSpType(const std::string& op); + static std::string GetSpStyle(const SP_TYPE sp); - static bool IsSpOp(const wxString& op); + static bool IsSpOp(const std::string& op); protected: - Branch& GetBranch(const wxString& name); - void SetSp(const wxString& name, u32 addr, bool create); - void LoadSp(const wxString& op, Elf64_Shdr& s_opd); + Branch& GetBranch(const std::string& name); + void SetSp(const std::string& name, u32 addr, bool create); + void LoadSp(const std::string& op, Elf64_Shdr& s_opd); public: void Compile(); diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 05405efc13..2e2de76536 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -10,7 +10,7 @@ PPUThread& GetCurrentPPUThread() { PPCThread* thread = GetCurrentPPCThread(); - if(!thread || thread->GetType() != CPU_THREAD_PPU) throw wxString("GetCurrentPPUThread: bad thread"); + if(!thread || thread->GetType() != CPU_THREAD_PPU) throw std::string("GetCurrentPPUThread: bad thread"); return *(PPUThread*)thread; } @@ -47,9 +47,9 @@ void PPUThread::DoReset() cycle = 0; } -void PPUThread::AddArgv(const wxString& arg) +void PPUThread::AddArgv(const std::string& arg) { - m_stack_point -= arg.Len() + 1; + m_stack_point -= arg.length() + 1; m_stack_point = Memory.AlignAddr(m_stack_point, 0x10) - 0x10; m_argv_addr.AddCpy(m_stack_point); Memory.WriteString(m_stack_point, arg); diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index d0db068ab9..9da6680abd 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -381,7 +381,7 @@ struct PPCdouble } #endif - throw wxString::Format("PPCdouble::UpdateType() -> unknown fpclass (0x%04x).", fpc); + throw fmt::Format("PPCdouble::UpdateType() -> unknown fpclass (0x%04x).", fpc); } FPRType GetType() const @@ -488,11 +488,11 @@ union VPR_reg VPR_reg() { Clear(); } - wxString ToString(bool hex=false) const + std::string ToString(bool hex = false) const { - if(hex) return wxString::Format("%08x%08x%08x%08x", _u32[3], _u32[2], _u32[1], _u32[0]); + if(hex) return fmt::Format("%08x%08x%08x%08x", _u32[3], _u32[2], _u32[1], _u32[0]); - return wxString::Format("x: %g y: %g z: %g w: %g", _f[3], _f[2], _f[1], _f[0]); + return fmt::Format("x: %g y: %g z: %g w: %g", _f[3], _f[2], _f[1], _f[0]); } u8 GetBit(u8 bit) @@ -735,99 +735,106 @@ public: FPSCR.FI = val; } - virtual wxString RegsToString() + virtual std::string RegsToString() { - wxString ret = "Registers:\n=========\n"; + std::string ret = "Registers:\n=========\n"; - for(uint i=0; i<32; ++i) ret += wxString::Format("GPR[%d] = 0x%llx\n", i, GPR[i]); - for(uint i=0; i<32; ++i) ret += wxString::Format("FPR[%d] = %.6G\n", i, (double)FPR[i]); - for(uint i=0; i<32; ++i) ret += wxString::Format("VPR[%d] = 0x%s [%s]\n", i, (const char*)VPR[i].ToString(true).wx_str(), (const char*)VPR[i].ToString().wx_str()); - ret += wxString::Format("CR = 0x%08x\n", CR.CR); - ret += wxString::Format("LR = 0x%llx\n", LR); - ret += wxString::Format("CTR = 0x%llx\n", CTR); - ret += wxString::Format("XER = 0x%llx [CA=%lld | OV=%lld | SO=%lld]\n", XER.XER, XER.CA, XER.OV, XER.SO); - ret += wxString::Format("FPSCR = 0x%x " + for(uint i=0; i<32; ++i) ret += fmt::Format("GPR[%d] = 0x%llx\n", i, GPR[i]); + for(uint i=0; i<32; ++i) ret += fmt::Format("FPR[%d] = %.6G\n", i, (double)FPR[i]); + for(uint i=0; i<32; ++i) ret += fmt::Format("VPR[%d] = 0x%s [%s]\n", i, (const char*)VPR[i].ToString(true).c_str(), (const char*)VPR[i].ToString().c_str()); + ret += fmt::Format("CR = 0x%08x\n", CR.CR); + ret += fmt::Format("LR = 0x%llx\n", LR); + ret += fmt::Format("CTR = 0x%llx\n", CTR); + ret += fmt::Format("XER = 0x%llx [CA=%lld | OV=%lld | SO=%lld]\n", XER.XER, fmt::by_value(XER.CA), fmt::by_value(XER.OV), fmt::by_value(XER.SO)); + ret += fmt::Format("FPSCR = 0x%x " "[RN=%d | NI=%d | XE=%d | ZE=%d | UE=%d | OE=%d | VE=%d | " "VXCVI=%d | VXSQRT=%d | VXSOFT=%d | FPRF=%d | " "FI=%d | FR=%d | VXVC=%d | VXIMZ=%d | " "VXZDZ=%d | VXIDI=%d | VXISI=%d | VXSNAN=%d | " "XX=%d | ZX=%d | UX=%d | OX=%d | VX=%d | FEX=%d | FX=%d]\n", FPSCR.FPSCR, - FPSCR.RN, - FPSCR.NI, FPSCR.XE, FPSCR.ZE, FPSCR.UE, FPSCR.OE, FPSCR.VE, - FPSCR.VXCVI, FPSCR.VXSQRT, FPSCR.VXSOFT, FPSCR.FPRF, - FPSCR.FI, FPSCR.FR, FPSCR.VXVC, FPSCR.VXIMZ, - FPSCR.VXZDZ, FPSCR.VXIDI, FPSCR.VXISI, FPSCR.VXSNAN, - FPSCR.XX, FPSCR.ZX, FPSCR.UX, FPSCR.OX, FPSCR.VX, FPSCR.FEX, FPSCR.FX); + fmt::by_value(FPSCR.RN), + fmt::by_value(FPSCR.NI), fmt::by_value(FPSCR.XE), fmt::by_value(FPSCR.ZE), fmt::by_value(FPSCR.UE), fmt::by_value(FPSCR.OE), fmt::by_value(FPSCR.VE), + fmt::by_value(FPSCR.VXCVI), fmt::by_value(FPSCR.VXSQRT), fmt::by_value(FPSCR.VXSOFT), fmt::by_value(FPSCR.FPRF), + fmt::by_value(FPSCR.FI), fmt::by_value(FPSCR.FR), fmt::by_value(FPSCR.VXVC), fmt::by_value(FPSCR.VXIMZ), + fmt::by_value(FPSCR.VXZDZ), fmt::by_value(FPSCR.VXIDI), fmt::by_value(FPSCR.VXISI), fmt::by_value(FPSCR.VXSNAN), + fmt::by_value(FPSCR.XX), fmt::by_value(FPSCR.ZX), fmt::by_value(FPSCR.UX), fmt::by_value(FPSCR.OX), fmt::by_value(FPSCR.VX), fmt::by_value(FPSCR.FEX), fmt::by_value(FPSCR.FX)); return ret; } - virtual wxString ReadRegString(wxString reg) + virtual std::string ReadRegString(const std::string& reg) { - if (reg.Contains("[")) + std::string::size_type first_brk = reg.find('['); + if (first_brk != std::string::npos) { - long reg_index; - reg.AfterFirst('[').RemoveLast().ToLong(®_index); - if (reg.StartsWith("GPR")) return wxString::Format("%016llx", GPR[reg_index]); - if (reg.StartsWith("FPR")) return wxString::Format("%016llx", (double)FPR[reg_index]); - if (reg.StartsWith("VPR")) return wxString::Format("%016llx%016llx", VPR[reg_index]._u64[1], VPR[reg_index]._u64[0]); + long reg_index = atol(reg.substr(first_brk+1,reg.length()-first_brk-2).c_str()); + if (reg.find("GPR")==0) return fmt::Format("%016llx", GPR[reg_index]); + if (reg.find("FPR")==0) return fmt::Format("%016llx", (double)FPR[reg_index]); + if (reg.find("VPR")==0) return fmt::Format("%016llx%016llx", VPR[reg_index]._u64[1], VPR[reg_index]._u64[0]); } - if (reg == "CR") return wxString::Format("%08x", CR.CR); - if (reg == "LR") return wxString::Format("%016llx", LR); - if (reg == "CTR") return wxString::Format("%016llx", CTR); - if (reg == "XER") return wxString::Format("%016llx", XER.XER); - if (reg == "FPSCR") return wxString::Format("%08x", FPSCR.FPSCR); + if (reg == "CR") return fmt::Format("%08x", CR.CR); + if (reg == "LR") return fmt::Format("%016llx", LR); + if (reg == "CTR") return fmt::Format("%016llx", CTR); + if (reg == "XER") return fmt::Format("%016llx", XER.XER); + if (reg == "FPSCR") return fmt::Format("%08x", FPSCR.FPSCR); - return wxEmptyString; + return ""; } - bool WriteRegString(wxString reg, wxString value) { - while (value.Len() < 32) value = "0"+value; - if (reg.Contains("[")) + bool WriteRegString(const std::string& reg, std::string value) { + while (value.length() < 32) value = "0"+value; + std::string::size_type first_brk = reg.find('['); + try { - long reg_index; - reg.AfterFirst('[').RemoveLast().ToLong(®_index); - if (reg.StartsWith("GPR") || (reg.StartsWith("FPR"))) + if (first_brk != std::string::npos) + { + long reg_index = atol(reg.substr(first_brk + 1, reg.length() - first_brk - 2).c_str()); + if (reg.find("GPR")==0 || reg.find("FPR")==0 ) + { + unsigned long long reg_value; + reg_value = std::stoull(value.substr(16, 31),0,16); + if (reg.find("GPR")==0) GPR[reg_index] = (u64)reg_value; + if (reg.find("FPR")==0) FPR[reg_index] = (u64)reg_value; + return true; + } + if (reg.find("VPR")==0) + { + unsigned long long reg_value0; + unsigned long long reg_value1; + reg_value0 = std::stoull(value.substr(16, 31), 0, 16); + reg_value1 = std::stoull(value.substr(0, 15), 0, 16); + VPR[reg_index]._u64[0] = (u64)reg_value0; + VPR[reg_index]._u64[1] = (u64)reg_value1; + return true; + } + } + if (reg == "LR" || reg == "CTR" || reg == "XER") { unsigned long long reg_value; - if (!value.SubString(16,31).ToULongLong(®_value, 16)) return false; - if (reg.StartsWith("GPR")) GPR[reg_index] = (u64)reg_value; - if (reg.StartsWith("FPR")) FPR[reg_index] = (u64)reg_value; + reg_value = std::stoull(value.substr(16, 31), 0, 16); + if (reg == "LR") LR = (u64)reg_value; + if (reg == "CTR") CTR = (u64)reg_value; + if (reg == "XER") XER.XER = (u64)reg_value; return true; } - if (reg.StartsWith("VPR")) + if (reg == "CR" || reg == "FPSCR") { - unsigned long long reg_value0; - unsigned long long reg_value1; - if (!value.SubString(16,31).ToULongLong(®_value0, 16)) return false; - if (!value.SubString(0,15).ToULongLong(®_value1, 16)) return false; - VPR[reg_index]._u64[0] = (u64)reg_value0; - VPR[reg_index]._u64[1] = (u64)reg_value1; + unsigned long reg_value; + reg_value = std::stoull(value.substr(24, 31), 0, 16); + if (reg == "CR") CR.CR = (u32)reg_value; + if (reg == "FPSCR") FPSCR.FPSCR = (u32)reg_value; return true; } } - if (reg == "LR" || reg == "CTR" || reg == "XER") + catch (std::invalid_argument& e)//if any of the stoull conversion fail { - unsigned long long reg_value; - if (!value.SubString(16,31).ToULongLong(®_value, 16)) return false; - if (reg == "LR") LR = (u64)reg_value; - if (reg == "CTR") CTR = (u64)reg_value; - if (reg == "XER") XER.XER = (u64)reg_value; - return true; - } - if (reg == "CR" || reg == "FPSCR") - { - unsigned long reg_value; - if (!value.SubString(24,31).ToULong(®_value, 16)) return false; - if (reg == "CR") CR.CR = (u32)reg_value; - if (reg == "FPSCR") FPSCR.FPSCR = (u32)reg_value; - return true; + return false; } return false; } - virtual void AddArgv(const wxString& arg) override; + virtual void AddArgv(const std::string& arg) override; public: virtual void InitRegs(); diff --git a/rpcs3/Emu/Cell/RawSPUThread.cpp b/rpcs3/Emu/Cell/RawSPUThread.cpp index 4cb3d27354..0c2dac87cb 100644 --- a/rpcs3/Emu/Cell/RawSPUThread.cpp +++ b/rpcs3/Emu/Cell/RawSPUThread.cpp @@ -251,7 +251,7 @@ u32 RawSPUThread::GetIndex() const void RawSPUThread::Task() { - if (Ini.HLELogging.GetValue()) ConLog.Write("%s enter", PPCThread::GetFName().wx_str()); + if (Ini.HLELogging.GetValue()) ConLog.Write("%s enter", PPCThread::GetFName().c_str()); const Array& bp = Emu.GetBreakPoints(); @@ -325,14 +325,14 @@ void RawSPUThread::Task() } } } - catch(const wxString& e) + catch(const std::string& e) { - ConLog.Error("Exception: %s", e.wx_str()); + ConLog.Error("Exception: %s", e.c_str()); } catch(const char* e) { - ConLog.Error("Exception: %s", wxString(e).wx_str()); + ConLog.Error("Exception: %s", e); } - if (Ini.HLELogging.GetValue()) ConLog.Write("%s leave", PPCThread::GetFName().wx_str()); + if (Ini.HLELogging.GetValue()) ConLog.Write("%s leave", PPCThread::GetFName().c_str()); } diff --git a/rpcs3/Emu/Cell/SPUDisAsm.h b/rpcs3/Emu/Cell/SPUDisAsm.h index e49d60b504..e1ee8fa932 100644 --- a/rpcs3/Emu/Cell/SPUDisAsm.h +++ b/rpcs3/Emu/Cell/SPUDisAsm.h @@ -26,54 +26,54 @@ private: } private: - wxString& FixOp(wxString& op) + std::string& FixOp(std::string& op) { - op.Append(' ', max(10 - (int)op.Len(), 0)); + op.append(max(10 - (int)op.length(), 0),' '); return op; } void DisAsm(const char* op) { Write(op); } - void DisAsm(wxString op, u32 a1) + void DisAsm(std::string op, u32 a1) { - Write(wxString::Format("%s 0x%x", FixOp(op).wx_str(), a1)); + Write(fmt::Format("%s 0x%x", FixOp(op).c_str(), a1)); } - void DisAsm(wxString op, const char* a1) + void DisAsm(std::string op, const char* a1) { - Write(wxString::Format("%s %s", FixOp(op).wx_str(), wxString(a1).wx_str())); + Write(fmt::Format("%s %s", FixOp(op).c_str(), a1)); } - void DisAsm(wxString op, const char* a1, const char* a2) + void DisAsm(std::string op, const char* a1, const char* a2) { - Write(wxString::Format("%s %s,%s", FixOp(op).wx_str(), wxString(a1).wx_str(), wxString(a2).wx_str())); + Write(fmt::Format("%s %s,%s", FixOp(op).c_str(), a1, a2)); } - void DisAsm(wxString op, int a1, const char* a2) + void DisAsm(std::string op, int a1, const char* a2) { - Write(wxString::Format("%s 0x%x,%s", FixOp(op).wx_str(), a1, wxString(a2).wx_str())); + Write(fmt::Format("%s 0x%x,%s", FixOp(op).c_str(), a1, a2)); } - void DisAsm(wxString op, const char* a1, int a2) + void DisAsm(std::string op, const char* a1, int a2) { - Write(wxString::Format("%s %s,0x%x", FixOp(op).wx_str(), wxString(a1).wx_str(), a2)); + Write(fmt::Format("%s %s,0x%x", FixOp(op).c_str(), a1, a2)); } - void DisAsm(wxString op, int a1, int a2) + void DisAsm(std::string op, int a1, int a2) { - Write(wxString::Format("%s 0x%x,0x%x", FixOp(op).wx_str(), a1, a2)); + Write(fmt::Format("%s 0x%x,0x%x", FixOp(op).c_str(), a1, a2)); } - void DisAsm(wxString op, const char* a1, const char* a2, const char* a3) + void DisAsm(std::string op, const char* a1, const char* a2, const char* a3) { - Write(wxString::Format("%s %s,%s,%s", FixOp(op).wx_str(), wxString(a1).wx_str(), wxString(a2).wx_str(), wxString(a3).wx_str())); + Write(fmt::Format("%s %s,%s,%s", FixOp(op).c_str(), a1, a2, a3)); } - void DisAsm(wxString op, const char* a1, int a2, const char* a3) + void DisAsm(std::string op, const char* a1, int a2, const char* a3) { - Write(wxString::Format("%s %s,0x%x(%s)", FixOp(op).wx_str(), wxString(a1).wx_str(), a2, wxString(a3).wx_str())); + Write(fmt::Format("%s %s,0x%x(%s)", FixOp(op).c_str(), a1, a2, a3)); } - void DisAsm(wxString op, const char* a1, const char* a2, int a3) + void DisAsm(std::string op, const char* a1, const char* a2, int a3) { - Write(wxString::Format("%s %s,%s,0x%x", FixOp(op).wx_str(), wxString(a1).wx_str(), wxString(a2).wx_str(), a3)); + Write(fmt::Format("%s %s,%s,0x%x", FixOp(op).c_str(), a1, a2, a3)); } - void DisAsm(wxString op, const char* a1, const char* a2, const char* a3, const char* a4) + void DisAsm(std::string op, const char* a1, const char* a2, const char* a3, const char* a4) { - Write(wxString::Format("%s %s,%s,%s,%s", FixOp(op).wx_str(), wxString(a1).wx_str(), wxString(a2).wx_str(), wxString(a3).wx_str(), wxString(a4).wx_str())); + Write(fmt::Format("%s %s,%s,%s,%s", FixOp(op).c_str(), a1, a2, a3, a4)); } //0 - 10 void STOP(u32 code) @@ -885,6 +885,6 @@ private: void UNK(u32 code, u32 opcode, u32 gcode) { - Write(wxString::Format("Unknown/Illegal opcode! (0x%08x, 0x%x, 0x%x)", code, opcode, gcode)); + Write(fmt::Format("Unknown/Illegal opcode! (0x%08x, 0x%x, 0x%x)", code, opcode, gcode)); } }; diff --git a/rpcs3/Emu/Cell/SPUInterpreter.h b/rpcs3/Emu/Cell/SPUInterpreter.h index 2b6a4d782a..dfca767c9c 100644 --- a/rpcs3/Emu/Cell/SPUInterpreter.h +++ b/rpcs3/Emu/Cell/SPUInterpreter.h @@ -1521,13 +1521,13 @@ private: void UNK(u32 code, u32 opcode, u32 gcode) { - UNK(wxString::Format("Unknown/Illegal opcode! (0x%08x, 0x%x, 0x%x)", code, opcode, gcode)); + UNK(fmt::Format("Unknown/Illegal opcode! (0x%08x, 0x%x, 0x%x)", code, opcode, gcode)); } - void UNK(const wxString& err) + void UNK(const std::string& err) { - ConLog.Error(err + wxString::Format(" #pc: 0x%x", CPU.PC)); + ConLog.Error(err + fmt::Format(" #pc: 0x%x", CPU.PC)); Emu.Pause(); - for(uint i=0; i<128; ++i) ConLog.Write("r%d = 0x%s", i, CPU.GPR[i].ToString().wx_str()); + for(uint i=0; i<128; ++i) ConLog.Write("r%d = 0x%s", i, CPU.GPR[i].ToString().c_str()); } }; diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 0d651af5f5..e3cc2b8db0 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -10,7 +10,7 @@ SPUThread& GetCurrentSPUThread() if(!thread || (thread->GetType() != CPU_THREAD_SPU && thread->GetType() != CPU_THREAD_RAW_SPU)) { - throw wxString("GetCurrentSPUThread: bad thread"); + throw std::string("GetCurrentSPUThread: bad thread"); } return *(SPUThread*)thread; diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index 0b9173d48d..f8d99b5c9a 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -138,9 +138,9 @@ public: FPSCR() {} - wxString ToString() const + std::string ToString() const { - return "FPSCR writer not yet implemented"; //wxString::Format("%08x%08x%08x%08x", _u32[3], _u32[2], _u32[1], _u32[0]); + return "FPSCR writer not yet implemented"; //fmt::Format("%08x%08x%08x%08x", _u32[3], _u32[2], _u32[1], _u32[0]); } void Reset() @@ -230,9 +230,9 @@ union SPU_GPR_hdr SPU_GPR_hdr() {} - wxString ToString() const + std::string ToString() const { - return wxString::Format("%08x%08x%08x%08x", _u32[3], _u32[2], _u32[1], _u32[0]); + return fmt::Format("%08x%08x%08x%08x", _u32[3], _u32[2], _u32[1], _u32[0]); } void Reset() @@ -249,9 +249,9 @@ union SPU_SPR_hdr SPU_SPR_hdr() {} - wxString ToString() const + std::string ToString() const { - return wxString::Format("%08x%08x%08x%08x", _u32[3], _u32[2], _u32[1], _u32[0]); + return fmt::Format("%08x%08x%08x%08x", _u32[3], _u32[2], _u32[1], _u32[0]); } void Reset() @@ -266,9 +266,9 @@ union SPU_SNRConfig_hdr SPU_SNRConfig_hdr() {} - wxString ToString() const + std::string ToString() const { - return wxString::Format("%01x", value); + return fmt::Format("%01x", value); } void Reset() @@ -699,10 +699,10 @@ public: case MFC_GET_CMD: { if (Ini.HLELogging.GetValue()) ConLog.Write("DMA %s%s%s%s: lsa = 0x%x, ea = 0x%llx, tag = 0x%x, size = 0x%x, cmd = 0x%x", - wxString(op & MFC_PUT_CMD ? "PUT" : "GET").wx_str(), - wxString(op & MFC_RESULT_MASK ? "R" : "").wx_str(), - wxString(op & MFC_BARRIER_MASK ? "B" : "").wx_str(), - wxString(op & MFC_FENCE_MASK ? "F" : "").wx_str(), + (op & MFC_PUT_CMD ? "PUT" : "GET"), + (op & MFC_RESULT_MASK ? "R" : ""), + (op & MFC_BARRIER_MASK ? "B" : ""), + (op & MFC_FENCE_MASK ? "F" : ""), lsa, ea, tag, size, cmd); MFCArgs.CMDStatus.SetValue(dmacCmd(cmd, tag, lsa, ea, size)); @@ -714,10 +714,10 @@ public: case MFC_GETL_CMD: { if (Ini.HLELogging.GetValue()) ConLog.Write("DMA %s%s%s%s: lsa = 0x%x, list = 0x%llx, tag = 0x%x, size = 0x%x, cmd = 0x%x", - wxString(op & MFC_PUT_CMD ? "PUT" : "GET").wx_str(), - wxString(op & MFC_RESULT_MASK ? "RL" : "L").wx_str(), - wxString(op & MFC_BARRIER_MASK ? "B" : "").wx_str(), - wxString(op & MFC_FENCE_MASK ? "F" : "").wx_str(), + (op & MFC_PUT_CMD ? "PUT" : "GET"), + (op & MFC_RESULT_MASK ? "RL" : "L"), + (op & MFC_BARRIER_MASK ? "B" : ""), + (op & MFC_FENCE_MASK ? "F" : ""), lsa, ea, tag, size, cmd); ListCmd(lsa, ea, tag, size, cmd, MFCArgs); @@ -730,9 +730,9 @@ public: case MFC_PUTQLLUC_CMD: { if (Ini.HLELogging.GetValue() || size != 128) ConLog.Write("DMA %s: lsa=0x%x, ea = 0x%llx, (tag) = 0x%x, (size) = 0x%x, cmd = 0x%x", - wxString(op == MFC_GETLLAR_CMD ? "GETLLAR" : + (op == MFC_GETLLAR_CMD ? "GETLLAR" : op == MFC_PUTLLC_CMD ? "PUTLLC" : - op == MFC_PUTLLUC_CMD ? "PUTLLUC" : "PUTQLLUC").wx_str(), + op == MFC_PUTLLUC_CMD ? "PUTLLUC" : "PUTQLLUC"), lsa, ea, tag, size, cmd); if (op == MFC_GETLLAR_CMD) // get reservation @@ -863,11 +863,11 @@ public: case SPU_RdInMbox: count = SPU.In_MBox.GetCount(); - //ConLog.Warning("GetChannelCount(%s) -> %d", wxString(spu_ch_name[ch]).wx_str(), count); + //ConLog.Warning("GetChannelCount(%s) -> %d", spu_ch_name[ch], count); return count; case SPU_WrOutIntrMbox: - ConLog.Warning("GetChannelCount(%s) = 0", wxString(spu_ch_name[ch]).wx_str()); + ConLog.Warning("GetChannelCount(%s) = 0", spu_ch_name[ch]); return 0; case MFC_RdTagStat: @@ -890,7 +890,7 @@ public: default: ConLog.Error("%s error: unknown/illegal channel (%d [%s]).", - wxString(__FUNCTION__).wx_str(), ch, wxString(spu_ch_name[ch]).wx_str()); + __FUNCTION__, ch, spu_ch_name[ch]); break; } @@ -1017,17 +1017,17 @@ public: break; case SPU_WrOutMbox: - //ConLog.Warning("%s: %s = 0x%x", wxString(__FUNCTION__).wx_str(), wxString(spu_ch_name[ch]).wx_str(), v); + //ConLog.Warning("%s: %s = 0x%x", __FUNCTION__, spu_ch_name[ch], v); while (!SPU.Out_MBox.Push(v) && !Emu.IsStopped()) Sleep(1); break; case MFC_WrTagMask: - //ConLog.Warning("%s: %s = 0x%x", wxString(__FUNCTION__).wx_str(), wxString(spu_ch_name[ch]).wx_str(), v); + //ConLog.Warning("%s: %s = 0x%x", __FUNCTION__, spu_ch_name[ch], v); Prxy.QueryMask.SetValue(v); break; case MFC_WrTagUpdate: - //ConLog.Warning("%s: %s = 0x%x", wxString(__FUNCTION__).wx_str(), wxString(spu_ch_name[ch]).wx_str(), v); + //ConLog.Warning("%s: %s = 0x%x", __FUNCTION__, spu_ch_name[ch], v); Prxy.TagStatus.PushUncond(Prxy.QueryMask.GetValue()); break; @@ -1075,11 +1075,11 @@ public: break; default: - ConLog.Error("%s error: unknown/illegal channel (%d [%s]).", wxString(__FUNCTION__).wx_str(), ch, wxString(spu_ch_name[ch]).wx_str()); + ConLog.Error("%s error: unknown/illegal channel (%d [%s]).", __FUNCTION__, ch, spu_ch_name[ch]); break; } - if (Emu.IsStopped()) ConLog.Warning("%s(%s) aborted", wxString(__FUNCTION__).wx_str(), wxString(spu_ch_name[ch]).wx_str()); + if (Emu.IsStopped()) ConLog.Warning("%s(%s) aborted", __FUNCTION__, spu_ch_name[ch]); } void ReadChannel(SPU_GPR_hdr& r, u32 ch) @@ -1091,22 +1091,22 @@ public: { case SPU_RdInMbox: while (!SPU.In_MBox.Pop(v) && !Emu.IsStopped()) Sleep(1); - //ConLog.Warning("%s: 0x%x = %s", wxString(__FUNCTION__).wx_str(), v, wxString(spu_ch_name[ch]).wx_str()); + //ConLog.Warning("%s: 0x%x = %s", __FUNCTION__, v, spu_ch_name[ch]); break; case MFC_RdTagStat: while (!Prxy.TagStatus.Pop(v) && !Emu.IsStopped()) Sleep(1); - //ConLog.Warning("%s: 0x%x = %s", wxString(__FUNCTION__).wx_str(), v, wxString(spu_ch_name[ch]).wx_str()); + //ConLog.Warning("%s: 0x%x = %s", __FUNCTION__, v, spu_ch_name[ch]); break; case SPU_RdSigNotify1: while (!SPU.SNR[0].Pop(v) && !Emu.IsStopped()) Sleep(1); - //ConLog.Warning("%s: 0x%x = %s", wxString(__FUNCTION__).wx_str(), v, wxString(spu_ch_name[ch]).wx_str()); + //ConLog.Warning("%s: 0x%x = %s", __FUNCTION__, v, spu_ch_name[ch]); break; case SPU_RdSigNotify2: while (!SPU.SNR[1].Pop(v) && !Emu.IsStopped()) Sleep(1); - //ConLog.Warning("%s: 0x%x = %s", wxString(__FUNCTION__).wx_str(), v, wxString(spu_ch_name[ch]).wx_str()); + //ConLog.Warning("%s: 0x%x = %s", __FUNCTION__, v, spu_ch_name[ch]); break; case MFC_RdAtomicStat: @@ -1118,11 +1118,11 @@ public: break; default: - ConLog.Error("%s error: unknown/illegal channel (%d [%s]).", wxString(__FUNCTION__).wx_str(), ch, wxString(spu_ch_name[ch]).wx_str()); + ConLog.Error("%s error: unknown/illegal channel (%d [%s]).", __FUNCTION__, ch, spu_ch_name[ch]); break; } - if (Emu.IsStopped()) ConLog.Warning("%s(%s) aborted", wxString(__FUNCTION__).wx_str(), wxString(spu_ch_name[ch]).wx_str()); + if (Emu.IsStopped()) ConLog.Warning("%s(%s) aborted", __FUNCTION__, spu_ch_name[ch]); } bool IsGoodLSA(const u32 lsa) const { return Memory.IsGoodAddr(lsa + m_offset) && lsa < 0x40000; } @@ -1142,39 +1142,48 @@ public: SPUThread(CPUThreadType type = CPU_THREAD_SPU); virtual ~SPUThread(); - virtual wxString RegsToString() + virtual std::string RegsToString() { - wxString ret = "Registers:\n=========\n"; + std::string ret = "Registers:\n=========\n"; - for(uint i=0; i<128; ++i) ret += wxString::Format("GPR[%d] = 0x%s\n", i, GPR[i].ToString().wx_str()); + for(uint i=0; i<128; ++i) ret += fmt::Format("GPR[%d] = 0x%s\n", i, GPR[i].ToString().c_str()); return ret; } - virtual wxString ReadRegString(wxString reg) + virtual std::string ReadRegString(const std::string& reg) { - if (reg.Contains("[")) + std::string::size_type first_brk = reg.find('['); + if (first_brk != std::string::npos) { long reg_index; - reg.AfterFirst('[').RemoveLast().ToLong(®_index); - if (reg.StartsWith("GPR")) return wxString::Format("%016llx%016llx", GPR[reg_index]._u64[1], GPR[reg_index]._u64[0]); + reg_index = atol(reg.substr(first_brk + 1, reg.length()-2).c_str()); + if (reg.find("GPR")==0) return fmt::Format("%016llx%016llx", GPR[reg_index]._u64[1], GPR[reg_index]._u64[0]); } - return wxEmptyString; + return ""; } - bool WriteRegString(wxString reg, wxString value) + bool WriteRegString(const std::string& reg, std::string value) { - while (value.Len() < 32) value = "0"+value; - if (reg.Contains("[")) + while (value.length() < 32) value = "0"+value; + std::string::size_type first_brk = reg.find('['); + if (first_brk != std::string::npos) { long reg_index; - reg.AfterFirst('[').RemoveLast().ToLong(®_index); - if (reg.StartsWith("GPR")) + reg_index = atol(reg.substr(first_brk + 1, reg.length() - 2).c_str()); + if (reg.find("GPR")==0) { unsigned long long reg_value0; unsigned long long reg_value1; - if (!value.SubString(16,31).ToULongLong(®_value0, 16)) return false; - if (!value.SubString(0,15).ToULongLong(®_value1, 16)) return false; + try + { + reg_value0 = std::stoull(value.substr(16, 31), 0, 16); + reg_value1 = std::stoull(value.substr(0, 15), 0, 16); + } + catch (std::invalid_argument& e) + { + return false; + } GPR[reg_index]._u64[0] = (u64)reg_value0; GPR[reg_index]._u64[1] = (u64)reg_value1; return true; diff --git a/rpcs3/Emu/DbgConsole.cpp b/rpcs3/Emu/DbgConsole.cpp index c24a258b5a..59237c8789 100644 --- a/rpcs3/Emu/DbgConsole.cpp +++ b/rpcs3/Emu/DbgConsole.cpp @@ -6,7 +6,7 @@ BEGIN_EVENT_TABLE(DbgConsole, FrameBase) END_EVENT_TABLE() DbgConsole::DbgConsole() - : FrameBase(nullptr, wxID_ANY, "DbgConsole", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxDEFAULT_FRAME_STYLE, true) + : FrameBase(nullptr, wxID_ANY, "DbgConsole", "", wxDefaultSize, wxDefaultPosition, wxDEFAULT_FRAME_STYLE, true) , ThreadBase("DbgConsole thread") , m_output(nullptr) { @@ -28,7 +28,7 @@ DbgConsole::~DbgConsole() m_dbg_buffer.Flush(); } -void DbgConsole::Write(int ch, const wxString& text) +void DbgConsole::Write(int ch, const std::string& text) { while (m_dbg_buffer.IsBusy()) { @@ -65,10 +65,10 @@ void DbgConsole::Task() DbgPacket packet = m_dbg_buffer.Pop(); m_console->SetDefaultStyle(packet.m_ch == 1 ? *m_color_red : *m_color_white); m_console->SetInsertionPointEnd(); - m_console->WriteText(packet.m_text); + m_console->WriteText(fmt::FromUTF8(packet.m_text)); if (m_output && Ini.HLESaveTTY.GetValue()) - m_output->Write(packet.m_text); + m_output->Write(fmt::FromUTF8(packet.m_text)); if(!DbgConsole::IsShown()) Show(); } diff --git a/rpcs3/Emu/DbgConsole.h b/rpcs3/Emu/DbgConsole.h index 31f3d69038..d432a4cbf2 100644 --- a/rpcs3/Emu/DbgConsole.h +++ b/rpcs3/Emu/DbgConsole.h @@ -3,9 +3,9 @@ struct DbgPacket { int m_ch; - wxString m_text; + std::string m_text; - DbgPacket(int ch, const wxString& text) + DbgPacket(int ch, const std::string& text) : m_ch(ch) , m_text(text) { @@ -17,7 +17,7 @@ struct DbgPacket void Clear() { - m_text.Clear(); + m_text.clear(); } }; @@ -29,7 +29,7 @@ struct _DbgBuffer : public MTPacketBuffer void _push(const DbgPacket& data) { - const u32 stext = data.m_text.Len(); + const u32 stext = data.m_text.length(); m_buffer.Reserve(sizeof(int) + sizeof(u32) + stext); @@ -40,7 +40,7 @@ struct _DbgBuffer : public MTPacketBuffer memcpy(&m_buffer[c_put], &stext, sizeof(u32)); c_put += sizeof(u32); - memcpy(&m_buffer[c_put], static_cast(data.m_text), stext); + memcpy(&m_buffer[c_put], data.m_text.data(), stext); c_put += stext; m_put = c_put; @@ -58,7 +58,7 @@ struct _DbgBuffer : public MTPacketBuffer const u32& stext = *(u32*)&m_buffer[c_get]; c_get += sizeof(u32); - if (stext) ret.m_text = wxString(reinterpret_cast(&m_buffer[c_get]), stext ); + if (stext) ret.m_text = std::string(reinterpret_cast(&m_buffer[c_get]), stext ); c_get += stext; m_get = c_get; @@ -81,7 +81,7 @@ class DbgConsole public: DbgConsole(); ~DbgConsole(); - void Write(int ch, const wxString& text); + void Write(int ch, const std::string& text); void Clear(); virtual void Task(); diff --git a/rpcs3/Emu/FS/VFS.cpp b/rpcs3/Emu/FS/VFS.cpp index 38ee1197b8..ee49e89f53 100644 --- a/rpcs3/Emu/FS/VFS.cpp +++ b/rpcs3/Emu/FS/VFS.cpp @@ -8,13 +8,13 @@ int sort_devices(const void* _a, const void* _b) const vfsDevice& a = **(const vfsDevice**)_a; const vfsDevice& b = **(const vfsDevice**)_b; - if(a.GetPs3Path().Len() > b.GetPs3Path().Len()) return 1; - if(a.GetPs3Path().Len() < b.GetPs3Path().Len()) return -1; + if(a.GetPs3Path().length() > b.GetPs3Path().length()) return 1; + if(a.GetPs3Path().length() < b.GetPs3Path().length()) return -1; return 0; } -void VFS::Mount(const wxString& ps3_path, const wxString& local_path, vfsDevice* device) +void VFS::Mount(const std::string& ps3_path, const std::string& local_path, vfsDevice* device) { UnMount(ps3_path); @@ -27,11 +27,11 @@ void VFS::Mount(const wxString& ps3_path, const wxString& local_path, vfsDevice* } } -void VFS::UnMount(const wxString& ps3_path) +void VFS::UnMount(const std::string& ps3_path) { for(u32 i=0; iGetNewFileStream()) @@ -65,9 +65,9 @@ vfsFileBase* VFS::OpenFile(const wxString& ps3_path, vfsOpenMode mode) const return nullptr; } -vfsDirBase* VFS::OpenDir(const wxString& ps3_path) const +vfsDirBase* VFS::OpenDir(const std::string& ps3_path) const { - wxString path; + std::string path; if(vfsDevice* dev = GetDevice(ps3_path, path)) { @@ -81,9 +81,9 @@ vfsDirBase* VFS::OpenDir(const wxString& ps3_path) const return nullptr; } -bool VFS::CreateFile(const wxString& ps3_path) const +bool VFS::CreateFile(const std::string& ps3_path) const { - wxString path; + std::string path; if(vfsDevice* dev = GetDevice(ps3_path, path)) { std::shared_ptr res(dev->GetNewFileStream()); @@ -97,9 +97,9 @@ bool VFS::CreateFile(const wxString& ps3_path) const return false; } -bool VFS::CreateDir(const wxString& ps3_path) const +bool VFS::CreateDir(const std::string& ps3_path) const { - wxString path; + std::string path; if(vfsDevice* dev = GetDevice(ps3_path, path)) { std::shared_ptr res(dev->GetNewDirStream()); @@ -113,9 +113,9 @@ bool VFS::CreateDir(const wxString& ps3_path) const return false; } -bool VFS::RemoveFile(const wxString& ps3_path) const +bool VFS::RemoveFile(const std::string& ps3_path) const { - wxString path; + std::string path; if(vfsDevice* dev = GetDevice(ps3_path, path)) { std::shared_ptr res(dev->GetNewFileStream()); @@ -129,9 +129,9 @@ bool VFS::RemoveFile(const wxString& ps3_path) const return false; } -bool VFS::RemoveDir(const wxString& ps3_path) const +bool VFS::RemoveDir(const std::string& ps3_path) const { - wxString path; + std::string path; if(vfsDevice* dev = GetDevice(ps3_path, path)) { std::shared_ptr res(dev->GetNewDirStream()); @@ -145,9 +145,9 @@ bool VFS::RemoveDir(const wxString& ps3_path) const return false; } -bool VFS::ExistsFile(const wxString& ps3_path) const +bool VFS::ExistsFile(const std::string& ps3_path) const { - wxString path; + std::string path; if(vfsDevice* dev = GetDevice(ps3_path, path)) { std::shared_ptr res(dev->GetNewFileStream()); @@ -161,9 +161,9 @@ bool VFS::ExistsFile(const wxString& ps3_path) const return false; } -bool VFS::ExistsDir(const wxString& ps3_path) const +bool VFS::ExistsDir(const std::string& ps3_path) const { - wxString path; + std::string path; if(vfsDevice* dev = GetDevice(ps3_path, path)) { std::shared_ptr res(dev->GetNewDirStream()); @@ -177,9 +177,9 @@ bool VFS::ExistsDir(const wxString& ps3_path) const return false; } -bool VFS::RenameFile(const wxString& ps3_path_from, const wxString& ps3_path_to) const +bool VFS::RenameFile(const std::string& ps3_path_from, const std::string& ps3_path_to) const { - wxString path; + std::string path; if(vfsDevice* dev = GetDevice(ps3_path_from, path)) { std::shared_ptr res(dev->GetNewFileStream()); @@ -193,9 +193,9 @@ bool VFS::RenameFile(const wxString& ps3_path_from, const wxString& ps3_path_to) return false; } -bool VFS::RenameDir(const wxString& ps3_path_from, const wxString& ps3_path_to) const +bool VFS::RenameDir(const std::string& ps3_path_from, const std::string& ps3_path_to) const { - wxString path; + std::string path; if(vfsDevice* dev = GetDevice(ps3_path_from, path)) { std::shared_ptr res(dev->GetNewDirStream()); @@ -209,7 +209,7 @@ bool VFS::RenameDir(const wxString& ps3_path_from, const wxString& ps3_path_to) return false; } -vfsDevice* VFS::GetDevice(const wxString& ps3_path, wxString& path) const +vfsDevice* VFS::GetDevice(const std::string& ps3_path, std::string& path) const { u32 max_eq; s32 max_i=-1; @@ -226,18 +226,18 @@ vfsDevice* VFS::GetDevice(const wxString& ps3_path, wxString& path) const } if(max_i < 0) return nullptr; - path = vfsDevice::GetWinPath(m_devices[max_i].GetLocalPath(), ps3_path(max_eq, ps3_path.Len() - max_eq)); + path = vfsDevice::GetWinPath(m_devices[max_i].GetLocalPath(), ps3_path.substr(max_eq, ps3_path.length() - max_eq)); return &m_devices[max_i]; } -vfsDevice* VFS::GetDeviceLocal(const wxString& local_path, wxString& path) const +vfsDevice* VFS::GetDeviceLocal(const std::string& local_path, std::string& path) const { u32 max_eq; s32 max_i=-1; - wxFileName file_path(local_path); + wxFileName file_path(fmt::FromUTF8(local_path)); file_path.Normalize(); - wxString mormalized_path = file_path.GetFullPath(); + std::string mormalized_path = fmt::ToUTF8(file_path.GetFullPath()); for(u32 i=0; i& res, bool is_load) for(int i=0; i entry_path; - IniEntry entry_device_path; - IniEntry entry_mount; + IniEntry entry_path; + IniEntry entry_device_path; + IniEntry entry_mount; IniEntry entry_device; - entry_path.Init(wxString::Format("path[%d]", i), "VFSManager"); - entry_device_path.Init(wxString::Format("device_path[%d]", i), "VFSManager"); - entry_mount.Init(wxString::Format("mount[%d]", i), "VFSManager"); - entry_device.Init(wxString::Format("device[%d]", i), "VFSManager"); + entry_path.Init(fmt::Format("path[%d]", i), "VFSManager"); + entry_device_path.Init(fmt::Format("device_path[%d]", i), "VFSManager"); + entry_mount.Init(fmt::Format("mount[%d]", i), "VFSManager"); + entry_device.Init(fmt::Format("device[%d]", i), "VFSManager"); if(is_load) { res[i] = VFSManagerEntry(); - 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].path = entry_path.LoadValue(""); + res[i].device_path = entry_device_path.LoadValue(""); + res[i].mount = entry_mount.LoadValue(""); res[i].device = (vfsDeviceType)entry_device.LoadValue(vfsDevice_LocalFile); } else diff --git a/rpcs3/Emu/FS/VFS.h b/rpcs3/Emu/FS/VFS.h index f624ba6892..f88a8321e0 100644 --- a/rpcs3/Emu/FS/VFS.h +++ b/rpcs3/Emu/FS/VFS.h @@ -17,9 +17,9 @@ static const char* vfsDeviceTypeNames[] = struct VFSManagerEntry { vfsDeviceType device; - const char* device_path; - const char* path; - const char* mount; + std::string device_path; + std::string path; + std::string mount; VFSManagerEntry() : device(vfsDevice_LocalFile) @@ -29,7 +29,7 @@ struct VFSManagerEntry { } - VFSManagerEntry(const vfsDeviceType& device, const char* path, const char* mount) + VFSManagerEntry(const vfsDeviceType& device, const std::string& path, const std::string& mount) : device(device) , device_path("") , path(path) @@ -42,24 +42,24 @@ struct VFSManagerEntry struct VFS { ArrayF m_devices; - void Mount(const wxString& ps3_path, const wxString& local_path, vfsDevice* device); - void UnMount(const wxString& ps3_path); + void Mount(const std::string& ps3_path, const std::string& local_path, vfsDevice* device); + void UnMount(const std::string& ps3_path); void UnMountAll(); - vfsFileBase* OpenFile(const wxString& ps3_path, vfsOpenMode mode) const; - vfsDirBase* OpenDir(const wxString& ps3_path) const; - bool CreateFile(const wxString& ps3_path) const; - bool CreateDir(const wxString& ps3_path) const; - bool RemoveFile(const wxString& ps3_path) const; - bool RemoveDir(const wxString& ps3_path) const; - bool ExistsFile(const wxString& ps3_path) const; - bool ExistsDir(const wxString& ps3_path) const; - bool RenameFile(const wxString& ps3_path_from, const wxString& ps3_path_to) const; - bool RenameDir(const wxString& ps3_path_from, const wxString& ps3_path_to) const; + vfsFileBase* OpenFile(const std::string& ps3_path, vfsOpenMode mode) const; + vfsDirBase* OpenDir(const std::string& ps3_path) const; + bool CreateFile(const std::string& ps3_path) const; + bool CreateDir(const std::string& ps3_path) const; + bool RemoveFile(const std::string& ps3_path) const; + bool RemoveDir(const std::string& ps3_path) const; + bool ExistsFile(const std::string& ps3_path) const; + bool ExistsDir(const std::string& ps3_path) const; + bool RenameFile(const std::string& ps3_path_from, const std::string& ps3_path_to) const; + bool RenameDir(const std::string& ps3_path_from, const std::string& ps3_path_to) const; - vfsDevice* GetDevice(const wxString& ps3_path, wxString& path) const; - vfsDevice* GetDeviceLocal(const wxString& local_path, wxString& path) const; + vfsDevice* GetDevice(const std::string& ps3_path, std::string& path) const; + vfsDevice* GetDeviceLocal(const std::string& local_path, std::string& path) const; - void Init(const wxString& path); + void Init(const std::string& path); void SaveLoadDevices(std::vector& res, bool is_load); }; \ No newline at end of file diff --git a/rpcs3/Emu/FS/vfsDevice.cpp b/rpcs3/Emu/FS/vfsDevice.cpp index d6af3341a7..e1f2ac8cdf 100644 --- a/rpcs3/Emu/FS/vfsDevice.cpp +++ b/rpcs3/Emu/FS/vfsDevice.cpp @@ -1,31 +1,31 @@ #include "stdafx.h" #include "vfsDevice.h" -vfsDevice::vfsDevice(const wxString& ps3_path, const wxString& local_path) +vfsDevice::vfsDevice(const std::string& ps3_path, const std::string& local_path) : m_ps3_path(ps3_path) , m_local_path(GetWinPath(local_path)) { } -wxString vfsDevice::GetLocalPath() const +std::string vfsDevice::GetLocalPath() const { return m_local_path; } -wxString vfsDevice::GetPs3Path() const +std::string vfsDevice::GetPs3Path() const { return m_ps3_path; } -void vfsDevice::SetPath(const wxString& ps3_path, const wxString& local_path) +void vfsDevice::SetPath(const std::string& ps3_path, const std::string& local_path) { m_ps3_path = ps3_path; m_local_path = local_path; } -u32 vfsDevice::CmpPs3Path(const wxString& ps3_path) +u32 vfsDevice::CmpPs3Path(const std::string& ps3_path) { - const u32 lim = min(m_ps3_path.Len(), ps3_path.Len()); + const u32 lim = min(m_ps3_path.length(), ps3_path.length()); u32 ret = 0; for(u32 i=0; i= 0; --i) + for(int i = path.length() - 1, dir = 0; i >= 0; --i) { if(path[i] == '\\' || path[i] == '/' || i == 0) { @@ -100,17 +100,17 @@ wxString vfsDevice::ErasePath(const wxString& path, u32 start_dir_count, u32 end } } - return path(from, to - from); + return path.substr(from, to - from); } -wxString vfsDevice::GetRoot(const wxString& path) +std::string vfsDevice::GetRoot(const std::string& path) { - //return wxFileName(path, wxPATH_UNIX).GetPath(); - if(path.IsEmpty()) return wxEmptyString; + //return fmt::ToUTF8(wxFileName(fmt::FromUTF8(path), wxPATH_UNIX).GetPath()); + if(path.empty()) return ""; - u32 first_dir = path.Len() - 1; + u32 first_dir = path.length() - 1; - for(int i = path.Len() - 1, dir = 0, li = path.Len() - 1; i >= 0 && dir < 2; --i) + for(int i = path.length() - 1, dir = 0, li = path.length() - 1; i >= 0 && dir < 2; --i) { if(path[i] == '\\' || path[i] == '/' || i == 0) { @@ -121,7 +121,7 @@ wxString vfsDevice::GetRoot(const wxString& path) break; case 1: - if(!path(i + 1, li - i).Cmp("USRDIR")) return path(0, i + 1); + if(!path.substr(i + 1, li - i).compare("USRDIR")) return path.substr(0, i + 1); continue; } @@ -129,46 +129,46 @@ wxString vfsDevice::GetRoot(const wxString& path) } } - return path(0, first_dir + 1); + return path.substr(0, first_dir + 1); } -wxString vfsDevice::GetRootPs3(const wxString& path) +std::string vfsDevice::GetRootPs3(const std::string& path) { - if(path.IsEmpty()) return wxEmptyString; + if(path.empty()) return ""; - static const wxString& home = "/dev_hdd0/game/"; + static const std::string home = "/dev_hdd0/game/"; u32 last_dir = 0; - u32 first_dir = path.Len() - 1; + u32 first_dir = path.length() - 1; - for(int i = path.Len() - 1, dir = 0; i >= 0; --i) + for(int i = path.length() - 1, dir = 0; i >= 0; --i) { if(path[i] == '\\' || path[i] == '/' || i == 0) { switch(dir++) { case 1: - if(!!path(i + 1, last_dir - i - 1).Cmp("USRDIR")) return wxEmptyString; + if(path.substr(i + 1, last_dir - i - 1) == "USRDIR") return ""; break; case 2: - return GetPs3Path(home + path(i + 1, last_dir - i - 1)); + return GetPs3Path(home + path.substr(i + 1, last_dir - i - 1)); } last_dir = i; } } - return GetPs3Path(home + path(0, last_dir - 1)); + return GetPs3Path(home + path.substr(0, last_dir - 1)); } -wxString vfsDevice::GetWinPath(const wxString& p, bool is_dir) +std::string vfsDevice::GetWinPath(const std::string& p, bool is_dir) { - if(p.IsEmpty()) return wxEmptyString; + if(p.empty()) return ""; - wxString ret; + std::string ret; bool is_ls = false; - for(u32 i=0; iIsOpened(); } -bool vfsDir::Create(const wxString& path) +bool vfsDir::Create(const std::string& path) { return m_stream->Create(path); } -bool vfsDir::IsExists(const wxString& path) const +bool vfsDir::IsExists(const std::string& path) const { return m_stream->IsExists(path); // Crash (Access violation reading location 0x0000000000000000) } @@ -38,12 +38,12 @@ const Array& vfsDir::GetEntries() const return m_stream->GetEntries(); } -bool vfsDir::Rename(const wxString& from, const wxString& to) +bool vfsDir::Rename(const std::string& from, const std::string& to) { return m_stream->Rename(from, to); } -bool vfsDir::Remove(const wxString& path) +bool vfsDir::Remove(const std::string& path) { return m_stream->Remove(path); } @@ -58,7 +58,7 @@ void vfsDir::Close() m_stream.reset(); } -wxString vfsDir::GetPath() const +std::string vfsDir::GetPath() const { return m_stream->GetPath(); } diff --git a/rpcs3/Emu/FS/vfsDir.h b/rpcs3/Emu/FS/vfsDir.h index 531403c854..3db6d11388 100644 --- a/rpcs3/Emu/FS/vfsDir.h +++ b/rpcs3/Emu/FS/vfsDir.h @@ -8,18 +8,18 @@ private: public: vfsDir(); - vfsDir(const wxString path); + vfsDir(const std::string& path); - virtual bool Open(const wxString& path) override; + virtual bool Open(const std::string& path) override; virtual bool IsOpened() const override; - virtual bool IsExists(const wxString& path) const override; + virtual bool IsExists(const std::string& path) const override; virtual const Array& GetEntries() const override; virtual void Close() override; - virtual wxString GetPath() const override; + virtual std::string GetPath() const override; - virtual bool Create(const wxString& path) override; + virtual bool Create(const std::string& path) override; //virtual bool Create(const DirEntryInfo& info) override; - virtual bool Rename(const wxString& from, const wxString& to) override; - virtual bool Remove(const wxString& path) override; + virtual bool Rename(const std::string& from, const std::string& to) override; + virtual bool Remove(const std::string& path) override; virtual const DirEntryInfo* Read() override; }; \ No newline at end of file diff --git a/rpcs3/Emu/FS/vfsDirBase.cpp b/rpcs3/Emu/FS/vfsDirBase.cpp index 365d1effb6..6589c8b070 100644 --- a/rpcs3/Emu/FS/vfsDirBase.cpp +++ b/rpcs3/Emu/FS/vfsDirBase.cpp @@ -11,7 +11,7 @@ vfsDirBase::~vfsDirBase() { } -bool vfsDirBase::Open(const wxString& path) +bool vfsDirBase::Open(const std::string& path) { if(IsOpened()) Close(); @@ -26,12 +26,12 @@ bool vfsDirBase::Open(const wxString& path) bool vfsDirBase::IsOpened() const { - return !m_cwd.IsEmpty(); + return !m_cwd.empty(); } -bool vfsDirBase::IsExists(const wxString& path) const +bool vfsDirBase::IsExists(const std::string& path) const { - return wxDirExists(path); + return wxDirExists(fmt::FromUTF8(path)); } const Array& vfsDirBase::GetEntries() const @@ -41,11 +41,11 @@ const Array& vfsDirBase::GetEntries() const void vfsDirBase::Close() { - m_cwd = wxEmptyString; + m_cwd = ""; m_entries.Clear(); } -wxString vfsDirBase::GetPath() const +std::string vfsDirBase::GetPath() const { return m_cwd; } diff --git a/rpcs3/Emu/FS/vfsDirBase.h b/rpcs3/Emu/FS/vfsDirBase.h index b6af8e1b62..00549c8e64 100644 --- a/rpcs3/Emu/FS/vfsDirBase.h +++ b/rpcs3/Emu/FS/vfsDirBase.h @@ -12,7 +12,7 @@ enum DirEntryFlags struct DirEntryInfo { - wxString name; + std::string name; u32 flags; time_t create_time; time_t access_time; @@ -30,7 +30,7 @@ struct DirEntryInfo class vfsDirBase { protected: - wxString m_cwd; + std::string m_cwd; Array m_entries; uint m_pos; vfsDevice* m_device; @@ -39,16 +39,16 @@ public: vfsDirBase(vfsDevice* device); virtual ~vfsDirBase(); - virtual bool Open(const wxString& path); + virtual bool Open(const std::string& path); virtual bool IsOpened() const; - virtual bool IsExists(const wxString& path) const; + virtual bool IsExists(const std::string& path) const; virtual const Array& GetEntries() const; virtual void Close(); - virtual wxString GetPath() const; + virtual std::string GetPath() const; - virtual bool Create(const wxString& path)=0; + virtual bool Create(const std::string& path) = 0; //virtual bool Create(const DirEntryInfo& info)=0; - virtual bool Rename(const wxString& from, const wxString& to)=0; - virtual bool Remove(const wxString& path)=0; + virtual bool Rename(const std::string& from, const std::string& to) = 0; + virtual bool Remove(const std::string& path) = 0; virtual const DirEntryInfo* Read(); }; \ No newline at end of file diff --git a/rpcs3/Emu/FS/vfsFile.cpp b/rpcs3/Emu/FS/vfsFile.cpp index 924b4a80ee..96bcbdd483 100644 --- a/rpcs3/Emu/FS/vfsFile.cpp +++ b/rpcs3/Emu/FS/vfsFile.cpp @@ -7,14 +7,14 @@ vfsFile::vfsFile() { } -vfsFile::vfsFile(const wxString path, vfsOpenMode mode) +vfsFile::vfsFile(const std::string& path, vfsOpenMode mode) : vfsFileBase(nullptr) , m_stream(nullptr) { Open(path, mode); } -bool vfsFile::Open(const wxString& path, vfsOpenMode mode) +bool vfsFile::Open(const std::string& path, vfsOpenMode mode) { Close(); @@ -23,22 +23,22 @@ bool vfsFile::Open(const wxString& path, vfsOpenMode mode) return m_stream && m_stream->IsOpened(); } -bool vfsFile::Create(const wxString& path) +bool vfsFile::Create(const std::string& path) { return m_stream->Create(path); } -bool vfsFile::Exists(const wxString& path) +bool vfsFile::Exists(const std::string& path) { return m_stream->Exists(path); } -bool vfsFile::Rename(const wxString& from, const wxString& to) +bool vfsFile::Rename(const std::string& from, const std::string& to) { return m_stream->Rename(from, to); } -bool vfsFile::Remove(const wxString& path) +bool vfsFile::Remove(const std::string& path) { return m_stream->Remove(path); } diff --git a/rpcs3/Emu/FS/vfsFile.h b/rpcs3/Emu/FS/vfsFile.h index 3b2fd102fd..4ab9ddc87d 100644 --- a/rpcs3/Emu/FS/vfsFile.h +++ b/rpcs3/Emu/FS/vfsFile.h @@ -8,13 +8,13 @@ private: public: vfsFile(); - vfsFile(const wxString path, vfsOpenMode mode = vfsRead); + vfsFile(const std::string& path, vfsOpenMode mode = vfsRead); - virtual bool Open(const wxString& path, vfsOpenMode mode = vfsRead) override; - virtual bool Create(const wxString& path) override; - virtual bool Exists(const wxString& path) override; - virtual bool Rename(const wxString& from, const wxString& to) override; - virtual bool Remove(const wxString& path) override; + virtual bool Open(const std::string& path, vfsOpenMode mode = vfsRead) override; + virtual bool Create(const std::string& path) override; + virtual bool Exists(const std::string& path) override; + virtual bool Rename(const std::string& from, const std::string& to) override; + virtual bool Remove(const std::string& path) override; virtual bool Close() override; virtual u64 GetSize() override; diff --git a/rpcs3/Emu/FS/vfsFileBase.cpp b/rpcs3/Emu/FS/vfsFileBase.cpp index 9209bb4619..1cbed18a2c 100644 --- a/rpcs3/Emu/FS/vfsFileBase.cpp +++ b/rpcs3/Emu/FS/vfsFileBase.cpp @@ -12,12 +12,12 @@ vfsFileBase::~vfsFileBase() Close(); } -bool Access(const wxString& path, vfsOpenMode mode) +bool Access(const std::string& path, vfsOpenMode mode) { return false; } -bool vfsFileBase::Open(const wxString& path, vfsOpenMode mode) +bool vfsFileBase::Open(const std::string& path, vfsOpenMode mode) { m_path = path; m_mode = mode; @@ -29,12 +29,12 @@ bool vfsFileBase::Open(const wxString& path, vfsOpenMode mode) bool vfsFileBase::Close() { - m_path = wxEmptyString; + m_path = ""; return vfsStream::Close(); } -wxString vfsFileBase::GetPath() const +std::string vfsFileBase::GetPath() const { return m_path; } diff --git a/rpcs3/Emu/FS/vfsFileBase.h b/rpcs3/Emu/FS/vfsFileBase.h index 78c310dada..a74e05e251 100644 --- a/rpcs3/Emu/FS/vfsFileBase.h +++ b/rpcs3/Emu/FS/vfsFileBase.h @@ -17,7 +17,7 @@ class vfsDevice; struct vfsFileBase : public vfsStream { protected: - wxString m_path; + std::string m_path; vfsOpenMode m_mode; vfsDevice* m_device; @@ -25,13 +25,13 @@ public: vfsFileBase(vfsDevice* device); virtual ~vfsFileBase(); - virtual bool Open(const wxString& path, vfsOpenMode mode); + virtual bool Open(const std::string& path, vfsOpenMode mode); virtual bool Close() override; - virtual bool Create(const wxString& path) { return false; } - virtual bool Exists(const wxString& path) { return false; } - virtual bool Rename(const wxString& from, const wxString& to) { return false; } - virtual bool Remove(const wxString& path) { return false; } + virtual bool Create(const std::string& path) { return false; } + virtual bool Exists(const std::string& path) { return false; } + virtual bool Rename(const std::string& from, const std::string& to) { return false; } + virtual bool Remove(const std::string& path) { return false; } - wxString GetPath() const; + std::string GetPath() const; vfsOpenMode GetOpenMode() const; }; diff --git a/rpcs3/Emu/FS/vfsLocalDir.cpp b/rpcs3/Emu/FS/vfsLocalDir.cpp index 6ae8009a21..676814fcfd 100644 --- a/rpcs3/Emu/FS/vfsLocalDir.cpp +++ b/rpcs3/Emu/FS/vfsLocalDir.cpp @@ -9,7 +9,7 @@ vfsLocalDir::~vfsLocalDir() { } -bool vfsLocalDir::Open(const wxString& path) +bool vfsLocalDir::Open(const std::string& path) { if(!vfsDirBase::Open(path)) return false; @@ -22,10 +22,10 @@ bool vfsLocalDir::Open(const wxString& path) wxString name; for(bool is_ok = dir.GetFirst(&name); is_ok; is_ok = dir.GetNext(&name)) { - wxString dir_path = path + name; + wxString dir_path = fmt::FromUTF8(path) + name; DirEntryInfo& info = m_entries[m_entries.Move(new DirEntryInfo())]; - info.name = name; + info.name = fmt::ToUTF8(name); info.flags |= dir.Exists(dir_path) ? DirEntry_TypeDir : DirEntry_TypeFile; if(wxIsWritable(dir_path)) info.flags |= DirEntry_PermWritable; @@ -36,17 +36,17 @@ bool vfsLocalDir::Open(const wxString& path) return true; } -bool vfsLocalDir::Create(const wxString& path) +bool vfsLocalDir::Create(const std::string& path) { - return wxFileName::Mkdir(path, 0777, wxPATH_MKDIR_FULL); + return wxFileName::Mkdir(fmt::FromUTF8(path), 0777, wxPATH_MKDIR_FULL); } -bool vfsLocalDir::Rename(const wxString& from, const wxString& to) +bool vfsLocalDir::Rename(const std::string& from, const std::string& to) { return false; } -bool vfsLocalDir::Remove(const wxString& path) +bool vfsLocalDir::Remove(const std::string& path) { - return wxRmdir(path); + return wxRmdir(fmt::FromUTF8(path)); } diff --git a/rpcs3/Emu/FS/vfsLocalDir.h b/rpcs3/Emu/FS/vfsLocalDir.h index 56aa176756..4120b12f41 100644 --- a/rpcs3/Emu/FS/vfsLocalDir.h +++ b/rpcs3/Emu/FS/vfsLocalDir.h @@ -10,9 +10,9 @@ public: vfsLocalDir(vfsDevice* device); virtual ~vfsLocalDir(); - virtual bool Open(const wxString& path) override; + virtual bool Open(const std::string& path) override; - virtual bool Create(const wxString& path) override; - virtual bool Rename(const wxString& from, const wxString& to) override; - virtual bool Remove(const wxString& path) override; + virtual bool Create(const std::string& path) override; + virtual bool Rename(const std::string& from, const std::string& to) override; + virtual bool Remove(const std::string& path) override; }; \ No newline at end of file diff --git a/rpcs3/Emu/FS/vfsLocalFile.cpp b/rpcs3/Emu/FS/vfsLocalFile.cpp index 104a11942b..3fbb78a8eb 100644 --- a/rpcs3/Emu/FS/vfsLocalFile.cpp +++ b/rpcs3/Emu/FS/vfsLocalFile.cpp @@ -31,50 +31,50 @@ vfsLocalFile::vfsLocalFile(vfsDevice* device) : vfsFileBase(device) { } -bool vfsLocalFile::Open(const wxString& path, vfsOpenMode mode) +bool vfsLocalFile::Open(const std::string& path, vfsOpenMode mode) { Close(); // if(m_device) // { - // if(!m_file.Access(vfsDevice::GetWinPath(m_device->GetLocalPath(), path), vfs2wx_mode(mode))) return false; + // if(!m_file.Access(fmt::FromUTF8(vfsDevice::GetWinPath(m_device->GetLocalPath(), path)), vfs2wx_mode(mode))) return false; - // return m_file.Open(vfsDevice::GetWinPath(m_device->GetLocalPath(), path), vfs2wx_mode(mode)) && - // vfsFileBase::Open(vfsDevice::GetPs3Path(m_device->GetPs3Path(), path), mode); + // return m_file.Open(fmt::FromUTF8(vfsDevice::GetWinPath(m_device->GetLocalPath(), path)), vfs2wx_mode(mode)) && + // vfsFileBase::Open(fmt::FromUTF8(vfsDevice::GetPs3Path(m_device->GetPs3Path(), path)), mode); // } // else // { - if(!m_file.Access(path, vfs2wx_mode(mode))) return false; + if(!m_file.Access(fmt::FromUTF8(path), vfs2wx_mode(mode))) return false; - return m_file.Open(path, vfs2wx_mode(mode)) && vfsFileBase::Open(path, mode); + return m_file.Open(fmt::FromUTF8(path), vfs2wx_mode(mode)) && vfsFileBase::Open(path, mode); // } } -bool vfsLocalFile::Create(const wxString& path) +bool vfsLocalFile::Create(const std::string& path) { - ConLog.Warning("vfsLocalFile::Create('%s')", path.wx_str()); - for(uint p=1; p < path.Len() && path[p] != '\0' ; p++) + ConLog.Warning("vfsLocalFile::Create('%s')", path.c_str()); + for(uint p=1; p < path.length() && path[p] != '\0' ; p++) { - for(; p < path.Len() && path[p] != '\0'; p++) + for(; p < path.length() && path[p] != '\0'; p++) if(path[p] == '/' || path[p] == '\\') break; // ??? - if(p == path.Len() || path[p] == '\0') + if(p == path.length() || path[p] == '\0') break; - const wxString& dir = path(0, p); - if(!wxDirExists(dir)) + const std::string& dir = path.substr(0, p); + if(!wxDirExists(fmt::FromUTF8(dir))) { - ConLog.Write("create dir: %s", dir.wx_str()); - wxMkdir(dir); + ConLog.Write("create dir: %s", dir.c_str()); + wxMkdir(fmt::FromUTF8(dir)); } } //create file - wxString m = path(path.Len() - 1, 1); - if(m != '/' && m != '\\' && !wxFileExists(path)) // ??? + const char m = path[path.length() - 1]; + if(m != '/' && m != '\\' && !wxFileExists(fmt::FromUTF8(path))) // ??? { wxFile f; - return f.Create(path); + return f.Create(fmt::FromUTF8(path)); } return true; diff --git a/rpcs3/Emu/FS/vfsLocalFile.h b/rpcs3/Emu/FS/vfsLocalFile.h index c380d53191..ec0c12d72a 100644 --- a/rpcs3/Emu/FS/vfsLocalFile.h +++ b/rpcs3/Emu/FS/vfsLocalFile.h @@ -9,8 +9,8 @@ private: public: vfsLocalFile(vfsDevice* device); - virtual bool Open(const wxString& path, vfsOpenMode mode = vfsRead) override; - virtual bool Create(const wxString& path) override; + virtual bool Open(const std::string& path, vfsOpenMode mode = vfsRead) override; + virtual bool Create(const std::string& path) override; virtual bool Close() override; virtual u64 GetSize() override; diff --git a/rpcs3/Emu/GS/GCM.h b/rpcs3/Emu/GS/GCM.h index a4d97f8562..c96dfbb9cc 100644 --- a/rpcs3/Emu/GS/GCM.h +++ b/rpcs3/Emu/GS/GCM.h @@ -503,12 +503,12 @@ enum NV3089_IMAGE_IN = 0x0000C40C, }; -static const wxString GetMethodName(const u32 id) +static const std::string GetMethodName(const u32 id) { struct MethodName { const u32 id; - const wxString& name; + const std::string& name; } static const METHOD_NAME_LIST[] = { { NV4097_NO_OPERATION , "NoOperation" } , { NV4097_NOTIFY , "Notify" } , @@ -1206,5 +1206,5 @@ static const wxString GetMethodName(const u32 id) if(METHOD_NAME_LIST[i].id == id) return "cellGcm" + METHOD_NAME_LIST[i].name; } - return wxString::Format("unknown/illegal method [0x%08x]", id); + return fmt::Format("unknown/illegal method [0x%08x]", id); } \ No newline at end of file diff --git a/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp b/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp index b79097942e..65d86ffd58 100644 --- a/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp @@ -59,7 +59,7 @@ void GLFragmentDecompilerThread::AddCode(std::string code, bool append_mask) case 7: code = "(" + code + " / 8)"; break; default: - ConLog.Error("Bad scale: %d", src1.scale); + ConLog.Error("Bad scale: %d", fmt::by_value(src1.scale)); Emu.Pause(); break; } @@ -186,7 +186,7 @@ template std::string GLFragmentDecompilerThread::GetSRC(T src) } else { - ConLog.Error("Bad src reg num: %d", dst.src_attr_reg_num); + ConLog.Error("Bad src reg num: %d", fmt::by_value(dst.src_attr_reg_num)); ret += m_parr.AddParam(PARAM_IN, "vec4", "unk"); Emu.Pause(); } @@ -200,7 +200,7 @@ template std::string GLFragmentDecompilerThread::GetSRC(T src) break; default: - ConLog.Error("Bad src type %d", src.reg_type); + ConLog.Error("Bad src type %d", fmt::by_value(src.reg_type)); Emu.Pause(); break; } @@ -223,7 +223,7 @@ template std::string GLFragmentDecompilerThread::GetSRC(T src) std::string GLFragmentDecompilerThread::BuildCode() { - //main += wxString::Format("\tgl_FragColor = %c0;\n", m_ctrl & 0x40 ? 'r' : 'h'); + //main += fmt::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"; @@ -420,7 +420,7 @@ void GLShaderProgram::Compile() GLsizei len; memset(buf, 0, r+1); glGetShaderInfoLog(id, r, &len, buf); - ConLog.Error("Failed to compile shader: %s", wxString(buf).wx_str()); + ConLog.Error("Failed to compile shader: %s", buf); delete[] buf; } diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index dd849d4623..a8831ba806 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -23,10 +23,14 @@ void printGlError(GLenum err, const char* situation) { if(err != GL_NO_ERROR) { - ConLog.Error("%s: opengl error 0x%04x", wxString(situation).wx_str(), err); + ConLog.Error("%s: opengl error 0x%04x", situation, err); Emu.Pause(); } } +void printGlError(GLenum err, const std::string& situation) +{ + printGlError(err, situation.c_str()); +} #if 0 #define checkForGlError(x) /*x*/ @@ -316,13 +320,13 @@ void GLGSRender::InitVertexData() for(u32 i=0; ioffset, c.x, c.y, c.z, c.w); - const wxString name = wxString::Format("fc%u", id); + const std::string name = fmt::Format("fc%u", id); const int l = m_program.GetLocation(name); checkForGlError("glGetUniformLocation " + name); glUniform4f(l, c.x, c.y, c.z, c.w); - checkForGlError("glUniform4f " + name + wxString::Format(" %d [%f %f %f %f]", l, c.x, c.y, c.z, c.w)); + checkForGlError("glUniform4f " + name + fmt::Format(" %d [%f %f %f %f]", l, c.x, c.y, c.z, c.w)); } //if(m_fragment_constants.GetCount()) @@ -735,7 +739,7 @@ void GLGSRender::ExecCMD() for(int i=0; i<4; ++i) { m_fbo.Renderbuffer(GL_COLOR_ATTACHMENT0 + i, m_rbo.GetId(i)); - checkForGlError(wxString::Format("m_fbo.Renderbuffer(GL_COLOR_ATTACHMENT%d)", i)); + checkForGlError(fmt::Format("m_fbo.Renderbuffer(GL_COLOR_ATTACHMENT%d)", i)); } m_fbo.Renderbuffer(GL_DEPTH_ATTACHMENT, m_rbo.GetId(4)); @@ -1044,10 +1048,10 @@ void GLGSRender::ExecCMD() checkForGlError("glActiveTexture"); m_gl_textures[i].Create(); m_gl_textures[i].Bind(); - checkForGlError(wxString::Format("m_gl_textures[%d].Bind", i)); + checkForGlError(fmt::Format("m_gl_textures[%d].Bind", i)); m_program.SetTex(i); m_gl_textures[i].Init(m_textures[i]); - checkForGlError(wxString::Format("m_gl_textures[%d].Init", i)); + checkForGlError(fmt::Format("m_gl_textures[%d].Init", i)); } m_vao.Bind(); diff --git a/rpcs3/Emu/GS/GL/GLGSRender.h b/rpcs3/Emu/GS/GL/GLGSRender.h index 37f8d8e41a..c0aee1dcb5 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.h +++ b/rpcs3/Emu/GS/GL/GLGSRender.h @@ -11,6 +11,7 @@ extern GLenum g_last_gl_error; void printGlError(GLenum err, const char* situation); +void printGlError(GLenum err, const std::string& situation); u32 LinearToSwizzleAddress(u32 x, u32 y, u32 z, u32 log2_width, u32 log2_height, u32 log2_depth); #if RSX_DEBUG @@ -171,7 +172,7 @@ public: break; default: ConLog.Error("Init tex error: Bad tex format (0x%x | %s | 0x%x)", format, - wxString(is_swizzled ? "swizzled" : "linear").wx_str(), tex.GetFormat() & 0x40); break; + (is_swizzled ? "swizzled" : "linear"), tex.GetFormat() & 0x40); break; } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, tex.GetMipmap() - 1); diff --git a/rpcs3/Emu/GS/GL/GLProgram.cpp b/rpcs3/Emu/GS/GL/GLProgram.cpp index ed044a6591..75d4087bd9 100644 --- a/rpcs3/Emu/GS/GL/GLProgram.cpp +++ b/rpcs3/Emu/GS/GL/GLProgram.cpp @@ -6,11 +6,11 @@ GLProgram::GLProgram() : id(0) { } -int GLProgram::GetLocation(const wxString& name) +int GLProgram::GetLocation(const std::string& name) { for(u32 i=0; i m_locations; @@ -18,7 +18,7 @@ public: GLProgram(); - int GetLocation(const wxString& name); + int GetLocation(const std::string& name); bool IsCreated() const; void Create(const u32 vp, const u32 fp); void Use(); diff --git a/rpcs3/Emu/GS/GL/GLProgramBuffer.cpp b/rpcs3/Emu/GS/GL/GLProgramBuffer.cpp index 4ca63b9d6d..a4d4a63e4f 100644 --- a/rpcs3/Emu/GS/GL/GLProgramBuffer.cpp +++ b/rpcs3/Emu/GS/GL/GLProgramBuffer.cpp @@ -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.wx_str()); - ConLog.Write("*** fp shader = \n%s", wxString(gl_fp.shader).wx_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; diff --git a/rpcs3/Emu/GS/GL/GLVertexProgram.cpp b/rpcs3/Emu/GS/GL/GLVertexProgram.cpp index 323ff04c61..567f608618 100644 --- a/rpcs3/Emu/GS/GL/GLVertexProgram.cpp +++ b/rpcs3/Emu/GS/GL/GLVertexProgram.cpp @@ -1,9 +1,9 @@ #include "stdafx.h" #include "GLVertexProgram.h" -wxString GLVertexDecompilerThread::GetMask(bool is_sca) +std::string GLVertexDecompilerThread::GetMask(bool is_sca) { - wxString ret = wxEmptyString; + std::string ret; if(is_sca) { @@ -20,20 +20,20 @@ wxString GLVertexDecompilerThread::GetMask(bool is_sca) if(d3.vec_writemask_w) ret += "w"; } - return ret.IsEmpty() || ret == "xyzw" ? wxString(wxEmptyString) : ("." + ret); + return ret.empty() || ret == "xyzw" ? "" : ("." + ret); } -wxString GLVertexDecompilerThread::GetVecMask() +std::string GLVertexDecompilerThread::GetVecMask() { return GetMask(false); } -wxString GLVertexDecompilerThread::GetScaMask() +std::string GLVertexDecompilerThread::GetScaMask() { return GetMask(true); } -wxString GLVertexDecompilerThread::GetDST(bool isSca) +std::string GLVertexDecompilerThread::GetDST(bool isSca) { static const std::string reg_table[] = { @@ -45,7 +45,7 @@ wxString GLVertexDecompilerThread::GetDST(bool isSca) "tc0", "tc1", "tc2", "tc3", "tc4", "tc5", "tc6", "tc7" }; - wxString ret = wxEmptyString; + std::string ret; switch(isSca ? 0x1f : d3.dst) { @@ -64,7 +64,7 @@ wxString GLVertexDecompilerThread::GetDST(bool isSca) } else { - ConLog.Error("Bad dst reg num: %d", d3.dst); + ConLog.Error("Bad dst reg num: %d", fmt::by_value(d3.dst)); ret += m_parr.AddParam(PARAM_OUT, "vec4", "unk"); } break; @@ -73,7 +73,7 @@ wxString GLVertexDecompilerThread::GetDST(bool isSca) return ret; } -wxString GLVertexDecompilerThread::GetSRC(const u32 n, bool isSca) +std::string GLVertexDecompilerThread::GetSRC(const u32 n, bool isSca) { static const std::string reg_table[] = { @@ -85,7 +85,7 @@ wxString GLVertexDecompilerThread::GetSRC(const u32 n, bool isSca) "in_tc4", "in_tc5", "in_tc6", "in_tc7" }; - wxString ret = wxEmptyString; + std::string ret; switch(src[n].reg_type) { @@ -99,7 +99,7 @@ wxString GLVertexDecompilerThread::GetSRC(const u32 n, bool isSca) } else { - ConLog.Error("Bad input src num: %d", d1.input_src); + ConLog.Error("Bad input src num: %d", fmt::by_value(d1.input_src)); ret += m_parr.AddParam(PARAM_IN, "vec4", "in_unk", d1.input_src); } break; @@ -108,12 +108,12 @@ wxString GLVertexDecompilerThread::GetSRC(const u32 n, bool isSca) break; default: - ConLog.Error("Bad src%u reg type: %d", n, src[n].reg_type); + ConLog.Error("Bad src%u reg type: %d", n, fmt::by_value(src[n].reg_type)); Emu.Pause(); break; } - static const wxString f = "xyzw"; + static const std::string f = "xyzw"; if (isSca) { @@ -126,7 +126,7 @@ wxString GLVertexDecompilerThread::GetSRC(const u32 n, bool isSca) } else { - wxString swizzle = wxEmptyString; + std::string swizzle; swizzle += f[src[n].swz_x]; swizzle += f[src[n].swz_y]; @@ -151,8 +151,9 @@ wxString GLVertexDecompilerThread::GetSRC(const u32 n, bool isSca) return ret; } -void GLVertexDecompilerThread::AddCode(bool is_sca, wxString code, bool src_mask, bool set_dst, bool set_cond) +void GLVertexDecompilerThread::AddCode(bool is_sca, const std::string& pCode, bool src_mask, bool set_dst, bool set_cond) { + std::string code = pCode; if(d0.cond == 0) return; enum { @@ -173,7 +174,7 @@ void GLVertexDecompilerThread::AddCode(bool is_sca, wxString code, bool src_mask "error" }; - wxString cond; + std::string cond; if((set_cond || d0.cond_test_enable) && d0.cond != (lt | gt | eq)) { @@ -187,11 +188,11 @@ void GLVertexDecompilerThread::AddCode(bool is_sca, wxString code, bool src_mask swizzle = swizzle == "xyzw" ? "" : "." + swizzle; - cond = wxString::Format("if(all(%s(rc%s, vec4(0.0)%s))) ", wxString(cond_string_table[d0.cond]).wx_str(), wxString(swizzle).wx_str(), wxString(swizzle).wx_str()); + cond = fmt::Format("if(all(%s(rc%s, vec4(0.0)%s))) ", cond_string_table[d0.cond], swizzle.c_str(), swizzle.c_str()); } - wxString mask = GetMask(is_sca); - wxString value = src_mask ? code + mask : code; + std::string mask = GetMask(is_sca); + std::string value = src_mask ? code + mask : code; if(is_sca && d0.vec_result) { @@ -205,7 +206,7 @@ void GLVertexDecompilerThread::AddCode(bool is_sca, wxString code, bool src_mask if(set_dst) { - wxString dest; + std::string dest; if(d0.cond_update_enable_0) { dest = m_parr.AddParam(PARAM_NONE, "vec4", "rc", "vec4(0.0)") + mask; @@ -224,7 +225,7 @@ void GLVertexDecompilerThread::AddCode(bool is_sca, wxString code, bool src_mask if(d3.vec_writemask_z) num += 1; else if(d3.vec_writemask_w) num += 2; - dest = wxString::Format(GetDST(is_sca) + "/*" + mask + "*/", num); + dest = fmt::Format(GetDST(is_sca) + "/*" + mask + "*/", num); } } else @@ -239,17 +240,17 @@ void GLVertexDecompilerThread::AddCode(bool is_sca, wxString code, bool src_mask code = cond + value; } - m_body.Add(code + ";"); + m_body.push_back(code + ";"); } -wxString GLVertexDecompilerThread::GetFunc() +std::string GLVertexDecompilerThread::GetFunc() { u32 offset = (d2.iaddrh << 3) | d3.iaddrl; - wxString name = wxString::Format("func%u", offset); + std::string name = fmt::Format("func%u", offset); for(uint i=0; i0; --i) { - fp += wxString::Format("void %s();\n", m_funcs[i].name.wx_str()); + fp += fmt::Format("void %s();\n", m_funcs[i].name.c_str()); } - wxString f = wxEmptyString; + std::string f; - f += wxString::Format("void %s()\n{\n\tgl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n\t%s();\n\tgl_Position = gl_Position * scaleOffsetMat;\n}\n", - m_funcs[0].name.wx_str(), m_funcs[1].name.wx_str()); + f += fmt::Format("void %s()\n{\n\tgl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n\t%s();\n\tgl_Position = gl_Position * scaleOffsetMat;\n}\n", + m_funcs[0].name.c_str(), m_funcs[1].name.c_str()); for(uint i=1; i m_body; ArrayF m_funcs; //wxString main; - wxString& m_shader; + std::string& m_shader; Array& m_data; GLParamArray& m_parr; - GLVertexDecompilerThread(Array& data, wxString& shader, GLParamArray& parr) + GLVertexDecompilerThread(Array& data, std::string& shader, GLParamArray& parr) : ThreadBase("Vertex Shader Decompiler Thread") , m_data(data) , m_shader(shader) @@ -157,17 +157,17 @@ struct GLVertexDecompilerThread : public ThreadBase //m_cur_func->body = "\tgl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n"; } - wxString GetMask(bool is_sca); - wxString GetVecMask(); - wxString GetScaMask(); - wxString GetDST(bool is_sca = false); - wxString GetSRC(const u32 n, bool is_sca = false); - wxString GetFunc(); - void AddCode(bool is_sca, wxString code, bool src_mask = true, bool set_dst = true, bool set_cond = true); - void AddVecCode(const wxString& code, bool src_mask = true, bool set_dst = true); - void AddScaCode(const wxString& code, bool set_dst = true, bool set_cond = true); - wxString BuildFuncBody(const FuncInfo& func); - wxString BuildCode(); + std::string GetMask(bool is_sca); + std::string GetVecMask(); + std::string GetScaMask(); + std::string GetDST(bool is_sca = false); + std::string GetSRC(const u32 n, bool is_sca = false); + std::string GetFunc(); + void AddCode(bool is_sca, const std::string& code, bool src_mask = true, bool set_dst = true, bool set_cond = true); + void AddVecCode(const std::string& code, bool src_mask = true, bool set_dst = true); + void AddScaCode(const std::string& code, bool set_dst = true, bool set_cond = true); + std::string BuildFuncBody(const FuncInfo& func); + std::string BuildCode(); virtual void Task(); }; @@ -181,7 +181,7 @@ struct GLVertexProgram GLParamArray parr; u32 id; - wxString shader; + std::string shader; void Wait() { diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index af7402cab9..56bebee980 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -105,9 +105,9 @@ u32 RSXVertexData::GetTypeSize() u32 RSXThread::OutOfArgsCount(const uint x, const u32 cmd, const u32 count) { - wxString debug = GetMethodName(cmd); + std::string debug = GetMethodName(cmd); debug += "("; - for(u32 i=0; i(GetMaxNameLen() - 1, name.Len() + 1)); + m_hdd.Write(name.c_str(), min(GetMaxNameLen() - 1, name.length() + 1)); } __forceinline u32 GetMaxNameLen() const @@ -424,13 +426,13 @@ class vfsHDD : public vfsFileBase { vfsHDD_Hdr m_hdd_info; vfsLocalFile m_hdd_file; - const wxString& m_hdd_path; + const std::string& m_hdd_path; vfsHDD_Entry m_cur_dir; u64 m_cur_dir_block; vfsHDDFile m_file; public: - vfsHDD(vfsDevice* device, const wxString& hdd_path) + vfsHDD(vfsDevice* device, const std::string& hdd_path) : m_hdd_file(device) , m_file(m_hdd_file, m_hdd_info) , m_hdd_path(hdd_path) @@ -453,18 +455,18 @@ public: return m_hdd_info.block_size - sizeof(vfsHDD_Entry); } - bool SearchEntry(const wxString& name, u64& entry_block, u64* parent_block = nullptr) + bool SearchEntry(const std::string& name, u64& entry_block, u64* parent_block = nullptr) { u64 last_block = 0; u64 block = m_cur_dir_block; vfsHDD_Entry entry; - wxString buf; + std::string buf; while(block) { ReadEntry(block, entry, buf); - if(name.CmpNoCase(buf) == 0) + if (fmt::CmpNoCase(name,buf) == 0) { entry_block = block; if(parent_block) @@ -480,9 +482,9 @@ public: return false; } - int OpenDir(const wxString& name) + int OpenDir(const std::string& name) { - ConLog.Warning("OpenDir(%s)", name.wx_str()); + ConLog.Warning("OpenDir(%s)", name.c_str()); u64 entry_block; if(!SearchEntry(name, entry_block)) return -1; @@ -499,7 +501,7 @@ public: return 0; } - bool Rename(const wxString& from, const wxString& to) + bool Rename(const std::string& from, const std::string& to) { u64 entry_block; if(!SearchEntry(from, entry_block)) @@ -555,27 +557,29 @@ public: m_hdd_file.Read(&data, sizeof(vfsHDD_Entry)); } - void ReadEntry(u64 block, vfsHDD_Entry& data, wxString& name) + void ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name) { m_hdd_file.Seek(block * m_hdd_info.block_size); m_hdd_file.Read(&data, sizeof(vfsHDD_Entry)); - m_hdd_file.Read(wxStringBuffer(name, GetMaxNameLen()), GetMaxNameLen()); + name.resize(GetMaxNameLen()); + m_hdd_file.Read(&name.front(), GetMaxNameLen()); } - void ReadEntry(u64 block, wxString& name) + void ReadEntry(u64 block, std::string& name) { m_hdd_file.Seek(block * m_hdd_info.block_size + sizeof(vfsHDD_Entry)); - m_hdd_file.Read(wxStringBuffer(name, GetMaxNameLen()), GetMaxNameLen()); + name.resize(GetMaxNameLen()); + m_hdd_file.Read(&name.front(), GetMaxNameLen()); } - void WriteEntry(u64 block, const vfsHDD_Entry& data, const wxString& name) + void WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name) { m_hdd_file.Seek(block * m_hdd_info.block_size); m_hdd_file.Write(&data, sizeof(vfsHDD_Entry)); - m_hdd_file.Write(name.c_str(), min(GetMaxNameLen() - 1, name.Len() + 1)); + m_hdd_file.Write(name.c_str(), min(GetMaxNameLen() - 1, name.length() + 1)); } - bool Create(vfsHDD_EntryType type, const wxString& name) + bool Create(vfsHDD_EntryType type, const std::string& name) { if(HasEntry(name)) { @@ -659,7 +663,7 @@ public: return true; } - bool GetFirstEntry(u64& block, vfsHDD_Entry& entry, wxString& name) + bool GetFirstEntry(u64& block, vfsHDD_Entry& entry, std::string& name) { if(!m_cur_dir_block) { @@ -672,7 +676,7 @@ public: return true; } - bool GetNextEntry(u64& block, vfsHDD_Entry& entry, wxString& name) + bool GetNextEntry(u64& block, vfsHDD_Entry& entry, std::string& name) { if(!block) { @@ -685,7 +689,7 @@ public: return true; } - virtual bool Open(const wxString& path, vfsOpenMode mode = vfsRead) + virtual bool Open(const std::string& path, vfsOpenMode mode = vfsRead) { const char* s = path.c_str(); u64 from = 0; @@ -705,7 +709,7 @@ public: { if(pos - from > 1) { - int res = OpenDir(wxString(s + from, pos)); + int res = OpenDir(std::string(s + from, pos)); if(res == -1) { return false; @@ -733,7 +737,7 @@ public: } u64 file_block; - if(!SearchEntry(wxString(s + file_pos), file_block)) + if(!SearchEntry(std::string(s + file_pos), file_block)) { return false; } @@ -744,7 +748,7 @@ public: return vfsFileBase::Open(path, mode); } - bool HasEntry(const wxString& name) + bool HasEntry(const std::string& name) { u64 file_block; if(!SearchEntry(name, file_block)) @@ -757,7 +761,7 @@ public: void RemoveBlocksDir(u64 start_block) { - wxString name; + std::string name; u64 block = start_block; vfsHDD_Entry entry; @@ -768,7 +772,7 @@ public: if(entry.type == vfsHDD_Entry_Dir && name != "." && name != "..") { - ConLog.Warning("Removing sub folder '%s'", name.wx_str()); + ConLog.Warning("Removing sub folder '%s'", name.c_str()); RemoveBlocksDir(entry.data_block); } else if(entry.type == vfsHDD_Entry_File) @@ -794,7 +798,7 @@ public: } } - bool RemoveEntry(const wxString& name) + bool RemoveEntry(const std::string& name) { u64 entry_block, parent_entry; if(!SearchEntry(name, entry_block, &parent_entry)) @@ -824,7 +828,7 @@ public: return true; } - virtual bool Create(const wxString& path) + virtual bool Create(const std::string& path) { return false; } diff --git a/rpcs3/Emu/Memory/Memory.h b/rpcs3/Emu/Memory/Memory.h index a7468cb161..e1535e8e82 100644 --- a/rpcs3/Emu/Memory/Memory.h +++ b/rpcs3/Emu/Memory/Memory.h @@ -400,27 +400,27 @@ public: *(T*)GetMemFromAddr(addr) = data; } - wxString ReadString(const u64 addr, const u64 len) + std::string ReadString(const u64 addr, const u64 len) { - wxString ret(GetMemFromAddr(addr), wxConvUTF8,len); + std::string ret((const char *)GetMemFromAddr(addr), len); return ret; } - wxString ReadString(const u64 addr) + std::string ReadString(const u64 addr) { - return wxString((const char*)GetMemFromAddr(addr), wxConvUTF8); + return std::string((const char*)GetMemFromAddr(addr)); } - void WriteString(const u64 addr, const wxString& str) + void WriteString(const u64 addr, const std::string& str) { - if(!IsGoodAddr(addr, str.Len())) + if(!IsGoodAddr(addr, str.length())) { ConLog.Error("Memory::WriteString error: bad address (0x%llx)", addr); return; } - strcpy((char*)GetMemFromAddr(addr), str); + strcpy((char*)GetMemFromAddr(addr), str.c_str()); } static u64 AlignAddr(const u64 addr, const u64 align) @@ -488,7 +488,7 @@ public: u8* operator + (const u64 vaddr) { u8* ret = GetMemFromAddr(vaddr); - if(!ret) throw wxString::Format("GetMemFromAddr(0x%llx)", vaddr); + if(!ret) throw fmt::Format("GetMemFromAddr(0x%llx)", vaddr); return ret; } diff --git a/rpcs3/Emu/SysCalls/Modules.cpp b/rpcs3/Emu/SysCalls/Modules.cpp index 370ad88004..6e2f6e2f93 100644 --- a/rpcs3/Emu/SysCalls/Modules.cpp +++ b/rpcs3/Emu/SysCalls/Modules.cpp @@ -407,57 +407,57 @@ void Module::SetName(const std::string& name) m_name = name; } -void Module::Log(const u32 id, wxString fmt, ...) +void Module::Log(const u32 id, std::string fmt, ...) { if(Ini.HLELogging.GetValue()) { va_list list; va_start(list, fmt); - ConLog.Write(GetName() + wxString::Format("[%d]: ", id).wx_str() + wxString::FormatV(fmt, list).wx_str()); + ConLog.Write(GetName() + fmt::Format("[%d]: ", id) + fmt::FormatV(fmt, list)); va_end(list); } } -void Module::Log(wxString fmt, ...) +void Module::Log(std::string fmt, ...) { if(Ini.HLELogging.GetValue()) { va_list list; va_start(list, fmt); - ConLog.Write(GetName() + ": " + wxString::FormatV(fmt, list).wx_str()); + ConLog.Write(GetName() + ": " + fmt::FormatV(fmt, list)); va_end(list); } } -void Module::Warning(const u32 id, wxString fmt, ...) +void Module::Warning(const u32 id, std::string fmt, ...) { va_list list; va_start(list, fmt); - ConLog.Warning(GetName() + wxString::Format("[%d] warning: ", id).wx_str() + wxString::FormatV(fmt, list).wx_str()); + ConLog.Warning(GetName() + fmt::Format("[%d] warning: ", id) + fmt::FormatV(fmt, list)); va_end(list); } -void Module::Warning(wxString fmt, ...) +void Module::Warning(std::string fmt, ...) { va_list list; va_start(list, fmt); - ConLog.Warning(GetName() + " warning: " + wxString::FormatV(fmt, list).wx_str()); + ConLog.Warning(GetName() + " warning: " + fmt::FormatV(fmt, list)); va_end(list); } -void Module::Error(const u32 id, wxString fmt, ...) +void Module::Error(const u32 id, std::string fmt, ...) { va_list list; va_start(list, fmt); - ConLog.Error(GetName() + wxString::Format("[%d] error: ", id).wx_str() + wxString::FormatV(fmt, list).wx_str()); + ConLog.Error(GetName() + fmt::Format("[%d] error: ", id) + fmt::FormatV(fmt, list)); va_end(list); } -void Module::Error(wxString fmt, ...) +void Module::Error(std::string fmt, ...) { va_list list; va_start(list, fmt); - ConLog.Error(GetName() + " error: " + wxString::FormatV(fmt, list).wx_str()); + ConLog.Error(GetName() + " error: " + fmt::FormatV(fmt, list)); va_end(list); } diff --git a/rpcs3/Emu/SysCalls/Modules.h b/rpcs3/Emu/SysCalls/Modules.h index 16323dd8e6..71a8e4c13c 100644 --- a/rpcs3/Emu/SysCalls/Modules.h +++ b/rpcs3/Emu/SysCalls/Modules.h @@ -71,14 +71,15 @@ public: void SetName(const std::string& name); public: - void Log(const u32 id, wxString fmt, ...); - void Log(wxString fmt, ...); + //TODO: use variadic function templates here to be able to use string references and forward all arguments without copying + void Log(const u32 id, std::string fmt, ...); + void Log(std::string fmt, ...); - void Warning(const u32 id, wxString fmt, ...); - void Warning(wxString fmt, ...); + void Warning(const u32 id, std::string fmt, ...); + void Warning(std::string fmt, ...); - void Error(const u32 id, wxString fmt, ...); - void Error(wxString fmt, ...); + void Error(const u32 id, std::string fmt, ...); + void Error(std::string fmt, ...); bool CheckID(u32 id) const; template bool CheckId(u32 id, T*& data) diff --git a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp index 8181010427..b8a16cb664 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp @@ -308,9 +308,9 @@ int cellFontOpenFontMemory(mem_ptr_t library, u32 fontAddr, u32 int cellFontOpenFontFile(mem_ptr_t library, mem8_ptr_t fontPath, u32 subNum, s32 uniqueId, mem_ptr_t font) { - wxString fp = fontPath.GetString(); + std::string fp(fontPath.GetString()); cellFont.Warning("cellFontOpenFontFile(library_addr=0x%x, fontPath=\"%s\", subNum=%d, uniqueId=%d, font_addr=0x%x)", - library.GetAddr(), fp.wx_str(), subNum, uniqueId, font.GetAddr()); + library.GetAddr(), fp.c_str(), subNum, uniqueId, font.GetAddr()); vfsFile f(fp); if (!f.IsOpened()) diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index fed9c0dc34..632fab7c91 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -305,9 +305,9 @@ int cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, u32 dirName_addr) default: return CELL_GAME_ERROR_PARAM; } - std::string errorMsg = wxString::Format("%s\nSpace needed: %d KB\nDirectory name: %s", - wxString(errorName).wx_str(), errNeedSizeKB, wxString(dirName).wx_str()).ToStdString(); - wxMessageBox(errorMsg, wxGetApp().GetAppName(), wxICON_ERROR | wxOK); + std::string errorMsg = fmt::Format("%s\nSpace needed: %d KB\nDirectory name: %s", + errorName.c_str(), errNeedSizeKB, dirName); + wxMessageBox(fmt::FromUTF8(errorMsg), wxGetApp().GetAppName(), wxICON_ERROR | wxOK); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp b/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp index 207006b0ca..c220409996 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp @@ -63,7 +63,7 @@ int jstrchk(mem8_ptr_t jstr) if (!jstr.IsGood()) cellL10n.Error("jstrchk(jstr_addr=0x%x): invalid address", jstr.GetAddr()); else if (jstr[0]) - cellL10n.Log("jstrchk(jstr_addr=0x%x): utf-8: [%s]", jstr.GetAddr(), Memory.ReadString(jstr.GetAddr()).wx_str()); + cellL10n.Log("jstrchk(jstr_addr=0x%x): utf-8: [%s]", jstr.GetAddr(), Memory.ReadString(jstr.GetAddr()).c_str()); else cellL10n.Log("jstrchk(jstr_addr=0x%x): empty string", jstr.GetAddr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index 99fc56d3ed..6971894250 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -737,7 +737,7 @@ int cellRescSetBufferAddress(mem32_t colorBuffers, mem32_t vertexArray, mem32_t s_rescInternalInstance->m_fragmentUcodeEA_addr = fragmentShader.GetAddr(); MemoryAllocator> dstOffset; - cellGcmAddressToOffset(s_rescInternalInstance->m_colorBuffersEA_addr, dstOffset); + cellGcmAddressToOffset(s_rescInternalInstance->m_colorBuffersEA_addr, dstOffset.GetAddr()); for(int i=0; i attr, const me if(size > 15) return CELL_SPURS_CORE_ERROR_INVAL; - attr->attr->_setNamePrefix(Memory.ReadString(prefix.GetAddr(), size), size); + attr->attr->_setNamePrefix(Memory.ReadString(prefix.GetAddr(), size).c_str(), size); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp index a1874ebf97..a7f435a56e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp @@ -162,7 +162,7 @@ int cellSysmoduleLoadModule(u16 id) { cellSysmodule.Error("cellSysmoduleLoadModule: TODO: CELL_SYSMODULE_LIBATRAC3MULTI"); } - cellSysmodule.Warning("cellSysmoduleLoadModule(%s)", wxString(getModuleName(id)).wx_str()); + cellSysmodule.Warning("cellSysmoduleLoadModule(%s)", getModuleName(id)); Module* m = GetModuleById(id); if(!m) @@ -181,7 +181,7 @@ int cellSysmoduleLoadModule(u16 id) int cellSysmoduleUnloadModule(u16 id) { - cellSysmodule.Warning("cellSysmoduleUnloadModule(%s)", wxString(getModuleName(id)).wx_str()); + cellSysmodule.Warning("cellSysmoduleUnloadModule(%s)", getModuleName(id)); Module* m = GetModuleById(id); if(!m) @@ -200,7 +200,7 @@ int cellSysmoduleUnloadModule(u16 id) int cellSysmoduleIsLoaded(u16 id) { - cellSysmodule.Warning("cellSysmoduleIsLoaded(%s)", wxString(getModuleName(id)).wx_str()); + cellSysmodule.Warning("cellSysmoduleIsLoaded(%s)", getModuleName(id)); Module* m = GetModuleById(id); if(!m) diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index 40141a8d91..fdbe6b0a4f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -794,7 +794,7 @@ public: virtual wxDirTraverseResult OnFile(const wxString& filename) { if (!wxRemoveFile(filename)){ - cellSysutil.Error("Couldn't delete File: %s", filename.wx_str()); + cellSysutil.Error("Couldn't delete File: %s", fmt::ToUTF8(filename).c_str()); } return wxDIR_CONTINUE; } @@ -816,11 +816,13 @@ int cellSysCacheClear(void) //if some software expects CELL_SYSCACHE_ERROR_NOTMOUNTED we need to check whether //it was mounted before, for that we would need to save the state which I don't know //where to put - wxString localPath; - Emu.GetVFS().GetDevice(wxString("/dev_hdd1/cache/"), localPath); - if (wxDirExists(localPath)){ + std::string localPath; + Emu.GetVFS().GetDevice(std::string("/dev_hdd1/cache/"), localPath); + + //TODO: replace wxWidgetsSpecific filesystem stuff + if (wxDirExists(fmt::FromUTF8(localPath))){ WxDirDeleteTraverser deleter; - wxString f = wxFindFirstFile(localPath+"\\*",wxDIR); + wxString f = wxFindFirstFile(fmt::FromUTF8(localPath+"\\*"),wxDIR); while (!f.empty()) { wxDir dir(f); @@ -840,7 +842,8 @@ int cellSysCacheMount(mem_ptr_t param) char id[CELL_SYSCACHE_ID_SIZE]; strncpy(id, param->cacheId, CELL_SYSCACHE_ID_SIZE); strncpy(param->getCachePath, ("/dev_hdd1/cache/" + std::string(id) + "/").c_str(), CELL_SYSCACHE_PATH_MAX); - Emu.GetVFS().CreateDir(wxString(param->getCachePath)); + param->getCachePath[CELL_SYSCACHE_PATH_MAX - 1] = '\0'; + Emu.GetVFS().CreateDir(std::string(param->getCachePath)); return CELL_SYSCACHE_RET_OK_RELAYED; } @@ -853,7 +856,7 @@ int cellHddGameCheck(u32 version, u32 dirName_addr, u32 errDialog, mem_func_ptr_ if (!Memory.IsGoodAddr(dirName_addr) || !funcStat.IsGood()) return CELL_HDDGAME_ERROR_PARAM; - std::string dirName = Memory.ReadString(dirName_addr).ToStdString(); + std::string dirName = Memory.ReadString(dirName_addr); if (dirName.size() != 9) return CELL_HDDGAME_ERROR_PARAM; @@ -890,14 +893,17 @@ int cellHddGameCheck(u32 version, u32 dirName_addr, u32 errDialog, mem_func_ptr_ get->getParam.attribute = psf.GetInteger("ATTRIBUTE"); get->getParam.resolution = psf.GetInteger("RESOLUTION"); get->getParam.soundFormat = psf.GetInteger("SOUND_FORMAT"); - memcpy(get->getParam.title, psf.GetString("TITLE"), CELL_HDDGAME_SYSP_TITLE_SIZE); - memcpy(get->getParam.dataVersion, psf.GetString("APP_VER"), CELL_HDDGAME_SYSP_VERSION_SIZE); - memcpy(get->getParam.titleId, dirName.c_str(), CELL_HDDGAME_SYSP_TITLEID_SIZE); + std::string title = psf.GetString("TITLE"); + memcpy(get->getParam.title, title.c_str(), min(CELL_HDDGAME_SYSP_TITLE_SIZE,title.length()+1)); + std::string app_ver = psf.GetString("APP_VER"); + memcpy(get->getParam.dataVersion, app_ver.c_str(), min(CELL_HDDGAME_SYSP_VERSION_SIZE,app_ver.length()+1)); + memcpy(get->getParam.titleId, dirName.c_str(), min(CELL_HDDGAME_SYSP_TITLEID_SIZE,dirName.length()+1)); for (u32 i=0; igetParam.titleLang[i], psf.GetString(key), CELL_HDDGAME_SYSP_TITLE_SIZE); + title = psf.GetString(key); + memcpy(get->getParam.titleLang[i], title.c_str(), min(CELL_HDDGAME_SYSP_TITLE_SIZE, title.length() + 1)); } } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp index 6fe5e52b86..1e9a2f8375 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp @@ -63,7 +63,7 @@ void addSaveDataEntry(std::vector& saveEntries, const std::st return; // PNG icon - wxString localPath; + std::string localPath; int width, height, actual_components; Emu.GetVFS().GetDevice(saveDir + "/ICON0.PNG", localPath); @@ -77,7 +77,7 @@ void addSaveDataEntry(std::vector& saveEntries, const std::st saveEntry.st_atime_ = 0; // TODO saveEntry.st_mtime_ = 0; // TODO saveEntry.st_ctime_ = 0; // TODO - saveEntry.iconBuf = stbi_load(localPath.mb_str(), &width, &height, &actual_components, 3); + saveEntry.iconBuf = stbi_load(localPath.c_str(), &width, &height, &actual_components, 3); saveEntry.iconBufSize = width * height * 3; saveEntry.isNew = false; @@ -229,11 +229,11 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t setList, m if(!dir.IsOpened()) return CELL_SAVEDATA_ERROR_INTERNAL; - std::string dirNamePrefix = std::string(Memory.ReadString(setList->dirNamePrefix_addr).mb_str()); + std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr); std::vector saveEntries; for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) { - if (entry->flags & DirEntry_TypeDir || entry->name.Left(dirNamePrefix.size()) == dirNamePrefix) + if (entry->flags & DirEntry_TypeDir || entry->name.substr(0,dirNamePrefix.size()) == dirNamePrefix) { // Count the amount of matches and the amount of listed directories listGet->dirListNum++; @@ -241,7 +241,7 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t setList, m continue; listGet->dirNum++; - std::string saveDir = saveBaseDir + (const char*)(entry->name.mb_str()); + std::string saveDir = saveBaseDir + entry->name; addSaveDataEntry(saveEntries, saveDir); } } @@ -322,11 +322,11 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, m if(!dir.IsOpened()) return CELL_SAVEDATA_ERROR_INTERNAL; - std::string dirNamePrefix = std::string(Memory.ReadString(setList->dirNamePrefix_addr).mb_str()); + std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr); std::vector saveEntries; for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) { - if (entry->flags & DirEntry_TypeDir || entry->name.Left(dirNamePrefix.size()) == dirNamePrefix) + if (entry->flags & DirEntry_TypeDir || entry->name.substr(0,dirNamePrefix.size()) == dirNamePrefix) { // Count the amount of matches and the amount of listed directories listGet->dirListNum++; @@ -334,7 +334,7 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, m continue; listGet->dirNum++; - std::string saveDir = saveBaseDir + (const char*)(entry->name.mb_str()); + std::string saveDir = saveBaseDir + entry->name; addSaveDataEntry(saveEntries, saveDir); } } diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index 5a9319dc1a..d14f440b24 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -23,7 +23,7 @@ int sceNpDrmIsAvailable(u32 k_licensee_addr, u32 drm_path_addr) { sceNp.Warning("sceNpDrmIsAvailable(k_licensee_addr=0x%x, drm_path_addr=0x%x)", k_licensee_addr, drm_path_addr); - wxString drm_path = Memory.ReadString(drm_path_addr); + wxString drm_path = fmt::FromUTF8(Memory.ReadString(drm_path_addr)); wxString k_licensee_str; u8 k_licensee[0x10]; for(int i = 0; i < 0x10; i++) @@ -32,8 +32,8 @@ int sceNpDrmIsAvailable(u32 k_licensee_addr, u32 drm_path_addr) k_licensee_str += wxString::Format("%02x", k_licensee[i]); } - sceNp.Warning("sceNpDrmIsAvailable: Found DRM license file at %s", drm_path.wx_str()); - sceNp.Warning("sceNpDrmIsAvailable: Using k_licensee 0x%s", k_licensee_str.wx_str()); + sceNp.Warning("sceNpDrmIsAvailable: Found DRM license file at %s", fmt::ToUTF8(drm_path).c_str()); + sceNp.Warning("sceNpDrmIsAvailable: Using k_licensee 0x%s", fmt::ToUTF8(k_licensee_str).c_str()); // Set the necessary file paths. wxString drm_file_name = drm_path.AfterLast('/'); @@ -46,7 +46,7 @@ int sceNpDrmIsAvailable(u32 k_licensee_addr, u32 drm_path_addr) wxString rap_file_path = rap_dir_path; // Search dev_usb000 for a compatible RAP file. - vfsDir *raps_dir = new vfsDir(rap_dir_path); + vfsDir *raps_dir = new vfsDir(fmt::ToUTF8(rap_dir_path)); if (!raps_dir->IsOpened()) sceNp.Warning("sceNpDrmIsAvailable: Can't find RAP file for DRM!"); else @@ -54,9 +54,9 @@ int sceNpDrmIsAvailable(u32 k_licensee_addr, u32 drm_path_addr) Array entries = raps_dir->GetEntries(); for (unsigned int i = 0; i < entries.GetCount(); i++) { - if (entries[i].name.Contains(titleID)) + if (entries[i].name.find(fmt::ToUTF8(titleID)) != std::string::npos ) { - rap_file_path += entries[i].name; + rap_file_path += fmt::FromUTF8(entries[i].name); break; } } @@ -68,7 +68,7 @@ int sceNpDrmIsAvailable(u32 k_licensee_addr, u32 drm_path_addr) wxMkdir(wxGetCwd() + "/dev_hdd1/" + titleID); // Decrypt this EDAT using the supplied k_licensee and matching RAP file. - DecryptEDAT(enc_drm_path.ToStdString(), dec_drm_path.ToStdString(), 8, rap_file_path.ToStdString(), k_licensee, false); + DecryptEDAT(fmt::ToUTF8(enc_drm_path), fmt::ToUTF8(dec_drm_path), 8, fmt::ToUTF8(rap_file_path), k_licensee, false); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp index 1e137e562e..77a71f81c7 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp @@ -10,6 +10,8 @@ #include "Loader/TROPUSR.h" #include "Emu/SysCalls/lv2/SC_Time.h" +#include + void sceNpTrophy_unload(); void sceNpTrophy_init(); Module sceNpTrophy(0xf035, sceNpTrophy_init, nullptr, sceNpTrophy_unload); @@ -225,25 +227,25 @@ int sceNpTrophyGetGameInfo(u32 context, u32 handle, mem_ptr_tGetChildren(); n; n = n->GetNext()) { if (n->GetName() == "title-name") - titleName = n->GetNodeContent().mb_str(); + titleName = fmt::ToUTF8(n->GetNodeContent()); if (n->GetName() == "title-detail") - titleDetail = n->GetNodeContent().mb_str(); + titleDetail = fmt::ToUTF8(n->GetNodeContent()); if (n->GetName() == "trophy") { - u32 trophy_id = atoi(n->GetAttribute("id").mb_str()); + u32 trophy_id = atoi(fmt::ToUTF8(n->GetAttribute("id")).c_str()); details->numTrophies++; - switch (((const char *)n->GetAttribute("ttype").mb_str())[0]) { + switch (fmt::ToUTF8(n->GetAttribute("ttype"))[0]) { case 'B': details->numBronze++; break; case 'S': details->numSilver++; break; case 'G': details->numGold++; break; @@ -253,7 +255,7 @@ int sceNpTrophyGetGameInfo(u32 context, u32 handle, mem_ptr_tGetTrophyUnlockState(trophy_id)) { data->unlockedTrophies++; - switch (((const char *)n->GetAttribute("ttype").mb_str())[0]) { + switch (fmt::ToUTF8(n->GetAttribute("ttype"))[0]) { case 'B': data->unlockedBronze++; break; case 'S': data->unlockedSilver++; break; case 'G': data->unlockedGold++; break; @@ -263,8 +265,8 @@ int sceNpTrophyGetGameInfo(u32 context, u32 handle, mem_ptr_ttitle, titleName.c_str(), SCE_NP_TROPHY_NAME_MAX_SIZE); - memcpy(details->description, titleDetail.c_str(), SCE_NP_TROPHY_DESCR_MAX_SIZE); + memcpy(details->title, titleName.c_str(), std::min((size_t) SCE_NP_TROPHY_NAME_MAX_SIZE, titleName.length() + 1)); + memcpy(details->description, titleDetail.c_str(), std::min((size_t) SCE_NP_TROPHY_DESCR_MAX_SIZE, titleDetail.length() + 1)); return CELL_OK; } @@ -352,33 +354,33 @@ int sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, mem_ptr_tGetChildren(); n; n = n->GetNext()) { - if (n->GetName() == "trophy" && (trophyId == atoi(n->GetAttribute("id").mb_str()))) + if (n->GetName() == "trophy" && (trophyId == atoi(fmt::ToUTF8(n->GetAttribute("id")).c_str()))) { details->trophyId = trophyId; - switch (((const char *)n->GetAttribute("ttype").mb_str())[0]) { + switch (fmt::ToUTF8(n->GetAttribute("ttype"))[0]) { case 'B': details->trophyGrade = SCE_NP_TROPHY_GRADE_BRONZE; break; case 'S': details->trophyGrade = SCE_NP_TROPHY_GRADE_SILVER; break; case 'G': details->trophyGrade = SCE_NP_TROPHY_GRADE_GOLD; break; case 'P': details->trophyGrade = SCE_NP_TROPHY_GRADE_PLATINUM; break; } - switch (((const char *)n->GetAttribute("ttype").mb_str())[0]) { + switch (fmt::ToUTF8(n->GetAttribute("ttype"))[0]) { case 'y': details->hidden = true; break; case 'n': details->hidden = false; break; } for (wxXmlNode *n2 = n->GetChildren(); n2; n2 = n2->GetNext()) { - if (n2->GetName() == "name") name = n2->GetNodeContent().mb_str(); - if (n2->GetName() == "detail") detail = n2->GetNodeContent().mb_str(); + if (n2->GetName() == "name") name = fmt::ToUTF8(n2->GetNodeContent()); + if (n2->GetName() == "detail") detail = fmt::ToUTF8(n2->GetNodeContent()); } data->trophyId = trophyId; @@ -387,8 +389,8 @@ int sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, mem_ptr_tname, name.c_str(), SCE_NP_TROPHY_NAME_MAX_SIZE); - memcpy(details->description, detail.c_str(), SCE_NP_TROPHY_DESCR_MAX_SIZE); + memcpy(details->name, name.c_str(), std::min((size_t) SCE_NP_TROPHY_NAME_MAX_SIZE, name.length() + 1)); + memcpy(details->description, detail.c_str(), std::min((size_t) SCE_NP_TROPHY_DESCR_MAX_SIZE, detail.length() + 1)); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp index ca91624905..b485a1ccbb 100644 --- a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp @@ -54,9 +54,9 @@ s64 sys_prx_exitspawn_with_level() s64 sys_strlen(u32 addr) { - const wxString& str = Memory.ReadString(addr); - sysPrxForUser.Log("sys_strlen(0x%x - \"%s\")", addr, str.wx_str()); - return str.Len(); + const std::string& str = Memory.ReadString(addr); + sysPrxForUser.Log("sys_strlen(0x%x - \"%s\")", addr, str.c_str()); + return str.length(); } int sys_spu_elf_get_information(u32 elf_img, mem32_t entry, mem32_t nseg) @@ -100,14 +100,14 @@ int sys_spu_image_close(mem_ptr_t img) int sys_raw_spu_load(int id, u32 path_addr, mem32_t entry) { - const wxString path = Memory.ReadString(path_addr).wx_str(); + const std::string path = Memory.ReadString(path_addr); sysPrxForUser.Warning("sys_raw_spu_load(id=0x%x, path=0x%x [%s], entry_addr=0x%x)", - id, path_addr, path.wx_str(), entry.GetAddr()); + id, path_addr, path.c_str(), entry.GetAddr()); vfsFile f(path); if(!f.IsOpened()) { - sysPrxForUser.Error("sys_raw_spu_load error: '%s' not found!", path.wx_str()); + sysPrxForUser.Error("sys_raw_spu_load error: '%s' not found!", path.c_str()); return CELL_ENOENT; } diff --git a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp index f37f2f1723..5cfd8acccb 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp @@ -31,20 +31,20 @@ bool sdata_check(u32 version, u32 flags, u64 filesizeInput, u64 filesizeTmp) return true; } -int sdata_unpack(wxString packed_file, wxString unpacked_file) +int sdata_unpack(const std::string& packed_file, const std::string& unpacked_file) { std::shared_ptr packed_stream(Emu.GetVFS().OpenFile(packed_file, vfsRead)); std::shared_ptr unpacked_stream(Emu.GetVFS().OpenFile(unpacked_file, vfsWrite)); if(!packed_stream || !packed_stream->IsOpened()) { - sys_fs.Error("'%s' not found! flags: 0x%08x", packed_file.wx_str(), vfsRead); + sys_fs.Error("'%s' not found! flags: 0x%08x", packed_file.c_str(), vfsRead); return CELL_ENOENT; } if(!unpacked_stream || !unpacked_stream->IsOpened()) { - sys_fs.Error("'%s' couldn't be created! flags: 0x%08x", unpacked_file.wx_str(), vfsWrite); + sys_fs.Error("'%s' couldn't be created! flags: 0x%08x", unpacked_file.c_str(), vfsWrite); return CELL_ENOENT; } @@ -108,9 +108,9 @@ int sdata_unpack(wxString packed_file, wxString unpacked_file) int cellFsSdataOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size) { - const wxString& path = Memory.ReadString(path_addr); + const std::string& path = Memory.ReadString(path_addr); sys_fs.Warning("cellFsSdataOpen(path=\"%s\", flags=0x%x, fd_addr=0x%x, arg_addr=0x%x, size=0x%llx)", - path.wx_str(), flags, fd.GetAddr(), arg.GetAddr(), size); + path.c_str(), flags, fd.GetAddr(), arg.GetAddr(), size); if (!fd.IsGood() || (!arg.IsGood() && size)) return CELL_EFAULT; @@ -118,10 +118,13 @@ int cellFsSdataOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size) if (flags != CELL_O_RDONLY) return CELL_EINVAL; - if (!path.Lower().EndsWith(".sdat")) + std::string suffix = path.substr(path.length() - 5, 4); + if (suffix != ".sdat" && suffix != ".SDAT") return CELL_ENOTSDATA; - wxString unpacked_path = "/dev_hdd1/"+path.AfterLast('/')+".unpacked"; + std::string::size_type last_slash = path.rfind('/'); //TODO: use a filesystem library to solve this more robustly + last_slash = last_slash == std::string::npos ? 0 : last_slash+1; + std::string unpacked_path = "/dev_hdd1/"+path.substr(last_slash,path.length()-last_slash)+".unpacked"; int ret = sdata_unpack(path, unpacked_path); if (ret) return ret; @@ -149,7 +152,16 @@ void fsAioRead(u32 fd, mem_ptr_t aio, int xid, mem_func_ptr_tGetPath().AfterFirst('/'); + std::string path = orig_file->GetPath(); + std::string::size_type first_slash = path.find('/'); + if (first_slash == std::string::npos) + { + path = ""; + } + else + { + path = path.substr(first_slash+1,std::string::npos); + } u64 nbytes = aio->size; u32 buf_addr = aio->buf_addr; @@ -204,7 +216,7 @@ fin: file.Seek(old_pos); ConLog.Warning("*** fsAioRead(fd=%d, offset=0x%llx, buf_addr=0x%x, size=0x%x, error=0x%x, res=0x%x, xid=0x%x [%s])", - fd, (u64)aio->offset, buf_addr, (u64)aio->size, error, res, xid, path.wx_str()); + fd, (u64)aio->offset, buf_addr, (u64)aio->size, error, res, xid, path.c_str()); if (func) // start callback thread { @@ -257,16 +269,16 @@ int cellFsAioRead(mem_ptr_t aio, mem32_t aio_id, mem_func_ptr_t 1) { @@ -144,7 +144,7 @@ void StaticAnalyse(void* ptr, u32 size, u32 base) if (g_static_funcs_list[k].found) { res |= GSR_EXCESS; - ConLog.Error("Function '%s' hooked twice", wxString(g_static_funcs_list[j].name).wx_str()); + ConLog.Error("Function '%s' hooked twice", g_static_funcs_list[j].name); } } } @@ -152,7 +152,7 @@ void StaticAnalyse(void* ptr, u32 size, u32 base) else { res |= GSR_EXCESS; - ConLog.Error("Function '%s' hooked twice", wxString(g_static_funcs_list[j].name).wx_str()); + ConLog.Error("Function '%s' hooked twice", g_static_funcs_list[j].name); } } @@ -168,13 +168,13 @@ void StaticAnalyse(void* ptr, u32 size, u32 base) if (res == GSR_SUCCESS) { - ConLog.Success("Function group [%s] successfully hooked", wxString(name, 9).wx_str()); + ConLog.Success("Function group [%s] successfully hooked", std::string(name, 9).c_str()); } else { - ConLog.Error("Function group [%s] failed:%s%s", wxString(name, 9).wx_str(), - wxString(res & GSR_MISSING ? " missing;" : "").wx_str(), - wxString(res & GSR_EXCESS ? " excess;" : "").wx_str()); + ConLog.Error("Function group [%s] failed:%s%s", std::string(name, 9).c_str(), + (res & GSR_MISSING ? " missing;" : ""), + (res & GSR_EXCESS ? " excess;" : "")); } } } diff --git a/rpcs3/Emu/SysCalls/SysCalls.cpp b/rpcs3/Emu/SysCalls/SysCalls.cpp index 91ecd0dfa2..595e1597b9 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.cpp +++ b/rpcs3/Emu/SysCalls/SysCalls.cpp @@ -359,12 +359,12 @@ void default_syscall() case 999: dump_enable = !dump_enable; Emu.Pause(); - ConLog.Warning("Dump %s", wxString(dump_enable ? "enabled" : "disabled").wx_str()); + ConLog.Warning("Dump %s", (dump_enable ? "enabled" : "disabled")); return; case 1000: Ini.HLELogging.SetValue(!Ini.HLELogging.GetValue()); - ConLog.Warning("Log %s", wxString(Ini.HLELogging.GetValue() ? "enabled" : "disabled").wx_str()); + ConLog.Warning("Log %s", (Ini.HLELogging.GetValue() ? "enabled" : "disabled")); return; } diff --git a/rpcs3/Emu/SysCalls/SysCalls.h b/rpcs3/Emu/SysCalls/SysCalls.h index 1050d00892..e40cff1124 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.h +++ b/rpcs3/Emu/SysCalls/SysCalls.h @@ -44,61 +44,61 @@ public: const std::string& GetName() const { return m_module_name; } - void Log(const u32 id, wxString fmt, ...) + void Log(const u32 id, std::string fmt, ...) { if(Ini.HLELogging.GetValue()) { va_list list; va_start(list, fmt); - ConLog.Write(GetName() + wxString::Format("[%d]: ", id).wx_str() + wxString::FormatV(fmt, list).wx_str()); + ConLog.Write(GetName() + fmt::Format("[%d]: ", id) + fmt::FormatV(fmt, list)); va_end(list); } } - void Log(wxString fmt, ...) + void Log(std::string fmt, ...) { if(Ini.HLELogging.GetValue()) { va_list list; va_start(list, fmt); - ConLog.Write(GetName() + ": " + wxString::FormatV(fmt, list).wx_str()); + ConLog.Write(GetName() + ": " + fmt::FormatV(fmt, list)); va_end(list); } } - void Warning(const u32 id, wxString fmt, ...) + void Warning(const u32 id, std::string fmt, ...) { //#ifdef SYSCALLS_DEBUG va_list list; va_start(list, fmt); - ConLog.Warning(GetName() + wxString::Format("[%d] warning: ", id).wx_str() + wxString::FormatV(fmt, list).wx_str()); + ConLog.Warning(GetName() + fmt::Format("[%d] warning: ", id) + fmt::FormatV(fmt, list)); va_end(list); //#endif } - void Warning(wxString fmt, ...) + void Warning(std::string fmt, ...) { //#ifdef SYSCALLS_DEBUG va_list list; va_start(list, fmt); - ConLog.Warning(GetName() + " warning: " + wxString::FormatV(fmt, list).wx_str()); + ConLog.Warning(GetName() + " warning: " + fmt::FormatV(fmt, list)); va_end(list); //#endif } - void Error(const u32 id, wxString fmt, ...) + void Error(const u32 id, std::string fmt, ...) { va_list list; va_start(list, fmt); - ConLog.Error(GetName() + wxString::Format("[%d] error: ", id).wx_str() + wxString::FormatV(fmt, list).wx_str()); + ConLog.Error(GetName() + fmt::Format("[%d] error: ", id) + fmt::FormatV(fmt, list)); va_end(list); } - void Error(wxString fmt, ...) + void Error(std::string fmt, ...) { va_list list; va_start(list, fmt); - ConLog.Error(GetName() + " error: " + wxString::FormatV(fmt, list).wx_str()); + ConLog.Error(GetName() + " error: " + fmt::FormatV(fmt, list)); va_end(list); } @@ -421,7 +421,7 @@ extern int sys_rsx_device_map(mem32_t a1, mem32_t a2, u32 a3); extern int sys_rsx_device_unmap(); extern int sys_rsx_attribute(); -#define UNIMPLEMENTED_FUNC(module) module.Error("Unimplemented function: %s", wxString(__FUNCTION__).wx_str()) +#define UNIMPLEMENTED_FUNC(module) module.Error("Unimplemented function: %s", __FUNCTION__) #define SC_ARG_0 CPU.GPR[3] #define SC_ARG_1 CPU.GPR[4] diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Condition.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Condition.cpp index 71d4ac0de9..8e31bb2674 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Condition.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Condition.cpp @@ -35,7 +35,7 @@ int sys_cond_create(mem32_t cond_id, u32 mutex_id, mem_ptr_t u32 id = sys_cond.GetNewId(cond); cond_id = id; mutex->cond_count++; - sys_cond.Warning("*** condition created [%s] (mutex_id=%d): id = %d", wxString(attr->name, 8).wx_str(), mutex_id, cond_id.GetValue()); + sys_cond.Warning("*** condition created [%s] (mutex_id=%d): id = %d", std::string(attr->name, 8).c_str(), mutex_id, cond_id.GetValue()); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp index d6ea1a26a3..246d597e88 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp @@ -52,7 +52,7 @@ int sys_event_queue_create(mem32_t equeue_id, mem_ptr_t at equeue_id = sys_event.GetNewId(eq); sys_event.Warning("*** event_queue created [%s] (protocol=0x%x, type=0x%x): id = %d", - wxString(attr->name, 8).wx_str(), (u32)attr->protocol, (int)attr->type, equeue_id.GetValue()); + std::string(attr->name, 8).c_str(), (u32)attr->protocol, (int)attr->type, equeue_id.GetValue()); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Event_flag.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Event_flag.cpp index 72ac3ebef6..4caf1c1d6f 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Event_flag.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Event_flag.cpp @@ -38,7 +38,7 @@ int sys_event_flag_create(mem32_t eflag_id, mem_ptr_t attr, eflag_id = sys_event_flag.GetNewId(new EventFlag(init, (u32)attr->protocol, (int)attr->type)); sys_event_flag.Warning("*** event_flag created [%s] (protocol=0x%x, type=0x%x): id = %d", - wxString(attr->name, 8).wx_str(), (u32)attr->protocol, (int)attr->type, eflag_id.GetValue()); + std::string(attr->name, 8).c_str(), (u32)attr->protocol, (int)attr->type, eflag_id.GetValue()); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp b/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp index 5dcdf1a12f..52af35a547 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp @@ -45,12 +45,12 @@ struct FsRingBufferConfig int cellFsOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size) { - const wxString& path = Memory.ReadString(path_addr); + const std::string& path = Memory.ReadString(path_addr); sys_fs.Log("cellFsOpen(path=\"%s\", flags=0x%x, fd_addr=0x%x, arg_addr=0x%x, size=0x%llx)", - path.wx_str(), flags, fd.GetAddr(), arg.GetAddr(), size); + path.c_str(), flags, fd.GetAddr(), arg.GetAddr(), size); - const wxString& ppath = path; - //ConLog.Warning("path: %s [%s]", ppath.wx_str(), path.wx_str()); + const std::string& ppath = path; + //ConLog.Warning("path: %s [%s]", ppath.c_str(), path.c_str()); s32 _oflags = flags; if(flags & CELL_O_CREAT) @@ -102,7 +102,7 @@ int cellFsOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size) if(_oflags != 0) { - sys_fs.Error("\"%s\" has unknown flags! flags: 0x%08x", ppath.wx_str(), flags); + sys_fs.Error("\"%s\" has unknown flags! flags: 0x%08x", ppath.c_str(), flags); return CELL_EINVAL; } @@ -110,12 +110,12 @@ int cellFsOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size) if(!stream || !stream->IsOpened()) { - sys_fs.Error("\"%s\" not found! flags: 0x%08x", ppath.wx_str(), flags); + sys_fs.Error("\"%s\" not found! flags: 0x%08x", ppath.c_str(), flags); return CELL_ENOENT; } fd = sys_fs.GetNewId(stream, IDFlag_File); - ConLog.Warning("*** cellFsOpen(path=\"%s\"): fd = %d", path.wx_str(), fd.GetValue()); + ConLog.Warning("*** cellFsOpen(path=\"%s\"): fd = %d", path.c_str(), fd.GetValue()); return CELL_OK; } @@ -201,8 +201,8 @@ int cellFsClose(u32 fd) int cellFsOpendir(u32 path_addr, mem32_t fd) { - const wxString& path = Memory.ReadString(path_addr); - sys_fs.Warning("cellFsOpendir(path=\"%s\", fd_addr=0x%x)", path.wx_str(), fd.GetAddr()); + const std::string& path = Memory.ReadString(path_addr); + sys_fs.Warning("cellFsOpendir(path=\"%s\", fd_addr=0x%x)", path.c_str(), fd.GetAddr()); if(!Memory.IsGoodAddr(path_addr) || !fd.IsGood()) return CELL_EFAULT; @@ -232,8 +232,8 @@ int cellFsReaddir(u32 fd, mem_ptr_t dir, mem64_t nread) if(info) { nread = 1; - Memory.WriteString(dir.GetAddr()+2, info->name.wx_str()); - dir->d_namlen = info->name.Length(); + Memory.WriteString(dir.GetAddr()+2, info->name); + dir->d_namlen = info->name.length(); dir->d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY; } else @@ -256,8 +256,8 @@ int cellFsClosedir(u32 fd) int cellFsStat(const u32 path_addr, mem_ptr_t sb) { - const wxString& path = Memory.ReadString(path_addr); - sys_fs.Log("cellFsStat(path=\"%s\", sb_addr: 0x%x)", path.wx_str(), sb.GetAddr()); + const std::string& path = Memory.ReadString(path_addr); + sys_fs.Log("cellFsStat(path=\"%s\", sb_addr: 0x%x)", path.c_str(), sb.GetAddr()); sb->st_mode = CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR | @@ -290,7 +290,7 @@ int cellFsStat(const u32 path_addr, mem_ptr_t sb) } } - sys_fs.Warning("cellFsStat: \"%s\" not found.", path.wx_str()); + sys_fs.Warning("cellFsStat: \"%s\" not found.", path.c_str()); return CELL_ENOENT; } @@ -321,8 +321,8 @@ int cellFsFstat(u32 fd, mem_ptr_t sb) int cellFsMkdir(u32 path_addr, u32 mode) { - const wxString& ps3_path = Memory.ReadString(path_addr); - sys_fs.Log("cellFsMkdir(path=\"%s\", mode=0x%x)", ps3_path.wx_str(), mode); + const std::string& ps3_path = Memory.ReadString(path_addr); + sys_fs.Log("cellFsMkdir(path=\"%s\", mode=0x%x)", ps3_path.c_str(), mode); /*vfsDir dir; if(dir.IsExists(ps3_path)) @@ -340,8 +340,8 @@ int cellFsMkdir(u32 path_addr, u32 mode) int cellFsRename(u32 from_addr, u32 to_addr) { - const wxString& ps3_from = Memory.ReadString(from_addr); - const wxString& ps3_to = Memory.ReadString(to_addr); + const std::string& ps3_from = Memory.ReadString(from_addr); + const std::string& ps3_to = Memory.ReadString(to_addr); { vfsDir dir; @@ -370,8 +370,8 @@ int cellFsRename(u32 from_addr, u32 to_addr) int cellFsRmdir(u32 path_addr) { - const wxString& ps3_path = Memory.ReadString(path_addr); - sys_fs.Log("cellFsRmdir(path=\"%s\")", ps3_path.wx_str()); + const std::string& ps3_path = Memory.ReadString(path_addr); + sys_fs.Log("cellFsRmdir(path=\"%s\")", ps3_path.c_str()); vfsDir d; if(!d.IsExists(ps3_path)) @@ -385,8 +385,8 @@ int cellFsRmdir(u32 path_addr) int cellFsUnlink(u32 path_addr) { - const wxString& ps3_path = Memory.ReadString(path_addr); - sys_fs.Warning("cellFsUnlink(path=\"%s\")", ps3_path.wx_str()); + const std::string& ps3_path = Memory.ReadString(path_addr); + sys_fs.Warning("cellFsUnlink(path=\"%s\")", ps3_path.c_str()); if (ps3_path.empty()) return CELL_EFAULT; @@ -452,13 +452,13 @@ int cellFsFtruncate(u32 fd, u64 size) int cellFsTruncate(u32 path_addr, u64 size) { - const wxString& path = Memory.ReadString(path_addr); - sys_fs.Log("cellFsTruncate(path=\"%s\", size=%lld)", path.wx_str(), size); + const std::string& path = Memory.ReadString(path_addr); + sys_fs.Log("cellFsTruncate(path=\"%s\", size=%lld)", path.c_str(), size); vfsFile f(path, vfsReadWrite); if(!f.IsOpened()) { - sys_fs.Warning("cellFsTruncate: \"%s\" not found.", path.wx_str()); + sys_fs.Warning("cellFsTruncate: \"%s\" not found.", path.c_str()); return CELL_ENOENT; } u64 initialSize = f.GetSize(); @@ -496,7 +496,7 @@ int cellFsFGetBlockSize(u32 fd, mem64_t sector_size, mem64_t block_size) int cellFsGetBlockSize(u32 path_addr, mem64_t sector_size, mem64_t block_size) { - sys_fs.Log("cellFsGetBlockSize(file: %s, sector_size_addr: 0x%x, block_size_addr: 0x%x)", Memory.ReadString(path_addr).wx_str(), sector_size.GetAddr(), block_size.GetAddr()); + sys_fs.Log("cellFsGetBlockSize(file: %s, sector_size_addr: 0x%x, block_size_addr: 0x%x)", Memory.ReadString(path_addr).c_str(), sector_size.GetAddr(), block_size.GetAddr()); sector_size = 4096; // ? block_size = 4096; // ? @@ -506,9 +506,9 @@ int cellFsGetBlockSize(u32 path_addr, mem64_t sector_size, mem64_t block_size) int cellFsGetFreeSize(u32 path_addr, mem32_t block_size, mem64_t block_count) { - const wxString& ps3_path = Memory.ReadString(path_addr); + const std::string& ps3_path = Memory.ReadString(path_addr); sys_fs.Warning("cellFsGetFreeSize(path=\"%s\", block_size_addr=0x%x, block_count_addr=0x%x)", - ps3_path.wx_str(), block_size.GetAddr(), block_count.GetAddr()); + ps3_path.c_str(), block_size.GetAddr(), block_count.GetAddr()); if (!Memory.IsGoodAddr(path_addr) || !block_size.IsGood() || !block_count.IsGood()) return CELL_EFAULT; @@ -537,8 +537,8 @@ int cellFsGetDirectoryEntries(u32 fd, mem_ptr_t entries, u if(info) { data_count = 1; - Memory.WriteString(entries.GetAddr()+2, info->name.wx_str()); - entries->entry_name.d_namlen = info->name.Length(); + Memory.WriteString(entries.GetAddr()+2, info->name); + entries->entry_name.d_namlen = info->name.length(); entries->entry_name.d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY; entries->attribute.st_mode = diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp index 1a359c5ed8..6954c45158 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp @@ -35,7 +35,7 @@ int sys_lwcond_create(mem_ptr_t lwcond, mem_ptr_t l } sys_lwcond.Warning("*** lwcond created [%s] (lwmutex_addr=0x%x): id = %d", - wxString(attr->name, 8).wx_str(), lwmutex.GetAddr(), (u32)lwcond->lwcond_queue); + std::string(attr->name, 8).c_str(), lwmutex.GetAddr(), (u32) lwcond->lwcond_queue); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp index 0049df7810..4b0d480395 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp @@ -38,7 +38,7 @@ int sys_lwmutex_create(mem_ptr_t lwmutex, mem_ptr_tsleep_queue = sq_id; sc_lwmutex.Warning("*** lwmutex created [%s] (attribute=0x%x): sq_id = %d", - wxString(attr->name, 8).wx_str(), (u32)lwmutex->attribute, sq_id); + std::string(attr->name, 8).c_str(), (u32) lwmutex->attribute, sq_id); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Mutex.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Mutex.cpp index e09bc1874e..59095350e8 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Mutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Mutex.cpp @@ -45,8 +45,8 @@ int sys_mutex_create(mem32_t mutex_id, mem_ptr_t attr) mutex_id = id; mutex->m_mutex.unlock(tid); sys_mtx.Warning("*** mutex created [%s] (protocol=0x%x, recursive=%s): id = %d", - wxString(attr->name, 8).wx_str(), (u32)attr->protocol, - wxString(is_recursive ? "true" : "false").wx_str(), mutex_id.GetValue()); + std::string(attr->name, 8).c_str(), (u32) attr->protocol, + (is_recursive ? "true" : "false"), mutex_id.GetValue()); // TODO: unlock mutex when owner thread does exit diff --git a/rpcs3/Emu/SysCalls/lv2/SC_PPU_Thread.cpp b/rpcs3/Emu/SysCalls/lv2/SC_PPU_Thread.cpp index 5cf8fa52bd..8fd9e51796 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_PPU_Thread.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_PPU_Thread.cpp @@ -142,7 +142,7 @@ int sys_ppu_thread_restart(u32 thread_id) int sys_ppu_thread_create(u32 thread_id_addr, u32 entry, u64 arg, int prio, u32 stacksize, u64 flags, u32 threadname_addr) { sysPrxForUser.Log("sys_ppu_thread_create(thread_id_addr=0x%x, entry=0x%x, arg=0x%x, prio=%d, stacksize=0x%x, flags=0x%llx, threadname_addr=0x%x('%s'))", - thread_id_addr, entry, arg, prio, stacksize, flags, threadname_addr, Memory.ReadString(threadname_addr).wx_str()); + thread_id_addr, entry, arg, prio, stacksize, flags, threadname_addr, Memory.ReadString(threadname_addr).c_str()); if(!Memory.IsGoodAddr(entry) || !Memory.IsGoodAddr(thread_id_addr) || !Memory.IsGoodAddr(threadname_addr)) { @@ -157,9 +157,9 @@ int sys_ppu_thread_create(u32 thread_id_addr, u32 entry, u64 arg, int prio, u32 new_thread.SetPrio(prio); new_thread.SetStackSize(stacksize); //new_thread.flags = flags; - new_thread.SetName(Memory.ReadString(threadname_addr).ToStdString()); + new_thread.SetName(Memory.ReadString(threadname_addr)); - ConLog.Write("*** New PPU Thread [%s] (): id = %d", wxString(new_thread.GetName()).wx_str(), new_thread.GetId()); + ConLog.Write("*** New PPU Thread [%s] (): id = %d", new_thread.GetName().c_str(), new_thread.GetId()); new_thread.Run(); new_thread.Exec(); diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Process.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Process.cpp index f64907ce88..0e6969864c 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Process.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Process.cpp @@ -61,7 +61,7 @@ void sys_game_process_exitspawn( u64 flags ) { sc_p.Error("sys_game_process_exitspawn UNIMPLEMENTED"); - sc_p.Warning("path: %s", Memory.ReadString(path_addr).wx_str()); + sc_p.Warning("path: %s", Memory.ReadString(path_addr).c_str()); sc_p.Warning("argv: 0x%x", argv_addr); sc_p.Warning("envp: 0x%x", envp_addr); sc_p.Warning("data: 0x%x", data_addr); @@ -69,9 +69,9 @@ void sys_game_process_exitspawn( sc_p.Warning("prio: %d", prio); sc_p.Warning("flags: %d", flags); - wxString path = Memory.ReadString(path_addr); - std::vector argv; - std::vector env; + std::string path = Memory.ReadString(path_addr); + std::vector argv; + std::vector env; mem_ptr_t argvp(argv_addr); while (argvp.GetAddr() && argvp.IsGood() && *argvp) @@ -87,10 +87,10 @@ void sys_game_process_exitspawn( } for (auto &arg : argv){ - sc_p.Log("argument: %s", arg.wx_str()); + sc_p.Log("argument: %s", arg.c_str()); } for (auto &en : env){ - sc_p.Log("env_argument: %s", en.wx_str()); + sc_p.Log("env_argument: %s", en.c_str()); } //TODO: execute the file in with the args in argv //and the environment parameters in envp and copy the data @@ -109,7 +109,7 @@ void sys_game_process_exitspawn2( u64 flags) { sc_p.Error("sys_game_process_exitspawn2 UNIMPLEMENTED"); - sc_p.Warning("path: %s", Memory.ReadString(path_addr).wx_str()); + sc_p.Warning("path: %s", Memory.ReadString(path_addr).c_str()); sc_p.Warning("argv: 0x%x", argv_addr); sc_p.Warning("envp: 0x%x", envp_addr); sc_p.Warning("data: 0x%x", data_addr); @@ -118,8 +118,8 @@ void sys_game_process_exitspawn2( sc_p.Warning("flags: %d", flags); wxString path = Memory.ReadString(path_addr); - std::vector argv; - std::vector env; + std::vector argv; + std::vector env; mem_ptr_t argvp(argv_addr); while (argvp.GetAddr() && argvp.IsGood() && *argvp) @@ -135,10 +135,10 @@ void sys_game_process_exitspawn2( } for (auto &arg : argv){ - sc_p.Log("argument: %s", arg.wx_str()); + sc_p.Log("argument: %s", arg.c_str()); } for (auto &en : env){ - sc_p.Log("env_argument: %s", en.wx_str()); + sc_p.Log("env_argument: %s", en.c_str()); } //TODO: execute the file in with the args in argv //and the environment parameters in envp and copy the data diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Rwlock.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Rwlock.cpp index 29a178f537..2ca6ac53d3 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Rwlock.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Rwlock.cpp @@ -28,7 +28,7 @@ int sys_rwlock_create(mem32_t rw_lock_id, mem_ptr_t attr rw_lock_id = sys_rwlock.GetNewId(new RWLock((u32)attr->attr_protocol, attr->name_u64)); sys_rwlock.Warning("*** rwlock created [%s] (protocol=0x%x): id = %d", - wxString(attr->name, 8).wx_str(), (u32)attr->attr_protocol, rw_lock_id.GetValue()); + std::string(attr->name, 8).c_str(), (u32) attr->attr_protocol, rw_lock_id.GetValue()); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp b/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp index 1c66afe102..ba5c8023d8 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp @@ -40,8 +40,8 @@ u32 LoadSpuImage(vfsStream& stream) //156 int sys_spu_image_open(mem_ptr_t img, u32 path_addr) { - const wxString path = Memory.ReadString(path_addr).wx_str(); - sc_spu.Warning("sys_spu_image_open(img_addr=0x%x, path_addr=0x%x [%s])", img.GetAddr(), path_addr, path.wx_str()); + const std::string path = Memory.ReadString(path_addr).c_str(); + sc_spu.Warning("sys_spu_image_open(img_addr=0x%x, path_addr=0x%x [%s])", img.GetAddr(), path_addr, path.c_str()); if(!img.IsGood() || !Memory.IsGoodAddr(path_addr)) { @@ -51,7 +51,7 @@ int sys_spu_image_open(mem_ptr_t img, u32 path_addr) vfsFile f(path); if(!f.IsOpened()) { - sc_spu.Error("sys_spu_image_open error: '%s' not found!", path.wx_str()); + sc_spu.Error("sys_spu_image_open error: '%s' not found!", path.c_str()); return CELL_ENOENT; } @@ -106,7 +106,7 @@ int sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t< std::string name = "SPUThread"; if (attr->name_addr) { - name = Memory.ReadString(attr->name_addr, attr->name_len).ToStdString(); + name = Memory.ReadString(attr->name_addr, attr->name_len); } u64 a1 = arg->arg1; @@ -132,7 +132,7 @@ int sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t< (*(SPUThread*)&new_thread).group = group_info; sc_spu.Warning("*** New SPU Thread [%s] (img_offset=0x%x, ls_offset=0x%x, ep=0x%x, a1=0x%llx, a2=0x%llx, a3=0x%llx, a4=0x%llx): id=%d", - wxString(attr->name_addr ? name : "").wx_str(), (u32)img->segs_addr, ((SPUThread&)new_thread).dmac.ls_offset, spu_ep, a1, a2, a3, a4, thread.GetValue()); + (attr->name_addr ? name.c_str() : ""), (u32) img->segs_addr, ((SPUThread&) new_thread).dmac.ls_offset, spu_ep, a1, a2, a3, a4, thread.GetValue()); return CELL_OK; } @@ -302,12 +302,12 @@ int sys_spu_thread_group_create(mem32_t id, u32 num, int prio, mem_ptr_t 255) return CELL_EINVAL; - const wxString name = Memory.ReadString(attr->name_addr, attr->name_len); + const std::string name = Memory.ReadString(attr->name_addr, attr->name_len); id = sc_spu.GetNewId(new SpuGroupInfo(name, num, prio, attr->type, attr->ct)); sc_spu.Warning("*** SPU Thread Group created [%s] (type=0x%x, option.ct=0x%x): id=%d", - name.wx_str(), (int)attr->type, (u32)attr->ct, id.GetValue()); + name.c_str(), (int)attr->type, (u32)attr->ct, id.GetValue()); return CELL_OK; } diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 3f32054def..afe861905f 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -41,13 +41,13 @@ void Emulator::Init() //m_memory_viewer = new MemoryViewerPanel(wxGetApp().m_MainFrame); } -void Emulator::SetPath(const wxString& path, const wxString& elf_path) +void Emulator::SetPath(const std::string& path, const std::string& elf_path) { m_path = path; m_elf_path = elf_path; } -void Emulator::SetTitleID(const wxString& id) +void Emulator::SetTitleID(const std::string& id) { m_title_id = id; } @@ -103,9 +103,9 @@ bool Emulator::BootGame(const std::string& path) for(int i=0; i %s", m_vfs.m_devices[i].GetPs3Path().wx_str(), m_vfs.m_devices[i].GetLocalPath().wx_str()); + ConLog.Write("%s -> %s", m_vfs.m_devices[i].GetPs3Path().c_str(), m_vfs.m_devices[i].GetLocalPath().c_str()); } ConLog.SkipLn(); - if(m_elf_path.IsEmpty()) + if(m_elf_path.empty()) { GetVFS().GetDeviceLocal(m_path, m_elf_path); } @@ -162,7 +162,7 @@ void Emulator::Load() if(!f.IsOpened()) { - ConLog.Error("Elf not found! (%s - %s)", m_path.wx_str(), m_elf_path.wx_str()); + ConLog.Error("Elf not found! (%s - %s)", m_path.c_str(), m_elf_path.c_str()); return; } @@ -193,7 +193,7 @@ void Emulator::Load() } } - catch(const wxString& e) + catch(const std::string& e) { ConLog.Error(e); is_error = true; @@ -441,7 +441,7 @@ void Emulator::LoadPoints(const std::string& path) if(version != bpdb_version || (sizeof(u16) + break_count * sizeof(u64) + sizeof(u32) + marked_count * sizeof(u64) + sizeof(u32)) != length) { - ConLog.Error("'%s' is broken", wxString(path).wx_str()); + ConLog.Error("'%s' is broken", path.c_str()); return; } diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 1564afca76..6953dc8c3a 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -98,15 +98,15 @@ class Emulator EmuInfo m_info; public: - wxString m_path; - wxString m_elf_path; - wxString m_title_id; + std::string m_path; + std::string m_elf_path; + std::string m_title_id; Emulator(); void Init(); - void SetPath(const wxString& path, const wxString& elf_path = wxEmptyString); - void SetTitleID(const wxString& id); + void SetPath(const std::string& path, const std::string& elf_path = ""); + void SetTitleID(const std::string& id); CPUThreadManager& GetCPU() { return m_thread_manager; } PadManager& GetPadManager() { return m_pad_manager; } diff --git a/rpcs3/Gui/CompilerELF.cpp b/rpcs3/Gui/CompilerELF.cpp index 9ef926ba6b..622a54865c 100644 --- a/rpcs3/Gui/CompilerELF.cpp +++ b/rpcs3/Gui/CompilerELF.cpp @@ -16,7 +16,7 @@ wxFont GetFont(int size) } CompilerELF::CompilerELF(wxWindow* parent) - : FrameBase(parent, wxID_ANY, "CompilerELF", wxEmptyString, wxSize(640, 680)) + : FrameBase(parent, wxID_ANY, "CompilerELF", "", wxSize(640, 680)) , m_status_bar(*CreateStatusBar()) { m_disable_scroll = false; @@ -392,26 +392,26 @@ void CompilerELF::LoadElf(wxCommandEvent& event) wxFD_OPEN | wxFD_FILE_MUST_EXIST); if(ctrl.ShowModal() == wxID_CANCEL) return; - LoadElf(ctrl.GetPath()); + LoadElf(fmt::ToUTF8(ctrl.GetPath())); } #include "Emu/Cell/PPUDisAsm.h" #include "Emu/Cell/PPUDecoder.h" -void CompilerELF::LoadElf(const wxString& path) +void CompilerELF::LoadElf(const std::string& path) { } -void CompilerELF::SetTextStyle(const wxString& text, const wxColour& color, bool bold) +void CompilerELF::SetTextStyle(const std::string& text, const wxColour& color, bool bold) { - for(int p=0; (p = asm_list->GetValue().find(text, p)) >= 0; p += text.Len()) + for(int p=0; (p = fmt::ToUTF8(asm_list->GetValue()).find(text, p)) !=std::string::npos; p += text.length()) { - asm_list->SetStyle(p, p + text.Len(), wxTextAttr(color, wxNullColour, + asm_list->SetStyle(p, p + text.length(), wxTextAttr(color, wxNullColour, wxFont(-1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, bold ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL))); } } -void CompilerELF::SetOpStyle(const wxString& text, const wxColour& color, bool bold) +void CompilerELF::SetOpStyle(const std::string& text, const wxColour& color, bool bold) { /* for(int p=0; (p = FindOp(asm_list->GetValue(), text, p)) >= 0; p += text.Len()) @@ -424,5 +424,5 @@ void CompilerELF::SetOpStyle(const wxString& text, const wxColour& color, bool b void CompilerELF::DoAnalyzeCode(bool compile) { - CompilePPUProgram(asm_list->GetValue(), "compiled.elf", asm_list, hex_list, err_list, !compile).Compile(); + CompilePPUProgram(fmt::ToUTF8(asm_list->GetValue()), "compiled.elf", asm_list, hex_list, err_list, !compile).Compile(); } diff --git a/rpcs3/Gui/CompilerELF.h b/rpcs3/Gui/CompilerELF.h index a0b4fc1965..8d7321c5c3 100644 --- a/rpcs3/Gui/CompilerELF.h +++ b/rpcs3/Gui/CompilerELF.h @@ -38,10 +38,10 @@ public: } void LoadElf(wxCommandEvent& event); - void LoadElf(const wxString& path); + void LoadElf(const std::string& path); - void SetTextStyle(const wxString& text, const wxColour& color, bool bold=false); - void SetOpStyle(const wxString& text, const wxColour& color, bool bold=true); + void SetTextStyle(const std::string& text, const wxColour& color, bool bold=false); + void SetOpStyle(const std::string& text, const wxColour& color, bool bold = true); void DoAnalyzeCode(bool compile); void UpdateStatus(int offset=0); diff --git a/rpcs3/Gui/ConLog.cpp b/rpcs3/Gui/ConLog.cpp index e648652a7b..094c91c2a7 100644 --- a/rpcs3/Gui/ConLog.cpp +++ b/rpcs3/Gui/ConLog.cpp @@ -12,20 +12,20 @@ LogFrame* ConLogFrame; std::mutex g_cs_conlog; static const uint max_item_count = 500; -static const uint buffer_size = 1024 * 64 * sizeof(wxChar); +static const uint buffer_size = 1024 * 64; -static const wxString g_log_colors[] = +static const std::string g_log_colors[] = { "Black", "Green", "White", "Yellow", "Red", }; struct LogPacket { - wxString m_prefix; - wxString m_text; - wxString m_colour; + const std::string m_prefix; + const std::string m_text; + const 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) @@ -42,9 +42,9 @@ struct _LogBuffer : public MTPacketBuffer void _push(const LogPacket& data) { - const u32 sprefix = data.m_prefix.length() * sizeof(wxChar); - const u32 stext = data.m_text.length() * sizeof(wxChar); - const u32 scolour = data.m_colour.length() * sizeof(wxChar); + 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 + @@ -55,17 +55,17 @@ struct _LogBuffer : public MTPacketBuffer memcpy(&m_buffer[c_put], &sprefix, sizeof(u32)); c_put += sizeof(u32); - memcpy(&m_buffer[c_put], data.m_prefix.wx_str(), sprefix); + memcpy(&m_buffer[c_put], data.m_prefix.c_str(), sprefix); c_put += sprefix; memcpy(&m_buffer[c_put], &stext, sizeof(u32)); c_put += sizeof(u32); - memcpy(&m_buffer[c_put], data.m_text.wx_str(), stext); + memcpy(&m_buffer[c_put], data.m_text.c_str(), stext); c_put += stext; memcpy(&m_buffer[c_put], &scolour, sizeof(u32)); c_put += sizeof(u32); - memcpy(&m_buffer[c_put], data.m_colour.wx_str(), scolour); + memcpy(&m_buffer[c_put], data.m_colour.c_str(), scolour); c_put += scolour; m_put = c_put; @@ -78,17 +78,17 @@ struct _LogBuffer : public MTPacketBuffer const u32& sprefix = *(u32*)&m_buffer[c_get]; c_get += sizeof(u32); - const wxString& prefix = wxString((wxChar*)&m_buffer[c_get], sprefix / sizeof(wxChar)); + const std::string prefix( (const char*) &m_buffer[c_get], sprefix); c_get += sprefix; const u32& stext = *(u32*)&m_buffer[c_get]; c_get += sizeof(u32); - const wxString& text = wxString((wxChar*)&m_buffer[c_get], stext / sizeof(wxChar)); + const std::string text( (const char*) &m_buffer[c_get], stext); c_get += stext; const u32& scolour = *(u32*)&m_buffer[c_get]; c_get += sizeof(u32); - const wxString& colour = wxString((wxChar*)&m_buffer[c_get], scolour / sizeof(wxChar)); + const std::string colour( (const char*) &m_buffer[c_get], scolour); c_get += scolour; m_get = c_get; @@ -108,9 +108,9 @@ LogWriter::LogWriter() } } -void LogWriter::WriteToLog(const wxString& prefix, const wxString& value, u8 lvl/*, wxColour bgcolour*/) +void LogWriter::WriteToLog(const std::string& prefix, const std::string& value, u8 lvl/*, wxColour bgcolour*/) { - wxString new_prefix = prefix; + std::string new_prefix = prefix; if(!prefix.empty()) { if(NamedThreadBase* thr = GetCurrentNamedThread()) @@ -120,7 +120,7 @@ void LogWriter::WriteToLog(const wxString& prefix, const wxString& value, u8 lvl } if(m_logfile.IsOpened() && !new_prefix.empty()) - m_logfile.Write(wxString("[") + new_prefix + "]: " + value + "\n"); + m_logfile.Write(fmt::FromUTF8("[" + new_prefix + "]: " + value + "\n")); if(!ConLogFrame || Ini.HLELogLvl.GetValue() == 4 || (lvl != 0 && lvl <= Ini.HLELogLvl.GetValue())) return; @@ -157,57 +157,6 @@ void LogWriter::WriteToLog(const wxString& prefix, const wxString& value, u8 lvl LogBuffer.Push(LogPacket(new_prefix, value, g_log_colors[lvl])); } -void LogWriter::Write(const wxString& fmt, ...) -{ - va_list list; - va_start(list, fmt); - - wxString frmt; - frmt = wxString::FormatV(fmt, list); - - va_end(list); - - WriteToLog("!", frmt, 2); -} - -void LogWriter::Error(const wxString& fmt, ...) -{ - va_list list; - va_start(list, fmt); - - wxString frmt; - frmt = wxString::FormatV(fmt, list); - - va_end(list); - - WriteToLog("E", frmt, 4); -} - -void LogWriter::Warning(const wxString& fmt, ...) -{ - va_list list; - va_start(list, fmt); - - wxString frmt; - frmt = wxString::FormatV(fmt, list); - - va_end(list); - - WriteToLog("W", frmt, 3); -} - -void LogWriter::Success(const wxString& fmt, ...) -{ - va_list list; - va_start(list, fmt); - - wxString frmt; - frmt = wxString::FormatV(fmt, list); - - va_end(list); - - WriteToLog("S", frmt, 1); -} void LogWriter::SkipLn() { @@ -271,9 +220,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, fmt::FromUTF8(item.m_prefix)); + m_log.SetItem(cur_item, 1, fmt::FromUTF8(item.m_text)); + m_log.SetItemTextColour(cur_item, fmt::FromUTF8(item.m_colour)); m_log.SetColumnWidth(0, -1); // crashes on exit m_log.SetColumnWidth(1, -1); diff --git a/rpcs3/Gui/ConLog.h b/rpcs3/Gui/ConLog.h index dd44054c89..c0aff95a21 100644 --- a/rpcs3/Gui/ConLog.h +++ b/rpcs3/Gui/ConLog.h @@ -11,15 +11,39 @@ class LogWriter //wxString m_prefix; //wxString m_value; - virtual void WriteToLog(const wxString& prefix, const wxString& value, u8 lvl); + virtual void WriteToLog(const std::string& prefix, const std::string& value, u8 lvl); public: LogWriter(); - virtual void Write(const wxString& fmt, ...); - virtual void Error(const wxString& fmt, ...); - virtual void Warning(const wxString& fmt, ...); - virtual void Success(const wxString& fmt, ...); + template + void Write(const std::string &fmt, Arg&&... args) + { + std::string frmt = fmt::Format(fmt, std::forward(args)...); + WriteToLog("!", frmt, 2); + } + + template + void Error(const std::string &fmt, Arg&&... args) + { + std::string frmt = fmt::Format(fmt, std::forward(args)...); + WriteToLog("E", frmt, 4); + } + + template + void Warning(const std::string &fmt, Arg&&... args) + { + std::string frmt = fmt::Format(fmt, std::forward(args)...); + WriteToLog("W", frmt, 3); + } + + template + void Success(const std::string &fmt, Arg&&... args) + { + std::string frmt = fmt::Format(fmt, std::forward(args)...); + WriteToLog("S", frmt, 1); + } + virtual void SkipLn(); }; diff --git a/rpcs3/Gui/Debugger.cpp b/rpcs3/Gui/Debugger.cpp index 61499efb88..010ea4edf5 100644 --- a/rpcs3/Gui/Debugger.cpp +++ b/rpcs3/Gui/Debugger.cpp @@ -42,7 +42,7 @@ public: { m_btn_run->Enable(!Emu.IsStopped()); m_btn_stop->Enable(!Emu.IsStopped()); - m_btn_restart->Enable(!Emu.m_path.IsEmpty()); + m_btn_restart->Enable(!Emu.m_path.empty()); } void OnRun(wxCommandEvent& event) diff --git a/rpcs3/Gui/DisAsmFrame.cpp b/rpcs3/Gui/DisAsmFrame.cpp index d9520348fa..586e9b8edf 100644 --- a/rpcs3/Gui/DisAsmFrame.cpp +++ b/rpcs3/Gui/DisAsmFrame.cpp @@ -172,7 +172,7 @@ public: disasm->dump_pc = sh_addr + off; decoder->Decode(Memory.Read32(disasm->dump_pc)); - arr[id][sh].Add(disasm->last_opcode); + arr[id][sh].Add(fmt::FromUTF8(disasm->last_opcode)); off += (cores - id) * 4; off += id * 4; @@ -297,7 +297,7 @@ void DisAsmFrame::Dump(wxCommandEvent& WXUNUSED(event)) vfsLocalFile& f_elf = *new vfsLocalFile(nullptr); f_elf.Open(Emu.m_path); - ConLog.Write("path: %s", Emu.m_path.wx_str()); + ConLog.Write("path: %s", Emu.m_path.c_str()); Elf_Ehdr ehdr; ehdr.Load(f_elf); @@ -306,7 +306,7 @@ void DisAsmFrame::Dump(wxCommandEvent& WXUNUSED(event)) ConLog.Error("Corrupted ELF!"); return; } - wxArrayString name_arr; + std::vector name_arr; switch(ehdr.GetClass()) { @@ -384,10 +384,10 @@ void DisAsmFrame::Dump(wxCommandEvent& WXUNUSED(event)) const u64 sh_size = (ElfType64 ? (*shdr_arr_64)[sh].sh_size : (*shdr_arr_32)[sh].sh_size) / 4; const u64 sh_addr = (ElfType64 ? (*shdr_arr_64)[sh].sh_addr : (*shdr_arr_32)[sh].sh_addr); - const wxString name = sh < name_arr.GetCount() ? name_arr[sh] : "Unknown"; + const std::string name = sh < name_arr.size() ? name_arr[sh] : "Unknown"; - fd.Write(wxString::Format("Start of section header %s[%d] (instructions count: %d)\n", name.wx_str(), sh, sh_size)); - prog_dial.Update(0, vsize, wxString::Format("Disasm %s section", name.wx_str())); + fd.Write(wxString::Format("Start of section header %s[%d] (instructions count: %d)\n", name.c_str(), sh, sh_size)); + prog_dial.Update(0, vsize, wxString::Format("Disasm %s section", name.c_str())); if(Memory.IsGoodAddr(sh_addr)) { @@ -396,10 +396,10 @@ void DisAsmFrame::Dump(wxCommandEvent& WXUNUSED(event)) disasm->dump_pc = addr; decoder->Decode(Memory.Read32(disasm->dump_pc)); fd.Write("\t"); - fd.Write(disasm->last_opcode); + fd.Write(fmt::FromUTF8(disasm->last_opcode)); } } - fd.Write(wxString::Format("End of section header %s[%d]\n\n", name.wx_str(), sh)); + fd.Write(wxString::Format("End of section header %s[%d]\n\n", name.c_str(), sh)); } prog_dial.Close(); @@ -481,7 +481,7 @@ void DisAsmFrame::SetPc(wxCommandEvent& WXUNUSED(event)) if(diag.ShowModal() == wxID_OK) { - sscanf(p_pc->GetLabel(), "%llx", &CPU.PC); + sscanf(fmt::ToUTF8(p_pc->GetLabel()).c_str(), "%llx", &CPU.PC); Resume(); } } diff --git a/rpcs3/Gui/FrameBase.h b/rpcs3/Gui/FrameBase.h index e6abb14287..b35a5edd40 100644 --- a/rpcs3/Gui/FrameBase.h +++ b/rpcs3/Gui/FrameBase.h @@ -11,7 +11,7 @@ protected: wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& framename = "UnknownFrame", - const wxString& ininame = wxEmptyString, + const std::string& ininame = "", wxSize defsize = wxDefaultSize, wxPoint defposition = wxDefaultPosition, long style = wxDEFAULT_FRAME_STYLE, @@ -20,7 +20,7 @@ protected: , m_default_info(defsize, defposition) , m_is_skip_resize(is_skip_resize) { - m_ini.Init(ininame.IsEmpty() ? framename : ininame, "GuiSettings"); + m_ini.Init(ininame.empty() ? fmt::ToUTF8(framename) : ininame, "GuiSettings"); LoadInfo(); Connect(GetId(), wxEVT_CLOSE_WINDOW, wxCloseEventHandler(FrameBase::OnClose)); diff --git a/rpcs3/Gui/GameViewer.cpp b/rpcs3/Gui/GameViewer.cpp index 8450c81208..e7a9cb3511 100644 --- a/rpcs3/Gui/GameViewer.cpp +++ b/rpcs3/Gui/GameViewer.cpp @@ -2,7 +2,7 @@ #include "GameViewer.h" #include "Loader/PSF.h" -static const wxString m_class_name = "GameViewer"; +static const std::string m_class_name = "GameViewer"; GameViewer::GameViewer(wxWindow* parent) : wxListView(parent) { LoadSettings(); @@ -28,16 +28,16 @@ void GameViewer::DoResize(wxSize size) void GameViewer::LoadGames() { vfsDir dir(m_path); - ConLog.Write("path: %s", m_path.wx_str()); + ConLog.Write("path: %s", m_path.c_str()); if(!dir.IsOpened()) return; - m_games.Clear(); + m_games.clear(); for(const DirEntryInfo* info = dir.Read(); info; info = dir.Read()) { if(info->flags & DirEntry_TypeDir) { - m_games.Add(info->name); + m_games.push_back(info->name); } } @@ -48,9 +48,9 @@ void GameViewer::LoadGames() void GameViewer::LoadPSF() { m_game_data.clear(); - for(uint i=0; i data; - const wxString name; + const std::string name; const u32 def_pos; const u32 def_width; - Column(const u32 _def_pos, const u32 _def_width, const wxString& _name) + Column(const u32 _def_pos, const u32 _def_width, const std::string& _name) : def_pos(_def_pos) , def_width(_def_width) , pos(_def_pos) @@ -21,7 +21,7 @@ struct Column , shown(true) , name(_name) { - data.Clear(); + data.clear(); } }; @@ -91,23 +91,23 @@ public: void Update(std::vector& game_data) { - m_col_name->data.Clear(); - m_col_serial->data.Clear(); - m_col_fw->data.Clear(); - m_col_app_ver->data.Clear(); - m_col_category->data.Clear(); - m_col_path->data.Clear(); + m_col_name->data.clear(); + m_col_serial->data.clear(); + m_col_fw->data.clear(); + m_col_app_ver->data.clear(); + m_col_category->data.clear(); + m_col_path->data.clear(); if(m_columns.GetCount() == 0) return; for(const auto& game : game_data) { - m_col_name->data.Add(game.name); - m_col_serial->data.Add(game.serial); - m_col_fw->data.Add(game.fw); - m_col_app_ver->data.Add(game.app_ver); - m_col_category->data.Add(game.category); - m_col_path->data.Add(game.root); + m_col_name->data.push_back(game.name); + m_col_serial->data.push_back(game.serial); + m_col_fw->data.push_back(game.fw); + m_col_app_ver->data.push_back(game.app_ver); + m_col_category->data.push_back(game.category); + m_col_path->data.push_back(game.root); } } @@ -118,7 +118,7 @@ public: for(u32 i=0, c=0; iInsertColumn(c++, c_col[i].name, 0, c_col[i].width); + list->InsertColumn(c++, fmt::FromUTF8(c_col[i].name), 0, c_col[i].width); } } @@ -135,15 +135,15 @@ public: return; } - for(u32 i=0; idata.GetCount(); ++i) + for(u32 i=0; idata.size(); ++i) { if(list->GetItemCount() <= (int)i) list->InsertItem(i, wxEmptyString); - list->SetItem(i, c, col->data[i]); + list->SetItem(i, c, fmt::FromUTF8(col->data[i])); } } } - void LoadSave(bool isLoad, const wxString& path, wxListView* list = NULL) + void LoadSave(bool isLoad, const std::string& path, wxListView* list = NULL) { if(isLoad) Init(); else if(list) @@ -215,8 +215,8 @@ public: class GameViewer : public wxListView { - wxString m_path; - wxArrayString m_games; + std::string m_path; + std::vector m_games; std::vector m_game_data; ColumnsArr m_columns; diff --git a/rpcs3/Gui/InstructionEditor.h b/rpcs3/Gui/InstructionEditor.h index 5b9c508a87..4da800cbe6 100644 --- a/rpcs3/Gui/InstructionEditor.h +++ b/rpcs3/Gui/InstructionEditor.h @@ -98,7 +98,7 @@ void InstructionEditorDialog::updatePreview(wxCommandEvent& event) { disasm->dump_pc = pc; ((PPCDecoder*)decoder)->Decode((u32)opcode); - wxString preview = disasm->last_opcode; + wxString preview = fmt::FromUTF8(disasm->last_opcode); preview.Remove(0, preview.Find(':') + 1); t3_preview->SetLabel(preview); } diff --git a/rpcs3/Gui/InterpreterDisAsm.cpp b/rpcs3/Gui/InterpreterDisAsm.cpp index 362c01dd64..26fae5083c 100644 --- a/rpcs3/Gui/InterpreterDisAsm.cpp +++ b/rpcs3/Gui/InterpreterDisAsm.cpp @@ -257,11 +257,11 @@ void InterpreterDisAsmFrame::ShowAddr(const u64 addr) if(IsBreakPoint(PC)) { - m_list->SetItem(i, 0, ">>> " + disasm->last_opcode); + m_list->SetItem(i, 0, fmt::FromUTF8(">>> " + disasm->last_opcode)); } else { - m_list->SetItem(i, 0, " " + disasm->last_opcode); + m_list->SetItem(i, 0, fmt::FromUTF8(" " + disasm->last_opcode)); } wxColour colour; @@ -318,11 +318,11 @@ void InterpreterDisAsmFrame::WriteRegs() return; } - const wxString data = CPU->RegsToString(); + const std::string data = CPU->RegsToString(); m_regs->Freeze(); m_regs->Clear(); - m_regs->WriteText(data); + m_regs->WriteText(fmt::FromUTF8(data)); m_regs->Thaw(); } @@ -334,11 +334,11 @@ void InterpreterDisAsmFrame::WriteCallStack() return; } - const wxString data = CPU->CallStackToString(); + const std::string data = CPU->CallStackToString(); m_calls->Freeze(); m_calls->Clear(); - m_calls->WriteText(data); + m_calls->WriteText(fmt::FromUTF8(data)); m_calls->Thaw(); } diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index c405b9ad9d..691c8a825a 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -163,16 +163,16 @@ void MainFrame::AddPane(wxWindow* wind, const wxString& caption, int flags) void MainFrame::DoSettings(bool load) { - IniEntry ini; + IniEntry ini; ini.Init("Settings", "MainFrameAui"); if(load) { - m_aui_mgr.LoadPerspective(ini.LoadValue(m_aui_mgr.SavePerspective())); + m_aui_mgr.LoadPerspective(fmt::FromUTF8(ini.LoadValue(fmt::ToUTF8(m_aui_mgr.SavePerspective())))); } else { - ini.SaveValue(m_aui_mgr.SavePerspective()); + ini.SaveValue(fmt::ToUTF8(m_aui_mgr.SavePerspective())); } } @@ -228,7 +228,7 @@ void MainFrame::InstallPkg(wxCommandEvent& WXUNUSED(event)) Emu.Stop(); // Open and install PKG file - std::string filePath = ctrl.GetPath().ToStdString(); + wxString filePath = ctrl.GetPath(); wxFile pkg_f(filePath, wxFile::read); // TODO: Use VFS to install PKG files if (pkg_f.IsOpened()) @@ -271,7 +271,7 @@ void MainFrame::BootElf(wxCommandEvent& WXUNUSED(event)) Emu.Stop(); - Emu.SetPath(ctrl.GetPath()); + Emu.SetPath(fmt::ToUTF8(ctrl.GetPath())); Emu.Load(); ConLog.Success("(S)ELF: boot done."); @@ -862,7 +862,7 @@ void MainFrame::UpdateUI(wxCommandEvent& event) //send_exit.Enable(false); bool enable_commands = !is_stopped && Emu.GetCallbackManager().m_exit_callback.m_callbacks.GetCount(); - send_open_menu.SetItemLabel(wxString::Format("Send %s system menu cmd", wxString(m_sys_menu_opened ? "close" : "open").wx_str())); + send_open_menu.SetItemLabel(wxString::Format("Send %s system menu cmd", (m_sys_menu_opened ? "close" : "open"))); send_open_menu.Enable(enable_commands); send_exit.Enable(enable_commands); @@ -887,7 +887,7 @@ void MainFrame::OnKeyDown(wxKeyEvent& event) case 'E': case 'e': if(Emu.IsPaused()) Emu.Resume(); else if(Emu.IsReady()) Emu.Run(); return; case 'P': case 'p': if(Emu.IsRunning()) Emu.Pause(); return; case 'S': case 's': if(!Emu.IsStopped()) Emu.Stop(); return; - case 'R': case 'r': if(!Emu.m_path.IsEmpty()) {Emu.Stop(); Emu.Run();} return; + case 'R': case 'r': if(!Emu.m_path.empty()) {Emu.Stop(); Emu.Run();} return; } } diff --git a/rpcs3/Gui/RSXDebugger.cpp b/rpcs3/Gui/RSXDebugger.cpp index 7a69ac0793..cb7a39adbb 100644 --- a/rpcs3/Gui/RSXDebugger.cpp +++ b/rpcs3/Gui/RSXDebugger.cpp @@ -828,7 +828,7 @@ wxString RSXDebugger::DisAsmCommand(u32 cmd, u32 count, u32 currentAddr, u32 ioA default: DISASM("(Bad location!);"); break; } DISASM(" Cubemap:%s; Dimension:0x%x; Format:0x%x; Mipmap:0x%x", - wxString(((args[1] >> 2) & 0x1) ? "True" : "False").wx_str(), + (((args[1] >> 2) & 0x1) ? "True" : "False"), ((args[1] >> 4) & 0xf), ((args[1] >> 8) & 0xff), ((args[1] >> 16) & 0xffff)); diff --git a/rpcs3/Gui/RegisterEditor.h b/rpcs3/Gui/RegisterEditor.h index 56659ffbcb..56557f4b7f 100644 --- a/rpcs3/Gui/RegisterEditor.h +++ b/rpcs3/Gui/RegisterEditor.h @@ -92,8 +92,8 @@ RegisterEditorDialog::RegisterEditorDialog(wxPanel *parent, u64 _pc, CPUThread* if(ShowModal() == wxID_OK) { - wxString reg = t1_register->GetStringSelection(); - wxString value = t2_value->GetValue(); + std::string reg = fmt::ToUTF8(t1_register->GetStringSelection()); + std::string value = fmt::ToUTF8(t2_value->GetValue()); if (!CPU->WriteRegString(reg,value)) wxMessageBox("This value could not be converted.\nNo changes were made.","Error"); } @@ -101,6 +101,6 @@ RegisterEditorDialog::RegisterEditorDialog(wxPanel *parent, u64 _pc, CPUThread* void RegisterEditorDialog::updateRegister(wxCommandEvent& event) { - wxString reg = t1_register->GetStringSelection(); - t2_value->SetValue(CPU->ReadRegString(reg)); + std::string reg = fmt::ToUTF8(t1_register->GetStringSelection()); + t2_value->SetValue(fmt::FromUTF8(CPU->ReadRegString(reg))); } diff --git a/rpcs3/Gui/TextInputDialog.cpp b/rpcs3/Gui/TextInputDialog.cpp index 619bcf57c4..cd5047c815 100644 --- a/rpcs3/Gui/TextInputDialog.cpp +++ b/rpcs3/Gui/TextInputDialog.cpp @@ -1,10 +1,10 @@ #include "stdafx.h" #include "TextInputDialog.h" -TextInputDialog::TextInputDialog(wxWindow* parent, const wxString& defvalue) +TextInputDialog::TextInputDialog(wxWindow* parent, const std::string& defvalue) : wxDialog(parent, wxID_ANY, "Input text", wxDefaultPosition) { - m_tctrl_text = new wxTextCtrl(this, wxID_ANY, defvalue); + m_tctrl_text = new wxTextCtrl(this, wxID_ANY, fmt::ToUTF8(defvalue)); wxBoxSizer& s_text(*new wxBoxSizer(wxVERTICAL)); s_text.Add(m_tctrl_text, 1, wxEXPAND); @@ -27,11 +27,11 @@ TextInputDialog::TextInputDialog(wxWindow* parent, const wxString& defvalue) void TextInputDialog::OnOk(wxCommandEvent& event) { - m_result = m_tctrl_text->GetValue(); + m_result = fmt::ToUTF8(m_tctrl_text->GetValue()); EndModal(wxID_OK); } -wxString& TextInputDialog::GetResult() +std::string TextInputDialog::GetResult() { return m_result; } \ No newline at end of file diff --git a/rpcs3/Gui/TextInputDialog.h b/rpcs3/Gui/TextInputDialog.h index cb4cf0ab52..bc04510a53 100644 --- a/rpcs3/Gui/TextInputDialog.h +++ b/rpcs3/Gui/TextInputDialog.h @@ -3,11 +3,11 @@ class TextInputDialog : public wxDialog { wxTextCtrl* m_tctrl_text; - wxString m_result; + std::string m_result; public: - TextInputDialog(wxWindow* parent, const wxString& defvalue = wxEmptyString); + TextInputDialog(wxWindow* parent, const std::string& defvalue = ""); void OnOk(wxCommandEvent& event); - wxString& GetResult(); + std::string GetResult(); }; \ No newline at end of file diff --git a/rpcs3/Gui/VHDDManager.cpp b/rpcs3/Gui/VHDDManager.cpp index f64bef72b3..d8e028cc32 100644 --- a/rpcs3/Gui/VHDDManager.cpp +++ b/rpcs3/Gui/VHDDManager.cpp @@ -49,7 +49,7 @@ enum id_add_hdd }; -VHDDExplorer::VHDDExplorer(wxWindow* parent, const wxString& hdd_path) : wxDialog(parent, wxID_ANY, "Virtual HDD Explorer", wxDefaultPosition) +VHDDExplorer::VHDDExplorer(wxWindow* parent, const std::string& hdd_path) : wxDialog(parent, wxID_ANY, "Virtual HDD Explorer", wxDefaultPosition) { m_list = new wxListView(this); m_drop_target = new VHDDListDropTarget(m_list); @@ -88,21 +88,21 @@ void VHDDExplorer::UpdateList() m_list->Freeze(); m_list->DeleteAllItems(); m_entries.clear(); - m_names.Clear(); + m_names.clear(); u64 block; vfsHDD_Entry entry; - wxString name; + std::string name; for(bool is_ok = m_hdd->GetFirstEntry(block, entry, name); is_ok; is_ok = m_hdd->GetNextEntry(block, entry, name)) { int item = m_list->GetItemCount(); - m_list->InsertItem(item, name); + m_list->InsertItem(item, fmt::FromUTF8(name)); m_list->SetItem(item, 1, entry.type == vfsHDD_Entry_Dir ? "Dir" : "File"); m_list->SetItem(item, 2, wxString::Format("%lld", entry.size)); m_list->SetItem(item, 3, wxDateTime().Set(time_t(entry.ctime)).Format()); m_entries.push_back(entry); - m_names.Add(name); + m_names.push_back(name); } m_list->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); @@ -112,7 +112,7 @@ void VHDDExplorer::UpdateList() m_list->Thaw(); } -void VHDDExplorer::Import(const wxString& path, const wxString& to) +void VHDDExplorer::Import(const std::string& path, const std::string& to) { if(!m_hdd->Create(vfsHDD_Entry_File, to)) { @@ -126,7 +126,7 @@ void VHDDExplorer::Import(const wxString& path, const wxString& to) return; } - wxFile f(path); + wxFile f(fmt::FromUTF8(path)); char buf[256]; while(!f.Eof()) @@ -137,15 +137,15 @@ void VHDDExplorer::Import(const wxString& path, const wxString& to) m_hdd->Close(); } -void VHDDExplorer::Export(const wxString& path, const wxString& to) +void VHDDExplorer::Export(const std::string& path, const std::string& to) { if(!m_hdd->Open(path)) { - wxMessageBox(wxString::Format("EXPORT ERROR: file open error. (%s)", path.wx_str())); + wxMessageBox(wxString::Format("EXPORT ERROR: file open error. (%s)", path.c_str())); return; } - wxFile f(to, wxFile::write); + wxFile f(fmt::FromUTF8(to), wxFile::write); char buf[256]; while(u64 size = m_hdd->Read(buf, 256)) @@ -189,7 +189,7 @@ void VHDDExplorer::OnDropFiles(wxDropFilesEvent& event) for(int i=0; iHasEntry(wxString::Format(fmt, i))) i++; + static const std::string& fmt = "New Dir (%d)"; + while(m_hdd->HasEntry(fmt::Format(fmt, i))) i++; - m_hdd->Create(vfsHDD_Entry_Dir, wxString::Format(fmt, i)); + m_hdd->Create(vfsHDD_Entry_Dir, fmt::Format(fmt, i)); UpdateList(); } void VHDDExplorer::OnCreateFile(wxCommandEvent& event) { int i = 1; - static const wxString& fmt = "New File (%d)"; - while(m_hdd->HasEntry(wxString::Format(fmt, i))) i++; + static const std::string& fmt = "New File (%d)"; + while (m_hdd->HasEntry(fmt::Format(fmt, i))) i++; - m_hdd->Create(vfsHDD_Entry_File, wxString::Format(fmt, i)); + m_hdd->Create(vfsHDD_Entry_File, fmt::Format(fmt, i)); UpdateList(); } @@ -281,7 +281,7 @@ void VHDDExplorer::OnImport(wxCommandEvent& event) { if(wxFileExists(paths[i])) { - Import(paths[i], wxFileName(paths[i]).GetFullName()); + Import(fmt::ToUTF8(paths[i]), fmt::ToUTF8(wxFileName(paths[i]).GetFullName())); } } UpdateList(); @@ -300,20 +300,20 @@ void VHDDExplorer::OnExport(wxCommandEvent& event) for(int sel = m_list->GetNextSelected(-1); sel != wxNOT_FOUND; sel = m_list->GetNextSelected(sel)) { - Export(m_names[sel], ctrl.GetPath() + '\\' + m_names[sel]); + Export(m_names[sel], fmt::ToUTF8(ctrl.GetPath()) + '\\' + m_names[sel]); } } else { int sel = m_list->GetFirstSelected(); - wxFileDialog ctrl(this, "Select export file", wxEmptyString, m_names[sel], wxFileSelectorDefaultWildcardStr, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); + wxFileDialog ctrl(this, "Select export file", wxEmptyString, fmt::FromUTF8(m_names[sel]), wxFileSelectorDefaultWildcardStr, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if(ctrl.ShowModal() == wxID_CANCEL) { return; } - Export(m_names[sel], ctrl.GetPath()); + Export(m_names[sel], fmt::ToUTF8(ctrl.GetPath())); } UpdateList(); @@ -446,7 +446,7 @@ void VHDDManagerDialog::AddHDD(wxCommandEvent& event) bool skip = false; for(size_t j=0; j path_entry; - path_entry.Init(wxString::Format("path[%d]", i), "HDDManager"); - m_paths.emplace_back(path_entry.LoadValue(wxEmptyString)); + IniEntry path_entry; + path_entry.Init(fmt::Format("path[%d]", i), "HDDManager"); + m_paths.emplace_back(path_entry.LoadValue("")); } } @@ -540,8 +540,8 @@ void VHDDManagerDialog::SavePaths() for(size_t i=0; i path_entry; - path_entry.Init(wxString::Format("path[%d]", i), "HDDManager"); + IniEntry path_entry; + path_entry.Init(fmt::Format("path[%d]", i), "HDDManager"); path_entry.SaveValue(m_paths[i]); } } diff --git a/rpcs3/Gui/VHDDManager.h b/rpcs3/Gui/VHDDManager.h index 8632f225bb..e598a10161 100644 --- a/rpcs3/Gui/VHDDManager.h +++ b/rpcs3/Gui/VHDDManager.h @@ -22,17 +22,17 @@ public: class VHDDExplorer : public wxDialog { std::vector m_entries; - wxArrayString m_names; + std::vector m_names; wxListView* m_list; vfsHDD* m_hdd; VHDDListDropTarget* m_drop_target; public: - VHDDExplorer(wxWindow* parent, const wxString& hdd_path); + VHDDExplorer(wxWindow* parent, const std::string& hdd_path); void UpdateList(); - void Import(const wxString& path, const wxString& to); - void Export(const wxString& path, const wxString& to); + void Import(const std::string& path, const std::string& to); + void Export(const std::string& path, const std::string& to); void OnListDrag(wxListEvent& event); void OnDropFiles(wxDropFilesEvent& event); @@ -66,7 +66,7 @@ public: class VHDDManagerDialog : public wxDialog { - std::vector m_paths; + std::vector m_paths; wxListView* m_list; public: diff --git a/rpcs3/Ini.cpp b/rpcs3/Ini.cpp index 8ab63d3ca3..28b8375084 100644 --- a/rpcs3/Ini.cpp +++ b/rpcs3/Ini.cpp @@ -33,7 +33,7 @@ static wxSize StringToSize(const wxString& str) { wxSize ret; - wxString s[2] = {wxEmptyString}; + wxString s[2] = {wxEmptyString, wxEmptyString}; for(uint i=0, a=0; iWrite(key, PositionToString(value)); } -void Ini::Save(const wxString& key, wxString value) +void Ini::Save(const wxString& key, const std::string& value) { - m_Config->Write(key, value); + m_Config->Write(key, fmt::FromUTF8(value)); } void Ini::Save(const wxString& key, WindowInfo value) @@ -209,9 +209,9 @@ wxPoint Ini::Load(const wxString& key, const wxPoint def_value) return StringToPosition(m_Config->Read(key, PositionToString(def_value))); } -wxString Ini::Load(const wxString& key, const wxString& def_value) +std::string Ini::Load(const wxString& key, const std::string& def_value) { - return m_Config->Read(key, def_value); + return fmt::ToUTF8(m_Config->Read(key, def_value)); } WindowInfo Ini::Load(const wxString& key, const WindowInfo& def_value) diff --git a/rpcs3/Ini.h b/rpcs3/Ini.h index d8f7e55f9c..b273d69577 100644 --- a/rpcs3/Ini.h +++ b/rpcs3/Ini.h @@ -29,30 +29,30 @@ protected: virtual void Save(const wxString& key, bool value); virtual void Save(const wxString& key, wxSize value); virtual void Save(const wxString& key, wxPoint value); - virtual void Save(const wxString& key, wxString value); + virtual void Save(const wxString& key, const std::string& value); virtual void Save(const wxString& key, WindowInfo value); virtual int Load(const wxString& key, const int def_value); virtual bool Load(const wxString& key, const bool def_value); virtual wxSize Load(const wxString& key, const wxSize def_value); virtual wxPoint Load(const wxString& key, const wxPoint def_value); - virtual wxString Load(const wxString& key, const wxString& def_value); + virtual std::string Load(const wxString& key, const std::string& def_value); virtual WindowInfo Load(const wxString& key, const WindowInfo& def_value); }; template struct IniEntry : public Ini { T m_value; - wxString m_key; + std::string m_key; IniEntry() : Ini() { } - void Init(const wxString& key, const wxString& path) + void Init(const std::string& key, const std::string& path) { m_key = key; - m_Config->SetPath(path); + m_Config->SetPath(fmt::FromUTF8(path)); } void SetValue(const T& value) @@ -89,7 +89,7 @@ template struct IniEntry : public Ini class Inis { private: - const wxString DefPath; + const std::string DefPath; public: IniEntry CPUDecoderMode; @@ -133,7 +133,7 @@ public: public: Inis() : DefPath("EmuSettings") { - wxString path; + std::string path; path = DefPath + "/" + "CPU"; CPUDecoderMode.Init("DecoderMode", path); diff --git a/rpcs3/Loader/ELF32.cpp b/rpcs3/Loader/ELF32.cpp index 9d7b3b84f2..a68a0c2ce1 100644 --- a/rpcs3/Loader/ELF32.cpp +++ b/rpcs3/Loader/ELF32.cpp @@ -184,7 +184,7 @@ bool ELF32Loader::LoadShdrInfo() name.AddCpy(c); } name.AddCpy('\0'); - shdr_name_arr.Add(wxString(name.GetPtr(), wxConvUTF8)); + shdr_name_arr.push_back(std::string(name.GetPtr())); } return true; @@ -275,13 +275,13 @@ bool ELF32Loader::LoadPhdrData(u64 _offset) if(note.descsz == sizeof(note.desc)) { - ConLog.Warning("name = %s", wxString(note.name, 8).wx_str()); + ConLog.Warning("name = %s", std::string((const char *)note.name, 8).c_str()); ConLog.Warning("ls_size = %d", note.desc.ls_size); ConLog.Warning("stack_size = %d", note.desc.stack_size); } else { - ConLog.Warning("desc = '%s'", wxString(note.desc_text, 32).wx_str()); + ConLog.Warning("desc = '%s'", std::string(note.desc_text, 32).c_str()); } } #ifdef LOADER_DEBUG @@ -299,7 +299,7 @@ bool ELF32Loader::LoadShdrData(u64 offset) Elf32_Shdr& shdr = shdr_arr[i]; #ifdef LOADER_DEBUG - if(i < shdr_name_arr.GetCount()) ConLog.Write("Name: %s", shdr_name_arr[i].wx_str()); + if(i < shdr_name_arr.GetCount()) ConLog.Write("Name: %s", shdr_name_arr[i].c_str()); shdr.Show(); ConLog.SkipLn(); #endif diff --git a/rpcs3/Loader/ELF32.h b/rpcs3/Loader/ELF32.h index 10154db8c9..50713431fc 100644 --- a/rpcs3/Loader/ELF32.h +++ b/rpcs3/Loader/ELF32.h @@ -27,13 +27,13 @@ struct Elf32_Ehdr { #ifdef LOADER_DEBUG ConLog.Write("Magic: %08x", e_magic); - ConLog.Write("Class: %s", wxString("ELF32").wx_str()); - ConLog.Write("Data: %s", Ehdr_DataToString(e_data).wx_str()); + ConLog.Write("Class: %s", "ELF32"); + ConLog.Write("Data: %s", Ehdr_DataToString(e_data).c_str()); ConLog.Write("Current Version: %d", e_curver); - ConLog.Write("OS/ABI: %s", Ehdr_OS_ABIToString(e_os_abi).wx_str()); + ConLog.Write("OS/ABI: %s", Ehdr_OS_ABIToString(e_os_abi).c_str()); ConLog.Write("ABI version: %lld", e_abi_ver); - ConLog.Write("Type: %s", Ehdr_TypeToString(e_type).wx_str()); - ConLog.Write("Machine: %s", Ehdr_MachineToString(e_machine).wx_str()); + ConLog.Write("Type: %s", Ehdr_TypeToString(e_type).c_str()); + ConLog.Write("Machine: %s", Ehdr_MachineToString(e_machine).c_str()); ConLog.Write("Version: %d", e_version); ConLog.Write("Entry point address: 0x%x", e_entry); ConLog.Write("Program headers offset: 0x%08x", e_phoff); @@ -268,13 +268,13 @@ struct Elf32_Phdr void Show() { #ifdef LOADER_DEBUG - ConLog.Write("Type: %s", Phdr_TypeToString(p_type).wx_str()); + ConLog.Write("Type: %s", Phdr_TypeToString(p_type).c_str()); ConLog.Write("Offset: 0x%08x", p_offset); ConLog.Write("Virtual address: 0x%08x", p_vaddr); ConLog.Write("Physical address: 0x%08x", p_paddr); ConLog.Write("File size: 0x%08x", p_filesz); ConLog.Write("Memory size: 0x%08x", p_memsz); - ConLog.Write("Flags: %s", Phdr_FlagsToString(p_flags).wx_str()); + ConLog.Write("Flags: %s", Phdr_FlagsToString(p_flags).c_str()); ConLog.Write("Align: 0x%x", p_align); #endif } @@ -286,7 +286,7 @@ class ELF32Loader : public LoaderBase public: Elf32_Ehdr ehdr; - wxArrayString shdr_name_arr; + std::vector shdr_name_arr; Array shdr_arr; Array phdr_arr; diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index 321e3723ed..2093b89790 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -152,7 +152,7 @@ bool ELF64Loader::LoadPhdrInfo(s64 offset) bool ELF64Loader::LoadShdrInfo(s64 offset) { shdr_arr.Clear(); - shdr_name_arr.Clear(); + shdr_name_arr.clear(); if(ehdr.e_shoff == 0 && ehdr.e_shnum) { ConLog.Warning("LoadShdr64 error: Section header offset is null!"); @@ -185,7 +185,7 @@ bool ELF64Loader::LoadShdrInfo(s64 offset) name.AddCpy(c); } name.AddCpy('\0'); - shdr_name_arr.Add(wxString(name.GetPtr(), wxConvUTF8)); + shdr_name_arr.push_back(std::string(name.GetPtr())); } return true; @@ -336,15 +336,15 @@ bool ELF64Loader::LoadPhdrData(u64 offset) stub.s_nid = re(stub.s_nid); stub.s_text = re(stub.s_text); - const wxString& module_name = Memory.ReadString(stub.s_modulename); - Module* module = GetModuleByName(module_name.ToStdString()); + const std::string& module_name = Memory.ReadString(stub.s_modulename); + Module* module = GetModuleByName(module_name); if(module) { //module->SetLoaded(); } else { - ConLog.Warning("Unknown module '%s'", module_name.wx_str()); + ConLog.Warning("Unknown module '%s'", module_name.c_str()); } #ifdef LOADER_DEBUG @@ -354,7 +354,7 @@ bool ELF64Loader::LoadPhdrData(u64 offset) ConLog.Write("*** unk0: 0x%x", stub.s_unk0); ConLog.Write("*** unk1: 0x%x", stub.s_unk1); ConLog.Write("*** imports: %d", stub.s_imports); - ConLog.Write("*** module name: %s [0x%x]", module_name.wx_str(), stub.s_modulename); + ConLog.Write("*** module name: %s [0x%x]", module_name.c_str(), stub.s_modulename); ConLog.Write("*** nid: 0x%x", stub.s_nid); ConLog.Write("*** text: 0x%x", stub.s_text); #endif @@ -371,7 +371,7 @@ bool ELF64Loader::LoadPhdrData(u64 offset) { if(!module->Load(nid)) { - ConLog.Warning("Unknown function 0x%08x in '%s' module", nid, module_name.wx_str()); + ConLog.Warning("Unknown function 0x%08x in '%s' module", nid, module_name.c_str()); SysCalls::DoFunc(nid); } } @@ -415,12 +415,10 @@ bool ELF64Loader::LoadShdrData(u64 offset) { Elf64_Shdr& shdr = shdr_arr[i]; - if(i < shdr_name_arr.GetCount()) + if(i < shdr_name_arr.size()) { - const wxString& name = shdr_name_arr[i]; - #ifdef LOADER_DEBUG - ConLog.Write("Name: %s", shdr_name_arr[i].wx_str()); + ConLog.Write("Name: %s", shdr_name_arr[i].c_str()); #endif } diff --git a/rpcs3/Loader/ELF64.h b/rpcs3/Loader/ELF64.h index 9e977c7241..8d56e0cf73 100644 --- a/rpcs3/Loader/ELF64.h +++ b/rpcs3/Loader/ELF64.h @@ -50,13 +50,13 @@ struct Elf64_Ehdr { #ifdef LOADER_DEBUG ConLog.Write("Magic: %08x", e_magic); - ConLog.Write("Class: %s", wxString("ELF64").wx_str()); - ConLog.Write("Data: %s", Ehdr_DataToString(e_data).wx_str()); + ConLog.Write("Class: %s", "ELF64"); + ConLog.Write("Data: %s", Ehdr_DataToString(e_data).c_str()); ConLog.Write("Current Version: %d", e_curver); - ConLog.Write("OS/ABI: %s", Ehdr_OS_ABIToString(e_os_abi).wx_str()); + ConLog.Write("OS/ABI: %s", Ehdr_OS_ABIToString(e_os_abi).c_str()); ConLog.Write("ABI version: %lld", e_abi_ver); - ConLog.Write("Type: %s", Ehdr_TypeToString(e_type).wx_str()); - ConLog.Write("Machine: %s", Ehdr_MachineToString(e_machine).wx_str()); + ConLog.Write("Type: %s", Ehdr_TypeToString(e_type).c_str()); + ConLog.Write("Machine: %s", Ehdr_MachineToString(e_machine).c_str()); ConLog.Write("Version: %d", e_version); ConLog.Write("Entry point address: 0x%08llx", e_entry); ConLog.Write("Program headers offset: 0x%08llx", e_phoff); @@ -145,13 +145,13 @@ struct Elf64_Phdr void Show() { #ifdef LOADER_DEBUG - ConLog.Write("Type: %s", Phdr_TypeToString(p_type).wx_str()); + ConLog.Write("Type: %s", Phdr_TypeToString(p_type).c_str()); ConLog.Write("Offset: 0x%08llx", p_offset); ConLog.Write("Virtual address: 0x%08llx", p_vaddr); ConLog.Write("Physical address: 0x%08llx", p_paddr); ConLog.Write("File size: 0x%08llx", p_filesz); ConLog.Write("Memory size: 0x%08llx", p_memsz); - ConLog.Write("Flags: %s", Phdr_FlagsToString(p_flags).wx_str()); + ConLog.Write("Flags: %s", Phdr_FlagsToString(p_flags).c_str()); ConLog.Write("Align: 0x%llx", p_align); #endif } @@ -163,7 +163,7 @@ class ELF64Loader : public LoaderBase public: Elf64_Ehdr ehdr; - wxArrayString shdr_name_arr; + std::vector shdr_name_arr; Array shdr_arr; Array phdr_arr; diff --git a/rpcs3/Loader/Loader.cpp b/rpcs3/Loader/Loader.cpp index b9107cce0e..be0ac775fc 100644 --- a/rpcs3/Loader/Loader.cpp +++ b/rpcs3/Loader/Loader.cpp @@ -7,15 +7,15 @@ static const u64 g_spu_offset = 0x10000; -const wxString Ehdr_DataToString(const u8 data) +const std::string Ehdr_DataToString(const u8 data) { - if(data > 1) return wxString::Format("%d's complement, big endian", data); + if(data > 1) return fmt::Format("%d's complement, big endian", data); if(data < 1) return "Data is not found"; - return wxString::Format("%d's complement, small endian", data); + return fmt::Format("%d's complement, small endian", data); } -const wxString Ehdr_TypeToString(const u16 type) +const std::string Ehdr_TypeToString(const u16 type) { switch(type) { @@ -23,10 +23,10 @@ const wxString Ehdr_TypeToString(const u16 type) case 2: return "EXEC (Executable file)"; }; - return wxString::Format("Unknown (%d)", type); + return fmt::Format("Unknown (%d)", type); } -const wxString Ehdr_OS_ABIToString(const u8 os_abi) +const std::string Ehdr_OS_ABIToString(const u8 os_abi) { switch(os_abi) { @@ -34,10 +34,10 @@ const wxString Ehdr_OS_ABIToString(const u8 os_abi) case 0x66: return "Cell OS LV-2"; }; - return wxString::Format("Unknown (%x)", os_abi); + return fmt::Format("Unknown (%x)", os_abi); } -const wxString Ehdr_MachineToString(const u16 machine) +const std::string Ehdr_MachineToString(const u16 machine) { switch(machine) { @@ -47,32 +47,32 @@ const wxString Ehdr_MachineToString(const u16 machine) case MACHINE_ARM: return "ARM"; }; - return wxString::Format("Unknown (%x)", machine); + return fmt::Format("Unknown (%x)", machine); } -const wxString Phdr_FlagsToString(u32 flags) +const std::string Phdr_FlagsToString(u32 flags) { enum {ppu_R = 0x1, ppu_W = 0x2, ppu_E = 0x4}; enum {spu_E = 0x1, spu_W = 0x2, spu_R = 0x4}; enum {rsx_R = 0x1, rsx_W = 0x2, rsx_E = 0x4}; #define FLAGS_TO_STRING(f) \ - wxString(f & f##_R ? "R" : "-") + \ - wxString(f & f##_W ? "W" : "-") + \ - wxString(f & f##_E ? "E" : "-") + std::string(f & f##_R ? "R" : "-") + \ + std::string(f & f##_W ? "W" : "-") + \ + std::string(f & f##_E ? "E" : "-") const u8 ppu = flags & 0xf; const u8 spu = (flags >> 0x14) & 0xf; const u8 rsx = (flags >> 0x18) & 0xf; - wxString ret = wxEmptyString; - ret += wxString::Format("[0x%x] ", flags); + std::string ret; + ret += fmt::Format("[0x%x] ", flags); flags &= ~ppu; flags &= ~spu << 0x14; flags &= ~rsx << 0x18; - if(flags != 0) return wxString::Format("Unknown %s PPU[%x] SPU[%x] RSX[%x]", ret.wx_str(), ppu, spu, rsx); + if(flags != 0) return fmt::Format("Unknown %s PPU[%x] SPU[%x] RSX[%x]", ret.c_str(), ppu, spu, rsx); ret += "PPU[" + FLAGS_TO_STRING(ppu) + "] "; ret += "SPU[" + FLAGS_TO_STRING(spu) + "] "; @@ -81,7 +81,7 @@ const wxString Phdr_FlagsToString(u32 flags) return ret; } -const wxString Phdr_TypeToString(const u32 type) +const std::string Phdr_TypeToString(const u32 type) { switch(type) { @@ -92,7 +92,7 @@ const wxString Phdr_TypeToString(const u32 type) case 0x60000002: return "LOOS+2"; }; - return wxString::Format("Unknown (%x)", type); + return fmt::Format("Unknown (%x)", type); } Loader::Loader() @@ -163,9 +163,9 @@ bool Loader::Load() } /* - const wxString& root = wxFileName(wxFileName(m_stream->GetPath()).GetPath()).GetPath(); - wxString ps3_path; - const wxString& psf_path = root + "/" + "PARAM.SFO"; + const std::string& root = fmt::ToUTF8(wxFileName(wxFileName(m_stream->GetPath()).GetPath()).GetPath()); + std::string ps3_path; + const std::string& psf_path = root + "/" + "PARAM.SFO"; vfsFile f(psf_path); if(f.IsOpened()) { diff --git a/rpcs3/Loader/Loader.h b/rpcs3/Loader/Loader.h index 25eedd0912..c650a876b9 100644 --- a/rpcs3/Loader/Loader.h +++ b/rpcs3/Loader/Loader.h @@ -116,12 +116,12 @@ __forceinline static void Write64LE(wxFile& f, const u64 data) Write32LE(f, data >> 32); } -const wxString Ehdr_DataToString(const u8 data); -const wxString Ehdr_TypeToString(const u16 type); -const wxString Ehdr_OS_ABIToString(const u8 os_abi); -const wxString Ehdr_MachineToString(const u16 machine); -const wxString Phdr_FlagsToString(u32 flags); -const wxString Phdr_TypeToString(const u32 type); +const std::string Ehdr_DataToString(const u8 data); +const std::string Ehdr_TypeToString(const u16 type); +const std::string Ehdr_OS_ABIToString(const u8 os_abi); +const std::string Ehdr_MachineToString(const u16 machine); +const std::string Phdr_FlagsToString(u32 flags); +const std::string Phdr_TypeToString(const u32 type); struct sys_process_param_info { @@ -210,7 +210,7 @@ public: Loader(vfsFileBase& stream); ~Loader(); - void Open(const wxString& path); + void Open(const std::string& path); void Open(vfsFileBase& stream); bool Analyze(); diff --git a/rpcs3/Loader/PKG.cpp b/rpcs3/Loader/PKG.cpp index 9fdabcd59e..3faf6fdb25 100644 --- a/rpcs3/Loader/PKG.cpp +++ b/rpcs3/Loader/PKG.cpp @@ -12,7 +12,7 @@ bool PKGLoader::Install(std::string dest) if (!pkg_f.IsOpened()) return false; - dest = wxGetCwd() + dest; + dest = fmt::ToUTF8(wxGetCwd()) + dest; if (!dest.empty() && dest.back() != '/') dest += '/'; @@ -23,18 +23,18 @@ bool PKGLoader::Install(std::string dest) std::string titleID = std::string(title_id).substr(7, 9); - if (wxDirExists(dest+titleID)) { + if (wxDirExists(fmt::FromUTF8(dest+titleID))) { wxMessageDialog d_overwrite(NULL, "Another installation was found. Do you want to overwrite it?", "PKG Decrypter / Installer", wxYES_NO|wxCENTRE); if (d_overwrite.ShowModal() != wxID_YES) { - ConLog.Error("PKG Loader: Another installation found in: %s", wxString(titleID).wx_str()); + ConLog.Error("PKG Loader: Another installation found in: %s", titleID.c_str()); return false; } // TODO: Remove the following two lines and remove the folder dest+titleID - ConLog.Error("PKG Loader: Another installation found in: %s", wxString(titleID).wx_str()); + ConLog.Error("PKG Loader: Another installation found in: %s", titleID.c_str()); return false; } - if (!wxMkdir(dest+titleID)) { - ConLog.Error("PKG Loader: Could not make the installation directory: %s", wxString(titleID).wx_str()); + if (!wxMkdir(fmt::FromUTF8(dest+titleID))) { + ConLog.Error("PKG Loader: Could not make the installation directory: %s", titleID.c_str()); return false; } @@ -46,7 +46,7 @@ bool PKGLoader::Install(std::string dest) } else { - ConLog.Write("PKG Loader: Package successfully installed in: /dev_hdd0/game/%s", wxString(titleID.c_str()).wx_str()); + ConLog.Write("PKG Loader: Package successfully installed in: /dev_hdd0/game/%s", titleID.c_str()); return true; } } diff --git a/rpcs3/Loader/PSF.cpp b/rpcs3/Loader/PSF.cpp index 83053cc942..03c5d7f124 100644 --- a/rpcs3/Loader/PSF.cpp +++ b/rpcs3/Loader/PSF.cpp @@ -94,7 +94,7 @@ bool PSFLoader::LoadDataTable() return true; } -const char* PSFLoader::GetString(const std::string& key) +std::string PSFLoader::GetString(const std::string& key) { if(PSFEntry* entry = SearchEntry(key)) return entry->FormatString(); diff --git a/rpcs3/Loader/PSF.h b/rpcs3/Loader/PSF.h index 8b2cb799f3..7cd8db139b 100644 --- a/rpcs3/Loader/PSF.h +++ b/rpcs3/Loader/PSF.h @@ -27,16 +27,16 @@ struct PSFEntry u16 fmt; char param[4096]; - const char* FormatString() const + std::string FormatString() const { switch(fmt) { default: case 0x0400: case 0x0402: - return (const char*)param; + return std::string(param); case 0x0404: - return (const char*)wxString::Format("0x%x", FormatInteger()).mb_str(); + return fmt::Format("0x%x", FormatInteger()); } } @@ -65,6 +65,6 @@ public: virtual bool Close(); PSFEntry* SearchEntry(const std::string& key); - const char* GetString(const std::string& key); + std::string GetString(const std::string& key); u32 GetInteger(const std::string& key); }; \ No newline at end of file diff --git a/rpcs3/Loader/SELF.h b/rpcs3/Loader/SELF.h index b8d3a67950..63ac82f90f 100644 --- a/rpcs3/Loader/SELF.h +++ b/rpcs3/Loader/SELF.h @@ -25,7 +25,7 @@ struct SceHeader void Show() { ConLog.Write("Magic: %08x", se_magic); - ConLog.Write("Class: %s", wxString("SELF").wx_str()); + ConLog.Write("Class: %s", "SELF"); ConLog.Write("hver: 0x%08x", se_hver); ConLog.Write("flags: 0x%04x", se_flags); ConLog.Write("type: 0x%04x", se_type); diff --git a/rpcs3/Loader/TROPUSR.cpp b/rpcs3/Loader/TROPUSR.cpp index 03483701e9..738e00ca46 100644 --- a/rpcs3/Loader/TROPUSR.cpp +++ b/rpcs3/Loader/TROPUSR.cpp @@ -120,10 +120,10 @@ bool TROPUSRLoader::Save(const std::string& filepath) bool TROPUSRLoader::Generate(const std::string& filepath, const std::string& configpath) { - wxString path; + std::string path; wxXmlDocument doc; Emu.GetVFS().GetDevice(configpath.c_str(), path); - doc.Load(path); + doc.Load(fmt::FromUTF8(path)); m_table4.clear(); m_table6.clear(); diff --git a/rpcs3/Loader/TRP.cpp b/rpcs3/Loader/TRP.cpp index 3de3738208..de38f9cbca 100644 --- a/rpcs3/Loader/TRP.cpp +++ b/rpcs3/Loader/TRP.cpp @@ -58,7 +58,7 @@ bool TRPLoader::LoadHeader(bool show) return false; if (show) - ConLog.Write("TRP entry #%d: %s", wxString(m_entries[i].name).wx_str()); + ConLog.Write("TRP entry #%d: %s", m_entries[i].name); } return true; diff --git a/rpcs3/rpcs3.cpp b/rpcs3/rpcs3.cpp index b58fd00f5e..e46eea3d9a 100644 --- a/rpcs3/rpcs3.cpp +++ b/rpcs3/rpcs3.cpp @@ -47,7 +47,7 @@ void Rpcs3App::OnArguments() // Force this value to be true Ini.HLEExitOnStop.SetValue(true); - Emu.SetPath(argv[1]); + Emu.SetPath(fmt::ToUTF8(argv[1])); Emu.Load(); Emu.Run(); } diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index 80574729e6..5aa56519bc 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -28,20 +28,20 @@ Application true Unicode - v110 + v120 Application true Unicode - v110 + v120 Application false true Unicode - v110 + v120 false @@ -49,7 +49,7 @@ false true Unicode - v110 + v120 false @@ -207,6 +207,7 @@ + @@ -362,6 +363,7 @@ + diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index b82ef165e5..1c1ed0a365 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -484,6 +484,9 @@ Emu\Cell + + Utilities + @@ -693,5 +696,8 @@ Include + + Utilities + \ No newline at end of file diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index 3e08c96092..a039b04acf 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -262,6 +262,7 @@ enum Status #include "Utilities/Array.h" #include "Utilities/Timer.h" #include "Utilities/IdManager.h" +#include "Utilities/StrFmt.h" #include "AppConnector.h" diff --git a/wxWidgets b/wxWidgets index eb5f454529..6637946d55 160000 --- a/wxWidgets +++ b/wxWidgets @@ -1 +1 @@ -Subproject commit eb5f4545297a32d04a35a360919e908dbea3dfca +Subproject commit 6637946d55f41e8615c09fd202c6399017916e2b