Give MusyX it's own types

This commit is contained in:
Phillip Stephens 2022-08-05 12:43:46 -07:00
parent 7043befead
commit 79eff1f8b5
8 changed files with 178 additions and 72 deletions

View File

@ -1,30 +1,81 @@
#ifndef MUSYX_H #ifndef MUSYX_H
#define MUSYX_H #define MUSYX_H
#include "types.h" typedef signed char s8;
typedef unsigned char u8;
typedef signed short s16;
typedef unsigned short u16;
typedef signed long s32;
typedef unsigned long u32;
typedef float f32;
typedef double f64;
#ifndef NULL
#define NULL 0
#endif
#ifndef bool8 #ifndef bool8
typedef unsigned char bool8; typedef unsigned char bool8;
#endif #endif
#ifndef bool
typedef signed long bool;
#define FALSE 0
#define TRUE 1
#endif
#define SND_STUDIO_MAXNUM 8
#define SND_STUDIO_DEFAULT 0
#define SND_STUDIO_NONE 0xFF
#define SYNTH_MAX_VOICES 64
typedef u32 SND_SEQID;
typedef u32 SND_VOICEID;
typedef u32 SND_STREAMID;
typedef u16 SND_GROUPID;
typedef u16 SND_SONGID;
typedef u16 SND_FXID;
typedef enum {
SND_OUTPUTMODE_MONO = 0,
SND_OUTPUTMODE_STEREO,
SND_OUTPUTMODE_SURROUND,
} SND_OUTPUTMODE;
typedef struct SND_PLAYBACKINFO {
u32 frq;
u8 stereo;
u8 bits;
s8 deviceName[256];
s8 versionText[256];
} SND_PLAYBACKINFO;
typedef struct SND_SEQVOLDEF {
u8 track;
u8 volGroup;
} SND_SEQVOLDEF;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef struct _SynthInfo { typedef struct SND_HOOKS {
u32 freq;
u8 unk[0x20c];
u8 voices;
u8 music;
u8 sfx;
u8 studios;
} SynthInfo;
typedef struct _SND_HOOKS {
void* (*malloc)(u32 len); void* (*malloc)(u32 len);
void (*free)(void* addr); void (*free)(void* addr);
} SND_HOOKS; } SND_HOOKS;
typedef struct SND_FVECTOR {
f32 x;
f32 y;
f32 z;
} SND_FVECTOR;
typedef struct SND_FMATRIX {
f32 m[3][3];
f32 t[3];
} SND_FMATRIX;
#define SND_AUX_NUMPARAMETERS 4 #define SND_AUX_NUMPARAMETERS 4
#define SND_AUX_REASON_BUFFERUPDATE 0 #define SND_AUX_REASON_BUFFERUPDATE 0
@ -97,10 +148,10 @@ typedef struct SND_AUX_DELAY {
} SND_AUX_DELAY; } SND_AUX_DELAY;
void sndAuxCallbackDelay(u8 reason, SND_AUX_INFO* info, void* user); void sndAuxCallbackDelay(u8 reason, SND_AUX_INFO* info, void* user);
s32 sndAuxCallbackUpdateSettingsDelay(SND_AUX_DELAY* delay); bool sndAuxCallbackUpdateSettingsDelay(SND_AUX_DELAY* delay);
s32 sndAuxCallbackPrepareDelay(SND_AUX_DELAY* rev); bool sndAuxCallbackPrepareDelay(SND_AUX_DELAY* rev);
s32 sndAuxCallbackShutdownDelay(SND_AUX_DELAY* rev); bool sndAuxCallbackShutdownDelay(SND_AUX_DELAY* rev);
s32 sndAuxCallbackUpdateSettingsReverbHI(SND_AUX_REVERBHI* rev); bool sndAuxCallbackUpdateSettingsReverbHI(SND_AUX_REVERBHI* rev);
typedef struct _SND_REVSTD_DELAYLINE { typedef struct _SND_REVSTD_DELAYLINE {
s32 inPoint; s32 inPoint;
@ -135,20 +186,32 @@ typedef struct SND_AUX_REVERBSTD {
} SND_AUX_REVERBSTD; } SND_AUX_REVERBSTD;
void sndAuxCallbackReverbSTD(u8 reason, SND_AUX_INFO* info, void* user); void sndAuxCallbackReverbSTD(u8 reason, SND_AUX_INFO* info, void* user);
s32 sndAuxCallbackPrepareReverbSTD(SND_AUX_REVERBSTD* rev); bool sndAuxCallbackPrepareReverbSTD(SND_AUX_REVERBSTD* rev);
s32 sndAuxCallbackShutdownReverbSTD(SND_AUX_REVERBSTD* rev); bool sndAuxCallbackShutdownReverbSTD(SND_AUX_REVERBSTD* rev);
s32 sndAuxCallbackUpdateSettingsReverbSTD(SND_AUX_REVERBSTD* rev); bool sndAuxCallbackUpdateSettingsReverbSTD(SND_AUX_REVERBSTD* rev);
typedef struct SND_FVECTOR { typedef struct SND_PARAMETER {
f32 x; u8 ctrl;
f32 y; union {
f32 z; u8 value7;
} SND_FVECTOR; u16 value14;
} paraData;
} SND_PARAMETER;
typedef struct SND_FMATRIX { typedef struct SND_PARAMETER_INFO {
f32 m[3][3]; u8 numPara;
f32 t[3]; SND_PARAMETER* paraArray;
} SND_FMATRIX;
} SND_PARAMETER_INFO;
#define sndFXStart(fid,vol,pan) sndFXStartEx(fid,vol,pan,SND_STUDIO_DEFAULT)
SND_VOICEID sndFXStartEx(SND_FXID fid,u8 vol,u8 pan,u8 studio);
SND_VOICEID sndFXStartPara(SND_FXID fid,u8 vol,u8 pan,u8 studio,u8 numPara,...);
SND_VOICEID sndFXStartParaInfo(SND_FXID fid,u8 vol,u8 pan,u8 studio,SND_PARAMETER_INFO *paraInfo);
SND_VOICEID sndFXCheck(SND_VOICEID vid);
bool sndFXKeyOff(SND_VOICEID vid);
bool sndFXCtrl(SND_VOICEID vid,u8 ctrl,u8 value);
bool sndFXCtrl14(SND_VOICEID vid,u8 ctrl,u16 value);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -6,6 +6,16 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef struct _SynthInfo {
u32 freq;
u8 unk[0x20c];
u8 voices;
u8 music;
u8 sfx;
u8 studios;
} SynthInfo;
typedef s32 (*SND_COMPARE)(u16*, u8*); typedef s32 (*SND_COMPARE)(u16*, u8*);
void dataInit(u32, s32); /* extern */ void dataInit(u32, s32); /* extern */

View File

@ -166,9 +166,23 @@ asm void PPCSync (void)
* Address: ........ * Address: ........
* Size: 000034 * Size: 000034
*/ */
void PPCEieio(void) asm void PPCEieio(void) {
{ nofralloc
// UNUSED FUNCTION mfmsr r5
rlwinm r6, r5, 0, 0x11, 0xf
mtmsr r6
mfspr r3, hid0
ori r4, r3, 8
mtspr hid0, r4
isync
eieio
isync
mtspr hid0, r3
mtmsr r5
isync
blr
} }
/* /*
@ -196,9 +210,11 @@ _spin:
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void PPCMfmmcr0(void) asm void PPCMfmmcr0(void)
{ {
// UNUSED FUNCTION nofralloc
mfspr r3, MMCR0
blr
} }
/* /*
@ -219,10 +235,11 @@ asm void PPCMtmmcr0 (register u32 newMmcr0)
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void PPCMfmmcr1(void) asm void PPCMfmmcr1(void)
{ {
// UNUSED FUNCTION nofralloc
} mfspr r3, MMCR1
blr}
/* /*
* --INFO-- * --INFO--
@ -242,9 +259,11 @@ asm void PPCMtmmcr1 (register u32 newMmcr1)
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void PPCMfpmc1(void) asm void PPCMfpmc1(void)
{ {
// UNUSED FUNCTION nofralloc
mfspr r3, PMC1
blr
} }
/* /*
@ -265,9 +284,11 @@ asm void PPCMtpmc1 (register u32 newPmc1)
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void PPCMfpmc2(void) asm void PPCMfpmc2(void)
{ {
// UNUSED FUNCTION nofralloc
mfspr r3, PMC2
blr
} }
/* /*
@ -288,10 +309,11 @@ asm void PPCMtpmc2 (register u32 newPmc2)
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void PPCMfpmc3(void) asm void PPCMfpmc3(void)
{ {
// UNUSED FUNCTION nofralloc
} mfspr r3, PMC2
blr}
/* /*
* --INFO-- * --INFO--
@ -311,9 +333,11 @@ asm void PPCMtpmc3 (register u32 newPmc3)
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void PPCMfpmc4(void) asm void PPCMfpmc4(void)
{ {
// UNUSED FUNCTION nofralloc
mfspr r3, PMC4
blr
} }
/* /*
@ -334,19 +358,22 @@ asm void PPCMtpmc4 (register u32 newPmc4)
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void PPCMfsia(void) asm void PPCMfsia(void)
{ {
// UNUSED FUNCTION nofralloc
} mfspr r3, SIA
blr}
/* /*
* --INFO-- * --INFO--
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void PPCMtsia(void) asm void PPCMtsia(register u32 newSia)
{ {
// UNUSED FUNCTION nofralloc
mtspr SIA, newSia
blr
} }
/* /*
@ -441,9 +468,11 @@ asm void PPCMtwpar ( register u32 newwpar )
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void PPCMfdmaU(void) asm void PPCMfdmaU(void)
{ {
// UNUSED FUNCTION nofralloc
mfspr r3, DMA_U
blr
} }
/* /*
@ -451,9 +480,11 @@ void PPCMfdmaU(void)
* Address: ........ * Address: ........
* Size: 000008 * Size: 000008
*/ */
void PPCMfdmaL(void) asm void PPCMfdmaL(void)
{ {
// UNUSED FUNCTION nofralloc
mfspr r3, DMA_L
blr
} }
/* /*

View File

@ -23,8 +23,8 @@ void __AICallbackStackSwitch(register AIDCallback cb);
void __AI_SRC_INIT(void); void __AI_SRC_INIT(void);
AIDCallback AIRegisterDMACallback(AIDCallback callback) { AIDCallback AIRegisterDMACallback(AIDCallback callback) {
AIDCallback ret;
s32 oldInts; s32 oldInts;
AIDCallback ret;
ret = __AID_Callback; ret = __AID_Callback;
oldInts = OSDisableInterrupts(); oldInts = OSDisableInterrupts();

View File

@ -1,6 +1,6 @@
#include "musyx/musyx_priv.h" #include "musyx/musyx_priv.h"
extern s32 ReverbSTDCreate(_SND_REVSTD_WORK* rv, f32 coloration, f32 time, f32 mix, f32 damping, f32 preDelay); extern bool ReverbSTDCreate(_SND_REVSTD_WORK* rv, f32 coloration, f32 time, f32 mix, f32 damping, f32 preDelay);
extern void ReverbHIFree(_SND_REVSTD_WORK* rev); extern void ReverbHIFree(_SND_REVSTD_WORK* rev);
extern void ReverbSTDCallback(s32* left, s32* right, s32* surround, _SND_REVSTD_WORK* rv); extern void ReverbSTDCallback(s32* left, s32* right, s32* surround, _SND_REVSTD_WORK* rv);
@ -21,14 +21,15 @@ void sndAuxCallbackReverbSTD(u8 reason, SND_AUX_INFO* info, void* user) {
} }
} }
s32 sndAuxCallbackPrepareReverbSTD(SND_AUX_REVERBSTD* rev) { bool sndAuxCallbackPrepareReverbSTD(SND_AUX_REVERBSTD* rev) {
rev->tempDisableFX = 0; rev->tempDisableFX = 0;
return ReverbSTDCreate(&rev->rv, rev->coloration, rev->time, rev->mix, rev->damping, rev->preDelay); return ReverbSTDCreate(&rev->rv, rev->coloration, rev->time, rev->mix, rev->damping, rev->preDelay);
} }
s32 sndAuxCallbackShutdownReverbSTD(SND_AUX_REVERBSTD* rev) { bool sndAuxCallbackShutdownReverbSTD(SND_AUX_REVERBSTD* rev) {
ReverbSTDFree(&rev->rv); ReverbSTDFree(&rev->rv);
return 1; return TRUE;
} }
s32 sndAuxCallbackUpdateSettingsReverbSTD(SND_AUX_REVERBSTD* rev) { /* not in MP */ bool sndAuxCallbackUpdateSettingsReverbSTD(SND_AUX_REVERBSTD* rev) {
return FALSE;
} }

View File

@ -59,7 +59,7 @@ void sndAuxCallbackDelay(u8 reason, SND_AUX_INFO* info, void* user) {
} }
} }
s32 sndAuxCallbackUpdateSettingsDelay(SND_AUX_DELAY* delay) { bool sndAuxCallbackUpdateSettingsDelay(SND_AUX_DELAY* delay) {
s32 i; s32 i;
s32* left; s32* left;
s32* right; s32* right;
@ -96,19 +96,19 @@ s32 sndAuxCallbackUpdateSettingsDelay(SND_AUX_DELAY* delay) {
*sur = 0; *sur = 0;
++sur; ++sur;
} }
return 1; return TRUE;
} }
s32 sndAuxCallbackPrepareDelay(SND_AUX_DELAY* delay) { bool sndAuxCallbackPrepareDelay(SND_AUX_DELAY* delay) {
delay->left = NULL; delay->left = NULL;
return sndAuxCallbackUpdateSettingsDelay(delay); return sndAuxCallbackUpdateSettingsDelay(delay);
} }
s32 sndAuxCallbackShutdownDelay(SND_AUX_DELAY* delay) { bool sndAuxCallbackShutdownDelay(SND_AUX_DELAY* delay) {
if (delay->left != NULL) { if (delay->left != NULL) {
salFree(delay->left); salFree(delay->left);
salFree(delay->right); salFree(delay->right);
salFree(delay->sur); salFree(delay->sur);
} }
return 1; return TRUE;
} }

View File

@ -17,7 +17,7 @@
extern s32 ReverbHICreate(_SND_REVHI_WORK* rev, f32 coloration, f32 time, f32 mix, f32 damping, f32 preDelay, f32 crosstalk); extern bool ReverbHICreate(_SND_REVHI_WORK* rev, f32 coloration, f32 time, f32 mix, f32 damping, f32 preDelay, f32 crosstalk);
extern void ReverbHIFree(_SND_REVHI_WORK* rev); extern void ReverbHIFree(_SND_REVHI_WORK* rev);
void sndAuxCallbackReverbHI(u8 reason, SND_AUX_INFO* info, void* user) { void sndAuxCallbackReverbHI(u8 reason, SND_AUX_INFO* info, void* user) {
@ -36,16 +36,17 @@ void sndAuxCallbackReverbHI(u8 reason, SND_AUX_INFO* info, void* user) {
} }
} }
s32 sndAuxCallbackPrepareReverbHI(SND_AUX_REVERBHI *rev) { bool sndAuxCallbackPrepareReverbHI(SND_AUX_REVERBHI *rev) {
rev->tempDisableFX = 0; rev->tempDisableFX = 0;
return ReverbHICreate(&rev->rv, rev->coloration, rev->time, rev->mix, rev->damping, rev->preDelay, rev->crosstalk); return ReverbHICreate(&rev->rv, rev->coloration, rev->time, rev->mix, rev->damping, rev->preDelay, rev->crosstalk);
} }
s32 sndAuxCallbackShutdownReverbHI(SND_AUX_REVERBHI* rev) { bool sndAuxCallbackShutdownReverbHI(SND_AUX_REVERBHI* rev) {
ReverbHIFree(&rev->rv); ReverbHIFree(&rev->rv);
return 1; return TRUE;
} }
s32 sndAuxCallbackUpdateSettingsReverbHI(SND_AUX_REVERBHI *rev) { bool sndAuxCallbackUpdateSettingsReverbHI(SND_AUX_REVERBHI *rev) {
/* not in MP */ /* not in MP */
return FALSE;
} }

View File

@ -9,7 +9,7 @@ extern s8 sndActive;
extern s8 synthIdleWaitActive; extern s8 synthIdleWaitActive;
extern SynthInfo synthInfo; extern SynthInfo synthInfo;
inline s32 DoInit(u32 rate, u32 aramSize, u8 voices, u32 flags) { inline bool DoInit(u32 rate, u32 aramSize, u8 voices, u32 flags) {
dataInitStack(); dataInitStack();
dataInit(0, aramSize); dataInit(0, aramSize);
seqInit(); seqInit();
@ -20,10 +20,10 @@ inline s32 DoInit(u32 rate, u32 aramSize, u8 voices, u32 flags) {
s3dInit(flags); s3dInit(flags);
sndActive = 1; sndActive = 1;
return 0; return FALSE;
} }
s32 sndInit(u8 voices, u8 music, u8 sfx, u8 studios, s32 flags, s32 aramSize) { bool sndInit(u8 voices, u8 music, u8 sfx, u8 studios, s32 flags, s32 aramSize) {
s32 rate; s32 rate;
s32 ret; s32 ret;