From 475ca80882225b65b468dc5262bdec7fe0b896e8 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 28 Feb 2026 15:43:37 -0700 Subject: [PATCH 1/9] Some MULTI_CHAR fixes --- CMakeLists.txt | 12 ++++----- include/global.h | 22 +++++++-------- src/d/actor/d_a_npc_bouS.cpp | 52 ++++++++++++++++++------------------ src/d/actor/d_a_npc_theB.cpp | 52 ++++++++++++++++++------------------ src/d/d_com_inf_game.cpp | 6 ++--- 5 files changed, 72 insertions(+), 72 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41f61c8df9..6f9284539a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,8 +15,11 @@ add_subdirectory(extern/aurora EXCLUDE_FROM_ALL) option(DUSK_BUILD_WARNINGS "If off, compiler warnings will be suppressed") 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} -Wno-register") + # Multi-character constants ('ABCD') are implementation-defined but all compilers + # (CW, GCC, Clang, MSVC) encode them identically in big-endian order. + # For >4-char literals (which GCC/Clang truncate to int), use the MULTI_CHAR() macro. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar -Wno-unused-variable -Wno-unused-parameter") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-multichar") set(CMAKE_INSTALL_RPATH "$ORIGIN") set(CMAKE_BUILD_RPATH "$ORIGIN") elseif (APPLE) @@ -38,10 +41,7 @@ elseif (MSVC) endif () add_compile_options(/utf-8) endif () -if (NOT MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error -Wno-c++11-narrowing") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error -Wno-c++11-narrowing") -endif () + include(files.cmake) diff --git a/include/global.h b/include/global.h index 8c9cfe3d7d..375b92de1a 100644 --- a/include/global.h +++ b/include/global.h @@ -169,22 +169,22 @@ static const float INF = 2000000000.0f; #define UNSET_FLAG(var, flag, type) (var) &= ~(flag) #endif -#ifdef TARGET_PC +// Macro for multi-character literals that exceed 4 bytes (e.g. 'ari_os'). +// CW encodes all characters in big-endian order into the full integer, but GCC/Clang +// truncate multi-char constants to int (4 bytes). This macro produces matching u64 +// values on all compilers. For <=4-char literals, raw constants like 'ABCD' are fine. +#ifdef __MWERKS__ + #define MULTI_CHAR(x) (x) +#else template - inline constexpr auto MultiCharLiteral(const char (&buf)[N]) { - // static_assert(buf[0] == '\'' && buf[N - 2] == '\''); // can't constexpr strings, just pray - constexpr int len = N - 1; - static_assert(len >= 2 && len <= 10); - + inline constexpr unsigned long long MultiCharLiteral(const char (&buf)[N]) { + static_assert(N - 1 >= 3 && N - 1 <= 10, "MULTI_CHAR literal must be 1-8 characters"); unsigned long long out = 0; - for (int i = 1; i < len - 1; i++) { - out = (out << 8) | ((unsigned long long)buf[i]); + for (int i = 1; i < N - 2; i++) { + out = (out << 8) | static_cast(buf[i]); } return out; } - - #define MULTI_CHAR(x) MultiCharLiteral(#x) -#else #define MULTI_CHAR(x) MultiCharLiteral(#x) #endif diff --git a/src/d/actor/d_a_npc_bouS.cpp b/src/d/actor/d_a_npc_bouS.cpp index a782634f37..6d807edacd 100644 --- a/src/d/actor/d_a_npc_bouS.cpp +++ b/src/d/actor/d_a_npc_bouS.cpp @@ -1361,22 +1361,22 @@ int daNpcBouS_c::EvCut_BousIntroSumo1(int i_staffId) { if (eventManager.getIsAddvance(i_staffId)) { switch (*cutName) { - case MULTI_CHAR('0001'): + case '0001': setLookMode(LOOK_PLAYER_TALK); mActorMngrs[0].entry(daPy_getPlayerActorClass()); break; - case MULTI_CHAR('0002'): - case MULTI_CHAR('0003'): - case MULTI_CHAR('0005'): - case MULTI_CHAR('0006'): - case MULTI_CHAR('0007'): - case MULTI_CHAR('0008'): - case MULTI_CHAR('0009'): + case '0002': + case '0003': + case '0005': + case '0006': + case '0007': + case '0008': + case '0009': initTalk(9, NULL); break; - case MULTI_CHAR('0004'): + case '0004': setExpressionAnm(ANM_FH_TALK_B, true); break; @@ -1397,17 +1397,17 @@ int daNpcBouS_c::EvCut_BousIntroSumo1(int i_staffId) { } switch (*cutName) { - case MULTI_CHAR('0001'): - case MULTI_CHAR('0004'): + case '0001': + case '0004': return 1; - case MULTI_CHAR('0002'): - case MULTI_CHAR('0003'): - case MULTI_CHAR('0005'): - case MULTI_CHAR('0006'): - case MULTI_CHAR('0007'): - case MULTI_CHAR('0008'): - case MULTI_CHAR('0009'): + case '0002': + case '0003': + case '0005': + case '0006': + case '0007': + case '0008': + case '0009': if (talkProc(NULL, TRUE, NULL)) { s32 choiceNo = mFlow.getChoiceNo(); OS_REPORT("二択分岐 %s\n", choiceNo == 0 ? "はい" : "いいえ"); @@ -1435,7 +1435,7 @@ int daNpcBouS_c::EvCut_BousIntroSumo2(int i_staffId) { if (eventManager.getIsAddvance(i_staffId)) { switch (*cutName) { - case MULTI_CHAR('0001'): + case '0001': initTalk(9, NULL); setLookMode(LOOK_PLAYER_TALK); mActorMngrs[0].entry(daPy_getPlayerActorClass()); @@ -1457,7 +1457,7 @@ int daNpcBouS_c::EvCut_BousIntroSumo2(int i_staffId) { } switch (*cutName) { - case MULTI_CHAR('0001'): + case '0001': if (mCurAngle.y == fopAcM_searchPlayerAngleY(this)) { if (talkProc(NULL, TRUE, NULL)) { int choiceNo = mFlow.getChoiceNo(); @@ -1490,15 +1490,15 @@ int daNpcBouS_c::EvCut_BousIntroSumo3(int i_staffId) { if (eventManager.getIsAddvance(i_staffId)) { switch (*cutName) { - case MULTI_CHAR('0001'): + case '0001': setLookMode(LOOK_PLAYER_TALK); mActorMngrs[0].entry(daPy_getPlayerActorClass()); break; - case MULTI_CHAR('0003'): + case '0003': setMotion(MOT_WALK, -1.0f, 0); // fallthrough - case MULTI_CHAR('0002'): + case '0002': setAngle(-0x2AAA); initTalk(9, NULL); break; @@ -1522,16 +1522,16 @@ int daNpcBouS_c::EvCut_BousIntroSumo3(int i_staffId) { } switch (*cutName) { - case MULTI_CHAR('0001'): + case '0001': return 1; - case MULTI_CHAR('0002'): + case '0002': if (talkProc(NULL, TRUE, NULL)) { return 1; } break; - case MULTI_CHAR('0003'): { + case '0003': { cXyz* pos = dComIfGp_evmng_getMyXyzP(i_staffId, "pos"); if (pos != NULL) { if (cLib_chaseAngleS(&shape_angle.y, cLib_targetAngleY(¤t.pos, pos), 0x100)) { diff --git a/src/d/actor/d_a_npc_theB.cpp b/src/d/actor/d_a_npc_theB.cpp index a0e6ffb701..5cde34a632 100644 --- a/src/d/actor/d_a_npc_theB.cpp +++ b/src/d/actor/d_a_npc_theB.cpp @@ -1177,10 +1177,10 @@ int daNpcTheB_c::EvCut_PersonalCombatIntro(int i_staffId) { if (eventManager.getIsAddvance(i_staffId)) { switch (*cutName) { - case MULTI_CHAR('0001'): + case '0001': break; - case MULTI_CHAR('0002'): + case '0002': initTalk(0x16, NULL); setLookMode(LOOK_PLAYER); mActorMngrs[0].entry(daPy_getPlayerActorClass()); @@ -1205,10 +1205,10 @@ int daNpcTheB_c::EvCut_PersonalCombatIntro(int i_staffId) { } switch (*cutName) { - case MULTI_CHAR('0001'): + case '0001': return 1; - case MULTI_CHAR('0002'): + case '0002': if (talkProc(NULL, TRUE, NULL)) { dComIfGs_onSaveDunSwitch(52); dComIfGs_onSaveDunSwitch(53); @@ -1230,7 +1230,7 @@ int daNpcTheB_c::EvCut_PersonalCombatRevenge(int i_staffId) { if (eventManager.getIsAddvance(i_staffId)) { switch (*cutName) { - case MULTI_CHAR('0001'): { + case '0001': { fopAc_ac_c* actor_p = getEvtAreaTagP(5, 0); cXyz* pos = dComIfGp_evmng_getMyXyzP(i_staffId, "pos"); int* angle = dComIfGp_evmng_getMyIntegerP(i_staffId, "angle"); @@ -1249,13 +1249,13 @@ int daNpcTheB_c::EvCut_PersonalCombatRevenge(int i_staffId) { break; } - case MULTI_CHAR('0002'): + case '0002': initTalk(0x17, NULL); setLookMode(LOOK_PLAYER); mActorMngrs[0].entry(daPy_getPlayerActorClass()); break; - case MULTI_CHAR('0003'): + case '0003': break; default: @@ -1283,19 +1283,19 @@ int daNpcTheB_c::EvCut_PersonalCombatRevenge(int i_staffId) { } switch (*cutName) { - case MULTI_CHAR('0001'): + case '0001': if (getCoachSpeed() == 0.0f) { return 1; } break; - case MULTI_CHAR('0002'): + case '0002': if (talkProc(NULL, TRUE, NULL)) { return 1; } break; - case MULTI_CHAR('0003'): + case '0003': return 1; default: @@ -1412,7 +1412,7 @@ int daNpcTheB_c::EvCut_AnnulationFieldRace(int i_staffId) { if (eventManager.getIsAddvance(i_staffId)) { switch (*cutName) { - case MULTI_CHAR('0001'): + case '0001': if (startAndGoal_p != NULL) { startAndGoal_p->readyStartTimer(); } @@ -1425,7 +1425,7 @@ int daNpcTheB_c::EvCut_AnnulationFieldRace(int i_staffId) { } switch (*cutName) { - case MULTI_CHAR('0001'): + case '0001': if (startAndGoal_p != NULL && startAndGoal_p->isStartCheck()) { return 1; } @@ -1445,15 +1445,15 @@ int daNpcTheB_c::EvCut_TheBHint(int i_staffId) { if (eventManager.getIsAddvance(i_staffId)) { switch (*cutName) { - case MULTI_CHAR('0001'): + case '0001': setMotionAnm(ANM_SIT, 0.0f); break; - case MULTI_CHAR('0002'): + case '0002': initTalk(mHintMsgNo, NULL); break; - case MULTI_CHAR('0003'): { + case '0003': { cXyz pos; csXyz angle; daNpcF_getPlayerInfoFromPlayerList(field_0xe04, mRoomNo, pos, angle); @@ -1480,11 +1480,11 @@ int daNpcTheB_c::EvCut_TheBHint(int i_staffId) { } switch (*cutName) { - case MULTI_CHAR('0001'): - case MULTI_CHAR('0003'): + case '0001': + case '0003': return 1; - case MULTI_CHAR('0002'): + case '0002': if (talkProc(NULL, TRUE, NULL)) { mHintEvtFlag = 0; return 1; @@ -1505,22 +1505,22 @@ int daNpcTheB_c::EvCut_CoachGuardGameOver(int i_staffId) { if (eventManager.getIsAddvance(i_staffId)) { switch (*cutName) { - case MULTI_CHAR('0001'): + case '0001': Z2GetAudioMgr()->bgmStart(Z2BGM_GAME_OVER, 0, 0); break; - case MULTI_CHAR('0002'): { + case '0002': { daNpcCoach_c* coach_p = (daNpcCoach_c*)fopAcM_SearchByID(parentActorID); cXyz pos(0.0f, -30000.0f, 0.0f); coach_p->setPosAngle(pos, shape_angle); break; } - case MULTI_CHAR('0003'): + case '0003': ((daCoach2D_c*)fpcM_SearchByName(PROC_COACH2D))->hide(); break; - case MULTI_CHAR('0004'): + case '0004': break; default: @@ -1530,12 +1530,12 @@ int daNpcTheB_c::EvCut_CoachGuardGameOver(int i_staffId) { } switch (*cutName) { - case MULTI_CHAR('0001'): - case MULTI_CHAR('0002'): - case MULTI_CHAR('0003'): + case '0001': + case '0002': + case '0003': return 1; - case MULTI_CHAR('0004'): + case '0004': daPy_getPlayerActorClass()->onForceGameOver(); return 1; diff --git a/src/d/d_com_inf_game.cpp b/src/d/d_com_inf_game.cpp index 2e5791f870..b7180656db 100644 --- a/src/d/d_com_inf_game.cpp +++ b/src/d/d_com_inf_game.cpp @@ -1114,7 +1114,7 @@ void dComIfG_inf_c::baseCsr_c::draw(f32 param_1, f32 param_2) { r28 = 0xFF; } - J2DPicture* picture = field_0x8.getPicture('cursor00'); + J2DPicture* picture = field_0x8.getPicture(MULTI_CHAR('cursor00')); JUT_ASSERT(1450, picture != NULL); picture->scale(1.3f, 1.3f); JUtility::TColor color = picture->getWhite(); @@ -1148,7 +1148,7 @@ void dComIfG_inf_c::baseCsr_c::create() { int rt = field_0x8.create(resInfo->getArchive(), "zelda_pointing_cursor_navi.blo"); JUT_ASSERT(1498, rt); - J2DPicture* picture = field_0x8.getPicture('cursor00'); + J2DPicture* picture = field_0x8.getPicture(MULTI_CHAR('cursor00')); JUT_ASSERT(1500, picture != NULL); JUtility::TColor color = picture->getWhite(); color.a = 0; @@ -1172,7 +1172,7 @@ void dComIfG_inf_c::baseCsr_c::particleExecute() { } void dComIfG_inf_c::anmCsr_c::draw(f32 param_1, f32 param_2) { - field_0x8.setPos('lock_n', param_1, param_2); + field_0x8.setPos(MULTI_CHAR('lock_n'), param_1, param_2); dComIfGd_set2DXlu(&field_0x8); } #endif From 62f42abe12954ff67b78d58b1b3e8578aa97bf78 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 28 Feb 2026 15:59:24 -0700 Subject: [PATCH 2/9] Fix all -Wconversion-null warnings --- include/JSystem/J2DGraph/J2DAnimation.h | 2 +- include/d/d_stage.h | 50 +++++++++++------------ include/dolphin/types.h | 6 ++- include/revolution/types.h | 6 ++- src/DynamicLink.cpp | 2 +- src/JSystem/J2DGraph/J2DPictureEx.cpp | 2 +- src/JSystem/J3DGraphBase/J3DShape.cpp | 2 +- src/JSystem/JAudio2/JASSimpleWaveBank.cpp | 2 +- src/JSystem/JAudio2/JAUSectionHeap.cpp | 2 +- src/JSystem/JKernel/JKRAram.cpp | 2 +- src/JSystem/JKernel/JKRFileCache.cpp | 2 +- src/JSystem/JKernel/JKRThread.cpp | 2 +- src/JSystem/JParticle/JPAEmitter.cpp | 2 +- src/d/actor/d_a_alink.cpp | 2 +- src/d/actor/d_a_alink_horse.inc | 2 +- src/d/actor/d_a_alink_swim.inc | 2 +- src/d/actor/d_a_b_dr.cpp | 2 +- src/d/actor/d_a_door_shutter.cpp | 2 +- src/d/actor/d_a_e_yh.cpp | 2 +- src/d/actor/d_a_e_ym.cpp | 2 +- src/d/actor/d_a_kago.cpp | 4 +- src/d/actor/d_a_npc_blue_ns.cpp | 4 +- src/d/actor/d_a_npc_fairy.cpp | 6 +-- src/d/actor/d_a_npc_grm.cpp | 4 +- src/d/actor/d_a_npc_henna.cpp | 2 +- src/d/actor/d_a_npc_kasi_hana.cpp | 6 +-- src/d/actor/d_a_npc_kasi_kyu.cpp | 6 +-- src/d/actor/d_a_npc_kasi_mich.cpp | 6 +-- src/d/actor/d_a_npc_maro.cpp | 2 +- src/d/actor/d_a_npc_shad.cpp | 2 +- src/d/actor/d_a_npc_ykw.cpp | 2 +- src/d/actor/d_a_obj_batta.cpp | 2 +- src/d/actor/d_a_obj_bed.cpp | 2 +- src/d/actor/d_a_obj_bky_rock.cpp | 2 +- src/d/actor/d_a_obj_digholl.cpp | 4 +- src/d/actor/d_a_obj_lv3Water.cpp | 2 +- src/d/actor/d_a_obj_lv6ChangeGate.cpp | 4 +- src/d/actor/d_a_obj_prop.cpp | 2 +- src/d/actor/d_a_obj_rope_bridge.cpp | 2 +- src/d/actor/d_a_obj_sekizoa.cpp | 2 +- src/d/actor/d_a_obj_stone.cpp | 2 +- src/d/actor/d_a_obj_vground.cpp | 4 +- src/d/actor/d_a_shop_item.cpp | 2 +- src/d/actor/d_a_tag_allmato.cpp | 2 +- src/d/d_bg_w_kcol.cpp | 6 +-- src/d/d_cc_d.cpp | 2 +- src/d/d_event_manager.cpp | 2 +- src/d/d_menu_dmap.cpp | 2 +- src/d/d_menu_letter.cpp | 4 +- src/d/d_meter2_draw.cpp | 2 +- src/d/d_msg_scrn_staff.cpp | 2 +- src/d/d_s_logo.cpp | 2 +- src/d/d_s_name.cpp | 4 +- src/d/d_stage.cpp | 10 ++--- 54 files changed, 108 insertions(+), 100 deletions(-) diff --git a/include/JSystem/J2DGraph/J2DAnimation.h b/include/JSystem/J2DGraph/J2DAnimation.h index c1408a898d..76d8d06171 100644 --- a/include/JSystem/J2DGraph/J2DAnimation.h +++ b/include/JSystem/J2DGraph/J2DAnimation.h @@ -59,7 +59,7 @@ public: J2DAnmVtxColor() { mKind = KIND_VTX_COLOR; for (int i = 0; i < ARRAY_SIZE(mAnmTableNum); i++) { - mAnmTableNum[i] = NULL; + mAnmTableNum[i] = 0; } for (int i = 0; i < ARRAY_SIZE(mVtxColorIndexData); i++) { mVtxColorIndexData[i] = NULL; diff --git a/include/d/d_stage.h b/include/d/d_stage.h index 335d432c75..6f558f87c0 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -573,7 +573,7 @@ public: virtual roomRead_class* getRoom(void) const { OSReport("Room non room data !!\n"); JUT_ASSERT(2100, FALSE); - return NULL; + return 0; } virtual void setMapInfo(stage_map_info_class* i_MapInfo) { mMapInfo = i_MapInfo; } virtual stage_map_info_class* getMapInfo(void) const { return mMapInfo; } @@ -589,7 +589,7 @@ public: virtual stage_palette_info_class* getPaletteInfo(void) const { OSReport("Room non palet data !!\n"); JUT_ASSERT(2130, FALSE); - return NULL; + return 0; } virtual void setPselectInfo(stage_pselect_info_class* i_PselectInfo) { UNUSED(i_PselectInfo); @@ -600,7 +600,7 @@ public: virtual stage_pselect_info_class* getPselectInfo(void) const { OSReport("Room non pselect data !!\n"); JUT_ASSERT(2141, FALSE); - return NULL; + return 0; } virtual void setEnvrInfo(stage_envr_info_class* i_EnvrInfo) { UNUSED(i_EnvrInfo); @@ -611,7 +611,7 @@ public: virtual stage_envr_info_class* getEnvrInfo(void) const { OSReport("Room non envr data !!\n"); JUT_ASSERT(2152, FALSE); - return NULL; + return 0; } virtual void setVrboxInfo(stage_vrbox_info_class* i_VrboxInfo) { mVrboxInfo = i_VrboxInfo; } virtual stage_vrbox_info_class* getVrboxInfo(void) const { return mVrboxInfo; } @@ -626,7 +626,7 @@ public: virtual stage_plight_info_class* getPlightInfo(void) const { OSReport("Room non plight data !!\n"); JUT_ASSERT(2178, FALSE); - return NULL; + return 0; } virtual void setPaletteNumInfo(int i_PaletteNumInfo) { UNUSED(i_PaletteNumInfo); @@ -637,7 +637,7 @@ public: virtual int getPaletteNumInfo(void) const { OSReport("Room non palette num data !!\n"); JUT_ASSERT(2190, FALSE); - return NULL; + return 0; } virtual void setPselectNumInfo(int i_PselectNumInfo) { UNUSED(i_PselectNumInfo); @@ -648,7 +648,7 @@ public: virtual int getPselectNumInfo(void) const { OSReport("Room non pselect num data !!\n"); JUT_ASSERT(2201, FALSE); - return NULL; + return 0; } virtual void setEnvrNumInfo(int i_EnvrNumInfo) { UNUSED(i_EnvrNumInfo); @@ -659,7 +659,7 @@ public: virtual int getEnvrNumInfo(void) const { OSReport("Room non envr num data !!\n"); JUT_ASSERT(2212, FALSE); - return NULL; + return 0; } virtual void setVrboxNumInfo(int i_VrboxNumInfo) { mVrboxNumInfo = i_VrboxNumInfo; } virtual int getVrboxNumInfo(void) const { return mVrboxNumInfo; } @@ -674,7 +674,7 @@ public: virtual int getPlightNumInfo(void) const { OSReport("Room non plight num data !!\n"); JUT_ASSERT(2227, FALSE); - return NULL; + return 0; } virtual void setLightVecInfo(stage_pure_lightvec_info_class* i_LightVecInfo) { mLightVecInfo = i_LightVecInfo; } virtual stage_pure_lightvec_info_class* getLightVecInfo(void) const { return mLightVecInfo; } @@ -689,7 +689,7 @@ public: virtual stage_stag_info_class* getStagInfo(void) const { OSReport("Room non stag data !!\n"); JUT_ASSERT(2260, FALSE); - return NULL; + return 0; } virtual void setSclsInfo(stage_scls_info_dummy_class* i_SclsInfo) { mSclsInfo = i_SclsInfo; } virtual stage_scls_info_dummy_class* getSclsInfo(void) const { return mSclsInfo; } @@ -702,7 +702,7 @@ public: virtual dStage_dPnt_c* getPntInf(void) const { OSReport("Room non Pnts data !\n"); JUT_ASSERT(2285, FALSE); - return NULL; + return 0; } virtual void setPathInfo(dStage_dPath_c* i_PathInfo) { UNUSED(i_PathInfo); @@ -713,7 +713,7 @@ public: virtual dStage_dPath_c* getPathInf(void) const { OSReport("Room non Path data !\n"); JUT_ASSERT(2296, FALSE); - return NULL; + return 0; } virtual void setPnt2Info(dStage_dPnt_c* i_Pnt2Info) { mPnt2Info = i_Pnt2Info; } virtual dStage_dPnt_c* getPnt2Inf(void) const { return mPnt2Info; } @@ -739,7 +739,7 @@ public: virtual dStage_MemoryConfig_c* getMemoryConfig(void) const { OSReport("Room non memory config data!\n"); JUT_ASSERT(2423, FALSE); - return NULL; + return 0; } virtual void setMemoryMap(dStage_MemoryMap_c* i_MemoryMap) { UNUSED(i_MemoryMap); @@ -749,7 +749,7 @@ public: virtual dStage_MemoryMap_c* getMemoryMap(void) const { OSReport("Room non memory map data!\n"); JUT_ASSERT(2442, FALSE); - return NULL; + return 0; } virtual void setMulti(dStage_Multi_c* i_Multi) { UNUSED(i_Multi); @@ -759,7 +759,7 @@ public: virtual dStage_Multi_c* getMulti(void) const { OSReport("Room non multi data!\n"); JUT_ASSERT(2457, FALSE); - return NULL; + return 0; } virtual void setOldMulti(void) { OSReport("Room non old multi data!\n"); @@ -772,7 +772,7 @@ public: virtual dStage_Multi_c* getOldMulti(void) const { OSReport("Room non old multi data!\n"); JUT_ASSERT(2472, FALSE); - return NULL; + return 0; } virtual void setLbnk(dStage_Lbnk_c* i_Lbnk) { mLbnk = i_Lbnk; } virtual dStage_Lbnk_c* getLbnk(void) const { return mLbnk; } @@ -786,7 +786,7 @@ public: virtual dStage_DMap_c* getDMap(void) const { OS_REPORT("Room non DMap data\n"); JUT_ASSERT(2513, FALSE); - return NULL; + return 0; } virtual void setDrTg(stage_tgsc_class* i_DrTg) { mDrTg = i_DrTg; } virtual stage_tgsc_class* getDrTg(void) const { return mDrTg; } @@ -804,7 +804,7 @@ public: virtual void* getMapPath(void) { OSReport("stage non 2d map path data !!\n"); JUT_ASSERT(2561, FALSE); - return NULL; + return 0; } virtual void setElst(dStage_Elst_c* i_Elst) { UNUSED(i_Elst); @@ -815,7 +815,7 @@ public: virtual dStage_Elst_c* getElst(void) { dStage_SetErrorRoom(); OSReport("Room no Elst Data!!\n"); - return NULL; + return 0; } public: @@ -901,7 +901,7 @@ public: /* vt[43] */ virtual stage_pure_lightvec_info_class* getLightVecInfo(void) const { OSReport("stage non LightVec data !!\n"); JUT_ASSERT(3007, FALSE); - return NULL; + return 0; } /* vt[44] */ virtual void setLightVecInfoNum(int i_LightVecInfoNum) { UNUSED(i_LightVecInfoNum); @@ -912,7 +912,7 @@ public: /* vt[45] */ virtual int getLightVecInfoNum(void) const { OSReport("stage non LightVecNum data !!\n"); JUT_ASSERT(3018, FALSE); - return NULL; + return 0; } /* vt[40] */ virtual void setPlightNumInfo(int i_PlightNumInfo) { mPlightNumInfo = i_PlightNumInfo; } /* vt[41] */ virtual int getPlightNumInfo(void) const { return mPlightNumInfo; } @@ -943,7 +943,7 @@ public: /* vt[65] */ virtual dStage_FileList2_dt_c* getFileList2Info(void) const { OSReport("stage non filelist2 data!\n"); JUT_ASSERT(3127, FALSE); - return NULL; + return 0; } /* vt[66] */ virtual void setFileListInfo(dStage_FileList_dt_c* list) { UNUSED(list); @@ -954,7 +954,7 @@ public: /* vt[67] */ virtual dStage_FileList_dt_c* getFileListInfo(void) const { OSReport("stage non filelist data!\n"); JUT_ASSERT(3142, FALSE); - return NULL; + return 0; } /* vt[68] */ virtual void setFloorInfo(dStage_FloorInfo_c* i_FloorInfo) { mFloorInfo = i_FloorInfo; } /* vt[69] */ virtual dStage_FloorInfo_c* getFloorInfo(void) const { return mFloorInfo; } @@ -976,7 +976,7 @@ public: /* vt[80] */ virtual dStage_Lbnk_c* getLbnk(void) const { OSReport("stage non Lbnk data!\n"); JUT_ASSERT(3238, FALSE); - return NULL; + return 0; } /* vt[81] */ virtual void setTresure(stage_tresure_class* i_Tresure) { mTresure = i_Tresure; } /* vt[82] */ virtual stage_tresure_class* getTresure(void) const { return mTresure; } @@ -995,7 +995,7 @@ public: virtual void* getUnit() { OSReport("stage non unit list data !!\n"); JUT_ASSERT(3325, 0); - return NULL; + return 0; } #endif /* vt[89] */ virtual void setMapPath(void* i_MapPath) { return; } diff --git a/include/dolphin/types.h b/include/dolphin/types.h index 5044dabbb5..8c7620a057 100644 --- a/include/dolphin/types.h +++ b/include/dolphin/types.h @@ -87,8 +87,12 @@ typedef unsigned int uint; #endif #ifndef NULL -#ifdef __cplusplus +#ifdef __cplusplus +#if __cplusplus >= 201103L +#define NULL nullptr +#else #define NULL 0 +#endif #else #define NULL ((void*)0) #endif diff --git a/include/revolution/types.h b/include/revolution/types.h index 355768087e..7b559fd505 100644 --- a/include/revolution/types.h +++ b/include/revolution/types.h @@ -71,8 +71,12 @@ typedef unsigned int uint; #endif #ifndef NULL -#ifdef __cplusplus +#ifdef __cplusplus +#if __cplusplus >= 201103L +#define NULL nullptr +#else #define NULL 0 +#endif #else #define NULL ((void*)0) #endif diff --git a/src/DynamicLink.cpp b/src/DynamicLink.cpp index 0d0ad35374..d83a937e4d 100644 --- a/src/DynamicLink.cpp +++ b/src/DynamicLink.cpp @@ -224,7 +224,7 @@ bool DynamicModuleControl::do_load() { if (mModule == NULL) { snprintf(buffer, 64, "/rel/Final/Release/%s.rel", mName); mModule = (OSModuleHeader*)JKRDvdToMainRam( - buffer, NULL, EXPAND_SWITCH_UNKNOWN1, NULL, heap, + buffer, NULL, EXPAND_SWITCH_UNKNOWN1, 0, heap, JKRDvdRipper::ALLOC_DIRECTION_FORWARD, 0, NULL, NULL); if (mModule != NULL) { mSize = 0; diff --git a/src/JSystem/J2DGraph/J2DPictureEx.cpp b/src/JSystem/J2DGraph/J2DPictureEx.cpp index 27cc68cc94..bf2ea7168a 100644 --- a/src/JSystem/J2DGraph/J2DPictureEx.cpp +++ b/src/JSystem/J2DGraph/J2DPictureEx.cpp @@ -917,7 +917,7 @@ JUTTexture* J2DPictureEx::getTexture(u8 param_0) const { u8 J2DPictureEx::getTextureCount() const { if (mMaterial == NULL) { - return NULL; + return 0; } return mMaterial->getTexGenBlock()->getTexGenNum(); diff --git a/src/JSystem/J3DGraphBase/J3DShape.cpp b/src/JSystem/J3DGraphBase/J3DShape.cpp index 485d4bca4f..befdf34a90 100644 --- a/src/JSystem/J3DGraphBase/J3DShape.cpp +++ b/src/JSystem/J3DGraphBase/J3DShape.cpp @@ -227,7 +227,7 @@ void J3DShape::makeVtxArrayCmd() { if (array[i] != 0) GDSetArray((GXAttr)(i + GX_VA_POS), array[i], stride[i]); else - GDSetArrayRaw((GXAttr)(i + GX_VA_POS), NULL, stride[i]); + GDSetArrayRaw((GXAttr)(i + GX_VA_POS), 0, stride[i]); } } diff --git a/src/JSystem/JAudio2/JASSimpleWaveBank.cpp b/src/JSystem/JAudio2/JASSimpleWaveBank.cpp index 9bc0bbf31d..c599a0e857 100644 --- a/src/JSystem/JAudio2/JASSimpleWaveBank.cpp +++ b/src/JSystem/JAudio2/JASSimpleWaveBank.cpp @@ -42,7 +42,7 @@ JASWaveArc* JASSimpleWaveBank::getWaveArc(u32 no) { int JASSimpleWaveBank::TWaveHandle::getWavePtr() const { void* base = mHeap->getBase(); if (base == NULL) { - return NULL; + return 0; } return (intptr_t)base + mWaveInfo.field_0x08; } diff --git a/src/JSystem/JAudio2/JAUSectionHeap.cpp b/src/JSystem/JAudio2/JAUSectionHeap.cpp index 8a9bbf8277..eb1f211070 100644 --- a/src/JSystem/JAudio2/JAUSectionHeap.cpp +++ b/src/JSystem/JAudio2/JAUSectionHeap.cpp @@ -40,7 +40,7 @@ namespace { field_0x4 = stack_14.getNumFiles(); field_0x8 = new s32[field_0x4]; if (!field_0x8) { - field_0x4 = NULL; + field_0x4 = 0; return; } for (u32 i = 0; i < field_0x4; i++) { diff --git a/src/JSystem/JKernel/JKRAram.cpp b/src/JSystem/JKernel/JKRAram.cpp index a16a0ffb0b..bbc49ff7eb 100644 --- a/src/JSystem/JKernel/JKRAram.cpp +++ b/src/JSystem/JKernel/JKRAram.cpp @@ -69,7 +69,7 @@ JKRAram::JKRAram(u32 audio_buffer_size, u32 audio_graph_size, s32 priority) if (mAramMemorySize) { mAramMemoryPtr = ARAlloc(mAramMemorySize); } else { - mAramMemoryPtr = NULL; + mAramMemoryPtr = 0; } OS_REPORT("ARAM audio area %08x: %08x\n", mAudioMemoryPtr, mAudioMemorySize); diff --git a/src/JSystem/JKernel/JKRFileCache.cpp b/src/JSystem/JKernel/JKRFileCache.cpp index d0162d95e5..4579a9ee88 100644 --- a/src/JSystem/JKernel/JKRFileCache.cpp +++ b/src/JSystem/JKernel/JKRFileCache.cpp @@ -192,7 +192,7 @@ u32 JKRFileCache::readResource(void* dst, u32 dstLength, u32, const char* path) if (findFile(finalPath, path)) { return readResource(dst, dstLength, filePath); } - return NULL; + return 0; } void JKRFileCache::removeResourceAll(void) { diff --git a/src/JSystem/JKernel/JKRThread.cpp b/src/JSystem/JKernel/JKRThread.cpp index 918f1012fc..cb5055012a 100644 --- a/src/JSystem/JKernel/JKRThread.cpp +++ b/src/JSystem/JKernel/JKRThread.cpp @@ -73,7 +73,7 @@ void JKRThread::setCommon_mesgQueue(JKRHeap* heap, int message_count) { sThreadList.append(&mThreadListLink); mCurrentHeap = NULL; - mCurrentHeapError = NULL; + mCurrentHeapError = 0; } void JKRThread::setCommon_heapSpecified(JKRHeap* heap, u32 stack_size, int param_3) { diff --git a/src/JSystem/JParticle/JPAEmitter.cpp b/src/JSystem/JParticle/JPAEmitter.cpp index fb03d52640..5e7ccbc6dd 100644 --- a/src/JSystem/JParticle/JPAEmitter.cpp +++ b/src/JSystem/JParticle/JPAEmitter.cpp @@ -39,7 +39,7 @@ void JPABaseEmitter::init(JPAEmitterManager* param_0, JPAResource* param_1) { mGlobalPrmClr.r = mGlobalPrmClr.g = mGlobalPrmClr.b = mGlobalPrmClr.a = mGlobalEnvClr.r = mGlobalEnvClr.g = mGlobalEnvClr.b = mGlobalEnvClr.a = 0xff; param_1->getBsp()->getPrmClr(&mPrmClr); param_1->getBsp()->getEnvClr(&mEnvClr); - mpUserWork = NULL; + mpUserWork = 0; mScaleOut = 1.0f; mEmitCount = 0.0f; initStatus(0x30); diff --git a/src/d/actor/d_a_alink.cpp b/src/d/actor/d_a_alink.cpp index a2b5a11f6d..aed6026b10 100644 --- a/src/d/actor/d_a_alink.cpp +++ b/src/d/actor/d_a_alink.cpp @@ -12223,7 +12223,7 @@ BOOL daAlink_c::checkGroundSpecialMode() { return procScreamWaitInit(); } - return NULL; + return 0; } int daAlink_c::commonCheckNextAction(int param_0) { diff --git a/src/d/actor/d_a_alink_horse.inc b/src/d/actor/d_a_alink_horse.inc index a637ef42cb..e9ce673c98 100644 --- a/src/d/actor/d_a_alink_horse.inc +++ b/src/d/actor/d_a_alink_horse.inc @@ -339,7 +339,7 @@ void daAlink_c::setHorseStirrup() { if (field_0x2fab & 1) { mDoMtx_stack_c::copy(mpLinkModel->getAnmMtx(field_0x30bc)); mDoMtx_stack_c::transM(-2.0f, -11.0f, 1.5f); - mDoMtx_stack_c::ZXYrotM(NULL, -0x8000, 0x4000); + mDoMtx_stack_c::ZXYrotM(0, -0x8000, 0x4000); mDoMtx_copy(mDoMtx_stack_c::get(), horse->getLeftStirrupMtx()); } diff --git a/src/d/actor/d_a_alink_swim.inc b/src/d/actor/d_a_alink_swim.inc index 857a3693f6..aa7cd98350 100644 --- a/src/d/actor/d_a_alink_swim.inc +++ b/src/d/actor/d_a_alink_swim.inc @@ -346,7 +346,7 @@ int daAlink_c::checkNextActionSwim() { int daAlink_c::checkSwimAction(int param_0) { f32 var_f31; if (checkWolf()) { - if (getMoveBGActorName(mLinkAcch.m_gnd, NULL) == PROC_Obj_ITA) { + if (getMoveBGActorName(mLinkAcch.m_gnd, 0) == PROC_Obj_ITA) { var_f31 = 200.0f; } else { var_f31 = mpHIO->mWolf.mWlSwim.m.mStartHeight; diff --git a/src/d/actor/d_a_b_dr.cpp b/src/d/actor/d_a_b_dr.cpp index 609ba1e94d..0a9d6c7a9a 100644 --- a/src/d/actor/d_a_b_dr.cpp +++ b/src/d/actor/d_a_b_dr.cpp @@ -4083,7 +4083,7 @@ int daB_DR_c::create() { gravity = -3.0f; mSound.init(¤t.pos, &eyePos, 3, 1); - mColliderStts.Init(0x19, NULL, this); + mColliderStts.Init(0x19, 0, this); fopAcM_OnStatus(this, 0x4000); diff --git a/src/d/actor/d_a_door_shutter.cpp b/src/d/actor/d_a_door_shutter.cpp index 60bde824e6..66441fb197 100644 --- a/src/d/actor/d_a_door_shutter.cpp +++ b/src/d/actor/d_a_door_shutter.cpp @@ -306,7 +306,7 @@ int daDoor20_c::checkOpenMsgDoor(int* param_1) { *param_1 = 0; return 1; } - field_0x624.init(NULL, msgNo, NULL, NULL); + field_0x624.init(NULL, msgNo, 0, NULL); int rv = field_0x624.checkOpenDoor(this, param_1); dMsgObject_endFlowGroup(); return rv; diff --git a/src/d/actor/d_a_e_yh.cpp b/src/d/actor/d_a_e_yh.cpp index 871708c0f9..369b19b216 100644 --- a/src/d/actor/d_a_e_yh.cpp +++ b/src/d/actor/d_a_e_yh.cpp @@ -2008,7 +2008,7 @@ static int daE_YH_Execute(e_yh_class* i_this) { J3DModel* model = i_this->mpMorf->getModel(); model->setBaseTRMtx(mDoMtx_stack_c::get()); - i_this->mpMorf->play(NULL, dComIfGp_getReverb(fopAcM_GetRoomNo(a_this))); + i_this->mpMorf->play(0, dComIfGp_getReverb(fopAcM_GetRoomNo(a_this))); i_this->mBrk->play(); i_this->mpMorf->modelCalc(); diff --git a/src/d/actor/d_a_e_ym.cpp b/src/d/actor/d_a_e_ym.cpp index 1bcc56551d..38e63b4fa4 100644 --- a/src/d/actor/d_a_e_ym.cpp +++ b/src/d/actor/d_a_e_ym.cpp @@ -3147,7 +3147,7 @@ void daE_YM_c::action() { cXyz unused_vec(field_0x68c, field_0x68c, field_0x68c); cXyz my_pos = current.pos; setMidnaBindEffect(this, &mSound, &my_pos, &scale); - mpMorf->play(NULL, dComIfGp_getReverb(fopAcM_GetRoomNo(this))); + mpMorf->play(0, dComIfGp_getReverb(fopAcM_GetRoomNo(this))); mpBrk->play(); } diff --git a/src/d/actor/d_a_kago.cpp b/src/d/actor/d_a_kago.cpp index 6eb85ad6f7..c2d2d8b489 100644 --- a/src/d/actor/d_a_kago.cpp +++ b/src/d/actor/d_a_kago.cpp @@ -511,7 +511,7 @@ void daKago_c::demo_skip(int param_0) { switch (param_0) { case 0: field_0x748 = 2; - field_0x74c = NULL; + field_0x74c = 0; break; case 1: field_0x728 = 0; @@ -525,7 +525,7 @@ void daKago_c::demo_skip(int param_0) { /* dSv_event_flag_c::M_051 - Main Event - Shadow Kargorok (?) (Large) event complete (Horse grass appears in various places) */ dComIfGs_onEventBit(dSv_event_flag_c::saveBitLabels[84]); field_0x748 = 7; - field_0x74c = NULL; + field_0x74c = 0; break; case 4: setSceneChange(0); diff --git a/src/d/actor/d_a_npc_blue_ns.cpp b/src/d/actor/d_a_npc_blue_ns.cpp index 7492657fd4..220c64af3f 100644 --- a/src/d/actor/d_a_npc_blue_ns.cpp +++ b/src/d/actor/d_a_npc_blue_ns.cpp @@ -736,14 +736,14 @@ void daNpcBlueNS_c::playMotion() { int daNpcBlueNS_c::setAction(int (daNpcBlueNS_c::*i_action)(int)) { field_0xdc0 = 3; if (mAction != NULL) { - (this->*mAction)(NULL); + (this->*mAction)(0); } field_0xdc0 = 0; mAction = i_action; if (mAction != NULL) { - (this->*mAction)(NULL); + (this->*mAction)(0); } return 1; diff --git a/src/d/actor/d_a_npc_fairy.cpp b/src/d/actor/d_a_npc_fairy.cpp index 850c5baa7b..f579985d22 100644 --- a/src/d/actor/d_a_npc_fairy.cpp +++ b/src/d/actor/d_a_npc_fairy.cpp @@ -883,7 +883,7 @@ void daNpc_Fairy_c::srchActors() { BOOL daNpc_Fairy_c::evtTalk() { if (chkAction(&daNpc_Fairy_c::talk)) { - (this->*mAction)(NULL); + (this->*mAction)(0); } else { mPreItemNo = 0; @@ -952,7 +952,7 @@ void daNpc_Fairy_c::action() { } if (mAction) { - (this->*mAction)(NULL); + (this->*mAction)(0); } } @@ -1124,7 +1124,7 @@ BOOL daNpc_Fairy_c::setAction(actionFunc action, int param_2) { mMode = 0xFFFF; if (mAction) { - (this->*mAction)(NULL); + (this->*mAction)(0); } mMode = 0; diff --git a/src/d/actor/d_a_npc_grm.cpp b/src/d/actor/d_a_npc_grm.cpp index 819b40db8c..c530f869f9 100644 --- a/src/d/actor/d_a_npc_grm.cpp +++ b/src/d/actor/d_a_npc_grm.cpp @@ -448,8 +448,8 @@ BOOL daNpc_grM_c::evtProc() { int face_motion, motion; if (ctrlMsgAnm(&face_motion, &motion, this, field_0xe2d)) { if (field_0xe26) { - mFaceMotionSeqMngr.setNo(face_motion, -1.0f, TRUE, NULL); - mMotionSeqMngr.setNo(motion, -1.0f, TRUE, NULL); + mFaceMotionSeqMngr.setNo(face_motion, -1.0f, TRUE, 0); + mMotionSeqMngr.setNo(motion, -1.0f, TRUE, 0); } } else if (tmp != 0 && field_0xe26) { setAfterTalkMotion(); diff --git a/src/d/actor/d_a_npc_henna.cpp b/src/d/actor/d_a_npc_henna.cpp index 53f945e50b..0eef1094f7 100644 --- a/src/d/actor/d_a_npc_henna.cpp +++ b/src/d/actor/d_a_npc_henna.cpp @@ -277,7 +277,7 @@ static void message_shop(npc_henna_class* i_this) { i_this->field_0x750 = 1; } if (i_this->field_0x750 != 0) { - fopAcM_OffStatus(actor, NULL); + fopAcM_OffStatus(actor, 0); cLib_offBit(actor->attention_info.flags, fopAc_AttnFlag_SPEAK_e | fopAc_AttnFlag_TALK_e); } else { fopAcM_OnStatus(actor, 0); diff --git a/src/d/actor/d_a_npc_kasi_hana.cpp b/src/d/actor/d_a_npc_kasi_hana.cpp index 2d592ec85e..e9544a9a52 100644 --- a/src/d/actor/d_a_npc_kasi_hana.cpp +++ b/src/d/actor/d_a_npc_kasi_hana.cpp @@ -853,7 +853,7 @@ BOOL daNpcKasiHana_c::main() { } if (mAction) { - (this->*mAction)(NULL); + (this->*mAction)(0); } mKasiMng.sendInfo(); @@ -1072,14 +1072,14 @@ BOOL daNpcKasiHana_c::setAction(actionFunc action) { mMode = -1; if (mAction) { - (this->*mAction)(NULL); + (this->*mAction)(0); } mMode = 0; mAction = action; if (mAction) { - (this->*mAction)(NULL); + (this->*mAction)(0); } return TRUE; diff --git a/src/d/actor/d_a_npc_kasi_kyu.cpp b/src/d/actor/d_a_npc_kasi_kyu.cpp index 27c4a0b6ba..8f3f9464cf 100644 --- a/src/d/actor/d_a_npc_kasi_kyu.cpp +++ b/src/d/actor/d_a_npc_kasi_kyu.cpp @@ -400,7 +400,7 @@ BOOL daNpcKasiKyu_c::main() { } if (mAction) { - (this->*mAction)(NULL); + (this->*mAction)(0); } playMotion(); @@ -621,14 +621,14 @@ BOOL daNpcKasiKyu_c::setAction(actionFunc action) { mMode = -1; if (mAction) { - (this->*mAction)(NULL); + (this->*mAction)(0); } mMode = 0; mAction = action; if (mAction) { - (this->*mAction)(NULL); + (this->*mAction)(0); } return TRUE; diff --git a/src/d/actor/d_a_npc_kasi_mich.cpp b/src/d/actor/d_a_npc_kasi_mich.cpp index 4b3d7ca068..86e0632047 100644 --- a/src/d/actor/d_a_npc_kasi_mich.cpp +++ b/src/d/actor/d_a_npc_kasi_mich.cpp @@ -400,7 +400,7 @@ BOOL daNpcKasiMich_c::main() { } if (mAction) { - (this->*mAction)(NULL); + (this->*mAction)(0); } playMotion(); @@ -621,14 +621,14 @@ BOOL daNpcKasiMich_c::setAction(actionFunc action) { mMode = -1; if (mAction) { - (this->*mAction)(NULL); + (this->*mAction)(0); } mMode = 0; mAction = action; if (mAction) { - (this->*mAction)(NULL); + (this->*mAction)(0); } return TRUE; diff --git a/src/d/actor/d_a_npc_maro.cpp b/src/d/actor/d_a_npc_maro.cpp index 7682afd2b1..1bcf6892d8 100644 --- a/src/d/actor/d_a_npc_maro.cpp +++ b/src/d/actor/d_a_npc_maro.cpp @@ -386,7 +386,7 @@ int daNpc_Maro_c::Execute() { setSellItemMax(getMaxNumItem()); field_0xf60 = -1; setMasterType(2); - mShopCamAction.setCamDataIdx(NULL); + mShopCamAction.setCamDataIdx(0); mShopCamAction.setCamAction(NULL); field_0x1131 = 1; } diff --git a/src/d/actor/d_a_npc_shad.cpp b/src/d/actor/d_a_npc_shad.cpp index fcd4d7abc0..1665797d58 100644 --- a/src/d/actor/d_a_npc_shad.cpp +++ b/src/d/actor/d_a_npc_shad.cpp @@ -1485,7 +1485,7 @@ bool daNpcShad_c::talk(void* param_1) { if (strcmp(dComIfGp_getStartStageName(), "R_SP116") == 0 || mCurAngle.y == fopAcM_searchPlayerAngleY(this)) { if (talkProc(NULL, TRUE, NULL)) { mActorMngr[0].entry(daPy_getPlayerActorClass()); - itemNo = NULL; + itemNo = 0; eventID = mFlow.getEventId(&itemNo); OS_REPORT("会話終了時 イベントID=%d アイテムNo=%d\n", eventID, itemNo); // At the end of the conversation, Event ID=%d Item No=%d diff --git a/src/d/actor/d_a_npc_ykw.cpp b/src/d/actor/d_a_npc_ykw.cpp index 7aac0c1340..9c2c816d37 100644 --- a/src/d/actor/d_a_npc_ykw.cpp +++ b/src/d/actor/d_a_npc_ykw.cpp @@ -1822,7 +1822,7 @@ BOOL daNpc_ykW_c::cutLv5DungeonClear(int param_0) { itemPos.y += 50.0f; unkActor1 = fopAcM_fastCreateItem(&itemPos, 0, fopAcM_GetRoomNo(this), &unkSxyz, - &unkXyz1, &unkFloat2, &unkFloat3, -1, NULL, NULL); + &unkXyz1, &unkFloat2, &unkFloat3, -1, 0, NULL); if (unkActor1 != NULL) { mDoAud_seStart(Z2SE_OBJ_YO_HEART_S, &itemPos, 0, 0); fopAcM_OnStatus(unkActor1, fopAcM_STATUS_UNK_0x4000); diff --git a/src/d/actor/d_a_obj_batta.cpp b/src/d/actor/d_a_obj_batta.cpp index 23ce104482..eb187f1ac0 100644 --- a/src/d/actor/d_a_obj_batta.cpp +++ b/src/d/actor/d_a_obj_batta.cpp @@ -509,7 +509,7 @@ int daObjBATTA_c::execute() { action(); mBrk->play(); mBtk->play(); - mpMorf->play(NULL, dComIfGp_getReverb(fopAcM_GetRoomNo(this))); + mpMorf->play(0, dComIfGp_getReverb(fopAcM_GetRoomNo(this))); mtx_set(); if (field_0x9f0 == 0) { mSph.SetC(current.pos); diff --git a/src/d/actor/d_a_obj_bed.cpp b/src/d/actor/d_a_obj_bed.cpp index 37de863ca6..06c2eb71da 100644 --- a/src/d/actor/d_a_obj_bed.cpp +++ b/src/d/actor/d_a_obj_bed.cpp @@ -30,7 +30,7 @@ void daObj_Bed_HIO_c::genMessage(JORMContext* ctx) { } #endif -daObj_Bed_HIOParam const daObj_Bed_Param_c::m = {NULL, -3.0f, 1.0f, 600.0f}; +daObj_Bed_HIOParam const daObj_Bed_Param_c::m = {0, -3.0f, 1.0f, 600.0f}; daObj_Bed_c::~daObj_Bed_c() { if (mpCollider != NULL) { diff --git a/src/d/actor/d_a_obj_bky_rock.cpp b/src/d/actor/d_a_obj_bky_rock.cpp index d2918eeaeb..08fc622c8c 100644 --- a/src/d/actor/d_a_obj_bky_rock.cpp +++ b/src/d/actor/d_a_obj_bky_rock.cpp @@ -68,7 +68,7 @@ int daBkyRock_c::draw() { mModels[mMode], &tevStr); if (field_0x57a) { - dMdl_c* dMdl = dMdl_mng_c::entry(mModels[2]->getModelData(), NULL, current.roomNo); + dMdl_c* dMdl = dMdl_mng_c::entry(mModels[2]->getModelData(), 0, current.roomNo); if (dMdl != NULL) { _pieceData* piece = mPieces; for (int i = 0; i < 20; i++, piece++) { diff --git a/src/d/actor/d_a_obj_digholl.cpp b/src/d/actor/d_a_obj_digholl.cpp index 0e9aca1f7c..d9fa7f3528 100644 --- a/src/d/actor/d_a_obj_digholl.cpp +++ b/src/d/actor/d_a_obj_digholl.cpp @@ -74,9 +74,9 @@ int daObjDigholl_c::execute() { } if (player->current.pos.abs(current.pos) < 1000.0f) { - dComIfGp_particle_setSimple(0x70f, ¤t.pos, 0xff, g_whiteColor, g_whiteColor, NULL, + dComIfGp_particle_setSimple(0x70f, ¤t.pos, 0xff, g_whiteColor, g_whiteColor, 0, 0.0f); - dComIfGp_particle_setSimple(0x73d, ¤t.pos, 0xff, g_whiteColor, g_whiteColor, NULL, + dComIfGp_particle_setSimple(0x73d, ¤t.pos, 0xff, g_whiteColor, g_whiteColor, 0, 0.0f); } diff --git a/src/d/actor/d_a_obj_lv3Water.cpp b/src/d/actor/d_a_obj_lv3Water.cpp index 704f35dcf5..e9b17c3ad6 100644 --- a/src/d/actor/d_a_obj_lv3Water.cpp +++ b/src/d/actor/d_a_obj_lv3Water.cpp @@ -31,7 +31,7 @@ public: }; daLv3Water_HIO_c::daLv3Water_HIO_c() { - mLevelControlWaitFrames = NULL; + mLevelControlWaitFrames = 0; } #if DEBUG diff --git a/src/d/actor/d_a_obj_lv6ChangeGate.cpp b/src/d/actor/d_a_obj_lv6ChangeGate.cpp index a28b3dca48..da9f2efe23 100644 --- a/src/d/actor/d_a_obj_lv6ChangeGate.cpp +++ b/src/d/actor/d_a_obj_lv6ChangeGate.cpp @@ -127,7 +127,7 @@ int daLv6ChangeGate_c::Execute(Mtx** param_0) { for (int i = 0; i < 12; i++) { cXyz spC(cyl_x_offset + mMoveTransX, 0.0f, 0.0f); - mDoMtx_stack_c::ZXYrotS(NULL, shape_angle.y, shape_angle.z); + mDoMtx_stack_c::ZXYrotS(0, shape_angle.y, shape_angle.z); mDoMtx_stack_c::multVec(&spC, &spC); spC += current.pos; @@ -251,7 +251,7 @@ void daLv6ChangeGate_c::init_modeBreak() { void daLv6ChangeGate_c::modeBreak() { cXyz effpos(mMoveTransX, 0.0f, 0.0f); - mDoMtx_stack_c::ZXYrotS(NULL, shape_angle.y, shape_angle.z); + mDoMtx_stack_c::ZXYrotS(0, shape_angle.y, shape_angle.z); mDoMtx_stack_c::multVec(&effpos, &effpos); effpos += current.pos; diff --git a/src/d/actor/d_a_obj_prop.cpp b/src/d/actor/d_a_obj_prop.cpp index fc2b773538..273e03b5f1 100644 --- a/src/d/actor/d_a_obj_prop.cpp +++ b/src/d/actor/d_a_obj_prop.cpp @@ -53,7 +53,7 @@ int daObjProp_c::Delete() { } int daObjProp_c::draw() { - g_env_light.settingTevStruct(NULL, ¤t.pos, &tevStr); + g_env_light.settingTevStruct(0, ¤t.pos, &tevStr); g_env_light.setLightTevColorType_MAJI(mpModel, &tevStr); mDoExt_modelUpdate(mpModel); return 1; diff --git a/src/d/actor/d_a_obj_rope_bridge.cpp b/src/d/actor/d_a_obj_rope_bridge.cpp index 9c0874ccab..402ca74b46 100644 --- a/src/d/actor/d_a_obj_rope_bridge.cpp +++ b/src/d/actor/d_a_obj_rope_bridge.cpp @@ -16,7 +16,7 @@ static char* l_ropeArcName = "L_Ropest"; void daObjRBridge_c::initBaseMtx() { mDoMtx_stack_c::transS(current.pos); - mDoMtx_stack_c::ZXYrotM(NULL, current.angle.y, 0); + mDoMtx_stack_c::ZXYrotM(0, current.angle.y, 0); MTXCopy(mDoMtx_stack_c::get(), mMtx); mpBrgModel->setBaseScale(scale); diff --git a/src/d/actor/d_a_obj_sekizoa.cpp b/src/d/actor/d_a_obj_sekizoa.cpp index 1e2ff2ccbd..7165ff0929 100644 --- a/src/d/actor/d_a_obj_sekizoa.cpp +++ b/src/d/actor/d_a_obj_sekizoa.cpp @@ -736,7 +736,7 @@ void daObj_Sekizoa_c::setAttnPos() { mpMorf[1]->modelCalc(); } if (mpMcaMorf != NULL) { - ((mDoExt_McaMorfSO*)mpMcaMorf)->play(NULL, 0); + ((mDoExt_McaMorfSO*)mpMcaMorf)->play(0, 0); if (mType == TYPE_1 || mType == TYPE_3 || mType == TYPE_5) { mDoMtx_stack_c::copy(mpMorf[0]->getModel()->getAnmMtx(7)); } else { diff --git a/src/d/actor/d_a_obj_stone.cpp b/src/d/actor/d_a_obj_stone.cpp index c5ddc061b9..b8b1677513 100644 --- a/src/d/actor/d_a_obj_stone.cpp +++ b/src/d/actor/d_a_obj_stone.cpp @@ -807,7 +807,7 @@ void daObjStone_c::init_modeBreak() { JPABaseEmitter* emitter = dComIfGp_particle_set( 0x15c, ¤t.pos, 0, &acStack_40, 0xff, &dPa_modelEcallBack::getEcallback(), fopAcM_GetRoomNo(this), 0, 0, 0); dPa_modelEcallBack::setModel(emitter, stone_bmd, tevStr, - 3, 0, NULL, 0); + 3, 0, 0, 0); for (int i = 0; i < 3; i = i + 1) { dComIfGp_particle_set( l_eff_id[i], diff --git a/src/d/actor/d_a_obj_vground.cpp b/src/d/actor/d_a_obj_vground.cpp index 47dae42331..3af6e0c5e7 100644 --- a/src/d/actor/d_a_obj_vground.cpp +++ b/src/d/actor/d_a_obj_vground.cpp @@ -47,7 +47,7 @@ int daObjVGnd_c::CreateHeap() { J3DAnmTextureSRTKey* pbtk = (J3DAnmTextureSRTKey*)dComIfG_getObjectRes(l_arcName, 0xb); JUT_ASSERT(198, pbtk != NULL); mpBtk = new mDoExt_btkAnm(); - if ((!mpBtk) || (!mpBtk->init(modelData, pbtk, 1, NULL, 1.0f, NULL, -1))) { + if ((!mpBtk) || (!mpBtk->init(modelData, pbtk, 1, 0, 1.0f, 0, -1))) { return 0; } } @@ -56,7 +56,7 @@ int daObjVGnd_c::CreateHeap() { J3DAnmTevRegKey* pbrk = (J3DAnmTevRegKey*)dComIfG_getObjectRes(l_arcName, 0x8); JUT_ASSERT(212, pbrk != NULL); mpBrk = new mDoExt_brkAnm(); - if ((!mpBrk) || (!mpBrk->init(modelData, pbrk, 1, NULL, 1.0f, NULL, -1))) { + if ((!mpBrk) || (!mpBrk->init(modelData, pbrk, 1, 0, 1.0f, 0, -1))) { return 0; } } diff --git a/src/d/actor/d_a_shop_item.cpp b/src/d/actor/d_a_shop_item.cpp index 136d429b9a..09ef16cb70 100644 --- a/src/d/actor/d_a_shop_item.cpp +++ b/src/d/actor/d_a_shop_item.cpp @@ -128,7 +128,7 @@ void daShopItem_c::CreateInit() { home.pos = current.pos; set_mtx(); - mpModel->setUserArea(NULL); + mpModel->setUserArea(0); } void daShopItem_c::set_mtx() { diff --git a/src/d/actor/d_a_tag_allmato.cpp b/src/d/actor/d_a_tag_allmato.cpp index b1a4549e2c..2a2c94acfb 100644 --- a/src/d/actor/d_a_tag_allmato.cpp +++ b/src/d/actor/d_a_tag_allmato.cpp @@ -517,7 +517,7 @@ int daTag_AllMato_c::checkCrsMato2() { } fopAc_ac_c* sp18 = NULL; - int sp14 = NULL; + int sp14 = 0; for (int i = 0; i < 499; i++) { for (int j = 0; j < mBouMatoActorNum; j++) { diff --git a/src/d/d_bg_w_kcol.cpp b/src/d/d_bg_w_kcol.cpp index 834669d042..e7b5c76ebd 100644 --- a/src/d/d_bg_w_kcol.cpp +++ b/src/d/d_bg_w_kcol.cpp @@ -689,9 +689,9 @@ void dBgWKCol::ShdwDraw(cBgS_ShdwDraw* param_0) { do { stepY_sp78 = 1000000; - best1_sp70 = NULL; - best2_sp6C = NULL; - best3_sp68 = NULL; + best1_sp70 = 0; + best2_sp6C = 0; + best3_sp68 = 0; int x_sp44 = minX_spA0; do { diff --git a/src/d/d_cc_d.cpp b/src/d/d_cc_d.cpp index cf09711b3e..3c1acd7d5a 100644 --- a/src/d/d_cc_d.cpp +++ b/src/d/d_cc_d.cpp @@ -255,7 +255,7 @@ dCcD_GObjInf* dCcD_GObjInf::GetTgHitGObj() { u8 dCcD_GObjInf::GetTgHitObjSe() { dCcD_GObjInf* objInf = GetTgHitGObj(); if (objInf == NULL) { - return NULL; + return 0; } else { return objInf->GetAtSe(); } diff --git a/src/d/d_event_manager.cpp b/src/d/d_event_manager.cpp index 8b2291b124..84af0a5d51 100644 --- a/src/d/d_event_manager.cpp +++ b/src/d/d_event_manager.cpp @@ -1245,7 +1245,7 @@ void* dEvent_manager_c::getMySubstanceP(int staffId, const char* dataname, int d int dEvent_manager_c::getMySubstanceNum(int staffId, const char* dataname) { dEvDtData_c* data = getMyDataP(staffId, dataname, FALSE); if (data == NULL) { - return NULL; + return 0; } else { return data->getNumber(); } diff --git a/src/d/d_menu_dmap.cpp b/src/d/d_menu_dmap.cpp index f50c0f3c64..db7404534e 100644 --- a/src/d/d_menu_dmap.cpp +++ b/src/d/d_menu_dmap.cpp @@ -1728,7 +1728,7 @@ void dMenu_Dmap_c::_create() { screenInit(); - mpDrawBg->getMapPane()->changeTexture(mMapCtrl->getResTIMGPointer(0), NULL); + mpDrawBg->getMapPane()->changeTexture(mMapCtrl->getResTIMGPointer(0), 0); if (mpDrawBg->getMapPane()->append(mMapCtrl->getResTIMGPointer(1), 1.0f)) { mpDrawBg->getMapPane()->setBlendRatio(1.0f, 0.0f); diff --git a/src/d/d_menu_letter.cpp b/src/d/d_menu_letter.cpp index a9f27feb71..0ac02bdfac 100644 --- a/src/d/d_menu_letter.cpp +++ b/src/d/d_menu_letter.cpp @@ -492,7 +492,7 @@ void dMenu_Letter_c::read_open_init() { } J2DTextBox* text2 = (J2DTextBox*)field_0x2ec[i]->getPanePtr(); mpString->getStringPage(dMenu_Letter::getLetterText(idx), field_0x3e3 - 1, LINE_MAX, text2, text1, - NULL, NULL, NULL); + NULL, NULL, 0); } field_0x3e2 = mpString->getPageMax(LINE_MAX); if (field_0x3e2 > 1) { @@ -642,7 +642,7 @@ void dMenu_Letter_c::read_next_fadein_init() { text1 = (J2DTextBox*)field_0x2f4[i]->getPanePtr(); } J2DTextBox* text2 = (J2DTextBox*)field_0x2ec[i]->getPanePtr(); - mpString->getStringPage(dMenu_Letter::getLetterText(idx), field_0x3e3 - 1, LINE_MAX, text2, text1, NULL, NULL, NULL); + mpString->getStringPage(dMenu_Letter::getLetterText(idx), field_0x3e3 - 1, LINE_MAX, text2, text1, NULL, NULL, 0); } char acStack_30[10]; sprintf(acStack_30, "%d/%d", field_0x3e3, field_0x3e2); diff --git a/src/d/d_meter2_draw.cpp b/src/d/d_meter2_draw.cpp index 5d945fa5fc..302ef5e06a 100644 --- a/src/d/d_meter2_draw.cpp +++ b/src/d/d_meter2_draw.cpp @@ -1173,7 +1173,7 @@ void dMeter2Draw_c::initButton() { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - field_0x524[i][j] = NULL; + field_0x524[i][j] = 0; } } diff --git a/src/d/d_msg_scrn_staff.cpp b/src/d/d_msg_scrn_staff.cpp index d0cd861250..1f92124146 100644 --- a/src/d/d_msg_scrn_staff.cpp +++ b/src/d/d_msg_scrn_staff.cpp @@ -30,7 +30,7 @@ dMsgScrnStaff_c::dMsgScrnStaff_c(u8 unused) { mpScreen->search(MULTI_CHAR('right_n'))->hide(); for (int i = 0; i < 6; i++) { - mpTm_c[i] = new CPaneMgr(mpScreen, t_tag[i], NULL, NULL); + mpTm_c[i] = new CPaneMgr(mpScreen, t_tag[i], 0, NULL); ((J2DTextBox*)mpTm_c[i]->getPanePtr())->setFont(mDoExt_getMesgFont()); ((J2DTextBox*)mpTm_c[i]->getPanePtr())->setString(0x200, ""); } diff --git a/src/d/d_s_logo.cpp b/src/d/d_s_logo.cpp index 0504084f32..a7821acfe4 100644 --- a/src/d/d_s_logo.cpp +++ b/src/d/d_s_logo.cpp @@ -974,5 +974,5 @@ scene_process_profile_definition g_profile_LOGO_SCENE = { 0, &g_fopScn_Method.base, &l_dScnLogo_Method, - NULL, + 0, }; diff --git a/src/d/d_s_name.cpp b/src/d/d_s_name.cpp index a59d7d2d06..4bdbfd21ac 100644 --- a/src/d/d_s_name.cpp +++ b/src/d/d_s_name.cpp @@ -339,7 +339,7 @@ scene_process_profile_definition g_profile_NAME_SCENE = { 0, &g_fopScn_Method.base, &l_dScnName_Method, - NULL, + 0, }; scene_process_profile_definition g_profile_NAMEEX_SCENE = { @@ -353,5 +353,5 @@ scene_process_profile_definition g_profile_NAMEEX_SCENE = { 0, &g_fopScn_Method.base, &l_dScnName_Method, - NULL, + 0, }; diff --git a/src/d/d_stage.cpp b/src/d/d_stage.cpp index 22e7b00c64..4fdbd71a44 100644 --- a/src/d/d_stage.cpp +++ b/src/d/d_stage.cpp @@ -2456,10 +2456,10 @@ static int dStage_elstInfoInit(dStage_dt_c* i_stage, void* i_data, int param_2, } static void dKankyo_create() { - fopKyM_fastCreate(PROC_KANKYO, NULL, NULL, NULL, NULL); - fopKyM_fastCreate(PROC_KYEFF, NULL, NULL, NULL, NULL); - fopKyM_fastCreate(PROC_KYEFF2, NULL, NULL, NULL, NULL); - fopKyM_fastCreate(PROC_ENVSE, NULL, NULL, NULL, NULL); + fopKyM_fastCreate(PROC_KANKYO, 0, NULL, NULL, NULL); + fopKyM_fastCreate(PROC_KYEFF, 0, NULL, NULL, NULL); + fopKyM_fastCreate(PROC_KYEFF2, 0, NULL, NULL, NULL); + fopKyM_fastCreate(PROC_ENVSE, 0, NULL, NULL, NULL); } static void layerMemoryInfoLoader(void* i_data, dStage_dt_c* i_stage, int param_2) { @@ -2710,7 +2710,7 @@ void dStage_Create() { JUT_ASSERT(4517, status); } - *dStage_roomControl_c::getDemoArcName() = NULL; + *dStage_roomControl_c::getDemoArcName() = 0; dKankyo_create(); if (dComIfG_getStageRes("vrbox_sora.bmd")) { From 3ebf3c5a7ade39fdd3e9a3597ccc24b2721936c4 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 28 Feb 2026 17:16:20 -0700 Subject: [PATCH 3/9] Update CMake warning flags for Linux --- CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f9284539a..6d0b388991 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,11 +15,13 @@ add_subdirectory(extern/aurora EXCLUDE_FROM_ALL) option(DUSK_BUILD_WARNINGS "If off, compiler warnings will be suppressed") if (CMAKE_SYSTEM_NAME STREQUAL Linux) - # Multi-character constants ('ABCD') are implementation-defined but all compilers - # (CW, GCC, Clang, MSVC) encode them identically in big-endian order. - # For >4-char literals (which GCC/Clang truncate to int), use the MULTI_CHAR() macro. - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar -Wno-unused-variable -Wno-unused-parameter") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-multichar") + # -Wno-multichar: Multi-character constants ('ABCD') are implementation-defined but all compilers + # (CW, GCC, Clang, MSVC) encode them identically in big-endian order. + # For >4-char literals (which GCC/Clang truncate to int), use the MULTI_CHAR() macro. + # -Wwrite-strings: Game code relies on implicit const char* -> char* conversions + # -Wdeprecated-declarations: JSystem uses std::iterator, deprecated in C++17 + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar -Wno-write-strings") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-multichar -Wno-write-strings -Wno-trigraphs -Wno-deprecated-declarations") set(CMAKE_INSTALL_RPATH "$ORIGIN") set(CMAKE_BUILD_RPATH "$ORIGIN") elseif (APPLE) From f233787c0a9099a84fde4c8b883b52d8014d781c Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 28 Feb 2026 17:17:01 -0700 Subject: [PATCH 4/9] Include JUTPalette in J2DAnimation to avoid deleting forward decl --- include/JSystem/J2DGraph/J2DAnimation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/JSystem/J2DGraph/J2DAnimation.h b/include/JSystem/J2DGraph/J2DAnimation.h index 76d8d06171..64b2a37b76 100644 --- a/include/JSystem/J2DGraph/J2DAnimation.h +++ b/include/JSystem/J2DGraph/J2DAnimation.h @@ -3,11 +3,11 @@ #include "JSystem/JMath/JMath.h" #include "JSystem/J3DGraphAnimator/J3DAnimation.h" +#include "JSystem/JUtility/JUTPalette.h" typedef struct _GXColor GXColor; typedef struct _GXColorS10 GXColorS10; class J2DScreen; -class JUTPalette; struct ResTIMG; enum J2DAnmKind { From 989c6ac3dbf831e052b8ae8513d1fa0fa540a03f Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 28 Feb 2026 17:18:04 -0700 Subject: [PATCH 5/9] Various minor warning fixes --- include/JSystem/JAudio2/JAISeMgr.h | 4 ++-- include/JSystem/JHostIO/JORMContext.h | 2 +- include/JSystem/JSupport/JSupport.h | 2 +- include/JSystem/JUtility/JUTAssert.h | 6 +++--- include/dusk/math.h | 2 ++ include/f_op/f_op_actor.h | 2 +- include/f_op/f_op_actor_mng.h | 9 ++++++++- src/JSystem/J2DGraph/J2DMaterialFactory.cpp | 4 ++-- src/JSystem/JKernel/JKRAramArchive.cpp | 4 ++-- src/JSystem/JKernel/JKRAramStream.cpp | 2 +- src/JSystem/JUtility/JUTGraphFifo.cpp | 2 +- 11 files changed, 24 insertions(+), 15 deletions(-) diff --git a/include/JSystem/JAudio2/JAISeMgr.h b/include/JSystem/JAudio2/JAISeMgr.h index 50f81fb1b4..928d85525b 100644 --- a/include/JSystem/JAudio2/JAISeMgr.h +++ b/include/JSystem/JAudio2/JAISeMgr.h @@ -15,7 +15,7 @@ struct JASNonCopyable { JASNonCopyable() {} ~JASNonCopyable() {} - /* 0x0 */ int field_0x0; + /* 0x0 */ void* field_0x0; }; // Size: 0x4 /** @@ -56,7 +56,7 @@ public: mParams.init(); mMaxActiveSe = 0; mMaxInactiveSe = 0; - field_0x0 = 0; + field_0x0 = NULL; } virtual bool isUsingSeqData(const JAISeqDataRegion& seqDataRegion); diff --git a/include/JSystem/JHostIO/JORMContext.h b/include/JSystem/JHostIO/JORMContext.h index 99de2bac17..551c2410f2 100644 --- a/include/JSystem/JHostIO/JORMContext.h +++ b/include/JSystem/JHostIO/JORMContext.h @@ -249,7 +249,7 @@ public: */ DEFINE_GEN_SLIDER(u8, 0x100 | jhostio::EKind_8B) DEFINE_GEN_SLIDER(s16, jhostio::EKind_16B) - DEFINE_GEN_SLIDER(f32, JORPropertyEvent::EKind_FloatValue | jhostio::EKind_32B) + DEFINE_GEN_SLIDER(f32, (u32)JORPropertyEvent::EKind_FloatValue | (u32)jhostio::EKind_32B) DEFINE_GEN_SLIDER(s32, jhostio::EKind_32B) DEFINE_GEN_SLIDER_ID(f64, JORPropertyEvent::EKind_ValueID | JORPropertyEvent::EKind_FloatValue) diff --git a/include/JSystem/JSupport/JSupport.h b/include/JSystem/JSupport/JSupport.h index 5b6b26a20f..1940e6dff8 100644 --- a/include/JSystem/JSupport/JSupport.h +++ b/include/JSystem/JSupport/JSupport.h @@ -24,7 +24,7 @@ T* JSUConvertOffsetToPtr(const void* ptr, u32 offset) { T* JSUConvertOffsetToPtr(const void* ptr, const void* offset) { #endif T* ret; - if (offset == NULL) { + if (offset == 0) { ret = NULL; } else { ret = (T*)((intptr_t)ptr + (intptr_t)offset); diff --git a/include/JSystem/JUtility/JUTAssert.h b/include/JSystem/JUtility/JUTAssert.h index e10171f992..03306a8f8a 100644 --- a/include/JSystem/JUtility/JUTAssert.h +++ b/include/JSystem/JUtility/JUTAssert.h @@ -60,13 +60,13 @@ JUTAssertion::showAssert_f(JUTAssertion::getSDevice(), __FILE__, __LINE__, MSG, OSPanic(__FILE__, __LINE__, "Halt"); #define JUT_WARN_DEVICE(LINE, DEVICE, ...) \ - JUTAssertion::setWarningMessage_f(DEVICE, __FILE__, __LINE__, __VA_ARGS__); \ + JUTAssertion::setWarningMessage_f(DEVICE, const_cast(__FILE__), __LINE__, __VA_ARGS__); \ #define JUT_LOG(LINE, ...) \ - JUTAssertion::setLogMessage_f(JUTAssertion::getSDevice(), __FILE__, __LINE__, __VA_ARGS__) + JUTAssertion::setLogMessage_f(JUTAssertion::getSDevice(), const_cast(__FILE__), __LINE__, __VA_ARGS__) #define JUT_SET_CONFIRM(LINE, COND) \ - JUTAssertion::setConfirmMessage(JUTAssertion::getSDevice(), __FILE__, __LINE__, COND, #COND) + JUTAssertion::setConfirmMessage(JUTAssertion::getSDevice(), const_cast(__FILE__), __LINE__, COND, #COND) #endif #define JUT_WARN(LINE, ...) \ diff --git a/include/dusk/math.h b/include/dusk/math.h index 578ff80398..14c50db90a 100644 --- a/include/dusk/math.h +++ b/include/dusk/math.h @@ -3,7 +3,9 @@ #include +#ifndef M_PI #define M_PI 3.14159265358979323846f +#endif #define M_SQRT3 1.73205f #define DEG_TO_RAD(degrees) (degrees * (M_PI / 180.0f)) diff --git a/include/f_op/f_op_actor.h b/include/f_op/f_op_actor.h index d743c143f2..6aa5713e1b 100644 --- a/include/f_op/f_op_actor.h +++ b/include/f_op/f_op_actor.h @@ -199,7 +199,7 @@ public: BOOL chkCondition(u16 condition) { return (mCondition & condition) == condition; } void suspendProc(void* actor) { - if (field_0x10 != NULL) { + if (field_0x10 != 0) { field_0x14(actor); } } diff --git a/include/f_op/f_op_actor_mng.h b/include/f_op/f_op_actor_mng.h index 83f009a41e..b3a8873bcc 100644 --- a/include/f_op/f_op_actor_mng.h +++ b/include/f_op/f_op_actor_mng.h @@ -423,7 +423,14 @@ inline BOOL fopAcM_CULLSIZE_IS_BOX(int i_culltype) { i_culltype == fopAc_CULLBOX_CUSTOM_e; } -inline const cXyz& fopAcM_getCullSizeSphereCenter(const fopAc_ac_c* i_actor) { +inline +#ifdef __MWERKS__ +// In the original code, this constructs a temporary and returns a reference to it +const cXyz& +#else +const Vec& +#endif +fopAcM_getCullSizeSphereCenter(const fopAc_ac_c* i_actor) { return i_actor->cull.sphere.center; } diff --git a/src/JSystem/J2DGraph/J2DMaterialFactory.cpp b/src/JSystem/J2DGraph/J2DMaterialFactory.cpp index c8c9fc65f7..fdb604f01b 100644 --- a/src/JSystem/J2DGraph/J2DMaterialFactory.cpp +++ b/src/JSystem/J2DGraph/J2DMaterialFactory.cpp @@ -248,7 +248,7 @@ u16 J2DMaterialFactory::newTexNo(int param_0, int param_1) const { if (iVar2->field_0x38[param_1] != 0xffff) { return field_0x28[iVar2->field_0x38[param_1]]; } - return 0x1FFFF; + return 0xFFFF; } u16 J2DMaterialFactory::newFontNo(int param_0) const { @@ -256,7 +256,7 @@ u16 J2DMaterialFactory::newFontNo(int param_0) const { if (iVar2->field_0x48 != 0xffff) { return field_0x2c[iVar2->field_0x48]; } - return 0x1FFFF; + return 0xFFFF; } J2DTevOrder J2DMaterialFactory::newTevOrder(int param_0, int param_1) const { diff --git a/src/JSystem/JKernel/JKRAramArchive.cpp b/src/JSystem/JKernel/JKRAramArchive.cpp index f13f7fcbac..5ed1bc181c 100644 --- a/src/JSystem/JKernel/JKRAramArchive.cpp +++ b/src/JSystem/JKernel/JKRAramArchive.cpp @@ -208,7 +208,7 @@ void* JKRAramArchive::fetchResource(SDIFileEntry* pEntry, u32* pOutSize) { &outBuf); *pOutSize = size; - if (size == NULL) { + if (size == 0) { return NULL; } @@ -243,7 +243,7 @@ void* JKRAramArchive::fetchResource(void* buffer, u32 bufferSize, SDIFileEntry* } else { if (compression == COMPRESSION_YAZ0) { u32 expandSize = this->getExpandSize(pEntry); - if (expandSize != NULL) { + if (expandSize != 0) { size = expandSize; } } diff --git a/src/JSystem/JKernel/JKRAramStream.cpp b/src/JSystem/JKernel/JKRAramStream.cpp index 94b9ca91fc..76324f6f14 100644 --- a/src/JSystem/JKernel/JKRAramStream.cpp +++ b/src/JSystem/JKernel/JKRAramStream.cpp @@ -128,7 +128,7 @@ s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) { } } - OSSendMessage(&command->mMessageQueue, (OSMessage)writtenLength, OS_MESSAGE_NOBLOCK); + OSSendMessage(&command->mMessageQueue, (OSMessage)(uintptr_t)writtenLength, OS_MESSAGE_NOBLOCK); return writtenLength; } diff --git a/src/JSystem/JUtility/JUTGraphFifo.cpp b/src/JSystem/JUtility/JUTGraphFifo.cpp index 2ec9de1de2..840eca7523 100644 --- a/src/JSystem/JUtility/JUTGraphFifo.cpp +++ b/src/JSystem/JUtility/JUTGraphFifo.cpp @@ -18,7 +18,7 @@ JUTGraphFifo::JUTGraphFifo(u32 size) { GXInitFifoPtrs(mFifo, mBase, mBase); } else { mBase = JKRAllocFromSysHeap(mSize + 0xA0, 32); - mBase = (void*)ROUND((intptr_t)mBase, 0x20); + mBase = (void*)ALIGN_NEXT((intptr_t)mBase, 0x20); mFifo = GXInit(mBase, mSize); GXSetColorUpdate(GX_ENABLE); data_804514B8 = true; From e29f1fabdca3157eb97329a0f96f6b4c09678e33 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 28 Feb 2026 17:26:24 -0700 Subject: [PATCH 6/9] Guard operator new/delete behind !TARGET_PC --- include/JSystem/JKernel/JKRHeap.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/JSystem/JKernel/JKRHeap.h b/include/JSystem/JKernel/JKRHeap.h index 189af24376..17b3059314 100644 --- a/include/JSystem/JKernel/JKRHeap.h +++ b/include/JSystem/JKernel/JKRHeap.h @@ -210,16 +210,22 @@ public: static JKRErrorHandler mErrorHandler; }; +#ifndef TARGET_PC void* operator new(size_t size); +#endif void* operator new(size_t size, int alignment); void* operator new(size_t size, JKRHeap* heap, int alignment); +#ifndef TARGET_PC void* operator new[](size_t size); +#endif void* operator new[](size_t size, int alignment); void* operator new[](size_t size, JKRHeap* heap, int alignment); +#ifndef TARGET_PC void operator delete(void* ptr); void operator delete[](void* ptr); +#endif void JKRDefaultMemoryErrorRoutine(void* heap, u32 size, int alignment); From 9853034e31fa26fd6c1defcc53be77ddff3b71d2 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 28 Feb 2026 18:10:14 -0700 Subject: [PATCH 7/9] Add C versions of all ASM blocks (except THP) --- files.cmake | 1 - .../JSystem/J3DGraphAnimator/J3DSkinDeform.h | 3 + include/JSystem/J3DGraphBase/J3DStruct.h | 4 +- include/JSystem/J3DGraphBase/J3DTransform.h | 36 ++++++++++ include/JSystem/JGeometry.h | 14 ++++ src/JSystem/J3DGraphBase/J3DStruct.cpp | 6 ++ src/JSystem/J3DGraphBase/J3DTransform.cpp | 65 +++++++++++++++++++ src/JSystem/JMath/JMath.cpp | 25 +++++++ src/d/d_ky_thunder.cpp | 2 + src/dusk/J3DTransforms_C.cpp | 26 -------- 10 files changed, 153 insertions(+), 29 deletions(-) delete mode 100644 src/dusk/J3DTransforms_C.cpp diff --git a/files.cmake b/files.cmake index c305ab5f3f..451a07429d 100644 --- a/files.cmake +++ b/files.cmake @@ -1326,7 +1326,6 @@ set(DUSK_FILES src/dusk/extras.c src/dusk/extras.cpp src/dusk/globals.cpp - src/dusk/J3DTransforms_C.cpp #src/dusk/m_Do_ext_dusk.cpp src/dusk/dvd_emu.cpp src/dolphin/os/OSContext.cpp diff --git a/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h b/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h index 9ae2a81d27..60fa5fc776 100644 --- a/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h +++ b/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h @@ -4,6 +4,7 @@ #include "JSystem/J3DGraphAnimator/J3DCluster.h" #include "JSystem/J3DGraphAnimator/J3DMtxBuffer.h" #include +#include class J3DModel; class J3DAnmCluster; @@ -115,6 +116,8 @@ inline void J3DFillZero32B(__REGISTER void* param_0, __REGISTER u32 param_1) { addi param_0, param_0, 0x20 bdnz lbl_8032D948 } +#else + memset(param_0, 0, param_1); #endif } diff --git a/include/JSystem/J3DGraphBase/J3DStruct.h b/include/JSystem/J3DGraphBase/J3DStruct.h index 82debd627e..59fb3b14c0 100644 --- a/include/JSystem/J3DGraphBase/J3DStruct.h +++ b/include/JSystem/J3DGraphBase/J3DStruct.h @@ -39,8 +39,8 @@ struct J3DTextureSRTInfo { /* 0x10 */ f32 mTranslationY; bool operator==(J3DTextureSRTInfo&) const; - inline void operator=(J3DTextureSRTInfo const& other) { #ifdef __MWERKS__ + inline void operator=(J3DTextureSRTInfo const& other) { __REGISTER const f32* src = &other.mScaleX; __REGISTER f32* dst = &mScaleX; __REGISTER f32 xy; @@ -58,8 +58,8 @@ struct J3DTextureSRTInfo { psq_l xy, 0(src), 0, 0 psq_st xy, 0(dst), 0, 0 }; -#endif } +#endif }; // Size: 0x14 enum J3DTexMtxMode { diff --git a/include/JSystem/J3DGraphBase/J3DTransform.h b/include/JSystem/J3DGraphBase/J3DTransform.h index 07b717a9ab..523bf81c69 100644 --- a/include/JSystem/J3DGraphBase/J3DTransform.h +++ b/include/JSystem/J3DGraphBase/J3DTransform.h @@ -85,6 +85,12 @@ inline void J3DPSMtx33Copy(__REGISTER Mtx3P src, __REGISTER Mtx3P dst) { psq_st fr1, 0x18(dst), 0, 0 stfs fr0, 0x20(dst) } +#else + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + dst[i][j] = src[i][j]; + } + } #endif } @@ -110,6 +116,12 @@ inline void J3DPSMtx33CopyFrom34(__REGISTER MtxP src, __REGISTER Mtx3P dst) { psq_st x_y3, 24(dst), 0, 0 stfs z3, 0x20(dst) } +#else + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + dst[i][j] = src[i][j]; + } + } #endif } @@ -137,6 +149,12 @@ inline void J3DPSMulMtxVec(__REGISTER MtxP mtx, __REGISTER Vec* vec, __REGISTER ps_sum0 f6, f5, f6, f5 psq_st f6, 8(dst), 1, 0 } +#else + Vec tmp; + tmp.x = mtx[0][0] * vec->x + mtx[0][1] * vec->y + mtx[0][2] * vec->z + mtx[0][3]; + tmp.y = mtx[1][0] * vec->x + mtx[1][1] * vec->y + mtx[1][2] * vec->z + mtx[1][3]; + tmp.z = mtx[2][0] * vec->x + mtx[2][1] * vec->y + mtx[2][2] * vec->z + mtx[2][3]; + *dst = tmp; #endif } @@ -164,6 +182,12 @@ inline void J3DPSMulMtxVec(__REGISTER MtxP mtx, __REGISTER S16Vec* vec, __REGIST ps_sum0 f6, f5, f6, f5 psq_st f6, 4(dst), 1, 7 } +#else + S16Vec tmp; + tmp.x = (s16)(mtx[0][0] * vec->x + mtx[0][1] * vec->y + mtx[0][2] * vec->z + mtx[0][3]); + tmp.y = (s16)(mtx[1][0] * vec->x + mtx[1][1] * vec->y + mtx[1][2] * vec->z + mtx[1][3]); + tmp.z = (s16)(mtx[2][0] * vec->x + mtx[2][1] * vec->y + mtx[2][2] * vec->z + mtx[2][3]); + *dst = tmp; #endif } @@ -195,6 +219,12 @@ inline void J3DPSMulMtxVec(__REGISTER Mtx3P mtx, __REGISTER Vec* vec, __REGISTER ps_sum0 f6, f5, f6, f5 psq_st f6, 8(dst), 1, 0 } +#else + Vec tmp; + tmp.x = mtx[0][0] * vec->x + mtx[0][1] * vec->y + mtx[0][2] * vec->z; + tmp.y = mtx[1][0] * vec->x + mtx[1][1] * vec->y + mtx[1][2] * vec->z; + tmp.z = mtx[2][0] * vec->x + mtx[2][1] * vec->y + mtx[2][2] * vec->z; + *dst = tmp; #endif } @@ -226,6 +256,12 @@ inline void J3DPSMulMtxVec(__REGISTER Mtx3P mtx, __REGISTER S16Vec* vec, __REGIS ps_sum0 f6, f5, f6, f5 psq_st f6, 4(dst), 1, 7 } +#else + S16Vec tmp; + tmp.x = (s16)(mtx[0][0] * vec->x + mtx[0][1] * vec->y + mtx[0][2] * vec->z); + tmp.y = (s16)(mtx[1][0] * vec->x + mtx[1][1] * vec->y + mtx[1][2] * vec->z); + tmp.z = (s16)(mtx[2][0] * vec->x + mtx[2][1] * vec->y + mtx[2][2] * vec->z); + *dst = tmp; #endif } diff --git a/include/JSystem/JGeometry.h b/include/JSystem/JGeometry.h index 15204795a9..6177e366e2 100644 --- a/include/JSystem/JGeometry.h +++ b/include/JSystem/JGeometry.h @@ -151,6 +151,10 @@ inline void setTVec3f(const __REGISTER f32* vec_a, __REGISTER f32* vec_b) { psq_st a_x, 0(vec_b), 0, 0 stfs b_x, 8(vec_b) }; +#else + vec_b[0] = vec_a[0]; + vec_b[1] = vec_a[1]; + vec_b[2] = vec_a[2]; #endif } @@ -163,6 +167,8 @@ inline float fsqrt_step(float mag) { #ifdef __MWERKS__ f32 root = __frsqrte(mag); return 0.5f * root * (3.0f - mag * (root * root)); + #else + return 1.0f / sqrtf(mag); #endif } @@ -182,6 +188,10 @@ inline void mulInternal(__REGISTER const f32* a, __REGISTER const f32* b, __REGI psq_st x_y, 0(dst), 0, 0 }; dst[2] = a[2] * b[2]; +#else + dst[0] = a[0] * b[0]; + dst[1] = a[1] * b[1]; + dst[2] = a[2] * b[2]; #endif } @@ -359,6 +369,10 @@ struct TVec3 : public Vec { fneg z, z stfs z, 8(rdst) }; +#else + dst->x = -x; + dst->y = -y; + dst->z = -z; #endif } diff --git a/src/JSystem/J3DGraphBase/J3DStruct.cpp b/src/JSystem/J3DGraphBase/J3DStruct.cpp index b273cafffe..a914a75f61 100644 --- a/src/JSystem/J3DGraphBase/J3DStruct.cpp +++ b/src/JSystem/J3DGraphBase/J3DStruct.cpp @@ -109,6 +109,12 @@ void J3DTexMtxInfo::setEffectMtx(Mtx param_0) { }; mEffectMtx[3][2] = 0.0f; mEffectMtx[3][3] = 1.0f; +#else + JMath::gekko_ps_copy12(&mEffectMtx, param_0); + mEffectMtx[3][0] = 0.0f; + mEffectMtx[3][1] = 0.0f; + mEffectMtx[3][2] = 0.0f; + mEffectMtx[3][3] = 1.0f; #endif } diff --git a/src/JSystem/J3DGraphBase/J3DTransform.cpp b/src/JSystem/J3DGraphBase/J3DTransform.cpp index 9194e6e263..de74086073 100644 --- a/src/JSystem/J3DGraphBase/J3DTransform.cpp +++ b/src/JSystem/J3DGraphBase/J3DTransform.cpp @@ -159,6 +159,14 @@ lbl_8005F118: li r3, 1 psq_st f8, 32(r4), 1, 0 blr +#else + Mtx invX; + + if (C_MTXInvXpose(src, invX) == 0) { + return; + } + + J3DPSMtx33CopyFrom34(invX, dst); #endif // clang-format on } @@ -327,6 +335,22 @@ ASM void J3DScaleNrmMtx(__REGISTER Mtx mtx, const __REGISTER Vec& scl) { fmuls f4, fp1, fp3 stfs f4, 40(mtx) blr +#else + f32 sx = scl.x; + f32 sy = scl.y; + f32 sz = scl.z; + + mtx[0][0] *= sx; + mtx[0][1] *= sy; + mtx[0][2] *= sz; + + mtx[1][0] *= sx; + mtx[1][1] *= sy; + mtx[1][2] *= sz; + + mtx[2][0] *= sx; + mtx[2][1] *= sy; + mtx[2][2] *= sz; #endif // clang-format on } @@ -353,6 +377,22 @@ ASM void J3DScaleNrmMtx33(__REGISTER Mtx33 mtx, const __REGISTER Vec& scale) { psq_st f4, 24(mtx), 0, 0 stfs f5, 0x20(mtx) blr +#else + f32 sx = scale.x; + f32 sy = scale.y; + f32 sz = scale.z; + + mtx[0][0] *= sx; + mtx[0][1] *= sy; + mtx[0][2] *= sz; + + mtx[1][0] *= sx; + mtx[1][1] *= sy; + mtx[1][2] *= sz; + + mtx[2][0] *= sx; + mtx[2][1] *= sy; + mtx[2][2] *= sz; #endif // clang-format on } @@ -431,6 +471,22 @@ ASM void J3DMtxProjConcat(__REGISTER Mtx mtx1, __REGISTER Mtx mtx2, __REGISTER M ps_madd f0, f9, f13, f0 psq_st f0, 40(dst), 0, 0 blr +#else + Mtx tmp; + + for (int i = 0; i < 3; i++) { + f32 a0 = mtx1[i][0]; + f32 a1 = mtx1[i][1]; + f32 a2 = mtx1[i][2]; + f32 a3 = mtx1[i][3]; + + tmp[i][0] = a0 * mtx2[0][0] + a1 * mtx2[1][0] + a2 * mtx2[2][0] + a3 * mtx2[3][0]; + tmp[i][1] = a0 * mtx2[0][1] + a1 * mtx2[1][1] + a2 * mtx2[2][1] + a3 * mtx2[3][1]; + tmp[i][2] = a0 * mtx2[0][2] + a1 * mtx2[1][2] + a2 * mtx2[2][2] + a3 * mtx2[3][2]; + tmp[i][3] = a0 * mtx2[0][3] + a1 * mtx2[1][3] + a2 * mtx2[2][3] + a3 * mtx2[3][3]; + } + + JMath::gekko_ps_copy12(dst, tmp); #endif // clang-format on } @@ -543,6 +599,15 @@ loop: #undef FP31 #undef UNIT_R } +#else +void J3DPSMtxArrayConcat(Mtx mA, Mtx mB, Mtx mAB, u32 count) { + Mtx* src = (Mtx*)mB; + Mtx* dst = (Mtx*)mAB; + + for (u32 i = 0; i < count; i++) { + C_MTXConcat(mA, src[i], dst[i]); + } +} #endif // clang-format on f32 const PSMulUnit01[] = { diff --git a/src/JSystem/JMath/JMath.cpp b/src/JSystem/JMath/JMath.cpp index 40ba07e463..3d39ea6f1f 100644 --- a/src/JSystem/JMath/JMath.cpp +++ b/src/JSystem/JMath/JMath.cpp @@ -37,6 +37,8 @@ void JMAQuatLerp(__REGISTER const Quaternion* p, __REGISTER const Quaternion* q, ps_sum0 dp, dp, dp, dp } +#else + dp = p->x * q->x + p->y * q->y + p->z * q->z + p->w * q->w; #endif // clang-format on f32 local_78 = dp; if (local_78 < 0.0) { @@ -68,6 +70,12 @@ void JMAFastVECNormalize(__REGISTER const Vec* src, __REGISTER Vec* dst) { fmuls vz, vz, length stfs vz, dst->z } +#else + f32 mag = src->x * src->x + src->y * src->y + src->z * src->z; + length = 1.0f / sqrtf(mag); + dst->x = src->x * length; + dst->y = src->y * length; + dst->z = src->z * length; #endif // clang-format on } @@ -88,6 +96,10 @@ void JMAVECScaleAdd(__REGISTER const Vec* vec1, __REGISTER const Vec* vec2, __RE ps_madds0 rz, v1z, scale, v2z psq_st rz, 8(dst), 1, 0 } +#else + dst->x = vec1->x * scale + vec2->x; + dst->y = vec1->y * scale + vec2->y; + dst->z = vec1->z * scale + vec2->z; #endif // clang-format on } @@ -122,5 +134,18 @@ void JMAMTXApplyScale(__REGISTER const Mtx src, __REGISTER Mtx dst, __REGISTER f psq_st y, 24(dst), 0, 0 psq_st z, 40(dst), 0, 0 } +#else + dst[0][0] = src[0][0] * xScale; + dst[0][1] = src[0][1] * yScale; + dst[0][2] = src[0][2] * zScale; + dst[0][3] = src[0][3]; + dst[1][0] = src[1][0] * xScale; + dst[1][1] = src[1][1] * yScale; + dst[1][2] = src[1][2] * zScale; + dst[1][3] = src[1][3]; + dst[2][0] = src[2][0] * xScale; + dst[2][1] = src[2][1] * yScale; + dst[2][2] = src[2][2] * zScale; + dst[2][3] = src[2][3]; #endif // clang-format on } diff --git a/src/d/d_ky_thunder.cpp b/src/d/d_ky_thunder.cpp index 0dd064f69a..a42c5329a9 100644 --- a/src/d/d_ky_thunder.cpp +++ b/src/d/d_ky_thunder.cpp @@ -228,6 +228,8 @@ int dThunder_c::create() { #ifdef __MWERKS__ f32 tmp = __frsqrtes(var_f29_2); var_f29_2 = tmp * var_f29_2; + #else + var_f29_2 = sqrtf(var_f29_2); #endif } diff --git a/src/dusk/J3DTransforms_C.cpp b/src/dusk/J3DTransforms_C.cpp deleted file mode 100644 index fa8bc30607..0000000000 --- a/src/dusk/J3DTransforms_C.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include "JSystem/J3DGraphBase/J3DTransform.h" - -// translated to C, should be correct, but not tested. - -void J3DPSMtxArrayConcat(Mtx mA, Mtx mB, Mtx mAB, u32 count) { - for (uint32_t i = 0; i < count; i++) { - const float* b = (const float*)mB[i]; - float* res = (float*)mAB[i]; - - for (int row = 0; row < 3; row++) { - float a0 = mA[row][0]; - float a1 = mA[row][1]; - float a2 = mA[row][2]; - float a3 = mA[row][3]; - - // Standard Matrix Multiply for 3x4 * 3x4 (with implicit 4th row [0,0,0,1]) - res[row * 4 + 0] = a0 * b[0] + a1 * b[4] + a2 * b[8]; - res[row * 4 + 1] = a0 * b[1] + a1 * b[5] + a2 * b[9]; - res[row * 4 + 2] = a0 * b[2] + a1 * b[6] + a2 * b[10]; - // The 4th column includes the translation - res[row * 4 + 3] = a0 * b[3] + a1 * b[7] + a2 * b[11] + a3; - } - } -} From 22fa7326c375fb32bb309d5b6d5f2105a504c549 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 28 Feb 2026 18:24:48 -0700 Subject: [PATCH 8/9] Implement JHIhtonl/JHIntohl --- include/JSystem/JHostIO/JHICommonMem.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/include/JSystem/JHostIO/JHICommonMem.h b/include/JSystem/JHostIO/JHICommonMem.h index 57c810c46f..b0a08fa02e 100644 --- a/include/JSystem/JHostIO/JHICommonMem.h +++ b/include/JSystem/JHostIO/JHICommonMem.h @@ -2,17 +2,14 @@ #define JHICOMMONMEM_H #include +#include "dusk/endian.h" inline u32 JHIhtonl(u32 v) { -#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ - return v; -#else - // todo -#endif + return BSWAP32(v); } inline u32 JHIntohl(u32 v) { - return v; + return BSWAP32(v); } template class JHIComPortManager; From b68dfd94f64f075e803cee886ee5c08ea45bc8e3 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 28 Feb 2026 18:47:49 -0700 Subject: [PATCH 9/9] More pointer truncation & implicit conversion fixes --- include/JSystem/JStudio/JStudio/fvb-data.h | 2 +- include/JSystem/JStudio/JStudio/stb.h | 2 +- src/d/actor/d_a_obj_bmWindow.cpp | 2 +- src/d/actor/d_a_obj_flag.cpp | 2 +- src/d/actor/d_a_obj_kbox.cpp | 4 ++-- src/d/actor/d_a_obj_laundry_rope.cpp | 2 +- src/d/actor/d_a_obj_lp.cpp | 10 ++++----- src/d/actor/d_a_obj_lv6TogeRoll.cpp | 4 ++-- src/d/actor/d_a_obj_lv6bemos2.cpp | 2 +- src/d/actor/d_a_obj_maki.cpp | 2 +- src/d/actor/d_a_obj_rfHole.cpp | 2 +- src/d/actor/d_a_obj_sekizoa.cpp | 2 +- src/d/actor/d_a_obj_so.cpp | 2 +- src/d/actor/d_a_obj_stone.cpp | 2 +- src/d/actor/d_a_obj_tks.cpp | 2 +- src/d/actor/d_a_passer_mng.cpp | 2 +- src/d/actor/d_a_peru.cpp | 24 ++++++++++++++++++++++ src/d/actor/d_a_tag_spinner.cpp | 2 +- 18 files changed, 47 insertions(+), 23 deletions(-) diff --git a/include/JSystem/JStudio/JStudio/fvb-data.h b/include/JSystem/JStudio/JStudio/fvb-data.h index b88f637dbb..3932d0edc1 100644 --- a/include/JSystem/JStudio/JStudio/fvb-data.h +++ b/include/JSystem/JStudio/JStudio/fvb-data.h @@ -14,7 +14,7 @@ extern const char ga4cSignature[4]; const int PARAGRAPH_DATA = 1; -typedef enum TEComposite { +enum TEComposite { /* 0x0 */ COMPOSITE_NONE, /* 0x1 */ COMPOSITE_RAW, /* 0x2 */ COMPOSITE_IDX, diff --git a/include/JSystem/JStudio/JStudio/stb.h b/include/JSystem/JStudio/JStudio/stb.h index 52ddf088af..8bd8d0fc52 100644 --- a/include/JSystem/JStudio/JStudio/stb.h +++ b/include/JSystem/JStudio/JStudio/stb.h @@ -86,7 +86,7 @@ public: const void* getSequence() const { return pSequence; } void setSequence_(const void* arg1) { pSequence = arg1; } const void* getSequence_offset(s32 i_no) const { - int s32Val = (intptr_t)getSequence(); + intptr_t s32Val = (intptr_t)getSequence(); return (const void*)(s32Val + i_no); } const void* getSequence_next() const { return pSequence_next; } diff --git a/src/d/actor/d_a_obj_bmWindow.cpp b/src/d/actor/d_a_obj_bmWindow.cpp index eadbca6baa..e16f6a753a 100644 --- a/src/d/actor/d_a_obj_bmWindow.cpp +++ b/src/d/actor/d_a_obj_bmWindow.cpp @@ -288,7 +288,7 @@ void daBmWindow_c::setBreakEffect(int param_1) { } int temp = param_1 * 3; for (int i = temp; i < temp + 3; i++) { - dComIfGp_particle_set(particle_id[i], &cStack_2c, &cStack_40, &scale, 0xff, 0, 0xffffffff, + dComIfGp_particle_set(particle_id[i], &cStack_2c, &cStack_40, &scale, 0xff, 0, -1, NULL, NULL, NULL); } } diff --git a/src/d/actor/d_a_obj_flag.cpp b/src/d/actor/d_a_obj_flag.cpp index 7443e8fa3f..9e2e11bdaf 100644 --- a/src/d/actor/d_a_obj_flag.cpp +++ b/src/d/actor/d_a_obj_flag.cpp @@ -80,7 +80,7 @@ void daObjFlag_c::calcJointAngle() { joint->mJoint3 = joint->mJoint1 - joint->mJoint2; } - if(attr().field_0x25 != NULL) { + if(attr().field_0x25 != 0) { if(i == 1) { calcAngleSwingX(joint, power); } diff --git a/src/d/actor/d_a_obj_kbox.cpp b/src/d/actor/d_a_obj_kbox.cpp index 655f625720..8f85615ea9 100644 --- a/src/d/actor/d_a_obj_kbox.cpp +++ b/src/d/actor/d_a_obj_kbox.cpp @@ -62,7 +62,7 @@ static void break_eff(obj_kbox_class* i_this) { fopAcM_GetRoomNo(&i_this->mActor), NULL, NULL, &particleScale); dPa_modelEcallBack::setModel(pEmitter, kibako_bmd, i_this->mActor.tevStr, 3, NULL, 0, 0); for (int i = 0; i < 3; i++) { - dComIfGp_particle_set(particle_id[i], &emitterPos, 0, &particleScale, 0xff, 0, 0xffffffff, + dComIfGp_particle_set(particle_id[i], &emitterPos, 0, &particleScale, 0xff, 0, -1, 0, 0, 0); } } @@ -213,7 +213,7 @@ static void kbox_float(obj_kbox_class* i_this) { i_this->field_0x5a4 + i_this->field_0x590 + i_this->field_0x58c + i_this->field_0x5ac; i_this->field_0x9e8 = dComIfGp_particle_set(i_this->field_0x9e8, 0x86c3, &cStack_88, &a_this->tevStr, &a_this->shape_angle, - &cStack_7c, 0xff, 0, 0xffffffff, 0, 0, 0); + &cStack_7c, 0xff, 0, -1, 0, 0, 0); if (i_this->field_0x5ac <= -50.0f) { fopAcM_delete(a_this); dComIfGp_particle_set(0x86c4, &cStack_88, &a_this->tevStr, &a_this->shape_angle, diff --git a/src/d/actor/d_a_obj_laundry_rope.cpp b/src/d/actor/d_a_obj_laundry_rope.cpp index f23271db21..080f45915b 100644 --- a/src/d/actor/d_a_obj_laundry_rope.cpp +++ b/src/d/actor/d_a_obj_laundry_rope.cpp @@ -113,7 +113,7 @@ cXyz* daObjLndRope_c::getRopeStartPos() { } f32 daObjLndRope_c::getStartRate(cXyz* i_ropeSegmentPos) { - if (mFlag != NULL) { + if (mFlag != 0) { return mScale * (i_ropeSegmentPos->x - getRopeStartPos()->x); } else { return mScale * (i_ropeSegmentPos->z - getRopeStartPos()->z); diff --git a/src/d/actor/d_a_obj_lp.cpp b/src/d/actor/d_a_obj_lp.cpp index 4d75aacb08..77011548d5 100644 --- a/src/d/actor/d_a_obj_lp.cpp +++ b/src/d/actor/d_a_obj_lp.cpp @@ -53,14 +53,14 @@ static int tandem; static int demo_f; -static int target_info[10]; +static void* target_info[10]; static int target_info_count; static void* s_ks_sub(void* param_1, void* param_2) { if (fopAcM_IsActor(param_1) && fopAcM_GetName(param_1) == 0x60) { if (target_info_count < 10) { - target_info[target_info_count] = (intptr_t)param_1; + target_info[target_info_count] = param_1; target_info_count++; } return param_1; @@ -77,7 +77,7 @@ static int hit_check(obj_lp_class* i_this, wd_ss* WdSs) { fVar1 = 50.0f; for (int i = 0; i < target_info_count; i++) { - sp6c = WdSs->field_0x10 - *(cXyz *)(target_info[i] + 0x4d0); + sp6c = WdSs->field_0x10 - *(cXyz *)((u8 *)target_info[i] + 0x4d0); if (sp6c.y >= -3.0f) { f32 dist = JMAFastSqrt(sp6c.x * sp6c.x + sp6c.z * sp6c.z); if (dist <= fVar1 * WdSs->field_0x3c) { @@ -126,7 +126,7 @@ static int hit_check(obj_lp_class* i_this, wd_ss* WdSs) { cLib_addCalc2(&WdSs->field_0x10.y, WdSs->field_0x4.y + fVar8 * -0.5f, 0.5f, 3.0f); cLib_addCalc2(&WdSs->field_0x28.x, fVar8, 0.1f, fVar8 * 0.5f); cLib_addCalcAngleS2(&WdSs->field_0x34, cM_atan2s(sp6c.x, sp6c.z), 0x20, 0x400); - cLib_addCalcAngleS2(&WdSs->field_0x36, 0xfffff060, 0x20, 0x400); + cLib_addCalcAngleS2(&WdSs->field_0x36, -4000, 0x20, 0x400); rv = 1; } } @@ -221,7 +221,7 @@ static int daObj_Lp_Execute(obj_lp_class* i_this) { target_info[i] = 0; } - target_info[0] = (intptr_t)dComIfGp_getPlayer(0); + target_info[0] = dComIfGp_getPlayer(0); target_info_count = 1; if (strcmp(dComIfGp_getStartStageName(), "D_MN05") == 0) { diff --git a/src/d/actor/d_a_obj_lv6TogeRoll.cpp b/src/d/actor/d_a_obj_lv6TogeRoll.cpp index 9fe1438399..2ee3dbd334 100644 --- a/src/d/actor/d_a_obj_lv6TogeRoll.cpp +++ b/src/d/actor/d_a_obj_lv6TogeRoll.cpp @@ -206,7 +206,7 @@ void daTogeRoll_c::moveTogeRoll() { &daTogeRoll_c::modeBound, &daTogeRoll_c::modeBound2, &daTogeRoll_c::modeBoundWait, }; - if (field_0x5dc == NULL) { + if (field_0x5dc == 0) { for (int i = 0; i < 8; i++) { if (mSph[i].ChkCoHit()) { fopAc_ac_c* hit_actor = dCc_GetAc(mSph[i].GetCoHitObj()->GetAc()); @@ -264,7 +264,7 @@ void daTogeRoll_c::init_modeBoundWait() { } void daTogeRoll_c::modeBoundWait() { - if (field_0x5db != NULL) { + if (field_0x5db != 0) { field_0x5db -= 1; } else { field_0x5dc = 0; diff --git a/src/d/actor/d_a_obj_lv6bemos2.cpp b/src/d/actor/d_a_obj_lv6bemos2.cpp index c7e58cc22a..134c3fa042 100644 --- a/src/d/actor/d_a_obj_lv6bemos2.cpp +++ b/src/d/actor/d_a_obj_lv6bemos2.cpp @@ -494,7 +494,7 @@ void daObjLv6Bm_c::calcBeam() { if (field_0xa19 > 0) { cXyz sp84(field_0x9f8); - if (fopAcM_lc_c::lineCheck(&field_0x9e4, &field_0x9f8, this) != NULL && fopAcM_lc_c::checkGroundHit()) { + if (fopAcM_lc_c::lineCheck(&field_0x9e4, &field_0x9f8, this) != false && fopAcM_lc_c::checkGroundHit()) { sp84 = fopAcM_lc_c::getCross(); } diff --git a/src/d/actor/d_a_obj_maki.cpp b/src/d/actor/d_a_obj_maki.cpp index 161d1388d5..c079a2a000 100644 --- a/src/d/actor/d_a_obj_maki.cpp +++ b/src/d/actor/d_a_obj_maki.cpp @@ -114,7 +114,7 @@ int daObj_Maki_Execute(obj_maki_class* i_this) { cxyz.y += 20000.0f; i_this->field_0x6f8[0] = dComIfGp_particle_set( i_this->field_0x6f8[0], 0x820b, &i_this->current.pos, &i_this->tevStr, - &i_this->shape_angle, 0, 0xff, 0, 0xffffffff, 0, 0, 0); + &i_this->shape_angle, 0, 0xff, 0, -1, 0, 0, 0); fopAcM_seStartLevel(i_this, 0x800a6, 0); } } diff --git a/src/d/actor/d_a_obj_rfHole.cpp b/src/d/actor/d_a_obj_rfHole.cpp index 02d1883cd1..6433549b88 100644 --- a/src/d/actor/d_a_obj_rfHole.cpp +++ b/src/d/actor/d_a_obj_rfHole.cpp @@ -157,7 +157,7 @@ void daRfHole_c::setBreakEffect() { mDoMtx_stack_c::multVec(&acStack_24, &acStack_24); cXyz cStack_30 = current.pos + acStack_24; for (int i = 0; i < 5; i++) { - dComIfGp_particle_set(particle_id[i], &cStack_30, NULL, &scale, 0xff, 0, 0xffffffff, NULL, + dComIfGp_particle_set(particle_id[i], &cStack_30, NULL, &scale, 0xff, 0, -1, NULL, NULL, NULL); } } diff --git a/src/d/actor/d_a_obj_sekizoa.cpp b/src/d/actor/d_a_obj_sekizoa.cpp index 7165ff0929..fcf5bf8107 100644 --- a/src/d/actor/d_a_obj_sekizoa.cpp +++ b/src/d/actor/d_a_obj_sekizoa.cpp @@ -255,7 +255,7 @@ int daObj_Sekizoa_c::CreateHeap() { } if (mType == TYPE_6) { int success_create = mInvModel.create(mpMorf[0]->getModel(), 1); - if (success_create == NULL) { + if (success_create == 0) { return 0; } diff --git a/src/d/actor/d_a_obj_so.cpp b/src/d/actor/d_a_obj_so.cpp index 0431d31851..47ffa2a36c 100644 --- a/src/d/actor/d_a_obj_so.cpp +++ b/src/d/actor/d_a_obj_so.cpp @@ -831,7 +831,7 @@ static void demo_camera(obj_so_class* i_this) { // fallthrough case 2: sp3c.set(12459.0f, 3152.0f, 4628.0f); - daPy_getPlayerActorClass()->setPlayerPosAndAngle(&sp3c, 0xfffffaee, 0); + daPy_getPlayerActorClass()->setPlayerPosAndAngle(&sp3c, -1298, 0); i_this->mDemoCamCenter.x = a_this->current.pos.x; i_this->mDemoCamCenter.z = a_this->current.pos.z; sp3c.y = (a_this->current.pos.y + 150.0f) - 50.0f; diff --git a/src/d/actor/d_a_obj_stone.cpp b/src/d/actor/d_a_obj_stone.cpp index b8b1677513..1d7c35e86d 100644 --- a/src/d/actor/d_a_obj_stone.cpp +++ b/src/d/actor/d_a_obj_stone.cpp @@ -947,7 +947,7 @@ void daObjStone_c::set_carry_eff() { if (field_0x0950 == 3) { for (int i = 0; i < 3; i++) { field_0x0964[i] = - dComIfGp_particle_set(l_carry_eff_id[i], ¤t.pos, 0, &pos, 0xFF, 0, 0xFFFFFFFF, + dComIfGp_particle_set(l_carry_eff_id[i], ¤t.pos, 0, &pos, 0xFF, 0, -1, 0, 0, 0); // float literal inline if (field_0x0964[i] != 0) { field_0x0964[i]->becomeImmortalEmitter(); diff --git a/src/d/actor/d_a_obj_tks.cpp b/src/d/actor/d_a_obj_tks.cpp index f01ec869f7..f769340976 100644 --- a/src/d/actor/d_a_obj_tks.cpp +++ b/src/d/actor/d_a_obj_tks.cpp @@ -279,7 +279,7 @@ int daObjTks_c::createHeapCallBack(fopAc_ac_c* i_this) { } int daObjTks_c::ctrlJointCallBack(J3DJoint* i_joint, int param_1) { - if (param_1 == NULL) { + if (param_1 == 0) { J3DModel* mdl_p = j3dSys.getModel(); daObjTks_c* a_this = (daObjTks_c*)mdl_p->getUserArea(); diff --git a/src/d/actor/d_a_passer_mng.cpp b/src/d/actor/d_a_passer_mng.cpp index c48a9e76ad..ea584d9158 100644 --- a/src/d/actor/d_a_passer_mng.cpp +++ b/src/d/actor/d_a_passer_mng.cpp @@ -23,7 +23,7 @@ int daPasserMng_c::execute() { csXyz cStack_20(field_0x596 != 0 ? 0xff : endTime, current.angle.y, 0); childProcIds[currentChildIndex] = fopAcM_createChild(npcId, fopAcM_GetID(this), getPasserParam(), ¤t.pos, - fopAcM_GetRoomNo(this), &cStack_20, 0, 0xffffffff, 0); + fopAcM_GetRoomNo(this), &cStack_20, 0, -1, 0); currentChildIndex = (currentChildIndex + 1) % getMaxNum(); } mTime = time + intervalTime; diff --git a/src/d/actor/d_a_peru.cpp b/src/d/actor/d_a_peru.cpp index fd4e5716bf..e6f86f68d9 100644 --- a/src/d/actor/d_a_peru.cpp +++ b/src/d/actor/d_a_peru.cpp @@ -561,8 +561,10 @@ int daPeru_c::wait(int param_0) { _AppearDemoTag_delete(); } break; +#ifdef __MWERKS__ case MODE_INVALID: break; +#endif } return 1; } @@ -632,8 +634,10 @@ int daPeru_c::talk(int param_0) { } } break; +#ifdef __MWERKS__ case MODE_INVALID: break; +#endif } return 0; @@ -674,7 +678,11 @@ int daPeru_c::jump_st(int param_1) { setAction(&daPeru_c::jump_ed, actionArg); } break; +#ifdef __MWERKS__ case MODE_INVALID: +#else + case (u16)MODE_INVALID: +#endif field_0xe58 = 0; break; } @@ -712,7 +720,11 @@ int daPeru_c::jump_ed(int param_1) { return 1; } break; +#ifdef __MWERKS__ case MODE_INVALID: +#else + case (u16)MODE_INVALID: +#endif field_0xe58 = 0; break; } @@ -739,8 +751,10 @@ int daPeru_c::sniff(int param_0) { mSound.startCreatureVoice(Z2SE_GZ_NE_KNKN, -1); } break; +#ifdef __MWERKS__ case MODE_INVALID: break; +#endif } return 0; @@ -769,8 +783,10 @@ int daPeru_c::demo_appear(int param_0) { return 1; } break; +#ifdef __MWERKS__ case MODE_INVALID: break; +#endif } return 0; @@ -809,8 +825,10 @@ int daPeru_c::demo_walk_to_link(int param_0) { } break; } +#ifdef __MWERKS__ case MODE_INVALID: break; +#endif } return 0; } @@ -838,8 +856,10 @@ int daPeru_c::demo_walk_circle(int param_0) { field_0xe6e -= 0x155; break; } +#ifdef __MWERKS__ case MODE_INVALID: break; +#endif } return 0; @@ -880,8 +900,10 @@ int daPeru_c::demo_walk_to_window(int param_0) { } break; } +#ifdef __MWERKS__ case MODE_INVALID: break; +#endif } return 0; @@ -912,8 +934,10 @@ int daPeru_c::demo_walk_to_window(int param_0) { } break; } +#ifdef __MWERKS__ case MODE_INVALID: break; +#endif } return 0; diff --git a/src/d/actor/d_a_tag_spinner.cpp b/src/d/actor/d_a_tag_spinner.cpp index 8a95bd4955..5f553929c7 100644 --- a/src/d/actor/d_a_tag_spinner.cpp +++ b/src/d/actor/d_a_tag_spinner.cpp @@ -44,7 +44,7 @@ static void* search_spinner_sub(void* tag_0, void* tag_1) { daTagSpinner_c* actor2 = (daTagSpinner_c*)tag_1; if (actor != NULL && - fopAcM_IsActor(actor) != NULL && + fopAcM_IsActor(actor) != 0 && fopAcM_GetProfName(actor) == PROC_SPINNER) { f32 latDist = actor->current.pos.absXZ(actor2->current.pos); if (latDist < actor2->GetR()) {