Implemented camera aspect ratio hooks

This commit is contained in:
Hyper
2024-10-17 19:15:36 +01:00
parent 02c9484c9c
commit 3c1c13e4ce
17 changed files with 307 additions and 7 deletions

View File

@@ -0,0 +1,8 @@
#pragma once
#include "SWA/Camera/Camera.h"
#include "SWA/Player/Character/EvilSonic/EvilSonicContext.h"
#include "SWA/System/ApplicationDocument.h"
#include "SWA/System/GameDocument.h"
#include "SWA/System/InputState.h"
#include "SWA/System/PadState.h"

View File

@@ -0,0 +1,9 @@
#pragma once
#include <cpu/guest_code.h>
#define SWA__CONCAT2(x, y) x##y
#define SWA_CONCAT2(x, y) _CONCAT(x, y)
#define SWA_INSERT_PADDING(length) \
uint8_t SWA_CONCAT2(pad, __LINE__)[length]

View File

@@ -0,0 +1,19 @@
#pragma once
#include "SWA.inl"
namespace SWA
{
class CCamera // : public CGameObject, public Hedgehog::Universe::TStateMachine<CCamera>
{
public:
SWA_INSERT_PADDING(0x184);
be<float> m_VertAspectRatio;
SWA_INSERT_PADDING(0x48);
be<float> m_HorzAspectRatio;
SWA_INSERT_PADDING(0x178);
be<float> m_FieldOfView;
be<float> m_VertFieldOfView;
be<float> m_HorzFieldOfView;
};
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include "SWA.inl"
namespace SWA::Player
{
class CEvilSonicContext // : public CPlayerContext
{
public:
SWA_INSERT_PADDING(0x688);
be<float> m_DarkGaiaEnergy;
SWA_INSERT_PADDING(0x138);
be<uint32_t> m_AnimationID;
};
}

View File

@@ -0,0 +1,19 @@
#pragma once
namespace SWA
{
class CApplicationDocument // : public Hedgehog::Base::CSynchronizedObject
{
public:
// TODO: Hedgehog::Base::TSynchronizedPtr<CApplicationDocument>*
inline static xpointer<CApplicationDocument>* ms_pInstance = (xpointer<CApplicationDocument>*)g_memory.Translate(0x833678A0);
// TODO: Hedgehog::Base::TSynchronizedPtr<CApplicationDocument>
static CApplicationDocument* GetInstance();
SWA_INSERT_PADDING(0x18);
be<uint32_t> m_Region;
};
}
#include "ApplicationDocument.inl"

View File

@@ -0,0 +1,8 @@
namespace SWA
{
// TODO: Hedgehog::Base::TSynchronizedPtr<CApplicationDocument>
inline CApplicationDocument* CApplicationDocument::GetInstance()
{
return *ms_pInstance;
}
}

View File

@@ -0,0 +1,26 @@
#pragma once
namespace SWA
{
class CGameDocument // : public Hedgehog::Base::CSynchronizedObject
{
public:
class CMember
{
public:
SWA_INSERT_PADDING(0x20C);
be<uint32_t> m_Score;
};
// TODO: Hedgehog::Base::TSynchronizedPtr<CGameDocument>*
inline static xpointer<CGameDocument>* ms_pInstance = (xpointer<CGameDocument>*)g_memory.Translate(0x83367900);
// TODO: Hedgehog::Base::TSynchronizedPtr<CGameDocument>
static CGameDocument* GetInstance();
SWA_INSERT_PADDING(0x08);
xpointer<CMember> m_pMember;
};
}
#include "GameDocument.inl"

View File

@@ -0,0 +1,8 @@
namespace SWA
{
// TODO: Hedgehog::Base::TSynchronizedPtr<CGameDocument>
inline CGameDocument* CGameDocument::GetInstance()
{
return *ms_pInstance;
}
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include "SWA.inl"
#include "PadState.h"
namespace SWA
{
class CInputState // : public Hedgehog::Base::CSynchronizedObject
{
public:
// TODO: Hedgehog::Base::TSynchronizedPtr<CInputState>*
inline static xpointer<CInputState>* ms_pInstance = (xpointer<CInputState>*)g_memory.Translate(0x833671EC);
// TODO: Hedgehog::Base::TSynchronizedPtr<CInputState>
static CInputState* GetInstance();
SPadState m_PadStates[40];
SWA_INSERT_PADDING(0x50);
be<uint32_t> m_CurrentPadStateIndex;
SWA_INSERT_PADDING(0x04);
const SPadState& GetPadState() const;
};
}
#include "InputState.inl"

View File

@@ -0,0 +1,13 @@
namespace SWA
{
// TODO: Hedgehog::Base::TSynchronizedPtr<CInputState>
inline CInputState* CInputState::GetInstance()
{
return *ms_pInstance;
}
inline const SPadState& CInputState::GetPadState() const
{
return m_PadStates[m_CurrentPadStateIndex];
}
}

View File

@@ -0,0 +1,77 @@
#pragma once
#include "SWA.inl"
namespace SWA
{
enum EKeyState : uint32_t
{
eKeyState_None = 0x0,
eKeyState_A = 0x1,
eKeyState_B = 0x2,
eKeyState_X = 0x8,
eKeyState_Y = 0x10,
eKeyState_DpadUp = 0x40,
eKeyState_DpadDown = 0x80,
eKeyState_DpadLeft = 0x100,
eKeyState_DpadRight = 0x200,
eKeyState_Start = 0x400,
eKeyState_Select = 0x800,
eKeyState_LeftBumper = 0x1000,
eKeyState_RightBumper = 0x2000,
eKeyState_LeftTrigger = 0x4000,
eKeyState_RightTrigger = 0x8000,
eKeyState_LeftStick = 0x10000,
eKeyState_RightStick = 0x20000,
eKeyState_LeftStickUp = 0x40000,
eKeyState_LeftStickDown = 0x80000,
eKeyState_LeftStickLeft = 0x100000,
eKeyState_LeftStickRight = 0x200000,
eKeyState_RightStickUp = 0x400000,
eKeyState_RightStickDown = 0x800000,
eKeyState_RightStickLeft = 0x1000000,
eKeyState_RightStickRight = 0x2000000
};
struct SPadState
{
SWA_INSERT_PADDING(0x20);
be<uint32_t> DownState;
be<uint32_t> UpState;
be<uint32_t> TappedState;
be<uint32_t> ReleasedState;
SWA_INSERT_PADDING(0x04);
be<float> LeftStickHorizontal;
be<float> LeftStickVertical;
SWA_INSERT_PADDING(0x04);
be<float> RightStickHorizontal;
be<float> RightStickVertical;
SWA_INSERT_PADDING(0x04);
be<float> LeftTrigger;
be<float> RightTrigger;
SWA_INSERT_PADDING(0x20);
bool IsDown(const EKeyState in_Keys) const;
bool IsUp(const EKeyState in_Keys) const;
bool IsTapped(const EKeyState in_Keys) const;
bool IsReleased(const EKeyState in_Keys) const;
};
}
#include "PadState.inl"

View File

@@ -0,0 +1,22 @@
namespace SWA
{
inline bool SPadState::IsDown(const EKeyState in_Keys) const
{
return (DownState & in_Keys) == in_Keys;
}
inline bool SPadState::IsUp(const EKeyState in_Keys) const
{
return (UpState & in_Keys) == in_Keys;
}
inline bool SPadState::IsTapped(const EKeyState in_Keys) const
{
return (TappedState & in_Keys) == in_Keys;
}
inline bool SPadState::IsReleased(const EKeyState in_Keys) const
{
return (ReleasedState & in_Keys) == in_Keys;
}
}