mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-26 01:58:51 -05:00
Makes sequenceMap and seqLoadStatus a dynamic size (#2610)
Refactors to allow the above two arrays to be a dynamic size when the game launches, size is set during the AudioLoad_Init function.
This commit is contained in:
parent
1ce9634f65
commit
d9008938f8
@ -22,7 +22,8 @@
|
||||
|
||||
#define CALC_RESAMPLE_FREQ(sampleRate) ((float)sampleRate / (s32)gAudioContext.audioBufferParameters.frequency)
|
||||
|
||||
#define MAX_SEQUENCES 0x400
|
||||
//#define MAX_SEQUENCES 0x800
|
||||
extern size_t sequenceMapSize;
|
||||
|
||||
extern char* fontMap[256];
|
||||
|
||||
@ -917,7 +918,7 @@ typedef struct {
|
||||
/* 0x342C */ AudioPoolSplit3 temporaryCommonPoolSplit;
|
||||
/* 0x3438 */ u8 sampleFontLoadStatus[0x30];
|
||||
/* 0x3468 */ u8 fontLoadStatus[0x30];
|
||||
/* 0x3498 */ u8 seqLoadStatus[MAX_SEQUENCES];
|
||||
/* 0x3498 */ u8* seqLoadStatus;
|
||||
/* 0x3518 */ volatile u8 resetStatus;
|
||||
/* 0x3519 */ u8 audioResetSpecIdToLoad;
|
||||
/* 0x351C */ s32 audioResetFadeOutFramesLeft;
|
||||
|
@ -53,7 +53,7 @@ void AudioHeap_ResetLoadStatus(void) {
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_SEQUENCES; i++) {
|
||||
for (i = 0; i < sequenceMapSize; i++) {
|
||||
if (gAudioContext.seqLoadStatus[i] != 5) {
|
||||
gAudioContext.seqLoadStatus[i] = 0;
|
||||
}
|
||||
|
@ -77,7 +77,8 @@ void* sUnusedHandler = NULL;
|
||||
|
||||
s32 gAudioContextInitalized = false;
|
||||
|
||||
char* sequenceMap[MAX_SEQUENCES];
|
||||
char** sequenceMap;
|
||||
size_t sequenceMapSize;
|
||||
// A map of authentic sequence IDs to their cache policies, for use with sequence swapping.
|
||||
u8 seqCachePolicyMap[MAX_AUTHENTIC_SEQID];
|
||||
char* fontMap[256];
|
||||
@ -488,7 +489,7 @@ u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts) {
|
||||
return NULL;
|
||||
|
||||
u16 newSeqId = AudioEditor_GetReplacementSeq(seqId);
|
||||
if (newSeqId > MAX_SEQUENCES || !sequenceMap[newSeqId]) {
|
||||
if (newSeqId > sequenceMapSize || !sequenceMap[newSeqId]) {
|
||||
return NULL;
|
||||
}
|
||||
SequenceData sDat = ResourceMgr_LoadSeqByName(sequenceMap[newSeqId]);
|
||||
@ -1342,7 +1343,12 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
|
||||
AudioHeap_ResetStep();
|
||||
|
||||
int seqListSize = 0;
|
||||
int customSeqListSize = 0;
|
||||
char** seqList = ResourceMgr_ListFiles("audio/sequences*", &seqListSize);
|
||||
char** customSeqList = ResourceMgr_ListFiles("custom/music/*", &customSeqListSize);
|
||||
sequenceMapSize = (size_t)(seqListSize + customSeqListSize);
|
||||
sequenceMap = malloc(sequenceMapSize * sizeof(char*));
|
||||
gAudioContext.seqLoadStatus = malloc(sequenceMapSize * sizeof(char*));
|
||||
|
||||
for (size_t i = 0; i < seqListSize; i++)
|
||||
{
|
||||
@ -1357,9 +1363,7 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
|
||||
|
||||
free(seqList);
|
||||
|
||||
int customSeqListSize = 0;
|
||||
int startingSeqNum = MAX_AUTHENTIC_SEQID; // 109 is the highest vanilla sequence
|
||||
char** customSeqList = ResourceMgr_ListFiles("custom/music/*", &customSeqListSize);
|
||||
qsort(customSeqList, customSeqListSize, sizeof(char*), strcmp_sort);
|
||||
|
||||
for (size_t i = startingSeqNum; i < startingSeqNum + customSeqListSize; i++) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <libultraship/libultra.h>
|
||||
#include "global.h"
|
||||
|
||||
extern char* sequenceMap[MAX_SEQUENCES];
|
||||
extern char** sequenceMap;
|
||||
|
||||
#define PORTAMENTO_IS_SPECIAL(x) ((x).mode & 0x80)
|
||||
#define PORTAMENTO_MODE(x) ((x).mode & ~0x80)
|
||||
|
Loading…
Reference in New Issue
Block a user