api: update research

This commit is contained in:
Hyper 2024-11-24 09:22:17 +00:00
parent b8da31869e
commit 0b800cf691
44 changed files with 326 additions and 67 deletions

View file

@ -2,7 +2,5 @@
namespace Chao::CSD
{
class CBase
{
};
class CBase {};
}

View file

@ -13,9 +13,9 @@ namespace Chao::CSD
class CNode : public CResourceBase<Node>, SubjectBase<CNodeObserver, CNode>, CBase
{
public:
SWA_INSERT_PADDING(0x4C);
SWA_INSERT_PADDING(0x50);
~CNode() override = default;
~CNode();
void SetText(const char* in_pText);
void SetText(const wchar_t* in_pText);

View file

@ -2,6 +2,11 @@
namespace Chao::CSD
{
inline CNode::~CNode()
{
SWA_VIRTUAL_FUNCTION(void, 0, this);
}
inline void CNode::SetText(const char* in_pText)
{
GuestToHostFunction<int>(0x830BF640, this, in_pText);

View file

@ -6,7 +6,5 @@ namespace Chao::CSD
{
class CNode;
class CNodeObserver : public CObserverBase<CNode>
{
};
class CNodeObserver : public CObserverBase<CNode> {};
}

View file

@ -8,8 +8,16 @@ namespace Chao::CSD
class CObserverBase
{
public:
SWA_INSERT_PADDING(0x0C);
struct Vftable
{
be<uint32_t> m_fpDtor;
};
virtual ~CObserverBase() = default;
xpointer<Vftable> m_pVftable;
SWA_INSERT_PADDING(0x08);
~CObserverBase();
};
}
#include "CSD/Manager/csdmObserverBase.inl"

View file

@ -0,0 +1,8 @@
namespace Chao::CSD
{
template<typename TObservee>
inline CObserverBase<TObservee>::~CObserverBase()
{
GuestToHostFunction<void>(m_pVftable->m_fpDtor, this);
}
}

View file

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "CSD/Manager/csdmRCPtrAbs.h"
@ -7,14 +7,22 @@ namespace Chao::CSD
class RCPtrAbs::RCObject
{
public:
struct Vftable
{
be<uint32_t> m_fpDtor;
be<uint32_t> m_fpDeallocate;
};
xpointer<Vftable> m_pVftable;
xpointer<void> m_pMemory;
be<uint32_t> m_RefCount;
xpointer<void> m_pDealloctor;
be<uint32_t> m_eDealloctor;
virtual ~RCObject();
virtual void Deallocate(void* in_pMemory) = 0;
~RCObject();
void Deallocate(void* in_pMemory);
void Release();
};
}
#include "CSD/Manager/csdmRCObject.inl"

View file

@ -1,13 +1,14 @@
namespace Chao::CSD
{
inline void RCPtrAbs::RCObject::Release()
inline RCPtrAbs::RCObject::~RCObject()
{
GuestToHostFunction<void>(0x830BA068, this);
GuestToHostFunction<void>(m_pVftable->m_fpDtor, this);
}
inline RCPtrAbs::~RCPtrAbs()
{
RCObject* pObj = m_pObject;
RCPtrAbs::RCObject* pObj = m_pObject;
m_pObject = nullptr;
if (pObj)
@ -21,4 +22,14 @@ namespace Chao::CSD
return m_pObject->m_pMemory;
}
inline void RCPtrAbs::RCObject::Deallocate(void* in_pMemory)
{
GuestToHostFunction<void>(m_pVftable->m_fpDeallocate, this, in_pMemory);
}
inline void RCPtrAbs::RCObject::Release()
{
GuestToHostFunction<void>(0x830BA068, this);
}
}

View file

@ -5,8 +5,5 @@
namespace Chao::CSD
{
template<typename T>
class RCPtr<T>::RCObjectImp : public RCObject
{
void Deallocate(void* in_pMemory) override;
};
class RCPtr<T>::RCObjectImp : public RCObject {};
}

View file

@ -15,8 +15,6 @@ namespace Chao::CSD
RCPtr(const RCPtr& in_rOther) : RCPtrAbs(in_rOther) {}
RCPtr(RCPtr&& in_rOther) : RCPtrAbs(std::move(in_rOther)) {}
RCObject* CreateRCObject() override;
void Attach(T* in_pObject);
T* Get() const;
@ -30,3 +28,5 @@ namespace Chao::CSD
operator bool() const;
};
}
#include "CSD/Manager/csdmRCPtr.inl"

View file

@ -9,6 +9,13 @@ namespace Chao::CSD
public:
class RCObject;
struct Vftable
{
be<uint32_t> m_fpDtor;
be<uint32_t> m_fpCreateRCObject;
};
xpointer<Vftable> m_pVftable;
xpointer<RCObject> m_pObject;
RCPtrAbs();
@ -16,8 +23,8 @@ namespace Chao::CSD
RCPtrAbs(const RCPtrAbs& in_rOther);
RCPtrAbs(RCPtrAbs&& in_rPtr);
virtual ~RCPtrAbs();
virtual RCObject* CreateRCObject() = 0;
~RCPtrAbs();
RCObject* CreateRCObject();
void AttachAbs(void* in_pMemory);
void* GetAbs() const;
@ -31,3 +38,5 @@ namespace Chao::CSD
operator bool() const;
};
}
#include "CSD/Manager/csdmRCPtrAbs.inl"

View file

@ -20,6 +20,11 @@ namespace Chao::CSD
in_rPtr.m_pObject = nullptr;
}
inline RCPtrAbs::RCObject* RCPtrAbs::CreateRCObject()
{
return GuestToHostFunction<RCPtrAbs::RCObject*>(m_pVftable->m_fpCreateRCObject, this);
}
inline void RCPtrAbs::AttachAbs(void* in_pMemory)
{
GuestToHostFunction<void>(0x830BA298, this, in_pMemory);

View file

@ -8,11 +8,19 @@ namespace Chao::CSD
class CResourceBase
{
public:
struct Vftable
{
be<uint32_t> m_fpDtor;
be<uint32_t> m_fpCopyResource;
};
xpointer<Vftable> m_pVftable;
RCPtr<uint8_t> m_rcResourceHolder;
xpointer<T> m_pResource;
virtual ~CResourceBase() = default;
virtual void CopyResource(const CResourceBase& in_rOther);
~CResourceBase();
void CopyResource(const CResourceBase& in_rOther);
};
}
#include "CSD/Manager/csdmResourceBase.h"

View file

@ -1,7 +1,13 @@
namespace Chao::CSD
{
template<typename T>
void CResourceBase<T>::CopyResource(const CResourceBase& in_rOther)
inline CResourceBase<T>::~CResourceBase()
{
GuestToHostFunction<void>(m_pVftable->m_fpDtor, this);
}
template<typename T>
inline void CResourceBase<T>::CopyResource(const CResourceBase& in_rOther)
{
m_rcResourceHolder = in_rOther.m_rcResourceHolder;
m_pResource = in_rOther.m_pResource;

View file

@ -23,7 +23,7 @@ namespace Chao::CSD
class CScene : public CResourceBase<Scene>, SubjectBase<CSceneObserver, CScene>, CBase
{
public:
SWA_INSERT_PADDING(0x5C);
SWA_INSERT_PADDING(0x60);
be<float> m_PrevMotionFrame;
be<float> m_MotionFrame;
be<float> m_MotionSpeed;
@ -35,22 +35,9 @@ namespace Chao::CSD
be<EMotionRepeatType> m_MotionRepeatType;
SWA_INSERT_PADDING(0x2C);
~CScene() override = default;
// Update should be called with a delta time of zero
// after making changes to a motion.
// Example:
// SetMotion("Intro_Anim");
// SetMotionFrame(0.0);
// m_MotionSpeed = 2.0f;
// Update(0.0f);
// Changes are not going to be recognized if
// update is not called.
virtual void Update(float in_DeltaTime = 0.0f);
virtual void Render(void*);
~CScene();
void Update(float in_DeltaTime = 0.0f);
void Render(void* in_pUnk);
RCPtr<CNode> GetNode(const char* in_pName) const;
@ -62,3 +49,5 @@ namespace Chao::CSD
void SetScale(float in_X, float in_Y);
};
}
#include "CSD/Manager/csdmScene.inl"

View file

@ -1,5 +1,20 @@
namespace Chao::CSD
{
inline CScene::~CScene()
{
SWA_VIRTUAL_FUNCTION(void, 0, this);
}
inline void CScene::Update(float in_DeltaTime)
{
SWA_VIRTUAL_FUNCTION(void, 2, this, in_DeltaTime);
}
inline void CScene::Render(void* in_pUnk)
{
SWA_VIRTUAL_FUNCTION(void, 3, this, in_pUnk);
}
inline RCPtr<CNode> CScene::GetNode(const char* in_pName) const
{
RCPtr<CNode> rcNode;

View file

@ -6,7 +6,5 @@ namespace Chao::CSD
{
class CScene;
class CSceneObserver : public CObserverBase<CScene>
{
};
class CSceneObserver : public CObserverBase<CScene> {};
}

View file

@ -8,9 +8,18 @@ namespace Chao::CSD
class SubjectBase
{
public:
struct Vftable
{
be<uint32_t> m_fpDtor;
be<uint32_t> m_fpGetObservee;
};
xpointer<Vftable> m_pVftable;
SWA_INSERT_PADDING(0x0C);
virtual ~SubjectBase() = default;
virtual TObservee* GetObservee() const { return nullptr; }
~SubjectBase();
TObservee* GetObservee() const;
};
}
#include "CSD/Manager/csdmSubjectBase.inl"

View file

@ -0,0 +1,14 @@
namespace Chao::CSD
{
template<typename TObserver, typename TObservee>
inline SubjectBase<TObserver, TObservee>::~SubjectBase()
{
GuestToHostFunction<void>(m_pVftable->m_fpDtor, this);
}
template<typename TObserver, typename TObservee>
inline TObservee* SubjectBase<TObserver, TObservee>::GetObservee() const
{
return nullptr;
}
}

View file

@ -8,8 +8,16 @@ namespace Chao::CSD
class CTexList : public CBase
{
public:
struct Vftable
{
be<uint32_t> m_fpDtor;
};
xpointer<Vftable> m_pVftable;
RCPtr<uint8_t> m_rcData;
virtual ~CTexList() = default;
~CTexList();
};
}
#include "CSD/Platform/csdTexList.inl"

View file

@ -0,0 +1,7 @@
namespace Chao::CSD
{
inline CTexList::~CTexList()
{
GuestToHostFunction<void>(m_pVftable->m_fpDtor, this);
}
}

View file

@ -15,11 +15,18 @@ namespace Hedgehog::Database
class CDatabaseData : public Base::CObject
{
public:
uint8_t m_Flags; // see EDatabaseDataFlags
SWA_INSERT_PADDING(0x04); // TODO: Base::CSharedString m_TypeAndName;
struct Vftable
{
be<uint32_t> m_fpDtor;
be<uint32_t> m_fpCheckMadeAll;
};
virtual ~CDatabaseData() = default;
virtual bool CheckMadeAll();
xpointer<Vftable> m_pVftable;
uint8_t m_Flags;
Base::CSharedString m_TypeAndName;
~CDatabaseData();
bool CheckMadeAll();
bool IsMadeOne() const;
void SetMadeOne();

View file

@ -1,5 +1,10 @@
namespace Hedgehog::Database
{
inline CDatabaseData::~CDatabaseData()
{
GuestToHostFunction<void>(m_pVftable->m_fpDtor, this);
}
inline bool CDatabaseData::CheckMadeAll()
{
return true;

View file

@ -8,7 +8,7 @@ namespace Hedgehog::Mirage
class CRenderable : public Base::CObject
{
public:
xpointer<void> m_pVftable;
bool m_Enabled;
be<float> m_SortDepth;
};
}

View file

@ -8,8 +8,8 @@ namespace Hedgehog::Universe
class CUpdateUnit : public Base::CObject, public IParallelJob
{
public:
SWA_INSERT_PADDING(0x04); // vftable ptr
SWA_INSERT_PADDING(0x24);
xpointer<void> m_pVftable;
SWA_INSERT_PADDING(0x20);
CUpdateUnit(const swa_null_ctor& nil) : CObject(nil), IParallelJob(nil) {}
CUpdateUnit();

View file

@ -8,7 +8,7 @@ namespace Hedgehog::Universe
class IParallelJob
{
public:
SWA_INSERT_PADDING(0x04); // vftable ptr
xpointer<void> m_pVftable;
IParallelJob() {}
IParallelJob(const swa_null_ctor&) {}

View file

@ -38,9 +38,15 @@
#include "SWA/CSD/GameObjectCSD.h"
#include "SWA/HUD/Loading/Loading.h"
#include "SWA/HUD/Pause/HudPause.h"
#include "SWA/HUD/Sonic/HudSonicStage.h"
#include "SWA/Movie/MovieDisplayer.h"
#include "SWA/Movie/MovieManager.h"
#include "SWA/Player/Character/EvilSonic/Hud/EvilHudGuide.h"
#include "SWA/Player/Character/EvilSonic/EvilSonic.h"
#include "SWA/Player/Character/EvilSonic/EvilSonicContext.h"
#include "SWA/Sequence/Unit/SequenceUnitBase.h"
#include "SWA/Sequence/Unit/SequenceUnitPlayMovie.h"
#include "SWA/Sequence/Utility/SequencePlayMovieWrapper.h"
#include "SWA/Sound/Sound.h"
#include "SWA/Sound/SoundBGMActSonic.h"
#include "SWA/Sound/SoundBGMBase.h"
@ -48,6 +54,7 @@
#include "SWA/System/GameMode/Title/TitleStateBase.h"
#include "SWA/System/GameMode/GameMode.h"
#include "SWA/System/GameMode/GameModeStage.h"
#include "SWA/System/GameMode/GameModeStageMovie.h"
#include "SWA/System/Application.h"
#include "SWA/System/ApplicationD3D9.h"
#include "SWA/System/ApplicationXenon.h"

View file

@ -9,4 +9,7 @@
#define SWA_INSERT_PADDING(length) \
uint8_t SWA_CONCAT2(pad, __LINE__)[length]
#define SWA_VIRTUAL_FUNCTION(returnType, virtualIndex, ...) \
GuestToHostFunction<returnType>(*(be<uint32_t>*)(g_memory.Translate(*(be<uint32_t>*)(this) + (4 * virtualIndex))), __VA_ARGS__)
struct swa_null_ctor {};

View file

@ -14,6 +14,7 @@ namespace SWA
class CGameObjectCSD : public CGameObject
{
public:
xpointer<void> m_pVftable;
Chao::CSD::RCPtr<Chao::CSD::CProject> m_rcProject;
};
}

View file

@ -8,6 +8,7 @@ namespace SWA
class CCamera : public CGameObject // , public Hedgehog::Universe::TStateMachine<CCamera>
{
public:
xpointer<void> m_pVftable;
SWA_INSERT_PADDING(0xC4);
be<float> m_VertAspectRatio;
SWA_INSERT_PADDING(0x48);

View file

@ -46,6 +46,7 @@ namespace SWA
class CHudPause : public CGameObject
{
public:
xpointer<void> m_pVftable;
SWA_INSERT_PADDING(0xC8);
be<EActionType> m_Action;
be<EMenuType> m_Menu;

View file

@ -0,0 +1,22 @@
#pragma once
#include <SWA.inl>
namespace SWA
{
class CHudSonicStage
{
public:
SWA_INSERT_PADDING(0xE0);
Chao::CSD::RCPtr<Chao::CSD::CProject> m_rcPlayScreen;
Chao::CSD::RCPtr<Chao::CSD::CScene> m_rcSpeedGauge;
Chao::CSD::RCPtr<Chao::CSD::CScene> m_rcRingEnergyGauge;
Chao::CSD::RCPtr<Chao::CSD::CScene> m_rcGaugeFrame;
SWA_INSERT_PADDING(0x28);
Chao::CSD::RCPtr<Chao::CSD::CNode> m_rcScoreCount;
Chao::CSD::RCPtr<Chao::CSD::CNode> m_rcTimeCount;
Chao::CSD::RCPtr<Chao::CSD::CNode> m_rcTimeCount2;
Chao::CSD::RCPtr<Chao::CSD::CNode> m_rcTimeCount3;
Chao::CSD::RCPtr<Chao::CSD::CNode> m_rcPlayerCount;
};
}

View file

@ -0,0 +1,14 @@
#pragma once
#include <SWA.inl>
namespace SWA
{
class CMovieDisplayer : public Hedgehog::Universe::CUpdateUnit, public Hedgehog::Mirage::CRenderable
{
public:
SWA_INSERT_PADDING(0x04);
be<uint32_t> m_MovieWidth;
be<uint32_t> m_MovieHeight;
};
}

View file

@ -0,0 +1,17 @@
#pragma once
#include <SWA.inl>
namespace SWA
{
class CMovieManager // : Hedgehog::Base::TSingleton<SWA::CMovieManager, 0>
{
public:
static CMovieManager* GetInstance();
xpointer<void> m_pVftable;
SWA_INSERT_PADDING(0x330);
};
}
#include "SWA/Movie/MovieManager.inl"

View file

@ -0,0 +1,7 @@
namespace SWA
{
inline CMovieManager* CMovieManager::GetInstance()
{
return *(xpointer<CMovieManager>*)MmGetHostAddress(0x8336758C);
}
}

View file

@ -21,6 +21,7 @@ namespace SWA::Player
class CEvilHudGuide : public CGameObject
{
public:
xpointer<void> m_pVftable;
SWA_INSERT_PADDING(0x8D);
bool m_IsShown;
bool m_IsVisible;

View file

@ -0,0 +1,13 @@
#pragma once
#include <SWA.inl>
namespace SWA::Sequence::Unit
{
class CUnitBase : public Hedgehog::Base::CObject
{
public:
xpointer<void> m_pVftable;
SWA_INSERT_PADDING(0x14);
};
}

View file

@ -0,0 +1,8 @@
#pragma once
#include <SWA.inl>
namespace SWA::Sequence::Unit
{
class CPlayMovieUnit : public CUnitBase {};
}

View file

@ -7,16 +7,33 @@ namespace SWA::Sequence::Utility
{
class CPlayMovieWrapper
{
public:
class CRender : public Hedgehog::Mirage::CRenderable
{
SWA_INSERT_PADDING(0x08);
public:
be<uint32_t> m_ScreenWidth;
be<uint32_t> m_ScreenHeight;
be<float> m_MovieWidth;
be<float> m_MovieHeight;
SWA_INSERT_PADDING(0x74);
be<float> m_TopLeftX;
be<float> m_TopLeftY;
SWA_INSERT_PADDING(0x0C);
be<float> m_TopRightX;
be<float> m_TopRightY;
SWA_INSERT_PADDING(0x0C);
be<float> m_BottomRightX;
be<float> m_BottomRightY;
SWA_INSERT_PADDING(0x0C);
be<float> m_BottomLeftX;
be<float> m_BottomLeftY;
SWA_INSERT_PADDING(0xD4);
bool m_MaintainAspectRatio;
SWA_INSERT_PADDING(0x18);
be<float> m_TimeElapsed;
};
SWA_INSERT_PADDING(0x18);
CRender* m_pRender;
xpointer<CRender> m_pRender;
};
}

View file

@ -49,7 +49,8 @@ namespace SWA
SWA_INSERT_PADDING(0x58);
};
SWA_INSERT_PADDING(0x04); // vftable ptr
xpointer<void> m_pVftable;
SWA_INSERT_PADDING(0x04);
xpointer<CMember> m_pMember;
};
}

View file

@ -21,6 +21,12 @@ namespace SWA
eVoiceLanguage_Japanese
};
enum ERegion : uint32_t
{
eRegion_Japan,
eRegion_RestOfWorld
};
class CApplicationDocument : public Hedgehog::Base::CSynchronizedObject
{
public:
@ -39,8 +45,10 @@ namespace SWA
xpointer<CMember> m_pMember;
be<ELanguage> m_Language;
be<EVoiceLanguage> m_VoiceLanguage;
SWA_INSERT_PADDING(0x0D);
bool m_Subtitles;
SWA_INSERT_PADDING(0x08);
be<ERegion> m_Region;
bool m_InspireVoices;
bool m_InspireSubtitles;
};
}

View file

@ -4,5 +4,10 @@
namespace SWA
{
class CGameModeStage : public CGameMode {};
class CGameModeStage : public CGameMode
{
public:
xpointer<void> m_pVftable;
SWA_INSERT_PADDING(0x1B4);
};
}

View file

@ -0,0 +1,20 @@
#pragma once
#include <SWA.inl>
namespace SWA
{
class CGameModeStageMovie : public CGameModeStage
{
public:
class CRender : public Hedgehog::Mirage::CRenderable
{
public:
xpointer<CGameModeStageMovie> m_pThis;
};
xpointer<void> m_pVftable;
SWA_INSERT_PADDING(0x224);
xpointer<CRender> m_pRender;
};
}

View file

@ -26,7 +26,7 @@ void ToggleSubtitlesMidAsmHook(PPCRegister& r27)
{
auto pApplicationDocument = (SWA::CApplicationDocument*)g_memory.Translate(r27.u32);
pApplicationDocument->m_Subtitles = Config::Subtitles;
pApplicationDocument->m_InspireSubtitles = Config::Subtitles;
}
void WerehogBattleMusicMidAsmHook(PPCRegister& r11)