diff --git a/Core/HLE/FunctionWrappers.h b/Core/HLE/FunctionWrappers.h index 45c01e03cc..d7c72d1a1f 100644 --- a/Core/HLE/FunctionWrappers.h +++ b/Core/HLE/FunctionWrappers.h @@ -276,6 +276,11 @@ template void WrapU_UII() { RETURN(retval); } +template void WrapU_UIIU() { + u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); + RETURN(retval); +} + template void WrapI_UIIUU() { u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); RETURN(retval); diff --git a/Core/HLE/sceAudio.cpp b/Core/HLE/sceAudio.cpp index 73ef01ffbf..4fc4842087 100644 --- a/Core/HLE/sceAudio.cpp +++ b/Core/HLE/sceAudio.cpp @@ -52,7 +52,7 @@ AudioChannel chans[PSP_AUDIO_CHANNEL_MAX + 1]; // Not sure about the range of volume, I often see 0x800 so that might be either // max or 50%? -u32 sceAudioOutputBlocking(u32 chan, u32 vol, u32 samplePtr) { +u32 sceAudioOutputBlocking(u32 chan, int vol, u32 samplePtr) { if (vol > 0xFFFF) { ERROR_LOG(HLE, "sceAudioOutputBlocking() - invalid volume"); return SCE_ERROR_AUDIO_INVALID_VOLUME; @@ -67,14 +67,16 @@ u32 sceAudioOutputBlocking(u32 chan, u32 vol, u32 samplePtr) { return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED; } else { DEBUG_LOG(HLE, "sceAudioOutputBlocking(%08x, %08x, %08x)", chan, vol, samplePtr); - chans[chan].leftVolume = vol; - chans[chan].rightVolume = vol; + if (vol >= 0) { + chans[chan].leftVolume = vol; + chans[chan].rightVolume = vol; + } chans[chan].sampleAddress = samplePtr; return __AudioEnqueue(chans[chan], chan, true); } } -u32 sceAudioOutputPannedBlocking(u32 chan, u32 leftvol, u32 rightvol, u32 samplePtr) { +u32 sceAudioOutputPannedBlocking(u32 chan, int leftvol, int rightvol, u32 samplePtr) { if (leftvol > 0xFFFF || rightvol > 0xFFFF) { ERROR_LOG(HLE, "sceAudioOutputPannedBlocking() - invalid volume"); return SCE_ERROR_AUDIO_INVALID_VOLUME; @@ -89,14 +91,18 @@ u32 sceAudioOutputPannedBlocking(u32 chan, u32 leftvol, u32 rightvol, u32 sample return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED; } else { DEBUG_LOG(HLE, "sceAudioOutputPannedBlocking(%08x, %08x, %08x, %08x)", chan, leftvol, rightvol, samplePtr); - chans[chan].leftVolume = leftvol; - chans[chan].rightVolume = rightvol; + if (leftvol >= 0) { + chans[chan].leftVolume = leftvol; + } + if (rightvol >= 0) { + chans[chan].rightVolume = rightvol; + } chans[chan].sampleAddress = samplePtr; return __AudioEnqueue(chans[chan], chan, true); } } -u32 sceAudioOutput(u32 chan, u32 vol, u32 samplePtr) { +u32 sceAudioOutput(u32 chan, int vol, u32 samplePtr) { if (vol > 0xFFFF) { ERROR_LOG(HLE, "sceAudioOutput() - invalid volume"); return SCE_ERROR_AUDIO_INVALID_VOLUME; @@ -111,14 +117,16 @@ u32 sceAudioOutput(u32 chan, u32 vol, u32 samplePtr) { return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED; } else { DEBUG_LOG(HLE, "sceAudioOutputPanned(%08x, %08x, %08x)", chan, vol, samplePtr); - chans[chan].leftVolume = vol; - chans[chan].rightVolume = vol; + if (vol >= 0) { + chans[chan].leftVolume = vol; + chans[chan].rightVolume = vol; + } chans[chan].sampleAddress = samplePtr; return __AudioEnqueue(chans[chan], chan, false); } } -u32 sceAudioOutputPanned(u32 chan, u32 leftvol, u32 rightvol, u32 samplePtr) { +u32 sceAudioOutputPanned(u32 chan, int leftvol, int rightvol, u32 samplePtr) { if (leftvol > 0xFFFF || rightvol > 0xFFFF) { ERROR_LOG(HLE, "sceAudioOutputPannedBlocking() - invalid volume"); return SCE_ERROR_AUDIO_INVALID_VOLUME; @@ -133,8 +141,12 @@ u32 sceAudioOutputPanned(u32 chan, u32 leftvol, u32 rightvol, u32 samplePtr) { return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED; } else { DEBUG_LOG(HLE,"sceAudioOutputPanned(%08x, %08x, %08x, %08x)", chan, leftvol, rightvol, samplePtr); - chans[chan].leftVolume = leftvol; - chans[chan].rightVolume = rightvol; + if (leftvol >= 0) { + chans[chan].leftVolume = leftvol; + } + if (rightvol >= 0) { + chans[chan].rightVolume = rightvol; + } chans[chan].sampleAddress = samplePtr; return __AudioEnqueue(chans[chan], chan, false); } @@ -166,10 +178,10 @@ static u32 GetFreeChannel() { return -1; } -u32 sceAudioChReserve(u32 chan, u32 sampleCount, u32 format) { - if ((int)chan < 0) { +u32 sceAudioChReserve(int chan, u32 sampleCount, u32 format) { + if (chan < 0) { chan = GetFreeChannel(); - if ((int)chan < 0) { + if (chan < 0) { ERROR_LOG(HLE, "sceAudioChReserve - no channels remaining"); return SCE_ERROR_AUDIO_NO_CHANNELS_AVAILABLE; } @@ -195,6 +207,8 @@ u32 sceAudioChReserve(u32 chan, u32 sampleCount, u32 format) { chans[chan].sampleCount = sampleCount; chans[chan].format = format; chans[chan].reserved = true; + chans[chan].leftVolume = 0; + chans[chan].rightVolume = 0; return chan; } @@ -396,21 +410,21 @@ const HLEFunction sceAudio[] = {0x01562ba3, WrapU_U, "sceAudioOutput2Reserve"}, {0x2d53f36e, WrapU_UU, "sceAudioOutput2OutputBlocking"}, {0x63f2889c, WrapU_U, "sceAudioOutput2ChangeLength"}, - {0x647cef33, WrapU_V, "sceAudioOutput2GetRestSample"}, + {0x647cef33, WrapU_V, "sceAudioOutput2GetRestSample"}, {0x43196845, WrapU_V, "sceAudioOutput2Release"}, {0x80F1F7E0, WrapU_V, "sceAudioInit"}, {0x210567F7, WrapU_V, "sceAudioEnd"}, {0xA2BEAA6C, WrapU_U, "sceAudioSetFrequency"}, {0x927AC32B, WrapU_V, "sceAudioSetVolumeOffset"}, - {0x8c1009b2, WrapU_UUU, "sceAudioOutput"}, - {0x136CAF51, WrapU_UUU, "sceAudioOutputBlocking"}, - {0xE2D56B2D, WrapU_UUUU, "sceAudioOutputPanned"}, - {0x13F592BC, WrapU_UUUU, "sceAudioOutputPannedBlocking"}, - {0x5EC81C55, WrapU_UUU, "sceAudioChReserve"}, - {0x6FC46853, WrapU_U, "sceAudioChRelease"}, + {0x8c1009b2, WrapU_UIU, "sceAudioOutput"}, + {0x136CAF51, WrapU_UIU, "sceAudioOutputBlocking"}, + {0xE2D56B2D, WrapU_UIIU, "sceAudioOutputPanned"}, + {0x13F592BC, WrapU_UIIU, "sceAudioOutputPannedBlocking"}, + {0x5EC81C55, WrapU_IUU, "sceAudioChReserve"}, + {0x6FC46853, WrapU_U, "sceAudioChRelease"}, {0xE9D97901, WrapI_U, "sceAudioGetChannelRestLen"}, - {0xB011922F, WrapI_U, "sceAudioGetChannelRestLength"}, - {0xCB2E439E, WrapU_UU, "sceAudioSetChannelDataLen"}, + {0xB011922F, WrapI_U, "sceAudioGetChannelRestLength"}, + {0xCB2E439E, WrapU_UU, "sceAudioSetChannelDataLen"}, {0x95FD0C2D, WrapU_UU, "sceAudioChangeChannelConfig"}, {0xB7E1D8E7, WrapU_UUU, "sceAudioChangeChannelVolume"}, {0x38553111, WrapU_UUU, "sceAudioSRCChReserve"},