diff --git a/config/rel_slices.yml b/config/rel_slices.yml index b521ae84..698b5e42 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -327,6 +327,10 @@ ac_t_biscus4.c: ac_t_cobra1.c: .text: [0x804A809C, 0x804A81F0] .data: [0x8068EB88, 0x8068EBC8] +ac_t_cracker.c: + .text: [0x804A81F0, 0x804A8454] + .rodata: [0x80645EA8, 0x80645EB0] + .data: [0x8068EBC8, 0x8068EC28] ac_t_pistol.c: .text: [0x804A95F4, 0x804A9858] .rodata: [0x80645EF8, 0x80645F00] diff --git a/include/ac_t_cracker.h b/include/ac_t_cracker.h index 667e781b..8f3a5b78 100644 --- a/include/ac_t_cracker.h +++ b/include/ac_t_cracker.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_Cracker_Profile; +typedef void (*CRACKER_PROC)(ACTOR*); + +typedef struct t_cracker_s{ + TOOLS_ACTOR tools_class; + u8 pad2[0x8]; + CRACKER_PROC proc; + int current_id; +}CRACKER_ACTOR; + #ifdef __cplusplus } #endif diff --git a/include/ac_t_pistol.h b/include/ac_t_pistol.h index 28e8b6e6..f46b3f44 100644 --- a/include/ac_t_pistol.h +++ b/include/ac_t_pistol.h @@ -8,6 +8,8 @@ extern "C" { #endif +extern ACTOR_PROFILE T_Pistol_Profile; + typedef void (*PISTOL_PROC)(ACTOR*); typedef struct t_pistol_s{ @@ -17,9 +19,6 @@ typedef struct t_pistol_s{ int current_id; }PISTOL_ACTOR; - -extern ACTOR_PROFILE T_Pistol_Profile; - #ifdef __cplusplus } #endif diff --git a/rel/ac_t_cracker.c b/rel/ac_t_cracker.c new file mode 100644 index 00000000..f1e85dfd --- /dev/null +++ b/rel/ac_t_cracker.c @@ -0,0 +1,122 @@ +#include "ac_t_cracker.h" + +#include "m_name_table.h" +#include "sys_matrix.h" +#include "m_lib.h" +#include "m_rcp.h" + +static void aTCR_actor_ct(ACTOR* actor, GAME* game); +static void aTCR_actor_move(ACTOR* actor, GAME* game); +static void aTCR_actor_draw(ACTOR* actor, GAME* game); + +ACTOR_PROFILE T_Cracker_Profile = { + mAc_PROFILE_T_CRACKER, + ACTOR_PART_BG, + ACTOR_STATE_NO_DRAW_WHILE_CULLED | ACTOR_STATE_NO_MOVE_WHILE_CULLED, + EMPTY_NO, + 395, //Leftover from the object table, so this actor doesn't have an object bank + sizeof(CRACKER_ACTOR), + &aTCR_actor_ct, + NONE_ACTOR_PROC, + &aTCR_actor_move, + &aTCR_actor_draw, + NULL +}; + +static void aTCR_setupAction(ACTOR* actor, int idx); + +extern Gfx tol_cracker_1T_model[]; + +static void aTCR_actor_ct(ACTOR* actor, GAME* game){ + aTCR_setupAction(actor, 1); +} + +static void aTCR_calc_scale(ACTOR* actor, int idx){ + + static f32 aim[] = {1.0f, 0.0f}; + f32 cracker_scale = actor->scale.x; + + chase_f(&cracker_scale, aim[idx],0.05f); + + actor->scale.x = cracker_scale; + actor->scale.y = cracker_scale; + actor->scale.z = cracker_scale; + +} + +static void aTCR_takeout(ACTOR* actor){ + + aTCR_calc_scale(actor, 0); +} + +static void aTCR_putaway(ACTOR* actor){ + + aTCR_calc_scale(actor, 1); +} + +static void aTCR_destruct(ACTOR* actor){ + + Actor_delete(actor); +} + +static void aTCR_setupAction(ACTOR* actor, int idx){ + CRACKER_ACTOR* cracker = (CRACKER_ACTOR*)actor; + + static CRACKER_PROC process[] = {(CRACKER_PROC)none_proc1, aTCR_takeout,aTCR_putaway,aTCR_destruct, + (CRACKER_PROC)none_proc1,NULL}; + static f32 start_scale[] = {0.0f, 0.0f, 1.0f,1.0f,1.0f,0.0f,0.0f}; + f32 scale; + + cracker->proc = process[idx]; + cracker->current_id = idx; + cracker->tools_class.process_id = idx; + + scale = start_scale[idx]; + cracker->tools_class.actor_class.scale.x = scale; + cracker->tools_class.actor_class.scale.y = scale; + cracker->tools_class.actor_class.scale.z = scale; + +} + +static void aTCR_actor_move(ACTOR* actor, GAME* game){ + CRACKER_ACTOR* cracker = (CRACKER_ACTOR*)actor; + + int t = cracker->tools_class.process_id; + if(t!= cracker->current_id){ + aTCR_setupAction(actor, t); + } + cracker->proc(actor); +} + +static void aTCR_actor_draw(ACTOR* actor, GAME* game){ + CRACKER_ACTOR* cracker = (CRACKER_ACTOR*)actor; + + GRAPH* graph = game->graph; + Gfx* gfxp; + + OPEN_DISP(graph); + + if(cracker->tools_class.enable == 1){ + Matrix_put(&cracker->tools_class.matrix_work); + Matrix_Position_Zero(&cracker->tools_class.actor_class.world.position); + cracker->tools_class.enable = 0; + } + else{ + Matrix_translate(cracker->tools_class.actor_class.world.position.x, cracker->tools_class.actor_class.world.position.y, + cracker->tools_class.actor_class.world.position.z, FALSE); + Matrix_scale(0.01f, 0.01f, 0.01f, TRUE); + } + + Matrix_scale(cracker->tools_class.actor_class.scale.x, cracker->tools_class.actor_class.scale.y, cracker->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++, tol_cracker_1T_model); + SET_POLY_OPA_DISP(gfxp); + + CLOSE_DISP(graph); + +} + +