Skip to content

Commit

Permalink
Split lo.c, matched simple funcs & adjusted LO struct shape
Browse files Browse the repository at this point in the history
  • Loading branch information
bloppers committed Feb 17, 2025
1 parent a2cc2dc commit 74b9951
Show file tree
Hide file tree
Showing 12 changed files with 587 additions and 17 deletions.
2 changes: 1 addition & 1 deletion config/sly1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ segments:
#- [0x, asm, P2/keyhole]
#- [0x, asm, P2/landing]
#- [0x, asm, P2/lgn]
- [0x83c18, asm, P2/lo]
- [0x83c18, c, P2/lo]
- [0x84cc8, asm, P2/light]
- [0x86358, asm, P2/lookat]
- [0x86758, c, P2/main]
Expand Down
42 changes: 42 additions & 0 deletions config/symbol_addrs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,47 @@ g_pjt = 0x262e10; // size:0x4
////////////////////////////////////////////////////////////////
// P2/lo.c
////////////////////////////////////////////////////////////////
InitLo__FP2LO = 0x182c18; // type:func
PostLoLoad__FP2LO = 0x182c58; // type:func
AddLo__FP2LO = 0x182c80; // type:func
AddLoHierarchy__FP2LO = 0x182d00; // type:func
OnLoAdd__Fv = 0x182d48; // type:func
RemoveLo__FP2LO = 0x182d50; // type:func
DeferLoRemove__FP2LO = 0x182dd8; // type:func
SetLoSuckHideLimits__FP2LOP2LM = 0x182e40; // type:func
RemoveLoHierarchy__FP2LO = 0x182e88; // type:func
OnLoRemove__FP2LO = 0x182ed0; // type:func
SnipLo__FP2LO = 0x182ed8; // type:func
FFindLoParent__FP2LOP3ALO = 0x182f40; // type:func
SetLoParent__FP2LOP3ALO = 0x182f78; // type:func
FIsLoInWorld__FP2LO = 0x182fc8; // type:func
GetLoInWorld__FP2LOPi = 0x183028; // type:func
GetLoInWorld_padding = 0x183050; // type:func
PloCloneLo__FP2LOP2SWP3ALO = 0x183058; // type:func
CloneLoHierarchy__FP2LOT0 = 0x1830b0; // type:func
CloneLo__FP2LOT0 = 0x1830d8; // type:func
SubscribeSwPpmqStruct__FP2SWPP2MQPFPv5MSGIDPv_vPv = 0x1831e8; // type:func
UnsubscribeSwPpmqStruct__FP2SWPP2MQPFPv5MSGIDPv_vPv = 0x183238; // type:func
SubscribeLoStruct__FP2LOPFPv5MSGIDPv_vPv = 0x183290; // type:func
UnsubscribeLoStruct__FP2LOPFPv5MSGIDPv_vPv = 0x1832c0; // type:func
SubscribeLoObject__FP2LOT0 = 0x1832f0; // type:func
UnsubscribeLoObject__FP2LOT0 = 0x183320; // type:func
SendLoMessage__FP2LO5MSGIDPv = 0x183350; // type:func
LoadLoFromBrx__FP2LOP18CBinaryInputStream = 0x1833d0; // type:func
FMatchesLoName__FP2LO3OID = 0x1833f0; // type:func
OidProxyLo__FP2LO = 0x183438; // type:func
OidProxyLoPreferred__FP2LO = 0x183458; // type:func
GetLoOidProxy__FP2LOP3OID = 0x183478; // type:func
PostSpliceEventCallback__FP2LOUiPv = 0x1834a0; // type:func
FFilterSpliceEvent__FP2LO7SYMEVIDiPPv = 0x183668; // type:func
HandleLoSpliceEvent__FP2LOUiiPPv = 0x1837e0; // type:func
EnsureLoSidebagBool__FP2LO5OPTIDi = 0x183910; // type:func
EnsureLoSidebagInt__FP2LO5OPTIDi = 0x183990; // type:func
EnsureLoSidebagFloat__FP2LO5OPTIDf = 0x183a10; // type:func
EnsureLoSidebagClq__FP2LO5OPTIDP3CLQ = 0x183a90; // type:func
EnsureLoSidebagLm__FP2LO5OPTIDP2LM = 0x183b20; // type:func
EnsureLoSidebagOid__FP2LO5OPTID3OID = 0x183bb8; // type:func
EnsureLoSidebagVector__FP2LO5OPTIDP6VECTOR = 0x183c38; // type:func


////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1313,6 +1353,8 @@ VecCombo__FG8VU_FLOATG9VU_VECTORT0T1 = 0x1DB460; // type:func
////////////////////////////////////////////////////////////////
// P2/sw.c
////////////////////////////////////////////////////////////////
PmqAllocSw__FP2SW = 0x1dbbd8; // type:func
FreeSwMqList__FP2SWP2MQ = 0x1dbc18; // type:func
IncrementSwHandsOff__FP2SW = 0x1dda20; // type:func
DecrementSwHandsOff__FP2SW = 0x1dda50; // type:func

Expand Down
4 changes: 2 additions & 2 deletions include/alo.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ struct ALO : public LO
//XF xf;
//VECTOR pso

undefined4 padding[0x88];
undefined4 padding[0x8b];
FICG ficg;

undefined1 padding2[0x16];
undefined1 padding2[0x1a];
// ...
};

Expand Down
6 changes: 4 additions & 2 deletions include/basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "common.h"
#include <splice/sidebag.h>
#include <vtables.h>

/**
* @brief Basic object.
Expand All @@ -19,7 +18,10 @@
*/
struct BASIC
{
VTBASIC *pvtbasic;
union {
VTBASIC *pvtbasic;
VTLO *pvtlo;
};
CSidebag *psidebag;
};

Expand Down
5 changes: 5 additions & 0 deletions include/brx.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

#include "common.h"

/**
* @todo
*/
void LoadOptionsFromBrx(void *pvStruct, CBinaryInputStream *pbis);

/**
* @brief Get the PLO index from a stock OID.
*/
Expand Down
180 changes: 176 additions & 4 deletions include/lo.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
#include <oid.h>
#include <basic.h>
#include <dl.h>
#include <sw.h>
#include <splice/frame.h>
#include <mq.h>

struct ALO; // Forward declaration.
struct SW;
struct PXR;
struct LM;
struct CLQ;
struct VECTOR;

/**
* @brief "LO"
Expand All @@ -28,14 +32,182 @@ struct LO : public BASIC
DLE dleChild;
LO *ploCidNext;
MQ *pmqFirst;
char *pchzName;
// char *pchzName; // Not in release
CFrame *pframe;
ulong dtickPerf;
PXR *ppxr;
// ulong dtickPerf; // Not in release
};

/**
* Checks if the LO is currently in the world.
* @brief "Proxy Root"?
*/
struct PXR
{
LO *plo;
OID oidProxyRoot;
DLE dleProxyRoot;
char *pchzProxyRoot;
};

/**
* @brief Initialize LO with defaults set
*/
void InitLo(LO *plo);

/**
* @brief Calls HandleLoSpliceEvent with unknown event
* Called by LO subclasses?
*/
void PostLoLoad(LO *plo);

/**
* @brief Adds LO to 'dlChild' of either parent ALO, if present, or SW
* If LO is in world, also calls AddLoHierarchy
*/
void AddLo(LO *plo);

/**
* @brief Calls OnLoAdd, and SendLoMessage with MSGID_added
*/
void AddLoHierarchy(LO *plo);

/**
* @brief Does nothing
*/
void OnLoAdd();

/**
* @brief Removes LO from 'dlChild' of either parent ALO, if present, or SW
* If LO is in world, also calls RemoveLoHierarchy
*/
void RemoveLo(LO *plo);

/**
* @todo
*/
void DeferLoRemove(LO *plo);

/**
* @brief If global 'uSuck' is within given range, calls DeferLoRemove with this LO
*/
void SetLoSuckHideLimits(LO *plo, LM *plmUSuck);

/**
* @brief Calls OnLoRemove, and SendLoMessage with MSGID_removed
*/
void RemoveLoHierarchy(LO *plo);

/**
* @brief Does nothing
*/
void OnLoRemove(LO *plo);

/**
* @brief If LO is in world, remove it
*/
void SnipLo(LO *plo);

/**
* @brief Check ALO is parent/grandparent/etc of LO
*/
int FFindLoParent(LO *plo, ALO *paloParent);

/**
* @brief Removes LO, sets ALO as parent, then re-adds LO
*/
void SetLoParent(LO *plo, ALO *paloParent);

/**
* @brief Checks if the LO is currently in the world.
*/
int FIsLoInWorld(LO *PLO);

/**
* @brief Check if LO is in world and updates provided flag with result
*/
void GetLoInWorld(LO *plo, int *pfInWorld);

/**
* @brief Creates new LO, clones provided LO, returns new LO
*/
LO* PloCloneLo(LO *plo, SW *psw, ALO *paloParent);

/**
* @brief Clones from 'base' LO into provided LO
*/
void CloneLoHierarchy(LO *plo, LO *ploBase);

/**
* @brief Clones from 'base' LO into provided LO
*/
void CloneLo(LO *plo, LO *ploBase);

/**
* @todo
*/
void SubscribeSwPpmqStruct(SW *psw, MQ **ppmqFirst, PFNMQ pfnmq, void *pvContext);

void UnsubscribeSwPpmqStruct(SW *psw, MQ **ppmqFirst, PFNMQ pfnmq, void *pvContext);

void SubscribeLoStruct(LO *plo, PFNMQ pfnmq, void *pvContext);

void UnsubscribeLoStruct(LO *plo, PFNMQ pfnmq, void *pvContext);

void SubscribeLoObject(LO *plo, LO *ploTarget);

void UnsubscribeLoObject(LO *plo, LO *ploTarget);

/**
* @brief Calls HandleLoMessage, then each MQ function with provided MSGID and data pointer
*/
void SendLoMessage(LO *plo, MSGID msgid, void *pv);

/**
* @brief Loads options from Brx
*/
void LoadLoFromBrx(LO *plo, CBinaryInputStream *pbis);

/**
* @brief Checks if LO OID, or LO's PXR OID, match provided OID
*/
int FMatchesLoName(LO *plo, OID oid);

/**
* @brief Return OID of LO's PXR, or Nil
*/
OID GetProxyLo(LO *plo);

/**
* @brief Return OID of LO's PXR, or LO's own OID
*/
OID OidProxyLoPreferred(LO *plo);

/**
* @brief Updates provided OID pointer with LO's PXR OID
*/
void GetLoOidProxy(LO *plo, OID *poid);

/**
* @todo Args for following functions based on proto
*/
void PostSpliceEventCallback(LO *plo, uint symidEvent, void *pvarg);

int FFilterSpliceEvent(LO *plo, /* SYMEVID */ int symevid, int cargs, void **ppvargs);

void HandleLoSpliceEvent(LO *plo, uint symidEvent, int cargs, void **ppvargs);

void EnsureLoSidebagBool(LO *plo, uint optid, int f);

void EnsureLoSidebagInt(LO *plo, uint optid, int n);

void EnsureLoSidebagFoat(LO *plo, uint optid, float g);

void EnsureLoSidebagClq(LO *plo, uint optid, CLQ *pclq);

void EnsureLoSidebagLm(LO *plo, uint optid, LM *plm);

void EnsureLoSidebagOid(LO *plo, uint optid, OID oid);

void EnsureLoSidebagVector(LO *plo, uint optid, VECTOR *pvec);

#endif // LO_H
4 changes: 3 additions & 1 deletion include/mq.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ enum MSGID
MSGID_Max = 26
};

typedef void (*PFNMQ)(void*, MSGID, void*);

/**
* @brief Message queue(?)
*/
struct MQ
{
void *pfnmq;
PFNMQ pfnmq;
void *pvContext;
MSGID msgid;
void *pvCallbackData;
Expand Down
11 changes: 9 additions & 2 deletions include/sw.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@
#define SW_H

#include "common.h"
#include <lo.h>
#include <mq.h>

// todo Implement struct.
struct SW
struct SW : public LO
{
undefined1 padding[0x1c53];
undefined1 padding1[0x8];
DL dlRoot;
DL dlChild;
undefined1 padding2[0x1bff];
DL dlDprize;
};

extern SW *g_psw;

MQ *PmqAllocSw(SW *psw);
void IncrementSwHandsOff(SW *psw);
void FreeSwMqList(SW *psw, MQ *pmq);

#endif // SW_H
Loading

0 comments on commit 74b9951

Please sign in to comment.