diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 5a3cd77d35..8aa429ba1d 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -125,7 +125,7 @@ struct SceMpegLLI }; void SceMpegAu::read(u32 addr) { - Memory::ReadStruct(addr, this); + Memory::Memcpy(this, addr, sizeof(this), "SceMpegAu"); pts = (pts & 0xFFFFFFFFULL) << 32 | (((u64)pts) >> 32); dts = (dts & 0xFFFFFFFFULL) << 32 | (((u64)dts) >> 32); } @@ -133,7 +133,7 @@ void SceMpegAu::read(u32 addr) { void SceMpegAu::write(u32 addr) { pts = (pts & 0xFFFFFFFFULL) << 32 | (((u64)pts) >> 32); dts = (dts & 0xFFFFFFFFULL) << 32 | (((u64)dts) >> 32); - Memory::WriteStruct(addr, this); + Memory::Memcpy(addr, this, sizeof(this), "SceMpegAu"); } /* @@ -2410,15 +2410,15 @@ static u32 sceMpegBasePESpacketCopy(u32 p) { pmp_videoSource = p; pmp_nBlocks = 0; - SceMpegLLI lli; - while (1){ - Memory::ReadStruct(p, &lli); + + auto lli = PSPPointer::Create(p); + while (lli.IsValid()) { pmp_nBlocks++; // lli.Next ==0 for last block - if (lli.Next == 0){ + if (lli->Next == 0){ break; } - p = p + sizeof(SceMpegLLI); + ++lli; } DEBUG_LOG(ME, "sceMpegBasePESpacketCopy(%08x), received %d block(s)", pmp_videoSource, pmp_nBlocks); diff --git a/Core/HLE/scePsmf.cpp b/Core/HLE/scePsmf.cpp index 020ca8a808..b2aefa9a1a 100644 --- a/Core/HLE/scePsmf.cpp +++ b/Core/HLE/scePsmf.cpp @@ -766,20 +766,21 @@ static u32 scePsmfSetPsmf(u32 psmfStruct, u32 psmfData) { // Note: this structure changes between versions. // TODO: These values are not right, but games probably don't read them. - PsmfData data = {0}; - data.version = psmf->version; - data.headerSize = 0x800; - data.streamSize = psmf->streamSize; + auto data = PSPPointer::Create(psmfStruct); + memset((PsmfData *)data, 0, sizeof(PsmfData)); + data->version = psmf->version; + data->headerSize = 0x800; + data->streamSize = psmf->streamSize; // This should be and needs to be the current stream. - data.streamNum = psmf->currentStreamNum; - data.headerOffset = psmf->headerOffset; - Memory::WriteStruct(psmfStruct, &data); + data->streamNum = psmf->currentStreamNum; + data->headerOffset = psmf->headerOffset; + data.NotifyWrite("PsmfSetPsmf"); // Because the Psmf struct is sometimes copied, we use a value inside as an id. - auto iter = psmfMap.find(data.headerOffset); + auto iter = psmfMap.find(data->headerOffset); if (iter != psmfMap.end()) delete iter->second; - psmfMap[data.headerOffset] = psmf; + psmfMap[data->headerOffset] = psmf; return hleLogSuccessI(ME, 0); } @@ -1046,45 +1047,43 @@ static u32 scePsmfGetEPWithId(u32 psmfStruct, int epid, u32 entryAddr) { Psmf *psmf = getPsmf(psmfStruct); if (!psmf) { - ERROR_LOG(ME, "scePsmfGetEPWithId(%08x, %i, %08x): invalid psmf", psmfStruct, epid, entryAddr); - return ERROR_PSMF_NOT_INITIALIZED; + return hleLogError(ME, ERROR_PSMF_NOT_INITIALIZED, "invalid psmf"); } - DEBUG_LOG(ME, "scePsmfGetEPWithId(%08x, %i, %08x)", psmfStruct, epid, entryAddr); if (epid < 0 || epid >= (int)psmf->EPMap.size()) { - ERROR_LOG(ME, "scePsmfGetEPWithId(%08x, %i): invalid id", psmfStruct, epid); - return ERROR_PSMF_NOT_FOUND; + return hleLogError(ME, ERROR_PSMF_NOT_FOUND, "invalid id"); } - if (Memory::IsValidAddress(entryAddr)) { - Memory::WriteStruct(entryAddr, &psmf->EPMap[epid]); + + auto entry = PSPPointer::Create(entryAddr); + if (entry.IsValid()) { + *entry = psmf->EPMap[epid]; + entry.NotifyWrite("PsmfGetEPWithId"); } - return 0; + return hleLogSuccessI(ME, 0); } static u32 scePsmfGetEPWithTimestamp(u32 psmfStruct, u32 ts, u32 entryAddr) { Psmf *psmf = getPsmf(psmfStruct); if (!psmf) { - ERROR_LOG(ME, "scePsmfGetEPWithTimestamp(%08x, %i, %08x): invalid psmf", psmfStruct, ts, entryAddr); - return ERROR_PSMF_NOT_INITIALIZED; + return hleLogError(ME, ERROR_PSMF_NOT_INITIALIZED, "invalid psmf"); } - DEBUG_LOG(ME, "scePsmfGetEPWithTimestamp(%08x, %i, %08x)", psmfStruct, ts, entryAddr); if (ts < psmf->presentationStartTime) { - ERROR_LOG(ME, "scePsmfGetEPWithTimestamp(%08x, %i): invalid timestamp", psmfStruct, ts); - return ERROR_PSMF_NOT_FOUND; + return hleLogError(ME, ERROR_PSMF_NOT_FOUND, "invalid timestamp"); } int epid = psmf->FindEPWithTimestamp(ts); if (epid < 0 || epid >= (int)psmf->EPMap.size()) { - ERROR_LOG(ME, "scePsmfGetEPWithTimestamp(%08x, %i): invalid id", psmfStruct, epid); - return ERROR_PSMF_NOT_FOUND; + return hleLogError(ME, ERROR_PSMF_NOT_FOUND, "invalid id"); } - if (Memory::IsValidAddress(entryAddr)) { - Memory::WriteStruct(entryAddr, &psmf->EPMap[epid]); + auto entry = PSPPointer::Create(entryAddr); + if (entry.IsValid()) { + *entry = psmf->EPMap[epid]; + entry.NotifyWrite("PsmfGetEPWithTimestamp"); } - return 0; + return hleLogSuccessI(ME, 0); } static u32 scePsmfGetEPidWithTimestamp(u32 psmfStruct, u32 ts)