diff --git a/MarathonRecomp/api/Marathon.h b/MarathonRecomp/api/Marathon.h index 491e34b18..bd2c0e7dd 100644 --- a/MarathonRecomp/api/Marathon.h +++ b/MarathonRecomp/api/Marathon.h @@ -16,6 +16,7 @@ #include "CSD/Manager/csdmSubjectBase.h" #include "CSD/Platform/csdTexList.h" #include "Sonicteam/Actor.h" +#include "Sonicteam/ActorManager.h" #include "Sonicteam/AlertWindowTask.h" #include "Sonicteam/AppMarathon.h" #include "Sonicteam/AudioEngineXenon.h" @@ -36,21 +37,33 @@ #include "Sonicteam/MyGraphicsDevice.h" #include "Sonicteam/MyPhantom.h" #include "Sonicteam/MyTexture.h" +#include "Sonicteam/Player/GroundRayListener.h" #include "Sonicteam/Player/IDynamicLink.h" #include "Sonicteam/Player/IExportExternalFlag.h" #include "Sonicteam/Player/IExportPostureRequestFlag.h" #include "Sonicteam/Player/IExportWeaponRequestFlag.h" #include "Sonicteam/Player/IFlagCommunicator.h" #include "Sonicteam/Player/IGauge.h" +#include "Sonicteam/Player/INotification.h" #include "Sonicteam/Player/IPlugIn.h" +#include "Sonicteam/Player/IPostureControl.h" +#include "Sonicteam/Player/IPosturePlugIn.h" +#include "Sonicteam/Player/IPostureSupportEdge.h" +#include "Sonicteam/Player/IPostureSupportInput.h" +#include "Sonicteam/Player/IPostureSupportOttoto.h" +#include "Sonicteam/Player/IPostureSupportRayTemplate.h" +#include "Sonicteam/Player/IPostureSupportSphere.h" #include "Sonicteam/Player/IScore.h" #include "Sonicteam/Player/IStepable.h" #include "Sonicteam/Player/IVariable.h" #include "Sonicteam/Player/IZock.h" #include "Sonicteam/Player/Object.h" +#include "Sonicteam/Player/PostureControl.h" #include "Sonicteam/Player/RootFrame.h" #include "Sonicteam/Player/Score.h" #include "Sonicteam/Player/SonicGauge.h" +#include "Sonicteam/Player/ICollisionListener.h" +#include "Sonicteam/Player/ICollisionListenerTemplate.h" #include "Sonicteam/Player/State/CommonContext.h" #include "Sonicteam/Player/State/CommonFall.h" #include "Sonicteam/Player/State/CommonObject.h" @@ -65,10 +78,13 @@ #include "Sonicteam/Player/State/SonicObject.h" #include "Sonicteam/Player/State/SonicSpinDash.h" #include "Sonicteam/Player/State/TailsContext.h" +#include "Sonicteam/Player/Unit/ITestCase.h" +#include "Sonicteam/Player/Weapon/SonicWeapons.h" #include "Sonicteam/Player/Zock.h" #include "Sonicteam/SaveDataTask.h" #include "Sonicteam/SaveDataTaskXENON.h" #include "Sonicteam/SelectWindowTask.h" +#include "Sonicteam/SoX/LinkNode.h" #include "Sonicteam/SoX/AI/StateMachine.h" #include "Sonicteam/SoX/Audio/IAudioEngine.h" #include "Sonicteam/SoX/Component.h" @@ -88,7 +104,12 @@ #include "Sonicteam/SoX/Math/Vector.h" #include "Sonicteam/SoX/MessageReceiver.h" #include "Sonicteam/SoX/Object.h" +#include "Sonicteam/SoX/LinkNode.h" #include "Sonicteam/SoX/Physics/Entity.h" +#include "Sonicteam/SoX/Physics/IntersectEvent.h" +#include "Sonicteam/SoX/Physics/IntersectListener.h" +#include "Sonicteam/SoX/Physics/ShapeCastEvent.h" +#include "Sonicteam/SoX/Physics/ShapeCastListener.h" #include "Sonicteam/SoX/Physics/Havok/EntityHavok.h" #include "Sonicteam/SoX/Physics/Havok/EntityHavokImp.h" #include "Sonicteam/SoX/Physics/Havok/PhantomHavok.h" diff --git a/MarathonRecomp/api/Sonicteam/ActorManager.h b/MarathonRecomp/api/Sonicteam/ActorManager.h new file mode 100644 index 000000000..8e294b7f9 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/ActorManager.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +namespace Sonicteam +{ + class ActorManager + { + public: + be m_ActorID[0xFFFF]; + xpointer m_Actor[0xFFFF]; + be m_LastActorID; + be m_LastActorIndex; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/GameImp.h b/MarathonRecomp/api/Sonicteam/GameImp.h index 9b1459c01..5055bdcaa 100644 --- a/MarathonRecomp/api/Sonicteam/GameImp.h +++ b/MarathonRecomp/api/Sonicteam/GameImp.h @@ -27,7 +27,7 @@ namespace Sonicteam { be ActorID; be RingCount; - MARATHON_INSERT_PADDING(4); + be TownRingCount; be LifeCount; be ScoreCount; be AliveTime; diff --git a/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h b/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h new file mode 100644 index 000000000..948c47527 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/GroundRayListener.h @@ -0,0 +1,23 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +namespace Sonicteam::Player +{ + class GroundRayListener:public ICollisionListenerTemplate + { + public: + SoX::Math::Vector m_ContactPosition; + SoX::Math::Vector m_ContactNormal; + be m_RayDistance; //not sure + be m_RayFlag; //not sure + SoX::LinkRef m_ContactEntity; + MARATHON_INSERT_PADDING(0xC); + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/ICollisionListener.h b/MarathonRecomp/api/Sonicteam/Player/ICollisionListener.h new file mode 100644 index 000000000..5ed0e9b80 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/ICollisionListener.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include + +namespace Sonicteam::Player +{ + class ICollisionListener + { + public: + xpointer m_pVftable; + MARATHON_INSERT_PADDING(0xC); + be m_Flag1; + be m_Flag2; + be m_Flag3; + MARATHON_INSERT_PADDING(0x4); + SoX::Math::Vector m_CollisionNormal; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/ICollisionListenerTemplate.h b/MarathonRecomp/api/Sonicteam/Player/ICollisionListenerTemplate.h new file mode 100644 index 000000000..66c0747f7 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/ICollisionListenerTemplate.h @@ -0,0 +1,10 @@ +#pragma once + +#include +#include + +namespace Sonicteam::Player +{ + template + class ICollisionListenerTemplate:ICollisionListener,Cast {}; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/INotification.h b/MarathonRecomp/api/Sonicteam/Player/INotification.h new file mode 100644 index 000000000..0a2ea3dd9 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/INotification.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace Sonicteam::Player +{ + class INotification + { + public: + xpointer m_pVftable; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureControl.h b/MarathonRecomp/api/Sonicteam/Player/IPostureControl.h new file mode 100644 index 000000000..f5447b869 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureControl.h @@ -0,0 +1,50 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Sonicteam::Player +{ + class IPostureControl : public IVariable, public IDynamicLink, public Unit::ITestCase, public IFlagCommunicator + { + public: + SoX::RefSharedPointer m_spRootFrame; + SoX::Math::Quaternion m_RotationFixed; + SoX::Math::Vector m_PositionFixed; + SoX::RefSharedPointer m_spWorld; + boost::shared_ptr m_spGravity; + boost::shared_ptr m_spInputListener; + boost::shared_ptr m_spAmigoListener; + boost::shared_ptr m_ContextIF; + boost::shared_ptr m_spActorManager; + xpointer m_pTask; + boost::shared_ptr m_spPosturePlugIn; + SoX::Math::Vector m_GravityDirection; + be m_GravityForce; + SoX::Math::Vector m_NormalizedSurface; //ground normal? + SoX::Math::Vector m_Position; + SoX::Math::Quaternion m_Rotation; + MARATHON_INSERT_PADDING(0x20); + be m_PostureFlag; + be m_ImpulseForward; + be m_ImpulseVertical; + SoX::Math::Vector m_ImpulseUP; + be m_ContextIFFlag; + be m_PostureRequestFlag; + be m_PostureFlag118; + be m_PostureFlag11C; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPosturePlugIn.h b/MarathonRecomp/api/Sonicteam/Player/IPosturePlugIn.h new file mode 100644 index 000000000..fea96f109 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPosturePlugIn.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace Sonicteam::Player +{ + class IPosturePlugIn + { + public: + xpointer m_pVftable; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureSupportEdge.h b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportEdge.h new file mode 100644 index 000000000..1ea8aae53 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportEdge.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace Sonicteam::Player +{ + class IPostureSupportEdge + { + public: + xpointer m_pVftable; + MARATHON_INSERT_PADDING(0x70 - 4); + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureSupportInput.h b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportInput.h new file mode 100644 index 000000000..261f1d5a4 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportInput.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace Sonicteam::Player +{ + class IPostureSupportInput + { + public: + xpointer m_pVftable; + MARATHON_INSERT_PADDING(0x30 - 4); + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureSupportOttoto.h b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportOttoto.h new file mode 100644 index 000000000..6c2cef413 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportOttoto.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace Sonicteam::Player +{ + class IPostureSupportOttoto + { + public: + xpointer m_pVftable; + MARATHON_INSERT_PADDING(0x70 - 4); + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureSupportRayTemplate.h b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportRayTemplate.h new file mode 100644 index 000000000..59536ec5a --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportRayTemplate.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace Sonicteam::Player +{ + template + class IPostureSupportRayTemplate + { + public: + xpointer m_pVftable; + SoX::RefSharedPointer m_spWorld; + boost::shared_ptr m_spCollisionListener; + xpointer m_pRootFrame; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/IPostureSupportSphere.h b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportSphere.h new file mode 100644 index 000000000..02228ea5a --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/IPostureSupportSphere.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace Sonicteam::Player +{ + class IPostureSupportSphere + { + public: + xpointer m_pVftable; + MARATHON_INSERT_PADDING(0xD0 - 4); + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/Object.h b/MarathonRecomp/api/Sonicteam/Player/Object.h index 8ea599e9e..218f2f08a 100644 --- a/MarathonRecomp/api/Sonicteam/Player/Object.h +++ b/MarathonRecomp/api/Sonicteam/Player/Object.h @@ -2,44 +2,71 @@ #include #include +#include #include #include #include #include #include #include +#include +#include +#include +#include namespace Sonicteam::Player { - class Object : public Actor + #pragma pack(push, 1) + class __declspec(align(1)) Object : public Actor { + struct ObjectPlayerUpgrade + { + uint32_t global_flag; + uint32_t equip_flag; + }; + public: stdx::string m_PlayerLua; stdx::string m_PlayerPackage; - MARATHON_INSERT_PADDING(8); + be m_CameramanActorID; + xpointer m_Cameraman; be m_PlayerIndex; - MARATHON_INSERT_PADDING(0x2C); + be m_PlayerControllerIndex; + SoX::Math::Quaternion m_SpawnRotation; + SoX::Math::Vector m_SpawnPosition; + be m_SpawnRing; + SoX::RefSharedPointer m_spSpawnSource; // REF_TYPE(RefCountObject) bool m_IsPlayer; bool m_IsPosture; bool m_IsAmigo; MARATHON_INSERT_PADDING(1); SoX::RefSharedPointer m_spRootFrame; - MARATHON_INSERT_PADDING(0x14); + SoX::RefSharedPointer m_spPackageBinary; + boost::shared_ptr m_spPlayerModel; + boost::shared_ptr m_spPlayerPosture; boost::shared_ptr m_spStateMachine; - MARATHON_INSERT_PADDING(0x10); + boost::shared_ptr m_spPlayerGravity; + boost::shared_ptr m_spPlayerImpulse; be m_SetupModuleIndexPrefix; be m_SetupModuleIndexPostfix; boost::shared_ptr m_spGauge; MARATHON_INSERT_PADDING(8); stdx::vector> m_vspPlayerPlugins; - MARATHON_INSERT_PADDING(0x1F4); - + MARATHON_INSERT_PADDING(0x58); + be m_PlayerDelta; + MARATHON_INSERT_PADDING(0x48); + stdx::vector m_PlayerUpgrade; + stdx::string m_PlayerName; + MARATHON_INSERT_PADDING(0x134); + template inline T* GetGauge(); - + template inline T* GetPlugin(const char* pluginName); + }; + #pragma pack(pop) } #include diff --git a/MarathonRecomp/api/Sonicteam/Player/Object.inl b/MarathonRecomp/api/Sonicteam/Player/Object.inl index ed6ce292a..5324da751 100644 --- a/MarathonRecomp/api/Sonicteam/Player/Object.inl +++ b/MarathonRecomp/api/Sonicteam/Player/Object.inl @@ -1,3 +1,4 @@ +#include "Object.h" namespace Sonicteam::Player { template @@ -14,7 +15,6 @@ namespace Sonicteam::Player if (spPlugin->m_Name == pluginName) return static_cast(spPlugin.get()); } - return nullptr; - } + } } diff --git a/MarathonRecomp/api/Sonicteam/Player/PostureControl.h b/MarathonRecomp/api/Sonicteam/Player/PostureControl.h new file mode 100644 index 000000000..001a41d41 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/PostureControl.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Sonicteam::Player +{ + class PostureControl : public IPostureControl, public IPostureSupportSphere, public IPostureSupportOttoto, public IPostureSupportEdge, public IPostureSupportInput, public IPostureSupportRayTemplate + { + public: + //Gordon Ramsay + enum PostureFlag + { + PostureFlag_Ground = 0x1, // detects Ground + PostureFlag_WallBrushing = 0x8, // detects brushing against a wall + PostureFlag_HeadOnWall = 0x10, // detects head-on wall collision (will always be enabled w/ WallBrushing) + PostureFlag_RailGrind = 0x40, // Rail grinding + PostureFlag_BeforeFall = 0x100, // seems like Neutral or Pre-Fall? The moment before transitioning from the Jump to Fall animation + PostureFlag_Fall = 0x200, // FALL + PostureFlag_WaterCollision = 0x800, // Water collision (making you slide down an incline)? BeforeFall is often set with this + PostureFlag_LightDash = 0x4000, // Light Dashing + PostureFlag_QuickRotate = 0x8000, // is moving the control stick in a non-forward direction (usually only active for a frame since the character instantly rotates) + PostureFlag_Tentative = 0x10000, // is Tentative collision + PostureFlag_WaterSlide = 0x20000, // Water sliding + PostureFlag_Grass = 0x100000, // grass + PostureFlag_DirtClay = 0x200000, // dirt/clay + PostureFlag_Stone = 0x400000, // stone + PostureFlag_Shoreline = 0x1000000 // shoreline? sand? Uncertain + }; + // 0x314 ... 0x400 + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/Score.h b/MarathonRecomp/api/Sonicteam/Player/Score.h index ff270c709..5ee4d79c2 100644 --- a/MarathonRecomp/api/Sonicteam/Player/Score.h +++ b/MarathonRecomp/api/Sonicteam/Player/Score.h @@ -2,6 +2,7 @@ #include + namespace Sonicteam::Player { class Score : public IScore, public IVariable, public IStepable diff --git a/MarathonRecomp/api/Sonicteam/Player/SonicGauge.h b/MarathonRecomp/api/Sonicteam/Player/SonicGauge.h index 07b7dd9d0..d628e4114 100644 --- a/MarathonRecomp/api/Sonicteam/Player/SonicGauge.h +++ b/MarathonRecomp/api/Sonicteam/Player/SonicGauge.h @@ -12,6 +12,15 @@ namespace Sonicteam::Player be m_Flags; be m_GroundedFlags; be m_Maximum; - MARATHON_INSERT_PADDING(0x28); + be m_Green; + be m_Red; + be m_Blue; + be m_White; + be m_Sky; + be m_Yellow; + be m_Purple; + be m_Super; + be m_Heal; + be m_HealDelay; }; } diff --git a/MarathonRecomp/api/Sonicteam/Player/State/CommonContext.h b/MarathonRecomp/api/Sonicteam/Player/State/CommonContext.h index 11922870c..d2f141149 100644 --- a/MarathonRecomp/api/Sonicteam/Player/State/CommonContext.h +++ b/MarathonRecomp/api/Sonicteam/Player/State/CommonContext.h @@ -1,18 +1,29 @@ #pragma once - #include #include #include #include #include +#include namespace Sonicteam::Player::State { class CommonContext : public ICommonContext, public IExportPostureRequestFlag, public IExportWeaponRequestFlag { public: - MARATHON_INSERT_PADDING(0x90); - xpointer m_pScore; - MARATHON_INSERT_PADDING(0x104); + xpointer m_spComboAttackManager; + be m_ContextIFFlag1; + be m_ContextIFFlag2; + be m_ContextIFFlag3; + be m_ExportPostureRequestFlag; + be m_ExportWeaponRequestFlag; + MARATHON_INSERT_PADDING(0x14); + be m_PostureFlag; + be m_ExternalFlag; + be m_VehicleFlag; + be m_AmigoFlag; + MARATHON_INSERT_PADDING(0x50); + boost::shared_ptr m_pScore; //on merge, rename to spScore also do not forget about player_patches.cpp + MARATHON_INSERT_PADDING(0x100); }; } diff --git a/MarathonRecomp/api/Sonicteam/Player/State/ContextSpeedAndJump.h b/MarathonRecomp/api/Sonicteam/Player/State/ContextSpeedAndJump.h index 8a9f012a7..13be6b6d5 100644 --- a/MarathonRecomp/api/Sonicteam/Player/State/ContextSpeedAndJump.h +++ b/MarathonRecomp/api/Sonicteam/Player/State/ContextSpeedAndJump.h @@ -4,5 +4,11 @@ namespace Sonicteam::Player::State { - class ContextSpeedAndJump {}; + class ContextSpeedAndJump + { + be m_BaseSpeedForward; + be m_GimmickSpeedForward; + be m_BaseSpeedVertical; + be m_GimmickSpeedVertical; + }; } diff --git a/MarathonRecomp/api/Sonicteam/Player/State/ICommonContext.h b/MarathonRecomp/api/Sonicteam/Player/State/ICommonContext.h index 989ac55d5..583c06b4e 100644 --- a/MarathonRecomp/api/Sonicteam/Player/State/ICommonContext.h +++ b/MarathonRecomp/api/Sonicteam/Player/State/ICommonContext.h @@ -1,21 +1,28 @@ #pragma once - #include #include #include #include +#include +#include + namespace Sonicteam::Player::State { class ICommonContext : public IContext, public ICommonContextIF, public ContextSpeedAndJump { public: - MARATHON_INSERT_PADDING(0x10); - be m_StateID; - MARATHON_INSERT_PADDING(0x10); + be m_AnimationID; + be m_LockButtons; + be m_LastVelocityForward; + be m_LastVelocityVertical; + be m_LastLockButtons; be m_Buttons; - MARATHON_INSERT_PADDING(0x18); - be m_Field70; - MARATHON_INSERT_PADDING(0x1C); + be m_CurrentStickBorder; // 0 .. 1.0 + MARATHON_INSERT_PADDING(4); + be m_AnimationState; // & 2 == 0 (Animation End, no any idea about others) + MARATHON_INSERT_PADDING(0x2C); }; + //0x90 + } diff --git a/MarathonRecomp/api/Sonicteam/Player/State/Machine2.h b/MarathonRecomp/api/Sonicteam/Player/State/Machine2.h index 3fe896e79..522397b79 100644 --- a/MarathonRecomp/api/Sonicteam/Player/State/Machine2.h +++ b/MarathonRecomp/api/Sonicteam/Player/State/Machine2.h @@ -4,6 +4,7 @@ #include #include #include +#include namespace Sonicteam::Player::State { diff --git a/MarathonRecomp/api/Sonicteam/Player/State/SonicContext.h b/MarathonRecomp/api/Sonicteam/Player/State/SonicContext.h index 47ab0fe37..0d5f65059 100644 --- a/MarathonRecomp/api/Sonicteam/Player/State/SonicContext.h +++ b/MarathonRecomp/api/Sonicteam/Player/State/SonicContext.h @@ -1,8 +1,60 @@ #pragma once #include +#include +#include +#include namespace Sonicteam::Player::State { - class SonicContext : public CommonContext {}; + class SonicContext : public CommonContext + { + public: + //Sprite + enum GemSprite:uint32_t + { + GemSprite_Green = 1, + GemSprite_Red, + GemSprite_Blue, + GemSprite_White, + GemSprite_Sky, + GemSprite_Yellow, + GemSprite_Purple, + GemSprite_Super + }; + + enum Gem:uint32_t + { + Gem_Blue = 1, + Gem_Red, + Gem_Green, + Gem_Purple, + Gem_Sky, + Gem_White, + Gem_Yellow, + Gem_Super + }; + + be m_CurrentGemSprite; + boost::shared_ptr m_Gauge; + uint8_t m_HomingLockOn; + uint8_t m_DisablePlayerMovement; + uint8_t m_AntigravityHitBox; + uint8_t m_23F; + uint8_t m_BoundAttackHitBox; + uint8_t m_241; + uint8_t m_Shrink; + uint8_t m_ThunderGuard; + uint8_t m_Tornado; + uint8_t m_FPS; + uint8_t m_ThrowGem; + uint8_t m_SlowTime; + uint8_t m_MachAura; + uint8_t m_GemsEnabled; + uint8_t m_24A; + uint8_t m_24B; + be m_HomingFlip; + be m_CurrentGem; + MARATHON_INSERT_PADDING(0x58); + }; } diff --git a/MarathonRecomp/api/Sonicteam/Player/Unit/ITestCase.h b/MarathonRecomp/api/Sonicteam/Player/Unit/ITestCase.h new file mode 100644 index 000000000..64786d9fb --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/Unit/ITestCase.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace Sonicteam::Player::Unit +{ + class ITestCase + { + public: + xpointer m_pVftable; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/Player/Weapon/SonicWeapons.h b/MarathonRecomp/api/Sonicteam/Player/Weapon/SonicWeapons.h new file mode 100644 index 000000000..5fadba8a3 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/Player/Weapon/SonicWeapons.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Sonicteam::Player::Weapon +{ + class SonicWeapons : public IPlugIn, public IFlagCommunicator, public IStepable, public IDynamicLink, public IVariable, public INotification + { + public: + MARATHON_INSERT_PADDING(0x4C); + SoX::LinkRef m_GunDrive; + MARATHON_INSERT_PADDING(0x24); + }; +} diff --git a/MarathonRecomp/api/Sonicteam/SoX/LinkNode.h b/MarathonRecomp/api/Sonicteam/SoX/LinkNode.h new file mode 100644 index 000000000..92280d7d1 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/SoX/LinkNode.h @@ -0,0 +1,27 @@ +#pragma once + +namespace Sonicteam::SoX +{ + template + class LinkNodeTemplate + { + public: + xpointer m_pPrev; + xpointer m_pNext; + }; + + template + class LinkNode : public LinkNodeTemplate> + { + public: + xpointer> m_pThis; + }; + + template + class LinkRef + { + public: + xpointer m_pElement; + SoX::LinkNode m_lnElement; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectEvent.h b/MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectEvent.h new file mode 100644 index 000000000..2156724c1 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectEvent.h @@ -0,0 +1,9 @@ +#pragma once + +#include +#include + +namespace Sonicteam::SoX::Physics +{ + class IntersectEvent {}; +} diff --git a/MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectListener.h b/MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectListener.h new file mode 100644 index 000000000..247b6763b --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/SoX/Physics/IntersectListener.h @@ -0,0 +1,9 @@ +#pragma once + +#include +#include + +namespace Sonicteam::SoX::Physics +{ + class IntersectListener : public SoX::RefCountObject {}; +} diff --git a/MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastEvent.h b/MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastEvent.h new file mode 100644 index 000000000..14e9e4a91 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastEvent.h @@ -0,0 +1,9 @@ +#pragma once + +#include +#include + +namespace Sonicteam::SoX::Physics +{ + class ShapeCastEvent {}; +} diff --git a/MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastListener.h b/MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastListener.h new file mode 100644 index 000000000..281a2c81a --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/SoX/Physics/ShapeCastListener.h @@ -0,0 +1,9 @@ +#pragma once + +#include +#include + +namespace Sonicteam::SoX::Physics +{ + class ShapeCastListener : public SoX::RefCountObject {}; +} diff --git a/MarathonRecomp/api/stdx/vector.h b/MarathonRecomp/api/stdx/vector.h index c58a904ab..8a3e6c59c 100644 --- a/MarathonRecomp/api/stdx/vector.h +++ b/MarathonRecomp/api/stdx/vector.h @@ -514,4 +514,4 @@ namespace stdx { return !(lhs < rhs); } -} +} \ No newline at end of file diff --git a/MarathonRecomp/patches/player_patches.cpp b/MarathonRecomp/patches/player_patches.cpp index a3104b170..fc3806f9f 100644 --- a/MarathonRecomp/patches/player_patches.cpp +++ b/MarathonRecomp/patches/player_patches.cpp @@ -183,3 +183,228 @@ bool ControllableSpinkick() { return Config::ControllableSpinkick; } + + +///////////////////////////////////////////////////////// +////////// Sonic Gauge Restoration EX Version ///////// +//////////////////////////////////////////////////////// + +const Sonicteam::Player::State::SonicContext::GemSprite gemConversionTable[] = { + Sonicteam::Player::State::SonicContext::GemSprite_Blue, + Sonicteam::Player::State::SonicContext::GemSprite_Red, + Sonicteam::Player::State::SonicContext::GemSprite_Green, + Sonicteam::Player::State::SonicContext::GemSprite_Purple, + Sonicteam::Player::State::SonicContext::GemSprite_Sky, + Sonicteam::Player::State::SonicContext::GemSprite_White, + Sonicteam::Player::State::SonicContext::GemSprite_Yellow, + Sonicteam::Player::State::SonicContext::GemSprite_Super +}; + +//Check Gauge Drain +//SonicTeam::Player::SonicGauge (IVariable), IVariable::Init(RefSharedPointer) +PPC_FUNC_IMPL(__imp__sub_82217FC0); +PPC_FUNC(sub_82217FC0) { + + if (!Config::SonicGauge) + { + __imp__sub_82217FC0(ctx, base); + return; + } + + auto context = (Sonicteam::Player::State::SonicContext*)g_memory.Translate(ctx.r3.u32); + auto gauge = context->m_Gauge.get(); + + using enum Sonicteam::Player::State::SonicContext::Gem; + auto gem_id = (Sonicteam::Player::State::SonicContext::Gem)(ctx.r4.u32); + + switch (gem_id) + { + case Gem_Yellow: + if (context->m_ThunderGuard) break; //Prevent Yellow Gem spam, useless anyway + case Gem_Blue: + case Gem_Green: + case Gem_Sky: + case Gem_White: + case Gem_Super: + { + size_t index = gemConversionTable[gem_id - 1] - 1; + if (gauge->m_Value >= (&gauge->m_Green)[index].get()) + { + ctx.r3.u64 = 1; + return; + } + break; + } + case Gem_Red: + case Gem_Purple: + if (context->m_24A == 0) + { + ctx.r3.u64 = 1; + return; + } + break; + } + ctx.r3.u64 = 0; + return; + +} +//Gauge Drain +PPC_FUNC_IMPL(__imp__sub_82218068); +PPC_FUNC(sub_82218068) { + + if (!Config::SonicGauge) + { + __imp__sub_82217FC0(ctx, base); + return; + } + + auto context = (Sonicteam::Player::State::SonicContext*)g_memory.Translate(ctx.r3.u32); + auto gauge = context->m_Gauge.get(); + + using enum Sonicteam::Player::State::SonicContext::Gem; + auto gem_id = (Sonicteam::Player::State::SonicContext::Gem)(ctx.r4.u32); + double delta = ctx.f1.f64; + + switch (gem_id) + { + case Gem_Blue: + case Gem_Green: + case Gem_Yellow: + case Gem_Sky: + case Gem_White: + case Gem_Super: + { + uint32_t index = gemConversionTable[gem_id - 1] - 1; + gauge->m_Value = gauge->m_Value.get() - (&gauge->m_Green)[index].get(); + gauge->m_GroundedTime = 0.0; + break; + } + case Gem_Red: + case Gem_Purple: + { + uint32_t index = gemConversionTable[gem_id - 1] - 1; + gauge->m_Value = gauge->m_Value.get() - (&gauge->m_Green)[index].get() * delta; + gauge->m_GroundedTime = 0.0; + if (gauge->m_Value <= 0) + { + gauge->m_Value = 0.0; + context->m_Shrink = 0; + context->m_SlowTime = 0; + context->m_24A = 1; + + } + break; + } + } +} + + +PPC_FUNC_IMPL(__imp__sub_8223F360); +PPC_FUNC(sub_8223F360) { + + auto IVariable = ctx.r3.u32; + auto RefTypeLuaSystem = ctx.r4.u32; + __imp__sub_8223F360(ctx, base); + if (!Config::SonicGauge) + return; + + auto gauge = (Sonicteam::Player::SonicGauge*)g_memory.Translate(IVariable - 0x20); + auto buffer = g_userHeap.Alloc(); + + // if (gauge->m_Gem == 0.0) if m_Gem not intitialized by __imp__sub_8223F360 + *buffer = "c_gauge_green"; + if (gauge->m_Green.get() == 0.0) + gauge->m_Green = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_red"; + if (gauge->m_Red.get()== 0.0) + gauge->m_Red = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_blue"; + if (gauge->m_Blue.get() == 0.0) + gauge->m_Blue = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_white"; + if (gauge->m_White.get() == 0.0) + gauge->m_White = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_sky"; + if (gauge->m_Sky.get() == 0.0) + gauge->m_Sky = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_yellow"; + if (gauge->m_Yellow.get() == 0.0) + gauge->m_Yellow = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_purple"; + if (gauge->m_Purple.get() == 0.0) + gauge->m_Purple = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + *buffer = "c_gauge_super"; + if (gauge->m_Super.get() == 0.0) + gauge->m_Super = GuestToHostFunction(sub_821EA350, RefTypeLuaSystem, g_memory.MapVirtual(buffer)); + + + buffer->~string(); + g_userHeap.Free(buffer); + + /* For Testing + gauge->m_Green = 10; + gauge->m_Blue = 20; + gauge->m_White = 40; + gauge->m_Sky = 60; + gauge->m_Yellow = 80; + gauge->m_Super = 100; + gauge->m_Red = 20; + gauge->m_Purple = 40; + */ +} + +void SonicGaugeRestorationGaugeGemSpriteResetFix(PPCRegister& r_GameImp) { + + Sonicteam::GameImp* pGameImp = (Sonicteam::GameImp*)g_memory.Translate(r_GameImp.u32); + for (int i = 0; i < 4; i++) + pGameImp->m_PlayerData[i].GemIndex = 0; +} + +void SonicGaugeRestorationGaugeFlagFix(PPCRegister& r_gauge, PPCRegister& r_context) { + + if (!Config::SonicGauge || !r_gauge.u32) + return; + + auto pGauge = (Sonicteam::Player::SonicGauge*)g_memory.Translate(r_gauge.u32); + auto PContext = (Sonicteam::Player::State::SonicContext*)g_memory.Translate(r_context.u32); + + if ((uint32_t)(static_cast(pGauge)->m_pVftable.get()) != 0x8200D4D8) // != SonicGauge + return; + + auto weapons = PContext->m_pScore->m_pPlayer->GetPlugin("sonic_weapons"); + if (PContext->m_Tornado != 0 || PContext->m_AnimationID == 0xCB || PContext->m_AnimationID == 0xCC || PContext->m_AnimationID == 0x46 || PContext->m_AnimationID == 0xCE || weapons->m_GunDrive.m_pElement.get() != nullptr) + { + pGauge->m_GroundedFlags = 1; // Lock gauge + } + else + { + using enum Sonicteam::Player::State::SonicContext::Gem; + if ((PContext->m_Buttons.get() & 0x10000) != 0) { + PContext->m_24A = 0; + } + + if ((PContext->m_Buttons.get() & 0x20000) != 0 && (PContext->m_CurrentGem == Gem_Red || PContext->m_CurrentGem == Gem_Purple)) + { + pGauge->m_GroundedFlags = 1; + if (PContext->m_24A) + { + pGauge->m_GroundedFlags = 0; + PContext->m_Shrink = 0; + PContext->m_SlowTime = 0; + } + } + else if ((PContext->m_PostureFlag.get() & Sonicteam::Player::PostureControl::PostureFlag_Ground) != 0 || PContext->m_24A) + { + pGauge->m_GroundedFlags = 0; + + } + } +} +//Sonic Gauge Restoration diff --git a/MarathonRecomp/user/config_def.h b/MarathonRecomp/user/config_def.h index 6ff529718..086d68b18 100644 --- a/MarathonRecomp/user/config_def.h +++ b/MarathonRecomp/user/config_def.h @@ -86,6 +86,7 @@ CONFIG_DEFINE_HIDDEN("Codes", bool, RestoreContextualHUDColours, false); CONFIG_DEFINE_HIDDEN("Codes", bool, DisableEdgeGrabLeftover, false); CONFIG_DEFINE_HIDDEN("Codes", bool, TailsGauge, false); CONFIG_DEFINE_HIDDEN("Codes", bool, PlayerDebugMode, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, SonicGauge, false); CONFIG_DEFINE_HIDDEN("Codes", bool, MidairControlForMachSpeed, false); CONFIG_DEFINE_HIDDEN("Codes", bool, MidairControlForSnowboards, false); CONFIG_DEFINE_HIDDEN("Codes", bool, ControllableTeleportDash, false); diff --git a/MarathonRecompLib/config/Marathon.toml b/MarathonRecompLib/config/Marathon.toml index 852886a90..6f7d2a697 100644 --- a/MarathonRecompLib/config/Marathon.toml +++ b/MarathonRecompLib/config/Marathon.toml @@ -117,6 +117,7 @@ name = "ContextualHUD_LIFE_BER_ANIME_1" address = 0x824D8F2C registers = ["r5", "r31"] + [[midasm_hook]] name = "ContextualHUD_RING_1" address = 0x824DEB38 @@ -337,3 +338,23 @@ jump_address = 0x8258E308 name = "NOP" address = 0x8258E600 jump_address = 0x8258E604 + +[[midasm_hook]] +name = "SonicGaugeRestorationGaugeFlagFix" +address = 0x822196EC +registers = ["r3","r31"] + +[[midasm_hook]] +name = "SonicGaugeRestorationGaugeGemSpriteResetFix" +address = 0x82185768 +registers = ["r30"] + +[[midasm_hook]] +name = "SonicGaugeRestorationGaugeGemSpriteResetFix" +address = 0x821855A4 +registers = ["r29"] + +[[midasm_hook]] +name = "SonicGaugeRestorationGaugeGemSpriteResetFix" +address = 0x82177DFC +registers = ["r31"] diff --git a/thirdparty/SDL b/thirdparty/SDL index 98d1f3a45..1edaad172 160000 --- a/thirdparty/SDL +++ b/thirdparty/SDL @@ -1 +1 @@ -Subproject commit 98d1f3a45aae568ccd6ed5fec179330f47d4d356 +Subproject commit 1edaad17218d67b567c149badce9ef0fc67f65fa diff --git a/thirdparty/ddspp b/thirdparty/ddspp index 98ce1d384..1390499ec 160000 --- a/thirdparty/ddspp +++ b/thirdparty/ddspp @@ -1 +1 @@ -Subproject commit 98ce1d384706c8d7121876742a786f4eb89a23ef +Subproject commit 1390499ec9f7b82e7a9cbdeb2e6191808e981f84 diff --git a/tools/XenonRecomp b/tools/XenonRecomp index c3714b8d7..b3d25ae01 160000 --- a/tools/XenonRecomp +++ b/tools/XenonRecomp @@ -1 +1 @@ -Subproject commit c3714b8d7d35d202df293c4965b52bd74ae9df02 +Subproject commit b3d25ae01db833d58168a0d2a7cb6b7c71a4c4c1 diff --git a/tools/XenosRecomp b/tools/XenosRecomp index 3938ef646..2d3320dba 160000 --- a/tools/XenosRecomp +++ b/tools/XenosRecomp @@ -1 +1 @@ -Subproject commit 3938ef6464e08542f31b3941ee4543c3df6d20d1 +Subproject commit 2d3320dba5dbdfb3abd6d67ae6111918fbd8377b