Merge pull request #125 from Cuyler36/m_melody

Implement & link m_melody.c
This commit is contained in:
Cuyler36
2023-10-15 01:47:45 -04:00
committed by GitHub
6 changed files with 117 additions and 7 deletions
+3 -1
View File
@@ -8,4 +8,6 @@ symbol_aligns:
0x806D4D40: 32 # align fFTR_myhome_off_pal_table to 32 bytes
0x8064F860: 32 # data right after m_camera2 TU
0x80C78B20: 32 # mFM_grd_s_cliff_tex
0x80F8C460: 32 # mFM_grd_s_rail_tex
0x80F8C460: 32 # mFM_grd_s_rail_tex
0x80657200: 32 # .data msg.o
0x81297E80: 32 # .bss msg.o
+4
View File
@@ -149,6 +149,10 @@ m_mail_password_check.c:
m_mark_room.c:
.text: [0x803BEC9C, 0x803BF210]
.rodata: [0x806426D8, 0x806426E8]
m_melody.c:
.text: [0x803BF210, 0x803BF464]
.data: [0x806571D8, 0x80657200]
.bss: [0x81297E68, 0x81297E80]
m_museum.c:
.text: [0x803C6228, 0x803C74C0]
.rodata: [0x80642938, 0x80642950]
+12 -6
View File
@@ -7,6 +7,7 @@
#include "ac_npc_h.h"
#include "m_npc_schedule.h"
#include "m_actor_dlftbls.h"
#include "m_npc.h"
#ifdef __cplusplus
extern "C" {
@@ -55,19 +56,24 @@ struct ac_npc_clip_s {
};
typedef struct npc_info_s {
mNPS_schedule_c* schedule;
mNpc_NpcList_c* list;
Animal_c* animal;
void* event; // TODO: EventNpc struct
mNpc_NpcList_c* list;
mNPS_schedule_c* schedule;
mNpc_EventNpc_c* event;
mNpc_MaskNpc_c* mask;
mActor_name_t npc_name;
} NpcActorInfo_c;
struct npc_actor_s {
ACTOR actor_class;
int _174;
int _178;
NpcActorInfo_c npc_info;
// TODO: finish
u8 _174[0x718 - 0x184];
u8 _194[0x718 - 0x194];
int texture_bank_idx; // TEMP: this is part of draw struct
u8 _71C[0x9D8 - 0x71C];
u8 _71C[0x978 - 0x71C];
s16 melody_inst;
u8 _97A[0x9D8 - 0x97A];
};
extern ACTOR_PROFILE Npc_Profile;
+10
View File
@@ -2,12 +2,22 @@
#define M_MELODY_H
#include "types.h"
#include "m_actor_type.h"
#ifdef __cplusplus
extern "C" {
#endif
#define mMld_MELODY_LEN 16
extern void mMld_SetDefaultMelody();
extern void mMld_TransformMelodyData_u64_2_u8(u8* dst, u64 src);
extern void mMld_TransformMelodyData_u8_2_u64(u64* dst, u8* src);
extern void mMld_GetMelody(u8* dst);
extern void mMld_SetSaveMelody(u8* melody);
extern void mMld_MakeMelody(u16 inst);
extern void mMld_ActorMakeThisMelody(u8* melody, ACTOR* actor);
extern void mMld_ActorMakeMelody(ACTOR* actor);
#ifdef __cplusplus
}
+19
View File
@@ -196,6 +196,25 @@ typedef struct npc_list_s {
mActor_name_t reward_furniture;
} mNpc_NpcList_c;
typedef struct event_npc_s {
mActor_name_t event_id; /* event NPC id */
mActor_name_t texture_id; /* real NPC id which is used for texture data */
mActor_name_t npc_id; /* non-texture NPC id used for other NPC data */
mActor_name_t cloth_id; /* cloth texture id */
u8 exists; /* has the actor been spawned yet? */
u8 in_use; /* is this event npc structure being used? */
u16 _A; /* exists based on size of structure, seems unused */
} mNpc_EventNpc_c;
typedef struct mask_npc_s {
mActor_name_t mask_id; /* 'mask' actor id */
mActor_name_t npc_id; /* NPC actor id whose data will be used */
mActor_name_t cloth_id; /* cloth actor id */
u8 exists; /* has the actor been spawned yet? */
u8 in_use; /* is this mask npc structure being used? */
Animal_c animal_data; /* animal data is copied if the mask npc is a standard villager NPC */
} mNpc_MaskNpc_c;
/* anm_id could also just be a Animal_c pointer */
extern void mNpc_GetNpcWorldNameAnm(u8* name, AnmPersonalID_c* anm_id);
extern int mNpc_CheckFreeAnimalPersonalID(AnmPersonalID_c* anm_id);
+69
View File
@@ -0,0 +1,69 @@
#include "m_melody.h"
#include "ac_npc.h"
#include "m_common_data.h"
extern void mMld_SetDefaultMelody() {
static u8 melody[mMld_MELODY_LEN] = {
0x7, 0xC, 0xF, 0x7, 0x6, 0xB, 0xF, 0x9,
0xA, 0xE, 0xD, 0xE, 0x3, 0xF, 0xE, 0xE
};
mMld_SetSaveMelody(melody);
}
extern void mMld_TransformMelodyData_u64_2_u8(u8* dst, u64 src) {
int i;
for (i = 0; i < mMld_MELODY_LEN; i++) {
*dst++ = (src >> (60 - i * 4)) & 0xF;
}
}
extern void mMld_TransformMelodyData_u8_2_u64(u64* dst, u8* src) {
int i;
dst[0] = 0;
for (i = 0; i < mMld_MELODY_LEN; i++) {
dst[0] |= (u64)(src[0] & 0xF) << (60 - i * 4);
src++;
}
}
extern void mMld_GetMelody(u8* dst) {
mMld_TransformMelodyData_u64_2_u8(dst, Save_Get(melody));
}
extern void mMld_SetSaveMelody(u8* melody) {
mMld_TransformMelodyData_u8_2_u64(Save_GetPointer(melody), melody);
}
extern void mMld_MakeMelody(u16 inst) {
static u8 melody[mMld_MELODY_LEN];
mMld_GetMelody(melody);
sAdo_Inst(inst, melody);
}
extern void mMld_ActorMakeThisMelody(u8* melody, ACTOR* actor) {
if (actor != NULL && actor->part == ACTOR_PART_NPC) {
NPC_ACTOR* npc_actor = (NPC_ACTOR*)actor;
int melody_inst = npc_actor->melody_inst;
if (melody_inst != 0) {
sAdo_Inst(melody_inst, melody);
}
}
}
extern void mMld_ActorMakeMelody(ACTOR* actor) {
if (actor != NULL && actor->part == ACTOR_PART_NPC) {
NPC_ACTOR* npc_actor = (NPC_ACTOR*)actor;
int melody_inst = npc_actor->melody_inst;
if (melody_inst != 0) {
mMld_MakeMelody(melody_inst);
}
}
}