diff --git a/config/sly1.yaml b/config/sly1.yaml index 4189dcd4..6b2f0a0d 100644 --- a/config/sly1.yaml +++ b/config/sly1.yaml @@ -470,7 +470,7 @@ segments: #- [0x, data, P2/text] #- [0x, data, P2/thread] #- [0x, data, P2/tn] - #- [0x, data, P2/transition] + - [0x176af0, data, P2/transition] #- [0x, data, P2/turret] #- [0x, data, P2/tv] #- [0x, data, P2/ub] diff --git a/config/symbol_addrs.txt b/config/symbol_addrs.txt index d5ffda9d..9c726e4e 100644 --- a/config/symbol_addrs.txt +++ b/config/symbol_addrs.txt @@ -1380,7 +1380,7 @@ ResetWorld__F6FTRANS = 0x1E5278; // type:func transition__static_initialization_and_destruction_0 = 0x1E5328; // type:func _GLOBAL_$I$g_transition = 0x1E5358; // type:func -g_transition = 0x275af0; +g_transition = 0x275af0; // size:0x54 //////////////////////////////////////////////////////////////// diff --git a/include/splice/frame.h b/include/splice/frame.h index 4cf7336d..d7be0e83 100644 --- a/include/splice/frame.h +++ b/include/splice/frame.h @@ -11,4 +11,11 @@ class CFrame // todo Implement class. }; +// ... + +/** + * @brief Deletes the frame. + */ +void DeleteFrame(CFrame *pframe); + #endif // SPLICE_FRAME_H diff --git a/include/splice/method.h b/include/splice/method.h index f10a6108..6890b47a 100644 --- a/include/splice/method.h +++ b/include/splice/method.h @@ -18,6 +18,6 @@ class CMethod int m_crefReq; }; -static CMethod* PMethodNew(); +CMethod* PmethodNew(); #endif // SPLICE_METHOD_H diff --git a/include/splice/pair.h b/include/splice/pair.h index a2ef7a26..3a2742b3 100644 --- a/include/splice/pair.h +++ b/include/splice/pair.h @@ -21,7 +21,7 @@ class CPair void CloneTo(CPair* ppairClone, CFrame* pframeClone); }; -static CPair* PpairNew(); -static void DeletePair(CPair* ppair); +CPair* PpairNew(); +void DeletePair(CPair* ppair); #endif // SPLICE_PAIR_H diff --git a/include/splice/proc.h b/include/splice/proc.h index a1d4ba83..6caf2957 100644 --- a/include/splice/proc.h +++ b/include/splice/proc.h @@ -17,16 +17,16 @@ class CPair; class CProc { private: - CFrame* m_pframe; - CPair* m_ppair; + CFrame *m_pframe; + CPair *m_ppair; int m_crefReq; int m_fVarArg; - CPair* m_ppairCodeExpr; + CPair *m_ppairCodeExpr; public: - void CloneTo(CProc* pprocClone, CFrame* pframeClone); + void CloneTo(CProc *pprocClone, CFrame *pframeClone); }; -static CProc* PprocNew(); +CProc *PprocNew(); #endif // SPLICE_PROC_H diff --git a/include/splice/splotheap.h b/include/splice/splotheap.h index 326eae9f..1393d332 100644 --- a/include/splice/splotheap.h +++ b/include/splice/splotheap.h @@ -23,9 +23,10 @@ class CSplotheap SPLOT *m_psplotFree; SPLOT *m_psplotAlloc; SPLOT *m_psplotRecyclable; - PFNDELETE m_pfndelete; public: + PFNDELETE m_pfndelete; + void Startup(int cb, int c); void Shutdown(); int PvAllocUnsafe(); @@ -44,7 +45,7 @@ extern CSplotheap g_splotheapMethod; static void *PvFromPsplot(SPLOT *psplot); static SPLOT *PsplotFromPv(void *pv); -static bool FIsPvGarbage(void *pv); -static void MarkPvAlive(void *pv); +bool FIsPvGarbage(void *pv); +void MarkPvAlive(void *pv); #endif // SPLICE_SPLOTHEAP_H diff --git a/include/transition.h b/include/transition.h index a51264a0..053db2b3 100644 --- a/include/transition.h +++ b/include/transition.h @@ -9,10 +9,14 @@ #include "common.h" #include +class CTransition; +extern CTransition g_transition; + /** * @brief Transition flags. -*/ -enum FTRANS { + */ +enum FTRANS +{ FTRANS_None = 0, FTRANS_Checkpoint = 1, FTRANS_RetryWorld = 2, @@ -30,42 +34,52 @@ typedef int GRFTRANS; * @brief Transition data * * Responsible for holding data bout a level transition. -*/ + */ struct TRANS { uint fSet; struct LevelTableStruct *pchzWorld; // Current file thats loading struct - OID oidWarp; // Checkpoint Warps + OID oidWarp; // Checkpoint Warps OID oidWarpContet; GRFTRANS grftrans; // Lost all lives flags }; /** * @brief Transition -*/ + */ class CTransition { protected: - int m_fPending; // Basically like a level pending flag. - char *m_pchzWorld; // This is the ptr to enc level sector offset and size in memory - OID m_oidWarp; // Which checkpoint you spawn at when you start a level - OID m_oidWarpContext; + int m_fPending; // Basically like a level pending flag. + char *m_pchzWorld; // This is the ptr to enc level sector offset and size in memory + OID m_oidWarp; // Which checkpoint you spawn at when you start a level + OID m_oidWarpContext; public: GRFTRANS grftrans; // Flags that affect level loading, one of them checks if you lost all lives when you die. char m_achzWorldCur[64]; // File description contents. - // Constructor + /** + * @brief Constructor. + */ CTransition(); - // Sets the conditions on the level if you died or loading a level + /** + * @brief Sets the conditions on the level if you died or loading a level. + */ void Set(char *pchzWorld, OID oidWarp, OID oidWarpContext, GRFTRANS grftrans); - // Executes the conditions from CTransition::Set by setting some engine vaules to default and loading the level file + /** + * @brief Executes the conditions from CTransition::Set by setting some engine vaules to default and loading the level file. + */ void Execute(); }; -// Reloads the current level. The value of FTRANS affects the load. +/** + * @brief Reloads the current level. The value of FTRANS affects the load. + * + * @param ftrans Transition flags. + */ void ResetWorld(FTRANS ftrans); #endif // TRANSITION_H diff --git a/src/P2/joy.c b/src/P2/joy.c index 14c52c43..fd28da97 100644 --- a/src/P2/joy.c +++ b/src/P2/joy.c @@ -233,15 +233,14 @@ void ClearFchts() ResetWorld(FTRANS_None); } -INCLUDE_ASM(const s32, "P2/joy", AddFcht__Fi); -// void AddFcht(int nParam) -// { -// g_grfcht |= nParam & ~FCHT_ResetWorld; -// if (nParam & FCHT_ResetWorld) -// { -// ResetWorld(FTRANS_None); -// } -// } +void AddFcht(int nParam) +{ + g_grfcht |= nParam & ~FCHT_ResetWorld; + if (nParam & FCHT_ResetWorld) + { + ResetWorld(FTRANS_None); + } +} INCLUDE_ASM(const s32, "P2/joy", func_0016F470); diff --git a/src/P2/jt2.c b/src/P2/jt2.c index fe35b63b..c36a20a5 100644 --- a/src/P2/jt2.c +++ b/src/P2/jt2.c @@ -13,9 +13,8 @@ INCLUDE_ASM(const s32, "P2/jt2", EnableJtActadj__FP2JTi); INCLUDE_ASM(const s32, "P2/jt2", SetJtJts__FP2JT3JTS4JTBS); -//INCLUDE_ASM(const s32, "P2/jt2", ProfileJt__FP2JTi); -void ProfileJt(JT* pjt, int fProfile) { - // Does nothing. +void ProfileJt(JT *pjt, int fProfile) +{ return; } diff --git a/src/P2/splice/method.cpp b/src/P2/splice/method.cpp index ebe300fe..c9024b96 100644 --- a/src/P2/splice/method.cpp +++ b/src/P2/splice/method.cpp @@ -3,10 +3,10 @@ #include // todo: matches but blocked by reference in 001c15d8 -INCLUDE_ASM(const s32, "P2/splice/method", PmethodNew__Fv); -// static CMethod* PMethodNew() -// { -// CMethod* method = (CMethod*)g_splotheapMethod.PvAllocClear(); -// memset(method, 0, sizeof(CMethod)); -// return method; -// } +// INCLUDE_ASM(const s32, "P2/splice/method", PmethodNew__Fv); +CMethod *PmethodNew() +{ + CMethod *method = (CMethod *)g_splotheapMethod.PvAllocClear(); + memset(method, 0, sizeof(CMethod)); + return method; +} diff --git a/src/P2/splice/proc.cpp b/src/P2/splice/proc.cpp index a270f6e5..91561850 100644 --- a/src/P2/splice/proc.cpp +++ b/src/P2/splice/proc.cpp @@ -15,10 +15,9 @@ void CProc::CloneTo(CProc *pprocClone, CFrame *pframeClone) pprocClone->m_ppairCodeExpr = m_ppairCodeExpr; } -// todo: matches but blocked by references in CRef::CloneTo and RefEvalLambda -INCLUDE_ASM(const s32, "P2/splice/proc", PprocNew__Fv); -// static CProc* PprocNew() { -// CProc* proc = (CProc*)g_splotheapProc.PvAllocClear(); -// memset(proc, 0, sizeof(CProc)); -// return proc; -// } +CProc *PprocNew() +{ + CProc *proc = (CProc *)g_splotheapProc.PvAllocClear(); + memset(proc, 0, sizeof(CProc)); + return proc; +} diff --git a/src/P2/splice/spliceutils.cpp b/src/P2/splice/spliceutils.cpp index 97d5b6e6..0e7cc6f5 100644 --- a/src/P2/splice/spliceutils.cpp +++ b/src/P2/splice/spliceutils.cpp @@ -7,18 +7,24 @@ extern CGc g_gc; +// todo: match and fix blocked references INCLUDE_ASM(const s32, "P2/splice/spliceutils", StartupSplice__Fv); // void StartupSplice() // { // g_gc.Startup(); + // g_splotheapPair.Startup(0xc, 0x2000); // g_splotheapPair.m_pfndelete = reinterpret_cast(DeletePair); + // g_splotheapFrame.Startup(0x1c, 0x190); // g_splotheapFrame.m_pfndelete = reinterpret_cast(DeleteFrame); + // g_splotheapUnk1.Startup(0x10, 0x800); -// g_splotheapUnk1.m_pfndelete = func_0011C4E8; +// g_splotheapUnk1.m_pfndelete = reinterpret_cast(0x11C4E8); + // g_splotheapProc.Startup(0x14, 0x800); // StartupSpliceStructuredTypeFactories(); + // g_splotheapMethod.Startup(0xc,0x80); // } diff --git a/src/P2/splice/splotheap.cpp b/src/P2/splice/splotheap.cpp index dbba86fc..d334b5bc 100644 --- a/src/P2/splice/splotheap.cpp +++ b/src/P2/splice/splotheap.cpp @@ -40,21 +40,17 @@ static SPLOT *PsplotFromPv(void *pv) return (SPLOT *)((byte *)pv - sizeof(SPLOT)); } -// todo: both below functions are matching but blocked by reference in CGc::MarkLiveObjects - -INCLUDE_ASM(const s32, "P2/splice/splotheap", FIsPvGarbage__FPv); -// static bool FIsPvGarbage(void* pv) { -// SPLOT* psplot = PsplotFromPv(pv); - -// return psplot->fAlive == 0; -// } - -INCLUDE_ASM(const s32, "P2/splice/splotheap", MarkPvAlive__FPv); -// static void MarkPvAlive(void* pv) { -// SPLOT* psplot = PsplotFromPv(pv); +bool FIsPvGarbage(void *pv) +{ + SPLOT *psplot = PsplotFromPv(pv); + return psplot->fAlive == 0; +} -// psplot->fAlive = 1; -// } +void MarkPvAlive(void *pv) +{ + SPLOT *psplot = PsplotFromPv(pv); + psplot->fAlive = 1; +} INCLUDE_ASM(const s32, "P2/splice/splotheap", func_0011C418); diff --git a/src/P2/transition.c b/src/P2/transition.c index 04495897..9bd3923f 100644 --- a/src/P2/transition.c +++ b/src/P2/transition.c @@ -27,35 +27,34 @@ void CTransition::Set(char *pchzWorld, OID oidWarp, OID oidWarpContext, GRFTRANS INCLUDE_ASM(const s32, "P2/transition", Execute__11CTransition); -// Matching, blocked by broken references in joy.c -INCLUDE_ASM(const s32, "P2/transition", ResetWorld__F6FTRANS); -// void ResetWorld(FTRANS ftrans) -// { -// GRFTRANS grftrans; - -// SetMvgkRvol(0.0f); -// switch (ftrans) -// { -// case FTRANS_None: -// /* Reload with no transition */ -// grftrans = FTRANS_None; -// break; - -// case FTRANS_Checkpoint: -// ReturnChkmgrToCheckpoint(&g_chkmgr); -// return; - -// case FTRANS_RetryWorld: -// grftrans = FTRANS_RetryWorld; -// break; - -// case (FTRANS_Checkpoint | FTRANS_RetryWorld): -// /* Transition with the Sly Cooper logo wipe */ -// grftrans = 4; -// break; -// } -// g_transition.Set(g_transition.m_achzWorldCur, OID_Nil, OID_Nil, grftrans); -// } +void ResetWorld(FTRANS ftrans) +{ + GRFTRANS grftrans; + + SetMvgkRvol(0.0f); + switch (ftrans) + { + case FTRANS_None: + /* Reload with no transition */ + grftrans = FTRANS_None; + break; + + case FTRANS_Checkpoint: + ReturnChkmgrToCheckpoint(&g_chkmgr); + return; + + case FTRANS_RetryWorld: + grftrans = FTRANS_RetryWorld; + break; + + case (FTRANS_Checkpoint | FTRANS_RetryWorld): + /* Transition with the Sly Cooper logo wipe */ + grftrans = 4; + break; + } + + g_transition.Set(g_transition.m_achzWorldCur, OID_Nil, OID_Nil, grftrans); +} INCLUDE_ASM(const s32, "P2/transition", transition__static_initialization_and_destruction_0);