En_Elforg (Stray Fairy) OK and mostly documented (#359)

* Migrate data to C

* EnElforg_Init OK

* func_80ACC470 OK

* EnElforg_Destroy OK

* EnElforg_Update OK

* func_80ACCBD0 OK

* func_80ACCBB8 OK

* func_80ACD6EC OK

* func_80ACD59C OK

* func_80ACD6A8 OK

* func_80ACD610 OK

* func_80ACD878 OK

* Declare animated materials for Elforg

* EnElforg_Draw OK

* func_80ACCC98 OK

* func_80ACC7E4 OK

* func_80ACC8D4 OK

* func_80ACCEB0 OK

* func_80ACC994 OK

* PLAYER -> GET_PLAYER

* func_80ACCE4C OK

* func_80ACC934 OK

* func_80ACCAC0 OK

* func_80ACD2E4 OK

* func_80ACD1F0 OK

* func_80ACD164 OK

* func_80ACD1B0 OK (maybe fakematch but oh well)

* func_80ACD088 OK

* Better match for func_80ACD1B0

* Use compiled reloc

* Move static data to appropriate function

* Name sCylinderInit appropriately

* Add explanatory comment

* Clean up forward declarations

* Add macro for the flag

* Macro and enum for type

* Add STRAY_FAIRY_GET_PARAM_1C0 macro (no clue what this does)

* Document the area stuff

* Name some functions

* Document timer and direction

* Eliminate some early returns

* Tons more documentation

* Name remaining functions

* Document flags

* Name targetDistanceFromHome

* fairyFountainTimer -> secondaryTimer, since it's used outside of Fairy Fountains

* Name the unknown flag

* Name the collider fairy type

* Last bit of renaming/documenting

* Remove zero check

* Use hex constant for newAngle

* Merge animation updates

* Use 0x10000 instead of 65536.0f

* Use decimal for alpha

* Move yDifference initialization up to the same line as declaration

* Use +=/-=

* <= 30 instead of < 31

* += -1 -> --

* >= 81 -> > 80

* 0xDFFFFFFF -> ~0x20000000

* EnElforg_InitializeSpeedAndRotation -> EnElforg_InitializeParams
This commit is contained in:
Tom Overton
2021-10-31 13:25:10 -03:00
committed by GitHub
parent b1b114e142
commit d4effceefd
9 changed files with 642 additions and 62 deletions
+1
View File
@@ -1,3 +1,4 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "prevent_bss_reordering.h"
+1
View File
@@ -1,3 +1,4 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "prevent_bss_reordering.h"
@@ -5,6 +5,7 @@
*/
#include "z_en_elfbub.h"
#include "overlays/actors/ovl_En_Elforg/z_en_elforg.h"
#define FLAGS 0x00000001
@@ -76,7 +77,7 @@ void EnElfbub_Init(Actor* thisx, GlobalContext* globalCtx) {
childActor = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ELFORG,
this->actor.world.pos.x, this->actor.world.pos.y + 12.0f, this->actor.world.pos.z,
this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z,
((ENELFBUB_GET_SWITCHFLAG(&this->actor) & 0x7F) << 9) | 2);
((ENELFBUB_GET_SWITCHFLAG(&this->actor) & 0x7F) << 9) | STRAY_FAIRY_TYPE_BUBBLE);
if (childActor != NULL) {
childActor->parent = &this->actor;
}
File diff suppressed because it is too large Load Diff
@@ -3,14 +3,54 @@
#include "global.h"
#define STRAY_FAIRY_TYPE(thisx) ((thisx)->params & 0xF)
#define STRAY_FAIRY_GET_PARAM_1C0(thisx) ((thisx)->params & 0x1C0)
#define STRAY_FAIRY_FLAG(thisx) (((thisx)->params & 0xFE00) >> 9)
#define STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME (1 << 0)
#define STRAY_FAIRY_FLAG_SPARKLES_AND_SHRINKS (1 << 1)
#define STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN (1 << 2)
#define STRAY_FAIRY_FLAG_GREAT_FAIRYS_MASK_EQUIPPED (1 << 3)
typedef enum {
STRAY_FAIRY_TYPE_FREE_FLOATING, // The ones just floating around
STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN, // The ones already present when you enter a Fairy Fountain
STRAY_FAIRY_TYPE_BUBBLE, // The ones trapped in bubbles
STRAY_FAIRY_TYPE_CLOCK_TOWN, // The free-floating Stray Fairies in Clock Town
STRAY_FAIRY_TYPE_ENEMY, // The ones trapped inside enemies
STRAY_FAIRY_TYPE_COLLIDER, // Unused in retail. The fairy is hidden until the collider is hit
STRAY_FAIRY_TYPE_CHEST, // The ones in treasure chests
STRAY_FAIRY_TYPE_COLLECTIBLE, // The ones in boxes, pots, beehives, etc.
STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN // The ones you "turn in" by walking into a Fairy Fountain
} StrayFairyType;
typedef enum {
STRAY_FAIRY_AREA_CLOCK_TOWN,
STRAY_FAIRY_AREA_WOODFALL,
STRAY_FAIRY_AREA_SNOWHEAD,
STRAY_FAIRY_AREA_GREAT_BAY,
STRAY_FAIRY_AREA_STONE_TOWER,
STRAY_FAIRY_AREA_MAX
} StrayFairyArea;
struct EnElforg;
typedef void (*EnElforgActionFunc)(struct EnElforg*, GlobalContext*);
typedef struct EnElforg {
/* 0x0000 */ Actor actor;
/* 0x0144 */ char unk_144[0xE8];
/* 0x022C */ EnElforgActionFunc actionFunc;
/* 0x000 */ Actor actor;
/* 0x144 */ SkelAnime skelAnime;
/* 0x188 */ Vec3s jointTable[10];
/* 0x1C4 */ ColliderCylinder collider;
/* 0x210 */ Actor* enemy;
/* 0x214 */ u16 flags;
/* 0x216 */ s16 direction; // negative when facing left, positive when facing right
/* 0x218 */ s16 area;
/* 0x21C */ s32 timer;
/* 0x220 */ s32 secondaryTimer;
/* 0x224 */ f32 targetSpeedXZ;
/* 0x228 */ f32 targetDistanceFromHome;
/* 0x22C */ EnElforgActionFunc actionFunc;
} EnElforg; // size = 0x230
extern const ActorInit En_Elforg_InitVars;