diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1d41f0b2a..f2a7731b7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -54,13 +54,16 @@ set(CMAKE_C_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG")
else()
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
-set(CMAKE_CXX_FLAGS_DEBUG "-fuse-ld=lld")
set(CMAKE_C_FLAGS_DEBUG "-g")
-set(CMAKE_LINKER_FLAGS_DEBUG "-fuse-ld=lld")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_OBJCXX_FLAGS_RELEASE "-O2 -DNDEBUG")
endif()
+if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
+set(CMAKE_CXX_FLAGS_DEBUG "-fuse-ld=lld")
+set(CMAKE_LINKER_FLAGS_DEBUG "-fuse-ld=lld")
+endif()
+
if(NOT CMAKE_BUILD_TYPE )
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
endif()
diff --git a/OTRExporter b/OTRExporter
index 6212ebc44..c38b0ac81 160000
--- a/OTRExporter
+++ b/OTRExporter
@@ -1 +1 @@
-Subproject commit 6212ebc4407107340a76b3ab052f94170a42a3a6
+Subproject commit c38b0ac812e71600be11ad17451280bb7145d8f4
diff --git a/mm/2s2h/BenPort.h b/mm/2s2h/BenPort.h
index fbdd93bcf..0905fa75a 100644
--- a/mm/2s2h/BenPort.h
+++ b/mm/2s2h/BenPort.h
@@ -77,6 +77,7 @@ uint16_t ResourceMgr_LoadTexHeightByName(char* texPath);
CollisionHeader* ResourceMgr_LoadColByName(const char* path);
AnimatedMaterial* ResourceMgr_LoadAnimatedMatByName(const char* path);
char* ResourceMgr_LoadTexOrDListByName(const char* filePath);
+char* ResourceMgr_LoadIfDListByName(const char* filePath);
char* ResourceMgr_LoadPlayerAnimByName(const char* animPath);
AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path);
char* ResourceMgr_GetNameByCRC(uint64_t crc, char* alloc);
@@ -103,6 +104,7 @@ s32* ResourceMgr_LoadCSByName(const char* path);
int ResourceMgr_OTRSigCheck(char* imgData);
uint64_t osGetTime(void);
uint32_t osGetCount(void);
+uint64_t GetFrequency();
uint32_t OTRGetCurrentWidth(void);
uint32_t OTRGetCurrentHeight(void);
float OTRGetAspectRatio(void);
diff --git a/mm/include/audio/load.h b/mm/include/audio/load.h
index 1e896d744..eccdc2db2 100644
--- a/mm/include/audio/load.h
+++ b/mm/include/audio/load.h
@@ -132,7 +132,7 @@ s32 AudioLoad_SyncInitSeqPlayer(s32 playerIndex, s32 seqId, s32 arg2);
s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIndex, s32 seqId, s32 skipTicks);
void AudioLoad_ProcessLoads(s32 resetStatus);
void AudioLoad_SetDmaHandler(DmaHandler callback);
-void AudioLoad_Init(void* heap, u32 heapSize);
+void AudioLoad_Init(void* heap, size_t heapSize);
void AudioLoad_InitSlowLoads(void);
s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone);
s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone);
diff --git a/mm/include/functions.h b/mm/include/functions.h
index 8238a7d7e..0ab23b955 100644
--- a/mm/include/functions.h
+++ b/mm/include/functions.h
@@ -7,6 +7,7 @@ extern "C" {
#endif
#include "z64.h"
+#include "BenPort.h"
void bootproc(void);
void ViConfig_UpdateVi(u32 black);
@@ -40,10 +41,6 @@ void IrqMgr_HandleRetrace(IrqMgr* irqmgr);
void IrqMgr_ThreadEntry(IrqMgr* irqmgr);
void IrqMgr_Init(IrqMgr* irqmgr, void* stack, OSPri pri, u8 retraceCount);
-void osSyncPrintfUnused(const char* fmt, ...);
-
-void rmonPrintf(const char* fmt, ...);
-
void RcpUtils_PrintRegisterStatus(void);
void RcpUtils_Reset(void);
@@ -1324,6 +1321,41 @@ u8 AudioSeq_ResetReverb(void);
void AudioSeq_ResetActiveSequences(void);
void AudioSeq_ResetActiveSequencesAndVolume(void);
+// #region 2S2H [Port] Made Available via C++
+s32 osContInit(OSMesgQueue* mq, u8* controllerBits, OSContStatus* status);
+s32 osContStartReadData(OSMesgQueue* mesg);
+void osContGetReadData(OSContPad* pad);
+// #endregion
+// #region 2S2H [Port] Previously unavailable functions, made available for porting
+void PadMgr_ThreadEntry();
+void Heaps_Alloc(void);
+// #endregion
+// #region 2S2H [Port] Stubbed methods
+void osSetThreadPri(OSThread* thread, OSPri p);
+OSPri osGetThreadPri(OSThread* t);
+void osSyncPrintfUnused(const char* fmt, ...);
+void osSyncPrintf(const char* fmt, ...);
+void rmonPrintf(const char* fmt, ...);
+void osCreateThread(OSThread* thread, OSId id, void* entry, void* arg, void* sp, OSPri p);
+void osStartThread(OSThread* t);
+void osViSwapBuffer(void* frameBufPtr);
+void osViBlack(u8 active);
+void osDestroyThread(OSThread* t);
+void osViSetMode(OSViMode* modep);
+void osViSetSpecialFeatures(u32 func);
+s32 osContStartQuery(OSMesgQueue* mq);
+s32 osContSetCh(u8 ch);
+void osContGetQuery(OSContStatus* data);
+void osSpTaskLoad(OSTask* intp);
+void osSpTaskStartGo(OSTask* tp);
+void* osViGetCurrentFramebuffer(void);
+void* osViGetNextFramebuffer(void);
+OSYieldResult osSpTaskYielded(OSTask* task);
+void osSpTaskYield(void);
+void osViSetXScale(f32 value);
+void osViSetYScale(f32 value);
+// #endregion
+
void Regs_InitData(PlayState* play);
#ifdef __cplusplus
diff --git a/mm/include/libc/stdint.h b/mm/include/libc/stdint.h
index 854fd2546..7681b0c28 100644
--- a/mm/include/libc/stdint.h
+++ b/mm/include/libc/stdint.h
@@ -3,8 +3,12 @@
#include "PR/ultratypes.h"
+// #region 2S2H [Port] These are defined by LUS
+#if 0
typedef s32 intptr_t;
typedef u32 uintptr_t;
+#endif
+// #endregion
#define INT8_MIN (-0x80)
#define INT16_MIN (-0x8000)
diff --git a/mm/include/variables.h b/mm/include/variables.h
index de20d2c8c..8f25d218e 100644
--- a/mm/include/variables.h
+++ b/mm/include/variables.h
@@ -25,7 +25,7 @@ extern s32 sIrqMgrRetraceCount;
extern u8 sYaz0DataBuffer[0x400];
extern u8* sYaz0CurDataEnd;
-extern u32 sYaz0CurRomStart;
+extern uintptr_t sYaz0CurRomStart;
extern u32 sYaz0CurSize;
extern u8* sYaz0MaxPtr;
extern void* gYaz0DecompressDstEnd;
diff --git a/mm/include/z64item.h b/mm/include/z64item.h
index 1a43b00af..1378d7562 100644
--- a/mm/include/z64item.h
+++ b/mm/include/z64item.h
@@ -669,7 +669,7 @@ typedef enum GetItemDrawId {
/* 0x73 */ GID_CHATEAU,
/* 0x74 */ GID_PICTOGRAPH_BOX,
/* 0x75 */ GID_MASK_FIERCE_DEITY,
- /* 0x76 */ GID_MAX
+ /* 0x76 */ GID_MAXIMUM // 2S2H [Port] Changed from GID_MAX because that's a reserved macro on MacOS(?)
} GetItemDrawId;
#endif
diff --git a/mm/macosx/Info.plist.in b/mm/macosx/Info.plist.in
new file mode 100644
index 000000000..9f861c6a9
--- /dev/null
+++ b/mm/macosx/Info.plist.in
@@ -0,0 +1,42 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ English
+ CFBundleName
+ 2 Ship 2 Harkinian
+ CFBundleExecutable
+ 2s2h
+ CFBundleGetInfoString
+ @CMAKE_PROJECT_VERSION@
+ CFBundleIconFile
+ 2s2h.icns
+ CFBundleIdentifier
+ com.2ship2harkinian.2Ship2Harkinian
+ CFBundleDocumentTypes
+
+
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ @CMAKE_PROJECT_VERSION@
+ CFBundleSignature
+ ZMM
+ CFBundleVersion
+ @CMAKE_PROJECT_VERSION@
+ NSHumanReadableCopyright
+ Copyright 2024 HarbourMasters.
+ LSApplicationCategoryType
+ public.app-category.games
+ LSMinimumSystemVersion
+ 10.15
+ LSArchitecturePriority
+
+ arm64
+ x86_64
+
+
+
diff --git a/mm/src/boot/O2/padutils.c b/mm/src/boot/O2/padutils.c
index b56c01a24..197f23efb 100644
--- a/mm/src/boot/O2/padutils.c
+++ b/mm/src/boot/O2/padutils.c
@@ -1,4 +1,5 @@
#include "padutils.h"
+#include
#include
void PadUtils_Init(Input* input) {
diff --git a/mm/src/boot/fault.c b/mm/src/boot/fault.c
index 2244a8ce1..5ca8f8391 100644
--- a/mm/src/boot/fault.c
+++ b/mm/src/boot/fault.c
@@ -51,6 +51,8 @@
#include "main.h"
#include "macros.h"
#include "global.h"
+#include
+
#if 0
FaultMgr* sFaultInstance;
f32 sFaultTimeTotal; // read but not set anywhere
diff --git a/mm/src/boot/viconfig.c b/mm/src/boot/viconfig.c
index cfb17fe32..b3faf85d5 100644
--- a/mm/src/boot/viconfig.c
+++ b/mm/src/boot/viconfig.c
@@ -1,5 +1,6 @@
#include "libc/stdbool.h"
#include "idle.h"
+#include "functions.h"
extern OSViMode osViModeNtscHpf1;
extern OSViMode osViModePalLan1;
diff --git a/mm/src/boot/yaz0.c b/mm/src/boot/yaz0.c
index 54a3481f1..edd3be06a 100644
--- a/mm/src/boot/yaz0.c
+++ b/mm/src/boot/yaz0.c
@@ -1,5 +1,6 @@
#include "global.h"
#include "fault.h"
+#include
u8 sYaz0DataBuffer[0x400] ALIGNED(16);
u8* sYaz0CurDataEnd;
diff --git a/mm/src/boot/z_std_dma.c b/mm/src/boot/z_std_dma.c
index 208d6ed52..26b870d03 100644
--- a/mm/src/boot/z_std_dma.c
+++ b/mm/src/boot/z_std_dma.c
@@ -119,7 +119,7 @@ s32 DmaMgr_FindDmaIndex(uintptr_t vrom) {
#endif
}
-const char* func_800809F4(u32 a0) {
+const char* func_800809F4(uintptr_t a0) {
return "??";
}
diff --git a/mm/src/buffers/heaps.c b/mm/src/buffers/heaps.c
index 6a7cba7a8..c51f57f15 100644
--- a/mm/src/buffers/heaps.c
+++ b/mm/src/buffers/heaps.c
@@ -1,6 +1,7 @@
#include "buffers.h"
#include
#include
+#include
u8* gAudioHeap;
diff --git a/mm/src/code/padmgr.c b/mm/src/code/padmgr.c
index 09e29eaf5..44b0f763a 100644
--- a/mm/src/code/padmgr.c
+++ b/mm/src/code/padmgr.c
@@ -35,6 +35,7 @@
#include "PR/controller.h"
#include "PR/os_motor.h"
#include "fault.h"
+#include
//extern FaultMgr gFaultMgr;
diff --git a/mm/src/code/stubs.c b/mm/src/code/stubs.c
index 19c2d7a2c..8927089d9 100644
--- a/mm/src/code/stubs.c
+++ b/mm/src/code/stubs.c
@@ -2,6 +2,7 @@
#include
#include "z64.h"
#include
+#include "BenPort.h"
//#include
#define SCREEN_WIDTH 320
@@ -383,7 +384,7 @@ int bcmp(void* __s1, void* __s2, int __n) {
}
#endif
int ResourceMgr_OTRSigCheck(char* imgData);
-char* ResourceMgr_LoadTexOrDListByName(char* data);
+char* ResourceMgr_LoadTexOrDListByName(const char* data);
void gSPSegment(void* value, int segNum, uintptr_t target) {
char* imgData = (char*)target;
@@ -560,9 +561,9 @@ s32 osAiSetFrequency(u32 frequency) {
}
s32 osContStartQuery(OSMesgQueue* mq) {
}
-void osCreateThread(void* a, u32 b, void* c, void* d) {
+void osCreateThread(OSThread* thread, OSId id, void* entry, void* arg, void* sp, OSPri p) {
}
-void osGetThreadPri(void* a) {
+OSPri osGetThreadPri(OSThread* t) {
}
void osContGetQuery(OSContStatus* data) {
}
@@ -599,7 +600,7 @@ void osViSetXScale(f32 value) {
}
void osSpTaskYield(void) {
}
-u32* osViGetCurrentFramebuffer(void) {
+void* osViGetCurrentFramebuffer(void) {
}
OSPiHandle* osFlashInit(void) {
}
diff --git a/mm/src/code/z_bgcheck.c b/mm/src/code/z_bgcheck.c
index 4e6a2e7a8..7b8802b35 100644
--- a/mm/src/code/z_bgcheck.c
+++ b/mm/src/code/z_bgcheck.c
@@ -4,6 +4,7 @@
#include "fixed_point.h"
#include "vt.h"
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
+#include
#define DYNA_RAYCAST_FLOORS 1
#define DYNA_RAYCAST_WALLS 2
diff --git a/mm/src/code/z_message_nes.c b/mm/src/code/z_message_nes.c
index 79c2cb4c2..cf595be0c 100644
--- a/mm/src/code/z_message_nes.c
+++ b/mm/src/code/z_message_nes.c
@@ -1,6 +1,7 @@
#include "global.h"
#include "message_data_static.h"
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
+#include
f32 sNESFontWidths[160] = {
8.0f, 8.0f, 6.0f, 9.0f, 9.0f, 14.0f, 12.0f, 3.0f, 7.0f, 7.0f, 7.0f, 9.0f, 4.0f, 6.0f, 4.0f, 9.0f,
diff --git a/mm/src/code/z_rcp.c b/mm/src/code/z_rcp.c
index 2ae0388cb..0377274e1 100644
--- a/mm/src/code/z_rcp.c
+++ b/mm/src/code/z_rcp.c
@@ -1540,10 +1540,12 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g
OPEN_DISPS(gfxCtx);
+ // #region 2S2H [Port] Crashes on MacOS
gSPDisplayList(POLY_OPA_DISP++, gGfxMasterDL->setupBuffers);
gSPDisplayList(POLY_XLU_DISP++, gGfxMasterDL->setupBuffers);
gSPDisplayList(OVERLAY_DISP++, gGfxMasterDL->setupBuffers);
gSPDisplayList(DEBUG_DISP++, gGfxMasterDL->setupBuffers);
+ // #endregion
if (clearZb) {
__gSPDisplayList(POLY_OPA_DISP++,
diff --git a/mm/src/code/z_vr_box.c b/mm/src/code/z_vr_box.c
index 7e57c473b..546b91976 100644
--- a/mm/src/code/z_vr_box.c
+++ b/mm/src/code/z_vr_box.c
@@ -29,7 +29,7 @@ const char* sD2CloudStaticTex[] = {
gCloudySkybox1Tex, gCloudySkybox2Tex, gCloudySkybox3Tex, gCloudySkybox4Tex, gCloudySkybox5Tex,
};
-SkyboxFiles files[] = {
+SkyboxFiles skyboxFiles[] = { // 2S2H [Port] Renamed from files because of conflcit
{ sD2FineStaticTex, gClearSkyboxTlue },
{ sD2CloudStaticTex, gClearSkyboxTlue },
};