Global: Correct many endian types and casts.

This commit is contained in:
aliaspider 2021-02-18 22:25:24 -08:00 committed by Unknown W. Brackets
parent 1197795945
commit 9a3e5879bb
22 changed files with 103 additions and 100 deletions

View file

@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
#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++){

View file

@ -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)
{

View file

@ -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;

View file

@ -147,7 +147,7 @@ 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 = *(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);
}

View file

@ -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;

View file

@ -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<u32>::Create(remainAddr);
auto remainingFrames = PSPPointer<u32_le>::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<u32>::Create(fileOffsetAddr);
auto desiredSize = PSPPointer<u32>::Create(desiredSizeAddr);
auto fileOffset = PSPPointer<u32_le>::Create(fileOffsetAddr);
auto desiredSize = PSPPointer<u32_le>::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<u32>::Create(outEndSampleAddr);
auto outEndSample = PSPPointer<u32_le>::Create(outEndSampleAddr);
if (outEndSample.IsValid())
*outEndSample = atrac->endSample_;
auto outLoopStart = PSPPointer<u32>::Create(outLoopStartSampleAddr);
auto outLoopStart = PSPPointer<u32_le>::Create(outLoopStartSampleAddr);
if (outLoopStart.IsValid())
*outLoopStart = atrac->loopStartSample_ == -1 ? -1 : atrac->loopStartSample_ - atrac->firstSampleOffset_ - atrac->FirstOffsetExtra();
auto outLoopEnd = PSPPointer<u32>::Create(outLoopEndSampleAddr);
auto outLoopEnd = PSPPointer<u32_le>::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<u8>::Create(sourceAddr);
auto srcConsumed = PSPPointer<u32>::Create(sourceBytesConsumedAddr);
auto srcConsumed = PSPPointer<u32_le>::Create(sourceBytesConsumedAddr);
auto outp = PSPPointer<u8>::Create(samplesAddr);
auto outWritten = PSPPointer<u32>::Create(sampleBytesAddr);
auto outWritten = PSPPointer<u32_le>::Create(sampleBytesAddr);
Atrac *atrac = getAtrac(atracID);
if (!atrac) {

View file

@ -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);

View file

@ -944,7 +944,7 @@ static u32 sceFontNewLib(u32 paramPtr, u32 errorCodePtr) {
__LoadInternalFonts();
auto params = PSPPointer<FontNewLibParams>::Create(paramPtr);
auto errorCode = PSPPointer<u32>::Create(errorCodePtr);
auto errorCode = PSPPointer<s32_le>::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<int>::Create(errorCodePtr);
auto errorCode = PSPPointer<s32_le>::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<int>::Create(errorCodePtr);
auto errorCode = PSPPointer<s32_le>::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<int>::Create(errorCodePtr);
auto errorCode = PSPPointer<s32_le>::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<int>::Create(errorCodePtr);
auto errorCode = PSPPointer<s32_le>::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<const PGFFontStyle>::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<float>::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<int>::Create(errorCodePtr);
auto errorCode = PSPPointer<s32_le>::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<const PGFFontStyle>::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<int>::Create(errorCodePtr);
auto errorCode = PSPPointer<s32_le>::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<int>::Create(errorCodePtr);
auto errorCode = PSPPointer<s32_le>::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<int>::Create(errorCodePtr);
auto errorCode = PSPPointer<s32_le>::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<int>::Create(errorCodePtr);
auto errorCode = PSPPointer<s32_le>::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<int>::Create(errorCodePtr);
auto errorCode = PSPPointer<s32_le>::Create(errorCodePtr);
if (!errorCode.IsValid()) {
ERROR_LOG_REPORT(SCEFONT, "sceFontPointToPixelV(%08x, %f, %08x): invalid error address", fontLibHandle, fontPointsV, errorCodePtr);
return 0.0f;

View file

@ -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<SeekInfo>::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<SeekInfo>::Create(indataPtr);
FileMove seek;

View file

@ -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) {

View file

@ -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]) {

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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<SceUID>::Create(readBufPtr);
auto uids = PSPPointer<SceUID_le>::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.

View file

@ -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++) {

View file

@ -110,8 +110,8 @@ struct PsmfData {
struct PsmfPlayerCreateData {
PSPPointer<u8> 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<u32>::Create(psmfPlayer);
auto player = PSPPointer<u32_le>::Create(psmfPlayer);
const auto data = PSPPointer<const PsmfPlayerCreateData>::Create(dataPtr);
if (!player.IsValid() || !data.IsValid()) {

View file

@ -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;

View file

@ -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
}

View file

@ -270,8 +270,8 @@ bool DrawEngineCommon::GetCurrentSimpleVertices(int count, std::vector<GPUDebugV
if ((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);

View file

@ -285,7 +285,7 @@ void VertexDecoder::Step_TcU8ToFloat() const
void VertexDecoder::Step_TcU16ToFloat() const
{
float *uv = (float *)(decoded_ + decFmt.uvoff);
const u16 *uvdata = (const u16_le*)(ptr_ + tcoff);
const u16_le *uvdata = (const u16_le *)(ptr_ + tcoff);
uv[0] = uvdata[0] * (1.0f / 32768.0f);
uv[1] = uvdata[1] * (1.0f / 32768.0f);
}
@ -293,7 +293,7 @@ void VertexDecoder::Step_TcU16ToFloat() const
void VertexDecoder::Step_TcU16DoubleToFloat() const
{
float *uv = (float*)(decoded_ + decFmt.uvoff);
const u16 *uvdata = (const u16_le*)(ptr_ + tcoff);
const u16_le *uvdata = (const u16_le *)(ptr_ + tcoff);
uv[0] = uvdata[0] * (1.0f / 16384.0f);
uv[1] = uvdata[1] * (1.0f / 16384.0f);
}
@ -301,20 +301,20 @@ void VertexDecoder::Step_TcU16DoubleToFloat() const
void VertexDecoder::Step_TcU16ThroughToFloat() const
{
float *uv = (float *)(decoded_ + decFmt.uvoff);
const u16 *uvdata = (const u16_le*)(ptr_ + tcoff);
const u16_le *uvdata = (const u16_le *)(ptr_ + tcoff);
uv[0] = uvdata[0];
uv[1] = uvdata[1];
gstate_c.vertBounds.minU = std::min(gstate_c.vertBounds.minU, uvdata[0]);
gstate_c.vertBounds.maxU = std::max(gstate_c.vertBounds.maxU, uvdata[0]);
gstate_c.vertBounds.minV = std::min(gstate_c.vertBounds.minV, uvdata[1]);
gstate_c.vertBounds.maxV = std::max(gstate_c.vertBounds.maxV, uvdata[1]);
gstate_c.vertBounds.minU = std::min(gstate_c.vertBounds.minU, (u16)uvdata[0]);
gstate_c.vertBounds.maxU = std::max(gstate_c.vertBounds.maxU, (u16)uvdata[0]);
gstate_c.vertBounds.minV = std::min(gstate_c.vertBounds.minV, (u16)uvdata[1]);
gstate_c.vertBounds.maxV = std::max(gstate_c.vertBounds.maxV, (u16)uvdata[1]);
}
void VertexDecoder::Step_TcU16ThroughDoubleToFloat() const
{
float *uv = (float *)(decoded_ + decFmt.uvoff);
const u16 *uvdata = (const u16_le*)(ptr_ + tcoff);
const u16_le *uvdata = (const u16_le *)(ptr_ + tcoff);
uv[0] = uvdata[0] * 2;
uv[1] = uvdata[1] * 2;
}
@ -621,7 +621,7 @@ void VertexDecoder::Step_NormalS8ToFloat() const
void VertexDecoder::Step_NormalS16() const
{
s16 *normal = (s16 *)(decoded_ + decFmt.nrmoff);
const s16 *sv = (const s16_le*)(ptr_ + nrmoff);
const s16_le *sv = (const s16_le *)(ptr_ + nrmoff);
for (int j = 0; j < 3; j++)
normal[j] = sv[j];
normal[3] = 0;
@ -630,7 +630,7 @@ void VertexDecoder::Step_NormalS16() const
void VertexDecoder::Step_NormalFloat() const
{
u32 *normal = (u32 *)(decoded_ + decFmt.nrmoff);
const u32 *fv = (const u32_le*)(ptr_ + nrmoff);
const u32_le *fv = (const u32_le *)(ptr_ + nrmoff);
for (int j = 0; j < 3; j++)
normal[j] = fv[j];
}
@ -646,7 +646,7 @@ void VertexDecoder::Step_NormalS8Skin() const
void VertexDecoder::Step_NormalS16Skin() const
{
float *normal = (float *)(decoded_ + decFmt.nrmoff);
const s16 *sv = (const s16_le*)(ptr_ + nrmoff);
const s16_le *sv = (const s16_le *)(ptr_ + nrmoff);
const float fn[3] = { sv[0] * (1.0f / 32768.0f), sv[1] * (1.0f / 32768.0f), sv[2] * (1.0f / 32768.0f) };
Norm3ByMatrix43(normal, fn, skinMatrix);
}
@ -675,7 +675,7 @@ void VertexDecoder::Step_NormalS16Morph() const
float *normal = (float *)(decoded_ + decFmt.nrmoff);
memset(normal, 0, sizeof(float) * 3);
for (int n = 0; n < morphcount; n++) {
const s16 *sv = (const s16_le *)(ptr_ + onesize_*n + nrmoff);
const s16_le *sv = (const s16_le *)(ptr_ + onesize_*n + nrmoff);
const float multiplier = gstate_c.morphWeights[n] * (1.0f / 32768.0f);
for (int j = 0; j < 3; j++)
normal[j] += sv[j] * multiplier;
@ -710,7 +710,7 @@ void VertexDecoder::Step_NormalS16MorphSkin() const {
float *normal = (float *)(decoded_ + decFmt.nrmoff);
float nrm[3]{};
for (int n = 0; n < morphcount; n++) {
const s16 *sv = (const s16_le *)(ptr_ + onesize_ * n + nrmoff);
const s16_le *sv = (const s16_le *)(ptr_ + onesize_ * n + nrmoff);
const float multiplier = gstate_c.morphWeights[n] * (1.0f / 32768.0f);
for (int j = 0; j < 3; j++)
nrm[j] += sv[j] * multiplier;
@ -741,7 +741,7 @@ void VertexDecoder::Step_PosS8() const
void VertexDecoder::Step_PosS16() const
{
float *pos = (float *)(decoded_ + decFmt.posoff);
const s16 *sv = (const s16_le *)(ptr_ + posoff);
const s16_le *sv = (const s16_le *)(ptr_ + posoff);
for (int j = 0; j < 3; j++)
pos[j] = sv[j] * (1.0f / 32768.0f);
}

View file

@ -671,7 +671,7 @@ int GPUCommon::GetStack(int index, u32 stackPtr) {
}
if (index >= 0) {
auto stack = PSPPointer<u32>::Create(stackPtr);
auto stack = PSPPointer<u32_le>::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, PSPPointer<Ps
int id = -1;
u64 currentTicks = CoreTiming::GetTicks();
u32_le stackAddr = args.IsValid() && args->size >= 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

View file

@ -567,8 +567,8 @@ bool TransformUnit::GetCurrentSimpleVertices(int count, std::vector<GPUDebugVert
if (count > 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);