diff --git a/Core/HLE/sceFont.cpp b/Core/HLE/sceFont.cpp index b1eb4a4cd7..96a263af2f 100644 --- a/Core/HLE/sceFont.cpp +++ b/Core/HLE/sceFont.cpp @@ -878,7 +878,7 @@ int sceFontFindOptimumFont(u32 libHandle, u32 fontStylePtr, u32 errorCodePtr) { INFO_LOG(SCEFONT, "sceFontFindOptimumFont(%08x, %08x, %08x)", libHandle, fontStylePtr, errorCodePtr); - auto requestedStyle = Memory::GetStruct(fontStylePtr); + auto requestedStyle = PSPPointer::Create(fontStylePtr); // Find the first nearest match for H/V, OR the last exact match for others. float hRes = requestedStyle->fontHRes > 0.0f ? requestedStyle->fontHRes : fontLib->FontHRes(); @@ -941,7 +941,7 @@ int sceFontFindFont(u32 libHandle, u32 fontStylePtr, u32 errorCodePtr) { INFO_LOG(SCEFONT, "sceFontFindFont(%x, %x, %x)", libHandle, fontStylePtr, errorCodePtr); - auto requestedStyle = Memory::GetStruct(fontStylePtr); + auto requestedStyle = PSPPointer::Create(fontStylePtr); // Find the closest exact match for the fields specified. float hRes = requestedStyle->fontHRes > 0.0f ? requestedStyle->fontHRes : fontLib->FontHRes(); @@ -979,7 +979,7 @@ int sceFontGetFontInfo(u32 fontHandle, u32 fontInfoPtr) { } DEBUG_LOG(SCEFONT, "sceFontGetFontInfo(%x, %x)", fontHandle, fontInfoPtr); - auto fi = Memory::GetStruct(fontInfoPtr); + auto fi = PSPPointer::Create(fontInfoPtr); font->GetPGF()->GetFontInfo(fi); fi->fontStyle = font->GetFont()->GetFontStyle(); @@ -1008,7 +1008,7 @@ int sceFontGetCharInfo(u32 fontHandle, u32 charCode, u32 charInfoPtr) { DEBUG_LOG(SCEFONT, "sceFontGetCharInfo(%08x, %i, %08x)", fontHandle, charCode, charInfoPtr); auto fontLib = font->GetFontLib(); int altCharCode = fontLib == NULL ? -1 : fontLib->GetAltCharCode(); - auto charInfo = Memory::GetStruct(charInfoPtr); + auto charInfo = PSPPointer::Create(charInfoPtr); font->GetPGF()->GetCharInfo(charCode, charInfo, altCharCode); return 0; @@ -1057,7 +1057,7 @@ int sceFontGetCharGlyphImage(u32 fontHandle, u32 charCode, u32 glyphImagePtr) { } DEBUG_LOG(SCEFONT, "sceFontGetCharGlyphImage(%x, %x, %x)", fontHandle, charCode, glyphImagePtr); - auto glyph = Memory::GetStruct(glyphImagePtr); + auto glyph = PSPPointer::Create(glyphImagePtr); int altCharCode = font->GetFontLib()->GetAltCharCode(); font->GetPGF()->DrawCharacter(glyph, 0, 0, 8192, 8192, charCode, altCharCode, FONT_PGF_CHARGLYPH); return 0; @@ -1075,7 +1075,7 @@ int sceFontGetCharGlyphImage_Clip(u32 fontHandle, u32 charCode, u32 glyphImagePt } DEBUG_LOG(SCEFONT, "sceFontGetCharGlyphImage_Clip(%08x, %i, %08x, %i, %i, %i, %i)", fontHandle, charCode, glyphImagePtr, clipXPos, clipYPos, clipWidth, clipHeight); - auto glyph = Memory::GetStruct(glyphImagePtr); + auto glyph = PSPPointer::Create(glyphImagePtr); int altCharCode = font->GetFontLib()->GetAltCharCode(); font->GetPGF()->DrawCharacter(glyph, clipXPos, clipYPos, clipWidth, clipHeight, charCode, altCharCode, FONT_PGF_CHARGLYPH); return 0; diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 21f505727e..7edd0220fd 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1649,7 +1649,7 @@ u32 sceKernelStopModule(u32 moduleId, u32 argSize, u32 argAddr, u32 returnValueA // TODO: Need to test how this really works. Let's assume it's an override. if (Memory::IsValidAddress(optionAddr)) { - auto options = Memory::GetStruct(optionAddr); + auto options = PSPPointer::Create(optionAddr); // TODO: Check how size handling actually works. if (options->size != 0 && options->priority != 0) priority = options->priority; @@ -1728,7 +1728,7 @@ u32 sceKernelStopUnloadSelfModuleWithStatus(u32 exitCode, u32 argSize, u32 argp, // TODO: Need to test how this really works. Let's assume it's an override. if (Memory::IsValidAddress(optionAddr)) { - auto options = Memory::GetStruct(optionAddr); + auto options = PSPPointer::Create(optionAddr); // TODO: Check how size handling actually works. if (options->size != 0 && options->priority != 0) priority = options->priority; diff --git a/Core/HLE/sceKernelMutex.cpp b/Core/HLE/sceKernelMutex.cpp index ef0f0d3187..215f3c542d 100644 --- a/Core/HLE/sceKernelMutex.cpp +++ b/Core/HLE/sceKernelMutex.cpp @@ -721,7 +721,7 @@ int sceKernelCreateLwMutex(u32 workareaPtr, const char *name, u32 attr, int init mutex->nm.uid = id; mutex->nm.workarea = workareaPtr; mutex->nm.initialCount = initialCount; - auto workarea = Memory::GetStruct(workareaPtr); + auto workarea = PSPPointer::Create(workareaPtr); workarea->init(); workarea->lockLevel = initialCount; if (initialCount == 0) @@ -777,7 +777,7 @@ int sceKernelDeleteLwMutex(u32 workareaPtr) if (!workareaPtr || !Memory::IsValidAddress(workareaPtr)) return SCE_KERNEL_ERROR_ILLEGAL_ADDR; - auto workarea = Memory::GetStruct(workareaPtr); + auto workarea = PSPPointer::Create(workareaPtr); u32 error; LwMutex *mutex = kernelObjects.Get(workarea->uid, error); @@ -800,8 +800,7 @@ int sceKernelDeleteLwMutex(u32 workareaPtr) return error; } -template -bool __KernelLockLwMutex(T workarea, int count, u32 &error) +bool __KernelLockLwMutex(NativeLwMutexWorkarea *workarea, int count, u32 &error) { if (!error) { @@ -931,7 +930,7 @@ int sceKernelTryLockLwMutex(u32 workareaPtr, int count) { DEBUG_LOG(SCEKERNEL, "sceKernelTryLockLwMutex(%08x, %i)", workareaPtr, count); - auto workarea = Memory::GetStruct(workareaPtr); + auto workarea = PSPPointer::Create(workareaPtr); u32 error = 0; if (__KernelLockLwMutex(workarea, count, error)) @@ -947,7 +946,7 @@ int sceKernelTryLockLwMutex_600(u32 workareaPtr, int count) { DEBUG_LOG(SCEKERNEL, "sceKernelTryLockLwMutex_600(%08x, %i)", workareaPtr, count); - auto workarea = Memory::GetStruct(workareaPtr); + auto workarea = PSPPointer::Create(workareaPtr); u32 error = 0; if (__KernelLockLwMutex(workarea, count, error)) @@ -962,7 +961,7 @@ int sceKernelLockLwMutex(u32 workareaPtr, int count, u32 timeoutPtr) { VERBOSE_LOG(SCEKERNEL, "sceKernelLockLwMutex(%08x, %i, %08x)", workareaPtr, count, timeoutPtr); - auto workarea = Memory::GetStruct(workareaPtr); + auto workarea = PSPPointer::Create(workareaPtr); u32 error = 0; if (__KernelLockLwMutex(workarea, count, error)) @@ -993,7 +992,7 @@ int sceKernelLockLwMutexCB(u32 workareaPtr, int count, u32 timeoutPtr) { VERBOSE_LOG(SCEKERNEL, "sceKernelLockLwMutexCB(%08x, %i, %08x)", workareaPtr, count, timeoutPtr); - auto workarea = Memory::GetStruct(workareaPtr); + auto workarea = PSPPointer::Create(workareaPtr); u32 error = 0; if (__KernelLockLwMutex(workarea, count, error)) @@ -1024,7 +1023,7 @@ int sceKernelUnlockLwMutex(u32 workareaPtr, int count) { VERBOSE_LOG(SCEKERNEL, "sceKernelUnlockLwMutex(%08x, %i)", workareaPtr, count); - auto workarea = Memory::GetStruct(workareaPtr); + auto workarea = PSPPointer::Create(workareaPtr); if (workarea->uid == -1) return PSP_LWMUTEX_ERROR_NO_SUCH_LWMUTEX; @@ -1095,7 +1094,7 @@ int sceKernelReferLwMutexStatus(u32 workareaPtr, u32 infoPtr) if (!Memory::IsValidAddress(workareaPtr)) return -1; - auto workarea = Memory::GetStruct(workareaPtr); + auto workarea = PSPPointer::Create(workareaPtr); int error = __KernelReferLwMutexStatus(workarea->uid, infoPtr); if (error >= 0) diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 0af7bc84db..2e42929bfb 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -1315,7 +1315,7 @@ u32 sceMpegFlushAllStream(u32 mpeg) ctx->isAnalyzed = false; if (Memory::IsValidAddress(ctx->mpegRingbufferAddr)) { - auto ringbuffer = Memory::GetStruct(ctx->mpegRingbufferAddr); + auto ringbuffer = PSPPointer::Create(ctx->mpegRingbufferAddr); ringbuffer->packetsFree = ringbuffer->packets; ringbuffer->packetsRead = 0; diff --git a/Core/HLE/sceNetAdhoc.cpp b/Core/HLE/sceNetAdhoc.cpp index d4b0607b66..35e7c989f0 100644 --- a/Core/HLE/sceNetAdhoc.cpp +++ b/Core/HLE/sceNetAdhoc.cpp @@ -1256,7 +1256,7 @@ int sceNetAdhocPtpAccept(int id, u32 peerMacAddrPtr, u32 peerPortPtr, int timeou SceNetEtherAddr * addr = NULL; if (Memory::IsValidAddress(peerMacAddrPtr)) { - addr = Memory::GetStruct(peerMacAddrPtr); + addr = PSPPointer::Create(peerMacAddrPtr); } uint16_t * port = NULL; if (Memory::IsValidAddress(peerPortPtr)) { diff --git a/Core/HLE/sceRtc.cpp b/Core/HLE/sceRtc.cpp index 9262594628..9661b85826 100644 --- a/Core/HLE/sceRtc.cpp +++ b/Core/HLE/sceRtc.cpp @@ -201,7 +201,7 @@ void __RtcTicksToPspTime(ScePspDateTime &t, u64 ticks) t.second = local->tm_sec; } -u64 __RtcPspTimeToTicks(ScePspDateTime &pt) +u64 __RtcPspTimeToTicks(const ScePspDateTime &pt) { tm local; local.tm_year = pt.year - 1900; @@ -232,7 +232,7 @@ u64 __RtcPspTimeToTicks(ScePspDateTime &pt) return result + tickOffset; } -bool __RtcValidatePspTime(ScePspDateTime &t) +bool __RtcValidatePspTime(const ScePspDateTime &t) { return t.year > 0 && t.year <= 9999; } @@ -672,7 +672,7 @@ int sceRtcSetWin32FileTime(u32 datePtr, u64 win32Time) DEBUG_LOG(SCERTC, "sceRtcSetWin32FileTime(%08x, %lld)", datePtr, win32Time); u64 ticks = (win32Time / 10) + rtcFiletimeOffset; - auto pspTime = Memory::GetStruct(datePtr); + auto pspTime = PSPPointer::Create(datePtr); __RtcTicksToPspTime(*pspTime, ticks); return 0; } @@ -689,7 +689,7 @@ int sceRtcGetWin32FileTime(u32 datePtr, u32 win32TimePtr) if (!Memory::IsValidAddress(win32TimePtr)) return SCE_KERNEL_ERROR_INVALID_VALUE; - auto pspTime = Memory::GetStruct(datePtr); + auto pspTime = PSPPointer::Create(datePtr); u64 result = __RtcPspTimeToTicks(*pspTime); if (!__RtcValidatePspTime(*pspTime) || result < rtcFiletimeOffset) diff --git a/Core/MemMap.h b/Core/MemMap.h index 9a6d68ba70..c312ac95f8 100644 --- a/Core/MemMap.h +++ b/Core/MemMap.h @@ -307,13 +307,6 @@ void WriteStruct(u32 address, T *ptr) memcpy(GetPointer(address), ptr, sz); } -// Expect this to be some form of auto class on big endian. -template -T *GetStruct(u32 address) -{ - return (T *)GetPointer(address); -} - const char *GetAddressName(u32 address); };