diff --git a/CMakeLists.txt b/CMakeLists.txt index 08e6e0e373..569654b6a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,6 +227,12 @@ endif () include(src/dusk/randomizer/randomizer.cmake) +# Edit & Continue +if (MSVC) + add_compile_options("/ZI") + add_link_options("/INCREMENTAL") +endif () + # game_debug is for game code files that we know work when compiled with DEBUG=1 # Of course, if building a release build, this distinction is irrelevant add_library(game_debug OBJECT ${JSYSTEM_DEBUG_FILES} ${SSYSTEM_FILES} diff --git a/extern/aurora b/extern/aurora index aae772abfe..4c0d0feb02 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit aae772abfe667e24ebe8107073dadd457fe8d70f +Subproject commit 4c0d0feb0240546fc2815af709929c9f3bdcce22 diff --git a/files.cmake b/files.cmake index dbcc9b2e5f..6fb45e50be 100644 --- a/files.cmake +++ b/files.cmake @@ -1338,17 +1338,17 @@ set(DUSK_FILES src/d/actor/d_a_alink_dusk.cpp src/dusk/asserts.cpp src/dusk/config.cpp - src/dusk/settings.cpp - src/dusk/logging.cpp - src/dusk/frame_interpolation.cpp - src/dusk/layout.cpp - src/dusk/stubs.cpp src/dusk/endian.cpp src/dusk/extras.c src/dusk/extras.cpp - src/dusk/io.cpp + src/dusk/frame_interpolation.cpp src/dusk/globals.cpp + src/dusk/gyro_aim.cpp + src/dusk/io.cpp + src/dusk/layout.cpp + src/dusk/logging.cpp src/dusk/settings.cpp + src/dusk/stubs.cpp #src/dusk/m_Do_ext_dusk.cpp src/dusk/imgui/ImGuiConfig.hpp src/dusk/imgui/ImGuiConsole.hpp diff --git a/include/d/actor/d_a_alink.h b/include/d/actor/d_a_alink.h index f74aef4f0a..b68a4de5a9 100644 --- a/include/d/actor/d_a_alink.h +++ b/include/d/actor/d_a_alink.h @@ -4550,6 +4550,7 @@ public: #if TARGET_PC void handleQuickTransform(); + bool checkGyroAimItemContext(); #endif }; // Size: 0x385C diff --git a/include/d/d_bg_w_kcol.h b/include/d/d_bg_w_kcol.h index 463f414080..1fc812dd98 100644 --- a/include/d/d_bg_w_kcol.h +++ b/include/d/d_bg_w_kcol.h @@ -115,16 +115,7 @@ public: return pd; } - void getTri1Pos(KC_PrismData* pd, Vec** nrm) const { -#if TARGET_PC - static Vec pos_v; - pos_v = m_pkc_head->m_pos_data[pd->pos_i]; - be_swap(pos_v); - *nrm = &pos_v; -#else - *nrm = &m_pkc_head->m_pos_data[pd->pos_i]; -#endif - } + void getTri1Pos(KC_PrismData* pd, Vec** nrm) const { *nrm = &m_pkc_head->m_pos_data[pd->pos_i]; } private: /* 0x18 */ KC_Header* m_pkc_head; diff --git a/include/dusk/frame_interpolation.h b/include/dusk/frame_interpolation.h index 98495d18db..5c2dc2e1b8 100644 --- a/include/dusk/frame_interpolation.h +++ b/include/dusk/frame_interpolation.h @@ -7,6 +7,7 @@ #include struct cXyz; +class camera_process_class; #ifdef __cplusplus namespace dusk { @@ -14,6 +15,7 @@ namespace frame_interp { void ensure_initialized(); +void begin_record_camera(); void begin_record(); void end_record(); void interpolate(float step); @@ -25,12 +27,14 @@ void end_presentation_ui_pass(); void open_child(const void* key, int32_t id); void close_child(); +void record_camera(::camera_process_class* cam, int camera_id); void record_final_mtx_raw(const Mtx* dest, const Mtx src); bool lookup_replacement(const void* source, Mtx out); bool lookup_concat_replacement(const void* lhs, const void* rhs, Mtx out); void camera_eye_from_view_mtx(MtxP view_mtx, cXyz* o_eye); +bool build_star_view(Mtx o_view, Mtx o_cam_billboard_base, cXyz* o_anchor_eye, float* o_fovy); } // namespace frame_interp } // namespace dusk diff --git a/include/dusk/gyro_aim.h b/include/dusk/gyro_aim.h new file mode 100644 index 0000000000..aafc926811 --- /dev/null +++ b/include/dusk/gyro_aim.h @@ -0,0 +1,10 @@ +#ifndef DUSK_GYRO_AIM_H +#define DUSK_GYRO_AIM_H + +namespace dusk::gyro_aim { +void read(float dt, bool context_active); +void consumeAimDeltas(float& out_yaw_rad, float& out_pitch_rad); +bool queryGyroAimItemContext(); +} // namespace dusk::gyro_aim + +#endif diff --git a/include/dusk/settings.h b/include/dusk/settings.h index 8418602251..2ab587d3ce 100644 --- a/include/dusk/settings.h +++ b/include/dusk/settings.h @@ -35,11 +35,13 @@ struct UserSettings { // QoL ConfigVar enableQuickTransform; ConfigVar hideTvSettingsScreen; + ConfigVar skipWarningScreen; ConfigVar biggerWallets; ConfigVar noReturnRupees; ConfigVar disableRupeeCutscenes; ConfigVar noSwordRecoil; ConfigVar damageMultiplier; + ConfigVar noHeartDrops; ConfigVar instantDeath; ConfigVar fastClimbing; ConfigVar noMissClimbing; @@ -60,6 +62,12 @@ struct UserSettings { ConfigVar noLowHpSound; ConfigVar midnasLamentNonStop; + // Input + ConfigVar enableGyroAim; + ConfigVar gyroAimSensitivity; + ConfigVar gyroAimInvertPitch; + ConfigVar gyroAimInvertYaw; + // Cheats ConfigVar enableFastIronBoots; ConfigVar canTransformAnywhere; @@ -102,6 +110,7 @@ struct CollisionViewSettings { struct TransientSettings { CollisionViewSettings collisionView; bool skipFrameRateLimit; + bool moveLinkActive; }; TransientSettings& getTransientSettings(); diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h index 15128fab34..91461cdba3 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h @@ -53,7 +53,7 @@ private: /* 0x06 */ u16 mUniqueMatNum; /* 0x08 */ J3DMaterial** mMaterialNodePointer; /* 0x0C */ JUTNameTab* mMaterialName; - /* 0x10 */ J3DMaterial* field_0x10; + /* 0x10 */ J3DMaterial* mMaterial; /* 0x14 */ J3DTexture* mTexture; /* 0x18 */ JUTNameTab* mTextureName; /* 0x1C */ u16 field_0x1c; diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DMaterial.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DMaterial.h index 3083dd6480..829156ad1b 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DMaterial.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DMaterial.h @@ -115,7 +115,7 @@ public: /* 0x14 */ u16 mIndex; /* 0x18 */ u32 mInvalid; /* 0x1C */ u32 field_0x1c; - /* 0x20 */ u32 mDiffFlag; + /* 0x20 */ u32 mMaterialID; /* 0x24 */ J3DColorBlock* mColorBlock; /* 0x28 */ J3DTexGenBlock* mTexGenBlock; /* 0x2C */ J3DTevBlock* mTevBlock; diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DPacket.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DPacket.h index 79e19651e4..4be9fe1f17 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DPacket.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DPacket.h @@ -31,8 +31,6 @@ enum J3DDiffFlag { J3DDiffFlag_TevStageIndirect = 0x8000000, J3DDiffFlag_Fog = 0x10000000, J3DDiffFlag_Blend = 0x20000000, - J3DDiffFlag_Unk40000000 = 0x40000000, - J3DDiffFlag_Changed = 0x80000000, }; #define J3D_DIFF_LIGHTOBJNUM(n) ((n & 0xF) << 4) @@ -309,9 +307,9 @@ public: } void setInitShapePacket(J3DShapePacket* packet) { mpInitShapePacket = packet; } - void setMaterialID(u32 id) { mDiffFlag = id; } + void setMaterialID(u32 id) { mMaterialID = id; } void setMaterialAnmID(J3DMaterialAnm* materialAnm) { mpMaterialAnm = materialAnm; } - BOOL isChanged() { return mDiffFlag & J3DDiffFlag_Changed; } + BOOL isChanged() { return mMaterialID & 0x80000000; } bool isEnabled_Diff() { return mpInitShapePacket->getDisplayListObj() != NULL; } virtual ~J3DMatPacket(); @@ -322,7 +320,7 @@ public: /* 0x28 */ J3DShapePacket* mpInitShapePacket; /* 0x2C */ J3DShapePacket* mpShapePacket; /* 0x30 */ J3DMaterial* mpMaterial; - /* 0x34 */ u32 mDiffFlag; + /* 0x34 */ u32 mMaterialID; /* 0x38 */ J3DTexture* mpTexture; /* 0x3C */ J3DMaterialAnm* mpMaterialAnm; }; // Size: 0x40 diff --git a/libs/JSystem/include/JSystem/JStudio/JStudio/fvb.h b/libs/JSystem/include/JSystem/JStudio/JStudio/fvb.h index b04b2cbf1c..72121435a3 100644 --- a/libs/JSystem/include/JSystem/JStudio/JStudio/fvb.h +++ b/libs/JSystem/include/JSystem/JStudio/JStudio/fvb.h @@ -4,6 +4,9 @@ #include "JSystem/JGadget/linklist.h" #include "JSystem/JStudio/JStudio/fvb-data-parse.h" #include "JSystem/JStudio/JStudio/object-id.h" +#if TARGET_PC +#include +#endif namespace JStudio { namespace fvb { @@ -126,6 +129,9 @@ public: private: TFunctionValue_list fnValue; +#if TARGET_PC + std::vector mSwappedData; +#endif }; class TObject_list_parameter : public TObject { @@ -141,6 +147,9 @@ public: private: TFunctionValue_list_parameter fnValue; +#if TARGET_PC + std::vector mSwappedData; +#endif }; struct TObject_hermite : public TObject { @@ -156,6 +165,9 @@ public: private: TFunctionValue_hermite fnValue; +#if TARGET_PC + std::vector mSwappedData; +#endif }; } // namespace fvb diff --git a/libs/JSystem/include/JSystem/JUtility/JUTFader.h b/libs/JSystem/include/JSystem/JUtility/JUTFader.h index e68c648442..6c98a6840f 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTFader.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTFader.h @@ -16,6 +16,7 @@ public: }; JUTFader(int, int, int, int, JUtility::TColor); + void advance(); void control(); void setStatus(JUTFader::EStatus, int); diff --git a/libs/JSystem/src/J3DGraphAnimator/J3DMaterialAttach.cpp b/libs/JSystem/src/J3DGraphAnimator/J3DMaterialAttach.cpp index 6004d366e5..9a98c21357 100644 --- a/libs/JSystem/src/J3DGraphAnimator/J3DMaterialAttach.cpp +++ b/libs/JSystem/src/J3DGraphAnimator/J3DMaterialAttach.cpp @@ -11,7 +11,7 @@ void J3DMaterialTable::clear() { mUniqueMatNum = 0; mMaterialNodePointer = NULL; mMaterialName = NULL; - field_0x10 = 0; + mMaterial = NULL; mTexture = NULL; mTextureName = NULL; field_0x1c = 0; @@ -22,7 +22,7 @@ J3DMaterialTable::J3DMaterialTable() { mUniqueMatNum = 0; mMaterialNodePointer = NULL; mMaterialName = NULL; - field_0x10 = 0; + mMaterial = NULL; mTexture = NULL; mTextureName = NULL; field_0x1c = 0; diff --git a/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp b/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp index 6233d6dff7..f2bd737b4f 100644 --- a/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp +++ b/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp @@ -138,7 +138,7 @@ s32 J3DModel::createMatPacket(J3DModelData* pModelData, u32 mdlFlags) { matPacket->setInitShapePacket(shapePacket); matPacket->addShapePacket(shapePacket); matPacket->setTexture(pModelData->getTexture()); - matPacket->setMaterialID(materialNode->mDiffFlag); + matPacket->setMaterialID(materialNode->mMaterialID); if (pModelData->getModelDataType() == 1) { matPacket->lock(); diff --git a/libs/JSystem/src/J3DGraphBase/J3DMaterial.cpp b/libs/JSystem/src/J3DGraphBase/J3DMaterial.cpp index 6c39e96c9b..0c772305b2 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DMaterial.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DMaterial.cpp @@ -176,7 +176,7 @@ void J3DMaterial::initialize() { mMaterialMode = 1; mIndex = -1; mInvalid = 0; - mDiffFlag = 0; + mMaterialID = 0; mColorBlock = NULL; mTexGenBlock = NULL; mTevBlock = NULL; @@ -207,7 +207,7 @@ void J3DMaterial::makeDisplayList_private(J3DDisplayListObj* pDLObj) { void J3DMaterial::makeDisplayList() { if (!j3dSys.getMatPacket()->isLocked()) { - j3dSys.getMatPacket()->mDiffFlag = mDiffFlag; + j3dSys.getMatPacket()->setMaterialID(mMaterialID); makeDisplayList_private(j3dSys.getMatPacket()->getDisplayListObj()); } } @@ -238,7 +238,7 @@ void J3DMaterial::loadSharedDL() { } void J3DMaterial::patch() { - j3dSys.getMatPacket()->mDiffFlag = mDiffFlag; + j3dSys.getMatPacket()->setMaterialID(mMaterialID); j3dSys.getMatPacket()->beginPatch(); mTevBlock->patch(); mColorBlock->patch(); @@ -323,8 +323,8 @@ void J3DMaterial::copy(J3DMaterial* pOther) { } void J3DMaterial::reset() { - if ((~mDiffFlag & J3DDiffFlag_Changed) == 0) { - mDiffFlag &= ~J3DDiffFlag_Changed; + if ((~mMaterialID & 0x80000000) == 0) { + mMaterialID &= ~0x80000000; mMaterialMode = mpOrigMaterial->mMaterialMode; mInvalid = mpOrigMaterial->mInvalid; mMaterialAnm = NULL; @@ -333,8 +333,8 @@ void J3DMaterial::reset() { } void J3DMaterial::change() { - if ((mDiffFlag & (J3DDiffFlag_Changed | J3DDiffFlag_Unk40000000)) == 0) { - mDiffFlag |= J3DDiffFlag_Changed; + if ((mMaterialID & 0xC0000000) == 0) { + mMaterialID |= 0x80000000; mMaterialAnm = NULL; } } diff --git a/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp b/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp index bf2348020a..9e28a7f7cb 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp @@ -178,7 +178,7 @@ J3DMatPacket::J3DMatPacket() { mpInitShapePacket = NULL; mpShapePacket = NULL; mpMaterial = NULL; - mDiffFlag = 0xFFFFFFFF; + mMaterialID = 0xFFFFFFFF; mpTexture = NULL; mpMaterialAnm = NULL; } @@ -204,7 +204,7 @@ void J3DMatPacket::endDiff() { bool J3DMatPacket::isSame(J3DMatPacket* pOther) const { J3D_ASSERT_NULLPTR(521, pOther != NULL); - return mDiffFlag == pOther->mDiffFlag && (mDiffFlag >> 31) == 0; + return mMaterialID == pOther->mMaterialID && (mMaterialID & 0x80000000) == 0; } void J3DMatPacket::draw() { diff --git a/libs/JSystem/src/J3DGraphLoader/J3DModelLoader.cpp b/libs/JSystem/src/J3DGraphLoader/J3DModelLoader.cpp index 3d064e33de..32f0e4eed9 100644 --- a/libs/JSystem/src/J3DGraphLoader/J3DModelLoader.cpp +++ b/libs/JSystem/src/J3DGraphLoader/J3DModelLoader.cpp @@ -618,6 +618,12 @@ void J3DModelLoader::readJoint(J3DJointBlock const* i_block) { } } +#if TARGET_PC +#define MATERIAL_ID(ptr, offset) (((uintptr_t((ptr)) >> 4) & 0x3FFFFFFF) + (offset)) +#else +#define MATERIAL_ID(ptr, offset) (((uintptr_t((ptr)) >> 4) + (offset))) +#endif + void J3DModelLoader_v26::readMaterial(J3DMaterialBlock const* i_block, u32 i_flags) { J3D_ASSERT_NULLPTR(817, i_block); J3DMaterialFactory factory(*i_block); @@ -633,16 +639,16 @@ void J3DModelLoader_v26::readMaterial(J3DMaterialBlock const* i_block, u32 i_fla mpMaterialTable->mMaterialNodePointer = JKR_NEW_ARRAY(J3DMaterial*, mpMaterialTable->mMaterialNum); J3D_ASSERT_ALLOCMEM(841, mpMaterialTable->mMaterialNodePointer); if (i_flags & 0x200000) { - mpMaterialTable->field_0x10 = JKR_NEW_ARRAY_ARGS(J3DMaterial, mpMaterialTable->mUniqueMatNum, 0x20); - J3D_ASSERT_ALLOCMEM(846, mpMaterialTable->field_0x10); + mpMaterialTable->mMaterial = JKR_NEW_ARRAY_ARGS(J3DMaterial, mpMaterialTable->mUniqueMatNum, 0x20); + J3D_ASSERT_ALLOCMEM(846, mpMaterialTable->mMaterial); } else { - mpMaterialTable->field_0x10 = NULL; + mpMaterialTable->mMaterial = NULL; } if (i_flags & 0x200000) { for (u16 i = 0; i < mpMaterialTable->mUniqueMatNum; i++) { - factory.create(&mpMaterialTable->field_0x10[i], + factory.create(&mpMaterialTable->mMaterial[i], J3DMaterialFactory::MATERIAL_TYPE_NORMAL, i, i_flags); - mpMaterialTable->field_0x10[i].mDiffFlag = (uintptr_t)&mpMaterialTable->field_0x10[i] >> 4; + mpMaterialTable->mMaterial[i].mMaterialID = MATERIAL_ID(&mpMaterialTable->mMaterial[i], 0); } } for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) { @@ -651,15 +657,15 @@ void J3DModelLoader_v26::readMaterial(J3DMaterialBlock const* i_block, u32 i_fla } if (i_flags & 0x200000) { for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) { - mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag = - (uintptr_t)&mpMaterialTable->field_0x10[factory.getMaterialID(i)] >> 4; + mpMaterialTable->mMaterialNodePointer[i]->mMaterialID = + MATERIAL_ID(&mpMaterialTable->mMaterial[factory.getMaterialID(i)], 0); mpMaterialTable->mMaterialNodePointer[i]->mpOrigMaterial = - &mpMaterialTable->field_0x10[factory.getMaterialID(i)]; + &mpMaterialTable->mMaterial[factory.getMaterialID(i)]; } } else { for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) { - mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag = - ((uintptr_t)mpMaterialTable->mMaterialNodePointer >> 4) + factory.getMaterialID(i); + mpMaterialTable->mMaterialNodePointer[i]->mMaterialID = + MATERIAL_ID(mpMaterialTable->mMaterialNodePointer, factory.getMaterialID(i)); } } } @@ -679,15 +685,15 @@ void J3DModelLoader_v21::readMaterial_v21(J3DMaterialBlock_v21 const* i_block, u mpMaterialTable->mMaterialNodePointer = JKR_NEW_ARRAY(J3DMaterial*, mpMaterialTable->mMaterialNum); J3D_ASSERT_ALLOCMEM(940, mpMaterialTable->mMaterialNodePointer); if (i_flags & 0x200000) { - mpMaterialTable->field_0x10 = JKR_NEW_ARRAY_ARGS(J3DMaterial, mpMaterialTable->mUniqueMatNum, 0x20); - J3D_ASSERT_ALLOCMEM(945, mpMaterialTable->field_0x10); + mpMaterialTable->mMaterial = JKR_NEW_ARRAY_ARGS(J3DMaterial, mpMaterialTable->mUniqueMatNum, 0x20); + J3D_ASSERT_ALLOCMEM(945, mpMaterialTable->mMaterial); } else { - mpMaterialTable->field_0x10 = NULL; + mpMaterialTable->mMaterial = NULL; } if (i_flags & 0x200000) { for (u16 i = 0; i < mpMaterialTable->mUniqueMatNum; i++) { - factory.create(&mpMaterialTable->field_0x10[i], i, i_flags); - mpMaterialTable->field_0x10[i].mDiffFlag = (uintptr_t)&mpMaterialTable->field_0x10[i] >> 4; + factory.create(&mpMaterialTable->mMaterial[i], i, i_flags); + mpMaterialTable->mMaterial[i].mMaterialID = MATERIAL_ID(&mpMaterialTable->mMaterial[i], 0); } } for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) { @@ -695,14 +701,14 @@ void J3DModelLoader_v21::readMaterial_v21(J3DMaterialBlock_v21 const* i_block, u } if (i_flags & 0x200000) { for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) { - mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag = - (uintptr_t)&mpMaterialTable->field_0x10[factory.getMaterialID(i)] >> 4; + mpMaterialTable->mMaterialNodePointer[i]->mMaterialID = + MATERIAL_ID(&mpMaterialTable->mMaterial[factory.getMaterialID(i)], 0); mpMaterialTable->mMaterialNodePointer[i]->mpOrigMaterial = - &mpMaterialTable->field_0x10[factory.getMaterialID(i)]; + &mpMaterialTable->mMaterial[factory.getMaterialID(i)]; } } else { for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) { - mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag = 0xc0000000; + mpMaterialTable->mMaterialNodePointer[i]->mMaterialID = 0xC0000000; } } } @@ -767,8 +773,8 @@ void J3DModelLoader_v26::readMaterialTable(J3DMaterialBlock const* i_block, u32 factory.create(NULL, J3DMaterialFactory::MATERIAL_TYPE_NORMAL, i, i_flags); } for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) { - mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag = - (uintptr_t)mpMaterialTable->mMaterialNodePointer + factory.getMaterialID(i); + mpMaterialTable->mMaterialNodePointer[i]->mMaterialID = + MATERIAL_ID(mpMaterialTable->mMaterialNodePointer, factory.getMaterialID(i)); } } @@ -790,8 +796,8 @@ void J3DModelLoader_v21::readMaterialTable_v21(J3DMaterialBlock_v21 const* i_blo factory.create(NULL, i, i_flags); } for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) { - mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag = - ((uintptr_t)mpMaterialTable->mMaterialNodePointer >> 4) + factory.getMaterialID(i); + mpMaterialTable->mMaterialNodePointer[i]->mMaterialID = + MATERIAL_ID(mpMaterialTable->mMaterialNodePointer, factory.getMaterialID(i)); } } @@ -824,12 +830,12 @@ void J3DModelLoader::readPatchedMaterial(J3DMaterialBlock const* i_block, u32 i_ } mpMaterialTable->mMaterialNodePointer = JKR_NEW_ARRAY(J3DMaterial*, mpMaterialTable->mMaterialNum); J3D_ASSERT_ALLOCMEM(1260, mpMaterialTable->mMaterialNodePointer); - mpMaterialTable->field_0x10 = NULL; + mpMaterialTable->mMaterial = NULL; for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) { mpMaterialTable->mMaterialNodePointer[i] = factory.create(NULL, J3DMaterialFactory::MATERIAL_TYPE_PATCHED, i, i_flags); - mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag = - ((uintptr_t)mpMaterialTable->mMaterialNodePointer >> 4) + factory.getMaterialID(i); + mpMaterialTable->mMaterialNodePointer[i]->mMaterialID = + MATERIAL_ID(mpMaterialTable->mMaterialNodePointer, factory.getMaterialID(i)); } } @@ -850,14 +856,14 @@ void J3DModelLoader::readMaterialDL(J3DMaterialDLBlock const* i_block, u32 i_fla } mpMaterialTable->mMaterialNodePointer = JKR_NEW_ARRAY(J3DMaterial*, mpMaterialTable->mMaterialNum); J3D_ASSERT_ALLOCMEM(1320, mpMaterialTable->mMaterialNodePointer); - mpMaterialTable->field_0x10 = NULL; + mpMaterialTable->mMaterial = NULL; for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) { flags = i_flags; mpMaterialTable->mMaterialNodePointer[i] = factory.create(NULL, J3DMaterialFactory::MATERIAL_TYPE_LOCKED, i, flags); } for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) { - mpMaterialTable->mMaterialNodePointer[i]->mDiffFlag = 0xc0000000; + mpMaterialTable->mMaterialNodePointer[i]->mMaterialID = 0xC0000000; } } else { for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) { diff --git a/libs/JSystem/src/JFramework/JFWDisplay.cpp b/libs/JSystem/src/JFramework/JFWDisplay.cpp index d3e7abf0a1..ce4c870064 100644 --- a/libs/JSystem/src/JFramework/JFWDisplay.cpp +++ b/libs/JSystem/src/JFramework/JFWDisplay.cpp @@ -224,20 +224,17 @@ void JFWDisplay::endGX() { if (mFader != NULL) { ortho.setPort(); #ifdef TARGET_PC - if (dusk::getSettings().game.enableFrameInterpolation) { - u32 advance_count = 1; - if (s_faderSimSteps >= 0) { - advance_count = static_cast(s_faderSimSteps); - s_faderSimSteps = -1; - } - for (u32 i = 0; i < advance_count; i++) { - mFader->control(); - } - if (mFader->getStatus() != 1) { - mFader->draw(); - } + u32 advance_count = 1; + if (dusk::getSettings().game.enableFrameInterpolation && s_faderSimSteps >= 0) { + advance_count = static_cast(s_faderSimSteps); + s_faderSimSteps = -1; } else { - mFader->control(); + s_faderSimSteps = -1; + } + for (u32 i = 0; i < advance_count; i++) { + mFader->advance(); + } + if (mFader->getStatus() != 1) { mFader->draw(); } #else diff --git a/libs/JSystem/src/JStudio/JStudio/fvb.cpp b/libs/JSystem/src/JStudio/JStudio/fvb.cpp index b8082211c9..38cb801cfd 100644 --- a/libs/JSystem/src/JStudio/JStudio/fvb.cpp +++ b/libs/JSystem/src/JStudio/JStudio/fvb.cpp @@ -5,15 +5,7 @@ #include #if TARGET_PC -namespace { -void endianSwapListData(const f32* data, u32 count) { - // const hack to swap endianness - f32* nonConstData = const_cast(data); - for (int i = 0; i < count; i++) { - be_swap(nonConstData[i]); - } -} -} +#include #endif namespace JStudio { @@ -281,12 +273,14 @@ void TObject_list::prepare_data_(const data::TParse_TParagraph::TData& rData, TC const ListData* pContent = static_cast(rData.pContent); ASSERT(pContent != NULL); -#if TARGET_PC - endianSwapListData(pContent->_8, pContent->_4); -#endif - fnValue.data_setInterval(pContent->_0); +#if TARGET_PC + mSwappedData.assign(pContent->_8, pContent->_8 + (u32)pContent->_4); + be_swap(mSwappedData.data(), pContent->_4); + fnValue.data_set(mSwappedData.data(), pContent->_4); +#else fnValue.data_set(pContent->_8, pContent->_4); +#endif } TObject_list_parameter::TObject_list_parameter(data::TParse_TBlock const& param_0) @@ -303,9 +297,13 @@ void TObject_list_parameter::prepare_data_(const data::TParse_TParagraph::TData& ASSERT(pContent != NULL); #if TARGET_PC - endianSwapListData(pContent->_4, pContent->_0 * 2); -#endif + u32 count = pContent->_0 * 2; + mSwappedData.assign(pContent->_4, pContent->_4 + count); + be_swap(mSwappedData.data(), count); + fnValue.data_set(mSwappedData.data(), pContent->_0); +#else fnValue.data_set(pContent->_4, pContent->_0); +#endif } TObject_hermite::TObject_hermite(data::TParse_TBlock const& param_0) : TObject(param_0, &fnValue) {} @@ -323,8 +321,10 @@ void TObject_hermite::prepare_data_(const data::TParse_TParagraph::TData& rData, #if TARGET_PC u32 u = (pContent->_0 & 0xFFFFFFF); u32 uSize = (pContent->_0 >> 0x1C); - endianSwapListData(pContent->_4, u * uSize); - fnValue.data_set(pContent->_4, u, uSize); + u32 total = u * uSize; + mSwappedData.assign(pContent->_4, pContent->_4 + total); + be_swap(mSwappedData.data(), total); + fnValue.data_set(mSwappedData.data(), u, uSize); #else fnValue.data_set(pContent->_4, pContent->_0 & 0xFFFFFFF, pContent->_0 >> 0x1C); #endif diff --git a/libs/JSystem/src/JUtility/JUTFader.cpp b/libs/JSystem/src/JUtility/JUTFader.cpp index 1848e92787..f7fa963e63 100644 --- a/libs/JSystem/src/JUtility/JUTFader.cpp +++ b/libs/JSystem/src/JUtility/JUTFader.cpp @@ -17,7 +17,7 @@ JUTFader::JUTFader(int x, int y, int width, int height, JUtility::TColor pColor) mEStatus = UNKSTATUS_M1; } -void JUTFader::control() { +void JUTFader::advance() { if (0 <= mEStatus && mEStatus-- == 0) { mStatus = field_0x24; } @@ -59,9 +59,12 @@ void JUTFader::control() { break; } +} +void JUTFader::control() { + advance(); #ifndef TARGET_PC - // Frame interpolation: draw call moved to JFWDisplay + // FRAME INTERP NOTE: Draw is called by JFWDisplay when interpolation is active draw(); #endif } diff --git a/src/d/actor/d_a_alink.cpp b/src/d/actor/d_a_alink.cpp index e754d7522f..b218a8f1ee 100644 --- a/src/d/actor/d_a_alink.cpp +++ b/src/d/actor/d_a_alink.cpp @@ -51,6 +51,7 @@ #include "d/actor/d_a_ni.h" #include "d/d_s_play.h" +#include "dusk/settings.h" #include "res/Object/Alink.h" #include @@ -18048,7 +18049,10 @@ int daAlink_c::execute() { } BOOL isTrigDebugMoveInput = FALSE; - #if DEBUG +#if TARGET_PC + if (dusk::getTransientSettings().moveLinkActive && daPy_getPlayerActorClass() == this) { + isTrigDebugMoveInput = TRUE; +#elif DEBUG if (daPy_getPlayerActorClass() == this && checkDebugMoveInput()) { isTrigDebugMoveInput = TRUE; if (l_debugMode) { @@ -18059,6 +18063,8 @@ int daAlink_c::execute() { } if (l_debugMode) { +#endif +#if TARGET_PC || DEBUG if (checkModeFlg(0x400) && !checkBoardRide() && !checkSpinnerRide()) { if (checkCanoeRide()) { setSyncCanoePos(); @@ -18067,17 +18073,28 @@ int daAlink_c::execute() { } } else { f32 moveSpeed; +#if TARGET_PC + if (mDoCPd_c::getHoldZ(PAD_1)) { +#else if (mDoCPd_c::getHoldLockR(PAD_1)) { +#endif moveSpeed = 100.0f; } else { moveSpeed = 50.0f; } +#if TARGET_PC + f32 cStickY = mDoCPd_c::getSubStickY(PAD_1); + if (cStickY > 0.3f || cStickY < -0.3f) { + current.pos.y += moveSpeed * cStickY; + } +#else if (mDoCPd_c::getHoldY(PAD_1)) { current.pos.y += moveSpeed; } else if (mDoCPd_c::getHoldX(PAD_1)) { current.pos.y -= moveSpeed; } +#endif current.pos.x += moveSpeed * mStickValue * cM_ssin(mMoveAngle); current.pos.z += moveSpeed * mStickValue * cM_scos(mMoveAngle); @@ -18095,7 +18112,7 @@ int daAlink_c::execute() { setBodyPartPos(); setAttentionPos(); } else - #endif +#endif { if (isTrigDebugMoveInput) { mItemButton = 0; @@ -18563,9 +18580,11 @@ int daAlink_c::execute() { if (checkDeadHP()) { eventInfo.offCondition(fopAcCnd_NOEXEC_e); } else - #if DEBUG +#if TARGET_PC + if (!dusk::getTransientSettings().moveLinkActive) +#elif DEBUG if (!l_debugMode) - #endif +#endif { if (!checkMagneBootsOn()) { f32 gnd_nrm_y; diff --git a/src/d/actor/d_a_alink_dusk.cpp b/src/d/actor/d_a_alink_dusk.cpp index ae4cb2e96c..dbff923a2e 100644 --- a/src/d/actor/d_a_alink_dusk.cpp +++ b/src/d/actor/d_a_alink_dusk.cpp @@ -83,3 +83,32 @@ void daAlink_c::handleQuickTransform() { OSReport("Running quick transform!"); procCoMetamorphoseInit(); } + +bool daAlink_c::checkGyroAimItemContext() { + if (checkWolf()) { + return false; + } + + switch (mProcID) { + case PROC_BOW_SUBJECT: + case PROC_BOOMERANG_SUBJECT: + case PROC_COPY_ROD_SUBJECT: + case PROC_HOOKSHOT_SUBJECT: + case PROC_SWIM_HOOKSHOT_SUBJECT: + case PROC_HORSE_BOW_SUBJECT: + case PROC_HORSE_BOOMERANG_SUBJECT: + case PROC_HORSE_HOOKSHOT_SUBJECT: + case PROC_CANOE_BOW_SUBJECT: + case PROC_CANOE_BOOMERANG_SUBJECT: + case PROC_CANOE_HOOKSHOT_SUBJECT: + case PROC_HOOKSHOT_ROOF_WAIT: + case PROC_HOOKSHOT_ROOF_SHOOT: + case PROC_HOOKSHOT_WALL_WAIT: + case PROC_HOOKSHOT_WALL_SHOOT: + return true; + case PROC_IRON_BALL_SUBJECT: + return itemButton() && mItemVar0.field_0x3018 == 2; + default: + return false; + } +} diff --git a/src/d/actor/d_a_alink_hook.inc b/src/d/actor/d_a_alink_hook.inc index 7e2f3628b9..3641015993 100644 --- a/src/d/actor/d_a_alink_hook.inc +++ b/src/d/actor/d_a_alink_hook.inc @@ -28,6 +28,9 @@ void daAlink_c::hsChainShape_c::draw() { j3dSys.setVtxPos(modelData->getVtxPosArray(), modelData->getVtxNum()); j3dSys.setVtxNrm(modelData->getVtxNrmArray(), modelData->getNrmNum()); j3dSys.setVtxCol(modelData->getVtxColorArray(0), modelData->getColNum()); +#if TARGET_PC + j3dSys.setTexture(modelData->getTexture()); +#endif J3DShape::resetVcdVatCache(); material->loadSharedDL(); diff --git a/src/d/actor/d_a_alink_link.inc b/src/d/actor/d_a_alink_link.inc index 3b61cdfd96..4f8f5fa7b6 100644 --- a/src/d/actor/d_a_alink_link.inc +++ b/src/d/actor/d_a_alink_link.inc @@ -10,6 +10,10 @@ #include "d/actor/d_a_tag_mstop.h" #include "d/actor/d_a_tag_mhint.h" +#if TARGET_PC +#include "dusk/gyro_aim.h" +#endif + bool daAlink_c::checkNoSubjectModeCamera() { return dCam_getBody()->Type() == dCam_getBody()->GetCameraTypeFromCameraName("Rotary") || dCam_getBody()->Type() == dCam_getBody()->GetCameraTypeFromCameraName("Rampart2") || @@ -125,6 +129,40 @@ BOOL daAlink_c::setBodyAngleToCamera() { sp8 = mBodyAngle.x; } +#if TARGET_PC + if (dusk::getSettings().game.enableGyroAim && checkGyroAimItemContext()) { + f32 gyro_scale = 1.0f; + if (checkWolfEyeUp()) { + gyro_scale *= 0.6f; + } + + if (dComIfGp_checkPlayerStatus0(0, 0x200000)) { + gyro_scale /= dComIfGp_getCameraZoomScale(field_0x317c); + } + + f32 gy_yaw = 0.f; + f32 gy_pitch = 0.f; + dusk::gyro_aim::consumeAimDeltas(gy_yaw, gy_pitch); + + if (dusk::getSettings().game.gyroAimInvertPitch) { + gy_pitch = -gy_pitch; + } + if (dusk::getSettings().game.gyroAimInvertYaw) { + gy_yaw = -gy_yaw; + } + if (dusk::getSettings().game.enableMirrorMode) { + gy_yaw = -gy_yaw; + } + + shape_angle.y = shape_angle.y + cM_rad2s(gy_yaw * gyro_scale); + sp8 = sp8 + cM_rad2s(gy_pitch * gyro_scale); + + if (checkNotItemSinkLimit() && sp8 > 0 && sp8 > mBodyAngle.x) { + sp8 = mBodyAngle.x; + } + } +#endif + if (checkNotItemSinkLimit() && sp8 > 0) { cLib_addCalcAngleS(&sp8, 0, 5, 0x1000, 0x400); } diff --git a/src/d/actor/d_a_obj_fchain.cpp b/src/d/actor/d_a_obj_fchain.cpp index 7352c0657c..e681fec4e7 100644 --- a/src/d/actor/d_a_obj_fchain.cpp +++ b/src/d/actor/d_a_obj_fchain.cpp @@ -256,6 +256,9 @@ void daObjFchain_shape_c::draw() { j3dSys.setVtxPos(modelData->getVtxPosArray(), modelData->getVtxNum()); j3dSys.setVtxNrm(modelData->getVtxNrmArray(), modelData->getNrmNum()); j3dSys.setVtxCol(modelData->getVtxColorArray(0), modelData->getColNum()); +#if TARGET_PC + j3dSys.setTexture(modelData->getTexture()); +#endif J3DShape::resetVcdVatCache(); material->loadSharedDL(); material->getShape()->loadPreDrawSetting(); diff --git a/src/d/actor/d_a_obj_wchain.cpp b/src/d/actor/d_a_obj_wchain.cpp index 92cb2048e5..25e2c4f69f 100644 --- a/src/d/actor/d_a_obj_wchain.cpp +++ b/src/d/actor/d_a_obj_wchain.cpp @@ -315,6 +315,9 @@ void daObjWchain_shape_c::draw() { j3dSys.setVtxPos(model_data->getVtxPosArray(), model_data->getVtxNum()); j3dSys.setVtxNrm(model_data->getVtxNrmArray(), model_data->getNrmNum()); j3dSys.setVtxCol(model_data->getVtxColorArray(0), model_data->getColNum()); +#if TARGET_PC + j3dSys.setTexture(model_data->getTexture()); +#endif J3DShape::resetVcdVatCache(); material->loadSharedDL(); material->getShape()->loadPreDrawSetting(); diff --git a/src/d/d_bg_w_kcol.cpp b/src/d/d_bg_w_kcol.cpp index f6d4c0f585..cc58a0f1eb 100644 --- a/src/d/d_bg_w_kcol.cpp +++ b/src/d/d_bg_w_kcol.cpp @@ -36,8 +36,14 @@ void* dBgWKCol::initKCollision(void* i_kclData) { be_swap(kcl->m_area_x_blocks_shift); be_swap(kcl->m_area_xy_blocks_shift); - // for (KC_PrismData* pw = p_prism; (uintptr_t)pw < (uintptr_t)p_block; pw++) - // be_swap(*pw); + Vec* p_pos = kcl->m_pos_data; + Vec* p_nrm = kcl->m_nrm_data; + KC_PrismData* p_prism = kcl->m_prism_data; + BE(u32)* p_block = kcl->m_block_data; + for (Vec* pw = p_pos; pw < p_nrm; pw++) + be_swap(*pw); + for (Vec* pw = p_nrm; (uintptr_t)pw < (uintptr_t)p_prism + sizeof(Vec); pw++) + be_swap(*pw); #else ((KC_Header*)i_kclData)->m_pos_data = (Vec*)((uintptr_t)((KC_Header*)i_kclData) + (uintptr_t)((KC_Header*)i_kclData)->m_pos_data); @@ -64,15 +70,8 @@ void dBgWKCol::create(void* pprism, void* plc) { } void dBgWKCol::getTriNrm(KC_PrismData* pkc, Vec** nrm) const { -#if TARGET_PC - static Vec var_r31_v; - var_r31_v = m_pkc_head->m_nrm_data[pkc->fnrm_i]; - be_swap(var_r31_v); - *nrm = &var_r31_v; -#else Vec* var_r31 = &m_pkc_head->m_nrm_data[pkc->fnrm_i]; *nrm = var_r31; -#endif } bool dBgWKCol::ChkNotReady() const { @@ -125,29 +124,12 @@ bool dBgWKCol::GetTriPnt(int poly_index, Vec* ppos, Vec* param_2, Vec* param_3) bool dBgWKCol::GetTriPnt(KC_PrismData const* pd, Vec* ppos, Vec* param_3, Vec* param_4) const { -#if TARGET_PC - *ppos = m_pkc_head->m_pos_data[pd->pos_i]; - be_swap(*ppos); - Vec face_nrm_v = m_pkc_head->m_nrm_data[pd->fnrm_i]; - be_swap(face_nrm_v); - Vec* face_nrm = &face_nrm_v; - Vec edge_nrm1_v = m_pkc_head->m_nrm_data[pd->enrm1_i]; - be_swap(edge_nrm1_v); - Vec* edge_nrm1 = &edge_nrm1_v; - Vec edge_nrm2_v = m_pkc_head->m_nrm_data[pd->enrm2_i]; - be_swap(edge_nrm2_v); - Vec* edge_nrm2 = &edge_nrm2_v; - Vec edge_nrm3_v = m_pkc_head->m_nrm_data[pd->enrm3_i]; - be_swap(edge_nrm3_v); - Vec* edge_nrm3 = &edge_nrm3_v; -#else *ppos = m_pkc_head->m_pos_data[pd->pos_i]; Vec* face_nrm = &m_pkc_head->m_nrm_data[pd->fnrm_i]; Vec* edge_nrm1 = &m_pkc_head->m_nrm_data[pd->enrm1_i]; Vec* edge_nrm2 = &m_pkc_head->m_nrm_data[pd->enrm2_i]; Vec* edge_nrm3 = &m_pkc_head->m_nrm_data[pd->enrm3_i]; -#endif Vec sp64; PSVECCrossProduct(face_nrm, edge_nrm1, &sp64); @@ -458,17 +440,8 @@ bool dBgWKCol::LineCheck(cBgS_LinChk* plinchk) { } else { while (*(++sp28) != 0) { KC_PrismData* sp20 = getPrismData(sp28[0]); - #if TARGET_PC - Vec sp1C_v = m_pkc_head->m_nrm_data[sp20->fnrm_i]; - be_swap(sp1C_v); - Vec* sp1C = &sp1C_v; - Vec sp18_v = m_pkc_head->m_pos_data[sp20->pos_i]; - be_swap(sp18_v); - Vec* sp18 = &sp18_v; - #else Vec* sp1C = &m_pkc_head->m_nrm_data[sp20->fnrm_i]; Vec* sp18 = &m_pkc_head->m_pos_data[sp20->pos_i]; - #endif cXyz spE4; PSVECSubtract(&sp138, sp18, &spE4); @@ -496,32 +469,13 @@ bool dBgWKCol::LineCheck(cBgS_LinChk* plinchk) { cXyz spB4; PSVECAdd(&spE4, &spC0, &spB4); -#if TARGET_PC - Vec sp14_v = m_pkc_head->m_nrm_data[sp20->enrm1_i]; - be_swap(sp14_v); - Vec* sp14 = &sp14_v; -#else Vec* sp14 = &m_pkc_head->m_nrm_data[sp20->enrm1_i]; -#endif if (PSVECDotProduct(&spB4, sp14) <= 0.0075f) { -#if TARGET_PC - Vec sp10_v = m_pkc_head->m_nrm_data[sp20->enrm2_i]; - be_swap(sp10_v); - Vec* sp10 = &sp10_v; -#else Vec* sp10 = &m_pkc_head->m_nrm_data[sp20->enrm2_i]; -#endif if (PSVECDotProduct(&spB4, sp10) <= 0.0075f) { -#if TARGET_PC - Vec spC_v = - m_pkc_head->m_nrm_data[sp20->enrm3_i]; - be_swap(spC_v); - Vec* spC = &spC_v; -#else Vec* spC = &m_pkc_head->m_nrm_data[sp20->enrm3_i]; -#endif f32 var_f26 = PSVECDotProduct(&spB4, spC); if (var_f26 >= -0.0075f && var_f26 <= sp20->height + 0.0075f) @@ -639,43 +593,18 @@ bool dBgWKCol::GroundCross(cBgS_GndChk* i_chk) { while (*++sp1C != 0) { KC_PrismData* sp18 = getPrismData(sp1C[0]); -#if TARGET_PC - Vec sp14_v = m_pkc_head->m_nrm_data[sp18->fnrm_i]; - be_swap(sp14_v); - Vec* sp14 = &sp14_v; -#else Vec* sp14 = &m_pkc_head->m_nrm_data[sp18->fnrm_i]; -#endif if (!(sp14->y < 0.014f) && !cM3d_IsZero(sp14->y) && (!cBgW_CheckBWall(sp14->y) || i_chk->GetWallPrecheck())) { -#if TARGET_PC - Vec sp10_v = m_pkc_head->m_pos_data[sp18->pos_i]; - be_swap(sp10_v); - Vec* sp10 = &sp10_v; -#else Vec* sp10 = &m_pkc_head->m_pos_data[sp18->pos_i]; -#endif sp4C.x = point_p->x - sp10->x; sp4C.z = point_p->z - sp10->z; sp4C.y = -(sp4C.x * sp14->x + sp4C.z * sp14->z) / sp14->y; -#if TARGET_PC - Vec enrm1_v = m_pkc_head->m_nrm_data[sp18->enrm1_i]; - be_swap(enrm1_v); - Vec enrm2_v = m_pkc_head->m_nrm_data[sp18->enrm2_i]; - be_swap(enrm2_v); - if (!(PSVECDotProduct(&sp4C, &enrm1_v) > 0.0075f) && - !(PSVECDotProduct(&sp4C, &enrm2_v) > 0.0075f)) - { - Vec enrm3_v = m_pkc_head->m_nrm_data[sp18->enrm3_i]; - be_swap(enrm3_v); - f32 var_f30 = PSVECDotProduct(&sp4C, &enrm3_v); -#else if (!(PSVECDotProduct(&sp4C, &m_pkc_head->m_nrm_data[sp18->enrm1_i]) > 0.0075f) && !(PSVECDotProduct(&sp4C, &m_pkc_head->m_nrm_data[sp18->enrm2_i]) > 0.0075f)) { f32 var_f30 = PSVECDotProduct(&sp4C, &m_pkc_head->m_nrm_data[sp18->enrm3_i]); -#endif if (!(var_f30 > 0.0075f + sp18->height) && !(var_f30 < -0.0075f)) { dBgPc sp64; getPolyCode(sp1C[0], &sp64); @@ -887,22 +816,6 @@ void dBgWKCol::ShdwDraw(cBgS_ShdwDraw* param_0) { if (!ChkShdwDrawThrough(&polyCode_sp108)) { prismData_sp20 = getPrismData(p_prismList[0]); -#if TARGET_PC - sp11C[0] = - m_pkc_head->m_pos_data[prismData_sp20->pos_i]; - be_swap(sp11C[0]); - - Vec nrm1_sp1C_v = m_pkc_head->m_nrm_data[prismData_sp20->fnrm_i]; - be_swap(nrm1_sp1C_v); - nrm1_sp1C = &nrm1_sp1C_v; - Vec nrm2_sp18_v = m_pkc_head->m_nrm_data[prismData_sp20->enrm1_i]; - be_swap(nrm2_sp18_v); - nrm2_sp18 = &nrm2_sp18_v; - - Vec unk_sp14_v = m_pkc_head->m_nrm_data[prismData_sp20->enrm3_i]; - be_swap(unk_sp14_v); - unk_sp14 = &unk_sp14_v; -#else sp11C[0] = m_pkc_head->m_pos_data[prismData_sp20->pos_i]; @@ -913,7 +826,6 @@ void dBgWKCol::ShdwDraw(cBgS_ShdwDraw* param_0) { unk_sp14 = m_pkc_head->m_nrm_data + prismData_sp20->enrm3_i; -#endif PSVECCrossProduct(nrm1_sp1C, nrm2_sp18, &cross1_spBC); f32 dot = PSVECDotProduct(&cross1_spBC, unk_sp14); @@ -924,14 +836,8 @@ void dBgWKCol::ShdwDraw(cBgS_ShdwDraw* param_0) { &sp11C[2]); // Second edge direction -#if TARGET_PC - Vec temp_sp10_v = m_pkc_head->m_nrm_data[prismData_sp20->enrm2_i]; - be_swap(temp_sp10_v); - temp_sp10 = &temp_sp10_v; -#else temp_sp10 = m_pkc_head->m_nrm_data + prismData_sp20->enrm2_i; -#endif PSVECCrossProduct(temp_sp10, nrm1_sp1C, &cross2_spB0); f32 dot2 = @@ -1081,13 +987,7 @@ void dBgWKCol::CaptPoly(dBgS_CaptPoly& i_captpoly) { if (r28 != sp28) { while (*++r28 != 0) { KC_PrismData* spC = getPrismData(r28[0]); -#if TARGET_PC - Vec sp8_v = m_pkc_head->m_nrm_data[spC->fnrm_i]; - be_swap(sp8_v); - Vec* sp8 = &sp8_v; -#else Vec* sp8 = &m_pkc_head->m_nrm_data[spC->fnrm_i]; -#endif dBgPc spD8; getPolyCode(r28[0], &spD8); @@ -1271,13 +1171,7 @@ bool dBgWKCol::WallCorrectSort(dBgS_Acch* pwi) { } else { while (*++sp_c8 != 0) { KC_PrismData* sp_c0 = (KC_PrismData*)getPrismData(*sp_c8); -#if TARGET_PC - Vec sp_bc_v = m_pkc_head->m_nrm_data[sp_c0->fnrm_i]; - be_swap(sp_bc_v); - Vec* sp_bc = &sp_bc_v; -#else Vec* sp_bc = m_pkc_head->m_nrm_data + sp_c0->fnrm_i; -#endif if (!cBgW_CheckBGround(sp_bc->y)) { f32 sp_b8 = JMAFastSqrt(sp_bc->x * sp_bc->x + sp_bc->z * sp_bc->z); if (!cM3d_IsZero(sp_b8)) { @@ -1380,13 +1274,7 @@ bool dBgWKCol::WallCorrectSort(dBgS_Acch* pwi) { } int sp_a0 = sp_a4->_4; KC_PrismData* sp_9c = (KC_PrismData*)getPrismData(sp_a0); -#if TARGET_PC - Vec sp_98_v = m_pkc_head->m_nrm_data[sp_9c->fnrm_i]; - be_swap(sp_98_v); - Vec* sp_98 = &sp_98_v; -#else Vec* sp_98 = m_pkc_head->m_nrm_data + sp_9c->fnrm_i; -#endif f32 sp_94 = JMAFastSqrt(sp_98->x * sp_98->x + sp_98->z * sp_98->z); cXyz sp_168; cXyz sp_15c; @@ -1744,13 +1632,7 @@ bool dBgWKCol::WallCorrect(dBgS_Acch* pwi) { while (*++p_prismlist != 0) { KC_PrismData* sp9C = (KC_PrismData*)getPrismData(*p_prismlist); -#if TARGET_PC - Vec sp98_v = m_pkc_head->m_nrm_data[sp9C->fnrm_i]; - be_swap(sp98_v); - Vec* sp98 = &sp98_v; -#else Vec* sp98 = m_pkc_head->m_nrm_data + sp9C->fnrm_i; -#endif if (cBgW_CheckBGround(sp98->y)) { continue; } @@ -2047,48 +1929,15 @@ bool dBgWKCol::RoofChk(dBgS_RoofChk* param_0) { while (*++p_prismlist != 0) { sp1C = getPrismData(p_prismlist[0]); -#if TARGET_PC - Vec sp18_v = m_pkc_head->m_nrm_data[sp1C->fnrm_i]; - be_swap(sp18_v); - sp18 = &sp18_v; -#else sp18 = m_pkc_head->m_nrm_data + sp1C->fnrm_i; -#endif if (cBgW_CheckBRoof(sp18->y)) { -#if TARGET_PC - Vec sp14_v = m_pkc_head->m_pos_data[sp1C->pos_i]; - be_swap(sp14_v); - sp14 = &sp14_v; -#else sp14 = m_pkc_head->m_pos_data + sp1C->pos_i; -#endif cXyz sp5C; sp5C.x = sp40->x - sp14->x; sp5C.z = sp40->z - sp14->z; sp5C.y = -(sp5C.x * sp18->x + sp5C.z * sp18->z) / sp18->y; -#if TARGET_PC - Vec enrm1_v = m_pkc_head->m_nrm_data[sp1C->enrm1_i]; - be_swap(enrm1_v); - if (PSVECDotProduct(&sp5C, &enrm1_v) > - 0.0075f) - { - continue; - } - - Vec enrm2_v = m_pkc_head->m_nrm_data[sp1C->enrm2_i]; - be_swap(enrm2_v); - if (PSVECDotProduct(&sp5C, - &enrm2_v) > 0.0075f) - { - continue; - } - - Vec enrm3_v = m_pkc_head->m_nrm_data[sp1C->enrm3_i]; - be_swap(enrm3_v); - f32 dot_f30 = PSVECDotProduct(&sp5C, &enrm3_v); -#else if (PSVECDotProduct(&sp5C, &m_pkc_head->m_nrm_data[sp1C->enrm1_i]) > 0.0075f) { @@ -2102,7 +1951,6 @@ bool dBgWKCol::RoofChk(dBgS_RoofChk* param_0) { } f32 dot_f30 = PSVECDotProduct(&sp5C, &m_pkc_head->m_nrm_data[sp1C->enrm3_i]); -#endif if (dot_f30 < -0.0075f || dot_f30 > sp1C->height + 0.0075f) { continue; } @@ -2199,13 +2047,7 @@ bool dBgWKCol::SplGrpChk(dBgS_SplGrpChk* param_0) { BE(u16)* p_prismlist = (BE(u16)*)(block + (idx & 0x7fffffff)); while (*++p_prismlist != 0) { KC_PrismData* sp18 = getPrismData(*p_prismlist); -#if TARGET_PC - Vec sp14_v = m_pkc_head->m_nrm_data[sp18->fnrm_i]; - be_swap(sp14_v); - Vec* sp14 = &sp14_v; -#else Vec* sp14 = m_pkc_head->m_nrm_data + sp18->fnrm_i; -#endif if (!(sp14->y <= 0.0f) && !cM3d_IsZero(sp14->y)) { dBgPc sp64; getPolyCode(*p_prismlist, &sp64); @@ -2213,38 +2055,11 @@ bool dBgWKCol::SplGrpChk(dBgS_SplGrpChk* param_0) { if (!chkPolyThrough(&sp64, param_0->GetPolyPassChk(), param_0->GetGrpPassChk(), sp4C)) { -#if TARGET_PC - Vec sp10_v = m_pkc_head->m_pos_data[sp18->pos_i]; - be_swap(sp10_v); - Vec* sp10 = &sp10_v; -#else Vec* sp10 = m_pkc_head->m_pos_data + sp18->pos_i; -#endif cXyz sp40; sp40.x = sp3C->x - sp10->x; sp40.z = sp3C->z - sp10->z; sp40.y = -(sp40.x * sp14->x + sp40.z * sp14->z) / sp14->y; -#if TARGET_PC - Vec enrm1_v = m_pkc_head->m_nrm_data[sp18->enrm1_i]; - be_swap(enrm1_v); - if (PSVECDotProduct(&sp40, &enrm1_v) > - 0.0075f) - { - continue; - } - - Vec enrm2_v = m_pkc_head->m_nrm_data[sp18->enrm2_i]; - be_swap(enrm2_v); - if (PSVECDotProduct(&sp40, &enrm2_v) > - 0.0075f) - { - continue; - } - - Vec enrm3_v = m_pkc_head->m_nrm_data[sp18->enrm3_i]; - be_swap(enrm3_v); - f32 var_f30 = PSVECDotProduct(&sp40, &enrm3_v); -#else if (PSVECDotProduct(&sp40, &m_pkc_head->m_nrm_data[sp18->enrm1_i]) > 0.0075f) { @@ -2258,7 +2073,6 @@ bool dBgWKCol::SplGrpChk(dBgS_SplGrpChk* param_0) { } f32 var_f30 = PSVECDotProduct(&sp40, &m_pkc_head->m_nrm_data[sp18->enrm3_i]); -#endif if (var_f30 < -0.0075f || var_f30 > sp18->height + 0.0075f) { continue; } @@ -2408,13 +2222,7 @@ bool dBgWKCol::SphChk(dBgS_SphChk* param_0, void* param_1) { if (var_r28 != sp30) { while (*++var_r28 != 0) { KC_PrismData* sp14 = getPrismData(*var_r28); -#if TARGET_PC - Vec sp10_v = m_pkc_head->m_nrm_data[sp14->fnrm_i]; - be_swap(sp10_v); - Vec* sp10 = &sp10_v; -#else Vec* sp10 = &m_pkc_head->m_nrm_data[sp14->fnrm_i]; -#endif getPolyCode(*var_r28, &spD4); cXyz sp90 = *sp10; if (!chkPolyThrough(&spD4, param_0->GetPolyPassChk(), diff --git a/src/d/d_camera.cpp b/src/d/d_camera.cpp index 0047978e7e..955683e05b 100644 --- a/src/d/d_camera.cpp +++ b/src/d/d_camera.cpp @@ -11042,8 +11042,8 @@ static int camera_draw(camera_process_class* i_this) { mDoMtx_lookAt(process->view.viewMtx, &process->view.lookat.eye, &process->view.lookat.center, &process->view.lookat.up, process->view.bank); #ifdef TARGET_PC - dusk::frame_interp::record_final_mtx_raw(reinterpret_cast(process->view.viewMtx), - process->view.viewMtx); + dusk::frame_interp::record_camera(process, camera_id); + dusk::frame_interp::record_final_mtx_raw(reinterpret_cast(process->view.viewMtx), process->view.viewMtx); #endif #if WIDESCREEN_SUPPORT diff --git a/src/d/d_drawlist.cpp b/src/d/d_drawlist.cpp index 9f2255b884..42ac8075c7 100644 --- a/src/d/d_drawlist.cpp +++ b/src/d/d_drawlist.cpp @@ -1440,11 +1440,12 @@ void dDlst_shadowSimple_c::set(cXyz* param_0, f32 param_1, f32 param_2, cXyz* pa void dDlst_shadowControl_c::init() { #if TARGET_PC + u16 resMult = dusk::getSettings().game.shadowResolutionMultiplier; // Increase shadow map resolution u16 l_realImageSize[2] = { - 192 * dusk::getSettings().game.shadowResolutionMultiplier, - 64 * dusk::getSettings().game.shadowResolutionMultiplier + static_cast(192 * resMult), + static_cast(64 * resMult) }; #else static u16 l_realImageSize[2] = {192, 64}; @@ -1823,11 +1824,24 @@ static u16 const l_drawlistSize[21] = { }; static u8 const l_nonSortId[9] = { - 0x00, 0x01, 0x02, 0x04, 0x05, 0x06, 0x09, 0x12, 0x0D, + dDlst_list_c::DB_OPA_LIST_SKY, + dDlst_list_c::DB_XLU_LIST_SKY, + dDlst_list_c::DB_LIST_P0, + dDlst_list_c::DB_XLU_LIST_BG, + dDlst_list_c::DB_OPA_LIST_DARK_BG, + dDlst_list_c::DB_XLU_LIST_DARK_BG, + dDlst_list_c::DB_OPA_LIST_DARK, + dDlst_list_c::DB_LIST_2D_SCREEN, + dDlst_list_c::DB_OPA_LIST_ITEM3D, }; static const u8 l_zSortId[6] = { - 0x08, 0x0A, 0x0C, 0x0E, 0x10, 0x11, + dDlst_list_c::DB_XLU_LIST, + dDlst_list_c::DB_XLU_LIST_DARK, + dDlst_list_c::DB_LIST_FILTER, + dDlst_list_c::DB_XLU_LIST_ITEM3D, + dDlst_list_c::DB_XLU_LIST_INVISIBLE, + dDlst_list_c::DB_LIST_Z_XLU, }; void dDlst_list_c::init() { diff --git a/src/d/d_kankyo_rain.cpp b/src/d/d_kankyo_rain.cpp index 4814576c31..953768a525 100644 --- a/src/d/d_kankyo_rain.cpp +++ b/src/d/d_kankyo_rain.cpp @@ -12,6 +12,9 @@ #include "m_Do/m_Do_graphic.h" #include "m_Do/m_Do_lib.h" #include +#if TARGET_PC +#include "dusk/frame_interpolation.h" +#endif static void vectle_calc(DOUBLE_POS* i_pos, cXyz* o_out) { double s = sqrt(i_pos->x * i_pos->x + i_pos->y * i_pos->y + i_pos->z * i_pos->z); @@ -4107,28 +4110,62 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) { color_reg0.b = 0xFF; color_reg0.a = 0xFF; +#if TARGET_PC + Mtx star_gx_view; + cXyz anchor_eye; + f32 star_fovy = 45.0f; + MtxP gx_load_view = drawMtx; + bool star_use_present_view = false; + + if (dusk::getSettings().game.enableFrameInterpolation) { + star_use_present_view = dusk::frame_interp::build_star_view(star_gx_view, camMtx, &anchor_eye, &star_fovy); + } + + if (star_use_present_view) { + gx_load_view = star_gx_view; + } else { + if (dComIfGd_getView() != NULL) { + MTXInverse(dComIfGd_getView()->viewMtxNoTrans, camMtx); + anchor_eye = camera->view.lookat.eye; + star_fovy = dComIfGd_getView()->fovy; + } else { + return; + } + } +#else if (dComIfGd_getView() != NULL) { MTXInverse(dComIfGd_getView()->viewMtxNoTrans, camMtx); } else { return; } +#endif if (strcmp(dComIfGp_getStartStageName(), "F_SP200") == 0 && dComIfG_play_c::getLayerNo(0) == 0) { moon_pos = envlight->moon_pos; } else { +#if TARGET_PC + moon_pos = anchor_eye + envlight->moon_pos; +#else moon_pos = camera->view.lookat.eye + envlight->moon_pos; +#endif if (sp38) { +#if TARGET_PC + moon_pos.x = 3900.0f + anchor_eye.x; + moon_pos.y = 8052.0f + anchor_eye.y; + moon_pos.z = -9072.0f + anchor_eye.z; +#else moon_pos.x = 3900.0f + camera->view.lookat.eye.x; moon_pos.y = 8052.0f + camera->view.lookat.eye.y; moon_pos.z = -9072.0f + camera->view.lookat.eye.z; +#endif } } - #if TARGET_PC +#if TARGET_PC mDoLib_project(&moon_pos, &moon_proj, {0, 0, FB_WIDTH, FB_HEIGHT}); - #else +#else mDoLib_project(&moon_pos, &moon_proj); - #endif +#endif // Dusk optimization: we use vertex color rather than GX_TEVREG0 to set star color. // This allows us to merge all the stars into a single draw. @@ -4156,7 +4193,11 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) { MTXRotRad(rotMtx, 'Z', DEG_TO_RAD(rot)); MTXConcat(camMtx, rotMtx, camMtx); +#if TARGET_PC + GXLoadPosMtxImm(gx_load_view, GX_PNMTX0); +#else GXLoadPosMtxImm(drawMtx, GX_PNMTX0); +#endif GXSetCurrentMtx(GX_PNMTX0); rot += 0.65f; @@ -4164,12 +4205,23 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) { rot = 0.0f; } +#if TARGET_PC + spBC = anchor_eye; +#else spBC.x = camera->view.lookat.eye.x; spBC.y = camera->view.lookat.eye.y; spBC.z = camera->view.lookat.eye.z; +#endif f32 sp34 = -1.0f; int sp30 = 0; +#if TARGET_PC + f32 var_f30 = star_fovy / 45.0f; + if (var_f30 >= 1.0f) { + var_f30 = 1.0f; + } + var_f30 = 1.0f - var_f30; +#else f32 var_f30 = 0.0f; if (dComIfGd_getView() != NULL) { @@ -4179,7 +4231,7 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) { } var_f30 = 1.0f - var_f30; } - +#endif f32 temp_f27 = 0.28f * (1.0f - var_f30); sp98.x = 0.0f; diff --git a/src/d/d_menu_letter.cpp b/src/d/d_menu_letter.cpp index f393fb0785..cef018372f 100644 --- a/src/d/d_menu_letter.cpp +++ b/src/d/d_menu_letter.cpp @@ -452,7 +452,7 @@ void dMenu_Letter_c::wait_move() { void dMenu_Letter_c::slide_right_init() { field_0x358 = -field_0x1ec->getWidth() * mDoGph_gInf_c::getInvScale(); - field_0x35c = field_0x1ec->getWidth() * mDoGph_gInf_c::getInvScale(); + field_0x35c = field_0x1ec->getWidth() IF_NOT_DUSK(* mDoGph_gInf_c::getInvScale()); changePageLight(); copyDMYMenu(); setAButtonString(0); @@ -469,7 +469,7 @@ void dMenu_Letter_c::slide_right_move() { void dMenu_Letter_c::slide_left_init() { field_0x358 = field_0x1ec->getWidth() * mDoGph_gInf_c::getInvScale(); - field_0x35c = -field_0x1ec->getWidth() * mDoGph_gInf_c::getInvScale(); + field_0x35c = -field_0x1ec->getWidth() IF_NOT_DUSK(* mDoGph_gInf_c::getInvScale()); changePageLight(); copyDMYMenu(); setAButtonString(0); diff --git a/src/d/d_model.cpp b/src/d/d_model.cpp index 41a054571f..80dfbc0953 100644 --- a/src/d/d_model.cpp +++ b/src/d/d_model.cpp @@ -11,6 +11,9 @@ void dMdl_c::draw() { j3dSys.setVtxCol(mpModelData->getVtxColorArray(0), mpModelData->getColNum()); J3DShape::resetVcdVatCache(); +#if TARGET_PC + j3dSys.setTexture(mpModelData->getTexture()); +#endif J3DShape* shape = mpModelData->getMaterialNodePointer(mMaterialId)->getShape(); mpModelData->getMaterialNodePointer(mMaterialId)->loadSharedDL(); shape->loadPreDrawSetting(); diff --git a/src/d/d_s_logo.cpp b/src/d/d_s_logo.cpp index 71b4d21de4..f04df0fa39 100644 --- a/src/d/d_s_logo.cpp +++ b/src/d/d_s_logo.cpp @@ -480,7 +480,7 @@ void dScnLogo_c::warningInDraw() { if (mTimer == 0) { mExecCommand = EXEC_WARNING_DISP; - mTimer = 30; + mTimer = 3510; field_0x20e = 30; field_0x210 = field_0x20e; field_0x212 = 1; @@ -547,7 +547,7 @@ void dScnLogo_c::nintendoOutDraw() { if (mTimer == 0) { mExecCommand = EXEC_DOLBY_IN; - mTimer = 30; + mTimer = 90; mDoGph_gInf_c::startFadeIn(30); } } @@ -1104,12 +1104,26 @@ int dScnLogo_c::create() { checkProgSelect(); if (field_0x20a != 0) { mExecCommand = EXEC_PROG_IN; - mTimer = 1; + #if TARGET_PC + mTimer = dusk::getSettings().game.skipWarningScreen ? 1 : 30; + #else + mTimer = 30; + #endif field_0x218 = getProgressiveMode(); } else { #if TARGET_PC - mTimer = 0; // Possibly unnecessary but just in case - mExecCommand = EXEC_DVD_WAIT; + if (dusk::getSettings().game.skipWarningScreen) { + mTimer = 0; // Possibly unnecessary but just in case + mExecCommand = EXEC_DVD_WAIT; + } else { + if (mDoRst::getWarningDispFlag()) { + mTimer = 90; + mExecCommand = EXEC_NINTENDO_IN; + } else { + mTimer = 120; + mExecCommand = EXEC_WARNING_IN; + } + } #else if (mDoRst::getWarningDispFlag()) { mTimer = 90; diff --git a/src/dusk/frame_interpolation.cpp b/src/dusk/frame_interpolation.cpp index 0c21b2b5af..e9b35da1f0 100644 --- a/src/dusk/frame_interpolation.cpp +++ b/src/dusk/frame_interpolation.cpp @@ -1,3 +1,4 @@ +#include "f_op/f_op_camera_mng.h" #include "dusk/frame_interpolation.h" #include @@ -8,7 +9,6 @@ #include namespace { - enum class Op : uint8_t { OpenChild, FinalMtx, @@ -90,6 +90,13 @@ inline void lerp_matrix(Mtx out, const Mtx lhs, const Mtx rhs, float step) { } } +inline void lerp_xyz(cXyz* out, const cXyz& lhs, const cXyz& rhs, float step) { + const float old_weight = 1.0f - step; + out->x = lhs.x * old_weight + rhs.x * step; + out->y = lhs.y * old_weight + rhs.y * step; + out->z = lhs.z * old_weight + rhs.z * step; +} + inline bool matrix_differs(const Mtx lhs, const Mtx rhs, float epsilon = 0.0001f) { for (size_t row = 0; row < 3; ++row) { for (size_t col = 0; col < 4; ++col) { @@ -251,9 +258,7 @@ void clear_replacements() { } // namespace -namespace dusk { -namespace frame_interp { - +namespace dusk::frame_interp { void ensure_initialized() { g_enabled = getSettings().game.enableFrameInterpolation; s_initialized = true; @@ -405,5 +410,76 @@ void camera_eye_from_view_mtx(MtxP view_mtx, cXyz* o_eye) { o_eye->z = -(view_mtx[0][2] * view_mtx[0][3] + view_mtx[1][2] * view_mtx[1][3] + view_mtx[2][2] * view_mtx[2][3]); } -} // namespace frame_interp -} // namespace dusk +namespace { +struct CamSnap { + cXyz eye{}; + cXyz center{}; + cXyz up{}; + s16 bank{}; + f32 fovy{}; + bool valid{}; +}; + +CamSnap s_star_prev{}; +CamSnap s_star_curr{}; + +static void copy_view_to_snap(CamSnap* dst, const view_class& v) { + dst->eye = v.lookat.eye; + dst->center = v.lookat.center; + dst->up = v.lookat.up; + dst->bank = v.bank; + dst->fovy = v.fovy; + dst->valid = true; +} + +static void billboard_base_from_view(MtxP view_mtx, MtxP o_cam_billboard_base) { + Mtx rot; + MTXCopy(view_mtx, rot); + rot[0][3] = rot[1][3] = rot[2][3] = 0.0f; + MTXInverse(rot, o_cam_billboard_base); +} +} // namespace + +void begin_record_camera() { + ::camera_process_class* cam = dComIfGp_getCamera(0); + if (cam == nullptr) { + return; + } + copy_view_to_snap(&s_star_prev, cam->view); +} + +void record_camera(::camera_process_class* cam, int camera_id) { + if (!getSettings().game.enableFrameInterpolation || camera_id != 0 || cam == nullptr) { + return; + } + copy_view_to_snap(&s_star_curr, cam->view); +} + +bool build_star_view(Mtx o_view, Mtx o_cam_billboard_base, cXyz* o_anchor_eye, float* o_fovy) { + if (!getSettings().game.enableFrameInterpolation || !s_star_prev.valid || !s_star_curr.valid) { + return false; + } + + const f32 step = get_interpolation_step(); + cXyz eye; + cXyz center; + cXyz up; + lerp_xyz(&eye, s_star_prev.eye, s_star_curr.eye, step); + lerp_xyz(¢er, s_star_prev.center, s_star_curr.center, step); + lerp_xyz(&up, s_star_prev.up, s_star_curr.up, step); + if (!up.normalizeRS()) { + up = s_star_curr.up; + up.normalizeRS(); + } + + const f32 bank_rad = S2RAD(s_star_prev.bank) * (1.0f - step) + S2RAD(s_star_curr.bank) * step; + const s16 bank = cAngle::Radian_to_SAngle(bank_rad); + + mDoMtx_lookAt(o_view, &eye, ¢er, &up, bank); + billboard_base_from_view(o_view, o_cam_billboard_base); + + *o_anchor_eye = eye; + *o_fovy = s_star_prev.fovy + (s_star_curr.fovy - s_star_prev.fovy) * step; + return true; +} +} // namespace dusk::frame_interp diff --git a/src/dusk/gyro_aim.cpp b/src/dusk/gyro_aim.cpp new file mode 100644 index 0000000000..3558b804d1 --- /dev/null +++ b/src/dusk/gyro_aim.cpp @@ -0,0 +1,88 @@ +#include "dusk/gyro_aim.h" + +#include +#include "d/actor/d_a_alink.h" + +namespace dusk::gyro_aim { +namespace { +// TODO: Make deadband and smoothing configurable +constexpr float kDeadbandRadS = 0.04f; +constexpr float kSmoothAlpha = 0.35f; +bool s_sensor_enabled = false; +float s_smooth_gx = 0.0f; +float s_smooth_gy = 0.0f; +float s_pending_yaw_rad = 0.0f; +float s_pending_pitch_rad = 0.0f; + +void reset_filter_state() { + s_smooth_gx = s_smooth_gy = 0.0f; + s_pending_yaw_rad = s_pending_pitch_rad = 0.0f; +} + +float apply_deadband(float v) { + if (v > -kDeadbandRadS && v < kDeadbandRadS) { + return 0.0f; + } + return v; +} +} // namespace + +void read(float dt, bool context_active) { + if (!context_active || !static_cast(dusk::getSettings().game.enableGyroAim)) { + SDL_Gamepad* pad = SDL_GetGamepadFromPlayerIndex(0); + if (pad != nullptr && s_sensor_enabled) { + SDL_SetGamepadSensorEnabled(pad, SDL_SENSOR_GYRO, false); + s_sensor_enabled = false; + } + reset_filter_state(); + return; + } + + SDL_Gamepad* pad = SDL_GetGamepadFromPlayerIndex(0); + if (pad == nullptr || !SDL_GamepadHasSensor(pad, SDL_SENSOR_GYRO)) { + return; + } + + if (!s_sensor_enabled) { + if (!SDL_SetGamepadSensorEnabled(pad, SDL_SENSOR_GYRO, true)) { + return; + } + s_sensor_enabled = true; + reset_filter_state(); + } + + float gyro[3]; + if (!SDL_GetGamepadSensorData(pad, SDL_SENSOR_GYRO, gyro, 3)) { + return; + } + + s_smooth_gx += kSmoothAlpha * (gyro[0] - s_smooth_gx); + s_smooth_gy += kSmoothAlpha * (gyro[1] - s_smooth_gy); + float yaw_rate = apply_deadband(s_smooth_gy); + float pitch_rate = apply_deadband(s_smooth_gx); + + const float sens = dusk::getSettings().game.gyroAimSensitivity; + s_pending_yaw_rad += yaw_rate * dt * sens; + s_pending_pitch_rad += pitch_rate * dt * sens; +} + +void consumeAimDeltas(float& out_yaw_rad, float& out_pitch_rad) { + out_yaw_rad = s_pending_yaw_rad; + out_pitch_rad = s_pending_pitch_rad; + s_pending_yaw_rad = 0.0f; + s_pending_pitch_rad = 0.0f; +} + +bool queryGyroAimItemContext() { + if (!static_cast(dusk::getSettings().game.enableGyroAim)) { + return false; + } + + daAlink_c* link = daAlink_getAlinkActorClass(); + if (link == nullptr) { + return false; + } + + return link->checkGyroAimItemContext() && dComIfGp_checkCameraAttentionStatus(link->field_0x317c, 0x10); +} +} // namespace dusk::gyro_aim diff --git a/src/dusk/imgui/ImGuiConsole.cpp b/src/dusk/imgui/ImGuiConsole.cpp index 6e917761f6..1bff5da458 100644 --- a/src/dusk/imgui/ImGuiConsole.cpp +++ b/src/dusk/imgui/ImGuiConsole.cpp @@ -13,6 +13,8 @@ #include "JSystem/JUtility/JUTGamePad.h" #include "SDL3/SDL_mouse.h" +#include "m_Do/m_Do_controller_pad.h" +#include "m_Do/m_Do_main.h" #include "dusk/config.hpp" #include "dusk/main.h" #include "dusk/settings.h" @@ -202,6 +204,13 @@ namespace dusk { void ImGuiConsole::UpdateSettings() { getTransientSettings().skipFrameRateLimit = getSettings().game.enableTurboKeybind && ImGui::IsKeyDown(ImGuiKey_Tab); + + if (mDoMain::developmentMode == 1 && mDoCPd_c::getHoldL(PAD_1) && mDoCPd_c::getHoldR(PAD_1) && mDoCPd_c::getTrigY(PAD_1)) { + getTransientSettings().moveLinkActive = !getTransientSettings().moveLinkActive; + } + if (mDoMain::developmentMode != 1) { + getTransientSettings().moveLinkActive = false; + } } void ImGuiConsole::PreDraw() { diff --git a/src/dusk/imgui/ImGuiControllerOverlay.cpp b/src/dusk/imgui/ImGuiControllerOverlay.cpp index bd53e6f91d..8c24063375 100644 --- a/src/dusk/imgui/ImGuiControllerOverlay.cpp +++ b/src/dusk/imgui/ImGuiControllerOverlay.cpp @@ -5,6 +5,8 @@ #include "ImGuiConsole.hpp" #include "ImGuiMenuGame.hpp" +#include + namespace dusk { void ImGuiMenuGame::windowInputViewer() { if (!m_showInputViewer) { @@ -258,9 +260,37 @@ namespace dusk { size.y = 130 * scale; ImGui::Dummy(size); + SDL_Gamepad* pad = SDL_GetGamepadFromPlayerIndex(0); + if (pad != nullptr && SDL_GamepadHasSensor(pad, SDL_SENSOR_GYRO)) { + ImGui::Separator(); + ImGui::TextUnformatted("Gyro"); + + constexpr float kBarScale = 4.0f; + auto bar = [kBarScale](const char* label, float v) { + const float a = std::fabs(v); + const float t = std::min(1.f, a / kBarScale); + char overlay[32]; + snprintf(overlay, sizeof(overlay), "%s %+.3f", label, v); + ImGui::ProgressBar(t, ImVec2(-1, 0), overlay); + }; + + if (SDL_SetGamepadSensorEnabled(pad, SDL_SENSOR_GYRO, true)) { + float gyro[3]; + if (SDL_GetGamepadSensorData(pad, SDL_SENSOR_GYRO, gyro, 3)) { + bar("X", gyro[0]); + bar("Y", gyro[1]); + bar("Z", gyro[2]); + } + } else { + bar("X", 0.f); + bar("Y", 0.f); + bar("Z", 0.f); + } + } + ShowCornerContextMenu(m_inputOverlayCorner, 0); } ImGui::End(); } -} // namespace dusk \ No newline at end of file +} // namespace dusk diff --git a/src/dusk/imgui/ImGuiDebugPad.cpp b/src/dusk/imgui/ImGuiDebugPad.cpp index 114bee5a35..75dc8d77a6 100644 --- a/src/dusk/imgui/ImGuiDebugPad.cpp +++ b/src/dusk/imgui/ImGuiDebugPad.cpp @@ -4,67 +4,47 @@ #include "ImGuiConsole.hpp" void DuskDebugPad() { - if (ImGui::IsKeyPressed(ImGuiKey_K)) { - mDoCPd_c::getCpadInfo(PAD_1).mPressedButtonFlags |= PAD_BUTTON_A; + auto& pad = mDoCPd_c::getCpadInfo(PAD_1); + auto KeyFlag = [&](ImGuiKey key, u32 padFlag) { + if (ImGui::IsKeyDown(key)) + pad.mButtonFlags |= padFlag; + if (ImGui::IsKeyPressed(key)) + pad.mPressedButtonFlags |= padFlag; + + }; + + KeyFlag(ImGuiKey_K, PAD_BUTTON_A); + KeyFlag(ImGuiKey_J, PAD_BUTTON_B); + KeyFlag(ImGuiKey_L, PAD_BUTTON_X); + KeyFlag(ImGuiKey_I, PAD_BUTTON_Y); + KeyFlag(ImGuiKey_H, PAD_BUTTON_START); + KeyFlag(ImGuiKey_O, PAD_TRIGGER_Z); + KeyFlag(ImGuiKey_Keypad8, PAD_BUTTON_UP); + KeyFlag(ImGuiKey_Keypad2, PAD_BUTTON_DOWN); + KeyFlag(ImGuiKey_Keypad6, PAD_BUTTON_RIGHT); + KeyFlag(ImGuiKey_Keypad4, PAD_BUTTON_LEFT); + + if (ImGui::IsKeyDown(ImGuiKey_W)) { + pad.mMainStickPosY = 1.0f; + pad.mMainStickValue = 1.0f; + pad.mMainStickAngle = 0x8000; } - if (ImGui::IsKeyPressed(ImGuiKey_J)) { - mDoCPd_c::getCpadInfo(PAD_1).mPressedButtonFlags |= PAD_BUTTON_B; + if (ImGui::IsKeyDown(ImGuiKey_S)) { + pad.mMainStickPosY = -1.0f; + pad.mMainStickValue = 1.0f; + pad.mMainStickAngle = 0; } - if (ImGui::IsKeyPressed(ImGuiKey_L)) { - mDoCPd_c::getCpadInfo(PAD_1).mPressedButtonFlags |= PAD_BUTTON_X; + if (ImGui::IsKeyDown(ImGuiKey_D)) { + pad.mMainStickPosX = 1.0f; + pad.mMainStickValue = 1.0f; + pad.mMainStickAngle = 0x4000; } - if (ImGui::IsKeyPressed(ImGuiKey_I)) { - mDoCPd_c::getCpadInfo(PAD_1).mPressedButtonFlags |= PAD_BUTTON_Y; + if (ImGui::IsKeyDown(ImGuiKey_A)) { + pad.mMainStickPosX = -1.0f; + pad.mMainStickValue = 1.0f; + pad.mMainStickAngle = -0x4000; } - - if (ImGui::IsKeyPressed(ImGuiKey_H)) { - mDoCPd_c::getCpadInfo(PAD_1).mPressedButtonFlags |= PAD_BUTTON_START; - } - - if (ImGui::IsKeyPressed(ImGuiKey_O)) { - mDoCPd_c::getCpadInfo(PAD_1).mPressedButtonFlags |= PAD_TRIGGER_Z; - } - - if (ImGui::IsKeyPressed(ImGuiKey_Keypad8)) { - mDoCPd_c::getCpadInfo(PAD_1).mPressedButtonFlags |= PAD_BUTTON_UP; - } - - if (ImGui::IsKeyPressed(ImGuiKey_Keypad2)) { - mDoCPd_c::getCpadInfo(PAD_1).mPressedButtonFlags |= PAD_BUTTON_DOWN; - } - - if (ImGui::IsKeyPressed(ImGuiKey_Keypad6)) { - mDoCPd_c::getCpadInfo(PAD_1).mPressedButtonFlags |= PAD_BUTTON_RIGHT; - } - - if (ImGui::IsKeyPressed(ImGuiKey_Keypad4)) { - mDoCPd_c::getCpadInfo(PAD_1).mPressedButtonFlags |= PAD_BUTTON_LEFT; - } - - if (ImGui::IsKeyPressed(ImGuiKey_W)) { - mDoCPd_c::getCpadInfo(PAD_1).mMainStickPosY = 1.0f; - mDoCPd_c::getCpadInfo(PAD_1).mMainStickValue = 1.0f; - mDoCPd_c::getCpadInfo(PAD_1).mMainStickAngle = 0x8000; - } - - if (ImGui::IsKeyPressed(ImGuiKey_S)) { - mDoCPd_c::getCpadInfo(PAD_1).mMainStickPosY = -1.0f; - mDoCPd_c::getCpadInfo(PAD_1).mMainStickValue = 1.0f; - mDoCPd_c::getCpadInfo(PAD_1).mMainStickAngle = 0; - } - - if (ImGui::IsKeyPressed(ImGuiKey_D)) { - mDoCPd_c::getCpadInfo(PAD_1).mMainStickPosX = 1.0f; - mDoCPd_c::getCpadInfo(PAD_1).mMainStickValue = 1.0f; - mDoCPd_c::getCpadInfo(PAD_1).mMainStickAngle = 0x4000; - } - - if (ImGui::IsKeyPressed(ImGuiKey_A)) { - mDoCPd_c::getCpadInfo(PAD_1).mMainStickPosX = -1.0f; - mDoCPd_c::getCpadInfo(PAD_1).mMainStickValue = 1.0f; - mDoCPd_c::getCpadInfo(PAD_1).mMainStickAngle = -0x4000; - } -} \ No newline at end of file +} diff --git a/src/dusk/imgui/ImGuiFirstRunPreset.cpp b/src/dusk/imgui/ImGuiFirstRunPreset.cpp index be4866fd6a..b73eaff6e6 100644 --- a/src/dusk/imgui/ImGuiFirstRunPreset.cpp +++ b/src/dusk/imgui/ImGuiFirstRunPreset.cpp @@ -18,6 +18,7 @@ static void ApplyPresetClassic() { static void ApplyPresetHD() { auto& s = getSettings(); s.game.hideTvSettingsScreen.setValue(true); + s.game.skipWarningScreen.setValue(true); s.game.noReturnRupees.setValue(true); s.game.disableRupeeCutscenes.setValue(true); s.game.noSwordRecoil.setValue(true); diff --git a/src/dusk/imgui/ImGuiMenuEnhancements.cpp b/src/dusk/imgui/ImGuiMenuEnhancements.cpp index b505d84345..50e44f5c60 100644 --- a/src/dusk/imgui/ImGuiMenuEnhancements.cpp +++ b/src/dusk/imgui/ImGuiMenuEnhancements.cpp @@ -53,6 +53,11 @@ namespace dusk { ImGui::SetTooltip("Hides the TV calibration screen shown when loading a save."); } + config::ImGuiCheckbox("Skip Warning Screen", getSettings().game.skipWarningScreen); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Skips the warning screen shown when loading the game."); + } + config::ImGuiCheckbox("Instant Saves", getSettings().game.instantSaves); if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Skip the delay when writing to the Memory Card."); @@ -107,6 +112,20 @@ namespace dusk { ImGui::EndMenu(); } + if (ImGui::BeginMenu("Input")) { + config::ImGuiCheckbox("Gyro Aim", getSettings().game.enableGyroAim); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Enables the gyroscope on supported controllers while aiming the\n" + "Slingshot, Gale Boomerang, Hero's Bow, Clawshot(s), Ball and Chain, and Dominion Rod."); + } + + config::ImGuiSliderFloat("Gyro Sensitivity", getSettings().game.gyroAimSensitivity, 0.25f, 4.0f, "%.2f"); + config::ImGuiCheckbox("Invert Gyro Pitch", getSettings().game.gyroAimInvertPitch); + config::ImGuiCheckbox("Invert Gyro Yaw", getSettings().game.gyroAimInvertYaw); + + ImGui::EndMenu(); + } + if (ImGui::BeginMenu("Cheats")) { config::ImGuiCheckbox("Fast Iron Boots", getSettings().game.enableFastIronBoots); @@ -131,6 +150,12 @@ namespace dusk { if (ImGui::BeginMenu("Difficulty")) { config::ImGuiSliderInt("Damage Multiplier", getSettings().game.damageMultiplier, 1, 8, "x%d"); + config::ImGuiCheckbox("No Heart Drops", getSettings().game.noHeartDrops); + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Hearts will never drop from enemies,\n" + "pots and various other places."); + } + config::ImGuiCheckbox("Instant Death", getSettings().game.instantDeath); if (ImGui::IsItemHovered()) { ImGui::SetTooltip("Any hit will instantly kill you."); diff --git a/src/dusk/settings.cpp b/src/dusk/settings.cpp index dabed72f19..0e39e55854 100644 --- a/src/dusk/settings.cpp +++ b/src/dusk/settings.cpp @@ -23,11 +23,13 @@ UserSettings g_userSettings = { // Quality of Life .enableQuickTransform {"game.enableQuickTransform", false}, .hideTvSettingsScreen {"game.hideTvSettingsScreen", false}, + .skipWarningScreen {"game.skipWarningScreen", false}, .biggerWallets {"game.biggerWallets", false}, .noReturnRupees {"game.noReturnRupees", false}, .disableRupeeCutscenes {"game.disableRupeeCutscenes", false}, .noSwordRecoil {"game.noSwordRecoil", false}, .damageMultiplier {"game.damageMultiplier", 1}, + .noHeartDrops{"game.noHeartDrops", false}, .instantDeath {"game.instantDeath", false}, .fastClimbing {"game.fastClimbing", false}, .noMissClimbing {"game.noMissClimbing", false}, @@ -48,6 +50,12 @@ UserSettings g_userSettings = { .noLowHpSound {"game.noLowHpSound", false}, .midnasLamentNonStop {"game.midnasLamentNonStop", false}, + // Input + .enableGyroAim {"game.enableGyroAim", false}, + .gyroAimSensitivity {"game.gyroAimSensitivity", 1.0f}, + .gyroAimInvertPitch {"game.gyroAimInvertPitch", false}, + .gyroAimInvertYaw {"game.gyroAimInvertYaw", false}, + // Cheats .enableFastIronBoots {"game.enableFastIronBoots", false}, .canTransformAnywhere {"game.canTransformAnywhere", false}, @@ -58,7 +66,7 @@ UserSettings g_userSettings = { .restoreWiiGlitches {"game.restoreWiiGlitches", false}, // Controls - .enableTurboKeybind {"game.enableTurboKeybind", false}, + .enableTurboKeybind {"game.enableTurboKeybind", false} }, .backend = { @@ -91,11 +99,13 @@ void registerSettings() { // Game Register(g_userSettings.game.enableQuickTransform); Register(g_userSettings.game.hideTvSettingsScreen); + Register(g_userSettings.game.skipWarningScreen); Register(g_userSettings.game.biggerWallets); Register(g_userSettings.game.noReturnRupees); Register(g_userSettings.game.disableRupeeCutscenes); Register(g_userSettings.game.noSwordRecoil); Register(g_userSettings.game.damageMultiplier); + Register(g_userSettings.game.noHeartDrops); Register(g_userSettings.game.instantDeath); Register(g_userSettings.game.fastClimbing); Register(g_userSettings.game.fastTears); @@ -115,6 +125,10 @@ void registerSettings() { Register(g_userSettings.game.enableTurboKeybind); Register(g_userSettings.game.fastSpinner); Register(g_userSettings.game.enableFrameInterpolation); + Register(g_userSettings.game.enableGyroAim); + Register(g_userSettings.game.gyroAimSensitivity); + Register(g_userSettings.game.gyroAimInvertPitch); + Register(g_userSettings.game.gyroAimInvertYaw); Register(g_userSettings.backend.isoPath); Register(g_userSettings.backend.graphicsBackend); diff --git a/src/f_ap/f_ap_game.cpp b/src/f_ap/f_ap_game.cpp index 8e2b0a367c..f54ca1edad 100644 --- a/src/f_ap/f_ap_game.cpp +++ b/src/f_ap/f_ap_game.cpp @@ -725,6 +725,7 @@ void fapGm_After() { #ifdef TARGET_PC static void fapGm_Before() { + dusk::frame_interp::begin_record_camera(); dusk::frame_interp::begin_record(); } diff --git a/src/f_op/f_op_actor_mng.cpp b/src/f_op/f_op_actor_mng.cpp index dca07f98ba..208e868db2 100644 --- a/src/f_op/f_op_actor_mng.cpp +++ b/src/f_op/f_op_actor_mng.cpp @@ -1390,6 +1390,12 @@ fpc_ProcID fopAcM_createItemForPresentDemo(cXyz const* i_pos, int i_itemNo, u8 p JUT_ASSERT(3214, 0 <= i_itemNo && i_itemNo < 256); dComIfGp_event_setGtItm(i_itemNo); + #if TARGET_PC + if (dusk::getSettings().game.noHeartDrops && isHeart(i_itemNo)) { + return fpcM_ERROR_PROCESS_ID_e; + } + #endif + if (i_itemNo == dItemNo_NONE_e) { OS_REPORT("プレゼントデモ用なのに「ハズレ」です![%d]\n", i_itemNo); // Even though it is for a Present Demo, it is a 'Miss'! return fpcM_ERROR_PROCESS_ID_e; @@ -1404,6 +1410,12 @@ fpc_ProcID fopAcM_createItemForTrBoxDemo(cXyz const* i_pos, int i_itemNo, int i_ JUT_ASSERT(3259, 0 <= i_itemNo && i_itemNo < 256); dComIfGp_event_setGtItm(i_itemNo); + #if TARGET_PC + if (dusk::getSettings().game.noHeartDrops && isHeart(i_itemNo)) { + return fpcM_ERROR_PROCESS_ID_e; + } + #endif + if (i_itemNo == dItemNo_NONE_e) { OS_REPORT("ゲットデモ用なのに「ハズレ」です![%d]\n", i_itemNo); // Even though it is for a Get Demo, it is a 'Miss'! return fpcM_ERROR_PROCESS_ID_e; @@ -1529,6 +1541,12 @@ fpc_ProcID fopAcM_createItemFromTable(cXyz const* i_pos, int i_itemNo, int i_ite JUT_ASSERT(3655, 0 <= i_itemNo && i_itemNo <= 255 && (-1 <= i_itemBitNo && i_itemBitNo < (dSv_info_c::DAN_ITEM + dSv_info_c::MEMORY_ITEM + dSv_info_c::ZONE_ITEM )) || i_itemBitNo == 255); // clang-format on + #if TARGET_PC + if (dusk::getSettings().game.noHeartDrops && isHeart(i_itemNo)) { + return fpcM_ERROR_PROCESS_ID_e; + } + #endif + u8 tableNum; ItemTableList* tableList; tableList = (ItemTableList*)dComIfGp_getItemTable(); @@ -1572,6 +1590,12 @@ fpc_ProcID fopAcM_createDemoItem(const cXyz* i_pos, int i_itemNo, int i_itemBitN JUT_ASSERT(3824, 0 <= i_itemNo && i_itemNo < 256 && (-1 <= i_itemBitNo && i_itemBitNo < (dSv_info_c::DAN_ITEM + dSv_info_c::MEMORY_ITEM + dSv_info_c::ZONE_ITEM )) || i_itemBitNo == 255); // clang-format on + #if TARGET_PC + if (dusk::getSettings().game.noHeartDrops && isHeart(i_itemNo)) { + return fpcM_ERROR_PROCESS_ID_e; + } + #endif + if (i_itemNo == dItemNo_NONE_e) { return fpcM_ERROR_PROCESS_ID_e; } @@ -1583,6 +1607,12 @@ fpc_ProcID fopAcM_createDemoItem(const cXyz* i_pos, int i_itemNo, int i_itemBitN fpc_ProcID fopAcM_createItemForBoss(const cXyz* i_pos, int i_itemNo, int i_roomNo, const csXyz* i_angle, const cXyz* i_scale, f32 i_speedF, f32 i_speedY, int param_8) { + #if TARGET_PC + if (dusk::getSettings().game.noHeartDrops && isHeart(i_itemNo)) { + return fpcM_ERROR_PROCESS_ID_e; + } + #endif + int _ = -1; u32 params = 0xFFFF0000 | param_8 << 8 | (i_itemNo & 0xFF); @@ -1599,6 +1629,12 @@ fpc_ProcID fopAcM_createItemForBoss(const cXyz* i_pos, int i_itemNo, int i_roomN fpc_ProcID fopAcM_createItemForMidBoss(const cXyz* i_pos, int i_itemNo, int i_roomNo, const csXyz* i_angle, const cXyz* i_scale, int param_6, int param_7) { + #if TARGET_PC + if (dusk::getSettings().game.noHeartDrops && isHeart(i_itemNo)) { + return fpcM_ERROR_PROCESS_ID_e; + } + #endif + UNUSED(i_angle); UNUSED(param_6); fpc_ProcID ret = -1; @@ -1610,6 +1646,12 @@ fpc_ProcID fopAcM_createItemForMidBoss(const cXyz* i_pos, int i_itemNo, int i_ro fopAc_ac_c* fopAcM_createItemForDirectGet(const cXyz* i_pos, int i_itemNo, int i_roomNo, const csXyz* i_angle, const cXyz* i_scale, f32 i_speedF, f32 i_speedY) { + #if TARGET_PC + if (dusk::getSettings().game.noHeartDrops && isHeart(i_itemNo)) { + return NULL; + } + #endif + fopAc_ac_c* item = fopAcM_fastCreateItem(i_pos, i_itemNo, i_roomNo, i_angle, i_scale, &i_speedF, &i_speedY, -1, 0x7, NULL); fopAc_ac_c* ret = item; @@ -1619,6 +1661,12 @@ fopAc_ac_c* fopAcM_createItemForDirectGet(const cXyz* i_pos, int i_itemNo, int i fopAc_ac_c* fopAcM_createItemForSimpleDemo(const cXyz* i_pos, int i_itemNo, int i_roomNo, const csXyz* i_angle, const cXyz* i_scale, f32 i_speedF, f32 i_speedY) { + #if TARGET_PC + if (dusk::getSettings().game.noHeartDrops && isHeart(i_itemNo)) { + return NULL; + } + #endif + fopAc_ac_c* item = fopAcM_fastCreateItem(i_pos, i_itemNo, i_roomNo, i_angle, i_scale, &i_speedF, &i_speedY, -1, 0x4, NULL); fopAc_ac_c* ret = item; @@ -1631,6 +1679,12 @@ fpc_ProcID fopAcM_createItem(const cXyz* i_pos, int i_itemNo, int i_itemBitNo, i JUT_ASSERT(4067, 0 <= i_itemNo && i_itemNo < 256 && (-1 <= i_itemBitNo && i_itemBitNo < (dSv_info_c::DAN_ITEM + dSv_info_c::MEMORY_ITEM + dSv_info_c::ZONE_ITEM )) || i_itemBitNo == 255); // clang-format on + #if TARGET_PC + if (dusk::getSettings().game.noHeartDrops && isHeart(i_itemNo)) { + return fpcM_ERROR_PROCESS_ID_e; + } + #endif + if (i_itemNo == dItemNo_NONE_e) { return fpcM_ERROR_PROCESS_ID_e; } @@ -1695,6 +1749,12 @@ fopAc_ac_c* fopAcM_fastCreateItem2(const cXyz* i_pos, int i_itemNo, int i_itemBi JUT_ASSERT(4202, 0 <= i_itemNo && i_itemNo < 256 && (-1 <= i_itemBitNo && i_itemBitNo < (dSv_info_c::DAN_ITEM + dSv_info_c::MEMORY_ITEM + dSv_info_c::ZONE_ITEM )) || i_itemBitNo == 255); // clang-format on + #if TARGET_PC + if (dusk::getSettings().game.noHeartDrops && isHeart(i_itemNo)) { + return NULL; + } + #endif + csXyz item_angle(csXyz::Zero); if (i_itemNo == dItemNo_NONE_e) { diff --git a/src/m_Do/m_Do_graphic.cpp b/src/m_Do/m_Do_graphic.cpp index ff9e2042a0..f9d5750d71 100644 --- a/src/m_Do/m_Do_graphic.cpp +++ b/src/m_Do/m_Do_graphic.cpp @@ -1858,7 +1858,7 @@ int mDoGph_Painter() { JPADrawInfo draw_info(camera_p->view.viewMtx, camera_p->view.fovy, camera_p->view.aspect); #endif - #if WIDESCREEN_SUPPORT + #if 0 && WIDESCREEN_SUPPORT if (mDoGph_gInf_c::isWideZoom()) { Mtx44 sp140; draw_info.getPrjMtx(sp140); @@ -2419,7 +2419,9 @@ int mDoGph_Painter() { #if TARGET_PC dusk::g_imguiConsole.PostDraw(); - JFWDisplay::getManager()->setFaderSimSteps(pending_ui_ticks); + if (dusk::getSettings().game.enableFrameInterpolation) { + JFWDisplay::getManager()->setFaderSimSteps(pending_ui_ticks); + } #endif mDoGph_gInf_c::endRender(); diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp index 1cfa8edd3b..55f3d28a7e 100644 --- a/src/m_Do/m_Do_main.cpp +++ b/src/m_Do/m_Do_main.cpp @@ -48,6 +48,7 @@ #include "dusk/app_info.hpp" #include "dusk/dusk.h" #include "dusk/frame_interpolation.h" +#include "dusk/gyro_aim.h" #include "dusk/imgui/ImGuiEngine.hpp" #include "dusk/logging.h" #include "dusk/main.h" @@ -246,6 +247,9 @@ void main01(void) { if (dusk::getSettings().game.enableFrameInterpolation) { while (accumulator >= kSimStepSeconds) { mDoCPd_c::read(); + if (dusk::getSettings().game.enableGyroAim) { + dusk::gyro_aim::read(static_cast(kSimStepSeconds), dusk::gyro_aim::queryGyroAimItemContext()); + } fapGm_Execute(); mDoAud_Execute(); accumulator -= kSimStepSeconds; @@ -259,6 +263,9 @@ void main01(void) { // Game Inputs mDoCPd_c::read(); + if (dusk::getSettings().game.enableGyroAim) { + dusk::gyro_aim::read(static_cast(frame_seconds), dusk::gyro_aim::queryGyroAimItemContext()); + } // EXECUTE GAME LOGIC & RENDER // This calls mDoGph_Painter -> JFWDisplay -> GX Functions