mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-11-26 02:54:14 +01:00
wiiu: Endian and other fixes
now loads up to point where it's converting textures and crashes
This commit is contained in:
parent
cc798ad225
commit
3d302f5c7a
@ -1448,11 +1448,11 @@ cSampleManager::InitialiseSampleBanks(void)
|
||||
// fix endianess
|
||||
for (int i = 0; i < TOTAL_AUDIO_SAMPLES; i++)
|
||||
{
|
||||
m_aSamples[i].nOffset = __builtin_bswap32(m_aSamples[i].nOffset);
|
||||
m_aSamples[i].nSize = __builtin_bswap32(m_aSamples[i].nSize);
|
||||
m_aSamples[i].nFrequency = __builtin_bswap32(m_aSamples[i].nFrequency);
|
||||
m_aSamples[i].nLoopStart = __builtin_bswap32(m_aSamples[i].nLoopStart);
|
||||
m_aSamples[i].nLoopEnd = __builtin_bswap32(m_aSamples[i].nLoopEnd);
|
||||
m_aSamples[i].nOffset = BSWAP32(m_aSamples[i].nOffset);
|
||||
m_aSamples[i].nSize = BSWAP32(m_aSamples[i].nSize);
|
||||
m_aSamples[i].nFrequency = BSWAP32(m_aSamples[i].nFrequency);
|
||||
m_aSamples[i].nLoopStart = BSWAP32(m_aSamples[i].nLoopStart);
|
||||
m_aSamples[i].nLoopEnd = BSWAP32(m_aSamples[i].nLoopEnd);
|
||||
}
|
||||
#endif
|
||||
#ifdef AUDIO_OPUS
|
||||
|
@ -119,10 +119,7 @@ struct GlfwJoyState {
|
||||
|
||||
#ifdef __WIIU__
|
||||
struct WiiUJoyState {
|
||||
int8 id;
|
||||
bool isGamepad;
|
||||
VPADStatus status;
|
||||
bool mappedButtons[17];
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -193,6 +193,9 @@ CFileLoader::LoadCollisionFile(const char *filename)
|
||||
|
||||
while(CFileMgr::Read(fd, (char*)&header, sizeof(header))){
|
||||
assert(strncmp(header.ident, "COLL", 4) == 0);
|
||||
#ifdef BIGENDIAN
|
||||
header.size = BSWAP32(header.size);
|
||||
#endif
|
||||
CFileMgr::Read(fd, (char*)work_buff, header.size);
|
||||
memcpy(modelname, work_buff, 24);
|
||||
|
||||
@ -218,6 +221,7 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifndef BIGENDIAN
|
||||
model.boundingSphere.radius = *(float*)(buf);
|
||||
model.boundingSphere.center.x = *(float*)(buf+4);
|
||||
model.boundingSphere.center.y = *(float*)(buf+8);
|
||||
@ -229,59 +233,142 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
|
||||
model.boundingBox.max.y = *(float*)(buf+32);
|
||||
model.boundingBox.max.z = *(float*)(buf+36);
|
||||
model.numSpheres = *(int16*)(buf+40);
|
||||
#else
|
||||
// TODO make a macro for those buf to float bswaps
|
||||
// wtf is 0 | 128?
|
||||
model.boundingSphere.radius = FLOATSWAP32(*(float*)(buf));
|
||||
model.boundingSphere.center.x = FLOATSWAP32(*(float*)(buf+4));
|
||||
model.boundingSphere.center.y = FLOATSWAP32(*(float*)(buf+8));
|
||||
model.boundingSphere.center.z = FLOATSWAP32(*(float*)(buf+12));
|
||||
model.boundingBox.min.x = FLOATSWAP32(*(float*)(buf+16));
|
||||
model.boundingBox.min.y = FLOATSWAP32(*(float*)(buf+20));
|
||||
model.boundingBox.min.z = FLOATSWAP32(*(float*)(buf+24));
|
||||
model.boundingBox.max.x = FLOATSWAP32(*(float*)(buf+28));
|
||||
model.boundingBox.max.y = FLOATSWAP32(*(float*)(buf+32));
|
||||
model.boundingBox.max.z = FLOATSWAP32(*(float*)(buf+36));
|
||||
model.numSpheres = (int16) BSWAP16(*(uint16*)(buf+40));
|
||||
#endif
|
||||
|
||||
buf += 44;
|
||||
if(model.numSpheres > 0){
|
||||
model.spheres = (CColSphere*)RwMalloc(model.numSpheres*sizeof(CColSphere));
|
||||
for(i = 0; i < model.numSpheres; i++){
|
||||
#ifndef BIGENDIAN
|
||||
model.spheres[i].Set(*(float*)buf, *(CVector*)(buf+4), buf[16], buf[17]);
|
||||
#else
|
||||
float radius = FLOATSWAP32(*(float*)buf);
|
||||
CVector center = *(CVector*)(buf+4);
|
||||
center.x = FLOATSWAP32(center.x);
|
||||
center.y = FLOATSWAP32(center.y);
|
||||
center.z = FLOATSWAP32(center.z);
|
||||
model.spheres[i].Set(radius, center, buf[16], buf[17]);
|
||||
#endif
|
||||
buf += 20;
|
||||
}
|
||||
}else
|
||||
model.spheres = nil;
|
||||
|
||||
#ifndef BIGENDIAN
|
||||
model.numLines = *(int16*)buf;
|
||||
#else
|
||||
model.numLines = (int16) BSWAP16(*(uint16*)buf);
|
||||
#endif
|
||||
buf += 4;
|
||||
if(model.numLines > 0){
|
||||
model.lines = (CColLine*)RwMalloc(model.numLines*sizeof(CColLine));
|
||||
for(i = 0; i < model.numLines; i++){
|
||||
#ifndef BIGENDIAN
|
||||
model.lines[i].Set(*(CVector*)buf, *(CVector*)(buf+12));
|
||||
#else
|
||||
CVector p0 = *(CVector*)buf;
|
||||
p0.x = FLOATSWAP32(p0.x);
|
||||
p0.y = FLOATSWAP32(p0.y);
|
||||
p0.z = FLOATSWAP32(p0.z);
|
||||
CVector p1 = *(CVector*)(buf+12);
|
||||
p1.x = FLOATSWAP32(p1.x);
|
||||
p1.y = FLOATSWAP32(p1.y);
|
||||
p1.z = FLOATSWAP32(p1.z);
|
||||
model.lines[i].Set(p0, p1);
|
||||
#endif
|
||||
buf += 24;
|
||||
}
|
||||
}else
|
||||
model.lines = nil;
|
||||
|
||||
#ifndef BIGENDIAN
|
||||
model.numBoxes = *(int16*)buf;
|
||||
#else
|
||||
model.numBoxes = (int16) BSWAP16(*(uint16*)buf);
|
||||
#endif
|
||||
buf += 4;
|
||||
if(model.numBoxes > 0){
|
||||
model.boxes = (CColBox*)RwMalloc(model.numBoxes*sizeof(CColBox));
|
||||
for(i = 0; i < model.numBoxes; i++){
|
||||
#ifndef BIGENDIAN
|
||||
model.boxes[i].Set(*(CVector*)buf, *(CVector*)(buf+12), buf[24], buf[25]);
|
||||
#else
|
||||
CVector min = *(CVector*)buf;
|
||||
min.x = FLOATSWAP32(min.x);
|
||||
min.y = FLOATSWAP32(min.y);
|
||||
min.z = FLOATSWAP32(min.z);
|
||||
CVector max = *(CVector*)(buf+12);
|
||||
max.x = FLOATSWAP32(max.x);
|
||||
max.y = FLOATSWAP32(max.y);
|
||||
max.z = FLOATSWAP32(max.z);
|
||||
model.boxes[i].Set(min, max, buf[24], buf[25]);
|
||||
#endif
|
||||
buf += 28;
|
||||
}
|
||||
}else
|
||||
model.boxes = nil;
|
||||
|
||||
#ifndef BIGENDIAN
|
||||
int32 numVertices = *(int16*)buf;
|
||||
#else
|
||||
int32 numVertices = (int16) BSWAP16(*(uint16*)buf);
|
||||
#endif
|
||||
buf += 4;
|
||||
if(numVertices > 0){
|
||||
model.vertices = (CompressedVector*)RwMalloc(numVertices*sizeof(CompressedVector));
|
||||
for(i = 0; i < numVertices; i++){
|
||||
#ifndef BIGENDIAN
|
||||
model.vertices[i].Set(*(float*)buf, *(float*)(buf+4), *(float*)(buf+8));
|
||||
if(Abs(*(float*)buf) >= 256.0f ||
|
||||
Abs(*(float*)(buf+4)) >= 256.0f ||
|
||||
Abs(*(float*)(buf+8)) >= 256.0f)
|
||||
printf("%s:Collision volume too big\n", modelname);
|
||||
#else
|
||||
float x = FLOATSWAP32(*(float*)buf);
|
||||
float y = FLOATSWAP32(*(float*)(buf+4));
|
||||
float z = FLOATSWAP32(*(float*)(buf+8));
|
||||
model.vertices[i].Set(x, y, z);
|
||||
if(Abs(x) >= 256.0f ||
|
||||
Abs(y) >= 256.0f ||
|
||||
Abs(z) >= 256.0f)
|
||||
printf("%s:Collision volume too big\n", modelname);
|
||||
#endif
|
||||
buf += 12;
|
||||
}
|
||||
}else
|
||||
model.vertices = nil;
|
||||
|
||||
#ifndef BIGENDIAN
|
||||
model.numTriangles = *(int16*)buf;
|
||||
#else
|
||||
model.numTriangles = (int16) BSWAP16(*(uint16*)buf);
|
||||
#endif
|
||||
buf += 4;
|
||||
if(model.numTriangles > 0){
|
||||
model.triangles = (CColTriangle*)RwMalloc(model.numTriangles*sizeof(CColTriangle));
|
||||
for(i = 0; i < model.numTriangles; i++){
|
||||
#ifndef BIGENDIAN
|
||||
model.triangles[i].Set(model.vertices, *(int32*)buf, *(int32*)(buf+4), *(int32*)(buf+8), buf[12], buf[13]);
|
||||
#else
|
||||
int32 a = (int32) BSWAP32(*(uint32*)buf);
|
||||
int32 b = (int32) BSWAP32(*(uint32*)(buf+4));
|
||||
int32 c = (int32) BSWAP32(*(uint32*)(buf+8));
|
||||
model.triangles[i].Set(model.vertices, a, b, c, buf[12], buf[13]);
|
||||
#endif
|
||||
buf += 16;
|
||||
}
|
||||
}else
|
||||
|
@ -381,6 +381,10 @@ CStreaming::LoadCdDirectory(const char *dirname, int n)
|
||||
imgSelector = n<<24;
|
||||
assert(sizeof(direntry) == 32);
|
||||
while(CFileMgr::Read(fd, (char*)&direntry, sizeof(direntry))){
|
||||
#ifdef BIGENDIAN
|
||||
direntry.offset = BSWAP32(direntry.offset);
|
||||
direntry.size = BSWAP32(direntry.size);
|
||||
#endif
|
||||
dot = strchr(direntry.name, '.');
|
||||
if(dot) *dot = '\0';
|
||||
if(direntry.size > (uint32)ms_streamingBufferSize)
|
||||
|
@ -78,6 +78,18 @@ typedef int64_t int64;
|
||||
// hardcode ucs-2
|
||||
typedef uint16_t wchar;
|
||||
|
||||
#ifdef BIGENDIAN
|
||||
inline float _floatswap32(float f)
|
||||
{
|
||||
uint32_t _swapval = __builtin_bswap32(*(uint32_t*)&f);
|
||||
return *(float*)&_swapval;
|
||||
}
|
||||
|
||||
#define BSWAP32(x) __builtin_bswap32(x)
|
||||
#define BSWAP16(x) __builtin_bswap16(x)
|
||||
#define FLOATSWAP32(x) _floatswap32(x)
|
||||
#endif
|
||||
|
||||
#ifndef nil
|
||||
#define nil NULL
|
||||
#endif
|
||||
|
@ -913,6 +913,8 @@ RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags)
|
||||
{
|
||||
#ifdef RW_GL3
|
||||
return '3LGO';
|
||||
#elif __WIIU__
|
||||
return 'UIIW';
|
||||
#endif
|
||||
return flags & 0xF00;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ RwTexDictionaryGtaStreamRead(RwStream *stream)
|
||||
return nil;
|
||||
|
||||
#ifdef BIGENDIAN
|
||||
numTextures = __builtin_bswap32(numTextures);
|
||||
numTextures = BSWAP32(numTextures);
|
||||
#endif
|
||||
|
||||
texDict = RwTexDictionaryCreate();
|
||||
|
@ -174,6 +174,7 @@ char* casepath(char const* path, bool checkPathFirst)
|
||||
char* c;
|
||||
while (c = strsep(&p, "/\\"))
|
||||
{
|
||||
debug("sep string from %s is %s", p, c);
|
||||
// May be trailing slash(allow), slash at the start(avoid), or multiple slashes(avoid)
|
||||
if (*c == '\0')
|
||||
{
|
||||
|
@ -284,7 +284,7 @@ psInitialize(void)
|
||||
#endif
|
||||
// TODO: Is there a way to get free ram on wiiu?
|
||||
|
||||
_dwMemAvailPhys = 1024; //systemInfo.freeram;
|
||||
_dwMemAvailPhys = 1024*1024*170; //systemInfo.freeram;
|
||||
_dwOperatingSystemVersion = OS_WINXP; // To fool other classes
|
||||
|
||||
// debug("Physical memory size %u\n", systemInfo.totalram);
|
||||
@ -1382,9 +1382,6 @@ void CapturePad(RwInt32 padID)
|
||||
|
||||
memcpy(&ControlsManager.m_NewState.status, &status, sizeof(VPADStatus));
|
||||
|
||||
ControlsManager.m_NewState.id = 0;
|
||||
ControlsManager.m_NewState.isGamepad = true;
|
||||
|
||||
// if (ControlsManager.m_NewState.isGamepad)
|
||||
// {
|
||||
// memcpy(&ControlsManager.m_NewState.mappedButtons, gamepadState.buttons, sizeof(gamepadState.buttons));
|
||||
|
@ -71,7 +71,7 @@ CText::Load(void)
|
||||
sectlen = (int)filedata[offset+3]<<24 | (int)filedata[offset+2]<<16 |
|
||||
(int)filedata[offset+1]<<8 | (int)filedata[offset+0];
|
||||
#ifdef BIGENDIAN
|
||||
sectlen = __builtin_bswap32(sectlen);
|
||||
sectlen = BSWAP32(sectlen);
|
||||
#endif
|
||||
offset += 4;
|
||||
if(sectlen != 0){
|
||||
|
Loading…
Reference in New Issue
Block a user