mirror of
https://github.com/citra-mirror/citra.git
synced 2024-08-20 02:13:23 +02:00
Merge pull request #99 from archshift/ext-check
loader.cpp: improved file extension checking, made Upper/LowerStr useful, moved string_util into Common namespace
This commit is contained in:
commit
532a9e80a0
@ -100,7 +100,7 @@ union t128 {
|
|||||||
__m128 a; ///< 128-bit floating point (__m128 maps to the XMM[0-7] registers)
|
__m128 a; ///< 128-bit floating point (__m128 maps to the XMM[0-7] registers)
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace common {
|
namespace Common {
|
||||||
/// Rectangle data structure
|
/// Rectangle data structure
|
||||||
class Rect {
|
class Rect {
|
||||||
public:
|
public:
|
||||||
|
@ -43,7 +43,7 @@ void ConsoleListener::Open(bool Hidden, int Width, int Height, const char *Title
|
|||||||
// Save the window handle that AllocConsole() created
|
// Save the window handle that AllocConsole() created
|
||||||
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
// Set the console window title
|
// Set the console window title
|
||||||
SetConsoleTitle(UTF8ToTStr(Title).c_str());
|
SetConsoleTitle(Common::UTF8ToTStr(Title).c_str());
|
||||||
// Set letter space
|
// Set letter space
|
||||||
LetterSpace(80, 4000);
|
LetterSpace(80, 4000);
|
||||||
//MoveWindow(GetConsoleWindow(), 200,200, 800,800, true);
|
//MoveWindow(GetConsoleWindow(), 200,200, 800,800, true);
|
||||||
@ -189,11 +189,11 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
|
|||||||
{
|
{
|
||||||
Str.resize(Str.size() + 1);
|
Str.resize(Str.size() + 1);
|
||||||
if (!ReadConsoleOutputCharacter(hConsole, Str.back().data(), ReadBufferSize, coordScreen, &cCharsRead))
|
if (!ReadConsoleOutputCharacter(hConsole, Str.back().data(), ReadBufferSize, coordScreen, &cCharsRead))
|
||||||
SLog += StringFromFormat("WriteConsoleOutputCharacter error");
|
SLog += Common::StringFromFormat("WriteConsoleOutputCharacter error");
|
||||||
|
|
||||||
Attr.resize(Attr.size() + 1);
|
Attr.resize(Attr.size() + 1);
|
||||||
if (!ReadConsoleOutputAttribute(hConsole, Attr.back().data(), ReadBufferSize, coordScreen, &cAttrRead))
|
if (!ReadConsoleOutputAttribute(hConsole, Attr.back().data(), ReadBufferSize, coordScreen, &cAttrRead))
|
||||||
SLog += StringFromFormat("WriteConsoleOutputAttribute error");
|
SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error");
|
||||||
|
|
||||||
// Break on error
|
// Break on error
|
||||||
if (cAttrRead == 0) break;
|
if (cAttrRead == 0) break;
|
||||||
@ -219,9 +219,9 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
|
|||||||
for (size_t i = 0; i < Attr.size(); i++)
|
for (size_t i = 0; i < Attr.size(); i++)
|
||||||
{
|
{
|
||||||
if (!WriteConsoleOutputCharacter(hConsole, Str[i].data(), ReadBufferSize, coordScreen, &cCharsWritten))
|
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))
|
if (!WriteConsoleOutputAttribute(hConsole, Attr[i].data(), ReadBufferSize, coordScreen, &cAttrWritten))
|
||||||
SLog += StringFromFormat("WriteConsoleOutputAttribute error");
|
SLog += Common::StringFromFormat("WriteConsoleOutputAttribute error");
|
||||||
|
|
||||||
BytesWritten += cAttrWritten;
|
BytesWritten += cAttrWritten;
|
||||||
coordScreen = GetCoordinates(BytesWritten, LBufWidth);
|
coordScreen = GetCoordinates(BytesWritten, LBufWidth);
|
||||||
|
@ -278,7 +278,7 @@ void PrintFunctionAndSourceInfo(FILE* file, const STACKFRAME& callstack)
|
|||||||
|
|
||||||
GetFunctionInfoFromAddresses((ULONG)callstack.AddrPC.Offset, (ULONG)callstack.AddrFrame.Offset, symInfo);
|
GetFunctionInfoFromAddresses((ULONG)callstack.AddrPC.Offset, (ULONG)callstack.AddrFrame.Offset, symInfo);
|
||||||
GetSourceInfoFromAddress((ULONG)callstack.AddrPC.Offset, srcInfo);
|
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 )
|
void StackTrace( HANDLE hThread, const char* lpszMessage, FILE *file )
|
||||||
|
@ -33,10 +33,10 @@ CFileSearch::CFileSearch(const CFileSearch::XStringVector& _rSearchStrings, cons
|
|||||||
void CFileSearch::FindFiles(const std::string& _searchString, const std::string& _strPath)
|
void CFileSearch::FindFiles(const std::string& _searchString, const std::string& _strPath)
|
||||||
{
|
{
|
||||||
std::string GCMSearchPath;
|
std::string GCMSearchPath;
|
||||||
BuildCompleteFilename(GCMSearchPath, _strPath, _searchString);
|
Common::BuildCompleteFilename(GCMSearchPath, _strPath, _searchString);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WIN32_FIND_DATA findData;
|
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)
|
if (FindFirst != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string&
|
|||||||
if (findData.cFileName[0] != '.')
|
if (findData.cFileName[0] != '.')
|
||||||
{
|
{
|
||||||
std::string strFilename;
|
std::string strFilename;
|
||||||
BuildCompleteFilename(strFilename, _strPath, TStrToUTF8(findData.cFileName));
|
Common::BuildCompleteFilename(strFilename, _strPath, Common::TStrToUTF8(findData.cFileName));
|
||||||
m_FileNames.push_back(strFilename);
|
m_FileNames.push_back(strFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ bool Exists(const std::string &filename)
|
|||||||
StripTailDirSlashes(copy);
|
StripTailDirSlashes(copy);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info);
|
int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info);
|
||||||
#else
|
#else
|
||||||
int result = stat64(copy.c_str(), &file_info);
|
int result = stat64(copy.c_str(), &file_info);
|
||||||
#endif
|
#endif
|
||||||
@ -81,7 +81,7 @@ bool IsDirectory(const std::string &filename)
|
|||||||
StripTailDirSlashes(copy);
|
StripTailDirSlashes(copy);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int result = _tstat64(UTF8ToTStr(copy).c_str(), &file_info);
|
int result = _tstat64(Common::UTF8ToTStr(copy).c_str(), &file_info);
|
||||||
#else
|
#else
|
||||||
int result = stat64(copy.c_str(), &file_info);
|
int result = stat64(copy.c_str(), &file_info);
|
||||||
#endif
|
#endif
|
||||||
@ -117,7 +117,7 @@ bool Delete(const std::string &filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (!DeleteFile(UTF8ToTStr(filename).c_str()))
|
if (!DeleteFile(Common::UTF8ToTStr(filename).c_str()))
|
||||||
{
|
{
|
||||||
WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s",
|
WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s",
|
||||||
filename.c_str(), GetLastErrorMsg());
|
filename.c_str(), GetLastErrorMsg());
|
||||||
@ -139,7 +139,7 @@ bool CreateDir(const std::string &path)
|
|||||||
{
|
{
|
||||||
INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str());
|
INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str());
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (::CreateDirectory(UTF8ToTStr(path).c_str(), NULL))
|
if (::CreateDirectory(Common::UTF8ToTStr(path).c_str(), NULL))
|
||||||
return true;
|
return true;
|
||||||
DWORD error = GetLastError();
|
DWORD error = GetLastError();
|
||||||
if (error == ERROR_ALREADY_EXISTS)
|
if (error == ERROR_ALREADY_EXISTS)
|
||||||
@ -218,7 +218,7 @@ bool DeleteDir(const std::string &filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (::RemoveDirectory(UTF8ToTStr(filename).c_str()))
|
if (::RemoveDirectory(Common::UTF8ToTStr(filename).c_str()))
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
if (rmdir(filename.c_str()) == 0)
|
if (rmdir(filename.c_str()) == 0)
|
||||||
@ -247,7 +247,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
|
|||||||
INFO_LOG(COMMON, "Copy: %s --> %s",
|
INFO_LOG(COMMON, "Copy: %s --> %s",
|
||||||
srcFilename.c_str(), destFilename.c_str());
|
srcFilename.c_str(), destFilename.c_str());
|
||||||
#ifdef _WIN32
|
#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;
|
return true;
|
||||||
|
|
||||||
ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s",
|
ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s",
|
||||||
@ -335,7 +335,7 @@ u64 GetSize(const std::string &filename)
|
|||||||
|
|
||||||
struct stat64 buf;
|
struct stat64 buf;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (_tstat64(UTF8ToTStr(filename).c_str(), &buf) == 0)
|
if (_tstat64(Common::UTF8ToTStr(filename).c_str(), &buf) == 0)
|
||||||
#else
|
#else
|
||||||
if (stat64(filename.c_str(), &buf) == 0)
|
if (stat64(filename.c_str(), &buf) == 0)
|
||||||
#endif
|
#endif
|
||||||
@ -408,7 +408,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry)
|
|||||||
// Find the first file in the directory.
|
// Find the first file in the directory.
|
||||||
WIN32_FIND_DATA ffd;
|
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)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
@ -418,7 +418,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
FSTEntry entry;
|
FSTEntry entry;
|
||||||
const std::string virtualName(TStrToUTF8(ffd.cFileName));
|
const std::string virtualName(Common::TStrToUTF8(ffd.cFileName));
|
||||||
#else
|
#else
|
||||||
struct dirent dirent, *result = NULL;
|
struct dirent dirent, *result = NULL;
|
||||||
|
|
||||||
@ -475,7 +475,7 @@ bool DeleteDirRecursively(const std::string &directory)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Find the first file in the directory.
|
// Find the first file in the directory.
|
||||||
WIN32_FIND_DATA ffd;
|
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)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
@ -486,7 +486,7 @@ bool DeleteDirRecursively(const std::string &directory)
|
|||||||
// windows loop
|
// windows loop
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
const std::string virtualName(TStrToUTF8(ffd.cFileName));
|
const std::string virtualName(Common::TStrToUTF8(ffd.cFileName));
|
||||||
#else
|
#else
|
||||||
struct dirent dirent, *result = NULL;
|
struct dirent dirent, *result = NULL;
|
||||||
DIR *dirp = opendir(directory.c_str());
|
DIR *dirp = opendir(directory.c_str());
|
||||||
@ -624,7 +624,7 @@ std::string& GetExeDirectory()
|
|||||||
{
|
{
|
||||||
TCHAR Dolphin_exe_Path[2048];
|
TCHAR Dolphin_exe_Path[2048];
|
||||||
GetModuleFileName(NULL, 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('\\'));
|
DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\'));
|
||||||
}
|
}
|
||||||
return DolphinPath;
|
return DolphinPath;
|
||||||
@ -819,7 +819,7 @@ bool IOFile::Open(const std::string& filename, const char openmode[])
|
|||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
#ifdef _WIN32
|
#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
|
#else
|
||||||
m_file = fopen(filename.c_str(), openmode);
|
m_file = fopen(filename.c_str(), openmode);
|
||||||
#endif
|
#endif
|
||||||
|
@ -213,7 +213,7 @@ template <typename T>
|
|||||||
void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode)
|
void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fstream.open(UTF8ToTStr(filename).c_str(), openmode);
|
fstream.open(Common::UTF8ToTStr(filename).c_str(), openmode);
|
||||||
#else
|
#else
|
||||||
fstream.open(filename.c_str(), openmode);
|
fstream.open(filename.c_str(), openmode);
|
||||||
#endif
|
#endif
|
||||||
|
@ -120,7 +120,7 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const
|
|||||||
if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners())
|
if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args);
|
Common::CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args);
|
||||||
|
|
||||||
static const char level_to_char[7] = "ONEWID";
|
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,
|
sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line,
|
||||||
|
@ -139,7 +139,7 @@ void MemArena::GrabLowMemSpace(size_t size)
|
|||||||
// a bit more.
|
// a bit more.
|
||||||
for (int i = 0; i < 10000; i++)
|
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);
|
fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
{
|
{
|
||||||
|
@ -187,7 +187,7 @@ std::string MemUsage()
|
|||||||
if (NULL == hProcess) return "MemUsage Error";
|
if (NULL == hProcess) return "MemUsage Error";
|
||||||
|
|
||||||
if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc)))
|
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);
|
CloseHandle(hProcess);
|
||||||
return Ret;
|
return Ret;
|
||||||
|
@ -72,7 +72,7 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...)
|
|||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
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);
|
va_end(args);
|
||||||
|
|
||||||
ERROR_LOG(MASTER_LOG, "%s: %s", caption.c_str(), buffer);
|
ERROR_LOG(MASTER_LOG, "%s: %s", caption.c_str(), buffer);
|
||||||
|
@ -13,20 +13,18 @@
|
|||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
/// Make a string lowercase
|
/// Make a string lowercase
|
||||||
void LowerStr(char* str) {
|
std::string ToLower(std::string str) {
|
||||||
for (int i = 0; str[i]; i++) {
|
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||||
str[i] = tolower(str[ i ]);
|
return str;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Make a string uppercase
|
/// Make a string uppercase
|
||||||
void UpperStr(char* str) {
|
std::string ToUpper(std::string str) {
|
||||||
for (int i=0; i < strlen(str); i++) {
|
std::transform(str.begin(), str.end(), str.begin(), ::toupper);
|
||||||
if(str[i] >= 'a' && str[i] <= 'z') {
|
return str;
|
||||||
str[i] &= 0xDF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// faster than sscanf
|
// faster than sscanf
|
||||||
@ -546,3 +544,5 @@ std::string UTF16ToUTF8(const std::wstring& input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -12,11 +12,13 @@
|
|||||||
|
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
/// Make a string lowercase
|
/// Make a string lowercase
|
||||||
void LowerStr(char* str);
|
std::string ToLower(std::string str);
|
||||||
|
|
||||||
/// Make a string uppercase
|
/// Make a string uppercase
|
||||||
void UpperStr(char* str);
|
std::string ToUpper(std::string str);
|
||||||
|
|
||||||
std::string StringFromFormat(const char* format, ...);
|
std::string StringFromFormat(const char* format, ...);
|
||||||
// Cheap!
|
// Cheap!
|
||||||
@ -111,3 +113,5 @@ inline std::string UTF8ToTStr(const std::string& str)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -260,14 +260,14 @@ std::string ARM_Disasm::DisassembleALU(Opcode opcode, uint32_t insn)
|
|||||||
// The "mov" instruction ignores the first operand (rn).
|
// The "mov" instruction ignores the first operand (rn).
|
||||||
rn_str[0] = 0;
|
rn_str[0] = 0;
|
||||||
if ((flags & kNoOperand1) == 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):
|
// The following instructions do not write the result register (rd):
|
||||||
// tst, teq, cmp, cmn.
|
// tst, teq, cmp, cmn.
|
||||||
rd_str[0] = 0;
|
rd_str[0] = 0;
|
||||||
if ((flags & kNoDest) == 0) {
|
if ((flags & kNoDest) == 0) {
|
||||||
rd_str = StringFromFormat("r%d, ", rd);
|
rd_str = Common::StringFromFormat("r%d, ", rd);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *sbit_str = "";
|
const char *sbit_str = "";
|
||||||
@ -275,7 +275,7 @@ std::string ARM_Disasm::DisassembleALU(Opcode opcode, uint32_t insn)
|
|||||||
sbit_str = "s";
|
sbit_str = "s";
|
||||||
|
|
||||||
if (is_immed) {
|
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);
|
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));
|
rotated_val = (rotated_val >> rotate2) | (rotated_val << (32 - rotate2));
|
||||||
|
|
||||||
if (!shift_is_reg && shift_type == 0 && shift_amount == 0) {
|
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);
|
opname, cond_to_str(cond), sbit_str, rd_str.c_str(), rn_str.c_str(), rm);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *shift_name = shift_names[shift_type];
|
const char *shift_name = shift_names[shift_type];
|
||||||
if (shift_is_reg) {
|
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,
|
opname, cond_to_str(cond), sbit_str, rd_str.c_str(), rn_str.c_str(), rm,
|
||||||
shift_name, rs);
|
shift_name, rs);
|
||||||
}
|
}
|
||||||
if (shift_amount == 0) {
|
if (shift_amount == 0) {
|
||||||
if (shift_type == 3) {
|
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);
|
opname, cond_to_str(cond), sbit_str, rd_str.c_str(), rn_str.c_str(), rm);
|
||||||
}
|
}
|
||||||
shift_amount = 32;
|
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,
|
opname, cond_to_str(cond), sbit_str, rd_str.c_str(), rn_str.c_str(), rm,
|
||||||
shift_name, shift_amount);
|
shift_name, shift_amount);
|
||||||
}
|
}
|
||||||
@ -325,20 +325,20 @@ std::string ARM_Disasm::DisassembleBranch(uint32_t addr, Opcode opcode, uint32_t
|
|||||||
offset += 8;
|
offset += 8;
|
||||||
addr += offset;
|
addr += offset;
|
||||||
const char *opname = opcode_names[opcode];
|
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)
|
std::string ARM_Disasm::DisassembleBX(uint32_t insn)
|
||||||
{
|
{
|
||||||
uint8_t cond = (insn >> 28) & 0xf;
|
uint8_t cond = (insn >> 28) & 0xf;
|
||||||
uint8_t rn = insn & 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)
|
std::string ARM_Disasm::DisassembleBKPT(uint32_t insn)
|
||||||
{
|
{
|
||||||
uint32_t immed = (((insn >> 8) & 0xfff) << 4) | (insn & 0xf);
|
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)
|
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 cond = (insn >> 28) & 0xf;
|
||||||
uint8_t rd = (insn >> 12) & 0xf;
|
uint8_t rd = (insn >> 12) & 0xf;
|
||||||
uint8_t rm = insn & 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)
|
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;
|
tmp_list[0] = 0;
|
||||||
for (int ii = 0; ii < 16; ++ii) {
|
for (int ii = 0; ii < 16; ++ii) {
|
||||||
if (reg_list & (1 << ii)) {
|
if (reg_list & (1 << ii)) {
|
||||||
tmp_list += StringFromFormat("%sr%d", comma, ii);
|
tmp_list += Common::StringFromFormat("%sr%d", comma, ii);
|
||||||
comma = ",";
|
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);
|
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_reg == 0) {
|
||||||
if (is_pre) {
|
if (is_pre) {
|
||||||
if (offset == 0) {
|
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);
|
opname, cond_to_str(cond), byte, rd, rn);
|
||||||
} else {
|
} 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);
|
opname, cond_to_str(cond), byte, rd, rn, minus, offset, bang);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -443,7 +443,7 @@ std::string ARM_Disasm::DisassembleMem(uint32_t insn)
|
|||||||
if (write_back)
|
if (write_back)
|
||||||
transfer = "t";
|
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);
|
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 (is_pre) {
|
||||||
if (shift_amount == 0) {
|
if (shift_amount == 0) {
|
||||||
if (shift_type == 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);
|
opname, cond_to_str(cond), byte, rd, rn, minus, rm, bang);
|
||||||
}
|
}
|
||||||
if (shift_type == 3) {
|
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);
|
opname, cond_to_str(cond), byte, rd, rn, minus, rm, bang);
|
||||||
}
|
}
|
||||||
shift_amount = 32;
|
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,
|
opname, cond_to_str(cond), byte, rd, rn, minus, rm,
|
||||||
shift_name, shift_amount, bang);
|
shift_name, shift_amount, bang);
|
||||||
}
|
}
|
||||||
@ -477,17 +477,17 @@ std::string ARM_Disasm::DisassembleMem(uint32_t insn)
|
|||||||
|
|
||||||
if (shift_amount == 0) {
|
if (shift_amount == 0) {
|
||||||
if (shift_type == 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);
|
opname, cond_to_str(cond), byte, transfer, rd, rn, minus, rm);
|
||||||
}
|
}
|
||||||
if (shift_type == 3) {
|
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);
|
opname, cond_to_str(cond), byte, transfer, rd, rn, minus, rm);
|
||||||
}
|
}
|
||||||
shift_amount = 32;
|
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,
|
opname, cond_to_str(cond), byte, transfer, rd, rn, minus, rm,
|
||||||
shift_name, shift_amount);
|
shift_name, shift_amount);
|
||||||
}
|
}
|
||||||
@ -528,22 +528,22 @@ std::string ARM_Disasm::DisassembleMemHalf(uint32_t insn)
|
|||||||
if (is_immed) {
|
if (is_immed) {
|
||||||
if (is_pre) {
|
if (is_pre) {
|
||||||
if (offset == 0) {
|
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 {
|
} 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);
|
opname, cond_to_str(cond), rd, rn, minus, offset, bang);
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
opname, cond_to_str(cond), rd, rn, minus, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_pre) {
|
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);
|
opname, cond_to_str(cond), rd, rn, minus, rm, bang);
|
||||||
} else {
|
} 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);
|
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;
|
uint8_t crm = insn & 0xf;
|
||||||
|
|
||||||
const char *opname = opcode_names[opcode];
|
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);
|
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;
|
uint8_t bit_s = (insn >> 20) & 1;
|
||||||
|
|
||||||
const char *opname = opcode_names[opcode];
|
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);
|
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;
|
uint8_t bit_s = (insn >> 20) & 1;
|
||||||
|
|
||||||
const char *opname = opcode_names[opcode];
|
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);
|
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;
|
uint8_t bit_s = (insn >> 20) & 1;
|
||||||
|
|
||||||
const char *opname = opcode_names[opcode];
|
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);
|
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 rd = (insn >> 12) & 0xf;
|
||||||
uint8_t ps = (insn >> 22) & 1;
|
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)
|
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 rotate = (insn >> 8) & 0xf;
|
||||||
uint8_t rotate2 = rotate << 1;
|
uint8_t rotate2 = rotate << 1;
|
||||||
uint32_t rotated_val = (immed >> rotate2) | (immed << (32 - rotate2));
|
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);
|
cond_to_str(cond), pd ? "spsr" : "cpsr", flags, rotated_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t rm = insn & 0xf;
|
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);
|
cond_to_str(cond), pd ? "spsr" : "cpsr", flags, rm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,14 +658,14 @@ std::string ARM_Disasm::DisassemblePLD(uint32_t insn)
|
|||||||
|
|
||||||
if (is_reg) {
|
if (is_reg) {
|
||||||
uint8_t rm = insn & 0xf;
|
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;
|
uint16_t offset = insn & 0xfff;
|
||||||
if (offset == 0) {
|
if (offset == 0) {
|
||||||
return StringFromFormat("pld\t[r%d]", rn);
|
return Common::StringFromFormat("pld\t[r%d]", rn);
|
||||||
} else {
|
} 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;
|
uint8_t cond = (insn >> 28) & 0xf;
|
||||||
uint32_t sysnum = insn & 0x00ffffff;
|
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)
|
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;
|
uint8_t rm = insn & 0xf;
|
||||||
|
|
||||||
const char *opname = opcode_names[opcode];
|
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) {
|
Opcode ARM_Disasm::Decode(uint32_t insn) {
|
||||||
|
@ -218,7 +218,7 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p
|
|||||||
TSymbol symbol = Symbols::GetSymbol(entry_point);
|
TSymbol symbol = Symbols::GetSymbol(entry_point);
|
||||||
name = symbol.name;
|
name = symbol.name;
|
||||||
} else {
|
} 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,
|
Handle thread = Kernel::CreateThread(name.c_str(), entry_point, priority, arg, processor_id,
|
||||||
|
@ -25,22 +25,23 @@ FileType IdentifyFile(const std::string &filename) {
|
|||||||
ERROR_LOG(LOADER, "invalid filename %s", filename.c_str());
|
ERROR_LOG(LOADER, "invalid filename %s", filename.c_str());
|
||||||
return FileType::Error;
|
return FileType::Error;
|
||||||
}
|
}
|
||||||
std::string extension = filename.size() >= 5 ? filename.substr(filename.size() - 4) : "";
|
|
||||||
|
|
||||||
if (!strcasecmp(extension.c_str(), ".elf")) {
|
size_t extension_loc = filename.find_last_of('.');
|
||||||
return FileType::ELF; // TODO(bunnei): Do some filetype checking :p
|
if (extension_loc == std::string::npos)
|
||||||
}
|
return FileType::Unknown;
|
||||||
else if (!strcasecmp(extension.c_str(), ".axf")) {
|
std::string extension = Common::ToLower(filename.substr(extension_loc));
|
||||||
return FileType::ELF; // TODO(bunnei): Do some filetype checking :p
|
|
||||||
}
|
// TODO(bunnei): Do actual filetype checking instead of naively checking the extension
|
||||||
else if (!strcasecmp(extension.c_str(), ".cxi")) {
|
if (extension == ".elf") {
|
||||||
return FileType::CXI; // TODO(bunnei): Do some filetype checking :p
|
return FileType::ELF;
|
||||||
}
|
} else if (extension == ".axf") {
|
||||||
else if (!strcasecmp(extension.c_str(), ".cci")) {
|
return FileType::ELF;
|
||||||
return FileType::CCI; // TODO(bunnei): Do some filetype checking :p
|
} else if (extension == ".cxi") {
|
||||||
}
|
return FileType::CXI;
|
||||||
else if (!strcasecmp(extension.c_str(), ".bin")) {
|
} else if (extension == ".cci") {
|
||||||
return FileType::BIN; // TODO(bunnei): Do some filetype checking :p
|
return FileType::CCI;
|
||||||
|
} else if (extension == ".bin") {
|
||||||
|
return FileType::BIN;
|
||||||
}
|
}
|
||||||
return FileType::Unknown;
|
return FileType::Unknown;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ void RendererOpenGL::SwapBuffers() {
|
|||||||
//
|
//
|
||||||
// TODO(princesspeachum): (related to above^) this should only be called when there's new data, not every frame.
|
// TODO(princesspeachum): (related to above^) this should only be called when there's new data, not every frame.
|
||||||
// Currently this uploads data that shouldn't have changed.
|
// Currently this uploads data that shouldn't have changed.
|
||||||
common::Rect framebuffer_size(0, 0, resolution_width, resolution_height);
|
Common::Rect framebuffer_size(0, 0, resolution_width, resolution_height);
|
||||||
RenderXFB(framebuffer_size, framebuffer_size);
|
RenderXFB(framebuffer_size, framebuffer_size);
|
||||||
|
|
||||||
// XFB->Window copy
|
// XFB->Window copy
|
||||||
@ -113,7 +113,7 @@ void RendererOpenGL::FlipFramebuffer(const u8* raw_data, ScreenInfo& screen_info
|
|||||||
* @param src_rect Source rectangle in XFB to copy
|
* @param src_rect Source rectangle in XFB to copy
|
||||||
* @param dst_rect Destination rectangle in output framebuffer to copy to
|
* @param dst_rect Destination rectangle in output framebuffer to copy to
|
||||||
*/
|
*/
|
||||||
void RendererOpenGL::RenderXFB(const common::Rect& src_rect, const common::Rect& dst_rect) {
|
void RendererOpenGL::RenderXFB(const Common::Rect& src_rect, const Common::Rect& dst_rect) {
|
||||||
const auto& framebuffer_top = GPU::g_regs.framebuffer_config[0];
|
const auto& framebuffer_top = GPU::g_regs.framebuffer_config[0];
|
||||||
const auto& framebuffer_sub = GPU::g_regs.framebuffer_config[1];
|
const auto& framebuffer_sub = GPU::g_regs.framebuffer_config[1];
|
||||||
const u32 active_fb_top = (framebuffer_top.active_fb == 1)
|
const u32 active_fb_top = (framebuffer_top.active_fb == 1)
|
||||||
|
@ -27,7 +27,7 @@ public:
|
|||||||
* @param src_rect Source rectangle in XFB to copy
|
* @param src_rect Source rectangle in XFB to copy
|
||||||
* @param dst_rect Destination rectangle in output framebuffer to copy to
|
* @param dst_rect Destination rectangle in output framebuffer to copy to
|
||||||
*/
|
*/
|
||||||
void RenderXFB(const common::Rect& src_rect, const common::Rect& dst_rect);
|
void RenderXFB(const Common::Rect& src_rect, const Common::Rect& dst_rect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the emulator window to use for renderer
|
* Set the emulator window to use for renderer
|
||||||
|
Loading…
Reference in New Issue
Block a user