Code cleanup

This commit is contained in:
Exzap 2023-10-01 11:43:24 +02:00
parent 9523993a24
commit ff9d180154
26 changed files with 105 additions and 131 deletions

View File

@ -14,7 +14,7 @@
"generator": "Ninja",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}"
},
{
"name": "Debug",

View File

@ -254,13 +254,6 @@ void InfoLog_PrintActiveSettings()
cemuLog_log(LogType::Force, "Console language: {}", config.console_language);
}
void PPCCore_setupSPR(PPCInterpreter_t* hCPU, uint32 coreIndex)
{
hCPU->sprExtended.PVR = 0x70010001;
hCPU->spr.UPIR = coreIndex;
hCPU->sprExtended.msr |= MSR_FP; // enable floating point
}
struct SharedDataEntry
{
/* +0x00 */ uint32be name;

View File

@ -52,7 +52,7 @@ typedef struct
void hleExport_xcx_enterCriticalSection(PPCInterpreter_t* hCPU)
{
ppcDefineParamStructPtr(xcxCS, xcxCS_t, 0);
uint32 threadId = coreinitThread_getCurrentThreadMPTRDepr(hCPU);
uint32 threadId = MEMPTR<OSThread_t>(coreinit::OSGetCurrentThread()).GetMPTR();
cemu_assert_debug(xcxCS->ukn08 != 0);
cemu_assert_debug(threadId);
if (xcxCS->ownerThreadId == (uint32be)threadId)

View File

@ -513,10 +513,10 @@ void debugger_enterTW(PPCInterpreter_t* hCPU)
if (bp->bpType == DEBUGGER_BP_T_LOGGING && bp->enabled)
{
std::string logName = !bp->comment.empty() ? "Breakpoint '"+boost::nowide::narrow(bp->comment)+"'" : fmt::format("Breakpoint at 0x{:08X} (no comment)", bp->address);
std::string logContext = fmt::format("Thread: {:08x} LR: 0x{:08x}", coreinitThread_getCurrentThreadMPTRDepr(hCPU), hCPU->spr.LR, cemuLog_advancedPPCLoggingEnabled() ? " Stack Trace:" : "");
std::string logContext = fmt::format("Thread: {:08x} LR: 0x{:08x}", MEMPTR<OSThread_t>(coreinit::OSGetCurrentThread()).GetMPTR(), hCPU->spr.LR, cemuLog_advancedPPCLoggingEnabled() ? " Stack Trace:" : "");
cemuLog_log(LogType::Force, "[Debugger] {} was executed! {}", logName, logContext);
if (cemuLog_advancedPPCLoggingEnabled())
DebugLogStackTrace(coreinitThread_getCurrentThreadDepr(hCPU), hCPU->gpr[1]);
DebugLogStackTrace(coreinit::OSGetCurrentThread(), hCPU->gpr[1]);
break;
}
bp = bp->next;
@ -535,7 +535,7 @@ void debugger_enterTW(PPCInterpreter_t* hCPU)
// handle breakpoints
debuggerState.debugSession.isTrapped = true;
debuggerState.debugSession.debuggedThreadMPTR = coreinitThread_getCurrentThreadMPTRDepr(hCPU);
debuggerState.debugSession.debuggedThreadMPTR = MEMPTR<OSThread_t>(coreinit::OSGetCurrentThread()).GetMPTR();
debuggerState.debugSession.instructionPointer = hCPU->instructionPointer;
debuggerState.debugSession.hCPU = hCPU;
debugger_createPPCStateSnapshot(hCPU);

View File

@ -900,7 +900,7 @@ void GDBServer::HandleTrapInstruction(PPCInterpreter_t* hCPU)
return cemu_assert_suspicious();
// Secondly, delete one-shot breakpoints but also temporarily delete patched instruction to run original instruction
OSThread_t* currThread = coreinitThread_getCurrentThreadDepr(hCPU);
OSThread_t* currThread = coreinit::OSGetCurrentThread();
std::string pauseReason = fmt::format("T05thread:{:08X};core:{:02X};{}", GET_THREAD_ID(currThread), PPCInterpreter_getCoreIndex(hCPU), patchedBP->second.GetReason());
bool pauseThreads = patchedBP->second.ShouldBreakThreads() || patchedBP->second.ShouldBreakThreadsOnNextInterrupt();
if (patchedBP->second.IsPersistent())
@ -939,7 +939,7 @@ void GDBServer::HandleTrapInstruction(PPCInterpreter_t* hCPU)
ThreadPool::FireAndForget(&waitForBrokenThreads, std::move(m_resumed_context), pauseReason);
}
breakThreads(GET_THREAD_ID(coreinitThread_getCurrentThreadDepr(hCPU)));
breakThreads(GET_THREAD_ID(coreinit::OSGetCurrentThread()));
cemuLog_logDebug(LogType::Force, "[GDBStub] Resumed from a breakpoint!");
}
}

View File

@ -1,21 +1,27 @@
#pragma once
#include "Cafe/HW/Latte/ISA/LatteReg.h"
// this file contains legacy C-style defines, modernize and merge into LatteReg.h
// todo - this file contains legacy C-style defines, modernize and merge into LatteReg.h
// GPU7/Latte hardware info
#define LATTE_NUM_GPR (128)
#define LATTE_NUM_STREAMOUT_BUFFER (4)
#define LATTE_NUM_COLOR_TARGET (8)
#define LATTE_NUM_GPR 128
#define LATTE_NUM_STREAMOUT_BUFFER 4
#define LATTE_NUM_COLOR_TARGET 8
#define LATTE_NUM_MAX_TEX_UNITS (18) // number of available texture units per shader stage (this might be higher than 18? BotW is the only game which uses more than 16?)
#define LATTE_NUM_MAX_UNIFORM_BUFFERS (16) // number of supported uniform buffer binding locations
#define LATTE_NUM_MAX_TEX_UNITS 18 // number of available texture units per shader stage (this might be higher than 18? BotW is the only game which uses more than 16?)
#define LATTE_NUM_MAX_UNIFORM_BUFFERS 16 // number of supported uniform buffer binding locations
#define LATTE_VS_ATTRIBUTE_LIMIT (32) // todo: verify
#define LATTE_NUM_MAX_ATTRIBUTE_LOCATIONS (256) // should this be 128 since there are only 128 GPRs?
#define LATTE_VS_ATTRIBUTE_LIMIT 32 // todo: verify
#define LATTE_NUM_MAX_ATTRIBUTE_LOCATIONS 256 // should this be 128 since there are only 128 GPRs?
#define LATTE_MAX_VERTEX_BUFFERS (16)
#define LATTE_MAX_VERTEX_BUFFERS 16
// Cemu-specific constants
#define LATTE_CEMU_PS_TEX_UNIT_BASE 0
#define LATTE_CEMU_VS_TEX_UNIT_BASE 32
#define LATTE_CEMU_GS_TEX_UNIT_BASE 64
// vertex formats

View File

@ -1,10 +1,8 @@
#include "Cafe/HW/Latte/ISA/RegDefines.h"
#include "Cafe/OS/libs/gx2/GX2.h" // todo - remove this dependency
#include "Cafe/HW/Latte/Core/Latte.h"
#include "Cafe/HW/Latte/Core/LatteShader.h"
#include "Cafe/HW/Latte/Renderer/Renderer.h"
#include "Cafe/GraphicPack/GraphicPack2.h"
#include "Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h"
#include "Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.h"
@ -330,15 +328,15 @@ void LatteTexture_updateTextures()
// pixel shader
LatteDecompilerShader* pixelShader = LatteSHRC_GetActivePixelShader();
if (pixelShader)
LatteTexture_updateTexturesForStage(pixelShader, CEMU_PS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_PS);
LatteTexture_updateTexturesForStage(pixelShader, LATTE_CEMU_PS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_PS);
// vertex shader
LatteDecompilerShader* vertexShader = LatteSHRC_GetActiveVertexShader();
cemu_assert_debug(vertexShader != nullptr);
LatteTexture_updateTexturesForStage(vertexShader, CEMU_VS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_VS);
LatteTexture_updateTexturesForStage(vertexShader, LATTE_CEMU_VS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_VS);
// geometry shader
LatteDecompilerShader* geometryShader = LatteSHRC_GetActiveGeometryShader();
if (geometryShader)
LatteTexture_updateTexturesForStage(geometryShader, CEMU_GS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_GS);
LatteTexture_updateTexturesForStage(geometryShader, LATTE_CEMU_GS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_GS);
}
// returns the width, height, depth of the texture

View File

@ -1,9 +1,7 @@
#include "Cafe/HW/Latte/Core/LatteConst.h"
#include "Cafe/HW/Latte/Core/LatteShaderAssembly.h"
#include "Cafe/HW/Latte/ISA/RegDefines.h"
#include "Cafe/OS/libs/gx2/GX2.h" // todo - remove this dependency
#include "Cafe/HW/Latte/Core/Latte.h"
#include "Cafe/HW/Latte/Core/LatteDraw.h"
#include "Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h"
#include "Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h"
#include "Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInstructions.h"
@ -477,11 +475,11 @@ namespace LatteDecompiler
continue;
sint32 textureBindingPoint;
if (decompilerContext->shaderType == LatteConst::ShaderType::Vertex)
textureBindingPoint = i + CEMU_VS_TEX_UNIT_BASE;
textureBindingPoint = i + LATTE_CEMU_VS_TEX_UNIT_BASE;
else if (decompilerContext->shaderType == LatteConst::ShaderType::Geometry)
textureBindingPoint = i + CEMU_GS_TEX_UNIT_BASE;
textureBindingPoint = i + LATTE_CEMU_GS_TEX_UNIT_BASE;
else if (decompilerContext->shaderType == LatteConst::ShaderType::Pixel)
textureBindingPoint = i + CEMU_PS_TEX_UNIT_BASE;
textureBindingPoint = i + LATTE_CEMU_PS_TEX_UNIT_BASE;
decompilerContext->output->resourceMappingGL.textureUnitToBindingPoint[i] = textureBindingPoint;
}

View File

@ -75,10 +75,6 @@ private:
VkRenderingAttachmentInfoKHR m_vkColorAttachments[8];
VkRenderingAttachmentInfoKHR m_vkDepthAttachment;
VkRenderingAttachmentInfoKHR m_vkStencilAttachment;
//uint8 m_vkColorAttachmentsCount{0};
bool m_vkHasDepthAttachment{ false };
bool m_vkHasStencilAttachment{ false };
std::vector<class PipelineInfo*> m_usedByPipelines; // PipelineInfo objects which use this renderpass/framebuffer
};

View File

@ -513,15 +513,15 @@ uint64 VulkanRenderer::GetDescriptorSetStateHash(LatteDecompilerShader* shader)
switch (shader->shaderType)
{
case LatteConst::ShaderType::Vertex:
hostTextureUnit += CEMU_VS_TEX_UNIT_BASE;
hostTextureUnit += LATTE_CEMU_VS_TEX_UNIT_BASE;
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_VS;
break;
case LatteConst::ShaderType::Pixel:
hostTextureUnit += CEMU_PS_TEX_UNIT_BASE;
hostTextureUnit += LATTE_CEMU_PS_TEX_UNIT_BASE;
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_PS;
break;
case LatteConst::ShaderType::Geometry:
hostTextureUnit += CEMU_GS_TEX_UNIT_BASE;
hostTextureUnit += LATTE_CEMU_GS_TEX_UNIT_BASE;
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_GS;
break;
default:
@ -631,15 +631,15 @@ VkDescriptorSetInfo* VulkanRenderer::draw_getOrCreateDescriptorSet(PipelineInfo*
switch (shader->shaderType)
{
case LatteConst::ShaderType::Vertex:
hostTextureUnit += CEMU_VS_TEX_UNIT_BASE;
hostTextureUnit += LATTE_CEMU_VS_TEX_UNIT_BASE;
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_VS;
break;
case LatteConst::ShaderType::Pixel:
hostTextureUnit += CEMU_PS_TEX_UNIT_BASE;
hostTextureUnit += LATTE_CEMU_PS_TEX_UNIT_BASE;
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_PS;
break;
case LatteConst::ShaderType::Geometry:
hostTextureUnit += CEMU_GS_TEX_UNIT_BASE;
hostTextureUnit += LATTE_CEMU_GS_TEX_UNIT_BASE;
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_GS;
break;
default:

View File

@ -1,6 +1,5 @@
#include "Cafe/OS/common/OSCommon.h"
#include "Cafe/OS/libs/coreinit/coreinit_Thread.h"
#include "Cafe/OS/libs/coreinit/coreinit.h"
#include "iosu_ioctl.h"
#include "util/helpers/ringbuffer.h"
@ -23,7 +22,7 @@ sint32 iosuIoctl_pushAndWait(uint32 ioctlHandle, ioQueueEntry_t* ioQueueEntry)
}
__OSLockScheduler();
ioctlMutex.lock();
ioQueueEntry->ppcThread = coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance());
ioQueueEntry->ppcThread = coreinit::OSGetCurrentThread();
_ioctlRingbuffer[ioctlHandle].Push(ioQueueEntry);
ioctlMutex.unlock();

View File

@ -35,7 +35,7 @@
#include "Cafe/OS/libs/coreinit/coreinit_MEM_BlockHeap.h"
#include "Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.h"
coreinitData_t* gCoreinitData = NULL;
CoreinitSharedData* gCoreinitData = NULL;
sint32 ScoreStackTrace(OSThread_t* thread, MPTR sp)
{
@ -323,8 +323,8 @@ void coreinit_load()
coreinit::InitializeSysHeap();
// allocate coreinit global data
gCoreinitData = (coreinitData_t*)memory_getPointerFromVirtualOffset(coreinit_allocFromSysArea(sizeof(coreinitData_t), 32));
memset(gCoreinitData, 0x00, sizeof(coreinitData_t));
gCoreinitData = (CoreinitSharedData*)memory_getPointerFromVirtualOffset(coreinit_allocFromSysArea(sizeof(CoreinitSharedData), 32));
memset(gCoreinitData, 0x00, sizeof(CoreinitSharedData));
// coreinit weak links
osLib_addVirtualPointer("coreinit", "MEMAllocFromDefaultHeap", memory_getVirtualOffsetFromPointer(&gCoreinitData->MEMAllocFromDefaultHeap));

View File

@ -16,8 +16,7 @@ void coreinitAsyncCallback_addWithLock(MPTR functionMPTR, uint32 numParameters,
void coreinit_load();
// coreinit shared memory
typedef struct
struct CoreinitSharedData
{
MEMPTR<void> MEMAllocFromDefaultHeap;
MEMPTR<void> MEMAllocFromDefaultHeapEx;
@ -26,11 +25,9 @@ typedef struct
MPTR __cpp_exception_init_ptr;
MPTR __cpp_exception_cleanup_ptr;
MPTR __stdio_cleanup;
}coreinitData_t;
};
extern coreinitData_t* gCoreinitData;
#include "Cafe/OS/libs/coreinit/coreinit_Spinlock.h"
extern CoreinitSharedData* gCoreinitData;
// coreinit init
void coreinit_start(PPCInterpreter_t* hCPU);

View File

@ -71,7 +71,6 @@ sint32 MCP_GetSysProdSettings(MCPHANDLE mcpHandle, SysProdSettings* sysProdSetti
void coreinitExport_MCP_GetSysProdSettings(PPCInterpreter_t* hCPU)
{
cemuLog_logDebug(LogType::Force, "MCP_GetSysProdSettings(0x{:08x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4]);
sint32 result = MCP_GetSysProdSettings(hCPU->gpr[3], (SysProdSettings*)memory_getPointerFromVirtualOffset(hCPU->gpr[4]));
osLib_returnFromFunction(hCPU, result);
}

View File

@ -198,7 +198,7 @@ namespace coreinit
void threadEntry(PPCInterpreter_t* hCPU)
{
OSThread_t* currentThread = coreinitThread_getCurrentThreadDepr(hCPU);
OSThread_t* currentThread = coreinit::OSGetCurrentThread();
uint32 r3 = hCPU->gpr[3];
uint32 r4 = hCPU->gpr[4];
uint32 lr = hCPU->spr.LR;
@ -368,39 +368,38 @@ namespace coreinit
{
PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance();
hCPU->gpr[3] = exitValue;
OSThread_t* threadBE = coreinitThread_getCurrentThreadDepr(hCPU);
MPTR t = memory_getVirtualOffsetFromPointer(threadBE);
OSThread_t* currentThread = coreinit::OSGetCurrentThread();
// thread cleanup callback
if (!threadBE->cleanupCallback2.IsNull())
if (!currentThread->cleanupCallback2.IsNull())
{
threadBE->stateFlags = _swapEndianU32(_swapEndianU32(threadBE->stateFlags) | 0x00000001);
PPCCoreCallback(threadBE->cleanupCallback2.GetMPTR(), threadBE, _swapEndianU32(threadBE->stackEnd));
currentThread->stateFlags = _swapEndianU32(_swapEndianU32(currentThread->stateFlags) | 0x00000001);
PPCCoreCallback(currentThread->cleanupCallback2.GetMPTR(), currentThread, _swapEndianU32(currentThread->stackEnd));
}
// cpp exception cleanup
if (gCoreinitData->__cpp_exception_cleanup_ptr != 0 && threadBE->crt.eh_globals != nullptr)
if (gCoreinitData->__cpp_exception_cleanup_ptr != 0 && currentThread->crt.eh_globals != nullptr)
{
PPCCoreCallback(_swapEndianU32(gCoreinitData->__cpp_exception_cleanup_ptr), &threadBE->crt.eh_globals);
threadBE->crt.eh_globals = nullptr;
PPCCoreCallback(_swapEndianU32(gCoreinitData->__cpp_exception_cleanup_ptr), &currentThread->crt.eh_globals);
currentThread->crt.eh_globals = nullptr;
}
// set exit code
threadBE->exitValue = exitValue;
currentThread->exitValue = exitValue;
__OSLockScheduler();
// release held synchronization primitives
if (!threadBE->mutexQueue.isEmpty())
if (!currentThread->mutexQueue.isEmpty())
{
cemuLog_log(LogType::Force, "OSExitThread: Thread is holding mutexes");
while (true)
{
OSMutex* mutex = threadBE->mutexQueue.getFirst();
OSMutex* mutex = currentThread->mutexQueue.getFirst();
if (!mutex)
break;
if (mutex->owner != threadBE)
if (mutex->owner != currentThread)
{
cemuLog_log(LogType::Force, "OSExitThread: Thread is holding mutex which it doesn't own");
threadBE->mutexQueue.removeMutex(mutex);
currentThread->mutexQueue.removeMutex(mutex);
continue;
}
coreinit::OSUnlockMutexInternal(mutex);
@ -409,22 +408,22 @@ namespace coreinit
// todo - release all fast mutexes
// handle join queue
if (!threadBE->joinQueue.isEmpty())
threadBE->joinQueue.wakeupEntireWaitQueue(false);
if (!currentThread->joinQueue.isEmpty())
currentThread->joinQueue.wakeupEntireWaitQueue(false);
if ((threadBE->attr & 8) != 0)
if ((currentThread->attr & 8) != 0)
{
// deactivate thread since it is detached
threadBE->state = OSThread_t::THREAD_STATE::STATE_NONE;
coreinit::__OSDeactivateThread(threadBE);
currentThread->state = OSThread_t::THREAD_STATE::STATE_NONE;
coreinit::__OSDeactivateThread(currentThread);
// queue call to thread deallocator if set
if (!threadBE->deallocatorFunc.IsNull())
__OSQueueThreadDeallocation(threadBE);
if (!currentThread->deallocatorFunc.IsNull())
__OSQueueThreadDeallocation(currentThread);
}
else
{
// non-detached threads remain active
threadBE->state = OSThread_t::THREAD_STATE::STATE_MORIBUND;
currentThread->state = OSThread_t::THREAD_STATE::STATE_MORIBUND;
}
PPCCore_switchToSchedulerWithLock();
}
@ -1401,11 +1400,6 @@ void coreinit_resumeThread(OSThread_t* OSThreadBE, sint32 count)
__OSUnlockScheduler();
}
MPTR coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_t* hCPU)
{
return memory_getVirtualOffsetFromPointer(coreinit::__currentCoreThread[PPCInterpreter_getCoreIndex(hCPU)]);
}
OSThread_t* coreinitThread_getCurrentThreadDepr(PPCInterpreter_t* hCPU)
{
return coreinit::__currentCoreThread[PPCInterpreter_getCoreIndex(hCPU)];

View File

@ -486,8 +486,8 @@ struct OSThread_t
/* +0x668 */ MPTR tlsBlocksMPTR;
/* +0x66C */ MEMPTR<coreinit::OSFastMutex> waitingForFastMutex;
/* +0x670 */ coreinit::OSFastMutexLink contendedFastMutex; // link or queue?
/* +0x678 */ coreinit::OSFastMutexLink ownedFastMutex; // link or queue?
/* +0x670 */ coreinit::OSFastMutexLink contendedFastMutex;
/* +0x678 */ coreinit::OSFastMutexLink ownedFastMutex;
/* +0x680 */ uint32 padding680[28 / 4];
};
@ -615,7 +615,6 @@ namespace coreinit
void coreinit_suspendThread(OSThread_t* OSThreadBE, sint32 count = 1);
void coreinit_resumeThread(OSThread_t* OSThreadBE, sint32 count = 1);
MPTR coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_t* hCPU);
OSThread_t* coreinitThread_getCurrentThreadDepr(PPCInterpreter_t* hCPU);
extern MPTR activeThread[256];

View File

@ -7,11 +7,6 @@
#define GX2_ENABLE 1
#define GX2_DISABLE 0
// tex unit base for render backends
#define CEMU_PS_TEX_UNIT_BASE 0
#define CEMU_VS_TEX_UNIT_BASE 32
#define CEMU_GS_TEX_UNIT_BASE 64
#include "GX2_Surface.h"
// general

View File

@ -225,7 +225,7 @@ void CurlWorkerThread(CURL_t* curl, PPCConcurrentQueue<QueueMsg_t>* callerQueue,
uint32 SendOrderToWorker(CURL_t* curl, QueueOrder order, uint32 arg1 = 0)
{
OSThread_t* currentThread = coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance());
OSThread_t* currentThread = coreinit::OSGetCurrentThread();
curl->curlThread = currentThread;
// cemuLog_logDebug(LogType::Force, "CURRENTTHREAD: 0x{} -> {}",currentThread, order)
@ -707,7 +707,7 @@ void export_curl_easy_init(PPCInterpreter_t* hCPU)
memset(result.GetPtr(), 0, sizeof(CURL_t));
*result = {};
result->curl = curl_easy_init();
result->curlThread = coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance());
result->curlThread = coreinit::OSGetCurrentThread();
result->info_contentType = nullptr;
result->info_redirectUrl = nullptr;

View File

@ -283,7 +283,6 @@ void nnActExport_GetSimpleAddressIdEx(PPCInterpreter_t* hCPU)
void nnActExport_GetPrincipalId(PPCInterpreter_t* hCPU)
{
// return error for non-nnid accounts?
cemuLog_logDebug(LogType::Force, "nn_act.GetPrincipalId()");
uint32be principalId;
GetPrincipalIdEx(&principalId, iosu::act::ACT_SLOT_CURRENT);
osLib_returnFromFunction(hCPU, (uint32)principalId);

View File

@ -446,19 +446,20 @@ namespace save
SAVEStatus SAVEOpenFileOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParamsNew_t asyncParams;
asyncParams.ioMsgQueue = nullptr;
asyncParams.userCallback = PPCInterpreter_makeCallableExportDepr(AsyncCallback);
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetPointer();
SAVEStatus status = SAVEOpenFileOtherApplicationAsync(client, block, titleId, accountSlot, path, mode, hFile, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -680,19 +681,20 @@ namespace save
SAVEStatus SAVEGetFreeSpaceSize(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FSLargeSize* freeSize, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEGetFreeSpaceSizeAsync(client, block, accountSlot, freeSize, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -749,19 +751,20 @@ namespace save
SAVEStatus SAVERemove(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVERemoveAsync(client, block, accountSlot, path, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -862,19 +865,20 @@ namespace save
SAVEStatus SAVEOpenDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEOpenDirAsync(client, block, accountSlot, path, hDir, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -935,19 +939,20 @@ namespace save
SAVEStatus SAVEOpenDirOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEOpenDirOtherApplicationAsync(client, block, titleId, accountSlot, path, hDir, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -1071,19 +1076,20 @@ namespace save
SAVEStatus SAVEMakeDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEMakeDirAsync(client, block, accountSlot, path, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -1122,19 +1128,20 @@ namespace save
SAVEStatus SAVEOpenFile(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParamsNew_t asyncParams;
asyncParams.ioMsgQueue = nullptr;
asyncParams.userCallback = PPCInterpreter_makeCallableExportDepr(AsyncCallback);
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetPointer();
SAVEStatus status = SAVEOpenFileAsync(client, block, accountSlot, path, mode, hFile, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -1182,19 +1189,20 @@ namespace save
SAVEStatus SAVEGetStat(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEGetStatAsync(client, block, accountSlot, path, stat, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -1233,19 +1241,20 @@ namespace save
SAVEStatus SAVEGetStatOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEGetStatOtherApplicationAsync(client, block, titleId, accountSlot, path, stat, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -1422,19 +1431,20 @@ namespace save
SAVEStatus SAVEChangeDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEChangeDirAsync(client, block, accountSlot, path, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -1491,19 +1501,20 @@ namespace save
SAVEStatus SAVEFlushQuota(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEFlushQuotaAsync(client, block, accountSlot, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}

View File

@ -85,7 +85,7 @@ void nsysnetExport_socket_lib_finish(PPCInterpreter_t* hCPU)
uint32* __gh_errno_ptr()
{
OSThread_t* osThread = coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance());
OSThread_t* osThread = coreinit::OSGetCurrentThread();
return &osThread->context.error;
}

View File

@ -14,8 +14,6 @@
#include "gui/canvas/VulkanCanvas.h"
#include "Cafe/OS/libs/nn_nfp/nn_nfp.h"
#include "Cafe/OS/libs/swkbd/swkbd.h"
#include "Cafe/IOSU/legacy/iosu_crypto.h"
#include "Cafe/GameProfile/GameProfile.h"
#include "gui/debugger/DebuggerWindow2.h"
#include "util/helpers/helpers.h"
#include "config/CemuConfig.h"
@ -23,10 +21,8 @@
#include "util/ScreenSaver/ScreenSaver.h"
#include "gui/GeneralSettings2.h"
#include "gui/GraphicPacksWindow2.h"
#include "gui/GameProfileWindow.h"
#include "gui/CemuApp.h"
#include "gui/CemuUpdateWindow.h"
#include "gui/helpers/wxCustomData.h"
#include "gui/LoggingWindow.h"
#include "config/ActiveSettings.h"
#include "config/LaunchSettings.h"
@ -36,9 +32,7 @@
#include "gui/TitleManager.h"
#include "Cafe/CafeSystem.h"
#include "Cafe/TitleList/GameInfo.h"
#include <boost/algorithm/string.hpp>
#include "util/helpers/SystemException.h"
#include "gui/DownloadGraphicPacksWindow.h"
#include "gui/GettingStartedDialog.h"
@ -529,8 +523,8 @@ bool MainWindow::FileLoad(const fs::path launchPath, wxLaunchGameEvent::INITIATE
}
else //if (launchTitle.GetFormat() == TitleInfo::TitleDataFormat::INVALID_STRUCTURE )
{
// title is invalid, if its an RPX/ELF we can launch it directly
// otherwise its an error
// title is invalid, if it's an RPX/ELF we can launch it directly
// otherwise it's an error
CafeTitleFileType fileType = DetermineCafeSystemFileType(launchPath);
if (fileType == CafeTitleFileType::RPX || fileType == CafeTitleFileType::ELF)
{
@ -1875,7 +1869,7 @@ public:
{
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
lineSizer->Add(new wxStaticText(parent, -1, "zLib ("), 0);
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "http://www.zlib.net", "http://www.zlib.net"), 0);
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://www.zlib.net", "https://www.zlib.net"), 0);
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0);
sizer->Add(lineSizer);
}

View File

@ -86,7 +86,6 @@ private:
void OnDisconnect(wxCommandEvent& event);
void OnDlFilterCheckbox(wxCommandEvent& event);
void OnDlCheckboxShowUpdates(wxCommandEvent& event);
void SetConnected(bool state);

View File

@ -108,7 +108,6 @@ private:
[[nodiscard]] boost::optional<const TitleEntry&> GetTitleEntry(const fs::path& path) const;
[[nodiscard]] boost::optional<TitleEntry&> GetTitleEntry(const fs::path& path);
bool VerifyEntryFiles(TitleEntry& entry);
void OnConvertToCompressedFormat(uint64 titleId, uint64 rightClickedUID);
bool DeleteEntry(long index, const TitleEntry& entry);

View File

@ -256,7 +256,7 @@ void DisasmCtrl::DrawDisassemblyLine(wxDC& dc, const wxPoint& linePosition, MPTR
{
sint32 sImm = disasmInstr.operand[o].immS32;
if (disasmInstr.operand[o].immWidth == 16 && (sImm & 0x8000))
sImm |= 0xFFFF0000;
sImm |= (sint32)0xFFFF0000;
if ((sImm > -10 && sImm < 10) || forceDecDisplay)
string = wxString::Format("%d", sImm);

View File

@ -1,7 +1,5 @@
#pragma once
#include <atomic>
#if BOOST_OS_LINUX
#include "xcb/xproto.h"
#include <gdk/gdkkeysyms.h>