diff --git a/Common/Data/Random/Rng.h b/Common/Data/Random/Rng.h index 50ec4ea60e..8be052c0ba 100644 --- a/Common/Data/Random/Rng.h +++ b/Common/Data/Random/Rng.h @@ -1,6 +1,7 @@ #pragma once #include +#include "Common/Swap.h" // George Marsaglia-style random number generator. class GMRng { @@ -57,8 +58,8 @@ private: MT_SIZE = 624, }; - uint32_t index_; - uint32_t mt_[MT_SIZE]; + u32_le index_; + u32_le mt_[MT_SIZE]; void gen() { for(uint32_t i = 0; i < MT_SIZE; i++){ diff --git a/Core/ELF/ParamSFO.cpp b/Core/ELF/ParamSFO.cpp index b12b508942..5b966f1bfb 100644 --- a/Core/ELF/ParamSFO.cpp +++ b/Core/ELF/ParamSFO.cpp @@ -21,25 +21,26 @@ #include "Common/CommonTypes.h" #include "Common/Log.h" #include "Common/StringUtils.h" +#include "Common/Swap.h" #include "Core/ELF/ParamSFO.h" #include "Core/Core.h" struct Header { - u32 magic; /* Always PSF */ - u32 version; /* Usually 1.1 */ - u32 key_table_start; /* Start position of key_table */ - u32 data_table_start; /* Start position of data_table */ - u32 index_table_entries; /* Number of entries in index_table*/ + u32_le magic; /* Always PSF */ + u32_le version; /* Usually 1.1 */ + u32_le key_table_start; /* Start position of key_table */ + u32_le data_table_start; /* Start position of data_table */ + u32_le index_table_entries; /* Number of entries in index_table*/ }; struct IndexTable { - u16 key_table_offset; /* Offset of the param_key from start of key_table */ - u16 param_fmt; /* Type of data of param_data in the data_table */ - u32 param_len; /* Used Bytes by param_data in the data_table */ - u32 param_max_len; /* Total bytes reserved for param_data in the data_table */ - u32 data_table_offset; /* Offset of the param_data from start of data_table */ + u16_le key_table_offset; /* Offset of the param_key from start of key_table */ + u16_le param_fmt; /* Type of data of param_data in the data_table */ + u32_le param_len; /* Used Bytes by param_data in the data_table */ + u32_le param_max_len; /* Total bytes reserved for param_data in the data_table */ + u32_le data_table_offset; /* Offset of the param_data from start of data_table */ }; void ParamSFOData::SetValue(std::string key, unsigned int value, int max_size) { @@ -113,7 +114,7 @@ bool ParamSFOData::ReadSFO(const u8 *paramsfo, size_t size) { case 0x0404: { // Unsigned int - const u32 *data = (const u32 *)(data_start + indexTables[i].data_table_offset); + const u32_le *data = (const u32_le *)(data_start + indexTables[i].data_table_offset); SetValue(key,*data,indexTables[i].param_max_len); VERBOSE_LOG(LOADER, "%s %08x", key, *data); } @@ -218,7 +219,7 @@ bool ParamSFOData::WriteSFO(u8 **paramsfo, size_t *size) { index_ptr->param_fmt = 0x0404; index_ptr->param_len = 4; - *(int*)data_ptr = it->second.i_value; + *(s32_le *)data_ptr = it->second.i_value; } else if (it->second.type == VT_UTF8_SPE) { diff --git a/Core/Font/PGF.cpp b/Core/Font/PGF.cpp index deec9d589e..c1a8802571 100644 --- a/Core/Font/PGF.cpp +++ b/Core/Font/PGF.cpp @@ -41,7 +41,7 @@ static int getBits(int numBits, const u8 *buf, size_t pos) { _dbg_assert_msg_(numBits <= 32, "Unable to return more than 32 bits, %d requested", numBits); const size_t wordpos = pos >> 5; - const u32 *wordbuf = (const u32 *)buf; + const u32_le *wordbuf = (const u32_le *)buf; const u8 bitoff = pos & 31; // Might just be in one, has to be within two. @@ -350,7 +350,7 @@ bool PGF::GetCharInfo(int charCode, PGFCharInfo *charInfo, int altCharCode, int charInfo->sfp26Height = glyph.dimensionHeight; charInfo->sfp26Ascender = glyph.yAdjustH; // Font y goes upwards. If top is 10 and height is 11, the descender is approx. -1 (below 0.) - charInfo->sfp26Descender = charInfo->sfp26Ascender - (s32_le)charInfo->sfp26Height; + charInfo->sfp26Descender = charInfo->sfp26Ascender - (s32)charInfo->sfp26Height; charInfo->sfp26BearingHX = glyph.xAdjustH; charInfo->sfp26BearingHY = glyph.yAdjustH; charInfo->sfp26BearingVX = glyph.xAdjustV; diff --git a/Core/HLE/FunctionWrappers.h b/Core/HLE/FunctionWrappers.h index 01124ea157..73cc956d12 100644 --- a/Core/HLE/FunctionWrappers.h +++ b/Core/HLE/FunctionWrappers.h @@ -147,7 +147,7 @@ template void WrapI_IIIIIIU() { // Hm, do so many params get passed in registers? template void WrapI_IIIIIIIIU() { - u32 param8 = *(u32*)Memory::GetPointer(currentMIPS->r[29]); //Fixed 9th parameter, thanks to Kingcom + u32 param8 = *(const u32_le *)Memory::GetPointer(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); } diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index 86f696e994..c731e5a9f9 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -22,6 +22,7 @@ #include "Common/Common.h" #include "Common/Data/Convert/SmallDataConvert.h" #include "Common/Log.h" +#include "Common/Swap.h" #include "Core/Config.h" #include "Core/Debugger/Breakpoints.h" #include "Core/Debugger/SymbolMap.h" @@ -422,8 +423,8 @@ static int Replace_vmmul_q_transp() { // a1 = matrix // a2 = source address static int Replace_gta_dl_write_matrix() { - u32 *ptr = (u32 *)Memory::GetPointer(PARAM(0)); - u32 *src = (u32_le *)Memory::GetPointer(PARAM(2)); + u32_le *ptr = (u32_le *)Memory::GetPointer(PARAM(0)); + u32_le *src = (u32_le *)Memory::GetPointer(PARAM(2)); u32 matrix = PARAM(1) << 24; if (!ptr || !src) { @@ -431,7 +432,7 @@ static int Replace_gta_dl_write_matrix() { return 38; } - u32 *dest = (u32_le *)Memory::GetPointer(ptr[0]); + u32_le *dest = (u32_le *)Memory::GetPointer(ptr[0]); if (!dest) { RETURN(0); return 38; @@ -481,15 +482,15 @@ 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 *dlStruct = (u32 *)Memory::GetPointer(PARAM(0)); - u32 *src = (u32 *)Memory::GetPointer(PARAM(2)); + u32_le *dlStruct = (u32_le *)Memory::GetPointer(PARAM(0)); + u32_le *src = (u32_le *)Memory::GetPointer(PARAM(2)); if (!dlStruct || !src) { RETURN(0); return 60; } - u32 *dest = (u32 *)Memory::GetPointer(dlStruct[2]); + u32_le *dest = (u32_le *)Memory::GetPointer(dlStruct[2]); if (!dest) { RETURN(0); return 60; diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index bdaeea8b98..d05a73de96 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -1569,7 +1569,7 @@ static u32 sceAtracGetNextSample(int atracID, u32 outNAddr) { // Obtains the number of frames remaining in the buffer which can be decoded. // When no more data would be needed, this returns a negative number. static u32 sceAtracGetRemainFrame(int atracID, u32 remainAddr) { - auto remainingFrames = PSPPointer::Create(remainAddr); + auto remainingFrames = PSPPointer::Create(remainAddr); Atrac *atrac = getAtrac(atracID); u32 err = AtracValidateManaged(atrac); @@ -1588,8 +1588,8 @@ static u32 sceAtracGetRemainFrame(int atracID, u32 remainAddr) { } static u32 sceAtracGetSecondBufferInfo(int atracID, u32 fileOffsetAddr, u32 desiredSizeAddr) { - auto fileOffset = PSPPointer::Create(fileOffsetAddr); - auto desiredSize = PSPPointer::Create(desiredSizeAddr); + auto fileOffset = PSPPointer::Create(fileOffsetAddr); + auto desiredSize = PSPPointer::Create(desiredSizeAddr); Atrac *atrac = getAtrac(atracID); u32 err = AtracValidateManaged(atrac); @@ -1624,13 +1624,13 @@ static u32 sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoop return err; } - auto outEndSample = PSPPointer::Create(outEndSampleAddr); + auto outEndSample = PSPPointer::Create(outEndSampleAddr); if (outEndSample.IsValid()) *outEndSample = atrac->endSample_; - auto outLoopStart = PSPPointer::Create(outLoopStartSampleAddr); + auto outLoopStart = PSPPointer::Create(outLoopStartSampleAddr); if (outLoopStart.IsValid()) *outLoopStart = atrac->loopStartSample_ == -1 ? -1 : atrac->loopStartSample_ - atrac->firstSampleOffset_ - atrac->FirstOffsetExtra(); - auto outLoopEnd = PSPPointer::Create(outLoopEndSampleAddr); + auto outLoopEnd = PSPPointer::Create(outLoopEndSampleAddr); if (outLoopEnd.IsValid()) *outLoopEnd = atrac->loopEndSample_ == -1 ? -1 : atrac->loopEndSample_ - atrac->firstSampleOffset_ - atrac->FirstOffsetExtra(); @@ -2295,8 +2295,8 @@ void _AtracGenerateContext(Atrac *atrac, SceAtracId *context) { context->info.decodePos = atrac->DecodePosBySample(atrac->currentSample_); context->info.streamDataByte = atrac->first_.size - atrac->dataOff_; - u8* buf = (u8*)context; - *(u32*)(buf + 0xfc) = atrac->atracID_; + u8 *buf = (u8 *)context; + *(u32_le *)(buf + 0xfc) = atrac->atracID_; } static u32 _sceAtracGetContextAddress(int atracID) { @@ -2418,9 +2418,9 @@ static int sceAtracLowLevelInitDecoder(int atracID, u32 paramsAddr) { static int sceAtracLowLevelDecode(int atracID, u32 sourceAddr, u32 sourceBytesConsumedAddr, u32 samplesAddr, u32 sampleBytesAddr) { auto srcp = PSPPointer::Create(sourceAddr); - auto srcConsumed = PSPPointer::Create(sourceBytesConsumedAddr); + auto srcConsumed = PSPPointer::Create(sourceBytesConsumedAddr); auto outp = PSPPointer::Create(samplesAddr); - auto outWritten = PSPPointer::Create(sampleBytesAddr); + auto outWritten = PSPPointer::Create(sampleBytesAddr); Atrac *atrac = getAtrac(atracID); if (!atrac) { diff --git a/Core/HLE/sceDeflt.cpp b/Core/HLE/sceDeflt.cpp index 5c1f579071..2f0b6ec469 100644 --- a/Core/HLE/sceDeflt.cpp +++ b/Core/HLE/sceDeflt.cpp @@ -31,7 +31,7 @@ static int sceDeflateDecompress(u32 OutBuffer, int OutBufferLength, u32 InBuffer uLong crc; z_stream stream; u8 *outBufferPtr; - u32 *crc32AddrPtr = 0; + u32_le *crc32AddrPtr = nullptr; if (!Memory::IsValidAddress(OutBuffer) || !Memory::IsValidAddress(InBuffer)) { ERROR_LOG(HLE, "sceZlibDecompress: Bad address %08x %08x", OutBuffer, InBuffer); @@ -42,7 +42,7 @@ static int sceDeflateDecompress(u32 OutBuffer, int OutBufferLength, u32 InBuffer ERROR_LOG(HLE, "sceZlibDecompress: Bad address %08x", Crc32Addr); return 0; } - crc32AddrPtr = (u32 *)Memory::GetPointer(Crc32Addr); + crc32AddrPtr = (u32_le *)Memory::GetPointer(Crc32Addr); } outBufferPtr = Memory::GetPointer(OutBuffer); stream.next_in = (Bytef*)Memory::GetPointer(InBuffer); @@ -77,7 +77,7 @@ static int sceGzipDecompress(u32 OutBuffer, int OutBufferLength, u32 InBuffer, u uLong crc; z_stream stream; u8 *outBufferPtr; - u32 *crc32AddrPtr = 0; + u32_le *crc32AddrPtr = nullptr; if (!Memory::IsValidAddress(OutBuffer) || !Memory::IsValidAddress(InBuffer)) { ERROR_LOG(HLE, "sceZlibDecompress: Bad address %08x %08x", OutBuffer, InBuffer); @@ -88,7 +88,7 @@ static int sceGzipDecompress(u32 OutBuffer, int OutBufferLength, u32 InBuffer, u ERROR_LOG(HLE, "sceZlibDecompress: Bad address %08x", Crc32Addr); return 0; } - crc32AddrPtr = (u32 *)Memory::GetPointer(Crc32Addr); + crc32AddrPtr = (u32_le *)Memory::GetPointer(Crc32Addr); } outBufferPtr = Memory::GetPointer(OutBuffer); stream.next_in = (Bytef*)Memory::GetPointer(InBuffer); @@ -122,7 +122,7 @@ static int sceZlibDecompress(u32 OutBuffer, int OutBufferLength, u32 InBuffer, u uLong crc; z_stream stream; u8 *outBufferPtr; - u32 *crc32AddrPtr = 0; + u32_le *crc32AddrPtr = 0; if (!Memory::IsValidAddress(OutBuffer) || !Memory::IsValidAddress(InBuffer)) { ERROR_LOG(HLE, "sceZlibDecompress: Bad address %08x %08x", OutBuffer, InBuffer); @@ -133,7 +133,7 @@ static int sceZlibDecompress(u32 OutBuffer, int OutBufferLength, u32 InBuffer, u ERROR_LOG(HLE, "sceZlibDecompress: Bad address %08x", Crc32Addr); return 0; } - crc32AddrPtr = (u32 *)Memory::GetPointer(Crc32Addr); + crc32AddrPtr = (u32_le *)Memory::GetPointer(Crc32Addr); } outBufferPtr = Memory::GetPointer(OutBuffer); stream.next_in = (Bytef*)Memory::GetPointer(InBuffer); diff --git a/Core/HLE/sceFont.cpp b/Core/HLE/sceFont.cpp index 6eb01a8647..89d5f79a38 100644 --- a/Core/HLE/sceFont.cpp +++ b/Core/HLE/sceFont.cpp @@ -944,7 +944,7 @@ static u32 sceFontNewLib(u32 paramPtr, u32 errorCodePtr) { __LoadInternalFonts(); auto params = PSPPointer::Create(paramPtr); - auto errorCode = PSPPointer::Create(errorCodePtr); + auto errorCode = PSPPointer::Create(errorCodePtr); if (!params.IsValid() || !errorCode.IsValid()) { ERROR_LOG_REPORT(SCEFONT, "sceFontNewLib(%08x, %08x): invalid addresses", paramPtr, errorCodePtr); @@ -979,7 +979,7 @@ static int sceFontDoneLib(u32 fontLibHandle) { // Open internal font into a FontLib static u32 sceFontOpen(u32 libHandle, u32 index, u32 mode, u32 errorCodePtr) { - auto errorCode = PSPPointer::Create(errorCodePtr); + auto errorCode = PSPPointer::Create(errorCodePtr); if (!errorCode.IsValid()) { // Would crash on the PSP. ERROR_LOG(SCEFONT, "sceFontOpen(%x, %x, %x, %x): invalid pointer", libHandle, index, mode, errorCodePtr); @@ -1009,7 +1009,7 @@ static u32 sceFontOpen(u32 libHandle, u32 index, u32 mode, u32 errorCodePtr) { // Open a user font in RAM into a FontLib static u32 sceFontOpenUserMemory(u32 libHandle, u32 memoryFontAddrPtr, u32 memoryFontLength, u32 errorCodePtr) { - auto errorCode = PSPPointer::Create(errorCodePtr); + auto errorCode = PSPPointer::Create(errorCodePtr); if (!errorCode.IsValid()) { ERROR_LOG_REPORT(SCEFONT, "sceFontOpenUserMemory(%08x, %08x, %08x, %08x): invalid error address", libHandle, memoryFontAddrPtr, memoryFontLength, errorCodePtr); return -1; @@ -1054,7 +1054,7 @@ static u32 sceFontOpenUserMemory(u32 libHandle, u32 memoryFontAddrPtr, u32 memor // Open a user font in a file into a FontLib static u32 sceFontOpenUserFile(u32 libHandle, const char *fileName, u32 mode, u32 errorCodePtr) { - auto errorCode = PSPPointer::Create(errorCodePtr); + auto errorCode = PSPPointer::Create(errorCodePtr); if (!errorCode.IsValid()) { ERROR_LOG_REPORT(SCEFONT, "sceFontOpenUserFile(%08x, %s, %08x, %08x): invalid error address", libHandle, fileName, mode, errorCodePtr); @@ -1114,7 +1114,7 @@ static int sceFontClose(u32 fontHandle) { } static int sceFontFindOptimumFont(u32 libHandle, u32 fontStylePtr, u32 errorCodePtr) { - auto errorCode = PSPPointer::Create(errorCodePtr); + auto errorCode = PSPPointer::Create(errorCodePtr); if (!errorCode.IsValid()) { ERROR_LOG_REPORT(SCEFONT, "sceFontFindOptimumFont(%08x, %08x, %08x): invalid error address", libHandle, fontStylePtr, errorCodePtr); return SCE_KERNEL_ERROR_INVALID_ARGUMENT; @@ -1139,8 +1139,8 @@ static int sceFontFindOptimumFont(u32 libHandle, u32 fontStylePtr, u32 errorCode 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(); - float vRes = requestedStyle->fontVRes > 0.0f ? requestedStyle->fontVRes : fontLib->FontVRes(); + float hRes = requestedStyle->fontHRes > 0.0f ? (float)requestedStyle->fontHRes : fontLib->FontHRes(); + float vRes = requestedStyle->fontVRes > 0.0f ? (float)requestedStyle->fontVRes : fontLib->FontVRes(); Font *optimumFont = 0; Font *nearestFont = 0; float nearestDist = std::numeric_limits::infinity(); @@ -1182,7 +1182,7 @@ static int sceFontFindOptimumFont(u32 libHandle, u32 fontStylePtr, u32 errorCode // Returns the font index, not handle static int sceFontFindFont(u32 libHandle, u32 fontStylePtr, u32 errorCodePtr) { - auto errorCode = PSPPointer::Create(errorCodePtr); + auto errorCode = PSPPointer::Create(errorCodePtr); if (!errorCode.IsValid()) { ERROR_LOG_REPORT(SCEFONT, "sceFontFindFont(%x, %x, %x): invalid error address", libHandle, fontStylePtr, errorCodePtr); return SCE_KERNEL_ERROR_INVALID_ARGUMENT; @@ -1206,7 +1206,7 @@ static int sceFontFindFont(u32 libHandle, u32 fontStylePtr, u32 errorCodePtr) { auto requestedStyle = PSPPointer::Create(fontStylePtr); // Find the closest exact match for the fields specified. - float hRes = requestedStyle->fontHRes > 0.0f ? requestedStyle->fontHRes : fontLib->FontHRes(); + float hRes = requestedStyle->fontHRes > 0.0f ? (float)requestedStyle->fontHRes : fontLib->FontHRes(); for (size_t i = 0; i < internalFonts.size(); i++) { if (internalFonts[i]->MatchesStyle(*requestedStyle) != MATCH_NONE) { auto matchStyle = internalFonts[i]->GetFontStyle(); @@ -1461,7 +1461,7 @@ static int sceFontGetFontList(u32 fontLibHandle, u32 fontStylePtr, int numFonts) } static int sceFontGetNumFontList(u32 fontLibHandle, u32 errorCodePtr) { - auto errorCode = PSPPointer::Create(errorCodePtr); + auto errorCode = PSPPointer::Create(errorCodePtr); if (!errorCode.IsValid()) { ERROR_LOG_REPORT(SCEFONT, "sceFontGetNumFontList(%08x, %08x): invalid error address", fontLibHandle, errorCodePtr); return ERROR_FONT_INVALID_PARAMETER; @@ -1493,7 +1493,7 @@ static int sceFontSetResolution(u32 fontLibHandle, float hRes, float vRes) { } static float sceFontPixelToPointH(int fontLibHandle, float fontPixelsH, u32 errorCodePtr) { - auto errorCode = PSPPointer::Create(errorCodePtr); + auto errorCode = PSPPointer::Create(errorCodePtr); if (!errorCode.IsValid()) { ERROR_LOG_REPORT(SCEFONT, "sceFontPixelToPointH(%08x, %f, %08x): invalid error address", fontLibHandle, fontPixelsH, errorCodePtr); return 0.0f; @@ -1510,7 +1510,7 @@ static float sceFontPixelToPointH(int fontLibHandle, float fontPixelsH, u32 erro } static float sceFontPixelToPointV(int fontLibHandle, float fontPixelsV, u32 errorCodePtr) { - auto errorCode = PSPPointer::Create(errorCodePtr); + auto errorCode = PSPPointer::Create(errorCodePtr); if (!errorCode.IsValid()) { ERROR_LOG_REPORT(SCEFONT, "sceFontPixelToPointV(%08x, %f, %08x): invalid error address", fontLibHandle, fontPixelsV, errorCodePtr); return 0.0f; @@ -1527,7 +1527,7 @@ static float sceFontPixelToPointV(int fontLibHandle, float fontPixelsV, u32 erro } static float sceFontPointToPixelH(int fontLibHandle, float fontPointsH, u32 errorCodePtr) { - auto errorCode = PSPPointer::Create(errorCodePtr); + auto errorCode = PSPPointer::Create(errorCodePtr); if (!errorCode.IsValid()) { ERROR_LOG_REPORT(SCEFONT, "sceFontPointToPixelH(%08x, %f, %08x): invalid error address", fontLibHandle, fontPointsH, errorCodePtr); return 0.0f; @@ -1544,7 +1544,7 @@ static float sceFontPointToPixelH(int fontLibHandle, float fontPointsH, u32 erro } static float sceFontPointToPixelV(int fontLibHandle, float fontPointsV, u32 errorCodePtr) { - auto errorCode = PSPPointer::Create(errorCodePtr); + auto errorCode = PSPPointer::Create(errorCodePtr); if (!errorCode.IsValid()) { ERROR_LOG_REPORT(SCEFONT, "sceFontPointToPixelV(%08x, %f, %08x): invalid error address", fontLibHandle, fontPointsV, errorCodePtr); return 0.0f; diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 9abfd60f51..d64ff4d02e 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -2470,9 +2470,9 @@ static int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, // Even if the size is 4, it still actually reads a 16 byte struct, it seems. if (Memory::IsValidAddress(indataPtr) && inlen >= 4) { struct SeekInfo { - u64 offset; - u32 unk; - u32 whence; + u64_le offset; + u32_le unk; + u32_le whence; }; const auto seekInfo = PSPPointer::Create(indataPtr); FileMove seek; @@ -2574,9 +2574,9 @@ static int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, if (Memory::IsValidAddress(indataPtr) && inlen >= 4) { struct SeekInfo { - u64 offset; - u32 unk; - u32 whence; + u64_le offset; + u32_le unk; + u32_le whence; }; const auto seekInfo = PSPPointer::Create(indataPtr); FileMove seek; diff --git a/Core/HLE/sceJpeg.cpp b/Core/HLE/sceJpeg.cpp index 4230675599..d438a16111 100644 --- a/Core/HLE/sceJpeg.cpp +++ b/Core/HLE/sceJpeg.cpp @@ -84,7 +84,7 @@ static void __JpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int bufferW int width = (widthHeight >> 16) & 0xFFF; int lineWidth = std::min(width, bufferWidth); int skipEndOfLine = std::max(0, bufferWidth - lineWidth); - u32 *imageBuffer = (u32*)Memory::GetPointer(imageAddr); + u32_le *imageBuffer = (u32_le *)Memory::GetPointer(imageAddr); int sizeY = width * height; int sizeCb = sizeY >> 2; u8 *Y = (u8*)Memory::GetPointer(yCbCrAddr); @@ -150,7 +150,7 @@ static int __DecodeJpeg(u32 jpegAddr, int jpegSize, u32 imageAddr) { if (actual_components == 3) { u24_be *imageBuffer = (u24_be*)jpegBuf; - u32 *abgr = (u32*)Memory::GetPointer(imageAddr); + u32_le *abgr = (u32_le *)Memory::GetPointer(imageAddr); int pspWidth = 0; for (int w = 2; w <= 4096; w *= 2) { if (w >= width && w >= height) { diff --git a/Core/HLE/sceKernel.h b/Core/HLE/sceKernel.h index ca9bdfc2d1..08cfb4903d 100644 --- a/Core/HLE/sceKernel.h +++ b/Core/HLE/sceKernel.h @@ -500,7 +500,7 @@ public: } } - int ListIDType(int type, SceUID *uids, int count) const { + int ListIDType(int type, SceUID_le *uids, int count) const { int total = 0; for (int i = 0; i < maxCount; i++) { if (!occupied[i]) { diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 5ea2a721c1..728c188167 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1089,7 +1089,7 @@ static bool KernelImportModuleFuncs(PSPModule *module, u32 *firstImportStubAddr, } snprintf(temp, sizeof(temp), "%s ver=%04x, flags=%04x, size=%d, numVars=%d, numFuncs=%d, nidData=%08x, firstSym=%08x, varData=%08x, extra=%08x\n", - modulename, entry->version, entry->flags, entry->size, entry->numVars, entry->numFuncs, entry->nidData, entry->firstSymAddr, entry->size >= 6 ? entry->varData : 0, entry->size >= 7 ? entry->extra : 0); + modulename, entry->version, entry->flags, entry->size, entry->numVars, entry->numFuncs, entry->nidData, entry->firstSymAddr, entry->size >= 6 ? (u32)entry->varData : 0, entry->size >= 7 ? (u32)entry->extra : 0); debugInfo += temp; } diff --git a/Core/HLE/sceKernelMutex.cpp b/Core/HLE/sceKernelMutex.cpp index 1b6b314764..ea767c197d 100644 --- a/Core/HLE/sceKernelMutex.cpp +++ b/Core/HLE/sceKernelMutex.cpp @@ -1089,7 +1089,7 @@ static int __KernelReferLwMutexStatus(SceUID uid, u32 infoPtr) // Refresh and write m->nm.currentCount = workarea->lockLevel; - m->nm.lockThread = workarea->lockThread == 0 ? -1 : workarea->lockThread; + m->nm.lockThread = workarea->lockThread == 0 ? SceUID_le(-1) : workarea->lockThread; m->nm.numWaitThreads = (int) m->waitingThreads.size(); Memory::WriteStruct(infoPtr, &m->nm); } diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index 1cf0e6211a..d6251aaa84 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -1187,7 +1187,7 @@ void __KernelThreadingShutdown() { std::string __KernelThreadingSummary() { PSPThread *t = __GetCurrentThread(); - return StringFromFormat("Cur thread: %s (attr %08x)", t ? t->GetName() : "(null)", t ? t->nt.attr : 0); + return StringFromFormat("Cur thread: %s (attr %08x)", t ? t->GetName() : "(null)", t ? (u32)t->nt.attr : 0); } const char *__KernelGetThreadName(SceUID threadID) @@ -1400,7 +1400,7 @@ u32 sceKernelGetThreadmanIdList(u32 type, u32 readBufPtr, u32 readBufSize, u32 i } u32 total = 0; - auto uids = PSPPointer::Create(readBufPtr); + auto uids = PSPPointer::Create(readBufPtr); u32 error; if (type > 0 && type <= SCE_KERNEL_TMID_Tlspl) { DEBUG_LOG(SCEKERNEL, "sceKernelGetThreadmanIdList(%i, %08x, %i, %08x)", type, readBufPtr, readBufSize, idCountPtr); @@ -2020,7 +2020,7 @@ int __KernelStartThread(SceUID threadToStartID, int argSize, u32 argBlockPtr, bo return error; PSPThread *cur = __GetCurrentThread(); - __KernelResetThread(startThread, cur ? cur->nt.currentPriority : 0); + __KernelResetThread(startThread, cur ? (s32)cur->nt.currentPriority : 0); u32 &sp = startThread->context.r[MIPS_REG_SP]; // Force args means just use those as a0/a1 without any special treatment. diff --git a/Core/HLE/sceP3da.cpp b/Core/HLE/sceP3da.cpp index 1595dc139e..de5ce004dc 100644 --- a/Core/HLE/sceP3da.cpp +++ b/Core/HLE/sceP3da.cpp @@ -48,11 +48,11 @@ static u32 sceP3daBridgeCore(u32 p3daCoreAddr, u32 channelsNum, u32 samplesNum, DEBUG_LOG(SCEAUDIO, "sceP3daBridgeCore(%08x, %08x, %08x, %08x, %08x)", p3daCoreAddr, channelsNum, samplesNum, inputAddr, outputAddr); if (Memory::IsValidAddress(inputAddr) && Memory::IsValidAddress(outputAddr)) { int scaleval = getScaleValue(channelsNum); - s16* outbuf = (s16*)Memory::GetPointer(outputAddr); + s16_le *outbuf = (s16_le *)Memory::GetPointer(outputAddr); memset(outbuf, 0, samplesNum * sizeof(s16) * 2); for (u32 k = 0; k < channelsNum; k++) { u32 inaddr = Memory::Read_U32(inputAddr + k * 4); - s16 *inbuf = (s16*)Memory::GetPointer(inaddr); + const s16 *inbuf = (const s16 *)Memory::GetPointer(inaddr); if (!inbuf) continue; for (u32 i = 0; i < samplesNum; i++) { diff --git a/Core/HLE/scePsmf.cpp b/Core/HLE/scePsmf.cpp index c21aa4be1d..02957798f0 100644 --- a/Core/HLE/scePsmf.cpp +++ b/Core/HLE/scePsmf.cpp @@ -110,8 +110,8 @@ struct PsmfData { struct PsmfPlayerCreateData { PSPPointer buffer; - u32 bufferSize; - int threadPriority; + u32_le bufferSize; + s32_le threadPriority; }; struct PsmfPlayerData { @@ -1106,7 +1106,7 @@ static u32 scePsmfGetEPidWithTimestamp(u32 psmfStruct, u32 ts) } static int scePsmfPlayerCreate(u32 psmfPlayer, u32 dataPtr) { - auto player = PSPPointer::Create(psmfPlayer); + auto player = PSPPointer::Create(psmfPlayer); const auto data = PSPPointer::Create(dataPtr); if (!player.IsValid() || !data.IsValid()) { diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index c79faa2149..2eebf30474 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -129,7 +129,7 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader) { return IdentifiedFileType::ERROR_IDENTIFYING; } - u32 psar_offset = 0, psar_id = 0; + u32_le psar_offset = 0, psar_id = 0; u32 _id = id; if (!memcmp(&_id, "PK\x03\x04", 4) || !memcmp(&_id, "PK\x05\x06", 4) || !memcmp(&_id, "PK\x07\x08", 4)) { return IdentifiedFileType::ARCHIVE_ZIP; diff --git a/Core/MemMap.h b/Core/MemMap.h index 2c6be016b9..465802fb32 100644 --- a/Core/MemMap.h +++ b/Core/MemMap.h @@ -175,9 +175,9 @@ inline u32 ReadUnchecked_U32(const u32 address) { inline float ReadUnchecked_Float(const u32 address) { #ifdef MASKED_PSP_MEMORY - return *(float *)(base + (address & MEMVIEW32_MASK)); + return *(float_le *)(base + (address & MEMVIEW32_MASK)); #else - return *(float *)(base + address); + return *(float_le *)(base + address); #endif } @@ -207,9 +207,9 @@ inline void WriteUnchecked_U32(u32 data, u32 address) { inline void WriteUnchecked_Float(float data, u32 address) { #ifdef MASKED_PSP_MEMORY - *(float *)(base + (address & MEMVIEW32_MASK)) = data; + *(float_le *)(base + (address & MEMVIEW32_MASK)) = data; #else - *(float *)(base + address) = data; + *(float_le *)(base + address) = data; #endif } diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 290a30e2ce..2393431c76 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -270,8 +270,8 @@ bool DrawEngineCommon::GetCurrentSimpleVertices(int count, std::vector= 0) { - auto stack = PSPPointer::Create(stackPtr); + auto stack = PSPPointer::Create(stackPtr); if (stack.IsValid()) { auto entry = currentList->stack[index]; // Not really sure what most of these values are. @@ -702,7 +702,7 @@ u32 GPUCommon::EnqueueList(u32 listpc, u32 stall, int subIntrBase, PSPPointersize >= 16 ? args->stackAddr : 0; + u32 stackAddr = args.IsValid() && args->size >= 16 ? (u32)args->stackAddr : 0; // Check compatibility if (sceKernelGetCompiledSdkVersion() > 0x01FFFFFF) { //numStacks = 0; @@ -1041,7 +1041,7 @@ void GPUCommon::FastRunLoop(DisplayList &list) { int dc = downcount; for (; dc > 0; --dc) { // We know that display list PCs have the upper nibble == 0 - no need to mask the pointer - const u32 op = *(const u32 *)(Memory::base + list.pc); + const u32 op = *(const u32_le *)(Memory::base + list.pc); const u32 cmd = op >> 24; const CommandInfo &info = cmdInfo[cmd]; const u32 diff = op ^ gstate.cmdmem[cmd]; @@ -1636,8 +1636,8 @@ void GPUCommon::Execute_Prim(u32 op, u32 diff) { int totalVertCount = count; // PRIMs are often followed by more PRIMs. Save some work and submit them immediately. - const u32 *src = (const u32 *)Memory::GetPointerUnchecked(currentList->pc + 4); - const u32 *stall = currentList->stall ? (const u32 *)Memory::GetPointerUnchecked(currentList->stall) : 0; + const u32_le *src = (const u32_le *)Memory::GetPointerUnchecked(currentList->pc + 4); + const u32_le *stall = currentList->stall ? (const u32_le *)Memory::GetPointerUnchecked(currentList->stall) : 0; int cmdCount = 0; // Optimized submission of sequences of PRIM. Allows us to avoid going through all the mess diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index 501e369e52..31c298ec3e 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -567,8 +567,8 @@ bool TransformUnit::GetCurrentSimpleVertices(int count, std::vector 0 && (gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) { const u8 *inds = Memory::GetPointer(gstate_c.indexAddr); - const u16 *inds16 = (const u16 *)inds; - const u32 *inds32 = (const u32 *)inds; + const u16_le *inds16 = (const u16_le *)inds; + const u32_le *inds32 = (const u32_le *)inds; if (inds) { GetIndexBounds(inds, count, gstate.vertType, &indexLowerBound, &indexUpperBound);