Fix some compile failures under big endian.

This commit is contained in:
Unknown W. Brackets 2013-07-28 20:28:32 -07:00
parent 9ae32f641a
commit 0b5bdeb1d3
17 changed files with 52 additions and 43 deletions

View File

@ -76,7 +76,7 @@ public:
return swap(value);
}
swap_struct_t() :value(0) {}
swap_struct_t() : value((T)0) {}
swap_struct_t(const T &v): value(swap(v)) {}
template <typename S>

View File

@ -17,8 +17,9 @@
#pragma once
#include "../Globals.h"
#include "../Config.h"
#include "Globals.h"
#include "Common/Common.h"
#include "Core/Config.h"
class PointerWrap;

View File

@ -73,7 +73,7 @@ int PSPMsgDialog::Init(unsigned int paramAddr)
unsigned int validOp = SCE_UTILITY_MSGDIALOG_OPTION_TEXT |
SCE_UTILITY_MSGDIALOG_OPTION_YESNO |
SCE_UTILITY_MSGDIALOG_OPTION_DEFAULT_NO;
if((messageDialog.options | validOp) ^ validOp)
if (((messageDialog.options | validOp) ^ validOp) != 0)
{
flag |= DS_ERROR;
messageDialog.result = SCE_UTILITY_MSGDIALOG_ERROR_BADOPTION;

View File

@ -96,7 +96,9 @@ typedef SceUtilityOskState SceUtilityOskState_le;
typedef SceUtilityOskInputLanguage SceUtilityOskInputLanguage_le;
typedef SceUtilityOskResult SceUtilityOskResult_le;
#else
#error FIX ME
typedef swap_struct_t<SceUtilityOskState, swap_32_t<SceUtilityOskState> > SceUtilityOskState_le;
typedef swap_struct_t<SceUtilityOskInputLanguage, swap_32_t<SceUtilityOskInputLanguage> > SceUtilityOskInputLanguage_le;
typedef swap_struct_t<SceUtilityOskResult, swap_32_t<SceUtilityOskResult> > SceUtilityOskResult_le;
#endif
/**

View File

@ -56,10 +56,10 @@ int PSPSaveDialog::Init(int paramAddr)
u32 retval = param.SetPspParam(&request);
INFO_LOG(HLE,"sceUtilitySavedataInitStart(%08x)", paramAddr);
INFO_LOG(HLE,"Mode: %i", (SceUtilitySavedataType)param.GetPspParam()->mode);
INFO_LOG(HLE,"Mode: %i", (SceUtilitySavedataType)(u32)param.GetPspParam()->mode);
yesnoChoice = 1;
switch (param.GetPspParam()->focus)
switch ((SceUtilitySavedataFocus)(u32)param.GetPspParam()->focus)
{
case SCE_UTILITY_SAVEDATA_FOCUS_NAME:
// TODO: This should probably force not using the list?
@ -95,7 +95,7 @@ int PSPSaveDialog::Init(int paramAddr)
break;
}
switch (param.GetPspParam()->mode)
switch ((SceUtilitySavedataType)(u32)param.GetPspParam()->mode)
{
case SCE_UTILITY_SAVEDATA_TYPE_LOAD:
DEBUG_LOG(HLE, "Loading. Title: %s Save: %s File: %s", param.GetGameName(param.GetPspParam()).c_str(), param.GetSaveName(param.GetPspParam()).c_str(), param.GetFileName(param.GetPspParam()).c_str());
@ -164,7 +164,7 @@ int PSPSaveDialog::Init(int paramAddr)
break;
default:
{
ERROR_LOG_REPORT(HLE, "Load/Save function %d not coded. Title: %s Save: %s File: %s", (SceUtilitySavedataType)param.GetPspParam()->mode, param.GetGameName(param.GetPspParam()).c_str(), param.GetGameName(param.GetPspParam()).c_str(), param.GetFileName(param.GetPspParam()).c_str());
ERROR_LOG_REPORT(HLE, "Load/Save function %d not coded. Title: %s Save: %s File: %s", (SceUtilitySavedataType)(u32)param.GetPspParam()->mode, param.GetGameName(param.GetPspParam()).c_str(), param.GetGameName(param.GetPspParam()).c_str(), param.GetFileName(param.GetPspParam()).c_str());
param.GetPspParam()->common.result = 0;
status = SCE_UTILITY_STATUS_INITIALIZE;
display = DS_NONE;
@ -214,7 +214,7 @@ int PSPSaveDialog::Init(int paramAddr)
const std::string PSPSaveDialog::GetSelectedSaveDirName()
{
switch (param.GetPspParam()->mode)
switch ((SceUtilitySavedataType)(u32)param.GetPspParam()->mode)
{
case SCE_UTILITY_SAVEDATA_TYPE_LOAD:
case SCE_UTILITY_SAVEDATA_TYPE_AUTOLOAD:
@ -879,7 +879,7 @@ int PSPSaveDialog::Update()
case DS_NONE: // For action which display nothing
{
switch (param.GetPspParam()->mode)
switch ((SceUtilitySavedataType)(u32)param.GetPspParam()->mode)
{
case SCE_UTILITY_SAVEDATA_TYPE_LOAD: // Only load and exit
case SCE_UTILITY_SAVEDATA_TYPE_AUTOLOAD:

View File

@ -71,7 +71,8 @@ enum SceUtilitySavedataFocus
typedef SceUtilitySavedataType SceUtilitySavedataType_le;
typedef SceUtilitySavedataFocus SceUtilitySavedataFocus_le;
#else
#error FIX ME
typedef swap_struct_t<SceUtilitySavedataType, swap_32_t<SceUtilitySavedataType> > SceUtilitySavedataType_le;
typedef swap_struct_t<SceUtilitySavedataFocus, swap_32_t<SceUtilitySavedataFocus> > SceUtilitySavedataFocus_le;
#endif
typedef char SceUtilitySavedataSaveName[20];

View File

@ -73,8 +73,8 @@ public:
}
// Quick accessors
ElfType GetType() { return (ElfType)(header->e_type); }
ElfMachine GetMachine() { return (ElfMachine)(header->e_machine); }
ElfType GetType() { return (ElfType)(u16)(header->e_type); }
ElfMachine GetMachine() { return (ElfMachine)(u16)(header->e_machine); }
u32 GetEntryPoint() { return entryPoint; }
u32 GetFlags() { return (u32)(header->e_flags); }

View File

@ -15,7 +15,9 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#pragma once
#include "Common/Common.h"
///////////////////////
// ELF Header Constants
@ -283,7 +285,7 @@ struct Elf32_Rela
#define ELF32_R_TYPE(i) ((unsigned char)(i))
#define ELF32_R_INFO(s,t) (((s)<<8 )+(unsigned char)(t))
/*
struct Elf32_Dyn
{
Elf32_Sword d_tag;
@ -293,3 +295,4 @@ struct Elf32_Dyn
Elf32_Addr d_ptr;
} d_un;
};
*/

View File

@ -18,7 +18,7 @@
#pragma once
#include "Common/CommonTypes.h"
#include "Common/Common.h"
enum PBPSubFile {
PBP_PARAM_SFO,

View File

@ -280,16 +280,16 @@ void PGF::GetFontInfo(PGFFontInfo *fi) {
fi->maxGlyphTopYI = header.maxTopYAdjust;
fi->maxGlyphAdvanceXI = header.maxAdvance[0];
fi->maxGlyphAdvanceYI = header.maxAdvance[1];
fi->maxGlyphWidthF = header.maxSize[0] / 64.0f;
fi->maxGlyphHeightF = header.maxSize[1] / 64.0f;
fi->maxGlyphAscenderF = header.maxAscender / 64.0f;
fi->maxGlyphDescenderF = header.maxDescender / 64.0f;
fi->maxGlyphLeftXF = header.maxLeftXAdjust / 64.0f;
fi->maxGlyphBaseYF = header.maxBaseYAdjust / 64.0f;
fi->minGlyphCenterXF = header.minCenterXAdjust / 64.0f;
fi->maxGlyphTopYF = header.maxTopYAdjust / 64.0f;
fi->maxGlyphAdvanceXF = header.maxAdvance[0] / 64.0f;
fi->maxGlyphAdvanceYF = header.maxAdvance[1] / 64.0f;
fi->maxGlyphWidthF = (float)header.maxSize[0] / 64.0f;
fi->maxGlyphHeightF = (float)header.maxSize[1] / 64.0f;
fi->maxGlyphAscenderF = (float)header.maxAscender / 64.0f;
fi->maxGlyphDescenderF = (float)header.maxDescender / 64.0f;
fi->maxGlyphLeftXF = (float)header.maxLeftXAdjust / 64.0f;
fi->maxGlyphBaseYF = (float)header.maxBaseYAdjust / 64.0f;
fi->minGlyphCenterXF = (float)header.minCenterXAdjust / 64.0f;
fi->maxGlyphTopYF = (float)header.maxTopYAdjust / 64.0f;
fi->maxGlyphAdvanceXF = (float)header.maxAdvance[0] / 64.0f;
fi->maxGlyphAdvanceYF = (float)header.maxAdvance[1] / 64.0f;
fi->maxGlyphWidth = header.maxGlyphWidth;
fi->maxGlyphHeight = header.maxGlyphHeight;
@ -474,7 +474,7 @@ void PGF::DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipW
if (pixelX >= clipX && pixelX < clipX + clipWidth && pixelY >= clipY && pixelY < clipY + clipHeight) {
// 4-bit color value
int pixelColor = value;
switch (image->pixelFormat) {
switch ((FontPixelFormat)(u32)image->pixelFormat) {
case PSP_FONT_PIXELFORMAT_8:
// 8-bit color value
pixelColor |= pixelColor << 4;
@ -495,7 +495,7 @@ void PGF::DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipW
case PSP_FONT_PIXELFORMAT_4_REV:
break;
default:
ERROR_LOG_REPORT(HLE, "Unhandled font pixel format: %d", image->pixelFormat);
ERROR_LOG_REPORT(HLE, "Unhandled font pixel format: %d", (u32)image->pixelFormat);
break;
}

View File

@ -112,7 +112,7 @@ struct Glyph {
#if COMMON_LITTLE_ENDIAN
typedef FontPixelFormat FontPixelFormat_le;
#else
#error FIX ME
typedef swap_struct_t<FontPixelFormat, swap_32_t<FontPixelFormat> > FontPixelFormat_le;
#endif
struct GlyphImage {

View File

@ -130,10 +130,10 @@ public:
Font(const u8 *data, size_t dataSize) {
pgf_.ReadPtr(data, dataSize);
style_.fontH = pgf_.header.hSize / 64.0f;
style_.fontV = pgf_.header.vSize / 64.0f;
style_.fontHRes = pgf_.header.hResolution / 64.0f;
style_.fontVRes = pgf_.header.vResolution / 64.0f;
style_.fontH = (float)pgf_.header.hSize / 64.0f;
style_.fontV = (float)pgf_.header.vSize / 64.0f;
style_.fontHRes = (float)pgf_.header.hResolution / 64.0f;
style_.fontVRes = (float)pgf_.header.vResolution / 64.0f;
}
Font(const u8 *data, size_t dataSize, const FontRegistryEntry &entry) {

View File

@ -129,7 +129,7 @@ KernelObject *__KernelEventFlagObject()
return new EventFlag;
}
bool __KernelEventFlagMatches(u32 *pattern, u32 bits, u8 wait, u32 outAddr)
bool __KernelEventFlagMatches(u32_le *pattern, u32 bits, u8 wait, u32 outAddr)
{
if ((wait & PSP_EVENT_WAITOR)
? (bits & *pattern) /* one or more bits of the mask */

View File

@ -153,7 +153,7 @@ public:
#if COMMON_LITTLE_ENDIAN
typedef WaitType WaitType_le;
#else
#error FIX ME
typedef swap_struct_t<WaitType, swap_32_t<WaitType> > WaitType_le;
#endif
// Real PSP struct, don't change the fields
@ -1865,7 +1865,9 @@ Thread *__KernelCreateThread(SceUID &id, SceUID moduleId, const char *name, u32
strncpy(t->nt.name, name, KERNELOBJECT_MAX_NAME_LENGTH);
t->nt.name[KERNELOBJECT_MAX_NAME_LENGTH] = '\0';
t->AllocateStack(t->nt.stackSize); // can change the stacksize!
u32 stackSize = t->nt.stackSize;
t->AllocateStack(stackSize); // can change the stacksize!
t->nt.stackSize = stackSize;
return t;
}

View File

@ -60,7 +60,7 @@ KernelObject *__KernelVTimerObject() {
}
u64 __getVTimerRunningTime(VTimer *vt) {
if (!vt->nvt.active)
if (vt->nvt.active == 0)
return 0;
return cyclesToUs(CoreTiming::GetTicks()) - vt->nvt.base;
@ -89,7 +89,7 @@ void __KernelScheduleVTimer(VTimer *vt, u64 schedule) {
vt->nvt.schedule = schedule;
if (vt->nvt.active == 1 && vt->nvt.handlerAddr != 0)
CoreTiming::ScheduleEvent(usToCycles(vt->nvt.schedule), vtimerTimer, vt->GetUID());
CoreTiming::ScheduleEvent(usToCycles((u64)vt->nvt.schedule), vtimerTimer, vt->GetUID());
}
void __rescheduleVTimer(SceUID id, int delay) {
@ -345,7 +345,7 @@ u32 sceKernelStartVTimer(u32 uid) {
VTimer *vt = kernelObjects.Get<VTimer>(uid, error);
if (vt) {
if (vt->nvt.active)
if (vt->nvt.active != 0)
return 1;
__startVTimer(vt);

View File

@ -85,7 +85,7 @@ static const int TPSM_PIXEL_STORAGE_MODE_16BIT_BGR5650 = 0X00;
static const int TPSM_PIXEL_STORAGE_MODE_32BIT_ABGR8888 = 0X03;
int getMaxAheadTimestamp(const SceMpegRingBuffer &ringbuf) {
return std::max(40000, ringbuf.packets * 700); // empiric value from JPCSP, thanks!
return std::max(40000, 700 * ringbuf.packets); // empiric value from JPCSP, thanks!
}
const u8 defaultMpegheader[2048] = {0x50,0x53,0x4d,0x46,0x30,0x30,0x31,0x35,0x00,0x00,0x08,0x00,0x00,
@ -947,7 +947,7 @@ u32 sceMpegRingbufferPut(u32 ringbufferAddr, u32 numPackets, u32 available)
}
// Execute callback function as a direct MipsCall, no blocking here so no messing around with wait states etc
if (ringbuffer.callback_addr) {
if (ringbuffer.callback_addr != 0) {
PostPutAction *action = (PostPutAction *)__KernelCreateAction(actionPostPut);
action->setRingAddr(ringbufferAddr);
// TODO: Should call this multiple times until we get numPackets.

View File

@ -478,7 +478,7 @@ int sceRtcCheckValid(u32 datePtr)
{
return PSP_TIME_INVALID_SECONDS;
}
else if (pt.microsecond >= 1000000)
else if (pt.microsecond >= 1000000UL)
{
return PSP_TIME_INVALID_MICROSECONDS;
}