From d3a8ade6bae030b587cfbe7aa2d76117d1e54a02 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Wed, 12 Jan 2022 12:58:26 +1100 Subject: [PATCH] Migrate Remaining Audio Data & Cleanup some Audio Data externs (#1097) * Import code_800F7260.bss.s * Import code_800F9280.data.s * format * cleanup externs * Move bss to next file * Move struct_8016E320 (BgmRequests) back to file * Move data to init_params, remove data pad (can't remove bss pad), ReverbSettings * remove extra spacing * Remove data/bss comments --- data/code_800F7260.bss.s | 85 ---------------------------- data/code_800F9280.data.s | 104 ----------------------------------- include/variables.h | 5 +- spec | 2 - src/code/audio_init_params.c | 81 +++++++++++++++++++++++++++ src/code/code_800EC960.c | 5 -- src/code/code_800F7260.c | 34 ++++++------ src/code/code_800F9280.c | 26 ++++++--- 8 files changed, 118 insertions(+), 224 deletions(-) delete mode 100644 data/code_800F7260.bss.s delete mode 100644 data/code_800F9280.data.s diff --git a/data/code_800F7260.bss.s b/data/code_800F7260.bss.s deleted file mode 100644 index 7a55499e0e..0000000000 --- a/data/code_800F7260.bss.s +++ /dev/null @@ -1,85 +0,0 @@ -.include "macro.inc" - -# assembler directives -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 # allow use of 64-bit general purpose registers - -.section .bss - -.balign 16 - -glabel D_8016BAD0 - .space 0x1B0 - -glabel D_8016BC80 - .space 0x240 - -glabel D_8016BEC0 - .space 0x420 - -glabel D_8016C2E0 - .space 0x3C0 - -glabel D_8016C6A0 - .space 0x180 - -glabel D_8016C820 - .space 0x90 - -glabel D_8016C8B0 - .space 0xF0 - -glabel sSoundRequests - .space 0x1800 - -glabel sSoundBankListEnd - .space 0x8 - -glabel sSoundBankFreeListStart - .space 0x8 - -glabel sSoundBankUnused - .space 0x8 - -glabel gActiveSounds - .space 0xA8 - -glabel sCurSfxPlayerChannelIdx - .space 0x4 - -glabel gSoundBankMuted - .space 0xC - -glabel sUnusedBankLerp - .space 0x70 - -glabel gAudioSfxSwapSource - .space 0x18 - -glabel gAudioSfxSwapTarget - .space 0x18 - -glabel gAudioSfxSwapMode - .space 0x10 - -glabel D_8016E320 - .space 0x28 - -glabel D_8016E348 - .space 0x8 - -glabel sAudioSeqCmds - .space 0x400 - -glabel D_8016E750 - .space 0x990 - -glabel D_8016F0E0 # unused? - .space 0xA0 - -glabel gAudioContext - .space 0x6450 - -glabel D_801755D0 - .space 0x20 diff --git a/data/code_800F9280.data.s b/data/code_800F9280.data.s deleted file mode 100644 index a55ab4d8aa..0000000000 --- a/data/code_800F9280.data.s +++ /dev/null @@ -1,104 +0,0 @@ -.include "macro.inc" - -# assembler directives -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 # allow use of 64-bit general purpose registers - -.section .data - -.balign 16 - -glabel sSeqCmdWrPos - .incbin "baserom.z64", 0xBAA5A0, 0x4 - -glabel sSeqCmdRdPos - .incbin "baserom.z64", 0xBAA5A4, 0x4 - -glabel D_80133408 - .incbin "baserom.z64", 0xBAA5A8, 0x4 - -glabel D_8013340C - .incbin "baserom.z64", 0xBAA5AC, 0x4 - -glabel D_80133410 - .incbin "baserom.z64", 0xBAA5B0, 0x4 - -glabel gAudioSpecId - .incbin "baserom.z64", 0xBAA5B4, 0x4 - -glabel D_80133418 - .incbin "baserom.z64", 0xBAA5B8, 0x8 - -glabel D_80133420 - .incbin "baserom.z64", 0xBAA5C0, 0x48 - -glabel D_80133468 - .incbin "baserom.z64", 0xBAA608, 0x48 - -glabel D_801334B0 - .incbin "baserom.z64", 0xBAA650, 0x90 - -glabel D_80133540 - .incbin "baserom.z64", 0xBAA6E0, 0x48 - -glabel D_80133588 - .incbin "baserom.z64", 0xBAA728, 0x48 - -glabel D_801335D0 - .incbin "baserom.z64", 0xBAA770, 0x48 - -glabel D_80133618 - .incbin "baserom.z64", 0xBAA7B8, 0x48 - -glabel D_80133660 - .incbin "baserom.z64", 0xBAA800, 0x48 - -glabel D_801336A8 - .incbin "baserom.z64", 0xBAA848, 0x48 - -glabel D_801336F0 - .incbin "baserom.z64", 0xBAA890, 0x48 - -glabel D_80133738 - .incbin "baserom.z64", 0xBAA8D8, 0x90 - -glabel gAudioSpecs - .incbin "baserom.z64", 0xBAA968, 0xC - .word D_80133420 - .incbin "baserom.z64", 0xBAA978, 0x34 - .word D_80133468 - .incbin "baserom.z64", 0xBAA9B0, 0x34 - .word D_801334B0 - .incbin "baserom.z64", 0xBAA9E8, 0x34 - .word D_80133540 - .incbin "baserom.z64", 0xBAAA20, 0x34 - .word D_80133588 - .incbin "baserom.z64", 0xBAAA58, 0x34 - .word D_801335D0 - .incbin "baserom.z64", 0xBAAA90, 0x34 - .word D_80133618 - .incbin "baserom.z64", 0xBAAAC8, 0x34 - .word D_80133660 - .incbin "baserom.z64", 0xBAAB00, 0x34 - .word D_801336A8 - .incbin "baserom.z64", 0xBAAB38, 0x34 - .word D_80133660 - .incbin "baserom.z64", 0xBAAB70, 0x34 - .word D_801336F0 - .incbin "baserom.z64", 0xBAABA8, 0x34 - .word D_80133738 - .incbin "baserom.z64", 0xBAABE0, 0x34 - .word D_80133738 - .incbin "baserom.z64", 0xBAAC18, 0x34 - .word D_80133420 - .incbin "baserom.z64", 0xBAAC50, 0x34 - .word D_80133660 - .incbin "baserom.z64", 0xBAAC88, 0x34 - .word D_80133420 - .incbin "baserom.z64", 0xBAACC0, 0x34 - .word D_80133420 - .incbin "baserom.z64", 0xBAACF8, 0x34 - .word D_801334B0 - .incbin "baserom.z64", 0xBAAD30, 0x30 - \ No newline at end of file diff --git a/include/variables.h b/include/variables.h index 24bac80210..429e1a775e 100644 --- a/include/variables.h +++ b/include/variables.h @@ -210,14 +210,13 @@ extern volatile OSTime gRSPOtherTotalTime; extern volatile OSTime gRDPTotalTime; extern FaultThreadStruct gFaultStruct; -// data/code_800F7260.bss.s extern ActiveSound gActiveSounds[7][MAX_CHANNELS_PER_BANK]; // total size = 0xA8 extern u8 gSoundBankMuted[]; +extern u8 D_801333F0; +extern u8 gAudioSfxSwapOff; extern u16 gAudioSfxSwapSource[10]; extern u16 gAudioSfxSwapTarget[10]; extern u8 gAudioSfxSwapMode[10]; -extern u8 D_8016E348[4]; -extern u32 sAudioSeqCmds[0x100]; extern unk_D_8016E750 D_8016E750[4]; extern AudioContext gAudioContext; extern void(*D_801755D0)(void); diff --git a/spec b/spec index c45195200f..a780a42b38 100644 --- a/spec +++ b/spec @@ -421,9 +421,7 @@ beginseg include "build/src/code/code_800EC960.o" include "build/src/code/audio_sound_params.o" include "build/src/code/code_800F7260.o" - include "build/data/code_800F7260.bss.o" include "build/src/code/code_800F9280.o" - include "build/data/code_800F9280.data.o" include "build/src/code/audio_init_params.o" include "build/src/code/logseverity.o" include "build/src/code/gfxprint.o" diff --git a/src/code/audio_init_params.c b/src/code/audio_init_params.c index f7528deed0..0cebdf5964 100644 --- a/src/code/audio_init_params.c +++ b/src/code/audio_init_params.c @@ -1,7 +1,88 @@ #include "global.h" +u8 D_8016F0E0[0xA0]; // unused +AudioContext gAudioContext; +void (*D_801755D0)(void); +s32 D_801755D8[3]; // unused + const s16 D_8014A6C0[] = { 0x1C00, // unused 0x0030, // gTatumsPerBeat }; + const AudioContextInitSizes D_8014A6C4 = { 0x37F00, 0xE0E0, 0xBCE0 }; + +ReverbSettings D_80133420[][3] = { + { + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + { 1, 0x20, 0x0800, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x0000, 0x0, 0x0 }, + }, + { + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + { 1, 0x30, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x0000, 0xB, 0xB }, + }, + { + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + { 1, 0x38, 0x2800, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x0000, 0x7, 0x7 }, + }, + { + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + { 1, 0x50, 0x5000, 0, 0, 0x7FFF, 0x1000, 0x1000, 0xFF, 0x3000, 0x7, 0x7 }, + }, + { + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + { 1, 0x40, 0x5000, 0, 0, 0x7FFF, 0x1800, 0x1800, 0xFF, 0x3000, 0x7, 0x7 }, + }, + { + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + { 1, 0x40, 0x5C00, 0, 0, 0x7FFF, 0x2000, 0x2000, 0xFF, 0x3000, 0x4, 0x4 }, + }, + { + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + { 1, 0x30, 0x6000, 0, 0, 0x7FFF, 0x1000, 0x1000, 0xFF, 0x3000, 0xA, 0xA }, + }, + { + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + { 1, 0x30, 0x6800, 0, 0, 0x7FFF, 0x1400, 0x1400, 0xFF, 0x3000, 0x6, 0x6 }, + }, + { + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + { 2, 0x50, 0x5000, 0, 0, 0x7FFF, 0xD000, 0x3000, 0xFF, 0x3000, 0x0, 0x0 }, + }, + { + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + { 1, 0x20, 0x0000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x0000, 0x0, 0x0 }, + }, + { + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + { 1, 0x30, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x0000, 0xB, 0xB }, + }, + { + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + }, + { + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + { 1, 0x40, 0x5000, 0, 0, 0x7FFF, 0x0000, 0x0000, 0xFF, 0x3000, 0x0, 0x0 }, + }, +}; + +AudioSpec gAudioSpecs[18] = { + { 32000, 1, 24, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x4000, 0x2880, 0, 0, 0 }, + { 32000, 1, 24, 4, 0, 0, 2, D_80133420[1], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 }, + { 32000, 1, 24, 4, 0, 0, 2, D_80133420[2], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 }, + { 32000, 1, 23, 4, 0, 0, 2, D_80133420[4], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 }, + { 32000, 1, 23, 4, 0, 0, 2, D_80133420[5], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 }, + { 32000, 1, 24, 4, 0, 0, 2, D_80133420[6], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 }, + { 32000, 1, 24, 4, 0, 0, 2, D_80133420[7], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 }, + { 32000, 1, 23, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 }, + { 32000, 1, 24, 4, 0, 0, 2, D_80133420[9], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 }, + { 32000, 1, 23, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 }, + { 32000, 1, 28, 3, 0, 0, 2, D_80133420[10], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x2800, 0x2880, 0, 0, 0 }, + { 32000, 1, 28, 3, 0, 0, 1, D_80133420[11], 0x300, 0x200, 0x7FFF, 0, 0x4800, 0, 0x4000, 0, 0, 0, 0 }, + { 32000, 1, 28, 3, 0, 0, 1, D_80133420[11], 0x300, 0x200, 0x7FFF, 0, 0, 0, 0x4000, 0x4800, 0, 0, 0 }, + { 32000, 1, 22, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 }, + { 32000, 1, 22, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 }, + { 32000, 1, 16, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 }, + { 22050, 1, 24, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 }, + { 32000, 1, 24, 4, 0, 0, 2, D_80133420[2], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3600, 0x2600, 0, 0, 0 }, +}; diff --git a/src/code/code_800EC960.c b/src/code/code_800EC960.c index f10ebe3499..583d871bf5 100644 --- a/src/code/code_800EC960.c +++ b/src/code/code_800EC960.c @@ -84,8 +84,6 @@ typedef enum { #define SFX_PLAYER_CHANNEL_OCARINA 13 -extern f32 D_8012F6B4[]; // from audio_synthesis - u8 gIsLargeSoundBank[7] = { 0, 0, 0, 1, 0, 0, 0 }; // Only the first row of these is supported by sequence 0. (gSfxChannelLayout is always 0.) @@ -1170,9 +1168,6 @@ OcarinaSongInfo gOcarinaSongNotes[OCARINA_SONG_MAX] = { }; // clang-format on -extern u8 D_801333F0; -extern u8 gAudioSfxSwapOff; - /** * BSS */ diff --git a/src/code/code_800F7260.c b/src/code/code_800F7260.c index b04dfb6cf0..188f6d8b21 100644 --- a/src/code/code_800F7260.c +++ b/src/code/code_800F7260.c @@ -32,22 +32,24 @@ s32 D_8013338C = 0; char D_80133390[] = "SEQ H"; char D_80133398[] = " L"; -// bss -extern SoundRequest sSoundRequests[0x100]; -extern SoundBankEntry D_8016BAD0[9]; -extern SoundBankEntry D_8016BC80[12]; -extern SoundBankEntry D_8016BEC0[22]; -extern SoundBankEntry D_8016C2E0[20]; -extern SoundBankEntry D_8016C6A0[8]; -extern SoundBankEntry D_8016C820[3]; -extern SoundBankEntry D_8016C8B0[5]; -extern u8 sSoundBankListEnd[7]; -extern u8 sSoundBankFreeListStart[7]; -extern u8 sSoundBankUnused[7]; -extern u8 sCurSfxPlayerChannelIdx; -extern UnusedBankLerp sUnusedBankLerp[7]; - -// data +SoundBankEntry D_8016BAD0[9]; +SoundBankEntry D_8016BC80[12]; +SoundBankEntry D_8016BEC0[22]; +SoundBankEntry D_8016C2E0[20]; +SoundBankEntry D_8016C6A0[8]; +SoundBankEntry D_8016C820[3]; +SoundBankEntry D_8016C8B0[5]; +SoundRequest sSoundRequests[0x100]; +u8 sSoundBankListEnd[7]; +u8 sSoundBankFreeListStart[7]; +u8 sSoundBankUnused[7]; +ActiveSound gActiveSounds[7][3]; +u8 sCurSfxPlayerChannelIdx; +u8 gSoundBankMuted[7]; +UnusedBankLerp sUnusedBankLerp[7]; +u16 gAudioSfxSwapSource[10]; +u16 gAudioSfxSwapTarget[10]; +u8 gAudioSfxSwapMode[10]; // sSoundRequests ring buffer endpoints. read index <= write index, wrapping around mod 256. u8 sSoundRequestWriteIndex = 0; diff --git a/src/code/code_800F9280.c b/src/code/code_800F9280.c index 381cdf611e..075d609aa8 100644 --- a/src/code/code_800F9280.c +++ b/src/code/code_800F9280.c @@ -2,9 +2,23 @@ #include "global.h" #include "ultra64/abi.h" -extern u8 sSeqCmdRdPos; -extern u8 sSeqCmdWrPos; -extern u8 D_80133410[]; +typedef struct { + u8 unk_0; + u8 unk_1; // importance? +} Struct_8016E320; + +Struct_8016E320 D_8016E320[4][5]; +u8 D_8016E348[4]; +u32 sAudioSeqCmds[0x100]; +unk_D_8016E750 D_8016E750[4]; + +u8 sSeqCmdWrPos = 0; +u8 sSeqCmdRdPos = 0; +u8 D_80133408 = 0; +u8 D_8013340C = 1; +u8 D_80133410[] = { 0, 1, 2, 3 }; +u8 gAudioSpecId = 0; +u8 D_80133418 = 0; // TODO: clean up these macros. They are similar to ones in code_800EC960.c but without casts. #define Audio_StartSeq(playerIdx, fadeTimer, seqId) \ @@ -81,12 +95,6 @@ typedef enum { CMDF } SeqCmdType; -typedef struct { - u8 unk_0; - u8 unk_1; // importance? -} Struct_8016E320; -extern Struct_8016E320 D_8016E320[][5]; // sorted by unk_1, descending - void Audio_ProcessSeqCmd(u32 cmd) { s32 pad[2]; u16 fadeTimer;