diff --git a/config/rel_slices.yml b/config/rel_slices.yml index fcbcb0b8..3f1063b4 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -689,6 +689,10 @@ ac_dump.c: .text: [0x805AE704, 0x805AECE8] .rodata: [0x8064A7E8, 0x8064A808] .data: [0x806C5018, 0x806C5120] +ac_fallS.c: + .text: [0x805AECE8, 0x805AEF84] + .rodata: [0x8064A808, 0x8064A830] + .data: [0x806C5120, 0x806C5148] ac_kago.c: .text: [0x805B1A08, 0x805B1D50] .data: [0x806C5750, 0x806C57A8] diff --git a/include/ac_fallS.h b/include/ac_fallS.h index 078581be..24624c61 100644 --- a/include/ac_fallS.h +++ b/include/ac_fallS.h @@ -1,13 +1,16 @@ #ifndef AC_FALLS_H #define AC_FALLS_H -#include "types.h" -#include "m_actor.h" +#include "ac_structure.h" #ifdef __cplusplus extern "C" { #endif +typedef struct actor_fall_south_s{ + STRUCTURE_ACTOR structure_class; +}FALLS_ACTOR; + extern ACTOR_PROFILE FallS_Profile; #ifdef __cplusplus diff --git a/include/ac_fallSESW.h b/include/ac_fallSESW.h index 6284c5b1..5300a108 100644 --- a/include/ac_fallSESW.h +++ b/include/ac_fallSESW.h @@ -1,13 +1,16 @@ #ifndef AC_FALLSESW_H #define AC_FALLSESW_H -#include "types.h" -#include "m_actor.h" +#include "ac_structure.h" #ifdef __cplusplus extern "C" { #endif +typedef struct actor_falls_south_east_west{ + STRUCTURE_ACTOR structure_class; +}FALLSEW_ACTOR; + extern ACTOR_PROFILE FallSESW_Profile; #ifdef __cplusplus diff --git a/include/ac_tent.h b/include/ac_tent.h index c562a861..f43119c8 100644 --- a/include/ac_tent.h +++ b/include/ac_tent.h @@ -7,9 +7,9 @@ extern "C" { #endif -typedef struct actor_tent_s{ +typedef struct TENT_ACTOR_s{ STRUCTURE_ACTOR structure_class; -}ACTOR_TENT; +}TENT_ACTOR; extern ACTOR_PROFILE Tent_Profile; diff --git a/include/sys_math3d.h b/include/sys_math3d.h index 3c2d0a89..ef90a2bf 100644 --- a/include/sys_math3d.h +++ b/include/sys_math3d.h @@ -44,6 +44,7 @@ extern int Math3D_sphereVsPipe_cl(Math3D_sphere_c* s, Math3D_pipe_c* c, f32* in) extern int Math3D_pipeVsPipe_cl(Math3D_pipe_c* a, Math3D_pipe_c* b , f32* d); extern int Math3D_sphereCrossTriangle3_cp(Math3D_sphere_c* s, Math3D_triangle_c* tri, xyz_t* ip); extern int Math3D_pipeCrossTriangle_cp(Math3D_pipe_c* c,Math3D_triangle_c* tri, xyz_t* in); +extern void Math3DVectorProduct2Vec(const xyz_t* a, xyz_t* b, xyz_t* ret); extern xyz_t ZeroVec; extern s_xyz ZeroSVec; diff --git a/src/ac_fallS.c b/src/ac_fallS.c new file mode 100644 index 00000000..ace260b4 --- /dev/null +++ b/src/ac_fallS.c @@ -0,0 +1,33 @@ +#include "ac_fallS.h" +#include "m_name_table.h" +#include "evw_anime.h" +#include "m_common_data.h" +#include "m_lib.h" +#include "audio.h" +#include "sys_math3d.h" +#include "sys_matrix.h" + +extern Gfx obj_fallS_model[]; +extern Gfx obj_fallS_rainbowT_model[]; +extern EVW_ANIME_DATA obj_fallS_evw_anime; + +static void aFLS_actor_move(ACTOR* actor, GAME* game); +static void aFLS_actor_draw(ACTOR* actor, GAME* game); + +ACTOR_PROFILE FallS_Profile = { + mAc_PROFILE_FALLS, + ACTOR_PART_ITEM, + ACTOR_STATE_TA_SET, + WATERFALL_SOUTH, + ACTOR_OBJ_BANK_KEEP, + sizeof(FALLS_ACTOR), + NONE_ACTOR_PROC, + NONE_ACTOR_PROC, + aFLS_actor_move, + aFLS_actor_draw, + NULL, +}; + +#include "../src/ac_fallS_move.c_inc" + +#include "../src/ac_fallS_draw.c_inc" diff --git a/src/ac_fallS_draw.c_inc b/src/ac_fallS_draw.c_inc new file mode 100644 index 00000000..51a7e8ae --- /dev/null +++ b/src/ac_fallS_draw.c_inc @@ -0,0 +1,61 @@ + +void aFLS_actor_draw(ACTOR* actor, GAME* game) { + static const xyz_t shape_norm_vec = {0.0f, 0.0f, 1.0f}; + GAME_PLAY* play = (GAME_PLAY*)game; + GRAPH* graph = game->graph; + Gfx* gfx; + int a; + f32 vecLen; + f32 angle; + xyz_t bboard; + xyz_t l; + + _texture_z_light_fog_prim_xlu(graph); + + OPEN_DISP(graph); + + { + Gfx* gfx; + gfx = NOW_POLY_XLU_DISP; + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + NOW_POLY_XLU_DISP = gfx; + } + Evw_Anime_Set(play, &obj_fallS_evw_anime); + + gfx = NOW_POLY_XLU_DISP; + gSPDisplayList(gfx++, obj_fallS_model); + + if (Common_Get(rainbow_opacity) > 0.0f) { + a = (256.0f * Common_Get(rainbow_opacity)); + + if (a > 255) { + a = 255; + } + bboard.x = play->billboard_matrix.mf[2][0]; + bboard.y = play->billboard_matrix.mf[2][1]; + bboard.z = play->billboard_matrix.mf[2][2]; + + Math3DVectorProduct2Vec(&shape_norm_vec, &bboard, &l); + + vecLen = Math3DVecLength(&l); + + if (vecLen >= 0.0000001f) { + xyz_t_mult_v(&l, 1.0f / vecLen); + angle = facos(shape_norm_vec.z * bboard.z + ((shape_norm_vec.x * bboard.x) + shape_norm_vec.y * bboard.y)); + + Matrix_translate(actor->world.position.x, actor->world.position.y, actor->world.position.z, FALSE); + Matrix_RotateVector(RAD2SHORTANGLE(angle), &l, TRUE); + Matrix_scale(actor->scale.x, actor->scale.y, actor->scale.z, TRUE); + + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(gfx++, G_RM_FOG_SHADE_A, G_RM_XLU_SURF2); + gDPSetEnvColor(gfx++, 255, 255, 255, a); + gSPLoadGeometryMode(gfx++, G_SHADE | G_FOG | G_SHADING_SMOOTH); + gSPDisplayList(gfx++, obj_fallS_rainbowT_model); + } + } + + NOW_POLY_XLU_DISP = gfx; + CLOSE_DISP(graph); +} \ No newline at end of file diff --git a/src/ac_fallS_move.c_inc b/src/ac_fallS_move.c_inc new file mode 100644 index 00000000..daadde13 --- /dev/null +++ b/src/ac_fallS_move.c_inc @@ -0,0 +1,9 @@ +void aFLS_actor_move(ACTOR* actor, GAME*) { + xyz_t pos; + + xyz_t_move(&pos, &actor->world.position); + + pos.y += 40.0f; + + sAdo_OngenPos((u32)actor, 12, &pos); +} diff --git a/src/ac_tent.c b/src/ac_tent.c index d47b00a7..647b7937 100644 --- a/src/ac_tent.c +++ b/src/ac_tent.c @@ -17,7 +17,7 @@ ACTOR_PROFILE Tent_Profile = { ACTOR_STATE_TA_SET, TENT, ACTOR_OBJ_BANK_KEEP, - sizeof(ACTOR_TENT), + sizeof(TENT_ACTOR), aTnt_actor_ct, aTnt_actor_dt, aTnt_actor_init, @@ -56,8 +56,8 @@ static void aTnt_SetBgOffset(ACTOR* actor, int offset); static int aTnt_ControlLight(ACTOR* actor); -void aTnt_actor_ct(ACTOR* actor, GAME* game) { - ACTOR_TENT* tent = (ACTOR_TENT*)actor; +static void aTnt_actor_ct(ACTOR* actor, GAME* game) { + TENT_ACTOR* tent = (TENT_ACTOR*)actor; f32 t; aTnt_ChangeFg(actor, 1); @@ -73,11 +73,11 @@ void aTnt_actor_ct(ACTOR* actor, GAME* game) { tent->structure_class.arg0_f = t; } -void aTnt_actor_dt(ACTOR* actor, GAME* game) { +static void aTnt_actor_dt(ACTOR* actor, GAME* game) { aTnt_ChangeFg(actor, 0); } -void aTnt_ChangeFg(ACTOR* actor, int type) { +static void aTnt_ChangeFg(ACTOR* actor, int type) { xyz_t pos = actor->world.position; mActor_name_t* name; @@ -112,7 +112,7 @@ void aTnt_ChangeFg(ACTOR* actor, int type) { } } -void aTnt_SetBgOffset(ACTOR* actor, int type) { +static void aTnt_SetBgOffset(ACTOR* actor, int type) { static mCoBG_OffsetTable_c height_table_ct[] = { {100, 3, 1, 1, 7, 7, 0}, {100, 10, 10, 10, 10, 10, 0}, @@ -141,7 +141,7 @@ void aTnt_SetBgOffset(ACTOR* actor, int type) { } } -void aTnt_rewrite_out_data(ACTOR* actor, GAME_PLAY* play) { +static void aTnt_rewrite_out_data(ACTOR* actor, GAME_PLAY* play) { Door_data_c* door_data = Common_GetPointer(structure_exit_door_data); if (play->fb_wipe_mode == 0) { @@ -167,7 +167,7 @@ void aTnt_rewrite_out_data(ACTOR* actor, GAME_PLAY* play) { } } -int aTnt_check_player(ACTOR* actor, GAME_PLAY* play) { +static int aTnt_check_player(ACTOR* actor, GAME_PLAY* play) { u16 y; f32 xOffs; f32 zOffs; @@ -187,7 +187,7 @@ int aTnt_check_player(ACTOR* actor, GAME_PLAY* play) { return 0; } -void aTnt_wait(STRUCTURE_ACTOR* actor, GAME_PLAY* play) { +static void aTnt_wait(STRUCTURE_ACTOR* actor, GAME_PLAY* play) { xyz_t pos; if (actor == GET_PLAYER_ACTOR_NOW()->get_door_label_proc(gamePT)) { @@ -201,24 +201,24 @@ void aTnt_wait(STRUCTURE_ACTOR* actor, GAME_PLAY* play) { } } -void aTnt_SetupAction(ACTOR* actor, int type) { +static void aTnt_SetupAction(ACTOR* actor, int type) { static aSTR_MOVE_PROC process[] = { aTnt_wait, }; - ACTOR_TENT* tent = (ACTOR_TENT*)actor; + TENT_ACTOR* tent = (TENT_ACTOR*)actor; tent->structure_class.action_proc = process[type]; tent->structure_class.action = type; } -int aTnt_ControlLight(ACTOR*) { +static int aTnt_ControlLight(ACTOR*) { if (Common_Get(time.now_sec) >= 18000 && Common_Get(time.now_sec) < 64800) { return 0; } return 1; } -void aTnt_actor_move(ACTOR* actor, GAME* game) { +static void aTnt_actor_move(ACTOR* actor, GAME* game) { STRUCTURE_ACTOR* tent = (STRUCTURE_ACTOR*)actor; GAME_PLAY* play = (GAME_PLAY*)game; @@ -244,14 +244,14 @@ void aTnt_actor_move(ACTOR* actor, GAME* game) { } } -void aTnt_actor_init(ACTOR* actor, GAME* game) { +static void aTnt_actor_init(ACTOR* actor, GAME* game) { mFI_SetFG_common(DUMMY_TENT, actor->home.position, 0); aTnt_actor_move(actor, game); actor->mv_proc = aTnt_actor_move; } -Gfx* aTnt_MakeWindowPrimDisplayList(ACTOR* actor, GAME* game) { - ACTOR_TENT* tent = (ACTOR_TENT*)actor; +static Gfx* aTnt_MakeWindowPrimDisplayList(ACTOR* actor, GAME* game) { + TENT_ACTOR* tent = (TENT_ACTOR*)actor; GRAPH* graph = game->graph; Gfx* gfx = GRAPH_ALLOC_TYPE(graph, Gfx, 2); @@ -270,7 +270,7 @@ Gfx* aTnt_MakeWindowPrimDisplayList(ACTOR* actor, GAME* game) { extern Gfx obj_s_tent_model[]; -void aTnt_actor_draw(ACTOR* actor, GAME* game) { +static void aTnt_actor_draw(ACTOR* actor, GAME* game) { Mtx* m = _Matrix_to_Mtx_new(game->graph); Gfx* gfx = aTnt_MakeWindowPrimDisplayList(actor, game);