mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-01 12:07:31 +01:00
- sceHeapDeleteHeap never freed the heap's memory. Allocation failure returned -1 rather than a null pointer, and a near-4GB size wrapped. - The USB wait timeout resumed threads that were no longer waiting on USB, and UsbUpdateState resumed them too, and never rescheduled. - The Mersenne Twister drew from mt_[index_] with the index taken from guest memory. It's now taken modulo the state size. sceSfmt19937 checks its index, and that fill arrays are at least a state long, which the library writes regardless of the length it's given. - sceCccEncodeUTF16's surrogate test also caught U+F800 - U+FFFF, which includes the fullwidth forms. - sceAudioRoutingSetVolumeMode stored the routing mode. - A sample rate of 0 to sceAudioInput or the camera mic divided by zero, and a huge sample count sized a host buffer. sceP3daBridgeCore's sizes could wrap. sceRtc's tz offset could overflow tm_min. - Camera shutdown freed the frame buffer and config without the lock the capture thread uses. GPS data is set from the platform's location thread, so it's now locked too, and the satellite index is bounded. - A loop in the sys event handler list hung the unregister. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
77 lines
2.7 KiB
C++
77 lines
2.7 KiB
C++
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
// Official git repository and contact information can be found at
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
#include "Core/HLE/HLE.h"
|
|
#include "Core/HLE/FunctionWrappers.h"
|
|
#include "Core/HLE/sceP3da.h"
|
|
#include "Core/MemMap.h"
|
|
#include "Core/Reporting.h"
|
|
|
|
static u32 sceP3daBridgeInit(u32 channelsNum, u32 samplesNum) {
|
|
WARN_LOG(Log::sceAudio, "UNIMPL sceP3daBridgeInit(%08x, %08x)", channelsNum, samplesNum);
|
|
return hleNoLog(0);
|
|
}
|
|
|
|
static u32 sceP3daBridgeExit() {
|
|
WARN_LOG(Log::sceAudio, "UNIMPL sceP3daBridgeExit()");
|
|
return hleNoLog(0);
|
|
}
|
|
|
|
// Isn't this just a log2?
|
|
static inline int getScaleValue(u32 channelsNum) {
|
|
int val = 0;
|
|
while (channelsNum > 1) {
|
|
channelsNum >>= 1;
|
|
val++;
|
|
}
|
|
return val;
|
|
}
|
|
|
|
// What is this??
|
|
static u32 sceP3daBridgeCore(u32 p3daCoreAddr, u32 channelsNum, u32 samplesNum, u32 inputAddr, u32 outputAddr) {
|
|
// The sizes could wrap in 32 bits.
|
|
if ((u64)channelsNum * 4 <= 0xFFFFFFFF && (u64)samplesNum * sizeof(s16) * 2 <= 0xFFFFFFFF &&
|
|
Memory::IsValidRange(inputAddr, channelsNum * 4) && Memory::IsValidRange(outputAddr, samplesNum * sizeof(s16) * 2)) {
|
|
int scaleval = getScaleValue(channelsNum);
|
|
s16_le *outbuf = (s16_le *)Memory::GetPointerWriteUnchecked(outputAddr);
|
|
memset(outbuf, 0, samplesNum * sizeof(s16) * 2);
|
|
for (u32 k = 0; k < channelsNum; k++) {
|
|
u32 inaddr = Memory::ReadUnchecked_U32(inputAddr + k * 4);
|
|
const s16 *inbuf = (const s16 *)Memory::GetPointerUnchecked(inaddr);
|
|
if (!inbuf)
|
|
continue;
|
|
for (u32 i = 0; i < samplesNum; i++) {
|
|
s16 sample = inbuf[i] >> scaleval;
|
|
outbuf[i*2] += sample;
|
|
outbuf[i*2 + 1] += sample;
|
|
}
|
|
}
|
|
}
|
|
// same as sas core
|
|
return hleDelayResult(hleLogDebug(Log::sceAudio, 0), "p3da core", 240);
|
|
}
|
|
|
|
const HLEFunction sceP3da[] = {
|
|
{0X374500A5, &WrapU_UU<sceP3daBridgeInit>, "sceP3daBridgeInit", 'x', "xx" },
|
|
{0X43F756A2, &WrapU_V<sceP3daBridgeExit>, "sceP3daBridgeExit", 'x', "" },
|
|
{0X013016F3, &WrapU_UUUUU<sceP3daBridgeCore>, "sceP3daBridgeCore", 'x', "xxxxx"},
|
|
};
|
|
|
|
void Register_sceP3da() {
|
|
RegisterHLEModule("sceP3da", ARRAY_SIZE(sceP3da), sceP3da);
|
|
}
|