diff options
-rw-r--r-- | src/common/console_listener.cpp | 10 | ||||
-rw-r--r-- | src/common/extended_trace.cpp | 2 | ||||
-rw-r--r-- | src/common/file_search.cpp | 6 | ||||
-rw-r--r-- | src/common/file_util.cpp | 26 | ||||
-rw-r--r-- | src/common/file_util.h | 2 | ||||
-rw-r--r-- | src/common/log_manager.cpp | 2 | ||||
-rw-r--r-- | src/common/mem_arena.cpp | 2 | ||||
-rw-r--r-- | src/common/memory_util.cpp | 2 | ||||
-rw-r--r-- | src/common/msg_handler.cpp | 2 | ||||
-rw-r--r-- | src/common/string_util.cpp | 8 | ||||
-rw-r--r-- | src/common/string_util.h | 9 | ||||
-rw-r--r-- | src/core/arm/disassembler/arm_disasm.cpp | 78 | ||||
-rw-r--r-- | src/core/hle/svc.cpp | 2 | ||||
-rw-r--r-- | src/core/loader/loader.cpp | 31 |
14 files changed, 94 insertions, 88 deletions
diff --git a/src/common/console_listener.cpp b/src/common/console_listener.cpp index 27697ef1f..96970ab17 100644 --- a/src/common/console_listener.cpp +++ b/src/common/console_listener.cpp @@ -47,7 +47,7 @@ void ConsoleListener::Open(bool Hidden, int Width, int Height, const char *Title // Save the window handle that AllocConsole() created hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // Set the console window title - SetConsoleTitle(UTF8ToTStr(Title).c_str()); + SetConsoleTitle(Common::UTF8ToTStr(Title).c_str()); // Set letter space LetterSpace(80, 4000); //MoveWindow(GetConsoleWindow(), 200,200, 800,800, true); @@ -193,11 +193,11 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool { Str.resize(Str.size() + 1); if (!ReadConsoleOutputCharacter(hConsole, Str.back().data(), ReadBufferSize, coordScreen, &cCharsRead)) - SLog += StringFromFormat("WriteConsoleOutputCharacter error"); + SLog += Common::StringFromFormat("WriteConsoleOutputCharacter error"); Attr.resize(Attr.size() + 1); if (!ReadConsoleOutputAttribute(hConsole, Attr.back().data(), ReadBufferSize, coordScreen, &cAttrRead)) - SLog += StringFromFormat("WriteConsoleOutputAttribute error"); + SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error"); // Break on error if (cAttrRead == 0) break; @@ -223,9 +223,9 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool for (size_t i = 0; i < Attr.size(); i++) { if (!WriteConsoleOutputCharacter(hConsole, Str[i].data(), ReadBufferSize, coordScreen, &cCharsWritten)) - SLog += StringFromFormat("WriteConsoleOutputCharacter error"); + SLog += Common::StringFromFormat("WriteConsoleOutputCharacter error"); if (!WriteConsoleOutputAttribute(hConsole, Attr[i].data(), ReadBufferSize, coordScreen, &cAttrWritten)) - SLog += StringFromFormat("WriteConsoleOutputAttribute error"); + SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error"); BytesWritten += cAttrWritten; coordScreen = GetCoordinates(BytesWritten, LBufWidth); diff --git a/src/common/extended_trace.cpp b/src/common/extended_trace.cpp index 66dae4935..9cd0398ed 100644 --- a/src/common/extended_trace.cpp +++ b/src/common/extended_trace.cpp @@ -278,7 +278,7 @@ void PrintFunctionAndSourceInfo(FILE* file, const STACKFRAME& callstack) GetFunctionInfoFromAddresses((ULONG)callstack.AddrPC.Offset, (ULONG)callstack.AddrFrame.Offset, symInfo); GetSourceInfoFromAddress((ULONG)callstack.AddrPC.Offset, srcInfo); - etfprint(file, " " + TStrToUTF8(srcInfo) + " : " + TStrToUTF8(symInfo) + "\n"); + etfprint(file, " " + Common::TStrToUTF8(srcInfo) + " : " + Common::TStrToUTF8(symInfo) + "\n"); } void StackTrace( HANDLE hThread, const char* lpszMessage, FILE *file ) diff --git a/src/common/file_search.cpp b/src/common/file_search.cpp index a9d19477d..a80a98820 100644 --- a/src/common/file_search.cpp +++ b/src/common/file_search.cpp @@ -35,10 +35,10 @@ CFileSearch::CFileSearch(const CFileSearch::XStringVector& _rSearchStrings, cons void CFileSearch::FindFiles(const std::string& _searchString, const std::string& _strPath) { std::string GCMSearchPath; - BuildCompleteFilename(GCMSearchPath, _strPath, _searchString); + Common::BuildCompleteFilename(GCMSearchPath, _strPath, _searchString); #ifdef _WIN32 WIN32_FIND_DATA findData; - HANDLE FindFirst = FindFirstFile(UTF8ToTStr(GCMSearchPath).c_str(), &findData); + HANDLE FindFirst = FindFirstFile(Common::UTF8ToTStr(GCMSearchPath).c_str(), &findData); if (FindFirst != INVALID_HANDLE_VALUE) { @@ -49,7 +49,7 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string& if (findData.cFileName[0] != '.') { std::string strFilename; - BuildCompleteFilename(strFilename, _strPath, TStrToUTF8(findData.cFileName)); + Common::BuildCompleteFilename(strFilename, _strPath, Common::TStrToUTF8(findData.cFileName)); m_FileNames.push_back(strFilename); } diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index b6ff2e40b..2fdc7ec01 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -71,7 +71,7 @@ bool Exists(const std::string &filename) StripTailDirSlashes(copy); #ifdef _WIN32 - int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info); + int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); #else int result = stat64(copy.c_str(), &file_info); #endif @@ -88,7 +88,7 @@ bool IsDirectory(const std::string &filename) StripTailDirSlashes(copy); #ifdef _WIN32 - int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info); + int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info); #else int result = stat64(copy.c_str(), &file_info); #endif @@ -124,7 +124,7 @@ bool Delete(const std::string &filename) } #ifdef _WIN32 - if (!DeleteFile(UTF8ToTStr(filename).c_str())) + if (!DeleteFile(Common::UTF8ToTStr(filename).c_str())) { WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", filename.c_str(), GetLastErrorMsg()); @@ -146,7 +146,7 @@ bool CreateDir(const std::string &path) { INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); #ifdef _WIN32 - if (::CreateDirectory(UTF8ToTStr(path).c_str(), NULL)) + if (::CreateDirectory(Common::UTF8ToTStr(path).c_str(), NULL)) return true; DWORD error = GetLastError(); if (error == ERROR_ALREADY_EXISTS) @@ -225,7 +225,7 @@ bool DeleteDir(const std::string &filename) } #ifdef _WIN32 - if (::RemoveDirectory(UTF8ToTStr(filename).c_str())) + if (::RemoveDirectory(Common::UTF8ToTStr(filename).c_str())) return true; #else if (rmdir(filename.c_str()) == 0) @@ -254,7 +254,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename) INFO_LOG(COMMON, "Copy: %s --> %s", srcFilename.c_str(), destFilename.c_str()); #ifdef _WIN32 - if (CopyFile(UTF8ToTStr(srcFilename).c_str(), UTF8ToTStr(destFilename).c_str(), FALSE)) + if (CopyFile(Common::UTF8ToTStr(srcFilename).c_str(), Common::UTF8ToTStr(destFilename).c_str(), FALSE)) return true; ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", @@ -342,7 +342,7 @@ u64 GetSize(const std::string &filename) struct stat64 buf; #ifdef _WIN32 - if (_tstat64(UTF8ToTStr(filename).c_str(), &buf) == 0) + if (_tstat64(Common::UTF8ToTStr(filename).c_str(), &buf) == 0) #else if (stat64(filename.c_str(), &buf) == 0) #endif @@ -415,7 +415,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) // Find the first file in the directory. WIN32_FIND_DATA ffd; - HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd); + HANDLE hFind = FindFirstFile(Common::UTF8ToTStr(directory + "\\*").c_str(), &ffd); if (hFind == INVALID_HANDLE_VALUE) { FindClose(hFind); @@ -425,7 +425,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) do { FSTEntry entry; - const std::string virtualName(TStrToUTF8(ffd.cFileName)); + const std::string virtualName(Common::TStrToUTF8(ffd.cFileName)); #else struct dirent dirent, *result = NULL; @@ -482,7 +482,7 @@ bool DeleteDirRecursively(const std::string &directory) #ifdef _WIN32 // Find the first file in the directory. WIN32_FIND_DATA ffd; - HANDLE hFind = FindFirstFile(UTF8ToTStr(directory + "\\*").c_str(), &ffd); + HANDLE hFind = FindFirstFile(Common::UTF8ToTStr(directory + "\\*").c_str(), &ffd); if (hFind == INVALID_HANDLE_VALUE) { @@ -493,7 +493,7 @@ bool DeleteDirRecursively(const std::string &directory) // windows loop do { - const std::string virtualName(TStrToUTF8(ffd.cFileName)); + const std::string virtualName(Common::TStrToUTF8(ffd.cFileName)); #else struct dirent dirent, *result = NULL; DIR *dirp = opendir(directory.c_str()); @@ -631,7 +631,7 @@ std::string& GetExeDirectory() { TCHAR Dolphin_exe_Path[2048]; GetModuleFileName(NULL, Dolphin_exe_Path, 2048); - DolphinPath = TStrToUTF8(Dolphin_exe_Path); + DolphinPath = Common::TStrToUTF8(Dolphin_exe_Path); DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\')); } return DolphinPath; @@ -826,7 +826,7 @@ bool IOFile::Open(const std::string& filename, const char openmode[]) { Close(); #ifdef _WIN32 - _tfopen_s(&m_file, UTF8ToTStr(filename).c_str(), UTF8ToTStr(openmode).c_str()); + _tfopen_s(&m_file, Common::UTF8ToTStr(filename).c_str(), Common::UTF8ToTStr(openmode).c_str()); #else m_file = fopen(filename.c_str(), openmode); #endif diff --git a/src/common/file_util.h b/src/common/file_util.h index 0871734d4..fdae5c9c8 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -213,7 +213,7 @@ template <typename T> void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) { #ifdef _WIN32 - fstream.open(UTF8ToTStr(filename).c_str(), openmode); + fstream.open(Common::UTF8ToTStr(filename).c_str(), openmode); #else fstream.open(filename.c_str(), openmode); #endif diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp index 4e1cb60bd..9fd019fb3 100644 --- a/src/common/log_manager.cpp +++ b/src/common/log_manager.cpp @@ -121,7 +121,7 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners()) return; - CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args); + Common::CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args); static const char level_to_char[7] = "ONEWID"; sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line, diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp index b76ac92d3..d4dd933bf 100644 --- a/src/common/mem_arena.cpp +++ b/src/common/mem_arena.cpp @@ -143,7 +143,7 @@ void MemArena::GrabLowMemSpace(size_t size) // a bit more. for (int i = 0; i < 10000; i++) { - std::string file_name = StringFromFormat("/citramem.%d", i); + std::string file_name = Common::StringFromFormat("/citramem.%d", i); fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); if (fd != -1) { diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index e01e63175..1496002e9 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp @@ -190,7 +190,7 @@ std::string MemUsage() if (NULL == hProcess) return "MemUsage Error"; if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) - Ret = StringFromFormat("%s K", ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str()); + Ret = Common::StringFromFormat("%s K", Common::ThousandSeparate(pmc.WorkingSetSize / 1024, 7).c_str()); CloseHandle(hProcess); return Ret; diff --git a/src/common/msg_handler.cpp b/src/common/msg_handler.cpp index 3e02ec4d7..b3556aaa8 100644 --- a/src/common/msg_handler.cpp +++ b/src/common/msg_handler.cpp @@ -72,7 +72,7 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...) va_list args; va_start(args, format); - CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args); + Common::CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args); va_end(args); ERROR_LOG(MASTER_LOG, "%s: %s", caption.c_str(), buffer); diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index c489c868b..bd4c33391 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -17,14 +17,16 @@ #include <iconv.h> #endif +namespace Common { + /// Make a string lowercase -std::string LowerStr(std::string str) { +std::string ToLower(std::string str) { std::transform(str.begin(), str.end(), str.begin(), ::tolower); return str; } /// Make a string uppercase -std::string UpperStr(std::string str) { +std::string ToUpper(std::string str) { std::transform(str.begin(), str.end(), str.begin(), ::toupper); return str; } @@ -541,3 +543,5 @@ std::string UTF16ToUTF8(const std::wstring& input) } #endif + +} diff --git a/src/common/string_util.h b/src/common/string_util.h index b1118816e..16ce39bc1 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -12,12 +12,13 @@ #include "common/common.h" -/// Make a string lowercase +namespace Common { -std::string LowerStr(std::string str); +/// Make a string lowercase +std::string ToLower(std::string str); /// Make a string uppercase -std::string UpperStr(std::string str); +std::string ToUpper(std::string str); std::string StringFromFormat(const char* format, ...); // Cheap! @@ -112,3 +113,5 @@ inline std::string UTF8ToTStr(const std::string& str) #endif #endif + +} diff --git a/src/core/arm/disassembler/arm_disasm.cpp b/src/core/arm/disassembler/arm_disasm.cpp index 33e036cbf..45c720e16 100644 --- a/src/core/arm/disassembler/arm_disasm.cpp +++ b/src/core/arm/disassembler/arm_disasm.cpp @@ -260,14 +260,14 @@ std::string ARM_Disasm::DisassembleALU(Opcode opcode, uint32_t insn) // The "mov" instruction ignores the first operand (rn). rn_str[0] = 0; if ((flags & kNoOperand1) == 0) { - rn_str = StringFromFormat("r%d, ", rn); + rn_str = Common::StringFromFormat("r%d, ", rn); } // The following instructions do not write the result register (rd): // tst, teq, cmp, cmn. rd_str[0] = 0; if ((flags & kNoDest) == 0) { - rd_str = StringFromFormat("r%d, ", rd); + rd_str = Common::StringFromFormat("r%d, ", rd); } const char *sbit_str = ""; @@ -275,7 +275,7 @@ std::string ARM_Disasm::DisassembleALU(Opcode opcode, uint32_t insn) sbit_str = "s"; if (is_immed) { - return StringFromFormat("%s%s%s\t%s%s#%u ; 0x%x", + return Common::StringFromFormat("%s%s%s\t%s%s#%u ; 0x%x", opname, cond_to_str(cond), sbit_str, rd_str.c_str(), rn_str.c_str(), immed, immed); } @@ -290,24 +290,24 @@ std::string ARM_Disasm::DisassembleALU(Opcode opcode, uint32_t insn) rotated_val = (rotated_val >> rotate2) | (rotated_val << (32 - rotate2)); if (!shift_is_reg && shift_type == 0 && shift_amount == 0) { - return StringFromFormat("%s%s%s\t%s%sr%d", + return Common::StringFromFormat("%s%s%s\t%s%sr%d", opname, cond_to_str(cond), sbit_str, rd_str.c_str(), rn_str.c_str(), rm); } const char *shift_name = shift_names[shift_type]; if (shift_is_reg) { - return StringFromFormat("%s%s%s\t%s%sr%d, %s r%d", + return Common::StringFromFormat("%s%s%s\t%s%sr%d, %s r%d", opname, cond_to_str(cond), sbit_str, rd_str.c_str(), rn_str.c_str(), rm, shift_name, rs); } if (shift_amount == 0) { if (shift_type == 3) { - return StringFromFormat("%s%s%s\t%s%sr%d, RRX", + return Common::StringFromFormat("%s%s%s\t%s%sr%d, RRX", opname, cond_to_str(cond), sbit_str, rd_str.c_str(), rn_str.c_str(), rm); } shift_amount = 32; } - return StringFromFormat("%s%s%s\t%s%sr%d, %s #%u", + return Common::StringFromFormat("%s%s%s\t%s%sr%d, %s #%u", opname, cond_to_str(cond), sbit_str, rd_str.c_str(), rn_str.c_str(), rm, shift_name, shift_amount); } @@ -325,20 +325,20 @@ std::string ARM_Disasm::DisassembleBranch(uint32_t addr, Opcode opcode, uint32_t offset += 8; addr += offset; const char *opname = opcode_names[opcode]; - return StringFromFormat("%s%s\t0x%x", opname, cond_to_str(cond), addr); + return Common::StringFromFormat("%s%s\t0x%x", opname, cond_to_str(cond), addr); } std::string ARM_Disasm::DisassembleBX(uint32_t insn) { uint8_t cond = (insn >> 28) & 0xf; uint8_t rn = insn & 0xf; - return StringFromFormat("bx%s\tr%d", cond_to_str(cond), rn); + return Common::StringFromFormat("bx%s\tr%d", cond_to_str(cond), rn); } std::string ARM_Disasm::DisassembleBKPT(uint32_t insn) { uint32_t immed = (((insn >> 8) & 0xfff) << 4) | (insn & 0xf); - return StringFromFormat("bkpt\t#%d", immed); + return Common::StringFromFormat("bkpt\t#%d", immed); } std::string ARM_Disasm::DisassembleCLZ(uint32_t insn) @@ -346,7 +346,7 @@ std::string ARM_Disasm::DisassembleCLZ(uint32_t insn) uint8_t cond = (insn >> 28) & 0xf; uint8_t rd = (insn >> 12) & 0xf; uint8_t rm = insn & 0xf; - return StringFromFormat("clz%s\tr%d, r%d", cond_to_str(cond), rd, rm); + return Common::StringFromFormat("clz%s\tr%d, r%d", cond_to_str(cond), rd, rm); } std::string ARM_Disasm::DisassembleMemblock(Opcode opcode, uint32_t insn) @@ -376,7 +376,7 @@ std::string ARM_Disasm::DisassembleMemblock(Opcode opcode, uint32_t insn) tmp_list[0] = 0; for (int ii = 0; ii < 16; ++ii) { if (reg_list & (1 << ii)) { - tmp_list += StringFromFormat("%sr%d", comma, ii); + tmp_list += Common::StringFromFormat("%sr%d", comma, ii); comma = ","; } } @@ -396,7 +396,7 @@ std::string ARM_Disasm::DisassembleMemblock(Opcode opcode, uint32_t insn) } } - return StringFromFormat("%s%s%s\tr%d%s, {%s}%s", + return Common::StringFromFormat("%s%s%s\tr%d%s, {%s}%s", opname, cond_to_str(cond), addr_mode, rn, bang, tmp_list.c_str(), carret); } @@ -432,10 +432,10 @@ std::string ARM_Disasm::DisassembleMem(uint32_t insn) if (is_reg == 0) { if (is_pre) { if (offset == 0) { - return StringFromFormat("%s%s%s\tr%d, [r%d]", + return Common::StringFromFormat("%s%s%s\tr%d, [r%d]", opname, cond_to_str(cond), byte, rd, rn); } else { - return StringFromFormat("%s%s%s\tr%d, [r%d, #%s%u]%s", + return Common::StringFromFormat("%s%s%s\tr%d, [r%d, #%s%u]%s", opname, cond_to_str(cond), byte, rd, rn, minus, offset, bang); } } else { @@ -443,7 +443,7 @@ std::string ARM_Disasm::DisassembleMem(uint32_t insn) if (write_back) transfer = "t"; - return StringFromFormat("%s%s%s%s\tr%d, [r%d], #%s%u", + return Common::StringFromFormat("%s%s%s%s\tr%d, [r%d], #%s%u", opname, cond_to_str(cond), byte, transfer, rd, rn, minus, offset); } } @@ -457,16 +457,16 @@ std::string ARM_Disasm::DisassembleMem(uint32_t insn) if (is_pre) { if (shift_amount == 0) { if (shift_type == 0) { - return StringFromFormat("%s%s%s\tr%d, [r%d, %sr%d]%s", + return Common::StringFromFormat("%s%s%s\tr%d, [r%d, %sr%d]%s", opname, cond_to_str(cond), byte, rd, rn, minus, rm, bang); } if (shift_type == 3) { - return StringFromFormat("%s%s%s\tr%d, [r%d, %sr%d, RRX]%s", + return Common::StringFromFormat("%s%s%s\tr%d, [r%d, %sr%d, RRX]%s", opname, cond_to_str(cond), byte, rd, rn, minus, rm, bang); } shift_amount = 32; } - return StringFromFormat("%s%s%s\tr%d, [r%d, %sr%d, %s #%u]%s", + return Common::StringFromFormat("%s%s%s\tr%d, [r%d, %sr%d, %s #%u]%s", opname, cond_to_str(cond), byte, rd, rn, minus, rm, shift_name, shift_amount, bang); } @@ -477,17 +477,17 @@ std::string ARM_Disasm::DisassembleMem(uint32_t insn) if (shift_amount == 0) { if (shift_type == 0) { - return StringFromFormat("%s%s%s%s\tr%d, [r%d], %sr%d", + return Common::StringFromFormat("%s%s%s%s\tr%d, [r%d], %sr%d", opname, cond_to_str(cond), byte, transfer, rd, rn, minus, rm); } if (shift_type == 3) { - return StringFromFormat("%s%s%s%s\tr%d, [r%d], %sr%d, RRX", + return Common::StringFromFormat("%s%s%s%s\tr%d, [r%d], %sr%d, RRX", opname, cond_to_str(cond), byte, transfer, rd, rn, minus, rm); } shift_amount = 32; } - return StringFromFormat("%s%s%s%s\tr%d, [r%d], %sr%d, %s #%u", + return Common::StringFromFormat("%s%s%s%s\tr%d, [r%d], %sr%d, %s #%u", opname, cond_to_str(cond), byte, transfer, rd, rn, minus, rm, shift_name, shift_amount); } @@ -528,22 +528,22 @@ std::string ARM_Disasm::DisassembleMemHalf(uint32_t insn) if (is_immed) { if (is_pre) { if (offset == 0) { - return StringFromFormat("%s%sh\tr%d, [r%d]", opname, cond_to_str(cond), rd, rn); + return Common::StringFromFormat("%s%sh\tr%d, [r%d]", opname, cond_to_str(cond), rd, rn); } else { - return StringFromFormat("%s%sh\tr%d, [r%d, #%s%u]%s", + return Common::StringFromFormat("%s%sh\tr%d, [r%d, #%s%u]%s", opname, cond_to_str(cond), rd, rn, minus, offset, bang); } } else { - return StringFromFormat("%s%sh\tr%d, [r%d], #%s%u", + return Common::StringFromFormat("%s%sh\tr%d, [r%d], #%s%u", opname, cond_to_str(cond), rd, rn, minus, offset); } } if (is_pre) { - return StringFromFormat("%s%sh\tr%d, [r%d, %sr%d]%s", + return Common::StringFromFormat("%s%sh\tr%d, [r%d, %sr%d]%s", opname, cond_to_str(cond), rd, rn, minus, rm, bang); } else { - return StringFromFormat("%s%sh\tr%d, [r%d], %sr%d", + return Common::StringFromFormat("%s%sh\tr%d, [r%d], %sr%d", opname, cond_to_str(cond), rd, rn, minus, rm); } } @@ -558,7 +558,7 @@ std::string ARM_Disasm::DisassembleMCR(Opcode opcode, uint32_t insn) uint8_t crm = insn & 0xf; const char *opname = opcode_names[opcode]; - return StringFromFormat("%s%s\t%d, 0, r%d, cr%d, cr%d, {%d}", + return Common::StringFromFormat("%s%s\t%d, 0, r%d, cr%d, cr%d, {%d}", opname, cond_to_str(cond), cpnum, crd, crn, crm, opcode2); } @@ -572,7 +572,7 @@ std::string ARM_Disasm::DisassembleMLA(Opcode opcode, uint32_t insn) uint8_t bit_s = (insn >> 20) & 1; const char *opname = opcode_names[opcode]; - return StringFromFormat("%s%s%s\tr%d, r%d, r%d, r%d", + return Common::StringFromFormat("%s%s%s\tr%d, r%d, r%d, r%d", opname, cond_to_str(cond), bit_s ? "s" : "", rd, rm, rs, rn); } @@ -586,7 +586,7 @@ std::string ARM_Disasm::DisassembleUMLAL(Opcode opcode, uint32_t insn) uint8_t bit_s = (insn >> 20) & 1; const char *opname = opcode_names[opcode]; - return StringFromFormat("%s%s%s\tr%d, r%d, r%d, r%d", + return Common::StringFromFormat("%s%s%s\tr%d, r%d, r%d, r%d", opname, cond_to_str(cond), bit_s ? "s" : "", rdlo, rdhi, rm, rs); } @@ -599,7 +599,7 @@ std::string ARM_Disasm::DisassembleMUL(Opcode opcode, uint32_t insn) uint8_t bit_s = (insn >> 20) & 1; const char *opname = opcode_names[opcode]; - return StringFromFormat("%s%s%s\tr%d, r%d, r%d", + return Common::StringFromFormat("%s%s%s\tr%d, r%d, r%d", opname, cond_to_str(cond), bit_s ? "s" : "", rd, rm, rs); } @@ -609,7 +609,7 @@ std::string ARM_Disasm::DisassembleMRS(uint32_t insn) uint8_t rd = (insn >> 12) & 0xf; uint8_t ps = (insn >> 22) & 1; - return StringFromFormat("mrs%s\tr%d, %s", cond_to_str(cond), rd, ps ? "spsr" : "cpsr"); + return Common::StringFromFormat("mrs%s\tr%d, %s", cond_to_str(cond), rd, ps ? "spsr" : "cpsr"); } std::string ARM_Disasm::DisassembleMSR(uint32_t insn) @@ -636,13 +636,13 @@ std::string ARM_Disasm::DisassembleMSR(uint32_t insn) uint8_t rotate = (insn >> 8) & 0xf; uint8_t rotate2 = rotate << 1; uint32_t rotated_val = (immed >> rotate2) | (immed << (32 - rotate2)); - return StringFromFormat("msr%s\t%s_%s, #0x%x", + return Common::StringFromFormat("msr%s\t%s_%s, #0x%x", cond_to_str(cond), pd ? "spsr" : "cpsr", flags, rotated_val); } uint8_t rm = insn & 0xf; - return StringFromFormat("msr%s\t%s_%s, r%d", + return Common::StringFromFormat("msr%s\t%s_%s, r%d", cond_to_str(cond), pd ? "spsr" : "cpsr", flags, rm); } @@ -658,14 +658,14 @@ std::string ARM_Disasm::DisassemblePLD(uint32_t insn) if (is_reg) { uint8_t rm = insn & 0xf; - return StringFromFormat("pld\t[r%d, %sr%d]", rn, minus, rm); + return Common::StringFromFormat("pld\t[r%d, %sr%d]", rn, minus, rm); } uint16_t offset = insn & 0xfff; if (offset == 0) { - return StringFromFormat("pld\t[r%d]", rn); + return Common::StringFromFormat("pld\t[r%d]", rn); } else { - return StringFromFormat("pld\t[r%d, #%s%u]", rn, minus, offset); + return Common::StringFromFormat("pld\t[r%d, #%s%u]", rn, minus, offset); } } @@ -674,7 +674,7 @@ std::string ARM_Disasm::DisassembleSWI(uint32_t insn) uint8_t cond = (insn >> 28) & 0xf; uint32_t sysnum = insn & 0x00ffffff; - return StringFromFormat("swi%s 0x%x", cond_to_str(cond), sysnum); + return Common::StringFromFormat("swi%s 0x%x", cond_to_str(cond), sysnum); } std::string ARM_Disasm::DisassembleSWP(Opcode opcode, uint32_t insn) @@ -685,7 +685,7 @@ std::string ARM_Disasm::DisassembleSWP(Opcode opcode, uint32_t insn) uint8_t rm = insn & 0xf; const char *opname = opcode_names[opcode]; - return StringFromFormat("%s%s\tr%d, r%d, [r%d]", opname, cond_to_str(cond), rd, rm, rn); + return Common::StringFromFormat("%s%s\tr%d, r%d, [r%d]", opname, cond_to_str(cond), rd, rm, rn); } Opcode ARM_Disasm::Decode(uint32_t insn) { diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index bdcfae6f5..0ce3f027b 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -221,7 +221,7 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p TSymbol symbol = Symbols::GetSymbol(entry_point); name = symbol.name; } else { - name = StringFromFormat("unknown-%08x", entry_point); + name = Common::StringFromFormat("unknown-%08x", entry_point); } Handle thread = Kernel::CreateThread(name.c_str(), entry_point, priority, arg, processor_id, diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index ce1154b79..1f895ed2e 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp @@ -28,22 +28,21 @@ FileType IdentifyFile(const std::string &filename) { } size_t extension_loc = filename.find_last_of('.'); - std::string extension = extension_loc != std::string::npos ? filename.substr(extension_loc) : ""; - - if (LowerStr(extension) == ".elf") { - return FileType::ELF; // TODO(bunnei): Do some filetype checking :p - } - else if (LowerStr(extension) == ".axf") { - return FileType::ELF; // TODO(bunnei): Do some filetype checking :p - } - else if (LowerStr(extension) == ".cxi") { - return FileType::CXI; // TODO(bunnei): Do some filetype checking :p - } - else if (LowerStr(extension) == ".cci") { - return FileType::CCI; // TODO(bunnei): Do some filetype checking :p - } - else if (LowerStr(extension) == ".bin") { - return FileType::BIN; // TODO(bunnei): Do some filetype checking :p + if (extension_loc == std::string::npos) + return FileType::Unknown; + std::string extension = Common::ToLower(filename.substr(extension_loc)); + + // TODO(bunnei): Do actual filetype checking instead of naively checking the extension + if (extension == ".elf") { + return FileType::ELF; + } else if (extension == ".axf") { + return FileType::ELF; + } else if (extension == ".cxi") { + return FileType::CXI; + } else if (extension == ".cci") { + return FileType::CCI; + } else if (extension == ".bin") { + return FileType::BIN; } return FileType::Unknown; } |