mirror of https://github.com/zeldaret/mm.git
Move gAudioTatumInit and gAudioHeapInitSizes to their own file, using data-with-rodata instead of const qualifiers (#1771)
* Do not qualify gAudioHeapInitSizes with const under AVOID_UB * Move gAudioTatumInit and gAudioHeapInitSizes to their own file, move data to rodata * Space
This commit is contained in:
parent
047c505b96
commit
5a9c2871ed
11
Makefile
11
Makefile
|
@ -593,6 +593,15 @@ $(BUILD_DIR)/src/code/z_game_over.o: src/code/z_game_over.c
|
||||||
$(OBJDUMP_CMD)
|
$(OBJDUMP_CMD)
|
||||||
$(RM_MDEBUG)
|
$(RM_MDEBUG)
|
||||||
|
|
||||||
|
# Incremental link audio/session_init data into rodata
|
||||||
|
$(BUILD_DIR)/src/audio/session_init.o: src/audio/session_init.c $(BUILD_DIR)/assets/audio/soundfont_sizes.h $(BUILD_DIR)/assets/audio/sequence_sizes.h
|
||||||
|
$(CC_CHECK_COMP) $(CC_CHECK_FLAGS) $(IINC) $(CC_CHECK_WARNINGS) $(C_DEFINES) $(MIPS_BUILTIN_DEFS) -o $(@:.o=.tmp) $<
|
||||||
|
$(CC) -c $(CFLAGS) $(IINC) $(WARNINGS) $(C_DEFINES) $(MIPS_VERSION) $(ENDIAN) $(OPTFLAGS) -o $(@:.o=.tmp) $<
|
||||||
|
$(LD) -r -T linker_scripts/data_with_rodata.ld $(@:.o=.tmp) -o $@
|
||||||
|
@$(RM) $(@:.o=.tmp)
|
||||||
|
$(OBJDUMP_CMD)
|
||||||
|
$(RM_MDEBUG)
|
||||||
|
|
||||||
$(SHIFTJIS_O_FILES): $(BUILD_DIR)/src/%.o: src/%.c
|
$(SHIFTJIS_O_FILES): $(BUILD_DIR)/src/%.o: src/%.c
|
||||||
$(SHIFTJIS_CONV) -o $(@:.o=.enc.c) $<
|
$(SHIFTJIS_CONV) -o $(@:.o=.enc.c) $<
|
||||||
$(CC_CHECK_COMP) $(CC_CHECK_FLAGS) $(IINC) $(CC_CHECK_WARNINGS) $(C_DEFINES) $(MIPS_BUILTIN_DEFS) -o $@ $(@:.o=.enc.c)
|
$(CC_CHECK_COMP) $(CC_CHECK_FLAGS) $(IINC) $(CC_CHECK_WARNINGS) $(C_DEFINES) $(MIPS_BUILTIN_DEFS) -o $@ $(@:.o=.enc.c)
|
||||||
|
@ -783,8 +792,6 @@ $(BUILD_DIR)/assets/audio/sequence_font_table.o: $(BUILD_DIR)/assets/audio/seque
|
||||||
|
|
||||||
# make headers with file sizes and amounts
|
# make headers with file sizes and amounts
|
||||||
|
|
||||||
$(BUILD_DIR)/src/audio/session_config.o: $(BUILD_DIR)/assets/audio/soundfont_sizes.h $(BUILD_DIR)/assets/audio/sequence_sizes.h
|
|
||||||
|
|
||||||
$(BUILD_DIR)/assets/audio/soundfont_sizes.h: $(SOUNDFONT_O_FILES)
|
$(BUILD_DIR)/assets/audio/soundfont_sizes.h: $(SOUNDFONT_O_FILES)
|
||||||
$(AFILE_SIZES) $@ NUM_SOUNDFONTS SOUNDFONT_SIZES .rodata $^
|
$(AFILE_SIZES) $@ NUM_SOUNDFONTS SOUNDFONT_SIZES .rodata $^
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ extern AudioSpec gAudioSpecs[21];
|
||||||
|
|
||||||
// rodata
|
// rodata
|
||||||
extern const u16 gAudioEnvironmentalSfx[];
|
extern const u16 gAudioEnvironmentalSfx[];
|
||||||
extern const s16 gAudioTatumInit[];
|
extern s16 gAudioTatumInit[];
|
||||||
extern const AudioHeapInitSizes gAudioHeapInitSizes;
|
extern AudioHeapInitSizes gAudioHeapInitSizes;
|
||||||
extern AudioTable gSoundFontTable;
|
extern AudioTable gSoundFontTable;
|
||||||
extern u8 gSequenceFontTable[];
|
extern u8 gSequenceFontTable[];
|
||||||
extern u8 gSequenceTable[];
|
extern u8 gSequenceTable[];
|
||||||
|
@ -48,8 +48,6 @@ extern AudioTable gSampleBankTable;
|
||||||
extern u64* gAudioSPDataPtr;
|
extern u64* gAudioSPDataPtr;
|
||||||
extern u32 gAudioSPDataSize;
|
extern u32 gAudioSPDataSize;
|
||||||
|
|
||||||
extern AudioContext gAudioCtx; // at 0x80200C70
|
|
||||||
|
|
||||||
// other segments
|
// other segments
|
||||||
extern Mtx D_01000000;
|
extern Mtx D_01000000;
|
||||||
extern Gfx D_08000000[];
|
extern Gfx D_08000000[];
|
||||||
|
|
|
@ -261,4 +261,6 @@ typedef struct AudioContext {
|
||||||
/* 0x81F4 */ UNK_TYPE1 unk_81F4[4];
|
/* 0x81F4 */ UNK_TYPE1 unk_81F4[4];
|
||||||
} AudioContext; // size = 0x81F8
|
} AudioContext; // size = 0x81F8
|
||||||
|
|
||||||
|
extern AudioContext gAudioCtx; // at 0x80200C70
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
1
spec
1
spec
|
@ -771,6 +771,7 @@ beginseg
|
||||||
include "$(BUILD_DIR)/src/audio/sfx.o"
|
include "$(BUILD_DIR)/src/audio/sfx.o"
|
||||||
include "$(BUILD_DIR)/src/audio/sequence.o"
|
include "$(BUILD_DIR)/src/audio/sequence.o"
|
||||||
include "$(BUILD_DIR)/src/audio/session_config.o"
|
include "$(BUILD_DIR)/src/audio/session_config.o"
|
||||||
|
include "$(BUILD_DIR)/src/audio/session_init.o"
|
||||||
include "$(BUILD_DIR)/src/code/jpegutils.o"
|
include "$(BUILD_DIR)/src/code/jpegutils.o"
|
||||||
include "$(BUILD_DIR)/src/code/jpegdecoder.o"
|
include "$(BUILD_DIR)/src/code/jpegdecoder.o"
|
||||||
include "$(BUILD_DIR)/src/code/z_game_over.o"
|
include "$(BUILD_DIR)/src/code/z_game_over.o"
|
||||||
|
|
|
@ -1339,8 +1339,7 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr = AudioHeap_Alloc(&gAudioCtx.initPool, gAudioHeapInitSizes.permanentPoolSize), addr == NULL) {
|
if (addr = AudioHeap_Alloc(&gAudioCtx.initPool, gAudioHeapInitSizes.permanentPoolSize), addr == NULL) {
|
||||||
// cast away const from gAudioHeapInitSizes
|
gAudioHeapInitSizes.permanentPoolSize = 0;
|
||||||
*((u32*)&gAudioHeapInitSizes.permanentPoolSize) = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioHeap_InitPool(&gAudioCtx.permanentPool, addr, gAudioHeapInitSizes.permanentPoolSize);
|
AudioHeap_InitPool(&gAudioCtx.permanentPool, addr, gAudioHeapInitSizes.permanentPoolSize);
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "buffers.h"
|
|
||||||
#include "assets/audio/sequence_sizes.h"
|
|
||||||
#include "assets/audio/soundfont_sizes.h"
|
|
||||||
#define SFX_SEQ_SIZE Sequence_0_SIZE
|
|
||||||
#define AMBIENCE_SEQ_SIZE Sequence_1_SIZE
|
|
||||||
#define SFX_SOUNDFONTS_SIZE (Soundfont_0_SIZE + Soundfont_1_SIZE + Soundfont_2_SIZE)
|
|
||||||
|
|
||||||
static s32 sBssPad[36];
|
static s32 sBssPad[36];
|
||||||
AudioContext gAudioCtx;
|
AudioContext gAudioCtx;
|
||||||
|
@ -14,24 +8,6 @@ AudioCustomReverbFunction gAudioCustomReverbFunction;
|
||||||
AudioCustomSynthFunction gAudioCustomSynthFunction;
|
AudioCustomSynthFunction gAudioCustomSynthFunction;
|
||||||
static s32 sBssPad2[3];
|
static s32 sBssPad2[3];
|
||||||
|
|
||||||
const s16 gAudioTatumInit[] = {
|
|
||||||
0x1C00, // unused
|
|
||||||
TATUMS_PER_BEAT, // gTatumsPerBeat
|
|
||||||
};
|
|
||||||
|
|
||||||
// Sizes of everything on the init pool
|
|
||||||
#define AI_BUFFERS_SIZE (AIBUF_SIZE * ARRAY_COUNT(gAudioCtx.aiBuffers))
|
|
||||||
#define SOUNDFONT_LIST_SIZE (NUM_SOUNDFONTS * sizeof(SoundFont))
|
|
||||||
|
|
||||||
// 0x19BD0
|
|
||||||
#define PERMANENT_POOL_SIZE (SFX_SEQ_SIZE + AMBIENCE_SEQ_SIZE + SFX_SOUNDFONTS_SIZE + 0x430)
|
|
||||||
|
|
||||||
const AudioHeapInitSizes gAudioHeapInitSizes = {
|
|
||||||
ALIGN16(sizeof(gAudioHeap) - 0x100), // audio heap size
|
|
||||||
ALIGN16(PERMANENT_POOL_SIZE + AI_BUFFERS_SIZE + SOUNDFONT_LIST_SIZE + 0x40), // init pool size
|
|
||||||
ALIGN16(PERMANENT_POOL_SIZE), // permanent pool size
|
|
||||||
};
|
|
||||||
|
|
||||||
#define REVERB_INDEX_0_SETTINGS \
|
#define REVERB_INDEX_0_SETTINGS \
|
||||||
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x3000, 0, 0 }
|
{ 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x3000, 0, 0 }
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
#include "z64audio.h"
|
||||||
|
#include "buffers.h"
|
||||||
|
#include "assets/audio/sequence_sizes.h"
|
||||||
|
#include "assets/audio/soundfont_sizes.h"
|
||||||
|
|
||||||
|
#define SFX_SEQ_SIZE Sequence_0_SIZE
|
||||||
|
#define AMBIENCE_SEQ_SIZE Sequence_1_SIZE
|
||||||
|
#define SFX_SOUNDFONTS_SIZE (Soundfont_0_SIZE + Soundfont_1_SIZE + Soundfont_2_SIZE)
|
||||||
|
|
||||||
|
s16 gAudioTatumInit[] = {
|
||||||
|
0x1C00, // unused
|
||||||
|
TATUMS_PER_BEAT, // gTatumsPerBeat
|
||||||
|
};
|
||||||
|
|
||||||
|
// Sizes of everything on the init pool
|
||||||
|
#define AI_BUFFERS_SIZE (AIBUF_SIZE * ARRAY_COUNT(gAudioCtx.aiBuffers))
|
||||||
|
#define SOUNDFONT_LIST_SIZE (NUM_SOUNDFONTS * sizeof(SoundFont))
|
||||||
|
|
||||||
|
// 0x19BD0
|
||||||
|
#define PERMANENT_POOL_SIZE (SFX_SEQ_SIZE + AMBIENCE_SEQ_SIZE + SFX_SOUNDFONTS_SIZE + 0x430)
|
||||||
|
|
||||||
|
AudioHeapInitSizes gAudioHeapInitSizes = {
|
||||||
|
ALIGN16(sizeof(gAudioHeap) - 0x100), // audio heap size
|
||||||
|
ALIGN16(PERMANENT_POOL_SIZE + AI_BUFFERS_SIZE + SOUNDFONT_LIST_SIZE + 0x40), // init pool size
|
||||||
|
ALIGN16(PERMANENT_POOL_SIZE), // permanent pool size
|
||||||
|
};
|
Loading…
Reference in New Issue