Add xform.c and fill in related headers

This commit is contained in:
Zac 2024-07-06 05:47:09 +00:00 committed by GitHub
parent 951ac9b3ff
commit 48095bdee8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 314 additions and 23 deletions

View File

@ -297,8 +297,8 @@ segments:
- [0xf0838, asm, P2/waypoint]
- [0xf0ce8, asm, P2/wipe]
- [0xf1758, asm, P2/wm] # not confident
- [0xf49f8, asm, P2/xform]
- [0xf5f70, asm, P2/zap]
- [0xf49f8, c, P2/xform]
- [0xf5f20, asm, P2/zap]
## Source files in May proto that aren't in release:
# P2/cycle.c - some kind of wheeled vehicle
@ -311,7 +311,7 @@ segments:
#--------------------------------------------------------
# Libs
#--------------------------------------------------------
- [0xF69C4, asm] # TBD #MARK: libs
- [0xF6930, asm] # TBD #MARK: libs
- [0xF76F8, asm, sce/rand]
@ -395,7 +395,10 @@ segments:
#- [0x, data, P2/frm]
#- [0x, data, P2/freeze]
#- [0x, data, P2/frzg]
#- [0x, data, P2/game]
- [0x1633c0, data, P2/game]
- [0x1633d8, data]
#- [0x, data, P2/geom]
#- [0x, data,, P2/gifs]
#- [0x, data,, P2/glbs]

View File

@ -308,6 +308,18 @@ CcharmMost__Fv = 0x160D98; // type:func
reload_post_death = 0x160DA0; // type:func
g_pgsCur = 0x2623c0; // size:0x4
g_pwsCur = 0x2623c4; // size:0x4
g_plsCur = 0x2623c8; // size:0x4
g_worldlevelPrev = 0x2623cc; // size:0x4
chz_none = 0x2623d0; // size:0x7
// static
g_gsCur = 0xea0; // size:0x1a00
// P2/joy.c
StartupJoy__Fv = 0x16E0B8; // type:func
AddGrfusr__Fi = 0x16E0F0; // type:func
@ -458,6 +470,20 @@ FUN_001ae130 = 0x1AE130; // type:func
UpdateAttract__FP7ATTRACT = 0x1AE178; // type:func
DrawLineScreen__FUiUiUiUiUiUiG4RGBAi = 0x1AE3B8; // type:func
// Global blots
g_lifectr = 0x26c6c8; // size:0x280
g_cluectr = 0x26c948; // size:0x280
g_keyctr = 0x26cbc8; // size:0x280
g_coinctr = 0x26ce48; // size:0x280
g_unkblot0 = 0x26d0c8; // size:0x280
g_unkblot1 = 0x26d348; // size:0x280
g_unkblot2 = 0x26d5c8; // size:0x280
g_unkblot3 = 0x26d848; // size:0x280
g_unkblot4 = 0x26dac8; // size:0x280
g_unkblot5 = 0x26dd48; // size:0x280
g_unkblot6 = 0x26dfc8; // size:0x280
g_unkblot7 = 0x26e248; // size:0x280
// P2/steppower.c
SetFsp__F3FSP = 0x1D29C8; // type:func
@ -546,6 +572,34 @@ g_pwipe = 0x275f80;
g_wipe = 0x275f84;
// P2/xform.c
InitXfm__FP3XFM = 0x1F39F8; // type:func
LoadXfmFromBrx__FP3XFMP18CBinaryInputStream = 0x1F3A40; // type:func
SetXfmParent__FP3XFMP3ALO = 0x1F3A90; // type:func
ApplyXfmProxy__FP3XFMP5PROXY = 0x1F3AF0; // type:func
ConvertXfmLocalToWorld__FP3XFMP6VECTORT1 = 0x1F3B48; // type:func
GetXfmPos__FP3XFMP6VECTOR = 0x1F3BD8; // type:func
GetXfmMat__FP3XFMP7MATRIX3 = 0x1F3C08; // type:func
PwarpFromOid__F3OIDT0 = 0x1F3C38; // type:func
LoadWarpFromBrx__FP4WARPP18CBinaryInputStream = 0x1F3D80; // type:func
CloneWarp__FP4WARPT0 = 0x1F3EE0; // type:func
PostWarpLoad__FP4WARP = 0x1F3F80; // type:func
TriggerWarp__FP4WARP = 0x1F4008; // type:func
SetWarpRsmg__FP4WARPi3OIDN22 = 0x1F42D0; // type:func
TeleportSwPlayer__FP2SW3OIDT1 = 0x1F4318; // type:func
PexitDefault__Fv = 0x1F4378; // type:func
TriggerDefaultExit__Fi5WIPEK = 0x1F4408; // type:func
LoadExitFromBrx__FP4EXITP18CBinaryInputStream = 0x1F4500; // type:func
PostExitLoad__FP4EXIT = 0x1F4660; // type:func
SetExitExits__FP4EXIT5EXITS = 0x1F4760; // type:func
TriggerExit__FP4EXIT = 0x1F4808; // type:func
WipeExit__FP4EXIT = 0x1F4A30; // type:func
UpdateExit__FfP4EXIT = 0x1F4AE0; // type:func
InitCamera__FP6CAMERA = 0x1F4E18; // type:func
PostCameraLoad__FP6CAMERA = 0x1F4E48; // type:func
EnableCamera__FP6CAMERA = 0x1F4ED0; // type:func
// sce/ee/gcc/src/gcc/libgcc2.c
__main__Fv = 0x1fae18; // type:func

View File

@ -436,11 +436,14 @@ void GetBlueprintInfo(int *pgrfvault, int *pipdialog);
* @note Always returns 2. This is a holdover from earlier in development where
* there was a powerup that allowed you to have more than 2 charms.
*/
int CCharmMost();
int CcharmMost();
/**
* @brief Reloads the game state after the player dies.
*/
void reload_post_death();
extern GS g_gsCur;
extern GS *g_pgsCur;
#endif // GAME_H

19
include/proxy.h Normal file
View File

@ -0,0 +1,19 @@
/**
* @file proxy.h
*/
#ifndef PROXY_H
#define PROXY_H
#include "common.h"
#include <alo.h>
struct PROXY
{
DL dlProxyRoot;
DLE dleProxy;
undefined4 unk_0x8;
undefined4 unk_0xC;
undefined4 unk_0x10;
};
#endif // PROXY_H

20
include/rs.h Normal file
View File

@ -0,0 +1,20 @@
/**
* @file rs.h
*
* @note No functions are defined in this file.
*/
#ifndef RS_H
#define RS_H
#include "common.h"
#include <oid.h>
struct RSMG
{
OID oidRoot;
OID oidSM;
OID oidTriggerGoal;
OID oidUntriggerGoal;
};
#endif // RS_H

View File

@ -118,17 +118,13 @@ struct CTR : public BLOT
void *pv;
};
struct TRUNKCTR : public CTR { };
struct CRUSHERCTR : public CTR { };
struct LIFECTR : public CTR { };
struct CLUECTR : public CTR { };
struct KEYCTR : public CTR { };
struct COINCTR : public CTR { };
struct TRUNKCTR : public CTR
{
// empty
};
struct CRUSHERCTR : public CTR
{
// empty
};
// MARK: Totals

13
include/surf.h Normal file
View File

@ -0,0 +1,13 @@
/**
* @file stream.h
*/
#ifndef STREAM_H
#define STREAM_H
#include "common.h"
//todo implement structs
struct TSURF;
struct TBSP;
#endif // STREAM_H

View File

@ -7,7 +7,11 @@
#define UI_H
#include "common.h"
#include <screen.h>
// ...
extern LIFECTR g_lifectr;
extern CLUECTR g_cluectr;
extern KEYCTR g_keyctr;
extern COINCTR g_coinctr;
#endif // UI_H

View File

@ -14,7 +14,6 @@
struct VECTOR
{
float x, y, z;
float gUnused;
};
struct VECTOR4

View File

@ -12,10 +12,6 @@
#include "common.h"
#include <xform.h>
//todo implement structs
struct TSURF;
struct TBSP;
struct VOL : public XFM
{
int ctsurf;

View File

@ -8,9 +8,16 @@
#include "common.h"
#include <alo.h>
#include <vec.h>
#include <mat.h>
#include <util.h>
#include <dl.h>
#include <surf.h>
#include <game.h>
#include <oid.h>
#include <anim.h>
#include <wipe.h>
#include <bis.h>
#include <proxy.h>
#include <rs.h>
// Forward declarations
struct XFM;
@ -63,6 +70,9 @@ struct EXPLSTE
// ...
};
/**
* @brief Target.
*/
struct TARGET : public XFM
{
DLE dleTarget;
@ -74,6 +84,32 @@ struct TARGET : public XFM
undefined4 unk2;
};
/**
* @brief Warp.
*/
struct WARP : XFM
{
WID widMenu;
undefined4 unk0_0x4;
undefined4 unk1_0x8;
undefined4 unk2_0xC;
VECTOR v;
int fDefault;
float radCmInit;
int cpaseg;
ASEG **apaseg;
int coidHide;
OID *aoidHide;
int coidShowWhenDifficult;
OID aoidShowWhenDifficult[4];
OID oidAlias;
int crsmg;
RSMG arsmg[4];
undefined4 unk3;
undefined4 unk4;
undefined4 unk5;
};
/**
* @brief Point.
*/
@ -103,4 +139,99 @@ struct CAMERA : public ALO
undefined4 unk_4;
};
enum EXITS
{
EXITS_Nil = -1,
EXITS_Blocked = 0,
EXITS_Unblocked = 1,
EXITS_Disabled = 2,
EXITS_Enabled = 3,
EXITS_Totals = 4,
EXITS_Exiting = 5,
EXITS_Max = 6
};
enum EDK
{
EDK_Nil = -1,
EDK_DestinationKey = 0,
EDK_CurrentKey = 1,
EDK_Max = 2
};
struct EXIT : public ALO
{
int fDefault;
EXITS fKeyed;
float fFollowDefault;
int fTotals;
EXITS exits;
float tExits;
int ctsurf;
TSURF *atsurf;
int ctbsp;
TBSP *atbsp;
WID widWarp;
OID oidWarp;
EDK edkAlt;
WID widAlt;
OID oidAlt;
int cpaseg;
ASEG *apaseg;
WIPEK wipek;
float tWipe;
float dtUnblock;
float dtTriggerWipe;
};
void InitXfm(XFM *pxfm);
void LoadXfmFromBrx(XFM *pxfm, CBinaryInputStream *pbis);
void SetXfmParent(XFM *pxfm, ALO *paloParent);
void ApplyXfmProxy(XFM *pxfm, PROXY *pproxyApply);
void ConvertXfmWorldToLocal(XFM *pxfm, VECTOR *pposWorld, VECTOR *pposLocal);
void GetXfmPos(XFM *xfm, VECTOR *ppos);
void GetXfmMat(XFM *pxfm, MATRIX3 *pmat);
WARP *PwarpFromOid(OID oid, OID oidContext);
void LoadWarpFromBrx(WARP *pwarp, CBinaryInputStream *pbis);
void CloneWarp(WARP *pwarp, WARP *pwarpBase);
void PostWarpLoad(WARP *pwarp);
void TriggerWarp(WARP *pwarp);
void SetWarpRsmg(WARP *pwarp, int fOnTrigger, OID oidRoot, OID oidSM, OID oidGoal);
void TeleportSwPlayer(SW *psw, OID oidWarp, OID oidWarpContext);
EXIT *PexitDefault();
void TriggerDefaultExit(int fInhibitAsegs, WIPEK wipek);
void LoadExitFromBrx(EXIT *pexit, CBinaryInputStream *pbis);
void PostExitLoad(EXIT *pexit);
void SetExitExits(EXIT *pexit, EXITS exits);
void TriggerExit(EXIT *pexit);
void WipeExit(EXIT *pexit);
void UpdateExit(float dt, EXIT *pexit);
void InitCamera(CAMERA *pcamera);
void PostCameraLoad(CAMERA *camera);
void EnableCamera(CAMERA *pcamera);
#endif // XFORM_H

53
src/P2/xform.c Normal file
View File

@ -0,0 +1,53 @@
#include "common.h"
INCLUDE_ASM(const s32, "P2/xform", InitXfm__FP3XFM);
INCLUDE_ASM(const s32, "P2/xform", LoadXfmFromBrx__FP3XFMP18CBinaryInputStream);
INCLUDE_ASM(const s32, "P2/xform", SetXfmParent__FP3XFMP3ALO);
INCLUDE_ASM(const s32, "P2/xform", ApplyXfmProxy__FP3XFMP5PROXY);
INCLUDE_ASM(const s32, "P2/xform", ConvertXfmLocalToWorld__FP3XFMP6VECTORT1);
INCLUDE_ASM(const s32, "P2/xform", GetXfmPos__FP3XFMP6VECTOR);
INCLUDE_ASM(const s32, "P2/xform", GetXfmMat__FP3XFMP7MATRIX3);
INCLUDE_ASM(const s32, "P2/xform", PwarpFromOid__F3OIDT0);
INCLUDE_ASM(const s32, "P2/xform", LoadWarpFromBrx__FP4WARPP18CBinaryInputStream);
INCLUDE_ASM(const s32, "P2/xform", CloneWarp__FP4WARPT0);
INCLUDE_ASM(const s32, "P2/xform", PostWarpLoad__FP4WARP);
INCLUDE_ASM(const s32, "P2/xform", TriggerWarp__FP4WARP);
INCLUDE_ASM(const s32, "P2/xform", SetWarpRsmg__FP4WARPi3OIDN22);
INCLUDE_ASM(const s32, "P2/xform", func_001F4308);
INCLUDE_ASM(const s32, "P2/xform", TeleportSwPlayer__FP2SW3OIDT1);
INCLUDE_ASM(const s32, "P2/xform", PexitDefault__Fv);
INCLUDE_ASM(const s32, "P2/xform", TriggerDefaultExit__Fi5WIPEK);
INCLUDE_ASM(const s32, "P2/xform", LoadExitFromBrx__FP4EXITP18CBinaryInputStream);
INCLUDE_ASM(const s32, "P2/xform", PostExitLoad__FP4EXIT);
INCLUDE_ASM(const s32, "P2/xform", SetExitExits__FP4EXIT5EXITS);
INCLUDE_ASM(const s32, "P2/xform", TriggerExit__FP4EXIT);
INCLUDE_ASM(const s32, "P2/xform", WipeExit__FP4EXIT);
INCLUDE_ASM(const s32, "P2/xform", UpdateExit__FfP4EXIT);
INCLUDE_ASM(const s32, "P2/xform", InitCamera__FP6CAMERA);
INCLUDE_ASM(const s32, "P2/xform", PostCameraLoad__FP6CAMERA);
INCLUDE_ASM(const s32, "P2/xform", EnableCamera__FP6CAMERA);