diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 3dc9cad4..b521ae84 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -324,6 +324,9 @@ ac_t_biscus3.c: ac_t_biscus4.c: .text: [0x804A7F48, 0x804A809C] .data: [0x8068EB48, 0x8068EB88] +ac_t_cobra1.c: + .text: [0x804A809C, 0x804A81F0] + .data: [0x8068EB88, 0x8068EBC8] ac_t_pistol.c: .text: [0x804A95F4, 0x804A9858] .rodata: [0x80645EF8, 0x80645F00] diff --git a/include/ac_t_cobra1.h b/include/ac_t_cobra1.h index b0ba889f..96bcb0fd 100644 --- a/include/ac_t_cobra1.h +++ b/include/ac_t_cobra1.h @@ -3,6 +3,8 @@ #include "types.h" #include "m_actor.h" +#include "ac_tools.h" + #ifdef __cplusplus extern "C" { @@ -10,6 +12,16 @@ extern "C" { extern ACTOR_PROFILE T_Cobra1_Profile; +typedef void (*COBRA1_PROC)(ACTOR*); + +typedef struct t_cobra1_s{ + TOOLS_ACTOR tools_class; + u8 pad2[0x8]; + COBRA1_PROC proc; + int current_id; +}COBRA1_ACTOR; + + #ifdef __cplusplus } #endif diff --git a/rel/ac_t_cobra1.c b/rel/ac_t_cobra1.c new file mode 100644 index 00000000..ab10b68c --- /dev/null +++ b/rel/ac_t_cobra1.c @@ -0,0 +1,90 @@ +#include "ac_t_cobra1.h" + +#include "m_name_table.h" +#include "sys_matrix.h" +#include "m_lib.h" +#include "m_rcp.h" + + +static void aTCB1_actor_ct(ACTOR* actor, GAME*); +static void aTCB1_actor_move(ACTOR* actor, GAME*); +static void aTCB1_actor_draw(ACTOR* actor, GAME*); +static void aTCB1_setupAction(ACTOR*, int); + +ACTOR_PROFILE T_Cobra1_Profile = { + mAc_PROFILE_T_COBRA1, + ACTOR_PART_BG, + ACTOR_STATE_NO_DRAW_WHILE_CULLED | ACTOR_STATE_NO_MOVE_WHILE_CULLED, + EMPTY_NO, + ACTOR_OBJ_BANK_16, + sizeof(COBRA1_ACTOR), + &aTCB1_actor_ct, + NONE_ACTOR_PROC, + &aTCB1_actor_move, + &aTCB1_actor_draw, + NULL +}; + +extern Gfx crw_cobra_model[]; + +static void aTCB1_actor_ct(ACTOR* actor, GAME*){ + + aTCB1_setupAction(actor,4); +} + +static void aTCB1_destruct(ACTOR* actor){ + + Actor_delete(actor); +} + + +static void aTCB1_setupAction(ACTOR*actor, int action){ + COBRA1_ACTOR* biscus = (COBRA1_ACTOR*)actor; + static COBRA1_PROC process[] = { + (COBRA1_PROC)none_proc1,(COBRA1_PROC)none_proc1,(COBRA1_PROC)none_proc1,aTCB1_destruct,(COBRA1_PROC)none_proc1,NULL + }; + + biscus->proc = process[action]; + biscus->current_id = action; + biscus->tools_class.process_id = action; + +} + +static void aTCB1_actor_move(ACTOR* actor, GAME*){ + COBRA1_ACTOR* biscus = (COBRA1_ACTOR*)actor; + + if(biscus->tools_class.process_id != biscus->current_id){ + aTCB1_setupAction(actor, biscus->tools_class.process_id); + } + + biscus->proc(actor); +} + +static void aTCB1_actor_draw(ACTOR* actor, GAME* game){ + COBRA1_ACTOR* biscus = (COBRA1_ACTOR*)actor; + + GRAPH* graph; + Gfx* gfxp; + + if(biscus->tools_class.enable == 1){ + graph = game->graph; + + OPEN_DISP(graph); + + Matrix_put(&biscus->tools_class.matrix_work); + Matrix_Position_Zero(&biscus->tools_class.actor_class.world.position); + + biscus->tools_class.enable = 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_cobra_model); + SET_POLY_OPA_DISP(gfxp); + + CLOSE_DISP(graph); + } + + +} \ No newline at end of file