From 525213367c7bfa856016c9773b36409cfac09a3a Mon Sep 17 00:00:00 2001 From: dbalatoni13 <40299962+dbalatoni13@users.noreply.github.com> Date: Sun, 13 Apr 2025 18:32:21 +0200 Subject: [PATCH] Linux build fixes --- CMakeLists.txt | 28 +++++++++++++++------------- extern/aurora | 2 +- extern/musyx | 2 +- include/ext_math.h | 2 ++ include/game/board/boo.h | 4 ---- include/game/data.h | 1 - rel.map | 6 ++++++ src/dolphin/mtx/mtx.c | 1 - src/dolphin/os/OSStopwatch.c | 2 +- src/game/armem.c | 4 ++++ src/game/board/boo.c | 4 ++++ src/game/board/player.c | 4 ++++ src/game/chrman.c | 15 ++++++++++----- src/game/hsfdraw.c | 4 ++++ src/game/objmain.c | 2 +- src/game/ovllist.c | 7 +++++++ src/port/OS.c | 3 ++- src/port/audio.c | 1 - src/port/stubs.c | 3 --- 19 files changed, 62 insertions(+), 33 deletions(-) create mode 100644 rel.map diff --git a/CMakeLists.txt b/CMakeLists.txt index b39274aa..f707a8c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,24 +16,20 @@ if (NOT CMAKE_BUILD_TYPE) endif () if (CMAKE_SYSTEM_NAME STREQUAL Linux) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas -Wno-unused-variable -Wno-unused-parameter") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -fsanitize=address -fsanitize-address-use-after-scope") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -fsanitize=address -fsanitize-address-use-after-scope -Wno-unknown-pragmas -Wno-unused-variable -Wno-unused-parameter") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -fsanitize=address -fsanitize-address-use-after-scope -Wno-register") set(CMAKE_PREFIX_PATH /usr) set(CMAKE_LIBRARY_ARCHITECTURE i386-linux-gnu) - set(CMAKE_LIBRARY_PATH "/usr/lib32" CACHE PATH "") + set(CMAKE_LIBRARY_PATH "/usr/lib32" "/usr/lib/i386-linux-gnu" CACHE PATH "") set(CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX 32) -endif () - -if (APPLE) +elseif (APPLE) add_compile_options(-Wno-declaration-after-statement) +elseif (MSVC) + add_compile_options(/bigobj) endif () add_compile_options(-fsanitize=address) -if (MSVC) - add_compile_options(/bigobj) -endif () - add_subdirectory(extern/aurora EXCLUDE_FROM_ALL) add_subdirectory(extern/musyx EXCLUDE_FROM_ALL) @@ -142,10 +138,10 @@ source_group("Port" FILES ${PORT_FILES}) if (NOT MSVC) foreach (file ${DOLPHIN_FILES}) - set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "-std=c89 -Dinline=") + set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "-Dinline=") endforeach () foreach (file ${GAME_FILES}) - set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "-std=c89 -Dinline=") + set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "-Dinline=") endforeach () endif () @@ -162,7 +158,8 @@ if (MSVC) endif () target_link_options(dol PRIVATE "/DEF:${CMAKE_SOURCE_DIR}/dol.def") else () - target_compile_options(dol PRIVATE "-fvisibility=default") + # target_compile_options(dol PRIVATE "-fvisibility=hidden") + # target_link_options(dol PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/dol.map") endif () add_executable(marioparty4 src/port/portmain.c) @@ -184,6 +181,11 @@ foreach (dir ${REL_DIRS}) set_target_properties(${dir} PROPERTIES LINK_FLAGS "/EXPORT:ObjectSetup") else () endif () + if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows) + target_compile_options(${dir} PRIVATE "-fvisibility=hidden") + target_link_options(${dir} PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/rel.map") + set_target_properties(${dir} PROPERTIES PREFIX "") + endif () target_link_libraries(${dir} PRIVATE dol musyx) endif () endif () diff --git a/extern/aurora b/extern/aurora index 3b56e337..a18cdf3b 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit 3b56e337c08a1dd4946c226298011364c319c7a2 +Subproject commit a18cdf3b599b482c850096994cef09ba3920851b diff --git a/extern/musyx b/extern/musyx index a579f4d4..37e8ecd4 160000 --- a/extern/musyx +++ b/extern/musyx @@ -1 +1 @@ -Subproject commit a579f4d4abbac1c67fddf0d361291320f81a7b6c +Subproject commit 37e8ecd4e6503e90b97ea81cd7d669357861d501 diff --git a/include/ext_math.h b/include/ext_math.h index 1b190cb8..d13a036e 100644 --- a/include/ext_math.h +++ b/include/ext_math.h @@ -4,7 +4,9 @@ #include "math.h" #include "dolphin/mtx.h" +#ifndef M_PI #define M_PI 3.141592653589793 +#endif typedef struct vec2f { float x; diff --git a/include/game/board/boo.h b/include/game/board/boo.h index 39c7d971..6543950f 100755 --- a/include/game/board/boo.h +++ b/include/game/board/boo.h @@ -8,10 +8,6 @@ s16 BoardBooCreate(s32 arg0, Vec *arg1); void BoardBooKill(void); s32 BoardBooStealTypeSet(s32 arg0); s32 BoardBooStealMain(void); -BOOL CheckBallCoinDone(void); -void TakeBallStar(void); -void ExecTakeBallStar(omObjData *arg0); -BOOL CheckTakeBallStarDone(void); s32 BoardBooStealValueGet(s16 *arg0, s16 *arg1); BOOL BoardBooStealLightCheck(void); diff --git a/include/game/data.h b/include/game/data.h index 9c01b09b..3a1d41ff 100644 --- a/include/game/data.h +++ b/include/game/data.h @@ -34,7 +34,6 @@ s32 HuDataReadChk(s32 data_num); DataReadStat *HuDataGetStatus(void *dir_ptr); void *HuDataGetDirPtr(s32 data_num); DataReadStat *HuDataDirRead(s32 data_num); -DataReadStat *HuDataDirReadNum(s32 data_num, s32 num); DataReadStat *HuDataDirSet(void *dir_ptr, s32 data_num); void HuDataDirReadAsyncCallBack(s32 result, DVDFileInfo* fileInfo); s32 HuDataDirReadAsync(s32 data_num); diff --git a/rel.map b/rel.map new file mode 100644 index 00000000..1cdba41f --- /dev/null +++ b/rel.map @@ -0,0 +1,6 @@ +{ + global: + ObjectSetup; + local: + *; +}; diff --git a/src/dolphin/mtx/mtx.c b/src/dolphin/mtx/mtx.c index 30a3aa18..ab196f4e 100644 --- a/src/dolphin/mtx/mtx.c +++ b/src/dolphin/mtx/mtx.c @@ -1367,7 +1367,6 @@ void C_MTXMultVecArray(const Mtx m, const Vec* srcBase, Vec* dstBase, u32 count) void C_MTXROMultVecArray(const ROMtx m, const Vec *srcBase, Vec *dstBase, u32 count) { - u32 i; for (u32 i = 0; i < count; ++i) { Vec* src = &srcBase[i]; Vec* dst = &dstBase[i]; diff --git a/src/dolphin/os/OSStopwatch.c b/src/dolphin/os/OSStopwatch.c index 80e7dbdd..e1424396 100644 --- a/src/dolphin/os/OSStopwatch.c +++ b/src/dolphin/os/OSStopwatch.c @@ -34,7 +34,7 @@ void OSStopStopwatch(struct OSStopwatch *sw) } } -long long OSCheckStopwatch(struct OSStopwatch *sw) +OSTime OSCheckStopwatch(OSStopwatch *sw) { long long currTotal; diff --git a/src/game/armem.c b/src/game/armem.c index 73a34314..26b359f6 100644 --- a/src/game/armem.c +++ b/src/game/armem.c @@ -265,7 +265,11 @@ void *HuAR_ARAMtoMRAMNum(u32 src, s32 num) { block = HuARInfoGet(src); if (HuDataReadChk(block->dir << 16) >= 0) { +#ifdef NON_MATCHING + return 0; +#else return; +#endif } size = HuARSizeGet(src); dst = HuMemDirectMallocNum(HEAP_DVD, size, num); diff --git a/src/game/board/boo.c b/src/game/board/boo.c index 56dff9ce..14acebd2 100755 --- a/src/game/board/boo.c +++ b/src/game/board/boo.c @@ -95,6 +95,8 @@ typedef struct { float unk04; } BallTakeCoinWork; +static BOOL CheckBallCoinDone(void); +static void TakeBallStar(void); static void ComSetupStealPlayer(s32 arg0); static void ComSetStealPlayerInput(s32 arg0, s32 arg1); static void ExecCoinSteal(void); @@ -131,8 +133,10 @@ static void BallBooAttack(omObjData *arg0, BallBooWork *arg1); static void BallBooFlash(omObjData *arg0, BallBooWork *arg1); static void TakeBallCoin(void); static void ExecTakeBallCoin(omObjData *arg0); +static void ExecTakeBallStar(omObjData *arg0); static void TakeBallCoinPosSet(BallTakeCoinData *arg0, Vec *arg1); static void UpdatePlayerCoins(void); +static BOOL CheckTakeBallStarDone(void); s8 lbl_801D41E2; static s8 stealTarget; diff --git a/src/game/board/player.c b/src/game/board/player.c index 32d88858..08c14154 100644 --- a/src/game/board/player.c +++ b/src/game/board/player.c @@ -729,9 +729,11 @@ s32 BoardPlayerSizeGet(s32 idx) PlayerState *player; player = BoardPlayerGet(idx); +#ifndef NON_MATCHING if (!player) { return; } +#endif return player->size; } @@ -2220,9 +2222,11 @@ s32 BoardPlayerAutoSizeGet(s32 arg0) PlayerState *player; player = BoardPlayerGet(arg0); +#ifndef NON_MATCHING if (!player) { return; } +#endif return player->auto_size; } diff --git a/src/game/chrman.c b/src/game/chrman.c index 079d92b5..d2530265 100755 --- a/src/game/chrman.c +++ b/src/game/chrman.c @@ -685,13 +685,14 @@ static void UpdateCharAnim(s16 character, s16 arg1, s16 arg2, u8 arg3, s16 arg4, static s32 PlayCharVoice(s16 character, s16 arg1, u8 arg2) { - UnkCharInstanceStruct *temp_r31; - ModelData *temp_r29; - - temp_r31 = &charInstance[character]; - temp_r29 = &Hu3DData[temp_r31->unk00]; + UnkCharInstanceStruct *temp_r31 = &charInstance[character]; + ModelData *temp_r29 = &Hu3DData[temp_r31->unk00]; if (arg2 & 1) { +#ifdef NON_MATCHING + return 0; +#else return; +#endif } if (temp_r31->unkAC & 8) { return HuAudCharVoicePlayPos(character, arg1, &temp_r29->pos); @@ -1973,7 +1974,11 @@ static s32 PlayStepFX(s16 character, s16 arg1, u8 arg2) temp_r31 = &charInstance[character]; var_r28 = &Hu3DData[temp_r31->unk00]; if (arg2 & 1) { +#ifdef NON_MATCHING + return 0; +#else return; +#endif } if (temp_r31->unkB0 == 4) { arg1 = 0x109; diff --git a/src/game/hsfdraw.c b/src/game/hsfdraw.c index dfbbdd5b..dd4920fc 100755 --- a/src/game/hsfdraw.c +++ b/src/game/hsfdraw.c @@ -1828,7 +1828,11 @@ static s32 LoadTexture(ModelData *arg0, HsfBitmap *arg1, HsfAttribute *arg2, s16 if (arg1 == 0) { OSReport("Error: No Texture\n"); +#ifdef NON_MATCHING + return 0; +#else return; +#endif } var_r27 = arg1->sizeX; var_r26 = arg1->sizeY; diff --git a/src/game/objmain.c b/src/game/objmain.c index a936f7f1..55abeee3 100644 --- a/src/game/objmain.c +++ b/src/game/objmain.c @@ -268,7 +268,7 @@ void omDestroyObjMan(void) OSReport("objman>Destory ObjMan\n"); } -omObjData *omAddObjEx(Process *objman_process, s16 prio, u16 mdlcnt, u16 mtncnt, s16 group, void (*func)(omObjData *)) +omObjData *omAddObjEx(Process *objman_process, s16 prio, u16 mdlcnt, u16 mtncnt, s16 group, omObjFunc func) { s32 i; omObjData *object; diff --git a/src/game/ovllist.c b/src/game/ovllist.c index df997d83..b03102e9 100644 --- a/src/game/ovllist.c +++ b/src/game/ovllist.c @@ -1,9 +1,16 @@ #include "game/dvd.h" #include "game/object.h" +#ifdef TARGET_PC + #ifdef _WIN32 #define OVL_DEFINE(name, path) { path ".dll", 0 }, #else +#define OVL_DEFINE(name, path) { path ".so", 0 }, +#endif + +#else + #define OVL_DEFINE(name, path) { "dll/" path ".rel", 0 }, #endif diff --git a/src/port/OS.c b/src/port/OS.c index 9d5f61d6..2040968f 100644 --- a/src/port/OS.c +++ b/src/port/OS.c @@ -4,6 +4,7 @@ #include #ifndef _WIN32 +#include #include #include #if __APPLE__ @@ -36,7 +37,7 @@ static u64 GetGCTicks() struct timespec tp; clock_gettime(CLOCK_MONOTONIC, &tp); - return u64((tp.tv_sec * 1000000000ull) + tp.tv_nsec) * GetGCTicksPerSec() / 1000000000ull; + return ((tp.tv_sec * 1000000000ull) + tp.tv_nsec) * OS_CORE_CLOCK / 1000000000ull; #elif _WIN32 LARGE_INTEGER perf; QueryPerformanceCounter(&perf); diff --git a/src/port/audio.c b/src/port/audio.c index 4ee25b36..4b3e5085 100644 --- a/src/port/audio.c +++ b/src/port/audio.c @@ -226,7 +226,6 @@ void HuAudFXListnerKill(void) { void HuAudFXPauseAll(s32 pause) { // msmSePauseAll(pause, 0x64); - return 12; } s32 HuAudFXStatusGet(int seNo) { diff --git a/src/port/stubs.c b/src/port/stubs.c index df991ea1..c330ded7 100644 --- a/src/port/stubs.c +++ b/src/port/stubs.c @@ -751,6 +751,3 @@ s32 HuTHPTotalFrameGet(void) void HuTHPSetVolume(s32 left, s32 right) { } - -// TODO remove -u8 fadeStat = 0;