From 61ddf6ebdd67d95053db01458c784d1577b2009b Mon Sep 17 00:00:00 2001 From: Hexalotl <15166449+Hexalotl@users.noreply.github.com> Date: Wed, 17 Jan 2024 14:02:14 -0800 Subject: [PATCH] Implement and link ac_t_rei2 --- config/rel_slices.yml | 3 ++ include/ac_t_rei2.h | 10 ++++++ src/ac_t_rei2.c | 83 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 src/ac_t_rei2.c diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 42da331c..a56d4e9c 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -497,6 +497,9 @@ ac_t_pistol.c: ac_t_rei1.c: .text: [0x804A9858, 0x804A99AC] .data: [0x8068EEF8, 0x8068EF38] +ac_t_rei2.c: + .text: [0x804A99AC, 0x804A9B00] + .data: [0x8068EF38, 0x8068EF78] ac_t_tumbler.c: .text: [0x804A9CC4, 0x804A9F24] .rodata: [0x80645F10, 0x80645F18] diff --git a/include/ac_t_rei2.h b/include/ac_t_rei2.h index 0e048c47..c3847f15 100644 --- a/include/ac_t_rei2.h +++ b/include/ac_t_rei2.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_Rei2_Profile; +typedef void (*REI2_PROC)(ACTOR*); + +typedef struct t_rei2_s { + TOOLS_ACTOR tools_class; + REI2_PROC proc; + int current_id; + +} REI2_ACTOR; + #ifdef __cplusplus } #endif diff --git a/src/ac_t_rei2.c b/src/ac_t_rei2.c new file mode 100644 index 00000000..8c128a74 --- /dev/null +++ b/src/ac_t_rei2.c @@ -0,0 +1,83 @@ +#include "ac_t_rei2.h" + +#include "m_name_table.h" +#include "sys_matrix.h" +#include "m_lib.h" +#include "m_rcp.h" + +static void aTRI2_actor_ct(ACTOR* actor, GAME* game); +static void aTRI2_actor_draw(ACTOR* actor, GAME* game); +static void aTRI2_actor_move(ACTOR* actor, GAME* game); +static void aTRI2_setupAction(ACTOR* actor, int action); + +ACTOR_PROFILE T_Rei2_Profile = { + mAc_PROFILE_T_REI2, + ACTOR_PART_BG, + ACTOR_STATE_NO_DRAW_WHILE_CULLED | ACTOR_STATE_NO_MOVE_WHILE_CULLED, + EMPTY_NO, + ACTOR_OBJ_BANK_TOOLS, + sizeof(REI2_ACTOR), + &aTRI2_actor_ct, + NONE_ACTOR_PROC, + &aTRI2_actor_move, + &aTRI2_actor_draw, + NULL +}; + +extern Gfx crw_rei2_body_model[]; + +static void aTRI2_actor_ct(ACTOR* actor, GAME* game){ + aTRI2_setupAction(actor, 4); +} + +static void aTRI2_destruct(ACTOR* actor){ + Actor_delete(actor); +} + +static void aTRI2_setupAction(ACTOR* actor, int action){ + REI2_ACTOR* rei2 = (REI2_ACTOR*)actor; + static REI2_PROC process[] = { + (REI2_PROC)none_proc1, (REI2_PROC)none_proc1, (REI2_PROC)none_proc1, aTRI2_destruct,(REI2_PROC)none_proc1, NULL + }; + + rei2->proc = process[action]; + rei2->current_id = action; + rei2->tools_class.work0 = action; +} + +static void aTRI2_actor_move(ACTOR* actor, GAME* game){ + REI2_ACTOR* rei2 = (REI2_ACTOR*)actor; + + if(rei2->tools_class.work0 != rei2->current_id){ + aTRI2_setupAction(actor, rei2->tools_class.work0); + } + + rei2->proc(actor); +} + +static void aTRI2_actor_draw(ACTOR* actor, GAME* game){ + REI2_ACTOR* rei2 = (REI2_ACTOR*)actor; + + GRAPH* graph; + Gfx* gfxp; + + if(rei2->tools_class.init_matrix == 1){ + graph = game->graph; + + OPEN_DISP(graph); + + Matrix_put(&rei2->tools_class.matrix_work); + Matrix_Position_Zero(&rei2->tools_class.actor_class.world.position); + + rei2->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_rei2_body_model); + SET_POLY_OPA_DISP(gfxp); + + CLOSE_DISP(graph); + } +}