From e982c44721a76972de0e16a971e6447fc68f3f67 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 7 Sep 2024 16:03:00 -0600 Subject: [PATCH] Import data + bss (#1676) * extract gfxprint font data as blobs * Remove font from fault_drawer out name * audio heap bss * audio sequence bss * audio session config bss * Move code_801D1E80 down in the spec * Gfxprint don't just include generated c file --- assets/xml/boot/fault_drawer.xml | 2 +- assets/xml/boot/gfxprint.xml | 9 +++++++++ include/sequence.h | 4 ++-- include/variables.h | 5 ----- include/z64audio.h | 2 +- spec | 5 +---- src/audio/lib/heap.c | 3 +++ src/audio/sequence.c | 8 ++++++++ src/audio/session_config.c | 8 ++++++++ src/boot/O2/gfxprint.c | 24 +++++++++++++++++------- tools/disasm/files.txt | 1 + tools/disasm/variables.txt | 5 +---- 12 files changed, 52 insertions(+), 24 deletions(-) create mode 100644 assets/xml/boot/gfxprint.xml diff --git a/assets/xml/boot/fault_drawer.xml b/assets/xml/boot/fault_drawer.xml index 95386a353b..ac1296007e 100644 --- a/assets/xml/boot/fault_drawer.xml +++ b/assets/xml/boot/fault_drawer.xml @@ -1,5 +1,5 @@ - + diff --git a/assets/xml/boot/gfxprint.xml b/assets/xml/boot/gfxprint.xml new file mode 100644 index 0000000000..7446095849 --- /dev/null +++ b/assets/xml/boot/gfxprint.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/include/sequence.h b/include/sequence.h index 2ec8ae53b7..26a81658ce 100644 --- a/include/sequence.h +++ b/include/sequence.h @@ -407,9 +407,9 @@ u8 func_801A3950(u8 seqPlayerIndex, u8 resetChannelIO); u8 func_801A39F8(void); s32 func_801A46F8(void); -extern SeqRequest sSeqRequests[][5]; +extern SeqRequest sSeqRequests[5][5]; extern u8 sNumSeqRequests[5]; extern u32 sAudioSeqCmds[0x100]; -extern ActiveSequence gActiveSeqs[]; +extern ActiveSequence gActiveSeqs[5]; #endif diff --git a/include/variables.h b/include/variables.h index 57a7077a10..961b1a2f1b 100644 --- a/include/variables.h +++ b/include/variables.h @@ -48,11 +48,6 @@ extern AudioTable gSampleBankTable; extern u64* gAudioSPDataPtr; extern u32 gAudioSPDataSize; -extern s32 D_801FD120; - -extern u8 sResetAudioHeapTimer; -extern u16 sResetAudioHeapFadeReverbVolume; -extern u16 sResetAudioHeapFadeReverbVolumeStep; extern AudioContext gAudioCtx; // at 0x80200C70 // other segments diff --git a/include/z64audio.h b/include/z64audio.h index 41ae767751..68fc2f8a4f 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -132,7 +132,7 @@ typedef struct { /* 0x48 */ char unk_48[0x8]; } AudioTask; // size = 0x50 -typedef struct { +typedef struct AudioContext { /* 0x0000 */ char unk_0000; /* 0x0001 */ s8 numSynthesisReverbs; /* 0x0002 */ u16 unk_2; // reads from audio spec unk_14, never used, always set to 0x7FFF diff --git a/spec b/spec index 49cf92fdaf..4b52c0f829 100644 --- a/spec +++ b/spec @@ -38,7 +38,6 @@ beginseg include "$(BUILD_DIR)/src/boot/O2/padutils.o" include "$(BUILD_DIR)/src/boot/O2/stackcheck.o" include "$(BUILD_DIR)/src/boot/O2/gfxprint.o" - include "$(BUILD_DIR)/data/boot/gfxprint.data.o" include "$(BUILD_DIR)/src/boot/O2/mtxuty-cvt.o" include "$(BUILD_DIR)/src/boot/O2/debug.o" include "$(BUILD_DIR)/src/boot/O2/system_heap.o" @@ -617,20 +616,19 @@ beginseg include "$(BUILD_DIR)/src/code/sys_matrix.o" include "$(BUILD_DIR)/src/code/sys_ucode.o" include "$(BUILD_DIR)/src/code/sys_rumble.o" - include "$(BUILD_DIR)/data/code/code_801D1E80.data.o" include "$(BUILD_DIR)/src/code/code_80183070.o" include "$(BUILD_DIR)/src/code/c_keyframe.o" include "$(BUILD_DIR)/src/code/sys_slowly.o" include "$(BUILD_DIR)/src/code/sys_flashrom.o" include "$(BUILD_DIR)/asm/code/kanread.text.o" // handwritten include "$(BUILD_DIR)/src/code/osFlash.o" + include "$(BUILD_DIR)/data/code/code_801D1E80.data.o" pad_text pad_text pad_text include "$(BUILD_DIR)/src/audio/lib/data.o" include "$(BUILD_DIR)/src/audio/lib/synthesis.o" include "$(BUILD_DIR)/src/audio/lib/heap.o" - include "$(BUILD_DIR)/data/code/audio_heap.bss.o" include "$(BUILD_DIR)/src/audio/lib/load.o" include "$(BUILD_DIR)/src/audio/lib/thread.o" include "$(BUILD_DIR)/src/audio/lib/dcache.o" @@ -649,7 +647,6 @@ beginseg include "$(BUILD_DIR)/src/audio/sfx_params.o" include "$(BUILD_DIR)/src/audio/sfx.o" include "$(BUILD_DIR)/src/audio/sequence.o" - include "$(BUILD_DIR)/data/code/sequence.bss.o" include "$(BUILD_DIR)/src/audio/session_config.o" include "$(BUILD_DIR)/src/code/jpegutils.o" include "$(BUILD_DIR)/src/code/jpegdecoder.o" diff --git a/src/audio/lib/heap.c b/src/audio/lib/heap.c index 0ebd3b0c8c..11f1f2d93c 100644 --- a/src/audio/lib/heap.c +++ b/src/audio/lib/heap.c @@ -1396,6 +1396,9 @@ typedef struct { /* 0xC */ u8 newMedium; } StorageChange; // size = 0x10 +s32 D_801FD120; +static s32 sBssPad[3]; + void AudioHeap_ChangeStorage(StorageChange* change, Sample* sample) { if ((sample != NULL) && ((sample->medium == change->newMedium) || (D_801FD120 != 1)) && ((sample->medium == MEDIUM_RAM) || (D_801FD120 != 0))) { diff --git a/src/audio/sequence.c b/src/audio/sequence.c index 7d37a0ae99..9cb3ac1b9c 100644 --- a/src/audio/sequence.c +++ b/src/audio/sequence.c @@ -24,6 +24,14 @@ AudioSeq_ProcessSeqCmd((SEQCMD_OP_SET_SEQPLAYER_VOLUME << 28) | ((u8)(seqPlayerIndex) << 24) | \ ((u8)(duration) << 16) | ((u8)((volume)*127.0f))); +SeqRequest sSeqRequests[5][5]; +u8 sNumSeqRequests[5]; +u32 sAudioSeqCmds[0x100]; +ActiveSequence gActiveSeqs[5]; +u8 sResetAudioHeapTimer; +u16 sResetAudioHeapFadeReverbVolume; +u16 sResetAudioHeapFadeReverbVolumeStep; + u8 sSeqCmdWritePos = 0; u8 sSeqCmdReadPos = 0; u8 sStartSeqDisabled = 0; diff --git a/src/audio/session_config.c b/src/audio/session_config.c index 9d97222e8e..e0309468fe 100644 --- a/src/audio/session_config.c +++ b/src/audio/session_config.c @@ -1,6 +1,14 @@ #include "global.h" #include "buffers.h" +static s32 sBssPad[36]; +AudioContext gAudioCtx; +AudioCustomUpdateFunction gAudioCustomUpdateFunction; +AudioCustomSeqFunction gAudioCustomSeqFunction; +AudioCustomReverbFunction gAudioCustomReverbFunction; +AudioCustomSynthFunction gAudioCustomSynthFunction; +static s32 sBssPad2[3]; + const s16 gAudioTatumInit[] = { 0x1C00, // unused TATUMS_PER_BEAT, // gTatumsPerBeat diff --git a/src/boot/O2/gfxprint.c b/src/boot/O2/gfxprint.c index 735514e459..38acfb9526 100644 --- a/src/boot/O2/gfxprint.c +++ b/src/boot/O2/gfxprint.c @@ -7,11 +7,21 @@ #define GFXP_FLAG_ENLARGE (1 << 6) #define GFXP_FLAG_OPEN (1 << 7) -//! TODO: Need to extract -extern u16 sGfxPrintFontTLUT[64]; -extern u16 sGfxPrintRainbowTLUT[16]; -extern u8 sGfxPrintRainbowData[8]; -extern u8 sGfxPrintFontData[2048]; +u64 sGfxPrintFontTLUT[] = { +#include "assets/boot/gfxprint/gfx_print_font_tlut.rgba16.inc.c" +}; + +u64 sGfxPrintRainbowTLUT[] = { +#include "assets/boot/gfxprint/gfx_print_rainbow_tlut.rgba16.inc.c" +}; + +u8 sGfxPrintRainbowFont[] = { +#include "assets/boot/gfxprint/sGfxPrintRainbowFont.bin.inc.c" +}; + +u8 sGfxPrintFont[] = { +#include "assets/boot/gfxprint/sGfxPrintFont.bin.inc.c" +}; void GfxPrint_Setup(GfxPrint* this) { s32 width = 16; @@ -24,7 +34,7 @@ void GfxPrint_Setup(GfxPrint* this) { G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2); gDPSetCombineMode(this->dList++, G_CC_DECALRGBA, G_CC_DECALRGBA); - gDPLoadTextureBlock_4b(this->dList++, sGfxPrintFontData, G_IM_FMT_CI, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, + gDPLoadTextureBlock_4b(this->dList++, sGfxPrintFont, G_IM_FMT_CI, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); gDPLoadTLUT(this->dList++, 64, 256, sGfxPrintFontTLUT); @@ -36,7 +46,7 @@ void GfxPrint_Setup(GfxPrint* this) { gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba); - gDPLoadMultiTile_4b(this->dList++, sGfxPrintRainbowData, 0, 1, G_IM_FMT_CI, 2, 8, 0, 0, 1, 7, 4, + gDPLoadMultiTile_4b(this->dList++, sGfxPrintRainbowFont, 0, 1, G_IM_FMT_CI, 2, 8, 0, 0, 1, 7, 4, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 1, 3, G_TX_NOLOD, G_TX_NOLOD); gDPLoadTLUT(this->dList++, 16, 320, sGfxPrintRainbowTLUT); diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index 6b44092b1f..2838d687c6 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -751,6 +751,7 @@ 0x801FD5A0 : "voice_internal", 0x801FD710 : "code_801A5BD0", 0x801FFD00 : "sequence", + 0x80200BE0 : "session_config", 0x80208E90 : "jpegdecoder", 0x80208EA0 : "gfxbuffers", 0x8024A4C0 : "buffer_audio_heap", diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 7147f9cc28..b2cc8c45f9 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4186,10 +4186,7 @@ 0x801FFD00:("sSeqRequests","UNK_TYPE1","",0x1), 0x801FFD34:("sNumSeqRequests","UNK_TYPE1","",0x1), 0x801FFD40:("sAudioSeqCmds","u32","[0x100]",0x400), - 0x80200140:("gActiveSeqs","UNK_TYPE1","",0x1), - 0x8020034A:("D_8020034A","UNK_TYPE1","",0x1), - 0x80200B88:("D_80200B88","UNK_TYPE1","",0x1), - 0x80200BBA:("D_80200BBA","UNK_TYPE1","",0x1), + 0x80200140:("gActiveSeqs","UNK_TYPE1","",0xA8C), 0x80200BCC:("sResetAudioHeapTimer","UNK_TYPE1","",0x1), 0x80200BCE:("sResetAudioHeapFadeReverbVolume","UNK_TYPE1","",0x1), 0x80200BD0:("sResetAudioHeapFadeReverbVolumeStep","UNK_TYPE1","",0x1),