diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index 2f89000b..19391bbd 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -15,6 +15,33 @@ #include "util/helpers/helpers.h" +#ifdef __arm64__ +#if defined(__clang__) +#include +#elif defined(_MSC_VER) +#include +#endif +#endif + +namespace { + +void enableFlushDenormalsToZero() +{ +#if defined(ARCH_X86_64) + _mm_setcsr(_mm_getcsr() | 0x8000); +#elif defined(__arm64__) +#if defined(__clang__) + __arm_wsr64("fpcr", __arm_rsr64("fpcr") | (1 << 24)); +#elif defined(__GNUC__) + __builtin_aarch64_set_fpcr(__builtin_aarch64_get_fpcr() | (1 << 24)); +#elif defined(_MSC_VER) + _WriteStatusReg(ARM64_FPCR, _ReadStatusReg(ARM64_FPCR) | (1 << 24)); +#endif +#endif +} + +} + SlimRWLock srwlock_activeThreadList; // public list of active threads @@ -1321,9 +1348,7 @@ namespace coreinit #endif OSHostThread* hostThread = (OSHostThread*)_thread; - #if defined(ARCH_X86_64) - _mm_setcsr(_mm_getcsr() | 0x8000); // flush denormals to zero - #endif + enableFlushDenormalsToZero(); PPCInterpreter_t* hCPU = &hostThread->ppcInstance; __OSLoadThread(hostThread->m_thread, hCPU, hostThread->selectedCore); @@ -1369,9 +1394,8 @@ namespace coreinit { SetThreadName(fmt::format("OSSched[core={}]", (uintptr_t)_assignedCoreIndex).c_str()); t_assignedCoreIndex = (sint32)(uintptr_t)_assignedCoreIndex; - #if defined(ARCH_X86_64) - _mm_setcsr(_mm_getcsr() | 0x8000); // flush denormals to zero - #endif + + enableFlushDenormalsToZero(); #if BOOST_OS_LINUX if (g_gdbstub) diff --git a/src/gui/wxgui/components/wxGameList.cpp b/src/gui/wxgui/components/wxGameList.cpp index db7d5bce..89063d9b 100644 --- a/src/gui/wxgui/components/wxGameList.cpp +++ b/src/gui/wxgui/components/wxGameList.cpp @@ -517,6 +517,9 @@ std::weak_ordering wxGameList::SortComparator(uint64 titleId1, uint64 titleId2, return CafeTitleList::GetGameInfo(id).GetRegion(); }; + if (!sortData->asc) + std::swap(titleId1, titleId2); + switch(sortData->column) { default: @@ -545,7 +548,7 @@ std::weak_ordering wxGameList::SortComparator(uint64 titleId1, uint64 titleId2, int wxGameList::SortFunction(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData) { const auto sort_data = (SortData*)sortData; - return sort_data->dir * order_to_int(sort_data->thisptr->SortComparator((uint64)item1, (uint64)item2, sort_data)); + return order_to_int(sort_data->thisptr->SortComparator((uint64)item1, (uint64)item2, sort_data)); } void wxGameList::SortEntries(int column) @@ -569,7 +572,7 @@ void wxGameList::SortEntries(int column) case ColumnRegion: case ColumnTitleID: { - SortData data{this, ItemColumns{column}, ascending ? 1 : -1}; + SortData data{this, ItemColumns{column}, ascending}; SortItems(SortFunction, (wxIntPtr)&data); ShowSortIndicator(column, ascending); break; @@ -1680,7 +1683,8 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo) hres = shellLinkFile->Save(outputPath.wc_str(), TRUE); } } - if (!SUCCEEDED(hres)) { + if (FAILED(hres)) + { auto errorMsg = formatWxString(_("Failed to save shortcut to {}"), outputPath); wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); } diff --git a/src/gui/wxgui/components/wxGameList.h b/src/gui/wxgui/components/wxGameList.h index ae2ea245..e4f90ca3 100644 --- a/src/gui/wxgui/components/wxGameList.h +++ b/src/gui/wxgui/components/wxGameList.h @@ -89,7 +89,7 @@ private: { wxGameList* thisptr; ItemColumns column; - int dir; + bool asc; }; int FindInsertPosition(TitleId titleId);