Skip to content

Commit

Permalink
Merge pull request ACreTeam#131 from Cuyler36/ac_ev_dokutu
Browse files Browse the repository at this point in the history
Implement & link ac_ev_dokutu.c, NPC_ACTOR framework
  • Loading branch information
Cuyler36 authored Nov 2, 2023
2 parents da79f41 + 2347d62 commit 6b90113
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 12 deletions.
3 changes: 3 additions & 0 deletions config/rel_slices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 7 additions & 0 deletions include/ac_ev_dokutu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 46 additions & 12 deletions include/ac_npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
62 changes: 62 additions & 0 deletions rel/ac_ev_dokutu.c
Original file line number Diff line number Diff line change
@@ -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);
}
23 changes: 23 additions & 0 deletions rel/ac_ev_dokutu_talk.c_inc
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 6b90113

Please sign in to comment.