Minor MusyX cleanup

Former-commit-id: 8ddaa42dce
This commit is contained in:
Phillip Stephens 2023-08-01 14:45:19 -07:00
parent d46423af7e
commit b130648638
3 changed files with 35 additions and 20 deletions

View File

@ -1,15 +1,16 @@
#include "musyx/musyx_priv.h" #include "musyx/musyx_priv.h"
#include "musyx/synth.h" #include "musyx/synth.h"
u8 s3dCallCnt; static u8 s3dCallCnt;
SND_DOOR* s3dDoorRoot; static SND_EMITTER* s3dEmitterRoot;
SND_EMITTER* s3dEmitterRoot; static SND_LISTENER* s3dListenerRoot;
SND_LISTENER* s3dListenerRoot; static SND_ROOM* s3dRoomRoot;
SND_ROOM* s3dRoomRoot; static SND_DOOR* s3dDoorRoot;
u8 s3dUseMaxVoices; static u32 snd_used_studios;
u8 snd_base_studio; static u8 snd_base_studio;
u8 snd_max_studios; static u8 snd_max_studios;
u32 snd_used_studios; static u8 s3dUseMaxVoices;
static void UpdateRoomDistances() { static void UpdateRoomDistances() {
SND_ROOM* r; // r30 SND_ROOM* r; // r30
@ -840,14 +841,32 @@ void sndSetup3DStudios(unsigned char first, unsigned char num) {
snd_max_studios = num; snd_max_studios = num;
} }
void sndGet3DParameters(SND_3DINFO* info, SND_FVECTOR* pos, SND_FVECTOR* dir, float maxDis, void sndGet3DParameters(SND_3DINFO* info, SND_FVECTOR* pos, SND_FVECTOR* dir, f32 maxDis, f32 comp,
float comp, unsigned char maxVol, unsigned char minVol, u8 maxVol, u8 minVol, SND_ROOM* room) {
struct SND_ROOM* room) {
float xPan; // r1+0x34 float xPan; // r1+0x34
float yPan; // r1+0x30 float yPan; // r1+0x30
float zPan; // r1+0x2C float zPan; // r1+0x2C
float cvol; // r1+0x28 float cvol; // r1+0x28
float pitch; // r1+0x24 float pitch; // r1+0x24
static SND_EMITTER em;
hwDisableIrq();
em.flags = 8;
em.pos = *pos;
em.dir = *dir;
em.maxDis = maxDis;
em.maxVol = maxVol / 127.f;
em.minVol = minVol / 127.f;
em.volPush = comp;
em.room = room;
CalcEmitter(&em, &cvol, &pitch, &xPan, &yPan, &zPan);
info->vol = clip127(cvol * 127.f);
info->pan = clip127((xPan + 1.f) * 64.f);
info->span = clip127((1.f - zPan) * 64.f);
info->doppler = clip3FFF(pitch * 8192.f);
hwEnableIrq();
} }
void s3dInit(u32 flags) { void s3dInit(u32 flags) {

View File

@ -387,7 +387,6 @@ u8 inpGetMidiLastNote(u8 midi, u8 midiSet) {
return fx_lastNote[midi]; return fx_lastNote[midi];
} }
#pragma dont_inline on
static u16 _GetInputValue(SYNTH_VOICE* svoice, CTRL_DEST* inp, u8 midi, u8 midiSet) { static u16 _GetInputValue(SYNTH_VOICE* svoice, CTRL_DEST* inp, u8 midi, u8 midiSet) {
u32 i; // r26 u32 i; // r26
u32 value; // r29 u32 value; // r29
@ -447,8 +446,6 @@ static u16 _GetInputValue(SYNTH_VOICE* svoice, CTRL_DEST* inp, u8 midi, u8 midiS
return value; return value;
} }
#pragma dont_inline reset
static u16 GetInputValue(SYNTH_VOICE* svoice, CTRL_DEST* inp, u32 dirtyMask) { static u16 GetInputValue(SYNTH_VOICE* svoice, CTRL_DEST* inp, u32 dirtyMask) {
if (!(svoice->midiDirtyFlags & dirtyMask)) { if (!(svoice->midiDirtyFlags & dirtyMask)) {
@ -501,13 +498,12 @@ u16 inpGetTremolo(SYNTH_VOICE* svoice) {
return GetInputValue(svoice, &svoice->inpTremolo, 0x1000); return GetInputValue(svoice, &svoice->inpTremolo, 0x1000);
} }
u16 inpGetAuxB(u8 studio, u8 index, u8 midi, u8 midiSet) { u16 inpGetAuxA(u8 studio, u8 index, u8 midi, u8 midiSet) {
static u32 dirtyMask[4] = {0x80000001, 0x80000002, 0x80000004, 0x80000008}; static u32 dirtyMask[4] = {0x80000001, 0x80000002, 0x80000004, 0x80000008};
return GetGlobalInputValue(&inpAuxA[studio][index], dirtyMask[index], midi, midiSet); return GetGlobalInputValue(&inpAuxA[studio][index], dirtyMask[index], midi, midiSet);
} }
u16 inpGetAuxA(u8 studio, u8 index, u8 midi, u8 midiSet) { u16 inpGetAuxB(u8 studio, u8 index, u8 midi, u8 midiSet) {
static u32 dirtyMask[4] = {0x80000010, 0x80000020, 0x80000040, 0x80000080}; static u32 dirtyMask[4] = {0x80000010, 0x80000020, 0x80000040, 0x80000080};
return GetGlobalInputValue(&inpAuxB[studio][index], dirtyMask[index], midi, midiSet); return GetGlobalInputValue(&inpAuxB[studio][index], dirtyMask[index], midi, midiSet);