jaudio_NES: building from pik1

This commit is contained in:
Cuyler36
2025-06-21 04:26:24 -04:00
parent d5498f9b52
commit 46c688ea10
64 changed files with 12460 additions and 267 deletions
@@ -2,7 +2,7 @@
#define _METROTRK_TRKTYPES_H
#include "types.h"
#include "Dolphin/OS/OSInterrupt.h"
#include "dolphin/os/OSInterrupt.h"
#include "PowerPC_EABI_Support/MetroTRK/trkenum.h"
#ifdef __cplusplus
@@ -0,0 +1,33 @@
#include "MSL_C/w_math.h"
// #include "MSL_C/MSL_Common/float.h"
#define HALF_PI 1.5707964f
#ifdef __cplusplus
namespace std {
#endif
float sqrtf(float);
float sinf(float);
#ifdef __cplusplus
}
#endif
// TODO: this should be obtained from the other math header
// inline float sqrtf(float x) {
// static const double _half = .5;
// static const double _three = 3.0;
// volatile float y;
// if (x > 0.0f) {
// double guess = __frsqrte((double)x); // returns an approximation to
// guess = _half * guess * (_three - guess * guess * x); // now have 12 sig bits
// guess = _half * guess * (_three - guess * guess * x); // now have 24 sig bits
// guess = _half * guess * (_three - guess * guess * x); // now have 32 sig bits
// y = (float)(x * guess);
// return y;
// }
// return x;
// }
+36 -20
View File
@@ -1,36 +1,52 @@
#ifndef AICTRL_H
#define AICTRL_H
#ifndef _JAUDIO_AICTRL_H
#define _JAUDIO_AICTRL_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
#endif // ifdef __cplusplus
extern u32 UNIVERSAL_DACCOUNTER;
extern u32 JAC_VFRAME_COUNTER;
/////////// JAUDIO AI CONTROL DEFINITIONS ///////////
// Callbacks.
typedef s16* (*MixCallback)(s32);
typedef void (*DACCallback)(s16*, s32);
// Enums.
/**
* @brief TODO
*/
typedef enum _MixMode {
MixMode_Mono,
MixMode_MonoWide,
MixMode_Extra,
MixMode_Interleave,
MixMode_Num
MixMode_Mono = 0,
MixMode_MonoWide = 1,
MixMode_Extra = 2,
MixMode_Interleave = 3,
MixMode_Num, // 4
} MixMode;
typedef s16* (*MixCallback)(s32);
// Global counters.
extern u32 UNIVERSAL_DACCOUNTER;
extern u32 JAC_VFRAME_COUNTER;
extern u32 JAC_SYSTEM_OUTPUT_MODE;
extern void Jac_HeapSetup(void* pHeap, s32 size);
extern void* OSAlloc2(u32 size);
extern void Jac_Init(void);
/////////////////////////////////////////////////////
//////////// JAUDIO AI CONTROL FUNCTIONS ////////////
void Jac_HeapSetup(void* heap, s32 size);
void* OSAlloc2(u32 size);
void Jac_Init();
void Jac_VframeWork();
void Jac_UpdateDAC();
void Jac_SetOutputMode(int mode);
int Jac_GetOutputMode();
void Jac_SetMixerLevel(f32, f32);
void Jac_RegisterMixcallback(MixCallback mixcallback, u8 mixmode);
extern MixCallback Jac_GetMixcallback(u8* mixmode);
extern void Jac_RegisterMixcallback(MixCallback mixcallback, u8 mixmode);
extern void Jac_VframeWork(void);
extern void Jac_UpdateDAC(void);
/////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
};
#endif // ifdef __cplusplus
#endif
+19 -8
View File
@@ -1,11 +1,22 @@
#ifndef ARAMCALL_H
#define ARAMCALL_H
#include "types.h"
#include "jaudio_NES/heapctrl.h"
#ifndef _JAUDIO_ARAMCALL_H
#define _JAUDIO_ARAMCALL_H
void Jac_WaveDirectorySet(char*);
void Jac_RegisterARAMCallback(u32 (*callback)(char*, u32, u32, u32*, JAHEAP*));
void Init_AramMotherHeap();
JAHEAP* Get_AramMotherHeap();
#include "types.h"
typedef struct jaheap_ jaheap_;
typedef u32 (*ARAMCallback)(char* filename, u32 src, u32 length, u32* status, jaheap_* heap);
void Jac_RegisterARAMCallback(ARAMCallback callback);
u32 LoadAram(char* filepath, u32* status, u32 dst);
u32 LoadAramSingle(char* filepath, u32 src, u32 length, u32* status, u32 dst);
void Jac_WaveDirectorySet(char* directory);
jaheap_* Get_AramMotherHeap(void);
void Show_AramMotherHeap(void);
void Collect_AramMotherHeap(void);
void Init_AramMotherHeap(void);
u32 LoadAram_Default(char* filename, u32 src, u32 length, u32* status, jaheap_* heap);
u32 LoadAram_All(char* filename, u32* status, jaheap_* heap);
u32 LoadAram_One(char* filename, u32 src, u32 length, u32* status, jaheap_* heap);
#endif
+188 -30
View File
@@ -5,6 +5,7 @@
#include "jaudio_NES/audiocommon.h"
#include "PR/abi.h"
#include "libultra/libultra.h"
#include "jaudio_NES/bx.h"
#ifdef __cplusplus
extern "C" {
@@ -922,41 +923,198 @@ typedef struct AudioGlobals {
/* 0x92AC */ s32 _92AC;
} AudioGlobals;
typedef union SOUNDID_ {
struct {
u8 wave_id;
u8 inst_id;
u8 _02;
u8 _03;
};
// typedef union SOUNDID_ {
// struct {
// u8 wave_id;
// u8 inst_id;
// u8 _02;
// u8 _03;
// };
u32 uint32;
} SOUNDID;
// u32 uint32;
// } SOUNDID;
typedef s32 (*PlayerCallBack)(void*);
// typedef s32 (*PlayerCallBack)(void*);
typedef struct PLAYER_CALL_ {
PlayerCallBack callback;
void* arg;
u32 DSP_mode;
} PLAYER_CALL;
// typedef struct PLAYER_CALL_ {
// PlayerCallBack callback;
// void* arg;
// u32 DSP_mode;
// } PLAYER_CALL;
typedef struct Bank_ {
u32 magic; // 'BANK'
u8* part0[128];
u8* part1[100];
u8* part2[12];
// more?
} Bank;
// typedef struct Bank_ {
// u32 magic; // 'BANK'
// u8* part0[128];
// u8* part1[100];
// u8* part2[12];
// // more?
// } Bank;
typedef struct InstBank_ {
u32 magic; // 'IBNK'
u32 _04;
u32 vid;
u8 pad[32 - 3 * sizeof(u32)];
Bank bank;
// more
} InstBank;
// typedef struct InstBank_ {
// u32 magic; // 'IBNK'
// u32 _04;
// u32 vid;
// u8 pad[32 - 3 * sizeof(u32)];
// Bank bank;
// // more
// } InstBank;
typedef union SOUNDID_ SOUNDID;
typedef struct PLAYER_CALL_ PLAYER_CALL;
typedef struct Bank_ Bank;
typedef struct Ibnk_ InstBank;
// C++ JAudio1
typedef enum JCSTATUS {
JCSTAT_Unk0 = 0,
JCSTAT_Unk1 = 1,
JCSTAT_Unk2 = 2,
JCSTAT_Unk6 = 6,
} JCSTATUS;
typedef struct dspch_ dspch_; // TODO: Figure out why there is another struct named `DSPChannel_` in syncstream.c.
typedef struct Jac_MessageQueue Jac_MessageQueue;
typedef struct JCMgr JCMgr;
typedef struct jc_ jc_;
typedef struct jcs_ jcs_;
typedef struct Wave_ Wave_;
typedef BOOL (*DSPChannelCallback)(dspch_*, u32);
/**
* @brief TODO.
*/
struct dspch_ {
u8 buffer_idx; // _00
u8 _01; // _01
u8 _02; // _02
u8 _03; // _03
u16 _04; // _04
u16 _06; // _06
jc_* _08; // _08
DSPChannelCallback _0C; // _0C
// DSPchannel_* _0C; // TODO: SMS says this exists, Pikmin 1 disagrees.
};
typedef struct PanMatrix_ {
f32 values[3];
} PanMatrix_;
/**
* @brief TODO
*
* @note Size: 0x74.
*/
struct jcs_ {
u32 chanCount; // _00, Number of channels in this system
u32 chanAllocCount; // _04, Total channel allocation counter
jc_* freeChannels; // _08, Linked list of free channels
jc_* activeChannels; // _0C, Linked list of active channels
jc_* releasingChannels; // _10, Linked list of releasing channels
jc_* waitingChannels; // _14, Linked list of channels waiting for DSP
f32 volume; // _18, Master volume (default 1.0)
f32 pitch; // _1C, Master pitch/cent adjustment (default 1.0)
f32 pan; // _20, Master pan position (default 0.5)
f32 fxmix; // _24, Effects mix level (default 0.0)
f32 dolby; // _28, Dolby surround level (default 0.0)
s16 firCoefficients[8]; // _2C, FIR filter coefficients (8 taps)
s16 iirCoefficients[4]; // _3C, IIR filter coefficients
char _44[8]; // _44
s16 distFilter; // _4C, Distance filter parameter (default 0)
u16 busConnect[6]; // _4E, Bus routing configuration for 6 outputs
u8 masterLevels[6]; // _5A
u8 maxDelay; // _60, Maximum delay setting (default 0)
u8 filterMode; // _61, Filter enable flags (bit 5=IIR, bits 0-4=FIR taps)
u8 panCalcTypes[3]; // _62, Pan calculation types (default [26,1,1])
u32 channelPriority; // _68
u16 releaseTime; // _6C, Release/fade time in samples (default 600)
int voiceStealingMode; // _70, Voice stealing enabled (0=off, 1=on)
};
// needed to match UpdateEffecterParam
typedef union MixConfig {
u16 whole;
struct {
u8 upper;
u8 lower0 : 4;
u8 lower1 : 4;
} parts;
} MixConfig;
typedef BOOL (*JCUpdateCallback)(jc_*, JCSTATUS);
/**
* @brief TODO.
*/
struct jc_ {
u8 velocity; // _00
u8 note; // _01
u8 pauseFlag; // _02
u8 toFlush; // _03
jcs_* mMgr; // _04
void** chanListHead; // _08
u8 logicalChanType; // _0C, 0 = Wave, 1 = ??, 2 = Oscillator
Wave_* waveData; // _10
u32 _14; // _14
u32 _18; // _18
u32 _1C; // _1C
dspch_* dspChannel; // _20
void* mNext; // _24
JCUpdateCallback updateCallback; // _28
JCUpdateCallback pitchSweepUpdater; // _2C
s32 playId; // _30
s32 savedPlayId; // _34
struct Osc_* mOscillators[4]; // _38
struct Oscbuf_ mOscBuffers[2]; // _48
f32 _78; // _78
char _7C[8]; // _7C
f32 _84; // _84
char _88[4]; // _88
f32 _8C; // _8C
f32 _90; // _90
f32 _94; // _94
u16 _98; // _98
u16 _9A; // _9A
void* _9C; // _9C
char _A0[8]; // _A0
f32 basePitch; // _A8
f32 baseVolume; // _AC
f32 currentPitch; // _B0
f32 currentVolume; // _B4
u8 panCalcTypes[3]; // _B8
PanMatrix_ panMatrices[4]; // _BC, 0 = Power distribution, 1 = Pan, 2 = Effects send (fxmix), 3 = Dolby surround
f32 pitchModifier; // _EC
f32 volumeModifier; // _F0
f32 targetPitch; // _F4
u16 finalPitch; // _F8
u16 pitchSweepSteps; // _FA
jcs_* lastManager; // _FC
f32 managerPitch; // _100
f32 managerVolume; // _104
MixConfig busRouting[6]; // _108
u16 mixerLevels[6]; // _114
u32 channelPriority; // _120
u16 releaseTime; // _124
u16 channelId; // _126
int soundId; // _128
u8 polyphonyCounter; // _12C
char _12D[3]; // _12D
int _130; // _130
int _134; // _134
int _138; // _138
int _13C; // _13C
};
typedef struct Wavelookuptable_ {
// TODO
} Wavelookuptable;
typedef struct fxconfig {
// TODO: members
} fxconfig_;
#ifdef __cplusplus
}
+27
View File
@@ -0,0 +1,27 @@
#ifndef _JAUDIO_BANKDRV_H
#define _JAUDIO_BANKDRV_H
#include "types.h"
typedef struct Bank_ Bank_;
typedef struct Inst_ Inst_;
typedef struct Perc_ Perc_;
typedef struct Voice_ Voice_;
typedef struct Sense_ Sense_;
typedef struct Rand_ Rand_;
typedef struct Osc_ Osc_;
typedef struct Oscbuf_ Oscbuf_;
typedef struct Vmap_ Vmap_;
Inst_* Bank_InstChange(Bank_*, u32);
Voice_* Bank_VoiceChange(Bank_*, u32);
Perc_* Bank_PercChange(Bank_*, u32);
int Bank_GetInstKeymap(Inst_*, u8);
int Bank_GetInstVmap(Inst_*, u8, u8);
Vmap_* Bank_GetPercVmap(Perc_*, u8, u8);
int Bank_GetVoiceMap(Voice_*, u16);
f32 Bank_SenseToOfs(Sense_*, u8);
f32 Bank_RandToOfs(Rand_* rand);
f32 Bank_OscToOfs(Osc_*, Oscbuf_*);
#endif
+10 -15
View File
@@ -1,19 +1,14 @@
#ifndef BANKREAD_H
#define BANKREAD_H
#ifndef _JAUDIO_BANKREAD_H
#define _JAUDIO_BANKREAD_H
#include "types.h"
#include "audiostruct.h"
#ifdef __cplusplus
extern "C" {
typedef struct Bank_ Bank_;
Bank_* Bank_Test(u8*);
BOOL Bank_Regist(void*, u32);
BOOL Bank_Regist_Direct(void*, u32, u32);
void Bank_Init();
Bank_* Bank_Get(u32);
#endif
BOOL Bank_Regist(void* bank, u32 pid);
void Bank_Init(void);
Bank* Bank_Get(u32 pid);
#ifdef __cplusplus
}
#endif
#endif /* BANKREAD_H */
+254
View File
@@ -0,0 +1,254 @@
#ifndef _JAUDIO_BX_H
#define _JAUDIO_BX_H
// This is an invented header containing several structs related to the file structure of pikibank.bx
#include "types.h"
#include "jaudio_NES/heapctrl.h"
#define BANK_INST_COUNT (0xF0)
#define BANK_TEST_INST_COUNT (0x80)
#define BANK_TEST_VOICE_OFFSET (BANK_TEST_INST_COUNT)
#define BANK_TEST_VOICE_COUNT (0x64)
#define BANK_TEST_PERC_OFFSET (BANK_TEST_INST_COUNT + BANK_TEST_VOICE_COUNT)
#define BANK_TEST_PERC_COUNT (0x0C)
typedef struct Bank_ Bank_;
typedef struct Ibnk_ Ibnk_;
typedef struct Inst_ Inst_;
typedef struct Perc_ Perc_;
typedef struct Voice_ Voice_;
typedef struct Sense_ Sense_;
typedef struct Rand_ Rand_;
typedef struct Osc_ Osc_;
typedef struct Oscbuf_ Oscbuf_;
typedef struct Vmap_ Vmap_;
typedef struct InstKeymap_ InstKeymap_;
typedef struct PercKeymap_ PercKeymap_;
// these type names are confirmed:
typedef struct WaveArchiveBank_ WaveArchiveBank_;
typedef struct CtrlGroup_ CtrlGroup_;
typedef struct Ctrl_ Ctrl_;
typedef struct WaveArchive_ WaveArchive_;
typedef struct Wave_ Wave_;
// these type names are fabricated, feel free to rename if found:
typedef struct Wsys_ Wsys_;
typedef struct SCNE_ SCNE_;
typedef struct WaveID_ WaveID_;
//////////////////////////////////////////////////////////
////////////////////// BANK STRUCTS //////////////////////
struct Bank_ {
int mMagic; // _00 | 'BANK'
union { // _04 | Can point to INST, VOICE, PERC.
// There's no way this was actually an anonymous union, as this only became a feature
// of the C programming language in C11. However, it does make the code nicer to read.
Inst_* mInstruments[BANK_INST_COUNT];
Voice_* mVoices[BANK_INST_COUNT];
Perc_* mPercs[BANK_INST_COUNT];
};
};
struct Ibnk_ {
int magic; // _00 | 'IBNK'
u32 _04; // _04
u32 _08; // _08
int _0C; // _0C
struct WaveArchiveBank_* waveArcBank; // _10
u8 _14[0x20 - 0x14]; // _14
Bank_ bank; // _20
};
/**
* @brief This is an invented type of an unknown name.
*
* @note Size: 0x10.
*/
struct Vmap_ {
u8 mBaseVelocity; // _00
s16 mWsysID; // _04
s16 mWaveID; // _06
f32 mVolume; // _08
f32 mPitch; // _0C
};
/**
* @brief This is an invented type of an unknown name.
*
* @note Size: 0x10.
*/
struct InstKeymap_ {
u8 mBaseKey; // _00
u32 mVelocityCount; // _04
Vmap_* mVelocities[2]; // _08
};
/**
* @brief This is an invented type of an unknown name.
*
* @note Size: 0x18.
*/
struct PercKeymap_ {
f32 mPitch; // _00
f32 mVolume; // _04
void* _08; // _08, pointer type unknown, but gets hit by PTconvert in Bank_Test
void* _0C; // _0C, pointer type unknown, but gets hit by PTconvert in Bank_Test
int mVelocityCount; // _10
Vmap_* mVelocities[2]; // _14
};
struct Sense_ {
u8 id; // _00
u8 type; // _01
u8 threshold; // _02
f32 min; // _04
f32 max; // _08
};
struct Osc_ {
u8 mode; // _00
f32 rate; // _04
s16* attackVecOffset; // _08
s16* releaseVecOffset; // _0C
f32 width; // _10
f32 vertex; // _14
};
/**
* @note Size: 0x18.
*/
struct Oscbuf_ {
u8 state; // _00
u8 curveType; // _01
u16 tableIndex; // _02
f32 timeCounter; // _04
f32 value; // _08
f32 targetValue; // _0C
f32 deltaRate; // _10
u16 releaseParam; // _14
};
/**
* @note Size: 0x40.
*/
struct Inst_ {
int mMagic; // _00 | 'INST'
u32 mFlag; // _04
f32 mFreqMultiplier; // _08
f32 mGainMultiplier; // _0C
Osc_* mOscillators[2]; // _10
Rand_* mEffects[2]; // _18
Sense_* mSensors[2]; // _20
int mKeyRegionCount; // _28
InstKeymap_* mKeyRegions[5]; // _2C
};
struct Voice_ {
u8 _00[0x8]; // _00, unknown
int size; // _08, count of whatever's at 0xC
void* _0C[1]; // _0C, unsure of length of array or type
};
struct Perc_ {
int mMagic; // _00 | 'PER2' (or 'PERC'?)
u8 _04[0x84]; // _04, unknown
PercKeymap_* mKeyRegions[128]; // _88
s8 _288[128]; // _288
u16 _308[128]; // _308
};
struct Rand_ {
u8 id; // _00
f32 value; // _04
f32 range; // _08
u8 _0C[0x10 - 0x0C]; // _0C
};
struct Pmap_ {
Rand_* _00; // _00
int _04; // _04
};
//////////////////////////////////////////////////////////
////////////////////// WAVE STRUCTS //////////////////////
// Name fabricated, but makes sense in line with Ibnk_
struct Wsys_ {
int magic; // _00, 'WSYS'
int size; // _04
int globalID; // _08
int _0C; // _0C, unused?
WaveArchiveBank_* waveArcBank; // _10
CtrlGroup_* ctrlGroup; // _14
};
struct WaveArchiveBank_ {
int magic; // _00, 'WINF'
int count; // _04, same count as CtrlGroup_
WaveArchive_* waveGroups[1]; // _08, array size variable
};
struct CtrlGroup_ {
int magic; // _00, 'WBCT'
u32 _04; // _04, unknown
int count; // _08, same count as WaveArchiveBank_
SCNE_* scenes[1]; // _0C, array size variable
};
// Name fabricated based on magic ID.
struct SCNE_ {
int magic; // _00, 'SCNE'
u32 _04; // _04
u32 _08; // _08
Ctrl_* cdf; // _0C
Ctrl_* cex; // _10
Ctrl_* cst; // _14
int _18[1]; // _18, variable size?
};
struct Ctrl_ {
int magic; // _00, 'C-DF', 'C-EX' or 'C-ST'
int count; // _04
WaveID_* waveIDs[1]; // _08, array size variable
};
// Name fabricated from Xayr's tools.
struct WaveID_ {
u32 id; // _00, split into sound id and ws id
jaheap_ heap; // _04
u32 loadStatus; // _30
Wave_* data; // _34
};
struct WaveArchive_ {
char filePath[0x40]; // _00, might be smaller, unsure
jaheap_ heap; // _40
u32 fileLoadStatus; // _6C
int waveCount; // _70
Wave_* waves[1]; // _74, array size variable
};
/**
* @brief File data, size unknown
*/
struct Wave_ {
u8 _00; // _00
u8 compBlockIdx; // _01
u8 key; // _02
f32 _04; // _04
int srcAddress; // _08
int length; // _0C
s32 isLooping; // _10
s32 loopAddress; // _14
s32 loopStartPosition; // _18
s32 _1C; // _1C
s16 loopYN1; // _20
s16 loopYN2; // _22
u32* fileLoadStatus; // _24, set to dolphin/dvd.h 'DVD_RESULT_*' defines
};
#endif
+16
View File
@@ -0,0 +1,16 @@
#ifndef _JAUDIO_CENTCALC_H
#define _JAUDIO_CENTCALC_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
f32 Jam_PitchToCent(f32, f32);
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif
+26 -5
View File
@@ -1,15 +1,36 @@
#ifndef CMDSTACK_H
#define CMDSTACK_H
#ifndef _JAUDIO_CMDSTACK_H
#define _JAUDIO_CMDSTACK_H
#include "types.h"
typedef struct JPorthead_ {
u32 _00; // _00
u32 _04; // _04
} JPorthead_;
#ifdef __cplusplus
extern "C" {
#endif
#endif // ifdef __cplusplus
void Add_PortcmdOnce(u32*);
void Add_PortcmdStay(void); // UNUSED but we know it's extern "C"
int Set_Portcmd(int*, int, int);
BOOL Add_Portcmd(JPorthead_*, u32*);
void Cancel_Portcmd(void); // UNUSED but we know it's extern "C"
void Cancel_PortcmdStay(void); // UNUSED but we know it's extern "C"
int Jac_Portcmd_Proc_Once(JPorthead_*);
int Jac_Portcmd_Proc_Stay(JPorthead_*);
void Jac_Porthead_Init(JPorthead_*);
void Jac_Portcmd_Init(void);
void JP_Pitch1Shot(void); // UNUSED but we know it's extern "C"
void JP_Start1Shot(void); // UNUSED but we know it's extern "C"
void JP_Stop1Shot(void); // UNUSED but we know it's extern "C"
#ifdef __cplusplus
}
#endif
#endif // ifdef __cplusplus
#endif
static int Get_Portcmd(JPorthead_* port);
static s32 Portcmd_Main(void* a);
#endif
+16 -2
View File
@@ -3,7 +3,21 @@
#include "types.h"
void Jac_ConnectTableInit(void);
void Jac_BnkConnectTableSet(u32 vid, u32 pid);
typedef struct WaveArchive_ WaveArchive_;
typedef struct WaveArchiveBank_ WaveArchiveBank_;
typedef struct Ctrl_ Ctrl_;
typedef struct CtrlGroup_ CtrlGroup_;
void Jac_SceneClose(WaveArchiveBank_*, CtrlGroup_*, u32, BOOL);
BOOL Jac_SceneSet(WaveArchiveBank_*, CtrlGroup_*, u32, BOOL);
struct WaveID_* GetSoundHandle(CtrlGroup_*, u32);
u16 Jac_WsVirtualToPhysical(u16);
u16 Jac_BnkVirtualToPhysical(u16);
u16 Jac_BnkPhysicalToVirtual(u16);
u16 Jac_WsPhysicalToVirtual(u16);
void Jac_WsConnectTableSet(u32, u32);
void Jac_BnkConnectTableSet(u32, u32);
void Jac_ConnectTableInit();
struct WaveID_* __GetSoundHandle(CtrlGroup_*, u32, u32);
#endif
+10 -7
View File
@@ -1,12 +1,15 @@
#ifndef CPUBUF_H
#define CPUBUF_H
#ifndef _JAUDIO_CPUBUF_H
#define _JAUDIO_CPUBUF_H
#include "types.h"
#include "jaudio_NES/rate.h"
#include "jaudio_NES/audiocommon.h"
#include "jaudio_NES/dspbuf.h"
extern s16* CpubufProcess(DSPBUF_EVENTS event);
extern void CpuFrameEnd(void);
extern s16* MixCpu(s32 nSamples);
/////////// JAUDIO CPU BUFFER DEFINITIONS ///////////
// Global functions (all C++, so no extern C wrap).
s16* CpubufProcess(DSPBUF_EVENTS event);
void CpuFrameEnd();
s16* MixCpu(s32 n_samples);
/////////////////////////////////////////////////////
#endif
+38
View File
@@ -0,0 +1,38 @@
#ifndef _JAUDIO_DRIVERINTERFACE_H
#define _JAUDIO_DRIVERINTERFACE_H
#include "types.h"
#include "jaudio_NES/audiostruct.h"
/////////// JAUDIO DRIVER INTERFACE DEFINITIONS ///////////
// Global functions (all C++, so no extern C wrap).
void Channel_SetMixerLevel(f32);
jcs_* Get_GlobalHandle();
int List_CountChannel(jc_**);
int List_CutChannel(jc_*);
jc_* List_GetChannel(jc_**);
void List_AddChannelTail(jc_**, jc_*);
void List_AddChannel(jc_**, jc_*);
int FixAllocChannel(jcs_*, u32);
int FixReleaseChannel(jc_*);
int FixReleaseChannelAll(jcs_*);
int FixMoveChannelAll(jcs_*, jcs_*);
void InitJcs(jcs_*);
void Channel_Init(jc_*);
void InitGlobalChannel();
void UpdateJcToDSP(jc_*);
void UpdateEffecterParam(jc_*);
void DoEffectOsc(jc_*, u8, f32);
BOOL StopLogicalChannel(jc_*);
BOOL CheckLogicalChannel(jc_*);
BOOL PlayLogicalChannel(jc_*);
BOOL ResetInitialVolume(jc_*);
BOOL Add_WaitDSPChannel(jc_*);
BOOL Del_WaitDSPChannel(jc_*);
void __Entry_WaitChannel(u8);
void EntryCheck_WaitDSPChannel();
BOOL ForceStopLogicalChannel(jc_*);
///////////////////////////////////////////////////////////
#endif
+16
View File
@@ -0,0 +1,16 @@
#ifndef _JAUDIO_DSP_CARDUNLOCK_H
#define _JAUDIO_DSP_CARDUNLOCK_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
int __CARDUnlock(int chan, u8 flashID[12]);
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif
+18 -3
View File
@@ -1,8 +1,23 @@
#ifndef DSPDRIVER_H
#define DSPDRIVER_H
#ifndef _JAUDIO_DSPDRIVER_H
#define _JAUDIO_DSPDRIVER_H
#include "types.h"
#include "jaudio_NES/audiostruct.h"
extern void UpdateDSPchannelAll(void);
/////////// JAUDIO DSP DRIVER DEFINITIONS ///////////
// Global functions (all C++, so no extern C wrap).
dspch_* GetDSPchannelHandle(u32 idx);
void InitDSPchannel();
dspch_* AllocDSPchannel(u32, u32);
int DeAllocDSPchannel(dspch_*, u32);
dspch_* GetLowerDSPchannel();
dspch_* GetLowerActiveDSPchannel();
BOOL ForceStopDSPchannel(dspch_*);
BOOL BreakLowerDSPchannel(u8);
BOOL BreakLowerActiveDSPchannel(u8);
void UpdateDSPchannelAll();
/////////////////////////////////////////////////////
#endif
+130 -4
View File
@@ -1,9 +1,135 @@
#ifndef DSPINTERFACE_H
#define DSPINTERFACE_H
#ifndef _JAUDIO_DSPINTERFACE_H
#define _JAUDIO_DSPINTERFACE_H
#include "types.h"
#include "jaudio_NES/audiostruct.h"
extern void DSP_InitBuffer(void);
extern void DSP_InvalChannelAll(void);
typedef struct DSPMixerChannel DSPMixerChannel;
typedef struct DSPchannel_ DSPchannel_;
typedef struct FXDestination FXDestination;
typedef struct FXBuffer FXBuffer;
// A lot of u16s in these DSP structs act like BOOL, so lets codify it.
typedef u16 DSPBOOL;
#define DSP_TRUE ((DSPBOOL)1)
#define DSP_FALSE ((DSPBOOL)0)
/////////// JAUDIO DSP INTERFACE DEFINITIONS ///////////
// Global functions (all C++, so no extern C wrap).
DSPchannel_* GetDspHandle(u8 idx);
FXBuffer* GetFxHandle(u8 idx);
void DSP_SetPitch(u8 idx, u16 pitch);
void DSP_SetMixerInitDelayMax(u8 idx, u8 initDelayMax);
void DSP_SetMixerInitVolume(u8 idx, u8 mixer, s16 volume, u8 param_4);
void DSP_SetMixerVolume(u8 idx, u8 mixer, s16 volume, u8 param_4);
void DSP_SetOscInfo(u8 idx, u32 samplesSourceType);
void DSP_SetPauseFlag(u8 idx, u8 pauseFlag);
void DSP_SetWaveInfo(u8 idx, Wave_* wave, u32 baseAddress);
void DSP_SetBusConnect(u8 idx, u8 mixer, u8 busConnect);
void DSP_PlayStop(u8 idx);
void DSP_AllocInit(u8 idx);
void DSP_PlayStart(u8 idx);
void DSP_SetDistFilter(u8 idx, s16 distFilter);
void DSP_SetFilterTable(s16* dst, s16* src, u32 len);
void DSP_SetIIRFilterParam(u8 idx, s16* param_2);
void DSP_SetFIR8FilterParam(u8 idx, s16* param_2);
void DSP_SetFilterMode(u8 idx, u16 filterMode);
void DSP_InitFilter(u8 idx);
void DSP_FlushBuffer();
void DSP_FlushChannel(u8 idx);
void DSP_InvalChannelAll();
void DSP_ClearBuffer();
void DSP_SetupBuffer();
void DSP_InitBuffer();
///////////////////////////////////////////////////////////////////////////////
// Based on `ZeldaAudioRenderer::VPB` from Dolphin Emulator. Thank you all!
/**
* @brief TODO.
*/
struct DSPMixerChannel {
u16 id; // _00
u16 targetVolume; // _02
u16 currentVolume; // _04
u16 level; // _06
};
/**
* @brief TODO.
*/
struct DSPchannel_ {
DSPBOOL enabled; // _00 - DSP_AllocInit, DSP_PlayStop, DSP_PlayStart
DSPBOOL done; // _02 - DSP_AllocInit
u16 resamplingRatio; // _04 - DSP_SetPitch
u16 _06; // _06
DSPBOOL resetVpb; // _08 - DSP_PlayStart
DSPBOOL endReached; // _0A
DSPBOOL useConstantSample; // _0C - DSP_SetPauseFlag
u16 samplesToKeepCount; // _0E - DSP_SetMixerInitDelayMax
DSPMixerChannel mixChannels[6]; // _10 - DSP_SetMixerInitVolume, DSP_SetMixerVolume, DSP_SetBusConnect
u8 _40[0x50 - 0x40]; // _40
u16 dolbyVoicePosition; // _50
s16 dolbyReverbFactor; // _52
s16 dolbyVolumeCurrent; // _54
s16 dolbyVolumeTarget; // _56
DSPBOOL useDolbyVolume; // _58
u16 _5A; // _5A
u16 _5C; // _5C
u16 _5E; // _5E
u16 currentPosFrac; // _60 - DSP_PlayStart
u16 _62; // _62
u16 afcRemainingDecodedSamples; // _64 - DSP_SetOscInfo, DSP_SetWaveInfo
s16 constantSample; // _66 - DSP_PlayStart
u32 currentPosition; // _68 - DSP_PlayStart
u16 samplesBeforeLoop; // _6C
u16 _6E; // _6E
u32 currentAramAddr; // _70
u32 remainingLength; // _74
s16 resampleBuffer[4]; // _78 - DSP_PlayStart
u16 variableFirHistory[20]; // _80 - DSP_PlayStart
s16 biquadHistory[4]; // _A8 - DSP_PlayStart
u16 afcRemainingSamples[16]; // _B0 - DSP_SetWaveInfo
s16 lowPassHistory[2]; // _D0
u8 _D4[0x100 - 0xD4]; // _D4
u16 samplesSourceType; // _100 - DSP_SetOscInfo, DSP_SetWaveInfo
DSPBOOL isLooping; // _102 - DSP_SetWaveInfo
s16 loopYN1; // _104 - DSP_SetWaveInfo
s16 loopYN2; // _106 - DSP_SetWaveInfo
s16 filterMode; // _108 - DSP_SetFilterMode
DSPBOOL endRequested; // _10A - DSP_AllocInit, DSP_SetMixerVolume
u32 _10C; // _10C - DSP_PlayStart
u32 loopAddress; // _110 - DSP_SetWaveInfo
u32 loopStartPosition; // _114 - DSP_SetWaveInfo
u32 baseAddress; // _118 - DSP_SetOscInfo, DSP_SetWaveInfo
u32 _11C; // _11C - DSP_SetWaveInfo
s16 variableFirCoeffs[20]; // _120 - DSP_InitFilter, DSP_SetFIR8FilterParam
s16 biquadFilterCoeffs[4]; // _148 - DSP_InitFilter, DSP_SetIIRFilterParam
s16 lowPassCoeff; // _150 - DSP_InitFilter, DSP_SetDistFilter
u8 padding[0x180 - 0x152]; // _152
};
///////////////////////////////////////////////////////////////////////////////
// Based on `DSP::HLE::ReverbPB` from Dolphin Emulator. Thank you all!
/**
* @brief TODO. Does this name make sense? Dolphin calls this "Destination"
*/
struct FXDestination {
u16 bufferId; // _00 - See DSPMixerChannel::id
s16 volume; // _02 - 1.15 format.
};
/**
* @brief TODO.
*/
struct FXBuffer {
DSPBOOL enabled; // _00
u16 circularBufferSize; // _02
s16* circularBufferBase; // _04
FXDestination dest[2]; // _08
s16 filterCoeffs[8]; // _10
};
#endif
+6 -1
View File
@@ -3,8 +3,13 @@
#include "types.h"
extern u32 DSPReleaseHalt(void);
extern s32 DSPSendCommands(u32* commands, u32 count);
extern u32 DSPReleaseHalt();
extern void DSPWaitFinish();
extern void DsetupTable(u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4);
extern void DsyncFrame(u32 subframes, u32 dspbuf_start, u32 dspbuf_end);
extern void DwaitFrame();
extern void DiplSec(u32 arg0);
extern void DagbSec(u32 arg0);
#endif
+1 -1
View File
@@ -17,7 +17,7 @@ extern u32 GetNeosRom_PreLoaded(void);
extern u32 SetPreCopy_NeosRom(u8* load_addr, u32 load_size, BOOL cut_flag);
extern BOOL ARAMStartDMAmesg(u32 dir, u32 dramAddr, u32 aramAddr, u32 size, s32 unused, OSMesgQueue* mq);
extern void Jac_SetAudioARAMSize(u32 size);
extern void ARAllocFull(u32* outSize);
extern void* ARAllocFull(u32* outSize);
extern void Jac_InitARAM(u32 loadAudiorom);
#endif
+18
View File
@@ -0,0 +1,18 @@
#ifndef _JAUDIO_FAT_H
#define _JAUDIO_FAT_H
#include "types.h"
void Jac_FatMemory_Init(u32);
void FAT_InitSystem(u8*, u32);
int FAT_AllocateMemory(u32);
int FAT_FreeMemory(u16);
u8* FAT_GetPointer(u16, u32);
u8 FAT_ReadByte(u16, u32);
u16 FAT_ReadWord(u16, u32); // UNUSED, but these were probably global
void FAT_ReadWordD(u16, u32); // UNUSED, but these were probably global
u32 FAT_ReadLong(u16, u32); // UNUSED, but these were probably global
void FAT_ReadLongD(u16, u32); // UNUSED, but these were probably global
int FAT_StoreBlock(u8*, u16, u32, u32);
#endif
+20
View File
@@ -0,0 +1,20 @@
#ifndef _JAUDIO_FXINTERFACE_H
#define _JAUDIO_FXINTERFACE_H
#include "jaudio_NES/dspinterface.h"
typedef struct FxlineConfig_ FxlineConfig;
struct FxlineConfig_ {
u8 enabled; // _00
u16 sendIdx0; // _02
s16 volume0; // _04
u16 sendIdx1; // _06
s16 volume1; // _08
s32 circularBufferSize; // _0C
s16 filterCoeffs[8]; // _10
};
BOOL DFX_SetFxLine(u8 idx, s16* circularBufferBase, FxlineConfig* fxlineConfig);
#endif
+35 -8
View File
@@ -1,13 +1,40 @@
#ifndef HEAPCTRL_H
#define HEAPCTRL_H
#ifndef _JAUDIO_HEAPCTRL_H
#define _JAUDIO_HEAPCTRL_H
#include "types.h"
typedef struct jaheap_ {
void* _00;
void* _04;
void* _08;
} JAHEAP;
typedef struct jaheap_ jaheap_;
typedef struct jaheap_ jaheap;
JAHEAP* Jac_AllocHeap(jaheap_*, jaheap_*, unsigned long);
struct jaheap_ {
u8 isRootHeap; // _00, is this a 'mother' heap?
u8 memoryType; // _01, 0 = ARAM, 1 = DRAM
u16 childCount; // _02
u32 heapId; // _04
u32 startAddress; // _08
u32 usedSize; // _0C
u32 size; // _10
jaheap_* firstChild; // _14
jaheap_* parent; // _18
jaheap_* nextSibling; // _1C
jaheap_* groupOwner; // _20
jaheap_* firstGroupedHeap; // _24
jaheap_* nextGroupedHeap; // _28
};
void Jac_GetUnlockHeap(jaheap_*);
void Jac_CheckAlloc(jaheap_*);
void Jac_InitHeap(jaheap_*);
void Jac_SelfInitHeap(jaheap_*, u32, u32, u32);
BOOL Jac_SelfAllocHeap(jaheap_*, jaheap_*, u32, u32);
BOOL Jac_SetGroupHeap(jaheap_*, jaheap_*);
void Jac_CutdownHeap(jaheap_*);
void Jac_InitMotherHeap(jaheap_*, u32, u32, u8);
BOOL Jac_AllocHeap(jaheap_*, jaheap_*, u32);
BOOL Jac_DeleteHeap(jaheap_*);
void Jac_GarbageCollection_St(jaheap_*);
void Jac_CheckFreeHeap_Total(jaheap_*);
void Jac_CheckFreeHeap_Linear(jaheap_*);
void Jac_ShowHeap(jaheap_*, u32);
#endif
+24 -3
View File
@@ -1,8 +1,29 @@
#ifndef IPLDEC_H
#define IPLDEC_H
#ifndef _JAUDIO_IPLDEC_H
#define _JAUDIO_IPLDEC_H
#include "types.h"
#include "dolphin/dsp.h"
extern BOOL DspExtraTaskCheck(void);
/////////// JAUDIO IPL DEC DEFINITIONS ///////////
// Global functions (all C++, so no extern C wrap).
BOOL DspExtraTaskCheck();
void Jac_DSPcardDecodeAsync(void*, void*, DSPCallback);
// IPL Decode specific structs.
#define DSPTARGET_IPL 0
#define DSPTARGET_AGB 1
/**
* @brief TODO.
*/
typedef struct DSPTask {
u8 target; // _00, ipl (gc) or agb (gameboy player)
u32 cmd; // _04
void* task; // _08
DSPCallback callback; // _0C
} DSPTask;
//////////////////////////////////////////////////
#endif
+10 -3
View File
@@ -1,8 +1,15 @@
#ifndef JA_CALC_H
#define JA_CALC_H
#ifndef _JAUDIO_JA_CALC_H
#define _JAUDIO_JA_CALC_H
#include "types.h"
extern void Jac_InitSinTable(void);
/////////// JAUDIO MATH DEFINITIONS ///////////
// Global functions (all C++, so no extern C wrap).
f32 sqrtf2(f32);
f32 atanf2(f32, f32);
void Jac_InitSinTable();
f32 sinf3(f32);
///////////////////////////////////////////////
#endif
-16
View File
@@ -1,16 +0,0 @@
#ifndef JAMMAIN_H
#define JAMMAIN_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
void Jam_InitRegistTrack(void);
#ifdef __cplusplus
}
#endif
#endif
+358
View File
@@ -0,0 +1,358 @@
#ifndef _JAUDIO_JAMMAIN_2_H
#define _JAUDIO_JAMMAIN_2_H
#include "types.h"
#include "jaudio_NES/audiostruct.h"
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
//! NOTE from intns:
//! There's something iffy going on with the value 0xC0.
//! It appears in seqsetup with flags regarding opening tracks,
//! It appears to do with command id(s) for some reason
//! It's everywhere, but why? Why, J(esus)System?
typedef struct seqp_ seqp_;
typedef struct TrackPort_ TrackPort_;
typedef struct MoveParam_ MoveParam_;
typedef struct AInnerParam_ AInnerParam_;
typedef union TimedParam_ TimedParam_;
typedef struct OuterParam_ OuterParam_;
typedef struct RegisterParam_ RegisterParam_;
typedef union URegisterParam_ URegisterParam_;
typedef u32 (*CmdFunction)(); // TODO: Confirm return type
typedef u16 (*TrackCallback)(seqp_*, u16); // TODO: Confirm return type
typedef enum {
OuterParamFlag_None = 0,
OuterParamFlag_Volume = 1 << 0,
OuterParamFlag_Pitch = 1 << 1,
OuterParamFlag_Fxmix = 1 << 2,
OuterParamFlag_Pan = 1 << 3,
OuterParamFlag_Dolby = 1 << 4,
OuterParamFlag_DistFilt = 1 << 5,
OuterParamFlag_Tempo = 1 << 6,
OuterParamFlag_FIR8Filter = 1 << 7, // Probably related to FIR filter
OuterParamFlag_IIR0 = 1 << 12, // IIR0 filter
OuterParamFlag_IIR1 = 1 << 13, // IIR1 filter
OuterParamFlag_IIR2 = 1 << 14, // IIR2 filter
OuterParamFlag_IIR3 = 1 << 15, // IIR3 filter
OuterParamFlag_IIRFilter = (OuterParamFlag_IIR0 | OuterParamFlag_IIR1 | OuterParamFlag_IIR2 | OuterParamFlag_IIR3),
SEQTRACK_FLAG_MASTER_LEVEL = 1 << 17 // TODO: suspicious, unknown use
} OuterParamFlag;
typedef enum {
CMD_NONE_0 = 0, // 0
CMD_OPEN_TRACK, // 1
CMD_OPEN_TRACK_BROS, // 2
CMD_CALL, // 3
CMD_CALL_F, // 4
CMD_RETURN, // 5
CMD_RETURN_F, // 6
CMD_JUMP, // 7
CMD_JUMP_F, // 8
CMD_LOOP_START, // 9
CMD_LOOP_END, // 10
CMD_READ_PORT, // 11
CMD_WRITE_PORT, // 12
CMD_CHECK_PORT_IMPORT, // 13
CMD_CHECK_PORT_EXPORT, // 14
CMD_WAIT_REGISTER, // 15
CMD_CONNECT_NAME, // 16
CMD_PARENT_WRITE_PORT, // 17
CMD_CHILD_WRITE_PORT, // 18
CMD_NONE_1, // 19
CMD_SET_LAST_NOTE, // 20
CMD_TIME_RELATE, // 21
CMD_SIMPLE_OSC, // 22
CMD_SIMPLE_ENV, // 23
CMD_SIMPLE_ADSR, // 24
CMD_TRANSPOSE, // 25
CMD_CLOSE_TRACK, // 26
CMD_OUTPUT_SWITCH, // 27
CMD_UPDATE_SYNC, // 28
CMD_BUS_CONNECT, // 29
CMD_PAUSE_STATUS, // 30
CMD_SET_INTERRUPT, // 31
CMD_DISABLE_INTERRUPT, // 32
CMD_CLEAR_I, // 33
CMD_SET_I, // 34
CMD_RETURN_I, // 35
CMD_INTERRUPT_TIMER, // 36
CMD_CONNECT_OPEN, // 37
CMD_CONNECT_CLOSE, // 38
CMD_SYNC_CPU, // 39
CMD_FLUSH_ALL, // 40
CMD_FLUSH_RELEASE, // 41
CMD_WAIT_3, // 42
CMD_PAN_POWER_SET, // 43
CMD_IIR_SET, // 44
CMD_FIR_SET, // 45
CMD_EXT_SET, // 46
CMD_PAN_SWITCH_SET, // 47
CMD_OSC_ROUTE, // 48
CMD_IIR_CUTOFF, // 49
CMD_OSC_FULL, // 50
CMD_NONE_2, // 51
CMD_NONE_3, // 52
CMD_NONE_4, // 53
CMD_NONE_5, // 54
CMD_NONE_6, // 55
CMD_NONE_7, // 56
CMD_NONE_8, // 57
CMD_CHECK_WAVE, // 58
CMD_PRINTF, // 59
CMD_NOP, // 60
CMD_TEMPO, // 61
CMD_TIME_BASE, // 62
CMD_FINISH, // 63
CMD_COUNT // 64
} CommandID;
/**
* @brief This is an invented type of an unknown name.
*
* @note Size: 4
*/
struct TrackPort_ {
u8 importFlag; // _00
u8 exportFlag; // _01
u16 value; // _02
};
/**
* @brief Name borrowed from `JASTrack.h` from Pikmin 2.
*
* @note Size: 16
*/
struct MoveParam_ {
f32 currentValue; // _00
f32 targetValue; // _04
f32 duration; // _08
f32 stepSize; // _0C
};
/**
* @brief Name borrowed from `JASTrack.h` from Pikmin 2.
*
* @note Size: 0x120
*/
struct AInnerParam_ {
MoveParam_ volume; // _00
MoveParam_ pitch; // _10
MoveParam_ fxmix; // _20
MoveParam_ pan; // _30
MoveParam_ dolby; // _40
MoveParam_ distFilter; // _50
MoveParam_ osc0Width; // _60
MoveParam_ osc0Rate; // _70
MoveParam_ osc0Vertex; // _80
MoveParam_ osc1Width; // _90
MoveParam_ osc1Rate; // _A0
MoveParam_ osc1Vertex; // _B0
MoveParam_ IIRs[4]; // _C0
MoveParam_ _100; // _100
MoveParam_ _110; // _110
};
union TimedParam_ {
AInnerParam_ inner; // Get individual params by member name
MoveParam_ move[18]; // Get individual params by index
};
/**
* @brief Name borrowed from `JASTrack.h` from Pikmin 2.
*
* @note Size: 0x40.
*/
struct OuterParam_ {
BOOL isAssigned; // _00
u32 refCount; // _04
u16 flags; // _08
u16 updateFlags; // _0A
f32 volume; // _0C
f32 fxMix; // _10
f32 dolby; // _14
f32 pitch; // _18
f32 pan; // _1C
f32 tempo; // _20
s16 firCoefficients[8]; // _24
u8 _34[0x40 - 0x34]; // _34
};
/**
* @brief Name borrowed from `JASRegisterParam.h` from Pikmin 2.
*
* @note Size: 0x40.
*/
struct RegisterParam_ {
u8 _00[0x06 - 0x00]; // _00, 00 - 02
u16 value; // _06, 03
u8 _08[0x0C - 0x08]; // _08, 04 - 05
u16 bankNumber; // _0C, 06
u16 pitchScale; // _0E, 07
u16 arguments[5]; // _10, 08 - 12, Exact length confirmed: `Cmd_PanPowSet`.
u16 basePriority; // _1A, 13
u8 _1C[0x20 - 0x1C]; // _1C, 14
u32 _20[4]; // _20, 15 - 22, Exact length semi-confirmed; Pikmin 2 also says 4.
u8 _30[0x40 - 0x30]; // _1C, 23 - 31
};
/**
* @brief Invented struct necessitated by behavior in `seqsetup.c`.
*
* @note Size: 0x40.
*/
union URegisterParam_ {
RegisterParam_ param;
u16 reg[32];
};
/**
* @brief This struct is analogous to `JASTrack` of later JAudio.
*
* @note Size: 0x434 (Confirmed by `Jaf_HandleToSeq`).
*/
struct seqp_ {
u8* baseData; // _000
u32 programCounter; // _004
u32 callStackDepth; // _008
u32 callStack[2]; // _00C, Exact length unknown, but it is an array.
u8 _10[0x02c - 0x014]; // _008
u16 loopCounters[2]; // _02C, Exact length unknown, but it is an array.
u8 _30[0x03c - 0x030]; // _030
u8 trackState; // _03C, Confirmed unsigned by switch cases
u8 dataSourceMode; // _03D
u8 fileHandle; // _03E
u8 flags; // _03F
seqp_* parent; // _040
seqp_* children[16]; // _044
u32 connectionId; // _084
u32 trackId; // _088
s32 waitTimer; // _08C
u32 _90; // _090
u8 _94[8]; // _094
jc_* channels[8]; // _09C
u16 activeSoundIds[8]; // _0BC
u8 _CC; // _0CC
u8 _CD; // _0CD
u8 _CE[0x0d0 - 0x0ce]; // _0CE
u32 _D0; // _0D0
u8 _D4; // _0D4
u8 _D5; // _0D5
u8 _D6; // _0D6, boolean-like
u8 _D7[0x0d8 - 0x0d7]; // _0D7
jcs_ parentController; // _0D8
TimedParam_ timedParam; // _14C
URegisterParam_ regParam; // _26C
OuterParam_* outerParams; // _2AC
OuterParam_* childOuterParams[16]; // _2B0
TrackPort_ trackPort[16]; // _2F0
f32 tempoAccumulator; // _330
f32 tempoFactor; // _334
u16 timeBase; // _338
u16 tempo; // _33A
u8 timeRelationMode; // _33C
u8 _33D; // _33D
Osc_ oscillators[2]; // _340
u8 oscillatorRouting[2]; // _370
s16 adsTable[12]; // _372
s16 relTable[6]; // _38A
s8 transpose; // _396
u8 finalTranspose; // _397
s32 tickCounter; // _398
u8 isPaused; // _39C, boolean-like
u8 pauseStatus; // _39D
u8 isMuted; // _39E, boolean-like
u8 _39F[0x3a0 - 0x39f]; // _39F
u16 childMuteMask; // _3A0
u8 _3A2[0x3a4 - 0x3a2]; // _3A2
u8 interruptActive; // _3A4
u8 interruptPending; // _3A5
u8 interruptEnable; // _3A6
u8 timerCount; // _3A7
u32 interruptAddresses[8]; // _3A8
u32 savedProgramCounter; // _3C8
u32 _3CC; // _3CC, to do with timers (CMD_IntTimer)
u32 timer; // _3D0, to do with timers (CMD_IntTimer)
u32 maxTime; // _3D4, to do with timers (CMD_IntTimer)
u32 updateFlags; // _3D8, see `SEQTRACK_FLAG_*` defines
u8 panCalcTypes[3]; // _3DC
u8 parentPanCalcTypes[3]; // _3DF
u8 isRegistered; // _3E2
u8 doChangeTempo; // _3E3, boolean-like
u8 _3E4; // _3E4
u8 _3E5[0x3e8 - 0x3e5]; // _3E5
Oscbuf_ oscillatorParams[2]; // _3E8
u8 _418[0x434 - 0x418]; // _400
};
extern s16 CUTOFF_TO_IIR_TABLE[128][4];
void* Jam_OfsToAddr(seqp_*, u32);
void Jam_WriteRegDirect(seqp_*, u8, u16);
void Jam_WriteRegParam(seqp_*, u8);
u16 Jam_ReadRegDirect(seqp_*, u8);
u32 Jam_ReadReg32(seqp_* track, u8 index);
void Jam_WriteRegXY(seqp_* track, u32 param_2);
void Jam_WritePortApp(void);
void Jam_ReadPortApp(void);
void Jam_CheckExportApp(void);
void Jam_CheckImportApp(void);
void Jam_WritePortIndirect(void);
void Jam_ReadPortIndirect(void);
void Jam_CheckPortIndirect(void);
BOOL Jam_WritePortAppDirect(seqp_*, u32, u16);
BOOL Jam_ReadPortAppDirect(seqp_*, u32, u16*);
BOOL Jam_CheckPortAppDirect(seqp_*, u32, u16);
void Jam_WritePort(void);
void Jam_ReadPort(void);
void Jam_WritePortChild(void);
void Jam_WritePortBros(void);
void Jam_InitRegistTrack(void);
void Jam_UnRegistTrack(seqp_*);
seqp_* Jam_GetTrackHandle(u32);
void Jam_InitExtBuffer(OuterParam_*);
BOOL Jam_AssignExtBuffer(seqp_*, OuterParam_*);
BOOL Jam_AssignExtBufferP(seqp_*, u8, OuterParam_*);
void Jam_SetExtFirFilterD(OuterParam_*, s16*);
void Jam_SetExtParamD(f32, OuterParam_*, u8);
void Jam_OnExtSwitchD(OuterParam_*, u16);
void Jam_OffExtSwitchD(OuterParam_*, u16);
void Jam_SetExtSwitchDirectD(void);
void Jam_SetExtFirFilter(void);
void Jam_SetExtParam(f32, seqp_*, u8);
void Jam_OnExtSwitch(seqp_*, u16);
void Jam_OffExtSwitch(seqp_*, u16);
void Jam_SetExtSwitchDirect(void);
void Jam_SetExtFirFilterP(void);
void Jam_SetExtParamP(f32, seqp_*, u8, u8);
void Jam_OnExtSwitchP(seqp_*, u8, u16);
void Jam_OffExtSwitchP(seqp_*, u8, u16);
void Jam_SetExtSwitchDirectP(void);
void Jam_CheckRunningCounter(void);
BOOL Jam_RegisterTrackCallback(TrackCallback);
void Jam_SetTrackExtPanPower(void);
void Jam_UpdateTrackAll(seqp_*);
void Jam_UpdateTrack(seqp_*, u32);
void Jam_UpdateTempo(seqp_*);
void Jam_MuteTrack(seqp_*, u8);
void Jam_MuteChildTracks(void);
void Jam_PauseTrack(seqp_*, u8);
void Jam_UnPauseTrack(seqp_*, u8);
void Jam_SetInterrupt(seqp_*, u16);
BOOL Jam_TryInterrupt(seqp_*);
s32 Jam_SeqmainNote(seqp_*, u8);
void SeqUpdate(seqp_*, u32);
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif
+24
View File
@@ -0,0 +1,24 @@
#ifndef _JAUDIO_JAMOSC_H
#define _JAUDIO_JAMOSC_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
typedef struct seqp_ seqp_;
void Osc_Update_Param(seqp_* track, u8 id, f32 val);
void Osc_Setup_Simple(seqp_* track, u8);
void Osc_Clear_Overwrite(seqp_* track);
void Osc_Init_Env(seqp_* track);
void Osc_Setup_SimpleEnv(seqp_* track, u8, u32);
void Osc_Setup_ADSR(seqp_* track, s16*);
void Osc_Setup_Full(seqp_* track, u8, u32, u32);
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef JAUDIO_MEMORY_H
#define JAUDIO_MEMORY_H
#ifndef _JAUDIO_MEMORY_H
#define _JAUDIO_MEMORY_H
#include "types.h"
#include "jaudio_NES/audiostruct.h"
+15
View File
@@ -0,0 +1,15 @@
#ifndef _JAUDIO_NOTEON_H
#define _JAUDIO_NOTEON_H
#include "types.h"
typedef struct seqp_ seqp_;
s32 NoteON(seqp_*, s32, s32, s32, s32);
s32 NoteOFF_R(seqp_*, u8, u16);
s32 NoteOFF(seqp_*, u8);
s32 GateON(seqp_*, s32, s32, s32, s32);
void ProgramChange(s32);
BOOL CheckNoteStop(seqp_*, s32);
#endif
+53
View File
@@ -0,0 +1,53 @@
#ifndef _JAUDIO_ONESHOT_H
#define _JAUDIO_ONESHOT_H
#include "types.h"
typedef struct jc_ jc_;
typedef struct Inst_ Inst_;
typedef struct Perc_ Perc_;
typedef struct Pmap_ Pmap_;
typedef struct Osc_ Osc_;
typedef struct jcs_ jcs_;
typedef struct Vmap_ Vmap_;
typedef struct CtrlWave_ {
int _00; // _00
int _04; // _04
int _08; // _08
u32 _0C; // _0C
u8 _10[0x34 - 0x10]; // _10, unknown
u32 _34; // _34, unknown
} CtrlWave_;
typedef union SOUNDID_ SOUNDID_;
/**
* @brief This is a "boxed" integer type to be passed by value.
*
* @note Size: 4. Why wasn't this just an enum... This compiler is not smart enough to optimize this.
*/
union SOUNDID_ {
u32 value; // _00
u8 bytes[4];
};
void Effecter_Overwrite_1ShotD(jc_*, Osc_*, u32);
Perc_* PercRead(u32, u32);
Inst_* InstRead(u32, u32);
Vmap_* VmapRead(Inst_*, u8, u8);
void Init_1shot(jcs_*, u32);
void Stop_1Shot(jc_*);
void Stop_1Shot_R(jc_*, u16);
void AllStop_1Shot(jcs_*);
void SetPitchTarget_1Shot(jc_*, f32, u32);
void SetKeyTarget_1Shot(jc_*, u8, u32);
void Gate_1Shot(jc_*, u8, u8, s32);
void UpdatePause_1Shot(jc_*, u8 a1);
void UpdatePanPower_1Shot(jc_*, f32, f32, f32, f32);
void FlushRelease_1Shot(jcs_*);
u32 One_CheckInstWave(SOUNDID_); // Return type unsure
jc_* Play_1shot(jcs_*, SOUNDID_, u32);
jc_* Play_1shot_Perc(jcs_*, SOUNDID_, u32);
jc_* Play_1shot_Osc(jcs_*, SOUNDID_, u32);
#endif
+8
View File
@@ -8,6 +8,14 @@
extern "C" {
#endif
typedef s32 (*PlayerCallBack)(void*);
typedef struct PLAYER_CALL_ {
PlayerCallBack callback; // _00
void* arg; // _04
u32 DSP_mode; // _08
} PLAYER_CALL;
extern void ResetPlayerCallback();
extern s32 Jac_RegisterDspPlayerCallback(PlayerCallBack callback, void* arg);
extern s32 Jac_RegisterPlayerCallback(PlayerCallBack callback, void* arg);
+5 -9
View File
@@ -1,19 +1,15 @@
#ifndef RATE_H
#define RATE_H
#ifndef _JAUDIO_RATE_H
#define _JAUDIO_RATE_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
/////////// JAUDIO GLOBAL RATE SETTINGS ///////////
extern u32 JAC_AI_SETTING;
extern f32 JAC_DAC_RATE;
extern u32 JAC_SUBFRAMES;
extern u32 JAC_FRAMESAMPLES;
extern u32 DAC_SIZE;
#ifdef __cplusplus
}
#endif
///////////////////////////////////////////////////
#endif
+16 -8
View File
@@ -1,19 +1,27 @@
#ifndef SEQSETUP_H
#define SEQSETUP_H
#ifndef _JAUDIO_SEQSETUP_H
#define _JAUDIO_SEQSETUP_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
#endif // ifdef __cplusplus
typedef struct seqp seqp; // TODO
typedef struct seqp_ seqp_;
void Jaq_Reset(void);
s32 Jaq_SetSeqData(seqp* seqp, u8* param_2, u32 param_3, int param_4);
s32 Jaq_StartSeq(u8);
void Jaq_GetRemainFreeTracks(void);
seqp_* Jaq_HandleToSeq(u32 handle);
BOOL Jaq_StopSeq(s32 index);
s32 Jaq_SetSeqData(seqp_*, u8*, u32, u32);
s32 Jaq_SetSeqData_Limit(seqp_*, u8*, u32, u32, u8);
BOOL Jaq_SetBankNumber(seqp_* track, u8 bankNum);
BOOL Jaq_StartSeq(u32);
s32 Jaq_OpenTrack(seqp_*, u32, u32);
u32 Jaq_CloseTrack(seqp_*);
#ifdef __cplusplus
}
#endif
};
#endif // ifdef __cplusplus
#endif
+9
View File
@@ -0,0 +1,9 @@
#ifndef _JAUDIO_TABLES_H
#define _JAUDIO_TABLES_H
#include "types.h"
#define C5BASE_PITCHTABLE_LENGTH (128)
extern f32 C5BASE_PITCHTABLE[C5BASE_PITCHTABLE_LENGTH];
#endif
+18
View File
@@ -0,0 +1,18 @@
#ifndef _JAUDIO_WAVEREAD_H
#define _JAUDIO_WAVEREAD_H
#include "types.h"
typedef struct CtrlGroup_ CtrlGroup_;
CtrlGroup_* Wave_Test(u8*);
void GetSound_Test(u32);
BOOL Wavegroup_Regist(void*, u32);
void Wavegroup_Init();
CtrlGroup_* WaveidToWavegroup(u32, u32);
BOOL WaveScene_Set(u32, u32);
BOOL WaveScene_Load(u32, u32);
void WaveScene_Close(u32, u32);
void WaveScene_Erase(u32, u32);
#endif