mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-14 10:48:28 +12:00
Code clean up + replace some wstring instances with utf8 (#640)
This commit is contained in:
parent
ca79a6aa0d
commit
f3ff919be2
41 changed files with 163 additions and 641 deletions
|
@ -1,8 +1,6 @@
|
|||
#include "Account.h"
|
||||
#include "util/helpers/helpers.h"
|
||||
#include "gui/CemuApp.h"
|
||||
#include "util/helpers/SystemException.h"
|
||||
|
||||
#include "config/ActiveSettings.h"
|
||||
#include "Cafe/IOSU/legacy/iosu_crypto.h"
|
||||
#include "Common/FileStream.h"
|
||||
|
@ -175,7 +173,7 @@ std::error_code Account::Load()
|
|||
|
||||
std::error_code Account::Save()
|
||||
{
|
||||
fs::path path = CemuApp::GetMLCPath(fmt::format(L"usr/save/system/act/{:08x}", m_persistent_id)).ToStdWstring();
|
||||
fs::path path = ActiveSettings::GetMlcPath(fmt::format(L"usr/save/system/act/{:08x}", m_persistent_id));
|
||||
if (!fs::exists(path))
|
||||
{
|
||||
std::error_code ec;
|
||||
|
@ -184,7 +182,7 @@ std::error_code Account::Save()
|
|||
return ec;
|
||||
}
|
||||
|
||||
path /= L"account.dat";
|
||||
path /= "account.dat";
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -302,7 +300,7 @@ void Account::SetMiiName(std::wstring_view name)
|
|||
const std::vector<Account>& Account::RefreshAccounts()
|
||||
{
|
||||
std::vector<Account> result;
|
||||
const fs::path path = CemuApp::GetMLCPath(L"usr/save/system/act").ToStdWstring();
|
||||
const fs::path path = ActiveSettings::GetMlcPath("usr/save/system/act");
|
||||
if (fs::exists(path))
|
||||
{
|
||||
for (const auto& it : fs::directory_iterator(path))
|
||||
|
@ -417,7 +415,7 @@ fs::path Account::GetFileName(uint32 persistent_id)
|
|||
if (persistent_id < kMinPersistendId)
|
||||
throw std::invalid_argument(fmt::format("persistent id {:#x} is invalid", persistent_id));
|
||||
|
||||
return CemuApp::GetMLCPath(fmt::format(L"usr/save/system/act/{:08x}/account.dat", persistent_id)).ToStdWstring();
|
||||
return ActiveSettings::GetMlcPath(fmt::format("usr/save/system/act/{:08x}/account.dat", persistent_id));
|
||||
}
|
||||
|
||||
OnlineValidator Account::ValidateOnlineFiles() const
|
||||
|
|
|
@ -454,8 +454,6 @@ add_library(CemuCafe
|
|||
TitleList/BaseInfo.cpp
|
||||
TitleList/BaseInfo.h
|
||||
TitleList/GameInfo.h
|
||||
TitleList/MetaInfo.cpp
|
||||
TitleList/MetaInfo.h
|
||||
TitleList/ParsedMetaXml.h
|
||||
TitleList/SaveInfo.cpp
|
||||
TitleList/SaveInfo.h
|
||||
|
|
|
@ -337,7 +337,7 @@ uint32 loadSharedData()
|
|||
// advance write offset and pad to 16 byte alignment
|
||||
dataWritePtr += ((fileSize + 15) & ~15);
|
||||
}
|
||||
forceLog_printfW(L"COS: System fonts found. Generated shareddata (%dKB)", (uint32)(dataWritePtr - (uint8*)shareddataTable) / 1024);
|
||||
cemuLog_log(LogType::Force, "COS: System fonts found. Generated shareddata ({}KB)", (uint32)(dataWritePtr - (uint8*)shareddataTable) / 1024);
|
||||
return memory_getVirtualOffsetFromPointer(dataWritePtr);
|
||||
}
|
||||
// alternative method: load RAM dump
|
||||
|
|
|
@ -139,7 +139,7 @@ void hle_scan(uint8* data, sint32 dataLength, char* hleFunctionName)
|
|||
uint32 offset = (uint32)(scanCurrent - scanStart) + 0x01000000;
|
||||
debug_printf("HLE signature for '%s' found at 0x%08x\n", hleFunctionName, offset);
|
||||
uint32 opcode = (1<<26)|(functionIndex+0x1000); // opcode for HLE: 0x1000 + FunctionIndex
|
||||
memory_writeU32Direct(offset, opcode);
|
||||
memory_write<uint32>(offset, opcode);
|
||||
break;
|
||||
}
|
||||
scanCurrent += 4;
|
||||
|
@ -330,7 +330,7 @@ void GamePatch_scan()
|
|||
#endif
|
||||
sint32 functionIndex = hleIndex_h000000001;
|
||||
uint32 opcode = (1 << 26) | (functionIndex); // opcode for HLE: 0x1000 + FunctionIndex
|
||||
memory_writeU32Direct(hleAddr - 4, opcode);
|
||||
memory_write<uint32>(hleAddr - 4, opcode);
|
||||
}
|
||||
hleIndex_h000000002 = osLib_getFunctionIndex("hle", "h000000002");
|
||||
hleAddr = hle_locate(botw_busyLoopSignature2, botw_busyLoopMask2, sizeof(botw_busyLoopSignature2));
|
||||
|
@ -341,7 +341,7 @@ void GamePatch_scan()
|
|||
#endif
|
||||
sint32 functionIndex = hleIndex_h000000002;
|
||||
uint32 opcode = (1 << 26) | (functionIndex); // opcode for HLE: 0x1000 + FunctionIndex
|
||||
memory_writeU32Direct(hleAddr - 4, opcode);
|
||||
memory_write<uint32>(hleAddr - 4, opcode);
|
||||
}
|
||||
|
||||
// FFL library float array endian conversion
|
||||
|
@ -353,7 +353,7 @@ void GamePatch_scan()
|
|||
forceLogDebug_printf("HLE: Hook FFL float array endian swap function at 0x%08x", hleAddr);
|
||||
sint32 functionIndex = hleIndex_h000000003;
|
||||
uint32 opcode = (1 << 26) | (functionIndex); // opcode for HLE: 0x1000 + FunctionIndex
|
||||
memory_writeU32Direct(hleAddr, opcode);
|
||||
memory_write<uint32>(hleAddr, opcode);
|
||||
}
|
||||
|
||||
// XCX freeze workaround
|
||||
|
|
|
@ -500,6 +500,14 @@ GraphicPack2::GraphicPack2(std::wstring filename, IniParser& rules)
|
|||
}
|
||||
}
|
||||
|
||||
// returns true if enabling, disabling (changeEnableState) or changing presets (changePreset) for the graphic pack requires restarting if the game is already running
|
||||
bool GraphicPack2::RequiresRestart(bool changeEnableState, bool changePreset)
|
||||
{
|
||||
if (!GetTextureRules().empty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GraphicPack2::Reload()
|
||||
{
|
||||
Deactivate();
|
||||
|
|
|
@ -105,6 +105,7 @@ public:
|
|||
sint32 GetVersion() const { return m_version; }
|
||||
const std::wstring& GetFilename() const { return m_filename; }
|
||||
const fs::path GetFilename2() const { return fs::path(m_filename); }
|
||||
bool RequiresRestart(bool changeEnableState, bool changePreset);
|
||||
bool Reload();
|
||||
|
||||
bool HasName() const { return !m_name.empty(); }
|
||||
|
@ -172,6 +173,7 @@ public:
|
|||
|
||||
static void ActivateForCurrentTitle();
|
||||
static void Reset();
|
||||
|
||||
private:
|
||||
bool Activate();
|
||||
bool Deactivate();
|
||||
|
|
|
@ -102,14 +102,14 @@ bool GraphicPack2::LoadCemuPatches()
|
|||
// load Cemu style patch file
|
||||
if (!ParseCemuPatchesTxtInternal(patchesStream))
|
||||
{
|
||||
forceLog_printfW(L"Error while processing \"%s\". No patches for this graphic pack will be applied.", path.c_str());
|
||||
cemuLog_log(LogType::Force, "Error while processing \"{}\". No patches for this graphic pack will be applied.", _pathToUtf8(path));
|
||||
cemu_assert_debug(list_patchGroups.empty());
|
||||
return true; // return true since a .asm patch was found even if we could not parse it
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forceLog_printfW(L"Unable to load patch file \"%s\"", path.c_str());
|
||||
cemuLog_log(LogType::Force, "Unable to load patch file \"{}\"", _pathToUtf8(path));
|
||||
}
|
||||
foundPatches = true;
|
||||
}
|
||||
|
|
|
@ -559,19 +559,19 @@ LatteCMDPtr LatteCP_itLoadReg(LatteCMDPtr cmd, uint32 nWords, uint32 regBase)
|
|||
MPTR physAddressRegArea = LatteReadCMD();
|
||||
uint32 waitForIdle = LatteReadCMD();
|
||||
uint32 loadEntries = (nWords - 2) / 2;
|
||||
uint32 regIndex = 0;
|
||||
uint32 regShadowMemAddr = physAddressRegArea;
|
||||
for (uint32 i = 0; i < loadEntries; i++)
|
||||
{
|
||||
uint32 regOffset = LatteReadCMD();
|
||||
uint32 regCount = LatteReadCMD();
|
||||
cemu_assert_debug(regCount != 0);
|
||||
uint32 regAddr = regBase + regOffset;
|
||||
for (uint32 f = 0; f < regCount; f++)
|
||||
{
|
||||
uint32 regAddr = regBase + regOffset + f;
|
||||
uint32 regShadowMemAddr = physAddressRegArea + regIndex * 4;
|
||||
LatteGPUState.contextRegisterShadowAddr[regAddr] = regShadowMemAddr;
|
||||
LatteGPUState.contextRegister[regAddr] = memory_readU32Direct(regShadowMemAddr);
|
||||
regIndex++;
|
||||
LatteGPUState.contextRegister[regAddr] = memory_read<uint32>(regShadowMemAddr);
|
||||
regAddr++;
|
||||
regShadowMemAddr += 4;
|
||||
}
|
||||
}
|
||||
return cmd;
|
||||
|
@ -716,7 +716,7 @@ LatteCMDPtr LatteCP_itHLESampleTimer(LatteCMDPtr cmd, uint32 nWords)
|
|||
{
|
||||
cemu_assert_debug(nWords == 1);
|
||||
MPTR timerMPTR = (MPTR)LatteReadCMD();
|
||||
memory_writeU64Slow(timerMPTR, coreinit::coreinit_getTimerTick());
|
||||
memory_writeU64(timerMPTR, coreinit::coreinit_getTimerTick());
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ void LatteShaderCache_load()
|
|||
if(!fc_shaderCacheGeneric)
|
||||
{
|
||||
// no shader cache available yet
|
||||
forceLog_printfW(L"Unable to open or create shader cache file \"%s\"", pathGeneric.c_str());
|
||||
cemuLog_log(LogType::Force, "Unable to open or create shader cache file \"{}\"", _pathToUtf8(pathGeneric));
|
||||
LatteShaderCache_finish();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -695,7 +695,7 @@ void LatteTextureLoader_UpdateTextureSliceData(LatteTexture* tex, sint32 texture
|
|||
if (textureLoader.dump)
|
||||
{
|
||||
wchar_t path[1024];
|
||||
swprintf(path, 1024, L"dump\\textures\\%08x_fmt%04x_slice%d_mip%02d_%dx%d_tm%02d.tga", physImagePtr, (uint32)tex->format, sliceIndex, mipIndex, tex->width, tex->height, tileMode);
|
||||
swprintf(path, 1024, L"dump/textures/%08x_fmt%04x_slice%d_mip%02d_%dx%d_tm%02d.tga", physImagePtr, (uint32)tex->format, sliceIndex, mipIndex, tex->width, tex->height, tileMode);
|
||||
tga_write_rgba(path, textureLoader.width, textureLoader.height, textureLoader.dumpRGBA);
|
||||
free(textureLoader.dumpRGBA);
|
||||
}
|
||||
|
|
|
@ -293,11 +293,6 @@ uint8* memory_getPointerFromVirtualOffsetAllowNull(uint32 virtualOffset)
|
|||
return memory_getPointerFromVirtualOffset(virtualOffset);
|
||||
}
|
||||
|
||||
void memory_writeU32Direct(uint32 address, uint32 v)
|
||||
{
|
||||
*(uint32*)(memory_getPointerFromVirtualOffset(address)) = CPU_swapEndianU32(v);
|
||||
}
|
||||
|
||||
// write access
|
||||
void memory_writeDouble(uint32 address, double vf)
|
||||
{
|
||||
|
@ -320,12 +315,6 @@ void memory_writeU32(uint32 address, uint32 v)
|
|||
*(uint32*)(memory_getPointerFromVirtualOffset(address)) = CPU_swapEndianU32(v);
|
||||
}
|
||||
|
||||
void memory_writeU64Slow(uint32 address, uint64 v)
|
||||
{
|
||||
memory_writeU32(address+0, (v>>32)&0xFFFFFFFF);
|
||||
memory_writeU32(address+4, (v)&0xFFFFFFFF);
|
||||
}
|
||||
|
||||
void memory_writeU64(uint32 address, uint64 v)
|
||||
{
|
||||
*(uint64*)(memory_getPointerFromVirtualOffset(address)) = CPU_swapEndianU64(v);
|
||||
|
@ -372,12 +361,6 @@ uint32 memory_readU32(uint32 address)
|
|||
return CPU_swapEndianU32(v);
|
||||
}
|
||||
|
||||
uint32 memory_readU32Direct(uint32 address)
|
||||
{
|
||||
uint32 v = *(uint32*)(memory_getPointerFromVirtualOffset(address));
|
||||
return CPU_swapEndianU32(v);
|
||||
}
|
||||
|
||||
uint16 memory_readU16(uint32 address)
|
||||
{
|
||||
uint16 v = *(uint16*)(memory_getPointerFromVirtualOffset(address));
|
||||
|
|
|
@ -15,7 +15,7 @@ uint8* memory_getPointerFromPhysicalOffset(uint32 physicalOffset);
|
|||
uint32 memory_virtualToPhysical(uint32 virtualOffset);
|
||||
uint32 memory_physicalToVirtual(uint32 physicalOffset);
|
||||
|
||||
extern uint8* memory_base; // points to 0x00000000
|
||||
extern uint8* memory_base; // points to base of PowerPC address space
|
||||
|
||||
enum class MMU_MEM_AREA_ID
|
||||
{
|
||||
|
@ -171,33 +171,26 @@ bool memory_isAddressRangeAccessible(MPTR virtualAddress, uint32 size);
|
|||
#define MEMORY_SHAREDDATA_AREA_ADDR (0xF8000000)
|
||||
#define MEMORY_SHAREDDATA_AREA_SIZE (0x02000000) // 32MB
|
||||
|
||||
static uint16 CPU_swapEndianU16(uint16 v)
|
||||
{
|
||||
return (v>>8)|(v<<8);
|
||||
}
|
||||
|
||||
#if BOOST_OS_WINDOWS
|
||||
#define CPU_swapEndianU64(_v) _byteswap_uint64((uint64)(_v))
|
||||
#define CPU_swapEndianU32(_v) _byteswap_ulong((uint32)(_v))
|
||||
#define CPU_swapEndianU16(_v) _byteswap_ushort((uint16)(_v))
|
||||
#elif BOOST_OS_LINUX
|
||||
#define CPU_swapEndianU64(_v) bswap_64((uint64)(_v))
|
||||
#define CPU_swapEndianU32(_v) bswap_32((uint32)(_v))
|
||||
#define CPU_swapEndianU16(_v) bswap_16((uint16)(_v))
|
||||
#elif BOOST_OS_MACOS
|
||||
#define CPU_swapEndianU64(_v) OSSwapInt64((uint64)(_v))
|
||||
#define CPU_swapEndianU32(_v) OSSwapInt32((uint32)(_v))
|
||||
#define CPU_swapEndianU16(_v) OSSwapInt16((uint16)(_v))
|
||||
#endif
|
||||
|
||||
// direct memory access (no hardware interface access)
|
||||
void memory_writeU32Direct(uint32 address, uint32 v);
|
||||
uint32 memory_readU32Direct(uint32 address);
|
||||
|
||||
// memory access (includes hardware interface, slower)
|
||||
// C-style memory access, deprecated. Use memory_read<> and memory_write<> templates instead
|
||||
void memory_writeDouble(uint32 address, double vf);
|
||||
void memory_writeFloat(uint32 address, float vf);
|
||||
void memory_writeU32(uint32 address, uint32 v);
|
||||
void memory_writeU16(uint32 address, uint16 v);
|
||||
void memory_writeU8(uint32 address, uint8 v);
|
||||
void memory_writeU64Slow(uint32 address, uint64 v);
|
||||
void memory_writeU64(uint32 address, uint64 v);
|
||||
|
||||
double memory_readDouble(uint32 address);
|
||||
|
@ -210,43 +203,24 @@ uint8 memory_readU8(uint32 address);
|
|||
void memory_createDump();
|
||||
|
||||
template<size_t count>
|
||||
void memory_readBytes(uint32 address, std::array<uint8, count>& buffer)
|
||||
void memory_readBytes(VAddr address, std::array<uint8, count>& buffer)
|
||||
{
|
||||
memcpy(buffer.data(), memory_getPointerFromVirtualOffset(address), count);
|
||||
}
|
||||
|
||||
template <typename T> T memory_read(uint32 address)
|
||||
template <typename T> inline T memory_read(VAddr address)
|
||||
{
|
||||
if constexpr(std::is_floating_point<T>::value)
|
||||
{
|
||||
if constexpr(sizeof(T) == sizeof(float))
|
||||
return memory_readFloat(address);
|
||||
else
|
||||
return memory_readDouble(address);
|
||||
}
|
||||
else if(std::is_integral<T>::value)
|
||||
{
|
||||
if constexpr (sizeof(T) == sizeof(uint8))
|
||||
return (T)memory_readU8(address);
|
||||
else if constexpr (sizeof(T) == sizeof(uint16))
|
||||
return (T)memory_readU16(address);
|
||||
else if constexpr (sizeof(T) == sizeof(uint32))
|
||||
return (T)memory_readU32(address);
|
||||
else if constexpr (sizeof(T) == sizeof(uint64))
|
||||
return (T)memory_readU64(address);
|
||||
}
|
||||
return *(betype<T>*)(memory_base + address);
|
||||
}
|
||||
|
||||
debugBreakpoint();
|
||||
return {};
|
||||
template <typename T> inline void memory_write(VAddr address, T value)
|
||||
{
|
||||
*(betype<T>*)(memory_base + address) = value;
|
||||
}
|
||||
|
||||
// LLE implementation
|
||||
void memory_initPhysicalLayout();
|
||||
|
||||
// updated code
|
||||
using EAddr = uint32; // effective address
|
||||
using PAddr = uint32; // physical address
|
||||
|
||||
namespace MMU
|
||||
{
|
||||
using MMIOFuncWrite32 = void (*)(PAddr addr, uint32 value);
|
||||
|
|
|
@ -734,7 +734,7 @@ uint32 RPLLoader_MakePPCCallable(void(*ppcCallableExport)(PPCInterpreter_t* hCPU
|
|||
sint32 functionIndex = PPCInterpreter_registerHLECall(ppcCallableExport);
|
||||
MPTR codeAddr = memory_getVirtualOffsetFromPointer(RPLLoader_AllocateTrampolineCodeSpace(4));
|
||||
uint32 opcode = (1 << 26) | functionIndex;
|
||||
memory_writeU32Direct(codeAddr, opcode);
|
||||
memory_write<uint32>(codeAddr, opcode);
|
||||
g_map_callableExports[ppcCallableExport] = codeAddr;
|
||||
return codeAddr;
|
||||
}
|
||||
|
@ -772,7 +772,7 @@ uint32 rpl_mapHLEImport(RPLModule* rplLoaderContext, const char* rplName, const
|
|||
{
|
||||
MPTR codeAddr = memory_getVirtualOffsetFromPointer(RPLLoader_AllocateTrampolineCodeSpace(4));
|
||||
uint32 opcode = (1 << 26) | functionIndex;
|
||||
memory_writeU32Direct(codeAddr, opcode);
|
||||
memory_write<uint32>(codeAddr, opcode);
|
||||
// register mapped import
|
||||
mappedFunctionImport_t newImport;
|
||||
newImport.hash1 = mappedImportHash1;
|
||||
|
@ -792,8 +792,8 @@ uint32 rpl_mapHLEImport(RPLModule* rplLoaderContext, const char* rplName, const
|
|||
uint32 codeStart = memory_getVirtualOffsetFromPointer(RPLLoader_AllocateTrampolineCodeSpace(256));
|
||||
uint32 currentAddress = codeStart;
|
||||
uint32 opcode = (1 << 26) | (0xFFD0); // opcode for HLE: Unsupported import
|
||||
memory_writeU32Direct(codeStart + 0, opcode);
|
||||
memory_writeU32Direct(codeStart + 4, 0x4E800020);
|
||||
memory_write<uint32>(codeStart + 0, opcode);
|
||||
memory_write<uint32>(codeStart + 4, 0x4E800020);
|
||||
currentAddress += 8;
|
||||
// write name of lib/function
|
||||
sint32 libNameLength = std::min(128, (sint32)strlen(libName));
|
||||
|
|
|
@ -176,12 +176,11 @@ namespace coreinit
|
|||
alarm->setMagic();
|
||||
}
|
||||
|
||||
void coreinitExport_OSCreateAlarmEx(PPCInterpreter_t* hCPU)
|
||||
void OSCreateAlarmEx(OSAlarm_t* alarm, const char* alarmName)
|
||||
{
|
||||
OSAlarm_t* OSAlarm = (OSAlarm_t*)memory_getPointerFromVirtualOffset(hCPU->gpr[3]);
|
||||
OSCreateAlarm(OSAlarm);
|
||||
OSAlarm->name = _swapEndianU32(hCPU->gpr[4]);
|
||||
osLib_returnFromFunction(hCPU, 0);
|
||||
memset(alarm, 0, sizeof(OSAlarm_t));
|
||||
alarm->setMagic();
|
||||
alarm->name = alarmName;
|
||||
}
|
||||
|
||||
std::unordered_map<OSAlarm_t*, OSHostAlarm*> g_activeAlarms;
|
||||
|
@ -274,14 +273,12 @@ namespace coreinit
|
|||
|
||||
void OSSetAlarmUserData(OSAlarm_t* alarm, uint32 userData)
|
||||
{
|
||||
alarm->userData = _swapEndianU32(userData);
|
||||
alarm->userData = userData;
|
||||
}
|
||||
|
||||
void coreinitExport_OSGetAlarmUserData(PPCInterpreter_t* hCPU)
|
||||
uint32 OSGetAlarmUserData(OSAlarm_t* alarm)
|
||||
{
|
||||
OSAlarm_t* OSAlarmBE = (OSAlarm_t*)memory_getPointerFromVirtualOffset(hCPU->gpr[3]);
|
||||
MPTR userData = _swapEndianU32(OSAlarmBE->userData);
|
||||
osLib_returnFromFunction(hCPU, userData);
|
||||
return alarm->userData;
|
||||
}
|
||||
|
||||
void OSAlarm_resetAll()
|
||||
|
@ -337,15 +334,13 @@ namespace coreinit
|
|||
|
||||
void InitializeAlarm()
|
||||
{
|
||||
cafeExportRegister("coreinit", OSCreateAlarm, LogType::Placeholder);
|
||||
cafeExportRegister("coreinit", OSCancelAlarm, LogType::Placeholder);
|
||||
cafeExportRegister("coreinit", OSSetAlarm, LogType::Placeholder);
|
||||
cafeExportRegister("coreinit", OSSetPeriodicAlarm, LogType::Placeholder);
|
||||
|
||||
cafeExportRegister("coreinit", OSSetAlarmUserData, LogType::Placeholder);
|
||||
|
||||
osLib_addFunction("coreinit", "OSCreateAlarmEx", coreinitExport_OSCreateAlarmEx);
|
||||
osLib_addFunction("coreinit", "OSGetAlarmUserData", coreinitExport_OSGetAlarmUserData);
|
||||
cafeExportRegister("coreinit", OSCreateAlarm, LogType::CoreinitAlarm);
|
||||
cafeExportRegister("coreinit", OSCreateAlarmEx, LogType::CoreinitAlarm);
|
||||
cafeExportRegister("coreinit", OSCancelAlarm, LogType::CoreinitAlarm);
|
||||
cafeExportRegister("coreinit", OSSetAlarm, LogType::CoreinitAlarm);
|
||||
cafeExportRegister("coreinit", OSSetPeriodicAlarm, LogType::CoreinitAlarm);
|
||||
cafeExportRegister("coreinit", OSSetAlarmUserData, LogType::CoreinitAlarm);
|
||||
cafeExportRegister("coreinit", OSGetAlarmUserData, LogType::CoreinitAlarm);
|
||||
|
||||
// init event
|
||||
OSInitEvent(g_alarmEvent.GetPtr(), OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, OSEvent::EVENT_MODE::MODE_AUTO);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
namespace coreinit
|
||||
{
|
||||
|
||||
class OSHostAlarm;
|
||||
OSHostAlarm* OSHostAlarmCreate(uint64 nextFire, uint64 period, void(*callbackFunc)(uint64 currentTick, void* context), void* context);
|
||||
void OSHostAlarmDestroy(OSHostAlarm* hostAlarm);
|
||||
|
@ -11,7 +10,7 @@ namespace coreinit
|
|||
struct OSAlarm_t
|
||||
{
|
||||
/* +0x00 */ betype<uint32> magic;
|
||||
/* +0x04 */ MPTR_UINT8 name;
|
||||
/* +0x04 */ MEMPTR<const char> name;
|
||||
/* +0x08 */ uint32 ukn08;
|
||||
/* +0x0C */ MPTR handler;
|
||||
/* +0x10 */ uint32 ukn10;
|
||||
|
@ -21,7 +20,7 @@ namespace coreinit
|
|||
/* +0x24 */ MPTR next; // pointer to OSAlarm
|
||||
/* +0x28 */ uint64 period; // period (zero for non-periodic timer)
|
||||
/* +0x30 */ uint64 startTime; // period start
|
||||
/* +0x38 */ MPTR userData;
|
||||
/* +0x38 */ uint32be userData;
|
||||
/* +0x3C */ uint32 ukn3C;
|
||||
/* +0x40 */ OSThreadQueue uknThreadQueue;
|
||||
/* +0x50 */ MPTR alarmQueue;
|
||||
|
|
|
@ -428,8 +428,8 @@ struct OSThread_t
|
|||
|
||||
/* +0x38C */ coreinit::OSThreadLink activeThreadChain; // queue of active threads (g_activeThreadQueue)
|
||||
|
||||
/* +0x394 */ MPTR_UINT8 stackBase; // upper limit of stack
|
||||
/* +0x398 */ MPTR_UINT32 stackEnd; // lower limit of stack
|
||||
/* +0x394 */ MPTR stackBase; // upper limit of stack
|
||||
/* +0x398 */ MPTR stackEnd; // lower limit of stack
|
||||
|
||||
/* +0x39C */ MPTR entrypoint;
|
||||
/* +0x3A0 */ crt_t crt;
|
||||
|
@ -443,8 +443,7 @@ struct OSThread_t
|
|||
/* +0x5C8 */ uint32 userStackPointer;
|
||||
|
||||
/* +0x5CC */ MEMPTR<void> cleanupCallback2;
|
||||
/* +0x5D0 */ //MPTR deallocator;
|
||||
MEMPTR<void> deallocatorFunc;
|
||||
/* +0x5D0 */ MEMPTR<void> deallocatorFunc;
|
||||
|
||||
/* +0x5D4 */ uint32 stateFlags; // 0x5D4 | various flags? Controls if canceling/suspension is allowed (at cancel points) or not? If 1 -> Cancel/Suspension not allowed, if 0 -> Cancel/Suspension allowed
|
||||
/* +0x5D8 */ betype<REQUEST_FLAG_BIT> requestFlags;
|
||||
|
|
|
@ -37,8 +37,8 @@ void gx2Export_GX2GetSwapStatus(PPCInterpreter_t* hCPU)
|
|||
{
|
||||
memory_writeU32(hCPU->gpr[3], _swapEndianU32(LatteGPUState.sharedArea->flipRequestCountBE));
|
||||
memory_writeU32(hCPU->gpr[4], _swapEndianU32(LatteGPUState.sharedArea->flipExecuteCountBE));
|
||||
memory_writeU64Slow(hCPU->gpr[5], lastSwapTime);
|
||||
memory_writeU64Slow(hCPU->gpr[6], lastSwapTime);
|
||||
memory_writeU64(hCPU->gpr[5], lastSwapTime);
|
||||
memory_writeU64(hCPU->gpr[6], lastSwapTime);
|
||||
|
||||
osLib_returnFromFunction(hCPU, 0);
|
||||
}
|
||||
|
@ -54,14 +54,14 @@ void gx2Export_GX2GetGPUTimeout(PPCInterpreter_t* hCPU)
|
|||
void gx2Export_GX2SampleTopGPUCycle(PPCInterpreter_t* hCPU)
|
||||
{
|
||||
gx2Log_printf("GX2SampleTopGPUCycle(0x%08x)\n", hCPU->gpr[3]);
|
||||
memory_writeU64Slow(hCPU->gpr[3], coreinit::coreinit_getTimerTick());
|
||||
memory_writeU64(hCPU->gpr[3], coreinit::coreinit_getTimerTick());
|
||||
osLib_returnFromFunction(hCPU, 0);
|
||||
}
|
||||
|
||||
void gx2Export_GX2SampleBottomGPUCycle(PPCInterpreter_t* hCPU)
|
||||
{
|
||||
gx2Log_printf("GX2SampleBottomGPUCycle(0x%08x)\n", hCPU->gpr[3]);
|
||||
memory_writeU64Slow(hCPU->gpr[3], GX2_INVALID_COUNTER_VALUE_U64);
|
||||
memory_writeU64(hCPU->gpr[3], GX2_INVALID_COUNTER_VALUE_U64);
|
||||
|
||||
osLib_returnFromFunction(hCPU, 0);
|
||||
return;
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace nn::temp
|
|||
forceLogDebug_printf("TEMPCreateAndInitTempDir(...) - placeholder");
|
||||
|
||||
// create random temp id
|
||||
memory_writeU64Slow(hCPU->gpr[5], tempIdGenerator);
|
||||
memory_writeU64(hCPU->gpr[5], tempIdGenerator);
|
||||
tempIdGenerator = (tempIdGenerator << 3) | (tempIdGenerator >> 61);
|
||||
tempIdGenerator += 0x56e28bd5f4ULL;
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ namespace nsyshid
|
|||
deviceItr->hFile = openDevice(deviceItr->devicePath);
|
||||
if (deviceItr->hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
forceLog_printfW(L"HID: Failed to open device \"%s\"", deviceItr->devicePath);
|
||||
cemuLog_log(LogType::Force, "HID: Failed to open device \"{}\"", boost::nowide::narrow(std::wstring(deviceItr->devicePath)));
|
||||
return nullptr;
|
||||
}
|
||||
HidD_SetNumInputBuffers(deviceItr->hFile, 2); // dont cache too many reports
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "config/CemuConfig.h"
|
||||
#include "MetaInfo.h"
|
||||
#include "TitleInfo.h"
|
||||
#include "config/ActiveSettings.h"
|
||||
|
||||
|
|
|
@ -1,179 +0,0 @@
|
|||
#include "MetaInfo.h"
|
||||
#include "Cafe/Filesystem/fsc.h"
|
||||
|
||||
#include "pugixml.hpp"
|
||||
#include "Cafe/Filesystem/FST/FST.h"
|
||||
|
||||
MetaInfo::MetaInfo()
|
||||
{
|
||||
m_type = GameType::FSC;
|
||||
|
||||
uint32 meta_size;
|
||||
const auto meta_data = ReadFSCFile("vol/meta/meta.xml", meta_size);
|
||||
if (meta_size == 0 || !meta_data)
|
||||
throw std::runtime_error("meta.xml missing");
|
||||
|
||||
pugi::xml_document meta_doc;
|
||||
ParseMetaFile(meta_doc, meta_doc.load_buffer_inplace(meta_data.get(), meta_size));
|
||||
}
|
||||
|
||||
MetaInfo::MetaInfo(const fs::path& filename)
|
||||
{
|
||||
if (!fs::exists(filename))
|
||||
throw std::invalid_argument("filename doesn't exist");
|
||||
|
||||
if (fs::is_directory(filename))
|
||||
{
|
||||
MetaInfo::ParseDirectory(filename);
|
||||
m_type = GameType::Directory;
|
||||
m_type_path = filename;
|
||||
}
|
||||
else
|
||||
MetaInfo::ParseFile(filename);
|
||||
}
|
||||
|
||||
std::string MetaInfo::GetName(CafeConsoleLanguage language) const
|
||||
{
|
||||
std::string long_name{ GetLongName(language) };
|
||||
const auto nl = long_name.find(L'\n');
|
||||
if (nl != std::string::npos)
|
||||
long_name.replace(nl, 1, " - ");
|
||||
|
||||
return long_name;
|
||||
}
|
||||
|
||||
const std::string& MetaInfo::GetLongName(CafeConsoleLanguage language) const
|
||||
{
|
||||
return m_long_name[(int)language].empty() ? m_long_name[(int)CafeConsoleLanguage::EN] : m_long_name[(int)language];
|
||||
}
|
||||
|
||||
const std::string& MetaInfo::GetShortName(CafeConsoleLanguage language) const
|
||||
{
|
||||
return m_short_name[(int)language].empty() ? m_short_name[(int)CafeConsoleLanguage::EN] : m_short_name[(int)language];
|
||||
}
|
||||
|
||||
const std::string& MetaInfo::GetPublisher(CafeConsoleLanguage language) const
|
||||
{
|
||||
return m_publisher[(int)language].empty() ? m_publisher[(int)CafeConsoleLanguage::EN] : m_publisher[(int)language];
|
||||
}
|
||||
|
||||
void MetaInfo::ParseDirectory(const fs::path& filename)
|
||||
{
|
||||
const auto meta_dir = fs::path(filename).append(L"meta");
|
||||
if (!fs::exists(meta_dir) || !fs::is_directory(meta_dir))
|
||||
throw std::invalid_argument("meta directory missing");
|
||||
|
||||
const auto meta_file = meta_dir / L"meta.xml";
|
||||
if (!fs::exists(meta_file) || !fs::is_regular_file(meta_file))
|
||||
throw std::invalid_argument("meta.xml missing");
|
||||
|
||||
ParseMetaFile(meta_file.wstring());
|
||||
}
|
||||
|
||||
bool MetaInfo::ParseFile(const fs::path& filename)
|
||||
{
|
||||
if (filename.filename() != "meta.xml")
|
||||
return false;
|
||||
|
||||
const auto base_dir = filename.parent_path().parent_path();
|
||||
|
||||
ParseMetaFile(filename);
|
||||
m_type = GameType::Directory;
|
||||
m_type_path = base_dir;
|
||||
return true;
|
||||
}
|
||||
|
||||
void MetaInfo::ParseMetaFile(const fs::path& meta_file)
|
||||
{
|
||||
pugi::xml_document doc;
|
||||
const auto result = doc.load_file(meta_file.wstring().c_str());
|
||||
ParseMetaFile(doc, result);
|
||||
}
|
||||
|
||||
void MetaInfo::ParseMetaFile(const pugi::xml_document& doc, const pugi::xml_parse_result& result)
|
||||
{
|
||||
if (!result)
|
||||
throw std::invalid_argument(fmt::format("error when parsing the meta.xml: {}", result.description()));
|
||||
|
||||
const auto root = doc.child("menu");
|
||||
if (!root)
|
||||
throw std::invalid_argument("meta.xml invalid");
|
||||
|
||||
for (const auto& child : root.children())
|
||||
{
|
||||
std::string_view name = child.name();
|
||||
if (name == "title_version")
|
||||
m_version = child.text().as_uint();
|
||||
else if (name == "product_code")
|
||||
m_product_code = child.text().as_string();
|
||||
else if (name == "company_code")
|
||||
m_company_code = child.text().as_string();
|
||||
else if (name == "content_platform")
|
||||
m_content_platform = child.text().as_string();
|
||||
else if (name == "title_id")
|
||||
m_title_id = std::stoull(child.text().as_string(), nullptr, 16);
|
||||
else if (name == "region")
|
||||
m_region = (CafeConsoleRegion)child.text().as_uint();
|
||||
else if (boost::starts_with(name, "longname_"))
|
||||
{
|
||||
const sint32 index = GetLanguageIndex(name.substr(std::size("longname_") - 1));
|
||||
if (index != -1)
|
||||
m_long_name[index] = child.text().as_string();
|
||||
}
|
||||
else if (boost::starts_with(name, L"shortname_"))
|
||||
{
|
||||
const sint32 index = GetLanguageIndex(name.substr(std::size("shortname_") - 1));
|
||||
if (index != -1)
|
||||
m_short_name[index] = child.text().as_string();
|
||||
}
|
||||
else if (boost::starts_with(name, L"publisher_"))
|
||||
{
|
||||
const sint32 index = GetLanguageIndex(name.substr(std::size("publisher_") - 1));
|
||||
if (index != -1)
|
||||
m_publisher[index] = child.text().as_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<uint8[]> MetaInfo::GetIcon(uint32& size) const
|
||||
{
|
||||
size = 0;
|
||||
switch (m_type)
|
||||
{
|
||||
case GameType::FSC:
|
||||
return ReadFSCFile("vol/meta/iconTex.tga", size);
|
||||
case GameType::Directory:
|
||||
{
|
||||
cemu_assert_debug(!m_type_path.empty());
|
||||
const auto icon = fs::path(m_type_path).append(L"meta").append(L"iconTex.tga");
|
||||
std::ifstream file(icon, std::ios::binary | std::ios::ate);
|
||||
if (file.is_open())
|
||||
{
|
||||
size = file.tellg();
|
||||
if (size > 0)
|
||||
{
|
||||
file.seekg(0, std::ios::beg);
|
||||
auto result = std::make_unique<uint8[]>(size);
|
||||
file.read((char*)result.get(), size);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
case GameType::Image:
|
||||
{
|
||||
cemu_assert_debug(!m_type_path.empty());
|
||||
FSTVolume* volume = FSTVolume::OpenFromDiscImage(m_type_path);
|
||||
if (volume)
|
||||
{
|
||||
auto result = ReadVirtualFile(volume, "meta/iconTex.tga", size);
|
||||
delete volume;
|
||||
return result;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "BaseInfo.h"
|
||||
#include "config/CemuConfig.h"
|
||||
|
||||
class MetaInfo : public BaseInfo
|
||||
{
|
||||
public:
|
||||
MetaInfo();
|
||||
MetaInfo(const fs::path& filename);
|
||||
|
||||
// returns long name with replaces newlines to ' - '
|
||||
[[nodiscard]] std::string GetName(CafeConsoleLanguage language = CafeConsoleLanguage::EN) const;
|
||||
|
||||
[[nodiscard]] uint64 GetTitleId() const { return m_title_id; }
|
||||
[[nodiscard]] uint32 GetTitleIdHigh() const { return (uint32)(GetTitleId() >> 32); }
|
||||
[[nodiscard]] uint32 GetTitleIdLow() const { return (uint32)(GetTitleId() & 0xFFFFFFFF); }
|
||||
|
||||
[[nodiscard]] uint64 GetBaseTitleId() const { return m_title_id & ~0xF00000000ULL; }
|
||||
[[nodiscard]] uint32 GetBaseTitleIdHigh() const { return (uint32)(GetBaseTitleId() >> 32); }
|
||||
[[nodiscard]] uint32 GetBaseTitleIdLow() const { return (uint32)(GetBaseTitleId() & 0xFFFFFFFF); }
|
||||
|
||||
[[nodiscard]] uint64 GetUpdateTitleId() const { return GetBaseTitleId() | 0xE00000000ULL; }
|
||||
[[nodiscard]] uint32 GetUpdateTitleIdHigh() const { return (uint32)(GetUpdateTitleId() >> 32); }
|
||||
[[nodiscard]] uint32 GetUpdateTitleIdLow() const { return (uint32)(GetUpdateTitleId() & 0xFFFFFFFF); }
|
||||
|
||||
[[nodiscard]] uint64 GetDLCTitleId() const { return GetBaseTitleId() | 0xC00000000ULL; }
|
||||
[[nodiscard]] uint32 GetDLCTitleIdHigh() const { return (uint32)(GetDLCTitleId() >> 32); }
|
||||
[[nodiscard]] uint32 GetDLCTitleIdLow() const { return (uint32)(GetDLCTitleId() & 0xFFFFFFFF); }
|
||||
|
||||
[[nodiscard]] const std::string& GetLongName(CafeConsoleLanguage language) const;
|
||||
[[nodiscard]] const std::string& GetShortName(CafeConsoleLanguage language) const;
|
||||
[[nodiscard]] const std::string& GetPublisher(CafeConsoleLanguage language) const;
|
||||
[[nodiscard]] const std::string& GetProductCode() const { return m_product_code; }
|
||||
[[nodiscard]] const std::string& GetCompanyCode() const { return m_company_code; }
|
||||
[[nodiscard]] const std::string& GetContentPlatform() const { return m_content_platform; }
|
||||
[[nodiscard]] uint32 GetVersion() const { return m_version; }
|
||||
[[nodiscard]] CafeConsoleRegion GetRegion() const { return m_region; }
|
||||
|
||||
[[nodiscard]] std::unique_ptr<uint8[]> GetIcon(uint32& size) const;
|
||||
|
||||
protected:
|
||||
// meta.xml
|
||||
uint32 m_version;
|
||||
std::string m_product_code;
|
||||
std::string m_company_code;
|
||||
std::string m_content_platform;
|
||||
uint64 m_title_id;
|
||||
CafeConsoleRegion m_region;
|
||||
|
||||
std::array<std::string, 12> m_long_name;
|
||||
std::array<std::string, 12> m_short_name;
|
||||
std::array<std::string, 12> m_publisher;
|
||||
|
||||
void ParseDirectory(const fs::path& filename) override;
|
||||
bool ParseFile(const fs::path& filename) override;
|
||||
|
||||
void ParseMetaFile(const fs::path& meta_file);
|
||||
void ParseMetaFile(const pugi::xml_document& doc, const pugi::xml_parse_result& result);
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue