mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-30 01:33:45 +01:00
Rename the get-memory-pointer functions to make it clear where CPU exceptions can happen.
This commit is contained in:
1 parent
e9a3449ede
commit
c5e4d0d90d
53 files changed
+224
-224
No files matched your search
@@ -265,11 +265,11 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
||||
}
|
||||
if (reqsz > 0) {
|
||||
if (hleCall(sceNetAdhocctl, int, sceNetAdhocctlGetScanInfo, scanInfosAddr, scanInfosAddr + (u32)sizeof(s32)) >= 0) {
|
||||
ScanInfos* scanInfos = (ScanInfos*)Memory::GetPointer(scanInfosAddr);
|
||||
ScanInfos* scanInfos = (ScanInfos*)Memory::GetPointerOrException(scanInfosAddr);
|
||||
int n = scanInfos->sz / sizeof(SceNetAdhocctlScanInfoEmu);
|
||||
// Assuming returned SceNetAdhocctlScanInfoEmu(s) are contiguous where next is pointing to current addr + sizeof(SceNetAdhocctlScanInfoEmu)
|
||||
while (n > 0) {
|
||||
SceNetAdhocctlScanInfoEmu* si = (SceNetAdhocctlScanInfoEmu*)Memory::GetPointer(scanInfosAddr + sizeof(s32) + sizeof(SceNetAdhocctlScanInfoEmu) * (n - 1LL));
|
||||
SceNetAdhocctlScanInfoEmu* si = (SceNetAdhocctlScanInfoEmu*)Memory::GetPointerOrException(scanInfosAddr + sizeof(s32) + sizeof(SceNetAdhocctlScanInfoEmu) * (n - 1LL));
|
||||
if (memcmp(si->group_name.data, request.NetconfData->groupName, ADHOCCTL_GROUPNAME_LEN) == 0) {
|
||||
// Moving found group info to the front so we can use it on sceNetAdhocctlJoin easily
|
||||
memcpy((char*)scanInfos + sizeof(s32), si, sizeof(SceNetAdhocctlScanInfoEmu));
|
||||
|
||||
@@ -678,7 +678,7 @@ int PSPSaveDialog::Update(int animSpeed) {
|
||||
// Check if it has changed, reload it.
|
||||
// TODO: Cut down on preloading? This rebuilds the list from scratch.
|
||||
int size = std::min((u32)sizeof(originalRequest), Memory::ReadUnchecked_U32(requestAddr));
|
||||
const u8 *updatedRequest = Memory::GetPointerRange(requestAddr, size);
|
||||
const u8 *updatedRequest = Memory::GetPointerRangeOrException(requestAddr, size);
|
||||
if (updatedRequest && memcmp(updatedRequest, &originalRequest, size) != 0) {
|
||||
memset(&request, 0, sizeof(request));
|
||||
Memory::Memcpy(&request, requestAddr, size);
|
||||
|
||||
@@ -544,7 +544,7 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) {
|
||||
}
|
||||
const u32 srcSize = p->p_filesz;
|
||||
const u32 dstSize = p->p_memsz; // can be bigger than size-in-file (p_filesz), we'll zero the rest below. But cannot be smaller!
|
||||
u8 *dst = Memory::GetPointerWriteRange(writeAddr, dstSize);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(writeAddr, dstSize);
|
||||
if (dst) {
|
||||
if (srcSize < dstSize) {
|
||||
memset(dst + srcSize, 0, dstSize - srcSize); // zero out the rest of the segment, this also applies to bss (which is all-zero)
|
||||
|
||||
@@ -455,7 +455,7 @@ int ISOFileSystem::Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outd
|
||||
} else {
|
||||
int block = (u16)desc.firstLETableSector;
|
||||
u32 size = Memory::ClampValidSizeAt(outdataPtr, (u32)desc.pathTableLength);
|
||||
u8 *out = Memory::GetPointerWriteRange(outdataPtr, size);
|
||||
u8 *out = Memory::GetPointerWriteRangeOrException(outdataPtr, size);
|
||||
|
||||
int blocks = size / blockDevice->GetBlockSize();
|
||||
blockDevice->ReadBlocks(block, blocks, out);
|
||||
|
||||
@@ -165,7 +165,7 @@ void Atrac::ResetData() {
|
||||
}
|
||||
|
||||
u8 *Atrac::BufferStart() {
|
||||
return ignoreDataBuf_ ? Memory::GetPointerWrite(first_.addr) : dataBuf_;
|
||||
return ignoreDataBuf_ ? Memory::GetPointerWriteOrException(first_.addr) : dataBuf_;
|
||||
}
|
||||
|
||||
AtracBase::~AtracBase() {
|
||||
|
||||
@@ -863,7 +863,7 @@ u32 Atrac2::DecodeInternal(u32 outbufAddr, int *SamplesNum, int *finish) {
|
||||
}
|
||||
outPtr = decodeTemp_;
|
||||
} else {
|
||||
outPtr = outbufAddr ? (int16_t *)Memory::GetPointer(outbufAddr) : 0; // outbufAddr can be 0 during skip!
|
||||
outPtr = outbufAddr ? (int16_t *)Memory::GetPointerOrException(outbufAddr) : 0; // outbufAddr can be 0 during skip!
|
||||
}
|
||||
|
||||
context_->codec.inBuf = inAddr;
|
||||
@@ -899,7 +899,7 @@ u32 Atrac2::DecodeInternal(u32 outbufAddr, int *SamplesNum, int *finish) {
|
||||
} else {
|
||||
*finish = 0;
|
||||
}
|
||||
u8 *outBuf = outbufAddr ? Memory::GetPointerWrite(outbufAddr) : nullptr;
|
||||
u8 *outBuf = outbufAddr ? Memory::GetPointerWriteOrException(outbufAddr) : nullptr;
|
||||
if (samplesToDecode != info.SamplesPerFrame() && samplesToDecode != 0 && outBuf) {
|
||||
memcpy(outBuf, decodeTemp_, samplesToDecode * outputChannels_ * sizeof(int16_t));
|
||||
}
|
||||
@@ -958,8 +958,8 @@ u32 Atrac2::DecodeInternal(u32 outbufAddr, int *SamplesNum, int *finish) {
|
||||
size_t copyLen = info.secondBufferByte % info.sampleSize;
|
||||
if (copyLen > info.bufferByte)
|
||||
copyLen = info.bufferByte;
|
||||
memcpy(Memory::GetPointerWrite(info.buffer),
|
||||
Memory::GetPointer(info.secondBuffer + (info.secondBufferByte - info.secondBufferByte % info.sampleSize)),
|
||||
memcpy(Memory::GetPointerWriteOrException(info.buffer),
|
||||
Memory::GetPointerOrException(info.secondBuffer + (info.secondBufferByte - info.secondBufferByte % info.sampleSize)),
|
||||
copyLen);
|
||||
}
|
||||
}
|
||||
@@ -1214,7 +1214,7 @@ void Atrac2::DecodeForSas(s16 *dstData, int *bytesWritten, int *finish) {
|
||||
// Keep decoding from the current buffer until it runs out.
|
||||
if (sas_.streamOffset + (int)info.sampleSize <= (int)sas_.bufSize[sas_.curBuffer]) {
|
||||
// Just decode.
|
||||
const u8 *srcData = Memory::GetPointer(sas_.bufPtr[sas_.curBuffer] + sas_.streamOffset);
|
||||
const u8 *srcData = Memory::GetPointerOrException(sas_.bufPtr[sas_.curBuffer] + sas_.streamOffset);
|
||||
int bytesConsumed = 0;
|
||||
bool decodeResult = decoder_->Decode(srcData, info.sampleSize, &bytesConsumed, 1, dstData, bytesWritten);
|
||||
if (!decodeResult) {
|
||||
|
||||
+11
-11
@@ -106,7 +106,7 @@ template<u32 func()> void WrapU_V() {
|
||||
}
|
||||
|
||||
template<u32 func(int, void *, int)> void WrapU_IVI() {
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWrite(PARAM(1)), PARAM(2));
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWriteOrException(PARAM(1)), PARAM(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ template<int func(const char *, int, int, u32)> void WrapI_CIIU() {
|
||||
}
|
||||
|
||||
template<int func(int, const char *, u32, void *, void *, u32, int)> void WrapI_ICUVVUI() {
|
||||
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointerWrite(PARAM(3)),Memory::GetPointerWrite(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointerWriteOrException(PARAM(3)),Memory::GetPointerWriteOrException(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
@@ -147,13 +147,13 @@ template<int func(int, int, int, int, int, int, u32)> void WrapI_IIIIIIU() {
|
||||
|
||||
// Hm, do so many params get passed in registers?
|
||||
template<int func(int, int, int, int, int, int, int, int, u32)> void WrapI_IIIIIIIIU() {
|
||||
u32 param8 = *(const u32_le *)Memory::GetPointerWrite(currentMIPS->r[29]); //Fixed 9th parameter, thanks to Kingcom
|
||||
u32 param8 = *(const u32_le *)Memory::GetPointerWriteOrException(currentMIPS->r[29]); //Fixed 9th parameter, thanks to Kingcom
|
||||
u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6), PARAM(7), param8);
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(int, void *)> void WrapU_IV() {
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWrite(PARAM(1)));
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWriteOrException(PARAM(1)));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
@@ -881,27 +881,27 @@ template <int func(int, const char *, int)> void WrapI_ICI() {
|
||||
}
|
||||
|
||||
template<int func(int, void *, void *, void *, void *, u32, int)> void WrapI_IVVVVUI(){
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWrite(PARAM(1)), Memory::GetPointerWrite(PARAM(2)), Memory::GetPointerWrite(PARAM(3)), Memory::GetPointerWrite(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
u32 retval = func(PARAM(0), Memory::GetPointerWriteOrException(PARAM(1)), Memory::GetPointerWriteOrException(PARAM(2)), Memory::GetPointerWriteOrException(PARAM(3)), Memory::GetPointerWriteOrException(PARAM(4)), PARAM(5), PARAM(6) );
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(int, const char *, u32, void *, int, int, int)> void WrapI_ICUVIII(){
|
||||
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointerWrite(PARAM(3)), PARAM(4), PARAM(5), PARAM(6));
|
||||
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointerWriteOrException(PARAM(3)), PARAM(4), PARAM(5), PARAM(6));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(void *, u32, int)> void WrapI_VUI(){
|
||||
u32 retval = func(Memory::GetPointerWrite(PARAM(0)), PARAM(1), PARAM(2));
|
||||
u32 retval = func(Memory::GetPointerWriteOrException(PARAM(0)), PARAM(1), PARAM(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(void *, u32, u32)> void WrapU_VUU() {
|
||||
u32 retval = func(Memory::GetPointerWrite(PARAM(0)), PARAM(1), PARAM(2));
|
||||
u32 retval = func(Memory::GetPointerWriteOrException(PARAM(0)), PARAM(1), PARAM(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(void *, const char *)> void WrapU_VC() {
|
||||
u32 retval = func(Memory::GetPointerWrite(PARAM(0)), Memory::GetCharPointer(PARAM(1)));
|
||||
u32 retval = func(Memory::GetPointerWriteOrException(PARAM(0)), Memory::GetCharPointer(PARAM(1)));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
@@ -916,11 +916,11 @@ template<int func(const char *, const char*)> void WrapI_CC() {
|
||||
}
|
||||
|
||||
template<u32 func(void *, const char *, u32)> void WrapU_VCU() {
|
||||
u32 retval = func(Memory::GetPointerWrite(PARAM(0)), Memory::GetCharPointer(PARAM(1)), PARAM(2));
|
||||
u32 retval = func(Memory::GetPointerWriteOrException(PARAM(0)), Memory::GetCharPointer(PARAM(1)), PARAM(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(void *, int)> void WrapU_VI() {
|
||||
u32 retval = func(Memory::GetPointerWrite(PARAM(0)), PARAM(1));
|
||||
u32 retval = func(Memory::GetPointerWriteOrException(PARAM(0)), PARAM(1));
|
||||
RETURN(retval);
|
||||
}
|
||||
+30
-30
@@ -133,8 +133,8 @@ static int Replace_memcpy() {
|
||||
}
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointerWriteRange(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRange(srcPtr, bytes);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRangeOrException(srcPtr, bytes);
|
||||
|
||||
if (!dst || !src) {
|
||||
// Already logged.
|
||||
@@ -200,8 +200,8 @@ static int Replace_memcpy_jak() {
|
||||
sliced = true;
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointerWriteRange(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRange(srcPtr, bytes);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRangeOrException(srcPtr, bytes);
|
||||
|
||||
if (dst && src) {
|
||||
// Jak style overlap.
|
||||
@@ -265,8 +265,8 @@ static int Replace_memcpy16() {
|
||||
}
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointerWriteRange(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRange(srcPtr, bytes);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRangeOrException(srcPtr, bytes);
|
||||
if (dst && src) {
|
||||
memmove(dst, src, bytes);
|
||||
}
|
||||
@@ -290,8 +290,8 @@ static int Replace_memcpy_swizzled() {
|
||||
gpu->PerformReadbackToMemory(srcPtr, pitch * h);
|
||||
}
|
||||
}
|
||||
u8 *dstp = Memory::GetPointerWriteRange(destPtr, pitch * h);
|
||||
const u8 *srcp = Memory::GetPointerRange(srcPtr, pitch * h);
|
||||
u8 *dstp = Memory::GetPointerWriteRangeOrException(destPtr, pitch * h);
|
||||
const u8 *srcp = Memory::GetPointerRangeOrException(srcPtr, pitch * h);
|
||||
|
||||
if (dstp && srcp) {
|
||||
const u8 *ysrcp = srcp;
|
||||
@@ -333,8 +333,8 @@ static int Replace_memmove() {
|
||||
}
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointerWriteRange(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRange(srcPtr, bytes);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(destPtr, bytes);
|
||||
const u8 *src = Memory::GetPointerRangeOrException(srcPtr, bytes);
|
||||
if (dst && src) {
|
||||
memmove(dst, src, bytes);
|
||||
}
|
||||
@@ -357,7 +357,7 @@ static int Replace_memset() {
|
||||
skip = gpu->PerformMemorySet(destPtr, value, bytes);
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointerWriteRange(destPtr, bytes);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(destPtr, bytes);
|
||||
if (dst) {
|
||||
memset(dst, value, bytes);
|
||||
}
|
||||
@@ -391,7 +391,7 @@ static int Replace_memset_jak() {
|
||||
sliced = true;
|
||||
}
|
||||
if (!skip && bytes != 0) {
|
||||
u8 *dst = Memory::GetPointerWriteRange(destPtr, bytes);
|
||||
u8 *dst = Memory::GetPointerWriteRangeOrException(destPtr, bytes);
|
||||
if (dst) {
|
||||
memset(dst, value, bytes);
|
||||
}
|
||||
@@ -419,7 +419,7 @@ static int Replace_memset_jak() {
|
||||
|
||||
static uint32_t SafeStringLen(const uint32_t ptr, uint32_t maxLen = 0x07FFFFFF) {
|
||||
maxLen = Memory::ClampValidSizeAt(ptr, 0x07FFFFFF);
|
||||
const uint8_t *p = Memory::GetPointerRange(ptr, maxLen);
|
||||
const uint8_t *p = Memory::GetPointerRangeOrException(ptr, maxLen);
|
||||
if (!p)
|
||||
return 0;
|
||||
const uint8_t *end = (const uint8_t *)memchr(p, '\0', maxLen);
|
||||
@@ -439,8 +439,8 @@ static int Replace_strcpy() {
|
||||
u32 destPtr = PARAM(0);
|
||||
u32 srcPtr = PARAM(1);
|
||||
u32 len = SafeStringLen(srcPtr);
|
||||
char *dst = (char *)Memory::GetPointerWriteRange(destPtr, len);
|
||||
const char *src = (const char *)Memory::GetPointerRange(srcPtr, len);
|
||||
char *dst = (char *)Memory::GetPointerWriteRangeOrException(destPtr, len);
|
||||
const char *src = (const char *)Memory::GetPointerRangeOrException(srcPtr, len);
|
||||
if (dst && src && len != 0) {
|
||||
strcpy(dst, src);
|
||||
}
|
||||
@@ -452,9 +452,9 @@ static int Replace_strncpy() {
|
||||
u32 destPtr = PARAM(0);
|
||||
u32 srcPtr = PARAM(1);
|
||||
u32 bytes = PARAM(2);
|
||||
char *dst = (char *)Memory::GetPointerRange(destPtr, bytes);
|
||||
char *dst = (char *)Memory::GetPointerRangeOrException(destPtr, bytes);
|
||||
u32 srcLen = SafeStringLen(srcPtr, bytes);
|
||||
const char *src = (const char *)Memory::GetPointerRange(srcPtr, srcLen == 0 ? bytes : srcLen);
|
||||
const char *src = (const char *)Memory::GetPointerRangeOrException(srcPtr, srcLen == 0 ? bytes : srcLen);
|
||||
if (dst && src && bytes != 0) {
|
||||
strncpy(dst, src, bytes);
|
||||
}
|
||||
@@ -464,9 +464,9 @@ static int Replace_strncpy() {
|
||||
|
||||
static int Replace_strcmp() {
|
||||
u32 aLen = SafeStringLen(PARAM(0));
|
||||
const char *a = (const char *)Memory::GetPointerRange(PARAM(0), aLen);
|
||||
const char *a = (const char *)Memory::GetPointerRangeOrException(PARAM(0), aLen);
|
||||
u32 bLen = SafeStringLen(PARAM(1));
|
||||
const char *b = (const char *)Memory::GetPointerRange(PARAM(1), bLen);
|
||||
const char *b = (const char *)Memory::GetPointerRangeOrException(PARAM(1), bLen);
|
||||
if (a && b && aLen != 0 && bLen != 0) {
|
||||
RETURN(strcmp(a, b));
|
||||
} else {
|
||||
@@ -478,9 +478,9 @@ static int Replace_strcmp() {
|
||||
static int Replace_strncmp() {
|
||||
u32 bytes = PARAM(2);
|
||||
u32 aLen = SafeStringLen(PARAM(0), bytes);
|
||||
const char *a = (const char *)Memory::GetPointerRange(PARAM(0), aLen == 0 ? bytes : aLen);
|
||||
const char *a = (const char *)Memory::GetPointerRangeOrException(PARAM(0), aLen == 0 ? bytes : aLen);
|
||||
u32 bLen = SafeStringLen(PARAM(1), bytes);
|
||||
const char *b = (const char *)Memory::GetPointerRange(PARAM(1), bLen == 0 ? bytes : bLen);
|
||||
const char *b = (const char *)Memory::GetPointerRangeOrException(PARAM(1), bLen == 0 ? bytes : bLen);
|
||||
if (a && b && bytes != 0) {
|
||||
RETURN(strncmp(a, b, bytes));
|
||||
} else {
|
||||
@@ -495,9 +495,9 @@ static int Replace_fabsf() {
|
||||
}
|
||||
|
||||
static int Replace_vmmul_q_transp() {
|
||||
float_le *out = (float_le *)Memory::GetPointerRange(PARAM(0), 16 * 4);
|
||||
const float_le *a = (const float_le *)Memory::GetPointerRange(PARAM(1), 16 * 4);
|
||||
const float_le *b = (const float_le *)Memory::GetPointerRange(PARAM(2), 16 * 4);
|
||||
float_le *out = (float_le *)Memory::GetPointerRangeOrException(PARAM(0), 16 * 4);
|
||||
const float_le *a = (const float_le *)Memory::GetPointerRangeOrException(PARAM(1), 16 * 4);
|
||||
const float_le *b = (const float_le *)Memory::GetPointerRangeOrException(PARAM(2), 16 * 4);
|
||||
|
||||
// TODO: Actually use an optimized matrix multiply here...
|
||||
if (out && b && a) {
|
||||
@@ -522,8 +522,8 @@ static int Replace_vmmul_q_transp() {
|
||||
// a1 = matrix
|
||||
// a2 = source address
|
||||
static int Replace_gta_dl_write_matrix() {
|
||||
u32_le *ptr = (u32_le *)Memory::GetPointerWriteRange(PARAM(0), 4);
|
||||
const u32_le *src = (const u32_le *)Memory::GetPointerRange(PARAM(2), 16);
|
||||
u32_le *ptr = (u32_le *)Memory::GetPointerWriteRangeOrException(PARAM(0), 4);
|
||||
const u32_le *src = (const u32_le *)Memory::GetPointerRangeOrException(PARAM(2), 16);
|
||||
u32 matrix = PARAM(1) << 24;
|
||||
|
||||
if (!ptr || !src) {
|
||||
@@ -531,7 +531,7 @@ static int Replace_gta_dl_write_matrix() {
|
||||
return 38;
|
||||
}
|
||||
|
||||
u32_le *dest = (u32_le *)Memory::GetPointerWriteRange(ptr[0], 12 * 4);
|
||||
u32_le *dest = (u32_le *)Memory::GetPointerWriteRangeOrException(ptr[0], 12 * 4);
|
||||
if (!dest) {
|
||||
RETURN(0);
|
||||
return 38;
|
||||
@@ -581,8 +581,8 @@ static int Replace_gta_dl_write_matrix() {
|
||||
// TODO: Inline into a few NEON or SSE instructions - especially if a1 is a known immediate!
|
||||
// Anyway, not sure if worth it. There's not that many matrices written per frame normally.
|
||||
static int Replace_dl_write_matrix() {
|
||||
u32_le *dlStruct = (u32_le *)Memory::GetPointerWriteRange(PARAM(0), 3 * 4);
|
||||
const u32_le *src = (const u32_le *)Memory::GetPointerRange(PARAM(2), 16 * 4);
|
||||
u32_le *dlStruct = (u32_le *)Memory::GetPointerWriteRangeOrException(PARAM(0), 3 * 4);
|
||||
const u32_le *src = (const u32_le *)Memory::GetPointerRangeOrException(PARAM(2), 16 * 4);
|
||||
|
||||
if (!dlStruct || !src) {
|
||||
RETURN(0);
|
||||
@@ -607,7 +607,7 @@ static int Replace_dl_write_matrix() {
|
||||
break;
|
||||
}
|
||||
|
||||
u32_le *dest = (u32_le *)Memory::GetPointerWriteRange(dlStruct[2], 4 + count * 4);
|
||||
u32_le *dest = (u32_le *)Memory::GetPointerWriteRangeOrException(dlStruct[2], 4 + count * 4);
|
||||
if (!dest) {
|
||||
RETURN(0);
|
||||
return 60;
|
||||
|
||||
@@ -259,7 +259,7 @@ u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking) {
|
||||
if (chan.format == PSP_AUDIO_FORMAT_STEREO) {
|
||||
const u32 totalSamples = chan.sampleCount * 2;
|
||||
|
||||
s16_le *sampleData = (s16_le *) Memory::GetPointer(chan.sampleAddress);
|
||||
s16_le *sampleData = (s16_le *) Memory::GetPointerOrException(chan.sampleAddress);
|
||||
|
||||
// Walking a pointer for speed. But let's make sure we wouldn't trip on an invalid ptr.
|
||||
if (Memory::IsValidAddress(chan.sampleAddress + (totalSamples - 1) * sizeof(s16_le))) {
|
||||
|
||||
@@ -1202,7 +1202,7 @@ void AfterMatchingMipsCall::run(MipsCall &call) {
|
||||
u32 v0 = currentMIPS->r[MIPS_REG_V0];
|
||||
if (__IsInInterrupt()) ERROR_LOG(Log::sceNet, "AfterMatchingMipsCall::run [ID=%i][Event=%d] is Returning Inside an Interrupt!", contextID, EventID);
|
||||
//SetMatchingInCallback(context, false);
|
||||
DEBUG_LOG(Log::sceNet, "AfterMatchingMipsCall::run [ID=%i][Event=%d][%s] [cbId: %u][retV0: %08x]", contextID, EventID, mac2str((SceNetEtherAddr*)Memory::GetPointer(bufAddr)).c_str(), call.cbId, v0);
|
||||
DEBUG_LOG(Log::sceNet, "AfterMatchingMipsCall::run [ID=%i][Event=%d][%s] [cbId: %u][retV0: %08x]", contextID, EventID, mac2str((SceNetEtherAddr*)Memory::GetPointerOrException(bufAddr)).c_str(), call.cbId, v0);
|
||||
if (Memory::IsValidAddress(bufAddr)) userMemory.Free(bufAddr);
|
||||
//call.setReturnValue(v0);
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ static u32 sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32
|
||||
return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_SIZE_TOO_SMALL);
|
||||
}
|
||||
|
||||
u8 *outPtr = outAddr ? Memory::GetPointerWrite(outAddr) : nullptr;
|
||||
u8 *outPtr = outAddr ? Memory::GetPointerWriteOrException(outAddr) : nullptr;
|
||||
|
||||
int ret = atrac->DecodeData(outPtr, outAddr, &numSamplesWritten, &finish, &remains);
|
||||
if (ret != (int)SCE_ERROR_ATRAC_BAD_ATRACID && ret != (int)SCE_ERROR_ATRAC_NO_DATA) {
|
||||
|
||||
@@ -256,9 +256,9 @@ static int sceAudiocodecDecode(u32 ctxPtr, int codec) {
|
||||
|
||||
DEBUG_LOG(Log::ME, "decoder. in: %08x out: %08x unk40: %02x unk41: %02x", ctx->inBuf, ctx->outBuf, ctx->unk40, ctx->unk41);
|
||||
|
||||
int16_t *outBuf = (int16_t *)Memory::GetPointerWrite(ctx->outBuf);
|
||||
int16_t *outBuf = (int16_t *)Memory::GetPointerWriteOrException(ctx->outBuf);
|
||||
|
||||
bool result = decoder->Decode(Memory::GetPointer(ctx->inBuf), bytesPerFrame, &inDataConsumed, 2, outBuf, &outSamples);
|
||||
bool result = decoder->Decode(Memory::GetPointerOrException(ctx->inBuf), bytesPerFrame, &inDataConsumed, 2, outBuf, &outSamples);
|
||||
if (!result) {
|
||||
ctx->err = 0x20b;
|
||||
ERROR_LOG(Log::ME, "AudioCodec decode failed. Setting error to %08x", ctx->err);
|
||||
|
||||
@@ -218,10 +218,10 @@ static int sub_17A8(KirkState *kirk, u8* data)
|
||||
|
||||
static int sceSdGetLastIndex(u32 addressCtx, u32 addressHash, u32 addressKey) {
|
||||
auto ctx = PSPPointer<pspChnnlsvContext1>::Create(addressCtx);
|
||||
u8 *hash = Memory::GetPointerWrite(addressHash);
|
||||
u8 *hash = Memory::GetPointerWriteOrException(addressHash);
|
||||
if (!ctx.IsValid() || !hash)
|
||||
return hleLogError(Log::sceMisc, 0, "Invalid pointer");
|
||||
return hleLogDebug(Log::sceMisc, sceSdMacFinal(*ctx, hash, Memory::GetPointerWrite(addressKey)));
|
||||
return hleLogDebug(Log::sceMisc, sceSdMacFinal(*ctx, hash, Memory::GetPointerWriteOrException(addressKey)));
|
||||
}
|
||||
|
||||
int sceSdMacFinal(pspChnnlsvContext1& ctx, u8* in_hash, const u8* in_key)
|
||||
@@ -347,7 +347,7 @@ static int sceSdRemoveValue(u32 addressCtx, u32 addressData, int length) {
|
||||
auto ctx = PSPPointer<pspChnnlsvContext1>::Create(addressCtx);
|
||||
if (!ctx.IsValid() || !Memory::IsValidAddress(addressData))
|
||||
return hleLogError(Log::sceMisc, 0, "Invalid pointer");
|
||||
return hleLogDebug(Log::sceMisc, sceSdMacUpdate(*ctx, Memory::GetPointerWrite(addressData), length));
|
||||
return hleLogDebug(Log::sceMisc, sceSdMacUpdate(*ctx, Memory::GetPointerWriteOrException(addressData), length));
|
||||
}
|
||||
|
||||
int sceSdMacUpdate(pspChnnlsvContext1& ctx, const u8* data, int length)
|
||||
@@ -394,8 +394,8 @@ int sceSdMacUpdate(pspChnnlsvContext1& ctx, const u8* data, int length)
|
||||
|
||||
static int sceSdCreateList(u32 ctx2Addr, int mode, int unkwn, u32 dataAddr, u32 cryptkeyAddr) {
|
||||
auto ctx2 = PSPPointer<pspChnnlsvContext2>::Create(ctx2Addr);
|
||||
u8* data = Memory::GetPointerWrite(dataAddr);
|
||||
u8* cryptkey = Memory::GetPointerWrite(cryptkeyAddr);
|
||||
u8* data = Memory::GetPointerWriteOrException(dataAddr);
|
||||
u8* cryptkey = Memory::GetPointerWriteOrException(cryptkeyAddr);
|
||||
if (!ctx2.IsValid() || !data)
|
||||
return hleLogError(Log::sceMisc, 0, "Invalid pointer");
|
||||
|
||||
@@ -458,7 +458,7 @@ int sceSdCipherInit(pspChnnlsvContext2& ctx2, int mode, int uknw, u8* data, cons
|
||||
|
||||
static int sceSdSetMember(u32 ctxAddr, u32 dataAddr, int alignedLen) {
|
||||
auto ctx = PSPPointer<pspChnnlsvContext2>::Create(ctxAddr);
|
||||
u8 *data = Memory::GetPointerWrite(dataAddr);
|
||||
u8 *data = Memory::GetPointerWriteOrException(dataAddr);
|
||||
if (!ctx.IsValid() || !data)
|
||||
return hleLogError(Log::sceMisc, 0, "Invalid pointer");
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ static int CommonDecompress(int windowBits, u32 OutBuffer, int OutBufferLength,
|
||||
}
|
||||
|
||||
z_stream stream{};
|
||||
u8 *outBufferPtr = Memory::GetPointerWrite(OutBuffer);
|
||||
stream.next_in = (Bytef*)Memory::GetPointer(InBuffer);
|
||||
u8 *outBufferPtr = Memory::GetPointerWriteOrException(OutBuffer);
|
||||
stream.next_in = (Bytef*)Memory::GetPointerOrException(InBuffer);
|
||||
// We don't know the available length, just let it use as much as it wants.
|
||||
stream.avail_in = (uInt)Memory::ClampValidSizeAt(InBuffer, Memory::g_MemorySize);
|
||||
stream.next_out = outBufferPtr;
|
||||
|
||||
@@ -1096,7 +1096,7 @@ static u32 sceFontOpenUserMemory(u32 libHandle, u32 memoryFontPtr, u32 memoryFon
|
||||
return hleReportError(Log::sceFont, 0, "invalid size");
|
||||
}
|
||||
|
||||
const u8 *fontData = Memory::GetPointer(memoryFontPtr);
|
||||
const u8 *fontData = Memory::GetPointerOrException(memoryFontPtr);
|
||||
// Games are able to overstate the size of a font. Let's avoid crashing when we memcpy() it.
|
||||
// Unsigned 0xFFFFFFFF is treated as max, but that's impossible, so let's clamp to 64MB.
|
||||
if (memoryFontLength > 0x03FFFFFF)
|
||||
|
||||
+2
-2
@@ -540,7 +540,7 @@ u32 sceGeSaveContext(u32 ctxAddr) {
|
||||
|
||||
// Let's just dump gstate.
|
||||
if (Memory::IsValidAddress(ctxAddr)) {
|
||||
gstate.Save((u32_le *)Memory::GetPointer(ctxAddr));
|
||||
gstate.Save((u32_le *)Memory::GetPointerOrException(ctxAddr));
|
||||
}
|
||||
|
||||
// This action should probably be pushed to the end of the queue of the display thread -
|
||||
@@ -554,7 +554,7 @@ u32 sceGeRestoreContext(u32 ctxAddr) {
|
||||
}
|
||||
|
||||
if (Memory::IsValidAddress(ctxAddr)) {
|
||||
gstate.Restore((u32_le *)Memory::GetPointer(ctxAddr));
|
||||
gstate.Restore((u32_le *)Memory::GetPointerOrException(ctxAddr));
|
||||
}
|
||||
|
||||
gpu->ReapplyGfxState();
|
||||
|
||||
@@ -158,7 +158,7 @@ int HTTPRequest::getAllResponseHeaders(u32 headerAddrPtr, u32 headerSizePtr) {
|
||||
headerSize_ = sz;
|
||||
}
|
||||
|
||||
u8* header = Memory::GetPointerWrite(headerAddr_);
|
||||
u8* header = Memory::GetPointerWriteOrException(headerAddr_);
|
||||
DEBUG_LOG(Log::sceNet, "headerAddr: %08x => %08x", headerAddr.IsValid() ? *headerAddr : 0, headerAddr_);
|
||||
DEBUG_LOG(Log::sceNet, "headerSize: %d => %d", headerSize.IsValid() ? *headerSize : 0, sz);
|
||||
if (!header && sz > 0) {
|
||||
|
||||
+2
-2
@@ -1196,7 +1196,7 @@ static bool __IoWrite(int &result, int id, u32 data_addr, int size, int &us) {
|
||||
us = 100;
|
||||
}
|
||||
|
||||
const void *data_ptr = Memory::GetPointer(data_addr);
|
||||
const void *data_ptr = Memory::GetPointerOrException(data_addr);
|
||||
const u32 validSize = Memory::ClampValidSizeAt(data_addr, size);
|
||||
// Let's handle stdout/stderr specially.
|
||||
if (id == PSP_STDOUT || id == PSP_STDERR) {
|
||||
@@ -2522,7 +2522,7 @@ static u32 sceIoDread(int id, u32 dirent_addr) {
|
||||
Core_MemoryException(dirent_addr, sizeof(SceIoDirEnt), currentMIPS->pc, MemoryExceptionType::WRITE_BLOCK, "sceIoDread");
|
||||
return hleLogError(Log::sceIo, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid address");
|
||||
}
|
||||
SceIoDirEnt *entry = (SceIoDirEnt*) Memory::GetPointer(dirent_addr);
|
||||
SceIoDirEnt *entry = (SceIoDirEnt*) Memory::GetPointerOrException(dirent_addr);
|
||||
|
||||
if (dir->index == (int) dir->listing.size()) {
|
||||
entry->d_name[0] = '\0';
|
||||
|
||||
@@ -396,7 +396,7 @@ static int JpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr) {
|
||||
}
|
||||
|
||||
#ifdef JPEG_DEBUG
|
||||
const u8 *jpegDumpBuf = Memory::GetPointer(jpegAddr);
|
||||
const u8 *jpegDumpBuf = Memory::GetPointerOrException(jpegAddr);
|
||||
u32 jpeg_xxhash = XXH32((const char *)jpegDumpBuf, jpegSize, 0xC0108888);
|
||||
Path jpegDir("Jpeg");
|
||||
Path jpegFile = jpegDir / StringFromFormat("%X.jpg", jpeg_xxhash);
|
||||
|
||||
@@ -927,7 +927,7 @@ static bool KernelImportModuleFuncs(PSPModule *module, u32 *firstImportStubAddr,
|
||||
|
||||
if (needReport) {
|
||||
std::string debugInfo;
|
||||
entryPos = (const u32_le *)Memory::GetPointer(module->libstub);
|
||||
entryPos = (const u32_le *)Memory::GetPointerOrException(module->libstub);
|
||||
while (entryPos < entryEnd) {
|
||||
const PspLibStubEntry *entry = (const PspLibStubEntry *)entryPos;
|
||||
entryPos += entry->size;
|
||||
@@ -1453,8 +1453,8 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load
|
||||
module->nm.stub_top = modinfo->libstub;
|
||||
module->nm.stub_size = modinfo->libstubend - modinfo->libstub;
|
||||
|
||||
const u32_le *entPos = (u32_le *)Memory::GetPointer(modinfo->libent);
|
||||
const u32_le *entEnd = (u32_le *)Memory::GetPointer(modinfo->libentend);
|
||||
const u32_le *entPos = (u32_le *)Memory::GetPointerOrException(modinfo->libent);
|
||||
const u32_le *entEnd = (u32_le *)Memory::GetPointerOrException(modinfo->libentend);
|
||||
|
||||
for (int m = 0; entPos < entEnd; ++m) {
|
||||
const PspLibEntEntry *ent = (const PspLibEntEntry *)entPos;
|
||||
@@ -2017,7 +2017,7 @@ u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) {
|
||||
}
|
||||
const SceKernelLMOption *lmoption = 0;
|
||||
if (optionAddr) {
|
||||
lmoption = (const SceKernelLMOption *)Memory::GetPointer(optionAddr);
|
||||
lmoption = (const SceKernelLMOption *)Memory::GetPointerOrException(optionAddr);
|
||||
if (lmoption->position < PSP_SMEM_Low || lmoption->position > PSP_SMEM_HighAligned) {
|
||||
ERROR_LOG_REPORT(Log::Loader, "sceKernelLoadModule(%s): invalid position (%i)", name, (int)lmoption->position);
|
||||
return hleDelayResult(SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCKTYPE, "module loaded", 500);
|
||||
@@ -2486,7 +2486,7 @@ static u32 sceKernelLoadModuleByID(u32 id, u32 flags, u32 lmoptionPtr) {
|
||||
}
|
||||
const SceKernelLMOption *lmoption = 0;
|
||||
if (lmoptionPtr) {
|
||||
lmoption = (const SceKernelLMOption *)Memory::GetPointer(lmoptionPtr);
|
||||
lmoption = (const SceKernelLMOption *)Memory::GetPointerOrException(lmoptionPtr);
|
||||
WARN_LOG_REPORT(Log::Loader, "sceKernelLoadModuleByID: unsupported options size=%08x, flags=%08x, pos=%d, access=%d, data=%d, text=%d", lmoption->size, lmoption->flags, lmoption->position, lmoption->access, lmoption->mpiddata, lmoption->mpidtext);
|
||||
}
|
||||
u32 pos = (u32)pspFileSystem.SeekFile(handle, 0, FILEMOVE_CURRENT);
|
||||
@@ -2547,7 +2547,7 @@ SceUID sceKernelLoadModuleBufferUsbWlan(u32 size, u32 bufPtr, u32 flags, u32 lmo
|
||||
}
|
||||
const SceKernelLMOption *lmoption = 0;
|
||||
if (lmoptionPtr) {
|
||||
lmoption = (const SceKernelLMOption *)Memory::GetPointer(lmoptionPtr);
|
||||
lmoption = (const SceKernelLMOption *)Memory::GetPointerOrException(lmoptionPtr);
|
||||
WARN_LOG_REPORT(Log::Loader, "sceKernelLoadModuleBufferUsbWlan: unsupported options size=%08x, flags=%08x, pos=%d, access=%d, data=%d, text=%d", lmoption->size, lmoption->flags, lmoption->position, lmoption->access, lmoption->mpiddata, lmoption->mpidtext);
|
||||
}
|
||||
std::string error_string;
|
||||
@@ -2559,7 +2559,7 @@ SceUID sceKernelLoadModuleBufferUsbWlan(u32 size, u32 bufPtr, u32 flags, u32 lmo
|
||||
char fakeDebugFilename[512];
|
||||
snprintf(fakeDebugFilename, sizeof(fakeDebugFilename), "moduleByPtr_%08x_%d", bufPtr, (int)size);
|
||||
|
||||
module = __KernelLoadELFFromPtr(Memory::GetPointer(bufPtr), size, 0, lmoption ? lmoption->position == PSP_SMEM_High : false, &error_string, &magic, fakeDebugFilename, error);
|
||||
module = __KernelLoadELFFromPtr(Memory::GetPointerOrException(bufPtr), size, 0, lmoption ? lmoption->position == PSP_SMEM_High : false, &error_string, &magic, fakeDebugFilename, error);
|
||||
|
||||
if (!module) {
|
||||
// Some games try to load strange stuff as PARAM.SFO as modules and expect it to fail.
|
||||
|
||||
@@ -222,7 +222,7 @@ struct MsgPipe : public KernelObject
|
||||
// Receive as much as possible, even if it's not enough to wake up.
|
||||
u32 bytesToSend = std::min(thread->freeSize, GetUsedSize());
|
||||
|
||||
u8* ptr = Memory::GetPointerWrite(buffer);
|
||||
u8* ptr = Memory::GetPointerWriteOrException(buffer);
|
||||
thread->WriteBuffer(buffer, bytesToSend);
|
||||
// Put the unused data at the start of the buffer.
|
||||
nmp.freeSize += bytesToSend;
|
||||
@@ -496,7 +496,7 @@ static int __KernelReceiveMsgPipe(MsgPipe *m, u32 receiveBufAddr, u32 receiveSiz
|
||||
{
|
||||
Memory::Memcpy(curReceiveAddr, m->buffer, bytesToReceive, "MsgPipeReceive");
|
||||
m->nmp.freeSize += bytesToReceive;
|
||||
memmove(Memory::GetPointerWrite(m->buffer), Memory::GetPointer(m->buffer) + bytesToReceive, m->GetUsedSize());
|
||||
memmove(Memory::GetPointerWriteOrException(m->buffer), Memory::GetPointerOrException(m->buffer) + bytesToReceive, m->GetUsedSize());
|
||||
curReceiveAddr += bytesToReceive;
|
||||
receiveSize -= bytesToReceive;
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ u32 sceKernelLibcGettimeofday(u32 timeAddr, u32 tzAddr)
|
||||
// TODO: tzAddr?
|
||||
if (Memory::IsValidAddress(timeAddr))
|
||||
{
|
||||
PSPTimeval *tv = (PSPTimeval *)Memory::GetPointer(timeAddr);
|
||||
PSPTimeval *tv = (PSPTimeval *)Memory::GetPointerOrException(timeAddr);
|
||||
__RtcTimeOfDay(tv);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ u32 sceKernelUtilsMt19937Init(u32 ctx, u32 seed) {
|
||||
DEBUG_LOG(Log::HLE, "sceKernelUtilsMt19937Init(%08x, %08x)", ctx, seed);
|
||||
if (!Memory::IsValidAddress(ctx))
|
||||
return -1;
|
||||
void *ptr = Memory::GetPointerWrite(ctx);
|
||||
void *ptr = Memory::GetPointerWriteOrException(ctx);
|
||||
// This is made to match the memory layout of a PSP MT structure exactly.
|
||||
// Let's just construct it in place with placement new. Elite C++ hackery FTW.
|
||||
new (ptr) MersenneTwister(seed);
|
||||
|
||||
@@ -923,7 +923,7 @@ static bool decodePmpVideo(PSPPointer<SceMpegRingBuffer> ringbuffer, u32 pmpctxA
|
||||
for (int i = 0; i < pmp_nBlocks; i++){
|
||||
auto lli = PSPPointer<SceMpegLLI>::Create(pmp_videoSource);
|
||||
// add source block into pmpframes
|
||||
const uint8_t *ptr = Memory::GetPointerRange(lli->pSrc, lli->iSize);
|
||||
const uint8_t *ptr = Memory::GetPointerRangeOrException(lli->pSrc, lli->iSize);
|
||||
if (ptr)
|
||||
pmpframes->add(ptr, lli->iSize);
|
||||
// get next block
|
||||
@@ -1449,7 +1449,7 @@ void PostPutAction::run(MipsCall &call) {
|
||||
auto demuxer = std::make_unique<MpegDemux>(packetsAddedThisRound * 2048, 0);
|
||||
int readOffset = ringbuffer->packetsRead % (s32)ringbuffer->packets;
|
||||
uint32_t bufSize = Memory::ClampValidSizeAt(ringbuffer->data + readOffset * 2048, packetsAddedThisRound * 2048);
|
||||
const u8 *buf = Memory::GetPointer(ringbuffer->data + readOffset * 2048);
|
||||
const u8 *buf = Memory::GetPointerOrException(ringbuffer->data + readOffset * 2048);
|
||||
bool invalid = false;
|
||||
for (uint32_t i = 0; i < bufSize / 2048; ++i) {
|
||||
demuxer->addStreamData(buf, 2048);
|
||||
@@ -1484,7 +1484,7 @@ void PostPutAction::run(MipsCall &call) {
|
||||
WARN_LOG(Log::Mpeg, "sceMpegRingbufferPut clamping packetsAdded old=%i new=%i", packetsAddedThisRound, ringbuffer->packets - ringbuffer->packetsAvail);
|
||||
packetsAddedThisRound = ringbuffer->packets - ringbuffer->packetsAvail;
|
||||
}
|
||||
const u8 *data = Memory::GetPointer(ringbuffer->data + writeOffset * 2048);
|
||||
const u8 *data = Memory::GetPointerOrException(ringbuffer->data + writeOffset * 2048);
|
||||
uint32_t dataSize = Memory::ClampValidSizeAt(ringbuffer->data + writeOffset * 2048, packetsAddedThisRound * 2048);
|
||||
int actuallyAdded = ctx->mediaengine == NULL ? 8 : ctx->mediaengine->addStreamData(data, dataSize) / 2048;
|
||||
if (actuallyAdded != packetsAddedThisRound) {
|
||||
@@ -2102,7 +2102,7 @@ static int __MpegAvcConvertToYuv420(const void *data, u32 bufferOutputAddr, int
|
||||
u32 *imageBuffer = (u32*)data;
|
||||
int sizeY = width * height;
|
||||
int sizeCb = sizeY >> 2;
|
||||
u8 *Y = Memory::GetPointerWriteRange(bufferOutputAddr, sizeY + sizeCb + sizeCb);
|
||||
u8 *Y = Memory::GetPointerWriteRangeOrException(bufferOutputAddr, sizeY + sizeCb + sizeCb);
|
||||
u8 *Cb = Y + sizeY;
|
||||
u8 *Cr = Cb + sizeCb;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ static u32 sceMt19937UInt(u32 mt19937Addr)
|
||||
{
|
||||
if (!Memory::IsValidAddress(mt19937Addr))
|
||||
return hleLogError(Log::HLE, -1);
|
||||
MersenneTwister *mt = (MersenneTwister *)Memory::GetPointer(mt19937Addr);
|
||||
MersenneTwister *mt = (MersenneTwister *)Memory::GetPointerOrException(mt19937Addr);
|
||||
return hleLogVerbose(Log::HLE, mt->R32());
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1098,7 +1098,7 @@ static void sceNetEtherStrton(u32 bufferPtr, u32 macPtr) {
|
||||
|
||||
if (Memory::IsValidAddress(bufferPtr) && Memory::IsValidAddress(macPtr)) {
|
||||
const char *buffer = (const char *)Memory::GetPointerUnchecked(bufferPtr);
|
||||
u8 *mac = Memory::GetPointerWrite(macPtr);
|
||||
u8 *mac = Memory::GetPointerWriteOrException(macPtr);
|
||||
|
||||
// MAC address is always 6 pairs of hex digits.
|
||||
// TODO: Funny stuff happens if it's too short.
|
||||
@@ -1124,7 +1124,7 @@ static void sceNetEtherStrton(u32 bufferPtr, u32 macPtr) {
|
||||
}
|
||||
}
|
||||
|
||||
VERBOSE_LOG(Log::sceNet, "sceNetEtherStrton - [%s]", mac2str((SceNetEtherAddr*)Memory::GetPointer(macPtr)).c_str());
|
||||
VERBOSE_LOG(Log::sceNet, "sceNetEtherStrton - [%s]", mac2str((SceNetEtherAddr*)Memory::GetPointerOrException(macPtr)).c_str());
|
||||
// Seems to maybe kinda return the last value. Probably returns void.
|
||||
//return value;
|
||||
}
|
||||
|
||||
+21
-21
@@ -2986,7 +2986,7 @@ int sceNetAdhocPollSocket(u32 socketStructAddr, int count, int timeout, int nonb
|
||||
if (netAdhocInited)
|
||||
{
|
||||
SceNetAdhocPollSd * sds = NULL;
|
||||
if (Memory::IsValidAddress(socketStructAddr)) sds = (SceNetAdhocPollSd *)Memory::GetPointer(socketStructAddr);
|
||||
if (Memory::IsValidAddress(socketStructAddr)) sds = (SceNetAdhocPollSd *)Memory::GetPointerOrException(socketStructAddr);
|
||||
|
||||
// Valid Arguments
|
||||
if (sds != NULL && count > 0)
|
||||
@@ -3201,11 +3201,11 @@ int sceNetAdhocctlScan() {
|
||||
int sceNetAdhocctlGetScanInfo(u32 sizeAddr, u32 bufAddr) {
|
||||
s32_le *buflen = NULL;
|
||||
if (Memory::IsValidAddress(sizeAddr)) {
|
||||
buflen = (s32_le *)Memory::GetPointer(sizeAddr);
|
||||
buflen = (s32_le *)Memory::GetPointerOrException(sizeAddr);
|
||||
}
|
||||
SceNetAdhocctlScanInfoEmu *buf = NULL;
|
||||
if (Memory::IsValidAddress(bufAddr)) {
|
||||
buf = (SceNetAdhocctlScanInfoEmu *)Memory::GetPointer(bufAddr);
|
||||
buf = (SceNetAdhocctlScanInfoEmu *)Memory::GetPointerOrException(bufAddr);
|
||||
}
|
||||
|
||||
INFO_LOG(Log::sceNet, "sceNetAdhocctlGetScanInfo([%08x]=%i, %08x) at %08x", sizeAddr, Memory::ReadUnchecked_U32(sizeAddr), bufAddr, currentMIPS->pc);
|
||||
@@ -3518,7 +3518,7 @@ static int sceNetAdhocctlGetNameByAddr(const char *mac, u32 nameAddr) {
|
||||
// Valid Arguments
|
||||
if (mac != NULL && Memory::IsValidAddress(nameAddr))
|
||||
{
|
||||
SceNetAdhocctlNickname * nickname = (SceNetAdhocctlNickname *)Memory::GetPointer(nameAddr);
|
||||
SceNetAdhocctlNickname * nickname = (SceNetAdhocctlNickname *)Memory::GetPointerOrException(nameAddr);
|
||||
// Get Local MAC Address
|
||||
SceNetEtherAddr localmac;
|
||||
getLocalMac(&localmac);
|
||||
@@ -3584,7 +3584,7 @@ int sceNetAdhocctlGetPeerInfo(const char *mac, int size, u32 peerInfoAddr) {
|
||||
SceNetEtherAddr * maddr = (SceNetEtherAddr *)mac;
|
||||
SceNetAdhocctlPeerInfoEmu * buf = NULL;
|
||||
if (Memory::IsValidAddress(peerInfoAddr)) {
|
||||
buf = (SceNetAdhocctlPeerInfoEmu *)Memory::GetPointer(peerInfoAddr);
|
||||
buf = (SceNetAdhocctlPeerInfoEmu *)Memory::GetPointerOrException(peerInfoAddr);
|
||||
}
|
||||
// Library initialized
|
||||
if (netAdhocctlInited) {
|
||||
@@ -3755,7 +3755,7 @@ int sceNetAdhocctlJoin(u32 scanInfoAddr) {
|
||||
// Valid Argument
|
||||
if (Memory::IsValidAddress(scanInfoAddr))
|
||||
{
|
||||
SceNetAdhocctlScanInfoEmu* sinfo = (SceNetAdhocctlScanInfoEmu*)Memory::GetPointer(scanInfoAddr);
|
||||
SceNetAdhocctlScanInfoEmu* sinfo = (SceNetAdhocctlScanInfoEmu*)Memory::GetPointerOrException(scanInfoAddr);
|
||||
char grpName[ADHOCCTL_GROUPNAME_LEN + 1] = { 0 };
|
||||
memcpy(grpName, sinfo->group_name.data, ADHOCCTL_GROUPNAME_LEN); // For logging purpose, must not be truncated
|
||||
DEBUG_LOG(Log::sceNet, "sceNetAdhocctlJoin - Group: %s", grpName);
|
||||
@@ -3943,9 +3943,9 @@ static int sceNetAdhocGetPdpStat(u32 structSize, u32 structAddr) {
|
||||
if (netAdhocInited)
|
||||
{
|
||||
s32_le *buflen = NULL;
|
||||
if (Memory::IsValidAddress(structSize)) buflen = (s32_le *)Memory::GetPointer(structSize);
|
||||
if (Memory::IsValidAddress(structSize)) buflen = (s32_le *)Memory::GetPointerOrException(structSize);
|
||||
SceNetAdhocPdpStat *buf = NULL;
|
||||
if (Memory::IsValidAddress(structAddr)) buf = (SceNetAdhocPdpStat *)Memory::GetPointer(structAddr);
|
||||
if (Memory::IsValidAddress(structAddr)) buf = (SceNetAdhocPdpStat *)Memory::GetPointerOrException(structAddr);
|
||||
|
||||
// Socket Count
|
||||
int socketcount = getPDPSocketCount();
|
||||
@@ -4049,9 +4049,9 @@ static int sceNetAdhocGetPtpStat(u32 structSize, u32 structAddr) {
|
||||
VERBOSE_LOG(Log::sceNet,"sceNetAdhocGetPtpStat(%08x, %08x) at %08x",structSize,structAddr,currentMIPS->pc);
|
||||
|
||||
s32_le *buflen = NULL;
|
||||
if (Memory::IsValidAddress(structSize)) buflen = (s32_le *)Memory::GetPointer(structSize);
|
||||
if (Memory::IsValidAddress(structSize)) buflen = (s32_le *)Memory::GetPointerOrException(structSize);
|
||||
SceNetAdhocPtpStat *buf = NULL;
|
||||
if (Memory::IsValidAddress(structAddr)) buf = (SceNetAdhocPtpStat *)Memory::GetPointer(structAddr);
|
||||
if (Memory::IsValidAddress(structAddr)) buf = (SceNetAdhocPtpStat *)Memory::GetPointerOrException(structAddr);
|
||||
|
||||
// Library is initialized
|
||||
if (netAdhocInited) {
|
||||
@@ -4637,7 +4637,7 @@ static int sceNetAdhocPtpAccept(int id, u32 peerMacAddrPtr, u32 peerPortPtr, int
|
||||
}
|
||||
uint16_t * port = NULL; //
|
||||
if (Memory::IsValidAddress(peerPortPtr)) {
|
||||
port = (uint16_t *)Memory::GetPointer(peerPortPtr);
|
||||
port = (uint16_t *)Memory::GetPointerOrException(peerPortPtr);
|
||||
}
|
||||
if (flag == 0) { // Prevent spamming Debug Log with retries of non-bocking socket
|
||||
DEBUG_LOG(Log::sceNet, "sceNetAdhocPtpAccept(%d, [%08x]=%s, [%08x]=%u, %d, %u) at %08x", id, peerMacAddrPtr, mac2str(addr).c_str(), peerPortPtr, port ? *port : -1, timeout, flag, currentMIPS->pc);
|
||||
@@ -5211,7 +5211,7 @@ static int sceNetAdhocPtpListen(const char *srcmac, int sport, int bufsize, int
|
||||
static int sceNetAdhocPtpSend(int id, u32 dataAddr, u32 dataSizeAddr, int timeout, int flag) {
|
||||
DEBUG_LOG(Log::sceNet, "sceNetAdhocPtpSend(%d,%08x,%08x,%d,%d) at %08x", id, dataAddr, dataSizeAddr, timeout, flag, currentMIPS->pc);
|
||||
|
||||
int * len = (int *)Memory::GetPointer(dataSizeAddr);
|
||||
int * len = (int *)Memory::GetPointerOrException(dataSizeAddr);
|
||||
const char * data = Memory::GetCharPointer(dataAddr);
|
||||
// Library is initialized
|
||||
if (netAdhocInited) {
|
||||
@@ -5331,8 +5331,8 @@ static int sceNetAdhocPtpSend(int id, u32 dataAddr, u32 dataSizeAddr, int timeou
|
||||
static int sceNetAdhocPtpRecv(int id, u32 dataAddr, u32 dataSizeAddr, int timeout, int flag) {
|
||||
DEBUG_LOG(Log::sceNet, "sceNetAdhocPtpRecv(%d,%08x,%08x,%d,%d) at %08x", id, dataAddr, dataSizeAddr, timeout, flag, currentMIPS->pc);
|
||||
|
||||
void * buf = (void *)Memory::GetPointer(dataAddr);
|
||||
int * len = (int *)Memory::GetPointer(dataSizeAddr);
|
||||
void * buf = (void *)Memory::GetPointerOrException(dataAddr);
|
||||
int * len = (int *)Memory::GetPointerOrException(dataSizeAddr);
|
||||
// Library is initialized
|
||||
if (netAdhocInited) {
|
||||
// Valid Arguments
|
||||
@@ -5726,7 +5726,7 @@ static int sceNetAdhocGameModeUpdateReplica(int id, u32 infoAddr) {
|
||||
// Bomberman Panic Bomber is using 0/null on infoAddr, so i guess it's optional.
|
||||
GameModeUpdateInfo* gmuinfo = NULL;
|
||||
if (Memory::IsValidAddress(infoAddr)) {
|
||||
gmuinfo = (GameModeUpdateInfo*)Memory::GetPointer(infoAddr);
|
||||
gmuinfo = (GameModeUpdateInfo*)Memory::GetPointerOrException(infoAddr);
|
||||
}
|
||||
|
||||
for (auto& gma : replicaGameModeAreas) {
|
||||
@@ -5943,7 +5943,7 @@ static int sceNetAdhocctlGetGameModeInfo(u32 infoAddr) {
|
||||
if (!Memory::IsValidAddress(infoAddr))
|
||||
return hleLogError(Log::sceNet, SCE_NET_ADHOCCTL_ERROR_INVALID_ARG, "invalid arg");
|
||||
|
||||
SceNetAdhocctlGameModeInfo* gmInfo = (SceNetAdhocctlGameModeInfo*)Memory::GetPointer(infoAddr);
|
||||
SceNetAdhocctlGameModeInfo* gmInfo = (SceNetAdhocctlGameModeInfo*)Memory::GetPointerOrException(infoAddr);
|
||||
// Writes number of participants and each participating MAC address into infoAddr/gmInfo
|
||||
gmInfo->num = static_cast<s32_le>(gameModeMacs.size());
|
||||
int i = 0;
|
||||
@@ -5961,11 +5961,11 @@ static int sceNetAdhocctlGetGameModeInfo(u32 infoAddr) {
|
||||
static int sceNetAdhocctlGetPeerList(u32 sizeAddr, u32 bufAddr) {
|
||||
s32_le *buflen = NULL;
|
||||
if (Memory::IsValidAddress(sizeAddr)) {
|
||||
buflen = (s32_le *)Memory::GetPointer(sizeAddr);
|
||||
buflen = (s32_le *)Memory::GetPointerOrException(sizeAddr);
|
||||
}
|
||||
SceNetAdhocctlPeerInfoEmu *buf = NULL;
|
||||
if (Memory::IsValidAddress(bufAddr)) {
|
||||
buf = (SceNetAdhocctlPeerInfoEmu *)Memory::GetPointer(bufAddr);
|
||||
buf = (SceNetAdhocctlPeerInfoEmu *)Memory::GetPointerOrException(bufAddr);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceNet, "sceNetAdhocctlGetPeerList([%08x]=%i, %08x) at %08x", sizeAddr, /*buflen ? *buflen : -1*/Memory::ReadUnchecked_U32(sizeAddr), bufAddr, currentMIPS->pc);
|
||||
@@ -6058,7 +6058,7 @@ static int sceNetAdhocctlGetPeerList(u32 sizeAddr, u32 bufAddr) {
|
||||
|
||||
static int sceNetAdhocctlGetAddrByName(const char *nickName, u32 sizeAddr, u32 bufAddr) {
|
||||
s32_le *buflen = NULL; //int32_t
|
||||
if (Memory::IsValidAddress(sizeAddr)) buflen = (s32_le *)Memory::GetPointer(sizeAddr);
|
||||
if (Memory::IsValidAddress(sizeAddr)) buflen = (s32_le *)Memory::GetPointerOrException(sizeAddr);
|
||||
|
||||
if (!nickName || !buflen) {
|
||||
return hleLogError(Log::sceNet, SCE_NET_ADHOCCTL_ERROR_INVALID_ARG);
|
||||
@@ -6075,7 +6075,7 @@ static int sceNetAdhocctlGetAddrByName(const char *nickName, u32 sizeAddr, u32 b
|
||||
{
|
||||
{
|
||||
SceNetAdhocctlPeerInfoEmu *buf = NULL;
|
||||
if (Memory::IsValidAddress(bufAddr)) buf = (SceNetAdhocctlPeerInfoEmu *)Memory::GetPointer(bufAddr);
|
||||
if (Memory::IsValidAddress(bufAddr)) buf = (SceNetAdhocctlPeerInfoEmu *)Memory::GetPointerOrException(bufAddr);
|
||||
|
||||
// Multithreading Lock
|
||||
peerlock.lock();
|
||||
@@ -6219,7 +6219,7 @@ int sceNetAdhocDiscoverInitStart(u32 paramAddr) {
|
||||
//if (Memory::ReadOrException_U32(netAdhocDiscoverBufAddr + 0x80) != 0) //if (*((int*)Memory::GetPointer(0x000010B0)) != 0)
|
||||
// return 0x80411301; // Already Initialized/Started?
|
||||
// TODO: Need to findout whether using invalid params or param address will return an error code or not
|
||||
netAdhocDiscoverParam = (SceNetAdhocDiscoverParam*)Memory::GetPointer(paramAddr);
|
||||
netAdhocDiscoverParam = (SceNetAdhocDiscoverParam*)Memory::GetPointerOrException(paramAddr);
|
||||
if (!netAdhocDiscoverParam)
|
||||
return hleLogError(Log::sceNet, -1, "invalid param?");
|
||||
// FIXME: paramAddr seems to be stored at 0x000010D8 without validating the value first
|
||||
|
||||
@@ -86,7 +86,7 @@ void notifyMatchingHandler(SceNetAdhocMatchingContext * context, ThreadMessage *
|
||||
MatchingArgs argsNew = { 0 };
|
||||
u32_le dataBufLen = msg->optlen + 8; //max(bufLen, msg->optlen + 8);
|
||||
u32_le dataBufAddr = userMemory.Alloc(dataBufLen); // We will free this memory after returning from mipscall. FIXME: Are these buffers supposed to be taken/pre-allocated from the memory pool during sceNetAdhocMatchingInit?
|
||||
uint8_t *dataPtr = Memory::GetPointerWriteRange(dataBufAddr, dataBufLen);
|
||||
uint8_t *dataPtr = Memory::GetPointerWriteRangeOrException(dataBufAddr, dataBufLen);
|
||||
if (dataPtr) {
|
||||
memcpy(dataPtr, &msg->mac, sizeof(msg->mac));
|
||||
if (msg->optlen > 0)
|
||||
@@ -2594,7 +2594,7 @@ int sceNetAdhocMatchingGetPoolStat(u32 poolstatPtr) {
|
||||
}
|
||||
|
||||
SceNetMallocStat * poolstat = NULL;
|
||||
if (Memory::IsValidAddress(poolstatPtr)) poolstat = (SceNetMallocStat *)Memory::GetPointer(poolstatPtr);
|
||||
if (Memory::IsValidAddress(poolstatPtr)) poolstat = (SceNetMallocStat *)Memory::GetPointerOrException(poolstatPtr);
|
||||
|
||||
if (poolstat == NULL) {
|
||||
// Invalid Argument
|
||||
@@ -2628,10 +2628,10 @@ void __NetMatchingCallbacks() { //(int matchingId)
|
||||
actionAfterMatchingMipsCall = __KernelRegisterActionType(AfterMatchingMipsCall::Create);
|
||||
}
|
||||
DEBUG_LOG(Log::sceNet, "AdhocMatching - Remaining Events: %zu", matchingEvents.size());
|
||||
auto peer = findPeer(context, (SceNetEtherAddr*)Memory::GetPointer(args[2]));
|
||||
auto peer = findPeer(context, (SceNetEtherAddr*)Memory::GetPointerOrException(args[2]));
|
||||
// Discard HELLO Events when in the middle of joining, as some games (ie. Super Pocket Tennis) might tried to join again (TODO: Need to confirm whether sceNetAdhocMatchingSelectTarget supposed to be blocking the current thread or not)
|
||||
if (peer == NULL || (args[1] != PSP_ADHOC_MATCHING_EVENT_HELLO || (peer->state != PSP_ADHOC_MATCHING_PEER_OUTGOING_REQUEST && peer->state != PSP_ADHOC_MATCHING_PEER_INCOMING_REQUEST && peer->state != PSP_ADHOC_MATCHING_PEER_CANCEL_IN_PROGRESS))) {
|
||||
DEBUG_LOG(Log::sceNet, "AdhocMatchingCallback: [ID=%i][EVENT=%i][%s]", args[0], args[1], mac2str((SceNetEtherAddr *)Memory::GetPointer(args[2])).c_str());
|
||||
DEBUG_LOG(Log::sceNet, "AdhocMatchingCallback: [ID=%i][EVENT=%i][%s]", args[0], args[1], mac2str((SceNetEtherAddr *)Memory::GetPointerOrException(args[2])).c_str());
|
||||
|
||||
AfterMatchingMipsCall* after = (AfterMatchingMipsCall*)__KernelCreateAction(actionAfterMatchingMipsCall);
|
||||
after->SetData(args[0], args[1], args[2]);
|
||||
@@ -2639,7 +2639,7 @@ void __NetMatchingCallbacks() { //(int matchingId)
|
||||
matchingEvents.pop_front();
|
||||
}
|
||||
else {
|
||||
DEBUG_LOG(Log::sceNet, "AdhocMatching - Discarding Callback: [ID=%i][EVENT=%i][%s]", args[0], args[1], mac2str((SceNetEtherAddr*)Memory::GetPointer(args[2])).c_str());
|
||||
DEBUG_LOG(Log::sceNet, "AdhocMatching - Discarding Callback: [ID=%i][EVENT=%i][%s]", args[0], args[1], mac2str((SceNetEtherAddr*)Memory::GetPointerOrException(args[2])).c_str());
|
||||
matchingEvents.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
+31
-31
@@ -106,7 +106,7 @@ static int sceNetInetInetPton(int af, const char* hostname, u32 inAddrPtr) {
|
||||
return hleLogError(Log::sceNet, 0, "invalid arg"); //-1
|
||||
}
|
||||
|
||||
int retval = inet_pton(convertSocketDomainPSP2Host(af), hostname, (void*)Memory::GetPointer(inAddrPtr));
|
||||
int retval = inet_pton(convertSocketDomainPSP2Host(af), hostname, (void*)Memory::GetPointerOrException(inAddrPtr));
|
||||
// Note that inet_pton can set errno!
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__);
|
||||
@@ -121,7 +121,7 @@ static int sceNetInetInetAton(const char* hostname, u32 inAddrPtr) {
|
||||
}
|
||||
|
||||
// TODO: Wait what, we're calling pton in aton?
|
||||
int retval = inet_pton(AF_INET, hostname, (void*)Memory::GetPointer(inAddrPtr));
|
||||
int retval = inet_pton(AF_INET, hostname, (void*)Memory::GetPointerOrException(inAddrPtr));
|
||||
// inet_aton() returns nonzero if the address is valid, zero if not.
|
||||
return hleLogDebug(Log::sceNet, retval);
|
||||
}
|
||||
@@ -165,8 +165,8 @@ static int sceNetInetGetpeername(int socket, u32 namePtr, u32 namelenPtr) {
|
||||
return hleLogError(Log::sceNet, ERROR_INET_EBADF, "Bad socket #%d", socket);
|
||||
}
|
||||
|
||||
SceNetInetSockaddr* name = (SceNetInetSockaddr*)Memory::GetPointer(namePtr);
|
||||
int* namelen = (int*)Memory::GetPointer(namelenPtr);
|
||||
SceNetInetSockaddr* name = (SceNetInetSockaddr*)Memory::GetPointerOrException(namePtr);
|
||||
int* namelen = (int*)Memory::GetPointerOrException(namelenPtr);
|
||||
SockAddrIN4 saddr{};
|
||||
// TODO: Should've created convertSockaddrPSP2Host (and Host2PSP too) function as it's being used pretty often, thus fixing a bug on it will be tedious when scattered all over the places
|
||||
saddr.addr.sa_family = name->sa_family;
|
||||
@@ -199,8 +199,8 @@ static int sceNetInetGetsockname(int socket, u32 namePtr, u32 namelenPtr) {
|
||||
return hleLogError(Log::sceNet, ERROR_INET_EBADF, "Bad socket #%d", socket);
|
||||
}
|
||||
|
||||
SceNetInetSockaddr* name = (SceNetInetSockaddr*)Memory::GetPointer(namePtr);
|
||||
int* namelen = (int*)Memory::GetPointer(namelenPtr);
|
||||
SceNetInetSockaddr* name = (SceNetInetSockaddr*)Memory::GetPointerOrException(namePtr);
|
||||
int* namelen = (int*)Memory::GetPointerOrException(namelenPtr);
|
||||
SockAddrIN4 saddr{};
|
||||
saddr.addr.sa_family = name->sa_family;
|
||||
int len = std::min(*namelen > 0 ? *namelen : 0, static_cast<int>(sizeof(saddr)));
|
||||
@@ -223,10 +223,10 @@ static int sceNetInetGetsockname(int socket, u32 namePtr, u32 namelenPtr) {
|
||||
|
||||
// FIXME: nfds is number of fd(s) as in posix poll, or was it maximum fd value as in posix select? Star Wars Battlefront Renegade seems to set the nfds to 64, while Coded Arms Contagion is using 256
|
||||
int sceNetInetSelect(int nfds, u32 readfdsPtr, u32 writefdsPtr, u32 exceptfdsPtr, u32 timeoutPtr) {
|
||||
SceNetInetFdSet *readfds = readfdsPtr ? (SceNetInetFdSet*)Memory::GetPointerWrite(readfdsPtr) : nullptr;
|
||||
SceNetInetFdSet *writefds = writefdsPtr ? (SceNetInetFdSet*)Memory::GetPointerWrite(writefdsPtr) : nullptr;
|
||||
SceNetInetFdSet *exceptfds = exceptfdsPtr ? (SceNetInetFdSet*)Memory::GetPointerWrite(exceptfdsPtr) : nullptr;
|
||||
SceNetInetTimeval *timeout = timeoutPtr ? (SceNetInetTimeval*)Memory::GetPointerWrite(timeoutPtr) : nullptr;
|
||||
SceNetInetFdSet *readfds = readfdsPtr ? (SceNetInetFdSet*)Memory::GetPointerWriteOrException(readfdsPtr) : nullptr;
|
||||
SceNetInetFdSet *writefds = writefdsPtr ? (SceNetInetFdSet*)Memory::GetPointerWriteOrException(writefdsPtr) : nullptr;
|
||||
SceNetInetFdSet *exceptfds = exceptfdsPtr ? (SceNetInetFdSet*)Memory::GetPointerWriteOrException(exceptfdsPtr) : nullptr;
|
||||
SceNetInetTimeval *timeout = timeoutPtr ? (SceNetInetTimeval*)Memory::GetPointerWriteOrException(timeoutPtr) : nullptr;
|
||||
|
||||
// First, translate the specified fd_sets to host sockets.
|
||||
|
||||
@@ -357,7 +357,7 @@ int sceNetInetPoll(u32 fdsPtr, u32 nfds, int timeout) { // timeout in milisecond
|
||||
DEBUG_LOG(Log::sceNet, "UNTESTED sceNetInetPoll(%08x, %d, %i) at %08x", fdsPtr, nfds, timeout, currentMIPS->pc);
|
||||
int retval = -1;
|
||||
int maxHostFd = 0;
|
||||
SceNetInetPollfd *fdarray = (SceNetInetPollfd*)Memory::GetPointer(fdsPtr); // SceNetInetPollfd/pollfd, sceNetInetPoll() have similarity to BSD poll() but pollfd have different size on 64bit
|
||||
SceNetInetPollfd *fdarray = (SceNetInetPollfd*)Memory::GetPointerOrException(fdsPtr); // SceNetInetPollfd/pollfd, sceNetInetPoll() have similarity to BSD poll() but pollfd have different size on 64bit
|
||||
|
||||
if (nfds > FD_SETSIZE)
|
||||
nfds = FD_SETSIZE;
|
||||
@@ -419,7 +419,7 @@ static int sceNetInetRecv(int socket, u32 bufPtr, u32 bufLen, u32 flags) {
|
||||
|
||||
int flgs = flags & ~PSP_NET_INET_MSG_DONTWAIT; // removing non-POSIX flag, which is an alternative way to use non-blocking mode
|
||||
flgs = convertMSGFlagsPSP2Host(flgs);
|
||||
int retval = recv(inetSock->sock, (char*)Memory::GetPointer(bufPtr), bufLen, flgs | MSG_NOSIGNAL);
|
||||
int retval = recv(inetSock->sock, (char*)Memory::GetPointerOrException(bufPtr), bufLen, flgs | MSG_NOSIGNAL);
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
retval = hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
@@ -430,7 +430,7 @@ static int sceNetInetRecv(int socket, u32 bufPtr, u32 bufLen, u32 flags) {
|
||||
}
|
||||
|
||||
std::string datahex;
|
||||
DataToHexString(10, 0, Memory::GetPointer(bufPtr), retval, &datahex);
|
||||
DataToHexString(10, 0, Memory::GetPointerOrException(bufPtr), retval, &datahex);
|
||||
VERBOSE_LOG(Log::sceNet, "Data Dump (%d bytes):\n%s", retval, datahex.c_str());
|
||||
|
||||
return hleDelayResult(hleLogInfo(Log::sceNet, retval), "workaround until blocking-socket", 500); // Using hleDelayResult as a workaround for games that need blocking-socket to be implemented
|
||||
@@ -443,12 +443,12 @@ static int sceNetInetSend(int socket, u32 bufPtr, u32 bufLen, u32 flags) {
|
||||
}
|
||||
|
||||
std::string datahex;
|
||||
DataToHexString(10, 0, Memory::GetPointer(bufPtr), bufLen, &datahex);
|
||||
DataToHexString(10, 0, Memory::GetPointerOrException(bufPtr), bufLen, &datahex);
|
||||
VERBOSE_LOG(Log::sceNet, "Data Dump (%d bytes):\n%s", bufLen, datahex.c_str());
|
||||
|
||||
int flgs = flags & ~PSP_NET_INET_MSG_DONTWAIT; // removing non-POSIX flag, which is an alternative way to use non-blocking mode
|
||||
flgs = convertMSGFlagsPSP2Host(flgs);
|
||||
int retval = send(inetSock->sock, (char*)Memory::GetPointer(bufPtr), bufLen, flgs | MSG_NOSIGNAL);
|
||||
int retval = send(inetSock->sock, (char*)Memory::GetPointerOrException(bufPtr), bufLen, flgs | MSG_NOSIGNAL);
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
@@ -561,8 +561,8 @@ static int sceNetInetGetsockopt(int socket, int level, int optname, u32 optvalPt
|
||||
return hleLogError(Log::sceNet, ERROR_INET_EBADF, "Bad socket #%d", socket);
|
||||
}
|
||||
|
||||
u32_le* optval = (u32_le*)Memory::GetPointer(optvalPtr);
|
||||
socklen_t* optlen = (socklen_t*)Memory::GetPointer(optlenPtr);
|
||||
u32_le* optval = (u32_le*)Memory::GetPointerOrException(optvalPtr);
|
||||
socklen_t* optlen = (socklen_t*)Memory::GetPointerOrException(optlenPtr);
|
||||
DEBUG_LOG(Log::sceNet, "SockOpt: Level = %s, OptName = %s", inetSockoptLevel2str(level).c_str(), inetSockoptName2str(optname, level).c_str());
|
||||
timeval tval{};
|
||||
// TODO: Ignoring SO_NBIO/SO_NONBLOCK flag if we always use non-bloking mode (ie. simulated blocking mode)
|
||||
@@ -626,7 +626,7 @@ static int sceNetInetBind(int socket, u32 namePtr, int namelen) {
|
||||
return hleLogError(Log::sceNet, ERROR_INET_EBADF, "Bad socket #%d", socket);
|
||||
}
|
||||
|
||||
SceNetInetSockaddr* name = (SceNetInetSockaddr*)Memory::GetPointer(namePtr);
|
||||
SceNetInetSockaddr* name = (SceNetInetSockaddr*)Memory::GetPointerOrException(namePtr);
|
||||
SockAddrIN4 saddr{};
|
||||
// TODO: Should've created convertSockaddrPSP2Host (and Host2PSP too) function as it's being used pretty often, thus fixing a bug on it will be tedious when scattered all over the places
|
||||
saddr.addr.sa_family = name->sa_family;
|
||||
@@ -687,7 +687,7 @@ static int sceNetInetConnect(int socket, u32 sockAddrPtr, int sockAddrLen) {
|
||||
|
||||
// Still using warn log here so it stands out in the log
|
||||
|
||||
SceNetInetSockaddr* dst = (SceNetInetSockaddr*)Memory::GetPointer(sockAddrPtr);
|
||||
SceNetInetSockaddr* dst = (SceNetInetSockaddr*)Memory::GetPointerOrException(sockAddrPtr);
|
||||
SockAddrIN4 saddr{};
|
||||
int dstlen = std::min(sockAddrLen > 0 ? sockAddrLen : 0, static_cast<int>(sizeof(saddr)));
|
||||
saddr.addr.sa_family = dst->sa_family;
|
||||
@@ -852,7 +852,7 @@ static int sceNetInetRecvfrom(int socket, u32 bufferPtr, int len, int flags, u32
|
||||
*srclen = std::min((*srclen) > 0 ? *srclen : 0, static_cast<socklen_t>(sizeof(saddr)));
|
||||
int flgs = flags & ~PSP_NET_INET_MSG_DONTWAIT; // removing non-POSIX flag, which is an alternative way to use non-blocking mode
|
||||
flgs = convertMSGFlagsPSP2Host(flgs);
|
||||
int retval = recvfrom(inetSock->sock, (char*)Memory::GetPointer(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, srclen);
|
||||
int retval = recvfrom(inetSock->sock, (char*)Memory::GetPointerOrException(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, srclen);
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
retval = hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
@@ -879,7 +879,7 @@ static int sceNetInetRecvfrom(int socket, u32 bufferPtr, int len, int flags, u32
|
||||
}*/
|
||||
|
||||
std::string datahex;
|
||||
DataToHexString(0, 0, Memory::GetPointer(bufferPtr), retval, &datahex);
|
||||
DataToHexString(0, 0, Memory::GetPointerOrException(bufferPtr), retval, &datahex);
|
||||
VERBOSE_LOG(Log::sceNet, "Data Dump (%d bytes):\n%s", retval, datahex.c_str());
|
||||
|
||||
// Using hleDelayResult as a workaround for games that need blocking-socket to be implemented (ie. Coded Arms Contagion)
|
||||
@@ -904,7 +904,7 @@ static int sceNetInetSendto(int socket, u32 bufferPtr, int len, int flags, u32 t
|
||||
}
|
||||
|
||||
std::string datahex;
|
||||
DataToHexString(0, 0, Memory::GetPointer(bufferPtr), len, &datahex);
|
||||
DataToHexString(0, 0, Memory::GetPointerOrException(bufferPtr), len, &datahex);
|
||||
VERBOSE_LOG(Log::sceNet, "Data Dump (%d bytes):\n%s", len, datahex.c_str());
|
||||
|
||||
int retval;
|
||||
@@ -920,7 +920,7 @@ static int sceNetInetSendto(int socket, u32 bufferPtr, int len, int flags, u32 t
|
||||
continue;
|
||||
|
||||
saddr.in.sin_addr.s_addr = peer->ip_addr;
|
||||
retval = sendto(inetSock->sock, (char*)Memory::GetPointer(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, dstlen);
|
||||
retval = sendto(inetSock->sock, (char*)Memory::GetPointerOrException(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, dstlen);
|
||||
if (retval < 0) {
|
||||
DEBUG_LOG(Log::sceNet, "SendTo(BC): Socket error %d", socket_errno);
|
||||
} else {
|
||||
@@ -946,7 +946,7 @@ static int sceNetInetSendto(int socket, u32 bufferPtr, int len, int flags, u32 t
|
||||
saddr.in.sin_addr.s_addr = sockAddr.sin_addr.s_addr;
|
||||
DEBUG_LOG(Log::sceNet, "SendTo(BC): Address Replacement = %s", ip2str(saddr.in.sin_addr).c_str());
|
||||
}*/
|
||||
retval = sendto(inetSock->sock, (char*)Memory::GetPointer(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, dstlen);
|
||||
retval = sendto(inetSock->sock, (char*)Memory::GetPointerOrException(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, dstlen);
|
||||
}
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(__KernelGetCurThread(), socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
@@ -974,7 +974,7 @@ static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
return hleLogError(Log::sceNet, ERROR_INET_EBADF, "Bad socket #%d", socket);
|
||||
}
|
||||
|
||||
InetMsghdr* pspMsghdr = (InetMsghdr*)Memory::GetPointer(msghdrPtr);
|
||||
InetMsghdr* pspMsghdr = (InetMsghdr*)Memory::GetPointerOrException(msghdrPtr);
|
||||
int flgs = flags & ~PSP_NET_INET_MSG_DONTWAIT; // removing non-POSIX flag, which is an alternative way to use non-blocking mode
|
||||
flgs = convertMSGFlagsPSP2Host(flgs);
|
||||
SockAddrIN4 saddr{};
|
||||
@@ -996,7 +996,7 @@ static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
memset(iov, 0, pspMsghdr->msg_iovlen * iovecsize);
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
if (pspMsghdr->msg_name != 0) {
|
||||
SceNetInetSockaddr* pspSaddr = (SceNetInetSockaddr*)Memory::GetPointer(pspMsghdr->msg_name);
|
||||
SceNetInetSockaddr* pspSaddr = (SceNetInetSockaddr*)Memory::GetPointerOrException(pspMsghdr->msg_name);
|
||||
saddr.addr.sa_family = pspSaddr->sa_family;
|
||||
size_t datalen = std::min(pspMsghdr->msg_namelen - (sizeof(pspSaddr->sa_len) + sizeof(pspSaddr->sa_family)), sizeof(saddr.addr.sa_data));
|
||||
memcpy(saddr.addr.sa_data, pspSaddr->sa_data, datalen);
|
||||
@@ -1017,14 +1017,14 @@ static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
hdr.msg_iovlen = pspMsghdr->msg_iovlen;
|
||||
#endif
|
||||
if (pspMsghdr->msg_iov != 0) {
|
||||
SceNetIovec* pspIov = (SceNetIovec*)Memory::GetPointer(pspMsghdr->msg_iov);
|
||||
SceNetIovec* pspIov = (SceNetIovec*)Memory::GetPointerOrException(pspMsghdr->msg_iov);
|
||||
for (int i = 0; i < pspMsghdr->msg_iovlen; i++) {
|
||||
if (pspIov[i].iov_base != 0) {
|
||||
#if defined(_WIN32)
|
||||
iov[i].buf = (char*)Memory::GetPointer(pspIov[i].iov_base);
|
||||
iov[i].buf = (char*)Memory::GetPointerOrException(pspIov[i].iov_base);
|
||||
iov[i].len = pspIov[i].iov_len;
|
||||
#else
|
||||
iov[i].iov_base = (char*)Memory::GetPointer(pspIov[i].iov_base);
|
||||
iov[i].iov_base = (char*)Memory::GetPointerOrException(pspIov[i].iov_base);
|
||||
iov[i].iov_len = pspIov[i].iov_len;
|
||||
#endif
|
||||
}
|
||||
@@ -1042,7 +1042,7 @@ static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
free(iov);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
InetCmsghdr* pspCmsghdr = (InetCmsghdr*)Memory::GetPointer(pspMsghdr->msg_control);
|
||||
InetCmsghdr* pspCmsghdr = (InetCmsghdr*)Memory::GetPointerOrException(pspMsghdr->msg_control);
|
||||
// TODO: Convert InetCmsghdr into platform-specific struct as they're affected by 32/64bit
|
||||
memcpy(chdr, pspCmsghdr, pspMsghdr->msg_controllen);
|
||||
#if defined(_WIN32)
|
||||
@@ -1173,7 +1173,7 @@ static int sceNetInetRecvmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
UpdateErrnoFromHost(__KernelGetCurThread(), EFAULT, __FUNCTION__);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
InetMsghdr* pspMsghdr = (InetMsghdr*)Memory::GetPointer(msghdrPtr);
|
||||
InetMsghdr* pspMsghdr = (InetMsghdr*)Memory::GetPointerOrException(msghdrPtr);
|
||||
int flgs = flags & ~PSP_NET_INET_MSG_DONTWAIT; // removing non-POSIX flag, which is an alternative way to use non-blocking mode
|
||||
flgs = convertMSGFlagsPSP2Host(flgs);
|
||||
SockAddrIN4 saddr{};
|
||||
|
||||
@@ -117,7 +117,7 @@ u32 sceNetStrlen(const char* str) {
|
||||
|
||||
s32 sceNetMemcmp(u32 lhsPtr, u32 rhsPtr, u32 count) {
|
||||
// Redirect that to libc
|
||||
s32 res = std::memcmp(Memory::GetPointer(lhsPtr), Memory::GetPointer(rhsPtr), count);
|
||||
s32 res = std::memcmp(Memory::GetPointerOrException(lhsPtr), Memory::GetPointerOrException(rhsPtr), count);
|
||||
|
||||
return hleLogDebug(Log::sceNet, res);
|
||||
}
|
||||
|
||||
+3
-3
@@ -432,7 +432,7 @@ int sceNpAuthGetTicket(u32 requestId, u32 bufferAddr, u32 length) {
|
||||
// Dummy Login ticket returned as Login response. Dummy ticket contents were taken from https://www.psdevwiki.com/ps3/X-I-5-Ticket
|
||||
ticket.header.version = TICKET_VER_2_1;
|
||||
ticket.header.size = 0xF0; // size excluding the header
|
||||
u8* buf = Memory::GetPointerWrite(bufferAddr + sizeof(ticket));
|
||||
u8* buf = Memory::GetPointerWriteOrException(bufferAddr + sizeof(ticket));
|
||||
int ofs = 0;
|
||||
ofs += writeTicketParam(buf, PARAM_TYPE_STRING_ASCII, "\x4c\x47\x56\x3b\x81\x39\x4a\x22\xd8\x6b\xc1\x57\x71\x6e\xfd\xb8\xab\x63\xcc\x51", 20); // 20 random letters, token key or SceNpSignature?
|
||||
ofs += writeTicketU32Param(buf + ofs, PARAM_TYPE_INT, 0x0100); // a flags?
|
||||
@@ -516,13 +516,13 @@ int sceNpAuthGetTicketParam(u32 ticketBufPtr, int ticketLen, int paramNum, u32 b
|
||||
return hleLogError(Log::sceNet, SCE_NP_MANAGER_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
SceNpTicket* ticket = (SceNpTicket*)Memory::GetPointer(ticketBufPtr);
|
||||
SceNpTicket* ticket = (SceNpTicket*)Memory::GetPointerOrException(ticketBufPtr);
|
||||
u32 inbuf = ticketBufPtr;
|
||||
inbuf += sizeof(ticket->header);
|
||||
inbuf += ticket->section.size + sizeof(ticket->section);
|
||||
u32 outbuf = bufferPtr;
|
||||
for (int i = 0; i < paramNum; i++) {
|
||||
SceNpTicketParamData* ticketParam = (SceNpTicketParamData*)Memory::GetPointer(inbuf);
|
||||
SceNpTicketParamData* ticketParam = (SceNpTicketParamData*)Memory::GetPointerOrException(inbuf);
|
||||
u32 sz = (u32)sizeof(SceNpTicketParamData) + ticketParam->length;
|
||||
Memory::Memcpy(outbuf, inbuf, sz);
|
||||
DEBUG_LOG(Log::sceNet, "%s - Param #%d: Type = %04x, Length = %u", __FUNCTION__, i, static_cast<unsigned int>(ticketParam->type), static_cast<unsigned int>(ticketParam->length));
|
||||
|
||||
+2
-2
@@ -72,9 +72,9 @@ bool NpMatching2ProcessEvents() {
|
||||
}
|
||||
|
||||
// Per npMatching2 function callback
|
||||
u32* inStruct = (u32*)Memory::GetPointer(inStructPtr);
|
||||
u32* inStruct = (u32*)Memory::GetPointerOrException(inStructPtr);
|
||||
if (Memory::IsValidAddress(inStruct[0])) {
|
||||
DEBUG_LOG(Log::sceNet, "NpMatching2Callback [ServerID=%i][EventID=%04x][State=%04x][FuncAddr=%08x][ArgsPtr=%08x]", *(u32*)Memory::GetPointer(serverIdPtr), event, stat, inStruct[0], inStruct[1]);
|
||||
DEBUG_LOG(Log::sceNet, "NpMatching2Callback [ServerID=%i][EventID=%04x][State=%04x][FuncAddr=%08x][ArgsPtr=%08x]", *(u32*)Memory::GetPointerOrException(serverIdPtr), event, stat, inStruct[0], inStruct[1]);
|
||||
hleEnqueueCall(inStruct[0], 7, args.data);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -770,7 +770,7 @@ static u32 scePsmfSetPsmf(u32 psmfStruct, u32 psmfData) {
|
||||
return hleReportError(Log::ME, SCE_KERNEL_ERROR_ILLEGAL_ADDRESS, "bad address");
|
||||
}
|
||||
|
||||
Psmf *psmf = new Psmf(Memory::GetPointer(psmfData), psmfData);
|
||||
Psmf *psmf = new Psmf(Memory::GetPointerOrException(psmfData), psmfData);
|
||||
if (psmf->magic != PSMF_MAGIC) {
|
||||
delete psmf;
|
||||
return hleLogError(Log::ME, SCE_PSMF_ERROR_INVALID_PSMF, "invalid psmf data");
|
||||
|
||||
+2
-2
@@ -1145,7 +1145,7 @@ int sceRegGetKeys(int catHandle, u32 bufAddr, int num) {
|
||||
count = std::min(count, num);
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
char *dest = (char *)Memory::GetPointerWrite(bufAddr + i * keyLen);
|
||||
char *dest = (char *)Memory::GetPointerWriteOrException(bufAddr + i * keyLen);
|
||||
strncpy(dest, keyvals[i].name.c_str(), keyLen);
|
||||
}
|
||||
|
||||
@@ -1366,7 +1366,7 @@ int sceRegGetCategoryListAtRoot(int regHandle, u32 bufPtr, int numCategories) {
|
||||
for (int i = 0; i < numCategories; i++) {
|
||||
const KeyValue &kv = ROOT[i];
|
||||
_dbg_assert_msg_(kv.type == ValueType::DIR, "Unexpected non-dir in ROOT");
|
||||
char *dest = (char *)Memory::GetPointerWrite(bufPtr + i * 27);
|
||||
char *dest = (char *)Memory::GetPointerWriteOrException(bufPtr + i * 27);
|
||||
if (dest) {
|
||||
strncpy(dest, kv.name.c_str(), 27);
|
||||
}
|
||||
|
||||
@@ -1077,7 +1077,7 @@ int MediaEngine::getNextAudioFrame(u8 **buf, int *headerCode1, int *headerCode2)
|
||||
}
|
||||
|
||||
int MediaEngine::getAudioSamples(u32 bufferPtr) {
|
||||
int16_t *buffer = (int16_t *)Memory::GetPointerWriteRange(bufferPtr, 8192);
|
||||
int16_t *buffer = (int16_t *)Memory::GetPointerWriteRangeOrException(bufferPtr, 8192);
|
||||
if (buffer == nullptr) {
|
||||
ERROR_LOG_REPORT(Log::ME, "Ignoring bad audio decode address %08x during video playback", bufferPtr);
|
||||
}
|
||||
|
||||
@@ -641,8 +641,8 @@ void SasInstance::Mix(u32 outAddr, u32 inAddr, int leftVol, int rightVol, bool m
|
||||
// Then mix the send buffer in with the rest.
|
||||
|
||||
// Alright, all voices mixed. Let's convert and clip, and at the same time, wipe mixBuffer for next time. Could also dither.
|
||||
s16 *outp = (s16 *)Memory::GetPointerWriteRange(outAddr, 4 * grainSize);
|
||||
const s16 *inp = inAddr ? (const s16 *)Memory::GetPointerRange(inAddr, 4 * grainSize) : 0;
|
||||
s16 *outp = (s16 *)Memory::GetPointerWriteRangeOrException(outAddr, 4 * grainSize);
|
||||
const s16 *inp = inAddr ? (const s16 *)Memory::GetPointerRangeOrException(inAddr, 4 * grainSize) : 0;
|
||||
if (!outp) {
|
||||
WARN_LOG_REPORT(Log::sceSas, "Bad SAS Mix output address: %08x, grain=%d", outAddr, grainSize);
|
||||
} else if (outputMode == PSP_SAS_OUTPUTMODE_MIXED) {
|
||||
|
||||
@@ -497,7 +497,7 @@ size_t AuCtx::FindNextMp3Sync() {
|
||||
// return output pcm size, <0 error
|
||||
u32 AuCtx::AuDecode(u32 pcmAddr) {
|
||||
u32 outptr = PCMBuf + nextOutputHalf * PCMBufSize / 2;
|
||||
auto outbuf = Memory::GetPointerWriteRange(outptr, PCMBufSize / 2);
|
||||
auto outbuf = Memory::GetPointerWriteRangeOrException(outptr, PCMBufSize / 2);
|
||||
int outpcmbufsize = 0;
|
||||
|
||||
if (pcmAddr)
|
||||
|
||||
+1
-1
@@ -337,7 +337,7 @@ void Reinit() {
|
||||
}
|
||||
|
||||
static void DoMemoryVoid(PointerWrap &p, uint32_t start, uint32_t size) {
|
||||
uint8_t *d = GetPointerWrite(start);
|
||||
uint8_t *d = GetPointerWriteOrException(start);
|
||||
uint8_t *&storage = *p.ptr;
|
||||
|
||||
// We only handle aligned data and sizes.
|
||||
|
||||
+7
-7
@@ -242,19 +242,19 @@ void WriteOrException_U16(const u16 data, const u32 address);
|
||||
void WriteOrException_U32(const u32 data, const u32 address);
|
||||
void WriteOrException_U64(const u64 data, const u32 address);
|
||||
|
||||
u8* GetPointerWrite(const u32 address);
|
||||
const u8* GetPointer(const u32 address);
|
||||
u8* GetPointerWriteOrException(const u32 address);
|
||||
const u8* GetPointerOrException(const u32 address);
|
||||
|
||||
u8 *GetPointerWriteRange(const u32 address, const u32 size);
|
||||
u8 *GetPointerWriteRangeOrException(const u32 address, const u32 size);
|
||||
template<typename T>
|
||||
T* GetTypedPointerWriteRange(const u32 address, const u32 size) {
|
||||
return reinterpret_cast<T*>(GetPointerWriteRange(address, size));
|
||||
return reinterpret_cast<T*>(GetPointerWriteRangeOrException(address, size));
|
||||
}
|
||||
|
||||
const u8 *GetPointerRange(const u32 address, const u32 size);
|
||||
const u8 *GetPointerRangeOrException(const u32 address, const u32 size);
|
||||
template<typename T>
|
||||
const T* GetTypedPointerRange(const u32 address, const u32 size) {
|
||||
return reinterpret_cast<const T*>(GetPointerRange(address, size));
|
||||
return reinterpret_cast<const T*>(GetPointerRangeOrException(address, size));
|
||||
}
|
||||
|
||||
bool IsRAMAddress(const u32 address);
|
||||
@@ -568,7 +568,7 @@ struct PSPPointer
|
||||
}
|
||||
|
||||
void FillWithZero() {
|
||||
memset(Memory::GetPointerWrite(ptr), 0, sizeof(T));
|
||||
memset(Memory::GetPointerWriteOrException(ptr), 0, sizeof(T));
|
||||
}
|
||||
|
||||
bool Equals(u32 addr) const {
|
||||
|
||||
+17
-17
@@ -27,7 +27,7 @@
|
||||
|
||||
namespace Memory {
|
||||
|
||||
u8 *GetPointerWrite(const u32 address) {
|
||||
u8 *GetPointerWriteOrException(const u32 address) {
|
||||
if ((address & 0x3E000000) == 0x08000000 || // RAM
|
||||
(address & 0xBF800000) == 0x04000000 || // VRAM
|
||||
(address & 0xBFFFC000) == 0x00010000 || // Scratchpad
|
||||
@@ -40,7 +40,7 @@ u8 *GetPointerWrite(const u32 address) {
|
||||
}
|
||||
}
|
||||
|
||||
const u8 *GetPointer(const u32 address) {
|
||||
const u8 *GetPointerOrException(const u32 address) {
|
||||
if ((address & 0x3E000000) == 0x08000000 || // RAM
|
||||
(address & 0xBF800000) == 0x04000000 || // VRAM
|
||||
(address & 0xBFFFC000) == 0x00010000 || // Scratchpad
|
||||
@@ -53,8 +53,8 @@ const u8 *GetPointer(const u32 address) {
|
||||
}
|
||||
}
|
||||
|
||||
u8 *GetPointerWriteRange(const u32 address, const u32 size) {
|
||||
u8 *ptr = GetPointerWrite(address);
|
||||
u8 *GetPointerWriteRangeOrException(const u32 address, const u32 size) {
|
||||
u8 *ptr = GetPointerWriteOrException(address);
|
||||
if (ptr) {
|
||||
if (ClampValidSizeAt(address, size) != size) {
|
||||
// That's a memory exception! TODO: Adjust reported address to the end of the range?
|
||||
@@ -69,8 +69,8 @@ u8 *GetPointerWriteRange(const u32 address, const u32 size) {
|
||||
}
|
||||
}
|
||||
|
||||
const u8 *GetPointerRange(const u32 address, const u32 size) {
|
||||
const u8 *ptr = GetPointer(address);
|
||||
const u8 *GetPointerRangeOrException(const u32 address, const u32 size) {
|
||||
const u8 *ptr = GetPointerOrException(address);
|
||||
if (ptr) {
|
||||
if (ClampValidSizeAt(address, size) != size) {
|
||||
// That's a memory exception! TODO: Adjust reported address to the end of the range?
|
||||
@@ -86,7 +86,7 @@ const u8 *GetPointerRange(const u32 address, const u32 size) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void ReadMemoryOrRaiseException(T &var, const u32 address) {
|
||||
inline void ReadMemoryOrException(T &var, const u32 address) {
|
||||
if ((address & 0x3E000000) == 0x08000000 || // RAM
|
||||
(address & 0xBF800000) == 0x04000000 || // VRAM
|
||||
(address & 0xBFFFC000) == 0x00010000 || // Scratchpad
|
||||
@@ -99,7 +99,7 @@ inline void ReadMemoryOrRaiseException(T &var, const u32 address) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void WriteMemoryOrRaiseException(u32 address, const T data) {
|
||||
inline void WriteMemoryOrException(u32 address, const T data) {
|
||||
if ((address & 0x3E000000) == 0x08000000 || // RAM
|
||||
(address & 0xBF800000) == 0x04000000 || // VRAM
|
||||
(address & 0xBFFFC000) == 0x00010000 || // Scratchpad
|
||||
@@ -126,42 +126,42 @@ bool IsScratchpadAddress(const u32 address) {
|
||||
|
||||
u8 ReadOrException_U8(const u32 address) {
|
||||
u8 value = 0;
|
||||
ReadMemoryOrRaiseException<u8>(value, address);
|
||||
ReadMemoryOrException<u8>(value, address);
|
||||
return (u8)value;
|
||||
}
|
||||
|
||||
u16 ReadOrException_U16(const u32 address) {
|
||||
u16_le value = 0;
|
||||
ReadMemoryOrRaiseException<u16_le>(value, address);
|
||||
ReadMemoryOrException<u16_le>(value, address);
|
||||
return (u16)value;
|
||||
}
|
||||
|
||||
u32 ReadOrException_U32(const u32 address) {
|
||||
u32_le value = 0;
|
||||
ReadMemoryOrRaiseException<u32_le>(value, address);
|
||||
ReadMemoryOrException<u32_le>(value, address);
|
||||
return value;
|
||||
}
|
||||
|
||||
u64 Read_U64(const u32 address) {
|
||||
u64 ReadOrException_U64(const u32 address) {
|
||||
u64_le value = 0;
|
||||
ReadMemoryOrRaiseException<u64_le>(value, address);
|
||||
ReadMemoryOrException<u64_le>(value, address);
|
||||
return value;
|
||||
}
|
||||
|
||||
void WriteOrException_U8(const u8 _Data, const u32 address) {
|
||||
WriteMemoryOrRaiseException<u8>(address, _Data);
|
||||
WriteMemoryOrException<u8>(address, _Data);
|
||||
}
|
||||
|
||||
void WriteOrException_U16(const u16 _Data, const u32 address) {
|
||||
WriteMemoryOrRaiseException<u16_le>(address, _Data);
|
||||
WriteMemoryOrException<u16_le>(address, _Data);
|
||||
}
|
||||
|
||||
void WriteOrException_U32(const u32 _Data, const u32 address) {
|
||||
WriteMemoryOrRaiseException<u32_le>(address, _Data);
|
||||
WriteMemoryOrException<u32_le>(address, _Data);
|
||||
}
|
||||
|
||||
void WriteOrException_U64(const u64 _Data, const u32 address) {
|
||||
WriteMemoryOrRaiseException<u64_le>(address, _Data);
|
||||
WriteMemoryOrException<u64_le>(address, _Data);
|
||||
}
|
||||
|
||||
} // namespace Memory
|
||||
@@ -32,7 +32,7 @@ namespace Memory
|
||||
{
|
||||
|
||||
inline void Memcpy(const u32 to_address, const void *from_data, const u32 len, const char *tag, size_t tagLen) {
|
||||
u8 *to = GetPointerWriteRange(to_address, len);
|
||||
u8 *to = GetPointerWriteRangeOrException(to_address, len);
|
||||
if (to) {
|
||||
memcpy(to, from_data, len);
|
||||
if (!tag) {
|
||||
@@ -45,7 +45,7 @@ inline void Memcpy(const u32 to_address, const void *from_data, const u32 len, c
|
||||
}
|
||||
|
||||
inline void Memcpy(void *to_data, const u32 from_address, const u32 len, const char *tag, size_t tagLen) {
|
||||
const u8 *from = GetPointerRange(from_address, len);
|
||||
const u8 *from = GetPointerRangeOrException(from_address, len);
|
||||
if (from) {
|
||||
memcpy(to_data, from, len);
|
||||
if (!tag) {
|
||||
@@ -58,11 +58,11 @@ inline void Memcpy(void *to_data, const u32 from_address, const u32 len, const c
|
||||
}
|
||||
|
||||
inline void Memcpy(const u32 to_address, const u32 from_address, const u32 len, const char *tag, size_t tagLen) {
|
||||
u8 *to = GetPointerWriteRange(to_address, len);
|
||||
u8 *to = GetPointerWriteRangeOrException(to_address, len);
|
||||
// If not, GetPointer will log.
|
||||
if (!to)
|
||||
return;
|
||||
const u8 *from = GetPointerRange(from_address, len);
|
||||
const u8 *from = GetPointerRangeOrException(from_address, len);
|
||||
if (!from)
|
||||
return;
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ void __PPGeInit() {
|
||||
NotifyMemInfo(MemBlockFlags::WRITE, palette.ptr, 16 * sizeof(u16_le), "PPGe Palette");
|
||||
|
||||
const u32_le *imagePtr = (u32_le *)imageData[0];
|
||||
u8 *ramPtr = atlasPtr == 0 ? nullptr : (u8 *)Memory::GetPointerRange(atlasPtr, atlasSize);
|
||||
u8 *ramPtr = atlasPtr == 0 ? nullptr : (u8 *)Memory::GetPointerRangeOrException(atlasPtr, atlasSize);
|
||||
|
||||
// Palettize to 4-bit, the easy way.
|
||||
for (int i = 0; i < width[0] * height[0] / 2; i++) {
|
||||
@@ -334,7 +334,7 @@ void __PPGeDoState(PointerWrap &p)
|
||||
} else {
|
||||
// Memory was already updated by this point, so check directly.
|
||||
if (atlasPtr != 0) {
|
||||
savedHash = XXH3_64bits(Memory::GetPointerRange(atlasPtr, atlasWidth * atlasHeight / 2), atlasWidth * atlasHeight / 2);
|
||||
savedHash = XXH3_64bits(Memory::GetPointerRangeOrException(atlasPtr, atlasWidth * atlasHeight / 2), atlasWidth * atlasHeight / 2);
|
||||
} else {
|
||||
savedHash ^= 1;
|
||||
}
|
||||
@@ -929,7 +929,7 @@ static PPGeTextDrawerImage PPGeGetTextImage(std::string_view text, const PPGeSty
|
||||
|
||||
if (im.ptr) {
|
||||
int wBytes = (im.entry.bmWidth + 1) / 2;
|
||||
u8 *ramPtr = Memory::GetPointerWriteRange(im.ptr, sz);
|
||||
u8 *ramPtr = Memory::GetPointerWriteRangeOrException(im.ptr, sz);
|
||||
for (int y = 0; y < im.entry.bmHeight; ++y) {
|
||||
for (int x = 0; x < wBytes; ++x) {
|
||||
uint8_t c1 = bitmapData[y * im.entry.bmWidth + x * 2];
|
||||
@@ -1373,7 +1373,7 @@ bool PPGeImage::Load() {
|
||||
int success;
|
||||
if (filename_.empty()) {
|
||||
_dbg_assert_(size_ < MAX_VALID_IMAGE_SIZE);
|
||||
const u8 *srcPtr = Memory::GetPointerRange(png_, (u32)size_);
|
||||
const u8 *srcPtr = Memory::GetPointerRangeOrException(png_, (u32)size_);
|
||||
if (!srcPtr) {
|
||||
ERROR_LOG(Log::sceGe, "Trying to load PPGeImage from invalid range: %08x, %08x bytes", png_, (int)size_);
|
||||
return false;
|
||||
|
||||
@@ -3144,7 +3144,7 @@ bool FramebufferManagerCommon::GetStencilbuffer(u32 fb_address, int fb_stride, G
|
||||
return false;
|
||||
// If there's no vfb and we're drawing there, must be memory?
|
||||
// TODO: Actually get the stencil.
|
||||
buffer = GPUDebugBuffer(Memory::GetPointerWrite(fb_address), fb_stride, 512, GPU_DBG_FORMAT_8888);
|
||||
buffer = GPUDebugBuffer(Memory::GetPointerWriteOrException(fb_address), fb_stride, 512, GPU_DBG_FORMAT_8888);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ bool FramebufferManagerCommon::PerformWriteStencilFromMemory(u32 addr, int size,
|
||||
u8 usedBits = 0;
|
||||
bool useExportShader = draw_->GetDeviceCaps().fragmentShaderStencilWriteSupported;
|
||||
|
||||
const u8 *src = Memory::GetPointer(addr);
|
||||
const u8 *src = Memory::GetPointerOrException(addr);
|
||||
if (!src)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ static u32 ComputeTextureHash(TextureReplacer &replacer, u32 addr, int bufw, int
|
||||
} else {
|
||||
sizeInRAM = (textureBitsPerPixel[format] * bufw * h) >> 3;
|
||||
}
|
||||
const u32 *checkp = (const u32 *)Memory::GetPointer(addr);
|
||||
const u32 *checkp = (const u32 *)Memory::GetPointerOrException(addr);
|
||||
|
||||
if (Memory::IsValidAddress(addr + sizeInRAM)) {
|
||||
gpuStats.perFrame.numTextureDataBytesHashed += sizeInRAM;
|
||||
@@ -1956,7 +1956,7 @@ TextureAlpha TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETex
|
||||
|
||||
int w = gstate.getTextureWidth(level);
|
||||
int h = gstate.getTextureHeight(level);
|
||||
const u8 *texptr = Memory::GetPointer(texaddr);
|
||||
const u8 *texptr = Memory::GetPointerOrException(texaddr);
|
||||
const uint32_t byteSize = (textureBitsPerPixel[format] * bufw * h) / 8;
|
||||
|
||||
// Validate the texture data fits in mapped RAM, like the DXT path does.
|
||||
|
||||
@@ -135,7 +135,7 @@ inline void DeIndexTexture(/*WRITEONLY*/ ClutT *dest, const IndexT *indexed, int
|
||||
|
||||
template <typename IndexT, typename ClutT>
|
||||
inline void DeIndexTexture(/*WRITEONLY*/ ClutT *dest, const u32 texaddr, int length, const ClutT *clut, u32 *outAlphaSum) {
|
||||
const IndexT *indexed = (const IndexT *) Memory::GetPointer(texaddr);
|
||||
const IndexT *indexed = (const IndexT *) Memory::GetPointerOrException(texaddr);
|
||||
DeIndexTexture(dest, indexed, length, clut, outAlphaSum);
|
||||
}
|
||||
|
||||
@@ -221,12 +221,12 @@ inline void DeIndexTexture4OptimalRev(u16 *dest, const u8 *indexed, int length,
|
||||
|
||||
template <typename ClutT>
|
||||
inline void DeIndexTexture4(ClutT *dest, const u32 texaddr, int length, const ClutT *clut) {
|
||||
const u8 *indexed = (const u8 *) Memory::GetPointer(texaddr);
|
||||
const u8 *indexed = (const u8 *) Memory::GetPointerOrException(texaddr);
|
||||
DeIndexTexture4(dest, indexed, length, clut);
|
||||
}
|
||||
|
||||
template <typename ClutT>
|
||||
inline void DeIndexTexture4Optimal(ClutT *dest, const u32 texaddr, int length, ClutT color) {
|
||||
const u8 *indexed = (const u8 *) Memory::GetPointer(texaddr);
|
||||
const u8 *indexed = (const u8 *) Memory::GetPointerOrException(texaddr);
|
||||
DeIndexTexture4Optimal(dest, indexed, length, color);
|
||||
}
|
||||
@@ -466,10 +466,10 @@ void Recorder::FlushPrimState(int vcount) {
|
||||
}
|
||||
}
|
||||
|
||||
const void *verts = Memory::GetPointer(gstate_c.vertexAddr);
|
||||
const void *verts = Memory::GetPointerOrException(gstate_c.vertexAddr);
|
||||
const void *indices = nullptr;
|
||||
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
|
||||
indices = Memory::GetPointer(gstate_c.indexAddr);
|
||||
indices = Memory::GetPointerOrException(gstate_c.indexAddr);
|
||||
}
|
||||
|
||||
u32 ibytes = 0;
|
||||
|
||||
+8
-8
@@ -1768,8 +1768,8 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
|
||||
u32 dstLineStartAddr = dstBasePtr + (dstY * dstStride + dstX) * bpp;
|
||||
u32 bytesToCopy = width * height * bpp;
|
||||
|
||||
const u8 *srcp = Memory::GetPointer(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWrite(dstLineStartAddr);
|
||||
const u8 *srcp = Memory::GetPointerOrException(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWriteOrException(dstLineStartAddr);
|
||||
memcpy(dstp, srcp, bytesToCopy);
|
||||
|
||||
if (MemBlockInfoDetailed(bytesToCopy)) {
|
||||
@@ -1786,8 +1786,8 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
|
||||
}
|
||||
|
||||
auto notifyingMemmove = [&](u32 d, u32 s, u32 sz) {
|
||||
const u8 *srcp = Memory::GetPointer(s);
|
||||
u8 *dstp = Memory::GetPointerWrite(d);
|
||||
const u8 *srcp = Memory::GetPointerOrException(s);
|
||||
u8 *dstp = Memory::GetPointerWriteOrException(d);
|
||||
memmove(dstp, srcp, sz);
|
||||
|
||||
if (notifyDetail) {
|
||||
@@ -1809,8 +1809,8 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
|
||||
bool dstLineWrap = !Memory::IsValidRange(dstLineStartAddr, bytesToCopy);
|
||||
|
||||
if (!srcLineWrap && !dstLineWrap) {
|
||||
const u8 *srcp = Memory::GetPointer(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWrite(dstLineStartAddr);
|
||||
const u8 *srcp = Memory::GetPointerOrException(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWriteOrException(dstLineStartAddr);
|
||||
for (u32 i = 0; i < bytesToCopy; i += 64) {
|
||||
u32 chunk = i + 64 > bytesToCopy ? bytesToCopy - i : 64;
|
||||
memmove(dstp + i, srcp + i, chunk);
|
||||
@@ -1890,8 +1890,8 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
|
||||
u32 srcLineStartAddr = srcBasePtr + ((y + srcY) * srcStride + srcX) * bpp;
|
||||
u32 dstLineStartAddr = dstBasePtr + ((y + dstY) * dstStride + dstX) * bpp;
|
||||
|
||||
const u8 *srcp = Memory::GetPointer(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWrite(dstLineStartAddr);
|
||||
const u8 *srcp = Memory::GetPointerOrException(srcLineStartAddr);
|
||||
u8 *dstp = Memory::GetPointerWriteOrException(dstLineStartAddr);
|
||||
memcpy(dstp, srcp, bytesToCopy);
|
||||
|
||||
// If we're tracking detail, it's useful to have the gaps illustrated properly.
|
||||
|
||||
@@ -1850,7 +1850,7 @@ bool GetCurrentTexture(GPUDebugBuffer &buffer, int level)
|
||||
return false;
|
||||
}
|
||||
|
||||
u8 *texptr = Memory::GetPointerWrite(texaddr);
|
||||
u8 *texptr = Memory::GetPointerWriteOrException(texaddr);
|
||||
u32 *row = (u32 *)buffer.GetData();
|
||||
for (int y = 0; y < h; ++y) {
|
||||
for (int x = 0; x < w; ++x) {
|
||||
|
||||
@@ -395,8 +395,8 @@ const SoftwareCommandTableEntry softgpuCommandTable[] = {
|
||||
SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
||||
: GPUCommon(gfxCtx, draw)
|
||||
{
|
||||
fb.data = Memory::GetPointerWrite(0x44000000); // TODO: correct default address?
|
||||
depthbuf.data = Memory::GetPointerWrite(0x44000000); // TODO: correct default address?
|
||||
fb.data = Memory::GetPointerWriteOrException(0x44000000); // TODO: correct default address?
|
||||
depthbuf.data = Memory::GetPointerWriteOrException(0x44000000); // TODO: correct default address?
|
||||
|
||||
memset(softgpuCmdInfo, 0, sizeof(softgpuCmdInfo));
|
||||
|
||||
@@ -500,7 +500,7 @@ void SoftGPU::ConvertTextureDescFrom16(Draw::TextureDesc &desc, int srcwidth, in
|
||||
fbTexBuffer_.resize(srcwidth * srcheight);
|
||||
const uint16_t *displayBuffer = overrideData;
|
||||
if (!displayBuffer)
|
||||
displayBuffer = (const uint16_t *)Memory::GetPointer(displayFramebuf_);
|
||||
displayBuffer = (const uint16_t *)Memory::GetPointerOrException(displayFramebuf_);
|
||||
|
||||
for (int y = 0; y < srcheight; ++y) {
|
||||
u32 *buf_line = &fbTexBuffer_[y * srcwidth];
|
||||
@@ -564,7 +564,7 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(const DisplayLayoutConfig &config,
|
||||
bool hasPostShader = presentation_ && presentation_->HasPostShader();
|
||||
|
||||
if (PSP_CoreParameter().compat.flags().DarkStalkersPresentHack && displayFormat_ == GE_FORMAT_5551 && g_DarkStalkerStretch != DSStretch::Off) {
|
||||
const u8 *data = Memory::GetPointerWrite(0x04088000);
|
||||
const u8 *data = Memory::GetPointerWriteOrException(0x04088000);
|
||||
bool fillDesc = true;
|
||||
if (draw_->GetDataFormatSupport(Draw::DataFormat::A1B5G5R5_UNORM_PACK16) & Draw::FMT_TEXTURE) {
|
||||
// The perfect one.
|
||||
@@ -593,13 +593,13 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(const DisplayLayoutConfig &config,
|
||||
hasImage = false;
|
||||
u1 = 1.0f;
|
||||
} else if (displayFormat_ == GE_FORMAT_8888) {
|
||||
const u8 *data = Memory::GetPointer(displayFramebuf_);
|
||||
const u8 *data = Memory::GetPointerOrException(displayFramebuf_);
|
||||
desc.width = displayStride_ == 0 ? srcwidth : displayStride_;
|
||||
desc.height = srcheight;
|
||||
desc.initData.push_back(data);
|
||||
desc.format = Draw::DataFormat::R8G8B8A8_UNORM;
|
||||
} else if (displayFormat_ == GE_FORMAT_5551) {
|
||||
const u8 *data = Memory::GetPointer(displayFramebuf_);
|
||||
const u8 *data = Memory::GetPointerOrException(displayFramebuf_);
|
||||
bool fillDesc = true;
|
||||
if (draw_->GetDataFormatSupport(Draw::DataFormat::A1B5G5R5_UNORM_PACK16) & Draw::FMT_TEXTURE) {
|
||||
// The perfect one.
|
||||
@@ -1037,7 +1037,7 @@ void SoftGPU::Execute_ZbufPtr(u32 op, u32 diff) {
|
||||
drawEngine_->transformUnit.Flush(this, "depthbuf");
|
||||
// For the pointer, ignore memory mirrors. This also gives some buffer for draws that go outside.
|
||||
// TODO: Confirm how wrapping is handled in drawing. Adjust if we ever handle VRAM mirrors more accurately.
|
||||
depthbuf.data = Memory::GetPointerWrite(gstate.getDepthBufAddress() & 0x041FFFF0);
|
||||
depthbuf.data = Memory::GetPointerWriteOrException(gstate.getDepthBufAddress() & 0x041FFFF0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1365,7 +1365,7 @@ bool SoftGPU::GetCurrentFramebuffer(GPUDebugBuffer &buffer, GPUDebugFramebufferT
|
||||
size.y = 272;
|
||||
stride = displayStride_;
|
||||
fmt = displayFormat_;
|
||||
src = Memory::GetPointer(displayFramebuf_);
|
||||
src = Memory::GetPointerOrException(displayFramebuf_);
|
||||
}
|
||||
|
||||
buffer.Allocate(size.x, size.y, fmt);
|
||||
|
||||
@@ -1381,7 +1381,7 @@ void DrawMediaDecodersView(ImConfig &cfg, ImControl &control) {
|
||||
if (!Memory::IsValidRange(info.buffer, info.bufferByte)) {
|
||||
return;
|
||||
}
|
||||
const u8 *data = Memory::GetPointerRange(info.buffer, info.bufferByte);
|
||||
const u8 *data = Memory::GetPointerRangeOrException(info.buffer, info.bufferByte);
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,16 +99,16 @@ INT_PTR CALLBACK DumpMemoryWindow::dlgFunc(HWND hwnd, UINT iMsg, WPARAM wParam,
|
||||
}
|
||||
|
||||
if (includeReplacements) {
|
||||
fwrite(Memory::GetPointer(bp->start), 1, bp->size, output);
|
||||
fwrite(Memory::GetPointerOrException(bp->start), 1, bp->size, output);
|
||||
} else {
|
||||
auto savedReplacements = SaveAndClearReplacements();
|
||||
std::lock_guard<std::recursive_mutex> guard(MIPSComp::jitLock);
|
||||
if (MIPSComp::jit) {
|
||||
auto savedBlocks = MIPSComp::jit->SaveAndClearEmuHackOps();
|
||||
fwrite(Memory::GetPointer(bp->start), 1, bp->size, output);
|
||||
fwrite(Memory::GetPointerOrException(bp->start), 1, bp->size, output);
|
||||
MIPSComp::jit->RestoreSavedEmuHackOps(savedBlocks);
|
||||
} else {
|
||||
fwrite(Memory::GetPointer(bp->start), 1, bp->size, output);
|
||||
fwrite(Memory::GetPointerOrException(bp->start), 1, bp->size, output);
|
||||
}
|
||||
RestoreSavedReplacements(savedReplacements);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ bool TestJit() {
|
||||
|
||||
g_Config.bFastMemory = true;
|
||||
currentMIPS->pc = PSP_GetUserMemoryBase();
|
||||
u32 *p = (u32 *)Memory::GetPointer(currentMIPS->pc);
|
||||
u32 *p = (u32 *)Memory::GetPointerOrException(currentMIPS->pc);
|
||||
|
||||
// TODO: Smarter way of seeding in the code sequence.
|
||||
static const char *lines[] = {
|
||||
|
||||
Reference in new issue
Block a user