Implement & link jaudio_NES/staff.c

This commit is contained in:
Cuyler36
2024-06-08 01:09:47 -04:00
parent 24863a411e
commit f96a44c0d9
10 changed files with 266 additions and 18 deletions
+1
View File
@@ -2,6 +2,7 @@ trim_ctors: true
symbol_aligns:
0x80008480: 32
0x80016d20: 32
0x80018920: 32
0x800190e0: 32
0x80019380: 32
+5
View File
@@ -51,6 +51,11 @@ jaudio_NES/rhythm.c:
jaudio_NES/radio.c:
.text: [0x800165ec, 0x8001676c]
.sdata2: [0x80218d78, 0x80218d88]
jaudio_NES/staff.c:
.text: [0x80016840, 0x80016d20]
.data: [0x800cfe10, 0x800cff20]
.sbss: [0x802183b8, 0x802183c8]
.sdata2: [0x80218d98, 0x80218da0]
jaudio_NES/aictrl.c:
.text: [0x80017e80, 0x80018640]
.rodata: [0x800aa500, 0x800aa518]
+2 -1
View File
@@ -636,7 +636,8 @@ JAUDIO_USER_TUS = [
"verysimple.c",
"melody.c",
"radio.c",
"rhythm.c"
"rhythm.c",
"staff.c"
]
class CSource(Source):
+21 -1
View File
@@ -15,6 +15,26 @@ typedef struct audio_tempo_beat_s {
/* 0x01 */ s8 beat;
} TempoBeat_c;
/* sizeof(StaffRollInfo_c) == 0x18 */
typedef struct audio_staffroll_info_s {
/* 0x00 */ s16 staffroll_part;
/* 0x02 */ s16 _01;
/* 0x08 */ f64 percent;
/* 0x10 */ s8 mouth_num;
/* 0x11 */ s8 blink_flag;
/* 0x12 */ s8 beat;
} StaffRollInfo_c;
enum {
STAFFROLL_PART_START,
STAFFROLL_PART_INTRO,
STAFFROLL_PART_MAIN,
STAFFROLL_PART_FADEOUT,
STAFFROLL_PART_FINISH,
STAFFROLL_PART_NUM
};
enum {
VOICE_STATUS_NORMAL,
VOICE_STATUS_ANGRY,
@@ -94,7 +114,7 @@ extern void sAdos_KishaStatusLevel(f32 speed, u32 ongenNum1, u16 angle1, f32 dis
extern void sAdos_GetRadioCounter(void* p);
extern void sAdos_GetKappaCounter(void* p);
extern void sAdos_GetStaffRollInfo(void* p);
extern void sAdos_GetStaffRollInfo(StaffRollInfo_c* info);
extern void sAdos_TTKK_ARM(u8 mode);
+1
View File
@@ -14,6 +14,7 @@ extern "C" {
#define AUDIO_ARAM_HEAP_SIZE 0xC000
#define AUDIO_GROUP_MAX 5
#define AUDIO_SUBTRACK_NUM 16
#define NA_MAKE_COMMAND(a0, a1, a2, a3) \
(u32)((((a0) & 0xFF) << 24) | (((a1) & 0xFF) << 16) | (((a2) & 0xFF) << 8) | (((a3) & 0xFF) << 0))
+1 -1
View File
@@ -520,7 +520,7 @@ struct group_ {
/* 0x02C */ f32 fade_volume_scale;
/* 0x030 */ f32 applied_fade_volume;
/* 0x034 */ f32 bend;
/* 0x038 */ sub* subtracks[16];
/* 0x038 */ sub* subtracks[AUDIO_SUBTRACK_NUM];
/* 0x078 */ seqplayer seq_player;
/* 0x094 */ u8* short_note_velocity_tbl;
/* 0x098 */ u8* short_note_gate_time_tbl;
+5 -9
View File
@@ -2,22 +2,18 @@
#define STAFF_H
#include "types.h"
#include "audio.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct staff_roll_info_s{
s16 unk0;
int unk4;
f64 unk8;
}StaffRoll;
extern void Na_GetStaffRollInfo(void*);
extern void Na_StaffRollInit(void);
extern void Na_StaffRollStart(s16 seq_no);
extern void Na_GetStaffRollInfo(StaffRollInfo_c* info);
#ifdef __cplusplus
}
#endif
#endif
#endif
+4 -3
View File
@@ -87,7 +87,7 @@ void aNRTC_actor_init(ACTOR* actor, GAME* game) {
}
void aNRTC_actor_move(ACTOR* actor, GAME* game) {
StaffRoll info;
StaffRollInfo_c info;
f32 val = 0.5f;
u8 arm_flag = TRUE;
NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor;
@@ -95,10 +95,11 @@ void aNRTC_actor_move(ACTOR* actor, GAME* game) {
if (rtc->npc_class.draw.animation_id == 0x76) {
sAdos_GetStaffRollInfo(&info);
if (info.unk0 != 4) {
if (info.staffroll_part != STAFFROLL_PART_FINISH) {
val = 0.0f;
arm_flag = FALSE;
rtc->npc_class.draw.main_animation.keyframe.frame_control.current_frame = 1.0f + (64.0f * (f32)info.unk8);
rtc->npc_class.draw.main_animation.keyframe.frame_control.current_frame =
1.0f + (64.0f * (f32)info.percent);
}
}
+2 -3
View File
@@ -306,9 +306,8 @@ extern void sAdos_GetKappaCounter(void* p) {
Na_GetKappaCounter(p);
}
extern void sAdos_GetStaffRollInfo(void* p) {
Na_GetStaffRollInfo(p);
extern void sAdos_GetStaffRollInfo(StaffRollInfo_c* info) {
Na_GetStaffRollInfo(info);
}
extern void sAdos_TTKK_ARM(u8 mode) {
+224
View File
@@ -0,0 +1,224 @@
#include "jaudio_NES/staff.h"
#include "jaudio_NES/game64.h"
#include "jaudio_NES/sub_sys.h"
#include "jaudio_NES/audiowork.h"
static BOOL start_flag = FALSE;
static s32 mouth_num = 0;
static u32 seq_num = 0;
extern void Na_StaffRollInit(void) {
start_flag = FALSE;
mouth_num = 0;
seq_num = -1;
}
extern void Na_StaffRollStart(s16 seq_no) {
Nap_SetS8(NA_MAKE_COMMAND(0x46, sou_now_bgm_handle, 0, 0), 0);
Nap_SetS8(NA_MAKE_COMMAND(0x46, sou_now_bgm_handle, 0, 1), 0);
Nap_SetS8(NA_MAKE_COMMAND(0x46, sou_now_bgm_handle, 0, 2), -1);
seq_num = seq_no;
start_flag = TRUE;
}
extern void Na_GetStaffRollInfo(StaffRollInfo_c* info) {
group* group = nullptr;
sub* subtrack = nullptr;
note* note = nullptr;
channel* channel = nullptr;
s32 temp;
s32 mouth_type = 0;
s32 blink;
s32 group_unk16;
s32 i;
if (AG.groups[sou_now_bgm_handle].flags.enabled) {
start_flag = FALSE;
group = &AG.groups[sou_now_bgm_handle];
if (group->seq_script_io[2] == 0) {
info->staffroll_part = STAFFROLL_PART_MAIN;
} else if (group->seq_script_io[2] == 1) {
info->staffroll_part = STAFFROLL_PART_FADEOUT;
} else {
info->staffroll_part = STAFFROLL_PART_INTRO;
}
} else {
if (start_flag) {
info->staffroll_part = STAFFROLL_PART_START;
} else {
info->staffroll_part = STAFFROLL_PART_FINISH;
}
return;
}
for (i = 2; i < AUDIO_SUBTRACK_NUM; i++) {
subtrack = group->subtracks[i];
if (subtrack != nullptr) {
note = subtrack->note_layers[0];
if (note != nullptr && note->_00bit3) {
channel = note->channel;
if (channel != nullptr && channel->common_ch.enabled) {
/* Found our enabled note channel, get mouth type */
switch (i) {
case 2:
case 7:
case 12:
mouth_type = 4;
break;
case 6:
mouth_type = 1;
break;
case 4:
case 13:
mouth_type = 5;
break;
case 10:
mouth_type = 3;
break;
case 11:
mouth_type = 0;
break;
default:
mouth_type = 2;
break;
}
/* stop searching */
break;
}
}
}
}
/* update mouth num */
if (mouth_type != mouth_num) {
switch (mouth_type) {
case 4:
switch (mouth_num) {
case 0:
case 1:
mouth_num = 3;
break;
case 3:
mouth_num = 4;
break;
default:
mouth_num = 1;
break;
}
break;
case 1:
switch (mouth_num) {
case 4:
mouth_num = 3;
break;
default:
mouth_num = 1;
break;
}
break;
case 3:
switch (mouth_num) {
case 2:
case 5:
mouth_num = 1;
break;
default:
mouth_num = 3;
break;
}
break;
case 5:
switch (mouth_num) {
case 4:
mouth_num = 3;
break;
case 1:
mouth_num = 5;
break;
default:
mouth_num = 1;
break;
}
break;
case 2:
switch (mouth_num) {
case 4:
mouth_num = 3;
break;
case 1:
mouth_num = 2;
break;
default:
mouth_num = 1;
break;
}
break;
case 0:
switch (mouth_num) {
case 1:
case 3:
mouth_num = 0;
break;
case 4:
mouth_num = 3;
break;
default:
mouth_num = 1;
break;
}
}
}
info->mouth_num = mouth_num;
/* sequence script itself controls blink flag? */
if (group->seq_script_io[1] == 1) {
blink = TRUE;
} else {
blink = FALSE;
}
info->blink_flag = blink;
group_unk16 = group->unk016;
switch (seq_num) {
case 1:
case 2:
case 3:
case 14:
case 17:
case 19:
case 31:
case 32:
case 39:
case 44:
case 49:
case 52:
info->beat = 3;
break;
default:
info->beat = 4;
break;
}
temp = info->beat * 48;
info->_01 = group_unk16 / temp;
group_unk16 -= info->_01 * temp;
info->percent = (f32)group_unk16 / temp;
}