Add coin.c and fill in related headers

This commit is contained in:
Zac 2024-07-05 21:00:36 +00:00 committed by GitHub
parent 9dd2292713
commit fe18c5d893
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 359 additions and 4 deletions

View File

@ -115,7 +115,7 @@ segments:
- [0x43ed0, c, P2/clock]
- [0x44148, c, P2/cm]
- [0x47100, asm, P2/cnvo]
- [0x491A0, asm, P2/coin]
- [0x491A0, c, P2/coin]
- [0x4a398, asm, P2/cplcy]
- [0x4bbd0, asm, P2/credit]

View File

@ -173,6 +173,43 @@ _GLOBAL_$I$StartupCm__Fv = 0x1460E0; // type:func
g_pcm = 0x261990; // size:0x4
// P2/coin.c
InitDprize__FP6DPRIZE = 0x146340; // type:func
LoadDprizeFromBrx__FP6DPRIZEP18CBinaryInputStream = 0x1463C0; // type:func
CloneDprize__FP6DPRIZET0 = 0x146418; // type:func
PostDprizeLoad__FP6DPRIZE = 0x146470; // type:func
ProjectDprizeTransform__FP6DPRIZEfi = 0x146518; // type:func
FFilterDprizeObjects__FP6DPRIZEP2SO = 0x146D10; // type:func
CheckDprizeBounce__FP6DPRIZE = 0x146DB0; // type:func
CheckDprizeCollect__FP6DPRIZE = 0x1471B0; // type:func
FAbsorbDprizeWkr__FP6DPRIZEP3WKR = 0x1473E0; // type:func
UpdateDprize__FP6DPRIZEf = 0x147428; // type:func
RenderDprizeAll__FP6DPRIZEP2CMP2RO = 0x1478F0; // type:func
SetDprizeDprizes__FP6DPRIZE7DPRIZES = 0x147AB0; // type:func
InitCoin__FP4COIN = 0x147E40; // type:func
FUN_00147ed0 = 0x147ED0; // type:func
FUN_00147ef8 = 0x147EF8; // type:func
UpdateCoin__FP4COINf = 0x147FB0; // type:func
CreateSwCharm__FP2SW = 0x148038; // type:func
AddLife__FPv = 0x148178; // type:func
OnCoinSmack__FP4COIN = 0x1481A0; // type:func
SetCoinDprizes__FP4COIN7DPRIZES = 0x148298; // type:func
FUN_00148400 = 0x148400; // type:func
SetCharmDprizes__FP5CHARM7DPRIZES = 0x148470; // type:func
FUN_00148510 = 0x148510; // type:func
SetKeyDprizes__FP3KEY7DPRIZES = 0x148598; // type:func
FUN_00148698 = 0x148698; // type:func
FUN_00148718 = 0x148718; // type:func
FUN_00148748 = 0x148748; // type:func
FUN_00148770 = 0x148770; // type:func
FUN_00148828 = 0x148828; // type:func
FUN_00148888 = 0x148888; // type:func
FUN_00148938 = 0x148938; // type:func
CpdprizeAttractSwDprizes__FP2SW3CIDP6VECTORiPP6DPRIZE = 0x148AC0; // type:func
RemoveSwExtraneousCharms__FP2SW = 0x148CE0; // type:func
// P2/difficulty.c
PdifficultyEnsureSw = 0x1519E0; // type:func
OnDifficultyGameLoad = 0x151A68; // type:func

52
include/anim.h Normal file
View File

@ -0,0 +1,52 @@
/**
* @file anim.h
*
* @brief Animation.
*
* @todo Implement structs.
*/
#ifndef ANIM_H
#define ANIM_H
#include "common.h"
#include <lo.h>
// Forward declarations.
struct ASEG;
struct ASEGA;
struct ASEGD;
struct ASEGBL;
/**
* @brief Animation segment.
*/
struct ASEG : public LO
{
// ...
};
/**
* @brief Animation segment something(?).
*/
struct ASEGA : public BASIC
{
// ...
};
/**
* @brief Animation segment something(?).
*/
struct ASEGD
{
// ...
};
/**
* @brief Animation segment blend.
*/
struct ASEGBL : public ASEG
{
// ...
};
#endif // ANIM_H

View File

@ -1,11 +1,97 @@
/**
* @file coin.h
*
* @brief Coins, keys, and other collectibles.
*/
#ifndef COIN_H
#define COIN_H
#include "common.h"
#include <alo.h>
#include <oid.h>
#include <sm.h>
#include <xform.h>
// ...
// Forward declarations
struct DPRIZE;
struct COIN;
struct KEY;
/**
* @brief DPRIZE state.
*
* @note Values based on May 19 build.
*/
enum DPRIZES
{
DPRIZES_Nil = -1,
DPRIZES_Normal = 0,
DPRIZES_Collect = 1,
DPRIZES_Removed = 2,
DPRIZES_Fall = 3,
DPRIZES_Swirl = 4,
DPRIZES_Stick = 5,
DPRIZES_Lose = 6,
DPRIZES_Attract = 7,
DPRIZES_Max = 8
};
/**
* @brief DPRIZE.
*
* Base class for coins, keys, and other collectibles.
*/
struct DPRIZE : public ALO
{
DPRIZES dprizes; // State
float tDprizes;
DPRIZES dprizesInit;
OID oidInitialState;
float dtInitialSkip;
SM *psm; // State machine
SMA *psma; // State machine action
TARGET *ptarget;
VECTOR posCenter;
VECTOR vCenter;
VECTOR dvCenter;
float uGlintChance;
PNT *ppntFrontGlint;
PNT *ppntBackGlint;
int fNeverReuse;
int fReuseCandidate;
int fLastBounce;
float svLastBounceMax;
float svLastBounce;
float sRadiusBounce;
float sRadiusCollect;
float rzBounce;
float rxyBounce;
float radSmooth;
undefined4 unk_0;
VECTOR normalSmooth;
int fSwirlDone;
DLE dle;
int ichkCollected;
EXPL *pexplCollect;
EXPL *pexplAttract;
float svcAtract;
float cAttract;
};
/**
* @brief Coin.
*/
struct COIN : public DPRIZE
{
// ...
};
/**
* @brief Treasure key.
*/
struct KEY : public DPRIZE
{
// ...
};
#endif // COIN_H

View File

@ -6,6 +6,8 @@
#ifndef MQ_H
#define MQ_H
#include "common.h"
/**
* @brief Message ID
*

View File

@ -1,11 +1,73 @@
/**
* @file sm.h
*
* @brief State machines.
*/
#ifndef SM_H
#define SM_H
#include "common.h"
#include <dl.h>
#include <anim.h>
#include <mq.h>
// ...
// Forward declatations.
struct SM;
struct SMA;
struct SMT;
struct SMS;
/**
* @brief State machine.
*/
struct SM : public LO
{
int csms;
SMS *asms;
int csmt;
SMT *asmt;
int fDefault;
DL dlSma;
};
/**
* @brief State machine action.
*/
struct SMA : public BASIC
{
DLE dleSm;
DLE dleSw;
SM *psm;
ALO *paloRoot;
int grfapl;
ASEGA *pasegaCur;
int ismsCur;
int ismsNext;
int ismsGoal;
SMT *psmtCur;
float svtLocal;
MQ *pmqFirst;
};
/**
* @brief State machine transition.
*/
struct SMT
{
undefined4 unk_0;
int ismsFrom;
int ismsTo;
int grfsmt;
float gProbability;
};
/**
* @brief State machine state(?).
*/
struct SMS
{
OID oid;
undefined4 unk_0;
};
#endif // SM_H

View File

@ -1,5 +1,7 @@
/**
* @file xform.h
*
* @brief Transform.
*/
#ifndef XFORM_H
#define XFORM_H
@ -8,19 +10,84 @@
#include <alo.h>
#include <vec.h>
#include <mat.h>
#include <oid.h>
#include <dl.h>
// Forward declarations
struct XFM;
struct EXPL;
struct EXPLG;
struct EXPLO;
struct EXPLS;
struct EXPLSO;
struct EXPLSTE;
struct TARGET;
struct PNT;
struct CAMERA;
/**
* @brief Transform.
*/
struct XFM : public LO
{
VECTOR posLocal;
MATRIX3 matLocal;
};
struct EXPL : public XFM
{
// ...
};
struct EXPLG : public EXPL
{
// ...
};
struct EXPLO : public EXPL
{
// ...
};
struct EXPLS : public EXPLO
{
// ...
};
struct EXPLSO
{
// ...
};
struct EXPLSTE
{
// ...
};
struct TARGET : public XFM
{
DLE dleTarget;
int grftak;
float sRadiusTarget;
int fHitTest;
undefined4 unk0;
undefined4 unk1;
undefined4 unk2;
};
/**
* @brief Point.
*/
struct PNT : public LO
{
VECTOR posLocal;
};
/**
* @brief Camera.
*
* @note Not the same as the game camera CM. More research needed.
* Might be in the wrong header.
*/
struct CAMERA : public ALO
{
OID oidTarget;

49
src/P2/coin.c Normal file
View File

@ -0,0 +1,49 @@
#include <coin.h>
INCLUDE_ASM(const s32, "P2/coin", OnCoinSmack__FP4COIN);
INCLUDE_ASM(const s32, "P2/coin", SetCoinDprizes__FP4COIN7DPRIZES);
INCLUDE_ASM(const s32, "P2/coin", FUN_00148400);
INCLUDE_ASM(const s32, "P2/coin", SetCharmDprizes__FP5CHARM7DPRIZES);
INCLUDE_ASM(const s32, "P2/coin", FUN_00148510);
INCLUDE_ASM(const s32, "P2/coin", SetKeyDprizes__FP3KEY7DPRIZES);
INCLUDE_ASM(const s32, "P2/coin", FUN_00148698);
INCLUDE_ASM(const s32, "P2/coin", FUN_00148718);
INCLUDE_ASM(const s32, "P2/coin", FUN_00148748);
INCLUDE_ASM(const s32, "P2/coin", FUN_00148770);
INCLUDE_ASM(const s32, "P2/coin", FUN_00148828);
INCLUDE_ASM(const s32, "P2/coin", FUN_00148888);
INCLUDE_ASM(const s32, "P2/coin", func_00148910);
INCLUDE_ASM(const s32, "P2/coin", FUN_00148938);
INCLUDE_ASM(const s32, "P2/coin", CpdprizeAttractSwDprizes__FP2SW3CIDP6VECTORiPP6DPRIZE);
INCLUDE_ASM(const s32, "P2/coin", RemoveSwExtraneousCharms__FP2SW);
INCLUDE_ASM(const s32, "P2/coin", func_00148D90);
INCLUDE_ASM(const s32, "P2/coin", func_00148E18);
INCLUDE_ASM(const s32, "P2/coin", func_00148E40);
INCLUDE_ASM(const s32, "P2/coin", func_00148EF8);
INCLUDE_ASM(const s32, "P2/coin", func_00148F80);
INCLUDE_ASM(const s32, "P2/coin", func_00148FF0);
INCLUDE_ASM(const s32, "P2/coin", func_00149168);
INCLUDE_ASM(const s32, "P2/coin", func_00149190);