diff --git a/Core/HLE/sceHprm.cpp b/Core/HLE/sceHprm.cpp index bb1e6dd9fe..fb2b56ffd9 100644 --- a/Core/HLE/sceHprm.cpp +++ b/Core/HLE/sceHprm.cpp @@ -22,46 +22,38 @@ #include "Core/MIPS/MIPS.h" static u32 sceHprmPeekCurrentKey(u32 keyAddress) { - DEBUG_LOG(Log::HLE,"0=sceHprmPeekCurrentKey(ptr)"); Memory::Write_U32(0, keyAddress); - return 0; + return hleLogDebug(Log::HLE, 0); } // TODO: Might make sense to reflect the headphone status of the host here, // if the games adjust their sound. static u32 sceHprmIsHeadphoneExist() { - DEBUG_LOG(Log::HLE, "sceHprmIsHeadphoneExist()"); - return 0; + return hleLogDebug(Log::HLE, 0); } static u32 sceHprmIsMicrophoneExist() { - DEBUG_LOG(Log::HLE, "sceHprmIsMicrophoneExist()"); - return 0; + return hleLogDebug(Log::HLE, 0); } static u32 sceHprmIsRemoteExist() { - DEBUG_LOG(Log::HLE, "sceHprmIsRemoteExist()"); - return 0; + return hleLogDebug(Log::HLE, 0); } static u32 sceHprmRegisterCallback() { - ERROR_LOG(Log::HLE, "UNIMPL %s", __FUNCTION__); - return 0; + return hleLogError(Log::HLE, 0, "UNIMPL"); } static u32 sceHprmUnregisterCallback() { - ERROR_LOG(Log::HLE, "UNIMPL %s", __FUNCTION__); - return 0; + return hleLogError(Log::HLE, 0, "UNIMPL"); } static u32 sceHprmPeekLatch(u32 latchAddr) { - DEBUG_LOG(Log::HLE,"sceHprmPeekLatch latchAddr %08x",latchAddr); - return 0; + return hleLogDebug(Log::HLE,0, "latchAddr %08x", latchAddr); } static u32 sceHprmReadLatch(u32 latchAddr) { - DEBUG_LOG(Log::HLE,"sceHprmReadLatch latchAddr %08x",latchAddr); - return 0; + return hleLogDebug(Log::HLE, 0, "latchAddr %08x", latchAddr); } const HLEFunction sceHprm[] = diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index 16135a37d4..960d15855f 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -365,15 +365,15 @@ int sceKernelRegisterDefaultExceptionHandler() { return hleLogError(Log::sceKernel, 0, "UNIMPL"); } -void sceKernelSetGPO(u32 ledBits) -{ +void sceKernelSetGPO(u32 ledBits) { // Sets debug LEDs. Some games do interesting stuff with this, like a metronome in Parappa. // Shows up as a vertical strip of LEDs at the side of the screen, if enabled. g_GPOBits = ledBits; + DEBUG_LOG(Log::sceKernel, "sceKernelSetGPO: %08x", ledBits); + return hleNoLogVoid(); } -u32 sceKernelGetGPI() -{ +u32 sceKernelGetGPI() { // Always returns 0 on production systems. // On developer systems, there are 8 switches that control the lower 8 bits of the return value. return hleLogDebug(Log::sceKernel, g_GPIBits); diff --git a/Core/HLE/sceKernelVTimer.cpp b/Core/HLE/sceKernelVTimer.cpp index f9e836e8ee..d6b1ee131c 100644 --- a/Core/HLE/sceKernelVTimer.cpp +++ b/Core/HLE/sceKernelVTimer.cpp @@ -85,9 +85,9 @@ static u64 __getVTimerCurrentTime(VTimer* vt) { static int __KernelCancelVTimer(SceUID id) { u32 error; VTimer *vt = kernelObjects.Get(id, error); - - if (!vt) + if (!vt) { return error; + } CoreTiming::UnscheduleEvent(vtimerTimer, id); vt->nvt.handlerAddr = 0; @@ -216,10 +216,8 @@ void __KernelVTimerInit() { u32 sceKernelCreateVTimer(const char *name, u32 optParamAddr) { if (!name) { - WARN_LOG_REPORT(Log::sceKernel, "%08x=sceKernelCreateVTimer(): invalid name", SCE_KERNEL_ERROR_ERROR); - return SCE_KERNEL_ERROR_ERROR; + return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ERROR, "invalid name"); } - DEBUG_LOG(Log::sceKernel, "sceKernelCreateVTimer(%s, %08x)", name, optParamAddr); VTimer *vtimer = new VTimer; SceUID id = kernelObjects.Create(vtimer); @@ -232,21 +230,17 @@ u32 sceKernelCreateVTimer(const char *name, u32 optParamAddr) { if (optParamAddr != 0) { u32 size = Memory::Read_U32(optParamAddr); if (size > 4) - WARN_LOG_REPORT(Log::sceKernel, "sceKernelCreateVTimer(%s) unsupported options parameter, size = %d", name, size); + WARN_LOG_REPORT_ONCE(vtimeropt, Log::sceKernel, "sceKernelCreateVTimer(%s) unsupported options parameter, size = %d", name, size); } - return id; + return hleLogDebug(Log::sceKernel, id); } u32 sceKernelDeleteVTimer(SceUID uid) { - DEBUG_LOG(Log::sceKernel, "sceKernelDeleteVTimer(%08x)", uid); - u32 error; VTimer* vt = kernelObjects.Get(uid, error); - - if (error) { - WARN_LOG(Log::sceKernel, "%08x=sceKernelDeleteVTimer(%08x)", error, uid); - return error; + if (!vt) { + return hleLogError(Log::sceKernel, error, "bad timer ID"); } for (std::list::iterator it = vtimers.begin(); it != vtimers.end(); ++it) { @@ -256,71 +250,55 @@ u32 sceKernelDeleteVTimer(SceUID uid) { } } - return kernelObjects.Destroy(uid); + return hleLogDebugOrError(Log::sceKernel, kernelObjects.Destroy(uid)); } u32 sceKernelGetVTimerBase(SceUID uid, u32 baseClockAddr) { - DEBUG_LOG(Log::sceKernel, "sceKernelGetVTimerBase(%08x, %08x)", uid, baseClockAddr); - u32 error; VTimer *vt = kernelObjects.Get(uid, error); - - if (error) { - WARN_LOG(Log::sceKernel, "%08x=sceKernelGetVTimerBase(%08x, %08x)", error, uid, baseClockAddr); - return error; + if (!vt) { + return hleLogError(Log::sceKernel, error, "bad timer ID"); } if (Memory::IsValidAddress(baseClockAddr)) Memory::Write_U64(vt->nvt.base, baseClockAddr); - return 0; + return hleLogDebug(Log::sceKernel, 0); } u64 sceKernelGetVTimerBaseWide(SceUID uid) { - DEBUG_LOG(Log::sceKernel, "sceKernelGetVTimerBaseWide(%08x)", uid); - u32 error; VTimer *vt = kernelObjects.Get(uid, error); - - if (error) { - WARN_LOG(Log::sceKernel, "%08x=sceKernelGetVTimerBaseWide(%08x)", error, uid); - return -1; + if (!vt) { + return hleLogError(Log::sceKernel, error, "bad timer ID"); } - return vt->nvt.base; + return hleLogDebug(Log::sceKernel, vt->nvt.base); } u32 sceKernelGetVTimerTime(SceUID uid, u32 timeClockAddr) { - DEBUG_LOG(Log::sceKernel, "sceKernelGetVTimerTime(%08x, %08x)", uid, timeClockAddr); - u32 error; VTimer *vt = kernelObjects.Get(uid, error); - - if (error) { - WARN_LOG(Log::sceKernel, "%08x=sceKernelGetVTimerTime(%08x, %08x)", error, uid, timeClockAddr); - return error; + if (!vt) { + return hleLogError(Log::sceKernel, error, "bad timer ID"); } u64 time = __getVTimerCurrentTime(vt); if (Memory::IsValidAddress(timeClockAddr)) Memory::Write_U64(time, timeClockAddr); - return 0; + return hleLogDebug(Log::sceKernel, 0); } u64 sceKernelGetVTimerTimeWide(SceUID uid) { - DEBUG_LOG(Log::sceKernel, "sceKernelGetVTimerTimeWide(%08x)", uid); - u32 error; VTimer *vt = kernelObjects.Get(uid, error); - - if (error) { - WARN_LOG(Log::sceKernel, "%08x=sceKernelGetVTimerTimeWide(%08x)", error, uid); - return -1; + if (!vt) { + return hleLogError(Log::sceKernel, error, "bad timer ID"); } u64 time = __getVTimerCurrentTime(vt); - return time; + return hleLogDebug(Log::sceKernel, time); } static u64 __KernelSetVTimer(VTimer *vt, u64 time) { @@ -334,39 +312,31 @@ static u64 __KernelSetVTimer(VTimer *vt, u64 time) { } u32 sceKernelSetVTimerTime(SceUID uid, u32 timeClockAddr) { - DEBUG_LOG(Log::sceKernel, "sceKernelSetVTimerTime(%08x, %08x)", uid, timeClockAddr); - u32 error; VTimer *vt = kernelObjects.Get(uid, error); - - if (error) { - WARN_LOG(Log::sceKernel, "%08x=sceKernelSetVTimerTime(%08x, %08x)", error, uid, timeClockAddr); - return error; + if (!vt) { + return hleLogError(Log::sceKernel, error, "bad timer ID"); } u64 time = Memory::Read_U64(timeClockAddr); if (Memory::IsValidAddress(timeClockAddr)) Memory::Write_U64(__KernelSetVTimer(vt, time), timeClockAddr); - return 0; + return hleLogDebug(Log::sceKernel, 0); } u64 sceKernelSetVTimerTimeWide(SceUID uid, u64 timeClock) { if (__IsInInterrupt()) { - WARN_LOG(Log::sceKernel, "sceKernelSetVTimerTimeWide(%08x, %llu): in interrupt", uid, timeClock); - return -1; + return hleLogWarning(Log::sceKernel, -1, "in interrupt"); } - DEBUG_LOG(Log::sceKernel, "sceKernelSetVTimerTimeWide(%08x, %llu)", uid, timeClock); u32 error; VTimer *vt = kernelObjects.Get(uid, error); - - if (error || vt == NULL) { - WARN_LOG(Log::sceKernel, "%08x=sceKernelSetVTimerTimeWide(%08x, %llu)", error, uid, timeClock); - return -1; + if (!vt) { + return hleLogError(Log::sceKernel, error, "bad timer ID"); } - return __KernelSetVTimer(vt, timeClock); + return hleLogDebug(Log::sceKernel, __KernelSetVTimer(vt, timeClock)); } static void __startVTimer(VTimer *vt) { @@ -379,26 +349,22 @@ static void __startVTimer(VTimer *vt) { u32 sceKernelStartVTimer(SceUID uid) { hleEatCycles(12200); - if (uid == runningVTimer) { - WARN_LOG(Log::sceKernel, "sceKernelStartVTimer(%08x): invalid vtimer", uid); - return SCE_KERNEL_ERROR_ILLEGAL_VTID; + return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_VTID, "invalid vtimer - can't be runningVTimer"); } - DEBUG_LOG(Log::sceKernel, "sceKernelStartVTimer(%08x)", uid); - u32 error; VTimer *vt = kernelObjects.Get(uid, error); - - if (vt) { - if (vt->nvt.active != 0) - return 1; - - __startVTimer(vt); - return 0; + if (!vt) { + return hleLogError(Log::sceKernel, error, "bad timer ID"); } - return error; + if (vt->nvt.active != 0) { + return hleLogDebug(Log::sceKernel, 1); + } + + __startVTimer(vt); + return hleLogDebug(Log::sceKernel, 0); } static void __stopVTimer(VTimer *vt) { @@ -410,41 +376,35 @@ static void __stopVTimer(VTimer *vt) { u32 sceKernelStopVTimer(SceUID uid) { if (uid == runningVTimer) { - WARN_LOG(Log::sceKernel, "sceKernelStopVTimer(%08x): invalid vtimer", uid); - return SCE_KERNEL_ERROR_ILLEGAL_VTID; + return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_VTID, "invalid vtimer - can't be runningVTimer"); } - DEBUG_LOG(Log::sceKernel, "sceKernelStopVTimer(%08x)", uid); u32 error; VTimer *vt = kernelObjects.Get(uid, error); - - if (vt) { - if (vt->nvt.active == 0) - return 0; - - __stopVTimer(vt); - return 1; + if (!vt) { + return hleLogError(Log::sceKernel, error, "bad timer ID"); } - return error; + if (vt->nvt.active == 0) { + return hleLogDebug(Log::sceKernel, 0); + } + + __stopVTimer(vt); + return hleLogDebug(Log::sceKernel, 1); } u32 sceKernelSetVTimerHandler(SceUID uid, u32 scheduleAddr, u32 handlerFuncAddr, u32 commonAddr) { hleEatCycles(900); if (uid == runningVTimer) { - WARN_LOG(Log::sceKernel, "sceKernelSetVTimerHandler(%08x, %08x, %08x, %08x): invalid vtimer", uid, scheduleAddr, handlerFuncAddr, commonAddr); - return SCE_KERNEL_ERROR_ILLEGAL_VTID; + return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_VTID, "invalid vtimer - can't be runningVTimer"); } u32 error; VTimer *vt = kernelObjects.Get(uid, error); - - if (error) { - WARN_LOG(Log::sceKernel, "%08x=sceKernelSetVTimerHandler(%08x, %08x, %08x, %08x)", error, uid, scheduleAddr, handlerFuncAddr, commonAddr); - return error; + if (!vt) { + return hleLogError(Log::sceKernel, error, "bad timer ID"); } - DEBUG_LOG(Log::sceKernel, "sceKernelSetVTimerHandler(%08x, %08x, %08x, %08x)", uid, scheduleAddr, handlerFuncAddr, commonAddr); hleEatCycles(2000); u64 schedule = Memory::Read_U64(scheduleAddr); @@ -456,26 +416,21 @@ u32 sceKernelSetVTimerHandler(SceUID uid, u32 scheduleAddr, u32 handlerFuncAddr, __KernelScheduleVTimer(vt, vt->nvt.schedule); } - return 0; + return hleLogDebug(Log::sceKernel, 0); } u32 sceKernelSetVTimerHandlerWide(SceUID uid, u64 schedule, u32 handlerFuncAddr, u32 commonAddr) { hleEatCycles(900); if (uid == runningVTimer) { - WARN_LOG(Log::sceKernel, "sceKernelSetVTimerHandlerWide(%08x, %llu, %08x, %08x): invalid vtimer", uid, schedule, handlerFuncAddr, commonAddr); - return SCE_KERNEL_ERROR_ILLEGAL_VTID; + return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_VTID, "invalid vtimer - can't be runningVTimer"); } u32 error; VTimer *vt = kernelObjects.Get(uid, error); - - if (error) { - WARN_LOG(Log::sceKernel, "%08x=sceKernelSetVTimerHandlerWide(%08x, %llu, %08x, %08x)", error, uid, schedule, handlerFuncAddr, commonAddr); - return error; + if (!vt) { + return hleLogError(Log::sceKernel, error, "bad timer ID"); } - DEBUG_LOG(Log::sceKernel, "sceKernelSetVTimerHandlerWide(%08x, %llu, %08x, %08x)", uid, schedule, handlerFuncAddr, commonAddr); - vt->nvt.handlerAddr = handlerFuncAddr; if (handlerFuncAddr) { vt->nvt.commonAddr = commonAddr; @@ -484,30 +439,23 @@ u32 sceKernelSetVTimerHandlerWide(SceUID uid, u64 schedule, u32 handlerFuncAddr, __KernelScheduleVTimer(vt, vt->nvt.schedule); } - return 0; + return hleLogDebug(Log::sceKernel, 0); } u32 sceKernelCancelVTimerHandler(SceUID uid) { if (uid == runningVTimer) { - WARN_LOG(Log::sceKernel, "sceKernelCancelVTimerHandler(%08x): invalid vtimer", uid); - return SCE_KERNEL_ERROR_ILLEGAL_VTID; + return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_VTID, "invalid vtimer - can't be runningVTimer"); } - DEBUG_LOG(Log::sceKernel, "sceKernelCancelVTimerHandler(%08x)", uid); - //__cancelVTimer checks if uid is valid - return __KernelCancelVTimer(uid); + return hleLogDebugOrError(Log::sceKernel, __KernelCancelVTimer(uid)); } u32 sceKernelReferVTimerStatus(SceUID uid, u32 statusAddr) { - DEBUG_LOG(Log::sceKernel, "sceKernelReferVTimerStatus(%08x, %08x)", uid, statusAddr); - u32 error; VTimer *vt = kernelObjects.Get(uid, error); - - if (error) { - WARN_LOG(Log::sceKernel, "%08x=sceKernelReferVTimerStatus(%08x, %08x)", error, uid, statusAddr); - return error; + if (!vt) { + return hleLogError(Log::sceKernel, error, "bad timer ID"); } if (Memory::IsValidAddress(statusAddr)) { @@ -517,10 +465,11 @@ u32 sceKernelReferVTimerStatus(SceUID uid, u32 statusAddr) { Memory::Memcpy(statusAddr, &status, std::min(size, (u32)sizeof(status)), "VTimerStatus"); } - return 0; + return hleLogDebug(Log::sceKernel, 0); } // Not sure why this is exposed... void _sceKernelReturnFromTimerHandler() { ERROR_LOG_REPORT(Log::sceKernel,"_sceKernelReturnFromTimerHandler - should not be called!"); + return hleNoLogVoid(); } diff --git a/Core/HLE/sceOpenPSID.cpp b/Core/HLE/sceOpenPSID.cpp index 62def434e6..f3e4d07c13 100644 --- a/Core/HLE/sceOpenPSID.cpp +++ b/Core/HLE/sceOpenPSID.cpp @@ -31,32 +31,25 @@ void __OpenPSIDInit() { } void __OpenPSIDShutdown() { - return; } -static int sceOpenPSIDGetOpenPSID(u32 OpenPSIDPtr) -{ - WARN_LOG(Log::HLE, "UNTESTED %s(%08x)", __FUNCTION__, OpenPSIDPtr); - +static int sceOpenPSIDGetOpenPSID(u32 OpenPSIDPtr) { auto ptr = PSPPointer::Create(OpenPSIDPtr); if (ptr.IsValid()) { *ptr = dummyOpenPSID; ptr.NotifyWrite("OpenPSIDGetOpenPSID"); } - return 0; + return hleLogWarning(Log::HLE, 0, "UNTESTED"); } -static int sceOpenPSIDGetPSID(u32 OpenPSIDPtr,u32 unknown) -{ - WARN_LOG(Log::HLE, "UNTESTED %s(%08x, %08x)", __FUNCTION__, OpenPSIDPtr, unknown); - +static int sceOpenPSIDGetPSID(u32 OpenPSIDPtr, u32 unknown) { auto ptr = PSPPointer::Create(OpenPSIDPtr); if (ptr.IsValid()) { *ptr = dummyOpenPSID; ptr.NotifyWrite("OpenPSIDGetPSID"); } - return 0; + return hleLogWarning(Log::HLE, 0, "UNTESTED"); } /* @@ -74,21 +67,15 @@ Returns: 0 on success, otherwise < 0. */ static s32 sceDdrdb_F013F8BF(u32 pDataPtr, u32 pSigPtr) { - ERROR_LOG(Log::HLE, "UNIMPL %s(%08x, %08x)", __FUNCTION__, pDataPtr, pSigPtr); - - return 0; + return hleLogError(Log::HLE, 0, "UNIMPL"); } // unkPtr might be a pointer to OpenPSID static s32 sceOpenPSIDGetProductCode(u32 unkPtr) { - ERROR_LOG_REPORT(Log::HLE, "UNIMPL %s(%08x)", __FUNCTION__, unkPtr); - - return 0; + return hleLogError(Log::HLE, 0, "UNIMPL"); } - -const HLEFunction sceOpenPSID[] = -{ +const HLEFunction sceOpenPSID[] = { {0xC69BEBCE, &WrapI_U, "sceOpenPSIDGetOpenPSID", 'i', "x" }, {0xB29330DE, &WrapI_U, "sceOpenPSIDGetProductCode", 'i', "x" }, }; diff --git a/Core/HLE/sceSas.cpp b/Core/HLE/sceSas.cpp index 05091303fd..fcf24930bd 100644 --- a/Core/HLE/sceSas.cpp +++ b/Core/HLE/sceSas.cpp @@ -226,29 +226,27 @@ void __SasShutdown() { sas = 0; } - static u32 sceSasInit(u32 core, u32 grainSize, u32 maxVoices, u32 outputMode, u32 sampleRate) { if (!Memory::IsValidAddress(core) || (core & 0x3F) != 0) { ERROR_LOG_REPORT(Log::sceSas, "sceSasInit(%08x, %i, %i, %i, %i): bad core address", core, grainSize, maxVoices, outputMode, sampleRate); - return ERROR_SAS_BAD_ADDRESS; + return hleNoLog(ERROR_SAS_BAD_ADDRESS); } if (maxVoices == 0 || maxVoices > PSP_SAS_VOICES_MAX) { ERROR_LOG_REPORT(Log::sceSas, "sceSasInit(%08x, %i, %i, %i, %i): bad max voices", core, grainSize, maxVoices, outputMode, sampleRate); - return ERROR_SAS_INVALID_MAX_VOICES; + return hleNoLog(ERROR_SAS_INVALID_MAX_VOICES); } if (grainSize < 0x40 || grainSize > 0x800 || (grainSize & 0x1F) != 0) { ERROR_LOG_REPORT(Log::sceSas, "sceSasInit(%08x, %i, %i, %i, %i): bad grain size", core, grainSize, maxVoices, outputMode, sampleRate); - return ERROR_SAS_INVALID_GRAIN; + return hleNoLog(ERROR_SAS_INVALID_GRAIN); } if (outputMode != 0 && outputMode != 1) { ERROR_LOG_REPORT(Log::sceSas, "sceSasInit(%08x, %i, %i, %i, %i): bad output mode", core, grainSize, maxVoices, outputMode, sampleRate); - return ERROR_SAS_INVALID_OUTPUT_MODE; + return hleNoLog(ERROR_SAS_INVALID_OUTPUT_MODE); } if (sampleRate != 44100) { ERROR_LOG_REPORT(Log::sceSas, "sceSasInit(%08x, %i, %i, %i, %i): bad sample rate", core, grainSize, maxVoices, outputMode, sampleRate); - return ERROR_SAS_INVALID_SAMPLE_RATE; + return hleNoLog(ERROR_SAS_INVALID_SAMPLE_RATE); } - INFO_LOG(Log::sceSas, "sceSasInit(%08x, %i, %i, %i, %i)", core, grainSize, maxVoices, outputMode, sampleRate); sas->SetGrainSize(grainSize); // Seems like the maxVoices param is actually ignored for all intents and purposes. @@ -259,7 +257,7 @@ static u32 sceSasInit(u32 core, u32 grainSize, u32 maxVoices, u32 outputMode, u3 sas->voices[i].playing = false; sas->voices[i].loop = false; } - return 0; + return hleLogInfo(Log::sceSas, 0); } static u32 sceSasGetEndFlag(u32 core) { @@ -270,8 +268,7 @@ static u32 sceSasGetEndFlag(u32 core) { endFlag |= (1 << i); } - VERBOSE_LOG(Log::sceSas, "%08x=sceSasGetEndFlag(%08x)", endFlag, core); - return endFlag; + return hleLogVerbose(Log::sceSas, endFlag); } static int delaySasResult(int result) { @@ -319,7 +316,7 @@ static u32 _sceSasCoreWithMix(u32 core, u32 inoutAddr, int leftVolume, int right __SasEnqueueMix(inoutAddr, inoutAddr, leftVolume, rightVolume); - return hleLogVerbose(Log::sceSas, delaySasResult(0)); + return delaySasResult(hleLogVerbose(Log::sceSas, 0)); } static u32 sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loop) { @@ -329,20 +326,18 @@ static u32 sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loo if (size == 0 || ((u32)size & 0xF) != 0) { if (size == 0) { - DEBUG_LOG(Log::sceSas, "%s: invalid size %d", __FUNCTION__, size); + return hleLogDebug(Log::sceSas, ERROR_SAS_INVALID_PARAMETER, "invalid size %d", size); } else { - WARN_LOG(Log::sceSas, "%s: invalid size %d", __FUNCTION__, size); + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_PARAMETER, "invalid size %d", size); } - return ERROR_SAS_INVALID_PARAMETER; } if (loop != 0 && loop != 1) { WARN_LOG_REPORT(Log::sceSas, "%s: invalid loop mode %d", __FUNCTION__, loop); - return ERROR_SAS_INVALID_LOOP_POS; + return hleNoLog(ERROR_SAS_INVALID_LOOP_POS); } if (!Memory::IsValidAddress(vagAddr)) { - ERROR_LOG(Log::sceSas, "%s: Ignoring invalid VAG audio address %08x", __FUNCTION__, vagAddr); - return 0; + return hleLogError(Log::sceSas, 0, "Ignoring invalid VAG audio address %08x", vagAddr); } __SasDrain(); @@ -372,7 +367,7 @@ static u32 sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loo v.playing = true; } v.vag.Start(vagAddr, size, loop != 0); - return 0; + return hleNoLog(0); } static u32 sceSasSetVoicePCM(u32 core, int voiceNum, u32 pcmAddr, int size, int loopPos) { @@ -380,16 +375,14 @@ static u32 sceSasSetVoicePCM(u32 core, int voiceNum, u32 pcmAddr, int size, int return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_VOICE, "invalid voicenum"); } if (size <= 0 || size > 0x10000) { - WARN_LOG(Log::sceSas, "%s: invalid size %d", __FUNCTION__, size); - return ERROR_SAS_INVALID_PCM_SIZE; + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_PCM_SIZE, "invalid size %d", size); } if (loopPos >= size) { ERROR_LOG_REPORT(Log::sceSas, "sceSasSetVoicePCM(%08x, %i, %08x, %i, %i): bad loop pos", core, voiceNum, pcmAddr, size, loopPos); - return ERROR_SAS_INVALID_LOOP_POS; + return hleNoLog(ERROR_SAS_INVALID_LOOP_POS); } if (!Memory::IsValidAddress(pcmAddr)) { - ERROR_LOG(Log::sceSas, "Ignoring invalid PCM audio address %08x", pcmAddr); - return 0; + return hleLogError(Log::sceSas, 0, "Ignoring invalid PCM audio address %08x", pcmAddr); } __SasDrain(); @@ -398,8 +391,6 @@ static u32 sceSasSetVoicePCM(u32 core, int voiceNum, u32 pcmAddr, int size, int return hleLogError(Log::sceSas, ERROR_SAS_ATRAC3_ALREADY_SET, "voice is already ATRAC3"); } - DEBUG_LOG(Log::sceSas, "sceSasSetVoicePCM(%08x, %i, %08x, %i, %i)", core, voiceNum, pcmAddr, size, loopPos); - u32 prevPcmAddr = v.pcmAddr; v.type = VOICETYPE_PCM; v.pcmAddr = pcmAddr; @@ -408,7 +399,7 @@ static u32 sceSasSetVoicePCM(u32 core, int voiceNum, u32 pcmAddr, int size, int v.pcmLoopPos = loopPos >= 0 ? loopPos : 0; v.loop = loopPos >= 0 ? true : false; v.playing = true; - return 0; + return hleLogDebug(Log::sceSas, 0); } static u32 sceSasGetPauseFlag(u32 core) { @@ -419,13 +410,10 @@ static u32 sceSasGetPauseFlag(u32 core) { pauseFlag |= (1 << i); } - DEBUG_LOG(Log::sceSas, "sceSasGetPauseFlag(%08x)", pauseFlag); - return pauseFlag; + return hleLogDebug(Log::sceSas, pauseFlag); } static u32 sceSasSetPause(u32 core, u32 voicebit, int pause) { - DEBUG_LOG(Log::sceSas, "sceSasSetPause(%08x, %08x, %i)", core, voicebit, pause); - __SasDrain(); for (int i = 0; voicebit != 0; i++, voicebit >>= 1) { if (i < PSP_SAS_VOICES_MAX && i >= 0) { @@ -434,20 +422,18 @@ static u32 sceSasSetPause(u32 core, u32 voicebit, int pause) { } } - return 0; + return hleLogDebug(Log::sceSas, 0); } static u32 sceSasSetVolume(u32 core, int voiceNum, int leftVol, int rightVol, int effectLeftVol, int effectRightVol) { - DEBUG_LOG(Log::sceSas, "sceSasSetVolume(%08x, %i, %i, %i, %i, %i)", core, voiceNum, leftVol, rightVol, effectLeftVol, effectRightVol); - if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { - WARN_LOG(Log::sceSas, "%s: invalid voicenum %d", __FUNCTION__, voiceNum); - return ERROR_SAS_INVALID_VOICE; + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_VOICE, "invalid voicenum"); } bool overVolume = abs(leftVol) > PSP_SAS_VOL_MAX || abs(rightVol) > PSP_SAS_VOL_MAX; overVolume = overVolume || abs(effectLeftVol) > PSP_SAS_VOL_MAX || abs(effectRightVol) > PSP_SAS_VOL_MAX; - if (overVolume) - return ERROR_SAS_INVALID_VOLUME; + if (overVolume) { + return hleLogError(Log::sceSas, ERROR_SAS_INVALID_VOLUME); + } __SasDrain(); SasVoice &v = sas->voices[voiceNum]; @@ -455,52 +441,43 @@ static u32 sceSasSetVolume(u32 core, int voiceNum, int leftVol, int rightVol, in v.volumeRight = rightVol; v.effectLeft = effectLeftVol; v.effectRight = effectRightVol; - return 0; + return hleLogDebug(Log::sceSas, 0); } static u32 sceSasSetPitch(u32 core, int voiceNum, int pitch) { if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { - WARN_LOG(Log::sceSas, "%s: invalid voicenum %d", __FUNCTION__, voiceNum); - return ERROR_SAS_INVALID_VOICE; + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_VOICE, "invalid voiceNum"); } if (pitch < PSP_SAS_PITCH_MIN || pitch > PSP_SAS_PITCH_MAX) { - WARN_LOG(Log::sceSas, "sceSasSetPitch(%08x, %i, %i): bad pitch", core, voiceNum, pitch); - return ERROR_SAS_INVALID_PITCH; + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_PITCH, "bad pitch"); } - DEBUG_LOG(Log::sceSas, "sceSasSetPitch(%08x, %i, %i)", core, voiceNum, pitch); __SasDrain(); SasVoice &v = sas->voices[voiceNum]; v.pitch = pitch; - return 0; + return hleLogDebug(Log::sceSas, 0); } static u32 sceSasSetKeyOn(u32 core, int voiceNum) { - DEBUG_LOG(Log::sceSas, "sceSasSetKeyOn(%08x, %i)", core, voiceNum); - if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { - WARN_LOG(Log::sceSas, "%s: invalid voicenum %d", __FUNCTION__, voiceNum); - return ERROR_SAS_INVALID_VOICE; + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_VOICE, "invalid voiceNum"); } __SasDrain(); if (sas->voices[voiceNum].paused || sas->voices[voiceNum].on) { - return ERROR_SAS_VOICE_PAUSED; + return hleLogError(Log::sceSas, ERROR_SAS_VOICE_PAUSED); } SasVoice &v = sas->voices[voiceNum]; v.KeyOn(); - return 0; + return hleLogDebug(Log::sceSas, 0); } // sceSasSetKeyOff can be used to start sounds, that just sound during the Release phase! static u32 sceSasSetKeyOff(u32 core, int voiceNum) { if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { - WARN_LOG(Log::sceSas, "%s: invalid voicenum %d", __FUNCTION__, voiceNum); - return ERROR_SAS_INVALID_VOICE; + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_VOICE, "invalid voiceNum"); } else { - DEBUG_LOG(Log::sceSas, "sceSasSetKeyOff(%08x, %i)", core, voiceNum); - __SasDrain(); if (sas->voices[voiceNum].paused || !sas->voices[voiceNum].on) { return ERROR_SAS_VOICE_PAUSED; @@ -508,33 +485,28 @@ static u32 sceSasSetKeyOff(u32 core, int voiceNum) { SasVoice &v = sas->voices[voiceNum]; v.KeyOff(); - return 0; + return hleLogDebug(Log::sceSas, 0); } } static u32 sceSasSetNoise(u32 core, int voiceNum, int freq) { - if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { - WARN_LOG(Log::sceSas, "%s: invalid voicenum %d", __FUNCTION__, voiceNum); - return ERROR_SAS_INVALID_VOICE; + if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_VOICE, "invalid voiceNum"); } if (freq < 0 || freq >= 64) { - DEBUG_LOG(Log::sceSas, "sceSasSetNoise(%08x, %i, %i)", core, voiceNum, freq); - return ERROR_SAS_INVALID_NOISE_FREQ; + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_NOISE_FREQ); } - DEBUG_LOG(Log::sceSas, "sceSasSetNoise(%08x, %i, %i)", core, voiceNum, freq); - __SasDrain(); SasVoice &v = sas->voices[voiceNum]; v.type = VOICETYPE_NOISE; v.noiseFreq = freq; - return 0; + return hleLogDebug(Log::sceSas, 0); } static u32 sceSasSetSL(u32 core, int voiceNum, int level) { if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { - WARN_LOG(Log::sceSas, "%s: invalid voicenum %d", __FUNCTION__, voiceNum); - return ERROR_SAS_INVALID_VOICE; + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_VOICE, "invalid voiceNum"); } DEBUG_LOG(Log::sceSas, "sceSasSetSL(%08x, %i, %08x)", core, voiceNum, level); @@ -545,9 +517,8 @@ static u32 sceSasSetSL(u32 core, int voiceNum, int level) { } static u32 sceSasSetADSR(u32 core, int voiceNum, int flag, int a, int d, int s, int r) { - if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { - WARN_LOG(Log::sceSas, "%s: invalid voicenum %d", __FUNCTION__, voiceNum); - return ERROR_SAS_INVALID_VOICE; + if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_VOICE, "invalid voiceNum"); } // Create a mask like flag for the invalid values. int invalid = (a < 0 ? 0x1 : 0) | (d < 0 ? 0x2 : 0) | (s < 0 ? 0x4 : 0) | (r < 0 ? 0x8 : 0); @@ -565,9 +536,8 @@ static u32 sceSasSetADSR(u32 core, int voiceNum, int flag, int a, int d, int s, } static u32 sceSasSetADSRMode(u32 core, int voiceNum, int flag, int a, int d, int s, int r) { - if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { - WARN_LOG(Log::sceSas, "%s: invalid voicenum %d", __FUNCTION__, voiceNum); - return ERROR_SAS_INVALID_VOICE; + if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_VOICE, "invalid voiceNum"); } // Probably by accident (?), the PSP ignores the top bit of these values. @@ -609,35 +579,29 @@ static u32 sceSasSetADSRMode(u32 core, int voiceNum, int flag, int a, int d, int static u32 sceSasSetSimpleADSR(u32 core, int voiceNum, u32 ADSREnv1, u32 ADSREnv2) { - if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { - WARN_LOG(Log::sceSas, "%s: invalid voicenum %d", __FUNCTION__, voiceNum); - return ERROR_SAS_INVALID_VOICE; + if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_VOICE, "invalid voiceNum"); } // This bit could be related to decay type or systain type, but gives an error if you try to set it. if ((ADSREnv2 >> 13) & 1) { - WARN_LOG_REPORT(Log::sceSas, "sceSasSetSimpleADSR(%08x, %d, %04x, %04x): Invalid ADSREnv2", core, voiceNum, ADSREnv1, ADSREnv2); - return ERROR_SAS_INVALID_ADSR_CURVE_MODE; + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_ADSR_CURVE_MODE, "Invalid ADSREnv2"); } - DEBUG_LOG(Log::sceSas, "sasSetSimpleADSR(%08x, %i, %08x, %08x)", core, voiceNum, ADSREnv1, ADSREnv2); - __SasDrain(); SasVoice &v = sas->voices[voiceNum]; v.envelope.SetSimpleEnvelope(ADSREnv1 & 0xFFFF, ADSREnv2 & 0xFFFF); - return 0; + return hleLogDebug(Log::sceSas, 0); } static u32 sceSasGetEnvelopeHeight(u32 core, int voiceNum) { - if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { - ERROR_LOG(Log::sceSas, "%s: invalid voicenum %d", __FUNCTION__, voiceNum); - return ERROR_SAS_INVALID_VOICE; + if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) { + return hleLogWarning(Log::sceSas, ERROR_SAS_INVALID_VOICE, "invalid voiceNum"); } __SasDrain(); SasVoice &v = sas->voices[voiceNum]; int height = v.envelope.GetHeight(); - DEBUG_LOG(Log::sceSas, "%i = sceSasGetEnvelopeHeight(%08x, %i)", height, core, voiceNum); - return height; + return hleLogDebug(Log::sceSas, height); } static u32 sceSasRevType(u32 core, int type) { @@ -683,39 +647,33 @@ static u32 sceSasRevVON(u32 core, int dry, int wet) { } static u32 sceSasGetGrain(u32 core) { - DEBUG_LOG(Log::sceSas, "sceSasGetGrain(%08x)", core); - return sas->GetGrainSize(); + return hleLogDebug(Log::sceSas, sas->GetGrainSize()); } static u32 sceSasSetGrain(u32 core, int grain) { - INFO_LOG(Log::sceSas, "sceSasSetGrain(%08x, %i)", core, grain); __SasDrain(); sas->SetGrainSize(grain); - return 0; + return hleLogInfo(Log::sceSas, 0); } static u32 sceSasGetOutputMode(u32 core) { - DEBUG_LOG(Log::sceSas, "sceSasGetOutputMode(%08x)", core); - return sas->outputMode; + return hleLogDebug(Log::sceSas, sas->outputMode); } static u32 sceSasSetOutputMode(u32 core, u32 outputMode) { if (outputMode != 0 && outputMode != 1) { ERROR_LOG_REPORT(Log::sceSas, "sceSasSetOutputMode(%08x, %i): bad output mode", core, outputMode); - return ERROR_SAS_INVALID_OUTPUT_MODE; + return hleNoLog(ERROR_SAS_INVALID_OUTPUT_MODE); } - DEBUG_LOG(Log::sceSas, "sceSasSetOutputMode(%08x, %i)", core, outputMode); + __SasDrain(); sas->outputMode = outputMode; - - return 0; + return hleLogDebug(Log::sceSas, 0); } static u32 sceSasGetAllEnvelopeHeights(u32 core, u32 heightsAddr) { - DEBUG_LOG(Log::sceSas, "sceSasGetAllEnvelopeHeights(%08x, %i)", core, heightsAddr); - if (!Memory::IsValidAddress(heightsAddr)) { - return ERROR_SAS_INVALID_PARAMETER; + return hleLogError(Log::sceSas, ERROR_SAS_INVALID_PARAMETER); } __SasDrain(); @@ -724,17 +682,17 @@ static u32 sceSasGetAllEnvelopeHeights(u32 core, u32 heightsAddr) { Memory::Write_U32(voiceHeight, heightsAddr + i * 4); } - return 0; + return hleLogDebug(Log::sceSas, 0); } static u32 sceSasSetTriangularWave(u32 sasCore, int voice, int unknown) { ERROR_LOG_REPORT(Log::sceSas, "UNIMPL sceSasSetTriangularWave(%08x, %i, %i)", sasCore, voice, unknown); - return 0; + return hleNoLog(0); } static u32 sceSasSetSteepWave(u32 sasCore, int voice, int unknown) { ERROR_LOG_REPORT(Log::sceSas, "UNIMPL sceSasSetSteepWave(%08x, %i, %i)", sasCore, voice, unknown); - return 0; + return hleNoLog(0); } static u32 __sceSasSetVoiceATRAC3(u32 core, int voiceNum, u32 atrac3Context) { @@ -766,7 +724,7 @@ static u32 __sceSasConcatenateATRAC3(u32 core, int voiceNum, u32 atrac3DataAddr, SasVoice &v = sas->voices[voiceNum]; if (Memory::IsValidAddress(atrac3DataAddr)) v.atrac3.addStreamData(atrac3DataAddr, atrac3DataLength); - return 0; + return hleNoLog(0); } static u32 __sceSasUnsetATRAC3(u32 core, int voiceNum) {