diff options
| author | kuchenmitsahne <25233413+kuchenmitsahne@users.noreply.github.com> | 2024-11-27 13:46:58 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-27 11:46:58 -0700 |
| commit | 7c055329a7a71f8652587cb7dc779ac3eb69f5d4 (patch) | |
| tree | 0d91e8452b99087ccb0762be26946119ea6fbde6 | |
| parent | d38ac6a9d32e9b5c0e3caafbfc8d311a0f8f51f4 (diff) | |
ac_hanami_npc1 OK (#228)
* Rename symbols
* First pass on struct Hanami_Npc1
* Actor funcs (ct, save, dt, init, draw) OK
* Add trailing member to struct_809AEFA4
* Update Clip_unk_040_unk_E4 typedef to ActorFunc signature in order to unify *_actor_draw signatures
* All talk functions and proc functions (minus aHM1_think_main_proc.s) OK
* mFI_GetPuleIdx (func_8008930C_jp) OK; rename symbols (m_field_info)
* aHM1_set_animation OK
* aHM1_actor_move OK; update *_actor_move function signature to ActorFunc across project
* aHM1_set_request_act, aHM1_check_moveRange OK
* aHM1_check_inBlock OK; fix style in aHM1_check_moveRange
* aHM1_turn, aHM1_walk, aHM1_set_spd_info OK
* aHM1_think_init_proc OK
* aHM1_revise_moveRange OK with fake (all functions matching)
* Remove extraneous prototypes
* Fix aHM1_think_main_proc signature
* Import data
* Fix aHM1_revise_moveRange signature
* Standardize actor accesses
* Improve define usage
* Name blockX and blockZ members in Actor struct
* Remove extraneous comments
* mFI_BkNum2WposXZ OK (m_field_info)
* Add defines to m_field_info
* Formatting pass
* Remove extraneous comments
* Fix unk_18 type in struct_809AEFA4
---------
Co-authored-by: emilybrooks <emilybrooksemilybrooks@gmail.com>
| -rw-r--r-- | include/m_actor.h | 8 | ||||
| -rw-r--r-- | include/m_clip.h | 4 | ||||
| -rw-r--r-- | include/m_field_info.h | 31 | ||||
| -rw-r--r-- | linker_scripts/jp/symbol_addrs_code.txt | 8 | ||||
| -rw-r--r-- | linker_scripts/jp/symbol_addrs_overlays.txt | 68 | ||||
| -rw-r--r-- | src/code/m_actor.c | 12 | ||||
| -rw-r--r-- | src/code/m_field_info.c | 35 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1.c | 324 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1.h | 39 | ||||
| -rw-r--r-- | yamls/jp/overlays.yaml | 2 |
10 files changed, 435 insertions, 96 deletions
diff --git a/include/m_actor.h b/include/m_actor.h index 5c9dc1e..5e348e9 100644 --- a/include/m_actor.h +++ b/include/m_actor.h @@ -97,9 +97,9 @@ typedef struct Actor { /* 0x003 */ u8 unk_003; // If set to 1 then fgdata will be restored independently of the actor's part /* 0x004 */ u16 unk_004; /* 0x006 */ u16 fgName; - /* 0x008 */ s8 unk_008; - /* 0x008 */ s8 unk_009; - /* 0x008 */ s16 unk_00A; + /* 0x008 */ s8 blockX; + /* 0x009 */ s8 blockZ; + /* 0x00A */ s16 unk_00A; /* 0x00C */ PosRot home; /* 0x020 */ u32 flags; /* 0x024 */ s16 params; @@ -252,7 +252,7 @@ void Actor_info_call_actor(struct Game_Play* game_play, ActorInfo* actorInfo); void Actor_info_draw_actor(struct Game_Play* game_play, ActorInfo* actorInfo); void Actor_free_overlay_area(struct ActorOverlay* overlayEntry); void Actor_get_overlay_area(struct ActorOverlay* overlayEntry, const u8* arg1, size_t overlaySize); -void Actor_init_actor_class(Actor* actor, ActorProfile* profile, struct ActorOverlay* overlayEntry, struct Game_Play* game_play, s32 arg4, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s8 argB, s8 argC, s16 argD, u16 fgName, s16 params); +void Actor_init_actor_class(Actor* actor, ActorProfile* profile, struct ActorOverlay* overlayEntry, struct Game_Play* game_play, s32 arg4, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s8 blockX, s8 blockZ, s16 argD, u16 fgName, s16 params); Actor* Actor_info_make_actor(ActorInfo* actorInfo, struct Game_Play* game_play, s16 actorId, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s8 arg9, s8 argA, s16 argB, u16 fgName, s16 params, s8 argE, s32 argF); Actor* Actor_info_make_child_actor(ActorInfo* actorInfo, Actor* arg1, struct Game_Play* game_play, s16 actorId, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s16 argA, u16 fgName, s16 params, s32 argD); void restore_fgdata(Actor* actor, struct Game_Play* game_play); diff --git a/include/m_clip.h b/include/m_clip.h index 2122083..b825c24 100644 --- a/include/m_clip.h +++ b/include/m_clip.h @@ -34,8 +34,8 @@ typedef void (*Clip_unk_040_unk_C0)(struct Actor*, struct Game_Play*, struct str typedef UNK_RET (*Clip_unk_040_unk_C4)(struct Actor*, struct Game_Play*); typedef UNK_RET (*Clip_unk_040_unk_C8)(struct Actor*, struct Game_Play*); typedef UNK_RET (*Clip_unk_040_unk_CC)(struct Actor*, struct Game_Play*); -typedef void (*Clip_unk_040_unk_D0)(struct Actor*, struct Game_Play*); -typedef void (*Clip_unk_040_unk_E4)(struct Actor*, struct Game_Play*); +typedef UNK_RET (*Clip_unk_040_unk_D0)(struct Actor*, struct Game_Play*); +typedef UNK_RET (*Clip_unk_040_unk_E4)(struct Actor*, struct Game_Play*); typedef UNK_RET (*Clip_unk_040_unk_E8)(void); typedef UNK_RET (*Clip_unk_040_unk_EC)(struct ObjectStatus*, s16, s16); typedef UNK_RET (*Clip_unk_040_unk_F0)(struct ObjectStatus*, struct Actor*); diff --git a/include/m_field_info.h b/include/m_field_info.h index 744dbae..f6519a1 100644 --- a/include/m_field_info.h +++ b/include/m_field_info.h @@ -5,6 +5,7 @@ #include "z64math.h" #include "m_collision_bg.h" #include "unk.h" +#include "m_field_make.h" struct Actor; struct Game_Play; @@ -12,13 +13,25 @@ struct FieldMakeBlockInfo; struct FieldMakeMoveActor; struct Game; -#define FI_UT_WORLDSIZE_Z 40 -#define FI_UT_WORLDSIZE_Z_F (f32)FI_UT_WORLDSIZE_Z -#define FI_UT_WORLDSIZE_X 40 -#define FI_UT_WORLDSIZE_X_F (f32)FI_UT_WORLDSIZE_Z #define FI_UT_BASE_SIZE 40 #define FI_UT_BASE_SIZE_F ((f32)FI_UT_BASE_SIZE) +#define FI_UT_WORLDSIZE_X FI_UT_BASE_SIZE +#define FI_UT_WORLDSIZE_X_F (f32)FI_UT_WORLDSIZE_X + +#define FI_UT_WORLDSIZE_Z FI_UT_BASE_SIZE +#define FI_UT_WORLDSIZE_Z_F (f32)FI_UT_WORLDSIZE_Z + +#define FI_BK_WORLDSIZE_BASE (FI_UT_BASE_SIZE * UT_BASE_NUM) +#define FI_BK_WORLDSIZE_BASE_F ((f32)FI_BK_WORLDSIZE_BASE) + +#define FI_BK_WORLDSIZE_X FI_BK_WORLDSIZE_BASE +#define FI_BK_WORLDSIZE_Z FI_BK_WORLDSIZE_BASE + +#define FI_BK_WORLDSIZE_X_F FI_BK_WORLDSIZE_BASE_F +#define FI_BK_WORLDSIZE_Z_F FI_BK_WORLDSIZE_BASE_F + + typedef enum FieldType { /* 0 */ FI_FIELDTYPE_FG, /* 1 */ FI_FIELDTYPE_1, @@ -61,7 +74,7 @@ s32 mFI_GetBlockZMax(void); // void func_80088018_jp(); // void func_80088160_jp(); // void func_8008819C_jp(); -// void func_800881AC_jp(); +// s32 mFI_BlockCheck(s32 blockX, s32 blockZ); // void func_80088270_jp(); // void func_800882AC_jp(); // void func_800882FC_jp(); @@ -77,8 +90,8 @@ s32 mFI_Wpos2BkandUtNuminBlock(s32*,s32*, s32* ,s32* ,xyz_t); // void func_80088938_jp(); // void func_800889D8_jp(); // void func_80088A58_jp(); -// void func_80088B3C_jp(); -void mFI_UtNum2PosXZInBk(f32*, f32*, s32,s32); +s32 mFI_BkNum2WposXZ(f32* worldPosX, f32* worldPosZ, s32 blockX, s32 blockZ); +void mFI_UtNum2PosXZInBk(f32*, f32*, s32, s32); // void func_80088BFC_jp(); void mFI_BkandUtNum2CenterWpos(xyz_t*, s32, s32, s32, s32); // void func_80088CBC_jp(); @@ -98,8 +111,8 @@ void mFI_BkandUtNum2CenterWpos(xyz_t*, s32, s32, s32, s32); // void func_80089114_jp(); // void func_800891AC_jp(); u8 mFI_BkNum2BlockType(s32,s32); -// void func_800892CC_jp(); -// void func_8008930C_jp(); +// s32 mFI_GetPuleTypeIdx(u8 type); +s32 mFI_GetPuleIdx(void); // void func_80089348_jp(); // void func_800893C8_jp(); s32 mFI_CheckBlockKind_OR(s32, s32, s32); diff --git a/linker_scripts/jp/symbol_addrs_code.txt b/linker_scripts/jp/symbol_addrs_code.txt index 5a146be..d83cf9a 100644 --- a/linker_scripts/jp/symbol_addrs_code.txt +++ b/linker_scripts/jp/symbol_addrs_code.txt @@ -1309,7 +1309,7 @@ func_80087ED0_jp = 0x80087ED0; // type:func func_80088018_jp = 0x80088018; // type:func func_80088160_jp = 0x80088160; // type:func func_8008819C_jp = 0x8008819C; // type:func -func_800881AC_jp = 0x800881AC; // type:func +mFI_BlockCheck = 0x800881AC; // type:func func_80088270_jp = 0x80088270; // type:func func_800882AC_jp = 0x800882AC; // type:func func_800882FC_jp = 0x800882FC; // type:func @@ -1325,7 +1325,7 @@ func_800888AC_jp = 0x800888AC; // type:func func_80088938_jp = 0x80088938; // type:func func_800889D8_jp = 0x800889D8; // type:func func_80088A58_jp = 0x80088A58; // type:func -func_80088B3C_jp = 0x80088B3C; // type:func +mFI_BkNum2WposXZ = 0x80088B3C; // type:func mFI_UtNum2PosXZInBk = 0x80088BC0; // type:func func_80088BFC_jp = 0x80088BFC; // type:func mFI_BkandUtNum2CenterWpos = 0x80088C74; // type:func @@ -1346,8 +1346,8 @@ func_8008907C_jp = 0x8008907C; // type:func func_80089114_jp = 0x80089114; // type:func func_800891AC_jp = 0x800891AC; // type:func mFI_BkNum2BlockType = 0x80089268; // type:func -func_800892CC_jp = 0x800892CC; // type:func -func_8008930C_jp = 0x8008930C; // type:func +mFI_GetPuleTypeIdx = 0x800892CC; // type:func +mFI_GetPuleIdx = 0x8008930C; // type:func func_80089348_jp = 0x80089348; // type:func func_800893C8_jp = 0x800893C8; // type:func mFI_CheckBlockKind_OR = 0x80089404; // type:func diff --git a/linker_scripts/jp/symbol_addrs_overlays.txt b/linker_scripts/jp/symbol_addrs_overlays.txt index 122f60f..493db2a 100644 --- a/linker_scripts/jp/symbol_addrs_overlays.txt +++ b/linker_scripts/jp/symbol_addrs_overlays.txt @@ -12757,44 +12757,44 @@ aHM1_actor_ct = 0x809DEC90; // type:func aHM1_actor_save = 0x809DED00; // type:func aHM1_actor_dt = 0x809DED2C; // type:func aHM1_actor_init = 0x809DED58; // type:func -func_809DED84_jp = 0x809DED84; // type:func -func_809DEDC4_jp = 0x809DEDC4; // type:func -func_809DEDF0_jp = 0x809DEDF0; // type:func -func_809DEE10_jp = 0x809DEE10; // type:func -func_809DEE60_jp = 0x809DEE60; // type:func -func_809DEEEC_jp = 0x809DEEEC; // type:func -func_809DF028_jp = 0x809DF028; // type:func -func_809DF074_jp = 0x809DF074; // type:func -func_809DF0EC_jp = 0x809DF0EC; // type:func -func_809DF134_jp = 0x809DF134; // type:func -func_809DF180_jp = 0x809DF180; // type:func -func_809DF194_jp = 0x809DF194; // type:func -func_809DF1B8_jp = 0x809DF1B8; // type:func -func_809DF1E0_jp = 0x809DF1E0; // type:func -func_809DF210_jp = 0x809DF210; // type:func -func_809DF30C_jp = 0x809DF30C; // type:func -func_809DF33C_jp = 0x809DF33C; // type:func -func_809DF36C_jp = 0x809DF36C; // type:func -func_809DF3FC_jp = 0x809DF3FC; // type:func -func_809DF468_jp = 0x809DF468; // type:func -func_809DF498_jp = 0x809DF498; // type:func -func_809DF4F0_jp = 0x809DF4F0; // type:func -func_809DF524_jp = 0x809DF524; // type:func -func_809DF550_jp = 0x809DF550; // type:func -func_809DF590_jp = 0x809DF590; // type:func +aHM1_set_animation = 0x809DED84; // type:func +aHM1_actor_move = 0x809DEDC4; // type:func +aHM1_set_request_act = 0x809DEDF0; // type:func +aHM1_check_moveRange = 0x809DEE10; // type:func +aHM1_check_inBlock = 0x809DEE60; // type:func +aHM1_revise_moveRange = 0x809DEEEC; // type:func +aHM1_turn = 0x809DF028; // type:func +aHM1_walk = 0x809DF074; // type:func +aHM1_set_spd_info = 0x809DF0EC; // type:func +aHM1_setupAction = 0x809DF134; // type:func +aHM1_act_chg_data_proc = 0x809DF180; // type:func +aHM1_act_init_proc = 0x809DF194; // type:func +aHM1_act_main_proc = 0x809DF1B8; // type:func +aHM1_act_proc = 0x809DF1E0; // type:func +aHM1_think_main_proc = 0x809DF210; // type:func +aHM1_think_init_proc = 0x809DF30C; // type:func +aHM1_think_proc = 0x809DF33C; // type:func +aHM1_schedule_init_proc = 0x809DF36C; // type:func +aHM1_schedule_main_proc = 0x809DF3FC; // type:func +aHM1_schedule_proc = 0x809DF468; // type:func +aHM1_set_talk_info = 0x809DF498; // type:func +aHM1_talk_request = 0x809DF4F0; // type:func +aHM1_talk_init = 0x809DF524; // type:func +aHM1_talk_end_chk = 0x809DF550; // type:func +aHM1_actor_draw = 0x809DF590; // type:func // .data Hanami_Npc1_Profile = 0x809DF5C0; // -D_809DF5E4_jp = 0x809DF5E4; // -D_809DF600_jp = 0x809DF600; // -D_FLT_809DF608_jp = 0x809DF608; // type:f32 -D_809DF610_jp = 0x809DF610; // -D_809DF618_jp = 0x809DF618; // -D_809DF624_jp = 0x809DF624; // -D_809DF62C_jp = 0x809DF62C; // type:s16 -D_809DF63C_jp = 0x809DF63C; // -D_809DF644_jp = 0x809DF644; // +aHM1_ct_data = 0x809DF5E4; // +animeSeqNo = 0x809DF600; // allow_duplicated:true +offset = 0x809DF608; // type:f32 allow_duplicated:true +process = 0x809DF610; // allow_duplicated:true +act_proc = 0x809DF618; // allow_duplicated:true +think_proc = 0x809DF624; // allow_duplicated:true +def_angle = 0x809DF62C; // type:s16 size:0xE allow_duplicated:true +sche_proc = 0x809DF63C; // allow_duplicated:true +msg_base = 0x809DF644; // size:0x18 allow_duplicated:true // .rodata diff --git a/src/code/m_actor.c b/src/code/m_actor.c index 53c22f9..8995617 100644 --- a/src/code/m_actor.c +++ b/src/code/m_actor.c @@ -322,11 +322,11 @@ void Actor_delete_check(Actor* actor, Game_Play* game_play) { return; } - if ((actor->unk_008 < 0) || (actor->unk_009 < 0)) { + if ((actor->blockX < 0) || (actor->blockZ < 0)) { return; } - if ((actor->unk_008 == game_play->unk_00E4) && (actor->unk_009 == game_play->unk_00E5)) { + if ((actor->blockX == game_play->unk_00E4) && (actor->blockZ == game_play->unk_00E5)) { return; } @@ -761,7 +761,7 @@ s32 Actor_malloc_actor_class(Actor** actorP, ActorProfile* profile, ActorOverlay } void Actor_init_actor_class(Actor* actor, ActorProfile* profile, ActorOverlay* overlayEntry, Game_Play* game_play, - s32 arg4, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s8 argB, s8 argC, s16 argD, + s32 arg4, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s8 blockX, s8 blockZ, s16 argD, u16 fgName, s16 params) { mem_clear((u8*)actor, profile->instanceSize, 0); @@ -789,8 +789,8 @@ void Actor_init_actor_class(Actor* actor, ActorProfile* profile, ActorOverlay* o actor->home.rot.y = rotY; actor->home.rot.z = rotZ; - actor->unk_008 = argB; - actor->unk_009 = argC; + actor->blockX = blockX; + actor->blockZ = blockZ; actor->unk_00A = argD; actor->fgName = fgName; } @@ -861,7 +861,7 @@ void restore_fgdata(Actor* actor, Game_Play* game_play UNUSED) { return; } - if ((actor->unk_008 < 0) || (actor->unk_009 < 0)) { + if ((actor->blockX < 0) || (actor->blockZ < 0)) { return; } diff --git a/src/code/m_field_info.c b/src/code/m_field_info.c index a005e5b..9277fa6 100644 --- a/src/code/m_field_info.c +++ b/src/code/m_field_info.c @@ -3,6 +3,9 @@ #include "m_collision_bg.h" #include "libc64/qrand.h" +s32 mFI_GetPuleTypeIdx(u8 type); +s32 mFI_BlockCheck(s32 blockX, s32 blockZ); + #pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/mFI_ClearFieldData.s") #pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/mFI_CheckFieldData.s") @@ -31,7 +34,7 @@ #pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/func_8008819C_jp.s") -#pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/func_800881AC_jp.s") +#pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/mFI_BlockCheck.s") #pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/func_80088270_jp.s") @@ -63,7 +66,19 @@ #pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/func_80088A58_jp.s") -#pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/func_80088B3C_jp.s") +s32 mFI_BkNum2WposXZ(f32* worldPosX, f32* worldPosZ, s32 blockX, s32 blockZ) { + s32 result; + + *worldPosX = (f32)(blockX * FI_BK_WORLDSIZE_X); + *worldPosZ = (f32)(blockZ * FI_BK_WORLDSIZE_Z); + result = FALSE; + + if (mFI_CheckFieldData() == TRUE) { + result = mFI_BlockCheck(blockX, blockZ); + } + + return result; +} #pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/mFI_UtNum2PosXZInBk.s") @@ -105,9 +120,21 @@ #pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/mFI_BkNum2BlockType.s") -#pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/func_800892CC_jp.s") +#pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/mFI_GetPuleTypeIdx.s") + +s32 mFI_GetPuleIdx(void) { + u32 mask = (1 << 15); // TODO: make an enum/define + s32 blockX; + s32 blockZ; + u8 type; + s32 result; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/func_8008930C_jp.s") + mFI_BlockKind2BkNum(&blockX, &blockZ, mask); + type = mFI_BkNum2BlockType(blockX, blockZ); + result = mFI_GetPuleTypeIdx(type); + + return result; +} #pragma GLOBAL_ASM("asm/jp/nonmatchings/code/m_field_info/func_80089348_jp.s") diff --git a/src/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1.c b/src/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1.c index 14e275a..be40690 100644 --- a/src/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1.c +++ b/src/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1.c @@ -3,13 +3,22 @@ #include "m_actor_dlftbls.h" #include "m_object.h" #include "overlays/gamestates/ovl_play/m_play.h" +#include "m_field_info.h" + +#define THIS ((Hanami_Npc1*)thisx) +#define ACTION_WALK 1 void aHM1_actor_ct(Actor* thisx, Game_Play* game_play); void aHM1_actor_dt(Actor* thisx, Game_Play* game_play); void aHM1_actor_init(Actor* thisx, Game_Play* game_play); void aHM1_actor_save(Actor* thisx, Game_Play* game_play); +void aHM1_actor_move(Actor* thisx, Game_Play* game_play); +void aHM1_actor_draw(Actor* thisx, Game_Play* game_play); +void aHM1_schedule_proc(Actor* thisx, Game_Play* game_play, s32 processIndex); +void aHM1_talk_request(Actor* thisx, UNK_TYPE arg1 UNUSED); +s32 aHM1_talk_init(UNK_TYPE arg0 UNUSED, UNK_TYPE arg1 UNUSED); +s32 aHM1_talk_end_chk(Actor* thisx, UNK_TYPE arg1 UNUSED); -#if 0 ActorProfile Hanami_Npc1_Profile = { /* */ ACTOR_HANAMI_NPC1, /* */ ACTOR_PART_NPC, @@ -23,62 +32,315 @@ ActorProfile Hanami_Npc1_Profile = { /* */ (void*)none_proc1, /* */ aHM1_actor_save, }; -#endif -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/aHM1_actor_ct.s") +struct_809AEFA4 aHM1_ct_data = { + /* */ aHM1_actor_move, + /* */ aHM1_actor_draw, + /* */ 4, + /* */ aHM1_talk_request, + /* */ aHM1_talk_init, + /* */ aHM1_talk_end_chk, + /* */ NULL, +}; + +void aHM1_actor_ct(Actor* thisx, Game_Play* game_play) { + Hanami_Npc1* this = THIS; + + if (common_data.clip.unk_040->unk_BC(&this->actor, game_play) == 1) { + this->unk_7C0 = aHM1_schedule_proc; + common_data.clip.unk_040->unk_C0(&this->actor, game_play, &aHM1_ct_data); + } +} + +void aHM1_actor_save(Actor* thisx, Game_Play* game_play) { + common_data.clip.unk_040->unk_C8(thisx, game_play); +} + +void aHM1_actor_dt(Actor* thisx, Game_Play* game_play) { + common_data.clip.unk_040->unk_C4(thisx, game_play); +} + +void aHM1_actor_init(Actor* thisx, Game_Play* game_play) { + common_data.clip.unk_040->unk_CC(thisx, game_play); +} + +void aHM1_set_animation(Hanami_Npc1* this, s32 processIndex) { + static UNK_TYPE4 animeSeqNo[] = { 0x0000004B, 0x0000004B }; + + common_data.clip.unk_040->unk_104(&this->actor, animeSeqNo[processIndex], 0, processIndex); +} + +void aHM1_actor_move(Actor* thisx, Game_Play* game_play) { + common_data.clip.unk_040->unk_D0(thisx, game_play); +} + +void aHM1_set_request_act(Actor* thisx) { + Hanami_Npc1* this = THIS; + + this->unk_7D4 = 4; + this->unk_7D5 = 0x12; + this->unk_7D6 = 2; +} + +s32 aHM1_check_moveRange(Actor* thisx, xyz_t* destination) { + f32 posDiffX = thisx->home.pos.x - destination->x; + f32 posDiffZ = thisx->home.pos.z - destination->z; + f32 magnitudeSquared; + s32 notInRange = FALSE; + + magnitudeSquared = (posDiffX * posDiffX) + (posDiffZ * posDiffZ); + + if (magnitudeSquared > 10000.0f) { + notInRange = TRUE; + } + + return notInRange; +} + +s32 aHM1_check_inBlock(Actor* thisx, xyz_t* pos, s32* blockX, s32* blockZ) { + s32 notInBlock = FALSE; + + mFI_Wpos2BlockNum(blockX, blockZ, *pos); + + if ((thisx->blockX != *blockX) || (thisx->blockZ != *blockZ)) { + notInBlock = TRUE; + } + + return notInBlock; +} + +void aHM1_revise_moveRange(Hanami_Npc1* this) { + static f32 offset[] = { 0.0f, 319.0f }; + s32 mask = 0; + + if (aHM1_check_moveRange(&this->actor, &this->actor.world.pos) == TRUE) { + s16 searchAngle = search_position_angleY(&this->actor.home.pos, &this->actor.world.pos); + this->actor.world.pos.x = (sin_s(searchAngle) * 100.0f) + this->actor.home.pos.x; + this->actor.world.pos.z = (cos_s(searchAngle) * 100.0f) + this->actor.home.pos.z; + mask = 3; + } else { + s32 blockX; + s32 blockZ; + f32 worldPosX; + f32 worldPosZ; + + if (aHM1_check_inBlock(&this->actor, &this->actor.world.pos, &blockX, &blockZ) == TRUE) { + s32 hanamiBlock; + s32 offsetIndex; + + mFI_BkNum2WposXZ(&worldPosX, &worldPosZ, this->actor.blockX, this->actor.blockZ); + + //! FAKE + if (hanamiBlock) {} + + hanamiBlock = this->actor.blockX; + offsetIndex = hanamiBlock < blockX; + + if (blockX != hanamiBlock) { + this->actor.world.pos.x = offset[offsetIndex] + worldPosX; + } + + hanamiBlock = this->actor.blockZ; + offsetIndex = hanamiBlock < blockZ; + + if (blockZ != hanamiBlock) { + this->actor.world.pos.z = offset[offsetIndex] + worldPosZ; + } + mask = 3; + } + } + + this->unk_910 = (u8)(this->unk_910 | mask); +} + +void aHM1_turn(Actor* thisx) { + Hanami_Npc1* this = THIS; + + if (chase_angle(&this->actor.shape.rot.y, this->unk_8DC, 0x800) == TRUE) { + this->unk_93C = 1; + this->unk_7C6 = 0xFF; + } + + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void aHM1_walk(Actor* thisx) { + Hanami_Npc1* this = THIS; + + aHM1_revise_moveRange(this); + + if (this->unk_910 != 0) { + this->unk_7C6 = 0xFF; + } else if (this->unk_8CC >= 0x1F) { + this->unk_7C6 = 0xFF; + } + + chase_angle(&this->actor.shape.rot.y, this->unk_8DC, 0x400); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void aHM1_set_spd_info(Hanami_Npc1* this, s32 action) { + if (action == ACTION_WALK) { + this->unk_8B4 = 0.1f; + this->unk_8B8 = 0.1f; + this->unk_8B0 = 1.0f; + + return; + } + + this->actor.speed = 0.0f; + this->unk_8B0 = 0.0f; + this->unk_8B4 = 0.0f; + this->unk_8B8 = 0.0f; +} + +void aHM1_setupAction(Hanami_Npc1* this, s32 processIndex) { + static Hanami_Npc1_unk_940 process[] = { aHM1_turn, aHM1_walk }; + + this->unk_7C6 = 0; + this->unk_938 = processIndex; + this->unk_940 = process[processIndex]; + aHM1_set_animation(this, processIndex); + aHM1_set_spd_info(this, processIndex); +} + +void aHM1_act_chg_data_proc(Hanami_Npc1* this, Game_Play* game_play UNUSED) { + this->unk_7C9 = 1; +} + +void aHM1_act_init_proc(Hanami_Npc1* this, Game_Play* game_play UNUSED) { + aHM1_setupAction(this, 1); +} + +void aHM1_act_main_proc(Hanami_Npc1* this, Game_Play* game_play UNUSED) { + this->unk_940(&this->actor); +} + +void aHM1_act_proc(Actor* thisx, Game_Play* game_play, s32 processIndex) { + static Hanami_Npc1ActionFunc act_proc[] = { aHM1_act_init_proc, aHM1_act_chg_data_proc, aHM1_act_main_proc }; + Hanami_Npc1* this = THIS; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/aHM1_actor_save.s") + (*act_proc[processIndex])(this, game_play); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/aHM1_actor_dt.s") +void aHM1_think_main_proc(Hanami_Npc1* this, Game_Play* game_play UNUSED) { + s16 modRotY; + s32 modRotYAbsValue; + f32 randS16AsFloat; + s32 processIndex; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/aHM1_actor_init.s") + if (this->unk_7C6 == 0xFF) { + if (this->unk_7C5 == 0x12) { + if (this->unk_93C != -1) { + processIndex = this->unk_93C; + } else { + randS16AsFloat = (fqrand() - 0.5f) * 65536.0f; + modRotY = ((s16)randS16AsFloat) - this->actor.shape.rot.y; + this->unk_8DC = randS16AsFloat; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DED84_jp.s") + if (modRotY >= 0) { + modRotYAbsValue = modRotY; + } else { + modRotYAbsValue = -modRotY; + } -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DEDC4_jp.s") + if (modRotYAbsValue >= 0x6001) { + processIndex = 0; + } else { -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DEDF0_jp.s") + if (!(this->unk_910 & 3)) { + processIndex = 1; + } else { + processIndex = 0; + } + } + } -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DEE10_jp.s") + this->unk_8CC = 0; + aHM1_setupAction(this, processIndex); + } -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DEE60_jp.s") + this->unk_93C = -1; + this->unk_80C = 3; + aHM1_set_request_act(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DEEEC_jp.s") +void aHM1_think_init_proc(Hanami_Npc1* this, Game_Play* game_play UNUSED) { + this->unk_7A8 = 0; + this->unk_7D0 = aHM1_act_proc; + aHM1_set_request_act(&this->actor); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF028_jp.s") +void aHM1_think_proc(Actor* thisx, Game_Play* game_play, s32 processIndex) { + static Hanami_Npc1ActionFunc think_proc[] = { aHM1_think_init_proc, aHM1_think_main_proc }; + Hanami_Npc1* this = THIS; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF074_jp.s") + (*think_proc[processIndex])(this, game_play); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF0EC_jp.s") +void aHM1_schedule_init_proc(Hanami_Npc1* this, Game_Play* game_play) { + static s16 def_angle[] = { 0x2000, 0x2000, 0xE000, 0xC000, 0x0000, 0xE000, 0xE000 }; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF134_jp.s") + this->unk_7A4 = aHM1_think_proc; + this->unk_7FD = 0; + this->unk_8AC = -1; + this->unk_93C = -1; + this->unk_80C = 3; + this->actor.colStatus.mass = MASS_HEAVY; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF180_jp.s") + { + s32 angleIndex = mFI_GetPuleIdx(); + s16 tempAngle = def_angle[angleIndex]; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF194_jp.s") + this->actor.shape.rot.y = tempAngle; + this->actor.world.rot.y = tempAngle; + this->unk_8DC = tempAngle; + } -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF1B8_jp.s") + common_data.clip.unk_040->unk_110(&this->actor, game_play, 8, 0); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF1E0_jp.s") +void aHM1_schedule_main_proc(Hanami_Npc1* this, Game_Play* game_play) { + if (common_data.clip.unk_040->unk_110(&this->actor, game_play, -1, 1) == 0) { + common_data.clip.unk_040->unk_110(&this->actor, game_play, -1, 2); + } +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF210_jp.s") +void aHM1_schedule_proc(Actor* thisx, Game_Play* game_play, s32 processIndex) { + static Hanami_Npc1ActionFunc sche_proc[] = { aHM1_schedule_init_proc, aHM1_schedule_main_proc }; + Hanami_Npc1* this = THIS; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF30C_jp.s") + (*sche_proc[processIndex])(this, game_play); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF33C_jp.s") +void aHM1_set_talk_info(Actor* thisx) { + static u32 msg_base[] = { 0x00001939, 0x00001948, 0x0000192A, 0x00001957, 0x00001966, 0x00001975 }; + enum NpcLooks looks = mNpc_GetNpcLooks(thisx); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF36C_jp.s") + mDemo_Set_msg_num(msg_base[looks] + ((s32)(fqrand() * 3.0f))); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF3FC_jp.s") +void aHM1_talk_request(Actor* thisx, UNK_TYPE arg1 UNUSED) { + mDemo_Request(7, thisx, aHM1_set_talk_info); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF468_jp.s") +s32 aHM1_talk_init(UNK_TYPE arg0 UNUSED, UNK_TYPE arg1 UNUSED) { + mDemo_Set_ListenAble(); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF498_jp.s") + return 1; +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF4F0_jp.s") +s32 aHM1_talk_end_chk(Actor* thisx, UNK_TYPE arg1 UNUSED) { + s32 result = FALSE; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF524_jp.s") + if (!mDemo_Check(7, thisx)) { + result = TRUE; + } -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF550_jp.s") + return result; +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1/func_809DF590_jp.s") +void aHM1_actor_draw(Actor* thisx, Game_Play* game_play) { + common_data.clip.unk_040->unk_E4(thisx, game_play); +} diff --git a/src/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1.h b/src/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1.h index 30a8b91..432a036 100644 --- a/src/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1.h +++ b/src/overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1.h @@ -9,10 +9,47 @@ struct Game_Play; struct Hanami_Npc1; typedef void (*Hanami_Npc1ActionFunc)(struct Hanami_Npc1*, struct Game_Play*); +typedef void (*Hanami_Npc1_unk_940)(struct Actor*); typedef struct Hanami_Npc1 { /* 0x000 */ Actor actor; - /* 0x174 */ UNK_TYPE1 unk_174[0x7D0]; + /* 0x174 */ UNK_TYPE1 unk_174[0x630]; // unreferenced in actor file + /* 0x7A4 */ UNK_PTR unk_7A4; + /* 0x7A8 */ UNK_TYPE4 unk_7A8; + /* 0x7AC */ UNK_TYPE1 unk_7AC[0x14]; // unreferenced in actor file + /* 0x7C0 */ UNK_PTR unk_7C0; + /* 0x7C4 */ UNK_TYPE1 unk_7C4; // inferred from alignment + /* 0x7C5 */ u8 unk_7C5; + /* 0x7C6 */ u8 unk_7C6; + /* 0x7C7 */ UNK_TYPE1 unk_7C7; // inferred from alignment (could be auto padding) + /* 0x7C8 */ UNK_TYPE1 unk_7C8; // inferred from alignment + /* 0x7C9 */ UNK_TYPE1 unk_7C9; + /* 0x7CA */ UNK_TYPE1 unk_7CA[6]; // unreferenced in actor file + /* 0x7D0 */ UNK_PTR unk_7D0; + /* 0x7D4 */ UNK_TYPE1 unk_7D4; + /* 0x7D5 */ UNK_TYPE1 unk_7D5; + /* 0x7D6 */ UNK_TYPE1 unk_7D6; + /* 0x7D7 */ UNK_TYPE1 unk_7D7; // inferred from alignment (could be auto padding) + /* 0x7D8 */ UNK_TYPE1 unk_7D8[0x24]; // unreferenced in actor file + /* 0x7FC */ UNK_TYPE1 unk_7FC; // inferred from alignment + /* 0x7FD */ UNK_TYPE1 unk_7FD; + /* 0x7FE */ UNK_TYPE1 unk_7FE[0xE]; // unreferenced in actor file + /* 0x80C */ UNK_TYPE4 unk_80C; + /* 0x810 */ UNK_TYPE1 unk_810[0x9C]; // unreferenced in actor file + /* 0x8AC */ UNK_TYPE4 unk_8AC; + /* 0x8B0 */ f32 unk_8B0; + /* 0x8B4 */ f32 unk_8B4; + /* 0x8B8 */ f32 unk_8B8; + /* 0x8BC */ UNK_TYPE1 unk_8BC[0x10]; // unreferenced in actor file + /* 0x8CC */ UNK_TYPE2 unk_8CC; + /* 0X8CE */ UNK_TYPE1 unk_8CE[0xE]; // unreferenced in actor file + /* 0x8DC */ UNK_TYPE2 unk_8DC; + /* 0x8DE */ UNK_TYPE1 unk_8DE[0x32]; // unreferenced in actor file + /* 0x910 */ u8 unk_910; + /* 0x911 */ UNK_TYPE1 unk_911[0x27]; // unreferenced in actor file + /* 0x938 */ UNK_TYPE4 unk_938; + /* 0x93C */ UNK_TYPE unk_93C; + /* 0x940 */ Hanami_Npc1_unk_940 unk_940; } Hanami_Npc1; // size = 0x944 #endif diff --git a/yamls/jp/overlays.yaml b/yamls/jp/overlays.yaml index 8489ab1..eb003f3 100644 --- a/yamls/jp/overlays.yaml +++ b/yamls/jp/overlays.yaml @@ -2664,7 +2664,7 @@ bss_size: 0x0 subsegments: - [0x8C2480, c, overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1] - - [0x8C2DB0, data, overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1] + - [0x8C2DB0, .data, overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1] - [0x8C2E50, .rodata, overlays/actors/ovl_Hanami_Npc1/ac_hanami_npc1] - name: ovl_Hanami_Npc1_reloc type: code |
