Skip to content

Commit

Permalink
Merge pull request #139 from TheOnlyZac/theonlyzac-working
Browse files Browse the repository at this point in the history
Unblock matched functions
  • Loading branch information
TheOnlyZac authored Dec 5, 2024
2 parents fe2cb75 + 09019f9 commit c6ee666
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 96 deletions.
2 changes: 1 addition & 1 deletion config/sly1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion config/symbol_addrs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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


////////////////////////////////////////////////////////////////
Expand Down
7 changes: 7 additions & 0 deletions include/splice/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@ class CFrame
// todo Implement class.
};

// ...

/**
* @brief Deletes the frame.
*/
void DeleteFrame(CFrame *pframe);

#endif // SPLICE_FRAME_H
2 changes: 1 addition & 1 deletion include/splice/method.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class CMethod
int m_crefReq;
};

static CMethod* PMethodNew();
CMethod* PmethodNew();

#endif // SPLICE_METHOD_H
4 changes: 2 additions & 2 deletions include/splice/pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions include/splice/proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions include/splice/splotheap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
40 changes: 27 additions & 13 deletions include/transition.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
#include "common.h"
#include <oid.h>

class CTransition;
extern CTransition g_transition;

/**
* @brief Transition flags.
*/
enum FTRANS {
*/
enum FTRANS
{
FTRANS_None = 0,
FTRANS_Checkpoint = 1,
FTRANS_RetryWorld = 2,
Expand All @@ -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
17 changes: 8 additions & 9 deletions src/P2/joy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 2 additions & 3 deletions src/P2/jt2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
14 changes: 7 additions & 7 deletions src/P2/splice/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include <splice/splotheap.h>

// 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;
}
13 changes: 6 additions & 7 deletions src/P2/splice/proc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
8 changes: 7 additions & 1 deletion src/P2/splice/spliceutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PFNDELETE>(DeletePair);

// g_splotheapFrame.Startup(0x1c, 0x190);
// g_splotheapFrame.m_pfndelete = reinterpret_cast<PFNDELETE>(DeleteFrame);

// g_splotheapUnk1.Startup(0x10, 0x800);
// g_splotheapUnk1.m_pfndelete = func_0011C4E8;
// g_splotheapUnk1.m_pfndelete = reinterpret_cast<PFNDELETE>(0x11C4E8);

// g_splotheapProc.Startup(0x14, 0x800);
// StartupSpliceStructuredTypeFactories();

// g_splotheapMethod.Startup(0xc,0x80);
// }

Expand Down
24 changes: 10 additions & 14 deletions src/P2/splice/splotheap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
57 changes: 28 additions & 29 deletions src/P2/transition.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit c6ee666

Please sign in to comment.