From c7913c5866fa7d6b0dfae3bc367849171ffb235b Mon Sep 17 00:00:00 2001 From: Hexalotl <15166449+Hexalotl@users.noreply.github.com> Date: Wed, 17 Jan 2024 20:51:02 -0800 Subject: [PATCH] Implement and link ac_t_zinnia2 --- config/rel_slices.yml | 3 ++ include/ac_t_zinnia2.h | 10 +++++ src/ac_t_zinnia2.c | 83 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 src/ac_t_zinnia2.c diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 5111b936..fa4fc536 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -512,6 +512,9 @@ ac_t_tumbler.c: ac_t_zinnia1.c: .text: [0x804AA72C, 0x804AA880] .data: [0x8068F370, 0x8068F3B0] +ac_t_zinnia2.c: + .text: [0x804AA880, 0x804AA9d4] + .data: [0x8068F3B0, 0x8068F3F0] ac_tools.c: .text: [0x804AC034, 0x804AC2D8] .rodata: [0x80645F90, 0x80645F98] diff --git a/include/ac_t_zinnia2.h b/include/ac_t_zinnia2.h index 895393a8..9fcaa00c 100644 --- a/include/ac_t_zinnia2.h +++ b/include/ac_t_zinnia2.h @@ -3,6 +3,7 @@ #include "types.h" #include "m_actor.h" +#include "ac_tools.h" #ifdef __cplusplus extern "C" { @@ -10,6 +11,15 @@ extern "C" { extern ACTOR_PROFILE T_Zinnia2_Profile; +typedef void (*ZINNIA2_PROC)(ACTOR*); + +typedef struct t_zinnia2_s { + TOOLS_ACTOR tools_class; + ZINNIA2_PROC proc; + int current_id; + +} ZINNIA2_ACTOR; + #ifdef __cplusplus } #endif diff --git a/src/ac_t_zinnia2.c b/src/ac_t_zinnia2.c new file mode 100644 index 00000000..3d329a20 --- /dev/null +++ b/src/ac_t_zinnia2.c @@ -0,0 +1,83 @@ +#include "ac_t_zinnia2.h" + +#include "m_name_table.h" +#include "sys_matrix.h" +#include "m_lib.h" +#include "m_rcp.h" + +static void aTZN2_actor_ct(ACTOR* actor, GAME* game); +static void aTZN2_actor_draw(ACTOR* actor, GAME* game); +static void aTZN2_actor_move(ACTOR* actor, GAME* game); +static void aTZN2_setupAction(ACTOR* actor, int action); + +ACTOR_PROFILE T_Zinnia2_Profile = { + mAc_PROFILE_T_ZINNIA2, + ACTOR_PART_BG, + ACTOR_STATE_NO_DRAW_WHILE_CULLED | ACTOR_STATE_NO_MOVE_WHILE_CULLED, + EMPTY_NO, + ACTOR_OBJ_BANK_TOOLS, + sizeof(ZINNIA2_ACTOR), + &aTZN2_actor_ct, + NONE_ACTOR_PROC, + &aTZN2_actor_move, + &aTZN2_actor_draw, + NULL +}; + +extern Gfx crw_zinnia2_body_model[]; + +static void aTZN2_actor_ct(ACTOR* actor, GAME* game){ + aTZN2_setupAction(actor, 4); +} + +static void aTZN2_destruct(ACTOR* actor){ + Actor_delete(actor); +} + +static void aTZN2_setupAction(ACTOR* actor, int action){ + ZINNIA2_ACTOR* zinnia2 = (ZINNIA2_ACTOR*)actor; + static ZINNIA2_PROC process[] = { + (ZINNIA2_PROC)none_proc1, (ZINNIA2_PROC)none_proc1, (ZINNIA2_PROC)none_proc1, aTZN2_destruct,(ZINNIA2_PROC)none_proc1, NULL + }; + + zinnia2->proc = process[action]; + zinnia2->current_id = action; + zinnia2->tools_class.work0 = action; +} + +static void aTZN2_actor_move(ACTOR* actor, GAME* game){ + ZINNIA2_ACTOR* zinnia2 = (ZINNIA2_ACTOR*)actor; + + if(zinnia2->tools_class.work0 != zinnia2->current_id){ + aTZN2_setupAction(actor, zinnia2->tools_class.work0); + } + + zinnia2->proc(actor); +} + +static void aTZN2_actor_draw(ACTOR* actor, GAME* game){ + ZINNIA2_ACTOR* zinnia2 = (ZINNIA2_ACTOR*)actor; + + GRAPH* graph; + Gfx* gfxp; + + if(zinnia2->tools_class.init_matrix == 1){ + graph = game->graph; + + OPEN_DISP(graph); + + Matrix_put(&zinnia2->tools_class.matrix_work); + Matrix_Position_Zero(&zinnia2->tools_class.actor_class.world.position); + + zinnia2->tools_class.init_matrix = 0; + + _texture_z_light_fog_prim_npc(graph); + + gfxp = NOW_POLY_OPA_DISP; + gSPMatrix(gfxp++, _Matrix_to_Mtx_new(graph),G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfxp++, crw_zinnia2_body_model); + SET_POLY_OPA_DISP(gfxp); + + CLOSE_DISP(graph); + } +}