diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 3222240e..8b088563 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -342,6 +342,10 @@ ac_t_flag.c: .text: [0x804A8454, 0x804A8834] .rodata: [0x80645EB0, 0x80645EC8] .data: [0x8068EC28, 0x8068EC50] +ac_t_hanabi.c: + .text: [0x804A8834, 0x804A8A9C] + .rodata: [0x80645EC8, 0x80645ED0] + .data: [0x8068EC50, 0x8068ECB0] ac_t_pistol.c: .text: [0x804A95F4, 0x804A9858] .rodata: [0x80645EF8, 0x80645F00] diff --git a/include/ac_t_hanabi.h b/include/ac_t_hanabi.h index 6645e66f..d59c03d3 100644 --- a/include/ac_t_hanabi.h +++ b/include/ac_t_hanabi.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_Hanabi_Profile; +typedef void (*HANABI_PROC)(ACTOR*); + +typedef struct t_hanabi_s{ + TOOLS_ACTOR tools_class; + u8 pad2[0x8]; + HANABI_PROC proc; + int current_id; +}HANABI_ACTOR; + #ifdef __cplusplus } #endif diff --git a/include/m_actor.h b/include/m_actor.h index ac10b78a..4bc10994 100644 --- a/include/m_actor.h +++ b/include/m_actor.h @@ -40,6 +40,8 @@ typedef void (*mActor_proc)(ACTOR*, GAME*); #define ACTOR_OBJ_BANK_12 12 #define ACTOR_OBJ_BANK_16 16 #define ACTOR_OBJ_BANK_41 41 +#define ACTOR_OBJ_BANK_53 53 + enum actor_part { ACTOR_PART_FG, diff --git a/rel/ac_t_hanabi.c b/rel/ac_t_hanabi.c new file mode 100644 index 00000000..49de40e1 --- /dev/null +++ b/rel/ac_t_hanabi.c @@ -0,0 +1,126 @@ +#include "ac_t_hanabi.h" + +#include "m_rcp.h" +#include "m_name_table.h" +#include "sys_matrix.h" + +static void aTHB_actor_ct(ACTOR* actor, GAME* game); +static void aTHB_actor_dt(ACTOR* actor, GAME* game); +static void aTHB_actor_move(ACTOR* actor, GAME* game); +static void aTHB_actor_draw(ACTOR* actor, GAME* game); + +ACTOR_PROFILE T_Hanabi_Profile = { + mAc_PROFILE_T_HANABI, + ACTOR_PART_BG, + ACTOR_STATE_NO_DRAW_WHILE_CULLED | ACTOR_STATE_NO_MOVE_WHILE_CULLED, + EMPTY_NO, + ACTOR_OBJ_BANK_53, + sizeof(HANABI_ACTOR), + &aTHB_actor_ct, + &aTHB_actor_dt, + &aTHB_actor_move, + &aTHB_actor_draw, + NULL +}; + +static void aTHB_setupAction(ACTOR* actor, int idx); + +extern Gfx main_utiwa1_model[]; + +static void aTHB_actor_ct(ACTOR* actor, GAME* game){ + aTHB_setupAction(actor, 1); +} + +static void aTHB_actor_dt(ACTOR* actor, GAME* game){ + +} + +static void aTHB_calc_scale(ACTOR* actor, int idx){ + + static f32 aim[] = {1.0f, 0.0f}; + f32 hanabi_scale = actor->scale.x; + + chase_f(&hanabi_scale, aim[idx],0.05f); + + actor->scale.x = hanabi_scale; + actor->scale.y = hanabi_scale; + actor->scale.z = hanabi_scale; + +} + +void aTHB_takeout(ACTOR* actor){ + + aTHB_calc_scale(actor, 0); +} + +void aTHB_putaway(ACTOR* actor){ + + aTHB_calc_scale(actor, 1); +} + +void aTHB_destruct(ACTOR* actor){ + + Actor_delete(actor); +} + +static void aTHB_setupAction(ACTOR* actor, int idx){ + HANABI_ACTOR* hanabi = (HANABI_ACTOR*)actor; + + static HANABI_PROC process[] = {(HANABI_PROC)none_proc1, aTHB_takeout,aTHB_putaway,aTHB_destruct, + (HANABI_PROC)none_proc1,NULL}; + static f32 start_scale[] = {0.0f, 0.0f, 1.0f,1.0f,1.0f,0.0f,0.0f}; + f32 scale; + + hanabi->proc = process[idx]; + hanabi->current_id = idx; + hanabi->tools_class.process_id = idx; + + scale = start_scale[idx]; + hanabi->tools_class.actor_class.scale.x = scale; + hanabi->tools_class.actor_class.scale.y = scale; + hanabi->tools_class.actor_class.scale.z = scale; + +} + +static void aTHB_actor_move(ACTOR* actor, GAME* game){ + HANABI_ACTOR* hanabi = (HANABI_ACTOR*)actor; + + int t = hanabi->tools_class.process_id; + if(t!= hanabi->current_id){ + aTHB_setupAction(actor, t); + } + hanabi->proc(actor); +} + +static void aTHB_actor_draw(ACTOR* actor, GAME* game){ + HANABI_ACTOR* hanabi = (HANABI_ACTOR*)actor; + + GRAPH* graph = game->graph; + Gfx* gfxp; + + OPEN_DISP(graph); + + if(hanabi->tools_class.enable == 1){ + Matrix_put(&hanabi->tools_class.matrix_work); + Matrix_Position_Zero(&hanabi->tools_class.actor_class.world.position); + hanabi->tools_class.enable = 0; + } + else{ + Matrix_translate(hanabi->tools_class.actor_class.world.position.x, hanabi->tools_class.actor_class.world.position.y, + hanabi->tools_class.actor_class.world.position.z, FALSE); + Matrix_scale(0.01f, 0.01f, 0.01f, TRUE); + } + + Matrix_scale(hanabi->tools_class.actor_class.scale.x, hanabi->tools_class.actor_class.scale.y, hanabi->tools_class.actor_class.scale.z, TRUE); + _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++, main_utiwa1_model); + SET_POLY_OPA_DISP(gfxp); + + CLOSE_DISP(graph); + +} + +