Implement & link jaudio_NES/track.c

This commit is contained in:
Cuyler36
2024-06-14 13:24:55 -04:00
parent 9647647c1b
commit 0aa45868bb
12 changed files with 2426 additions and 45 deletions
+3 -1
View File
@@ -9,6 +9,7 @@ symbol_aligns:
0x80019760: 32
0x8001a0c0: 32
0x80026400: 32
0x8002c920: 32 # __DSPCheckMXICBoot2__FP16STRUCT_DSP_TASK2
0x80031d80: 32
0x80207458: 8 # align RunQueue to 0x001251d8
0x800b9140: 32 # align gam_win_moji1_tex to 32 bytes
@@ -16,4 +17,5 @@ symbol_aligns:
0x800daaa0: 32 # align texture_cache_data_func to 32 bytes
0x80206f30: 16 # malloc.c align 16 bytes
0x800ab260: 32
0x801864b0: 8 # dspbuf align 8 (not sure why this doesn't happen)
0x800d3b00: 32 # dspboot data section has alignment to 32
0x801864b0: 8 # dspbuf align 8 (not sure why this doesn't happen)
+6
View File
@@ -111,6 +111,12 @@ jaudio_NES/internal/os.c:
.text: [0x80026120, 0x80026300]
jaudio_NES/internal/astest.c:
.text: [0x80026300, 0x80026400]
jaudio_NES/internal/track.c:
.text: [0x80028e60, 0x8002c920]
.rodata: [0x800aa720, 0x800aa780]
.data: [0x800d36f0, 0x800d3b00]
.sbss: [0x80218540, 0x80218548]
.sdata2: [0x80218ec8, 0x80218f08]
jaudio_NES/internal/random.c:
.text: [0x80031ce0, 0x80031d80]
.sdata: [0x80217c38, 0x80217c40]
+63 -2
View File
@@ -15,13 +15,16 @@ extern "C" {
#define AUDIO_GROUP_MAX 5
#define AUDIO_SUBTRACK_NUM 16
#define AUDIO_NOTE_MAX 128
#define AUDIO_TATUMS_PER_BEAT 48
#define AUDIO_GROUP_ALL_SUBTRACKS (0xFFFF)
#define AUDIO_MUTE_FLAG_STOP_SAMPLES (1 << 3)
#define AUDIO_MUTE_FLAG_STOP_NOTE (1 << 4)
#define AUDIO_MUTE_FLAG_STOP_SUBTRACK (1 << 4)
#define AUDIO_MUTE_FLAG_SOFTEN (1 << 5)
#define AUDIO_MUTE_FLAG_6 (1 << 6)
#define AUDIO_MUTE_FLAG_STOP_NOTE (1 << 6)
#define AUDIO_MUTE_FLAG_STOP_SCRIPT (1 << 7)
#define NA_MAKE_COMMAND(a0, a1, a2, a3) \
@@ -41,6 +44,13 @@ typedef enum SampleMedium {
/* 5 */ MEDIUM_RAM_UNLOADED = 5
} SampleMedium;
typedef enum AudioCacheType {
/* 0 */ CACHE_TEMPORARY,
/* 1 */ CACHE_PERSISTENT,
/* 2 */ CACHE_EITHER,
/* 3 */ CACHE_PERMANENT
} AudioCacheType;
typedef enum AudioCacheLoadType {
/* 0 */ CACHE_LOAD_PERMANENT,
/* 1 */ CACHE_LOAD_PERSISTENT,
@@ -49,6 +59,15 @@ typedef enum AudioCacheLoadType {
/* 4 */ CACHE_LOAD_EITHER_NOSYNC
} AudioCacheLoadType;
typedef enum AudioLoadStatus {
/* 0 */ LOAD_STATUS_NOT_LOADED,
/* 1 */ LOAD_STATUS_IN_PROGRESS,
/* 2 */ LOAD_STATUS_COMPLETE,
/* 3 */ LOAD_STATUS_DISCARDABLE,
/* 4 */ LOAD_STATUS_MAYBE_DISCARDABLE,
/* 5 */ LOAD_STATUS_PERMANENT
} AudioLoadStatus;
typedef enum AdsrStatus {
/* 0 */ ADSR_STATUS_DISABLED,
/* 1 */ ADSR_STATUS_INITIAL,
@@ -61,6 +80,31 @@ typedef enum AdsrStatus {
/* 8 */ ADSR_STATUS_SUSTAIN
} AdsrStatus;
typedef enum PortamentoMode {
/* 0 */ PORTAMENTO_MODE_OFF,
/* 1 */ PORTAMENTO_MODE_1,
/* 2 */ PORTAMENTO_MODE_2,
/* 3 */ PORTAMENTO_MODE_3,
/* 4 */ PORTAMENTO_MODE_4,
/* 5 */ PORTAMENTO_MODE_5,
/* 6 */ PORTAMENTO_MODE_6,
/* 7 */ PORTAMENTO_MODE_7,
/* 8 */ PORTAMENTO_MODE_8, // might be PORTAMENTO_MODE_NUM
} PortamentoMode;
typedef enum SampleBankTableType {
/* 0 */ SEQUENCE_TABLE,
/* 1 */ BANK_TABLE,
/* 2 */ WAVE_TABLE
} SampleBankTableType;
#define VOICE_TYPE_PERCUSSION 0
#define VOICE_TYPE_SOUND_EFF 1
#define VOICE_TYPE_INSTRUMENT_START 2
#define AUDIO_SWEEP_IS_SPECIAL(s) ((s).mode & 0x80)
#define AUDIO_SWEEP_MODE(s) ((s).mode & ~0x80)
#define AUDIO_NOTE_RELEASE (1 << 0)
#define AUDIO_NOTE_SAMPLE_NOTES (1 << 1)
@@ -144,6 +188,23 @@ typedef enum AudioCmd {
/* 0xFF */ AUDIOCMD_MAIN_GROUP_SET_VOL_SCALE
} AudioCmd;
typedef enum SeqCmd {
SEQCMD_BRANCH_REL_NOT_EQ_ZERO = 0xF2,
SEQCMD_BRANCH_REL_EQ_ZERO = 0xF3,
SEQCMD_BRANCH_REL = 0xF4,
SEQCMD_BRANCH_ABS_GREQ_ZERO = 0xF5,
SEQCMD_BREAK = 0xF6,
SEQCMD_LOOP_END = 0xF7,
SEQCMD_LOOP = 0xF8,
SEQCMD_BRANCH_ABS_NOT_EQ_ZERO = 0xF9,
SEQCMD_BRANCH_ABS_EQ_ZERO = 0xFA,
SEQCMD_BRANCH_ABS = 0xFB,
SEQCMD_CALL = 0xFC,
SEQCMD_DELAY_N_FRAMES = 0xFD,
SEQCMD_DELAY_1_FRAME = 0xFE,
SEQCMD_STOP_SCRIPT = 0xFF,
} SeqCmd;
typedef enum AUDIO_CALLBACKS {
/* 0x00 */ AUDIO_CALLBACK_SEQ_0,
/* 0x01 */ AUDIO_CALLBACK_SEQ_1,
+42 -38
View File
@@ -26,10 +26,10 @@ struct link_ {
/* sizeof(struct chnode_) == 0x40 */
struct chnode_ {
/* 0x00 */ link globalUse;
/* 0x10 */ link globalFree;
/* 0x20 */ link globalRelease;
/* 0x30 */ link globalReleaseWait;
/* 0x00 */ link freeList;
/* 0x10 */ link releaseList;
/* 0x20 */ link relwaitList;
/* 0x30 */ link useList;
};
/* forward declared */
@@ -301,9 +301,9 @@ typedef struct playbackch_ {
/* 0x06 */ s16 adsr_volume_scale_unused;
/* 0x08 */ f32 portamento_frequency_scale;
/* 0x0C */ f32 vibrato_frequency_scale;
/* 0x10 */ note* wanted_parent_note;
/* 0x10 */ note* previous_parent_note;
/* 0x14 */ note* current_parent_note;
/* 0x18 */ note* previous_parent_note;
/* 0x18 */ note* wanted_parent_note;
/* 0x1C */ playbackparams params;
/* 0x34 */ envp adsr_envp;
/* 0x54 */ sweep portamento_sweep;
@@ -434,14 +434,14 @@ typedef struct delay_ {
/* 0x2A0 */ adpcmloop adpcm_loop;
} delay;
/* sizeof(seqplayer) == 0x1C */
typedef struct seqplayer_ {
/* sizeof(macro) == 0x1C */
typedef struct macro_ {
/* 0x00 */ u8* pc;
/* 0x04 */ u8* stack[4];
/* 0x14 */ u8 remaining_loop_iters[4];
/* 0x18 */ u8 depth;
/* 0x19 */ s8 value;
} seqplayer;
} macro;
/* SubTrack struct */
/* sizeof(sub) == 0xE0 */
@@ -469,7 +469,7 @@ typedef struct sub_ {
/* 0x04 */ u8 target_reverb_vol;
/* 0x05 */ u8 note_priority;
/* 0x06 */ u8 priority2;
/* 0x07 */ u8 inst_id;
/* 0x07 */ u8 bank_id;
/* 0x08 */ u8 reverb_idx;
/* 0x09 */ u8 book_ofs;
/* 0x0A */ u8 new_pan;
@@ -479,12 +479,12 @@ typedef struct sub_ {
/* 0x0E */ u8 gate_time_random_variance;
/* 0x0F */ u8 comb_filter_size;
/* 0x10 */ u8 surround_effect_idx;
/* 0x11 */ u8 channel_idx;
/* 0x12 */ u16 _12;
/* 0x11 */ u8 subtrack_idx;
/* 0x12 */ u8 note_semitone;
/* 0x14 */ vibparam vibrato_params;
/* 0x22 */ u16 delay;
/* 0x24 */ u16 comb_filter_gain;
/* 0x26 */ u16 _26;
/* 0x26 */ u16 dynamic_value;
/* 0x28 */ s16 inst_or_wave;
/* 0x2A */ s16 transposition;
/* 0x2C */ f32 volume_scale;
@@ -498,7 +498,7 @@ typedef struct sub_ {
/* 0x4C */ voicetable* voicetable;
/* 0x50 */ group* group;
/* 0x54 */ struct note_* note_layers[4];
/* 0x64 */ seqplayer seq_player;
/* 0x64 */ macro macro_player;
/* 0x80 */ env adsr_env;
/* 0x88 */ chnode channel_node;
/* 0xC8 */ s8 port[8];
@@ -506,7 +506,8 @@ typedef struct sub_ {
/* 0xD4 */ s16* filter;
/* 0xD8 */ phase stereo_phase;
/* 0xDC */ s32 sample_start_pos;
/* 0xE0 */ u8 _unk[0x100 - 0x0E0];
/* 0xE0 */ s32 _E0;
/* 0xE4 */ u8 _unk[0x100 - 0x0E4];
} sub;
/* sizeof(group) == 0x160 */
@@ -526,7 +527,7 @@ struct group_ {
/* 0x002 */ u8 note_alloc_policy;
/* 0x003 */ u8 mute_flags;
/* 0x004 */ u8 seq_id;
/* 0x005 */ u8 default_bank;
/* 0x005 */ u8 bank_id;
/* 0x006 */ u8 unk006;
/* 0x007 */ s8 group_idx;
/* 0x008 */ u16 tempo;
@@ -546,7 +547,7 @@ struct group_ {
/* 0x030 */ f32 applied_fade_volume;
/* 0x034 */ f32 bend;
/* 0x038 */ sub* subtracks[AUDIO_SUBTRACK_NUM];
/* 0x078 */ seqplayer seq_player;
/* 0x078 */ macro macro_player;
/* 0x094 */ u8* short_note_velocity_tbl;
/* 0x098 */ u8* short_note_gate_time_tbl;
/* 0x09C */ chnode channel_node;
@@ -576,24 +577,27 @@ struct note_ {
/* 0x08 */ u8 surround_effect_idx;
/* 0x09 */ u8 target_reverb_volume;
struct {
/* 0x0A */ u16 bit0 : 1;
/* 0x0A */ u16 bit1 : 1;
/* 0x0A */ u16 bit2 : 1;
/* 0x0A */ u16 use_vibrato : 1;
/* 0x0A */ u16 bit4 : 1;
/* 0x0A */ u16 bit5 : 1;
/* 0x0A */ u16 bit6 : 1;
/* 0x0A */ u16 bit7 : 1;
/* 0x0B */ u16 bit8 : 1;
/* 0x0B */ u16 bit9 : 1;
/* 0x0B */ u16 bitA : 1;
/* 0x0B */ u16 bitB : 1;
/* 0x0B */ u16 bitC : 1;
/* 0x0B */ u16 bitD : 1;
/* 0x0B */ u16 bitE : 1;
/* 0x0B */ u16 bitF : 1;
};
union {
struct {
/* 0x0A */ u16 bit0 : 1;
/* 0x0A */ u16 bit1 : 1;
/* 0x0A */ u16 bit2 : 1;
/* 0x0A */ u16 use_vibrato : 1;
/* 0x0A */ u16 add_subtrack_transposition : 1;
/* 0x0A */ u16 bit5 : 1;
/* 0x0A */ u16 bit6 : 1;
/* 0x0A */ u16 bit7 : 1;
/* 0x0B */ u16 bit8 : 1;
/* 0x0B */ u16 bit9 : 1;
/* 0x0B */ u16 bitA : 1;
/* 0x0B */ u16 bitB : 1;
/* 0x0B */ u16 bitC : 1;
/* 0x0B */ u16 bitD : 1;
/* 0x0B */ u16 bitE : 1;
/* 0x0B */ u16 bitF : 1;
} flags;
/* 0x0A */ u16 asU16;
} _0A;
/* 0x0C */ vibparam vibrato_params;
/* 0x1A */ s16 delay;
@@ -615,7 +619,7 @@ struct note_ {
/* 0x58 */ voicetable* instrument;
/* 0x5C */ wtstr* tuned_sample;
/* 0x60 */ sub* sub_track;
/* 0x64 */ seqplayer seq_player;
/* 0x64 */ macro macro_player;
/* 0x80 */ link link;
};
@@ -883,10 +887,10 @@ typedef struct AudioGlobals {
/* 0x3780 */ size_t audio_heap_size;
/* 0x3784 */ channel* channels;
/* 0x3788 */ struct group_ groups[AUDIO_GROUP_MAX];
/* 0x3E68 */ note notes[128];
/* 0x3E68 */ note notes[AUDIO_NOTE_MAX];
/* 0x8668 */ sub null_sub_track; /* used for 'null' sub tracks */
/* 0x8748 */ group* groups_p[AUDIO_GROUP_MAX];
/* 0x877C */ s32 _877C;
/* 0x877C */ s32 sample_state_offset;
/* 0x8780 */ link note_link;
/* 0x8790 */ chnode channel_node; /* main chnode */
/* 0x87D0 */ struct group_ main_group;
+7
View File
@@ -2,8 +2,15 @@
#define AUDIOTABLE_H
#include "types.h"
#include "jaudio_NES/audiostruct.h"
extern f32 PCENTTABLE[];
extern f32 PCENTTABLE2[];
extern envdat DEFAULT_ENV[];
extern f32 PITCHTABLE[];
extern u8 DEFAULT_VTABLE[];
extern u8 DEFAULT_GTABLE[];
extern u8 BDB_SEQDATA[];
#endif
+2 -2
View File
@@ -11,13 +11,13 @@ extern "C" {
#endif
typedef void (*VFRAME_CALLBACK)(void);
typedef u32 (*GRP_CALLBACK)(s8, sub*);
typedef u32 (*GRP_CALLBACK)(s8, group*);
typedef void* (*SOUND_CALLBACK)(smzwavetable*, s32, s8, s32);
typedef Acmd* (*DACOUT_CALLBACK)(Acmd*, s32, s32);
extern AudioGlobals AG;
extern VFRAME_CALLBACK NA_VFRAME_CALLBACK;
// extern ??? NA_CALLBACK;
extern SequenceCallback NA_CALLBACK;
extern GRP_CALLBACK NA_GRP_CALLBACK;
extern SOUND_CALLBACK NA_SOUND_CALLBACK;
extern DACOUT_CALLBACK NA_DACOUT_CALLBACK;
+15
View File
@@ -2,7 +2,22 @@
#define CHANNEL_H
#include "types.h"
#include "jaudio_NES/audiowork.h"
extern s32 OverwriteBank(s32 type, s32 bankId, s32 idx, s32 voicetable);
extern channel* Nas_AllocationOnRequest(note* n);
extern wtstr* NoteToVoice(voicetable* voicetbl, s32 note);
extern voicetable* ProgToVp(s32 prog, s32 note);
extern percvoicetable* PercToPp(s32 perc, s32 note);
extern veffvoicetable* VpercToVep(s32 vperc, s32 note);
extern void Nas_UpdateChannel(void);
extern void Nas_DeAllocAllVoices(chnode* node);
extern void Nas_AllocVoices(chnode* node, s32 num);
extern void Nas_InitChNode(chnode* node);
extern void Nas_Release_Channel(note* n);
extern void Nas_Release_Channel_Force(note* n);
#endif
+12
View File
@@ -0,0 +1,12 @@
#ifndef EFFECT_H
#define EFFECT_H
#include "types.h"
#include "jaudio_NES/audiowork.h"
extern void Nas_ChannelModInit(channel* ch);
extern void Nas_SweepInit(channel* ch);
extern void Nas_MainCtrl(group* grp);
#endif
+3
View File
@@ -6,6 +6,9 @@
extern void Nas_HeapInit(ALHeap* heap, u8* base, s32 len);
extern void* Nas_HeapAlloc(ALHeap* heap, s32 size);
extern void* Nas_HeapAlloc_CL(ALHeap*, s32 size);
extern u32 Nas_SzCacheCheck(s32 type, s32 cache_type, s32 id);
extern void Nas_SzStayDelete(s32 type);
extern void Nas_SetDelayLineParam(s32 delayIdx, s32 param_type, s32 param_value, s32 init);
+10
View File
@@ -32,6 +32,16 @@ extern void Nas_WaveDmaFrameWork(void);
extern void Nas_BgDmaFrameWork(s32 reset_status);
extern void MK_FrameWork(void);
extern BOOL Nas_CheckIDseq(s32 id);
extern BOOL Nas_CheckIDbank(s32 id);
extern void Nas_WriteIDseq(s32 id, s32 type);
extern void Nas_WriteIDbank(s32 id, s32 type);
extern s32 VoiceLoad(s32 bank_id, u32 inst_id, s8* done_p);
extern s32 SeqLoad(s32 seq_id, u8* ram_addr, s8* done_p);
extern void MK_load(s32 type, s32 id, u8* done_p);
extern BOOL AUDIO_SYSTEM_READY;
#endif
+11 -2
View File
@@ -4,7 +4,16 @@
#include "types.h"
#include "jaudio_NES/audiowork.h"
extern void Nas_SeqSkip(group* group);
extern void Nas_ReleaseGroup_Force(group* group);
extern void Nas_ReleaseNoteTrack(note* note);
extern void Nas_ReleaseSubTrack(sub* subtrack);
extern void Nas_ReleaseGroup_Force(group* grp);
extern void Nas_ReleaseGroup(group* grp);
extern void Nas_AddList(link* root, link* list);
extern void* Nas_GetList(link* root);
extern void Nas_MySeqMain(u32 frames_left);
extern void Nas_SeqSkip(group* grp);
extern void Nas_InitMySeq(group* grp);
extern void Nas_AssignSubTrack(s32 group_idx);
extern void Nas_InitPlayer(void);
#endif
File diff suppressed because it is too large Load Diff