mirror of https://github.com/PrimeDecomp/prime.git
Fully match seq_api.c
This commit is contained in:
parent
e5668e767e
commit
c03eb111e7
|
@ -383,7 +383,7 @@ LIBS = [
|
||||||
"WorldFormat/CAreaOctTree",
|
"WorldFormat/CAreaOctTree",
|
||||||
["WorldFormat/CMetroidAreaCollider", False],
|
["WorldFormat/CMetroidAreaCollider", False],
|
||||||
["WorldFormat/CWorldLight", False],
|
["WorldFormat/CWorldLight", False],
|
||||||
"WorldFormat/COBBTree",
|
["WorldFormat/COBBTree", False],
|
||||||
"WorldFormat/CCollidableOBBTree",
|
"WorldFormat/CCollidableOBBTree",
|
||||||
"WorldFormat/CCollidableOBBTreeGroup",
|
"WorldFormat/CCollidableOBBTreeGroup",
|
||||||
"WorldFormat/CPVSAreaSet",
|
"WorldFormat/CPVSAreaSet",
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
#ifndef _MUSYX_MUSYX_PRIV
|
#ifndef _MUSYX_MUSYX_PRIV
|
||||||
#define _MUSYX_MUSYX_PRIV
|
#define _MUSYX_MUSYX_PRIV
|
||||||
|
|
||||||
#include "musyx/assert.h"
|
|
||||||
#include "musyx/musyx.h"
|
#include "musyx/musyx.h"
|
||||||
|
#include "musyx/assert.h"
|
||||||
|
#include "musyx/hardware.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -1015,6 +1016,8 @@ void streamOutputModeChanged();
|
||||||
u8 inpTranslateExCtrl(u8 ctrl);
|
u8 inpTranslateExCtrl(u8 ctrl);
|
||||||
void inpSetGlobalMIDIDirtyFlag(u8 chan, u8 midiSet, s32 flag);
|
void inpSetGlobalMIDIDirtyFlag(u8 chan, u8 midiSet, s32 flag);
|
||||||
void inpAddCtrl(struct CTRL_DEST* dest, u8 ctrl, long scale, u8 comb, u32 isVar);
|
void inpAddCtrl(struct CTRL_DEST* dest, u8 ctrl, long scale, u8 comb, u32 isVar);
|
||||||
|
void inpSetMidiCtrl(unsigned char ctrl, unsigned char channel, unsigned char set, unsigned char value);
|
||||||
|
void inpSetMidiCtrl14(unsigned char ctrl, unsigned char channel, unsigned char set, u16 value);
|
||||||
void inpSetExCtrl(SYNTH_VOICE* svoice, u8 ctrl, s16 v);
|
void inpSetExCtrl(SYNTH_VOICE* svoice, u8 ctrl, s16 v);
|
||||||
CHANNEL_DEFAULTS* inpGetChannelDefaults(u8 midi, u8 midiSet);
|
CHANNEL_DEFAULTS* inpGetChannelDefaults(u8 midi, u8 midiSet);
|
||||||
extern CTRL_DEST inpAuxA[8][4];
|
extern CTRL_DEST inpAuxA[8][4];
|
||||||
|
|
|
@ -163,13 +163,15 @@ extern u8 synthTrackVolume[64];
|
||||||
extern SEQ_INSTANCE seqInstance[8];
|
extern SEQ_INSTANCE seqInstance[8];
|
||||||
extern u16 seqMIDIPriority[8][16];
|
extern u16 seqMIDIPriority[8][16];
|
||||||
|
|
||||||
|
void seqSpeed(unsigned long seqId, unsigned short speed);
|
||||||
|
void seqVolume(unsigned char volume, unsigned short time, unsigned long seqId, unsigned char mode);
|
||||||
void sndSeqStop(s32 unk);
|
void sndSeqStop(s32 unk);
|
||||||
void sndSeqSpeed(s32 unk1, s32 unk2);
|
void sndSeqSpeed(u32 seqId, u16 speed);
|
||||||
void sndSeqContinue(s32 unk);
|
void sndSeqContinue(s32 unk);
|
||||||
void sndSeqMute(s32 unk1, s32 unk2, s32 unk3);
|
void sndSeqMute(s32 unk1, s32 unk2, s32 unk3);
|
||||||
void sndSeqVolume(s32 unk1, s32 unk2, s32 unk3, s32 unk4);
|
void sndSeqVolume(unsigned char volume, unsigned short time, unsigned long seqId, unsigned char mode);
|
||||||
void seqStop(unsigned long seqId);
|
void seqStop(unsigned long seqId);
|
||||||
u16 seqGetMIDIPriority(s32 unk1, s32 unk2);
|
u16 seqGetMIDIPriority(u8 set, u8 channel);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,357 @@
|
||||||
#include "musyx/seq.h"
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "musyx/hardware.h"
|
||||||
|
#include "musyx/seq.h"
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
void sndSeqCrossFade(struct SND_CROSSFADE* ci, unsigned long* new_seqId) {
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
|
|
||||||
|
MUSY_ASSERT_MSG(ci != NULL, "Crossfade information pointer is NULL.");
|
||||||
|
MUSY_ASSERT_MSG(ci->studio2 < 8, "Studio index is illegal.");
|
||||||
|
MUSY_ASSERT_MSG(hwIsStudioActive(ci->studio2), "Selected studio is inactive.");
|
||||||
|
|
||||||
|
hwDisableIrq();
|
||||||
|
|
||||||
|
seqCrossFade(ci, new_seqId, 0);
|
||||||
|
|
||||||
|
hwEnableIrq();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
u32 sndSeqCrossFadeDone(u32* new_seqId) {
|
||||||
|
if (*new_seqId != -1) {
|
||||||
|
return (*new_seqId & 0x80000000) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 sndSeqGetLoopCnt(u32 seqId) {
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
|
|
||||||
|
seqId = seqGetPrivateId(seqId);
|
||||||
|
if (seqId != -1 && (seqId & 0x80000000) == 0) {
|
||||||
|
return seqInstance[seqId].section[0].loopCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
u16 sndSeqGetLoopCntEx(u32 seqId, u8 track) {
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
|
|
||||||
|
seqId = seqGetPrivateId(seqId);
|
||||||
|
if (seqId != -1 && (seqId & 0x80000000) == 0) {
|
||||||
|
if (seqInstance[seqId].trackSectionTab == NULL) {
|
||||||
|
return seqInstance[seqId].section[0].loopCnt;
|
||||||
|
} else {
|
||||||
|
return seqInstance[seqId].section[seqInstance[seqId].trackSectionTab[track]].loopCnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
unsigned long sndSeqGetValid(unsigned long seqId) {
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
|
|
||||||
|
return seqGetPrivateId(seqId) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
void sndSeqPause(s32 unk) {
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
|
hwDisableIrq();
|
||||||
|
seqPause(unk);
|
||||||
|
hwEnableIrq();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
void sndSeqStop(s32 unk) {
|
void sndSeqStop(s32 unk) {
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
hwDisableIrq();
|
hwDisableIrq();
|
||||||
seqStop(unk);
|
seqStop(unk);
|
||||||
hwEnableIrq();
|
hwEnableIrq();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sndSeqSpeed(s32 unk1, s32 unk2) {
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
unsigned long sndSeqLoop(unsigned long seqId, bool on) {
|
||||||
|
unsigned long i; // r30
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
|
|
||||||
|
if ((seqId = seqGetPrivateId(seqId)) != -1) {
|
||||||
|
if ((seqId & 0x80000000) == 0) {
|
||||||
|
for (i = 0; i < 16; ++i) {
|
||||||
|
seqInstance[seqId].section[i].loopDisable = !on;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MUSY_DEBUG("Sequencer ID is temporary.\n");
|
||||||
|
} else {
|
||||||
|
MUSY_DEBUG("Sequencer ID is not valid.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
unsigned long sndSeqLoopEx(unsigned long seqId, unsigned char track, bool on) {
|
||||||
|
unsigned long i; // r29
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
|
|
||||||
|
if ((seqId = seqGetPrivateId(seqId)) != -1) {
|
||||||
|
if ((seqId & 0x80000000) == 0) {
|
||||||
|
if (seqInstance[seqId].trackSectionTab == NULL) {
|
||||||
|
for (i = 0; i < 16; ++i) {
|
||||||
|
seqInstance[seqId].section[i].loopDisable = !on;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
seqInstance[seqId].section[seqInstance[seqId].trackSectionTab[track]].loopDisable = !on;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MUSY_DEBUG("Sequencer ID is temporary.\n");
|
||||||
|
} else {
|
||||||
|
MUSY_DEBUG("Sequencer ID is not valid.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
void sndSeqSpeed(u32 seqId, u16 speed) {
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
hwDisableIrq();
|
hwDisableIrq();
|
||||||
seqSpeed(unk1, unk2);
|
seqSpeed(seqId, speed);
|
||||||
hwEnableIrq();
|
hwEnableIrq();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
void sndSeqContinue(s32 unk) {
|
void sndSeqContinue(s32 unk) {
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
hwDisableIrq();
|
hwDisableIrq();
|
||||||
seqContinue(unk);
|
seqContinue(unk);
|
||||||
hwEnableIrq();
|
hwEnableIrq();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
void sndSeqMute(s32 unk1, s32 unk2, s32 unk3) {
|
void sndSeqMute(s32 unk1, s32 unk2, s32 unk3) {
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
hwDisableIrq();
|
hwDisableIrq();
|
||||||
seqMute(unk1, unk2, unk3);
|
seqMute(unk1, unk2, unk3);
|
||||||
hwEnableIrq();
|
hwEnableIrq();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sndSeqVolume(s32 unk1, s32 unk2, s32 unk3, s32 unk4) {
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
void sndSeqVolume(unsigned char volume, unsigned short time, unsigned long seqId,
|
||||||
|
unsigned char mode) {
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
hwDisableIrq();
|
hwDisableIrq();
|
||||||
seqVolume(unk1, unk2, unk3, unk4);
|
seqVolume(volume, time, seqId, mode);
|
||||||
hwEnableIrq();
|
hwEnableIrq();
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 seqGetMIDIPriority(s32 arg0, s32 arg1) { return seqMIDIPriority[(u8)arg0][(u8)arg1]; }
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
unsigned char sndSeqGetVolGroup(unsigned long seqId) {
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
|
if ((seqId = seqGetPrivateId(seqId)) != -1) {
|
||||||
|
return seqInstance[seqId].defVGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
MUSY_DEBUG("Volume group could not be received from sequencer.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
unsigned long sndSeqAssignVolGroup2Track(unsigned long seqId, unsigned char track,
|
||||||
|
unsigned char vGroup) {
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
|
|
||||||
|
if ((seqId = seqGetPrivateId(seqId)) != -1) {
|
||||||
|
seqInstance[seqId].trackVolGroup[track] = vGroup;
|
||||||
|
synthSetMusicVolumeType(vGroup, 2);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MUSY_DEBUG("Volume group could not be assigned to track.\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
unsigned char sndSeqGetMidiCtrl(unsigned long seqId, unsigned char channel, unsigned char ctrl) {
|
||||||
|
unsigned char value; // r31
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
|
|
||||||
|
value = 0;
|
||||||
|
hwDisableIrq();
|
||||||
|
|
||||||
|
if ((seqId = seqGetPrivateId(seqId)) != -1) {
|
||||||
|
value = inpGetMidiCtrl(ctrl, channel, seqId) >> 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
hwEnableIrq();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
unsigned short sndSeqGetMidiCtrl14(unsigned long seqId, unsigned char channel, unsigned char ctrl) {
|
||||||
|
unsigned short value; // r31
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
|
|
||||||
|
value = 0;
|
||||||
|
hwDisableIrq();
|
||||||
|
|
||||||
|
if ((seqId = seqGetPrivateId(seqId)) != -1) {
|
||||||
|
value = inpGetMidiCtrl(ctrl, channel, seqId);
|
||||||
|
}
|
||||||
|
|
||||||
|
hwEnableIrq();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
*/
|
||||||
|
unsigned long sndSeqSetMidiCtrl(unsigned long seqId, unsigned char channel, unsigned char ctrl,
|
||||||
|
unsigned char value) {
|
||||||
|
unsigned long ret = FALSE; // r30
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
|
hwDisableIrq();
|
||||||
|
if ((seqId = seqGetPrivateId(seqId)) != -1) {
|
||||||
|
inpSetMidiCtrl(ctrl, channel, seqId, value);
|
||||||
|
ret = TRUE;
|
||||||
|
} else {
|
||||||
|
MUSY_DEBUG("Sequenzer ID is not valid.\n\n");
|
||||||
|
}
|
||||||
|
hwEnableIrq();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
unsigned long sndSeqSetMidiCtrl14(unsigned long seqId, unsigned char channel, unsigned char ctrl,
|
||||||
|
unsigned short value) {
|
||||||
|
unsigned long ret = FALSE; // r30
|
||||||
|
MUSY_ASSERT_MSG(sndActive, "Sound system is not initialized.");
|
||||||
|
hwDisableIrq();
|
||||||
|
if ((seqId = seqGetPrivateId(seqId)) != -1) {
|
||||||
|
inpSetMidiCtrl14(ctrl, channel, seqId, value);
|
||||||
|
ret = TRUE;
|
||||||
|
} else {
|
||||||
|
MUSY_DEBUG("Sequenzer ID is not valid.\n\n");
|
||||||
|
}
|
||||||
|
hwEnableIrq();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 seqGetMIDIPriority(u8 set, u8 channel) { return seqMIDIPriority[set][channel]; }
|
||||||
|
|
|
@ -34,7 +34,7 @@ void vidInit() {
|
||||||
lvl->next = NULL;
|
lvl->next = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VID_LIST* get_vidlist(u32 vid) {
|
static VID_LIST* get_vidlist(u32 vid) {
|
||||||
VID_LIST* vl = vidRoot;
|
VID_LIST* vl = vidRoot;
|
||||||
while (vl != NULL) {
|
while (vl != NULL) {
|
||||||
if (vl->vid == vid) {
|
if (vl->vid == vid) {
|
||||||
|
@ -49,7 +49,7 @@ VID_LIST* get_vidlist(u32 vid) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 get_newvid() {
|
static u32 get_newvid() {
|
||||||
u32 vid; // r31
|
u32 vid; // r31
|
||||||
do {
|
do {
|
||||||
vid = vidCurrentId++;
|
vid = vidCurrentId++;
|
||||||
|
@ -58,7 +58,7 @@ u32 get_newvid() {
|
||||||
return vid;
|
return vid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vidRemove(VID_LIST** vidList) {
|
static void vidRemove(VID_LIST** vidList) {
|
||||||
if ((*vidList)->prev != NULL) {
|
if ((*vidList)->prev != NULL) {
|
||||||
(*vidList)->prev->next = (*vidList)->next;
|
(*vidList)->prev->next = (*vidList)->next;
|
||||||
} else {
|
} else {
|
||||||
|
@ -184,7 +184,7 @@ u32 vidGetInternalId(u32 vid) {
|
||||||
return 0xffffffff;
|
return 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void voiceInitPrioSort() {
|
static void voiceInitPrioSort() {
|
||||||
u32 i;
|
u32 i;
|
||||||
|
|
||||||
for (i = 0; i < synthInfo.voiceNum; ++i) {
|
for (i = 0; i < synthInfo.voiceNum; ++i) {
|
||||||
|
@ -328,7 +328,7 @@ void voiceFree(SYNTH_VOICE* svoice) {
|
||||||
svoice->id = 0xFFFFFFFF;
|
svoice->id = 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void voiceInitFreeList() {
|
static void voiceInitFreeList() {
|
||||||
u32 i; // r31
|
u32 i; // r31
|
||||||
|
|
||||||
for (i = 0; i < synthInfo.voiceNum; ++i) {
|
for (i = 0; i < synthInfo.voiceNum; ++i) {
|
||||||
|
|
Loading…
Reference in New Issue