External data now works on Shindou, fix glabel

This commit is contained in:
AloXado320 2022-06-03 16:30:35 -05:00
parent 75bb71fd41
commit 1876456353
6 changed files with 114 additions and 55 deletions

View file

@ -1237,13 +1237,18 @@ $(BASEPACK_LST): $(EXE_DEPEND)
@echo "$(BUILD_DIR)/sound/sequences.bin sound/sequences.bin" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sound_data.ctl sound/sound_data.ctl" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/sound_data.tbl sound/sound_data.tbl" >> $(BASEPACK_LST)
ifeq ($(VERSION),sh)
@echo "$(BUILD_DIR)/sound/sequences_header sound/sequences_header" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/ctl_header sound/ctl_header" >> $(BASEPACK_LST)
@echo "$(BUILD_DIR)/sound/tbl_header sound/tbl_header" >> $(BASEPACK_LST)
endif
@$(foreach f, $(wildcard $(SKYTILE_DIR)/*), echo $(f) gfx/$(f:$(BUILD_DIR)/%=%) >> $(BASEPACK_LST);)
@find actors -name \*.png -exec echo "{} gfx/{}" >> $(BASEPACK_LST) \;
@find levels -name \*.png -exec echo "{} gfx/{}" >> $(BASEPACK_LST) \;
@find textures -name \*.png -exec echo "{} gfx/{}" >> $(BASEPACK_LST) \;
ifeq ($(PORT_MOP_OBJS),1)
ifeq ($(PORT_MOP_OBJS),1)
@find src/extras/mop/actors -name \*.png -exec echo "{} gfx/{}" >> $(BASEPACK_LST) \;
endif
endif
# prepares the resource ZIP with base data
$(BASEPACK_PATH): $(BASEPACK_LST)
@ -1278,8 +1283,10 @@ $(CRASH_TEXTURE_C_FILES): TEXTURE_ENCODING := u32
$(BUILD_DIR)/lib/rsp.o: $(BUILD_DIR)/rsp/rspboot.bin $(BUILD_DIR)/rsp/fast3d.bin $(BUILD_DIR)/rsp/audio.bin
ifeq ($(VERSION),sh)
$(BUILD_DIR)/src/audio/load_sh.o: $(SOUND_BIN_DIR)/bank_sets.inc.c $(SOUND_BIN_DIR)/sequences_header.inc.c $(SOUND_BIN_DIR)/ctl_header.inc.c $(SOUND_BIN_DIR)/tbl_header.inc.c
ifeq ($(EXTERNAL_DATA),0)
ifeq ($(VERSION),sh)
$(BUILD_DIR)/src/audio/load_sh.o: $(SOUND_BIN_DIR)/bank_sets.inc.c $(SOUND_BIN_DIR)/sequences_header.inc.c $(SOUND_BIN_DIR)/ctl_header.inc.c $(SOUND_BIN_DIR)/tbl_header.inc.c
endif
endif
$(BUILD_DIR)/include/text_strings.h: include/text_strings.h.in
@ -1543,7 +1550,14 @@ $(SOUND_BIN_DIR)/%.inc.c: $(SOUND_BIN_DIR)/%
endif
$(SOUND_BIN_DIR)/sound_data.o: $(SOUND_BIN_DIR)/sound_data.ctl $(SOUND_BIN_DIR)/sound_data.tbl $(SOUND_BIN_DIR)/sequences.bin $(SOUND_BIN_DIR)/bank_sets
SOUND_FILES := $(SOUND_BIN_DIR)/sound_data.ctl $(SOUND_BIN_DIR)/sound_data.tbl $(SOUND_BIN_DIR)/sequences.bin $(SOUND_BIN_DIR)/bank_sets
ifeq ($(EXTERNAL_DATA),1)
ifeq ($(VERSION),sh)
SOUND_FILES += $(SOUND_BIN_DIR)/sequences_header $(SOUND_BIN_DIR)/ctl_header $(SOUND_BIN_DIR)/tbl_header
endif
endif
$(SOUND_BIN_DIR)/sound_data.o: $(SOUND_FILES)
$(BUILD_DIR)/levels/scripts.o: $(BUILD_DIR)/include/level_headers.h

View file

@ -82,6 +82,9 @@ endif
# Check for external data
ifeq ($(EXTERNAL_DATA),1)
CUSTOM_C_DEFINES += -DEXTERNAL_DATA
ifeq ($(TARGET_N64),1)
$(error External data is not usable on N64)
endif
endif
# Use PC-only exclusive defines

View file

@ -1,13 +1,24 @@
// Assembly Macros
#if defined(__APPLE__)
.macro .section label
\label
.endm
#endif
#if defined(__APPLE__) || (defined(__MINGW32__) && !defined(__MINGW64__))
# define cdecl(s) _##s
#else
# define cdecl(s) s
#endif
.set K0BASE, 0x80000000
.set K1BASE, 0xA0000000
.set K2BASE, 0xC0000000
.macro glabel label
.global \label
.global cdecl(\label)
.balign 4
\label:
cdecl(\label):
.endm
.macro .word32 x

View file

@ -2,36 +2,56 @@
.section .data
glabel gSoundDataADSR
#ifdef EXTERNAL_DATA
.ascii "sound/sound_data.ctl"
#define SOUND_FILE(file) .ascii file
#define SKIP(num) .skip num
#else
.incbin "sound/sound_data.ctl"
#define SOUND_FILE(file) .incbin file
#define SKIP(num)
#endif
glabel gSoundDataADSR
SOUND_FILE("sound/sound_data.ctl")
SKIP(4)
.balign 16
glabel gSoundDataRaw
#ifdef EXTERNAL_DATA
.ascii "sound/sound_data.tbl"
#else
.incbin "sound/sound_data.tbl"
#endif
SOUND_FILE("sound/sound_data.tbl")
SKIP(4)
.balign 16
glabel gMusicData
#ifdef EXTERNAL_DATA
.ascii "sound/sequences.bin"
#else
.incbin "sound/sequences.bin"
#endif
SOUND_FILE("sound/sequences.bin")
SKIP(4)
.balign 16
#ifndef VERSION_SH
glabel gBankSetsData
#ifdef EXTERNAL_DATA
.ascii "sound/bank_sets"
#else
.incbin "sound/bank_sets"
#endif
SOUND_FILE("sound/bank_sets")
SKIP(4)
.balign 16
#endif
#if defined(EXTERNAL_DATA) && defined(VERSION_SH)
glabel gBankSetsData
SOUND_FILE("sound/bank_sets")
SKIP(4)
.balign 16
glabel gShindouSequencesHeader
SOUND_FILE("sound/sequences_header")
SKIP(4)
.balign 16
glabel gShindouSoundBanksHeader
SOUND_FILE("sound/ctl_header")
SKIP(4)
.balign 16
glabel gShindouSampleBanksHeader
SOUND_FILE("sound/tbl_header")
SKIP(4)
.balign 16
#endif

View file

@ -7,7 +7,7 @@
#include "load.h"
#include "seqplayer.h"
#if defined(EXTERNAL_DATA) || !defined(TARGET_N64)
#ifdef EXTERNAL_DATA
#include "pc/platform.h"
#include "pc/fs/fs.h"
#endif
@ -103,18 +103,10 @@ s8 gAudioUpdatesPerFrame;
extern u64 gAudioGlobalsStartMarker;
extern u64 gAudioGlobalsEndMarker;
// Make sure to tell non N64 compilers they are in an asm file
#ifdef TARGET_N64
extern u8 gSoundDataADSR[]; // sound_data.ctl
extern u8 gSoundDataRaw[]; // sound_data.tbl
extern u8 gMusicData[]; // sequences.s
extern u8 gBankSetsData[]; // bank_sets.s
#else
extern u8 gSoundDataADSR[] asm("gSoundDataADSR"); // sound_data.ctl
extern u8 gSoundDataRaw[] asm("gSoundDataRaw"); // sound_data.tbl
extern u8 gMusicData[] asm("gMusicData"); // sequences.s
extern u8 gBankSetsData[] asm("gBankSetsData"); // bank_sets.s
#endif
extern u8 gMusicData[]; // sequences.bin
extern u8 gBankSetsData[]; // bank_sets
ALSeqFile *get_audio_file_header(s32 arg0);

View file

@ -7,6 +7,11 @@
#include "load.h"
#include "seqplayer.h"
#ifdef EXTERNAL_DATA
#include "pc/platform.h"
#include "pc/fs/fs.h"
#endif
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
struct SharedDma {
@ -105,17 +110,6 @@ s8 gAudioUpdatesPerFrame;
extern u64 gAudioGlobalsStartMarker;
extern u64 gAudioGlobalsEndMarker;
// Hack: MINGW32 doesn't properly detect these defines in sound_data.s
#if !IS_64_BIT && defined(__MINGW32__)
extern u8 gSoundDataADSR[] asm("gSoundDataADSR"); // sound_data.ctl
extern u8 gSoundDataRaw[] asm("gSoundDataRaw"); // sound_data.tbl
extern u8 gMusicData[] asm("gMusicData"); // sequences.s
#else
extern u8 gSoundDataADSR[]; // ctl
extern u8 gSoundDataRaw[]; // tbl
extern u8 gMusicData[]; // sequences
#endif
ALSeqFile *get_audio_file_header(s32 arg0);
void *func_sh_802f3688(s32 bankId);
@ -997,7 +991,22 @@ void func_sh_802f41e4(s32 audioResetStatus) {
func_sh_802f4dcc(audioResetStatus);
}
#if defined(VERSION_SH)
#ifdef EXTERNAL_DATA
# define LOAD_DATA(x) load_sound_res((const char *)x)
# include <stdio.h>
# include <stdlib.h>
static inline void *load_sound_res(const char *path) {
void *data = fs_load_file(path, NULL);
if (!data) sys_fatal("could not load sound data from '%s'", path);
// FIXME: figure out where it is safe to free this shit
// can't free it immediately after in audio_init()
return data;
}
#else
# define LOAD_DATA(x) x
#endif
#ifndef EXTERNAL_DATA
u8 gShindouSoundBanksHeader[] = {
#include "sound/ctl_header.inc.c"
};
@ -1015,6 +1024,16 @@ u8 gShindouSequencesHeader[] = {
};
#endif
extern u8 gSoundDataADSR[]; // sound_data.ctl
extern u8 gSoundDataRaw[]; // sound_data.tbl
extern u8 gMusicData[]; // sequences.bin
#ifdef EXTERNAL_DATA
extern u8 gBankSetsData[]; // bank_sets
extern u8 gShindouSequencesHeader[]; // sequences_header
extern u8 gShindouSoundBanksHeader[]; // ctl_header
extern u8 gShindouSampleBanksHeader[]; // tbl_header
#endif
// (void) must be omitted from parameters
void audio_init() {
UNUSED s8 pad[16]; // SH - 52
@ -1096,14 +1115,14 @@ void audio_init() {
eu_stubbed_printf_0("Main Heap Initialize.\n");
// Load headers for sounds and sequences
gSeqFileHeader = (ALSeqFile *) gShindouSequencesHeader;
gAlCtlHeader = (ALSeqFile *) gShindouSoundBanksHeader;
gAlTbl = (ALSeqFile *) gShindouSampleBanksHeader;
gAlBankSets = gBankSetsData;
gSeqFileHeader = LOAD_DATA((ALSeqFile *) gShindouSequencesHeader);
gAlCtlHeader = LOAD_DATA((ALSeqFile *) gShindouSoundBanksHeader);
gAlTbl = LOAD_DATA((ALSeqFile *) gShindouSampleBanksHeader);
gAlBankSets = LOAD_DATA(gBankSetsData);
gSequenceCount = (s16) gSeqFileHeader->seqCount;
patch_seq_file(gSeqFileHeader, gMusicData, D_SH_80315EF4);
patch_seq_file(gAlCtlHeader, gSoundDataADSR, D_SH_80315EF8);
patch_seq_file(gAlTbl, gSoundDataRaw, D_SH_80315EFC);
patch_seq_file(gSeqFileHeader, LOAD_DATA(gMusicData), D_SH_80315EF4);
patch_seq_file(gAlCtlHeader, LOAD_DATA(gSoundDataADSR), D_SH_80315EF8);
patch_seq_file(gAlTbl, LOAD_DATA(gSoundDataRaw), D_SH_80315EFC);
seqCount = gAlCtlHeader->seqCount;
gCtlEntries = sound_alloc_uninitialized(&gAudioInitPool, seqCount * sizeof(struct CtlEntry));
for (i = 0; i < seqCount; i++) {