minor MusyX fixes

Former-commit-id: ce047bc95cd9421978c6e194e5a02e3e0f8425b2
This commit is contained in:
Phillip Stephens 2023-10-21 16:00:13 -07:00
parent 4606f494f9
commit 5402539211
8 changed files with 47 additions and 57 deletions

View File

@ -205,7 +205,7 @@ cflags_musyx_debug = [
"-sym on",
"-D_DEBUG=1",
"-enum int",
"-D_MATH_INLINE=static",
"-Cpp_exceptions off",
]
# REL flags

View File

@ -30,9 +30,12 @@ void hwSetVirtualSampleLoopBuffer(u32 voice, void* addr, u32 len);
u16 hwGetSampleID(u32 voice);
u8 hwGetSampleType(u32 voice);
void hwChangeStudioMix(u8 studio, u32 isMaster);
void hwSetStreamLoopPS(u32 voice, u8 ps);
void hwFlushStream(void* base, u32 offset, u32 bytes, unsigned char hwStreamHandle, void (*callback)(u32),
u32 user);
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
void hwSetFilter(unsigned long v, unsigned char mode, unsigned short coefA, unsigned short coefB);
void hwLowPassFrqToCoef(unsigned long frq, unsigned short* _a0, unsigned short* _b1);
void hwSetFilter(u32 v, unsigned char mode, unsigned short coefA, unsigned short coefB);
void hwLowPassFrqToCoef(u32 frq, unsigned short* _a0, unsigned short* _b1);
#endif
extern u32 aramSize;

View File

@ -50,9 +50,9 @@ void synthActivateStudio(u8 studio, u32 isMaster, SND_STUDIO_TYPE type);
void synthDeactivateStudio(u8 studio);
u8 synthFXGetMaxVoices(u16 fid);
void synthPauseVolume(u8 volume, u16 time, u8 vGroup);
bool dataRemoveFX(u16 gid);
void voiceUnblock(u32 voice);
void voiceRemovePriority(const SYNTH_VOICE* svoice);
#ifdef __cplusplus
}
#endif

View File

@ -167,9 +167,9 @@ static inline int __fpclassifyd(double x) {
#define isinf(x) (fpclassify(x) == FP_INFINITE)
#define isfinite(x) ((fpclassify(x) > FP_INFINITE))
_MATH_INLINE float sqrtf(float x) {
const double _half = .5;
const double _three = 3.0;
extern inline float sqrtf(float x) {
static const double _half = .5;
static const double _three = 3.0;
volatile float y;
if (x > 0.0f) {

View File

@ -352,7 +352,7 @@ void hwSetVolume(unsigned long v, unsigned char table, float vol, unsigned long
}
if (hwGetITDMode(dsp_vptr)) {
SetupITD(dsp_vptr, (pan >> 16) & 0xFF);
SetupITD(dsp_vptr, (pan >> 16));
}
}
@ -435,7 +435,7 @@ u32 hwFrq2Pitch(u32 frq) { return (frq * 4096.f) / synthInfo.mixFrq; }
void hwInitSampleMem(u32 baseAddr, u32 length) {
#line 940
MUSY_ASSERT(baseAddr == 0x00000000);
MUSY_ASSERT(baseAddr==0x00000000);
aramInit(length);
}

View File

@ -5,9 +5,9 @@
#endif
static STREAM_INFO streamInfo[64];
u32 nextPublicID = 0;
u8 streamCallDelay = 0;
u8 streamCallCnt = 0;
static u32 nextPublicID = 0;
static u8 streamCallDelay = 0;
static u8 streamCallCnt = 0;
void streamInit() {
s32 i;
@ -64,7 +64,7 @@ void streamHandle() {
newsmp.extraData = &si->adpcmInfo;
newsmp.compType = 4;
#if MUSY_VERSION >= MUSY_VERSION_CHECK(1, 5, 4)
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 0)
hwSetStreamLoopPS(si->voice, si->lastPSFromBuffer);
si->adpcmInfo.initialPS = si->adpcmInfo.loopPS = si->lastPSFromBuffer;
#endif
@ -168,7 +168,6 @@ u32 sndStreamCallbackFrq(u32 msTime) {
void sndStreamARAMUpdate(u32 stid, u32 off1, u32 len1, u32 off2, u32 len2) {
u32 i; // r30
#line 0x1eb
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
i = GetPrivateIndex(stid);
@ -263,7 +262,6 @@ u32 sndStreamAllocEx(u8 prio, void* buffer, u32 samples, u32 frq, u8 vol, u8 pan
u32 i; // r31
u32 bytes; // r25
u32 j; // r28
#line 0x234
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
@ -375,7 +373,6 @@ u32 sndStreamAllocLength(u32 num, u32 flags) {
void sndStreamADPCMParameter(u32 stid, SND_ADPCMSTREAM_INFO* adpcmInfo) {
u32 j; // r31
u32 i; // r30
#line 0x2cb
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
i = GetPrivateIndex(stid);
@ -396,7 +393,6 @@ void sndStreamADPCMParameter(u32 stid, SND_ADPCMSTREAM_INFO* adpcmInfo) {
void sndStreamMixParameter(u32 stid, u8 vol, u8 pan, u8 span, u8 fxvol) {
u32 i; // r31
#line 0x2ec
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
i = GetPrivateIndex(stid);
@ -427,7 +423,6 @@ void sndStreamMixParameter(u32 stid, u8 vol, u8 pan, u8 span, u8 fxvol) {
void sndStreamMixParameterEx(u32 stid, u8 vol, u8 pan, u8 span, u8 auxa, u8 auxb) {
u32 i; // r31
#line 0x30f
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
i = GetPrivateIndex(stid);
@ -466,7 +461,7 @@ void sndStreamFrq(u32 stid, u32 frq) {
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
i = GetPrivateIndex(stid);
(i = GetPrivateIndex(stid));
if (i != -1) {
streamInfo[i].frq = frq;
if (streamInfo[i].state == 2) {
@ -486,7 +481,6 @@ void sndStreamFrq(u32 stid, u32 frq) {
void sndStreamFree(u32 stid) {
u32 i; // r31
#line 0x357
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
i = GetPrivateIndex(stid);
@ -508,10 +502,9 @@ void sndStreamFree(u32 stid) {
u32 sndStreamActivate(u32 stid) {
u32 i; // r31
u32 ret; // r28
ret = 0;
#line 0x37a
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
i = 0;
ret = 0;
hwDisableIrq();
i = GetPrivateIndex(stid);
if (i != -1) {
@ -542,7 +535,6 @@ u32 sndStreamActivate(u32 stid) {
void sndStreamDeactivate(u32 stid) {
u32 i; // r31
#line 0x3ab
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
hwDisableIrq();
i = GetPrivateIndex(stid);

View File

@ -301,11 +301,11 @@ void sndVirtualSampleARAMUpdate(unsigned short instID, void* base, unsigned long
if (len1 != 0) {
hwFlushStream(base, off1, len1, vs.streamBuffer[i].hwId, vsARAMDMACallback,
&vs.streamBuffer[i]);
(u32)&vs.streamBuffer[i]);
}
if (len2 != 0) {
hwFlushStream(base, off2, len2, vs.streamBuffer[i].hwId, vsARAMDMACallback,
&vs.streamBuffer[i]);
(u32)&vs.streamBuffer[i]);
}
if (vs.streamBuffer[i].smpType == 5) {

View File

@ -165,11 +165,7 @@ u32 vidMakeNew(SYNTH_VOICE* svoice, u32 isMaster) {
svoice->vidMasterList = isMaster ? vl : NULL;
svoice->vidList = vl;
if (isMaster != 0) {
return vid;
}
return svoice->id;
return isMaster ? vid : svoice->id;
}
u32 vidGetInternalId(u32 vid) {
@ -198,7 +194,7 @@ static void voiceInitPrioSort() {
voicePrioSortRootListRoot = 0xffff;
}
void voiceRemovePriority(SYNTH_VOICE* svoice) {
void voiceRemovePriority(const SYNTH_VOICE* svoice) {
SYNTH_VOICELIST* vps = &voicePrioSortVoices[svoice->id & 0xFF]; // r31
SYNTH_ROOTLIST* rps; // r30
if (vps->user != 1) {
@ -232,9 +228,9 @@ void voiceRemovePriority(SYNTH_VOICE* svoice) {
}
void voiceSetPriority(SYNTH_VOICE* svoice, u8 prio) {
u16 i; // r29
u16 li; // r25
SYNTH_VOICELIST* vps; // r27
u16 i; // r29
u32 v; // r26
v = (u8)svoice->id;
vps = &voicePrioSortVoices[v];
@ -250,34 +246,32 @@ void voiceSetPriority(SYNTH_VOICE* svoice, u8 prio) {
vps->prev = 0xff;
if ((vps->next = voicePrioSortVoicesRoot[prio]) != 0xFF) {
voicePrioSortVoices[voicePrioSortVoicesRoot[prio]].prev = v;
} else {
if (voicePrioSortRootListRoot != 0xFFFF) {
if (prio >= voicePrioSortRootListRoot) {
for (i = voicePrioSortRootListRoot; i != 0xFFFF; i = voicePrioSortRootList[i].next) {
if ((u16)i > prio) {
break;
}
li = i;
} else if (voicePrioSortRootListRoot != 0xFFFF) {
if (prio >= voicePrioSortRootListRoot) {
for (i = voicePrioSortRootListRoot; i != 0xFFFF; i = voicePrioSortRootList[i].next) {
if ((u16)i > prio) {
break;
}
voicePrioSortRootList[li].next = (u16)prio;
voicePrioSortRootList[prio].prev = li;
voicePrioSortRootList[prio].next = i;
if (i != 0xFFFF) {
voicePrioSortRootList[i].prev = prio;
}
} else {
voicePrioSortRootList[prio].next = voicePrioSortRootListRoot;
voicePrioSortRootList[prio].prev = 0xFFFF;
voicePrioSortRootList[voicePrioSortRootListRoot].prev = prio;
voicePrioSortRootListRoot = prio;
li = i;
}
voicePrioSortRootList[li].next = (u16)prio;
voicePrioSortRootList[prio].prev = li;
voicePrioSortRootList[prio].next = i;
if (i != 0xFFFF) {
voicePrioSortRootList[i].prev = prio;
}
} else {
voicePrioSortRootList[prio].next = 0xFFFF;
voicePrioSortRootList[prio].next = voicePrioSortRootListRoot;
voicePrioSortRootList[prio].prev = 0xFFFF;
voicePrioSortRootList[voicePrioSortRootListRoot].prev = prio;
voicePrioSortRootListRoot = prio;
}
} else {
voicePrioSortRootList[prio].next = 0xFFFF;
voicePrioSortRootList[prio].prev = 0xFFFF;
voicePrioSortRootListRoot = prio;
}
voicePrioSortVoicesRoot[prio] = v;
@ -299,7 +293,8 @@ u32 voiceAllocate(u8 priority, u8 maxVoices, u16 allocId, u8 fxFlag) {
void voiceFree(SYNTH_VOICE* svoice) {
u32 i; // r29
SYNTH_VOICELIST* sfv; // r30
MUSY_ASSERT(svoice->id != 0xFFFFFFFF);
i = 1;
MUSY_ASSERT(svoice->id!=0xFFFFFFFF);
macMakeInactive(svoice, MAC_STATE_STOPPED);
voiceRemovePriority(svoice);
svoice->addr = NULL;