From 3e0023961f79c0e7bf6225a441d237420d479277 Mon Sep 17 00:00:00 2001 From: PJB3005 Date: Wed, 25 Feb 2026 20:43:43 +0100 Subject: [PATCH] Windows build fixes Name mangling/linkage shenanigans Remove jsystem_stubs.cpp, it's not necessary. --- files.cmake | 1 - include/JSystem/JAudio2/JASBank.h | 2 +- include/JSystem/JAudio2/JASHeapCtrl.h | 2 +- include/JSystem/JAudio2/JAUSectionHeap.h | 4 +- include/c/c_damagereaction.h | 5 +- include/d/d_meter2_info.h | 2 +- src/JSystem/JAudio2/JASHeapCtrl.cpp | 2 - src/JSystem/JKernel/JKRHeap.cpp | 20 ++-- src/c/c_damagereaction.cpp | 6 +- src/d/d_particle.cpp | 4 +- src/dusk/J3DTransforms_C.cpp | 1 + src/dusk/jsystem_stubs.cpp | 140 ----------------------- src/dusk/stubs.cpp | 3 - 13 files changed, 26 insertions(+), 166 deletions(-) delete mode 100644 src/dusk/jsystem_stubs.cpp diff --git a/files.cmake b/files.cmake index 0d2bce5539..53466d5bf8 100644 --- a/files.cmake +++ b/files.cmake @@ -1325,7 +1325,6 @@ set(DUSK_FILES src/dusk/globals.cpp src/dusk/J3DTransforms_C.cpp #src/dusk/m_Do_ext_dusk.cpp - src/dusk/jsystem_stubs.cpp src/dusk/dvd_emu.cpp src/dolphin/os/OSContext.cpp src/dolphin/os/OSThread.cpp diff --git a/include/JSystem/JAudio2/JASBank.h b/include/JSystem/JAudio2/JASBank.h index 9c2fae3dfa..1a99601f3d 100644 --- a/include/JSystem/JAudio2/JASBank.h +++ b/include/JSystem/JAudio2/JASBank.h @@ -4,7 +4,7 @@ #include class JASChannel; -class JASInstParam; +struct JASInstParam; class JASWaveBank; namespace JASDsp { diff --git a/include/JSystem/JAudio2/JASHeapCtrl.h b/include/JSystem/JAudio2/JASHeapCtrl.h index 3cdd338538..05a97838b9 100644 --- a/include/JSystem/JAudio2/JASHeapCtrl.h +++ b/include/JSystem/JAudio2/JASHeapCtrl.h @@ -7,7 +7,7 @@ #include #include -class JASDisposer; +struct JASDisposer; class JKRHeap; class JKRSolidHeap; diff --git a/include/JSystem/JAudio2/JAUSectionHeap.h b/include/JSystem/JAudio2/JAUSectionHeap.h index b6aec38a31..e02b7df164 100644 --- a/include/JSystem/JAudio2/JAUSectionHeap.h +++ b/include/JSystem/JAudio2/JAUSectionHeap.h @@ -14,8 +14,8 @@ class JASVoiceBank; class JAUBankTableLink; class JAUDisposer_; class JAUSectionHeap; -class JAUSoundTable; -class JAUSoundNameTable; +struct JAUSoundTable; +struct JAUSoundNameTable; class JKRArchive; class JKRSolidHeap; diff --git a/include/c/c_damagereaction.h b/include/c/c_damagereaction.h index 3f927e4e32..e2c8bfe051 100644 --- a/include/c/c_damagereaction.h +++ b/include/c/c_damagereaction.h @@ -21,7 +21,10 @@ extern u8 data_80450C9D; extern u8 data_80450C9E; extern u8 cDmr_FishingWether; extern u8 data_80450CA0; -extern JPTraceParticleCallBack4 JPTracePCB4; + +extern "C" { + extern JPTraceParticleCallBack4 JPTracePCB4; +} void debug_actor_create(); diff --git a/include/d/d_meter2_info.h b/include/d/d_meter2_info.h index 0dad0ee3b2..649beea72c 100644 --- a/include/d/d_meter2_info.h +++ b/include/d/d_meter2_info.h @@ -5,7 +5,7 @@ class CPaneMgr; class J2DTextBox; -struct JMSMesgEntry_c; +class JMSMesgEntry_c; class JUTFont; struct dMenu_LetterData { diff --git a/src/JSystem/JAudio2/JASHeapCtrl.cpp b/src/JSystem/JAudio2/JASHeapCtrl.cpp index b7bddde2f0..e23ae3909f 100644 --- a/src/JSystem/JAudio2/JASHeapCtrl.cpp +++ b/src/JSystem/JAudio2/JASHeapCtrl.cpp @@ -8,7 +8,6 @@ #include "JSystem/JUtility/JUTAssert.h" #include -#if !TARGET_PC JASHeap::JASHeap(JASDisposer* disposer) : mTree(this) { mDisposer = disposer; mBase = NULL; @@ -16,7 +15,6 @@ JASHeap::JASHeap(JASDisposer* disposer) : mTree(this) { field_0x40 = 0; OSInitMutex(&mMutex); } -#endif void JASHeap::initRootHeap(void* param_0, u32 param_1) { JUT_ASSERT(97, ! isAllocated()); diff --git a/src/JSystem/JKernel/JKRHeap.cpp b/src/JSystem/JKernel/JKRHeap.cpp index e2aad73bab..6b9ec1e685 100644 --- a/src/JSystem/JKernel/JKRHeap.cpp +++ b/src/JSystem/JKernel/JKRHeap.cpp @@ -498,7 +498,7 @@ bool JKRHeap::isSubHeap(JKRHeap* heap) const { return false; } -#ifdef __MWERKS__ +#if !TARGET_PC void* operator new(size_t size) { return JKRHeap::alloc(size, 4, NULL); } @@ -516,14 +516,14 @@ void* operator new(size_t size) { } #endif -#ifdef __MWERKS__ +#if !TARGET_PC void* operator new(size_t size, int alignment) { return JKRHeap::alloc(size, alignment, NULL); } #else void* operator new(size_t size, int alignment) { if (sCurrentHeap == nullptr) -#if TARGET_PC +#if !_WIN32 return aligned_alloc(alignment, size); #else return _aligned_malloc(size, alignment); @@ -531,7 +531,7 @@ void* operator new(size_t size, int alignment) { void* mem = JKRHeap::alloc(size, alignment, nullptr); if (mem == nullptr) { OSReport("[NEW] JKRHeap FULL! Fallback to aligned_malloc size %u\n", (unsigned)size); -#if TARGET_PC +#if !_WIN32 return aligned_alloc(alignment, size); #else return _aligned_malloc(size, alignment); @@ -545,7 +545,7 @@ void* operator new(size_t size, JKRHeap* heap, int alignment) { return JKRHeap::alloc(size, alignment, heap); } -#ifdef __MWERKS__ +#if !TARGET_PC void* operator new[](size_t size) { return JKRHeap::alloc(size, 4, NULL); } @@ -561,21 +561,21 @@ void* operator new[](size_t size) { } #endif -#ifdef __MWERKS__ +#if !TARGET_PC void* operator new[](size_t size, int alignment) { return JKRHeap::alloc(size, alignment, NULL); } #else void* operator new[](size_t size, int alignment) { if (sCurrentHeap == nullptr) -#if TARGET_PC +#if !_WIN32 return aligned_alloc(alignment, size); #else return _aligned_malloc(size, alignment); #endif void* mem = JKRHeap::alloc(size, alignment, nullptr); if (mem == nullptr) -#if TARGET_PC +#if !_WIN32 return aligned_alloc(alignment, size); #else return _aligned_malloc(size, alignment); @@ -588,7 +588,7 @@ void* operator new[](size_t size, JKRHeap* heap, int alignment) { return JKRHeap::alloc(size, alignment, heap); } -#ifdef __MWERKS__ +#if !TARGET_PC void operator delete(void* ptr) { JKRHeap::free(ptr, NULL); } @@ -605,7 +605,7 @@ void operator delete(void* ptr) { } #endif -#ifdef __MWERKS__ +#if !TARGET_PC void operator delete[](void* ptr) { JKRHeap::free(ptr, NULL); } diff --git a/src/c/c_damagereaction.cpp b/src/c/c_damagereaction.cpp index bbae79726d..95781ba7e9 100644 --- a/src/c/c_damagereaction.cpp +++ b/src/c/c_damagereaction.cpp @@ -62,6 +62,6 @@ BOOL cDmrNowMidnaTalk() { u8 data_80450CA0; -#if !TARGET_PC -JPTraceParticleCallBack4 JPTracePCB4; -#endif +extern "C" { + JPTraceParticleCallBack4 JPTracePCB4; +} diff --git a/src/d/d_particle.cpp b/src/d/d_particle.cpp index f5ddeef3bc..e1396ca94a 100644 --- a/src/d/d_particle.cpp +++ b/src/d/d_particle.cpp @@ -33,7 +33,9 @@ //#pragma nosyminline on #endif -extern dPa_particleTracePcallBack_c JPTracePCB4; +extern "C" { + extern dPa_particleTracePcallBack_c JPTracePCB4; +} void dPa_cleanupGX() { GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); diff --git a/src/dusk/J3DTransforms_C.cpp b/src/dusk/J3DTransforms_C.cpp index efdd2793cd..fa8bc30607 100644 --- a/src/dusk/J3DTransforms_C.cpp +++ b/src/dusk/J3DTransforms_C.cpp @@ -1,5 +1,6 @@ #include #include +#include "JSystem/J3DGraphBase/J3DTransform.h" // translated to C, should be correct, but not tested. diff --git a/src/dusk/jsystem_stubs.cpp b/src/dusk/jsystem_stubs.cpp deleted file mode 100644 index 95386bf862..0000000000 --- a/src/dusk/jsystem_stubs.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* -#include -#include -*/ -#pragma mark J3DShapeTable -#include "JSystem/J3DGraphAnimator/J3DShapeTable.h" - -// JAISe::JAISeMgr_startID_, JAISeq::JAISeqMgr_startID_, JAIStream::JAIStreamMgr_startID_ -// are compiled from their real source files (JAISe.obj, JAISeq.obj, JAIStream.obj) - -#pragma mark JAUSection -#include "JSystem/JAudio2/JAUSectionHeap.h" - -#if 0 - -JAUSoundTable* JAUSection::newSoundTable(void const* data, u32 size, bool flag) { - puts("JAUSection::newSoundTable is a stub"); - return nullptr; -} -JAUSoundNameTable* JAUSection::newSoundNameTable(void const* data, u32 size, bool flag) { - puts("JAUSection::newSoundNameTable is a stub"); - return nullptr; -} -#endif -#pragma mark JASHeap -#include "JSystem/JAudio2/JASHeapCtrl.h" - -JASHeap::JASHeap(JASDisposer* disposer) - : mTree(this), mDisposer(disposer), mBase(nullptr), mSize(0), field_0x40(nullptr) { - OSInitMutex(&mMutex); -} - -#pragma mark JASVoiceBank -#include "JSystem/JAudio2/JASVoiceBank.h" - -/* -bool JASVoiceBank::getInstParam(int a, int b, int c, JASInstParam* param) const { - puts("JASVoiceBank::getInstParam is a stub"); - return false; -}*/ - -// JASSeqParser::sCallBackFunc is compiled from JASSeqParser.obj -/* -#pragma mark JHICommBuf -#include "JSystem/JHostIO/JHIComm.h" - -void JHICommBufHeader::init() { - puts("JHICommBufHeader::init is a stub"); -} - -int JHICommBufHeader::load() { - puts("JHICommBufHeader::load is a stub"); - return -1; -} - -int JHICommBufReader::readBegin() { - puts("JHICommBufReader::readBegin is a stub"); - return -1; -} - -void JHICommBufReader::readEnd() { - puts("JHICommBufReader::readEnd is a stub"); -} - -int JHICommBufReader::read(void* buf, int size) { - puts("JHICommBufReader::read is a stub"); - return 0; -} - -u32 JHICommBufReader::Header::getReadableSize() const { - puts("JHICommBufReader::Header::getReadableSize is a stub"); - return 0; -} - -int JHICommBufWriter::writeBegin() { - puts("JHICommBufWriter::writeBegin is a stub"); - return -1; -} - -void JHICommBufWriter::writeEnd() { - puts("JHICommBufWriter::writeEnd is a stub"); -} - -int JHICommBufWriter::write(void* buf, int size) { - puts("JHICommBufWriter::write is a stub"); - return 0; -} - -#pragma mark HIO / HIO2 -#include -#include - -extern "C" { - -BOOL HIORead(u32 addr, void* buffer, s32 size) { - puts("HIORead is a stub"); - return FALSE; -} - -BOOL HIOWrite(u32 addr, void* buffer, s32 size) { - puts("HIOWrite is a stub"); - return FALSE; -} - -BOOL HIO2Init(void) { - puts("HIO2Init is a stub"); - return FALSE; -} - -BOOL HIO2EnumDevices(HIO2EnumCallback callback) { - puts("HIO2EnumDevices is a stub"); - return FALSE; -} - -s32 HIO2Open(HIO2DeviceType type, HIO2UnkCallback exiCb, HIO2DisconnectCallback disconnectCb) { - puts("HIO2Open is a stub"); - return -1; -} - -BOOL HIO2Close(s32 handle) { - puts("HIO2Close is a stub"); - return FALSE; -} - -} // extern "C" - -#pragma mark JOR -#include "JSystem/JHostIO/JORServer.h" - -int JOREventCallbackListNode::JORAct(u32 eventID, const char* eventName) { - puts("JOREventCallbackListNode::JORAct is a stub"); - return 0; -} -*/ -#if !TARGET_PC -#pragma mark J3DPSMtxArrayConcat -void J3DPSMtxArrayConcat(float (*a)[4], float (*b)[4], float (*out)[4], u32 count) { - puts("J3DPSMtxArrayConcat is a stub"); -} -#endif diff --git a/src/dusk/stubs.cpp b/src/dusk/stubs.cpp index f094c91c26..97955439f8 100644 --- a/src/dusk/stubs.cpp +++ b/src/dusk/stubs.cpp @@ -1859,6 +1859,3 @@ u32 JHICommBufReader::Header::getReadableSize() const { puts("JHICommBufReader::Header::getReadableSize is a stub"); return 0; } - - -dPa_particleTracePcallBack_c JPTracePCB4;