Skip to content

Commit

Permalink
Merge pull request ACreTeam#453 from Rainchus/master
Browse files Browse the repository at this point in the history
decompile ef_young_tree.c
  • Loading branch information
Cuyler36 authored Dec 1, 2024
2 parents b36ceb7 + fa49683 commit 2eb00c3
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 23 deletions.
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ def MatchingFor(*versions):
Object(NonMatching, "effect/ef_walk_asimoto.c"),
Object(NonMatching, "effect/ef_warau.c"),
Object(NonMatching, "effect/ef_yajirushi.c"),
Object(NonMatching, "effect/ef_young_tree.c"),
Object(Matching, "effect/ef_young_tree.c"),
Object(Matching, "effect/ef_yukidama.c"),
Object(Matching, "effect/ef_yukidaruma.c"),
Object(Matching, "effect/ef_yukihane.c"),
Expand Down
5 changes: 5 additions & 0 deletions include/ef_effect_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ extern "C" {
#define eEC_DEFAULT_DEATH_DIST (800.0f)
#define eEC_IGNORE_DEATH_DIST (-1000.203064f) // ignore death range check when set to this

#define eEC_BUSH_HAPPA_TREE (0 << 13)
#define eEC_BUSH_HAPPA_PALM (1 << 13)
#define eEC_BUSH_HAPPA_CEDAR (2 << 13)
#define eEC_BUSH_HAPPA_GOLD (3 << 13)

enum effect_type {
eEC_EFFECT_SHOCK,
eEC_EFFECT_DUST,
Expand Down
22 changes: 11 additions & 11 deletions include/m_field_make.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,17 @@ typedef struct field_display_list_info_s {
} mFM_field_draw_info_c;

typedef struct field_pal_s {
u16* earth_pal;
u16* cliff_pal;
u16* bush_pal;
u16* flower0_pal;
u16* flower1_pal;
u16* flower2_pal;
u16* grass_pal;
u16* tree_pal;
u16* cedar_tree_pal; // probably?
u16* palm_tree_pal;
u16* golden_tree_pal;
/* 0x00 */ u16* earth_pal;
/* 0x04 */ u16* cliff_pal;
/* 0x08 */ u16* bush_pal;
/* 0x0C */ u16* flower0_pal;
/* 0x10 */ u16* flower1_pal;
/* 0x14 */ u16* flower2_pal;
/* 0x18 */ u16* grass_pal;
/* 0x1C */ u16* tree_pal;
/* 0x20 */ u16* cedar_tree_pal; // probably?
/* 0x24 */ u16* palm_tree_pal;
/* 0x28 */ u16* golden_tree_pal;
} mFM_field_pal_c;

typedef struct field_bg_sound_source_s {
Expand Down
14 changes: 7 additions & 7 deletions src/actor/ac_effectbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,17 +646,17 @@ static void EffectBG_Make_Leafs(EffectBg_c* efbg, GAME* game, xyz_t pos, s16 cou
}
} else if (type == EffectBG_EFFECT_CUT_RIGHT_PALM) {
bush_yuki_type = 0;
bush_happa_type = 0x2000 | 4;
bush_happa_type = eEC_BUSH_HAPPA_PALM | 4;
} else if (type == EffectBG_EFFECT_CUT_RIGHT_CEDAR) {
bush_yuki_type = 0;
bush_happa_type = 0x4000 | 4;
bush_happa_type = eEC_BUSH_HAPPA_CEDAR | 4;
} else if (type == EffectBG_EFFECT_CUT_RIGHT_GOLD) {
bush_yuki_type = 0;

if (Common_Get(time).term_idx == mTM_TERM_4) {
bush_happa_type = 0x4000 | 0x2000 | 6;
bush_happa_type = eEC_BUSH_HAPPA_GOLD | 6;
} else {
bush_happa_type = 0x4000 | 0x2000 | 4;
bush_happa_type = eEC_BUSH_HAPPA_GOLD | 4;
}
} else {
if (Common_Get(time).term_idx == 4) {
Expand All @@ -669,11 +669,11 @@ static void EffectBG_Make_Leafs(EffectBg_c* efbg, GAME* game, xyz_t pos, s16 cou
}

if ((efbg->status & EffectBg_STATUS_GOLD) != 0 || efbg->variant == EffectBG_VARIANT_GOLD_SMALL) {
bush_happa_type |= 0x4000 | 0x2000;
bush_happa_type |= eEC_BUSH_HAPPA_GOLD;
} else if ((efbg->status & EffectBg_STATUS_PALM) != 0 || efbg->variant == EffectBG_VARIANT_PALM_SMALL) {
bush_happa_type |= 0x2000;
bush_happa_type |= eEC_BUSH_HAPPA_PALM;
} else if ((efbg->status & EffectBg_STATUS_CEDAR) != 0 || efbg->variant == EffectBG_VARIANT_CEDAR_SMALL) {
bush_happa_type |= 0x4000;
bush_happa_type |= eEC_BUSH_HAPPA_CEDAR;
}

while (count-- != 0) {
Expand Down
162 changes: 158 additions & 4 deletions src/effect/ef_young_tree.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "ef_effect_control.h"
#include "m_common_data.h"
#include "m_debug.h"
#include "m_rcp.h"
#include "sys_matrix.h"

static void eYoung_Tree_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1);
static void eYoung_Tree_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg);
Expand All @@ -18,17 +22,167 @@ eEC_PROFILE_c iam_ef_young_tree = {
};

static void eYoung_Tree_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1) {
// TODO
eEC_CLIP->make_effect_proc(eEC_EFFECT_YOUNG_TREE, pos, NULL, game, NULL, item_name, prio, arg0, arg1);
}

static void eYoung_Tree_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg) {
// TODO
GAME_PLAY* play = (GAME_PLAY*)game;
Camera2* camera = &play->camera;

f32 dist = search_position_distance(&camera->lookat.eye, &camera->lookat.center);

effect->scale.x = 0.010299999f;
effect->scale.y = 0.0095f;
effect->scale.z = 0.0095f;

if (effect->arg0 == 2 || effect->arg0 == 1) {
effect->velocity = ZeroVec;
effect->velocity.y = 0.75f;
effect->acceleration = ZeroVec;
effect->acceleration.y = -0.05f;
effect->timer = 40;
} else if (effect->arg0 == 3) {
effect->velocity = ZeroVec;
effect->acceleration = ZeroVec;
effect->timer = 14;
} else {
effect->velocity = ZeroVec;
effect->acceleration = ZeroVec;
effect->timer = 82;
}
effect->effect_specific[1] = 0;
effect->effect_specific[2] = 0;

xyz_t_sub(&camera->lookat.eye, &camera->lookat.center, &effect->offset);
xyz_t_mult_v(&effect->offset, 1.0f / dist);
effect->effect_specific[0] = Common_Get(time.season);
}

static void eYoung_Tree_mv(eEC_Effect_c* effect, GAME* game) {
// TODO
f32 fVar4;
f32 dVar3;
xyz_t effPos;
xyz_t effPos2;
s16 uVar2;

xyz_t_add(&effect->velocity, &effect->acceleration, &effect->velocity);
xyz_t_add(&effect->position, &effect->velocity, &effect->position);
if (effect->arg0 == 1) {
effect->effect_specific[1] = effect->effect_specific[1] + 384;
} else if (effect->arg0 == 2) {
effect->effect_specific[1] = effect->effect_specific[1] - 384;
} else {
dVar3 = eEC_CLIP->calc_adjust_proc(effect->timer, 0, 0x28, 0.0f, 2184.0f);
fVar4 = sin_s(effect->effect_specific[2]);

effect->effect_specific[1] = dVar3 * fVar4;
effect->effect_specific[2] = effect->effect_specific[2] + 0xC68;
if ((effect->timer & 0x1F) == 0) {
effPos = effect->position;
if (Common_Get(time).term_idx == mTM_TERM_4) {
uVar2 = 6;
} else {
uVar2 = 4;
}

if (effect->arg1 == 1) {
uVar2 |= eEC_BUSH_HAPPA_PALM;
} else if (effect->arg1 == 2) {
uVar2 |= eEC_BUSH_HAPPA_CEDAR;
} else if (effect->arg1 == 3) {
uVar2 |= eEC_BUSH_HAPPA_GOLD;
}

effPos.x = effPos.x + fqrand2() * 30.0f;
effPos.y = effPos.y + fqrand() * 30.0f;
uVar2 |= 0x8000;

eEC_CLIP->effect_make_proc(eEC_EFFECT_BUSH_HAPPA, effPos, 2, 0, game, 0xFFFF, 0, uVar2);

if (effect->effect_specific[0] == 3) {
effPos2 = effect->position;
effPos2.x = effPos2.x + fqrand2() * 30.0f;
effPos2.y = effPos2.y + fqrand() * 30.0f;
eEC_CLIP->effect_make_proc(eEC_EFFECT_BUSH_YUKI, effPos2, 2, 0, game, 0xFFFF, 0, 0);
}
}
}
}

extern Gfx ef_w_young_palm_modelT[];
extern Gfx ef_s_young_palm_modelT[];
extern Gfx ef_w_young_cedar_modelT[];
extern Gfx ef_s_young_cedar_modelT[];
extern Gfx ef_w_youngtree_00_modelT[];
extern Gfx ef_f_youngtree_00_modelT[];
extern Gfx ef_s_youngtree_00_modelT[];

static void eYoung_Tree_dw(eEC_Effect_c* effect, GAME* game) {
// TODO
GRAPH* graph;
mFM_field_pal_c* field_pal = mFI_GetFieldPal();
u16* cedar_pal = field_pal->cedar_tree_pal;
u16* palm_pal = field_pal->palm_tree_pal;
u16* golden_pal = field_pal->golden_tree_pal;
s16 remain = 0x28 - effect->timer;
u8 alpha;

if (effect->arg0 == 2 || effect->arg0 == 1) {
alpha = (int)eEC_CLIP->calc_adjust_proc(remain, 0, 0x28, 255.0f, 0.0f);
} else {
alpha = (int)eEC_CLIP->calc_adjust_proc(effect->timer, 0, 8, 0.0f, 255.0f);
}

graph = game->graph;
_texture_z_light_fog_prim_xlu(graph);
Matrix_translate(effect->position.x, effect->position.y + 3.0f, effect->position.z + 3.0f, 0);

if (effect->arg1 == 0 || effect->arg1 == 3) {
Matrix_RotateVector(effect->effect_specific[1], &effect->offset, 1);
} else if (effect->arg1 == 1) {
Matrix_translate(0.0f, (f32)GETREG(TAKREG, 20) + 5.0f, 0.0f, 1);
Matrix_RotateVector(effect->effect_specific[1], &effect->offset, 1);
Matrix_translate(0.0f, -5.0f - (f32)GETREG(TAKREG, 20), 0.0f, 1);
} else {
Matrix_translate(0.0f, 15.0f, 0.0f, 1);
Matrix_RotateVector(effect->effect_specific[1], &effect->offset, 1);
Matrix_translate(0.0f, -15.0f, 0.0f, 1);
}
Matrix_scale(effect->scale.x, effect->scale.y, effect->scale.z, 1);

OPEN_DISP(graph);
gSPMatrix(NEXT_POLY_XLU_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);

if (effect->arg1 == 0) {
gSPSegment(NEXT_POLY_XLU_DISP, ANIME_1_TXT_SEG, cedar_pal);
} else if (effect->arg1 == 3) {
gSPSegment(NEXT_POLY_XLU_DISP, ANIME_1_TXT_SEG, golden_pal);
} else {
gSPSegment(NEXT_POLY_XLU_DISP, ANIME_1_TXT_SEG, palm_pal);
}

gDPSetPrimColor(NEXT_POLY_XLU_DISP, 0, 255, 255, 255, 255, alpha);
gDPSetTextureAdjustMode(NEXT_POLY_XLU_DISP, G_TA_DOLPHIN);

if (effect->arg1 == 1) {
if (effect->effect_specific[0] == 3) {
gSPDisplayList(NEXT_POLY_XLU_DISP, &ef_w_young_palm_modelT);
} else {
gSPDisplayList(NEXT_POLY_XLU_DISP, &ef_s_young_palm_modelT);
}
} else if (effect->arg1 == 2) {
if (effect->effect_specific[0] == 3) {
gSPDisplayList(NEXT_POLY_XLU_DISP, &ef_w_young_cedar_modelT);
} else {
gSPDisplayList(NEXT_POLY_XLU_DISP, &ef_s_young_cedar_modelT);
}
} else if (effect->effect_specific[0] == 3) {
gSPDisplayList(NEXT_POLY_XLU_DISP, &ef_w_youngtree_00_modelT);
} else if (Common_Get(time).term_idx == mTM_TERM_4) {
gSPDisplayList(NEXT_POLY_XLU_DISP, &ef_f_youngtree_00_modelT);
} else {
gSPDisplayList(NEXT_POLY_XLU_DISP, &ef_s_youngtree_00_modelT);
}

gDPSetTextureAdjustMode(NEXT_POLY_XLU_DISP, G_TA_N64);
CLOSE_DISP(graph);
}

0 comments on commit 2eb00c3

Please sign in to comment.