From ad2791a9cfb6cfff245045921d42ea3765ab2a35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 4 Mar 2025 16:04:11 +0100 Subject: [PATCH] More HLE logging cleanup --- Core/HLE/sceKernelMemory.cpp | 69 ++++++++---------- Core/HLE/sceKernelMutex.cpp | 80 +++++++++------------ Core/HLE/sceKernelSemaphore.cpp | 55 ++++++--------- Core/HLE/sceKernelThread.cpp | 89 +++++++++-------------- Core/HLE/sceKernelTime.cpp | 2 +- Core/HLE/sceMpeg.cpp | 120 ++++++++++++-------------------- Core/HLE/scePower.cpp | 2 +- Core/HLE/sceSas.cpp | 18 ++--- 8 files changed, 171 insertions(+), 264 deletions(-) diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index d7cc7de02d..7eb1053986 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -1598,8 +1598,7 @@ int sceKernelAllocateVpl(SceUID uid, u32 size, u32 addrPtr, u32 timeoutPtr) if (timeoutPtr != 0 && Memory::Read_U32(timeoutPtr) == 0) return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_WAIT_TIMEOUT); - if (vpl) - { + if (vpl) { SceUID threadID = __KernelGetCurThread(); HLEKernel::RemoveWaitingThread(vpl->waitingThreads, threadID); VplWaitingThread waiting = {threadID, addrPtr}; @@ -1613,7 +1612,7 @@ int sceKernelAllocateVpl(SceUID uid, u32 size, u32 addrPtr, u32 timeoutPtr) else if (error == 0 && !vpl->waitingThreads.empty()) return hleDelayResult(hleLogDebug(Log::sceKernel, error), "vpl allocated", 50); } - return error; + return hleLogDebugOrError(Log::sceKernel, error); } int sceKernelAllocateVplCB(SceUID uid, u32 size, u32 addrPtr, u32 timeoutPtr) @@ -1644,7 +1643,7 @@ int sceKernelAllocateVplCB(SceUID uid, u32 size, u32 addrPtr, u32 timeoutPtr) else if (error == 0 && !vpl->waitingThreads.empty()) return hleDelayResult(hleLogDebug(Log::sceKernel, error), "vpl allocated", 50); } - return error; + return hleLogDebugOrError(Log::sceKernel, error); } int sceKernelTryAllocateVpl(SceUID uid, u32 size, u32 addrPtr) @@ -1662,7 +1661,9 @@ int sceKernelFreeVpl(SceUID uid, u32 addr) { VERBOSE_LOG(Log::sceKernel, "sceKernelFreeVpl(%i, %08x)", uid, addr); u32 error; VPL *vpl = kernelObjects.Get(uid, error); - if (vpl) { + if (!vpl) { + return hleLogError(Log::sceKernel, error, "invalid vpl"); + } else { bool freed; // Free using the header for newer vpls (not old savestates.) if (vpl->header.IsValid()) { @@ -1690,13 +1691,10 @@ retry: hleReSchedule("vpl freed"); } - return 0; + return hleNoLog(0); } else { - WARN_LOG(Log::sceKernel, "%08x=sceKernelFreeVpl(%i, %08x): Unable to free", SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK, uid, addr); - return SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK; + return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK, "unable to free"); } - } else { - return error; } } @@ -1704,8 +1702,9 @@ int sceKernelCancelVpl(SceUID uid, u32 numWaitThreadsPtr) { u32 error; VPL *vpl = kernelObjects.Get(uid, error); - if (vpl) - { + if (!vpl) { + return hleLogError(Log::sceKernel, error, "invalid vpl"); + } else { vpl->nv.numWaitThreads = (int) vpl->waitingThreads.size(); if (Memory::IsValidAddress(numWaitThreadsPtr)) Memory::Write_U32(vpl->nv.numWaitThreads, numWaitThreadsPtr); @@ -1716,11 +1715,6 @@ int sceKernelCancelVpl(SceUID uid, u32 numWaitThreadsPtr) return hleLogDebug(Log::sceKernel, 0); } - else - { - DEBUG_LOG(Log::sceKernel, "sceKernelCancelVpl(%i, %08x): invalid vpl", uid, numWaitThreadsPtr); - return error; - } } int sceKernelReferVplStatus(SceUID uid, u32 infoPtr) { @@ -1745,22 +1739,23 @@ int sceKernelReferVplStatus(SceUID uid, u32 infoPtr) { } } +// this is an unnamed hle function static u32 AllocMemoryBlock(const char *pname, u32 type, u32 size, u32 paramsAddr) { if (Memory::IsValidAddress(paramsAddr) && Memory::Read_U32(paramsAddr) != 4) { ERROR_LOG_REPORT(Log::sceKernel, "AllocMemoryBlock(%s): unsupported params size %d", pname, Memory::Read_U32(paramsAddr)); - return SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT; + return hleNoLog(SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT); } if (type != PSP_SMEM_High && type != PSP_SMEM_Low) { ERROR_LOG_REPORT(Log::sceKernel, "AllocMemoryBlock(%s): unsupported type %d", pname, type); - return SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCKTYPE; + return hleNoLog(SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCKTYPE); } if (size == 0) { WARN_LOG_REPORT(Log::sceKernel, "AllocMemoryBlock(%s): invalid size %x", pname, size); - return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED; + return hleNoLog(SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED); } - if (pname == NULL) { + if (!pname) { ERROR_LOG_REPORT(Log::sceKernel, "AllocMemoryBlock(): NULL name"); - return SCE_KERNEL_ERROR_ERROR; + return hleNoLog(SCE_KERNEL_ERROR_ERROR); } PartitionMemoryBlock *block = new PartitionMemoryBlock(&userMemory, pname, size, (MemblockType)type, 0); @@ -1769,47 +1764,41 @@ static u32 AllocMemoryBlock(const char *pname, u32 type, u32 size, u32 paramsAdd return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED, "allocation failed"); } SceUID uid = kernelObjects.Create(block); - - INFO_LOG(Log::sceKernel,"%08x=AllocMemoryBlock(SysMemUserForUser_FE707FDF)(%s, %i, %08x, %08x)", uid, pname, type, size, paramsAddr); - return uid; + return hleLogDebugOrError(Log::sceKernel, uid, "SysMemUserForUser_FE707FDF"); } +// this is an unnamed hle function static u32 FreeMemoryBlock(u32 uid) { - INFO_LOG(Log::sceKernel, "FreeMemoryBlock(%08x)", uid); - return kernelObjects.Destroy(uid); + return hleLogDebugOrError(Log::sceKernel, kernelObjects.Destroy(uid)); } +// this is an unnamed hle function static u32 GetMemoryBlockPtr(u32 uid, u32 addr) { u32 error; PartitionMemoryBlock *block = kernelObjects.Get(uid, error); - if (block) - { - INFO_LOG(Log::sceKernel, "GetMemoryBlockPtr(%08x, %08x) = %08x", uid, addr, block->address); + if (block) { Memory::Write_U32(block->address, addr); - return 0; - } - else - { - ERROR_LOG(Log::sceKernel, "GetMemoryBlockPtr(%08x, %08x) failed", uid, addr); - return 0; + return hleLogInfo(Log::sceKernel, 0, "block address: %08x", block->address); + } else { + return hleLogError(Log::sceKernel, 0, "failed"); } } +// this is an unnamed hle function static u32 SysMemUserForUser_D8DE5C1E() { // Called by Evangelion Jo and return 0 here to go in-game. - ERROR_LOG(Log::sceKernel,"UNIMPL SysMemUserForUser_D8DE5C1E()"); - return 0; + return hleLogError(Log::sceKernel, 0, "UNIMPL"); } static u32 SysMemUserForUser_ACBD88CA() { ERROR_LOG_REPORT_ONCE(SysMemUserForUser_ACBD88CA, Log::sceKernel, "UNIMPL SysMemUserForUser_ACBD88CA()"); - return 0; + return hleNoLog(0); } static u32 SysMemUserForUser_945E45DA() { // Called by Evangelion Jo and expected return 0 here. ERROR_LOG_REPORT_ONCE(SysMemUserForUser945E45DA, Log::sceKernel, "UNIMPL SysMemUserForUser_945E45DA()"); - return 0; + return hleNoLog(0); } enum diff --git a/Core/HLE/sceKernelMutex.cpp b/Core/HLE/sceKernelMutex.cpp index a5cc4e2c16..80fc48db02 100644 --- a/Core/HLE/sceKernelMutex.cpp +++ b/Core/HLE/sceKernelMutex.cpp @@ -902,11 +902,8 @@ void __KernelLwMutexEndCallback(SceUID threadID, SceUID prevCallbackId) int sceKernelTryLockLwMutex(u32 workareaPtr, int count) { - DEBUG_LOG(Log::sceKernel, "sceKernelTryLockLwMutex(%08x, %i)", workareaPtr, count); - if (!Memory::IsValidAddress(workareaPtr)) { - ERROR_LOG(Log::sceKernel, "Bad workarea pointer for LwMutex"); - return SCE_KERNEL_ERROR_ACCESS_ERROR; + return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ACCESS_ERROR, "Bad workarea pointer for LwMutex"); } auto workarea = PSPPointer::Create(workareaPtr); @@ -914,21 +911,18 @@ int sceKernelTryLockLwMutex(u32 workareaPtr, int count) u32 error = 0; if (__KernelLockLwMutex(workarea, count, error)) - return 0; - // Unlike sceKernelTryLockLwMutex_600, this always returns the same error. + return hleLogDebug(Log::sceKernel, 0); else if (error) - return PSP_MUTEX_ERROR_TRYLOCK_FAILED; + // Unlike sceKernelTryLockLwMutex_600, this always returns the same error. + return hleLogDebug(Log::sceKernel, PSP_MUTEX_ERROR_TRYLOCK_FAILED); else - return PSP_MUTEX_ERROR_TRYLOCK_FAILED; + return hleLogDebug(Log::sceKernel, PSP_MUTEX_ERROR_TRYLOCK_FAILED); } int sceKernelTryLockLwMutex_600(u32 workareaPtr, int count) { - DEBUG_LOG(Log::sceKernel, "sceKernelTryLockLwMutex_600(%08x, %i)", workareaPtr, count); - if (!Memory::IsValidAddress(workareaPtr)) { - ERROR_LOG(Log::sceKernel, "Bad workarea pointer for LwMutex"); - return SCE_KERNEL_ERROR_ACCESS_ERROR; + return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ACCESS_ERROR, "Bad workarea pointer for LwMutex"); } auto workarea = PSPPointer::Create(workareaPtr); @@ -936,20 +930,17 @@ int sceKernelTryLockLwMutex_600(u32 workareaPtr, int count) u32 error = 0; if (__KernelLockLwMutex(workarea, count, error)) - return 0; + return hleLogDebug(Log::sceKernel, 0); else if (error) - return error; + return hleLogDebug(Log::sceKernel, error); else - return PSP_LWMUTEX_ERROR_TRYLOCK_FAILED; + return hleLogDebug(Log::sceKernel, PSP_LWMUTEX_ERROR_TRYLOCK_FAILED); } int sceKernelLockLwMutex(u32 workareaPtr, int count, u32 timeoutPtr) { - VERBOSE_LOG(Log::sceKernel, "sceKernelLockLwMutex(%08x, %i, %08x)", workareaPtr, count, timeoutPtr); - if (!Memory::IsValidAddress(workareaPtr)) { - ERROR_LOG(Log::sceKernel, "Bad workarea pointer for LwMutex"); - return SCE_KERNEL_ERROR_ACCESS_ERROR; + return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ACCESS_ERROR, "Bad workarea pointer for LwMutex"); } auto workarea = PSPPointer::Create(workareaPtr); @@ -957,14 +948,15 @@ int sceKernelLockLwMutex(u32 workareaPtr, int count, u32 timeoutPtr) u32 error = 0; if (__KernelLockLwMutex(workarea, count, error)) - return 0; + return hleLogVerbose(Log::sceKernel, 0); else if (error) - return error; + return hleLogVerbose(Log::sceKernel, error); else { LwMutex *mutex = kernelObjects.Get(workarea->uid, error); - if (mutex) - { + if (!mutex) { + return hleLogError(Log::sceKernel, error); + } else { SceUID threadID = __KernelGetCurThread(); // May be in a tight loop timing out (where we don't remove from waitingThreads yet), don't want to add duplicates. if (std::find(mutex->waitingThreads.begin(), mutex->waitingThreads.end(), threadID) == mutex->waitingThreads.end()) @@ -973,10 +965,8 @@ int sceKernelLockLwMutex(u32 workareaPtr, int count, u32 timeoutPtr) __KernelWaitCurThread(WAITTYPE_LWMUTEX, workarea->uid, count, timeoutPtr, false, "lwmutex waited"); // Return value will be overwritten by wait. - return 0; + return hleLogVerbose(Log::sceKernel, 0); } - else - return error; } } @@ -985,8 +975,7 @@ int sceKernelLockLwMutexCB(u32 workareaPtr, int count, u32 timeoutPtr) VERBOSE_LOG(Log::sceKernel, "sceKernelLockLwMutexCB(%08x, %i, %08x)", workareaPtr, count, timeoutPtr); if (!Memory::IsValidAddress(workareaPtr)) { - ERROR_LOG(Log::sceKernel, "Bad workarea pointer for LwMutex"); - return SCE_KERNEL_ERROR_ACCESS_ERROR; + return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ACCESS_ERROR, "Bad workarea pointer for LwMutex"); } auto workarea = PSPPointer::Create(workareaPtr); @@ -994,14 +983,15 @@ int sceKernelLockLwMutexCB(u32 workareaPtr, int count, u32 timeoutPtr) u32 error = 0; if (__KernelLockLwMutex(workarea, count, error)) - return 0; + return hleLogVerbose(Log::sceKernel, 0); else if (error) - return error; + return hleLogVerbose(Log::sceKernel, error); else { LwMutex *mutex = kernelObjects.Get(workarea->uid, error); - if (mutex) - { + if (!mutex) { + return hleLogError(Log::sceKernel, error); + } else { SceUID threadID = __KernelGetCurThread(); // May be in a tight loop timing out (where we don't remove from waitingThreads yet), don't want to add duplicates. if (std::find(mutex->waitingThreads.begin(), mutex->waitingThreads.end(), threadID) == mutex->waitingThreads.end()) @@ -1010,35 +1000,32 @@ int sceKernelLockLwMutexCB(u32 workareaPtr, int count, u32 timeoutPtr) __KernelWaitCurThread(WAITTYPE_LWMUTEX, workarea->uid, count, timeoutPtr, true, "lwmutex cb waited"); // Return value will be overwritten by wait. - return 0; + return hleLogVerbose(Log::sceKernel, 0); } - else - return error; } } int sceKernelUnlockLwMutex(u32 workareaPtr, int count) { - VERBOSE_LOG(Log::sceKernel, "sceKernelUnlockLwMutex(%08x, %i)", workareaPtr, count); - if (!Memory::IsValidAddress(workareaPtr)) { - ERROR_LOG(Log::sceKernel, "Bad workarea pointer for LwMutex"); - return SCE_KERNEL_ERROR_ACCESS_ERROR; + return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ACCESS_ERROR, "Bad workarea pointer for LwMutex"); } auto workarea = PSPPointer::Create(workareaPtr); hleEatCycles(28); if (workarea->uid == -1) - return PSP_LWMUTEX_ERROR_NO_SUCH_LWMUTEX; + return hleLogError(Log::sceKernel, PSP_LWMUTEX_ERROR_NO_SUCH_LWMUTEX); else if (count <= 0) - return SCE_KERNEL_ERROR_ILLEGAL_COUNT; + return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_COUNT); else if ((workarea->attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE) == 0 && count > 1) - return SCE_KERNEL_ERROR_ILLEGAL_COUNT; + return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_COUNT); else if (workarea->lockLevel == 0 || workarea->lockThread != __KernelGetCurThread()) - return PSP_LWMUTEX_ERROR_NOT_LOCKED; + return hleLogDebug(Log::sceKernel, PSP_LWMUTEX_ERROR_NOT_LOCKED); else if (workarea->lockLevel < count) - return PSP_LWMUTEX_ERROR_UNLOCK_UNDERFLOW; + return hleLogDebug(Log::sceKernel, PSP_LWMUTEX_ERROR_UNLOCK_UNDERFLOW); + + VERBOSE_LOG(Log::sceKernel, "sceKernelUnlockLwMutex(%08x, %i)", workareaPtr, count); workarea->lockLevel -= count; @@ -1049,9 +1036,10 @@ int sceKernelUnlockLwMutex(u32 workareaPtr, int count) hleReSchedule("lwmutex unlocked"); } - return 0; + return hleNoLog(0); } +// Logs like a HLE function static int __KernelReferLwMutexStatus(SceUID uid, u32 infoPtr) { u32 error; LwMutex *m = kernelObjects.Get(uid, error); @@ -1086,7 +1074,7 @@ int sceKernelReferLwMutexStatusByID(SceUID uid, u32 infoPtr) { int sceKernelReferLwMutexStatus(u32 workareaPtr, u32 infoPtr) { auto workarea = PSPPointer::Create(workareaPtr); if (!workarea.IsValid()) { - return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ACCESS_ERROR, "bad workarea pointer for LwMutex"); + return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ACCESS_ERROR, "Bad workarea pointer for LwMutex"); } return __KernelReferLwMutexStatus(workarea->uid, infoPtr); diff --git a/Core/HLE/sceKernelSemaphore.cpp b/Core/HLE/sceKernelSemaphore.cpp index b3f4b4829e..193ea5a561 100644 --- a/Core/HLE/sceKernelSemaphore.cpp +++ b/Core/HLE/sceKernelSemaphore.cpp @@ -172,12 +172,11 @@ int sceKernelCancelSema(SceUID id, int newCount, u32 numWaitThreadsPtr) { u32 error; PSPSemaphore *s = kernelObjects.Get(id, error); - if (s) - { - if (newCount > s->ns.maxCount) - { - DEBUG_LOG(Log::sceKernel, "sceKernelCancelSema(%i, %i, %08x): invalid count", id, newCount, numWaitThreadsPtr); - return SCE_KERNEL_ERROR_ILLEGAL_COUNT; + if (!s) { + return hleLogError(Log::sceKernel, error, "bad sema id"); + } else { + if (newCount > s->ns.maxCount) { + return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_COUNT); } DEBUG_LOG(Log::sceKernel, "sceKernelCancelSema(%i, %i, %08x)", id, newCount, numWaitThreadsPtr); @@ -194,11 +193,7 @@ int sceKernelCancelSema(SceUID id, int newCount, u32 numWaitThreadsPtr) if (__KernelClearSemaThreads(s, SCE_KERNEL_ERROR_WAIT_CANCEL)) hleReSchedule("semaphore canceled"); - return 0; - } - else - { - return hleLogError(Log::sceKernel, error, "invalid semaphore"); + return hleNoLog(0); } } @@ -234,31 +229,28 @@ int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32 return hleLogDebug(Log::sceKernel, id); } -int sceKernelDeleteSema(SceUID id) -{ +int sceKernelDeleteSema(SceUID id) { u32 error; PSPSemaphore *s = kernelObjects.Get(id, error); - if (s) - { + if (!s) { + return hleLogError(Log::sceKernel, error, "bad sema id"); + } else { DEBUG_LOG(Log::sceKernel, "sceKernelDeleteSema(%i)", id); bool wokeThreads = __KernelClearSemaThreads(s, SCE_KERNEL_ERROR_WAIT_DELETE); if (wokeThreads) hleReSchedule("semaphore deleted"); - return kernelObjects.Destroy(id); - } - else - { - DEBUG_LOG(Log::sceKernel, "sceKernelDeleteSema(%i): invalid semaphore", id); - return error; + return hleNoLog(kernelObjects.Destroy(id)); } } int sceKernelReferSemaStatus(SceUID id, u32 infoPtr) { u32 error; PSPSemaphore *s = kernelObjects.Get(id, error); - if (s) { + if (!s) { + return hleLogError(Log::sceKernel, error, "bad sema id"); + } else { auto info = PSPPointer::Create(infoPtr); if (!info.IsValid()) return hleLogWarning(Log::sceKernel, -1, "invalid pointer"); @@ -271,8 +263,6 @@ int sceKernelReferSemaStatus(SceUID id, u32 infoPtr) { info.NotifyWrite("SemaStatus"); } return hleLogDebug(Log::sceKernel, 0); - } else { - return hleLogError(Log::sceKernel, error); } } @@ -280,7 +270,7 @@ int sceKernelSignalSema(SceUID id, int signal) { u32 error; PSPSemaphore *s = kernelObjects.Get(id, error); if (!s) { - return hleLogError(Log::sceKernel, error); + return hleLogError(Log::sceKernel, error, "bad sema id"); } else { if (s->ns.currentCount + signal - (int) s->waitingThreads.size() > s->ns.maxCount) { return hleLogDebug(Log::sceKernel, SCE_KERNEL_ERROR_SEMA_OVF, "overflow at %d", s->ns.currentCount); @@ -355,17 +345,17 @@ static int __KernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr, bool pro u32 error; PSPSemaphore *s = kernelObjects.Get(id, error); - if (s) - { + if (!s) { + return error; + } else { if (wantedCount > s->ns.maxCount) return SCE_KERNEL_ERROR_ILLEGAL_COUNT; // If there are any callbacks, we always wait, and wake after the callbacks. bool hasCallbacks = processCallbacks && __KernelCurHasReadyCallbacks(); - if (s->ns.currentCount >= wantedCount && s->waitingThreads.size() == 0 && !hasCallbacks) + if (s->ns.currentCount >= wantedCount && s->waitingThreads.size() == 0 && !hasCallbacks) { s->ns.currentCount -= wantedCount; - else - { + } else { SceUID threadID = __KernelGetCurThread(); // May be in a tight loop timing out (where we don't remove from waitingThreads yet), don't want to add duplicates. if (std::find(s->waitingThreads.begin(), s->waitingThreads.end(), threadID) == s->waitingThreads.end()) @@ -376,8 +366,6 @@ static int __KernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr, bool pro return 0; } - else - return error; } int sceKernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr) { @@ -406,7 +394,8 @@ int sceKernelPollSema(SceUID id, int wantedCount) { s->ns.currentCount -= wantedCount; return hleLogDebug(Log::sceKernel, 0); } else { - return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_SEMA_ZERO); + // this is OK. + return hleLogDebug(Log::sceKernel, SCE_KERNEL_ERROR_SEMA_ZERO); } } diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index ffaac05380..28de1050d1 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -2127,31 +2127,26 @@ int sceKernelStartThread(SceUID threadToStartID, int argSize, u32 argBlockPtr) { return hleLogDebugOrError(Log::sceKernel, retval); } -int sceKernelGetThreadStackFreeSize(SceUID threadID) -{ - DEBUG_LOG(Log::sceKernel, "sceKernelGetThreadStackFreeSize(%i)", threadID); - +int sceKernelGetThreadStackFreeSize(SceUID threadID) { if (threadID == 0) threadID = __KernelGetCurThread(); u32 error; PSPThread *thread = kernelObjects.Get(threadID, error); - if (thread == nullptr) { - ERROR_LOG(Log::sceKernel, "sceKernelGetThreadStackFreeSize: invalid thread id %i", threadID); - return error; + if (!thread) { + return hleLogError(Log::sceKernel, error, "invalid thread id"); } // Scan the stack for 0xFF, starting after 0x10 (the thread id is written there.) // Obviously this doesn't work great if PSP_THREAD_ATTR_NO_FILLSTACK is used. int sz = 0; - for (u32 offset = 0x10; offset < thread->nt.stackSize; ++offset) - { + for (u32 offset = 0x10; offset < thread->nt.stackSize; ++offset) { if (Memory::Read_U8(thread->currentStack.start + offset) != 0xFF) break; sz++; } - return sz & ~3; + return hleLogDebug(Log::sceKernel, sz & ~3); } void __KernelReturnFromThread() @@ -2171,6 +2166,7 @@ void __KernelReturnFromThread() __KernelThreadTriggerEvent((thread->nt.attr & PSP_THREAD_ATTR_KERNEL) != 0, thread->GetUID(), THREADEVENT_EXIT); // The stack will be deallocated when the thread is deleted. + return hleNoLogVoid(); } int sceKernelExitThread(int exitStatus) { @@ -2191,7 +2187,7 @@ int sceKernelExitThread(int exitStatus) { __KernelThreadTriggerEvent((thread->nt.attr & PSP_THREAD_ATTR_KERNEL) != 0, thread->GetUID(), THREADEVENT_EXIT); // The stack will be deallocated when the thread is deleted. - return 0; + return hleNoLog(0); } void _sceKernelExitThread(int exitStatus) { @@ -2207,6 +2203,7 @@ void _sceKernelExitThread(int exitStatus) { __KernelThreadTriggerEvent((thread->nt.attr & PSP_THREAD_ATTR_KERNEL) != 0, thread->GetUID(), THREADEVENT_EXIT); // The stack will be deallocated when the thread is deleted. + hleNoLogVoid(); } int sceKernelExitDeleteThread(int exitStatus) { @@ -2225,33 +2222,26 @@ int sceKernelExitDeleteThread(int exitStatus) { // TODO: This should trigger ON the thread when it exits. __KernelThreadTriggerEvent((thread_attr & PSP_THREAD_ATTR_KERNEL) != 0, uid, THREADEVENT_EXIT); - } - else + } else { ERROR_LOG_REPORT(Log::sceKernel, "sceKernelExitDeleteThread(%d) ERROR - could not find myself!", exitStatus); + } return hleNoLog(0); } -u32 sceKernelSuspendDispatchThread() -{ - if (!__InterruptsEnabled()) - { - DEBUG_LOG(Log::sceKernel, "sceKernelSuspendDispatchThread(): interrupts disabled"); - return SCE_KERNEL_ERROR_CPUDI; +u32 sceKernelSuspendDispatchThread() { + if (!__InterruptsEnabled()) { + return hleLogDebug(Log::sceKernel, SCE_KERNEL_ERROR_CPUDI, "interrupts disabled"); } u32 oldDispatchEnabled = dispatchEnabled; dispatchEnabled = false; - DEBUG_LOG(Log::sceKernel, "%i=sceKernelSuspendDispatchThread()", oldDispatchEnabled); hleEatCycles(940); - return oldDispatchEnabled; + return hleLogDebug(Log::sceKernel, oldDispatchEnabled); } -u32 sceKernelResumeDispatchThread(u32 enabled) -{ - if (!__InterruptsEnabled()) - { - DEBUG_LOG(Log::sceKernel, "sceKernelResumeDispatchThread(%i): interrupts disabled", enabled); - return SCE_KERNEL_ERROR_CPUDI; +u32 sceKernelResumeDispatchThread(u32 enabled) { + if (!__InterruptsEnabled()) { + return hleLogDebug(Log::sceKernel, SCE_KERNEL_ERROR_CPUDI, "interrupts disabled"); } u32 oldDispatchEnabled = dispatchEnabled; @@ -2259,11 +2249,10 @@ u32 sceKernelResumeDispatchThread(u32 enabled) DEBUG_LOG(Log::sceKernel, "sceKernelResumeDispatchThread(%i) - from %i", enabled, oldDispatchEnabled); hleReSchedule("dispatch resumed"); hleEatCycles(940); - return 0; + return hleNoLog(0); } -bool __KernelIsDispatchEnabled() -{ +bool __KernelIsDispatchEnabled() { // Dispatch can never be enabled when interrupts are disabled. return dispatchEnabled && __InterruptsEnabled(); } @@ -2303,40 +2292,35 @@ int sceKernelRotateThreadReadyQueue(int priority) { int sceKernelDeleteThread(int threadID) { if (threadID == 0 || threadID == currentThread) { - ERROR_LOG(Log::sceKernel, "sceKernelDeleteThread(%i): cannot delete current thread", threadID); - return SCE_KERNEL_ERROR_NOT_DORMANT; + return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_NOT_DORMANT, "cannot delete current thread"); } u32 error; PSPThread *t = kernelObjects.Get(threadID, error); - if (t) { + if (!t) { + return hleLogError(Log::sceKernel, error, "bad thread id"); + } else { if (!t->isStopped()) { - ERROR_LOG(Log::sceKernel, "sceKernelDeleteThread(%i): thread not dormant", threadID); - return SCE_KERNEL_ERROR_NOT_DORMANT; + return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_NOT_DORMANT); } - DEBUG_LOG(Log::sceKernel, "sceKernelDeleteThread(%i)", threadID); - return __KernelDeleteThread(threadID, SCE_KERNEL_ERROR_THREAD_TERMINATED, "thread deleted"); - } else { - ERROR_LOG(Log::sceKernel, "sceKernelDeleteThread(%i): thread doesn't exist", threadID); - return error; + return hleLogDebug(Log::sceKernel, __KernelDeleteThread(threadID, SCE_KERNEL_ERROR_THREAD_TERMINATED, "thread deleted")); } } -int sceKernelTerminateDeleteThread(int threadID) -{ - if (threadID == 0 || threadID == currentThread) - { - ERROR_LOG(Log::sceKernel, "sceKernelTerminateDeleteThread(%i): cannot terminate current thread", threadID); - return SCE_KERNEL_ERROR_ILLEGAL_THID; +int sceKernelTerminateDeleteThread(int threadID) { + if (threadID == 0 || threadID == currentThread) { + return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_THID, "cannot terminate current thread"); } - if (!__KernelIsDispatchEnabled() && sceKernelGetCompiledSdkVersion() >= 0x03080000) + if (!__KernelIsDispatchEnabled() && sceKernelGetCompiledSdkVersion() >= 0x03080000) { return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_CAN_NOT_WAIT); + } u32 error; PSPThread *t = kernelObjects.Get(threadID, error); - if (t) - { + if (!t) { + return hleLogError(Log::sceKernel, error, "bad thread id"); + } else { bool wasStopped = t->isStopped(); uint32_t attr = t->nt.attr; uint32_t uid = t->GetUID(); @@ -2350,12 +2334,7 @@ int sceKernelTerminateDeleteThread(int threadID) __KernelThreadTriggerEvent((attr & PSP_THREAD_ATTR_KERNEL) != 0, uid, THREADEVENT_EXIT); } - return error; - } - else - { - ERROR_LOG(Log::sceKernel, "sceKernelTerminateDeleteThread(%i): thread doesn't exist", threadID); - return error; + return hleNoLog(error); } } diff --git a/Core/HLE/sceKernelTime.cpp b/Core/HLE/sceKernelTime.cpp index 7b2e6f0f19..a15c981062 100644 --- a/Core/HLE/sceKernelTime.cpp +++ b/Core/HLE/sceKernelTime.cpp @@ -74,7 +74,7 @@ int sceKernelGetSystemTime(u32 sysclockPtr) VERBOSE_LOG(Log::sceKernel, "sceKernelGetSystemTime(out:%16llx)", t); hleEatCycles(265); hleReSchedule("system time"); - return 0; + return hleNoLog(0); } u32 sceKernelGetSystemTimeLow() diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index c598828ed8..f7e412413c 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -472,36 +472,33 @@ static u32 __MpegRingbufferQueryMemSize(int packets) { static u32 sceMpegRingbufferQueryMemSize(int packets) { u32 size = __MpegRingbufferQueryMemSize(packets); - DEBUG_LOG(Log::ME, "%i = sceMpegRingbufferQueryMemSize(%i)", size, packets); - return size; + return hleLogDebug(Log::ME, size); } - static u32 sceMpegRingbufferConstruct(u32 ringbufferAddr, u32 numPackets, u32 data, u32 size, u32 callbackAddr, u32 callbackArg) { if (!Memory::IsValidAddress(ringbufferAddr)) { ERROR_LOG_REPORT(Log::ME, "sceMpegRingbufferConstruct(%08x, %i, %08x, %08x, %08x, %08x): bad ringbuffer, should crash", ringbufferAddr, numPackets, data, size, callbackAddr, callbackArg); - return SCE_KERNEL_ERROR_ILLEGAL_ADDRESS; + return hleNoLog(SCE_KERNEL_ERROR_ILLEGAL_ADDRESS); } if ((int)size < 0) { ERROR_LOG_REPORT(Log::ME, "sceMpegRingbufferConstruct(%08x, %i, %08x, %08x, %08x, %08x): invalid size", ringbufferAddr, numPackets, data, size, callbackAddr, callbackArg); - return ERROR_MPEG_NO_MEMORY; + return hleNoLog(ERROR_MPEG_NO_MEMORY); } if (__MpegRingbufferQueryMemSize(numPackets) > size) { if (numPackets < 0x00100000) { ERROR_LOG_REPORT(Log::ME, "sceMpegRingbufferConstruct(%08x, %i, %08x, %08x, %08x, %08x): too many packets for buffer", ringbufferAddr, numPackets, data, size, callbackAddr, callbackArg); - return ERROR_MPEG_NO_MEMORY; + return hleNoLog(ERROR_MPEG_NO_MEMORY); } else { // The PSP's firmware allows some cases here, due to a bug in its validation. ERROR_LOG_REPORT(Log::ME, "sceMpegRingbufferConstruct(%08x, %i, %08x, %08x, %08x, %08x): too many packets for buffer, bogus size", ringbufferAddr, numPackets, data, size, callbackAddr, callbackArg); } } - DEBUG_LOG(Log::ME, "sceMpegRingbufferConstruct(%08x, %i, %08x, %08x, %08x, %08x)", ringbufferAddr, numPackets, data, size, callbackAddr, callbackArg); auto ring = PSPPointer::Create(ringbufferAddr); InitRingbuffer(ring, numPackets, data, size, callbackAddr, callbackArg); - return 0; + return hleLogDebug(Log::ME, 0); } static u32 MpegRequiredMem() { @@ -511,16 +508,13 @@ static u32 MpegRequiredMem() { return MPEG_MEMSIZE_0105; } -static u32 sceMpegCreate(u32 mpegAddr, u32 dataPtr, u32 size, u32 ringbufferAddr, u32 frameWidth, u32 mode, u32 ddrTop) -{ +static u32 sceMpegCreate(u32 mpegAddr, u32 dataPtr, u32 size, u32 ringbufferAddr, u32 frameWidth, u32 mode, u32 ddrTop) { if (!Memory::IsValidAddress(mpegAddr)) { - WARN_LOG(Log::ME, "sceMpegCreate(%08x, %08x, %i, %08x, %i, %i, %i): invalid addresses", mpegAddr, dataPtr, size, ringbufferAddr, frameWidth, mode, ddrTop); - return -1; + return hleLogWarning(Log::ME, -1, "invalid addresses"); } if (size < MpegRequiredMem()) { - WARN_LOG(Log::ME, "ERROR_MPEG_NO_MEMORY=sceMpegCreate(%08x, %08x, %i, %08x, %i, %i, %i)", mpegAddr, dataPtr, size, ringbufferAddr, frameWidth, mode, ddrTop); - return ERROR_MPEG_NO_MEMORY; + return hleLogWarning(Log::ME, ERROR_MPEG_NO_MEMORY); } auto ringbuffer = PSPPointer::Create(ringbufferAddr); @@ -579,12 +573,10 @@ static u32 sceMpegCreate(u32 mpegAddr, u32 dataPtr, u32 size, u32 ringbufferAddr return hleDelayResult(hleLogInfo(Log::ME, 0), "mpeg create", 29000); } -static int sceMpegDelete(u32 mpeg) -{ +static int sceMpegDelete(u32 mpeg) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - WARN_LOG(Log::ME, "sceMpegDelete(%08x): bad mpeg handle", mpeg); - return -1; + return hleLogWarning(Log::ME, -1, "bad mpeg handle"); } delete ctx; @@ -597,14 +589,12 @@ static int sceMpegDelete(u32 mpeg) static int sceMpegAvcDecodeMode(u32 mpeg, u32 modeAddr) { if (!Memory::IsValidAddress(modeAddr)) { - WARN_LOG(Log::ME, "sceMpegAvcDecodeMode(%08x, %08x): invalid addresses", mpeg, modeAddr); - return -1; + return hleLogWarning(Log::ME, -1, "invalid addresses"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - WARN_LOG(Log::ME, "sceMpegAvcDecodeMode(%08x, %08x): bad mpeg handle", mpeg, modeAddr); - return -1; + return hleLogWarning(Log::ME, -1, "bad mpeg handle"); } DEBUG_LOG(Log::ME, "sceMpegAvcDecodeMode(%08x, %08x)", mpeg, modeAddr); @@ -622,48 +612,38 @@ static int sceMpegAvcDecodeMode(u32 mpeg, u32 modeAddr) static int sceMpegQueryStreamOffset(u32 mpeg, u32 bufferAddr, u32 offsetAddr) { if (!Memory::IsValidAddress(bufferAddr) || !Memory::IsValidAddress(offsetAddr)) { - ERROR_LOG(Log::ME, "sceMpegQueryStreamOffset(%08x, %08x, %08x): invalid addresses", mpeg, bufferAddr, offsetAddr); - return -1; + return hleLogWarning(Log::ME, -1, "invalid addresses"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - WARN_LOG(Log::ME, "sceMpegQueryStreamOffset(%08x, %08x, %08x): bad mpeg handle", mpeg, bufferAddr, offsetAddr); - return -1; + return hleLogWarning(Log::ME, -1, "bad mpeg handle"); } - DEBUG_LOG(Log::ME, "sceMpegQueryStreamOffset(%08x, %08x, %08x)", mpeg, bufferAddr, offsetAddr); - // Kinda destructive, no? Shouldn't this just do what sceMpegQueryStreamSize does? AnalyzeMpeg(Memory::GetPointerWriteUnchecked(bufferAddr), Memory::ValidSize(bufferAddr, 32768), ctx); if (ctx->mpegMagic != PSMF_MAGIC) { - ERROR_LOG(Log::ME, "sceMpegQueryStreamOffset: Bad PSMF magic"); - Memory::Write_U32(0, offsetAddr); - return ERROR_MPEG_INVALID_VALUE; + Memory::WriteUnchecked_U32(0, offsetAddr); + return hleLogError(Log::ME, ERROR_MPEG_INVALID_VALUE, "Bad PSMF magic"); } else if (ctx->mpegVersion < 0) { - ERROR_LOG(Log::ME, "sceMpegQueryStreamOffset: Bad version"); - Memory::Write_U32(0, offsetAddr); - return ERROR_MPEG_BAD_VERSION; + Memory::WriteUnchecked_U32(0, offsetAddr); + return hleLogError(Log::ME, ERROR_MPEG_BAD_VERSION, "Bad version"); } else if ((ctx->mpegOffset & 2047) != 0 || ctx->mpegOffset == 0) { - ERROR_LOG(Log::ME, "sceMpegQueryStreamOffset: Bad offset"); - Memory::Write_U32(0, offsetAddr); - return ERROR_MPEG_INVALID_VALUE; + Memory::WriteUnchecked_U32(0, offsetAddr); + return hleLogError(Log::ME, ERROR_MPEG_INVALID_VALUE, "Bad offset"); } - Memory::Write_U32(ctx->mpegOffset, offsetAddr); - return 0; + Memory::WriteUnchecked_U32(ctx->mpegOffset, offsetAddr); + return hleLogDebug(Log::ME, 0); } static u32 sceMpegQueryStreamSize(u32 bufferAddr, u32 sizeAddr) { if (!Memory::IsValidAddress(bufferAddr) || !Memory::IsValidAddress(sizeAddr)) { - ERROR_LOG(Log::ME, "sceMpegQueryStreamSize(%08x, %08x): invalid addresses", bufferAddr, sizeAddr); - return -1; + return hleLogWarning(Log::ME, -1, "invalid addresses"); } - DEBUG_LOG(Log::ME, "sceMpegQueryStreamSize(%08x, %08x)", bufferAddr, sizeAddr); - MpegContext ctx; ctx.mediaengine = nullptr; // makes sure we don't actually load the stream. ctx.isAnalyzed = false; @@ -671,29 +651,24 @@ static u32 sceMpegQueryStreamSize(u32 bufferAddr, u32 sizeAddr) AnalyzeMpeg(Memory::GetPointerWriteUnchecked(bufferAddr), Memory::ValidSize(bufferAddr, 32768), &ctx); if (ctx.mpegMagic != PSMF_MAGIC) { - ERROR_LOG(Log::ME, "sceMpegQueryStreamSize: Bad PSMF magic"); - Memory::Write_U32(0, sizeAddr); - return ERROR_MPEG_INVALID_VALUE; + Memory::WriteUnchecked_U32(0, sizeAddr); + return hleLogError(Log::ME, ERROR_MPEG_INVALID_VALUE, "Bad PSMF magic"); } else if ((ctx.mpegOffset & 2047) != 0 ) { - ERROR_LOG(Log::ME, "sceMpegQueryStreamSize: Bad offset"); - Memory::Write_U32(0, sizeAddr); - return ERROR_MPEG_INVALID_VALUE; + Memory::WriteUnchecked_U32(0, sizeAddr); + return hleLogError(Log::ME, ERROR_MPEG_INVALID_VALUE, "Bad offset %08x", ctx.mpegOffset); } - Memory::Write_U32(ctx.mpegStreamSize, sizeAddr); - return 0; + Memory::WriteUnchecked_U32(ctx.mpegStreamSize, sizeAddr); + return hleLogDebug(Log::ME, 0); } static int sceMpegRegistStream(u32 mpeg, u32 streamType, u32 streamNum) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - WARN_LOG(Log::ME, "sceMpegRegistStream(%08x, %i, %i): bad mpeg handle", mpeg, streamType, streamNum); - return -1; + return hleLogWarning(Log::ME, -1, "bad mpeg handle"); } - INFO_LOG(Log::ME, "sceMpegRegistStream(%08x, %i, %i)", mpeg, streamType, streamNum); - switch (streamType) { case MPEG_AVC_STREAM: ctx->avcRegistered = true; @@ -725,49 +700,43 @@ static int sceMpegRegistStream(u32 mpeg, u32 streamType, u32 streamNum) info.sid = sid; info.needsReset = true; ctx->streamMap[sid] = info; - return sid; + return hleLogInfo(Log::ME, sid); } -static int sceMpegMallocAvcEsBuf(u32 mpeg) -{ +static int sceMpegMallocAvcEsBuf(u32 mpeg) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - WARN_LOG(Log::ME, "sceMpegMallocAvcEsBuf(%08x): bad mpeg handle", mpeg); - return -1; + return hleLogWarning(Log::ME, -1, "bad mpeg handle"); } - DEBUG_LOG(Log::ME, "sceMpegMallocAvcEsBuf(%08x)", mpeg); - // Doesn't actually malloc, just keeps track of a couple of flags for (int i = 0; i < MPEG_DATA_ES_BUFFERS; i++) { if (!ctx->esBuffers[i]) { ctx->esBuffers[i] = true; - return i + 1; + return hleLogDebug(Log::ME, i + 1); } } + // No es buffer - return 0; + return hleLogDebug(Log::ME, 0); } static int sceMpegFreeAvcEsBuf(u32 mpeg, int esBuf) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - WARN_LOG(Log::ME, "sceMpegFreeAvcEsBuf(%08x, %i): bad mpeg handle", mpeg, esBuf); - return -1; + return hleLogWarning(Log::ME, -1, "bad mpeg handle"); } - DEBUG_LOG(Log::ME, "sceMpegFreeAvcEsBuf(%08x, %i)", mpeg, esBuf); - if (esBuf == 0) { - return ERROR_MPEG_INVALID_VALUE; + return hleLogError(Log::ME, ERROR_MPEG_INVALID_VALUE); } if (esBuf >= 1 && esBuf <= MPEG_DATA_ES_BUFFERS) { // TODO: Check if it's already been free'd? ctx->esBuffers[esBuf - 1] = false; } - return 0; + return hleLogDebug(Log::ME, 0); } // check the existence of pmp media context @@ -1127,8 +1096,7 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - WARN_LOG(Log::ME, "sceMpegAvcDecode(%08x, %08x, %d, %08x, %08x): bad mpeg handle", mpeg, auAddr, frameWidth, bufferAddr, initAddr); - return -1; + return hleLogWarning(Log::ME, -1, "bad mpeg handle"); } if (frameWidth == 0) { // wtf, go sudoku passes in 0xcccccccc @@ -1144,8 +1112,7 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr auto ringbuffer = PSPPointer::Create(ctx->mpegRingbufferAddr); if (!ringbuffer.IsValid()) { - ERROR_LOG(Log::ME, "Bogus mpegringbufferaddr"); - return -1; + return hleLogError(Log::ME, -1, "Bogus mpegringbufferaddr"); } u32 buffer = Memory::Read_U32(bufferAddr); @@ -1364,9 +1331,8 @@ static int sceMpegAvcDecodeYCbCr(u32 mpeg, u32 auAddr, u32 bufferAddr, u32 initA if (mpegLibVersion >= 0x010A) { // Sunday Vs Magazine Shuuketsu! Choujou Daikessen expect, issue #11060 Memory::Write_U32(1, initAddr); - } - else { - // Save the current frame's status to initAddr + } else { + // Save the current frame's status to initAddr Memory::Write_U32(ctx->avc.avcFrameStatus, initAddr); } ctx->avc.avcDecodeResult = MPEG_AVC_DECODE_SUCCESS; diff --git a/Core/HLE/scePower.cpp b/Core/HLE/scePower.cpp index 7294c9c2a0..262d5c74a8 100644 --- a/Core/HLE/scePower.cpp +++ b/Core/HLE/scePower.cpp @@ -426,7 +426,7 @@ static int sceKernelVolatileMemLock(int type, u32 paddr, u32 psize) { break; } - return error; + return hleNoLog(error); } diff --git a/Core/HLE/sceSas.cpp b/Core/HLE/sceSas.cpp index fcf24930bd..5069b8ec31 100644 --- a/Core/HLE/sceSas.cpp +++ b/Core/HLE/sceSas.cpp @@ -480,7 +480,7 @@ static u32 sceSasSetKeyOff(u32 core, int voiceNum) { } else { __SasDrain(); if (sas->voices[voiceNum].paused || !sas->voices[voiceNum].on) { - return ERROR_SAS_VOICE_PAUSED; + return hleLogDebug(Log::sceSas, ERROR_SAS_VOICE_PAUSED); // this is ok } SasVoice &v = sas->voices[voiceNum]; @@ -509,11 +509,10 @@ static u32 sceSasSetSL(u32 core, int voiceNum, int level) { return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_VOICE, "invalid voiceNum"); } - DEBUG_LOG(Log::sceSas, "sceSasSetSL(%08x, %i, %08x)", core, voiceNum, level); __SasDrain(); SasVoice &v = sas->voices[voiceNum]; v.envelope.SetSustainLevel(level); - return 0; + return hleLogDebug(Log::sceSas, 0); } static u32 sceSasSetADSR(u32 core, int voiceNum, int flag, int a, int d, int s, int r) { @@ -524,15 +523,13 @@ static u32 sceSasSetADSR(u32 core, int voiceNum, int flag, int a, int d, int s, int invalid = (a < 0 ? 0x1 : 0) | (d < 0 ? 0x2 : 0) | (s < 0 ? 0x4 : 0) | (r < 0 ? 0x8 : 0); if (invalid & flag) { WARN_LOG_REPORT(Log::sceSas, "sceSasSetADSR(%08x, %i, %i, %08x, %08x, %08x, %08x): invalid value", core, voiceNum, flag, a, d, s, r); - return ERROR_SAS_INVALID_ADSR_RATE; + return hleNoLog(ERROR_SAS_INVALID_ADSR_RATE); } - DEBUG_LOG(Log::sceSas, "0=sceSasSetADSR(%08x, %i, %i, %08x, %08x, %08x, %08x)", core, voiceNum, flag, a, d, s, r); - __SasDrain(); SasVoice &v = sas->voices[voiceNum]; v.envelope.SetRate(flag, a, d, s, r); - return 0; + return hleLogDebug(Log::sceSas, 0); } static u32 sceSasSetADSRMode(u32 core, int voiceNum, int flag, int a, int d, int s, int r) { @@ -563,18 +560,17 @@ static u32 sceSasSetADSRMode(u32 core, int voiceNum, int flag, int a, int d, int if (invalid & flag) { if (a == 5 && d == 5 && s == 5 && r == 5) { // Some games do this right at init. It seems to fail even on a PSP, but let's not report it. - DEBUG_LOG(Log::sceSas, "sceSasSetADSRMode(%08x, %i, %i, %08x, %08x, %08x, %08x): invalid modes", core, voiceNum, flag, a, d, s, r); + return hleLogDebug(Log::sceSas, ERROR_SAS_INVALID_ADSR_CURVE_MODE, "sceSasSetADSRMode(%08x, %i, %i, %08x, %08x, %08x, %08x): invalid modes", core, voiceNum, flag, a, d, s, r); } else { WARN_LOG_REPORT(Log::sceSas, "sceSasSetADSRMode(%08x, %i, %i, %08x, %08x, %08x, %08x): invalid modes", core, voiceNum, flag, a, d, s, r); + return hleNoLog(ERROR_SAS_INVALID_ADSR_CURVE_MODE); } - return ERROR_SAS_INVALID_ADSR_CURVE_MODE; } - DEBUG_LOG(Log::sceSas, "sceSasSetADSRMode(%08x, %i, %i, %08x, %08x, %08x, %08x)", core, voiceNum, flag, a, d, s, r); __SasDrain(); SasVoice &v = sas->voices[voiceNum]; v.envelope.SetEnvelope(flag, a, d, s, r); - return 0; + return hleLogDebug(Log::sceSas, 0); }