mirror of
https://github.com/zeldaret/mm.git
synced 2026-05-23 06:54:14 -04:00
z_fireobj.h header (#1179)
* fireobj.h * name states and cleanups * minor cleanups * format * bss * review * bss * review
This commit is contained in:
+1
-6
@@ -1292,12 +1292,7 @@ s16 ActorCutscene_GetCurrentSubCamId(s16 index);
|
||||
s16 func_800F21CC(void);
|
||||
s32 func_800F22C4(s16 param_1, Actor* actor);
|
||||
void ActorCutscene_SetReturnCamera(s16 index);
|
||||
void FireObj_SetPosition(FireObj* fire, Vec3f* pos);
|
||||
void FireObj_Draw(PlayState* play, FireObj* fire);
|
||||
void FireObj_Init(PlayState* play, FireObj* fire, FireObjInitParams* init, Actor* actor);
|
||||
void FireObj_Destroy(PlayState* play, FireObj* fire);
|
||||
void FireObj_SetState2(FireObj* fire, f32 dynamicSizeStep, u8 newState);
|
||||
void FireObj_Update(PlayState* play, FireObj* fire, Actor* actor);
|
||||
|
||||
s32 func_800F3940(PlayState* play);
|
||||
// void func_800F39B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
|
||||
// void func_800F3A64(void);
|
||||
|
||||
@@ -140,28 +140,6 @@ typedef struct {
|
||||
/* 0xF */ s8 a;
|
||||
} F3DVertexNormal; // size = 0x10
|
||||
|
||||
typedef struct {
|
||||
/* 0x0 */ f32 size;
|
||||
/* 0x4 */ f32 dynamicSizeStep;
|
||||
/* 0x8 */ u8 state;
|
||||
/* 0x9 */ u8 sizeGrowsCos2;
|
||||
/* 0xA */ u8 colorsIndex;
|
||||
/* 0xB */ u8 flags;
|
||||
/* 0xC */ u8 lightParamsIndex;
|
||||
} FireObjInitParams; // size = 0x10
|
||||
|
||||
typedef struct FireObjColors {
|
||||
/* 0x0 */ Color_RGBA8 primColor;
|
||||
/* 0x4 */ u8 lod;
|
||||
/* 0x5 */ Color_RGB8 envColor;
|
||||
} FireObjColors; // size = 0x8
|
||||
|
||||
typedef struct FireObjLightParams {
|
||||
/* 0x0 */ s16 radius;
|
||||
/* 0x2 */ Color_RGB8 color;
|
||||
/* 0x5 */ Color_RGB8 maxColorAdj;
|
||||
} FireObjLightParams; // size = 0x8
|
||||
|
||||
// Game Info aka. Static Context
|
||||
// Data normally accessed through REG macros (see regs.h)
|
||||
typedef struct {
|
||||
@@ -687,12 +665,6 @@ typedef enum {
|
||||
STACK_STATUS_OVERFLOW = 2
|
||||
} StackStatus;
|
||||
|
||||
typedef struct FireObjLight {
|
||||
/* 0x00 */ LightNode* light;
|
||||
/* 0x04 */ LightInfo lightInfo;
|
||||
/* 0x12 */ u8 lightParamsIndex;
|
||||
} FireObjLight; // size = 0x14
|
||||
|
||||
#define OS_SC_RETRACE_MSG 1
|
||||
#define OS_SC_DONE_MSG 2
|
||||
#define OS_SC_NMI_MSG 3 // name is made up, 3 is OS_SC_RDP_DONE_MSG in the original sched.c
|
||||
@@ -713,25 +685,6 @@ typedef struct {
|
||||
/* 0x130 */ OSThread thread;
|
||||
} AudioMgr; // size = 0x2E0
|
||||
|
||||
typedef struct FireObj {
|
||||
/* 0x00 */ Vec3f position;
|
||||
/* 0x0C */ f32 size;
|
||||
/* 0x10 */ f32 sizeInv;
|
||||
/* 0x14 */ f32 xScale;
|
||||
/* 0x18 */ f32 yScale;
|
||||
/* 0x1C */ f32 dynamicSize;
|
||||
/* 0x20 */ f32 dynamicSizeStep;
|
||||
/* 0x24 */ u8 state; // 0 - growing, 1 - shrinking, 2 - fully lit, 3 - not lit
|
||||
/* 0x25 */ u8 sizeGrowsCos2;
|
||||
/* 0x26 */ u8 unk26;
|
||||
/* 0x27 */ u8 colorsIndex;
|
||||
/* 0x28 */ u8 flags; // bit 0 - ?, bit 1 - ?
|
||||
/* 0x29 */ UNK_TYPE1 pad29[0x1];
|
||||
/* 0x2A */ s16 ignitionDelay;
|
||||
/* 0x2C */ ColliderCylinder collision;
|
||||
/* 0x78 */ FireObjLight light;
|
||||
} FireObj; // size = 0x8B
|
||||
|
||||
typedef struct {
|
||||
/* 0x0 */ u8 seqId;
|
||||
/* 0x1 */ u8 ambienceId;
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#include "PR/gbi.h"
|
||||
#include "color.h"
|
||||
|
||||
struct PlayState;
|
||||
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u8 ambientColor[3];
|
||||
/* 0x03 */ s8 diffuseDir1[3];
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
#ifndef Z_FIREOBJ_H
|
||||
#define Z_FIREOBJ_H
|
||||
|
||||
#include "ultra64.h"
|
||||
#include "color.h"
|
||||
#include "z64collision_check.h"
|
||||
#include "z64light.h"
|
||||
#include "z64math.h"
|
||||
|
||||
struct PlayState;
|
||||
struct Actor;
|
||||
|
||||
|
||||
typedef struct FireObjInitParams {
|
||||
/* 0x0 */ f32 size;
|
||||
/* 0x4 */ f32 dynamicSizeStep;
|
||||
/* 0x8 */ u8 state;
|
||||
/* 0x9 */ u8 sizeGrowsCos2;
|
||||
/* 0xA */ u8 colorsIndex;
|
||||
/* 0xB */ u8 flags;
|
||||
/* 0xC */ u8 lightParamsIndex;
|
||||
} FireObjInitParams; // size = 0x10
|
||||
|
||||
typedef struct FireObjColors {
|
||||
/* 0x0 */ Color_RGBA8 primColor;
|
||||
/* 0x4 */ u8 lod;
|
||||
/* 0x5 */ Color_RGB8 envColor;
|
||||
} FireObjColors; // size = 0x8
|
||||
|
||||
typedef struct FireObjLightParams {
|
||||
/* 0x0 */ s16 radius;
|
||||
/* 0x2 */ Color_RGB8 color;
|
||||
/* 0x5 */ Color_RGB8 maxColorAdj;
|
||||
} FireObjLightParams; // size = 0x8
|
||||
|
||||
typedef struct FireObjLight {
|
||||
/* 0x00 */ LightNode* light;
|
||||
/* 0x04 */ LightInfo lightInfo;
|
||||
/* 0x12 */ u8 lightParamsIndex;
|
||||
} FireObjLight; // size = 0x14
|
||||
|
||||
typedef struct FireObj {
|
||||
/* 0x00 */ Vec3f position;
|
||||
/* 0x0C */ f32 size;
|
||||
/* 0x10 */ f32 sizeInv;
|
||||
/* 0x14 */ f32 xScale;
|
||||
/* 0x18 */ f32 yScale;
|
||||
/* 0x1C */ f32 dynamicSize;
|
||||
/* 0x20 */ f32 dynamicSizeStep;
|
||||
/* 0x24 */ u8 state; // @see FireState enum
|
||||
/* 0x25 */ u8 sizeGrowsCos2;
|
||||
/* 0x26 */ u8 timer;
|
||||
/* 0x27 */ u8 colorsIndex;
|
||||
/* 0x28 */ u8 flags; // @see FIRE_FLAG_
|
||||
/* 0x2A */ s16 ignitionDelay;
|
||||
/* 0x2C */ ColliderCylinder collision;
|
||||
/* 0x78 */ FireObjLight light;
|
||||
} FireObj; // size = 0x8B
|
||||
|
||||
typedef enum FireState {
|
||||
/* 0 */ FIRE_STATE_GROWING,
|
||||
/* 1 */ FIRE_STATE_SHRINKING,
|
||||
/* 2 */ FIRE_STATE_FULLY_LIT,
|
||||
/* 3 */ FIRE_STATE_NOT_LIT,
|
||||
} FireState;
|
||||
|
||||
#define FIRE_FLAG_WATER_EXTINGUISHABLE (1 << 0)
|
||||
#define FIRE_FLAG_INTERACT_STICK (1 << 1)
|
||||
|
||||
void FireObj_SetPosition(FireObj* fire, Vec3f* pos);
|
||||
void FireObj_Draw(struct PlayState* play, FireObj* fire);
|
||||
void FireObj_Init(struct PlayState* play, FireObj* fire, FireObjInitParams* init, struct Actor* actor);
|
||||
void FireObj_Destroy(struct PlayState* play, FireObj* fire);
|
||||
void FireObj_SetState2(FireObj* fire, f32 dynamicSizeStep, u8 newState);
|
||||
void FireObj_Update(struct PlayState* play, FireObj* fire, struct Actor* actor);
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,3 @@
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
#include "overlays/gamestates/ovl_daytelop/z_daytelop.h"
|
||||
|
||||
+34
-37
@@ -1,14 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "z_fireobj.h"
|
||||
#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h"
|
||||
#include "objects/gameplay_keep/gameplay_keep.h"
|
||||
|
||||
typedef enum {
|
||||
FIRE_STATE_0,
|
||||
FIRE_STATE_1,
|
||||
FIRE_STATE_2,
|
||||
FIRE_STATE_3,
|
||||
} FireState;
|
||||
|
||||
ColliderCylinderInit sFireObjCollisionInit = {
|
||||
{
|
||||
COLTYPE_NONE,
|
||||
@@ -48,17 +41,17 @@ void FireObj_InitWithParams(PlayState* play, FireObj* fire, FireObjInitParams* i
|
||||
fire->xScale = 0.0f;
|
||||
fire->yScale = 0.0f;
|
||||
fire->dynamicSize = 0.0f;
|
||||
fire->unk26 = Rand_ZeroOne() * 20.0f;
|
||||
fire->timer = Rand_ZeroOne() * 20.0f;
|
||||
fire->ignitionDelay = -1;
|
||||
}
|
||||
|
||||
void FireObj_SetState(FireObj* fire, f32 dynamicSizeStep, u8 newState) {
|
||||
fire->state = newState;
|
||||
if (fire->state == FIRE_STATE_3) {
|
||||
if (fire->state == FIRE_STATE_NOT_LIT) {
|
||||
fire->yScale = 0.0f;
|
||||
fire->xScale = 0.0f;
|
||||
fire->dynamicSize = 0.0f;
|
||||
} else if (fire->state == FIRE_STATE_2) {
|
||||
} else if (fire->state == FIRE_STATE_FULLY_LIT) {
|
||||
fire->xScale = fire->yScale = fire->size;
|
||||
fire->dynamicSize = 1.0f;
|
||||
}
|
||||
@@ -70,15 +63,16 @@ void FireObj_SetPosition(FireObj* fire, Vec3f* pos) {
|
||||
}
|
||||
|
||||
void FireObj_StepSize(FireObj* fire) {
|
||||
if (fire->state == FIRE_STATE_0) {
|
||||
if (Math_StepToF(&fire->dynamicSize, 1.0f, fire->dynamicSizeStep) != 0) {
|
||||
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_2);
|
||||
if (fire->state == FIRE_STATE_GROWING) {
|
||||
if (Math_StepToF(&fire->dynamicSize, 1.0f, fire->dynamicSizeStep)) {
|
||||
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_FULLY_LIT);
|
||||
}
|
||||
} else if ((fire->state == FIRE_STATE_1) && (Math_StepToF(&fire->dynamicSize, 0.0f, fire->dynamicSizeStep) != 0)) {
|
||||
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3);
|
||||
} else if ((fire->state == FIRE_STATE_SHRINKING) &&
|
||||
(Math_StepToF(&fire->dynamicSize, 0.0f, fire->dynamicSizeStep))) {
|
||||
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_NOT_LIT);
|
||||
}
|
||||
if (fire->sizeGrowsCos2 == 1) {
|
||||
if ((fire->state == FIRE_STATE_0) || (fire->state == FIRE_STATE_1)) {
|
||||
if ((fire->state == FIRE_STATE_GROWING) || (fire->state == FIRE_STATE_SHRINKING)) {
|
||||
fire->xScale = (1.0f - Math_CosS(SQ(fire->dynamicSize) * 0x4000)) * fire->size;
|
||||
fire->yScale = fire->dynamicSize * fire->size;
|
||||
} else {
|
||||
@@ -101,39 +95,41 @@ void FireObj_UpdateStateTransitions(PlayState* play, FireObj* fire) {
|
||||
Vec3f dist;
|
||||
|
||||
FireObj_StepSize(fire);
|
||||
fire->unk26++;
|
||||
fire->timer++;
|
||||
if (fire->ignitionDelay > 0) {
|
||||
fire->ignitionDelay--;
|
||||
} else if (fire->ignitionDelay == 0) {
|
||||
fire->ignitionDelay = -1;
|
||||
if ((fire->state == FIRE_STATE_3) || (fire->state == FIRE_STATE_1)) {
|
||||
nextState = FIRE_STATE_0;
|
||||
if ((fire->state == FIRE_STATE_NOT_LIT) || (fire->state == FIRE_STATE_SHRINKING)) {
|
||||
nextState = FIRE_STATE_GROWING;
|
||||
} else {
|
||||
nextState = FIRE_STATE_1;
|
||||
nextState = FIRE_STATE_SHRINKING;
|
||||
}
|
||||
FireObj_SetState(fire, fire->dynamicSizeStep, nextState);
|
||||
}
|
||||
if ((fire->flags & 1) && (fire->state != FIRE_STATE_3) &&
|
||||
|
||||
if ((fire->flags & FIRE_FLAG_WATER_EXTINGUISHABLE) && (fire->state != FIRE_STATE_NOT_LIT) &&
|
||||
WaterBox_GetSurface1_2(play, &play->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) &&
|
||||
(waterY - fire->position.y > 6500.0f * fire->yScale)) {
|
||||
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3);
|
||||
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_NOT_LIT);
|
||||
}
|
||||
if ((fire->flags & 2) && (player->heldItemAction == PLAYER_IA_STICK)) {
|
||||
if ((fire->flags & FIRE_FLAG_INTERACT_STICK) && (player->heldItemAction == PLAYER_IA_STICK)) {
|
||||
Math_Vec3f_Diff(&player->meleeWeaponInfo[0].tip, &fire->position, &dist);
|
||||
if (Math3D_LengthSquared(&dist) < 400.0f) {
|
||||
if (Math3D_LengthSquared(&dist) < SQ(20.0f)) {
|
||||
sp40 = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (sp40) {
|
||||
if (fire->state == FIRE_STATE_3) {
|
||||
if (fire->state == FIRE_STATE_NOT_LIT) {
|
||||
if (player->unk_B28 > 0) {
|
||||
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0);
|
||||
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_GROWING);
|
||||
}
|
||||
} else if (player->unk_B28 == 0) {
|
||||
player->unk_B28 = 0xD2;
|
||||
player->unk_B28 = 210;
|
||||
SoundSource_PlaySfxAtFixedWorldPos(play, &fire->position, 20, NA_SE_EV_FLAME_IGNITION);
|
||||
} else if (player->unk_B28 < 0xC8) {
|
||||
player->unk_B28 = 0xC8;
|
||||
} else if (player->unk_B28 < 200) {
|
||||
player->unk_B28 = 200;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,13 +138,13 @@ void FireObj_Draw(PlayState* play, FireObj* fire) {
|
||||
s32 pad;
|
||||
FireObjColors* fireColors = &sFireObjColors[fire->colorsIndex];
|
||||
|
||||
if (fire->state != FIRE_STATE_3) {
|
||||
if (fire->state != FIRE_STATE_NOT_LIT) {
|
||||
Vec3s vec;
|
||||
|
||||
OPEN_DISPS(play->state.gfxCtx);
|
||||
func_8012C2DC(play->state.gfxCtx);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x08,
|
||||
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->unk26 * -20) & 511, 32, 128));
|
||||
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->timer * -20) % 512U, 32, 128));
|
||||
|
||||
gDPSetPrimColor(POLY_XLU_DISP++, 0, fireColors->lod, fireColors->primColor.r, fireColors->primColor.g,
|
||||
fireColors->primColor.b, fireColors->primColor.a);
|
||||
@@ -185,7 +181,7 @@ void FireObj_UpdateLight(PlayState* play, FireObjLight* light, FireObj* fire) {
|
||||
FireObjLightParams* lightParams = &sFireObjLightParams[light->lightParamsIndex];
|
||||
s16 radius;
|
||||
|
||||
if (fire->state == FIRE_STATE_3) {
|
||||
if (fire->state == FIRE_STATE_NOT_LIT) {
|
||||
Lights_PointSetColorAndRadius(&light->lightInfo, 0, 0, 0, -1);
|
||||
} else {
|
||||
radius = (fire->yScale * 140.0f * fire->sizeInv) + 60.0f;
|
||||
@@ -225,14 +221,15 @@ void FireObj_Update(PlayState* play, FireObj* fire, Actor* actor) {
|
||||
EnArrow* arrow = (EnArrow*)fire->collision.base.ac;
|
||||
|
||||
FireObj_UpdateStateTransitions(play, fire);
|
||||
if (fire->state == FIRE_STATE_3) {
|
||||
if ((fire->collision.base.acFlags & AC_HIT) && (fire->collision.info.acHitInfo->toucher.dmgFlags & 0x800)) {
|
||||
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0);
|
||||
if (fire->state == FIRE_STATE_NOT_LIT) {
|
||||
if ((fire->collision.base.acFlags & AC_HIT) &&
|
||||
(fire->collision.info.acHitInfo->toucher.dmgFlags & DMG_FIRE_ARROW)) {
|
||||
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_GROWING);
|
||||
}
|
||||
} else if ((fire->collision.base.acFlags & AC_HIT) && (arrow->actor.update != NULL) &&
|
||||
(arrow->actor.id == ACTOR_EN_ARROW)) {
|
||||
arrow->actor.params = 0;
|
||||
arrow->collider.info.toucher.dmgFlags = 0x800;
|
||||
arrow->collider.info.toucher.dmgFlags = DMG_FIRE_ARROW;
|
||||
}
|
||||
fire->collision.dim.pos.x = fire->position.x;
|
||||
fire->collision.dim.pos.y = fire->position.y;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "global.h"
|
||||
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
|
||||
#include "interface/parameter_static/parameter_static.h"
|
||||
|
||||
@@ -63,7 +63,7 @@ static ColliderCylinderInit sCylinderInit = {
|
||||
};
|
||||
|
||||
static FireObjInitParams sFireObjInit = {
|
||||
0.00405000010505f, 0.0500000007451f, 3, 1, 0, 0, 0,
|
||||
0.00405f, 1.0f / 20.0f, FIRE_STATE_NOT_LIT, 1, 0, 0, 0,
|
||||
};
|
||||
|
||||
static s16 sInitialAnglePerPetal[] = { 0x0000, 0x2AAA, 0x5555, 0x8000, 0xAAAA, 0xD555 };
|
||||
@@ -175,7 +175,7 @@ void BgNumaHana_Init(Actor* thisx, PlayState* play) {
|
||||
this->flowerRotationalVelocity = 0x147;
|
||||
|
||||
this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 210.0f;
|
||||
FireObj_SetState2(&this->fire, 0.05f, 2);
|
||||
FireObj_SetState2(&this->fire, 0.05f, FIRE_STATE_FULLY_LIT);
|
||||
Flags_SetSwitch(play, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor));
|
||||
BgNumaHana_SetupOpenedIdle(this);
|
||||
} else {
|
||||
@@ -215,7 +215,7 @@ void BgNumaHana_SetupClosedIdle(BgNumaHana* this) {
|
||||
* the cutscene where the petals unfold.
|
||||
*/
|
||||
void BgNumaHana_ClosedIdle(BgNumaHana* this, PlayState* play) {
|
||||
if (this->fire.state != 3) {
|
||||
if (this->fire.state != FIRE_STATE_NOT_LIT) {
|
||||
Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_FLAME_IGNITION);
|
||||
if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) {
|
||||
ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define Z_BG_NUMA_HANA_H
|
||||
|
||||
#include "global.h"
|
||||
#include "z_fireobj.h"
|
||||
|
||||
#define BG_NUMA_HANA_GET_TYPE(thisx) ((thisx)->params & 1)
|
||||
#define BG_NUMA_HANA_SWITCH_FLAG(thisx) (((thisx)->params >> 8) & 0x7F)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* Description: Breakable Pot With Grass
|
||||
*/
|
||||
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "z_obj_flowerpot.h"
|
||||
#include "objects/object_flowerpot/object_flowerpot.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user