From 99f9820e491a832198ba8dce342ed6304354cc19 Mon Sep 17 00:00:00 2001 From: Hexalotl <15166449+Hexalotl@users.noreply.github.com> Date: Thu, 25 Jan 2024 08:57:43 -0800 Subject: [PATCH] Implement and link ac_t_tama with major help from Cuyler and Prakxo (#235) --- config/rel_slices.yml | 4 ++ include/ac_t_tama.h | 5 ++ include/m_actor.h | 2 +- src/ac_t_tama.c | 103 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 src/ac_t_tama.c diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 78e98b50..2409a444 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -518,6 +518,10 @@ ac_t_tumbler.c: .text: [0x804A9CC4, 0x804A9F24] .rodata: [0x80645F10, 0x80645F18] .data: [0x8068EFE0, 0x8068F040] +ac_t_tama.c: + .text: [0x804A9B00, 0x804A9CC4] + .data: [0x8068EF78, 0x8068EFE0] + .rodata: [0x80645F00, 0x80645F10] ac_t_utiwa.c: .text: [0x804AA4C8, 0x804AA72C] .data: [0x8068F310, 0x8068F370] diff --git a/include/ac_t_tama.h b/include/ac_t_tama.h index 9d437d6a..2f9eae00 100644 --- a/include/ac_t_tama.h +++ b/include/ac_t_tama.h @@ -3,6 +3,7 @@ #include "types.h" #include "m_actor.h" +#include "ac_tools.h" #ifdef __cplusplus extern "C" { @@ -10,6 +11,10 @@ extern "C" { extern ACTOR_PROFILE T_Tama_Profile; +typedef struct t_tama_s { + TOOLS_ACTOR tools_class; +} T_TAMA_ACTOR; + #ifdef __cplusplus } #endif diff --git a/include/m_actor.h b/include/m_actor.h index 5aa587ac..9fbbabaf 100644 --- a/include/m_actor.h +++ b/include/m_actor.h @@ -430,7 +430,7 @@ typedef enum bank_id { ACTOR_OBJ_BANK_388, ACTOR_OBJ_BANK_389, ACTOR_OBJ_BANK_390, - ACTOR_OBJ_BANK_391, + ACTOR_OBJ_BANK_TAMA, ACTOR_OBJ_BANK_392, ACTOR_OBJ_BANK_393, ACTOR_OBJ_BANK_ROPE, diff --git a/src/ac_t_tama.c b/src/ac_t_tama.c new file mode 100644 index 00000000..e240ee4a --- /dev/null +++ b/src/ac_t_tama.c @@ -0,0 +1,103 @@ +#include "ac_t_tama.h" + +#include "m_name_table.h" +#include "sys_matrix.h" +#include "m_lib.h" +#include "m_rcp.h" +#include "m_common_data.h" + +static void aTTM_actor_draw(ACTOR* actor, GAME* game); + +ACTOR_PROFILE T_Tama_Profile = { + mAc_PROFILE_T_TAMA, + ACTOR_PART_BG, + ACTOR_STATE_NO_DRAW_WHILE_CULLED | ACTOR_STATE_NO_MOVE_WHILE_CULLED, + EMPTY_NO, + ACTOR_OBJ_BANK_TAMA, + sizeof(T_TAMA_ACTOR), + NONE_ACTOR_PROC, + NONE_ACTOR_PROC, + NONE_ACTOR_PROC, + &aTTM_actor_draw, + NULL +}; + +extern Gfx tama01_model[]; +extern Gfx tol_tamaire_model[]; + +extern u8 tama01_r_tex[]; +extern u8 tama01_w_tex[]; +extern u8 tol_tamaire_r1_tex[]; +extern u8 tol_tamaire_r2_tex[]; +extern u8 tol_tamaire_r3_tex[]; +extern u8 tol_tamaire_w1_tex[]; +extern u8 tol_tamaire_w2_tex[]; +extern u8 tol_tamaire_w3_tex[]; + +void aTTM_actor_draw(ACTOR* actor, GAME* game) { + static Gfx* displayList[] = { + tama01_model, + tama01_model, + tol_tamaire_model, + tol_tamaire_model, + }; + + static u8* texture[4][3] = { + { tama01_r_tex, tama01_r_tex, tama01_r_tex }, + { tama01_w_tex, tama01_w_tex, tama01_w_tex }, + { tol_tamaire_r1_tex, tol_tamaire_r2_tex, tol_tamaire_r3_tex }, + { tol_tamaire_w1_tex, tol_tamaire_w2_tex, tol_tamaire_w3_tex }, + }; + + T_TAMA_ACTOR* tama; + int work2; + ACTOR* parent; + xyz_t position1; + xyz_t position2; + int tool_name; + GRAPH* graph; + Gfx* gfx; + + tama = (T_TAMA_ACTOR*)actor; + parent = actor->parent_actor; + work2 = tama->tools_class.work2; + if (work2 > 0 && tama->tools_class.init_matrix == TRUE) { + graph = game->graph; + tool_name = (tama->tools_class.tool_name - 0x30); + switch (tool_name) { + case 0: + case 1: + Matrix_put(&tama->tools_class.matrix_work); + Matrix_scale(0.5f, 0.5f, 0.5f, TRUE); + break; + case 2: + case 3: + Matrix_RotateY(parent->shape_info.rotation.y - 0x4000, FALSE); + Matrix_translate(6.0f, 3.0f, 3.0f, TRUE); + Matrix_Position_Zero(&position1); + Matrix_put(&tama->tools_class.matrix_work); + Matrix_Position_Zero(&position2); + + position2.x += position1.x; + position2.y += position1.y; + position2.z += position1.z; + Matrix_translate(position2.x, position2.y, position2.z, FALSE); + Matrix_scale(0.01f, 0.01f, 0.01f, TRUE); + break; + default: + return; + } + tama->tools_class.init_matrix = FALSE; + _texture_z_light_fog_prim_npc(graph); + + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + work2--; + gSPSegment(gfx++, G_MWO_SEGMENT_8, texture[tool_name][work2]); + gSPDisplayList(gfx++, displayList[tool_name]); + + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); + } +}