Skip to content

Commit

Permalink
portx64: a bunch of gcc14 fixes
Browse files Browse the repository at this point in the history
portx64: fixed pal

Update c-cpp.yml

portx64: fixed linux build

portx64: fixed linux build

ops

portx64: fixed linux build, one more time

portx64: fixed linux build, one more time
  • Loading branch information
Raf committed Aug 9, 2024
1 parent 01cbcd9 commit e77b317
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
cp build/ntsc-final-port/pd.exe bin/
cp build/pal-final-port/pd.pal.exe bin/
cp build/jpn-final-port/pd.jpn.exe bin/
cp /mingw64/bin/{SDL2.dll,zlib1.dll,libgcc_s_dw2-1.dll,libwinpthread-1.dll} bin/
cp /mingw64/bin/{SDL2.dll,zlib1.dll,libwinpthread-1.dll} bin/
touch bin/data/put_your_rom_here.txt
- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions include/PR/gbi.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <PR/ultratypes.h>
#include "gbiex.h"
#include <stdint.h>

#ifndef PLATFORM_N64
#include "platform.h"
Expand Down
10 changes: 10 additions & 0 deletions port/src/preprocess/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "platform.h"

#ifdef PLATFORM_WIN32

#include <winsock2.h>
// this BS comes from windows.h
#undef near
#undef far

#else

#include <arpa/inet.h>

#endif

#include <sys/param.h>

#include <PR/ultratypes.h>
Expand Down
43 changes: 22 additions & 21 deletions port/src/preprocess/filemodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,11 @@ struct dst_texconfig {
u8 unk0b;
};

static inline void *minPtr(void *a, void *b) {
static inline uintptr_t minPtr(uintptr_t a, uintptr_t b) {
return (a && (a < b || !b)) ? a : b;
}

static inline void *minPtr3(void *a, void *b, void *c) {
static inline uintptr_t minPtr3(uintptr_t a, uintptr_t b, uintptr_t c) {
return minPtr(minPtr(a, b), c);
}

Expand Down Expand Up @@ -781,14 +781,14 @@ static u32 resolvePointer(u32 src_offset)

static u8 *relinkPointers(u8 *dst, u8 *src)
{
u8 *textures_end = 0;
uintptr_t textures_end = 0;

for (int i = 0; i < m_NumMarkers; i++) {
struct marker *marker = &m_Markers[i];
void *src_thing = &src[marker->src_offset];
void *dst_thing = &dst[marker->dst_offset];

u8 *lowestptr = 0;
uintptr_t lowestptr = 0;

switch (marker->type) {
case CT_MODELDEF:
Expand Down Expand Up @@ -913,6 +913,7 @@ static u8 *relinkPointers(u8 *dst, u8 *src)
break;
case CT_TEXDATA:
case CT_VTXCOL:
case CT_VTXCOL4:
case CT_GDL:
case CT_RODATA_BBOX:
case CT_RODATA_11:
Expand All @@ -925,31 +926,17 @@ static u8 *relinkPointers(u8 *dst, u8 *src)
textures_end = minPtr(textures_end, lowestptr);
}

return textures_end;
}

static int convertModel(u8 *dst, u8 *src, u32 srclen)
{
u32 dstpos;

populateMarkers(src);
sortMarkers();

dstpos = convertContent(dst, src, srclen);
u8 *tex_end = relinkPointers(dst, src);
preprocessModelTextures(dst, tex_end);

return dstpos;
return (u8*)textures_end;
}

void preprocessTextureRGBA32Embedded(u32* dest, u32 size_bytes)
static void preprocessTextureRGBA32Embedded(u32* dest, u32 size_bytes)
{
for (uint32_t i = 0; i < size_bytes; i += 4, ++dest) {
*dest = PD_BE32(*dest);
}
}

void preprocessModelTextures(u8 *base, u8 *textures_end)
static void preprocessModelTextures(u8 *base, u8 *textures_end)
{
struct modeldef* mdl = (struct modeldef*)base;
if (!mdl->texconfigs) return;
Expand All @@ -976,6 +963,20 @@ void preprocessModelTextures(u8 *base, u8 *textures_end)
}
}

static int convertModel(u8* dst, u8* src, u32 srclen)
{
u32 dstpos;

populateMarkers(src);
sortMarkers();

dstpos = convertContent(dst, src, srclen);
u8* tex_end = relinkPointers(dst, src);
preprocessModelTextures(dst, tex_end);

return dstpos;
}

u8 *preprocessModelFile(u8 *data, u32 size, u32 *outSize)
{
gbiReset();
Expand Down
Loading

0 comments on commit e77b317

Please sign in to comment.