mirror of
https://github.com/zeldaret/oot.git
synced 2024-12-26 14:46:16 +00:00
Fix audio strings with -use_readwrite_const and -signed (#1324)
* Fix audio strings with -use_readwrite_const and -signed * Add comments for audio flags in makefile
This commit is contained in:
parent
7254adec9f
commit
1652b7e5d7
8 changed files with 120 additions and 103 deletions
7
Makefile
7
Makefile
|
@ -199,6 +199,13 @@ build/src/code/fmodf.o: OPTFLAGS := -g
|
|||
build/src/code/__osMemset.o: OPTFLAGS := -g
|
||||
build/src/code/__osMemmove.o: OPTFLAGS := -g
|
||||
|
||||
# Use signed chars instead of unsigned for code_800EC960.c (needed to match AudioDebug_ScrPrt)
|
||||
build/src/code/code_800EC960.o: CFLAGS += -signed
|
||||
|
||||
# Put string literals in .data for some audio files (needed to match these files with literals)
|
||||
build/src/code/code_800F7260.o: CFLAGS += -use_readwrite_const
|
||||
build/src/code/code_800F9280.o: CFLAGS += -use_readwrite_const
|
||||
|
||||
build/src/libultra/libc/absf.o: OPTFLAGS := -O2 -g3
|
||||
build/src/libultra/libc/sqrt.o: OPTFLAGS := -O2 -g3
|
||||
build/src/libultra/libc/ll.o: OPTFLAGS := -O1
|
||||
|
|
|
@ -1899,7 +1899,7 @@ void AudioOcarina_MemoryGameInit(u8 minigameRound);
|
|||
s32 AudioOcarina_MemoryGameNextNote(void);
|
||||
void AudioOcarina_PlayLongScarecrowAfterCredits(void);
|
||||
void AudioDebug_Draw(GfxPrint* printer);
|
||||
void AudioDebug_ScrPrt(const s8* str, u16 num);
|
||||
void AudioDebug_ScrPrt(const char* str, u16 num);
|
||||
void func_800F3054(void);
|
||||
void Audio_SetSoundProperties(u8 bankId, u8 entryIdx, u8 channelIdx);
|
||||
void Audio_PlayCutsceneEffectsSequence(u8 csEffectType);
|
||||
|
|
|
@ -140,15 +140,23 @@ extern OcarinaSongButtons gOcarinaSongButtons[];
|
|||
extern SoundParams* gSoundParams[7];
|
||||
extern char D_80133390[];
|
||||
extern char D_80133398[];
|
||||
extern u8 gSoundRequestWriteIndex;
|
||||
extern u8 gSoundRequestReadIndex;
|
||||
extern SoundBankEntry* gSoundBanks[7];
|
||||
extern u8 gSoundBankSizes[];
|
||||
extern u8 gSfxChannelLayout;
|
||||
extern u16 D_801333D0;
|
||||
extern Vec3f gSfxDefaultPos;
|
||||
extern f32 gSfxDefaultFreqAndVolScale;
|
||||
extern s8 gSfxDefaultReverb;
|
||||
extern u8 D_801333F0;
|
||||
extern u8 gAudioSfxSwapOff;
|
||||
extern u8 D_801333F8;
|
||||
extern u8 gSeqCmdWrPos;
|
||||
extern u8 gSeqCmdRdPos;
|
||||
extern u8 D_80133408;
|
||||
extern u8 D_8013340C;
|
||||
extern u8 gSoundModeList[];
|
||||
extern u8 gAudioSpecId;
|
||||
extern u8 D_80133418;
|
||||
extern AudioSpec gAudioSpecs[18];
|
||||
|
@ -200,6 +208,13 @@ extern volatile OSTime gRSPGFXTotalTime;
|
|||
extern volatile OSTime gRSPOtherTotalTime;
|
||||
extern volatile OSTime gRDPTotalTime;
|
||||
|
||||
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 ActiveSound gActiveSounds[7][MAX_CHANNELS_PER_BANK]; // total size = 0xA8
|
||||
extern u8 gSoundBankMuted[];
|
||||
extern u16 gAudioSfxSwapSource[10];
|
||||
|
|
1
spec
1
spec
|
@ -426,6 +426,7 @@ beginseg
|
|||
include "build/src/code/audio_sound_params.o"
|
||||
include "build/src/code/code_800F7260.o"
|
||||
include "build/src/code/code_800F9280.o"
|
||||
include "build/src/code/audio_external_data.o"
|
||||
include "build/src/code/audio_init_params.o"
|
||||
include "build/src/code/logseverity.o"
|
||||
include "build/src/code/gfxprint.o"
|
||||
|
|
69
src/code/audio_external_data.c
Normal file
69
src/code/audio_external_data.c
Normal file
|
@ -0,0 +1,69 @@
|
|||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
|
||||
// sSoundRequests ring buffer endpoints. read index <= write index, wrapping around mod 256.
|
||||
u8 gSoundRequestWriteIndex = 0;
|
||||
u8 gSoundRequestReadIndex = 0;
|
||||
|
||||
/**
|
||||
* Array of pointers to arrays of SoundBankEntry of sizes: 9, 12, 22, 20, 8, 3, 5
|
||||
*
|
||||
* 0 : Player Bank size 9
|
||||
* 1 : Item Bank size 12
|
||||
* 2 : Environment Bank size 22
|
||||
* 3 : Enemy Bank size 20
|
||||
* 4 : System Bank size 8
|
||||
* 5 : Ocarina Bank size 3
|
||||
* 6 : Voice Bank size 5
|
||||
*/
|
||||
SoundBankEntry* gSoundBanks[7] = {
|
||||
D_8016BAD0, D_8016BC80, D_8016BEC0, D_8016C2E0, D_8016C6A0, D_8016C820, D_8016C8B0,
|
||||
};
|
||||
|
||||
u8 gSoundBankSizes[ARRAY_COUNT(gSoundBanks)] = {
|
||||
ARRAY_COUNT(D_8016BAD0), ARRAY_COUNT(D_8016BC80), ARRAY_COUNT(D_8016BEC0), ARRAY_COUNT(D_8016C2E0),
|
||||
ARRAY_COUNT(D_8016C6A0), ARRAY_COUNT(D_8016C820), ARRAY_COUNT(D_8016C8B0),
|
||||
};
|
||||
|
||||
u8 gSfxChannelLayout = 0;
|
||||
|
||||
u16 D_801333D0 = 0;
|
||||
|
||||
// The center of the screen in projected coordinates.
|
||||
// Gives the impression that the sfx has no specific location
|
||||
Vec3f gSfxDefaultPos = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
// Reused as either frequency or volume multiplicative scaling factor
|
||||
// Does not alter or change frequency or volume
|
||||
f32 gSfxDefaultFreqAndVolScale = 1.0f;
|
||||
|
||||
s32 D_801333E4 = 0; // unused
|
||||
|
||||
// Adds no reverb to the existing reverb
|
||||
s8 gSfxDefaultReverb = 0;
|
||||
|
||||
s32 D_801333EC = 0; // unused
|
||||
|
||||
u8 D_801333F0 = 0;
|
||||
|
||||
u8 gAudioSfxSwapOff = 0;
|
||||
|
||||
u8 D_801333F8 = 0;
|
||||
|
||||
s32 D_801333FC = 0; // unused
|
||||
|
||||
u8 gSeqCmdWrPos = 0;
|
||||
u8 gSeqCmdRdPos = 0;
|
||||
u8 D_80133408 = 0;
|
||||
u8 D_8013340C = 1;
|
||||
|
||||
u8 gSoundModeList[] = {
|
||||
SOUNDMODE_STEREO,
|
||||
SOUNDMODE_HEADSET,
|
||||
SOUNDMODE_SURROUND,
|
||||
SOUNDMODE_MONO,
|
||||
};
|
||||
|
||||
u8 gAudioSpecId = 0;
|
||||
|
||||
u8 D_80133418 = 0;
|
|
@ -1225,7 +1225,7 @@ s8 D_8016B7DC;
|
|||
f32 D_8016B7E0;
|
||||
u16 D_8016B7E4;
|
||||
struct {
|
||||
s8 str[5];
|
||||
char str[5];
|
||||
u16 num;
|
||||
} sAudioScrPrtBuf[SCROLL_PRINT_BUF_SIZE];
|
||||
u8 sRiverSoundMainBgmVol;
|
||||
|
@ -3586,18 +3586,18 @@ void AudioDebug_ProcessInput_SfxParamChg(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void AudioDebug_ScrPrt(const s8* str, u16 num) {
|
||||
void AudioDebug_ScrPrt(const char* str, u16 num) {
|
||||
u8 i = 0;
|
||||
|
||||
sAudioScrPrtBuf[sAudioScrPrtInd].num = num;
|
||||
|
||||
while (str[i] != 0) {
|
||||
while (str[i] != '\0') {
|
||||
sAudioScrPrtBuf[sAudioScrPrtInd].str[i] = str[i];
|
||||
i++;
|
||||
}
|
||||
|
||||
while (i < 5) {
|
||||
sAudioScrPrtBuf[sAudioScrPrtInd].str[i] = 0;
|
||||
sAudioScrPrtBuf[sAudioScrPrtInd].str[i] = '\0';
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,20 +18,6 @@ typedef struct {
|
|||
/* 0x0C */ u16 remainingFrames;
|
||||
} UnusedBankLerp; // size = 0x10
|
||||
|
||||
// rodata for Audio_ProcessSoundRequest (this file)
|
||||
// (probably moved to .data due to -use_readwrite_const)
|
||||
char D_80133340[] = "SE";
|
||||
|
||||
// rodata for Audio_ChooseActiveSounds (this file)
|
||||
char D_80133344[] = VT_COL(RED, WHITE) "<INAGAKI CHECK> dist over! flag:%04X ptr:%08X pos:%f-%f-%f" VT_RST "\n";
|
||||
|
||||
// file padding
|
||||
s32 D_8013338C = 0;
|
||||
|
||||
// rodata for Audio_ProcessSeqCmd (code_800F9280.c)
|
||||
char D_80133390[] = "SEQ H";
|
||||
char D_80133398[] = " L";
|
||||
|
||||
SoundBankEntry D_8016BAD0[9];
|
||||
SoundBankEntry D_8016BC80[12];
|
||||
SoundBankEntry D_8016BEC0[22];
|
||||
|
@ -51,55 +37,6 @@ u16 gAudioSfxSwapSource[10];
|
|||
u16 gAudioSfxSwapTarget[10];
|
||||
u8 gAudioSfxSwapMode[10];
|
||||
|
||||
// sSoundRequests ring buffer endpoints. read index <= write index, wrapping around mod 256.
|
||||
u8 sSoundRequestWriteIndex = 0;
|
||||
u8 sSoundRequestReadIndex = 0;
|
||||
|
||||
/**
|
||||
* Array of pointers to arrays of SoundBankEntry of sizes: 9, 12, 22, 20, 8, 3, 5
|
||||
*
|
||||
* 0 : Player Bank size 9
|
||||
* 1 : Item Bank size 12
|
||||
* 2 : Environment Bank size 22
|
||||
* 3 : Enemy Bank size 20
|
||||
* 4 : System Bank size 8
|
||||
* 5 : Ocarina Bank size 3
|
||||
* 6 : Voice Bank size 5
|
||||
*/
|
||||
SoundBankEntry* gSoundBanks[7] = {
|
||||
D_8016BAD0, D_8016BC80, D_8016BEC0, D_8016C2E0, D_8016C6A0, D_8016C820, D_8016C8B0,
|
||||
};
|
||||
|
||||
u8 sBankSizes[ARRAY_COUNT(gSoundBanks)] = {
|
||||
ARRAY_COUNT(D_8016BAD0), ARRAY_COUNT(D_8016BC80), ARRAY_COUNT(D_8016BEC0), ARRAY_COUNT(D_8016C2E0),
|
||||
ARRAY_COUNT(D_8016C6A0), ARRAY_COUNT(D_8016C820), ARRAY_COUNT(D_8016C8B0),
|
||||
};
|
||||
|
||||
u8 gSfxChannelLayout = 0;
|
||||
|
||||
u16 D_801333D0 = 0;
|
||||
|
||||
// The center of the screen in projected coordinates.
|
||||
// Gives the impression that the sfx has no specific location
|
||||
Vec3f gSfxDefaultPos = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
// Reused as either frequency or volume multiplicative scaling factor
|
||||
// Does not alter or change frequency or volume
|
||||
f32 gSfxDefaultFreqAndVolScale = 1.0f;
|
||||
|
||||
s32 D_801333E4 = 0; // unused
|
||||
|
||||
// Adds no reverb to the existing reverb
|
||||
s8 gSfxDefaultReverb = 0;
|
||||
|
||||
s32 D_801333EC = 0; // unused
|
||||
|
||||
u8 D_801333F0 = 0;
|
||||
|
||||
u8 gAudioSfxSwapOff = 0;
|
||||
|
||||
u8 D_801333F8 = 0;
|
||||
|
||||
void Audio_SetSoundBanksMute(u16 muteMask) {
|
||||
u8 bankId;
|
||||
|
||||
|
@ -132,7 +69,7 @@ void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32
|
|||
SoundRequest* req;
|
||||
|
||||
if (!gSoundBankMuted[SFX_BANK_SHIFT(sfxId)]) {
|
||||
req = &sSoundRequests[sSoundRequestWriteIndex];
|
||||
req = &sSoundRequests[gSoundRequestWriteIndex];
|
||||
if (!gAudioSfxSwapOff) {
|
||||
for (i = 0; i < 10; i++) {
|
||||
if (sfxId == gAudioSfxSwapSource[i]) {
|
||||
|
@ -145,8 +82,8 @@ void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32
|
|||
req->freqScale = freqScale;
|
||||
req->vol = vol;
|
||||
req->reverbAdd = reverbAdd;
|
||||
sSoundRequestWriteIndex++;
|
||||
req = &sSoundRequests[sSoundRequestWriteIndex];
|
||||
gSoundRequestWriteIndex++;
|
||||
req = &sSoundRequests[gSoundRequestWriteIndex];
|
||||
}
|
||||
i = 10; // "break;"
|
||||
}
|
||||
|
@ -158,16 +95,16 @@ void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32
|
|||
req->freqScale = freqScale;
|
||||
req->vol = vol;
|
||||
req->reverbAdd = reverbAdd;
|
||||
sSoundRequestWriteIndex++;
|
||||
gSoundRequestWriteIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
void Audio_RemoveMatchingSoundRequests(u8 aspect, SoundBankEntry* cmp) {
|
||||
SoundRequest* req;
|
||||
s32 remove;
|
||||
u8 i = sSoundRequestReadIndex;
|
||||
u8 i = gSoundRequestReadIndex;
|
||||
|
||||
for (; i != sSoundRequestWriteIndex; i++) {
|
||||
for (; i != gSoundRequestWriteIndex; i++) {
|
||||
remove = false;
|
||||
req = &sSoundRequests[i];
|
||||
switch (aspect) {
|
||||
|
@ -219,14 +156,14 @@ void Audio_ProcessSoundRequest(void) {
|
|||
u8 evictImportance;
|
||||
u8 evictIndex;
|
||||
|
||||
req = &sSoundRequests[sSoundRequestReadIndex];
|
||||
req = &sSoundRequests[gSoundRequestReadIndex];
|
||||
evictIndex = 0x80;
|
||||
if (req->sfxId == 0) {
|
||||
return;
|
||||
}
|
||||
bankId = SFX_BANK(req->sfxId);
|
||||
if ((1 << bankId) & D_801333F0) {
|
||||
AudioDebug_ScrPrt((const s8*)D_80133340, req->sfxId);
|
||||
AudioDebug_ScrPrt("SE", req->sfxId);
|
||||
bankId = SFX_BANK(req->sfxId);
|
||||
}
|
||||
count = 0;
|
||||
|
@ -387,8 +324,9 @@ void Audio_ChooseActiveSounds(u8 bankId) {
|
|||
} else {
|
||||
if (entry->dist > 0x7FFFFFD0) {
|
||||
entry->dist = 0x70000008;
|
||||
osSyncPrintf(D_80133344, entry->sfxId, entry->posX, entry->posZ, *entry->posX, *entry->posY,
|
||||
*entry->posZ);
|
||||
osSyncPrintf(VT_COL(RED, WHITE) "<INAGAKI CHECK> dist over! "
|
||||
"flag:%04X ptr:%08X pos:%f-%f-%f" VT_RST "\n",
|
||||
entry->sfxId, entry->posX, entry->posZ, *entry->posX, *entry->posY, *entry->posZ);
|
||||
}
|
||||
temp3 = entry->sfxId; // fake
|
||||
entry->priority = (u32)entry->dist + (SQ(0xFF - sfxImportance) * SQ(76)) + temp3 - temp3;
|
||||
|
@ -694,9 +632,9 @@ void Audio_StopSfxById(u32 sfxId) {
|
|||
}
|
||||
|
||||
void Audio_ProcessSoundRequests(void) {
|
||||
while (sSoundRequestWriteIndex != sSoundRequestReadIndex) {
|
||||
while (gSoundRequestWriteIndex != gSoundRequestReadIndex) {
|
||||
Audio_ProcessSoundRequest();
|
||||
sSoundRequestReadIndex++;
|
||||
gSoundRequestReadIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -752,8 +690,8 @@ void Audio_ResetSounds(void) {
|
|||
u8 i;
|
||||
u8 entryIndex;
|
||||
|
||||
sSoundRequestWriteIndex = 0;
|
||||
sSoundRequestReadIndex = 0;
|
||||
gSoundRequestWriteIndex = 0;
|
||||
gSoundRequestReadIndex = 0;
|
||||
D_801333D0 = 0;
|
||||
for (bankId = 0; bankId < ARRAY_COUNT(gSoundBanks); bankId++) {
|
||||
sSoundBankListEnd[bankId] = 0;
|
||||
|
@ -771,7 +709,7 @@ void Audio_ResetSounds(void) {
|
|||
for (bankId = 0; bankId < ARRAY_COUNT(gSoundBanks); bankId++) {
|
||||
gSoundBanks[bankId][0].prev = 0xFF;
|
||||
gSoundBanks[bankId][0].next = 0xFF;
|
||||
for (i = 1; i < sBankSizes[bankId] - 1; i++) {
|
||||
for (i = 1; i < gSoundBankSizes[bankId] - 1; i++) {
|
||||
gSoundBanks[bankId][i].prev = i - 1;
|
||||
gSoundBanks[bankId][i].next = i + 1;
|
||||
}
|
||||
|
|
|
@ -12,19 +12,6 @@ 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 sSoundModeList[] = {
|
||||
SOUNDMODE_STEREO,
|
||||
SOUNDMODE_HEADSET,
|
||||
SOUNDMODE_SURROUND,
|
||||
SOUNDMODE_MONO,
|
||||
};
|
||||
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) \
|
||||
Audio_QueueSeqCmd(0x00000000 | ((playerIdx) << 24) | ((fadeTimer) << 16) | (seqId))
|
||||
|
@ -122,8 +109,8 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
|||
f32 freqScale;
|
||||
|
||||
if (D_8013340C && (cmd & 0xF0000000) != 0x70000000) {
|
||||
AudioDebug_ScrPrt((const s8*)D_80133390, (cmd >> 16) & 0xFFFF); // "SEQ H"
|
||||
AudioDebug_ScrPrt((const s8*)D_80133398, cmd & 0xFFFF); // " L"
|
||||
AudioDebug_ScrPrt("SEQ H", (cmd >> 16) & 0xFFFF);
|
||||
AudioDebug_ScrPrt(" L", cmd & 0xFFFF);
|
||||
}
|
||||
|
||||
op = cmd >> 28;
|
||||
|
@ -347,7 +334,7 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
|||
switch (subOp) {
|
||||
case 0:
|
||||
// set sound mode
|
||||
Audio_QueueCmdS32(0xF0000000, sSoundModeList[val]);
|
||||
Audio_QueueCmdS32(0xF0000000, gSoundModeList[val]);
|
||||
break;
|
||||
case 1:
|
||||
// set sequence starting disabled?
|
||||
|
@ -370,12 +357,12 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
|||
}
|
||||
|
||||
void Audio_QueueSeqCmd(u32 cmd) {
|
||||
sAudioSeqCmds[sSeqCmdWrPos++] = cmd;
|
||||
sAudioSeqCmds[gSeqCmdWrPos++] = cmd;
|
||||
}
|
||||
|
||||
void Audio_ProcessSeqCmds(void) {
|
||||
while (sSeqCmdWrPos != sSeqCmdRdPos) {
|
||||
Audio_ProcessSeqCmd(sAudioSeqCmds[sSeqCmdRdPos++]);
|
||||
while (gSeqCmdWrPos != gSeqCmdRdPos) {
|
||||
Audio_ProcessSeqCmd(sAudioSeqCmds[gSeqCmdRdPos++]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,7 +376,7 @@ u16 func_800FA0B4(u8 playerIdx) {
|
|||
s32 func_800FA11C(u32 arg0, u32 arg1) {
|
||||
u8 i;
|
||||
|
||||
for (i = sSeqCmdRdPos; i != sSeqCmdWrPos; i++) {
|
||||
for (i = gSeqCmdRdPos; i != gSeqCmdWrPos; i++) {
|
||||
if (arg0 == (sAudioSeqCmds[i] & arg1)) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue