From 2347d62c132b1949f8c66a8fa417bd2172299691 Mon Sep 17 00:00:00 2001 From: Cuyler36 Date: Wed, 1 Nov 2023 23:56:38 -0400 Subject: [PATCH] Implement & link ac_ev_dokutu.c, NPC_ACTOR framework --- config/rel_slices.yml | 3 ++ include/ac_ev_dokutu.h | 7 +++++ include/ac_npc.h | 58 +++++++++++++++++++++++++++------- rel/ac_ev_dokutu.c | 62 +++++++++++++++++++++++++++++++++++++ rel/ac_ev_dokutu_talk.c_inc | 23 ++++++++++++++ 5 files changed, 141 insertions(+), 12 deletions(-) create mode 100644 rel/ac_ev_dokutu.c create mode 100644 rel/ac_ev_dokutu_talk.c_inc diff --git a/config/rel_slices.yml b/config/rel_slices.yml index a6913fed..0a98e7f0 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -492,6 +492,9 @@ ac_aprilfool_control.c: ac_groundhog_control.c: .text: [0x805155C8, 0x80515C48] .data: [0x8069FD88, 0x8069FDD0] +ac_ev_dokutu.c: + .text: [0x8051DFF4, 0x8051E228] + .data: [0x806A05C8, 0x806A0608] ac_douzou.c: .text: [0x805AD6D8, 0x805AE704] .rodata: [0x8064A7C0, 0x8064A7E8] diff --git a/include/ac_ev_dokutu.h b/include/ac_ev_dokutu.h index 72516919..59e30dd2 100644 --- a/include/ac_ev_dokutu.h +++ b/include/ac_ev_dokutu.h @@ -3,11 +3,18 @@ #include "types.h" #include "m_actor.h" +#include "ac_npc.h" #ifdef __cplusplus extern "C" { #endif +typedef struct event_dokutu_actor_s { + NPC_ACTOR npc_class; + int _994; + int _998; +} EVENT_DOKUTU_ACTOR; + extern ACTOR_PROFILE Ev_Dokutu_Profile; #ifdef __cplusplus diff --git a/include/ac_npc.h b/include/ac_npc.h index 841569d0..bf0776ca 100644 --- a/include/ac_npc.h +++ b/include/ac_npc.h @@ -29,30 +29,64 @@ enum { aNPC_ATTENTION_TYPE_NUM }; +typedef void (*aNPC_TALK_REQUEST_PROC)(ACTOR*, GAME*); +typedef int (*aNPC_TALK_INIT_PROC)(ACTOR*, GAME*); +typedef int (*aNPC_TALK_END_CHECK_PROC)(ACTOR*, GAME*); + +typedef struct npc_ct_data_s { + mActor_proc move_proc; + mActor_proc draw_proc; + int _08; + aNPC_TALK_REQUEST_PROC talk_request_proc; + aNPC_TALK_INIT_PROC talk_init_proc; + aNPC_TALK_END_CHECK_PROC talk_end_check_proc; + int _18; +} aNPC_ct_data_c; + typedef int (*aNPC_SETUP_ACTOR_PROC)(GAME_PLAY*, mActor_name_t, s8, int, s16, int, int, int, int); typedef void (*aNPC_DMA_DRAW_DATA_PROC)(aNPC_draw_data_c*, mActor_name_t); typedef void (*aNPC_FREE_OVERLAY_AREA_PROC)(ACTOR_DLFTBL*); typedef ACTOR* (*aNPC_GET_ACTOR_AREA_PROC)(size_t, const char*, int); typedef void (*aNPC_FREE_ACTOR_AREA_PROC)(ACTOR*); typedef void (*aNPC_SET_ATTENTION_REQUEST_PROC)(u8, ACTOR*, xyz_t*); +typedef int (*aNPC_BIRTH_CHECK_PROC)(ACTOR*, GAME*); +typedef void (*aNPC_CT_PROC)(ACTOR*, GAME*, aNPC_ct_data_c*); +typedef void (*aNPC_DT_PROC)(ACTOR*, GAME*); +typedef void (*aNPC_SAVE_PROC)(ACTOR*, GAME*); +typedef void (*aNPC_INIT_PROC)(ACTOR*, GAME*); +typedef void (*aNPC_MOVE_PROC)(ACTOR*, GAME*); +typedef void (*aNPC_MOVE_BEFORE_PROC)(ACTOR*, GAME*); +typedef void (*aNPC_MOVE_AFTER_PROC)(ACTOR*, GAME*); +typedef void (*aNPC_DRAW_PROC)(ACTOR*, GAME*); typedef void (*aNPC_REBUILD_DMA_PROC)(); typedef int (*aNPC_FORCE_CALL_REQ_PROC)(NPC_ACTOR*, int); struct ac_npc_clip_s { - aNPC_SETUP_ACTOR_PROC setupActor_proc; - void* _004; - aNPC_FREE_OVERLAY_AREA_PROC free_overlay_area_proc; - aNPC_GET_ACTOR_AREA_PROC get_actor_area_proc; - aNPC_FREE_ACTOR_AREA_PROC free_actor_area_proc; - aNPC_DMA_DRAW_DATA_PROC dma_draw_data_proc; - aNPC_SET_ATTENTION_REQUEST_PROC set_attention_request_proc; - void* _01C[(0x0F8 - 0x01C) / sizeof(void*)]; - aNPC_REBUILD_DMA_PROC rebuild_dma_proc; - void* _0FC[(0x124 - 0x0FC) / sizeof(void*)]; - aNPC_FORCE_CALL_REQ_PROC force_call_req_proc; - void* _128; + /* 0x000 */ aNPC_SETUP_ACTOR_PROC setupActor_proc; + /* 0x004 */ void* _004; + /* 0x008 */ aNPC_FREE_OVERLAY_AREA_PROC free_overlay_area_proc; + /* 0x00C */ aNPC_GET_ACTOR_AREA_PROC get_actor_area_proc; + /* 0x010 */ aNPC_FREE_ACTOR_AREA_PROC free_actor_area_proc; + /* 0x014 */ aNPC_DMA_DRAW_DATA_PROC dma_draw_data_proc; + /* 0x018 */ aNPC_SET_ATTENTION_REQUEST_PROC set_attention_request_proc; + /* 0x01C */ void* _01C[(0x0CC - 0x01C) / sizeof(void*)]; + /* 0x0CC */ aNPC_BIRTH_CHECK_PROC birth_check_proc; + /* 0x0D0 */ aNPC_CT_PROC ct_proc; + /* 0x0D4 */ aNPC_DT_PROC dt_proc; + /* 0x0D8 */ aNPC_SAVE_PROC save_proc; + /* 0x0DC */ aNPC_INIT_PROC init_proc; + /* 0x0E0 */ aNPC_MOVE_PROC move_proc; + /* 0x0E4 */ aNPC_MOVE_BEFORE_PROC move_before_proc; + /* 0x0E8 */ aNPC_MOVE_AFTER_PROC move_after_proc; + /* 0x0EC */ void* _0EC; + /* 0x0F0 */ void* _0F0; + /* 0x0F4 */ aNPC_DRAW_PROC draw_proc; + /* 0x0F8 */ aNPC_REBUILD_DMA_PROC rebuild_dma_proc; + /* 0x0FC */ void* _0FC[(0x124 - 0x0FC) / sizeof(void*)]; + /* 0x124 */ aNPC_FORCE_CALL_REQ_PROC force_call_req_proc; + /* 0x128 */ void* _128; }; typedef struct npc_info_s { diff --git a/rel/ac_ev_dokutu.c b/rel/ac_ev_dokutu.c new file mode 100644 index 00000000..b020f8fe --- /dev/null +++ b/rel/ac_ev_dokutu.c @@ -0,0 +1,62 @@ +#include "ac_ev_dokutu.h" + +#include "m_common_data.h" + +#include "../rel/ac_ev_dokutu_talk.c_inc" + +static void aEVD_actor_ct(ACTOR* actorx, GAME* game); +static void aEVD_actor_dt(ACTOR* actorx, GAME* game); +static void aEVD_actor_init(ACTOR* actorx, GAME* game); +static void aEVD_actor_save(ACTOR* actorx, GAME* game); +static void aEVD_actor_move(ACTOR* actorx, GAME* game); +static void aEVD_actor_draw(ACTOR* actorx, GAME* game); + +ACTOR_PROFILE Ev_Dokutu_Profile = { + mAc_PROFILE_EV_DOKUTU, + ACTOR_PART_NPC, + 0, + SP_NPC_EV_DOKUTU, + ACTOR_OBJ_BANK_KEEP, + sizeof(EVENT_DOKUTU_ACTOR), + &aEVD_actor_ct, + &aEVD_actor_dt, + &aEVD_actor_init, + mActor_NONE_PROC1, + &aEVD_actor_save +}; + +static aNPC_ct_data_c ct_data = { + &aEVD_actor_move, + &aEVD_actor_draw, + 3, + &aEVD_talk_request, + &aEVD_talk_init, + &aEVD_talk_end_chk, + 0 +}; + +static void aEVD_actor_ct(ACTOR* actorx, GAME* game) { + if ((*Common_Get(clip).npc_clip->birth_check_proc)(actorx, game) == TRUE) { + (*Common_Get(clip).npc_clip->ct_proc)(actorx, game, &ct_data); + } +} + +static void aEVD_actor_save(ACTOR* actorx, GAME* game) { + mNpc_RenewalSetNpc(actorx); +} + +static void aEVD_actor_dt(ACTOR* actorx, GAME* game) { + (*Common_Get(clip).npc_clip->dt_proc)(actorx, game); +} + +static void aEVD_actor_init(ACTOR* actorx, GAME* game) { + (*Common_Get(clip).npc_clip->init_proc)(actorx, game); +} + +static void aEVD_actor_move(ACTOR* actorx, GAME* game) { + (*Common_Get(clip).npc_clip->move_proc)(actorx, game); +} + +static void aEVD_actor_draw(ACTOR* actorx, GAME* game) { + (*Common_Get(clip).npc_clip->draw_proc)(actorx, game); +} diff --git a/rel/ac_ev_dokutu_talk.c_inc b/rel/ac_ev_dokutu_talk.c_inc new file mode 100644 index 00000000..ba36e9d8 --- /dev/null +++ b/rel/ac_ev_dokutu_talk.c_inc @@ -0,0 +1,23 @@ + +static void aEVD_set_talk_info(ACTOR* actorx) { + mDemo_Set_msg_num(0x3146); +} + +static void aEVD_talk_request(ACTOR* actorx, GAME* game) { + mDemo_Request(mDemo_TYPE_TALK, actorx, &aEVD_set_talk_info); +} + +static int aEVD_talk_init(ACTOR* actorx, GAME* game) { + mDemo_Set_ListenAble(); + return TRUE; +} + +static int aEVD_talk_end_chk(ACTOR* actorx, GAME* game) { + int res = FALSE; + + if (mDemo_Check(mDemo_TYPE_TALK, actorx) == FALSE) { + res = TRUE; + } + + return res; +}